diff --git "a/assets/ChatMessage-tUEq7nWM.js" "b/assets/ChatMessage-tUEq7nWM.js" deleted file mode 100644--- "a/assets/ChatMessage-tUEq7nWM.js" +++ /dev/null @@ -1,127 +0,0 @@ -var Jf=Object.defineProperty;var Qf=(e,t,r)=>t in e?Jf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var le=(e,t,r)=>Qf(e,typeof t!="symbol"?t+"":t,r);import{d as mr,r as Pt,j as S,z as Q,N as Gl,E as wt,X as Yf,C as Xf}from"./index-BUGd2Z7P.js";import{u as Wl,a as Bl,b as Jl,M as eh,R as th,W as rh,d as Wo,A as nh,n as sh,K as oh,L as Ql,N as ah}from"./chatSessions-CWXfdKPU.js";import"./katex.min-BSBacQyE.js";import{H as Bo,a as Jo,b as Qo}from"./hover-card-BXhAt0h6.js";import{u as ih}from"./useQuery-nODHhqiD.js";import{f as ch,p as lh}from"./github-CyygY7fD.js";import{G as Yo}from"./github-U8ObNWrQ.js";import{r as uh,a as dh,P as Yl}from"./PaperPreviewLink-DaC0evwF.js";import{M as fh,r as hh,d as ph}from"./index-ByE99vYm.js";import{E as mh}from"./external-link-C5inEQt7.js";import{c as _c}from"./chat-Cfm46N6G.js";import{F as gh}from"./file-text-BAAhBuAl.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 _h=mr("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 yc=mr("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 vc=mr("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=mr("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 vh=mr("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 $h=mr("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 wh=mr("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 Es({selection:e,editable:t=!1,onRemove:r}){const n=Pt.useId(),s=Pt.useRef(null),[o,a]=Pt.useState(!1),[i,c]=Pt.useState(!1),l=`Selection · Page ${e.page}`;return Pt.useEffect(()=>{const d=s.current;!d||o||c(d.scrollHeight>d.clientHeight+1)},[o,e.text]),S.jsxs("div",{className:`chat-paper-selection${t?" is-editable":""}`,children:[S.jsxs("div",{className:"chat-paper-selection-header",children:[S.jsx("span",{className:"chat-paper-selection-label",children:l}),S.jsxs("div",{className:"chat-paper-selection-actions",children:[(i||o)&&S.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&&S.jsx("button",{type:"button",className:"chat-paper-selection-remove","aria-label":"Remove selected paper passage",onClick:r,children:"Remove"})]})]}),S.jsx("blockquote",{id:n,ref:s,className:`chat-paper-selection-quote${o?" is-expanded":""}`,children:e.text})]})}const bh=sh(),CT=({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:y=!1,paperSelectionEnabled:_=!0,webSearchAvailable:g=!1,webSearchEnabled:v=!1,onWebSearchChange:m,reasoningEffort:h="low",onReasoningEffortChange:$})=>{const[k,T]=Pt.useState(bh),E=s??k,x=Pt.useRef(null),[M,L]=Pt.useState(0),G=F=>{s||T(F),o==null||o(F)},V=Wl({draft:E,onChange:G,enabled:y,textareaRef:x});Pt.useEffect(()=>{const F=x.current;F&&(F.style.height="auto",F.style.height=`${Math.min(F.scrollHeight,200)}px`)},[E.text]),Pt.useEffect(()=>{var F;n&&((F=x.current)==null||F.focus())},[n]);const K=()=>{const F=E.text.length-E.text.trimStart().length,ie=E.text.trim(),ke=!!E.paperSelection&&!_;if(!ie||t||d||ke)return;const $e=F+ie.length,ct={text:ie,paperMentions:E.paperMentions.filter(Oe=>Oe.start>=F&&Oe.end<=$e).map(Oe=>({...Oe,start:Oe.start-F,end:Oe.end-F})),...E.paperSelection?{paperSelection:E.paperSelection}:{}};e(ct)},Y=!!E.paperSelection&&!_,ne=!!E.text.trim()&&!Y;return S.jsxs("div",{className:"chat-composer",children:[E.paperSelection&&S.jsx(Es,{selection:E.paperSelection,editable:!0,onRemove:()=>{var F;G({text:E.text,paperMentions:E.paperMentions}),(F=x.current)==null||F.focus()}}),Y&&S.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."}),S.jsxs("div",{className:"chat-composer-textarea-wrap",children:[S.jsx(Bl,{text:E.text,mentions:E.paperMentions,scrollTop:M}),S.jsx("textarea",{ref:x,rows:1,value:E.text,placeholder:r||(E.paperSelection?"Ask about this selection…":"Ask anything about research…"),onChange:F=>V.updateText(F.target.value,F.target.selectionStart),onSelect:F=>V.refresh(F.currentTarget.selectionStart),onClick:F=>V.refresh(F.currentTarget.selectionStart),onScroll:F=>L(F.currentTarget.scrollTop),onBlur:F=>{var ie,ke;(ke=(ie=F.relatedTarget)==null?void 0:ie.closest)!=null&&ke.call(ie,".chat-paper-picker")||window.setTimeout(V.close,0)},onKeyDown:F=>{V.keyDown(F)||F.key==="Enter"&&!F.shiftKey&&!F.nativeEvent.isComposing&&(F.preventDefault(),K())},role:"combobox","aria-expanded":V.open,"aria-controls":V.open?V.pickerId:void 0,"aria-activedescendant":V.open&&V.results.length?`${V.optionIdPrefix}-${V.activeIndex}`:void 0,"aria-autocomplete":"list","aria-describedby":[f,V.message?"chat-paper-mention-message":null].filter(Boolean).join(" ")||void 0}),S.jsx(Jl,{open:V.open,query:V.query,results:V.results,activeIndex:V.activeIndex,loading:V.loading,error:V.error,onSelect:V.select,id:V.pickerId,optionIdPrefix:V.optionIdPrefix})]}),V.message&&S.jsx("div",{id:"chat-paper-mention-message",className:"chat-paper-mention-message",role:"alert",children:V.message}),S.jsxs("div",{className:"chat-composer-row",children:[S.jsxs("div",{className:"chat-composer-tools",children:[i.length>0&&c&&l&&S.jsx(eh,{models:i,selectedModel:c,onModelChange:l,disabled:t}),$&&S.jsx(th,{value:h,onChange:$,disabled:t}),g&&m&&S.jsx(rh,{enabled:v,onChange:m,disabled:t}),S.jsx("span",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]}),S.jsx("button",{type:"button",className:`chat-send${t||ne?" chat-send-on":""}`,onClick:t?a:K,disabled:d||(t?!a:!ne),"aria-label":t?"Stop generating":"Send message",children:t?a?S.jsx("span",{"aria-hidden":"true",children:"■"}):S.jsx(Wo,{light:!0}):S.jsx(nh,{})})]})]})},Zs=new Map,Xl=e=>{if(!e)return Promise.resolve();const t=Zs.get(e);if(t)return t;const r=new Promise(n=>{const s=new Image;s.onload=()=>{n()},s.onerror=()=>{Zs.delete(e),n()},s.src=e});return Zs.set(e,r),r},Sh=new Set(["huggingface.co","www.huggingface.co"]),Eh=new Set(["api","blog","chat","collections","docs","enterprise","join","login","models","new","organizations","papers","posts","pricing","search","settings","spaces","tasks"]);function kh(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!=="https:"||!Sh.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"&&Eh.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 Ph=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,Rh=({repo:e})=>{const[t,r]=Q.useState(!1);return S.jsxs("div",{className:"hf-preview-card",children:[t?S.jsx("div",{className:"hf-preview-fallback","aria-hidden":"true",children:"🤗"}):S.jsx("img",{className:"hf-preview-image","data-testid":"hf-preview-image",src:e.thumbnailUrl,alt:"",loading:"eager",decoding:"async",onError:()=>r(!0)}),S.jsxs("div",{className:"hf-preview-meta",children:[S.jsxs("span",{className:"hf-preview-kind",children:["Hugging Face ",e.type]}),S.jsx("strong",{children:e.repoId}),S.jsx("span",{children:"huggingface.co"})]})]})},Th=({repo:e,children:t})=>{const[r,n]=Q.useState(!1),s=Q.useRef(null),o=Q.useCallback(()=>{Xl(e.thumbnailUrl)},[e.thumbnailUrl]);return Q.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]),S.jsxs(Bo,{open:r,onOpenChange:a=>{(!a||!Ph())&&n(a)},openDelay:150,closeDelay:100,children:[S.jsx(Jo,{asChild:!0,children:S.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})}),S.jsx(Qo,{className:"hf-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:S.jsx(Rh,{repo:e})})]})},Ch=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,jh=({repo:e,preview:t,unavailable:r})=>{const[n,s]=Q.useState(!1),o=!!(t!=null&&t.avatarUrl)&&!n;return S.jsxs("div",{className:"github-preview-card",children:[o?S.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)}):S.jsx("div",{className:"github-preview-fallback","aria-hidden":"true",children:S.jsx(Yo,{})}),S.jsxs("div",{className:"github-preview-meta",children:[S.jsx("span",{className:"github-preview-kind",children:"GitHub repository"}),S.jsx("strong",{children:e.repoId}),(t==null?void 0:t.description)&&S.jsx("span",{className:"github-preview-description",children:t.description}),t?S.jsxs("span",{className:"github-preview-stats",children:[t.language&&S.jsxs(S.Fragment,{children:[t.language," · "]}),"★ ",t.stars.toLocaleString()," · ⑂ ",t.forks.toLocaleString(),t.archived&&S.jsx(S.Fragment,{children:" · Archived"})]}):S.jsx("span",{children:r?"Preview unavailable":"Loading preview…"})]})]})},Nh=({repo:e,children:t})=>{var l;const[r,n]=Q.useState(!1),[s,o]=Q.useState(!1),a=Q.useRef(null),i=Q.useCallback(()=>o(!0),[]),c=ih({queryKey:["github-repository-preview",e.repoId.toLowerCase()],queryFn:({signal:d})=>ch(e,d),enabled:r||s,staleTime:30*60*1e3,gcTime:60*60*1e3,retry:!1});return Q.useEffect(()=>{const d=a.current;if(!d||typeof IntersectionObserver>"u")return;const f=new IntersectionObserver(([y])=>{y.isIntersecting&&(i(),f.disconnect())},{rootMargin:"200px"});return f.observe(d),()=>f.disconnect()},[i]),Q.useEffect(()=>{var d;(d=c.data)!=null&&d.avatarUrl&&Xl(c.data.avatarUrl)},[(l=c.data)==null?void 0:l.avatarUrl]),S.jsxs(Bo,{open:r,onOpenChange:d=>{(!d||!Ch())&&n(d)},openDelay:150,closeDelay:100,children:[S.jsx(Jo,{asChild:!0,children:S.jsxs("a",{ref:a,className:"chat-github-link",href:e.url,target:"_blank",rel:"noopener noreferrer",onPointerEnter:i,onFocus:i,children:[S.jsx(Yo,{"aria-hidden":"true"}),t]})}),S.jsx(Qo,{className:"github-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:S.jsx(jh,{repo:e,preview:c.data,unavailable:c.isError})})]})},Ih=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches;function Oh(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return"Web source"}}const xh=({citation:e})=>{const[t,r]=Q.useState(!1),[n,s]=Q.useState(!1),o=e.thumbnail_url,a=e.favicon_url;return S.jsxs("div",{className:"web-preview-card",children:[o&&!t&&S.jsx("img",{className:"web-preview-image","data-testid":"web-preview-image",src:o,alt:"",loading:"eager",decoding:"async",referrerPolicy:"no-referrer",onError:()=>r(!0)}),S.jsxs("div",{className:"web-preview-meta",children:[S.jsxs("div",{className:"web-preview-source",children:[a&&!n&&S.jsx("img",{src:a,alt:"",loading:"eager",decoding:"async",referrerPolicy:"no-referrer",onError:()=>s(!0)}),S.jsx("span",{children:Oh(e.url??"")}),e.published&&S.jsxs(S.Fragment,{children:[S.jsx("span",{"aria-hidden":"true",children:"·"}),S.jsx("time",{children:e.published.slice(0,10)})]})]}),S.jsx("strong",{children:e.title}),e.excerpt&&S.jsx("p",{children:e.excerpt.replace(/\s+/g," ").trim()})]})]})},Ah=({citation:e,children:t})=>{const[r,n]=Q.useState(!1),s=e.url??"";return S.jsxs(Bo,{open:r,onOpenChange:o=>{(!o||!Ih())&&n(o)},openDelay:150,closeDelay:100,children:[S.jsx(Jo,{asChild:!0,children:S.jsx("a",{href:s,className:"chat-web-citation",target:"_blank",rel:"noopener noreferrer",children:t})}),S.jsx(Qo,{className:"web-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:S.jsx(xh,{citation:e})})]})};function Mh(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 bc(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 eu=({routeId:e,paper:t,citation:r,className:n="chat-paper-link",children:s})=>S.jsx(Yl,{routeId:e,initialData:qh(e,t,r),className:n,target:"_blank",children:s});function Dh(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 Uh=e=>e.startsWith("paper:")?e:ph(e);function Fh(e){try{const t=new URL(e);return t.protocol==="https:"&&(t.hostname==="github.com"||t.hostname==="www.github.com")}catch{return!1}}const lo=({text:e,streaming:t,papers:r,citations:n,webCitations:s})=>{const o=zh(t?Dh(e):e);return S.jsx(fh,{remarkPlugins:[hh,dh],rehypePlugins:[uh],urlTransform:Uh,components:{a:({href:a,children:i})=>{if(a!=null&&a.startsWith("paper:")){const d=a.slice(6);return!r[d]&&!(n!=null&&n[d])?S.jsx("span",{className:"chat-invalid-citation",children:i}):S.jsx(eu,{routeId:d,paper:r[d],citation:n==null?void 0:n[d],children:i})}const c=a?kh(a):null;if(c)return S.jsx(Th,{repo:c,children:i});const l=a?lh(a):null;return l?S.jsx(Nh,{repo:l,children:i}):a&&Fh(a)?S.jsxs("a",{href:a,className:"chat-github-link",target:"_blank",rel:"noopener noreferrer",children:[S.jsx(Yo,{"aria-hidden":"true"}),i]}):a!=null&&a.startsWith("https://")&&(s!=null&&s[a])?S.jsx(Ah,{citation:s[a],children:i}):a!=null&&a.startsWith("https://")?S.jsx("a",{href:a,className:"chat-external-link",target:"_blank",rel:"noopener noreferrer",children:i}):S.jsx("span",{children:i})}},children:o})},Lh=Object.freeze({status:"aborted"});function z(e,t,r){function n(i,c){var l;Object.defineProperty(i,"_zod",{value:i._zod??{},enumerable:!1}),(l=i._zod).traits??(l.traits=new Set),i._zod.traits.add(e),t(i,c);for(const d in a.prototype)d in i||Object.defineProperty(i,d,{value:a.prototype[d].bind(i)});i._zod.constr=a,i._zod.def=c}const s=(r==null?void 0:r.Parent)??Object;class o extends s{}Object.defineProperty(o,"name",{value:e});function a(i){var c;const l=r!=null&&r.Parent?new o:this;n(l,i),(c=l._zod).deferred??(c.deferred=[]);for(const d of l._zod.deferred)d();return l}return Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:i=>{var c,l;return r!=null&&r.Parent&&i instanceof r.Parent?!0:(l=(c=i==null?void 0:i._zod)==null?void 0:c.traits)==null?void 0:l.has(e)}}),Object.defineProperty(a,"name",{value:e}),a}class dn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const tu={};function Kt(e){return tu}function Vh(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 Hh(e,t){return typeof t=="bigint"?t.toString():t}function Xo(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ea(e){return e==null}function ta(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Zh(e,t){const r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,s=r>n?r:n,o=Number.parseInt(e.toFixed(s).replace(".","")),a=Number.parseInt(t.toFixed(s).replace(".",""));return o%a/10**s}function Te(e,t,r){Object.defineProperty(e,t,{get(){{const n=r();return e[t]=n,n}},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function ks(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Zr(e){return JSON.stringify(e)}const ru=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function os(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Kh=Xo(()=>{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 as(e){if(os(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(os(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}const Gh=new Set(["string","number","symbol"]);function _n(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function gr(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r!=null&&r.parent)&&(n._zod.parent=e),n}function te(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Wh(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Bh={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 Jh(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 gr(e,{...e._zod.def,shape:r,checks:[]})}function Qh(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 gr(e,{...e._zod.def,shape:r,checks:[]})}function Yh(e,t){if(!as(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 ks(this,"shape",n),n},checks:[]};return gr(e,r)}function Xh(e,t){return gr(e,{...e._zod.def,get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return ks(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function ep(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 gr(t,{...t._zod.def,shape:s,checks:[]})}function tp(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 gr(t,{...t._zod.def,shape:s,checks:[]})}function en(e,t=0){var r;for(let n=t;n{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function In(e){return typeof e=="string"?e:e==null?void 0:e.message}function Gt(e,t,r){var s,o,a,i,c,l;const n={...e,path:e.path??[]};if(!e.message){const d=In((a=(o=(s=e.inst)==null?void 0:s._zod.def)==null?void 0:o.error)==null?void 0:a.call(o,e))??In((i=t==null?void 0:t.error)==null?void 0:i.call(t,e))??In((c=r.customError)==null?void 0:c.call(r,e))??In((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 ra(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function fn(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const nu=(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,Hh,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},su=z("$ZodError",nu),ou=z("$ZodError",nu,{Parent:Error});function rp(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 np(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 dn;if(a.issues.length){const i=new((s==null?void 0:s.Err)??e)(a.issues.map(c=>Gt(c,o,Kt())));throw ru(i,s==null?void 0:s.callee),i}return a.value},op=e=>async(t,r,n,s)=>{const o=n?Object.assign(n,{async:!0}):{async:!0};let a=t._zod.run({value:r,issues:[]},o);if(a instanceof Promise&&(a=await a),a.issues.length){const i=new((s==null?void 0:s.Err)??e)(a.issues.map(c=>Gt(c,o,Kt())));throw ru(i,s==null?void 0:s.callee),i}return a.value},au=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 dn;return o.issues.length?{success:!1,error:new(e??su)(o.issues.map(a=>Gt(a,s,Kt())))}:{success:!0,data:o.value}},iu=au(ou),cu=e=>async(t,r,n)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let o=t._zod.run({value:r,issues:[]},s);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(a=>Gt(a,s,Kt())))}:{success:!0,data:o.value}},ap=cu(ou),ip=/^[cC][^\s-]{8,}$/,cp=/^[0-9a-z]+$/,lp=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,up=/^[0-9a-vA-V]{20}$/,dp=/^[A-Za-z0-9]{27}$/,fp=/^[a-zA-Z0-9_-]{21}$/,hp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,pp=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Sc=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)$/,mp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,gp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function _p(){return new RegExp(gp,"u")}const yp=/^(?:(?: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])$/,vp=/^(([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})$/,$p=/^((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])$/,wp=/^(([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])$/,bp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,lu=/^[A-Za-z0-9_-]*$/,Sp=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,Ep=/^\+(?:[0-9]){6,14}[0-9]$/,uu="(?:(?:\\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])))",kp=new RegExp(`^${uu}$`);function du(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 Pp(e){return new RegExp(`^${du(e)}$`)}function Rp(e){const t=du({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(`^${uu}T(?:${n})$`)}const Tp=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}$`)},Cp=/^\d+$/,jp=/^-?\d+(?:\.\d+)?/i,Np=/true|false/i,Ip=/null/i,Op=/undefined/i,xp=/^[^A-Z]*$/,Ap=/^[^a-z]*$/,it=z("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),fu={number:"number",bigint:"bigint",object:"date"},hu=z("$ZodCheckLessThan",(e,t)=>{it.init(e,t);const r=fu[typeof t.value];e._zod.onattach.push(n=>{const s=n._zod.bag,o=(t.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value{(t.inclusive?n.value<=t.value:n.value{it.init(e,t);const r=fu[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})}}),Mp=z("$ZodCheckMultipleOf",(e,t)=>{it.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Zh(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})}}),zp=z("$ZodCheckNumberFormat",(e,t)=>{var a;it.init(e,t),t.format=t.format||"float64";const r=(a=t.format)==null?void 0:a.includes("int"),n=r?"int":"number",[s,o]=Bh[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=Cp)}),e._zod.check=i=>{const c=i.value;if(r){if(!Number.isInteger(c)){i.issues.push({expected:n,format:t.format,code:"invalid_type",input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?i.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort}):i.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort});return}}co&&i.issues.push({origin:"number",input:c,code:"too_big",maximum:o,inst:e})}}),qp=z("$ZodCheckMaxLength",(e,t)=>{var r;it.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!ea(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=ra(s);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Dp=z("$ZodCheckMinLength",(e,t)=>{var r;it.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!ea(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=ra(s);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Up=z("$ZodCheckLengthEquals",(e,t)=>{var r;it.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!ea(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=ra(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})}}),Ps=z("$ZodCheckStringFormat",(e,t)=>{var r,n;it.init(e,t),e._zod.onattach.push(s=>{const o=s._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=s=>{t.pattern.lastIndex=0,!t.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:t.format,input:s.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Fp=z("$ZodCheckRegex",(e,t)=>{Ps.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})}}),Lp=z("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=xp),Ps.init(e,t)}),Vp=z("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Ap),Ps.init(e,t)}),Hp=z("$ZodCheckIncludes",(e,t)=>{it.init(e,t);const r=_n(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})}}),Zp=z("$ZodCheckStartsWith",(e,t)=>{it.init(e,t);const r=new RegExp(`^${_n(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})}}),Kp=z("$ZodCheckEndsWith",(e,t)=>{it.init(e,t);const r=new RegExp(`.*${_n(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})}}),Gp=z("$ZodCheckOverwrite",(e,t)=>{it.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class Wp{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 Bp={major:4,minor:0,patch:0},Ee=z("$ZodType",(e,t)=>{var s;var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Bp;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=en(a),d;for(const f of i){if(f._zod.def.when){if(!f._zod.def.when(a))continue}else if(l)continue;const y=a.issues.length,_=f._zod.check(a);if(_ instanceof Promise&&(c==null?void 0:c.async)===!1)throw new dn;if(d||_ instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await _,a.issues.length!==y&&(l||(l=en(a,y)))});else{if(a.issues.length===y)continue;l||(l=en(a,y))}}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 dn;return c.then(l=>o(l,n,i))}return o(c,n,i)}}e["~standard"]={validate:o=>{var a;try{const i=iu(e,o);return i.success?{value:i.data}:{issues:(a=i.error)==null?void 0:a.issues}}catch{return ap(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}}),na=z("$ZodString",(e,t)=>{var r;Ee.init(e,t),e._zod.pattern=[...((r=e==null?void 0:e._zod.bag)==null?void 0:r.patterns)??[]].pop()??Tp(e._zod.bag),e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),je=z("$ZodStringFormat",(e,t)=>{Ps.init(e,t),na.init(e,t)}),Jp=z("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=pp),je.init(e,t)}),Qp=z("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Sc(n))}else t.pattern??(t.pattern=Sc());je.init(e,t)}),Yp=z("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=mp),je.init(e,t)}),Xp=z("$ZodURL",(e,t)=>{je.init(e,t),e._zod.check=r=>{try{const n=r.value,s=new URL(n),o=s.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(s.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Sp.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})}}}),em=z("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=_p()),je.init(e,t)}),tm=z("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=fp),je.init(e,t)}),rm=z("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=ip),je.init(e,t)}),nm=z("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=cp),je.init(e,t)}),sm=z("$ZodULID",(e,t)=>{t.pattern??(t.pattern=lp),je.init(e,t)}),om=z("$ZodXID",(e,t)=>{t.pattern??(t.pattern=up),je.init(e,t)}),am=z("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=dp),je.init(e,t)}),im=z("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Rp(t)),je.init(e,t)}),cm=z("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=kp),je.init(e,t)}),lm=z("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Pp(t)),je.init(e,t)}),um=z("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=hp),je.init(e,t)}),dm=z("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=yp),je.init(e,t),e._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv4"})}),fm=z("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=vp),je.init(e,t),e._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv6"}),e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),hm=z("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=$p),je.init(e,t)}),pm=z("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=wp),je.init(e,t),e._zod.check=r=>{const[n,s]=r.value.split("/");try{if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function mu(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const mm=z("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=bp),je.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),e._zod.check=r=>{mu(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function gm(e){if(!lu.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return mu(r)}const _m=z("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=lu),je.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),e._zod.check=r=>{gm(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),ym=z("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Ep),je.init(e,t)});function vm(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 $m=z("$ZodJWT",(e,t)=>{je.init(e,t),e._zod.check=r=>{vm(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),gu=z("$ZodNumber",(e,t)=>{Ee.init(e,t),e._zod.pattern=e._zod.bag.pattern??jp,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}}),wm=z("$ZodNumber",(e,t)=>{zp.init(e,t),gu.init(e,t)}),bm=z("$ZodBoolean",(e,t)=>{Ee.init(e,t),e._zod.pattern=Np,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}}),Sm=z("$ZodUndefined",(e,t)=>{Ee.init(e,t),e._zod.pattern=Op,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}}),Em=z("$ZodNull",(e,t)=>{Ee.init(e,t),e._zod.pattern=Ip,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}}),km=z("$ZodAny",(e,t)=>{Ee.init(e,t),e._zod.parse=r=>r}),Pm=z("$ZodUnknown",(e,t)=>{Ee.init(e,t),e._zod.parse=r=>r}),Rm=z("$ZodNever",(e,t)=>{Ee.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Ec(e,t,r){e.issues.length&&t.issues.push(...cr(r,e.issues)),t.value[r]=e.value}const Tm=z("$ZodArray",(e,t)=>{Ee.init(e,t),e._zod.parse=(r,n)=>{const s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),r;r.value=Array(s.length);const o=[];for(let a=0;aEc(l,r,a))):Ec(c,r,a)}return o.length?Promise.all(o).then(()=>r):r}});function On(e,t,r){e.issues.length&&t.issues.push(...cr(r,e.issues)),t.value[r]=e.value}function kc(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(...cr(r,e.issues)):e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}const Cm=z("$ZodObject",(e,t)=>{Ee.init(e,t);const r=Xo(()=>{const f=Object.keys(t.shape);for(const _ of f)if(!(t.shape[_]instanceof Ee))throw new Error(`Invalid element at key "${_}": expected a Zod schema`);const y=Wh(t.shape);return{shape:t.shape,keys:f,keySet:new Set(f),numKeys:f.length,optionalKeys:new Set(y)}});Te(e._zod,"propValues",()=>{const f=t.shape,y={};for(const _ in f){const g=f[_]._zod;if(g.values){y[_]??(y[_]=new Set);for(const v of g.values)y[_].add(v)}}return y});const n=f=>{const y=new Wp(["shape","payload","ctx"]),_=r.value,g=$=>{const k=Zr($);return`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`};y.write("const input = payload.value;");const v=Object.create(null);let m=0;for(const $ of _.keys)v[$]=`key_${m++}`;y.write("const newResult = {}");for(const $ of _.keys)if(_.optionalKeys.has($)){const k=v[$];y.write(`const ${k} = ${g($)};`);const T=Zr($);y.write(` - if (${k}.issues.length) { - if (input[${T}] === undefined) { - if (${T} in input) { - newResult[${T}] = undefined; - } - } else { - payload.issues = payload.issues.concat( - ${k}.issues.map((iss) => ({ - ...iss, - path: iss.path ? [${T}, ...iss.path] : [${T}], - })) - ); - } - } else if (${k}.value === undefined) { - if (${T} in input) newResult[${T}] = undefined; - } else { - newResult[${T}] = ${k}.value; - } - `)}else{const k=v[$];y.write(`const ${k} = ${g($)};`),y.write(` - if (${k}.issues.length) payload.issues = payload.issues.concat(${k}.issues.map(iss => ({ - ...iss, - path: iss.path ? [${Zr($)}, ...iss.path] : [${Zr($)}] - })));`),y.write(`newResult[${Zr($)}] = ${k}.value`)}y.write("payload.value = newResult;"),y.write("return payload;");const h=y.compile();return($,k)=>h(f,$,k)};let s;const o=os,a=!tu.jitless,c=a&&Kh.value,l=t.catchall;let d;e._zod.parse=(f,y)=>{d??(d=r.value);const _=f.value;if(!o(_))return f.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),f;const g=[];if(a&&c&&(y==null?void 0:y.async)===!1&&y.jitless!==!0)s||(s=n(t.shape)),f=s(f,y);else{f.value={};const k=d.shape;for(const T of d.keys){const E=k[T],x=E._zod.run({value:_[T],issues:[]},y),M=E._zod.optin==="optional"&&E._zod.optout==="optional";x instanceof Promise?g.push(x.then(L=>M?kc(L,f,T,_):On(L,f,T))):M?kc(x,f,T,_):On(x,f,T)}}if(!l)return g.length?Promise.all(g).then(()=>f):f;const v=[],m=d.keySet,h=l._zod,$=h.def.type;for(const k of Object.keys(_)){if(m.has(k))continue;if($==="never"){v.push(k);continue}const T=h.run({value:_[k],issues:[]},y);T instanceof Promise?g.push(T.then(E=>On(E,f,k))):On(T,f,k)}return v.length&&f.issues.push({code:"unrecognized_keys",keys:v,input:_,inst:e}),g.length?Promise.all(g).then(()=>f):f}});function Pc(e,t,r,n){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(o=>Gt(o,n,Kt())))}),t}const _u=z("$ZodUnion",(e,t)=>{Ee.init(e,t),Te(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),Te(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),Te(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),Te(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>ta(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=>Pc(a,r,e,n)):Pc(o,r,e,n)}}),jm=z("$ZodDiscriminatedUnion",(e,t)=>{_u.init(e,t);const r=e._zod.parse;Te(e._zod,"propValues",()=>{const s={};for(const o of t.options){const a=o._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const[i,c]of Object.entries(a)){s[i]||(s[i]=new Set);for(const l of c)s[i].add(l)}}return s});const n=Xo(()=>{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(!os(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)}}),Nm=z("$ZodIntersection",(e,t)=>{Ee.init(e,t),e._zod.parse=(r,n)=>{const s=r.value,o=t.left._zod.run({value:s,issues:[]},n),a=t.right._zod.run({value:s,issues:[]},n);return o instanceof Promise||a instanceof Promise?Promise.all([o,a]).then(([c,l])=>Rc(r,c,l)):Rc(r,o,a)}});function uo(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(as(e)&&as(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=uo(e[o],t[o]);if(!a.valid)return{valid:!1,mergeErrorPath:[o,...a.mergeErrorPath]};s[o]=a.data}return{valid:!0,data:s}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n{Ee.init(e,t),e._zod.parse=(r,n)=>{const s=r.value;if(!as(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(...cr(c,d.issues)),r.value[c]=d.value})):(l.issues.length&&r.issues.push(...cr(c,l.issues)),r.value[c]=l.value)}let i;for(const c in s)a.has(c)||(i=i??[],i.push(c));i&&i.length>0&&r.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:i})}else{r.value={};for(const a of Reflect.ownKeys(s)){if(a==="__proto__")continue;const i=t.keyType._zod.run({value:a,issues:[]},n);if(i instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(i.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:i.issues.map(l=>Gt(l,n,Kt())),input:a,path:[a],inst:e}),r.value[i.value]=i.value;continue}const c=t.valueType._zod.run({value:s[a],issues:[]},n);c instanceof Promise?o.push(c.then(l=>{l.issues.length&&r.issues.push(...cr(a,l.issues)),r.value[i.value]=l.value})):(c.issues.length&&r.issues.push(...cr(a,c.issues)),r.value[i.value]=c.value)}}return o.length?Promise.all(o).then(()=>r):r}}),Om=z("$ZodEnum",(e,t)=>{Ee.init(e,t);const r=Vh(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(n=>Gh.has(typeof n)).map(n=>typeof n=="string"?_n(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}}),xm=z("$ZodLiteral",(e,t)=>{Ee.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?_n(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}}),Am=z("$ZodTransform",(e,t)=>{Ee.init(e,t),e._zod.parse=(r,n)=>{const s=t.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(a=>(r.value=a,r));if(s instanceof Promise)throw new dn;return r.value=s,r}}),Mm=z("$ZodOptional",(e,t)=>{Ee.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Te(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Te(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${ta(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)}),zm=z("$ZodNullable",(e,t)=>{Ee.init(e,t),Te(e._zod,"optin",()=>t.innerType._zod.optin),Te(e._zod,"optout",()=>t.innerType._zod.optout),Te(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${ta(r.source)}|null)$`):void 0}),Te(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),qm=z("$ZodDefault",(e,t)=>{Ee.init(e,t),e._zod.optin="optional",Te(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=t.defaultValue,r;const s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>Tc(o,t)):Tc(s,t)}});function Tc(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Dm=z("$ZodPrefault",(e,t)=>{Ee.init(e,t),e._zod.optin="optional",Te(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Um=z("$ZodNonOptional",(e,t)=>{Ee.init(e,t),Te(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{const s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>Cc(o,e)):Cc(s,e)}});function Cc(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 Fm=z("$ZodCatch",(e,t)=>{Ee.init(e,t),e._zod.optin="optional",Te(e._zod,"optout",()=>t.innerType._zod.optout),Te(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{const s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(a=>Gt(a,n,Kt()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=t.catchValue({...r,error:{issues:s.issues.map(o=>Gt(o,n,Kt()))},input:r.value}),r.issues=[]),r)}}),Lm=z("$ZodPipe",(e,t)=>{Ee.init(e,t),Te(e._zod,"values",()=>t.in._zod.values),Te(e._zod,"optin",()=>t.in._zod.optin),Te(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(r,n)=>{const s=t.in._zod.run(r,n);return s instanceof Promise?s.then(o=>jc(o,t,n)):jc(s,t,n)}});function jc(e,t,r){return en(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}const Vm=z("$ZodReadonly",(e,t)=>{Ee.init(e,t),Te(e._zod,"propValues",()=>t.innerType._zod.propValues),Te(e._zod,"values",()=>t.innerType._zod.values),Te(e._zod,"optin",()=>t.innerType._zod.optin),Te(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(r,n)=>{const s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(Nc):Nc(s)}});function Nc(e){return e.value=Object.freeze(e.value),e}const Hm=z("$ZodCustom",(e,t)=>{it.init(e,t),Ee.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,s=t.fn(n);if(s instanceof Promise)return s.then(o=>Ic(o,r,n,e));Ic(s,r,n,e)}});function Ic(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(fn(s))}}class Zm{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 Km(){return new Zm}const xn=Km();function Gm(e,t){return new e({type:"string",...te(t)})}function Wm(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...te(t)})}function Oc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...te(t)})}function Bm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...te(t)})}function Jm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...te(t)})}function Qm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...te(t)})}function Ym(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...te(t)})}function yu(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...te(t)})}function Xm(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...te(t)})}function eg(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...te(t)})}function tg(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...te(t)})}function rg(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...te(t)})}function ng(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...te(t)})}function sg(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...te(t)})}function og(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...te(t)})}function ag(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...te(t)})}function ig(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...te(t)})}function cg(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...te(t)})}function lg(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...te(t)})}function ug(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...te(t)})}function dg(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...te(t)})}function fg(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...te(t)})}function hg(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...te(t)})}function pg(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...te(t)})}function mg(e,t){return new e({type:"string",format:"date",check:"string_format",...te(t)})}function gg(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...te(t)})}function _g(e,t){return new e({type:"string",format:"duration",check:"string_format",...te(t)})}function yg(e,t){return new e({type:"number",checks:[],...te(t)})}function vg(e,t){return new e({type:"number",coerce:!0,checks:[],...te(t)})}function $g(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...te(t)})}function wg(e,t){return new e({type:"boolean",...te(t)})}function bg(e,t){return new e({type:"undefined",...te(t)})}function Sg(e,t){return new e({type:"null",...te(t)})}function Eg(e){return new e({type:"any"})}function kg(e){return new e({type:"unknown"})}function Pg(e,t){return new e({type:"never",...te(t)})}function xc(e,t){return new hu({check:"less_than",...te(t),value:e,inclusive:!1})}function Ks(e,t){return new hu({check:"less_than",...te(t),value:e,inclusive:!0})}function Ac(e,t){return new pu({check:"greater_than",...te(t),value:e,inclusive:!1})}function Gs(e,t){return new pu({check:"greater_than",...te(t),value:e,inclusive:!0})}function Mc(e,t){return new Mp({check:"multiple_of",...te(t),value:e})}function vu(e,t){return new qp({check:"max_length",...te(t),maximum:e})}function is(e,t){return new Dp({check:"min_length",...te(t),minimum:e})}function $u(e,t){return new Up({check:"length_equals",...te(t),length:e})}function Rg(e,t){return new Fp({check:"string_format",format:"regex",...te(t),pattern:e})}function Tg(e){return new Lp({check:"string_format",format:"lowercase",...te(e)})}function Cg(e){return new Vp({check:"string_format",format:"uppercase",...te(e)})}function jg(e,t){return new Hp({check:"string_format",format:"includes",...te(t),includes:e})}function Ng(e,t){return new Zp({check:"string_format",format:"starts_with",...te(t),prefix:e})}function Ig(e,t){return new Kp({check:"string_format",format:"ends_with",...te(t),suffix:e})}function yn(e){return new Gp({check:"overwrite",tx:e})}function Og(e){return yn(t=>t.normalize(e))}function xg(){return yn(e=>e.trim())}function Ag(){return yn(e=>e.toLowerCase())}function Mg(){return yn(e=>e.toUpperCase())}function zg(e,t,r){return new e({type:"array",element:t,...te(r)})}function qg(e,t,r){const n=te(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function Dg(e,t,r){return new e({type:"custom",check:"custom",fn:t,...te(r)})}const Ug=z("ZodISODateTime",(e,t)=>{im.init(e,t),Ie.init(e,t)});function wu(e){return pg(Ug,e)}const Fg=z("ZodISODate",(e,t)=>{cm.init(e,t),Ie.init(e,t)});function Lg(e){return mg(Fg,e)}const Vg=z("ZodISOTime",(e,t)=>{lm.init(e,t),Ie.init(e,t)});function Hg(e){return gg(Vg,e)}const Zg=z("ZodISODuration",(e,t)=>{um.init(e,t),Ie.init(e,t)});function Kg(e){return _g(Zg,e)}const Gg=(e,t)=>{su.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>np(e,r)},flatten:{value:r=>rp(e,r)},addIssue:{value:r=>e.issues.push(r)},addIssues:{value:r=>e.issues.push(...r)},isEmpty:{get(){return e.issues.length===0}}})},Rs=z("ZodError",Gg,{Parent:Error}),Wg=sp(Rs),Bg=op(Rs),Jg=au(Rs),Qg=cu(Rs),Ce=z("ZodType",(e,t)=>(Ee.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(r,n)=>gr(e,r,n),e.brand=()=>e,e.register=(r,n)=>(r.add(e,n),e),e.parse=(r,n)=>Wg(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Jg(e,r,n),e.parseAsync=async(r,n)=>Bg(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Qg(e,r,n),e.spa=e.safeParseAsync,e.refine=(r,n)=>e.check(V_(r,n)),e.superRefine=r=>e.check(H_(r)),e.overwrite=r=>e.check(yn(r)),e.optional=()=>Ne(e),e.nullable=()=>Dc(e),e.nullish=()=>Ne(Dc(e)),e.nonoptional=r=>A_(e,r),e.array=()=>H(e),e.or=r=>_e([e,r]),e.and=r=>aa(e,r),e.transform=r=>mo(e,Ru(r)),e.default=r=>I_(e,r),e.prefault=r=>x_(e,r),e.catch=r=>z_(e,r),e.pipe=r=>mo(e,r),e.readonly=()=>U_(e),e.describe=r=>{const n=e.clone();return xn.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){var r;return(r=xn.get(e))==null?void 0:r.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return xn.get(e);const n=e.clone();return xn.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),bu=z("_ZodString",(e,t)=>{na.init(e,t),Ce.init(e,t);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(Rg(...n)),e.includes=(...n)=>e.check(jg(...n)),e.startsWith=(...n)=>e.check(Ng(...n)),e.endsWith=(...n)=>e.check(Ig(...n)),e.min=(...n)=>e.check(is(...n)),e.max=(...n)=>e.check(vu(...n)),e.length=(...n)=>e.check($u(...n)),e.nonempty=(...n)=>e.check(is(1,...n)),e.lowercase=n=>e.check(Tg(n)),e.uppercase=n=>e.check(Cg(n)),e.trim=()=>e.check(xg()),e.normalize=(...n)=>e.check(Og(...n)),e.toLowerCase=()=>e.check(Ag()),e.toUpperCase=()=>e.check(Mg())}),Yg=z("ZodString",(e,t)=>{na.init(e,t),bu.init(e,t),e.email=r=>e.check(Wm(Xg,r)),e.url=r=>e.check(yu(Su,r)),e.jwt=r=>e.check(hg(m_,r)),e.emoji=r=>e.check(Xm(t_,r)),e.guid=r=>e.check(Oc(zc,r)),e.uuid=r=>e.check(Bm(An,r)),e.uuidv4=r=>e.check(Jm(An,r)),e.uuidv6=r=>e.check(Qm(An,r)),e.uuidv7=r=>e.check(Ym(An,r)),e.nanoid=r=>e.check(eg(r_,r)),e.guid=r=>e.check(Oc(zc,r)),e.cuid=r=>e.check(tg(n_,r)),e.cuid2=r=>e.check(rg(s_,r)),e.ulid=r=>e.check(ng(o_,r)),e.base64=r=>e.check(ug(f_,r)),e.base64url=r=>e.check(dg(h_,r)),e.xid=r=>e.check(sg(a_,r)),e.ksuid=r=>e.check(og(i_,r)),e.ipv4=r=>e.check(ag(c_,r)),e.ipv6=r=>e.check(ig(l_,r)),e.cidrv4=r=>e.check(cg(u_,r)),e.cidrv6=r=>e.check(lg(d_,r)),e.e164=r=>e.check(fg(p_,r)),e.datetime=r=>e.check(wu(r)),e.date=r=>e.check(Lg(r)),e.time=r=>e.check(Hg(r)),e.duration=r=>e.check(Kg(r))});function R(e){return Gm(Yg,e)}const Ie=z("ZodStringFormat",(e,t)=>{je.init(e,t),bu.init(e,t)}),Xg=z("ZodEmail",(e,t)=>{Yp.init(e,t),Ie.init(e,t)}),zc=z("ZodGUID",(e,t)=>{Jp.init(e,t),Ie.init(e,t)}),An=z("ZodUUID",(e,t)=>{Qp.init(e,t),Ie.init(e,t)}),Su=z("ZodURL",(e,t)=>{Xp.init(e,t),Ie.init(e,t)});function e_(e){return yu(Su,e)}const t_=z("ZodEmoji",(e,t)=>{em.init(e,t),Ie.init(e,t)}),r_=z("ZodNanoID",(e,t)=>{tm.init(e,t),Ie.init(e,t)}),n_=z("ZodCUID",(e,t)=>{rm.init(e,t),Ie.init(e,t)}),s_=z("ZodCUID2",(e,t)=>{nm.init(e,t),Ie.init(e,t)}),o_=z("ZodULID",(e,t)=>{sm.init(e,t),Ie.init(e,t)}),a_=z("ZodXID",(e,t)=>{om.init(e,t),Ie.init(e,t)}),i_=z("ZodKSUID",(e,t)=>{am.init(e,t),Ie.init(e,t)}),c_=z("ZodIPv4",(e,t)=>{dm.init(e,t),Ie.init(e,t)}),l_=z("ZodIPv6",(e,t)=>{fm.init(e,t),Ie.init(e,t)}),u_=z("ZodCIDRv4",(e,t)=>{hm.init(e,t),Ie.init(e,t)}),d_=z("ZodCIDRv6",(e,t)=>{pm.init(e,t),Ie.init(e,t)}),f_=z("ZodBase64",(e,t)=>{mm.init(e,t),Ie.init(e,t)}),h_=z("ZodBase64URL",(e,t)=>{_m.init(e,t),Ie.init(e,t)}),p_=z("ZodE164",(e,t)=>{ym.init(e,t),Ie.init(e,t)}),m_=z("ZodJWT",(e,t)=>{$m.init(e,t),Ie.init(e,t)}),sa=z("ZodNumber",(e,t)=>{gu.init(e,t),Ce.init(e,t),e.gt=(n,s)=>e.check(Ac(n,s)),e.gte=(n,s)=>e.check(Gs(n,s)),e.min=(n,s)=>e.check(Gs(n,s)),e.lt=(n,s)=>e.check(xc(n,s)),e.lte=(n,s)=>e.check(Ks(n,s)),e.max=(n,s)=>e.check(Ks(n,s)),e.int=n=>e.check(qc(n)),e.safe=n=>e.check(qc(n)),e.positive=n=>e.check(Ac(0,n)),e.nonnegative=n=>e.check(Gs(0,n)),e.negative=n=>e.check(xc(0,n)),e.nonpositive=n=>e.check(Ks(0,n)),e.multipleOf=(n,s)=>e.check(Mc(n,s)),e.step=(n,s)=>e.check(Mc(n,s)),e.finite=()=>e;const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function fe(e){return yg(sa,e)}const g_=z("ZodNumberFormat",(e,t)=>{wm.init(e,t),sa.init(e,t)});function qc(e){return $g(g_,e)}const __=z("ZodBoolean",(e,t)=>{bm.init(e,t),Ce.init(e,t)});function ye(e){return wg(__,e)}const y_=z("ZodUndefined",(e,t)=>{Sm.init(e,t),Ce.init(e,t)});function fo(e){return bg(y_,e)}const v_=z("ZodNull",(e,t)=>{Em.init(e,t),Ce.init(e,t)});function $_(e){return Sg(v_,e)}const w_=z("ZodAny",(e,t)=>{km.init(e,t),Ce.init(e,t)});function oa(){return Eg(w_)}const b_=z("ZodUnknown",(e,t)=>{Pm.init(e,t),Ce.init(e,t)});function Se(){return kg(b_)}const S_=z("ZodNever",(e,t)=>{Rm.init(e,t),Ce.init(e,t)});function ho(e){return Pg(S_,e)}const E_=z("ZodArray",(e,t)=>{Tm.init(e,t),Ce.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(is(r,n)),e.nonempty=r=>e.check(is(1,r)),e.max=(r,n)=>e.check(vu(r,n)),e.length=(r,n)=>e.check($u(r,n)),e.unwrap=()=>e.element});function H(e,t){return zg(E_,e,t)}const Eu=z("ZodObject",(e,t)=>{Cm.init(e,t),Ce.init(e,t),Te(e,"shape",()=>t.shape),e.keyof=()=>lt(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Se()}),e.loose=()=>e.clone({...e._zod.def,catchall:Se()}),e.strict=()=>e.clone({...e._zod.def,catchall:ho()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>Yh(e,r),e.merge=r=>Xh(e,r),e.pick=r=>Jh(e,r),e.omit=r=>Qh(e,r),e.partial=(...r)=>ep(Tu,e,r[0]),e.required=(...r)=>tp(Cu,e,r[0])});function A(e,t){const r={type:"object",get shape(){return ks(this,"shape",{...e}),this.shape},...te(t)};return new Eu(r)}function Be(e,t){return new Eu({type:"object",get shape(){return ks(this,"shape",{...e}),this.shape},catchall:Se(),...te(t)})}const ku=z("ZodUnion",(e,t)=>{_u.init(e,t),Ce.init(e,t),e.options=t.options});function _e(e,t){return new ku({type:"union",options:e,...te(t)})}const k_=z("ZodDiscriminatedUnion",(e,t)=>{ku.init(e,t),jm.init(e,t)});function Pu(e,t,r){return new k_({type:"union",options:t,discriminator:e,...te(r)})}const P_=z("ZodIntersection",(e,t)=>{Nm.init(e,t),Ce.init(e,t)});function aa(e,t){return new P_({type:"intersection",left:e,right:t})}const R_=z("ZodRecord",(e,t)=>{Im.init(e,t),Ce.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function ve(e,t,r){return new R_({type:"record",keyType:e,valueType:t,...te(r)})}const po=z("ZodEnum",(e,t)=>{Om.init(e,t),Ce.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(n,s)=>{const o={};for(const a of n)if(r.has(a))o[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new po({...t,checks:[],...te(s),entries:o})},e.exclude=(n,s)=>{const o={...t.entries};for(const a of n)if(r.has(a))delete o[a];else throw new Error(`Key ${a} not found in enum`);return new po({...t,checks:[],...te(s),entries:o})}});function lt(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new po({type:"enum",entries:r,...te(t)})}const T_=z("ZodLiteral",(e,t)=>{xm.init(e,t),Ce.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function N(e,t){return new T_({type:"literal",values:Array.isArray(e)?e:[e],...te(t)})}const C_=z("ZodTransform",(e,t)=>{Am.init(e,t),Ce.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=o=>{if(typeof o=="string")r.issues.push(fn(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(fn(a))}};const s=t.transform(r.value,r);return s instanceof Promise?s.then(o=>(r.value=o,r)):(r.value=s,r)}});function Ru(e){return new C_({type:"transform",transform:e})}const Tu=z("ZodOptional",(e,t)=>{Mm.init(e,t),Ce.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ne(e){return new Tu({type:"optional",innerType:e})}const j_=z("ZodNullable",(e,t)=>{zm.init(e,t),Ce.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Dc(e){return new j_({type:"nullable",innerType:e})}const N_=z("ZodDefault",(e,t)=>{qm.init(e,t),Ce.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function I_(e,t){return new N_({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const O_=z("ZodPrefault",(e,t)=>{Dm.init(e,t),Ce.init(e,t),e.unwrap=()=>e._zod.def.innerType});function x_(e,t){return new O_({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const Cu=z("ZodNonOptional",(e,t)=>{Um.init(e,t),Ce.init(e,t),e.unwrap=()=>e._zod.def.innerType});function A_(e,t){return new Cu({type:"nonoptional",innerType:e,...te(t)})}const M_=z("ZodCatch",(e,t)=>{Fm.init(e,t),Ce.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function z_(e,t){return new M_({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const q_=z("ZodPipe",(e,t)=>{Lm.init(e,t),Ce.init(e,t),e.in=t.in,e.out=t.out});function mo(e,t){return new q_({type:"pipe",in:e,out:t})}const D_=z("ZodReadonly",(e,t)=>{Vm.init(e,t),Ce.init(e,t)});function U_(e){return new D_({type:"readonly",innerType:e})}const ju=z("ZodCustom",(e,t)=>{Hm.init(e,t),Ce.init(e,t)});function F_(e){const t=new it({check:"custom"});return t._zod.check=e,t}function L_(e,t){return qg(ju,e??(()=>!0),t)}function V_(e,t={}){return Dg(ju,e,t)}function H_(e){const t=F_(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(fn(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(fn(s))}},e(r.value,r)));return t}function Nu(e,t){return mo(Ru(e),t)}const Z_={custom:"custom"};function K_(e){return vg(sa,e)}const Ts="2025-11-25",G_=[Ts,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],rr="io.modelcontextprotocol/related-task",Cs="2.0",Ue=L_(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Iu=_e([R(),fe().int()]),Ou=R();Be({ttl:fe().optional(),pollInterval:fe().optional()});const W_=A({ttl:fe().optional()}),B_=A({taskId:R()}),ia=Be({progressToken:Iu.optional(),[rr]:B_.optional()}),ut=A({_meta:ia.optional()}),vn=ut.extend({task:W_.optional()}),J_=e=>vn.safeParse(e).success,Je=A({method:R(),params:ut.loose().optional()}),ht=A({_meta:ia.optional()}),pt=A({method:R(),params:ht.loose().optional()}),Qe=Be({_meta:ia.optional()}),$n=_e([R(),fe().int()]),xu=A({jsonrpc:N(Cs),id:$n,...Je.shape}).strict(),go=e=>xu.safeParse(e).success,Au=A({jsonrpc:N(Cs),...pt.shape}).strict(),Q_=e=>Au.safeParse(e).success,ca=A({jsonrpc:N(Cs),id:$n,result:Qe}).strict(),Jr=e=>ca.safeParse(e).success;var ae;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(ae||(ae={}));const la=A({jsonrpc:N(Cs),id:$n.optional(),error:A({code:fe().int(),message:R(),data:Se().optional()})}).strict(),Y_=e=>la.safeParse(e).success,Wn=_e([xu,Au,ca,la]);_e([ca,la]);const Er=Qe.strict(),X_=ht.extend({requestId:$n.optional(),reason:R().optional()}),ua=pt.extend({method:N("notifications/cancelled"),params:X_}),ey=A({src:R(),mimeType:R().optional(),sizes:H(R()).optional(),theme:lt(["light","dark"]).optional()}),wn=A({icons:H(ey).optional()}),Nr=A({name:R(),title:R().optional()}),js=Nr.extend({...Nr.shape,...wn.shape,version:R(),websiteUrl:R().optional(),description:R().optional()}),ty=aa(A({applyDefaults:ye().optional()}),ve(R(),Se())),ry=Nu(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,aa(A({form:ty.optional(),url:Ue.optional()}),ve(R(),Se()).optional())),ny=Be({list:Ue.optional(),cancel:Ue.optional(),requests:Be({sampling:Be({createMessage:Ue.optional()}).optional(),elicitation:Be({create:Ue.optional()}).optional()}).optional()}),sy=Be({list:Ue.optional(),cancel:Ue.optional(),requests:Be({tools:Be({call:Ue.optional()}).optional()}).optional()}),oy=A({experimental:ve(R(),Ue).optional(),sampling:A({context:Ue.optional(),tools:Ue.optional()}).optional(),elicitation:ry.optional(),roots:A({listChanged:ye().optional()}).optional(),tasks:ny.optional(),extensions:ve(R(),Ue).optional()}),ay=ut.extend({protocolVersion:R(),capabilities:oy,clientInfo:js}),iy=Je.extend({method:N("initialize"),params:ay}),cy=A({experimental:ve(R(),Ue).optional(),logging:Ue.optional(),completions:Ue.optional(),prompts:A({listChanged:ye().optional()}).optional(),resources:A({subscribe:ye().optional(),listChanged:ye().optional()}).optional(),tools:A({listChanged:ye().optional()}).optional(),tasks:sy.optional(),extensions:ve(R(),Ue).optional()}),Mu=Qe.extend({protocolVersion:R(),capabilities:cy,serverInfo:js,instructions:R().optional()}),zu=pt.extend({method:N("notifications/initialized"),params:ht.optional()}),ly=e=>zu.safeParse(e).success,Ns=Je.extend({method:N("ping"),params:ut.optional()}),uy=A({progress:fe(),total:Ne(fe()),message:Ne(R())}),dy=A({...ht.shape,...uy.shape,progressToken:Iu}),da=pt.extend({method:N("notifications/progress"),params:dy}),fy=ut.extend({cursor:Ou.optional()}),bn=Je.extend({params:fy.optional()}),Sn=Qe.extend({nextCursor:Ou.optional()}),hy=lt(["working","input_required","completed","failed","cancelled"]),En=A({taskId:R(),status:hy,ttl:_e([fe(),$_()]),createdAt:R(),lastUpdatedAt:R(),pollInterval:Ne(fe()),statusMessage:Ne(R())}),hn=Qe.extend({task:En}),py=ht.merge(En),cs=pt.extend({method:N("notifications/tasks/status"),params:py}),fa=Je.extend({method:N("tasks/get"),params:ut.extend({taskId:R()})}),ha=Qe.merge(En),pa=Je.extend({method:N("tasks/result"),params:ut.extend({taskId:R()})});Qe.loose();const ma=bn.extend({method:N("tasks/list")}),ga=Sn.extend({tasks:H(En)}),_a=Je.extend({method:N("tasks/cancel"),params:ut.extend({taskId:R()})}),my=Qe.merge(En),qu=A({uri:R(),mimeType:Ne(R()),_meta:ve(R(),Se()).optional()}),Du=qu.extend({text:R()}),ya=R().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Uu=qu.extend({blob:ya}),kn=lt(["user","assistant"]),Mr=A({audience:H(kn).optional(),priority:fe().min(0).max(1).optional(),lastModified:wu({offset:!0}).optional()}),Fu=A({...Nr.shape,...wn.shape,uri:R(),description:Ne(R()),mimeType:Ne(R()),size:Ne(fe()),annotations:Mr.optional(),_meta:Ne(Be({}))}),gy=A({...Nr.shape,...wn.shape,uriTemplate:R(),description:Ne(R()),mimeType:Ne(R()),annotations:Mr.optional(),_meta:Ne(Be({}))}),Lu=bn.extend({method:N("resources/list")}),va=Sn.extend({resources:H(Fu)}),Vu=bn.extend({method:N("resources/templates/list")}),$a=Sn.extend({resourceTemplates:H(gy)}),wa=ut.extend({uri:R()}),_y=wa,Hu=Je.extend({method:N("resources/read"),params:_y}),ba=Qe.extend({contents:H(_e([Du,Uu]))}),Sa=pt.extend({method:N("notifications/resources/list_changed"),params:ht.optional()}),yy=wa,vy=Je.extend({method:N("resources/subscribe"),params:yy}),$y=wa,wy=Je.extend({method:N("resources/unsubscribe"),params:$y}),by=ht.extend({uri:R()}),Sy=pt.extend({method:N("notifications/resources/updated"),params:by}),Ey=A({name:R(),description:Ne(R()),required:Ne(ye())}),ky=A({...Nr.shape,...wn.shape,description:Ne(R()),arguments:Ne(H(Ey)),_meta:Ne(Be({}))}),Zu=bn.extend({method:N("prompts/list")}),Ea=Sn.extend({prompts:H(ky)}),Py=ut.extend({name:R(),arguments:ve(R(),R()).optional()}),Ry=Je.extend({method:N("prompts/get"),params:Py}),ka=A({type:N("text"),text:R(),annotations:Mr.optional(),_meta:ve(R(),Se()).optional()}),Pa=A({type:N("image"),data:ya,mimeType:R(),annotations:Mr.optional(),_meta:ve(R(),Se()).optional()}),Ra=A({type:N("audio"),data:ya,mimeType:R(),annotations:Mr.optional(),_meta:ve(R(),Se()).optional()}),Ty=A({type:N("tool_use"),name:R(),id:R(),input:ve(R(),Se()),_meta:ve(R(),Se()).optional()}),Ku=A({type:N("resource"),resource:_e([Du,Uu]),annotations:Mr.optional(),_meta:ve(R(),Se()).optional()}),Gu=Fu.extend({type:N("resource_link")}),Pn=_e([ka,Pa,Ra,Gu,Ku]),Cy=A({role:kn,content:Pn}),Wu=Qe.extend({description:R().optional(),messages:H(Cy)}),Ta=pt.extend({method:N("notifications/prompts/list_changed"),params:ht.optional()}),jy=A({title:R().optional(),readOnlyHint:ye().optional(),destructiveHint:ye().optional(),idempotentHint:ye().optional(),openWorldHint:ye().optional()}),Ny=A({taskSupport:lt(["required","optional","forbidden"]).optional()}),Ca=A({...Nr.shape,...wn.shape,description:R().optional(),inputSchema:A({type:N("object"),properties:ve(R(),Ue).optional(),required:H(R()).optional()}).catchall(Se()),outputSchema:A({type:N("object"),properties:ve(R(),Ue).optional(),required:H(R()).optional()}).catchall(Se()).optional(),annotations:jy.optional(),execution:Ny.optional(),_meta:ve(R(),Se()).optional()}),Iy=bn.extend({method:N("tools/list")}),ja=Sn.extend({tools:H(Ca)}),lr=Qe.extend({content:H(Pn).default([]),structuredContent:ve(R(),Se()).optional(),isError:ye().optional()});lr.or(Qe.extend({toolResult:Se()}));const Oy=vn.extend({name:R(),arguments:ve(R(),Se()).optional()}),Bu=Je.extend({method:N("tools/call"),params:Oy}),Na=pt.extend({method:N("notifications/tools/list_changed"),params:ht.optional()}),xy=A({autoRefresh:ye().default(!0),debounceMs:fe().int().nonnegative().default(300)}),Ju=lt(["debug","info","notice","warning","error","critical","alert","emergency"]),Ay=ut.extend({level:Ju}),My=Je.extend({method:N("logging/setLevel"),params:Ay}),zy=ht.extend({level:Ju,logger:R().optional(),data:Se()}),Qu=pt.extend({method:N("notifications/message"),params:zy}),qy=A({name:R().optional()}),Dy=A({hints:H(qy).optional(),costPriority:fe().min(0).max(1).optional(),speedPriority:fe().min(0).max(1).optional(),intelligencePriority:fe().min(0).max(1).optional()}),Uy=A({mode:lt(["auto","required","none"]).optional()}),Fy=A({type:N("tool_result"),toolUseId:R().describe("The unique identifier for the corresponding tool call."),content:H(Pn).default([]),structuredContent:A({}).loose().optional(),isError:ye().optional(),_meta:ve(R(),Se()).optional()}),Ly=Pu("type",[ka,Pa,Ra]),ls=Pu("type",[ka,Pa,Ra,Ty,Fy]),Vy=A({role:kn,content:_e([ls,H(ls)]),_meta:ve(R(),Se()).optional()}),Hy=vn.extend({messages:H(Vy),modelPreferences:Dy.optional(),systemPrompt:R().optional(),includeContext:lt(["none","thisServer","allServers"]).optional(),temperature:fe().optional(),maxTokens:fe().int(),stopSequences:H(R()).optional(),metadata:Ue.optional(),tools:H(Ca).optional(),toolChoice:Uy.optional()}),Ia=Je.extend({method:N("sampling/createMessage"),params:Hy}),Yu=Qe.extend({model:R(),stopReason:Ne(lt(["endTurn","stopSequence","maxTokens"]).or(R())),role:kn,content:Ly}),Xu=Qe.extend({model:R(),stopReason:Ne(lt(["endTurn","stopSequence","maxTokens","toolUse"]).or(R())),role:kn,content:_e([ls,H(ls)])}),Zy=A({type:N("boolean"),title:R().optional(),description:R().optional(),default:ye().optional()}),Ky=A({type:N("string"),title:R().optional(),description:R().optional(),minLength:fe().optional(),maxLength:fe().optional(),format:lt(["email","uri","date","date-time"]).optional(),default:R().optional()}),Gy=A({type:lt(["number","integer"]),title:R().optional(),description:R().optional(),minimum:fe().optional(),maximum:fe().optional(),default:fe().optional()}),Wy=A({type:N("string"),title:R().optional(),description:R().optional(),enum:H(R()),default:R().optional()}),By=A({type:N("string"),title:R().optional(),description:R().optional(),oneOf:H(A({const:R(),title:R()})),default:R().optional()}),Jy=A({type:N("string"),title:R().optional(),description:R().optional(),enum:H(R()),enumNames:H(R()).optional(),default:R().optional()}),Qy=_e([Wy,By]),Yy=A({type:N("array"),title:R().optional(),description:R().optional(),minItems:fe().optional(),maxItems:fe().optional(),items:A({type:N("string"),enum:H(R())}),default:H(R()).optional()}),Xy=A({type:N("array"),title:R().optional(),description:R().optional(),minItems:fe().optional(),maxItems:fe().optional(),items:A({anyOf:H(A({const:R(),title:R()}))}),default:H(R()).optional()}),ev=_e([Yy,Xy]),tv=_e([Jy,Qy,ev]),rv=_e([tv,Zy,Ky,Gy]),nv=vn.extend({mode:N("form").optional(),message:R(),requestedSchema:A({type:N("object"),properties:ve(R(),rv),required:H(R()).optional()})}),sv=vn.extend({mode:N("url"),message:R(),elicitationId:R(),url:R().url()}),ov=_e([nv,sv]),ed=Je.extend({method:N("elicitation/create"),params:ov}),av=ht.extend({elicitationId:R()}),iv=pt.extend({method:N("notifications/elicitation/complete"),params:av}),td=Qe.extend({action:lt(["accept","decline","cancel"]),content:Nu(e=>e===null?void 0:e,ve(R(),_e([R(),fe(),ye(),H(R())])).optional())}),cv=A({type:N("ref/resource"),uri:R()}),lv=A({type:N("ref/prompt"),name:R()}),uv=ut.extend({ref:_e([lv,cv]),argument:A({name:R(),value:R()}),context:A({arguments:ve(R(),R()).optional()}).optional()}),dv=Je.extend({method:N("completion/complete"),params:uv}),rd=Qe.extend({completion:Be({values:H(R()).max(100),total:Ne(fe().int()),hasMore:Ne(ye())})}),fv=A({uri:R().startsWith("file://"),name:R().optional(),_meta:ve(R(),Se()).optional()}),hv=Je.extend({method:N("roots/list"),params:ut.optional()}),pv=Qe.extend({roots:H(fv)}),mv=pt.extend({method:N("notifications/roots/list_changed"),params:ht.optional()});_e([Ns,iy,dv,My,Ry,Zu,Lu,Vu,Hu,vy,wy,Bu,Iy,fa,pa,ma,_a]);_e([ua,da,zu,mv,cs]);_e([Er,Yu,Xu,td,pv,ha,ga,hn]);_e([Ns,Ia,ed,hv,fa,pa,ma,_a]);_e([ua,da,Qu,Sy,Sa,Na,Ta,cs,iv]);_e([Er,Mu,rd,Wu,Ea,va,$a,ba,lr,ja,ha,ga,hn]);class se extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===ae.UrlElicitationRequired&&n){const s=n;if(s.elicitations)return new gv(s.elicitations,r)}return new se(t,r,n)}}class gv extends se{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(ae.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){var t;return((t=this.data)==null?void 0:t.elicitations)??[]}}function Oa(e){return!!e._zod}function Ut(e,t){return Oa(e)?iu(e,t):e.safeParse(t)}function nd(e){var r,n;if(!e)return;let t;if(Oa(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 sd(e){var s;if(Oa(e)){const a=(s=e._zod)==null?void 0:s.def;if(a){if(a.value!==void 0)return a.value;if(Array.isArray(a.values)&&a.values.length>0)return a.values[0]}}const r=e._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}const n=e.value;if(n!==void 0)return n}function Qt(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Uc(e){const t=nd(e),r=t==null?void 0:t.method;if(!r)throw new Error("Schema is missing a method literal");const n=sd(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Fc(e,t){const r=Ut(e,t);if(!r.success)throw r.error;return r.data}const _v=6e4;class od{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(ua,r=>{this._oncancel(r)}),this.setNotificationHandler(da,r=>{this._onprogress(r)}),this.setRequestHandler(Ns,r=>({})),this._taskStore=t==null?void 0:t.taskStore,this._taskMessageQueue=t==null?void 0:t.taskMessageQueue,this._taskStore&&(this.setRequestHandler(fa,async(r,n)=>{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new se(ae.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(pa,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 y=l,_=new se(y.error.code,y.error.message,y.error.data);f(_)}else{const y=c.type==="response"?"Response":"Error";this._onerror(new Error(`${y} handler missing for request ${d}`))}continue}await((i=this._transport)==null?void 0:i.send(c.message,{relatedRequestId:n.requestId}))}}const a=await this._taskStore.getTask(o,n.sessionId);if(!a)throw new se(ae.InvalidParams,`Task not found: ${o}`);if(!Qt(a.status))return await this._waitForTaskUpdate(o,n.signal),await s();if(Qt(a.status)){const c=await this._taskStore.getTaskResult(o,n.sessionId);return this._clearTaskQueue(o),{...c,_meta:{...c._meta,[rr]:{taskId:o}}}}return await s()};return await s()}),this.setRequestHandler(ma,async(r,n)=>{var s;try{const{tasks:o,nextCursor:a}=await this._taskStore.listTasks((s=r.params)==null?void 0:s.cursor,n.sessionId);return{tasks:o,nextCursor:a,_meta:{}}}catch(o){throw new se(ae.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(_a,async(r,n)=>{try{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new se(ae.InvalidParams,`Task not found: ${r.params.taskId}`);if(Qt(s.status))throw new se(ae.InvalidParams,`Cannot cancel task in terminal status: ${s.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);const o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new se(ae.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(s){throw s instanceof se?s:new se(ae.InvalidRequest,`Failed to cancel task: ${s instanceof Error?s.message:String(s)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;const r=this._requestHandlerAbortControllers.get(t.params.requestId);r==null||r.abort(t.params.reason)}_setupTimeout(t,r,n,s,o=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(s,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:o,onTimeout:s})}_resetTimeout(t){const r=this._timeoutInfo.get(t);if(!r)return!1;const n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),se.fromError(ae.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){const r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){var o,a,i;if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;const r=(o=this.transport)==null?void 0:o.onclose;this._transport.onclose=()=>{r==null||r(),this._onclose()};const n=(a=this.transport)==null?void 0:a.onerror;this._transport.onerror=c=>{n==null||n(c),this._onerror(c)};const s=(i=this._transport)==null?void 0:i.onmessage;this._transport.onmessage=(c,l)=>{s==null||s(c,l),Jr(c)||Y_(c)?this._onresponse(c):go(c)?this._onrequest(c,l):Q_(c)?this._onnotification(c):this._onerror(new Error(`Unknown message type: ${JSON.stringify(c)}`))},await this._transport.start()}_onclose(){var n;const t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const s of this._timeoutInfo.values())clearTimeout(s.timeoutId);this._timeoutInfo.clear();for(const s of this._requestHandlerAbortControllers.values())s.abort();this._requestHandlerAbortControllers.clear();const r=se.fromError(ae.ConnectionClosed,"Connection closed");this._transport=void 0,(n=this.onclose)==null||n.call(this);for(const s of t.values())s(r)}_onerror(t){var r;(r=this.onerror)==null||r.call(this,t)}_onnotification(t){const r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){var d,f,y,_;const n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,s=this._transport,o=(y=(f=(d=t.params)==null?void 0:d._meta)==null?void 0:f[rr])==null?void 0:y.taskId;if(n===void 0){const g={jsonrpc:"2.0",id:t.id,error:{code:ae.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:g,timestamp:Date.now()},s==null?void 0:s.sessionId).catch(v=>this._onerror(new Error(`Failed to enqueue error response: ${v}`))):s==null||s.send(g).catch(v=>this._onerror(new Error(`Failed to send an error response: ${v}`)));return}const a=new AbortController;this._requestHandlerAbortControllers.set(t.id,a);const i=J_(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 g=>{if(a.signal.aborted)return;const v={relatedRequestId:t.id};o&&(v.relatedTask={taskId:o}),await this.notification(g,v)},sendRequest:async(g,v,m)=>{var k;if(a.signal.aborted)throw new se(ae.ConnectionClosed,"Request was cancelled");const h={...m,relatedRequestId:t.id};o&&!h.relatedTask&&(h.relatedTask={taskId:o});const $=((k=h.relatedTask)==null?void 0:k.taskId)??o;return $&&c&&await c.updateTaskStatus($,"input_required"),await this.request(g,v,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 g=>{if(a.signal.aborted)return;const v={result:g,jsonrpc:"2.0",id:t.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:v,timestamp:Date.now()},s==null?void 0:s.sessionId):await(s==null?void 0:s.send(v))},async g=>{if(a.signal.aborted)return;const v={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(g.code)?g.code:ae.InternalError,message:g.message??"Internal error",...g.data!==void 0&&{data:g.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:v,timestamp:Date.now()},s==null?void 0:s.sessionId):await(s==null?void 0:s.send(v))}).catch(g=>this._onerror(new Error(`Failed to send response: ${g}`))).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),Jr(t))n(t);else{const a=new se(t.error.code,t.error.message,t.error.data);n(a)}return}const s=this._responseHandlers.get(r);if(s===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let o=!1;if(Jr(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),Jr(t))s(t);else{const a=se.fromError(t.error.code,t.error.message,t.error.data);s(a)}}get transport(){return this._transport}async close(){var t;await((t=this._transport)==null?void 0:t.close())}async*requestStream(t,r,n){var a,i;const{task:s}=n??{};if(!s){try{yield{type:"result",result:await this.request(t,r,n)}}catch(c){yield{type:"error",error:c instanceof se?c:new se(ae.InternalError,String(c))}}return}let o;try{const c=await this.request(t,hn,n);if(c.task)o=c.task.taskId,yield{type:"taskCreated",task:c.task};else throw new se(ae.InternalError,"Task creation did not return a task");for(;;){const l=await this.getTask({taskId:o},n);if(yield{type:"taskStatus",task:l},Qt(l.status)){l.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)}:l.status==="failed"?yield{type:"error",error:new se(ae.InternalError,`Task ${o} failed`)}:l.status==="cancelled"&&(yield{type:"error",error:new se(ae.InternalError,`Task ${o} was cancelled`)});return}if(l.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)};return}const d=l.pollInterval??((a=this._options)==null?void 0:a.defaultTaskPollInterval)??1e3;await new Promise(f=>setTimeout(f,d)),(i=n==null?void 0:n.signal)==null||i.throwIfAborted()}}catch(c){yield{type:"error",error:c instanceof se?c:new se(ae.InternalError,String(c))}}}request(t,r,n){const{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a,task:i,relatedTask:c}=n??{};return new Promise((l,d)=>{var $,k,T,E,x;const f=M=>{d(M)};if(!this._transport){f(new Error("Not connected"));return}if((($=this._options)==null?void 0:$.enforceStrictCapabilities)===!0)try{this.assertCapabilityForMethod(t.method),i&&this.assertTaskCapability(t.method)}catch(M){f(M);return}(k=n==null?void 0:n.signal)==null||k.throwIfAborted();const y=this._requestMessageId++,_={...t,jsonrpc:"2.0",id:y};n!=null&&n.onprogress&&(this._progressHandlers.set(y,n.onprogress),_.params={...t.params,_meta:{...((T=t.params)==null?void 0:T._meta)||{},progressToken:y}}),i&&(_.params={..._.params,task:i}),c&&(_.params={..._.params,_meta:{...((E=_.params)==null?void 0:E._meta)||{},[rr]:c}});const g=M=>{var G;this._responseHandlers.delete(y),this._progressHandlers.delete(y),this._cleanupTimeout(y),(G=this._transport)==null||G.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:y,reason:String(M)}},{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a}).catch(V=>this._onerror(new Error(`Failed to send cancellation: ${V}`)));const L=M instanceof se?M:new se(ae.RequestTimeout,String(M));d(L)};this._responseHandlers.set(y,M=>{var L;if(!((L=n==null?void 0:n.signal)!=null&&L.aborted)){if(M instanceof Error)return d(M);try{const G=Ut(r,M.result);G.success?l(G.data):d(G.error)}catch(G){d(G)}}}),(x=n==null?void 0:n.signal)==null||x.addEventListener("abort",()=>{var M;g((M=n==null?void 0:n.signal)==null?void 0:M.reason)});const v=(n==null?void 0:n.timeout)??_v,m=()=>g(se.fromError(ae.RequestTimeout,"Request timed out",{timeout:v}));this._setupTimeout(y,v,n==null?void 0:n.maxTotalTimeout,m,(n==null?void 0:n.resetTimeoutOnProgress)??!1);const h=c==null?void 0:c.taskId;if(h){const M=L=>{const G=this._responseHandlers.get(y);G?G(L):this._onerror(new Error(`Response handler missing for side-channeled request ${y}`))};this._requestResolvers.set(y,M),this._enqueueTaskMessage(h,{type:"request",message:_,timestamp:Date.now()}).catch(L=>{this._cleanupTimeout(y),d(L)})}else this._transport.send(_,{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a}).catch(M=>{this._cleanupTimeout(y),d(M)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},ha,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},ga,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},my,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)||{},[rr]: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 y,_;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:{...((y=f.params)==null?void 0:y._meta)||{},[rr]:r.relatedTask}}}),(_=this._transport)==null||_.send(f,r).catch(g=>this._onerror(g))});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)||{},[rr]:r.relatedTask}}}),await this._transport.send(a,r)}setRequestHandler(t,r){const n=Uc(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,o)=>{const a=Fc(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=Uc(t);this._notificationHandlers.set(n,s=>{const o=Fc(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"&&go(s.message)){const o=s.message.id,a=this._requestResolvers.get(o);a?(a(new se(ae.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r){var s,o;let n=((s=this._options)==null?void 0:s.defaultTaskPollInterval)??1e3;try{const a=await((o=this._taskStore)==null?void 0:o.getTask(t));a!=null&&a.pollInterval&&(n=a.pollInterval)}catch{}return new Promise((a,i)=>{if(r.aborted){i(new se(ae.InvalidRequest,"Request cancelled"));return}const c=setTimeout(a,n);r.addEventListener("abort",()=>{clearTimeout(c),i(new se(ae.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){const n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async s=>{if(!t)throw new Error("No request provided");return await n.createTask(s,t.id,{method:t.method,params:t.params},r)},getTask:async s=>{const o=await n.getTask(s,r);if(!o)throw new se(ae.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(s,o,a)=>{await n.storeTaskResult(s,o,a,r);const i=await n.getTask(s,r);if(i){const c=cs.parse({method:"notifications/tasks/status",params:i});await this.notification(c),Qt(i.status)&&this._cleanupTaskProgressHandler(s)}},getTaskResult:s=>n.getTaskResult(s,r),updateTaskStatus:async(s,o,a)=>{const i=await n.getTask(s,r);if(!i)throw new se(ae.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(Qt(i.status))throw new se(ae.InvalidParams,`Cannot update task "${s}" from terminal status "${i.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(s,o,a,r);const c=await n.getTask(s,r);if(c){const l=cs.parse({method:"notifications/tasks/status",params:c});await this.notification(l),Qt(c.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>n.listTasks(s,r)}}}function Lc(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function yv(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];Lc(a)&&Lc(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 vv extends od{constructor(){super(...arguments);le(this,"_registeredMethods",new Set);le(this,"_eventSlots",new Map);le(this,"setRequestHandler",(r,n)=>{this._assertMethodNotRegistered(r,"setRequestHandler"),super.setRequestHandler(r,n)});le(this,"setNotificationHandler",(r,n)=>{this._assertMethodNotRegistered(r,"setNotificationHandler"),super.setNotificationHandler(r,n)});le(this,"replaceRequestHandler",(r,n)=>{let s=r.shape.method.value;this._registeredMethods.add(s),super.setRequestHandler(r,n)})}onEventDispatch(r,n){}_ensureEventSlot(r){let n=this._eventSlots.get(r);if(!n){let s=this.eventSchemas[r];if(!s)throw Error(`Unknown event: ${String(r)}`);n={listeners:[]},this._eventSlots.set(r,n);let o=s.shape.method.value;this._registeredMethods.add(o);let a=n;super.setNotificationHandler(s,i=>{var l;let c=i.params;this.onEventDispatch(r,c),(l=a.onHandler)==null||l.call(a,c);for(let d of[...a.listeners])d(c)})}return n}setEventHandler(r,n){let s=this._ensureEventSlot(r);s.onHandler&&n&&console.warn(`[MCP Apps] on${String(r)} handler replaced. Use addEventListener("${String(r)}", …) to add multiple listeners without replacing.`),s.onHandler=n}getEventHandler(r){var n;return(n=this._eventSlots.get(r))==null?void 0:n.onHandler}addEventListener(r,n){this._ensureEventSlot(r).listeners.push(n)}removeEventListener(r,n){let s=this._eventSlots.get(r);if(!s)return;let o=s.listeners.indexOf(n);o!==-1&&s.listeners.splice(o,1)}warnIfRequestHandlerReplaced(r,n,s){n&&s&&console.warn(`[MCP Apps] ${r} handler replaced. Previous handler will no longer be called.`)}_assertMethodNotRegistered(r,n){let s=r.shape.method.value;if(this._registeredMethods.has(s))throw Error(`Handler for "${s}" already registered (via ${n}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._registeredMethods.add(s)}}var ad="2026-01-26",$v="ui/notifications/tool-input-partial",wv=_e([N("light"),N("dark")]).describe("Color theme preference for the host environment."),pn=_e([N("inline"),N("fullscreen"),N("pip")]).describe("Display mode for UI presentation."),bv=_e([N("--color-background-primary"),N("--color-background-secondary"),N("--color-background-tertiary"),N("--color-background-inverse"),N("--color-background-ghost"),N("--color-background-info"),N("--color-background-danger"),N("--color-background-success"),N("--color-background-warning"),N("--color-background-disabled"),N("--color-text-primary"),N("--color-text-secondary"),N("--color-text-tertiary"),N("--color-text-inverse"),N("--color-text-ghost"),N("--color-text-info"),N("--color-text-danger"),N("--color-text-success"),N("--color-text-warning"),N("--color-text-disabled"),N("--color-border-primary"),N("--color-border-secondary"),N("--color-border-tertiary"),N("--color-border-inverse"),N("--color-border-ghost"),N("--color-border-info"),N("--color-border-danger"),N("--color-border-success"),N("--color-border-warning"),N("--color-border-disabled"),N("--color-ring-primary"),N("--color-ring-secondary"),N("--color-ring-inverse"),N("--color-ring-info"),N("--color-ring-danger"),N("--color-ring-success"),N("--color-ring-warning"),N("--font-sans"),N("--font-mono"),N("--font-weight-normal"),N("--font-weight-medium"),N("--font-weight-semibold"),N("--font-weight-bold"),N("--font-text-xs-size"),N("--font-text-sm-size"),N("--font-text-md-size"),N("--font-text-lg-size"),N("--font-heading-xs-size"),N("--font-heading-sm-size"),N("--font-heading-md-size"),N("--font-heading-lg-size"),N("--font-heading-xl-size"),N("--font-heading-2xl-size"),N("--font-heading-3xl-size"),N("--font-text-xs-line-height"),N("--font-text-sm-line-height"),N("--font-text-md-line-height"),N("--font-text-lg-line-height"),N("--font-heading-xs-line-height"),N("--font-heading-sm-line-height"),N("--font-heading-md-line-height"),N("--font-heading-lg-line-height"),N("--font-heading-xl-line-height"),N("--font-heading-2xl-line-height"),N("--font-heading-3xl-line-height"),N("--border-radius-xs"),N("--border-radius-sm"),N("--border-radius-md"),N("--border-radius-lg"),N("--border-radius-xl"),N("--border-radius-full"),N("--border-width-regular"),N("--shadow-hairline"),N("--shadow-sm"),N("--shadow-md"),N("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),Sv=ve(bv.describe(`Style variables for theming MCP apps. - -Individual style keys are optional - hosts may provide any subset of these values. -Values are strings containing CSS values (colors, sizes, font stacks, etc.). - -Note: This type uses \`Record\` rather than \`Partial>\` -for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),_e([R(),fo()]).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.`),Ev=A({method:N("ui/open-link"),params:A({url:R().describe("URL to open in the host's browser")})});A({isError:ye().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough();A({isError:ye().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough();A({isError:ye().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();var kv=A({method:N("ui/notifications/sandbox-proxy-ready"),params:A({})}),xa=A({connectDomains:H(R()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket). - -- Maps to CSP \`connect-src\` directive -- Empty or omitted → no network connections (secure default)`),resourceDomains:H(R()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:H(R()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:H(R()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),Aa=A({camera:A({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:A({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:A({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:A({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),Pv=A({method:N("ui/notifications/size-changed"),params:A({width:fe().optional().describe("New width in pixels."),height:fe().optional().describe("New height in pixels.")})});A({method:N("ui/notifications/tool-input"),params:A({arguments:ve(R(),Se().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})});A({method:N("ui/notifications/tool-input-partial"),params:A({arguments:ve(R(),Se().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})});A({method:N("ui/notifications/tool-cancelled"),params:A({reason:R().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})});var Rv=A({fonts:R().optional()}),Tv=A({variables:Sv.optional().describe("CSS variables for theming the app."),css:Rv.optional().describe("CSS blocks that apps can inject.")});A({method:N("ui/resource-teardown"),params:A({})});var Cv=ve(R(),Se()),Vc=A({text:A({}).optional().describe("Host supports text content blocks."),image:A({}).optional().describe("Host supports image content blocks."),audio:A({}).optional().describe("Host supports audio content blocks."),resource:A({}).optional().describe("Host supports resource content blocks."),resourceLink:A({}).optional().describe("Host supports resource link content blocks."),structuredContent:A({}).optional().describe("Host supports structured content.")}),jv=A({method:N("ui/notifications/request-teardown"),params:A({}).optional()}),Nv=A({experimental:ve(R(),ve(R(),oa()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:A({}).optional().describe("Host supports opening external URLs."),downloadFile:A({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:A({listChanged:ye().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:A({listChanged:ye().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:A({}).optional().describe("Host accepts log messages."),sandbox:A({permissions:Aa.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:xa.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:Vc.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:Vc.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:A({tools:A({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.")}).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")}),Iv=A({experimental:ve(R(),ve(R(),oa()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:A({listChanged:ye().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:H(pn).optional().describe("Display modes the app supports.")}),Ov=A({method:N("ui/notifications/initialized"),params:A({}).optional()});A({csp:xa.optional().describe("Content Security Policy configuration for UI resources."),permissions:Aa.optional().describe("Sandbox permissions requested by the UI resource."),domain:R().optional().describe(`Dedicated origin for view sandbox. - -Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists. - -**Host-dependent:** The format and validation rules for this field are determined by each host. Servers MUST consult host-specific documentation for the expected domain format. Common patterns include: -- Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`) -- URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`) - -If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:ye().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 Hc=A({method:N("ui/request-display-mode"),params:A({mode:pn.describe("The display mode being requested.")})});A({mode:pn.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough();var xv=_e([N("model"),N("app")]).describe("Tool visibility scope - who can access the tool.");A({resourceUri:R().optional(),visibility:H(xv).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:ho().optional(),permissions:ho().optional()});A({mimeTypes:H(R()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});var Av=A({method:N("ui/download-file"),params:A({contents:H(_e([Ku,Gu])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),Mv=A({method:N("ui/message"),params:A({role:N("user").describe('Message role, currently only "user" is supported.'),content:H(Pn).describe("Message content blocks (text, image, etc.).")})});A({method:N("ui/notifications/sandbox-resource-ready"),params:A({html:R().describe("HTML content to load into the inner iframe."),sandbox:R().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:xa.optional().describe("CSP configuration from resource metadata."),permissions:Aa.optional().describe("Sandbox permissions from resource metadata.")})});A({method:N("ui/notifications/tool-result"),params:lr.describe("Standard MCP tool execution result.")});var id=A({toolInfo:A({id:$n.optional().describe("JSON-RPC id of the tools/call request."),tool:Ca.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:wv.optional().describe("Current color theme preference."),styles:Tv.optional().describe("Style configuration for theming the app."),displayMode:pn.optional().describe("How the UI is currently displayed."),availableDisplayModes:H(pn).optional().describe("Display modes the host supports."),containerDimensions:_e([A({height:fe().describe("Fixed container height in pixels.")}),A({maxHeight:_e([fe(),fo()]).optional().describe("Maximum container height in pixels.")})]).and(_e([A({width:fe().describe("Fixed container width in pixels.")}),A({maxWidth:_e([fe(),fo()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other -container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:R().optional().describe("User's language and region preference in BCP 47 format."),timeZone:R().optional().describe("User's timezone in IANA format."),userAgent:R().optional().describe("Host application identifier."),platform:_e([N("web"),N("desktop"),N("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:A({touch:ye().optional().describe("Whether the device supports touch input."),hover:ye().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:A({top:fe().describe("Top safe area inset in pixels."),right:fe().describe("Right safe area inset in pixels."),bottom:fe().describe("Bottom safe area inset in pixels."),left:fe().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough();A({method:N("ui/notifications/host-context-changed"),params:id.describe("Partial context update containing only changed fields.")});var zv=A({method:N("ui/update-model-context"),params:A({content:H(Pn).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:ve(R(),Se().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),qv=A({method:N("ui/initialize"),params:A({appInfo:js.describe("App identification (name and version)."),appCapabilities:Iv.describe("Features and capabilities this app provides."),protocolVersion:R().describe("Protocol version this app supports.")})});A({protocolVersion:R().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:js.describe("Host application identification and version."),hostCapabilities:Nv.describe("Features and capabilities provided by the host."),hostContext:id.describe("Rich context about the host environment.")}).passthrough();class Dv{constructor(t=window.parent,r){le(this,"eventTarget");le(this,"eventSource");le(this,"messageListener");le(this,"onclose");le(this,"onerror");le(this,"onmessage");le(this,"sessionId");le(this,"setProtocolVersion");this.eventTarget=t,this.eventSource=r,this.messageListener=n=>{var o,a,i;if(r&&n.source!==this.eventSource){console.debug("Ignoring message from unknown source",n);return}let s=Wn.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!==$v&&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 Uv=[ad];class Fv extends vv{constructor(r,n,s,o){super(o);le(this,"_client");le(this,"_hostInfo");le(this,"_capabilities");le(this,"_appCapabilities");le(this,"_hostContext",{});le(this,"_appInfo");le(this,"_initializedReceived",!1);le(this,"_baseReplaceRequestHandler",this.replaceRequestHandler);le(this,"replaceRequestHandler",(r,n)=>{this._baseReplaceRequestHandler(r,(s,o)=>(this._initializedReceived||console.warn(`[ext-apps] AppBridge received '${s.method}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`),n(s,o)))});le(this,"eventSchemas",{sizechange:Pv,sandboxready:kv,initialized:Ov,requestteardown:jv,loggingmessage:Qu});le(this,"onping");le(this,"_onmessage");le(this,"_onopenlink");le(this,"_ondownloadfile");le(this,"_onrequestdisplaymode");le(this,"_onupdatemodelcontext");le(this,"_oncalltool");le(this,"_onlistresources");le(this,"_onlistresourcetemplates");le(this,"_onreadresource");le(this,"_onlistprompts");le(this,"sendResourceTeardown",this.teardownResource);this._client=r,this._hostInfo=n,this._capabilities=s,this.addEventListener("initialized",()=>{this._initializedReceived=!0}),this._hostContext=(o==null?void 0:o.hostContext)||{},this.setRequestHandler(qv,a=>this._oninitialize(a)),this.setRequestHandler(Ns,(a,i)=>{var c;return(c=this.onping)==null||c.call(this,a.params,i),{}}),this.replaceRequestHandler(Hc,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(Mv,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(Ev,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(Av,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(Hc,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(zv,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(Bu,async(n,s)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,s)})}set oncreatesamplingmessage(r){this.setRequestHandler(Ia,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(Lu,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(Vu,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(Hu,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(Zu,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:Uv.includes(n)?n:ad,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];Lv(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},Cv,n)}callTool(r,n){return this.request({method:"tools/call",params:r},lr,n)}listTools(r,n){return this.request({method:"tools/list",params:r},ja,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},lr,{signal:o.signal}),n.tools.listChanged&&this._client.setNotificationHandler(Na,s=>this.sendToolListChanged(s.params))),n.resources&&(this.onlistresources=async(s,o)=>this._client.request({method:"resources/list",params:s},va,{signal:o.signal}),this.onlistresourcetemplates=async(s,o)=>this._client.request({method:"resources/templates/list",params:s},$a,{signal:o.signal}),this.onreadresource=async(s,o)=>this._client.request({method:"resources/read",params:s},ba,{signal:o.signal}),n.resources.listChanged&&this._client.setNotificationHandler(Sa,s=>this.sendResourceListChanged(s.params))),n.prompts&&(this.onlistprompts=async(s,o)=>this._client.request({method:"prompts/list",params:s},Ea,{signal:o.signal}),n.prompts.listChanged&&this._client.setNotificationHandler(Ta,s=>this.sendPromptListChanged(s.params)))}return super.connect(r)}}function Lv(e,t){return JSON.stringify(e)===JSON.stringify(t)}const Vv={x:0,y:0,width:1024,height:768},_o=28,Hv=12,Zv=.9;function Ft(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function Kv(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return e}function Gv(e){return e.type==="text"&&typeof(e.text??e.originalText)=="string"}function cd(e){const t=String(e.text??e.originalText??""),r=Ft(e.fontSize)??20,n=t.length*r*Zv,s=Ft(e.width);return Math.max(s&&s>0?s:0,n)}function Wv(e){for(const t of e){if(t.type!=="cameraUpdate")continue;const r=Ft(t.width),n=Ft(t.height);if(!(!r||r<=0||!n||n<=0))return{x:Ft(t.x)??0,y:Ft(t.y)??0,width:r,height:n}}return Vv}function Bv(e,t){const r=Ft(e.x);if(r===void 0)return!1;const n=cd(e),s=t.x+_o,o=t.x+t.width-_o;return ro+1}function Jv(e,t){const r={...e},n=Ft(r.fontSize)??20;let s=cd(r);const o=Math.max(1,t.width-_o*2);if(s>o){const a=o/s;r.fontSize=Math.max(Hv,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 Qv(e){const t=e.map(Kv);if(t.some(s=>s===void 0))return e;const r=t,n=Wv(r);return r.map(s=>!Gv(s)||!Bv(s,n)?s:Jv(s,n))}var yo={exports:{}},ld={},Nt={},Yt={},Rn={},ge={},mn={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class t{}e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends t{constructor($){if(super(),!e.IDENTIFIER.test($))throw new Error("CodeGen: name must be a valid identifier");this.str=$}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=r;class n extends t{constructor($){super(),this._items=typeof $=="string"?[$]:$}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const $=this._items[0];return $===""||$==='""'}get str(){var $;return($=this._str)!==null&&$!==void 0?$:this._str=this._items.reduce((k,T)=>`${k}${T}`,"")}get names(){var $;return($=this._names)!==null&&$!==void 0?$:this._names=this._items.reduce((k,T)=>(T instanceof r&&(k[T.str]=(k[T.str]||0)+1),k),{})}}e._Code=n,e.nil=new n("");function s(h,...$){const k=[h[0]];let T=0;for(;T<$.length;)i(k,$[T]),k.push(h[++T]);return new n(k)}e._=s;const o=new n("+");function a(h,...$){const k=[_(h[0])];let T=0;for(;T<$.length;)k.push(o),i(k,$[T]),k.push(o,_(h[++T]));return c(k),new n(k)}e.str=a;function i(h,$){$ instanceof n?h.push(...$._items):$ instanceof r?h.push($):h.push(f($))}e.addCodeArg=i;function c(h){let $=1;for(;${if(f.scopePath===void 0)throw new Error(`CodeGen: name "${f}" has no value`);return(0,t._)`${l}${f.scopePath}`})}scopeCode(l=this._values,d,f){return this._reduceValues(l,y=>{if(y.value===void 0)throw new Error(`CodeGen: name "${y}" has no value`);return y.value.code},d,f)}_reduceValues(l,d,f={},y){let _=t.nil;for(const g in l){const v=l[g];if(!v)continue;const m=f[g]=f[g]||new Map;v.forEach(h=>{if(m.has(h))return;m.set(h,n.Started);let $=d(h);if($){const k=this.opts.es5?e.varKinds.var:e.varKinds.const;_=(0,t._)`${_}${k} ${h} = ${$};${this.opts._n}`}else if($=y==null?void 0:y(h))_=(0,t._)`${_}${$}${this.opts._n}`;else throw new r(h);m.set(h,n.Completed)})}return _}}e.ValueScope=i})(vo);(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=mn,r=vo;var n=mn;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=vo;Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class o{optimizeNodes(){return this}optimizeNames(u,p){return this}}class a extends o{constructor(u,p,P){super(),this.varKind=u,this.name=p,this.rhs=P}render({es5:u,_n:p}){const P=u?r.varKinds.var:this.varKind,q=this.rhs===void 0?"":` = ${this.rhs}`;return`${P} ${this.name}${q};`+p}optimizeNames(u,p){if(u[this.name.str])return this.rhs&&(this.rhs=F(this.rhs,u,p)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class i extends o{constructor(u,p,P){super(),this.lhs=u,this.rhs=p,this.sideEffects=P}render({_n:u}){return`${this.lhs} = ${this.rhs};`+u}optimizeNames(u,p){if(!(this.lhs instanceof t.Name&&!u[this.lhs.str]&&!this.sideEffects))return this.rhs=F(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,P,q){super(u,P,q),this.op=p}render({_n:u}){return`${this.lhs} ${this.op}= ${this.rhs};`+u}}class l extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`${this.label}:`+u}}class d extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`break${this.label?` ${this.label}`:""};`+u}}class f extends o{constructor(u){super(),this.error=u}render({_n:u}){return`throw ${this.error};`+u}get names(){return this.error.names}}class y 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=F(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,P)=>p+P.render(u),"")}optimizeNodes(){const{nodes:u}=this;let p=u.length;for(;p--;){const P=u[p].optimizeNodes();Array.isArray(P)?u.splice(p,1,...P):P?u[p]=P:u.splice(p,1)}return u.length>0?this:void 0}optimizeNames(u,p){const{nodes:P}=this;let q=P.length;for(;q--;){const D=P[q];D.optimizeNames(u,p)||(ie(u,D.names),P.splice(q,1))}return P.length>0?this:void 0}get names(){return this.nodes.reduce((u,p)=>Y(u,p.names),{})}}class g extends _{render(u){return"{"+u._n+super.render(u)+"}"+u._n}}class v extends _{}class m extends g{}m.kind="else";class h extends g{constructor(u,p){super(p),this.condition=u}render(u){let p=`if(${this.condition})`+super.render(u);return this.else&&(p+="else "+this.else.render(u)),p}optimizeNodes(){super.optimizeNodes();const u=this.condition;if(u===!0)return this.nodes;let p=this.else;if(p){const P=p.optimizeNodes();p=this.else=Array.isArray(P)?new m(P):P}if(p)return u===!1?p instanceof h?p:p.nodes:this.nodes.length?this:new h(ke(u),p instanceof h?[p]:p.nodes);if(!(u===!1||!this.nodes.length))return this}optimizeNames(u,p){var P;if(this.else=(P=this.else)===null||P===void 0?void 0:P.optimizeNames(u,p),!!(super.optimizeNames(u,p)||this.else))return this.condition=F(this.condition,u,p),this}get names(){const u=super.names;return ne(u,this.condition),this.else&&Y(u,this.else.names),u}}h.kind="if";class $ extends g{}$.kind="for";class k extends ${constructor(u){super(),this.iteration=u}render(u){return`for(${this.iteration})`+super.render(u)}optimizeNames(u,p){if(super.optimizeNames(u,p))return this.iteration=F(this.iteration,u,p),this}get names(){return Y(super.names,this.iteration.names)}}class T extends ${constructor(u,p,P,q){super(),this.varKind=u,this.name=p,this.from=P,this.to=q}render(u){const p=u.es5?r.varKinds.var:this.varKind,{name:P,from:q,to:D}=this;return`for(${p} ${P}=${q}; ${P}<${D}; ${P}++)`+super.render(u)}get names(){const u=ne(super.names,this.from);return ne(u,this.to)}}class E extends ${constructor(u,p,P,q){super(),this.loop=u,this.varKind=p,this.name=P,this.iterable=q}render(u){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(u)}optimizeNames(u,p){if(super.optimizeNames(u,p))return this.iterable=F(this.iterable,u,p),this}get names(){return Y(super.names,this.iterable.names)}}class x extends g{constructor(u,p,P){super(),this.name=u,this.args=p,this.async=P}render(u){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(u)}}x.kind="func";class M extends _{render(u){return"return "+super.render(u)}}M.kind="return";class L extends g{render(u){let p="try"+super.render(u);return this.catch&&(p+=this.catch.render(u)),this.finally&&(p+=this.finally.render(u)),p}optimizeNodes(){var u,p;return super.optimizeNodes(),(u=this.catch)===null||u===void 0||u.optimizeNodes(),(p=this.finally)===null||p===void 0||p.optimizeNodes(),this}optimizeNames(u,p){var P,q;return super.optimizeNames(u,p),(P=this.catch)===null||P===void 0||P.optimizeNames(u,p),(q=this.finally)===null||q===void 0||q.optimizeNames(u,p),this}get names(){const u=super.names;return this.catch&&Y(u,this.catch.names),this.finally&&Y(u,this.finally.names),u}}class G extends g{constructor(u){super(),this.error=u}render(u){return`catch(${this.error})`+super.render(u)}}G.kind="catch";class V extends g{render(u){return"finally"+super.render(u)}}V.kind="finally";class K{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 v]}toString(){return this._root.render(this.opts)}name(u){return this._scope.name(u)}scopeName(u){return this._extScope.name(u)}scopeValue(u,p){const P=this._extScope.value(u,p);return(this._values[P.prefix]||(this._values[P.prefix]=new Set)).add(P),P}getScopeValue(u,p){return this._extScope.getValue(u,p)}scopeRefs(u){return this._extScope.scopeRefs(u,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(u,p,P,q){const D=this._scope.toName(p);return P!==void 0&&q&&(this._constants[D.str]=P),this._leafNode(new a(u,D,P)),D}const(u,p,P){return this._def(r.varKinds.const,u,p,P)}let(u,p,P){return this._def(r.varKinds.let,u,p,P)}var(u,p,P){return this._def(r.varKinds.var,u,p,P)}assign(u,p,P){return this._leafNode(new i(u,p,P))}add(u,p){return this._leafNode(new c(u,e.operators.ADD,p))}code(u){return typeof u=="function"?u():u!==t.nil&&this._leafNode(new y(u)),this}object(...u){const p=["{"];for(const[P,q]of u)p.length>1&&p.push(","),p.push(P),(P!==q||this.opts.es5)&&(p.push(":"),(0,t.addCodeArg)(p,q));return p.push("}"),new t._Code(p)}if(u,p,P){if(this._blockNode(new h(u)),p&&P)this.code(p).else().code(P).endIf();else if(p)this.code(p).endIf();else if(P)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(u){return this._elseNode(new h(u))}else(){return this._elseNode(new m)}endIf(){return this._endBlockNode(h,m)}_for(u,p){return this._blockNode(u),p&&this.code(p).endFor(),this}for(u,p){return this._for(new k(u),p)}forRange(u,p,P,q,D=this.opts.es5?r.varKinds.var:r.varKinds.let){const X=this._scope.toName(u);return this._for(new T(D,X,p,P),()=>q(X))}forOf(u,p,P,q=r.varKinds.const){const D=this._scope.toName(u);if(this.opts.es5){const X=p instanceof t.Name?p:this.var("_arr",p);return this.forRange("_i",0,(0,t._)`${X}.length`,J=>{this.var(D,(0,t._)`${X}[${J}]`),P(D)})}return this._for(new E("of",q,D,p),()=>P(D))}forIn(u,p,P,q=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(u,(0,t._)`Object.keys(${p})`,P);const D=this._scope.toName(u);return this._for(new E("in",q,D,p),()=>P(D))}endFor(){return this._endBlockNode($)}label(u){return this._leafNode(new l(u))}break(u){return this._leafNode(new d(u))}return(u){const p=new M;if(this._blockNode(p),this.code(u),p.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(M)}try(u,p,P){if(!p&&!P)throw new Error('CodeGen: "try" without "catch" and "finally"');const q=new L;if(this._blockNode(q),this.code(u),p){const D=this.name("e");this._currNode=q.catch=new G(D),p(D)}return P&&(this._currNode=q.finally=new V,this.code(P)),this._endBlockNode(G,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 P=this._nodes.length-p;if(P<0||u!==void 0&&P!==u)throw new Error(`CodeGen: wrong number of nodes: ${P} vs ${u} expected`);return this._nodes.length=p,this}func(u,p=t.nil,P,q){return this._blockNode(new x(u,p,P)),q&&this.code(q).endFunc(),this}endFunc(){return this._endBlockNode(x)}optimize(u=1){for(;u-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(u){return this._currNode.nodes.push(u),this}_blockNode(u){this._currNode.nodes.push(u),this._nodes.push(u)}_endBlockNode(u,p){const P=this._currNode;if(P instanceof u||p&&P instanceof p)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${p?`${u.kind}/${p.kind}`:u.kind}"`)}_elseNode(u){const p=this._currNode;if(!(p instanceof 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=K;function Y(b,u){for(const p in u)b[p]=(b[p]||0)+(u[p]||0);return b}function ne(b,u){return u instanceof t._CodeOrName?Y(b,u.names):b}function F(b,u,p){if(b instanceof t.Name)return P(b);if(!q(b))return b;return new t._Code(b._items.reduce((D,X)=>(X instanceof t.Name&&(X=P(X)),X instanceof t._Code?D.push(...X._items):D.push(X),D),[]));function P(D){const X=p[D.str];return X===void 0||u[D.str]!==1?D:(delete u[D.str],X)}function q(D){return D instanceof t._Code&&D._items.some(X=>X instanceof t.Name&&u[X.str]===1&&p[X.str]!==void 0)}}function ie(b,u){for(const p in u)b[p]=(b[p]||0)-(u[p]||0)}function ke(b){return typeof b=="boolean"||typeof b=="number"||b===null?!b:(0,t._)`!${C(b)}`}e.not=ke;const $e=w(e.operators.AND);function ct(...b){return b.reduce($e)}e.and=ct;const Oe=w(e.operators.OR);function O(...b){return b.reduce(Oe)}e.or=O;function w(b){return(u,p)=>u===t.nil?p:p===t.nil?u:(0,t._)`${C(u)} ${b} ${C(p)}`}function C(b){return b instanceof t.Name?b:(0,t._)`(${b})`}})(ge);var W={};Object.defineProperty(W,"__esModule",{value:!0});W.checkStrictMode=W.getErrorPath=W.Type=W.useFunc=W.setEvaluated=W.evaluatedPropsToName=W.mergeEvaluated=W.eachItem=W.unescapeJsonPointer=W.escapeJsonPointer=W.escapeFragment=W.unescapeFragment=W.schemaRefOrVal=W.schemaHasRulesButRef=W.schemaHasRules=W.checkUnknownRules=W.alwaysValidSchema=W.toHash=void 0;const we=ge,Yv=mn;function Xv(e){const t={};for(const r of e)t[r]=!0;return t}W.toHash=Xv;function e$(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(ud(e,t),!dd(t,e.self.RULES.all))}W.alwaysValidSchema=e$;function ud(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]||pd(e,`unknown keyword: "${o}"`)}W.checkUnknownRules=ud;function dd(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(t[r])return!0;return!1}W.schemaHasRules=dd;function t$(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}W.schemaHasRulesButRef=t$;function r$({topSchemaRef:e,schemaPath:t},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,we._)`${r}`}return(0,we._)`${e}${t}${(0,we.getProperty)(n)}`}W.schemaRefOrVal=r$;function n$(e){return fd(decodeURIComponent(e))}W.unescapeFragment=n$;function s$(e){return encodeURIComponent(Ma(e))}W.escapeFragment=s$;function Ma(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}W.escapeJsonPointer=Ma;function fd(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}W.unescapeJsonPointer=fd;function o$(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)}W.eachItem=o$;function Zc({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(s,o,a,i)=>{const c=a===void 0?o:a instanceof we.Name?(o instanceof we.Name?e(s,o,a):t(s,o,a),a):o instanceof we.Name?(t(s,a,o),o):r(o,a);return i===we.Name&&!(c instanceof we.Name)?n(s,c):c}}W.mergeEvaluated={props:Zc({mergeNames:(e,t,r)=>e.if((0,we._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,we._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,we._)`${r} || {}`).code((0,we._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,we._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,we._)`${r} || {}`),za(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:hd}),items:Zc({mergeNames:(e,t,r)=>e.if((0,we._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,we._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,we._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,we._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function hd(e,t){if(t===!0)return e.var("props",!0);const r=e.var("props",(0,we._)`{}`);return t!==void 0&&za(e,r,t),r}W.evaluatedPropsToName=hd;function za(e,t,r){Object.keys(r).forEach(n=>e.assign((0,we._)`${t}${(0,we.getProperty)(n)}`,!0))}W.setEvaluated=za;const Kc={};function a$(e,t){return e.scopeValue("func",{ref:t,code:Kc[t.code]||(Kc[t.code]=new Yv._Code(t.code))})}W.useFunc=a$;var $o;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})($o||(W.Type=$o={}));function i$(e,t,r){if(e instanceof we.Name){const n=t===$o.Num;return r?n?(0,we._)`"[" + ${e} + "]"`:(0,we._)`"['" + ${e} + "']"`:n?(0,we._)`"/" + ${e}`:(0,we._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,we.getProperty)(e).toString():"/"+Ma(e)}W.getErrorPath=i$;function pd(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}W.checkStrictMode=pd;var Ct={};Object.defineProperty(Ct,"__esModule",{value:!0});const Xe=ge,c$={data:new Xe.Name("data"),valCxt:new Xe.Name("valCxt"),instancePath:new Xe.Name("instancePath"),parentData:new Xe.Name("parentData"),parentDataProperty:new Xe.Name("parentDataProperty"),rootData:new Xe.Name("rootData"),dynamicAnchors:new Xe.Name("dynamicAnchors"),vErrors:new Xe.Name("vErrors"),errors:new Xe.Name("errors"),this:new Xe.Name("this"),self:new Xe.Name("self"),scope:new Xe.Name("scope"),json:new Xe.Name("json"),jsonPos:new Xe.Name("jsonPos"),jsonLen:new Xe.Name("jsonLen"),jsonPart:new Xe.Name("jsonPart")};Ct.default=c$;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;const t=ge,r=W,n=Ct;e.keywordError={message:({keyword:m})=>(0,t.str)`must pass "${m}" keyword validation`},e.keyword$DataError={message:({keyword:m,schemaType:h})=>h?(0,t.str)`"${m}" keyword must be ${h} ($data)`:(0,t.str)`"${m}" keyword is invalid ($data)`};function s(m,h=e.keywordError,$,k){const{it:T}=m,{gen:E,compositeRule:x,allErrors:M}=T,L=f(m,h,$);k??(x||M)?c(E,L):l(T,(0,t._)`[${L}]`)}e.reportError=s;function o(m,h=e.keywordError,$){const{it:k}=m,{gen:T,compositeRule:E,allErrors:x}=k,M=f(m,h,$);c(T,M),E||x||l(k,n.default.vErrors)}e.reportExtraError=o;function a(m,h){m.assign(n.default.errors,h),m.if((0,t._)`${n.default.vErrors} !== null`,()=>m.if(h,()=>m.assign((0,t._)`${n.default.vErrors}.length`,h),()=>m.assign(n.default.vErrors,null)))}e.resetErrorsCount=a;function i({gen:m,keyword:h,schemaValue:$,data:k,errsCount:T,it:E}){if(T===void 0)throw new Error("ajv implementation error");const x=m.name("err");m.forRange("i",T,n.default.errors,M=>{m.const(x,(0,t._)`${n.default.vErrors}[${M}]`),m.if((0,t._)`${x}.instancePath === undefined`,()=>m.assign((0,t._)`${x}.instancePath`,(0,t.strConcat)(n.default.instancePath,E.errorPath))),m.assign((0,t._)`${x}.schemaPath`,(0,t.str)`${E.errSchemaPath}/${h}`),E.opts.verbose&&(m.assign((0,t._)`${x}.schema`,$),m.assign((0,t._)`${x}.data`,k))})}e.extendErrors=i;function c(m,h){const $=m.const("err",h);m.if((0,t._)`${n.default.vErrors} === null`,()=>m.assign(n.default.vErrors,(0,t._)`[${$}]`),(0,t._)`${n.default.vErrors}.push(${$})`),m.code((0,t._)`${n.default.errors}++`)}function l(m,h){const{gen:$,validateName:k,schemaEnv:T}=m;T.$async?$.throw((0,t._)`new ${m.ValidationError}(${h})`):($.assign((0,t._)`${k}.errors`,h),$.return(!1))}const d={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function f(m,h,$){const{createErrors:k}=m.it;return k===!1?(0,t._)`{}`:y(m,h,$)}function y(m,h,$={}){const{gen:k,it:T}=m,E=[_(T,$),g(m,$)];return v(m,h,E),k.object(...E)}function _({errorPath:m},{instancePath:h}){const $=h?(0,t.str)`${m}${(0,r.getErrorPath)(h,r.Type.Str)}`:m;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,$)]}function g({keyword:m,it:{errSchemaPath:h}},{schemaPath:$,parentSchema:k}){let T=k?h:(0,t.str)`${h}/${m}`;return $&&(T=(0,t.str)`${T}${(0,r.getErrorPath)($,r.Type.Str)}`),[d.schemaPath,T]}function v(m,{params:h,message:$},k){const{keyword:T,data:E,schemaValue:x,it:M}=m,{opts:L,propertyName:G,topSchemaRef:V,schemaPath:K}=M;k.push([d.keyword,T],[d.params,typeof h=="function"?h(m):h||(0,t._)`{}`]),L.messages&&k.push([d.message,typeof $=="function"?$(m):$]),L.verbose&&k.push([d.schema,x],[d.parentSchema,(0,t._)`${V}${K}`],[n.default.data,E]),G&&k.push([d.propertyName,G])}})(Rn);var Gc;function l$(){if(Gc)return Yt;Gc=1,Object.defineProperty(Yt,"__esModule",{value:!0}),Yt.boolOrEmptySchema=Yt.topBoolOrEmptySchema=void 0;const e=Rn,t=ge,r=Ct,n={message:"boolean schema is false"};function s(i){const{gen:c,schema:l,validateName:d}=i;l===!1?a(i,!1):typeof l=="object"&&l.$async===!0?c.return(r.default.data):(c.assign((0,t._)`${d}.errors`,null),c.return(!0))}Yt.topBoolOrEmptySchema=s;function o(i,c){const{gen:l,schema:d}=i;d===!1?(l.var(c,!1),a(i)):l.var(c,!0)}Yt.boolOrEmptySchema=o;function a(i,c){const{gen:l,data:d}=i,f={gen:l,keyword:"false schema",data:d,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:i};(0,e.reportError)(f,n,void 0,c)}return Yt}var qe={},ur={};Object.defineProperty(ur,"__esModule",{value:!0});ur.getRules=ur.isJSONType=void 0;const u$=["string","number","integer","boolean","null","object","array"],d$=new Set(u$);function f$(e){return typeof e=="string"&&d$.has(e)}ur.isJSONType=f$;function h$(){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:{}}}ur.getRules=h$;var It={},Wc;function md(){if(Wc)return It;Wc=1,Object.defineProperty(It,"__esModule",{value:!0}),It.shouldUseRule=It.shouldUseGroup=It.schemaHasRulesForType=void 0;function e({schema:n,self:s},o){const a=s.RULES.types[o];return a&&a!==!0&&t(n,a)}It.schemaHasRulesForType=e;function t(n,s){return s.rules.some(o=>r(n,o))}It.shouldUseGroup=t;function r(n,s){var o;return n[s.keyword]!==void 0||((o=s.definition.implements)===null||o===void 0?void 0:o.some(a=>n[a]!==void 0))}return It.shouldUseRule=r,It}Object.defineProperty(qe,"__esModule",{value:!0});qe.reportTypeError=qe.checkDataTypes=qe.checkDataType=qe.coerceAndCheckDataType=qe.getJSONTypes=qe.getSchemaTypes=qe.DataType=void 0;const p$=ur,m$=md(),g$=Rn,ue=ge,gd=W;var Rr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Rr||(qe.DataType=Rr={}));function _$(e){const t=_d(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}qe.getSchemaTypes=_$;function _d(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(p$.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}qe.getJSONTypes=_d;function y$(e,t){const{gen:r,data:n,opts:s}=e,o=v$(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0,m$.schemaHasRulesForType)(e,t[0]));if(a){const i=qa(t,n,s.strictNumbers,Rr.Wrong);r.if(i,()=>{o.length?$$(e,t,o):Da(e)})}return a}qe.coerceAndCheckDataType=y$;const yd=new Set(["string","number","integer","boolean","null"]);function v$(e,t){return t?e.filter(r=>yd.has(r)||t==="array"&&r==="array"):[]}function $$(e,t,r){const{gen:n,data:s,opts:o}=e,a=n.let("dataType",(0,ue._)`typeof ${s}`),i=n.let("coerced",(0,ue._)`undefined`);o.coerceTypes==="array"&&n.if((0,ue._)`${a} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,ue._)`${s}[0]`).assign(a,(0,ue._)`typeof ${s}`).if(qa(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0,ue._)`${i} !== undefined`);for(const l of r)(yd.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),Da(e),n.endIf(),n.if((0,ue._)`${i} !== undefined`,()=>{n.assign(s,i),w$(e,i)});function c(l){switch(l){case"string":n.elseIf((0,ue._)`${a} == "number" || ${a} == "boolean"`).assign(i,(0,ue._)`"" + ${s}`).elseIf((0,ue._)`${s} === null`).assign(i,(0,ue._)`""`);return;case"number":n.elseIf((0,ue._)`${a} == "boolean" || ${s} === null - || (${a} == "string" && ${s} && ${s} == +${s})`).assign(i,(0,ue._)`+${s}`);return;case"integer":n.elseIf((0,ue._)`${a} === "boolean" || ${s} === null - || (${a} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(i,(0,ue._)`+${s}`);return;case"boolean":n.elseIf((0,ue._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(i,!1).elseIf((0,ue._)`${s} === "true" || ${s} === 1`).assign(i,!0);return;case"null":n.elseIf((0,ue._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(i,null);return;case"array":n.elseIf((0,ue._)`${a} === "string" || ${a} === "number" - || ${a} === "boolean" || ${s} === null`).assign(i,(0,ue._)`[${s}]`)}}}function w$({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,ue._)`${t} !== undefined`,()=>e.assign((0,ue._)`${t}[${r}]`,n))}function wo(e,t,r,n=Rr.Correct){const s=n===Rr.Correct?ue.operators.EQ:ue.operators.NEQ;let o;switch(e){case"null":return(0,ue._)`${t} ${s} null`;case"array":o=(0,ue._)`Array.isArray(${t})`;break;case"object":o=(0,ue._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=a((0,ue._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=a();break;default:return(0,ue._)`typeof ${t} ${s} ${e}`}return n===Rr.Correct?o:(0,ue.not)(o);function a(i=ue.nil){return(0,ue.and)((0,ue._)`typeof ${t} == "number"`,i,r?(0,ue._)`isFinite(${t})`:ue.nil)}}qe.checkDataType=wo;function qa(e,t,r,n){if(e.length===1)return wo(e[0],t,r,n);let s;const o=(0,gd.toHash)(e);if(o.array&&o.object){const a=(0,ue._)`typeof ${t} != "object"`;s=o.null?a:(0,ue._)`!${t} || ${a}`,delete o.null,delete o.array,delete o.object}else s=ue.nil;o.number&&delete o.integer;for(const a in o)s=(0,ue.and)(s,wo(a,t,r,n));return s}qe.checkDataTypes=qa;const b$={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,ue._)`{type: ${e}}`:(0,ue._)`{type: ${t}}`};function Da(e){const t=S$(e);(0,g$.reportError)(t,b$)}qe.reportTypeError=Da;function S$(e){const{gen:t,data:r,schema:n}=e,s=(0,gd.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}var Kr={},Bc;function E$(){if(Bc)return Kr;Bc=1,Object.defineProperty(Kr,"__esModule",{value:!0}),Kr.assignDefaults=void 0;const e=ge,t=W;function r(s,o){const{properties:a,items:i}=s.schema;if(o==="object"&&a)for(const c in a)n(s,c,a[c].default);else o==="array"&&Array.isArray(i)&&i.forEach((c,l)=>n(s,l,c.default))}Kr.assignDefaults=r;function n(s,o,a){const{gen:i,compositeRule:c,data:l,opts:d}=s;if(a===void 0)return;const f=(0,e._)`${l}${(0,e.getProperty)(o)}`;if(c){(0,t.checkStrictMode)(s,`default is ignored for: ${f}`);return}let y=(0,e._)`${f} === undefined`;d.useDefaults==="empty"&&(y=(0,e._)`${y} || ${f} === null || ${f} === ""`),i.if(y,(0,e._)`${f} = ${(0,e.stringify)(a)}`)}return Kr}var gt={},pe={};Object.defineProperty(pe,"__esModule",{value:!0});pe.validateUnion=pe.validateArray=pe.usePattern=pe.callValidateCode=pe.schemaProperties=pe.allSchemaProperties=pe.noPropertyInData=pe.propertyInData=pe.isOwnProperty=pe.hasPropFunc=pe.reportMissingProp=pe.checkMissingProp=pe.checkReportMissingProp=void 0;const Pe=ge,Ua=W,Mt=Ct,k$=W;function P$(e,t){const{gen:r,data:n,it:s}=e;r.if(La(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Pe._)`${t}`},!0),e.error()})}pe.checkReportMissingProp=P$;function R$({gen:e,data:t,it:{opts:r}},n,s){return(0,Pe.or)(...n.map(o=>(0,Pe.and)(La(e,t,o,r.ownProperties),(0,Pe._)`${s} = ${o}`)))}pe.checkMissingProp=R$;function T$(e,t){e.setParams({missingProperty:t},!0),e.error()}pe.reportMissingProp=T$;function vd(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Pe._)`Object.prototype.hasOwnProperty`})}pe.hasPropFunc=vd;function Fa(e,t,r){return(0,Pe._)`${vd(e)}.call(${t}, ${r})`}pe.isOwnProperty=Fa;function C$(e,t,r,n){const s=(0,Pe._)`${t}${(0,Pe.getProperty)(r)} !== undefined`;return n?(0,Pe._)`${s} && ${Fa(e,t,r)}`:s}pe.propertyInData=C$;function La(e,t,r,n){const s=(0,Pe._)`${t}${(0,Pe.getProperty)(r)} === undefined`;return n?(0,Pe.or)(s,(0,Pe.not)(Fa(e,t,r))):s}pe.noPropertyInData=La;function $d(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}pe.allSchemaProperties=$d;function j$(e,t){return $d(t).filter(r=>!(0,Ua.alwaysValidSchema)(e,t[r]))}pe.schemaProperties=j$;function N$({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:a},i,c,l){const d=l?(0,Pe._)`${e}, ${t}, ${n}${s}`:t,f=[[Mt.default.instancePath,(0,Pe.strConcat)(Mt.default.instancePath,o)],[Mt.default.parentData,a.parentData],[Mt.default.parentDataProperty,a.parentDataProperty],[Mt.default.rootData,Mt.default.rootData]];a.opts.dynamicRef&&f.push([Mt.default.dynamicAnchors,Mt.default.dynamicAnchors]);const y=(0,Pe._)`${d}, ${r.object(...f)}`;return c!==Pe.nil?(0,Pe._)`${i}.call(${c}, ${y})`:(0,Pe._)`${i}(${y})`}pe.callValidateCode=N$;const I$=(0,Pe._)`new RegExp`;function O$({gen:e,it:{opts:t}},r){const n=t.unicodeRegExp?"u":"",{regExp:s}=t.code,o=s(r,n);return e.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,Pe._)`${s.code==="new RegExp"?I$:(0,k$.useFunc)(e,s)}(${r}, ${n})`})}pe.usePattern=O$;function x$(e){const{gen:t,data:r,keyword:n,it:s}=e,o=t.name("valid");if(s.allErrors){const i=t.let("valid",!0);return a(()=>t.assign(i,!1)),i}return t.var(o,!0),a(()=>t.break()),o;function a(i){const c=t.const("len",(0,Pe._)`${r}.length`);t.forRange("i",0,c,l=>{e.subschema({keyword:n,dataProp:l,dataPropType:Ua.Type.Num},o),t.if((0,Pe.not)(o),i)})}}pe.validateArray=x$;function A$(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,Ua.alwaysValidSchema)(s,c))&&!s.opts.unevaluated)return;const a=t.let("valid",!1),i=t.name("_valid");t.block(()=>r.forEach((c,l)=>{const d=e.subschema({keyword:n,schemaProp:l,compositeRule:!0},i);t.assign(a,(0,Pe._)`${a} || ${i}`),e.mergeValidEvaluated(d,i)||t.if((0,Pe.not)(a))})),e.result(a,()=>e.reset(),()=>e.error(!0))}pe.validateUnion=A$;var Jc;function M$(){if(Jc)return gt;Jc=1,Object.defineProperty(gt,"__esModule",{value:!0}),gt.validateKeywordUsage=gt.validSchemaType=gt.funcKeywordCode=gt.macroKeywordCode=void 0;const e=ge,t=Ct,r=pe,n=Rn;function s(y,_){const{gen:g,keyword:v,schema:m,parentSchema:h,it:$}=y,k=_.macro.call($.self,m,h,$),T=l(g,v,k);$.opts.validateSchema!==!1&&$.self.validateSchema(k,!0);const E=g.name("valid");y.subschema({schema:k,schemaPath:e.nil,errSchemaPath:`${$.errSchemaPath}/${v}`,topSchemaRef:T,compositeRule:!0},E),y.pass(E,()=>y.error(!0))}gt.macroKeywordCode=s;function o(y,_){var g;const{gen:v,keyword:m,schema:h,parentSchema:$,$data:k,it:T}=y;c(T,_);const E=!k&&_.compile?_.compile.call(T.self,h,$,T):_.validate,x=l(v,m,E),M=v.let("valid");y.block$data(M,L),y.ok((g=_.valid)!==null&&g!==void 0?g:M);function L(){if(_.errors===!1)K(),_.modifying&&a(y),Y(()=>y.error());else{const ne=_.async?G():V();_.modifying&&a(y),Y(()=>i(y,ne))}}function G(){const ne=v.let("ruleErrs",null);return v.try(()=>K((0,e._)`await `),F=>v.assign(M,!1).if((0,e._)`${F} instanceof ${T.ValidationError}`,()=>v.assign(ne,(0,e._)`${F}.errors`),()=>v.throw(F))),ne}function V(){const ne=(0,e._)`${x}.errors`;return v.assign(ne,null),K(e.nil),ne}function K(ne=_.async?(0,e._)`await `:e.nil){const F=T.opts.passContext?t.default.this:t.default.self,ie=!("compile"in _&&!k||_.schema===!1);v.assign(M,(0,e._)`${ne}${(0,r.callValidateCode)(y,x,F,ie)}`,_.modifying)}function Y(ne){var F;v.if((0,e.not)((F=_.valid)!==null&&F!==void 0?F:M),ne)}}gt.funcKeywordCode=o;function a(y){const{gen:_,data:g,it:v}=y;_.if(v.parentData,()=>_.assign(g,(0,e._)`${v.parentData}[${v.parentDataProperty}]`))}function i(y,_){const{gen:g}=y;g.if((0,e._)`Array.isArray(${_})`,()=>{g.assign(t.default.vErrors,(0,e._)`${t.default.vErrors} === null ? ${_} : ${t.default.vErrors}.concat(${_})`).assign(t.default.errors,(0,e._)`${t.default.vErrors}.length`),(0,n.extendErrors)(y)},()=>y.error())}function c({schemaEnv:y},_){if(_.async&&!y.$async)throw new Error("async keyword in sync schema")}function l(y,_,g){if(g===void 0)throw new Error(`keyword "${_}" failed to compile`);return y.scopeValue("keyword",typeof g=="function"?{ref:g}:{ref:g,code:(0,e.stringify)(g)})}function d(y,_,g=!1){return!_.length||_.some(v=>v==="array"?Array.isArray(y):v==="object"?y&&typeof y=="object"&&!Array.isArray(y):typeof y==v||g&&typeof y>"u")}gt.validSchemaType=d;function f({schema:y,opts:_,self:g,errSchemaPath:v},m,h){if(Array.isArray(m.keyword)?!m.keyword.includes(h):m.keyword!==h)throw new Error("ajv implementation error");const $=m.dependencies;if($!=null&&$.some(k=>!Object.prototype.hasOwnProperty.call(y,k)))throw new Error(`parent schema must have dependencies of ${h}: ${$.join(",")}`);if(m.validateSchema&&!m.validateSchema(y[h])){const T=`keyword "${h}" value is invalid at path "${v}": `+g.errorsText(m.validateSchema.errors);if(_.validateSchema==="log")g.logger.error(T);else throw new Error(T)}}return gt.validateKeywordUsage=f,gt}var Ot={},Qc;function z$(){if(Qc)return Ot;Qc=1,Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.extendSubschemaMode=Ot.extendSubschemaData=Ot.getSubschema=void 0;const e=ge,t=W;function r(o,{keyword:a,schemaProp:i,schema:c,schemaPath:l,errSchemaPath:d,topSchemaRef:f}){if(a!==void 0&&c!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(a!==void 0){const y=o.schema[a];return i===void 0?{schema:y,schemaPath:(0,e._)`${o.schemaPath}${(0,e.getProperty)(a)}`,errSchemaPath:`${o.errSchemaPath}/${a}`}:{schema:y[i],schemaPath:(0,e._)`${o.schemaPath}${(0,e.getProperty)(a)}${(0,e.getProperty)(i)}`,errSchemaPath:`${o.errSchemaPath}/${a}/${(0,t.escapeFragment)(i)}`}}if(c!==void 0){if(l===void 0||d===void 0||f===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:c,schemaPath:l,topSchemaRef:f,errSchemaPath:d}}throw new Error('either "keyword" or "schema" must be passed')}Ot.getSubschema=r;function n(o,a,{dataProp:i,dataPropType:c,data:l,dataTypes:d,propertyName:f}){if(l!==void 0&&i!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:y}=a;if(i!==void 0){const{errorPath:g,dataPathArr:v,opts:m}=a,h=y.let("data",(0,e._)`${a.data}${(0,e.getProperty)(i)}`,!0);_(h),o.errorPath=(0,e.str)`${g}${(0,t.getErrorPath)(i,c,m.jsPropertySyntax)}`,o.parentDataProperty=(0,e._)`${i}`,o.dataPathArr=[...v,o.parentDataProperty]}if(l!==void 0){const g=l instanceof e.Name?l:y.let("data",l,!0);_(g),f!==void 0&&(o.propertyName=f)}d&&(o.dataTypes=d);function _(g){o.data=g,o.dataLevel=a.dataLevel+1,o.dataTypes=[],a.definedProperties=new Set,o.parentData=a.data,o.dataNames=[...a.dataNames,g]}}Ot.extendSubschemaData=n;function s(o,{jtdDiscriminator:a,jtdMetadata:i,compositeRule:c,createErrors:l,allErrors:d}){c!==void 0&&(o.compositeRule=c),l!==void 0&&(o.createErrors=l),d!==void 0&&(o.allErrors=d),o.jtdDiscriminator=a,o.jtdMetadata=i}return Ot.extendSubschemaMode=s,Ot}var Ge={},Is=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},wd={exports:{}},Lt=wd.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(){};Bn(t,n,s,e,"",e)};Lt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Lt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Lt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Lt.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Bn(e,t,r,n,s,o,a,i,c,l){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,s,o,a,i,c,l);for(var d in n){var f=n[d];if(Array.isArray(f)){if(d in Lt.arrayKeywords)for(var y=0;yt+=bd(n)),t===1/0))return 1/0}return t}function Sd(e,t="",r){r!==!1&&(t=Tr(t));const n=e.parse(t);return Ed(e,n)}Ge.getFullPath=Sd;function Ed(e,t){return e.serialize(t).split("#")[0]+"#"}Ge._getFullPath=Ed;const K$=/#\/?$/;function Tr(e){return e?e.replace(K$,""):""}Ge.normalizeId=Tr;function G$(e,t,r){return r=Tr(r),e.resolve(t,r)}Ge.resolveUrl=G$;const W$=/^[a-z_][-a-z0-9._]*$/i;function B$(e,t){if(typeof e=="boolean")return{};const{schemaId:r,uriResolver:n}=this.opts,s=Tr(e[r]||t),o={"":s},a=Sd(n,s,!1),i={},c=new Set;return L$(e,{allKeys:!0},(f,y,_,g)=>{if(g===void 0)return;const v=a+y;let m=o[g];typeof f[r]=="string"&&(m=h.call(this,f[r])),$.call(this,f.$anchor),$.call(this,f.$dynamicAnchor),o[y]=m;function h(k){const T=this.opts.uriResolver.resolve;if(k=Tr(m?T(m,k):k),c.has(k))throw d(k);c.add(k);let E=this.refs[k];return typeof E=="string"&&(E=this.refs[E]),typeof E=="object"?l(f,E.schema,k):k!==Tr(v)&&(k[0]==="#"?(l(f,i[k],k),i[k]=f):this.refs[k]=v),k}function $(k){if(typeof k=="string"){if(!W$.test(k))throw new Error(`invalid anchor "${k}"`);h.call(this,`#${k}`)}}}),i;function l(f,y,_){if(y!==void 0&&!F$(f,y))throw d(_)}function d(f){return new Error(`reference "${f}" resolves to more than one schema`)}}Ge.getSchemaRefs=B$;var Yc;function Os(){if(Yc)return Nt;Yc=1,Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.getData=Nt.KeywordCxt=Nt.validateFunctionCode=void 0;const e=l$(),t=qe,r=md(),n=qe,s=E$(),o=M$(),a=z$(),i=ge,c=Ct,l=Ge,d=W,f=Rn;function y(j){if(E(j)&&(M(j),T(j))){m(j);return}_(j,()=>(0,e.topBoolOrEmptySchema)(j))}Nt.validateFunctionCode=y;function _({gen:j,validateName:I,schema:U,schemaEnv:Z,opts:ee},ce){ee.code.es5?j.func(I,(0,i._)`${c.default.data}, ${c.default.valCxt}`,Z.$async,()=>{j.code((0,i._)`"use strict"; ${$(U,ee)}`),v(j,ee),j.code(ce)}):j.func(I,(0,i._)`${c.default.data}, ${g(ee)}`,Z.$async,()=>j.code($(U,ee)).code(ce))}function g(j){return(0,i._)`{${c.default.instancePath}="", ${c.default.parentData}, ${c.default.parentDataProperty}, ${c.default.rootData}=${c.default.data}${j.dynamicRef?(0,i._)`, ${c.default.dynamicAnchors}={}`:i.nil}}={}`}function v(j,I){j.if(c.default.valCxt,()=>{j.var(c.default.instancePath,(0,i._)`${c.default.valCxt}.${c.default.instancePath}`),j.var(c.default.parentData,(0,i._)`${c.default.valCxt}.${c.default.parentData}`),j.var(c.default.parentDataProperty,(0,i._)`${c.default.valCxt}.${c.default.parentDataProperty}`),j.var(c.default.rootData,(0,i._)`${c.default.valCxt}.${c.default.rootData}`),I.dynamicRef&&j.var(c.default.dynamicAnchors,(0,i._)`${c.default.valCxt}.${c.default.dynamicAnchors}`)},()=>{j.var(c.default.instancePath,(0,i._)`""`),j.var(c.default.parentData,(0,i._)`undefined`),j.var(c.default.parentDataProperty,(0,i._)`undefined`),j.var(c.default.rootData,c.default.data),I.dynamicRef&&j.var(c.default.dynamicAnchors,(0,i._)`{}`)})}function m(j){const{schema:I,opts:U,gen:Z}=j;_(j,()=>{U.$comment&&I.$comment&&ne(j),V(j),Z.let(c.default.vErrors,null),Z.let(c.default.errors,0),U.unevaluated&&h(j),L(j),F(j)})}function h(j){const{gen:I,validateName:U}=j;j.evaluated=I.const("evaluated",(0,i._)`${U}.evaluated`),I.if((0,i._)`${j.evaluated}.dynamicProps`,()=>I.assign((0,i._)`${j.evaluated}.props`,(0,i._)`undefined`)),I.if((0,i._)`${j.evaluated}.dynamicItems`,()=>I.assign((0,i._)`${j.evaluated}.items`,(0,i._)`undefined`))}function $(j,I){const U=typeof j=="object"&&j[I.schemaId];return U&&(I.code.source||I.code.process)?(0,i._)`/*# sourceURL=${U} */`:i.nil}function k(j,I){if(E(j)&&(M(j),T(j))){x(j,I);return}(0,e.boolOrEmptySchema)(j,I)}function T({schema:j,self:I}){if(typeof j=="boolean")return!j;for(const U in j)if(I.RULES.all[U])return!0;return!1}function E(j){return typeof j.schema!="boolean"}function x(j,I){const{schema:U,gen:Z,opts:ee}=j;ee.$comment&&U.$comment&&ne(j),K(j),Y(j);const ce=Z.const("_errs",c.default.errors);L(j,ce),Z.var(I,(0,i._)`${ce} === ${c.default.errors}`)}function M(j){(0,d.checkUnknownRules)(j),G(j)}function L(j,I){if(j.opts.jtd)return ke(j,[],!1,I);const U=(0,t.getSchemaTypes)(j.schema),Z=(0,t.coerceAndCheckDataType)(j,U);ke(j,U,!Z,I)}function G(j){const{schema:I,errSchemaPath:U,opts:Z,self:ee}=j;I.$ref&&Z.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(I,ee.RULES)&&ee.logger.warn(`$ref: keywords ignored in schema at path "${U}"`)}function V(j){const{schema:I,opts:U}=j;I.default!==void 0&&U.useDefaults&&U.strictSchema&&(0,d.checkStrictMode)(j,"default is ignored in the schema root")}function K(j){const I=j.schema[j.opts.schemaId];I&&(j.baseId=(0,l.resolveUrl)(j.opts.uriResolver,j.baseId,I))}function Y(j){if(j.schema.$async&&!j.schemaEnv.$async)throw new Error("async schema in sync schema")}function ne({gen:j,schemaEnv:I,schema:U,errSchemaPath:Z,opts:ee}){const ce=U.$comment;if(ee.$comment===!0)j.code((0,i._)`${c.default.self}.logger.log(${ce})`);else if(typeof ee.$comment=="function"){const xe=(0,i.str)`${Z}/$comment`,tt=j.scopeValue("root",{ref:I.root});j.code((0,i._)`${c.default.self}.opts.$comment(${ce}, ${xe}, ${tt}.schema)`)}}function F(j){const{gen:I,schemaEnv:U,validateName:Z,ValidationError:ee,opts:ce}=j;U.$async?I.if((0,i._)`${c.default.errors} === 0`,()=>I.return(c.default.data),()=>I.throw((0,i._)`new ${ee}(${c.default.vErrors})`)):(I.assign((0,i._)`${Z}.errors`,c.default.vErrors),ce.unevaluated&&ie(j),I.return((0,i._)`${c.default.errors} === 0`))}function ie({gen:j,evaluated:I,props:U,items:Z}){U instanceof i.Name&&j.assign((0,i._)`${I}.props`,U),Z instanceof i.Name&&j.assign((0,i._)`${I}.items`,Z)}function ke(j,I,U,Z){const{gen:ee,schema:ce,data:xe,allErrors:tt,opts:Fe,self:Le}=j,{RULES:Ae}=Le;if(ce.$ref&&(Fe.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(ce,Ae))){ee.block(()=>q(j,"$ref",Ae.all.$ref.definition));return}Fe.jtd||ct(j,I),ee.block(()=>{for(const Ye of Ae.rules)kt(Ye);kt(Ae.post)});function kt(Ye){(0,r.shouldUseGroup)(ce,Ye)&&(Ye.type?(ee.if((0,n.checkDataType)(Ye.type,xe,Fe.strictNumbers)),$e(j,Ye),I.length===1&&I[0]===Ye.type&&U&&(ee.else(),(0,n.reportTypeError)(j)),ee.endIf()):$e(j,Ye),tt||ee.if((0,i._)`${c.default.errors} === ${Z||0}`))}}function $e(j,I){const{gen:U,schema:Z,opts:{useDefaults:ee}}=j;ee&&(0,s.assignDefaults)(j,I.type),U.block(()=>{for(const ce of I.rules)(0,r.shouldUseRule)(Z,ce)&&q(j,ce.keyword,ce.definition,I.type)})}function ct(j,I){j.schemaEnv.meta||!j.opts.strictTypes||(Oe(j,I),j.opts.allowUnionTypes||O(j,I),w(j,j.dataTypes))}function Oe(j,I){if(I.length){if(!j.dataTypes.length){j.dataTypes=I;return}I.forEach(U=>{b(j.dataTypes,U)||p(j,`type "${U}" not allowed by context "${j.dataTypes.join(",")}"`)}),u(j,I)}}function O(j,I){I.length>1&&!(I.length===2&&I.includes("null"))&&p(j,"use allowUnionTypes to allow union type keyword")}function w(j,I){const U=j.self.RULES.all;for(const Z in U){const ee=U[Z];if(typeof ee=="object"&&(0,r.shouldUseRule)(j.schema,ee)){const{type:ce}=ee.definition;ce.length&&!ce.some(xe=>C(I,xe))&&p(j,`missing type "${ce.join(",")}" for keyword "${Z}"`)}}}function C(j,I){return j.includes(I)||I==="number"&&j.includes("integer")}function b(j,I){return j.includes(I)||I==="integer"&&j.includes("number")}function u(j,I){const U=[];for(const Z of j.dataTypes)b(I,Z)?U.push(Z):I.includes("integer")&&Z==="number"&&U.push("integer");j.dataTypes=U}function p(j,I){const U=j.schemaEnv.baseId+j.errSchemaPath;I+=` at "${U}" (strictTypes)`,(0,d.checkStrictMode)(j,I,j.opts.strictTypes)}class P{constructor(I,U,Z){if((0,o.validateKeywordUsage)(I,U,Z),this.gen=I.gen,this.allErrors=I.allErrors,this.keyword=Z,this.data=I.data,this.schema=I.schema[Z],this.$data=U.$data&&I.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d.schemaRefOrVal)(I,this.schema,Z,this.$data),this.schemaType=U.schemaType,this.parentSchema=I.schema,this.params={},this.it=I,this.def=U,this.$data)this.schemaCode=I.gen.const("vSchema",J(this.$data,I));else if(this.schemaCode=this.schemaValue,!(0,o.validSchemaType)(this.schema,U.schemaType,U.allowUndefined))throw new Error(`${Z} value must be ${JSON.stringify(U.schemaType)}`);("code"in U?U.trackErrors:U.errors!==!1)&&(this.errsCount=I.gen.const("_errs",c.default.errors))}result(I,U,Z){this.failResult((0,i.not)(I),U,Z)}failResult(I,U,Z){this.gen.if(I),Z?Z():this.error(),U?(this.gen.else(),U(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(I,U){this.failResult((0,i.not)(I),void 0,U)}fail(I){if(I===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(I),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(I){if(!this.$data)return this.fail(I);const{schemaCode:U}=this;this.fail((0,i._)`${U} !== undefined && (${(0,i.or)(this.invalid$data(),I)})`)}error(I,U,Z){if(U){this.setParams(U),this._error(I,Z),this.setParams({});return}this._error(I,Z)}_error(I,U){(I?f.reportExtraError:f.reportError)(this,this.def.error,U)}$dataError(){(0,f.reportError)(this,this.def.$dataError||f.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,f.resetErrorsCount)(this.gen,this.errsCount)}ok(I){this.allErrors||this.gen.if(I)}setParams(I,U){U?Object.assign(this.params,I):this.params=I}block$data(I,U,Z=i.nil){this.gen.block(()=>{this.check$data(I,Z),U()})}check$data(I=i.nil,U=i.nil){if(!this.$data)return;const{gen:Z,schemaCode:ee,schemaType:ce,def:xe}=this;Z.if((0,i.or)((0,i._)`${ee} === undefined`,U)),I!==i.nil&&Z.assign(I,!0),(ce.length||xe.validateSchema)&&(Z.elseIf(this.invalid$data()),this.$dataError(),I!==i.nil&&Z.assign(I,!1)),Z.else()}invalid$data(){const{gen:I,schemaCode:U,schemaType:Z,def:ee,it:ce}=this;return(0,i.or)(xe(),tt());function xe(){if(Z.length){if(!(U instanceof i.Name))throw new Error("ajv implementation error");const Fe=Array.isArray(Z)?Z:[Z];return(0,i._)`${(0,n.checkDataTypes)(Fe,U,ce.opts.strictNumbers,n.DataType.Wrong)}`}return i.nil}function tt(){if(ee.validateSchema){const Fe=I.scopeValue("validate$data",{ref:ee.validateSchema});return(0,i._)`!${Fe}(${U})`}return i.nil}}subschema(I,U){const Z=(0,a.getSubschema)(this.it,I);(0,a.extendSubschemaData)(Z,this.it,I),(0,a.extendSubschemaMode)(Z,I);const ee={...this.it,...Z,items:void 0,props:void 0};return k(ee,U),ee}mergeEvaluated(I,U){const{it:Z,gen:ee}=this;Z.opts.unevaluated&&(Z.props!==!0&&I.props!==void 0&&(Z.props=d.mergeEvaluated.props(ee,I.props,Z.props,U)),Z.items!==!0&&I.items!==void 0&&(Z.items=d.mergeEvaluated.items(ee,I.items,Z.items,U)))}mergeValidEvaluated(I,U){const{it:Z,gen:ee}=this;if(Z.opts.unevaluated&&(Z.props!==!0||Z.items!==!0))return ee.if(U,()=>this.mergeEvaluated(I,i.Name)),!0}}Nt.KeywordCxt=P;function q(j,I,U,Z){const ee=new P(j,U,I);"code"in U?U.code(ee,Z):ee.$data&&U.validate?(0,o.funcKeywordCode)(ee,U):"macro"in U?(0,o.macroKeywordCode)(ee,U):(U.compile||U.validate)&&(0,o.funcKeywordCode)(ee,U)}const D=/^\/(?:[^~]|~0|~1)*$/,X=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function J(j,{dataLevel:I,dataNames:U,dataPathArr:Z}){let ee,ce;if(j==="")return c.default.rootData;if(j[0]==="/"){if(!D.test(j))throw new Error(`Invalid JSON-pointer: ${j}`);ee=j,ce=c.default.rootData}else{const Le=X.exec(j);if(!Le)throw new Error(`Invalid JSON-pointer: ${j}`);const Ae=+Le[1];if(ee=Le[2],ee==="#"){if(Ae>=I)throw new Error(Fe("property/index",Ae));return Z[I-Ae]}if(Ae>I)throw new Error(Fe("data",Ae));if(ce=U[I-Ae],!ee)return ce}let xe=ce;const tt=ee.split("/");for(const Le of tt)Le&&(ce=(0,i._)`${ce}${(0,i.getProperty)((0,d.unescapeJsonPointer)(Le))}`,xe=(0,i._)`${xe} && ${ce}`);return xe;function Fe(Le,Ae){return`Cannot access ${Le} ${Ae} levels up, current level is ${I}`}}return Nt.getData=J,Nt}var Mn={},Xc;function Va(){if(Xc)return Mn;Xc=1,Object.defineProperty(Mn,"__esModule",{value:!0});class e extends Error{constructor(r){super("validation failed"),this.errors=r,this.ajv=this.validation=!0}}return Mn.default=e,Mn}var zr={};Object.defineProperty(zr,"__esModule",{value:!0});const Ws=Ge;let J$=class extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Ws.resolveUrl)(t,r,n),this.missingSchema=(0,Ws.normalizeId)((0,Ws.getFullPath)(t,this.missingRef))}};zr.default=J$;var ot={};Object.defineProperty(ot,"__esModule",{value:!0});ot.resolveSchema=ot.getCompilingSchema=ot.resolveRef=ot.compileSchema=ot.SchemaEnv=void 0;const _t=ge,Q$=Va(),Xt=Ct,bt=Ge,el=W,Y$=Os();let xs=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,bt.normalizeId)(n==null?void 0:n[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n==null?void 0:n.$async,this.refs={}}};ot.SchemaEnv=xs;function Ha(e){const t=kd.call(this,e);if(t)return t;const r=(0,bt.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,a=new _t.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o});let i;e.$async&&(i=a.scopeValue("Error",{ref:Q$.default,code:(0,_t._)`require("ajv/dist/runtime/validation_error").default`}));const c=a.scopeName("validate");e.validateName=c;const l={gen:a,allErrors:this.opts.allErrors,data:Xt.default.data,parentData:Xt.default.parentData,parentDataProperty:Xt.default.parentDataProperty,dataNames:[Xt.default.data],dataPathArr:[_t.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,_t.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:_t.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,_t._)`""`,opts:this.opts,self:this};let d;try{this._compilations.add(e),(0,Y$.validateFunctionCode)(l),a.optimize(this.opts.code.optimize);const f=a.toString();d=`${a.scopeRefs(Xt.default.scope)}return ${f}`,this.opts.code.process&&(d=this.opts.code.process(d,e));const _=new Function(`${Xt.default.self}`,`${Xt.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:g,items:v}=l;_.evaluated={props:g instanceof _t.Name?void 0:g,items:v instanceof _t.Name?void 0:v,dynamicProps:g instanceof _t.Name,dynamicItems:v instanceof _t.Name},_.source&&(_.source.evaluated=(0,_t.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)}}ot.compileSchema=Ha;function X$(e,t,r){var n;r=(0,bt.resolveUrl)(this.opts.uriResolver,t,r);const s=e.refs[r];if(s)return s;let o=rw.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 xs({schema:a,schemaId:i,root:e,baseId:t}))}if(o!==void 0)return e.refs[r]=ew.call(this,o)}ot.resolveRef=X$;function ew(e){return(0,bt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Ha.call(this,e)}function kd(e){for(const t of this._compilations)if(tw(t,e))return t}ot.getCompilingSchema=kd;function tw(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function rw(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||As.call(this,e,t)}function As(e,t){const r=this.opts.uriResolver.parse(t),n=(0,bt._getFullPath)(this.opts.uriResolver,r);let s=(0,bt.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===s)return Bs.call(this,r,e);const o=(0,bt.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){const i=As.call(this,e,a);return typeof(i==null?void 0:i.schema)!="object"?void 0:Bs.call(this,r,i)}if(typeof(a==null?void 0:a.schema)=="object"){if(a.validate||Ha.call(this,a),o===(0,bt.normalizeId)(t)){const{schema:i}=a,{schemaId:c}=this.opts,l=i[c];return l&&(s=(0,bt.resolveUrl)(this.opts.uriResolver,s,l)),new xs({schema:i,schemaId:c,root:e,baseId:s})}return Bs.call(this,r,a)}}ot.resolveSchema=As;const nw=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Bs(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,el.unescapeFragment)(i)];if(c===void 0)return;r=c;const l=typeof r=="object"&&r[this.opts.schemaId];!nw.has(i)&&l&&(t=(0,bt.resolveUrl)(this.opts.uriResolver,t,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,el.schemaHasRulesButRef)(r,this.RULES)){const i=(0,bt.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=As.call(this,n,i)}const{schemaId:a}=this.opts;if(o=o||new xs({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}const sw="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",ow="Meta-schema for $data reference (JSON AnySchema extension proposal)",aw="object",iw=["$data"],cw={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},lw=!1,uw={$id:sw,description:ow,type:aw,required:iw,properties:cw,additionalProperties:lw};var Za={},Ms={exports:{}};const dw=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Pd=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),Ka=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),Rd=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),fw=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function Td(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 hw=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function tl(e){return e.length=0,!0}function pw(e,t,r){if(e.length){const n=Td(e);if(n!=="")t.push(n);else return r.error=!0,!1;e.length=0}return!0}function mw(e){let t=0;const r={error:!1,address:"",zone:""},n=[],s=[];let o=!1,a=!1,i=pw;for(let c=0;c7){r.error=!0;break}c>0&&e[c-1]===":"&&(o=!0),n.push(":");continue}else if(l==="%"){if(!i(s,n,r))break;i=tl}else{s.push(l);continue}}return s.length&&(i===tl?r.zone=s.join(""):a?n.push(s.join("")):n.push(Td(s))),r.address=n.join(""),r}function Cd(e){if(gw(e,":")<2)return{host:e,isIPV6:!1};const t=mw(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 gw(e,t){let r=0;for(let n=0;nyw[n])}function ww(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n65535))return"URI port is malformed."}function ds(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(Qw);a!==null&&a[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",s=!0);const i=e.match(Yw);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(Jw);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=Xw(n,c);if(l!==void 0&&(n.error=n.error||l,s=!0),n.host)if(Hw(n.host)===!1){const y=qw(n.host);n.host=y.host.toLowerCase(),o=y.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=Md(r.scheme||n.scheme);if(!r.unicodeSupport&&(!d||!d.unicodeSupport)&&n.host&&(r.domainHost||d&&d.domainHost)&&o===!1&&Zw(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=Vw(unescape(n.host),o))),n.path&&(n.path=Fw(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 fs(e,t){return ds(e,t).parsed}function e0(e,t){return qd(e,t).normalized}function qd(e,t){const{parsed:r,malformedAuthorityOrPort:n}=ds(e,t);return{normalized:n?e:dr(r,t),malformedAuthorityOrPort:n}}function rl(e,t){if(typeof e=="string"){const{normalized:r,malformedAuthorityOrPort:n}=qd(e,t);return n?void 0:r}if(typeof e=="object")return dr(e,t)}const Wa={SCHEMES:Kw,normalize:Gw,resolve:Ww,resolveComponent:zd,equal:Bw,serialize:dr,parse:fs};Ms.exports=Wa;Ms.exports.default=Wa;Ms.exports.fastUri=Wa;var Dd=Ms.exports;Object.defineProperty(Za,"__esModule",{value:!0});const Ud=Dd;Ud.code='require("ajv/dist/runtime/uri").default';Za.default=Ud;(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=Os();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=ge;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});const n=Va(),s=zr,o=ur,a=ot,i=ge,c=Ge,l=qe,d=W,f=uw,y=Za,_=(O,w)=>new RegExp(O,w);_.code="new RegExp";const g=["removeAdditional","useDefaults","coerceTypes"],v=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),m={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},h={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},$=200;function k(O){var w,C,b,u,p,P,q,D,X,J,j,I,U,Z,ee,ce,xe,tt,Fe,Le,Ae,kt,Ye,Wt,Bt;const mt=O.strict,Jt=(w=O.code)===null||w===void 0?void 0:w.optimize,Vr=Jt===!0||Jt===void 0?1:Jt||0,Hr=(b=(C=O.code)===null||C===void 0?void 0:C.regExp)!==null&&b!==void 0?b:_,Hs=(u=O.uriResolver)!==null&&u!==void 0?u:y.default;return{strictSchema:(P=(p=O.strictSchema)!==null&&p!==void 0?p:mt)!==null&&P!==void 0?P:!0,strictNumbers:(D=(q=O.strictNumbers)!==null&&q!==void 0?q:mt)!==null&&D!==void 0?D:!0,strictTypes:(J=(X=O.strictTypes)!==null&&X!==void 0?X:mt)!==null&&J!==void 0?J:"log",strictTuples:(I=(j=O.strictTuples)!==null&&j!==void 0?j:mt)!==null&&I!==void 0?I:"log",strictRequired:(Z=(U=O.strictRequired)!==null&&U!==void 0?U:mt)!==null&&Z!==void 0?Z:!1,code:O.code?{...O.code,optimize:Vr,regExp:Hr}:{optimize:Vr,regExp:Hr},loopRequired:(ee=O.loopRequired)!==null&&ee!==void 0?ee:$,loopEnum:(ce=O.loopEnum)!==null&&ce!==void 0?ce:$,meta:(xe=O.meta)!==null&&xe!==void 0?xe:!0,messages:(tt=O.messages)!==null&&tt!==void 0?tt:!0,inlineRefs:(Fe=O.inlineRefs)!==null&&Fe!==void 0?Fe:!0,schemaId:(Le=O.schemaId)!==null&&Le!==void 0?Le:"$id",addUsedSchema:(Ae=O.addUsedSchema)!==null&&Ae!==void 0?Ae:!0,validateSchema:(kt=O.validateSchema)!==null&&kt!==void 0?kt:!0,validateFormats:(Ye=O.validateFormats)!==null&&Ye!==void 0?Ye:!0,unicodeRegExp:(Wt=O.unicodeRegExp)!==null&&Wt!==void 0?Wt:!0,int32range:(Bt=O.int32range)!==null&&Bt!==void 0?Bt:!0,uriResolver:Hs}}class T{constructor(w={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,w=this.opts={...w,...k(w)};const{es5:C,lines:b}=this.opts.code;this.scope=new i.ValueScope({scope:{},prefixes:v,es5:C,lines:b}),this.logger=Y(w.logger);const u=w.validateFormats;w.validateFormats=!1,this.RULES=(0,o.getRules)(),E.call(this,m,w,"NOT SUPPORTED"),E.call(this,h,w,"DEPRECATED","warn"),this._metaOpts=V.call(this),w.formats&&L.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),w.keywords&&G.call(this,w.keywords),typeof w.meta=="object"&&this.addMetaSchema(w.meta),M.call(this),w.validateFormats=u}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:w,meta:C,schemaId:b}=this.opts;let u=f;b==="id"&&(u={...f},u.id=u.$id,delete u.$id),C&&w&&this.addMetaSchema(u,u[b],!1)}defaultMeta(){const{meta:w,schemaId:C}=this.opts;return this.opts.defaultMeta=typeof w=="object"?w[C]||w:void 0}validate(w,C){let b;if(typeof w=="string"){if(b=this.getSchema(w),!b)throw new Error(`no schema with key or ref "${w}"`)}else b=this.compile(w);const u=b(C);return"$async"in b||(this.errors=b.errors),u}compile(w,C){const b=this._addSchema(w,C);return b.validate||this._compileSchemaEnv(b)}compileAsync(w,C){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:b}=this.opts;return u.call(this,w,C);async function u(J,j){await p.call(this,J.$schema);const I=this._addSchema(J,j);return I.validate||P.call(this,I)}async function p(J){J&&!this.getSchema(J)&&await u.call(this,{$ref:J},!0)}async function P(J){try{return this._compileSchemaEnv(J)}catch(j){if(!(j instanceof s.default))throw j;return q.call(this,j),await D.call(this,j.missingSchema),P.call(this,J)}}function q({missingSchema:J,missingRef:j}){if(this.refs[J])throw new Error(`AnySchema ${J} is loaded but ${j} cannot be resolved`)}async function D(J){const j=await X.call(this,J);this.refs[J]||await p.call(this,j.$schema),this.refs[J]||this.addSchema(j,J,C)}async function X(J){const j=this._loading[J];if(j)return j;try{return await(this._loading[J]=b(J))}finally{delete this._loading[J]}}}addSchema(w,C,b,u=this.opts.validateSchema){if(Array.isArray(w)){for(const P of w)this.addSchema(P,void 0,b,u);return this}let p;if(typeof w=="object"){const{schemaId:P}=this.opts;if(p=w[P],p!==void 0&&typeof p!="string")throw new Error(`schema ${P} must be string`)}return C=(0,c.normalizeId)(C||p),this._checkUnique(C),this.schemas[C]=this._addSchema(w,b,C,u,!0),this}addMetaSchema(w,C,b=this.opts.validateSchema){return this.addSchema(w,C,!0,b),this}validateSchema(w,C){if(typeof w=="boolean")return!0;let b;if(b=w.$schema,b!==void 0&&typeof b!="string")throw new Error("$schema must be a string");if(b=b||this.opts.defaultMeta||this.defaultMeta(),!b)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const u=this.validate(b,w);if(!u&&C){const p="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(p);else throw new Error(p)}return u}getSchema(w){let C;for(;typeof(C=x.call(this,w))=="string";)w=C;if(C===void 0){const{schemaId:b}=this.opts,u=new a.SchemaEnv({schema:{},schemaId:b});if(C=a.resolveSchema.call(this,u,w),!C)return;this.refs[w]=C}return C.validate||this._compileSchemaEnv(C)}removeSchema(w){if(w instanceof RegExp)return this._removeAllSchemas(this.schemas,w),this._removeAllSchemas(this.refs,w),this;switch(typeof w){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const C=x.call(this,w);return typeof C=="object"&&this._cache.delete(C.schema),delete this.schemas[w],delete this.refs[w],this}case"object":{const C=w;this._cache.delete(C);let b=w[this.opts.schemaId];return b&&(b=(0,c.normalizeId)(b),delete this.schemas[b],delete this.refs[b]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(w){for(const C of w)this.addKeyword(C);return this}addKeyword(w,C){let b;if(typeof w=="string")b=w,typeof C=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),C.keyword=b);else if(typeof w=="object"&&C===void 0){if(C=w,b=C.keyword,Array.isArray(b)&&!b.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(F.call(this,b,C),!C)return(0,d.eachItem)(b,p=>ie.call(this,p)),this;$e.call(this,C);const u={...C,type:(0,l.getJSONTypes)(C.type),schemaType:(0,l.getJSONTypes)(C.schemaType)};return(0,d.eachItem)(b,u.type.length===0?p=>ie.call(this,p,u):p=>u.type.forEach(P=>ie.call(this,p,u,P))),this}getKeyword(w){const C=this.RULES.all[w];return typeof C=="object"?C.definition:!!C}removeKeyword(w){const{RULES:C}=this;delete C.keywords[w],delete C.all[w];for(const b of C.rules){const u=b.rules.findIndex(p=>p.keyword===w);u>=0&&b.rules.splice(u,1)}return this}addFormat(w,C){return typeof C=="string"&&(C=new RegExp(C)),this.formats[w]=C,this}errorsText(w=this.errors,{separator:C=", ",dataVar:b="data"}={}){return!w||w.length===0?"No errors":w.map(u=>`${b}${u.instancePath} ${u.message}`).reduce((u,p)=>u+C+p)}$dataMetaSchema(w,C){const b=this.RULES.all;w=JSON.parse(JSON.stringify(w));for(const u of C){const p=u.split("/").slice(1);let P=w;for(const q of p)P=P[q];for(const q in b){const D=b[q];if(typeof D!="object")continue;const{$data:X}=D.definition,J=P[q];X&&J&&(P[q]=Oe(J))}}return w}_removeAllSchemas(w,C){for(const b in w){const u=w[b];(!C||C.test(b))&&(typeof u=="string"?delete w[b]:u&&!u.meta&&(this._cache.delete(u.schema),delete w[b]))}}_addSchema(w,C,b,u=this.opts.validateSchema,p=this.opts.addUsedSchema){let P;const{schemaId:q}=this.opts;if(typeof w=="object")P=w[q];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof w!="boolean")throw new Error("schema must be object or boolean")}let D=this._cache.get(w);if(D!==void 0)return D;b=(0,c.normalizeId)(P||b);const X=c.getSchemaRefs.call(this,w,b);return D=new a.SchemaEnv({schema:w,schemaId:q,meta:C,baseId:b,localRefs:X}),this._cache.set(D.schema,D),p&&!b.startsWith("#")&&(b&&this._checkUnique(b),this.refs[b]=D),u&&this.validateSchema(w,!0),D}_checkUnique(w){if(this.schemas[w]||this.refs[w])throw new Error(`schema with key or id "${w}" already exists`)}_compileSchemaEnv(w){if(w.meta?this._compileMetaSchema(w):a.compileSchema.call(this,w),!w.validate)throw new Error("ajv implementation error");return w.validate}_compileMetaSchema(w){const C=this.opts;this.opts=this._metaOpts;try{a.compileSchema.call(this,w)}finally{this.opts=C}}}T.ValidationError=n.default,T.MissingRefError=s.default,e.default=T;function E(O,w,C,b="error"){for(const u in O){const p=u;p in w&&this.logger[b](`${C}: option ${u}. ${O[p]}`)}}function x(O){return O=(0,c.normalizeId)(O),this.schemas[O]||this.refs[O]}function M(){const O=this.opts.schemas;if(O)if(Array.isArray(O))this.addSchema(O);else for(const w in O)this.addSchema(O[w],w)}function L(){for(const O in this.opts.formats){const w=this.opts.formats[O];w&&this.addFormat(O,w)}}function G(O){if(Array.isArray(O)){this.addVocabulary(O);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const w in O){const C=O[w];C.keyword||(C.keyword=w),this.addKeyword(C)}}function V(){const O={...this.opts};for(const w of g)delete O[w];return O}const K={log(){},warn(){},error(){}};function Y(O){if(O===!1)return K;if(O===void 0)return console;if(O.log&&O.warn&&O.error)return O;throw new Error("logger must implement log, warn and error methods")}const ne=/^[a-z_$][a-z0-9_$:-]*$/i;function F(O,w){const{RULES:C}=this;if((0,d.eachItem)(O,b=>{if(C.keywords[b])throw new Error(`Keyword ${b} is already defined`);if(!ne.test(b))throw new Error(`Keyword ${b} has invalid name`)}),!!w&&w.$data&&!("code"in w||"validate"in w))throw new Error('$data keyword must have "code" or "validate" function')}function ie(O,w,C){var b;const u=w==null?void 0:w.post;if(C&&u)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:p}=this;let P=u?p.post:p.rules.find(({type:D})=>D===C);if(P||(P={type:C,rules:[]},p.rules.push(P)),p.keywords[O]=!0,!w)return;const q={keyword:O,definition:{...w,type:(0,l.getJSONTypes)(w.type),schemaType:(0,l.getJSONTypes)(w.schemaType)}};w.before?ke.call(this,P,q,w.before):P.rules.push(q),p.all[O]=q,(b=w.implements)===null||b===void 0||b.forEach(D=>this.addKeyword(D))}function ke(O,w,C){const b=O.rules.findIndex(u=>u.keyword===C);b>=0?O.rules.splice(b,0,w):(O.rules.push(w),this.logger.warn(`rule ${C} is not defined`))}function $e(O){let{metaSchema:w}=O;w!==void 0&&(O.$data&&this.opts.$data&&(w=Oe(w)),O.validateSchema=this.compile(w,!0))}const ct={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Oe(O){return{anyOf:[O,ct]}}})(ld);var Ba={},Ja={},Qa={};Object.defineProperty(Qa,"__esModule",{value:!0});const t0={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Qa.default=t0;var fr={};Object.defineProperty(fr,"__esModule",{value:!0});fr.callRef=fr.getValidate=void 0;const r0=zr,nl=pe,nt=ge,_r=Ct,sl=ot,zn=W,n0={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=sl.resolveRef.call(c,l,s,r);if(d===void 0)throw new r0.default(n.opts.uriResolver,s,r);if(d instanceof sl.SchemaEnv)return y(d);return _(d);function f(){if(o===l)return Qn(e,a,o,o.$async);const g=t.scopeValue("root",{ref:l});return Qn(e,(0,nt._)`${g}.validate`,l,l.$async)}function y(g){const v=Fd(e,g);Qn(e,v,g,g.$async)}function _(g){const v=t.scopeValue("schema",i.code.source===!0?{ref:g,code:(0,nt.stringify)(g)}:{ref:g}),m=t.name("valid"),h=e.subschema({schema:g,dataTypes:[],schemaPath:nt.nil,topSchemaRef:v,errSchemaPath:r},m);e.mergeEvaluated(h),e.ok(m)}}};function Fd(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,nt._)`${r.scopeValue("wrapper",{ref:t})}.validate`}fr.getValidate=Fd;function Qn(e,t,r,n){const{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:c}=o,l=c.passContext?_r.default.this:nt.nil;n?d():f();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");const g=s.let("valid");s.try(()=>{s.code((0,nt._)`await ${(0,nl.callValidateCode)(e,t,l)}`),_(t),a||s.assign(g,!0)},v=>{s.if((0,nt._)`!(${v} instanceof ${o.ValidationError})`,()=>s.throw(v)),y(v),a||s.assign(g,!1)}),e.ok(g)}function f(){e.result((0,nl.callValidateCode)(e,t,l),()=>_(t),()=>y(t))}function y(g){const v=(0,nt._)`${g}.errors`;s.assign(_r.default.vErrors,(0,nt._)`${_r.default.vErrors} === null ? ${v} : ${_r.default.vErrors}.concat(${v})`),s.assign(_r.default.errors,(0,nt._)`${_r.default.vErrors}.length`)}function _(g){var v;if(!o.opts.unevaluated)return;const m=(v=r==null?void 0:r.validate)===null||v===void 0?void 0:v.evaluated;if(o.props!==!0)if(m&&!m.dynamicProps)m.props!==void 0&&(o.props=zn.mergeEvaluated.props(s,m.props,o.props));else{const h=s.var("props",(0,nt._)`${g}.evaluated.props`);o.props=zn.mergeEvaluated.props(s,h,o.props,nt.Name)}if(o.items!==!0)if(m&&!m.dynamicItems)m.items!==void 0&&(o.items=zn.mergeEvaluated.items(s,m.items,o.items));else{const h=s.var("items",(0,nt._)`${g}.evaluated.items`);o.items=zn.mergeEvaluated.items(s,h,o.items,nt.Name)}}}fr.callRef=Qn;fr.default=n0;Object.defineProperty(Ja,"__esModule",{value:!0});const s0=Qa,o0=fr,a0=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",s0.default,o0.default];Ja.default=a0;var Ya={},Xa={};Object.defineProperty(Xa,"__esModule",{value:!0});const hs=ge,zt=hs.operators,ps={maximum:{okStr:"<=",ok:zt.LTE,fail:zt.GT},minimum:{okStr:">=",ok:zt.GTE,fail:zt.LT},exclusiveMaximum:{okStr:"<",ok:zt.LT,fail:zt.GTE},exclusiveMinimum:{okStr:">",ok:zt.GT,fail:zt.LTE}},i0={message:({keyword:e,schemaCode:t})=>(0,hs.str)`must be ${ps[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,hs._)`{comparison: ${ps[e].okStr}, limit: ${t}}`},c0={keyword:Object.keys(ps),type:"number",schemaType:"number",$data:!0,error:i0,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,hs._)`${r} ${ps[t].fail} ${n} || isNaN(${r})`)}};Xa.default=c0;var ei={};Object.defineProperty(ei,"__esModule",{value:!0});const tn=ge,l0={message:({schemaCode:e})=>(0,tn.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,tn._)`{multipleOf: ${e}}`},u0={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:l0,code(e){const{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0,tn._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0,tn._)`${a} !== parseInt(${a})`;e.fail$data((0,tn._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};ei.default=u0;var ti={},ri={};Object.defineProperty(ri,"__esModule",{value:!0});function Ld(e){const t=e.length;let r=0,n=0,s;for(;n=55296&&s<=56319&&n(0,nr._)`{limit: ${e}}`},p0={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:h0,code(e){const{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?nr.operators.GT:nr.operators.LT,a=s.opts.unicode===!1?(0,nr._)`${r}.length`:(0,nr._)`${(0,d0.useFunc)(e.gen,f0.default)}(${r})`;e.fail$data((0,nr._)`${a} ${o} ${n}`)}};ti.default=p0;var ni={};Object.defineProperty(ni,"__esModule",{value:!0});const m0=pe,g0=W,kr=ge,_0={message:({schemaCode:e})=>(0,kr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,kr._)`{pattern: ${e}}`},y0={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:_0,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,kr._)`new RegExp`:(0,g0.useFunc)(t,c),d=t.let("valid");t.try(()=>t.assign(d,(0,kr._)`${l}(${o}, ${i}).test(${r})`),()=>t.assign(d,!1)),e.fail$data((0,kr._)`!${d}`)}else{const c=(0,m0.usePattern)(e,s);e.fail$data((0,kr._)`!${c}.test(${r})`)}}};ni.default=y0;var si={};Object.defineProperty(si,"__esModule",{value:!0});const rn=ge,v0={message({keyword:e,schemaCode:t}){const r=e==="maxProperties"?"more":"fewer";return(0,rn.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,rn._)`{limit: ${e}}`},$0={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:v0,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?rn.operators.GT:rn.operators.LT;e.fail$data((0,rn._)`Object.keys(${r}).length ${s} ${n}`)}};si.default=$0;var oi={};Object.defineProperty(oi,"__esModule",{value:!0});const Gr=pe,nn=ge,w0=W,b0={message:({params:{missingProperty:e}})=>(0,nn.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,nn._)`{missingProperty: ${e}}`},S0={keyword:"required",type:"object",schemaType:"array",$data:!0,error:b0,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:g}=e.it;for(const v of r)if((_==null?void 0:_[v])===void 0&&!g.has(v)){const m=a.schemaEnv.baseId+a.errSchemaPath,h=`required property "${v}" is not defined at "${m}" (strictRequired)`;(0,w0.checkStrictMode)(a,h,a.opts.strictRequired)}}function l(){if(c||o)e.block$data(nn.nil,f);else for(const _ of r)(0,Gr.checkReportMissingProp)(e,_)}function d(){const _=t.let("missing");if(c||o){const g=t.let("valid",!0);e.block$data(g,()=>y(_,g)),e.ok(g)}else t.if((0,Gr.checkMissingProp)(e,r,_)),(0,Gr.reportMissingProp)(e,_),t.else()}function f(){t.forOf("prop",n,_=>{e.setParams({missingProperty:_}),t.if((0,Gr.noPropertyInData)(t,s,_,i.ownProperties),()=>e.error())})}function y(_,g){e.setParams({missingProperty:_}),t.forOf(_,n,()=>{t.assign(g,(0,Gr.propertyInData)(t,s,_,i.ownProperties)),t.if((0,nn.not)(g),()=>{e.error(),t.break()})},nn.nil)}}};oi.default=S0;var ai={};Object.defineProperty(ai,"__esModule",{value:!0});const sn=ge,E0={message({keyword:e,schemaCode:t}){const r=e==="maxItems"?"more":"fewer";return(0,sn.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,sn._)`{limit: ${e}}`},k0={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:E0,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?sn.operators.GT:sn.operators.LT;e.fail$data((0,sn._)`${r}.length ${s} ${n}`)}};ai.default=k0;var ii={},Tn={};Object.defineProperty(Tn,"__esModule",{value:!0});const Vd=Is;Vd.code='require("ajv/dist/runtime/equal").default';Tn.default=Vd;Object.defineProperty(ii,"__esModule",{value:!0});const Js=qe,He=ge,P0=W,R0=Tn,T0={message:({params:{i:e,j:t}})=>(0,He.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,He._)`{i: ${e}, j: ${t}}`},C0={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:T0,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,Js.getSchemaTypes)(o.items):[];e.block$data(c,d,(0,He._)`${a} === false`),e.ok(c);function d(){const g=t.let("i",(0,He._)`${r}.length`),v=t.let("j");e.setParams({i:g,j:v}),t.assign(c,!0),t.if((0,He._)`${g} > 1`,()=>(f()?y:_)(g,v))}function f(){return l.length>0&&!l.some(g=>g==="object"||g==="array")}function y(g,v){const m=t.name("item"),h=(0,Js.checkDataTypes)(l,m,i.opts.strictNumbers,Js.DataType.Wrong),$=t.const("indices",(0,He._)`{}`);t.for((0,He._)`;${g}--;`,()=>{t.let(m,(0,He._)`${r}[${g}]`),t.if(h,(0,He._)`continue`),l.length>1&&t.if((0,He._)`typeof ${m} == "string"`,(0,He._)`${m} += "_"`),t.if((0,He._)`typeof ${$}[${m}] == "number"`,()=>{t.assign(v,(0,He._)`${$}[${m}]`),e.error(),t.assign(c,!1).break()}).code((0,He._)`${$}[${m}] = ${g}`)})}function _(g,v){const m=(0,P0.useFunc)(t,R0.default),h=t.name("outer");t.label(h).for((0,He._)`;${g}--;`,()=>t.for((0,He._)`${v} = ${g}; ${v}--;`,()=>t.if((0,He._)`${m}(${r}[${g}], ${r}[${v}])`,()=>{e.error(),t.assign(c,!1).break(h)})))}}};ii.default=C0;var ci={};Object.defineProperty(ci,"__esModule",{value:!0});const So=ge,j0=W,N0=Tn,I0={message:"must be equal to constant",params:({schemaCode:e})=>(0,So._)`{allowedValue: ${e}}`},O0={keyword:"const",$data:!0,error:I0,code(e){const{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,So._)`!${(0,j0.useFunc)(t,N0.default)}(${r}, ${s})`):e.fail((0,So._)`${o} !== ${r}`)}};ci.default=O0;var li={};Object.defineProperty(li,"__esModule",{value:!0});const Yr=ge,x0=W,A0=Tn,M0={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,Yr._)`{allowedValues: ${e}}`},z0={keyword:"enum",schemaType:"array",$data:!0,error:M0,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,x0.useFunc)(t,A0.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,Yr.or)(...s.map((g,v)=>y(_,v)))}e.pass(d);function f(){t.assign(d,!1),t.forOf("v",o,_=>t.if((0,Yr._)`${l()}(${r}, ${_})`,()=>t.assign(d,!0).break()))}function y(_,g){const v=s[g];return typeof v=="object"&&v!==null?(0,Yr._)`${l()}(${r}, ${_}[${g}])`:(0,Yr._)`${r} === ${v}`}}};li.default=z0;Object.defineProperty(Ya,"__esModule",{value:!0});const q0=Xa,D0=ei,U0=ti,F0=ni,L0=si,V0=oi,H0=ai,Z0=ii,K0=ci,G0=li,W0=[q0.default,D0.default,U0.default,F0.default,L0.default,V0.default,H0.default,Z0.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},K0.default,G0.default];Ya.default=W0;var ui={},qr={};Object.defineProperty(qr,"__esModule",{value:!0});qr.validateAdditionalItems=void 0;const sr=ge,Eo=W,B0={message:({params:{len:e}})=>(0,sr.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,sr._)`{limit: ${e}}`},J0={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:B0,code(e){const{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Eo.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Hd(e,n)}};function Hd(e,t){const{gen:r,schema:n,data:s,keyword:o,it:a}=e;a.items=!0;const i=r.const("len",(0,sr._)`${s}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,sr._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0,Eo.alwaysValidSchema)(a,n)){const l=r.var("valid",(0,sr._)`${i} <= ${t.length}`);r.if((0,sr.not)(l),()=>c(l)),e.ok(l)}function c(l){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:Eo.Type.Num},l),a.allErrors||r.if((0,sr.not)(l),()=>r.break())})}}qr.validateAdditionalItems=Hd;qr.default=J0;var di={},Dr={};Object.defineProperty(Dr,"__esModule",{value:!0});Dr.validateTuple=void 0;const ol=ge,Yn=W,Q0=pe,Y0={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return Zd(e,"additionalItems",t);r.items=!0,!(0,Yn.alwaysValidSchema)(r,t)&&e.ok((0,Q0.validateArray)(e))}};function Zd(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=Yn.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),l=n.const("len",(0,ol._)`${o}.length`);r.forEach((f,y)=>{(0,Yn.alwaysValidSchema)(i,f)||(n.if((0,ol._)`${l} > ${y}`,()=>e.subschema({keyword:a,schemaProp:y,dataProp:y},c)),e.ok(c))});function d(f){const{opts:y,errSchemaPath:_}=i,g=r.length,v=g===f.minItems&&(g===f.maxItems||f[t]===!1);if(y.strictTuples&&!v){const m=`"${a}" is ${g}-tuple, but minItems or maxItems/${t} are not specified or different at path "${_}"`;(0,Yn.checkStrictMode)(i,m,y.strictTuples)}}}Dr.validateTuple=Zd;Dr.default=Y0;Object.defineProperty(di,"__esModule",{value:!0});const X0=Dr,eb={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,X0.validateTuple)(e,"items")};di.default=eb;var fi={};Object.defineProperty(fi,"__esModule",{value:!0});const al=ge,tb=W,rb=pe,nb=qr,sb={message:({params:{len:e}})=>(0,al.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,al._)`{limit: ${e}}`},ob={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:sb,code(e){const{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=!0,!(0,tb.alwaysValidSchema)(n,t)&&(s?(0,nb.validateAdditionalItems)(e,s):e.ok((0,rb.validateArray)(e)))}};fi.default=ob;var hi={};Object.defineProperty(hi,"__esModule",{value:!0});const dt=ge,qn=W,ab={message:({params:{min:e,max:t}})=>t===void 0?(0,dt.str)`must contain at least ${e} valid item(s)`:(0,dt.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,dt._)`{minContains: ${e}}`:(0,dt._)`{minContains: ${e}, maxContains: ${t}}`},ib={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:ab,code(e){const{gen:t,schema:r,parentSchema:n,data:s,it:o}=e;let a,i;const{minContains:c,maxContains:l}=n;o.opts.next?(a=c===void 0?1:c,i=l):a=1;const d=t.const("len",(0,dt._)`${s}.length`);if(e.setParams({min:a,max:i}),i===void 0&&a===0){(0,qn.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0,qn.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,qn.alwaysValidSchema)(o,r)){let v=(0,dt._)`${d} >= ${a}`;i!==void 0&&(v=(0,dt._)`${v} && ${d} <= ${i}`),e.pass(v);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,dt._)`${s}.length > 0`,y)):(t.let(f,!1),y()),e.result(f,()=>e.reset());function y(){const v=t.name("_valid"),m=t.let("count",0);_(v,()=>t.if(v,()=>g(m)))}function _(v,m){t.forRange("i",0,d,h=>{e.subschema({keyword:"contains",dataProp:h,dataPropType:qn.Type.Num,compositeRule:!0},v),m()})}function g(v){t.code((0,dt._)`${v}++`),i===void 0?t.if((0,dt._)`${v} >= ${a}`,()=>t.assign(f,!0).break()):(t.if((0,dt._)`${v} > ${i}`,()=>t.assign(f,!1).break()),a===1?t.assign(f,!0):t.if((0,dt._)`${v} >= ${a}`,()=>t.assign(f,!0)))}}};hi.default=ib;var Kd={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=ge,r=W,n=pe;e.error={message:({params:{property:c,depsCount:l,deps:d}})=>{const f=l===1?"property":"properties";return(0,t.str)`must have ${f} ${d} when property ${c} is present`},params:({params:{property:c,depsCount:l,deps:d,missingProperty:f}})=>(0,t._)`{property: ${c}, - missingProperty: ${f}, - depsCount: ${l}, - deps: ${d}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(c){const[l,d]=o(c);a(c,l),i(c,d)}};function o({schema:c}){const l={},d={};for(const f in c){if(f==="__proto__")continue;const y=Array.isArray(c[f])?l:d;y[f]=c[f]}return[l,d]}function a(c,l=c.schema){const{gen:d,data:f,it:y}=c;if(Object.keys(l).length===0)return;const _=d.let("missing");for(const g in l){const v=l[g];if(v.length===0)continue;const m=(0,n.propertyInData)(d,f,g,y.opts.ownProperties);c.setParams({property:g,depsCount:v.length,deps:v.join(", ")}),y.allErrors?d.if(m,()=>{for(const h of v)(0,n.checkReportMissingProp)(c,h)}):(d.if((0,t._)`${m} && (${(0,n.checkMissingProp)(c,v,_)})`),(0,n.reportMissingProp)(c,_),d.else())}}e.validatePropertyDeps=a;function i(c,l=c.schema){const{gen:d,data:f,keyword:y,it:_}=c,g=d.name("valid");for(const v in l)(0,r.alwaysValidSchema)(_,l[v])||(d.if((0,n.propertyInData)(d,f,v,_.opts.ownProperties),()=>{const m=c.subschema({keyword:y,schemaProp:v},g);c.mergeValidEvaluated(m,g)},()=>d.var(g,!0)),c.ok(g))}e.validateSchemaDeps=i,e.default=s})(Kd);var pi={};Object.defineProperty(pi,"__esModule",{value:!0});const Gd=ge,cb=W,lb={message:"property name must be valid",params:({params:e})=>(0,Gd._)`{propertyName: ${e.propertyName}}`},ub={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:lb,code(e){const{gen:t,schema:r,data:n,it:s}=e;if((0,cb.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,Gd.not)(o),()=>{e.error(!0),s.allErrors||t.break()})}),e.ok(o)}};pi.default=ub;var zs={};Object.defineProperty(zs,"__esModule",{value:!0});const Dn=pe,vt=ge,db=Ct,Un=W,fb={message:"must NOT have additional properties",params:({params:e})=>(0,vt._)`{additionalProperty: ${e.additionalProperty}}`},hb={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:fb,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,Un.alwaysValidSchema)(a,r))return;const l=(0,Dn.allSchemaProperties)(n.properties),d=(0,Dn.allSchemaProperties)(n.patternProperties);f(),e.ok((0,vt._)`${o} === ${db.default.errors}`);function f(){t.forIn("key",s,m=>{!l.length&&!d.length?g(m):t.if(y(m),()=>g(m))})}function y(m){let h;if(l.length>8){const $=(0,Un.schemaRefOrVal)(a,n.properties,"properties");h=(0,Dn.isOwnProperty)(t,$,m)}else l.length?h=(0,vt.or)(...l.map($=>(0,vt._)`${m} === ${$}`)):h=vt.nil;return d.length&&(h=(0,vt.or)(h,...d.map($=>(0,vt._)`${(0,Dn.usePattern)(e,$)}.test(${m})`))),(0,vt.not)(h)}function _(m){t.code((0,vt._)`delete ${s}[${m}]`)}function g(m){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){_(m);return}if(r===!1){e.setParams({additionalProperty:m}),e.error(),i||t.break();return}if(typeof r=="object"&&!(0,Un.alwaysValidSchema)(a,r)){const h=t.name("valid");c.removeAdditional==="failing"?(v(m,h,!1),t.if((0,vt.not)(h),()=>{e.reset(),_(m)})):(v(m,h),i||t.if((0,vt.not)(h),()=>t.break()))}}function v(m,h,$){const k={keyword:"additionalProperties",dataProp:m,dataPropType:Un.Type.Str};$===!1&&Object.assign(k,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(k,h)}}};zs.default=hb;var mi={};Object.defineProperty(mi,"__esModule",{value:!0});const pb=Os(),il=pe,Qs=W,cl=zs,mb={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&&cl.default.code(new pb.KeywordCxt(o,cl.default,"additionalProperties"));const a=(0,il.allSchemaProperties)(r);for(const f of a)o.definedProperties.add(f);o.opts.unevaluated&&a.length&&o.props!==!0&&(o.props=Qs.mergeEvaluated.props(t,(0,Qs.toHash)(a),o.props));const i=a.filter(f=>!(0,Qs.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,il.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)}}};mi.default=mb;var gi={};Object.defineProperty(gi,"__esModule",{value:!0});const ll=pe,Fn=ge,ul=W,dl=W,gb={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,ll.allSchemaProperties)(r),c=i.filter(v=>(0,ul.alwaysValidSchema)(o,r[v]));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 Fn.Name)&&(o.props=(0,dl.evaluatedPropsToName)(t,o.props));const{props:f}=o;y();function y(){for(const v of i)l&&_(v),o.allErrors?g(v):(t.var(d,!0),g(v),t.if(d))}function _(v){for(const m in l)new RegExp(v).test(m)&&(0,ul.checkStrictMode)(o,`property ${m} matches pattern ${v} (use allowMatchingProperties)`)}function g(v){t.forIn("key",n,m=>{t.if((0,Fn._)`${(0,ll.usePattern)(e,v)}.test(${m})`,()=>{const h=c.includes(v);h||e.subschema({keyword:"patternProperties",schemaProp:v,dataProp:m,dataPropType:dl.Type.Str},d),o.opts.unevaluated&&f!==!0?t.assign((0,Fn._)`${f}[${m}]`,!0):!h&&!o.allErrors&&t.if((0,Fn.not)(d),()=>t.break())})})}}};gi.default=gb;var _i={};Object.defineProperty(_i,"__esModule",{value:!0});const _b=W,yb={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,_b.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"}};_i.default=yb;var yi={};Object.defineProperty(yi,"__esModule",{value:!0});const vb=pe,$b={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:vb.validateUnion,error:{message:"must match a schema in anyOf"}};yi.default=$b;var vi={};Object.defineProperty(vi,"__esModule",{value:!0});const Xn=ge,wb=W,bb={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,Xn._)`{passingSchemas: ${e.passing}}`},Sb={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:bb,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 y;(0,wb.alwaysValidSchema)(s,d)?t.var(c,!0):y=e.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},c),f>0&&t.if((0,Xn._)`${c} && ${a}`).assign(a,!1).assign(i,(0,Xn._)`[${i}, ${f}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,f),y&&e.mergeEvaluated(y,Xn.Name)})})}}};vi.default=Sb;var $i={};Object.defineProperty($i,"__esModule",{value:!0});const Eb=W,kb={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,Eb.alwaysValidSchema)(n,o))return;const i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i)})}};$i.default=kb;var wi={};Object.defineProperty(wi,"__esModule",{value:!0});const ms=ge,Wd=W,Pb={message:({params:e})=>(0,ms.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,ms._)`{failingKeyword: ${e.ifClause}}`},Rb={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:Pb,code(e){const{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,Wd.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const s=fl(n,"then"),o=fl(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,ms.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 y=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(y,a),f?t.assign(f,(0,ms._)`${d}`):e.setParams({ifClause:d})}}}};function fl(e,t){const r=e.schema[t];return r!==void 0&&!(0,Wd.alwaysValidSchema)(e,r)}wi.default=Rb;var bi={};Object.defineProperty(bi,"__esModule",{value:!0});const Tb=W,Cb={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,Tb.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};bi.default=Cb;Object.defineProperty(ui,"__esModule",{value:!0});const jb=qr,Nb=di,Ib=Dr,Ob=fi,xb=hi,Ab=Kd,Mb=pi,zb=zs,qb=mi,Db=gi,Ub=_i,Fb=yi,Lb=vi,Vb=$i,Hb=wi,Zb=bi;function Kb(e=!1){const t=[Ub.default,Fb.default,Lb.default,Vb.default,Hb.default,Zb.default,Mb.default,zb.default,Ab.default,qb.default,Db.default];return e?t.push(Nb.default,Ob.default):t.push(jb.default,Ib.default),t.push(xb.default),t}ui.default=Kb;var Si={},Ei={};Object.defineProperty(Ei,"__esModule",{value:!0});const Me=ge,Gb={message:({schemaCode:e})=>(0,Me.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,Me._)`{format: ${e}}`},Wb={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:Gb,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?y():_();function y(){const g=r.scopeValue("formats",{ref:f.formats,code:c.code.formats}),v=r.const("fDef",(0,Me._)`${g}[${a}]`),m=r.let("fType"),h=r.let("format");r.if((0,Me._)`typeof ${v} == "object" && !(${v} instanceof RegExp)`,()=>r.assign(m,(0,Me._)`${v}.type || "string"`).assign(h,(0,Me._)`${v}.validate`),()=>r.assign(m,(0,Me._)`"string"`).assign(h,v)),e.fail$data((0,Me.or)($(),k()));function $(){return c.strictSchema===!1?Me.nil:(0,Me._)`${a} && !${h}`}function k(){const T=d.$async?(0,Me._)`(${v}.async ? await ${h}(${n}) : ${h}(${n}))`:(0,Me._)`${h}(${n})`,E=(0,Me._)`(typeof ${h} == "function" ? ${T} : ${h}.test(${n}))`;return(0,Me._)`${h} && ${h} !== true && ${m} === ${t} && !${E}`}}function _(){const g=f.formats[o];if(!g){$();return}if(g===!0)return;const[v,m,h]=k(g);v===t&&e.pass(T());function $(){if(c.strictSchema===!1){f.logger.warn(E());return}throw new Error(E());function E(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function k(E){const x=E instanceof RegExp?(0,Me.regexpCode)(E):c.code.formats?(0,Me._)`${c.code.formats}${(0,Me.getProperty)(o)}`:void 0,M=r.scopeValue("formats",{key:o,ref:E,code:x});return typeof E=="object"&&!(E instanceof RegExp)?[E.type||"string",E.validate,(0,Me._)`${M}.validate`]:["string",E,M]}function T(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!d.$async)throw new Error("async format in sync schema");return(0,Me._)`await ${h}(${n})`}return typeof m=="function"?(0,Me._)`${h}(${n})`:(0,Me._)`${h}.test(${n})`}}}};Ei.default=Wb;Object.defineProperty(Si,"__esModule",{value:!0});const Bb=Ei,Jb=[Bb.default];Si.default=Jb;var Ir={};Object.defineProperty(Ir,"__esModule",{value:!0});Ir.contentVocabulary=Ir.metadataVocabulary=void 0;Ir.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Ir.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(Ba,"__esModule",{value:!0});const Qb=Ja,Yb=Ya,Xb=ui,eS=Si,hl=Ir,tS=[Qb.default,Yb.default,(0,Xb.default)(),eS.default,hl.metadataVocabulary,hl.contentVocabulary];Ba.default=tS;var ki={},qs={};Object.defineProperty(qs,"__esModule",{value:!0});qs.DiscrError=void 0;var pl;(function(e){e.Tag="tag",e.Mapping="mapping"})(pl||(qs.DiscrError=pl={}));Object.defineProperty(ki,"__esModule",{value:!0});const br=ge,ko=qs,ml=ot,rS=zr,nS=W,sS={message:({params:{discrError:e,tagName:t}})=>e===ko.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,br._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},oS={keyword:"discriminator",type:"object",schemaType:"object",error:sS,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,br._)`${r}${(0,br.getProperty)(i)}`);t.if((0,br._)`typeof ${l} == "string"`,()=>d(),()=>e.error(!1,{discrError:ko.DiscrError.Tag,tag:l,tagName:i})),e.ok(c);function d(){const _=y();t.if(!1);for(const g in _)t.elseIf((0,br._)`${l} === ${g}`),t.assign(c,f(_[g]));t.else(),e.error(!1,{discrError:ko.DiscrError.Mapping,tag:l,tagName:i}),t.endIf()}function f(_){const g=t.name("valid"),v=e.subschema({keyword:"oneOf",schemaProp:_},g);return e.mergeEvaluated(v,br.Name),g}function y(){var _;const g={},v=h(s);let m=!0;for(let T=0;Tthis.addVocabulary(g)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const g=this.opts.$data?this.$dataMetaSchema(o,a):o;this.addMetaSchema(g,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=Os();Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var d=ge;Object.defineProperty(t,"_",{enumerable:!0,get:function(){return d._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return d.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return d.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return d.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return d.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return d.CodeGen}});var f=Va();Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return f.default}});var y=zr;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return y.default}})})(yo,yo.exports);var hS=yo.exports;const pS=Gl(hS);var Po={exports:{}},Bd={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(K,Y){return{validate:K,compare:Y}}e.fullFormats={date:t(o,a),time:t(c(!0),l),"date-time":t(y(!0),_),"iso-time":t(c(),d),"iso-date-time":t(y(),g),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:k,int32:{type:"number",validate:x},int64:{type:"number",validate:M},float:{type:"number",validate:L},double:{type:"number",validate:L},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,a),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,l),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,_),"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,g),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(K){return K%4===0&&(K%100!==0||K%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(K){const Y=n.exec(K);if(!Y)return!1;const ne=+Y[1],F=+Y[2],ie=+Y[3];return F>=1&&F<=12&&ie>=1&&ie<=(F===2&&r(ne)?29:s[F])}function a(K,Y){if(K&&Y)return K>Y?1:K23||w>59||K&&!ct)return!1;if(ie<=23&&ke<=59&&$e<60)return!0;const C=ke-w*Oe,b=ie-O*Oe-(C<0?1:0);return(b===23||b===-1)&&(C===59||C===-1)&&$e<61}}function l(K,Y){if(!(K&&Y))return;const ne=new Date("2020-01-01T"+K).valueOf(),F=new Date("2020-01-01T"+Y).valueOf();if(ne&&F)return ne-F}function d(K,Y){if(!(K&&Y))return;const ne=i.exec(K),F=i.exec(Y);if(ne&&F)return K=ne[1]+ne[2]+ne[3],Y=F[1]+F[2]+F[3],K>Y?1:K=T}function M(K){return Number.isInteger(K)}function L(){return!0}const G=/[^\\]\\Z/;function V(K){if(G.test(K))return!1;try{return new RegExp(K),!0}catch{return!1}}})(Bd);var Jd={},Ro={exports:{}},Qd={},Et={},Or={},Cn={},he={},gn={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class t{}e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends t{constructor($){if(super(),!e.IDENTIFIER.test($))throw new Error("CodeGen: name must be a valid identifier");this.str=$}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=r;class n extends t{constructor($){super(),this._items=typeof $=="string"?[$]:$}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const $=this._items[0];return $===""||$==='""'}get str(){var $;return($=this._str)!==null&&$!==void 0?$:this._str=this._items.reduce((k,T)=>`${k}${T}`,"")}get names(){var $;return($=this._names)!==null&&$!==void 0?$:this._names=this._items.reduce((k,T)=>(T instanceof r&&(k[T.str]=(k[T.str]||0)+1),k),{})}}e._Code=n,e.nil=new n("");function s(h,...$){const k=[h[0]];let T=0;for(;T<$.length;)i(k,$[T]),k.push(h[++T]);return new n(k)}e._=s;const o=new n("+");function a(h,...$){const k=[_(h[0])];let T=0;for(;T<$.length;)k.push(o),i(k,$[T]),k.push(o,_(h[++T]));return c(k),new n(k)}e.str=a;function i(h,$){$ instanceof n?h.push(...$._items):$ instanceof r?h.push($):h.push(f($))}e.addCodeArg=i;function c(h){let $=1;for(;${if(f.scopePath===void 0)throw new Error(`CodeGen: name "${f}" has no value`);return(0,t._)`${l}${f.scopePath}`})}scopeCode(l=this._values,d,f){return this._reduceValues(l,y=>{if(y.value===void 0)throw new Error(`CodeGen: name "${y}" has no value`);return y.value.code},d,f)}_reduceValues(l,d,f={},y){let _=t.nil;for(const g in l){const v=l[g];if(!v)continue;const m=f[g]=f[g]||new Map;v.forEach(h=>{if(m.has(h))return;m.set(h,n.Started);let $=d(h);if($){const k=this.opts.es5?e.varKinds.var:e.varKinds.const;_=(0,t._)`${_}${k} ${h} = ${$};${this.opts._n}`}else if($=y==null?void 0:y(h))_=(0,t._)`${_}${$}${this.opts._n}`;else throw new r(h);m.set(h,n.Completed)})}return _}}e.ValueScope=i})(To);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=gn,r=To;var n=gn;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}});var s=To;Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class o{optimizeNodes(){return this}optimizeNames(u,p){return this}}class a extends o{constructor(u,p,P){super(),this.varKind=u,this.name=p,this.rhs=P}render({es5:u,_n:p}){const P=u?r.varKinds.var:this.varKind,q=this.rhs===void 0?"":` = ${this.rhs}`;return`${P} ${this.name}${q};`+p}optimizeNames(u,p){if(u[this.name.str])return this.rhs&&(this.rhs=F(this.rhs,u,p)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class i extends o{constructor(u,p,P){super(),this.lhs=u,this.rhs=p,this.sideEffects=P}render({_n:u}){return`${this.lhs} = ${this.rhs};`+u}optimizeNames(u,p){if(!(this.lhs instanceof t.Name&&!u[this.lhs.str]&&!this.sideEffects))return this.rhs=F(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,P,q){super(u,P,q),this.op=p}render({_n:u}){return`${this.lhs} ${this.op}= ${this.rhs};`+u}}class l extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`${this.label}:`+u}}class d extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`break${this.label?` ${this.label}`:""};`+u}}class f extends o{constructor(u){super(),this.error=u}render({_n:u}){return`throw ${this.error};`+u}get names(){return this.error.names}}class y 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=F(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,P)=>p+P.render(u),"")}optimizeNodes(){const{nodes:u}=this;let p=u.length;for(;p--;){const P=u[p].optimizeNodes();Array.isArray(P)?u.splice(p,1,...P):P?u[p]=P:u.splice(p,1)}return u.length>0?this:void 0}optimizeNames(u,p){const{nodes:P}=this;let q=P.length;for(;q--;){const D=P[q];D.optimizeNames(u,p)||(ie(u,D.names),P.splice(q,1))}return P.length>0?this:void 0}get names(){return this.nodes.reduce((u,p)=>Y(u,p.names),{})}}class g extends _{render(u){return"{"+u._n+super.render(u)+"}"+u._n}}class v extends _{}class m extends g{}m.kind="else";class h extends g{constructor(u,p){super(p),this.condition=u}render(u){let p=`if(${this.condition})`+super.render(u);return this.else&&(p+="else "+this.else.render(u)),p}optimizeNodes(){super.optimizeNodes();const u=this.condition;if(u===!0)return this.nodes;let p=this.else;if(p){const P=p.optimizeNodes();p=this.else=Array.isArray(P)?new m(P):P}if(p)return u===!1?p instanceof h?p:p.nodes:this.nodes.length?this:new h(ke(u),p instanceof h?[p]:p.nodes);if(!(u===!1||!this.nodes.length))return this}optimizeNames(u,p){var P;if(this.else=(P=this.else)===null||P===void 0?void 0:P.optimizeNames(u,p),!!(super.optimizeNames(u,p)||this.else))return this.condition=F(this.condition,u,p),this}get names(){const u=super.names;return ne(u,this.condition),this.else&&Y(u,this.else.names),u}}h.kind="if";class $ extends g{}$.kind="for";class k extends ${constructor(u){super(),this.iteration=u}render(u){return`for(${this.iteration})`+super.render(u)}optimizeNames(u,p){if(super.optimizeNames(u,p))return this.iteration=F(this.iteration,u,p),this}get names(){return Y(super.names,this.iteration.names)}}class T extends ${constructor(u,p,P,q){super(),this.varKind=u,this.name=p,this.from=P,this.to=q}render(u){const p=u.es5?r.varKinds.var:this.varKind,{name:P,from:q,to:D}=this;return`for(${p} ${P}=${q}; ${P}<${D}; ${P}++)`+super.render(u)}get names(){const u=ne(super.names,this.from);return ne(u,this.to)}}class E extends ${constructor(u,p,P,q){super(),this.loop=u,this.varKind=p,this.name=P,this.iterable=q}render(u){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(u)}optimizeNames(u,p){if(super.optimizeNames(u,p))return this.iterable=F(this.iterable,u,p),this}get names(){return Y(super.names,this.iterable.names)}}class x extends g{constructor(u,p,P){super(),this.name=u,this.args=p,this.async=P}render(u){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(u)}}x.kind="func";class M extends _{render(u){return"return "+super.render(u)}}M.kind="return";class L extends g{render(u){let p="try"+super.render(u);return this.catch&&(p+=this.catch.render(u)),this.finally&&(p+=this.finally.render(u)),p}optimizeNodes(){var u,p;return super.optimizeNodes(),(u=this.catch)===null||u===void 0||u.optimizeNodes(),(p=this.finally)===null||p===void 0||p.optimizeNodes(),this}optimizeNames(u,p){var P,q;return super.optimizeNames(u,p),(P=this.catch)===null||P===void 0||P.optimizeNames(u,p),(q=this.finally)===null||q===void 0||q.optimizeNames(u,p),this}get names(){const u=super.names;return this.catch&&Y(u,this.catch.names),this.finally&&Y(u,this.finally.names),u}}class G extends g{constructor(u){super(),this.error=u}render(u){return`catch(${this.error})`+super.render(u)}}G.kind="catch";class V extends g{render(u){return"finally"+super.render(u)}}V.kind="finally";class K{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 v]}toString(){return this._root.render(this.opts)}name(u){return this._scope.name(u)}scopeName(u){return this._extScope.name(u)}scopeValue(u,p){const P=this._extScope.value(u,p);return(this._values[P.prefix]||(this._values[P.prefix]=new Set)).add(P),P}getScopeValue(u,p){return this._extScope.getValue(u,p)}scopeRefs(u){return this._extScope.scopeRefs(u,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(u,p,P,q){const D=this._scope.toName(p);return P!==void 0&&q&&(this._constants[D.str]=P),this._leafNode(new a(u,D,P)),D}const(u,p,P){return this._def(r.varKinds.const,u,p,P)}let(u,p,P){return this._def(r.varKinds.let,u,p,P)}var(u,p,P){return this._def(r.varKinds.var,u,p,P)}assign(u,p,P){return this._leafNode(new i(u,p,P))}add(u,p){return this._leafNode(new c(u,e.operators.ADD,p))}code(u){return typeof u=="function"?u():u!==t.nil&&this._leafNode(new y(u)),this}object(...u){const p=["{"];for(const[P,q]of u)p.length>1&&p.push(","),p.push(P),(P!==q||this.opts.es5)&&(p.push(":"),(0,t.addCodeArg)(p,q));return p.push("}"),new t._Code(p)}if(u,p,P){if(this._blockNode(new h(u)),p&&P)this.code(p).else().code(P).endIf();else if(p)this.code(p).endIf();else if(P)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(u){return this._elseNode(new h(u))}else(){return this._elseNode(new m)}endIf(){return this._endBlockNode(h,m)}_for(u,p){return this._blockNode(u),p&&this.code(p).endFor(),this}for(u,p){return this._for(new k(u),p)}forRange(u,p,P,q,D=this.opts.es5?r.varKinds.var:r.varKinds.let){const X=this._scope.toName(u);return this._for(new T(D,X,p,P),()=>q(X))}forOf(u,p,P,q=r.varKinds.const){const D=this._scope.toName(u);if(this.opts.es5){const X=p instanceof t.Name?p:this.var("_arr",p);return this.forRange("_i",0,(0,t._)`${X}.length`,J=>{this.var(D,(0,t._)`${X}[${J}]`),P(D)})}return this._for(new E("of",q,D,p),()=>P(D))}forIn(u,p,P,q=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(u,(0,t._)`Object.keys(${p})`,P);const D=this._scope.toName(u);return this._for(new E("in",q,D,p),()=>P(D))}endFor(){return this._endBlockNode($)}label(u){return this._leafNode(new l(u))}break(u){return this._leafNode(new d(u))}return(u){const p=new M;if(this._blockNode(p),this.code(u),p.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(M)}try(u,p,P){if(!p&&!P)throw new Error('CodeGen: "try" without "catch" and "finally"');const q=new L;if(this._blockNode(q),this.code(u),p){const D=this.name("e");this._currNode=q.catch=new G(D),p(D)}return P&&(this._currNode=q.finally=new V,this.code(P)),this._endBlockNode(G,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 P=this._nodes.length-p;if(P<0||u!==void 0&&P!==u)throw new Error(`CodeGen: wrong number of nodes: ${P} vs ${u} expected`);return this._nodes.length=p,this}func(u,p=t.nil,P,q){return this._blockNode(new x(u,p,P)),q&&this.code(q).endFunc(),this}endFunc(){return this._endBlockNode(x)}optimize(u=1){for(;u-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(u){return this._currNode.nodes.push(u),this}_blockNode(u){this._currNode.nodes.push(u),this._nodes.push(u)}_endBlockNode(u,p){const P=this._currNode;if(P instanceof u||p&&P instanceof p)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${p?`${u.kind}/${p.kind}`:u.kind}"`)}_elseNode(u){const p=this._currNode;if(!(p instanceof 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=K;function Y(b,u){for(const p in u)b[p]=(b[p]||0)+(u[p]||0);return b}function ne(b,u){return u instanceof t._CodeOrName?Y(b,u.names):b}function F(b,u,p){if(b instanceof t.Name)return P(b);if(!q(b))return b;return new t._Code(b._items.reduce((D,X)=>(X instanceof t.Name&&(X=P(X)),X instanceof t._Code?D.push(...X._items):D.push(X),D),[]));function P(D){const X=p[D.str];return X===void 0||u[D.str]!==1?D:(delete u[D.str],X)}function q(D){return D instanceof t._Code&&D._items.some(X=>X instanceof t.Name&&u[X.str]===1&&p[X.str]!==void 0)}}function ie(b,u){for(const p in u)b[p]=(b[p]||0)-(u[p]||0)}function ke(b){return typeof b=="boolean"||typeof b=="number"||b===null?!b:(0,t._)`!${C(b)}`}e.not=ke;const $e=w(e.operators.AND);function ct(...b){return b.reduce($e)}e.and=ct;const Oe=w(e.operators.OR);function O(...b){return b.reduce(Oe)}e.or=O;function w(b){return(u,p)=>u===t.nil?p:p===t.nil?u:(0,t._)`${C(u)} ${b} ${C(p)}`}function C(b){return b instanceof t.Name?b:(0,t._)`(${b})`}})(he);var B={};Object.defineProperty(B,"__esModule",{value:!0});B.checkStrictMode=B.getErrorPath=B.Type=B.useFunc=B.setEvaluated=B.evaluatedPropsToName=B.mergeEvaluated=B.eachItem=B.unescapeJsonPointer=B.escapeJsonPointer=B.escapeFragment=B.unescapeFragment=B.schemaRefOrVal=B.schemaHasRulesButRef=B.schemaHasRules=B.checkUnknownRules=B.alwaysValidSchema=B.toHash=void 0;const be=he,mS=gn;function gS(e){const t={};for(const r of e)t[r]=!0;return t}B.toHash=gS;function _S(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(Yd(e,t),!Xd(t,e.self.RULES.all))}B.alwaysValidSchema=_S;function Yd(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]||rf(e,`unknown keyword: "${o}"`)}B.checkUnknownRules=Yd;function Xd(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(t[r])return!0;return!1}B.schemaHasRules=Xd;function yS(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}B.schemaHasRulesButRef=yS;function vS({topSchemaRef:e,schemaPath:t},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,be._)`${r}`}return(0,be._)`${e}${t}${(0,be.getProperty)(n)}`}B.schemaRefOrVal=vS;function $S(e){return ef(decodeURIComponent(e))}B.unescapeFragment=$S;function wS(e){return encodeURIComponent(Pi(e))}B.escapeFragment=wS;function Pi(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}B.escapeJsonPointer=Pi;function ef(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}B.unescapeJsonPointer=ef;function bS(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)}B.eachItem=bS;function gl({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(s,o,a,i)=>{const c=a===void 0?o:a instanceof be.Name?(o instanceof be.Name?e(s,o,a):t(s,o,a),a):o instanceof be.Name?(t(s,a,o),o):r(o,a);return i===be.Name&&!(c instanceof be.Name)?n(s,c):c}}B.mergeEvaluated={props:gl({mergeNames:(e,t,r)=>e.if((0,be._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,be._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,be._)`${r} || {}`).code((0,be._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,be._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,be._)`${r} || {}`),Ri(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:tf}),items:gl({mergeNames:(e,t,r)=>e.if((0,be._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,be._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,be._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,be._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function tf(e,t){if(t===!0)return e.var("props",!0);const r=e.var("props",(0,be._)`{}`);return t!==void 0&&Ri(e,r,t),r}B.evaluatedPropsToName=tf;function Ri(e,t,r){Object.keys(r).forEach(n=>e.assign((0,be._)`${t}${(0,be.getProperty)(n)}`,!0))}B.setEvaluated=Ri;const _l={};function SS(e,t){return e.scopeValue("func",{ref:t,code:_l[t.code]||(_l[t.code]=new mS._Code(t.code))})}B.useFunc=SS;var Co;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Co||(B.Type=Co={}));function ES(e,t,r){if(e instanceof be.Name){const n=t===Co.Num;return r?n?(0,be._)`"[" + ${e} + "]"`:(0,be._)`"['" + ${e} + "']"`:n?(0,be._)`"/" + ${e}`:(0,be._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,be.getProperty)(e).toString():"/"+Pi(e)}B.getErrorPath=ES;function rf(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}B.checkStrictMode=rf;var jt={};Object.defineProperty(jt,"__esModule",{value:!0});const et=he,kS={data:new et.Name("data"),valCxt:new et.Name("valCxt"),instancePath:new et.Name("instancePath"),parentData:new et.Name("parentData"),parentDataProperty:new et.Name("parentDataProperty"),rootData:new et.Name("rootData"),dynamicAnchors:new et.Name("dynamicAnchors"),vErrors:new et.Name("vErrors"),errors:new et.Name("errors"),this:new et.Name("this"),self:new et.Name("self"),scope:new et.Name("scope"),json:new et.Name("json"),jsonPos:new et.Name("jsonPos"),jsonLen:new et.Name("jsonLen"),jsonPart:new et.Name("jsonPart")};jt.default=kS;(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=B,n=jt;e.keywordError={message:({keyword:m})=>(0,t.str)`must pass "${m}" keyword validation`},e.keyword$DataError={message:({keyword:m,schemaType:h})=>h?(0,t.str)`"${m}" keyword must be ${h} ($data)`:(0,t.str)`"${m}" keyword is invalid ($data)`};function s(m,h=e.keywordError,$,k){const{it:T}=m,{gen:E,compositeRule:x,allErrors:M}=T,L=f(m,h,$);k??(x||M)?c(E,L):l(T,(0,t._)`[${L}]`)}e.reportError=s;function o(m,h=e.keywordError,$){const{it:k}=m,{gen:T,compositeRule:E,allErrors:x}=k,M=f(m,h,$);c(T,M),E||x||l(k,n.default.vErrors)}e.reportExtraError=o;function a(m,h){m.assign(n.default.errors,h),m.if((0,t._)`${n.default.vErrors} !== null`,()=>m.if(h,()=>m.assign((0,t._)`${n.default.vErrors}.length`,h),()=>m.assign(n.default.vErrors,null)))}e.resetErrorsCount=a;function i({gen:m,keyword:h,schemaValue:$,data:k,errsCount:T,it:E}){if(T===void 0)throw new Error("ajv implementation error");const x=m.name("err");m.forRange("i",T,n.default.errors,M=>{m.const(x,(0,t._)`${n.default.vErrors}[${M}]`),m.if((0,t._)`${x}.instancePath === undefined`,()=>m.assign((0,t._)`${x}.instancePath`,(0,t.strConcat)(n.default.instancePath,E.errorPath))),m.assign((0,t._)`${x}.schemaPath`,(0,t.str)`${E.errSchemaPath}/${h}`),E.opts.verbose&&(m.assign((0,t._)`${x}.schema`,$),m.assign((0,t._)`${x}.data`,k))})}e.extendErrors=i;function c(m,h){const $=m.const("err",h);m.if((0,t._)`${n.default.vErrors} === null`,()=>m.assign(n.default.vErrors,(0,t._)`[${$}]`),(0,t._)`${n.default.vErrors}.push(${$})`),m.code((0,t._)`${n.default.errors}++`)}function l(m,h){const{gen:$,validateName:k,schemaEnv:T}=m;T.$async?$.throw((0,t._)`new ${m.ValidationError}(${h})`):($.assign((0,t._)`${k}.errors`,h),$.return(!1))}const d={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function f(m,h,$){const{createErrors:k}=m.it;return k===!1?(0,t._)`{}`:y(m,h,$)}function y(m,h,$={}){const{gen:k,it:T}=m,E=[_(T,$),g(m,$)];return v(m,h,E),k.object(...E)}function _({errorPath:m},{instancePath:h}){const $=h?(0,t.str)`${m}${(0,r.getErrorPath)(h,r.Type.Str)}`:m;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,$)]}function g({keyword:m,it:{errSchemaPath:h}},{schemaPath:$,parentSchema:k}){let T=k?h:(0,t.str)`${h}/${m}`;return $&&(T=(0,t.str)`${T}${(0,r.getErrorPath)($,r.Type.Str)}`),[d.schemaPath,T]}function v(m,{params:h,message:$},k){const{keyword:T,data:E,schemaValue:x,it:M}=m,{opts:L,propertyName:G,topSchemaRef:V,schemaPath:K}=M;k.push([d.keyword,T],[d.params,typeof h=="function"?h(m):h||(0,t._)`{}`]),L.messages&&k.push([d.message,typeof $=="function"?$(m):$]),L.verbose&&k.push([d.schema,x],[d.parentSchema,(0,t._)`${V}${K}`],[n.default.data,E]),G&&k.push([d.propertyName,G])}})(Cn);Object.defineProperty(Or,"__esModule",{value:!0});Or.boolOrEmptySchema=Or.topBoolOrEmptySchema=void 0;const PS=Cn,RS=he,TS=jt,CS={message:"boolean schema is false"};function jS(e){const{gen:t,schema:r,validateName:n}=e;r===!1?nf(e,!1):typeof r=="object"&&r.$async===!0?t.return(TS.default.data):(t.assign((0,RS._)`${n}.errors`,null),t.return(!0))}Or.topBoolOrEmptySchema=jS;function NS(e,t){const{gen:r,schema:n}=e;n===!1?(r.var(t,!1),nf(e)):r.var(t,!0)}Or.boolOrEmptySchema=NS;function nf(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,PS.reportError)(s,CS,void 0,t)}var De={},hr={};Object.defineProperty(hr,"__esModule",{value:!0});hr.getRules=hr.isJSONType=void 0;const IS=["string","number","integer","boolean","null","object","array"],OS=new Set(IS);function xS(e){return typeof e=="string"&&OS.has(e)}hr.isJSONType=xS;function AS(){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:{}}}hr.getRules=AS;var xt={};Object.defineProperty(xt,"__esModule",{value:!0});xt.shouldUseRule=xt.shouldUseGroup=xt.schemaHasRulesForType=void 0;function MS({schema:e,self:t},r){const n=t.RULES.types[r];return n&&n!==!0&&sf(e,n)}xt.schemaHasRulesForType=MS;function sf(e,t){return t.rules.some(r=>of(e,r))}xt.shouldUseGroup=sf;function of(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}xt.shouldUseRule=of;Object.defineProperty(De,"__esModule",{value:!0});De.reportTypeError=De.checkDataTypes=De.checkDataType=De.coerceAndCheckDataType=De.getJSONTypes=De.getSchemaTypes=De.DataType=void 0;const zS=hr,qS=xt,DS=Cn,de=he,af=B;var Cr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Cr||(De.DataType=Cr={}));function US(e){const t=cf(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}De.getSchemaTypes=US;function cf(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(zS.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}De.getJSONTypes=cf;function FS(e,t){const{gen:r,data:n,opts:s}=e,o=LS(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0,qS.schemaHasRulesForType)(e,t[0]));if(a){const i=Ti(t,n,s.strictNumbers,Cr.Wrong);r.if(i,()=>{o.length?VS(e,t,o):Ci(e)})}return a}De.coerceAndCheckDataType=FS;const lf=new Set(["string","number","integer","boolean","null"]);function LS(e,t){return t?e.filter(r=>lf.has(r)||t==="array"&&r==="array"):[]}function VS(e,t,r){const{gen:n,data:s,opts:o}=e,a=n.let("dataType",(0,de._)`typeof ${s}`),i=n.let("coerced",(0,de._)`undefined`);o.coerceTypes==="array"&&n.if((0,de._)`${a} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,de._)`${s}[0]`).assign(a,(0,de._)`typeof ${s}`).if(Ti(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0,de._)`${i} !== undefined`);for(const l of r)(lf.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),Ci(e),n.endIf(),n.if((0,de._)`${i} !== undefined`,()=>{n.assign(s,i),HS(e,i)});function c(l){switch(l){case"string":n.elseIf((0,de._)`${a} == "number" || ${a} == "boolean"`).assign(i,(0,de._)`"" + ${s}`).elseIf((0,de._)`${s} === null`).assign(i,(0,de._)`""`);return;case"number":n.elseIf((0,de._)`${a} == "boolean" || ${s} === null - || (${a} == "string" && ${s} && ${s} == +${s})`).assign(i,(0,de._)`+${s}`);return;case"integer":n.elseIf((0,de._)`${a} === "boolean" || ${s} === null - || (${a} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(i,(0,de._)`+${s}`);return;case"boolean":n.elseIf((0,de._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(i,!1).elseIf((0,de._)`${s} === "true" || ${s} === 1`).assign(i,!0);return;case"null":n.elseIf((0,de._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(i,null);return;case"array":n.elseIf((0,de._)`${a} === "string" || ${a} === "number" - || ${a} === "boolean" || ${s} === null`).assign(i,(0,de._)`[${s}]`)}}}function HS({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,de._)`${t} !== undefined`,()=>e.assign((0,de._)`${t}[${r}]`,n))}function jo(e,t,r,n=Cr.Correct){const s=n===Cr.Correct?de.operators.EQ:de.operators.NEQ;let o;switch(e){case"null":return(0,de._)`${t} ${s} null`;case"array":o=(0,de._)`Array.isArray(${t})`;break;case"object":o=(0,de._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=a((0,de._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=a();break;default:return(0,de._)`typeof ${t} ${s} ${e}`}return n===Cr.Correct?o:(0,de.not)(o);function a(i=de.nil){return(0,de.and)((0,de._)`typeof ${t} == "number"`,i,r?(0,de._)`isFinite(${t})`:de.nil)}}De.checkDataType=jo;function Ti(e,t,r,n){if(e.length===1)return jo(e[0],t,r,n);let s;const o=(0,af.toHash)(e);if(o.array&&o.object){const a=(0,de._)`typeof ${t} != "object"`;s=o.null?a:(0,de._)`!${t} || ${a}`,delete o.null,delete o.array,delete o.object}else s=de.nil;o.number&&delete o.integer;for(const a in o)s=(0,de.and)(s,jo(a,t,r,n));return s}De.checkDataTypes=Ti;const ZS={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,de._)`{type: ${e}}`:(0,de._)`{type: ${t}}`};function Ci(e){const t=KS(e);(0,DS.reportError)(t,ZS)}De.reportTypeError=Ci;function KS(e){const{gen:t,data:r,schema:n}=e,s=(0,af.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}var Ds={};Object.defineProperty(Ds,"__esModule",{value:!0});Ds.assignDefaults=void 0;const yr=he,GS=B;function WS(e,t){const{properties:r,items:n}=e.schema;if(t==="object"&&r)for(const s in r)yl(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>yl(e,o,s.default))}Ds.assignDefaults=WS;function yl(e,t,r){const{gen:n,compositeRule:s,data:o,opts:a}=e;if(r===void 0)return;const i=(0,yr._)`${o}${(0,yr.getProperty)(t)}`;if(s){(0,GS.checkStrictMode)(e,`default is ignored for: ${i}`);return}let c=(0,yr._)`${i} === undefined`;a.useDefaults==="empty"&&(c=(0,yr._)`${c} || ${i} === null || ${i} === ""`),n.if(c,(0,yr._)`${i} = ${(0,yr.stringify)(r)}`)}var Tt={},me={};Object.defineProperty(me,"__esModule",{value:!0});me.validateUnion=me.validateArray=me.usePattern=me.callValidateCode=me.schemaProperties=me.allSchemaProperties=me.noPropertyInData=me.propertyInData=me.isOwnProperty=me.hasPropFunc=me.reportMissingProp=me.checkMissingProp=me.checkReportMissingProp=void 0;const Re=he,ji=B,qt=jt,BS=B;function JS(e,t){const{gen:r,data:n,it:s}=e;r.if(Ii(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Re._)`${t}`},!0),e.error()})}me.checkReportMissingProp=JS;function QS({gen:e,data:t,it:{opts:r}},n,s){return(0,Re.or)(...n.map(o=>(0,Re.and)(Ii(e,t,o,r.ownProperties),(0,Re._)`${s} = ${o}`)))}me.checkMissingProp=QS;function YS(e,t){e.setParams({missingProperty:t},!0),e.error()}me.reportMissingProp=YS;function uf(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Re._)`Object.prototype.hasOwnProperty`})}me.hasPropFunc=uf;function Ni(e,t,r){return(0,Re._)`${uf(e)}.call(${t}, ${r})`}me.isOwnProperty=Ni;function XS(e,t,r,n){const s=(0,Re._)`${t}${(0,Re.getProperty)(r)} !== undefined`;return n?(0,Re._)`${s} && ${Ni(e,t,r)}`:s}me.propertyInData=XS;function Ii(e,t,r,n){const s=(0,Re._)`${t}${(0,Re.getProperty)(r)} === undefined`;return n?(0,Re.or)(s,(0,Re.not)(Ni(e,t,r))):s}me.noPropertyInData=Ii;function df(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}me.allSchemaProperties=df;function eE(e,t){return df(t).filter(r=>!(0,ji.alwaysValidSchema)(e,t[r]))}me.schemaProperties=eE;function tE({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:a},i,c,l){const d=l?(0,Re._)`${e}, ${t}, ${n}${s}`:t,f=[[qt.default.instancePath,(0,Re.strConcat)(qt.default.instancePath,o)],[qt.default.parentData,a.parentData],[qt.default.parentDataProperty,a.parentDataProperty],[qt.default.rootData,qt.default.rootData]];a.opts.dynamicRef&&f.push([qt.default.dynamicAnchors,qt.default.dynamicAnchors]);const y=(0,Re._)`${d}, ${r.object(...f)}`;return c!==Re.nil?(0,Re._)`${i}.call(${c}, ${y})`:(0,Re._)`${i}(${y})`}me.callValidateCode=tE;const rE=(0,Re._)`new RegExp`;function nE({gen:e,it:{opts:t}},r){const n=t.unicodeRegExp?"u":"",{regExp:s}=t.code,o=s(r,n);return e.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,Re._)`${s.code==="new RegExp"?rE:(0,BS.useFunc)(e,s)}(${r}, ${n})`})}me.usePattern=nE;function sE(e){const{gen:t,data:r,keyword:n,it:s}=e,o=t.name("valid");if(s.allErrors){const i=t.let("valid",!0);return a(()=>t.assign(i,!1)),i}return t.var(o,!0),a(()=>t.break()),o;function a(i){const c=t.const("len",(0,Re._)`${r}.length`);t.forRange("i",0,c,l=>{e.subschema({keyword:n,dataProp:l,dataPropType:ji.Type.Num},o),t.if((0,Re.not)(o),i)})}}me.validateArray=sE;function oE(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,ji.alwaysValidSchema)(s,c))&&!s.opts.unevaluated)return;const a=t.let("valid",!1),i=t.name("_valid");t.block(()=>r.forEach((c,l)=>{const d=e.subschema({keyword:n,schemaProp:l,compositeRule:!0},i);t.assign(a,(0,Re._)`${a} || ${i}`),e.mergeValidEvaluated(d,i)||t.if((0,Re.not)(a))})),e.result(a,()=>e.reset(),()=>e.error(!0))}me.validateUnion=oE;Object.defineProperty(Tt,"__esModule",{value:!0});Tt.validateKeywordUsage=Tt.validSchemaType=Tt.funcKeywordCode=Tt.macroKeywordCode=void 0;const rt=he,or=jt,aE=me,iE=Cn;function cE(e,t){const{gen:r,keyword:n,schema:s,parentSchema:o,it:a}=e,i=t.macro.call(a.self,s,o,a),c=ff(r,n,i);a.opts.validateSchema!==!1&&a.self.validateSchema(i,!0);const l=r.name("valid");e.subschema({schema:i,schemaPath:rt.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},l),e.pass(l,()=>e.error(!0))}Tt.macroKeywordCode=cE;function lE(e,t){var r;const{gen:n,keyword:s,schema:o,parentSchema:a,$data:i,it:c}=e;dE(c,t);const l=!i&&t.compile?t.compile.call(c.self,o,a,c):t.validate,d=ff(n,s,l),f=n.let("valid");e.block$data(f,y),e.ok((r=t.valid)!==null&&r!==void 0?r:f);function y(){if(t.errors===!1)v(),t.modifying&&vl(e),m(()=>e.error());else{const h=t.async?_():g();t.modifying&&vl(e),m(()=>uE(e,h))}}function _(){const h=n.let("ruleErrs",null);return n.try(()=>v((0,rt._)`await `),$=>n.assign(f,!1).if((0,rt._)`${$} instanceof ${c.ValidationError}`,()=>n.assign(h,(0,rt._)`${$}.errors`),()=>n.throw($))),h}function g(){const h=(0,rt._)`${d}.errors`;return n.assign(h,null),v(rt.nil),h}function v(h=t.async?(0,rt._)`await `:rt.nil){const $=c.opts.passContext?or.default.this:or.default.self,k=!("compile"in t&&!i||t.schema===!1);n.assign(f,(0,rt._)`${h}${(0,aE.callValidateCode)(e,d,$,k)}`,t.modifying)}function m(h){var $;n.if((0,rt.not)(($=t.valid)!==null&&$!==void 0?$:f),h)}}Tt.funcKeywordCode=lE;function vl(e){const{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,rt._)`${n.parentData}[${n.parentDataProperty}]`))}function uE(e,t){const{gen:r}=e;r.if((0,rt._)`Array.isArray(${t})`,()=>{r.assign(or.default.vErrors,(0,rt._)`${or.default.vErrors} === null ? ${t} : ${or.default.vErrors}.concat(${t})`).assign(or.default.errors,(0,rt._)`${or.default.vErrors}.length`),(0,iE.extendErrors)(e)},()=>e.error())}function dE({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function ff(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,rt.stringify)(r)})}function fE(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}Tt.validSchemaType=fE;function hE({schema:e,opts:t,self:r,errSchemaPath:n},s,o){if(Array.isArray(s.keyword)?!s.keyword.includes(o):s.keyword!==o)throw new Error("ajv implementation error");const a=s.dependencies;if(a!=null&&a.some(i=>!Object.prototype.hasOwnProperty.call(e,i)))throw new Error(`parent schema must have dependencies of ${o}: ${a.join(",")}`);if(s.validateSchema&&!s.validateSchema(e[o])){const c=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(s.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}Tt.validateKeywordUsage=hE;var Zt={};Object.defineProperty(Zt,"__esModule",{value:!0});Zt.extendSubschemaMode=Zt.extendSubschemaData=Zt.getSubschema=void 0;const Rt=he,hf=B;function pE(e,{keyword:t,schemaProp:r,schema:n,schemaPath:s,errSchemaPath:o,topSchemaRef:a}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){const i=e.schema[t];return r===void 0?{schema:i,schemaPath:(0,Rt._)`${e.schemaPath}${(0,Rt.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:i[r],schemaPath:(0,Rt._)`${e.schemaPath}${(0,Rt.getProperty)(t)}${(0,Rt.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,hf.escapeFragment)(r)}`}}if(n!==void 0){if(s===void 0||o===void 0||a===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:s,topSchemaRef:a,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}Zt.getSubschema=pE;function mE(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,y=i.let("data",(0,Rt._)`${t.data}${(0,Rt.getProperty)(r)}`,!0);c(y),e.errorPath=(0,Rt.str)`${l}${(0,hf.getErrorPath)(r,n,f.jsPropertySyntax)}`,e.parentDataProperty=(0,Rt._)`${r}`,e.dataPathArr=[...d,e.parentDataProperty]}if(s!==void 0){const l=s instanceof Rt.Name?s:i.let("data",s,!0);c(l),a!==void 0&&(e.propertyName=a)}o&&(e.dataTypes=o);function c(l){e.data=l,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,l]}}Zt.extendSubschemaData=mE;function gE(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:s,allErrors:o}){n!==void 0&&(e.compositeRule=n),s!==void 0&&(e.createErrors=s),o!==void 0&&(e.allErrors=o),e.jtdDiscriminator=t,e.jtdMetadata=r}Zt.extendSubschemaMode=gE;var We={},pf={exports:{}},Vt=pf.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(){};es(t,n,s,e,"",e)};Vt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Vt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Vt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Vt.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function es(e,t,r,n,s,o,a,i,c,l){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,s,o,a,i,c,l);for(var d in n){var f=n[d];if(Array.isArray(f)){if(d in Vt.arrayKeywords)for(var y=0;yt+=mf(n)),t===1/0))return 1/0}return t}function gf(e,t="",r){r!==!1&&(t=jr(t));const n=e.parse(t);return _f(e,n)}We.getFullPath=gf;function _f(e,t){return e.serialize(t).split("#")[0]+"#"}We._getFullPath=_f;const kE=/#\/?$/;function jr(e){return e?e.replace(kE,""):""}We.normalizeId=jr;function PE(e,t,r){return r=jr(r),e.resolve(t,r)}We.resolveUrl=PE;const RE=/^[a-z_][-a-z0-9._]*$/i;function TE(e,t){if(typeof e=="boolean")return{};const{schemaId:r,uriResolver:n}=this.opts,s=jr(e[r]||t),o={"":s},a=gf(n,s,!1),i={},c=new Set;return wE(e,{allKeys:!0},(f,y,_,g)=>{if(g===void 0)return;const v=a+y;let m=o[g];typeof f[r]=="string"&&(m=h.call(this,f[r])),$.call(this,f.$anchor),$.call(this,f.$dynamicAnchor),o[y]=m;function h(k){const T=this.opts.uriResolver.resolve;if(k=jr(m?T(m,k):k),c.has(k))throw d(k);c.add(k);let E=this.refs[k];return typeof E=="string"&&(E=this.refs[E]),typeof E=="object"?l(f,E.schema,k):k!==jr(v)&&(k[0]==="#"?(l(f,i[k],k),i[k]=f):this.refs[k]=v),k}function $(k){if(typeof k=="string"){if(!RE.test(k))throw new Error(`invalid anchor "${k}"`);h.call(this,`#${k}`)}}}),i;function l(f,y,_){if(y!==void 0&&!$E(f,y))throw d(_)}function d(f){return new Error(`reference "${f}" resolves to more than one schema`)}}We.getSchemaRefs=TE;Object.defineProperty(Et,"__esModule",{value:!0});Et.getData=Et.KeywordCxt=Et.validateFunctionCode=void 0;const yf=Or,$l=De,Oi=xt,gs=De,CE=Ds,on=Tt,Ys=Zt,re=he,oe=jt,jE=We,At=B,Wr=Cn;function NE(e){if(wf(e)&&(bf(e),$f(e))){xE(e);return}vf(e,()=>(0,yf.topBoolOrEmptySchema)(e))}Et.validateFunctionCode=NE;function vf({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},o){s.code.es5?e.func(t,(0,re._)`${oe.default.data}, ${oe.default.valCxt}`,n.$async,()=>{e.code((0,re._)`"use strict"; ${wl(r,s)}`),OE(e,s),e.code(o)}):e.func(t,(0,re._)`${oe.default.data}, ${IE(s)}`,n.$async,()=>e.code(wl(r,s)).code(o))}function IE(e){return(0,re._)`{${oe.default.instancePath}="", ${oe.default.parentData}, ${oe.default.parentDataProperty}, ${oe.default.rootData}=${oe.default.data}${e.dynamicRef?(0,re._)`, ${oe.default.dynamicAnchors}={}`:re.nil}}={}`}function OE(e,t){e.if(oe.default.valCxt,()=>{e.var(oe.default.instancePath,(0,re._)`${oe.default.valCxt}.${oe.default.instancePath}`),e.var(oe.default.parentData,(0,re._)`${oe.default.valCxt}.${oe.default.parentData}`),e.var(oe.default.parentDataProperty,(0,re._)`${oe.default.valCxt}.${oe.default.parentDataProperty}`),e.var(oe.default.rootData,(0,re._)`${oe.default.valCxt}.${oe.default.rootData}`),t.dynamicRef&&e.var(oe.default.dynamicAnchors,(0,re._)`${oe.default.valCxt}.${oe.default.dynamicAnchors}`)},()=>{e.var(oe.default.instancePath,(0,re._)`""`),e.var(oe.default.parentData,(0,re._)`undefined`),e.var(oe.default.parentDataProperty,(0,re._)`undefined`),e.var(oe.default.rootData,oe.default.data),t.dynamicRef&&e.var(oe.default.dynamicAnchors,(0,re._)`{}`)})}function xE(e){const{schema:t,opts:r,gen:n}=e;vf(e,()=>{r.$comment&&t.$comment&&Ef(e),DE(e),n.let(oe.default.vErrors,null),n.let(oe.default.errors,0),r.unevaluated&&AE(e),Sf(e),LE(e)})}function AE(e){const{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,re._)`${r}.evaluated`),t.if((0,re._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,re._)`${e.evaluated}.props`,(0,re._)`undefined`)),t.if((0,re._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,re._)`${e.evaluated}.items`,(0,re._)`undefined`))}function wl(e,t){const r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,re._)`/*# sourceURL=${r} */`:re.nil}function ME(e,t){if(wf(e)&&(bf(e),$f(e))){zE(e,t);return}(0,yf.boolOrEmptySchema)(e,t)}function $f({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 wf(e){return typeof e.schema!="boolean"}function zE(e,t){const{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&Ef(e),UE(e),FE(e);const o=n.const("_errs",oe.default.errors);Sf(e,o),n.var(t,(0,re._)`${o} === ${oe.default.errors}`)}function bf(e){(0,At.checkUnknownRules)(e),qE(e)}function Sf(e,t){if(e.opts.jtd)return bl(e,[],!1,t);const r=(0,$l.getSchemaTypes)(e.schema),n=(0,$l.coerceAndCheckDataType)(e,r);bl(e,r,!n,t)}function qE(e){const{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,At.schemaHasRulesButRef)(t,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function DE(e){const{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,At.checkStrictMode)(e,"default is ignored in the schema root")}function UE(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,jE.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function FE(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Ef({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:s}){const o=r.$comment;if(s.$comment===!0)e.code((0,re._)`${oe.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){const a=(0,re.str)`${n}/$comment`,i=e.scopeValue("root",{ref:t.root});e.code((0,re._)`${oe.default.self}.opts.$comment(${o}, ${a}, ${i}.schema)`)}}function LE(e){const{gen:t,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=e;r.$async?t.if((0,re._)`${oe.default.errors} === 0`,()=>t.return(oe.default.data),()=>t.throw((0,re._)`new ${s}(${oe.default.vErrors})`)):(t.assign((0,re._)`${n}.errors`,oe.default.vErrors),o.unevaluated&&VE(e),t.return((0,re._)`${oe.default.errors} === 0`))}function VE({gen:e,evaluated:t,props:r,items:n}){r instanceof re.Name&&e.assign((0,re._)`${t}.props`,r),n instanceof re.Name&&e.assign((0,re._)`${t}.items`,n)}function bl(e,t,r,n){const{gen:s,schema:o,data:a,allErrors:i,opts:c,self:l}=e,{RULES:d}=l;if(o.$ref&&(c.ignoreKeywordsWithRef||!(0,At.schemaHasRulesButRef)(o,d))){s.block(()=>Rf(e,"$ref",d.all.$ref.definition));return}c.jtd||HE(e,t),s.block(()=>{for(const y of d.rules)f(y);f(d.post)});function f(y){(0,Oi.shouldUseGroup)(o,y)&&(y.type?(s.if((0,gs.checkDataType)(y.type,a,c.strictNumbers)),Sl(e,y),t.length===1&&t[0]===y.type&&r&&(s.else(),(0,gs.reportTypeError)(e)),s.endIf()):Sl(e,y),i||s.if((0,re._)`${oe.default.errors} === ${n||0}`))}}function Sl(e,t){const{gen:r,schema:n,opts:{useDefaults:s}}=e;s&&(0,CE.assignDefaults)(e,t.type),r.block(()=>{for(const o of t.rules)(0,Oi.shouldUseRule)(n,o)&&Rf(e,o.keyword,o.definition,t.type)})}function HE(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(ZE(e,t),e.opts.allowUnionTypes||KE(e,t),GE(e,e.dataTypes))}function ZE(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{kf(e.dataTypes,r)||xi(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),BE(e,t)}}function KE(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&xi(e,"use allowUnionTypes to allow union type keyword")}function GE(e,t){const r=e.self.RULES.all;for(const n in r){const s=r[n];if(typeof s=="object"&&(0,Oi.shouldUseRule)(e.schema,s)){const{type:o}=s.definition;o.length&&!o.some(a=>WE(t,a))&&xi(e,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function WE(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function kf(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function BE(e,t){const r=[];for(const n of e.dataTypes)kf(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function xi(e,t){const r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,At.checkStrictMode)(e,t,e.opts.strictTypes)}class Pf{constructor(t,r,n){if((0,on.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,At.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",Tf(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,on.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",oe.default.errors))}result(t,r,n){this.failResult((0,re.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,re.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,re._)`${r} !== undefined && (${(0,re.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?Wr.reportExtraError:Wr.reportError)(this,this.def.error,r)}$dataError(){(0,Wr.reportError)(this,this.def.$dataError||Wr.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Wr.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=re.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=re.nil,r=re.nil){if(!this.$data)return;const{gen:n,schemaCode:s,schemaType:o,def:a}=this;n.if((0,re.or)((0,re._)`${s} === undefined`,r)),t!==re.nil&&n.assign(t,!0),(o.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==re.nil&&n.assign(t,!1)),n.else()}invalid$data(){const{gen:t,schemaCode:r,schemaType:n,def:s,it:o}=this;return(0,re.or)(a(),i());function a(){if(n.length){if(!(r instanceof re.Name))throw new Error("ajv implementation error");const c=Array.isArray(n)?n:[n];return(0,re._)`${(0,gs.checkDataTypes)(c,r,o.opts.strictNumbers,gs.DataType.Wrong)}`}return re.nil}function i(){if(s.validateSchema){const c=t.scopeValue("validate$data",{ref:s.validateSchema});return(0,re._)`!${c}(${r})`}return re.nil}}subschema(t,r){const n=(0,Ys.getSubschema)(this.it,t);(0,Ys.extendSubschemaData)(n,this.it,t),(0,Ys.extendSubschemaMode)(n,t);const s={...this.it,...n,items:void 0,props:void 0};return ME(s,r),s}mergeEvaluated(t,r){const{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=At.mergeEvaluated.props(s,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=At.mergeEvaluated.items(s,t.items,n.items,r)))}mergeValidEvaluated(t,r){const{it:n,gen:s}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return s.if(r,()=>this.mergeEvaluated(t,re.Name)),!0}}Et.KeywordCxt=Pf;function Rf(e,t,r,n){const s=new Pf(e,r,t);"code"in r?r.code(s,n):s.$data&&r.validate?(0,on.funcKeywordCode)(s,r):"macro"in r?(0,on.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,on.funcKeywordCode)(s,r)}const JE=/^\/(?:[^~]|~0|~1)*$/,QE=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Tf(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,o;if(e==="")return oe.default.rootData;if(e[0]==="/"){if(!JE.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,o=oe.default.rootData}else{const l=QE.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,re._)`${o}${(0,re.getProperty)((0,At.unescapeJsonPointer)(l))}`,a=(0,re._)`${a} && ${o}`);return a;function c(l,d){return`Cannot access ${l} ${d} levels up, current level is ${t}`}}Et.getData=Tf;var jn={};Object.defineProperty(jn,"__esModule",{value:!0});class YE extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}}jn.default=YE;var Ur={};Object.defineProperty(Ur,"__esModule",{value:!0});const Xs=We;class XE extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Xs.resolveUrl)(t,r,n),this.missingSchema=(0,Xs.normalizeId)((0,Xs.getFullPath)(t,this.missingRef))}}Ur.default=XE;var at={};Object.defineProperty(at,"__esModule",{value:!0});at.resolveSchema=at.getCompilingSchema=at.resolveRef=at.compileSchema=at.SchemaEnv=void 0;const yt=he,ek=jn,er=jt,St=We,El=B,tk=Et;class Us{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,St.normalizeId)(n==null?void 0:n[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n==null?void 0:n.$async,this.refs={}}}at.SchemaEnv=Us;function Ai(e){const t=Cf.call(this,e);if(t)return t;const r=(0,St.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,a=new yt.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o});let i;e.$async&&(i=a.scopeValue("Error",{ref:ek.default,code:(0,yt._)`require("ajv/dist/runtime/validation_error").default`}));const c=a.scopeName("validate");e.validateName=c;const l={gen:a,allErrors:this.opts.allErrors,data:er.default.data,parentData:er.default.parentData,parentDataProperty:er.default.parentDataProperty,dataNames:[er.default.data],dataPathArr:[yt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,yt.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:yt.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,yt._)`""`,opts:this.opts,self:this};let d;try{this._compilations.add(e),(0,tk.validateFunctionCode)(l),a.optimize(this.opts.code.optimize);const f=a.toString();d=`${a.scopeRefs(er.default.scope)}return ${f}`,this.opts.code.process&&(d=this.opts.code.process(d,e));const _=new Function(`${er.default.self}`,`${er.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:g,items:v}=l;_.evaluated={props:g instanceof yt.Name?void 0:g,items:v instanceof yt.Name?void 0:v,dynamicProps:g instanceof yt.Name,dynamicItems:v instanceof yt.Name},_.source&&(_.source.evaluated=(0,yt.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)}}at.compileSchema=Ai;function rk(e,t,r){var n;r=(0,St.resolveUrl)(this.opts.uriResolver,t,r);const s=e.refs[r];if(s)return s;let o=ok.call(this,e,r);if(o===void 0){const a=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:i}=this.opts;a&&(o=new Us({schema:a,schemaId:i,root:e,baseId:t}))}if(o!==void 0)return e.refs[r]=nk.call(this,o)}at.resolveRef=rk;function nk(e){return(0,St.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Ai.call(this,e)}function Cf(e){for(const t of this._compilations)if(sk(t,e))return t}at.getCompilingSchema=Cf;function sk(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function ok(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Fs.call(this,e,t)}function Fs(e,t){const r=this.opts.uriResolver.parse(t),n=(0,St._getFullPath)(this.opts.uriResolver,r);let s=(0,St.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===s)return eo.call(this,r,e);const o=(0,St.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){const i=Fs.call(this,e,a);return typeof(i==null?void 0:i.schema)!="object"?void 0:eo.call(this,r,i)}if(typeof(a==null?void 0:a.schema)=="object"){if(a.validate||Ai.call(this,a),o===(0,St.normalizeId)(t)){const{schema:i}=a,{schemaId:c}=this.opts,l=i[c];return l&&(s=(0,St.resolveUrl)(this.opts.uriResolver,s,l)),new Us({schema:i,schemaId:c,root:e,baseId:s})}return eo.call(this,r,a)}}at.resolveSchema=Fs;const ak=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function eo(e,{baseId:t,schema:r,root:n}){var s;if(((s=e.fragment)===null||s===void 0?void 0:s[0])!=="/")return;for(const i of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;const c=r[(0,El.unescapeFragment)(i)];if(c===void 0)return;r=c;const l=typeof r=="object"&&r[this.opts.schemaId];!ak.has(i)&&l&&(t=(0,St.resolveUrl)(this.opts.uriResolver,t,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,El.schemaHasRulesButRef)(r,this.RULES)){const i=(0,St.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=Fs.call(this,n,i)}const{schemaId:a}=this.opts;if(o=o||new Us({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}const ik="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",ck="Meta-schema for $data reference (JSON AnySchema extension proposal)",lk="object",uk=["$data"],dk={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},fk=!1,hk={$id:ik,description:ck,type:lk,required:uk,properties:dk,additionalProperties:fk};var Mi={};Object.defineProperty(Mi,"__esModule",{value:!0});const jf=Dd;jf.code='require("ajv/dist/runtime/uri").default';Mi.default=jf;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=Et;Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=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=jn,s=Ur,o=hr,a=at,i=he,c=We,l=De,d=B,f=hk,y=Mi,_=(O,w)=>new RegExp(O,w);_.code="new RegExp";const g=["removeAdditional","useDefaults","coerceTypes"],v=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),m={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},h={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},$=200;function k(O){var w,C,b,u,p,P,q,D,X,J,j,I,U,Z,ee,ce,xe,tt,Fe,Le,Ae,kt,Ye,Wt,Bt;const mt=O.strict,Jt=(w=O.code)===null||w===void 0?void 0:w.optimize,Vr=Jt===!0||Jt===void 0?1:Jt||0,Hr=(b=(C=O.code)===null||C===void 0?void 0:C.regExp)!==null&&b!==void 0?b:_,Hs=(u=O.uriResolver)!==null&&u!==void 0?u:y.default;return{strictSchema:(P=(p=O.strictSchema)!==null&&p!==void 0?p:mt)!==null&&P!==void 0?P:!0,strictNumbers:(D=(q=O.strictNumbers)!==null&&q!==void 0?q:mt)!==null&&D!==void 0?D:!0,strictTypes:(J=(X=O.strictTypes)!==null&&X!==void 0?X:mt)!==null&&J!==void 0?J:"log",strictTuples:(I=(j=O.strictTuples)!==null&&j!==void 0?j:mt)!==null&&I!==void 0?I:"log",strictRequired:(Z=(U=O.strictRequired)!==null&&U!==void 0?U:mt)!==null&&Z!==void 0?Z:!1,code:O.code?{...O.code,optimize:Vr,regExp:Hr}:{optimize:Vr,regExp:Hr},loopRequired:(ee=O.loopRequired)!==null&&ee!==void 0?ee:$,loopEnum:(ce=O.loopEnum)!==null&&ce!==void 0?ce:$,meta:(xe=O.meta)!==null&&xe!==void 0?xe:!0,messages:(tt=O.messages)!==null&&tt!==void 0?tt:!0,inlineRefs:(Fe=O.inlineRefs)!==null&&Fe!==void 0?Fe:!0,schemaId:(Le=O.schemaId)!==null&&Le!==void 0?Le:"$id",addUsedSchema:(Ae=O.addUsedSchema)!==null&&Ae!==void 0?Ae:!0,validateSchema:(kt=O.validateSchema)!==null&&kt!==void 0?kt:!0,validateFormats:(Ye=O.validateFormats)!==null&&Ye!==void 0?Ye:!0,unicodeRegExp:(Wt=O.unicodeRegExp)!==null&&Wt!==void 0?Wt:!0,int32range:(Bt=O.int32range)!==null&&Bt!==void 0?Bt:!0,uriResolver:Hs}}class T{constructor(w={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,w=this.opts={...w,...k(w)};const{es5:C,lines:b}=this.opts.code;this.scope=new i.ValueScope({scope:{},prefixes:v,es5:C,lines:b}),this.logger=Y(w.logger);const u=w.validateFormats;w.validateFormats=!1,this.RULES=(0,o.getRules)(),E.call(this,m,w,"NOT SUPPORTED"),E.call(this,h,w,"DEPRECATED","warn"),this._metaOpts=V.call(this),w.formats&&L.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),w.keywords&&G.call(this,w.keywords),typeof w.meta=="object"&&this.addMetaSchema(w.meta),M.call(this),w.validateFormats=u}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:w,meta:C,schemaId:b}=this.opts;let u=f;b==="id"&&(u={...f},u.id=u.$id,delete u.$id),C&&w&&this.addMetaSchema(u,u[b],!1)}defaultMeta(){const{meta:w,schemaId:C}=this.opts;return this.opts.defaultMeta=typeof w=="object"?w[C]||w:void 0}validate(w,C){let b;if(typeof w=="string"){if(b=this.getSchema(w),!b)throw new Error(`no schema with key or ref "${w}"`)}else b=this.compile(w);const u=b(C);return"$async"in b||(this.errors=b.errors),u}compile(w,C){const b=this._addSchema(w,C);return b.validate||this._compileSchemaEnv(b)}compileAsync(w,C){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:b}=this.opts;return u.call(this,w,C);async function u(J,j){await p.call(this,J.$schema);const I=this._addSchema(J,j);return I.validate||P.call(this,I)}async function p(J){J&&!this.getSchema(J)&&await u.call(this,{$ref:J},!0)}async function P(J){try{return this._compileSchemaEnv(J)}catch(j){if(!(j instanceof s.default))throw j;return q.call(this,j),await D.call(this,j.missingSchema),P.call(this,J)}}function q({missingSchema:J,missingRef:j}){if(this.refs[J])throw new Error(`AnySchema ${J} is loaded but ${j} cannot be resolved`)}async function D(J){const j=await X.call(this,J);this.refs[J]||await p.call(this,j.$schema),this.refs[J]||this.addSchema(j,J,C)}async function X(J){const j=this._loading[J];if(j)return j;try{return await(this._loading[J]=b(J))}finally{delete this._loading[J]}}}addSchema(w,C,b,u=this.opts.validateSchema){if(Array.isArray(w)){for(const P of w)this.addSchema(P,void 0,b,u);return this}let p;if(typeof w=="object"){const{schemaId:P}=this.opts;if(p=w[P],p!==void 0&&typeof p!="string")throw new Error(`schema ${P} must be string`)}return C=(0,c.normalizeId)(C||p),this._checkUnique(C),this.schemas[C]=this._addSchema(w,b,C,u,!0),this}addMetaSchema(w,C,b=this.opts.validateSchema){return this.addSchema(w,C,!0,b),this}validateSchema(w,C){if(typeof w=="boolean")return!0;let b;if(b=w.$schema,b!==void 0&&typeof b!="string")throw new Error("$schema must be a string");if(b=b||this.opts.defaultMeta||this.defaultMeta(),!b)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const u=this.validate(b,w);if(!u&&C){const p="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(p);else throw new Error(p)}return u}getSchema(w){let C;for(;typeof(C=x.call(this,w))=="string";)w=C;if(C===void 0){const{schemaId:b}=this.opts,u=new a.SchemaEnv({schema:{},schemaId:b});if(C=a.resolveSchema.call(this,u,w),!C)return;this.refs[w]=C}return C.validate||this._compileSchemaEnv(C)}removeSchema(w){if(w instanceof RegExp)return this._removeAllSchemas(this.schemas,w),this._removeAllSchemas(this.refs,w),this;switch(typeof w){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const C=x.call(this,w);return typeof C=="object"&&this._cache.delete(C.schema),delete this.schemas[w],delete this.refs[w],this}case"object":{const C=w;this._cache.delete(C);let b=w[this.opts.schemaId];return b&&(b=(0,c.normalizeId)(b),delete this.schemas[b],delete this.refs[b]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(w){for(const C of w)this.addKeyword(C);return this}addKeyword(w,C){let b;if(typeof w=="string")b=w,typeof C=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),C.keyword=b);else if(typeof w=="object"&&C===void 0){if(C=w,b=C.keyword,Array.isArray(b)&&!b.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(F.call(this,b,C),!C)return(0,d.eachItem)(b,p=>ie.call(this,p)),this;$e.call(this,C);const u={...C,type:(0,l.getJSONTypes)(C.type),schemaType:(0,l.getJSONTypes)(C.schemaType)};return(0,d.eachItem)(b,u.type.length===0?p=>ie.call(this,p,u):p=>u.type.forEach(P=>ie.call(this,p,u,P))),this}getKeyword(w){const C=this.RULES.all[w];return typeof C=="object"?C.definition:!!C}removeKeyword(w){const{RULES:C}=this;delete C.keywords[w],delete C.all[w];for(const b of C.rules){const u=b.rules.findIndex(p=>p.keyword===w);u>=0&&b.rules.splice(u,1)}return this}addFormat(w,C){return typeof C=="string"&&(C=new RegExp(C)),this.formats[w]=C,this}errorsText(w=this.errors,{separator:C=", ",dataVar:b="data"}={}){return!w||w.length===0?"No errors":w.map(u=>`${b}${u.instancePath} ${u.message}`).reduce((u,p)=>u+C+p)}$dataMetaSchema(w,C){const b=this.RULES.all;w=JSON.parse(JSON.stringify(w));for(const u of C){const p=u.split("/").slice(1);let P=w;for(const q of p)P=P[q];for(const q in b){const D=b[q];if(typeof D!="object")continue;const{$data:X}=D.definition,J=P[q];X&&J&&(P[q]=Oe(J))}}return w}_removeAllSchemas(w,C){for(const b in w){const u=w[b];(!C||C.test(b))&&(typeof u=="string"?delete w[b]:u&&!u.meta&&(this._cache.delete(u.schema),delete w[b]))}}_addSchema(w,C,b,u=this.opts.validateSchema,p=this.opts.addUsedSchema){let P;const{schemaId:q}=this.opts;if(typeof w=="object")P=w[q];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof w!="boolean")throw new Error("schema must be object or boolean")}let D=this._cache.get(w);if(D!==void 0)return D;b=(0,c.normalizeId)(P||b);const X=c.getSchemaRefs.call(this,w,b);return D=new a.SchemaEnv({schema:w,schemaId:q,meta:C,baseId:b,localRefs:X}),this._cache.set(D.schema,D),p&&!b.startsWith("#")&&(b&&this._checkUnique(b),this.refs[b]=D),u&&this.validateSchema(w,!0),D}_checkUnique(w){if(this.schemas[w]||this.refs[w])throw new Error(`schema with key or id "${w}" already exists`)}_compileSchemaEnv(w){if(w.meta?this._compileMetaSchema(w):a.compileSchema.call(this,w),!w.validate)throw new Error("ajv implementation error");return w.validate}_compileMetaSchema(w){const C=this.opts;this.opts=this._metaOpts;try{a.compileSchema.call(this,w)}finally{this.opts=C}}}T.ValidationError=n.default,T.MissingRefError=s.default,e.default=T;function E(O,w,C,b="error"){for(const u in O){const p=u;p in w&&this.logger[b](`${C}: option ${u}. ${O[p]}`)}}function x(O){return O=(0,c.normalizeId)(O),this.schemas[O]||this.refs[O]}function M(){const O=this.opts.schemas;if(O)if(Array.isArray(O))this.addSchema(O);else for(const w in O)this.addSchema(O[w],w)}function L(){for(const O in this.opts.formats){const w=this.opts.formats[O];w&&this.addFormat(O,w)}}function G(O){if(Array.isArray(O)){this.addVocabulary(O);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const w in O){const C=O[w];C.keyword||(C.keyword=w),this.addKeyword(C)}}function V(){const O={...this.opts};for(const w of g)delete O[w];return O}const K={log(){},warn(){},error(){}};function Y(O){if(O===!1)return K;if(O===void 0)return console;if(O.log&&O.warn&&O.error)return O;throw new Error("logger must implement log, warn and error methods")}const ne=/^[a-z_$][a-z0-9_$:-]*$/i;function F(O,w){const{RULES:C}=this;if((0,d.eachItem)(O,b=>{if(C.keywords[b])throw new Error(`Keyword ${b} is already defined`);if(!ne.test(b))throw new Error(`Keyword ${b} has invalid name`)}),!!w&&w.$data&&!("code"in w||"validate"in w))throw new Error('$data keyword must have "code" or "validate" function')}function ie(O,w,C){var b;const u=w==null?void 0:w.post;if(C&&u)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:p}=this;let P=u?p.post:p.rules.find(({type:D})=>D===C);if(P||(P={type:C,rules:[]},p.rules.push(P)),p.keywords[O]=!0,!w)return;const q={keyword:O,definition:{...w,type:(0,l.getJSONTypes)(w.type),schemaType:(0,l.getJSONTypes)(w.schemaType)}};w.before?ke.call(this,P,q,w.before):P.rules.push(q),p.all[O]=q,(b=w.implements)===null||b===void 0||b.forEach(D=>this.addKeyword(D))}function ke(O,w,C){const b=O.rules.findIndex(u=>u.keyword===C);b>=0?O.rules.splice(b,0,w):(O.rules.push(w),this.logger.warn(`rule ${C} is not defined`))}function $e(O){let{metaSchema:w}=O;w!==void 0&&(O.$data&&this.opts.$data&&(w=Oe(w)),O.validateSchema=this.compile(w,!0))}const ct={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Oe(O){return{anyOf:[O,ct]}}})(Qd);var zi={},qi={},Di={};Object.defineProperty(Di,"__esModule",{value:!0});const pk={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Di.default=pk;var pr={};Object.defineProperty(pr,"__esModule",{value:!0});pr.callRef=pr.getValidate=void 0;const mk=Ur,kl=me,st=he,vr=jt,Pl=at,Ln=B,gk={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=Pl.resolveRef.call(c,l,s,r);if(d===void 0)throw new mk.default(n.opts.uriResolver,s,r);if(d instanceof Pl.SchemaEnv)return y(d);return _(d);function f(){if(o===l)return ts(e,a,o,o.$async);const g=t.scopeValue("root",{ref:l});return ts(e,(0,st._)`${g}.validate`,l,l.$async)}function y(g){const v=Nf(e,g);ts(e,v,g,g.$async)}function _(g){const v=t.scopeValue("schema",i.code.source===!0?{ref:g,code:(0,st.stringify)(g)}:{ref:g}),m=t.name("valid"),h=e.subschema({schema:g,dataTypes:[],schemaPath:st.nil,topSchemaRef:v,errSchemaPath:r},m);e.mergeEvaluated(h),e.ok(m)}}};function Nf(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,st._)`${r.scopeValue("wrapper",{ref:t})}.validate`}pr.getValidate=Nf;function ts(e,t,r,n){const{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:c}=o,l=c.passContext?vr.default.this:st.nil;n?d():f();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");const g=s.let("valid");s.try(()=>{s.code((0,st._)`await ${(0,kl.callValidateCode)(e,t,l)}`),_(t),a||s.assign(g,!0)},v=>{s.if((0,st._)`!(${v} instanceof ${o.ValidationError})`,()=>s.throw(v)),y(v),a||s.assign(g,!1)}),e.ok(g)}function f(){e.result((0,kl.callValidateCode)(e,t,l),()=>_(t),()=>y(t))}function y(g){const v=(0,st._)`${g}.errors`;s.assign(vr.default.vErrors,(0,st._)`${vr.default.vErrors} === null ? ${v} : ${vr.default.vErrors}.concat(${v})`),s.assign(vr.default.errors,(0,st._)`${vr.default.vErrors}.length`)}function _(g){var v;if(!o.opts.unevaluated)return;const m=(v=r==null?void 0:r.validate)===null||v===void 0?void 0:v.evaluated;if(o.props!==!0)if(m&&!m.dynamicProps)m.props!==void 0&&(o.props=Ln.mergeEvaluated.props(s,m.props,o.props));else{const h=s.var("props",(0,st._)`${g}.evaluated.props`);o.props=Ln.mergeEvaluated.props(s,h,o.props,st.Name)}if(o.items!==!0)if(m&&!m.dynamicItems)m.items!==void 0&&(o.items=Ln.mergeEvaluated.items(s,m.items,o.items));else{const h=s.var("items",(0,st._)`${g}.evaluated.items`);o.items=Ln.mergeEvaluated.items(s,h,o.items,st.Name)}}}pr.callRef=ts;pr.default=gk;Object.defineProperty(qi,"__esModule",{value:!0});const _k=Di,yk=pr,vk=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",_k.default,yk.default];qi.default=vk;var Ui={},Fi={};Object.defineProperty(Fi,"__esModule",{value:!0});const _s=he,Dt=_s.operators,ys={maximum:{okStr:"<=",ok:Dt.LTE,fail:Dt.GT},minimum:{okStr:">=",ok:Dt.GTE,fail:Dt.LT},exclusiveMaximum:{okStr:"<",ok:Dt.LT,fail:Dt.GTE},exclusiveMinimum:{okStr:">",ok:Dt.GT,fail:Dt.LTE}},$k={message:({keyword:e,schemaCode:t})=>(0,_s.str)`must be ${ys[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,_s._)`{comparison: ${ys[e].okStr}, limit: ${t}}`},wk={keyword:Object.keys(ys),type:"number",schemaType:"number",$data:!0,error:$k,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,_s._)`${r} ${ys[t].fail} ${n} || isNaN(${r})`)}};Fi.default=wk;var Li={};Object.defineProperty(Li,"__esModule",{value:!0});const an=he,bk={message:({schemaCode:e})=>(0,an.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,an._)`{multipleOf: ${e}}`},Sk={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:bk,code(e){const{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0,an._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0,an._)`${a} !== parseInt(${a})`;e.fail$data((0,an._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};Li.default=Sk;var Vi={},Hi={};Object.defineProperty(Hi,"__esModule",{value:!0});function If(e){const t=e.length;let r=0,n=0,s;for(;n=55296&&s<=56319&&n(0,ar._)`{limit: ${e}}`},Rk={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:Pk,code(e){const{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?ar.operators.GT:ar.operators.LT,a=s.opts.unicode===!1?(0,ar._)`${r}.length`:(0,ar._)`${(0,Ek.useFunc)(e.gen,kk.default)}(${r})`;e.fail$data((0,ar._)`${a} ${o} ${n}`)}};Vi.default=Rk;var Zi={};Object.defineProperty(Zi,"__esModule",{value:!0});const Tk=me,Ck=B,Pr=he,jk={message:({schemaCode:e})=>(0,Pr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Pr._)`{pattern: ${e}}`},Nk={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:jk,code(e){const{gen:t,data:r,$data:n,schema:s,schemaCode:o,it:a}=e,i=a.opts.unicodeRegExp?"u":"";if(n){const{regExp:c}=a.opts.code,l=c.code==="new RegExp"?(0,Pr._)`new RegExp`:(0,Ck.useFunc)(t,c),d=t.let("valid");t.try(()=>t.assign(d,(0,Pr._)`${l}(${o}, ${i}).test(${r})`),()=>t.assign(d,!1)),e.fail$data((0,Pr._)`!${d}`)}else{const c=(0,Tk.usePattern)(e,s);e.fail$data((0,Pr._)`!${c}.test(${r})`)}}};Zi.default=Nk;var Ki={};Object.defineProperty(Ki,"__esModule",{value:!0});const cn=he,Ik={message({keyword:e,schemaCode:t}){const r=e==="maxProperties"?"more":"fewer";return(0,cn.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,cn._)`{limit: ${e}}`},Ok={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:Ik,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?cn.operators.GT:cn.operators.LT;e.fail$data((0,cn._)`Object.keys(${r}).length ${s} ${n}`)}};Ki.default=Ok;var Gi={};Object.defineProperty(Gi,"__esModule",{value:!0});const Br=me,ln=he,xk=B,Ak={message:({params:{missingProperty:e}})=>(0,ln.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,ln._)`{missingProperty: ${e}}`},Mk={keyword:"required",type:"object",schemaType:"array",$data:!0,error:Ak,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:g}=e.it;for(const v of r)if((_==null?void 0:_[v])===void 0&&!g.has(v)){const m=a.schemaEnv.baseId+a.errSchemaPath,h=`required property "${v}" is not defined at "${m}" (strictRequired)`;(0,xk.checkStrictMode)(a,h,a.opts.strictRequired)}}function l(){if(c||o)e.block$data(ln.nil,f);else for(const _ of r)(0,Br.checkReportMissingProp)(e,_)}function d(){const _=t.let("missing");if(c||o){const g=t.let("valid",!0);e.block$data(g,()=>y(_,g)),e.ok(g)}else t.if((0,Br.checkMissingProp)(e,r,_)),(0,Br.reportMissingProp)(e,_),t.else()}function f(){t.forOf("prop",n,_=>{e.setParams({missingProperty:_}),t.if((0,Br.noPropertyInData)(t,s,_,i.ownProperties),()=>e.error())})}function y(_,g){e.setParams({missingProperty:_}),t.forOf(_,n,()=>{t.assign(g,(0,Br.propertyInData)(t,s,_,i.ownProperties)),t.if((0,ln.not)(g),()=>{e.error(),t.break()})},ln.nil)}}};Gi.default=Mk;var Wi={};Object.defineProperty(Wi,"__esModule",{value:!0});const un=he,zk={message({keyword:e,schemaCode:t}){const r=e==="maxItems"?"more":"fewer";return(0,un.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,un._)`{limit: ${e}}`},qk={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:zk,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?un.operators.GT:un.operators.LT;e.fail$data((0,un._)`${r}.length ${s} ${n}`)}};Wi.default=qk;var Bi={},Nn={};Object.defineProperty(Nn,"__esModule",{value:!0});const Of=Is;Of.code='require("ajv/dist/runtime/equal").default';Nn.default=Of;Object.defineProperty(Bi,"__esModule",{value:!0});const to=De,Ze=he,Dk=B,Uk=Nn,Fk={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}}`},Lk={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:Fk,code(e){const{gen:t,data:r,$data:n,schema:s,parentSchema:o,schemaCode:a,it:i}=e;if(!n&&!s)return;const c=t.let("valid"),l=o.items?(0,to.getSchemaTypes)(o.items):[];e.block$data(c,d,(0,Ze._)`${a} === false`),e.ok(c);function d(){const g=t.let("i",(0,Ze._)`${r}.length`),v=t.let("j");e.setParams({i:g,j:v}),t.assign(c,!0),t.if((0,Ze._)`${g} > 1`,()=>(f()?y:_)(g,v))}function f(){return l.length>0&&!l.some(g=>g==="object"||g==="array")}function y(g,v){const m=t.name("item"),h=(0,to.checkDataTypes)(l,m,i.opts.strictNumbers,to.DataType.Wrong),$=t.const("indices",(0,Ze._)`{}`);t.for((0,Ze._)`;${g}--;`,()=>{t.let(m,(0,Ze._)`${r}[${g}]`),t.if(h,(0,Ze._)`continue`),l.length>1&&t.if((0,Ze._)`typeof ${m} == "string"`,(0,Ze._)`${m} += "_"`),t.if((0,Ze._)`typeof ${$}[${m}] == "number"`,()=>{t.assign(v,(0,Ze._)`${$}[${m}]`),e.error(),t.assign(c,!1).break()}).code((0,Ze._)`${$}[${m}] = ${g}`)})}function _(g,v){const m=(0,Dk.useFunc)(t,Uk.default),h=t.name("outer");t.label(h).for((0,Ze._)`;${g}--;`,()=>t.for((0,Ze._)`${v} = ${g}; ${v}--;`,()=>t.if((0,Ze._)`${m}(${r}[${g}], ${r}[${v}])`,()=>{e.error(),t.assign(c,!1).break(h)})))}}};Bi.default=Lk;var Ji={};Object.defineProperty(Ji,"__esModule",{value:!0});const Io=he,Vk=B,Hk=Nn,Zk={message:"must be equal to constant",params:({schemaCode:e})=>(0,Io._)`{allowedValue: ${e}}`},Kk={keyword:"const",$data:!0,error:Zk,code(e){const{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,Io._)`!${(0,Vk.useFunc)(t,Hk.default)}(${r}, ${s})`):e.fail((0,Io._)`${o} !== ${r}`)}};Ji.default=Kk;var Qi={};Object.defineProperty(Qi,"__esModule",{value:!0});const Xr=he,Gk=B,Wk=Nn,Bk={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,Xr._)`{allowedValues: ${e}}`},Jk={keyword:"enum",schemaType:"array",$data:!0,error:Bk,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,Gk.useFunc)(t,Wk.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,Xr.or)(...s.map((g,v)=>y(_,v)))}e.pass(d);function f(){t.assign(d,!1),t.forOf("v",o,_=>t.if((0,Xr._)`${l()}(${r}, ${_})`,()=>t.assign(d,!0).break()))}function y(_,g){const v=s[g];return typeof v=="object"&&v!==null?(0,Xr._)`${l()}(${r}, ${_}[${g}])`:(0,Xr._)`${r} === ${v}`}}};Qi.default=Jk;Object.defineProperty(Ui,"__esModule",{value:!0});const Qk=Fi,Yk=Li,Xk=Vi,eP=Zi,tP=Ki,rP=Gi,nP=Wi,sP=Bi,oP=Ji,aP=Qi,iP=[Qk.default,Yk.default,Xk.default,eP.default,tP.default,rP.default,nP.default,sP.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},oP.default,aP.default];Ui.default=iP;var Yi={},Fr={};Object.defineProperty(Fr,"__esModule",{value:!0});Fr.validateAdditionalItems=void 0;const ir=he,Oo=B,cP={message:({params:{len:e}})=>(0,ir.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,ir._)`{limit: ${e}}`},lP={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:cP,code(e){const{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Oo.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}xf(e,n)}};function xf(e,t){const{gen:r,schema:n,data:s,keyword:o,it:a}=e;a.items=!0;const i=r.const("len",(0,ir._)`${s}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,ir._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0,Oo.alwaysValidSchema)(a,n)){const l=r.var("valid",(0,ir._)`${i} <= ${t.length}`);r.if((0,ir.not)(l),()=>c(l)),e.ok(l)}function c(l){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:Oo.Type.Num},l),a.allErrors||r.if((0,ir.not)(l),()=>r.break())})}}Fr.validateAdditionalItems=xf;Fr.default=lP;var Xi={},Lr={};Object.defineProperty(Lr,"__esModule",{value:!0});Lr.validateTuple=void 0;const Rl=he,rs=B,uP=me,dP={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return Af(e,"additionalItems",t);r.items=!0,!(0,rs.alwaysValidSchema)(r,t)&&e.ok((0,uP.validateArray)(e))}};function Af(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=rs.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),l=n.const("len",(0,Rl._)`${o}.length`);r.forEach((f,y)=>{(0,rs.alwaysValidSchema)(i,f)||(n.if((0,Rl._)`${l} > ${y}`,()=>e.subschema({keyword:a,schemaProp:y,dataProp:y},c)),e.ok(c))});function d(f){const{opts:y,errSchemaPath:_}=i,g=r.length,v=g===f.minItems&&(g===f.maxItems||f[t]===!1);if(y.strictTuples&&!v){const m=`"${a}" is ${g}-tuple, but minItems or maxItems/${t} are not specified or different at path "${_}"`;(0,rs.checkStrictMode)(i,m,y.strictTuples)}}}Lr.validateTuple=Af;Lr.default=dP;Object.defineProperty(Xi,"__esModule",{value:!0});const fP=Lr,hP={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,fP.validateTuple)(e,"items")};Xi.default=hP;var ec={};Object.defineProperty(ec,"__esModule",{value:!0});const Tl=he,pP=B,mP=me,gP=Fr,_P={message:({params:{len:e}})=>(0,Tl.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Tl._)`{limit: ${e}}`},yP={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:_P,code(e){const{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=!0,!(0,pP.alwaysValidSchema)(n,t)&&(s?(0,gP.validateAdditionalItems)(e,s):e.ok((0,mP.validateArray)(e)))}};ec.default=yP;var tc={};Object.defineProperty(tc,"__esModule",{value:!0});const ft=he,Vn=B,vP={message:({params:{min:e,max:t}})=>t===void 0?(0,ft.str)`must contain at least ${e} valid item(s)`:(0,ft.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,ft._)`{minContains: ${e}}`:(0,ft._)`{minContains: ${e}, maxContains: ${t}}`},$P={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:vP,code(e){const{gen:t,schema:r,parentSchema:n,data:s,it:o}=e;let a,i;const{minContains:c,maxContains:l}=n;o.opts.next?(a=c===void 0?1:c,i=l):a=1;const d=t.const("len",(0,ft._)`${s}.length`);if(e.setParams({min:a,max:i}),i===void 0&&a===0){(0,Vn.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0,Vn.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Vn.alwaysValidSchema)(o,r)){let v=(0,ft._)`${d} >= ${a}`;i!==void 0&&(v=(0,ft._)`${v} && ${d} <= ${i}`),e.pass(v);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,ft._)`${s}.length > 0`,y)):(t.let(f,!1),y()),e.result(f,()=>e.reset());function y(){const v=t.name("_valid"),m=t.let("count",0);_(v,()=>t.if(v,()=>g(m)))}function _(v,m){t.forRange("i",0,d,h=>{e.subschema({keyword:"contains",dataProp:h,dataPropType:Vn.Type.Num,compositeRule:!0},v),m()})}function g(v){t.code((0,ft._)`${v}++`),i===void 0?t.if((0,ft._)`${v} >= ${a}`,()=>t.assign(f,!0).break()):(t.if((0,ft._)`${v} > ${i}`,()=>t.assign(f,!1).break()),a===1?t.assign(f,!0):t.if((0,ft._)`${v} >= ${a}`,()=>t.assign(f,!0)))}}};tc.default=$P;var Mf={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=he,r=B,n=me;e.error={message:({params:{property:c,depsCount:l,deps:d}})=>{const f=l===1?"property":"properties";return(0,t.str)`must have ${f} ${d} when property ${c} is present`},params:({params:{property:c,depsCount:l,deps:d,missingProperty:f}})=>(0,t._)`{property: ${c}, - missingProperty: ${f}, - depsCount: ${l}, - deps: ${d}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(c){const[l,d]=o(c);a(c,l),i(c,d)}};function o({schema:c}){const l={},d={};for(const f in c){if(f==="__proto__")continue;const y=Array.isArray(c[f])?l:d;y[f]=c[f]}return[l,d]}function a(c,l=c.schema){const{gen:d,data:f,it:y}=c;if(Object.keys(l).length===0)return;const _=d.let("missing");for(const g in l){const v=l[g];if(v.length===0)continue;const m=(0,n.propertyInData)(d,f,g,y.opts.ownProperties);c.setParams({property:g,depsCount:v.length,deps:v.join(", ")}),y.allErrors?d.if(m,()=>{for(const h of v)(0,n.checkReportMissingProp)(c,h)}):(d.if((0,t._)`${m} && (${(0,n.checkMissingProp)(c,v,_)})`),(0,n.reportMissingProp)(c,_),d.else())}}e.validatePropertyDeps=a;function i(c,l=c.schema){const{gen:d,data:f,keyword:y,it:_}=c,g=d.name("valid");for(const v in l)(0,r.alwaysValidSchema)(_,l[v])||(d.if((0,n.propertyInData)(d,f,v,_.opts.ownProperties),()=>{const m=c.subschema({keyword:y,schemaProp:v},g);c.mergeValidEvaluated(m,g)},()=>d.var(g,!0)),c.ok(g))}e.validateSchemaDeps=i,e.default=s})(Mf);var rc={};Object.defineProperty(rc,"__esModule",{value:!0});const zf=he,wP=B,bP={message:"property name must be valid",params:({params:e})=>(0,zf._)`{propertyName: ${e.propertyName}}`},SP={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:bP,code(e){const{gen:t,schema:r,data:n,it:s}=e;if((0,wP.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,zf.not)(o),()=>{e.error(!0),s.allErrors||t.break()})}),e.ok(o)}};rc.default=SP;var Ls={};Object.defineProperty(Ls,"__esModule",{value:!0});const Hn=me,$t=he,EP=jt,Zn=B,kP={message:"must NOT have additional properties",params:({params:e})=>(0,$t._)`{additionalProperty: ${e.additionalProperty}}`},PP={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:kP,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,Zn.alwaysValidSchema)(a,r))return;const l=(0,Hn.allSchemaProperties)(n.properties),d=(0,Hn.allSchemaProperties)(n.patternProperties);f(),e.ok((0,$t._)`${o} === ${EP.default.errors}`);function f(){t.forIn("key",s,m=>{!l.length&&!d.length?g(m):t.if(y(m),()=>g(m))})}function y(m){let h;if(l.length>8){const $=(0,Zn.schemaRefOrVal)(a,n.properties,"properties");h=(0,Hn.isOwnProperty)(t,$,m)}else l.length?h=(0,$t.or)(...l.map($=>(0,$t._)`${m} === ${$}`)):h=$t.nil;return d.length&&(h=(0,$t.or)(h,...d.map($=>(0,$t._)`${(0,Hn.usePattern)(e,$)}.test(${m})`))),(0,$t.not)(h)}function _(m){t.code((0,$t._)`delete ${s}[${m}]`)}function g(m){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){_(m);return}if(r===!1){e.setParams({additionalProperty:m}),e.error(),i||t.break();return}if(typeof r=="object"&&!(0,Zn.alwaysValidSchema)(a,r)){const h=t.name("valid");c.removeAdditional==="failing"?(v(m,h,!1),t.if((0,$t.not)(h),()=>{e.reset(),_(m)})):(v(m,h),i||t.if((0,$t.not)(h),()=>t.break()))}}function v(m,h,$){const k={keyword:"additionalProperties",dataProp:m,dataPropType:Zn.Type.Str};$===!1&&Object.assign(k,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(k,h)}}};Ls.default=PP;var nc={};Object.defineProperty(nc,"__esModule",{value:!0});const RP=Et,Cl=me,ro=B,jl=Ls,TP={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&&jl.default.code(new RP.KeywordCxt(o,jl.default,"additionalProperties"));const a=(0,Cl.allSchemaProperties)(r);for(const f of a)o.definedProperties.add(f);o.opts.unevaluated&&a.length&&o.props!==!0&&(o.props=ro.mergeEvaluated.props(t,(0,ro.toHash)(a),o.props));const i=a.filter(f=>!(0,ro.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,Cl.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)}}};nc.default=TP;var sc={};Object.defineProperty(sc,"__esModule",{value:!0});const Nl=me,Kn=he,Il=B,Ol=B,CP={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,Nl.allSchemaProperties)(r),c=i.filter(v=>(0,Il.alwaysValidSchema)(o,r[v]));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 Kn.Name)&&(o.props=(0,Ol.evaluatedPropsToName)(t,o.props));const{props:f}=o;y();function y(){for(const v of i)l&&_(v),o.allErrors?g(v):(t.var(d,!0),g(v),t.if(d))}function _(v){for(const m in l)new RegExp(v).test(m)&&(0,Il.checkStrictMode)(o,`property ${m} matches pattern ${v} (use allowMatchingProperties)`)}function g(v){t.forIn("key",n,m=>{t.if((0,Kn._)`${(0,Nl.usePattern)(e,v)}.test(${m})`,()=>{const h=c.includes(v);h||e.subschema({keyword:"patternProperties",schemaProp:v,dataProp:m,dataPropType:Ol.Type.Str},d),o.opts.unevaluated&&f!==!0?t.assign((0,Kn._)`${f}[${m}]`,!0):!h&&!o.allErrors&&t.if((0,Kn.not)(d),()=>t.break())})})}}};sc.default=CP;var oc={};Object.defineProperty(oc,"__esModule",{value:!0});const jP=B,NP={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,jP.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"}};oc.default=NP;var ac={};Object.defineProperty(ac,"__esModule",{value:!0});const IP=me,OP={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:IP.validateUnion,error:{message:"must match a schema in anyOf"}};ac.default=OP;var ic={};Object.defineProperty(ic,"__esModule",{value:!0});const ns=he,xP=B,AP={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,ns._)`{passingSchemas: ${e.passing}}`},MP={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:AP,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 y;(0,xP.alwaysValidSchema)(s,d)?t.var(c,!0):y=e.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},c),f>0&&t.if((0,ns._)`${c} && ${a}`).assign(a,!1).assign(i,(0,ns._)`[${i}, ${f}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,f),y&&e.mergeEvaluated(y,ns.Name)})})}}};ic.default=MP;var cc={};Object.defineProperty(cc,"__esModule",{value:!0});const zP=B,qP={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,zP.alwaysValidSchema)(n,o))return;const i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i)})}};cc.default=qP;var lc={};Object.defineProperty(lc,"__esModule",{value:!0});const vs=he,qf=B,DP={message:({params:e})=>(0,vs.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,vs._)`{failingKeyword: ${e.ifClause}}`},UP={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:DP,code(e){const{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,qf.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const s=xl(n,"then"),o=xl(n,"else");if(!s&&!o)return;const a=t.let("valid",!0),i=t.name("_valid");if(c(),e.reset(),s&&o){const d=t.let("ifClause");e.setParams({ifClause:d}),t.if(i,l("then",d),l("else",d))}else s?t.if(i,l("then")):t.if((0,vs.not)(i),l("else"));e.pass(a,()=>e.error(!0));function c(){const d=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},i);e.mergeEvaluated(d)}function l(d,f){return()=>{const y=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(y,a),f?t.assign(f,(0,vs._)`${d}`):e.setParams({ifClause:d})}}}};function xl(e,t){const r=e.schema[t];return r!==void 0&&!(0,qf.alwaysValidSchema)(e,r)}lc.default=UP;var uc={};Object.defineProperty(uc,"__esModule",{value:!0});const FP=B,LP={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,FP.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};uc.default=LP;Object.defineProperty(Yi,"__esModule",{value:!0});const VP=Fr,HP=Xi,ZP=Lr,KP=ec,GP=tc,WP=Mf,BP=rc,JP=Ls,QP=nc,YP=sc,XP=oc,e1=ac,t1=ic,r1=cc,n1=lc,s1=uc;function o1(e=!1){const t=[XP.default,e1.default,t1.default,r1.default,n1.default,s1.default,BP.default,JP.default,WP.default,QP.default,YP.default];return e?t.push(HP.default,KP.default):t.push(VP.default,ZP.default),t.push(GP.default),t}Yi.default=o1;var dc={},fc={};Object.defineProperty(fc,"__esModule",{value:!0});const ze=he,a1={message:({schemaCode:e})=>(0,ze.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,ze._)`{format: ${e}}`},i1={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:a1,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?y():_();function y(){const g=r.scopeValue("formats",{ref:f.formats,code:c.code.formats}),v=r.const("fDef",(0,ze._)`${g}[${a}]`),m=r.let("fType"),h=r.let("format");r.if((0,ze._)`typeof ${v} == "object" && !(${v} instanceof RegExp)`,()=>r.assign(m,(0,ze._)`${v}.type || "string"`).assign(h,(0,ze._)`${v}.validate`),()=>r.assign(m,(0,ze._)`"string"`).assign(h,v)),e.fail$data((0,ze.or)($(),k()));function $(){return c.strictSchema===!1?ze.nil:(0,ze._)`${a} && !${h}`}function k(){const T=d.$async?(0,ze._)`(${v}.async ? await ${h}(${n}) : ${h}(${n}))`:(0,ze._)`${h}(${n})`,E=(0,ze._)`(typeof ${h} == "function" ? ${T} : ${h}.test(${n}))`;return(0,ze._)`${h} && ${h} !== true && ${m} === ${t} && !${E}`}}function _(){const g=f.formats[o];if(!g){$();return}if(g===!0)return;const[v,m,h]=k(g);v===t&&e.pass(T());function $(){if(c.strictSchema===!1){f.logger.warn(E());return}throw new Error(E());function E(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function k(E){const x=E instanceof RegExp?(0,ze.regexpCode)(E):c.code.formats?(0,ze._)`${c.code.formats}${(0,ze.getProperty)(o)}`:void 0,M=r.scopeValue("formats",{key:o,ref:E,code:x});return typeof E=="object"&&!(E instanceof RegExp)?[E.type||"string",E.validate,(0,ze._)`${M}.validate`]:["string",E,M]}function T(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!d.$async)throw new Error("async format in sync schema");return(0,ze._)`await ${h}(${n})`}return typeof m=="function"?(0,ze._)`${h}(${n})`:(0,ze._)`${h}.test(${n})`}}}};fc.default=i1;Object.defineProperty(dc,"__esModule",{value:!0});const c1=fc,l1=[c1.default];dc.default=l1;var xr={};Object.defineProperty(xr,"__esModule",{value:!0});xr.contentVocabulary=xr.metadataVocabulary=void 0;xr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];xr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(zi,"__esModule",{value:!0});const u1=qi,d1=Ui,f1=Yi,h1=dc,Al=xr,p1=[u1.default,d1.default,(0,f1.default)(),h1.default,Al.metadataVocabulary,Al.contentVocabulary];zi.default=p1;var hc={},Vs={};Object.defineProperty(Vs,"__esModule",{value:!0});Vs.DiscrError=void 0;var Ml;(function(e){e.Tag="tag",e.Mapping="mapping"})(Ml||(Vs.DiscrError=Ml={}));Object.defineProperty(hc,"__esModule",{value:!0});const Sr=he,xo=Vs,zl=at,m1=Ur,g1=B,_1={message:({params:{discrError:e,tagName:t}})=>e===xo.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Sr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},y1={keyword:"discriminator",type:"object",schemaType:"object",error:_1,code(e){const{gen:t,data:r,schema:n,parentSchema:s,it:o}=e,{oneOf:a}=s;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");const i=n.propertyName;if(typeof i!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!a)throw new Error("discriminator: requires oneOf keyword");const c=t.let("valid",!1),l=t.const("tag",(0,Sr._)`${r}${(0,Sr.getProperty)(i)}`);t.if((0,Sr._)`typeof ${l} == "string"`,()=>d(),()=>e.error(!1,{discrError:xo.DiscrError.Tag,tag:l,tagName:i})),e.ok(c);function d(){const _=y();t.if(!1);for(const g in _)t.elseIf((0,Sr._)`${l} === ${g}`),t.assign(c,f(_[g]));t.else(),e.error(!1,{discrError:xo.DiscrError.Mapping,tag:l,tagName:i}),t.endIf()}function f(_){const g=t.name("valid"),v=e.subschema({keyword:"oneOf",schemaProp:_},g);return e.mergeEvaluated(v,Sr.Name),g}function y(){var _;const g={},v=h(s);let m=!0;for(let T=0;Tthis.addVocabulary(g)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const g=this.opts.$data?this.$dataMetaSchema(o,a):o;this.addMetaSchema(g,i,!1),this.refs["http://json-schema.org/schema"]=i}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(i)?i:void 0)}}t.Ajv=c,e.exports=t=c,e.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var l=Et;Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var d=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=jn;Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return f.default}});var y=Ur;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return y.default}})})(Ro,Ro.exports);var P1=Ro.exports;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;const t=P1,r=he,n=r.operators,s={formatMaximum:{okStr:"<=",ok:n.LTE,fail:n.GT},formatMinimum:{okStr:">=",ok:n.GTE,fail:n.LT},formatExclusiveMaximum:{okStr:"<",ok:n.LT,fail:n.GTE},formatExclusiveMinimum:{okStr:">",ok:n.GT,fail:n.LTE}},o={message:({keyword:i,schemaCode:c})=>(0,r.str)`should be ${s[i].okStr} ${c}`,params:({keyword:i,schemaCode:c})=>(0,r._)`{comparison: ${s[i].okStr}, limit: ${c}}`};e.formatLimitDefinition={keyword:Object.keys(s),type:"string",schemaType:"string",$data:!0,error:o,code(i){const{gen:c,data:l,schemaCode:d,keyword:f,it:y}=i,{opts:_,self:g}=y;if(!_.validateFormats)return;const v=new t.KeywordCxt(y,g.RULES.all.format.definition,"format");v.$data?m():h();function m(){const k=c.scopeValue("formats",{ref:g.formats,code:_.code.formats}),T=c.const("fmt",(0,r._)`${k}[${v.schemaCode}]`);i.fail$data((0,r.or)((0,r._)`typeof ${T} != "object"`,(0,r._)`${T} instanceof RegExp`,(0,r._)`typeof ${T}.compare != "function"`,$(T)))}function h(){const k=v.schema,T=g.formats[k];if(!T||T===!0)return;if(typeof T!="object"||T instanceof RegExp||typeof T.compare!="function")throw new Error(`"${f}": format "${k}" does not define "compare" function`);const E=c.scopeValue("formats",{key:k,ref:T,code:_.code.formats?(0,r._)`${_.code.formats}${(0,r.getProperty)(k)}`:void 0});i.fail$data($(E))}function $(k){return(0,r._)`${k}.compare(${l}, ${d}) ${s[f].fail} 0`}},dependencies:["format"]};const a=i=>(i.addKeyword(e.formatLimitDefinition),i);e.default=a})(Jd);(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r=Bd,n=Jd,s=he,o=new s.Name("fullFormats"),a=new s.Name("fastFormats"),i=(l,d={keywords:!0})=>{if(Array.isArray(d))return c(l,d,r.fullFormats,o),l;const[f,y]=d.mode==="fast"?[r.fastFormats,a]:[r.fullFormats,o],_=d.formats||r.formatNames;return c(l,_,f,y),d.keywords&&(0,n.default)(l),l};i.get=(l,d="full")=>{const y=(d==="fast"?r.fastFormats:r.fullFormats)[l];if(!y)throw new Error(`Unknown format "${l}"`);return y};function c(l,d,f,y){var _,g;(_=(g=l.opts.code).formats)!==null&&_!==void 0||(g.formats=(0,s._)`require("ajv-formats/dist/formats").${y}`);for(const v of d)l.addFormat(v,f[v])}e.exports=t=i,Object.defineProperty(t,"__esModule",{value:!0}),t.default=i})(Po,Po.exports);var R1=Po.exports;const T1=Gl(R1);function C1(){const e=new pS({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return T1(e),e}class j1{constructor(t){this._ajv=t??C1()}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 N1{constructor(t){this._client=t}async*callToolStream(t,r=lr,n){const s=this._client,o={...n,task:(n==null?void 0:n.task)??(s.isToolTask(t.name)?{}:void 0)},a=s.requestStream({method:"tools/call",params:t},r,o),i=s.getToolOutputValidator(t.name);for await(const c of a){if(c.type==="result"&&i){const l=c.result;if(!l.structuredContent&&!l.isError){yield{type:"error",error:new se(ae.InvalidRequest,`Tool ${t.name} has an output schema but did not return structured content`)};return}if(l.structuredContent)try{const d=i(l.structuredContent);if(!d.valid){yield{type:"error",error:new se(ae.InvalidParams,`Structured content does not match the tool's output schema: ${d.errorMessage}`)};return}}catch(d){if(d instanceof se){yield{type:"error",error:d};return}yield{type:"error",error:new se(ae.InvalidParams,`Failed to validate structured content: ${d instanceof Error?d.message:String(d)}`)};return}}yield c}}async getTask(t,r){return this._client.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._client.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._client.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._client.cancelTask({taskId:t},r)}requestStream(t,r,n){return this._client.requestStream(t,r,n)}}function I1(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 O1(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 ss(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&&ss(o,r[s])}}if(Array.isArray(e.anyOf))for(const r of e.anyOf)typeof r!="boolean"&&ss(r,t);if(Array.isArray(e.oneOf))for(const r of e.oneOf)typeof r!="boolean"&&ss(r,t)}}function x1(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 A1 extends od{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 j1,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",Na,t.tools,async()=>(await this.listTools()).tools),t.prompts&&((o=(s=this._serverCapabilities)==null?void 0:s.prompts)!=null&&o.listChanged)&&this._setupListChangedHandler("prompts",Ta,t.prompts,async()=>(await this.listPrompts()).prompts),t.resources&&((i=(a=this._serverCapabilities)==null?void 0:a.resources)!=null&&i.listChanged)&&this._setupListChangedHandler("resources",Sa,t.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new N1(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=yv(this._capabilities,t)}setRequestHandler(t,r){const n=nd(t),s=n==null?void 0:n.method;if(!s)throw new Error("Schema is missing a method literal");const o=sd(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 $,k;const d=Ut(ed,c);if(!d.success){const T=d.error instanceof Error?d.error.message:String(d.error);throw new se(ae.InvalidParams,`Invalid elicitation request: ${T}`)}const{params:f}=d.data;f.mode=f.mode??"form";const{supportsFormMode:y,supportsUrlMode:_}=x1(this._capabilities.elicitation);if(f.mode==="form"&&!y)throw new se(ae.InvalidParams,"Client does not support form-mode elicitation requests");if(f.mode==="url"&&!_)throw new se(ae.InvalidParams,"Client does not support URL-mode elicitation requests");const g=await Promise.resolve(r(c,l));if(f.task){const T=Ut(hn,g);if(!T.success){const E=T.error instanceof Error?T.error.message:String(T.error);throw new se(ae.InvalidParams,`Invalid task creation result: ${E}`)}return T.data}const v=Ut(td,g);if(!v.success){const T=v.error instanceof Error?v.error.message:String(v.error);throw new se(ae.InvalidParams,`Invalid elicitation result: ${T}`)}const m=v.data,h=f.mode==="form"?f.requestedSchema:void 0;if(f.mode==="form"&&m.action==="accept"&&m.content&&h&&(k=($=this._capabilities.elicitation)==null?void 0:$.form)!=null&&k.applyDefaults)try{ss(h,m.content)}catch{}return m};return super.setRequestHandler(t,i)}if(a==="sampling/createMessage"){const i=async(c,l)=>{const d=Ut(Ia,c);if(!d.success){const m=d.error instanceof Error?d.error.message:String(d.error);throw new se(ae.InvalidParams,`Invalid sampling request: ${m}`)}const{params:f}=d.data,y=await Promise.resolve(r(c,l));if(f.task){const m=Ut(hn,y);if(!m.success){const h=m.error instanceof Error?m.error.message:String(m.error);throw new se(ae.InvalidParams,`Invalid task creation result: ${h}`)}return m.data}const g=f.tools||f.toolChoice?Xu:Yu,v=Ut(g,y);if(!v.success){const m=v.error instanceof Error?v.error.message:String(v.error);throw new se(ae.InvalidParams,`Invalid sampling result: ${m}`)}return v.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:Ts,capabilities:this._capabilities,clientInfo:this._clientInfo}},Mu,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!G_.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;I1((n=(r=this._serverCapabilities)==null?void 0:r.tasks)==null?void 0:n.requests,t,"Server")}assertTaskHandlerCapability(t){var r;this._capabilities&&O1((r=this._capabilities.tasks)==null?void 0:r.requests,t,"Client")}async ping(t){return this.request({method:"ping"},Er,t)}async complete(t,r){return this.request({method:"completion/complete",params:t},rd,r)}async setLoggingLevel(t,r){return this.request({method:"logging/setLevel",params:{level:t}},Er,r)}async getPrompt(t,r){return this.request({method:"prompts/get",params:t},Wu,r)}async listPrompts(t,r){return this.request({method:"prompts/list",params:t},Ea,r)}async listResources(t,r){return this.request({method:"resources/list",params:t},va,r)}async listResourceTemplates(t,r){return this.request({method:"resources/templates/list",params:t},$a,r)}async readResource(t,r){return this.request({method:"resources/read",params:t},ba,r)}async subscribeResource(t,r){return this.request({method:"resources/subscribe",params:t},Er,r)}async unsubscribeResource(t,r){return this.request({method:"resources/unsubscribe",params:t},Er,r)}async callTool(t,r=lr,n){if(this.isToolTaskRequired(t.name))throw new se(ae.InvalidRequest,`Tool "${t.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);const s=await this.request({method:"tools/call",params:t},r,n),o=this.getToolOutputValidator(t.name);if(o){if(!s.structuredContent&&!s.isError)throw new se(ae.InvalidRequest,`Tool ${t.name} has an output schema but did not return structured content`);if(s.structuredContent)try{const a=o(s.structuredContent);if(!a.valid)throw new se(ae.InvalidParams,`Structured content does not match the tool's output schema: ${a.errorMessage}`)}catch(a){throw a instanceof se?a:new se(ae.InvalidParams,`Failed to validate structured content: ${a instanceof Error?a.message:String(a)}`)}}return s}isToolTask(t){var r,n,s,o;return(o=(s=(n=(r=this._serverCapabilities)==null?void 0:r.tasks)==null?void 0:n.requests)==null?void 0:s.tools)!=null&&o.call?this._cachedKnownTaskTools.has(t):!1}isToolTaskRequired(t){return this._cachedRequiredTaskTools.has(t)}cacheToolMetadata(t){var r;this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(const n of t){if(n.outputSchema){const o=this._jsonSchemaValidator.getValidator(n.outputSchema);this._cachedToolOutputValidators.set(n.name,o)}const s=(r=n.execution)==null?void 0:r.taskSupport;(s==="required"||s==="optional")&&this._cachedKnownTaskTools.add(n.name),s==="required"&&this._cachedRequiredTaskTools.add(n.name)}}getToolOutputValidator(t){return this._cachedToolOutputValidators.get(t)}async listTools(t,r){const n=await this.request({method:"tools/list",params:t},ja,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(t,r,n,s){const o=xy.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 y=f instanceof Error?f:new Error(String(f));c(y,null)}},d=()=>{if(i){const f=this._listChangedDebounceTimers.get(t);f&&clearTimeout(f);const y=setTimeout(l,i);this._listChangedDebounceTimers.set(t,y)}else l()};this.setNotificationHandler(r,d)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}var pc={};/*! - * content-type - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - */var ql=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,M1=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,Df=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,z1=/\\([\u000b\u0020-\u00ff])/g,q1=/([\\"])/g,Uf=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;pc.format=D1;pc.parse=U1;function D1(e){if(!e||typeof e!="object")throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!Uf.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&&!M1.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(q1,"\\$1")+'"'}function V1(e){this.parameters=Object.create(null),this.type=e}function H1(e){if(e)try{return pc.parse(e).type}catch{const t=(e.split(";",1)[0]??"").trim().toLowerCase();return t===""||e.slice(t.length).includes(",")?void 0:t}}function Ao(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function Z1(e=fetch,t){return t?async(r,n)=>{const s={...t,...n,headers:n!=null&&n.headers?{...Ao(t.headers),...Ao(n.headers)}:t.headers};return e(r,s)}:e}let mc;mc=globalThis.crypto;async function K1(e){return(await mc).getRandomValues(new Uint8Array(e))}async function G1(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 W1(e),r=await B1(t);return{code_verifier:t,code_challenge:r}}const Ke=e_().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:Z_.custom,message:"URL must be parseable",fatal:!0}),Lh}).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"}),Q1=Be({resource:R().url(),authorization_servers:H(Ke).optional(),jwks_uri:R().url().optional(),scopes_supported:H(R()).optional(),bearer_methods_supported:H(R()).optional(),resource_signing_alg_values_supported:H(R()).optional(),resource_name:R().optional(),resource_documentation:R().optional(),resource_policy_uri:R().url().optional(),resource_tos_uri:R().url().optional(),tls_client_certificate_bound_access_tokens:ye().optional(),authorization_details_types_supported:H(R()).optional(),dpop_signing_alg_values_supported:H(R()).optional(),dpop_bound_access_tokens_required:ye().optional()}),Ff=Be({issuer:R(),authorization_endpoint:Ke,token_endpoint:Ke,registration_endpoint:Ke.optional(),scopes_supported:H(R()).optional(),response_types_supported:H(R()),response_modes_supported:H(R()).optional(),grant_types_supported:H(R()).optional(),token_endpoint_auth_methods_supported:H(R()).optional(),token_endpoint_auth_signing_alg_values_supported:H(R()).optional(),service_documentation:Ke.optional(),revocation_endpoint:Ke.optional(),revocation_endpoint_auth_methods_supported:H(R()).optional(),revocation_endpoint_auth_signing_alg_values_supported:H(R()).optional(),introspection_endpoint:R().optional(),introspection_endpoint_auth_methods_supported:H(R()).optional(),introspection_endpoint_auth_signing_alg_values_supported:H(R()).optional(),code_challenge_methods_supported:H(R()).optional(),client_id_metadata_document_supported:ye().optional()}),Y1=Be({issuer:R(),authorization_endpoint:Ke,token_endpoint:Ke,userinfo_endpoint:Ke.optional(),jwks_uri:Ke,registration_endpoint:Ke.optional(),scopes_supported:H(R()).optional(),response_types_supported:H(R()),response_modes_supported:H(R()).optional(),grant_types_supported:H(R()).optional(),acr_values_supported:H(R()).optional(),subject_types_supported:H(R()),id_token_signing_alg_values_supported:H(R()),id_token_encryption_alg_values_supported:H(R()).optional(),id_token_encryption_enc_values_supported:H(R()).optional(),userinfo_signing_alg_values_supported:H(R()).optional(),userinfo_encryption_alg_values_supported:H(R()).optional(),userinfo_encryption_enc_values_supported:H(R()).optional(),request_object_signing_alg_values_supported:H(R()).optional(),request_object_encryption_alg_values_supported:H(R()).optional(),request_object_encryption_enc_values_supported:H(R()).optional(),token_endpoint_auth_methods_supported:H(R()).optional(),token_endpoint_auth_signing_alg_values_supported:H(R()).optional(),display_values_supported:H(R()).optional(),claim_types_supported:H(R()).optional(),claims_supported:H(R()).optional(),service_documentation:R().optional(),claims_locales_supported:H(R()).optional(),ui_locales_supported:H(R()).optional(),claims_parameter_supported:ye().optional(),request_parameter_supported:ye().optional(),request_uri_parameter_supported:ye().optional(),require_request_uri_registration:ye().optional(),op_policy_uri:Ke.optional(),op_tos_uri:Ke.optional(),client_id_metadata_document_supported:ye().optional()}),X1=A({...Y1.shape,...Ff.pick({code_challenge_methods_supported:!0}).shape}),eR=A({access_token:R(),id_token:R().optional(),token_type:R(),expires_in:K_().optional(),scope:R().optional(),refresh_token:R().optional()}).strip(),tR=A({error:R(),error_description:R().optional(),error_uri:R().optional()}),Dl=Ke.optional().or(N("").transform(()=>{})),rR=A({redirect_uris:H(Ke),token_endpoint_auth_method:R().optional(),grant_types:H(R()).optional(),response_types:H(R()).optional(),client_name:R().optional(),client_uri:Ke.optional(),logo_uri:Dl,scope:R().optional(),contacts:H(R()).optional(),tos_uri:Dl,policy_uri:R().optional(),jwks_uri:Ke.optional(),jwks:oa().optional(),software_id:R().optional(),software_version:R().optional(),software_statement:R().optional()}).strip(),nR=A({client_id:R(),client_secret:R().optional(),client_id_issued_at:fe().optional(),client_secret_expires_at:fe().optional()}).strip(),sR=rR.merge(nR);A({error:R(),error_description:R().optional()}).strip();A({token:R(),token_type_hint:R().optional()}).strip();function oR(e){const t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function aR({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 yR(e,t,r,n){const s=new URL(e),o=(n==null?void 0:n.protocolVersion)??Ts;let a;if(n!=null&&n.metadataUrl)a=new URL(n.metadataUrl);else{const c=gR(t,s.pathname);a=new URL(c,(n==null?void 0:n.metadataServerUrl)??s),a.search=s.search}let i=await Fl(a,o,r);if(!(n!=null&&n.metadataUrl)&&_R(i,s.pathname)){const c=new URL(`/.well-known/${t}`,s);i=await Fl(c,o,r)}return i}function vR(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 Hf(e,{fetchFn:t=fetch,protocolVersion:r=Ts}={}){var o;const n={"MCP-Protocol-Version":r,Accept:"application/json"},s=vR(e);for(const{url:a,type:i}of s){const c=await gc(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"?Ff.parse(await c.json()):X1.parse(await c.json())}}}async function $R(e,t){let r,n;try{r=await Vf(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 Hf(n,{fetchFn:t==null?void 0:t.fetchFn});return{authorizationServerUrl:n,authorizationServerMetadata:s,resourceMetadata:r}}async function wR(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(no))throw new Error(`Incompatible auth server: does not support response type ${no}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(so))throw new Error(`Incompatible auth server: does not support code challenge method ${so}`)}else i=new URL("/authorize",e);const c=await J1(),l=c.code_verifier,d=c.code_challenge;return i.searchParams.set("response_type",no),i.searchParams.set("client_id",r.client_id),i.searchParams.set("code_challenge",d),i.searchParams.set("code_challenge_method",so),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 bR(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}async function Zf(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=lR(n,d);uR(f,n,c,r)}const l=await(a??fetch)(i,{method:"POST",headers:c,body:r});if(!l.ok)throw await Lf(l);return eR.parse(await l.json())}async function SR(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 Zf(e,{metadata:t,tokenRequestParams:i,clientInformation:r,addClientAuthentication:o,resource:s,fetchFn:a});return{refresh_token:n,...c}}async function ER(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=bR(s,l,e.redirectUrl)}const c=await e.clientInformation();return Zf(t,{metadata:r,tokenRequestParams:i,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:n,fetchFn:o})}async function kR(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 Lf(a);return sR.parse(await a.json())}class io 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 Ll=10,PR=13,tr=32;function co(e){}function RR(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=co,onError:r=co,onRetry:n=co,onComment:s,maxBufferSize:o}=e,a=[];let i=0,c=!0,l,d="",f=0,y,_=!1;function g(E){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,E.charCodeAt(0)===239&&E.charCodeAt(1)===187&&E.charCodeAt(2)===191&&(E=E.slice(3))),a.length===0){const L=m(E);L!==""&&(a.push(L),i=L.length),v();return}if(E.indexOf(` -`)===-1&&E.indexOf("\r")===-1){a.push(E),i+=E.length,v();return}a.push(E);const x=a.join("");a.length=0,i=0;const M=m(x);M!==""&&(a.push(M),i=M.length),v()}function v(){o!==void 0&&(i+d.length<=o||(_=!0,a.length=0,i=0,l=void 0,d="",f=0,y=void 0,r(new io(`Buffered data exceeded max buffer size of ${o} characters`,{type:"max-buffer-size-exceeded"}))))}function m(E){let x=0;if(E.indexOf("\r")===-1){let M=E.indexOf(` -`,x);for(;M!==-1;){if(x===M){f>0&&t({id:l,event:y,data:d}),l=void 0,d="",f=0,y=void 0,x=M+1,M=E.indexOf(` -`,x);continue}const L=E.charCodeAt(x);if(Vl(E,x,L)){const G=E.charCodeAt(x+5)===tr?x+6:x+5,V=E.slice(G,M);if(f===0&&E.charCodeAt(M+1)===Ll){t({id:l,event:y,data:V}),l=void 0,d="",y=void 0,x=M+2,M=E.indexOf(` -`,x);continue}d=f===0?V:`${d} -${V}`,f++}else Hl(E,x,L)?y=E.slice(E.charCodeAt(x+6)===tr?x+7:x+6,M)||void 0:h(E,x,M);x=M+1,M=E.indexOf(` -`,x)}return E.slice(x)}for(;x20?`${E.slice(0,20)}…`:E}"`,{type:"unknown-field",field:E,value:x,line:M}));break}}function k(){f>0&&t({id:l,event:y,data:d}),l=void 0,d="",f=0,y=void 0}function T(E={}){if(E.consume&&a.length>0){const x=a.join("");h(x,0,x.length)}c=!0,l=void 0,d="",f=0,y=void 0,a.length=0,i=0,_=!1}return{feed:g,reset:T}}function Vl(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 Hl(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 TR extends TransformStream{constructor({onError:t,onRetry:r,onComment:n,maxBufferSize:s}={}){let o;super({start(a){o=RR({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 CR={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class wr extends Error{constructor(t,r){super(`Streamable HTTP error: ${r}`),this.code=t}}class jR{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=Z1(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)??CR}async _authThenStart(){var r;if(!this._authProvider)throw new $r("No auth provider");let t;try{t=await Gn(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 $r;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=Ao((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 wr(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,y,_;try{const g=t.pipeThrough(new TextDecoderStream).pipeThrough(new TR({onRetry:h=>{this._serverRetryMs=h}})).getReader();for(;;){const{value:h,done:$}=await g.read();if($)break;if(h.id&&(a=h.id,i=!0,s==null||s(h.id)),!!h.data&&(!h.event||h.event==="message"))try{const k=Wn.parse(JSON.parse(h.data));Jr(k)&&(c=!0,o!==void 0&&(k.id=o)),(d=this.onmessage)==null||d.call(this,k)}catch(k){(f=this.onerror)==null||f.call(this,k)}}(n||i)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:a,onresumptiontoken:s,replayMessageId:o},0)}catch(g){if((y=this.onerror)==null||y.call(this,new Error(`SSE stream disconnected: ${g}`)),(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 $r("No auth provider");if(await Gn(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new $r("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:go(t)?t.id:void 0}).catch(k=>{var T;return(T=this.onerror)==null?void 0:T.call(this,k)});return}const f=await this._commonHeaders();f.set("content-type","application/json"),f.set("accept","application/json, text/event-stream");const y={...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,y),g=_.headers.get("mcp-session-id");if(g&&(this._sessionId=g),!_.ok){const k=await _.text().catch(()=>null);if(_.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new wr(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:T,scope:E}=Ul(_);if(this._resourceMetadataUrl=T,this._scope=E,await Gn(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new $r;return this._hasCompletedAuthFlow=!0,this.send(t)}if(_.status===403&&this._authProvider){const{resourceMetadataUrl:T,scope:E,error:x}=Ul(_);if(x==="insufficient_scope"){const M=_.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===M)throw new wr(403,"Server returned 403 after trying upscoping");if(E&&(this._scope=E),T&&(this._resourceMetadataUrl=T),this._lastUpscopingHeader=M??void 0,await Gn(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new $r;return this.send(t)}}throw new wr(_.status,`Error POSTing to endpoint: ${k}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,_.status===202){await((s=_.body)==null?void 0:s.cancel()),ly(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(k=>{var T;return(T=this.onerror)==null?void 0:T.call(this,k)});return}const m=(Array.isArray(t)?t:[t]).filter(k=>"method"in k&&"id"in k&&k.id!==void 0).length>0,h=_.headers.get("content-type"),$=H1(h);if(m)if($==="text/event-stream")this._handleSseStream(_.body,{onresumptiontoken:d},!1);else if($==="application/json"){const k=await _.json(),T=Array.isArray(k)?k.map(E=>Wn.parse(E)):[Wn.parse(k)];for(const E of T)(o=this.onmessage)==null||o.call(this,E)}else throw await((a=_.body)==null?void 0:a.cancel()),new wr(-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 wr(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 NR="https://mcp.excalidraw.com/mcp",IR="mcp.excalidraw.com",OR="/api/v1/chat/mcp-apps/excalidraw",Kf="ui://excalidraw/mcp-app.html",xR=["read_me","create_view"],Gf=new Set(["export_to_excalidraw","save_checkpoint","read_checkpoint"]),AR=256*1024,MR=1024*1024,zR=1024*1024,qR=240,DR=720,UR=525;function FR(e){return!Number.isFinite(e)||e<=0?UR:Math.max(qR,Math.min(DR,Math.round(e*3/4)))}const LR={excalidraw:{id:"excalidraw",endpoint:NR,hostname:IR,resourceUri:Kf,modelTools:xR,appTools:Gf}};function VR(e){return LR[e]}function HR(){return new URL(wt(OR),window.location.origin)}class ZR{constructor(){le(this,"client",new A1({name:"pwc-chat-mcp-app-host",version:"1"}));le(this,"transport",new jR(HR(),{requestInit:{credentials:"include"}}));le(this,"connected");le(this,"bytes",0);le(this,"closed",!1)}connect(){return this.closed?Promise.reject(new Error("App host client is closed")):(this.connected||(this.connected=this.client.connect(this.transport).then(()=>{},t=>{throw this.connected=void 0,this.retire(),t})),this.connected)}async readResource(t){if(t!==Kf)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,zR);const s=await BR(n.text);return{text:n.text,digest:s}}async callTool(t,r){if(!Gf.has(t))throw new Error("Unapproved App tool");const n=JSON.stringify(r);this.consume(n);try{await this.connect();const s=await this.client.callTool({name:t,arguments:r});return this.consume(JSON.stringify(s)),s}catch(s){throw this.retire(),s}}close(){this.closed=!0,this.connected=void 0,this.transport.close()}retire(){this.close(),Ht===this&&(Ht=void 0)}consume(t,r=AR){const n=new TextEncoder().encode(t).byteLength;if(n>r||this.bytes+n>MR)throw new Error("App request exceeds host limit");this.bytes+=n}}let Ht;function KR(){return Ht??(Ht=new ZR),Ht}function GR(){Ht==null||Ht.close(),Ht=void 0}function WR(e){GR()}async function BR(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 JR(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 QR=({block:e})=>{const t=Q.useRef(null),r=Q.useRef(null),n=Q.useRef(!1),s=Q.useRef(e),o=Q.useRef(!1);s.current=e;const[a,i]=Q.useState(),[c,l]=Q.useState("loading"),[d,f]=Q.useState(e.height),[y,_]=Q.useState(!1),[g,v]=Q.useState(0),m=Q.useRef(null),h=e.input.elements,$=!!e.permissions.clipboardWrite;o.current=y;const k=Q.useCallback(()=>{_(!1),document.fullscreenElement&&document.exitFullscreen()},[]),T=Q.useCallback(()=>{var M,L;if(y){k();return}_(!0),(L=(M=m.current)==null?void 0:M.requestFullscreen)==null||L.call(M).catch(()=>{})},[k,y]),E=Q.useCallback(()=>{WR(),i(void 0),l("loading"),v(M=>M+1)},[]);Q.useEffect(()=>{const M=m.current;if(!M)return;const L=()=>{o.current||f(FR(M.clientWidth))};L();const G=new ResizeObserver(L);return G.observe(M),()=>G.disconnect()},[]),Q.useEffect(()=>{if(!y)return;const M=m.current,L=V=>{V.key==="Escape"&&(document.fullscreenElement||k())},G=()=>{document.fullscreenElement||_(!1)};return window.addEventListener("keydown",L),document.addEventListener("fullscreenchange",G),()=>{window.removeEventListener("keydown",L),document.removeEventListener("fullscreenchange",G),document.fullscreenElement===M&&document.exitFullscreen()}},[k,y]),Q.useEffect(()=>{VR(e.provider);{l("unavailable");return}},[g,e.provider,e.resource_uri]),Q.useEffect(()=>{if(!a||c!=="ready")return;const M=t.current;if(!M)return;let L=null;const G=JR(M,()=>{M.contentWindow&&(L=new Fv(null,{name:"Papers with Code",version:"1"},{serverTools:{},openLinks:{},logging:{},...$?{clipboard:{write:{}}}:{}},{hostContext:{theme:document.documentElement.dataset.theme==="dark"?"dark":"light",displayMode:y?"fullscreen":"inline"}}),L.oncalltool=async({name:V,arguments:K})=>{if(s.current.public_fork&&V!=="export_to_excalidraw")throw new Error("Shared diagrams cannot mutate owner state");return KR().callTool(V,K??{})},L.onopenlink=async({url:V})=>{const K=new URL(V);if(K.protocol!=="https:"||K.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(K.href,"_blank","noopener,noreferrer"),{}},L.onsizechange=()=>{},L.oninitialized=()=>{n.current=!0;try{const V=JSON.parse(h);L.sendToolInput({arguments:{elements:Array.isArray(V)?Qv(V):V}}),L.sendToolResult(s.current.result)}catch{l("error")}},r.current=L,L.connect(new Dv(M.contentWindow??void 0,M.contentWindow)).catch(()=>l("error")))});return()=>{G(),n.current=!1,L==null||L.teardownResource({}).catch(()=>{}),r.current===L&&(r.current=null)}},[a,c,y,h,$,g]),Q.useEffect(()=>{var M;c!=="ready"||!n.current||(M=r.current)==null||M.sendToolResult(e.result).catch(()=>{})},[e.result,c]);const x=c==="unavailable"||c==="incompatible"||c==="error";return S.jsxs("section",{ref:m,className:`chat-mcp-app${y?" chat-mcp-app-fullscreen":""}`,"aria-label":"Interactive Excalidraw diagram",children:[S.jsx("header",{children:S.jsx("button",{type:"button",onClick:T,children:y?"Exit fullscreen":"Fullscreen"})}),c==="loading"&&S.jsx("div",{className:"chat-mcp-loading",role:"status",children:"Loading interactive diagram…"}),x&&S.jsxs("div",{className:"chat-mcp-error",children:["Interactive diagram unavailable. The cited text answer is still available.",S.jsx("button",{type:"button",onClick:E,children:"Retry diagram"})]}),a&&c==="ready"&&S.jsx("iframe",{ref:t,title:"Interactive Excalidraw diagram",sandbox:"allow-scripts",allow:$?"clipboard-write":void 0,srcDoc:a,style:{height:d}},g)]})},YR="https://github.com/Chenruishuo/posterly/tree/b9f42e5578a49a27525a68f85376bb3bb25af86f";function XR(){if(typeof window>"u")return null;const e=window.location.pathname.match(/^\/share\/([^/]+)/u);return e?decodeURIComponent(e[1]):null}function Zl(e){if(e.scope==="public"){const r=XR();if(!r||!e.public_capability)return null;const n=`/api/v1/chat/shares/${encodeURIComponent(r)}/artifacts/${encodeURIComponent(e.public_capability)}`;return{preview:wt(`${n}/preview`),png:wt(`${n}/download/png`),pdf:wt(`${n}/download/pdf`),manifest:null,source:null,gate: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)}`;return{preview:wt(`${t}/preview`),png:wt(`${t}/download/${encodeURIComponent("poster.png")}`),pdf:null,manifest:wt(`${t}/manifest`),source:r=>wt(`${t}/source/${r.split("/").map(encodeURIComponent).join("/")}`),gate:r=>wt(`${t}/source/${r.split("/").map(encodeURIComponent).join("/")}`),download:r=>wt(`${t}/download/${r.split("/").map(encodeURIComponent).join("/")}`)}}const Kl=e=>({passed:"Passed",warnings:"Passed with warnings",failed:"Non-final draft"})[e??"passed"],eT=({block:e})=>{var T;const[t,r]=Q.useState(!1),[n,s]=Q.useState("preview"),[o,a]=Q.useState(null),[i,c]=Q.useState(null),[l,d]=Q.useState([]),[f,y]=Q.useState(null),_=Q.useRef(e.status),g=f?{...e,version_id:f.version_id,version:f.version,gate_status:f.gate_status,total_bytes:f.total_bytes}:e,v=Zl(e),m=Zl(g);if(Q.useEffect(()=>{_.current==="generating"&&e.status==="ready"&&e.scope==="owner"&&r(!0),_.current=e.status},[e.scope,e.status]),Q.useEffect(()=>{!t||e.scope!=="owner"||!e.artifact_id||l.length||fetch(wt(`/api/v1/chat/artifacts/${encodeURIComponent(e.artifact_id)}`),{credentials:"include",cache:"no-store"}).then(E=>E.ok?E.json():Promise.reject()).then(E=>d(E.versions)).catch(()=>{})},[e.artifact_id,e.scope,t,l.length]),Q.useEffect(()=>{!t||!(m!=null&&m.manifest)||o||fetch(m.manifest,{credentials:"include",cache:"no-store"}).then(E=>E.ok?E.json():Promise.reject()).then(a).catch(()=>{})},[m==null?void 0:m.manifest,o,t]),Q.useEffect(()=>{if(n!=="source"||i!==null||!o||!(m!=null&&m.source))return;const E=m.source(o.entrypoint);fetch(E,{credentials:"include",cache:"no-store"}).then(x=>x.ok?x.text():Promise.reject()).then(c).catch(()=>c("Source could not be loaded."))},[m,o,i,n]),e.status==="generating")return S.jsxs("div",{className:"chat-artifact-card chat-artifact-generating",role:"status",children:[S.jsx("span",{className:"chat-artifact-pulse","aria-hidden":"true"}),S.jsxs("span",{children:[S.jsx("strong",{children:e.title}),S.jsx("small",{children:"Publishing Posterly preview…"})]})]});if(e.status==="error")return S.jsxs("div",{className:"chat-artifact-card chat-artifact-error",role:"alert",children:[S.jsx(vc,{"aria-hidden":"true"}),S.jsxs("span",{children:[S.jsx("strong",{children:e.title}),S.jsx("small",{children:e.error_message??"Poster publication failed."})]})]});if(!m||!v)return null;const h=(T=o==null?void 0:o.downloads[0])==null?void 0:T.path,$=e.scope==="public"?m.pdf:h&&typeof m.download=="function"?m.download(h):null,k=e.scope==="public"?m.png:m.preview;return S.jsxs(S.Fragment,{children:[S.jsxs("button",{type:"button",className:"chat-artifact-card",onClick:()=>r(!0),children:[S.jsx("img",{src:v.preview,alt:`Preview of ${e.title}`}),S.jsxs("span",{className:"chat-artifact-card-copy",children:[S.jsxs("span",{className:"chat-artifact-kicker",children:[S.jsx(yh,{"aria-hidden":"true"})," Posterly · v",e.version]}),S.jsx("strong",{children:e.title}),S.jsx("small",{className:`chat-artifact-gate chat-artifact-gate-${e.gate_status}`,children:Kl(e.gate_status)})]})]}),t&&S.jsx("div",{className:"chat-artifact-overlay",role:"presentation",onMouseDown:E=>{E.target===E.currentTarget&&r(!1)},children:S.jsxs("section",{className:"chat-artifact-panel",role:"dialog","aria-modal":"true","aria-label":e.title,children:[S.jsxs("header",{children:[S.jsxs("div",{children:[S.jsx("span",{children:"Posterly artifact"}),S.jsx("h2",{children:e.title})]}),l.length>1&&S.jsxs("label",{className:"chat-artifact-version",children:["Version",S.jsx("select",{value:g.version_id,onChange:E=>{y(l.find(x=>x.version_id===E.target.value)??null),a(null),c(null),s("preview")},children:[...l].reverse().map(E=>S.jsxs("option",{value:E.version_id,children:["v",E.version]},E.version_id))})]}),S.jsx("button",{type:"button","aria-label":"Close poster",onClick:()=>r(!1),children:S.jsx(Yf,{})})]}),S.jsxs("nav",{"aria-label":"Poster views",children:[S.jsx("button",{type:"button",className:n==="preview"?"active":"",onClick:()=>s("preview"),children:"Preview"}),e.scope==="owner"&&S.jsx("button",{type:"button",className:n==="source"?"active":"",onClick:()=>s("source"),children:"Source"})]}),S.jsx("div",{className:"chat-artifact-panel-body",children:n==="preview"?S.jsx("img",{src:m.preview,alt:`Full preview of ${e.title}`}):S.jsx("pre",{children:S.jsx("code",{children:i??"Loading source…"})})}),S.jsxs("footer",{children:[S.jsxs("div",{className:"chat-artifact-metadata",children:[S.jsx("strong",{children:Kl(g.gate_status)}),o&&S.jsxs("span",{children:[o.canvas.width," × ",o.canvas.height," ",o.canvas.unit," · ",o.canvas.orientation," · ",o.direction]}),o==null?void 0:o.gate_summary.map(E=>S.jsx("span",{children:E},E))]}),S.jsxs("div",{className:"chat-artifact-actions",children:[S.jsxs("a",{href:k,download:!0,children:[S.jsx(yc,{})," PNG"]}),g.gate_status!=="failed"&&$&&S.jsxs("a",{href:$,download:!0,children:[S.jsx(yc,{})," PDF"]}),e.scope==="owner"&&o&&m.source&&S.jsxs("a",{href:m.source(o.entrypoint),download:!0,children:[S.jsx(vc,{})," HTML"]}),e.scope==="owner"&&o&&m.gate&&S.jsx("a",{href:m.gate(o.gate_report),download:!0,children:"Gate report"}),S.jsxs("a",{href:YR,target:"_blank",rel:"noreferrer",children:[S.jsx(mh,{})," Posterly source · AGPL-3.0"]})]})]})]})})]})};function tT(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 rT(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 nT(e,t=240){const r=e.content.trim();return r.length<=t?r:`${r.slice(0,t).trimEnd()}…`}const sT="https://huggingface.co/pro",oT="https://huggingface.co/docs/inference-providers/pricing",aT="https://paperswithcode.co/chat",Wf=()=>S.jsx("span",{className:"chat-caret"}),iT=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},cT=e=>{var _,g;const t=e.currentTarget,r=t.ownerDocument,n=(_=r.caretPositionFromPoint)==null?void 0:_.call(r,e.clientX,e.clientY),s=n?null:(g=r.caretRangeFromPoint)==null?void 0:g.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(S.jsxs("span",{className:"chat-inline-paper-mention",children:[S.jsx(gh,{size:13,"aria-hidden":"true"}),S.jsx(Yl,{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)),S.jsx(S.Fragment,{children:r})},uT=({block:e,papers:t,citations:r,webCitations:n,onToggle:s})=>e.active?S.jsxs("div",{className:"chat-reason-live",children:[S.jsxs("div",{className:"chat-reason-live-head",children:[S.jsx(Wo,{})," ",S.jsx("span",{children:"Thinking…"})]}),S.jsxs("div",{className:"chat-reason-live-body chat-answer chat-reason-markdown",children:[S.jsx(lo,{text:e.text,streaming:!0,papers:t,citations:r,webCitations:n}),S.jsx(Wf,{})]})]}):S.jsxs("div",{className:"chat-reason-done",children:[S.jsxs("button",{type:"button",className:"chat-reason-done-head",onClick:s,"aria-expanded":e.open,children:[S.jsx(oh,{}),S.jsx("span",{children:"Thought for a few seconds"}),S.jsx(Ql,{open:e.open})]}),e.open&&S.jsx("div",{className:"chat-reason-done-body chat-answer chat-reason-markdown",children:S.jsx(lo,{text:e.text,papers:t,citations:r,webCitations:n})})]}),dT=({block:e,papers:t,onToggle:r})=>{var d,f,y,_;const n=e.status==="running",s=e.schema_version===2||!!e.content,o=e.status==="error"||e.status==="denied",a=typeof e.args.query=="string"?e.args.query:"",i=typeof e.args.command=="string"?e.args.command:typeof e.args.file_path=="string"?e.args.file_path:a,c=((d=e.content)==null?void 0:d.map(g=>g.text).join(""))??"",l=n?"running…":s?`${e.status} · ${e.took_ms??0} ms`:`${e.hits} results · ${e.took_ms} ms`;return S.jsxs("div",{className:`chat-tool${n?" chat-tool-running":""}${o?" chat-tool-failed":""}`,children:[S.jsxs("button",{type:"button",className:"chat-tool-head",onClick:r,disabled:n,"aria-expanded":n?void 0:e.open,children:[S.jsxs("span",{className:"chat-tool-head-left",children:[n?S.jsx(Wo,{}):S.jsx(ah,{}),S.jsx("code",{className:"chat-tool-name",children:e.name}),S.jsx("span",{className:"chat-tool-query",children:s?i:`("${a}")`})]}),S.jsxs("span",{className:"chat-tool-head-right",children:[S.jsx("span",{className:"chat-tool-status",children:l}),!n&&S.jsx(Ql,{open:e.open})]})]}),!n&&e.open&&S.jsxs("div",{className:"chat-tool-body",children:[S.jsxs("div",{className:"chat-tool-args",children:[S.jsx("span",{className:"chat-tool-label",children:"arguments"}),S.jsx("pre",{children:JSON.stringify(e.args,null,2)})]}),s?S.jsxs(S.Fragment,{children:[S.jsxs("div",{className:"chat-tool-output-head",children:[S.jsx("span",{className:"chat-tool-label",children:"result"}),S.jsx("button",{type:"button",className:"chat-tool-copy",onClick:()=>void navigator.clipboard.writeText(c),children:"Copy"})]}),S.jsx("pre",{className:"chat-tool-output",children:S.jsx("code",{children:c})}),((f=e.metadata)==null?void 0:f.output_truncated)&&S.jsx("div",{className:"chat-tool-truncated",children:"Output was truncated."})]}):S.jsxs(S.Fragment,{children:[S.jsxs("div",{className:"chat-tool-label chat-tool-results-label",children:["returned ",((y=e.results)==null?void 0:y.length)??0," papers"]}),S.jsx("ol",{className:"chat-tool-results",children:(_=e.results)==null?void 0:_.map(g=>S.jsxs("li",{className:"chat-hit",children:[S.jsx("div",{className:"chat-hit-top",children:S.jsx(eu,{routeId:g.route_id,paper:t[g.route_id],className:"chat-hit-title",children:g.title})}),S.jsx("div",{className:"chat-hit-meta",children:[tT(g.metadata),rT(g.metadata)].filter(Boolean).join(" · ")}),S.jsxs("div",{className:"chat-hit-snippet",children:[nT(g),g.content_truncated&&S.jsx("span",{className:"chat-hit-truncated",children:" (truncated)"})]})]},g.route_id))})]})]})]})},fT=({block:e,papers:t,citations:r,webCitations:n,streaming:s})=>S.jsxs("div",{className:"chat-answer",children:[S.jsx(lo,{text:e.text,streaming:s,papers:t,citations:r,webCitations:n}),s&&!!e.text.trim()&&S.jsx(Wf,{})]}),hT=({block:e})=>S.jsx(QR,{block:e}),Bf=e=>{const t=Q.useRef(null),r=Q.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 Q.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}},pT=({id:e,text:t,paperSelection:r,editNotice:n,onCancel:s,onResend:o,onResendDraft:a})=>{const[i,c]=Q.useState(t),[l,d]=Q.useState(r),[f,y]=Q.useState(!1),{textareaRef:_,resize:g}=Bf(t);Q.useLayoutEffect(g,[g,i]);const v=!!i.trim()&&i.length<=8e3,m=()=>{if(!v||f)return;y(!0),((a==null?void 0:a({text:i,paperMentions:[],...l?{paperSelection:l}:{}}))??(o==null?void 0:o(i))??!1)||y(!1)};return S.jsx("div",{className:"chat-msg chat-msg-user chat-msg-user-editing","data-message-id":e,children:S.jsxs("div",{className:"chat-inline-editor",children:[l&&S.jsx(Es,{selection:l,editable:!0,onRemove:()=>d(void 0)}),S.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(),m())}}),n&&S.jsx("div",{className:"chat-inline-editor-notice",children:n}),S.jsxs("div",{className:"chat-inline-editor-actions",children:[S.jsx("button",{type:"button",onClick:s,children:"Cancel"}),S.jsx("button",{type:"button",className:"chat-inline-editor-send",disabled:!v||f,onClick:m,children:"Send"})]})]})})},mT=({id:e,text:t,paperMentions:r,paperSelection:n,enabled:s,editNotice:o,onCancel:a,onResend:i,onResendDraft:c})=>{const[l,d]=Q.useState({text:t,paperMentions:r,...n?{paperSelection:n}:{}}),[f,y]=Q.useState(!1),[_,g]=Q.useState(0),{textareaRef:v,resize:m}=Bf(t),h=Wl({draft:l,onChange:d,enabled:s,textareaRef:v});Q.useLayoutEffect(m,[m,l.text]);const $=!!l.text.trim()&&l.text.length<=8e3&&(s||l.paperMentions.length===0),k=()=>{if(!$||f)return;y(!0),((c==null?void 0:c(l))??(i==null?void 0:i(l.text))??!1)||y(!1)};return S.jsx("div",{className:"chat-msg chat-msg-user chat-msg-user-editing","data-message-id":e,children:S.jsxs("div",{className:"chat-inline-editor",children:[l.paperSelection&&S.jsx(Es,{selection:l.paperSelection,editable:!0,onRemove:()=>d({text:l.text,paperMentions:l.paperMentions})}),S.jsxs("div",{className:"chat-inline-editor-textarea-wrap",children:[S.jsx(Bl,{text:l.text,mentions:l.paperMentions,scrollTop:_,variant:"editor"}),S.jsx("textarea",{ref:v,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:T=>h.updateText(T.target.value,T.target.selectionStart),onSelect:T=>h.refresh(T.currentTarget.selectionStart),onScroll:T=>g(T.currentTarget.scrollTop),onKeyDown:T=>{h.keyDown(T)||(T.key==="Escape"?(T.preventDefault(),a==null||a()):T.key==="Enter"&&!T.shiftKey&&!T.nativeEvent.isComposing&&(T.preventDefault(),k()))}}),S.jsx(Jl,{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&&S.jsx("div",{className:"chat-inline-editor-notice",role:"status",children:"Paper mentions are currently disabled. Remove them before sending."}),o&&S.jsx("div",{className:"chat-inline-editor-notice",children:o}),S.jsxs("div",{className:"chat-inline-editor-actions",children:[S.jsx("button",{type:"button",onClick:a,children:"Cancel"}),S.jsx("button",{type:"button",className:"chat-inline-editor-send",disabled:!$||f,onClick:k,children:"Send"})]})]})})},IT=({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[y,_]=Q.useState(!1),g=Q.useRef(null);Q.useEffect(()=>()=>{g.current!==null&&window.clearTimeout(g.current)},[]);const v=async()=>{var m;if((m=navigator.clipboard)!=null&&m.writeText)try{await navigator.clipboard.writeText(t),_(!0),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>_(!1),1500)}catch{}};return a?!s&&r.length===0?S.jsx(pT,{id:e,text:t,paperSelection:n,editNotice:i,onCancel:l,onResend:d,onResendDraft:f}):S.jsx(mT,{id:e,text:t,paperMentions:r,paperSelection:n,enabled:s,editNotice:i,onCancel:l,onResend:d,onResendDraft:f}):S.jsx("div",{className:"chat-msg chat-msg-user","data-message-id":e,children:S.jsxs("div",{className:"chat-user-message-wrap",children:[n&&S.jsx(Es,{selection:n}),S.jsx("div",{className:"chat-bubble",onDoubleClick:cT,children:S.jsx(lT,{text:t,mentions:r})}),S.jsxs("div",{className:"chat-user-actions",children:[S.jsx("button",{type:"button",className:"chat-user-action","aria-label":y?"Message copied":"Copy message",title:y?"Copied":"Copy",onClick:()=>void v(),children:y?S.jsx(Xf,{"aria-hidden":"true"}):S.jsx(_h,{"aria-hidden":"true"})}),o&&S.jsx("button",{type:"button",className:"chat-user-action","aria-label":"Edit message",title:"Edit",onClick:c,children:S.jsx(vh,{"aria-hidden":"true"})})]})]})})},OT=({msg:e,papers:t,onToggleBlock:r,onArchiveOldChats:n,onArchiveOldestChats:s,archivePending:o=null,hfBilling:a=null,openRouterFallbackEnabled:i=!1,feedbackEnabled:c=!1})=>{var M,L,G;const[l,d]=Q.useState(null),[f,y]=Q.useState(!1),[_,g]=Q.useState(!1),[v,m]=Q.useState(!1),[h,$]=Q.useState(""),k=Q.useRef(null),T=`chat-feedback-panel-${e.id}`,E=c&&!e.streaming&&!e.error&&!!((M=e.blocks)!=null&&M.some(V=>V.kind==="answer"&&V.text.trim()));Q.useEffect(()=>{var V;v&&((V=k.current)==null||V.focus())},[v]);const x=async(V,K)=>{if(!f){y(!0),g(!1);try{K===void 0?await _c.reportFeedback(e.id,V):await _c.reportFeedback(e.id,V,K),d(V),m(!1),$("")}catch{g(!0)}finally{y(!1)}}};return S.jsx("div",{className:"chat-msg chat-msg-assistant",children:S.jsxs("div",{className:"chat-msg-blocks",children:[(L=e.blocks)==null?void 0:L.map((V,K)=>{var ke;const Y=`${e.id}-${K}`,ne="citations"in V&&V.citations!==void 0?V.citations:e.citations??[],F=Object.fromEntries(ne.filter($e=>($e.kind??"paper")==="paper"&&$e.route_id).map($e=>[$e.route_id,$e])),ie=Object.fromEntries(ne.filter($e=>$e.kind==="web"&&$e.url).map($e=>[$e.url,$e]));return V.kind==="reasoning"?S.jsx(uT,{block:V,papers:t,citations:F,webCitations:ie,onToggle:()=>r(e.id,K)},Y):V.kind==="tool"?S.jsx(dT,{block:V,papers:t,onToggle:()=>r(e.id,K)},Y):V.kind==="app"?S.jsx(hT,{block:V},V.instance_id||Y):V.kind==="artifact"?S.jsx(eT,{block:V},V.publication_id||V.version_id||Y):S.jsx(fT,{block:V,papers:t,citations:F,webCitations:ie,streaming:!!(e.streaming&&K===(((ke=e.blocks)==null?void 0:ke.length)??0)-1)},Y)}),iT(e)&&S.jsx("div",{className:"chat-waiting",role:"status","aria-live":"polite",children:S.jsx("span",{className:"chat-thinking",children:(((G=e.blocks)==null?void 0:G.length)??0)===0?e.status??"Thinking…":"Thinking…"})}),e.error&&S.jsxs("div",{className:"chat-error",children:[S.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??"")&&S.jsx("a",{href:"/settings",children:"Re-sign in with Hugging Face"}),e.errorCode==="hf_inference_billing_exhausted"&&S.jsxs(S.Fragment,{children:[(a==null?void 0:a.account_type)==="Free"&&!a.bill_to?S.jsx("a",{href:sT,target:"_blank",rel:"noreferrer",children:"Upgrade to Hugging Face PRO — $9/month for 20× more included credits"}):S.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"}),S.jsx("a",{href:oT,target:"_blank",rel:"noreferrer",children:"Inference Providers pricing and billing details"})]}),e.errorCode==="openrouter_monthly_budget_exhausted"&&S.jsxs(S.Fragment,{children:[i?S.jsx("span",{children:"This response started on the shared allowance. Your connected OpenRouter key will be used when you explicitly retry."}):S.jsx("a",{href:"/settings#openrouter-byok",children:"Connect your own OpenRouter key"}),S.jsx("span",{children:"Or select a Hugging Face-backed model and explicitly retry."})]}),e.errorCode==="openrouter_staging_funding_disabled"&&S.jsx("a",{href:aT,children:"Continue on paperswithcode.co"}),e.errorCode==="openrouter_unavailable"&&S.jsxs(S.Fragment,{children:[S.jsx("a",{href:"/settings#openrouter-byok",children:"Bring your own key in Settings"}),S.jsx("a",{href:"https://github.com/huggingface/paperswithcode-feedback",target:"_blank",rel:"noreferrer",children:"File an issue"})]}),e.errorCode==="openrouter_byok_billing_error"&&S.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??"")&&S.jsx("a",{href:"/settings#openrouter-byok",children:"Review OpenRouter settings"}),e.errorCode==="chat_session_quota_exceeded"&&(n||s)&&S.jsxs("span",{className:"chat-error-actions",children:[n&&S.jsx("button",{type:"button",disabled:o!==null,onClick:n,children:o==="old"?"Archiving…":"Archive chats older than 30 days"}),s&&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"&&S.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," ")}).`}),E&&S.jsxs("div",{className:"chat-feedback","aria-label":"Rate this response",children:[S.jsx("span",{className:"chat-feedback-label",children:l===null?"Was this helpful?":"Thanks for your feedback"}),S.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:()=>{m(!1),x(!0)},children:S.jsx(wh,{"aria-hidden":"true"})}),S.jsx("button",{type:"button",className:`chat-feedback-action${l===!1?" chat-feedback-action-selected":""}`,"aria-label":"Unhelpful response","aria-pressed":l===!1,"aria-expanded":v,"aria-controls":T,disabled:f,onClick:()=>{g(!1),m(!0)},children:S.jsx($h,{"aria-hidden":"true"})}),_&&S.jsx("span",{className:"chat-feedback-error",role:"status",children:"Couldn’t send feedback."})]}),E&&v&&S.jsxs("div",{className:"chat-feedback-panel",id:T,role:"group","aria-labelledby":`${T}-title`,children:[S.jsx("div",{className:"chat-feedback-panel-title",id:`${T}-title`,children:"Additional feedback"}),S.jsx("label",{className:"chat-feedback-panel-label",htmlFor:`${T}-comment`,children:"Tell us what went wrong (optional)"}),S.jsx("textarea",{ref:k,id:`${T}-comment`,className:"chat-feedback-comment",value:h,maxLength:500,rows:4,disabled:f,onChange:V=>$(V.target.value),onKeyDown:V=>{V.key==="Escape"&&(V.preventDefault(),m(!1))}}),S.jsxs("div",{className:"chat-feedback-panel-actions",children:[S.jsx("button",{type:"button",className:"chat-feedback-skip",disabled:f,onClick:()=>void x(!1),children:"Skip"}),S.jsx("button",{type:"button",className:"chat-feedback-submit",disabled:f,onClick:()=>void x(!1,h.trim()||void 0),children:f?"Submitting…":"Submit"})]})]})]})})};export{OT as A,CT as C,IT as U};