diff --git "a/assets/ArtifactWorkspace-DDaC0452.js" "b/assets/ArtifactWorkspace-DDaC0452.js" deleted file mode 100644--- "a/assets/ArtifactWorkspace-DDaC0452.js" +++ /dev/null @@ -1,128 +0,0 @@ -var ih=Object.defineProperty;var ch=(e,t,r)=>t in e?ih(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var le=(e,t,r)=>ch(e,typeof t!="symbol"?t+"":t,r);import{d as _r,r as Pt,j as w,z as K,N as Yl,E as ht,X as Xl,C as lh}from"./index-DSwBvlRC.js";import{u as eu,P as tu,b as ru,M as uh,R as dh,W as fh,d as na,A as hh,n as ph,L as mh,N as nu,O as gh}from"./chatLaunch-CuDDg_RD.js";import"./katex.min-BSBacQyE.js";import{H as Rs,a as Ts,b as js}from"./hover-card-BAXaG9_6.js";import{u as ur}from"./useQuery-BODnKxZK.js";import{f as _h,p as yh}from"./github-CqDoVlVl.js";import{G as sa}from"./github-jAttqsZv.js";import{r as vh,a as $h,P as su}from"./PaperPreviewLink-BNlS5Jmo.js";import{M as wh,r as bh,d as Sh}from"./index-B2LaHILf.js";import{c as Ec}from"./chat-CNspOisr.js";import{F as Eh}from"./file-text-Bueb87Jm.js";import{E as kh}from"./external-link-oiJ5fbTV.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 Ph=_r("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 go=_r("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 oa=_r("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 Rh=_r("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 Th=_r("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 jh=_r("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=_r("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=Pt.useId(),s=Pt.useRef(null),[o,a]=Pt.useState(!1),[i,c]=Pt.useState(!1),l=`Selection · Page ${e.page}`;return Pt.useEffect(()=>{const d=s.current;!d||o||c(d.scrollHeight>d.clientHeight+1)},[o,e.text]),w.jsxs("div",{className:`chat-paper-selection${t?" is-editable":""}`,children:[w.jsxs("div",{className:"chat-paper-selection-header",children:[w.jsx("span",{className:"chat-paper-selection-label",children:l}),w.jsxs("div",{className:"chat-paper-selection-actions",children:[(i||o)&&w.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&&w.jsx("button",{type:"button",className:"chat-paper-selection-remove","aria-label":"Remove selected paper passage",onClick:r,children:"Remove"})]})]}),w.jsx("blockquote",{id:n,ref:s,className:`chat-paper-selection-quote${o?" is-expanded":""}`,children:e.text})]})}const Nh=ph(),KT=({onSend:e,busy:t,placeholder:r,autoFocus:n,draft:s,onDraftChange:o,onStop:a,models:i=[],selectedModel:c,onModelChange:l,disabled:d=!1,describedBy:f,paperMentionsEnabled:m=!1,paperSelectionEnabled:g=!0,webSearchAvailable:_=!1,webSearchEnabled:y=!1,onWebSearchChange:v,reasoningEffort:h="low",onReasoningEffortChange:$})=>{const[E,R]=Pt.useState(Nh),k=s??E,N=Pt.useRef(null),[A,F]=Pt.useState(0),D=H=>{s||R(H),o==null||o(H)},L=eu({draft:k,onChange:D,enabled:m,textareaRef:N});Pt.useEffect(()=>{const H=N.current;H&&(H.style.height="auto",H.style.height=`${Math.min(H.scrollHeight,200)}px`)},[k.text]),Pt.useEffect(()=>{var H;n&&((H=N.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 w.jsxs("div",{className:"chat-composer",children:[k.paperSelection&&w.jsx(Cs,{selection:k.paperSelection,editable:!0,onRemove:()=>{var H;D({text:k.text,paperMentions:k.paperMentions}),(H=N.current)==null||H.focus()}}),B&&w.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."}),w.jsxs("div",{className:"chat-composer-textarea-wrap",children:[w.jsx(tu,{text:k.text,mentions:k.paperMentions,scrollTop:A}),w.jsx("textarea",{ref:N,rows:1,value:k.text,placeholder:r||(k.paperSelection?"Ask about this selection…":"Ask anything about research…"),onChange:H=>L.updateText(H.target.value,H.target.selectionStart),onSelect:H=>L.refresh(H.currentTarget.selectionStart),onClick:H=>L.refresh(H.currentTarget.selectionStart),onScroll:H=>F(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(L.close,0)},onKeyDown:H=>{L.keyDown(H)||H.key==="Enter"&&!H.shiftKey&&!H.nativeEvent.isComposing&&(H.preventDefault(),Z())},role:"combobox","aria-expanded":L.open,"aria-controls":L.open?L.pickerId:void 0,"aria-activedescendant":L.open&&L.results.length?`${L.optionIdPrefix}-${L.activeIndex}`:void 0,"aria-autocomplete":"list","aria-describedby":[f,L.message?"chat-paper-mention-message":null].filter(Boolean).join(" ")||void 0}),w.jsx(ru,{open:L.open,query:L.query,results:L.results,activeIndex:L.activeIndex,loading:L.loading,error:L.error,onSelect:L.select,id:L.pickerId,optionIdPrefix:L.optionIdPrefix})]}),L.message&&w.jsx("div",{id:"chat-paper-mention-message",className:"chat-paper-mention-message",role:"alert",children:L.message}),w.jsxs("div",{className:"chat-composer-row",children:[w.jsxs("div",{className:"chat-composer-tools",children:[i.length>0&&c&&l&&w.jsx(uh,{models:i,selectedModel:c,onModelChange:l,disabled:t}),$&&w.jsx(dh,{value:h,onChange:$,disabled:t}),_&&v&&w.jsx(fh,{enabled:y,onChange:v,disabled:t}),w.jsx("span",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]}),w.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?w.jsx("span",{"aria-hidden":"true",children:"■"}):w.jsx(na,{light:!0}):w.jsx(hh,{})})]})]})},Qs=new Map,ou=e=>{if(!e)return Promise.resolve();const t=Qs.get(e);if(t)return t;const r=new Promise(n=>{const s=new Image;s.onload=()=>{n()},s.onerror=()=>{Qs.delete(e),n()},s.src=e});return Qs.set(e,r),r},Ih=new Set(["huggingface.co","www.huggingface.co"]),Oh=new Set(["api","blog","chat","collections","docs","enterprise","join","login","models","new","organizations","papers","posts","pricing","search","settings","spaces","tasks"]);function xh(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!=="https:"||!Ih.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"&&Oh.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 Ah=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,Mh=({repo:e})=>{const[t,r]=K.useState(!1);return w.jsxs("div",{className:"hf-preview-card",children:[t?w.jsx("div",{className:"hf-preview-fallback","aria-hidden":"true",children:"🤗"}):w.jsx("img",{className:"hf-preview-image","data-testid":"hf-preview-image",src:e.thumbnailUrl,alt:"",loading:"eager",decoding:"async",onError:()=>r(!0)}),w.jsxs("div",{className:"hf-preview-meta",children:[w.jsxs("span",{className:"hf-preview-kind",children:["Hugging Face ",e.type]}),w.jsx("strong",{children:e.repoId}),w.jsx("span",{children:"huggingface.co"})]})]})},zh=({repo:e,children:t})=>{const[r,n]=K.useState(!1),s=K.useRef(null),o=K.useCallback(()=>{ou(e.thumbnailUrl)},[e.thumbnailUrl]);return K.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]),w.jsxs(Rs,{open:r,onOpenChange:a=>{(!a||!Ah())&&n(a)},openDelay:150,closeDelay:100,children:[w.jsx(Ts,{asChild:!0,children:w.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})}),w.jsx(js,{className:"hf-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:w.jsx(Mh,{repo:e})})]})},qh=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,Dh=({repo:e,preview:t,unavailable:r})=>{const[n,s]=K.useState(!1),o=!!(t!=null&&t.avatarUrl)&&!n;return w.jsxs("div",{className:"github-preview-card",children:[o?w.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)}):w.jsx("div",{className:"github-preview-fallback","aria-hidden":"true",children:w.jsx(sa,{})}),w.jsxs("div",{className:"github-preview-meta",children:[w.jsx("span",{className:"github-preview-kind",children:"GitHub repository"}),w.jsx("strong",{children:e.repoId}),(t==null?void 0:t.description)&&w.jsx("span",{className:"github-preview-description",children:t.description}),t?w.jsxs("span",{className:"github-preview-stats",children:[t.language&&w.jsxs(w.Fragment,{children:[t.language," · "]}),"★ ",t.stars.toLocaleString()," · ⑂ ",t.forks.toLocaleString(),t.archived&&w.jsx(w.Fragment,{children:" · Archived"})]}):w.jsx("span",{children:r?"Preview unavailable":"Loading preview…"})]})]})},Uh=({repo:e,children:t})=>{var l;const[r,n]=K.useState(!1),[s,o]=K.useState(!1),a=K.useRef(null),i=K.useCallback(()=>o(!0),[]),c=ur({queryKey:["github-repository-preview",e.repoId.toLowerCase()],queryFn:({signal:d})=>_h(e,d),enabled:r||s,staleTime:30*60*1e3,gcTime:60*60*1e3,retry:!1});return K.useEffect(()=>{const d=a.current;if(!d||typeof IntersectionObserver>"u")return;const f=new IntersectionObserver(([m])=>{m.isIntersecting&&(i(),f.disconnect())},{rootMargin:"200px"});return f.observe(d),()=>f.disconnect()},[i]),K.useEffect(()=>{var d;(d=c.data)!=null&&d.avatarUrl&&ou(c.data.avatarUrl)},[(l=c.data)==null?void 0:l.avatarUrl]),w.jsxs(Rs,{open:r,onOpenChange:d=>{(!d||!qh())&&n(d)},openDelay:150,closeDelay:100,children:[w.jsx(Ts,{asChild:!0,children:w.jsxs("a",{ref:a,className:"chat-github-link",href:e.url,target:"_blank",rel:"noopener noreferrer",onPointerEnter:i,onFocus:i,children:[w.jsx(sa,{"aria-hidden":"true"}),t]})}),w.jsx(js,{className:"github-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:w.jsx(Dh,{repo:e,preview:c.data,unavailable:c.isError})})]})},Fh=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches;function Lh(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return"Web source"}}const Vh=({citation:e})=>{const[t,r]=K.useState(!1),[n,s]=K.useState(!1),o=e.thumbnail_url,a=e.favicon_url;return w.jsxs("div",{className:"web-preview-card",children:[o&&!t&&w.jsx("img",{className:"web-preview-image","data-testid":"web-preview-image",src:o,alt:"",loading:"eager",decoding:"async",referrerPolicy:"no-referrer",onError:()=>r(!0)}),w.jsxs("div",{className:"web-preview-meta",children:[w.jsxs("div",{className:"web-preview-source",children:[a&&!n&&w.jsx("img",{src:a,alt:"",loading:"eager",decoding:"async",referrerPolicy:"no-referrer",onError:()=>s(!0)}),w.jsx("span",{children:Lh(e.url??"")}),e.published&&w.jsxs(w.Fragment,{children:[w.jsx("span",{"aria-hidden":"true",children:"·"}),w.jsx("time",{children:e.published.slice(0,10)})]})]}),w.jsx("strong",{children:e.title}),e.excerpt&&w.jsx("p",{children:e.excerpt.replace(/\s+/g," ").trim()})]})]})},Hh=({citation:e,children:t})=>{const[r,n]=K.useState(!1),s=e.url??"";return w.jsxs(Rs,{open:r,onOpenChange:o=>{(!o||!Fh())&&n(o)},openDelay:150,closeDelay:100,children:[w.jsx(Ts,{asChild:!0,children:w.jsx("a",{href:s,className:"chat-web-citation",target:"_blank",rel:"noopener noreferrer",children:t})}),w.jsx(js,{className:"web-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:w.jsx(Vh,{citation:e})})]})},Zh=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,Kh=e=>e==="semantic_scholar"?"Semantic Scholar":"External paper",Gh=({citation:e})=>{var t,r;return w.jsxs("div",{className:"external-paper-preview-card",children:[w.jsxs("div",{className:"external-paper-preview-source",children:[w.jsx("span",{children:Kh(e.provider)}),e.published&&w.jsxs(w.Fragment,{children:[w.jsx("span",{"aria-hidden":"true",children:"·"}),w.jsx("time",{children:e.published.slice(0,10)})]})]}),w.jsx("strong",{children:e.title}),(((t=e.authors)==null?void 0:t.length)??0)>0&&w.jsx("p",{className:"external-paper-preview-authors",children:(r=e.authors)==null?void 0:r.join(", ")}),e.excerpt&&w.jsx("p",{children:e.excerpt.replace(/\s+/g," ").trim()}),e.citation_count!==null&&e.citation_count!==void 0&&w.jsxs("span",{className:"external-paper-preview-citations",children:[e.citation_count.toLocaleString()," citations"]})]})},Wh=({citation:e,children:t})=>{const[r,n]=K.useState(!1);return w.jsxs(Rs,{open:r,onOpenChange:s=>{(!s||!Zh())&&n(s)},openDelay:150,closeDelay:100,children:[w.jsx(Ts,{asChild:!0,children:w.jsx("a",{href:e.url??"",className:"chat-external-paper-citation",target:"_blank",rel:"noopener noreferrer",children:t})}),w.jsx(js,{className:"external-paper-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:w.jsx(Gh,{citation:e})})]})};function Bh(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 Rc(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 au=({routeId:e,paper:t,citation:r,className:n="chat-paper-link",children:s})=>w.jsx(su,{routeId:e,initialData:Qh(e,t,r),className:n,target:"_blank",children:s});function Yh(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 Xh=e=>e.startsWith("paper:")?e:Sh(e);function ep(e){try{const t=new URL(e);return t.protocol==="https:"&&(t.hostname==="github.com"||t.hostname==="www.github.com")}catch{return!1}}const _o=({text:e,streaming:t,papers:r,citations:n,webCitations:s})=>{const o=Jh(t?Yh(e):e);return w.jsx(wh,{remarkPlugins:[bh,$h],rehypePlugins:[vh],urlTransform:Xh,components:{a:({href:a,children:i})=>{if(a!=null&&a.startsWith("paper:")){const d=a.slice(6);return!r[d]&&!(n!=null&&n[d])?w.jsx("span",{className:"chat-invalid-citation",children:i}):w.jsx(au,{routeId:d,paper:r[d],citation:n==null?void 0:n[d],children:i})}const c=a?xh(a):null;if(c)return w.jsx(zh,{repo:c,children:i});const l=a?yh(a):null;return l?w.jsx(Uh,{repo:l,children:i}):a&&ep(a)?w.jsxs("a",{href:a,className:"chat-github-link",target:"_blank",rel:"noopener noreferrer",children:[w.jsx(sa,{"aria-hidden":"true"}),i]}):a!=null&&a.startsWith("https://")&&(s!=null&&s[a])?s[a].source_type==="paper"?w.jsx(Wh,{citation:s[a],children:i}):w.jsx(Hh,{citation:s[a],children:i}):a!=null&&a.startsWith("https://")?w.jsx("a",{href:a,className:"chat-external-link",target:"_blank",rel:"noopener noreferrer",children:i}):w.jsx("span",{children:i})}},children:o})},tp=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 hn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const iu={};function Kt(e){return iu}function rp(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 np(e,t){return typeof t=="bigint"?t.toString():t}function aa(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ia(e){return e==null}function ca(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function sp(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 Ns(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Gr(e){return JSON.stringify(e)}const cu=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function cs(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const op=aa(()=>{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 ls(e){if(cs(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(cs(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}const ap=new Set(["string","number","symbol"]);function vn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function yr(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 ip(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const cp={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 lp(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 yr(e,{...e._zod.def,shape:r,checks:[]})}function up(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 yr(e,{...e._zod.def,shape:r,checks:[]})}function dp(e,t){if(!ls(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 Ns(this,"shape",n),n},checks:[]};return yr(e,r)}function fp(e,t){return yr(e,{...e._zod.def,get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Ns(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function hp(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 yr(t,{...t._zod.def,shape:s,checks:[]})}function pp(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 yr(t,{...t._zod.def,shape:s,checks:[]})}function rn(e,t=0){var r;for(let n=t;n{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function An(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=An((a=(o=(s=e.inst)==null?void 0:s._zod.def)==null?void 0:o.error)==null?void 0:a.call(o,e))??An((i=t==null?void 0:t.error)==null?void 0:i.call(t,e))??An((c=r.customError)==null?void 0:c.call(r,e))??An((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 la(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function pn(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const lu=(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,np,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},uu=z("$ZodError",lu),du=z("$ZodError",lu,{Parent:Error});function mp(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 gp(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 hn;if(a.issues.length){const i=new((s==null?void 0:s.Err)??e)(a.issues.map(c=>Gt(c,o,Kt())));throw cu(i,s==null?void 0:s.callee),i}return a.value},yp=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 cu(i,s==null?void 0:s.callee),i}return a.value},fu=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 hn;return o.issues.length?{success:!1,error:new(e??uu)(o.issues.map(a=>Gt(a,s,Kt())))}:{success:!0,data:o.value}},hu=fu(du),pu=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}},vp=pu(du),$p=/^[cC][^\s-]{8,}$/,wp=/^[0-9a-z]+$/,bp=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Sp=/^[0-9a-vA-V]{20}$/,Ep=/^[A-Za-z0-9]{27}$/,kp=/^[a-zA-Z0-9_-]{21}$/,Pp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Rp=/^([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})$/,Tc=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)$/,Tp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,jp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Cp(){return new RegExp(jp,"u")}const Np=/^(?:(?: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])$/,Ip=/^(([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})$/,Op=/^((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])$/,xp=/^(([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])$/,Ap=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,mu=/^[A-Za-z0-9_-]*$/,Mp=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,zp=/^\+(?:[0-9]){6,14}[0-9]$/,gu="(?:(?:\\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])))",qp=new RegExp(`^${gu}$`);function _u(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 Dp(e){return new RegExp(`^${_u(e)}$`)}function Up(e){const t=_u({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(`^${gu}T(?:${n})$`)}const Fp=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}$`)},Lp=/^\d+$/,Vp=/^-?\d+(?:\.\d+)?/i,Hp=/true|false/i,Zp=/null/i,Kp=/undefined/i,Gp=/^[^A-Z]*$/,Wp=/^[^a-z]*$/,it=z("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),yu={number:"number",bigint:"bigint",object:"date"},vu=z("$ZodCheckLessThan",(e,t)=>{it.init(e,t);const r=yu[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=yu[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})}}),Bp=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):sp(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})}}),Jp=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]=cp[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=Lp)}),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})}}),Qp=z("$ZodCheckMaxLength",(e,t)=>{var r;it.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!ia(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=la(s);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Yp=z("$ZodCheckMinLength",(e,t)=>{var r;it.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!ia(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=la(s);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Xp=z("$ZodCheckLengthEquals",(e,t)=>{var r;it.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!ia(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=la(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})}}),Is=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=()=>{})}),em=z("$ZodCheckRegex",(e,t)=>{Is.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})}}),tm=z("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Gp),Is.init(e,t)}),rm=z("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Wp),Is.init(e,t)}),nm=z("$ZodCheckIncludes",(e,t)=>{it.init(e,t);const r=vn(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})}}),sm=z("$ZodCheckStartsWith",(e,t)=>{it.init(e,t);const r=new RegExp(`^${vn(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})}}),om=z("$ZodCheckEndsWith",(e,t)=>{it.init(e,t);const r=new RegExp(`.*${vn(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})}}),am=z("$ZodCheckOverwrite",(e,t)=>{it.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class im{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 cm={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=cm;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=rn(a),d;for(const f of i){if(f._zod.def.when){if(!f._zod.def.when(a))continue}else if(l)continue;const m=a.issues.length,g=f._zod.check(a);if(g instanceof Promise&&(c==null?void 0:c.async)===!1)throw new hn;if(d||g instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await g,a.issues.length!==m&&(l||(l=rn(a,m)))});else{if(a.issues.length===m)continue;l||(l=rn(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 hn;return c.then(l=>o(l,n,i))}return o(c,n,i)}}e["~standard"]={validate:o=>{var a;try{const i=hu(e,o);return i.success?{value:i.data}:{issues:(a=i.error)==null?void 0:a.issues}}catch{return vp(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}}),ua=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()??Fp(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}}),Ce=z("$ZodStringFormat",(e,t)=>{Is.init(e,t),ua.init(e,t)}),lm=z("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Rp),Ce.init(e,t)}),um=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=Tc(n))}else t.pattern??(t.pattern=Tc());Ce.init(e,t)}),dm=z("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Tp),Ce.init(e,t)}),fm=z("$ZodURL",(e,t)=>{Ce.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:Mp.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})}}}),hm=z("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Cp()),Ce.init(e,t)}),pm=z("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=kp),Ce.init(e,t)}),mm=z("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=$p),Ce.init(e,t)}),gm=z("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=wp),Ce.init(e,t)}),_m=z("$ZodULID",(e,t)=>{t.pattern??(t.pattern=bp),Ce.init(e,t)}),ym=z("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Sp),Ce.init(e,t)}),vm=z("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ep),Ce.init(e,t)}),$m=z("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Up(t)),Ce.init(e,t)}),wm=z("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=qp),Ce.init(e,t)}),bm=z("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Dp(t)),Ce.init(e,t)}),Sm=z("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Pp),Ce.init(e,t)}),Em=z("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Np),Ce.init(e,t),e._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv4"})}),km=z("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ip),Ce.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})}}}),Pm=z("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Op),Ce.init(e,t)}),Rm=z("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=xp),Ce.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 wu(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Tm=z("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Ap),Ce.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),e._zod.check=r=>{wu(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function jm(e){if(!mu.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return wu(r)}const Cm=z("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=mu),Ce.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),e._zod.check=r=>{jm(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Nm=z("$ZodE164",(e,t)=>{t.pattern??(t.pattern=zp),Ce.init(e,t)});function Im(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 Om=z("$ZodJWT",(e,t)=>{Ce.init(e,t),e._zod.check=r=>{Im(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),bu=z("$ZodNumber",(e,t)=>{Ee.init(e,t),e._zod.pattern=e._zod.bag.pattern??Vp,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}}),xm=z("$ZodNumber",(e,t)=>{Jp.init(e,t),bu.init(e,t)}),Am=z("$ZodBoolean",(e,t)=>{Ee.init(e,t),e._zod.pattern=Hp,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}}),Mm=z("$ZodUndefined",(e,t)=>{Ee.init(e,t),e._zod.pattern=Kp,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}}),zm=z("$ZodNull",(e,t)=>{Ee.init(e,t),e._zod.pattern=Zp,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}}),qm=z("$ZodAny",(e,t)=>{Ee.init(e,t),e._zod.parse=r=>r}),Dm=z("$ZodUnknown",(e,t)=>{Ee.init(e,t),e._zod.parse=r=>r}),Um=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 jc(e,t,r){e.issues.length&&t.issues.push(...lr(r,e.issues)),t.value[r]=e.value}const Fm=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;ajc(l,r,a))):jc(c,r,a)}return o.length?Promise.all(o).then(()=>r):r}});function Mn(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 Lm=z("$ZodObject",(e,t)=>{Ee.init(e,t);const r=aa(()=>{const f=Object.keys(t.shape);for(const g of f)if(!(t.shape[g]instanceof Ee))throw new Error(`Invalid element at key "${g}": expected a Zod schema`);const m=ip(t.shape);return{shape:t.shape,keys:f,keySet:new Set(f),numKeys:f.length,optionalKeys:new Set(m)}});Te(e._zod,"propValues",()=>{const f=t.shape,m={};for(const g in f){const _=f[g]._zod;if(_.values){m[g]??(m[g]=new Set);for(const y of _.values)m[g].add(y)}}return m});const n=f=>{const m=new im(["shape","payload","ctx"]),g=r.value,_=$=>{const E=Gr($);return`shape[${E}]._zod.run({ value: input[${E}], issues: [] }, ctx)`};m.write("const input = payload.value;");const y=Object.create(null);let v=0;for(const $ of g.keys)y[$]=`key_${v++}`;m.write("const newResult = {}");for(const $ of g.keys)if(g.optionalKeys.has($)){const E=y[$];m.write(`const ${E} = ${_($)};`);const R=Gr($);m.write(` - if (${E}.issues.length) { - if (input[${R}] === undefined) { - if (${R} in input) { - newResult[${R}] = undefined; - } - } else { - payload.issues = payload.issues.concat( - ${E}.issues.map((iss) => ({ - ...iss, - path: iss.path ? [${R}, ...iss.path] : [${R}], - })) - ); - } - } else if (${E}.value === undefined) { - if (${R} in input) newResult[${R}] = undefined; - } else { - newResult[${R}] = ${E}.value; - } - `)}else{const E=y[$];m.write(`const ${E} = ${_($)};`),m.write(` - if (${E}.issues.length) payload.issues = payload.issues.concat(${E}.issues.map(iss => ({ - ...iss, - path: iss.path ? [${Gr($)}, ...iss.path] : [${Gr($)}] - })));`),m.write(`newResult[${Gr($)}] = ${E}.value`)}m.write("payload.value = newResult;"),m.write("return payload;");const h=m.compile();return($,E)=>h(f,$,E)};let s;const o=cs,a=!iu.jitless,c=a&&op.value,l=t.catchall;let d;e._zod.parse=(f,m)=>{d??(d=r.value);const g=f.value;if(!o(g))return f.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),f;const _=[];if(a&&c&&(m==null?void 0:m.async)===!1&&m.jitless!==!0)s||(s=n(t.shape)),f=s(f,m);else{f.value={};const E=d.shape;for(const R of d.keys){const k=E[R],N=k._zod.run({value:g[R],issues:[]},m),A=k._zod.optin==="optional"&&k._zod.optout==="optional";N instanceof Promise?_.push(N.then(F=>A?Cc(F,f,R,g):Mn(F,f,R))):A?Cc(N,f,R,g):Mn(N,f,R)}}if(!l)return _.length?Promise.all(_).then(()=>f):f;const y=[],v=d.keySet,h=l._zod,$=h.def.type;for(const E of Object.keys(g)){if(v.has(E))continue;if($==="never"){y.push(E);continue}const R=h.run({value:g[E],issues:[]},m);R instanceof Promise?_.push(R.then(k=>Mn(k,f,E))):Mn(R,f,E)}return y.length&&f.issues.push({code:"unrecognized_keys",keys:y,input:g,inst:e}),_.length?Promise.all(_).then(()=>f):f}});function Nc(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 Su=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=>ca(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=>Nc(a,r,e,n)):Nc(o,r,e,n)}}),Vm=z("$ZodDiscriminatedUnion",(e,t)=>{Su.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=aa(()=>{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(!cs(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)}}),Hm=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])=>Ic(r,c,l)):Ic(r,o,a)}});function yo(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(ls(e)&&ls(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=yo(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(!ls(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}}),Km=z("$ZodEnum",(e,t)=>{Ee.init(e,t);const r=rp(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(n=>ap.has(typeof n)).map(n=>typeof n=="string"?vn(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}}),Gm=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"?vn(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}}),Wm=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 hn;return r.value=s,r}}),Bm=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(`^(${ca(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)}),Jm=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(`^(${ca(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)}),Qm=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=>Oc(o,t)):Oc(s,t)}});function Oc(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Ym=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))}),Xm=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=>xc(o,e)):xc(s,e)}});function xc(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 eg=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)}}),tg=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=>Ac(o,t,n)):Ac(s,t,n)}});function Ac(e,t,r){return rn(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}const rg=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(Mc):Mc(s)}});function Mc(e){return e.value=Object.freeze(e.value),e}const ng=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=>zc(o,r,n,e));zc(s,r,n,e)}});function zc(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(pn(s))}}class sg{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 og(){return new sg}const zn=og();function ag(e,t){return new e({type:"string",...te(t)})}function ig(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...te(t)})}function qc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...te(t)})}function cg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...te(t)})}function lg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...te(t)})}function ug(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...te(t)})}function dg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...te(t)})}function Eu(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...te(t)})}function fg(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...te(t)})}function hg(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...te(t)})}function pg(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...te(t)})}function mg(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...te(t)})}function gg(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...te(t)})}function _g(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...te(t)})}function yg(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...te(t)})}function vg(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...te(t)})}function $g(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...te(t)})}function wg(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...te(t)})}function bg(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...te(t)})}function Sg(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...te(t)})}function Eg(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...te(t)})}function kg(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...te(t)})}function Pg(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...te(t)})}function Rg(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...te(t)})}function Tg(e,t){return new e({type:"string",format:"date",check:"string_format",...te(t)})}function jg(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 Ng(e,t){return new e({type:"number",checks:[],...te(t)})}function Ig(e,t){return new e({type:"number",coerce:!0,checks:[],...te(t)})}function Og(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...te(t)})}function xg(e,t){return new e({type:"boolean",...te(t)})}function Ag(e,t){return new e({type:"undefined",...te(t)})}function Mg(e,t){return new e({type:"null",...te(t)})}function zg(e){return new e({type:"any"})}function qg(e){return new e({type:"unknown"})}function Dg(e,t){return new e({type:"never",...te(t)})}function Dc(e,t){return new vu({check:"less_than",...te(t),value:e,inclusive:!1})}function Ys(e,t){return new vu({check:"less_than",...te(t),value:e,inclusive:!0})}function Uc(e,t){return new $u({check:"greater_than",...te(t),value:e,inclusive:!1})}function Xs(e,t){return new $u({check:"greater_than",...te(t),value:e,inclusive:!0})}function Fc(e,t){return new Bp({check:"multiple_of",...te(t),value:e})}function ku(e,t){return new Qp({check:"max_length",...te(t),maximum:e})}function us(e,t){return new Yp({check:"min_length",...te(t),minimum:e})}function Pu(e,t){return new Xp({check:"length_equals",...te(t),length:e})}function Ug(e,t){return new em({check:"string_format",format:"regex",...te(t),pattern:e})}function Fg(e){return new tm({check:"string_format",format:"lowercase",...te(e)})}function Lg(e){return new rm({check:"string_format",format:"uppercase",...te(e)})}function Vg(e,t){return new nm({check:"string_format",format:"includes",...te(t),includes:e})}function Hg(e,t){return new sm({check:"string_format",format:"starts_with",...te(t),prefix:e})}function Zg(e,t){return new om({check:"string_format",format:"ends_with",...te(t),suffix:e})}function $n(e){return new am({check:"overwrite",tx:e})}function Kg(e){return $n(t=>t.normalize(e))}function Gg(){return $n(e=>e.trim())}function Wg(){return $n(e=>e.toLowerCase())}function Bg(){return $n(e=>e.toUpperCase())}function Jg(e,t,r){return new e({type:"array",element:t,...te(r)})}function Qg(e,t,r){const n=te(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function Yg(e,t,r){return new e({type:"custom",check:"custom",fn:t,...te(r)})}const Xg=z("ZodISODateTime",(e,t)=>{$m.init(e,t),Ie.init(e,t)});function Ru(e){return Rg(Xg,e)}const e_=z("ZodISODate",(e,t)=>{wm.init(e,t),Ie.init(e,t)});function t_(e){return Tg(e_,e)}const r_=z("ZodISOTime",(e,t)=>{bm.init(e,t),Ie.init(e,t)});function n_(e){return jg(r_,e)}const s_=z("ZodISODuration",(e,t)=>{Sm.init(e,t),Ie.init(e,t)});function o_(e){return Cg(s_,e)}const a_=(e,t)=>{uu.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>gp(e,r)},flatten:{value:r=>mp(e,r)},addIssue:{value:r=>e.issues.push(r)},addIssues:{value:r=>e.issues.push(...r)},isEmpty:{get(){return e.issues.length===0}}})},Os=z("ZodError",a_,{Parent:Error}),i_=_p(Os),c_=yp(Os),l_=fu(Os),u_=pu(Os),je=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)=>yr(e,r,n),e.brand=()=>e,e.register=(r,n)=>(r.add(e,n),e),e.parse=(r,n)=>i_(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>l_(e,r,n),e.parseAsync=async(r,n)=>c_(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>u_(e,r,n),e.spa=e.safeParseAsync,e.refine=(r,n)=>e.check(ry(r,n)),e.superRefine=r=>e.check(ny(r)),e.overwrite=r=>e.check($n(r)),e.optional=()=>Ne(e),e.nullable=()=>Hc(e),e.nullish=()=>Ne(Hc(e)),e.nonoptional=r=>W_(e,r),e.array=()=>G(e),e.or=r=>_e([e,r]),e.and=r=>ha(e,r),e.transform=r=>bo(e,Ou(r)),e.default=r=>Z_(e,r),e.prefault=r=>G_(e,r),e.catch=r=>J_(e,r),e.pipe=r=>bo(e,r),e.readonly=()=>X_(e),e.describe=r=>{const n=e.clone();return zn.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){var r;return(r=zn.get(e))==null?void 0:r.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return zn.get(e);const n=e.clone();return zn.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Tu=z("_ZodString",(e,t)=>{ua.init(e,t),je.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(Ug(...n)),e.includes=(...n)=>e.check(Vg(...n)),e.startsWith=(...n)=>e.check(Hg(...n)),e.endsWith=(...n)=>e.check(Zg(...n)),e.min=(...n)=>e.check(us(...n)),e.max=(...n)=>e.check(ku(...n)),e.length=(...n)=>e.check(Pu(...n)),e.nonempty=(...n)=>e.check(us(1,...n)),e.lowercase=n=>e.check(Fg(n)),e.uppercase=n=>e.check(Lg(n)),e.trim=()=>e.check(Gg()),e.normalize=(...n)=>e.check(Kg(...n)),e.toLowerCase=()=>e.check(Wg()),e.toUpperCase=()=>e.check(Bg())}),d_=z("ZodString",(e,t)=>{ua.init(e,t),Tu.init(e,t),e.email=r=>e.check(ig(f_,r)),e.url=r=>e.check(Eu(ju,r)),e.jwt=r=>e.check(Pg(T_,r)),e.emoji=r=>e.check(fg(p_,r)),e.guid=r=>e.check(qc(Lc,r)),e.uuid=r=>e.check(cg(qn,r)),e.uuidv4=r=>e.check(lg(qn,r)),e.uuidv6=r=>e.check(ug(qn,r)),e.uuidv7=r=>e.check(dg(qn,r)),e.nanoid=r=>e.check(hg(m_,r)),e.guid=r=>e.check(qc(Lc,r)),e.cuid=r=>e.check(pg(g_,r)),e.cuid2=r=>e.check(mg(__,r)),e.ulid=r=>e.check(gg(y_,r)),e.base64=r=>e.check(Sg(k_,r)),e.base64url=r=>e.check(Eg(P_,r)),e.xid=r=>e.check(_g(v_,r)),e.ksuid=r=>e.check(yg($_,r)),e.ipv4=r=>e.check(vg(w_,r)),e.ipv6=r=>e.check($g(b_,r)),e.cidrv4=r=>e.check(wg(S_,r)),e.cidrv6=r=>e.check(bg(E_,r)),e.e164=r=>e.check(kg(R_,r)),e.datetime=r=>e.check(Ru(r)),e.date=r=>e.check(t_(r)),e.time=r=>e.check(n_(r)),e.duration=r=>e.check(o_(r))});function T(e){return ag(d_,e)}const Ie=z("ZodStringFormat",(e,t)=>{Ce.init(e,t),Tu.init(e,t)}),f_=z("ZodEmail",(e,t)=>{dm.init(e,t),Ie.init(e,t)}),Lc=z("ZodGUID",(e,t)=>{lm.init(e,t),Ie.init(e,t)}),qn=z("ZodUUID",(e,t)=>{um.init(e,t),Ie.init(e,t)}),ju=z("ZodURL",(e,t)=>{fm.init(e,t),Ie.init(e,t)});function h_(e){return Eu(ju,e)}const p_=z("ZodEmoji",(e,t)=>{hm.init(e,t),Ie.init(e,t)}),m_=z("ZodNanoID",(e,t)=>{pm.init(e,t),Ie.init(e,t)}),g_=z("ZodCUID",(e,t)=>{mm.init(e,t),Ie.init(e,t)}),__=z("ZodCUID2",(e,t)=>{gm.init(e,t),Ie.init(e,t)}),y_=z("ZodULID",(e,t)=>{_m.init(e,t),Ie.init(e,t)}),v_=z("ZodXID",(e,t)=>{ym.init(e,t),Ie.init(e,t)}),$_=z("ZodKSUID",(e,t)=>{vm.init(e,t),Ie.init(e,t)}),w_=z("ZodIPv4",(e,t)=>{Em.init(e,t),Ie.init(e,t)}),b_=z("ZodIPv6",(e,t)=>{km.init(e,t),Ie.init(e,t)}),S_=z("ZodCIDRv4",(e,t)=>{Pm.init(e,t),Ie.init(e,t)}),E_=z("ZodCIDRv6",(e,t)=>{Rm.init(e,t),Ie.init(e,t)}),k_=z("ZodBase64",(e,t)=>{Tm.init(e,t),Ie.init(e,t)}),P_=z("ZodBase64URL",(e,t)=>{Cm.init(e,t),Ie.init(e,t)}),R_=z("ZodE164",(e,t)=>{Nm.init(e,t),Ie.init(e,t)}),T_=z("ZodJWT",(e,t)=>{Om.init(e,t),Ie.init(e,t)}),da=z("ZodNumber",(e,t)=>{bu.init(e,t),je.init(e,t),e.gt=(n,s)=>e.check(Uc(n,s)),e.gte=(n,s)=>e.check(Xs(n,s)),e.min=(n,s)=>e.check(Xs(n,s)),e.lt=(n,s)=>e.check(Dc(n,s)),e.lte=(n,s)=>e.check(Ys(n,s)),e.max=(n,s)=>e.check(Ys(n,s)),e.int=n=>e.check(Vc(n)),e.safe=n=>e.check(Vc(n)),e.positive=n=>e.check(Uc(0,n)),e.nonnegative=n=>e.check(Xs(0,n)),e.negative=n=>e.check(Dc(0,n)),e.nonpositive=n=>e.check(Ys(0,n)),e.multipleOf=(n,s)=>e.check(Fc(n,s)),e.step=(n,s)=>e.check(Fc(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 Ng(da,e)}const j_=z("ZodNumberFormat",(e,t)=>{xm.init(e,t),da.init(e,t)});function Vc(e){return Og(j_,e)}const C_=z("ZodBoolean",(e,t)=>{Am.init(e,t),je.init(e,t)});function ve(e){return xg(C_,e)}const N_=z("ZodUndefined",(e,t)=>{Mm.init(e,t),je.init(e,t)});function vo(e){return Ag(N_,e)}const I_=z("ZodNull",(e,t)=>{zm.init(e,t),je.init(e,t)});function O_(e){return Mg(I_,e)}const x_=z("ZodAny",(e,t)=>{qm.init(e,t),je.init(e,t)});function fa(){return zg(x_)}const A_=z("ZodUnknown",(e,t)=>{Dm.init(e,t),je.init(e,t)});function Se(){return qg(A_)}const M_=z("ZodNever",(e,t)=>{Um.init(e,t),je.init(e,t)});function $o(e){return Dg(M_,e)}const z_=z("ZodArray",(e,t)=>{Fm.init(e,t),je.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(us(r,n)),e.nonempty=r=>e.check(us(1,r)),e.max=(r,n)=>e.check(ku(r,n)),e.length=(r,n)=>e.check(Pu(r,n)),e.unwrap=()=>e.element});function G(e,t){return Jg(z_,e,t)}const Cu=z("ZodObject",(e,t)=>{Lm.init(e,t),je.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:$o()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>dp(e,r),e.merge=r=>fp(e,r),e.pick=r=>lp(e,r),e.omit=r=>up(e,r),e.partial=(...r)=>hp(xu,e,r[0]),e.required=(...r)=>pp(Au,e,r[0])});function M(e,t){const r={type:"object",get shape(){return Ns(this,"shape",{...e}),this.shape},...te(t)};return new Cu(r)}function Be(e,t){return new Cu({type:"object",get shape(){return Ns(this,"shape",{...e}),this.shape},catchall:Se(),...te(t)})}const Nu=z("ZodUnion",(e,t)=>{Su.init(e,t),je.init(e,t),e.options=t.options});function _e(e,t){return new Nu({type:"union",options:e,...te(t)})}const q_=z("ZodDiscriminatedUnion",(e,t)=>{Nu.init(e,t),Vm.init(e,t)});function Iu(e,t,r){return new q_({type:"union",options:t,discriminator:e,...te(r)})}const D_=z("ZodIntersection",(e,t)=>{Hm.init(e,t),je.init(e,t)});function ha(e,t){return new D_({type:"intersection",left:e,right:t})}const U_=z("ZodRecord",(e,t)=>{Zm.init(e,t),je.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function $e(e,t,r){return new U_({type:"record",keyType:e,valueType:t,...te(r)})}const wo=z("ZodEnum",(e,t)=>{Km.init(e,t),je.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 wo({...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 wo({...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 wo({type:"enum",entries:r,...te(t)})}const F_=z("ZodLiteral",(e,t)=>{Gm.init(e,t),je.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 I(e,t){return new F_({type:"literal",values:Array.isArray(e)?e:[e],...te(t)})}const L_=z("ZodTransform",(e,t)=>{Wm.init(e,t),je.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=o=>{if(typeof o=="string")r.issues.push(pn(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(pn(a))}};const s=t.transform(r.value,r);return s instanceof Promise?s.then(o=>(r.value=o,r)):(r.value=s,r)}});function Ou(e){return new L_({type:"transform",transform:e})}const xu=z("ZodOptional",(e,t)=>{Bm.init(e,t),je.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ne(e){return new xu({type:"optional",innerType:e})}const V_=z("ZodNullable",(e,t)=>{Jm.init(e,t),je.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Hc(e){return new V_({type:"nullable",innerType:e})}const H_=z("ZodDefault",(e,t)=>{Qm.init(e,t),je.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Z_(e,t){return new H_({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const K_=z("ZodPrefault",(e,t)=>{Ym.init(e,t),je.init(e,t),e.unwrap=()=>e._zod.def.innerType});function G_(e,t){return new K_({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const Au=z("ZodNonOptional",(e,t)=>{Xm.init(e,t),je.init(e,t),e.unwrap=()=>e._zod.def.innerType});function W_(e,t){return new Au({type:"nonoptional",innerType:e,...te(t)})}const B_=z("ZodCatch",(e,t)=>{eg.init(e,t),je.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function J_(e,t){return new B_({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Q_=z("ZodPipe",(e,t)=>{tg.init(e,t),je.init(e,t),e.in=t.in,e.out=t.out});function bo(e,t){return new Q_({type:"pipe",in:e,out:t})}const Y_=z("ZodReadonly",(e,t)=>{rg.init(e,t),je.init(e,t)});function X_(e){return new Y_({type:"readonly",innerType:e})}const Mu=z("ZodCustom",(e,t)=>{ng.init(e,t),je.init(e,t)});function ey(e){const t=new it({check:"custom"});return t._zod.check=e,t}function ty(e,t){return Qg(Mu,e??(()=>!0),t)}function ry(e,t={}){return Yg(Mu,e,t)}function ny(e){const t=ey(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(pn(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(pn(s))}},e(r.value,r)));return t}function zu(e,t){return bo(Ou(e),t)}const sy={custom:"custom"};function oy(e){return Ig(da,e)}const xs="2025-11-25",ay=[xs,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],nr="io.modelcontextprotocol/related-task",As="2.0",Ue=ty(e=>e!==null&&(typeof e=="object"||typeof e=="function")),qu=_e([T(),fe().int()]),Du=T();Be({ttl:fe().optional(),pollInterval:fe().optional()});const iy=M({ttl:fe().optional()}),cy=M({taskId:T()}),pa=Be({progressToken:qu.optional(),[nr]:cy.optional()}),ut=M({_meta:pa.optional()}),wn=ut.extend({task:iy.optional()}),ly=e=>wn.safeParse(e).success,Je=M({method:T(),params:ut.loose().optional()}),pt=M({_meta:pa.optional()}),mt=M({method:T(),params:pt.loose().optional()}),Qe=Be({_meta:pa.optional()}),bn=_e([T(),fe().int()]),Uu=M({jsonrpc:I(As),id:bn,...Je.shape}).strict(),So=e=>Uu.safeParse(e).success,Fu=M({jsonrpc:I(As),...mt.shape}).strict(),uy=e=>Fu.safeParse(e).success,ma=M({jsonrpc:I(As),id:bn,result:Qe}).strict(),Yr=e=>ma.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 ga=M({jsonrpc:I(As),id:bn.optional(),error:M({code:fe().int(),message:T(),data:Se().optional()})}).strict(),dy=e=>ga.safeParse(e).success,Qn=_e([Uu,Fu,ma,ga]);_e([ma,ga]);const Pr=Qe.strict(),fy=pt.extend({requestId:bn.optional(),reason:T().optional()}),_a=mt.extend({method:I("notifications/cancelled"),params:fy}),hy=M({src:T(),mimeType:T().optional(),sizes:G(T()).optional(),theme:lt(["light","dark"]).optional()}),Sn=M({icons:G(hy).optional()}),Or=M({name:T(),title:T().optional()}),Ms=Or.extend({...Or.shape,...Sn.shape,version:T(),websiteUrl:T().optional(),description:T().optional()}),py=ha(M({applyDefaults:ve().optional()}),$e(T(),Se())),my=zu(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ha(M({form:py.optional(),url:Ue.optional()}),$e(T(),Se()).optional())),gy=Be({list:Ue.optional(),cancel:Ue.optional(),requests:Be({sampling:Be({createMessage:Ue.optional()}).optional(),elicitation:Be({create:Ue.optional()}).optional()}).optional()}),_y=Be({list:Ue.optional(),cancel:Ue.optional(),requests:Be({tools:Be({call:Ue.optional()}).optional()}).optional()}),yy=M({experimental:$e(T(),Ue).optional(),sampling:M({context:Ue.optional(),tools:Ue.optional()}).optional(),elicitation:my.optional(),roots:M({listChanged:ve().optional()}).optional(),tasks:gy.optional(),extensions:$e(T(),Ue).optional()}),vy=ut.extend({protocolVersion:T(),capabilities:yy,clientInfo:Ms}),$y=Je.extend({method:I("initialize"),params:vy}),wy=M({experimental:$e(T(),Ue).optional(),logging:Ue.optional(),completions:Ue.optional(),prompts:M({listChanged:ve().optional()}).optional(),resources:M({subscribe:ve().optional(),listChanged:ve().optional()}).optional(),tools:M({listChanged:ve().optional()}).optional(),tasks:_y.optional(),extensions:$e(T(),Ue).optional()}),Lu=Qe.extend({protocolVersion:T(),capabilities:wy,serverInfo:Ms,instructions:T().optional()}),Vu=mt.extend({method:I("notifications/initialized"),params:pt.optional()}),by=e=>Vu.safeParse(e).success,zs=Je.extend({method:I("ping"),params:ut.optional()}),Sy=M({progress:fe(),total:Ne(fe()),message:Ne(T())}),Ey=M({...pt.shape,...Sy.shape,progressToken:qu}),ya=mt.extend({method:I("notifications/progress"),params:Ey}),ky=ut.extend({cursor:Du.optional()}),En=Je.extend({params:ky.optional()}),kn=Qe.extend({nextCursor:Du.optional()}),Py=lt(["working","input_required","completed","failed","cancelled"]),Pn=M({taskId:T(),status:Py,ttl:_e([fe(),O_()]),createdAt:T(),lastUpdatedAt:T(),pollInterval:Ne(fe()),statusMessage:Ne(T())}),mn=Qe.extend({task:Pn}),Ry=pt.merge(Pn),ds=mt.extend({method:I("notifications/tasks/status"),params:Ry}),va=Je.extend({method:I("tasks/get"),params:ut.extend({taskId:T()})}),$a=Qe.merge(Pn),wa=Je.extend({method:I("tasks/result"),params:ut.extend({taskId:T()})});Qe.loose();const ba=En.extend({method:I("tasks/list")}),Sa=kn.extend({tasks:G(Pn)}),Ea=Je.extend({method:I("tasks/cancel"),params:ut.extend({taskId:T()})}),Ty=Qe.merge(Pn),Hu=M({uri:T(),mimeType:Ne(T()),_meta:$e(T(),Se()).optional()}),Zu=Hu.extend({text:T()}),ka=T().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Ku=Hu.extend({blob:ka}),Rn=lt(["user","assistant"]),qr=M({audience:G(Rn).optional(),priority:fe().min(0).max(1).optional(),lastModified:Ru({offset:!0}).optional()}),Gu=M({...Or.shape,...Sn.shape,uri:T(),description:Ne(T()),mimeType:Ne(T()),size:Ne(fe()),annotations:qr.optional(),_meta:Ne(Be({}))}),jy=M({...Or.shape,...Sn.shape,uriTemplate:T(),description:Ne(T()),mimeType:Ne(T()),annotations:qr.optional(),_meta:Ne(Be({}))}),Wu=En.extend({method:I("resources/list")}),Pa=kn.extend({resources:G(Gu)}),Bu=En.extend({method:I("resources/templates/list")}),Ra=kn.extend({resourceTemplates:G(jy)}),Ta=ut.extend({uri:T()}),Cy=Ta,Ju=Je.extend({method:I("resources/read"),params:Cy}),ja=Qe.extend({contents:G(_e([Zu,Ku]))}),Ca=mt.extend({method:I("notifications/resources/list_changed"),params:pt.optional()}),Ny=Ta,Iy=Je.extend({method:I("resources/subscribe"),params:Ny}),Oy=Ta,xy=Je.extend({method:I("resources/unsubscribe"),params:Oy}),Ay=pt.extend({uri:T()}),My=mt.extend({method:I("notifications/resources/updated"),params:Ay}),zy=M({name:T(),description:Ne(T()),required:Ne(ve())}),qy=M({...Or.shape,...Sn.shape,description:Ne(T()),arguments:Ne(G(zy)),_meta:Ne(Be({}))}),Qu=En.extend({method:I("prompts/list")}),Na=kn.extend({prompts:G(qy)}),Dy=ut.extend({name:T(),arguments:$e(T(),T()).optional()}),Uy=Je.extend({method:I("prompts/get"),params:Dy}),Ia=M({type:I("text"),text:T(),annotations:qr.optional(),_meta:$e(T(),Se()).optional()}),Oa=M({type:I("image"),data:ka,mimeType:T(),annotations:qr.optional(),_meta:$e(T(),Se()).optional()}),xa=M({type:I("audio"),data:ka,mimeType:T(),annotations:qr.optional(),_meta:$e(T(),Se()).optional()}),Fy=M({type:I("tool_use"),name:T(),id:T(),input:$e(T(),Se()),_meta:$e(T(),Se()).optional()}),Yu=M({type:I("resource"),resource:_e([Zu,Ku]),annotations:qr.optional(),_meta:$e(T(),Se()).optional()}),Xu=Gu.extend({type:I("resource_link")}),Tn=_e([Ia,Oa,xa,Xu,Yu]),Ly=M({role:Rn,content:Tn}),ed=Qe.extend({description:T().optional(),messages:G(Ly)}),Aa=mt.extend({method:I("notifications/prompts/list_changed"),params:pt.optional()}),Vy=M({title:T().optional(),readOnlyHint:ve().optional(),destructiveHint:ve().optional(),idempotentHint:ve().optional(),openWorldHint:ve().optional()}),Hy=M({taskSupport:lt(["required","optional","forbidden"]).optional()}),Ma=M({...Or.shape,...Sn.shape,description:T().optional(),inputSchema:M({type:I("object"),properties:$e(T(),Ue).optional(),required:G(T()).optional()}).catchall(Se()),outputSchema:M({type:I("object"),properties:$e(T(),Ue).optional(),required:G(T()).optional()}).catchall(Se()).optional(),annotations:Vy.optional(),execution:Hy.optional(),_meta:$e(T(),Se()).optional()}),Zy=En.extend({method:I("tools/list")}),za=kn.extend({tools:G(Ma)}),dr=Qe.extend({content:G(Tn).default([]),structuredContent:$e(T(),Se()).optional(),isError:ve().optional()});dr.or(Qe.extend({toolResult:Se()}));const Ky=wn.extend({name:T(),arguments:$e(T(),Se()).optional()}),td=Je.extend({method:I("tools/call"),params:Ky}),qa=mt.extend({method:I("notifications/tools/list_changed"),params:pt.optional()}),Gy=M({autoRefresh:ve().default(!0),debounceMs:fe().int().nonnegative().default(300)}),rd=lt(["debug","info","notice","warning","error","critical","alert","emergency"]),Wy=ut.extend({level:rd}),By=Je.extend({method:I("logging/setLevel"),params:Wy}),Jy=pt.extend({level:rd,logger:T().optional(),data:Se()}),nd=mt.extend({method:I("notifications/message"),params:Jy}),Qy=M({name:T().optional()}),Yy=M({hints:G(Qy).optional(),costPriority:fe().min(0).max(1).optional(),speedPriority:fe().min(0).max(1).optional(),intelligencePriority:fe().min(0).max(1).optional()}),Xy=M({mode:lt(["auto","required","none"]).optional()}),ev=M({type:I("tool_result"),toolUseId:T().describe("The unique identifier for the corresponding tool call."),content:G(Tn).default([]),structuredContent:M({}).loose().optional(),isError:ve().optional(),_meta:$e(T(),Se()).optional()}),tv=Iu("type",[Ia,Oa,xa]),fs=Iu("type",[Ia,Oa,xa,Fy,ev]),rv=M({role:Rn,content:_e([fs,G(fs)]),_meta:$e(T(),Se()).optional()}),nv=wn.extend({messages:G(rv),modelPreferences:Yy.optional(),systemPrompt:T().optional(),includeContext:lt(["none","thisServer","allServers"]).optional(),temperature:fe().optional(),maxTokens:fe().int(),stopSequences:G(T()).optional(),metadata:Ue.optional(),tools:G(Ma).optional(),toolChoice:Xy.optional()}),Da=Je.extend({method:I("sampling/createMessage"),params:nv}),sd=Qe.extend({model:T(),stopReason:Ne(lt(["endTurn","stopSequence","maxTokens"]).or(T())),role:Rn,content:tv}),od=Qe.extend({model:T(),stopReason:Ne(lt(["endTurn","stopSequence","maxTokens","toolUse"]).or(T())),role:Rn,content:_e([fs,G(fs)])}),sv=M({type:I("boolean"),title:T().optional(),description:T().optional(),default:ve().optional()}),ov=M({type:I("string"),title:T().optional(),description:T().optional(),minLength:fe().optional(),maxLength:fe().optional(),format:lt(["email","uri","date","date-time"]).optional(),default:T().optional()}),av=M({type:lt(["number","integer"]),title:T().optional(),description:T().optional(),minimum:fe().optional(),maximum:fe().optional(),default:fe().optional()}),iv=M({type:I("string"),title:T().optional(),description:T().optional(),enum:G(T()),default:T().optional()}),cv=M({type:I("string"),title:T().optional(),description:T().optional(),oneOf:G(M({const:T(),title:T()})),default:T().optional()}),lv=M({type:I("string"),title:T().optional(),description:T().optional(),enum:G(T()),enumNames:G(T()).optional(),default:T().optional()}),uv=_e([iv,cv]),dv=M({type:I("array"),title:T().optional(),description:T().optional(),minItems:fe().optional(),maxItems:fe().optional(),items:M({type:I("string"),enum:G(T())}),default:G(T()).optional()}),fv=M({type:I("array"),title:T().optional(),description:T().optional(),minItems:fe().optional(),maxItems:fe().optional(),items:M({anyOf:G(M({const:T(),title:T()}))}),default:G(T()).optional()}),hv=_e([dv,fv]),pv=_e([lv,uv,hv]),mv=_e([pv,sv,ov,av]),gv=wn.extend({mode:I("form").optional(),message:T(),requestedSchema:M({type:I("object"),properties:$e(T(),mv),required:G(T()).optional()})}),_v=wn.extend({mode:I("url"),message:T(),elicitationId:T(),url:T().url()}),yv=_e([gv,_v]),ad=Je.extend({method:I("elicitation/create"),params:yv}),vv=pt.extend({elicitationId:T()}),$v=mt.extend({method:I("notifications/elicitation/complete"),params:vv}),id=Qe.extend({action:lt(["accept","decline","cancel"]),content:zu(e=>e===null?void 0:e,$e(T(),_e([T(),fe(),ve(),G(T())])).optional())}),wv=M({type:I("ref/resource"),uri:T()}),bv=M({type:I("ref/prompt"),name:T()}),Sv=ut.extend({ref:_e([bv,wv]),argument:M({name:T(),value:T()}),context:M({arguments:$e(T(),T()).optional()}).optional()}),Ev=Je.extend({method:I("completion/complete"),params:Sv}),cd=Qe.extend({completion:Be({values:G(T()).max(100),total:Ne(fe().int()),hasMore:Ne(ve())})}),kv=M({uri:T().startsWith("file://"),name:T().optional(),_meta:$e(T(),Se()).optional()}),Pv=Je.extend({method:I("roots/list"),params:ut.optional()}),Rv=Qe.extend({roots:G(kv)}),Tv=mt.extend({method:I("notifications/roots/list_changed"),params:pt.optional()});_e([zs,$y,Ev,By,Uy,Qu,Wu,Bu,Ju,Iy,xy,td,Zy,va,wa,ba,Ea]);_e([_a,ya,Vu,Tv,ds]);_e([Pr,sd,od,id,Rv,$a,Sa,mn]);_e([zs,Da,ad,Pv,va,wa,ba,Ea]);_e([_a,ya,nd,My,Ca,qa,Aa,ds,$v]);_e([Pr,Lu,cd,ed,Na,Pa,Ra,ja,dr,za,$a,Sa,mn]);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 jv(s.elicitations,r)}return new se(t,r,n)}}class jv 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 Ua(e){return!!e._zod}function Ut(e,t){return Ua(e)?hu(e,t):e.safeParse(t)}function ld(e){var r,n;if(!e)return;let t;if(Ua(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 ud(e){var s;if(Ua(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 Zc(e){const t=ld(e),r=t==null?void 0:t.method;if(!r)throw new Error("Schema is missing a method literal");const n=ud(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Kc(e,t){const r=Ut(e,t);if(!r.success)throw r.error;return r.data}const Cv=6e4;class dd{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(_a,r=>{this._oncancel(r)}),this.setNotificationHandler(ya,r=>{this._onprogress(r)}),this.setRequestHandler(zs,r=>({})),this._taskStore=t==null?void 0:t.taskStore,this._taskMessageQueue=t==null?void 0:t.taskMessageQueue,this._taskStore&&(this.setRequestHandler(va,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(wa,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,f=this._requestResolvers.get(d);if(f)if(this._requestResolvers.delete(d),c.type==="response")f(l);else{const m=l,g=new se(m.error.code,m.error.message,m.error.data);f(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(ba,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(Ea,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),Yr(c)||dy(c)?this._onresponse(c):So(c)?this._onrequest(c,l):uy(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,f,m,g;const n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,s=this._transport,o=(m=(f=(d=t.params)==null?void 0:d._meta)==null?void 0:f[nr])==null?void 0:m.taskId;if(n===void 0){const _={jsonrpc:"2.0",id:t.id,error:{code:ae.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:_,timestamp:Date.now()},s==null?void 0:s.sessionId).catch(y=>this._onerror(new Error(`Failed to enqueue error response: ${y}`))):s==null||s.send(_).catch(y=>this._onerror(new Error(`Failed to send an error response: ${y}`)));return}const a=new AbortController;this._requestHandlerAbortControllers.set(t.id,a);const i=ly(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 _=>{if(a.signal.aborted)return;const y={relatedRequestId:t.id};o&&(y.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 h={...v,relatedRequestId:t.id};o&&!h.relatedTask&&(h.relatedTask={taskId:o});const $=((E=h.relatedTask)==null?void 0:E.taskId)??o;return $&&c&&await c.updateTaskStatus($,"input_required"),await this.request(_,y,h)},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 _=>{if(a.signal.aborted)return;const y={result:_,jsonrpc:"2.0",id:t.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:y,timestamp:Date.now()},s==null?void 0:s.sessionId):await(s==null?void 0:s.send(y))},async _=>{if(a.signal.aborted)return;const y={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(_.code)?_.code:ae.InternalError,message:_.message??"Internal error",..._.data!==void 0&&{data:_.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:y,timestamp:Date.now()},s==null?void 0:s.sessionId):await(s==null?void 0:s.send(y))}).catch(_=>this._onerror(new Error(`Failed to send response: ${_}`))).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),Yr(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(Yr(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),Yr(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,mn,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(f=>setTimeout(f,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,R,k,N;const f=A=>{d(A)};if(!this._transport){f(new Error("Not connected"));return}if((($=this._options)==null?void 0:$.enforceStrictCapabilities)===!0)try{this.assertCapabilityForMethod(t.method),i&&this.assertTaskCapability(t.method)}catch(A){f(A);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:{...((R=t.params)==null?void 0:R._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 _=A=>{var D;this._responseHandlers.delete(m),this._progressHandlers.delete(m),this._cleanupTimeout(m),(D=this._transport)==null||D.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:m,reason:String(A)}},{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a}).catch(L=>this._onerror(new Error(`Failed to send cancellation: ${L}`)));const F=A instanceof se?A:new se(ae.RequestTimeout,String(A));d(F)};this._responseHandlers.set(m,A=>{var F;if(!((F=n==null?void 0:n.signal)!=null&&F.aborted)){if(A instanceof Error)return d(A);try{const D=Ut(r,A.result);D.success?l(D.data):d(D.error)}catch(D){d(D)}}}),(N=n==null?void 0:n.signal)==null||N.addEventListener("abort",()=>{var A;_((A=n==null?void 0:n.signal)==null?void 0:A.reason)});const y=(n==null?void 0:n.timeout)??Cv,v=()=>_(se.fromError(ae.RequestTimeout,"Request timed out",{timeout:y}));this._setupTimeout(m,y,n==null?void 0:n.maxTotalTimeout,v,(n==null?void 0:n.resetTimeoutOnProgress)??!1);const h=c==null?void 0:c.taskId;if(h){const A=F=>{const D=this._responseHandlers.get(m);D?D(F):this._onerror(new Error(`Response handler missing for side-channeled request ${m}`))};this._requestResolvers.set(m,A),this._enqueueTaskMessage(h,{type:"request",message:g,timestamp:Date.now()}).catch(F=>{this._cleanupTimeout(m),d(F)})}else this._transport.send(g,{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a}).catch(A=>{this._cleanupTimeout(m),d(A)})})}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},Sa,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},Ty,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 f={...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:f,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 f={...t,jsonrpc:"2.0"};r!=null&&r.relatedTask&&(f={...f,params:{...f.params,_meta:{...((m=f.params)==null?void 0:m._meta)||{},[nr]:r.relatedTask}}}),(g=this._transport)==null||g.send(f,r).catch(_=>this._onerror(_))});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=Zc(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,o)=>{const a=Kc(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=Zc(t);this._notificationHandlers.set(n,s=>{const o=Kc(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"&&So(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=ds.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=ds.parse({method:"notifications/tasks/status",params:c});await this.notification(l),Qt(c.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>n.listTasks(s,r)}}}function Gc(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Nv(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];Gc(a)&&Gc(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 Iv extends dd{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 fd="2026-01-26",Ov="ui/notifications/tool-input-partial",xv=_e([I("light"),I("dark")]).describe("Color theme preference for the host environment."),gn=_e([I("inline"),I("fullscreen"),I("pip")]).describe("Display mode for UI presentation."),Av=_e([I("--color-background-primary"),I("--color-background-secondary"),I("--color-background-tertiary"),I("--color-background-inverse"),I("--color-background-ghost"),I("--color-background-info"),I("--color-background-danger"),I("--color-background-success"),I("--color-background-warning"),I("--color-background-disabled"),I("--color-text-primary"),I("--color-text-secondary"),I("--color-text-tertiary"),I("--color-text-inverse"),I("--color-text-ghost"),I("--color-text-info"),I("--color-text-danger"),I("--color-text-success"),I("--color-text-warning"),I("--color-text-disabled"),I("--color-border-primary"),I("--color-border-secondary"),I("--color-border-tertiary"),I("--color-border-inverse"),I("--color-border-ghost"),I("--color-border-info"),I("--color-border-danger"),I("--color-border-success"),I("--color-border-warning"),I("--color-border-disabled"),I("--color-ring-primary"),I("--color-ring-secondary"),I("--color-ring-inverse"),I("--color-ring-info"),I("--color-ring-danger"),I("--color-ring-success"),I("--color-ring-warning"),I("--font-sans"),I("--font-mono"),I("--font-weight-normal"),I("--font-weight-medium"),I("--font-weight-semibold"),I("--font-weight-bold"),I("--font-text-xs-size"),I("--font-text-sm-size"),I("--font-text-md-size"),I("--font-text-lg-size"),I("--font-heading-xs-size"),I("--font-heading-sm-size"),I("--font-heading-md-size"),I("--font-heading-lg-size"),I("--font-heading-xl-size"),I("--font-heading-2xl-size"),I("--font-heading-3xl-size"),I("--font-text-xs-line-height"),I("--font-text-sm-line-height"),I("--font-text-md-line-height"),I("--font-text-lg-line-height"),I("--font-heading-xs-line-height"),I("--font-heading-sm-line-height"),I("--font-heading-md-line-height"),I("--font-heading-lg-line-height"),I("--font-heading-xl-line-height"),I("--font-heading-2xl-line-height"),I("--font-heading-3xl-line-height"),I("--border-radius-xs"),I("--border-radius-sm"),I("--border-radius-md"),I("--border-radius-lg"),I("--border-radius-xl"),I("--border-radius-full"),I("--border-width-regular"),I("--shadow-hairline"),I("--shadow-sm"),I("--shadow-md"),I("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),Mv=$e(Av.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([T(),vo()]).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.`),zv=M({method:I("ui/open-link"),params:M({url:T().describe("URL to open in the host's browser")})});M({isError:ve().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough();M({isError:ve().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough();M({isError:ve().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();var qv=M({method:I("ui/notifications/sandbox-proxy-ready"),params:M({})}),Fa=M({connectDomains:G(T()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket). - -- Maps to CSP \`connect-src\` directive -- Empty or omitted → no network connections (secure default)`),resourceDomains:G(T()).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:G(T()).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:G(T()).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'`)")}),La=M({camera:M({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:M({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:M({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:M({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),Dv=M({method:I("ui/notifications/size-changed"),params:M({width:fe().optional().describe("New width in pixels."),height:fe().optional().describe("New height in pixels.")})});M({method:I("ui/notifications/tool-input"),params:M({arguments:$e(T(),Se().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})});M({method:I("ui/notifications/tool-input-partial"),params:M({arguments:$e(T(),Se().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})});M({method:I("ui/notifications/tool-cancelled"),params:M({reason:T().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})});var Uv=M({fonts:T().optional()}),Fv=M({variables:Mv.optional().describe("CSS variables for theming the app."),css:Uv.optional().describe("CSS blocks that apps can inject.")});M({method:I("ui/resource-teardown"),params:M({})});var Lv=$e(T(),Se()),Wc=M({text:M({}).optional().describe("Host supports text content blocks."),image:M({}).optional().describe("Host supports image content blocks."),audio:M({}).optional().describe("Host supports audio content blocks."),resource:M({}).optional().describe("Host supports resource content blocks."),resourceLink:M({}).optional().describe("Host supports resource link content blocks."),structuredContent:M({}).optional().describe("Host supports structured content.")}),Vv=M({method:I("ui/notifications/request-teardown"),params:M({}).optional()}),Hv=M({experimental:$e(T(),$e(T(),fa()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:M({}).optional().describe("Host supports opening external URLs."),downloadFile:M({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:M({listChanged:ve().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:M({listChanged:ve().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:M({}).optional().describe("Host accepts log messages."),sandbox:M({permissions:La.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:Fa.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:Wc.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:Wc.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:M({tools:M({}).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.")}),Zv=M({experimental:$e(T(),$e(T(),fa()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:M({listChanged:ve().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:G(gn).optional().describe("Display modes the app supports.")}),Kv=M({method:I("ui/notifications/initialized"),params:M({}).optional()});M({csp:Fa.optional().describe("Content Security Policy configuration for UI resources."),permissions:La.optional().describe("Sandbox permissions requested by the UI resource."),domain:T().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 Bc=M({method:I("ui/request-display-mode"),params:M({mode:gn.describe("The display mode being requested.")})});M({mode:gn.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough();var Gv=_e([I("model"),I("app")]).describe("Tool visibility scope - who can access the tool.");M({resourceUri:T().optional(),visibility:G(Gv).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:$o().optional(),permissions:$o().optional()});M({mimeTypes:G(T()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});var Wv=M({method:I("ui/download-file"),params:M({contents:G(_e([Yu,Xu])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),Bv=M({method:I("ui/message"),params:M({role:I("user").describe('Message role, currently only "user" is supported.'),content:G(Tn).describe("Message content blocks (text, image, etc.).")})});M({method:I("ui/notifications/sandbox-resource-ready"),params:M({html:T().describe("HTML content to load into the inner iframe."),sandbox:T().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Fa.optional().describe("CSP configuration from resource metadata."),permissions:La.optional().describe("Sandbox permissions from resource metadata.")})});M({method:I("ui/notifications/tool-result"),params:dr.describe("Standard MCP tool execution result.")});var hd=M({toolInfo:M({id:bn.optional().describe("JSON-RPC id of the tools/call request."),tool:Ma.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:xv.optional().describe("Current color theme preference."),styles:Fv.optional().describe("Style configuration for theming the app."),displayMode:gn.optional().describe("How the UI is currently displayed."),availableDisplayModes:G(gn).optional().describe("Display modes the host supports."),containerDimensions:_e([M({height:fe().describe("Fixed container height in pixels.")}),M({maxHeight:_e([fe(),vo()]).optional().describe("Maximum container height in pixels.")})]).and(_e([M({width:fe().describe("Fixed container width in pixels.")}),M({maxWidth:_e([fe(),vo()]).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:T().optional().describe("User's language and region preference in BCP 47 format."),timeZone:T().optional().describe("User's timezone in IANA format."),userAgent:T().optional().describe("Host application identifier."),platform:_e([I("web"),I("desktop"),I("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:M({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:M({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();M({method:I("ui/notifications/host-context-changed"),params:hd.describe("Partial context update containing only changed fields.")});var Jv=M({method:I("ui/update-model-context"),params:M({content:G(Tn).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:$e(T(),Se().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),Qv=M({method:I("ui/initialize"),params:M({appInfo:Ms.describe("App identification (name and version)."),appCapabilities:Zv.describe("Features and capabilities this app provides."),protocolVersion:T().describe("Protocol version this app supports.")})});M({protocolVersion:T().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Ms.describe("Host application identification and version."),hostCapabilities:Hv.describe("Features and capabilities provided by the host."),hostContext:hd.describe("Rich context about the host environment.")}).passthrough();class Yv{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=Qn.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!==Ov&&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 Xv=[fd];class e$ extends Iv{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:Dv,sandboxready:qv,initialized:Kv,requestteardown:Vv,loggingmessage:nd});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(Qv,a=>this._oninitialize(a)),this.setRequestHandler(zs,(a,i)=>{var c;return(c=this.onping)==null||c.call(this,a.params,i),{}}),this.replaceRequestHandler(Bc,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(Bv,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(zv,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(Wv,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(Bc,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(Jv,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(td,async(n,s)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,s)})}set oncreatesamplingmessage(r){this.setRequestHandler(Da,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(Wu,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(Bu,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(Ju,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(Qu,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:Xv.includes(n)?n:fd,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];t$(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},Lv,n)}callTool(r,n){return this.request({method:"tools/call",params:r},dr,n)}listTools(r,n){return this.request({method:"tools/list",params:r},za,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},dr,{signal:o.signal}),n.tools.listChanged&&this._client.setNotificationHandler(qa,s=>this.sendToolListChanged(s.params))),n.resources&&(this.onlistresources=async(s,o)=>this._client.request({method:"resources/list",params:s},Pa,{signal:o.signal}),this.onlistresourcetemplates=async(s,o)=>this._client.request({method:"resources/templates/list",params:s},Ra,{signal:o.signal}),this.onreadresource=async(s,o)=>this._client.request({method:"resources/read",params:s},ja,{signal:o.signal}),n.resources.listChanged&&this._client.setNotificationHandler(Ca,s=>this.sendResourceListChanged(s.params))),n.prompts&&(this.onlistprompts=async(s,o)=>this._client.request({method:"prompts/list",params:s},Na,{signal:o.signal}),n.prompts.listChanged&&this._client.setNotificationHandler(Aa,s=>this.sendPromptListChanged(s.params)))}return super.connect(r)}}function t$(e,t){return JSON.stringify(e)===JSON.stringify(t)}const r$={x:0,y:0,width:1024,height:768},Eo=28,n$=12,s$=.9;function Ft(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function pd(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return e}function ko(e){if(Array.isArray(e))return e.map(ko);const t=pd(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,` -`):ko(n)])):e}function o$(e){return e.type==="text"&&typeof(e.text??e.originalText)=="string"}function md(e){const t=String(e.text??e.originalText??""),r=Ft(e.fontSize)??20,n=t.length*r*s$,s=Ft(e.width);return Math.max(s&&s>0?s:0,n)}function a$(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 r$}function i$(e,t){const r=Ft(e.x);if(r===void 0)return!1;const n=md(e),s=t.x+Eo,o=t.x+t.width-Eo;return ro+1}function c$(e,t){const r={...e},n=Ft(r.fontSize)??20;let s=md(r);const o=Math.max(1,t.width-Eo*2);if(s>o){const a=o/s;r.fontSize=Math.max(n$,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 l$(e){const r=ko(e).map(pd);if(r.some(o=>o===void 0))return e;const n=r,s=a$(n);return n.map(o=>!o$(o)||!i$(o,s)?o:c$(o,s))}var Po={exports:{}},gd={},Et={},xr={},jn={},ge={},_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,R)=>`${E}${R}`,"")}get names(){var $;return($=this._names)!==null&&$!==void 0?$:this._names=this._items.reduce((E,R)=>(R instanceof r&&(E[R.str]=(E[R.str]||0)+1),E),{})}}e._Code=n,e.nil=new n("");function s(h,...$){const E=[h[0]];let R=0;for(;R<$.length;)i(E,$[R]),E.push(h[++R]);return new n(E)}e._=s;const o=new n("+");function a(h,...$){const E=[g(h[0])];let R=0;for(;R<$.length;)E.push(o),i(E,$[R]),E.push(o,g(h[++R]));return c(E),new n(E)}e.str=a;function i(h,$){$ instanceof n?h.push(...$._items):$ instanceof r?h.push($):h.push(f($))}e.addCodeArg=i;function c(h){let $=1;for(;${if(f.scopePath===void 0)throw new Error(`CodeGen: name "${f}" has no value`);return(0,t._)`${l}${f.scopePath}`})}scopeCode(l=this._values,d,f){return this._reduceValues(l,m=>{if(m.value===void 0)throw new Error(`CodeGen: name "${m}" has no value`);return m.value.code},d,f)}_reduceValues(l,d,f={},m){let g=t.nil;for(const _ in l){const y=l[_];if(!y)continue;const v=f[_]=f[_]||new Map;y.forEach(h=>{if(v.has(h))return;v.set(h,n.Started);let $=d(h);if($){const E=this.opts.es5?e.varKinds.var:e.varKinds.const;g=(0,t._)`${g}${E} ${h} = ${$};${this.opts._n}`}else if($=m==null?void 0:m(h))g=(0,t._)`${g}${$}${this.opts._n}`;else throw new r(h);v.set(h,n.Completed)})}return g}}e.ValueScope=i})(Ro);(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=Ro;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=Ro;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 f 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 U=P[q];U.optimizeNames(u,p)||(ie(u,U.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 _ extends g{render(u){return"{"+u._n+super.render(u)+"}"+u._n}}class y extends g{}class v extends _{}v.kind="else";class h extends _{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 h?p:p.nodes:this.nodes.length?this:new h(ke(u),p instanceof h?[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}}h.kind="if";class $ extends _{}$.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 R 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:U}=this;return`for(${p} ${P}=${q}; ${P}<${U}; ${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 N extends _{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)}}N.kind="func";class A extends g{render(u){return"return "+super.render(u)}}A.kind="return";class F extends _{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 D extends _{constructor(u){super(),this.error=u}render(u){return`catch(${this.error})`+super.render(u)}}D.kind="catch";class L extends _{render(u){return"finally"+super.render(u)}}L.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 y]}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 U=this._scope.toName(p);return P!==void 0&&q&&(this._constants[U.str]=P),this._leafNode(new a(u,U,P)),U}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 h(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 h(u))}else(){return this._elseNode(new v)}endIf(){return this._endBlockNode(h,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,U=this.opts.es5?r.varKinds.var:r.varKinds.let){const X=this._scope.toName(u);return this._for(new R(U,X,p,P),()=>q(X))}forOf(u,p,P,q=r.varKinds.const){const U=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(U,(0,t._)`${X}[${Y}]`),P(U)})}return this._for(new k("of",q,U,p),()=>P(U))}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 U=this._scope.toName(u);return this._for(new k("in",q,U,p),()=>P(U))}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 A;if(this._blockNode(p),this.code(u),p.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(A)}try(u,p,P){if(!p&&!P)throw new Error('CodeGen: "try" without "catch" and "finally"');const q=new F;if(this._blockNode(q),this.code(u),p){const U=this.name("e");this._currNode=q.catch=new D(U),p(U)}return P&&(this._currNode=q.finally=new L,this.code(P)),this._endBlockNode(D,L)}throw(u){return this._leafNode(new f(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 N(u,p,P)),q&&this.code(q).endFunc(),this}endFunc(){return this._endBlockNode(N)}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 h))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((U,X)=>(X instanceof t.Name&&(X=P(X)),X instanceof t._Code?U.push(...X._items):U.push(X),U),[]));function P(U){const X=p[U.str];return X===void 0||u[U.str]!==1?U:(delete u[U.str],X)}function q(U){return U instanceof t._Code&&U._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._)`!${j(S)}`}e.not=ke;const ye=b(e.operators.AND);function ct(...S){return S.reduce(ye)}e.and=ct;const Oe=b(e.operators.OR);function x(...S){return S.reduce(Oe)}e.or=x;function b(S){return(u,p)=>u===t.nil?p:p===t.nil?u:(0,t._)`${j(u)} ${S} ${j(p)}`}function j(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,u$=_n;function d$(e){const t={};for(const r of e)t[r]=!0;return t}J.toHash=d$;function f$(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(_d(e,t),!yd(t,e.self.RULES.all))}J.alwaysValidSchema=f$;function _d(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]||wd(e,`unknown keyword: "${o}"`)}J.checkUnknownRules=_d;function yd(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(t[r])return!0;return!1}J.schemaHasRules=yd;function h$(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=h$;function p$({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=p$;function m$(e){return vd(decodeURIComponent(e))}J.unescapeFragment=m$;function g$(e){return encodeURIComponent(Va(e))}J.escapeFragment=g$;function Va(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}J.escapeJsonPointer=Va;function vd(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}J.unescapeJsonPointer=vd;function _$(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)}J.eachItem=_$;function Jc({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:Jc({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} || {}`),Ha(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:$d}),items:Jc({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&&Ha(e,r,t),r}J.evaluatedPropsToName=$d;function Ha(e,t,r){Object.keys(r).forEach(n=>e.assign((0,we._)`${t}${(0,we.getProperty)(n)}`,!0))}J.setEvaluated=Ha;const Qc={};function y$(e,t){return e.scopeValue("func",{ref:t,code:Qc[t.code]||(Qc[t.code]=new u$._Code(t.code))})}J.useFunc=y$;var To;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(To||(J.Type=To={}));function v$(e,t,r){if(e instanceof we.Name){const n=t===To.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():"/"+Va(e)}J.getErrorPath=v$;function wd(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=wd;var jt={};Object.defineProperty(jt,"__esModule",{value:!0});const Xe=ge,$$={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")};jt.default=$$;(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=jt;e.keywordError={message:({keyword:v})=>(0,t.str)`must pass "${v}" keyword validation`},e.keyword$DataError={message:({keyword:v,schemaType:h})=>h?(0,t.str)`"${v}" keyword must be ${h} ($data)`:(0,t.str)`"${v}" keyword is invalid ($data)`};function s(v,h=e.keywordError,$,E){const{it:R}=v,{gen:k,compositeRule:N,allErrors:A}=R,F=f(v,h,$);E??(N||A)?c(k,F):l(R,(0,t._)`[${F}]`)}e.reportError=s;function o(v,h=e.keywordError,$){const{it:E}=v,{gen:R,compositeRule:k,allErrors:N}=E,A=f(v,h,$);c(R,A),k||N||l(E,n.default.vErrors)}e.reportExtraError=o;function a(v,h){v.assign(n.default.errors,h),v.if((0,t._)`${n.default.vErrors} !== null`,()=>v.if(h,()=>v.assign((0,t._)`${n.default.vErrors}.length`,h),()=>v.assign(n.default.vErrors,null)))}e.resetErrorsCount=a;function i({gen:v,keyword:h,schemaValue:$,data:E,errsCount:R,it:k}){if(R===void 0)throw new Error("ajv implementation error");const N=v.name("err");v.forRange("i",R,n.default.errors,A=>{v.const(N,(0,t._)`${n.default.vErrors}[${A}]`),v.if((0,t._)`${N}.instancePath === undefined`,()=>v.assign((0,t._)`${N}.instancePath`,(0,t.strConcat)(n.default.instancePath,k.errorPath))),v.assign((0,t._)`${N}.schemaPath`,(0,t.str)`${k.errSchemaPath}/${h}`),k.opts.verbose&&(v.assign((0,t._)`${N}.schema`,$),v.assign((0,t._)`${N}.data`,E))})}e.extendErrors=i;function c(v,h){const $=v.const("err",h);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,h){const{gen:$,validateName:E,schemaEnv:R}=v;R.$async?$.throw((0,t._)`new ${v.ValidationError}(${h})`):($.assign((0,t._)`${E}.errors`,h),$.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 f(v,h,$){const{createErrors:E}=v.it;return E===!1?(0,t._)`{}`:m(v,h,$)}function m(v,h,$={}){const{gen:E,it:R}=v,k=[g(R,$),_(v,$)];return y(v,h,k),E.object(...k)}function g({errorPath:v},{instancePath:h}){const $=h?(0,t.str)`${v}${(0,r.getErrorPath)(h,r.Type.Str)}`:v;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,$)]}function _({keyword:v,it:{errSchemaPath:h}},{schemaPath:$,parentSchema:E}){let R=E?h:(0,t.str)`${h}/${v}`;return $&&(R=(0,t.str)`${R}${(0,r.getErrorPath)($,r.Type.Str)}`),[d.schemaPath,R]}function y(v,{params:h,message:$},E){const{keyword:R,data:k,schemaValue:N,it:A}=v,{opts:F,propertyName:D,topSchemaRef:L,schemaPath:Z}=A;E.push([d.keyword,R],[d.params,typeof h=="function"?h(v):h||(0,t._)`{}`]),F.messages&&E.push([d.message,typeof $=="function"?$(v):$]),F.verbose&&E.push([d.schema,N],[d.parentSchema,(0,t._)`${L}${Z}`],[n.default.data,k]),D&&E.push([d.propertyName,D])}})(jn);Object.defineProperty(xr,"__esModule",{value:!0});xr.boolOrEmptySchema=xr.topBoolOrEmptySchema=void 0;const w$=jn,b$=ge,S$=jt,E$={message:"boolean schema is false"};function k$(e){const{gen:t,schema:r,validateName:n}=e;r===!1?bd(e,!1):typeof r=="object"&&r.$async===!0?t.return(S$.default.data):(t.assign((0,b$._)`${n}.errors`,null),t.return(!0))}xr.topBoolOrEmptySchema=k$;function P$(e,t){const{gen:r,schema:n}=e;n===!1?(r.var(t,!1),bd(e)):r.var(t,!0)}xr.boolOrEmptySchema=P$;function bd(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,w$.reportError)(s,E$,void 0,t)}var qe={},fr={};Object.defineProperty(fr,"__esModule",{value:!0});fr.getRules=fr.isJSONType=void 0;const R$=["string","number","integer","boolean","null","object","array"],T$=new Set(R$);function j$(e){return typeof e=="string"&&T$.has(e)}fr.isJSONType=j$;function C$(){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:{}}}fr.getRules=C$;var xt={};Object.defineProperty(xt,"__esModule",{value:!0});xt.shouldUseRule=xt.shouldUseGroup=xt.schemaHasRulesForType=void 0;function N$({schema:e,self:t},r){const n=t.RULES.types[r];return n&&n!==!0&&Sd(e,n)}xt.schemaHasRulesForType=N$;function Sd(e,t){return t.rules.some(r=>Ed(e,r))}xt.shouldUseGroup=Sd;function Ed(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))}xt.shouldUseRule=Ed;Object.defineProperty(qe,"__esModule",{value:!0});qe.reportTypeError=qe.checkDataTypes=qe.checkDataType=qe.coerceAndCheckDataType=qe.getJSONTypes=qe.getSchemaTypes=qe.DataType=void 0;const I$=fr,O$=xt,x$=jn,ue=ge,kd=J;var jr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(jr||(qe.DataType=jr={}));function A$(e){const t=Pd(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=A$;function Pd(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(I$.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}qe.getJSONTypes=Pd;function M$(e,t){const{gen:r,data:n,opts:s}=e,o=z$(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0,O$.schemaHasRulesForType)(e,t[0]));if(a){const i=Za(t,n,s.strictNumbers,jr.Wrong);r.if(i,()=>{o.length?q$(e,t,o):Ka(e)})}return a}qe.coerceAndCheckDataType=M$;const Rd=new Set(["string","number","integer","boolean","null"]);function z$(e,t){return t?e.filter(r=>Rd.has(r)||t==="array"&&r==="array"):[]}function q$(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(Za(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0,ue._)`${i} !== undefined`);for(const l of r)(Rd.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),Ka(e),n.endIf(),n.if((0,ue._)`${i} !== undefined`,()=>{n.assign(s,i),D$(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 D$({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,ue._)`${t} !== undefined`,()=>e.assign((0,ue._)`${t}[${r}]`,n))}function jo(e,t,r,n=jr.Correct){const s=n===jr.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===jr.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=jo;function Za(e,t,r,n){if(e.length===1)return jo(e[0],t,r,n);let s;const o=(0,kd.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,jo(a,t,r,n));return s}qe.checkDataTypes=Za;const U$={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,ue._)`{type: ${e}}`:(0,ue._)`{type: ${t}}`};function Ka(e){const t=F$(e);(0,x$.reportError)(t,U$)}qe.reportTypeError=Ka;function F$(e){const{gen:t,data:r,schema:n}=e,s=(0,kd.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}var qs={};Object.defineProperty(qs,"__esModule",{value:!0});qs.assignDefaults=void 0;const vr=ge,L$=J;function V$(e,t){const{properties:r,items:n}=e.schema;if(t==="object"&&r)for(const s in r)Yc(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>Yc(e,o,s.default))}qs.assignDefaults=V$;function Yc(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,L$.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 Tt={},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,Ga=J,Mt=jt,H$=J;function Z$(e,t){const{gen:r,data:n,it:s}=e;r.if(Ba(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Pe._)`${t}`},!0),e.error()})}pe.checkReportMissingProp=Z$;function K$({gen:e,data:t,it:{opts:r}},n,s){return(0,Pe.or)(...n.map(o=>(0,Pe.and)(Ba(e,t,o,r.ownProperties),(0,Pe._)`${s} = ${o}`)))}pe.checkMissingProp=K$;function G$(e,t){e.setParams({missingProperty:t},!0),e.error()}pe.reportMissingProp=G$;function Td(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Pe._)`Object.prototype.hasOwnProperty`})}pe.hasPropFunc=Td;function Wa(e,t,r){return(0,Pe._)`${Td(e)}.call(${t}, ${r})`}pe.isOwnProperty=Wa;function W$(e,t,r,n){const s=(0,Pe._)`${t}${(0,Pe.getProperty)(r)} !== undefined`;return n?(0,Pe._)`${s} && ${Wa(e,t,r)}`:s}pe.propertyInData=W$;function Ba(e,t,r,n){const s=(0,Pe._)`${t}${(0,Pe.getProperty)(r)} === undefined`;return n?(0,Pe.or)(s,(0,Pe.not)(Wa(e,t,r))):s}pe.noPropertyInData=Ba;function jd(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}pe.allSchemaProperties=jd;function B$(e,t){return jd(t).filter(r=>!(0,Ga.alwaysValidSchema)(e,t[r]))}pe.schemaProperties=B$;function J$({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,f=[[Mt.default.instancePath,(0,Pe.strConcat)(Mt.default.instancePath,o)],[Mt.default.parentData,a.parentData],[Mt.default.parentDataProperty,a.parentDataProperty],[Mt.default.rootData,Mt.default.rootData]];a.opts.dynamicRef&&f.push([Mt.default.dynamicAnchors,Mt.default.dynamicAnchors]);const m=(0,Pe._)`${d}, ${r.object(...f)}`;return c!==Pe.nil?(0,Pe._)`${i}.call(${c}, ${m})`:(0,Pe._)`${i}(${m})`}pe.callValidateCode=J$;const Q$=(0,Pe._)`new RegExp`;function Y$({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"?Q$:(0,H$.useFunc)(e,s)}(${r}, ${n})`})}pe.usePattern=Y$;function X$(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:Ga.Type.Num},o),t.if((0,Pe.not)(o),i)})}}pe.validateArray=X$;function ew(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,Ga.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=ew;Object.defineProperty(Tt,"__esModule",{value:!0});Tt.validateKeywordUsage=Tt.validSchemaType=Tt.funcKeywordCode=Tt.macroKeywordCode=void 0;const rt=ge,sr=jt,tw=pe,rw=jn;function nw(e,t){const{gen:r,keyword:n,schema:s,parentSchema:o,it:a}=e,i=t.macro.call(a.self,s,o,a),c=Cd(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))}Tt.macroKeywordCode=nw;function sw(e,t){var r;const{gen:n,keyword:s,schema:o,parentSchema:a,$data:i,it:c}=e;aw(c,t);const l=!i&&t.compile?t.compile.call(c.self,o,a,c):t.validate,d=Cd(n,s,l),f=n.let("valid");e.block$data(f,m),e.ok((r=t.valid)!==null&&r!==void 0?r:f);function m(){if(t.errors===!1)y(),t.modifying&&Xc(e),v(()=>e.error());else{const h=t.async?g():_();t.modifying&&Xc(e),v(()=>ow(e,h))}}function g(){const h=n.let("ruleErrs",null);return n.try(()=>y((0,rt._)`await `),$=>n.assign(f,!1).if((0,rt._)`${$} instanceof ${c.ValidationError}`,()=>n.assign(h,(0,rt._)`${$}.errors`),()=>n.throw($))),h}function _(){const h=(0,rt._)`${d}.errors`;return n.assign(h,null),y(rt.nil),h}function y(h=t.async?(0,rt._)`await `:rt.nil){const $=c.opts.passContext?sr.default.this:sr.default.self,E=!("compile"in t&&!i||t.schema===!1);n.assign(f,(0,rt._)`${h}${(0,tw.callValidateCode)(e,d,$,E)}`,t.modifying)}function v(h){var $;n.if((0,rt.not)(($=t.valid)!==null&&$!==void 0?$:f),h)}}Tt.funcKeywordCode=sw;function Xc(e){const{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,rt._)`${n.parentData}[${n.parentDataProperty}]`))}function ow(e,t){const{gen:r}=e;r.if((0,rt._)`Array.isArray(${t})`,()=>{r.assign(sr.default.vErrors,(0,rt._)`${sr.default.vErrors} === null ? ${t} : ${sr.default.vErrors}.concat(${t})`).assign(sr.default.errors,(0,rt._)`${sr.default.vErrors}.length`),(0,rw.extendErrors)(e)},()=>e.error())}function aw({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function Cd(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 iw(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")}Tt.validSchemaType=iw;function cw({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)}}Tt.validateKeywordUsage=cw;var Zt={};Object.defineProperty(Zt,"__esModule",{value:!0});Zt.extendSubschemaMode=Zt.extendSubschemaData=Zt.getSubschema=void 0;const Rt=ge,Nd=J;function lw(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,Rt._)`${e.schemaPath}${(0,Rt.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:i[r],schemaPath:(0,Rt._)`${e.schemaPath}${(0,Rt.getProperty)(t)}${(0,Rt.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,Nd.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=lw;function uw(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:f}=t,m=i.let("data",(0,Rt._)`${t.data}${(0,Rt.getProperty)(r)}`,!0);c(m),e.errorPath=(0,Rt.str)`${l}${(0,Nd.getErrorPath)(r,n,f.jsPropertySyntax)}`,e.parentDataProperty=(0,Rt._)`${r}`,e.dataPathArr=[...d,e.parentDataProperty]}if(s!==void 0){const l=s instanceof Rt.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=uw;function dw(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=dw;var Ge={},Ds=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},Id={exports:{}},Lt=Id.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(){};Yn(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 Yn(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 f=n[d];if(Array.isArray(f)){if(d in Lt.arrayKeywords)for(var m=0;mt+=Od(n)),t===1/0))return 1/0}return t}function xd(e,t="",r){r!==!1&&(t=Cr(t));const n=e.parse(t);return Ad(e,n)}Ge.getFullPath=xd;function Ad(e,t){return e.serialize(t).split("#")[0]+"#"}Ge._getFullPath=Ad;const $w=/#\/?$/;function Cr(e){return e?e.replace($w,""):""}Ge.normalizeId=Cr;function ww(e,t,r){return r=Cr(r),e.resolve(t,r)}Ge.resolveUrl=ww;const bw=/^[a-z_][-a-z0-9._]*$/i;function Sw(e,t){if(typeof e=="boolean")return{};const{schemaId:r,uriResolver:n}=this.opts,s=Cr(e[r]||t),o={"":s},a=xd(n,s,!1),i={},c=new Set;return gw(e,{allKeys:!0},(f,m,g,_)=>{if(_===void 0)return;const y=a+m;let v=o[_];typeof f[r]=="string"&&(v=h.call(this,f[r])),$.call(this,f.$anchor),$.call(this,f.$dynamicAnchor),o[m]=v;function h(E){const R=this.opts.uriResolver.resolve;if(E=Cr(v?R(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(f,k.schema,E):E!==Cr(y)&&(E[0]==="#"?(l(f,i[E],E),i[E]=f):this.refs[E]=y),E}function $(E){if(typeof E=="string"){if(!bw.test(E))throw new Error(`invalid anchor "${E}"`);h.call(this,`#${E}`)}}}),i;function l(f,m,g){if(m!==void 0&&!mw(f,m))throw d(g)}function d(f){return new Error(`reference "${f}" resolves to more than one schema`)}}Ge.getSchemaRefs=Sw;Object.defineProperty(Et,"__esModule",{value:!0});Et.getData=Et.KeywordCxt=Et.validateFunctionCode=void 0;const Md=xr,el=qe,Ja=xt,hs=qe,Ew=qs,nn=Tt,eo=Zt,ne=ge,oe=jt,kw=Ge,At=J,Wr=jn;function Pw(e){if(Dd(e)&&(Ud(e),qd(e))){jw(e);return}zd(e,()=>(0,Md.topBoolOrEmptySchema)(e))}Et.validateFunctionCode=Pw;function zd({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"; ${tl(r,s)}`),Tw(e,s),e.code(o)}):e.func(t,(0,ne._)`${oe.default.data}, ${Rw(s)}`,n.$async,()=>e.code(tl(r,s)).code(o))}function Rw(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 Tw(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 jw(e){const{schema:t,opts:r,gen:n}=e;zd(e,()=>{r.$comment&&t.$comment&&Ld(e),xw(e),n.let(oe.default.vErrors,null),n.let(oe.default.errors,0),r.unevaluated&&Cw(e),Fd(e),zw(e)})}function Cw(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 tl(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 Nw(e,t){if(Dd(e)&&(Ud(e),qd(e))){Iw(e,t);return}(0,Md.boolOrEmptySchema)(e,t)}function qd({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 Dd(e){return typeof e.schema!="boolean"}function Iw(e,t){const{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&Ld(e),Aw(e),Mw(e);const o=n.const("_errs",oe.default.errors);Fd(e,o),n.var(t,(0,ne._)`${o} === ${oe.default.errors}`)}function Ud(e){(0,At.checkUnknownRules)(e),Ow(e)}function Fd(e,t){if(e.opts.jtd)return rl(e,[],!1,t);const r=(0,el.getSchemaTypes)(e.schema),n=(0,el.coerceAndCheckDataType)(e,r);rl(e,r,!n,t)}function Ow(e){const{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,At.schemaHasRulesButRef)(t,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function xw(e){const{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,At.checkStrictMode)(e,"default is ignored in the schema root")}function Aw(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,kw.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function Mw(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Ld({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 zw(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&&qw(e),t.return((0,ne._)`${oe.default.errors} === 0`))}function qw({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 rl(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,At.schemaHasRulesButRef)(o,d))){s.block(()=>Zd(e,"$ref",d.all.$ref.definition));return}c.jtd||Dw(e,t),s.block(()=>{for(const m of d.rules)f(m);f(d.post)});function f(m){(0,Ja.shouldUseGroup)(o,m)&&(m.type?(s.if((0,hs.checkDataType)(m.type,a,c.strictNumbers)),nl(e,m),t.length===1&&t[0]===m.type&&r&&(s.else(),(0,hs.reportTypeError)(e)),s.endIf()):nl(e,m),i||s.if((0,ne._)`${oe.default.errors} === ${n||0}`))}}function nl(e,t){const{gen:r,schema:n,opts:{useDefaults:s}}=e;s&&(0,Ew.assignDefaults)(e,t.type),r.block(()=>{for(const o of t.rules)(0,Ja.shouldUseRule)(n,o)&&Zd(e,o.keyword,o.definition,t.type)})}function Dw(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(Uw(e,t),e.opts.allowUnionTypes||Fw(e,t),Lw(e,e.dataTypes))}function Uw(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{Vd(e.dataTypes,r)||Qa(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),Hw(e,t)}}function Fw(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Qa(e,"use allowUnionTypes to allow union type keyword")}function Lw(e,t){const r=e.self.RULES.all;for(const n in r){const s=r[n];if(typeof s=="object"&&(0,Ja.shouldUseRule)(e.schema,s)){const{type:o}=s.definition;o.length&&!o.some(a=>Vw(t,a))&&Qa(e,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function Vw(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function Vd(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function Hw(e,t){const r=[];for(const n of e.dataTypes)Vd(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function Qa(e,t){const r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,At.checkStrictMode)(e,t,e.opts.strictTypes)}class Hd{constructor(t,r,n){if((0,nn.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,At.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",Kd(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,nn.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?Wr.reportExtraError:Wr.reportError)(this,this.def.error,r)}$dataError(){(0,Wr.reportError)(this,this.def.$dataError||Wr.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Wr.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,hs.checkDataTypes)(c,r,o.opts.strictNumbers,hs.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,eo.getSubschema)(this.it,t);(0,eo.extendSubschemaData)(n,this.it,t),(0,eo.extendSubschemaMode)(n,t);const s={...this.it,...n,items:void 0,props:void 0};return Nw(s,r),s}mergeEvaluated(t,r){const{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=At.mergeEvaluated.props(s,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=At.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}}Et.KeywordCxt=Hd;function Zd(e,t,r,n){const s=new Hd(e,r,t);"code"in r?r.code(s,n):s.$data&&r.validate?(0,nn.funcKeywordCode)(s,r):"macro"in r?(0,nn.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,nn.funcKeywordCode)(s,r)}const Zw=/^\/(?:[^~]|~0|~1)*$/,Kw=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Kd(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,o;if(e==="")return oe.default.rootData;if(e[0]==="/"){if(!Zw.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,o=oe.default.rootData}else{const l=Kw.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,At.unescapeJsonPointer)(l))}`,a=(0,ne._)`${a} && ${o}`);return a;function c(l,d){return`Cannot access ${l} ${d} levels up, current level is ${t}`}}Et.getData=Kd;var Cn={};Object.defineProperty(Cn,"__esModule",{value:!0});class Gw extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}}Cn.default=Gw;var Dr={};Object.defineProperty(Dr,"__esModule",{value:!0});const to=Ge;let Ww=class extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,to.resolveUrl)(t,r,n),this.missingSchema=(0,to.normalizeId)((0,to.getFullPath)(t,this.missingRef))}};Dr.default=Ww;var ot={};Object.defineProperty(ot,"__esModule",{value:!0});ot.resolveSchema=ot.getCompilingSchema=ot.resolveRef=ot.compileSchema=ot.SchemaEnv=void 0;const _t=ge,Bw=Cn,Yt=jt,bt=Ge,sl=J,Jw=Et;let Us=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,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={}}};ot.SchemaEnv=Us;function Ya(e){const t=Gd.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 _t.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o});let i;e.$async&&(i=a.scopeValue("Error",{ref:Bw.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:Yt.default.data,parentData:Yt.default.parentData,parentDataProperty:Yt.default.parentDataProperty,dataNames:[Yt.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,Jw.validateFunctionCode)(l),a.optimize(this.opts.code.optimize);const f=a.toString();d=`${a.scopeRefs(Yt.default.scope)}return ${f}`,this.opts.code.process&&(d=this.opts.code.process(d,e));const g=new Function(`${Yt.default.self}`,`${Yt.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:f,scopeValues:a._values}),this.opts.unevaluated){const{props:_,items:y}=l;g.evaluated={props:_ instanceof _t.Name?void 0:_,items:y instanceof _t.Name?void 0:y,dynamicProps:_ instanceof _t.Name,dynamicItems:y instanceof _t.Name},g.source&&(g.source.evaluated=(0,_t.stringify)(g.evaluated))}return e.validate=g,e}catch(f){throw delete e.validate,delete e.validateName,d&&this.logger.error("Error compiling schema, function code:",d),f}finally{this._compilations.delete(e)}}ot.compileSchema=Ya;function Qw(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=e0.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 Us({schema:a,schemaId:i,root:e,baseId:t}))}if(o!==void 0)return e.refs[r]=Yw.call(this,o)}ot.resolveRef=Qw;function Yw(e){return(0,bt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Ya.call(this,e)}function Gd(e){for(const t of this._compilations)if(Xw(t,e))return t}ot.getCompilingSchema=Gd;function Xw(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function e0(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Fs.call(this,e,t)}function Fs(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 ro.call(this,r,e);const o=(0,bt.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){const i=Fs.call(this,e,a);return typeof(i==null?void 0:i.schema)!="object"?void 0:ro.call(this,r,i)}if(typeof(a==null?void 0:a.schema)=="object"){if(a.validate||Ya.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 Us({schema:i,schemaId:c,root:e,baseId:s})}return ro.call(this,r,a)}}ot.resolveSchema=Fs;const t0=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function ro(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,sl.unescapeFragment)(i)];if(c===void 0)return;r=c;const l=typeof r=="object"&&r[this.opts.schemaId];!t0.has(i)&&l&&(t=(0,bt.resolveUrl)(this.opts.uriResolver,t,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,sl.schemaHasRulesButRef)(r,this.RULES)){const i=(0,bt.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=Fs.call(this,n,i)}const{schemaId:a}=this.opts;if(o=o||new Us({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}const r0="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",n0="Meta-schema for $data reference (JSON AnySchema extension proposal)",s0="object",o0=["$data"],a0={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},i0=!1,c0={$id:r0,description:n0,type:s0,required:o0,properties:a0,additionalProperties:i0};var Xa={},Ls={exports:{}};const l0=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Wd=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),ei=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),Bd=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),u0=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function Jd(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 d0=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function ol(e){return e.length=0,!0}function f0(e,t,r){if(e.length){const n=Jd(e);if(n!=="")t.push(n);else return r.error=!0,!1;e.length=0}return!0}function h0(e){let t=0;const r={error:!1,address:"",zone:""},n=[],s=[];let o=!1,a=!1,i=f0;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=ol}else{s.push(l);continue}}return s.length&&(i===ol?r.zone=s.join(""):a?n.push(s.join("")):n.push(Jd(s))),r.address=n.join(""),r}function Qd(e){if(p0(e,":")<2)return{host:e,isIPV6:!1};const t=h0(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 p0(e,t){let r=0;for(let n=0;ng0[n])}function v0(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n65535))return"URI port is malformed."}function ms(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(B0);a!==null&&a[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",s=!0);const i=e.match(J0);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(W0);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=Q0(n,c);if(l!==void 0&&(n.error=n.error||l,s=!0),n.host)if(L0(n.host)===!1){const m=M0(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=sf(r.scheme||n.scheme);if(!r.unicodeSupport&&(!d||!d.unicodeSupport)&&n.host&&(r.domainHost||d&&d.domainHost)&&o===!1&&V0(n.host))try{n.host=new URL("http://"+n.host).hostname}catch(f){n.error=n.error||"Host's domain name can not be converted to ASCII: "+f}if((!d||d&&!d.skipNormalize)&&(e.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=F0(unescape(n.host),o))),n.path&&(n.path=D0(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 gs(e,t){return ms(e,t).parsed}function Y0(e,t){return af(e,t).normalized}function af(e,t){const{parsed:r,malformedAuthorityOrPort:n}=ms(e,t);return{normalized:n?e:hr(r,t),malformedAuthorityOrPort:n}}function al(e,t){if(typeof e=="string"){const{normalized:r,malformedAuthorityOrPort:n}=af(e,t);return n?void 0:r}if(typeof e=="object")return hr(e,t)}const ri={SCHEMES:H0,normalize:Z0,resolve:K0,resolveComponent:of,equal:G0,serialize:hr,parse:gs};Ls.exports=ri;Ls.exports.default=ri;Ls.exports.fastUri=ri;var cf=Ls.exports;Object.defineProperty(Xa,"__esModule",{value:!0});const lf=cf;lf.code='require("ajv/dist/runtime/uri").default';Xa.default=lf;(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=Et;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=Cn,s=Dr,o=fr,a=ot,i=ge,c=Ge,l=qe,d=J,f=c0,m=Xa,g=(x,b)=>new RegExp(x,b);g.code="new RegExp";const _=["removeAdditional","useDefaults","coerceTypes"],y=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."},h={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},$=200;function E(x){var b,j,S,u,p,P,q,U,X,Y,C,O,V,W,ee,ce,xe,tt,Fe,Le,Ae,kt,Ye,Wt,Bt;const gt=x.strict,Jt=(b=x.code)===null||b===void 0?void 0:b.optimize,Zr=Jt===!0||Jt===void 0?1:Jt||0,Kr=(S=(j=x.code)===null||j===void 0?void 0:j.regExp)!==null&&S!==void 0?S:g,Js=(u=x.uriResolver)!==null&&u!==void 0?u:m.default;return{strictSchema:(P=(p=x.strictSchema)!==null&&p!==void 0?p:gt)!==null&&P!==void 0?P:!0,strictNumbers:(U=(q=x.strictNumbers)!==null&&q!==void 0?q:gt)!==null&&U!==void 0?U:!0,strictTypes:(Y=(X=x.strictTypes)!==null&&X!==void 0?X:gt)!==null&&Y!==void 0?Y:"log",strictTuples:(O=(C=x.strictTuples)!==null&&C!==void 0?C:gt)!==null&&O!==void 0?O:"log",strictRequired:(W=(V=x.strictRequired)!==null&&V!==void 0?V:gt)!==null&&W!==void 0?W:!1,code:x.code?{...x.code,optimize:Zr,regExp:Kr}:{optimize:Zr,regExp:Kr},loopRequired:(ee=x.loopRequired)!==null&&ee!==void 0?ee:$,loopEnum:(ce=x.loopEnum)!==null&&ce!==void 0?ce:$,meta:(xe=x.meta)!==null&&xe!==void 0?xe:!0,messages:(tt=x.messages)!==null&&tt!==void 0?tt:!0,inlineRefs:(Fe=x.inlineRefs)!==null&&Fe!==void 0?Fe:!0,schemaId:(Le=x.schemaId)!==null&&Le!==void 0?Le:"$id",addUsedSchema:(Ae=x.addUsedSchema)!==null&&Ae!==void 0?Ae:!0,validateSchema:(kt=x.validateSchema)!==null&&kt!==void 0?kt:!0,validateFormats:(Ye=x.validateFormats)!==null&&Ye!==void 0?Ye:!0,unicodeRegExp:(Wt=x.unicodeRegExp)!==null&&Wt!==void 0?Wt:!0,int32range:(Bt=x.int32range)!==null&&Bt!==void 0?Bt:!0,uriResolver:Js}}class R{constructor(b={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,b=this.opts={...b,...E(b)};const{es5:j,lines:S}=this.opts.code;this.scope=new i.ValueScope({scope:{},prefixes:y,es5:j,lines:S}),this.logger=B(b.logger);const u=b.validateFormats;b.validateFormats=!1,this.RULES=(0,o.getRules)(),k.call(this,v,b,"NOT SUPPORTED"),k.call(this,h,b,"DEPRECATED","warn"),this._metaOpts=L.call(this),b.formats&&F.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),b.keywords&&D.call(this,b.keywords),typeof b.meta=="object"&&this.addMetaSchema(b.meta),A.call(this),b.validateFormats=u}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:b,meta:j,schemaId:S}=this.opts;let u=f;S==="id"&&(u={...f},u.id=u.$id,delete u.$id),j&&b&&this.addMetaSchema(u,u[S],!1)}defaultMeta(){const{meta:b,schemaId:j}=this.opts;return this.opts.defaultMeta=typeof b=="object"?b[j]||b:void 0}validate(b,j){let S;if(typeof b=="string"){if(S=this.getSchema(b),!S)throw new Error(`no schema with key or ref "${b}"`)}else S=this.compile(b);const u=S(j);return"$async"in S||(this.errors=S.errors),u}compile(b,j){const S=this._addSchema(b,j);return S.validate||this._compileSchemaEnv(S)}compileAsync(b,j){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:S}=this.opts;return u.call(this,b,j);async function u(Y,C){await p.call(this,Y.$schema);const O=this._addSchema(Y,C);return O.validate||P.call(this,O)}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(C){if(!(C instanceof s.default))throw C;return q.call(this,C),await U.call(this,C.missingSchema),P.call(this,Y)}}function q({missingSchema:Y,missingRef:C}){if(this.refs[Y])throw new Error(`AnySchema ${Y} is loaded but ${C} cannot be resolved`)}async function U(Y){const C=await X.call(this,Y);this.refs[Y]||await p.call(this,C.$schema),this.refs[Y]||this.addSchema(C,Y,j)}async function X(Y){const C=this._loading[Y];if(C)return C;try{return await(this._loading[Y]=S(Y))}finally{delete this._loading[Y]}}}addSchema(b,j,S,u=this.opts.validateSchema){if(Array.isArray(b)){for(const P of b)this.addSchema(P,void 0,S,u);return this}let p;if(typeof b=="object"){const{schemaId:P}=this.opts;if(p=b[P],p!==void 0&&typeof p!="string")throw new Error(`schema ${P} must be string`)}return j=(0,c.normalizeId)(j||p),this._checkUnique(j),this.schemas[j]=this._addSchema(b,S,j,u,!0),this}addMetaSchema(b,j,S=this.opts.validateSchema){return this.addSchema(b,j,!0,S),this}validateSchema(b,j){if(typeof b=="boolean")return!0;let S;if(S=b.$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,b);if(!u&&j){const p="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(p);else throw new Error(p)}return u}getSchema(b){let j;for(;typeof(j=N.call(this,b))=="string";)b=j;if(j===void 0){const{schemaId:S}=this.opts,u=new a.SchemaEnv({schema:{},schemaId:S});if(j=a.resolveSchema.call(this,u,b),!j)return;this.refs[b]=j}return j.validate||this._compileSchemaEnv(j)}removeSchema(b){if(b instanceof RegExp)return this._removeAllSchemas(this.schemas,b),this._removeAllSchemas(this.refs,b),this;switch(typeof b){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const j=N.call(this,b);return typeof j=="object"&&this._cache.delete(j.schema),delete this.schemas[b],delete this.refs[b],this}case"object":{const j=b;this._cache.delete(j);let S=b[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(b){for(const j of b)this.addKeyword(j);return this}addKeyword(b,j){let S;if(typeof b=="string")S=b,typeof j=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),j.keyword=S);else if(typeof b=="object"&&j===void 0){if(j=b,S=j.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,j),!j)return(0,d.eachItem)(S,p=>ie.call(this,p)),this;ye.call(this,j);const u={...j,type:(0,l.getJSONTypes)(j.type),schemaType:(0,l.getJSONTypes)(j.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(b){const j=this.RULES.all[b];return typeof j=="object"?j.definition:!!j}removeKeyword(b){const{RULES:j}=this;delete j.keywords[b],delete j.all[b];for(const S of j.rules){const u=S.rules.findIndex(p=>p.keyword===b);u>=0&&S.rules.splice(u,1)}return this}addFormat(b,j){return typeof j=="string"&&(j=new RegExp(j)),this.formats[b]=j,this}errorsText(b=this.errors,{separator:j=", ",dataVar:S="data"}={}){return!b||b.length===0?"No errors":b.map(u=>`${S}${u.instancePath} ${u.message}`).reduce((u,p)=>u+j+p)}$dataMetaSchema(b,j){const S=this.RULES.all;b=JSON.parse(JSON.stringify(b));for(const u of j){const p=u.split("/").slice(1);let P=b;for(const q of p)P=P[q];for(const q in S){const U=S[q];if(typeof U!="object")continue;const{$data:X}=U.definition,Y=P[q];X&&Y&&(P[q]=Oe(Y))}}return b}_removeAllSchemas(b,j){for(const S in b){const u=b[S];(!j||j.test(S))&&(typeof u=="string"?delete b[S]:u&&!u.meta&&(this._cache.delete(u.schema),delete b[S]))}}_addSchema(b,j,S,u=this.opts.validateSchema,p=this.opts.addUsedSchema){let P;const{schemaId:q}=this.opts;if(typeof b=="object")P=b[q];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof b!="boolean")throw new Error("schema must be object or boolean")}let U=this._cache.get(b);if(U!==void 0)return U;S=(0,c.normalizeId)(P||S);const X=c.getSchemaRefs.call(this,b,S);return U=new a.SchemaEnv({schema:b,schemaId:q,meta:j,baseId:S,localRefs:X}),this._cache.set(U.schema,U),p&&!S.startsWith("#")&&(S&&this._checkUnique(S),this.refs[S]=U),u&&this.validateSchema(b,!0),U}_checkUnique(b){if(this.schemas[b]||this.refs[b])throw new Error(`schema with key or id "${b}" already exists`)}_compileSchemaEnv(b){if(b.meta?this._compileMetaSchema(b):a.compileSchema.call(this,b),!b.validate)throw new Error("ajv implementation error");return b.validate}_compileMetaSchema(b){const j=this.opts;this.opts=this._metaOpts;try{a.compileSchema.call(this,b)}finally{this.opts=j}}}R.ValidationError=n.default,R.MissingRefError=s.default,e.default=R;function k(x,b,j,S="error"){for(const u in x){const p=u;p in b&&this.logger[S](`${j}: option ${u}. ${x[p]}`)}}function N(x){return x=(0,c.normalizeId)(x),this.schemas[x]||this.refs[x]}function A(){const x=this.opts.schemas;if(x)if(Array.isArray(x))this.addSchema(x);else for(const b in x)this.addSchema(x[b],b)}function F(){for(const x in this.opts.formats){const b=this.opts.formats[x];b&&this.addFormat(x,b)}}function D(x){if(Array.isArray(x)){this.addVocabulary(x);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const b in x){const j=x[b];j.keyword||(j.keyword=b),this.addKeyword(j)}}function L(){const x={...this.opts};for(const b of _)delete x[b];return x}const Z={log(){},warn(){},error(){}};function B(x){if(x===!1)return Z;if(x===void 0)return console;if(x.log&&x.warn&&x.error)return x;throw new Error("logger must implement log, warn and error methods")}const re=/^[a-z_$][a-z0-9_$:-]*$/i;function H(x,b){const{RULES:j}=this;if((0,d.eachItem)(x,S=>{if(j.keywords[S])throw new Error(`Keyword ${S} is already defined`);if(!re.test(S))throw new Error(`Keyword ${S} has invalid name`)}),!!b&&b.$data&&!("code"in b||"validate"in b))throw new Error('$data keyword must have "code" or "validate" function')}function ie(x,b,j){var S;const u=b==null?void 0:b.post;if(j&&u)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:p}=this;let P=u?p.post:p.rules.find(({type:U})=>U===j);if(P||(P={type:j,rules:[]},p.rules.push(P)),p.keywords[x]=!0,!b)return;const q={keyword:x,definition:{...b,type:(0,l.getJSONTypes)(b.type),schemaType:(0,l.getJSONTypes)(b.schemaType)}};b.before?ke.call(this,P,q,b.before):P.rules.push(q),p.all[x]=q,(S=b.implements)===null||S===void 0||S.forEach(U=>this.addKeyword(U))}function ke(x,b,j){const S=x.rules.findIndex(u=>u.keyword===j);S>=0?x.rules.splice(S,0,b):(x.rules.push(b),this.logger.warn(`rule ${j} is not defined`))}function ye(x){let{metaSchema:b}=x;b!==void 0&&(x.$data&&this.opts.$data&&(b=Oe(b)),x.validateSchema=this.compile(b,!0))}const ct={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Oe(x){return{anyOf:[x,ct]}}})(gd);var ni={},si={},oi={};Object.defineProperty(oi,"__esModule",{value:!0});const X0={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};oi.default=X0;var pr={};Object.defineProperty(pr,"__esModule",{value:!0});pr.callRef=pr.getValidate=void 0;const eb=Dr,il=pe,nt=ge,$r=jt,cl=ot,Dn=J,tb={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 f();const d=cl.resolveRef.call(c,l,s,r);if(d===void 0)throw new eb.default(n.opts.uriResolver,s,r);if(d instanceof cl.SchemaEnv)return m(d);return g(d);function f(){if(o===l)return es(e,a,o,o.$async);const _=t.scopeValue("root",{ref:l});return es(e,(0,nt._)`${_}.validate`,l,l.$async)}function m(_){const y=uf(e,_);es(e,y,_,_.$async)}function g(_){const y=t.scopeValue("schema",i.code.source===!0?{ref:_,code:(0,nt.stringify)(_)}:{ref:_}),v=t.name("valid"),h=e.subschema({schema:_,dataTypes:[],schemaPath:nt.nil,topSchemaRef:y,errSchemaPath:r},v);e.mergeEvaluated(h),e.ok(v)}}};function uf(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,nt._)`${r.scopeValue("wrapper",{ref:t})}.validate`}pr.getValidate=uf;function es(e,t,r,n){const{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:c}=o,l=c.passContext?$r.default.this:nt.nil;n?d():f();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");const _=s.let("valid");s.try(()=>{s.code((0,nt._)`await ${(0,il.callValidateCode)(e,t,l)}`),g(t),a||s.assign(_,!0)},y=>{s.if((0,nt._)`!(${y} instanceof ${o.ValidationError})`,()=>s.throw(y)),m(y),a||s.assign(_,!1)}),e.ok(_)}function f(){e.result((0,il.callValidateCode)(e,t,l),()=>g(t),()=>m(t))}function m(_){const y=(0,nt._)`${_}.errors`;s.assign($r.default.vErrors,(0,nt._)`${$r.default.vErrors} === null ? ${y} : ${$r.default.vErrors}.concat(${y})`),s.assign($r.default.errors,(0,nt._)`${$r.default.vErrors}.length`)}function g(_){var y;if(!o.opts.unevaluated)return;const v=(y=r==null?void 0:r.validate)===null||y===void 0?void 0:y.evaluated;if(o.props!==!0)if(v&&!v.dynamicProps)v.props!==void 0&&(o.props=Dn.mergeEvaluated.props(s,v.props,o.props));else{const h=s.var("props",(0,nt._)`${_}.evaluated.props`);o.props=Dn.mergeEvaluated.props(s,h,o.props,nt.Name)}if(o.items!==!0)if(v&&!v.dynamicItems)v.items!==void 0&&(o.items=Dn.mergeEvaluated.items(s,v.items,o.items));else{const h=s.var("items",(0,nt._)`${_}.evaluated.items`);o.items=Dn.mergeEvaluated.items(s,h,o.items,nt.Name)}}}pr.callRef=es;pr.default=tb;Object.defineProperty(si,"__esModule",{value:!0});const rb=oi,nb=pr,sb=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",rb.default,nb.default];si.default=sb;var ai={},ii={};Object.defineProperty(ii,"__esModule",{value:!0});const _s=ge,zt=_s.operators,ys={maximum:{okStr:"<=",ok:zt.LTE,fail:zt.GT},minimum:{okStr:">=",ok:zt.GTE,fail:zt.LT},exclusiveMaximum:{okStr:"<",ok:zt.LT,fail:zt.GTE},exclusiveMinimum:{okStr:">",ok:zt.GT,fail:zt.LTE}},ob={message:({keyword:e,schemaCode:t})=>(0,_s.str)`must be ${ys[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,_s._)`{comparison: ${ys[e].okStr}, limit: ${t}}`},ab={keyword:Object.keys(ys),type:"number",schemaType:"number",$data:!0,error:ob,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,_s._)`${r} ${ys[t].fail} ${n} || isNaN(${r})`)}};ii.default=ab;var ci={};Object.defineProperty(ci,"__esModule",{value:!0});const sn=ge,ib={message:({schemaCode:e})=>(0,sn.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,sn._)`{multipleOf: ${e}}`},cb={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:ib,code(e){const{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0,sn._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0,sn._)`${a} !== parseInt(${a})`;e.fail$data((0,sn._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};ci.default=cb;var li={},ui={};Object.defineProperty(ui,"__esModule",{value:!0});function df(e){const t=e.length;let r=0,n=0,s;for(;n=55296&&s<=56319&&n(0,or._)`{limit: ${e}}`},fb={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:db,code(e){const{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?or.operators.GT:or.operators.LT,a=s.opts.unicode===!1?(0,or._)`${r}.length`:(0,or._)`${(0,lb.useFunc)(e.gen,ub.default)}(${r})`;e.fail$data((0,or._)`${a} ${o} ${n}`)}};li.default=fb;var di={};Object.defineProperty(di,"__esModule",{value:!0});const hb=pe,pb=J,Rr=ge,mb={message:({schemaCode:e})=>(0,Rr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Rr._)`{pattern: ${e}}`},gb={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:mb,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,pb.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,hb.usePattern)(e,s);e.fail$data((0,Rr._)`!${c}.test(${r})`)}}};di.default=gb;var fi={};Object.defineProperty(fi,"__esModule",{value:!0});const on=ge,_b={message({keyword:e,schemaCode:t}){const r=e==="maxProperties"?"more":"fewer";return(0,on.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,on._)`{limit: ${e}}`},yb={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:_b,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?on.operators.GT:on.operators.LT;e.fail$data((0,on._)`Object.keys(${r}).length ${s} ${n}`)}};fi.default=yb;var hi={};Object.defineProperty(hi,"__esModule",{value:!0});const Br=pe,an=ge,vb=J,$b={message:({params:{missingProperty:e}})=>(0,an.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,an._)`{missingProperty: ${e}}`},wb={keyword:"required",type:"object",schemaType:"array",$data:!0,error:$b,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:_}=e.it;for(const y of r)if((g==null?void 0:g[y])===void 0&&!_.has(y)){const v=a.schemaEnv.baseId+a.errSchemaPath,h=`required property "${y}" is not defined at "${v}" (strictRequired)`;(0,vb.checkStrictMode)(a,h,a.opts.strictRequired)}}function l(){if(c||o)e.block$data(an.nil,f);else for(const g of r)(0,Br.checkReportMissingProp)(e,g)}function d(){const g=t.let("missing");if(c||o){const _=t.let("valid",!0);e.block$data(_,()=>m(g,_)),e.ok(_)}else t.if((0,Br.checkMissingProp)(e,r,g)),(0,Br.reportMissingProp)(e,g),t.else()}function f(){t.forOf("prop",n,g=>{e.setParams({missingProperty:g}),t.if((0,Br.noPropertyInData)(t,s,g,i.ownProperties),()=>e.error())})}function m(g,_){e.setParams({missingProperty:g}),t.forOf(g,n,()=>{t.assign(_,(0,Br.propertyInData)(t,s,g,i.ownProperties)),t.if((0,an.not)(_),()=>{e.error(),t.break()})},an.nil)}}};hi.default=wb;var pi={};Object.defineProperty(pi,"__esModule",{value:!0});const cn=ge,bb={message({keyword:e,schemaCode:t}){const r=e==="maxItems"?"more":"fewer";return(0,cn.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,cn._)`{limit: ${e}}`},Sb={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:bb,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?cn.operators.GT:cn.operators.LT;e.fail$data((0,cn._)`${r}.length ${s} ${n}`)}};pi.default=Sb;var mi={},Nn={};Object.defineProperty(Nn,"__esModule",{value:!0});const ff=Ds;ff.code='require("ajv/dist/runtime/equal").default';Nn.default=ff;Object.defineProperty(mi,"__esModule",{value:!0});const no=qe,He=ge,Eb=J,kb=Nn,Pb={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}}`},Rb={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:Pb,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,no.getSchemaTypes)(o.items):[];e.block$data(c,d,(0,He._)`${a} === false`),e.ok(c);function d(){const _=t.let("i",(0,He._)`${r}.length`),y=t.let("j");e.setParams({i:_,j:y}),t.assign(c,!0),t.if((0,He._)`${_} > 1`,()=>(f()?m:g)(_,y))}function f(){return l.length>0&&!l.some(_=>_==="object"||_==="array")}function m(_,y){const v=t.name("item"),h=(0,no.checkDataTypes)(l,v,i.opts.strictNumbers,no.DataType.Wrong),$=t.const("indices",(0,He._)`{}`);t.for((0,He._)`;${_}--;`,()=>{t.let(v,(0,He._)`${r}[${_}]`),t.if(h,(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(y,(0,He._)`${$}[${v}]`),e.error(),t.assign(c,!1).break()}).code((0,He._)`${$}[${v}] = ${_}`)})}function g(_,y){const v=(0,Eb.useFunc)(t,kb.default),h=t.name("outer");t.label(h).for((0,He._)`;${_}--;`,()=>t.for((0,He._)`${y} = ${_}; ${y}--;`,()=>t.if((0,He._)`${v}(${r}[${_}], ${r}[${y}])`,()=>{e.error(),t.assign(c,!1).break(h)})))}}};mi.default=Rb;var gi={};Object.defineProperty(gi,"__esModule",{value:!0});const No=ge,Tb=J,jb=Nn,Cb={message:"must be equal to constant",params:({schemaCode:e})=>(0,No._)`{allowedValue: ${e}}`},Nb={keyword:"const",$data:!0,error:Cb,code(e){const{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,No._)`!${(0,Tb.useFunc)(t,jb.default)}(${r}, ${s})`):e.fail((0,No._)`${o} !== ${r}`)}};gi.default=Nb;var _i={};Object.defineProperty(_i,"__esModule",{value:!0});const en=ge,Ib=J,Ob=Nn,xb={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,en._)`{allowedValues: ${e}}`},Ab={keyword:"enum",schemaType:"array",$data:!0,error:xb,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,Ib.useFunc)(t,Ob.default));let d;if(i||n)d=t.let("valid"),e.block$data(d,f);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,y)))}e.pass(d);function f(){t.assign(d,!1),t.forOf("v",o,g=>t.if((0,en._)`${l()}(${r}, ${g})`,()=>t.assign(d,!0).break()))}function m(g,_){const y=s[_];return typeof y=="object"&&y!==null?(0,en._)`${l()}(${r}, ${g}[${_}])`:(0,en._)`${r} === ${y}`}}};_i.default=Ab;Object.defineProperty(ai,"__esModule",{value:!0});const Mb=ii,zb=ci,qb=li,Db=di,Ub=fi,Fb=hi,Lb=pi,Vb=mi,Hb=gi,Zb=_i,Kb=[Mb.default,zb.default,qb.default,Db.default,Ub.default,Fb.default,Lb.default,Vb.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},Hb.default,Zb.default];ai.default=Kb;var yi={},Ur={};Object.defineProperty(Ur,"__esModule",{value:!0});Ur.validateAdditionalItems=void 0;const ar=ge,Io=J,Gb={message:({params:{len:e}})=>(0,ar.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,ar._)`{limit: ${e}}`},Wb={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:Gb,code(e){const{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Io.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}hf(e,n)}};function hf(e,t){const{gen:r,schema:n,data:s,keyword:o,it:a}=e;a.items=!0;const i=r.const("len",(0,ar._)`${s}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,ar._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0,Io.alwaysValidSchema)(a,n)){const l=r.var("valid",(0,ar._)`${i} <= ${t.length}`);r.if((0,ar.not)(l),()=>c(l)),e.ok(l)}function c(l){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:Io.Type.Num},l),a.allErrors||r.if((0,ar.not)(l),()=>r.break())})}}Ur.validateAdditionalItems=hf;Ur.default=Wb;var vi={},Fr={};Object.defineProperty(Fr,"__esModule",{value:!0});Fr.validateTuple=void 0;const ll=ge,ts=J,Bb=pe,Jb={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return pf(e,"additionalItems",t);r.items=!0,!(0,ts.alwaysValidSchema)(r,t)&&e.ok((0,Bb.validateArray)(e))}};function pf(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=ts.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),l=n.const("len",(0,ll._)`${o}.length`);r.forEach((f,m)=>{(0,ts.alwaysValidSchema)(i,f)||(n.if((0,ll._)`${l} > ${m}`,()=>e.subschema({keyword:a,schemaProp:m,dataProp:m},c)),e.ok(c))});function d(f){const{opts:m,errSchemaPath:g}=i,_=r.length,y=_===f.minItems&&(_===f.maxItems||f[t]===!1);if(m.strictTuples&&!y){const v=`"${a}" is ${_}-tuple, but minItems or maxItems/${t} are not specified or different at path "${g}"`;(0,ts.checkStrictMode)(i,v,m.strictTuples)}}}Fr.validateTuple=pf;Fr.default=Jb;Object.defineProperty(vi,"__esModule",{value:!0});const Qb=Fr,Yb={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,Qb.validateTuple)(e,"items")};vi.default=Yb;var $i={};Object.defineProperty($i,"__esModule",{value:!0});const ul=ge,Xb=J,eS=pe,tS=Ur,rS={message:({params:{len:e}})=>(0,ul.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,ul._)`{limit: ${e}}`},nS={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:rS,code(e){const{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=!0,!(0,Xb.alwaysValidSchema)(n,t)&&(s?(0,tS.validateAdditionalItems)(e,s):e.ok((0,eS.validateArray)(e)))}};$i.default=nS;var wi={};Object.defineProperty(wi,"__esModule",{value:!0});const dt=ge,Un=J,sS={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}}`},oS={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:sS,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,Un.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0,Un.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Un.alwaysValidSchema)(o,r)){let y=(0,dt._)`${d} >= ${a}`;i!==void 0&&(y=(0,dt._)`${y} && ${d} <= ${i}`),e.pass(y);return}o.items=!0;const f=t.name("valid");i===void 0&&a===1?g(f,()=>t.if(f,()=>t.break())):a===0?(t.let(f,!0),i!==void 0&&t.if((0,dt._)`${s}.length > 0`,m)):(t.let(f,!1),m()),e.result(f,()=>e.reset());function m(){const y=t.name("_valid"),v=t.let("count",0);g(y,()=>t.if(y,()=>_(v)))}function g(y,v){t.forRange("i",0,d,h=>{e.subschema({keyword:"contains",dataProp:h,dataPropType:Un.Type.Num,compositeRule:!0},y),v()})}function _(y){t.code((0,dt._)`${y}++`),i===void 0?t.if((0,dt._)`${y} >= ${a}`,()=>t.assign(f,!0).break()):(t.if((0,dt._)`${y} > ${i}`,()=>t.assign(f,!1).break()),a===1?t.assign(f,!0):t.if((0,dt._)`${y} >= ${a}`,()=>t.assign(f,!0)))}}};wi.default=oS;var mf={};(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 f=l===1?"property":"properties";return(0,t.str)`must have ${f} ${d} when property ${c} is present`},params:({params:{property:c,depsCount:l,deps:d,missingProperty:f}})=>(0,t._)`{property: ${c}, - missingProperty: ${f}, - 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 f in c){if(f==="__proto__")continue;const m=Array.isArray(c[f])?l:d;m[f]=c[f]}return[l,d]}function a(c,l=c.schema){const{gen:d,data:f,it:m}=c;if(Object.keys(l).length===0)return;const g=d.let("missing");for(const _ in l){const y=l[_];if(y.length===0)continue;const v=(0,n.propertyInData)(d,f,_,m.opts.ownProperties);c.setParams({property:_,depsCount:y.length,deps:y.join(", ")}),m.allErrors?d.if(v,()=>{for(const h of y)(0,n.checkReportMissingProp)(c,h)}):(d.if((0,t._)`${v} && (${(0,n.checkMissingProp)(c,y,g)})`),(0,n.reportMissingProp)(c,g),d.else())}}e.validatePropertyDeps=a;function i(c,l=c.schema){const{gen:d,data:f,keyword:m,it:g}=c,_=d.name("valid");for(const y in l)(0,r.alwaysValidSchema)(g,l[y])||(d.if((0,n.propertyInData)(d,f,y,g.opts.ownProperties),()=>{const v=c.subschema({keyword:m,schemaProp:y},_);c.mergeValidEvaluated(v,_)},()=>d.var(_,!0)),c.ok(_))}e.validateSchemaDeps=i,e.default=s})(mf);var bi={};Object.defineProperty(bi,"__esModule",{value:!0});const gf=ge,aS=J,iS={message:"property name must be valid",params:({params:e})=>(0,gf._)`{propertyName: ${e.propertyName}}`},cS={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:iS,code(e){const{gen:t,schema:r,data:n,it:s}=e;if((0,aS.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,gf.not)(o),()=>{e.error(!0),s.allErrors||t.break()})}),e.ok(o)}};bi.default=cS;var Vs={};Object.defineProperty(Vs,"__esModule",{value:!0});const Fn=pe,$t=ge,lS=jt,Ln=J,uS={message:"must NOT have additional properties",params:({params:e})=>(0,$t._)`{additionalProperty: ${e.additionalProperty}}`},dS={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:uS,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,Ln.alwaysValidSchema)(a,r))return;const l=(0,Fn.allSchemaProperties)(n.properties),d=(0,Fn.allSchemaProperties)(n.patternProperties);f(),e.ok((0,$t._)`${o} === ${lS.default.errors}`);function f(){t.forIn("key",s,v=>{!l.length&&!d.length?_(v):t.if(m(v),()=>_(v))})}function m(v){let h;if(l.length>8){const $=(0,Ln.schemaRefOrVal)(a,n.properties,"properties");h=(0,Fn.isOwnProperty)(t,$,v)}else l.length?h=(0,$t.or)(...l.map($=>(0,$t._)`${v} === ${$}`)):h=$t.nil;return d.length&&(h=(0,$t.or)(h,...d.map($=>(0,$t._)`${(0,Fn.usePattern)(e,$)}.test(${v})`))),(0,$t.not)(h)}function g(v){t.code((0,$t._)`delete ${s}[${v}]`)}function _(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,Ln.alwaysValidSchema)(a,r)){const h=t.name("valid");c.removeAdditional==="failing"?(y(v,h,!1),t.if((0,$t.not)(h),()=>{e.reset(),g(v)})):(y(v,h),i||t.if((0,$t.not)(h),()=>t.break()))}}function y(v,h,$){const E={keyword:"additionalProperties",dataProp:v,dataPropType:Ln.Type.Str};$===!1&&Object.assign(E,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(E,h)}}};Vs.default=dS;var Si={};Object.defineProperty(Si,"__esModule",{value:!0});const fS=Et,dl=pe,so=J,fl=Vs,hS={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&&fl.default.code(new fS.KeywordCxt(o,fl.default,"additionalProperties"));const a=(0,dl.allSchemaProperties)(r);for(const f of a)o.definedProperties.add(f);o.opts.unevaluated&&a.length&&o.props!==!0&&(o.props=so.mergeEvaluated.props(t,(0,so.toHash)(a),o.props));const i=a.filter(f=>!(0,so.alwaysValidSchema)(o,r[f]));if(i.length===0)return;const c=t.name("valid");for(const f of i)l(f)?d(f):(t.if((0,dl.propertyInData)(t,s,f,o.opts.ownProperties)),d(f),o.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(f),e.ok(c);function l(f){return o.opts.useDefaults&&!o.compositeRule&&r[f].default!==void 0}function d(f){e.subschema({keyword:"properties",schemaProp:f,dataProp:f},c)}}};Si.default=hS;var Ei={};Object.defineProperty(Ei,"__esModule",{value:!0});const hl=pe,Vn=ge,pl=J,ml=J,pS={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,hl.allSchemaProperties)(r),c=i.filter(y=>(0,pl.alwaysValidSchema)(o,r[y]));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 Vn.Name)&&(o.props=(0,ml.evaluatedPropsToName)(t,o.props));const{props:f}=o;m();function m(){for(const y of i)l&&g(y),o.allErrors?_(y):(t.var(d,!0),_(y),t.if(d))}function g(y){for(const v in l)new RegExp(y).test(v)&&(0,pl.checkStrictMode)(o,`property ${v} matches pattern ${y} (use allowMatchingProperties)`)}function _(y){t.forIn("key",n,v=>{t.if((0,Vn._)`${(0,hl.usePattern)(e,y)}.test(${v})`,()=>{const h=c.includes(y);h||e.subschema({keyword:"patternProperties",schemaProp:y,dataProp:v,dataPropType:ml.Type.Str},d),o.opts.unevaluated&&f!==!0?t.assign((0,Vn._)`${f}[${v}]`,!0):!h&&!o.allErrors&&t.if((0,Vn.not)(d),()=>t.break())})})}}};Ei.default=pS;var ki={};Object.defineProperty(ki,"__esModule",{value:!0});const mS=J,gS={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,mS.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"}};ki.default=gS;var Pi={};Object.defineProperty(Pi,"__esModule",{value:!0});const _S=pe,yS={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:_S.validateUnion,error:{message:"must match a schema in anyOf"}};Pi.default=yS;var Ri={};Object.defineProperty(Ri,"__esModule",{value:!0});const rs=ge,vS=J,$S={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,rs._)`{passingSchemas: ${e.passing}}`},wS={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:$S,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,f)=>{let m;(0,vS.alwaysValidSchema)(s,d)?t.var(c,!0):m=e.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},c),f>0&&t.if((0,rs._)`${c} && ${a}`).assign(a,!1).assign(i,(0,rs._)`[${i}, ${f}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,f),m&&e.mergeEvaluated(m,rs.Name)})})}}};Ri.default=wS;var Ti={};Object.defineProperty(Ti,"__esModule",{value:!0});const bS=J,SS={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,bS.alwaysValidSchema)(n,o))return;const i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i)})}};Ti.default=SS;var ji={};Object.defineProperty(ji,"__esModule",{value:!0});const vs=ge,_f=J,ES={message:({params:e})=>(0,vs.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,vs._)`{failingKeyword: ${e.ifClause}}`},kS={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:ES,code(e){const{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,_f.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const s=gl(n,"then"),o=gl(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,vs.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,f){return()=>{const m=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(m,a),f?t.assign(f,(0,vs._)`${d}`):e.setParams({ifClause:d})}}}};function gl(e,t){const r=e.schema[t];return r!==void 0&&!(0,_f.alwaysValidSchema)(e,r)}ji.default=kS;var Ci={};Object.defineProperty(Ci,"__esModule",{value:!0});const PS=J,RS={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,PS.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Ci.default=RS;Object.defineProperty(yi,"__esModule",{value:!0});const TS=Ur,jS=vi,CS=Fr,NS=$i,IS=wi,OS=mf,xS=bi,AS=Vs,MS=Si,zS=Ei,qS=ki,DS=Pi,US=Ri,FS=Ti,LS=ji,VS=Ci;function HS(e=!1){const t=[qS.default,DS.default,US.default,FS.default,LS.default,VS.default,xS.default,AS.default,OS.default,MS.default,zS.default];return e?t.push(jS.default,NS.default):t.push(TS.default,CS.default),t.push(IS.default),t}yi.default=HS;var Ni={},Ii={};Object.defineProperty(Ii,"__esModule",{value:!0});const Me=ge,ZS={message:({schemaCode:e})=>(0,Me.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,Me._)`{format: ${e}}`},KS={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:ZS,code(e,t){const{gen:r,data:n,$data:s,schema:o,schemaCode:a,it:i}=e,{opts:c,errSchemaPath:l,schemaEnv:d,self:f}=i;if(!c.validateFormats)return;s?m():g();function m(){const _=r.scopeValue("formats",{ref:f.formats,code:c.code.formats}),y=r.const("fDef",(0,Me._)`${_}[${a}]`),v=r.let("fType"),h=r.let("format");r.if((0,Me._)`typeof ${y} == "object" && !(${y} instanceof RegExp)`,()=>r.assign(v,(0,Me._)`${y}.type || "string"`).assign(h,(0,Me._)`${y}.validate`),()=>r.assign(v,(0,Me._)`"string"`).assign(h,y)),e.fail$data((0,Me.or)($(),E()));function $(){return c.strictSchema===!1?Me.nil:(0,Me._)`${a} && !${h}`}function E(){const R=d.$async?(0,Me._)`(${y}.async ? await ${h}(${n}) : ${h}(${n}))`:(0,Me._)`${h}(${n})`,k=(0,Me._)`(typeof ${h} == "function" ? ${R} : ${h}.test(${n}))`;return(0,Me._)`${h} && ${h} !== true && ${v} === ${t} && !${k}`}}function g(){const _=f.formats[o];if(!_){$();return}if(_===!0)return;const[y,v,h]=E(_);y===t&&e.pass(R());function $(){if(c.strictSchema===!1){f.logger.warn(k());return}throw new Error(k());function k(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function E(k){const N=k instanceof RegExp?(0,Me.regexpCode)(k):c.code.formats?(0,Me._)`${c.code.formats}${(0,Me.getProperty)(o)}`:void 0,A=r.scopeValue("formats",{key:o,ref:k,code:N});return typeof k=="object"&&!(k instanceof RegExp)?[k.type||"string",k.validate,(0,Me._)`${A}.validate`]:["string",k,A]}function R(){if(typeof _=="object"&&!(_ instanceof RegExp)&&_.async){if(!d.$async)throw new Error("async format in sync schema");return(0,Me._)`await ${h}(${n})`}return typeof v=="function"?(0,Me._)`${h}(${n})`:(0,Me._)`${h}.test(${n})`}}}};Ii.default=KS;Object.defineProperty(Ni,"__esModule",{value:!0});const GS=Ii,WS=[GS.default];Ni.default=WS;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(ni,"__esModule",{value:!0});const BS=si,JS=ai,QS=yi,YS=Ni,_l=Ar,XS=[BS.default,JS.default,(0,QS.default)(),YS.default,_l.metadataVocabulary,_l.contentVocabulary];ni.default=XS;var Oi={},Hs={};Object.defineProperty(Hs,"__esModule",{value:!0});Hs.DiscrError=void 0;var yl;(function(e){e.Tag="tag",e.Mapping="mapping"})(yl||(Hs.DiscrError=yl={}));Object.defineProperty(Oi,"__esModule",{value:!0});const Er=ge,Oo=Hs,vl=ot,eE=Dr,tE=J,rE={message:({params:{discrError:e,tagName:t}})=>e===Oo.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}}`},nE={keyword:"discriminator",type:"object",schemaType:"object",error:rE,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:Oo.DiscrError.Tag,tag:l,tagName:i})),e.ok(c);function d(){const g=m();t.if(!1);for(const _ in g)t.elseIf((0,Er._)`${l} === ${_}`),t.assign(c,f(g[_]));t.else(),e.error(!1,{discrError:Oo.DiscrError.Mapping,tag:l,tagName:i}),t.endIf()}function f(g){const _=t.name("valid"),y=e.subschema({keyword:"oneOf",schemaProp:g},_);return e.mergeEvaluated(y,Er.Name),_}function m(){var g;const _={},y=h(s);let v=!0;for(let R=0;Rthis.addVocabulary(_)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const _=this.opts.$data?this.$dataMetaSchema(o,a):o;this.addMetaSchema(_,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=Et;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 f=Cn;Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return f.default}});var m=Dr;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return m.default}})})(Po,Po.exports);var dE=Po.exports;const fE=Yl(dE);var xo={exports:{}},yf={};(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(),_),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:h,"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:L,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:N},int64:{type:"number",validate:A},float:{type:"number",validate:F},double:{type:"number",validate:F},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,_),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||b>59||Z&&!ct)return!1;if(ie<=23&&ke<=59&&ye<60)return!0;const j=ke-b*Oe,S=ie-x*Oe-(j<0?1:0);return(S===23||S===-1)&&(j===59||j===-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=R}function A(Z){return Number.isInteger(Z)}function F(){return!0}const D=/[^\\]\\Z/;function L(Z){if(D.test(Z))return!1;try{return new RegExp(Z),!0}catch{return!1}}})(yf);var vf={},Ao={exports:{}},$f={},Nt={},Xt={},In={},he={},yn={};(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,R)=>`${E}${R}`,"")}get names(){var $;return($=this._names)!==null&&$!==void 0?$:this._names=this._items.reduce((E,R)=>(R instanceof r&&(E[R.str]=(E[R.str]||0)+1),E),{})}}e._Code=n,e.nil=new n("");function s(h,...$){const E=[h[0]];let R=0;for(;R<$.length;)i(E,$[R]),E.push(h[++R]);return new n(E)}e._=s;const o=new n("+");function a(h,...$){const E=[g(h[0])];let R=0;for(;R<$.length;)E.push(o),i(E,$[R]),E.push(o,g(h[++R]));return c(E),new n(E)}e.str=a;function i(h,$){$ instanceof n?h.push(...$._items):$ instanceof r?h.push($):h.push(f($))}e.addCodeArg=i;function c(h){let $=1;for(;${if(f.scopePath===void 0)throw new Error(`CodeGen: name "${f}" has no value`);return(0,t._)`${l}${f.scopePath}`})}scopeCode(l=this._values,d,f){return this._reduceValues(l,m=>{if(m.value===void 0)throw new Error(`CodeGen: name "${m}" has no value`);return m.value.code},d,f)}_reduceValues(l,d,f={},m){let g=t.nil;for(const _ in l){const y=l[_];if(!y)continue;const v=f[_]=f[_]||new Map;y.forEach(h=>{if(v.has(h))return;v.set(h,n.Started);let $=d(h);if($){const E=this.opts.es5?e.varKinds.var:e.varKinds.const;g=(0,t._)`${g}${E} ${h} = ${$};${this.opts._n}`}else if($=m==null?void 0:m(h))g=(0,t._)`${g}${$}${this.opts._n}`;else throw new r(h);v.set(h,n.Completed)})}return g}}e.ValueScope=i})(Mo);(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=yn,r=Mo;var n=yn;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=Mo;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 f 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 U=P[q];U.optimizeNames(u,p)||(ie(u,U.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 _ extends g{render(u){return"{"+u._n+super.render(u)+"}"+u._n}}class y extends g{}class v extends _{}v.kind="else";class h extends _{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 h?p:p.nodes:this.nodes.length?this:new h(ke(u),p instanceof h?[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}}h.kind="if";class $ extends _{}$.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 R 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:U}=this;return`for(${p} ${P}=${q}; ${P}<${U}; ${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 N extends _{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)}}N.kind="func";class A extends g{render(u){return"return "+super.render(u)}}A.kind="return";class F extends _{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 D extends _{constructor(u){super(),this.error=u}render(u){return`catch(${this.error})`+super.render(u)}}D.kind="catch";class L extends _{render(u){return"finally"+super.render(u)}}L.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 y]}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 U=this._scope.toName(p);return P!==void 0&&q&&(this._constants[U.str]=P),this._leafNode(new a(u,U,P)),U}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 h(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 h(u))}else(){return this._elseNode(new v)}endIf(){return this._endBlockNode(h,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,U=this.opts.es5?r.varKinds.var:r.varKinds.let){const X=this._scope.toName(u);return this._for(new R(U,X,p,P),()=>q(X))}forOf(u,p,P,q=r.varKinds.const){const U=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(U,(0,t._)`${X}[${Y}]`),P(U)})}return this._for(new k("of",q,U,p),()=>P(U))}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 U=this._scope.toName(u);return this._for(new k("in",q,U,p),()=>P(U))}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 A;if(this._blockNode(p),this.code(u),p.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(A)}try(u,p,P){if(!p&&!P)throw new Error('CodeGen: "try" without "catch" and "finally"');const q=new F;if(this._blockNode(q),this.code(u),p){const U=this.name("e");this._currNode=q.catch=new D(U),p(U)}return P&&(this._currNode=q.finally=new L,this.code(P)),this._endBlockNode(D,L)}throw(u){return this._leafNode(new f(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 N(u,p,P)),q&&this.code(q).endFunc(),this}endFunc(){return this._endBlockNode(N)}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 h))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((U,X)=>(X instanceof t.Name&&(X=P(X)),X instanceof t._Code?U.push(...X._items):U.push(X),U),[]));function P(U){const X=p[U.str];return X===void 0||u[U.str]!==1?U:(delete u[U.str],X)}function q(U){return U instanceof t._Code&&U._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._)`!${j(S)}`}e.not=ke;const ye=b(e.operators.AND);function ct(...S){return S.reduce(ye)}e.and=ct;const Oe=b(e.operators.OR);function x(...S){return S.reduce(Oe)}e.or=x;function b(S){return(u,p)=>u===t.nil?p:p===t.nil?u:(0,t._)`${j(u)} ${S} ${j(p)}`}function j(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,hE=yn;function pE(e){const t={};for(const r of e)t[r]=!0;return t}Q.toHash=pE;function mE(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(wf(e,t),!bf(t,e.self.RULES.all))}Q.alwaysValidSchema=mE;function wf(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]||kf(e,`unknown keyword: "${o}"`)}Q.checkUnknownRules=wf;function bf(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(t[r])return!0;return!1}Q.schemaHasRules=bf;function gE(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=gE;function _E({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=_E;function yE(e){return Sf(decodeURIComponent(e))}Q.unescapeFragment=yE;function vE(e){return encodeURIComponent(xi(e))}Q.escapeFragment=vE;function xi(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}Q.escapeJsonPointer=xi;function Sf(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}Q.unescapeJsonPointer=Sf;function $E(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)}Q.eachItem=$E;function $l({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:$l({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} || {}`),Ai(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Ef}),items:$l({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 Ef(e,t){if(t===!0)return e.var("props",!0);const r=e.var("props",(0,be._)`{}`);return t!==void 0&&Ai(e,r,t),r}Q.evaluatedPropsToName=Ef;function Ai(e,t,r){Object.keys(r).forEach(n=>e.assign((0,be._)`${t}${(0,be.getProperty)(n)}`,!0))}Q.setEvaluated=Ai;const wl={};function wE(e,t){return e.scopeValue("func",{ref:t,code:wl[t.code]||(wl[t.code]=new hE._Code(t.code))})}Q.useFunc=wE;var zo;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(zo||(Q.Type=zo={}));function bE(e,t,r){if(e instanceof be.Name){const n=t===zo.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():"/"+xi(e)}Q.getErrorPath=bE;function kf(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=kf;var Ct={};Object.defineProperty(Ct,"__esModule",{value:!0});const et=he,SE={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=SE;(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:h})=>h?(0,t.str)`"${v}" keyword must be ${h} ($data)`:(0,t.str)`"${v}" keyword is invalid ($data)`};function s(v,h=e.keywordError,$,E){const{it:R}=v,{gen:k,compositeRule:N,allErrors:A}=R,F=f(v,h,$);E??(N||A)?c(k,F):l(R,(0,t._)`[${F}]`)}e.reportError=s;function o(v,h=e.keywordError,$){const{it:E}=v,{gen:R,compositeRule:k,allErrors:N}=E,A=f(v,h,$);c(R,A),k||N||l(E,n.default.vErrors)}e.reportExtraError=o;function a(v,h){v.assign(n.default.errors,h),v.if((0,t._)`${n.default.vErrors} !== null`,()=>v.if(h,()=>v.assign((0,t._)`${n.default.vErrors}.length`,h),()=>v.assign(n.default.vErrors,null)))}e.resetErrorsCount=a;function i({gen:v,keyword:h,schemaValue:$,data:E,errsCount:R,it:k}){if(R===void 0)throw new Error("ajv implementation error");const N=v.name("err");v.forRange("i",R,n.default.errors,A=>{v.const(N,(0,t._)`${n.default.vErrors}[${A}]`),v.if((0,t._)`${N}.instancePath === undefined`,()=>v.assign((0,t._)`${N}.instancePath`,(0,t.strConcat)(n.default.instancePath,k.errorPath))),v.assign((0,t._)`${N}.schemaPath`,(0,t.str)`${k.errSchemaPath}/${h}`),k.opts.verbose&&(v.assign((0,t._)`${N}.schema`,$),v.assign((0,t._)`${N}.data`,E))})}e.extendErrors=i;function c(v,h){const $=v.const("err",h);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,h){const{gen:$,validateName:E,schemaEnv:R}=v;R.$async?$.throw((0,t._)`new ${v.ValidationError}(${h})`):($.assign((0,t._)`${E}.errors`,h),$.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 f(v,h,$){const{createErrors:E}=v.it;return E===!1?(0,t._)`{}`:m(v,h,$)}function m(v,h,$={}){const{gen:E,it:R}=v,k=[g(R,$),_(v,$)];return y(v,h,k),E.object(...k)}function g({errorPath:v},{instancePath:h}){const $=h?(0,t.str)`${v}${(0,r.getErrorPath)(h,r.Type.Str)}`:v;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,$)]}function _({keyword:v,it:{errSchemaPath:h}},{schemaPath:$,parentSchema:E}){let R=E?h:(0,t.str)`${h}/${v}`;return $&&(R=(0,t.str)`${R}${(0,r.getErrorPath)($,r.Type.Str)}`),[d.schemaPath,R]}function y(v,{params:h,message:$},E){const{keyword:R,data:k,schemaValue:N,it:A}=v,{opts:F,propertyName:D,topSchemaRef:L,schemaPath:Z}=A;E.push([d.keyword,R],[d.params,typeof h=="function"?h(v):h||(0,t._)`{}`]),F.messages&&E.push([d.message,typeof $=="function"?$(v):$]),F.verbose&&E.push([d.schema,N],[d.parentSchema,(0,t._)`${L}${Z}`],[n.default.data,k]),D&&E.push([d.propertyName,D])}})(In);var bl;function EE(){if(bl)return Xt;bl=1,Object.defineProperty(Xt,"__esModule",{value:!0}),Xt.boolOrEmptySchema=Xt.topBoolOrEmptySchema=void 0;const e=In,t=he,r=Ct,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))}Xt.topBoolOrEmptySchema=s;function o(i,c){const{gen:l,schema:d}=i;d===!1?(l.var(c,!1),a(i)):l.var(c,!0)}Xt.boolOrEmptySchema=o;function a(i,c){const{gen:l,data:d}=i,f={gen:l,keyword:"false schema",data:d,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:i};(0,e.reportError)(f,n,void 0,c)}return Xt}var De={},mr={};Object.defineProperty(mr,"__esModule",{value:!0});mr.getRules=mr.isJSONType=void 0;const kE=["string","number","integer","boolean","null","object","array"],PE=new Set(kE);function RE(e){return typeof e=="string"&&PE.has(e)}mr.isJSONType=RE;function TE(){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:{}}}mr.getRules=TE;var It={},Sl;function Pf(){if(Sl)return It;Sl=1,Object.defineProperty(It,"__esModule",{value:!0}),It.shouldUseRule=It.shouldUseGroup=It.schemaHasRulesForType=void 0;function e({schema:n,self:s},o){const a=s.RULES.types[o];return a&&a!==!0&&t(n,a)}It.schemaHasRulesForType=e;function t(n,s){return s.rules.some(o=>r(n,o))}It.shouldUseGroup=t;function r(n,s){var o;return n[s.keyword]!==void 0||((o=s.definition.implements)===null||o===void 0?void 0:o.some(a=>n[a]!==void 0))}return It.shouldUseRule=r,It}Object.defineProperty(De,"__esModule",{value:!0});De.reportTypeError=De.checkDataTypes=De.checkDataType=De.coerceAndCheckDataType=De.getJSONTypes=De.getSchemaTypes=De.DataType=void 0;const jE=mr,CE=Pf(),NE=In,de=he,Rf=Q;var Nr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Nr||(De.DataType=Nr={}));function IE(e){const t=Tf(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=IE;function Tf(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(jE.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}De.getJSONTypes=Tf;function OE(e,t){const{gen:r,data:n,opts:s}=e,o=xE(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0,CE.schemaHasRulesForType)(e,t[0]));if(a){const i=Mi(t,n,s.strictNumbers,Nr.Wrong);r.if(i,()=>{o.length?AE(e,t,o):zi(e)})}return a}De.coerceAndCheckDataType=OE;const jf=new Set(["string","number","integer","boolean","null"]);function xE(e,t){return t?e.filter(r=>jf.has(r)||t==="array"&&r==="array"):[]}function AE(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(Mi(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0,de._)`${i} !== undefined`);for(const l of r)(jf.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),zi(e),n.endIf(),n.if((0,de._)`${i} !== undefined`,()=>{n.assign(s,i),ME(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 ME({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,de._)`${t} !== undefined`,()=>e.assign((0,de._)`${t}[${r}]`,n))}function qo(e,t,r,n=Nr.Correct){const s=n===Nr.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===Nr.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=qo;function Mi(e,t,r,n){if(e.length===1)return qo(e[0],t,r,n);let s;const o=(0,Rf.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,qo(a,t,r,n));return s}De.checkDataTypes=Mi;const zE={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,de._)`{type: ${e}}`:(0,de._)`{type: ${t}}`};function zi(e){const t=qE(e);(0,NE.reportError)(t,zE)}De.reportTypeError=zi;function qE(e){const{gen:t,data:r,schema:n}=e,s=(0,Rf.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}var Jr={},El;function DE(){if(El)return Jr;El=1,Object.defineProperty(Jr,"__esModule",{value:!0}),Jr.assignDefaults=void 0;const e=he,t=Q;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))}Jr.assignDefaults=r;function n(s,o,a){const{gen:i,compositeRule:c,data:l,opts:d}=s;if(a===void 0)return;const f=(0,e._)`${l}${(0,e.getProperty)(o)}`;if(c){(0,t.checkStrictMode)(s,`default is ignored for: ${f}`);return}let m=(0,e._)`${f} === undefined`;d.useDefaults==="empty"&&(m=(0,e._)`${m} || ${f} === null || ${f} === ""`),i.if(m,(0,e._)`${f} = ${(0,e.stringify)(a)}`)}return Jr}var yt={},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,qi=Q,qt=Ct,UE=Q;function FE(e,t){const{gen:r,data:n,it:s}=e;r.if(Ui(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Re._)`${t}`},!0),e.error()})}me.checkReportMissingProp=FE;function LE({gen:e,data:t,it:{opts:r}},n,s){return(0,Re.or)(...n.map(o=>(0,Re.and)(Ui(e,t,o,r.ownProperties),(0,Re._)`${s} = ${o}`)))}me.checkMissingProp=LE;function VE(e,t){e.setParams({missingProperty:t},!0),e.error()}me.reportMissingProp=VE;function Cf(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Re._)`Object.prototype.hasOwnProperty`})}me.hasPropFunc=Cf;function Di(e,t,r){return(0,Re._)`${Cf(e)}.call(${t}, ${r})`}me.isOwnProperty=Di;function HE(e,t,r,n){const s=(0,Re._)`${t}${(0,Re.getProperty)(r)} !== undefined`;return n?(0,Re._)`${s} && ${Di(e,t,r)}`:s}me.propertyInData=HE;function Ui(e,t,r,n){const s=(0,Re._)`${t}${(0,Re.getProperty)(r)} === undefined`;return n?(0,Re.or)(s,(0,Re.not)(Di(e,t,r))):s}me.noPropertyInData=Ui;function Nf(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}me.allSchemaProperties=Nf;function ZE(e,t){return Nf(t).filter(r=>!(0,qi.alwaysValidSchema)(e,t[r]))}me.schemaProperties=ZE;function KE({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,f=[[qt.default.instancePath,(0,Re.strConcat)(qt.default.instancePath,o)],[qt.default.parentData,a.parentData],[qt.default.parentDataProperty,a.parentDataProperty],[qt.default.rootData,qt.default.rootData]];a.opts.dynamicRef&&f.push([qt.default.dynamicAnchors,qt.default.dynamicAnchors]);const m=(0,Re._)`${d}, ${r.object(...f)}`;return c!==Re.nil?(0,Re._)`${i}.call(${c}, ${m})`:(0,Re._)`${i}(${m})`}me.callValidateCode=KE;const GE=(0,Re._)`new RegExp`;function WE({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"?GE:(0,UE.useFunc)(e,s)}(${r}, ${n})`})}me.usePattern=WE;function BE(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:qi.Type.Num},o),t.if((0,Re.not)(o),i)})}}me.validateArray=BE;function JE(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,qi.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=JE;var kl;function QE(){if(kl)return yt;kl=1,Object.defineProperty(yt,"__esModule",{value:!0}),yt.validateKeywordUsage=yt.validSchemaType=yt.funcKeywordCode=yt.macroKeywordCode=void 0;const e=he,t=Ct,r=me,n=In;function s(m,g){const{gen:_,keyword:y,schema:v,parentSchema:h,it:$}=m,E=g.macro.call($.self,v,h,$),R=l(_,y,E);$.opts.validateSchema!==!1&&$.self.validateSchema(E,!0);const k=_.name("valid");m.subschema({schema:E,schemaPath:e.nil,errSchemaPath:`${$.errSchemaPath}/${y}`,topSchemaRef:R,compositeRule:!0},k),m.pass(k,()=>m.error(!0))}yt.macroKeywordCode=s;function o(m,g){var _;const{gen:y,keyword:v,schema:h,parentSchema:$,$data:E,it:R}=m;c(R,g);const k=!E&&g.compile?g.compile.call(R.self,h,$,R):g.validate,N=l(y,v,k),A=y.let("valid");m.block$data(A,F),m.ok((_=g.valid)!==null&&_!==void 0?_:A);function F(){if(g.errors===!1)Z(),g.modifying&&a(m),B(()=>m.error());else{const re=g.async?D():L();g.modifying&&a(m),B(()=>i(m,re))}}function D(){const re=y.let("ruleErrs",null);return y.try(()=>Z((0,e._)`await `),H=>y.assign(A,!1).if((0,e._)`${H} instanceof ${R.ValidationError}`,()=>y.assign(re,(0,e._)`${H}.errors`),()=>y.throw(H))),re}function L(){const re=(0,e._)`${N}.errors`;return y.assign(re,null),Z(e.nil),re}function Z(re=g.async?(0,e._)`await `:e.nil){const H=R.opts.passContext?t.default.this:t.default.self,ie=!("compile"in g&&!E||g.schema===!1);y.assign(A,(0,e._)`${re}${(0,r.callValidateCode)(m,N,H,ie)}`,g.modifying)}function B(re){var H;y.if((0,e.not)((H=g.valid)!==null&&H!==void 0?H:A),re)}}yt.funcKeywordCode=o;function a(m){const{gen:g,data:_,it:y}=m;g.if(y.parentData,()=>g.assign(_,(0,e._)`${y.parentData}[${y.parentDataProperty}]`))}function i(m,g){const{gen:_}=m;_.if((0,e._)`Array.isArray(${g})`,()=>{_.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,_){if(_===void 0)throw new Error(`keyword "${g}" failed to compile`);return m.scopeValue("keyword",typeof _=="function"?{ref:_}:{ref:_,code:(0,e.stringify)(_)})}function d(m,g,_=!1){return!g.length||g.some(y=>y==="array"?Array.isArray(m):y==="object"?m&&typeof m=="object"&&!Array.isArray(m):typeof m==y||_&&typeof m>"u")}yt.validSchemaType=d;function f({schema:m,opts:g,self:_,errSchemaPath:y},v,h){if(Array.isArray(v.keyword)?!v.keyword.includes(h):v.keyword!==h)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 ${h}: ${$.join(",")}`);if(v.validateSchema&&!v.validateSchema(m[h])){const R=`keyword "${h}" value is invalid at path "${y}": `+_.errorsText(v.validateSchema.errors);if(g.validateSchema==="log")_.logger.error(R);else throw new Error(R)}}return yt.validateKeywordUsage=f,yt}var Ot={},Pl;function YE(){if(Pl)return Ot;Pl=1,Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.extendSubschemaMode=Ot.extendSubschemaData=Ot.getSubschema=void 0;const e=he,t=Q;function r(o,{keyword:a,schemaProp:i,schema:c,schemaPath:l,errSchemaPath:d,topSchemaRef:f}){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||f===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:c,schemaPath:l,topSchemaRef:f,errSchemaPath:d}}throw new Error('either "keyword" or "schema" must be passed')}Ot.getSubschema=r;function n(o,a,{dataProp:i,dataPropType:c,data:l,dataTypes:d,propertyName:f}){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:_,dataPathArr:y,opts:v}=a,h=m.let("data",(0,e._)`${a.data}${(0,e.getProperty)(i)}`,!0);g(h),o.errorPath=(0,e.str)`${_}${(0,t.getErrorPath)(i,c,v.jsPropertySyntax)}`,o.parentDataProperty=(0,e._)`${i}`,o.dataPathArr=[...y,o.parentDataProperty]}if(l!==void 0){const _=l instanceof e.Name?l:m.let("data",l,!0);g(_),f!==void 0&&(o.propertyName=f)}d&&(o.dataTypes=d);function g(_){o.data=_,o.dataLevel=a.dataLevel+1,o.dataTypes=[],a.definedProperties=new Set,o.parentData=a.data,o.dataNames=[...a.dataNames,_]}}Ot.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 Ot.extendSubschemaMode=s,Ot}var We={},If={exports:{}},Vt=If.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(){};ns(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 ns(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 f=n[d];if(Array.isArray(f)){if(d in Vt.arrayKeywords)for(var m=0;mt+=Of(n)),t===1/0))return 1/0}return t}function xf(e,t="",r){r!==!1&&(t=Ir(t));const n=e.parse(t);return Af(e,n)}We.getFullPath=xf;function Af(e,t){return e.serialize(t).split("#")[0]+"#"}We._getFullPath=Af;const ik=/#\/?$/;function Ir(e){return e?e.replace(ik,""):""}We.normalizeId=Ir;function ck(e,t,r){return r=Ir(r),e.resolve(t,r)}We.resolveUrl=ck;const lk=/^[a-z_][-a-z0-9._]*$/i;function uk(e,t){if(typeof e=="boolean")return{};const{schemaId:r,uriResolver:n}=this.opts,s=Ir(e[r]||t),o={"":s},a=xf(n,s,!1),i={},c=new Set;return nk(e,{allKeys:!0},(f,m,g,_)=>{if(_===void 0)return;const y=a+m;let v=o[_];typeof f[r]=="string"&&(v=h.call(this,f[r])),$.call(this,f.$anchor),$.call(this,f.$dynamicAnchor),o[m]=v;function h(E){const R=this.opts.uriResolver.resolve;if(E=Ir(v?R(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(f,k.schema,E):E!==Ir(y)&&(E[0]==="#"?(l(f,i[E],E),i[E]=f):this.refs[E]=y),E}function $(E){if(typeof E=="string"){if(!lk.test(E))throw new Error(`invalid anchor "${E}"`);h.call(this,`#${E}`)}}}),i;function l(f,m,g){if(m!==void 0&&!rk(f,m))throw d(g)}function d(f){return new Error(`reference "${f}" resolves to more than one schema`)}}We.getSchemaRefs=uk;var Rl;function Zs(){if(Rl)return Nt;Rl=1,Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.getData=Nt.KeywordCxt=Nt.validateFunctionCode=void 0;const e=EE(),t=De,r=Pf(),n=De,s=DE(),o=QE(),a=YE(),i=he,c=Ct,l=We,d=Q,f=In;function m(C){if(k(C)&&(A(C),R(C))){v(C);return}g(C,()=>(0,e.topBoolOrEmptySchema)(C))}Nt.validateFunctionCode=m;function g({gen:C,validateName:O,schema:V,schemaEnv:W,opts:ee},ce){ee.code.es5?C.func(O,(0,i._)`${c.default.data}, ${c.default.valCxt}`,W.$async,()=>{C.code((0,i._)`"use strict"; ${$(V,ee)}`),y(C,ee),C.code(ce)}):C.func(O,(0,i._)`${c.default.data}, ${_(ee)}`,W.$async,()=>C.code($(V,ee)).code(ce))}function _(C){return(0,i._)`{${c.default.instancePath}="", ${c.default.parentData}, ${c.default.parentDataProperty}, ${c.default.rootData}=${c.default.data}${C.dynamicRef?(0,i._)`, ${c.default.dynamicAnchors}={}`:i.nil}}={}`}function y(C,O){C.if(c.default.valCxt,()=>{C.var(c.default.instancePath,(0,i._)`${c.default.valCxt}.${c.default.instancePath}`),C.var(c.default.parentData,(0,i._)`${c.default.valCxt}.${c.default.parentData}`),C.var(c.default.parentDataProperty,(0,i._)`${c.default.valCxt}.${c.default.parentDataProperty}`),C.var(c.default.rootData,(0,i._)`${c.default.valCxt}.${c.default.rootData}`),O.dynamicRef&&C.var(c.default.dynamicAnchors,(0,i._)`${c.default.valCxt}.${c.default.dynamicAnchors}`)},()=>{C.var(c.default.instancePath,(0,i._)`""`),C.var(c.default.parentData,(0,i._)`undefined`),C.var(c.default.parentDataProperty,(0,i._)`undefined`),C.var(c.default.rootData,c.default.data),O.dynamicRef&&C.var(c.default.dynamicAnchors,(0,i._)`{}`)})}function v(C){const{schema:O,opts:V,gen:W}=C;g(C,()=>{V.$comment&&O.$comment&&re(C),L(C),W.let(c.default.vErrors,null),W.let(c.default.errors,0),V.unevaluated&&h(C),F(C),H(C)})}function h(C){const{gen:O,validateName:V}=C;C.evaluated=O.const("evaluated",(0,i._)`${V}.evaluated`),O.if((0,i._)`${C.evaluated}.dynamicProps`,()=>O.assign((0,i._)`${C.evaluated}.props`,(0,i._)`undefined`)),O.if((0,i._)`${C.evaluated}.dynamicItems`,()=>O.assign((0,i._)`${C.evaluated}.items`,(0,i._)`undefined`))}function $(C,O){const V=typeof C=="object"&&C[O.schemaId];return V&&(O.code.source||O.code.process)?(0,i._)`/*# sourceURL=${V} */`:i.nil}function E(C,O){if(k(C)&&(A(C),R(C))){N(C,O);return}(0,e.boolOrEmptySchema)(C,O)}function R({schema:C,self:O}){if(typeof C=="boolean")return!C;for(const V in C)if(O.RULES.all[V])return!0;return!1}function k(C){return typeof C.schema!="boolean"}function N(C,O){const{schema:V,gen:W,opts:ee}=C;ee.$comment&&V.$comment&&re(C),Z(C),B(C);const ce=W.const("_errs",c.default.errors);F(C,ce),W.var(O,(0,i._)`${ce} === ${c.default.errors}`)}function A(C){(0,d.checkUnknownRules)(C),D(C)}function F(C,O){if(C.opts.jtd)return ke(C,[],!1,O);const V=(0,t.getSchemaTypes)(C.schema),W=(0,t.coerceAndCheckDataType)(C,V);ke(C,V,!W,O)}function D(C){const{schema:O,errSchemaPath:V,opts:W,self:ee}=C;O.$ref&&W.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(O,ee.RULES)&&ee.logger.warn(`$ref: keywords ignored in schema at path "${V}"`)}function L(C){const{schema:O,opts:V}=C;O.default!==void 0&&V.useDefaults&&V.strictSchema&&(0,d.checkStrictMode)(C,"default is ignored in the schema root")}function Z(C){const O=C.schema[C.opts.schemaId];O&&(C.baseId=(0,l.resolveUrl)(C.opts.uriResolver,C.baseId,O))}function B(C){if(C.schema.$async&&!C.schemaEnv.$async)throw new Error("async schema in sync schema")}function re({gen:C,schemaEnv:O,schema:V,errSchemaPath:W,opts:ee}){const ce=V.$comment;if(ee.$comment===!0)C.code((0,i._)`${c.default.self}.logger.log(${ce})`);else if(typeof ee.$comment=="function"){const xe=(0,i.str)`${W}/$comment`,tt=C.scopeValue("root",{ref:O.root});C.code((0,i._)`${c.default.self}.opts.$comment(${ce}, ${xe}, ${tt}.schema)`)}}function H(C){const{gen:O,schemaEnv:V,validateName:W,ValidationError:ee,opts:ce}=C;V.$async?O.if((0,i._)`${c.default.errors} === 0`,()=>O.return(c.default.data),()=>O.throw((0,i._)`new ${ee}(${c.default.vErrors})`)):(O.assign((0,i._)`${W}.errors`,c.default.vErrors),ce.unevaluated&&ie(C),O.return((0,i._)`${c.default.errors} === 0`))}function ie({gen:C,evaluated:O,props:V,items:W}){V instanceof i.Name&&C.assign((0,i._)`${O}.props`,V),W instanceof i.Name&&C.assign((0,i._)`${O}.items`,W)}function ke(C,O,V,W){const{gen:ee,schema:ce,data:xe,allErrors:tt,opts:Fe,self:Le}=C,{RULES:Ae}=Le;if(ce.$ref&&(Fe.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(ce,Ae))){ee.block(()=>q(C,"$ref",Ae.all.$ref.definition));return}Fe.jtd||ct(C,O),ee.block(()=>{for(const Ye of Ae.rules)kt(Ye);kt(Ae.post)});function kt(Ye){(0,r.shouldUseGroup)(ce,Ye)&&(Ye.type?(ee.if((0,n.checkDataType)(Ye.type,xe,Fe.strictNumbers)),ye(C,Ye),O.length===1&&O[0]===Ye.type&&V&&(ee.else(),(0,n.reportTypeError)(C)),ee.endIf()):ye(C,Ye),tt||ee.if((0,i._)`${c.default.errors} === ${W||0}`))}}function ye(C,O){const{gen:V,schema:W,opts:{useDefaults:ee}}=C;ee&&(0,s.assignDefaults)(C,O.type),V.block(()=>{for(const ce of O.rules)(0,r.shouldUseRule)(W,ce)&&q(C,ce.keyword,ce.definition,O.type)})}function ct(C,O){C.schemaEnv.meta||!C.opts.strictTypes||(Oe(C,O),C.opts.allowUnionTypes||x(C,O),b(C,C.dataTypes))}function Oe(C,O){if(O.length){if(!C.dataTypes.length){C.dataTypes=O;return}O.forEach(V=>{S(C.dataTypes,V)||p(C,`type "${V}" not allowed by context "${C.dataTypes.join(",")}"`)}),u(C,O)}}function x(C,O){O.length>1&&!(O.length===2&&O.includes("null"))&&p(C,"use allowUnionTypes to allow union type keyword")}function b(C,O){const V=C.self.RULES.all;for(const W in V){const ee=V[W];if(typeof ee=="object"&&(0,r.shouldUseRule)(C.schema,ee)){const{type:ce}=ee.definition;ce.length&&!ce.some(xe=>j(O,xe))&&p(C,`missing type "${ce.join(",")}" for keyword "${W}"`)}}}function j(C,O){return C.includes(O)||O==="number"&&C.includes("integer")}function S(C,O){return C.includes(O)||O==="integer"&&C.includes("number")}function u(C,O){const V=[];for(const W of C.dataTypes)S(O,W)?V.push(W):O.includes("integer")&&W==="number"&&V.push("integer");C.dataTypes=V}function p(C,O){const V=C.schemaEnv.baseId+C.errSchemaPath;O+=` at "${V}" (strictTypes)`,(0,d.checkStrictMode)(C,O,C.opts.strictTypes)}class P{constructor(O,V,W){if((0,o.validateKeywordUsage)(O,V,W),this.gen=O.gen,this.allErrors=O.allErrors,this.keyword=W,this.data=O.data,this.schema=O.schema[W],this.$data=V.$data&&O.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d.schemaRefOrVal)(O,this.schema,W,this.$data),this.schemaType=V.schemaType,this.parentSchema=O.schema,this.params={},this.it=O,this.def=V,this.$data)this.schemaCode=O.gen.const("vSchema",Y(this.$data,O));else if(this.schemaCode=this.schemaValue,!(0,o.validSchemaType)(this.schema,V.schemaType,V.allowUndefined))throw new Error(`${W} value must be ${JSON.stringify(V.schemaType)}`);("code"in V?V.trackErrors:V.errors!==!1)&&(this.errsCount=O.gen.const("_errs",c.default.errors))}result(O,V,W){this.failResult((0,i.not)(O),V,W)}failResult(O,V,W){this.gen.if(O),W?W():this.error(),V?(this.gen.else(),V(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(O,V){this.failResult((0,i.not)(O),void 0,V)}fail(O){if(O===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(O),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(O){if(!this.$data)return this.fail(O);const{schemaCode:V}=this;this.fail((0,i._)`${V} !== undefined && (${(0,i.or)(this.invalid$data(),O)})`)}error(O,V,W){if(V){this.setParams(V),this._error(O,W),this.setParams({});return}this._error(O,W)}_error(O,V){(O?f.reportExtraError:f.reportError)(this,this.def.error,V)}$dataError(){(0,f.reportError)(this,this.def.$dataError||f.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,f.resetErrorsCount)(this.gen,this.errsCount)}ok(O){this.allErrors||this.gen.if(O)}setParams(O,V){V?Object.assign(this.params,O):this.params=O}block$data(O,V,W=i.nil){this.gen.block(()=>{this.check$data(O,W),V()})}check$data(O=i.nil,V=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`,V)),O!==i.nil&&W.assign(O,!0),(ce.length||xe.validateSchema)&&(W.elseIf(this.invalid$data()),this.$dataError(),O!==i.nil&&W.assign(O,!1)),W.else()}invalid$data(){const{gen:O,schemaCode:V,schemaType:W,def:ee,it:ce}=this;return(0,i.or)(xe(),tt());function xe(){if(W.length){if(!(V instanceof i.Name))throw new Error("ajv implementation error");const Fe=Array.isArray(W)?W:[W];return(0,i._)`${(0,n.checkDataTypes)(Fe,V,ce.opts.strictNumbers,n.DataType.Wrong)}`}return i.nil}function tt(){if(ee.validateSchema){const Fe=O.scopeValue("validate$data",{ref:ee.validateSchema});return(0,i._)`!${Fe}(${V})`}return i.nil}}subschema(O,V){const W=(0,a.getSubschema)(this.it,O);(0,a.extendSubschemaData)(W,this.it,O),(0,a.extendSubschemaMode)(W,O);const ee={...this.it,...W,items:void 0,props:void 0};return E(ee,V),ee}mergeEvaluated(O,V){const{it:W,gen:ee}=this;W.opts.unevaluated&&(W.props!==!0&&O.props!==void 0&&(W.props=d.mergeEvaluated.props(ee,O.props,W.props,V)),W.items!==!0&&O.items!==void 0&&(W.items=d.mergeEvaluated.items(ee,O.items,W.items,V)))}mergeValidEvaluated(O,V){const{it:W,gen:ee}=this;if(W.opts.unevaluated&&(W.props!==!0||W.items!==!0))return ee.if(V,()=>this.mergeEvaluated(O,i.Name)),!0}}Nt.KeywordCxt=P;function q(C,O,V,W){const ee=new P(C,V,O);"code"in V?V.code(ee,W):ee.$data&&V.validate?(0,o.funcKeywordCode)(ee,V):"macro"in V?(0,o.macroKeywordCode)(ee,V):(V.compile||V.validate)&&(0,o.funcKeywordCode)(ee,V)}const U=/^\/(?:[^~]|~0|~1)*$/,X=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Y(C,{dataLevel:O,dataNames:V,dataPathArr:W}){let ee,ce;if(C==="")return c.default.rootData;if(C[0]==="/"){if(!U.test(C))throw new Error(`Invalid JSON-pointer: ${C}`);ee=C,ce=c.default.rootData}else{const Le=X.exec(C);if(!Le)throw new Error(`Invalid JSON-pointer: ${C}`);const Ae=+Le[1];if(ee=Le[2],ee==="#"){if(Ae>=O)throw new Error(Fe("property/index",Ae));return W[O-Ae]}if(Ae>O)throw new Error(Fe("data",Ae));if(ce=V[O-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 ${O}`}}return Nt.getData=Y,Nt}var Hn={},Tl;function Fi(){if(Tl)return Hn;Tl=1,Object.defineProperty(Hn,"__esModule",{value:!0});class e extends Error{constructor(r){super("validation failed"),this.errors=r,this.ajv=this.validation=!0}}return Hn.default=e,Hn}var Lr={};Object.defineProperty(Lr,"__esModule",{value:!0});const oo=We;class dk extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,oo.resolveUrl)(t,r,n),this.missingSchema=(0,oo.normalizeId)((0,oo.getFullPath)(t,this.missingRef))}}Lr.default=dk;var at={};Object.defineProperty(at,"__esModule",{value:!0});at.resolveSchema=at.getCompilingSchema=at.resolveRef=at.compileSchema=at.SchemaEnv=void 0;const vt=he,fk=Fi(),er=Ct,St=We,jl=Q,hk=Zs();class Ks{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,St.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=Ks;function Li(e){const t=Mf.call(this,e);if(t)return t;const r=(0,St.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,a=new vt.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o});let i;e.$async&&(i=a.scopeValue("Error",{ref:fk.default,code:(0,vt._)`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:[vt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,vt.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:vt.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,vt._)`""`,opts:this.opts,self:this};let d;try{this._compilations.add(e),(0,hk.validateFunctionCode)(l),a.optimize(this.opts.code.optimize);const f=a.toString();d=`${a.scopeRefs(er.default.scope)}return ${f}`,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:f,scopeValues:a._values}),this.opts.unevaluated){const{props:_,items:y}=l;g.evaluated={props:_ instanceof vt.Name?void 0:_,items:y instanceof vt.Name?void 0:y,dynamicProps:_ instanceof vt.Name,dynamicItems:y instanceof vt.Name},g.source&&(g.source.evaluated=(0,vt.stringify)(g.evaluated))}return e.validate=g,e}catch(f){throw delete e.validate,delete e.validateName,d&&this.logger.error("Error compiling schema, function code:",d),f}finally{this._compilations.delete(e)}}at.compileSchema=Li;function pk(e,t,r){var n;r=(0,St.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 Ks({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,St.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Li.call(this,e)}function Mf(e){for(const t of this._compilations)if(gk(t,e))return t}at.getCompilingSchema=Mf;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]||Gs.call(this,e,t)}function Gs(e,t){const r=this.opts.uriResolver.parse(t),n=(0,St._getFullPath)(this.opts.uriResolver,r);let s=(0,St.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===s)return ao.call(this,r,e);const o=(0,St.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){const i=Gs.call(this,e,a);return typeof(i==null?void 0:i.schema)!="object"?void 0:ao.call(this,r,i)}if(typeof(a==null?void 0:a.schema)=="object"){if(a.validate||Li.call(this,a),o===(0,St.normalizeId)(t)){const{schema:i}=a,{schemaId:c}=this.opts,l=i[c];return l&&(s=(0,St.resolveUrl)(this.opts.uriResolver,s,l)),new Ks({schema:i,schemaId:c,root:e,baseId:s})}return ao.call(this,r,a)}}at.resolveSchema=Gs;const yk=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function ao(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,jl.unescapeFragment)(i)];if(c===void 0)return;r=c;const l=typeof r=="object"&&r[this.opts.schemaId];!yk.has(i)&&l&&(t=(0,St.resolveUrl)(this.opts.uriResolver,t,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,jl.schemaHasRulesButRef)(r,this.RULES)){const i=(0,St.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=Gs.call(this,n,i)}const{schemaId:a}=this.opts;if(o=o||new Ks({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 Vi={};Object.defineProperty(Vi,"__esModule",{value:!0});const zf=cf;zf.code='require("ajv/dist/runtime/uri").default';Vi.default=zf;(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=Zs();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=Fi(),s=Lr,o=mr,a=at,i=he,c=We,l=De,d=Q,f=kk,m=Vi,g=(x,b)=>new RegExp(x,b);g.code="new RegExp";const _=["removeAdditional","useDefaults","coerceTypes"],y=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."},h={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},$=200;function E(x){var b,j,S,u,p,P,q,U,X,Y,C,O,V,W,ee,ce,xe,tt,Fe,Le,Ae,kt,Ye,Wt,Bt;const gt=x.strict,Jt=(b=x.code)===null||b===void 0?void 0:b.optimize,Zr=Jt===!0||Jt===void 0?1:Jt||0,Kr=(S=(j=x.code)===null||j===void 0?void 0:j.regExp)!==null&&S!==void 0?S:g,Js=(u=x.uriResolver)!==null&&u!==void 0?u:m.default;return{strictSchema:(P=(p=x.strictSchema)!==null&&p!==void 0?p:gt)!==null&&P!==void 0?P:!0,strictNumbers:(U=(q=x.strictNumbers)!==null&&q!==void 0?q:gt)!==null&&U!==void 0?U:!0,strictTypes:(Y=(X=x.strictTypes)!==null&&X!==void 0?X:gt)!==null&&Y!==void 0?Y:"log",strictTuples:(O=(C=x.strictTuples)!==null&&C!==void 0?C:gt)!==null&&O!==void 0?O:"log",strictRequired:(W=(V=x.strictRequired)!==null&&V!==void 0?V:gt)!==null&&W!==void 0?W:!1,code:x.code?{...x.code,optimize:Zr,regExp:Kr}:{optimize:Zr,regExp:Kr},loopRequired:(ee=x.loopRequired)!==null&&ee!==void 0?ee:$,loopEnum:(ce=x.loopEnum)!==null&&ce!==void 0?ce:$,meta:(xe=x.meta)!==null&&xe!==void 0?xe:!0,messages:(tt=x.messages)!==null&&tt!==void 0?tt:!0,inlineRefs:(Fe=x.inlineRefs)!==null&&Fe!==void 0?Fe:!0,schemaId:(Le=x.schemaId)!==null&&Le!==void 0?Le:"$id",addUsedSchema:(Ae=x.addUsedSchema)!==null&&Ae!==void 0?Ae:!0,validateSchema:(kt=x.validateSchema)!==null&&kt!==void 0?kt:!0,validateFormats:(Ye=x.validateFormats)!==null&&Ye!==void 0?Ye:!0,unicodeRegExp:(Wt=x.unicodeRegExp)!==null&&Wt!==void 0?Wt:!0,int32range:(Bt=x.int32range)!==null&&Bt!==void 0?Bt:!0,uriResolver:Js}}class R{constructor(b={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,b=this.opts={...b,...E(b)};const{es5:j,lines:S}=this.opts.code;this.scope=new i.ValueScope({scope:{},prefixes:y,es5:j,lines:S}),this.logger=B(b.logger);const u=b.validateFormats;b.validateFormats=!1,this.RULES=(0,o.getRules)(),k.call(this,v,b,"NOT SUPPORTED"),k.call(this,h,b,"DEPRECATED","warn"),this._metaOpts=L.call(this),b.formats&&F.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),b.keywords&&D.call(this,b.keywords),typeof b.meta=="object"&&this.addMetaSchema(b.meta),A.call(this),b.validateFormats=u}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:b,meta:j,schemaId:S}=this.opts;let u=f;S==="id"&&(u={...f},u.id=u.$id,delete u.$id),j&&b&&this.addMetaSchema(u,u[S],!1)}defaultMeta(){const{meta:b,schemaId:j}=this.opts;return this.opts.defaultMeta=typeof b=="object"?b[j]||b:void 0}validate(b,j){let S;if(typeof b=="string"){if(S=this.getSchema(b),!S)throw new Error(`no schema with key or ref "${b}"`)}else S=this.compile(b);const u=S(j);return"$async"in S||(this.errors=S.errors),u}compile(b,j){const S=this._addSchema(b,j);return S.validate||this._compileSchemaEnv(S)}compileAsync(b,j){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:S}=this.opts;return u.call(this,b,j);async function u(Y,C){await p.call(this,Y.$schema);const O=this._addSchema(Y,C);return O.validate||P.call(this,O)}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(C){if(!(C instanceof s.default))throw C;return q.call(this,C),await U.call(this,C.missingSchema),P.call(this,Y)}}function q({missingSchema:Y,missingRef:C}){if(this.refs[Y])throw new Error(`AnySchema ${Y} is loaded but ${C} cannot be resolved`)}async function U(Y){const C=await X.call(this,Y);this.refs[Y]||await p.call(this,C.$schema),this.refs[Y]||this.addSchema(C,Y,j)}async function X(Y){const C=this._loading[Y];if(C)return C;try{return await(this._loading[Y]=S(Y))}finally{delete this._loading[Y]}}}addSchema(b,j,S,u=this.opts.validateSchema){if(Array.isArray(b)){for(const P of b)this.addSchema(P,void 0,S,u);return this}let p;if(typeof b=="object"){const{schemaId:P}=this.opts;if(p=b[P],p!==void 0&&typeof p!="string")throw new Error(`schema ${P} must be string`)}return j=(0,c.normalizeId)(j||p),this._checkUnique(j),this.schemas[j]=this._addSchema(b,S,j,u,!0),this}addMetaSchema(b,j,S=this.opts.validateSchema){return this.addSchema(b,j,!0,S),this}validateSchema(b,j){if(typeof b=="boolean")return!0;let S;if(S=b.$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,b);if(!u&&j){const p="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(p);else throw new Error(p)}return u}getSchema(b){let j;for(;typeof(j=N.call(this,b))=="string";)b=j;if(j===void 0){const{schemaId:S}=this.opts,u=new a.SchemaEnv({schema:{},schemaId:S});if(j=a.resolveSchema.call(this,u,b),!j)return;this.refs[b]=j}return j.validate||this._compileSchemaEnv(j)}removeSchema(b){if(b instanceof RegExp)return this._removeAllSchemas(this.schemas,b),this._removeAllSchemas(this.refs,b),this;switch(typeof b){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const j=N.call(this,b);return typeof j=="object"&&this._cache.delete(j.schema),delete this.schemas[b],delete this.refs[b],this}case"object":{const j=b;this._cache.delete(j);let S=b[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(b){for(const j of b)this.addKeyword(j);return this}addKeyword(b,j){let S;if(typeof b=="string")S=b,typeof j=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),j.keyword=S);else if(typeof b=="object"&&j===void 0){if(j=b,S=j.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,j),!j)return(0,d.eachItem)(S,p=>ie.call(this,p)),this;ye.call(this,j);const u={...j,type:(0,l.getJSONTypes)(j.type),schemaType:(0,l.getJSONTypes)(j.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(b){const j=this.RULES.all[b];return typeof j=="object"?j.definition:!!j}removeKeyword(b){const{RULES:j}=this;delete j.keywords[b],delete j.all[b];for(const S of j.rules){const u=S.rules.findIndex(p=>p.keyword===b);u>=0&&S.rules.splice(u,1)}return this}addFormat(b,j){return typeof j=="string"&&(j=new RegExp(j)),this.formats[b]=j,this}errorsText(b=this.errors,{separator:j=", ",dataVar:S="data"}={}){return!b||b.length===0?"No errors":b.map(u=>`${S}${u.instancePath} ${u.message}`).reduce((u,p)=>u+j+p)}$dataMetaSchema(b,j){const S=this.RULES.all;b=JSON.parse(JSON.stringify(b));for(const u of j){const p=u.split("/").slice(1);let P=b;for(const q of p)P=P[q];for(const q in S){const U=S[q];if(typeof U!="object")continue;const{$data:X}=U.definition,Y=P[q];X&&Y&&(P[q]=Oe(Y))}}return b}_removeAllSchemas(b,j){for(const S in b){const u=b[S];(!j||j.test(S))&&(typeof u=="string"?delete b[S]:u&&!u.meta&&(this._cache.delete(u.schema),delete b[S]))}}_addSchema(b,j,S,u=this.opts.validateSchema,p=this.opts.addUsedSchema){let P;const{schemaId:q}=this.opts;if(typeof b=="object")P=b[q];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof b!="boolean")throw new Error("schema must be object or boolean")}let U=this._cache.get(b);if(U!==void 0)return U;S=(0,c.normalizeId)(P||S);const X=c.getSchemaRefs.call(this,b,S);return U=new a.SchemaEnv({schema:b,schemaId:q,meta:j,baseId:S,localRefs:X}),this._cache.set(U.schema,U),p&&!S.startsWith("#")&&(S&&this._checkUnique(S),this.refs[S]=U),u&&this.validateSchema(b,!0),U}_checkUnique(b){if(this.schemas[b]||this.refs[b])throw new Error(`schema with key or id "${b}" already exists`)}_compileSchemaEnv(b){if(b.meta?this._compileMetaSchema(b):a.compileSchema.call(this,b),!b.validate)throw new Error("ajv implementation error");return b.validate}_compileMetaSchema(b){const j=this.opts;this.opts=this._metaOpts;try{a.compileSchema.call(this,b)}finally{this.opts=j}}}R.ValidationError=n.default,R.MissingRefError=s.default,e.default=R;function k(x,b,j,S="error"){for(const u in x){const p=u;p in b&&this.logger[S](`${j}: option ${u}. ${x[p]}`)}}function N(x){return x=(0,c.normalizeId)(x),this.schemas[x]||this.refs[x]}function A(){const x=this.opts.schemas;if(x)if(Array.isArray(x))this.addSchema(x);else for(const b in x)this.addSchema(x[b],b)}function F(){for(const x in this.opts.formats){const b=this.opts.formats[x];b&&this.addFormat(x,b)}}function D(x){if(Array.isArray(x)){this.addVocabulary(x);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const b in x){const j=x[b];j.keyword||(j.keyword=b),this.addKeyword(j)}}function L(){const x={...this.opts};for(const b of _)delete x[b];return x}const Z={log(){},warn(){},error(){}};function B(x){if(x===!1)return Z;if(x===void 0)return console;if(x.log&&x.warn&&x.error)return x;throw new Error("logger must implement log, warn and error methods")}const re=/^[a-z_$][a-z0-9_$:-]*$/i;function H(x,b){const{RULES:j}=this;if((0,d.eachItem)(x,S=>{if(j.keywords[S])throw new Error(`Keyword ${S} is already defined`);if(!re.test(S))throw new Error(`Keyword ${S} has invalid name`)}),!!b&&b.$data&&!("code"in b||"validate"in b))throw new Error('$data keyword must have "code" or "validate" function')}function ie(x,b,j){var S;const u=b==null?void 0:b.post;if(j&&u)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:p}=this;let P=u?p.post:p.rules.find(({type:U})=>U===j);if(P||(P={type:j,rules:[]},p.rules.push(P)),p.keywords[x]=!0,!b)return;const q={keyword:x,definition:{...b,type:(0,l.getJSONTypes)(b.type),schemaType:(0,l.getJSONTypes)(b.schemaType)}};b.before?ke.call(this,P,q,b.before):P.rules.push(q),p.all[x]=q,(S=b.implements)===null||S===void 0||S.forEach(U=>this.addKeyword(U))}function ke(x,b,j){const S=x.rules.findIndex(u=>u.keyword===j);S>=0?x.rules.splice(S,0,b):(x.rules.push(b),this.logger.warn(`rule ${j} is not defined`))}function ye(x){let{metaSchema:b}=x;b!==void 0&&(x.$data&&this.opts.$data&&(b=Oe(b)),x.validateSchema=this.compile(b,!0))}const ct={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Oe(x){return{anyOf:[x,ct]}}})($f);var Hi={},Zi={},Ki={};Object.defineProperty(Ki,"__esModule",{value:!0});const Pk={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Ki.default=Pk;var gr={};Object.defineProperty(gr,"__esModule",{value:!0});gr.callRef=gr.getValidate=void 0;const Rk=Lr,Cl=me,st=he,wr=Ct,Nl=at,Zn=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 f();const d=Nl.resolveRef.call(c,l,s,r);if(d===void 0)throw new Rk.default(n.opts.uriResolver,s,r);if(d instanceof Nl.SchemaEnv)return m(d);return g(d);function f(){if(o===l)return ss(e,a,o,o.$async);const _=t.scopeValue("root",{ref:l});return ss(e,(0,st._)`${_}.validate`,l,l.$async)}function m(_){const y=qf(e,_);ss(e,y,_,_.$async)}function g(_){const y=t.scopeValue("schema",i.code.source===!0?{ref:_,code:(0,st.stringify)(_)}:{ref:_}),v=t.name("valid"),h=e.subschema({schema:_,dataTypes:[],schemaPath:st.nil,topSchemaRef:y,errSchemaPath:r},v);e.mergeEvaluated(h),e.ok(v)}}};function qf(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,st._)`${r.scopeValue("wrapper",{ref:t})}.validate`}gr.getValidate=qf;function ss(e,t,r,n){const{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:c}=o,l=c.passContext?wr.default.this:st.nil;n?d():f();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");const _=s.let("valid");s.try(()=>{s.code((0,st._)`await ${(0,Cl.callValidateCode)(e,t,l)}`),g(t),a||s.assign(_,!0)},y=>{s.if((0,st._)`!(${y} instanceof ${o.ValidationError})`,()=>s.throw(y)),m(y),a||s.assign(_,!1)}),e.ok(_)}function f(){e.result((0,Cl.callValidateCode)(e,t,l),()=>g(t),()=>m(t))}function m(_){const y=(0,st._)`${_}.errors`;s.assign(wr.default.vErrors,(0,st._)`${wr.default.vErrors} === null ? ${y} : ${wr.default.vErrors}.concat(${y})`),s.assign(wr.default.errors,(0,st._)`${wr.default.vErrors}.length`)}function g(_){var y;if(!o.opts.unevaluated)return;const v=(y=r==null?void 0:r.validate)===null||y===void 0?void 0:y.evaluated;if(o.props!==!0)if(v&&!v.dynamicProps)v.props!==void 0&&(o.props=Zn.mergeEvaluated.props(s,v.props,o.props));else{const h=s.var("props",(0,st._)`${_}.evaluated.props`);o.props=Zn.mergeEvaluated.props(s,h,o.props,st.Name)}if(o.items!==!0)if(v&&!v.dynamicItems)v.items!==void 0&&(o.items=Zn.mergeEvaluated.items(s,v.items,o.items));else{const h=s.var("items",(0,st._)`${_}.evaluated.items`);o.items=Zn.mergeEvaluated.items(s,h,o.items,st.Name)}}}gr.callRef=ss;gr.default=Tk;Object.defineProperty(Zi,"__esModule",{value:!0});const jk=Ki,Ck=gr,Nk=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",jk.default,Ck.default];Zi.default=Nk;var Gi={},Wi={};Object.defineProperty(Wi,"__esModule",{value:!0});const $s=he,Dt=$s.operators,ws={maximum:{okStr:"<=",ok:Dt.LTE,fail:Dt.GT},minimum:{okStr:">=",ok:Dt.GTE,fail:Dt.LT},exclusiveMaximum:{okStr:"<",ok:Dt.LT,fail:Dt.GTE},exclusiveMinimum:{okStr:">",ok:Dt.GT,fail:Dt.LTE}},Ik={message:({keyword:e,schemaCode:t})=>(0,$s.str)`must be ${ws[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,$s._)`{comparison: ${ws[e].okStr}, limit: ${t}}`},Ok={keyword:Object.keys(ws),type:"number",schemaType:"number",$data:!0,error:Ik,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,$s._)`${r} ${ws[t].fail} ${n} || isNaN(${r})`)}};Wi.default=Ok;var Bi={};Object.defineProperty(Bi,"__esModule",{value:!0});const ln=he,xk={message:({schemaCode:e})=>(0,ln.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,ln._)`{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,ln._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0,ln._)`${a} !== parseInt(${a})`;e.fail$data((0,ln._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};Bi.default=Ak;var Ji={},Qi={};Object.defineProperty(Qi,"__esModule",{value:!0});function Df(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}`)}};Ji.default=Dk;var Yi={};Object.defineProperty(Yi,"__esModule",{value:!0});const Uk=me,Fk=Q,Tr=he,Lk={message:({schemaCode:e})=>(0,Tr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Tr._)`{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,Tr._)`new RegExp`:(0,Fk.useFunc)(t,c),d=t.let("valid");t.try(()=>t.assign(d,(0,Tr._)`${l}(${o}, ${i}).test(${r})`),()=>t.assign(d,!1)),e.fail$data((0,Tr._)`!${d}`)}else{const c=(0,Uk.usePattern)(e,s);e.fail$data((0,Tr._)`!${c}.test(${r})`)}}};Yi.default=Vk;var Xi={};Object.defineProperty(Xi,"__esModule",{value:!0});const un=he,Hk={message({keyword:e,schemaCode:t}){const r=e==="maxProperties"?"more":"fewer";return(0,un.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,un._)`{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"?un.operators.GT:un.operators.LT;e.fail$data((0,un._)`Object.keys(${r}).length ${s} ${n}`)}};Xi.default=Zk;var ec={};Object.defineProperty(ec,"__esModule",{value:!0});const Qr=me,dn=he,Kk=Q,Gk={message:({params:{missingProperty:e}})=>(0,dn.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,dn._)`{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:_}=e.it;for(const y of r)if((g==null?void 0:g[y])===void 0&&!_.has(y)){const v=a.schemaEnv.baseId+a.errSchemaPath,h=`required property "${y}" is not defined at "${v}" (strictRequired)`;(0,Kk.checkStrictMode)(a,h,a.opts.strictRequired)}}function l(){if(c||o)e.block$data(dn.nil,f);else for(const g of r)(0,Qr.checkReportMissingProp)(e,g)}function d(){const g=t.let("missing");if(c||o){const _=t.let("valid",!0);e.block$data(_,()=>m(g,_)),e.ok(_)}else t.if((0,Qr.checkMissingProp)(e,r,g)),(0,Qr.reportMissingProp)(e,g),t.else()}function f(){t.forOf("prop",n,g=>{e.setParams({missingProperty:g}),t.if((0,Qr.noPropertyInData)(t,s,g,i.ownProperties),()=>e.error())})}function m(g,_){e.setParams({missingProperty:g}),t.forOf(g,n,()=>{t.assign(_,(0,Qr.propertyInData)(t,s,g,i.ownProperties)),t.if((0,dn.not)(_),()=>{e.error(),t.break()})},dn.nil)}}};ec.default=Wk;var tc={};Object.defineProperty(tc,"__esModule",{value:!0});const fn=he,Bk={message({keyword:e,schemaCode:t}){const r=e==="maxItems"?"more":"fewer";return(0,fn.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,fn._)`{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"?fn.operators.GT:fn.operators.LT;e.fail$data((0,fn._)`${r}.length ${s} ${n}`)}};tc.default=Jk;var rc={},On={};Object.defineProperty(On,"__esModule",{value:!0});const Uf=Ds;Uf.code='require("ajv/dist/runtime/equal").default';On.default=Uf;Object.defineProperty(rc,"__esModule",{value:!0});const io=De,Ze=he,Qk=Q,Yk=On,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,io.getSchemaTypes)(o.items):[];e.block$data(c,d,(0,Ze._)`${a} === false`),e.ok(c);function d(){const _=t.let("i",(0,Ze._)`${r}.length`),y=t.let("j");e.setParams({i:_,j:y}),t.assign(c,!0),t.if((0,Ze._)`${_} > 1`,()=>(f()?m:g)(_,y))}function f(){return l.length>0&&!l.some(_=>_==="object"||_==="array")}function m(_,y){const v=t.name("item"),h=(0,io.checkDataTypes)(l,v,i.opts.strictNumbers,io.DataType.Wrong),$=t.const("indices",(0,Ze._)`{}`);t.for((0,Ze._)`;${_}--;`,()=>{t.let(v,(0,Ze._)`${r}[${_}]`),t.if(h,(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(y,(0,Ze._)`${$}[${v}]`),e.error(),t.assign(c,!1).break()}).code((0,Ze._)`${$}[${v}] = ${_}`)})}function g(_,y){const v=(0,Qk.useFunc)(t,Yk.default),h=t.name("outer");t.label(h).for((0,Ze._)`;${_}--;`,()=>t.for((0,Ze._)`${y} = ${_}; ${y}--;`,()=>t.if((0,Ze._)`${v}(${r}[${_}], ${r}[${y}])`,()=>{e.error(),t.assign(c,!1).break(h)})))}}};rc.default=eP;var nc={};Object.defineProperty(nc,"__esModule",{value:!0});const Uo=he,tP=Q,rP=On,nP={message:"must be equal to constant",params:({schemaCode:e})=>(0,Uo._)`{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,Uo._)`!${(0,tP.useFunc)(t,rP.default)}(${r}, ${s})`):e.fail((0,Uo._)`${o} !== ${r}`)}};nc.default=sP;var sc={};Object.defineProperty(sc,"__esModule",{value:!0});const tn=he,oP=Q,aP=On,iP={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,tn._)`{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,f);else{if(!Array.isArray(s))throw new Error("ajv implementation error");const g=t.const("vSchema",o);d=(0,tn.or)(...s.map((_,y)=>m(g,y)))}e.pass(d);function f(){t.assign(d,!1),t.forOf("v",o,g=>t.if((0,tn._)`${l()}(${r}, ${g})`,()=>t.assign(d,!0).break()))}function m(g,_){const y=s[_];return typeof y=="object"&&y!==null?(0,tn._)`${l()}(${r}, ${g}[${_}])`:(0,tn._)`${r} === ${y}`}}};sc.default=cP;Object.defineProperty(Gi,"__esModule",{value:!0});const lP=Wi,uP=Bi,dP=Ji,fP=Yi,hP=Xi,pP=ec,mP=tc,gP=rc,_P=nc,yP=sc,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];Gi.default=vP;var oc={},Vr={};Object.defineProperty(Vr,"__esModule",{value:!0});Vr.validateAdditionalItems=void 0;const cr=he,Fo=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,Fo.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Ff(e,n)}};function Ff(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,Fo.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:Fo.Type.Num},l),a.allErrors||r.if((0,cr.not)(l),()=>r.break())})}}Vr.validateAdditionalItems=Ff;Vr.default=wP;var ac={},Hr={};Object.defineProperty(Hr,"__esModule",{value:!0});Hr.validateTuple=void 0;const Il=he,os=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 Lf(e,"additionalItems",t);r.items=!0,!(0,os.alwaysValidSchema)(r,t)&&e.ok((0,bP.validateArray)(e))}};function Lf(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=os.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),l=n.const("len",(0,Il._)`${o}.length`);r.forEach((f,m)=>{(0,os.alwaysValidSchema)(i,f)||(n.if((0,Il._)`${l} > ${m}`,()=>e.subschema({keyword:a,schemaProp:m,dataProp:m},c)),e.ok(c))});function d(f){const{opts:m,errSchemaPath:g}=i,_=r.length,y=_===f.minItems&&(_===f.maxItems||f[t]===!1);if(m.strictTuples&&!y){const v=`"${a}" is ${_}-tuple, but minItems or maxItems/${t} are not specified or different at path "${g}"`;(0,os.checkStrictMode)(i,v,m.strictTuples)}}}Hr.validateTuple=Lf;Hr.default=SP;Object.defineProperty(ac,"__esModule",{value:!0});const EP=Hr,kP={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,EP.validateTuple)(e,"items")};ac.default=kP;var ic={};Object.defineProperty(ic,"__esModule",{value:!0});const Ol=he,PP=Q,RP=me,TP=Vr,jP={message:({params:{len:e}})=>(0,Ol.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Ol._)`{limit: ${e}}`},CP={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:jP,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)))}};ic.default=CP;var cc={};Object.defineProperty(cc,"__esModule",{value:!0});const ft=he,Kn=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,Kn.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0,Kn.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Kn.alwaysValidSchema)(o,r)){let y=(0,ft._)`${d} >= ${a}`;i!==void 0&&(y=(0,ft._)`${y} && ${d} <= ${i}`),e.pass(y);return}o.items=!0;const f=t.name("valid");i===void 0&&a===1?g(f,()=>t.if(f,()=>t.break())):a===0?(t.let(f,!0),i!==void 0&&t.if((0,ft._)`${s}.length > 0`,m)):(t.let(f,!1),m()),e.result(f,()=>e.reset());function m(){const y=t.name("_valid"),v=t.let("count",0);g(y,()=>t.if(y,()=>_(v)))}function g(y,v){t.forRange("i",0,d,h=>{e.subschema({keyword:"contains",dataProp:h,dataPropType:Kn.Type.Num,compositeRule:!0},y),v()})}function _(y){t.code((0,ft._)`${y}++`),i===void 0?t.if((0,ft._)`${y} >= ${a}`,()=>t.assign(f,!0).break()):(t.if((0,ft._)`${y} > ${i}`,()=>t.assign(f,!1).break()),a===1?t.assign(f,!0):t.if((0,ft._)`${y} >= ${a}`,()=>t.assign(f,!0)))}}};cc.default=IP;var Vf={};(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 f=l===1?"property":"properties";return(0,t.str)`must have ${f} ${d} when property ${c} is present`},params:({params:{property:c,depsCount:l,deps:d,missingProperty:f}})=>(0,t._)`{property: ${c}, - missingProperty: ${f}, - 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 f in c){if(f==="__proto__")continue;const m=Array.isArray(c[f])?l:d;m[f]=c[f]}return[l,d]}function a(c,l=c.schema){const{gen:d,data:f,it:m}=c;if(Object.keys(l).length===0)return;const g=d.let("missing");for(const _ in l){const y=l[_];if(y.length===0)continue;const v=(0,n.propertyInData)(d,f,_,m.opts.ownProperties);c.setParams({property:_,depsCount:y.length,deps:y.join(", ")}),m.allErrors?d.if(v,()=>{for(const h of y)(0,n.checkReportMissingProp)(c,h)}):(d.if((0,t._)`${v} && (${(0,n.checkMissingProp)(c,y,g)})`),(0,n.reportMissingProp)(c,g),d.else())}}e.validatePropertyDeps=a;function i(c,l=c.schema){const{gen:d,data:f,keyword:m,it:g}=c,_=d.name("valid");for(const y in l)(0,r.alwaysValidSchema)(g,l[y])||(d.if((0,n.propertyInData)(d,f,y,g.opts.ownProperties),()=>{const v=c.subschema({keyword:m,schemaProp:y},_);c.mergeValidEvaluated(v,_)},()=>d.var(_,!0)),c.ok(_))}e.validateSchemaDeps=i,e.default=s})(Vf);var lc={};Object.defineProperty(lc,"__esModule",{value:!0});const Hf=he,OP=Q,xP={message:"property name must be valid",params:({params:e})=>(0,Hf._)`{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,Hf.not)(o),()=>{e.error(!0),s.allErrors||t.break()})}),e.ok(o)}};lc.default=AP;var Ws={};Object.defineProperty(Ws,"__esModule",{value:!0});const Gn=me,wt=he,MP=Ct,Wn=Q,zP={message:"must NOT have additional properties",params:({params:e})=>(0,wt._)`{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,Wn.alwaysValidSchema)(a,r))return;const l=(0,Gn.allSchemaProperties)(n.properties),d=(0,Gn.allSchemaProperties)(n.patternProperties);f(),e.ok((0,wt._)`${o} === ${MP.default.errors}`);function f(){t.forIn("key",s,v=>{!l.length&&!d.length?_(v):t.if(m(v),()=>_(v))})}function m(v){let h;if(l.length>8){const $=(0,Wn.schemaRefOrVal)(a,n.properties,"properties");h=(0,Gn.isOwnProperty)(t,$,v)}else l.length?h=(0,wt.or)(...l.map($=>(0,wt._)`${v} === ${$}`)):h=wt.nil;return d.length&&(h=(0,wt.or)(h,...d.map($=>(0,wt._)`${(0,Gn.usePattern)(e,$)}.test(${v})`))),(0,wt.not)(h)}function g(v){t.code((0,wt._)`delete ${s}[${v}]`)}function _(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,Wn.alwaysValidSchema)(a,r)){const h=t.name("valid");c.removeAdditional==="failing"?(y(v,h,!1),t.if((0,wt.not)(h),()=>{e.reset(),g(v)})):(y(v,h),i||t.if((0,wt.not)(h),()=>t.break()))}}function y(v,h,$){const E={keyword:"additionalProperties",dataProp:v,dataPropType:Wn.Type.Str};$===!1&&Object.assign(E,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(E,h)}}};Ws.default=qP;var uc={};Object.defineProperty(uc,"__esModule",{value:!0});const DP=Zs(),xl=me,co=Q,Al=Ws,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&&Al.default.code(new DP.KeywordCxt(o,Al.default,"additionalProperties"));const a=(0,xl.allSchemaProperties)(r);for(const f of a)o.definedProperties.add(f);o.opts.unevaluated&&a.length&&o.props!==!0&&(o.props=co.mergeEvaluated.props(t,(0,co.toHash)(a),o.props));const i=a.filter(f=>!(0,co.alwaysValidSchema)(o,r[f]));if(i.length===0)return;const c=t.name("valid");for(const f of i)l(f)?d(f):(t.if((0,xl.propertyInData)(t,s,f,o.opts.ownProperties)),d(f),o.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(f),e.ok(c);function l(f){return o.opts.useDefaults&&!o.compositeRule&&r[f].default!==void 0}function d(f){e.subschema({keyword:"properties",schemaProp:f,dataProp:f},c)}}};uc.default=UP;var dc={};Object.defineProperty(dc,"__esModule",{value:!0});const Ml=me,Bn=he,zl=Q,ql=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,Ml.allSchemaProperties)(r),c=i.filter(y=>(0,zl.alwaysValidSchema)(o,r[y]));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 Bn.Name)&&(o.props=(0,ql.evaluatedPropsToName)(t,o.props));const{props:f}=o;m();function m(){for(const y of i)l&&g(y),o.allErrors?_(y):(t.var(d,!0),_(y),t.if(d))}function g(y){for(const v in l)new RegExp(y).test(v)&&(0,zl.checkStrictMode)(o,`property ${v} matches pattern ${y} (use allowMatchingProperties)`)}function _(y){t.forIn("key",n,v=>{t.if((0,Bn._)`${(0,Ml.usePattern)(e,y)}.test(${v})`,()=>{const h=c.includes(y);h||e.subschema({keyword:"patternProperties",schemaProp:y,dataProp:v,dataPropType:ql.Type.Str},d),o.opts.unevaluated&&f!==!0?t.assign((0,Bn._)`${f}[${v}]`,!0):!h&&!o.allErrors&&t.if((0,Bn.not)(d),()=>t.break())})})}}};dc.default=FP;var fc={};Object.defineProperty(fc,"__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"}};fc.default=VP;var hc={};Object.defineProperty(hc,"__esModule",{value:!0});const HP=me,ZP={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:HP.validateUnion,error:{message:"must match a schema in anyOf"}};hc.default=ZP;var pc={};Object.defineProperty(pc,"__esModule",{value:!0});const as=he,KP=Q,GP={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,as._)`{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,f)=>{let m;(0,KP.alwaysValidSchema)(s,d)?t.var(c,!0):m=e.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},c),f>0&&t.if((0,as._)`${c} && ${a}`).assign(a,!1).assign(i,(0,as._)`[${i}, ${f}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,f),m&&e.mergeEvaluated(m,as.Name)})})}}};pc.default=WP;var mc={};Object.defineProperty(mc,"__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)})}};mc.default=JP;var gc={};Object.defineProperty(gc,"__esModule",{value:!0});const bs=he,Zf=Q,QP={message:({params:e})=>(0,bs.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,bs._)`{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,Zf.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const s=Dl(n,"then"),o=Dl(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,bs.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,f){return()=>{const m=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(m,a),f?t.assign(f,(0,bs._)`${d}`):e.setParams({ifClause:d})}}}};function Dl(e,t){const r=e.schema[t];return r!==void 0&&!(0,Zf.alwaysValidSchema)(e,r)}gc.default=YP;var _c={};Object.defineProperty(_c,"__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`)}};_c.default=e1;Object.defineProperty(oc,"__esModule",{value:!0});const t1=Vr,r1=ac,n1=Hr,s1=ic,o1=cc,a1=Vf,i1=lc,c1=Ws,l1=uc,u1=dc,d1=fc,f1=hc,h1=pc,p1=mc,m1=gc,g1=_c;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}oc.default=_1;var yc={},vc={};Object.defineProperty(vc,"__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:f}=i;if(!c.validateFormats)return;s?m():g();function m(){const _=r.scopeValue("formats",{ref:f.formats,code:c.code.formats}),y=r.const("fDef",(0,ze._)`${_}[${a}]`),v=r.let("fType"),h=r.let("format");r.if((0,ze._)`typeof ${y} == "object" && !(${y} instanceof RegExp)`,()=>r.assign(v,(0,ze._)`${y}.type || "string"`).assign(h,(0,ze._)`${y}.validate`),()=>r.assign(v,(0,ze._)`"string"`).assign(h,y)),e.fail$data((0,ze.or)($(),E()));function $(){return c.strictSchema===!1?ze.nil:(0,ze._)`${a} && !${h}`}function E(){const R=d.$async?(0,ze._)`(${y}.async ? await ${h}(${n}) : ${h}(${n}))`:(0,ze._)`${h}(${n})`,k=(0,ze._)`(typeof ${h} == "function" ? ${R} : ${h}.test(${n}))`;return(0,ze._)`${h} && ${h} !== true && ${v} === ${t} && !${k}`}}function g(){const _=f.formats[o];if(!_){$();return}if(_===!0)return;const[y,v,h]=E(_);y===t&&e.pass(R());function $(){if(c.strictSchema===!1){f.logger.warn(k());return}throw new Error(k());function k(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function E(k){const N=k instanceof RegExp?(0,ze.regexpCode)(k):c.code.formats?(0,ze._)`${c.code.formats}${(0,ze.getProperty)(o)}`:void 0,A=r.scopeValue("formats",{key:o,ref:k,code:N});return typeof k=="object"&&!(k instanceof RegExp)?[k.type||"string",k.validate,(0,ze._)`${A}.validate`]:["string",k,A]}function R(){if(typeof _=="object"&&!(_ instanceof RegExp)&&_.async){if(!d.$async)throw new Error("async format in sync schema");return(0,ze._)`await ${h}(${n})`}return typeof v=="function"?(0,ze._)`${h}(${n})`:(0,ze._)`${h}.test(${n})`}}}};vc.default=v1;Object.defineProperty(yc,"__esModule",{value:!0});const $1=vc,w1=[$1.default];yc.default=w1;var Mr={};Object.defineProperty(Mr,"__esModule",{value:!0});Mr.contentVocabulary=Mr.metadataVocabulary=void 0;Mr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Mr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(Hi,"__esModule",{value:!0});const b1=Zi,S1=Gi,E1=oc,k1=yc,Ul=Mr,P1=[b1.default,S1.default,(0,E1.default)(),k1.default,Ul.metadataVocabulary,Ul.contentVocabulary];Hi.default=P1;var $c={},Bs={};Object.defineProperty(Bs,"__esModule",{value:!0});Bs.DiscrError=void 0;var Fl;(function(e){e.Tag="tag",e.Mapping="mapping"})(Fl||(Bs.DiscrError=Fl={}));Object.defineProperty($c,"__esModule",{value:!0});const kr=he,Lo=Bs,Ll=at,R1=Lr,T1=Q,j1={message:({params:{discrError:e,tagName:t}})=>e===Lo.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,kr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},C1={keyword:"discriminator",type:"object",schemaType:"object",error:j1,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,kr._)`${r}${(0,kr.getProperty)(i)}`);t.if((0,kr._)`typeof ${l} == "string"`,()=>d(),()=>e.error(!1,{discrError:Lo.DiscrError.Tag,tag:l,tagName:i})),e.ok(c);function d(){const g=m();t.if(!1);for(const _ in g)t.elseIf((0,kr._)`${l} === ${_}`),t.assign(c,f(g[_]));t.else(),e.error(!1,{discrError:Lo.DiscrError.Mapping,tag:l,tagName:i}),t.endIf()}function f(g){const _=t.name("valid"),y=e.subschema({keyword:"oneOf",schemaProp:g},_);return e.mergeEvaluated(y,kr.Name),_}function m(){var g;const _={},y=h(s);let v=!0;for(let R=0;Rthis.addVocabulary(_)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const _=this.opts.$data?this.$dataMetaSchema(o,a):o;this.addMetaSchema(_,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=Zs();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 f=Fi();Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return f.default}});var m=Lr;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return m.default}})})(Ao,Ao.exports);var q1=Ao.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:f,it:m}=i,{opts:g,self:_}=m;if(!g.validateFormats)return;const y=new t.KeywordCxt(m,_.RULES.all.format.definition,"format");y.$data?v():h();function v(){const E=c.scopeValue("formats",{ref:_.formats,code:g.code.formats}),R=c.const("fmt",(0,r._)`${E}[${y.schemaCode}]`);i.fail$data((0,r.or)((0,r._)`typeof ${R} != "object"`,(0,r._)`${R} instanceof RegExp`,(0,r._)`typeof ${R}.compare != "function"`,$(R)))}function h(){const E=y.schema,R=_.formats[E];if(!R||R===!0)return;if(typeof R!="object"||R instanceof RegExp||typeof R.compare!="function")throw new Error(`"${f}": format "${E}" does not define "compare" function`);const k=c.scopeValue("formats",{key:E,ref:R,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[f].fail} 0`}},dependencies:["format"]};const a=i=>(i.addKeyword(e.formatLimitDefinition),i);e.default=a})(vf);(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r=yf,n=vf,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[f,m]=d.mode==="fast"?[r.fastFormats,a]:[r.fullFormats,o],g=d.formats||r.formatNames;return c(l,g,f,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,f,m){var g,_;(g=(_=l.opts.code).formats)!==null&&g!==void 0||(_.formats=(0,s._)`require("ajv-formats/dist/formats").${m}`);for(const y of d)l.addFormat(y,f[y])}e.exports=t=i,Object.defineProperty(t,"__esModule",{value:!0}),t.default=i})(xo,xo.exports);var D1=xo.exports;const U1=Yl(D1);function F1(){const e=new fE({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=dr,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 is(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&&is(o,r[s])}}if(Array.isArray(e.anyOf))for(const r of e.anyOf)typeof r!="boolean"&&is(r,t);if(Array.isArray(e.oneOf))for(const r of e.oneOf)typeof r!="boolean"&&is(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 dd{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",qa,t.tools,async()=>(await this.listTools()).tools),t.prompts&&((o=(s=this._serverCapabilities)==null?void 0:s.prompts)!=null&&o.listChanged)&&this._setupListChangedHandler("prompts",Aa,t.prompts,async()=>(await this.listPrompts()).prompts),t.resources&&((i=(a=this._serverCapabilities)==null?void 0:a.resources)!=null&&i.listChanged)&&this._setupListChangedHandler("resources",Ca,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=Nv(this._capabilities,t)}setRequestHandler(t,r){const n=ld(t),s=n==null?void 0:n.method;if(!s)throw new Error("Schema is missing a method literal");const o=ud(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(ad,c);if(!d.success){const R=d.error instanceof Error?d.error.message:String(d.error);throw new se(ae.InvalidParams,`Invalid elicitation request: ${R}`)}const{params:f}=d.data;f.mode=f.mode??"form";const{supportsFormMode:m,supportsUrlMode:g}=K1(this._capabilities.elicitation);if(f.mode==="form"&&!m)throw new se(ae.InvalidParams,"Client does not support form-mode elicitation requests");if(f.mode==="url"&&!g)throw new se(ae.InvalidParams,"Client does not support URL-mode elicitation requests");const _=await Promise.resolve(r(c,l));if(f.task){const R=Ut(mn,_);if(!R.success){const k=R.error instanceof Error?R.error.message:String(R.error);throw new se(ae.InvalidParams,`Invalid task creation result: ${k}`)}return R.data}const y=Ut(id,_);if(!y.success){const R=y.error instanceof Error?y.error.message:String(y.error);throw new se(ae.InvalidParams,`Invalid elicitation result: ${R}`)}const v=y.data,h=f.mode==="form"?f.requestedSchema:void 0;if(f.mode==="form"&&v.action==="accept"&&v.content&&h&&(E=($=this._capabilities.elicitation)==null?void 0:$.form)!=null&&E.applyDefaults)try{is(h,v.content)}catch{}return v};return super.setRequestHandler(t,i)}if(a==="sampling/createMessage"){const i=async(c,l)=>{const d=Ut(Da,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:f}=d.data,m=await Promise.resolve(r(c,l));if(f.task){const v=Ut(mn,m);if(!v.success){const h=v.error instanceof Error?v.error.message:String(v.error);throw new se(ae.InvalidParams,`Invalid task creation result: ${h}`)}return v.data}const _=f.tools||f.toolChoice?od:sd,y=Ut(_,m);if(!y.success){const v=y.error instanceof Error?y.error.message:String(y.error);throw new se(ae.InvalidParams,`Invalid sampling result: ${v}`)}return y.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:xs,capabilities:this._capabilities,clientInfo:this._clientInfo}},Lu,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!ay.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"},Pr,t)}async complete(t,r){return this.request({method:"completion/complete",params:t},cd,r)}async setLoggingLevel(t,r){return this.request({method:"logging/setLevel",params:{level:t}},Pr,r)}async getPrompt(t,r){return this.request({method:"prompts/get",params:t},ed,r)}async listPrompts(t,r){return this.request({method:"prompts/list",params:t},Na,r)}async listResources(t,r){return this.request({method:"resources/list",params:t},Pa,r)}async listResourceTemplates(t,r){return this.request({method:"resources/templates/list",params:t},Ra,r)}async readResource(t,r){return this.request({method:"resources/read",params:t},ja,r)}async subscribeResource(t,r){return this.request({method:"resources/subscribe",params:t},Pr,r)}async unsubscribeResource(t,r){return this.request({method:"resources/unsubscribe",params:t},Pr,r)}async callTool(t,r=dr,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},za,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(t,r,n,s){const o=Gy.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 f=await s();c(null,f)}catch(f){const m=f instanceof Error?f:new Error(String(f));c(m,null)}},d=()=>{if(i){const f=this._listChangedDebounceTimers.get(t);f&&clearTimeout(f);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 wc={};/*! - * content-type - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - */var Vl=/; *([!#$%&'*+.^_`|~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]+$/,Kf=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,B1=/\\([\u000b\u0020-\u00ff])/g,J1=/([\\"])/g,Gf=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;wc.format=Q1;wc.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||!Gf.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 wc.parse(e).type}catch{const t=(e.split(";",1)[0]??"").trim().toLowerCase();return t===""||e.slice(t.length).includes(",")?void 0:t}}function Vo(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?{...Vo(t.headers),...Vo(n.headers)}:t.headers};return e(r,s)}:e}let bc;bc=globalThis.crypto;async function sR(e){return(await bc).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=h_().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:sy.custom,message:"URL must be parseable",fatal:!0}),tp}).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:T().url(),authorization_servers:G(Ke).optional(),jwks_uri:T().url().optional(),scopes_supported:G(T()).optional(),bearer_methods_supported:G(T()).optional(),resource_signing_alg_values_supported:G(T()).optional(),resource_name:T().optional(),resource_documentation:T().optional(),resource_policy_uri:T().url().optional(),resource_tos_uri:T().url().optional(),tls_client_certificate_bound_access_tokens:ve().optional(),authorization_details_types_supported:G(T()).optional(),dpop_signing_alg_values_supported:G(T()).optional(),dpop_bound_access_tokens_required:ve().optional()}),Wf=Be({issuer:T(),authorization_endpoint:Ke,token_endpoint:Ke,registration_endpoint:Ke.optional(),scopes_supported:G(T()).optional(),response_types_supported:G(T()),response_modes_supported:G(T()).optional(),grant_types_supported:G(T()).optional(),token_endpoint_auth_methods_supported:G(T()).optional(),token_endpoint_auth_signing_alg_values_supported:G(T()).optional(),service_documentation:Ke.optional(),revocation_endpoint:Ke.optional(),revocation_endpoint_auth_methods_supported:G(T()).optional(),revocation_endpoint_auth_signing_alg_values_supported:G(T()).optional(),introspection_endpoint:T().optional(),introspection_endpoint_auth_methods_supported:G(T()).optional(),introspection_endpoint_auth_signing_alg_values_supported:G(T()).optional(),code_challenge_methods_supported:G(T()).optional(),client_id_metadata_document_supported:ve().optional()}),uR=Be({issuer:T(),authorization_endpoint:Ke,token_endpoint:Ke,userinfo_endpoint:Ke.optional(),jwks_uri:Ke,registration_endpoint:Ke.optional(),scopes_supported:G(T()).optional(),response_types_supported:G(T()),response_modes_supported:G(T()).optional(),grant_types_supported:G(T()).optional(),acr_values_supported:G(T()).optional(),subject_types_supported:G(T()),id_token_signing_alg_values_supported:G(T()),id_token_encryption_alg_values_supported:G(T()).optional(),id_token_encryption_enc_values_supported:G(T()).optional(),userinfo_signing_alg_values_supported:G(T()).optional(),userinfo_encryption_alg_values_supported:G(T()).optional(),userinfo_encryption_enc_values_supported:G(T()).optional(),request_object_signing_alg_values_supported:G(T()).optional(),request_object_encryption_alg_values_supported:G(T()).optional(),request_object_encryption_enc_values_supported:G(T()).optional(),token_endpoint_auth_methods_supported:G(T()).optional(),token_endpoint_auth_signing_alg_values_supported:G(T()).optional(),display_values_supported:G(T()).optional(),claim_types_supported:G(T()).optional(),claims_supported:G(T()).optional(),service_documentation:T().optional(),claims_locales_supported:G(T()).optional(),ui_locales_supported:G(T()).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=M({...uR.shape,...Wf.pick({code_challenge_methods_supported:!0}).shape}),fR=M({access_token:T(),id_token:T().optional(),token_type:T(),expires_in:oy().optional(),scope:T().optional(),refresh_token:T().optional()}).strip(),hR=M({error:T(),error_description:T().optional(),error_uri:T().optional()}),Hl=Ke.optional().or(I("").transform(()=>{})),pR=M({redirect_uris:G(Ke),token_endpoint_auth_method:T().optional(),grant_types:G(T()).optional(),response_types:G(T()).optional(),client_name:T().optional(),client_uri:Ke.optional(),logo_uri:Hl,scope:T().optional(),contacts:G(T()).optional(),tos_uri:Hl,policy_uri:T().optional(),jwks_uri:Ke.optional(),jwks:fa().optional(),software_id:T().optional(),software_version:T().optional(),software_statement:T().optional()}).strip(),mR=M({client_id:T(),client_secret:T().optional(),client_id_issued_at:fe().optional(),client_secret_expires_at:fe().optional()}).strip(),gR=pR.merge(mR);M({error:T(),error_description:T().optional()}).strip();M({token:T(),token_type_hint:T().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 CR(e,t,r,n){const s=new URL(e),o=(n==null?void 0:n.protocolVersion)??xs;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 Kl(a,o,r);if(!(n!=null&&n.metadataUrl)&&jR(i,s.pathname)){const c=new URL(`/.well-known/${t}`,s);i=await Kl(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 Qf(e,{fetchFn:t=fetch,protocolVersion:r=xs}={}){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 Sc(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"?Wf.parse(await c.json()):dR.parse(await c.json())}}}async function IR(e,t){let r,n;try{r=await Jf(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 Qf(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(lo))throw new Error(`Incompatible auth server: does not support response type ${lo}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(uo))throw new Error(`Incompatible auth server: does not support code challenge method ${uo}`)}else i=new URL("/authorize",e);const c=await cR(),l=c.code_verifier,d=c.code_challenge;return i.searchParams.set("response_type",lo),i.searchParams.set("client_id",r.client_id),i.searchParams.set("code_challenge",d),i.searchParams.set("code_challenge_method",uo),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 Yf(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)??[],f=wR(n,d);bR(f,n,c,r)}const l=await(a??fetch)(i,{method:"POST",headers:c,body:r});if(!l.ok)throw await Bf(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 Yf(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 Yf(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 Bf(a);return gR.parse(await a.json())}class po 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 Gl=10,qR=13,tr=32;function mo(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=mo,onError:r=mo,onRetry:n=mo,onComment:s,maxBufferSize:o}=e,a=[];let i=0,c=!0,l,d="",f=0,m,g=!1;function _(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 F=v(k);F!==""&&(a.push(F),i=F.length),y();return}if(k.indexOf(` -`)===-1&&k.indexOf("\r")===-1){a.push(k),i+=k.length,y();return}a.push(k);const N=a.join("");a.length=0,i=0;const A=v(N);A!==""&&(a.push(A),i=A.length),y()}function y(){o!==void 0&&(i+d.length<=o||(g=!0,a.length=0,i=0,l=void 0,d="",f=0,m=void 0,r(new po(`Buffered data exceeded max buffer size of ${o} characters`,{type:"max-buffer-size-exceeded"}))))}function v(k){let N=0;if(k.indexOf("\r")===-1){let A=k.indexOf(` -`,N);for(;A!==-1;){if(N===A){f>0&&t({id:l,event:m,data:d}),l=void 0,d="",f=0,m=void 0,N=A+1,A=k.indexOf(` -`,N);continue}const F=k.charCodeAt(N);if(Wl(k,N,F)){const D=k.charCodeAt(N+5)===tr?N+6:N+5,L=k.slice(D,A);if(f===0&&k.charCodeAt(A+1)===Gl){t({id:l,event:m,data:L}),l=void 0,d="",m=void 0,N=A+2,A=k.indexOf(` -`,N);continue}d=f===0?L:`${d} -${L}`,f++}else Bl(k,N,F)?m=k.slice(k.charCodeAt(N+6)===tr?N+7:N+6,A)||void 0:h(k,N,A);N=A+1,A=k.indexOf(` -`,N)}return k.slice(N)}for(;N20?`${k.slice(0,20)}…`:k}"`,{type:"unknown-field",field:k,value:N,line:A}));break}}function E(){f>0&&t({id:l,event:m,data:d}),l=void 0,d="",f=0,m=void 0}function R(k={}){if(k.consume&&a.length>0){const N=a.join("");h(N,0,N.length)}c=!0,l=void 0,d="",f=0,m=void 0,a.length=0,i=0,g=!1}return{feed:_,reset:R}}function Wl(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 Bl(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 Sr 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 br("No auth provider");let t;try{t=await Jn(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 br;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=Vo((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 Sr(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,f,m,g;try{const _=t.pipeThrough(new TextDecoderStream).pipeThrough(new UR({onRetry:h=>{this._serverRetryMs=h}})).getReader();for(;;){const{value:h,done:$}=await _.read();if($)break;if(h.id&&(a=h.id,i=!0,s==null||s(h.id)),!!h.data&&(!h.event||h.event==="message"))try{const E=Qn.parse(JSON.parse(h.data));Yr(E)&&(c=!0,o!==void 0&&(E.id=o)),(d=this.onmessage)==null||d.call(this,E)}catch(E){(f=this.onerror)==null||f.call(this,E)}}(n||i)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:a,onresumptiontoken:s,replayMessageId:o},0)}catch(_){if((m=this.onerror)==null||m.call(this,new Error(`SSE stream disconnected: ${_}`)),(n||i)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:a,onresumptiontoken:s,replayMessageId:o},0)}catch(h){(g=this.onerror)==null||g.call(this,new Error(`Failed to reconnect: ${h instanceof Error?h.message:String(h)}`))}}})()}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 br("No auth provider");if(await Jn(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new br("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:So(t)?t.id:void 0}).catch(E=>{var R;return(R=this.onerror)==null?void 0:R.call(this,E)});return}const f=await this._commonHeaders();f.set("content-type","application/json"),f.set("accept","application/json, text/event-stream");const m={...this._requestInit,method:"POST",headers:f,body:JSON.stringify(t),signal:(n=this._abortController)==null?void 0:n.signal},g=await(this._fetch??fetch)(this._url,m),_=g.headers.get("mcp-session-id");if(_&&(this._sessionId=_),!g.ok){const E=await g.text().catch(()=>null);if(g.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Sr(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:R,scope:k}=Zl(g);if(this._resourceMetadataUrl=R,this._scope=k,await Jn(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new br;return this._hasCompletedAuthFlow=!0,this.send(t)}if(g.status===403&&this._authProvider){const{resourceMetadataUrl:R,scope:k,error:N}=Zl(g);if(N==="insufficient_scope"){const A=g.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===A)throw new Sr(403,"Server returned 403 after trying upscoping");if(k&&(this._scope=k),R&&(this._resourceMetadataUrl=R),this._lastUpscopingHeader=A??void 0,await Jn(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new br;return this.send(t)}}throw new Sr(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()),by(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(E=>{var R;return(R=this.onerror)==null?void 0:R.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,h=g.headers.get("content-type"),$=rR(h);if(v)if($==="text/event-stream")this._handleSseStream(g.body,{onresumptiontoken:d},!1);else if($==="application/json"){const E=await g.json(),R=Array.isArray(E)?E.map(k=>Qn.parse(k)):[Qn.parse(E)];for(const k of R)(o=this.onmessage)==null||o.call(this,k)}else throw await((a=g.body)==null?void 0:a.cancel()),new Sr(-1,`Unexpected content type: ${h}`);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 Sr(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",Xf="ui://excalidraw/mcp-app.html",KR=["read_me","create_view"],eh=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:Xf,modelTools:KR,appTools:eh}};function tT(e){return eT[e]}function rT(){return new URL(ht(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!==Xf)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(!eh.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=K.useRef(null),r=K.useRef(null),n=K.useRef(!1),s=K.useRef(e),o=K.useRef(!1);s.current=e;const[a,i]=K.useState(),[c,l]=K.useState("loading"),[d,f]=K.useState(e.height),[m,g]=K.useState(!1),[_,y]=K.useState(0),v=K.useRef(null),h=e.input.elements,$=!!e.permissions.clipboardWrite;o.current=m;const E=K.useCallback(()=>{g(!1),document.fullscreenElement&&document.exitFullscreen()},[]),R=K.useCallback(()=>{var A,F;if(m){E();return}g(!0),(F=(A=v.current)==null?void 0:A.requestFullscreen)==null||F.call(A).catch(()=>{})},[E,m]),k=K.useCallback(()=>{aT(),i(void 0),l("loading"),y(A=>A+1)},[]);K.useEffect(()=>{const A=v.current;if(!A)return;const F=()=>{o.current||f(XR(A.clientWidth))};F();const D=new ResizeObserver(F);return D.observe(A),()=>D.disconnect()},[]),K.useEffect(()=>{if(!m)return;const A=v.current,F=L=>{L.key==="Escape"&&(document.fullscreenElement||E())},D=()=>{document.fullscreenElement||g(!1)};return window.addEventListener("keydown",F),document.addEventListener("fullscreenchange",D),()=>{window.removeEventListener("keydown",F),document.removeEventListener("fullscreenchange",D),document.fullscreenElement===A&&document.exitFullscreen()}},[E,m]),K.useEffect(()=>{tT(e.provider);{l("unavailable");return}},[_,e.provider,e.resource_uri]),K.useEffect(()=>{if(!a||c!=="ready")return;const A=t.current;if(!A)return;let F=null;const D=[],L=cT(A,()=>{A.contentWindow&&(F=new e$(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"}}),F.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??{})},F.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"),{}},F.onsizechange=()=>{},F.oninitialized=()=>{n.current=!0;try{const Z=JSON.parse(h),B={arguments:{elements:Array.isArray(Z)?l$(Z):Z}};for(const re of[0,50,200,750])D.push(window.setTimeout(()=>{r.current===F&&F.sendToolInput(B)},re));F.sendToolResult(s.current.result)}catch{l("error")}},r.current=F,F.connect(new Yv(A.contentWindow??void 0,A.contentWindow)).catch(()=>l("error")))});return()=>{L(),D.forEach(Z=>window.clearTimeout(Z)),n.current=!1,F==null||F.teardownResource({}).catch(()=>{}),r.current===F&&(r.current=null)}},[a,c,m,h,$,_]),K.useEffect(()=>{var A;c!=="ready"||!n.current||(A=r.current)==null||A.sendToolResult(e.result).catch(()=>{})},[e.result,c]);const N=c==="unavailable"||c==="incompatible"||c==="error";return w.jsxs("section",{ref:v,className:`chat-mcp-app${m?" chat-mcp-app-fullscreen":""}`,"aria-label":"Interactive Excalidraw diagram",children:[w.jsx("header",{children:w.jsx("button",{type:"button",onClick:R,children:m?"Exit fullscreen":"Fullscreen"})}),c==="loading"&&w.jsx("div",{className:"chat-mcp-loading",role:"status",children:"Loading interactive diagram…"}),N&&w.jsxs("div",{className:"chat-mcp-error",children:["Interactive diagram unavailable. The cited text answer is still available.",w.jsx("button",{type:"button",onClick:k,children:"Retry diagram"})]}),a&&c==="ready"&&w.jsx("iframe",{ref:t,title:"Interactive Excalidraw diagram",sandbox:"allow-scripts",allow:$?"clipboard-write":void 0,srcDoc:a,style:{height:d}},_)]})},th=()=>({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{...th(),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 ra(e){return e.publication_id||e.public_capability||e.version_id||`${e.scope}:${e.identifier}:${e.version??"pending"}`}const rh=K.createContext(null),BT=({children:e,workspaceKey:t,autoOpenOnMount:r=!1})=>{const[n,s]=K.useReducer(uT,void 0,th),o=K.useRef(null),a=K.useRef(t);K.useEffect(()=>{a.current!==t&&(a.current=t,o.current=null,s({type:"reset"}))},[t]);const i=K.useCallback(()=>{s({type:"close"}),window.setTimeout(()=>{var h;return(h=o.current)==null?void 0:h.focus()},0)},[]),c=K.useCallback(h=>s({type:"register",key:ra(h),block:h,autoOpenOnMount:r}),[r]),l=K.useCallback(h=>s({type:"unregister",key:h}),[]),d=K.useCallback((h,$)=>{o.current=$??null,s({type:"open",key:ra(h),block:h})},[]),f=K.useCallback(h=>s({type:"tab",tab:h}),[]),m=K.useCallback(h=>s({type:"source",path:h}),[]),g=K.useCallback(h=>s({type:"version",versionId:h}),[]),_=K.useCallback(h=>s({type:"width",percent:h}),[]),y=K.useCallback(()=>s({type:"reset"}),[]),v=K.useMemo(()=>({state:n,autoOpenOnMount:r,register:c,unregister:l,open:d,close:i,setTab:f,setSourceFile:m,setVersion:g,setPanelPercent:_,reset:y}),[r,i,d,c,y,_,m,f,g,n,l]);return w.jsx(rh.Provider,{value:v,children:e})};function xn(){const e=K.useContext(rh);if(!e)throw new Error("Poster artifacts require an ArtifactPanelProvider");return e}function Jl(e,t,r){return ht(`/api/v1/chat/artifacts/${encodeURIComponent(e)}/versions/${encodeURIComponent(t)}/source/${r.split("/").map(encodeURIComponent).join("/")}`)}const dT=({block:e,forceDialog:t=!1})=>{var R,k;const r=xn(),n=r.close,[s,o]=K.useState(()=>{var N;return typeof window<"u"&&((N=window.matchMedia)==null?void 0:N.call(window,"(max-width: 760px)").matches)}),a=K.useRef(null),i=K.useRef(!1),c=t||s;K.useEffect(()=>{var F,D;const N=(F=window.matchMedia)==null?void 0:F.call(window,"(max-width: 760px)");if(!N)return;const A=()=>o(N.matches);return A(),(D=N.addEventListener)==null||D.call(N,"change",A),()=>{var L;return(L=N.removeEventListener)==null?void 0:L.call(N,"change",A)}},[]),K.useEffect(()=>{var F,D;if(!c)return;(D=(F=a.current)==null?void 0:F.querySelector("[data-artifact-close]"))==null||D.focus(),window.history.pushState({...window.history.state,pwcArtifactPanel:!0},""),i.current=!0;const N=()=>{i.current=!1,n()},A=L=>{L.key==="Escape"&&(L.preventDefault(),n(),i.current&&(i.current=!1,window.history.back()))};return window.addEventListener("popstate",N),document.addEventListener("keydown",A),()=>{window.removeEventListener("popstate",N),document.removeEventListener("keydown",A)}},[n,c]);const d=ur({queryKey:["chat-latex-paper",e.artifact_id],queryFn:async()=>{const N=await fetch(ht(`/api/v1/chat/artifacts/${encodeURIComponent(e.artifact_id)}`),{credentials:"include",cache:"no-store"});if(!N.ok)throw new Error("Could not load paper details");return N.json()},enabled:!!e.artifact_id,staleTime:5e3}).data,f=d==null?void 0:d.source_head,m=d==null?void 0:d.preview_head,g=ur({queryKey:["chat-latex-paper-manifest",e.artifact_id,f==null?void 0:f.version_id],queryFn:async()=>{const N=await fetch(ht(`/api/v1/chat/artifacts/${encodeURIComponent(e.artifact_id)}/versions/${encodeURIComponent(f.version_id)}/manifest`),{credentials:"include",cache:"no-store"});if(!N.ok)throw new Error("Could not load paper files");return N.json()},enabled:r.state.tab==="files"&&!!(f!=null&&f.version_id),staleTime:Number.POSITIVE_INFINITY}),_=r.state.sourceFile??((R=g.data)==null?void 0:R.root_document),y=ur({queryKey:["chat-latex-paper-source",e.artifact_id,f==null?void 0:f.version_id,_],queryFn:async()=>{const N=await fetch(Jl(e.artifact_id,f.version_id,_),{credentials:"include",cache:"no-store"});if(!N.ok)throw new Error("Could not load paper source");return N.text()},enabled:r.state.tab==="files"&&!!(f!=null&&f.version_id&&_),staleTime:Number.POSITIVE_INFINITY}),v=m?ht(`/api/v1/chat/artifacts/${encodeURIComponent(e.artifact_id)}/versions/${encodeURIComponent(m.version_id)}/preview`):null,h=((k=g.data)==null?void 0:k.files.filter(N=>N.media_type==="text/x-tex"||N.media_type==="application/x-bibtex"))??[],$=!!(f&&m&&f.version_id!==m.version_id),E=()=>{n(),c&&i.current&&(i.current=!1,window.history.back())};return w.jsxs("section",{ref:a,className:`chat-artifact-panel${c?" is-dialog":" is-docked"}`,role:c?"dialog":"complementary","aria-modal":c?!0:void 0,"aria-label":e.title,"data-testid":"latex-paper-panel",children:[w.jsxs("header",{children:[w.jsxs("div",{children:[w.jsx("span",{children:"Private paper"}),w.jsx("h2",{children:e.title})]}),w.jsx("button",{type:"button","data-artifact-close":!0,"aria-label":c?"Back to conversation":"Close paper",onClick:E,children:w.jsx(Xl,{})})]}),w.jsxs("nav",{"aria-label":"Paper views",children:[w.jsx("button",{type:"button","aria-pressed":r.state.tab==="preview",className:r.state.tab==="preview"?"active":"",onClick:()=>r.setTab("preview"),children:"Preview"}),w.jsx("button",{type:"button","aria-pressed":r.state.tab==="files",className:r.state.tab==="files"?"active":"",onClick:()=>r.setTab("files"),children:"Files"})]}),w.jsx("div",{className:"chat-artifact-panel-body",children:r.state.tab==="preview"?v?w.jsx("iframe",{title:`Preview of ${e.title}`,src:v,className:"h-full w-full border-0"}):w.jsx("p",{children:"Preview is compiling. The stored source is available in Files."}):w.jsxs("div",{className:"chat-artifact-source-workspace",children:[w.jsx("nav",{"aria-label":"Paper source files",children:h.map(N=>w.jsx("button",{type:"button","aria-pressed":_===N.path,onClick:()=>r.setSourceFile(N.path),children:N.path},N.path))}),w.jsx("pre",{children:w.jsx("code",{children:y.isError?"Source could not be loaded.":y.data??"Loading source…"})})]})}),w.jsxs("footer",{children:[w.jsxs("div",{className:"chat-artifact-metadata",children:[$&&w.jsx("strong",{children:"Out of date"}),f&&w.jsxs("span",{children:["Source v",f.version," · ",f.compile_status]})]}),w.jsxs("div",{className:"chat-artifact-actions",children:[v&&w.jsxs("a",{href:v,download:!0,children:[w.jsx(go,{})," PDF"]}),f&&_&&w.jsxs("a",{href:Jl(e.artifact_id,f.version_id,_),download:!0,children:[w.jsx(oa,{})," Source"]})]})]})]})},fT="https://github.com/Chenruishuo/posterly/tree/b9f42e5578a49a27525a68f85376bb3bb25af86f";function hT(){if(typeof window>"u")return null;const e=window.location.pathname.match(/^\/share\/([^/]+)/u);return e?decodeURIComponent(e[1]):null}function nh(e){if(e.scope==="public"){const n=hT();if(!n||!e.public_capability)return null;const s=`/api/v1/chat/shares/${encodeURIComponent(n)}/artifacts/${encodeURIComponent(e.public_capability)}`;return{preview:ht(`${s}/preview`),png:ht(`${s}/download/png`),pdf:ht(`${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)=>ht(`${t}/${n}/${s.split("/").map(encodeURIComponent).join("/")}`);return{preview:ht(`${t}/preview`),png:r("download","poster.png"),pdf:null,manifest:ht(`${t}/manifest`),source:n=>r("source",n),gate:n=>r("source",n),download:n=>r("download",n)}}const sh=e=>({passed:"Passed",warnings:"Passed with warnings",failed:"Draft—checks failed"})[e??"passed"];function pT(){const[e,t]=K.useState(()=>{var r;return typeof window<"u"&&((r=window.matchMedia)==null?void 0:r.call(window,"(max-width: 760px)").matches)});return K.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 mT=({forceDialog:e=!1,readerFallback:t=!1})=>{var k,N,A,F;const r=xn(),n=r.close,{state:s}=r,o=s.selected,a=pT(),i=e||a,c=K.useRef(null),l=K.useRef(!1),d=ur({queryKey:["chat-artifact-versions",o==null?void 0:o.artifact_id],queryFn:async()=>{const D=await fetch(ht(`/api/v1/chat/artifacts/${encodeURIComponent(o.artifact_id)}`),{credentials:"include",cache:"no-store"});if(!D.ok)throw new Error("Could not load poster versions");return(await D.json()).versions},enabled:s.open&&(o==null?void 0:o.scope)==="owner"&&!!o.artifact_id,staleTime:Number.POSITIVE_INFINITY}),f=(k=d.data)==null?void 0:k.find(D=>D.version_id===s.selectedVersionId),m=o&&f?{...o,version_id:f.version_id,version:f.version,gate_status:f.gate_status,total_bytes:f.total_bytes}:o,g=m?nh(m):null,y=ur({queryKey:["chat-artifact-manifest",m==null?void 0:m.version_id],queryFn:async()=>{const D=await fetch(g.manifest,{credentials:"include",cache:"no-store"});if(!D.ok)throw new Error("Could not load poster details");return D.json()},enabled:s.open&&(m==null?void 0:m.scope)==="owner"&&!!(g!=null&&g.manifest),staleTime:Number.POSITIVE_INFINITY}).data,v=s.sourceFile??(y==null?void 0:y.entrypoint)??null,h=ur({queryKey:["chat-artifact-source",m==null?void 0:m.version_id,v],queryFn:async()=>{const D=await fetch(g.source(v),{credentials:"include",cache:"no-store"});if(!D.ok)throw new Error("Source could not be loaded");return D.text()},enabled:s.open&&s.tab==="source"&&(m==null?void 0:m.scope)==="owner"&&!!(v&&(g!=null&&g.source)),staleTime:Number.POSITIVE_INFINITY});if(K.useEffect(()=>{var L,Z;if(!s.open||!i)return;(Z=(L=c.current)==null?void 0:L.querySelector("[data-artifact-close]"))==null||Z.focus(),window.history.pushState({...window.history.state,pwcArtifactPanel:!0},""),l.current=!0;const D=()=>{l.current=!1,n()};return window.addEventListener("popstate",D),()=>window.removeEventListener("popstate",D)},[n,i,s.open]),K.useEffect(()=>{if(!s.open||!i)return;const D=L=>{if(L.key==="Escape"){L.preventDefault(),n(),l.current&&(l.current=!1,window.history.back());return}if(L.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);L.shiftKey&&document.activeElement===B?(L.preventDefault(),re.focus()):!L.shiftKey&&document.activeElement===re&&(L.preventDefault(),B.focus())};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[n,i,s.open]),!s.open||!m||!g)return null;const $=()=>{n(),i&&l.current&&(l.current=!1,window.history.back())},E=(N=y==null?void 0:y.downloads[0])==null?void 0:N.path,R=m.scope==="public"?g.pdf:E&&g.download?g.download(E):null;return w.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:[w.jsxs("header",{children:[w.jsxs("div",{children:[w.jsx("span",{children:"Posterly artifact"}),w.jsx("h2",{children:m.title})]}),(((A=d.data)==null?void 0:A.length)??0)>1&&w.jsxs("label",{className:"chat-artifact-version",children:["Version",w.jsx("select",{"aria-label":"Poster version",value:m.version_id,onChange:D=>r.setVersion(D.target.value),children:[...d.data??[]].reverse().map(D=>w.jsxs("option",{value:D.version_id,children:["v",D.version]},D.version_id))})]}),w.jsx("button",{type:"button","data-artifact-close":!0,"aria-label":i?"Back to conversation":"Close poster",onClick:$,children:w.jsx(Xl,{})})]}),w.jsxs("nav",{"aria-label":"Poster views",children:[w.jsx("button",{type:"button","aria-pressed":s.tab==="preview",className:s.tab==="preview"?"active":"",onClick:()=>r.setTab("preview"),children:"Preview"}),m.scope==="owner"&&w.jsx("button",{type:"button","aria-pressed":s.tab==="source",className:s.tab==="source"?"active":"",onClick:()=>r.setTab("source"),children:"Source"})]}),w.jsx("div",{className:"chat-artifact-panel-body",children:s.tab==="preview"?w.jsx("img",{src:g.preview,alt:`Full preview of ${m.title}`}):w.jsxs("div",{className:"chat-artifact-source-workspace",children:[(((F=y==null?void 0:y.source_files)==null?void 0:F.length)??0)>1&&w.jsx("nav",{"aria-label":"Poster source files",children:y.source_files.map(D=>w.jsx("button",{type:"button","aria-pressed":v===D,onClick:()=>r.setSourceFile(D),children:D},D))}),w.jsx("pre",{children:w.jsx("code",{children:h.isError?"Source could not be loaded.":h.data??"Loading source…"})})]})}),w.jsxs("footer",{children:[w.jsxs("div",{className:"chat-artifact-metadata",children:[w.jsx("strong",{children:sh(m.gate_status)}),y&&w.jsxs("span",{children:[y.canvas.width," × ",y.canvas.height," ",y.canvas.unit," · ",y.canvas.orientation," · ",y.direction]}),y==null?void 0:y.gate_summary.map(D=>w.jsx("span",{children:D},D))]}),w.jsxs("div",{className:"chat-artifact-actions",children:[w.jsxs("a",{href:g.png,download:!0,children:[w.jsx(go,{})," PNG"]}),m.gate_status!=="failed"&&R&&w.jsxs("a",{href:R,download:!0,children:[w.jsx(go,{})," PDF"]}),m.scope==="owner"&&y&&g.source&&w.jsxs("a",{href:g.source(y.entrypoint),download:!0,children:[w.jsx(oa,{})," HTML"]}),m.scope==="owner"&&y&&g.gate&&w.jsx("a",{href:g.gate(y.gate_report),download:!0,children:"Gate report"}),w.jsxs("a",{href:fT,target:"_blank",rel:"noreferrer",children:[w.jsx(kh,{})," Posterly source · AGPL-3.0"]})]})]})]})},Ql=e=>{var r;const{state:t}=xn();return((r=t.selected)==null?void 0:r.artifact_kind)==="latex_paper"?w.jsx(dT,{block:t.selected,...e}):w.jsx(mT,{...e})},gT=({block:e})=>{const t=xn(),r=t.register,n=t.unregister,s=ra(e);if(K.useEffect(()=>{r(e)},[e,r]),K.useEffect(()=>()=>n(s),[s,n]),e.status==="generating")return w.jsxs("div",{className:"chat-artifact-card chat-artifact-generating",role:"status",children:[w.jsx("span",{className:"chat-artifact-pulse","aria-hidden":"true"}),w.jsxs("span",{children:[w.jsx("strong",{children:e.title}),w.jsx("small",{children:"Publishing Posterly preview…"})]})]});if(e.status==="error")return w.jsxs("div",{className:"chat-artifact-card chat-artifact-error",role:"alert",children:[w.jsx(oa,{"aria-hidden":"true"}),w.jsxs("span",{children:[w.jsx("strong",{children:e.title}),w.jsx("small",{children:e.error_message??"Poster publication failed."})]})]});const o=nh(e);if(!o)return null;const a=t.state.open&&t.state.selectedKey===s;return w.jsxs("button",{type:"button",className:`chat-artifact-card${a?" is-selected":""}`,"aria-pressed":a,onClick:i=>t.open(e,i.currentTarget),children:[w.jsx("img",{src:o.preview,alt:`Preview of ${e.title}`}),w.jsxs("span",{className:"chat-artifact-card-copy",children:[w.jsxs("span",{className:"chat-artifact-kicker",children:[w.jsx(Rh,{"aria-hidden":"true"})," Posterly · v",e.version]}),w.jsx("strong",{children:e.title}),w.jsx("small",{className:`chat-artifact-gate chat-artifact-gate-${e.gate_status}`,children:sh(e.gate_status)})]})]})};function _T(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 yT(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 vT(e,t=240){const r=e.content.trim();return r.length<=t?r:`${r.slice(0,t).trimEnd()}…`}const $T="https://huggingface.co/pro",wT="https://huggingface.co/docs/inference-providers/pricing",bT="https://paperswithcode.co/chat",oh=()=>w.jsx("span",{className:"chat-caret"}),ST=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},ET=e=>{var g,_;const t=e.currentTarget,r=t.ownerDocument,n=(g=r.caretPositionFromPoint)==null?void 0:g.call(r,e.clientX,e.clientY),s=n?null:(_=r.caretRangeFromPoint)==null?void 0:_.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(w.jsxs("span",{className:"chat-inline-paper-mention",children:[w.jsx(Eh,{size:13,"aria-hidden":"true"}),w.jsx(su,{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)),w.jsx(w.Fragment,{children:r})},PT=({block:e,papers:t,citations:r,webCitations:n,onToggle:s})=>e.active?w.jsxs("div",{className:"chat-reason-live",children:[w.jsxs("div",{className:"chat-reason-live-head",children:[w.jsx(na,{})," ",w.jsx("span",{children:"Thinking…"})]}),w.jsxs("div",{className:"chat-reason-live-body chat-answer chat-reason-markdown",children:[w.jsx(_o,{text:e.text,streaming:!0,papers:t,citations:r,webCitations:n}),w.jsx(oh,{})]})]}):w.jsxs("div",{className:"chat-reason-done",children:[w.jsxs("button",{type:"button",className:"chat-reason-done-head",onClick:s,"aria-expanded":e.open,children:[w.jsx(mh,{}),w.jsx("span",{children:"Thought for a few seconds"}),w.jsx(nu,{open:e.open})]}),e.open&&w.jsx("div",{className:"chat-reason-done-body chat-answer chat-reason-markdown",children:w.jsx(_o,{text:e.text,papers:t,citations:r,webCitations:n})})]}),RT=({block:e,papers:t,onToggle:r})=>{var f,m,g,_;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=((f=e.content)==null?void 0:f.map(y=>y.text).join(""))??"",d=s?"streaming arguments…":n?"running…":o?`${e.status} · ${e.took_ms??0} ms`:`${e.hits} results · ${e.took_ms} ms`;return w.jsxs("div",{className:`chat-tool${n?" chat-tool-running":""}${a?" chat-tool-failed":""}`,children:[w.jsxs("button",{type:"button",className:"chat-tool-head",onClick:r,"aria-expanded":e.open,children:[w.jsxs("span",{className:"chat-tool-head-left",children:[n?w.jsx(na,{}):w.jsx(gh,{}),w.jsx("code",{className:"chat-tool-name",children:e.name}),w.jsx("span",{className:"chat-tool-query",children:o?c:`("${i}")`})]}),w.jsxs("span",{className:"chat-tool-head-right",children:[w.jsx("span",{className:"chat-tool-status",children:d}),w.jsx(nu,{open:e.open})]})]}),e.open&&w.jsxs("div",{className:"chat-tool-body",children:[w.jsxs("div",{className:"chat-tool-args",children:[w.jsxs("span",{className:"chat-tool-label",children:["arguments",e.arguments_redacted?" · redacted":""]}),w.jsx("pre",{children:e.argumentState==="streaming"&&!e.arguments_redacted&&e.argumentText||JSON.stringify(e.args,null,2)})]}),!n&&o?w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"chat-tool-output-head",children:[w.jsx("span",{className:"chat-tool-label",children:"result"}),w.jsx("button",{type:"button",className:"chat-tool-copy",onClick:()=>void navigator.clipboard.writeText(l),children:"Copy"})]}),w.jsx("pre",{className:"chat-tool-output",children:w.jsx("code",{children:l})}),((m=e.metadata)==null?void 0:m.output_truncated)&&w.jsx("div",{className:"chat-tool-truncated",children:"Output was truncated."})]}):n?null:w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"chat-tool-label chat-tool-results-label",children:["returned ",((g=e.results)==null?void 0:g.length)??0," papers"]}),w.jsx("ol",{className:"chat-tool-results",children:(_=e.results)==null?void 0:_.map(y=>w.jsxs("li",{className:"chat-hit",children:[w.jsx("div",{className:"chat-hit-top",children:w.jsx(au,{routeId:y.route_id,paper:t[y.route_id],className:"chat-hit-title",children:y.title})}),w.jsx("div",{className:"chat-hit-meta",children:[_T(y.metadata),yT(y.metadata)].filter(Boolean).join(" · ")}),w.jsxs("div",{className:"chat-hit-snippet",children:[vT(y),y.content_truncated&&w.jsx("span",{className:"chat-hit-truncated",children:" (truncated)"})]})]},y.route_id))})]})]})]})},TT=({block:e,papers:t,citations:r,webCitations:n,streaming:s})=>w.jsxs("div",{className:"chat-answer",children:[w.jsx(_o,{text:e.text,streaming:s,papers:t,citations:r,webCitations:n}),s&&!!e.text.trim()&&w.jsx(oh,{})]}),jT=({block:e})=>w.jsx(lT,{block:e}),ah=e=>{const t=K.useRef(null),r=K.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 K.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}},CT=({id:e,text:t,paperSelection:r,editNotice:n,onCancel:s,onResend:o,onResendDraft:a})=>{const[i,c]=K.useState(t),[l,d]=K.useState(r),[f,m]=K.useState(!1),{textareaRef:g,resize:_}=ah(t);K.useLayoutEffect(_,[_,i]);const y=!!i.trim()&&i.length<=8e3,v=()=>{if(!y||f)return;m(!0),((a==null?void 0:a({text:i,paperMentions:[],...l?{paperSelection:l}:{}}))??(o==null?void 0:o(i))??!1)||m(!1)};return w.jsx("div",{className:"chat-msg chat-msg-user chat-msg-user-editing","data-message-id":e,children:w.jsxs("div",{className:"chat-inline-editor",children:[l&&w.jsx(Cs,{selection:l,editable:!0,onRemove:()=>d(void 0)}),w.jsx("textarea",{ref:g,className:"chat-inline-editor-textarea","aria-label":"Edit message",value:i,maxLength:8e3,onChange:h=>c(h.target.value),onKeyDown:h=>{h.key==="Escape"?(h.preventDefault(),s==null||s()):h.key==="Enter"&&!h.shiftKey&&!h.nativeEvent.isComposing&&(h.preventDefault(),v())}}),n&&w.jsx("div",{className:"chat-inline-editor-notice",children:n}),w.jsxs("div",{className:"chat-inline-editor-actions",children:[w.jsx("button",{type:"button",onClick:s,children:"Cancel"}),w.jsx("button",{type:"button",className:"chat-inline-editor-send",disabled:!y||f,onClick:v,children:"Send"})]})]})})},NT=({id:e,text:t,paperMentions:r,paperSelection:n,enabled:s,editNotice:o,onCancel:a,onResend:i,onResendDraft:c})=>{const[l,d]=K.useState({text:t,paperMentions:r,...n?{paperSelection:n}:{}}),[f,m]=K.useState(!1),[g,_]=K.useState(0),{textareaRef:y,resize:v}=ah(t),h=eu({draft:l,onChange:d,enabled:s,textareaRef:y});K.useLayoutEffect(v,[v,l.text]);const $=!!l.text.trim()&&l.text.length<=8e3&&(s||l.paperMentions.length===0),E=()=>{if(!$||f)return;m(!0),((c==null?void 0:c(l))??(i==null?void 0:i(l.text))??!1)||m(!1)};return w.jsx("div",{className:"chat-msg chat-msg-user chat-msg-user-editing","data-message-id":e,children:w.jsxs("div",{className:"chat-inline-editor",children:[l.paperSelection&&w.jsx(Cs,{selection:l.paperSelection,editable:!0,onRemove:()=>d({text:l.text,paperMentions:l.paperMentions})}),w.jsxs("div",{className:"chat-inline-editor-textarea-wrap",children:[w.jsx(tu,{text:l.text,mentions:l.paperMentions,scrollTop:g,variant:"editor"}),w.jsx("textarea",{ref:y,className:"chat-inline-editor-textarea","aria-label":"Edit message",value:l.text,maxLength:8e3,role:"combobox","aria-autocomplete":"list","aria-expanded":h.open,"aria-controls":h.open?h.pickerId:void 0,"aria-activedescendant":h.open&&h.results.length?`${h.optionIdPrefix}-${h.activeIndex}`:void 0,onChange:R=>h.updateText(R.target.value,R.target.selectionStart),onSelect:R=>h.refresh(R.currentTarget.selectionStart),onScroll:R=>_(R.currentTarget.scrollTop),onKeyDown:R=>{h.keyDown(R)||(R.key==="Escape"?(R.preventDefault(),a==null||a()):R.key==="Enter"&&!R.shiftKey&&!R.nativeEvent.isComposing&&(R.preventDefault(),E()))}}),w.jsx(ru,{open:h.open,query:h.query,results:h.results,activeIndex:h.activeIndex,loading:h.loading,error:h.error,onSelect:h.select,id:h.pickerId,optionIdPrefix:h.optionIdPrefix})]}),!s&&l.paperMentions.length>0&&w.jsx("div",{className:"chat-inline-editor-notice",role:"status",children:"Paper mentions are currently disabled. Remove them before sending."}),o&&w.jsx("div",{className:"chat-inline-editor-notice",children:o}),w.jsxs("div",{className:"chat-inline-editor-actions",children:[w.jsx("button",{type:"button",onClick:a,children:"Cancel"}),w.jsx("button",{type:"button",className:"chat-inline-editor-send",disabled:!$||f,onClick:E,children:"Send"})]})]})})},JT=({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:f})=>{const[m,g]=K.useState(!1),_=K.useRef(null);K.useEffect(()=>()=>{_.current!==null&&window.clearTimeout(_.current)},[]);const y=async()=>{var v;if((v=navigator.clipboard)!=null&&v.writeText)try{await navigator.clipboard.writeText(t),g(!0),_.current!==null&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>g(!1),1500)}catch{}};return a?!s&&r.length===0?w.jsx(CT,{id:e,text:t,paperSelection:n,editNotice:i,onCancel:l,onResend:d,onResendDraft:f}):w.jsx(NT,{id:e,text:t,paperMentions:r,paperSelection:n,enabled:s,editNotice:i,onCancel:l,onResend:d,onResendDraft:f}):w.jsx("div",{className:"chat-msg chat-msg-user","data-message-id":e,children:w.jsxs("div",{className:"chat-user-message-wrap",children:[n&&w.jsx(Cs,{selection:n}),w.jsx("div",{className:"chat-bubble",onDoubleClick:ET,children:w.jsx(kT,{text:t,mentions:r})}),w.jsxs("div",{className:"chat-user-actions",children:[w.jsx("button",{type:"button",className:"chat-user-action","aria-label":m?"Message copied":"Copy message",title:m?"Copied":"Copy",onClick:()=>void y(),children:m?w.jsx(lh,{"aria-hidden":"true"}):w.jsx(Ph,{"aria-hidden":"true"})}),o&&w.jsx("button",{type:"button",className:"chat-user-action","aria-label":"Edit message",title:"Edit",onClick:c,children:w.jsx(Th,{"aria-hidden":"true"})})]})]})})},QT=({msg:e,papers:t,onToggleBlock:r,onArchiveOldChats:n,onArchiveOldestChats:s,archivePending:o=null,hfBilling:a=null,openRouterFallbackEnabled:i=!1,feedbackEnabled:c=!1})=>{var A,F,D;const[l,d]=K.useState(null),[f,m]=K.useState(!1),[g,_]=K.useState(!1),[y,v]=K.useState(!1),[h,$]=K.useState(""),E=K.useRef(null),R=`chat-feedback-panel-${e.id}`,k=c&&!e.streaming&&!e.error&&!!((A=e.blocks)!=null&&A.some(L=>L.kind==="answer"&&L.text.trim()));K.useEffect(()=>{var L;y&&((L=E.current)==null||L.focus())},[y]);const N=async(L,Z)=>{if(!f){m(!0),_(!1);try{Z===void 0?await Ec.reportFeedback(e.id,L):await Ec.reportFeedback(e.id,L,Z),d(L),v(!1),$("")}catch{_(!0)}finally{m(!1)}}};return w.jsx("div",{className:"chat-msg chat-msg-assistant",children:w.jsxs("div",{className:"chat-msg-blocks",children:[(F=e.blocks)==null?void 0:F.map((L,Z)=>{var ke;const B=`${e.id}-${Z}`,re="citations"in L&&L.citations!==void 0?L.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 L.kind==="reasoning"?w.jsx(PT,{block:L,papers:t,citations:H,webCitations:ie,onToggle:()=>r(e.id,Z)},B):L.kind==="tool"?w.jsx(RT,{block:L,papers:t,onToggle:()=>r(e.id,Z)},B):L.kind==="app"?w.jsx(jT,{block:L},L.instance_id||B):L.kind==="artifact"?w.jsx(gT,{block:L},L.publication_id||L.version_id||B):w.jsx(TT,{block:L,papers:t,citations:H,webCitations:ie,streaming:!!(e.streaming&&Z===(((ke=e.blocks)==null?void 0:ke.length)??0)-1)},B)}),ST(e)&&w.jsx("div",{className:"chat-waiting",role:"status","aria-live":"polite",children:w.jsx("span",{className:"chat-thinking",children:(((D=e.blocks)==null?void 0:D.length)??0)===0?e.status??"Thinking…":"Thinking…"})}),e.error&&w.jsxs("div",{className:"chat-error",children:[w.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??"")&&w.jsx("a",{href:"/settings",children:"Re-sign in with Hugging Face"}),e.errorCode==="hf_inference_billing_exhausted"&&w.jsxs(w.Fragment,{children:[(a==null?void 0:a.account_type)==="Free"&&!a.bill_to?w.jsx("a",{href:$T,target:"_blank",rel:"noreferrer",children:"Upgrade to Hugging Face PRO — $9/month for 20× more included credits"}):w.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"}),w.jsx("a",{href:wT,target:"_blank",rel:"noreferrer",children:"Inference Providers pricing and billing details"})]}),e.errorCode==="openrouter_monthly_budget_exhausted"&&w.jsxs(w.Fragment,{children:[i?w.jsx("span",{children:"This response started on the shared allowance. Your connected OpenRouter key will be used when you explicitly retry."}):w.jsx("a",{href:"/settings#openrouter-byok",children:"Connect your own OpenRouter key"}),w.jsx("span",{children:"Or select a Hugging Face-backed model and explicitly retry."})]}),e.errorCode==="openrouter_staging_funding_disabled"&&w.jsx("a",{href:bT,children:"Continue on paperswithcode.co"}),e.errorCode==="openrouter_unavailable"&&w.jsxs(w.Fragment,{children:[w.jsx("a",{href:"/settings#openrouter-byok",children:"Bring your own key in Settings"}),w.jsx("a",{href:"https://github.com/huggingface/paperswithcode-feedback",target:"_blank",rel:"noreferrer",children:"File an issue"})]}),e.errorCode==="openrouter_byok_billing_error"&&w.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??"")&&w.jsx("a",{href:"/settings#openrouter-byok",children:"Review OpenRouter settings"}),e.errorCode==="chat_session_quota_exceeded"&&(n||s)&&w.jsxs("span",{className:"chat-error-actions",children:[n&&w.jsx("button",{type:"button",disabled:o!==null,onClick:n,children:o==="old"?"Archiving…":"Archive chats older than 30 days"}),s&&w.jsx("button",{type:"button",disabled:o!==null,onClick:s,children:o==="oldest"?"Archiving…":"Archive oldest 50 chats"})]})]}),!e.streaming&&e.finishReason&&e.finishReason!=="success"&&w.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&&w.jsxs("div",{className:"chat-feedback","aria-label":"Rate this response",children:[w.jsx("span",{className:"chat-feedback-label",children:l===null?"Was this helpful?":"Thanks for your feedback"}),w.jsx("button",{type:"button",className:`chat-feedback-action${l===!0?" chat-feedback-action-selected":""}`,"aria-label":"Helpful response","aria-pressed":l===!0,disabled:f,onClick:()=>{v(!1),N(!0)},children:w.jsx(Ch,{"aria-hidden":"true"})}),w.jsx("button",{type:"button",className:`chat-feedback-action${l===!1?" chat-feedback-action-selected":""}`,"aria-label":"Unhelpful response","aria-pressed":l===!1,"aria-expanded":y,"aria-controls":R,disabled:f,onClick:()=>{_(!1),v(!0)},children:w.jsx(jh,{"aria-hidden":"true"})}),g&&w.jsx("span",{className:"chat-feedback-error",role:"status",children:"Couldn’t send feedback."})]}),k&&y&&w.jsxs("div",{className:"chat-feedback-panel",id:R,role:"group","aria-labelledby":`${R}-title`,children:[w.jsx("div",{className:"chat-feedback-panel-title",id:`${R}-title`,children:"Additional feedback"}),w.jsx("label",{className:"chat-feedback-panel-label",htmlFor:`${R}-comment`,children:"Tell us what went wrong (optional)"}),w.jsx("textarea",{ref:E,id:`${R}-comment`,className:"chat-feedback-comment",value:h,maxLength:500,rows:4,disabled:f,onChange:L=>$(L.target.value),onKeyDown:L=>{L.key==="Escape"&&(L.preventDefault(),v(!1))}}),w.jsxs("div",{className:"chat-feedback-panel-actions",children:[w.jsx("button",{type:"button",className:"chat-feedback-skip",disabled:f,onClick:()=>void N(!1),children:"Skip"}),w.jsx("button",{type:"button",className:"chat-feedback-submit",disabled:f,onClick:()=>void N(!1,h.trim()||void 0),children:f?"Submitting…":"Submit"})]})]})]})})},IT={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 YT=({children:e,variant:t})=>{const r=xn(),n=IT[t],s=K.useRef(null),o=K.useRef(null),a=K.useRef(null),i=K.useRef(null),[c,l]=K.useState(0),d=K.useRef(!1),f=K.useRef(r.state.panelPercent);K.useLayoutEffect(()=>{const h=s.current;if(!h)return;const $=()=>l(h.clientWidth||window.innerWidth);if($(),typeof ResizeObserver>"u")return;const E=new ResizeObserver($);return E.observe(h),()=>E.disconnect()},[]);const m=r.state.open&&c>=n.breakpoint,g=rr(c,r.state.panelPercent,n.left,n.right),_=h=>{var E;const $=rr(c,h,n.left,n.right);f.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($)))},y=h=>{var E;const $=(E=s.current)==null?void 0:E.getBoundingClientRect();$!=null&&$.width&&_(($.right-h)/$.width*100)},v=()=>{d.current&&(d.current=!1,r.setPanelPercent(f.current))};return w.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:[w.jsx("div",{ref:o,className:"chat-artifact-workspace-content",style:m?{width:`${100-g}%`}:void 0,children:e}),m&&w.jsxs(w.Fragment,{children:[w.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:h=>{d.current=!0,h.currentTarget.setPointerCapture(h.pointerId),y(h.clientX)},onPointerMove:h=>{d.current&&y(h.clientX)},onPointerUp:v,onPointerCancel:v,onLostPointerCapture:v,onDoubleClick:()=>r.setPanelPercent(55),onKeyDown:h=>{(h.key==="ArrowLeft"||h.key==="ArrowRight")&&(h.preventDefault(),r.setPanelPercent(rr(c,g+(h.key==="ArrowLeft"?2:-2),n.left,n.right))),h.key==="Home"&&r.setPanelPercent(rr(c,25,n.left,n.right)),h.key==="End"&&r.setPanelPercent(rr(c,75,n.left,n.right))}}),w.jsx("div",{ref:a,className:"chat-artifact-workspace-pane",style:{width:`${g}%`},children:w.jsx(Ql,{})})]}),r.state.open&&!m&&w.jsx(Ql,{forceDialog:!0,readerFallback:t==="reader"})]})};export{BT as A,KT as C,JT as U,YT as a,QT as b,ra as c,xn as u};