diff --git "a/assets/ChatMessage-BbH5ZMSW.js" "b/assets/ChatMessage-BbH5ZMSW.js" deleted file mode 100644--- "a/assets/ChatMessage-BbH5ZMSW.js" +++ /dev/null @@ -1,111 +0,0 @@ -var Vf=Object.defineProperty;var Ff=(e,t,r)=>t in e?Vf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var fe=(e,t,r)=>Ff(e,typeof t!="symbol"?t+"":t,r);import{d as ws,r as kt,j as R,z as se,N as Dl,E as Lf,C as Hf}from"./index-GPj7ATde.js";import{u as Ul,a as Vl,b as Fl,M as Zf,R as Kf,W as Gf,d as Zo,A as Wf,n as Bf,K as Jf,L as Ll,N as Qf}from"./chatSessions-BlWxJLLK.js";import"./katex.min-BSBacQyE.js";import{H as Ko,a as Go,b as Wo}from"./hover-card-DNKXLMCs.js";import{u as Yf}from"./useQuery-VaQ1Mk_g.js";import{f as Xf,p as eh}from"./github-De35yAAk.js";import{G as Bo}from"./github-DLYSBsIp.js";import{r as th,a as rh,P as Hl}from"./PaperPreviewLink-DLgJesF4.js";import{M as nh,r as sh,d as oh}from"./index-CD8oG2PE.js";import{c as pc}from"./chat-B-s5h2da.js";import{F as ah}from"./file-text-BS10SkRg.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 ih=ws("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 ch=ws("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 lh=ws("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 uh=ws("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 bs({selection:e,editable:t=!1,onRemove:r}){const n=kt.useId(),s=kt.useRef(null),[o,a]=kt.useState(!1),[i,c]=kt.useState(!1),l=`Selection · Page ${e.page}`;return kt.useEffect(()=>{const d=s.current;!d||o||c(d.scrollHeight>d.clientHeight+1)},[o,e.text]),R.jsxs("div",{className:`chat-paper-selection${t?" is-editable":""}`,children:[R.jsxs("div",{className:"chat-paper-selection-header",children:[R.jsx("span",{className:"chat-paper-selection-label",children:l}),R.jsxs("div",{className:"chat-paper-selection-actions",children:[(i||o)&&R.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&&R.jsx("button",{type:"button",className:"chat-paper-selection-remove","aria-label":"Remove selected paper passage",onClick:r,children:"Remove"})]})]}),R.jsx("blockquote",{id:n,ref:s,className:`chat-paper-selection-quote${o?" is-expanded":""}`,children:e.text})]})}const dh=Bf(),nR=({onSend:e,busy:t,placeholder:r,autoFocus:n,draft:s,onDraftChange:o,onStop:a,models:i=[],selectedModel:c,onModelChange:l,disabled:d=!1,describedBy:f,paperMentionsEnabled:_=!1,paperSelectionEnabled:g=!0,webSearchAvailable:m=!1,webSearchEnabled:v=!1,onWebSearchChange:y,reasoningEffort:h="low",onReasoningEffortChange:$})=>{const[S,T]=kt.useState(dh),k=s??S,I=kt.useRef(null),[z,F]=kt.useState(0),G=V=>{s||T(V),o==null||o(V)},Z=Ul({draft:k,onChange:G,enabled:_,textareaRef:I});kt.useEffect(()=>{const V=I.current;V&&(V.style.height="auto",V.style.height=`${Math.min(V.scrollHeight,200)}px`)},[k.text]),kt.useEffect(()=>{var V;n&&((V=I.current)==null||V.focus())},[n]);const K=()=>{const V=k.text.length-k.text.trimStart().length,ie=k.text.trim(),ke=!!k.paperSelection&&!g;if(!ie||t||d||ke)return;const $e=V+ie.length,ct={text:ie,paperMentions:k.paperMentions.filter(Oe=>Oe.start>=V&&Oe.end<=$e).map(Oe=>({...Oe,start:Oe.start-V,end:Oe.end-V})),...k.paperSelection?{paperSelection:k.paperSelection}:{}};e(ct)},Q=!!k.paperSelection&&!g,re=!!k.text.trim()&&!Q;return R.jsxs("div",{className:"chat-composer",children:[k.paperSelection&&R.jsx(bs,{selection:k.paperSelection,editable:!0,onRemove:()=>{var V;G({text:k.text,paperMentions:k.paperMentions}),(V=I.current)==null||V.focus()}}),Q&&R.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."}),R.jsxs("div",{className:"chat-composer-textarea-wrap",children:[R.jsx(Vl,{text:k.text,mentions:k.paperMentions,scrollTop:z}),R.jsx("textarea",{ref:I,rows:1,value:k.text,placeholder:r||(k.paperSelection?"Ask about this selection…":"Ask anything about research…"),onChange:V=>Z.updateText(V.target.value,V.target.selectionStart),onSelect:V=>Z.refresh(V.currentTarget.selectionStart),onClick:V=>Z.refresh(V.currentTarget.selectionStart),onScroll:V=>F(V.currentTarget.scrollTop),onBlur:V=>{var ie,ke;(ke=(ie=V.relatedTarget)==null?void 0:ie.closest)!=null&&ke.call(ie,".chat-paper-picker")||window.setTimeout(Z.close,0)},onKeyDown:V=>{Z.keyDown(V)||V.key==="Enter"&&!V.shiftKey&&!V.nativeEvent.isComposing&&(V.preventDefault(),K())},role:"combobox","aria-expanded":Z.open,"aria-controls":Z.open?Z.pickerId:void 0,"aria-activedescendant":Z.open&&Z.results.length?`${Z.optionIdPrefix}-${Z.activeIndex}`:void 0,"aria-autocomplete":"list","aria-describedby":[f,Z.message?"chat-paper-mention-message":null].filter(Boolean).join(" ")||void 0}),R.jsx(Fl,{open:Z.open,query:Z.query,results:Z.results,activeIndex:Z.activeIndex,loading:Z.loading,error:Z.error,onSelect:Z.select,id:Z.pickerId,optionIdPrefix:Z.optionIdPrefix})]}),Z.message&&R.jsx("div",{id:"chat-paper-mention-message",className:"chat-paper-mention-message",role:"alert",children:Z.message}),R.jsxs("div",{className:"chat-composer-row",children:[R.jsxs("div",{className:"chat-composer-tools",children:[i.length>0&&c&&l&&R.jsx(Zf,{models:i,selectedModel:c,onModelChange:l,disabled:t}),$&&R.jsx(Kf,{value:h,onChange:$,disabled:t}),m&&y&&R.jsx(Gf,{enabled:v,onChange:y,disabled:t}),R.jsx("span",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]}),R.jsx("button",{type:"button",className:`chat-send${t||re?" chat-send-on":""}`,onClick:t?a:K,disabled:d||(t?!a:!re),"aria-label":t?"Stop generating":"Send message",children:t?a?R.jsx("span",{"aria-hidden":"true",children:"■"}):R.jsx(Zo,{light:!0}):R.jsx(Wf,{})})]})]})},Ls=new Map,fh=e=>{if(!e)return Promise.resolve();const t=Ls.get(e);if(t)return t;const r=new Promise(n=>{const s=new Image;s.onload=()=>{n()},s.onerror=()=>{Ls.delete(e),n()},s.src=e});return Ls.set(e,r),r},hh=new Set(["huggingface.co","www.huggingface.co"]),ph=new Set(["api","blog","chat","collections","docs","enterprise","join","login","models","new","organizations","papers","posts","pricing","search","settings","spaces","tasks"]);function mh(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!=="https:"||!hh.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"&&ph.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 gh=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,_h=({repo:e})=>{const[t,r]=se.useState(!1);return R.jsxs("div",{className:"hf-preview-card",children:[t?R.jsx("div",{className:"hf-preview-fallback","aria-hidden":"true",children:"🤗"}):R.jsx("img",{className:"hf-preview-image","data-testid":"hf-preview-image",src:e.thumbnailUrl,alt:"",loading:"eager",decoding:"async",onError:()=>r(!0)}),R.jsxs("div",{className:"hf-preview-meta",children:[R.jsxs("span",{className:"hf-preview-kind",children:["Hugging Face ",e.type]}),R.jsx("strong",{children:e.repoId}),R.jsx("span",{children:"huggingface.co"})]})]})},yh=({repo:e,children:t})=>{const[r,n]=se.useState(!1),s=se.useRef(null),o=se.useCallback(()=>{fh(e.thumbnailUrl)},[e.thumbnailUrl]);return se.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]),R.jsxs(Ko,{open:r,onOpenChange:a=>{(!a||!gh())&&n(a)},openDelay:150,closeDelay:100,children:[R.jsx(Go,{asChild:!0,children:R.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})}),R.jsx(Wo,{className:"hf-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:R.jsx(_h,{repo:e})})]})},vh=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,$h=({repo:e,preview:t,unavailable:r})=>{const[n,s]=se.useState(!1),o=!!(t!=null&&t.avatarUrl)&&!n;return R.jsxs("div",{className:"github-preview-card",children:[o?R.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)}):R.jsx("div",{className:"github-preview-fallback","aria-hidden":"true",children:R.jsx(Bo,{})}),R.jsxs("div",{className:"github-preview-meta",children:[R.jsx("span",{className:"github-preview-kind",children:"GitHub repository"}),R.jsx("strong",{children:e.repoId}),(t==null?void 0:t.description)&&R.jsx("span",{className:"github-preview-description",children:t.description}),t?R.jsxs("span",{className:"github-preview-stats",children:[t.language&&R.jsxs(R.Fragment,{children:[t.language," · "]}),"★ ",t.stars.toLocaleString()," · ⑂ ",t.forks.toLocaleString(),t.archived&&R.jsx(R.Fragment,{children:" · Archived"})]}):R.jsx("span",{children:r?"Preview unavailable":"Loading preview…"})]})]})},wh=({repo:e,children:t})=>{const[r,n]=se.useState(!1),s=Yf({queryKey:["github-repository-preview",e.repoId.toLowerCase()],queryFn:({signal:o})=>Xf(e,o),enabled:r,staleTime:30*60*1e3,gcTime:60*60*1e3,retry:!1});return R.jsxs(Ko,{open:r,onOpenChange:o=>{(!o||!vh())&&n(o)},openDelay:150,closeDelay:100,children:[R.jsx(Go,{asChild:!0,children:R.jsxs("a",{className:"chat-github-link",href:e.url,target:"_blank",rel:"noopener noreferrer",children:[R.jsx(Bo,{"aria-hidden":"true"}),t]})}),R.jsx(Wo,{className:"github-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:R.jsx($h,{repo:e,preview:s.data,unavailable:s.isError})})]})},bh=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches;function Sh(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return"Web source"}}const Eh=({citation:e})=>{const[t,r]=se.useState(!1),[n,s]=se.useState(!1),o=e.thumbnail_url,a=e.favicon_url;return R.jsxs("div",{className:"web-preview-card",children:[o&&!t&&R.jsx("img",{className:"web-preview-image","data-testid":"web-preview-image",src:o,alt:"",loading:"eager",decoding:"async",referrerPolicy:"no-referrer",onError:()=>r(!0)}),R.jsxs("div",{className:"web-preview-meta",children:[R.jsxs("div",{className:"web-preview-source",children:[a&&!n&&R.jsx("img",{src:a,alt:"",loading:"eager",decoding:"async",referrerPolicy:"no-referrer",onError:()=>s(!0)}),R.jsx("span",{children:Sh(e.url??"")}),e.published&&R.jsxs(R.Fragment,{children:[R.jsx("span",{"aria-hidden":"true",children:"·"}),R.jsx("time",{children:e.published.slice(0,10)})]})]}),R.jsx("strong",{children:e.title}),e.excerpt&&R.jsx("p",{children:e.excerpt.replace(/\s+/g," ").trim()})]})]})},kh=({citation:e,children:t})=>{const[r,n]=se.useState(!1),s=e.url??"";return R.jsxs(Ko,{open:r,onOpenChange:o=>{(!o||!bh())&&n(o)},openDelay:150,closeDelay:100,children:[R.jsx(Go,{asChild:!0,children:R.jsx("a",{href:s,className:"chat-web-citation",target:"_blank",rel:"noopener noreferrer",children:t})}),R.jsx(Wo,{className:"web-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:R.jsx(Eh,{citation:e})})]})};function Ph(e,t,r){if(t)return{routeId:e,title:t.title,arxivId:t.metadata.arxiv_id,source:t.metadata.source,sourceUrl:t.metadata.source_url,thumbnailUrl:t.metadata.thumbnail_url,authors:t.metadata.authors.map(n=>n.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 Zl=({routeId:e,paper:t,citation:r,className:n="chat-paper-link",children:s})=>R.jsx(Hl,{routeId:e,initialData:Ph(e,t,r),className:n,target:"_blank",children:s});function Th(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 Rh=e=>e.startsWith("paper:")?e:oh(e);function Ch(e){try{const t=new URL(e);return t.protocol==="https:"&&(t.hostname==="github.com"||t.hostname==="www.github.com")}catch{return!1}}const io=({text:e,streaming:t,papers:r,citations:n,webCitations:s})=>{const o=t?Th(e):e;return R.jsx(nh,{remarkPlugins:[sh,rh],rehypePlugins:[th],urlTransform:Rh,components:{a:({href:a,children:i})=>{if(a!=null&&a.startsWith("paper:")){const d=a.slice(6);return!r[d]&&!(n!=null&&n[d])?R.jsx("span",{className:"chat-invalid-citation",children:i}):R.jsx(Zl,{routeId:d,paper:r[d],citation:n==null?void 0:n[d],children:i})}const c=a?mh(a):null;if(c)return R.jsx(yh,{repo:c,children:i});const l=a?eh(a):null;return l?R.jsx(wh,{repo:l,children:i}):a&&Ch(a)?R.jsxs("a",{href:a,className:"chat-github-link",target:"_blank",rel:"noopener noreferrer",children:[R.jsx(Bo,{"aria-hidden":"true"}),i]}):a!=null&&a.startsWith("https://")&&(s!=null&&s[a])?R.jsx(kh,{citation:s[a],children:i}):a!=null&&a.startsWith("https://")?R.jsx("a",{href:a,className:"chat-external-link",target:"_blank",rel:"noopener noreferrer",children:i}):R.jsx("span",{children:i})}},children:o})},Nh=Object.freeze({status:"aborted"});function x(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 cn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Kl={};function Lt(e){return Kl}function Ih(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 jh(e,t){return typeof t=="bigint"?t.toString():t}function Jo(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Qo(e){return e==null}function Yo(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Oh(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 Re(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 Ss(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Fr(e){return JSON.stringify(e)}const Gl=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function rs(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Ah=Jo(()=>{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 ns(e){if(rs(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(rs(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}const Mh=new Set(["string","number","symbol"]);function pn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function hr(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 ee(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 zh(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const xh={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 qh(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 hr(e,{...e._zod.def,shape:r,checks:[]})}function Dh(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 hr(e,{...e._zod.def,shape:r,checks:[]})}function Uh(e,t){if(!ns(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 Ss(this,"shape",n),n},checks:[]};return hr(e,r)}function Vh(e,t){return hr(e,{...e._zod.def,get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Ss(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function Fh(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 hr(t,{...t._zod.def,shape:s,checks:[]})}function Lh(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 hr(t,{...t._zod.def,shape:s,checks:[]})}function Qr(e,t=0){var r;for(let n=t;n{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Cn(e){return typeof e=="string"?e:e==null?void 0:e.message}function Ht(e,t,r){var s,o,a,i,c,l;const n={...e,path:e.path??[]};if(!e.message){const d=Cn((a=(o=(s=e.inst)==null?void 0:s._zod.def)==null?void 0:o.error)==null?void 0:a.call(o,e))??Cn((i=t==null?void 0:t.error)==null?void 0:i.call(t,e))??Cn((c=r.customError)==null?void 0:c.call(r,e))??Cn((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 Xo(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ln(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const Wl=(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,jh,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Bl=x("$ZodError",Wl),Jl=x("$ZodError",Wl,{Parent:Error});function Hh(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 Zh(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 cn;if(a.issues.length){const i=new((s==null?void 0:s.Err)??e)(a.issues.map(c=>Ht(c,o,Lt())));throw Gl(i,s==null?void 0:s.callee),i}return a.value},Gh=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=>Ht(c,o,Lt())));throw Gl(i,s==null?void 0:s.callee),i}return a.value},Ql=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 cn;return o.issues.length?{success:!1,error:new(e??Bl)(o.issues.map(a=>Ht(a,s,Lt())))}:{success:!0,data:o.value}},Yl=Ql(Jl),Xl=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=>Ht(a,s,Lt())))}:{success:!0,data:o.value}},Wh=Xl(Jl),Bh=/^[cC][^\s-]{8,}$/,Jh=/^[0-9a-z]+$/,Qh=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Yh=/^[0-9a-vA-V]{20}$/,Xh=/^[A-Za-z0-9]{27}$/,ep=/^[a-zA-Z0-9_-]{21}$/,tp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,rp=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,mc=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)$/,np=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,sp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function op(){return new RegExp(sp,"u")}const ap=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ip=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,cp=/^((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])$/,lp=/^(([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])$/,up=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,eu=/^[A-Za-z0-9_-]*$/,dp=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,fp=/^\+(?:[0-9]){6,14}[0-9]$/,tu="(?:(?:\\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])))",hp=new RegExp(`^${tu}$`);function ru(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function pp(e){return new RegExp(`^${ru(e)}$`)}function mp(e){const t=ru({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-]\\d{2}:\\d{2})");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${tu}T(?:${n})$`)}const gp=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}$`)},_p=/^\d+$/,yp=/^-?\d+(?:\.\d+)?/i,vp=/true|false/i,$p=/null/i,wp=/undefined/i,bp=/^[^A-Z]*$/,Sp=/^[^a-z]*$/,it=x("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),nu={number:"number",bigint:"bigint",object:"date"},su=x("$ZodCheckLessThan",(e,t)=>{it.init(e,t);const r=nu[typeof t.value];e._zod.onattach.push(n=>{const s=n._zod.bag,o=(t.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value{(t.inclusive?n.value<=t.value:n.value{it.init(e,t);const r=nu[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})}}),Ep=x("$ZodCheckMultipleOf",(e,t)=>{it.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Oh(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})}}),kp=x("$ZodCheckNumberFormat",(e,t)=>{var a;it.init(e,t),t.format=t.format||"float64";const r=(a=t.format)==null?void 0:a.includes("int"),n=r?"int":"number",[s,o]=xh[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=_p)}),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})}}),Pp=x("$ZodCheckMaxLength",(e,t)=>{var r;it.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!Qo(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=Xo(s);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Tp=x("$ZodCheckMinLength",(e,t)=>{var r;it.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!Qo(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=Xo(s);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Rp=x("$ZodCheckLengthEquals",(e,t)=>{var r;it.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!Qo(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=Xo(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})}}),Es=x("$ZodCheckStringFormat",(e,t)=>{var r,n;it.init(e,t),e._zod.onattach.push(s=>{const o=s._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=s=>{t.pattern.lastIndex=0,!t.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:t.format,input:s.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Cp=x("$ZodCheckRegex",(e,t)=>{Es.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})}}),Np=x("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=bp),Es.init(e,t)}),Ip=x("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Sp),Es.init(e,t)}),jp=x("$ZodCheckIncludes",(e,t)=>{it.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})}}),Op=x("$ZodCheckStartsWith",(e,t)=>{it.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})}}),Ap=x("$ZodCheckEndsWith",(e,t)=>{it.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})}}),Mp=x("$ZodCheckOverwrite",(e,t)=>{it.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class zp{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 xp={major:4,minor:0,patch:0},Ee=x("$ZodType",(e,t)=>{var s;var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=xp;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=Qr(a),d;for(const f of i){if(f._zod.def.when){if(!f._zod.def.when(a))continue}else if(l)continue;const _=a.issues.length,g=f._zod.check(a);if(g instanceof Promise&&(c==null?void 0:c.async)===!1)throw new cn;if(d||g instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await g,a.issues.length!==_&&(l||(l=Qr(a,_)))});else{if(a.issues.length===_)continue;l||(l=Qr(a,_))}}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 cn;return c.then(l=>o(l,n,i))}return o(c,n,i)}}e["~standard"]={validate:o=>{var a;try{const i=Yl(e,o);return i.success?{value:i.data}:{issues:(a=i.error)==null?void 0:a.issues}}catch{return Wh(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}}),ea=x("$ZodString",(e,t)=>{var r;Ee.init(e,t),e._zod.pattern=[...((r=e==null?void 0:e._zod.bag)==null?void 0:r.patterns)??[]].pop()??gp(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}}),Ne=x("$ZodStringFormat",(e,t)=>{Es.init(e,t),ea.init(e,t)}),qp=x("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=rp),Ne.init(e,t)}),Dp=x("$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=mc(n))}else t.pattern??(t.pattern=mc());Ne.init(e,t)}),Up=x("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=np),Ne.init(e,t)}),Vp=x("$ZodURL",(e,t)=>{Ne.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:dp.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})}}}),Fp=x("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=op()),Ne.init(e,t)}),Lp=x("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=ep),Ne.init(e,t)}),Hp=x("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Bh),Ne.init(e,t)}),Zp=x("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Jh),Ne.init(e,t)}),Kp=x("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Qh),Ne.init(e,t)}),Gp=x("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Yh),Ne.init(e,t)}),Wp=x("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Xh),Ne.init(e,t)}),Bp=x("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=mp(t)),Ne.init(e,t)}),Jp=x("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=hp),Ne.init(e,t)}),Qp=x("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=pp(t)),Ne.init(e,t)}),Yp=x("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=tp),Ne.init(e,t)}),Xp=x("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ap),Ne.init(e,t),e._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv4"})}),em=x("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ip),Ne.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})}}}),tm=x("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=cp),Ne.init(e,t)}),rm=x("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=lp),Ne.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 au(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const nm=x("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=up),Ne.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),e._zod.check=r=>{au(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function sm(e){if(!eu.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return au(r)}const om=x("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=eu),Ne.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),e._zod.check=r=>{sm(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),am=x("$ZodE164",(e,t)=>{t.pattern??(t.pattern=fp),Ne.init(e,t)});function im(e,t=null){try{const r=e.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const s=JSON.parse(atob(n));return!("typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||t&&(!("alg"in s)||s.alg!==t))}catch{return!1}}const cm=x("$ZodJWT",(e,t)=>{Ne.init(e,t),e._zod.check=r=>{im(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),iu=x("$ZodNumber",(e,t)=>{Ee.init(e,t),e._zod.pattern=e._zod.bag.pattern??yp,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}}),lm=x("$ZodNumber",(e,t)=>{kp.init(e,t),iu.init(e,t)}),um=x("$ZodBoolean",(e,t)=>{Ee.init(e,t),e._zod.pattern=vp,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}const s=r.value;return typeof s=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:e}),r}}),dm=x("$ZodUndefined",(e,t)=>{Ee.init(e,t),e._zod.pattern=wp,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}}),fm=x("$ZodNull",(e,t)=>{Ee.init(e,t),e._zod.pattern=$p,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}}),hm=x("$ZodAny",(e,t)=>{Ee.init(e,t),e._zod.parse=r=>r}),pm=x("$ZodUnknown",(e,t)=>{Ee.init(e,t),e._zod.parse=r=>r}),mm=x("$ZodNever",(e,t)=>{Ee.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function gc(e,t,r){e.issues.length&&t.issues.push(...ar(r,e.issues)),t.value[r]=e.value}const gm=x("$ZodArray",(e,t)=>{Ee.init(e,t),e._zod.parse=(r,n)=>{const s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),r;r.value=Array(s.length);const o=[];for(let a=0;agc(l,r,a))):gc(c,r,a)}return o.length?Promise.all(o).then(()=>r):r}});function Nn(e,t,r){e.issues.length&&t.issues.push(...ar(r,e.issues)),t.value[r]=e.value}function _c(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(...ar(r,e.issues)):e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}const _m=x("$ZodObject",(e,t)=>{Ee.init(e,t);const r=Jo(()=>{const f=Object.keys(t.shape);for(const g of f)if(!(t.shape[g]instanceof Ee))throw new Error(`Invalid element at key "${g}": expected a Zod schema`);const _=zh(t.shape);return{shape:t.shape,keys:f,keySet:new Set(f),numKeys:f.length,optionalKeys:new Set(_)}});Re(e._zod,"propValues",()=>{const f=t.shape,_={};for(const g in f){const m=f[g]._zod;if(m.values){_[g]??(_[g]=new Set);for(const v of m.values)_[g].add(v)}}return _});const n=f=>{const _=new zp(["shape","payload","ctx"]),g=r.value,m=$=>{const S=Fr($);return`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`};_.write("const input = payload.value;");const v=Object.create(null);let y=0;for(const $ of g.keys)v[$]=`key_${y++}`;_.write("const newResult = {}");for(const $ of g.keys)if(g.optionalKeys.has($)){const S=v[$];_.write(`const ${S} = ${m($)};`);const T=Fr($);_.write(` - if (${S}.issues.length) { - if (input[${T}] === undefined) { - if (${T} in input) { - newResult[${T}] = undefined; - } - } else { - payload.issues = payload.issues.concat( - ${S}.issues.map((iss) => ({ - ...iss, - path: iss.path ? [${T}, ...iss.path] : [${T}], - })) - ); - } - } else if (${S}.value === undefined) { - if (${T} in input) newResult[${T}] = undefined; - } else { - newResult[${T}] = ${S}.value; - } - `)}else{const S=v[$];_.write(`const ${S} = ${m($)};`),_.write(` - if (${S}.issues.length) payload.issues = payload.issues.concat(${S}.issues.map(iss => ({ - ...iss, - path: iss.path ? [${Fr($)}, ...iss.path] : [${Fr($)}] - })));`),_.write(`newResult[${Fr($)}] = ${S}.value`)}_.write("payload.value = newResult;"),_.write("return payload;");const h=_.compile();return($,S)=>h(f,$,S)};let s;const o=rs,a=!Kl.jitless,c=a&&Ah.value,l=t.catchall;let d;e._zod.parse=(f,_)=>{d??(d=r.value);const g=f.value;if(!o(g))return f.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),f;const m=[];if(a&&c&&(_==null?void 0:_.async)===!1&&_.jitless!==!0)s||(s=n(t.shape)),f=s(f,_);else{f.value={};const S=d.shape;for(const T of d.keys){const k=S[T],I=k._zod.run({value:g[T],issues:[]},_),z=k._zod.optin==="optional"&&k._zod.optout==="optional";I instanceof Promise?m.push(I.then(F=>z?_c(F,f,T,g):Nn(F,f,T))):z?_c(I,f,T,g):Nn(I,f,T)}}if(!l)return m.length?Promise.all(m).then(()=>f):f;const v=[],y=d.keySet,h=l._zod,$=h.def.type;for(const S of Object.keys(g)){if(y.has(S))continue;if($==="never"){v.push(S);continue}const T=h.run({value:g[S],issues:[]},_);T instanceof Promise?m.push(T.then(k=>Nn(k,f,S))):Nn(T,f,S)}return v.length&&f.issues.push({code:"unrecognized_keys",keys:v,input:g,inst:e}),m.length?Promise.all(m).then(()=>f):f}});function yc(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=>Ht(o,n,Lt())))}),t}const cu=x("$ZodUnion",(e,t)=>{Ee.init(e,t),Re(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),Re(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),Re(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),Re(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=>Yo(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=>yc(a,r,e,n)):yc(o,r,e,n)}}),ym=x("$ZodDiscriminatedUnion",(e,t)=>{cu.init(e,t);const r=e._zod.parse;Re(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=Jo(()=>{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(!rs(a))return s.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),s;const i=n.value.get(a==null?void 0:a[t.discriminator]);return i?i._zod.run(s,o):t.unionFallback?r(s,o):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:a,path:[t.discriminator],inst:e}),s)}}),vm=x("$ZodIntersection",(e,t)=>{Ee.init(e,t),e._zod.parse=(r,n)=>{const s=r.value,o=t.left._zod.run({value:s,issues:[]},n),a=t.right._zod.run({value:s,issues:[]},n);return o instanceof Promise||a instanceof Promise?Promise.all([o,a]).then(([c,l])=>vc(r,c,l)):vc(r,o,a)}});function co(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(ns(e)&&ns(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=co(e[o],t[o]);if(!a.valid)return{valid:!1,mergeErrorPath:[o,...a.mergeErrorPath]};s[o]=a.data}return{valid:!0,data:s}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n{Ee.init(e,t),e._zod.parse=(r,n)=>{const s=r.value;if(!ns(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(...ar(c,d.issues)),r.value[c]=d.value})):(l.issues.length&&r.issues.push(...ar(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=>Ht(l,n,Lt())),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(...ar(a,l.issues)),r.value[i.value]=l.value})):(c.issues.length&&r.issues.push(...ar(a,c.issues)),r.value[i.value]=c.value)}}return o.length?Promise.all(o).then(()=>r):r}}),wm=x("$ZodEnum",(e,t)=>{Ee.init(e,t);const r=Ih(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(n=>Mh.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}}),bm=x("$ZodLiteral",(e,t)=>{Ee.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?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}}),Sm=x("$ZodTransform",(e,t)=>{Ee.init(e,t),e._zod.parse=(r,n)=>{const s=t.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(a=>(r.value=a,r));if(s instanceof Promise)throw new cn;return r.value=s,r}}),Em=x("$ZodOptional",(e,t)=>{Ee.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Re(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Re(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${Yo(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)}),km=x("$ZodNullable",(e,t)=>{Ee.init(e,t),Re(e._zod,"optin",()=>t.innerType._zod.optin),Re(e._zod,"optout",()=>t.innerType._zod.optout),Re(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${Yo(r.source)}|null)$`):void 0}),Re(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)}),Pm=x("$ZodDefault",(e,t)=>{Ee.init(e,t),e._zod.optin="optional",Re(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=>$c(o,t)):$c(s,t)}});function $c(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Tm=x("$ZodPrefault",(e,t)=>{Ee.init(e,t),e._zod.optin="optional",Re(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))}),Rm=x("$ZodNonOptional",(e,t)=>{Ee.init(e,t),Re(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=>wc(o,e)):wc(s,e)}});function wc(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 Cm=x("$ZodCatch",(e,t)=>{Ee.init(e,t),e._zod.optin="optional",Re(e._zod,"optout",()=>t.innerType._zod.optout),Re(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=>Ht(a,n,Lt()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=t.catchValue({...r,error:{issues:s.issues.map(o=>Ht(o,n,Lt()))},input:r.value}),r.issues=[]),r)}}),Nm=x("$ZodPipe",(e,t)=>{Ee.init(e,t),Re(e._zod,"values",()=>t.in._zod.values),Re(e._zod,"optin",()=>t.in._zod.optin),Re(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=>bc(o,t,n)):bc(s,t,n)}});function bc(e,t,r){return Qr(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}const Im=x("$ZodReadonly",(e,t)=>{Ee.init(e,t),Re(e._zod,"propValues",()=>t.innerType._zod.propValues),Re(e._zod,"values",()=>t.innerType._zod.values),Re(e._zod,"optin",()=>t.innerType._zod.optin),Re(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(Sc):Sc(s)}});function Sc(e){return e.value=Object.freeze(e.value),e}const jm=x("$ZodCustom",(e,t)=>{it.init(e,t),Ee.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,s=t.fn(n);if(s instanceof Promise)return s.then(o=>Ec(o,r,n,e));Ec(s,r,n,e)}});function Ec(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(ln(s))}}class Om{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 Am(){return new Om}const In=Am();function Mm(e,t){return new e({type:"string",...ee(t)})}function zm(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ee(t)})}function kc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ee(t)})}function xm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ee(t)})}function qm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ee(t)})}function Dm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ee(t)})}function Um(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ee(t)})}function lu(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ee(t)})}function Vm(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ee(t)})}function Fm(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ee(t)})}function Lm(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ee(t)})}function Hm(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ee(t)})}function Zm(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ee(t)})}function Km(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ee(t)})}function Gm(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ee(t)})}function Wm(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ee(t)})}function Bm(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ee(t)})}function Jm(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ee(t)})}function Qm(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ee(t)})}function Ym(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ee(t)})}function Xm(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ee(t)})}function eg(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ee(t)})}function tg(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ee(t)})}function rg(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ee(t)})}function ng(e,t){return new e({type:"string",format:"date",check:"string_format",...ee(t)})}function sg(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ee(t)})}function og(e,t){return new e({type:"string",format:"duration",check:"string_format",...ee(t)})}function ag(e,t){return new e({type:"number",checks:[],...ee(t)})}function ig(e,t){return new e({type:"number",coerce:!0,checks:[],...ee(t)})}function cg(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ee(t)})}function lg(e,t){return new e({type:"boolean",...ee(t)})}function ug(e,t){return new e({type:"undefined",...ee(t)})}function dg(e,t){return new e({type:"null",...ee(t)})}function fg(e){return new e({type:"any"})}function hg(e){return new e({type:"unknown"})}function pg(e,t){return new e({type:"never",...ee(t)})}function Pc(e,t){return new su({check:"less_than",...ee(t),value:e,inclusive:!1})}function Hs(e,t){return new su({check:"less_than",...ee(t),value:e,inclusive:!0})}function Tc(e,t){return new ou({check:"greater_than",...ee(t),value:e,inclusive:!1})}function Zs(e,t){return new ou({check:"greater_than",...ee(t),value:e,inclusive:!0})}function Rc(e,t){return new Ep({check:"multiple_of",...ee(t),value:e})}function uu(e,t){return new Pp({check:"max_length",...ee(t),maximum:e})}function ss(e,t){return new Tp({check:"min_length",...ee(t),minimum:e})}function du(e,t){return new Rp({check:"length_equals",...ee(t),length:e})}function mg(e,t){return new Cp({check:"string_format",format:"regex",...ee(t),pattern:e})}function gg(e){return new Np({check:"string_format",format:"lowercase",...ee(e)})}function _g(e){return new Ip({check:"string_format",format:"uppercase",...ee(e)})}function yg(e,t){return new jp({check:"string_format",format:"includes",...ee(t),includes:e})}function vg(e,t){return new Op({check:"string_format",format:"starts_with",...ee(t),prefix:e})}function $g(e,t){return new Ap({check:"string_format",format:"ends_with",...ee(t),suffix:e})}function mn(e){return new Mp({check:"overwrite",tx:e})}function wg(e){return mn(t=>t.normalize(e))}function bg(){return mn(e=>e.trim())}function Sg(){return mn(e=>e.toLowerCase())}function Eg(){return mn(e=>e.toUpperCase())}function kg(e,t,r){return new e({type:"array",element:t,...ee(r)})}function Pg(e,t,r){const n=ee(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function Tg(e,t,r){return new e({type:"custom",check:"custom",fn:t,...ee(r)})}const Rg=x("ZodISODateTime",(e,t)=>{Bp.init(e,t),je.init(e,t)});function fu(e){return rg(Rg,e)}const Cg=x("ZodISODate",(e,t)=>{Jp.init(e,t),je.init(e,t)});function Ng(e){return ng(Cg,e)}const Ig=x("ZodISOTime",(e,t)=>{Qp.init(e,t),je.init(e,t)});function jg(e){return sg(Ig,e)}const Og=x("ZodISODuration",(e,t)=>{Yp.init(e,t),je.init(e,t)});function Ag(e){return og(Og,e)}const Mg=(e,t)=>{Bl.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Zh(e,r)},flatten:{value:r=>Hh(e,r)},addIssue:{value:r=>e.issues.push(r)},addIssues:{value:r=>e.issues.push(...r)},isEmpty:{get(){return e.issues.length===0}}})},ks=x("ZodError",Mg,{Parent:Error}),zg=Kh(ks),xg=Gh(ks),qg=Ql(ks),Dg=Xl(ks),Ce=x("ZodType",(e,t)=>(Ee.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(r,n)=>hr(e,r,n),e.brand=()=>e,e.register=(r,n)=>(r.add(e,n),e),e.parse=(r,n)=>zg(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>qg(e,r,n),e.parseAsync=async(r,n)=>xg(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Dg(e,r,n),e.spa=e.safeParseAsync,e.refine=(r,n)=>e.check(I_(r,n)),e.superRefine=r=>e.check(j_(r)),e.overwrite=r=>e.check(mn(r)),e.optional=()=>Ie(e),e.nullable=()=>Ic(e),e.nullish=()=>Ie(Ic(e)),e.nonoptional=r=>S_(e,r),e.array=()=>L(e),e.or=r=>_e([e,r]),e.and=r=>na(e,r),e.transform=r=>ho(e,yu(r)),e.default=r=>$_(e,r),e.prefault=r=>b_(e,r),e.catch=r=>k_(e,r),e.pipe=r=>ho(e,r),e.readonly=()=>R_(e),e.describe=r=>{const n=e.clone();return In.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){var r;return(r=In.get(e))==null?void 0:r.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return In.get(e);const n=e.clone();return In.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),hu=x("_ZodString",(e,t)=>{ea.init(e,t),Ce.init(e,t);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(mg(...n)),e.includes=(...n)=>e.check(yg(...n)),e.startsWith=(...n)=>e.check(vg(...n)),e.endsWith=(...n)=>e.check($g(...n)),e.min=(...n)=>e.check(ss(...n)),e.max=(...n)=>e.check(uu(...n)),e.length=(...n)=>e.check(du(...n)),e.nonempty=(...n)=>e.check(ss(1,...n)),e.lowercase=n=>e.check(gg(n)),e.uppercase=n=>e.check(_g(n)),e.trim=()=>e.check(bg()),e.normalize=(...n)=>e.check(wg(...n)),e.toLowerCase=()=>e.check(Sg()),e.toUpperCase=()=>e.check(Eg())}),Ug=x("ZodString",(e,t)=>{ea.init(e,t),hu.init(e,t),e.email=r=>e.check(zm(Vg,r)),e.url=r=>e.check(lu(pu,r)),e.jwt=r=>e.check(tg(n_,r)),e.emoji=r=>e.check(Vm(Lg,r)),e.guid=r=>e.check(kc(Cc,r)),e.uuid=r=>e.check(xm(jn,r)),e.uuidv4=r=>e.check(qm(jn,r)),e.uuidv6=r=>e.check(Dm(jn,r)),e.uuidv7=r=>e.check(Um(jn,r)),e.nanoid=r=>e.check(Fm(Hg,r)),e.guid=r=>e.check(kc(Cc,r)),e.cuid=r=>e.check(Lm(Zg,r)),e.cuid2=r=>e.check(Hm(Kg,r)),e.ulid=r=>e.check(Zm(Gg,r)),e.base64=r=>e.check(Ym(e_,r)),e.base64url=r=>e.check(Xm(t_,r)),e.xid=r=>e.check(Km(Wg,r)),e.ksuid=r=>e.check(Gm(Bg,r)),e.ipv4=r=>e.check(Wm(Jg,r)),e.ipv6=r=>e.check(Bm(Qg,r)),e.cidrv4=r=>e.check(Jm(Yg,r)),e.cidrv6=r=>e.check(Qm(Xg,r)),e.e164=r=>e.check(eg(r_,r)),e.datetime=r=>e.check(fu(r)),e.date=r=>e.check(Ng(r)),e.time=r=>e.check(jg(r)),e.duration=r=>e.check(Ag(r))});function P(e){return Mm(Ug,e)}const je=x("ZodStringFormat",(e,t)=>{Ne.init(e,t),hu.init(e,t)}),Vg=x("ZodEmail",(e,t)=>{Up.init(e,t),je.init(e,t)}),Cc=x("ZodGUID",(e,t)=>{qp.init(e,t),je.init(e,t)}),jn=x("ZodUUID",(e,t)=>{Dp.init(e,t),je.init(e,t)}),pu=x("ZodURL",(e,t)=>{Vp.init(e,t),je.init(e,t)});function Fg(e){return lu(pu,e)}const Lg=x("ZodEmoji",(e,t)=>{Fp.init(e,t),je.init(e,t)}),Hg=x("ZodNanoID",(e,t)=>{Lp.init(e,t),je.init(e,t)}),Zg=x("ZodCUID",(e,t)=>{Hp.init(e,t),je.init(e,t)}),Kg=x("ZodCUID2",(e,t)=>{Zp.init(e,t),je.init(e,t)}),Gg=x("ZodULID",(e,t)=>{Kp.init(e,t),je.init(e,t)}),Wg=x("ZodXID",(e,t)=>{Gp.init(e,t),je.init(e,t)}),Bg=x("ZodKSUID",(e,t)=>{Wp.init(e,t),je.init(e,t)}),Jg=x("ZodIPv4",(e,t)=>{Xp.init(e,t),je.init(e,t)}),Qg=x("ZodIPv6",(e,t)=>{em.init(e,t),je.init(e,t)}),Yg=x("ZodCIDRv4",(e,t)=>{tm.init(e,t),je.init(e,t)}),Xg=x("ZodCIDRv6",(e,t)=>{rm.init(e,t),je.init(e,t)}),e_=x("ZodBase64",(e,t)=>{nm.init(e,t),je.init(e,t)}),t_=x("ZodBase64URL",(e,t)=>{om.init(e,t),je.init(e,t)}),r_=x("ZodE164",(e,t)=>{am.init(e,t),je.init(e,t)}),n_=x("ZodJWT",(e,t)=>{cm.init(e,t),je.init(e,t)}),ta=x("ZodNumber",(e,t)=>{iu.init(e,t),Ce.init(e,t),e.gt=(n,s)=>e.check(Tc(n,s)),e.gte=(n,s)=>e.check(Zs(n,s)),e.min=(n,s)=>e.check(Zs(n,s)),e.lt=(n,s)=>e.check(Pc(n,s)),e.lte=(n,s)=>e.check(Hs(n,s)),e.max=(n,s)=>e.check(Hs(n,s)),e.int=n=>e.check(Nc(n)),e.safe=n=>e.check(Nc(n)),e.positive=n=>e.check(Tc(0,n)),e.nonnegative=n=>e.check(Zs(0,n)),e.negative=n=>e.check(Pc(0,n)),e.nonpositive=n=>e.check(Hs(0,n)),e.multipleOf=(n,s)=>e.check(Rc(n,s)),e.step=(n,s)=>e.check(Rc(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 de(e){return ag(ta,e)}const s_=x("ZodNumberFormat",(e,t)=>{lm.init(e,t),ta.init(e,t)});function Nc(e){return cg(s_,e)}const o_=x("ZodBoolean",(e,t)=>{um.init(e,t),Ce.init(e,t)});function ye(e){return lg(o_,e)}const a_=x("ZodUndefined",(e,t)=>{dm.init(e,t),Ce.init(e,t)});function lo(e){return ug(a_,e)}const i_=x("ZodNull",(e,t)=>{fm.init(e,t),Ce.init(e,t)});function c_(e){return dg(i_,e)}const l_=x("ZodAny",(e,t)=>{hm.init(e,t),Ce.init(e,t)});function ra(){return fg(l_)}const u_=x("ZodUnknown",(e,t)=>{pm.init(e,t),Ce.init(e,t)});function Se(){return hg(u_)}const d_=x("ZodNever",(e,t)=>{mm.init(e,t),Ce.init(e,t)});function uo(e){return pg(d_,e)}const f_=x("ZodArray",(e,t)=>{gm.init(e,t),Ce.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(ss(r,n)),e.nonempty=r=>e.check(ss(1,r)),e.max=(r,n)=>e.check(uu(r,n)),e.length=(r,n)=>e.check(du(r,n)),e.unwrap=()=>e.element});function L(e,t){return kg(f_,e,t)}const mu=x("ZodObject",(e,t)=>{_m.init(e,t),Ce.init(e,t),Re(e,"shape",()=>t.shape),e.keyof=()=>lt(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Se()}),e.loose=()=>e.clone({...e._zod.def,catchall:Se()}),e.strict=()=>e.clone({...e._zod.def,catchall:uo()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>Uh(e,r),e.merge=r=>Vh(e,r),e.pick=r=>qh(e,r),e.omit=r=>Dh(e,r),e.partial=(...r)=>Fh(vu,e,r[0]),e.required=(...r)=>Lh($u,e,r[0])});function M(e,t){const r={type:"object",get shape(){return Ss(this,"shape",{...e}),this.shape},...ee(t)};return new mu(r)}function Be(e,t){return new mu({type:"object",get shape(){return Ss(this,"shape",{...e}),this.shape},catchall:Se(),...ee(t)})}const gu=x("ZodUnion",(e,t)=>{cu.init(e,t),Ce.init(e,t),e.options=t.options});function _e(e,t){return new gu({type:"union",options:e,...ee(t)})}const h_=x("ZodDiscriminatedUnion",(e,t)=>{gu.init(e,t),ym.init(e,t)});function _u(e,t,r){return new h_({type:"union",options:t,discriminator:e,...ee(r)})}const p_=x("ZodIntersection",(e,t)=>{vm.init(e,t),Ce.init(e,t)});function na(e,t){return new p_({type:"intersection",left:e,right:t})}const m_=x("ZodRecord",(e,t)=>{$m.init(e,t),Ce.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function ve(e,t,r){return new m_({type:"record",keyType:e,valueType:t,...ee(r)})}const fo=x("ZodEnum",(e,t)=>{wm.init(e,t),Ce.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(n,s)=>{const o={};for(const a of n)if(r.has(a))o[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new fo({...t,checks:[],...ee(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 fo({...t,checks:[],...ee(s),entries:o})}});function lt(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new fo({type:"enum",entries:r,...ee(t)})}const g_=x("ZodLiteral",(e,t)=>{bm.init(e,t),Ce.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function j(e,t){return new g_({type:"literal",values:Array.isArray(e)?e:[e],...ee(t)})}const __=x("ZodTransform",(e,t)=>{Sm.init(e,t),Ce.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=o=>{if(typeof o=="string")r.issues.push(ln(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(ln(a))}};const s=t.transform(r.value,r);return s instanceof Promise?s.then(o=>(r.value=o,r)):(r.value=s,r)}});function yu(e){return new __({type:"transform",transform:e})}const vu=x("ZodOptional",(e,t)=>{Em.init(e,t),Ce.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ie(e){return new vu({type:"optional",innerType:e})}const y_=x("ZodNullable",(e,t)=>{km.init(e,t),Ce.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ic(e){return new y_({type:"nullable",innerType:e})}const v_=x("ZodDefault",(e,t)=>{Pm.init(e,t),Ce.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function $_(e,t){return new v_({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const w_=x("ZodPrefault",(e,t)=>{Tm.init(e,t),Ce.init(e,t),e.unwrap=()=>e._zod.def.innerType});function b_(e,t){return new w_({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const $u=x("ZodNonOptional",(e,t)=>{Rm.init(e,t),Ce.init(e,t),e.unwrap=()=>e._zod.def.innerType});function S_(e,t){return new $u({type:"nonoptional",innerType:e,...ee(t)})}const E_=x("ZodCatch",(e,t)=>{Cm.init(e,t),Ce.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function k_(e,t){return new E_({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const P_=x("ZodPipe",(e,t)=>{Nm.init(e,t),Ce.init(e,t),e.in=t.in,e.out=t.out});function ho(e,t){return new P_({type:"pipe",in:e,out:t})}const T_=x("ZodReadonly",(e,t)=>{Im.init(e,t),Ce.init(e,t)});function R_(e){return new T_({type:"readonly",innerType:e})}const wu=x("ZodCustom",(e,t)=>{jm.init(e,t),Ce.init(e,t)});function C_(e){const t=new it({check:"custom"});return t._zod.check=e,t}function N_(e,t){return Pg(wu,e??(()=>!0),t)}function I_(e,t={}){return Tg(wu,e,t)}function j_(e){const t=C_(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(ln(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(ln(s))}},e(r.value,r)));return t}function bu(e,t){return ho(yu(e),t)}const O_={custom:"custom"};function A_(e){return ig(ta,e)}const Ps="2025-11-25",M_=[Ps,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],er="io.modelcontextprotocol/related-task",Ts="2.0",Ue=N_(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Su=_e([P(),de().int()]),Eu=P();Be({ttl:de().optional(),pollInterval:de().optional()});const z_=M({ttl:de().optional()}),x_=M({taskId:P()}),sa=Be({progressToken:Su.optional(),[er]:x_.optional()}),ut=M({_meta:sa.optional()}),gn=ut.extend({task:z_.optional()}),q_=e=>gn.safeParse(e).success,Je=M({method:P(),params:ut.loose().optional()}),ht=M({_meta:sa.optional()}),pt=M({method:P(),params:ht.loose().optional()}),Qe=Be({_meta:sa.optional()}),_n=_e([P(),de().int()]),ku=M({jsonrpc:j(Ts),id:_n,...Je.shape}).strict(),po=e=>ku.safeParse(e).success,Pu=M({jsonrpc:j(Ts),...pt.shape}).strict(),D_=e=>Pu.safeParse(e).success,oa=M({jsonrpc:j(Ts),id:_n,result:Qe}).strict(),Gr=e=>oa.safeParse(e).success;var ae;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(ae||(ae={}));const aa=M({jsonrpc:j(Ts),id:_n.optional(),error:M({code:de().int(),message:P(),data:Se().optional()})}).strict(),U_=e=>aa.safeParse(e).success,Zn=_e([ku,Pu,oa,aa]);_e([oa,aa]);const wr=Qe.strict(),V_=ht.extend({requestId:_n.optional(),reason:P().optional()}),ia=pt.extend({method:j("notifications/cancelled"),params:V_}),F_=M({src:P(),mimeType:P().optional(),sizes:L(P()).optional(),theme:lt(["light","dark"]).optional()}),yn=M({icons:L(F_).optional()}),Rr=M({name:P(),title:P().optional()}),Rs=Rr.extend({...Rr.shape,...yn.shape,version:P(),websiteUrl:P().optional(),description:P().optional()}),L_=na(M({applyDefaults:ye().optional()}),ve(P(),Se())),H_=bu(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,na(M({form:L_.optional(),url:Ue.optional()}),ve(P(),Se()).optional())),Z_=Be({list:Ue.optional(),cancel:Ue.optional(),requests:Be({sampling:Be({createMessage:Ue.optional()}).optional(),elicitation:Be({create:Ue.optional()}).optional()}).optional()}),K_=Be({list:Ue.optional(),cancel:Ue.optional(),requests:Be({tools:Be({call:Ue.optional()}).optional()}).optional()}),G_=M({experimental:ve(P(),Ue).optional(),sampling:M({context:Ue.optional(),tools:Ue.optional()}).optional(),elicitation:H_.optional(),roots:M({listChanged:ye().optional()}).optional(),tasks:Z_.optional(),extensions:ve(P(),Ue).optional()}),W_=ut.extend({protocolVersion:P(),capabilities:G_,clientInfo:Rs}),B_=Je.extend({method:j("initialize"),params:W_}),J_=M({experimental:ve(P(),Ue).optional(),logging:Ue.optional(),completions:Ue.optional(),prompts:M({listChanged:ye().optional()}).optional(),resources:M({subscribe:ye().optional(),listChanged:ye().optional()}).optional(),tools:M({listChanged:ye().optional()}).optional(),tasks:K_.optional(),extensions:ve(P(),Ue).optional()}),Tu=Qe.extend({protocolVersion:P(),capabilities:J_,serverInfo:Rs,instructions:P().optional()}),Ru=pt.extend({method:j("notifications/initialized"),params:ht.optional()}),Q_=e=>Ru.safeParse(e).success,Cs=Je.extend({method:j("ping"),params:ut.optional()}),Y_=M({progress:de(),total:Ie(de()),message:Ie(P())}),X_=M({...ht.shape,...Y_.shape,progressToken:Su}),ca=pt.extend({method:j("notifications/progress"),params:X_}),ey=ut.extend({cursor:Eu.optional()}),vn=Je.extend({params:ey.optional()}),$n=Qe.extend({nextCursor:Eu.optional()}),ty=lt(["working","input_required","completed","failed","cancelled"]),wn=M({taskId:P(),status:ty,ttl:_e([de(),c_()]),createdAt:P(),lastUpdatedAt:P(),pollInterval:Ie(de()),statusMessage:Ie(P())}),un=Qe.extend({task:wn}),ry=ht.merge(wn),os=pt.extend({method:j("notifications/tasks/status"),params:ry}),la=Je.extend({method:j("tasks/get"),params:ut.extend({taskId:P()})}),ua=Qe.merge(wn),da=Je.extend({method:j("tasks/result"),params:ut.extend({taskId:P()})});Qe.loose();const fa=vn.extend({method:j("tasks/list")}),ha=$n.extend({tasks:L(wn)}),pa=Je.extend({method:j("tasks/cancel"),params:ut.extend({taskId:P()})}),ny=Qe.merge(wn),Cu=M({uri:P(),mimeType:Ie(P()),_meta:ve(P(),Se()).optional()}),Nu=Cu.extend({text:P()}),ma=P().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Iu=Cu.extend({blob:ma}),bn=lt(["user","assistant"]),Or=M({audience:L(bn).optional(),priority:de().min(0).max(1).optional(),lastModified:fu({offset:!0}).optional()}),ju=M({...Rr.shape,...yn.shape,uri:P(),description:Ie(P()),mimeType:Ie(P()),size:Ie(de()),annotations:Or.optional(),_meta:Ie(Be({}))}),sy=M({...Rr.shape,...yn.shape,uriTemplate:P(),description:Ie(P()),mimeType:Ie(P()),annotations:Or.optional(),_meta:Ie(Be({}))}),Ou=vn.extend({method:j("resources/list")}),ga=$n.extend({resources:L(ju)}),Au=vn.extend({method:j("resources/templates/list")}),_a=$n.extend({resourceTemplates:L(sy)}),ya=ut.extend({uri:P()}),oy=ya,Mu=Je.extend({method:j("resources/read"),params:oy}),va=Qe.extend({contents:L(_e([Nu,Iu]))}),$a=pt.extend({method:j("notifications/resources/list_changed"),params:ht.optional()}),ay=ya,iy=Je.extend({method:j("resources/subscribe"),params:ay}),cy=ya,ly=Je.extend({method:j("resources/unsubscribe"),params:cy}),uy=ht.extend({uri:P()}),dy=pt.extend({method:j("notifications/resources/updated"),params:uy}),fy=M({name:P(),description:Ie(P()),required:Ie(ye())}),hy=M({...Rr.shape,...yn.shape,description:Ie(P()),arguments:Ie(L(fy)),_meta:Ie(Be({}))}),zu=vn.extend({method:j("prompts/list")}),wa=$n.extend({prompts:L(hy)}),py=ut.extend({name:P(),arguments:ve(P(),P()).optional()}),my=Je.extend({method:j("prompts/get"),params:py}),ba=M({type:j("text"),text:P(),annotations:Or.optional(),_meta:ve(P(),Se()).optional()}),Sa=M({type:j("image"),data:ma,mimeType:P(),annotations:Or.optional(),_meta:ve(P(),Se()).optional()}),Ea=M({type:j("audio"),data:ma,mimeType:P(),annotations:Or.optional(),_meta:ve(P(),Se()).optional()}),gy=M({type:j("tool_use"),name:P(),id:P(),input:ve(P(),Se()),_meta:ve(P(),Se()).optional()}),xu=M({type:j("resource"),resource:_e([Nu,Iu]),annotations:Or.optional(),_meta:ve(P(),Se()).optional()}),qu=ju.extend({type:j("resource_link")}),Sn=_e([ba,Sa,Ea,qu,xu]),_y=M({role:bn,content:Sn}),Du=Qe.extend({description:P().optional(),messages:L(_y)}),ka=pt.extend({method:j("notifications/prompts/list_changed"),params:ht.optional()}),yy=M({title:P().optional(),readOnlyHint:ye().optional(),destructiveHint:ye().optional(),idempotentHint:ye().optional(),openWorldHint:ye().optional()}),vy=M({taskSupport:lt(["required","optional","forbidden"]).optional()}),Pa=M({...Rr.shape,...yn.shape,description:P().optional(),inputSchema:M({type:j("object"),properties:ve(P(),Ue).optional(),required:L(P()).optional()}).catchall(Se()),outputSchema:M({type:j("object"),properties:ve(P(),Ue).optional(),required:L(P()).optional()}).catchall(Se()).optional(),annotations:yy.optional(),execution:vy.optional(),_meta:ve(P(),Se()).optional()}),$y=vn.extend({method:j("tools/list")}),Ta=$n.extend({tools:L(Pa)}),ir=Qe.extend({content:L(Sn).default([]),structuredContent:ve(P(),Se()).optional(),isError:ye().optional()});ir.or(Qe.extend({toolResult:Se()}));const wy=gn.extend({name:P(),arguments:ve(P(),Se()).optional()}),Uu=Je.extend({method:j("tools/call"),params:wy}),Ra=pt.extend({method:j("notifications/tools/list_changed"),params:ht.optional()}),by=M({autoRefresh:ye().default(!0),debounceMs:de().int().nonnegative().default(300)}),Vu=lt(["debug","info","notice","warning","error","critical","alert","emergency"]),Sy=ut.extend({level:Vu}),Ey=Je.extend({method:j("logging/setLevel"),params:Sy}),ky=ht.extend({level:Vu,logger:P().optional(),data:Se()}),Fu=pt.extend({method:j("notifications/message"),params:ky}),Py=M({name:P().optional()}),Ty=M({hints:L(Py).optional(),costPriority:de().min(0).max(1).optional(),speedPriority:de().min(0).max(1).optional(),intelligencePriority:de().min(0).max(1).optional()}),Ry=M({mode:lt(["auto","required","none"]).optional()}),Cy=M({type:j("tool_result"),toolUseId:P().describe("The unique identifier for the corresponding tool call."),content:L(Sn).default([]),structuredContent:M({}).loose().optional(),isError:ye().optional(),_meta:ve(P(),Se()).optional()}),Ny=_u("type",[ba,Sa,Ea]),as=_u("type",[ba,Sa,Ea,gy,Cy]),Iy=M({role:bn,content:_e([as,L(as)]),_meta:ve(P(),Se()).optional()}),jy=gn.extend({messages:L(Iy),modelPreferences:Ty.optional(),systemPrompt:P().optional(),includeContext:lt(["none","thisServer","allServers"]).optional(),temperature:de().optional(),maxTokens:de().int(),stopSequences:L(P()).optional(),metadata:Ue.optional(),tools:L(Pa).optional(),toolChoice:Ry.optional()}),Ca=Je.extend({method:j("sampling/createMessage"),params:jy}),Lu=Qe.extend({model:P(),stopReason:Ie(lt(["endTurn","stopSequence","maxTokens"]).or(P())),role:bn,content:Ny}),Hu=Qe.extend({model:P(),stopReason:Ie(lt(["endTurn","stopSequence","maxTokens","toolUse"]).or(P())),role:bn,content:_e([as,L(as)])}),Oy=M({type:j("boolean"),title:P().optional(),description:P().optional(),default:ye().optional()}),Ay=M({type:j("string"),title:P().optional(),description:P().optional(),minLength:de().optional(),maxLength:de().optional(),format:lt(["email","uri","date","date-time"]).optional(),default:P().optional()}),My=M({type:lt(["number","integer"]),title:P().optional(),description:P().optional(),minimum:de().optional(),maximum:de().optional(),default:de().optional()}),zy=M({type:j("string"),title:P().optional(),description:P().optional(),enum:L(P()),default:P().optional()}),xy=M({type:j("string"),title:P().optional(),description:P().optional(),oneOf:L(M({const:P(),title:P()})),default:P().optional()}),qy=M({type:j("string"),title:P().optional(),description:P().optional(),enum:L(P()),enumNames:L(P()).optional(),default:P().optional()}),Dy=_e([zy,xy]),Uy=M({type:j("array"),title:P().optional(),description:P().optional(),minItems:de().optional(),maxItems:de().optional(),items:M({type:j("string"),enum:L(P())}),default:L(P()).optional()}),Vy=M({type:j("array"),title:P().optional(),description:P().optional(),minItems:de().optional(),maxItems:de().optional(),items:M({anyOf:L(M({const:P(),title:P()}))}),default:L(P()).optional()}),Fy=_e([Uy,Vy]),Ly=_e([qy,Dy,Fy]),Hy=_e([Ly,Oy,Ay,My]),Zy=gn.extend({mode:j("form").optional(),message:P(),requestedSchema:M({type:j("object"),properties:ve(P(),Hy),required:L(P()).optional()})}),Ky=gn.extend({mode:j("url"),message:P(),elicitationId:P(),url:P().url()}),Gy=_e([Zy,Ky]),Zu=Je.extend({method:j("elicitation/create"),params:Gy}),Wy=ht.extend({elicitationId:P()}),By=pt.extend({method:j("notifications/elicitation/complete"),params:Wy}),Ku=Qe.extend({action:lt(["accept","decline","cancel"]),content:bu(e=>e===null?void 0:e,ve(P(),_e([P(),de(),ye(),L(P())])).optional())}),Jy=M({type:j("ref/resource"),uri:P()}),Qy=M({type:j("ref/prompt"),name:P()}),Yy=ut.extend({ref:_e([Qy,Jy]),argument:M({name:P(),value:P()}),context:M({arguments:ve(P(),P()).optional()}).optional()}),Xy=Je.extend({method:j("completion/complete"),params:Yy}),Gu=Qe.extend({completion:Be({values:L(P()).max(100),total:Ie(de().int()),hasMore:Ie(ye())})}),ev=M({uri:P().startsWith("file://"),name:P().optional(),_meta:ve(P(),Se()).optional()}),tv=Je.extend({method:j("roots/list"),params:ut.optional()}),rv=Qe.extend({roots:L(ev)}),nv=pt.extend({method:j("notifications/roots/list_changed"),params:ht.optional()});_e([Cs,B_,Xy,Ey,my,zu,Ou,Au,Mu,iy,ly,Uu,$y,la,da,fa,pa]);_e([ia,ca,Ru,nv,os]);_e([wr,Lu,Hu,Ku,rv,ua,ha,un]);_e([Cs,Ca,Zu,tv,la,da,fa,pa]);_e([ia,ca,Fu,dy,$a,Ra,ka,os,By]);_e([wr,Tu,Gu,Du,wa,ga,_a,va,ir,Ta,ua,ha,un]);class ne extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===ae.UrlElicitationRequired&&n){const s=n;if(s.elicitations)return new sv(s.elicitations,r)}return new ne(t,r,n)}}class sv extends ne{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(ae.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){var t;return((t=this.data)==null?void 0:t.elicitations)??[]}}function Na(e){return!!e._zod}function Dt(e,t){return Na(e)?Yl(e,t):e.safeParse(t)}function Wu(e){var r,n;if(!e)return;let t;if(Na(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 Bu(e){var s;if(Na(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 Wt(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function jc(e){const t=Wu(e),r=t==null?void 0:t.method;if(!r)throw new Error("Schema is missing a method literal");const n=Bu(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Oc(e,t){const r=Dt(e,t);if(!r.success)throw r.error;return r.data}const ov=6e4;class Ju{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(ia,r=>{this._oncancel(r)}),this.setNotificationHandler(ca,r=>{this._onprogress(r)}),this.setRequestHandler(Cs,r=>({})),this._taskStore=t==null?void 0:t.taskStore,this._taskMessageQueue=t==null?void 0:t.taskMessageQueue,this._taskStore&&(this.setRequestHandler(la,async(r,n)=>{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new ne(ae.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(da,async(r,n)=>{const s=async()=>{var i;const o=r.params.taskId;if(this._taskMessageQueue){let c;for(;c=await this._taskMessageQueue.dequeue(o,n.sessionId);){if(c.type==="response"||c.type==="error"){const l=c.message,d=l.id,f=this._requestResolvers.get(d);if(f)if(this._requestResolvers.delete(d),c.type==="response")f(l);else{const _=l,g=new ne(_.error.code,_.error.message,_.error.data);f(g)}else{const _=c.type==="response"?"Response":"Error";this._onerror(new Error(`${_} 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 ne(ae.InvalidParams,`Task not found: ${o}`);if(!Wt(a.status))return await this._waitForTaskUpdate(o,n.signal),await s();if(Wt(a.status)){const c=await this._taskStore.getTaskResult(o,n.sessionId);return this._clearTaskQueue(o),{...c,_meta:{...c._meta,[er]:{taskId:o}}}}return await s()};return await s()}),this.setRequestHandler(fa,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 ne(ae.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(pa,async(r,n)=>{try{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new ne(ae.InvalidParams,`Task not found: ${r.params.taskId}`);if(Wt(s.status))throw new ne(ae.InvalidParams,`Cannot cancel task in terminal status: ${s.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);const o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new ne(ae.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(s){throw s instanceof ne?s:new ne(ae.InvalidRequest,`Failed to cancel task: ${s instanceof Error?s.message:String(s)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;const r=this._requestHandlerAbortControllers.get(t.params.requestId);r==null||r.abort(t.params.reason)}_setupTimeout(t,r,n,s,o=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(s,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:o,onTimeout:s})}_resetTimeout(t){const r=this._timeoutInfo.get(t);if(!r)return!1;const n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),ne.fromError(ae.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){const r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){var o,a,i;if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;const r=(o=this.transport)==null?void 0:o.onclose;this._transport.onclose=()=>{r==null||r(),this._onclose()};const n=(a=this.transport)==null?void 0:a.onerror;this._transport.onerror=c=>{n==null||n(c),this._onerror(c)};const s=(i=this._transport)==null?void 0:i.onmessage;this._transport.onmessage=(c,l)=>{s==null||s(c,l),Gr(c)||U_(c)?this._onresponse(c):po(c)?this._onrequest(c,l):D_(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=ne.fromError(ae.ConnectionClosed,"Connection closed");this._transport=void 0,(n=this.onclose)==null||n.call(this);for(const s of t.values())s(r)}_onerror(t){var r;(r=this.onerror)==null||r.call(this,t)}_onnotification(t){const r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){var d,f,_,g;const n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,s=this._transport,o=(_=(f=(d=t.params)==null?void 0:d._meta)==null?void 0:f[er])==null?void 0:_.taskId;if(n===void 0){const m={jsonrpc:"2.0",id:t.id,error:{code:ae.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:m,timestamp:Date.now()},s==null?void 0:s.sessionId).catch(v=>this._onerror(new Error(`Failed to enqueue error response: ${v}`))):s==null||s.send(m).catch(v=>this._onerror(new Error(`Failed to send an error response: ${v}`)));return}const a=new AbortController;this._requestHandlerAbortControllers.set(t.id,a);const i=q_(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,s==null?void 0:s.sessionId):void 0,l={signal:a.signal,sessionId:s==null?void 0:s.sessionId,_meta:(g=t.params)==null?void 0:g._meta,sendNotification:async m=>{if(a.signal.aborted)return;const v={relatedRequestId:t.id};o&&(v.relatedTask={taskId:o}),await this.notification(m,v)},sendRequest:async(m,v,y)=>{var S;if(a.signal.aborted)throw new ne(ae.ConnectionClosed,"Request was cancelled");const h={...y,relatedRequestId:t.id};o&&!h.relatedTask&&(h.relatedTask={taskId:o});const $=((S=h.relatedTask)==null?void 0:S.taskId)??o;return $&&c&&await c.updateTaskStatus($,"input_required"),await this.request(m,v,h)},authInfo:r==null?void 0:r.authInfo,requestId:t.id,requestInfo:r==null?void 0:r.requestInfo,taskId:o,taskStore:c,taskRequestedTtl:i==null?void 0:i.ttl,closeSSEStream:r==null?void 0:r.closeSSEStream,closeStandaloneSSEStream:r==null?void 0:r.closeStandaloneSSEStream};Promise.resolve().then(()=>{i&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,l)).then(async m=>{if(a.signal.aborted)return;const v={result:m,jsonrpc:"2.0",id:t.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:v,timestamp:Date.now()},s==null?void 0:s.sessionId):await(s==null?void 0:s.send(v))},async m=>{if(a.signal.aborted)return;const v={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(m.code)?m.code:ae.InternalError,message:m.message??"Internal error",...m.data!==void 0&&{data:m.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:v,timestamp:Date.now()},s==null?void 0:s.sessionId):await(s==null?void 0:s.send(v))}).catch(m=>this._onerror(new Error(`Failed to send response: ${m}`))).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),Gr(t))n(t);else{const a=new ne(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(Gr(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),Gr(t))s(t);else{const a=ne.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 ne?c:new ne(ae.InternalError,String(c))}}return}let o;try{const c=await this.request(t,un,n);if(c.task)o=c.task.taskId,yield{type:"taskCreated",task:c.task};else throw new ne(ae.InternalError,"Task creation did not return a task");for(;;){const l=await this.getTask({taskId:o},n);if(yield{type:"taskStatus",task:l},Wt(l.status)){l.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)}:l.status==="failed"?yield{type:"error",error:new ne(ae.InternalError,`Task ${o} failed`)}:l.status==="cancelled"&&(yield{type:"error",error:new ne(ae.InternalError,`Task ${o} was cancelled`)});return}if(l.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)};return}const d=l.pollInterval??((a=this._options)==null?void 0:a.defaultTaskPollInterval)??1e3;await new Promise(f=>setTimeout(f,d)),(i=n==null?void 0:n.signal)==null||i.throwIfAborted()}}catch(c){yield{type:"error",error:c instanceof ne?c:new ne(ae.InternalError,String(c))}}}request(t,r,n){const{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a,task:i,relatedTask:c}=n??{};return new Promise((l,d)=>{var $,S,T,k,I;const f=z=>{d(z)};if(!this._transport){f(new Error("Not connected"));return}if((($=this._options)==null?void 0:$.enforceStrictCapabilities)===!0)try{this.assertCapabilityForMethod(t.method),i&&this.assertTaskCapability(t.method)}catch(z){f(z);return}(S=n==null?void 0:n.signal)==null||S.throwIfAborted();const _=this._requestMessageId++,g={...t,jsonrpc:"2.0",id:_};n!=null&&n.onprogress&&(this._progressHandlers.set(_,n.onprogress),g.params={...t.params,_meta:{...((T=t.params)==null?void 0:T._meta)||{},progressToken:_}}),i&&(g.params={...g.params,task:i}),c&&(g.params={...g.params,_meta:{...((k=g.params)==null?void 0:k._meta)||{},[er]:c}});const m=z=>{var G;this._responseHandlers.delete(_),this._progressHandlers.delete(_),this._cleanupTimeout(_),(G=this._transport)==null||G.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:_,reason:String(z)}},{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a}).catch(Z=>this._onerror(new Error(`Failed to send cancellation: ${Z}`)));const F=z instanceof ne?z:new ne(ae.RequestTimeout,String(z));d(F)};this._responseHandlers.set(_,z=>{var F;if(!((F=n==null?void 0:n.signal)!=null&&F.aborted)){if(z instanceof Error)return d(z);try{const G=Dt(r,z.result);G.success?l(G.data):d(G.error)}catch(G){d(G)}}}),(I=n==null?void 0:n.signal)==null||I.addEventListener("abort",()=>{var z;m((z=n==null?void 0:n.signal)==null?void 0:z.reason)});const v=(n==null?void 0:n.timeout)??ov,y=()=>m(ne.fromError(ae.RequestTimeout,"Request timed out",{timeout:v}));this._setupTimeout(_,v,n==null?void 0:n.maxTotalTimeout,y,(n==null?void 0:n.resetTimeoutOnProgress)??!1);const h=c==null?void 0:c.taskId;if(h){const z=F=>{const G=this._responseHandlers.get(_);G?G(F):this._onerror(new Error(`Response handler missing for side-channeled request ${_}`))};this._requestResolvers.set(_,z),this._enqueueTaskMessage(h,{type:"request",message:g,timestamp:Date.now()}).catch(F=>{this._cleanupTimeout(_),d(F)})}else this._transport.send(g,{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a}).catch(z=>{this._cleanupTimeout(_),d(z)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},ua,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},ha,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},ny,r)}async notification(t,r){var i,c,l,d;if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);const n=(i=r==null?void 0:r.relatedTask)==null?void 0:i.taskId;if(n){const f={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...((c=t.params)==null?void 0:c._meta)||{},[er]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:f,timestamp:Date.now()});return}if((((l=this._options)==null?void 0:l.debouncedNotificationMethods)??[]).includes(t.method)&&!t.params&&!(r!=null&&r.relatedRequestId)&&!(r!=null&&r.relatedTask)){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{var _,g;if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let f={...t,jsonrpc:"2.0"};r!=null&&r.relatedTask&&(f={...f,params:{...f.params,_meta:{...((_=f.params)==null?void 0:_._meta)||{},[er]:r.relatedTask}}}),(g=this._transport)==null||g.send(f,r).catch(m=>this._onerror(m))});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)||{},[er]:r.relatedTask}}}),await this._transport.send(a,r)}setRequestHandler(t,r){const n=jc(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,o)=>{const a=Oc(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=jc(t);this._notificationHandlers.set(n,s=>{const o=Oc(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"&&po(s.message)){const o=s.message.id,a=this._requestResolvers.get(o);a?(a(new ne(ae.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r){var s,o;let n=((s=this._options)==null?void 0:s.defaultTaskPollInterval)??1e3;try{const a=await((o=this._taskStore)==null?void 0:o.getTask(t));a!=null&&a.pollInterval&&(n=a.pollInterval)}catch{}return new Promise((a,i)=>{if(r.aborted){i(new ne(ae.InvalidRequest,"Request cancelled"));return}const c=setTimeout(a,n);r.addEventListener("abort",()=>{clearTimeout(c),i(new ne(ae.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){const n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async s=>{if(!t)throw new Error("No request provided");return await n.createTask(s,t.id,{method:t.method,params:t.params},r)},getTask:async s=>{const o=await n.getTask(s,r);if(!o)throw new ne(ae.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(s,o,a)=>{await n.storeTaskResult(s,o,a,r);const i=await n.getTask(s,r);if(i){const c=os.parse({method:"notifications/tasks/status",params:i});await this.notification(c),Wt(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 ne(ae.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(Wt(i.status))throw new ne(ae.InvalidParams,`Cannot update task "${s}" from terminal status "${i.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(s,o,a,r);const c=await n.getTask(s,r);if(c){const l=os.parse({method:"notifications/tasks/status",params:c});await this.notification(l),Wt(c.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>n.listTasks(s,r)}}}function Ac(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function av(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];Ac(a)&&Ac(o)?r[s]={...a,...o}:r[s]=o}return r}(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});class iv extends Ju{constructor(){super(...arguments);fe(this,"_registeredMethods",new Set);fe(this,"_eventSlots",new Map);fe(this,"setRequestHandler",(r,n)=>{this._assertMethodNotRegistered(r,"setRequestHandler"),super.setRequestHandler(r,n)});fe(this,"setNotificationHandler",(r,n)=>{this._assertMethodNotRegistered(r,"setNotificationHandler"),super.setNotificationHandler(r,n)});fe(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 Qu="2026-01-26",cv="ui/notifications/tool-input-partial",lv=_e([j("light"),j("dark")]).describe("Color theme preference for the host environment."),dn=_e([j("inline"),j("fullscreen"),j("pip")]).describe("Display mode for UI presentation."),uv=_e([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."),dv=ve(uv.describe(`Style variables for theming MCP apps. - -Individual style keys are optional - hosts may provide any subset of these values. -Values are strings containing CSS values (colors, sizes, font stacks, etc.). - -Note: This type uses \`Record\` rather than \`Partial>\` -for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),_e([P(),lo()]).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.`),fv=M({method:j("ui/open-link"),params:M({url:P().describe("URL to open in the host's browser")})});M({isError:ye().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough();M({isError:ye().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough();M({isError:ye().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();var hv=M({method:j("ui/notifications/sandbox-proxy-ready"),params:M({})}),Ia=M({connectDomains:L(P()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket). - -- Maps to CSP \`connect-src\` directive -- Empty or omitted → no network connections (secure default)`),resourceDomains:L(P()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:L(P()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:L(P()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),ja=M({camera:M({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:M({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:M({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:M({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),pv=M({method:j("ui/notifications/size-changed"),params:M({width:de().optional().describe("New width in pixels."),height:de().optional().describe("New height in pixels.")})});M({method:j("ui/notifications/tool-input"),params:M({arguments:ve(P(),Se().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})});M({method:j("ui/notifications/tool-input-partial"),params:M({arguments:ve(P(),Se().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})});M({method:j("ui/notifications/tool-cancelled"),params:M({reason:P().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})});var mv=M({fonts:P().optional()}),gv=M({variables:dv.optional().describe("CSS variables for theming the app."),css:mv.optional().describe("CSS blocks that apps can inject.")});M({method:j("ui/resource-teardown"),params:M({})});var _v=ve(P(),Se()),Mc=M({text:M({}).optional().describe("Host supports text content blocks."),image:M({}).optional().describe("Host supports image content blocks."),audio:M({}).optional().describe("Host supports audio content blocks."),resource:M({}).optional().describe("Host supports resource content blocks."),resourceLink:M({}).optional().describe("Host supports resource link content blocks."),structuredContent:M({}).optional().describe("Host supports structured content.")}),yv=M({method:j("ui/notifications/request-teardown"),params:M({}).optional()}),vv=M({experimental:ve(P(),ve(P(),ra()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:M({}).optional().describe("Host supports opening external URLs."),downloadFile:M({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:M({listChanged:ye().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:M({listChanged:ye().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:M({}).optional().describe("Host accepts log messages."),sandbox:M({permissions:ja.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:Ia.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:Mc.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:Mc.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:M({tools:M({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.")}).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")}),$v=M({experimental:ve(P(),ve(P(),ra()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:M({listChanged:ye().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:L(dn).optional().describe("Display modes the app supports.")}),wv=M({method:j("ui/notifications/initialized"),params:M({}).optional()});M({csp:Ia.optional().describe("Content Security Policy configuration for UI resources."),permissions:ja.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:ye().optional().describe(`Visual boundary preference - true if view prefers a visible border. - -Boolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary. - -- \`true\`: request visible border + background -- \`false\`: request no visible border + background -- omitted: host decides border`)});var zc=M({method:j("ui/request-display-mode"),params:M({mode:dn.describe("The display mode being requested.")})});M({mode:dn.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough();var bv=_e([j("model"),j("app")]).describe("Tool visibility scope - who can access the tool.");M({resourceUri:P().optional(),visibility:L(bv).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:uo().optional(),permissions:uo().optional()});M({mimeTypes:L(P()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});var Sv=M({method:j("ui/download-file"),params:M({contents:L(_e([xu,qu])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),Ev=M({method:j("ui/message"),params:M({role:j("user").describe('Message role, currently only "user" is supported.'),content:L(Sn).describe("Message content blocks (text, image, etc.).")})});M({method:j("ui/notifications/sandbox-resource-ready"),params:M({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:Ia.optional().describe("CSP configuration from resource metadata."),permissions:ja.optional().describe("Sandbox permissions from resource metadata.")})});M({method:j("ui/notifications/tool-result"),params:ir.describe("Standard MCP tool execution result.")});var Yu=M({toolInfo:M({id:_n.optional().describe("JSON-RPC id of the tools/call request."),tool:Pa.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:lv.optional().describe("Current color theme preference."),styles:gv.optional().describe("Style configuration for theming the app."),displayMode:dn.optional().describe("How the UI is currently displayed."),availableDisplayModes:L(dn).optional().describe("Display modes the host supports."),containerDimensions:_e([M({height:de().describe("Fixed container height in pixels.")}),M({maxHeight:_e([de(),lo()]).optional().describe("Maximum container height in pixels.")})]).and(_e([M({width:de().describe("Fixed container width in pixels.")}),M({maxWidth:_e([de(),lo()]).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:_e([j("web"),j("desktop"),j("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:M({touch:ye().optional().describe("Whether the device supports touch input."),hover:ye().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:M({top:de().describe("Top safe area inset in pixels."),right:de().describe("Right safe area inset in pixels."),bottom:de().describe("Bottom safe area inset in pixels."),left:de().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough();M({method:j("ui/notifications/host-context-changed"),params:Yu.describe("Partial context update containing only changed fields.")});var kv=M({method:j("ui/update-model-context"),params:M({content:L(Sn).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:ve(P(),Se().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),Pv=M({method:j("ui/initialize"),params:M({appInfo:Rs.describe("App identification (name and version)."),appCapabilities:$v.describe("Features and capabilities this app provides."),protocolVersion:P().describe("Protocol version this app supports.")})});M({protocolVersion:P().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Rs.describe("Host application identification and version."),hostCapabilities:vv.describe("Features and capabilities provided by the host."),hostContext:Yu.describe("Rich context about the host environment.")}).passthrough();class Tv{constructor(t=window.parent,r){fe(this,"eventTarget");fe(this,"eventSource");fe(this,"messageListener");fe(this,"onclose");fe(this,"onerror");fe(this,"onmessage");fe(this,"sessionId");fe(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=Zn.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!==cv&&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 Rv=[Qu];class Cv extends iv{constructor(r,n,s,o){super(o);fe(this,"_client");fe(this,"_hostInfo");fe(this,"_capabilities");fe(this,"_appCapabilities");fe(this,"_hostContext",{});fe(this,"_appInfo");fe(this,"_initializedReceived",!1);fe(this,"_baseReplaceRequestHandler",this.replaceRequestHandler);fe(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)))});fe(this,"eventSchemas",{sizechange:pv,sandboxready:hv,initialized:wv,requestteardown:yv,loggingmessage:Fu});fe(this,"onping");fe(this,"_onmessage");fe(this,"_onopenlink");fe(this,"_ondownloadfile");fe(this,"_onrequestdisplaymode");fe(this,"_onupdatemodelcontext");fe(this,"_oncalltool");fe(this,"_onlistresources");fe(this,"_onlistresourcetemplates");fe(this,"_onreadresource");fe(this,"_onlistprompts");fe(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(Pv,a=>this._oninitialize(a)),this.setRequestHandler(Cs,(a,i)=>{var c;return(c=this.onping)==null||c.call(this,a.params,i),{}}),this.replaceRequestHandler(zc,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(Ev,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(fv,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(Sv,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(zc,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(kv,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(Uu,async(n,s)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,s)})}set oncreatesamplingmessage(r){this.setRequestHandler(Ca,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(Ou,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(Au,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(Mu,async(n,s)=>{if(!this._onreadresource)throw Error("No onreadresource handler set");return this._onreadresource(n.params,s)})}sendResourceListChanged(r={}){return this.notification({method:"notifications/resources/list_changed",params:r})}get onlistprompts(){return this._onlistprompts}set onlistprompts(r){this.warnIfRequestHandlerReplaced("onlistprompts",this._onlistprompts,r),this._onlistprompts=r,this.replaceRequestHandler(zu,async(n,s)=>{if(!this._onlistprompts)throw Error("No onlistprompts handler set");return this._onlistprompts(n.params,s)})}sendPromptListChanged(r={}){return this.notification({method:"notifications/prompts/list_changed",params:r})}assertCapabilityForMethod(r){}assertRequestHandlerCapability(r){}assertNotificationCapability(r){}assertTaskCapability(r){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(r){throw Error("Task handlers are not supported in MCP Apps")}getCapabilities(){return this._capabilities}async _oninitialize(r){let n=r.params.protocolVersion;return this._appInfo!==void 0&&console.warn("[ext-apps] AppBridge received a second ui/initialize. The View may be double-mounting (e.g. React StrictMode in dev) without closing the previous App instance. Responding normally; the latest appInfo/appCapabilities replace the previous values."),this._appCapabilities=r.params.appCapabilities,this._appInfo=r.params.appInfo,{protocolVersion:Rv.includes(n)?n:Qu,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];Nv(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},_v,n)}callTool(r,n){return this.request({method:"tools/call",params:r},ir,n)}listTools(r,n){return this.request({method:"tools/list",params:r},Ta,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},ir,{signal:o.signal}),n.tools.listChanged&&this._client.setNotificationHandler(Ra,s=>this.sendToolListChanged(s.params))),n.resources&&(this.onlistresources=async(s,o)=>this._client.request({method:"resources/list",params:s},ga,{signal:o.signal}),this.onlistresourcetemplates=async(s,o)=>this._client.request({method:"resources/templates/list",params:s},_a,{signal:o.signal}),this.onreadresource=async(s,o)=>this._client.request({method:"resources/read",params:s},va,{signal:o.signal}),n.resources.listChanged&&this._client.setNotificationHandler($a,s=>this.sendResourceListChanged(s.params))),n.prompts&&(this.onlistprompts=async(s,o)=>this._client.request({method:"prompts/list",params:s},wa,{signal:o.signal}),n.prompts.listChanged&&this._client.setNotificationHandler(ka,s=>this.sendPromptListChanged(s.params)))}return super.connect(r)}}function Nv(e,t){return JSON.stringify(e)===JSON.stringify(t)}const Iv=24,xc=4/3;function Bt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function jv(e){const t=e.type;if(t==="cameraUpdate"||t==="delete"||t==="restoreCheckpoint")return null;const r=Bt(e.x),n=Bt(e.y);if(r===void 0||n===void 0)return null;let s=r,o=n,a=r,i=n;const c=Bt(e.width),l=Bt(e.height);if(c!==void 0&&l!==void 0)a=r+c,i=n+l;else if(t==="text"&&typeof e.text=="string"){const d=Bt(e.fontSize)??20;a=r+e.text.length*d*.65,i=n+d*1.5}if(Array.isArray(e.points))for(const d of e.points){if(!Array.isArray(d)||d.length<2)continue;const f=r+(Bt(d[0])??0),_=n+(Bt(d[1])??0);s=Math.min(s,f),o=Math.min(o,_),a=Math.max(a,f),i=Math.max(i,_)}return{x:s,y:o,width:a-s,height:i-o}}function Ov(e,t){const r=Math.min(e.x,t.x),n=Math.min(e.y,t.y);return{x:r,y:n,width:Math.max(e.x+e.width,t.x+t.width)-r,height:Math.max(e.y+e.height,t.y+t.height)-n}}function Av(e){return Math.max(Iv,Math.round(Math.max(e.width,e.height)*.03))}function Mv(e){const t=Av(e),r={x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2},n=r.width/r.height;if(Math.abs(n-xc)<.01)return r;if(n>xc){const o=Math.round(r.width*3/4);return{x:r.x,y:r.y-Math.round((o-r.height)/2),width:r.width,height:o}}const s=Math.round(r.height*4/3);return{x:r.x-Math.round((s-r.width)/2),y:r.y,width:s,height:r.height}}function zv(e){let t=null;const r=[];for(const n of e){if(!n||typeof n!="object"||Array.isArray(n))continue;const s=n;if(s.type==="cameraUpdate")continue;r.push(s);const o=jv(s);o&&(t=t?Ov(t,o):o)}return!t||t.width<=0||t.height<=0?e:[...r,{type:"cameraUpdate",...Mv(t)}]}var mo={exports:{}},Xu={},St={},Cr={},En={},ge={},fn={};(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((S,T)=>`${S}${T}`,"")}get names(){var $;return($=this._names)!==null&&$!==void 0?$:this._names=this._items.reduce((S,T)=>(T instanceof r&&(S[T.str]=(S[T.str]||0)+1),S),{})}}e._Code=n,e.nil=new n("");function s(h,...$){const S=[h[0]];let T=0;for(;T<$.length;)i(S,$[T]),S.push(h[++T]);return new n(S)}e._=s;const o=new n("+");function a(h,...$){const S=[g(h[0])];let T=0;for(;T<$.length;)S.push(o),i(S,$[T]),S.push(o,g(h[++T]));return c(S),new n(S)}e.str=a;function i(h,$){$ instanceof n?h.push(...$._items):$ instanceof r?h.push($):h.push(f($))}e.addCodeArg=i;function c(h){let $=1;for(;${if(f.scopePath===void 0)throw new Error(`CodeGen: name "${f}" has no value`);return(0,t._)`${l}${f.scopePath}`})}scopeCode(l=this._values,d,f){return this._reduceValues(l,_=>{if(_.value===void 0)throw new Error(`CodeGen: name "${_}" has no value`);return _.value.code},d,f)}_reduceValues(l,d,f={},_){let g=t.nil;for(const m in l){const v=l[m];if(!v)continue;const y=f[m]=f[m]||new Map;v.forEach(h=>{if(y.has(h))return;y.set(h,n.Started);let $=d(h);if($){const S=this.opts.es5?e.varKinds.var:e.varKinds.const;g=(0,t._)`${g}${S} ${h} = ${$};${this.opts._n}`}else if($=_==null?void 0:_(h))g=(0,t._)`${g}${$}${this.opts._n}`;else throw new r(h);y.set(h,n.Completed)})}return g}}e.ValueScope=i})(go);(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=fn,r=go;var n=fn;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=go;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,E){super(),this.varKind=u,this.name=p,this.rhs=E}render({es5:u,_n:p}){const E=u?r.varKinds.var:this.varKind,q=this.rhs===void 0?"":` = ${this.rhs}`;return`${E} ${this.name}${q};`+p}optimizeNames(u,p){if(u[this.name.str])return this.rhs&&(this.rhs=V(this.rhs,u,p)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class i extends o{constructor(u,p,E){super(),this.lhs=u,this.rhs=p,this.sideEffects=E}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=V(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,E,q){super(u,E,q),this.op=p}render({_n:u}){return`${this.lhs} ${this.op}= ${this.rhs};`+u}}class l extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`${this.label}:`+u}}class d extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`break${this.label?` ${this.label}`:""};`+u}}class f extends o{constructor(u){super(),this.error=u}render({_n:u}){return`throw ${this.error};`+u}get names(){return this.error.names}}class _ 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=V(this.code,u,p),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}}class g extends o{constructor(u=[]){super(),this.nodes=u}render(u){return this.nodes.reduce((p,E)=>p+E.render(u),"")}optimizeNodes(){const{nodes:u}=this;let p=u.length;for(;p--;){const E=u[p].optimizeNodes();Array.isArray(E)?u.splice(p,1,...E):E?u[p]=E:u.splice(p,1)}return u.length>0?this:void 0}optimizeNames(u,p){const{nodes:E}=this;let q=E.length;for(;q--;){const D=E[q];D.optimizeNames(u,p)||(ie(u,D.names),E.splice(q,1))}return E.length>0?this:void 0}get names(){return this.nodes.reduce((u,p)=>Q(u,p.names),{})}}class m extends g{render(u){return"{"+u._n+super.render(u)+"}"+u._n}}class v extends g{}class y extends m{}y.kind="else";class h extends m{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 E=p.optimizeNodes();p=this.else=Array.isArray(E)?new y(E):E}if(p)return u===!1?p instanceof h?p:p.nodes:this.nodes.length?this:new h(ke(u),p instanceof h?[p]:p.nodes);if(!(u===!1||!this.nodes.length))return this}optimizeNames(u,p){var E;if(this.else=(E=this.else)===null||E===void 0?void 0:E.optimizeNames(u,p),!!(super.optimizeNames(u,p)||this.else))return this.condition=V(this.condition,u,p),this}get names(){const u=super.names;return re(u,this.condition),this.else&&Q(u,this.else.names),u}}h.kind="if";class $ extends m{}$.kind="for";class S 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=V(this.iteration,u,p),this}get names(){return Q(super.names,this.iteration.names)}}class T extends ${constructor(u,p,E,q){super(),this.varKind=u,this.name=p,this.from=E,this.to=q}render(u){const p=u.es5?r.varKinds.var:this.varKind,{name:E,from:q,to:D}=this;return`for(${p} ${E}=${q}; ${E}<${D}; ${E}++)`+super.render(u)}get names(){const u=re(super.names,this.from);return re(u,this.to)}}class k extends ${constructor(u,p,E,q){super(),this.loop=u,this.varKind=p,this.name=E,this.iterable=q}render(u){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(u)}optimizeNames(u,p){if(super.optimizeNames(u,p))return this.iterable=V(this.iterable,u,p),this}get names(){return Q(super.names,this.iterable.names)}}class I extends m{constructor(u,p,E){super(),this.name=u,this.args=p,this.async=E}render(u){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(u)}}I.kind="func";class z extends g{render(u){return"return "+super.render(u)}}z.kind="return";class F extends m{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 E,q;return super.optimizeNames(u,p),(E=this.catch)===null||E===void 0||E.optimizeNames(u,p),(q=this.finally)===null||q===void 0||q.optimizeNames(u,p),this}get names(){const u=super.names;return this.catch&&Q(u,this.catch.names),this.finally&&Q(u,this.finally.names),u}}class G extends m{constructor(u){super(),this.error=u}render(u){return`catch(${this.error})`+super.render(u)}}G.kind="catch";class Z extends m{render(u){return"finally"+super.render(u)}}Z.kind="finally";class K{constructor(u,p={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...p,_n:p.lines?` -`:""},this._extScope=u,this._scope=new r.Scope({parent:u}),this._nodes=[new v]}toString(){return this._root.render(this.opts)}name(u){return this._scope.name(u)}scopeName(u){return this._extScope.name(u)}scopeValue(u,p){const E=this._extScope.value(u,p);return(this._values[E.prefix]||(this._values[E.prefix]=new Set)).add(E),E}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,E,q){const D=this._scope.toName(p);return E!==void 0&&q&&(this._constants[D.str]=E),this._leafNode(new a(u,D,E)),D}const(u,p,E){return this._def(r.varKinds.const,u,p,E)}let(u,p,E){return this._def(r.varKinds.let,u,p,E)}var(u,p,E){return this._def(r.varKinds.var,u,p,E)}assign(u,p,E){return this._leafNode(new i(u,p,E))}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 _(u)),this}object(...u){const p=["{"];for(const[E,q]of u)p.length>1&&p.push(","),p.push(E),(E!==q||this.opts.es5)&&(p.push(":"),(0,t.addCodeArg)(p,q));return p.push("}"),new t._Code(p)}if(u,p,E){if(this._blockNode(new h(u)),p&&E)this.code(p).else().code(E).endIf();else if(p)this.code(p).endIf();else if(E)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(u){return this._elseNode(new h(u))}else(){return this._elseNode(new y)}endIf(){return this._endBlockNode(h,y)}_for(u,p){return this._blockNode(u),p&&this.code(p).endFor(),this}for(u,p){return this._for(new S(u),p)}forRange(u,p,E,q,D=this.opts.es5?r.varKinds.var:r.varKinds.let){const Y=this._scope.toName(u);return this._for(new T(D,Y,p,E),()=>q(Y))}forOf(u,p,E,q=r.varKinds.const){const D=this._scope.toName(u);if(this.opts.es5){const Y=p instanceof t.Name?p:this.var("_arr",p);return this.forRange("_i",0,(0,t._)`${Y}.length`,J=>{this.var(D,(0,t._)`${Y}[${J}]`),E(D)})}return this._for(new k("of",q,D,p),()=>E(D))}forIn(u,p,E,q=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(u,(0,t._)`Object.keys(${p})`,E);const D=this._scope.toName(u);return this._for(new k("in",q,D,p),()=>E(D))}endFor(){return this._endBlockNode($)}label(u){return this._leafNode(new l(u))}break(u){return this._leafNode(new d(u))}return(u){const p=new z;if(this._blockNode(p),this.code(u),p.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(z)}try(u,p,E){if(!p&&!E)throw new Error('CodeGen: "try" without "catch" and "finally"');const q=new F;if(this._blockNode(q),this.code(u),p){const D=this.name("e");this._currNode=q.catch=new G(D),p(D)}return E&&(this._currNode=q.finally=new Z,this.code(E)),this._endBlockNode(G,Z)}throw(u){return this._leafNode(new f(u))}block(u,p){return this._blockStarts.push(this._nodes.length),u&&this.code(u).endBlock(p),this}endBlock(u){const p=this._blockStarts.pop();if(p===void 0)throw new Error("CodeGen: not in self-balancing block");const E=this._nodes.length-p;if(E<0||u!==void 0&&E!==u)throw new Error(`CodeGen: wrong number of nodes: ${E} vs ${u} expected`);return this._nodes.length=p,this}func(u,p=t.nil,E,q){return this._blockNode(new I(u,p,E)),q&&this.code(q).endFunc(),this}endFunc(){return this._endBlockNode(I)}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 E=this._currNode;if(E instanceof u||p&&E instanceof p)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${p?`${u.kind}/${p.kind}`:u.kind}"`)}_elseNode(u){const p=this._currNode;if(!(p instanceof h))throw new Error('CodeGen: "else" without "if"');return this._currNode=p.else=u,this}get _root(){return this._nodes[0]}get _currNode(){const u=this._nodes;return u[u.length-1]}set _currNode(u){const p=this._nodes;p[p.length-1]=u}}e.CodeGen=K;function Q(b,u){for(const p in u)b[p]=(b[p]||0)+(u[p]||0);return b}function re(b,u){return u instanceof t._CodeOrName?Q(b,u.names):b}function V(b,u,p){if(b instanceof t.Name)return E(b);if(!q(b))return b;return new t._Code(b._items.reduce((D,Y)=>(Y instanceof t.Name&&(Y=E(Y)),Y instanceof t._Code?D.push(...Y._items):D.push(Y),D),[]));function E(D){const Y=p[D.str];return Y===void 0||u[D.str]!==1?D:(delete u[D.str],Y)}function q(D){return D instanceof t._Code&&D._items.some(Y=>Y instanceof t.Name&&u[Y.str]===1&&p[Y.str]!==void 0)}}function ie(b,u){for(const p in u)b[p]=(b[p]||0)-(u[p]||0)}function ke(b){return typeof b=="boolean"||typeof b=="number"||b===null?!b:(0,t._)`!${C(b)}`}e.not=ke;const $e=w(e.operators.AND);function ct(...b){return b.reduce($e)}e.and=ct;const Oe=w(e.operators.OR);function A(...b){return b.reduce(Oe)}e.or=A;function w(b){return(u,p)=>u===t.nil?p:p===t.nil?u:(0,t._)`${C(u)} ${b} ${C(p)}`}function C(b){return b instanceof t.Name?b:(0,t._)`(${b})`}})(ge);var W={};Object.defineProperty(W,"__esModule",{value:!0});W.checkStrictMode=W.getErrorPath=W.Type=W.useFunc=W.setEvaluated=W.evaluatedPropsToName=W.mergeEvaluated=W.eachItem=W.unescapeJsonPointer=W.escapeJsonPointer=W.escapeFragment=W.unescapeFragment=W.schemaRefOrVal=W.schemaHasRulesButRef=W.schemaHasRules=W.checkUnknownRules=W.alwaysValidSchema=W.toHash=void 0;const we=ge,xv=fn;function qv(e){const t={};for(const r of e)t[r]=!0;return t}W.toHash=qv;function Dv(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(ed(e,t),!td(t,e.self.RULES.all))}W.alwaysValidSchema=Dv;function ed(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]||sd(e,`unknown keyword: "${o}"`)}W.checkUnknownRules=ed;function td(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(t[r])return!0;return!1}W.schemaHasRules=td;function Uv(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}W.schemaHasRulesButRef=Uv;function Vv({topSchemaRef:e,schemaPath:t},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,we._)`${r}`}return(0,we._)`${e}${t}${(0,we.getProperty)(n)}`}W.schemaRefOrVal=Vv;function Fv(e){return rd(decodeURIComponent(e))}W.unescapeFragment=Fv;function Lv(e){return encodeURIComponent(Oa(e))}W.escapeFragment=Lv;function Oa(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}W.escapeJsonPointer=Oa;function rd(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}W.unescapeJsonPointer=rd;function Hv(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)}W.eachItem=Hv;function qc({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(s,o,a,i)=>{const c=a===void 0?o:a instanceof we.Name?(o instanceof we.Name?e(s,o,a):t(s,o,a),a):o instanceof we.Name?(t(s,a,o),o):r(o,a);return i===we.Name&&!(c instanceof we.Name)?n(s,c):c}}W.mergeEvaluated={props:qc({mergeNames:(e,t,r)=>e.if((0,we._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,we._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,we._)`${r} || {}`).code((0,we._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,we._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,we._)`${r} || {}`),Aa(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:nd}),items:qc({mergeNames:(e,t,r)=>e.if((0,we._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,we._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,we._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,we._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function nd(e,t){if(t===!0)return e.var("props",!0);const r=e.var("props",(0,we._)`{}`);return t!==void 0&&Aa(e,r,t),r}W.evaluatedPropsToName=nd;function Aa(e,t,r){Object.keys(r).forEach(n=>e.assign((0,we._)`${t}${(0,we.getProperty)(n)}`,!0))}W.setEvaluated=Aa;const Dc={};function Zv(e,t){return e.scopeValue("func",{ref:t,code:Dc[t.code]||(Dc[t.code]=new xv._Code(t.code))})}W.useFunc=Zv;var _o;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(_o||(W.Type=_o={}));function Kv(e,t,r){if(e instanceof we.Name){const n=t===_o.Num;return r?n?(0,we._)`"[" + ${e} + "]"`:(0,we._)`"['" + ${e} + "']"`:n?(0,we._)`"/" + ${e}`:(0,we._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,we.getProperty)(e).toString():"/"+Oa(e)}W.getErrorPath=Kv;function sd(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}W.checkStrictMode=sd;var Rt={};Object.defineProperty(Rt,"__esModule",{value:!0});const Xe=ge,Gv={data:new Xe.Name("data"),valCxt:new Xe.Name("valCxt"),instancePath:new Xe.Name("instancePath"),parentData:new Xe.Name("parentData"),parentDataProperty:new Xe.Name("parentDataProperty"),rootData:new Xe.Name("rootData"),dynamicAnchors:new Xe.Name("dynamicAnchors"),vErrors:new Xe.Name("vErrors"),errors:new Xe.Name("errors"),this:new Xe.Name("this"),self:new Xe.Name("self"),scope:new Xe.Name("scope"),json:new Xe.Name("json"),jsonPos:new Xe.Name("jsonPos"),jsonLen:new Xe.Name("jsonLen"),jsonPart:new Xe.Name("jsonPart")};Rt.default=Gv;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;const t=ge,r=W,n=Rt;e.keywordError={message:({keyword:y})=>(0,t.str)`must pass "${y}" keyword validation`},e.keyword$DataError={message:({keyword:y,schemaType:h})=>h?(0,t.str)`"${y}" keyword must be ${h} ($data)`:(0,t.str)`"${y}" keyword is invalid ($data)`};function s(y,h=e.keywordError,$,S){const{it:T}=y,{gen:k,compositeRule:I,allErrors:z}=T,F=f(y,h,$);S??(I||z)?c(k,F):l(T,(0,t._)`[${F}]`)}e.reportError=s;function o(y,h=e.keywordError,$){const{it:S}=y,{gen:T,compositeRule:k,allErrors:I}=S,z=f(y,h,$);c(T,z),k||I||l(S,n.default.vErrors)}e.reportExtraError=o;function a(y,h){y.assign(n.default.errors,h),y.if((0,t._)`${n.default.vErrors} !== null`,()=>y.if(h,()=>y.assign((0,t._)`${n.default.vErrors}.length`,h),()=>y.assign(n.default.vErrors,null)))}e.resetErrorsCount=a;function i({gen:y,keyword:h,schemaValue:$,data:S,errsCount:T,it:k}){if(T===void 0)throw new Error("ajv implementation error");const I=y.name("err");y.forRange("i",T,n.default.errors,z=>{y.const(I,(0,t._)`${n.default.vErrors}[${z}]`),y.if((0,t._)`${I}.instancePath === undefined`,()=>y.assign((0,t._)`${I}.instancePath`,(0,t.strConcat)(n.default.instancePath,k.errorPath))),y.assign((0,t._)`${I}.schemaPath`,(0,t.str)`${k.errSchemaPath}/${h}`),k.opts.verbose&&(y.assign((0,t._)`${I}.schema`,$),y.assign((0,t._)`${I}.data`,S))})}e.extendErrors=i;function c(y,h){const $=y.const("err",h);y.if((0,t._)`${n.default.vErrors} === null`,()=>y.assign(n.default.vErrors,(0,t._)`[${$}]`),(0,t._)`${n.default.vErrors}.push(${$})`),y.code((0,t._)`${n.default.errors}++`)}function l(y,h){const{gen:$,validateName:S,schemaEnv:T}=y;T.$async?$.throw((0,t._)`new ${y.ValidationError}(${h})`):($.assign((0,t._)`${S}.errors`,h),$.return(!1))}const d={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function f(y,h,$){const{createErrors:S}=y.it;return S===!1?(0,t._)`{}`:_(y,h,$)}function _(y,h,$={}){const{gen:S,it:T}=y,k=[g(T,$),m(y,$)];return v(y,h,k),S.object(...k)}function g({errorPath:y},{instancePath:h}){const $=h?(0,t.str)`${y}${(0,r.getErrorPath)(h,r.Type.Str)}`:y;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,$)]}function m({keyword:y,it:{errSchemaPath:h}},{schemaPath:$,parentSchema:S}){let T=S?h:(0,t.str)`${h}/${y}`;return $&&(T=(0,t.str)`${T}${(0,r.getErrorPath)($,r.Type.Str)}`),[d.schemaPath,T]}function v(y,{params:h,message:$},S){const{keyword:T,data:k,schemaValue:I,it:z}=y,{opts:F,propertyName:G,topSchemaRef:Z,schemaPath:K}=z;S.push([d.keyword,T],[d.params,typeof h=="function"?h(y):h||(0,t._)`{}`]),F.messages&&S.push([d.message,typeof $=="function"?$(y):$]),F.verbose&&S.push([d.schema,I],[d.parentSchema,(0,t._)`${Z}${K}`],[n.default.data,k]),G&&S.push([d.propertyName,G])}})(En);Object.defineProperty(Cr,"__esModule",{value:!0});Cr.boolOrEmptySchema=Cr.topBoolOrEmptySchema=void 0;const Wv=En,Bv=ge,Jv=Rt,Qv={message:"boolean schema is false"};function Yv(e){const{gen:t,schema:r,validateName:n}=e;r===!1?od(e,!1):typeof r=="object"&&r.$async===!0?t.return(Jv.default.data):(t.assign((0,Bv._)`${n}.errors`,null),t.return(!0))}Cr.topBoolOrEmptySchema=Yv;function Xv(e,t){const{gen:r,schema:n}=e;n===!1?(r.var(t,!1),od(e)):r.var(t,!0)}Cr.boolOrEmptySchema=Xv;function od(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,Wv.reportError)(s,Qv,void 0,t)}var qe={},cr={};Object.defineProperty(cr,"__esModule",{value:!0});cr.getRules=cr.isJSONType=void 0;const e$=["string","number","integer","boolean","null","object","array"],t$=new Set(e$);function r$(e){return typeof e=="string"&&t$.has(e)}cr.isJSONType=r$;function n$(){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:{}}}cr.getRules=n$;var jt={};Object.defineProperty(jt,"__esModule",{value:!0});jt.shouldUseRule=jt.shouldUseGroup=jt.schemaHasRulesForType=void 0;function s$({schema:e,self:t},r){const n=t.RULES.types[r];return n&&n!==!0&&ad(e,n)}jt.schemaHasRulesForType=s$;function ad(e,t){return t.rules.some(r=>id(e,r))}jt.shouldUseGroup=ad;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))}jt.shouldUseRule=id;Object.defineProperty(qe,"__esModule",{value:!0});qe.reportTypeError=qe.checkDataTypes=qe.checkDataType=qe.coerceAndCheckDataType=qe.getJSONTypes=qe.getSchemaTypes=qe.DataType=void 0;const o$=cr,a$=jt,i$=En,le=ge,cd=W;var Er;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Er||(qe.DataType=Er={}));function c$(e){const t=ld(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}qe.getSchemaTypes=c$;function ld(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(o$.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}qe.getJSONTypes=ld;function l$(e,t){const{gen:r,data:n,opts:s}=e,o=u$(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0,a$.schemaHasRulesForType)(e,t[0]));if(a){const i=Ma(t,n,s.strictNumbers,Er.Wrong);r.if(i,()=>{o.length?d$(e,t,o):za(e)})}return a}qe.coerceAndCheckDataType=l$;const ud=new Set(["string","number","integer","boolean","null"]);function u$(e,t){return t?e.filter(r=>ud.has(r)||t==="array"&&r==="array"):[]}function d$(e,t,r){const{gen:n,data:s,opts:o}=e,a=n.let("dataType",(0,le._)`typeof ${s}`),i=n.let("coerced",(0,le._)`undefined`);o.coerceTypes==="array"&&n.if((0,le._)`${a} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,le._)`${s}[0]`).assign(a,(0,le._)`typeof ${s}`).if(Ma(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0,le._)`${i} !== undefined`);for(const l of r)(ud.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),za(e),n.endIf(),n.if((0,le._)`${i} !== undefined`,()=>{n.assign(s,i),f$(e,i)});function c(l){switch(l){case"string":n.elseIf((0,le._)`${a} == "number" || ${a} == "boolean"`).assign(i,(0,le._)`"" + ${s}`).elseIf((0,le._)`${s} === null`).assign(i,(0,le._)`""`);return;case"number":n.elseIf((0,le._)`${a} == "boolean" || ${s} === null - || (${a} == "string" && ${s} && ${s} == +${s})`).assign(i,(0,le._)`+${s}`);return;case"integer":n.elseIf((0,le._)`${a} === "boolean" || ${s} === null - || (${a} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(i,(0,le._)`+${s}`);return;case"boolean":n.elseIf((0,le._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(i,!1).elseIf((0,le._)`${s} === "true" || ${s} === 1`).assign(i,!0);return;case"null":n.elseIf((0,le._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(i,null);return;case"array":n.elseIf((0,le._)`${a} === "string" || ${a} === "number" - || ${a} === "boolean" || ${s} === null`).assign(i,(0,le._)`[${s}]`)}}}function f$({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,le._)`${t} !== undefined`,()=>e.assign((0,le._)`${t}[${r}]`,n))}function yo(e,t,r,n=Er.Correct){const s=n===Er.Correct?le.operators.EQ:le.operators.NEQ;let o;switch(e){case"null":return(0,le._)`${t} ${s} null`;case"array":o=(0,le._)`Array.isArray(${t})`;break;case"object":o=(0,le._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=a((0,le._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=a();break;default:return(0,le._)`typeof ${t} ${s} ${e}`}return n===Er.Correct?o:(0,le.not)(o);function a(i=le.nil){return(0,le.and)((0,le._)`typeof ${t} == "number"`,i,r?(0,le._)`isFinite(${t})`:le.nil)}}qe.checkDataType=yo;function Ma(e,t,r,n){if(e.length===1)return yo(e[0],t,r,n);let s;const o=(0,cd.toHash)(e);if(o.array&&o.object){const a=(0,le._)`typeof ${t} != "object"`;s=o.null?a:(0,le._)`!${t} || ${a}`,delete o.null,delete o.array,delete o.object}else s=le.nil;o.number&&delete o.integer;for(const a in o)s=(0,le.and)(s,yo(a,t,r,n));return s}qe.checkDataTypes=Ma;const h$={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,le._)`{type: ${e}}`:(0,le._)`{type: ${t}}`};function za(e){const t=p$(e);(0,i$.reportError)(t,h$)}qe.reportTypeError=za;function p$(e){const{gen:t,data:r,schema:n}=e,s=(0,cd.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}var Ns={};Object.defineProperty(Ns,"__esModule",{value:!0});Ns.assignDefaults=void 0;const pr=ge,m$=W;function g$(e,t){const{properties:r,items:n}=e.schema;if(t==="object"&&r)for(const s in r)Uc(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>Uc(e,o,s.default))}Ns.assignDefaults=g$;function Uc(e,t,r){const{gen:n,compositeRule:s,data:o,opts:a}=e;if(r===void 0)return;const i=(0,pr._)`${o}${(0,pr.getProperty)(t)}`;if(s){(0,m$.checkStrictMode)(e,`default is ignored for: ${i}`);return}let c=(0,pr._)`${i} === undefined`;a.useDefaults==="empty"&&(c=(0,pr._)`${c} || ${i} === null || ${i} === ""`),n.if(c,(0,pr._)`${i} = ${(0,pr.stringify)(r)}`)}var Tt={},pe={};Object.defineProperty(pe,"__esModule",{value:!0});pe.validateUnion=pe.validateArray=pe.usePattern=pe.callValidateCode=pe.schemaProperties=pe.allSchemaProperties=pe.noPropertyInData=pe.propertyInData=pe.isOwnProperty=pe.hasPropFunc=pe.reportMissingProp=pe.checkMissingProp=pe.checkReportMissingProp=void 0;const Pe=ge,xa=W,Mt=Rt,_$=W;function y$(e,t){const{gen:r,data:n,it:s}=e;r.if(Da(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Pe._)`${t}`},!0),e.error()})}pe.checkReportMissingProp=y$;function v$({gen:e,data:t,it:{opts:r}},n,s){return(0,Pe.or)(...n.map(o=>(0,Pe.and)(Da(e,t,o,r.ownProperties),(0,Pe._)`${s} = ${o}`)))}pe.checkMissingProp=v$;function $$(e,t){e.setParams({missingProperty:t},!0),e.error()}pe.reportMissingProp=$$;function dd(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Pe._)`Object.prototype.hasOwnProperty`})}pe.hasPropFunc=dd;function qa(e,t,r){return(0,Pe._)`${dd(e)}.call(${t}, ${r})`}pe.isOwnProperty=qa;function w$(e,t,r,n){const s=(0,Pe._)`${t}${(0,Pe.getProperty)(r)} !== undefined`;return n?(0,Pe._)`${s} && ${qa(e,t,r)}`:s}pe.propertyInData=w$;function Da(e,t,r,n){const s=(0,Pe._)`${t}${(0,Pe.getProperty)(r)} === undefined`;return n?(0,Pe.or)(s,(0,Pe.not)(qa(e,t,r))):s}pe.noPropertyInData=Da;function fd(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}pe.allSchemaProperties=fd;function b$(e,t){return fd(t).filter(r=>!(0,xa.alwaysValidSchema)(e,t[r]))}pe.schemaProperties=b$;function S$({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:a},i,c,l){const d=l?(0,Pe._)`${e}, ${t}, ${n}${s}`:t,f=[[Mt.default.instancePath,(0,Pe.strConcat)(Mt.default.instancePath,o)],[Mt.default.parentData,a.parentData],[Mt.default.parentDataProperty,a.parentDataProperty],[Mt.default.rootData,Mt.default.rootData]];a.opts.dynamicRef&&f.push([Mt.default.dynamicAnchors,Mt.default.dynamicAnchors]);const _=(0,Pe._)`${d}, ${r.object(...f)}`;return c!==Pe.nil?(0,Pe._)`${i}.call(${c}, ${_})`:(0,Pe._)`${i}(${_})`}pe.callValidateCode=S$;const E$=(0,Pe._)`new RegExp`;function k$({gen:e,it:{opts:t}},r){const n=t.unicodeRegExp?"u":"",{regExp:s}=t.code,o=s(r,n);return e.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,Pe._)`${s.code==="new RegExp"?E$:(0,_$.useFunc)(e,s)}(${r}, ${n})`})}pe.usePattern=k$;function P$(e){const{gen:t,data:r,keyword:n,it:s}=e,o=t.name("valid");if(s.allErrors){const i=t.let("valid",!0);return a(()=>t.assign(i,!1)),i}return t.var(o,!0),a(()=>t.break()),o;function a(i){const c=t.const("len",(0,Pe._)`${r}.length`);t.forRange("i",0,c,l=>{e.subschema({keyword:n,dataProp:l,dataPropType:xa.Type.Num},o),t.if((0,Pe.not)(o),i)})}}pe.validateArray=P$;function T$(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,xa.alwaysValidSchema)(s,c))&&!s.opts.unevaluated)return;const a=t.let("valid",!1),i=t.name("_valid");t.block(()=>r.forEach((c,l)=>{const d=e.subschema({keyword:n,schemaProp:l,compositeRule:!0},i);t.assign(a,(0,Pe._)`${a} || ${i}`),e.mergeValidEvaluated(d,i)||t.if((0,Pe.not)(a))})),e.result(a,()=>e.reset(),()=>e.error(!0))}pe.validateUnion=T$;Object.defineProperty(Tt,"__esModule",{value:!0});Tt.validateKeywordUsage=Tt.validSchemaType=Tt.funcKeywordCode=Tt.macroKeywordCode=void 0;const rt=ge,tr=Rt,R$=pe,C$=En;function N$(e,t){const{gen:r,keyword:n,schema:s,parentSchema:o,it:a}=e,i=t.macro.call(a.self,s,o,a),c=hd(r,n,i);a.opts.validateSchema!==!1&&a.self.validateSchema(i,!0);const l=r.name("valid");e.subschema({schema:i,schemaPath:rt.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},l),e.pass(l,()=>e.error(!0))}Tt.macroKeywordCode=N$;function I$(e,t){var r;const{gen:n,keyword:s,schema:o,parentSchema:a,$data:i,it:c}=e;O$(c,t);const l=!i&&t.compile?t.compile.call(c.self,o,a,c):t.validate,d=hd(n,s,l),f=n.let("valid");e.block$data(f,_),e.ok((r=t.valid)!==null&&r!==void 0?r:f);function _(){if(t.errors===!1)v(),t.modifying&&Vc(e),y(()=>e.error());else{const h=t.async?g():m();t.modifying&&Vc(e),y(()=>j$(e,h))}}function g(){const h=n.let("ruleErrs",null);return n.try(()=>v((0,rt._)`await `),$=>n.assign(f,!1).if((0,rt._)`${$} instanceof ${c.ValidationError}`,()=>n.assign(h,(0,rt._)`${$}.errors`),()=>n.throw($))),h}function m(){const h=(0,rt._)`${d}.errors`;return n.assign(h,null),v(rt.nil),h}function v(h=t.async?(0,rt._)`await `:rt.nil){const $=c.opts.passContext?tr.default.this:tr.default.self,S=!("compile"in t&&!i||t.schema===!1);n.assign(f,(0,rt._)`${h}${(0,R$.callValidateCode)(e,d,$,S)}`,t.modifying)}function y(h){var $;n.if((0,rt.not)(($=t.valid)!==null&&$!==void 0?$:f),h)}}Tt.funcKeywordCode=I$;function Vc(e){const{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,rt._)`${n.parentData}[${n.parentDataProperty}]`))}function j$(e,t){const{gen:r}=e;r.if((0,rt._)`Array.isArray(${t})`,()=>{r.assign(tr.default.vErrors,(0,rt._)`${tr.default.vErrors} === null ? ${t} : ${tr.default.vErrors}.concat(${t})`).assign(tr.default.errors,(0,rt._)`${tr.default.vErrors}.length`),(0,C$.extendErrors)(e)},()=>e.error())}function O$({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function hd(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,rt.stringify)(r)})}function A$(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}Tt.validSchemaType=A$;function M$({schema:e,opts:t,self:r,errSchemaPath:n},s,o){if(Array.isArray(s.keyword)?!s.keyword.includes(o):s.keyword!==o)throw new Error("ajv implementation error");const a=s.dependencies;if(a!=null&&a.some(i=>!Object.prototype.hasOwnProperty.call(e,i)))throw new Error(`parent schema must have dependencies of ${o}: ${a.join(",")}`);if(s.validateSchema&&!s.validateSchema(e[o])){const c=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(s.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}Tt.validateKeywordUsage=M$;var Ft={};Object.defineProperty(Ft,"__esModule",{value:!0});Ft.extendSubschemaMode=Ft.extendSubschemaData=Ft.getSubschema=void 0;const Pt=ge,pd=W;function z$(e,{keyword:t,schemaProp:r,schema:n,schemaPath:s,errSchemaPath:o,topSchemaRef:a}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){const i=e.schema[t];return r===void 0?{schema:i,schemaPath:(0,Pt._)`${e.schemaPath}${(0,Pt.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:i[r],schemaPath:(0,Pt._)`${e.schemaPath}${(0,Pt.getProperty)(t)}${(0,Pt.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,pd.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')}Ft.getSubschema=z$;function x$(e,t,{dataProp:r,dataPropType:n,data:s,dataTypes:o,propertyName:a}){if(s!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:i}=t;if(r!==void 0){const{errorPath:l,dataPathArr:d,opts:f}=t,_=i.let("data",(0,Pt._)`${t.data}${(0,Pt.getProperty)(r)}`,!0);c(_),e.errorPath=(0,Pt.str)`${l}${(0,pd.getErrorPath)(r,n,f.jsPropertySyntax)}`,e.parentDataProperty=(0,Pt._)`${r}`,e.dataPathArr=[...d,e.parentDataProperty]}if(s!==void 0){const l=s instanceof Pt.Name?s:i.let("data",s,!0);c(l),a!==void 0&&(e.propertyName=a)}o&&(e.dataTypes=o);function c(l){e.data=l,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,l]}}Ft.extendSubschemaData=x$;function q$(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}Ft.extendSubschemaMode=q$;var Ge={},Is=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,s,o;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(s=n;s--!==0;)if(!e(t[s],r[s]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(o=Object.keys(t),n=o.length,n!==Object.keys(r).length)return!1;for(s=n;s--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[s]))return!1;for(s=n;s--!==0;){var a=o[s];if(!e(t[a],r[a]))return!1}return!0}return t!==t&&r!==r},md={exports:{}},Ut=md.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(){};Kn(t,n,s,e,"",e)};Ut.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Ut.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Ut.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Ut.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 Kn(e,t,r,n,s,o,a,i,c,l){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,s,o,a,i,c,l);for(var d in n){var f=n[d];if(Array.isArray(f)){if(d in Ut.arrayKeywords)for(var _=0;_t+=gd(n)),t===1/0))return 1/0}return t}function _d(e,t="",r){r!==!1&&(t=kr(t));const n=e.parse(t);return yd(e,n)}Ge.getFullPath=_d;function yd(e,t){return e.serialize(t).split("#")[0]+"#"}Ge._getFullPath=yd;const G$=/#\/?$/;function kr(e){return e?e.replace(G$,""):""}Ge.normalizeId=kr;function W$(e,t,r){return r=kr(r),e.resolve(t,r)}Ge.resolveUrl=W$;const B$=/^[a-z_][-a-z0-9._]*$/i;function J$(e,t){if(typeof e=="boolean")return{};const{schemaId:r,uriResolver:n}=this.opts,s=kr(e[r]||t),o={"":s},a=_d(n,s,!1),i={},c=new Set;return L$(e,{allKeys:!0},(f,_,g,m)=>{if(m===void 0)return;const v=a+_;let y=o[m];typeof f[r]=="string"&&(y=h.call(this,f[r])),$.call(this,f.$anchor),$.call(this,f.$dynamicAnchor),o[_]=y;function h(S){const T=this.opts.uriResolver.resolve;if(S=kr(y?T(y,S):S),c.has(S))throw d(S);c.add(S);let k=this.refs[S];return typeof k=="string"&&(k=this.refs[k]),typeof k=="object"?l(f,k.schema,S):S!==kr(v)&&(S[0]==="#"?(l(f,i[S],S),i[S]=f):this.refs[S]=v),S}function $(S){if(typeof S=="string"){if(!B$.test(S))throw new Error(`invalid anchor "${S}"`);h.call(this,`#${S}`)}}}),i;function l(f,_,g){if(_!==void 0&&!F$(f,_))throw d(g)}function d(f){return new Error(`reference "${f}" resolves to more than one schema`)}}Ge.getSchemaRefs=J$;Object.defineProperty(St,"__esModule",{value:!0});St.getData=St.KeywordCxt=St.validateFunctionCode=void 0;const vd=Cr,Fc=qe,Ua=jt,is=qe,Q$=Ns,Yr=Tt,Ks=Ft,te=ge,oe=Rt,Y$=Ge,Ot=W,Lr=En;function X$(e){if(bd(e)&&(Sd(e),wd(e))){rw(e);return}$d(e,()=>(0,vd.topBoolOrEmptySchema)(e))}St.validateFunctionCode=X$;function $d({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},o){s.code.es5?e.func(t,(0,te._)`${oe.default.data}, ${oe.default.valCxt}`,n.$async,()=>{e.code((0,te._)`"use strict"; ${Lc(r,s)}`),tw(e,s),e.code(o)}):e.func(t,(0,te._)`${oe.default.data}, ${ew(s)}`,n.$async,()=>e.code(Lc(r,s)).code(o))}function ew(e){return(0,te._)`{${oe.default.instancePath}="", ${oe.default.parentData}, ${oe.default.parentDataProperty}, ${oe.default.rootData}=${oe.default.data}${e.dynamicRef?(0,te._)`, ${oe.default.dynamicAnchors}={}`:te.nil}}={}`}function tw(e,t){e.if(oe.default.valCxt,()=>{e.var(oe.default.instancePath,(0,te._)`${oe.default.valCxt}.${oe.default.instancePath}`),e.var(oe.default.parentData,(0,te._)`${oe.default.valCxt}.${oe.default.parentData}`),e.var(oe.default.parentDataProperty,(0,te._)`${oe.default.valCxt}.${oe.default.parentDataProperty}`),e.var(oe.default.rootData,(0,te._)`${oe.default.valCxt}.${oe.default.rootData}`),t.dynamicRef&&e.var(oe.default.dynamicAnchors,(0,te._)`${oe.default.valCxt}.${oe.default.dynamicAnchors}`)},()=>{e.var(oe.default.instancePath,(0,te._)`""`),e.var(oe.default.parentData,(0,te._)`undefined`),e.var(oe.default.parentDataProperty,(0,te._)`undefined`),e.var(oe.default.rootData,oe.default.data),t.dynamicRef&&e.var(oe.default.dynamicAnchors,(0,te._)`{}`)})}function rw(e){const{schema:t,opts:r,gen:n}=e;$d(e,()=>{r.$comment&&t.$comment&&kd(e),iw(e),n.let(oe.default.vErrors,null),n.let(oe.default.errors,0),r.unevaluated&&nw(e),Ed(e),uw(e)})}function nw(e){const{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,te._)`${r}.evaluated`),t.if((0,te._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,te._)`${e.evaluated}.props`,(0,te._)`undefined`)),t.if((0,te._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,te._)`${e.evaluated}.items`,(0,te._)`undefined`))}function Lc(e,t){const r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,te._)`/*# sourceURL=${r} */`:te.nil}function sw(e,t){if(bd(e)&&(Sd(e),wd(e))){ow(e,t);return}(0,vd.boolOrEmptySchema)(e,t)}function wd({schema:e,self:t}){if(typeof e=="boolean")return!e;for(const r in e)if(t.RULES.all[r])return!0;return!1}function bd(e){return typeof e.schema!="boolean"}function ow(e,t){const{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&kd(e),cw(e),lw(e);const o=n.const("_errs",oe.default.errors);Ed(e,o),n.var(t,(0,te._)`${o} === ${oe.default.errors}`)}function Sd(e){(0,Ot.checkUnknownRules)(e),aw(e)}function Ed(e,t){if(e.opts.jtd)return Hc(e,[],!1,t);const r=(0,Fc.getSchemaTypes)(e.schema),n=(0,Fc.coerceAndCheckDataType)(e,r);Hc(e,r,!n,t)}function aw(e){const{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,Ot.schemaHasRulesButRef)(t,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function iw(e){const{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Ot.checkStrictMode)(e,"default is ignored in the schema root")}function cw(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,Y$.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function lw(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function kd({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:s}){const o=r.$comment;if(s.$comment===!0)e.code((0,te._)`${oe.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){const a=(0,te.str)`${n}/$comment`,i=e.scopeValue("root",{ref:t.root});e.code((0,te._)`${oe.default.self}.opts.$comment(${o}, ${a}, ${i}.schema)`)}}function uw(e){const{gen:t,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=e;r.$async?t.if((0,te._)`${oe.default.errors} === 0`,()=>t.return(oe.default.data),()=>t.throw((0,te._)`new ${s}(${oe.default.vErrors})`)):(t.assign((0,te._)`${n}.errors`,oe.default.vErrors),o.unevaluated&&dw(e),t.return((0,te._)`${oe.default.errors} === 0`))}function dw({gen:e,evaluated:t,props:r,items:n}){r instanceof te.Name&&e.assign((0,te._)`${t}.props`,r),n instanceof te.Name&&e.assign((0,te._)`${t}.items`,n)}function Hc(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,Ot.schemaHasRulesButRef)(o,d))){s.block(()=>Rd(e,"$ref",d.all.$ref.definition));return}c.jtd||fw(e,t),s.block(()=>{for(const _ of d.rules)f(_);f(d.post)});function f(_){(0,Ua.shouldUseGroup)(o,_)&&(_.type?(s.if((0,is.checkDataType)(_.type,a,c.strictNumbers)),Zc(e,_),t.length===1&&t[0]===_.type&&r&&(s.else(),(0,is.reportTypeError)(e)),s.endIf()):Zc(e,_),i||s.if((0,te._)`${oe.default.errors} === ${n||0}`))}}function Zc(e,t){const{gen:r,schema:n,opts:{useDefaults:s}}=e;s&&(0,Q$.assignDefaults)(e,t.type),r.block(()=>{for(const o of t.rules)(0,Ua.shouldUseRule)(n,o)&&Rd(e,o.keyword,o.definition,t.type)})}function fw(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(hw(e,t),e.opts.allowUnionTypes||pw(e,t),mw(e,e.dataTypes))}function hw(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{Pd(e.dataTypes,r)||Va(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),_w(e,t)}}function pw(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Va(e,"use allowUnionTypes to allow union type keyword")}function mw(e,t){const r=e.self.RULES.all;for(const n in r){const s=r[n];if(typeof s=="object"&&(0,Ua.shouldUseRule)(e.schema,s)){const{type:o}=s.definition;o.length&&!o.some(a=>gw(t,a))&&Va(e,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function gw(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function Pd(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function _w(e,t){const r=[];for(const n of e.dataTypes)Pd(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function Va(e,t){const r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,Ot.checkStrictMode)(e,t,e.opts.strictTypes)}class Td{constructor(t,r,n){if((0,Yr.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,Ot.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",Cd(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,Yr.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",oe.default.errors))}result(t,r,n){this.failResult((0,te.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,te.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,te._)`${r} !== undefined && (${(0,te.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?Lr.reportExtraError:Lr.reportError)(this,this.def.error,r)}$dataError(){(0,Lr.reportError)(this,this.def.$dataError||Lr.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Lr.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=te.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=te.nil,r=te.nil){if(!this.$data)return;const{gen:n,schemaCode:s,schemaType:o,def:a}=this;n.if((0,te.or)((0,te._)`${s} === undefined`,r)),t!==te.nil&&n.assign(t,!0),(o.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==te.nil&&n.assign(t,!1)),n.else()}invalid$data(){const{gen:t,schemaCode:r,schemaType:n,def:s,it:o}=this;return(0,te.or)(a(),i());function a(){if(n.length){if(!(r instanceof te.Name))throw new Error("ajv implementation error");const c=Array.isArray(n)?n:[n];return(0,te._)`${(0,is.checkDataTypes)(c,r,o.opts.strictNumbers,is.DataType.Wrong)}`}return te.nil}function i(){if(s.validateSchema){const c=t.scopeValue("validate$data",{ref:s.validateSchema});return(0,te._)`!${c}(${r})`}return te.nil}}subschema(t,r){const n=(0,Ks.getSubschema)(this.it,t);(0,Ks.extendSubschemaData)(n,this.it,t),(0,Ks.extendSubschemaMode)(n,t);const s={...this.it,...n,items:void 0,props:void 0};return sw(s,r),s}mergeEvaluated(t,r){const{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=Ot.mergeEvaluated.props(s,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=Ot.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,te.Name)),!0}}St.KeywordCxt=Td;function Rd(e,t,r,n){const s=new Td(e,r,t);"code"in r?r.code(s,n):s.$data&&r.validate?(0,Yr.funcKeywordCode)(s,r):"macro"in r?(0,Yr.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,Yr.funcKeywordCode)(s,r)}const yw=/^\/(?:[^~]|~0|~1)*$/,vw=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Cd(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,o;if(e==="")return oe.default.rootData;if(e[0]==="/"){if(!yw.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,o=oe.default.rootData}else{const l=vw.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,te._)`${o}${(0,te.getProperty)((0,Ot.unescapeJsonPointer)(l))}`,a=(0,te._)`${a} && ${o}`);return a;function c(l,d){return`Cannot access ${l} ${d} levels up, current level is ${t}`}}St.getData=Cd;var kn={};Object.defineProperty(kn,"__esModule",{value:!0});class $w extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}}kn.default=$w;var Ar={};Object.defineProperty(Ar,"__esModule",{value:!0});const Gs=Ge;let ww=class extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Gs.resolveUrl)(t,r,n),this.missingSchema=(0,Gs.normalizeId)((0,Gs.getFullPath)(t,this.missingRef))}};Ar.default=ww;var ot={};Object.defineProperty(ot,"__esModule",{value:!0});ot.resolveSchema=ot.getCompilingSchema=ot.resolveRef=ot.compileSchema=ot.SchemaEnv=void 0;const gt=ge,bw=kn,Jt=Rt,wt=Ge,Kc=W,Sw=St;let js=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,wt.normalizeId)(n==null?void 0:n[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n==null?void 0:n.$async,this.refs={}}};ot.SchemaEnv=js;function Fa(e){const t=Nd.call(this,e);if(t)return t;const r=(0,wt.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,a=new gt.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o});let i;e.$async&&(i=a.scopeValue("Error",{ref:bw.default,code:(0,gt._)`require("ajv/dist/runtime/validation_error").default`}));const c=a.scopeName("validate");e.validateName=c;const l={gen:a,allErrors:this.opts.allErrors,data:Jt.default.data,parentData:Jt.default.parentData,parentDataProperty:Jt.default.parentDataProperty,dataNames:[Jt.default.data],dataPathArr:[gt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,gt.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:gt.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,gt._)`""`,opts:this.opts,self:this};let d;try{this._compilations.add(e),(0,Sw.validateFunctionCode)(l),a.optimize(this.opts.code.optimize);const f=a.toString();d=`${a.scopeRefs(Jt.default.scope)}return ${f}`,this.opts.code.process&&(d=this.opts.code.process(d,e));const g=new Function(`${Jt.default.self}`,`${Jt.default.scope}`,d)(this,this.scope.get());if(this.scope.value(c,{ref:g}),g.errors=null,g.schema=e.schema,g.schemaEnv=e,e.$async&&(g.$async=!0),this.opts.code.source===!0&&(g.source={validateName:c,validateCode:f,scopeValues:a._values}),this.opts.unevaluated){const{props:m,items:v}=l;g.evaluated={props:m instanceof gt.Name?void 0:m,items:v instanceof gt.Name?void 0:v,dynamicProps:m instanceof gt.Name,dynamicItems:v instanceof gt.Name},g.source&&(g.source.evaluated=(0,gt.stringify)(g.evaluated))}return e.validate=g,e}catch(f){throw delete e.validate,delete e.validateName,d&&this.logger.error("Error compiling schema, function code:",d),f}finally{this._compilations.delete(e)}}ot.compileSchema=Fa;function Ew(e,t,r){var n;r=(0,wt.resolveUrl)(this.opts.uriResolver,t,r);const s=e.refs[r];if(s)return s;let o=Tw.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 js({schema:a,schemaId:i,root:e,baseId:t}))}if(o!==void 0)return e.refs[r]=kw.call(this,o)}ot.resolveRef=Ew;function kw(e){return(0,wt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Fa.call(this,e)}function Nd(e){for(const t of this._compilations)if(Pw(t,e))return t}ot.getCompilingSchema=Nd;function Pw(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function Tw(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Os.call(this,e,t)}function Os(e,t){const r=this.opts.uriResolver.parse(t),n=(0,wt._getFullPath)(this.opts.uriResolver,r);let s=(0,wt.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===s)return Ws.call(this,r,e);const o=(0,wt.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){const i=Os.call(this,e,a);return typeof(i==null?void 0:i.schema)!="object"?void 0:Ws.call(this,r,i)}if(typeof(a==null?void 0:a.schema)=="object"){if(a.validate||Fa.call(this,a),o===(0,wt.normalizeId)(t)){const{schema:i}=a,{schemaId:c}=this.opts,l=i[c];return l&&(s=(0,wt.resolveUrl)(this.opts.uriResolver,s,l)),new js({schema:i,schemaId:c,root:e,baseId:s})}return Ws.call(this,r,a)}}ot.resolveSchema=Os;const Rw=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Ws(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,Kc.unescapeFragment)(i)];if(c===void 0)return;r=c;const l=typeof r=="object"&&r[this.opts.schemaId];!Rw.has(i)&&l&&(t=(0,wt.resolveUrl)(this.opts.uriResolver,t,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,Kc.schemaHasRulesButRef)(r,this.RULES)){const i=(0,wt.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=Os.call(this,n,i)}const{schemaId:a}=this.opts;if(o=o||new js({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}const Cw="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",Nw="Meta-schema for $data reference (JSON AnySchema extension proposal)",Iw="object",jw=["$data"],Ow={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},Aw=!1,Mw={$id:Cw,description:Nw,type:Iw,required:jw,properties:Ow,additionalProperties:Aw};var La={},As={exports:{}};const zw=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Id=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),Ha=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),jd=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),xw=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function Od(e){let t="",r=0,n=0;for(n=0;n=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}const qw=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Gc(e){return e.length=0,!0}function Dw(e,t,r){if(e.length){const n=Od(e);if(n!=="")t.push(n);else return r.error=!0,!1;e.length=0}return!0}function Uw(e){let t=0;const r={error:!1,address:"",zone:""},n=[],s=[];let o=!1,a=!1,i=Dw;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=Gc}else{s.push(l);continue}}return s.length&&(i===Gc?r.zone=s.join(""):a?n.push(s.join("")):n.push(Od(s))),r.address=n.join(""),r}function Ad(e){if(Vw(e,":")<2)return{host:e,isIPV6:!1};const t=Uw(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 Vw(e,t){let r=0;for(let n=0;nLw[n])}function Kw(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n65535))return"URI port is malformed."}function ls(e,t){const r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0};let s=!1,o=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);const a=e.match(b0);a!==null&&a[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",s=!0);const i=e.match(S0);if(i!==null){const l=i[1],d=l.replace(/[\t\n\r]/g,"");d.length>=2&&(d.slice(0,2)!=="//"?(n.error=n.error||"URI authority must not contain a literal backslash.",s=!0):l.length!==d.length&&(n.error=n.error||"URI authority introducer must not contain whitespace.",s=!0))}const c=e.match(w0);if(c){n.scheme=c[1],n.userinfo=c[3],n.host=c[4],n.port=parseInt(c[5],10),n.path=c[6]||"",n.query=c[7],n.fragment=c[8],isNaN(n.port)&&(n.port=c[5]);const l=E0(n,c);if(l!==void 0&&(n.error=n.error||l,s=!0),n.host)if(m0(n.host)===!1){const _=l0(n.host);n.host=_.host.toLowerCase(),o=_.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=Vd(r.scheme||n.scheme);if(!r.unicodeSupport&&(!d||!d.unicodeSupport)&&n.host&&(r.domainHost||d&&d.domainHost)&&o===!1&&g0(n.host))try{n.host=new URL("http://"+n.host).hostname}catch(f){n.error=n.error||"Host's domain name can not be converted to ASCII: "+f}if((!d||d&&!d.skipNormalize)&&(e.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=p0(unescape(n.host),o))),n.path&&(n.path=f0(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 us(e,t){return ls(e,t).parsed}function k0(e,t){return Ld(e,t).normalized}function Ld(e,t){const{parsed:r,malformedAuthorityOrPort:n}=ls(e,t);return{normalized:n?e:lr(r,t),malformedAuthorityOrPort:n}}function Wc(e,t){if(typeof e=="string"){const{normalized:r,malformedAuthorityOrPort:n}=Ld(e,t);return n?void 0:r}if(typeof e=="object")return lr(e,t)}const Ka={SCHEMES:_0,normalize:y0,resolve:v0,resolveComponent:Fd,equal:$0,serialize:lr,parse:us};As.exports=Ka;As.exports.default=Ka;As.exports.fastUri=Ka;var Hd=As.exports;Object.defineProperty(La,"__esModule",{value:!0});const Zd=Hd;Zd.code='require("ajv/dist/runtime/uri").default';La.default=Zd;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=St;Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=ge;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});const n=kn,s=Ar,o=cr,a=ot,i=ge,c=Ge,l=qe,d=W,f=Mw,_=La,g=(A,w)=>new RegExp(A,w);g.code="new RegExp";const m=["removeAdditional","useDefaults","coerceTypes"],v=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),y={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},h={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},$=200;function S(A){var w,C,b,u,p,E,q,D,Y,J,N,O,U,H,X,ce,Ae,tt,Ve,Fe,Me,Et,Ye,Zt,Kt;const mt=A.strict,Gt=(w=A.code)===null||w===void 0?void 0:w.optimize,Ur=Gt===!0||Gt===void 0?1:Gt||0,Vr=(b=(C=A.code)===null||C===void 0?void 0:C.regExp)!==null&&b!==void 0?b:g,Fs=(u=A.uriResolver)!==null&&u!==void 0?u:_.default;return{strictSchema:(E=(p=A.strictSchema)!==null&&p!==void 0?p:mt)!==null&&E!==void 0?E:!0,strictNumbers:(D=(q=A.strictNumbers)!==null&&q!==void 0?q:mt)!==null&&D!==void 0?D:!0,strictTypes:(J=(Y=A.strictTypes)!==null&&Y!==void 0?Y:mt)!==null&&J!==void 0?J:"log",strictTuples:(O=(N=A.strictTuples)!==null&&N!==void 0?N:mt)!==null&&O!==void 0?O:"log",strictRequired:(H=(U=A.strictRequired)!==null&&U!==void 0?U:mt)!==null&&H!==void 0?H:!1,code:A.code?{...A.code,optimize:Ur,regExp:Vr}:{optimize:Ur,regExp:Vr},loopRequired:(X=A.loopRequired)!==null&&X!==void 0?X:$,loopEnum:(ce=A.loopEnum)!==null&&ce!==void 0?ce:$,meta:(Ae=A.meta)!==null&&Ae!==void 0?Ae:!0,messages:(tt=A.messages)!==null&&tt!==void 0?tt:!0,inlineRefs:(Ve=A.inlineRefs)!==null&&Ve!==void 0?Ve:!0,schemaId:(Fe=A.schemaId)!==null&&Fe!==void 0?Fe:"$id",addUsedSchema:(Me=A.addUsedSchema)!==null&&Me!==void 0?Me:!0,validateSchema:(Et=A.validateSchema)!==null&&Et!==void 0?Et:!0,validateFormats:(Ye=A.validateFormats)!==null&&Ye!==void 0?Ye:!0,unicodeRegExp:(Zt=A.unicodeRegExp)!==null&&Zt!==void 0?Zt:!0,int32range:(Kt=A.int32range)!==null&&Kt!==void 0?Kt:!0,uriResolver:Fs}}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,...S(w)};const{es5:C,lines:b}=this.opts.code;this.scope=new i.ValueScope({scope:{},prefixes:v,es5:C,lines:b}),this.logger=Q(w.logger);const u=w.validateFormats;w.validateFormats=!1,this.RULES=(0,o.getRules)(),k.call(this,y,w,"NOT SUPPORTED"),k.call(this,h,w,"DEPRECATED","warn"),this._metaOpts=Z.call(this),w.formats&&F.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),w.keywords&&G.call(this,w.keywords),typeof w.meta=="object"&&this.addMetaSchema(w.meta),z.call(this),w.validateFormats=u}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:w,meta:C,schemaId:b}=this.opts;let u=f;b==="id"&&(u={...f},u.id=u.$id,delete u.$id),C&&w&&this.addMetaSchema(u,u[b],!1)}defaultMeta(){const{meta:w,schemaId:C}=this.opts;return this.opts.defaultMeta=typeof w=="object"?w[C]||w:void 0}validate(w,C){let b;if(typeof w=="string"){if(b=this.getSchema(w),!b)throw new Error(`no schema with key or ref "${w}"`)}else b=this.compile(w);const u=b(C);return"$async"in b||(this.errors=b.errors),u}compile(w,C){const b=this._addSchema(w,C);return b.validate||this._compileSchemaEnv(b)}compileAsync(w,C){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:b}=this.opts;return u.call(this,w,C);async function u(J,N){await p.call(this,J.$schema);const O=this._addSchema(J,N);return O.validate||E.call(this,O)}async function p(J){J&&!this.getSchema(J)&&await u.call(this,{$ref:J},!0)}async function E(J){try{return this._compileSchemaEnv(J)}catch(N){if(!(N instanceof s.default))throw N;return q.call(this,N),await D.call(this,N.missingSchema),E.call(this,J)}}function q({missingSchema:J,missingRef:N}){if(this.refs[J])throw new Error(`AnySchema ${J} is loaded but ${N} cannot be resolved`)}async function D(J){const N=await Y.call(this,J);this.refs[J]||await p.call(this,N.$schema),this.refs[J]||this.addSchema(N,J,C)}async function Y(J){const N=this._loading[J];if(N)return N;try{return await(this._loading[J]=b(J))}finally{delete this._loading[J]}}}addSchema(w,C,b,u=this.opts.validateSchema){if(Array.isArray(w)){for(const E of w)this.addSchema(E,void 0,b,u);return this}let p;if(typeof w=="object"){const{schemaId:E}=this.opts;if(p=w[E],p!==void 0&&typeof p!="string")throw new Error(`schema ${E} must be string`)}return C=(0,c.normalizeId)(C||p),this._checkUnique(C),this.schemas[C]=this._addSchema(w,b,C,u,!0),this}addMetaSchema(w,C,b=this.opts.validateSchema){return this.addSchema(w,C,!0,b),this}validateSchema(w,C){if(typeof w=="boolean")return!0;let b;if(b=w.$schema,b!==void 0&&typeof b!="string")throw new Error("$schema must be a string");if(b=b||this.opts.defaultMeta||this.defaultMeta(),!b)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const u=this.validate(b,w);if(!u&&C){const p="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(p);else throw new Error(p)}return u}getSchema(w){let C;for(;typeof(C=I.call(this,w))=="string";)w=C;if(C===void 0){const{schemaId:b}=this.opts,u=new a.SchemaEnv({schema:{},schemaId:b});if(C=a.resolveSchema.call(this,u,w),!C)return;this.refs[w]=C}return C.validate||this._compileSchemaEnv(C)}removeSchema(w){if(w instanceof RegExp)return this._removeAllSchemas(this.schemas,w),this._removeAllSchemas(this.refs,w),this;switch(typeof w){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const C=I.call(this,w);return typeof C=="object"&&this._cache.delete(C.schema),delete this.schemas[w],delete this.refs[w],this}case"object":{const C=w;this._cache.delete(C);let b=w[this.opts.schemaId];return b&&(b=(0,c.normalizeId)(b),delete this.schemas[b],delete this.refs[b]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(w){for(const C of w)this.addKeyword(C);return this}addKeyword(w,C){let b;if(typeof w=="string")b=w,typeof C=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),C.keyword=b);else if(typeof w=="object"&&C===void 0){if(C=w,b=C.keyword,Array.isArray(b)&&!b.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(V.call(this,b,C),!C)return(0,d.eachItem)(b,p=>ie.call(this,p)),this;$e.call(this,C);const u={...C,type:(0,l.getJSONTypes)(C.type),schemaType:(0,l.getJSONTypes)(C.schemaType)};return(0,d.eachItem)(b,u.type.length===0?p=>ie.call(this,p,u):p=>u.type.forEach(E=>ie.call(this,p,u,E))),this}getKeyword(w){const C=this.RULES.all[w];return typeof C=="object"?C.definition:!!C}removeKeyword(w){const{RULES:C}=this;delete C.keywords[w],delete C.all[w];for(const b of C.rules){const u=b.rules.findIndex(p=>p.keyword===w);u>=0&&b.rules.splice(u,1)}return this}addFormat(w,C){return typeof C=="string"&&(C=new RegExp(C)),this.formats[w]=C,this}errorsText(w=this.errors,{separator:C=", ",dataVar:b="data"}={}){return!w||w.length===0?"No errors":w.map(u=>`${b}${u.instancePath} ${u.message}`).reduce((u,p)=>u+C+p)}$dataMetaSchema(w,C){const b=this.RULES.all;w=JSON.parse(JSON.stringify(w));for(const u of C){const p=u.split("/").slice(1);let E=w;for(const q of p)E=E[q];for(const q in b){const D=b[q];if(typeof D!="object")continue;const{$data:Y}=D.definition,J=E[q];Y&&J&&(E[q]=Oe(J))}}return w}_removeAllSchemas(w,C){for(const b in w){const u=w[b];(!C||C.test(b))&&(typeof u=="string"?delete w[b]:u&&!u.meta&&(this._cache.delete(u.schema),delete w[b]))}}_addSchema(w,C,b,u=this.opts.validateSchema,p=this.opts.addUsedSchema){let E;const{schemaId:q}=this.opts;if(typeof w=="object")E=w[q];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof w!="boolean")throw new Error("schema must be object or boolean")}let D=this._cache.get(w);if(D!==void 0)return D;b=(0,c.normalizeId)(E||b);const Y=c.getSchemaRefs.call(this,w,b);return D=new a.SchemaEnv({schema:w,schemaId:q,meta:C,baseId:b,localRefs:Y}),this._cache.set(D.schema,D),p&&!b.startsWith("#")&&(b&&this._checkUnique(b),this.refs[b]=D),u&&this.validateSchema(w,!0),D}_checkUnique(w){if(this.schemas[w]||this.refs[w])throw new Error(`schema with key or id "${w}" already exists`)}_compileSchemaEnv(w){if(w.meta?this._compileMetaSchema(w):a.compileSchema.call(this,w),!w.validate)throw new Error("ajv implementation error");return w.validate}_compileMetaSchema(w){const C=this.opts;this.opts=this._metaOpts;try{a.compileSchema.call(this,w)}finally{this.opts=C}}}T.ValidationError=n.default,T.MissingRefError=s.default,e.default=T;function k(A,w,C,b="error"){for(const u in A){const p=u;p in w&&this.logger[b](`${C}: option ${u}. ${A[p]}`)}}function I(A){return A=(0,c.normalizeId)(A),this.schemas[A]||this.refs[A]}function z(){const A=this.opts.schemas;if(A)if(Array.isArray(A))this.addSchema(A);else for(const w in A)this.addSchema(A[w],w)}function F(){for(const A in this.opts.formats){const w=this.opts.formats[A];w&&this.addFormat(A,w)}}function G(A){if(Array.isArray(A)){this.addVocabulary(A);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const w in A){const C=A[w];C.keyword||(C.keyword=w),this.addKeyword(C)}}function Z(){const A={...this.opts};for(const w of m)delete A[w];return A}const K={log(){},warn(){},error(){}};function Q(A){if(A===!1)return K;if(A===void 0)return console;if(A.log&&A.warn&&A.error)return A;throw new Error("logger must implement log, warn and error methods")}const re=/^[a-z_$][a-z0-9_$:-]*$/i;function V(A,w){const{RULES:C}=this;if((0,d.eachItem)(A,b=>{if(C.keywords[b])throw new Error(`Keyword ${b} is already defined`);if(!re.test(b))throw new Error(`Keyword ${b} has invalid name`)}),!!w&&w.$data&&!("code"in w||"validate"in w))throw new Error('$data keyword must have "code" or "validate" function')}function ie(A,w,C){var b;const u=w==null?void 0:w.post;if(C&&u)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:p}=this;let E=u?p.post:p.rules.find(({type:D})=>D===C);if(E||(E={type:C,rules:[]},p.rules.push(E)),p.keywords[A]=!0,!w)return;const q={keyword:A,definition:{...w,type:(0,l.getJSONTypes)(w.type),schemaType:(0,l.getJSONTypes)(w.schemaType)}};w.before?ke.call(this,E,q,w.before):E.rules.push(q),p.all[A]=q,(b=w.implements)===null||b===void 0||b.forEach(D=>this.addKeyword(D))}function ke(A,w,C){const b=A.rules.findIndex(u=>u.keyword===C);b>=0?A.rules.splice(b,0,w):(A.rules.push(w),this.logger.warn(`rule ${C} is not defined`))}function $e(A){let{metaSchema:w}=A;w!==void 0&&(A.$data&&this.opts.$data&&(w=Oe(w)),A.validateSchema=this.compile(w,!0))}const ct={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Oe(A){return{anyOf:[A,ct]}}})(Xu);var Ga={},Wa={},Ba={};Object.defineProperty(Ba,"__esModule",{value:!0});const P0={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Ba.default=P0;var ur={};Object.defineProperty(ur,"__esModule",{value:!0});ur.callRef=ur.getValidate=void 0;const T0=Ar,Bc=pe,nt=ge,mr=Rt,Jc=ot,On=W,R0={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:r,it:n}=e,{baseId:s,schemaEnv:o,validateName:a,opts:i,self:c}=n,{root:l}=o;if((r==="#"||r==="#/")&&s===l.baseId)return f();const d=Jc.resolveRef.call(c,l,s,r);if(d===void 0)throw new T0.default(n.opts.uriResolver,s,r);if(d instanceof Jc.SchemaEnv)return _(d);return g(d);function f(){if(o===l)return Wn(e,a,o,o.$async);const m=t.scopeValue("root",{ref:l});return Wn(e,(0,nt._)`${m}.validate`,l,l.$async)}function _(m){const v=Kd(e,m);Wn(e,v,m,m.$async)}function g(m){const v=t.scopeValue("schema",i.code.source===!0?{ref:m,code:(0,nt.stringify)(m)}:{ref:m}),y=t.name("valid"),h=e.subschema({schema:m,dataTypes:[],schemaPath:nt.nil,topSchemaRef:v,errSchemaPath:r},y);e.mergeEvaluated(h),e.ok(y)}}};function Kd(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,nt._)`${r.scopeValue("wrapper",{ref:t})}.validate`}ur.getValidate=Kd;function Wn(e,t,r,n){const{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:c}=o,l=c.passContext?mr.default.this:nt.nil;n?d():f();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");const m=s.let("valid");s.try(()=>{s.code((0,nt._)`await ${(0,Bc.callValidateCode)(e,t,l)}`),g(t),a||s.assign(m,!0)},v=>{s.if((0,nt._)`!(${v} instanceof ${o.ValidationError})`,()=>s.throw(v)),_(v),a||s.assign(m,!1)}),e.ok(m)}function f(){e.result((0,Bc.callValidateCode)(e,t,l),()=>g(t),()=>_(t))}function _(m){const v=(0,nt._)`${m}.errors`;s.assign(mr.default.vErrors,(0,nt._)`${mr.default.vErrors} === null ? ${v} : ${mr.default.vErrors}.concat(${v})`),s.assign(mr.default.errors,(0,nt._)`${mr.default.vErrors}.length`)}function g(m){var v;if(!o.opts.unevaluated)return;const y=(v=r==null?void 0:r.validate)===null||v===void 0?void 0:v.evaluated;if(o.props!==!0)if(y&&!y.dynamicProps)y.props!==void 0&&(o.props=On.mergeEvaluated.props(s,y.props,o.props));else{const h=s.var("props",(0,nt._)`${m}.evaluated.props`);o.props=On.mergeEvaluated.props(s,h,o.props,nt.Name)}if(o.items!==!0)if(y&&!y.dynamicItems)y.items!==void 0&&(o.items=On.mergeEvaluated.items(s,y.items,o.items));else{const h=s.var("items",(0,nt._)`${m}.evaluated.items`);o.items=On.mergeEvaluated.items(s,h,o.items,nt.Name)}}}ur.callRef=Wn;ur.default=R0;Object.defineProperty(Wa,"__esModule",{value:!0});const C0=Ba,N0=ur,I0=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",C0.default,N0.default];Wa.default=I0;var Ja={},Qa={};Object.defineProperty(Qa,"__esModule",{value:!0});const ds=ge,zt=ds.operators,fs={maximum:{okStr:"<=",ok:zt.LTE,fail:zt.GT},minimum:{okStr:">=",ok:zt.GTE,fail:zt.LT},exclusiveMaximum:{okStr:"<",ok:zt.LT,fail:zt.GTE},exclusiveMinimum:{okStr:">",ok:zt.GT,fail:zt.LTE}},j0={message:({keyword:e,schemaCode:t})=>(0,ds.str)`must be ${fs[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,ds._)`{comparison: ${fs[e].okStr}, limit: ${t}}`},O0={keyword:Object.keys(fs),type:"number",schemaType:"number",$data:!0,error:j0,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,ds._)`${r} ${fs[t].fail} ${n} || isNaN(${r})`)}};Qa.default=O0;var Ya={};Object.defineProperty(Ya,"__esModule",{value:!0});const Xr=ge,A0={message:({schemaCode:e})=>(0,Xr.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,Xr._)`{multipleOf: ${e}}`},M0={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:A0,code(e){const{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0,Xr._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0,Xr._)`${a} !== parseInt(${a})`;e.fail$data((0,Xr._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};Ya.default=M0;var Xa={},ei={};Object.defineProperty(ei,"__esModule",{value:!0});function Gd(e){const t=e.length;let r=0,n=0,s;for(;n=55296&&s<=56319&&n(0,rr._)`{limit: ${e}}`},D0={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:q0,code(e){const{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?rr.operators.GT:rr.operators.LT,a=s.opts.unicode===!1?(0,rr._)`${r}.length`:(0,rr._)`${(0,z0.useFunc)(e.gen,x0.default)}(${r})`;e.fail$data((0,rr._)`${a} ${o} ${n}`)}};Xa.default=D0;var ti={};Object.defineProperty(ti,"__esModule",{value:!0});const U0=pe,V0=W,br=ge,F0={message:({schemaCode:e})=>(0,br.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,br._)`{pattern: ${e}}`},L0={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:F0,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,br._)`new RegExp`:(0,V0.useFunc)(t,c),d=t.let("valid");t.try(()=>t.assign(d,(0,br._)`${l}(${o}, ${i}).test(${r})`),()=>t.assign(d,!1)),e.fail$data((0,br._)`!${d}`)}else{const c=(0,U0.usePattern)(e,s);e.fail$data((0,br._)`!${c}.test(${r})`)}}};ti.default=L0;var ri={};Object.defineProperty(ri,"__esModule",{value:!0});const en=ge,H0={message({keyword:e,schemaCode:t}){const r=e==="maxProperties"?"more":"fewer";return(0,en.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,en._)`{limit: ${e}}`},Z0={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:H0,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?en.operators.GT:en.operators.LT;e.fail$data((0,en._)`Object.keys(${r}).length ${s} ${n}`)}};ri.default=Z0;var ni={};Object.defineProperty(ni,"__esModule",{value:!0});const Hr=pe,tn=ge,K0=W,G0={message:({params:{missingProperty:e}})=>(0,tn.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,tn._)`{missingProperty: ${e}}`},W0={keyword:"required",type:"object",schemaType:"array",$data:!0,error:G0,code(e){const{gen:t,schema:r,schemaCode:n,data:s,$data:o,it:a}=e,{opts:i}=a;if(!o&&r.length===0)return;const c=r.length>=i.loopRequired;if(a.allErrors?l():d(),i.strictRequired){const g=e.parentSchema.properties,{definedProperties:m}=e.it;for(const v of r)if((g==null?void 0:g[v])===void 0&&!m.has(v)){const y=a.schemaEnv.baseId+a.errSchemaPath,h=`required property "${v}" is not defined at "${y}" (strictRequired)`;(0,K0.checkStrictMode)(a,h,a.opts.strictRequired)}}function l(){if(c||o)e.block$data(tn.nil,f);else for(const g of r)(0,Hr.checkReportMissingProp)(e,g)}function d(){const g=t.let("missing");if(c||o){const m=t.let("valid",!0);e.block$data(m,()=>_(g,m)),e.ok(m)}else t.if((0,Hr.checkMissingProp)(e,r,g)),(0,Hr.reportMissingProp)(e,g),t.else()}function f(){t.forOf("prop",n,g=>{e.setParams({missingProperty:g}),t.if((0,Hr.noPropertyInData)(t,s,g,i.ownProperties),()=>e.error())})}function _(g,m){e.setParams({missingProperty:g}),t.forOf(g,n,()=>{t.assign(m,(0,Hr.propertyInData)(t,s,g,i.ownProperties)),t.if((0,tn.not)(m),()=>{e.error(),t.break()})},tn.nil)}}};ni.default=W0;var si={};Object.defineProperty(si,"__esModule",{value:!0});const rn=ge,B0={message({keyword:e,schemaCode:t}){const r=e==="maxItems"?"more":"fewer";return(0,rn.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,rn._)`{limit: ${e}}`},J0={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:B0,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?rn.operators.GT:rn.operators.LT;e.fail$data((0,rn._)`${r}.length ${s} ${n}`)}};si.default=J0;var oi={},Pn={};Object.defineProperty(Pn,"__esModule",{value:!0});const Wd=Is;Wd.code='require("ajv/dist/runtime/equal").default';Pn.default=Wd;Object.defineProperty(oi,"__esModule",{value:!0});const Bs=qe,He=ge,Q0=W,Y0=Pn,X0={message:({params:{i:e,j:t}})=>(0,He.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,He._)`{i: ${e}, j: ${t}}`},eb={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:X0,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,Bs.getSchemaTypes)(o.items):[];e.block$data(c,d,(0,He._)`${a} === false`),e.ok(c);function d(){const m=t.let("i",(0,He._)`${r}.length`),v=t.let("j");e.setParams({i:m,j:v}),t.assign(c,!0),t.if((0,He._)`${m} > 1`,()=>(f()?_:g)(m,v))}function f(){return l.length>0&&!l.some(m=>m==="object"||m==="array")}function _(m,v){const y=t.name("item"),h=(0,Bs.checkDataTypes)(l,y,i.opts.strictNumbers,Bs.DataType.Wrong),$=t.const("indices",(0,He._)`{}`);t.for((0,He._)`;${m}--;`,()=>{t.let(y,(0,He._)`${r}[${m}]`),t.if(h,(0,He._)`continue`),l.length>1&&t.if((0,He._)`typeof ${y} == "string"`,(0,He._)`${y} += "_"`),t.if((0,He._)`typeof ${$}[${y}] == "number"`,()=>{t.assign(v,(0,He._)`${$}[${y}]`),e.error(),t.assign(c,!1).break()}).code((0,He._)`${$}[${y}] = ${m}`)})}function g(m,v){const y=(0,Q0.useFunc)(t,Y0.default),h=t.name("outer");t.label(h).for((0,He._)`;${m}--;`,()=>t.for((0,He._)`${v} = ${m}; ${v}--;`,()=>t.if((0,He._)`${y}(${r}[${m}], ${r}[${v}])`,()=>{e.error(),t.assign(c,!1).break(h)})))}}};oi.default=eb;var ai={};Object.defineProperty(ai,"__esModule",{value:!0});const $o=ge,tb=W,rb=Pn,nb={message:"must be equal to constant",params:({schemaCode:e})=>(0,$o._)`{allowedValue: ${e}}`},sb={keyword:"const",$data:!0,error:nb,code(e){const{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,$o._)`!${(0,tb.useFunc)(t,rb.default)}(${r}, ${s})`):e.fail((0,$o._)`${o} !== ${r}`)}};ai.default=sb;var ii={};Object.defineProperty(ii,"__esModule",{value:!0});const Br=ge,ob=W,ab=Pn,ib={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,Br._)`{allowedValues: ${e}}`},cb={keyword:"enum",schemaType:"array",$data:!0,error:ib,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,ob.useFunc)(t,ab.default));let d;if(i||n)d=t.let("valid"),e.block$data(d,f);else{if(!Array.isArray(s))throw new Error("ajv implementation error");const g=t.const("vSchema",o);d=(0,Br.or)(...s.map((m,v)=>_(g,v)))}e.pass(d);function f(){t.assign(d,!1),t.forOf("v",o,g=>t.if((0,Br._)`${l()}(${r}, ${g})`,()=>t.assign(d,!0).break()))}function _(g,m){const v=s[m];return typeof v=="object"&&v!==null?(0,Br._)`${l()}(${r}, ${g}[${m}])`:(0,Br._)`${r} === ${v}`}}};ii.default=cb;Object.defineProperty(Ja,"__esModule",{value:!0});const lb=Qa,ub=Ya,db=Xa,fb=ti,hb=ri,pb=ni,mb=si,gb=oi,_b=ai,yb=ii,vb=[lb.default,ub.default,db.default,fb.default,hb.default,pb.default,mb.default,gb.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},_b.default,yb.default];Ja.default=vb;var ci={},Mr={};Object.defineProperty(Mr,"__esModule",{value:!0});Mr.validateAdditionalItems=void 0;const nr=ge,wo=W,$b={message:({params:{len:e}})=>(0,nr.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,nr._)`{limit: ${e}}`},wb={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:$b,code(e){const{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,wo.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Bd(e,n)}};function Bd(e,t){const{gen:r,schema:n,data:s,keyword:o,it:a}=e;a.items=!0;const i=r.const("len",(0,nr._)`${s}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,nr._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0,wo.alwaysValidSchema)(a,n)){const l=r.var("valid",(0,nr._)`${i} <= ${t.length}`);r.if((0,nr.not)(l),()=>c(l)),e.ok(l)}function c(l){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:wo.Type.Num},l),a.allErrors||r.if((0,nr.not)(l),()=>r.break())})}}Mr.validateAdditionalItems=Bd;Mr.default=wb;var li={},zr={};Object.defineProperty(zr,"__esModule",{value:!0});zr.validateTuple=void 0;const Qc=ge,Bn=W,bb=pe,Sb={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return Jd(e,"additionalItems",t);r.items=!0,!(0,Bn.alwaysValidSchema)(r,t)&&e.ok((0,bb.validateArray)(e))}};function Jd(e,t,r=e.schema){const{gen:n,parentSchema:s,data:o,keyword:a,it:i}=e;d(s),i.opts.unevaluated&&r.length&&i.items!==!0&&(i.items=Bn.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),l=n.const("len",(0,Qc._)`${o}.length`);r.forEach((f,_)=>{(0,Bn.alwaysValidSchema)(i,f)||(n.if((0,Qc._)`${l} > ${_}`,()=>e.subschema({keyword:a,schemaProp:_,dataProp:_},c)),e.ok(c))});function d(f){const{opts:_,errSchemaPath:g}=i,m=r.length,v=m===f.minItems&&(m===f.maxItems||f[t]===!1);if(_.strictTuples&&!v){const y=`"${a}" is ${m}-tuple, but minItems or maxItems/${t} are not specified or different at path "${g}"`;(0,Bn.checkStrictMode)(i,y,_.strictTuples)}}}zr.validateTuple=Jd;zr.default=Sb;Object.defineProperty(li,"__esModule",{value:!0});const Eb=zr,kb={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,Eb.validateTuple)(e,"items")};li.default=kb;var ui={};Object.defineProperty(ui,"__esModule",{value:!0});const Yc=ge,Pb=W,Tb=pe,Rb=Mr,Cb={message:({params:{len:e}})=>(0,Yc.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Yc._)`{limit: ${e}}`},Nb={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:Cb,code(e){const{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=!0,!(0,Pb.alwaysValidSchema)(n,t)&&(s?(0,Rb.validateAdditionalItems)(e,s):e.ok((0,Tb.validateArray)(e)))}};ui.default=Nb;var di={};Object.defineProperty(di,"__esModule",{value:!0});const dt=ge,An=W,Ib={message:({params:{min:e,max:t}})=>t===void 0?(0,dt.str)`must contain at least ${e} valid item(s)`:(0,dt.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,dt._)`{minContains: ${e}}`:(0,dt._)`{minContains: ${e}, maxContains: ${t}}`},jb={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:Ib,code(e){const{gen:t,schema:r,parentSchema:n,data:s,it:o}=e;let a,i;const{minContains:c,maxContains:l}=n;o.opts.next?(a=c===void 0?1:c,i=l):a=1;const d=t.const("len",(0,dt._)`${s}.length`);if(e.setParams({min:a,max:i}),i===void 0&&a===0){(0,An.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0,An.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,An.alwaysValidSchema)(o,r)){let v=(0,dt._)`${d} >= ${a}`;i!==void 0&&(v=(0,dt._)`${v} && ${d} <= ${i}`),e.pass(v);return}o.items=!0;const f=t.name("valid");i===void 0&&a===1?g(f,()=>t.if(f,()=>t.break())):a===0?(t.let(f,!0),i!==void 0&&t.if((0,dt._)`${s}.length > 0`,_)):(t.let(f,!1),_()),e.result(f,()=>e.reset());function _(){const v=t.name("_valid"),y=t.let("count",0);g(v,()=>t.if(v,()=>m(y)))}function g(v,y){t.forRange("i",0,d,h=>{e.subschema({keyword:"contains",dataProp:h,dataPropType:An.Type.Num,compositeRule:!0},v),y()})}function m(v){t.code((0,dt._)`${v}++`),i===void 0?t.if((0,dt._)`${v} >= ${a}`,()=>t.assign(f,!0).break()):(t.if((0,dt._)`${v} > ${i}`,()=>t.assign(f,!1).break()),a===1?t.assign(f,!0):t.if((0,dt._)`${v} >= ${a}`,()=>t.assign(f,!0)))}}};di.default=jb;var Qd={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=ge,r=W,n=pe;e.error={message:({params:{property:c,depsCount:l,deps:d}})=>{const f=l===1?"property":"properties";return(0,t.str)`must have ${f} ${d} when property ${c} is present`},params:({params:{property:c,depsCount:l,deps:d,missingProperty:f}})=>(0,t._)`{property: ${c}, - missingProperty: ${f}, - depsCount: ${l}, - deps: ${d}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(c){const[l,d]=o(c);a(c,l),i(c,d)}};function o({schema:c}){const l={},d={};for(const f in c){if(f==="__proto__")continue;const _=Array.isArray(c[f])?l:d;_[f]=c[f]}return[l,d]}function a(c,l=c.schema){const{gen:d,data:f,it:_}=c;if(Object.keys(l).length===0)return;const g=d.let("missing");for(const m in l){const v=l[m];if(v.length===0)continue;const y=(0,n.propertyInData)(d,f,m,_.opts.ownProperties);c.setParams({property:m,depsCount:v.length,deps:v.join(", ")}),_.allErrors?d.if(y,()=>{for(const h of v)(0,n.checkReportMissingProp)(c,h)}):(d.if((0,t._)`${y} && (${(0,n.checkMissingProp)(c,v,g)})`),(0,n.reportMissingProp)(c,g),d.else())}}e.validatePropertyDeps=a;function i(c,l=c.schema){const{gen:d,data:f,keyword:_,it:g}=c,m=d.name("valid");for(const v in l)(0,r.alwaysValidSchema)(g,l[v])||(d.if((0,n.propertyInData)(d,f,v,g.opts.ownProperties),()=>{const y=c.subschema({keyword:_,schemaProp:v},m);c.mergeValidEvaluated(y,m)},()=>d.var(m,!0)),c.ok(m))}e.validateSchemaDeps=i,e.default=s})(Qd);var fi={};Object.defineProperty(fi,"__esModule",{value:!0});const Yd=ge,Ob=W,Ab={message:"property name must be valid",params:({params:e})=>(0,Yd._)`{propertyName: ${e.propertyName}}`},Mb={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Ab,code(e){const{gen:t,schema:r,data:n,it:s}=e;if((0,Ob.alwaysValidSchema)(s,r))return;const o=t.name("valid");t.forIn("key",n,a=>{e.setParams({propertyName:a}),e.subschema({keyword:"propertyNames",data:a,dataTypes:["string"],propertyName:a,compositeRule:!0},o),t.if((0,Yd.not)(o),()=>{e.error(!0),s.allErrors||t.break()})}),e.ok(o)}};fi.default=Mb;var Ms={};Object.defineProperty(Ms,"__esModule",{value:!0});const Mn=pe,vt=ge,zb=Rt,zn=W,xb={message:"must NOT have additional properties",params:({params:e})=>(0,vt._)`{additionalProperty: ${e.additionalProperty}}`},qb={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:xb,code(e){const{gen:t,schema:r,parentSchema:n,data:s,errsCount:o,it:a}=e;if(!o)throw new Error("ajv implementation error");const{allErrors:i,opts:c}=a;if(a.props=!0,c.removeAdditional!=="all"&&(0,zn.alwaysValidSchema)(a,r))return;const l=(0,Mn.allSchemaProperties)(n.properties),d=(0,Mn.allSchemaProperties)(n.patternProperties);f(),e.ok((0,vt._)`${o} === ${zb.default.errors}`);function f(){t.forIn("key",s,y=>{!l.length&&!d.length?m(y):t.if(_(y),()=>m(y))})}function _(y){let h;if(l.length>8){const $=(0,zn.schemaRefOrVal)(a,n.properties,"properties");h=(0,Mn.isOwnProperty)(t,$,y)}else l.length?h=(0,vt.or)(...l.map($=>(0,vt._)`${y} === ${$}`)):h=vt.nil;return d.length&&(h=(0,vt.or)(h,...d.map($=>(0,vt._)`${(0,Mn.usePattern)(e,$)}.test(${y})`))),(0,vt.not)(h)}function g(y){t.code((0,vt._)`delete ${s}[${y}]`)}function m(y){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){g(y);return}if(r===!1){e.setParams({additionalProperty:y}),e.error(),i||t.break();return}if(typeof r=="object"&&!(0,zn.alwaysValidSchema)(a,r)){const h=t.name("valid");c.removeAdditional==="failing"?(v(y,h,!1),t.if((0,vt.not)(h),()=>{e.reset(),g(y)})):(v(y,h),i||t.if((0,vt.not)(h),()=>t.break()))}}function v(y,h,$){const S={keyword:"additionalProperties",dataProp:y,dataPropType:zn.Type.Str};$===!1&&Object.assign(S,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(S,h)}}};Ms.default=qb;var hi={};Object.defineProperty(hi,"__esModule",{value:!0});const Db=St,Xc=pe,Js=W,el=Ms,Ub={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&&el.default.code(new Db.KeywordCxt(o,el.default,"additionalProperties"));const a=(0,Xc.allSchemaProperties)(r);for(const f of a)o.definedProperties.add(f);o.opts.unevaluated&&a.length&&o.props!==!0&&(o.props=Js.mergeEvaluated.props(t,(0,Js.toHash)(a),o.props));const i=a.filter(f=>!(0,Js.alwaysValidSchema)(o,r[f]));if(i.length===0)return;const c=t.name("valid");for(const f of i)l(f)?d(f):(t.if((0,Xc.propertyInData)(t,s,f,o.opts.ownProperties)),d(f),o.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(f),e.ok(c);function l(f){return o.opts.useDefaults&&!o.compositeRule&&r[f].default!==void 0}function d(f){e.subschema({keyword:"properties",schemaProp:f,dataProp:f},c)}}};hi.default=Ub;var pi={};Object.defineProperty(pi,"__esModule",{value:!0});const tl=pe,xn=ge,rl=W,nl=W,Vb={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,tl.allSchemaProperties)(r),c=i.filter(v=>(0,rl.alwaysValidSchema)(o,r[v]));if(i.length===0||c.length===i.length&&(!o.opts.unevaluated||o.props===!0))return;const l=a.strictSchema&&!a.allowMatchingProperties&&s.properties,d=t.name("valid");o.props!==!0&&!(o.props instanceof xn.Name)&&(o.props=(0,nl.evaluatedPropsToName)(t,o.props));const{props:f}=o;_();function _(){for(const v of i)l&&g(v),o.allErrors?m(v):(t.var(d,!0),m(v),t.if(d))}function g(v){for(const y in l)new RegExp(v).test(y)&&(0,rl.checkStrictMode)(o,`property ${y} matches pattern ${v} (use allowMatchingProperties)`)}function m(v){t.forIn("key",n,y=>{t.if((0,xn._)`${(0,tl.usePattern)(e,v)}.test(${y})`,()=>{const h=c.includes(v);h||e.subschema({keyword:"patternProperties",schemaProp:v,dataProp:y,dataPropType:nl.Type.Str},d),o.opts.unevaluated&&f!==!0?t.assign((0,xn._)`${f}[${y}]`,!0):!h&&!o.allErrors&&t.if((0,xn.not)(d),()=>t.break())})})}}};pi.default=Vb;var mi={};Object.defineProperty(mi,"__esModule",{value:!0});const Fb=W,Lb={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,Fb.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"}};mi.default=Lb;var gi={};Object.defineProperty(gi,"__esModule",{value:!0});const Hb=pe,Zb={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:Hb.validateUnion,error:{message:"must match a schema in anyOf"}};gi.default=Zb;var _i={};Object.defineProperty(_i,"__esModule",{value:!0});const Jn=ge,Kb=W,Gb={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,Jn._)`{passingSchemas: ${e.passing}}`},Wb={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:Gb,code(e){const{gen:t,schema:r,parentSchema:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;const o=r,a=t.let("valid",!1),i=t.let("passing",null),c=t.name("_valid");e.setParams({passing:i}),t.block(l),e.result(a,()=>e.reset(),()=>e.error(!0));function l(){o.forEach((d,f)=>{let _;(0,Kb.alwaysValidSchema)(s,d)?t.var(c,!0):_=e.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},c),f>0&&t.if((0,Jn._)`${c} && ${a}`).assign(a,!1).assign(i,(0,Jn._)`[${i}, ${f}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,f),_&&e.mergeEvaluated(_,Jn.Name)})})}}};_i.default=Wb;var yi={};Object.defineProperty(yi,"__esModule",{value:!0});const Bb=W,Jb={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,Bb.alwaysValidSchema)(n,o))return;const i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i)})}};yi.default=Jb;var vi={};Object.defineProperty(vi,"__esModule",{value:!0});const hs=ge,Xd=W,Qb={message:({params:e})=>(0,hs.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,hs._)`{failingKeyword: ${e.ifClause}}`},Yb={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:Qb,code(e){const{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,Xd.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const s=sl(n,"then"),o=sl(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,hs.not)(i),l("else"));e.pass(a,()=>e.error(!0));function c(){const d=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},i);e.mergeEvaluated(d)}function l(d,f){return()=>{const _=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(_,a),f?t.assign(f,(0,hs._)`${d}`):e.setParams({ifClause:d})}}}};function sl(e,t){const r=e.schema[t];return r!==void 0&&!(0,Xd.alwaysValidSchema)(e,r)}vi.default=Yb;var $i={};Object.defineProperty($i,"__esModule",{value:!0});const Xb=W,eS={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,Xb.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};$i.default=eS;Object.defineProperty(ci,"__esModule",{value:!0});const tS=Mr,rS=li,nS=zr,sS=ui,oS=di,aS=Qd,iS=fi,cS=Ms,lS=hi,uS=pi,dS=mi,fS=gi,hS=_i,pS=yi,mS=vi,gS=$i;function _S(e=!1){const t=[dS.default,fS.default,hS.default,pS.default,mS.default,gS.default,iS.default,cS.default,aS.default,lS.default,uS.default];return e?t.push(rS.default,sS.default):t.push(tS.default,nS.default),t.push(oS.default),t}ci.default=_S;var wi={},bi={};Object.defineProperty(bi,"__esModule",{value:!0});const ze=ge,yS={message:({schemaCode:e})=>(0,ze.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,ze._)`{format: ${e}}`},vS={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:yS,code(e,t){const{gen:r,data:n,$data:s,schema:o,schemaCode:a,it:i}=e,{opts:c,errSchemaPath:l,schemaEnv:d,self:f}=i;if(!c.validateFormats)return;s?_():g();function _(){const m=r.scopeValue("formats",{ref:f.formats,code:c.code.formats}),v=r.const("fDef",(0,ze._)`${m}[${a}]`),y=r.let("fType"),h=r.let("format");r.if((0,ze._)`typeof ${v} == "object" && !(${v} instanceof RegExp)`,()=>r.assign(y,(0,ze._)`${v}.type || "string"`).assign(h,(0,ze._)`${v}.validate`),()=>r.assign(y,(0,ze._)`"string"`).assign(h,v)),e.fail$data((0,ze.or)($(),S()));function $(){return c.strictSchema===!1?ze.nil:(0,ze._)`${a} && !${h}`}function S(){const T=d.$async?(0,ze._)`(${v}.async ? await ${h}(${n}) : ${h}(${n}))`:(0,ze._)`${h}(${n})`,k=(0,ze._)`(typeof ${h} == "function" ? ${T} : ${h}.test(${n}))`;return(0,ze._)`${h} && ${h} !== true && ${y} === ${t} && !${k}`}}function g(){const m=f.formats[o];if(!m){$();return}if(m===!0)return;const[v,y,h]=S(m);v===t&&e.pass(T());function $(){if(c.strictSchema===!1){f.logger.warn(k());return}throw new Error(k());function k(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function S(k){const I=k instanceof RegExp?(0,ze.regexpCode)(k):c.code.formats?(0,ze._)`${c.code.formats}${(0,ze.getProperty)(o)}`:void 0,z=r.scopeValue("formats",{key:o,ref:k,code:I});return typeof k=="object"&&!(k instanceof RegExp)?[k.type||"string",k.validate,(0,ze._)`${z}.validate`]:["string",k,z]}function T(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!d.$async)throw new Error("async format in sync schema");return(0,ze._)`await ${h}(${n})`}return typeof y=="function"?(0,ze._)`${h}(${n})`:(0,ze._)`${h}.test(${n})`}}}};bi.default=vS;Object.defineProperty(wi,"__esModule",{value:!0});const $S=bi,wS=[$S.default];wi.default=wS;var Nr={};Object.defineProperty(Nr,"__esModule",{value:!0});Nr.contentVocabulary=Nr.metadataVocabulary=void 0;Nr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Nr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(Ga,"__esModule",{value:!0});const bS=Wa,SS=Ja,ES=ci,kS=wi,ol=Nr,PS=[bS.default,SS.default,(0,ES.default)(),kS.default,ol.metadataVocabulary,ol.contentVocabulary];Ga.default=PS;var Si={},zs={};Object.defineProperty(zs,"__esModule",{value:!0});zs.DiscrError=void 0;var al;(function(e){e.Tag="tag",e.Mapping="mapping"})(al||(zs.DiscrError=al={}));Object.defineProperty(Si,"__esModule",{value:!0});const vr=ge,bo=zs,il=ot,TS=Ar,RS=W,CS={message:({params:{discrError:e,tagName:t}})=>e===bo.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,vr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},NS={keyword:"discriminator",type:"object",schemaType:"object",error:CS,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,vr._)`${r}${(0,vr.getProperty)(i)}`);t.if((0,vr._)`typeof ${l} == "string"`,()=>d(),()=>e.error(!1,{discrError:bo.DiscrError.Tag,tag:l,tagName:i})),e.ok(c);function d(){const g=_();t.if(!1);for(const m in g)t.elseIf((0,vr._)`${l} === ${m}`),t.assign(c,f(g[m]));t.else(),e.error(!1,{discrError:bo.DiscrError.Mapping,tag:l,tagName:i}),t.endIf()}function f(g){const m=t.name("valid"),v=e.subschema({keyword:"oneOf",schemaProp:g},m);return e.mergeEvaluated(v,vr.Name),m}function _(){var g;const m={},v=h(s);let y=!0;for(let T=0;Tthis.addVocabulary(m)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const m=this.opts.$data?this.$dataMetaSchema(o,a):o;this.addMetaSchema(m,i,!1),this.refs["http://json-schema.org/schema"]=i}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(i)?i:void 0)}}t.Ajv=c,e.exports=t=c,e.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var l=St;Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var d=ge;Object.defineProperty(t,"_",{enumerable:!0,get:function(){return d._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return d.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return d.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return d.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return d.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return d.CodeGen}});var f=kn;Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return f.default}});var _=Ar;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return _.default}})})(mo,mo.exports);var qS=mo.exports;const DS=Dl(qS);var So={exports:{}},ef={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(K,Q){return{validate:K,compare:Q}}e.fullFormats={date:t(o,a),time:t(c(!0),l),"date-time":t(_(!0),g),"iso-time":t(c(),d),"iso-date-time":t(_(),m),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:h,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:Z,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:S,int32:{type:"number",validate:I},int64:{type:"number",validate:z},float:{type:"number",validate:F},double:{type:"number",validate:F},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,a),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,l),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,g),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,d),"iso-date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,m),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);function r(K){return K%4===0&&(K%100!==0||K%400===0)}const n=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,s=[0,31,28,31,30,31,30,31,31,30,31,30,31];function o(K){const Q=n.exec(K);if(!Q)return!1;const re=+Q[1],V=+Q[2],ie=+Q[3];return V>=1&&V<=12&&ie>=1&&ie<=(V===2&&r(re)?29:s[V])}function a(K,Q){if(K&&Q)return K>Q?1:K23||w>59||K&&!ct)return!1;if(ie<=23&&ke<=59&&$e<60)return!0;const C=ke-w*Oe,b=ie-A*Oe-(C<0?1:0);return(b===23||b===-1)&&(C===59||C===-1)&&$e<61}}function l(K,Q){if(!(K&&Q))return;const re=new Date("2020-01-01T"+K).valueOf(),V=new Date("2020-01-01T"+Q).valueOf();if(re&&V)return re-V}function d(K,Q){if(!(K&&Q))return;const re=i.exec(K),V=i.exec(Q);if(re&&V)return K=re[1]+re[2]+re[3],Q=V[1]+V[2]+V[3],K>Q?1:K=T}function z(K){return Number.isInteger(K)}function F(){return!0}const G=/[^\\]\\Z/;function Z(K){if(G.test(K))return!1;try{return new RegExp(K),!0}catch{return!1}}})(ef);var tf={},Eo={exports:{}},rf={},Nt={},Qt={},Tn={},he={},hn={};(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((S,T)=>`${S}${T}`,"")}get names(){var $;return($=this._names)!==null&&$!==void 0?$:this._names=this._items.reduce((S,T)=>(T instanceof r&&(S[T.str]=(S[T.str]||0)+1),S),{})}}e._Code=n,e.nil=new n("");function s(h,...$){const S=[h[0]];let T=0;for(;T<$.length;)i(S,$[T]),S.push(h[++T]);return new n(S)}e._=s;const o=new n("+");function a(h,...$){const S=[g(h[0])];let T=0;for(;T<$.length;)S.push(o),i(S,$[T]),S.push(o,g(h[++T]));return c(S),new n(S)}e.str=a;function i(h,$){$ instanceof n?h.push(...$._items):$ instanceof r?h.push($):h.push(f($))}e.addCodeArg=i;function c(h){let $=1;for(;${if(f.scopePath===void 0)throw new Error(`CodeGen: name "${f}" has no value`);return(0,t._)`${l}${f.scopePath}`})}scopeCode(l=this._values,d,f){return this._reduceValues(l,_=>{if(_.value===void 0)throw new Error(`CodeGen: name "${_}" has no value`);return _.value.code},d,f)}_reduceValues(l,d,f={},_){let g=t.nil;for(const m in l){const v=l[m];if(!v)continue;const y=f[m]=f[m]||new Map;v.forEach(h=>{if(y.has(h))return;y.set(h,n.Started);let $=d(h);if($){const S=this.opts.es5?e.varKinds.var:e.varKinds.const;g=(0,t._)`${g}${S} ${h} = ${$};${this.opts._n}`}else if($=_==null?void 0:_(h))g=(0,t._)`${g}${$}${this.opts._n}`;else throw new r(h);y.set(h,n.Completed)})}return g}}e.ValueScope=i})(ko);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=hn,r=ko;var n=hn;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}});var s=ko;Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class o{optimizeNodes(){return this}optimizeNames(u,p){return this}}class a extends o{constructor(u,p,E){super(),this.varKind=u,this.name=p,this.rhs=E}render({es5:u,_n:p}){const E=u?r.varKinds.var:this.varKind,q=this.rhs===void 0?"":` = ${this.rhs}`;return`${E} ${this.name}${q};`+p}optimizeNames(u,p){if(u[this.name.str])return this.rhs&&(this.rhs=V(this.rhs,u,p)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class i extends o{constructor(u,p,E){super(),this.lhs=u,this.rhs=p,this.sideEffects=E}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=V(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,E,q){super(u,E,q),this.op=p}render({_n:u}){return`${this.lhs} ${this.op}= ${this.rhs};`+u}}class l extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`${this.label}:`+u}}class d extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`break${this.label?` ${this.label}`:""};`+u}}class f extends o{constructor(u){super(),this.error=u}render({_n:u}){return`throw ${this.error};`+u}get names(){return this.error.names}}class _ 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=V(this.code,u,p),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}}class g extends o{constructor(u=[]){super(),this.nodes=u}render(u){return this.nodes.reduce((p,E)=>p+E.render(u),"")}optimizeNodes(){const{nodes:u}=this;let p=u.length;for(;p--;){const E=u[p].optimizeNodes();Array.isArray(E)?u.splice(p,1,...E):E?u[p]=E:u.splice(p,1)}return u.length>0?this:void 0}optimizeNames(u,p){const{nodes:E}=this;let q=E.length;for(;q--;){const D=E[q];D.optimizeNames(u,p)||(ie(u,D.names),E.splice(q,1))}return E.length>0?this:void 0}get names(){return this.nodes.reduce((u,p)=>Q(u,p.names),{})}}class m extends g{render(u){return"{"+u._n+super.render(u)+"}"+u._n}}class v extends g{}class y extends m{}y.kind="else";class h extends m{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 E=p.optimizeNodes();p=this.else=Array.isArray(E)?new y(E):E}if(p)return u===!1?p instanceof h?p:p.nodes:this.nodes.length?this:new h(ke(u),p instanceof h?[p]:p.nodes);if(!(u===!1||!this.nodes.length))return this}optimizeNames(u,p){var E;if(this.else=(E=this.else)===null||E===void 0?void 0:E.optimizeNames(u,p),!!(super.optimizeNames(u,p)||this.else))return this.condition=V(this.condition,u,p),this}get names(){const u=super.names;return re(u,this.condition),this.else&&Q(u,this.else.names),u}}h.kind="if";class $ extends m{}$.kind="for";class S 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=V(this.iteration,u,p),this}get names(){return Q(super.names,this.iteration.names)}}class T extends ${constructor(u,p,E,q){super(),this.varKind=u,this.name=p,this.from=E,this.to=q}render(u){const p=u.es5?r.varKinds.var:this.varKind,{name:E,from:q,to:D}=this;return`for(${p} ${E}=${q}; ${E}<${D}; ${E}++)`+super.render(u)}get names(){const u=re(super.names,this.from);return re(u,this.to)}}class k extends ${constructor(u,p,E,q){super(),this.loop=u,this.varKind=p,this.name=E,this.iterable=q}render(u){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(u)}optimizeNames(u,p){if(super.optimizeNames(u,p))return this.iterable=V(this.iterable,u,p),this}get names(){return Q(super.names,this.iterable.names)}}class I extends m{constructor(u,p,E){super(),this.name=u,this.args=p,this.async=E}render(u){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(u)}}I.kind="func";class z extends g{render(u){return"return "+super.render(u)}}z.kind="return";class F extends m{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 E,q;return super.optimizeNames(u,p),(E=this.catch)===null||E===void 0||E.optimizeNames(u,p),(q=this.finally)===null||q===void 0||q.optimizeNames(u,p),this}get names(){const u=super.names;return this.catch&&Q(u,this.catch.names),this.finally&&Q(u,this.finally.names),u}}class G extends m{constructor(u){super(),this.error=u}render(u){return`catch(${this.error})`+super.render(u)}}G.kind="catch";class Z extends m{render(u){return"finally"+super.render(u)}}Z.kind="finally";class K{constructor(u,p={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...p,_n:p.lines?` -`:""},this._extScope=u,this._scope=new r.Scope({parent:u}),this._nodes=[new v]}toString(){return this._root.render(this.opts)}name(u){return this._scope.name(u)}scopeName(u){return this._extScope.name(u)}scopeValue(u,p){const E=this._extScope.value(u,p);return(this._values[E.prefix]||(this._values[E.prefix]=new Set)).add(E),E}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,E,q){const D=this._scope.toName(p);return E!==void 0&&q&&(this._constants[D.str]=E),this._leafNode(new a(u,D,E)),D}const(u,p,E){return this._def(r.varKinds.const,u,p,E)}let(u,p,E){return this._def(r.varKinds.let,u,p,E)}var(u,p,E){return this._def(r.varKinds.var,u,p,E)}assign(u,p,E){return this._leafNode(new i(u,p,E))}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 _(u)),this}object(...u){const p=["{"];for(const[E,q]of u)p.length>1&&p.push(","),p.push(E),(E!==q||this.opts.es5)&&(p.push(":"),(0,t.addCodeArg)(p,q));return p.push("}"),new t._Code(p)}if(u,p,E){if(this._blockNode(new h(u)),p&&E)this.code(p).else().code(E).endIf();else if(p)this.code(p).endIf();else if(E)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(u){return this._elseNode(new h(u))}else(){return this._elseNode(new y)}endIf(){return this._endBlockNode(h,y)}_for(u,p){return this._blockNode(u),p&&this.code(p).endFor(),this}for(u,p){return this._for(new S(u),p)}forRange(u,p,E,q,D=this.opts.es5?r.varKinds.var:r.varKinds.let){const Y=this._scope.toName(u);return this._for(new T(D,Y,p,E),()=>q(Y))}forOf(u,p,E,q=r.varKinds.const){const D=this._scope.toName(u);if(this.opts.es5){const Y=p instanceof t.Name?p:this.var("_arr",p);return this.forRange("_i",0,(0,t._)`${Y}.length`,J=>{this.var(D,(0,t._)`${Y}[${J}]`),E(D)})}return this._for(new k("of",q,D,p),()=>E(D))}forIn(u,p,E,q=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(u,(0,t._)`Object.keys(${p})`,E);const D=this._scope.toName(u);return this._for(new k("in",q,D,p),()=>E(D))}endFor(){return this._endBlockNode($)}label(u){return this._leafNode(new l(u))}break(u){return this._leafNode(new d(u))}return(u){const p=new z;if(this._blockNode(p),this.code(u),p.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(z)}try(u,p,E){if(!p&&!E)throw new Error('CodeGen: "try" without "catch" and "finally"');const q=new F;if(this._blockNode(q),this.code(u),p){const D=this.name("e");this._currNode=q.catch=new G(D),p(D)}return E&&(this._currNode=q.finally=new Z,this.code(E)),this._endBlockNode(G,Z)}throw(u){return this._leafNode(new f(u))}block(u,p){return this._blockStarts.push(this._nodes.length),u&&this.code(u).endBlock(p),this}endBlock(u){const p=this._blockStarts.pop();if(p===void 0)throw new Error("CodeGen: not in self-balancing block");const E=this._nodes.length-p;if(E<0||u!==void 0&&E!==u)throw new Error(`CodeGen: wrong number of nodes: ${E} vs ${u} expected`);return this._nodes.length=p,this}func(u,p=t.nil,E,q){return this._blockNode(new I(u,p,E)),q&&this.code(q).endFunc(),this}endFunc(){return this._endBlockNode(I)}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 E=this._currNode;if(E instanceof u||p&&E instanceof p)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${p?`${u.kind}/${p.kind}`:u.kind}"`)}_elseNode(u){const p=this._currNode;if(!(p instanceof h))throw new Error('CodeGen: "else" without "if"');return this._currNode=p.else=u,this}get _root(){return this._nodes[0]}get _currNode(){const u=this._nodes;return u[u.length-1]}set _currNode(u){const p=this._nodes;p[p.length-1]=u}}e.CodeGen=K;function Q(b,u){for(const p in u)b[p]=(b[p]||0)+(u[p]||0);return b}function re(b,u){return u instanceof t._CodeOrName?Q(b,u.names):b}function V(b,u,p){if(b instanceof t.Name)return E(b);if(!q(b))return b;return new t._Code(b._items.reduce((D,Y)=>(Y instanceof t.Name&&(Y=E(Y)),Y instanceof t._Code?D.push(...Y._items):D.push(Y),D),[]));function E(D){const Y=p[D.str];return Y===void 0||u[D.str]!==1?D:(delete u[D.str],Y)}function q(D){return D instanceof t._Code&&D._items.some(Y=>Y instanceof t.Name&&u[Y.str]===1&&p[Y.str]!==void 0)}}function ie(b,u){for(const p in u)b[p]=(b[p]||0)-(u[p]||0)}function ke(b){return typeof b=="boolean"||typeof b=="number"||b===null?!b:(0,t._)`!${C(b)}`}e.not=ke;const $e=w(e.operators.AND);function ct(...b){return b.reduce($e)}e.and=ct;const Oe=w(e.operators.OR);function A(...b){return b.reduce(Oe)}e.or=A;function w(b){return(u,p)=>u===t.nil?p:p===t.nil?u:(0,t._)`${C(u)} ${b} ${C(p)}`}function C(b){return b instanceof t.Name?b:(0,t._)`(${b})`}})(he);var B={};Object.defineProperty(B,"__esModule",{value:!0});B.checkStrictMode=B.getErrorPath=B.Type=B.useFunc=B.setEvaluated=B.evaluatedPropsToName=B.mergeEvaluated=B.eachItem=B.unescapeJsonPointer=B.escapeJsonPointer=B.escapeFragment=B.unescapeFragment=B.schemaRefOrVal=B.schemaHasRulesButRef=B.schemaHasRules=B.checkUnknownRules=B.alwaysValidSchema=B.toHash=void 0;const be=he,US=hn;function VS(e){const t={};for(const r of e)t[r]=!0;return t}B.toHash=VS;function FS(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(nf(e,t),!sf(t,e.self.RULES.all))}B.alwaysValidSchema=FS;function nf(e,t=e.schema){const{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;const s=n.RULES.keywords;for(const o in t)s[o]||cf(e,`unknown keyword: "${o}"`)}B.checkUnknownRules=nf;function sf(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(t[r])return!0;return!1}B.schemaHasRules=sf;function LS(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}B.schemaHasRulesButRef=LS;function HS({topSchemaRef:e,schemaPath:t},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,be._)`${r}`}return(0,be._)`${e}${t}${(0,be.getProperty)(n)}`}B.schemaRefOrVal=HS;function ZS(e){return of(decodeURIComponent(e))}B.unescapeFragment=ZS;function KS(e){return encodeURIComponent(Ei(e))}B.escapeFragment=KS;function Ei(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}B.escapeJsonPointer=Ei;function of(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}B.unescapeJsonPointer=of;function GS(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)}B.eachItem=GS;function cl({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(s,o,a,i)=>{const c=a===void 0?o:a instanceof be.Name?(o instanceof be.Name?e(s,o,a):t(s,o,a),a):o instanceof be.Name?(t(s,a,o),o):r(o,a);return i===be.Name&&!(c instanceof be.Name)?n(s,c):c}}B.mergeEvaluated={props:cl({mergeNames:(e,t,r)=>e.if((0,be._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,be._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,be._)`${r} || {}`).code((0,be._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,be._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,be._)`${r} || {}`),ki(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:af}),items:cl({mergeNames:(e,t,r)=>e.if((0,be._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,be._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,be._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,be._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function af(e,t){if(t===!0)return e.var("props",!0);const r=e.var("props",(0,be._)`{}`);return t!==void 0&&ki(e,r,t),r}B.evaluatedPropsToName=af;function ki(e,t,r){Object.keys(r).forEach(n=>e.assign((0,be._)`${t}${(0,be.getProperty)(n)}`,!0))}B.setEvaluated=ki;const ll={};function WS(e,t){return e.scopeValue("func",{ref:t,code:ll[t.code]||(ll[t.code]=new US._Code(t.code))})}B.useFunc=WS;var Po;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Po||(B.Type=Po={}));function BS(e,t,r){if(e instanceof be.Name){const n=t===Po.Num;return r?n?(0,be._)`"[" + ${e} + "]"`:(0,be._)`"['" + ${e} + "']"`:n?(0,be._)`"/" + ${e}`:(0,be._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,be.getProperty)(e).toString():"/"+Ei(e)}B.getErrorPath=BS;function cf(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}B.checkStrictMode=cf;var Ct={};Object.defineProperty(Ct,"__esModule",{value:!0});const et=he,JS={data:new et.Name("data"),valCxt:new et.Name("valCxt"),instancePath:new et.Name("instancePath"),parentData:new et.Name("parentData"),parentDataProperty:new et.Name("parentDataProperty"),rootData:new et.Name("rootData"),dynamicAnchors:new et.Name("dynamicAnchors"),vErrors:new et.Name("vErrors"),errors:new et.Name("errors"),this:new et.Name("this"),self:new et.Name("self"),scope:new et.Name("scope"),json:new et.Name("json"),jsonPos:new et.Name("jsonPos"),jsonLen:new et.Name("jsonLen"),jsonPart:new et.Name("jsonPart")};Ct.default=JS;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;const t=he,r=B,n=Ct;e.keywordError={message:({keyword:y})=>(0,t.str)`must pass "${y}" keyword validation`},e.keyword$DataError={message:({keyword:y,schemaType:h})=>h?(0,t.str)`"${y}" keyword must be ${h} ($data)`:(0,t.str)`"${y}" keyword is invalid ($data)`};function s(y,h=e.keywordError,$,S){const{it:T}=y,{gen:k,compositeRule:I,allErrors:z}=T,F=f(y,h,$);S??(I||z)?c(k,F):l(T,(0,t._)`[${F}]`)}e.reportError=s;function o(y,h=e.keywordError,$){const{it:S}=y,{gen:T,compositeRule:k,allErrors:I}=S,z=f(y,h,$);c(T,z),k||I||l(S,n.default.vErrors)}e.reportExtraError=o;function a(y,h){y.assign(n.default.errors,h),y.if((0,t._)`${n.default.vErrors} !== null`,()=>y.if(h,()=>y.assign((0,t._)`${n.default.vErrors}.length`,h),()=>y.assign(n.default.vErrors,null)))}e.resetErrorsCount=a;function i({gen:y,keyword:h,schemaValue:$,data:S,errsCount:T,it:k}){if(T===void 0)throw new Error("ajv implementation error");const I=y.name("err");y.forRange("i",T,n.default.errors,z=>{y.const(I,(0,t._)`${n.default.vErrors}[${z}]`),y.if((0,t._)`${I}.instancePath === undefined`,()=>y.assign((0,t._)`${I}.instancePath`,(0,t.strConcat)(n.default.instancePath,k.errorPath))),y.assign((0,t._)`${I}.schemaPath`,(0,t.str)`${k.errSchemaPath}/${h}`),k.opts.verbose&&(y.assign((0,t._)`${I}.schema`,$),y.assign((0,t._)`${I}.data`,S))})}e.extendErrors=i;function c(y,h){const $=y.const("err",h);y.if((0,t._)`${n.default.vErrors} === null`,()=>y.assign(n.default.vErrors,(0,t._)`[${$}]`),(0,t._)`${n.default.vErrors}.push(${$})`),y.code((0,t._)`${n.default.errors}++`)}function l(y,h){const{gen:$,validateName:S,schemaEnv:T}=y;T.$async?$.throw((0,t._)`new ${y.ValidationError}(${h})`):($.assign((0,t._)`${S}.errors`,h),$.return(!1))}const d={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function f(y,h,$){const{createErrors:S}=y.it;return S===!1?(0,t._)`{}`:_(y,h,$)}function _(y,h,$={}){const{gen:S,it:T}=y,k=[g(T,$),m(y,$)];return v(y,h,k),S.object(...k)}function g({errorPath:y},{instancePath:h}){const $=h?(0,t.str)`${y}${(0,r.getErrorPath)(h,r.Type.Str)}`:y;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,$)]}function m({keyword:y,it:{errSchemaPath:h}},{schemaPath:$,parentSchema:S}){let T=S?h:(0,t.str)`${h}/${y}`;return $&&(T=(0,t.str)`${T}${(0,r.getErrorPath)($,r.Type.Str)}`),[d.schemaPath,T]}function v(y,{params:h,message:$},S){const{keyword:T,data:k,schemaValue:I,it:z}=y,{opts:F,propertyName:G,topSchemaRef:Z,schemaPath:K}=z;S.push([d.keyword,T],[d.params,typeof h=="function"?h(y):h||(0,t._)`{}`]),F.messages&&S.push([d.message,typeof $=="function"?$(y):$]),F.verbose&&S.push([d.schema,I],[d.parentSchema,(0,t._)`${Z}${K}`],[n.default.data,k]),G&&S.push([d.propertyName,G])}})(Tn);var ul;function QS(){if(ul)return Qt;ul=1,Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.boolOrEmptySchema=Qt.topBoolOrEmptySchema=void 0;const e=Tn,t=he,r=Ct,n={message:"boolean schema is false"};function s(i){const{gen:c,schema:l,validateName:d}=i;l===!1?a(i,!1):typeof l=="object"&&l.$async===!0?c.return(r.default.data):(c.assign((0,t._)`${d}.errors`,null),c.return(!0))}Qt.topBoolOrEmptySchema=s;function o(i,c){const{gen:l,schema:d}=i;d===!1?(l.var(c,!1),a(i)):l.var(c,!0)}Qt.boolOrEmptySchema=o;function a(i,c){const{gen:l,data:d}=i,f={gen:l,keyword:"false schema",data:d,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:i};(0,e.reportError)(f,n,void 0,c)}return Qt}var De={},dr={};Object.defineProperty(dr,"__esModule",{value:!0});dr.getRules=dr.isJSONType=void 0;const YS=["string","number","integer","boolean","null","object","array"],XS=new Set(YS);function eE(e){return typeof e=="string"&&XS.has(e)}dr.isJSONType=eE;function tE(){const e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}dr.getRules=tE;var At={};Object.defineProperty(At,"__esModule",{value:!0});At.shouldUseRule=At.shouldUseGroup=At.schemaHasRulesForType=void 0;function rE({schema:e,self:t},r){const n=t.RULES.types[r];return n&&n!==!0&&lf(e,n)}At.schemaHasRulesForType=rE;function lf(e,t){return t.rules.some(r=>uf(e,r))}At.shouldUseGroup=lf;function uf(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))}At.shouldUseRule=uf;Object.defineProperty(De,"__esModule",{value:!0});De.reportTypeError=De.checkDataTypes=De.checkDataType=De.coerceAndCheckDataType=De.getJSONTypes=De.getSchemaTypes=De.DataType=void 0;const nE=dr,sE=At,oE=Tn,ue=he,df=B;var Pr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Pr||(De.DataType=Pr={}));function aE(e){const t=ff(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}De.getSchemaTypes=aE;function ff(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(nE.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}De.getJSONTypes=ff;function iE(e,t){const{gen:r,data:n,opts:s}=e,o=cE(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0,sE.schemaHasRulesForType)(e,t[0]));if(a){const i=Pi(t,n,s.strictNumbers,Pr.Wrong);r.if(i,()=>{o.length?lE(e,t,o):Ti(e)})}return a}De.coerceAndCheckDataType=iE;const hf=new Set(["string","number","integer","boolean","null"]);function cE(e,t){return t?e.filter(r=>hf.has(r)||t==="array"&&r==="array"):[]}function lE(e,t,r){const{gen:n,data:s,opts:o}=e,a=n.let("dataType",(0,ue._)`typeof ${s}`),i=n.let("coerced",(0,ue._)`undefined`);o.coerceTypes==="array"&&n.if((0,ue._)`${a} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,ue._)`${s}[0]`).assign(a,(0,ue._)`typeof ${s}`).if(Pi(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0,ue._)`${i} !== undefined`);for(const l of r)(hf.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),Ti(e),n.endIf(),n.if((0,ue._)`${i} !== undefined`,()=>{n.assign(s,i),uE(e,i)});function c(l){switch(l){case"string":n.elseIf((0,ue._)`${a} == "number" || ${a} == "boolean"`).assign(i,(0,ue._)`"" + ${s}`).elseIf((0,ue._)`${s} === null`).assign(i,(0,ue._)`""`);return;case"number":n.elseIf((0,ue._)`${a} == "boolean" || ${s} === null - || (${a} == "string" && ${s} && ${s} == +${s})`).assign(i,(0,ue._)`+${s}`);return;case"integer":n.elseIf((0,ue._)`${a} === "boolean" || ${s} === null - || (${a} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(i,(0,ue._)`+${s}`);return;case"boolean":n.elseIf((0,ue._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(i,!1).elseIf((0,ue._)`${s} === "true" || ${s} === 1`).assign(i,!0);return;case"null":n.elseIf((0,ue._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(i,null);return;case"array":n.elseIf((0,ue._)`${a} === "string" || ${a} === "number" - || ${a} === "boolean" || ${s} === null`).assign(i,(0,ue._)`[${s}]`)}}}function uE({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,ue._)`${t} !== undefined`,()=>e.assign((0,ue._)`${t}[${r}]`,n))}function To(e,t,r,n=Pr.Correct){const s=n===Pr.Correct?ue.operators.EQ:ue.operators.NEQ;let o;switch(e){case"null":return(0,ue._)`${t} ${s} null`;case"array":o=(0,ue._)`Array.isArray(${t})`;break;case"object":o=(0,ue._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=a((0,ue._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=a();break;default:return(0,ue._)`typeof ${t} ${s} ${e}`}return n===Pr.Correct?o:(0,ue.not)(o);function a(i=ue.nil){return(0,ue.and)((0,ue._)`typeof ${t} == "number"`,i,r?(0,ue._)`isFinite(${t})`:ue.nil)}}De.checkDataType=To;function Pi(e,t,r,n){if(e.length===1)return To(e[0],t,r,n);let s;const o=(0,df.toHash)(e);if(o.array&&o.object){const a=(0,ue._)`typeof ${t} != "object"`;s=o.null?a:(0,ue._)`!${t} || ${a}`,delete o.null,delete o.array,delete o.object}else s=ue.nil;o.number&&delete o.integer;for(const a in o)s=(0,ue.and)(s,To(a,t,r,n));return s}De.checkDataTypes=Pi;const dE={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,ue._)`{type: ${e}}`:(0,ue._)`{type: ${t}}`};function Ti(e){const t=fE(e);(0,oE.reportError)(t,dE)}De.reportTypeError=Ti;function fE(e){const{gen:t,data:r,schema:n}=e,s=(0,df.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}var Zr={},dl;function hE(){if(dl)return Zr;dl=1,Object.defineProperty(Zr,"__esModule",{value:!0}),Zr.assignDefaults=void 0;const e=he,t=B;function r(s,o){const{properties:a,items:i}=s.schema;if(o==="object"&&a)for(const c in a)n(s,c,a[c].default);else o==="array"&&Array.isArray(i)&&i.forEach((c,l)=>n(s,l,c.default))}Zr.assignDefaults=r;function n(s,o,a){const{gen:i,compositeRule:c,data:l,opts:d}=s;if(a===void 0)return;const f=(0,e._)`${l}${(0,e.getProperty)(o)}`;if(c){(0,t.checkStrictMode)(s,`default is ignored for: ${f}`);return}let _=(0,e._)`${f} === undefined`;d.useDefaults==="empty"&&(_=(0,e._)`${_} || ${f} === null || ${f} === ""`),i.if(_,(0,e._)`${f} = ${(0,e.stringify)(a)}`)}return Zr}var _t={},me={};Object.defineProperty(me,"__esModule",{value:!0});me.validateUnion=me.validateArray=me.usePattern=me.callValidateCode=me.schemaProperties=me.allSchemaProperties=me.noPropertyInData=me.propertyInData=me.isOwnProperty=me.hasPropFunc=me.reportMissingProp=me.checkMissingProp=me.checkReportMissingProp=void 0;const Te=he,Ri=B,xt=Ct,pE=B;function mE(e,t){const{gen:r,data:n,it:s}=e;r.if(Ni(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Te._)`${t}`},!0),e.error()})}me.checkReportMissingProp=mE;function gE({gen:e,data:t,it:{opts:r}},n,s){return(0,Te.or)(...n.map(o=>(0,Te.and)(Ni(e,t,o,r.ownProperties),(0,Te._)`${s} = ${o}`)))}me.checkMissingProp=gE;function _E(e,t){e.setParams({missingProperty:t},!0),e.error()}me.reportMissingProp=_E;function pf(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Te._)`Object.prototype.hasOwnProperty`})}me.hasPropFunc=pf;function Ci(e,t,r){return(0,Te._)`${pf(e)}.call(${t}, ${r})`}me.isOwnProperty=Ci;function yE(e,t,r,n){const s=(0,Te._)`${t}${(0,Te.getProperty)(r)} !== undefined`;return n?(0,Te._)`${s} && ${Ci(e,t,r)}`:s}me.propertyInData=yE;function Ni(e,t,r,n){const s=(0,Te._)`${t}${(0,Te.getProperty)(r)} === undefined`;return n?(0,Te.or)(s,(0,Te.not)(Ci(e,t,r))):s}me.noPropertyInData=Ni;function mf(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}me.allSchemaProperties=mf;function vE(e,t){return mf(t).filter(r=>!(0,Ri.alwaysValidSchema)(e,t[r]))}me.schemaProperties=vE;function $E({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:a},i,c,l){const d=l?(0,Te._)`${e}, ${t}, ${n}${s}`:t,f=[[xt.default.instancePath,(0,Te.strConcat)(xt.default.instancePath,o)],[xt.default.parentData,a.parentData],[xt.default.parentDataProperty,a.parentDataProperty],[xt.default.rootData,xt.default.rootData]];a.opts.dynamicRef&&f.push([xt.default.dynamicAnchors,xt.default.dynamicAnchors]);const _=(0,Te._)`${d}, ${r.object(...f)}`;return c!==Te.nil?(0,Te._)`${i}.call(${c}, ${_})`:(0,Te._)`${i}(${_})`}me.callValidateCode=$E;const wE=(0,Te._)`new RegExp`;function bE({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,Te._)`${s.code==="new RegExp"?wE:(0,pE.useFunc)(e,s)}(${r}, ${n})`})}me.usePattern=bE;function SE(e){const{gen:t,data:r,keyword:n,it:s}=e,o=t.name("valid");if(s.allErrors){const i=t.let("valid",!0);return a(()=>t.assign(i,!1)),i}return t.var(o,!0),a(()=>t.break()),o;function a(i){const c=t.const("len",(0,Te._)`${r}.length`);t.forRange("i",0,c,l=>{e.subschema({keyword:n,dataProp:l,dataPropType:Ri.Type.Num},o),t.if((0,Te.not)(o),i)})}}me.validateArray=SE;function EE(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,Ri.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,Te._)`${a} || ${i}`),e.mergeValidEvaluated(d,i)||t.if((0,Te.not)(a))})),e.result(a,()=>e.reset(),()=>e.error(!0))}me.validateUnion=EE;var fl;function kE(){if(fl)return _t;fl=1,Object.defineProperty(_t,"__esModule",{value:!0}),_t.validateKeywordUsage=_t.validSchemaType=_t.funcKeywordCode=_t.macroKeywordCode=void 0;const e=he,t=Ct,r=me,n=Tn;function s(_,g){const{gen:m,keyword:v,schema:y,parentSchema:h,it:$}=_,S=g.macro.call($.self,y,h,$),T=l(m,v,S);$.opts.validateSchema!==!1&&$.self.validateSchema(S,!0);const k=m.name("valid");_.subschema({schema:S,schemaPath:e.nil,errSchemaPath:`${$.errSchemaPath}/${v}`,topSchemaRef:T,compositeRule:!0},k),_.pass(k,()=>_.error(!0))}_t.macroKeywordCode=s;function o(_,g){var m;const{gen:v,keyword:y,schema:h,parentSchema:$,$data:S,it:T}=_;c(T,g);const k=!S&&g.compile?g.compile.call(T.self,h,$,T):g.validate,I=l(v,y,k),z=v.let("valid");_.block$data(z,F),_.ok((m=g.valid)!==null&&m!==void 0?m:z);function F(){if(g.errors===!1)K(),g.modifying&&a(_),Q(()=>_.error());else{const re=g.async?G():Z();g.modifying&&a(_),Q(()=>i(_,re))}}function G(){const re=v.let("ruleErrs",null);return v.try(()=>K((0,e._)`await `),V=>v.assign(z,!1).if((0,e._)`${V} instanceof ${T.ValidationError}`,()=>v.assign(re,(0,e._)`${V}.errors`),()=>v.throw(V))),re}function Z(){const re=(0,e._)`${I}.errors`;return v.assign(re,null),K(e.nil),re}function K(re=g.async?(0,e._)`await `:e.nil){const V=T.opts.passContext?t.default.this:t.default.self,ie=!("compile"in g&&!S||g.schema===!1);v.assign(z,(0,e._)`${re}${(0,r.callValidateCode)(_,I,V,ie)}`,g.modifying)}function Q(re){var V;v.if((0,e.not)((V=g.valid)!==null&&V!==void 0?V:z),re)}}_t.funcKeywordCode=o;function a(_){const{gen:g,data:m,it:v}=_;g.if(v.parentData,()=>g.assign(m,(0,e._)`${v.parentData}[${v.parentDataProperty}]`))}function i(_,g){const{gen:m}=_;m.if((0,e._)`Array.isArray(${g})`,()=>{m.assign(t.default.vErrors,(0,e._)`${t.default.vErrors} === null ? ${g} : ${t.default.vErrors}.concat(${g})`).assign(t.default.errors,(0,e._)`${t.default.vErrors}.length`),(0,n.extendErrors)(_)},()=>_.error())}function c({schemaEnv:_},g){if(g.async&&!_.$async)throw new Error("async keyword in sync schema")}function l(_,g,m){if(m===void 0)throw new Error(`keyword "${g}" failed to compile`);return _.scopeValue("keyword",typeof m=="function"?{ref:m}:{ref:m,code:(0,e.stringify)(m)})}function d(_,g,m=!1){return!g.length||g.some(v=>v==="array"?Array.isArray(_):v==="object"?_&&typeof _=="object"&&!Array.isArray(_):typeof _==v||m&&typeof _>"u")}_t.validSchemaType=d;function f({schema:_,opts:g,self:m,errSchemaPath:v},y,h){if(Array.isArray(y.keyword)?!y.keyword.includes(h):y.keyword!==h)throw new Error("ajv implementation error");const $=y.dependencies;if($!=null&&$.some(S=>!Object.prototype.hasOwnProperty.call(_,S)))throw new Error(`parent schema must have dependencies of ${h}: ${$.join(",")}`);if(y.validateSchema&&!y.validateSchema(_[h])){const T=`keyword "${h}" value is invalid at path "${v}": `+m.errorsText(y.validateSchema.errors);if(g.validateSchema==="log")m.logger.error(T);else throw new Error(T)}}return _t.validateKeywordUsage=f,_t}var It={},hl;function PE(){if(hl)return It;hl=1,Object.defineProperty(It,"__esModule",{value:!0}),It.extendSubschemaMode=It.extendSubschemaData=It.getSubschema=void 0;const e=he,t=B;function r(o,{keyword:a,schemaProp:i,schema:c,schemaPath:l,errSchemaPath:d,topSchemaRef:f}){if(a!==void 0&&c!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(a!==void 0){const _=o.schema[a];return i===void 0?{schema:_,schemaPath:(0,e._)`${o.schemaPath}${(0,e.getProperty)(a)}`,errSchemaPath:`${o.errSchemaPath}/${a}`}:{schema:_[i],schemaPath:(0,e._)`${o.schemaPath}${(0,e.getProperty)(a)}${(0,e.getProperty)(i)}`,errSchemaPath:`${o.errSchemaPath}/${a}/${(0,t.escapeFragment)(i)}`}}if(c!==void 0){if(l===void 0||d===void 0||f===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:c,schemaPath:l,topSchemaRef:f,errSchemaPath:d}}throw new Error('either "keyword" or "schema" must be passed')}It.getSubschema=r;function n(o,a,{dataProp:i,dataPropType:c,data:l,dataTypes:d,propertyName:f}){if(l!==void 0&&i!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:_}=a;if(i!==void 0){const{errorPath:m,dataPathArr:v,opts:y}=a,h=_.let("data",(0,e._)`${a.data}${(0,e.getProperty)(i)}`,!0);g(h),o.errorPath=(0,e.str)`${m}${(0,t.getErrorPath)(i,c,y.jsPropertySyntax)}`,o.parentDataProperty=(0,e._)`${i}`,o.dataPathArr=[...v,o.parentDataProperty]}if(l!==void 0){const m=l instanceof e.Name?l:_.let("data",l,!0);g(m),f!==void 0&&(o.propertyName=f)}d&&(o.dataTypes=d);function g(m){o.data=m,o.dataLevel=a.dataLevel+1,o.dataTypes=[],a.definedProperties=new Set,o.parentData=a.data,o.dataNames=[...a.dataNames,m]}}It.extendSubschemaData=n;function s(o,{jtdDiscriminator:a,jtdMetadata:i,compositeRule:c,createErrors:l,allErrors:d}){c!==void 0&&(o.compositeRule=c),l!==void 0&&(o.createErrors=l),d!==void 0&&(o.allErrors=d),o.jtdDiscriminator=a,o.jtdMetadata=i}return It.extendSubschemaMode=s,It}var We={},gf={exports:{}},Vt=gf.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},s=r.post||function(){};Qn(t,n,s,e,"",e)};Vt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Vt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Vt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Vt.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Qn(e,t,r,n,s,o,a,i,c,l){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,s,o,a,i,c,l);for(var d in n){var f=n[d];if(Array.isArray(f)){if(d in Vt.arrayKeywords)for(var _=0;_t+=_f(n)),t===1/0))return 1/0}return t}function yf(e,t="",r){r!==!1&&(t=Tr(t));const n=e.parse(t);return vf(e,n)}We.getFullPath=yf;function vf(e,t){return e.serialize(t).split("#")[0]+"#"}We._getFullPath=vf;const ME=/#\/?$/;function Tr(e){return e?e.replace(ME,""):""}We.normalizeId=Tr;function zE(e,t,r){return r=Tr(r),e.resolve(t,r)}We.resolveUrl=zE;const xE=/^[a-z_][-a-z0-9._]*$/i;function qE(e,t){if(typeof e=="boolean")return{};const{schemaId:r,uriResolver:n}=this.opts,s=Tr(e[r]||t),o={"":s},a=yf(n,s,!1),i={},c=new Set;return IE(e,{allKeys:!0},(f,_,g,m)=>{if(m===void 0)return;const v=a+_;let y=o[m];typeof f[r]=="string"&&(y=h.call(this,f[r])),$.call(this,f.$anchor),$.call(this,f.$dynamicAnchor),o[_]=y;function h(S){const T=this.opts.uriResolver.resolve;if(S=Tr(y?T(y,S):S),c.has(S))throw d(S);c.add(S);let k=this.refs[S];return typeof k=="string"&&(k=this.refs[k]),typeof k=="object"?l(f,k.schema,S):S!==Tr(v)&&(S[0]==="#"?(l(f,i[S],S),i[S]=f):this.refs[S]=v),S}function $(S){if(typeof S=="string"){if(!xE.test(S))throw new Error(`invalid anchor "${S}"`);h.call(this,`#${S}`)}}}),i;function l(f,_,g){if(_!==void 0&&!NE(f,_))throw d(g)}function d(f){return new Error(`reference "${f}" resolves to more than one schema`)}}We.getSchemaRefs=qE;var pl;function xs(){if(pl)return Nt;pl=1,Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.getData=Nt.KeywordCxt=Nt.validateFunctionCode=void 0;const e=QS(),t=De,r=At,n=De,s=hE(),o=kE(),a=PE(),i=he,c=Ct,l=We,d=B,f=Tn;function _(N){if(k(N)&&(z(N),T(N))){y(N);return}g(N,()=>(0,e.topBoolOrEmptySchema)(N))}Nt.validateFunctionCode=_;function g({gen:N,validateName:O,schema:U,schemaEnv:H,opts:X},ce){X.code.es5?N.func(O,(0,i._)`${c.default.data}, ${c.default.valCxt}`,H.$async,()=>{N.code((0,i._)`"use strict"; ${$(U,X)}`),v(N,X),N.code(ce)}):N.func(O,(0,i._)`${c.default.data}, ${m(X)}`,H.$async,()=>N.code($(U,X)).code(ce))}function m(N){return(0,i._)`{${c.default.instancePath}="", ${c.default.parentData}, ${c.default.parentDataProperty}, ${c.default.rootData}=${c.default.data}${N.dynamicRef?(0,i._)`, ${c.default.dynamicAnchors}={}`:i.nil}}={}`}function v(N,O){N.if(c.default.valCxt,()=>{N.var(c.default.instancePath,(0,i._)`${c.default.valCxt}.${c.default.instancePath}`),N.var(c.default.parentData,(0,i._)`${c.default.valCxt}.${c.default.parentData}`),N.var(c.default.parentDataProperty,(0,i._)`${c.default.valCxt}.${c.default.parentDataProperty}`),N.var(c.default.rootData,(0,i._)`${c.default.valCxt}.${c.default.rootData}`),O.dynamicRef&&N.var(c.default.dynamicAnchors,(0,i._)`${c.default.valCxt}.${c.default.dynamicAnchors}`)},()=>{N.var(c.default.instancePath,(0,i._)`""`),N.var(c.default.parentData,(0,i._)`undefined`),N.var(c.default.parentDataProperty,(0,i._)`undefined`),N.var(c.default.rootData,c.default.data),O.dynamicRef&&N.var(c.default.dynamicAnchors,(0,i._)`{}`)})}function y(N){const{schema:O,opts:U,gen:H}=N;g(N,()=>{U.$comment&&O.$comment&&re(N),Z(N),H.let(c.default.vErrors,null),H.let(c.default.errors,0),U.unevaluated&&h(N),F(N),V(N)})}function h(N){const{gen:O,validateName:U}=N;N.evaluated=O.const("evaluated",(0,i._)`${U}.evaluated`),O.if((0,i._)`${N.evaluated}.dynamicProps`,()=>O.assign((0,i._)`${N.evaluated}.props`,(0,i._)`undefined`)),O.if((0,i._)`${N.evaluated}.dynamicItems`,()=>O.assign((0,i._)`${N.evaluated}.items`,(0,i._)`undefined`))}function $(N,O){const U=typeof N=="object"&&N[O.schemaId];return U&&(O.code.source||O.code.process)?(0,i._)`/*# sourceURL=${U} */`:i.nil}function S(N,O){if(k(N)&&(z(N),T(N))){I(N,O);return}(0,e.boolOrEmptySchema)(N,O)}function T({schema:N,self:O}){if(typeof N=="boolean")return!N;for(const U in N)if(O.RULES.all[U])return!0;return!1}function k(N){return typeof N.schema!="boolean"}function I(N,O){const{schema:U,gen:H,opts:X}=N;X.$comment&&U.$comment&&re(N),K(N),Q(N);const ce=H.const("_errs",c.default.errors);F(N,ce),H.var(O,(0,i._)`${ce} === ${c.default.errors}`)}function z(N){(0,d.checkUnknownRules)(N),G(N)}function F(N,O){if(N.opts.jtd)return ke(N,[],!1,O);const U=(0,t.getSchemaTypes)(N.schema),H=(0,t.coerceAndCheckDataType)(N,U);ke(N,U,!H,O)}function G(N){const{schema:O,errSchemaPath:U,opts:H,self:X}=N;O.$ref&&H.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(O,X.RULES)&&X.logger.warn(`$ref: keywords ignored in schema at path "${U}"`)}function Z(N){const{schema:O,opts:U}=N;O.default!==void 0&&U.useDefaults&&U.strictSchema&&(0,d.checkStrictMode)(N,"default is ignored in the schema root")}function K(N){const O=N.schema[N.opts.schemaId];O&&(N.baseId=(0,l.resolveUrl)(N.opts.uriResolver,N.baseId,O))}function Q(N){if(N.schema.$async&&!N.schemaEnv.$async)throw new Error("async schema in sync schema")}function re({gen:N,schemaEnv:O,schema:U,errSchemaPath:H,opts:X}){const ce=U.$comment;if(X.$comment===!0)N.code((0,i._)`${c.default.self}.logger.log(${ce})`);else if(typeof X.$comment=="function"){const Ae=(0,i.str)`${H}/$comment`,tt=N.scopeValue("root",{ref:O.root});N.code((0,i._)`${c.default.self}.opts.$comment(${ce}, ${Ae}, ${tt}.schema)`)}}function V(N){const{gen:O,schemaEnv:U,validateName:H,ValidationError:X,opts:ce}=N;U.$async?O.if((0,i._)`${c.default.errors} === 0`,()=>O.return(c.default.data),()=>O.throw((0,i._)`new ${X}(${c.default.vErrors})`)):(O.assign((0,i._)`${H}.errors`,c.default.vErrors),ce.unevaluated&&ie(N),O.return((0,i._)`${c.default.errors} === 0`))}function ie({gen:N,evaluated:O,props:U,items:H}){U instanceof i.Name&&N.assign((0,i._)`${O}.props`,U),H instanceof i.Name&&N.assign((0,i._)`${O}.items`,H)}function ke(N,O,U,H){const{gen:X,schema:ce,data:Ae,allErrors:tt,opts:Ve,self:Fe}=N,{RULES:Me}=Fe;if(ce.$ref&&(Ve.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(ce,Me))){X.block(()=>q(N,"$ref",Me.all.$ref.definition));return}Ve.jtd||ct(N,O),X.block(()=>{for(const Ye of Me.rules)Et(Ye);Et(Me.post)});function Et(Ye){(0,r.shouldUseGroup)(ce,Ye)&&(Ye.type?(X.if((0,n.checkDataType)(Ye.type,Ae,Ve.strictNumbers)),$e(N,Ye),O.length===1&&O[0]===Ye.type&&U&&(X.else(),(0,n.reportTypeError)(N)),X.endIf()):$e(N,Ye),tt||X.if((0,i._)`${c.default.errors} === ${H||0}`))}}function $e(N,O){const{gen:U,schema:H,opts:{useDefaults:X}}=N;X&&(0,s.assignDefaults)(N,O.type),U.block(()=>{for(const ce of O.rules)(0,r.shouldUseRule)(H,ce)&&q(N,ce.keyword,ce.definition,O.type)})}function ct(N,O){N.schemaEnv.meta||!N.opts.strictTypes||(Oe(N,O),N.opts.allowUnionTypes||A(N,O),w(N,N.dataTypes))}function Oe(N,O){if(O.length){if(!N.dataTypes.length){N.dataTypes=O;return}O.forEach(U=>{b(N.dataTypes,U)||p(N,`type "${U}" not allowed by context "${N.dataTypes.join(",")}"`)}),u(N,O)}}function A(N,O){O.length>1&&!(O.length===2&&O.includes("null"))&&p(N,"use allowUnionTypes to allow union type keyword")}function w(N,O){const U=N.self.RULES.all;for(const H in U){const X=U[H];if(typeof X=="object"&&(0,r.shouldUseRule)(N.schema,X)){const{type:ce}=X.definition;ce.length&&!ce.some(Ae=>C(O,Ae))&&p(N,`missing type "${ce.join(",")}" for keyword "${H}"`)}}}function C(N,O){return N.includes(O)||O==="number"&&N.includes("integer")}function b(N,O){return N.includes(O)||O==="integer"&&N.includes("number")}function u(N,O){const U=[];for(const H of N.dataTypes)b(O,H)?U.push(H):O.includes("integer")&&H==="number"&&U.push("integer");N.dataTypes=U}function p(N,O){const U=N.schemaEnv.baseId+N.errSchemaPath;O+=` at "${U}" (strictTypes)`,(0,d.checkStrictMode)(N,O,N.opts.strictTypes)}class E{constructor(O,U,H){if((0,o.validateKeywordUsage)(O,U,H),this.gen=O.gen,this.allErrors=O.allErrors,this.keyword=H,this.data=O.data,this.schema=O.schema[H],this.$data=U.$data&&O.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d.schemaRefOrVal)(O,this.schema,H,this.$data),this.schemaType=U.schemaType,this.parentSchema=O.schema,this.params={},this.it=O,this.def=U,this.$data)this.schemaCode=O.gen.const("vSchema",J(this.$data,O));else if(this.schemaCode=this.schemaValue,!(0,o.validSchemaType)(this.schema,U.schemaType,U.allowUndefined))throw new Error(`${H} value must be ${JSON.stringify(U.schemaType)}`);("code"in U?U.trackErrors:U.errors!==!1)&&(this.errsCount=O.gen.const("_errs",c.default.errors))}result(O,U,H){this.failResult((0,i.not)(O),U,H)}failResult(O,U,H){this.gen.if(O),H?H():this.error(),U?(this.gen.else(),U(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(O,U){this.failResult((0,i.not)(O),void 0,U)}fail(O){if(O===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(O),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(O){if(!this.$data)return this.fail(O);const{schemaCode:U}=this;this.fail((0,i._)`${U} !== undefined && (${(0,i.or)(this.invalid$data(),O)})`)}error(O,U,H){if(U){this.setParams(U),this._error(O,H),this.setParams({});return}this._error(O,H)}_error(O,U){(O?f.reportExtraError:f.reportError)(this,this.def.error,U)}$dataError(){(0,f.reportError)(this,this.def.$dataError||f.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,f.resetErrorsCount)(this.gen,this.errsCount)}ok(O){this.allErrors||this.gen.if(O)}setParams(O,U){U?Object.assign(this.params,O):this.params=O}block$data(O,U,H=i.nil){this.gen.block(()=>{this.check$data(O,H),U()})}check$data(O=i.nil,U=i.nil){if(!this.$data)return;const{gen:H,schemaCode:X,schemaType:ce,def:Ae}=this;H.if((0,i.or)((0,i._)`${X} === undefined`,U)),O!==i.nil&&H.assign(O,!0),(ce.length||Ae.validateSchema)&&(H.elseIf(this.invalid$data()),this.$dataError(),O!==i.nil&&H.assign(O,!1)),H.else()}invalid$data(){const{gen:O,schemaCode:U,schemaType:H,def:X,it:ce}=this;return(0,i.or)(Ae(),tt());function Ae(){if(H.length){if(!(U instanceof i.Name))throw new Error("ajv implementation error");const Ve=Array.isArray(H)?H:[H];return(0,i._)`${(0,n.checkDataTypes)(Ve,U,ce.opts.strictNumbers,n.DataType.Wrong)}`}return i.nil}function tt(){if(X.validateSchema){const Ve=O.scopeValue("validate$data",{ref:X.validateSchema});return(0,i._)`!${Ve}(${U})`}return i.nil}}subschema(O,U){const H=(0,a.getSubschema)(this.it,O);(0,a.extendSubschemaData)(H,this.it,O),(0,a.extendSubschemaMode)(H,O);const X={...this.it,...H,items:void 0,props:void 0};return S(X,U),X}mergeEvaluated(O,U){const{it:H,gen:X}=this;H.opts.unevaluated&&(H.props!==!0&&O.props!==void 0&&(H.props=d.mergeEvaluated.props(X,O.props,H.props,U)),H.items!==!0&&O.items!==void 0&&(H.items=d.mergeEvaluated.items(X,O.items,H.items,U)))}mergeValidEvaluated(O,U){const{it:H,gen:X}=this;if(H.opts.unevaluated&&(H.props!==!0||H.items!==!0))return X.if(U,()=>this.mergeEvaluated(O,i.Name)),!0}}Nt.KeywordCxt=E;function q(N,O,U,H){const X=new E(N,U,O);"code"in U?U.code(X,H):X.$data&&U.validate?(0,o.funcKeywordCode)(X,U):"macro"in U?(0,o.macroKeywordCode)(X,U):(U.compile||U.validate)&&(0,o.funcKeywordCode)(X,U)}const D=/^\/(?:[^~]|~0|~1)*$/,Y=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function J(N,{dataLevel:O,dataNames:U,dataPathArr:H}){let X,ce;if(N==="")return c.default.rootData;if(N[0]==="/"){if(!D.test(N))throw new Error(`Invalid JSON-pointer: ${N}`);X=N,ce=c.default.rootData}else{const Fe=Y.exec(N);if(!Fe)throw new Error(`Invalid JSON-pointer: ${N}`);const Me=+Fe[1];if(X=Fe[2],X==="#"){if(Me>=O)throw new Error(Ve("property/index",Me));return H[O-Me]}if(Me>O)throw new Error(Ve("data",Me));if(ce=U[O-Me],!X)return ce}let Ae=ce;const tt=X.split("/");for(const Fe of tt)Fe&&(ce=(0,i._)`${ce}${(0,i.getProperty)((0,d.unescapeJsonPointer)(Fe))}`,Ae=(0,i._)`${Ae} && ${ce}`);return Ae;function Ve(Fe,Me){return`Cannot access ${Fe} ${Me} levels up, current level is ${O}`}}return Nt.getData=J,Nt}var qn={},ml;function Ii(){if(ml)return qn;ml=1,Object.defineProperty(qn,"__esModule",{value:!0});class e extends Error{constructor(r){super("validation failed"),this.errors=r,this.ajv=this.validation=!0}}return qn.default=e,qn}var xr={};Object.defineProperty(xr,"__esModule",{value:!0});const Qs=We;class DE extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Qs.resolveUrl)(t,r,n),this.missingSchema=(0,Qs.normalizeId)((0,Qs.getFullPath)(t,this.missingRef))}}xr.default=DE;var at={};Object.defineProperty(at,"__esModule",{value:!0});at.resolveSchema=at.getCompilingSchema=at.resolveRef=at.compileSchema=at.SchemaEnv=void 0;const yt=he,UE=Ii(),Yt=Ct,bt=We,gl=B,VE=xs();class qs{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,bt.normalizeId)(n==null?void 0:n[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n==null?void 0:n.$async,this.refs={}}}at.SchemaEnv=qs;function ji(e){const t=$f.call(this,e);if(t)return t;const r=(0,bt.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,a=new yt.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o});let i;e.$async&&(i=a.scopeValue("Error",{ref:UE.default,code:(0,yt._)`require("ajv/dist/runtime/validation_error").default`}));const c=a.scopeName("validate");e.validateName=c;const l={gen:a,allErrors:this.opts.allErrors,data:Yt.default.data,parentData:Yt.default.parentData,parentDataProperty:Yt.default.parentDataProperty,dataNames:[Yt.default.data],dataPathArr:[yt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,yt.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:yt.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,yt._)`""`,opts:this.opts,self:this};let d;try{this._compilations.add(e),(0,VE.validateFunctionCode)(l),a.optimize(this.opts.code.optimize);const f=a.toString();d=`${a.scopeRefs(Yt.default.scope)}return ${f}`,this.opts.code.process&&(d=this.opts.code.process(d,e));const g=new Function(`${Yt.default.self}`,`${Yt.default.scope}`,d)(this,this.scope.get());if(this.scope.value(c,{ref:g}),g.errors=null,g.schema=e.schema,g.schemaEnv=e,e.$async&&(g.$async=!0),this.opts.code.source===!0&&(g.source={validateName:c,validateCode:f,scopeValues:a._values}),this.opts.unevaluated){const{props:m,items:v}=l;g.evaluated={props:m instanceof yt.Name?void 0:m,items:v instanceof yt.Name?void 0:v,dynamicProps:m instanceof yt.Name,dynamicItems:v instanceof yt.Name},g.source&&(g.source.evaluated=(0,yt.stringify)(g.evaluated))}return e.validate=g,e}catch(f){throw delete e.validate,delete e.validateName,d&&this.logger.error("Error compiling schema, function code:",d),f}finally{this._compilations.delete(e)}}at.compileSchema=ji;function FE(e,t,r){var n;r=(0,bt.resolveUrl)(this.opts.uriResolver,t,r);const s=e.refs[r];if(s)return s;let o=ZE.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 qs({schema:a,schemaId:i,root:e,baseId:t}))}if(o!==void 0)return e.refs[r]=LE.call(this,o)}at.resolveRef=FE;function LE(e){return(0,bt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:ji.call(this,e)}function $f(e){for(const t of this._compilations)if(HE(t,e))return t}at.getCompilingSchema=$f;function HE(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function ZE(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Ds.call(this,e,t)}function Ds(e,t){const r=this.opts.uriResolver.parse(t),n=(0,bt._getFullPath)(this.opts.uriResolver,r);let s=(0,bt.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===s)return Ys.call(this,r,e);const o=(0,bt.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){const i=Ds.call(this,e,a);return typeof(i==null?void 0:i.schema)!="object"?void 0:Ys.call(this,r,i)}if(typeof(a==null?void 0:a.schema)=="object"){if(a.validate||ji.call(this,a),o===(0,bt.normalizeId)(t)){const{schema:i}=a,{schemaId:c}=this.opts,l=i[c];return l&&(s=(0,bt.resolveUrl)(this.opts.uriResolver,s,l)),new qs({schema:i,schemaId:c,root:e,baseId:s})}return Ys.call(this,r,a)}}at.resolveSchema=Ds;const KE=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Ys(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,gl.unescapeFragment)(i)];if(c===void 0)return;r=c;const l=typeof r=="object"&&r[this.opts.schemaId];!KE.has(i)&&l&&(t=(0,bt.resolveUrl)(this.opts.uriResolver,t,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,gl.schemaHasRulesButRef)(r,this.RULES)){const i=(0,bt.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=Ds.call(this,n,i)}const{schemaId:a}=this.opts;if(o=o||new qs({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}const GE="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",WE="Meta-schema for $data reference (JSON AnySchema extension proposal)",BE="object",JE=["$data"],QE={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},YE=!1,XE={$id:GE,description:WE,type:BE,required:JE,properties:QE,additionalProperties:YE};var Oi={};Object.defineProperty(Oi,"__esModule",{value:!0});const wf=Hd;wf.code='require("ajv/dist/runtime/uri").default';Oi.default=wf;(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=xs();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=he;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});const n=Ii(),s=xr,o=dr,a=at,i=he,c=We,l=De,d=B,f=XE,_=Oi,g=(A,w)=>new RegExp(A,w);g.code="new RegExp";const m=["removeAdditional","useDefaults","coerceTypes"],v=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),y={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},h={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},$=200;function S(A){var w,C,b,u,p,E,q,D,Y,J,N,O,U,H,X,ce,Ae,tt,Ve,Fe,Me,Et,Ye,Zt,Kt;const mt=A.strict,Gt=(w=A.code)===null||w===void 0?void 0:w.optimize,Ur=Gt===!0||Gt===void 0?1:Gt||0,Vr=(b=(C=A.code)===null||C===void 0?void 0:C.regExp)!==null&&b!==void 0?b:g,Fs=(u=A.uriResolver)!==null&&u!==void 0?u:_.default;return{strictSchema:(E=(p=A.strictSchema)!==null&&p!==void 0?p:mt)!==null&&E!==void 0?E:!0,strictNumbers:(D=(q=A.strictNumbers)!==null&&q!==void 0?q:mt)!==null&&D!==void 0?D:!0,strictTypes:(J=(Y=A.strictTypes)!==null&&Y!==void 0?Y:mt)!==null&&J!==void 0?J:"log",strictTuples:(O=(N=A.strictTuples)!==null&&N!==void 0?N:mt)!==null&&O!==void 0?O:"log",strictRequired:(H=(U=A.strictRequired)!==null&&U!==void 0?U:mt)!==null&&H!==void 0?H:!1,code:A.code?{...A.code,optimize:Ur,regExp:Vr}:{optimize:Ur,regExp:Vr},loopRequired:(X=A.loopRequired)!==null&&X!==void 0?X:$,loopEnum:(ce=A.loopEnum)!==null&&ce!==void 0?ce:$,meta:(Ae=A.meta)!==null&&Ae!==void 0?Ae:!0,messages:(tt=A.messages)!==null&&tt!==void 0?tt:!0,inlineRefs:(Ve=A.inlineRefs)!==null&&Ve!==void 0?Ve:!0,schemaId:(Fe=A.schemaId)!==null&&Fe!==void 0?Fe:"$id",addUsedSchema:(Me=A.addUsedSchema)!==null&&Me!==void 0?Me:!0,validateSchema:(Et=A.validateSchema)!==null&&Et!==void 0?Et:!0,validateFormats:(Ye=A.validateFormats)!==null&&Ye!==void 0?Ye:!0,unicodeRegExp:(Zt=A.unicodeRegExp)!==null&&Zt!==void 0?Zt:!0,int32range:(Kt=A.int32range)!==null&&Kt!==void 0?Kt:!0,uriResolver:Fs}}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,...S(w)};const{es5:C,lines:b}=this.opts.code;this.scope=new i.ValueScope({scope:{},prefixes:v,es5:C,lines:b}),this.logger=Q(w.logger);const u=w.validateFormats;w.validateFormats=!1,this.RULES=(0,o.getRules)(),k.call(this,y,w,"NOT SUPPORTED"),k.call(this,h,w,"DEPRECATED","warn"),this._metaOpts=Z.call(this),w.formats&&F.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),w.keywords&&G.call(this,w.keywords),typeof w.meta=="object"&&this.addMetaSchema(w.meta),z.call(this),w.validateFormats=u}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:w,meta:C,schemaId:b}=this.opts;let u=f;b==="id"&&(u={...f},u.id=u.$id,delete u.$id),C&&w&&this.addMetaSchema(u,u[b],!1)}defaultMeta(){const{meta:w,schemaId:C}=this.opts;return this.opts.defaultMeta=typeof w=="object"?w[C]||w:void 0}validate(w,C){let b;if(typeof w=="string"){if(b=this.getSchema(w),!b)throw new Error(`no schema with key or ref "${w}"`)}else b=this.compile(w);const u=b(C);return"$async"in b||(this.errors=b.errors),u}compile(w,C){const b=this._addSchema(w,C);return b.validate||this._compileSchemaEnv(b)}compileAsync(w,C){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:b}=this.opts;return u.call(this,w,C);async function u(J,N){await p.call(this,J.$schema);const O=this._addSchema(J,N);return O.validate||E.call(this,O)}async function p(J){J&&!this.getSchema(J)&&await u.call(this,{$ref:J},!0)}async function E(J){try{return this._compileSchemaEnv(J)}catch(N){if(!(N instanceof s.default))throw N;return q.call(this,N),await D.call(this,N.missingSchema),E.call(this,J)}}function q({missingSchema:J,missingRef:N}){if(this.refs[J])throw new Error(`AnySchema ${J} is loaded but ${N} cannot be resolved`)}async function D(J){const N=await Y.call(this,J);this.refs[J]||await p.call(this,N.$schema),this.refs[J]||this.addSchema(N,J,C)}async function Y(J){const N=this._loading[J];if(N)return N;try{return await(this._loading[J]=b(J))}finally{delete this._loading[J]}}}addSchema(w,C,b,u=this.opts.validateSchema){if(Array.isArray(w)){for(const E of w)this.addSchema(E,void 0,b,u);return this}let p;if(typeof w=="object"){const{schemaId:E}=this.opts;if(p=w[E],p!==void 0&&typeof p!="string")throw new Error(`schema ${E} must be string`)}return C=(0,c.normalizeId)(C||p),this._checkUnique(C),this.schemas[C]=this._addSchema(w,b,C,u,!0),this}addMetaSchema(w,C,b=this.opts.validateSchema){return this.addSchema(w,C,!0,b),this}validateSchema(w,C){if(typeof w=="boolean")return!0;let b;if(b=w.$schema,b!==void 0&&typeof b!="string")throw new Error("$schema must be a string");if(b=b||this.opts.defaultMeta||this.defaultMeta(),!b)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const u=this.validate(b,w);if(!u&&C){const p="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(p);else throw new Error(p)}return u}getSchema(w){let C;for(;typeof(C=I.call(this,w))=="string";)w=C;if(C===void 0){const{schemaId:b}=this.opts,u=new a.SchemaEnv({schema:{},schemaId:b});if(C=a.resolveSchema.call(this,u,w),!C)return;this.refs[w]=C}return C.validate||this._compileSchemaEnv(C)}removeSchema(w){if(w instanceof RegExp)return this._removeAllSchemas(this.schemas,w),this._removeAllSchemas(this.refs,w),this;switch(typeof w){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const C=I.call(this,w);return typeof C=="object"&&this._cache.delete(C.schema),delete this.schemas[w],delete this.refs[w],this}case"object":{const C=w;this._cache.delete(C);let b=w[this.opts.schemaId];return b&&(b=(0,c.normalizeId)(b),delete this.schemas[b],delete this.refs[b]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(w){for(const C of w)this.addKeyword(C);return this}addKeyword(w,C){let b;if(typeof w=="string")b=w,typeof C=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),C.keyword=b);else if(typeof w=="object"&&C===void 0){if(C=w,b=C.keyword,Array.isArray(b)&&!b.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(V.call(this,b,C),!C)return(0,d.eachItem)(b,p=>ie.call(this,p)),this;$e.call(this,C);const u={...C,type:(0,l.getJSONTypes)(C.type),schemaType:(0,l.getJSONTypes)(C.schemaType)};return(0,d.eachItem)(b,u.type.length===0?p=>ie.call(this,p,u):p=>u.type.forEach(E=>ie.call(this,p,u,E))),this}getKeyword(w){const C=this.RULES.all[w];return typeof C=="object"?C.definition:!!C}removeKeyword(w){const{RULES:C}=this;delete C.keywords[w],delete C.all[w];for(const b of C.rules){const u=b.rules.findIndex(p=>p.keyword===w);u>=0&&b.rules.splice(u,1)}return this}addFormat(w,C){return typeof C=="string"&&(C=new RegExp(C)),this.formats[w]=C,this}errorsText(w=this.errors,{separator:C=", ",dataVar:b="data"}={}){return!w||w.length===0?"No errors":w.map(u=>`${b}${u.instancePath} ${u.message}`).reduce((u,p)=>u+C+p)}$dataMetaSchema(w,C){const b=this.RULES.all;w=JSON.parse(JSON.stringify(w));for(const u of C){const p=u.split("/").slice(1);let E=w;for(const q of p)E=E[q];for(const q in b){const D=b[q];if(typeof D!="object")continue;const{$data:Y}=D.definition,J=E[q];Y&&J&&(E[q]=Oe(J))}}return w}_removeAllSchemas(w,C){for(const b in w){const u=w[b];(!C||C.test(b))&&(typeof u=="string"?delete w[b]:u&&!u.meta&&(this._cache.delete(u.schema),delete w[b]))}}_addSchema(w,C,b,u=this.opts.validateSchema,p=this.opts.addUsedSchema){let E;const{schemaId:q}=this.opts;if(typeof w=="object")E=w[q];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof w!="boolean")throw new Error("schema must be object or boolean")}let D=this._cache.get(w);if(D!==void 0)return D;b=(0,c.normalizeId)(E||b);const Y=c.getSchemaRefs.call(this,w,b);return D=new a.SchemaEnv({schema:w,schemaId:q,meta:C,baseId:b,localRefs:Y}),this._cache.set(D.schema,D),p&&!b.startsWith("#")&&(b&&this._checkUnique(b),this.refs[b]=D),u&&this.validateSchema(w,!0),D}_checkUnique(w){if(this.schemas[w]||this.refs[w])throw new Error(`schema with key or id "${w}" already exists`)}_compileSchemaEnv(w){if(w.meta?this._compileMetaSchema(w):a.compileSchema.call(this,w),!w.validate)throw new Error("ajv implementation error");return w.validate}_compileMetaSchema(w){const C=this.opts;this.opts=this._metaOpts;try{a.compileSchema.call(this,w)}finally{this.opts=C}}}T.ValidationError=n.default,T.MissingRefError=s.default,e.default=T;function k(A,w,C,b="error"){for(const u in A){const p=u;p in w&&this.logger[b](`${C}: option ${u}. ${A[p]}`)}}function I(A){return A=(0,c.normalizeId)(A),this.schemas[A]||this.refs[A]}function z(){const A=this.opts.schemas;if(A)if(Array.isArray(A))this.addSchema(A);else for(const w in A)this.addSchema(A[w],w)}function F(){for(const A in this.opts.formats){const w=this.opts.formats[A];w&&this.addFormat(A,w)}}function G(A){if(Array.isArray(A)){this.addVocabulary(A);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const w in A){const C=A[w];C.keyword||(C.keyword=w),this.addKeyword(C)}}function Z(){const A={...this.opts};for(const w of m)delete A[w];return A}const K={log(){},warn(){},error(){}};function Q(A){if(A===!1)return K;if(A===void 0)return console;if(A.log&&A.warn&&A.error)return A;throw new Error("logger must implement log, warn and error methods")}const re=/^[a-z_$][a-z0-9_$:-]*$/i;function V(A,w){const{RULES:C}=this;if((0,d.eachItem)(A,b=>{if(C.keywords[b])throw new Error(`Keyword ${b} is already defined`);if(!re.test(b))throw new Error(`Keyword ${b} has invalid name`)}),!!w&&w.$data&&!("code"in w||"validate"in w))throw new Error('$data keyword must have "code" or "validate" function')}function ie(A,w,C){var b;const u=w==null?void 0:w.post;if(C&&u)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:p}=this;let E=u?p.post:p.rules.find(({type:D})=>D===C);if(E||(E={type:C,rules:[]},p.rules.push(E)),p.keywords[A]=!0,!w)return;const q={keyword:A,definition:{...w,type:(0,l.getJSONTypes)(w.type),schemaType:(0,l.getJSONTypes)(w.schemaType)}};w.before?ke.call(this,E,q,w.before):E.rules.push(q),p.all[A]=q,(b=w.implements)===null||b===void 0||b.forEach(D=>this.addKeyword(D))}function ke(A,w,C){const b=A.rules.findIndex(u=>u.keyword===C);b>=0?A.rules.splice(b,0,w):(A.rules.push(w),this.logger.warn(`rule ${C} is not defined`))}function $e(A){let{metaSchema:w}=A;w!==void 0&&(A.$data&&this.opts.$data&&(w=Oe(w)),A.validateSchema=this.compile(w,!0))}const ct={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Oe(A){return{anyOf:[A,ct]}}})(rf);var Ai={},Mi={},zi={};Object.defineProperty(zi,"__esModule",{value:!0});const ek={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};zi.default=ek;var fr={};Object.defineProperty(fr,"__esModule",{value:!0});fr.callRef=fr.getValidate=void 0;const tk=xr,_l=me,st=he,gr=Ct,yl=at,Dn=B,rk={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:r,it:n}=e,{baseId:s,schemaEnv:o,validateName:a,opts:i,self:c}=n,{root:l}=o;if((r==="#"||r==="#/")&&s===l.baseId)return f();const d=yl.resolveRef.call(c,l,s,r);if(d===void 0)throw new tk.default(n.opts.uriResolver,s,r);if(d instanceof yl.SchemaEnv)return _(d);return g(d);function f(){if(o===l)return Yn(e,a,o,o.$async);const m=t.scopeValue("root",{ref:l});return Yn(e,(0,st._)`${m}.validate`,l,l.$async)}function _(m){const v=bf(e,m);Yn(e,v,m,m.$async)}function g(m){const v=t.scopeValue("schema",i.code.source===!0?{ref:m,code:(0,st.stringify)(m)}:{ref:m}),y=t.name("valid"),h=e.subschema({schema:m,dataTypes:[],schemaPath:st.nil,topSchemaRef:v,errSchemaPath:r},y);e.mergeEvaluated(h),e.ok(y)}}};function bf(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,st._)`${r.scopeValue("wrapper",{ref:t})}.validate`}fr.getValidate=bf;function Yn(e,t,r,n){const{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:c}=o,l=c.passContext?gr.default.this:st.nil;n?d():f();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");const m=s.let("valid");s.try(()=>{s.code((0,st._)`await ${(0,_l.callValidateCode)(e,t,l)}`),g(t),a||s.assign(m,!0)},v=>{s.if((0,st._)`!(${v} instanceof ${o.ValidationError})`,()=>s.throw(v)),_(v),a||s.assign(m,!1)}),e.ok(m)}function f(){e.result((0,_l.callValidateCode)(e,t,l),()=>g(t),()=>_(t))}function _(m){const v=(0,st._)`${m}.errors`;s.assign(gr.default.vErrors,(0,st._)`${gr.default.vErrors} === null ? ${v} : ${gr.default.vErrors}.concat(${v})`),s.assign(gr.default.errors,(0,st._)`${gr.default.vErrors}.length`)}function g(m){var v;if(!o.opts.unevaluated)return;const y=(v=r==null?void 0:r.validate)===null||v===void 0?void 0:v.evaluated;if(o.props!==!0)if(y&&!y.dynamicProps)y.props!==void 0&&(o.props=Dn.mergeEvaluated.props(s,y.props,o.props));else{const h=s.var("props",(0,st._)`${m}.evaluated.props`);o.props=Dn.mergeEvaluated.props(s,h,o.props,st.Name)}if(o.items!==!0)if(y&&!y.dynamicItems)y.items!==void 0&&(o.items=Dn.mergeEvaluated.items(s,y.items,o.items));else{const h=s.var("items",(0,st._)`${m}.evaluated.items`);o.items=Dn.mergeEvaluated.items(s,h,o.items,st.Name)}}}fr.callRef=Yn;fr.default=rk;Object.defineProperty(Mi,"__esModule",{value:!0});const nk=zi,sk=fr,ok=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",nk.default,sk.default];Mi.default=ok;var xi={},qi={};Object.defineProperty(qi,"__esModule",{value:!0});const ps=he,qt=ps.operators,ms={maximum:{okStr:"<=",ok:qt.LTE,fail:qt.GT},minimum:{okStr:">=",ok:qt.GTE,fail:qt.LT},exclusiveMaximum:{okStr:"<",ok:qt.LT,fail:qt.GTE},exclusiveMinimum:{okStr:">",ok:qt.GT,fail:qt.LTE}},ak={message:({keyword:e,schemaCode:t})=>(0,ps.str)`must be ${ms[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,ps._)`{comparison: ${ms[e].okStr}, limit: ${t}}`},ik={keyword:Object.keys(ms),type:"number",schemaType:"number",$data:!0,error:ak,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,ps._)`${r} ${ms[t].fail} ${n} || isNaN(${r})`)}};qi.default=ik;var Di={};Object.defineProperty(Di,"__esModule",{value:!0});const nn=he,ck={message:({schemaCode:e})=>(0,nn.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,nn._)`{multipleOf: ${e}}`},lk={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:ck,code(e){const{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0,nn._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0,nn._)`${a} !== parseInt(${a})`;e.fail$data((0,nn._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};Di.default=lk;var Ui={},Vi={};Object.defineProperty(Vi,"__esModule",{value:!0});function Sf(e){const t=e.length;let r=0,n=0,s;for(;n=55296&&s<=56319&&n(0,sr._)`{limit: ${e}}`},hk={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:fk,code(e){const{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?sr.operators.GT:sr.operators.LT,a=s.opts.unicode===!1?(0,sr._)`${r}.length`:(0,sr._)`${(0,uk.useFunc)(e.gen,dk.default)}(${r})`;e.fail$data((0,sr._)`${a} ${o} ${n}`)}};Ui.default=hk;var Fi={};Object.defineProperty(Fi,"__esModule",{value:!0});const pk=me,mk=B,Sr=he,gk={message:({schemaCode:e})=>(0,Sr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Sr._)`{pattern: ${e}}`},_k={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:gk,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,Sr._)`new RegExp`:(0,mk.useFunc)(t,c),d=t.let("valid");t.try(()=>t.assign(d,(0,Sr._)`${l}(${o}, ${i}).test(${r})`),()=>t.assign(d,!1)),e.fail$data((0,Sr._)`!${d}`)}else{const c=(0,pk.usePattern)(e,s);e.fail$data((0,Sr._)`!${c}.test(${r})`)}}};Fi.default=_k;var Li={};Object.defineProperty(Li,"__esModule",{value:!0});const sn=he,yk={message({keyword:e,schemaCode:t}){const r=e==="maxProperties"?"more":"fewer";return(0,sn.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,sn._)`{limit: ${e}}`},vk={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:yk,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?sn.operators.GT:sn.operators.LT;e.fail$data((0,sn._)`Object.keys(${r}).length ${s} ${n}`)}};Li.default=vk;var Hi={};Object.defineProperty(Hi,"__esModule",{value:!0});const Kr=me,on=he,$k=B,wk={message:({params:{missingProperty:e}})=>(0,on.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,on._)`{missingProperty: ${e}}`},bk={keyword:"required",type:"object",schemaType:"array",$data:!0,error:wk,code(e){const{gen:t,schema:r,schemaCode:n,data:s,$data:o,it:a}=e,{opts:i}=a;if(!o&&r.length===0)return;const c=r.length>=i.loopRequired;if(a.allErrors?l():d(),i.strictRequired){const g=e.parentSchema.properties,{definedProperties:m}=e.it;for(const v of r)if((g==null?void 0:g[v])===void 0&&!m.has(v)){const y=a.schemaEnv.baseId+a.errSchemaPath,h=`required property "${v}" is not defined at "${y}" (strictRequired)`;(0,$k.checkStrictMode)(a,h,a.opts.strictRequired)}}function l(){if(c||o)e.block$data(on.nil,f);else for(const g of r)(0,Kr.checkReportMissingProp)(e,g)}function d(){const g=t.let("missing");if(c||o){const m=t.let("valid",!0);e.block$data(m,()=>_(g,m)),e.ok(m)}else t.if((0,Kr.checkMissingProp)(e,r,g)),(0,Kr.reportMissingProp)(e,g),t.else()}function f(){t.forOf("prop",n,g=>{e.setParams({missingProperty:g}),t.if((0,Kr.noPropertyInData)(t,s,g,i.ownProperties),()=>e.error())})}function _(g,m){e.setParams({missingProperty:g}),t.forOf(g,n,()=>{t.assign(m,(0,Kr.propertyInData)(t,s,g,i.ownProperties)),t.if((0,on.not)(m),()=>{e.error(),t.break()})},on.nil)}}};Hi.default=bk;var Zi={};Object.defineProperty(Zi,"__esModule",{value:!0});const an=he,Sk={message({keyword:e,schemaCode:t}){const r=e==="maxItems"?"more":"fewer";return(0,an.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,an._)`{limit: ${e}}`},Ek={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Sk,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?an.operators.GT:an.operators.LT;e.fail$data((0,an._)`${r}.length ${s} ${n}`)}};Zi.default=Ek;var Ki={},Rn={};Object.defineProperty(Rn,"__esModule",{value:!0});const Ef=Is;Ef.code='require("ajv/dist/runtime/equal").default';Rn.default=Ef;Object.defineProperty(Ki,"__esModule",{value:!0});const Xs=De,Ze=he,kk=B,Pk=Rn,Tk={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}}`},Rk={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:Tk,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,Xs.getSchemaTypes)(o.items):[];e.block$data(c,d,(0,Ze._)`${a} === false`),e.ok(c);function d(){const m=t.let("i",(0,Ze._)`${r}.length`),v=t.let("j");e.setParams({i:m,j:v}),t.assign(c,!0),t.if((0,Ze._)`${m} > 1`,()=>(f()?_:g)(m,v))}function f(){return l.length>0&&!l.some(m=>m==="object"||m==="array")}function _(m,v){const y=t.name("item"),h=(0,Xs.checkDataTypes)(l,y,i.opts.strictNumbers,Xs.DataType.Wrong),$=t.const("indices",(0,Ze._)`{}`);t.for((0,Ze._)`;${m}--;`,()=>{t.let(y,(0,Ze._)`${r}[${m}]`),t.if(h,(0,Ze._)`continue`),l.length>1&&t.if((0,Ze._)`typeof ${y} == "string"`,(0,Ze._)`${y} += "_"`),t.if((0,Ze._)`typeof ${$}[${y}] == "number"`,()=>{t.assign(v,(0,Ze._)`${$}[${y}]`),e.error(),t.assign(c,!1).break()}).code((0,Ze._)`${$}[${y}] = ${m}`)})}function g(m,v){const y=(0,kk.useFunc)(t,Pk.default),h=t.name("outer");t.label(h).for((0,Ze._)`;${m}--;`,()=>t.for((0,Ze._)`${v} = ${m}; ${v}--;`,()=>t.if((0,Ze._)`${y}(${r}[${m}], ${r}[${v}])`,()=>{e.error(),t.assign(c,!1).break(h)})))}}};Ki.default=Rk;var Gi={};Object.defineProperty(Gi,"__esModule",{value:!0});const Co=he,Ck=B,Nk=Rn,Ik={message:"must be equal to constant",params:({schemaCode:e})=>(0,Co._)`{allowedValue: ${e}}`},jk={keyword:"const",$data:!0,error:Ik,code(e){const{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,Co._)`!${(0,Ck.useFunc)(t,Nk.default)}(${r}, ${s})`):e.fail((0,Co._)`${o} !== ${r}`)}};Gi.default=jk;var Wi={};Object.defineProperty(Wi,"__esModule",{value:!0});const Jr=he,Ok=B,Ak=Rn,Mk={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,Jr._)`{allowedValues: ${e}}`},zk={keyword:"enum",schemaType:"array",$data:!0,error:Mk,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,Ok.useFunc)(t,Ak.default));let d;if(i||n)d=t.let("valid"),e.block$data(d,f);else{if(!Array.isArray(s))throw new Error("ajv implementation error");const g=t.const("vSchema",o);d=(0,Jr.or)(...s.map((m,v)=>_(g,v)))}e.pass(d);function f(){t.assign(d,!1),t.forOf("v",o,g=>t.if((0,Jr._)`${l()}(${r}, ${g})`,()=>t.assign(d,!0).break()))}function _(g,m){const v=s[m];return typeof v=="object"&&v!==null?(0,Jr._)`${l()}(${r}, ${g}[${m}])`:(0,Jr._)`${r} === ${v}`}}};Wi.default=zk;Object.defineProperty(xi,"__esModule",{value:!0});const xk=qi,qk=Di,Dk=Ui,Uk=Fi,Vk=Li,Fk=Hi,Lk=Zi,Hk=Ki,Zk=Gi,Kk=Wi,Gk=[xk.default,qk.default,Dk.default,Uk.default,Vk.default,Fk.default,Lk.default,Hk.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},Zk.default,Kk.default];xi.default=Gk;var Bi={},qr={};Object.defineProperty(qr,"__esModule",{value:!0});qr.validateAdditionalItems=void 0;const or=he,No=B,Wk={message:({params:{len:e}})=>(0,or.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,or._)`{limit: ${e}}`},Bk={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:Wk,code(e){const{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,No.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}kf(e,n)}};function kf(e,t){const{gen:r,schema:n,data:s,keyword:o,it:a}=e;a.items=!0;const i=r.const("len",(0,or._)`${s}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,or._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0,No.alwaysValidSchema)(a,n)){const l=r.var("valid",(0,or._)`${i} <= ${t.length}`);r.if((0,or.not)(l),()=>c(l)),e.ok(l)}function c(l){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:No.Type.Num},l),a.allErrors||r.if((0,or.not)(l),()=>r.break())})}}qr.validateAdditionalItems=kf;qr.default=Bk;var Ji={},Dr={};Object.defineProperty(Dr,"__esModule",{value:!0});Dr.validateTuple=void 0;const vl=he,Xn=B,Jk=me,Qk={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return Pf(e,"additionalItems",t);r.items=!0,!(0,Xn.alwaysValidSchema)(r,t)&&e.ok((0,Jk.validateArray)(e))}};function Pf(e,t,r=e.schema){const{gen:n,parentSchema:s,data:o,keyword:a,it:i}=e;d(s),i.opts.unevaluated&&r.length&&i.items!==!0&&(i.items=Xn.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),l=n.const("len",(0,vl._)`${o}.length`);r.forEach((f,_)=>{(0,Xn.alwaysValidSchema)(i,f)||(n.if((0,vl._)`${l} > ${_}`,()=>e.subschema({keyword:a,schemaProp:_,dataProp:_},c)),e.ok(c))});function d(f){const{opts:_,errSchemaPath:g}=i,m=r.length,v=m===f.minItems&&(m===f.maxItems||f[t]===!1);if(_.strictTuples&&!v){const y=`"${a}" is ${m}-tuple, but minItems or maxItems/${t} are not specified or different at path "${g}"`;(0,Xn.checkStrictMode)(i,y,_.strictTuples)}}}Dr.validateTuple=Pf;Dr.default=Qk;Object.defineProperty(Ji,"__esModule",{value:!0});const Yk=Dr,Xk={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,Yk.validateTuple)(e,"items")};Ji.default=Xk;var Qi={};Object.defineProperty(Qi,"__esModule",{value:!0});const $l=he,eP=B,tP=me,rP=qr,nP={message:({params:{len:e}})=>(0,$l.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,$l._)`{limit: ${e}}`},sP={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:nP,code(e){const{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=!0,!(0,eP.alwaysValidSchema)(n,t)&&(s?(0,rP.validateAdditionalItems)(e,s):e.ok((0,tP.validateArray)(e)))}};Qi.default=sP;var Yi={};Object.defineProperty(Yi,"__esModule",{value:!0});const ft=he,Un=B,oP={message:({params:{min:e,max:t}})=>t===void 0?(0,ft.str)`must contain at least ${e} valid item(s)`:(0,ft.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,ft._)`{minContains: ${e}}`:(0,ft._)`{minContains: ${e}, maxContains: ${t}}`},aP={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:oP,code(e){const{gen:t,schema:r,parentSchema:n,data:s,it:o}=e;let a,i;const{minContains:c,maxContains:l}=n;o.opts.next?(a=c===void 0?1:c,i=l):a=1;const d=t.const("len",(0,ft._)`${s}.length`);if(e.setParams({min:a,max:i}),i===void 0&&a===0){(0,Un.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0,Un.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Un.alwaysValidSchema)(o,r)){let v=(0,ft._)`${d} >= ${a}`;i!==void 0&&(v=(0,ft._)`${v} && ${d} <= ${i}`),e.pass(v);return}o.items=!0;const f=t.name("valid");i===void 0&&a===1?g(f,()=>t.if(f,()=>t.break())):a===0?(t.let(f,!0),i!==void 0&&t.if((0,ft._)`${s}.length > 0`,_)):(t.let(f,!1),_()),e.result(f,()=>e.reset());function _(){const v=t.name("_valid"),y=t.let("count",0);g(v,()=>t.if(v,()=>m(y)))}function g(v,y){t.forRange("i",0,d,h=>{e.subschema({keyword:"contains",dataProp:h,dataPropType:Un.Type.Num,compositeRule:!0},v),y()})}function m(v){t.code((0,ft._)`${v}++`),i===void 0?t.if((0,ft._)`${v} >= ${a}`,()=>t.assign(f,!0).break()):(t.if((0,ft._)`${v} > ${i}`,()=>t.assign(f,!1).break()),a===1?t.assign(f,!0):t.if((0,ft._)`${v} >= ${a}`,()=>t.assign(f,!0)))}}};Yi.default=aP;var Tf={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=he,r=B,n=me;e.error={message:({params:{property:c,depsCount:l,deps:d}})=>{const f=l===1?"property":"properties";return(0,t.str)`must have ${f} ${d} when property ${c} is present`},params:({params:{property:c,depsCount:l,deps:d,missingProperty:f}})=>(0,t._)`{property: ${c}, - missingProperty: ${f}, - depsCount: ${l}, - deps: ${d}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(c){const[l,d]=o(c);a(c,l),i(c,d)}};function o({schema:c}){const l={},d={};for(const f in c){if(f==="__proto__")continue;const _=Array.isArray(c[f])?l:d;_[f]=c[f]}return[l,d]}function a(c,l=c.schema){const{gen:d,data:f,it:_}=c;if(Object.keys(l).length===0)return;const g=d.let("missing");for(const m in l){const v=l[m];if(v.length===0)continue;const y=(0,n.propertyInData)(d,f,m,_.opts.ownProperties);c.setParams({property:m,depsCount:v.length,deps:v.join(", ")}),_.allErrors?d.if(y,()=>{for(const h of v)(0,n.checkReportMissingProp)(c,h)}):(d.if((0,t._)`${y} && (${(0,n.checkMissingProp)(c,v,g)})`),(0,n.reportMissingProp)(c,g),d.else())}}e.validatePropertyDeps=a;function i(c,l=c.schema){const{gen:d,data:f,keyword:_,it:g}=c,m=d.name("valid");for(const v in l)(0,r.alwaysValidSchema)(g,l[v])||(d.if((0,n.propertyInData)(d,f,v,g.opts.ownProperties),()=>{const y=c.subschema({keyword:_,schemaProp:v},m);c.mergeValidEvaluated(y,m)},()=>d.var(m,!0)),c.ok(m))}e.validateSchemaDeps=i,e.default=s})(Tf);var Xi={};Object.defineProperty(Xi,"__esModule",{value:!0});const Rf=he,iP=B,cP={message:"property name must be valid",params:({params:e})=>(0,Rf._)`{propertyName: ${e.propertyName}}`},lP={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:cP,code(e){const{gen:t,schema:r,data:n,it:s}=e;if((0,iP.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,Rf.not)(o),()=>{e.error(!0),s.allErrors||t.break()})}),e.ok(o)}};Xi.default=lP;var Us={};Object.defineProperty(Us,"__esModule",{value:!0});const Vn=me,$t=he,uP=Ct,Fn=B,dP={message:"must NOT have additional properties",params:({params:e})=>(0,$t._)`{additionalProperty: ${e.additionalProperty}}`},fP={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:dP,code(e){const{gen:t,schema:r,parentSchema:n,data:s,errsCount:o,it:a}=e;if(!o)throw new Error("ajv implementation error");const{allErrors:i,opts:c}=a;if(a.props=!0,c.removeAdditional!=="all"&&(0,Fn.alwaysValidSchema)(a,r))return;const l=(0,Vn.allSchemaProperties)(n.properties),d=(0,Vn.allSchemaProperties)(n.patternProperties);f(),e.ok((0,$t._)`${o} === ${uP.default.errors}`);function f(){t.forIn("key",s,y=>{!l.length&&!d.length?m(y):t.if(_(y),()=>m(y))})}function _(y){let h;if(l.length>8){const $=(0,Fn.schemaRefOrVal)(a,n.properties,"properties");h=(0,Vn.isOwnProperty)(t,$,y)}else l.length?h=(0,$t.or)(...l.map($=>(0,$t._)`${y} === ${$}`)):h=$t.nil;return d.length&&(h=(0,$t.or)(h,...d.map($=>(0,$t._)`${(0,Vn.usePattern)(e,$)}.test(${y})`))),(0,$t.not)(h)}function g(y){t.code((0,$t._)`delete ${s}[${y}]`)}function m(y){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){g(y);return}if(r===!1){e.setParams({additionalProperty:y}),e.error(),i||t.break();return}if(typeof r=="object"&&!(0,Fn.alwaysValidSchema)(a,r)){const h=t.name("valid");c.removeAdditional==="failing"?(v(y,h,!1),t.if((0,$t.not)(h),()=>{e.reset(),g(y)})):(v(y,h),i||t.if((0,$t.not)(h),()=>t.break()))}}function v(y,h,$){const S={keyword:"additionalProperties",dataProp:y,dataPropType:Fn.Type.Str};$===!1&&Object.assign(S,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(S,h)}}};Us.default=fP;var ec={};Object.defineProperty(ec,"__esModule",{value:!0});const hP=xs(),wl=me,eo=B,bl=Us,pP={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 hP.KeywordCxt(o,bl.default,"additionalProperties"));const a=(0,wl.allSchemaProperties)(r);for(const f of a)o.definedProperties.add(f);o.opts.unevaluated&&a.length&&o.props!==!0&&(o.props=eo.mergeEvaluated.props(t,(0,eo.toHash)(a),o.props));const i=a.filter(f=>!(0,eo.alwaysValidSchema)(o,r[f]));if(i.length===0)return;const c=t.name("valid");for(const f of i)l(f)?d(f):(t.if((0,wl.propertyInData)(t,s,f,o.opts.ownProperties)),d(f),o.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(f),e.ok(c);function l(f){return o.opts.useDefaults&&!o.compositeRule&&r[f].default!==void 0}function d(f){e.subschema({keyword:"properties",schemaProp:f,dataProp:f},c)}}};ec.default=pP;var tc={};Object.defineProperty(tc,"__esModule",{value:!0});const Sl=me,Ln=he,El=B,kl=B,mP={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(v=>(0,El.alwaysValidSchema)(o,r[v]));if(i.length===0||c.length===i.length&&(!o.opts.unevaluated||o.props===!0))return;const l=a.strictSchema&&!a.allowMatchingProperties&&s.properties,d=t.name("valid");o.props!==!0&&!(o.props instanceof Ln.Name)&&(o.props=(0,kl.evaluatedPropsToName)(t,o.props));const{props:f}=o;_();function _(){for(const v of i)l&&g(v),o.allErrors?m(v):(t.var(d,!0),m(v),t.if(d))}function g(v){for(const y in l)new RegExp(v).test(y)&&(0,El.checkStrictMode)(o,`property ${y} matches pattern ${v} (use allowMatchingProperties)`)}function m(v){t.forIn("key",n,y=>{t.if((0,Ln._)`${(0,Sl.usePattern)(e,v)}.test(${y})`,()=>{const h=c.includes(v);h||e.subschema({keyword:"patternProperties",schemaProp:v,dataProp:y,dataPropType:kl.Type.Str},d),o.opts.unevaluated&&f!==!0?t.assign((0,Ln._)`${f}[${y}]`,!0):!h&&!o.allErrors&&t.if((0,Ln.not)(d),()=>t.break())})})}}};tc.default=mP;var rc={};Object.defineProperty(rc,"__esModule",{value:!0});const gP=B,_P={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,gP.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"}};rc.default=_P;var nc={};Object.defineProperty(nc,"__esModule",{value:!0});const yP=me,vP={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:yP.validateUnion,error:{message:"must match a schema in anyOf"}};nc.default=vP;var sc={};Object.defineProperty(sc,"__esModule",{value:!0});const es=he,$P=B,wP={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,es._)`{passingSchemas: ${e.passing}}`},bP={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:wP,code(e){const{gen:t,schema:r,parentSchema:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;const o=r,a=t.let("valid",!1),i=t.let("passing",null),c=t.name("_valid");e.setParams({passing:i}),t.block(l),e.result(a,()=>e.reset(),()=>e.error(!0));function l(){o.forEach((d,f)=>{let _;(0,$P.alwaysValidSchema)(s,d)?t.var(c,!0):_=e.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},c),f>0&&t.if((0,es._)`${c} && ${a}`).assign(a,!1).assign(i,(0,es._)`[${i}, ${f}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,f),_&&e.mergeEvaluated(_,es.Name)})})}}};sc.default=bP;var oc={};Object.defineProperty(oc,"__esModule",{value:!0});const SP=B,EP={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,SP.alwaysValidSchema)(n,o))return;const i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i)})}};oc.default=EP;var ac={};Object.defineProperty(ac,"__esModule",{value:!0});const gs=he,Cf=B,kP={message:({params:e})=>(0,gs.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,gs._)`{failingKeyword: ${e.ifClause}}`},PP={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:kP,code(e){const{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,Cf.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,gs.not)(i),l("else"));e.pass(a,()=>e.error(!0));function c(){const d=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},i);e.mergeEvaluated(d)}function l(d,f){return()=>{const _=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(_,a),f?t.assign(f,(0,gs._)`${d}`):e.setParams({ifClause:d})}}}};function Pl(e,t){const r=e.schema[t];return r!==void 0&&!(0,Cf.alwaysValidSchema)(e,r)}ac.default=PP;var ic={};Object.defineProperty(ic,"__esModule",{value:!0});const TP=B,RP={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,TP.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};ic.default=RP;Object.defineProperty(Bi,"__esModule",{value:!0});const CP=qr,NP=Ji,IP=Dr,jP=Qi,OP=Yi,AP=Tf,MP=Xi,zP=Us,xP=ec,qP=tc,DP=rc,UP=nc,VP=sc,FP=oc,LP=ac,HP=ic;function ZP(e=!1){const t=[DP.default,UP.default,VP.default,FP.default,LP.default,HP.default,MP.default,zP.default,AP.default,xP.default,qP.default];return e?t.push(NP.default,jP.default):t.push(CP.default,IP.default),t.push(OP.default),t}Bi.default=ZP;var cc={},lc={};Object.defineProperty(lc,"__esModule",{value:!0});const xe=he,KP={message:({schemaCode:e})=>(0,xe.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,xe._)`{format: ${e}}`},GP={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:KP,code(e,t){const{gen:r,data:n,$data:s,schema:o,schemaCode:a,it:i}=e,{opts:c,errSchemaPath:l,schemaEnv:d,self:f}=i;if(!c.validateFormats)return;s?_():g();function _(){const m=r.scopeValue("formats",{ref:f.formats,code:c.code.formats}),v=r.const("fDef",(0,xe._)`${m}[${a}]`),y=r.let("fType"),h=r.let("format");r.if((0,xe._)`typeof ${v} == "object" && !(${v} instanceof RegExp)`,()=>r.assign(y,(0,xe._)`${v}.type || "string"`).assign(h,(0,xe._)`${v}.validate`),()=>r.assign(y,(0,xe._)`"string"`).assign(h,v)),e.fail$data((0,xe.or)($(),S()));function $(){return c.strictSchema===!1?xe.nil:(0,xe._)`${a} && !${h}`}function S(){const T=d.$async?(0,xe._)`(${v}.async ? await ${h}(${n}) : ${h}(${n}))`:(0,xe._)`${h}(${n})`,k=(0,xe._)`(typeof ${h} == "function" ? ${T} : ${h}.test(${n}))`;return(0,xe._)`${h} && ${h} !== true && ${y} === ${t} && !${k}`}}function g(){const m=f.formats[o];if(!m){$();return}if(m===!0)return;const[v,y,h]=S(m);v===t&&e.pass(T());function $(){if(c.strictSchema===!1){f.logger.warn(k());return}throw new Error(k());function k(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function S(k){const I=k instanceof RegExp?(0,xe.regexpCode)(k):c.code.formats?(0,xe._)`${c.code.formats}${(0,xe.getProperty)(o)}`:void 0,z=r.scopeValue("formats",{key:o,ref:k,code:I});return typeof k=="object"&&!(k instanceof RegExp)?[k.type||"string",k.validate,(0,xe._)`${z}.validate`]:["string",k,z]}function T(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!d.$async)throw new Error("async format in sync schema");return(0,xe._)`await ${h}(${n})`}return typeof y=="function"?(0,xe._)`${h}(${n})`:(0,xe._)`${h}.test(${n})`}}}};lc.default=GP;Object.defineProperty(cc,"__esModule",{value:!0});const WP=lc,BP=[WP.default];cc.default=BP;var Ir={};Object.defineProperty(Ir,"__esModule",{value:!0});Ir.contentVocabulary=Ir.metadataVocabulary=void 0;Ir.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Ir.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(Ai,"__esModule",{value:!0});const JP=Mi,QP=xi,YP=Bi,XP=cc,Tl=Ir,e1=[JP.default,QP.default,(0,YP.default)(),XP.default,Tl.metadataVocabulary,Tl.contentVocabulary];Ai.default=e1;var uc={},Vs={};Object.defineProperty(Vs,"__esModule",{value:!0});Vs.DiscrError=void 0;var Rl;(function(e){e.Tag="tag",e.Mapping="mapping"})(Rl||(Vs.DiscrError=Rl={}));Object.defineProperty(uc,"__esModule",{value:!0});const $r=he,Io=Vs,Cl=at,t1=xr,r1=B,n1={message:({params:{discrError:e,tagName:t}})=>e===Io.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,$r._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},s1={keyword:"discriminator",type:"object",schemaType:"object",error:n1,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,$r._)`${r}${(0,$r.getProperty)(i)}`);t.if((0,$r._)`typeof ${l} == "string"`,()=>d(),()=>e.error(!1,{discrError:Io.DiscrError.Tag,tag:l,tagName:i})),e.ok(c);function d(){const g=_();t.if(!1);for(const m in g)t.elseIf((0,$r._)`${l} === ${m}`),t.assign(c,f(g[m]));t.else(),e.error(!1,{discrError:Io.DiscrError.Mapping,tag:l,tagName:i}),t.endIf()}function f(g){const m=t.name("valid"),v=e.subschema({keyword:"oneOf",schemaProp:g},m);return e.mergeEvaluated(v,$r.Name),m}function _(){var g;const m={},v=h(s);let y=!0;for(let T=0;Tthis.addVocabulary(m)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const m=this.opts.$data?this.$dataMetaSchema(o,a):o;this.addMetaSchema(m,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=xs();Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var d=he;Object.defineProperty(t,"_",{enumerable:!0,get:function(){return d._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return d.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return d.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return d.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return d.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return d.CodeGen}});var f=Ii();Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return f.default}});var _=xr;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return _.default}})})(Eo,Eo.exports);var f1=Eo.exports;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;const t=f1,r=he,n=r.operators,s={formatMaximum:{okStr:"<=",ok:n.LTE,fail:n.GT},formatMinimum:{okStr:">=",ok:n.GTE,fail:n.LT},formatExclusiveMaximum:{okStr:"<",ok:n.LT,fail:n.GTE},formatExclusiveMinimum:{okStr:">",ok:n.GT,fail:n.LTE}},o={message:({keyword:i,schemaCode:c})=>(0,r.str)`should be ${s[i].okStr} ${c}`,params:({keyword:i,schemaCode:c})=>(0,r._)`{comparison: ${s[i].okStr}, limit: ${c}}`};e.formatLimitDefinition={keyword:Object.keys(s),type:"string",schemaType:"string",$data:!0,error:o,code(i){const{gen:c,data:l,schemaCode:d,keyword:f,it:_}=i,{opts:g,self:m}=_;if(!g.validateFormats)return;const v=new t.KeywordCxt(_,m.RULES.all.format.definition,"format");v.$data?y():h();function y(){const S=c.scopeValue("formats",{ref:m.formats,code:g.code.formats}),T=c.const("fmt",(0,r._)`${S}[${v.schemaCode}]`);i.fail$data((0,r.or)((0,r._)`typeof ${T} != "object"`,(0,r._)`${T} instanceof RegExp`,(0,r._)`typeof ${T}.compare != "function"`,$(T)))}function h(){const S=v.schema,T=m.formats[S];if(!T||T===!0)return;if(typeof T!="object"||T instanceof RegExp||typeof T.compare!="function")throw new Error(`"${f}": format "${S}" does not define "compare" function`);const k=c.scopeValue("formats",{key:S,ref:T,code:g.code.formats?(0,r._)`${g.code.formats}${(0,r.getProperty)(S)}`:void 0});i.fail$data($(k))}function $(S){return(0,r._)`${S}.compare(${l}, ${d}) ${s[f].fail} 0`}},dependencies:["format"]};const a=i=>(i.addKeyword(e.formatLimitDefinition),i);e.default=a})(tf);(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r=ef,n=tf,s=he,o=new s.Name("fullFormats"),a=new s.Name("fastFormats"),i=(l,d={keywords:!0})=>{if(Array.isArray(d))return c(l,d,r.fullFormats,o),l;const[f,_]=d.mode==="fast"?[r.fastFormats,a]:[r.fullFormats,o],g=d.formats||r.formatNames;return c(l,g,f,_),d.keywords&&(0,n.default)(l),l};i.get=(l,d="full")=>{const _=(d==="fast"?r.fastFormats:r.fullFormats)[l];if(!_)throw new Error(`Unknown format "${l}"`);return _};function c(l,d,f,_){var g,m;(g=(m=l.opts.code).formats)!==null&&g!==void 0||(m.formats=(0,s._)`require("ajv-formats/dist/formats").${_}`);for(const v of d)l.addFormat(v,f[v])}e.exports=t=i,Object.defineProperty(t,"__esModule",{value:!0}),t.default=i})(So,So.exports);var h1=So.exports;const p1=Dl(h1);function m1(){const e=new DS({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return p1(e),e}class g1{constructor(t){this._ajv=t??m1()}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 _1{constructor(t){this._client=t}async*callToolStream(t,r=ir,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 ne(ae.InvalidRequest,`Tool ${t.name} has an output schema but did not return structured content`)};return}if(l.structuredContent)try{const d=i(l.structuredContent);if(!d.valid){yield{type:"error",error:new ne(ae.InvalidParams,`Structured content does not match the tool's output schema: ${d.errorMessage}`)};return}}catch(d){if(d instanceof ne){yield{type:"error",error:d};return}yield{type:"error",error:new ne(ae.InvalidParams,`Failed to validate structured content: ${d instanceof Error?d.message:String(d)}`)};return}}yield c}}async getTask(t,r){return this._client.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._client.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._client.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._client.cancelTask({taskId:t},r)}requestStream(t,r,n){return this._client.requestStream(t,r,n)}}function y1(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 v1(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 ts(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&&ts(o,r[s])}}if(Array.isArray(e.anyOf))for(const r of e.anyOf)typeof r!="boolean"&&ts(r,t);if(Array.isArray(e.oneOf))for(const r of e.oneOf)typeof r!="boolean"&&ts(r,t)}}function $1(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 w1 extends Ju{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 g1,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",Ra,t.tools,async()=>(await this.listTools()).tools),t.prompts&&((o=(s=this._serverCapabilities)==null?void 0:s.prompts)!=null&&o.listChanged)&&this._setupListChangedHandler("prompts",ka,t.prompts,async()=>(await this.listPrompts()).prompts),t.resources&&((i=(a=this._serverCapabilities)==null?void 0:a.resources)!=null&&i.listChanged)&&this._setupListChangedHandler("resources",$a,t.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new _1(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=av(this._capabilities,t)}setRequestHandler(t,r){const n=Wu(t),s=n==null?void 0:n.method;if(!s)throw new Error("Schema is missing a method literal");const o=Bu(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 $,S;const d=Dt(Zu,c);if(!d.success){const T=d.error instanceof Error?d.error.message:String(d.error);throw new ne(ae.InvalidParams,`Invalid elicitation request: ${T}`)}const{params:f}=d.data;f.mode=f.mode??"form";const{supportsFormMode:_,supportsUrlMode:g}=$1(this._capabilities.elicitation);if(f.mode==="form"&&!_)throw new ne(ae.InvalidParams,"Client does not support form-mode elicitation requests");if(f.mode==="url"&&!g)throw new ne(ae.InvalidParams,"Client does not support URL-mode elicitation requests");const m=await Promise.resolve(r(c,l));if(f.task){const T=Dt(un,m);if(!T.success){const k=T.error instanceof Error?T.error.message:String(T.error);throw new ne(ae.InvalidParams,`Invalid task creation result: ${k}`)}return T.data}const v=Dt(Ku,m);if(!v.success){const T=v.error instanceof Error?v.error.message:String(v.error);throw new ne(ae.InvalidParams,`Invalid elicitation result: ${T}`)}const y=v.data,h=f.mode==="form"?f.requestedSchema:void 0;if(f.mode==="form"&&y.action==="accept"&&y.content&&h&&(S=($=this._capabilities.elicitation)==null?void 0:$.form)!=null&&S.applyDefaults)try{ts(h,y.content)}catch{}return y};return super.setRequestHandler(t,i)}if(a==="sampling/createMessage"){const i=async(c,l)=>{const d=Dt(Ca,c);if(!d.success){const y=d.error instanceof Error?d.error.message:String(d.error);throw new ne(ae.InvalidParams,`Invalid sampling request: ${y}`)}const{params:f}=d.data,_=await Promise.resolve(r(c,l));if(f.task){const y=Dt(un,_);if(!y.success){const h=y.error instanceof Error?y.error.message:String(y.error);throw new ne(ae.InvalidParams,`Invalid task creation result: ${h}`)}return y.data}const m=f.tools||f.toolChoice?Hu:Lu,v=Dt(m,_);if(!v.success){const y=v.error instanceof Error?v.error.message:String(v.error);throw new ne(ae.InvalidParams,`Invalid sampling result: ${y}`)}return v.data};return super.setRequestHandler(t,i)}return super.setRequestHandler(t,r)}assertCapability(t,r){var n;if(!((n=this._serverCapabilities)!=null&&n[t]))throw new Error(`Server does not support ${t} (required for ${r})`)}async connect(t,r){if(await super.connect(t),t.sessionId===void 0)try{const n=await this.request({method:"initialize",params:{protocolVersion:Ps,capabilities:this._capabilities,clientInfo:this._clientInfo}},Tu,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!M_.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;y1((n=(r=this._serverCapabilities)==null?void 0:r.tasks)==null?void 0:n.requests,t,"Server")}assertTaskHandlerCapability(t){var r;this._capabilities&&v1((r=this._capabilities.tasks)==null?void 0:r.requests,t,"Client")}async ping(t){return this.request({method:"ping"},wr,t)}async complete(t,r){return this.request({method:"completion/complete",params:t},Gu,r)}async setLoggingLevel(t,r){return this.request({method:"logging/setLevel",params:{level:t}},wr,r)}async getPrompt(t,r){return this.request({method:"prompts/get",params:t},Du,r)}async listPrompts(t,r){return this.request({method:"prompts/list",params:t},wa,r)}async listResources(t,r){return this.request({method:"resources/list",params:t},ga,r)}async listResourceTemplates(t,r){return this.request({method:"resources/templates/list",params:t},_a,r)}async readResource(t,r){return this.request({method:"resources/read",params:t},va,r)}async subscribeResource(t,r){return this.request({method:"resources/subscribe",params:t},wr,r)}async unsubscribeResource(t,r){return this.request({method:"resources/unsubscribe",params:t},wr,r)}async callTool(t,r=ir,n){if(this.isToolTaskRequired(t.name))throw new ne(ae.InvalidRequest,`Tool "${t.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);const s=await this.request({method:"tools/call",params:t},r,n),o=this.getToolOutputValidator(t.name);if(o){if(!s.structuredContent&&!s.isError)throw new ne(ae.InvalidRequest,`Tool ${t.name} has an output schema but did not return structured content`);if(s.structuredContent)try{const a=o(s.structuredContent);if(!a.valid)throw new ne(ae.InvalidParams,`Structured content does not match the tool's output schema: ${a.errorMessage}`)}catch(a){throw a instanceof ne?a:new ne(ae.InvalidParams,`Failed to validate structured content: ${a instanceof Error?a.message:String(a)}`)}}return s}isToolTask(t){var r,n,s,o;return(o=(s=(n=(r=this._serverCapabilities)==null?void 0:r.tasks)==null?void 0:n.requests)==null?void 0:s.tools)!=null&&o.call?this._cachedKnownTaskTools.has(t):!1}isToolTaskRequired(t){return this._cachedRequiredTaskTools.has(t)}cacheToolMetadata(t){var r;this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(const n of t){if(n.outputSchema){const o=this._jsonSchemaValidator.getValidator(n.outputSchema);this._cachedToolOutputValidators.set(n.name,o)}const s=(r=n.execution)==null?void 0:r.taskSupport;(s==="required"||s==="optional")&&this._cachedKnownTaskTools.add(n.name),s==="required"&&this._cachedRequiredTaskTools.add(n.name)}}getToolOutputValidator(t){return this._cachedToolOutputValidators.get(t)}async listTools(t,r){const n=await this.request({method:"tools/list",params:t},Ta,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(t,r,n,s){const o=by.safeParse(n);if(!o.success)throw new Error(`Invalid ${t} listChanged options: ${o.error.message}`);if(typeof n.onChanged!="function")throw new Error(`Invalid ${t} listChanged options: onChanged must be a function`);const{autoRefresh:a,debounceMs:i}=o.data,{onChanged:c}=n,l=async()=>{if(!a){c(null,null);return}try{const f=await s();c(null,f)}catch(f){const _=f instanceof Error?f:new Error(String(f));c(_,null)}},d=()=>{if(i){const f=this._listChangedDebounceTimers.get(t);f&&clearTimeout(f);const _=setTimeout(l,i);this._listChangedDebounceTimers.set(t,_)}else l()};this.setNotificationHandler(r,d)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}var dc={};/*! - * content-type - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - */var Nl=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,b1=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,Nf=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,S1=/\\([\u000b\u0020-\u00ff])/g,E1=/([\\"])/g,If=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;dc.format=k1;dc.parse=P1;function k1(e){if(!e||typeof e!="object")throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!If.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&&!b1.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(E1,"\\$1")+'"'}function C1(e){this.parameters=Object.create(null),this.type=e}function N1(e){if(e)try{return dc.parse(e).type}catch{const t=(e.split(";",1)[0]??"").trim().toLowerCase();return t===""||e.slice(t.length).includes(",")?void 0:t}}function jo(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function I1(e=fetch,t){return t?async(r,n)=>{const s={...t,...n,headers:n!=null&&n.headers?{...jo(t.headers),...jo(n.headers)}:t.headers};return e(r,s)}:e}let fc;fc=globalThis.crypto;async function j1(e){return(await fc).getRandomValues(new Uint8Array(e))}async function O1(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 A1(e),r=await M1(t);return{code_verifier:t,code_challenge:r}}const Ke=Fg().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:O_.custom,message:"URL must be parseable",fatal:!0}),Nh}).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"}),x1=Be({resource:P().url(),authorization_servers:L(Ke).optional(),jwks_uri:P().url().optional(),scopes_supported:L(P()).optional(),bearer_methods_supported:L(P()).optional(),resource_signing_alg_values_supported:L(P()).optional(),resource_name:P().optional(),resource_documentation:P().optional(),resource_policy_uri:P().url().optional(),resource_tos_uri:P().url().optional(),tls_client_certificate_bound_access_tokens:ye().optional(),authorization_details_types_supported:L(P()).optional(),dpop_signing_alg_values_supported:L(P()).optional(),dpop_bound_access_tokens_required:ye().optional()}),jf=Be({issuer:P(),authorization_endpoint:Ke,token_endpoint:Ke,registration_endpoint:Ke.optional(),scopes_supported:L(P()).optional(),response_types_supported:L(P()),response_modes_supported:L(P()).optional(),grant_types_supported:L(P()).optional(),token_endpoint_auth_methods_supported:L(P()).optional(),token_endpoint_auth_signing_alg_values_supported:L(P()).optional(),service_documentation:Ke.optional(),revocation_endpoint:Ke.optional(),revocation_endpoint_auth_methods_supported:L(P()).optional(),revocation_endpoint_auth_signing_alg_values_supported:L(P()).optional(),introspection_endpoint:P().optional(),introspection_endpoint_auth_methods_supported:L(P()).optional(),introspection_endpoint_auth_signing_alg_values_supported:L(P()).optional(),code_challenge_methods_supported:L(P()).optional(),client_id_metadata_document_supported:ye().optional()}),q1=Be({issuer:P(),authorization_endpoint:Ke,token_endpoint:Ke,userinfo_endpoint:Ke.optional(),jwks_uri:Ke,registration_endpoint:Ke.optional(),scopes_supported:L(P()).optional(),response_types_supported:L(P()),response_modes_supported:L(P()).optional(),grant_types_supported:L(P()).optional(),acr_values_supported:L(P()).optional(),subject_types_supported:L(P()),id_token_signing_alg_values_supported:L(P()),id_token_encryption_alg_values_supported:L(P()).optional(),id_token_encryption_enc_values_supported:L(P()).optional(),userinfo_signing_alg_values_supported:L(P()).optional(),userinfo_encryption_alg_values_supported:L(P()).optional(),userinfo_encryption_enc_values_supported:L(P()).optional(),request_object_signing_alg_values_supported:L(P()).optional(),request_object_encryption_alg_values_supported:L(P()).optional(),request_object_encryption_enc_values_supported:L(P()).optional(),token_endpoint_auth_methods_supported:L(P()).optional(),token_endpoint_auth_signing_alg_values_supported:L(P()).optional(),display_values_supported:L(P()).optional(),claim_types_supported:L(P()).optional(),claims_supported:L(P()).optional(),service_documentation:P().optional(),claims_locales_supported:L(P()).optional(),ui_locales_supported:L(P()).optional(),claims_parameter_supported:ye().optional(),request_parameter_supported:ye().optional(),request_uri_parameter_supported:ye().optional(),require_request_uri_registration:ye().optional(),op_policy_uri:Ke.optional(),op_tos_uri:Ke.optional(),client_id_metadata_document_supported:ye().optional()}),D1=M({...q1.shape,...jf.pick({code_challenge_methods_supported:!0}).shape}),U1=M({access_token:P(),id_token:P().optional(),token_type:P(),expires_in:A_().optional(),scope:P().optional(),refresh_token:P().optional()}).strip(),V1=M({error:P(),error_description:P().optional(),error_uri:P().optional()}),Il=Ke.optional().or(j("").transform(()=>{})),F1=M({redirect_uris:L(Ke),token_endpoint_auth_method:P().optional(),grant_types:L(P()).optional(),response_types:L(P()).optional(),client_name:P().optional(),client_uri:Ke.optional(),logo_uri:Il,scope:P().optional(),contacts:L(P()).optional(),tos_uri:Il,policy_uri:P().optional(),jwks_uri:Ke.optional(),jwks:ra().optional(),software_id:P().optional(),software_version:P().optional(),software_statement:P().optional()}).strip(),L1=M({client_id:P(),client_secret:P().optional(),client_id_issued_at:de().optional(),client_secret_expires_at:de().optional()}).strip(),H1=F1.merge(L1);M({error:P(),error_description:P().optional()}).strip();M({token:P(),token_type_hint:P().optional()}).strip();function Z1(e){const t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function K1({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 sT(e,t,r,n){const s=new URL(e),o=(n==null?void 0:n.protocolVersion)??Ps;let a;if(n!=null&&n.metadataUrl)a=new URL(n.metadataUrl);else{const c=rT(t,s.pathname);a=new URL(c,(n==null?void 0:n.metadataServerUrl)??s),a.search=s.search}let i=await Ol(a,o,r);if(!(n!=null&&n.metadataUrl)&&nT(i,s.pathname)){const c=new URL(`/.well-known/${t}`,s);i=await Ol(c,o,r)}return i}function oT(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 Mf(e,{fetchFn:t=fetch,protocolVersion:r=Ps}={}){var o;const n={"MCP-Protocol-Version":r,Accept:"application/json"},s=oT(e);for(const{url:a,type:i}of s){const c=await hc(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"?jf.parse(await c.json()):D1.parse(await c.json())}}}async function aT(e,t){let r,n;try{r=await Af(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 Mf(n,{fetchFn:t==null?void 0:t.fetchFn});return{authorizationServerUrl:n,authorizationServerMetadata:s,resourceMetadata:r}}async function iT(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(to))throw new Error(`Incompatible auth server: does not support response type ${to}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(ro))throw new Error(`Incompatible auth server: does not support code challenge method ${ro}`)}else i=new URL("/authorize",e);const c=await z1(),l=c.code_verifier,d=c.code_challenge;return i.searchParams.set("response_type",to),i.searchParams.set("client_id",r.client_id),i.searchParams.set("code_challenge",d),i.searchParams.set("code_challenge_method",ro),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 cT(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}async function zf(e,{metadata:t,tokenRequestParams:r,clientInformation:n,addClientAuthentication:s,resource:o,fetchFn:a}){const i=t!=null&&t.token_endpoint?new URL(t.token_endpoint):new URL("/token",e),c=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(o&&r.set("resource",o.href),s)await s(c,r,i,t);else if(n){const d=(t==null?void 0:t.token_endpoint_auth_methods_supported)??[],f=B1(n,d);J1(f,n,c,r)}const l=await(a??fetch)(i,{method:"POST",headers:c,body:r});if(!l.ok)throw await Of(l);return U1.parse(await l.json())}async function lT(e,{metadata:t,clientInformation:r,refreshToken:n,resource:s,addClientAuthentication:o,fetchFn:a}){const i=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),c=await zf(e,{metadata:t,tokenRequestParams:i,clientInformation:r,addClientAuthentication:o,resource:s,fetchFn:a});return{refresh_token:n,...c}}async function uT(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=cT(s,l,e.redirectUrl)}const c=await e.clientInformation();return zf(t,{metadata:r,tokenRequestParams:i,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:n,fetchFn:o})}async function dT(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 Of(a);return H1.parse(await a.json())}class oo 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 Al=10,fT=13,Xt=32;function ao(e){}function hT(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=ao,onError:r=ao,onRetry:n=ao,onComment:s,maxBufferSize:o}=e,a=[];let i=0,c=!0,l,d="",f=0,_,g=!1;function m(k){if(g)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,k.charCodeAt(0)===239&&k.charCodeAt(1)===187&&k.charCodeAt(2)===191&&(k=k.slice(3))),a.length===0){const F=y(k);F!==""&&(a.push(F),i=F.length),v();return}if(k.indexOf(` -`)===-1&&k.indexOf("\r")===-1){a.push(k),i+=k.length,v();return}a.push(k);const I=a.join("");a.length=0,i=0;const z=y(I);z!==""&&(a.push(z),i=z.length),v()}function v(){o!==void 0&&(i+d.length<=o||(g=!0,a.length=0,i=0,l=void 0,d="",f=0,_=void 0,r(new oo(`Buffered data exceeded max buffer size of ${o} characters`,{type:"max-buffer-size-exceeded"}))))}function y(k){let I=0;if(k.indexOf("\r")===-1){let z=k.indexOf(` -`,I);for(;z!==-1;){if(I===z){f>0&&t({id:l,event:_,data:d}),l=void 0,d="",f=0,_=void 0,I=z+1,z=k.indexOf(` -`,I);continue}const F=k.charCodeAt(I);if(Ml(k,I,F)){const G=k.charCodeAt(I+5)===Xt?I+6:I+5,Z=k.slice(G,z);if(f===0&&k.charCodeAt(z+1)===Al){t({id:l,event:_,data:Z}),l=void 0,d="",_=void 0,I=z+2,z=k.indexOf(` -`,I);continue}d=f===0?Z:`${d} -${Z}`,f++}else zl(k,I,F)?_=k.slice(k.charCodeAt(I+6)===Xt?I+7:I+6,z)||void 0:h(k,I,z);I=z+1,z=k.indexOf(` -`,I)}return k.slice(I)}for(;I20?`${k.slice(0,20)}…`:k}"`,{type:"unknown-field",field:k,value:I,line:z}));break}}function S(){f>0&&t({id:l,event:_,data:d}),l=void 0,d="",f=0,_=void 0}function T(k={}){if(k.consume&&a.length>0){const I=a.join("");h(I,0,I.length)}c=!0,l=void 0,d="",f=0,_=void 0,a.length=0,i=0,g=!1}return{feed:m,reset:T}}function Ml(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 zl(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 pT extends TransformStream{constructor({onError:t,onRetry:r,onComment:n,maxBufferSize:s}={}){let o;super({start(a){o=hT({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 mT={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class yr extends Error{constructor(t,r){super(`Streamable HTTP error: ${r}`),this.code=t}}class gT{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=I1(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)??mT}async _authThenStart(){var r;if(!this._authProvider)throw new _r("No auth provider");let t;try{t=await Hn(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(n){throw(r=this.onerror)==null||r.call(this,n),n}if(t!=="AUTHORIZED")throw new _r;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var n;const t={};if(this._authProvider){const s=await this._authProvider.tokens();s&&(t.Authorization=`Bearer ${s.access_token}`)}this._sessionId&&(t["mcp-session-id"]=this._sessionId),this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);const r=jo((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 yr(i.status,`Failed to open SSE stream: ${i.statusText}`)}this._handleSseStream(i.body,t,!0)}catch(a){throw(o=this.onerror)==null||o.call(this,a),a}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const r=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,s=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(n,t),s)}_scheduleReconnection(t,r=0){var o;const n=this._reconnectionOptions.maxRetries;if(r>=n){(o=this.onerror)==null||o.call(this,new Error(`Maximum reconnection attempts (${n}) exceeded.`));return}const s=this._getNextReconnectionDelay(r);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(a=>{var i;(i=this.onerror)==null||i.call(this,new Error(`Failed to reconnect SSE stream: ${a instanceof Error?a.message:String(a)}`)),this._scheduleReconnection(t,r+1)})},s)}_handleSseStream(t,r,n){if(!t)return;const{onresumptiontoken:s,replayMessageId:o}=r;let a,i=!1,c=!1;(async()=>{var d,f,_,g;try{const m=t.pipeThrough(new TextDecoderStream).pipeThrough(new pT({onRetry:h=>{this._serverRetryMs=h}})).getReader();for(;;){const{value:h,done:$}=await m.read();if($)break;if(h.id&&(a=h.id,i=!0,s==null||s(h.id)),!!h.data&&(!h.event||h.event==="message"))try{const S=Zn.parse(JSON.parse(h.data));Gr(S)&&(c=!0,o!==void 0&&(S.id=o)),(d=this.onmessage)==null||d.call(this,S)}catch(S){(f=this.onerror)==null||f.call(this,S)}}(n||i)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:a,onresumptiontoken:s,replayMessageId:o},0)}catch(m){if((_=this.onerror)==null||_.call(this,new Error(`SSE stream disconnected: ${m}`)),(n||i)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:a,onresumptiontoken:s,replayMessageId:o},0)}catch(h){(g=this.onerror)==null||g.call(this,new Error(`Failed to reconnect: ${h instanceof Error?h.message:String(h)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(t){if(!this._authProvider)throw new _r("No auth provider");if(await Hn(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new _r("Failed to authorize")}async close(){var t,r;this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),(t=this._abortController)==null||t.abort(),(r=this.onclose)==null||r.call(this)}async send(t,r){var n,s,o,a,i,c;try{const{resumptionToken:l,onresumptiontoken:d}=r||{};if(l){this._startOrAuthSse({resumptionToken:l,replayMessageId:po(t)?t.id:void 0}).catch(S=>{var T;return(T=this.onerror)==null?void 0:T.call(this,S)});return}const f=await this._commonHeaders();f.set("content-type","application/json"),f.set("accept","application/json, text/event-stream");const _={...this._requestInit,method:"POST",headers:f,body:JSON.stringify(t),signal:(n=this._abortController)==null?void 0:n.signal},g=await(this._fetch??fetch)(this._url,_),m=g.headers.get("mcp-session-id");if(m&&(this._sessionId=m),!g.ok){const S=await g.text().catch(()=>null);if(g.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new yr(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:T,scope:k}=jl(g);if(this._resourceMetadataUrl=T,this._scope=k,await Hn(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new _r;return this._hasCompletedAuthFlow=!0,this.send(t)}if(g.status===403&&this._authProvider){const{resourceMetadataUrl:T,scope:k,error:I}=jl(g);if(I==="insufficient_scope"){const z=g.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===z)throw new yr(403,"Server returned 403 after trying upscoping");if(k&&(this._scope=k),T&&(this._resourceMetadataUrl=T),this._lastUpscopingHeader=z??void 0,await Hn(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new _r;return this.send(t)}}throw new yr(g.status,`Error POSTing to endpoint: ${S}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,g.status===202){await((s=g.body)==null?void 0:s.cancel()),Q_(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(S=>{var T;return(T=this.onerror)==null?void 0:T.call(this,S)});return}const y=(Array.isArray(t)?t:[t]).filter(S=>"method"in S&&"id"in S&&S.id!==void 0).length>0,h=g.headers.get("content-type"),$=N1(h);if(y)if($==="text/event-stream")this._handleSseStream(g.body,{onresumptiontoken:d},!1);else if($==="application/json"){const S=await g.json(),T=Array.isArray(S)?S.map(k=>Zn.parse(k)):[Zn.parse(S)];for(const k of T)(o=this.onmessage)==null||o.call(this,k)}else throw await((a=g.body)==null?void 0:a.cancel()),new yr(-1,`Unexpected content type: ${h}`);else await((i=g.body)==null?void 0:i.cancel())}catch(l){throw(c=this.onerror)==null||c.call(this,l),l}}get sessionId(){return this._sessionId}async terminateSession(){var t,r,n;if(this._sessionId)try{const s=await this._commonHeaders(),o={...this._requestInit,method:"DELETE",headers:s,signal:(t=this._abortController)==null?void 0:t.signal},a=await(this._fetch??fetch)(this._url,o);if(await((r=a.body)==null?void 0:r.cancel()),!a.ok&&a.status!==405)throw new yr(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 _T="https://mcp.excalidraw.com/mcp",yT="mcp.excalidraw.com",vT="/api/v1/chat/mcp-apps/excalidraw",xf="ui://excalidraw/mcp-app.html",$T=["read_me","create_view"],qf=new Set(["export_to_excalidraw","save_checkpoint","read_checkpoint"]),wT=256*1024,bT=1024*1024,ST={excalidraw:{id:"excalidraw",endpoint:_T,hostname:yT,resourceUri:xf,modelTools:$T,appTools:qf}};function ET(e){return ST[e]}function kT(){return new URL(Lf(vT),window.location.origin)}class PT{constructor(){fe(this,"client",new w1({name:"pwc-chat-mcp-app-host",version:"1"}));fe(this,"transport",new gT(kT(),{requestInit:{credentials:"include"}}));fe(this,"connected");fe(this,"bytes",0)}connect(){return this.connected??(this.connected=this.client.connect(this.transport)),this.connected}async readResource(t){if(t!==xf)throw new Error("Unapproved App resource");await this.connect();const n=(await this.client.readResource({uri:t})).contents[0];if(!n||!("text"in n)||typeof n.text!="string"||n.mimeType!=="text/html;profile=mcp-app")throw new Error("Incompatible App resource");this.consume(n.text,1024*1024);const s=await RT(n.text);return{text:n.text,digest:s}}async callTool(t,r){if(!qf.has(t))throw new Error("Unapproved App tool");const n=JSON.stringify(r);this.consume(n),await this.connect();const s=await this.client.callTool({name:t,arguments:r});return this.consume(JSON.stringify(s)),s}close(){this.transport.close()}consume(t,r=wT){const n=new TextEncoder().encode(t).byteLength;if(n>r||this.bytes+n>bT)throw new Error("App request exceeds host limit");this.bytes+=n}}let xl;function TT(){return xl??(xl=new PT),xl}async function RT(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("")}const ql=e=>Math.max(240,Math.min(720,e)),CT=({block:e})=>{const t=se.useRef(null),r=se.useRef(null),n=se.useRef(!1),s=se.useRef(e),o=se.useRef(e.status);s.current=e,o.current=e.status;const[a,i]=se.useState(),[c,l]=se.useState(e.status),[d,f]=se.useState(ql(e.height)),[_,g]=se.useState(!1),[m,v]=se.useState(0),y=se.useRef(null),h=e.input.elements,$=!!e.permissions.clipboardWrite,S=se.useCallback(()=>{g(!1),document.fullscreenElement&&document.exitFullscreen()},[]),T=se.useCallback(()=>{var I,z;if(_){S();return}g(!0),(z=(I=y.current)==null?void 0:I.requestFullscreen)==null||z.call(I).catch(()=>{})},[S,_]);se.useEffect(()=>{if(!_)return;const I=y.current,z=G=>{G.key==="Escape"&&(document.fullscreenElement||S())},F=()=>{document.fullscreenElement||g(!1)};return window.addEventListener("keydown",z),document.addEventListener("fullscreenchange",F),()=>{window.removeEventListener("keydown",z),document.removeEventListener("fullscreenchange",F),document.fullscreenElement===I&&document.exitFullscreen()}},[S,_]),se.useEffect(()=>{ET(e.provider);{l("unavailable");return}},[m,e.provider,e.resource_uri]),se.useEffect(()=>{if(!a||!t.current||c!=="ready")return;const I=t.current,z=new Cv(null,{name:"Papers with Code",version:"1"},{serverTools:{},openLinks:{},logging:{},...$?{clipboard:{write:{}}}:{}},{hostContext:{theme:document.documentElement.dataset.theme==="dark"?"dark":"light",displayMode:_?"fullscreen":"inline"}});return z.oncalltool=async({name:F,arguments:G})=>{if(s.current.public_fork&&F!=="export_to_excalidraw")throw new Error("Shared diagrams cannot mutate owner state");return TT().callTool(F,G??{})},z.onopenlink=async({url:F})=>{const G=new URL(F);if(G.protocol!=="https:"||G.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(G.href,"_blank","noopener,noreferrer"),{}},z.onsizechange=({height:F})=>{typeof F=="number"&&f(ql(F))},z.oninitialized=()=>{n.current=!0;try{const F=JSON.parse(h);z.sendToolInput({arguments:{elements:Array.isArray(F)?zv(F):F}}),z.sendToolResult(s.current.result)}catch{l("error")}},r.current=z,z.connect(new Tv(I.contentWindow??void 0,I.contentWindow)).catch(()=>l("error")),()=>{n.current=!1,z.teardownResource({}).catch(()=>{}),r.current===z&&(r.current=null)}},[a,c,_,h,$]),se.useEffect(()=>{var I;c!=="ready"||!n.current||(I=r.current)==null||I.sendToolResult(e.result).catch(()=>{})},[e.result,c]);const k=c==="unavailable"||c==="incompatible"||c==="error";return R.jsxs("section",{ref:y,className:`chat-mcp-app${_?" chat-mcp-app-fullscreen":""}`,"aria-label":"Interactive Excalidraw diagram",children:[R.jsx("header",{children:R.jsx("button",{type:"button",onClick:T,children:_?"Exit fullscreen":"Fullscreen"})}),c==="loading"&&R.jsx("div",{className:"chat-mcp-loading",role:"status",children:"Loading interactive diagram…"}),k&&R.jsxs("div",{className:"chat-mcp-error",children:["Interactive diagram unavailable. The cited text answer is still available.",R.jsx("button",{type:"button",onClick:()=>v(I=>I+1),children:"Retry diagram"})]}),a&&c==="ready"&&R.jsx("iframe",{ref:t,title:"Interactive Excalidraw diagram",sandbox:"allow-scripts",allow:$?"clipboard-write":void 0,srcDoc:a,style:{height:d}})]})};function NT(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 IT(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 jT(e,t=240){const r=e.content.trim();return r.length<=t?r:`${r.slice(0,t).trimEnd()}…`}const OT="https://huggingface.co/pro",AT="https://huggingface.co/docs/inference-providers/pricing",MT="https://paperswithcode.co/chat",Df=()=>R.jsx("span",{className:"chat-caret"}),zT=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},xT=e=>{var g,m;const t=e.currentTarget,r=t.ownerDocument,n=(g=r.caretPositionFromPoint)==null?void 0:g.call(r,e.clientX,e.clientY),s=n?null:(m=r.caretRangeFromPoint)==null?void 0:m.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(R.jsxs("span",{className:"chat-inline-paper-mention",children:[R.jsx(ah,{size:13,"aria-hidden":"true"}),R.jsx(Hl,{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)),R.jsx(R.Fragment,{children:r})},DT=({block:e,papers:t,citations:r,webCitations:n,onToggle:s})=>e.active?R.jsxs("div",{className:"chat-reason-live",children:[R.jsxs("div",{className:"chat-reason-live-head",children:[R.jsx(Zo,{})," ",R.jsx("span",{children:"Thinking…"})]}),R.jsxs("div",{className:"chat-reason-live-body chat-answer chat-reason-markdown",children:[R.jsx(io,{text:e.text,streaming:!0,papers:t,citations:r,webCitations:n}),R.jsx(Df,{})]})]}):R.jsxs("div",{className:"chat-reason-done",children:[R.jsxs("button",{type:"button",className:"chat-reason-done-head",onClick:s,"aria-expanded":e.open,children:[R.jsx(Jf,{}),R.jsx("span",{children:"Thought for a few seconds"}),R.jsx(Ll,{open:e.open})]}),e.open&&R.jsx("div",{className:"chat-reason-done-body chat-answer chat-reason-markdown",children:R.jsx(io,{text:e.text,papers:t,citations:r,webCitations:n})})]}),UT=({block:e,papers:t,onToggle:r})=>{var d,f,_,g;const n=e.status==="running",s=e.schema_version===2||!!e.content,o=e.status==="error"||e.status==="denied",a=typeof e.args.query=="string"?e.args.query:"",i=typeof e.args.command=="string"?e.args.command:typeof e.args.file_path=="string"?e.args.file_path:a,c=((d=e.content)==null?void 0:d.map(m=>m.text).join(""))??"",l=n?"running…":s?`${e.status} · ${e.took_ms??0} ms`:`${e.hits} results · ${e.took_ms} ms`;return R.jsxs("div",{className:`chat-tool${n?" chat-tool-running":""}${o?" chat-tool-failed":""}`,children:[R.jsxs("button",{type:"button",className:"chat-tool-head",onClick:r,disabled:n,"aria-expanded":n?void 0:e.open,children:[R.jsxs("span",{className:"chat-tool-head-left",children:[n?R.jsx(Zo,{}):R.jsx(Qf,{}),R.jsx("code",{className:"chat-tool-name",children:e.name}),R.jsx("span",{className:"chat-tool-query",children:s?i:`("${a}")`})]}),R.jsxs("span",{className:"chat-tool-head-right",children:[R.jsx("span",{className:"chat-tool-status",children:l}),!n&&R.jsx(Ll,{open:e.open})]})]}),!n&&e.open&&R.jsxs("div",{className:"chat-tool-body",children:[R.jsxs("div",{className:"chat-tool-args",children:[R.jsx("span",{className:"chat-tool-label",children:"arguments"}),R.jsx("pre",{children:JSON.stringify(e.args,null,2)})]}),s?R.jsxs(R.Fragment,{children:[R.jsxs("div",{className:"chat-tool-output-head",children:[R.jsx("span",{className:"chat-tool-label",children:"result"}),R.jsx("button",{type:"button",className:"chat-tool-copy",onClick:()=>void navigator.clipboard.writeText(c),children:"Copy"})]}),R.jsx("pre",{className:"chat-tool-output",children:R.jsx("code",{children:c})}),((f=e.metadata)==null?void 0:f.output_truncated)&&R.jsx("div",{className:"chat-tool-truncated",children:"Output was truncated."})]}):R.jsxs(R.Fragment,{children:[R.jsxs("div",{className:"chat-tool-label chat-tool-results-label",children:["returned ",((_=e.results)==null?void 0:_.length)??0," papers"]}),R.jsx("ol",{className:"chat-tool-results",children:(g=e.results)==null?void 0:g.map(m=>R.jsxs("li",{className:"chat-hit",children:[R.jsx("div",{className:"chat-hit-top",children:R.jsx(Zl,{routeId:m.route_id,paper:t[m.route_id],className:"chat-hit-title",children:m.title})}),R.jsx("div",{className:"chat-hit-meta",children:[NT(m.metadata),IT(m.metadata)].filter(Boolean).join(" · ")}),R.jsxs("div",{className:"chat-hit-snippet",children:[jT(m),m.content_truncated&&R.jsx("span",{className:"chat-hit-truncated",children:" (truncated)"})]})]},m.route_id))})]})]})]})},VT=({block:e,papers:t,citations:r,webCitations:n,streaming:s})=>R.jsxs("div",{className:"chat-answer",children:[R.jsx(io,{text:e.text,streaming:s,papers:t,citations:r,webCitations:n}),s&&!!e.text.trim()&&R.jsx(Df,{})]}),FT=({block:e})=>R.jsx(CT,{block:e}),Uf=e=>{const t=se.useRef(null),r=se.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 se.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}},LT=({id:e,text:t,paperSelection:r,editNotice:n,onCancel:s,onResend:o,onResendDraft:a})=>{const[i,c]=se.useState(t),[l,d]=se.useState(r),[f,_]=se.useState(!1),{textareaRef:g,resize:m}=Uf(t);se.useLayoutEffect(m,[m,i]);const v=!!i.trim()&&i.length<=8e3,y=()=>{if(!v||f)return;_(!0),((a==null?void 0:a({text:i,paperMentions:[],...l?{paperSelection:l}:{}}))??(o==null?void 0:o(i))??!1)||_(!1)};return R.jsx("div",{className:"chat-msg chat-msg-user chat-msg-user-editing","data-message-id":e,children:R.jsxs("div",{className:"chat-inline-editor",children:[l&&R.jsx(bs,{selection:l,editable:!0,onRemove:()=>d(void 0)}),R.jsx("textarea",{ref:g,className:"chat-inline-editor-textarea","aria-label":"Edit message",value:i,maxLength:8e3,onChange:h=>c(h.target.value),onKeyDown:h=>{h.key==="Escape"?(h.preventDefault(),s==null||s()):h.key==="Enter"&&!h.shiftKey&&!h.nativeEvent.isComposing&&(h.preventDefault(),y())}}),n&&R.jsx("div",{className:"chat-inline-editor-notice",children:n}),R.jsxs("div",{className:"chat-inline-editor-actions",children:[R.jsx("button",{type:"button",onClick:s,children:"Cancel"}),R.jsx("button",{type:"button",className:"chat-inline-editor-send",disabled:!v||f,onClick:y,children:"Send"})]})]})})},HT=({id:e,text:t,paperMentions:r,paperSelection:n,enabled:s,editNotice:o,onCancel:a,onResend:i,onResendDraft:c})=>{const[l,d]=se.useState({text:t,paperMentions:r,...n?{paperSelection:n}:{}}),[f,_]=se.useState(!1),[g,m]=se.useState(0),{textareaRef:v,resize:y}=Uf(t),h=Ul({draft:l,onChange:d,enabled:s,textareaRef:v});se.useLayoutEffect(y,[y,l.text]);const $=!!l.text.trim()&&l.text.length<=8e3&&(s||l.paperMentions.length===0),S=()=>{if(!$||f)return;_(!0),((c==null?void 0:c(l))??(i==null?void 0:i(l.text))??!1)||_(!1)};return R.jsx("div",{className:"chat-msg chat-msg-user chat-msg-user-editing","data-message-id":e,children:R.jsxs("div",{className:"chat-inline-editor",children:[l.paperSelection&&R.jsx(bs,{selection:l.paperSelection,editable:!0,onRemove:()=>d({text:l.text,paperMentions:l.paperMentions})}),R.jsxs("div",{className:"chat-inline-editor-textarea-wrap",children:[R.jsx(Vl,{text:l.text,mentions:l.paperMentions,scrollTop:g,variant:"editor"}),R.jsx("textarea",{ref:v,className:"chat-inline-editor-textarea","aria-label":"Edit message",value:l.text,maxLength:8e3,role:"combobox","aria-autocomplete":"list","aria-expanded":h.open,"aria-controls":h.open?h.pickerId:void 0,"aria-activedescendant":h.open&&h.results.length?`${h.optionIdPrefix}-${h.activeIndex}`:void 0,onChange:T=>h.updateText(T.target.value,T.target.selectionStart),onSelect:T=>h.refresh(T.currentTarget.selectionStart),onScroll:T=>m(T.currentTarget.scrollTop),onKeyDown:T=>{h.keyDown(T)||(T.key==="Escape"?(T.preventDefault(),a==null||a()):T.key==="Enter"&&!T.shiftKey&&!T.nativeEvent.isComposing&&(T.preventDefault(),S()))}}),R.jsx(Fl,{open:h.open,query:h.query,results:h.results,activeIndex:h.activeIndex,loading:h.loading,error:h.error,onSelect:h.select,id:h.pickerId,optionIdPrefix:h.optionIdPrefix})]}),!s&&l.paperMentions.length>0&&R.jsx("div",{className:"chat-inline-editor-notice",role:"status",children:"Paper mentions are currently disabled. Remove them before sending."}),o&&R.jsx("div",{className:"chat-inline-editor-notice",children:o}),R.jsxs("div",{className:"chat-inline-editor-actions",children:[R.jsx("button",{type:"button",onClick:a,children:"Cancel"}),R.jsx("button",{type:"button",className:"chat-inline-editor-send",disabled:!$||f,onClick:S,children:"Send"})]})]})})},aR=({id:e,text:t,paperMentions:r=[],paperSelection:n,paperMentionsEnabled:s=!1,editingAllowed:o=!1,editing:a=!1,editNotice:i,onEdit:c,onCancel:l,onResend:d,onResendDraft:f})=>{const[_,g]=se.useState(!1),m=se.useRef(null);se.useEffect(()=>()=>{m.current!==null&&window.clearTimeout(m.current)},[]);const v=async()=>{var y;if((y=navigator.clipboard)!=null&&y.writeText)try{await navigator.clipboard.writeText(t),g(!0),m.current!==null&&window.clearTimeout(m.current),m.current=window.setTimeout(()=>g(!1),1500)}catch{}};return a?!s&&r.length===0?R.jsx(LT,{id:e,text:t,paperSelection:n,editNotice:i,onCancel:l,onResend:d,onResendDraft:f}):R.jsx(HT,{id:e,text:t,paperMentions:r,paperSelection:n,enabled:s,editNotice:i,onCancel:l,onResend:d,onResendDraft:f}):R.jsx("div",{className:"chat-msg chat-msg-user","data-message-id":e,children:R.jsxs("div",{className:"chat-user-message-wrap",children:[n&&R.jsx(bs,{selection:n}),R.jsx("div",{className:"chat-bubble",onDoubleClick:xT,children:R.jsx(qT,{text:t,mentions:r})}),R.jsxs("div",{className:"chat-user-actions",children:[R.jsx("button",{type:"button",className:"chat-user-action","aria-label":_?"Message copied":"Copy message",title:_?"Copied":"Copy",onClick:()=>void v(),children:_?R.jsx(Hf,{"aria-hidden":"true"}):R.jsx(ih,{"aria-hidden":"true"})}),o&&R.jsx("button",{type:"button",className:"chat-user-action","aria-label":"Edit message",title:"Edit",onClick:c,children:R.jsx(ch,{"aria-hidden":"true"})})]})]})})},iR=({msg:e,papers:t,onToggleBlock:r,onArchiveOldChats:n,onArchiveOldestChats:s,archivePending:o=null,hfBilling:a=null,openRouterFallbackEnabled:i=!1,feedbackEnabled:c=!1})=>{var z,F,G;const[l,d]=se.useState(null),[f,_]=se.useState(!1),[g,m]=se.useState(!1),[v,y]=se.useState(!1),[h,$]=se.useState(""),S=se.useRef(null),T=`chat-feedback-panel-${e.id}`,k=c&&!e.streaming&&!e.error&&!!((z=e.blocks)!=null&&z.some(Z=>Z.kind==="answer"&&Z.text.trim()));se.useEffect(()=>{var Z;v&&((Z=S.current)==null||Z.focus())},[v]);const I=async(Z,K)=>{if(!f){_(!0),m(!1);try{K===void 0?await pc.reportFeedback(e.id,Z):await pc.reportFeedback(e.id,Z,K),d(Z),y(!1),$("")}catch{m(!0)}finally{_(!1)}}};return R.jsx("div",{className:"chat-msg chat-msg-assistant",children:R.jsxs("div",{className:"chat-msg-blocks",children:[(F=e.blocks)==null?void 0:F.map((Z,K)=>{var ke;const Q=`${e.id}-${K}`,re="citations"in Z&&Z.citations!==void 0?Z.citations:e.citations??[],V=Object.fromEntries(re.filter($e=>($e.kind??"paper")==="paper"&&$e.route_id).map($e=>[$e.route_id,$e])),ie=Object.fromEntries(re.filter($e=>$e.kind==="web"&&$e.url).map($e=>[$e.url,$e]));return Z.kind==="reasoning"?R.jsx(DT,{block:Z,papers:t,citations:V,webCitations:ie,onToggle:()=>r(e.id,K)},Q):Z.kind==="tool"?R.jsx(UT,{block:Z,papers:t,onToggle:()=>r(e.id,K)},Q):Z.kind==="app"?R.jsx(FT,{block:Z},Q):R.jsx(VT,{block:Z,papers:t,citations:V,webCitations:ie,streaming:!!(e.streaming&&K===(((ke=e.blocks)==null?void 0:ke.length)??0)-1)},Q)}),zT(e)&&R.jsx("div",{className:"chat-waiting",role:"status","aria-live":"polite",children:R.jsx("span",{className:"chat-thinking",children:(((G=e.blocks)==null?void 0:G.length)??0)===0?e.status??"Thinking…":"Thinking…"})}),e.error&&R.jsxs("div",{className:"chat-error",children:[R.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??"")&&R.jsx("a",{href:"/settings",children:"Re-sign in with Hugging Face"}),e.errorCode==="hf_inference_billing_exhausted"&&R.jsxs(R.Fragment,{children:[(a==null?void 0:a.account_type)==="Free"&&!a.bill_to?R.jsx("a",{href:OT,target:"_blank",rel:"noreferrer",children:"Upgrade to Hugging Face PRO — $9/month for 20× more included credits"}):R.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"}),R.jsx("a",{href:AT,target:"_blank",rel:"noreferrer",children:"Inference Providers pricing and billing details"})]}),e.errorCode==="openrouter_monthly_budget_exhausted"&&R.jsxs(R.Fragment,{children:[i?R.jsx("span",{children:"This response started on the shared allowance. Your connected OpenRouter key will be used when you explicitly retry."}):R.jsx("a",{href:"/settings#openrouter-byok",children:"Connect your own OpenRouter key"}),R.jsx("span",{children:"Or select a Hugging Face-backed model and explicitly retry."})]}),e.errorCode==="openrouter_staging_funding_disabled"&&R.jsx("a",{href:MT,children:"Continue on paperswithcode.co"}),e.errorCode==="openrouter_unavailable"&&R.jsxs(R.Fragment,{children:[R.jsx("a",{href:"/settings#openrouter-byok",children:"Bring your own key in Settings"}),R.jsx("a",{href:"https://github.com/huggingface/paperswithcode-feedback",target:"_blank",rel:"noreferrer",children:"File an issue"})]}),e.errorCode==="openrouter_byok_billing_error"&&R.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??"")&&R.jsx("a",{href:"/settings#openrouter-byok",children:"Review OpenRouter settings"}),e.errorCode==="chat_session_quota_exceeded"&&(n||s)&&R.jsxs("span",{className:"chat-error-actions",children:[n&&R.jsx("button",{type:"button",disabled:o!==null,onClick:n,children:o==="old"?"Archiving…":"Archive chats older than 30 days"}),s&&R.jsx("button",{type:"button",disabled:o!==null,onClick:s,children:o==="oldest"?"Archiving…":"Archive oldest 50 chats"})]})]}),!e.streaming&&e.finishReason&&e.finishReason!=="success"&&R.jsx("div",{className:"chat-finish-note",children:["tool_limit","max_turns"].includes(e.finishReason)?"The assistant stopped at the execution limit.":`The assistant stopped early (${e.finishReason.replace(/_/g," ")}).`}),k&&R.jsxs("div",{className:"chat-feedback","aria-label":"Rate this response",children:[R.jsx("span",{className:"chat-feedback-label",children:l===null?"Was this helpful?":"Thanks for your feedback"}),R.jsx("button",{type:"button",className:`chat-feedback-action${l===!0?" chat-feedback-action-selected":""}`,"aria-label":"Helpful response","aria-pressed":l===!0,disabled:f,onClick:()=>{y(!1),I(!0)},children:R.jsx(uh,{"aria-hidden":"true"})}),R.jsx("button",{type:"button",className:`chat-feedback-action${l===!1?" chat-feedback-action-selected":""}`,"aria-label":"Unhelpful response","aria-pressed":l===!1,"aria-expanded":v,"aria-controls":T,disabled:f,onClick:()=>{m(!1),y(!0)},children:R.jsx(lh,{"aria-hidden":"true"})}),g&&R.jsx("span",{className:"chat-feedback-error",role:"status",children:"Couldn’t send feedback."})]}),k&&v&&R.jsxs("div",{className:"chat-feedback-panel",id:T,role:"group","aria-labelledby":`${T}-title`,children:[R.jsx("div",{className:"chat-feedback-panel-title",id:`${T}-title`,children:"Additional feedback"}),R.jsx("label",{className:"chat-feedback-panel-label",htmlFor:`${T}-comment`,children:"Tell us what went wrong (optional)"}),R.jsx("textarea",{ref:S,id:`${T}-comment`,className:"chat-feedback-comment",value:h,maxLength:500,rows:4,disabled:f,onChange:Z=>$(Z.target.value),onKeyDown:Z=>{Z.key==="Escape"&&(Z.preventDefault(),y(!1))}}),R.jsxs("div",{className:"chat-feedback-panel-actions",children:[R.jsx("button",{type:"button",className:"chat-feedback-skip",disabled:f,onClick:()=>void I(!1),children:"Skip"}),R.jsx("button",{type:"button",className:"chat-feedback-submit",disabled:f,onClick:()=>void I(!1,h.trim()||void 0),children:f?"Submitting…":"Submit"})]})]})]})})};export{iR as A,nR as C,aR as U};