diff --git "a/assets/ArtifactWorkspace-rhI362JW.js" "b/assets/ArtifactWorkspace-rhI362JW.js" deleted file mode 100644--- "a/assets/ArtifactWorkspace-rhI362JW.js" +++ /dev/null @@ -1,128 +0,0 @@ -var jh=Object.defineProperty;var Nh=(e,t,r)=>t in e?jh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var se=(e,t,r)=>Nh(e,typeof t!="symbol"?t+"":t,r);import{d as wr,r as _t,j as b,z as H,N as au,E as It,X as Ih,C as Oh}from"./index-DxnSsCPb.js";import{u as iu,P as cu,b as lu,M as xh,R as Ah,W as Mh,d as da,A as zh,n as Dh,L as qh,N as uu,O as Uh}from"./chatLaunch-Br3HZtqf.js";import"./katex.min-BSBacQyE.js";import{H as As,a as Ms,b as zs}from"./hover-card-C0tdqTeN.js";import{u as ns}from"./useQuery-DEE9grJB.js";import{f as Fh,p as Lh}from"./github-d4UhOz6_.js";import{G as fa}from"./github-BLfbl85d.js";import{r as Vh,a as Hh,P as du}from"./PaperPreviewLink-BSsRaO7m.js";import{M as Zh,r as Kh,d as Gh}from"./index-tT3sKWIF.js";import{c as Oc}from"./chat-DU3GOumt.js";import{F as Wh}from"./file-text-BUfOfDMN.js";import{E as Bh}from"./external-link-DG-yMfwx.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 Jh=wr("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 xc=wr("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 fu=wr("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 Qh=wr("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 Yh=wr("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 Xh=wr("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 ep=wr("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 Ds({selection:e,editable:t=!1,onRemove:r}){const n=_t.useId(),s=_t.useRef(null),[o,a]=_t.useState(!1),[i,c]=_t.useState(!1),l=`Selection · Page ${e.page}`;return _t.useEffect(()=>{const d=s.current;!d||o||c(d.scrollHeight>d.clientHeight+1)},[o,e.text]),b.jsxs("div",{className:`chat-paper-selection${t?" is-editable":""}`,children:[b.jsxs("div",{className:"chat-paper-selection-header",children:[b.jsx("span",{className:"chat-paper-selection-label",children:l}),b.jsxs("div",{className:"chat-paper-selection-actions",children:[(i||o)&&b.jsx("button",{type:"button",className:"chat-paper-selection-toggle","aria-expanded":o,"aria-controls":n,onClick:()=>a(d=>!d),children:o?"Collapse":"Expand"}),t&&r&&b.jsx("button",{type:"button",className:"chat-paper-selection-remove","aria-label":"Remove selected paper passage",onClick:r,children:"Remove"})]})]}),b.jsx("blockquote",{id:n,ref:s,className:`chat-paper-selection-quote${o?" is-expanded":""}`,children:e.text})]})}const tp=Dh(),ej=({onSend:e,busy:t,placeholder:r,autoFocus:n,draft:s,onDraftChange:o,onStop:a,models:i=[],selectedModel:c,onModelChange:l,disabled:d=!1,describedBy:h,paperMentionsEnabled:m=!1,paperSelectionEnabled:_=!0,webSearchAvailable:v=!1,webSearchEnabled:y=!1,onWebSearchChange:g,reasoningEffort:f="low",onReasoningEffortChange:$})=>{const[E,T]=_t.useState(tp),R=s??E,O=_t.useRef(null),[x,U]=_t.useState(0),D=F=>{s||T(F),o==null||o(F)},q=iu({draft:R,onChange:D,enabled:m,textareaRef:O});_t.useEffect(()=>{const F=O.current;F&&(F.style.height="auto",F.style.height=`${Math.min(F.scrollHeight,200)}px`)},[R.text]),_t.useEffect(()=>{var F;n&&((F=O.current)==null||F.focus())},[n]);const L=()=>{const F=R.text.length-R.text.trimStart().length,le=R.text.trim(),Ce=!!R.paperSelection&&!_;if(!le||t||d||Ce)return;const _e=F+le.length,it={text:le,paperMentions:R.paperMentions.filter(Ie=>Ie.start>=F&&Ie.end<=_e).map(Ie=>({...Ie,start:Ie.start-F,end:Ie.end-F})),...R.paperSelection?{paperSelection:R.paperSelection}:{}};e(it)},Z=!!R.paperSelection&&!_,re=!!R.text.trim()&&!Z;return b.jsxs("div",{className:"chat-composer",children:[R.paperSelection&&b.jsx(Ds,{selection:R.paperSelection,editable:!0,onRemove:()=>{var F;D({text:R.text,paperMentions:R.paperMentions}),(F=O.current)==null||F.focus()}}),Z&&b.jsx("div",{className:"chat-paper-selection-disabled",role:"status",children:"Paper selection is currently disabled. Remove the selected passage or wait for the feature to recover."}),b.jsxs("div",{className:"chat-composer-textarea-wrap",children:[b.jsx(cu,{text:R.text,mentions:R.paperMentions,scrollTop:x}),b.jsx("textarea",{ref:O,rows:1,value:R.text,placeholder:r||(R.paperSelection?"Ask about this selection…":"Ask anything about research…"),onChange:F=>q.updateText(F.target.value,F.target.selectionStart),onSelect:F=>q.refresh(F.currentTarget.selectionStart),onClick:F=>q.refresh(F.currentTarget.selectionStart),onScroll:F=>U(F.currentTarget.scrollTop),onBlur:F=>{var le,Ce;(Ce=(le=F.relatedTarget)==null?void 0:le.closest)!=null&&Ce.call(le,".chat-paper-picker")||window.setTimeout(q.close,0)},onKeyDown:F=>{q.keyDown(F)||F.key==="Enter"&&!F.shiftKey&&!F.nativeEvent.isComposing&&(F.preventDefault(),L())},role:"combobox","aria-expanded":q.open,"aria-controls":q.open?q.pickerId:void 0,"aria-activedescendant":q.open&&q.results.length?`${q.optionIdPrefix}-${q.activeIndex}`:void 0,"aria-autocomplete":"list","aria-describedby":[h,q.message?"chat-paper-mention-message":null].filter(Boolean).join(" ")||void 0}),b.jsx(lu,{open:q.open,query:q.query,results:q.results,activeIndex:q.activeIndex,loading:q.loading,error:q.error,onSelect:q.select,id:q.pickerId,optionIdPrefix:q.optionIdPrefix})]}),q.message&&b.jsx("div",{id:"chat-paper-mention-message",className:"chat-paper-mention-message",role:"alert",children:q.message}),b.jsxs("div",{className:"chat-composer-row",children:[b.jsxs("div",{className:"chat-composer-tools",children:[i.length>0&&c&&l&&b.jsx(xh,{models:i,selectedModel:c,onModelChange:l,disabled:t}),$&&b.jsx(Ah,{value:f,onChange:$,disabled:t}),v&&g&&b.jsx(Mh,{enabled:y,onChange:g,disabled:t}),b.jsx("span",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]}),b.jsx("button",{type:"button",className:`chat-send${t||re?" chat-send-on":""}`,onClick:t?a:L,disabled:d||(t?!a:!re),"aria-label":t?"Stop generating":"Send message",children:t?a?b.jsx("span",{"aria-hidden":"true",children:"■"}):b.jsx(da,{light:!0}):b.jsx(zh,{})})]})]})},oo=new Map,hu=e=>{if(!e)return Promise.resolve();const t=oo.get(e);if(t)return t;const r=new Promise(n=>{const s=new Image;s.onload=()=>{n()},s.onerror=()=>{oo.delete(e),n()},s.src=e});return oo.set(e,r),r},rp=new Set(["huggingface.co","www.huggingface.co"]),np=new Set(["api","blog","chat","collections","docs","enterprise","join","login","models","new","organizations","papers","posts","pricing","search","settings","spaces","tasks"]);function sp(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!=="https:"||!rp.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"&&np.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 op=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,ap=({repo:e})=>{const[t,r]=H.useState(!1);return b.jsxs("div",{className:"hf-preview-card",children:[t?b.jsx("div",{className:"hf-preview-fallback","aria-hidden":"true",children:"🤗"}):b.jsx("img",{className:"hf-preview-image","data-testid":"hf-preview-image",src:e.thumbnailUrl,alt:"",loading:"eager",decoding:"async",onError:()=>r(!0)}),b.jsxs("div",{className:"hf-preview-meta",children:[b.jsxs("span",{className:"hf-preview-kind",children:["Hugging Face ",e.type]}),b.jsx("strong",{children:e.repoId}),b.jsx("span",{children:"huggingface.co"})]})]})},ip=({repo:e,children:t})=>{const[r,n]=H.useState(!1),s=H.useRef(null),o=H.useCallback(()=>{hu(e.thumbnailUrl)},[e.thumbnailUrl]);return H.useEffect(()=>{const a=s.current;if(!a||typeof IntersectionObserver>"u")return;const i=new IntersectionObserver(([c])=>{c.isIntersecting&&(o(),i.disconnect())},{rootMargin:"200px"});return i.observe(a),()=>i.disconnect()},[o]),b.jsxs(As,{open:r,onOpenChange:a=>{(!a||!op())&&n(a)},openDelay:150,closeDelay:100,children:[b.jsx(Ms,{asChild:!0,children:b.jsx("a",{ref:s,className:"chat-paper-link chat-hf-link",href:e.url,target:"_blank",rel:"noopener noreferrer",onPointerEnter:o,onFocus:o,children:t})}),b.jsx(zs,{className:"hf-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:b.jsx(ap,{repo:e})})]})},cp=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,lp=({repo:e,preview:t,unavailable:r})=>{const[n,s]=H.useState(!1),o=!!(t!=null&&t.avatarUrl)&&!n;return b.jsxs("div",{className:"github-preview-card",children:[o?b.jsx("img",{className:"github-preview-image","data-testid":"github-preview-image",src:t==null?void 0:t.avatarUrl,alt:"",loading:"eager",decoding:"async",onError:()=>s(!0)}):b.jsx("div",{className:"github-preview-fallback","aria-hidden":"true",children:b.jsx(fa,{})}),b.jsxs("div",{className:"github-preview-meta",children:[b.jsx("span",{className:"github-preview-kind",children:"GitHub repository"}),b.jsx("strong",{children:e.repoId}),(t==null?void 0:t.description)&&b.jsx("span",{className:"github-preview-description",children:t.description}),t?b.jsxs("span",{className:"github-preview-stats",children:[t.language&&b.jsxs(b.Fragment,{children:[t.language," · "]}),"★ ",t.stars.toLocaleString()," · ⑂ ",t.forks.toLocaleString(),t.archived&&b.jsx(b.Fragment,{children:" · Archived"})]}):b.jsx("span",{children:r?"Preview unavailable":"Loading preview…"})]})]})},up=({repo:e,children:t})=>{var l;const[r,n]=H.useState(!1),[s,o]=H.useState(!1),a=H.useRef(null),i=H.useCallback(()=>o(!0),[]),c=ns({queryKey:["github-repository-preview",e.repoId.toLowerCase()],queryFn:({signal:d})=>Fh(e,d),enabled:r||s,staleTime:30*60*1e3,gcTime:60*60*1e3,retry:!1});return H.useEffect(()=>{const d=a.current;if(!d||typeof IntersectionObserver>"u")return;const h=new IntersectionObserver(([m])=>{m.isIntersecting&&(i(),h.disconnect())},{rootMargin:"200px"});return h.observe(d),()=>h.disconnect()},[i]),H.useEffect(()=>{var d;(d=c.data)!=null&&d.avatarUrl&&hu(c.data.avatarUrl)},[(l=c.data)==null?void 0:l.avatarUrl]),b.jsxs(As,{open:r,onOpenChange:d=>{(!d||!cp())&&n(d)},openDelay:150,closeDelay:100,children:[b.jsx(Ms,{asChild:!0,children:b.jsxs("a",{ref:a,className:"chat-github-link",href:e.url,target:"_blank",rel:"noopener noreferrer",onPointerEnter:i,onFocus:i,children:[b.jsx(fa,{"aria-hidden":"true"}),t]})}),b.jsx(zs,{className:"github-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:b.jsx(lp,{repo:e,preview:c.data,unavailable:c.isError})})]})},dp=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches;function fp(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return"Web source"}}const hp=({citation:e})=>{const[t,r]=H.useState(!1),[n,s]=H.useState(!1),o=e.thumbnail_url,a=e.favicon_url;return b.jsxs("div",{className:"web-preview-card",children:[o&&!t&&b.jsx("img",{className:"web-preview-image","data-testid":"web-preview-image",src:o,alt:"",loading:"eager",decoding:"async",referrerPolicy:"no-referrer",onError:()=>r(!0)}),b.jsxs("div",{className:"web-preview-meta",children:[b.jsxs("div",{className:"web-preview-source",children:[a&&!n&&b.jsx("img",{src:a,alt:"",loading:"eager",decoding:"async",referrerPolicy:"no-referrer",onError:()=>s(!0)}),b.jsx("span",{children:fp(e.url??"")}),e.published&&b.jsxs(b.Fragment,{children:[b.jsx("span",{"aria-hidden":"true",children:"·"}),b.jsx("time",{children:e.published.slice(0,10)})]})]}),b.jsx("strong",{children:e.title}),e.excerpt&&b.jsx("p",{children:e.excerpt.replace(/\s+/g," ").trim()})]})]})},pp=({citation:e,children:t})=>{const[r,n]=H.useState(!1),s=e.url??"";return b.jsxs(As,{open:r,onOpenChange:o=>{(!o||!dp())&&n(o)},openDelay:150,closeDelay:100,children:[b.jsx(Ms,{asChild:!0,children:b.jsx("a",{href:s,className:"chat-web-citation",target:"_blank",rel:"noopener noreferrer",children:t})}),b.jsx(zs,{className:"web-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:b.jsx(hp,{citation:e})})]})},mp=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,gp=e=>e==="semantic_scholar"?"Semantic Scholar":"External paper",_p=({citation:e})=>{var t,r;return b.jsxs("div",{className:"external-paper-preview-card",children:[b.jsxs("div",{className:"external-paper-preview-source",children:[b.jsx("span",{children:gp(e.provider)}),e.published&&b.jsxs(b.Fragment,{children:[b.jsx("span",{"aria-hidden":"true",children:"·"}),b.jsx("time",{children:e.published.slice(0,10)})]})]}),b.jsx("strong",{children:e.title}),(((t=e.authors)==null?void 0:t.length)??0)>0&&b.jsx("p",{className:"external-paper-preview-authors",children:(r=e.authors)==null?void 0:r.join(", ")}),e.excerpt&&b.jsx("p",{children:e.excerpt.replace(/\s+/g," ").trim()}),e.citation_count!==null&&e.citation_count!==void 0&&b.jsxs("span",{className:"external-paper-preview-citations",children:[e.citation_count.toLocaleString()," citations"]})]})},yp=({citation:e,children:t})=>{const[r,n]=H.useState(!1);return b.jsxs(As,{open:r,onOpenChange:s=>{(!s||!mp())&&n(s)},openDelay:150,closeDelay:100,children:[b.jsx(Ms,{asChild:!0,children:b.jsx("a",{href:e.url??"",className:"chat-external-paper-citation",target:"_blank",rel:"noopener noreferrer",children:t})}),b.jsx(zs,{className:"external-paper-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:b.jsx(_p,{citation:e})})]})};function vp(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 zc(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 pu=({routeId:e,paper:t,citation:r,className:n="chat-paper-link",children:s})=>b.jsx(du,{routeId:e,initialData:wp(e,t,r),className:n,target:"_blank",children:s});function bp(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 Sp=e=>e.startsWith("paper:")?e:Gh(e);function Ep(e){try{const t=new URL(e);return t.protocol==="https:"&&(t.hostname==="github.com"||t.hostname==="www.github.com")}catch{return!1}}const ko=({text:e,streaming:t,papers:r,citations:n,webCitations:s})=>{const o=$p(t?bp(e):e);return b.jsx(Zh,{remarkPlugins:[Kh,Hh],rehypePlugins:[Vh],urlTransform:Sp,components:{a:({href:a,children:i})=>{if(a!=null&&a.startsWith("paper:")){const d=a.slice(6);return!r[d]&&!(n!=null&&n[d])?b.jsx("span",{className:"chat-invalid-citation",children:i}):b.jsx(pu,{routeId:d,paper:r[d],citation:n==null?void 0:n[d],children:i})}const c=a?sp(a):null;if(c)return b.jsx(ip,{repo:c,children:i});const l=a?Lh(a):null;return l?b.jsx(up,{repo:l,children:i}):a&&Ep(a)?b.jsxs("a",{href:a,className:"chat-github-link",target:"_blank",rel:"noopener noreferrer",children:[b.jsx(fa,{"aria-hidden":"true"}),i]}):a!=null&&a.startsWith("https://")&&(s!=null&&s[a])?s[a].source_type==="paper"?b.jsx(yp,{citation:s[a],children:i}):b.jsx(pp,{citation:s[a],children:i}):a!=null&&a.startsWith("https://")?b.jsx("a",{href:a,className:"chat-external-link",target:"_blank",rel:"noopener noreferrer",children:i}):b.jsx("span",{children:i})}},children:o})},kp=Object.freeze({status:"aborted"});function A(e,t,r){function n(i,c){var l;Object.defineProperty(i,"_zod",{value:i._zod??{},enumerable:!1}),(l=i._zod).traits??(l.traits=new Set),i._zod.traits.add(e),t(i,c);for(const d in a.prototype)d in i||Object.defineProperty(i,d,{value:a.prototype[d].bind(i)});i._zod.constr=a,i._zod.def=c}const s=(r==null?void 0:r.Parent)??Object;class o extends s{}Object.defineProperty(o,"name",{value:e});function a(i){var c;const l=r!=null&&r.Parent?new o:this;n(l,i),(c=l._zod).deferred??(c.deferred=[]);for(const d of l._zod.deferred)d();return l}return Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:i=>{var c,l;return r!=null&&r.Parent&&i instanceof r.Parent?!0:(l=(c=i==null?void 0:i._zod)==null?void 0:c.traits)==null?void 0:l.has(e)}}),Object.defineProperty(a,"name",{value:e}),a}class $n extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const mu={};function Ut(e){return mu}function Pp(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,s])=>t.indexOf(+n)===-1).map(([n,s])=>s)}function Rp(e,t){return typeof t=="bigint"?t.toString():t}function ha(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function pa(e){return e==null}function ma(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Tp(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 Ee(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 qs(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Xr(e){return JSON.stringify(e)}const gu=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function ms(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Cp=ha(()=>{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 gs(e){if(ms(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(ms(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}const jp=new Set(["string","number","symbol"]);function Pn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function br(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 B(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Np(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Ip={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Op(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 br(e,{...e._zod.def,shape:r,checks:[]})}function xp(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 br(e,{...e._zod.def,shape:r,checks:[]})}function Ap(e,t){if(!gs(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 qs(this,"shape",n),n},checks:[]};return br(e,r)}function Mp(e,t){return br(e,{...e._zod.def,get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return qs(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function zp(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 br(t,{...t._zod.def,shape:s,checks:[]})}function Dp(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 br(t,{...t._zod.def,shape:s,checks:[]})}function ln(e,t=0){var r;for(let n=t;n{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Ln(e){return typeof e=="string"?e:e==null?void 0:e.message}function Ft(e,t,r){var s,o,a,i,c,l;const n={...e,path:e.path??[]};if(!e.message){const d=Ln((a=(o=(s=e.inst)==null?void 0:s._zod.def)==null?void 0:o.error)==null?void 0:a.call(o,e))??Ln((i=t==null?void 0:t.error)==null?void 0:i.call(t,e))??Ln((c=r.customError)==null?void 0:c.call(r,e))??Ln((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 ga(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function wn(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const _u=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,Rp,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},yu=A("$ZodError",_u),vu=A("$ZodError",_u,{Parent:Error});function qp(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 Up(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 $n;if(a.issues.length){const i=new((s==null?void 0:s.Err)??e)(a.issues.map(c=>Ft(c,o,Ut())));throw gu(i,s==null?void 0:s.callee),i}return a.value},Lp=e=>async(t,r,n,s)=>{const o=n?Object.assign(n,{async:!0}):{async:!0};let a=t._zod.run({value:r,issues:[]},o);if(a instanceof Promise&&(a=await a),a.issues.length){const i=new((s==null?void 0:s.Err)??e)(a.issues.map(c=>Ft(c,o,Ut())));throw gu(i,s==null?void 0:s.callee),i}return a.value},$u=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 $n;return o.issues.length?{success:!1,error:new(e??yu)(o.issues.map(a=>Ft(a,s,Ut())))}:{success:!0,data:o.value}},wu=$u(vu),bu=e=>async(t,r,n)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let o=t._zod.run({value:r,issues:[]},s);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(a=>Ft(a,s,Ut())))}:{success:!0,data:o.value}},Vp=bu(vu),Hp=/^[cC][^\s-]{8,}$/,Zp=/^[0-9a-z]+$/,Kp=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Gp=/^[0-9a-vA-V]{20}$/,Wp=/^[A-Za-z0-9]{27}$/,Bp=/^[a-zA-Z0-9_-]{21}$/,Jp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Qp=/^([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})$/,Dc=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)$/,Yp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Xp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function em(){return new RegExp(Xp,"u")}const tm=/^(?:(?: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])$/,rm=/^(([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})$/,nm=/^((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])$/,sm=/^(([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])$/,om=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Su=/^[A-Za-z0-9_-]*$/,am=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,im=/^\+(?:[0-9]){6,14}[0-9]$/,Eu="(?:(?:\\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])))",cm=new RegExp(`^${Eu}$`);function ku(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 lm(e){return new RegExp(`^${ku(e)}$`)}function um(e){const t=ku({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(`^${Eu}T(?:${n})$`)}const dm=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}$`)},fm=/^\d+$/,hm=/^-?\d+(?:\.\d+)?/i,pm=/true|false/i,mm=/null/i,gm=/undefined/i,_m=/^[^A-Z]*$/,ym=/^[^a-z]*$/,Xe=A("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Pu={number:"number",bigint:"bigint",object:"date"},Ru=A("$ZodCheckLessThan",(e,t)=>{Xe.init(e,t);const r=Pu[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{Xe.init(e,t);const r=Pu[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})}}),vm=A("$ZodCheckMultipleOf",(e,t)=>{Xe.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):Tp(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})}}),$m=A("$ZodCheckNumberFormat",(e,t)=>{var a;Xe.init(e,t),t.format=t.format||"float64";const r=(a=t.format)==null?void 0:a.includes("int"),n=r?"int":"number",[s,o]=Ip[t.format];e._zod.onattach.push(i=>{const c=i._zod.bag;c.format=t.format,c.minimum=s,c.maximum=o,r&&(c.pattern=fm)}),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})}}),wm=A("$ZodCheckMaxLength",(e,t)=>{var r;Xe.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!pa(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=ga(s);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),bm=A("$ZodCheckMinLength",(e,t)=>{var r;Xe.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!pa(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=ga(s);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Sm=A("$ZodCheckLengthEquals",(e,t)=>{var r;Xe.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!pa(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=ga(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})}}),Us=A("$ZodCheckStringFormat",(e,t)=>{var r,n;Xe.init(e,t),e._zod.onattach.push(s=>{const o=s._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=s=>{t.pattern.lastIndex=0,!t.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:t.format,input:s.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Em=A("$ZodCheckRegex",(e,t)=>{Us.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})}}),km=A("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=_m),Us.init(e,t)}),Pm=A("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ym),Us.init(e,t)}),Rm=A("$ZodCheckIncludes",(e,t)=>{Xe.init(e,t);const r=Pn(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})}}),Tm=A("$ZodCheckStartsWith",(e,t)=>{Xe.init(e,t);const r=new RegExp(`^${Pn(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Cm=A("$ZodCheckEndsWith",(e,t)=>{Xe.init(e,t);const r=new RegExp(`.*${Pn(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})}}),jm=A("$ZodCheckOverwrite",(e,t)=>{Xe.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class Nm{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const n=t.split(` -`).filter(a=>a),s=Math.min(...n.map(a=>a.length-a.trimStart().length)),o=n.map(a=>a.slice(s)).map(a=>" ".repeat(this.indent*2)+a);for(const a of o)this.content.push(a)}compile(){const t=Function,r=this==null?void 0:this.args,s=[...((this==null?void 0:this.content)??[""]).map(o=>` ${o}`)];return new t(...r,s.join(` -`))}}const Im={major:4,minor:0,patch:0},we=A("$ZodType",(e,t)=>{var s;var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Im;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const o of n)for(const a of o._zod.onattach)a(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),(s=e._zod.deferred)==null||s.push(()=>{e._zod.run=e._zod.parse});else{const o=(a,i,c)=>{let l=ln(a),d;for(const h of i){if(h._zod.def.when){if(!h._zod.def.when(a))continue}else if(l)continue;const m=a.issues.length,_=h._zod.check(a);if(_ instanceof Promise&&(c==null?void 0:c.async)===!1)throw new $n;if(d||_ instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await _,a.issues.length!==m&&(l||(l=ln(a,m)))});else{if(a.issues.length===m)continue;l||(l=ln(a,m))}}return d?d.then(()=>a):a};e._zod.run=(a,i)=>{const c=e._zod.parse(a,i);if(c instanceof Promise){if(i.async===!1)throw new $n;return c.then(l=>o(l,n,i))}return o(c,n,i)}}e["~standard"]={validate:o=>{var a;try{const i=wu(e,o);return i.success?{value:i.data}:{issues:(a=i.error)==null?void 0:a.issues}}catch{return Vp(e,o).then(c=>{var l;return c.success?{value:c.data}:{issues:(l=c.error)==null?void 0:l.issues}})}},vendor:"zod",version:1}}),_a=A("$ZodString",(e,t)=>{var r;we.init(e,t),e._zod.pattern=[...((r=e==null?void 0:e._zod.bag)==null?void 0:r.patterns)??[]].pop()??dm(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}}),Pe=A("$ZodStringFormat",(e,t)=>{Us.init(e,t),_a.init(e,t)}),Om=A("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Qp),Pe.init(e,t)}),xm=A("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Dc(n))}else t.pattern??(t.pattern=Dc());Pe.init(e,t)}),Am=A("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Yp),Pe.init(e,t)}),Mm=A("$ZodURL",(e,t)=>{Pe.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:am.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})}}}),zm=A("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=em()),Pe.init(e,t)}),Dm=A("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Bp),Pe.init(e,t)}),qm=A("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Hp),Pe.init(e,t)}),Um=A("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Zp),Pe.init(e,t)}),Fm=A("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Kp),Pe.init(e,t)}),Lm=A("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Gp),Pe.init(e,t)}),Vm=A("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Wp),Pe.init(e,t)}),Hm=A("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=um(t)),Pe.init(e,t)}),Zm=A("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=cm),Pe.init(e,t)}),Km=A("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=lm(t)),Pe.init(e,t)}),Gm=A("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Jp),Pe.init(e,t)}),Wm=A("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=tm),Pe.init(e,t),e._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv4"})}),Bm=A("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=rm),Pe.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})}}}),Jm=A("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=nm),Pe.init(e,t)}),Qm=A("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=sm),Pe.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 Cu(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Ym=A("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=om),Pe.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),e._zod.check=r=>{Cu(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Xm(e){if(!Su.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Cu(r)}const eg=A("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Su),Pe.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),e._zod.check=r=>{Xm(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),tg=A("$ZodE164",(e,t)=>{t.pattern??(t.pattern=im),Pe.init(e,t)});function rg(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 ng=A("$ZodJWT",(e,t)=>{Pe.init(e,t),e._zod.check=r=>{rg(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),ju=A("$ZodNumber",(e,t)=>{we.init(e,t),e._zod.pattern=e._zod.bag.pattern??hm,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}}),sg=A("$ZodNumber",(e,t)=>{$m.init(e,t),ju.init(e,t)}),og=A("$ZodBoolean",(e,t)=>{we.init(e,t),e._zod.pattern=pm,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}}),ag=A("$ZodUndefined",(e,t)=>{we.init(e,t),e._zod.pattern=gm,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}}),ig=A("$ZodNull",(e,t)=>{we.init(e,t),e._zod.pattern=mm,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}}),cg=A("$ZodAny",(e,t)=>{we.init(e,t),e._zod.parse=r=>r}),lg=A("$ZodUnknown",(e,t)=>{we.init(e,t),e._zod.parse=r=>r}),ug=A("$ZodNever",(e,t)=>{we.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function qc(e,t,r){e.issues.length&&t.issues.push(...pr(r,e.issues)),t.value[r]=e.value}const dg=A("$ZodArray",(e,t)=>{we.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;aqc(l,r,a))):qc(c,r,a)}return o.length?Promise.all(o).then(()=>r):r}});function Vn(e,t,r){e.issues.length&&t.issues.push(...pr(r,e.issues)),t.value[r]=e.value}function Uc(e,t,r,n){e.issues.length?n[r]===void 0?r in n?t.value[r]=void 0:t.value[r]=e.value:t.issues.push(...pr(r,e.issues)):e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}const fg=A("$ZodObject",(e,t)=>{we.init(e,t);const r=ha(()=>{const h=Object.keys(t.shape);for(const _ of h)if(!(t.shape[_]instanceof we))throw new Error(`Invalid element at key "${_}": expected a Zod schema`);const m=Np(t.shape);return{shape:t.shape,keys:h,keySet:new Set(h),numKeys:h.length,optionalKeys:new Set(m)}});Ee(e._zod,"propValues",()=>{const h=t.shape,m={};for(const _ in h){const v=h[_]._zod;if(v.values){m[_]??(m[_]=new Set);for(const y of v.values)m[_].add(y)}}return m});const n=h=>{const m=new Nm(["shape","payload","ctx"]),_=r.value,v=$=>{const E=Xr($);return`shape[${E}]._zod.run({ value: input[${E}], issues: [] }, ctx)`};m.write("const input = payload.value;");const y=Object.create(null);let g=0;for(const $ of _.keys)y[$]=`key_${g++}`;m.write("const newResult = {}");for(const $ of _.keys)if(_.optionalKeys.has($)){const E=y[$];m.write(`const ${E} = ${v($)};`);const T=Xr($);m.write(` - if (${E}.issues.length) { - if (input[${T}] === undefined) { - if (${T} in input) { - newResult[${T}] = undefined; - } - } else { - payload.issues = payload.issues.concat( - ${E}.issues.map((iss) => ({ - ...iss, - path: iss.path ? [${T}, ...iss.path] : [${T}], - })) - ); - } - } else if (${E}.value === undefined) { - if (${T} in input) newResult[${T}] = undefined; - } else { - newResult[${T}] = ${E}.value; - } - `)}else{const E=y[$];m.write(`const ${E} = ${v($)};`),m.write(` - if (${E}.issues.length) payload.issues = payload.issues.concat(${E}.issues.map(iss => ({ - ...iss, - path: iss.path ? [${Xr($)}, ...iss.path] : [${Xr($)}] - })));`),m.write(`newResult[${Xr($)}] = ${E}.value`)}m.write("payload.value = newResult;"),m.write("return payload;");const f=m.compile();return($,E)=>f(h,$,E)};let s;const o=ms,a=!mu.jitless,c=a&&Cp.value,l=t.catchall;let d;e._zod.parse=(h,m)=>{d??(d=r.value);const _=h.value;if(!o(_))return h.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),h;const v=[];if(a&&c&&(m==null?void 0:m.async)===!1&&m.jitless!==!0)s||(s=n(t.shape)),h=s(h,m);else{h.value={};const E=d.shape;for(const T of d.keys){const R=E[T],O=R._zod.run({value:_[T],issues:[]},m),x=R._zod.optin==="optional"&&R._zod.optout==="optional";O instanceof Promise?v.push(O.then(U=>x?Uc(U,h,T,_):Vn(U,h,T))):x?Uc(O,h,T,_):Vn(O,h,T)}}if(!l)return v.length?Promise.all(v).then(()=>h):h;const y=[],g=d.keySet,f=l._zod,$=f.def.type;for(const E of Object.keys(_)){if(g.has(E))continue;if($==="never"){y.push(E);continue}const T=f.run({value:_[E],issues:[]},m);T instanceof Promise?v.push(T.then(R=>Vn(R,h,E))):Vn(T,h,E)}return y.length&&h.issues.push({code:"unrecognized_keys",keys:y,input:_,inst:e}),v.length?Promise.all(v).then(()=>h):h}});function Fc(e,t,r,n){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(o=>Ft(o,n,Ut())))}),t}const Nu=A("$ZodUnion",(e,t)=>{we.init(e,t),Ee(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),Ee(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),Ee(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),Ee(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=>ma(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=>Fc(a,r,e,n)):Fc(o,r,e,n)}}),hg=A("$ZodDiscriminatedUnion",(e,t)=>{Nu.init(e,t);const r=e._zod.parse;Ee(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=ha(()=>{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(!ms(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)}}),pg=A("$ZodIntersection",(e,t)=>{we.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])=>Lc(r,c,l)):Lc(r,o,a)}});function Po(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(gs(e)&&gs(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=Po(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{we.init(e,t),e._zod.parse=(r,n)=>{const s=r.value;if(!gs(s))return r.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),r;const o=[];if(t.keyType._zod.values){const a=t.keyType._zod.values;r.value={};for(const c of a)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){const l=t.valueType._zod.run({value:s[c],issues:[]},n);l instanceof Promise?o.push(l.then(d=>{d.issues.length&&r.issues.push(...pr(c,d.issues)),r.value[c]=d.value})):(l.issues.length&&r.issues.push(...pr(c,l.issues)),r.value[c]=l.value)}let i;for(const c in s)a.has(c)||(i=i??[],i.push(c));i&&i.length>0&&r.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:i})}else{r.value={};for(const a of Reflect.ownKeys(s)){if(a==="__proto__")continue;const i=t.keyType._zod.run({value:a,issues:[]},n);if(i instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(i.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:i.issues.map(l=>Ft(l,n,Ut())),input:a,path:[a],inst:e}),r.value[i.value]=i.value;continue}const c=t.valueType._zod.run({value:s[a],issues:[]},n);c instanceof Promise?o.push(c.then(l=>{l.issues.length&&r.issues.push(...pr(a,l.issues)),r.value[i.value]=l.value})):(c.issues.length&&r.issues.push(...pr(a,c.issues)),r.value[i.value]=c.value)}}return o.length?Promise.all(o).then(()=>r):r}}),gg=A("$ZodEnum",(e,t)=>{we.init(e,t);const r=Pp(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(n=>jp.has(typeof n)).map(n=>typeof n=="string"?Pn(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}}),_g=A("$ZodLiteral",(e,t)=>{we.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Pn(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}}),yg=A("$ZodTransform",(e,t)=>{we.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 $n;return r.value=s,r}}),vg=A("$ZodOptional",(e,t)=>{we.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ee(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ee(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${ma(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)}),$g=A("$ZodNullable",(e,t)=>{we.init(e,t),Ee(e._zod,"optin",()=>t.innerType._zod.optin),Ee(e._zod,"optout",()=>t.innerType._zod.optout),Ee(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${ma(r.source)}|null)$`):void 0}),Ee(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)}),wg=A("$ZodDefault",(e,t)=>{we.init(e,t),e._zod.optin="optional",Ee(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=>Vc(o,t)):Vc(s,t)}});function Vc(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const bg=A("$ZodPrefault",(e,t)=>{we.init(e,t),e._zod.optin="optional",Ee(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))}),Sg=A("$ZodNonOptional",(e,t)=>{we.init(e,t),Ee(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=>Hc(o,e)):Hc(s,e)}});function Hc(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Eg=A("$ZodCatch",(e,t)=>{we.init(e,t),e._zod.optin="optional",Ee(e._zod,"optout",()=>t.innerType._zod.optout),Ee(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{const s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(a=>Ft(a,n,Ut()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=t.catchValue({...r,error:{issues:s.issues.map(o=>Ft(o,n,Ut()))},input:r.value}),r.issues=[]),r)}}),kg=A("$ZodPipe",(e,t)=>{we.init(e,t),Ee(e._zod,"values",()=>t.in._zod.values),Ee(e._zod,"optin",()=>t.in._zod.optin),Ee(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=>Zc(o,t,n)):Zc(s,t,n)}});function Zc(e,t,r){return ln(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}const Pg=A("$ZodReadonly",(e,t)=>{we.init(e,t),Ee(e._zod,"propValues",()=>t.innerType._zod.propValues),Ee(e._zod,"values",()=>t.innerType._zod.values),Ee(e._zod,"optin",()=>t.innerType._zod.optin),Ee(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(Kc):Kc(s)}});function Kc(e){return e.value=Object.freeze(e.value),e}const Rg=A("$ZodCustom",(e,t)=>{Xe.init(e,t),we.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=>Gc(o,r,n,e));Gc(s,r,n,e)}});function Gc(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(wn(s))}}class Tg{constructor(){this._map=new Map,this._idmap=new Map}add(t,...r){const n=r[0];if(this._map.set(t,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,t)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(t){const r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){const r=t._zod.parent;if(r){const n={...this.get(r)??{}};return delete n.id,{...n,...this._map.get(t)}}return this._map.get(t)}has(t){return this._map.has(t)}}function Cg(){return new Tg}const Hn=Cg();function jg(e,t){return new e({type:"string",...B(t)})}function Ng(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...B(t)})}function Wc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...B(t)})}function Ig(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...B(t)})}function Og(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...B(t)})}function xg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...B(t)})}function Ag(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...B(t)})}function Iu(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...B(t)})}function Mg(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...B(t)})}function zg(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...B(t)})}function Dg(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...B(t)})}function qg(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...B(t)})}function Ug(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...B(t)})}function Fg(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...B(t)})}function Lg(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...B(t)})}function Vg(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...B(t)})}function Hg(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...B(t)})}function Zg(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...B(t)})}function Kg(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...B(t)})}function Gg(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...B(t)})}function Wg(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...B(t)})}function Bg(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...B(t)})}function Jg(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...B(t)})}function Qg(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...B(t)})}function Yg(e,t){return new e({type:"string",format:"date",check:"string_format",...B(t)})}function Xg(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...B(t)})}function e_(e,t){return new e({type:"string",format:"duration",check:"string_format",...B(t)})}function t_(e,t){return new e({type:"number",checks:[],...B(t)})}function r_(e,t){return new e({type:"number",coerce:!0,checks:[],...B(t)})}function n_(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...B(t)})}function s_(e,t){return new e({type:"boolean",...B(t)})}function o_(e,t){return new e({type:"undefined",...B(t)})}function a_(e,t){return new e({type:"null",...B(t)})}function i_(e){return new e({type:"any"})}function c_(e){return new e({type:"unknown"})}function l_(e,t){return new e({type:"never",...B(t)})}function Bc(e,t){return new Ru({check:"less_than",...B(t),value:e,inclusive:!1})}function ao(e,t){return new Ru({check:"less_than",...B(t),value:e,inclusive:!0})}function Jc(e,t){return new Tu({check:"greater_than",...B(t),value:e,inclusive:!1})}function io(e,t){return new Tu({check:"greater_than",...B(t),value:e,inclusive:!0})}function Qc(e,t){return new vm({check:"multiple_of",...B(t),value:e})}function Ou(e,t){return new wm({check:"max_length",...B(t),maximum:e})}function _s(e,t){return new bm({check:"min_length",...B(t),minimum:e})}function xu(e,t){return new Sm({check:"length_equals",...B(t),length:e})}function u_(e,t){return new Em({check:"string_format",format:"regex",...B(t),pattern:e})}function d_(e){return new km({check:"string_format",format:"lowercase",...B(e)})}function f_(e){return new Pm({check:"string_format",format:"uppercase",...B(e)})}function h_(e,t){return new Rm({check:"string_format",format:"includes",...B(t),includes:e})}function p_(e,t){return new Tm({check:"string_format",format:"starts_with",...B(t),prefix:e})}function m_(e,t){return new Cm({check:"string_format",format:"ends_with",...B(t),suffix:e})}function Rn(e){return new jm({check:"overwrite",tx:e})}function g_(e){return Rn(t=>t.normalize(e))}function __(){return Rn(e=>e.trim())}function y_(){return Rn(e=>e.toLowerCase())}function v_(){return Rn(e=>e.toUpperCase())}function $_(e,t,r){return new e({type:"array",element:t,...B(r)})}function w_(e,t,r){const n=B(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function b_(e,t,r){return new e({type:"custom",check:"custom",fn:t,...B(r)})}const S_=A("ZodISODateTime",(e,t)=>{Hm.init(e,t),Te.init(e,t)});function Au(e){return Qg(S_,e)}const E_=A("ZodISODate",(e,t)=>{Zm.init(e,t),Te.init(e,t)});function k_(e){return Yg(E_,e)}const P_=A("ZodISOTime",(e,t)=>{Km.init(e,t),Te.init(e,t)});function R_(e){return Xg(P_,e)}const T_=A("ZodISODuration",(e,t)=>{Gm.init(e,t),Te.init(e,t)});function C_(e){return e_(T_,e)}const j_=(e,t)=>{yu.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Up(e,r)},flatten:{value:r=>qp(e,r)},addIssue:{value:r=>e.issues.push(r)},addIssues:{value:r=>e.issues.push(...r)},isEmpty:{get(){return e.issues.length===0}}})},Fs=A("ZodError",j_,{Parent:Error}),N_=Fp(Fs),I_=Lp(Fs),O_=$u(Fs),x_=bu(Fs),ke=A("ZodType",(e,t)=>(we.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)=>br(e,r,n),e.brand=()=>e,e.register=(r,n)=>(r.add(e,n),e),e.parse=(r,n)=>N_(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>O_(e,r,n),e.parseAsync=async(r,n)=>I_(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>x_(e,r,n),e.spa=e.safeParseAsync,e.refine=(r,n)=>e.check(Py(r,n)),e.superRefine=r=>e.check(Ry(r)),e.overwrite=r=>e.check(Rn(r)),e.optional=()=>Re(e),e.nullable=()=>el(e),e.nullish=()=>Re(el(e)),e.nonoptional=r=>yy(e,r),e.array=()=>V(e),e.or=r=>pe([e,r]),e.and=r=>$a(e,r),e.transform=r=>jo(e,Fu(r)),e.default=r=>my(e,r),e.prefault=r=>_y(e,r),e.catch=r=>$y(e,r),e.pipe=r=>jo(e,r),e.readonly=()=>Sy(e),e.describe=r=>{const n=e.clone();return Hn.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){var r;return(r=Hn.get(e))==null?void 0:r.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return Hn.get(e);const n=e.clone();return Hn.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Mu=A("_ZodString",(e,t)=>{_a.init(e,t),ke.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(u_(...n)),e.includes=(...n)=>e.check(h_(...n)),e.startsWith=(...n)=>e.check(p_(...n)),e.endsWith=(...n)=>e.check(m_(...n)),e.min=(...n)=>e.check(_s(...n)),e.max=(...n)=>e.check(Ou(...n)),e.length=(...n)=>e.check(xu(...n)),e.nonempty=(...n)=>e.check(_s(1,...n)),e.lowercase=n=>e.check(d_(n)),e.uppercase=n=>e.check(f_(n)),e.trim=()=>e.check(__()),e.normalize=(...n)=>e.check(g_(...n)),e.toLowerCase=()=>e.check(y_()),e.toUpperCase=()=>e.check(v_())}),A_=A("ZodString",(e,t)=>{_a.init(e,t),Mu.init(e,t),e.email=r=>e.check(Ng(M_,r)),e.url=r=>e.check(Iu(zu,r)),e.jwt=r=>e.check(Jg(Y_,r)),e.emoji=r=>e.check(Mg(D_,r)),e.guid=r=>e.check(Wc(Yc,r)),e.uuid=r=>e.check(Ig(Zn,r)),e.uuidv4=r=>e.check(Og(Zn,r)),e.uuidv6=r=>e.check(xg(Zn,r)),e.uuidv7=r=>e.check(Ag(Zn,r)),e.nanoid=r=>e.check(zg(q_,r)),e.guid=r=>e.check(Wc(Yc,r)),e.cuid=r=>e.check(Dg(U_,r)),e.cuid2=r=>e.check(qg(F_,r)),e.ulid=r=>e.check(Ug(L_,r)),e.base64=r=>e.check(Gg(B_,r)),e.base64url=r=>e.check(Wg(J_,r)),e.xid=r=>e.check(Fg(V_,r)),e.ksuid=r=>e.check(Lg(H_,r)),e.ipv4=r=>e.check(Vg(Z_,r)),e.ipv6=r=>e.check(Hg(K_,r)),e.cidrv4=r=>e.check(Zg(G_,r)),e.cidrv6=r=>e.check(Kg(W_,r)),e.e164=r=>e.check(Bg(Q_,r)),e.datetime=r=>e.check(Au(r)),e.date=r=>e.check(k_(r)),e.time=r=>e.check(R_(r)),e.duration=r=>e.check(C_(r))});function P(e){return jg(A_,e)}const Te=A("ZodStringFormat",(e,t)=>{Pe.init(e,t),Mu.init(e,t)}),M_=A("ZodEmail",(e,t)=>{Am.init(e,t),Te.init(e,t)}),Yc=A("ZodGUID",(e,t)=>{Om.init(e,t),Te.init(e,t)}),Zn=A("ZodUUID",(e,t)=>{xm.init(e,t),Te.init(e,t)}),zu=A("ZodURL",(e,t)=>{Mm.init(e,t),Te.init(e,t)});function z_(e){return Iu(zu,e)}const D_=A("ZodEmoji",(e,t)=>{zm.init(e,t),Te.init(e,t)}),q_=A("ZodNanoID",(e,t)=>{Dm.init(e,t),Te.init(e,t)}),U_=A("ZodCUID",(e,t)=>{qm.init(e,t),Te.init(e,t)}),F_=A("ZodCUID2",(e,t)=>{Um.init(e,t),Te.init(e,t)}),L_=A("ZodULID",(e,t)=>{Fm.init(e,t),Te.init(e,t)}),V_=A("ZodXID",(e,t)=>{Lm.init(e,t),Te.init(e,t)}),H_=A("ZodKSUID",(e,t)=>{Vm.init(e,t),Te.init(e,t)}),Z_=A("ZodIPv4",(e,t)=>{Wm.init(e,t),Te.init(e,t)}),K_=A("ZodIPv6",(e,t)=>{Bm.init(e,t),Te.init(e,t)}),G_=A("ZodCIDRv4",(e,t)=>{Jm.init(e,t),Te.init(e,t)}),W_=A("ZodCIDRv6",(e,t)=>{Qm.init(e,t),Te.init(e,t)}),B_=A("ZodBase64",(e,t)=>{Ym.init(e,t),Te.init(e,t)}),J_=A("ZodBase64URL",(e,t)=>{eg.init(e,t),Te.init(e,t)}),Q_=A("ZodE164",(e,t)=>{tg.init(e,t),Te.init(e,t)}),Y_=A("ZodJWT",(e,t)=>{ng.init(e,t),Te.init(e,t)}),ya=A("ZodNumber",(e,t)=>{ju.init(e,t),ke.init(e,t),e.gt=(n,s)=>e.check(Jc(n,s)),e.gte=(n,s)=>e.check(io(n,s)),e.min=(n,s)=>e.check(io(n,s)),e.lt=(n,s)=>e.check(Bc(n,s)),e.lte=(n,s)=>e.check(ao(n,s)),e.max=(n,s)=>e.check(ao(n,s)),e.int=n=>e.check(Xc(n)),e.safe=n=>e.check(Xc(n)),e.positive=n=>e.check(Jc(0,n)),e.nonnegative=n=>e.check(io(0,n)),e.negative=n=>e.check(Bc(0,n)),e.nonpositive=n=>e.check(ao(0,n)),e.multipleOf=(n,s)=>e.check(Qc(n,s)),e.step=(n,s)=>e.check(Qc(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 ie(e){return t_(ya,e)}const X_=A("ZodNumberFormat",(e,t)=>{sg.init(e,t),ya.init(e,t)});function Xc(e){return n_(X_,e)}const ey=A("ZodBoolean",(e,t)=>{og.init(e,t),ke.init(e,t)});function me(e){return s_(ey,e)}const ty=A("ZodUndefined",(e,t)=>{ag.init(e,t),ke.init(e,t)});function Ro(e){return o_(ty,e)}const ry=A("ZodNull",(e,t)=>{ig.init(e,t),ke.init(e,t)});function ny(e){return a_(ry,e)}const sy=A("ZodAny",(e,t)=>{cg.init(e,t),ke.init(e,t)});function va(){return i_(sy)}const oy=A("ZodUnknown",(e,t)=>{lg.init(e,t),ke.init(e,t)});function $e(){return c_(oy)}const ay=A("ZodNever",(e,t)=>{ug.init(e,t),ke.init(e,t)});function To(e){return l_(ay,e)}const iy=A("ZodArray",(e,t)=>{dg.init(e,t),ke.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(_s(r,n)),e.nonempty=r=>e.check(_s(1,r)),e.max=(r,n)=>e.check(Ou(r,n)),e.length=(r,n)=>e.check(xu(r,n)),e.unwrap=()=>e.element});function V(e,t){return $_(iy,e,t)}const Du=A("ZodObject",(e,t)=>{fg.init(e,t),ke.init(e,t),Ee(e,"shape",()=>t.shape),e.keyof=()=>tt(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:$e()}),e.loose=()=>e.clone({...e._zod.def,catchall:$e()}),e.strict=()=>e.clone({...e._zod.def,catchall:To()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>Ap(e,r),e.merge=r=>Mp(e,r),e.pick=r=>Op(e,r),e.omit=r=>xp(e,r),e.partial=(...r)=>zp(Lu,e,r[0]),e.required=(...r)=>Dp(Vu,e,r[0])});function I(e,t){const r={type:"object",get shape(){return qs(this,"shape",{...e}),this.shape},...B(t)};return new Du(r)}function Le(e,t){return new Du({type:"object",get shape(){return qs(this,"shape",{...e}),this.shape},catchall:$e(),...B(t)})}const qu=A("ZodUnion",(e,t)=>{Nu.init(e,t),ke.init(e,t),e.options=t.options});function pe(e,t){return new qu({type:"union",options:e,...B(t)})}const cy=A("ZodDiscriminatedUnion",(e,t)=>{qu.init(e,t),hg.init(e,t)});function Uu(e,t,r){return new cy({type:"union",options:t,discriminator:e,...B(r)})}const ly=A("ZodIntersection",(e,t)=>{pg.init(e,t),ke.init(e,t)});function $a(e,t){return new ly({type:"intersection",left:e,right:t})}const uy=A("ZodRecord",(e,t)=>{mg.init(e,t),ke.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function ge(e,t,r){return new uy({type:"record",keyType:e,valueType:t,...B(r)})}const Co=A("ZodEnum",(e,t)=>{gg.init(e,t),ke.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 Co({...t,checks:[],...B(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 Co({...t,checks:[],...B(s),entries:o})}});function tt(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Co({type:"enum",entries:r,...B(t)})}const dy=A("ZodLiteral",(e,t)=>{_g.init(e,t),ke.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 j(e,t){return new dy({type:"literal",values:Array.isArray(e)?e:[e],...B(t)})}const fy=A("ZodTransform",(e,t)=>{yg.init(e,t),ke.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=o=>{if(typeof o=="string")r.issues.push(wn(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(wn(a))}};const s=t.transform(r.value,r);return s instanceof Promise?s.then(o=>(r.value=o,r)):(r.value=s,r)}});function Fu(e){return new fy({type:"transform",transform:e})}const Lu=A("ZodOptional",(e,t)=>{vg.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Re(e){return new Lu({type:"optional",innerType:e})}const hy=A("ZodNullable",(e,t)=>{$g.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType});function el(e){return new hy({type:"nullable",innerType:e})}const py=A("ZodDefault",(e,t)=>{wg.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function my(e,t){return new py({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const gy=A("ZodPrefault",(e,t)=>{bg.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType});function _y(e,t){return new gy({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const Vu=A("ZodNonOptional",(e,t)=>{Sg.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType});function yy(e,t){return new Vu({type:"nonoptional",innerType:e,...B(t)})}const vy=A("ZodCatch",(e,t)=>{Eg.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function $y(e,t){return new vy({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const wy=A("ZodPipe",(e,t)=>{kg.init(e,t),ke.init(e,t),e.in=t.in,e.out=t.out});function jo(e,t){return new wy({type:"pipe",in:e,out:t})}const by=A("ZodReadonly",(e,t)=>{Pg.init(e,t),ke.init(e,t)});function Sy(e){return new by({type:"readonly",innerType:e})}const Hu=A("ZodCustom",(e,t)=>{Rg.init(e,t),ke.init(e,t)});function Ey(e){const t=new Xe({check:"custom"});return t._zod.check=e,t}function ky(e,t){return w_(Hu,e??(()=>!0),t)}function Py(e,t={}){return b_(Hu,e,t)}function Ry(e){const t=Ey(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(wn(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(wn(s))}},e(r.value,r)));return t}function Zu(e,t){return jo(Fu(e),t)}const Ty={custom:"custom"};function Cy(e){return r_(ya,e)}const Ls="2025-11-25",jy=[Ls,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],ir="io.modelcontextprotocol/related-task",Vs="2.0",Ae=ky(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Ku=pe([P(),ie().int()]),Gu=P();Le({ttl:ie().optional(),pollInterval:ie().optional()});const Ny=I({ttl:ie().optional()}),Iy=I({taskId:P()}),wa=Le({progressToken:Ku.optional(),[ir]:Iy.optional()}),rt=I({_meta:wa.optional()}),Tn=rt.extend({task:Ny.optional()}),Oy=e=>Tn.safeParse(e).success,Ve=I({method:P(),params:rt.loose().optional()}),ot=I({_meta:wa.optional()}),at=I({method:P(),params:ot.loose().optional()}),He=Le({_meta:wa.optional()}),Cn=pe([P(),ie().int()]),Wu=I({jsonrpc:j(Vs),id:Cn,...Ve.shape}).strict(),No=e=>Wu.safeParse(e).success,Bu=I({jsonrpc:j(Vs),...at.shape}).strict(),xy=e=>Bu.safeParse(e).success,ba=I({jsonrpc:j(Vs),id:Cn,result:He}).strict(),sn=e=>ba.safeParse(e).success;var ne;(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"})(ne||(ne={}));const Sa=I({jsonrpc:j(Vs),id:Cn.optional(),error:I({code:ie().int(),message:P(),data:$e().optional()})}).strict(),Ay=e=>Sa.safeParse(e).success,ss=pe([Wu,Bu,ba,Sa]);pe([ba,Sa]);const Nr=He.strict(),My=ot.extend({requestId:Cn.optional(),reason:P().optional()}),Ea=at.extend({method:j("notifications/cancelled"),params:My}),zy=I({src:P(),mimeType:P().optional(),sizes:V(P()).optional(),theme:tt(["light","dark"]).optional()}),jn=I({icons:V(zy).optional()}),Dr=I({name:P(),title:P().optional()}),Hs=Dr.extend({...Dr.shape,...jn.shape,version:P(),websiteUrl:P().optional(),description:P().optional()}),Dy=$a(I({applyDefaults:me().optional()}),ge(P(),$e())),qy=Zu(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,$a(I({form:Dy.optional(),url:Ae.optional()}),ge(P(),$e()).optional())),Uy=Le({list:Ae.optional(),cancel:Ae.optional(),requests:Le({sampling:Le({createMessage:Ae.optional()}).optional(),elicitation:Le({create:Ae.optional()}).optional()}).optional()}),Fy=Le({list:Ae.optional(),cancel:Ae.optional(),requests:Le({tools:Le({call:Ae.optional()}).optional()}).optional()}),Ly=I({experimental:ge(P(),Ae).optional(),sampling:I({context:Ae.optional(),tools:Ae.optional()}).optional(),elicitation:qy.optional(),roots:I({listChanged:me().optional()}).optional(),tasks:Uy.optional(),extensions:ge(P(),Ae).optional()}),Vy=rt.extend({protocolVersion:P(),capabilities:Ly,clientInfo:Hs}),Hy=Ve.extend({method:j("initialize"),params:Vy}),Zy=I({experimental:ge(P(),Ae).optional(),logging:Ae.optional(),completions:Ae.optional(),prompts:I({listChanged:me().optional()}).optional(),resources:I({subscribe:me().optional(),listChanged:me().optional()}).optional(),tools:I({listChanged:me().optional()}).optional(),tasks:Fy.optional(),extensions:ge(P(),Ae).optional()}),Ju=He.extend({protocolVersion:P(),capabilities:Zy,serverInfo:Hs,instructions:P().optional()}),Qu=at.extend({method:j("notifications/initialized"),params:ot.optional()}),Ky=e=>Qu.safeParse(e).success,Zs=Ve.extend({method:j("ping"),params:rt.optional()}),Gy=I({progress:ie(),total:Re(ie()),message:Re(P())}),Wy=I({...ot.shape,...Gy.shape,progressToken:Ku}),ka=at.extend({method:j("notifications/progress"),params:Wy}),By=rt.extend({cursor:Gu.optional()}),Nn=Ve.extend({params:By.optional()}),In=He.extend({nextCursor:Gu.optional()}),Jy=tt(["working","input_required","completed","failed","cancelled"]),On=I({taskId:P(),status:Jy,ttl:pe([ie(),ny()]),createdAt:P(),lastUpdatedAt:P(),pollInterval:Re(ie()),statusMessage:Re(P())}),bn=He.extend({task:On}),Qy=ot.merge(On),ys=at.extend({method:j("notifications/tasks/status"),params:Qy}),Pa=Ve.extend({method:j("tasks/get"),params:rt.extend({taskId:P()})}),Ra=He.merge(On),Ta=Ve.extend({method:j("tasks/result"),params:rt.extend({taskId:P()})});He.loose();const Ca=Nn.extend({method:j("tasks/list")}),ja=In.extend({tasks:V(On)}),Na=Ve.extend({method:j("tasks/cancel"),params:rt.extend({taskId:P()})}),Yy=He.merge(On),Yu=I({uri:P(),mimeType:Re(P()),_meta:ge(P(),$e()).optional()}),Xu=Yu.extend({text:P()}),Ia=P().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),ed=Yu.extend({blob:Ia}),xn=tt(["user","assistant"]),Hr=I({audience:V(xn).optional(),priority:ie().min(0).max(1).optional(),lastModified:Au({offset:!0}).optional()}),td=I({...Dr.shape,...jn.shape,uri:P(),description:Re(P()),mimeType:Re(P()),size:Re(ie()),annotations:Hr.optional(),_meta:Re(Le({}))}),Xy=I({...Dr.shape,...jn.shape,uriTemplate:P(),description:Re(P()),mimeType:Re(P()),annotations:Hr.optional(),_meta:Re(Le({}))}),rd=Nn.extend({method:j("resources/list")}),Oa=In.extend({resources:V(td)}),nd=Nn.extend({method:j("resources/templates/list")}),xa=In.extend({resourceTemplates:V(Xy)}),Aa=rt.extend({uri:P()}),ev=Aa,sd=Ve.extend({method:j("resources/read"),params:ev}),Ma=He.extend({contents:V(pe([Xu,ed]))}),za=at.extend({method:j("notifications/resources/list_changed"),params:ot.optional()}),tv=Aa,rv=Ve.extend({method:j("resources/subscribe"),params:tv}),nv=Aa,sv=Ve.extend({method:j("resources/unsubscribe"),params:nv}),ov=ot.extend({uri:P()}),av=at.extend({method:j("notifications/resources/updated"),params:ov}),iv=I({name:P(),description:Re(P()),required:Re(me())}),cv=I({...Dr.shape,...jn.shape,description:Re(P()),arguments:Re(V(iv)),_meta:Re(Le({}))}),od=Nn.extend({method:j("prompts/list")}),Da=In.extend({prompts:V(cv)}),lv=rt.extend({name:P(),arguments:ge(P(),P()).optional()}),uv=Ve.extend({method:j("prompts/get"),params:lv}),qa=I({type:j("text"),text:P(),annotations:Hr.optional(),_meta:ge(P(),$e()).optional()}),Ua=I({type:j("image"),data:Ia,mimeType:P(),annotations:Hr.optional(),_meta:ge(P(),$e()).optional()}),Fa=I({type:j("audio"),data:Ia,mimeType:P(),annotations:Hr.optional(),_meta:ge(P(),$e()).optional()}),dv=I({type:j("tool_use"),name:P(),id:P(),input:ge(P(),$e()),_meta:ge(P(),$e()).optional()}),ad=I({type:j("resource"),resource:pe([Xu,ed]),annotations:Hr.optional(),_meta:ge(P(),$e()).optional()}),id=td.extend({type:j("resource_link")}),An=pe([qa,Ua,Fa,id,ad]),fv=I({role:xn,content:An}),cd=He.extend({description:P().optional(),messages:V(fv)}),La=at.extend({method:j("notifications/prompts/list_changed"),params:ot.optional()}),hv=I({title:P().optional(),readOnlyHint:me().optional(),destructiveHint:me().optional(),idempotentHint:me().optional(),openWorldHint:me().optional()}),pv=I({taskSupport:tt(["required","optional","forbidden"]).optional()}),Va=I({...Dr.shape,...jn.shape,description:P().optional(),inputSchema:I({type:j("object"),properties:ge(P(),Ae).optional(),required:V(P()).optional()}).catchall($e()),outputSchema:I({type:j("object"),properties:ge(P(),Ae).optional(),required:V(P()).optional()}).catchall($e()).optional(),annotations:hv.optional(),execution:pv.optional(),_meta:ge(P(),$e()).optional()}),mv=Nn.extend({method:j("tools/list")}),Ha=In.extend({tools:V(Va)}),mr=He.extend({content:V(An).default([]),structuredContent:ge(P(),$e()).optional(),isError:me().optional()});mr.or(He.extend({toolResult:$e()}));const gv=Tn.extend({name:P(),arguments:ge(P(),$e()).optional()}),ld=Ve.extend({method:j("tools/call"),params:gv}),Za=at.extend({method:j("notifications/tools/list_changed"),params:ot.optional()}),_v=I({autoRefresh:me().default(!0),debounceMs:ie().int().nonnegative().default(300)}),ud=tt(["debug","info","notice","warning","error","critical","alert","emergency"]),yv=rt.extend({level:ud}),vv=Ve.extend({method:j("logging/setLevel"),params:yv}),$v=ot.extend({level:ud,logger:P().optional(),data:$e()}),dd=at.extend({method:j("notifications/message"),params:$v}),wv=I({name:P().optional()}),bv=I({hints:V(wv).optional(),costPriority:ie().min(0).max(1).optional(),speedPriority:ie().min(0).max(1).optional(),intelligencePriority:ie().min(0).max(1).optional()}),Sv=I({mode:tt(["auto","required","none"]).optional()}),Ev=I({type:j("tool_result"),toolUseId:P().describe("The unique identifier for the corresponding tool call."),content:V(An).default([]),structuredContent:I({}).loose().optional(),isError:me().optional(),_meta:ge(P(),$e()).optional()}),kv=Uu("type",[qa,Ua,Fa]),vs=Uu("type",[qa,Ua,Fa,dv,Ev]),Pv=I({role:xn,content:pe([vs,V(vs)]),_meta:ge(P(),$e()).optional()}),Rv=Tn.extend({messages:V(Pv),modelPreferences:bv.optional(),systemPrompt:P().optional(),includeContext:tt(["none","thisServer","allServers"]).optional(),temperature:ie().optional(),maxTokens:ie().int(),stopSequences:V(P()).optional(),metadata:Ae.optional(),tools:V(Va).optional(),toolChoice:Sv.optional()}),Ka=Ve.extend({method:j("sampling/createMessage"),params:Rv}),fd=He.extend({model:P(),stopReason:Re(tt(["endTurn","stopSequence","maxTokens"]).or(P())),role:xn,content:kv}),hd=He.extend({model:P(),stopReason:Re(tt(["endTurn","stopSequence","maxTokens","toolUse"]).or(P())),role:xn,content:pe([vs,V(vs)])}),Tv=I({type:j("boolean"),title:P().optional(),description:P().optional(),default:me().optional()}),Cv=I({type:j("string"),title:P().optional(),description:P().optional(),minLength:ie().optional(),maxLength:ie().optional(),format:tt(["email","uri","date","date-time"]).optional(),default:P().optional()}),jv=I({type:tt(["number","integer"]),title:P().optional(),description:P().optional(),minimum:ie().optional(),maximum:ie().optional(),default:ie().optional()}),Nv=I({type:j("string"),title:P().optional(),description:P().optional(),enum:V(P()),default:P().optional()}),Iv=I({type:j("string"),title:P().optional(),description:P().optional(),oneOf:V(I({const:P(),title:P()})),default:P().optional()}),Ov=I({type:j("string"),title:P().optional(),description:P().optional(),enum:V(P()),enumNames:V(P()).optional(),default:P().optional()}),xv=pe([Nv,Iv]),Av=I({type:j("array"),title:P().optional(),description:P().optional(),minItems:ie().optional(),maxItems:ie().optional(),items:I({type:j("string"),enum:V(P())}),default:V(P()).optional()}),Mv=I({type:j("array"),title:P().optional(),description:P().optional(),minItems:ie().optional(),maxItems:ie().optional(),items:I({anyOf:V(I({const:P(),title:P()}))}),default:V(P()).optional()}),zv=pe([Av,Mv]),Dv=pe([Ov,xv,zv]),qv=pe([Dv,Tv,Cv,jv]),Uv=Tn.extend({mode:j("form").optional(),message:P(),requestedSchema:I({type:j("object"),properties:ge(P(),qv),required:V(P()).optional()})}),Fv=Tn.extend({mode:j("url"),message:P(),elicitationId:P(),url:P().url()}),Lv=pe([Uv,Fv]),pd=Ve.extend({method:j("elicitation/create"),params:Lv}),Vv=ot.extend({elicitationId:P()}),Hv=at.extend({method:j("notifications/elicitation/complete"),params:Vv}),md=He.extend({action:tt(["accept","decline","cancel"]),content:Zu(e=>e===null?void 0:e,ge(P(),pe([P(),ie(),me(),V(P())])).optional())}),Zv=I({type:j("ref/resource"),uri:P()}),Kv=I({type:j("ref/prompt"),name:P()}),Gv=rt.extend({ref:pe([Kv,Zv]),argument:I({name:P(),value:P()}),context:I({arguments:ge(P(),P()).optional()}).optional()}),Wv=Ve.extend({method:j("completion/complete"),params:Gv}),gd=He.extend({completion:Le({values:V(P()).max(100),total:Re(ie().int()),hasMore:Re(me())})}),Bv=I({uri:P().startsWith("file://"),name:P().optional(),_meta:ge(P(),$e()).optional()}),Jv=Ve.extend({method:j("roots/list"),params:rt.optional()}),Qv=He.extend({roots:V(Bv)}),Yv=at.extend({method:j("notifications/roots/list_changed"),params:ot.optional()});pe([Zs,Hy,Wv,vv,uv,od,rd,nd,sd,rv,sv,ld,mv,Pa,Ta,Ca,Na]);pe([Ea,ka,Qu,Yv,ys]);pe([Nr,fd,hd,md,Qv,Ra,ja,bn]);pe([Zs,Ka,pd,Jv,Pa,Ta,Ca,Na]);pe([Ea,ka,dd,av,za,Za,La,ys,Hv]);pe([Nr,Ju,gd,cd,Da,Oa,xa,Ma,mr,Ha,Ra,ja,bn]);class X 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===ne.UrlElicitationRequired&&n){const s=n;if(s.elicitations)return new Xv(s.elicitations,r)}return new X(t,r,n)}}class Xv extends X{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(ne.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){var t;return((t=this.data)==null?void 0:t.elicitations)??[]}}function Ga(e){return!!e._zod}function Ot(e,t){return Ga(e)?wu(e,t):e.safeParse(t)}function _d(e){var r,n;if(!e)return;let t;if(Ga(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 yd(e){var s;if(Ga(e)){const a=(s=e._zod)==null?void 0:s.def;if(a){if(a.value!==void 0)return a.value;if(Array.isArray(a.values)&&a.values.length>0)return a.values[0]}}const r=e._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}const n=e.value;if(n!==void 0)return n}function rr(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function tl(e){const t=_d(e),r=t==null?void 0:t.method;if(!r)throw new Error("Schema is missing a method literal");const n=yd(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function rl(e,t){const r=Ot(e,t);if(!r.success)throw r.error;return r.data}const e$=6e4;class vd{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(Ea,r=>{this._oncancel(r)}),this.setNotificationHandler(ka,r=>{this._onprogress(r)}),this.setRequestHandler(Zs,r=>({})),this._taskStore=t==null?void 0:t.taskStore,this._taskMessageQueue=t==null?void 0:t.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Pa,async(r,n)=>{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new X(ne.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(Ta,async(r,n)=>{const s=async()=>{var i;const o=r.params.taskId;if(this._taskMessageQueue){let c;for(;c=await this._taskMessageQueue.dequeue(o,n.sessionId);){if(c.type==="response"||c.type==="error"){const l=c.message,d=l.id,h=this._requestResolvers.get(d);if(h)if(this._requestResolvers.delete(d),c.type==="response")h(l);else{const m=l,_=new X(m.error.code,m.error.message,m.error.data);h(_)}else{const m=c.type==="response"?"Response":"Error";this._onerror(new Error(`${m} handler missing for request ${d}`))}continue}await((i=this._transport)==null?void 0:i.send(c.message,{relatedRequestId:n.requestId}))}}const a=await this._taskStore.getTask(o,n.sessionId);if(!a)throw new X(ne.InvalidParams,`Task not found: ${o}`);if(!rr(a.status))return await this._waitForTaskUpdate(o,n.signal),await s();if(rr(a.status)){const c=await this._taskStore.getTaskResult(o,n.sessionId);return this._clearTaskQueue(o),{...c,_meta:{...c._meta,[ir]:{taskId:o}}}}return await s()};return await s()}),this.setRequestHandler(Ca,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 X(ne.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Na,async(r,n)=>{try{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new X(ne.InvalidParams,`Task not found: ${r.params.taskId}`);if(rr(s.status))throw new X(ne.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 X(ne.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(s){throw s instanceof X?s:new X(ne.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),X.fromError(ne.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),sn(c)||Ay(c)?this._onresponse(c):No(c)?this._onrequest(c,l):xy(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=X.fromError(ne.ConnectionClosed,"Connection closed");this._transport=void 0,(n=this.onclose)==null||n.call(this);for(const s of t.values())s(r)}_onerror(t){var r;(r=this.onerror)==null||r.call(this,t)}_onnotification(t){const r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){var d,h,m,_;const n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,s=this._transport,o=(m=(h=(d=t.params)==null?void 0:d._meta)==null?void 0:h[ir])==null?void 0:m.taskId;if(n===void 0){const v={jsonrpc:"2.0",id:t.id,error:{code:ne.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:v,timestamp:Date.now()},s==null?void 0:s.sessionId).catch(y=>this._onerror(new Error(`Failed to enqueue error response: ${y}`))):s==null||s.send(v).catch(y=>this._onerror(new Error(`Failed to send an error response: ${y}`)));return}const a=new AbortController;this._requestHandlerAbortControllers.set(t.id,a);const i=Oy(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,s==null?void 0:s.sessionId):void 0,l={signal:a.signal,sessionId:s==null?void 0:s.sessionId,_meta:(_=t.params)==null?void 0:_._meta,sendNotification:async v=>{if(a.signal.aborted)return;const y={relatedRequestId:t.id};o&&(y.relatedTask={taskId:o}),await this.notification(v,y)},sendRequest:async(v,y,g)=>{var E;if(a.signal.aborted)throw new X(ne.ConnectionClosed,"Request was cancelled");const f={...g,relatedRequestId:t.id};o&&!f.relatedTask&&(f.relatedTask={taskId:o});const $=((E=f.relatedTask)==null?void 0:E.taskId)??o;return $&&c&&await c.updateTaskStatus($,"input_required"),await this.request(v,y,f)},authInfo:r==null?void 0:r.authInfo,requestId:t.id,requestInfo:r==null?void 0:r.requestInfo,taskId:o,taskStore:c,taskRequestedTtl:i==null?void 0:i.ttl,closeSSEStream:r==null?void 0:r.closeSSEStream,closeStandaloneSSEStream:r==null?void 0:r.closeStandaloneSSEStream};Promise.resolve().then(()=>{i&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,l)).then(async v=>{if(a.signal.aborted)return;const y={result:v,jsonrpc:"2.0",id:t.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:y,timestamp:Date.now()},s==null?void 0:s.sessionId):await(s==null?void 0:s.send(y))},async v=>{if(a.signal.aborted)return;const y={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(v.code)?v.code:ne.InternalError,message:v.message??"Internal error",...v.data!==void 0&&{data:v.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:y,timestamp:Date.now()},s==null?void 0:s.sessionId):await(s==null?void 0:s.send(y))}).catch(v=>this._onerror(new Error(`Failed to send response: ${v}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===a&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){const{progressToken:r,...n}=t.params,s=Number(r),o=this._progressHandlers.get(s);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}const a=this._responseHandlers.get(s),i=this._timeoutInfo.get(s);if(i&&a&&i.resetTimeoutOnProgress)try{this._resetTimeout(s)}catch(c){this._responseHandlers.delete(s),this._progressHandlers.delete(s),this._cleanupTimeout(s),a(c);return}o(n)}_onresponse(t){const r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),sn(t))n(t);else{const a=new X(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(sn(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),sn(t))s(t);else{const a=X.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 X?c:new X(ne.InternalError,String(c))}}return}let o;try{const c=await this.request(t,bn,n);if(c.task)o=c.task.taskId,yield{type:"taskCreated",task:c.task};else throw new X(ne.InternalError,"Task creation did not return a task");for(;;){const l=await this.getTask({taskId:o},n);if(yield{type:"taskStatus",task:l},rr(l.status)){l.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)}:l.status==="failed"?yield{type:"error",error:new X(ne.InternalError,`Task ${o} failed`)}:l.status==="cancelled"&&(yield{type:"error",error:new X(ne.InternalError,`Task ${o} was cancelled`)});return}if(l.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)};return}const d=l.pollInterval??((a=this._options)==null?void 0:a.defaultTaskPollInterval)??1e3;await new Promise(h=>setTimeout(h,d)),(i=n==null?void 0:n.signal)==null||i.throwIfAborted()}}catch(c){yield{type:"error",error:c instanceof X?c:new X(ne.InternalError,String(c))}}}request(t,r,n){const{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a,task:i,relatedTask:c}=n??{};return new Promise((l,d)=>{var $,E,T,R,O;const h=x=>{d(x)};if(!this._transport){h(new Error("Not connected"));return}if((($=this._options)==null?void 0:$.enforceStrictCapabilities)===!0)try{this.assertCapabilityForMethod(t.method),i&&this.assertTaskCapability(t.method)}catch(x){h(x);return}(E=n==null?void 0:n.signal)==null||E.throwIfAborted();const m=this._requestMessageId++,_={...t,jsonrpc:"2.0",id:m};n!=null&&n.onprogress&&(this._progressHandlers.set(m,n.onprogress),_.params={...t.params,_meta:{...((T=t.params)==null?void 0:T._meta)||{},progressToken:m}}),i&&(_.params={..._.params,task:i}),c&&(_.params={..._.params,_meta:{...((R=_.params)==null?void 0:R._meta)||{},[ir]:c}});const v=x=>{var D;this._responseHandlers.delete(m),this._progressHandlers.delete(m),this._cleanupTimeout(m),(D=this._transport)==null||D.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:m,reason:String(x)}},{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a}).catch(q=>this._onerror(new Error(`Failed to send cancellation: ${q}`)));const U=x instanceof X?x:new X(ne.RequestTimeout,String(x));d(U)};this._responseHandlers.set(m,x=>{var U;if(!((U=n==null?void 0:n.signal)!=null&&U.aborted)){if(x instanceof Error)return d(x);try{const D=Ot(r,x.result);D.success?l(D.data):d(D.error)}catch(D){d(D)}}}),(O=n==null?void 0:n.signal)==null||O.addEventListener("abort",()=>{var x;v((x=n==null?void 0:n.signal)==null?void 0:x.reason)});const y=(n==null?void 0:n.timeout)??e$,g=()=>v(X.fromError(ne.RequestTimeout,"Request timed out",{timeout:y}));this._setupTimeout(m,y,n==null?void 0:n.maxTotalTimeout,g,(n==null?void 0:n.resetTimeoutOnProgress)??!1);const f=c==null?void 0:c.taskId;if(f){const x=U=>{const D=this._responseHandlers.get(m);D?D(U):this._onerror(new Error(`Response handler missing for side-channeled request ${m}`))};this._requestResolvers.set(m,x),this._enqueueTaskMessage(f,{type:"request",message:_,timestamp:Date.now()}).catch(U=>{this._cleanupTimeout(m),d(U)})}else this._transport.send(_,{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a}).catch(x=>{this._cleanupTimeout(m),d(x)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},Ra,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},ja,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},Yy,r)}async notification(t,r){var i,c,l,d;if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);const n=(i=r==null?void 0:r.relatedTask)==null?void 0:i.taskId;if(n){const h={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...((c=t.params)==null?void 0:c._meta)||{},[ir]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:h,timestamp:Date.now()});return}if((((l=this._options)==null?void 0:l.debouncedNotificationMethods)??[]).includes(t.method)&&!t.params&&!(r!=null&&r.relatedRequestId)&&!(r!=null&&r.relatedTask)){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{var m,_;if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let h={...t,jsonrpc:"2.0"};r!=null&&r.relatedTask&&(h={...h,params:{...h.params,_meta:{...((m=h.params)==null?void 0:m._meta)||{},[ir]:r.relatedTask}}}),(_=this._transport)==null||_.send(h,r).catch(v=>this._onerror(v))});return}let a={...t,jsonrpc:"2.0"};r!=null&&r.relatedTask&&(a={...a,params:{...a.params,_meta:{...((d=a.params)==null?void 0:d._meta)||{},[ir]:r.relatedTask}}}),await this._transport.send(a,r)}setRequestHandler(t,r){const n=tl(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,o)=>{const a=rl(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=tl(t);this._notificationHandlers.set(n,s=>{const o=rl(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"&&No(s.message)){const o=s.message.id,a=this._requestResolvers.get(o);a?(a(new X(ne.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 X(ne.InvalidRequest,"Request cancelled"));return}const c=setTimeout(a,n);r.addEventListener("abort",()=>{clearTimeout(c),i(new X(ne.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 X(ne.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=ys.parse({method:"notifications/tasks/status",params:i});await this.notification(c),rr(i.status)&&this._cleanupTaskProgressHandler(s)}},getTaskResult:s=>n.getTaskResult(s,r),updateTaskStatus:async(s,o,a)=>{const i=await n.getTask(s,r);if(!i)throw new X(ne.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(rr(i.status))throw new X(ne.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=ys.parse({method:"notifications/tasks/status",params:c});await this.notification(l),rr(c.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>n.listTasks(s,r)}}}function nl(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function t$(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];nl(a)&&nl(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 r$ extends vd{constructor(){super(...arguments);se(this,"_registeredMethods",new Set);se(this,"_eventSlots",new Map);se(this,"setRequestHandler",(r,n)=>{this._assertMethodNotRegistered(r,"setRequestHandler"),super.setRequestHandler(r,n)});se(this,"setNotificationHandler",(r,n)=>{this._assertMethodNotRegistered(r,"setNotificationHandler"),super.setNotificationHandler(r,n)});se(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 $d="2026-01-26",n$="ui/notifications/tool-input-partial",s$=pe([j("light"),j("dark")]).describe("Color theme preference for the host environment."),Sn=pe([j("inline"),j("fullscreen"),j("pip")]).describe("Display mode for UI presentation."),o$=pe([j("--color-background-primary"),j("--color-background-secondary"),j("--color-background-tertiary"),j("--color-background-inverse"),j("--color-background-ghost"),j("--color-background-info"),j("--color-background-danger"),j("--color-background-success"),j("--color-background-warning"),j("--color-background-disabled"),j("--color-text-primary"),j("--color-text-secondary"),j("--color-text-tertiary"),j("--color-text-inverse"),j("--color-text-ghost"),j("--color-text-info"),j("--color-text-danger"),j("--color-text-success"),j("--color-text-warning"),j("--color-text-disabled"),j("--color-border-primary"),j("--color-border-secondary"),j("--color-border-tertiary"),j("--color-border-inverse"),j("--color-border-ghost"),j("--color-border-info"),j("--color-border-danger"),j("--color-border-success"),j("--color-border-warning"),j("--color-border-disabled"),j("--color-ring-primary"),j("--color-ring-secondary"),j("--color-ring-inverse"),j("--color-ring-info"),j("--color-ring-danger"),j("--color-ring-success"),j("--color-ring-warning"),j("--font-sans"),j("--font-mono"),j("--font-weight-normal"),j("--font-weight-medium"),j("--font-weight-semibold"),j("--font-weight-bold"),j("--font-text-xs-size"),j("--font-text-sm-size"),j("--font-text-md-size"),j("--font-text-lg-size"),j("--font-heading-xs-size"),j("--font-heading-sm-size"),j("--font-heading-md-size"),j("--font-heading-lg-size"),j("--font-heading-xl-size"),j("--font-heading-2xl-size"),j("--font-heading-3xl-size"),j("--font-text-xs-line-height"),j("--font-text-sm-line-height"),j("--font-text-md-line-height"),j("--font-text-lg-line-height"),j("--font-heading-xs-line-height"),j("--font-heading-sm-line-height"),j("--font-heading-md-line-height"),j("--font-heading-lg-line-height"),j("--font-heading-xl-line-height"),j("--font-heading-2xl-line-height"),j("--font-heading-3xl-line-height"),j("--border-radius-xs"),j("--border-radius-sm"),j("--border-radius-md"),j("--border-radius-lg"),j("--border-radius-xl"),j("--border-radius-full"),j("--border-width-regular"),j("--shadow-hairline"),j("--shadow-sm"),j("--shadow-md"),j("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),a$=ge(o$.describe(`Style variables for theming MCP apps. - -Individual style keys are optional - hosts may provide any subset of these values. -Values are strings containing CSS values (colors, sizes, font stacks, etc.). - -Note: This type uses \`Record\` rather than \`Partial>\` -for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),pe([P(),Ro()]).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.`),i$=I({method:j("ui/open-link"),params:I({url:P().describe("URL to open in the host's browser")})});I({isError:me().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough();I({isError:me().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough();I({isError:me().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();var c$=I({method:j("ui/notifications/sandbox-proxy-ready"),params:I({})}),Wa=I({connectDomains:V(P()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket). - -- Maps to CSP \`connect-src\` directive -- Empty or omitted → no network connections (secure default)`),resourceDomains:V(P()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:V(P()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:V(P()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),Ba=I({camera:I({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:I({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:I({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:I({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),l$=I({method:j("ui/notifications/size-changed"),params:I({width:ie().optional().describe("New width in pixels."),height:ie().optional().describe("New height in pixels.")})});I({method:j("ui/notifications/tool-input"),params:I({arguments:ge(P(),$e().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})});I({method:j("ui/notifications/tool-input-partial"),params:I({arguments:ge(P(),$e().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})});I({method:j("ui/notifications/tool-cancelled"),params:I({reason:P().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})});var u$=I({fonts:P().optional()}),d$=I({variables:a$.optional().describe("CSS variables for theming the app."),css:u$.optional().describe("CSS blocks that apps can inject.")});I({method:j("ui/resource-teardown"),params:I({})});var f$=ge(P(),$e()),sl=I({text:I({}).optional().describe("Host supports text content blocks."),image:I({}).optional().describe("Host supports image content blocks."),audio:I({}).optional().describe("Host supports audio content blocks."),resource:I({}).optional().describe("Host supports resource content blocks."),resourceLink:I({}).optional().describe("Host supports resource link content blocks."),structuredContent:I({}).optional().describe("Host supports structured content.")}),h$=I({method:j("ui/notifications/request-teardown"),params:I({}).optional()}),p$=I({experimental:ge(P(),ge(P(),va()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:I({}).optional().describe("Host supports opening external URLs."),downloadFile:I({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:I({listChanged:me().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:I({listChanged:me().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:I({}).optional().describe("Host accepts log messages."),sandbox:I({permissions:Ba.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:Wa.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:sl.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:sl.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:I({tools:I({}).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.")}),m$=I({experimental:ge(P(),ge(P(),va()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:I({listChanged:me().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:V(Sn).optional().describe("Display modes the app supports.")}),g$=I({method:j("ui/notifications/initialized"),params:I({}).optional()});I({csp:Wa.optional().describe("Content Security Policy configuration for UI resources."),permissions:Ba.optional().describe("Sandbox permissions requested by the UI resource."),domain:P().optional().describe(`Dedicated origin for view sandbox. - -Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists. - -**Host-dependent:** The format and validation rules for this field are determined by each host. Servers MUST consult host-specific documentation for the expected domain format. Common patterns include: -- Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`) -- URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`) - -If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:me().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 ol=I({method:j("ui/request-display-mode"),params:I({mode:Sn.describe("The display mode being requested.")})});I({mode:Sn.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough();var _$=pe([j("model"),j("app")]).describe("Tool visibility scope - who can access the tool.");I({resourceUri:P().optional(),visibility:V(_$).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:To().optional(),permissions:To().optional()});I({mimeTypes:V(P()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});var y$=I({method:j("ui/download-file"),params:I({contents:V(pe([ad,id])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),v$=I({method:j("ui/message"),params:I({role:j("user").describe('Message role, currently only "user" is supported.'),content:V(An).describe("Message content blocks (text, image, etc.).")})});I({method:j("ui/notifications/sandbox-resource-ready"),params:I({html:P().describe("HTML content to load into the inner iframe."),sandbox:P().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Wa.optional().describe("CSP configuration from resource metadata."),permissions:Ba.optional().describe("Sandbox permissions from resource metadata.")})});I({method:j("ui/notifications/tool-result"),params:mr.describe("Standard MCP tool execution result.")});var wd=I({toolInfo:I({id:Cn.optional().describe("JSON-RPC id of the tools/call request."),tool:Va.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:s$.optional().describe("Current color theme preference."),styles:d$.optional().describe("Style configuration for theming the app."),displayMode:Sn.optional().describe("How the UI is currently displayed."),availableDisplayModes:V(Sn).optional().describe("Display modes the host supports."),containerDimensions:pe([I({height:ie().describe("Fixed container height in pixels.")}),I({maxHeight:pe([ie(),Ro()]).optional().describe("Maximum container height in pixels.")})]).and(pe([I({width:ie().describe("Fixed container width in pixels.")}),I({maxWidth:pe([ie(),Ro()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other -container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:P().optional().describe("User's language and region preference in BCP 47 format."),timeZone:P().optional().describe("User's timezone in IANA format."),userAgent:P().optional().describe("Host application identifier."),platform:pe([j("web"),j("desktop"),j("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:I({touch:me().optional().describe("Whether the device supports touch input."),hover:me().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:I({top:ie().describe("Top safe area inset in pixels."),right:ie().describe("Right safe area inset in pixels."),bottom:ie().describe("Bottom safe area inset in pixels."),left:ie().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough();I({method:j("ui/notifications/host-context-changed"),params:wd.describe("Partial context update containing only changed fields.")});var $$=I({method:j("ui/update-model-context"),params:I({content:V(An).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:ge(P(),$e().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),w$=I({method:j("ui/initialize"),params:I({appInfo:Hs.describe("App identification (name and version)."),appCapabilities:m$.describe("Features and capabilities this app provides."),protocolVersion:P().describe("Protocol version this app supports.")})});I({protocolVersion:P().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Hs.describe("Host application identification and version."),hostCapabilities:p$.describe("Features and capabilities provided by the host."),hostContext:wd.describe("Rich context about the host environment.")}).passthrough();class b${constructor(t=window.parent,r){se(this,"eventTarget");se(this,"eventSource");se(this,"messageListener");se(this,"onclose");se(this,"onerror");se(this,"onmessage");se(this,"sessionId");se(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=ss.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!==n$&&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 S$=[$d];class E$ extends r${constructor(r,n,s,o){super(o);se(this,"_client");se(this,"_hostInfo");se(this,"_capabilities");se(this,"_appCapabilities");se(this,"_hostContext",{});se(this,"_appInfo");se(this,"_initializedReceived",!1);se(this,"_baseReplaceRequestHandler",this.replaceRequestHandler);se(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)))});se(this,"eventSchemas",{sizechange:l$,sandboxready:c$,initialized:g$,requestteardown:h$,loggingmessage:dd});se(this,"onping");se(this,"_onmessage");se(this,"_onopenlink");se(this,"_ondownloadfile");se(this,"_onrequestdisplaymode");se(this,"_onupdatemodelcontext");se(this,"_oncalltool");se(this,"_onlistresources");se(this,"_onlistresourcetemplates");se(this,"_onreadresource");se(this,"_onlistprompts");se(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(w$,a=>this._oninitialize(a)),this.setRequestHandler(Zs,(a,i)=>{var c;return(c=this.onping)==null||c.call(this,a.params,i),{}}),this.replaceRequestHandler(ol,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(v$,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(i$,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(y$,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(ol,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($$,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(ld,async(n,s)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,s)})}set oncreatesamplingmessage(r){this.setRequestHandler(Ka,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(rd,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(nd,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(sd,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(od,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:S$.includes(n)?n:$d,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];k$(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},f$,n)}callTool(r,n){return this.request({method:"tools/call",params:r},mr,n)}listTools(r,n){return this.request({method:"tools/list",params:r},Ha,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},mr,{signal:o.signal}),n.tools.listChanged&&this._client.setNotificationHandler(Za,s=>this.sendToolListChanged(s.params))),n.resources&&(this.onlistresources=async(s,o)=>this._client.request({method:"resources/list",params:s},Oa,{signal:o.signal}),this.onlistresourcetemplates=async(s,o)=>this._client.request({method:"resources/templates/list",params:s},xa,{signal:o.signal}),this.onreadresource=async(s,o)=>this._client.request({method:"resources/read",params:s},Ma,{signal:o.signal}),n.resources.listChanged&&this._client.setNotificationHandler(za,s=>this.sendResourceListChanged(s.params))),n.prompts&&(this.onlistprompts=async(s,o)=>this._client.request({method:"prompts/list",params:s},Da,{signal:o.signal}),n.prompts.listChanged&&this._client.setNotificationHandler(La,s=>this.sendPromptListChanged(s.params)))}return super.connect(r)}}function k$(e,t){return JSON.stringify(e)===JSON.stringify(t)}const P$={x:0,y:0,width:1024,height:768},Io=28,R$=12,T$=.9;function xt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function bd(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return e}function Oo(e){if(Array.isArray(e))return e.map(Oo);const t=bd(e);return t?Object.fromEntries(Object.entries(t).map(([r,n])=>[r,(r==="text"||r==="originalText")&&typeof n=="string"?n.replace(/\\r\\n|\\n|\\r/gu,` -`):Oo(n)])):e}function C$(e){return e.type==="text"&&typeof(e.text??e.originalText)=="string"}function Sd(e){const t=String(e.text??e.originalText??""),r=xt(e.fontSize)??20,n=t.length*r*T$,s=xt(e.width);return Math.max(s&&s>0?s:0,n)}function j$(e){for(const t of e){if(t.type!=="cameraUpdate")continue;const r=xt(t.width),n=xt(t.height);if(!(!r||r<=0||!n||n<=0))return{x:xt(t.x)??0,y:xt(t.y)??0,width:r,height:n}}return P$}function N$(e,t){const r=xt(e.x);if(r===void 0)return!1;const n=Sd(e),s=t.x+Io,o=t.x+t.width-Io;return ro+1}function I$(e,t){const r={...e},n=xt(r.fontSize)??20;let s=Sd(r);const o=Math.max(1,t.width-Io*2);if(s>o){const a=o/s;r.fontSize=Math.max(R$,n*a),typeof r.height=="number"&&(r.height*=Number(r.fontSize)/n),s=Math.min(o,s*(Number(r.fontSize)/n))}return r.width=s,r.autoResize=!1,r.textAlign="left",r.x=t.x+(t.width-s)/2,r}function O$(e){const r=Oo(e).map(bd);if(r.some(o=>o===void 0))return e;const n=r,s=j$(n);return n.map(o=>!C$(o)||!N$(o,s)?o:I$(o,s))}var xo={exports:{}},Ed={},mt={},qr={},Mn={},fe={},En={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class t{}e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends t{constructor($){if(super(),!e.IDENTIFIER.test($))throw new Error("CodeGen: name must be a valid identifier");this.str=$}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=r;class n extends t{constructor($){super(),this._items=typeof $=="string"?[$]:$}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const $=this._items[0];return $===""||$==='""'}get str(){var $;return($=this._str)!==null&&$!==void 0?$:this._str=this._items.reduce((E,T)=>`${E}${T}`,"")}get names(){var $;return($=this._names)!==null&&$!==void 0?$:this._names=this._items.reduce((E,T)=>(T instanceof r&&(E[T.str]=(E[T.str]||0)+1),E),{})}}e._Code=n,e.nil=new n("");function s(f,...$){const E=[f[0]];let T=0;for(;T<$.length;)i(E,$[T]),E.push(f[++T]);return new n(E)}e._=s;const o=new n("+");function a(f,...$){const E=[_(f[0])];let T=0;for(;T<$.length;)E.push(o),i(E,$[T]),E.push(o,_(f[++T]));return c(E),new n(E)}e.str=a;function i(f,$){$ instanceof n?f.push(...$._items):$ instanceof r?f.push($):f.push(h($))}e.addCodeArg=i;function c(f){let $=1;for(;${if(h.scopePath===void 0)throw new Error(`CodeGen: name "${h}" has no value`);return(0,t._)`${l}${h.scopePath}`})}scopeCode(l=this._values,d,h){return this._reduceValues(l,m=>{if(m.value===void 0)throw new Error(`CodeGen: name "${m}" has no value`);return m.value.code},d,h)}_reduceValues(l,d,h={},m){let _=t.nil;for(const v in l){const y=l[v];if(!y)continue;const g=h[v]=h[v]||new Map;y.forEach(f=>{if(g.has(f))return;g.set(f,n.Started);let $=d(f);if($){const E=this.opts.es5?e.varKinds.var:e.varKinds.const;_=(0,t._)`${_}${E} ${f} = ${$};${this.opts._n}`}else if($=m==null?void 0:m(f))_=(0,t._)`${_}${$}${this.opts._n}`;else throw new r(f);g.set(f,n.Completed)})}return _}}e.ValueScope=i})(Ao);(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=En,r=Ao;var n=En;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=Ao;Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class o{optimizeNodes(){return this}optimizeNames(u,p){return this}}class a extends o{constructor(u,p,k){super(),this.varKind=u,this.name=p,this.rhs=k}render({es5:u,_n:p}){const k=u?r.varKinds.var:this.varKind,M=this.rhs===void 0?"":` = ${this.rhs}`;return`${k} ${this.name}${M};`+p}optimizeNames(u,p){if(u[this.name.str])return this.rhs&&(this.rhs=F(this.rhs,u,p)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class i extends o{constructor(u,p,k){super(),this.lhs=u,this.rhs=p,this.sideEffects=k}render({_n:u}){return`${this.lhs} = ${this.rhs};`+u}optimizeNames(u,p){if(!(this.lhs instanceof t.Name&&!u[this.lhs.str]&&!this.sideEffects))return this.rhs=F(this.rhs,u,p),this}get names(){const u=this.lhs instanceof t.Name?{}:{...this.lhs.names};return re(u,this.rhs)}}class c extends i{constructor(u,p,k,M){super(u,k,M),this.op=p}render({_n:u}){return`${this.lhs} ${this.op}= ${this.rhs};`+u}}class l extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`${this.label}:`+u}}class d extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`break${this.label?` ${this.label}`:""};`+u}}class h extends o{constructor(u){super(),this.error=u}render({_n:u}){return`throw ${this.error};`+u}get names(){return this.error.names}}class m extends o{constructor(u){super(),this.code=u}render({_n:u}){return`${this.code};`+u}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(u,p){return this.code=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,k)=>p+k.render(u),"")}optimizeNodes(){const{nodes:u}=this;let p=u.length;for(;p--;){const k=u[p].optimizeNodes();Array.isArray(k)?u.splice(p,1,...k):k?u[p]=k:u.splice(p,1)}return u.length>0?this:void 0}optimizeNames(u,p){const{nodes:k}=this;let M=k.length;for(;M--;){const z=k[M];z.optimizeNames(u,p)||(le(u,z.names),k.splice(M,1))}return k.length>0?this:void 0}get names(){return this.nodes.reduce((u,p)=>Z(u,p.names),{})}}class v extends _{render(u){return"{"+u._n+super.render(u)+"}"+u._n}}class y extends _{}class g extends v{}g.kind="else";class f extends v{constructor(u,p){super(p),this.condition=u}render(u){let p=`if(${this.condition})`+super.render(u);return this.else&&(p+="else "+this.else.render(u)),p}optimizeNodes(){super.optimizeNodes();const u=this.condition;if(u===!0)return this.nodes;let p=this.else;if(p){const k=p.optimizeNodes();p=this.else=Array.isArray(k)?new g(k):k}if(p)return u===!1?p instanceof f?p:p.nodes:this.nodes.length?this:new f(Ce(u),p instanceof f?[p]:p.nodes);if(!(u===!1||!this.nodes.length))return this}optimizeNames(u,p){var k;if(this.else=(k=this.else)===null||k===void 0?void 0:k.optimizeNames(u,p),!!(super.optimizeNames(u,p)||this.else))return this.condition=F(this.condition,u,p),this}get names(){const u=super.names;return re(u,this.condition),this.else&&Z(u,this.else.names),u}}f.kind="if";class $ extends v{}$.kind="for";class E extends ${constructor(u){super(),this.iteration=u}render(u){return`for(${this.iteration})`+super.render(u)}optimizeNames(u,p){if(super.optimizeNames(u,p))return this.iteration=F(this.iteration,u,p),this}get names(){return Z(super.names,this.iteration.names)}}class T extends ${constructor(u,p,k,M){super(),this.varKind=u,this.name=p,this.from=k,this.to=M}render(u){const p=u.es5?r.varKinds.var:this.varKind,{name:k,from:M,to:z}=this;return`for(${p} ${k}=${M}; ${k}<${z}; ${k}++)`+super.render(u)}get names(){const u=re(super.names,this.from);return re(u,this.to)}}class R extends ${constructor(u,p,k,M){super(),this.loop=u,this.varKind=p,this.name=k,this.iterable=M}render(u){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(u)}optimizeNames(u,p){if(super.optimizeNames(u,p))return this.iterable=F(this.iterable,u,p),this}get names(){return Z(super.names,this.iterable.names)}}class O extends v{constructor(u,p,k){super(),this.name=u,this.args=p,this.async=k}render(u){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(u)}}O.kind="func";class x extends _{render(u){return"return "+super.render(u)}}x.kind="return";class U extends v{render(u){let p="try"+super.render(u);return this.catch&&(p+=this.catch.render(u)),this.finally&&(p+=this.finally.render(u)),p}optimizeNodes(){var u,p;return super.optimizeNodes(),(u=this.catch)===null||u===void 0||u.optimizeNodes(),(p=this.finally)===null||p===void 0||p.optimizeNodes(),this}optimizeNames(u,p){var k,M;return super.optimizeNames(u,p),(k=this.catch)===null||k===void 0||k.optimizeNames(u,p),(M=this.finally)===null||M===void 0||M.optimizeNames(u,p),this}get names(){const u=super.names;return this.catch&&Z(u,this.catch.names),this.finally&&Z(u,this.finally.names),u}}class D extends v{constructor(u){super(),this.error=u}render(u){return`catch(${this.error})`+super.render(u)}}D.kind="catch";class q extends v{render(u){return"finally"+super.render(u)}}q.kind="finally";class L{constructor(u,p={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...p,_n:p.lines?` -`:""},this._extScope=u,this._scope=new r.Scope({parent:u}),this._nodes=[new y]}toString(){return this._root.render(this.opts)}name(u){return this._scope.name(u)}scopeName(u){return this._extScope.name(u)}scopeValue(u,p){const k=this._extScope.value(u,p);return(this._values[k.prefix]||(this._values[k.prefix]=new Set)).add(k),k}getScopeValue(u,p){return this._extScope.getValue(u,p)}scopeRefs(u){return this._extScope.scopeRefs(u,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(u,p,k,M){const z=this._scope.toName(p);return k!==void 0&&M&&(this._constants[z.str]=k),this._leafNode(new a(u,z,k)),z}const(u,p,k){return this._def(r.varKinds.const,u,p,k)}let(u,p,k){return this._def(r.varKinds.let,u,p,k)}var(u,p,k){return this._def(r.varKinds.var,u,p,k)}assign(u,p,k){return this._leafNode(new i(u,p,k))}add(u,p){return this._leafNode(new c(u,e.operators.ADD,p))}code(u){return typeof u=="function"?u():u!==t.nil&&this._leafNode(new m(u)),this}object(...u){const p=["{"];for(const[k,M]of u)p.length>1&&p.push(","),p.push(k),(k!==M||this.opts.es5)&&(p.push(":"),(0,t.addCodeArg)(p,M));return p.push("}"),new t._Code(p)}if(u,p,k){if(this._blockNode(new f(u)),p&&k)this.code(p).else().code(k).endIf();else if(p)this.code(p).endIf();else if(k)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(u){return this._elseNode(new f(u))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(f,g)}_for(u,p){return this._blockNode(u),p&&this.code(p).endFor(),this}for(u,p){return this._for(new E(u),p)}forRange(u,p,k,M,z=this.opts.es5?r.varKinds.var:r.varKinds.let){const J=this._scope.toName(u);return this._for(new T(z,J,p,k),()=>M(J))}forOf(u,p,k,M=r.varKinds.const){const z=this._scope.toName(u);if(this.opts.es5){const J=p instanceof t.Name?p:this.var("_arr",p);return this.forRange("_i",0,(0,t._)`${J}.length`,W=>{this.var(z,(0,t._)`${J}[${W}]`),k(z)})}return this._for(new R("of",M,z,p),()=>k(z))}forIn(u,p,k,M=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(u,(0,t._)`Object.keys(${p})`,k);const z=this._scope.toName(u);return this._for(new R("in",M,z,p),()=>k(z))}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 x;if(this._blockNode(p),this.code(u),p.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(x)}try(u,p,k){if(!p&&!k)throw new Error('CodeGen: "try" without "catch" and "finally"');const M=new U;if(this._blockNode(M),this.code(u),p){const z=this.name("e");this._currNode=M.catch=new D(z),p(z)}return k&&(this._currNode=M.finally=new q,this.code(k)),this._endBlockNode(D,q)}throw(u){return this._leafNode(new h(u))}block(u,p){return this._blockStarts.push(this._nodes.length),u&&this.code(u).endBlock(p),this}endBlock(u){const p=this._blockStarts.pop();if(p===void 0)throw new Error("CodeGen: not in self-balancing block");const k=this._nodes.length-p;if(k<0||u!==void 0&&k!==u)throw new Error(`CodeGen: wrong number of nodes: ${k} vs ${u} expected`);return this._nodes.length=p,this}func(u,p=t.nil,k,M){return this._blockNode(new O(u,p,k)),M&&this.code(M).endFunc(),this}endFunc(){return this._endBlockNode(O)}optimize(u=1){for(;u-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(u){return this._currNode.nodes.push(u),this}_blockNode(u){this._currNode.nodes.push(u),this._nodes.push(u)}_endBlockNode(u,p){const k=this._currNode;if(k instanceof u||p&&k instanceof p)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${p?`${u.kind}/${p.kind}`:u.kind}"`)}_elseNode(u){const p=this._currNode;if(!(p instanceof f))throw new Error('CodeGen: "else" without "if"');return this._currNode=p.else=u,this}get _root(){return this._nodes[0]}get _currNode(){const u=this._nodes;return u[u.length-1]}set _currNode(u){const p=this._nodes;p[p.length-1]=u}}e.CodeGen=L;function Z(S,u){for(const p in u)S[p]=(S[p]||0)+(u[p]||0);return S}function re(S,u){return u instanceof t._CodeOrName?Z(S,u.names):S}function F(S,u,p){if(S instanceof t.Name)return k(S);if(!M(S))return S;return new t._Code(S._items.reduce((z,J)=>(J instanceof t.Name&&(J=k(J)),J instanceof t._Code?z.push(...J._items):z.push(J),z),[]));function k(z){const J=p[z.str];return J===void 0||u[z.str]!==1?z:(delete u[z.str],J)}function M(z){return z instanceof t._Code&&z._items.some(J=>J instanceof t.Name&&u[J.str]===1&&p[J.str]!==void 0)}}function le(S,u){for(const p in u)S[p]=(S[p]||0)-(u[p]||0)}function Ce(S){return typeof S=="boolean"||typeof S=="number"||S===null?!S:(0,t._)`!${C(S)}`}e.not=Ce;const _e=w(e.operators.AND);function it(...S){return S.reduce(_e)}e.and=it;const Ie=w(e.operators.OR);function N(...S){return S.reduce(Ie)}e.or=N;function w(S){return(u,p)=>u===t.nil?p:p===t.nil?u:(0,t._)`${C(u)} ${S} ${C(p)}`}function C(S){return S instanceof t.Name?S:(0,t._)`(${S})`}})(fe);var K={};Object.defineProperty(K,"__esModule",{value:!0});K.checkStrictMode=K.getErrorPath=K.Type=K.useFunc=K.setEvaluated=K.evaluatedPropsToName=K.mergeEvaluated=K.eachItem=K.unescapeJsonPointer=K.escapeJsonPointer=K.escapeFragment=K.unescapeFragment=K.schemaRefOrVal=K.schemaHasRulesButRef=K.schemaHasRules=K.checkUnknownRules=K.alwaysValidSchema=K.toHash=void 0;const ye=fe,x$=En;function A$(e){const t={};for(const r of e)t[r]=!0;return t}K.toHash=A$;function M$(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(kd(e,t),!Pd(t,e.self.RULES.all))}K.alwaysValidSchema=M$;function kd(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]||Cd(e,`unknown keyword: "${o}"`)}K.checkUnknownRules=kd;function Pd(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(t[r])return!0;return!1}K.schemaHasRules=Pd;function z$(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}K.schemaHasRulesButRef=z$;function D$({topSchemaRef:e,schemaPath:t},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,ye._)`${r}`}return(0,ye._)`${e}${t}${(0,ye.getProperty)(n)}`}K.schemaRefOrVal=D$;function q$(e){return Rd(decodeURIComponent(e))}K.unescapeFragment=q$;function U$(e){return encodeURIComponent(Ja(e))}K.escapeFragment=U$;function Ja(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}K.escapeJsonPointer=Ja;function Rd(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}K.unescapeJsonPointer=Rd;function F$(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)}K.eachItem=F$;function al({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(s,o,a,i)=>{const c=a===void 0?o:a instanceof ye.Name?(o instanceof ye.Name?e(s,o,a):t(s,o,a),a):o instanceof ye.Name?(t(s,a,o),o):r(o,a);return i===ye.Name&&!(c instanceof ye.Name)?n(s,c):c}}K.mergeEvaluated={props:al({mergeNames:(e,t,r)=>e.if((0,ye._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,ye._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,ye._)`${r} || {}`).code((0,ye._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,ye._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,ye._)`${r} || {}`),Qa(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Td}),items:al({mergeNames:(e,t,r)=>e.if((0,ye._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,ye._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,ye._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,ye._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Td(e,t){if(t===!0)return e.var("props",!0);const r=e.var("props",(0,ye._)`{}`);return t!==void 0&&Qa(e,r,t),r}K.evaluatedPropsToName=Td;function Qa(e,t,r){Object.keys(r).forEach(n=>e.assign((0,ye._)`${t}${(0,ye.getProperty)(n)}`,!0))}K.setEvaluated=Qa;const il={};function L$(e,t){return e.scopeValue("func",{ref:t,code:il[t.code]||(il[t.code]=new x$._Code(t.code))})}K.useFunc=L$;var Mo;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Mo||(K.Type=Mo={}));function V$(e,t,r){if(e instanceof ye.Name){const n=t===Mo.Num;return r?n?(0,ye._)`"[" + ${e} + "]"`:(0,ye._)`"['" + ${e} + "']"`:n?(0,ye._)`"/" + ${e}`:(0,ye._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,ye.getProperty)(e).toString():"/"+Ja(e)}K.getErrorPath=V$;function Cd(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}K.checkStrictMode=Cd;var bt={};Object.defineProperty(bt,"__esModule",{value:!0});const Ze=fe,H$={data:new Ze.Name("data"),valCxt:new Ze.Name("valCxt"),instancePath:new Ze.Name("instancePath"),parentData:new Ze.Name("parentData"),parentDataProperty:new Ze.Name("parentDataProperty"),rootData:new Ze.Name("rootData"),dynamicAnchors:new Ze.Name("dynamicAnchors"),vErrors:new Ze.Name("vErrors"),errors:new Ze.Name("errors"),this:new Ze.Name("this"),self:new Ze.Name("self"),scope:new Ze.Name("scope"),json:new Ze.Name("json"),jsonPos:new Ze.Name("jsonPos"),jsonLen:new Ze.Name("jsonLen"),jsonPart:new Ze.Name("jsonPart")};bt.default=H$;(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=fe,r=K,n=bt;e.keywordError={message:({keyword:g})=>(0,t.str)`must pass "${g}" keyword validation`},e.keyword$DataError={message:({keyword:g,schemaType:f})=>f?(0,t.str)`"${g}" keyword must be ${f} ($data)`:(0,t.str)`"${g}" keyword is invalid ($data)`};function s(g,f=e.keywordError,$,E){const{it:T}=g,{gen:R,compositeRule:O,allErrors:x}=T,U=h(g,f,$);E??(O||x)?c(R,U):l(T,(0,t._)`[${U}]`)}e.reportError=s;function o(g,f=e.keywordError,$){const{it:E}=g,{gen:T,compositeRule:R,allErrors:O}=E,x=h(g,f,$);c(T,x),R||O||l(E,n.default.vErrors)}e.reportExtraError=o;function a(g,f){g.assign(n.default.errors,f),g.if((0,t._)`${n.default.vErrors} !== null`,()=>g.if(f,()=>g.assign((0,t._)`${n.default.vErrors}.length`,f),()=>g.assign(n.default.vErrors,null)))}e.resetErrorsCount=a;function i({gen:g,keyword:f,schemaValue:$,data:E,errsCount:T,it:R}){if(T===void 0)throw new Error("ajv implementation error");const O=g.name("err");g.forRange("i",T,n.default.errors,x=>{g.const(O,(0,t._)`${n.default.vErrors}[${x}]`),g.if((0,t._)`${O}.instancePath === undefined`,()=>g.assign((0,t._)`${O}.instancePath`,(0,t.strConcat)(n.default.instancePath,R.errorPath))),g.assign((0,t._)`${O}.schemaPath`,(0,t.str)`${R.errSchemaPath}/${f}`),R.opts.verbose&&(g.assign((0,t._)`${O}.schema`,$),g.assign((0,t._)`${O}.data`,E))})}e.extendErrors=i;function c(g,f){const $=g.const("err",f);g.if((0,t._)`${n.default.vErrors} === null`,()=>g.assign(n.default.vErrors,(0,t._)`[${$}]`),(0,t._)`${n.default.vErrors}.push(${$})`),g.code((0,t._)`${n.default.errors}++`)}function l(g,f){const{gen:$,validateName:E,schemaEnv:T}=g;T.$async?$.throw((0,t._)`new ${g.ValidationError}(${f})`):($.assign((0,t._)`${E}.errors`,f),$.return(!1))}const d={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function h(g,f,$){const{createErrors:E}=g.it;return E===!1?(0,t._)`{}`:m(g,f,$)}function m(g,f,$={}){const{gen:E,it:T}=g,R=[_(T,$),v(g,$)];return y(g,f,R),E.object(...R)}function _({errorPath:g},{instancePath:f}){const $=f?(0,t.str)`${g}${(0,r.getErrorPath)(f,r.Type.Str)}`:g;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,$)]}function v({keyword:g,it:{errSchemaPath:f}},{schemaPath:$,parentSchema:E}){let T=E?f:(0,t.str)`${f}/${g}`;return $&&(T=(0,t.str)`${T}${(0,r.getErrorPath)($,r.Type.Str)}`),[d.schemaPath,T]}function y(g,{params:f,message:$},E){const{keyword:T,data:R,schemaValue:O,it:x}=g,{opts:U,propertyName:D,topSchemaRef:q,schemaPath:L}=x;E.push([d.keyword,T],[d.params,typeof f=="function"?f(g):f||(0,t._)`{}`]),U.messages&&E.push([d.message,typeof $=="function"?$(g):$]),U.verbose&&E.push([d.schema,O],[d.parentSchema,(0,t._)`${q}${L}`],[n.default.data,R]),D&&E.push([d.propertyName,D])}})(Mn);Object.defineProperty(qr,"__esModule",{value:!0});qr.boolOrEmptySchema=qr.topBoolOrEmptySchema=void 0;const Z$=Mn,K$=fe,G$=bt,W$={message:"boolean schema is false"};function B$(e){const{gen:t,schema:r,validateName:n}=e;r===!1?jd(e,!1):typeof r=="object"&&r.$async===!0?t.return(G$.default.data):(t.assign((0,K$._)`${n}.errors`,null),t.return(!0))}qr.topBoolOrEmptySchema=B$;function J$(e,t){const{gen:r,schema:n}=e;n===!1?(r.var(t,!1),jd(e)):r.var(t,!0)}qr.boolOrEmptySchema=J$;function jd(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,Z$.reportError)(s,W$,void 0,t)}var Oe={},gr={};Object.defineProperty(gr,"__esModule",{value:!0});gr.getRules=gr.isJSONType=void 0;const Q$=["string","number","integer","boolean","null","object","array"],Y$=new Set(Q$);function X$(e){return typeof e=="string"&&Y$.has(e)}gr.isJSONType=X$;function ew(){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:{}}}gr.getRules=ew;var Et={};Object.defineProperty(Et,"__esModule",{value:!0});Et.shouldUseRule=Et.shouldUseGroup=Et.schemaHasRulesForType=void 0;function tw({schema:e,self:t},r){const n=t.RULES.types[r];return n&&n!==!0&&Nd(e,n)}Et.schemaHasRulesForType=tw;function Nd(e,t){return t.rules.some(r=>Id(e,r))}Et.shouldUseGroup=Nd;function Id(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))}Et.shouldUseRule=Id;Object.defineProperty(Oe,"__esModule",{value:!0});Oe.reportTypeError=Oe.checkDataTypes=Oe.checkDataType=Oe.coerceAndCheckDataType=Oe.getJSONTypes=Oe.getSchemaTypes=Oe.DataType=void 0;const rw=gr,nw=Et,sw=Mn,oe=fe,Od=K;var xr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(xr||(Oe.DataType=xr={}));function ow(e){const t=xd(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}Oe.getSchemaTypes=ow;function xd(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(rw.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Oe.getJSONTypes=xd;function aw(e,t){const{gen:r,data:n,opts:s}=e,o=iw(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0,nw.schemaHasRulesForType)(e,t[0]));if(a){const i=Ya(t,n,s.strictNumbers,xr.Wrong);r.if(i,()=>{o.length?cw(e,t,o):Xa(e)})}return a}Oe.coerceAndCheckDataType=aw;const Ad=new Set(["string","number","integer","boolean","null"]);function iw(e,t){return t?e.filter(r=>Ad.has(r)||t==="array"&&r==="array"):[]}function cw(e,t,r){const{gen:n,data:s,opts:o}=e,a=n.let("dataType",(0,oe._)`typeof ${s}`),i=n.let("coerced",(0,oe._)`undefined`);o.coerceTypes==="array"&&n.if((0,oe._)`${a} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,oe._)`${s}[0]`).assign(a,(0,oe._)`typeof ${s}`).if(Ya(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0,oe._)`${i} !== undefined`);for(const l of r)(Ad.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),Xa(e),n.endIf(),n.if((0,oe._)`${i} !== undefined`,()=>{n.assign(s,i),lw(e,i)});function c(l){switch(l){case"string":n.elseIf((0,oe._)`${a} == "number" || ${a} == "boolean"`).assign(i,(0,oe._)`"" + ${s}`).elseIf((0,oe._)`${s} === null`).assign(i,(0,oe._)`""`);return;case"number":n.elseIf((0,oe._)`${a} == "boolean" || ${s} === null - || (${a} == "string" && ${s} && ${s} == +${s})`).assign(i,(0,oe._)`+${s}`);return;case"integer":n.elseIf((0,oe._)`${a} === "boolean" || ${s} === null - || (${a} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(i,(0,oe._)`+${s}`);return;case"boolean":n.elseIf((0,oe._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(i,!1).elseIf((0,oe._)`${s} === "true" || ${s} === 1`).assign(i,!0);return;case"null":n.elseIf((0,oe._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(i,null);return;case"array":n.elseIf((0,oe._)`${a} === "string" || ${a} === "number" - || ${a} === "boolean" || ${s} === null`).assign(i,(0,oe._)`[${s}]`)}}}function lw({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,oe._)`${t} !== undefined`,()=>e.assign((0,oe._)`${t}[${r}]`,n))}function zo(e,t,r,n=xr.Correct){const s=n===xr.Correct?oe.operators.EQ:oe.operators.NEQ;let o;switch(e){case"null":return(0,oe._)`${t} ${s} null`;case"array":o=(0,oe._)`Array.isArray(${t})`;break;case"object":o=(0,oe._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=a((0,oe._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=a();break;default:return(0,oe._)`typeof ${t} ${s} ${e}`}return n===xr.Correct?o:(0,oe.not)(o);function a(i=oe.nil){return(0,oe.and)((0,oe._)`typeof ${t} == "number"`,i,r?(0,oe._)`isFinite(${t})`:oe.nil)}}Oe.checkDataType=zo;function Ya(e,t,r,n){if(e.length===1)return zo(e[0],t,r,n);let s;const o=(0,Od.toHash)(e);if(o.array&&o.object){const a=(0,oe._)`typeof ${t} != "object"`;s=o.null?a:(0,oe._)`!${t} || ${a}`,delete o.null,delete o.array,delete o.object}else s=oe.nil;o.number&&delete o.integer;for(const a in o)s=(0,oe.and)(s,zo(a,t,r,n));return s}Oe.checkDataTypes=Ya;const uw={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,oe._)`{type: ${e}}`:(0,oe._)`{type: ${t}}`};function Xa(e){const t=dw(e);(0,sw.reportError)(t,uw)}Oe.reportTypeError=Xa;function dw(e){const{gen:t,data:r,schema:n}=e,s=(0,Od.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}var Ks={};Object.defineProperty(Ks,"__esModule",{value:!0});Ks.assignDefaults=void 0;const Sr=fe,fw=K;function hw(e,t){const{properties:r,items:n}=e.schema;if(t==="object"&&r)for(const s in r)cl(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>cl(e,o,s.default))}Ks.assignDefaults=hw;function cl(e,t,r){const{gen:n,compositeRule:s,data:o,opts:a}=e;if(r===void 0)return;const i=(0,Sr._)`${o}${(0,Sr.getProperty)(t)}`;if(s){(0,fw.checkStrictMode)(e,`default is ignored for: ${i}`);return}let c=(0,Sr._)`${i} === undefined`;a.useDefaults==="empty"&&(c=(0,Sr._)`${c} || ${i} === null || ${i} === ""`),n.if(c,(0,Sr._)`${i} = ${(0,Sr.stringify)(r)}`)}var $t={},ue={};Object.defineProperty(ue,"__esModule",{value:!0});ue.validateUnion=ue.validateArray=ue.usePattern=ue.callValidateCode=ue.schemaProperties=ue.allSchemaProperties=ue.noPropertyInData=ue.propertyInData=ue.isOwnProperty=ue.hasPropFunc=ue.reportMissingProp=ue.checkMissingProp=ue.checkReportMissingProp=void 0;const be=fe,ei=K,Tt=bt,pw=K;function mw(e,t){const{gen:r,data:n,it:s}=e;r.if(ri(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0,be._)`${t}`},!0),e.error()})}ue.checkReportMissingProp=mw;function gw({gen:e,data:t,it:{opts:r}},n,s){return(0,be.or)(...n.map(o=>(0,be.and)(ri(e,t,o,r.ownProperties),(0,be._)`${s} = ${o}`)))}ue.checkMissingProp=gw;function _w(e,t){e.setParams({missingProperty:t},!0),e.error()}ue.reportMissingProp=_w;function Md(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,be._)`Object.prototype.hasOwnProperty`})}ue.hasPropFunc=Md;function ti(e,t,r){return(0,be._)`${Md(e)}.call(${t}, ${r})`}ue.isOwnProperty=ti;function yw(e,t,r,n){const s=(0,be._)`${t}${(0,be.getProperty)(r)} !== undefined`;return n?(0,be._)`${s} && ${ti(e,t,r)}`:s}ue.propertyInData=yw;function ri(e,t,r,n){const s=(0,be._)`${t}${(0,be.getProperty)(r)} === undefined`;return n?(0,be.or)(s,(0,be.not)(ti(e,t,r))):s}ue.noPropertyInData=ri;function zd(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}ue.allSchemaProperties=zd;function vw(e,t){return zd(t).filter(r=>!(0,ei.alwaysValidSchema)(e,t[r]))}ue.schemaProperties=vw;function $w({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:a},i,c,l){const d=l?(0,be._)`${e}, ${t}, ${n}${s}`:t,h=[[Tt.default.instancePath,(0,be.strConcat)(Tt.default.instancePath,o)],[Tt.default.parentData,a.parentData],[Tt.default.parentDataProperty,a.parentDataProperty],[Tt.default.rootData,Tt.default.rootData]];a.opts.dynamicRef&&h.push([Tt.default.dynamicAnchors,Tt.default.dynamicAnchors]);const m=(0,be._)`${d}, ${r.object(...h)}`;return c!==be.nil?(0,be._)`${i}.call(${c}, ${m})`:(0,be._)`${i}(${m})`}ue.callValidateCode=$w;const ww=(0,be._)`new RegExp`;function bw({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,be._)`${s.code==="new RegExp"?ww:(0,pw.useFunc)(e,s)}(${r}, ${n})`})}ue.usePattern=bw;function Sw(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,be._)`${r}.length`);t.forRange("i",0,c,l=>{e.subschema({keyword:n,dataProp:l,dataPropType:ei.Type.Num},o),t.if((0,be.not)(o),i)})}}ue.validateArray=Sw;function Ew(e){const{gen:t,schema:r,keyword:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,ei.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,be._)`${a} || ${i}`),e.mergeValidEvaluated(d,i)||t.if((0,be.not)(a))})),e.result(a,()=>e.reset(),()=>e.error(!0))}ue.validateUnion=Ew;Object.defineProperty($t,"__esModule",{value:!0});$t.validateKeywordUsage=$t.validSchemaType=$t.funcKeywordCode=$t.macroKeywordCode=void 0;const Ge=fe,cr=bt,kw=ue,Pw=Mn;function Rw(e,t){const{gen:r,keyword:n,schema:s,parentSchema:o,it:a}=e,i=t.macro.call(a.self,s,o,a),c=Dd(r,n,i);a.opts.validateSchema!==!1&&a.self.validateSchema(i,!0);const l=r.name("valid");e.subschema({schema:i,schemaPath:Ge.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},l),e.pass(l,()=>e.error(!0))}$t.macroKeywordCode=Rw;function Tw(e,t){var r;const{gen:n,keyword:s,schema:o,parentSchema:a,$data:i,it:c}=e;jw(c,t);const l=!i&&t.compile?t.compile.call(c.self,o,a,c):t.validate,d=Dd(n,s,l),h=n.let("valid");e.block$data(h,m),e.ok((r=t.valid)!==null&&r!==void 0?r:h);function m(){if(t.errors===!1)y(),t.modifying&&ll(e),g(()=>e.error());else{const f=t.async?_():v();t.modifying&&ll(e),g(()=>Cw(e,f))}}function _(){const f=n.let("ruleErrs",null);return n.try(()=>y((0,Ge._)`await `),$=>n.assign(h,!1).if((0,Ge._)`${$} instanceof ${c.ValidationError}`,()=>n.assign(f,(0,Ge._)`${$}.errors`),()=>n.throw($))),f}function v(){const f=(0,Ge._)`${d}.errors`;return n.assign(f,null),y(Ge.nil),f}function y(f=t.async?(0,Ge._)`await `:Ge.nil){const $=c.opts.passContext?cr.default.this:cr.default.self,E=!("compile"in t&&!i||t.schema===!1);n.assign(h,(0,Ge._)`${f}${(0,kw.callValidateCode)(e,d,$,E)}`,t.modifying)}function g(f){var $;n.if((0,Ge.not)(($=t.valid)!==null&&$!==void 0?$:h),f)}}$t.funcKeywordCode=Tw;function ll(e){const{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Ge._)`${n.parentData}[${n.parentDataProperty}]`))}function Cw(e,t){const{gen:r}=e;r.if((0,Ge._)`Array.isArray(${t})`,()=>{r.assign(cr.default.vErrors,(0,Ge._)`${cr.default.vErrors} === null ? ${t} : ${cr.default.vErrors}.concat(${t})`).assign(cr.default.errors,(0,Ge._)`${cr.default.vErrors}.length`),(0,Pw.extendErrors)(e)},()=>e.error())}function jw({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function Dd(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Ge.stringify)(r)})}function Nw(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")}$t.validSchemaType=Nw;function Iw({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)}}$t.validateKeywordUsage=Iw;var Dt={};Object.defineProperty(Dt,"__esModule",{value:!0});Dt.extendSubschemaMode=Dt.extendSubschemaData=Dt.getSubschema=void 0;const yt=fe,qd=K;function Ow(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,yt._)`${e.schemaPath}${(0,yt.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:i[r],schemaPath:(0,yt._)`${e.schemaPath}${(0,yt.getProperty)(t)}${(0,yt.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,qd.escapeFragment)(r)}`}}if(n!==void 0){if(s===void 0||o===void 0||a===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:s,topSchemaRef:a,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}Dt.getSubschema=Ow;function xw(e,t,{dataProp:r,dataPropType:n,data:s,dataTypes:o,propertyName:a}){if(s!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:i}=t;if(r!==void 0){const{errorPath:l,dataPathArr:d,opts:h}=t,m=i.let("data",(0,yt._)`${t.data}${(0,yt.getProperty)(r)}`,!0);c(m),e.errorPath=(0,yt.str)`${l}${(0,qd.getErrorPath)(r,n,h.jsPropertySyntax)}`,e.parentDataProperty=(0,yt._)`${r}`,e.dataPathArr=[...d,e.parentDataProperty]}if(s!==void 0){const l=s instanceof yt.Name?s:i.let("data",s,!0);c(l),a!==void 0&&(e.propertyName=a)}o&&(e.dataTypes=o);function c(l){e.data=l,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,l]}}Dt.extendSubschemaData=xw;function Aw(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:s,allErrors:o}){n!==void 0&&(e.compositeRule=n),s!==void 0&&(e.createErrors=s),o!==void 0&&(e.allErrors=o),e.jtdDiscriminator=t,e.jtdMetadata=r}Dt.extendSubschemaMode=Aw;var Ue={},Gs=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},Ud={exports:{}},At=Ud.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(){};os(t,n,s,e,"",e)};At.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};At.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};At.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};At.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function os(e,t,r,n,s,o,a,i,c,l){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,s,o,a,i,c,l);for(var d in n){var h=n[d];if(Array.isArray(h)){if(d in At.arrayKeywords)for(var m=0;mt+=Fd(n)),t===1/0))return 1/0}return t}function Ld(e,t="",r){r!==!1&&(t=Ar(t));const n=e.parse(t);return Vd(e,n)}Ue.getFullPath=Ld;function Vd(e,t){return e.serialize(t).split("#")[0]+"#"}Ue._getFullPath=Vd;const Hw=/#\/?$/;function Ar(e){return e?e.replace(Hw,""):""}Ue.normalizeId=Ar;function Zw(e,t,r){return r=Ar(r),e.resolve(t,r)}Ue.resolveUrl=Zw;const Kw=/^[a-z_][-a-z0-9._]*$/i;function Gw(e,t){if(typeof e=="boolean")return{};const{schemaId:r,uriResolver:n}=this.opts,s=Ar(e[r]||t),o={"":s},a=Ld(n,s,!1),i={},c=new Set;return Uw(e,{allKeys:!0},(h,m,_,v)=>{if(v===void 0)return;const y=a+m;let g=o[v];typeof h[r]=="string"&&(g=f.call(this,h[r])),$.call(this,h.$anchor),$.call(this,h.$dynamicAnchor),o[m]=g;function f(E){const T=this.opts.uriResolver.resolve;if(E=Ar(g?T(g,E):E),c.has(E))throw d(E);c.add(E);let R=this.refs[E];return typeof R=="string"&&(R=this.refs[R]),typeof R=="object"?l(h,R.schema,E):E!==Ar(y)&&(E[0]==="#"?(l(h,i[E],E),i[E]=h):this.refs[E]=y),E}function $(E){if(typeof E=="string"){if(!Kw.test(E))throw new Error(`invalid anchor "${E}"`);f.call(this,`#${E}`)}}}),i;function l(h,m,_){if(m!==void 0&&!qw(h,m))throw d(_)}function d(h){return new Error(`reference "${h}" resolves to more than one schema`)}}Ue.getSchemaRefs=Gw;Object.defineProperty(mt,"__esModule",{value:!0});mt.getData=mt.KeywordCxt=mt.validateFunctionCode=void 0;const Hd=qr,ul=Oe,ni=Et,$s=Oe,Ww=Ks,un=$t,co=Dt,Q=fe,ee=bt,Bw=Ue,kt=K,en=Mn;function Jw(e){if(Gd(e)&&(Wd(e),Kd(e))){Xw(e);return}Zd(e,()=>(0,Hd.topBoolOrEmptySchema)(e))}mt.validateFunctionCode=Jw;function Zd({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},o){s.code.es5?e.func(t,(0,Q._)`${ee.default.data}, ${ee.default.valCxt}`,n.$async,()=>{e.code((0,Q._)`"use strict"; ${dl(r,s)}`),Yw(e,s),e.code(o)}):e.func(t,(0,Q._)`${ee.default.data}, ${Qw(s)}`,n.$async,()=>e.code(dl(r,s)).code(o))}function Qw(e){return(0,Q._)`{${ee.default.instancePath}="", ${ee.default.parentData}, ${ee.default.parentDataProperty}, ${ee.default.rootData}=${ee.default.data}${e.dynamicRef?(0,Q._)`, ${ee.default.dynamicAnchors}={}`:Q.nil}}={}`}function Yw(e,t){e.if(ee.default.valCxt,()=>{e.var(ee.default.instancePath,(0,Q._)`${ee.default.valCxt}.${ee.default.instancePath}`),e.var(ee.default.parentData,(0,Q._)`${ee.default.valCxt}.${ee.default.parentData}`),e.var(ee.default.parentDataProperty,(0,Q._)`${ee.default.valCxt}.${ee.default.parentDataProperty}`),e.var(ee.default.rootData,(0,Q._)`${ee.default.valCxt}.${ee.default.rootData}`),t.dynamicRef&&e.var(ee.default.dynamicAnchors,(0,Q._)`${ee.default.valCxt}.${ee.default.dynamicAnchors}`)},()=>{e.var(ee.default.instancePath,(0,Q._)`""`),e.var(ee.default.parentData,(0,Q._)`undefined`),e.var(ee.default.parentDataProperty,(0,Q._)`undefined`),e.var(ee.default.rootData,ee.default.data),t.dynamicRef&&e.var(ee.default.dynamicAnchors,(0,Q._)`{}`)})}function Xw(e){const{schema:t,opts:r,gen:n}=e;Zd(e,()=>{r.$comment&&t.$comment&&Jd(e),s0(e),n.let(ee.default.vErrors,null),n.let(ee.default.errors,0),r.unevaluated&&e0(e),Bd(e),i0(e)})}function e0(e){const{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,Q._)`${r}.evaluated`),t.if((0,Q._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,Q._)`${e.evaluated}.props`,(0,Q._)`undefined`)),t.if((0,Q._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,Q._)`${e.evaluated}.items`,(0,Q._)`undefined`))}function dl(e,t){const r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,Q._)`/*# sourceURL=${r} */`:Q.nil}function t0(e,t){if(Gd(e)&&(Wd(e),Kd(e))){r0(e,t);return}(0,Hd.boolOrEmptySchema)(e,t)}function Kd({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 Gd(e){return typeof e.schema!="boolean"}function r0(e,t){const{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&Jd(e),o0(e),a0(e);const o=n.const("_errs",ee.default.errors);Bd(e,o),n.var(t,(0,Q._)`${o} === ${ee.default.errors}`)}function Wd(e){(0,kt.checkUnknownRules)(e),n0(e)}function Bd(e,t){if(e.opts.jtd)return fl(e,[],!1,t);const r=(0,ul.getSchemaTypes)(e.schema),n=(0,ul.coerceAndCheckDataType)(e,r);fl(e,r,!n,t)}function n0(e){const{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,kt.schemaHasRulesButRef)(t,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function s0(e){const{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,kt.checkStrictMode)(e,"default is ignored in the schema root")}function o0(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,Bw.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function a0(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Jd({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:s}){const o=r.$comment;if(s.$comment===!0)e.code((0,Q._)`${ee.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){const a=(0,Q.str)`${n}/$comment`,i=e.scopeValue("root",{ref:t.root});e.code((0,Q._)`${ee.default.self}.opts.$comment(${o}, ${a}, ${i}.schema)`)}}function i0(e){const{gen:t,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=e;r.$async?t.if((0,Q._)`${ee.default.errors} === 0`,()=>t.return(ee.default.data),()=>t.throw((0,Q._)`new ${s}(${ee.default.vErrors})`)):(t.assign((0,Q._)`${n}.errors`,ee.default.vErrors),o.unevaluated&&c0(e),t.return((0,Q._)`${ee.default.errors} === 0`))}function c0({gen:e,evaluated:t,props:r,items:n}){r instanceof Q.Name&&e.assign((0,Q._)`${t}.props`,r),n instanceof Q.Name&&e.assign((0,Q._)`${t}.items`,n)}function fl(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,kt.schemaHasRulesButRef)(o,d))){s.block(()=>Xd(e,"$ref",d.all.$ref.definition));return}c.jtd||l0(e,t),s.block(()=>{for(const m of d.rules)h(m);h(d.post)});function h(m){(0,ni.shouldUseGroup)(o,m)&&(m.type?(s.if((0,$s.checkDataType)(m.type,a,c.strictNumbers)),hl(e,m),t.length===1&&t[0]===m.type&&r&&(s.else(),(0,$s.reportTypeError)(e)),s.endIf()):hl(e,m),i||s.if((0,Q._)`${ee.default.errors} === ${n||0}`))}}function hl(e,t){const{gen:r,schema:n,opts:{useDefaults:s}}=e;s&&(0,Ww.assignDefaults)(e,t.type),r.block(()=>{for(const o of t.rules)(0,ni.shouldUseRule)(n,o)&&Xd(e,o.keyword,o.definition,t.type)})}function l0(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(u0(e,t),e.opts.allowUnionTypes||d0(e,t),f0(e,e.dataTypes))}function u0(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{Qd(e.dataTypes,r)||si(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),p0(e,t)}}function d0(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&si(e,"use allowUnionTypes to allow union type keyword")}function f0(e,t){const r=e.self.RULES.all;for(const n in r){const s=r[n];if(typeof s=="object"&&(0,ni.shouldUseRule)(e.schema,s)){const{type:o}=s.definition;o.length&&!o.some(a=>h0(t,a))&&si(e,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function h0(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function Qd(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function p0(e,t){const r=[];for(const n of e.dataTypes)Qd(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function si(e,t){const r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,kt.checkStrictMode)(e,t,e.opts.strictTypes)}let Yd=class{constructor(t,r,n){if((0,un.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,kt.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",ef(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,un.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",ee.default.errors))}result(t,r,n){this.failResult((0,Q.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,Q.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);const{schemaCode:r}=this;this.fail((0,Q._)`${r} !== undefined && (${(0,Q.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?en.reportExtraError:en.reportError)(this,this.def.error,r)}$dataError(){(0,en.reportError)(this,this.def.$dataError||en.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,en.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=Q.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=Q.nil,r=Q.nil){if(!this.$data)return;const{gen:n,schemaCode:s,schemaType:o,def:a}=this;n.if((0,Q.or)((0,Q._)`${s} === undefined`,r)),t!==Q.nil&&n.assign(t,!0),(o.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==Q.nil&&n.assign(t,!1)),n.else()}invalid$data(){const{gen:t,schemaCode:r,schemaType:n,def:s,it:o}=this;return(0,Q.or)(a(),i());function a(){if(n.length){if(!(r instanceof Q.Name))throw new Error("ajv implementation error");const c=Array.isArray(n)?n:[n];return(0,Q._)`${(0,$s.checkDataTypes)(c,r,o.opts.strictNumbers,$s.DataType.Wrong)}`}return Q.nil}function i(){if(s.validateSchema){const c=t.scopeValue("validate$data",{ref:s.validateSchema});return(0,Q._)`!${c}(${r})`}return Q.nil}}subschema(t,r){const n=(0,co.getSubschema)(this.it,t);(0,co.extendSubschemaData)(n,this.it,t),(0,co.extendSubschemaMode)(n,t);const s={...this.it,...n,items:void 0,props:void 0};return t0(s,r),s}mergeEvaluated(t,r){const{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=kt.mergeEvaluated.props(s,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=kt.mergeEvaluated.items(s,t.items,n.items,r)))}mergeValidEvaluated(t,r){const{it:n,gen:s}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return s.if(r,()=>this.mergeEvaluated(t,Q.Name)),!0}};mt.KeywordCxt=Yd;function Xd(e,t,r,n){const s=new Yd(e,r,t);"code"in r?r.code(s,n):s.$data&&r.validate?(0,un.funcKeywordCode)(s,r):"macro"in r?(0,un.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,un.funcKeywordCode)(s,r)}const m0=/^\/(?:[^~]|~0|~1)*$/,g0=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function ef(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,o;if(e==="")return ee.default.rootData;if(e[0]==="/"){if(!m0.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,o=ee.default.rootData}else{const l=g0.exec(e);if(!l)throw new Error(`Invalid JSON-pointer: ${e}`);const d=+l[1];if(s=l[2],s==="#"){if(d>=t)throw new Error(c("property/index",d));return n[t-d]}if(d>t)throw new Error(c("data",d));if(o=r[t-d],!s)return o}let a=o;const i=s.split("/");for(const l of i)l&&(o=(0,Q._)`${o}${(0,Q.getProperty)((0,kt.unescapeJsonPointer)(l))}`,a=(0,Q._)`${a} && ${o}`);return a;function c(l,d){return`Cannot access ${l} ${d} levels up, current level is ${t}`}}mt.getData=ef;var zn={};Object.defineProperty(zn,"__esModule",{value:!0});let _0=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};zn.default=_0;var Zr={};Object.defineProperty(Zr,"__esModule",{value:!0});const lo=Ue;let y0=class extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,lo.resolveUrl)(t,r,n),this.missingSchema=(0,lo.normalizeId)((0,lo.getFullPath)(t,this.missingRef))}};Zr.default=y0;var Qe={};Object.defineProperty(Qe,"__esModule",{value:!0});Qe.resolveSchema=Qe.getCompilingSchema=Qe.resolveRef=Qe.compileSchema=Qe.SchemaEnv=void 0;const lt=fe,v0=zn,nr=bt,ht=Ue,pl=K,$0=mt;let Ws=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,ht.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={}}};Qe.SchemaEnv=Ws;function oi(e){const t=tf.call(this,e);if(t)return t;const r=(0,ht.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,a=new lt.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o});let i;e.$async&&(i=a.scopeValue("Error",{ref:v0.default,code:(0,lt._)`require("ajv/dist/runtime/validation_error").default`}));const c=a.scopeName("validate");e.validateName=c;const l={gen:a,allErrors:this.opts.allErrors,data:nr.default.data,parentData:nr.default.parentData,parentDataProperty:nr.default.parentDataProperty,dataNames:[nr.default.data],dataPathArr:[lt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,lt.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:lt.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,lt._)`""`,opts:this.opts,self:this};let d;try{this._compilations.add(e),(0,$0.validateFunctionCode)(l),a.optimize(this.opts.code.optimize);const h=a.toString();d=`${a.scopeRefs(nr.default.scope)}return ${h}`,this.opts.code.process&&(d=this.opts.code.process(d,e));const _=new Function(`${nr.default.self}`,`${nr.default.scope}`,d)(this,this.scope.get());if(this.scope.value(c,{ref:_}),_.errors=null,_.schema=e.schema,_.schemaEnv=e,e.$async&&(_.$async=!0),this.opts.code.source===!0&&(_.source={validateName:c,validateCode:h,scopeValues:a._values}),this.opts.unevaluated){const{props:v,items:y}=l;_.evaluated={props:v instanceof lt.Name?void 0:v,items:y instanceof lt.Name?void 0:y,dynamicProps:v instanceof lt.Name,dynamicItems:y instanceof lt.Name},_.source&&(_.source.evaluated=(0,lt.stringify)(_.evaluated))}return e.validate=_,e}catch(h){throw delete e.validate,delete e.validateName,d&&this.logger.error("Error compiling schema, function code:",d),h}finally{this._compilations.delete(e)}}Qe.compileSchema=oi;function w0(e,t,r){var n;r=(0,ht.resolveUrl)(this.opts.uriResolver,t,r);const s=e.refs[r];if(s)return s;let o=E0.call(this,e,r);if(o===void 0){const a=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:i}=this.opts;a&&(o=new Ws({schema:a,schemaId:i,root:e,baseId:t}))}if(o!==void 0)return e.refs[r]=b0.call(this,o)}Qe.resolveRef=w0;function b0(e){return(0,ht.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:oi.call(this,e)}function tf(e){for(const t of this._compilations)if(S0(t,e))return t}Qe.getCompilingSchema=tf;function S0(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function E0(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Bs.call(this,e,t)}function Bs(e,t){const r=this.opts.uriResolver.parse(t),n=(0,ht._getFullPath)(this.opts.uriResolver,r);let s=(0,ht.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===s)return uo.call(this,r,e);const o=(0,ht.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){const i=Bs.call(this,e,a);return typeof(i==null?void 0:i.schema)!="object"?void 0:uo.call(this,r,i)}if(typeof(a==null?void 0:a.schema)=="object"){if(a.validate||oi.call(this,a),o===(0,ht.normalizeId)(t)){const{schema:i}=a,{schemaId:c}=this.opts,l=i[c];return l&&(s=(0,ht.resolveUrl)(this.opts.uriResolver,s,l)),new Ws({schema:i,schemaId:c,root:e,baseId:s})}return uo.call(this,r,a)}}Qe.resolveSchema=Bs;const k0=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function uo(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,pl.unescapeFragment)(i)];if(c===void 0)return;r=c;const l=typeof r=="object"&&r[this.opts.schemaId];!k0.has(i)&&l&&(t=(0,ht.resolveUrl)(this.opts.uriResolver,t,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,pl.schemaHasRulesButRef)(r,this.RULES)){const i=(0,ht.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=Bs.call(this,n,i)}const{schemaId:a}=this.opts;if(o=o||new Ws({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}const P0="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",R0="Meta-schema for $data reference (JSON AnySchema extension proposal)",T0="object",C0=["$data"],j0={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},N0=!1,I0={$id:P0,description:R0,type:T0,required:C0,properties:j0,additionalProperties:N0};var ai={},Js={exports:{}};const O0=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),rf=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),ii=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),nf=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),x0=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function sf(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 A0=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function ml(e){return e.length=0,!0}function M0(e,t,r){if(e.length){const n=sf(e);if(n!=="")t.push(n);else return r.error=!0,!1;e.length=0}return!0}function z0(e){let t=0;const r={error:!1,address:"",zone:""},n=[],s=[];let o=!1,a=!1,i=M0;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=ml}else{s.push(l);continue}}return s.length&&(i===ml?r.zone=s.join(""):a?n.push(s.join("")):n.push(sf(s))),r.address=n.join(""),r}function of(e){if(D0(e,":")<2)return{host:e,isIPV6:!1};const t=z0(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 D0(e,t){let r=0;for(let n=0;nU0[n])}function V0(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n65535))return"URI port is malformed."}function bs(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(vb);a!==null&&a[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",s=!0);const i=e.match($b);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(yb);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=wb(n,c);if(l!==void 0&&(n.error=n.error||l,s=!0),n.host)if(fb(n.host)===!1){const m=ab(n.host);n.host=m.host.toLowerCase(),o=m.isIPV6}else o=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");const d=hf(r.scheme||n.scheme);if(!r.unicodeSupport&&(!d||!d.unicodeSupport)&&n.host&&(r.domainHost||d&&d.domainHost)&&o===!1&&hb(n.host))try{n.host=new URL("http://"+n.host).hostname}catch(h){n.error=n.error||"Host's domain name can not be converted to ASCII: "+h}if((!d||d&&!d.skipNormalize)&&(e.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=db(unescape(n.host),o))),n.path&&(n.path=lb(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 Ss(e,t){return bs(e,t).parsed}function bb(e,t){return mf(e,t).normalized}function mf(e,t){const{parsed:r,malformedAuthorityOrPort:n}=bs(e,t);return{normalized:n?e:_r(r,t),malformedAuthorityOrPort:n}}function gl(e,t){if(typeof e=="string"){const{normalized:r,malformedAuthorityOrPort:n}=mf(e,t);return n?void 0:r}if(typeof e=="object")return _r(e,t)}const li={SCHEMES:pb,normalize:mb,resolve:gb,resolveComponent:pf,equal:_b,serialize:_r,parse:Ss};Js.exports=li;Js.exports.default=li;Js.exports.fastUri=li;var gf=Js.exports;Object.defineProperty(ai,"__esModule",{value:!0});const _f=gf;_f.code='require("ajv/dist/runtime/uri").default';ai.default=_f;(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=mt;Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=fe;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=zn,s=Zr,o=gr,a=Qe,i=fe,c=Ue,l=Oe,d=K,h=I0,m=ai,_=(N,w)=>new RegExp(N,w);_.code="new RegExp";const v=["removeAdditional","useDefaults","coerceTypes"],y=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),g={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},f={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},$=200;function E(N){var w,C,S,u,p,k,M,z,J,W,he,et,Lt,Vt,Ht,Zt,Kt,Gt,Wt,Bt,Jt,Qt,Yt,Xt,er;const ct=N.strict,tr=(w=N.code)===null||w===void 0?void 0:w.optimize,Qr=tr===!0||tr===void 0?1:tr||0,Yr=(S=(C=N.code)===null||C===void 0?void 0:C.regExp)!==null&&S!==void 0?S:_,so=(u=N.uriResolver)!==null&&u!==void 0?u:m.default;return{strictSchema:(k=(p=N.strictSchema)!==null&&p!==void 0?p:ct)!==null&&k!==void 0?k:!0,strictNumbers:(z=(M=N.strictNumbers)!==null&&M!==void 0?M:ct)!==null&&z!==void 0?z:!0,strictTypes:(W=(J=N.strictTypes)!==null&&J!==void 0?J:ct)!==null&&W!==void 0?W:"log",strictTuples:(et=(he=N.strictTuples)!==null&&he!==void 0?he:ct)!==null&&et!==void 0?et:"log",strictRequired:(Vt=(Lt=N.strictRequired)!==null&&Lt!==void 0?Lt:ct)!==null&&Vt!==void 0?Vt:!1,code:N.code?{...N.code,optimize:Qr,regExp:Yr}:{optimize:Qr,regExp:Yr},loopRequired:(Ht=N.loopRequired)!==null&&Ht!==void 0?Ht:$,loopEnum:(Zt=N.loopEnum)!==null&&Zt!==void 0?Zt:$,meta:(Kt=N.meta)!==null&&Kt!==void 0?Kt:!0,messages:(Gt=N.messages)!==null&&Gt!==void 0?Gt:!0,inlineRefs:(Wt=N.inlineRefs)!==null&&Wt!==void 0?Wt:!0,schemaId:(Bt=N.schemaId)!==null&&Bt!==void 0?Bt:"$id",addUsedSchema:(Jt=N.addUsedSchema)!==null&&Jt!==void 0?Jt:!0,validateSchema:(Qt=N.validateSchema)!==null&&Qt!==void 0?Qt:!0,validateFormats:(Yt=N.validateFormats)!==null&&Yt!==void 0?Yt:!0,unicodeRegExp:(Xt=N.unicodeRegExp)!==null&&Xt!==void 0?Xt:!0,int32range:(er=N.int32range)!==null&&er!==void 0?er:!0,uriResolver:so}}class T{constructor(w={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,w=this.opts={...w,...E(w)};const{es5:C,lines:S}=this.opts.code;this.scope=new i.ValueScope({scope:{},prefixes:y,es5:C,lines:S}),this.logger=Z(w.logger);const u=w.validateFormats;w.validateFormats=!1,this.RULES=(0,o.getRules)(),R.call(this,g,w,"NOT SUPPORTED"),R.call(this,f,w,"DEPRECATED","warn"),this._metaOpts=q.call(this),w.formats&&U.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),w.keywords&&D.call(this,w.keywords),typeof w.meta=="object"&&this.addMetaSchema(w.meta),x.call(this),w.validateFormats=u}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:w,meta:C,schemaId:S}=this.opts;let u=h;S==="id"&&(u={...h},u.id=u.$id,delete u.$id),C&&w&&this.addMetaSchema(u,u[S],!1)}defaultMeta(){const{meta:w,schemaId:C}=this.opts;return this.opts.defaultMeta=typeof w=="object"?w[C]||w:void 0}validate(w,C){let S;if(typeof w=="string"){if(S=this.getSchema(w),!S)throw new Error(`no schema with key or ref "${w}"`)}else S=this.compile(w);const u=S(C);return"$async"in S||(this.errors=S.errors),u}compile(w,C){const S=this._addSchema(w,C);return S.validate||this._compileSchemaEnv(S)}compileAsync(w,C){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:S}=this.opts;return u.call(this,w,C);async function u(W,he){await p.call(this,W.$schema);const et=this._addSchema(W,he);return et.validate||k.call(this,et)}async function p(W){W&&!this.getSchema(W)&&await u.call(this,{$ref:W},!0)}async function k(W){try{return this._compileSchemaEnv(W)}catch(he){if(!(he instanceof s.default))throw he;return M.call(this,he),await z.call(this,he.missingSchema),k.call(this,W)}}function M({missingSchema:W,missingRef:he}){if(this.refs[W])throw new Error(`AnySchema ${W} is loaded but ${he} cannot be resolved`)}async function z(W){const he=await J.call(this,W);this.refs[W]||await p.call(this,he.$schema),this.refs[W]||this.addSchema(he,W,C)}async function J(W){const he=this._loading[W];if(he)return he;try{return await(this._loading[W]=S(W))}finally{delete this._loading[W]}}}addSchema(w,C,S,u=this.opts.validateSchema){if(Array.isArray(w)){for(const k of w)this.addSchema(k,void 0,S,u);return this}let p;if(typeof w=="object"){const{schemaId:k}=this.opts;if(p=w[k],p!==void 0&&typeof p!="string")throw new Error(`schema ${k} must be string`)}return C=(0,c.normalizeId)(C||p),this._checkUnique(C),this.schemas[C]=this._addSchema(w,S,C,u,!0),this}addMetaSchema(w,C,S=this.opts.validateSchema){return this.addSchema(w,C,!0,S),this}validateSchema(w,C){if(typeof w=="boolean")return!0;let S;if(S=w.$schema,S!==void 0&&typeof S!="string")throw new Error("$schema must be a string");if(S=S||this.opts.defaultMeta||this.defaultMeta(),!S)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const u=this.validate(S,w);if(!u&&C){const p="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(p);else throw new Error(p)}return u}getSchema(w){let C;for(;typeof(C=O.call(this,w))=="string";)w=C;if(C===void 0){const{schemaId:S}=this.opts,u=new a.SchemaEnv({schema:{},schemaId:S});if(C=a.resolveSchema.call(this,u,w),!C)return;this.refs[w]=C}return C.validate||this._compileSchemaEnv(C)}removeSchema(w){if(w instanceof RegExp)return this._removeAllSchemas(this.schemas,w),this._removeAllSchemas(this.refs,w),this;switch(typeof w){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const C=O.call(this,w);return typeof C=="object"&&this._cache.delete(C.schema),delete this.schemas[w],delete this.refs[w],this}case"object":{const C=w;this._cache.delete(C);let S=w[this.opts.schemaId];return S&&(S=(0,c.normalizeId)(S),delete this.schemas[S],delete this.refs[S]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(w){for(const C of w)this.addKeyword(C);return this}addKeyword(w,C){let S;if(typeof w=="string")S=w,typeof C=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),C.keyword=S);else if(typeof w=="object"&&C===void 0){if(C=w,S=C.keyword,Array.isArray(S)&&!S.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(F.call(this,S,C),!C)return(0,d.eachItem)(S,p=>le.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)(S,u.type.length===0?p=>le.call(this,p,u):p=>u.type.forEach(k=>le.call(this,p,u,k))),this}getKeyword(w){const C=this.RULES.all[w];return typeof C=="object"?C.definition:!!C}removeKeyword(w){const{RULES:C}=this;delete C.keywords[w],delete C.all[w];for(const S of C.rules){const u=S.rules.findIndex(p=>p.keyword===w);u>=0&&S.rules.splice(u,1)}return this}addFormat(w,C){return typeof C=="string"&&(C=new RegExp(C)),this.formats[w]=C,this}errorsText(w=this.errors,{separator:C=", ",dataVar:S="data"}={}){return!w||w.length===0?"No errors":w.map(u=>`${S}${u.instancePath} ${u.message}`).reduce((u,p)=>u+C+p)}$dataMetaSchema(w,C){const S=this.RULES.all;w=JSON.parse(JSON.stringify(w));for(const u of C){const p=u.split("/").slice(1);let k=w;for(const M of p)k=k[M];for(const M in S){const z=S[M];if(typeof z!="object")continue;const{$data:J}=z.definition,W=k[M];J&&W&&(k[M]=Ie(W))}}return w}_removeAllSchemas(w,C){for(const S in w){const u=w[S];(!C||C.test(S))&&(typeof u=="string"?delete w[S]:u&&!u.meta&&(this._cache.delete(u.schema),delete w[S]))}}_addSchema(w,C,S,u=this.opts.validateSchema,p=this.opts.addUsedSchema){let k;const{schemaId:M}=this.opts;if(typeof w=="object")k=w[M];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 z=this._cache.get(w);if(z!==void 0)return z;S=(0,c.normalizeId)(k||S);const J=c.getSchemaRefs.call(this,w,S);return z=new a.SchemaEnv({schema:w,schemaId:M,meta:C,baseId:S,localRefs:J}),this._cache.set(z.schema,z),p&&!S.startsWith("#")&&(S&&this._checkUnique(S),this.refs[S]=z),u&&this.validateSchema(w,!0),z}_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 R(N,w,C,S="error"){for(const u in N){const p=u;p in w&&this.logger[S](`${C}: option ${u}. ${N[p]}`)}}function O(N){return N=(0,c.normalizeId)(N),this.schemas[N]||this.refs[N]}function x(){const N=this.opts.schemas;if(N)if(Array.isArray(N))this.addSchema(N);else for(const w in N)this.addSchema(N[w],w)}function U(){for(const N in this.opts.formats){const w=this.opts.formats[N];w&&this.addFormat(N,w)}}function D(N){if(Array.isArray(N)){this.addVocabulary(N);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const w in N){const C=N[w];C.keyword||(C.keyword=w),this.addKeyword(C)}}function q(){const N={...this.opts};for(const w of v)delete N[w];return N}const L={log(){},warn(){},error(){}};function Z(N){if(N===!1)return L;if(N===void 0)return console;if(N.log&&N.warn&&N.error)return N;throw new Error("logger must implement log, warn and error methods")}const re=/^[a-z_$][a-z0-9_$:-]*$/i;function F(N,w){const{RULES:C}=this;if((0,d.eachItem)(N,S=>{if(C.keywords[S])throw new Error(`Keyword ${S} is already defined`);if(!re.test(S))throw new Error(`Keyword ${S} has invalid name`)}),!!w&&w.$data&&!("code"in w||"validate"in w))throw new Error('$data keyword must have "code" or "validate" function')}function le(N,w,C){var S;const u=w==null?void 0:w.post;if(C&&u)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:p}=this;let k=u?p.post:p.rules.find(({type:z})=>z===C);if(k||(k={type:C,rules:[]},p.rules.push(k)),p.keywords[N]=!0,!w)return;const M={keyword:N,definition:{...w,type:(0,l.getJSONTypes)(w.type),schemaType:(0,l.getJSONTypes)(w.schemaType)}};w.before?Ce.call(this,k,M,w.before):k.rules.push(M),p.all[N]=M,(S=w.implements)===null||S===void 0||S.forEach(z=>this.addKeyword(z))}function Ce(N,w,C){const S=N.rules.findIndex(u=>u.keyword===C);S>=0?N.rules.splice(S,0,w):(N.rules.push(w),this.logger.warn(`rule ${C} is not defined`))}function _e(N){let{metaSchema:w}=N;w!==void 0&&(N.$data&&this.opts.$data&&(w=Ie(w)),N.validateSchema=this.compile(w,!0))}const it={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Ie(N){return{anyOf:[N,it]}}})(Ed);var ui={},di={},fi={};Object.defineProperty(fi,"__esModule",{value:!0});const Sb={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};fi.default=Sb;var yr={};Object.defineProperty(yr,"__esModule",{value:!0});yr.callRef=yr.getValidate=void 0;const Eb=Zr,_l=ue,Be=fe,Er=bt,yl=Qe,Kn=K,kb={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:r,it:n}=e,{baseId:s,schemaEnv:o,validateName:a,opts:i,self:c}=n,{root:l}=o;if((r==="#"||r==="#/")&&s===l.baseId)return h();const d=yl.resolveRef.call(c,l,s,r);if(d===void 0)throw new Eb.default(n.opts.uriResolver,s,r);if(d instanceof yl.SchemaEnv)return m(d);return _(d);function h(){if(o===l)return is(e,a,o,o.$async);const v=t.scopeValue("root",{ref:l});return is(e,(0,Be._)`${v}.validate`,l,l.$async)}function m(v){const y=yf(e,v);is(e,y,v,v.$async)}function _(v){const y=t.scopeValue("schema",i.code.source===!0?{ref:v,code:(0,Be.stringify)(v)}:{ref:v}),g=t.name("valid"),f=e.subschema({schema:v,dataTypes:[],schemaPath:Be.nil,topSchemaRef:y,errSchemaPath:r},g);e.mergeEvaluated(f),e.ok(g)}}};function yf(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Be._)`${r.scopeValue("wrapper",{ref:t})}.validate`}yr.getValidate=yf;function is(e,t,r,n){const{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:c}=o,l=c.passContext?Er.default.this:Be.nil;n?d():h();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");const v=s.let("valid");s.try(()=>{s.code((0,Be._)`await ${(0,_l.callValidateCode)(e,t,l)}`),_(t),a||s.assign(v,!0)},y=>{s.if((0,Be._)`!(${y} instanceof ${o.ValidationError})`,()=>s.throw(y)),m(y),a||s.assign(v,!1)}),e.ok(v)}function h(){e.result((0,_l.callValidateCode)(e,t,l),()=>_(t),()=>m(t))}function m(v){const y=(0,Be._)`${v}.errors`;s.assign(Er.default.vErrors,(0,Be._)`${Er.default.vErrors} === null ? ${y} : ${Er.default.vErrors}.concat(${y})`),s.assign(Er.default.errors,(0,Be._)`${Er.default.vErrors}.length`)}function _(v){var y;if(!o.opts.unevaluated)return;const g=(y=r==null?void 0:r.validate)===null||y===void 0?void 0:y.evaluated;if(o.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(o.props=Kn.mergeEvaluated.props(s,g.props,o.props));else{const f=s.var("props",(0,Be._)`${v}.evaluated.props`);o.props=Kn.mergeEvaluated.props(s,f,o.props,Be.Name)}if(o.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(o.items=Kn.mergeEvaluated.items(s,g.items,o.items));else{const f=s.var("items",(0,Be._)`${v}.evaluated.items`);o.items=Kn.mergeEvaluated.items(s,f,o.items,Be.Name)}}}yr.callRef=is;yr.default=kb;Object.defineProperty(di,"__esModule",{value:!0});const Pb=fi,Rb=yr,Tb=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Pb.default,Rb.default];di.default=Tb;var hi={},pi={};Object.defineProperty(pi,"__esModule",{value:!0});const Es=fe,Ct=Es.operators,ks={maximum:{okStr:"<=",ok:Ct.LTE,fail:Ct.GT},minimum:{okStr:">=",ok:Ct.GTE,fail:Ct.LT},exclusiveMaximum:{okStr:"<",ok:Ct.LT,fail:Ct.GTE},exclusiveMinimum:{okStr:">",ok:Ct.GT,fail:Ct.LTE}},Cb={message:({keyword:e,schemaCode:t})=>(0,Es.str)`must be ${ks[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Es._)`{comparison: ${ks[e].okStr}, limit: ${t}}`},jb={keyword:Object.keys(ks),type:"number",schemaType:"number",$data:!0,error:Cb,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,Es._)`${r} ${ks[t].fail} ${n} || isNaN(${r})`)}};pi.default=jb;var mi={};Object.defineProperty(mi,"__esModule",{value:!0});const dn=fe,Nb={message:({schemaCode:e})=>(0,dn.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,dn._)`{multipleOf: ${e}}`},Ib={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:Nb,code(e){const{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0,dn._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0,dn._)`${a} !== parseInt(${a})`;e.fail$data((0,dn._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};mi.default=Ib;var gi={},_i={};Object.defineProperty(_i,"__esModule",{value:!0});function vf(e){const t=e.length;let r=0,n=0,s;for(;n=55296&&s<=56319&&n(0,lr._)`{limit: ${e}}`},Mb={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:Ab,code(e){const{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?lr.operators.GT:lr.operators.LT,a=s.opts.unicode===!1?(0,lr._)`${r}.length`:(0,lr._)`${(0,Ob.useFunc)(e.gen,xb.default)}(${r})`;e.fail$data((0,lr._)`${a} ${o} ${n}`)}};gi.default=Mb;var yi={};Object.defineProperty(yi,"__esModule",{value:!0});const zb=ue,Db=K,Ir=fe,qb={message:({schemaCode:e})=>(0,Ir.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Ir._)`{pattern: ${e}}`},Ub={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:qb,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,Ir._)`new RegExp`:(0,Db.useFunc)(t,c),d=t.let("valid");t.try(()=>t.assign(d,(0,Ir._)`${l}(${o}, ${i}).test(${r})`),()=>t.assign(d,!1)),e.fail$data((0,Ir._)`!${d}`)}else{const c=(0,zb.usePattern)(e,s);e.fail$data((0,Ir._)`!${c}.test(${r})`)}}};yi.default=Ub;var vi={};Object.defineProperty(vi,"__esModule",{value:!0});const fn=fe,Fb={message({keyword:e,schemaCode:t}){const r=e==="maxProperties"?"more":"fewer";return(0,fn.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,fn._)`{limit: ${e}}`},Lb={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:Fb,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?fn.operators.GT:fn.operators.LT;e.fail$data((0,fn._)`Object.keys(${r}).length ${s} ${n}`)}};vi.default=Lb;var $i={};Object.defineProperty($i,"__esModule",{value:!0});const tn=ue,hn=fe,Vb=K,Hb={message:({params:{missingProperty:e}})=>(0,hn.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,hn._)`{missingProperty: ${e}}`},Zb={keyword:"required",type:"object",schemaType:"array",$data:!0,error:Hb,code(e){const{gen:t,schema:r,schemaCode:n,data:s,$data:o,it:a}=e,{opts:i}=a;if(!o&&r.length===0)return;const c=r.length>=i.loopRequired;if(a.allErrors?l():d(),i.strictRequired){const _=e.parentSchema.properties,{definedProperties:v}=e.it;for(const y of r)if((_==null?void 0:_[y])===void 0&&!v.has(y)){const g=a.schemaEnv.baseId+a.errSchemaPath,f=`required property "${y}" is not defined at "${g}" (strictRequired)`;(0,Vb.checkStrictMode)(a,f,a.opts.strictRequired)}}function l(){if(c||o)e.block$data(hn.nil,h);else for(const _ of r)(0,tn.checkReportMissingProp)(e,_)}function d(){const _=t.let("missing");if(c||o){const v=t.let("valid",!0);e.block$data(v,()=>m(_,v)),e.ok(v)}else t.if((0,tn.checkMissingProp)(e,r,_)),(0,tn.reportMissingProp)(e,_),t.else()}function h(){t.forOf("prop",n,_=>{e.setParams({missingProperty:_}),t.if((0,tn.noPropertyInData)(t,s,_,i.ownProperties),()=>e.error())})}function m(_,v){e.setParams({missingProperty:_}),t.forOf(_,n,()=>{t.assign(v,(0,tn.propertyInData)(t,s,_,i.ownProperties)),t.if((0,hn.not)(v),()=>{e.error(),t.break()})},hn.nil)}}};$i.default=Zb;var wi={};Object.defineProperty(wi,"__esModule",{value:!0});const pn=fe,Kb={message({keyword:e,schemaCode:t}){const r=e==="maxItems"?"more":"fewer";return(0,pn.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,pn._)`{limit: ${e}}`},Gb={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Kb,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?pn.operators.GT:pn.operators.LT;e.fail$data((0,pn._)`${r}.length ${s} ${n}`)}};wi.default=Gb;var bi={},Dn={};Object.defineProperty(Dn,"__esModule",{value:!0});const $f=Gs;$f.code='require("ajv/dist/runtime/equal").default';Dn.default=$f;Object.defineProperty(bi,"__esModule",{value:!0});const fo=Oe,ze=fe,Wb=K,Bb=Dn,Jb={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}}`},Qb={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:Jb,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,fo.getSchemaTypes)(o.items):[];e.block$data(c,d,(0,ze._)`${a} === false`),e.ok(c);function d(){const v=t.let("i",(0,ze._)`${r}.length`),y=t.let("j");e.setParams({i:v,j:y}),t.assign(c,!0),t.if((0,ze._)`${v} > 1`,()=>(h()?m:_)(v,y))}function h(){return l.length>0&&!l.some(v=>v==="object"||v==="array")}function m(v,y){const g=t.name("item"),f=(0,fo.checkDataTypes)(l,g,i.opts.strictNumbers,fo.DataType.Wrong),$=t.const("indices",(0,ze._)`{}`);t.for((0,ze._)`;${v}--;`,()=>{t.let(g,(0,ze._)`${r}[${v}]`),t.if(f,(0,ze._)`continue`),l.length>1&&t.if((0,ze._)`typeof ${g} == "string"`,(0,ze._)`${g} += "_"`),t.if((0,ze._)`typeof ${$}[${g}] == "number"`,()=>{t.assign(y,(0,ze._)`${$}[${g}]`),e.error(),t.assign(c,!1).break()}).code((0,ze._)`${$}[${g}] = ${v}`)})}function _(v,y){const g=(0,Wb.useFunc)(t,Bb.default),f=t.name("outer");t.label(f).for((0,ze._)`;${v}--;`,()=>t.for((0,ze._)`${y} = ${v}; ${y}--;`,()=>t.if((0,ze._)`${g}(${r}[${v}], ${r}[${y}])`,()=>{e.error(),t.assign(c,!1).break(f)})))}}};bi.default=Qb;var Si={};Object.defineProperty(Si,"__esModule",{value:!0});const qo=fe,Yb=K,Xb=Dn,eS={message:"must be equal to constant",params:({schemaCode:e})=>(0,qo._)`{allowedValue: ${e}}`},tS={keyword:"const",$data:!0,error:eS,code(e){const{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,qo._)`!${(0,Yb.useFunc)(t,Xb.default)}(${r}, ${s})`):e.fail((0,qo._)`${o} !== ${r}`)}};Si.default=tS;var Ei={};Object.defineProperty(Ei,"__esModule",{value:!0});const an=fe,rS=K,nS=Dn,sS={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,an._)`{allowedValues: ${e}}`},oS={keyword:"enum",schemaType:"array",$data:!0,error:sS,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,rS.useFunc)(t,nS.default));let d;if(i||n)d=t.let("valid"),e.block$data(d,h);else{if(!Array.isArray(s))throw new Error("ajv implementation error");const _=t.const("vSchema",o);d=(0,an.or)(...s.map((v,y)=>m(_,y)))}e.pass(d);function h(){t.assign(d,!1),t.forOf("v",o,_=>t.if((0,an._)`${l()}(${r}, ${_})`,()=>t.assign(d,!0).break()))}function m(_,v){const y=s[v];return typeof y=="object"&&y!==null?(0,an._)`${l()}(${r}, ${_}[${v}])`:(0,an._)`${r} === ${y}`}}};Ei.default=oS;Object.defineProperty(hi,"__esModule",{value:!0});const aS=pi,iS=mi,cS=gi,lS=yi,uS=vi,dS=$i,fS=wi,hS=bi,pS=Si,mS=Ei,gS=[aS.default,iS.default,cS.default,lS.default,uS.default,dS.default,fS.default,hS.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},pS.default,mS.default];hi.default=gS;var ki={},Kr={};Object.defineProperty(Kr,"__esModule",{value:!0});Kr.validateAdditionalItems=void 0;const ur=fe,Uo=K,_S={message:({params:{len:e}})=>(0,ur.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,ur._)`{limit: ${e}}`},yS={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:_S,code(e){const{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Uo.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}wf(e,n)}};function wf(e,t){const{gen:r,schema:n,data:s,keyword:o,it:a}=e;a.items=!0;const i=r.const("len",(0,ur._)`${s}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,ur._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0,Uo.alwaysValidSchema)(a,n)){const l=r.var("valid",(0,ur._)`${i} <= ${t.length}`);r.if((0,ur.not)(l),()=>c(l)),e.ok(l)}function c(l){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:Uo.Type.Num},l),a.allErrors||r.if((0,ur.not)(l),()=>r.break())})}}Kr.validateAdditionalItems=wf;Kr.default=yS;var Pi={},Gr={};Object.defineProperty(Gr,"__esModule",{value:!0});Gr.validateTuple=void 0;const vl=fe,cs=K,vS=ue,$S={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return bf(e,"additionalItems",t);r.items=!0,!(0,cs.alwaysValidSchema)(r,t)&&e.ok((0,vS.validateArray)(e))}};function bf(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=cs.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),l=n.const("len",(0,vl._)`${o}.length`);r.forEach((h,m)=>{(0,cs.alwaysValidSchema)(i,h)||(n.if((0,vl._)`${l} > ${m}`,()=>e.subschema({keyword:a,schemaProp:m,dataProp:m},c)),e.ok(c))});function d(h){const{opts:m,errSchemaPath:_}=i,v=r.length,y=v===h.minItems&&(v===h.maxItems||h[t]===!1);if(m.strictTuples&&!y){const g=`"${a}" is ${v}-tuple, but minItems or maxItems/${t} are not specified or different at path "${_}"`;(0,cs.checkStrictMode)(i,g,m.strictTuples)}}}Gr.validateTuple=bf;Gr.default=$S;Object.defineProperty(Pi,"__esModule",{value:!0});const wS=Gr,bS={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,wS.validateTuple)(e,"items")};Pi.default=bS;var Ri={};Object.defineProperty(Ri,"__esModule",{value:!0});const $l=fe,SS=K,ES=ue,kS=Kr,PS={message:({params:{len:e}})=>(0,$l.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,$l._)`{limit: ${e}}`},RS={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:PS,code(e){const{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=!0,!(0,SS.alwaysValidSchema)(n,t)&&(s?(0,kS.validateAdditionalItems)(e,s):e.ok((0,ES.validateArray)(e)))}};Ri.default=RS;var Ti={};Object.defineProperty(Ti,"__esModule",{value:!0});const nt=fe,Gn=K,TS={message:({params:{min:e,max:t}})=>t===void 0?(0,nt.str)`must contain at least ${e} valid item(s)`:(0,nt.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,nt._)`{minContains: ${e}}`:(0,nt._)`{minContains: ${e}, maxContains: ${t}}`},CS={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:TS,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,nt._)`${s}.length`);if(e.setParams({min:a,max:i}),i===void 0&&a===0){(0,Gn.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0,Gn.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Gn.alwaysValidSchema)(o,r)){let y=(0,nt._)`${d} >= ${a}`;i!==void 0&&(y=(0,nt._)`${y} && ${d} <= ${i}`),e.pass(y);return}o.items=!0;const h=t.name("valid");i===void 0&&a===1?_(h,()=>t.if(h,()=>t.break())):a===0?(t.let(h,!0),i!==void 0&&t.if((0,nt._)`${s}.length > 0`,m)):(t.let(h,!1),m()),e.result(h,()=>e.reset());function m(){const y=t.name("_valid"),g=t.let("count",0);_(y,()=>t.if(y,()=>v(g)))}function _(y,g){t.forRange("i",0,d,f=>{e.subschema({keyword:"contains",dataProp:f,dataPropType:Gn.Type.Num,compositeRule:!0},y),g()})}function v(y){t.code((0,nt._)`${y}++`),i===void 0?t.if((0,nt._)`${y} >= ${a}`,()=>t.assign(h,!0).break()):(t.if((0,nt._)`${y} > ${i}`,()=>t.assign(h,!1).break()),a===1?t.assign(h,!0):t.if((0,nt._)`${y} >= ${a}`,()=>t.assign(h,!0)))}}};Ti.default=CS;var Sf={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=fe,r=K,n=ue;e.error={message:({params:{property:c,depsCount:l,deps:d}})=>{const h=l===1?"property":"properties";return(0,t.str)`must have ${h} ${d} when property ${c} is present`},params:({params:{property:c,depsCount:l,deps:d,missingProperty:h}})=>(0,t._)`{property: ${c}, - missingProperty: ${h}, - depsCount: ${l}, - deps: ${d}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(c){const[l,d]=o(c);a(c,l),i(c,d)}};function o({schema:c}){const l={},d={};for(const h in c){if(h==="__proto__")continue;const m=Array.isArray(c[h])?l:d;m[h]=c[h]}return[l,d]}function a(c,l=c.schema){const{gen:d,data:h,it:m}=c;if(Object.keys(l).length===0)return;const _=d.let("missing");for(const v in l){const y=l[v];if(y.length===0)continue;const g=(0,n.propertyInData)(d,h,v,m.opts.ownProperties);c.setParams({property:v,depsCount:y.length,deps:y.join(", ")}),m.allErrors?d.if(g,()=>{for(const f of y)(0,n.checkReportMissingProp)(c,f)}):(d.if((0,t._)`${g} && (${(0,n.checkMissingProp)(c,y,_)})`),(0,n.reportMissingProp)(c,_),d.else())}}e.validatePropertyDeps=a;function i(c,l=c.schema){const{gen:d,data:h,keyword:m,it:_}=c,v=d.name("valid");for(const y in l)(0,r.alwaysValidSchema)(_,l[y])||(d.if((0,n.propertyInData)(d,h,y,_.opts.ownProperties),()=>{const g=c.subschema({keyword:m,schemaProp:y},v);c.mergeValidEvaluated(g,v)},()=>d.var(v,!0)),c.ok(v))}e.validateSchemaDeps=i,e.default=s})(Sf);var Ci={};Object.defineProperty(Ci,"__esModule",{value:!0});const Ef=fe,jS=K,NS={message:"property name must be valid",params:({params:e})=>(0,Ef._)`{propertyName: ${e.propertyName}}`},IS={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:NS,code(e){const{gen:t,schema:r,data:n,it:s}=e;if((0,jS.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,Ef.not)(o),()=>{e.error(!0),s.allErrors||t.break()})}),e.ok(o)}};Ci.default=IS;var Qs={};Object.defineProperty(Qs,"__esModule",{value:!0});const Wn=ue,dt=fe,OS=bt,Bn=K,xS={message:"must NOT have additional properties",params:({params:e})=>(0,dt._)`{additionalProperty: ${e.additionalProperty}}`},AS={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:xS,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,Bn.alwaysValidSchema)(a,r))return;const l=(0,Wn.allSchemaProperties)(n.properties),d=(0,Wn.allSchemaProperties)(n.patternProperties);h(),e.ok((0,dt._)`${o} === ${OS.default.errors}`);function h(){t.forIn("key",s,g=>{!l.length&&!d.length?v(g):t.if(m(g),()=>v(g))})}function m(g){let f;if(l.length>8){const $=(0,Bn.schemaRefOrVal)(a,n.properties,"properties");f=(0,Wn.isOwnProperty)(t,$,g)}else l.length?f=(0,dt.or)(...l.map($=>(0,dt._)`${g} === ${$}`)):f=dt.nil;return d.length&&(f=(0,dt.or)(f,...d.map($=>(0,dt._)`${(0,Wn.usePattern)(e,$)}.test(${g})`))),(0,dt.not)(f)}function _(g){t.code((0,dt._)`delete ${s}[${g}]`)}function v(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){_(g);return}if(r===!1){e.setParams({additionalProperty:g}),e.error(),i||t.break();return}if(typeof r=="object"&&!(0,Bn.alwaysValidSchema)(a,r)){const f=t.name("valid");c.removeAdditional==="failing"?(y(g,f,!1),t.if((0,dt.not)(f),()=>{e.reset(),_(g)})):(y(g,f),i||t.if((0,dt.not)(f),()=>t.break()))}}function y(g,f,$){const E={keyword:"additionalProperties",dataProp:g,dataPropType:Bn.Type.Str};$===!1&&Object.assign(E,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(E,f)}}};Qs.default=AS;var ji={};Object.defineProperty(ji,"__esModule",{value:!0});const MS=mt,wl=ue,ho=K,bl=Qs,zS={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&&bl.default.code(new MS.KeywordCxt(o,bl.default,"additionalProperties"));const a=(0,wl.allSchemaProperties)(r);for(const h of a)o.definedProperties.add(h);o.opts.unevaluated&&a.length&&o.props!==!0&&(o.props=ho.mergeEvaluated.props(t,(0,ho.toHash)(a),o.props));const i=a.filter(h=>!(0,ho.alwaysValidSchema)(o,r[h]));if(i.length===0)return;const c=t.name("valid");for(const h of i)l(h)?d(h):(t.if((0,wl.propertyInData)(t,s,h,o.opts.ownProperties)),d(h),o.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(h),e.ok(c);function l(h){return o.opts.useDefaults&&!o.compositeRule&&r[h].default!==void 0}function d(h){e.subschema({keyword:"properties",schemaProp:h,dataProp:h},c)}}};ji.default=zS;var Ni={};Object.defineProperty(Ni,"__esModule",{value:!0});const Sl=ue,Jn=fe,El=K,kl=K,DS={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,Sl.allSchemaProperties)(r),c=i.filter(y=>(0,El.alwaysValidSchema)(o,r[y]));if(i.length===0||c.length===i.length&&(!o.opts.unevaluated||o.props===!0))return;const l=a.strictSchema&&!a.allowMatchingProperties&&s.properties,d=t.name("valid");o.props!==!0&&!(o.props instanceof Jn.Name)&&(o.props=(0,kl.evaluatedPropsToName)(t,o.props));const{props:h}=o;m();function m(){for(const y of i)l&&_(y),o.allErrors?v(y):(t.var(d,!0),v(y),t.if(d))}function _(y){for(const g in l)new RegExp(y).test(g)&&(0,El.checkStrictMode)(o,`property ${g} matches pattern ${y} (use allowMatchingProperties)`)}function v(y){t.forIn("key",n,g=>{t.if((0,Jn._)`${(0,Sl.usePattern)(e,y)}.test(${g})`,()=>{const f=c.includes(y);f||e.subschema({keyword:"patternProperties",schemaProp:y,dataProp:g,dataPropType:kl.Type.Str},d),o.opts.unevaluated&&h!==!0?t.assign((0,Jn._)`${h}[${g}]`,!0):!f&&!o.allErrors&&t.if((0,Jn.not)(d),()=>t.break())})})}}};Ni.default=DS;var Ii={};Object.defineProperty(Ii,"__esModule",{value:!0});const qS=K,US={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,qS.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"}};Ii.default=US;var Oi={};Object.defineProperty(Oi,"__esModule",{value:!0});const FS=ue,LS={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:FS.validateUnion,error:{message:"must match a schema in anyOf"}};Oi.default=LS;var xi={};Object.defineProperty(xi,"__esModule",{value:!0});const ls=fe,VS=K,HS={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,ls._)`{passingSchemas: ${e.passing}}`},ZS={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:HS,code(e){const{gen:t,schema:r,parentSchema:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;const o=r,a=t.let("valid",!1),i=t.let("passing",null),c=t.name("_valid");e.setParams({passing:i}),t.block(l),e.result(a,()=>e.reset(),()=>e.error(!0));function l(){o.forEach((d,h)=>{let m;(0,VS.alwaysValidSchema)(s,d)?t.var(c,!0):m=e.subschema({keyword:"oneOf",schemaProp:h,compositeRule:!0},c),h>0&&t.if((0,ls._)`${c} && ${a}`).assign(a,!1).assign(i,(0,ls._)`[${i}, ${h}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,h),m&&e.mergeEvaluated(m,ls.Name)})})}}};xi.default=ZS;var Ai={};Object.defineProperty(Ai,"__esModule",{value:!0});const KS=K,GS={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,KS.alwaysValidSchema)(n,o))return;const i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i)})}};Ai.default=GS;var Mi={};Object.defineProperty(Mi,"__esModule",{value:!0});const Ps=fe,kf=K,WS={message:({params:e})=>(0,Ps.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,Ps._)`{failingKeyword: ${e.ifClause}}`},BS={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:WS,code(e){const{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,kf.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const s=Pl(n,"then"),o=Pl(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,Ps.not)(i),l("else"));e.pass(a,()=>e.error(!0));function c(){const d=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},i);e.mergeEvaluated(d)}function l(d,h){return()=>{const m=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(m,a),h?t.assign(h,(0,Ps._)`${d}`):e.setParams({ifClause:d})}}}};function Pl(e,t){const r=e.schema[t];return r!==void 0&&!(0,kf.alwaysValidSchema)(e,r)}Mi.default=BS;var zi={};Object.defineProperty(zi,"__esModule",{value:!0});const JS=K,QS={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,JS.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};zi.default=QS;Object.defineProperty(ki,"__esModule",{value:!0});const YS=Kr,XS=Pi,eE=Gr,tE=Ri,rE=Ti,nE=Sf,sE=Ci,oE=Qs,aE=ji,iE=Ni,cE=Ii,lE=Oi,uE=xi,dE=Ai,fE=Mi,hE=zi;function pE(e=!1){const t=[cE.default,lE.default,uE.default,dE.default,fE.default,hE.default,sE.default,oE.default,nE.default,aE.default,iE.default];return e?t.push(XS.default,tE.default):t.push(YS.default,eE.default),t.push(rE.default),t}ki.default=pE;var Di={},qi={};Object.defineProperty(qi,"__esModule",{value:!0});const je=fe,mE={message:({schemaCode:e})=>(0,je.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,je._)`{format: ${e}}`},gE={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:mE,code(e,t){const{gen:r,data:n,$data:s,schema:o,schemaCode:a,it:i}=e,{opts:c,errSchemaPath:l,schemaEnv:d,self:h}=i;if(!c.validateFormats)return;s?m():_();function m(){const v=r.scopeValue("formats",{ref:h.formats,code:c.code.formats}),y=r.const("fDef",(0,je._)`${v}[${a}]`),g=r.let("fType"),f=r.let("format");r.if((0,je._)`typeof ${y} == "object" && !(${y} instanceof RegExp)`,()=>r.assign(g,(0,je._)`${y}.type || "string"`).assign(f,(0,je._)`${y}.validate`),()=>r.assign(g,(0,je._)`"string"`).assign(f,y)),e.fail$data((0,je.or)($(),E()));function $(){return c.strictSchema===!1?je.nil:(0,je._)`${a} && !${f}`}function E(){const T=d.$async?(0,je._)`(${y}.async ? await ${f}(${n}) : ${f}(${n}))`:(0,je._)`${f}(${n})`,R=(0,je._)`(typeof ${f} == "function" ? ${T} : ${f}.test(${n}))`;return(0,je._)`${f} && ${f} !== true && ${g} === ${t} && !${R}`}}function _(){const v=h.formats[o];if(!v){$();return}if(v===!0)return;const[y,g,f]=E(v);y===t&&e.pass(T());function $(){if(c.strictSchema===!1){h.logger.warn(R());return}throw new Error(R());function R(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function E(R){const O=R instanceof RegExp?(0,je.regexpCode)(R):c.code.formats?(0,je._)`${c.code.formats}${(0,je.getProperty)(o)}`:void 0,x=r.scopeValue("formats",{key:o,ref:R,code:O});return typeof R=="object"&&!(R instanceof RegExp)?[R.type||"string",R.validate,(0,je._)`${x}.validate`]:["string",R,x]}function T(){if(typeof v=="object"&&!(v instanceof RegExp)&&v.async){if(!d.$async)throw new Error("async format in sync schema");return(0,je._)`await ${f}(${n})`}return typeof g=="function"?(0,je._)`${f}(${n})`:(0,je._)`${f}.test(${n})`}}}};qi.default=gE;Object.defineProperty(Di,"__esModule",{value:!0});const _E=qi,yE=[_E.default];Di.default=yE;var Ur={};Object.defineProperty(Ur,"__esModule",{value:!0});Ur.contentVocabulary=Ur.metadataVocabulary=void 0;Ur.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Ur.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(ui,"__esModule",{value:!0});const vE=di,$E=hi,wE=ki,bE=Di,Rl=Ur,SE=[vE.default,$E.default,(0,wE.default)(),bE.default,Rl.metadataVocabulary,Rl.contentVocabulary];ui.default=SE;var Ui={},Ys={};Object.defineProperty(Ys,"__esModule",{value:!0});Ys.DiscrError=void 0;var Tl;(function(e){e.Tag="tag",e.Mapping="mapping"})(Tl||(Ys.DiscrError=Tl={}));Object.defineProperty(Ui,"__esModule",{value:!0});const Cr=fe,Fo=Ys,Cl=Qe,EE=Zr,kE=K,PE={message:({params:{discrError:e,tagName:t}})=>e===Fo.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Cr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},RE={keyword:"discriminator",type:"object",schemaType:"object",error:PE,code(e){const{gen:t,data:r,schema:n,parentSchema:s,it:o}=e,{oneOf:a}=s;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");const i=n.propertyName;if(typeof i!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!a)throw new Error("discriminator: requires oneOf keyword");const c=t.let("valid",!1),l=t.const("tag",(0,Cr._)`${r}${(0,Cr.getProperty)(i)}`);t.if((0,Cr._)`typeof ${l} == "string"`,()=>d(),()=>e.error(!1,{discrError:Fo.DiscrError.Tag,tag:l,tagName:i})),e.ok(c);function d(){const _=m();t.if(!1);for(const v in _)t.elseIf((0,Cr._)`${l} === ${v}`),t.assign(c,h(_[v]));t.else(),e.error(!1,{discrError:Fo.DiscrError.Mapping,tag:l,tagName:i}),t.endIf()}function h(_){const v=t.name("valid"),y=e.subschema({keyword:"oneOf",schemaProp:_},v);return e.mergeEvaluated(y,Cr.Name),v}function m(){var _;const v={},y=f(s);let g=!0;for(let T=0;Tthis.addVocabulary(v)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const v=this.opts.$data?this.$dataMetaSchema(o,a):o;this.addMetaSchema(v,i,!1),this.refs["http://json-schema.org/schema"]=i}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(i)?i:void 0)}}t.Ajv=c,e.exports=t=c,e.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var l=mt;Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var d=fe;Object.defineProperty(t,"_",{enumerable:!0,get:function(){return d._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return d.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return d.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return d.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return d.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return d.CodeGen}});var h=zn;Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return h.default}});var m=Zr;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return m.default}})})(xo,xo.exports);var AE=xo.exports;const ME=au(AE);var Lo={exports:{}},Pf={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(L,Z){return{validate:L,compare:Z}}e.fullFormats={date:t(o,a),time:t(c(!0),l),"date-time":t(m(!0),_),"iso-time":t(c(),d),"iso-date-time":t(m(),v),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:f,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:q,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:E,int32:{type:"number",validate:O},int64:{type:"number",validate:x},float:{type:"number",validate:U},double:{type:"number",validate:U},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,a),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,l),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,_),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,d),"iso-date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,v),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);function r(L){return L%4===0&&(L%100!==0||L%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(L){const Z=n.exec(L);if(!Z)return!1;const re=+Z[1],F=+Z[2],le=+Z[3];return F>=1&&F<=12&&le>=1&&le<=(F===2&&r(re)?29:s[F])}function a(L,Z){if(L&&Z)return L>Z?1:L23||w>59||L&&!it)return!1;if(le<=23&&Ce<=59&&_e<60)return!0;const C=Ce-w*Ie,S=le-N*Ie-(C<0?1:0);return(S===23||S===-1)&&(C===59||C===-1)&&_e<61}}function l(L,Z){if(!(L&&Z))return;const re=new Date("2020-01-01T"+L).valueOf(),F=new Date("2020-01-01T"+Z).valueOf();if(re&&F)return re-F}function d(L,Z){if(!(L&&Z))return;const re=i.exec(L),F=i.exec(Z);if(re&&F)return L=re[1]+re[2]+re[3],Z=F[1]+F[2]+F[3],L>Z?1:L=T}function x(L){return Number.isInteger(L)}function U(){return!0}const D=/[^\\]\\Z/;function q(L){if(D.test(L))return!1;try{return new RegExp(L),!0}catch{return!1}}})(Pf);var Rf={},Vo={exports:{}},Tf={},gt={},Fr={},qn={},ce={},kn={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class t{}e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends t{constructor($){if(super(),!e.IDENTIFIER.test($))throw new Error("CodeGen: name must be a valid identifier");this.str=$}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=r;class n extends t{constructor($){super(),this._items=typeof $=="string"?[$]:$}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const $=this._items[0];return $===""||$==='""'}get str(){var $;return($=this._str)!==null&&$!==void 0?$:this._str=this._items.reduce((E,T)=>`${E}${T}`,"")}get names(){var $;return($=this._names)!==null&&$!==void 0?$:this._names=this._items.reduce((E,T)=>(T instanceof r&&(E[T.str]=(E[T.str]||0)+1),E),{})}}e._Code=n,e.nil=new n("");function s(f,...$){const E=[f[0]];let T=0;for(;T<$.length;)i(E,$[T]),E.push(f[++T]);return new n(E)}e._=s;const o=new n("+");function a(f,...$){const E=[_(f[0])];let T=0;for(;T<$.length;)E.push(o),i(E,$[T]),E.push(o,_(f[++T]));return c(E),new n(E)}e.str=a;function i(f,$){$ instanceof n?f.push(...$._items):$ instanceof r?f.push($):f.push(h($))}e.addCodeArg=i;function c(f){let $=1;for(;${if(h.scopePath===void 0)throw new Error(`CodeGen: name "${h}" has no value`);return(0,t._)`${l}${h.scopePath}`})}scopeCode(l=this._values,d,h){return this._reduceValues(l,m=>{if(m.value===void 0)throw new Error(`CodeGen: name "${m}" has no value`);return m.value.code},d,h)}_reduceValues(l,d,h={},m){let _=t.nil;for(const v in l){const y=l[v];if(!y)continue;const g=h[v]=h[v]||new Map;y.forEach(f=>{if(g.has(f))return;g.set(f,n.Started);let $=d(f);if($){const E=this.opts.es5?e.varKinds.var:e.varKinds.const;_=(0,t._)`${_}${E} ${f} = ${$};${this.opts._n}`}else if($=m==null?void 0:m(f))_=(0,t._)`${_}${$}${this.opts._n}`;else throw new r(f);g.set(f,n.Completed)})}return _}}e.ValueScope=i})(Ho);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=kn,r=Ho;var n=kn;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}});var s=Ho;Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class o{optimizeNodes(){return this}optimizeNames(u,p){return this}}class a extends o{constructor(u,p,k){super(),this.varKind=u,this.name=p,this.rhs=k}render({es5:u,_n:p}){const k=u?r.varKinds.var:this.varKind,M=this.rhs===void 0?"":` = ${this.rhs}`;return`${k} ${this.name}${M};`+p}optimizeNames(u,p){if(u[this.name.str])return this.rhs&&(this.rhs=F(this.rhs,u,p)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class i extends o{constructor(u,p,k){super(),this.lhs=u,this.rhs=p,this.sideEffects=k}render({_n:u}){return`${this.lhs} = ${this.rhs};`+u}optimizeNames(u,p){if(!(this.lhs instanceof t.Name&&!u[this.lhs.str]&&!this.sideEffects))return this.rhs=F(this.rhs,u,p),this}get names(){const u=this.lhs instanceof t.Name?{}:{...this.lhs.names};return re(u,this.rhs)}}class c extends i{constructor(u,p,k,M){super(u,k,M),this.op=p}render({_n:u}){return`${this.lhs} ${this.op}= ${this.rhs};`+u}}class l extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`${this.label}:`+u}}class d extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`break${this.label?` ${this.label}`:""};`+u}}class h extends o{constructor(u){super(),this.error=u}render({_n:u}){return`throw ${this.error};`+u}get names(){return this.error.names}}class m extends o{constructor(u){super(),this.code=u}render({_n:u}){return`${this.code};`+u}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(u,p){return this.code=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,k)=>p+k.render(u),"")}optimizeNodes(){const{nodes:u}=this;let p=u.length;for(;p--;){const k=u[p].optimizeNodes();Array.isArray(k)?u.splice(p,1,...k):k?u[p]=k:u.splice(p,1)}return u.length>0?this:void 0}optimizeNames(u,p){const{nodes:k}=this;let M=k.length;for(;M--;){const z=k[M];z.optimizeNames(u,p)||(le(u,z.names),k.splice(M,1))}return k.length>0?this:void 0}get names(){return this.nodes.reduce((u,p)=>Z(u,p.names),{})}}class v extends _{render(u){return"{"+u._n+super.render(u)+"}"+u._n}}class y extends _{}class g extends v{}g.kind="else";class f extends v{constructor(u,p){super(p),this.condition=u}render(u){let p=`if(${this.condition})`+super.render(u);return this.else&&(p+="else "+this.else.render(u)),p}optimizeNodes(){super.optimizeNodes();const u=this.condition;if(u===!0)return this.nodes;let p=this.else;if(p){const k=p.optimizeNodes();p=this.else=Array.isArray(k)?new g(k):k}if(p)return u===!1?p instanceof f?p:p.nodes:this.nodes.length?this:new f(Ce(u),p instanceof f?[p]:p.nodes);if(!(u===!1||!this.nodes.length))return this}optimizeNames(u,p){var k;if(this.else=(k=this.else)===null||k===void 0?void 0:k.optimizeNames(u,p),!!(super.optimizeNames(u,p)||this.else))return this.condition=F(this.condition,u,p),this}get names(){const u=super.names;return re(u,this.condition),this.else&&Z(u,this.else.names),u}}f.kind="if";class $ extends v{}$.kind="for";class E extends ${constructor(u){super(),this.iteration=u}render(u){return`for(${this.iteration})`+super.render(u)}optimizeNames(u,p){if(super.optimizeNames(u,p))return this.iteration=F(this.iteration,u,p),this}get names(){return Z(super.names,this.iteration.names)}}class T extends ${constructor(u,p,k,M){super(),this.varKind=u,this.name=p,this.from=k,this.to=M}render(u){const p=u.es5?r.varKinds.var:this.varKind,{name:k,from:M,to:z}=this;return`for(${p} ${k}=${M}; ${k}<${z}; ${k}++)`+super.render(u)}get names(){const u=re(super.names,this.from);return re(u,this.to)}}class R extends ${constructor(u,p,k,M){super(),this.loop=u,this.varKind=p,this.name=k,this.iterable=M}render(u){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(u)}optimizeNames(u,p){if(super.optimizeNames(u,p))return this.iterable=F(this.iterable,u,p),this}get names(){return Z(super.names,this.iterable.names)}}class O extends v{constructor(u,p,k){super(),this.name=u,this.args=p,this.async=k}render(u){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(u)}}O.kind="func";class x extends _{render(u){return"return "+super.render(u)}}x.kind="return";class U extends v{render(u){let p="try"+super.render(u);return this.catch&&(p+=this.catch.render(u)),this.finally&&(p+=this.finally.render(u)),p}optimizeNodes(){var u,p;return super.optimizeNodes(),(u=this.catch)===null||u===void 0||u.optimizeNodes(),(p=this.finally)===null||p===void 0||p.optimizeNodes(),this}optimizeNames(u,p){var k,M;return super.optimizeNames(u,p),(k=this.catch)===null||k===void 0||k.optimizeNames(u,p),(M=this.finally)===null||M===void 0||M.optimizeNames(u,p),this}get names(){const u=super.names;return this.catch&&Z(u,this.catch.names),this.finally&&Z(u,this.finally.names),u}}class D extends v{constructor(u){super(),this.error=u}render(u){return`catch(${this.error})`+super.render(u)}}D.kind="catch";class q extends v{render(u){return"finally"+super.render(u)}}q.kind="finally";class L{constructor(u,p={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...p,_n:p.lines?` -`:""},this._extScope=u,this._scope=new r.Scope({parent:u}),this._nodes=[new y]}toString(){return this._root.render(this.opts)}name(u){return this._scope.name(u)}scopeName(u){return this._extScope.name(u)}scopeValue(u,p){const k=this._extScope.value(u,p);return(this._values[k.prefix]||(this._values[k.prefix]=new Set)).add(k),k}getScopeValue(u,p){return this._extScope.getValue(u,p)}scopeRefs(u){return this._extScope.scopeRefs(u,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(u,p,k,M){const z=this._scope.toName(p);return k!==void 0&&M&&(this._constants[z.str]=k),this._leafNode(new a(u,z,k)),z}const(u,p,k){return this._def(r.varKinds.const,u,p,k)}let(u,p,k){return this._def(r.varKinds.let,u,p,k)}var(u,p,k){return this._def(r.varKinds.var,u,p,k)}assign(u,p,k){return this._leafNode(new i(u,p,k))}add(u,p){return this._leafNode(new c(u,e.operators.ADD,p))}code(u){return typeof u=="function"?u():u!==t.nil&&this._leafNode(new m(u)),this}object(...u){const p=["{"];for(const[k,M]of u)p.length>1&&p.push(","),p.push(k),(k!==M||this.opts.es5)&&(p.push(":"),(0,t.addCodeArg)(p,M));return p.push("}"),new t._Code(p)}if(u,p,k){if(this._blockNode(new f(u)),p&&k)this.code(p).else().code(k).endIf();else if(p)this.code(p).endIf();else if(k)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(u){return this._elseNode(new f(u))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(f,g)}_for(u,p){return this._blockNode(u),p&&this.code(p).endFor(),this}for(u,p){return this._for(new E(u),p)}forRange(u,p,k,M,z=this.opts.es5?r.varKinds.var:r.varKinds.let){const J=this._scope.toName(u);return this._for(new T(z,J,p,k),()=>M(J))}forOf(u,p,k,M=r.varKinds.const){const z=this._scope.toName(u);if(this.opts.es5){const J=p instanceof t.Name?p:this.var("_arr",p);return this.forRange("_i",0,(0,t._)`${J}.length`,W=>{this.var(z,(0,t._)`${J}[${W}]`),k(z)})}return this._for(new R("of",M,z,p),()=>k(z))}forIn(u,p,k,M=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(u,(0,t._)`Object.keys(${p})`,k);const z=this._scope.toName(u);return this._for(new R("in",M,z,p),()=>k(z))}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 x;if(this._blockNode(p),this.code(u),p.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(x)}try(u,p,k){if(!p&&!k)throw new Error('CodeGen: "try" without "catch" and "finally"');const M=new U;if(this._blockNode(M),this.code(u),p){const z=this.name("e");this._currNode=M.catch=new D(z),p(z)}return k&&(this._currNode=M.finally=new q,this.code(k)),this._endBlockNode(D,q)}throw(u){return this._leafNode(new h(u))}block(u,p){return this._blockStarts.push(this._nodes.length),u&&this.code(u).endBlock(p),this}endBlock(u){const p=this._blockStarts.pop();if(p===void 0)throw new Error("CodeGen: not in self-balancing block");const k=this._nodes.length-p;if(k<0||u!==void 0&&k!==u)throw new Error(`CodeGen: wrong number of nodes: ${k} vs ${u} expected`);return this._nodes.length=p,this}func(u,p=t.nil,k,M){return this._blockNode(new O(u,p,k)),M&&this.code(M).endFunc(),this}endFunc(){return this._endBlockNode(O)}optimize(u=1){for(;u-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(u){return this._currNode.nodes.push(u),this}_blockNode(u){this._currNode.nodes.push(u),this._nodes.push(u)}_endBlockNode(u,p){const k=this._currNode;if(k instanceof u||p&&k instanceof p)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${p?`${u.kind}/${p.kind}`:u.kind}"`)}_elseNode(u){const p=this._currNode;if(!(p instanceof f))throw new Error('CodeGen: "else" without "if"');return this._currNode=p.else=u,this}get _root(){return this._nodes[0]}get _currNode(){const u=this._nodes;return u[u.length-1]}set _currNode(u){const p=this._nodes;p[p.length-1]=u}}e.CodeGen=L;function Z(S,u){for(const p in u)S[p]=(S[p]||0)+(u[p]||0);return S}function re(S,u){return u instanceof t._CodeOrName?Z(S,u.names):S}function F(S,u,p){if(S instanceof t.Name)return k(S);if(!M(S))return S;return new t._Code(S._items.reduce((z,J)=>(J instanceof t.Name&&(J=k(J)),J instanceof t._Code?z.push(...J._items):z.push(J),z),[]));function k(z){const J=p[z.str];return J===void 0||u[z.str]!==1?z:(delete u[z.str],J)}function M(z){return z instanceof t._Code&&z._items.some(J=>J instanceof t.Name&&u[J.str]===1&&p[J.str]!==void 0)}}function le(S,u){for(const p in u)S[p]=(S[p]||0)-(u[p]||0)}function Ce(S){return typeof S=="boolean"||typeof S=="number"||S===null?!S:(0,t._)`!${C(S)}`}e.not=Ce;const _e=w(e.operators.AND);function it(...S){return S.reduce(_e)}e.and=it;const Ie=w(e.operators.OR);function N(...S){return S.reduce(Ie)}e.or=N;function w(S){return(u,p)=>u===t.nil?p:p===t.nil?u:(0,t._)`${C(u)} ${S} ${C(p)}`}function C(S){return S instanceof t.Name?S:(0,t._)`(${S})`}})(ce);var G={};Object.defineProperty(G,"__esModule",{value:!0});G.checkStrictMode=G.getErrorPath=G.Type=G.useFunc=G.setEvaluated=G.evaluatedPropsToName=G.mergeEvaluated=G.eachItem=G.unescapeJsonPointer=G.escapeJsonPointer=G.escapeFragment=G.unescapeFragment=G.schemaRefOrVal=G.schemaHasRulesButRef=G.schemaHasRules=G.checkUnknownRules=G.alwaysValidSchema=G.toHash=void 0;const ve=ce,zE=kn;function DE(e){const t={};for(const r of e)t[r]=!0;return t}G.toHash=DE;function qE(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(Cf(e,t),!jf(t,e.self.RULES.all))}G.alwaysValidSchema=qE;function Cf(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]||Of(e,`unknown keyword: "${o}"`)}G.checkUnknownRules=Cf;function jf(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(t[r])return!0;return!1}G.schemaHasRules=jf;function UE(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}G.schemaHasRulesButRef=UE;function FE({topSchemaRef:e,schemaPath:t},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,ve._)`${r}`}return(0,ve._)`${e}${t}${(0,ve.getProperty)(n)}`}G.schemaRefOrVal=FE;function LE(e){return Nf(decodeURIComponent(e))}G.unescapeFragment=LE;function VE(e){return encodeURIComponent(Fi(e))}G.escapeFragment=VE;function Fi(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}G.escapeJsonPointer=Fi;function Nf(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}G.unescapeJsonPointer=Nf;function HE(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)}G.eachItem=HE;function jl({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(s,o,a,i)=>{const c=a===void 0?o:a instanceof ve.Name?(o instanceof ve.Name?e(s,o,a):t(s,o,a),a):o instanceof ve.Name?(t(s,a,o),o):r(o,a);return i===ve.Name&&!(c instanceof ve.Name)?n(s,c):c}}G.mergeEvaluated={props:jl({mergeNames:(e,t,r)=>e.if((0,ve._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,ve._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,ve._)`${r} || {}`).code((0,ve._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,ve._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,ve._)`${r} || {}`),Li(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:If}),items:jl({mergeNames:(e,t,r)=>e.if((0,ve._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,ve._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,ve._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,ve._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function If(e,t){if(t===!0)return e.var("props",!0);const r=e.var("props",(0,ve._)`{}`);return t!==void 0&&Li(e,r,t),r}G.evaluatedPropsToName=If;function Li(e,t,r){Object.keys(r).forEach(n=>e.assign((0,ve._)`${t}${(0,ve.getProperty)(n)}`,!0))}G.setEvaluated=Li;const Nl={};function ZE(e,t){return e.scopeValue("func",{ref:t,code:Nl[t.code]||(Nl[t.code]=new zE._Code(t.code))})}G.useFunc=ZE;var Zo;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Zo||(G.Type=Zo={}));function KE(e,t,r){if(e instanceof ve.Name){const n=t===Zo.Num;return r?n?(0,ve._)`"[" + ${e} + "]"`:(0,ve._)`"['" + ${e} + "']"`:n?(0,ve._)`"/" + ${e}`:(0,ve._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,ve.getProperty)(e).toString():"/"+Fi(e)}G.getErrorPath=KE;function Of(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}G.checkStrictMode=Of;var St={};Object.defineProperty(St,"__esModule",{value:!0});const Ke=ce,GE={data:new Ke.Name("data"),valCxt:new Ke.Name("valCxt"),instancePath:new Ke.Name("instancePath"),parentData:new Ke.Name("parentData"),parentDataProperty:new Ke.Name("parentDataProperty"),rootData:new Ke.Name("rootData"),dynamicAnchors:new Ke.Name("dynamicAnchors"),vErrors:new Ke.Name("vErrors"),errors:new Ke.Name("errors"),this:new Ke.Name("this"),self:new Ke.Name("self"),scope:new Ke.Name("scope"),json:new Ke.Name("json"),jsonPos:new Ke.Name("jsonPos"),jsonLen:new Ke.Name("jsonLen"),jsonPart:new Ke.Name("jsonPart")};St.default=GE;(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=ce,r=G,n=St;e.keywordError={message:({keyword:g})=>(0,t.str)`must pass "${g}" keyword validation`},e.keyword$DataError={message:({keyword:g,schemaType:f})=>f?(0,t.str)`"${g}" keyword must be ${f} ($data)`:(0,t.str)`"${g}" keyword is invalid ($data)`};function s(g,f=e.keywordError,$,E){const{it:T}=g,{gen:R,compositeRule:O,allErrors:x}=T,U=h(g,f,$);E??(O||x)?c(R,U):l(T,(0,t._)`[${U}]`)}e.reportError=s;function o(g,f=e.keywordError,$){const{it:E}=g,{gen:T,compositeRule:R,allErrors:O}=E,x=h(g,f,$);c(T,x),R||O||l(E,n.default.vErrors)}e.reportExtraError=o;function a(g,f){g.assign(n.default.errors,f),g.if((0,t._)`${n.default.vErrors} !== null`,()=>g.if(f,()=>g.assign((0,t._)`${n.default.vErrors}.length`,f),()=>g.assign(n.default.vErrors,null)))}e.resetErrorsCount=a;function i({gen:g,keyword:f,schemaValue:$,data:E,errsCount:T,it:R}){if(T===void 0)throw new Error("ajv implementation error");const O=g.name("err");g.forRange("i",T,n.default.errors,x=>{g.const(O,(0,t._)`${n.default.vErrors}[${x}]`),g.if((0,t._)`${O}.instancePath === undefined`,()=>g.assign((0,t._)`${O}.instancePath`,(0,t.strConcat)(n.default.instancePath,R.errorPath))),g.assign((0,t._)`${O}.schemaPath`,(0,t.str)`${R.errSchemaPath}/${f}`),R.opts.verbose&&(g.assign((0,t._)`${O}.schema`,$),g.assign((0,t._)`${O}.data`,E))})}e.extendErrors=i;function c(g,f){const $=g.const("err",f);g.if((0,t._)`${n.default.vErrors} === null`,()=>g.assign(n.default.vErrors,(0,t._)`[${$}]`),(0,t._)`${n.default.vErrors}.push(${$})`),g.code((0,t._)`${n.default.errors}++`)}function l(g,f){const{gen:$,validateName:E,schemaEnv:T}=g;T.$async?$.throw((0,t._)`new ${g.ValidationError}(${f})`):($.assign((0,t._)`${E}.errors`,f),$.return(!1))}const d={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function h(g,f,$){const{createErrors:E}=g.it;return E===!1?(0,t._)`{}`:m(g,f,$)}function m(g,f,$={}){const{gen:E,it:T}=g,R=[_(T,$),v(g,$)];return y(g,f,R),E.object(...R)}function _({errorPath:g},{instancePath:f}){const $=f?(0,t.str)`${g}${(0,r.getErrorPath)(f,r.Type.Str)}`:g;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,$)]}function v({keyword:g,it:{errSchemaPath:f}},{schemaPath:$,parentSchema:E}){let T=E?f:(0,t.str)`${f}/${g}`;return $&&(T=(0,t.str)`${T}${(0,r.getErrorPath)($,r.Type.Str)}`),[d.schemaPath,T]}function y(g,{params:f,message:$},E){const{keyword:T,data:R,schemaValue:O,it:x}=g,{opts:U,propertyName:D,topSchemaRef:q,schemaPath:L}=x;E.push([d.keyword,T],[d.params,typeof f=="function"?f(g):f||(0,t._)`{}`]),U.messages&&E.push([d.message,typeof $=="function"?$(g):$]),U.verbose&&E.push([d.schema,O],[d.parentSchema,(0,t._)`${q}${L}`],[n.default.data,R]),D&&E.push([d.propertyName,D])}})(qn);Object.defineProperty(Fr,"__esModule",{value:!0});Fr.boolOrEmptySchema=Fr.topBoolOrEmptySchema=void 0;const WE=qn,BE=ce,JE=St,QE={message:"boolean schema is false"};function YE(e){const{gen:t,schema:r,validateName:n}=e;r===!1?xf(e,!1):typeof r=="object"&&r.$async===!0?t.return(JE.default.data):(t.assign((0,BE._)`${n}.errors`,null),t.return(!0))}Fr.topBoolOrEmptySchema=YE;function XE(e,t){const{gen:r,schema:n}=e;n===!1?(r.var(t,!1),xf(e)):r.var(t,!0)}Fr.boolOrEmptySchema=XE;function xf(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,WE.reportError)(s,QE,void 0,t)}var xe={},vr={};Object.defineProperty(vr,"__esModule",{value:!0});vr.getRules=vr.isJSONType=void 0;const ek=["string","number","integer","boolean","null","object","array"],tk=new Set(ek);function rk(e){return typeof e=="string"&&tk.has(e)}vr.isJSONType=rk;function nk(){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:{}}}vr.getRules=nk;var Pt={};Object.defineProperty(Pt,"__esModule",{value:!0});Pt.shouldUseRule=Pt.shouldUseGroup=Pt.schemaHasRulesForType=void 0;function sk({schema:e,self:t},r){const n=t.RULES.types[r];return n&&n!==!0&&Af(e,n)}Pt.schemaHasRulesForType=sk;function Af(e,t){return t.rules.some(r=>Mf(e,r))}Pt.shouldUseGroup=Af;function Mf(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))}Pt.shouldUseRule=Mf;Object.defineProperty(xe,"__esModule",{value:!0});xe.reportTypeError=xe.checkDataTypes=xe.checkDataType=xe.coerceAndCheckDataType=xe.getJSONTypes=xe.getSchemaTypes=xe.DataType=void 0;const ok=vr,ak=Pt,ik=qn,ae=ce,zf=G;var Mr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Mr||(xe.DataType=Mr={}));function ck(e){const t=Df(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}xe.getSchemaTypes=ck;function Df(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(ok.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}xe.getJSONTypes=Df;function lk(e,t){const{gen:r,data:n,opts:s}=e,o=uk(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0,ak.schemaHasRulesForType)(e,t[0]));if(a){const i=Vi(t,n,s.strictNumbers,Mr.Wrong);r.if(i,()=>{o.length?dk(e,t,o):Hi(e)})}return a}xe.coerceAndCheckDataType=lk;const qf=new Set(["string","number","integer","boolean","null"]);function uk(e,t){return t?e.filter(r=>qf.has(r)||t==="array"&&r==="array"):[]}function dk(e,t,r){const{gen:n,data:s,opts:o}=e,a=n.let("dataType",(0,ae._)`typeof ${s}`),i=n.let("coerced",(0,ae._)`undefined`);o.coerceTypes==="array"&&n.if((0,ae._)`${a} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,ae._)`${s}[0]`).assign(a,(0,ae._)`typeof ${s}`).if(Vi(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0,ae._)`${i} !== undefined`);for(const l of r)(qf.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),Hi(e),n.endIf(),n.if((0,ae._)`${i} !== undefined`,()=>{n.assign(s,i),fk(e,i)});function c(l){switch(l){case"string":n.elseIf((0,ae._)`${a} == "number" || ${a} == "boolean"`).assign(i,(0,ae._)`"" + ${s}`).elseIf((0,ae._)`${s} === null`).assign(i,(0,ae._)`""`);return;case"number":n.elseIf((0,ae._)`${a} == "boolean" || ${s} === null - || (${a} == "string" && ${s} && ${s} == +${s})`).assign(i,(0,ae._)`+${s}`);return;case"integer":n.elseIf((0,ae._)`${a} === "boolean" || ${s} === null - || (${a} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(i,(0,ae._)`+${s}`);return;case"boolean":n.elseIf((0,ae._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(i,!1).elseIf((0,ae._)`${s} === "true" || ${s} === 1`).assign(i,!0);return;case"null":n.elseIf((0,ae._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(i,null);return;case"array":n.elseIf((0,ae._)`${a} === "string" || ${a} === "number" - || ${a} === "boolean" || ${s} === null`).assign(i,(0,ae._)`[${s}]`)}}}function fk({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,ae._)`${t} !== undefined`,()=>e.assign((0,ae._)`${t}[${r}]`,n))}function Ko(e,t,r,n=Mr.Correct){const s=n===Mr.Correct?ae.operators.EQ:ae.operators.NEQ;let o;switch(e){case"null":return(0,ae._)`${t} ${s} null`;case"array":o=(0,ae._)`Array.isArray(${t})`;break;case"object":o=(0,ae._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=a((0,ae._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=a();break;default:return(0,ae._)`typeof ${t} ${s} ${e}`}return n===Mr.Correct?o:(0,ae.not)(o);function a(i=ae.nil){return(0,ae.and)((0,ae._)`typeof ${t} == "number"`,i,r?(0,ae._)`isFinite(${t})`:ae.nil)}}xe.checkDataType=Ko;function Vi(e,t,r,n){if(e.length===1)return Ko(e[0],t,r,n);let s;const o=(0,zf.toHash)(e);if(o.array&&o.object){const a=(0,ae._)`typeof ${t} != "object"`;s=o.null?a:(0,ae._)`!${t} || ${a}`,delete o.null,delete o.array,delete o.object}else s=ae.nil;o.number&&delete o.integer;for(const a in o)s=(0,ae.and)(s,Ko(a,t,r,n));return s}xe.checkDataTypes=Vi;const hk={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,ae._)`{type: ${e}}`:(0,ae._)`{type: ${t}}`};function Hi(e){const t=pk(e);(0,ik.reportError)(t,hk)}xe.reportTypeError=Hi;function pk(e){const{gen:t,data:r,schema:n}=e,s=(0,zf.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}var Xs={};Object.defineProperty(Xs,"__esModule",{value:!0});Xs.assignDefaults=void 0;const kr=ce,mk=G;function gk(e,t){const{properties:r,items:n}=e.schema;if(t==="object"&&r)for(const s in r)Il(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>Il(e,o,s.default))}Xs.assignDefaults=gk;function Il(e,t,r){const{gen:n,compositeRule:s,data:o,opts:a}=e;if(r===void 0)return;const i=(0,kr._)`${o}${(0,kr.getProperty)(t)}`;if(s){(0,mk.checkStrictMode)(e,`default is ignored for: ${i}`);return}let c=(0,kr._)`${i} === undefined`;a.useDefaults==="empty"&&(c=(0,kr._)`${c} || ${i} === null || ${i} === ""`),n.if(c,(0,kr._)`${i} = ${(0,kr.stringify)(r)}`)}var wt={},de={};Object.defineProperty(de,"__esModule",{value:!0});de.validateUnion=de.validateArray=de.usePattern=de.callValidateCode=de.schemaProperties=de.allSchemaProperties=de.noPropertyInData=de.propertyInData=de.isOwnProperty=de.hasPropFunc=de.reportMissingProp=de.checkMissingProp=de.checkReportMissingProp=void 0;const Se=ce,Zi=G,jt=St,_k=G;function yk(e,t){const{gen:r,data:n,it:s}=e;r.if(Gi(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Se._)`${t}`},!0),e.error()})}de.checkReportMissingProp=yk;function vk({gen:e,data:t,it:{opts:r}},n,s){return(0,Se.or)(...n.map(o=>(0,Se.and)(Gi(e,t,o,r.ownProperties),(0,Se._)`${s} = ${o}`)))}de.checkMissingProp=vk;function $k(e,t){e.setParams({missingProperty:t},!0),e.error()}de.reportMissingProp=$k;function Uf(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Se._)`Object.prototype.hasOwnProperty`})}de.hasPropFunc=Uf;function Ki(e,t,r){return(0,Se._)`${Uf(e)}.call(${t}, ${r})`}de.isOwnProperty=Ki;function wk(e,t,r,n){const s=(0,Se._)`${t}${(0,Se.getProperty)(r)} !== undefined`;return n?(0,Se._)`${s} && ${Ki(e,t,r)}`:s}de.propertyInData=wk;function Gi(e,t,r,n){const s=(0,Se._)`${t}${(0,Se.getProperty)(r)} === undefined`;return n?(0,Se.or)(s,(0,Se.not)(Ki(e,t,r))):s}de.noPropertyInData=Gi;function Ff(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}de.allSchemaProperties=Ff;function bk(e,t){return Ff(t).filter(r=>!(0,Zi.alwaysValidSchema)(e,t[r]))}de.schemaProperties=bk;function Sk({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:a},i,c,l){const d=l?(0,Se._)`${e}, ${t}, ${n}${s}`:t,h=[[jt.default.instancePath,(0,Se.strConcat)(jt.default.instancePath,o)],[jt.default.parentData,a.parentData],[jt.default.parentDataProperty,a.parentDataProperty],[jt.default.rootData,jt.default.rootData]];a.opts.dynamicRef&&h.push([jt.default.dynamicAnchors,jt.default.dynamicAnchors]);const m=(0,Se._)`${d}, ${r.object(...h)}`;return c!==Se.nil?(0,Se._)`${i}.call(${c}, ${m})`:(0,Se._)`${i}(${m})`}de.callValidateCode=Sk;const Ek=(0,Se._)`new RegExp`;function kk({gen:e,it:{opts:t}},r){const n=t.unicodeRegExp?"u":"",{regExp:s}=t.code,o=s(r,n);return e.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,Se._)`${s.code==="new RegExp"?Ek:(0,_k.useFunc)(e,s)}(${r}, ${n})`})}de.usePattern=kk;function Pk(e){const{gen:t,data:r,keyword:n,it:s}=e,o=t.name("valid");if(s.allErrors){const i=t.let("valid",!0);return a(()=>t.assign(i,!1)),i}return t.var(o,!0),a(()=>t.break()),o;function a(i){const c=t.const("len",(0,Se._)`${r}.length`);t.forRange("i",0,c,l=>{e.subschema({keyword:n,dataProp:l,dataPropType:Zi.Type.Num},o),t.if((0,Se.not)(o),i)})}}de.validateArray=Pk;function Rk(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,Zi.alwaysValidSchema)(s,c))&&!s.opts.unevaluated)return;const a=t.let("valid",!1),i=t.name("_valid");t.block(()=>r.forEach((c,l)=>{const d=e.subschema({keyword:n,schemaProp:l,compositeRule:!0},i);t.assign(a,(0,Se._)`${a} || ${i}`),e.mergeValidEvaluated(d,i)||t.if((0,Se.not)(a))})),e.result(a,()=>e.reset(),()=>e.error(!0))}de.validateUnion=Rk;Object.defineProperty(wt,"__esModule",{value:!0});wt.validateKeywordUsage=wt.validSchemaType=wt.funcKeywordCode=wt.macroKeywordCode=void 0;const We=ce,dr=St,Tk=de,Ck=qn;function jk(e,t){const{gen:r,keyword:n,schema:s,parentSchema:o,it:a}=e,i=t.macro.call(a.self,s,o,a),c=Lf(r,n,i);a.opts.validateSchema!==!1&&a.self.validateSchema(i,!0);const l=r.name("valid");e.subschema({schema:i,schemaPath:We.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},l),e.pass(l,()=>e.error(!0))}wt.macroKeywordCode=jk;function Nk(e,t){var r;const{gen:n,keyword:s,schema:o,parentSchema:a,$data:i,it:c}=e;Ok(c,t);const l=!i&&t.compile?t.compile.call(c.self,o,a,c):t.validate,d=Lf(n,s,l),h=n.let("valid");e.block$data(h,m),e.ok((r=t.valid)!==null&&r!==void 0?r:h);function m(){if(t.errors===!1)y(),t.modifying&&Ol(e),g(()=>e.error());else{const f=t.async?_():v();t.modifying&&Ol(e),g(()=>Ik(e,f))}}function _(){const f=n.let("ruleErrs",null);return n.try(()=>y((0,We._)`await `),$=>n.assign(h,!1).if((0,We._)`${$} instanceof ${c.ValidationError}`,()=>n.assign(f,(0,We._)`${$}.errors`),()=>n.throw($))),f}function v(){const f=(0,We._)`${d}.errors`;return n.assign(f,null),y(We.nil),f}function y(f=t.async?(0,We._)`await `:We.nil){const $=c.opts.passContext?dr.default.this:dr.default.self,E=!("compile"in t&&!i||t.schema===!1);n.assign(h,(0,We._)`${f}${(0,Tk.callValidateCode)(e,d,$,E)}`,t.modifying)}function g(f){var $;n.if((0,We.not)(($=t.valid)!==null&&$!==void 0?$:h),f)}}wt.funcKeywordCode=Nk;function Ol(e){const{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,We._)`${n.parentData}[${n.parentDataProperty}]`))}function Ik(e,t){const{gen:r}=e;r.if((0,We._)`Array.isArray(${t})`,()=>{r.assign(dr.default.vErrors,(0,We._)`${dr.default.vErrors} === null ? ${t} : ${dr.default.vErrors}.concat(${t})`).assign(dr.default.errors,(0,We._)`${dr.default.vErrors}.length`),(0,Ck.extendErrors)(e)},()=>e.error())}function Ok({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function Lf(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,We.stringify)(r)})}function xk(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}wt.validSchemaType=xk;function Ak({schema:e,opts:t,self:r,errSchemaPath:n},s,o){if(Array.isArray(s.keyword)?!s.keyword.includes(o):s.keyword!==o)throw new Error("ajv implementation error");const a=s.dependencies;if(a!=null&&a.some(i=>!Object.prototype.hasOwnProperty.call(e,i)))throw new Error(`parent schema must have dependencies of ${o}: ${a.join(",")}`);if(s.validateSchema&&!s.validateSchema(e[o])){const c=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(s.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}wt.validateKeywordUsage=Ak;var qt={};Object.defineProperty(qt,"__esModule",{value:!0});qt.extendSubschemaMode=qt.extendSubschemaData=qt.getSubschema=void 0;const vt=ce,Vf=G;function Mk(e,{keyword:t,schemaProp:r,schema:n,schemaPath:s,errSchemaPath:o,topSchemaRef:a}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){const i=e.schema[t];return r===void 0?{schema:i,schemaPath:(0,vt._)`${e.schemaPath}${(0,vt.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:i[r],schemaPath:(0,vt._)`${e.schemaPath}${(0,vt.getProperty)(t)}${(0,vt.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,Vf.escapeFragment)(r)}`}}if(n!==void 0){if(s===void 0||o===void 0||a===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:s,topSchemaRef:a,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}qt.getSubschema=Mk;function zk(e,t,{dataProp:r,dataPropType:n,data:s,dataTypes:o,propertyName:a}){if(s!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:i}=t;if(r!==void 0){const{errorPath:l,dataPathArr:d,opts:h}=t,m=i.let("data",(0,vt._)`${t.data}${(0,vt.getProperty)(r)}`,!0);c(m),e.errorPath=(0,vt.str)`${l}${(0,Vf.getErrorPath)(r,n,h.jsPropertySyntax)}`,e.parentDataProperty=(0,vt._)`${r}`,e.dataPathArr=[...d,e.parentDataProperty]}if(s!==void 0){const l=s instanceof vt.Name?s:i.let("data",s,!0);c(l),a!==void 0&&(e.propertyName=a)}o&&(e.dataTypes=o);function c(l){e.data=l,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,l]}}qt.extendSubschemaData=zk;function Dk(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:s,allErrors:o}){n!==void 0&&(e.compositeRule=n),s!==void 0&&(e.createErrors=s),o!==void 0&&(e.allErrors=o),e.jtdDiscriminator=t,e.jtdMetadata=r}qt.extendSubschemaMode=Dk;var Fe={},Hf={exports:{}},Mt=Hf.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(){};us(t,n,s,e,"",e)};Mt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Mt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Mt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Mt.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function us(e,t,r,n,s,o,a,i,c,l){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,s,o,a,i,c,l);for(var d in n){var h=n[d];if(Array.isArray(h)){if(d in Mt.arrayKeywords)for(var m=0;mt+=Zf(n)),t===1/0))return 1/0}return t}function Kf(e,t="",r){r!==!1&&(t=zr(t));const n=e.parse(t);return Gf(e,n)}Fe.getFullPath=Kf;function Gf(e,t){return e.serialize(t).split("#")[0]+"#"}Fe._getFullPath=Gf;const Gk=/#\/?$/;function zr(e){return e?e.replace(Gk,""):""}Fe.normalizeId=zr;function Wk(e,t,r){return r=zr(r),e.resolve(t,r)}Fe.resolveUrl=Wk;const Bk=/^[a-z_][-a-z0-9._]*$/i;function Jk(e,t){if(typeof e=="boolean")return{};const{schemaId:r,uriResolver:n}=this.opts,s=zr(e[r]||t),o={"":s},a=Kf(n,s,!1),i={},c=new Set;return Vk(e,{allKeys:!0},(h,m,_,v)=>{if(v===void 0)return;const y=a+m;let g=o[v];typeof h[r]=="string"&&(g=f.call(this,h[r])),$.call(this,h.$anchor),$.call(this,h.$dynamicAnchor),o[m]=g;function f(E){const T=this.opts.uriResolver.resolve;if(E=zr(g?T(g,E):E),c.has(E))throw d(E);c.add(E);let R=this.refs[E];return typeof R=="string"&&(R=this.refs[R]),typeof R=="object"?l(h,R.schema,E):E!==zr(y)&&(E[0]==="#"?(l(h,i[E],E),i[E]=h):this.refs[E]=y),E}function $(E){if(typeof E=="string"){if(!Bk.test(E))throw new Error(`invalid anchor "${E}"`);f.call(this,`#${E}`)}}}),i;function l(h,m,_){if(m!==void 0&&!Lk(h,m))throw d(_)}function d(h){return new Error(`reference "${h}" resolves to more than one schema`)}}Fe.getSchemaRefs=Jk;Object.defineProperty(gt,"__esModule",{value:!0});gt.getData=gt.KeywordCxt=gt.validateFunctionCode=void 0;const Wf=Fr,xl=xe,Wi=Pt,Rs=xe,Qk=Xs,mn=wt,po=qt,Y=ce,te=St,Yk=Fe,Rt=G,rn=qn;function Xk(e){if(Qf(e)&&(Yf(e),Jf(e))){rP(e);return}Bf(e,()=>(0,Wf.topBoolOrEmptySchema)(e))}gt.validateFunctionCode=Xk;function Bf({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},o){s.code.es5?e.func(t,(0,Y._)`${te.default.data}, ${te.default.valCxt}`,n.$async,()=>{e.code((0,Y._)`"use strict"; ${Al(r,s)}`),tP(e,s),e.code(o)}):e.func(t,(0,Y._)`${te.default.data}, ${eP(s)}`,n.$async,()=>e.code(Al(r,s)).code(o))}function eP(e){return(0,Y._)`{${te.default.instancePath}="", ${te.default.parentData}, ${te.default.parentDataProperty}, ${te.default.rootData}=${te.default.data}${e.dynamicRef?(0,Y._)`, ${te.default.dynamicAnchors}={}`:Y.nil}}={}`}function tP(e,t){e.if(te.default.valCxt,()=>{e.var(te.default.instancePath,(0,Y._)`${te.default.valCxt}.${te.default.instancePath}`),e.var(te.default.parentData,(0,Y._)`${te.default.valCxt}.${te.default.parentData}`),e.var(te.default.parentDataProperty,(0,Y._)`${te.default.valCxt}.${te.default.parentDataProperty}`),e.var(te.default.rootData,(0,Y._)`${te.default.valCxt}.${te.default.rootData}`),t.dynamicRef&&e.var(te.default.dynamicAnchors,(0,Y._)`${te.default.valCxt}.${te.default.dynamicAnchors}`)},()=>{e.var(te.default.instancePath,(0,Y._)`""`),e.var(te.default.parentData,(0,Y._)`undefined`),e.var(te.default.parentDataProperty,(0,Y._)`undefined`),e.var(te.default.rootData,te.default.data),t.dynamicRef&&e.var(te.default.dynamicAnchors,(0,Y._)`{}`)})}function rP(e){const{schema:t,opts:r,gen:n}=e;Bf(e,()=>{r.$comment&&t.$comment&&eh(e),iP(e),n.let(te.default.vErrors,null),n.let(te.default.errors,0),r.unevaluated&&nP(e),Xf(e),uP(e)})}function nP(e){const{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,Y._)`${r}.evaluated`),t.if((0,Y._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,Y._)`${e.evaluated}.props`,(0,Y._)`undefined`)),t.if((0,Y._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,Y._)`${e.evaluated}.items`,(0,Y._)`undefined`))}function Al(e,t){const r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,Y._)`/*# sourceURL=${r} */`:Y.nil}function sP(e,t){if(Qf(e)&&(Yf(e),Jf(e))){oP(e,t);return}(0,Wf.boolOrEmptySchema)(e,t)}function Jf({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 Qf(e){return typeof e.schema!="boolean"}function oP(e,t){const{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&eh(e),cP(e),lP(e);const o=n.const("_errs",te.default.errors);Xf(e,o),n.var(t,(0,Y._)`${o} === ${te.default.errors}`)}function Yf(e){(0,Rt.checkUnknownRules)(e),aP(e)}function Xf(e,t){if(e.opts.jtd)return Ml(e,[],!1,t);const r=(0,xl.getSchemaTypes)(e.schema),n=(0,xl.coerceAndCheckDataType)(e,r);Ml(e,r,!n,t)}function aP(e){const{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,Rt.schemaHasRulesButRef)(t,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function iP(e){const{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Rt.checkStrictMode)(e,"default is ignored in the schema root")}function cP(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,Yk.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function lP(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function eh({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:s}){const o=r.$comment;if(s.$comment===!0)e.code((0,Y._)`${te.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){const a=(0,Y.str)`${n}/$comment`,i=e.scopeValue("root",{ref:t.root});e.code((0,Y._)`${te.default.self}.opts.$comment(${o}, ${a}, ${i}.schema)`)}}function uP(e){const{gen:t,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=e;r.$async?t.if((0,Y._)`${te.default.errors} === 0`,()=>t.return(te.default.data),()=>t.throw((0,Y._)`new ${s}(${te.default.vErrors})`)):(t.assign((0,Y._)`${n}.errors`,te.default.vErrors),o.unevaluated&&dP(e),t.return((0,Y._)`${te.default.errors} === 0`))}function dP({gen:e,evaluated:t,props:r,items:n}){r instanceof Y.Name&&e.assign((0,Y._)`${t}.props`,r),n instanceof Y.Name&&e.assign((0,Y._)`${t}.items`,n)}function Ml(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,Rt.schemaHasRulesButRef)(o,d))){s.block(()=>nh(e,"$ref",d.all.$ref.definition));return}c.jtd||fP(e,t),s.block(()=>{for(const m of d.rules)h(m);h(d.post)});function h(m){(0,Wi.shouldUseGroup)(o,m)&&(m.type?(s.if((0,Rs.checkDataType)(m.type,a,c.strictNumbers)),zl(e,m),t.length===1&&t[0]===m.type&&r&&(s.else(),(0,Rs.reportTypeError)(e)),s.endIf()):zl(e,m),i||s.if((0,Y._)`${te.default.errors} === ${n||0}`))}}function zl(e,t){const{gen:r,schema:n,opts:{useDefaults:s}}=e;s&&(0,Qk.assignDefaults)(e,t.type),r.block(()=>{for(const o of t.rules)(0,Wi.shouldUseRule)(n,o)&&nh(e,o.keyword,o.definition,t.type)})}function fP(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(hP(e,t),e.opts.allowUnionTypes||pP(e,t),mP(e,e.dataTypes))}function hP(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{th(e.dataTypes,r)||Bi(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),_P(e,t)}}function pP(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Bi(e,"use allowUnionTypes to allow union type keyword")}function mP(e,t){const r=e.self.RULES.all;for(const n in r){const s=r[n];if(typeof s=="object"&&(0,Wi.shouldUseRule)(e.schema,s)){const{type:o}=s.definition;o.length&&!o.some(a=>gP(t,a))&&Bi(e,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function gP(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function th(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function _P(e,t){const r=[];for(const n of e.dataTypes)th(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function Bi(e,t){const r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,Rt.checkStrictMode)(e,t,e.opts.strictTypes)}class rh{constructor(t,r,n){if((0,mn.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,Rt.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",sh(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,mn.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",te.default.errors))}result(t,r,n){this.failResult((0,Y.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,Y.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);const{schemaCode:r}=this;this.fail((0,Y._)`${r} !== undefined && (${(0,Y.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?rn.reportExtraError:rn.reportError)(this,this.def.error,r)}$dataError(){(0,rn.reportError)(this,this.def.$dataError||rn.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,rn.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=Y.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=Y.nil,r=Y.nil){if(!this.$data)return;const{gen:n,schemaCode:s,schemaType:o,def:a}=this;n.if((0,Y.or)((0,Y._)`${s} === undefined`,r)),t!==Y.nil&&n.assign(t,!0),(o.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==Y.nil&&n.assign(t,!1)),n.else()}invalid$data(){const{gen:t,schemaCode:r,schemaType:n,def:s,it:o}=this;return(0,Y.or)(a(),i());function a(){if(n.length){if(!(r instanceof Y.Name))throw new Error("ajv implementation error");const c=Array.isArray(n)?n:[n];return(0,Y._)`${(0,Rs.checkDataTypes)(c,r,o.opts.strictNumbers,Rs.DataType.Wrong)}`}return Y.nil}function i(){if(s.validateSchema){const c=t.scopeValue("validate$data",{ref:s.validateSchema});return(0,Y._)`!${c}(${r})`}return Y.nil}}subschema(t,r){const n=(0,po.getSubschema)(this.it,t);(0,po.extendSubschemaData)(n,this.it,t),(0,po.extendSubschemaMode)(n,t);const s={...this.it,...n,items:void 0,props:void 0};return sP(s,r),s}mergeEvaluated(t,r){const{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=Rt.mergeEvaluated.props(s,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=Rt.mergeEvaluated.items(s,t.items,n.items,r)))}mergeValidEvaluated(t,r){const{it:n,gen:s}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return s.if(r,()=>this.mergeEvaluated(t,Y.Name)),!0}}gt.KeywordCxt=rh;function nh(e,t,r,n){const s=new rh(e,r,t);"code"in r?r.code(s,n):s.$data&&r.validate?(0,mn.funcKeywordCode)(s,r):"macro"in r?(0,mn.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,mn.funcKeywordCode)(s,r)}const yP=/^\/(?:[^~]|~0|~1)*$/,vP=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function sh(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,o;if(e==="")return te.default.rootData;if(e[0]==="/"){if(!yP.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,o=te.default.rootData}else{const l=vP.exec(e);if(!l)throw new Error(`Invalid JSON-pointer: ${e}`);const d=+l[1];if(s=l[2],s==="#"){if(d>=t)throw new Error(c("property/index",d));return n[t-d]}if(d>t)throw new Error(c("data",d));if(o=r[t-d],!s)return o}let a=o;const i=s.split("/");for(const l of i)l&&(o=(0,Y._)`${o}${(0,Y.getProperty)((0,Rt.unescapeJsonPointer)(l))}`,a=(0,Y._)`${a} && ${o}`);return a;function c(l,d){return`Cannot access ${l} ${d} levels up, current level is ${t}`}}gt.getData=sh;var Un={};Object.defineProperty(Un,"__esModule",{value:!0});class $P extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}}Un.default=$P;var Wr={};Object.defineProperty(Wr,"__esModule",{value:!0});const mo=Fe;class wP extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,mo.resolveUrl)(t,r,n),this.missingSchema=(0,mo.normalizeId)((0,mo.getFullPath)(t,this.missingRef))}}Wr.default=wP;var Ye={};Object.defineProperty(Ye,"__esModule",{value:!0});Ye.resolveSchema=Ye.getCompilingSchema=Ye.resolveRef=Ye.compileSchema=Ye.SchemaEnv=void 0;const ut=ce,bP=Un,sr=St,pt=Fe,Dl=G,SP=gt;class eo{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,pt.normalizeId)(n==null?void 0:n[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n==null?void 0:n.$async,this.refs={}}}Ye.SchemaEnv=eo;function Ji(e){const t=oh.call(this,e);if(t)return t;const r=(0,pt.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,a=new ut.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o});let i;e.$async&&(i=a.scopeValue("Error",{ref:bP.default,code:(0,ut._)`require("ajv/dist/runtime/validation_error").default`}));const c=a.scopeName("validate");e.validateName=c;const l={gen:a,allErrors:this.opts.allErrors,data:sr.default.data,parentData:sr.default.parentData,parentDataProperty:sr.default.parentDataProperty,dataNames:[sr.default.data],dataPathArr:[ut.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,ut.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:ut.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,ut._)`""`,opts:this.opts,self:this};let d;try{this._compilations.add(e),(0,SP.validateFunctionCode)(l),a.optimize(this.opts.code.optimize);const h=a.toString();d=`${a.scopeRefs(sr.default.scope)}return ${h}`,this.opts.code.process&&(d=this.opts.code.process(d,e));const _=new Function(`${sr.default.self}`,`${sr.default.scope}`,d)(this,this.scope.get());if(this.scope.value(c,{ref:_}),_.errors=null,_.schema=e.schema,_.schemaEnv=e,e.$async&&(_.$async=!0),this.opts.code.source===!0&&(_.source={validateName:c,validateCode:h,scopeValues:a._values}),this.opts.unevaluated){const{props:v,items:y}=l;_.evaluated={props:v instanceof ut.Name?void 0:v,items:y instanceof ut.Name?void 0:y,dynamicProps:v instanceof ut.Name,dynamicItems:y instanceof ut.Name},_.source&&(_.source.evaluated=(0,ut.stringify)(_.evaluated))}return e.validate=_,e}catch(h){throw delete e.validate,delete e.validateName,d&&this.logger.error("Error compiling schema, function code:",d),h}finally{this._compilations.delete(e)}}Ye.compileSchema=Ji;function EP(e,t,r){var n;r=(0,pt.resolveUrl)(this.opts.uriResolver,t,r);const s=e.refs[r];if(s)return s;let o=RP.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 eo({schema:a,schemaId:i,root:e,baseId:t}))}if(o!==void 0)return e.refs[r]=kP.call(this,o)}Ye.resolveRef=EP;function kP(e){return(0,pt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Ji.call(this,e)}function oh(e){for(const t of this._compilations)if(PP(t,e))return t}Ye.getCompilingSchema=oh;function PP(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function RP(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||to.call(this,e,t)}function to(e,t){const r=this.opts.uriResolver.parse(t),n=(0,pt._getFullPath)(this.opts.uriResolver,r);let s=(0,pt.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===s)return go.call(this,r,e);const o=(0,pt.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){const i=to.call(this,e,a);return typeof(i==null?void 0:i.schema)!="object"?void 0:go.call(this,r,i)}if(typeof(a==null?void 0:a.schema)=="object"){if(a.validate||Ji.call(this,a),o===(0,pt.normalizeId)(t)){const{schema:i}=a,{schemaId:c}=this.opts,l=i[c];return l&&(s=(0,pt.resolveUrl)(this.opts.uriResolver,s,l)),new eo({schema:i,schemaId:c,root:e,baseId:s})}return go.call(this,r,a)}}Ye.resolveSchema=to;const TP=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function go(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,Dl.unescapeFragment)(i)];if(c===void 0)return;r=c;const l=typeof r=="object"&&r[this.opts.schemaId];!TP.has(i)&&l&&(t=(0,pt.resolveUrl)(this.opts.uriResolver,t,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,Dl.schemaHasRulesButRef)(r,this.RULES)){const i=(0,pt.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=to.call(this,n,i)}const{schemaId:a}=this.opts;if(o=o||new eo({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}const CP="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",jP="Meta-schema for $data reference (JSON AnySchema extension proposal)",NP="object",IP=["$data"],OP={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},xP=!1,AP={$id:CP,description:jP,type:NP,required:IP,properties:OP,additionalProperties:xP};var Qi={};Object.defineProperty(Qi,"__esModule",{value:!0});const ah=gf;ah.code='require("ajv/dist/runtime/uri").default';Qi.default=ah;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=gt;Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=ce;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=Un,s=Wr,o=vr,a=Ye,i=ce,c=Fe,l=xe,d=G,h=AP,m=Qi,_=(N,w)=>new RegExp(N,w);_.code="new RegExp";const v=["removeAdditional","useDefaults","coerceTypes"],y=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),g={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},f={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},$=200;function E(N){var w,C,S,u,p,k,M,z,J,W,he,et,Lt,Vt,Ht,Zt,Kt,Gt,Wt,Bt,Jt,Qt,Yt,Xt,er;const ct=N.strict,tr=(w=N.code)===null||w===void 0?void 0:w.optimize,Qr=tr===!0||tr===void 0?1:tr||0,Yr=(S=(C=N.code)===null||C===void 0?void 0:C.regExp)!==null&&S!==void 0?S:_,so=(u=N.uriResolver)!==null&&u!==void 0?u:m.default;return{strictSchema:(k=(p=N.strictSchema)!==null&&p!==void 0?p:ct)!==null&&k!==void 0?k:!0,strictNumbers:(z=(M=N.strictNumbers)!==null&&M!==void 0?M:ct)!==null&&z!==void 0?z:!0,strictTypes:(W=(J=N.strictTypes)!==null&&J!==void 0?J:ct)!==null&&W!==void 0?W:"log",strictTuples:(et=(he=N.strictTuples)!==null&&he!==void 0?he:ct)!==null&&et!==void 0?et:"log",strictRequired:(Vt=(Lt=N.strictRequired)!==null&&Lt!==void 0?Lt:ct)!==null&&Vt!==void 0?Vt:!1,code:N.code?{...N.code,optimize:Qr,regExp:Yr}:{optimize:Qr,regExp:Yr},loopRequired:(Ht=N.loopRequired)!==null&&Ht!==void 0?Ht:$,loopEnum:(Zt=N.loopEnum)!==null&&Zt!==void 0?Zt:$,meta:(Kt=N.meta)!==null&&Kt!==void 0?Kt:!0,messages:(Gt=N.messages)!==null&&Gt!==void 0?Gt:!0,inlineRefs:(Wt=N.inlineRefs)!==null&&Wt!==void 0?Wt:!0,schemaId:(Bt=N.schemaId)!==null&&Bt!==void 0?Bt:"$id",addUsedSchema:(Jt=N.addUsedSchema)!==null&&Jt!==void 0?Jt:!0,validateSchema:(Qt=N.validateSchema)!==null&&Qt!==void 0?Qt:!0,validateFormats:(Yt=N.validateFormats)!==null&&Yt!==void 0?Yt:!0,unicodeRegExp:(Xt=N.unicodeRegExp)!==null&&Xt!==void 0?Xt:!0,int32range:(er=N.int32range)!==null&&er!==void 0?er:!0,uriResolver:so}}class T{constructor(w={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,w=this.opts={...w,...E(w)};const{es5:C,lines:S}=this.opts.code;this.scope=new i.ValueScope({scope:{},prefixes:y,es5:C,lines:S}),this.logger=Z(w.logger);const u=w.validateFormats;w.validateFormats=!1,this.RULES=(0,o.getRules)(),R.call(this,g,w,"NOT SUPPORTED"),R.call(this,f,w,"DEPRECATED","warn"),this._metaOpts=q.call(this),w.formats&&U.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),w.keywords&&D.call(this,w.keywords),typeof w.meta=="object"&&this.addMetaSchema(w.meta),x.call(this),w.validateFormats=u}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:w,meta:C,schemaId:S}=this.opts;let u=h;S==="id"&&(u={...h},u.id=u.$id,delete u.$id),C&&w&&this.addMetaSchema(u,u[S],!1)}defaultMeta(){const{meta:w,schemaId:C}=this.opts;return this.opts.defaultMeta=typeof w=="object"?w[C]||w:void 0}validate(w,C){let S;if(typeof w=="string"){if(S=this.getSchema(w),!S)throw new Error(`no schema with key or ref "${w}"`)}else S=this.compile(w);const u=S(C);return"$async"in S||(this.errors=S.errors),u}compile(w,C){const S=this._addSchema(w,C);return S.validate||this._compileSchemaEnv(S)}compileAsync(w,C){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:S}=this.opts;return u.call(this,w,C);async function u(W,he){await p.call(this,W.$schema);const et=this._addSchema(W,he);return et.validate||k.call(this,et)}async function p(W){W&&!this.getSchema(W)&&await u.call(this,{$ref:W},!0)}async function k(W){try{return this._compileSchemaEnv(W)}catch(he){if(!(he instanceof s.default))throw he;return M.call(this,he),await z.call(this,he.missingSchema),k.call(this,W)}}function M({missingSchema:W,missingRef:he}){if(this.refs[W])throw new Error(`AnySchema ${W} is loaded but ${he} cannot be resolved`)}async function z(W){const he=await J.call(this,W);this.refs[W]||await p.call(this,he.$schema),this.refs[W]||this.addSchema(he,W,C)}async function J(W){const he=this._loading[W];if(he)return he;try{return await(this._loading[W]=S(W))}finally{delete this._loading[W]}}}addSchema(w,C,S,u=this.opts.validateSchema){if(Array.isArray(w)){for(const k of w)this.addSchema(k,void 0,S,u);return this}let p;if(typeof w=="object"){const{schemaId:k}=this.opts;if(p=w[k],p!==void 0&&typeof p!="string")throw new Error(`schema ${k} must be string`)}return C=(0,c.normalizeId)(C||p),this._checkUnique(C),this.schemas[C]=this._addSchema(w,S,C,u,!0),this}addMetaSchema(w,C,S=this.opts.validateSchema){return this.addSchema(w,C,!0,S),this}validateSchema(w,C){if(typeof w=="boolean")return!0;let S;if(S=w.$schema,S!==void 0&&typeof S!="string")throw new Error("$schema must be a string");if(S=S||this.opts.defaultMeta||this.defaultMeta(),!S)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const u=this.validate(S,w);if(!u&&C){const p="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(p);else throw new Error(p)}return u}getSchema(w){let C;for(;typeof(C=O.call(this,w))=="string";)w=C;if(C===void 0){const{schemaId:S}=this.opts,u=new a.SchemaEnv({schema:{},schemaId:S});if(C=a.resolveSchema.call(this,u,w),!C)return;this.refs[w]=C}return C.validate||this._compileSchemaEnv(C)}removeSchema(w){if(w instanceof RegExp)return this._removeAllSchemas(this.schemas,w),this._removeAllSchemas(this.refs,w),this;switch(typeof w){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const C=O.call(this,w);return typeof C=="object"&&this._cache.delete(C.schema),delete this.schemas[w],delete this.refs[w],this}case"object":{const C=w;this._cache.delete(C);let S=w[this.opts.schemaId];return S&&(S=(0,c.normalizeId)(S),delete this.schemas[S],delete this.refs[S]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(w){for(const C of w)this.addKeyword(C);return this}addKeyword(w,C){let S;if(typeof w=="string")S=w,typeof C=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),C.keyword=S);else if(typeof w=="object"&&C===void 0){if(C=w,S=C.keyword,Array.isArray(S)&&!S.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(F.call(this,S,C),!C)return(0,d.eachItem)(S,p=>le.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)(S,u.type.length===0?p=>le.call(this,p,u):p=>u.type.forEach(k=>le.call(this,p,u,k))),this}getKeyword(w){const C=this.RULES.all[w];return typeof C=="object"?C.definition:!!C}removeKeyword(w){const{RULES:C}=this;delete C.keywords[w],delete C.all[w];for(const S of C.rules){const u=S.rules.findIndex(p=>p.keyword===w);u>=0&&S.rules.splice(u,1)}return this}addFormat(w,C){return typeof C=="string"&&(C=new RegExp(C)),this.formats[w]=C,this}errorsText(w=this.errors,{separator:C=", ",dataVar:S="data"}={}){return!w||w.length===0?"No errors":w.map(u=>`${S}${u.instancePath} ${u.message}`).reduce((u,p)=>u+C+p)}$dataMetaSchema(w,C){const S=this.RULES.all;w=JSON.parse(JSON.stringify(w));for(const u of C){const p=u.split("/").slice(1);let k=w;for(const M of p)k=k[M];for(const M in S){const z=S[M];if(typeof z!="object")continue;const{$data:J}=z.definition,W=k[M];J&&W&&(k[M]=Ie(W))}}return w}_removeAllSchemas(w,C){for(const S in w){const u=w[S];(!C||C.test(S))&&(typeof u=="string"?delete w[S]:u&&!u.meta&&(this._cache.delete(u.schema),delete w[S]))}}_addSchema(w,C,S,u=this.opts.validateSchema,p=this.opts.addUsedSchema){let k;const{schemaId:M}=this.opts;if(typeof w=="object")k=w[M];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 z=this._cache.get(w);if(z!==void 0)return z;S=(0,c.normalizeId)(k||S);const J=c.getSchemaRefs.call(this,w,S);return z=new a.SchemaEnv({schema:w,schemaId:M,meta:C,baseId:S,localRefs:J}),this._cache.set(z.schema,z),p&&!S.startsWith("#")&&(S&&this._checkUnique(S),this.refs[S]=z),u&&this.validateSchema(w,!0),z}_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 R(N,w,C,S="error"){for(const u in N){const p=u;p in w&&this.logger[S](`${C}: option ${u}. ${N[p]}`)}}function O(N){return N=(0,c.normalizeId)(N),this.schemas[N]||this.refs[N]}function x(){const N=this.opts.schemas;if(N)if(Array.isArray(N))this.addSchema(N);else for(const w in N)this.addSchema(N[w],w)}function U(){for(const N in this.opts.formats){const w=this.opts.formats[N];w&&this.addFormat(N,w)}}function D(N){if(Array.isArray(N)){this.addVocabulary(N);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const w in N){const C=N[w];C.keyword||(C.keyword=w),this.addKeyword(C)}}function q(){const N={...this.opts};for(const w of v)delete N[w];return N}const L={log(){},warn(){},error(){}};function Z(N){if(N===!1)return L;if(N===void 0)return console;if(N.log&&N.warn&&N.error)return N;throw new Error("logger must implement log, warn and error methods")}const re=/^[a-z_$][a-z0-9_$:-]*$/i;function F(N,w){const{RULES:C}=this;if((0,d.eachItem)(N,S=>{if(C.keywords[S])throw new Error(`Keyword ${S} is already defined`);if(!re.test(S))throw new Error(`Keyword ${S} has invalid name`)}),!!w&&w.$data&&!("code"in w||"validate"in w))throw new Error('$data keyword must have "code" or "validate" function')}function le(N,w,C){var S;const u=w==null?void 0:w.post;if(C&&u)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:p}=this;let k=u?p.post:p.rules.find(({type:z})=>z===C);if(k||(k={type:C,rules:[]},p.rules.push(k)),p.keywords[N]=!0,!w)return;const M={keyword:N,definition:{...w,type:(0,l.getJSONTypes)(w.type),schemaType:(0,l.getJSONTypes)(w.schemaType)}};w.before?Ce.call(this,k,M,w.before):k.rules.push(M),p.all[N]=M,(S=w.implements)===null||S===void 0||S.forEach(z=>this.addKeyword(z))}function Ce(N,w,C){const S=N.rules.findIndex(u=>u.keyword===C);S>=0?N.rules.splice(S,0,w):(N.rules.push(w),this.logger.warn(`rule ${C} is not defined`))}function _e(N){let{metaSchema:w}=N;w!==void 0&&(N.$data&&this.opts.$data&&(w=Ie(w)),N.validateSchema=this.compile(w,!0))}const it={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Ie(N){return{anyOf:[N,it]}}})(Tf);var Yi={},Xi={},ec={};Object.defineProperty(ec,"__esModule",{value:!0});const MP={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};ec.default=MP;var $r={};Object.defineProperty($r,"__esModule",{value:!0});$r.callRef=$r.getValidate=void 0;const zP=Wr,ql=de,Je=ce,Pr=St,Ul=Ye,Qn=G,DP={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:r,it:n}=e,{baseId:s,schemaEnv:o,validateName:a,opts:i,self:c}=n,{root:l}=o;if((r==="#"||r==="#/")&&s===l.baseId)return h();const d=Ul.resolveRef.call(c,l,s,r);if(d===void 0)throw new zP.default(n.opts.uriResolver,s,r);if(d instanceof Ul.SchemaEnv)return m(d);return _(d);function h(){if(o===l)return ds(e,a,o,o.$async);const v=t.scopeValue("root",{ref:l});return ds(e,(0,Je._)`${v}.validate`,l,l.$async)}function m(v){const y=ih(e,v);ds(e,y,v,v.$async)}function _(v){const y=t.scopeValue("schema",i.code.source===!0?{ref:v,code:(0,Je.stringify)(v)}:{ref:v}),g=t.name("valid"),f=e.subschema({schema:v,dataTypes:[],schemaPath:Je.nil,topSchemaRef:y,errSchemaPath:r},g);e.mergeEvaluated(f),e.ok(g)}}};function ih(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Je._)`${r.scopeValue("wrapper",{ref:t})}.validate`}$r.getValidate=ih;function ds(e,t,r,n){const{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:c}=o,l=c.passContext?Pr.default.this:Je.nil;n?d():h();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");const v=s.let("valid");s.try(()=>{s.code((0,Je._)`await ${(0,ql.callValidateCode)(e,t,l)}`),_(t),a||s.assign(v,!0)},y=>{s.if((0,Je._)`!(${y} instanceof ${o.ValidationError})`,()=>s.throw(y)),m(y),a||s.assign(v,!1)}),e.ok(v)}function h(){e.result((0,ql.callValidateCode)(e,t,l),()=>_(t),()=>m(t))}function m(v){const y=(0,Je._)`${v}.errors`;s.assign(Pr.default.vErrors,(0,Je._)`${Pr.default.vErrors} === null ? ${y} : ${Pr.default.vErrors}.concat(${y})`),s.assign(Pr.default.errors,(0,Je._)`${Pr.default.vErrors}.length`)}function _(v){var y;if(!o.opts.unevaluated)return;const g=(y=r==null?void 0:r.validate)===null||y===void 0?void 0:y.evaluated;if(o.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(o.props=Qn.mergeEvaluated.props(s,g.props,o.props));else{const f=s.var("props",(0,Je._)`${v}.evaluated.props`);o.props=Qn.mergeEvaluated.props(s,f,o.props,Je.Name)}if(o.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(o.items=Qn.mergeEvaluated.items(s,g.items,o.items));else{const f=s.var("items",(0,Je._)`${v}.evaluated.items`);o.items=Qn.mergeEvaluated.items(s,f,o.items,Je.Name)}}}$r.callRef=ds;$r.default=DP;Object.defineProperty(Xi,"__esModule",{value:!0});const qP=ec,UP=$r,FP=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",qP.default,UP.default];Xi.default=FP;var tc={},rc={};Object.defineProperty(rc,"__esModule",{value:!0});const Ts=ce,Nt=Ts.operators,Cs={maximum:{okStr:"<=",ok:Nt.LTE,fail:Nt.GT},minimum:{okStr:">=",ok:Nt.GTE,fail:Nt.LT},exclusiveMaximum:{okStr:"<",ok:Nt.LT,fail:Nt.GTE},exclusiveMinimum:{okStr:">",ok:Nt.GT,fail:Nt.LTE}},LP={message:({keyword:e,schemaCode:t})=>(0,Ts.str)`must be ${Cs[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Ts._)`{comparison: ${Cs[e].okStr}, limit: ${t}}`},VP={keyword:Object.keys(Cs),type:"number",schemaType:"number",$data:!0,error:LP,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,Ts._)`${r} ${Cs[t].fail} ${n} || isNaN(${r})`)}};rc.default=VP;var nc={};Object.defineProperty(nc,"__esModule",{value:!0});const gn=ce,HP={message:({schemaCode:e})=>(0,gn.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,gn._)`{multipleOf: ${e}}`},ZP={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:HP,code(e){const{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0,gn._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0,gn._)`${a} !== parseInt(${a})`;e.fail$data((0,gn._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};nc.default=ZP;var sc={},oc={};Object.defineProperty(oc,"__esModule",{value:!0});function ch(e){const t=e.length;let r=0,n=0,s;for(;n=55296&&s<=56319&&n(0,fr._)`{limit: ${e}}`},BP={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:WP,code(e){const{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?fr.operators.GT:fr.operators.LT,a=s.opts.unicode===!1?(0,fr._)`${r}.length`:(0,fr._)`${(0,KP.useFunc)(e.gen,GP.default)}(${r})`;e.fail$data((0,fr._)`${a} ${o} ${n}`)}};sc.default=BP;var ac={};Object.defineProperty(ac,"__esModule",{value:!0});const JP=de,QP=G,Or=ce,YP={message:({schemaCode:e})=>(0,Or.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Or._)`{pattern: ${e}}`},XP={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:YP,code(e){const{gen:t,data:r,$data:n,schema:s,schemaCode:o,it:a}=e,i=a.opts.unicodeRegExp?"u":"";if(n){const{regExp:c}=a.opts.code,l=c.code==="new RegExp"?(0,Or._)`new RegExp`:(0,QP.useFunc)(t,c),d=t.let("valid");t.try(()=>t.assign(d,(0,Or._)`${l}(${o}, ${i}).test(${r})`),()=>t.assign(d,!1)),e.fail$data((0,Or._)`!${d}`)}else{const c=(0,JP.usePattern)(e,s);e.fail$data((0,Or._)`!${c}.test(${r})`)}}};ac.default=XP;var ic={};Object.defineProperty(ic,"__esModule",{value:!0});const _n=ce,e1={message({keyword:e,schemaCode:t}){const r=e==="maxProperties"?"more":"fewer";return(0,_n.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,_n._)`{limit: ${e}}`},t1={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:e1,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?_n.operators.GT:_n.operators.LT;e.fail$data((0,_n._)`Object.keys(${r}).length ${s} ${n}`)}};ic.default=t1;var cc={};Object.defineProperty(cc,"__esModule",{value:!0});const nn=de,yn=ce,r1=G,n1={message:({params:{missingProperty:e}})=>(0,yn.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,yn._)`{missingProperty: ${e}}`},s1={keyword:"required",type:"object",schemaType:"array",$data:!0,error:n1,code(e){const{gen:t,schema:r,schemaCode:n,data:s,$data:o,it:a}=e,{opts:i}=a;if(!o&&r.length===0)return;const c=r.length>=i.loopRequired;if(a.allErrors?l():d(),i.strictRequired){const _=e.parentSchema.properties,{definedProperties:v}=e.it;for(const y of r)if((_==null?void 0:_[y])===void 0&&!v.has(y)){const g=a.schemaEnv.baseId+a.errSchemaPath,f=`required property "${y}" is not defined at "${g}" (strictRequired)`;(0,r1.checkStrictMode)(a,f,a.opts.strictRequired)}}function l(){if(c||o)e.block$data(yn.nil,h);else for(const _ of r)(0,nn.checkReportMissingProp)(e,_)}function d(){const _=t.let("missing");if(c||o){const v=t.let("valid",!0);e.block$data(v,()=>m(_,v)),e.ok(v)}else t.if((0,nn.checkMissingProp)(e,r,_)),(0,nn.reportMissingProp)(e,_),t.else()}function h(){t.forOf("prop",n,_=>{e.setParams({missingProperty:_}),t.if((0,nn.noPropertyInData)(t,s,_,i.ownProperties),()=>e.error())})}function m(_,v){e.setParams({missingProperty:_}),t.forOf(_,n,()=>{t.assign(v,(0,nn.propertyInData)(t,s,_,i.ownProperties)),t.if((0,yn.not)(v),()=>{e.error(),t.break()})},yn.nil)}}};cc.default=s1;var lc={};Object.defineProperty(lc,"__esModule",{value:!0});const vn=ce,o1={message({keyword:e,schemaCode:t}){const r=e==="maxItems"?"more":"fewer";return(0,vn.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,vn._)`{limit: ${e}}`},a1={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:o1,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?vn.operators.GT:vn.operators.LT;e.fail$data((0,vn._)`${r}.length ${s} ${n}`)}};lc.default=a1;var uc={},Fn={};Object.defineProperty(Fn,"__esModule",{value:!0});const lh=Gs;lh.code='require("ajv/dist/runtime/equal").default';Fn.default=lh;Object.defineProperty(uc,"__esModule",{value:!0});const _o=xe,De=ce,i1=G,c1=Fn,l1={message:({params:{i:e,j:t}})=>(0,De.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,De._)`{i: ${e}, j: ${t}}`},u1={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:l1,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,_o.getSchemaTypes)(o.items):[];e.block$data(c,d,(0,De._)`${a} === false`),e.ok(c);function d(){const v=t.let("i",(0,De._)`${r}.length`),y=t.let("j");e.setParams({i:v,j:y}),t.assign(c,!0),t.if((0,De._)`${v} > 1`,()=>(h()?m:_)(v,y))}function h(){return l.length>0&&!l.some(v=>v==="object"||v==="array")}function m(v,y){const g=t.name("item"),f=(0,_o.checkDataTypes)(l,g,i.opts.strictNumbers,_o.DataType.Wrong),$=t.const("indices",(0,De._)`{}`);t.for((0,De._)`;${v}--;`,()=>{t.let(g,(0,De._)`${r}[${v}]`),t.if(f,(0,De._)`continue`),l.length>1&&t.if((0,De._)`typeof ${g} == "string"`,(0,De._)`${g} += "_"`),t.if((0,De._)`typeof ${$}[${g}] == "number"`,()=>{t.assign(y,(0,De._)`${$}[${g}]`),e.error(),t.assign(c,!1).break()}).code((0,De._)`${$}[${g}] = ${v}`)})}function _(v,y){const g=(0,i1.useFunc)(t,c1.default),f=t.name("outer");t.label(f).for((0,De._)`;${v}--;`,()=>t.for((0,De._)`${y} = ${v}; ${y}--;`,()=>t.if((0,De._)`${g}(${r}[${v}], ${r}[${y}])`,()=>{e.error(),t.assign(c,!1).break(f)})))}}};uc.default=u1;var dc={};Object.defineProperty(dc,"__esModule",{value:!0});const Wo=ce,d1=G,f1=Fn,h1={message:"must be equal to constant",params:({schemaCode:e})=>(0,Wo._)`{allowedValue: ${e}}`},p1={keyword:"const",$data:!0,error:h1,code(e){const{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,Wo._)`!${(0,d1.useFunc)(t,f1.default)}(${r}, ${s})`):e.fail((0,Wo._)`${o} !== ${r}`)}};dc.default=p1;var fc={};Object.defineProperty(fc,"__esModule",{value:!0});const cn=ce,m1=G,g1=Fn,_1={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,cn._)`{allowedValues: ${e}}`},y1={keyword:"enum",schemaType:"array",$data:!0,error:_1,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,m1.useFunc)(t,g1.default));let d;if(i||n)d=t.let("valid"),e.block$data(d,h);else{if(!Array.isArray(s))throw new Error("ajv implementation error");const _=t.const("vSchema",o);d=(0,cn.or)(...s.map((v,y)=>m(_,y)))}e.pass(d);function h(){t.assign(d,!1),t.forOf("v",o,_=>t.if((0,cn._)`${l()}(${r}, ${_})`,()=>t.assign(d,!0).break()))}function m(_,v){const y=s[v];return typeof y=="object"&&y!==null?(0,cn._)`${l()}(${r}, ${_}[${v}])`:(0,cn._)`${r} === ${y}`}}};fc.default=y1;Object.defineProperty(tc,"__esModule",{value:!0});const v1=rc,$1=nc,w1=sc,b1=ac,S1=ic,E1=cc,k1=lc,P1=uc,R1=dc,T1=fc,C1=[v1.default,$1.default,w1.default,b1.default,S1.default,E1.default,k1.default,P1.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},R1.default,T1.default];tc.default=C1;var hc={},Br={};Object.defineProperty(Br,"__esModule",{value:!0});Br.validateAdditionalItems=void 0;const hr=ce,Bo=G,j1={message:({params:{len:e}})=>(0,hr.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,hr._)`{limit: ${e}}`},N1={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:j1,code(e){const{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Bo.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}uh(e,n)}};function uh(e,t){const{gen:r,schema:n,data:s,keyword:o,it:a}=e;a.items=!0;const i=r.const("len",(0,hr._)`${s}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,hr._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0,Bo.alwaysValidSchema)(a,n)){const l=r.var("valid",(0,hr._)`${i} <= ${t.length}`);r.if((0,hr.not)(l),()=>c(l)),e.ok(l)}function c(l){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:Bo.Type.Num},l),a.allErrors||r.if((0,hr.not)(l),()=>r.break())})}}Br.validateAdditionalItems=uh;Br.default=N1;var pc={},Jr={};Object.defineProperty(Jr,"__esModule",{value:!0});Jr.validateTuple=void 0;const Fl=ce,fs=G,I1=de,O1={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return dh(e,"additionalItems",t);r.items=!0,!(0,fs.alwaysValidSchema)(r,t)&&e.ok((0,I1.validateArray)(e))}};function dh(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=fs.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),l=n.const("len",(0,Fl._)`${o}.length`);r.forEach((h,m)=>{(0,fs.alwaysValidSchema)(i,h)||(n.if((0,Fl._)`${l} > ${m}`,()=>e.subschema({keyword:a,schemaProp:m,dataProp:m},c)),e.ok(c))});function d(h){const{opts:m,errSchemaPath:_}=i,v=r.length,y=v===h.minItems&&(v===h.maxItems||h[t]===!1);if(m.strictTuples&&!y){const g=`"${a}" is ${v}-tuple, but minItems or maxItems/${t} are not specified or different at path "${_}"`;(0,fs.checkStrictMode)(i,g,m.strictTuples)}}}Jr.validateTuple=dh;Jr.default=O1;Object.defineProperty(pc,"__esModule",{value:!0});const x1=Jr,A1={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,x1.validateTuple)(e,"items")};pc.default=A1;var mc={};Object.defineProperty(mc,"__esModule",{value:!0});const Ll=ce,M1=G,z1=de,D1=Br,q1={message:({params:{len:e}})=>(0,Ll.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Ll._)`{limit: ${e}}`},U1={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:q1,code(e){const{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=!0,!(0,M1.alwaysValidSchema)(n,t)&&(s?(0,D1.validateAdditionalItems)(e,s):e.ok((0,z1.validateArray)(e)))}};mc.default=U1;var gc={};Object.defineProperty(gc,"__esModule",{value:!0});const st=ce,Yn=G,F1={message:({params:{min:e,max:t}})=>t===void 0?(0,st.str)`must contain at least ${e} valid item(s)`:(0,st.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,st._)`{minContains: ${e}}`:(0,st._)`{minContains: ${e}, maxContains: ${t}}`},L1={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:F1,code(e){const{gen:t,schema:r,parentSchema:n,data:s,it:o}=e;let a,i;const{minContains:c,maxContains:l}=n;o.opts.next?(a=c===void 0?1:c,i=l):a=1;const d=t.const("len",(0,st._)`${s}.length`);if(e.setParams({min:a,max:i}),i===void 0&&a===0){(0,Yn.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0,Yn.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Yn.alwaysValidSchema)(o,r)){let y=(0,st._)`${d} >= ${a}`;i!==void 0&&(y=(0,st._)`${y} && ${d} <= ${i}`),e.pass(y);return}o.items=!0;const h=t.name("valid");i===void 0&&a===1?_(h,()=>t.if(h,()=>t.break())):a===0?(t.let(h,!0),i!==void 0&&t.if((0,st._)`${s}.length > 0`,m)):(t.let(h,!1),m()),e.result(h,()=>e.reset());function m(){const y=t.name("_valid"),g=t.let("count",0);_(y,()=>t.if(y,()=>v(g)))}function _(y,g){t.forRange("i",0,d,f=>{e.subschema({keyword:"contains",dataProp:f,dataPropType:Yn.Type.Num,compositeRule:!0},y),g()})}function v(y){t.code((0,st._)`${y}++`),i===void 0?t.if((0,st._)`${y} >= ${a}`,()=>t.assign(h,!0).break()):(t.if((0,st._)`${y} > ${i}`,()=>t.assign(h,!1).break()),a===1?t.assign(h,!0):t.if((0,st._)`${y} >= ${a}`,()=>t.assign(h,!0)))}}};gc.default=L1;var fh={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=ce,r=G,n=de;e.error={message:({params:{property:c,depsCount:l,deps:d}})=>{const h=l===1?"property":"properties";return(0,t.str)`must have ${h} ${d} when property ${c} is present`},params:({params:{property:c,depsCount:l,deps:d,missingProperty:h}})=>(0,t._)`{property: ${c}, - missingProperty: ${h}, - depsCount: ${l}, - deps: ${d}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(c){const[l,d]=o(c);a(c,l),i(c,d)}};function o({schema:c}){const l={},d={};for(const h in c){if(h==="__proto__")continue;const m=Array.isArray(c[h])?l:d;m[h]=c[h]}return[l,d]}function a(c,l=c.schema){const{gen:d,data:h,it:m}=c;if(Object.keys(l).length===0)return;const _=d.let("missing");for(const v in l){const y=l[v];if(y.length===0)continue;const g=(0,n.propertyInData)(d,h,v,m.opts.ownProperties);c.setParams({property:v,depsCount:y.length,deps:y.join(", ")}),m.allErrors?d.if(g,()=>{for(const f of y)(0,n.checkReportMissingProp)(c,f)}):(d.if((0,t._)`${g} && (${(0,n.checkMissingProp)(c,y,_)})`),(0,n.reportMissingProp)(c,_),d.else())}}e.validatePropertyDeps=a;function i(c,l=c.schema){const{gen:d,data:h,keyword:m,it:_}=c,v=d.name("valid");for(const y in l)(0,r.alwaysValidSchema)(_,l[y])||(d.if((0,n.propertyInData)(d,h,y,_.opts.ownProperties),()=>{const g=c.subschema({keyword:m,schemaProp:y},v);c.mergeValidEvaluated(g,v)},()=>d.var(v,!0)),c.ok(v))}e.validateSchemaDeps=i,e.default=s})(fh);var _c={};Object.defineProperty(_c,"__esModule",{value:!0});const hh=ce,V1=G,H1={message:"property name must be valid",params:({params:e})=>(0,hh._)`{propertyName: ${e.propertyName}}`},Z1={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:H1,code(e){const{gen:t,schema:r,data:n,it:s}=e;if((0,V1.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,hh.not)(o),()=>{e.error(!0),s.allErrors||t.break()})}),e.ok(o)}};_c.default=Z1;var ro={};Object.defineProperty(ro,"__esModule",{value:!0});const Xn=de,ft=ce,K1=St,es=G,G1={message:"must NOT have additional properties",params:({params:e})=>(0,ft._)`{additionalProperty: ${e.additionalProperty}}`},W1={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:G1,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,es.alwaysValidSchema)(a,r))return;const l=(0,Xn.allSchemaProperties)(n.properties),d=(0,Xn.allSchemaProperties)(n.patternProperties);h(),e.ok((0,ft._)`${o} === ${K1.default.errors}`);function h(){t.forIn("key",s,g=>{!l.length&&!d.length?v(g):t.if(m(g),()=>v(g))})}function m(g){let f;if(l.length>8){const $=(0,es.schemaRefOrVal)(a,n.properties,"properties");f=(0,Xn.isOwnProperty)(t,$,g)}else l.length?f=(0,ft.or)(...l.map($=>(0,ft._)`${g} === ${$}`)):f=ft.nil;return d.length&&(f=(0,ft.or)(f,...d.map($=>(0,ft._)`${(0,Xn.usePattern)(e,$)}.test(${g})`))),(0,ft.not)(f)}function _(g){t.code((0,ft._)`delete ${s}[${g}]`)}function v(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){_(g);return}if(r===!1){e.setParams({additionalProperty:g}),e.error(),i||t.break();return}if(typeof r=="object"&&!(0,es.alwaysValidSchema)(a,r)){const f=t.name("valid");c.removeAdditional==="failing"?(y(g,f,!1),t.if((0,ft.not)(f),()=>{e.reset(),_(g)})):(y(g,f),i||t.if((0,ft.not)(f),()=>t.break()))}}function y(g,f,$){const E={keyword:"additionalProperties",dataProp:g,dataPropType:es.Type.Str};$===!1&&Object.assign(E,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(E,f)}}};ro.default=W1;var yc={};Object.defineProperty(yc,"__esModule",{value:!0});const B1=gt,Vl=de,yo=G,Hl=ro,J1={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&&Hl.default.code(new B1.KeywordCxt(o,Hl.default,"additionalProperties"));const a=(0,Vl.allSchemaProperties)(r);for(const h of a)o.definedProperties.add(h);o.opts.unevaluated&&a.length&&o.props!==!0&&(o.props=yo.mergeEvaluated.props(t,(0,yo.toHash)(a),o.props));const i=a.filter(h=>!(0,yo.alwaysValidSchema)(o,r[h]));if(i.length===0)return;const c=t.name("valid");for(const h of i)l(h)?d(h):(t.if((0,Vl.propertyInData)(t,s,h,o.opts.ownProperties)),d(h),o.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(h),e.ok(c);function l(h){return o.opts.useDefaults&&!o.compositeRule&&r[h].default!==void 0}function d(h){e.subschema({keyword:"properties",schemaProp:h,dataProp:h},c)}}};yc.default=J1;var vc={};Object.defineProperty(vc,"__esModule",{value:!0});const Zl=de,ts=ce,Kl=G,Gl=G,Q1={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,Zl.allSchemaProperties)(r),c=i.filter(y=>(0,Kl.alwaysValidSchema)(o,r[y]));if(i.length===0||c.length===i.length&&(!o.opts.unevaluated||o.props===!0))return;const l=a.strictSchema&&!a.allowMatchingProperties&&s.properties,d=t.name("valid");o.props!==!0&&!(o.props instanceof ts.Name)&&(o.props=(0,Gl.evaluatedPropsToName)(t,o.props));const{props:h}=o;m();function m(){for(const y of i)l&&_(y),o.allErrors?v(y):(t.var(d,!0),v(y),t.if(d))}function _(y){for(const g in l)new RegExp(y).test(g)&&(0,Kl.checkStrictMode)(o,`property ${g} matches pattern ${y} (use allowMatchingProperties)`)}function v(y){t.forIn("key",n,g=>{t.if((0,ts._)`${(0,Zl.usePattern)(e,y)}.test(${g})`,()=>{const f=c.includes(y);f||e.subschema({keyword:"patternProperties",schemaProp:y,dataProp:g,dataPropType:Gl.Type.Str},d),o.opts.unevaluated&&h!==!0?t.assign((0,ts._)`${h}[${g}]`,!0):!f&&!o.allErrors&&t.if((0,ts.not)(d),()=>t.break())})})}}};vc.default=Q1;var $c={};Object.defineProperty($c,"__esModule",{value:!0});const Y1=G,X1={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,Y1.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"}};$c.default=X1;var wc={};Object.defineProperty(wc,"__esModule",{value:!0});const eR=de,tR={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:eR.validateUnion,error:{message:"must match a schema in anyOf"}};wc.default=tR;var bc={};Object.defineProperty(bc,"__esModule",{value:!0});const hs=ce,rR=G,nR={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,hs._)`{passingSchemas: ${e.passing}}`},sR={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:nR,code(e){const{gen:t,schema:r,parentSchema:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;const o=r,a=t.let("valid",!1),i=t.let("passing",null),c=t.name("_valid");e.setParams({passing:i}),t.block(l),e.result(a,()=>e.reset(),()=>e.error(!0));function l(){o.forEach((d,h)=>{let m;(0,rR.alwaysValidSchema)(s,d)?t.var(c,!0):m=e.subschema({keyword:"oneOf",schemaProp:h,compositeRule:!0},c),h>0&&t.if((0,hs._)`${c} && ${a}`).assign(a,!1).assign(i,(0,hs._)`[${i}, ${h}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,h),m&&e.mergeEvaluated(m,hs.Name)})})}}};bc.default=sR;var Sc={};Object.defineProperty(Sc,"__esModule",{value:!0});const oR=G,aR={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,oR.alwaysValidSchema)(n,o))return;const i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i)})}};Sc.default=aR;var Ec={};Object.defineProperty(Ec,"__esModule",{value:!0});const js=ce,ph=G,iR={message:({params:e})=>(0,js.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,js._)`{failingKeyword: ${e.ifClause}}`},cR={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:iR,code(e){const{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,ph.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const s=Wl(n,"then"),o=Wl(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,js.not)(i),l("else"));e.pass(a,()=>e.error(!0));function c(){const d=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},i);e.mergeEvaluated(d)}function l(d,h){return()=>{const m=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(m,a),h?t.assign(h,(0,js._)`${d}`):e.setParams({ifClause:d})}}}};function Wl(e,t){const r=e.schema[t];return r!==void 0&&!(0,ph.alwaysValidSchema)(e,r)}Ec.default=cR;var kc={};Object.defineProperty(kc,"__esModule",{value:!0});const lR=G,uR={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,lR.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};kc.default=uR;Object.defineProperty(hc,"__esModule",{value:!0});const dR=Br,fR=pc,hR=Jr,pR=mc,mR=gc,gR=fh,_R=_c,yR=ro,vR=yc,$R=vc,wR=$c,bR=wc,SR=bc,ER=Sc,kR=Ec,PR=kc;function RR(e=!1){const t=[wR.default,bR.default,SR.default,ER.default,kR.default,PR.default,_R.default,yR.default,gR.default,vR.default,$R.default];return e?t.push(fR.default,pR.default):t.push(dR.default,hR.default),t.push(mR.default),t}hc.default=RR;var Pc={},Rc={};Object.defineProperty(Rc,"__esModule",{value:!0});const Ne=ce,TR={message:({schemaCode:e})=>(0,Ne.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,Ne._)`{format: ${e}}`},CR={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:TR,code(e,t){const{gen:r,data:n,$data:s,schema:o,schemaCode:a,it:i}=e,{opts:c,errSchemaPath:l,schemaEnv:d,self:h}=i;if(!c.validateFormats)return;s?m():_();function m(){const v=r.scopeValue("formats",{ref:h.formats,code:c.code.formats}),y=r.const("fDef",(0,Ne._)`${v}[${a}]`),g=r.let("fType"),f=r.let("format");r.if((0,Ne._)`typeof ${y} == "object" && !(${y} instanceof RegExp)`,()=>r.assign(g,(0,Ne._)`${y}.type || "string"`).assign(f,(0,Ne._)`${y}.validate`),()=>r.assign(g,(0,Ne._)`"string"`).assign(f,y)),e.fail$data((0,Ne.or)($(),E()));function $(){return c.strictSchema===!1?Ne.nil:(0,Ne._)`${a} && !${f}`}function E(){const T=d.$async?(0,Ne._)`(${y}.async ? await ${f}(${n}) : ${f}(${n}))`:(0,Ne._)`${f}(${n})`,R=(0,Ne._)`(typeof ${f} == "function" ? ${T} : ${f}.test(${n}))`;return(0,Ne._)`${f} && ${f} !== true && ${g} === ${t} && !${R}`}}function _(){const v=h.formats[o];if(!v){$();return}if(v===!0)return;const[y,g,f]=E(v);y===t&&e.pass(T());function $(){if(c.strictSchema===!1){h.logger.warn(R());return}throw new Error(R());function R(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function E(R){const O=R instanceof RegExp?(0,Ne.regexpCode)(R):c.code.formats?(0,Ne._)`${c.code.formats}${(0,Ne.getProperty)(o)}`:void 0,x=r.scopeValue("formats",{key:o,ref:R,code:O});return typeof R=="object"&&!(R instanceof RegExp)?[R.type||"string",R.validate,(0,Ne._)`${x}.validate`]:["string",R,x]}function T(){if(typeof v=="object"&&!(v instanceof RegExp)&&v.async){if(!d.$async)throw new Error("async format in sync schema");return(0,Ne._)`await ${f}(${n})`}return typeof g=="function"?(0,Ne._)`${f}(${n})`:(0,Ne._)`${f}.test(${n})`}}}};Rc.default=CR;Object.defineProperty(Pc,"__esModule",{value:!0});const jR=Rc,NR=[jR.default];Pc.default=NR;var Lr={};Object.defineProperty(Lr,"__esModule",{value:!0});Lr.contentVocabulary=Lr.metadataVocabulary=void 0;Lr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Lr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(Yi,"__esModule",{value:!0});const IR=Xi,OR=tc,xR=hc,AR=Pc,Bl=Lr,MR=[IR.default,OR.default,(0,xR.default)(),AR.default,Bl.metadataVocabulary,Bl.contentVocabulary];Yi.default=MR;var Tc={},no={};Object.defineProperty(no,"__esModule",{value:!0});no.DiscrError=void 0;var Jl;(function(e){e.Tag="tag",e.Mapping="mapping"})(Jl||(no.DiscrError=Jl={}));Object.defineProperty(Tc,"__esModule",{value:!0});const jr=ce,Jo=no,Ql=Ye,zR=Wr,DR=G,qR={message:({params:{discrError:e,tagName:t}})=>e===Jo.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,jr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},UR={keyword:"discriminator",type:"object",schemaType:"object",error:qR,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,jr._)`${r}${(0,jr.getProperty)(i)}`);t.if((0,jr._)`typeof ${l} == "string"`,()=>d(),()=>e.error(!1,{discrError:Jo.DiscrError.Tag,tag:l,tagName:i})),e.ok(c);function d(){const _=m();t.if(!1);for(const v in _)t.elseIf((0,jr._)`${l} === ${v}`),t.assign(c,h(_[v]));t.else(),e.error(!1,{discrError:Jo.DiscrError.Mapping,tag:l,tagName:i}),t.endIf()}function h(_){const v=t.name("valid"),y=e.subschema({keyword:"oneOf",schemaProp:_},v);return e.mergeEvaluated(y,jr.Name),v}function m(){var _;const v={},y=f(s);let g=!0;for(let T=0;Tthis.addVocabulary(v)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const v=this.opts.$data?this.$dataMetaSchema(o,a):o;this.addMetaSchema(v,i,!1),this.refs["http://json-schema.org/schema"]=i}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(i)?i:void 0)}}t.Ajv=c,e.exports=t=c,e.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var l=gt;Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var d=ce;Object.defineProperty(t,"_",{enumerable:!0,get:function(){return d._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return d.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return d.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return d.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return d.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return d.CodeGen}});var h=Un;Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return h.default}});var m=Wr;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return m.default}})})(Vo,Vo.exports);var WR=Vo.exports;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;const t=WR,r=ce,n=r.operators,s={formatMaximum:{okStr:"<=",ok:n.LTE,fail:n.GT},formatMinimum:{okStr:">=",ok:n.GTE,fail:n.LT},formatExclusiveMaximum:{okStr:"<",ok:n.LT,fail:n.GTE},formatExclusiveMinimum:{okStr:">",ok:n.GT,fail:n.LTE}},o={message:({keyword:i,schemaCode:c})=>(0,r.str)`should be ${s[i].okStr} ${c}`,params:({keyword:i,schemaCode:c})=>(0,r._)`{comparison: ${s[i].okStr}, limit: ${c}}`};e.formatLimitDefinition={keyword:Object.keys(s),type:"string",schemaType:"string",$data:!0,error:o,code(i){const{gen:c,data:l,schemaCode:d,keyword:h,it:m}=i,{opts:_,self:v}=m;if(!_.validateFormats)return;const y=new t.KeywordCxt(m,v.RULES.all.format.definition,"format");y.$data?g():f();function g(){const E=c.scopeValue("formats",{ref:v.formats,code:_.code.formats}),T=c.const("fmt",(0,r._)`${E}[${y.schemaCode}]`);i.fail$data((0,r.or)((0,r._)`typeof ${T} != "object"`,(0,r._)`${T} instanceof RegExp`,(0,r._)`typeof ${T}.compare != "function"`,$(T)))}function f(){const E=y.schema,T=v.formats[E];if(!T||T===!0)return;if(typeof T!="object"||T instanceof RegExp||typeof T.compare!="function")throw new Error(`"${h}": format "${E}" does not define "compare" function`);const R=c.scopeValue("formats",{key:E,ref:T,code:_.code.formats?(0,r._)`${_.code.formats}${(0,r.getProperty)(E)}`:void 0});i.fail$data($(R))}function $(E){return(0,r._)`${E}.compare(${l}, ${d}) ${s[h].fail} 0`}},dependencies:["format"]};const a=i=>(i.addKeyword(e.formatLimitDefinition),i);e.default=a})(Rf);(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r=Pf,n=Rf,s=ce,o=new s.Name("fullFormats"),a=new s.Name("fastFormats"),i=(l,d={keywords:!0})=>{if(Array.isArray(d))return c(l,d,r.fullFormats,o),l;const[h,m]=d.mode==="fast"?[r.fastFormats,a]:[r.fullFormats,o],_=d.formats||r.formatNames;return c(l,_,h,m),d.keywords&&(0,n.default)(l),l};i.get=(l,d="full")=>{const m=(d==="fast"?r.fastFormats:r.fullFormats)[l];if(!m)throw new Error(`Unknown format "${l}"`);return m};function c(l,d,h,m){var _,v;(_=(v=l.opts.code).formats)!==null&&_!==void 0||(v.formats=(0,s._)`require("ajv-formats/dist/formats").${m}`);for(const y of d)l.addFormat(y,h[y])}e.exports=t=i,Object.defineProperty(t,"__esModule",{value:!0}),t.default=i})(Lo,Lo.exports);var BR=Lo.exports;const JR=au(BR);function QR(){const e=new ME({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return JR(e),e}class YR{constructor(t){this._ajv=t??QR()}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 XR{constructor(t){this._client=t}async*callToolStream(t,r=mr,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 X(ne.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 X(ne.InvalidParams,`Structured content does not match the tool's output schema: ${d.errorMessage}`)};return}}catch(d){if(d instanceof X){yield{type:"error",error:d};return}yield{type:"error",error:new X(ne.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 eT(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 tT(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 ps(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&&ps(o,r[s])}}if(Array.isArray(e.anyOf))for(const r of e.anyOf)typeof r!="boolean"&&ps(r,t);if(Array.isArray(e.oneOf))for(const r of e.oneOf)typeof r!="boolean"&&ps(r,t)}}function rT(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 nT extends vd{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 YR,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",Za,t.tools,async()=>(await this.listTools()).tools),t.prompts&&((o=(s=this._serverCapabilities)==null?void 0:s.prompts)!=null&&o.listChanged)&&this._setupListChangedHandler("prompts",La,t.prompts,async()=>(await this.listPrompts()).prompts),t.resources&&((i=(a=this._serverCapabilities)==null?void 0:a.resources)!=null&&i.listChanged)&&this._setupListChangedHandler("resources",za,t.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new XR(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=t$(this._capabilities,t)}setRequestHandler(t,r){const n=_d(t),s=n==null?void 0:n.method;if(!s)throw new Error("Schema is missing a method literal");const o=yd(s);if(typeof o!="string")throw new Error("Schema method literal must be a string");const a=o;if(a==="elicitation/create"){const i=async(c,l)=>{var $,E;const d=Ot(pd,c);if(!d.success){const T=d.error instanceof Error?d.error.message:String(d.error);throw new X(ne.InvalidParams,`Invalid elicitation request: ${T}`)}const{params:h}=d.data;h.mode=h.mode??"form";const{supportsFormMode:m,supportsUrlMode:_}=rT(this._capabilities.elicitation);if(h.mode==="form"&&!m)throw new X(ne.InvalidParams,"Client does not support form-mode elicitation requests");if(h.mode==="url"&&!_)throw new X(ne.InvalidParams,"Client does not support URL-mode elicitation requests");const v=await Promise.resolve(r(c,l));if(h.task){const T=Ot(bn,v);if(!T.success){const R=T.error instanceof Error?T.error.message:String(T.error);throw new X(ne.InvalidParams,`Invalid task creation result: ${R}`)}return T.data}const y=Ot(md,v);if(!y.success){const T=y.error instanceof Error?y.error.message:String(y.error);throw new X(ne.InvalidParams,`Invalid elicitation result: ${T}`)}const g=y.data,f=h.mode==="form"?h.requestedSchema:void 0;if(h.mode==="form"&&g.action==="accept"&&g.content&&f&&(E=($=this._capabilities.elicitation)==null?void 0:$.form)!=null&&E.applyDefaults)try{ps(f,g.content)}catch{}return g};return super.setRequestHandler(t,i)}if(a==="sampling/createMessage"){const i=async(c,l)=>{const d=Ot(Ka,c);if(!d.success){const g=d.error instanceof Error?d.error.message:String(d.error);throw new X(ne.InvalidParams,`Invalid sampling request: ${g}`)}const{params:h}=d.data,m=await Promise.resolve(r(c,l));if(h.task){const g=Ot(bn,m);if(!g.success){const f=g.error instanceof Error?g.error.message:String(g.error);throw new X(ne.InvalidParams,`Invalid task creation result: ${f}`)}return g.data}const v=h.tools||h.toolChoice?hd:fd,y=Ot(v,m);if(!y.success){const g=y.error instanceof Error?y.error.message:String(y.error);throw new X(ne.InvalidParams,`Invalid sampling result: ${g}`)}return y.data};return super.setRequestHandler(t,i)}return super.setRequestHandler(t,r)}assertCapability(t,r){var n;if(!((n=this._serverCapabilities)!=null&&n[t]))throw new Error(`Server does not support ${t} (required for ${r})`)}async connect(t,r){if(await super.connect(t),t.sessionId===void 0)try{const n=await this.request({method:"initialize",params:{protocolVersion:Ls,capabilities:this._capabilities,clientInfo:this._clientInfo}},Ju,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!jy.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;eT((n=(r=this._serverCapabilities)==null?void 0:r.tasks)==null?void 0:n.requests,t,"Server")}assertTaskHandlerCapability(t){var r;this._capabilities&&tT((r=this._capabilities.tasks)==null?void 0:r.requests,t,"Client")}async ping(t){return this.request({method:"ping"},Nr,t)}async complete(t,r){return this.request({method:"completion/complete",params:t},gd,r)}async setLoggingLevel(t,r){return this.request({method:"logging/setLevel",params:{level:t}},Nr,r)}async getPrompt(t,r){return this.request({method:"prompts/get",params:t},cd,r)}async listPrompts(t,r){return this.request({method:"prompts/list",params:t},Da,r)}async listResources(t,r){return this.request({method:"resources/list",params:t},Oa,r)}async listResourceTemplates(t,r){return this.request({method:"resources/templates/list",params:t},xa,r)}async readResource(t,r){return this.request({method:"resources/read",params:t},Ma,r)}async subscribeResource(t,r){return this.request({method:"resources/subscribe",params:t},Nr,r)}async unsubscribeResource(t,r){return this.request({method:"resources/unsubscribe",params:t},Nr,r)}async callTool(t,r=mr,n){if(this.isToolTaskRequired(t.name))throw new X(ne.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 X(ne.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 X(ne.InvalidParams,`Structured content does not match the tool's output schema: ${a.errorMessage}`)}catch(a){throw a instanceof X?a:new X(ne.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},Ha,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(t,r,n,s){const o=_v.safeParse(n);if(!o.success)throw new Error(`Invalid ${t} listChanged options: ${o.error.message}`);if(typeof n.onChanged!="function")throw new Error(`Invalid ${t} listChanged options: onChanged must be a function`);const{autoRefresh:a,debounceMs:i}=o.data,{onChanged:c}=n,l=async()=>{if(!a){c(null,null);return}try{const h=await s();c(null,h)}catch(h){const m=h instanceof Error?h:new Error(String(h));c(m,null)}},d=()=>{if(i){const h=this._listChangedDebounceTimers.get(t);h&&clearTimeout(h);const m=setTimeout(l,i);this._listChangedDebounceTimers.set(t,m)}else l()};this.setNotificationHandler(r,d)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}var Cc={};/*! - * content-type - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - */var Yl=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,sT=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,mh=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,oT=/\\([\u000b\u0020-\u00ff])/g,aT=/([\\"])/g,gh=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;Cc.format=iT;Cc.parse=cT;function iT(e){if(!e||typeof e!="object")throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!gh.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&&!sT.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(aT,"\\$1")+'"'}function dT(e){this.parameters=Object.create(null),this.type=e}function fT(e){if(e)try{return Cc.parse(e).type}catch{const t=(e.split(";",1)[0]??"").trim().toLowerCase();return t===""||e.slice(t.length).includes(",")?void 0:t}}function Qo(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function hT(e=fetch,t){return t?async(r,n)=>{const s={...t,...n,headers:n!=null&&n.headers?{...Qo(t.headers),...Qo(n.headers)}:t.headers};return e(r,s)}:e}let jc;jc=globalThis.crypto;async function pT(e){return(await jc).getRandomValues(new Uint8Array(e))}async function mT(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 gT(e),r=await _T(t);return{code_verifier:t,code_challenge:r}}const qe=z_().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:Ty.custom,message:"URL must be parseable",fatal:!0}),kp}).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"}),vT=Le({resource:P().url(),authorization_servers:V(qe).optional(),jwks_uri:P().url().optional(),scopes_supported:V(P()).optional(),bearer_methods_supported:V(P()).optional(),resource_signing_alg_values_supported:V(P()).optional(),resource_name:P().optional(),resource_documentation:P().optional(),resource_policy_uri:P().url().optional(),resource_tos_uri:P().url().optional(),tls_client_certificate_bound_access_tokens:me().optional(),authorization_details_types_supported:V(P()).optional(),dpop_signing_alg_values_supported:V(P()).optional(),dpop_bound_access_tokens_required:me().optional()}),_h=Le({issuer:P(),authorization_endpoint:qe,token_endpoint:qe,registration_endpoint:qe.optional(),scopes_supported:V(P()).optional(),response_types_supported:V(P()),response_modes_supported:V(P()).optional(),grant_types_supported:V(P()).optional(),token_endpoint_auth_methods_supported:V(P()).optional(),token_endpoint_auth_signing_alg_values_supported:V(P()).optional(),service_documentation:qe.optional(),revocation_endpoint:qe.optional(),revocation_endpoint_auth_methods_supported:V(P()).optional(),revocation_endpoint_auth_signing_alg_values_supported:V(P()).optional(),introspection_endpoint:P().optional(),introspection_endpoint_auth_methods_supported:V(P()).optional(),introspection_endpoint_auth_signing_alg_values_supported:V(P()).optional(),code_challenge_methods_supported:V(P()).optional(),client_id_metadata_document_supported:me().optional()}),$T=Le({issuer:P(),authorization_endpoint:qe,token_endpoint:qe,userinfo_endpoint:qe.optional(),jwks_uri:qe,registration_endpoint:qe.optional(),scopes_supported:V(P()).optional(),response_types_supported:V(P()),response_modes_supported:V(P()).optional(),grant_types_supported:V(P()).optional(),acr_values_supported:V(P()).optional(),subject_types_supported:V(P()),id_token_signing_alg_values_supported:V(P()),id_token_encryption_alg_values_supported:V(P()).optional(),id_token_encryption_enc_values_supported:V(P()).optional(),userinfo_signing_alg_values_supported:V(P()).optional(),userinfo_encryption_alg_values_supported:V(P()).optional(),userinfo_encryption_enc_values_supported:V(P()).optional(),request_object_signing_alg_values_supported:V(P()).optional(),request_object_encryption_alg_values_supported:V(P()).optional(),request_object_encryption_enc_values_supported:V(P()).optional(),token_endpoint_auth_methods_supported:V(P()).optional(),token_endpoint_auth_signing_alg_values_supported:V(P()).optional(),display_values_supported:V(P()).optional(),claim_types_supported:V(P()).optional(),claims_supported:V(P()).optional(),service_documentation:P().optional(),claims_locales_supported:V(P()).optional(),ui_locales_supported:V(P()).optional(),claims_parameter_supported:me().optional(),request_parameter_supported:me().optional(),request_uri_parameter_supported:me().optional(),require_request_uri_registration:me().optional(),op_policy_uri:qe.optional(),op_tos_uri:qe.optional(),client_id_metadata_document_supported:me().optional()}),wT=I({...$T.shape,..._h.pick({code_challenge_methods_supported:!0}).shape}),bT=I({access_token:P(),id_token:P().optional(),token_type:P(),expires_in:Cy().optional(),scope:P().optional(),refresh_token:P().optional()}).strip(),ST=I({error:P(),error_description:P().optional(),error_uri:P().optional()}),Xl=qe.optional().or(j("").transform(()=>{})),ET=I({redirect_uris:V(qe),token_endpoint_auth_method:P().optional(),grant_types:V(P()).optional(),response_types:V(P()).optional(),client_name:P().optional(),client_uri:qe.optional(),logo_uri:Xl,scope:P().optional(),contacts:V(P()).optional(),tos_uri:Xl,policy_uri:P().optional(),jwks_uri:qe.optional(),jwks:va().optional(),software_id:P().optional(),software_version:P().optional(),software_statement:P().optional()}).strip(),kT=I({client_id:P(),client_secret:P().optional(),client_id_issued_at:ie().optional(),client_secret_expires_at:ie().optional()}).strip(),PT=ET.merge(kT);I({error:P(),error_description:P().optional()}).strip();I({token:P(),token_type_hint:P().optional()}).strip();function RT(e){const t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function TT({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 UT(e,t,r,n){const s=new URL(e),o=(n==null?void 0:n.protocolVersion)??Ls;let a;if(n!=null&&n.metadataUrl)a=new URL(n.metadataUrl);else{const c=DT(t,s.pathname);a=new URL(c,(n==null?void 0:n.metadataServerUrl)??s),a.search=s.search}let i=await tu(a,o,r);if(!(n!=null&&n.metadataUrl)&&qT(i,s.pathname)){const c=new URL(`/.well-known/${t}`,s);i=await tu(c,o,r)}return i}function FT(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 $h(e,{fetchFn:t=fetch,protocolVersion:r=Ls}={}){var o;const n={"MCP-Protocol-Version":r,Accept:"application/json"},s=FT(e);for(const{url:a,type:i}of s){const c=await Nc(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"?_h.parse(await c.json()):wT.parse(await c.json())}}}async function LT(e,t){let r,n;try{r=await vh(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 $h(n,{fetchFn:t==null?void 0:t.fetchFn});return{authorizationServerUrl:n,authorizationServerMetadata:s,resourceMetadata:r}}async function VT(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(vo))throw new Error(`Incompatible auth server: does not support response type ${vo}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes($o))throw new Error(`Incompatible auth server: does not support code challenge method ${$o}`)}else i=new URL("/authorize",e);const c=await yT(),l=c.code_verifier,d=c.code_challenge;return i.searchParams.set("response_type",vo),i.searchParams.set("client_id",r.client_id),i.searchParams.set("code_challenge",d),i.searchParams.set("code_challenge_method",$o),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 HT(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}async function wh(e,{metadata:t,tokenRequestParams:r,clientInformation:n,addClientAuthentication:s,resource:o,fetchFn:a}){const i=t!=null&&t.token_endpoint?new URL(t.token_endpoint):new URL("/token",e),c=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(o&&r.set("resource",o.href),s)await s(c,r,i,t);else if(n){const d=(t==null?void 0:t.token_endpoint_auth_methods_supported)??[],h=NT(n,d);IT(h,n,c,r)}const l=await(a??fetch)(i,{method:"POST",headers:c,body:r});if(!l.ok)throw await yh(l);return bT.parse(await l.json())}async function ZT(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 wh(e,{metadata:t,tokenRequestParams:i,clientInformation:r,addClientAuthentication:o,resource:s,fetchFn:a});return{refresh_token:n,...c}}async function KT(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=HT(s,l,e.redirectUrl)}const c=await e.clientInformation();return wh(t,{metadata:r,tokenRequestParams:i,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:n,fetchFn:o})}async function GT(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 yh(a);return PT.parse(await a.json())}class So 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 ru=10,WT=13,or=32;function Eo(e){}function BT(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=Eo,onError:r=Eo,onRetry:n=Eo,onComment:s,maxBufferSize:o}=e,a=[];let i=0,c=!0,l,d="",h=0,m,_=!1;function v(R){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,R.charCodeAt(0)===239&&R.charCodeAt(1)===187&&R.charCodeAt(2)===191&&(R=R.slice(3))),a.length===0){const U=g(R);U!==""&&(a.push(U),i=U.length),y();return}if(R.indexOf(` -`)===-1&&R.indexOf("\r")===-1){a.push(R),i+=R.length,y();return}a.push(R);const O=a.join("");a.length=0,i=0;const x=g(O);x!==""&&(a.push(x),i=x.length),y()}function y(){o!==void 0&&(i+d.length<=o||(_=!0,a.length=0,i=0,l=void 0,d="",h=0,m=void 0,r(new So(`Buffered data exceeded max buffer size of ${o} characters`,{type:"max-buffer-size-exceeded"}))))}function g(R){let O=0;if(R.indexOf("\r")===-1){let x=R.indexOf(` -`,O);for(;x!==-1;){if(O===x){h>0&&t({id:l,event:m,data:d}),l=void 0,d="",h=0,m=void 0,O=x+1,x=R.indexOf(` -`,O);continue}const U=R.charCodeAt(O);if(nu(R,O,U)){const D=R.charCodeAt(O+5)===or?O+6:O+5,q=R.slice(D,x);if(h===0&&R.charCodeAt(x+1)===ru){t({id:l,event:m,data:q}),l=void 0,d="",m=void 0,O=x+2,x=R.indexOf(` -`,O);continue}d=h===0?q:`${d} -${q}`,h++}else su(R,O,U)?m=R.slice(R.charCodeAt(O+6)===or?O+7:O+6,x)||void 0:f(R,O,x);O=x+1,x=R.indexOf(` -`,O)}return R.slice(O)}for(;O20?`${R.slice(0,20)}…`:R}"`,{type:"unknown-field",field:R,value:O,line:x}));break}}function E(){h>0&&t({id:l,event:m,data:d}),l=void 0,d="",h=0,m=void 0}function T(R={}){if(R.consume&&a.length>0){const O=a.join("");f(O,0,O.length)}c=!0,l=void 0,d="",h=0,m=void 0,a.length=0,i=0,_=!1}return{feed:v,reset:T}}function nu(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 su(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 JT extends TransformStream{constructor({onError:t,onRetry:r,onComment:n,maxBufferSize:s}={}){let o;super({start(a){o=BT({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 QT={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Tr extends Error{constructor(t,r){super(`Streamable HTTP error: ${r}`),this.code=t}}class YT{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=hT(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)??QT}async _authThenStart(){var r;if(!this._authProvider)throw new Rr("No auth provider");let t;try{t=await rs(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 Rr;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=Qo((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 Tr(i.status,`Failed to open SSE stream: ${i.statusText}`)}this._handleSseStream(i.body,t,!0)}catch(a){throw(o=this.onerror)==null||o.call(this,a),a}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const r=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,s=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(n,t),s)}_scheduleReconnection(t,r=0){var o;const n=this._reconnectionOptions.maxRetries;if(r>=n){(o=this.onerror)==null||o.call(this,new Error(`Maximum reconnection attempts (${n}) exceeded.`));return}const s=this._getNextReconnectionDelay(r);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(a=>{var i;(i=this.onerror)==null||i.call(this,new Error(`Failed to reconnect SSE stream: ${a instanceof Error?a.message:String(a)}`)),this._scheduleReconnection(t,r+1)})},s)}_handleSseStream(t,r,n){if(!t)return;const{onresumptiontoken:s,replayMessageId:o}=r;let a,i=!1,c=!1;(async()=>{var d,h,m,_;try{const v=t.pipeThrough(new TextDecoderStream).pipeThrough(new JT({onRetry:f=>{this._serverRetryMs=f}})).getReader();for(;;){const{value:f,done:$}=await v.read();if($)break;if(f.id&&(a=f.id,i=!0,s==null||s(f.id)),!!f.data&&(!f.event||f.event==="message"))try{const E=ss.parse(JSON.parse(f.data));sn(E)&&(c=!0,o!==void 0&&(E.id=o)),(d=this.onmessage)==null||d.call(this,E)}catch(E){(h=this.onerror)==null||h.call(this,E)}}(n||i)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:a,onresumptiontoken:s,replayMessageId:o},0)}catch(v){if((m=this.onerror)==null||m.call(this,new Error(`SSE stream disconnected: ${v}`)),(n||i)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:a,onresumptiontoken:s,replayMessageId:o},0)}catch(f){(_=this.onerror)==null||_.call(this,new Error(`Failed to reconnect: ${f instanceof Error?f.message:String(f)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(t){if(!this._authProvider)throw new Rr("No auth provider");if(await rs(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Rr("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:No(t)?t.id:void 0}).catch(E=>{var T;return(T=this.onerror)==null?void 0:T.call(this,E)});return}const h=await this._commonHeaders();h.set("content-type","application/json"),h.set("accept","application/json, text/event-stream");const m={...this._requestInit,method:"POST",headers:h,body:JSON.stringify(t),signal:(n=this._abortController)==null?void 0:n.signal},_=await(this._fetch??fetch)(this._url,m),v=_.headers.get("mcp-session-id");if(v&&(this._sessionId=v),!_.ok){const E=await _.text().catch(()=>null);if(_.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Tr(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:T,scope:R}=eu(_);if(this._resourceMetadataUrl=T,this._scope=R,await rs(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Rr;return this._hasCompletedAuthFlow=!0,this.send(t)}if(_.status===403&&this._authProvider){const{resourceMetadataUrl:T,scope:R,error:O}=eu(_);if(O==="insufficient_scope"){const x=_.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===x)throw new Tr(403,"Server returned 403 after trying upscoping");if(R&&(this._scope=R),T&&(this._resourceMetadataUrl=T),this._lastUpscopingHeader=x??void 0,await rs(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new Rr;return this.send(t)}}throw new Tr(_.status,`Error POSTing to endpoint: ${E}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,_.status===202){await((s=_.body)==null?void 0:s.cancel()),Ky(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(E=>{var T;return(T=this.onerror)==null?void 0:T.call(this,E)});return}const g=(Array.isArray(t)?t:[t]).filter(E=>"method"in E&&"id"in E&&E.id!==void 0).length>0,f=_.headers.get("content-type"),$=fT(f);if(g)if($==="text/event-stream")this._handleSseStream(_.body,{onresumptiontoken:d},!1);else if($==="application/json"){const E=await _.json(),T=Array.isArray(E)?E.map(R=>ss.parse(R)):[ss.parse(E)];for(const R of T)(o=this.onmessage)==null||o.call(this,R)}else throw await((a=_.body)==null?void 0:a.cancel()),new Tr(-1,`Unexpected content type: ${f}`);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 Tr(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 XT="https://mcp.excalidraw.com/mcp",eC="mcp.excalidraw.com",tC="/api/v1/chat/mcp-apps/excalidraw",bh="ui://excalidraw/mcp-app.html",rC=["read_me","create_view"],Sh=new Set(["export_to_excalidraw","save_checkpoint","read_checkpoint"]),nC=256*1024,sC=1024*1024,oC=1024*1024,aC=240,iC=720,cC=525;function lC(e){return!Number.isFinite(e)||e<=0?cC:Math.max(aC,Math.min(iC,Math.round(e*3/4)))}const uC={excalidraw:{id:"excalidraw",endpoint:XT,hostname:eC,resourceUri:bh,modelTools:rC,appTools:Sh}};function dC(e){return uC[e]}function fC(){return new URL(It(tC),window.location.origin)}class hC{constructor(){se(this,"client",new nT({name:"pwc-chat-mcp-app-host",version:"1"}));se(this,"transport",new YT(fC(),{requestInit:{credentials:"include"}}));se(this,"connected");se(this,"bytes",0);se(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!==bh)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,oC);const s=await _C(n.text);return{text:n.text,digest:s}}async callTool(t,r){if(!Sh.has(t))throw new Error("Unapproved App tool");const n=JSON.stringify(r);this.consume(n);try{await this.connect();const s=await this.client.callTool({name:t,arguments:r});return this.consume(JSON.stringify(s)),s}catch(s){throw this.retire(),s}}close(){this.closed=!0,this.connected=void 0,this.transport.close()}retire(){this.close(),zt===this&&(zt=void 0)}consume(t,r=nC){const n=new TextEncoder().encode(t).byteLength;if(n>r||this.bytes+n>sC)throw new Error("App request exceeds host limit");this.bytes+=n}}let zt;function pC(){return zt??(zt=new hC),zt}function mC(){zt==null||zt.close(),zt=void 0}function gC(e){mC()}async function _C(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 yC(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 vC=({block:e})=>{const t=H.useRef(null),r=H.useRef(null),n=H.useRef(!1),s=H.useRef(e),o=H.useRef(!1);s.current=e;const[a,i]=H.useState(),[c,l]=H.useState("loading"),[d,h]=H.useState(e.height),[m,_]=H.useState(!1),[v,y]=H.useState(0),g=H.useRef(null),f=e.input.elements,$=!!e.permissions.clipboardWrite;o.current=m;const E=H.useCallback(()=>{_(!1),document.fullscreenElement&&document.exitFullscreen()},[]),T=H.useCallback(()=>{var x,U;if(m){E();return}_(!0),(U=(x=g.current)==null?void 0:x.requestFullscreen)==null||U.call(x).catch(()=>{})},[E,m]),R=H.useCallback(()=>{gC(),i(void 0),l("loading"),y(x=>x+1)},[]);H.useEffect(()=>{const x=g.current;if(!x)return;const U=()=>{o.current||h(lC(x.clientWidth))};U();const D=new ResizeObserver(U);return D.observe(x),()=>D.disconnect()},[]),H.useEffect(()=>{if(!m)return;const x=g.current,U=q=>{q.key==="Escape"&&(document.fullscreenElement||E())},D=()=>{document.fullscreenElement||_(!1)};return window.addEventListener("keydown",U),document.addEventListener("fullscreenchange",D),()=>{window.removeEventListener("keydown",U),document.removeEventListener("fullscreenchange",D),document.fullscreenElement===x&&document.exitFullscreen()}},[E,m]),H.useEffect(()=>{dC(e.provider);{l("unavailable");return}},[v,e.provider,e.resource_uri]),H.useEffect(()=>{if(!a||c!=="ready")return;const x=t.current;if(!x)return;let U=null;const D=[],q=yC(x,()=>{x.contentWindow&&(U=new E$(null,{name:"Papers with Code",version:"1"},{serverTools:{},openLinks:{},logging:{},...$?{clipboard:{write:{}}}:{}},{hostContext:{theme:document.documentElement.dataset.theme==="dark"?"dark":"light",displayMode:m?"fullscreen":"inline"}}),U.oncalltool=async({name:L,arguments:Z})=>{if(s.current.public_fork&&L!=="export_to_excalidraw")throw new Error("Shared diagrams cannot mutate owner state");return pC().callTool(L,Z??{})},U.onopenlink=async({url:L})=>{const Z=new URL(L);if(Z.protocol!=="https:"||Z.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(Z.href,"_blank","noopener,noreferrer"),{}},U.onsizechange=()=>{},U.oninitialized=()=>{n.current=!0;try{const L=JSON.parse(f),Z={arguments:{elements:Array.isArray(L)?O$(L):L}};for(const re of[0,50,200,750])D.push(window.setTimeout(()=>{r.current===U&&U.sendToolInput(Z)},re));U.sendToolResult(s.current.result)}catch{l("error")}},r.current=U,U.connect(new b$(x.contentWindow??void 0,x.contentWindow)).catch(()=>l("error")))});return()=>{q(),D.forEach(L=>window.clearTimeout(L)),n.current=!1,U==null||U.teardownResource({}).catch(()=>{}),r.current===U&&(r.current=null)}},[a,c,m,f,$,v]),H.useEffect(()=>{var x;c!=="ready"||!n.current||(x=r.current)==null||x.sendToolResult(e.result).catch(()=>{})},[e.result,c]);const O=c==="unavailable"||c==="incompatible"||c==="error";return b.jsxs("section",{ref:g,className:`chat-mcp-app${m?" chat-mcp-app-fullscreen":""}`,"aria-label":"Interactive Excalidraw diagram",children:[b.jsx("header",{children:b.jsx("button",{type:"button",onClick:T,children:m?"Exit fullscreen":"Fullscreen"})}),c==="loading"&&b.jsx("div",{className:"chat-mcp-loading",role:"status",children:"Loading interactive diagram…"}),O&&b.jsxs("div",{className:"chat-mcp-error",children:["Interactive diagram unavailable. The cited text answer is still available.",b.jsx("button",{type:"button",onClick:R,children:"Retry diagram"})]}),a&&c==="ready"&&b.jsx("iframe",{ref:t,title:"Interactive Excalidraw diagram",sandbox:"allow-scripts",allow:$?"clipboard-write":void 0,srcDoc:a,style:{height:d}},v)]})},Eh=()=>({open:!1,selectedKey:null,selected:null,selectedVersionId:null,tab:"preview",sourceFile:null,panelPercent:55,requestNonce:0,registry:{},autoOpened:{},manuallyClosed:{}});function $C(e,t){if(t.type==="reset")return{...Eh(),panelPercent:e.panelPercent};if(t.type==="register"){const r=e.registry[t.key];if(r&&JSON.stringify(r)===JSON.stringify(t.block))return e;const n={...e.registry,[t.key]:t.block},s=e.selectedKey===t.key?t.block:e.selected,o=(r==null?void 0:r.status)==="generating"&&t.block.status==="ready",a=t.autoOpenOnMount&&!r&&t.block.status==="ready"&&!Object.values(e.autoOpened).some(Boolean);return(o||a)&&!e.autoOpened[t.key]&&!e.manuallyClosed[t.key]?{...e,registry:n,open:!0,selectedKey:t.key,selected:t.block,selectedVersionId:t.block.version_id??null,tab:"preview",sourceFile:null,requestNonce:e.requestNonce+1,autoOpened:{...e.autoOpened,[t.key]:!0}}:{...e,registry:n,selected:s}}return t.type==="unregister"?e:t.type==="open"?{...e,open:!0,selectedKey:t.key,selected:t.block,selectedVersionId:t.block.version_id??null,tab:"preview",sourceFile:null,requestNonce:e.requestNonce+1,manuallyClosed:{...e.manuallyClosed,[t.key]:!1}}:t.type==="close"?{...e,open:!1,manuallyClosed:e.selectedKey?{...e.manuallyClosed,[e.selectedKey]:!0}:e.manuallyClosed}:t.type==="tab"?{...e,tab:t.tab}:t.type==="source"?{...e,sourceFile:t.path}:t.type==="version"?{...e,selectedVersionId:t.versionId,tab:"preview",sourceFile:null}:{...e,panelPercent:t.percent}}function ua(e){return e.publication_id||e.public_capability||e.version_id||`${e.scope}:${e.identifier}:${e.version??"pending"}`}const kh=H.createContext(null),oj=({children:e,workspaceKey:t,autoOpenOnMount:r=!1})=>{const[n,s]=H.useReducer($C,void 0,Eh),o=H.useRef(null),a=H.useRef(t);H.useEffect(()=>{a.current!==t&&(a.current=t,o.current=null,s({type:"reset"}))},[t]);const i=H.useCallback(()=>{s({type:"close"}),window.setTimeout(()=>{var f;return(f=o.current)==null?void 0:f.focus()},0)},[]),c=H.useCallback(f=>s({type:"register",key:ua(f),block:f,autoOpenOnMount:r}),[r]),l=H.useCallback(f=>s({type:"unregister",key:f}),[]),d=H.useCallback((f,$)=>{o.current=$??null,s({type:"open",key:ua(f),block:f})},[]),h=H.useCallback(f=>s({type:"tab",tab:f}),[]),m=H.useCallback(f=>s({type:"source",path:f}),[]),_=H.useCallback(f=>s({type:"version",versionId:f}),[]),v=H.useCallback(f=>s({type:"width",percent:f}),[]),y=H.useCallback(()=>s({type:"reset"}),[]),g=H.useMemo(()=>({state:n,autoOpenOnMount:r,register:c,unregister:l,open:d,close:i,setTab:h,setSourceFile:m,setVersion:_,setPanelPercent:v,reset:y}),[r,i,d,c,y,v,m,h,_,n,l]);return b.jsx(kh.Provider,{value:g,children:e})};function Ic(){const e=H.useContext(kh);if(!e)throw new Error("Poster artifacts require an ArtifactPanelProvider");return e}const wC="https://github.com/Chenruishuo/posterly/tree/b9f42e5578a49a27525a68f85376bb3bb25af86f";function bC(){if(typeof window>"u")return null;const e=window.location.pathname.match(/^\/share\/([^/]+)/u);return e?decodeURIComponent(e[1]):null}function Ph(e){if(e.scope==="public"){const n=bC();if(!n||!e.public_capability)return null;const s=`/api/v1/chat/shares/${encodeURIComponent(n)}/artifacts/${encodeURIComponent(e.public_capability)}`;return{preview:It(`${s}/preview`),png:It(`${s}/download/png`),pdf:It(`${s}/download/pdf`),manifest:null,source:null,gate:null,download:null}}if(!e.artifact_id||!e.version_id)return null;const t=`/api/v1/chat/artifacts/${encodeURIComponent(e.artifact_id)}/versions/${encodeURIComponent(e.version_id)}`,r=(n,s)=>It(`${t}/${n}/${s.split("/").map(encodeURIComponent).join("/")}`);return{preview:It(`${t}/preview`),png:r("download","poster.png"),pdf:null,manifest:It(`${t}/manifest`),source:n=>r("source",n),gate:n=>r("source",n),download:n=>r("download",n)}}const Rh=e=>({passed:"Passed",warnings:"Passed with warnings",failed:"Draft—checks failed"})[e??"passed"];function SC(){const[e,t]=H.useState(()=>{var r;return typeof window<"u"&&((r=window.matchMedia)==null?void 0:r.call(window,"(max-width: 760px)").matches)});return H.useEffect(()=>{var s,o;const r=(s=window.matchMedia)==null?void 0:s.call(window,"(max-width: 760px)");if(!r)return;const n=()=>t(r.matches);return n(),(o=r.addEventListener)==null||o.call(r,"change",n),()=>{var a;return(a=r.removeEventListener)==null?void 0:a.call(r,"change",n)}},[]),e}const ou=({forceDialog:e=!1,readerFallback:t=!1})=>{var R,O,x,U;const r=Ic(),n=r.close,{state:s}=r,o=s.selected,a=SC(),i=e||a,c=H.useRef(null),l=H.useRef(!1),d=ns({queryKey:["chat-artifact-versions",o==null?void 0:o.artifact_id],queryFn:async()=>{const D=await fetch(It(`/api/v1/chat/artifacts/${encodeURIComponent(o.artifact_id)}`),{credentials:"include",cache:"no-store"});if(!D.ok)throw new Error("Could not load poster versions");return(await D.json()).versions},enabled:s.open&&(o==null?void 0:o.scope)==="owner"&&!!o.artifact_id,staleTime:Number.POSITIVE_INFINITY}),h=(R=d.data)==null?void 0:R.find(D=>D.version_id===s.selectedVersionId),m=o&&h?{...o,version_id:h.version_id,version:h.version,gate_status:h.gate_status,total_bytes:h.total_bytes}:o,_=m?Ph(m):null,y=ns({queryKey:["chat-artifact-manifest",m==null?void 0:m.version_id],queryFn:async()=>{const D=await fetch(_.manifest,{credentials:"include",cache:"no-store"});if(!D.ok)throw new Error("Could not load poster details");return D.json()},enabled:s.open&&(m==null?void 0:m.scope)==="owner"&&!!(_!=null&&_.manifest),staleTime:Number.POSITIVE_INFINITY}).data,g=s.sourceFile??(y==null?void 0:y.entrypoint)??null,f=ns({queryKey:["chat-artifact-source",m==null?void 0:m.version_id,g],queryFn:async()=>{const D=await fetch(_.source(g),{credentials:"include",cache:"no-store"});if(!D.ok)throw new Error("Source could not be loaded");return D.text()},enabled:s.open&&s.tab==="source"&&(m==null?void 0:m.scope)==="owner"&&!!(g&&(_!=null&&_.source)),staleTime:Number.POSITIVE_INFINITY});if(H.useEffect(()=>{var q,L;if(!s.open||!i)return;(L=(q=c.current)==null?void 0:q.querySelector("[data-artifact-close]"))==null||L.focus(),window.history.pushState({...window.history.state,pwcArtifactPanel:!0},""),l.current=!0;const D=()=>{l.current=!1,n()};return window.addEventListener("popstate",D),()=>window.removeEventListener("popstate",D)},[n,i,s.open]),H.useEffect(()=>{if(!s.open||!i)return;const D=q=>{if(q.key==="Escape"){q.preventDefault(),n(),l.current&&(l.current=!1,window.history.back());return}if(q.key!=="Tab"||!c.current)return;const L=[...c.current.querySelectorAll('button:not([disabled]), a[href], select:not([disabled]), [tabindex]:not([tabindex="-1"])')];if(!L.length)return;const Z=L[0],re=L.at(-1);q.shiftKey&&document.activeElement===Z?(q.preventDefault(),re.focus()):!q.shiftKey&&document.activeElement===re&&(q.preventDefault(),Z.focus())};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[n,i,s.open]),!s.open||!m||!_)return null;const $=()=>{n(),i&&l.current&&(l.current=!1,window.history.back())},E=(O=y==null?void 0:y.downloads[0])==null?void 0:O.path,T=m.scope==="public"?_.pdf:E&&_.download?_.download(E):null;return b.jsxs("section",{ref:c,className:`chat-artifact-panel${i?" is-dialog":" is-docked"}${t?" is-reader-fallback":""}`,role:i?"dialog":"complementary","aria-modal":i?!0:void 0,"aria-label":m.title,"data-testid":"artifact-panel",children:[b.jsxs("header",{children:[b.jsxs("div",{children:[b.jsx("span",{children:"Posterly artifact"}),b.jsx("h2",{children:m.title})]}),(((x=d.data)==null?void 0:x.length)??0)>1&&b.jsxs("label",{className:"chat-artifact-version",children:["Version",b.jsx("select",{"aria-label":"Poster version",value:m.version_id,onChange:D=>r.setVersion(D.target.value),children:[...d.data??[]].reverse().map(D=>b.jsxs("option",{value:D.version_id,children:["v",D.version]},D.version_id))})]}),b.jsx("button",{type:"button","data-artifact-close":!0,"aria-label":i?"Back to conversation":"Close poster",onClick:$,children:b.jsx(Ih,{})})]}),b.jsxs("nav",{"aria-label":"Poster views",children:[b.jsx("button",{type:"button","aria-pressed":s.tab==="preview",className:s.tab==="preview"?"active":"",onClick:()=>r.setTab("preview"),children:"Preview"}),m.scope==="owner"&&b.jsx("button",{type:"button","aria-pressed":s.tab==="source",className:s.tab==="source"?"active":"",onClick:()=>r.setTab("source"),children:"Source"})]}),b.jsx("div",{className:"chat-artifact-panel-body",children:s.tab==="preview"?b.jsx("img",{src:_.preview,alt:`Full preview of ${m.title}`}):b.jsxs("div",{className:"chat-artifact-source-workspace",children:[(((U=y==null?void 0:y.source_files)==null?void 0:U.length)??0)>1&&b.jsx("nav",{"aria-label":"Poster source files",children:y.source_files.map(D=>b.jsx("button",{type:"button","aria-pressed":g===D,onClick:()=>r.setSourceFile(D),children:D},D))}),b.jsx("pre",{children:b.jsx("code",{children:f.isError?"Source could not be loaded.":f.data??"Loading source…"})})]})}),b.jsxs("footer",{children:[b.jsxs("div",{className:"chat-artifact-metadata",children:[b.jsx("strong",{children:Rh(m.gate_status)}),y&&b.jsxs("span",{children:[y.canvas.width," × ",y.canvas.height," ",y.canvas.unit," · ",y.canvas.orientation," · ",y.direction]}),y==null?void 0:y.gate_summary.map(D=>b.jsx("span",{children:D},D))]}),b.jsxs("div",{className:"chat-artifact-actions",children:[b.jsxs("a",{href:_.png,download:!0,children:[b.jsx(xc,{})," PNG"]}),m.gate_status!=="failed"&&T&&b.jsxs("a",{href:T,download:!0,children:[b.jsx(xc,{})," PDF"]}),m.scope==="owner"&&y&&_.source&&b.jsxs("a",{href:_.source(y.entrypoint),download:!0,children:[b.jsx(fu,{})," HTML"]}),m.scope==="owner"&&y&&_.gate&&b.jsx("a",{href:_.gate(y.gate_report),download:!0,children:"Gate report"}),b.jsxs("a",{href:wC,target:"_blank",rel:"noreferrer",children:[b.jsx(Bh,{})," Posterly source · AGPL-3.0"]})]})]})]})},EC=({block:e})=>{const t=Ic(),r=t.register,n=t.unregister,s=ua(e);if(H.useEffect(()=>{r(e)},[e,r]),H.useEffect(()=>()=>n(s),[s,n]),e.status==="generating")return b.jsxs("div",{className:"chat-artifact-card chat-artifact-generating",role:"status",children:[b.jsx("span",{className:"chat-artifact-pulse","aria-hidden":"true"}),b.jsxs("span",{children:[b.jsx("strong",{children:e.title}),b.jsx("small",{children:"Publishing Posterly preview…"})]})]});if(e.status==="error")return b.jsxs("div",{className:"chat-artifact-card chat-artifact-error",role:"alert",children:[b.jsx(fu,{"aria-hidden":"true"}),b.jsxs("span",{children:[b.jsx("strong",{children:e.title}),b.jsx("small",{children:e.error_message??"Poster publication failed."})]})]});const o=Ph(e);if(!o)return null;const a=t.state.open&&t.state.selectedKey===s;return b.jsxs("button",{type:"button",className:`chat-artifact-card${a?" is-selected":""}`,"aria-pressed":a,onClick:i=>t.open(e,i.currentTarget),children:[b.jsx("img",{src:o.preview,alt:`Preview of ${e.title}`}),b.jsxs("span",{className:"chat-artifact-card-copy",children:[b.jsxs("span",{className:"chat-artifact-kicker",children:[b.jsx(Qh,{"aria-hidden":"true"})," Posterly · v",e.version]}),b.jsx("strong",{children:e.title}),b.jsx("small",{className:`chat-artifact-gate chat-artifact-gate-${e.gate_status}`,children:Rh(e.gate_status)})]})]})};function kC(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 PC(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 RC(e,t=240){const r=e.content.trim();return r.length<=t?r:`${r.slice(0,t).trimEnd()}…`}const TC="https://huggingface.co/pro",CC="https://huggingface.co/docs/inference-providers/pricing",jC="https://paperswithcode.co/chat",Th=()=>b.jsx("span",{className:"chat-caret"}),NC=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},IC=e=>{var _,v;const t=e.currentTarget,r=t.ownerDocument,n=(_=r.caretPositionFromPoint)==null?void 0:_.call(r,e.clientX,e.clientY),s=n?null:(v=r.caretRangeFromPoint)==null?void 0:v.call(r,e.clientX,e.clientY),o=(n==null?void 0:n.offsetNode)??(s==null?void 0:s.startContainer),a=(n==null?void 0:n.offset)??(s==null?void 0:s.startOffset);if(!(o instanceof Text)||a===void 0||!t.contains(o))return;const i=o.data,c=/[\p{L}\p{M}\p{N}_'-]/u;let l=Math.min(a,i.length),d=l;for(;l>0&&c.test(i[l-1]);)l-=1;for(;d{const r=[];let n=0;for(const s of[...t].sort((o,a)=>o.start-a.start)){const o=e.slice(s.start,s.end);s.starte.length||o!==s.title&&o!==`@${s.title}`||(r.push(e.slice(n,s.start)),r.push(b.jsxs("span",{className:"chat-inline-paper-mention",children:[b.jsx(Wh,{size:13,"aria-hidden":"true"}),b.jsx(du,{routeId:s.route_id,className:"chat-inline-paper-link",children:o.startsWith("@")?o.slice(1):o})]},s.key)),n=s.end)}return r.push(e.slice(n)),b.jsx(b.Fragment,{children:r})},xC=({block:e,papers:t,citations:r,webCitations:n,onToggle:s})=>e.active?b.jsxs("div",{className:"chat-reason-live",children:[b.jsxs("div",{className:"chat-reason-live-head",children:[b.jsx(da,{})," ",b.jsx("span",{children:"Thinking…"})]}),b.jsxs("div",{className:"chat-reason-live-body chat-answer chat-reason-markdown",children:[b.jsx(ko,{text:e.text,streaming:!0,papers:t,citations:r,webCitations:n}),b.jsx(Th,{})]})]}):b.jsxs("div",{className:"chat-reason-done",children:[b.jsxs("button",{type:"button",className:"chat-reason-done-head",onClick:s,"aria-expanded":e.open,children:[b.jsx(qh,{}),b.jsx("span",{children:"Thought for a few seconds"}),b.jsx(uu,{open:e.open})]}),e.open&&b.jsx("div",{className:"chat-reason-done-body chat-answer chat-reason-markdown",children:b.jsx(ko,{text:e.text,papers:t,citations:r,webCitations:n})})]}),AC=({block:e,papers:t,onToggle:r})=>{var h,m,_,v;const n=e.status==="running",s=n&&e.argumentState==="streaming",o=e.schema_version===2||!!e.content,a=e.status==="error"||e.status==="denied",i=typeof e.args.query=="string"?e.args.query:"",c=typeof e.args.command=="string"?e.args.command:typeof e.args.file_path=="string"?e.args.file_path:i,l=((h=e.content)==null?void 0:h.map(y=>y.text).join(""))??"",d=s?"streaming arguments…":n?"running…":o?`${e.status} · ${e.took_ms??0} ms`:`${e.hits} results · ${e.took_ms} ms`;return b.jsxs("div",{className:`chat-tool${n?" chat-tool-running":""}${a?" chat-tool-failed":""}`,children:[b.jsxs("button",{type:"button",className:"chat-tool-head",onClick:r,"aria-expanded":e.open,children:[b.jsxs("span",{className:"chat-tool-head-left",children:[n?b.jsx(da,{}):b.jsx(Uh,{}),b.jsx("code",{className:"chat-tool-name",children:e.name}),b.jsx("span",{className:"chat-tool-query",children:o?c:`("${i}")`})]}),b.jsxs("span",{className:"chat-tool-head-right",children:[b.jsx("span",{className:"chat-tool-status",children:d}),b.jsx(uu,{open:e.open})]})]}),e.open&&b.jsxs("div",{className:"chat-tool-body",children:[b.jsxs("div",{className:"chat-tool-args",children:[b.jsxs("span",{className:"chat-tool-label",children:["arguments",e.arguments_redacted?" · redacted":""]}),b.jsx("pre",{children:e.argumentState==="streaming"&&!e.arguments_redacted&&e.argumentText||JSON.stringify(e.args,null,2)})]}),!n&&o?b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"chat-tool-output-head",children:[b.jsx("span",{className:"chat-tool-label",children:"result"}),b.jsx("button",{type:"button",className:"chat-tool-copy",onClick:()=>void navigator.clipboard.writeText(l),children:"Copy"})]}),b.jsx("pre",{className:"chat-tool-output",children:b.jsx("code",{children:l})}),((m=e.metadata)==null?void 0:m.output_truncated)&&b.jsx("div",{className:"chat-tool-truncated",children:"Output was truncated."})]}):n?null:b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"chat-tool-label chat-tool-results-label",children:["returned ",((_=e.results)==null?void 0:_.length)??0," papers"]}),b.jsx("ol",{className:"chat-tool-results",children:(v=e.results)==null?void 0:v.map(y=>b.jsxs("li",{className:"chat-hit",children:[b.jsx("div",{className:"chat-hit-top",children:b.jsx(pu,{routeId:y.route_id,paper:t[y.route_id],className:"chat-hit-title",children:y.title})}),b.jsx("div",{className:"chat-hit-meta",children:[kC(y.metadata),PC(y.metadata)].filter(Boolean).join(" · ")}),b.jsxs("div",{className:"chat-hit-snippet",children:[RC(y),y.content_truncated&&b.jsx("span",{className:"chat-hit-truncated",children:" (truncated)"})]})]},y.route_id))})]})]})]})},MC=({block:e,papers:t,citations:r,webCitations:n,streaming:s})=>b.jsxs("div",{className:"chat-answer",children:[b.jsx(ko,{text:e.text,streaming:s,papers:t,citations:r,webCitations:n}),s&&!!e.text.trim()&&b.jsx(Th,{})]}),zC=({block:e})=>b.jsx(vC,{block:e}),Ch=e=>{const t=H.useRef(null),r=H.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 H.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}},DC=({id:e,text:t,paperSelection:r,editNotice:n,onCancel:s,onResend:o,onResendDraft:a})=>{const[i,c]=H.useState(t),[l,d]=H.useState(r),[h,m]=H.useState(!1),{textareaRef:_,resize:v}=Ch(t);H.useLayoutEffect(v,[v,i]);const y=!!i.trim()&&i.length<=8e3,g=()=>{if(!y||h)return;m(!0),((a==null?void 0:a({text:i,paperMentions:[],...l?{paperSelection:l}:{}}))??(o==null?void 0:o(i))??!1)||m(!1)};return b.jsx("div",{className:"chat-msg chat-msg-user chat-msg-user-editing","data-message-id":e,children:b.jsxs("div",{className:"chat-inline-editor",children:[l&&b.jsx(Ds,{selection:l,editable:!0,onRemove:()=>d(void 0)}),b.jsx("textarea",{ref:_,className:"chat-inline-editor-textarea","aria-label":"Edit message",value:i,maxLength:8e3,onChange:f=>c(f.target.value),onKeyDown:f=>{f.key==="Escape"?(f.preventDefault(),s==null||s()):f.key==="Enter"&&!f.shiftKey&&!f.nativeEvent.isComposing&&(f.preventDefault(),g())}}),n&&b.jsx("div",{className:"chat-inline-editor-notice",children:n}),b.jsxs("div",{className:"chat-inline-editor-actions",children:[b.jsx("button",{type:"button",onClick:s,children:"Cancel"}),b.jsx("button",{type:"button",className:"chat-inline-editor-send",disabled:!y||h,onClick:g,children:"Send"})]})]})})},qC=({id:e,text:t,paperMentions:r,paperSelection:n,enabled:s,editNotice:o,onCancel:a,onResend:i,onResendDraft:c})=>{const[l,d]=H.useState({text:t,paperMentions:r,...n?{paperSelection:n}:{}}),[h,m]=H.useState(!1),[_,v]=H.useState(0),{textareaRef:y,resize:g}=Ch(t),f=iu({draft:l,onChange:d,enabled:s,textareaRef:y});H.useLayoutEffect(g,[g,l.text]);const $=!!l.text.trim()&&l.text.length<=8e3&&(s||l.paperMentions.length===0),E=()=>{if(!$||h)return;m(!0),((c==null?void 0:c(l))??(i==null?void 0:i(l.text))??!1)||m(!1)};return b.jsx("div",{className:"chat-msg chat-msg-user chat-msg-user-editing","data-message-id":e,children:b.jsxs("div",{className:"chat-inline-editor",children:[l.paperSelection&&b.jsx(Ds,{selection:l.paperSelection,editable:!0,onRemove:()=>d({text:l.text,paperMentions:l.paperMentions})}),b.jsxs("div",{className:"chat-inline-editor-textarea-wrap",children:[b.jsx(cu,{text:l.text,mentions:l.paperMentions,scrollTop:_,variant:"editor"}),b.jsx("textarea",{ref:y,className:"chat-inline-editor-textarea","aria-label":"Edit message",value:l.text,maxLength:8e3,role:"combobox","aria-autocomplete":"list","aria-expanded":f.open,"aria-controls":f.open?f.pickerId:void 0,"aria-activedescendant":f.open&&f.results.length?`${f.optionIdPrefix}-${f.activeIndex}`:void 0,onChange:T=>f.updateText(T.target.value,T.target.selectionStart),onSelect:T=>f.refresh(T.currentTarget.selectionStart),onScroll:T=>v(T.currentTarget.scrollTop),onKeyDown:T=>{f.keyDown(T)||(T.key==="Escape"?(T.preventDefault(),a==null||a()):T.key==="Enter"&&!T.shiftKey&&!T.nativeEvent.isComposing&&(T.preventDefault(),E()))}}),b.jsx(lu,{open:f.open,query:f.query,results:f.results,activeIndex:f.activeIndex,loading:f.loading,error:f.error,onSelect:f.select,id:f.pickerId,optionIdPrefix:f.optionIdPrefix})]}),!s&&l.paperMentions.length>0&&b.jsx("div",{className:"chat-inline-editor-notice",role:"status",children:"Paper mentions are currently disabled. Remove them before sending."}),o&&b.jsx("div",{className:"chat-inline-editor-notice",children:o}),b.jsxs("div",{className:"chat-inline-editor-actions",children:[b.jsx("button",{type:"button",onClick:a,children:"Cancel"}),b.jsx("button",{type:"button",className:"chat-inline-editor-send",disabled:!$||h,onClick:E,children:"Send"})]})]})})},aj=({id:e,text:t,paperMentions:r=[],paperSelection:n,paperMentionsEnabled:s=!1,editingAllowed:o=!1,editing:a=!1,editNotice:i,onEdit:c,onCancel:l,onResend:d,onResendDraft:h})=>{const[m,_]=H.useState(!1),v=H.useRef(null);H.useEffect(()=>()=>{v.current!==null&&window.clearTimeout(v.current)},[]);const y=async()=>{var g;if((g=navigator.clipboard)!=null&&g.writeText)try{await navigator.clipboard.writeText(t),_(!0),v.current!==null&&window.clearTimeout(v.current),v.current=window.setTimeout(()=>_(!1),1500)}catch{}};return a?!s&&r.length===0?b.jsx(DC,{id:e,text:t,paperSelection:n,editNotice:i,onCancel:l,onResend:d,onResendDraft:h}):b.jsx(qC,{id:e,text:t,paperMentions:r,paperSelection:n,enabled:s,editNotice:i,onCancel:l,onResend:d,onResendDraft:h}):b.jsx("div",{className:"chat-msg chat-msg-user","data-message-id":e,children:b.jsxs("div",{className:"chat-user-message-wrap",children:[n&&b.jsx(Ds,{selection:n}),b.jsx("div",{className:"chat-bubble",onDoubleClick:IC,children:b.jsx(OC,{text:t,mentions:r})}),b.jsxs("div",{className:"chat-user-actions",children:[b.jsx("button",{type:"button",className:"chat-user-action","aria-label":m?"Message copied":"Copy message",title:m?"Copied":"Copy",onClick:()=>void y(),children:m?b.jsx(Oh,{"aria-hidden":"true"}):b.jsx(Jh,{"aria-hidden":"true"})}),o&&b.jsx("button",{type:"button",className:"chat-user-action","aria-label":"Edit message",title:"Edit",onClick:c,children:b.jsx(Yh,{"aria-hidden":"true"})})]})]})})},ij=({msg:e,papers:t,onToggleBlock:r,onArchiveOldChats:n,onArchiveOldestChats:s,archivePending:o=null,hfBilling:a=null,openRouterFallbackEnabled:i=!1,feedbackEnabled:c=!1})=>{var x,U,D;const[l,d]=H.useState(null),[h,m]=H.useState(!1),[_,v]=H.useState(!1),[y,g]=H.useState(!1),[f,$]=H.useState(""),E=H.useRef(null),T=`chat-feedback-panel-${e.id}`,R=c&&!e.streaming&&!e.error&&!!((x=e.blocks)!=null&&x.some(q=>q.kind==="answer"&&q.text.trim()));H.useEffect(()=>{var q;y&&((q=E.current)==null||q.focus())},[y]);const O=async(q,L)=>{if(!h){m(!0),v(!1);try{L===void 0?await Oc.reportFeedback(e.id,q):await Oc.reportFeedback(e.id,q,L),d(q),g(!1),$("")}catch{v(!0)}finally{m(!1)}}};return b.jsx("div",{className:"chat-msg chat-msg-assistant",children:b.jsxs("div",{className:"chat-msg-blocks",children:[(U=e.blocks)==null?void 0:U.map((q,L)=>{var Ce;const Z=`${e.id}-${L}`,re="citations"in q&&q.citations!==void 0?q.citations:e.citations??[],F=Object.fromEntries(re.filter(_e=>(_e.kind==="catalog_paper"||_e.kind==="paper"||!_e.kind&&_e.route_id)&&_e.route_id).map(_e=>[_e.route_id,_e])),le=Object.fromEntries(re.filter(_e=>(_e.kind==="external_source"||_e.kind==="web")&&_e.url).map(_e=>[_e.url,_e]));return q.kind==="reasoning"?b.jsx(xC,{block:q,papers:t,citations:F,webCitations:le,onToggle:()=>r(e.id,L)},Z):q.kind==="tool"?b.jsx(AC,{block:q,papers:t,onToggle:()=>r(e.id,L)},Z):q.kind==="app"?b.jsx(zC,{block:q},q.instance_id||Z):q.kind==="artifact"?b.jsx(EC,{block:q},q.publication_id||q.version_id||Z):b.jsx(MC,{block:q,papers:t,citations:F,webCitations:le,streaming:!!(e.streaming&&L===(((Ce=e.blocks)==null?void 0:Ce.length)??0)-1)},Z)}),NC(e)&&b.jsx("div",{className:"chat-waiting",role:"status","aria-live":"polite",children:b.jsx("span",{className:"chat-thinking",children:(((D=e.blocks)==null?void 0:D.length)??0)===0?e.status??"Thinking…":"Thinking…"})}),e.error&&b.jsxs("div",{className:"chat-error",children:[b.jsx("span",{children:e.errorCode==="chat_disabled_interrupted"?"Chat was disabled while this response was running. The partial response is saved. Please try again later.":e.errorCode==="chat_session_quota_exceeded"?e.error:`The assistant hit an error: ${e.error}`}),["hf_inference_billing_required","hf_inference_credential_expired"].includes(e.errorCode??"")&&b.jsx("a",{href:"/settings",children:"Re-sign in with Hugging Face"}),e.errorCode==="hf_inference_billing_exhausted"&&b.jsxs(b.Fragment,{children:[(a==null?void 0:a.account_type)==="Free"&&!a.bill_to?b.jsx("a",{href:TC,target:"_blank",rel:"noreferrer",children:"Upgrade to Hugging Face PRO — $9/month for 20× more included credits"}):b.jsx("a",{href:(a==null?void 0:a.usage_url)??"/settings",target:a?"_blank":void 0,rel:a?"noreferrer":void 0,children:"Review Hugging Face usage and billing"}),b.jsx("a",{href:CC,target:"_blank",rel:"noreferrer",children:"Inference Providers pricing and billing details"})]}),e.errorCode==="openrouter_monthly_budget_exhausted"&&b.jsxs(b.Fragment,{children:[i?b.jsx("span",{children:"This response started on the shared allowance. Your connected OpenRouter key will be used when you explicitly retry."}):b.jsx("a",{href:"/settings#openrouter-byok",children:"Connect your own OpenRouter key"}),b.jsx("span",{children:"Or select a Hugging Face-backed model and explicitly retry."})]}),e.errorCode==="openrouter_staging_funding_disabled"&&b.jsx("a",{href:jC,children:"Continue on paperswithcode.co"}),e.errorCode==="openrouter_unavailable"&&b.jsxs(b.Fragment,{children:[b.jsx("a",{href:"/settings#openrouter-byok",children:"Bring your own key in Settings"}),b.jsx("a",{href:"https://github.com/huggingface/paperswithcode-feedback",target:"_blank",rel:"noreferrer",children:"File an issue"})]}),e.errorCode==="openrouter_byok_billing_error"&&b.jsx("a",{href:"https://openrouter.ai/settings/credits",target:"_blank",rel:"noreferrer",children:"Review OpenRouter billing"}),["openrouter_byok_credential_invalid","openrouter_byok_rate_limit"].includes(e.errorCode??"")&&b.jsx("a",{href:"/settings#openrouter-byok",children:"Review OpenRouter settings"}),e.errorCode==="chat_session_quota_exceeded"&&(n||s)&&b.jsxs("span",{className:"chat-error-actions",children:[n&&b.jsx("button",{type:"button",disabled:o!==null,onClick:n,children:o==="old"?"Archiving…":"Archive chats older than 30 days"}),s&&b.jsx("button",{type:"button",disabled:o!==null,onClick:s,children:o==="oldest"?"Archiving…":"Archive oldest 50 chats"})]})]}),!e.streaming&&e.finishReason&&e.finishReason!=="success"&&b.jsx("div",{className:"chat-finish-note",children:["tool_limit","max_turns"].includes(e.finishReason)?"The assistant stopped at the execution limit.":`The assistant stopped early (${e.finishReason.replace(/_/g," ")}).`}),R&&b.jsxs("div",{className:"chat-feedback","aria-label":"Rate this response",children:[b.jsx("span",{className:"chat-feedback-label",children:l===null?"Was this helpful?":"Thanks for your feedback"}),b.jsx("button",{type:"button",className:`chat-feedback-action${l===!0?" chat-feedback-action-selected":""}`,"aria-label":"Helpful response","aria-pressed":l===!0,disabled:h,onClick:()=>{g(!1),O(!0)},children:b.jsx(ep,{"aria-hidden":"true"})}),b.jsx("button",{type:"button",className:`chat-feedback-action${l===!1?" chat-feedback-action-selected":""}`,"aria-label":"Unhelpful response","aria-pressed":l===!1,"aria-expanded":y,"aria-controls":T,disabled:h,onClick:()=>{v(!1),g(!0)},children:b.jsx(Xh,{"aria-hidden":"true"})}),_&&b.jsx("span",{className:"chat-feedback-error",role:"status",children:"Couldn’t send feedback."})]}),R&&y&&b.jsxs("div",{className:"chat-feedback-panel",id:T,role:"group","aria-labelledby":`${T}-title`,children:[b.jsx("div",{className:"chat-feedback-panel-title",id:`${T}-title`,children:"Additional feedback"}),b.jsx("label",{className:"chat-feedback-panel-label",htmlFor:`${T}-comment`,children:"Tell us what went wrong (optional)"}),b.jsx("textarea",{ref:E,id:`${T}-comment`,className:"chat-feedback-comment",value:f,maxLength:500,rows:4,disabled:h,onChange:q=>$(q.target.value),onKeyDown:q=>{q.key==="Escape"&&(q.preventDefault(),g(!1))}}),b.jsxs("div",{className:"chat-feedback-panel-actions",children:[b.jsx("button",{type:"button",className:"chat-feedback-skip",disabled:h,onClick:()=>void O(!1),children:"Skip"}),b.jsx("button",{type:"button",className:"chat-feedback-submit",disabled:h,onClick:()=>void O(!1,f.trim()||void 0),children:h?"Submitting…":"Submit"})]})]})]})})},UC={chat:{breakpoint:760,left:360,right:360},shared:{breakpoint:760,left:360,right:360},reader:{breakpoint:1260,left:840,right:420}};function ar(e,t,r,n){if(!e)return Math.max(25,Math.min(75,t));const s=Math.max(25,n/e*100),o=Math.min(75,(e-r)/e*100);return Math.max(s,Math.min(o,t))}const cj=({children:e,variant:t})=>{const r=Ic(),n=UC[t],s=H.useRef(null),o=H.useRef(null),a=H.useRef(null),i=H.useRef(null),[c,l]=H.useState(0),d=H.useRef(!1),h=H.useRef(r.state.panelPercent);H.useLayoutEffect(()=>{const f=s.current;if(!f)return;const $=()=>l(f.clientWidth||window.innerWidth);if($(),typeof ResizeObserver>"u")return;const E=new ResizeObserver($);return E.observe(f),()=>E.disconnect()},[]);const m=r.state.open&&c>=n.breakpoint,_=ar(c,r.state.panelPercent,n.left,n.right),v=f=>{var E;const $=ar(c,f,n.left,n.right);h.current=$,o.current&&(o.current.style.width=`${100-$}%`),a.current&&(a.current.style.width=`${$}%`),(E=i.current)==null||E.setAttribute("aria-valuenow",String(Math.round($)))},y=f=>{var E;const $=(E=s.current)==null?void 0:E.getBoundingClientRect();$!=null&&$.width&&v(($.right-f)/$.width*100)},g=()=>{d.current&&(d.current=!1,r.setPanelPercent(h.current))};return b.jsxs("div",{ref:s,className:`chat-artifact-workspace chat-artifact-workspace-${t}${m?" has-docked-artifact":""}`,"data-artifact-layout":m?"split":r.state.open?"dialog":"closed",children:[b.jsx("div",{ref:o,className:"chat-artifact-workspace-content",style:m?{width:`${100-_}%`}:void 0,children:e}),m&&b.jsxs(b.Fragment,{children:[b.jsx("div",{ref:i,className:"chat-artifact-resize-handle",role:"separator","aria-label":"Resize conversation and poster panels","aria-orientation":"vertical","aria-valuemin":Math.ceil(ar(c,0,n.left,n.right)),"aria-valuemax":Math.floor(ar(c,100,n.left,n.right)),"aria-valuenow":Math.round(_),tabIndex:0,onPointerDown:f=>{d.current=!0,f.currentTarget.setPointerCapture(f.pointerId),y(f.clientX)},onPointerMove:f=>{d.current&&y(f.clientX)},onPointerUp:g,onPointerCancel:g,onLostPointerCapture:g,onDoubleClick:()=>r.setPanelPercent(55),onKeyDown:f=>{(f.key==="ArrowLeft"||f.key==="ArrowRight")&&(f.preventDefault(),r.setPanelPercent(ar(c,_+(f.key==="ArrowLeft"?2:-2),n.left,n.right))),f.key==="Home"&&r.setPanelPercent(ar(c,25,n.left,n.right)),f.key==="End"&&r.setPanelPercent(ar(c,75,n.left,n.right))}}),b.jsx("div",{ref:a,className:"chat-artifact-workspace-pane",style:{width:`${_}%`},children:b.jsx(ou,{})})]}),r.state.open&&!m&&b.jsx(ou,{forceDialog:!0,readerFallback:t==="reader"})]})};export{oj as A,ej as C,aj as U,cj as a,ij as b,Ic as u};