diff --git "a/assets/ArtifactWorkspace-hmJwehMU.js" "b/assets/ArtifactWorkspace-hmJwehMU.js" new file mode 100644--- /dev/null +++ "b/assets/ArtifactWorkspace-hmJwehMU.js" @@ -0,0 +1,128 @@ +var Ih=Object.defineProperty;var Oh=(e,t,r)=>t in e?Ih(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var ae=(e,t,r)=>Oh(e,typeof t!="symbol"?t+"":t,r);import{d as br,r as yt,j as $,z as F,N as cu,E as at,X as lu,C as xh}from"./index-BKPk9YrB.js";import{u as uu,P as du,b as fu,M as Ah,R as Mh,W as zh,d as ha,A as Dh,n as qh,L as Uh,N as hu,O as Fh}from"./chatLaunch-CiHkw3Fa.js";import"./katex.min-BSBacQyE.js";import{H as Ms,a as zs,b as Ds}from"./hover-card-C9O4sRgI.js";import{u as mr}from"./useQuery-FZsOIwuk.js";import{f as Lh,p as Vh}from"./github-DR6dIf_B.js";import{G as pa}from"./github-QlDDNDar.js";import{r as Hh,a as Zh,P as pu}from"./PaperPreviewLink-eZ9VECTz.js";import{M as Kh,r as Gh,d as Wh}from"./index-6Rx6F2mq.js";import{c as Ac}from"./chat-D6v-DLzX.js";import{F as Bh}from"./file-text-B4F1u5Jw.js";import{E as Jh}from"./external-link-Nd66OiA4.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 Qh=br("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 Po=br("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 ma=br("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 Yh=br("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 Xh=br("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 ep=br("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 tp=br("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 qs({selection:e,editable:t=!1,onRemove:r}){const n=yt.useId(),s=yt.useRef(null),[o,a]=yt.useState(!1),[i,c]=yt.useState(!1),l=`Selection · Page ${e.page}`;return yt.useEffect(()=>{const d=s.current;!d||o||c(d.scrollHeight>d.clientHeight+1)},[o,e.text]),$.jsxs("div",{className:`chat-paper-selection${t?" is-editable":""}`,children:[$.jsxs("div",{className:"chat-paper-selection-header",children:[$.jsx("span",{className:"chat-paper-selection-label",children:l}),$.jsxs("div",{className:"chat-paper-selection-actions",children:[(i||o)&&$.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&&$.jsx("button",{type:"button",className:"chat-paper-selection-remove","aria-label":"Remove selected paper passage",onClick:r,children:"Remove"})]})]}),$.jsx("blockquote",{id:n,ref:s,className:`chat-paper-selection-quote${o?" is-expanded":""}`,children:e.text})]})}const rp=qh(),nC=({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:_=!0,webSearchAvailable:v=!1,webSearchEnabled:y=!1,onWebSearchChange:g,reasoningEffort:h="low",onReasoningEffortChange:w,paperArtifactsEnabled:E=!1})=>{const[R,T]=yt.useState(rp),C=s??R,x=yt.useRef(null),[U,q]=yt.useState(0),V=X=>{s||T(X),o==null||o(X)},z=uu({draft:C,onChange:V,enabled:m,textareaRef:x});yt.useEffect(()=>{const X=x.current;X&&(X.style.height="auto",X.style.height=`${Math.min(X.scrollHeight,200)}px`)},[C.text]),yt.useEffect(()=>{var X;n&&((X=x.current)==null||X.focus())},[n]);const H=()=>{const X=C.text.length-C.text.trimStart().length,oe=C.text.trim(),We=!!C.paperSelection&&!_;if(!oe||t||d||We)return;const Be=X+oe.length,I={text:oe,paperMentions:C.paperMentions.filter(b=>b.start>=X&&b.end<=Be).map(b=>({...b,start:b.start-X,end:b.end-X})),...C.paperSelection?{paperSelection:C.paperSelection}:{}};e(I)},ne=!!C.paperSelection&&!_,B=!!C.text.trim()&&!ne,ge=E&&C.text==="/";return $.jsxs("div",{className:"chat-composer",children:[C.paperSelection&&$.jsx(qs,{selection:C.paperSelection,editable:!0,onRemove:()=>{var X;V({text:C.text,paperMentions:C.paperMentions}),(X=x.current)==null||X.focus()}}),ne&&$.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."}),$.jsxs("div",{className:"chat-composer-textarea-wrap",children:[$.jsx(du,{text:C.text,mentions:C.paperMentions,scrollTop:U}),$.jsx("textarea",{ref:x,rows:1,value:C.text,placeholder:r||(C.paperSelection?"Ask about this selection…":"Ask anything about research…"),onChange:X=>z.updateText(X.target.value,X.target.selectionStart),onSelect:X=>z.refresh(X.currentTarget.selectionStart),onClick:X=>z.refresh(X.currentTarget.selectionStart),onScroll:X=>q(X.currentTarget.scrollTop),onBlur:X=>{var oe,We;(We=(oe=X.relatedTarget)==null?void 0:oe.closest)!=null&&We.call(oe,".chat-paper-picker, .chat-slash-command")||window.setTimeout(z.close,0)},onKeyDown:X=>{z.keyDown(X)||X.key==="Enter"&&!X.shiftKey&&!X.nativeEvent.isComposing&&(X.preventDefault(),H())},role:"combobox","aria-expanded":z.open||ge,"aria-controls":z.open?z.pickerId:ge?"chat-write-paper-command":void 0,"aria-activedescendant":z.open&&z.results.length?`${z.optionIdPrefix}-${z.activeIndex}`:ge?"chat-write-paper-command":void 0,"aria-autocomplete":"list","aria-describedby":[f,z.message?"chat-paper-mention-message":null].filter(Boolean).join(" ")||void 0}),$.jsx(fu,{open:z.open,query:z.query,results:z.results,activeIndex:z.activeIndex,loading:z.loading,error:z.error,onSelect:z.select,id:z.pickerId,optionIdPrefix:z.optionIdPrefix}),ge&&$.jsxs("button",{type:"button",id:"chat-write-paper-command",className:"chat-slash-command",role:"option",onMouseDown:X=>{var oe;X.preventDefault(),V({...C,text:"/write-paper "}),(oe=x.current)==null||oe.focus()},children:[$.jsx("code",{children:"/write-paper"}),$.jsx("span",{children:"Draft a paper from this research chat"})]})]}),z.message&&$.jsx("div",{id:"chat-paper-mention-message",className:"chat-paper-mention-message",role:"alert",children:z.message}),$.jsxs("div",{className:"chat-composer-row",children:[$.jsxs("div",{className:"chat-composer-tools",children:[i.length>0&&c&&l&&$.jsx(Ah,{models:i,selectedModel:c,onModelChange:l,disabled:t}),w&&$.jsx(Mh,{value:h,onChange:w,disabled:t}),v&&g&&$.jsx(zh,{enabled:y,onChange:g,disabled:t}),$.jsx("span",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]}),$.jsx("button",{type:"button",className:`chat-send${t||B?" chat-send-on":""}`,onClick:t?a:H,disabled:d||(t?!a:!B),"aria-label":t?"Stop generating":"Send message",children:t?a?$.jsx("span",{"aria-hidden":"true",children:"■"}):$.jsx(ha,{light:!0}):$.jsx(Dh,{})})]})]})},ao=new Map,mu=e=>{if(!e)return Promise.resolve();const t=ao.get(e);if(t)return t;const r=new Promise(n=>{const s=new Image;s.onload=()=>{n()},s.onerror=()=>{ao.delete(e),n()},s.src=e});return ao.set(e,r),r},np=new Set(["huggingface.co","www.huggingface.co"]),sp=new Set(["api","blog","chat","collections","docs","enterprise","join","login","models","new","organizations","papers","posts","pricing","search","settings","spaces","tasks"]);function op(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!=="https:"||!np.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"&&sp.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 ap=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,ip=({repo:e})=>{const[t,r]=F.useState(!1);return $.jsxs("div",{className:"hf-preview-card",children:[t?$.jsx("div",{className:"hf-preview-fallback","aria-hidden":"true",children:"🤗"}):$.jsx("img",{className:"hf-preview-image","data-testid":"hf-preview-image",src:e.thumbnailUrl,alt:"",loading:"eager",decoding:"async",onError:()=>r(!0)}),$.jsxs("div",{className:"hf-preview-meta",children:[$.jsxs("span",{className:"hf-preview-kind",children:["Hugging Face ",e.type]}),$.jsx("strong",{children:e.repoId}),$.jsx("span",{children:"huggingface.co"})]})]})},cp=({repo:e,children:t})=>{const[r,n]=F.useState(!1),s=F.useRef(null),o=F.useCallback(()=>{mu(e.thumbnailUrl)},[e.thumbnailUrl]);return F.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]),$.jsxs(Ms,{open:r,onOpenChange:a=>{(!a||!ap())&&n(a)},openDelay:150,closeDelay:100,children:[$.jsx(zs,{asChild:!0,children:$.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})}),$.jsx(Ds,{className:"hf-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:$.jsx(ip,{repo:e})})]})},lp=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,up=({repo:e,preview:t,unavailable:r})=>{const[n,s]=F.useState(!1),o=!!(t!=null&&t.avatarUrl)&&!n;return $.jsxs("div",{className:"github-preview-card",children:[o?$.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)}):$.jsx("div",{className:"github-preview-fallback","aria-hidden":"true",children:$.jsx(pa,{})}),$.jsxs("div",{className:"github-preview-meta",children:[$.jsx("span",{className:"github-preview-kind",children:"GitHub repository"}),$.jsx("strong",{children:e.repoId}),(t==null?void 0:t.description)&&$.jsx("span",{className:"github-preview-description",children:t.description}),t?$.jsxs("span",{className:"github-preview-stats",children:[t.language&&$.jsxs($.Fragment,{children:[t.language," · "]}),"★ ",t.stars.toLocaleString()," · ⑂ ",t.forks.toLocaleString(),t.archived&&$.jsx($.Fragment,{children:" · Archived"})]}):$.jsx("span",{children:r?"Preview unavailable":"Loading preview…"})]})]})},dp=({repo:e,children:t})=>{var l;const[r,n]=F.useState(!1),[s,o]=F.useState(!1),a=F.useRef(null),i=F.useCallback(()=>o(!0),[]),c=mr({queryKey:["github-repository-preview",e.repoId.toLowerCase()],queryFn:({signal:d})=>Lh(e,d),enabled:r||s,staleTime:30*60*1e3,gcTime:60*60*1e3,retry:!1});return F.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]),F.useEffect(()=>{var d;(d=c.data)!=null&&d.avatarUrl&&mu(c.data.avatarUrl)},[(l=c.data)==null?void 0:l.avatarUrl]),$.jsxs(Ms,{open:r,onOpenChange:d=>{(!d||!lp())&&n(d)},openDelay:150,closeDelay:100,children:[$.jsx(zs,{asChild:!0,children:$.jsxs("a",{ref:a,className:"chat-github-link",href:e.url,target:"_blank",rel:"noopener noreferrer",onPointerEnter:i,onFocus:i,children:[$.jsx(pa,{"aria-hidden":"true"}),t]})}),$.jsx(Ds,{className:"github-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:$.jsx(up,{repo:e,preview:c.data,unavailable:c.isError})})]})},fp=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches;function hp(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return"Web source"}}const pp=({citation:e})=>{const[t,r]=F.useState(!1),[n,s]=F.useState(!1),o=e.thumbnail_url,a=e.favicon_url;return $.jsxs("div",{className:"web-preview-card",children:[o&&!t&&$.jsx("img",{className:"web-preview-image","data-testid":"web-preview-image",src:o,alt:"",loading:"eager",decoding:"async",referrerPolicy:"no-referrer",onError:()=>r(!0)}),$.jsxs("div",{className:"web-preview-meta",children:[$.jsxs("div",{className:"web-preview-source",children:[a&&!n&&$.jsx("img",{src:a,alt:"",loading:"eager",decoding:"async",referrerPolicy:"no-referrer",onError:()=>s(!0)}),$.jsx("span",{children:hp(e.url??"")}),e.published&&$.jsxs($.Fragment,{children:[$.jsx("span",{"aria-hidden":"true",children:"·"}),$.jsx("time",{children:e.published.slice(0,10)})]})]}),$.jsx("strong",{children:e.title}),e.excerpt&&$.jsx("p",{children:e.excerpt.replace(/\s+/g," ").trim()})]})]})},mp=({citation:e,children:t})=>{const[r,n]=F.useState(!1),s=e.url??"";return $.jsxs(Ms,{open:r,onOpenChange:o=>{(!o||!fp())&&n(o)},openDelay:150,closeDelay:100,children:[$.jsx(zs,{asChild:!0,children:$.jsx("a",{href:s,className:"chat-web-citation",target:"_blank",rel:"noopener noreferrer",children:t})}),$.jsx(Ds,{className:"web-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:$.jsx(pp,{citation:e})})]})},gp=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,_p=e=>e==="semantic_scholar"?"Semantic Scholar":"External paper",yp=({citation:e})=>{var t,r;return $.jsxs("div",{className:"external-paper-preview-card",children:[$.jsxs("div",{className:"external-paper-preview-source",children:[$.jsx("span",{children:_p(e.provider)}),e.published&&$.jsxs($.Fragment,{children:[$.jsx("span",{"aria-hidden":"true",children:"·"}),$.jsx("time",{children:e.published.slice(0,10)})]})]}),$.jsx("strong",{children:e.title}),(((t=e.authors)==null?void 0:t.length)??0)>0&&$.jsx("p",{className:"external-paper-preview-authors",children:(r=e.authors)==null?void 0:r.join(", ")}),e.excerpt&&$.jsx("p",{children:e.excerpt.replace(/\s+/g," ").trim()}),e.citation_count!==null&&e.citation_count!==void 0&&$.jsxs("span",{className:"external-paper-preview-citations",children:[e.citation_count.toLocaleString()," citations"]})]})},vp=({citation:e,children:t})=>{const[r,n]=F.useState(!1);return $.jsxs(Ms,{open:r,onOpenChange:s=>{(!s||!gp())&&n(s)},openDelay:150,closeDelay:100,children:[$.jsx(zs,{asChild:!0,children:$.jsx("a",{href:e.url??"",className:"chat-external-paper-citation",target:"_blank",rel:"noopener noreferrer",children:t})}),$.jsx(Ds,{className:"external-paper-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:$.jsx(yp,{citation:e})})]})};function $p(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 Dc(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 gu=({routeId:e,paper:t,citation:r,className:n="chat-paper-link",children:s})=>$.jsx(pu,{routeId:e,initialData:bp(e,t,r),className:n,target:"_blank",children:s});function Sp(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 Ep=e=>e.startsWith("paper:")?e:Wh(e);function kp(e){try{const t=new URL(e);return t.protocol==="https:"&&(t.hostname==="github.com"||t.hostname==="www.github.com")}catch{return!1}}const Ro=({text:e,streaming:t,papers:r,citations:n,webCitations:s})=>{const o=wp(t?Sp(e):e);return $.jsx(Kh,{remarkPlugins:[Gh,Zh],rehypePlugins:[Hh],urlTransform:Ep,components:{a:({href:a,children:i})=>{if(a!=null&&a.startsWith("paper:")){const d=a.slice(6);return!r[d]&&!(n!=null&&n[d])?$.jsx("span",{className:"chat-invalid-citation",children:i}):$.jsx(gu,{routeId:d,paper:r[d],citation:n==null?void 0:n[d],children:i})}const c=a?op(a):null;if(c)return $.jsx(cp,{repo:c,children:i});const l=a?Vh(a):null;return l?$.jsx(dp,{repo:l,children:i}):a&&kp(a)?$.jsxs("a",{href:a,className:"chat-github-link",target:"_blank",rel:"noopener noreferrer",children:[$.jsx(pa,{"aria-hidden":"true"}),i]}):a!=null&&a.startsWith("https://")&&(s!=null&&s[a])?s[a].source_type==="paper"?$.jsx(vp,{citation:s[a],children:i}):$.jsx(mp,{citation:s[a],children:i}):a!=null&&a.startsWith("https://")?$.jsx("a",{href:a,className:"chat-external-link",target:"_blank",rel:"noopener noreferrer",children:i}):$.jsx("span",{children:i})}},children:o})},Pp=Object.freeze({status:"aborted"});function A(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 wn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const _u={};function Ut(e){return _u}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 Tp(e,t){return typeof t=="bigint"?t.toString():t}function ga(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function _a(e){return e==null}function ya(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function jp(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 ke(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 Us(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function en(e){return JSON.stringify(e)}const yu=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function gs(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Cp=ga(()=>{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 _s(e){if(gs(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(gs(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}const Np=new Set(["string","number","symbol"]);function Rn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Sr(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 W(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 Op={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 xp(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 Sr(e,{...e._zod.def,shape:r,checks:[]})}function Ap(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 Sr(e,{...e._zod.def,shape:r,checks:[]})}function Mp(e,t){if(!_s(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 Us(this,"shape",n),n},checks:[]};return Sr(e,r)}function zp(e,t){return Sr(e,{...e._zod.def,get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Us(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function Dp(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 Sr(t,{...t._zod.def,shape:s,checks:[]})}function qp(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 Sr(t,{...t._zod.def,shape:s,checks:[]})}function un(e,t=0){var r;for(let n=t;n{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Hn(e){return typeof e=="string"?e:e==null?void 0:e.message}function Ft(e,t,r){var s,o,a,i,c,l;const n={...e,path:e.path??[]};if(!e.message){const d=Hn((a=(o=(s=e.inst)==null?void 0:s._zod.def)==null?void 0:o.error)==null?void 0:a.call(o,e))??Hn((i=t==null?void 0:t.error)==null?void 0:i.call(t,e))??Hn((c=r.customError)==null?void 0:c.call(r,e))??Hn((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 va(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function bn(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const vu=(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,Tp,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},$u=A("$ZodError",vu),wu=A("$ZodError",vu,{Parent:Error});function Up(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 Fp(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 wn;if(a.issues.length){const i=new((s==null?void 0:s.Err)??e)(a.issues.map(c=>Ft(c,o,Ut())));throw yu(i,s==null?void 0:s.callee),i}return a.value},Vp=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=>Ft(c,o,Ut())));throw yu(i,s==null?void 0:s.callee),i}return a.value},bu=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 wn;return o.issues.length?{success:!1,error:new(e??$u)(o.issues.map(a=>Ft(a,s,Ut())))}:{success:!0,data:o.value}},Su=bu(wu),Eu=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=>Ft(a,s,Ut())))}:{success:!0,data:o.value}},Hp=Eu(wu),Zp=/^[cC][^\s-]{8,}$/,Kp=/^[0-9a-z]+$/,Gp=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Wp=/^[0-9a-vA-V]{20}$/,Bp=/^[A-Za-z0-9]{27}$/,Jp=/^[a-zA-Z0-9_-]{21}$/,Qp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Yp=/^([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})$/,qc=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)$/,Xp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,em="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function tm(){return new RegExp(em,"u")}const rm=/^(?:(?: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])$/,nm=/^(([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})$/,sm=/^((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])$/,om=/^(([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])$/,am=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ku=/^[A-Za-z0-9_-]*$/,im=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,cm=/^\+(?:[0-9]){6,14}[0-9]$/,Pu="(?:(?:\\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])))",lm=new RegExp(`^${Pu}$`);function Ru(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 um(e){return new RegExp(`^${Ru(e)}$`)}function dm(e){const t=Ru({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(`^${Pu}T(?:${n})$`)}const fm=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}$`)},hm=/^\d+$/,pm=/^-?\d+(?:\.\d+)?/i,mm=/true|false/i,gm=/null/i,_m=/undefined/i,ym=/^[^A-Z]*$/,vm=/^[^a-z]*$/,et=A("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Tu={number:"number",bigint:"bigint",object:"date"},ju=A("$ZodCheckLessThan",(e,t)=>{et.init(e,t);const r=Tu[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{et.init(e,t);const r=Tu[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})}}),$m=A("$ZodCheckMultipleOf",(e,t)=>{et.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):jp(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})}}),wm=A("$ZodCheckNumberFormat",(e,t)=>{var a;et.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]=Op[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=hm)}),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})}}),bm=A("$ZodCheckMaxLength",(e,t)=>{var r;et.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!_a(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=va(s);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Sm=A("$ZodCheckMinLength",(e,t)=>{var r;et.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!_a(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=va(s);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Em=A("$ZodCheckLengthEquals",(e,t)=>{var r;et.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!_a(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=va(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})}}),Fs=A("$ZodCheckStringFormat",(e,t)=>{var r,n;et.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=()=>{})}),km=A("$ZodCheckRegex",(e,t)=>{Fs.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})}}),Pm=A("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ym),Fs.init(e,t)}),Rm=A("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=vm),Fs.init(e,t)}),Tm=A("$ZodCheckIncludes",(e,t)=>{et.init(e,t);const r=Rn(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})}}),jm=A("$ZodCheckStartsWith",(e,t)=>{et.init(e,t);const r=new RegExp(`^${Rn(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})}}),Cm=A("$ZodCheckEndsWith",(e,t)=>{et.init(e,t);const r=new RegExp(`.*${Rn(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})}}),Nm=A("$ZodCheckOverwrite",(e,t)=>{et.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 Om={major:4,minor:0,patch:0},be=A("$ZodType",(e,t)=>{var s;var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Om;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=un(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,_=f._zod.check(a);if(_ instanceof Promise&&(c==null?void 0:c.async)===!1)throw new wn;if(d||_ instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await _,a.issues.length!==m&&(l||(l=un(a,m)))});else{if(a.issues.length===m)continue;l||(l=un(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 wn;return c.then(l=>o(l,n,i))}return o(c,n,i)}}e["~standard"]={validate:o=>{var a;try{const i=Su(e,o);return i.success?{value:i.data}:{issues:(a=i.error)==null?void 0:a.issues}}catch{return Hp(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}}),$a=A("$ZodString",(e,t)=>{var r;be.init(e,t),e._zod.pattern=[...((r=e==null?void 0:e._zod.bag)==null?void 0:r.patterns)??[]].pop()??fm(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}}),Re=A("$ZodStringFormat",(e,t)=>{Fs.init(e,t),$a.init(e,t)}),xm=A("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Yp),Re.init(e,t)}),Am=A("$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=qc(n))}else t.pattern??(t.pattern=qc());Re.init(e,t)}),Mm=A("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Xp),Re.init(e,t)}),zm=A("$ZodURL",(e,t)=>{Re.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:im.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})}}}),Dm=A("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=tm()),Re.init(e,t)}),qm=A("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Jp),Re.init(e,t)}),Um=A("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Zp),Re.init(e,t)}),Fm=A("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Kp),Re.init(e,t)}),Lm=A("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Gp),Re.init(e,t)}),Vm=A("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Wp),Re.init(e,t)}),Hm=A("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Bp),Re.init(e,t)}),Zm=A("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=dm(t)),Re.init(e,t)}),Km=A("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=lm),Re.init(e,t)}),Gm=A("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=um(t)),Re.init(e,t)}),Wm=A("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Qp),Re.init(e,t)}),Bm=A("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=rm),Re.init(e,t),e._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv4"})}),Jm=A("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=nm),Re.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})}}}),Qm=A("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=sm),Re.init(e,t)}),Ym=A("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=om),Re.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 Nu(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Xm=A("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=am),Re.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),e._zod.check=r=>{Nu(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function eg(e){if(!ku.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Nu(r)}const tg=A("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ku),Re.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),e._zod.check=r=>{eg(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),rg=A("$ZodE164",(e,t)=>{t.pattern??(t.pattern=cm),Re.init(e,t)});function ng(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 sg=A("$ZodJWT",(e,t)=>{Re.init(e,t),e._zod.check=r=>{ng(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Iu=A("$ZodNumber",(e,t)=>{be.init(e,t),e._zod.pattern=e._zod.bag.pattern??pm,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}}),og=A("$ZodNumber",(e,t)=>{wm.init(e,t),Iu.init(e,t)}),ag=A("$ZodBoolean",(e,t)=>{be.init(e,t),e._zod.pattern=mm,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}}),ig=A("$ZodUndefined",(e,t)=>{be.init(e,t),e._zod.pattern=_m,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}}),cg=A("$ZodNull",(e,t)=>{be.init(e,t),e._zod.pattern=gm,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}}),lg=A("$ZodAny",(e,t)=>{be.init(e,t),e._zod.parse=r=>r}),ug=A("$ZodUnknown",(e,t)=>{be.init(e,t),e._zod.parse=r=>r}),dg=A("$ZodNever",(e,t)=>{be.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Uc(e,t,r){e.issues.length&&t.issues.push(...pr(r,e.issues)),t.value[r]=e.value}const fg=A("$ZodArray",(e,t)=>{be.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;aUc(l,r,a))):Uc(c,r,a)}return o.length?Promise.all(o).then(()=>r):r}});function Zn(e,t,r){e.issues.length&&t.issues.push(...pr(r,e.issues)),t.value[r]=e.value}function Fc(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(...pr(r,e.issues)):e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}const hg=A("$ZodObject",(e,t)=>{be.init(e,t);const r=ga(()=>{const f=Object.keys(t.shape);for(const _ of f)if(!(t.shape[_]instanceof be))throw new Error(`Invalid element at key "${_}": 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)}});ke(e._zod,"propValues",()=>{const f=t.shape,m={};for(const _ in f){const v=f[_]._zod;if(v.values){m[_]??(m[_]=new Set);for(const y of v.values)m[_].add(y)}}return m});const n=f=>{const m=new Im(["shape","payload","ctx"]),_=r.value,v=w=>{const E=en(w);return`shape[${E}]._zod.run({ value: input[${E}], issues: [] }, ctx)`};m.write("const input = payload.value;");const y=Object.create(null);let g=0;for(const w of _.keys)y[w]=`key_${g++}`;m.write("const newResult = {}");for(const w of _.keys)if(_.optionalKeys.has(w)){const E=y[w];m.write(`const ${E} = ${v(w)};`);const R=en(w);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[w];m.write(`const ${E} = ${v(w)};`),m.write(` + if (${E}.issues.length) payload.issues = payload.issues.concat(${E}.issues.map(iss => ({ + ...iss, + path: iss.path ? [${en(w)}, ...iss.path] : [${en(w)}] + })));`),m.write(`newResult[${en(w)}] = ${E}.value`)}m.write("payload.value = newResult;"),m.write("return payload;");const h=m.compile();return(w,E)=>h(f,w,E)};let s;const o=gs,a=!_u.jitless,c=a&&Cp.value,l=t.catchall;let d;e._zod.parse=(f,m)=>{d??(d=r.value);const _=f.value;if(!o(_))return f.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),f;const v=[];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 T=E[R],C=T._zod.run({value:_[R],issues:[]},m),x=T._zod.optin==="optional"&&T._zod.optout==="optional";C instanceof Promise?v.push(C.then(U=>x?Fc(U,f,R,_):Zn(U,f,R))):x?Fc(C,f,R,_):Zn(C,f,R)}}if(!l)return v.length?Promise.all(v).then(()=>f):f;const y=[],g=d.keySet,h=l._zod,w=h.def.type;for(const E of Object.keys(_)){if(g.has(E))continue;if(w==="never"){y.push(E);continue}const R=h.run({value:_[E],issues:[]},m);R instanceof Promise?v.push(R.then(T=>Zn(T,f,E))):Zn(R,f,E)}return y.length&&f.issues.push({code:"unrecognized_keys",keys:y,input:_,inst:e}),v.length?Promise.all(v).then(()=>f):f}});function Lc(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=>Ft(o,n,Ut())))}),t}const Ou=A("$ZodUnion",(e,t)=>{be.init(e,t),ke(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),ke(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),ke(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),ke(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=>ya(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=>Lc(a,r,e,n)):Lc(o,r,e,n)}}),pg=A("$ZodDiscriminatedUnion",(e,t)=>{Ou.init(e,t);const r=e._zod.parse;ke(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=ga(()=>{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(!gs(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)}}),mg=A("$ZodIntersection",(e,t)=>{be.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])=>Vc(r,c,l)):Vc(r,o,a)}});function To(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(_s(e)&&_s(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=To(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{be.init(e,t),e._zod.parse=(r,n)=>{const s=r.value;if(!_s(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(...pr(c,d.issues)),r.value[c]=d.value})):(l.issues.length&&r.issues.push(...pr(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=>Ft(l,n,Ut())),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(...pr(a,l.issues)),r.value[i.value]=l.value})):(c.issues.length&&r.issues.push(...pr(a,c.issues)),r.value[i.value]=c.value)}}return o.length?Promise.all(o).then(()=>r):r}}),_g=A("$ZodEnum",(e,t)=>{be.init(e,t);const r=Rp(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(n=>Np.has(typeof n)).map(n=>typeof n=="string"?Rn(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}}),yg=A("$ZodLiteral",(e,t)=>{be.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Rn(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}}),vg=A("$ZodTransform",(e,t)=>{be.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 wn;return r.value=s,r}}),$g=A("$ZodOptional",(e,t)=>{be.init(e,t),e._zod.optin="optional",e._zod.optout="optional",ke(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ke(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${ya(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)}),wg=A("$ZodNullable",(e,t)=>{be.init(e,t),ke(e._zod,"optin",()=>t.innerType._zod.optin),ke(e._zod,"optout",()=>t.innerType._zod.optout),ke(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${ya(r.source)}|null)$`):void 0}),ke(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)}),bg=A("$ZodDefault",(e,t)=>{be.init(e,t),e._zod.optin="optional",ke(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=>Hc(o,t)):Hc(s,t)}});function Hc(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Sg=A("$ZodPrefault",(e,t)=>{be.init(e,t),e._zod.optin="optional",ke(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))}),Eg=A("$ZodNonOptional",(e,t)=>{be.init(e,t),ke(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=>Zc(o,e)):Zc(s,e)}});function Zc(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 kg=A("$ZodCatch",(e,t)=>{be.init(e,t),e._zod.optin="optional",ke(e._zod,"optout",()=>t.innerType._zod.optout),ke(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=>Ft(a,n,Ut()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=t.catchValue({...r,error:{issues:s.issues.map(o=>Ft(o,n,Ut()))},input:r.value}),r.issues=[]),r)}}),Pg=A("$ZodPipe",(e,t)=>{be.init(e,t),ke(e._zod,"values",()=>t.in._zod.values),ke(e._zod,"optin",()=>t.in._zod.optin),ke(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=>Kc(o,t,n)):Kc(s,t,n)}});function Kc(e,t,r){return un(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}const Rg=A("$ZodReadonly",(e,t)=>{be.init(e,t),ke(e._zod,"propValues",()=>t.innerType._zod.propValues),ke(e._zod,"values",()=>t.innerType._zod.values),ke(e._zod,"optin",()=>t.innerType._zod.optin),ke(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(Gc):Gc(s)}});function Gc(e){return e.value=Object.freeze(e.value),e}const Tg=A("$ZodCustom",(e,t)=>{et.init(e,t),be.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=>Wc(o,r,n,e));Wc(s,r,n,e)}});function Wc(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(bn(s))}}class jg{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 Cg(){return new jg}const Kn=Cg();function Ng(e,t){return new e({type:"string",...W(t)})}function Ig(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...W(t)})}function Bc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...W(t)})}function Og(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...W(t)})}function xg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...W(t)})}function Ag(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...W(t)})}function Mg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...W(t)})}function xu(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...W(t)})}function zg(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...W(t)})}function Dg(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...W(t)})}function qg(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...W(t)})}function Ug(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...W(t)})}function Fg(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...W(t)})}function Lg(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...W(t)})}function Vg(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...W(t)})}function Hg(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...W(t)})}function Zg(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...W(t)})}function Kg(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...W(t)})}function Gg(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...W(t)})}function Wg(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...W(t)})}function Bg(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...W(t)})}function Jg(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...W(t)})}function Qg(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...W(t)})}function Yg(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...W(t)})}function Xg(e,t){return new e({type:"string",format:"date",check:"string_format",...W(t)})}function e_(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...W(t)})}function t_(e,t){return new e({type:"string",format:"duration",check:"string_format",...W(t)})}function r_(e,t){return new e({type:"number",checks:[],...W(t)})}function n_(e,t){return new e({type:"number",coerce:!0,checks:[],...W(t)})}function s_(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...W(t)})}function o_(e,t){return new e({type:"boolean",...W(t)})}function a_(e,t){return new e({type:"undefined",...W(t)})}function i_(e,t){return new e({type:"null",...W(t)})}function c_(e){return new e({type:"any"})}function l_(e){return new e({type:"unknown"})}function u_(e,t){return new e({type:"never",...W(t)})}function Jc(e,t){return new ju({check:"less_than",...W(t),value:e,inclusive:!1})}function io(e,t){return new ju({check:"less_than",...W(t),value:e,inclusive:!0})}function Qc(e,t){return new Cu({check:"greater_than",...W(t),value:e,inclusive:!1})}function co(e,t){return new Cu({check:"greater_than",...W(t),value:e,inclusive:!0})}function Yc(e,t){return new $m({check:"multiple_of",...W(t),value:e})}function Au(e,t){return new bm({check:"max_length",...W(t),maximum:e})}function ys(e,t){return new Sm({check:"min_length",...W(t),minimum:e})}function Mu(e,t){return new Em({check:"length_equals",...W(t),length:e})}function d_(e,t){return new km({check:"string_format",format:"regex",...W(t),pattern:e})}function f_(e){return new Pm({check:"string_format",format:"lowercase",...W(e)})}function h_(e){return new Rm({check:"string_format",format:"uppercase",...W(e)})}function p_(e,t){return new Tm({check:"string_format",format:"includes",...W(t),includes:e})}function m_(e,t){return new jm({check:"string_format",format:"starts_with",...W(t),prefix:e})}function g_(e,t){return new Cm({check:"string_format",format:"ends_with",...W(t),suffix:e})}function Tn(e){return new Nm({check:"overwrite",tx:e})}function __(e){return Tn(t=>t.normalize(e))}function y_(){return Tn(e=>e.trim())}function v_(){return Tn(e=>e.toLowerCase())}function $_(){return Tn(e=>e.toUpperCase())}function w_(e,t,r){return new e({type:"array",element:t,...W(r)})}function b_(e,t,r){const n=W(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function S_(e,t,r){return new e({type:"custom",check:"custom",fn:t,...W(r)})}const E_=A("ZodISODateTime",(e,t)=>{Zm.init(e,t),je.init(e,t)});function zu(e){return Yg(E_,e)}const k_=A("ZodISODate",(e,t)=>{Km.init(e,t),je.init(e,t)});function P_(e){return Xg(k_,e)}const R_=A("ZodISOTime",(e,t)=>{Gm.init(e,t),je.init(e,t)});function T_(e){return e_(R_,e)}const j_=A("ZodISODuration",(e,t)=>{Wm.init(e,t),je.init(e,t)});function C_(e){return t_(j_,e)}const N_=(e,t)=>{$u.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Fp(e,r)},flatten:{value:r=>Up(e,r)},addIssue:{value:r=>e.issues.push(r)},addIssues:{value:r=>e.issues.push(...r)},isEmpty:{get(){return e.issues.length===0}}})},Ls=A("ZodError",N_,{Parent:Error}),I_=Lp(Ls),O_=Vp(Ls),x_=bu(Ls),A_=Eu(Ls),Pe=A("ZodType",(e,t)=>(be.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)=>Sr(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)=>x_(e,r,n),e.parseAsync=async(r,n)=>O_(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>A_(e,r,n),e.spa=e.safeParseAsync,e.refine=(r,n)=>e.check(Ry(r,n)),e.superRefine=r=>e.check(Ty(r)),e.overwrite=r=>e.check(Tn(r)),e.optional=()=>Te(e),e.nullable=()=>tl(e),e.nullish=()=>Te(tl(e)),e.nonoptional=r=>vy(e,r),e.array=()=>L(e),e.or=r=>me([e,r]),e.and=r=>Sa(e,r),e.transform=r=>Io(e,Vu(r)),e.default=r=>gy(e,r),e.prefault=r=>yy(e,r),e.catch=r=>wy(e,r),e.pipe=r=>Io(e,r),e.readonly=()=>Ey(e),e.describe=r=>{const n=e.clone();return Kn.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){var r;return(r=Kn.get(e))==null?void 0:r.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return Kn.get(e);const n=e.clone();return Kn.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Du=A("_ZodString",(e,t)=>{$a.init(e,t),Pe.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(d_(...n)),e.includes=(...n)=>e.check(p_(...n)),e.startsWith=(...n)=>e.check(m_(...n)),e.endsWith=(...n)=>e.check(g_(...n)),e.min=(...n)=>e.check(ys(...n)),e.max=(...n)=>e.check(Au(...n)),e.length=(...n)=>e.check(Mu(...n)),e.nonempty=(...n)=>e.check(ys(1,...n)),e.lowercase=n=>e.check(f_(n)),e.uppercase=n=>e.check(h_(n)),e.trim=()=>e.check(y_()),e.normalize=(...n)=>e.check(__(...n)),e.toLowerCase=()=>e.check(v_()),e.toUpperCase=()=>e.check($_())}),M_=A("ZodString",(e,t)=>{$a.init(e,t),Du.init(e,t),e.email=r=>e.check(Ig(z_,r)),e.url=r=>e.check(xu(qu,r)),e.jwt=r=>e.check(Qg(X_,r)),e.emoji=r=>e.check(zg(q_,r)),e.guid=r=>e.check(Bc(Xc,r)),e.uuid=r=>e.check(Og(Gn,r)),e.uuidv4=r=>e.check(xg(Gn,r)),e.uuidv6=r=>e.check(Ag(Gn,r)),e.uuidv7=r=>e.check(Mg(Gn,r)),e.nanoid=r=>e.check(Dg(U_,r)),e.guid=r=>e.check(Bc(Xc,r)),e.cuid=r=>e.check(qg(F_,r)),e.cuid2=r=>e.check(Ug(L_,r)),e.ulid=r=>e.check(Fg(V_,r)),e.base64=r=>e.check(Wg(J_,r)),e.base64url=r=>e.check(Bg(Q_,r)),e.xid=r=>e.check(Lg(H_,r)),e.ksuid=r=>e.check(Vg(Z_,r)),e.ipv4=r=>e.check(Hg(K_,r)),e.ipv6=r=>e.check(Zg(G_,r)),e.cidrv4=r=>e.check(Kg(W_,r)),e.cidrv6=r=>e.check(Gg(B_,r)),e.e164=r=>e.check(Jg(Y_,r)),e.datetime=r=>e.check(zu(r)),e.date=r=>e.check(P_(r)),e.time=r=>e.check(T_(r)),e.duration=r=>e.check(C_(r))});function P(e){return Ng(M_,e)}const je=A("ZodStringFormat",(e,t)=>{Re.init(e,t),Du.init(e,t)}),z_=A("ZodEmail",(e,t)=>{Mm.init(e,t),je.init(e,t)}),Xc=A("ZodGUID",(e,t)=>{xm.init(e,t),je.init(e,t)}),Gn=A("ZodUUID",(e,t)=>{Am.init(e,t),je.init(e,t)}),qu=A("ZodURL",(e,t)=>{zm.init(e,t),je.init(e,t)});function D_(e){return xu(qu,e)}const q_=A("ZodEmoji",(e,t)=>{Dm.init(e,t),je.init(e,t)}),U_=A("ZodNanoID",(e,t)=>{qm.init(e,t),je.init(e,t)}),F_=A("ZodCUID",(e,t)=>{Um.init(e,t),je.init(e,t)}),L_=A("ZodCUID2",(e,t)=>{Fm.init(e,t),je.init(e,t)}),V_=A("ZodULID",(e,t)=>{Lm.init(e,t),je.init(e,t)}),H_=A("ZodXID",(e,t)=>{Vm.init(e,t),je.init(e,t)}),Z_=A("ZodKSUID",(e,t)=>{Hm.init(e,t),je.init(e,t)}),K_=A("ZodIPv4",(e,t)=>{Bm.init(e,t),je.init(e,t)}),G_=A("ZodIPv6",(e,t)=>{Jm.init(e,t),je.init(e,t)}),W_=A("ZodCIDRv4",(e,t)=>{Qm.init(e,t),je.init(e,t)}),B_=A("ZodCIDRv6",(e,t)=>{Ym.init(e,t),je.init(e,t)}),J_=A("ZodBase64",(e,t)=>{Xm.init(e,t),je.init(e,t)}),Q_=A("ZodBase64URL",(e,t)=>{tg.init(e,t),je.init(e,t)}),Y_=A("ZodE164",(e,t)=>{rg.init(e,t),je.init(e,t)}),X_=A("ZodJWT",(e,t)=>{sg.init(e,t),je.init(e,t)}),wa=A("ZodNumber",(e,t)=>{Iu.init(e,t),Pe.init(e,t),e.gt=(n,s)=>e.check(Qc(n,s)),e.gte=(n,s)=>e.check(co(n,s)),e.min=(n,s)=>e.check(co(n,s)),e.lt=(n,s)=>e.check(Jc(n,s)),e.lte=(n,s)=>e.check(io(n,s)),e.max=(n,s)=>e.check(io(n,s)),e.int=n=>e.check(el(n)),e.safe=n=>e.check(el(n)),e.positive=n=>e.check(Qc(0,n)),e.nonnegative=n=>e.check(co(0,n)),e.negative=n=>e.check(Jc(0,n)),e.nonpositive=n=>e.check(io(0,n)),e.multipleOf=(n,s)=>e.check(Yc(n,s)),e.step=(n,s)=>e.check(Yc(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 le(e){return r_(wa,e)}const ey=A("ZodNumberFormat",(e,t)=>{og.init(e,t),wa.init(e,t)});function el(e){return s_(ey,e)}const ty=A("ZodBoolean",(e,t)=>{ag.init(e,t),Pe.init(e,t)});function _e(e){return o_(ty,e)}const ry=A("ZodUndefined",(e,t)=>{ig.init(e,t),Pe.init(e,t)});function jo(e){return a_(ry,e)}const ny=A("ZodNull",(e,t)=>{cg.init(e,t),Pe.init(e,t)});function sy(e){return i_(ny,e)}const oy=A("ZodAny",(e,t)=>{lg.init(e,t),Pe.init(e,t)});function ba(){return c_(oy)}const ay=A("ZodUnknown",(e,t)=>{ug.init(e,t),Pe.init(e,t)});function we(){return l_(ay)}const iy=A("ZodNever",(e,t)=>{dg.init(e,t),Pe.init(e,t)});function Co(e){return u_(iy,e)}const cy=A("ZodArray",(e,t)=>{fg.init(e,t),Pe.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(ys(r,n)),e.nonempty=r=>e.check(ys(1,r)),e.max=(r,n)=>e.check(Au(r,n)),e.length=(r,n)=>e.check(Mu(r,n)),e.unwrap=()=>e.element});function L(e,t){return w_(cy,e,t)}const Uu=A("ZodObject",(e,t)=>{hg.init(e,t),Pe.init(e,t),ke(e,"shape",()=>t.shape),e.keyof=()=>rt(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:we()}),e.loose=()=>e.clone({...e._zod.def,catchall:we()}),e.strict=()=>e.clone({...e._zod.def,catchall:Co()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>Mp(e,r),e.merge=r=>zp(e,r),e.pick=r=>xp(e,r),e.omit=r=>Ap(e,r),e.partial=(...r)=>Dp(Hu,e,r[0]),e.required=(...r)=>qp(Zu,e,r[0])});function O(e,t){const r={type:"object",get shape(){return Us(this,"shape",{...e}),this.shape},...W(t)};return new Uu(r)}function Fe(e,t){return new Uu({type:"object",get shape(){return Us(this,"shape",{...e}),this.shape},catchall:we(),...W(t)})}const Fu=A("ZodUnion",(e,t)=>{Ou.init(e,t),Pe.init(e,t),e.options=t.options});function me(e,t){return new Fu({type:"union",options:e,...W(t)})}const ly=A("ZodDiscriminatedUnion",(e,t)=>{Fu.init(e,t),pg.init(e,t)});function Lu(e,t,r){return new ly({type:"union",options:t,discriminator:e,...W(r)})}const uy=A("ZodIntersection",(e,t)=>{mg.init(e,t),Pe.init(e,t)});function Sa(e,t){return new uy({type:"intersection",left:e,right:t})}const dy=A("ZodRecord",(e,t)=>{gg.init(e,t),Pe.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function ye(e,t,r){return new dy({type:"record",keyType:e,valueType:t,...W(r)})}const No=A("ZodEnum",(e,t)=>{_g.init(e,t),Pe.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 No({...t,checks:[],...W(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 No({...t,checks:[],...W(s),entries:o})}});function rt(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new No({type:"enum",entries:r,...W(t)})}const fy=A("ZodLiteral",(e,t)=>{yg.init(e,t),Pe.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function N(e,t){return new fy({type:"literal",values:Array.isArray(e)?e:[e],...W(t)})}const hy=A("ZodTransform",(e,t)=>{vg.init(e,t),Pe.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=o=>{if(typeof o=="string")r.issues.push(bn(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(bn(a))}};const s=t.transform(r.value,r);return s instanceof Promise?s.then(o=>(r.value=o,r)):(r.value=s,r)}});function Vu(e){return new hy({type:"transform",transform:e})}const Hu=A("ZodOptional",(e,t)=>{$g.init(e,t),Pe.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Te(e){return new Hu({type:"optional",innerType:e})}const py=A("ZodNullable",(e,t)=>{wg.init(e,t),Pe.init(e,t),e.unwrap=()=>e._zod.def.innerType});function tl(e){return new py({type:"nullable",innerType:e})}const my=A("ZodDefault",(e,t)=>{bg.init(e,t),Pe.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function gy(e,t){return new my({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const _y=A("ZodPrefault",(e,t)=>{Sg.init(e,t),Pe.init(e,t),e.unwrap=()=>e._zod.def.innerType});function yy(e,t){return new _y({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const Zu=A("ZodNonOptional",(e,t)=>{Eg.init(e,t),Pe.init(e,t),e.unwrap=()=>e._zod.def.innerType});function vy(e,t){return new Zu({type:"nonoptional",innerType:e,...W(t)})}const $y=A("ZodCatch",(e,t)=>{kg.init(e,t),Pe.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function wy(e,t){return new $y({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const by=A("ZodPipe",(e,t)=>{Pg.init(e,t),Pe.init(e,t),e.in=t.in,e.out=t.out});function Io(e,t){return new by({type:"pipe",in:e,out:t})}const Sy=A("ZodReadonly",(e,t)=>{Rg.init(e,t),Pe.init(e,t)});function Ey(e){return new Sy({type:"readonly",innerType:e})}const Ku=A("ZodCustom",(e,t)=>{Tg.init(e,t),Pe.init(e,t)});function ky(e){const t=new et({check:"custom"});return t._zod.check=e,t}function Py(e,t){return b_(Ku,e??(()=>!0),t)}function Ry(e,t={}){return S_(Ku,e,t)}function Ty(e){const t=ky(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(bn(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(bn(s))}},e(r.value,r)));return t}function Gu(e,t){return Io(Vu(e),t)}const jy={custom:"custom"};function Cy(e){return n_(wa,e)}const Vs="2025-11-25",Ny=[Vs,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],ir="io.modelcontextprotocol/related-task",Hs="2.0",xe=Py(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Wu=me([P(),le().int()]),Bu=P();Fe({ttl:le().optional(),pollInterval:le().optional()});const Iy=O({ttl:le().optional()}),Oy=O({taskId:P()}),Ea=Fe({progressToken:Wu.optional(),[ir]:Oy.optional()}),nt=O({_meta:Ea.optional()}),jn=nt.extend({task:Iy.optional()}),xy=e=>jn.safeParse(e).success,Le=O({method:P(),params:nt.loose().optional()}),it=O({_meta:Ea.optional()}),ct=O({method:P(),params:it.loose().optional()}),Ve=Fe({_meta:Ea.optional()}),Cn=me([P(),le().int()]),Ju=O({jsonrpc:N(Hs),id:Cn,...Le.shape}).strict(),Oo=e=>Ju.safeParse(e).success,Qu=O({jsonrpc:N(Hs),...ct.shape}).strict(),Ay=e=>Qu.safeParse(e).success,ka=O({jsonrpc:N(Hs),id:Cn,result:Ve}).strict(),on=e=>ka.safeParse(e).success;var se;(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"})(se||(se={}));const Pa=O({jsonrpc:N(Hs),id:Cn.optional(),error:O({code:le().int(),message:P(),data:we().optional()})}).strict(),My=e=>Pa.safeParse(e).success,os=me([Ju,Qu,ka,Pa]);me([ka,Pa]);const Ir=Ve.strict(),zy=it.extend({requestId:Cn.optional(),reason:P().optional()}),Ra=ct.extend({method:N("notifications/cancelled"),params:zy}),Dy=O({src:P(),mimeType:P().optional(),sizes:L(P()).optional(),theme:rt(["light","dark"]).optional()}),Nn=O({icons:L(Dy).optional()}),qr=O({name:P(),title:P().optional()}),Zs=qr.extend({...qr.shape,...Nn.shape,version:P(),websiteUrl:P().optional(),description:P().optional()}),qy=Sa(O({applyDefaults:_e().optional()}),ye(P(),we())),Uy=Gu(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Sa(O({form:qy.optional(),url:xe.optional()}),ye(P(),we()).optional())),Fy=Fe({list:xe.optional(),cancel:xe.optional(),requests:Fe({sampling:Fe({createMessage:xe.optional()}).optional(),elicitation:Fe({create:xe.optional()}).optional()}).optional()}),Ly=Fe({list:xe.optional(),cancel:xe.optional(),requests:Fe({tools:Fe({call:xe.optional()}).optional()}).optional()}),Vy=O({experimental:ye(P(),xe).optional(),sampling:O({context:xe.optional(),tools:xe.optional()}).optional(),elicitation:Uy.optional(),roots:O({listChanged:_e().optional()}).optional(),tasks:Fy.optional(),extensions:ye(P(),xe).optional()}),Hy=nt.extend({protocolVersion:P(),capabilities:Vy,clientInfo:Zs}),Zy=Le.extend({method:N("initialize"),params:Hy}),Ky=O({experimental:ye(P(),xe).optional(),logging:xe.optional(),completions:xe.optional(),prompts:O({listChanged:_e().optional()}).optional(),resources:O({subscribe:_e().optional(),listChanged:_e().optional()}).optional(),tools:O({listChanged:_e().optional()}).optional(),tasks:Ly.optional(),extensions:ye(P(),xe).optional()}),Yu=Ve.extend({protocolVersion:P(),capabilities:Ky,serverInfo:Zs,instructions:P().optional()}),Xu=ct.extend({method:N("notifications/initialized"),params:it.optional()}),Gy=e=>Xu.safeParse(e).success,Ks=Le.extend({method:N("ping"),params:nt.optional()}),Wy=O({progress:le(),total:Te(le()),message:Te(P())}),By=O({...it.shape,...Wy.shape,progressToken:Wu}),Ta=ct.extend({method:N("notifications/progress"),params:By}),Jy=nt.extend({cursor:Bu.optional()}),In=Le.extend({params:Jy.optional()}),On=Ve.extend({nextCursor:Bu.optional()}),Qy=rt(["working","input_required","completed","failed","cancelled"]),xn=O({taskId:P(),status:Qy,ttl:me([le(),sy()]),createdAt:P(),lastUpdatedAt:P(),pollInterval:Te(le()),statusMessage:Te(P())}),Sn=Ve.extend({task:xn}),Yy=it.merge(xn),vs=ct.extend({method:N("notifications/tasks/status"),params:Yy}),ja=Le.extend({method:N("tasks/get"),params:nt.extend({taskId:P()})}),Ca=Ve.merge(xn),Na=Le.extend({method:N("tasks/result"),params:nt.extend({taskId:P()})});Ve.loose();const Ia=In.extend({method:N("tasks/list")}),Oa=On.extend({tasks:L(xn)}),xa=Le.extend({method:N("tasks/cancel"),params:nt.extend({taskId:P()})}),Xy=Ve.merge(xn),ed=O({uri:P(),mimeType:Te(P()),_meta:ye(P(),we()).optional()}),td=ed.extend({text:P()}),Aa=P().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),rd=ed.extend({blob:Aa}),An=rt(["user","assistant"]),Zr=O({audience:L(An).optional(),priority:le().min(0).max(1).optional(),lastModified:zu({offset:!0}).optional()}),nd=O({...qr.shape,...Nn.shape,uri:P(),description:Te(P()),mimeType:Te(P()),size:Te(le()),annotations:Zr.optional(),_meta:Te(Fe({}))}),ev=O({...qr.shape,...Nn.shape,uriTemplate:P(),description:Te(P()),mimeType:Te(P()),annotations:Zr.optional(),_meta:Te(Fe({}))}),sd=In.extend({method:N("resources/list")}),Ma=On.extend({resources:L(nd)}),od=In.extend({method:N("resources/templates/list")}),za=On.extend({resourceTemplates:L(ev)}),Da=nt.extend({uri:P()}),tv=Da,ad=Le.extend({method:N("resources/read"),params:tv}),qa=Ve.extend({contents:L(me([td,rd]))}),Ua=ct.extend({method:N("notifications/resources/list_changed"),params:it.optional()}),rv=Da,nv=Le.extend({method:N("resources/subscribe"),params:rv}),sv=Da,ov=Le.extend({method:N("resources/unsubscribe"),params:sv}),av=it.extend({uri:P()}),iv=ct.extend({method:N("notifications/resources/updated"),params:av}),cv=O({name:P(),description:Te(P()),required:Te(_e())}),lv=O({...qr.shape,...Nn.shape,description:Te(P()),arguments:Te(L(cv)),_meta:Te(Fe({}))}),id=In.extend({method:N("prompts/list")}),Fa=On.extend({prompts:L(lv)}),uv=nt.extend({name:P(),arguments:ye(P(),P()).optional()}),dv=Le.extend({method:N("prompts/get"),params:uv}),La=O({type:N("text"),text:P(),annotations:Zr.optional(),_meta:ye(P(),we()).optional()}),Va=O({type:N("image"),data:Aa,mimeType:P(),annotations:Zr.optional(),_meta:ye(P(),we()).optional()}),Ha=O({type:N("audio"),data:Aa,mimeType:P(),annotations:Zr.optional(),_meta:ye(P(),we()).optional()}),fv=O({type:N("tool_use"),name:P(),id:P(),input:ye(P(),we()),_meta:ye(P(),we()).optional()}),cd=O({type:N("resource"),resource:me([td,rd]),annotations:Zr.optional(),_meta:ye(P(),we()).optional()}),ld=nd.extend({type:N("resource_link")}),Mn=me([La,Va,Ha,ld,cd]),hv=O({role:An,content:Mn}),ud=Ve.extend({description:P().optional(),messages:L(hv)}),Za=ct.extend({method:N("notifications/prompts/list_changed"),params:it.optional()}),pv=O({title:P().optional(),readOnlyHint:_e().optional(),destructiveHint:_e().optional(),idempotentHint:_e().optional(),openWorldHint:_e().optional()}),mv=O({taskSupport:rt(["required","optional","forbidden"]).optional()}),Ka=O({...qr.shape,...Nn.shape,description:P().optional(),inputSchema:O({type:N("object"),properties:ye(P(),xe).optional(),required:L(P()).optional()}).catchall(we()),outputSchema:O({type:N("object"),properties:ye(P(),xe).optional(),required:L(P()).optional()}).catchall(we()).optional(),annotations:pv.optional(),execution:mv.optional(),_meta:ye(P(),we()).optional()}),gv=In.extend({method:N("tools/list")}),Ga=On.extend({tools:L(Ka)}),gr=Ve.extend({content:L(Mn).default([]),structuredContent:ye(P(),we()).optional(),isError:_e().optional()});gr.or(Ve.extend({toolResult:we()}));const _v=jn.extend({name:P(),arguments:ye(P(),we()).optional()}),dd=Le.extend({method:N("tools/call"),params:_v}),Wa=ct.extend({method:N("notifications/tools/list_changed"),params:it.optional()}),yv=O({autoRefresh:_e().default(!0),debounceMs:le().int().nonnegative().default(300)}),fd=rt(["debug","info","notice","warning","error","critical","alert","emergency"]),vv=nt.extend({level:fd}),$v=Le.extend({method:N("logging/setLevel"),params:vv}),wv=it.extend({level:fd,logger:P().optional(),data:we()}),hd=ct.extend({method:N("notifications/message"),params:wv}),bv=O({name:P().optional()}),Sv=O({hints:L(bv).optional(),costPriority:le().min(0).max(1).optional(),speedPriority:le().min(0).max(1).optional(),intelligencePriority:le().min(0).max(1).optional()}),Ev=O({mode:rt(["auto","required","none"]).optional()}),kv=O({type:N("tool_result"),toolUseId:P().describe("The unique identifier for the corresponding tool call."),content:L(Mn).default([]),structuredContent:O({}).loose().optional(),isError:_e().optional(),_meta:ye(P(),we()).optional()}),Pv=Lu("type",[La,Va,Ha]),$s=Lu("type",[La,Va,Ha,fv,kv]),Rv=O({role:An,content:me([$s,L($s)]),_meta:ye(P(),we()).optional()}),Tv=jn.extend({messages:L(Rv),modelPreferences:Sv.optional(),systemPrompt:P().optional(),includeContext:rt(["none","thisServer","allServers"]).optional(),temperature:le().optional(),maxTokens:le().int(),stopSequences:L(P()).optional(),metadata:xe.optional(),tools:L(Ka).optional(),toolChoice:Ev.optional()}),Ba=Le.extend({method:N("sampling/createMessage"),params:Tv}),pd=Ve.extend({model:P(),stopReason:Te(rt(["endTurn","stopSequence","maxTokens"]).or(P())),role:An,content:Pv}),md=Ve.extend({model:P(),stopReason:Te(rt(["endTurn","stopSequence","maxTokens","toolUse"]).or(P())),role:An,content:me([$s,L($s)])}),jv=O({type:N("boolean"),title:P().optional(),description:P().optional(),default:_e().optional()}),Cv=O({type:N("string"),title:P().optional(),description:P().optional(),minLength:le().optional(),maxLength:le().optional(),format:rt(["email","uri","date","date-time"]).optional(),default:P().optional()}),Nv=O({type:rt(["number","integer"]),title:P().optional(),description:P().optional(),minimum:le().optional(),maximum:le().optional(),default:le().optional()}),Iv=O({type:N("string"),title:P().optional(),description:P().optional(),enum:L(P()),default:P().optional()}),Ov=O({type:N("string"),title:P().optional(),description:P().optional(),oneOf:L(O({const:P(),title:P()})),default:P().optional()}),xv=O({type:N("string"),title:P().optional(),description:P().optional(),enum:L(P()),enumNames:L(P()).optional(),default:P().optional()}),Av=me([Iv,Ov]),Mv=O({type:N("array"),title:P().optional(),description:P().optional(),minItems:le().optional(),maxItems:le().optional(),items:O({type:N("string"),enum:L(P())}),default:L(P()).optional()}),zv=O({type:N("array"),title:P().optional(),description:P().optional(),minItems:le().optional(),maxItems:le().optional(),items:O({anyOf:L(O({const:P(),title:P()}))}),default:L(P()).optional()}),Dv=me([Mv,zv]),qv=me([xv,Av,Dv]),Uv=me([qv,jv,Cv,Nv]),Fv=jn.extend({mode:N("form").optional(),message:P(),requestedSchema:O({type:N("object"),properties:ye(P(),Uv),required:L(P()).optional()})}),Lv=jn.extend({mode:N("url"),message:P(),elicitationId:P(),url:P().url()}),Vv=me([Fv,Lv]),gd=Le.extend({method:N("elicitation/create"),params:Vv}),Hv=it.extend({elicitationId:P()}),Zv=ct.extend({method:N("notifications/elicitation/complete"),params:Hv}),_d=Ve.extend({action:rt(["accept","decline","cancel"]),content:Gu(e=>e===null?void 0:e,ye(P(),me([P(),le(),_e(),L(P())])).optional())}),Kv=O({type:N("ref/resource"),uri:P()}),Gv=O({type:N("ref/prompt"),name:P()}),Wv=nt.extend({ref:me([Gv,Kv]),argument:O({name:P(),value:P()}),context:O({arguments:ye(P(),P()).optional()}).optional()}),Bv=Le.extend({method:N("completion/complete"),params:Wv}),yd=Ve.extend({completion:Fe({values:L(P()).max(100),total:Te(le().int()),hasMore:Te(_e())})}),Jv=O({uri:P().startsWith("file://"),name:P().optional(),_meta:ye(P(),we()).optional()}),Qv=Le.extend({method:N("roots/list"),params:nt.optional()}),Yv=Ve.extend({roots:L(Jv)}),Xv=ct.extend({method:N("notifications/roots/list_changed"),params:it.optional()});me([Ks,Zy,Bv,$v,dv,id,sd,od,ad,nv,ov,dd,gv,ja,Na,Ia,xa]);me([Ra,Ta,Xu,Xv,vs]);me([Ir,pd,md,_d,Yv,Ca,Oa,Sn]);me([Ks,Ba,gd,Qv,ja,Na,Ia,xa]);me([Ra,Ta,hd,iv,Ua,Wa,Za,vs,Zv]);me([Ir,Yu,yd,ud,Fa,Ma,za,qa,gr,Ga,Ca,Oa,Sn]);class ee 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===se.UrlElicitationRequired&&n){const s=n;if(s.elicitations)return new e$(s.elicitations,r)}return new ee(t,r,n)}}class e$ extends ee{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(se.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){var t;return((t=this.data)==null?void 0:t.elicitations)??[]}}function Ja(e){return!!e._zod}function Ot(e,t){return Ja(e)?Su(e,t):e.safeParse(t)}function vd(e){var r,n;if(!e)return;let t;if(Ja(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 $d(e){var s;if(Ja(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 rr(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function rl(e){const t=vd(e),r=t==null?void 0:t.method;if(!r)throw new Error("Schema is missing a method literal");const n=$d(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function nl(e,t){const r=Ot(e,t);if(!r.success)throw r.error;return r.data}const t$=6e4;class wd{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(Ra,r=>{this._oncancel(r)}),this.setNotificationHandler(Ta,r=>{this._onprogress(r)}),this.setRequestHandler(Ks,r=>({})),this._taskStore=t==null?void 0:t.taskStore,this._taskMessageQueue=t==null?void 0:t.taskMessageQueue,this._taskStore&&(this.setRequestHandler(ja,async(r,n)=>{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new ee(se.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(Na,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,_=new ee(m.error.code,m.error.message,m.error.data);f(_)}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 ee(se.InvalidParams,`Task not found: ${o}`);if(!rr(a.status))return await this._waitForTaskUpdate(o,n.signal),await s();if(rr(a.status)){const c=await this._taskStore.getTaskResult(o,n.sessionId);return this._clearTaskQueue(o),{...c,_meta:{...c._meta,[ir]:{taskId:o}}}}return await s()};return await s()}),this.setRequestHandler(Ia,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 ee(se.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(xa,async(r,n)=>{try{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new ee(se.InvalidParams,`Task not found: ${r.params.taskId}`);if(rr(s.status))throw new ee(se.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 ee(se.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(s){throw s instanceof ee?s:new ee(se.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),ee.fromError(se.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),on(c)||My(c)?this._onresponse(c):Oo(c)?this._onrequest(c,l):Ay(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=ee.fromError(se.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,_;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[ir])==null?void 0:m.taskId;if(n===void 0){const v={jsonrpc:"2.0",id:t.id,error:{code:se.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:v,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(v).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=xy(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:(_=t.params)==null?void 0:_._meta,sendNotification:async v=>{if(a.signal.aborted)return;const y={relatedRequestId:t.id};o&&(y.relatedTask={taskId:o}),await this.notification(v,y)},sendRequest:async(v,y,g)=>{var E;if(a.signal.aborted)throw new ee(se.ConnectionClosed,"Request was cancelled");const h={...g,relatedRequestId:t.id};o&&!h.relatedTask&&(h.relatedTask={taskId:o});const w=((E=h.relatedTask)==null?void 0:E.taskId)??o;return w&&c&&await c.updateTaskStatus(w,"input_required"),await this.request(v,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 v=>{if(a.signal.aborted)return;const y={result:v,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 v=>{if(a.signal.aborted)return;const y={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(v.code)?v.code:se.InternalError,message:v.message??"Internal error",...v.data!==void 0&&{data:v.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(v=>this._onerror(new Error(`Failed to send response: ${v}`))).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),on(t))n(t);else{const a=new ee(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(on(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),on(t))s(t);else{const a=ee.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 ee?c:new ee(se.InternalError,String(c))}}return}let o;try{const c=await this.request(t,Sn,n);if(c.task)o=c.task.taskId,yield{type:"taskCreated",task:c.task};else throw new ee(se.InternalError,"Task creation did not return a task");for(;;){const l=await this.getTask({taskId:o},n);if(yield{type:"taskStatus",task:l},rr(l.status)){l.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)}:l.status==="failed"?yield{type:"error",error:new ee(se.InternalError,`Task ${o} failed`)}:l.status==="cancelled"&&(yield{type:"error",error:new ee(se.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 ee?c:new ee(se.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 w,E,R,T,C;const f=x=>{d(x)};if(!this._transport){f(new Error("Not connected"));return}if(((w=this._options)==null?void 0:w.enforceStrictCapabilities)===!0)try{this.assertCapabilityForMethod(t.method),i&&this.assertTaskCapability(t.method)}catch(x){f(x);return}(E=n==null?void 0:n.signal)==null||E.throwIfAborted();const m=this._requestMessageId++,_={...t,jsonrpc:"2.0",id:m};n!=null&&n.onprogress&&(this._progressHandlers.set(m,n.onprogress),_.params={...t.params,_meta:{...((R=t.params)==null?void 0:R._meta)||{},progressToken:m}}),i&&(_.params={..._.params,task:i}),c&&(_.params={..._.params,_meta:{...((T=_.params)==null?void 0:T._meta)||{},[ir]:c}});const v=x=>{var q;this._responseHandlers.delete(m),this._progressHandlers.delete(m),this._cleanupTimeout(m),(q=this._transport)==null||q.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:m,reason:String(x)}},{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a}).catch(V=>this._onerror(new Error(`Failed to send cancellation: ${V}`)));const U=x instanceof ee?x:new ee(se.RequestTimeout,String(x));d(U)};this._responseHandlers.set(m,x=>{var U;if(!((U=n==null?void 0:n.signal)!=null&&U.aborted)){if(x instanceof Error)return d(x);try{const q=Ot(r,x.result);q.success?l(q.data):d(q.error)}catch(q){d(q)}}}),(C=n==null?void 0:n.signal)==null||C.addEventListener("abort",()=>{var x;v((x=n==null?void 0:n.signal)==null?void 0:x.reason)});const y=(n==null?void 0:n.timeout)??t$,g=()=>v(ee.fromError(se.RequestTimeout,"Request timed out",{timeout:y}));this._setupTimeout(m,y,n==null?void 0:n.maxTotalTimeout,g,(n==null?void 0:n.resetTimeoutOnProgress)??!1);const h=c==null?void 0:c.taskId;if(h){const x=U=>{const q=this._responseHandlers.get(m);q?q(U):this._onerror(new Error(`Response handler missing for side-channeled request ${m}`))};this._requestResolvers.set(m,x),this._enqueueTaskMessage(h,{type:"request",message:_,timestamp:Date.now()}).catch(U=>{this._cleanupTimeout(m),d(U)})}else this._transport.send(_,{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a}).catch(x=>{this._cleanupTimeout(m),d(x)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},Ca,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},Oa,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},Xy,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)||{},[ir]: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,_;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)||{},[ir]:r.relatedTask}}}),(_=this._transport)==null||_.send(f,r).catch(v=>this._onerror(v))});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)||{},[ir]:r.relatedTask}}}),await this._transport.send(a,r)}setRequestHandler(t,r){const n=rl(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,o)=>{const a=nl(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=rl(t);this._notificationHandlers.set(n,s=>{const o=nl(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"&&Oo(s.message)){const o=s.message.id,a=this._requestResolvers.get(o);a?(a(new ee(se.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 ee(se.InvalidRequest,"Request cancelled"));return}const c=setTimeout(a,n);r.addEventListener("abort",()=>{clearTimeout(c),i(new ee(se.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 ee(se.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=vs.parse({method:"notifications/tasks/status",params:i});await this.notification(c),rr(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 ee(se.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(rr(i.status))throw new ee(se.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=vs.parse({method:"notifications/tasks/status",params:c});await this.notification(l),rr(c.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>n.listTasks(s,r)}}}function sl(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function r$(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];sl(a)&&sl(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 n$ extends wd{constructor(){super(...arguments);ae(this,"_registeredMethods",new Set);ae(this,"_eventSlots",new Map);ae(this,"setRequestHandler",(r,n)=>{this._assertMethodNotRegistered(r,"setRequestHandler"),super.setRequestHandler(r,n)});ae(this,"setNotificationHandler",(r,n)=>{this._assertMethodNotRegistered(r,"setNotificationHandler"),super.setNotificationHandler(r,n)});ae(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 bd="2026-01-26",s$="ui/notifications/tool-input-partial",o$=me([N("light"),N("dark")]).describe("Color theme preference for the host environment."),En=me([N("inline"),N("fullscreen"),N("pip")]).describe("Display mode for UI presentation."),a$=me([N("--color-background-primary"),N("--color-background-secondary"),N("--color-background-tertiary"),N("--color-background-inverse"),N("--color-background-ghost"),N("--color-background-info"),N("--color-background-danger"),N("--color-background-success"),N("--color-background-warning"),N("--color-background-disabled"),N("--color-text-primary"),N("--color-text-secondary"),N("--color-text-tertiary"),N("--color-text-inverse"),N("--color-text-ghost"),N("--color-text-info"),N("--color-text-danger"),N("--color-text-success"),N("--color-text-warning"),N("--color-text-disabled"),N("--color-border-primary"),N("--color-border-secondary"),N("--color-border-tertiary"),N("--color-border-inverse"),N("--color-border-ghost"),N("--color-border-info"),N("--color-border-danger"),N("--color-border-success"),N("--color-border-warning"),N("--color-border-disabled"),N("--color-ring-primary"),N("--color-ring-secondary"),N("--color-ring-inverse"),N("--color-ring-info"),N("--color-ring-danger"),N("--color-ring-success"),N("--color-ring-warning"),N("--font-sans"),N("--font-mono"),N("--font-weight-normal"),N("--font-weight-medium"),N("--font-weight-semibold"),N("--font-weight-bold"),N("--font-text-xs-size"),N("--font-text-sm-size"),N("--font-text-md-size"),N("--font-text-lg-size"),N("--font-heading-xs-size"),N("--font-heading-sm-size"),N("--font-heading-md-size"),N("--font-heading-lg-size"),N("--font-heading-xl-size"),N("--font-heading-2xl-size"),N("--font-heading-3xl-size"),N("--font-text-xs-line-height"),N("--font-text-sm-line-height"),N("--font-text-md-line-height"),N("--font-text-lg-line-height"),N("--font-heading-xs-line-height"),N("--font-heading-sm-line-height"),N("--font-heading-md-line-height"),N("--font-heading-lg-line-height"),N("--font-heading-xl-line-height"),N("--font-heading-2xl-line-height"),N("--font-heading-3xl-line-height"),N("--border-radius-xs"),N("--border-radius-sm"),N("--border-radius-md"),N("--border-radius-lg"),N("--border-radius-xl"),N("--border-radius-full"),N("--border-width-regular"),N("--shadow-hairline"),N("--shadow-sm"),N("--shadow-md"),N("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),i$=ye(a$.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.`),me([P(),jo()]).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.`),c$=O({method:N("ui/open-link"),params:O({url:P().describe("URL to open in the host's browser")})});O({isError:_e().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough();O({isError:_e().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough();O({isError:_e().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();var l$=O({method:N("ui/notifications/sandbox-proxy-ready"),params:O({})}),Qa=O({connectDomains:L(P()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket). + +- Maps to CSP \`connect-src\` directive +- Empty or omitted → no network connections (secure default)`),resourceDomains:L(P()).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:L(P()).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:L(P()).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'`)")}),Ya=O({camera:O({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:O({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:O({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:O({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),u$=O({method:N("ui/notifications/size-changed"),params:O({width:le().optional().describe("New width in pixels."),height:le().optional().describe("New height in pixels.")})});O({method:N("ui/notifications/tool-input"),params:O({arguments:ye(P(),we().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})});O({method:N("ui/notifications/tool-input-partial"),params:O({arguments:ye(P(),we().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})});O({method:N("ui/notifications/tool-cancelled"),params:O({reason:P().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})});var d$=O({fonts:P().optional()}),f$=O({variables:i$.optional().describe("CSS variables for theming the app."),css:d$.optional().describe("CSS blocks that apps can inject.")});O({method:N("ui/resource-teardown"),params:O({})});var h$=ye(P(),we()),ol=O({text:O({}).optional().describe("Host supports text content blocks."),image:O({}).optional().describe("Host supports image content blocks."),audio:O({}).optional().describe("Host supports audio content blocks."),resource:O({}).optional().describe("Host supports resource content blocks."),resourceLink:O({}).optional().describe("Host supports resource link content blocks."),structuredContent:O({}).optional().describe("Host supports structured content.")}),p$=O({method:N("ui/notifications/request-teardown"),params:O({}).optional()}),m$=O({experimental:ye(P(),ye(P(),ba()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:O({}).optional().describe("Host supports opening external URLs."),downloadFile:O({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:O({listChanged:_e().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:O({listChanged:_e().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:O({}).optional().describe("Host accepts log messages."),sandbox:O({permissions:Ya.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:Qa.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:ol.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:ol.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:O({tools:O({}).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.")}),g$=O({experimental:ye(P(),ye(P(),ba()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:O({listChanged:_e().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:L(En).optional().describe("Display modes the app supports.")}),_$=O({method:N("ui/notifications/initialized"),params:O({}).optional()});O({csp:Qa.optional().describe("Content Security Policy configuration for UI resources."),permissions:Ya.optional().describe("Sandbox permissions requested by the UI resource."),domain:P().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:_e().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 al=O({method:N("ui/request-display-mode"),params:O({mode:En.describe("The display mode being requested.")})});O({mode:En.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough();var y$=me([N("model"),N("app")]).describe("Tool visibility scope - who can access the tool.");O({resourceUri:P().optional(),visibility:L(y$).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:Co().optional(),permissions:Co().optional()});O({mimeTypes:L(P()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});var v$=O({method:N("ui/download-file"),params:O({contents:L(me([cd,ld])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),$$=O({method:N("ui/message"),params:O({role:N("user").describe('Message role, currently only "user" is supported.'),content:L(Mn).describe("Message content blocks (text, image, etc.).")})});O({method:N("ui/notifications/sandbox-resource-ready"),params:O({html:P().describe("HTML content to load into the inner iframe."),sandbox:P().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Qa.optional().describe("CSP configuration from resource metadata."),permissions:Ya.optional().describe("Sandbox permissions from resource metadata.")})});O({method:N("ui/notifications/tool-result"),params:gr.describe("Standard MCP tool execution result.")});var Sd=O({toolInfo:O({id:Cn.optional().describe("JSON-RPC id of the tools/call request."),tool:Ka.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:o$.optional().describe("Current color theme preference."),styles:f$.optional().describe("Style configuration for theming the app."),displayMode:En.optional().describe("How the UI is currently displayed."),availableDisplayModes:L(En).optional().describe("Display modes the host supports."),containerDimensions:me([O({height:le().describe("Fixed container height in pixels.")}),O({maxHeight:me([le(),jo()]).optional().describe("Maximum container height in pixels.")})]).and(me([O({width:le().describe("Fixed container width in pixels.")}),O({maxWidth:me([le(),jo()]).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:P().optional().describe("User's language and region preference in BCP 47 format."),timeZone:P().optional().describe("User's timezone in IANA format."),userAgent:P().optional().describe("Host application identifier."),platform:me([N("web"),N("desktop"),N("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:O({touch:_e().optional().describe("Whether the device supports touch input."),hover:_e().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:O({top:le().describe("Top safe area inset in pixels."),right:le().describe("Right safe area inset in pixels."),bottom:le().describe("Bottom safe area inset in pixels."),left:le().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough();O({method:N("ui/notifications/host-context-changed"),params:Sd.describe("Partial context update containing only changed fields.")});var w$=O({method:N("ui/update-model-context"),params:O({content:L(Mn).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:ye(P(),we().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),b$=O({method:N("ui/initialize"),params:O({appInfo:Zs.describe("App identification (name and version)."),appCapabilities:g$.describe("Features and capabilities this app provides."),protocolVersion:P().describe("Protocol version this app supports.")})});O({protocolVersion:P().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Zs.describe("Host application identification and version."),hostCapabilities:m$.describe("Features and capabilities provided by the host."),hostContext:Sd.describe("Rich context about the host environment.")}).passthrough();class S${constructor(t=window.parent,r){ae(this,"eventTarget");ae(this,"eventSource");ae(this,"messageListener");ae(this,"onclose");ae(this,"onerror");ae(this,"onmessage");ae(this,"sessionId");ae(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=os.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!==s$&&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 E$=[bd];class k$ extends n${constructor(r,n,s,o){super(o);ae(this,"_client");ae(this,"_hostInfo");ae(this,"_capabilities");ae(this,"_appCapabilities");ae(this,"_hostContext",{});ae(this,"_appInfo");ae(this,"_initializedReceived",!1);ae(this,"_baseReplaceRequestHandler",this.replaceRequestHandler);ae(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)))});ae(this,"eventSchemas",{sizechange:u$,sandboxready:l$,initialized:_$,requestteardown:p$,loggingmessage:hd});ae(this,"onping");ae(this,"_onmessage");ae(this,"_onopenlink");ae(this,"_ondownloadfile");ae(this,"_onrequestdisplaymode");ae(this,"_onupdatemodelcontext");ae(this,"_oncalltool");ae(this,"_onlistresources");ae(this,"_onlistresourcetemplates");ae(this,"_onreadresource");ae(this,"_onlistprompts");ae(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(b$,a=>this._oninitialize(a)),this.setRequestHandler(Ks,(a,i)=>{var c;return(c=this.onping)==null||c.call(this,a.params,i),{}}),this.replaceRequestHandler(al,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($$,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(c$,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(v$,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(al,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(w$,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(dd,async(n,s)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,s)})}set oncreatesamplingmessage(r){this.setRequestHandler(Ba,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(sd,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(od,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(ad,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(id,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:E$.includes(n)?n:bd,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];P$(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},h$,n)}callTool(r,n){return this.request({method:"tools/call",params:r},gr,n)}listTools(r,n){return this.request({method:"tools/list",params:r},Ga,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},gr,{signal:o.signal}),n.tools.listChanged&&this._client.setNotificationHandler(Wa,s=>this.sendToolListChanged(s.params))),n.resources&&(this.onlistresources=async(s,o)=>this._client.request({method:"resources/list",params:s},Ma,{signal:o.signal}),this.onlistresourcetemplates=async(s,o)=>this._client.request({method:"resources/templates/list",params:s},za,{signal:o.signal}),this.onreadresource=async(s,o)=>this._client.request({method:"resources/read",params:s},qa,{signal:o.signal}),n.resources.listChanged&&this._client.setNotificationHandler(Ua,s=>this.sendResourceListChanged(s.params))),n.prompts&&(this.onlistprompts=async(s,o)=>this._client.request({method:"prompts/list",params:s},Fa,{signal:o.signal}),n.prompts.listChanged&&this._client.setNotificationHandler(Za,s=>this.sendPromptListChanged(s.params)))}return super.connect(r)}}function P$(e,t){return JSON.stringify(e)===JSON.stringify(t)}const R$={x:0,y:0,width:1024,height:768},xo=28,T$=12,j$=.9;function xt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function Ed(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return e}function Ao(e){if(Array.isArray(e))return e.map(Ao);const t=Ed(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,` +`):Ao(n)])):e}function C$(e){return e.type==="text"&&typeof(e.text??e.originalText)=="string"}function kd(e){const t=String(e.text??e.originalText??""),r=xt(e.fontSize)??20,n=t.length*r*j$,s=xt(e.width);return Math.max(s&&s>0?s:0,n)}function N$(e){for(const t of e){if(t.type!=="cameraUpdate")continue;const r=xt(t.width),n=xt(t.height);if(!(!r||r<=0||!n||n<=0))return{x:xt(t.x)??0,y:xt(t.y)??0,width:r,height:n}}return R$}function I$(e,t){const r=xt(e.x);if(r===void 0)return!1;const n=kd(e),s=t.x+xo,o=t.x+t.width-xo;return ro+1}function O$(e,t){const r={...e},n=xt(r.fontSize)??20;let s=kd(r);const o=Math.max(1,t.width-xo*2);if(s>o){const a=o/s;r.fontSize=Math.max(T$,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 x$(e){const r=Ao(e).map(Ed);if(r.some(o=>o===void 0))return e;const n=r,s=N$(n);return n.map(o=>!C$(o)||!I$(o,s)?o:O$(o,s))}var Mo={exports:{}},Pd={},gt={},Ur={},zn={},he={},kn={};(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(w){if(super(),!e.IDENTIFIER.test(w))throw new Error("CodeGen: name must be a valid identifier");this.str=w}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=r;class n extends t{constructor(w){super(),this._items=typeof w=="string"?[w]:w}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const w=this._items[0];return w===""||w==='""'}get str(){var w;return(w=this._str)!==null&&w!==void 0?w:this._str=this._items.reduce((E,R)=>`${E}${R}`,"")}get names(){var w;return(w=this._names)!==null&&w!==void 0?w: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,...w){const E=[h[0]];let R=0;for(;R{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 _=t.nil;for(const v in l){const y=l[v];if(!y)continue;const g=f[v]=f[v]||new Map;y.forEach(h=>{if(g.has(h))return;g.set(h,n.Started);let w=d(h);if(w){const E=this.opts.es5?e.varKinds.var:e.varKinds.const;_=(0,t._)`${_}${E} ${h} = ${w};${this.opts._n}`}else if(w=m==null?void 0:m(h))_=(0,t._)`${_}${w}${this.opts._n}`;else throw new r(h);g.set(h,n.Completed)})}return _}}e.ValueScope=i})(zo);(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=kn,r=zo;var n=kn;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=zo;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,k){super(),this.varKind=u,this.name=p,this.rhs=k}render({es5:u,_n:p}){const k=u?r.varKinds.var:this.varKind,M=this.rhs===void 0?"":` = ${this.rhs}`;return`${k} ${this.name}${M};`+p}optimizeNames(u,p){if(u[this.name.str])return this.rhs&&(this.rhs=B(this.rhs,u,p)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class i extends o{constructor(u,p,k){super(),this.lhs=u,this.rhs=p,this.sideEffects=k}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=B(this.rhs,u,p),this}get names(){const u=this.lhs instanceof t.Name?{}:{...this.lhs.names};return ne(u,this.rhs)}}class c extends i{constructor(u,p,k,M){super(u,k,M),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=B(this.code,u,p),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}}class _ extends o{constructor(u=[]){super(),this.nodes=u}render(u){return this.nodes.reduce((p,k)=>p+k.render(u),"")}optimizeNodes(){const{nodes:u}=this;let p=u.length;for(;p--;){const k=u[p].optimizeNodes();Array.isArray(k)?u.splice(p,1,...k):k?u[p]=k:u.splice(p,1)}return u.length>0?this:void 0}optimizeNames(u,p){const{nodes:k}=this;let M=k.length;for(;M--;){const D=k[M];D.optimizeNames(u,p)||(ge(u,D.names),k.splice(M,1))}return k.length>0?this:void 0}get names(){return this.nodes.reduce((u,p)=>H(u,p.names),{})}}class v extends _{render(u){return"{"+u._n+super.render(u)+"}"+u._n}}class y extends _{}class g extends v{}g.kind="else";class h extends v{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 k=p.optimizeNodes();p=this.else=Array.isArray(k)?new g(k):k}if(p)return u===!1?p instanceof h?p:p.nodes:this.nodes.length?this:new h(X(u),p instanceof h?[p]:p.nodes);if(!(u===!1||!this.nodes.length))return this}optimizeNames(u,p){var k;if(this.else=(k=this.else)===null||k===void 0?void 0:k.optimizeNames(u,p),!!(super.optimizeNames(u,p)||this.else))return this.condition=B(this.condition,u,p),this}get names(){const u=super.names;return ne(u,this.condition),this.else&&H(u,this.else.names),u}}h.kind="if";class w extends v{}w.kind="for";class E extends w{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=B(this.iteration,u,p),this}get names(){return H(super.names,this.iteration.names)}}class R extends w{constructor(u,p,k,M){super(),this.varKind=u,this.name=p,this.from=k,this.to=M}render(u){const p=u.es5?r.varKinds.var:this.varKind,{name:k,from:M,to:D}=this;return`for(${p} ${k}=${M}; ${k}<${D}; ${k}++)`+super.render(u)}get names(){const u=ne(super.names,this.from);return ne(u,this.to)}}class T extends w{constructor(u,p,k,M){super(),this.loop=u,this.varKind=p,this.name=k,this.iterable=M}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=B(this.iterable,u,p),this}get names(){return H(super.names,this.iterable.names)}}class C extends v{constructor(u,p,k){super(),this.name=u,this.args=p,this.async=k}render(u){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(u)}}C.kind="func";class x extends _{render(u){return"return "+super.render(u)}}x.kind="return";class U extends v{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 k,M;return super.optimizeNames(u,p),(k=this.catch)===null||k===void 0||k.optimizeNames(u,p),(M=this.finally)===null||M===void 0||M.optimizeNames(u,p),this}get names(){const u=super.names;return this.catch&&H(u,this.catch.names),this.finally&&H(u,this.finally.names),u}}class q extends v{constructor(u){super(),this.error=u}render(u){return`catch(${this.error})`+super.render(u)}}q.kind="catch";class V extends v{render(u){return"finally"+super.render(u)}}V.kind="finally";class z{constructor(u,p={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...p,_n:p.lines?` +`:""},this._extScope=u,this._scope=new r.Scope({parent:u}),this._nodes=[new 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 k=this._extScope.value(u,p);return(this._values[k.prefix]||(this._values[k.prefix]=new Set)).add(k),k}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,k,M){const D=this._scope.toName(p);return k!==void 0&&M&&(this._constants[D.str]=k),this._leafNode(new a(u,D,k)),D}const(u,p,k){return this._def(r.varKinds.const,u,p,k)}let(u,p,k){return this._def(r.varKinds.let,u,p,k)}var(u,p,k){return this._def(r.varKinds.var,u,p,k)}assign(u,p,k){return this._leafNode(new i(u,p,k))}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[k,M]of u)p.length>1&&p.push(","),p.push(k),(k!==M||this.opts.es5)&&(p.push(":"),(0,t.addCodeArg)(p,M));return p.push("}"),new t._Code(p)}if(u,p,k){if(this._blockNode(new h(u)),p&&k)this.code(p).else().code(k).endIf();else if(p)this.code(p).endIf();else if(k)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(u){return this._elseNode(new h(u))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(h,g)}_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,k,M,D=this.opts.es5?r.varKinds.var:r.varKinds.let){const J=this._scope.toName(u);return this._for(new R(D,J,p,k),()=>M(J))}forOf(u,p,k,M=r.varKinds.const){const D=this._scope.toName(u);if(this.opts.es5){const J=p instanceof t.Name?p:this.var("_arr",p);return this.forRange("_i",0,(0,t._)`${J}.length`,G=>{this.var(D,(0,t._)`${J}[${G}]`),k(D)})}return this._for(new T("of",M,D,p),()=>k(D))}forIn(u,p,k,M=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(u,(0,t._)`Object.keys(${p})`,k);const D=this._scope.toName(u);return this._for(new T("in",M,D,p),()=>k(D))}endFor(){return this._endBlockNode(w)}label(u){return this._leafNode(new l(u))}break(u){return this._leafNode(new d(u))}return(u){const p=new x;if(this._blockNode(p),this.code(u),p.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(x)}try(u,p,k){if(!p&&!k)throw new Error('CodeGen: "try" without "catch" and "finally"');const M=new U;if(this._blockNode(M),this.code(u),p){const D=this.name("e");this._currNode=M.catch=new q(D),p(D)}return k&&(this._currNode=M.finally=new V,this.code(k)),this._endBlockNode(q,V)}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 k=this._nodes.length-p;if(k<0||u!==void 0&&k!==u)throw new Error(`CodeGen: wrong number of nodes: ${k} vs ${u} expected`);return this._nodes.length=p,this}func(u,p=t.nil,k,M){return this._blockNode(new C(u,p,k)),M&&this.code(M).endFunc(),this}endFunc(){return this._endBlockNode(C)}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 k=this._currNode;if(k instanceof u||p&&k 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 H(S,u){for(const p in u)S[p]=(S[p]||0)+(u[p]||0);return S}function ne(S,u){return u instanceof t._CodeOrName?H(S,u.names):S}function B(S,u,p){if(S instanceof t.Name)return k(S);if(!M(S))return S;return new t._Code(S._items.reduce((D,J)=>(J instanceof t.Name&&(J=k(J)),J instanceof t._Code?D.push(...J._items):D.push(J),D),[]));function k(D){const J=p[D.str];return J===void 0||u[D.str]!==1?D:(delete u[D.str],J)}function M(D){return D instanceof t._Code&&D._items.some(J=>J instanceof t.Name&&u[J.str]===1&&p[J.str]!==void 0)}}function ge(S,u){for(const p in u)S[p]=(S[p]||0)-(u[p]||0)}function X(S){return typeof S=="boolean"||typeof S=="number"||S===null?!S:(0,t._)`!${j(S)}`}e.not=X;const oe=b(e.operators.AND);function We(...S){return S.reduce(oe)}e.and=We;const Be=b(e.operators.OR);function I(...S){return S.reduce(Be)}e.or=I;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 Z={};Object.defineProperty(Z,"__esModule",{value:!0});Z.checkStrictMode=Z.getErrorPath=Z.Type=Z.useFunc=Z.setEvaluated=Z.evaluatedPropsToName=Z.mergeEvaluated=Z.eachItem=Z.unescapeJsonPointer=Z.escapeJsonPointer=Z.escapeFragment=Z.unescapeFragment=Z.schemaRefOrVal=Z.schemaHasRulesButRef=Z.schemaHasRules=Z.checkUnknownRules=Z.alwaysValidSchema=Z.toHash=void 0;const ve=he,A$=kn;function M$(e){const t={};for(const r of e)t[r]=!0;return t}Z.toHash=M$;function z$(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(Rd(e,t),!Td(t,e.self.RULES.all))}Z.alwaysValidSchema=z$;function Rd(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]||Nd(e,`unknown keyword: "${o}"`)}Z.checkUnknownRules=Rd;function Td(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(t[r])return!0;return!1}Z.schemaHasRules=Td;function D$(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}Z.schemaHasRulesButRef=D$;function q$({topSchemaRef:e,schemaPath:t},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,ve._)`${r}`}return(0,ve._)`${e}${t}${(0,ve.getProperty)(n)}`}Z.schemaRefOrVal=q$;function U$(e){return jd(decodeURIComponent(e))}Z.unescapeFragment=U$;function F$(e){return encodeURIComponent(Xa(e))}Z.escapeFragment=F$;function Xa(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}Z.escapeJsonPointer=Xa;function jd(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}Z.unescapeJsonPointer=jd;function L$(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)}Z.eachItem=L$;function il({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(s,o,a,i)=>{const c=a===void 0?o:a instanceof ve.Name?(o instanceof ve.Name?e(s,o,a):t(s,o,a),a):o instanceof ve.Name?(t(s,a,o),o):r(o,a);return i===ve.Name&&!(c instanceof ve.Name)?n(s,c):c}}Z.mergeEvaluated={props:il({mergeNames:(e,t,r)=>e.if((0,ve._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,ve._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,ve._)`${r} || {}`).code((0,ve._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,ve._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,ve._)`${r} || {}`),ei(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Cd}),items:il({mergeNames:(e,t,r)=>e.if((0,ve._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,ve._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,ve._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,ve._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Cd(e,t){if(t===!0)return e.var("props",!0);const r=e.var("props",(0,ve._)`{}`);return t!==void 0&&ei(e,r,t),r}Z.evaluatedPropsToName=Cd;function ei(e,t,r){Object.keys(r).forEach(n=>e.assign((0,ve._)`${t}${(0,ve.getProperty)(n)}`,!0))}Z.setEvaluated=ei;const cl={};function V$(e,t){return e.scopeValue("func",{ref:t,code:cl[t.code]||(cl[t.code]=new A$._Code(t.code))})}Z.useFunc=V$;var Do;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Do||(Z.Type=Do={}));function H$(e,t,r){if(e instanceof ve.Name){const n=t===Do.Num;return r?n?(0,ve._)`"[" + ${e} + "]"`:(0,ve._)`"['" + ${e} + "']"`:n?(0,ve._)`"/" + ${e}`:(0,ve._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,ve.getProperty)(e).toString():"/"+Xa(e)}Z.getErrorPath=H$;function Nd(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}Z.checkStrictMode=Nd;var St={};Object.defineProperty(St,"__esModule",{value:!0});const He=he,Z$={data:new He.Name("data"),valCxt:new He.Name("valCxt"),instancePath:new He.Name("instancePath"),parentData:new He.Name("parentData"),parentDataProperty:new He.Name("parentDataProperty"),rootData:new He.Name("rootData"),dynamicAnchors:new He.Name("dynamicAnchors"),vErrors:new He.Name("vErrors"),errors:new He.Name("errors"),this:new He.Name("this"),self:new He.Name("self"),scope:new He.Name("scope"),json:new He.Name("json"),jsonPos:new He.Name("jsonPos"),jsonLen:new He.Name("jsonLen"),jsonPart:new He.Name("jsonPart")};St.default=Z$;(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=Z,n=St;e.keywordError={message:({keyword:g})=>(0,t.str)`must pass "${g}" keyword validation`},e.keyword$DataError={message:({keyword:g,schemaType:h})=>h?(0,t.str)`"${g}" keyword must be ${h} ($data)`:(0,t.str)`"${g}" keyword is invalid ($data)`};function s(g,h=e.keywordError,w,E){const{it:R}=g,{gen:T,compositeRule:C,allErrors:x}=R,U=f(g,h,w);E??(C||x)?c(T,U):l(R,(0,t._)`[${U}]`)}e.reportError=s;function o(g,h=e.keywordError,w){const{it:E}=g,{gen:R,compositeRule:T,allErrors:C}=E,x=f(g,h,w);c(R,x),T||C||l(E,n.default.vErrors)}e.reportExtraError=o;function a(g,h){g.assign(n.default.errors,h),g.if((0,t._)`${n.default.vErrors} !== null`,()=>g.if(h,()=>g.assign((0,t._)`${n.default.vErrors}.length`,h),()=>g.assign(n.default.vErrors,null)))}e.resetErrorsCount=a;function i({gen:g,keyword:h,schemaValue:w,data:E,errsCount:R,it:T}){if(R===void 0)throw new Error("ajv implementation error");const C=g.name("err");g.forRange("i",R,n.default.errors,x=>{g.const(C,(0,t._)`${n.default.vErrors}[${x}]`),g.if((0,t._)`${C}.instancePath === undefined`,()=>g.assign((0,t._)`${C}.instancePath`,(0,t.strConcat)(n.default.instancePath,T.errorPath))),g.assign((0,t._)`${C}.schemaPath`,(0,t.str)`${T.errSchemaPath}/${h}`),T.opts.verbose&&(g.assign((0,t._)`${C}.schema`,w),g.assign((0,t._)`${C}.data`,E))})}e.extendErrors=i;function c(g,h){const w=g.const("err",h);g.if((0,t._)`${n.default.vErrors} === null`,()=>g.assign(n.default.vErrors,(0,t._)`[${w}]`),(0,t._)`${n.default.vErrors}.push(${w})`),g.code((0,t._)`${n.default.errors}++`)}function l(g,h){const{gen:w,validateName:E,schemaEnv:R}=g;R.$async?w.throw((0,t._)`new ${g.ValidationError}(${h})`):(w.assign((0,t._)`${E}.errors`,h),w.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(g,h,w){const{createErrors:E}=g.it;return E===!1?(0,t._)`{}`:m(g,h,w)}function m(g,h,w={}){const{gen:E,it:R}=g,T=[_(R,w),v(g,w)];return y(g,h,T),E.object(...T)}function _({errorPath:g},{instancePath:h}){const w=h?(0,t.str)`${g}${(0,r.getErrorPath)(h,r.Type.Str)}`:g;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,w)]}function v({keyword:g,it:{errSchemaPath:h}},{schemaPath:w,parentSchema:E}){let R=E?h:(0,t.str)`${h}/${g}`;return w&&(R=(0,t.str)`${R}${(0,r.getErrorPath)(w,r.Type.Str)}`),[d.schemaPath,R]}function y(g,{params:h,message:w},E){const{keyword:R,data:T,schemaValue:C,it:x}=g,{opts:U,propertyName:q,topSchemaRef:V,schemaPath:z}=x;E.push([d.keyword,R],[d.params,typeof h=="function"?h(g):h||(0,t._)`{}`]),U.messages&&E.push([d.message,typeof w=="function"?w(g):w]),U.verbose&&E.push([d.schema,C],[d.parentSchema,(0,t._)`${V}${z}`],[n.default.data,T]),q&&E.push([d.propertyName,q])}})(zn);Object.defineProperty(Ur,"__esModule",{value:!0});Ur.boolOrEmptySchema=Ur.topBoolOrEmptySchema=void 0;const K$=zn,G$=he,W$=St,B$={message:"boolean schema is false"};function J$(e){const{gen:t,schema:r,validateName:n}=e;r===!1?Id(e,!1):typeof r=="object"&&r.$async===!0?t.return(W$.default.data):(t.assign((0,G$._)`${n}.errors`,null),t.return(!0))}Ur.topBoolOrEmptySchema=J$;function Q$(e,t){const{gen:r,schema:n}=e;n===!1?(r.var(t,!1),Id(e)):r.var(t,!0)}Ur.boolOrEmptySchema=Q$;function Id(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,K$.reportError)(s,B$,void 0,t)}var Ie={},_r={};Object.defineProperty(_r,"__esModule",{value:!0});_r.getRules=_r.isJSONType=void 0;const Y$=["string","number","integer","boolean","null","object","array"],X$=new Set(Y$);function ew(e){return typeof e=="string"&&X$.has(e)}_r.isJSONType=ew;function tw(){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:{}}}_r.getRules=tw;var kt={};Object.defineProperty(kt,"__esModule",{value:!0});kt.shouldUseRule=kt.shouldUseGroup=kt.schemaHasRulesForType=void 0;function rw({schema:e,self:t},r){const n=t.RULES.types[r];return n&&n!==!0&&Od(e,n)}kt.schemaHasRulesForType=rw;function Od(e,t){return t.rules.some(r=>xd(e,r))}kt.shouldUseGroup=Od;function xd(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))}kt.shouldUseRule=xd;Object.defineProperty(Ie,"__esModule",{value:!0});Ie.reportTypeError=Ie.checkDataTypes=Ie.checkDataType=Ie.coerceAndCheckDataType=Ie.getJSONTypes=Ie.getSchemaTypes=Ie.DataType=void 0;const nw=_r,sw=kt,ow=zn,ie=he,Ad=Z;var Ar;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Ar||(Ie.DataType=Ar={}));function aw(e){const t=Md(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}Ie.getSchemaTypes=aw;function Md(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(nw.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Ie.getJSONTypes=Md;function iw(e,t){const{gen:r,data:n,opts:s}=e,o=cw(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0,sw.schemaHasRulesForType)(e,t[0]));if(a){const i=ti(t,n,s.strictNumbers,Ar.Wrong);r.if(i,()=>{o.length?lw(e,t,o):ri(e)})}return a}Ie.coerceAndCheckDataType=iw;const zd=new Set(["string","number","integer","boolean","null"]);function cw(e,t){return t?e.filter(r=>zd.has(r)||t==="array"&&r==="array"):[]}function lw(e,t,r){const{gen:n,data:s,opts:o}=e,a=n.let("dataType",(0,ie._)`typeof ${s}`),i=n.let("coerced",(0,ie._)`undefined`);o.coerceTypes==="array"&&n.if((0,ie._)`${a} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,ie._)`${s}[0]`).assign(a,(0,ie._)`typeof ${s}`).if(ti(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0,ie._)`${i} !== undefined`);for(const l of r)(zd.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),ri(e),n.endIf(),n.if((0,ie._)`${i} !== undefined`,()=>{n.assign(s,i),uw(e,i)});function c(l){switch(l){case"string":n.elseIf((0,ie._)`${a} == "number" || ${a} == "boolean"`).assign(i,(0,ie._)`"" + ${s}`).elseIf((0,ie._)`${s} === null`).assign(i,(0,ie._)`""`);return;case"number":n.elseIf((0,ie._)`${a} == "boolean" || ${s} === null + || (${a} == "string" && ${s} && ${s} == +${s})`).assign(i,(0,ie._)`+${s}`);return;case"integer":n.elseIf((0,ie._)`${a} === "boolean" || ${s} === null + || (${a} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(i,(0,ie._)`+${s}`);return;case"boolean":n.elseIf((0,ie._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(i,!1).elseIf((0,ie._)`${s} === "true" || ${s} === 1`).assign(i,!0);return;case"null":n.elseIf((0,ie._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(i,null);return;case"array":n.elseIf((0,ie._)`${a} === "string" || ${a} === "number" + || ${a} === "boolean" || ${s} === null`).assign(i,(0,ie._)`[${s}]`)}}}function uw({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,ie._)`${t} !== undefined`,()=>e.assign((0,ie._)`${t}[${r}]`,n))}function qo(e,t,r,n=Ar.Correct){const s=n===Ar.Correct?ie.operators.EQ:ie.operators.NEQ;let o;switch(e){case"null":return(0,ie._)`${t} ${s} null`;case"array":o=(0,ie._)`Array.isArray(${t})`;break;case"object":o=(0,ie._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=a((0,ie._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=a();break;default:return(0,ie._)`typeof ${t} ${s} ${e}`}return n===Ar.Correct?o:(0,ie.not)(o);function a(i=ie.nil){return(0,ie.and)((0,ie._)`typeof ${t} == "number"`,i,r?(0,ie._)`isFinite(${t})`:ie.nil)}}Ie.checkDataType=qo;function ti(e,t,r,n){if(e.length===1)return qo(e[0],t,r,n);let s;const o=(0,Ad.toHash)(e);if(o.array&&o.object){const a=(0,ie._)`typeof ${t} != "object"`;s=o.null?a:(0,ie._)`!${t} || ${a}`,delete o.null,delete o.array,delete o.object}else s=ie.nil;o.number&&delete o.integer;for(const a in o)s=(0,ie.and)(s,qo(a,t,r,n));return s}Ie.checkDataTypes=ti;const dw={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,ie._)`{type: ${e}}`:(0,ie._)`{type: ${t}}`};function ri(e){const t=fw(e);(0,ow.reportError)(t,dw)}Ie.reportTypeError=ri;function fw(e){const{gen:t,data:r,schema:n}=e,s=(0,Ad.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}var Gs={};Object.defineProperty(Gs,"__esModule",{value:!0});Gs.assignDefaults=void 0;const Er=he,hw=Z;function pw(e,t){const{properties:r,items:n}=e.schema;if(t==="object"&&r)for(const s in r)ll(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>ll(e,o,s.default))}Gs.assignDefaults=pw;function ll(e,t,r){const{gen:n,compositeRule:s,data:o,opts:a}=e;if(r===void 0)return;const i=(0,Er._)`${o}${(0,Er.getProperty)(t)}`;if(s){(0,hw.checkStrictMode)(e,`default is ignored for: ${i}`);return}let c=(0,Er._)`${i} === undefined`;a.useDefaults==="empty"&&(c=(0,Er._)`${c} || ${i} === null || ${i} === ""`),n.if(c,(0,Er._)`${i} = ${(0,Er.stringify)(r)}`)}var wt={},de={};Object.defineProperty(de,"__esModule",{value:!0});de.validateUnion=de.validateArray=de.usePattern=de.callValidateCode=de.schemaProperties=de.allSchemaProperties=de.noPropertyInData=de.propertyInData=de.isOwnProperty=de.hasPropFunc=de.reportMissingProp=de.checkMissingProp=de.checkReportMissingProp=void 0;const Se=he,ni=Z,jt=St,mw=Z;function gw(e,t){const{gen:r,data:n,it:s}=e;r.if(oi(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Se._)`${t}`},!0),e.error()})}de.checkReportMissingProp=gw;function _w({gen:e,data:t,it:{opts:r}},n,s){return(0,Se.or)(...n.map(o=>(0,Se.and)(oi(e,t,o,r.ownProperties),(0,Se._)`${s} = ${o}`)))}de.checkMissingProp=_w;function yw(e,t){e.setParams({missingProperty:t},!0),e.error()}de.reportMissingProp=yw;function Dd(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Se._)`Object.prototype.hasOwnProperty`})}de.hasPropFunc=Dd;function si(e,t,r){return(0,Se._)`${Dd(e)}.call(${t}, ${r})`}de.isOwnProperty=si;function vw(e,t,r,n){const s=(0,Se._)`${t}${(0,Se.getProperty)(r)} !== undefined`;return n?(0,Se._)`${s} && ${si(e,t,r)}`:s}de.propertyInData=vw;function oi(e,t,r,n){const s=(0,Se._)`${t}${(0,Se.getProperty)(r)} === undefined`;return n?(0,Se.or)(s,(0,Se.not)(si(e,t,r))):s}de.noPropertyInData=oi;function qd(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}de.allSchemaProperties=qd;function $w(e,t){return qd(t).filter(r=>!(0,ni.alwaysValidSchema)(e,t[r]))}de.schemaProperties=$w;function ww({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:a},i,c,l){const d=l?(0,Se._)`${e}, ${t}, ${n}${s}`:t,f=[[jt.default.instancePath,(0,Se.strConcat)(jt.default.instancePath,o)],[jt.default.parentData,a.parentData],[jt.default.parentDataProperty,a.parentDataProperty],[jt.default.rootData,jt.default.rootData]];a.opts.dynamicRef&&f.push([jt.default.dynamicAnchors,jt.default.dynamicAnchors]);const m=(0,Se._)`${d}, ${r.object(...f)}`;return c!==Se.nil?(0,Se._)`${i}.call(${c}, ${m})`:(0,Se._)`${i}(${m})`}de.callValidateCode=ww;const bw=(0,Se._)`new RegExp`;function Sw({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,Se._)`${s.code==="new RegExp"?bw:(0,mw.useFunc)(e,s)}(${r}, ${n})`})}de.usePattern=Sw;function Ew(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,Se._)`${r}.length`);t.forRange("i",0,c,l=>{e.subschema({keyword:n,dataProp:l,dataPropType:ni.Type.Num},o),t.if((0,Se.not)(o),i)})}}de.validateArray=Ew;function kw(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,ni.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,Se._)`${a} || ${i}`),e.mergeValidEvaluated(d,i)||t.if((0,Se.not)(a))})),e.result(a,()=>e.reset(),()=>e.error(!0))}de.validateUnion=kw;Object.defineProperty(wt,"__esModule",{value:!0});wt.validateKeywordUsage=wt.validSchemaType=wt.funcKeywordCode=wt.macroKeywordCode=void 0;const Ke=he,cr=St,Pw=de,Rw=zn;function Tw(e,t){const{gen:r,keyword:n,schema:s,parentSchema:o,it:a}=e,i=t.macro.call(a.self,s,o,a),c=Ud(r,n,i);a.opts.validateSchema!==!1&&a.self.validateSchema(i,!0);const l=r.name("valid");e.subschema({schema:i,schemaPath:Ke.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},l),e.pass(l,()=>e.error(!0))}wt.macroKeywordCode=Tw;function jw(e,t){var r;const{gen:n,keyword:s,schema:o,parentSchema:a,$data:i,it:c}=e;Nw(c,t);const l=!i&&t.compile?t.compile.call(c.self,o,a,c):t.validate,d=Ud(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&&ul(e),g(()=>e.error());else{const h=t.async?_():v();t.modifying&&ul(e),g(()=>Cw(e,h))}}function _(){const h=n.let("ruleErrs",null);return n.try(()=>y((0,Ke._)`await `),w=>n.assign(f,!1).if((0,Ke._)`${w} instanceof ${c.ValidationError}`,()=>n.assign(h,(0,Ke._)`${w}.errors`),()=>n.throw(w))),h}function v(){const h=(0,Ke._)`${d}.errors`;return n.assign(h,null),y(Ke.nil),h}function y(h=t.async?(0,Ke._)`await `:Ke.nil){const w=c.opts.passContext?cr.default.this:cr.default.self,E=!("compile"in t&&!i||t.schema===!1);n.assign(f,(0,Ke._)`${h}${(0,Pw.callValidateCode)(e,d,w,E)}`,t.modifying)}function g(h){var w;n.if((0,Ke.not)((w=t.valid)!==null&&w!==void 0?w:f),h)}}wt.funcKeywordCode=jw;function ul(e){const{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Ke._)`${n.parentData}[${n.parentDataProperty}]`))}function Cw(e,t){const{gen:r}=e;r.if((0,Ke._)`Array.isArray(${t})`,()=>{r.assign(cr.default.vErrors,(0,Ke._)`${cr.default.vErrors} === null ? ${t} : ${cr.default.vErrors}.concat(${t})`).assign(cr.default.errors,(0,Ke._)`${cr.default.vErrors}.length`),(0,Rw.extendErrors)(e)},()=>e.error())}function Nw({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function Ud(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,Ke.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")}wt.validSchemaType=Iw;function Ow({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)}}wt.validateKeywordUsage=Ow;var Dt={};Object.defineProperty(Dt,"__esModule",{value:!0});Dt.extendSubschemaMode=Dt.extendSubschemaData=Dt.getSubschema=void 0;const vt=he,Fd=Z;function xw(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,vt._)`${e.schemaPath}${(0,vt.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:i[r],schemaPath:(0,vt._)`${e.schemaPath}${(0,vt.getProperty)(t)}${(0,vt.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,Fd.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')}Dt.getSubschema=xw;function Aw(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,vt._)`${t.data}${(0,vt.getProperty)(r)}`,!0);c(m),e.errorPath=(0,vt.str)`${l}${(0,Fd.getErrorPath)(r,n,f.jsPropertySyntax)}`,e.parentDataProperty=(0,vt._)`${r}`,e.dataPathArr=[...d,e.parentDataProperty]}if(s!==void 0){const l=s instanceof vt.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]}}Dt.extendSubschemaData=Aw;function Mw(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}Dt.extendSubschemaMode=Mw;var qe={},Ws=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},Ld={exports:{}},At=Ld.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(){};as(t,n,s,e,"",e)};At.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};At.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};At.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};At.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 as(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 At.arrayKeywords)for(var m=0;mt+=Vd(n)),t===1/0))return 1/0}return t}function Hd(e,t="",r){r!==!1&&(t=Mr(t));const n=e.parse(t);return Zd(e,n)}qe.getFullPath=Hd;function Zd(e,t){return e.serialize(t).split("#")[0]+"#"}qe._getFullPath=Zd;const Zw=/#\/?$/;function Mr(e){return e?e.replace(Zw,""):""}qe.normalizeId=Mr;function Kw(e,t,r){return r=Mr(r),e.resolve(t,r)}qe.resolveUrl=Kw;const Gw=/^[a-z_][-a-z0-9._]*$/i;function Ww(e,t){if(typeof e=="boolean")return{};const{schemaId:r,uriResolver:n}=this.opts,s=Mr(e[r]||t),o={"":s},a=Hd(n,s,!1),i={},c=new Set;return Fw(e,{allKeys:!0},(f,m,_,v)=>{if(v===void 0)return;const y=a+m;let g=o[v];typeof f[r]=="string"&&(g=h.call(this,f[r])),w.call(this,f.$anchor),w.call(this,f.$dynamicAnchor),o[m]=g;function h(E){const R=this.opts.uriResolver.resolve;if(E=Mr(g?R(g,E):E),c.has(E))throw d(E);c.add(E);let T=this.refs[E];return typeof T=="string"&&(T=this.refs[T]),typeof T=="object"?l(f,T.schema,E):E!==Mr(y)&&(E[0]==="#"?(l(f,i[E],E),i[E]=f):this.refs[E]=y),E}function w(E){if(typeof E=="string"){if(!Gw.test(E))throw new Error(`invalid anchor "${E}"`);h.call(this,`#${E}`)}}}),i;function l(f,m,_){if(m!==void 0&&!Uw(f,m))throw d(_)}function d(f){return new Error(`reference "${f}" resolves to more than one schema`)}}qe.getSchemaRefs=Ww;Object.defineProperty(gt,"__esModule",{value:!0});gt.getData=gt.KeywordCxt=gt.validateFunctionCode=void 0;const Kd=Ur,dl=Ie,ai=kt,ws=Ie,Bw=Gs,dn=wt,lo=Dt,Q=he,te=St,Jw=qe,Pt=Z,tn=zn;function Qw(e){if(Bd(e)&&(Jd(e),Wd(e))){e0(e);return}Gd(e,()=>(0,Kd.topBoolOrEmptySchema)(e))}gt.validateFunctionCode=Qw;function Gd({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},o){s.code.es5?e.func(t,(0,Q._)`${te.default.data}, ${te.default.valCxt}`,n.$async,()=>{e.code((0,Q._)`"use strict"; ${fl(r,s)}`),Xw(e,s),e.code(o)}):e.func(t,(0,Q._)`${te.default.data}, ${Yw(s)}`,n.$async,()=>e.code(fl(r,s)).code(o))}function Yw(e){return(0,Q._)`{${te.default.instancePath}="", ${te.default.parentData}, ${te.default.parentDataProperty}, ${te.default.rootData}=${te.default.data}${e.dynamicRef?(0,Q._)`, ${te.default.dynamicAnchors}={}`:Q.nil}}={}`}function Xw(e,t){e.if(te.default.valCxt,()=>{e.var(te.default.instancePath,(0,Q._)`${te.default.valCxt}.${te.default.instancePath}`),e.var(te.default.parentData,(0,Q._)`${te.default.valCxt}.${te.default.parentData}`),e.var(te.default.parentDataProperty,(0,Q._)`${te.default.valCxt}.${te.default.parentDataProperty}`),e.var(te.default.rootData,(0,Q._)`${te.default.valCxt}.${te.default.rootData}`),t.dynamicRef&&e.var(te.default.dynamicAnchors,(0,Q._)`${te.default.valCxt}.${te.default.dynamicAnchors}`)},()=>{e.var(te.default.instancePath,(0,Q._)`""`),e.var(te.default.parentData,(0,Q._)`undefined`),e.var(te.default.parentDataProperty,(0,Q._)`undefined`),e.var(te.default.rootData,te.default.data),t.dynamicRef&&e.var(te.default.dynamicAnchors,(0,Q._)`{}`)})}function e0(e){const{schema:t,opts:r,gen:n}=e;Gd(e,()=>{r.$comment&&t.$comment&&Yd(e),o0(e),n.let(te.default.vErrors,null),n.let(te.default.errors,0),r.unevaluated&&t0(e),Qd(e),c0(e)})}function t0(e){const{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,Q._)`${r}.evaluated`),t.if((0,Q._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,Q._)`${e.evaluated}.props`,(0,Q._)`undefined`)),t.if((0,Q._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,Q._)`${e.evaluated}.items`,(0,Q._)`undefined`))}function fl(e,t){const r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,Q._)`/*# sourceURL=${r} */`:Q.nil}function r0(e,t){if(Bd(e)&&(Jd(e),Wd(e))){n0(e,t);return}(0,Kd.boolOrEmptySchema)(e,t)}function Wd({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 Bd(e){return typeof e.schema!="boolean"}function n0(e,t){const{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&Yd(e),a0(e),i0(e);const o=n.const("_errs",te.default.errors);Qd(e,o),n.var(t,(0,Q._)`${o} === ${te.default.errors}`)}function Jd(e){(0,Pt.checkUnknownRules)(e),s0(e)}function Qd(e,t){if(e.opts.jtd)return hl(e,[],!1,t);const r=(0,dl.getSchemaTypes)(e.schema),n=(0,dl.coerceAndCheckDataType)(e,r);hl(e,r,!n,t)}function s0(e){const{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,Pt.schemaHasRulesButRef)(t,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function o0(e){const{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Pt.checkStrictMode)(e,"default is ignored in the schema root")}function a0(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,Jw.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function i0(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Yd({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:s}){const o=r.$comment;if(s.$comment===!0)e.code((0,Q._)`${te.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){const a=(0,Q.str)`${n}/$comment`,i=e.scopeValue("root",{ref:t.root});e.code((0,Q._)`${te.default.self}.opts.$comment(${o}, ${a}, ${i}.schema)`)}}function c0(e){const{gen:t,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=e;r.$async?t.if((0,Q._)`${te.default.errors} === 0`,()=>t.return(te.default.data),()=>t.throw((0,Q._)`new ${s}(${te.default.vErrors})`)):(t.assign((0,Q._)`${n}.errors`,te.default.vErrors),o.unevaluated&&l0(e),t.return((0,Q._)`${te.default.errors} === 0`))}function l0({gen:e,evaluated:t,props:r,items:n}){r instanceof Q.Name&&e.assign((0,Q._)`${t}.props`,r),n instanceof Q.Name&&e.assign((0,Q._)`${t}.items`,n)}function hl(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,Pt.schemaHasRulesButRef)(o,d))){s.block(()=>tf(e,"$ref",d.all.$ref.definition));return}c.jtd||u0(e,t),s.block(()=>{for(const m of d.rules)f(m);f(d.post)});function f(m){(0,ai.shouldUseGroup)(o,m)&&(m.type?(s.if((0,ws.checkDataType)(m.type,a,c.strictNumbers)),pl(e,m),t.length===1&&t[0]===m.type&&r&&(s.else(),(0,ws.reportTypeError)(e)),s.endIf()):pl(e,m),i||s.if((0,Q._)`${te.default.errors} === ${n||0}`))}}function pl(e,t){const{gen:r,schema:n,opts:{useDefaults:s}}=e;s&&(0,Bw.assignDefaults)(e,t.type),r.block(()=>{for(const o of t.rules)(0,ai.shouldUseRule)(n,o)&&tf(e,o.keyword,o.definition,t.type)})}function u0(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(d0(e,t),e.opts.allowUnionTypes||f0(e,t),h0(e,e.dataTypes))}function d0(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{Xd(e.dataTypes,r)||ii(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),m0(e,t)}}function f0(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&ii(e,"use allowUnionTypes to allow union type keyword")}function h0(e,t){const r=e.self.RULES.all;for(const n in r){const s=r[n];if(typeof s=="object"&&(0,ai.shouldUseRule)(e.schema,s)){const{type:o}=s.definition;o.length&&!o.some(a=>p0(t,a))&&ii(e,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function p0(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function Xd(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function m0(e,t){const r=[];for(const n of e.dataTypes)Xd(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function ii(e,t){const r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,Pt.checkStrictMode)(e,t,e.opts.strictTypes)}let ef=class{constructor(t,r,n){if((0,dn.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,Pt.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",rf(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,dn.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",te.default.errors))}result(t,r,n){this.failResult((0,Q.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,Q.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,Q._)`${r} !== undefined && (${(0,Q.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?tn.reportExtraError:tn.reportError)(this,this.def.error,r)}$dataError(){(0,tn.reportError)(this,this.def.$dataError||tn.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,tn.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=Q.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=Q.nil,r=Q.nil){if(!this.$data)return;const{gen:n,schemaCode:s,schemaType:o,def:a}=this;n.if((0,Q.or)((0,Q._)`${s} === undefined`,r)),t!==Q.nil&&n.assign(t,!0),(o.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==Q.nil&&n.assign(t,!1)),n.else()}invalid$data(){const{gen:t,schemaCode:r,schemaType:n,def:s,it:o}=this;return(0,Q.or)(a(),i());function a(){if(n.length){if(!(r instanceof Q.Name))throw new Error("ajv implementation error");const c=Array.isArray(n)?n:[n];return(0,Q._)`${(0,ws.checkDataTypes)(c,r,o.opts.strictNumbers,ws.DataType.Wrong)}`}return Q.nil}function i(){if(s.validateSchema){const c=t.scopeValue("validate$data",{ref:s.validateSchema});return(0,Q._)`!${c}(${r})`}return Q.nil}}subschema(t,r){const n=(0,lo.getSubschema)(this.it,t);(0,lo.extendSubschemaData)(n,this.it,t),(0,lo.extendSubschemaMode)(n,t);const s={...this.it,...n,items:void 0,props:void 0};return r0(s,r),s}mergeEvaluated(t,r){const{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=Pt.mergeEvaluated.props(s,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=Pt.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,Q.Name)),!0}};gt.KeywordCxt=ef;function tf(e,t,r,n){const s=new ef(e,r,t);"code"in r?r.code(s,n):s.$data&&r.validate?(0,dn.funcKeywordCode)(s,r):"macro"in r?(0,dn.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,dn.funcKeywordCode)(s,r)}const g0=/^\/(?:[^~]|~0|~1)*$/,_0=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function rf(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,o;if(e==="")return te.default.rootData;if(e[0]==="/"){if(!g0.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,o=te.default.rootData}else{const l=_0.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,Q._)`${o}${(0,Q.getProperty)((0,Pt.unescapeJsonPointer)(l))}`,a=(0,Q._)`${a} && ${o}`);return a;function c(l,d){return`Cannot access ${l} ${d} levels up, current level is ${t}`}}gt.getData=rf;var Dn={};Object.defineProperty(Dn,"__esModule",{value:!0});let y0=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};Dn.default=y0;var Kr={};Object.defineProperty(Kr,"__esModule",{value:!0});const uo=qe;let v0=class extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,uo.resolveUrl)(t,r,n),this.missingSchema=(0,uo.normalizeId)((0,uo.getFullPath)(t,this.missingRef))}};Kr.default=v0;var Ye={};Object.defineProperty(Ye,"__esModule",{value:!0});Ye.resolveSchema=Ye.getCompilingSchema=Ye.resolveRef=Ye.compileSchema=Ye.SchemaEnv=void 0;const ut=he,$0=Dn,nr=St,pt=qe,ml=Z,w0=gt;let Bs=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,pt.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={}}};Ye.SchemaEnv=Bs;function ci(e){const t=nf.call(this,e);if(t)return t;const r=(0,pt.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,a=new ut.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o});let i;e.$async&&(i=a.scopeValue("Error",{ref:$0.default,code:(0,ut._)`require("ajv/dist/runtime/validation_error").default`}));const c=a.scopeName("validate");e.validateName=c;const l={gen:a,allErrors:this.opts.allErrors,data:nr.default.data,parentData:nr.default.parentData,parentDataProperty:nr.default.parentDataProperty,dataNames:[nr.default.data],dataPathArr:[ut.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,ut.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:ut.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,ut._)`""`,opts:this.opts,self:this};let d;try{this._compilations.add(e),(0,w0.validateFunctionCode)(l),a.optimize(this.opts.code.optimize);const f=a.toString();d=`${a.scopeRefs(nr.default.scope)}return ${f}`,this.opts.code.process&&(d=this.opts.code.process(d,e));const _=new Function(`${nr.default.self}`,`${nr.default.scope}`,d)(this,this.scope.get());if(this.scope.value(c,{ref:_}),_.errors=null,_.schema=e.schema,_.schemaEnv=e,e.$async&&(_.$async=!0),this.opts.code.source===!0&&(_.source={validateName:c,validateCode:f,scopeValues:a._values}),this.opts.unevaluated){const{props:v,items:y}=l;_.evaluated={props:v instanceof ut.Name?void 0:v,items:y instanceof ut.Name?void 0:y,dynamicProps:v instanceof ut.Name,dynamicItems:y instanceof ut.Name},_.source&&(_.source.evaluated=(0,ut.stringify)(_.evaluated))}return e.validate=_,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)}}Ye.compileSchema=ci;function b0(e,t,r){var n;r=(0,pt.resolveUrl)(this.opts.uriResolver,t,r);const s=e.refs[r];if(s)return s;let o=k0.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 Bs({schema:a,schemaId:i,root:e,baseId:t}))}if(o!==void 0)return e.refs[r]=S0.call(this,o)}Ye.resolveRef=b0;function S0(e){return(0,pt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:ci.call(this,e)}function nf(e){for(const t of this._compilations)if(E0(t,e))return t}Ye.getCompilingSchema=nf;function E0(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function k0(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Js.call(this,e,t)}function Js(e,t){const r=this.opts.uriResolver.parse(t),n=(0,pt._getFullPath)(this.opts.uriResolver,r);let s=(0,pt.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===s)return fo.call(this,r,e);const o=(0,pt.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){const i=Js.call(this,e,a);return typeof(i==null?void 0:i.schema)!="object"?void 0:fo.call(this,r,i)}if(typeof(a==null?void 0:a.schema)=="object"){if(a.validate||ci.call(this,a),o===(0,pt.normalizeId)(t)){const{schema:i}=a,{schemaId:c}=this.opts,l=i[c];return l&&(s=(0,pt.resolveUrl)(this.opts.uriResolver,s,l)),new Bs({schema:i,schemaId:c,root:e,baseId:s})}return fo.call(this,r,a)}}Ye.resolveSchema=Js;const P0=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function fo(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,ml.unescapeFragment)(i)];if(c===void 0)return;r=c;const l=typeof r=="object"&&r[this.opts.schemaId];!P0.has(i)&&l&&(t=(0,pt.resolveUrl)(this.opts.uriResolver,t,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,ml.schemaHasRulesButRef)(r,this.RULES)){const i=(0,pt.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=Js.call(this,n,i)}const{schemaId:a}=this.opts;if(o=o||new Bs({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#",T0="Meta-schema for $data reference (JSON AnySchema extension proposal)",j0="object",C0=["$data"],N0={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},I0=!1,O0={$id:R0,description:T0,type:j0,required:C0,properties:N0,additionalProperties:I0};var li={},Qs={exports:{}};const x0=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),sf=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),ui=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),of=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),A0=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function af(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 M0=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function gl(e){return e.length=0,!0}function z0(e,t,r){if(e.length){const n=af(e);if(n!=="")t.push(n);else return r.error=!0,!1;e.length=0}return!0}function D0(e){let t=0;const r={error:!1,address:"",zone:""},n=[],s=[];let o=!1,a=!1,i=z0;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=gl}else{s.push(l);continue}}return s.length&&(i===gl?r.zone=s.join(""):a?n.push(s.join("")):n.push(af(s))),r.address=n.join(""),r}function cf(e){if(q0(e,":")<2)return{host:e,isIPV6:!1};const t=D0(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 q0(e,t){let r=0;for(let n=0;nF0[n])}function H0(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n65535))return"URI port is malformed."}function Ss(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($b);a!==null&&a[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",s=!0);const i=e.match(wb);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(vb);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=bb(n,c);if(l!==void 0&&(n.error=n.error||l,s=!0),n.host)if(hb(n.host)===!1){const m=ib(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=mf(r.scheme||n.scheme);if(!r.unicodeSupport&&(!d||!d.unicodeSupport)&&n.host&&(r.domainHost||d&&d.domainHost)&&o===!1&&pb(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=fb(unescape(n.host),o))),n.path&&(n.path=ub(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 Es(e,t){return Ss(e,t).parsed}function Sb(e,t){return _f(e,t).normalized}function _f(e,t){const{parsed:r,malformedAuthorityOrPort:n}=Ss(e,t);return{normalized:n?e:yr(r,t),malformedAuthorityOrPort:n}}function _l(e,t){if(typeof e=="string"){const{normalized:r,malformedAuthorityOrPort:n}=_f(e,t);return n?void 0:r}if(typeof e=="object")return yr(e,t)}const fi={SCHEMES:mb,normalize:gb,resolve:_b,resolveComponent:gf,equal:yb,serialize:yr,parse:Es};Qs.exports=fi;Qs.exports.default=fi;Qs.exports.fastUri=fi;var yf=Qs.exports;Object.defineProperty(li,"__esModule",{value:!0});const vf=yf;vf.code='require("ajv/dist/runtime/uri").default';li.default=vf;(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=gt;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=Dn,s=Kr,o=_r,a=Ye,i=he,c=qe,l=Ie,d=Z,f=O0,m=li,_=(I,b)=>new RegExp(I,b);_.code="new RegExp";const v=["removeAdditional","useDefaults","coerceTypes"],y=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),g={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.'},w=200;function E(I){var b,j,S,u,p,k,M,D,J,G,pe,tt,Lt,Vt,Ht,Zt,Kt,Gt,Wt,Bt,Jt,Qt,Yt,Xt,er;const lt=I.strict,tr=(b=I.code)===null||b===void 0?void 0:b.optimize,Yr=tr===!0||tr===void 0?1:tr||0,Xr=(S=(j=I.code)===null||j===void 0?void 0:j.regExp)!==null&&S!==void 0?S:_,oo=(u=I.uriResolver)!==null&&u!==void 0?u:m.default;return{strictSchema:(k=(p=I.strictSchema)!==null&&p!==void 0?p:lt)!==null&&k!==void 0?k:!0,strictNumbers:(D=(M=I.strictNumbers)!==null&&M!==void 0?M:lt)!==null&&D!==void 0?D:!0,strictTypes:(G=(J=I.strictTypes)!==null&&J!==void 0?J:lt)!==null&&G!==void 0?G:"log",strictTuples:(tt=(pe=I.strictTuples)!==null&&pe!==void 0?pe:lt)!==null&&tt!==void 0?tt:"log",strictRequired:(Vt=(Lt=I.strictRequired)!==null&&Lt!==void 0?Lt:lt)!==null&&Vt!==void 0?Vt:!1,code:I.code?{...I.code,optimize:Yr,regExp:Xr}:{optimize:Yr,regExp:Xr},loopRequired:(Ht=I.loopRequired)!==null&&Ht!==void 0?Ht:w,loopEnum:(Zt=I.loopEnum)!==null&&Zt!==void 0?Zt:w,meta:(Kt=I.meta)!==null&&Kt!==void 0?Kt:!0,messages:(Gt=I.messages)!==null&&Gt!==void 0?Gt:!0,inlineRefs:(Wt=I.inlineRefs)!==null&&Wt!==void 0?Wt:!0,schemaId:(Bt=I.schemaId)!==null&&Bt!==void 0?Bt:"$id",addUsedSchema:(Jt=I.addUsedSchema)!==null&&Jt!==void 0?Jt:!0,validateSchema:(Qt=I.validateSchema)!==null&&Qt!==void 0?Qt:!0,validateFormats:(Yt=I.validateFormats)!==null&&Yt!==void 0?Yt:!0,unicodeRegExp:(Xt=I.unicodeRegExp)!==null&&Xt!==void 0?Xt:!0,int32range:(er=I.int32range)!==null&&er!==void 0?er:!0,uriResolver:oo}}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=H(b.logger);const u=b.validateFormats;b.validateFormats=!1,this.RULES=(0,o.getRules)(),T.call(this,g,b,"NOT SUPPORTED"),T.call(this,h,b,"DEPRECATED","warn"),this._metaOpts=V.call(this),b.formats&&U.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),b.keywords&&q.call(this,b.keywords),typeof b.meta=="object"&&this.addMetaSchema(b.meta),x.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(G,pe){await p.call(this,G.$schema);const tt=this._addSchema(G,pe);return tt.validate||k.call(this,tt)}async function p(G){G&&!this.getSchema(G)&&await u.call(this,{$ref:G},!0)}async function k(G){try{return this._compileSchemaEnv(G)}catch(pe){if(!(pe instanceof s.default))throw pe;return M.call(this,pe),await D.call(this,pe.missingSchema),k.call(this,G)}}function M({missingSchema:G,missingRef:pe}){if(this.refs[G])throw new Error(`AnySchema ${G} is loaded but ${pe} cannot be resolved`)}async function D(G){const pe=await J.call(this,G);this.refs[G]||await p.call(this,pe.$schema),this.refs[G]||this.addSchema(pe,G,j)}async function J(G){const pe=this._loading[G];if(pe)return pe;try{return await(this._loading[G]=S(G))}finally{delete this._loading[G]}}}addSchema(b,j,S,u=this.opts.validateSchema){if(Array.isArray(b)){for(const k of b)this.addSchema(k,void 0,S,u);return this}let p;if(typeof b=="object"){const{schemaId:k}=this.opts;if(p=b[k],p!==void 0&&typeof p!="string")throw new Error(`schema ${k} 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=C.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=C.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(B.call(this,S,j),!j)return(0,d.eachItem)(S,p=>ge.call(this,p)),this;oe.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=>ge.call(this,p,u):p=>u.type.forEach(k=>ge.call(this,p,u,k))),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 k=b;for(const M of p)k=k[M];for(const M in S){const D=S[M];if(typeof D!="object")continue;const{$data:J}=D.definition,G=k[M];J&&G&&(k[M]=Be(G))}}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 k;const{schemaId:M}=this.opts;if(typeof b=="object")k=b[M];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 D=this._cache.get(b);if(D!==void 0)return D;S=(0,c.normalizeId)(k||S);const J=c.getSchemaRefs.call(this,b,S);return D=new a.SchemaEnv({schema:b,schemaId:M,meta:j,baseId:S,localRefs:J}),this._cache.set(D.schema,D),p&&!S.startsWith("#")&&(S&&this._checkUnique(S),this.refs[S]=D),u&&this.validateSchema(b,!0),D}_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 T(I,b,j,S="error"){for(const u in I){const p=u;p in b&&this.logger[S](`${j}: option ${u}. ${I[p]}`)}}function C(I){return I=(0,c.normalizeId)(I),this.schemas[I]||this.refs[I]}function x(){const I=this.opts.schemas;if(I)if(Array.isArray(I))this.addSchema(I);else for(const b in I)this.addSchema(I[b],b)}function U(){for(const I in this.opts.formats){const b=this.opts.formats[I];b&&this.addFormat(I,b)}}function q(I){if(Array.isArray(I)){this.addVocabulary(I);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const b in I){const j=I[b];j.keyword||(j.keyword=b),this.addKeyword(j)}}function V(){const I={...this.opts};for(const b of v)delete I[b];return I}const z={log(){},warn(){},error(){}};function H(I){if(I===!1)return z;if(I===void 0)return console;if(I.log&&I.warn&&I.error)return I;throw new Error("logger must implement log, warn and error methods")}const ne=/^[a-z_$][a-z0-9_$:-]*$/i;function B(I,b){const{RULES:j}=this;if((0,d.eachItem)(I,S=>{if(j.keywords[S])throw new Error(`Keyword ${S} is already defined`);if(!ne.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 ge(I,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 k=u?p.post:p.rules.find(({type:D})=>D===j);if(k||(k={type:j,rules:[]},p.rules.push(k)),p.keywords[I]=!0,!b)return;const M={keyword:I,definition:{...b,type:(0,l.getJSONTypes)(b.type),schemaType:(0,l.getJSONTypes)(b.schemaType)}};b.before?X.call(this,k,M,b.before):k.rules.push(M),p.all[I]=M,(S=b.implements)===null||S===void 0||S.forEach(D=>this.addKeyword(D))}function X(I,b,j){const S=I.rules.findIndex(u=>u.keyword===j);S>=0?I.rules.splice(S,0,b):(I.rules.push(b),this.logger.warn(`rule ${j} is not defined`))}function oe(I){let{metaSchema:b}=I;b!==void 0&&(I.$data&&this.opts.$data&&(b=Be(b)),I.validateSchema=this.compile(b,!0))}const We={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Be(I){return{anyOf:[I,We]}}})(Pd);var hi={},pi={},mi={};Object.defineProperty(mi,"__esModule",{value:!0});const Eb={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};mi.default=Eb;var vr={};Object.defineProperty(vr,"__esModule",{value:!0});vr.callRef=vr.getValidate=void 0;const kb=Kr,yl=de,Je=he,kr=St,vl=Ye,Wn=Z,Pb={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=vl.resolveRef.call(c,l,s,r);if(d===void 0)throw new kb.default(n.opts.uriResolver,s,r);if(d instanceof vl.SchemaEnv)return m(d);return _(d);function f(){if(o===l)return cs(e,a,o,o.$async);const v=t.scopeValue("root",{ref:l});return cs(e,(0,Je._)`${v}.validate`,l,l.$async)}function m(v){const y=$f(e,v);cs(e,y,v,v.$async)}function _(v){const y=t.scopeValue("schema",i.code.source===!0?{ref:v,code:(0,Je.stringify)(v)}:{ref:v}),g=t.name("valid"),h=e.subschema({schema:v,dataTypes:[],schemaPath:Je.nil,topSchemaRef:y,errSchemaPath:r},g);e.mergeEvaluated(h),e.ok(g)}}};function $f(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Je._)`${r.scopeValue("wrapper",{ref:t})}.validate`}vr.getValidate=$f;function cs(e,t,r,n){const{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:c}=o,l=c.passContext?kr.default.this:Je.nil;n?d():f();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");const v=s.let("valid");s.try(()=>{s.code((0,Je._)`await ${(0,yl.callValidateCode)(e,t,l)}`),_(t),a||s.assign(v,!0)},y=>{s.if((0,Je._)`!(${y} instanceof ${o.ValidationError})`,()=>s.throw(y)),m(y),a||s.assign(v,!1)}),e.ok(v)}function f(){e.result((0,yl.callValidateCode)(e,t,l),()=>_(t),()=>m(t))}function m(v){const y=(0,Je._)`${v}.errors`;s.assign(kr.default.vErrors,(0,Je._)`${kr.default.vErrors} === null ? ${y} : ${kr.default.vErrors}.concat(${y})`),s.assign(kr.default.errors,(0,Je._)`${kr.default.vErrors}.length`)}function _(v){var y;if(!o.opts.unevaluated)return;const g=(y=r==null?void 0:r.validate)===null||y===void 0?void 0:y.evaluated;if(o.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(o.props=Wn.mergeEvaluated.props(s,g.props,o.props));else{const h=s.var("props",(0,Je._)`${v}.evaluated.props`);o.props=Wn.mergeEvaluated.props(s,h,o.props,Je.Name)}if(o.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(o.items=Wn.mergeEvaluated.items(s,g.items,o.items));else{const h=s.var("items",(0,Je._)`${v}.evaluated.items`);o.items=Wn.mergeEvaluated.items(s,h,o.items,Je.Name)}}}vr.callRef=cs;vr.default=Pb;Object.defineProperty(pi,"__esModule",{value:!0});const Rb=mi,Tb=vr,jb=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Rb.default,Tb.default];pi.default=jb;var gi={},_i={};Object.defineProperty(_i,"__esModule",{value:!0});const ks=he,Ct=ks.operators,Ps={maximum:{okStr:"<=",ok:Ct.LTE,fail:Ct.GT},minimum:{okStr:">=",ok:Ct.GTE,fail:Ct.LT},exclusiveMaximum:{okStr:"<",ok:Ct.LT,fail:Ct.GTE},exclusiveMinimum:{okStr:">",ok:Ct.GT,fail:Ct.LTE}},Cb={message:({keyword:e,schemaCode:t})=>(0,ks.str)`must be ${Ps[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,ks._)`{comparison: ${Ps[e].okStr}, limit: ${t}}`},Nb={keyword:Object.keys(Ps),type:"number",schemaType:"number",$data:!0,error:Cb,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,ks._)`${r} ${Ps[t].fail} ${n} || isNaN(${r})`)}};_i.default=Nb;var yi={};Object.defineProperty(yi,"__esModule",{value:!0});const fn=he,Ib={message:({schemaCode:e})=>(0,fn.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,fn._)`{multipleOf: ${e}}`},Ob={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,fn._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0,fn._)`${a} !== parseInt(${a})`;e.fail$data((0,fn._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};yi.default=Ob;var vi={},$i={};Object.defineProperty($i,"__esModule",{value:!0});function wf(e){const t=e.length;let r=0,n=0,s;for(;n=55296&&s<=56319&&n(0,lr._)`{limit: ${e}}`},zb={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:Mb,code(e){const{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?lr.operators.GT:lr.operators.LT,a=s.opts.unicode===!1?(0,lr._)`${r}.length`:(0,lr._)`${(0,xb.useFunc)(e.gen,Ab.default)}(${r})`;e.fail$data((0,lr._)`${a} ${o} ${n}`)}};vi.default=zb;var wi={};Object.defineProperty(wi,"__esModule",{value:!0});const Db=de,qb=Z,Or=he,Ub={message:({schemaCode:e})=>(0,Or.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Or._)`{pattern: ${e}}`},Fb={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:Ub,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,Or._)`new RegExp`:(0,qb.useFunc)(t,c),d=t.let("valid");t.try(()=>t.assign(d,(0,Or._)`${l}(${o}, ${i}).test(${r})`),()=>t.assign(d,!1)),e.fail$data((0,Or._)`!${d}`)}else{const c=(0,Db.usePattern)(e,s);e.fail$data((0,Or._)`!${c}.test(${r})`)}}};wi.default=Fb;var bi={};Object.defineProperty(bi,"__esModule",{value:!0});const hn=he,Lb={message({keyword:e,schemaCode:t}){const r=e==="maxProperties"?"more":"fewer";return(0,hn.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,hn._)`{limit: ${e}}`},Vb={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:Lb,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?hn.operators.GT:hn.operators.LT;e.fail$data((0,hn._)`Object.keys(${r}).length ${s} ${n}`)}};bi.default=Vb;var Si={};Object.defineProperty(Si,"__esModule",{value:!0});const rn=de,pn=he,Hb=Z,Zb={message:({params:{missingProperty:e}})=>(0,pn.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,pn._)`{missingProperty: ${e}}`},Kb={keyword:"required",type:"object",schemaType:"array",$data:!0,error:Zb,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 _=e.parentSchema.properties,{definedProperties:v}=e.it;for(const y of r)if((_==null?void 0:_[y])===void 0&&!v.has(y)){const g=a.schemaEnv.baseId+a.errSchemaPath,h=`required property "${y}" is not defined at "${g}" (strictRequired)`;(0,Hb.checkStrictMode)(a,h,a.opts.strictRequired)}}function l(){if(c||o)e.block$data(pn.nil,f);else for(const _ of r)(0,rn.checkReportMissingProp)(e,_)}function d(){const _=t.let("missing");if(c||o){const v=t.let("valid",!0);e.block$data(v,()=>m(_,v)),e.ok(v)}else t.if((0,rn.checkMissingProp)(e,r,_)),(0,rn.reportMissingProp)(e,_),t.else()}function f(){t.forOf("prop",n,_=>{e.setParams({missingProperty:_}),t.if((0,rn.noPropertyInData)(t,s,_,i.ownProperties),()=>e.error())})}function m(_,v){e.setParams({missingProperty:_}),t.forOf(_,n,()=>{t.assign(v,(0,rn.propertyInData)(t,s,_,i.ownProperties)),t.if((0,pn.not)(v),()=>{e.error(),t.break()})},pn.nil)}}};Si.default=Kb;var Ei={};Object.defineProperty(Ei,"__esModule",{value:!0});const mn=he,Gb={message({keyword:e,schemaCode:t}){const r=e==="maxItems"?"more":"fewer";return(0,mn.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,mn._)`{limit: ${e}}`},Wb={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Gb,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?mn.operators.GT:mn.operators.LT;e.fail$data((0,mn._)`${r}.length ${s} ${n}`)}};Ei.default=Wb;var ki={},qn={};Object.defineProperty(qn,"__esModule",{value:!0});const bf=Ws;bf.code='require("ajv/dist/runtime/equal").default';qn.default=bf;Object.defineProperty(ki,"__esModule",{value:!0});const ho=Ie,Me=he,Bb=Z,Jb=qn,Qb={message:({params:{i:e,j:t}})=>(0,Me.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,Me._)`{i: ${e}, j: ${t}}`},Yb={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:Qb,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,ho.getSchemaTypes)(o.items):[];e.block$data(c,d,(0,Me._)`${a} === false`),e.ok(c);function d(){const v=t.let("i",(0,Me._)`${r}.length`),y=t.let("j");e.setParams({i:v,j:y}),t.assign(c,!0),t.if((0,Me._)`${v} > 1`,()=>(f()?m:_)(v,y))}function f(){return l.length>0&&!l.some(v=>v==="object"||v==="array")}function m(v,y){const g=t.name("item"),h=(0,ho.checkDataTypes)(l,g,i.opts.strictNumbers,ho.DataType.Wrong),w=t.const("indices",(0,Me._)`{}`);t.for((0,Me._)`;${v}--;`,()=>{t.let(g,(0,Me._)`${r}[${v}]`),t.if(h,(0,Me._)`continue`),l.length>1&&t.if((0,Me._)`typeof ${g} == "string"`,(0,Me._)`${g} += "_"`),t.if((0,Me._)`typeof ${w}[${g}] == "number"`,()=>{t.assign(y,(0,Me._)`${w}[${g}]`),e.error(),t.assign(c,!1).break()}).code((0,Me._)`${w}[${g}] = ${v}`)})}function _(v,y){const g=(0,Bb.useFunc)(t,Jb.default),h=t.name("outer");t.label(h).for((0,Me._)`;${v}--;`,()=>t.for((0,Me._)`${y} = ${v}; ${y}--;`,()=>t.if((0,Me._)`${g}(${r}[${v}], ${r}[${y}])`,()=>{e.error(),t.assign(c,!1).break(h)})))}}};ki.default=Yb;var Pi={};Object.defineProperty(Pi,"__esModule",{value:!0});const Fo=he,Xb=Z,eS=qn,tS={message:"must be equal to constant",params:({schemaCode:e})=>(0,Fo._)`{allowedValue: ${e}}`},rS={keyword:"const",$data:!0,error:tS,code(e){const{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,Fo._)`!${(0,Xb.useFunc)(t,eS.default)}(${r}, ${s})`):e.fail((0,Fo._)`${o} !== ${r}`)}};Pi.default=rS;var Ri={};Object.defineProperty(Ri,"__esModule",{value:!0});const cn=he,nS=Z,sS=qn,oS={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,cn._)`{allowedValues: ${e}}`},aS={keyword:"enum",schemaType:"array",$data:!0,error:oS,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,nS.useFunc)(t,sS.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 _=t.const("vSchema",o);d=(0,cn.or)(...s.map((v,y)=>m(_,y)))}e.pass(d);function f(){t.assign(d,!1),t.forOf("v",o,_=>t.if((0,cn._)`${l()}(${r}, ${_})`,()=>t.assign(d,!0).break()))}function m(_,v){const y=s[v];return typeof y=="object"&&y!==null?(0,cn._)`${l()}(${r}, ${_}[${v}])`:(0,cn._)`${r} === ${y}`}}};Ri.default=aS;Object.defineProperty(gi,"__esModule",{value:!0});const iS=_i,cS=yi,lS=vi,uS=wi,dS=bi,fS=Si,hS=Ei,pS=ki,mS=Pi,gS=Ri,_S=[iS.default,cS.default,lS.default,uS.default,dS.default,fS.default,hS.default,pS.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},mS.default,gS.default];gi.default=_S;var Ti={},Gr={};Object.defineProperty(Gr,"__esModule",{value:!0});Gr.validateAdditionalItems=void 0;const ur=he,Lo=Z,yS={message:({params:{len:e}})=>(0,ur.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,ur._)`{limit: ${e}}`},vS={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:yS,code(e){const{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Lo.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Sf(e,n)}};function Sf(e,t){const{gen:r,schema:n,data:s,keyword:o,it:a}=e;a.items=!0;const i=r.const("len",(0,ur._)`${s}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,ur._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0,Lo.alwaysValidSchema)(a,n)){const l=r.var("valid",(0,ur._)`${i} <= ${t.length}`);r.if((0,ur.not)(l),()=>c(l)),e.ok(l)}function c(l){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:Lo.Type.Num},l),a.allErrors||r.if((0,ur.not)(l),()=>r.break())})}}Gr.validateAdditionalItems=Sf;Gr.default=vS;var ji={},Wr={};Object.defineProperty(Wr,"__esModule",{value:!0});Wr.validateTuple=void 0;const $l=he,ls=Z,$S=de,wS={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return Ef(e,"additionalItems",t);r.items=!0,!(0,ls.alwaysValidSchema)(r,t)&&e.ok((0,$S.validateArray)(e))}};function Ef(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=ls.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),l=n.const("len",(0,$l._)`${o}.length`);r.forEach((f,m)=>{(0,ls.alwaysValidSchema)(i,f)||(n.if((0,$l._)`${l} > ${m}`,()=>e.subschema({keyword:a,schemaProp:m,dataProp:m},c)),e.ok(c))});function d(f){const{opts:m,errSchemaPath:_}=i,v=r.length,y=v===f.minItems&&(v===f.maxItems||f[t]===!1);if(m.strictTuples&&!y){const g=`"${a}" is ${v}-tuple, but minItems or maxItems/${t} are not specified or different at path "${_}"`;(0,ls.checkStrictMode)(i,g,m.strictTuples)}}}Wr.validateTuple=Ef;Wr.default=wS;Object.defineProperty(ji,"__esModule",{value:!0});const bS=Wr,SS={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,bS.validateTuple)(e,"items")};ji.default=SS;var Ci={};Object.defineProperty(Ci,"__esModule",{value:!0});const wl=he,ES=Z,kS=de,PS=Gr,RS={message:({params:{len:e}})=>(0,wl.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,wl._)`{limit: ${e}}`},TS={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,ES.alwaysValidSchema)(n,t)&&(s?(0,PS.validateAdditionalItems)(e,s):e.ok((0,kS.validateArray)(e)))}};Ci.default=TS;var Ni={};Object.defineProperty(Ni,"__esModule",{value:!0});const st=he,Bn=Z,jS={message:({params:{min:e,max:t}})=>t===void 0?(0,st.str)`must contain at least ${e} valid item(s)`:(0,st.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,st._)`{minContains: ${e}}`:(0,st._)`{minContains: ${e}, maxContains: ${t}}`},CS={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:jS,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,st._)`${s}.length`);if(e.setParams({min:a,max:i}),i===void 0&&a===0){(0,Bn.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0,Bn.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Bn.alwaysValidSchema)(o,r)){let y=(0,st._)`${d} >= ${a}`;i!==void 0&&(y=(0,st._)`${y} && ${d} <= ${i}`),e.pass(y);return}o.items=!0;const f=t.name("valid");i===void 0&&a===1?_(f,()=>t.if(f,()=>t.break())):a===0?(t.let(f,!0),i!==void 0&&t.if((0,st._)`${s}.length > 0`,m)):(t.let(f,!1),m()),e.result(f,()=>e.reset());function m(){const y=t.name("_valid"),g=t.let("count",0);_(y,()=>t.if(y,()=>v(g)))}function _(y,g){t.forRange("i",0,d,h=>{e.subschema({keyword:"contains",dataProp:h,dataPropType:Bn.Type.Num,compositeRule:!0},y),g()})}function v(y){t.code((0,st._)`${y}++`),i===void 0?t.if((0,st._)`${y} >= ${a}`,()=>t.assign(f,!0).break()):(t.if((0,st._)`${y} > ${i}`,()=>t.assign(f,!1).break()),a===1?t.assign(f,!0):t.if((0,st._)`${y} >= ${a}`,()=>t.assign(f,!0)))}}};Ni.default=CS;var kf={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=he,r=Z,n=de;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 _=d.let("missing");for(const v in l){const y=l[v];if(y.length===0)continue;const g=(0,n.propertyInData)(d,f,v,m.opts.ownProperties);c.setParams({property:v,depsCount:y.length,deps:y.join(", ")}),m.allErrors?d.if(g,()=>{for(const h of y)(0,n.checkReportMissingProp)(c,h)}):(d.if((0,t._)`${g} && (${(0,n.checkMissingProp)(c,y,_)})`),(0,n.reportMissingProp)(c,_),d.else())}}e.validatePropertyDeps=a;function i(c,l=c.schema){const{gen:d,data:f,keyword:m,it:_}=c,v=d.name("valid");for(const y in l)(0,r.alwaysValidSchema)(_,l[y])||(d.if((0,n.propertyInData)(d,f,y,_.opts.ownProperties),()=>{const g=c.subschema({keyword:m,schemaProp:y},v);c.mergeValidEvaluated(g,v)},()=>d.var(v,!0)),c.ok(v))}e.validateSchemaDeps=i,e.default=s})(kf);var Ii={};Object.defineProperty(Ii,"__esModule",{value:!0});const Pf=he,NS=Z,IS={message:"property name must be valid",params:({params:e})=>(0,Pf._)`{propertyName: ${e.propertyName}}`},OS={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:IS,code(e){const{gen:t,schema:r,data:n,it:s}=e;if((0,NS.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,Pf.not)(o),()=>{e.error(!0),s.allErrors||t.break()})}),e.ok(o)}};Ii.default=OS;var Ys={};Object.defineProperty(Ys,"__esModule",{value:!0});const Jn=de,ft=he,xS=St,Qn=Z,AS={message:"must NOT have additional properties",params:({params:e})=>(0,ft._)`{additionalProperty: ${e.additionalProperty}}`},MS={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:AS,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,Qn.alwaysValidSchema)(a,r))return;const l=(0,Jn.allSchemaProperties)(n.properties),d=(0,Jn.allSchemaProperties)(n.patternProperties);f(),e.ok((0,ft._)`${o} === ${xS.default.errors}`);function f(){t.forIn("key",s,g=>{!l.length&&!d.length?v(g):t.if(m(g),()=>v(g))})}function m(g){let h;if(l.length>8){const w=(0,Qn.schemaRefOrVal)(a,n.properties,"properties");h=(0,Jn.isOwnProperty)(t,w,g)}else l.length?h=(0,ft.or)(...l.map(w=>(0,ft._)`${g} === ${w}`)):h=ft.nil;return d.length&&(h=(0,ft.or)(h,...d.map(w=>(0,ft._)`${(0,Jn.usePattern)(e,w)}.test(${g})`))),(0,ft.not)(h)}function _(g){t.code((0,ft._)`delete ${s}[${g}]`)}function v(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){_(g);return}if(r===!1){e.setParams({additionalProperty:g}),e.error(),i||t.break();return}if(typeof r=="object"&&!(0,Qn.alwaysValidSchema)(a,r)){const h=t.name("valid");c.removeAdditional==="failing"?(y(g,h,!1),t.if((0,ft.not)(h),()=>{e.reset(),_(g)})):(y(g,h),i||t.if((0,ft.not)(h),()=>t.break()))}}function y(g,h,w){const E={keyword:"additionalProperties",dataProp:g,dataPropType:Qn.Type.Str};w===!1&&Object.assign(E,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(E,h)}}};Ys.default=MS;var Oi={};Object.defineProperty(Oi,"__esModule",{value:!0});const zS=gt,bl=de,po=Z,Sl=Ys,DS={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&&Sl.default.code(new zS.KeywordCxt(o,Sl.default,"additionalProperties"));const a=(0,bl.allSchemaProperties)(r);for(const f of a)o.definedProperties.add(f);o.opts.unevaluated&&a.length&&o.props!==!0&&(o.props=po.mergeEvaluated.props(t,(0,po.toHash)(a),o.props));const i=a.filter(f=>!(0,po.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,bl.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)}}};Oi.default=DS;var xi={};Object.defineProperty(xi,"__esModule",{value:!0});const El=de,Yn=he,kl=Z,Pl=Z,qS={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,El.allSchemaProperties)(r),c=i.filter(y=>(0,kl.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 Yn.Name)&&(o.props=(0,Pl.evaluatedPropsToName)(t,o.props));const{props:f}=o;m();function m(){for(const y of i)l&&_(y),o.allErrors?v(y):(t.var(d,!0),v(y),t.if(d))}function _(y){for(const g in l)new RegExp(y).test(g)&&(0,kl.checkStrictMode)(o,`property ${g} matches pattern ${y} (use allowMatchingProperties)`)}function v(y){t.forIn("key",n,g=>{t.if((0,Yn._)`${(0,El.usePattern)(e,y)}.test(${g})`,()=>{const h=c.includes(y);h||e.subschema({keyword:"patternProperties",schemaProp:y,dataProp:g,dataPropType:Pl.Type.Str},d),o.opts.unevaluated&&f!==!0?t.assign((0,Yn._)`${f}[${g}]`,!0):!h&&!o.allErrors&&t.if((0,Yn.not)(d),()=>t.break())})})}}};xi.default=qS;var Ai={};Object.defineProperty(Ai,"__esModule",{value:!0});const US=Z,FS={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,US.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"}};Ai.default=FS;var Mi={};Object.defineProperty(Mi,"__esModule",{value:!0});const LS=de,VS={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:LS.validateUnion,error:{message:"must match a schema in anyOf"}};Mi.default=VS;var zi={};Object.defineProperty(zi,"__esModule",{value:!0});const us=he,HS=Z,ZS={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,us._)`{passingSchemas: ${e.passing}}`},KS={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:ZS,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,HS.alwaysValidSchema)(s,d)?t.var(c,!0):m=e.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},c),f>0&&t.if((0,us._)`${c} && ${a}`).assign(a,!1).assign(i,(0,us._)`[${i}, ${f}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,f),m&&e.mergeEvaluated(m,us.Name)})})}}};zi.default=KS;var Di={};Object.defineProperty(Di,"__esModule",{value:!0});const GS=Z,WS={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,GS.alwaysValidSchema)(n,o))return;const i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i)})}};Di.default=WS;var qi={};Object.defineProperty(qi,"__esModule",{value:!0});const Rs=he,Rf=Z,BS={message:({params:e})=>(0,Rs.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,Rs._)`{failingKeyword: ${e.ifClause}}`},JS={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:BS,code(e){const{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,Rf.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const s=Rl(n,"then"),o=Rl(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,Rs.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,Rs._)`${d}`):e.setParams({ifClause:d})}}}};function Rl(e,t){const r=e.schema[t];return r!==void 0&&!(0,Rf.alwaysValidSchema)(e,r)}qi.default=JS;var Ui={};Object.defineProperty(Ui,"__esModule",{value:!0});const QS=Z,YS={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,QS.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Ui.default=YS;Object.defineProperty(Ti,"__esModule",{value:!0});const XS=Gr,eE=ji,tE=Wr,rE=Ci,nE=Ni,sE=kf,oE=Ii,aE=Ys,iE=Oi,cE=xi,lE=Ai,uE=Mi,dE=zi,fE=Di,hE=qi,pE=Ui;function mE(e=!1){const t=[lE.default,uE.default,dE.default,fE.default,hE.default,pE.default,oE.default,aE.default,sE.default,iE.default,cE.default];return e?t.push(eE.default,rE.default):t.push(XS.default,tE.default),t.push(nE.default),t}Ti.default=mE;var Fi={},Li={};Object.defineProperty(Li,"__esModule",{value:!0});const Ce=he,gE={message:({schemaCode:e})=>(0,Ce.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,Ce._)`{format: ${e}}`},_E={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:gE,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():_();function m(){const v=r.scopeValue("formats",{ref:f.formats,code:c.code.formats}),y=r.const("fDef",(0,Ce._)`${v}[${a}]`),g=r.let("fType"),h=r.let("format");r.if((0,Ce._)`typeof ${y} == "object" && !(${y} instanceof RegExp)`,()=>r.assign(g,(0,Ce._)`${y}.type || "string"`).assign(h,(0,Ce._)`${y}.validate`),()=>r.assign(g,(0,Ce._)`"string"`).assign(h,y)),e.fail$data((0,Ce.or)(w(),E()));function w(){return c.strictSchema===!1?Ce.nil:(0,Ce._)`${a} && !${h}`}function E(){const R=d.$async?(0,Ce._)`(${y}.async ? await ${h}(${n}) : ${h}(${n}))`:(0,Ce._)`${h}(${n})`,T=(0,Ce._)`(typeof ${h} == "function" ? ${R} : ${h}.test(${n}))`;return(0,Ce._)`${h} && ${h} !== true && ${g} === ${t} && !${T}`}}function _(){const v=f.formats[o];if(!v){w();return}if(v===!0)return;const[y,g,h]=E(v);y===t&&e.pass(R());function w(){if(c.strictSchema===!1){f.logger.warn(T());return}throw new Error(T());function T(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function E(T){const C=T instanceof RegExp?(0,Ce.regexpCode)(T):c.code.formats?(0,Ce._)`${c.code.formats}${(0,Ce.getProperty)(o)}`:void 0,x=r.scopeValue("formats",{key:o,ref:T,code:C});return typeof T=="object"&&!(T instanceof RegExp)?[T.type||"string",T.validate,(0,Ce._)`${x}.validate`]:["string",T,x]}function R(){if(typeof v=="object"&&!(v instanceof RegExp)&&v.async){if(!d.$async)throw new Error("async format in sync schema");return(0,Ce._)`await ${h}(${n})`}return typeof g=="function"?(0,Ce._)`${h}(${n})`:(0,Ce._)`${h}.test(${n})`}}}};Li.default=_E;Object.defineProperty(Fi,"__esModule",{value:!0});const yE=Li,vE=[yE.default];Fi.default=vE;var Fr={};Object.defineProperty(Fr,"__esModule",{value:!0});Fr.contentVocabulary=Fr.metadataVocabulary=void 0;Fr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Fr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(hi,"__esModule",{value:!0});const $E=pi,wE=gi,bE=Ti,SE=Fi,Tl=Fr,EE=[$E.default,wE.default,(0,bE.default)(),SE.default,Tl.metadataVocabulary,Tl.contentVocabulary];hi.default=EE;var Vi={},Xs={};Object.defineProperty(Xs,"__esModule",{value:!0});Xs.DiscrError=void 0;var jl;(function(e){e.Tag="tag",e.Mapping="mapping"})(jl||(Xs.DiscrError=jl={}));Object.defineProperty(Vi,"__esModule",{value:!0});const Cr=he,Vo=Xs,Cl=Ye,kE=Kr,PE=Z,RE={message:({params:{discrError:e,tagName:t}})=>e===Vo.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Cr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},TE={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,Cr._)`${r}${(0,Cr.getProperty)(i)}`);t.if((0,Cr._)`typeof ${l} == "string"`,()=>d(),()=>e.error(!1,{discrError:Vo.DiscrError.Tag,tag:l,tagName:i})),e.ok(c);function d(){const _=m();t.if(!1);for(const v in _)t.elseIf((0,Cr._)`${l} === ${v}`),t.assign(c,f(_[v]));t.else(),e.error(!1,{discrError:Vo.DiscrError.Mapping,tag:l,tagName:i}),t.endIf()}function f(_){const v=t.name("valid"),y=e.subschema({keyword:"oneOf",schemaProp:_},v);return e.mergeEvaluated(y,Cr.Name),v}function m(){var _;const v={},y=h(s);let g=!0;for(let R=0;Rthis.addVocabulary(v)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const v=this.opts.$data?this.$dataMetaSchema(o,a):o;this.addMetaSchema(v,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=gt;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=Dn;Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return f.default}});var m=Kr;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return m.default}})})(Mo,Mo.exports);var ME=Mo.exports;const zE=cu(ME);var Ho={exports:{}},Tf={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(z,H){return{validate:z,compare:H}}e.fullFormats={date:t(o,a),time:t(c(!0),l),"date-time":t(m(!0),_),"iso-time":t(c(),d),"iso-date-time":t(m(),v),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:V,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:E,int32:{type:"number",validate:C},int64:{type:"number",validate:x},float:{type:"number",validate:U},double:{type:"number",validate:U},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,_),"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,v),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 H=n.exec(z);if(!H)return!1;const ne=+H[1],B=+H[2],ge=+H[3];return B>=1&&B<=12&&ge>=1&&ge<=(B===2&&r(ne)?29:s[B])}function a(z,H){if(z&&H)return z>H?1:z23||b>59||z&&!We)return!1;if(ge<=23&&X<=59&&oe<60)return!0;const j=X-b*Be,S=ge-I*Be-(j<0?1:0);return(S===23||S===-1)&&(j===59||j===-1)&&oe<61}}function l(z,H){if(!(z&&H))return;const ne=new Date("2020-01-01T"+z).valueOf(),B=new Date("2020-01-01T"+H).valueOf();if(ne&&B)return ne-B}function d(z,H){if(!(z&&H))return;const ne=i.exec(z),B=i.exec(H);if(ne&&B)return z=ne[1]+ne[2]+ne[3],H=B[1]+B[2]+B[3],z>H?1:z=R}function x(z){return Number.isInteger(z)}function U(){return!0}const q=/[^\\]\\Z/;function V(z){if(q.test(z))return!1;try{return new RegExp(z),!0}catch{return!1}}})(Tf);var jf={},Zo={exports:{}},Cf={},_t={},Lr={},Un={},ue={},Pn={};(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(w){if(super(),!e.IDENTIFIER.test(w))throw new Error("CodeGen: name must be a valid identifier");this.str=w}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=r;class n extends t{constructor(w){super(),this._items=typeof w=="string"?[w]:w}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const w=this._items[0];return w===""||w==='""'}get str(){var w;return(w=this._str)!==null&&w!==void 0?w:this._str=this._items.reduce((E,R)=>`${E}${R}`,"")}get names(){var w;return(w=this._names)!==null&&w!==void 0?w: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,...w){const E=[h[0]];let R=0;for(;R{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 _=t.nil;for(const v in l){const y=l[v];if(!y)continue;const g=f[v]=f[v]||new Map;y.forEach(h=>{if(g.has(h))return;g.set(h,n.Started);let w=d(h);if(w){const E=this.opts.es5?e.varKinds.var:e.varKinds.const;_=(0,t._)`${_}${E} ${h} = ${w};${this.opts._n}`}else if(w=m==null?void 0:m(h))_=(0,t._)`${_}${w}${this.opts._n}`;else throw new r(h);g.set(h,n.Completed)})}return _}}e.ValueScope=i})(Ko);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=Pn,r=Ko;var n=Pn;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}});var s=Ko;Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class o{optimizeNodes(){return this}optimizeNames(u,p){return this}}class a extends o{constructor(u,p,k){super(),this.varKind=u,this.name=p,this.rhs=k}render({es5:u,_n:p}){const k=u?r.varKinds.var:this.varKind,M=this.rhs===void 0?"":` = ${this.rhs}`;return`${k} ${this.name}${M};`+p}optimizeNames(u,p){if(u[this.name.str])return this.rhs&&(this.rhs=B(this.rhs,u,p)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class i extends o{constructor(u,p,k){super(),this.lhs=u,this.rhs=p,this.sideEffects=k}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=B(this.rhs,u,p),this}get names(){const u=this.lhs instanceof t.Name?{}:{...this.lhs.names};return ne(u,this.rhs)}}class c extends i{constructor(u,p,k,M){super(u,k,M),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=B(this.code,u,p),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}}class _ extends o{constructor(u=[]){super(),this.nodes=u}render(u){return this.nodes.reduce((p,k)=>p+k.render(u),"")}optimizeNodes(){const{nodes:u}=this;let p=u.length;for(;p--;){const k=u[p].optimizeNodes();Array.isArray(k)?u.splice(p,1,...k):k?u[p]=k:u.splice(p,1)}return u.length>0?this:void 0}optimizeNames(u,p){const{nodes:k}=this;let M=k.length;for(;M--;){const D=k[M];D.optimizeNames(u,p)||(ge(u,D.names),k.splice(M,1))}return k.length>0?this:void 0}get names(){return this.nodes.reduce((u,p)=>H(u,p.names),{})}}class v extends _{render(u){return"{"+u._n+super.render(u)+"}"+u._n}}class y extends _{}class g extends v{}g.kind="else";class h extends v{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 k=p.optimizeNodes();p=this.else=Array.isArray(k)?new g(k):k}if(p)return u===!1?p instanceof h?p:p.nodes:this.nodes.length?this:new h(X(u),p instanceof h?[p]:p.nodes);if(!(u===!1||!this.nodes.length))return this}optimizeNames(u,p){var k;if(this.else=(k=this.else)===null||k===void 0?void 0:k.optimizeNames(u,p),!!(super.optimizeNames(u,p)||this.else))return this.condition=B(this.condition,u,p),this}get names(){const u=super.names;return ne(u,this.condition),this.else&&H(u,this.else.names),u}}h.kind="if";class w extends v{}w.kind="for";class E extends w{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=B(this.iteration,u,p),this}get names(){return H(super.names,this.iteration.names)}}class R extends w{constructor(u,p,k,M){super(),this.varKind=u,this.name=p,this.from=k,this.to=M}render(u){const p=u.es5?r.varKinds.var:this.varKind,{name:k,from:M,to:D}=this;return`for(${p} ${k}=${M}; ${k}<${D}; ${k}++)`+super.render(u)}get names(){const u=ne(super.names,this.from);return ne(u,this.to)}}class T extends w{constructor(u,p,k,M){super(),this.loop=u,this.varKind=p,this.name=k,this.iterable=M}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=B(this.iterable,u,p),this}get names(){return H(super.names,this.iterable.names)}}class C extends v{constructor(u,p,k){super(),this.name=u,this.args=p,this.async=k}render(u){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(u)}}C.kind="func";class x extends _{render(u){return"return "+super.render(u)}}x.kind="return";class U extends v{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 k,M;return super.optimizeNames(u,p),(k=this.catch)===null||k===void 0||k.optimizeNames(u,p),(M=this.finally)===null||M===void 0||M.optimizeNames(u,p),this}get names(){const u=super.names;return this.catch&&H(u,this.catch.names),this.finally&&H(u,this.finally.names),u}}class q extends v{constructor(u){super(),this.error=u}render(u){return`catch(${this.error})`+super.render(u)}}q.kind="catch";class V extends v{render(u){return"finally"+super.render(u)}}V.kind="finally";class z{constructor(u,p={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...p,_n:p.lines?` +`:""},this._extScope=u,this._scope=new r.Scope({parent:u}),this._nodes=[new 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 k=this._extScope.value(u,p);return(this._values[k.prefix]||(this._values[k.prefix]=new Set)).add(k),k}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,k,M){const D=this._scope.toName(p);return k!==void 0&&M&&(this._constants[D.str]=k),this._leafNode(new a(u,D,k)),D}const(u,p,k){return this._def(r.varKinds.const,u,p,k)}let(u,p,k){return this._def(r.varKinds.let,u,p,k)}var(u,p,k){return this._def(r.varKinds.var,u,p,k)}assign(u,p,k){return this._leafNode(new i(u,p,k))}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[k,M]of u)p.length>1&&p.push(","),p.push(k),(k!==M||this.opts.es5)&&(p.push(":"),(0,t.addCodeArg)(p,M));return p.push("}"),new t._Code(p)}if(u,p,k){if(this._blockNode(new h(u)),p&&k)this.code(p).else().code(k).endIf();else if(p)this.code(p).endIf();else if(k)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(u){return this._elseNode(new h(u))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(h,g)}_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,k,M,D=this.opts.es5?r.varKinds.var:r.varKinds.let){const J=this._scope.toName(u);return this._for(new R(D,J,p,k),()=>M(J))}forOf(u,p,k,M=r.varKinds.const){const D=this._scope.toName(u);if(this.opts.es5){const J=p instanceof t.Name?p:this.var("_arr",p);return this.forRange("_i",0,(0,t._)`${J}.length`,G=>{this.var(D,(0,t._)`${J}[${G}]`),k(D)})}return this._for(new T("of",M,D,p),()=>k(D))}forIn(u,p,k,M=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(u,(0,t._)`Object.keys(${p})`,k);const D=this._scope.toName(u);return this._for(new T("in",M,D,p),()=>k(D))}endFor(){return this._endBlockNode(w)}label(u){return this._leafNode(new l(u))}break(u){return this._leafNode(new d(u))}return(u){const p=new x;if(this._blockNode(p),this.code(u),p.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(x)}try(u,p,k){if(!p&&!k)throw new Error('CodeGen: "try" without "catch" and "finally"');const M=new U;if(this._blockNode(M),this.code(u),p){const D=this.name("e");this._currNode=M.catch=new q(D),p(D)}return k&&(this._currNode=M.finally=new V,this.code(k)),this._endBlockNode(q,V)}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 k=this._nodes.length-p;if(k<0||u!==void 0&&k!==u)throw new Error(`CodeGen: wrong number of nodes: ${k} vs ${u} expected`);return this._nodes.length=p,this}func(u,p=t.nil,k,M){return this._blockNode(new C(u,p,k)),M&&this.code(M).endFunc(),this}endFunc(){return this._endBlockNode(C)}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 k=this._currNode;if(k instanceof u||p&&k 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 H(S,u){for(const p in u)S[p]=(S[p]||0)+(u[p]||0);return S}function ne(S,u){return u instanceof t._CodeOrName?H(S,u.names):S}function B(S,u,p){if(S instanceof t.Name)return k(S);if(!M(S))return S;return new t._Code(S._items.reduce((D,J)=>(J instanceof t.Name&&(J=k(J)),J instanceof t._Code?D.push(...J._items):D.push(J),D),[]));function k(D){const J=p[D.str];return J===void 0||u[D.str]!==1?D:(delete u[D.str],J)}function M(D){return D instanceof t._Code&&D._items.some(J=>J instanceof t.Name&&u[J.str]===1&&p[J.str]!==void 0)}}function ge(S,u){for(const p in u)S[p]=(S[p]||0)-(u[p]||0)}function X(S){return typeof S=="boolean"||typeof S=="number"||S===null?!S:(0,t._)`!${j(S)}`}e.not=X;const oe=b(e.operators.AND);function We(...S){return S.reduce(oe)}e.and=We;const Be=b(e.operators.OR);function I(...S){return S.reduce(Be)}e.or=I;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})`}})(ue);var K={};Object.defineProperty(K,"__esModule",{value:!0});K.checkStrictMode=K.getErrorPath=K.Type=K.useFunc=K.setEvaluated=K.evaluatedPropsToName=K.mergeEvaluated=K.eachItem=K.unescapeJsonPointer=K.escapeJsonPointer=K.escapeFragment=K.unescapeFragment=K.schemaRefOrVal=K.schemaHasRulesButRef=K.schemaHasRules=K.checkUnknownRules=K.alwaysValidSchema=K.toHash=void 0;const $e=ue,DE=Pn;function qE(e){const t={};for(const r of e)t[r]=!0;return t}K.toHash=qE;function UE(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(Nf(e,t),!If(t,e.self.RULES.all))}K.alwaysValidSchema=UE;function Nf(e,t=e.schema){const{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;const s=n.RULES.keywords;for(const o in t)s[o]||Af(e,`unknown keyword: "${o}"`)}K.checkUnknownRules=Nf;function If(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(t[r])return!0;return!1}K.schemaHasRules=If;function FE(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}K.schemaHasRulesButRef=FE;function LE({topSchemaRef:e,schemaPath:t},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,$e._)`${r}`}return(0,$e._)`${e}${t}${(0,$e.getProperty)(n)}`}K.schemaRefOrVal=LE;function VE(e){return Of(decodeURIComponent(e))}K.unescapeFragment=VE;function HE(e){return encodeURIComponent(Hi(e))}K.escapeFragment=HE;function Hi(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}K.escapeJsonPointer=Hi;function Of(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}K.unescapeJsonPointer=Of;function ZE(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)}K.eachItem=ZE;function Nl({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(s,o,a,i)=>{const c=a===void 0?o:a instanceof $e.Name?(o instanceof $e.Name?e(s,o,a):t(s,o,a),a):o instanceof $e.Name?(t(s,a,o),o):r(o,a);return i===$e.Name&&!(c instanceof $e.Name)?n(s,c):c}}K.mergeEvaluated={props:Nl({mergeNames:(e,t,r)=>e.if((0,$e._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,$e._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,$e._)`${r} || {}`).code((0,$e._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,$e._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,$e._)`${r} || {}`),Zi(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:xf}),items:Nl({mergeNames:(e,t,r)=>e.if((0,$e._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,$e._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,$e._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,$e._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function xf(e,t){if(t===!0)return e.var("props",!0);const r=e.var("props",(0,$e._)`{}`);return t!==void 0&&Zi(e,r,t),r}K.evaluatedPropsToName=xf;function Zi(e,t,r){Object.keys(r).forEach(n=>e.assign((0,$e._)`${t}${(0,$e.getProperty)(n)}`,!0))}K.setEvaluated=Zi;const Il={};function KE(e,t){return e.scopeValue("func",{ref:t,code:Il[t.code]||(Il[t.code]=new DE._Code(t.code))})}K.useFunc=KE;var Go;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Go||(K.Type=Go={}));function GE(e,t,r){if(e instanceof $e.Name){const n=t===Go.Num;return r?n?(0,$e._)`"[" + ${e} + "]"`:(0,$e._)`"['" + ${e} + "']"`:n?(0,$e._)`"/" + ${e}`:(0,$e._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,$e.getProperty)(e).toString():"/"+Hi(e)}K.getErrorPath=GE;function Af(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}K.checkStrictMode=Af;var Et={};Object.defineProperty(Et,"__esModule",{value:!0});const Ze=ue,WE={data:new Ze.Name("data"),valCxt:new Ze.Name("valCxt"),instancePath:new Ze.Name("instancePath"),parentData:new Ze.Name("parentData"),parentDataProperty:new Ze.Name("parentDataProperty"),rootData:new Ze.Name("rootData"),dynamicAnchors:new Ze.Name("dynamicAnchors"),vErrors:new Ze.Name("vErrors"),errors:new Ze.Name("errors"),this:new Ze.Name("this"),self:new Ze.Name("self"),scope:new Ze.Name("scope"),json:new Ze.Name("json"),jsonPos:new Ze.Name("jsonPos"),jsonLen:new Ze.Name("jsonLen"),jsonPart:new Ze.Name("jsonPart")};Et.default=WE;(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=ue,r=K,n=Et;e.keywordError={message:({keyword:g})=>(0,t.str)`must pass "${g}" keyword validation`},e.keyword$DataError={message:({keyword:g,schemaType:h})=>h?(0,t.str)`"${g}" keyword must be ${h} ($data)`:(0,t.str)`"${g}" keyword is invalid ($data)`};function s(g,h=e.keywordError,w,E){const{it:R}=g,{gen:T,compositeRule:C,allErrors:x}=R,U=f(g,h,w);E??(C||x)?c(T,U):l(R,(0,t._)`[${U}]`)}e.reportError=s;function o(g,h=e.keywordError,w){const{it:E}=g,{gen:R,compositeRule:T,allErrors:C}=E,x=f(g,h,w);c(R,x),T||C||l(E,n.default.vErrors)}e.reportExtraError=o;function a(g,h){g.assign(n.default.errors,h),g.if((0,t._)`${n.default.vErrors} !== null`,()=>g.if(h,()=>g.assign((0,t._)`${n.default.vErrors}.length`,h),()=>g.assign(n.default.vErrors,null)))}e.resetErrorsCount=a;function i({gen:g,keyword:h,schemaValue:w,data:E,errsCount:R,it:T}){if(R===void 0)throw new Error("ajv implementation error");const C=g.name("err");g.forRange("i",R,n.default.errors,x=>{g.const(C,(0,t._)`${n.default.vErrors}[${x}]`),g.if((0,t._)`${C}.instancePath === undefined`,()=>g.assign((0,t._)`${C}.instancePath`,(0,t.strConcat)(n.default.instancePath,T.errorPath))),g.assign((0,t._)`${C}.schemaPath`,(0,t.str)`${T.errSchemaPath}/${h}`),T.opts.verbose&&(g.assign((0,t._)`${C}.schema`,w),g.assign((0,t._)`${C}.data`,E))})}e.extendErrors=i;function c(g,h){const w=g.const("err",h);g.if((0,t._)`${n.default.vErrors} === null`,()=>g.assign(n.default.vErrors,(0,t._)`[${w}]`),(0,t._)`${n.default.vErrors}.push(${w})`),g.code((0,t._)`${n.default.errors}++`)}function l(g,h){const{gen:w,validateName:E,schemaEnv:R}=g;R.$async?w.throw((0,t._)`new ${g.ValidationError}(${h})`):(w.assign((0,t._)`${E}.errors`,h),w.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(g,h,w){const{createErrors:E}=g.it;return E===!1?(0,t._)`{}`:m(g,h,w)}function m(g,h,w={}){const{gen:E,it:R}=g,T=[_(R,w),v(g,w)];return y(g,h,T),E.object(...T)}function _({errorPath:g},{instancePath:h}){const w=h?(0,t.str)`${g}${(0,r.getErrorPath)(h,r.Type.Str)}`:g;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,w)]}function v({keyword:g,it:{errSchemaPath:h}},{schemaPath:w,parentSchema:E}){let R=E?h:(0,t.str)`${h}/${g}`;return w&&(R=(0,t.str)`${R}${(0,r.getErrorPath)(w,r.Type.Str)}`),[d.schemaPath,R]}function y(g,{params:h,message:w},E){const{keyword:R,data:T,schemaValue:C,it:x}=g,{opts:U,propertyName:q,topSchemaRef:V,schemaPath:z}=x;E.push([d.keyword,R],[d.params,typeof h=="function"?h(g):h||(0,t._)`{}`]),U.messages&&E.push([d.message,typeof w=="function"?w(g):w]),U.verbose&&E.push([d.schema,C],[d.parentSchema,(0,t._)`${V}${z}`],[n.default.data,T]),q&&E.push([d.propertyName,q])}})(Un);Object.defineProperty(Lr,"__esModule",{value:!0});Lr.boolOrEmptySchema=Lr.topBoolOrEmptySchema=void 0;const BE=Un,JE=ue,QE=Et,YE={message:"boolean schema is false"};function XE(e){const{gen:t,schema:r,validateName:n}=e;r===!1?Mf(e,!1):typeof r=="object"&&r.$async===!0?t.return(QE.default.data):(t.assign((0,JE._)`${n}.errors`,null),t.return(!0))}Lr.topBoolOrEmptySchema=XE;function ek(e,t){const{gen:r,schema:n}=e;n===!1?(r.var(t,!1),Mf(e)):r.var(t,!0)}Lr.boolOrEmptySchema=ek;function Mf(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,BE.reportError)(s,YE,void 0,t)}var Oe={},$r={};Object.defineProperty($r,"__esModule",{value:!0});$r.getRules=$r.isJSONType=void 0;const tk=["string","number","integer","boolean","null","object","array"],rk=new Set(tk);function nk(e){return typeof e=="string"&&rk.has(e)}$r.isJSONType=nk;function sk(){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:{}}}$r.getRules=sk;var Rt={};Object.defineProperty(Rt,"__esModule",{value:!0});Rt.shouldUseRule=Rt.shouldUseGroup=Rt.schemaHasRulesForType=void 0;function ok({schema:e,self:t},r){const n=t.RULES.types[r];return n&&n!==!0&&zf(e,n)}Rt.schemaHasRulesForType=ok;function zf(e,t){return t.rules.some(r=>Df(e,r))}Rt.shouldUseGroup=zf;function Df(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}Rt.shouldUseRule=Df;Object.defineProperty(Oe,"__esModule",{value:!0});Oe.reportTypeError=Oe.checkDataTypes=Oe.checkDataType=Oe.coerceAndCheckDataType=Oe.getJSONTypes=Oe.getSchemaTypes=Oe.DataType=void 0;const ak=$r,ik=Rt,ck=Un,ce=ue,qf=K;var zr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(zr||(Oe.DataType=zr={}));function lk(e){const t=Uf(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}Oe.getSchemaTypes=lk;function Uf(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(ak.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Oe.getJSONTypes=Uf;function uk(e,t){const{gen:r,data:n,opts:s}=e,o=dk(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0,ik.schemaHasRulesForType)(e,t[0]));if(a){const i=Ki(t,n,s.strictNumbers,zr.Wrong);r.if(i,()=>{o.length?fk(e,t,o):Gi(e)})}return a}Oe.coerceAndCheckDataType=uk;const Ff=new Set(["string","number","integer","boolean","null"]);function dk(e,t){return t?e.filter(r=>Ff.has(r)||t==="array"&&r==="array"):[]}function fk(e,t,r){const{gen:n,data:s,opts:o}=e,a=n.let("dataType",(0,ce._)`typeof ${s}`),i=n.let("coerced",(0,ce._)`undefined`);o.coerceTypes==="array"&&n.if((0,ce._)`${a} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,ce._)`${s}[0]`).assign(a,(0,ce._)`typeof ${s}`).if(Ki(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0,ce._)`${i} !== undefined`);for(const l of r)(Ff.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),Gi(e),n.endIf(),n.if((0,ce._)`${i} !== undefined`,()=>{n.assign(s,i),hk(e,i)});function c(l){switch(l){case"string":n.elseIf((0,ce._)`${a} == "number" || ${a} == "boolean"`).assign(i,(0,ce._)`"" + ${s}`).elseIf((0,ce._)`${s} === null`).assign(i,(0,ce._)`""`);return;case"number":n.elseIf((0,ce._)`${a} == "boolean" || ${s} === null + || (${a} == "string" && ${s} && ${s} == +${s})`).assign(i,(0,ce._)`+${s}`);return;case"integer":n.elseIf((0,ce._)`${a} === "boolean" || ${s} === null + || (${a} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(i,(0,ce._)`+${s}`);return;case"boolean":n.elseIf((0,ce._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(i,!1).elseIf((0,ce._)`${s} === "true" || ${s} === 1`).assign(i,!0);return;case"null":n.elseIf((0,ce._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(i,null);return;case"array":n.elseIf((0,ce._)`${a} === "string" || ${a} === "number" + || ${a} === "boolean" || ${s} === null`).assign(i,(0,ce._)`[${s}]`)}}}function hk({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,ce._)`${t} !== undefined`,()=>e.assign((0,ce._)`${t}[${r}]`,n))}function Wo(e,t,r,n=zr.Correct){const s=n===zr.Correct?ce.operators.EQ:ce.operators.NEQ;let o;switch(e){case"null":return(0,ce._)`${t} ${s} null`;case"array":o=(0,ce._)`Array.isArray(${t})`;break;case"object":o=(0,ce._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=a((0,ce._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=a();break;default:return(0,ce._)`typeof ${t} ${s} ${e}`}return n===zr.Correct?o:(0,ce.not)(o);function a(i=ce.nil){return(0,ce.and)((0,ce._)`typeof ${t} == "number"`,i,r?(0,ce._)`isFinite(${t})`:ce.nil)}}Oe.checkDataType=Wo;function Ki(e,t,r,n){if(e.length===1)return Wo(e[0],t,r,n);let s;const o=(0,qf.toHash)(e);if(o.array&&o.object){const a=(0,ce._)`typeof ${t} != "object"`;s=o.null?a:(0,ce._)`!${t} || ${a}`,delete o.null,delete o.array,delete o.object}else s=ce.nil;o.number&&delete o.integer;for(const a in o)s=(0,ce.and)(s,Wo(a,t,r,n));return s}Oe.checkDataTypes=Ki;const pk={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,ce._)`{type: ${e}}`:(0,ce._)`{type: ${t}}`};function Gi(e){const t=mk(e);(0,ck.reportError)(t,pk)}Oe.reportTypeError=Gi;function mk(e){const{gen:t,data:r,schema:n}=e,s=(0,qf.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}var eo={};Object.defineProperty(eo,"__esModule",{value:!0});eo.assignDefaults=void 0;const Pr=ue,gk=K;function _k(e,t){const{properties:r,items:n}=e.schema;if(t==="object"&&r)for(const s in r)Ol(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>Ol(e,o,s.default))}eo.assignDefaults=_k;function Ol(e,t,r){const{gen:n,compositeRule:s,data:o,opts:a}=e;if(r===void 0)return;const i=(0,Pr._)`${o}${(0,Pr.getProperty)(t)}`;if(s){(0,gk.checkStrictMode)(e,`default is ignored for: ${i}`);return}let c=(0,Pr._)`${i} === undefined`;a.useDefaults==="empty"&&(c=(0,Pr._)`${c} || ${i} === null || ${i} === ""`),n.if(c,(0,Pr._)`${i} = ${(0,Pr.stringify)(r)}`)}var bt={},fe={};Object.defineProperty(fe,"__esModule",{value:!0});fe.validateUnion=fe.validateArray=fe.usePattern=fe.callValidateCode=fe.schemaProperties=fe.allSchemaProperties=fe.noPropertyInData=fe.propertyInData=fe.isOwnProperty=fe.hasPropFunc=fe.reportMissingProp=fe.checkMissingProp=fe.checkReportMissingProp=void 0;const Ee=ue,Wi=K,Nt=Et,yk=K;function vk(e,t){const{gen:r,data:n,it:s}=e;r.if(Ji(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Ee._)`${t}`},!0),e.error()})}fe.checkReportMissingProp=vk;function $k({gen:e,data:t,it:{opts:r}},n,s){return(0,Ee.or)(...n.map(o=>(0,Ee.and)(Ji(e,t,o,r.ownProperties),(0,Ee._)`${s} = ${o}`)))}fe.checkMissingProp=$k;function wk(e,t){e.setParams({missingProperty:t},!0),e.error()}fe.reportMissingProp=wk;function Lf(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Ee._)`Object.prototype.hasOwnProperty`})}fe.hasPropFunc=Lf;function Bi(e,t,r){return(0,Ee._)`${Lf(e)}.call(${t}, ${r})`}fe.isOwnProperty=Bi;function bk(e,t,r,n){const s=(0,Ee._)`${t}${(0,Ee.getProperty)(r)} !== undefined`;return n?(0,Ee._)`${s} && ${Bi(e,t,r)}`:s}fe.propertyInData=bk;function Ji(e,t,r,n){const s=(0,Ee._)`${t}${(0,Ee.getProperty)(r)} === undefined`;return n?(0,Ee.or)(s,(0,Ee.not)(Bi(e,t,r))):s}fe.noPropertyInData=Ji;function Vf(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}fe.allSchemaProperties=Vf;function Sk(e,t){return Vf(t).filter(r=>!(0,Wi.alwaysValidSchema)(e,t[r]))}fe.schemaProperties=Sk;function Ek({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:a},i,c,l){const d=l?(0,Ee._)`${e}, ${t}, ${n}${s}`:t,f=[[Nt.default.instancePath,(0,Ee.strConcat)(Nt.default.instancePath,o)],[Nt.default.parentData,a.parentData],[Nt.default.parentDataProperty,a.parentDataProperty],[Nt.default.rootData,Nt.default.rootData]];a.opts.dynamicRef&&f.push([Nt.default.dynamicAnchors,Nt.default.dynamicAnchors]);const m=(0,Ee._)`${d}, ${r.object(...f)}`;return c!==Ee.nil?(0,Ee._)`${i}.call(${c}, ${m})`:(0,Ee._)`${i}(${m})`}fe.callValidateCode=Ek;const kk=(0,Ee._)`new RegExp`;function Pk({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,Ee._)`${s.code==="new RegExp"?kk:(0,yk.useFunc)(e,s)}(${r}, ${n})`})}fe.usePattern=Pk;function Rk(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,Ee._)`${r}.length`);t.forRange("i",0,c,l=>{e.subschema({keyword:n,dataProp:l,dataPropType:Wi.Type.Num},o),t.if((0,Ee.not)(o),i)})}}fe.validateArray=Rk;function Tk(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,Wi.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,Ee._)`${a} || ${i}`),e.mergeValidEvaluated(d,i)||t.if((0,Ee.not)(a))})),e.result(a,()=>e.reset(),()=>e.error(!0))}fe.validateUnion=Tk;Object.defineProperty(bt,"__esModule",{value:!0});bt.validateKeywordUsage=bt.validSchemaType=bt.funcKeywordCode=bt.macroKeywordCode=void 0;const Ge=ue,dr=Et,jk=fe,Ck=Un;function Nk(e,t){const{gen:r,keyword:n,schema:s,parentSchema:o,it:a}=e,i=t.macro.call(a.self,s,o,a),c=Hf(r,n,i);a.opts.validateSchema!==!1&&a.self.validateSchema(i,!0);const l=r.name("valid");e.subschema({schema:i,schemaPath:Ge.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},l),e.pass(l,()=>e.error(!0))}bt.macroKeywordCode=Nk;function Ik(e,t){var r;const{gen:n,keyword:s,schema:o,parentSchema:a,$data:i,it:c}=e;xk(c,t);const l=!i&&t.compile?t.compile.call(c.self,o,a,c):t.validate,d=Hf(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&&xl(e),g(()=>e.error());else{const h=t.async?_():v();t.modifying&&xl(e),g(()=>Ok(e,h))}}function _(){const h=n.let("ruleErrs",null);return n.try(()=>y((0,Ge._)`await `),w=>n.assign(f,!1).if((0,Ge._)`${w} instanceof ${c.ValidationError}`,()=>n.assign(h,(0,Ge._)`${w}.errors`),()=>n.throw(w))),h}function v(){const h=(0,Ge._)`${d}.errors`;return n.assign(h,null),y(Ge.nil),h}function y(h=t.async?(0,Ge._)`await `:Ge.nil){const w=c.opts.passContext?dr.default.this:dr.default.self,E=!("compile"in t&&!i||t.schema===!1);n.assign(f,(0,Ge._)`${h}${(0,jk.callValidateCode)(e,d,w,E)}`,t.modifying)}function g(h){var w;n.if((0,Ge.not)((w=t.valid)!==null&&w!==void 0?w:f),h)}}bt.funcKeywordCode=Ik;function xl(e){const{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Ge._)`${n.parentData}[${n.parentDataProperty}]`))}function Ok(e,t){const{gen:r}=e;r.if((0,Ge._)`Array.isArray(${t})`,()=>{r.assign(dr.default.vErrors,(0,Ge._)`${dr.default.vErrors} === null ? ${t} : ${dr.default.vErrors}.concat(${t})`).assign(dr.default.errors,(0,Ge._)`${dr.default.vErrors}.length`),(0,Ck.extendErrors)(e)},()=>e.error())}function xk({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function Hf(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,Ge.stringify)(r)})}function Ak(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")}bt.validSchemaType=Ak;function Mk({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)}}bt.validateKeywordUsage=Mk;var qt={};Object.defineProperty(qt,"__esModule",{value:!0});qt.extendSubschemaMode=qt.extendSubschemaData=qt.getSubschema=void 0;const $t=ue,Zf=K;function zk(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,$t._)`${e.schemaPath}${(0,$t.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:i[r],schemaPath:(0,$t._)`${e.schemaPath}${(0,$t.getProperty)(t)}${(0,$t.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,Zf.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')}qt.getSubschema=zk;function Dk(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,$t._)`${t.data}${(0,$t.getProperty)(r)}`,!0);c(m),e.errorPath=(0,$t.str)`${l}${(0,Zf.getErrorPath)(r,n,f.jsPropertySyntax)}`,e.parentDataProperty=(0,$t._)`${r}`,e.dataPathArr=[...d,e.parentDataProperty]}if(s!==void 0){const l=s instanceof $t.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]}}qt.extendSubschemaData=Dk;function qk(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}qt.extendSubschemaMode=qk;var Ue={},Kf={exports:{}},Mt=Kf.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(){};ds(t,n,s,e,"",e)};Mt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Mt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Mt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Mt.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 ds(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 Mt.arrayKeywords)for(var m=0;mt+=Gf(n)),t===1/0))return 1/0}return t}function Wf(e,t="",r){r!==!1&&(t=Dr(t));const n=e.parse(t);return Bf(e,n)}Ue.getFullPath=Wf;function Bf(e,t){return e.serialize(t).split("#")[0]+"#"}Ue._getFullPath=Bf;const Wk=/#\/?$/;function Dr(e){return e?e.replace(Wk,""):""}Ue.normalizeId=Dr;function Bk(e,t,r){return r=Dr(r),e.resolve(t,r)}Ue.resolveUrl=Bk;const Jk=/^[a-z_][-a-z0-9._]*$/i;function Qk(e,t){if(typeof e=="boolean")return{};const{schemaId:r,uriResolver:n}=this.opts,s=Dr(e[r]||t),o={"":s},a=Wf(n,s,!1),i={},c=new Set;return Hk(e,{allKeys:!0},(f,m,_,v)=>{if(v===void 0)return;const y=a+m;let g=o[v];typeof f[r]=="string"&&(g=h.call(this,f[r])),w.call(this,f.$anchor),w.call(this,f.$dynamicAnchor),o[m]=g;function h(E){const R=this.opts.uriResolver.resolve;if(E=Dr(g?R(g,E):E),c.has(E))throw d(E);c.add(E);let T=this.refs[E];return typeof T=="string"&&(T=this.refs[T]),typeof T=="object"?l(f,T.schema,E):E!==Dr(y)&&(E[0]==="#"?(l(f,i[E],E),i[E]=f):this.refs[E]=y),E}function w(E){if(typeof E=="string"){if(!Jk.test(E))throw new Error(`invalid anchor "${E}"`);h.call(this,`#${E}`)}}}),i;function l(f,m,_){if(m!==void 0&&!Vk(f,m))throw d(_)}function d(f){return new Error(`reference "${f}" resolves to more than one schema`)}}Ue.getSchemaRefs=Qk;Object.defineProperty(_t,"__esModule",{value:!0});_t.getData=_t.KeywordCxt=_t.validateFunctionCode=void 0;const Jf=Lr,Al=Oe,Qi=Rt,Ts=Oe,Yk=eo,gn=bt,mo=qt,Y=ue,re=Et,Xk=Ue,Tt=K,nn=Un;function eP(e){if(Xf(e)&&(eh(e),Yf(e))){nP(e);return}Qf(e,()=>(0,Jf.topBoolOrEmptySchema)(e))}_t.validateFunctionCode=eP;function Qf({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},o){s.code.es5?e.func(t,(0,Y._)`${re.default.data}, ${re.default.valCxt}`,n.$async,()=>{e.code((0,Y._)`"use strict"; ${Ml(r,s)}`),rP(e,s),e.code(o)}):e.func(t,(0,Y._)`${re.default.data}, ${tP(s)}`,n.$async,()=>e.code(Ml(r,s)).code(o))}function tP(e){return(0,Y._)`{${re.default.instancePath}="", ${re.default.parentData}, ${re.default.parentDataProperty}, ${re.default.rootData}=${re.default.data}${e.dynamicRef?(0,Y._)`, ${re.default.dynamicAnchors}={}`:Y.nil}}={}`}function rP(e,t){e.if(re.default.valCxt,()=>{e.var(re.default.instancePath,(0,Y._)`${re.default.valCxt}.${re.default.instancePath}`),e.var(re.default.parentData,(0,Y._)`${re.default.valCxt}.${re.default.parentData}`),e.var(re.default.parentDataProperty,(0,Y._)`${re.default.valCxt}.${re.default.parentDataProperty}`),e.var(re.default.rootData,(0,Y._)`${re.default.valCxt}.${re.default.rootData}`),t.dynamicRef&&e.var(re.default.dynamicAnchors,(0,Y._)`${re.default.valCxt}.${re.default.dynamicAnchors}`)},()=>{e.var(re.default.instancePath,(0,Y._)`""`),e.var(re.default.parentData,(0,Y._)`undefined`),e.var(re.default.parentDataProperty,(0,Y._)`undefined`),e.var(re.default.rootData,re.default.data),t.dynamicRef&&e.var(re.default.dynamicAnchors,(0,Y._)`{}`)})}function nP(e){const{schema:t,opts:r,gen:n}=e;Qf(e,()=>{r.$comment&&t.$comment&&rh(e),cP(e),n.let(re.default.vErrors,null),n.let(re.default.errors,0),r.unevaluated&&sP(e),th(e),dP(e)})}function sP(e){const{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,Y._)`${r}.evaluated`),t.if((0,Y._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,Y._)`${e.evaluated}.props`,(0,Y._)`undefined`)),t.if((0,Y._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,Y._)`${e.evaluated}.items`,(0,Y._)`undefined`))}function Ml(e,t){const r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,Y._)`/*# sourceURL=${r} */`:Y.nil}function oP(e,t){if(Xf(e)&&(eh(e),Yf(e))){aP(e,t);return}(0,Jf.boolOrEmptySchema)(e,t)}function Yf({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 Xf(e){return typeof e.schema!="boolean"}function aP(e,t){const{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&rh(e),lP(e),uP(e);const o=n.const("_errs",re.default.errors);th(e,o),n.var(t,(0,Y._)`${o} === ${re.default.errors}`)}function eh(e){(0,Tt.checkUnknownRules)(e),iP(e)}function th(e,t){if(e.opts.jtd)return zl(e,[],!1,t);const r=(0,Al.getSchemaTypes)(e.schema),n=(0,Al.coerceAndCheckDataType)(e,r);zl(e,r,!n,t)}function iP(e){const{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,Tt.schemaHasRulesButRef)(t,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function cP(e){const{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Tt.checkStrictMode)(e,"default is ignored in the schema root")}function lP(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,Xk.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function uP(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function rh({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:s}){const o=r.$comment;if(s.$comment===!0)e.code((0,Y._)`${re.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){const a=(0,Y.str)`${n}/$comment`,i=e.scopeValue("root",{ref:t.root});e.code((0,Y._)`${re.default.self}.opts.$comment(${o}, ${a}, ${i}.schema)`)}}function dP(e){const{gen:t,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=e;r.$async?t.if((0,Y._)`${re.default.errors} === 0`,()=>t.return(re.default.data),()=>t.throw((0,Y._)`new ${s}(${re.default.vErrors})`)):(t.assign((0,Y._)`${n}.errors`,re.default.vErrors),o.unevaluated&&fP(e),t.return((0,Y._)`${re.default.errors} === 0`))}function fP({gen:e,evaluated:t,props:r,items:n}){r instanceof Y.Name&&e.assign((0,Y._)`${t}.props`,r),n instanceof Y.Name&&e.assign((0,Y._)`${t}.items`,n)}function zl(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,Tt.schemaHasRulesButRef)(o,d))){s.block(()=>oh(e,"$ref",d.all.$ref.definition));return}c.jtd||hP(e,t),s.block(()=>{for(const m of d.rules)f(m);f(d.post)});function f(m){(0,Qi.shouldUseGroup)(o,m)&&(m.type?(s.if((0,Ts.checkDataType)(m.type,a,c.strictNumbers)),Dl(e,m),t.length===1&&t[0]===m.type&&r&&(s.else(),(0,Ts.reportTypeError)(e)),s.endIf()):Dl(e,m),i||s.if((0,Y._)`${re.default.errors} === ${n||0}`))}}function Dl(e,t){const{gen:r,schema:n,opts:{useDefaults:s}}=e;s&&(0,Yk.assignDefaults)(e,t.type),r.block(()=>{for(const o of t.rules)(0,Qi.shouldUseRule)(n,o)&&oh(e,o.keyword,o.definition,t.type)})}function hP(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(pP(e,t),e.opts.allowUnionTypes||mP(e,t),gP(e,e.dataTypes))}function pP(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{nh(e.dataTypes,r)||Yi(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),yP(e,t)}}function mP(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Yi(e,"use allowUnionTypes to allow union type keyword")}function gP(e,t){const r=e.self.RULES.all;for(const n in r){const s=r[n];if(typeof s=="object"&&(0,Qi.shouldUseRule)(e.schema,s)){const{type:o}=s.definition;o.length&&!o.some(a=>_P(t,a))&&Yi(e,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function _P(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function nh(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function yP(e,t){const r=[];for(const n of e.dataTypes)nh(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function Yi(e,t){const r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,Tt.checkStrictMode)(e,t,e.opts.strictTypes)}class sh{constructor(t,r,n){if((0,gn.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,Tt.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",ah(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,gn.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",re.default.errors))}result(t,r,n){this.failResult((0,Y.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,Y.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,Y._)`${r} !== undefined && (${(0,Y.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?nn.reportExtraError:nn.reportError)(this,this.def.error,r)}$dataError(){(0,nn.reportError)(this,this.def.$dataError||nn.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,nn.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=Y.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=Y.nil,r=Y.nil){if(!this.$data)return;const{gen:n,schemaCode:s,schemaType:o,def:a}=this;n.if((0,Y.or)((0,Y._)`${s} === undefined`,r)),t!==Y.nil&&n.assign(t,!0),(o.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==Y.nil&&n.assign(t,!1)),n.else()}invalid$data(){const{gen:t,schemaCode:r,schemaType:n,def:s,it:o}=this;return(0,Y.or)(a(),i());function a(){if(n.length){if(!(r instanceof Y.Name))throw new Error("ajv implementation error");const c=Array.isArray(n)?n:[n];return(0,Y._)`${(0,Ts.checkDataTypes)(c,r,o.opts.strictNumbers,Ts.DataType.Wrong)}`}return Y.nil}function i(){if(s.validateSchema){const c=t.scopeValue("validate$data",{ref:s.validateSchema});return(0,Y._)`!${c}(${r})`}return Y.nil}}subschema(t,r){const n=(0,mo.getSubschema)(this.it,t);(0,mo.extendSubschemaData)(n,this.it,t),(0,mo.extendSubschemaMode)(n,t);const s={...this.it,...n,items:void 0,props:void 0};return oP(s,r),s}mergeEvaluated(t,r){const{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=Tt.mergeEvaluated.props(s,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=Tt.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,Y.Name)),!0}}_t.KeywordCxt=sh;function oh(e,t,r,n){const s=new sh(e,r,t);"code"in r?r.code(s,n):s.$data&&r.validate?(0,gn.funcKeywordCode)(s,r):"macro"in r?(0,gn.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,gn.funcKeywordCode)(s,r)}const vP=/^\/(?:[^~]|~0|~1)*$/,$P=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function ah(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,o;if(e==="")return re.default.rootData;if(e[0]==="/"){if(!vP.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,o=re.default.rootData}else{const l=$P.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,Y._)`${o}${(0,Y.getProperty)((0,Tt.unescapeJsonPointer)(l))}`,a=(0,Y._)`${a} && ${o}`);return a;function c(l,d){return`Cannot access ${l} ${d} levels up, current level is ${t}`}}_t.getData=ah;var Fn={};Object.defineProperty(Fn,"__esModule",{value:!0});class wP extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}}Fn.default=wP;var Br={};Object.defineProperty(Br,"__esModule",{value:!0});const go=Ue;class bP extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,go.resolveUrl)(t,r,n),this.missingSchema=(0,go.normalizeId)((0,go.getFullPath)(t,this.missingRef))}}Br.default=bP;var Xe={};Object.defineProperty(Xe,"__esModule",{value:!0});Xe.resolveSchema=Xe.getCompilingSchema=Xe.resolveRef=Xe.compileSchema=Xe.SchemaEnv=void 0;const dt=ue,SP=Fn,sr=Et,mt=Ue,ql=K,EP=_t;class to{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,mt.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={}}}Xe.SchemaEnv=to;function Xi(e){const t=ih.call(this,e);if(t)return t;const r=(0,mt.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,a=new dt.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o});let i;e.$async&&(i=a.scopeValue("Error",{ref:SP.default,code:(0,dt._)`require("ajv/dist/runtime/validation_error").default`}));const c=a.scopeName("validate");e.validateName=c;const l={gen:a,allErrors:this.opts.allErrors,data:sr.default.data,parentData:sr.default.parentData,parentDataProperty:sr.default.parentDataProperty,dataNames:[sr.default.data],dataPathArr:[dt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,dt.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:dt.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,dt._)`""`,opts:this.opts,self:this};let d;try{this._compilations.add(e),(0,EP.validateFunctionCode)(l),a.optimize(this.opts.code.optimize);const f=a.toString();d=`${a.scopeRefs(sr.default.scope)}return ${f}`,this.opts.code.process&&(d=this.opts.code.process(d,e));const _=new Function(`${sr.default.self}`,`${sr.default.scope}`,d)(this,this.scope.get());if(this.scope.value(c,{ref:_}),_.errors=null,_.schema=e.schema,_.schemaEnv=e,e.$async&&(_.$async=!0),this.opts.code.source===!0&&(_.source={validateName:c,validateCode:f,scopeValues:a._values}),this.opts.unevaluated){const{props:v,items:y}=l;_.evaluated={props:v instanceof dt.Name?void 0:v,items:y instanceof dt.Name?void 0:y,dynamicProps:v instanceof dt.Name,dynamicItems:y instanceof dt.Name},_.source&&(_.source.evaluated=(0,dt.stringify)(_.evaluated))}return e.validate=_,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)}}Xe.compileSchema=Xi;function kP(e,t,r){var n;r=(0,mt.resolveUrl)(this.opts.uriResolver,t,r);const s=e.refs[r];if(s)return s;let o=TP.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 to({schema:a,schemaId:i,root:e,baseId:t}))}if(o!==void 0)return e.refs[r]=PP.call(this,o)}Xe.resolveRef=kP;function PP(e){return(0,mt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Xi.call(this,e)}function ih(e){for(const t of this._compilations)if(RP(t,e))return t}Xe.getCompilingSchema=ih;function RP(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function TP(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||ro.call(this,e,t)}function ro(e,t){const r=this.opts.uriResolver.parse(t),n=(0,mt._getFullPath)(this.opts.uriResolver,r);let s=(0,mt.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===s)return _o.call(this,r,e);const o=(0,mt.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){const i=ro.call(this,e,a);return typeof(i==null?void 0:i.schema)!="object"?void 0:_o.call(this,r,i)}if(typeof(a==null?void 0:a.schema)=="object"){if(a.validate||Xi.call(this,a),o===(0,mt.normalizeId)(t)){const{schema:i}=a,{schemaId:c}=this.opts,l=i[c];return l&&(s=(0,mt.resolveUrl)(this.opts.uriResolver,s,l)),new to({schema:i,schemaId:c,root:e,baseId:s})}return _o.call(this,r,a)}}Xe.resolveSchema=ro;const jP=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function _o(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,ql.unescapeFragment)(i)];if(c===void 0)return;r=c;const l=typeof r=="object"&&r[this.opts.schemaId];!jP.has(i)&&l&&(t=(0,mt.resolveUrl)(this.opts.uriResolver,t,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,ql.schemaHasRulesButRef)(r,this.RULES)){const i=(0,mt.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=ro.call(this,n,i)}const{schemaId:a}=this.opts;if(o=o||new to({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}const CP="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",NP="Meta-schema for $data reference (JSON AnySchema extension proposal)",IP="object",OP=["$data"],xP={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},AP=!1,MP={$id:CP,description:NP,type:IP,required:OP,properties:xP,additionalProperties:AP};var ec={};Object.defineProperty(ec,"__esModule",{value:!0});const ch=yf;ch.code='require("ajv/dist/runtime/uri").default';ec.default=ch;(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=_t;Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=ue;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=Fn,s=Br,o=$r,a=Xe,i=ue,c=Ue,l=Oe,d=K,f=MP,m=ec,_=(I,b)=>new RegExp(I,b);_.code="new RegExp";const v=["removeAdditional","useDefaults","coerceTypes"],y=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),g={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.'},w=200;function E(I){var b,j,S,u,p,k,M,D,J,G,pe,tt,Lt,Vt,Ht,Zt,Kt,Gt,Wt,Bt,Jt,Qt,Yt,Xt,er;const lt=I.strict,tr=(b=I.code)===null||b===void 0?void 0:b.optimize,Yr=tr===!0||tr===void 0?1:tr||0,Xr=(S=(j=I.code)===null||j===void 0?void 0:j.regExp)!==null&&S!==void 0?S:_,oo=(u=I.uriResolver)!==null&&u!==void 0?u:m.default;return{strictSchema:(k=(p=I.strictSchema)!==null&&p!==void 0?p:lt)!==null&&k!==void 0?k:!0,strictNumbers:(D=(M=I.strictNumbers)!==null&&M!==void 0?M:lt)!==null&&D!==void 0?D:!0,strictTypes:(G=(J=I.strictTypes)!==null&&J!==void 0?J:lt)!==null&&G!==void 0?G:"log",strictTuples:(tt=(pe=I.strictTuples)!==null&&pe!==void 0?pe:lt)!==null&&tt!==void 0?tt:"log",strictRequired:(Vt=(Lt=I.strictRequired)!==null&&Lt!==void 0?Lt:lt)!==null&&Vt!==void 0?Vt:!1,code:I.code?{...I.code,optimize:Yr,regExp:Xr}:{optimize:Yr,regExp:Xr},loopRequired:(Ht=I.loopRequired)!==null&&Ht!==void 0?Ht:w,loopEnum:(Zt=I.loopEnum)!==null&&Zt!==void 0?Zt:w,meta:(Kt=I.meta)!==null&&Kt!==void 0?Kt:!0,messages:(Gt=I.messages)!==null&&Gt!==void 0?Gt:!0,inlineRefs:(Wt=I.inlineRefs)!==null&&Wt!==void 0?Wt:!0,schemaId:(Bt=I.schemaId)!==null&&Bt!==void 0?Bt:"$id",addUsedSchema:(Jt=I.addUsedSchema)!==null&&Jt!==void 0?Jt:!0,validateSchema:(Qt=I.validateSchema)!==null&&Qt!==void 0?Qt:!0,validateFormats:(Yt=I.validateFormats)!==null&&Yt!==void 0?Yt:!0,unicodeRegExp:(Xt=I.unicodeRegExp)!==null&&Xt!==void 0?Xt:!0,int32range:(er=I.int32range)!==null&&er!==void 0?er:!0,uriResolver:oo}}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=H(b.logger);const u=b.validateFormats;b.validateFormats=!1,this.RULES=(0,o.getRules)(),T.call(this,g,b,"NOT SUPPORTED"),T.call(this,h,b,"DEPRECATED","warn"),this._metaOpts=V.call(this),b.formats&&U.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),b.keywords&&q.call(this,b.keywords),typeof b.meta=="object"&&this.addMetaSchema(b.meta),x.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(G,pe){await p.call(this,G.$schema);const tt=this._addSchema(G,pe);return tt.validate||k.call(this,tt)}async function p(G){G&&!this.getSchema(G)&&await u.call(this,{$ref:G},!0)}async function k(G){try{return this._compileSchemaEnv(G)}catch(pe){if(!(pe instanceof s.default))throw pe;return M.call(this,pe),await D.call(this,pe.missingSchema),k.call(this,G)}}function M({missingSchema:G,missingRef:pe}){if(this.refs[G])throw new Error(`AnySchema ${G} is loaded but ${pe} cannot be resolved`)}async function D(G){const pe=await J.call(this,G);this.refs[G]||await p.call(this,pe.$schema),this.refs[G]||this.addSchema(pe,G,j)}async function J(G){const pe=this._loading[G];if(pe)return pe;try{return await(this._loading[G]=S(G))}finally{delete this._loading[G]}}}addSchema(b,j,S,u=this.opts.validateSchema){if(Array.isArray(b)){for(const k of b)this.addSchema(k,void 0,S,u);return this}let p;if(typeof b=="object"){const{schemaId:k}=this.opts;if(p=b[k],p!==void 0&&typeof p!="string")throw new Error(`schema ${k} 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=C.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=C.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(B.call(this,S,j),!j)return(0,d.eachItem)(S,p=>ge.call(this,p)),this;oe.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=>ge.call(this,p,u):p=>u.type.forEach(k=>ge.call(this,p,u,k))),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 k=b;for(const M of p)k=k[M];for(const M in S){const D=S[M];if(typeof D!="object")continue;const{$data:J}=D.definition,G=k[M];J&&G&&(k[M]=Be(G))}}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 k;const{schemaId:M}=this.opts;if(typeof b=="object")k=b[M];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 D=this._cache.get(b);if(D!==void 0)return D;S=(0,c.normalizeId)(k||S);const J=c.getSchemaRefs.call(this,b,S);return D=new a.SchemaEnv({schema:b,schemaId:M,meta:j,baseId:S,localRefs:J}),this._cache.set(D.schema,D),p&&!S.startsWith("#")&&(S&&this._checkUnique(S),this.refs[S]=D),u&&this.validateSchema(b,!0),D}_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 T(I,b,j,S="error"){for(const u in I){const p=u;p in b&&this.logger[S](`${j}: option ${u}. ${I[p]}`)}}function C(I){return I=(0,c.normalizeId)(I),this.schemas[I]||this.refs[I]}function x(){const I=this.opts.schemas;if(I)if(Array.isArray(I))this.addSchema(I);else for(const b in I)this.addSchema(I[b],b)}function U(){for(const I in this.opts.formats){const b=this.opts.formats[I];b&&this.addFormat(I,b)}}function q(I){if(Array.isArray(I)){this.addVocabulary(I);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const b in I){const j=I[b];j.keyword||(j.keyword=b),this.addKeyword(j)}}function V(){const I={...this.opts};for(const b of v)delete I[b];return I}const z={log(){},warn(){},error(){}};function H(I){if(I===!1)return z;if(I===void 0)return console;if(I.log&&I.warn&&I.error)return I;throw new Error("logger must implement log, warn and error methods")}const ne=/^[a-z_$][a-z0-9_$:-]*$/i;function B(I,b){const{RULES:j}=this;if((0,d.eachItem)(I,S=>{if(j.keywords[S])throw new Error(`Keyword ${S} is already defined`);if(!ne.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 ge(I,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 k=u?p.post:p.rules.find(({type:D})=>D===j);if(k||(k={type:j,rules:[]},p.rules.push(k)),p.keywords[I]=!0,!b)return;const M={keyword:I,definition:{...b,type:(0,l.getJSONTypes)(b.type),schemaType:(0,l.getJSONTypes)(b.schemaType)}};b.before?X.call(this,k,M,b.before):k.rules.push(M),p.all[I]=M,(S=b.implements)===null||S===void 0||S.forEach(D=>this.addKeyword(D))}function X(I,b,j){const S=I.rules.findIndex(u=>u.keyword===j);S>=0?I.rules.splice(S,0,b):(I.rules.push(b),this.logger.warn(`rule ${j} is not defined`))}function oe(I){let{metaSchema:b}=I;b!==void 0&&(I.$data&&this.opts.$data&&(b=Be(b)),I.validateSchema=this.compile(b,!0))}const We={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Be(I){return{anyOf:[I,We]}}})(Cf);var tc={},rc={},nc={};Object.defineProperty(nc,"__esModule",{value:!0});const zP={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};nc.default=zP;var wr={};Object.defineProperty(wr,"__esModule",{value:!0});wr.callRef=wr.getValidate=void 0;const DP=Br,Ul=fe,Qe=ue,Rr=Et,Fl=Xe,Xn=K,qP={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=Fl.resolveRef.call(c,l,s,r);if(d===void 0)throw new DP.default(n.opts.uriResolver,s,r);if(d instanceof Fl.SchemaEnv)return m(d);return _(d);function f(){if(o===l)return fs(e,a,o,o.$async);const v=t.scopeValue("root",{ref:l});return fs(e,(0,Qe._)`${v}.validate`,l,l.$async)}function m(v){const y=lh(e,v);fs(e,y,v,v.$async)}function _(v){const y=t.scopeValue("schema",i.code.source===!0?{ref:v,code:(0,Qe.stringify)(v)}:{ref:v}),g=t.name("valid"),h=e.subschema({schema:v,dataTypes:[],schemaPath:Qe.nil,topSchemaRef:y,errSchemaPath:r},g);e.mergeEvaluated(h),e.ok(g)}}};function lh(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Qe._)`${r.scopeValue("wrapper",{ref:t})}.validate`}wr.getValidate=lh;function fs(e,t,r,n){const{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:c}=o,l=c.passContext?Rr.default.this:Qe.nil;n?d():f();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");const v=s.let("valid");s.try(()=>{s.code((0,Qe._)`await ${(0,Ul.callValidateCode)(e,t,l)}`),_(t),a||s.assign(v,!0)},y=>{s.if((0,Qe._)`!(${y} instanceof ${o.ValidationError})`,()=>s.throw(y)),m(y),a||s.assign(v,!1)}),e.ok(v)}function f(){e.result((0,Ul.callValidateCode)(e,t,l),()=>_(t),()=>m(t))}function m(v){const y=(0,Qe._)`${v}.errors`;s.assign(Rr.default.vErrors,(0,Qe._)`${Rr.default.vErrors} === null ? ${y} : ${Rr.default.vErrors}.concat(${y})`),s.assign(Rr.default.errors,(0,Qe._)`${Rr.default.vErrors}.length`)}function _(v){var y;if(!o.opts.unevaluated)return;const g=(y=r==null?void 0:r.validate)===null||y===void 0?void 0:y.evaluated;if(o.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(o.props=Xn.mergeEvaluated.props(s,g.props,o.props));else{const h=s.var("props",(0,Qe._)`${v}.evaluated.props`);o.props=Xn.mergeEvaluated.props(s,h,o.props,Qe.Name)}if(o.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(o.items=Xn.mergeEvaluated.items(s,g.items,o.items));else{const h=s.var("items",(0,Qe._)`${v}.evaluated.items`);o.items=Xn.mergeEvaluated.items(s,h,o.items,Qe.Name)}}}wr.callRef=fs;wr.default=qP;Object.defineProperty(rc,"__esModule",{value:!0});const UP=nc,FP=wr,LP=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",UP.default,FP.default];rc.default=LP;var sc={},oc={};Object.defineProperty(oc,"__esModule",{value:!0});const js=ue,It=js.operators,Cs={maximum:{okStr:"<=",ok:It.LTE,fail:It.GT},minimum:{okStr:">=",ok:It.GTE,fail:It.LT},exclusiveMaximum:{okStr:"<",ok:It.LT,fail:It.GTE},exclusiveMinimum:{okStr:">",ok:It.GT,fail:It.LTE}},VP={message:({keyword:e,schemaCode:t})=>(0,js.str)`must be ${Cs[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,js._)`{comparison: ${Cs[e].okStr}, limit: ${t}}`},HP={keyword:Object.keys(Cs),type:"number",schemaType:"number",$data:!0,error:VP,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,js._)`${r} ${Cs[t].fail} ${n} || isNaN(${r})`)}};oc.default=HP;var ac={};Object.defineProperty(ac,"__esModule",{value:!0});const _n=ue,ZP={message:({schemaCode:e})=>(0,_n.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,_n._)`{multipleOf: ${e}}`},KP={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:ZP,code(e){const{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0,_n._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0,_n._)`${a} !== parseInt(${a})`;e.fail$data((0,_n._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};ac.default=KP;var ic={},cc={};Object.defineProperty(cc,"__esModule",{value:!0});function uh(e){const t=e.length;let r=0,n=0,s;for(;n=55296&&s<=56319&&n(0,fr._)`{limit: ${e}}`},JP={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:BP,code(e){const{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?fr.operators.GT:fr.operators.LT,a=s.opts.unicode===!1?(0,fr._)`${r}.length`:(0,fr._)`${(0,GP.useFunc)(e.gen,WP.default)}(${r})`;e.fail$data((0,fr._)`${a} ${o} ${n}`)}};ic.default=JP;var lc={};Object.defineProperty(lc,"__esModule",{value:!0});const QP=fe,YP=K,xr=ue,XP={message:({schemaCode:e})=>(0,xr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,xr._)`{pattern: ${e}}`},e1={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:XP,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,xr._)`new RegExp`:(0,YP.useFunc)(t,c),d=t.let("valid");t.try(()=>t.assign(d,(0,xr._)`${l}(${o}, ${i}).test(${r})`),()=>t.assign(d,!1)),e.fail$data((0,xr._)`!${d}`)}else{const c=(0,QP.usePattern)(e,s);e.fail$data((0,xr._)`!${c}.test(${r})`)}}};lc.default=e1;var uc={};Object.defineProperty(uc,"__esModule",{value:!0});const yn=ue,t1={message({keyword:e,schemaCode:t}){const r=e==="maxProperties"?"more":"fewer";return(0,yn.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,yn._)`{limit: ${e}}`},r1={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:t1,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?yn.operators.GT:yn.operators.LT;e.fail$data((0,yn._)`Object.keys(${r}).length ${s} ${n}`)}};uc.default=r1;var dc={};Object.defineProperty(dc,"__esModule",{value:!0});const sn=fe,vn=ue,n1=K,s1={message:({params:{missingProperty:e}})=>(0,vn.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,vn._)`{missingProperty: ${e}}`},o1={keyword:"required",type:"object",schemaType:"array",$data:!0,error:s1,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 _=e.parentSchema.properties,{definedProperties:v}=e.it;for(const y of r)if((_==null?void 0:_[y])===void 0&&!v.has(y)){const g=a.schemaEnv.baseId+a.errSchemaPath,h=`required property "${y}" is not defined at "${g}" (strictRequired)`;(0,n1.checkStrictMode)(a,h,a.opts.strictRequired)}}function l(){if(c||o)e.block$data(vn.nil,f);else for(const _ of r)(0,sn.checkReportMissingProp)(e,_)}function d(){const _=t.let("missing");if(c||o){const v=t.let("valid",!0);e.block$data(v,()=>m(_,v)),e.ok(v)}else t.if((0,sn.checkMissingProp)(e,r,_)),(0,sn.reportMissingProp)(e,_),t.else()}function f(){t.forOf("prop",n,_=>{e.setParams({missingProperty:_}),t.if((0,sn.noPropertyInData)(t,s,_,i.ownProperties),()=>e.error())})}function m(_,v){e.setParams({missingProperty:_}),t.forOf(_,n,()=>{t.assign(v,(0,sn.propertyInData)(t,s,_,i.ownProperties)),t.if((0,vn.not)(v),()=>{e.error(),t.break()})},vn.nil)}}};dc.default=o1;var fc={};Object.defineProperty(fc,"__esModule",{value:!0});const $n=ue,a1={message({keyword:e,schemaCode:t}){const r=e==="maxItems"?"more":"fewer";return(0,$n.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,$n._)`{limit: ${e}}`},i1={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:a1,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?$n.operators.GT:$n.operators.LT;e.fail$data((0,$n._)`${r}.length ${s} ${n}`)}};fc.default=i1;var hc={},Ln={};Object.defineProperty(Ln,"__esModule",{value:!0});const dh=Ws;dh.code='require("ajv/dist/runtime/equal").default';Ln.default=dh;Object.defineProperty(hc,"__esModule",{value:!0});const yo=Oe,ze=ue,c1=K,l1=Ln,u1={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}}`},d1={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:u1,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,yo.getSchemaTypes)(o.items):[];e.block$data(c,d,(0,ze._)`${a} === false`),e.ok(c);function d(){const v=t.let("i",(0,ze._)`${r}.length`),y=t.let("j");e.setParams({i:v,j:y}),t.assign(c,!0),t.if((0,ze._)`${v} > 1`,()=>(f()?m:_)(v,y))}function f(){return l.length>0&&!l.some(v=>v==="object"||v==="array")}function m(v,y){const g=t.name("item"),h=(0,yo.checkDataTypes)(l,g,i.opts.strictNumbers,yo.DataType.Wrong),w=t.const("indices",(0,ze._)`{}`);t.for((0,ze._)`;${v}--;`,()=>{t.let(g,(0,ze._)`${r}[${v}]`),t.if(h,(0,ze._)`continue`),l.length>1&&t.if((0,ze._)`typeof ${g} == "string"`,(0,ze._)`${g} += "_"`),t.if((0,ze._)`typeof ${w}[${g}] == "number"`,()=>{t.assign(y,(0,ze._)`${w}[${g}]`),e.error(),t.assign(c,!1).break()}).code((0,ze._)`${w}[${g}] = ${v}`)})}function _(v,y){const g=(0,c1.useFunc)(t,l1.default),h=t.name("outer");t.label(h).for((0,ze._)`;${v}--;`,()=>t.for((0,ze._)`${y} = ${v}; ${y}--;`,()=>t.if((0,ze._)`${g}(${r}[${v}], ${r}[${y}])`,()=>{e.error(),t.assign(c,!1).break(h)})))}}};hc.default=d1;var pc={};Object.defineProperty(pc,"__esModule",{value:!0});const Jo=ue,f1=K,h1=Ln,p1={message:"must be equal to constant",params:({schemaCode:e})=>(0,Jo._)`{allowedValue: ${e}}`},m1={keyword:"const",$data:!0,error:p1,code(e){const{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,Jo._)`!${(0,f1.useFunc)(t,h1.default)}(${r}, ${s})`):e.fail((0,Jo._)`${o} !== ${r}`)}};pc.default=m1;var mc={};Object.defineProperty(mc,"__esModule",{value:!0});const ln=ue,g1=K,_1=Ln,y1={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,ln._)`{allowedValues: ${e}}`},v1={keyword:"enum",schemaType:"array",$data:!0,error:y1,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,g1.useFunc)(t,_1.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 _=t.const("vSchema",o);d=(0,ln.or)(...s.map((v,y)=>m(_,y)))}e.pass(d);function f(){t.assign(d,!1),t.forOf("v",o,_=>t.if((0,ln._)`${l()}(${r}, ${_})`,()=>t.assign(d,!0).break()))}function m(_,v){const y=s[v];return typeof y=="object"&&y!==null?(0,ln._)`${l()}(${r}, ${_}[${v}])`:(0,ln._)`${r} === ${y}`}}};mc.default=v1;Object.defineProperty(sc,"__esModule",{value:!0});const $1=oc,w1=ac,b1=ic,S1=lc,E1=uc,k1=dc,P1=fc,R1=hc,T1=pc,j1=mc,C1=[$1.default,w1.default,b1.default,S1.default,E1.default,k1.default,P1.default,R1.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},T1.default,j1.default];sc.default=C1;var gc={},Jr={};Object.defineProperty(Jr,"__esModule",{value:!0});Jr.validateAdditionalItems=void 0;const hr=ue,Qo=K,N1={message:({params:{len:e}})=>(0,hr.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,hr._)`{limit: ${e}}`},I1={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:N1,code(e){const{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Qo.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}fh(e,n)}};function fh(e,t){const{gen:r,schema:n,data:s,keyword:o,it:a}=e;a.items=!0;const i=r.const("len",(0,hr._)`${s}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,hr._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0,Qo.alwaysValidSchema)(a,n)){const l=r.var("valid",(0,hr._)`${i} <= ${t.length}`);r.if((0,hr.not)(l),()=>c(l)),e.ok(l)}function c(l){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:Qo.Type.Num},l),a.allErrors||r.if((0,hr.not)(l),()=>r.break())})}}Jr.validateAdditionalItems=fh;Jr.default=I1;var _c={},Qr={};Object.defineProperty(Qr,"__esModule",{value:!0});Qr.validateTuple=void 0;const Ll=ue,hs=K,O1=fe,x1={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return hh(e,"additionalItems",t);r.items=!0,!(0,hs.alwaysValidSchema)(r,t)&&e.ok((0,O1.validateArray)(e))}};function hh(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=hs.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,hs.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:_}=i,v=r.length,y=v===f.minItems&&(v===f.maxItems||f[t]===!1);if(m.strictTuples&&!y){const g=`"${a}" is ${v}-tuple, but minItems or maxItems/${t} are not specified or different at path "${_}"`;(0,hs.checkStrictMode)(i,g,m.strictTuples)}}}Qr.validateTuple=hh;Qr.default=x1;Object.defineProperty(_c,"__esModule",{value:!0});const A1=Qr,M1={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,A1.validateTuple)(e,"items")};_c.default=M1;var yc={};Object.defineProperty(yc,"__esModule",{value:!0});const Vl=ue,z1=K,D1=fe,q1=Jr,U1={message:({params:{len:e}})=>(0,Vl.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Vl._)`{limit: ${e}}`},F1={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:U1,code(e){const{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=!0,!(0,z1.alwaysValidSchema)(n,t)&&(s?(0,q1.validateAdditionalItems)(e,s):e.ok((0,D1.validateArray)(e)))}};yc.default=F1;var vc={};Object.defineProperty(vc,"__esModule",{value:!0});const ot=ue,es=K,L1={message:({params:{min:e,max:t}})=>t===void 0?(0,ot.str)`must contain at least ${e} valid item(s)`:(0,ot.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,ot._)`{minContains: ${e}}`:(0,ot._)`{minContains: ${e}, maxContains: ${t}}`},V1={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:L1,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,ot._)`${s}.length`);if(e.setParams({min:a,max:i}),i===void 0&&a===0){(0,es.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0,es.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,es.alwaysValidSchema)(o,r)){let y=(0,ot._)`${d} >= ${a}`;i!==void 0&&(y=(0,ot._)`${y} && ${d} <= ${i}`),e.pass(y);return}o.items=!0;const f=t.name("valid");i===void 0&&a===1?_(f,()=>t.if(f,()=>t.break())):a===0?(t.let(f,!0),i!==void 0&&t.if((0,ot._)`${s}.length > 0`,m)):(t.let(f,!1),m()),e.result(f,()=>e.reset());function m(){const y=t.name("_valid"),g=t.let("count",0);_(y,()=>t.if(y,()=>v(g)))}function _(y,g){t.forRange("i",0,d,h=>{e.subschema({keyword:"contains",dataProp:h,dataPropType:es.Type.Num,compositeRule:!0},y),g()})}function v(y){t.code((0,ot._)`${y}++`),i===void 0?t.if((0,ot._)`${y} >= ${a}`,()=>t.assign(f,!0).break()):(t.if((0,ot._)`${y} > ${i}`,()=>t.assign(f,!1).break()),a===1?t.assign(f,!0):t.if((0,ot._)`${y} >= ${a}`,()=>t.assign(f,!0)))}}};vc.default=V1;var ph={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=ue,r=K,n=fe;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 _=d.let("missing");for(const v in l){const y=l[v];if(y.length===0)continue;const g=(0,n.propertyInData)(d,f,v,m.opts.ownProperties);c.setParams({property:v,depsCount:y.length,deps:y.join(", ")}),m.allErrors?d.if(g,()=>{for(const h of y)(0,n.checkReportMissingProp)(c,h)}):(d.if((0,t._)`${g} && (${(0,n.checkMissingProp)(c,y,_)})`),(0,n.reportMissingProp)(c,_),d.else())}}e.validatePropertyDeps=a;function i(c,l=c.schema){const{gen:d,data:f,keyword:m,it:_}=c,v=d.name("valid");for(const y in l)(0,r.alwaysValidSchema)(_,l[y])||(d.if((0,n.propertyInData)(d,f,y,_.opts.ownProperties),()=>{const g=c.subschema({keyword:m,schemaProp:y},v);c.mergeValidEvaluated(g,v)},()=>d.var(v,!0)),c.ok(v))}e.validateSchemaDeps=i,e.default=s})(ph);var $c={};Object.defineProperty($c,"__esModule",{value:!0});const mh=ue,H1=K,Z1={message:"property name must be valid",params:({params:e})=>(0,mh._)`{propertyName: ${e.propertyName}}`},K1={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Z1,code(e){const{gen:t,schema:r,data:n,it:s}=e;if((0,H1.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,mh.not)(o),()=>{e.error(!0),s.allErrors||t.break()})}),e.ok(o)}};$c.default=K1;var no={};Object.defineProperty(no,"__esModule",{value:!0});const ts=fe,ht=ue,G1=Et,rs=K,W1={message:"must NOT have additional properties",params:({params:e})=>(0,ht._)`{additionalProperty: ${e.additionalProperty}}`},B1={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:W1,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,rs.alwaysValidSchema)(a,r))return;const l=(0,ts.allSchemaProperties)(n.properties),d=(0,ts.allSchemaProperties)(n.patternProperties);f(),e.ok((0,ht._)`${o} === ${G1.default.errors}`);function f(){t.forIn("key",s,g=>{!l.length&&!d.length?v(g):t.if(m(g),()=>v(g))})}function m(g){let h;if(l.length>8){const w=(0,rs.schemaRefOrVal)(a,n.properties,"properties");h=(0,ts.isOwnProperty)(t,w,g)}else l.length?h=(0,ht.or)(...l.map(w=>(0,ht._)`${g} === ${w}`)):h=ht.nil;return d.length&&(h=(0,ht.or)(h,...d.map(w=>(0,ht._)`${(0,ts.usePattern)(e,w)}.test(${g})`))),(0,ht.not)(h)}function _(g){t.code((0,ht._)`delete ${s}[${g}]`)}function v(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){_(g);return}if(r===!1){e.setParams({additionalProperty:g}),e.error(),i||t.break();return}if(typeof r=="object"&&!(0,rs.alwaysValidSchema)(a,r)){const h=t.name("valid");c.removeAdditional==="failing"?(y(g,h,!1),t.if((0,ht.not)(h),()=>{e.reset(),_(g)})):(y(g,h),i||t.if((0,ht.not)(h),()=>t.break()))}}function y(g,h,w){const E={keyword:"additionalProperties",dataProp:g,dataPropType:rs.Type.Str};w===!1&&Object.assign(E,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(E,h)}}};no.default=B1;var wc={};Object.defineProperty(wc,"__esModule",{value:!0});const J1=_t,Hl=fe,vo=K,Zl=no,Q1={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&&Zl.default.code(new J1.KeywordCxt(o,Zl.default,"additionalProperties"));const a=(0,Hl.allSchemaProperties)(r);for(const f of a)o.definedProperties.add(f);o.opts.unevaluated&&a.length&&o.props!==!0&&(o.props=vo.mergeEvaluated.props(t,(0,vo.toHash)(a),o.props));const i=a.filter(f=>!(0,vo.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,Hl.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)}}};wc.default=Q1;var bc={};Object.defineProperty(bc,"__esModule",{value:!0});const Kl=fe,ns=ue,Gl=K,Wl=K,Y1={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,Kl.allSchemaProperties)(r),c=i.filter(y=>(0,Gl.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 ns.Name)&&(o.props=(0,Wl.evaluatedPropsToName)(t,o.props));const{props:f}=o;m();function m(){for(const y of i)l&&_(y),o.allErrors?v(y):(t.var(d,!0),v(y),t.if(d))}function _(y){for(const g in l)new RegExp(y).test(g)&&(0,Gl.checkStrictMode)(o,`property ${g} matches pattern ${y} (use allowMatchingProperties)`)}function v(y){t.forIn("key",n,g=>{t.if((0,ns._)`${(0,Kl.usePattern)(e,y)}.test(${g})`,()=>{const h=c.includes(y);h||e.subschema({keyword:"patternProperties",schemaProp:y,dataProp:g,dataPropType:Wl.Type.Str},d),o.opts.unevaluated&&f!==!0?t.assign((0,ns._)`${f}[${g}]`,!0):!h&&!o.allErrors&&t.if((0,ns.not)(d),()=>t.break())})})}}};bc.default=Y1;var Sc={};Object.defineProperty(Sc,"__esModule",{value:!0});const X1=K,eR={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,X1.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"}};Sc.default=eR;var Ec={};Object.defineProperty(Ec,"__esModule",{value:!0});const tR=fe,rR={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:tR.validateUnion,error:{message:"must match a schema in anyOf"}};Ec.default=rR;var kc={};Object.defineProperty(kc,"__esModule",{value:!0});const ps=ue,nR=K,sR={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,ps._)`{passingSchemas: ${e.passing}}`},oR={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:sR,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,nR.alwaysValidSchema)(s,d)?t.var(c,!0):m=e.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},c),f>0&&t.if((0,ps._)`${c} && ${a}`).assign(a,!1).assign(i,(0,ps._)`[${i}, ${f}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,f),m&&e.mergeEvaluated(m,ps.Name)})})}}};kc.default=oR;var Pc={};Object.defineProperty(Pc,"__esModule",{value:!0});const aR=K,iR={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,aR.alwaysValidSchema)(n,o))return;const i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i)})}};Pc.default=iR;var Rc={};Object.defineProperty(Rc,"__esModule",{value:!0});const Ns=ue,gh=K,cR={message:({params:e})=>(0,Ns.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,Ns._)`{failingKeyword: ${e.ifClause}}`},lR={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:cR,code(e){const{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,gh.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const s=Bl(n,"then"),o=Bl(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,Ns.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,Ns._)`${d}`):e.setParams({ifClause:d})}}}};function Bl(e,t){const r=e.schema[t];return r!==void 0&&!(0,gh.alwaysValidSchema)(e,r)}Rc.default=lR;var Tc={};Object.defineProperty(Tc,"__esModule",{value:!0});const uR=K,dR={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,uR.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Tc.default=dR;Object.defineProperty(gc,"__esModule",{value:!0});const fR=Jr,hR=_c,pR=Qr,mR=yc,gR=vc,_R=ph,yR=$c,vR=no,$R=wc,wR=bc,bR=Sc,SR=Ec,ER=kc,kR=Pc,PR=Rc,RR=Tc;function TR(e=!1){const t=[bR.default,SR.default,ER.default,kR.default,PR.default,RR.default,yR.default,vR.default,_R.default,$R.default,wR.default];return e?t.push(hR.default,mR.default):t.push(fR.default,pR.default),t.push(gR.default),t}gc.default=TR;var jc={},Cc={};Object.defineProperty(Cc,"__esModule",{value:!0});const Ne=ue,jR={message:({schemaCode:e})=>(0,Ne.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,Ne._)`{format: ${e}}`},CR={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:jR,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():_();function m(){const v=r.scopeValue("formats",{ref:f.formats,code:c.code.formats}),y=r.const("fDef",(0,Ne._)`${v}[${a}]`),g=r.let("fType"),h=r.let("format");r.if((0,Ne._)`typeof ${y} == "object" && !(${y} instanceof RegExp)`,()=>r.assign(g,(0,Ne._)`${y}.type || "string"`).assign(h,(0,Ne._)`${y}.validate`),()=>r.assign(g,(0,Ne._)`"string"`).assign(h,y)),e.fail$data((0,Ne.or)(w(),E()));function w(){return c.strictSchema===!1?Ne.nil:(0,Ne._)`${a} && !${h}`}function E(){const R=d.$async?(0,Ne._)`(${y}.async ? await ${h}(${n}) : ${h}(${n}))`:(0,Ne._)`${h}(${n})`,T=(0,Ne._)`(typeof ${h} == "function" ? ${R} : ${h}.test(${n}))`;return(0,Ne._)`${h} && ${h} !== true && ${g} === ${t} && !${T}`}}function _(){const v=f.formats[o];if(!v){w();return}if(v===!0)return;const[y,g,h]=E(v);y===t&&e.pass(R());function w(){if(c.strictSchema===!1){f.logger.warn(T());return}throw new Error(T());function T(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function E(T){const C=T instanceof RegExp?(0,Ne.regexpCode)(T):c.code.formats?(0,Ne._)`${c.code.formats}${(0,Ne.getProperty)(o)}`:void 0,x=r.scopeValue("formats",{key:o,ref:T,code:C});return typeof T=="object"&&!(T instanceof RegExp)?[T.type||"string",T.validate,(0,Ne._)`${x}.validate`]:["string",T,x]}function R(){if(typeof v=="object"&&!(v instanceof RegExp)&&v.async){if(!d.$async)throw new Error("async format in sync schema");return(0,Ne._)`await ${h}(${n})`}return typeof g=="function"?(0,Ne._)`${h}(${n})`:(0,Ne._)`${h}.test(${n})`}}}};Cc.default=CR;Object.defineProperty(jc,"__esModule",{value:!0});const NR=Cc,IR=[NR.default];jc.default=IR;var Vr={};Object.defineProperty(Vr,"__esModule",{value:!0});Vr.contentVocabulary=Vr.metadataVocabulary=void 0;Vr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Vr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(tc,"__esModule",{value:!0});const OR=rc,xR=sc,AR=gc,MR=jc,Jl=Vr,zR=[OR.default,xR.default,(0,AR.default)(),MR.default,Jl.metadataVocabulary,Jl.contentVocabulary];tc.default=zR;var Nc={},so={};Object.defineProperty(so,"__esModule",{value:!0});so.DiscrError=void 0;var Ql;(function(e){e.Tag="tag",e.Mapping="mapping"})(Ql||(so.DiscrError=Ql={}));Object.defineProperty(Nc,"__esModule",{value:!0});const Nr=ue,Yo=so,Yl=Xe,DR=Br,qR=K,UR={message:({params:{discrError:e,tagName:t}})=>e===Yo.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Nr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},FR={keyword:"discriminator",type:"object",schemaType:"object",error:UR,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,Nr._)`${r}${(0,Nr.getProperty)(i)}`);t.if((0,Nr._)`typeof ${l} == "string"`,()=>d(),()=>e.error(!1,{discrError:Yo.DiscrError.Tag,tag:l,tagName:i})),e.ok(c);function d(){const _=m();t.if(!1);for(const v in _)t.elseIf((0,Nr._)`${l} === ${v}`),t.assign(c,f(_[v]));t.else(),e.error(!1,{discrError:Yo.DiscrError.Mapping,tag:l,tagName:i}),t.endIf()}function f(_){const v=t.name("valid"),y=e.subschema({keyword:"oneOf",schemaProp:_},v);return e.mergeEvaluated(y,Nr.Name),v}function m(){var _;const v={},y=h(s);let g=!0;for(let R=0;Rthis.addVocabulary(v)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const v=this.opts.$data?this.$dataMetaSchema(o,a):o;this.addMetaSchema(v,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=_t;Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var d=ue;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=Fn;Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return f.default}});var m=Br;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return m.default}})})(Zo,Zo.exports);var BR=Zo.exports;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;const t=BR,r=ue,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:_,self:v}=m;if(!_.validateFormats)return;const y=new t.KeywordCxt(m,v.RULES.all.format.definition,"format");y.$data?g():h();function g(){const E=c.scopeValue("formats",{ref:v.formats,code:_.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"`,w(R)))}function h(){const E=y.schema,R=v.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 T=c.scopeValue("formats",{key:E,ref:R,code:_.code.formats?(0,r._)`${_.code.formats}${(0,r.getProperty)(E)}`:void 0});i.fail$data(w(T))}function w(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})(jf);(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r=Tf,n=jf,s=ue,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],_=d.formats||r.formatNames;return c(l,_,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 _,v;(_=(v=l.opts.code).formats)!==null&&_!==void 0||(v.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})(Ho,Ho.exports);var JR=Ho.exports;const QR=cu(JR);function YR(){const e=new zE({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return QR(e),e}class XR{constructor(t){this._ajv=t??YR()}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 eT{constructor(t){this._client=t}async*callToolStream(t,r=gr,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 ee(se.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 ee(se.InvalidParams,`Structured content does not match the tool's output schema: ${d.errorMessage}`)};return}}catch(d){if(d instanceof ee){yield{type:"error",error:d};return}yield{type:"error",error:new ee(se.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 tT(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 rT(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 ms(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&&ms(o,r[s])}}if(Array.isArray(e.anyOf))for(const r of e.anyOf)typeof r!="boolean"&&ms(r,t);if(Array.isArray(e.oneOf))for(const r of e.oneOf)typeof r!="boolean"&&ms(r,t)}}function nT(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 sT extends wd{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 XR,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",Wa,t.tools,async()=>(await this.listTools()).tools),t.prompts&&((o=(s=this._serverCapabilities)==null?void 0:s.prompts)!=null&&o.listChanged)&&this._setupListChangedHandler("prompts",Za,t.prompts,async()=>(await this.listPrompts()).prompts),t.resources&&((i=(a=this._serverCapabilities)==null?void 0:a.resources)!=null&&i.listChanged)&&this._setupListChangedHandler("resources",Ua,t.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new eT(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=r$(this._capabilities,t)}setRequestHandler(t,r){const n=vd(t),s=n==null?void 0:n.method;if(!s)throw new Error("Schema is missing a method literal");const o=$d(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 w,E;const d=Ot(gd,c);if(!d.success){const R=d.error instanceof Error?d.error.message:String(d.error);throw new ee(se.InvalidParams,`Invalid elicitation request: ${R}`)}const{params:f}=d.data;f.mode=f.mode??"form";const{supportsFormMode:m,supportsUrlMode:_}=nT(this._capabilities.elicitation);if(f.mode==="form"&&!m)throw new ee(se.InvalidParams,"Client does not support form-mode elicitation requests");if(f.mode==="url"&&!_)throw new ee(se.InvalidParams,"Client does not support URL-mode elicitation requests");const v=await Promise.resolve(r(c,l));if(f.task){const R=Ot(Sn,v);if(!R.success){const T=R.error instanceof Error?R.error.message:String(R.error);throw new ee(se.InvalidParams,`Invalid task creation result: ${T}`)}return R.data}const y=Ot(_d,v);if(!y.success){const R=y.error instanceof Error?y.error.message:String(y.error);throw new ee(se.InvalidParams,`Invalid elicitation result: ${R}`)}const g=y.data,h=f.mode==="form"?f.requestedSchema:void 0;if(f.mode==="form"&&g.action==="accept"&&g.content&&h&&(E=(w=this._capabilities.elicitation)==null?void 0:w.form)!=null&&E.applyDefaults)try{ms(h,g.content)}catch{}return g};return super.setRequestHandler(t,i)}if(a==="sampling/createMessage"){const i=async(c,l)=>{const d=Ot(Ba,c);if(!d.success){const g=d.error instanceof Error?d.error.message:String(d.error);throw new ee(se.InvalidParams,`Invalid sampling request: ${g}`)}const{params:f}=d.data,m=await Promise.resolve(r(c,l));if(f.task){const g=Ot(Sn,m);if(!g.success){const h=g.error instanceof Error?g.error.message:String(g.error);throw new ee(se.InvalidParams,`Invalid task creation result: ${h}`)}return g.data}const v=f.tools||f.toolChoice?md:pd,y=Ot(v,m);if(!y.success){const g=y.error instanceof Error?y.error.message:String(y.error);throw new ee(se.InvalidParams,`Invalid sampling result: ${g}`)}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:Vs,capabilities:this._capabilities,clientInfo:this._clientInfo}},Yu,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!Ny.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;tT((n=(r=this._serverCapabilities)==null?void 0:r.tasks)==null?void 0:n.requests,t,"Server")}assertTaskHandlerCapability(t){var r;this._capabilities&&rT((r=this._capabilities.tasks)==null?void 0:r.requests,t,"Client")}async ping(t){return this.request({method:"ping"},Ir,t)}async complete(t,r){return this.request({method:"completion/complete",params:t},yd,r)}async setLoggingLevel(t,r){return this.request({method:"logging/setLevel",params:{level:t}},Ir,r)}async getPrompt(t,r){return this.request({method:"prompts/get",params:t},ud,r)}async listPrompts(t,r){return this.request({method:"prompts/list",params:t},Fa,r)}async listResources(t,r){return this.request({method:"resources/list",params:t},Ma,r)}async listResourceTemplates(t,r){return this.request({method:"resources/templates/list",params:t},za,r)}async readResource(t,r){return this.request({method:"resources/read",params:t},qa,r)}async subscribeResource(t,r){return this.request({method:"resources/subscribe",params:t},Ir,r)}async unsubscribeResource(t,r){return this.request({method:"resources/unsubscribe",params:t},Ir,r)}async callTool(t,r=gr,n){if(this.isToolTaskRequired(t.name))throw new ee(se.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 ee(se.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 ee(se.InvalidParams,`Structured content does not match the tool's output schema: ${a.errorMessage}`)}catch(a){throw a instanceof ee?a:new ee(se.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},Ga,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(t,r,n,s){const o=yv.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 Ic={};/*! + * content-type + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */var Xl=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,oT=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,_h=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,aT=/\\([\u000b\u0020-\u00ff])/g,iT=/([\\"])/g,yh=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;Ic.format=cT;Ic.parse=lT;function cT(e){if(!e||typeof e!="object")throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!yh.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&&!oT.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(iT,"\\$1")+'"'}function fT(e){this.parameters=Object.create(null),this.type=e}function hT(e){if(e)try{return Ic.parse(e).type}catch{const t=(e.split(";",1)[0]??"").trim().toLowerCase();return t===""||e.slice(t.length).includes(",")?void 0:t}}function Xo(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function pT(e=fetch,t){return t?async(r,n)=>{const s={...t,...n,headers:n!=null&&n.headers?{...Xo(t.headers),...Xo(n.headers)}:t.headers};return e(r,s)}:e}let Oc;Oc=globalThis.crypto;async function mT(e){return(await Oc).getRandomValues(new Uint8Array(e))}async function gT(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 _T(e),r=await yT(t);return{code_verifier:t,code_challenge:r}}const De=D_().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:jy.custom,message:"URL must be parseable",fatal:!0}),Pp}).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"}),$T=Fe({resource:P().url(),authorization_servers:L(De).optional(),jwks_uri:P().url().optional(),scopes_supported:L(P()).optional(),bearer_methods_supported:L(P()).optional(),resource_signing_alg_values_supported:L(P()).optional(),resource_name:P().optional(),resource_documentation:P().optional(),resource_policy_uri:P().url().optional(),resource_tos_uri:P().url().optional(),tls_client_certificate_bound_access_tokens:_e().optional(),authorization_details_types_supported:L(P()).optional(),dpop_signing_alg_values_supported:L(P()).optional(),dpop_bound_access_tokens_required:_e().optional()}),vh=Fe({issuer:P(),authorization_endpoint:De,token_endpoint:De,registration_endpoint:De.optional(),scopes_supported:L(P()).optional(),response_types_supported:L(P()),response_modes_supported:L(P()).optional(),grant_types_supported:L(P()).optional(),token_endpoint_auth_methods_supported:L(P()).optional(),token_endpoint_auth_signing_alg_values_supported:L(P()).optional(),service_documentation:De.optional(),revocation_endpoint:De.optional(),revocation_endpoint_auth_methods_supported:L(P()).optional(),revocation_endpoint_auth_signing_alg_values_supported:L(P()).optional(),introspection_endpoint:P().optional(),introspection_endpoint_auth_methods_supported:L(P()).optional(),introspection_endpoint_auth_signing_alg_values_supported:L(P()).optional(),code_challenge_methods_supported:L(P()).optional(),client_id_metadata_document_supported:_e().optional()}),wT=Fe({issuer:P(),authorization_endpoint:De,token_endpoint:De,userinfo_endpoint:De.optional(),jwks_uri:De,registration_endpoint:De.optional(),scopes_supported:L(P()).optional(),response_types_supported:L(P()),response_modes_supported:L(P()).optional(),grant_types_supported:L(P()).optional(),acr_values_supported:L(P()).optional(),subject_types_supported:L(P()),id_token_signing_alg_values_supported:L(P()),id_token_encryption_alg_values_supported:L(P()).optional(),id_token_encryption_enc_values_supported:L(P()).optional(),userinfo_signing_alg_values_supported:L(P()).optional(),userinfo_encryption_alg_values_supported:L(P()).optional(),userinfo_encryption_enc_values_supported:L(P()).optional(),request_object_signing_alg_values_supported:L(P()).optional(),request_object_encryption_alg_values_supported:L(P()).optional(),request_object_encryption_enc_values_supported:L(P()).optional(),token_endpoint_auth_methods_supported:L(P()).optional(),token_endpoint_auth_signing_alg_values_supported:L(P()).optional(),display_values_supported:L(P()).optional(),claim_types_supported:L(P()).optional(),claims_supported:L(P()).optional(),service_documentation:P().optional(),claims_locales_supported:L(P()).optional(),ui_locales_supported:L(P()).optional(),claims_parameter_supported:_e().optional(),request_parameter_supported:_e().optional(),request_uri_parameter_supported:_e().optional(),require_request_uri_registration:_e().optional(),op_policy_uri:De.optional(),op_tos_uri:De.optional(),client_id_metadata_document_supported:_e().optional()}),bT=O({...wT.shape,...vh.pick({code_challenge_methods_supported:!0}).shape}),ST=O({access_token:P(),id_token:P().optional(),token_type:P(),expires_in:Cy().optional(),scope:P().optional(),refresh_token:P().optional()}).strip(),ET=O({error:P(),error_description:P().optional(),error_uri:P().optional()}),eu=De.optional().or(N("").transform(()=>{})),kT=O({redirect_uris:L(De),token_endpoint_auth_method:P().optional(),grant_types:L(P()).optional(),response_types:L(P()).optional(),client_name:P().optional(),client_uri:De.optional(),logo_uri:eu,scope:P().optional(),contacts:L(P()).optional(),tos_uri:eu,policy_uri:P().optional(),jwks_uri:De.optional(),jwks:ba().optional(),software_id:P().optional(),software_version:P().optional(),software_statement:P().optional()}).strip(),PT=O({client_id:P(),client_secret:P().optional(),client_id_issued_at:le().optional(),client_secret_expires_at:le().optional()}).strip(),RT=kT.merge(PT);O({error:P(),error_description:P().optional()}).strip();O({token:P(),token_type_hint:P().optional()}).strip();function TT(e){const t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function jT({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 FT(e,t,r,n){const s=new URL(e),o=(n==null?void 0:n.protocolVersion)??Vs;let a;if(n!=null&&n.metadataUrl)a=new URL(n.metadataUrl);else{const c=qT(t,s.pathname);a=new URL(c,(n==null?void 0:n.metadataServerUrl)??s),a.search=s.search}let i=await ru(a,o,r);if(!(n!=null&&n.metadataUrl)&&UT(i,s.pathname)){const c=new URL(`/.well-known/${t}`,s);i=await ru(c,o,r)}return i}function LT(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 bh(e,{fetchFn:t=fetch,protocolVersion:r=Vs}={}){var o;const n={"MCP-Protocol-Version":r,Accept:"application/json"},s=LT(e);for(const{url:a,type:i}of s){const c=await xc(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"?vh.parse(await c.json()):bT.parse(await c.json())}}}async function VT(e,t){let r,n;try{r=await wh(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 bh(n,{fetchFn:t==null?void 0:t.fetchFn});return{authorizationServerUrl:n,authorizationServerMetadata:s,resourceMetadata:r}}async function HT(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($o))throw new Error(`Incompatible auth server: does not support response type ${$o}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(wo))throw new Error(`Incompatible auth server: does not support code challenge method ${wo}`)}else i=new URL("/authorize",e);const c=await vT(),l=c.code_verifier,d=c.code_challenge;return i.searchParams.set("response_type",$o),i.searchParams.set("client_id",r.client_id),i.searchParams.set("code_challenge",d),i.searchParams.set("code_challenge_method",wo),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 ZT(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}async function Sh(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=IT(n,d);OT(f,n,c,r)}const l=await(a??fetch)(i,{method:"POST",headers:c,body:r});if(!l.ok)throw await $h(l);return ST.parse(await l.json())}async function KT(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 Sh(e,{metadata:t,tokenRequestParams:i,clientInformation:r,addClientAuthentication:o,resource:s,fetchFn:a});return{refresh_token:n,...c}}async function GT(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=ZT(s,l,e.redirectUrl)}const c=await e.clientInformation();return Sh(t,{metadata:r,tokenRequestParams:i,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:n,fetchFn:o})}async function WT(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 $h(a);return RT.parse(await a.json())}class Eo 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 nu=10,BT=13,or=32;function ko(e){}function JT(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=ko,onError:r=ko,onRetry:n=ko,onComment:s,maxBufferSize:o}=e,a=[];let i=0,c=!0,l,d="",f=0,m,_=!1;function v(T){if(_)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,T.charCodeAt(0)===239&&T.charCodeAt(1)===187&&T.charCodeAt(2)===191&&(T=T.slice(3))),a.length===0){const U=g(T);U!==""&&(a.push(U),i=U.length),y();return}if(T.indexOf(` +`)===-1&&T.indexOf("\r")===-1){a.push(T),i+=T.length,y();return}a.push(T);const C=a.join("");a.length=0,i=0;const x=g(C);x!==""&&(a.push(x),i=x.length),y()}function y(){o!==void 0&&(i+d.length<=o||(_=!0,a.length=0,i=0,l=void 0,d="",f=0,m=void 0,r(new Eo(`Buffered data exceeded max buffer size of ${o} characters`,{type:"max-buffer-size-exceeded"}))))}function g(T){let C=0;if(T.indexOf("\r")===-1){let x=T.indexOf(` +`,C);for(;x!==-1;){if(C===x){f>0&&t({id:l,event:m,data:d}),l=void 0,d="",f=0,m=void 0,C=x+1,x=T.indexOf(` +`,C);continue}const U=T.charCodeAt(C);if(su(T,C,U)){const q=T.charCodeAt(C+5)===or?C+6:C+5,V=T.slice(q,x);if(f===0&&T.charCodeAt(x+1)===nu){t({id:l,event:m,data:V}),l=void 0,d="",m=void 0,C=x+2,x=T.indexOf(` +`,C);continue}d=f===0?V:`${d} +${V}`,f++}else ou(T,C,U)?m=T.slice(T.charCodeAt(C+6)===or?C+7:C+6,x)||void 0:h(T,C,x);C=x+1,x=T.indexOf(` +`,C)}return T.slice(C)}for(;C20?`${T.slice(0,20)}…`:T}"`,{type:"unknown-field",field:T,value:C,line:x}));break}}function E(){f>0&&t({id:l,event:m,data:d}),l=void 0,d="",f=0,m=void 0}function R(T={}){if(T.consume&&a.length>0){const C=a.join("");h(C,0,C.length)}c=!0,l=void 0,d="",f=0,m=void 0,a.length=0,i=0,_=!1}return{feed:v,reset:R}}function su(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 ou(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 QT extends TransformStream{constructor({onError:t,onRetry:r,onComment:n,maxBufferSize:s}={}){let o;super({start(a){o=JT({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 YT={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class jr extends Error{constructor(t,r){super(`Streamable HTTP error: ${r}`),this.code=t}}class XT{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=pT(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)??YT}async _authThenStart(){var r;if(!this._authProvider)throw new Tr("No auth provider");let t;try{t=await ss(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 Tr;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=Xo((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 jr(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,_;try{const v=t.pipeThrough(new TextDecoderStream).pipeThrough(new QT({onRetry:h=>{this._serverRetryMs=h}})).getReader();for(;;){const{value:h,done:w}=await v.read();if(w)break;if(h.id&&(a=h.id,i=!0,s==null||s(h.id)),!!h.data&&(!h.event||h.event==="message"))try{const E=os.parse(JSON.parse(h.data));on(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(v){if((m=this.onerror)==null||m.call(this,new Error(`SSE stream disconnected: ${v}`)),(n||i)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:a,onresumptiontoken:s,replayMessageId:o},0)}catch(h){(_=this.onerror)==null||_.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 Tr("No auth provider");if(await ss(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Tr("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:Oo(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},_=await(this._fetch??fetch)(this._url,m),v=_.headers.get("mcp-session-id");if(v&&(this._sessionId=v),!_.ok){const E=await _.text().catch(()=>null);if(_.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new jr(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:R,scope:T}=tu(_);if(this._resourceMetadataUrl=R,this._scope=T,await ss(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Tr;return this._hasCompletedAuthFlow=!0,this.send(t)}if(_.status===403&&this._authProvider){const{resourceMetadataUrl:R,scope:T,error:C}=tu(_);if(C==="insufficient_scope"){const x=_.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===x)throw new jr(403,"Server returned 403 after trying upscoping");if(T&&(this._scope=T),R&&(this._resourceMetadataUrl=R),this._lastUpscopingHeader=x??void 0,await ss(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new Tr;return this.send(t)}}throw new jr(_.status,`Error POSTing to endpoint: ${E}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,_.status===202){await((s=_.body)==null?void 0:s.cancel()),Gy(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(E=>{var R;return(R=this.onerror)==null?void 0:R.call(this,E)});return}const g=(Array.isArray(t)?t:[t]).filter(E=>"method"in E&&"id"in E&&E.id!==void 0).length>0,h=_.headers.get("content-type"),w=hT(h);if(g)if(w==="text/event-stream")this._handleSseStream(_.body,{onresumptiontoken:d},!1);else if(w==="application/json"){const E=await _.json(),R=Array.isArray(E)?E.map(T=>os.parse(T)):[os.parse(E)];for(const T of R)(o=this.onmessage)==null||o.call(this,T)}else throw await((a=_.body)==null?void 0:a.cancel()),new jr(-1,`Unexpected content type: ${h}`);else await((i=_.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 jr(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 ej="https://mcp.excalidraw.com/mcp",tj="mcp.excalidraw.com",rj="/api/v1/chat/mcp-apps/excalidraw",Eh="ui://excalidraw/mcp-app.html",nj=["read_me","create_view"],kh=new Set(["export_to_excalidraw","save_checkpoint","read_checkpoint"]),sj=256*1024,oj=1024*1024,aj=1024*1024,ij=240,cj=720,lj=525;function uj(e){return!Number.isFinite(e)||e<=0?lj:Math.max(ij,Math.min(cj,Math.round(e*3/4)))}const dj={excalidraw:{id:"excalidraw",endpoint:ej,hostname:tj,resourceUri:Eh,modelTools:nj,appTools:kh}};function fj(e){return dj[e]}function hj(){return new URL(at(rj),window.location.origin)}class pj{constructor(){ae(this,"client",new sT({name:"pwc-chat-mcp-app-host",version:"1"}));ae(this,"transport",new XT(hj(),{requestInit:{credentials:"include"}}));ae(this,"connected");ae(this,"bytes",0);ae(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!==Eh)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,aj);const s=await yj(n.text);return{text:n.text,digest:s}}async callTool(t,r){if(!kh.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(),zt===this&&(zt=void 0)}consume(t,r=sj){const n=new TextEncoder().encode(t).byteLength;if(n>r||this.bytes+n>oj)throw new Error("App request exceeds host limit");this.bytes+=n}}let zt;function mj(){return zt??(zt=new pj),zt}function gj(){zt==null||zt.close(),zt=void 0}function _j(e){gj()}async function yj(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 vj(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 $j=({block:e})=>{const t=F.useRef(null),r=F.useRef(null),n=F.useRef(!1),s=F.useRef(e),o=F.useRef(!1);s.current=e;const[a,i]=F.useState(),[c,l]=F.useState("loading"),[d,f]=F.useState(e.height),[m,_]=F.useState(!1),[v,y]=F.useState(0),g=F.useRef(null),h=e.input.elements,w=!!e.permissions.clipboardWrite;o.current=m;const E=F.useCallback(()=>{_(!1),document.fullscreenElement&&document.exitFullscreen()},[]),R=F.useCallback(()=>{var x,U;if(m){E();return}_(!0),(U=(x=g.current)==null?void 0:x.requestFullscreen)==null||U.call(x).catch(()=>{})},[E,m]),T=F.useCallback(()=>{_j(),i(void 0),l("loading"),y(x=>x+1)},[]);F.useEffect(()=>{const x=g.current;if(!x)return;const U=()=>{o.current||f(uj(x.clientWidth))};U();const q=new ResizeObserver(U);return q.observe(x),()=>q.disconnect()},[]),F.useEffect(()=>{if(!m)return;const x=g.current,U=V=>{V.key==="Escape"&&(document.fullscreenElement||E())},q=()=>{document.fullscreenElement||_(!1)};return window.addEventListener("keydown",U),document.addEventListener("fullscreenchange",q),()=>{window.removeEventListener("keydown",U),document.removeEventListener("fullscreenchange",q),document.fullscreenElement===x&&document.exitFullscreen()}},[E,m]),F.useEffect(()=>{fj(e.provider);{l("unavailable");return}},[v,e.provider,e.resource_uri]),F.useEffect(()=>{if(!a||c!=="ready")return;const x=t.current;if(!x)return;let U=null;const q=[],V=vj(x,()=>{x.contentWindow&&(U=new k$(null,{name:"Papers with Code",version:"1"},{serverTools:{},openLinks:{},logging:{},...w?{clipboard:{write:{}}}:{}},{hostContext:{theme:document.documentElement.dataset.theme==="dark"?"dark":"light",displayMode:m?"fullscreen":"inline"}}),U.oncalltool=async({name:z,arguments:H})=>{if(s.current.public_fork&&z!=="export_to_excalidraw")throw new Error("Shared diagrams cannot mutate owner state");return mj().callTool(z,H??{})},U.onopenlink=async({url:z})=>{const H=new URL(z);if(H.protocol!=="https:"||H.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(H.href,"_blank","noopener,noreferrer"),{}},U.onsizechange=()=>{},U.oninitialized=()=>{n.current=!0;try{const z=JSON.parse(h),H={arguments:{elements:Array.isArray(z)?x$(z):z}};for(const ne of[0,50,200,750])q.push(window.setTimeout(()=>{r.current===U&&U.sendToolInput(H)},ne));U.sendToolResult(s.current.result)}catch{l("error")}},r.current=U,U.connect(new S$(x.contentWindow??void 0,x.contentWindow)).catch(()=>l("error")))});return()=>{V(),q.forEach(z=>window.clearTimeout(z)),n.current=!1,U==null||U.teardownResource({}).catch(()=>{}),r.current===U&&(r.current=null)}},[a,c,m,h,w,v]),F.useEffect(()=>{var x;c!=="ready"||!n.current||(x=r.current)==null||x.sendToolResult(e.result).catch(()=>{})},[e.result,c]);const C=c==="unavailable"||c==="incompatible"||c==="error";return $.jsxs("section",{ref:g,className:`chat-mcp-app${m?" chat-mcp-app-fullscreen":""}`,"aria-label":"Interactive Excalidraw diagram",children:[$.jsx("header",{children:$.jsx("button",{type:"button",onClick:R,children:m?"Exit fullscreen":"Fullscreen"})}),c==="loading"&&$.jsx("div",{className:"chat-mcp-loading",role:"status",children:"Loading interactive diagram…"}),C&&$.jsxs("div",{className:"chat-mcp-error",children:["Interactive diagram unavailable. The cited text answer is still available.",$.jsx("button",{type:"button",onClick:T,children:"Retry diagram"})]}),a&&c==="ready"&&$.jsx("iframe",{ref:t,title:"Interactive Excalidraw diagram",sandbox:"allow-scripts",allow:w?"clipboard-write":void 0,srcDoc:a,style:{height:d}},v)]})},Ph=()=>({open:!1,selectedKey:null,selected:null,selectedVersionId:null,tab:"preview",sourceFile:null,panelPercent:55,requestNonce:0,registry:{},autoOpened:{},manuallyClosed:{}});function wj(e,t){if(t.type==="reset")return{...Ph(),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 fa(e){return e.publication_id||e.public_capability||e.version_id||`${e.scope}:${e.identifier}:${e.version??"pending"}`}const Rh=F.createContext(null),cC=({children:e,workspaceKey:t,autoOpenOnMount:r=!1})=>{const[n,s]=F.useReducer(wj,void 0,Ph),o=F.useRef(null),a=F.useRef(t);F.useEffect(()=>{a.current!==t&&(a.current=t,o.current=null,s({type:"reset"}))},[t]);const i=F.useCallback(()=>{s({type:"close"}),window.setTimeout(()=>{var h;return(h=o.current)==null?void 0:h.focus()},0)},[]),c=F.useCallback(h=>s({type:"register",key:fa(h),block:h,autoOpenOnMount:r}),[r]),l=F.useCallback(h=>s({type:"unregister",key:h}),[]),d=F.useCallback((h,w)=>{o.current=w??null,s({type:"open",key:fa(h),block:h})},[]),f=F.useCallback(h=>s({type:"tab",tab:h}),[]),m=F.useCallback(h=>s({type:"source",path:h}),[]),_=F.useCallback(h=>s({type:"version",versionId:h}),[]),v=F.useCallback(h=>s({type:"width",percent:h}),[]),y=F.useCallback(()=>s({type:"reset"}),[]),g=F.useMemo(()=>({state:n,autoOpenOnMount:r,register:c,unregister:l,open:d,close:i,setTab:f,setSourceFile:m,setVersion:_,setPanelPercent:v,reset:y}),[r,i,d,c,y,v,m,f,_,n,l]);return $.jsx(Rh.Provider,{value:g,children:e})};function Vn(){const e=F.useContext(Rh);if(!e)throw new Error("Poster artifacts require an ArtifactPanelProvider");return e}function au(e,t,r){return at(`/api/v1/chat/artifacts/${encodeURIComponent(e)}/versions/${encodeURIComponent(t)}/source/${r.split("/").map(encodeURIComponent).join("/")}`)}const bj=({block:e,forceDialog:t=!1})=>{var R,T;const r=Vn(),n=r.close,[s,o]=F.useState(()=>{var C;return typeof window<"u"&&((C=window.matchMedia)==null?void 0:C.call(window,"(max-width: 760px)").matches)}),a=F.useRef(null),i=F.useRef(!1),c=t||s;F.useEffect(()=>{var U,q;const C=(U=window.matchMedia)==null?void 0:U.call(window,"(max-width: 760px)");if(!C)return;const x=()=>o(C.matches);return x(),(q=C.addEventListener)==null||q.call(C,"change",x),()=>{var V;return(V=C.removeEventListener)==null?void 0:V.call(C,"change",x)}},[]),F.useEffect(()=>{var U,q;if(!c)return;(q=(U=a.current)==null?void 0:U.querySelector("[data-artifact-close]"))==null||q.focus(),window.history.pushState({...window.history.state,pwcArtifactPanel:!0},""),i.current=!0;const C=()=>{i.current=!1,n()},x=V=>{V.key==="Escape"&&(V.preventDefault(),n(),i.current&&(i.current=!1,window.history.back()))};return window.addEventListener("popstate",C),document.addEventListener("keydown",x),()=>{window.removeEventListener("popstate",C),document.removeEventListener("keydown",x)}},[n,c]);const d=mr({queryKey:["chat-latex-paper",e.artifact_id],queryFn:async()=>{const C=await fetch(at(`/api/v1/chat/artifacts/${encodeURIComponent(e.artifact_id)}`),{credentials:"include",cache:"no-store"});if(!C.ok)throw new Error("Could not load paper details");return C.json()},enabled:!!e.artifact_id,staleTime:5e3}).data,f=d==null?void 0:d.source_head,m=d==null?void 0:d.preview_head,_=mr({queryKey:["chat-latex-paper-manifest",e.artifact_id,f==null?void 0:f.version_id],queryFn:async()=>{const C=await fetch(at(`/api/v1/chat/artifacts/${encodeURIComponent(e.artifact_id)}/versions/${encodeURIComponent(f.version_id)}/manifest`),{credentials:"include",cache:"no-store"});if(!C.ok)throw new Error("Could not load paper files");return C.json()},enabled:r.state.tab==="files"&&!!(f!=null&&f.version_id),staleTime:Number.POSITIVE_INFINITY}),v=r.state.sourceFile??((R=_.data)==null?void 0:R.root_document),y=mr({queryKey:["chat-latex-paper-source",e.artifact_id,f==null?void 0:f.version_id,v],queryFn:async()=>{const C=await fetch(au(e.artifact_id,f.version_id,v),{credentials:"include",cache:"no-store"});if(!C.ok)throw new Error("Could not load paper source");return C.text()},enabled:r.state.tab==="files"&&!!(f!=null&&f.version_id&&v),staleTime:Number.POSITIVE_INFINITY}),g=m?at(`/api/v1/chat/artifacts/${encodeURIComponent(e.artifact_id)}/versions/${encodeURIComponent(m.version_id)}/preview`):null,h=((T=_.data)==null?void 0:T.files.filter(C=>C.media_type==="text/x-tex"||C.media_type==="application/x-bibtex"))??[],w=!!(f&&m&&f.version_id!==m.version_id),E=()=>{n(),c&&i.current&&(i.current=!1,window.history.back())};return $.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:[$.jsxs("header",{children:[$.jsxs("div",{children:[$.jsx("span",{children:"Private paper"}),$.jsx("h2",{children:e.title})]}),$.jsx("button",{type:"button","data-artifact-close":!0,"aria-label":c?"Back to conversation":"Close paper",onClick:E,children:$.jsx(lu,{})})]}),$.jsxs("nav",{"aria-label":"Paper views",children:[$.jsx("button",{type:"button","aria-pressed":r.state.tab==="preview",className:r.state.tab==="preview"?"active":"",onClick:()=>r.setTab("preview"),children:"Preview"}),$.jsx("button",{type:"button","aria-pressed":r.state.tab==="files",className:r.state.tab==="files"?"active":"",onClick:()=>r.setTab("files"),children:"Files"})]}),$.jsx("div",{className:"chat-artifact-panel-body",children:r.state.tab==="preview"?g?$.jsx("iframe",{title:`Preview of ${e.title}`,src:g,className:"h-full w-full border-0"}):$.jsx("p",{children:"Preview is compiling. The stored source is available in Files."}):$.jsxs("div",{className:"chat-artifact-source-workspace",children:[$.jsx("nav",{"aria-label":"Paper source files",children:h.map(C=>$.jsx("button",{type:"button","aria-pressed":v===C.path,onClick:()=>r.setSourceFile(C.path),children:C.path},C.path))}),$.jsx("pre",{children:$.jsx("code",{children:y.isError?"Source could not be loaded.":y.data??"Loading source…"})})]})}),$.jsxs("footer",{children:[$.jsxs("div",{className:"chat-artifact-metadata",children:[w&&$.jsx("strong",{children:"Out of date"}),f&&$.jsxs("span",{children:["Source v",f.version," · ",f.compile_status]})]}),$.jsxs("div",{className:"chat-artifact-actions",children:[g&&$.jsxs("a",{href:g,download:!0,children:[$.jsx(Po,{})," PDF"]}),f&&v&&$.jsxs("a",{href:au(e.artifact_id,f.version_id,v),download:!0,children:[$.jsx(ma,{})," Source"]})]})]})]})},Sj="https://github.com/Chenruishuo/posterly/tree/b9f42e5578a49a27525a68f85376bb3bb25af86f";function Ej(){if(typeof window>"u")return null;const e=window.location.pathname.match(/^\/share\/([^/]+)/u);return e?decodeURIComponent(e[1]):null}function Th(e){if(e.scope==="public"){const n=Ej();if(!n||!e.public_capability)return null;const s=`/api/v1/chat/shares/${encodeURIComponent(n)}/artifacts/${encodeURIComponent(e.public_capability)}`;return{preview:at(`${s}/preview`),png:at(`${s}/download/png`),pdf:at(`${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)=>at(`${t}/${n}/${s.split("/").map(encodeURIComponent).join("/")}`);return{preview:at(`${t}/preview`),png:r("download","poster.png"),pdf:null,manifest:at(`${t}/manifest`),source:n=>r("source",n),gate:n=>r("source",n),download:n=>r("download",n)}}const jh=e=>({passed:"Passed",warnings:"Passed with warnings",failed:"Draft—checks failed"})[e??"passed"];function kj(){const[e,t]=F.useState(()=>{var r;return typeof window<"u"&&((r=window.matchMedia)==null?void 0:r.call(window,"(max-width: 760px)").matches)});return F.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 Pj=({forceDialog:e=!1,readerFallback:t=!1})=>{var T,C,x,U;const r=Vn(),n=r.close,{state:s}=r,o=s.selected,a=kj(),i=e||a,c=F.useRef(null),l=F.useRef(!1),d=mr({queryKey:["chat-artifact-versions",o==null?void 0:o.artifact_id],queryFn:async()=>{const q=await fetch(at(`/api/v1/chat/artifacts/${encodeURIComponent(o.artifact_id)}`),{credentials:"include",cache:"no-store"});if(!q.ok)throw new Error("Could not load poster versions");return(await q.json()).versions},enabled:s.open&&(o==null?void 0:o.scope)==="owner"&&!!o.artifact_id,staleTime:Number.POSITIVE_INFINITY}),f=(T=d.data)==null?void 0:T.find(q=>q.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,_=m?Th(m):null,y=mr({queryKey:["chat-artifact-manifest",m==null?void 0:m.version_id],queryFn:async()=>{const q=await fetch(_.manifest,{credentials:"include",cache:"no-store"});if(!q.ok)throw new Error("Could not load poster details");return q.json()},enabled:s.open&&(m==null?void 0:m.scope)==="owner"&&!!(_!=null&&_.manifest),staleTime:Number.POSITIVE_INFINITY}).data,g=s.sourceFile??(y==null?void 0:y.entrypoint)??null,h=mr({queryKey:["chat-artifact-source",m==null?void 0:m.version_id,g],queryFn:async()=>{const q=await fetch(_.source(g),{credentials:"include",cache:"no-store"});if(!q.ok)throw new Error("Source could not be loaded");return q.text()},enabled:s.open&&s.tab==="source"&&(m==null?void 0:m.scope)==="owner"&&!!(g&&(_!=null&&_.source)),staleTime:Number.POSITIVE_INFINITY});if(F.useEffect(()=>{var V,z;if(!s.open||!i)return;(z=(V=c.current)==null?void 0:V.querySelector("[data-artifact-close]"))==null||z.focus(),window.history.pushState({...window.history.state,pwcArtifactPanel:!0},""),l.current=!0;const q=()=>{l.current=!1,n()};return window.addEventListener("popstate",q),()=>window.removeEventListener("popstate",q)},[n,i,s.open]),F.useEffect(()=>{if(!s.open||!i)return;const q=V=>{if(V.key==="Escape"){V.preventDefault(),n(),l.current&&(l.current=!1,window.history.back());return}if(V.key!=="Tab"||!c.current)return;const z=[...c.current.querySelectorAll('button:not([disabled]), a[href], select:not([disabled]), [tabindex]:not([tabindex="-1"])')];if(!z.length)return;const H=z[0],ne=z.at(-1);V.shiftKey&&document.activeElement===H?(V.preventDefault(),ne.focus()):!V.shiftKey&&document.activeElement===ne&&(V.preventDefault(),H.focus())};return document.addEventListener("keydown",q),()=>document.removeEventListener("keydown",q)},[n,i,s.open]),!s.open||!m||!_)return null;const w=()=>{n(),i&&l.current&&(l.current=!1,window.history.back())},E=(C=y==null?void 0:y.downloads[0])==null?void 0:C.path,R=m.scope==="public"?_.pdf:E&&_.download?_.download(E):null;return $.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:[$.jsxs("header",{children:[$.jsxs("div",{children:[$.jsx("span",{children:"Posterly artifact"}),$.jsx("h2",{children:m.title})]}),(((x=d.data)==null?void 0:x.length)??0)>1&&$.jsxs("label",{className:"chat-artifact-version",children:["Version",$.jsx("select",{"aria-label":"Poster version",value:m.version_id,onChange:q=>r.setVersion(q.target.value),children:[...d.data??[]].reverse().map(q=>$.jsxs("option",{value:q.version_id,children:["v",q.version]},q.version_id))})]}),$.jsx("button",{type:"button","data-artifact-close":!0,"aria-label":i?"Back to conversation":"Close poster",onClick:w,children:$.jsx(lu,{})})]}),$.jsxs("nav",{"aria-label":"Poster views",children:[$.jsx("button",{type:"button","aria-pressed":s.tab==="preview",className:s.tab==="preview"?"active":"",onClick:()=>r.setTab("preview"),children:"Preview"}),m.scope==="owner"&&$.jsx("button",{type:"button","aria-pressed":s.tab==="source",className:s.tab==="source"?"active":"",onClick:()=>r.setTab("source"),children:"Source"})]}),$.jsx("div",{className:"chat-artifact-panel-body",children:s.tab==="preview"?$.jsx("img",{src:_.preview,alt:`Full preview of ${m.title}`}):$.jsxs("div",{className:"chat-artifact-source-workspace",children:[(((U=y==null?void 0:y.source_files)==null?void 0:U.length)??0)>1&&$.jsx("nav",{"aria-label":"Poster source files",children:y.source_files.map(q=>$.jsx("button",{type:"button","aria-pressed":g===q,onClick:()=>r.setSourceFile(q),children:q},q))}),$.jsx("pre",{children:$.jsx("code",{children:h.isError?"Source could not be loaded.":h.data??"Loading source…"})})]})}),$.jsxs("footer",{children:[$.jsxs("div",{className:"chat-artifact-metadata",children:[$.jsx("strong",{children:jh(m.gate_status)}),y&&$.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(q=>$.jsx("span",{children:q},q))]}),$.jsxs("div",{className:"chat-artifact-actions",children:[$.jsxs("a",{href:_.png,download:!0,children:[$.jsx(Po,{})," PNG"]}),m.gate_status!=="failed"&&R&&$.jsxs("a",{href:R,download:!0,children:[$.jsx(Po,{})," PDF"]}),m.scope==="owner"&&y&&_.source&&$.jsxs("a",{href:_.source(y.entrypoint),download:!0,children:[$.jsx(ma,{})," HTML"]}),m.scope==="owner"&&y&&_.gate&&$.jsx("a",{href:_.gate(y.gate_report),download:!0,children:"Gate report"}),$.jsxs("a",{href:Sj,target:"_blank",rel:"noreferrer",children:[$.jsx(Jh,{})," Posterly source · AGPL-3.0"]})]})]})]})},iu=e=>{var r;const{state:t}=Vn();return((r=t.selected)==null?void 0:r.artifact_kind)==="latex_paper"?$.jsx(bj,{block:t.selected,...e}):$.jsx(Pj,{...e})},Rj=({block:e})=>{const t=Vn(),r=t.register,n=t.unregister,s=fa(e);if(F.useEffect(()=>{r(e)},[e,r]),F.useEffect(()=>()=>n(s),[s,n]),e.status==="generating")return $.jsxs("div",{className:"chat-artifact-card chat-artifact-generating",role:"status",children:[$.jsx("span",{className:"chat-artifact-pulse","aria-hidden":"true"}),$.jsxs("span",{children:[$.jsx("strong",{children:e.title}),$.jsx("small",{children:"Publishing Posterly preview…"})]})]});if(e.status==="error")return $.jsxs("div",{className:"chat-artifact-card chat-artifact-error",role:"alert",children:[$.jsx(ma,{"aria-hidden":"true"}),$.jsxs("span",{children:[$.jsx("strong",{children:e.title}),$.jsx("small",{children:e.error_message??"Poster publication failed."})]})]});const o=Th(e);if(!o)return null;const a=t.state.open&&t.state.selectedKey===s;return $.jsxs("button",{type:"button",className:`chat-artifact-card${a?" is-selected":""}`,"aria-pressed":a,onClick:i=>t.open(e,i.currentTarget),children:[$.jsx("img",{src:o.preview,alt:`Preview of ${e.title}`}),$.jsxs("span",{className:"chat-artifact-card-copy",children:[$.jsxs("span",{className:"chat-artifact-kicker",children:[$.jsx(Yh,{"aria-hidden":"true"})," Posterly · v",e.version]}),$.jsx("strong",{children:e.title}),$.jsx("small",{className:`chat-artifact-gate chat-artifact-gate-${e.gate_status}`,children:jh(e.gate_status)})]})]})};function Tj(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 jj(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 Cj(e,t=240){const r=e.content.trim();return r.length<=t?r:`${r.slice(0,t).trimEnd()}…`}const Nj="https://huggingface.co/pro",Ij="https://huggingface.co/docs/inference-providers/pricing",Oj="https://paperswithcode.co/chat",Ch=()=>$.jsx("span",{className:"chat-caret"}),xj=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},Aj=e=>{var _,v;const t=e.currentTarget,r=t.ownerDocument,n=(_=r.caretPositionFromPoint)==null?void 0:_.call(r,e.clientX,e.clientY),s=n?null:(v=r.caretRangeFromPoint)==null?void 0:v.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($.jsxs("span",{className:"chat-inline-paper-mention",children:[$.jsx(Bh,{size:13,"aria-hidden":"true"}),$.jsx(pu,{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)),$.jsx($.Fragment,{children:r})},zj=({block:e,papers:t,citations:r,webCitations:n,onToggle:s})=>e.active?$.jsxs("div",{className:"chat-reason-live",children:[$.jsxs("div",{className:"chat-reason-live-head",children:[$.jsx(ha,{})," ",$.jsx("span",{children:"Thinking…"})]}),$.jsxs("div",{className:"chat-reason-live-body chat-answer chat-reason-markdown",children:[$.jsx(Ro,{text:e.text,streaming:!0,papers:t,citations:r,webCitations:n}),$.jsx(Ch,{})]})]}):$.jsxs("div",{className:"chat-reason-done",children:[$.jsxs("button",{type:"button",className:"chat-reason-done-head",onClick:s,"aria-expanded":e.open,children:[$.jsx(Uh,{}),$.jsx("span",{children:"Thought for a few seconds"}),$.jsx(hu,{open:e.open})]}),e.open&&$.jsx("div",{className:"chat-reason-done-body chat-answer chat-reason-markdown",children:$.jsx(Ro,{text:e.text,papers:t,citations:r,webCitations:n})})]}),Dj=({block:e,papers:t,onToggle:r})=>{var f,m,_,v;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 $.jsxs("div",{className:`chat-tool${n?" chat-tool-running":""}${a?" chat-tool-failed":""}`,children:[$.jsxs("button",{type:"button",className:"chat-tool-head",onClick:r,"aria-expanded":e.open,children:[$.jsxs("span",{className:"chat-tool-head-left",children:[n?$.jsx(ha,{}):$.jsx(Fh,{}),$.jsx("code",{className:"chat-tool-name",children:e.name}),$.jsx("span",{className:"chat-tool-query",children:o?c:`("${i}")`})]}),$.jsxs("span",{className:"chat-tool-head-right",children:[$.jsx("span",{className:"chat-tool-status",children:d}),$.jsx(hu,{open:e.open})]})]}),e.open&&$.jsxs("div",{className:"chat-tool-body",children:[$.jsxs("div",{className:"chat-tool-args",children:[$.jsxs("span",{className:"chat-tool-label",children:["arguments",e.arguments_redacted?" · redacted":""]}),$.jsx("pre",{children:e.argumentState==="streaming"&&!e.arguments_redacted&&e.argumentText||JSON.stringify(e.args,null,2)})]}),!n&&o?$.jsxs($.Fragment,{children:[$.jsxs("div",{className:"chat-tool-output-head",children:[$.jsx("span",{className:"chat-tool-label",children:"result"}),$.jsx("button",{type:"button",className:"chat-tool-copy",onClick:()=>void navigator.clipboard.writeText(l),children:"Copy"})]}),$.jsx("pre",{className:"chat-tool-output",children:$.jsx("code",{children:l})}),((m=e.metadata)==null?void 0:m.output_truncated)&&$.jsx("div",{className:"chat-tool-truncated",children:"Output was truncated."})]}):n?null:$.jsxs($.Fragment,{children:[$.jsxs("div",{className:"chat-tool-label chat-tool-results-label",children:["returned ",((_=e.results)==null?void 0:_.length)??0," papers"]}),$.jsx("ol",{className:"chat-tool-results",children:(v=e.results)==null?void 0:v.map(y=>$.jsxs("li",{className:"chat-hit",children:[$.jsx("div",{className:"chat-hit-top",children:$.jsx(gu,{routeId:y.route_id,paper:t[y.route_id],className:"chat-hit-title",children:y.title})}),$.jsx("div",{className:"chat-hit-meta",children:[Tj(y.metadata),jj(y.metadata)].filter(Boolean).join(" · ")}),$.jsxs("div",{className:"chat-hit-snippet",children:[Cj(y),y.content_truncated&&$.jsx("span",{className:"chat-hit-truncated",children:" (truncated)"})]})]},y.route_id))})]})]})]})},qj=({block:e,papers:t,citations:r,webCitations:n,streaming:s})=>$.jsxs("div",{className:"chat-answer",children:[$.jsx(Ro,{text:e.text,streaming:s,papers:t,citations:r,webCitations:n}),s&&!!e.text.trim()&&$.jsx(Ch,{})]}),Uj=({block:e})=>$.jsx($j,{block:e}),Nh=e=>{const t=F.useRef(null),r=F.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 F.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}},Fj=({id:e,text:t,paperSelection:r,editNotice:n,onCancel:s,onResend:o,onResendDraft:a})=>{const[i,c]=F.useState(t),[l,d]=F.useState(r),[f,m]=F.useState(!1),{textareaRef:_,resize:v}=Nh(t);F.useLayoutEffect(v,[v,i]);const y=!!i.trim()&&i.length<=8e3,g=()=>{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 $.jsx("div",{className:"chat-msg chat-msg-user chat-msg-user-editing","data-message-id":e,children:$.jsxs("div",{className:"chat-inline-editor",children:[l&&$.jsx(qs,{selection:l,editable:!0,onRemove:()=>d(void 0)}),$.jsx("textarea",{ref:_,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(),g())}}),n&&$.jsx("div",{className:"chat-inline-editor-notice",children:n}),$.jsxs("div",{className:"chat-inline-editor-actions",children:[$.jsx("button",{type:"button",onClick:s,children:"Cancel"}),$.jsx("button",{type:"button",className:"chat-inline-editor-send",disabled:!y||f,onClick:g,children:"Send"})]})]})})},Lj=({id:e,text:t,paperMentions:r,paperSelection:n,enabled:s,editNotice:o,onCancel:a,onResend:i,onResendDraft:c})=>{const[l,d]=F.useState({text:t,paperMentions:r,...n?{paperSelection:n}:{}}),[f,m]=F.useState(!1),[_,v]=F.useState(0),{textareaRef:y,resize:g}=Nh(t),h=uu({draft:l,onChange:d,enabled:s,textareaRef:y});F.useLayoutEffect(g,[g,l.text]);const w=!!l.text.trim()&&l.text.length<=8e3&&(s||l.paperMentions.length===0),E=()=>{if(!w||f)return;m(!0),((c==null?void 0:c(l))??(i==null?void 0:i(l.text))??!1)||m(!1)};return $.jsx("div",{className:"chat-msg chat-msg-user chat-msg-user-editing","data-message-id":e,children:$.jsxs("div",{className:"chat-inline-editor",children:[l.paperSelection&&$.jsx(qs,{selection:l.paperSelection,editable:!0,onRemove:()=>d({text:l.text,paperMentions:l.paperMentions})}),$.jsxs("div",{className:"chat-inline-editor-textarea-wrap",children:[$.jsx(du,{text:l.text,mentions:l.paperMentions,scrollTop:_,variant:"editor"}),$.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=>v(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()))}}),$.jsx(fu,{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&&$.jsx("div",{className:"chat-inline-editor-notice",role:"status",children:"Paper mentions are currently disabled. Remove them before sending."}),o&&$.jsx("div",{className:"chat-inline-editor-notice",children:o}),$.jsxs("div",{className:"chat-inline-editor-actions",children:[$.jsx("button",{type:"button",onClick:a,children:"Cancel"}),$.jsx("button",{type:"button",className:"chat-inline-editor-send",disabled:!w||f,onClick:E,children:"Send"})]})]})})},lC=({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,_]=F.useState(!1),v=F.useRef(null);F.useEffect(()=>()=>{v.current!==null&&window.clearTimeout(v.current)},[]);const y=async()=>{var g;if((g=navigator.clipboard)!=null&&g.writeText)try{await navigator.clipboard.writeText(t),_(!0),v.current!==null&&window.clearTimeout(v.current),v.current=window.setTimeout(()=>_(!1),1500)}catch{}};return a?!s&&r.length===0?$.jsx(Fj,{id:e,text:t,paperSelection:n,editNotice:i,onCancel:l,onResend:d,onResendDraft:f}):$.jsx(Lj,{id:e,text:t,paperMentions:r,paperSelection:n,enabled:s,editNotice:i,onCancel:l,onResend:d,onResendDraft:f}):$.jsx("div",{className:"chat-msg chat-msg-user","data-message-id":e,children:$.jsxs("div",{className:"chat-user-message-wrap",children:[n&&$.jsx(qs,{selection:n}),$.jsx("div",{className:"chat-bubble",onDoubleClick:Aj,children:$.jsx(Mj,{text:t,mentions:r})}),$.jsxs("div",{className:"chat-user-actions",children:[$.jsx("button",{type:"button",className:"chat-user-action","aria-label":m?"Message copied":"Copy message",title:m?"Copied":"Copy",onClick:()=>void y(),children:m?$.jsx(xh,{"aria-hidden":"true"}):$.jsx(Qh,{"aria-hidden":"true"})}),o&&$.jsx("button",{type:"button",className:"chat-user-action","aria-label":"Edit message",title:"Edit",onClick:c,children:$.jsx(Xh,{"aria-hidden":"true"})})]})]})})},uC=({msg:e,papers:t,onToggleBlock:r,onArchiveOldChats:n,onArchiveOldestChats:s,archivePending:o=null,hfBilling:a=null,openRouterFallbackEnabled:i=!1,feedbackEnabled:c=!1})=>{var x,U,q;const[l,d]=F.useState(null),[f,m]=F.useState(!1),[_,v]=F.useState(!1),[y,g]=F.useState(!1),[h,w]=F.useState(""),E=F.useRef(null),R=`chat-feedback-panel-${e.id}`,T=c&&!e.streaming&&!e.error&&!!((x=e.blocks)!=null&&x.some(V=>V.kind==="answer"&&V.text.trim()));F.useEffect(()=>{var V;y&&((V=E.current)==null||V.focus())},[y]);const C=async(V,z)=>{if(!f){m(!0),v(!1);try{z===void 0?await Ac.reportFeedback(e.id,V):await Ac.reportFeedback(e.id,V,z),d(V),g(!1),w("")}catch{v(!0)}finally{m(!1)}}};return $.jsx("div",{className:"chat-msg chat-msg-assistant",children:$.jsxs("div",{className:"chat-msg-blocks",children:[(U=e.blocks)==null?void 0:U.map((V,z)=>{var X;const H=`${e.id}-${z}`,ne="citations"in V&&V.citations!==void 0?V.citations:e.citations??[],B=Object.fromEntries(ne.filter(oe=>(oe.kind==="catalog_paper"||oe.kind==="paper"||!oe.kind&&oe.route_id)&&oe.route_id).map(oe=>[oe.route_id,oe])),ge=Object.fromEntries(ne.filter(oe=>(oe.kind==="external_source"||oe.kind==="web")&&oe.url).map(oe=>[oe.url,oe]));return V.kind==="reasoning"?$.jsx(zj,{block:V,papers:t,citations:B,webCitations:ge,onToggle:()=>r(e.id,z)},H):V.kind==="tool"?$.jsx(Dj,{block:V,papers:t,onToggle:()=>r(e.id,z)},H):V.kind==="app"?$.jsx(Uj,{block:V},V.instance_id||H):V.kind==="artifact"?$.jsx(Rj,{block:V},V.publication_id||V.version_id||H):$.jsx(qj,{block:V,papers:t,citations:B,webCitations:ge,streaming:!!(e.streaming&&z===(((X=e.blocks)==null?void 0:X.length)??0)-1)},H)}),xj(e)&&$.jsx("div",{className:"chat-waiting",role:"status","aria-live":"polite",children:$.jsx("span",{className:"chat-thinking",children:(((q=e.blocks)==null?void 0:q.length)??0)===0?e.status??"Thinking…":"Thinking…"})}),e.error&&$.jsxs("div",{className:"chat-error",children:[$.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??"")&&$.jsx("a",{href:"/settings",children:"Re-sign in with Hugging Face"}),e.errorCode==="hf_inference_billing_exhausted"&&$.jsxs($.Fragment,{children:[(a==null?void 0:a.account_type)==="Free"&&!a.bill_to?$.jsx("a",{href:Nj,target:"_blank",rel:"noreferrer",children:"Upgrade to Hugging Face PRO — $9/month for 20× more included credits"}):$.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"}),$.jsx("a",{href:Ij,target:"_blank",rel:"noreferrer",children:"Inference Providers pricing and billing details"})]}),e.errorCode==="openrouter_monthly_budget_exhausted"&&$.jsxs($.Fragment,{children:[i?$.jsx("span",{children:"This response started on the shared allowance. Your connected OpenRouter key will be used when you explicitly retry."}):$.jsx("a",{href:"/settings#openrouter-byok",children:"Connect your own OpenRouter key"}),$.jsx("span",{children:"Or select a Hugging Face-backed model and explicitly retry."})]}),e.errorCode==="openrouter_staging_funding_disabled"&&$.jsx("a",{href:Oj,children:"Continue on paperswithcode.co"}),e.errorCode==="openrouter_unavailable"&&$.jsxs($.Fragment,{children:[$.jsx("a",{href:"/settings#openrouter-byok",children:"Bring your own key in Settings"}),$.jsx("a",{href:"https://github.com/huggingface/paperswithcode-feedback",target:"_blank",rel:"noreferrer",children:"File an issue"})]}),e.errorCode==="openrouter_byok_billing_error"&&$.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??"")&&$.jsx("a",{href:"/settings#openrouter-byok",children:"Review OpenRouter settings"}),e.errorCode==="chat_session_quota_exceeded"&&(n||s)&&$.jsxs("span",{className:"chat-error-actions",children:[n&&$.jsx("button",{type:"button",disabled:o!==null,onClick:n,children:o==="old"?"Archiving…":"Archive chats older than 30 days"}),s&&$.jsx("button",{type:"button",disabled:o!==null,onClick:s,children:o==="oldest"?"Archiving…":"Archive oldest 50 chats"})]})]}),!e.streaming&&e.finishReason&&e.finishReason!=="success"&&$.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," ")}).`}),T&&$.jsxs("div",{className:"chat-feedback","aria-label":"Rate this response",children:[$.jsx("span",{className:"chat-feedback-label",children:l===null?"Was this helpful?":"Thanks for your feedback"}),$.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:()=>{g(!1),C(!0)},children:$.jsx(tp,{"aria-hidden":"true"})}),$.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:()=>{v(!1),g(!0)},children:$.jsx(ep,{"aria-hidden":"true"})}),_&&$.jsx("span",{className:"chat-feedback-error",role:"status",children:"Couldn’t send feedback."})]}),T&&y&&$.jsxs("div",{className:"chat-feedback-panel",id:R,role:"group","aria-labelledby":`${R}-title`,children:[$.jsx("div",{className:"chat-feedback-panel-title",id:`${R}-title`,children:"Additional feedback"}),$.jsx("label",{className:"chat-feedback-panel-label",htmlFor:`${R}-comment`,children:"Tell us what went wrong (optional)"}),$.jsx("textarea",{ref:E,id:`${R}-comment`,className:"chat-feedback-comment",value:h,maxLength:500,rows:4,disabled:f,onChange:V=>w(V.target.value),onKeyDown:V=>{V.key==="Escape"&&(V.preventDefault(),g(!1))}}),$.jsxs("div",{className:"chat-feedback-panel-actions",children:[$.jsx("button",{type:"button",className:"chat-feedback-skip",disabled:f,onClick:()=>void C(!1),children:"Skip"}),$.jsx("button",{type:"button",className:"chat-feedback-submit",disabled:f,onClick:()=>void C(!1,h.trim()||void 0),children:f?"Submitting…":"Submit"})]})]})]})})},Vj={chat:{breakpoint:760,left:360,right:360},shared:{breakpoint:760,left:360,right:360},reader:{breakpoint:1260,left:840,right:420}};function ar(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 dC=({children:e,variant:t})=>{const r=Vn(),n=Vj[t],s=F.useRef(null),o=F.useRef(null),a=F.useRef(null),i=F.useRef(null),[c,l]=F.useState(0),d=F.useRef(!1),f=F.useRef(r.state.panelPercent);F.useLayoutEffect(()=>{const h=s.current;if(!h)return;const w=()=>l(h.clientWidth||window.innerWidth);if(w(),typeof ResizeObserver>"u")return;const E=new ResizeObserver(w);return E.observe(h),()=>E.disconnect()},[]);const m=r.state.open&&c>=n.breakpoint,_=ar(c,r.state.panelPercent,n.left,n.right),v=h=>{var E;const w=ar(c,h,n.left,n.right);f.current=w,o.current&&(o.current.style.width=`${100-w}%`),a.current&&(a.current.style.width=`${w}%`),(E=i.current)==null||E.setAttribute("aria-valuenow",String(Math.round(w)))},y=h=>{var E;const w=(E=s.current)==null?void 0:E.getBoundingClientRect();w!=null&&w.width&&v((w.right-h)/w.width*100)},g=()=>{d.current&&(d.current=!1,r.setPanelPercent(f.current))};return $.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:[$.jsx("div",{ref:o,className:"chat-artifact-workspace-content",style:m?{width:`${100-_}%`}:void 0,children:e}),m&&$.jsxs($.Fragment,{children:[$.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(ar(c,0,n.left,n.right)),"aria-valuemax":Math.floor(ar(c,100,n.left,n.right)),"aria-valuenow":Math.round(_),tabIndex:0,onPointerDown:h=>{d.current=!0,h.currentTarget.setPointerCapture(h.pointerId),y(h.clientX)},onPointerMove:h=>{d.current&&y(h.clientX)},onPointerUp:g,onPointerCancel:g,onLostPointerCapture:g,onDoubleClick:()=>r.setPanelPercent(55),onKeyDown:h=>{(h.key==="ArrowLeft"||h.key==="ArrowRight")&&(h.preventDefault(),r.setPanelPercent(ar(c,_+(h.key==="ArrowLeft"?2:-2),n.left,n.right))),h.key==="Home"&&r.setPanelPercent(ar(c,25,n.left,n.right)),h.key==="End"&&r.setPanelPercent(ar(c,75,n.left,n.right))}}),$.jsx("div",{ref:a,className:"chat-artifact-workspace-pane",style:{width:`${_}%`},children:$.jsx(iu,{})})]}),r.state.open&&!m&&$.jsx(iu,{forceDialog:!0,readerFallback:t==="reader"})]})};export{cC as A,nC as C,lC as U,dC as a,uC as b,fa as c,Vn as u};