diff --git "a/assets/ChatMessage-BaFFSdNJ.js" "b/assets/ChatMessage-BaFFSdNJ.js" new file mode 100644--- /dev/null +++ "b/assets/ChatMessage-BaFFSdNJ.js" @@ -0,0 +1,111 @@ +var Uf=Object.defineProperty;var Vf=(e,t,r)=>t in e?Uf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var de=(e,t,r)=>Vf(e,typeof t!="symbol"?t+"":t,r);import{d as $s,r as Et,j as T,z as fe,N as Dl,E as Lf,C as Ff}from"./index-MA8q2nlA.js";import{u as Ul,a as Vl,b as Ll,M as Hf,R as Zf,W as Kf,d as Ho,A as Gf,n as Wf,K as Bf,L as Fl,N as Jf}from"./chatSessions-D_sNgvSb.js";import"./katex.min-BSBacQyE.js";import{H as Zo,a as Ko,b as Go}from"./hover-card-B4S8D8FD.js";import{u as Qf}from"./useQuery-mChEV-vu.js";import{f as Yf,p as Xf}from"./github-DFYCOqlD.js";import{G as Wo}from"./github-h_56TTrc.js";import{r as eh,a as th,P as Hl}from"./PaperPreviewLink-vBcaUsk6.js";import{M as rh,r as nh,d as sh}from"./index-_H3THhBP.js";import{c as hc}from"./chat-CUByejEK.js";import{F as oh}from"./file-text-G0H7paxw.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 ah=$s("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 ih=$s("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 ch=$s("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 lh=$s("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 ws({selection:e,editable:t=!1,onRemove:r}){const n=Et.useId(),s=Et.useRef(null),[o,a]=Et.useState(!1),[i,c]=Et.useState(!1),l=`Selection · Page ${e.page}`;return Et.useEffect(()=>{const d=s.current;!d||o||c(d.scrollHeight>d.clientHeight+1)},[o,e.text]),T.jsxs("div",{className:`chat-paper-selection${t?" is-editable":""}`,children:[T.jsxs("div",{className:"chat-paper-selection-header",children:[T.jsx("span",{className:"chat-paper-selection-label",children:l}),T.jsxs("div",{className:"chat-paper-selection-actions",children:[(i||o)&&T.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&&T.jsx("button",{type:"button",className:"chat-paper-selection-remove","aria-label":"Remove selected paper passage",onClick:r,children:"Remove"})]})]}),T.jsx("blockquote",{id:n,ref:s,className:`chat-paper-selection-quote${o?" is-expanded":""}`,children:e.text})]})}const uh=Wf(),WT=({onSend:e,busy:t,placeholder:r,autoFocus:n,draft:s,onDraftChange:o,onStop:a,models:i=[],selectedModel:c,onModelChange:l,disabled:d=!1,describedBy:f,paperMentionsEnabled:y=!1,paperSelectionEnabled:g=!0,webSearchAvailable:m=!1,webSearchEnabled:v=!1,onWebSearchChange:_,reasoningEffort:h="low",onReasoningEffortChange:$})=>{const[S,R]=Et.useState(uh),k=s??S,M=Et.useRef(null),[x,K]=Et.useState(0),J=V=>{s||R(V),o==null||o(V)},H=Ul({draft:k,onChange:J,enabled:y,textareaRef:M});Et.useEffect(()=>{const V=M.current;V&&(V.style.height="auto",V.style.height=`${Math.min(V.scrollHeight,200)}px`)},[k.text]),Et.useEffect(()=>{var V;n&&((V=M.current)==null||V.focus())},[n]);const Z=()=>{const V=k.text.length-k.text.trimStart().length,ae=k.text.trim(),ke=!!k.paperSelection&&!g;if(!ae||t||d||ke)return;const $e=V+ae.length,it={text:ae,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(it)},Q=!!k.paperSelection&&!g,re=!!k.text.trim()&&!Q;return T.jsxs("div",{className:"chat-composer",children:[k.paperSelection&&T.jsx(ws,{selection:k.paperSelection,editable:!0,onRemove:()=>{var V;J({text:k.text,paperMentions:k.paperMentions}),(V=M.current)==null||V.focus()}}),Q&&T.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."}),T.jsxs("div",{className:"chat-composer-textarea-wrap",children:[T.jsx(Vl,{text:k.text,mentions:k.paperMentions,scrollTop:x}),T.jsx("textarea",{ref:M,rows:1,value:k.text,placeholder:r||(k.paperSelection?"Ask about this selection…":"Ask anything about research…"),onChange:V=>H.updateText(V.target.value,V.target.selectionStart),onSelect:V=>H.refresh(V.currentTarget.selectionStart),onClick:V=>H.refresh(V.currentTarget.selectionStart),onScroll:V=>K(V.currentTarget.scrollTop),onBlur:V=>{var ae,ke;(ke=(ae=V.relatedTarget)==null?void 0:ae.closest)!=null&&ke.call(ae,".chat-paper-picker")||window.setTimeout(H.close,0)},onKeyDown:V=>{H.keyDown(V)||V.key==="Enter"&&!V.shiftKey&&!V.nativeEvent.isComposing&&(V.preventDefault(),Z())},role:"combobox","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,"aria-autocomplete":"list","aria-describedby":[f,H.message?"chat-paper-mention-message":null].filter(Boolean).join(" ")||void 0}),T.jsx(Ll,{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})]}),H.message&&T.jsx("div",{id:"chat-paper-mention-message",className:"chat-paper-mention-message",role:"alert",children:H.message}),T.jsxs("div",{className:"chat-composer-row",children:[T.jsxs("div",{className:"chat-composer-tools",children:[i.length>0&&c&&l&&T.jsx(Hf,{models:i,selectedModel:c,onModelChange:l,disabled:t}),$&&T.jsx(Zf,{value:h,onChange:$,disabled:t}),m&&_&&T.jsx(Kf,{enabled:v,onChange:_,disabled:t}),T.jsx("span",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]}),T.jsx("button",{type:"button",className:`chat-send${t||re?" chat-send-on":""}`,onClick:t?a:Z,disabled:d||(t?!a:!re),"aria-label":t?"Stop generating":"Send message",children:t?a?T.jsx("span",{"aria-hidden":"true",children:"■"}):T.jsx(Ho,{light:!0}):T.jsx(Gf,{})})]})]})},Ls=new Map,dh=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},fh=new Set(["huggingface.co","www.huggingface.co"]),hh=new Set(["api","blog","chat","collections","docs","enterprise","join","login","models","new","organizations","papers","posts","pricing","search","settings","spaces","tasks"]);function ph(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!=="https:"||!fh.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"&&hh.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 mh=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,_h=({repo:e})=>{const[t,r]=fe.useState(!1);return T.jsxs("div",{className:"hf-preview-card",children:[t?T.jsx("div",{className:"hf-preview-fallback","aria-hidden":"true",children:"🤗"}):T.jsx("img",{className:"hf-preview-image","data-testid":"hf-preview-image",src:e.thumbnailUrl,alt:"",loading:"eager",decoding:"async",onError:()=>r(!0)}),T.jsxs("div",{className:"hf-preview-meta",children:[T.jsxs("span",{className:"hf-preview-kind",children:["Hugging Face ",e.type]}),T.jsx("strong",{children:e.repoId}),T.jsx("span",{children:"huggingface.co"})]})]})},gh=({repo:e,children:t})=>{const[r,n]=fe.useState(!1),s=fe.useRef(null),o=fe.useCallback(()=>{dh(e.thumbnailUrl)},[e.thumbnailUrl]);return fe.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]),T.jsxs(Zo,{open:r,onOpenChange:a=>{(!a||!mh())&&n(a)},openDelay:150,closeDelay:100,children:[T.jsx(Ko,{asChild:!0,children:T.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})}),T.jsx(Go,{className:"hf-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:T.jsx(_h,{repo:e})})]})},yh=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,vh=({repo:e,preview:t,unavailable:r})=>{const[n,s]=fe.useState(!1),o=!!(t!=null&&t.avatarUrl)&&!n;return T.jsxs("div",{className:"github-preview-card",children:[o?T.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)}):T.jsx("div",{className:"github-preview-fallback","aria-hidden":"true",children:T.jsx(Wo,{})}),T.jsxs("div",{className:"github-preview-meta",children:[T.jsx("span",{className:"github-preview-kind",children:"GitHub repository"}),T.jsx("strong",{children:e.repoId}),(t==null?void 0:t.description)&&T.jsx("span",{className:"github-preview-description",children:t.description}),t?T.jsxs("span",{className:"github-preview-stats",children:[t.language&&T.jsxs(T.Fragment,{children:[t.language," · "]}),"★ ",t.stars.toLocaleString()," · ⑂ ",t.forks.toLocaleString(),t.archived&&T.jsx(T.Fragment,{children:" · Archived"})]}):T.jsx("span",{children:r?"Preview unavailable":"Loading preview…"})]})]})},$h=({repo:e,children:t})=>{const[r,n]=fe.useState(!1),s=Qf({queryKey:["github-repository-preview",e.repoId.toLowerCase()],queryFn:({signal:o})=>Yf(e,o),enabled:r,staleTime:30*60*1e3,gcTime:60*60*1e3,retry:!1});return T.jsxs(Zo,{open:r,onOpenChange:o=>{(!o||!yh())&&n(o)},openDelay:150,closeDelay:100,children:[T.jsx(Ko,{asChild:!0,children:T.jsxs("a",{className:"chat-github-link",href:e.url,target:"_blank",rel:"noopener noreferrer",children:[T.jsx(Wo,{"aria-hidden":"true"}),t]})}),T.jsx(Go,{className:"github-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:T.jsx(vh,{repo:e,preview:s.data,unavailable:s.isError})})]})},wh=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches;function bh(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return"Web source"}}const Sh=({citation:e})=>{const[t,r]=fe.useState(!1),[n,s]=fe.useState(!1),o=e.thumbnail_url,a=e.favicon_url;return T.jsxs("div",{className:"web-preview-card",children:[o&&!t&&T.jsx("img",{className:"web-preview-image","data-testid":"web-preview-image",src:o,alt:"",loading:"eager",decoding:"async",referrerPolicy:"no-referrer",onError:()=>r(!0)}),T.jsxs("div",{className:"web-preview-meta",children:[T.jsxs("div",{className:"web-preview-source",children:[a&&!n&&T.jsx("img",{src:a,alt:"",loading:"eager",decoding:"async",referrerPolicy:"no-referrer",onError:()=>s(!0)}),T.jsx("span",{children:bh(e.url??"")}),e.published&&T.jsxs(T.Fragment,{children:[T.jsx("span",{"aria-hidden":"true",children:"·"}),T.jsx("time",{children:e.published.slice(0,10)})]})]}),T.jsx("strong",{children:e.title}),e.excerpt&&T.jsx("p",{children:e.excerpt.replace(/\s+/g," ").trim()})]})]})},Eh=({citation:e,children:t})=>{const[r,n]=fe.useState(!1),s=e.url??"";return T.jsxs(Zo,{open:r,onOpenChange:o=>{(!o||!wh())&&n(o)},openDelay:150,closeDelay:100,children:[T.jsx(Ko,{asChild:!0,children:T.jsx("a",{href:s,className:"chat-web-citation",target:"_blank",rel:"noopener noreferrer",children:t})}),T.jsx(Go,{className:"web-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:T.jsx(Sh,{citation:e})})]})};function kh(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})=>T.jsx(Hl,{routeId:e,initialData:kh(e,t,r),className:n,target:"_blank",children:s});function Ph(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 Th=e=>e.startsWith("paper:")?e:sh(e);function Rh(e){try{const t=new URL(e);return t.protocol==="https:"&&(t.hostname==="github.com"||t.hostname==="www.github.com")}catch{return!1}}const ao=({text:e,streaming:t,papers:r,citations:n,webCitations:s})=>{const o=t?Ph(e):e;return T.jsx(rh,{remarkPlugins:[nh,th],rehypePlugins:[eh],urlTransform:Th,components:{a:({href:a,children:i})=>{if(a!=null&&a.startsWith("paper:")){const d=a.slice(6);return!r[d]&&!(n!=null&&n[d])?T.jsx("span",{className:"chat-invalid-citation",children:i}):T.jsx(Zl,{routeId:d,paper:r[d],citation:n==null?void 0:n[d],children:i})}const c=a?ph(a):null;if(c)return T.jsx(gh,{repo:c,children:i});const l=a?Xf(a):null;return l?T.jsx($h,{repo:l,children:i}):a&&Rh(a)?T.jsxs("a",{href:a,className:"chat-github-link",target:"_blank",rel:"noopener noreferrer",children:[T.jsx(Wo,{"aria-hidden":"true"}),i]}):a!=null&&a.startsWith("https://")&&(s!=null&&s[a])?T.jsx(Eh,{citation:s[a],children:i}):a!=null&&a.startsWith("https://")?T.jsx("a",{href:a,className:"chat-external-link",target:"_blank",rel:"noopener noreferrer",children:i}):T.jsx("span",{children:i})}},children:o})},Ch=Object.freeze({status:"aborted"});function z(e,t,r){function n(i,c){var l;Object.defineProperty(i,"_zod",{value:i._zod??{},enumerable:!1}),(l=i._zod).traits??(l.traits=new Set),i._zod.traits.add(e),t(i,c);for(const d in a.prototype)d in i||Object.defineProperty(i,d,{value:a.prototype[d].bind(i)});i._zod.constr=a,i._zod.def=c}const s=(r==null?void 0:r.Parent)??Object;class o extends s{}Object.defineProperty(o,"name",{value:e});function a(i){var c;const l=r!=null&&r.Parent?new o:this;n(l,i),(c=l._zod).deferred??(c.deferred=[]);for(const d of l._zod.deferred)d();return l}return Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:i=>{var c,l;return r!=null&&r.Parent&&i instanceof r.Parent?!0:(l=(c=i==null?void 0:i._zod)==null?void 0:c.traits)==null?void 0:l.has(e)}}),Object.defineProperty(a,"name",{value:e}),a}class on extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Kl={};function Vt(e){return Kl}function Nh(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 Ih(e,t){return typeof t=="bigint"?t.toString():t}function Bo(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Jo(e){return e==null}function Qo(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function jh(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 bs(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Ur(e){return JSON.stringify(e)}const Gl=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function ts(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Oh=Bo(()=>{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 rs(e){if(ts(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(ts(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}const Ah=new Set(["string","number","symbol"]);function fn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function dr(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 Mh(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const zh={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 xh(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 dr(e,{...e._zod.def,shape:r,checks:[]})}function qh(e,t){const r={...e._zod.def.shape},n=e._zod.def;for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete r[s]}return dr(e,{...e._zod.def,shape:r,checks:[]})}function Dh(e,t){if(!rs(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 bs(this,"shape",n),n},checks:[]};return dr(e,r)}function Uh(e,t){return dr(e,{...e._zod.def,get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return bs(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function Vh(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 dr(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 dr(t,{...t._zod.def,shape:s,checks:[]})}function Br(e,t=0){var r;for(let n=t;n{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Tn(e){return typeof e=="string"?e:e==null?void 0:e.message}function Lt(e,t,r){var s,o,a,i,c,l;const n={...e,path:e.path??[]};if(!e.message){const d=Tn((a=(o=(s=e.inst)==null?void 0:s._zod.def)==null?void 0:o.error)==null?void 0:a.call(o,e))??Tn((i=t==null?void 0:t.error)==null?void 0:i.call(t,e))??Tn((c=r.customError)==null?void 0:c.call(r,e))??Tn((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 Yo(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function an(...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,Ih,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Bl=z("$ZodError",Wl),Jl=z("$ZodError",Wl,{Parent:Error});function Fh(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 Hh(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 on;if(a.issues.length){const i=new((s==null?void 0:s.Err)??e)(a.issues.map(c=>Lt(c,o,Vt())));throw Gl(i,s==null?void 0:s.callee),i}return a.value},Kh=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=>Lt(c,o,Vt())));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 on;return o.issues.length?{success:!1,error:new(e??Bl)(o.issues.map(a=>Lt(a,s,Vt())))}:{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=>Lt(a,s,Vt())))}:{success:!0,data:o.value}},Gh=Xl(Jl),Wh=/^[cC][^\s-]{8,}$/,Bh=/^[0-9a-z]+$/,Jh=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Qh=/^[0-9a-vA-V]{20}$/,Yh=/^[A-Za-z0-9]{27}$/,Xh=/^[a-zA-Z0-9_-]{21}$/,ep=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,tp=/^([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})$/,pc=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)$/,rp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,np="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function sp(){return new RegExp(np,"u")}const op=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ap=/^(([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})$/,ip=/^((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])$/,cp=/^(([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])$/,lp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,eu=/^[A-Za-z0-9_-]*$/,up=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,dp=/^\+(?:[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])))",fp=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 hp(e){return new RegExp(`^${ru(e)}$`)}function pp(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 mp=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+$/,gp=/^-?\d+(?:\.\d+)?/i,yp=/true|false/i,vp=/null/i,$p=/undefined/i,wp=/^[^A-Z]*$/,bp=/^[^a-z]*$/,at=z("$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=z("$ZodCheckLessThan",(e,t)=>{at.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{at.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})}}),Sp=z("$ZodCheckMultipleOf",(e,t)=>{at.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):jh(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})}}),Ep=z("$ZodCheckNumberFormat",(e,t)=>{var a;at.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]=zh[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})}}),kp=z("$ZodCheckMaxLength",(e,t)=>{var r;at.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!Jo(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=Yo(s);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Pp=z("$ZodCheckMinLength",(e,t)=>{var r;at.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!Jo(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=Yo(s);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Tp=z("$ZodCheckLengthEquals",(e,t)=>{var r;at.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!Jo(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=Yo(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})}}),Ss=z("$ZodCheckStringFormat",(e,t)=>{var r,n;at.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=()=>{})}),Rp=z("$ZodCheckRegex",(e,t)=>{Ss.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})}}),Cp=z("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=wp),Ss.init(e,t)}),Np=z("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=bp),Ss.init(e,t)}),Ip=z("$ZodCheckIncludes",(e,t)=>{at.init(e,t);const r=fn(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})}}),jp=z("$ZodCheckStartsWith",(e,t)=>{at.init(e,t);const r=new RegExp(`^${fn(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})}}),Op=z("$ZodCheckEndsWith",(e,t)=>{at.init(e,t);const r=new RegExp(`.*${fn(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})}}),Ap=z("$ZodCheckOverwrite",(e,t)=>{at.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class Mp{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 zp={major:4,minor:0,patch:0},Ee=z("$ZodType",(e,t)=>{var s;var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=zp;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=Br(a),d;for(const f of i){if(f._zod.def.when){if(!f._zod.def.when(a))continue}else if(l)continue;const y=a.issues.length,g=f._zod.check(a);if(g instanceof Promise&&(c==null?void 0:c.async)===!1)throw new on;if(d||g instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await g,a.issues.length!==y&&(l||(l=Br(a,y)))});else{if(a.issues.length===y)continue;l||(l=Br(a,y))}}return d?d.then(()=>a):a};e._zod.run=(a,i)=>{const c=e._zod.parse(a,i);if(c instanceof Promise){if(i.async===!1)throw new on;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 Gh(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}}),Xo=z("$ZodString",(e,t)=>{var r;Ee.init(e,t),e._zod.pattern=[...((r=e==null?void 0:e._zod.bag)==null?void 0:r.patterns)??[]].pop()??mp(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=z("$ZodStringFormat",(e,t)=>{Ss.init(e,t),Xo.init(e,t)}),xp=z("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=tp),Ne.init(e,t)}),qp=z("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=pc(n))}else t.pattern??(t.pattern=pc());Ne.init(e,t)}),Dp=z("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=rp),Ne.init(e,t)}),Up=z("$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:up.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})}}}),Vp=z("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=sp()),Ne.init(e,t)}),Lp=z("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Xh),Ne.init(e,t)}),Fp=z("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Wh),Ne.init(e,t)}),Hp=z("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Bh),Ne.init(e,t)}),Zp=z("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Jh),Ne.init(e,t)}),Kp=z("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Qh),Ne.init(e,t)}),Gp=z("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Yh),Ne.init(e,t)}),Wp=z("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=pp(t)),Ne.init(e,t)}),Bp=z("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=fp),Ne.init(e,t)}),Jp=z("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=hp(t)),Ne.init(e,t)}),Qp=z("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ep),Ne.init(e,t)}),Yp=z("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=op),Ne.init(e,t),e._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv4"})}),Xp=z("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ap),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})}}}),em=z("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ip),Ne.init(e,t)}),tm=z("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=cp),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 rm=z("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=lp),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 nm(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 sm=z("$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=>{nm(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),om=z("$ZodE164",(e,t)=>{t.pattern??(t.pattern=dp),Ne.init(e,t)});function am(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 im=z("$ZodJWT",(e,t)=>{Ne.init(e,t),e._zod.check=r=>{am(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),iu=z("$ZodNumber",(e,t)=>{Ee.init(e,t),e._zod.pattern=e._zod.bag.pattern??gp,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}}),cm=z("$ZodNumber",(e,t)=>{Ep.init(e,t),iu.init(e,t)}),lm=z("$ZodBoolean",(e,t)=>{Ee.init(e,t),e._zod.pattern=yp,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}}),um=z("$ZodUndefined",(e,t)=>{Ee.init(e,t),e._zod.pattern=$p,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}}),dm=z("$ZodNull",(e,t)=>{Ee.init(e,t),e._zod.pattern=vp,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}}),fm=z("$ZodAny",(e,t)=>{Ee.init(e,t),e._zod.parse=r=>r}),hm=z("$ZodUnknown",(e,t)=>{Ee.init(e,t),e._zod.parse=r=>r}),pm=z("$ZodNever",(e,t)=>{Ee.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function mc(e,t,r){e.issues.length&&t.issues.push(...sr(r,e.issues)),t.value[r]=e.value}const mm=z("$ZodArray",(e,t)=>{Ee.init(e,t),e._zod.parse=(r,n)=>{const s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),r;r.value=Array(s.length);const o=[];for(let a=0;amc(l,r,a))):mc(c,r,a)}return o.length?Promise.all(o).then(()=>r):r}});function Rn(e,t,r){e.issues.length&&t.issues.push(...sr(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(...sr(r,e.issues)):e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}const _m=z("$ZodObject",(e,t)=>{Ee.init(e,t);const r=Bo(()=>{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 y=Mh(t.shape);return{shape:t.shape,keys:f,keySet:new Set(f),numKeys:f.length,optionalKeys:new Set(y)}});Re(e._zod,"propValues",()=>{const f=t.shape,y={};for(const g in f){const m=f[g]._zod;if(m.values){y[g]??(y[g]=new Set);for(const v of m.values)y[g].add(v)}}return y});const n=f=>{const y=new Mp(["shape","payload","ctx"]),g=r.value,m=$=>{const S=Ur($);return`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`};y.write("const input = payload.value;");const v=Object.create(null);let _=0;for(const $ of g.keys)v[$]=`key_${_++}`;y.write("const newResult = {}");for(const $ of g.keys)if(g.optionalKeys.has($)){const S=v[$];y.write(`const ${S} = ${m($)};`);const R=Ur($);y.write(` + if (${S}.issues.length) { + if (input[${R}] === undefined) { + if (${R} in input) { + newResult[${R}] = undefined; + } + } else { + payload.issues = payload.issues.concat( + ${S}.issues.map((iss) => ({ + ...iss, + path: iss.path ? [${R}, ...iss.path] : [${R}], + })) + ); + } + } else if (${S}.value === undefined) { + if (${R} in input) newResult[${R}] = undefined; + } else { + newResult[${R}] = ${S}.value; + } + `)}else{const S=v[$];y.write(`const ${S} = ${m($)};`),y.write(` + if (${S}.issues.length) payload.issues = payload.issues.concat(${S}.issues.map(iss => ({ + ...iss, + path: iss.path ? [${Ur($)}, ...iss.path] : [${Ur($)}] + })));`),y.write(`newResult[${Ur($)}] = ${S}.value`)}y.write("payload.value = newResult;"),y.write("return payload;");const h=y.compile();return($,S)=>h(f,$,S)};let s;const o=ts,a=!Kl.jitless,c=a&&Oh.value,l=t.catchall;let d;e._zod.parse=(f,y)=>{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&&(y==null?void 0:y.async)===!1&&y.jitless!==!0)s||(s=n(t.shape)),f=s(f,y);else{f.value={};const S=d.shape;for(const R of d.keys){const k=S[R],M=k._zod.run({value:g[R],issues:[]},y),x=k._zod.optin==="optional"&&k._zod.optout==="optional";M instanceof Promise?m.push(M.then(K=>x?_c(K,f,R,g):Rn(K,f,R))):x?_c(M,f,R,g):Rn(M,f,R)}}if(!l)return m.length?Promise.all(m).then(()=>f):f;const v=[],_=d.keySet,h=l._zod,$=h.def.type;for(const S of Object.keys(g)){if(_.has(S))continue;if($==="never"){v.push(S);continue}const R=h.run({value:g[S],issues:[]},y);R instanceof Promise?m.push(R.then(k=>Rn(k,f,S))):Rn(R,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 gc(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=>Lt(o,n,Vt())))}),t}const cu=z("$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=>Qo(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=>gc(a,r,e,n)):gc(o,r,e,n)}}),gm=z("$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=Bo(()=>{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(!ts(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)}}),ym=z("$ZodIntersection",(e,t)=>{Ee.init(e,t),e._zod.parse=(r,n)=>{const s=r.value,o=t.left._zod.run({value:s,issues:[]},n),a=t.right._zod.run({value:s,issues:[]},n);return o instanceof Promise||a instanceof Promise?Promise.all([o,a]).then(([c,l])=>yc(r,c,l)):yc(r,o,a)}});function io(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(rs(e)&&rs(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=io(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(!rs(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(...sr(c,d.issues)),r.value[c]=d.value})):(l.issues.length&&r.issues.push(...sr(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=>Lt(l,n,Vt())),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(...sr(a,l.issues)),r.value[i.value]=l.value})):(c.issues.length&&r.issues.push(...sr(a,c.issues)),r.value[i.value]=c.value)}}return o.length?Promise.all(o).then(()=>r):r}}),$m=z("$ZodEnum",(e,t)=>{Ee.init(e,t);const r=Nh(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(n=>Ah.has(typeof n)).map(n=>typeof n=="string"?fn(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}}),wm=z("$ZodLiteral",(e,t)=>{Ee.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?fn(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}}),bm=z("$ZodTransform",(e,t)=>{Ee.init(e,t),e._zod.parse=(r,n)=>{const s=t.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(a=>(r.value=a,r));if(s instanceof Promise)throw new on;return r.value=s,r}}),Sm=z("$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(`^(${Qo(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)}),Em=z("$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(`^(${Qo(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)}),km=z("$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=>vc(o,t)):vc(s,t)}});function vc(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Pm=z("$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))}),Tm=z("$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=>$c(o,e)):$c(s,e)}});function $c(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 Rm=z("$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=>Lt(a,n,Vt()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=t.catchValue({...r,error:{issues:s.issues.map(o=>Lt(o,n,Vt()))},input:r.value}),r.issues=[]),r)}}),Cm=z("$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=>wc(o,t,n)):wc(s,t,n)}});function wc(e,t,r){return Br(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}const Nm=z("$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(bc):bc(s)}});function bc(e){return e.value=Object.freeze(e.value),e}const Im=z("$ZodCustom",(e,t)=>{at.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=>Sc(o,r,n,e));Sc(s,r,n,e)}});function Sc(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(an(s))}}class jm{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 Om(){return new jm}const Cn=Om();function Am(e,t){return new e({type:"string",...ee(t)})}function Mm(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ee(t)})}function Ec(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ee(t)})}function zm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ee(t)})}function xm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ee(t)})}function qm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ee(t)})}function Dm(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 Um(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ee(t)})}function Vm(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 Fm(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ee(t)})}function Hm(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ee(t)})}function Zm(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ee(t)})}function Km(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ee(t)})}function Gm(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ee(t)})}function Wm(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ee(t)})}function Bm(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ee(t)})}function Jm(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ee(t)})}function Qm(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ee(t)})}function Ym(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ee(t)})}function Xm(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ee(t)})}function e_(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ee(t)})}function t_(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ee(t)})}function r_(e,t){return new e({type:"string",format:"date",check:"string_format",...ee(t)})}function n_(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ee(t)})}function s_(e,t){return new e({type:"string",format:"duration",check:"string_format",...ee(t)})}function o_(e,t){return new e({type:"number",checks:[],...ee(t)})}function a_(e,t){return new e({type:"number",coerce:!0,checks:[],...ee(t)})}function i_(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ee(t)})}function c_(e,t){return new e({type:"boolean",...ee(t)})}function l_(e,t){return new e({type:"undefined",...ee(t)})}function u_(e,t){return new e({type:"null",...ee(t)})}function d_(e){return new e({type:"any"})}function f_(e){return new e({type:"unknown"})}function h_(e,t){return new e({type:"never",...ee(t)})}function kc(e,t){return new su({check:"less_than",...ee(t),value:e,inclusive:!1})}function Fs(e,t){return new su({check:"less_than",...ee(t),value:e,inclusive:!0})}function Pc(e,t){return new ou({check:"greater_than",...ee(t),value:e,inclusive:!1})}function Hs(e,t){return new ou({check:"greater_than",...ee(t),value:e,inclusive:!0})}function Tc(e,t){return new Sp({check:"multiple_of",...ee(t),value:e})}function uu(e,t){return new kp({check:"max_length",...ee(t),maximum:e})}function ns(e,t){return new Pp({check:"min_length",...ee(t),minimum:e})}function du(e,t){return new Tp({check:"length_equals",...ee(t),length:e})}function p_(e,t){return new Rp({check:"string_format",format:"regex",...ee(t),pattern:e})}function m_(e){return new Cp({check:"string_format",format:"lowercase",...ee(e)})}function __(e){return new Np({check:"string_format",format:"uppercase",...ee(e)})}function g_(e,t){return new Ip({check:"string_format",format:"includes",...ee(t),includes:e})}function y_(e,t){return new jp({check:"string_format",format:"starts_with",...ee(t),prefix:e})}function v_(e,t){return new Op({check:"string_format",format:"ends_with",...ee(t),suffix:e})}function hn(e){return new Ap({check:"overwrite",tx:e})}function $_(e){return hn(t=>t.normalize(e))}function w_(){return hn(e=>e.trim())}function b_(){return hn(e=>e.toLowerCase())}function S_(){return hn(e=>e.toUpperCase())}function E_(e,t,r){return new e({type:"array",element:t,...ee(r)})}function k_(e,t,r){const n=ee(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function P_(e,t,r){return new e({type:"custom",check:"custom",fn:t,...ee(r)})}const T_=z("ZodISODateTime",(e,t)=>{Wp.init(e,t),je.init(e,t)});function fu(e){return t_(T_,e)}const R_=z("ZodISODate",(e,t)=>{Bp.init(e,t),je.init(e,t)});function C_(e){return r_(R_,e)}const N_=z("ZodISOTime",(e,t)=>{Jp.init(e,t),je.init(e,t)});function I_(e){return n_(N_,e)}const j_=z("ZodISODuration",(e,t)=>{Qp.init(e,t),je.init(e,t)});function O_(e){return s_(j_,e)}const A_=(e,t)=>{Bl.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Hh(e,r)},flatten:{value:r=>Fh(e,r)},addIssue:{value:r=>e.issues.push(r)},addIssues:{value:r=>e.issues.push(...r)},isEmpty:{get(){return e.issues.length===0}}})},Es=z("ZodError",A_,{Parent:Error}),M_=Zh(Es),z_=Kh(Es),x_=Ql(Es),q_=Xl(Es),Ce=z("ZodType",(e,t)=>(Ee.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(r,n)=>dr(e,r,n),e.brand=()=>e,e.register=(r,n)=>(r.add(e,n),e),e.parse=(r,n)=>M_(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>x_(e,r,n),e.parseAsync=async(r,n)=>z_(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>q_(e,r,n),e.spa=e.safeParseAsync,e.refine=(r,n)=>e.check(Ng(r,n)),e.superRefine=r=>e.check(Ig(r)),e.overwrite=r=>e.check(hn(r)),e.optional=()=>Ie(e),e.nullable=()=>Nc(e),e.nullish=()=>Ie(Nc(e)),e.nonoptional=r=>bg(e,r),e.array=()=>L(e),e.or=r=>ge([e,r]),e.and=r=>ra(e,r),e.transform=r=>fo(e,yu(r)),e.default=r=>vg(e,r),e.prefault=r=>wg(e,r),e.catch=r=>Eg(e,r),e.pipe=r=>fo(e,r),e.readonly=()=>Tg(e),e.describe=r=>{const n=e.clone();return Cn.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){var r;return(r=Cn.get(e))==null?void 0:r.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return Cn.get(e);const n=e.clone();return Cn.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),hu=z("_ZodString",(e,t)=>{Xo.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(p_(...n)),e.includes=(...n)=>e.check(g_(...n)),e.startsWith=(...n)=>e.check(y_(...n)),e.endsWith=(...n)=>e.check(v_(...n)),e.min=(...n)=>e.check(ns(...n)),e.max=(...n)=>e.check(uu(...n)),e.length=(...n)=>e.check(du(...n)),e.nonempty=(...n)=>e.check(ns(1,...n)),e.lowercase=n=>e.check(m_(n)),e.uppercase=n=>e.check(__(n)),e.trim=()=>e.check(w_()),e.normalize=(...n)=>e.check($_(...n)),e.toLowerCase=()=>e.check(b_()),e.toUpperCase=()=>e.check(S_())}),D_=z("ZodString",(e,t)=>{Xo.init(e,t),hu.init(e,t),e.email=r=>e.check(Mm(U_,r)),e.url=r=>e.check(lu(pu,r)),e.jwt=r=>e.check(e_(rg,r)),e.emoji=r=>e.check(Um(L_,r)),e.guid=r=>e.check(Ec(Rc,r)),e.uuid=r=>e.check(zm(Nn,r)),e.uuidv4=r=>e.check(xm(Nn,r)),e.uuidv6=r=>e.check(qm(Nn,r)),e.uuidv7=r=>e.check(Dm(Nn,r)),e.nanoid=r=>e.check(Vm(F_,r)),e.guid=r=>e.check(Ec(Rc,r)),e.cuid=r=>e.check(Lm(H_,r)),e.cuid2=r=>e.check(Fm(Z_,r)),e.ulid=r=>e.check(Hm(K_,r)),e.base64=r=>e.check(Qm(X_,r)),e.base64url=r=>e.check(Ym(eg,r)),e.xid=r=>e.check(Zm(G_,r)),e.ksuid=r=>e.check(Km(W_,r)),e.ipv4=r=>e.check(Gm(B_,r)),e.ipv6=r=>e.check(Wm(J_,r)),e.cidrv4=r=>e.check(Bm(Q_,r)),e.cidrv6=r=>e.check(Jm(Y_,r)),e.e164=r=>e.check(Xm(tg,r)),e.datetime=r=>e.check(fu(r)),e.date=r=>e.check(C_(r)),e.time=r=>e.check(I_(r)),e.duration=r=>e.check(O_(r))});function P(e){return Am(D_,e)}const je=z("ZodStringFormat",(e,t)=>{Ne.init(e,t),hu.init(e,t)}),U_=z("ZodEmail",(e,t)=>{Dp.init(e,t),je.init(e,t)}),Rc=z("ZodGUID",(e,t)=>{xp.init(e,t),je.init(e,t)}),Nn=z("ZodUUID",(e,t)=>{qp.init(e,t),je.init(e,t)}),pu=z("ZodURL",(e,t)=>{Up.init(e,t),je.init(e,t)});function V_(e){return lu(pu,e)}const L_=z("ZodEmoji",(e,t)=>{Vp.init(e,t),je.init(e,t)}),F_=z("ZodNanoID",(e,t)=>{Lp.init(e,t),je.init(e,t)}),H_=z("ZodCUID",(e,t)=>{Fp.init(e,t),je.init(e,t)}),Z_=z("ZodCUID2",(e,t)=>{Hp.init(e,t),je.init(e,t)}),K_=z("ZodULID",(e,t)=>{Zp.init(e,t),je.init(e,t)}),G_=z("ZodXID",(e,t)=>{Kp.init(e,t),je.init(e,t)}),W_=z("ZodKSUID",(e,t)=>{Gp.init(e,t),je.init(e,t)}),B_=z("ZodIPv4",(e,t)=>{Yp.init(e,t),je.init(e,t)}),J_=z("ZodIPv6",(e,t)=>{Xp.init(e,t),je.init(e,t)}),Q_=z("ZodCIDRv4",(e,t)=>{em.init(e,t),je.init(e,t)}),Y_=z("ZodCIDRv6",(e,t)=>{tm.init(e,t),je.init(e,t)}),X_=z("ZodBase64",(e,t)=>{rm.init(e,t),je.init(e,t)}),eg=z("ZodBase64URL",(e,t)=>{sm.init(e,t),je.init(e,t)}),tg=z("ZodE164",(e,t)=>{om.init(e,t),je.init(e,t)}),rg=z("ZodJWT",(e,t)=>{im.init(e,t),je.init(e,t)}),ea=z("ZodNumber",(e,t)=>{iu.init(e,t),Ce.init(e,t),e.gt=(n,s)=>e.check(Pc(n,s)),e.gte=(n,s)=>e.check(Hs(n,s)),e.min=(n,s)=>e.check(Hs(n,s)),e.lt=(n,s)=>e.check(kc(n,s)),e.lte=(n,s)=>e.check(Fs(n,s)),e.max=(n,s)=>e.check(Fs(n,s)),e.int=n=>e.check(Cc(n)),e.safe=n=>e.check(Cc(n)),e.positive=n=>e.check(Pc(0,n)),e.nonnegative=n=>e.check(Hs(0,n)),e.negative=n=>e.check(kc(0,n)),e.nonpositive=n=>e.check(Fs(0,n)),e.multipleOf=(n,s)=>e.check(Tc(n,s)),e.step=(n,s)=>e.check(Tc(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 ue(e){return o_(ea,e)}const ng=z("ZodNumberFormat",(e,t)=>{cm.init(e,t),ea.init(e,t)});function Cc(e){return i_(ng,e)}const sg=z("ZodBoolean",(e,t)=>{lm.init(e,t),Ce.init(e,t)});function ye(e){return c_(sg,e)}const og=z("ZodUndefined",(e,t)=>{um.init(e,t),Ce.init(e,t)});function co(e){return l_(og,e)}const ag=z("ZodNull",(e,t)=>{dm.init(e,t),Ce.init(e,t)});function ig(e){return u_(ag,e)}const cg=z("ZodAny",(e,t)=>{fm.init(e,t),Ce.init(e,t)});function ta(){return d_(cg)}const lg=z("ZodUnknown",(e,t)=>{hm.init(e,t),Ce.init(e,t)});function Se(){return f_(lg)}const ug=z("ZodNever",(e,t)=>{pm.init(e,t),Ce.init(e,t)});function lo(e){return h_(ug,e)}const dg=z("ZodArray",(e,t)=>{mm.init(e,t),Ce.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(ns(r,n)),e.nonempty=r=>e.check(ns(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 E_(dg,e,t)}const mu=z("ZodObject",(e,t)=>{_m.init(e,t),Ce.init(e,t),Re(e,"shape",()=>t.shape),e.keyof=()=>ct(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:lo()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>Dh(e,r),e.merge=r=>Uh(e,r),e.pick=r=>xh(e,r),e.omit=r=>qh(e,r),e.partial=(...r)=>Vh(vu,e,r[0]),e.required=(...r)=>Lh($u,e,r[0])});function A(e,t){const r={type:"object",get shape(){return bs(this,"shape",{...e}),this.shape},...ee(t)};return new mu(r)}function Be(e,t){return new mu({type:"object",get shape(){return bs(this,"shape",{...e}),this.shape},catchall:Se(),...ee(t)})}const _u=z("ZodUnion",(e,t)=>{cu.init(e,t),Ce.init(e,t),e.options=t.options});function ge(e,t){return new _u({type:"union",options:e,...ee(t)})}const fg=z("ZodDiscriminatedUnion",(e,t)=>{_u.init(e,t),gm.init(e,t)});function gu(e,t,r){return new fg({type:"union",options:t,discriminator:e,...ee(r)})}const hg=z("ZodIntersection",(e,t)=>{ym.init(e,t),Ce.init(e,t)});function ra(e,t){return new hg({type:"intersection",left:e,right:t})}const pg=z("ZodRecord",(e,t)=>{vm.init(e,t),Ce.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function ve(e,t,r){return new pg({type:"record",keyType:e,valueType:t,...ee(r)})}const uo=z("ZodEnum",(e,t)=>{$m.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 uo({...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 uo({...t,checks:[],...ee(s),entries:o})}});function ct(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new uo({type:"enum",entries:r,...ee(t)})}const mg=z("ZodLiteral",(e,t)=>{wm.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 I(e,t){return new mg({type:"literal",values:Array.isArray(e)?e:[e],...ee(t)})}const _g=z("ZodTransform",(e,t)=>{bm.init(e,t),Ce.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=o=>{if(typeof o=="string")r.issues.push(an(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(an(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 _g({type:"transform",transform:e})}const vu=z("ZodOptional",(e,t)=>{Sm.init(e,t),Ce.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ie(e){return new vu({type:"optional",innerType:e})}const gg=z("ZodNullable",(e,t)=>{Em.init(e,t),Ce.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Nc(e){return new gg({type:"nullable",innerType:e})}const yg=z("ZodDefault",(e,t)=>{km.init(e,t),Ce.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function vg(e,t){return new yg({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const $g=z("ZodPrefault",(e,t)=>{Pm.init(e,t),Ce.init(e,t),e.unwrap=()=>e._zod.def.innerType});function wg(e,t){return new $g({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const $u=z("ZodNonOptional",(e,t)=>{Tm.init(e,t),Ce.init(e,t),e.unwrap=()=>e._zod.def.innerType});function bg(e,t){return new $u({type:"nonoptional",innerType:e,...ee(t)})}const Sg=z("ZodCatch",(e,t)=>{Rm.init(e,t),Ce.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Eg(e,t){return new Sg({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const kg=z("ZodPipe",(e,t)=>{Cm.init(e,t),Ce.init(e,t),e.in=t.in,e.out=t.out});function fo(e,t){return new kg({type:"pipe",in:e,out:t})}const Pg=z("ZodReadonly",(e,t)=>{Nm.init(e,t),Ce.init(e,t)});function Tg(e){return new Pg({type:"readonly",innerType:e})}const wu=z("ZodCustom",(e,t)=>{Im.init(e,t),Ce.init(e,t)});function Rg(e){const t=new at({check:"custom"});return t._zod.check=e,t}function Cg(e,t){return k_(wu,e??(()=>!0),t)}function Ng(e,t={}){return P_(wu,e,t)}function Ig(e){const t=Rg(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(an(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(an(s))}},e(r.value,r)));return t}function bu(e,t){return fo(yu(e),t)}const jg={custom:"custom"};function Og(e){return a_(ea,e)}const ks="2025-11-25",Ag=[ks,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Yt="io.modelcontextprotocol/related-task",Ps="2.0",Ue=Cg(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Su=ge([P(),ue().int()]),Eu=P();Be({ttl:ue().optional(),pollInterval:ue().optional()});const Mg=A({ttl:ue().optional()}),zg=A({taskId:P()}),na=Be({progressToken:Su.optional(),[Yt]:zg.optional()}),lt=A({_meta:na.optional()}),pn=lt.extend({task:Mg.optional()}),xg=e=>pn.safeParse(e).success,Je=A({method:P(),params:lt.loose().optional()}),ft=A({_meta:na.optional()}),ht=A({method:P(),params:ft.loose().optional()}),Qe=Be({_meta:na.optional()}),mn=ge([P(),ue().int()]),ku=A({jsonrpc:I(Ps),id:mn,...Je.shape}).strict(),ho=e=>ku.safeParse(e).success,Pu=A({jsonrpc:I(Ps),...ht.shape}).strict(),qg=e=>Pu.safeParse(e).success,sa=A({jsonrpc:I(Ps),id:mn,result:Qe}).strict(),Zr=e=>sa.safeParse(e).success;var oe;(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"})(oe||(oe={}));const oa=A({jsonrpc:I(Ps),id:mn.optional(),error:A({code:ue().int(),message:P(),data:Se().optional()})}).strict(),Dg=e=>oa.safeParse(e).success,Hn=ge([ku,Pu,sa,oa]);ge([sa,oa]);const vr=Qe.strict(),Ug=ft.extend({requestId:mn.optional(),reason:P().optional()}),aa=ht.extend({method:I("notifications/cancelled"),params:Ug}),Vg=A({src:P(),mimeType:P().optional(),sizes:L(P()).optional(),theme:ct(["light","dark"]).optional()}),_n=A({icons:L(Vg).optional()}),Pr=A({name:P(),title:P().optional()}),Ts=Pr.extend({...Pr.shape,..._n.shape,version:P(),websiteUrl:P().optional(),description:P().optional()}),Lg=ra(A({applyDefaults:ye().optional()}),ve(P(),Se())),Fg=bu(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ra(A({form:Lg.optional(),url:Ue.optional()}),ve(P(),Se()).optional())),Hg=Be({list:Ue.optional(),cancel:Ue.optional(),requests:Be({sampling:Be({createMessage:Ue.optional()}).optional(),elicitation:Be({create:Ue.optional()}).optional()}).optional()}),Zg=Be({list:Ue.optional(),cancel:Ue.optional(),requests:Be({tools:Be({call:Ue.optional()}).optional()}).optional()}),Kg=A({experimental:ve(P(),Ue).optional(),sampling:A({context:Ue.optional(),tools:Ue.optional()}).optional(),elicitation:Fg.optional(),roots:A({listChanged:ye().optional()}).optional(),tasks:Hg.optional(),extensions:ve(P(),Ue).optional()}),Gg=lt.extend({protocolVersion:P(),capabilities:Kg,clientInfo:Ts}),Wg=Je.extend({method:I("initialize"),params:Gg}),Bg=A({experimental:ve(P(),Ue).optional(),logging:Ue.optional(),completions:Ue.optional(),prompts:A({listChanged:ye().optional()}).optional(),resources:A({subscribe:ye().optional(),listChanged:ye().optional()}).optional(),tools:A({listChanged:ye().optional()}).optional(),tasks:Zg.optional(),extensions:ve(P(),Ue).optional()}),Tu=Qe.extend({protocolVersion:P(),capabilities:Bg,serverInfo:Ts,instructions:P().optional()}),Ru=ht.extend({method:I("notifications/initialized"),params:ft.optional()}),Jg=e=>Ru.safeParse(e).success,Rs=Je.extend({method:I("ping"),params:lt.optional()}),Qg=A({progress:ue(),total:Ie(ue()),message:Ie(P())}),Yg=A({...ft.shape,...Qg.shape,progressToken:Su}),ia=ht.extend({method:I("notifications/progress"),params:Yg}),Xg=lt.extend({cursor:Eu.optional()}),gn=Je.extend({params:Xg.optional()}),yn=Qe.extend({nextCursor:Eu.optional()}),ey=ct(["working","input_required","completed","failed","cancelled"]),vn=A({taskId:P(),status:ey,ttl:ge([ue(),ig()]),createdAt:P(),lastUpdatedAt:P(),pollInterval:Ie(ue()),statusMessage:Ie(P())}),cn=Qe.extend({task:vn}),ty=ft.merge(vn),ss=ht.extend({method:I("notifications/tasks/status"),params:ty}),ca=Je.extend({method:I("tasks/get"),params:lt.extend({taskId:P()})}),la=Qe.merge(vn),ua=Je.extend({method:I("tasks/result"),params:lt.extend({taskId:P()})});Qe.loose();const da=gn.extend({method:I("tasks/list")}),fa=yn.extend({tasks:L(vn)}),ha=Je.extend({method:I("tasks/cancel"),params:lt.extend({taskId:P()})}),ry=Qe.merge(vn),Cu=A({uri:P(),mimeType:Ie(P()),_meta:ve(P(),Se()).optional()}),Nu=Cu.extend({text:P()}),pa=P().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Iu=Cu.extend({blob:pa}),$n=ct(["user","assistant"]),Ir=A({audience:L($n).optional(),priority:ue().min(0).max(1).optional(),lastModified:fu({offset:!0}).optional()}),ju=A({...Pr.shape,..._n.shape,uri:P(),description:Ie(P()),mimeType:Ie(P()),size:Ie(ue()),annotations:Ir.optional(),_meta:Ie(Be({}))}),ny=A({...Pr.shape,..._n.shape,uriTemplate:P(),description:Ie(P()),mimeType:Ie(P()),annotations:Ir.optional(),_meta:Ie(Be({}))}),Ou=gn.extend({method:I("resources/list")}),ma=yn.extend({resources:L(ju)}),Au=gn.extend({method:I("resources/templates/list")}),_a=yn.extend({resourceTemplates:L(ny)}),ga=lt.extend({uri:P()}),sy=ga,Mu=Je.extend({method:I("resources/read"),params:sy}),ya=Qe.extend({contents:L(ge([Nu,Iu]))}),va=ht.extend({method:I("notifications/resources/list_changed"),params:ft.optional()}),oy=ga,ay=Je.extend({method:I("resources/subscribe"),params:oy}),iy=ga,cy=Je.extend({method:I("resources/unsubscribe"),params:iy}),ly=ft.extend({uri:P()}),uy=ht.extend({method:I("notifications/resources/updated"),params:ly}),dy=A({name:P(),description:Ie(P()),required:Ie(ye())}),fy=A({...Pr.shape,..._n.shape,description:Ie(P()),arguments:Ie(L(dy)),_meta:Ie(Be({}))}),zu=gn.extend({method:I("prompts/list")}),$a=yn.extend({prompts:L(fy)}),hy=lt.extend({name:P(),arguments:ve(P(),P()).optional()}),py=Je.extend({method:I("prompts/get"),params:hy}),wa=A({type:I("text"),text:P(),annotations:Ir.optional(),_meta:ve(P(),Se()).optional()}),ba=A({type:I("image"),data:pa,mimeType:P(),annotations:Ir.optional(),_meta:ve(P(),Se()).optional()}),Sa=A({type:I("audio"),data:pa,mimeType:P(),annotations:Ir.optional(),_meta:ve(P(),Se()).optional()}),my=A({type:I("tool_use"),name:P(),id:P(),input:ve(P(),Se()),_meta:ve(P(),Se()).optional()}),xu=A({type:I("resource"),resource:ge([Nu,Iu]),annotations:Ir.optional(),_meta:ve(P(),Se()).optional()}),qu=ju.extend({type:I("resource_link")}),wn=ge([wa,ba,Sa,qu,xu]),_y=A({role:$n,content:wn}),Du=Qe.extend({description:P().optional(),messages:L(_y)}),Ea=ht.extend({method:I("notifications/prompts/list_changed"),params:ft.optional()}),gy=A({title:P().optional(),readOnlyHint:ye().optional(),destructiveHint:ye().optional(),idempotentHint:ye().optional(),openWorldHint:ye().optional()}),yy=A({taskSupport:ct(["required","optional","forbidden"]).optional()}),ka=A({...Pr.shape,..._n.shape,description:P().optional(),inputSchema:A({type:I("object"),properties:ve(P(),Ue).optional(),required:L(P()).optional()}).catchall(Se()),outputSchema:A({type:I("object"),properties:ve(P(),Ue).optional(),required:L(P()).optional()}).catchall(Se()).optional(),annotations:gy.optional(),execution:yy.optional(),_meta:ve(P(),Se()).optional()}),vy=gn.extend({method:I("tools/list")}),Pa=yn.extend({tools:L(ka)}),or=Qe.extend({content:L(wn).default([]),structuredContent:ve(P(),Se()).optional(),isError:ye().optional()});or.or(Qe.extend({toolResult:Se()}));const $y=pn.extend({name:P(),arguments:ve(P(),Se()).optional()}),Uu=Je.extend({method:I("tools/call"),params:$y}),Ta=ht.extend({method:I("notifications/tools/list_changed"),params:ft.optional()}),wy=A({autoRefresh:ye().default(!0),debounceMs:ue().int().nonnegative().default(300)}),Vu=ct(["debug","info","notice","warning","error","critical","alert","emergency"]),by=lt.extend({level:Vu}),Sy=Je.extend({method:I("logging/setLevel"),params:by}),Ey=ft.extend({level:Vu,logger:P().optional(),data:Se()}),Lu=ht.extend({method:I("notifications/message"),params:Ey}),ky=A({name:P().optional()}),Py=A({hints:L(ky).optional(),costPriority:ue().min(0).max(1).optional(),speedPriority:ue().min(0).max(1).optional(),intelligencePriority:ue().min(0).max(1).optional()}),Ty=A({mode:ct(["auto","required","none"]).optional()}),Ry=A({type:I("tool_result"),toolUseId:P().describe("The unique identifier for the corresponding tool call."),content:L(wn).default([]),structuredContent:A({}).loose().optional(),isError:ye().optional(),_meta:ve(P(),Se()).optional()}),Cy=gu("type",[wa,ba,Sa]),os=gu("type",[wa,ba,Sa,my,Ry]),Ny=A({role:$n,content:ge([os,L(os)]),_meta:ve(P(),Se()).optional()}),Iy=pn.extend({messages:L(Ny),modelPreferences:Py.optional(),systemPrompt:P().optional(),includeContext:ct(["none","thisServer","allServers"]).optional(),temperature:ue().optional(),maxTokens:ue().int(),stopSequences:L(P()).optional(),metadata:Ue.optional(),tools:L(ka).optional(),toolChoice:Ty.optional()}),Ra=Je.extend({method:I("sampling/createMessage"),params:Iy}),Fu=Qe.extend({model:P(),stopReason:Ie(ct(["endTurn","stopSequence","maxTokens"]).or(P())),role:$n,content:Cy}),Hu=Qe.extend({model:P(),stopReason:Ie(ct(["endTurn","stopSequence","maxTokens","toolUse"]).or(P())),role:$n,content:ge([os,L(os)])}),jy=A({type:I("boolean"),title:P().optional(),description:P().optional(),default:ye().optional()}),Oy=A({type:I("string"),title:P().optional(),description:P().optional(),minLength:ue().optional(),maxLength:ue().optional(),format:ct(["email","uri","date","date-time"]).optional(),default:P().optional()}),Ay=A({type:ct(["number","integer"]),title:P().optional(),description:P().optional(),minimum:ue().optional(),maximum:ue().optional(),default:ue().optional()}),My=A({type:I("string"),title:P().optional(),description:P().optional(),enum:L(P()),default:P().optional()}),zy=A({type:I("string"),title:P().optional(),description:P().optional(),oneOf:L(A({const:P(),title:P()})),default:P().optional()}),xy=A({type:I("string"),title:P().optional(),description:P().optional(),enum:L(P()),enumNames:L(P()).optional(),default:P().optional()}),qy=ge([My,zy]),Dy=A({type:I("array"),title:P().optional(),description:P().optional(),minItems:ue().optional(),maxItems:ue().optional(),items:A({type:I("string"),enum:L(P())}),default:L(P()).optional()}),Uy=A({type:I("array"),title:P().optional(),description:P().optional(),minItems:ue().optional(),maxItems:ue().optional(),items:A({anyOf:L(A({const:P(),title:P()}))}),default:L(P()).optional()}),Vy=ge([Dy,Uy]),Ly=ge([xy,qy,Vy]),Fy=ge([Ly,jy,Oy,Ay]),Hy=pn.extend({mode:I("form").optional(),message:P(),requestedSchema:A({type:I("object"),properties:ve(P(),Fy),required:L(P()).optional()})}),Zy=pn.extend({mode:I("url"),message:P(),elicitationId:P(),url:P().url()}),Ky=ge([Hy,Zy]),Zu=Je.extend({method:I("elicitation/create"),params:Ky}),Gy=ft.extend({elicitationId:P()}),Wy=ht.extend({method:I("notifications/elicitation/complete"),params:Gy}),Ku=Qe.extend({action:ct(["accept","decline","cancel"]),content:bu(e=>e===null?void 0:e,ve(P(),ge([P(),ue(),ye(),L(P())])).optional())}),By=A({type:I("ref/resource"),uri:P()}),Jy=A({type:I("ref/prompt"),name:P()}),Qy=lt.extend({ref:ge([Jy,By]),argument:A({name:P(),value:P()}),context:A({arguments:ve(P(),P()).optional()}).optional()}),Yy=Je.extend({method:I("completion/complete"),params:Qy}),Gu=Qe.extend({completion:Be({values:L(P()).max(100),total:Ie(ue().int()),hasMore:Ie(ye())})}),Xy=A({uri:P().startsWith("file://"),name:P().optional(),_meta:ve(P(),Se()).optional()}),ev=Je.extend({method:I("roots/list"),params:lt.optional()}),tv=Qe.extend({roots:L(Xy)}),rv=ht.extend({method:I("notifications/roots/list_changed"),params:ft.optional()});ge([Rs,Wg,Yy,Sy,py,zu,Ou,Au,Mu,ay,cy,Uu,vy,ca,ua,da,ha]);ge([aa,ia,Ru,rv,ss]);ge([vr,Fu,Hu,Ku,tv,la,fa,cn]);ge([Rs,Ra,Zu,ev,ca,ua,da,ha]);ge([aa,ia,Lu,uy,va,Ta,Ea,ss,Wy]);ge([vr,Tu,Gu,Du,$a,ma,_a,ya,or,Pa,la,fa,cn]);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===oe.UrlElicitationRequired&&n){const s=n;if(s.elicitations)return new nv(s.elicitations,r)}return new ne(t,r,n)}}class nv extends ne{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(oe.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){var t;return((t=this.data)==null?void 0:t.elicitations)??[]}}function Ca(e){return!!e._zod}function xt(e,t){return Ca(e)?Yl(e,t):e.safeParse(t)}function Wu(e){var r,n;if(!e)return;let t;if(Ca(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(Ca(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 Gt(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Ic(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 jc(e,t){const r=xt(e,t);if(!r.success)throw r.error;return r.data}const sv=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(aa,r=>{this._oncancel(r)}),this.setNotificationHandler(ia,r=>{this._onprogress(r)}),this.setRequestHandler(Rs,r=>({})),this._taskStore=t==null?void 0:t.taskStore,this._taskMessageQueue=t==null?void 0:t.taskMessageQueue,this._taskStore&&(this.setRequestHandler(ca,async(r,n)=>{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new ne(oe.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(ua,async(r,n)=>{const s=async()=>{var i;const o=r.params.taskId;if(this._taskMessageQueue){let c;for(;c=await this._taskMessageQueue.dequeue(o,n.sessionId);){if(c.type==="response"||c.type==="error"){const l=c.message,d=l.id,f=this._requestResolvers.get(d);if(f)if(this._requestResolvers.delete(d),c.type==="response")f(l);else{const y=l,g=new ne(y.error.code,y.error.message,y.error.data);f(g)}else{const y=c.type==="response"?"Response":"Error";this._onerror(new Error(`${y} handler missing for request ${d}`))}continue}await((i=this._transport)==null?void 0:i.send(c.message,{relatedRequestId:n.requestId}))}}const a=await this._taskStore.getTask(o,n.sessionId);if(!a)throw new ne(oe.InvalidParams,`Task not found: ${o}`);if(!Gt(a.status))return await this._waitForTaskUpdate(o,n.signal),await s();if(Gt(a.status)){const c=await this._taskStore.getTaskResult(o,n.sessionId);return this._clearTaskQueue(o),{...c,_meta:{...c._meta,[Yt]:{taskId:o}}}}return await s()};return await s()}),this.setRequestHandler(da,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(oe.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(ha,async(r,n)=>{try{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new ne(oe.InvalidParams,`Task not found: ${r.params.taskId}`);if(Gt(s.status))throw new ne(oe.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(oe.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(s){throw s instanceof ne?s:new ne(oe.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(oe.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),Zr(c)||Dg(c)?this._onresponse(c):ho(c)?this._onrequest(c,l):qg(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(oe.ConnectionClosed,"Connection closed");this._transport=void 0,(n=this.onclose)==null||n.call(this);for(const s of t.values())s(r)}_onerror(t){var r;(r=this.onerror)==null||r.call(this,t)}_onnotification(t){const r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){var d,f,y,g;const n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,s=this._transport,o=(y=(f=(d=t.params)==null?void 0:d._meta)==null?void 0:f[Yt])==null?void 0:y.taskId;if(n===void 0){const m={jsonrpc:"2.0",id:t.id,error:{code:oe.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=xg(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,_)=>{var S;if(a.signal.aborted)throw new ne(oe.ConnectionClosed,"Request was cancelled");const h={..._,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:oe.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),Zr(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(Zr(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),Zr(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(oe.InternalError,String(c))}}return}let o;try{const c=await this.request(t,cn,n);if(c.task)o=c.task.taskId,yield{type:"taskCreated",task:c.task};else throw new ne(oe.InternalError,"Task creation did not return a task");for(;;){const l=await this.getTask({taskId:o},n);if(yield{type:"taskStatus",task:l},Gt(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(oe.InternalError,`Task ${o} failed`)}:l.status==="cancelled"&&(yield{type:"error",error:new ne(oe.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(oe.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,R,k,M;const f=x=>{d(x)};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(x){f(x);return}(S=n==null?void 0:n.signal)==null||S.throwIfAborted();const y=this._requestMessageId++,g={...t,jsonrpc:"2.0",id:y};n!=null&&n.onprogress&&(this._progressHandlers.set(y,n.onprogress),g.params={...t.params,_meta:{...((R=t.params)==null?void 0:R._meta)||{},progressToken:y}}),i&&(g.params={...g.params,task:i}),c&&(g.params={...g.params,_meta:{...((k=g.params)==null?void 0:k._meta)||{},[Yt]:c}});const m=x=>{var J;this._responseHandlers.delete(y),this._progressHandlers.delete(y),this._cleanupTimeout(y),(J=this._transport)==null||J.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:y,reason:String(x)}},{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a}).catch(H=>this._onerror(new Error(`Failed to send cancellation: ${H}`)));const K=x instanceof ne?x:new ne(oe.RequestTimeout,String(x));d(K)};this._responseHandlers.set(y,x=>{var K;if(!((K=n==null?void 0:n.signal)!=null&&K.aborted)){if(x instanceof Error)return d(x);try{const J=xt(r,x.result);J.success?l(J.data):d(J.error)}catch(J){d(J)}}}),(M=n==null?void 0:n.signal)==null||M.addEventListener("abort",()=>{var x;m((x=n==null?void 0:n.signal)==null?void 0:x.reason)});const v=(n==null?void 0:n.timeout)??sv,_=()=>m(ne.fromError(oe.RequestTimeout,"Request timed out",{timeout:v}));this._setupTimeout(y,v,n==null?void 0:n.maxTotalTimeout,_,(n==null?void 0:n.resetTimeoutOnProgress)??!1);const h=c==null?void 0:c.taskId;if(h){const x=K=>{const J=this._responseHandlers.get(y);J?J(K):this._onerror(new Error(`Response handler missing for side-channeled request ${y}`))};this._requestResolvers.set(y,x),this._enqueueTaskMessage(h,{type:"request",message:g,timestamp:Date.now()}).catch(K=>{this._cleanupTimeout(y),d(K)})}else this._transport.send(g,{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a}).catch(x=>{this._cleanupTimeout(y),d(x)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},la,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},fa,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},ry,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)||{},[Yt]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:f,timestamp:Date.now()});return}if((((l=this._options)==null?void 0:l.debouncedNotificationMethods)??[]).includes(t.method)&&!t.params&&!(r!=null&&r.relatedRequestId)&&!(r!=null&&r.relatedTask)){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{var y,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:{...((y=f.params)==null?void 0:y._meta)||{},[Yt]: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)||{},[Yt]:r.relatedTask}}}),await this._transport.send(a,r)}setRequestHandler(t,r){const n=Ic(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,o)=>{const a=jc(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=Ic(t);this._notificationHandlers.set(n,s=>{const o=jc(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"&&ho(s.message)){const o=s.message.id,a=this._requestResolvers.get(o);a?(a(new ne(oe.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(oe.InvalidRequest,"Request cancelled"));return}const c=setTimeout(a,n);r.addEventListener("abort",()=>{clearTimeout(c),i(new ne(oe.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(oe.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=ss.parse({method:"notifications/tasks/status",params:i});await this.notification(c),Gt(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(oe.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(Gt(i.status))throw new ne(oe.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=ss.parse({method:"notifications/tasks/status",params:c});await this.notification(l),Gt(c.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>n.listTasks(s,r)}}}function Oc(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ov(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];Oc(a)&&Oc(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 av extends Ju{constructor(){super(...arguments);de(this,"_registeredMethods",new Set);de(this,"_eventSlots",new Map);de(this,"setRequestHandler",(r,n)=>{this._assertMethodNotRegistered(r,"setRequestHandler"),super.setRequestHandler(r,n)});de(this,"setNotificationHandler",(r,n)=>{this._assertMethodNotRegistered(r,"setNotificationHandler"),super.setNotificationHandler(r,n)});de(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",iv="ui/notifications/tool-input-partial",cv=ge([I("light"),I("dark")]).describe("Color theme preference for the host environment."),ln=ge([I("inline"),I("fullscreen"),I("pip")]).describe("Display mode for UI presentation."),lv=ge([I("--color-background-primary"),I("--color-background-secondary"),I("--color-background-tertiary"),I("--color-background-inverse"),I("--color-background-ghost"),I("--color-background-info"),I("--color-background-danger"),I("--color-background-success"),I("--color-background-warning"),I("--color-background-disabled"),I("--color-text-primary"),I("--color-text-secondary"),I("--color-text-tertiary"),I("--color-text-inverse"),I("--color-text-ghost"),I("--color-text-info"),I("--color-text-danger"),I("--color-text-success"),I("--color-text-warning"),I("--color-text-disabled"),I("--color-border-primary"),I("--color-border-secondary"),I("--color-border-tertiary"),I("--color-border-inverse"),I("--color-border-ghost"),I("--color-border-info"),I("--color-border-danger"),I("--color-border-success"),I("--color-border-warning"),I("--color-border-disabled"),I("--color-ring-primary"),I("--color-ring-secondary"),I("--color-ring-inverse"),I("--color-ring-info"),I("--color-ring-danger"),I("--color-ring-success"),I("--color-ring-warning"),I("--font-sans"),I("--font-mono"),I("--font-weight-normal"),I("--font-weight-medium"),I("--font-weight-semibold"),I("--font-weight-bold"),I("--font-text-xs-size"),I("--font-text-sm-size"),I("--font-text-md-size"),I("--font-text-lg-size"),I("--font-heading-xs-size"),I("--font-heading-sm-size"),I("--font-heading-md-size"),I("--font-heading-lg-size"),I("--font-heading-xl-size"),I("--font-heading-2xl-size"),I("--font-heading-3xl-size"),I("--font-text-xs-line-height"),I("--font-text-sm-line-height"),I("--font-text-md-line-height"),I("--font-text-lg-line-height"),I("--font-heading-xs-line-height"),I("--font-heading-sm-line-height"),I("--font-heading-md-line-height"),I("--font-heading-lg-line-height"),I("--font-heading-xl-line-height"),I("--font-heading-2xl-line-height"),I("--font-heading-3xl-line-height"),I("--border-radius-xs"),I("--border-radius-sm"),I("--border-radius-md"),I("--border-radius-lg"),I("--border-radius-xl"),I("--border-radius-full"),I("--border-width-regular"),I("--shadow-hairline"),I("--shadow-sm"),I("--shadow-md"),I("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),uv=ve(lv.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.`),ge([P(),co()]).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.`),dv=A({method:I("ui/open-link"),params:A({url:P().describe("URL to open in the host's browser")})});A({isError:ye().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough();A({isError:ye().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough();A({isError:ye().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();var fv=A({method:I("ui/notifications/sandbox-proxy-ready"),params:A({})}),Na=A({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'`)")}),Ia=A({camera:A({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:A({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:A({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:A({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),hv=A({method:I("ui/notifications/size-changed"),params:A({width:ue().optional().describe("New width in pixels."),height:ue().optional().describe("New height in pixels.")})});A({method:I("ui/notifications/tool-input"),params:A({arguments:ve(P(),Se().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})});A({method:I("ui/notifications/tool-input-partial"),params:A({arguments:ve(P(),Se().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})});A({method:I("ui/notifications/tool-cancelled"),params:A({reason:P().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})});var pv=A({fonts:P().optional()}),mv=A({variables:uv.optional().describe("CSS variables for theming the app."),css:pv.optional().describe("CSS blocks that apps can inject.")});A({method:I("ui/resource-teardown"),params:A({})});var _v=ve(P(),Se()),Ac=A({text:A({}).optional().describe("Host supports text content blocks."),image:A({}).optional().describe("Host supports image content blocks."),audio:A({}).optional().describe("Host supports audio content blocks."),resource:A({}).optional().describe("Host supports resource content blocks."),resourceLink:A({}).optional().describe("Host supports resource link content blocks."),structuredContent:A({}).optional().describe("Host supports structured content.")}),gv=A({method:I("ui/notifications/request-teardown"),params:A({}).optional()}),yv=A({experimental:ve(P(),ve(P(),ta()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:A({}).optional().describe("Host supports opening external URLs."),downloadFile:A({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:A({listChanged:ye().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:A({listChanged:ye().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:A({}).optional().describe("Host accepts log messages."),sandbox:A({permissions:Ia.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:Na.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:Ac.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:Ac.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:A({tools:A({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.")}).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")}),vv=A({experimental:ve(P(),ve(P(),ta()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:A({listChanged:ye().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:L(ln).optional().describe("Display modes the app supports.")}),$v=A({method:I("ui/notifications/initialized"),params:A({}).optional()});A({csp:Na.optional().describe("Content Security Policy configuration for UI resources."),permissions:Ia.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 Mc=A({method:I("ui/request-display-mode"),params:A({mode:ln.describe("The display mode being requested.")})});A({mode:ln.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough();var wv=ge([I("model"),I("app")]).describe("Tool visibility scope - who can access the tool.");A({resourceUri:P().optional(),visibility:L(wv).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:lo().optional(),permissions:lo().optional()});A({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 bv=A({method:I("ui/download-file"),params:A({contents:L(ge([xu,qu])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),Sv=A({method:I("ui/message"),params:A({role:I("user").describe('Message role, currently only "user" is supported.'),content:L(wn).describe("Message content blocks (text, image, etc.).")})});A({method:I("ui/notifications/sandbox-resource-ready"),params:A({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:Na.optional().describe("CSP configuration from resource metadata."),permissions:Ia.optional().describe("Sandbox permissions from resource metadata.")})});A({method:I("ui/notifications/tool-result"),params:or.describe("Standard MCP tool execution result.")});var Yu=A({toolInfo:A({id:mn.optional().describe("JSON-RPC id of the tools/call request."),tool:ka.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:cv.optional().describe("Current color theme preference."),styles:mv.optional().describe("Style configuration for theming the app."),displayMode:ln.optional().describe("How the UI is currently displayed."),availableDisplayModes:L(ln).optional().describe("Display modes the host supports."),containerDimensions:ge([A({height:ue().describe("Fixed container height in pixels.")}),A({maxHeight:ge([ue(),co()]).optional().describe("Maximum container height in pixels.")})]).and(ge([A({width:ue().describe("Fixed container width in pixels.")}),A({maxWidth:ge([ue(),co()]).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:ge([I("web"),I("desktop"),I("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:A({touch:ye().optional().describe("Whether the device supports touch input."),hover:ye().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:A({top:ue().describe("Top safe area inset in pixels."),right:ue().describe("Right safe area inset in pixels."),bottom:ue().describe("Bottom safe area inset in pixels."),left:ue().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough();A({method:I("ui/notifications/host-context-changed"),params:Yu.describe("Partial context update containing only changed fields.")});var Ev=A({method:I("ui/update-model-context"),params:A({content:L(wn).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.")})}),kv=A({method:I("ui/initialize"),params:A({appInfo:Ts.describe("App identification (name and version)."),appCapabilities:vv.describe("Features and capabilities this app provides."),protocolVersion:P().describe("Protocol version this app supports.")})});A({protocolVersion:P().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Ts.describe("Host application identification and version."),hostCapabilities:yv.describe("Features and capabilities provided by the host."),hostContext:Yu.describe("Rich context about the host environment.")}).passthrough();class Pv{constructor(t=window.parent,r){de(this,"eventTarget");de(this,"eventSource");de(this,"messageListener");de(this,"onclose");de(this,"onerror");de(this,"onmessage");de(this,"sessionId");de(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=Hn.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!==iv&&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 Tv=[Qu];class Rv extends av{constructor(r,n,s,o){super(o);de(this,"_client");de(this,"_hostInfo");de(this,"_capabilities");de(this,"_appCapabilities");de(this,"_hostContext",{});de(this,"_appInfo");de(this,"_initializedReceived",!1);de(this,"_baseReplaceRequestHandler",this.replaceRequestHandler);de(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)))});de(this,"eventSchemas",{sizechange:hv,sandboxready:fv,initialized:$v,requestteardown:gv,loggingmessage:Lu});de(this,"onping");de(this,"_onmessage");de(this,"_onopenlink");de(this,"_ondownloadfile");de(this,"_onrequestdisplaymode");de(this,"_onupdatemodelcontext");de(this,"_oncalltool");de(this,"_onlistresources");de(this,"_onlistresourcetemplates");de(this,"_onreadresource");de(this,"_onlistprompts");de(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(kv,a=>this._oninitialize(a)),this.setRequestHandler(Rs,(a,i)=>{var c;return(c=this.onping)==null||c.call(this,a.params,i),{}}),this.replaceRequestHandler(Mc,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(Sv,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(dv,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(bv,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(Mc,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(Ev,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(Ra,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:Tv.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];Cv(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},or,n)}listTools(r,n){return this.request({method:"tools/list",params:r},Pa,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},or,{signal:o.signal}),n.tools.listChanged&&this._client.setNotificationHandler(Ta,s=>this.sendToolListChanged(s.params))),n.resources&&(this.onlistresources=async(s,o)=>this._client.request({method:"resources/list",params:s},ma,{signal:o.signal}),this.onlistresourcetemplates=async(s,o)=>this._client.request({method:"resources/templates/list",params:s},_a,{signal:o.signal}),this.onreadresource=async(s,o)=>this._client.request({method:"resources/read",params:s},ya,{signal:o.signal}),n.resources.listChanged&&this._client.setNotificationHandler(va,s=>this.sendResourceListChanged(s.params))),n.prompts&&(this.onlistprompts=async(s,o)=>this._client.request({method:"prompts/list",params:s},$a,{signal:o.signal}),n.prompts.listChanged&&this._client.setNotificationHandler(Ea,s=>this.sendPromptListChanged(s.params)))}return super.connect(r)}}function Cv(e,t){return JSON.stringify(e)===JSON.stringify(t)}var po={exports:{}},Xu={},bt={},Tr={},bn={},_e={},un={};(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,R)=>`${S}${R}`,"")}get names(){var $;return($=this._names)!==null&&$!==void 0?$:this._names=this._items.reduce((S,R)=>(R instanceof r&&(S[R.str]=(S[R.str]||0)+1),S),{})}}e._Code=n,e.nil=new n("");function s(h,...$){const S=[h[0]];let R=0;for(;R<$.length;)i(S,$[R]),S.push(h[++R]);return new n(S)}e._=s;const o=new n("+");function a(h,...$){const S=[g(h[0])];let R=0;for(;R<$.length;)S.push(o),i(S,$[R]),S.push(o,g(h[++R]));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,y=>{if(y.value===void 0)throw new Error(`CodeGen: name "${y}" has no value`);return y.value.code},d,f)}_reduceValues(l,d,f={},y){let g=t.nil;for(const m in l){const v=l[m];if(!v)continue;const _=f[m]=f[m]||new Map;v.forEach(h=>{if(_.has(h))return;_.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($=y==null?void 0:y(h))g=(0,t._)`${g}${$}${this.opts._n}`;else throw new r(h);_.set(h,n.Completed)})}return g}}e.ValueScope=i})(mo);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=un,r=mo;var n=un;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}});var s=mo;Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class o{optimizeNodes(){return this}optimizeNames(u,p){return this}}class a extends o{constructor(u,p,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 y extends o{constructor(u){super(),this.code=u}render({_n:u}){return`${this.code};`+u}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(u,p){return this.code=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)||(ae(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 _ extends m{}_.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 _(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 R 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 M 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)}}M.kind="func";class x extends g{render(u){return"return "+super.render(u)}}x.kind="return";class K 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 J extends m{constructor(u){super(),this.error=u}render(u){return`catch(${this.error})`+super.render(u)}}J.kind="catch";class H extends m{render(u){return"finally"+super.render(u)}}H.kind="finally";class Z{constructor(u,p={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...p,_n:p.lines?` +`:""},this._extScope=u,this._scope=new r.Scope({parent:u}),this._nodes=[new 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 y(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 _)}endIf(){return this._endBlockNode(h,_)}_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 R(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`,B=>{this.var(D,(0,t._)`${Y}[${B}]`),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 x;if(this._blockNode(p),this.code(u),p.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(x)}try(u,p,E){if(!p&&!E)throw new Error('CodeGen: "try" without "catch" and "finally"');const q=new K;if(this._blockNode(q),this.code(u),p){const D=this.name("e");this._currNode=q.catch=new J(D),p(D)}return E&&(this._currNode=q.finally=new H,this.code(E)),this._endBlockNode(J,H)}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 M(u,p,E)),q&&this.code(q).endFunc(),this}endFunc(){return this._endBlockNode(M)}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=Z;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 ae(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 it(...b){return b.reduce($e)}e.and=it;const Oe=w(e.operators.OR);function O(...b){return b.reduce(Oe)}e.or=O;function w(b){return(u,p)=>u===t.nil?p:p===t.nil?u:(0,t._)`${C(u)} ${b} ${C(p)}`}function C(b){return b instanceof t.Name?b:(0,t._)`(${b})`}})(_e);var G={};Object.defineProperty(G,"__esModule",{value:!0});G.checkStrictMode=G.getErrorPath=G.Type=G.useFunc=G.setEvaluated=G.evaluatedPropsToName=G.mergeEvaluated=G.eachItem=G.unescapeJsonPointer=G.escapeJsonPointer=G.escapeFragment=G.unescapeFragment=G.schemaRefOrVal=G.schemaHasRulesButRef=G.schemaHasRules=G.checkUnknownRules=G.alwaysValidSchema=G.toHash=void 0;const we=_e,Nv=un;function Iv(e){const t={};for(const r of e)t[r]=!0;return t}G.toHash=Iv;function jv(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(ed(e,t),!td(t,e.self.RULES.all))}G.alwaysValidSchema=jv;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}"`)}G.checkUnknownRules=ed;function td(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(t[r])return!0;return!1}G.schemaHasRules=td;function Ov(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}G.schemaHasRulesButRef=Ov;function Av({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)}`}G.schemaRefOrVal=Av;function Mv(e){return rd(decodeURIComponent(e))}G.unescapeFragment=Mv;function zv(e){return encodeURIComponent(ja(e))}G.escapeFragment=zv;function ja(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}G.escapeJsonPointer=ja;function rd(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}G.unescapeJsonPointer=rd;function xv(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)}G.eachItem=xv;function zc({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(s,o,a,i)=>{const c=a===void 0?o:a instanceof we.Name?(o instanceof we.Name?e(s,o,a):t(s,o,a),a):o instanceof we.Name?(t(s,a,o),o):r(o,a);return i===we.Name&&!(c instanceof we.Name)?n(s,c):c}}G.mergeEvaluated={props:zc({mergeNames:(e,t,r)=>e.if((0,we._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,we._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,we._)`${r} || {}`).code((0,we._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,we._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,we._)`${r} || {}`),Oa(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:nd}),items:zc({mergeNames:(e,t,r)=>e.if((0,we._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,we._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,we._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,we._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function nd(e,t){if(t===!0)return e.var("props",!0);const r=e.var("props",(0,we._)`{}`);return t!==void 0&&Oa(e,r,t),r}G.evaluatedPropsToName=nd;function Oa(e,t,r){Object.keys(r).forEach(n=>e.assign((0,we._)`${t}${(0,we.getProperty)(n)}`,!0))}G.setEvaluated=Oa;const xc={};function qv(e,t){return e.scopeValue("func",{ref:t,code:xc[t.code]||(xc[t.code]=new Nv._Code(t.code))})}G.useFunc=qv;var _o;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(_o||(G.Type=_o={}));function Dv(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():"/"+ja(e)}G.getErrorPath=Dv;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)}}G.checkStrictMode=sd;var Tt={};Object.defineProperty(Tt,"__esModule",{value:!0});const Xe=_e,Uv={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")};Tt.default=Uv;(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=_e,r=G,n=Tt;e.keywordError={message:({keyword:_})=>(0,t.str)`must pass "${_}" keyword validation`},e.keyword$DataError={message:({keyword:_,schemaType:h})=>h?(0,t.str)`"${_}" keyword must be ${h} ($data)`:(0,t.str)`"${_}" keyword is invalid ($data)`};function s(_,h=e.keywordError,$,S){const{it:R}=_,{gen:k,compositeRule:M,allErrors:x}=R,K=f(_,h,$);S??(M||x)?c(k,K):l(R,(0,t._)`[${K}]`)}e.reportError=s;function o(_,h=e.keywordError,$){const{it:S}=_,{gen:R,compositeRule:k,allErrors:M}=S,x=f(_,h,$);c(R,x),k||M||l(S,n.default.vErrors)}e.reportExtraError=o;function a(_,h){_.assign(n.default.errors,h),_.if((0,t._)`${n.default.vErrors} !== null`,()=>_.if(h,()=>_.assign((0,t._)`${n.default.vErrors}.length`,h),()=>_.assign(n.default.vErrors,null)))}e.resetErrorsCount=a;function i({gen:_,keyword:h,schemaValue:$,data:S,errsCount:R,it:k}){if(R===void 0)throw new Error("ajv implementation error");const M=_.name("err");_.forRange("i",R,n.default.errors,x=>{_.const(M,(0,t._)`${n.default.vErrors}[${x}]`),_.if((0,t._)`${M}.instancePath === undefined`,()=>_.assign((0,t._)`${M}.instancePath`,(0,t.strConcat)(n.default.instancePath,k.errorPath))),_.assign((0,t._)`${M}.schemaPath`,(0,t.str)`${k.errSchemaPath}/${h}`),k.opts.verbose&&(_.assign((0,t._)`${M}.schema`,$),_.assign((0,t._)`${M}.data`,S))})}e.extendErrors=i;function c(_,h){const $=_.const("err",h);_.if((0,t._)`${n.default.vErrors} === null`,()=>_.assign(n.default.vErrors,(0,t._)`[${$}]`),(0,t._)`${n.default.vErrors}.push(${$})`),_.code((0,t._)`${n.default.errors}++`)}function l(_,h){const{gen:$,validateName:S,schemaEnv:R}=_;R.$async?$.throw((0,t._)`new ${_.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(_,h,$){const{createErrors:S}=_.it;return S===!1?(0,t._)`{}`:y(_,h,$)}function y(_,h,$={}){const{gen:S,it:R}=_,k=[g(R,$),m(_,$)];return v(_,h,k),S.object(...k)}function g({errorPath:_},{instancePath:h}){const $=h?(0,t.str)`${_}${(0,r.getErrorPath)(h,r.Type.Str)}`:_;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,$)]}function m({keyword:_,it:{errSchemaPath:h}},{schemaPath:$,parentSchema:S}){let R=S?h:(0,t.str)`${h}/${_}`;return $&&(R=(0,t.str)`${R}${(0,r.getErrorPath)($,r.Type.Str)}`),[d.schemaPath,R]}function v(_,{params:h,message:$},S){const{keyword:R,data:k,schemaValue:M,it:x}=_,{opts:K,propertyName:J,topSchemaRef:H,schemaPath:Z}=x;S.push([d.keyword,R],[d.params,typeof h=="function"?h(_):h||(0,t._)`{}`]),K.messages&&S.push([d.message,typeof $=="function"?$(_):$]),K.verbose&&S.push([d.schema,M],[d.parentSchema,(0,t._)`${H}${Z}`],[n.default.data,k]),J&&S.push([d.propertyName,J])}})(bn);Object.defineProperty(Tr,"__esModule",{value:!0});Tr.boolOrEmptySchema=Tr.topBoolOrEmptySchema=void 0;const Vv=bn,Lv=_e,Fv=Tt,Hv={message:"boolean schema is false"};function Zv(e){const{gen:t,schema:r,validateName:n}=e;r===!1?od(e,!1):typeof r=="object"&&r.$async===!0?t.return(Fv.default.data):(t.assign((0,Lv._)`${n}.errors`,null),t.return(!0))}Tr.topBoolOrEmptySchema=Zv;function Kv(e,t){const{gen:r,schema:n}=e;n===!1?(r.var(t,!1),od(e)):r.var(t,!0)}Tr.boolOrEmptySchema=Kv;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,Vv.reportError)(s,Hv,void 0,t)}var qe={},ar={};Object.defineProperty(ar,"__esModule",{value:!0});ar.getRules=ar.isJSONType=void 0;const Gv=["string","number","integer","boolean","null","object","array"],Wv=new Set(Gv);function Bv(e){return typeof e=="string"&&Wv.has(e)}ar.isJSONType=Bv;function Jv(){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:{}}}ar.getRules=Jv;var It={};Object.defineProperty(It,"__esModule",{value:!0});It.shouldUseRule=It.shouldUseGroup=It.schemaHasRulesForType=void 0;function Qv({schema:e,self:t},r){const n=t.RULES.types[r];return n&&n!==!0&&ad(e,n)}It.schemaHasRulesForType=Qv;function ad(e,t){return t.rules.some(r=>id(e,r))}It.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))}It.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 Yv=ar,Xv=It,e$=bn,ce=_e,cd=G;var br;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(br||(qe.DataType=br={}));function t$(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=t$;function ld(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(Yv.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}qe.getJSONTypes=ld;function r$(e,t){const{gen:r,data:n,opts:s}=e,o=n$(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0,Xv.schemaHasRulesForType)(e,t[0]));if(a){const i=Aa(t,n,s.strictNumbers,br.Wrong);r.if(i,()=>{o.length?s$(e,t,o):Ma(e)})}return a}qe.coerceAndCheckDataType=r$;const ud=new Set(["string","number","integer","boolean","null"]);function n$(e,t){return t?e.filter(r=>ud.has(r)||t==="array"&&r==="array"):[]}function s$(e,t,r){const{gen:n,data:s,opts:o}=e,a=n.let("dataType",(0,ce._)`typeof ${s}`),i=n.let("coerced",(0,ce._)`undefined`);o.coerceTypes==="array"&&n.if((0,ce._)`${a} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,ce._)`${s}[0]`).assign(a,(0,ce._)`typeof ${s}`).if(Aa(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0,ce._)`${i} !== undefined`);for(const l of r)(ud.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),Ma(e),n.endIf(),n.if((0,ce._)`${i} !== undefined`,()=>{n.assign(s,i),o$(e,i)});function c(l){switch(l){case"string":n.elseIf((0,ce._)`${a} == "number" || ${a} == "boolean"`).assign(i,(0,ce._)`"" + ${s}`).elseIf((0,ce._)`${s} === null`).assign(i,(0,ce._)`""`);return;case"number":n.elseIf((0,ce._)`${a} == "boolean" || ${s} === null + || (${a} == "string" && ${s} && ${s} == +${s})`).assign(i,(0,ce._)`+${s}`);return;case"integer":n.elseIf((0,ce._)`${a} === "boolean" || ${s} === null + || (${a} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(i,(0,ce._)`+${s}`);return;case"boolean":n.elseIf((0,ce._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(i,!1).elseIf((0,ce._)`${s} === "true" || ${s} === 1`).assign(i,!0);return;case"null":n.elseIf((0,ce._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(i,null);return;case"array":n.elseIf((0,ce._)`${a} === "string" || ${a} === "number" + || ${a} === "boolean" || ${s} === null`).assign(i,(0,ce._)`[${s}]`)}}}function o$({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,ce._)`${t} !== undefined`,()=>e.assign((0,ce._)`${t}[${r}]`,n))}function go(e,t,r,n=br.Correct){const s=n===br.Correct?ce.operators.EQ:ce.operators.NEQ;let o;switch(e){case"null":return(0,ce._)`${t} ${s} null`;case"array":o=(0,ce._)`Array.isArray(${t})`;break;case"object":o=(0,ce._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=a((0,ce._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=a();break;default:return(0,ce._)`typeof ${t} ${s} ${e}`}return n===br.Correct?o:(0,ce.not)(o);function a(i=ce.nil){return(0,ce.and)((0,ce._)`typeof ${t} == "number"`,i,r?(0,ce._)`isFinite(${t})`:ce.nil)}}qe.checkDataType=go;function Aa(e,t,r,n){if(e.length===1)return go(e[0],t,r,n);let s;const o=(0,cd.toHash)(e);if(o.array&&o.object){const a=(0,ce._)`typeof ${t} != "object"`;s=o.null?a:(0,ce._)`!${t} || ${a}`,delete o.null,delete o.array,delete o.object}else s=ce.nil;o.number&&delete o.integer;for(const a in o)s=(0,ce.and)(s,go(a,t,r,n));return s}qe.checkDataTypes=Aa;const a$={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,ce._)`{type: ${e}}`:(0,ce._)`{type: ${t}}`};function Ma(e){const t=i$(e);(0,e$.reportError)(t,a$)}qe.reportTypeError=Ma;function i$(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 Cs={};Object.defineProperty(Cs,"__esModule",{value:!0});Cs.assignDefaults=void 0;const fr=_e,c$=G;function l$(e,t){const{properties:r,items:n}=e.schema;if(t==="object"&&r)for(const s in r)qc(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>qc(e,o,s.default))}Cs.assignDefaults=l$;function qc(e,t,r){const{gen:n,compositeRule:s,data:o,opts:a}=e;if(r===void 0)return;const i=(0,fr._)`${o}${(0,fr.getProperty)(t)}`;if(s){(0,c$.checkStrictMode)(e,`default is ignored for: ${i}`);return}let c=(0,fr._)`${i} === undefined`;a.useDefaults==="empty"&&(c=(0,fr._)`${c} || ${i} === null || ${i} === ""`),n.if(c,(0,fr._)`${i} = ${(0,fr.stringify)(r)}`)}var Pt={},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=_e,za=G,Ot=Tt,u$=G;function d$(e,t){const{gen:r,data:n,it:s}=e;r.if(qa(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Pe._)`${t}`},!0),e.error()})}pe.checkReportMissingProp=d$;function f$({gen:e,data:t,it:{opts:r}},n,s){return(0,Pe.or)(...n.map(o=>(0,Pe.and)(qa(e,t,o,r.ownProperties),(0,Pe._)`${s} = ${o}`)))}pe.checkMissingProp=f$;function h$(e,t){e.setParams({missingProperty:t},!0),e.error()}pe.reportMissingProp=h$;function dd(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Pe._)`Object.prototype.hasOwnProperty`})}pe.hasPropFunc=dd;function xa(e,t,r){return(0,Pe._)`${dd(e)}.call(${t}, ${r})`}pe.isOwnProperty=xa;function p$(e,t,r,n){const s=(0,Pe._)`${t}${(0,Pe.getProperty)(r)} !== undefined`;return n?(0,Pe._)`${s} && ${xa(e,t,r)}`:s}pe.propertyInData=p$;function qa(e,t,r,n){const s=(0,Pe._)`${t}${(0,Pe.getProperty)(r)} === undefined`;return n?(0,Pe.or)(s,(0,Pe.not)(xa(e,t,r))):s}pe.noPropertyInData=qa;function fd(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}pe.allSchemaProperties=fd;function m$(e,t){return fd(t).filter(r=>!(0,za.alwaysValidSchema)(e,t[r]))}pe.schemaProperties=m$;function _$({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=[[Ot.default.instancePath,(0,Pe.strConcat)(Ot.default.instancePath,o)],[Ot.default.parentData,a.parentData],[Ot.default.parentDataProperty,a.parentDataProperty],[Ot.default.rootData,Ot.default.rootData]];a.opts.dynamicRef&&f.push([Ot.default.dynamicAnchors,Ot.default.dynamicAnchors]);const y=(0,Pe._)`${d}, ${r.object(...f)}`;return c!==Pe.nil?(0,Pe._)`${i}.call(${c}, ${y})`:(0,Pe._)`${i}(${y})`}pe.callValidateCode=_$;const g$=(0,Pe._)`new RegExp`;function y$({gen:e,it:{opts:t}},r){const n=t.unicodeRegExp?"u":"",{regExp:s}=t.code,o=s(r,n);return e.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,Pe._)`${s.code==="new RegExp"?g$:(0,u$.useFunc)(e,s)}(${r}, ${n})`})}pe.usePattern=y$;function v$(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:za.Type.Num},o),t.if((0,Pe.not)(o),i)})}}pe.validateArray=v$;function $$(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,za.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=$$;Object.defineProperty(Pt,"__esModule",{value:!0});Pt.validateKeywordUsage=Pt.validSchemaType=Pt.funcKeywordCode=Pt.macroKeywordCode=void 0;const tt=_e,Xt=Tt,w$=pe,b$=bn;function S$(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:tt.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},l),e.pass(l,()=>e.error(!0))}Pt.macroKeywordCode=S$;function E$(e,t){var r;const{gen:n,keyword:s,schema:o,parentSchema:a,$data:i,it:c}=e;P$(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,y),e.ok((r=t.valid)!==null&&r!==void 0?r:f);function y(){if(t.errors===!1)v(),t.modifying&&Dc(e),_(()=>e.error());else{const h=t.async?g():m();t.modifying&&Dc(e),_(()=>k$(e,h))}}function g(){const h=n.let("ruleErrs",null);return n.try(()=>v((0,tt._)`await `),$=>n.assign(f,!1).if((0,tt._)`${$} instanceof ${c.ValidationError}`,()=>n.assign(h,(0,tt._)`${$}.errors`),()=>n.throw($))),h}function m(){const h=(0,tt._)`${d}.errors`;return n.assign(h,null),v(tt.nil),h}function v(h=t.async?(0,tt._)`await `:tt.nil){const $=c.opts.passContext?Xt.default.this:Xt.default.self,S=!("compile"in t&&!i||t.schema===!1);n.assign(f,(0,tt._)`${h}${(0,w$.callValidateCode)(e,d,$,S)}`,t.modifying)}function _(h){var $;n.if((0,tt.not)(($=t.valid)!==null&&$!==void 0?$:f),h)}}Pt.funcKeywordCode=E$;function Dc(e){const{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,tt._)`${n.parentData}[${n.parentDataProperty}]`))}function k$(e,t){const{gen:r}=e;r.if((0,tt._)`Array.isArray(${t})`,()=>{r.assign(Xt.default.vErrors,(0,tt._)`${Xt.default.vErrors} === null ? ${t} : ${Xt.default.vErrors}.concat(${t})`).assign(Xt.default.errors,(0,tt._)`${Xt.default.vErrors}.length`),(0,b$.extendErrors)(e)},()=>e.error())}function P$({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,tt.stringify)(r)})}function T$(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")}Pt.validSchemaType=T$;function R$({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)}}Pt.validateKeywordUsage=R$;var Ut={};Object.defineProperty(Ut,"__esModule",{value:!0});Ut.extendSubschemaMode=Ut.extendSubschemaData=Ut.getSubschema=void 0;const kt=_e,pd=G;function C$(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,kt._)`${e.schemaPath}${(0,kt.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:i[r],schemaPath:(0,kt._)`${e.schemaPath}${(0,kt.getProperty)(t)}${(0,kt.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')}Ut.getSubschema=C$;function N$(e,t,{dataProp:r,dataPropType:n,data:s,dataTypes:o,propertyName:a}){if(s!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:i}=t;if(r!==void 0){const{errorPath:l,dataPathArr:d,opts:f}=t,y=i.let("data",(0,kt._)`${t.data}${(0,kt.getProperty)(r)}`,!0);c(y),e.errorPath=(0,kt.str)`${l}${(0,pd.getErrorPath)(r,n,f.jsPropertySyntax)}`,e.parentDataProperty=(0,kt._)`${r}`,e.dataPathArr=[...d,e.parentDataProperty]}if(s!==void 0){const l=s instanceof kt.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]}}Ut.extendSubschemaData=N$;function I$(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}Ut.extendSubschemaMode=I$;var Ge={},Ns=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:{}},qt=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(){};Zn(t,n,s,e,"",e)};qt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};qt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};qt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};qt.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 Zn(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 qt.arrayKeywords)for(var y=0;yt+=_d(n)),t===1/0))return 1/0}return t}function gd(e,t="",r){r!==!1&&(t=Sr(t));const n=e.parse(t);return yd(e,n)}Ge.getFullPath=gd;function yd(e,t){return e.serialize(t).split("#")[0]+"#"}Ge._getFullPath=yd;const U$=/#\/?$/;function Sr(e){return e?e.replace(U$,""):""}Ge.normalizeId=Sr;function V$(e,t,r){return r=Sr(r),e.resolve(t,r)}Ge.resolveUrl=V$;const L$=/^[a-z_][-a-z0-9._]*$/i;function F$(e,t){if(typeof e=="boolean")return{};const{schemaId:r,uriResolver:n}=this.opts,s=Sr(e[r]||t),o={"":s},a=gd(n,s,!1),i={},c=new Set;return z$(e,{allKeys:!0},(f,y,g,m)=>{if(m===void 0)return;const v=a+y;let _=o[m];typeof f[r]=="string"&&(_=h.call(this,f[r])),$.call(this,f.$anchor),$.call(this,f.$dynamicAnchor),o[y]=_;function h(S){const R=this.opts.uriResolver.resolve;if(S=Sr(_?R(_,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!==Sr(v)&&(S[0]==="#"?(l(f,i[S],S),i[S]=f):this.refs[S]=v),S}function $(S){if(typeof S=="string"){if(!L$.test(S))throw new Error(`invalid anchor "${S}"`);h.call(this,`#${S}`)}}}),i;function l(f,y,g){if(y!==void 0&&!M$(f,y))throw d(g)}function d(f){return new Error(`reference "${f}" resolves to more than one schema`)}}Ge.getSchemaRefs=F$;Object.defineProperty(bt,"__esModule",{value:!0});bt.getData=bt.KeywordCxt=bt.validateFunctionCode=void 0;const vd=Tr,Uc=qe,Da=It,as=qe,H$=Cs,Jr=Pt,Zs=Ut,te=_e,se=Tt,Z$=Ge,jt=G,Vr=bn;function K$(e){if(bd(e)&&(Sd(e),wd(e))){B$(e);return}$d(e,()=>(0,vd.topBoolOrEmptySchema)(e))}bt.validateFunctionCode=K$;function $d({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},o){s.code.es5?e.func(t,(0,te._)`${se.default.data}, ${se.default.valCxt}`,n.$async,()=>{e.code((0,te._)`"use strict"; ${Vc(r,s)}`),W$(e,s),e.code(o)}):e.func(t,(0,te._)`${se.default.data}, ${G$(s)}`,n.$async,()=>e.code(Vc(r,s)).code(o))}function G$(e){return(0,te._)`{${se.default.instancePath}="", ${se.default.parentData}, ${se.default.parentDataProperty}, ${se.default.rootData}=${se.default.data}${e.dynamicRef?(0,te._)`, ${se.default.dynamicAnchors}={}`:te.nil}}={}`}function W$(e,t){e.if(se.default.valCxt,()=>{e.var(se.default.instancePath,(0,te._)`${se.default.valCxt}.${se.default.instancePath}`),e.var(se.default.parentData,(0,te._)`${se.default.valCxt}.${se.default.parentData}`),e.var(se.default.parentDataProperty,(0,te._)`${se.default.valCxt}.${se.default.parentDataProperty}`),e.var(se.default.rootData,(0,te._)`${se.default.valCxt}.${se.default.rootData}`),t.dynamicRef&&e.var(se.default.dynamicAnchors,(0,te._)`${se.default.valCxt}.${se.default.dynamicAnchors}`)},()=>{e.var(se.default.instancePath,(0,te._)`""`),e.var(se.default.parentData,(0,te._)`undefined`),e.var(se.default.parentDataProperty,(0,te._)`undefined`),e.var(se.default.rootData,se.default.data),t.dynamicRef&&e.var(se.default.dynamicAnchors,(0,te._)`{}`)})}function B$(e){const{schema:t,opts:r,gen:n}=e;$d(e,()=>{r.$comment&&t.$comment&&kd(e),ew(e),n.let(se.default.vErrors,null),n.let(se.default.errors,0),r.unevaluated&&J$(e),Ed(e),nw(e)})}function J$(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 Vc(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 Q$(e,t){if(bd(e)&&(Sd(e),wd(e))){Y$(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 Y$(e,t){const{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&kd(e),tw(e),rw(e);const o=n.const("_errs",se.default.errors);Ed(e,o),n.var(t,(0,te._)`${o} === ${se.default.errors}`)}function Sd(e){(0,jt.checkUnknownRules)(e),X$(e)}function Ed(e,t){if(e.opts.jtd)return Lc(e,[],!1,t);const r=(0,Uc.getSchemaTypes)(e.schema),n=(0,Uc.coerceAndCheckDataType)(e,r);Lc(e,r,!n,t)}function X$(e){const{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,jt.schemaHasRulesButRef)(t,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function ew(e){const{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,jt.checkStrictMode)(e,"default is ignored in the schema root")}function tw(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,Z$.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function rw(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._)`${se.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._)`${se.default.self}.opts.$comment(${o}, ${a}, ${i}.schema)`)}}function nw(e){const{gen:t,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=e;r.$async?t.if((0,te._)`${se.default.errors} === 0`,()=>t.return(se.default.data),()=>t.throw((0,te._)`new ${s}(${se.default.vErrors})`)):(t.assign((0,te._)`${n}.errors`,se.default.vErrors),o.unevaluated&&sw(e),t.return((0,te._)`${se.default.errors} === 0`))}function sw({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 Lc(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,jt.schemaHasRulesButRef)(o,d))){s.block(()=>Rd(e,"$ref",d.all.$ref.definition));return}c.jtd||ow(e,t),s.block(()=>{for(const y of d.rules)f(y);f(d.post)});function f(y){(0,Da.shouldUseGroup)(o,y)&&(y.type?(s.if((0,as.checkDataType)(y.type,a,c.strictNumbers)),Fc(e,y),t.length===1&&t[0]===y.type&&r&&(s.else(),(0,as.reportTypeError)(e)),s.endIf()):Fc(e,y),i||s.if((0,te._)`${se.default.errors} === ${n||0}`))}}function Fc(e,t){const{gen:r,schema:n,opts:{useDefaults:s}}=e;s&&(0,H$.assignDefaults)(e,t.type),r.block(()=>{for(const o of t.rules)(0,Da.shouldUseRule)(n,o)&&Rd(e,o.keyword,o.definition,t.type)})}function ow(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(aw(e,t),e.opts.allowUnionTypes||iw(e,t),cw(e,e.dataTypes))}function aw(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{Pd(e.dataTypes,r)||Ua(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),uw(e,t)}}function iw(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Ua(e,"use allowUnionTypes to allow union type keyword")}function cw(e,t){const r=e.self.RULES.all;for(const n in r){const s=r[n];if(typeof s=="object"&&(0,Da.shouldUseRule)(e.schema,s)){const{type:o}=s.definition;o.length&&!o.some(a=>lw(t,a))&&Ua(e,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function lw(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 uw(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 Ua(e,t){const r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,jt.checkStrictMode)(e,t,e.opts.strictTypes)}class Td{constructor(t,r,n){if((0,Jr.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,jt.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,Jr.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",se.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?Vr.reportExtraError:Vr.reportError)(this,this.def.error,r)}$dataError(){(0,Vr.reportError)(this,this.def.$dataError||Vr.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Vr.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,as.checkDataTypes)(c,r,o.opts.strictNumbers,as.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,Zs.getSubschema)(this.it,t);(0,Zs.extendSubschemaData)(n,this.it,t),(0,Zs.extendSubschemaMode)(n,t);const s={...this.it,...n,items:void 0,props:void 0};return Q$(s,r),s}mergeEvaluated(t,r){const{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=jt.mergeEvaluated.props(s,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=jt.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}}bt.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,Jr.funcKeywordCode)(s,r):"macro"in r?(0,Jr.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,Jr.funcKeywordCode)(s,r)}const dw=/^\/(?:[^~]|~0|~1)*$/,fw=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Cd(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,o;if(e==="")return se.default.rootData;if(e[0]==="/"){if(!dw.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,o=se.default.rootData}else{const l=fw.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,jt.unescapeJsonPointer)(l))}`,a=(0,te._)`${a} && ${o}`);return a;function c(l,d){return`Cannot access ${l} ${d} levels up, current level is ${t}`}}bt.getData=Cd;var Sn={};Object.defineProperty(Sn,"__esModule",{value:!0});class hw extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}}Sn.default=hw;var jr={};Object.defineProperty(jr,"__esModule",{value:!0});const Ks=Ge;let pw=class extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Ks.resolveUrl)(t,r,n),this.missingSchema=(0,Ks.normalizeId)((0,Ks.getFullPath)(t,this.missingRef))}};jr.default=pw;var st={};Object.defineProperty(st,"__esModule",{value:!0});st.resolveSchema=st.getCompilingSchema=st.resolveRef=st.compileSchema=st.SchemaEnv=void 0;const mt=_e,mw=Sn,Wt=Tt,$t=Ge,Hc=G,_w=bt;let Is=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,$t.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={}}};st.SchemaEnv=Is;function Va(e){const t=Nd.call(this,e);if(t)return t;const r=(0,$t.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,a=new mt.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o});let i;e.$async&&(i=a.scopeValue("Error",{ref:mw.default,code:(0,mt._)`require("ajv/dist/runtime/validation_error").default`}));const c=a.scopeName("validate");e.validateName=c;const l={gen:a,allErrors:this.opts.allErrors,data:Wt.default.data,parentData:Wt.default.parentData,parentDataProperty:Wt.default.parentDataProperty,dataNames:[Wt.default.data],dataPathArr:[mt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,mt.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:mt.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,mt._)`""`,opts:this.opts,self:this};let d;try{this._compilations.add(e),(0,_w.validateFunctionCode)(l),a.optimize(this.opts.code.optimize);const f=a.toString();d=`${a.scopeRefs(Wt.default.scope)}return ${f}`,this.opts.code.process&&(d=this.opts.code.process(d,e));const g=new Function(`${Wt.default.self}`,`${Wt.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 mt.Name?void 0:m,items:v instanceof mt.Name?void 0:v,dynamicProps:m instanceof mt.Name,dynamicItems:v instanceof mt.Name},g.source&&(g.source.evaluated=(0,mt.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)}}st.compileSchema=Va;function gw(e,t,r){var n;r=(0,$t.resolveUrl)(this.opts.uriResolver,t,r);const s=e.refs[r];if(s)return s;let o=$w.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 Is({schema:a,schemaId:i,root:e,baseId:t}))}if(o!==void 0)return e.refs[r]=yw.call(this,o)}st.resolveRef=gw;function yw(e){return(0,$t.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Va.call(this,e)}function Nd(e){for(const t of this._compilations)if(vw(t,e))return t}st.getCompilingSchema=Nd;function vw(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function $w(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||js.call(this,e,t)}function js(e,t){const r=this.opts.uriResolver.parse(t),n=(0,$t._getFullPath)(this.opts.uriResolver,r);let s=(0,$t.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===s)return Gs.call(this,r,e);const o=(0,$t.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){const i=js.call(this,e,a);return typeof(i==null?void 0:i.schema)!="object"?void 0:Gs.call(this,r,i)}if(typeof(a==null?void 0:a.schema)=="object"){if(a.validate||Va.call(this,a),o===(0,$t.normalizeId)(t)){const{schema:i}=a,{schemaId:c}=this.opts,l=i[c];return l&&(s=(0,$t.resolveUrl)(this.opts.uriResolver,s,l)),new Is({schema:i,schemaId:c,root:e,baseId:s})}return Gs.call(this,r,a)}}st.resolveSchema=js;const ww=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Gs(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,Hc.unescapeFragment)(i)];if(c===void 0)return;r=c;const l=typeof r=="object"&&r[this.opts.schemaId];!ww.has(i)&&l&&(t=(0,$t.resolveUrl)(this.opts.uriResolver,t,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,Hc.schemaHasRulesButRef)(r,this.RULES)){const i=(0,$t.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=js.call(this,n,i)}const{schemaId:a}=this.opts;if(o=o||new Is({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}const bw="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",Sw="Meta-schema for $data reference (JSON AnySchema extension proposal)",Ew="object",kw=["$data"],Pw={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},Tw=!1,Rw={$id:bw,description:Sw,type:Ew,required:kw,properties:Pw,additionalProperties:Tw};var La={},Os={exports:{}};const Cw=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),Fa=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),jd=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),Nw=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 Iw=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Zc(e){return e.length=0,!0}function jw(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 Ow(e){let t=0;const r={error:!1,address:"",zone:""},n=[],s=[];let o=!1,a=!1,i=jw;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=Zc}else{s.push(l);continue}}return s.length&&(i===Zc?r.zone=s.join(""):a?n.push(s.join("")):n.push(Od(s))),r.address=n.join(""),r}function Ad(e){if(Aw(e,":")<2)return{host:e,isIPV6:!1};const t=Ow(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 Aw(e,t){let r=0;for(let n=0;nzw[n])}function Dw(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n65535))return"URI port is malformed."}function cs(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(m0);a!==null&&a[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",s=!0);const i=e.match(_0);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(p0);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=g0(n,c);if(l!==void 0&&(n.error=n.error||l,s=!0),n.host)if(c0(n.host)===!1){const y=r0(n.host);n.host=y.host.toLowerCase(),o=y.isIPV6}else o=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");const d=Vd(r.scheme||n.scheme);if(!r.unicodeSupport&&(!d||!d.unicodeSupport)&&n.host&&(r.domainHost||d&&d.domainHost)&&o===!1&&l0(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=i0(unescape(n.host),o))),n.path&&(n.path=o0(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 ls(e,t){return cs(e,t).parsed}function y0(e,t){return Fd(e,t).normalized}function Fd(e,t){const{parsed:r,malformedAuthorityOrPort:n}=cs(e,t);return{normalized:n?e:ir(r,t),malformedAuthorityOrPort:n}}function Kc(e,t){if(typeof e=="string"){const{normalized:r,malformedAuthorityOrPort:n}=Fd(e,t);return n?void 0:r}if(typeof e=="object")return ir(e,t)}const Za={SCHEMES:u0,normalize:d0,resolve:f0,resolveComponent:Ld,equal:h0,serialize:ir,parse:ls};Os.exports=Za;Os.exports.default=Za;Os.exports.fastUri=Za;var Hd=Os.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=bt;Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=_e;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=Sn,s=jr,o=ar,a=st,i=_e,c=Ge,l=qe,d=G,f=Rw,y=La,g=(O,w)=>new RegExp(O,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"]),_={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(O){var w,C,b,u,p,E,q,D,Y,B,N,j,U,F,X,ie,Ae,et,Ve,Le,Me,St,Ye,Ht,Zt;const pt=O.strict,Kt=(w=O.code)===null||w===void 0?void 0:w.optimize,qr=Kt===!0||Kt===void 0?1:Kt||0,Dr=(b=(C=O.code)===null||C===void 0?void 0:C.regExp)!==null&&b!==void 0?b:g,Vs=(u=O.uriResolver)!==null&&u!==void 0?u:y.default;return{strictSchema:(E=(p=O.strictSchema)!==null&&p!==void 0?p:pt)!==null&&E!==void 0?E:!0,strictNumbers:(D=(q=O.strictNumbers)!==null&&q!==void 0?q:pt)!==null&&D!==void 0?D:!0,strictTypes:(B=(Y=O.strictTypes)!==null&&Y!==void 0?Y:pt)!==null&&B!==void 0?B:"log",strictTuples:(j=(N=O.strictTuples)!==null&&N!==void 0?N:pt)!==null&&j!==void 0?j:"log",strictRequired:(F=(U=O.strictRequired)!==null&&U!==void 0?U:pt)!==null&&F!==void 0?F:!1,code:O.code?{...O.code,optimize:qr,regExp:Dr}:{optimize:qr,regExp:Dr},loopRequired:(X=O.loopRequired)!==null&&X!==void 0?X:$,loopEnum:(ie=O.loopEnum)!==null&&ie!==void 0?ie:$,meta:(Ae=O.meta)!==null&&Ae!==void 0?Ae:!0,messages:(et=O.messages)!==null&&et!==void 0?et:!0,inlineRefs:(Ve=O.inlineRefs)!==null&&Ve!==void 0?Ve:!0,schemaId:(Le=O.schemaId)!==null&&Le!==void 0?Le:"$id",addUsedSchema:(Me=O.addUsedSchema)!==null&&Me!==void 0?Me:!0,validateSchema:(St=O.validateSchema)!==null&&St!==void 0?St:!0,validateFormats:(Ye=O.validateFormats)!==null&&Ye!==void 0?Ye:!0,unicodeRegExp:(Ht=O.unicodeRegExp)!==null&&Ht!==void 0?Ht:!0,int32range:(Zt=O.int32range)!==null&&Zt!==void 0?Zt:!0,uriResolver:Vs}}class R{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,_,w,"NOT SUPPORTED"),k.call(this,h,w,"DEPRECATED","warn"),this._metaOpts=H.call(this),w.formats&&K.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),w.keywords&&J.call(this,w.keywords),typeof w.meta=="object"&&this.addMetaSchema(w.meta),x.call(this),w.validateFormats=u}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:w,meta:C,schemaId: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(B,N){await p.call(this,B.$schema);const j=this._addSchema(B,N);return j.validate||E.call(this,j)}async function p(B){B&&!this.getSchema(B)&&await u.call(this,{$ref:B},!0)}async function E(B){try{return this._compileSchemaEnv(B)}catch(N){if(!(N instanceof s.default))throw N;return q.call(this,N),await D.call(this,N.missingSchema),E.call(this,B)}}function q({missingSchema:B,missingRef:N}){if(this.refs[B])throw new Error(`AnySchema ${B} is loaded but ${N} cannot be resolved`)}async function D(B){const N=await Y.call(this,B);this.refs[B]||await p.call(this,N.$schema),this.refs[B]||this.addSchema(N,B,C)}async function Y(B){const N=this._loading[B];if(N)return N;try{return await(this._loading[B]=b(B))}finally{delete this._loading[B]}}}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=M.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=M.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=>ae.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=>ae.call(this,p,u):p=>u.type.forEach(E=>ae.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,B=E[q];Y&&B&&(E[q]=Oe(B))}}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}}}R.ValidationError=n.default,R.MissingRefError=s.default,e.default=R;function k(O,w,C,b="error"){for(const u in O){const p=u;p in w&&this.logger[b](`${C}: option ${u}. ${O[p]}`)}}function M(O){return O=(0,c.normalizeId)(O),this.schemas[O]||this.refs[O]}function x(){const O=this.opts.schemas;if(O)if(Array.isArray(O))this.addSchema(O);else for(const w in O)this.addSchema(O[w],w)}function K(){for(const O in this.opts.formats){const w=this.opts.formats[O];w&&this.addFormat(O,w)}}function J(O){if(Array.isArray(O)){this.addVocabulary(O);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const w in O){const C=O[w];C.keyword||(C.keyword=w),this.addKeyword(C)}}function H(){const O={...this.opts};for(const w of m)delete O[w];return O}const Z={log(){},warn(){},error(){}};function Q(O){if(O===!1)return Z;if(O===void 0)return console;if(O.log&&O.warn&&O.error)return O;throw new Error("logger must implement log, warn and error methods")}const re=/^[a-z_$][a-z0-9_$:-]*$/i;function V(O,w){const{RULES:C}=this;if((0,d.eachItem)(O,b=>{if(C.keywords[b])throw new Error(`Keyword ${b} is already defined`);if(!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 ae(O,w,C){var b;const u=w==null?void 0:w.post;if(C&&u)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:p}=this;let E=u?p.post:p.rules.find(({type:D})=>D===C);if(E||(E={type:C,rules:[]},p.rules.push(E)),p.keywords[O]=!0,!w)return;const q={keyword:O,definition:{...w,type:(0,l.getJSONTypes)(w.type),schemaType:(0,l.getJSONTypes)(w.schemaType)}};w.before?ke.call(this,E,q,w.before):E.rules.push(q),p.all[O]=q,(b=w.implements)===null||b===void 0||b.forEach(D=>this.addKeyword(D))}function ke(O,w,C){const b=O.rules.findIndex(u=>u.keyword===C);b>=0?O.rules.splice(b,0,w):(O.rules.push(w),this.logger.warn(`rule ${C} is not defined`))}function $e(O){let{metaSchema:w}=O;w!==void 0&&(O.$data&&this.opts.$data&&(w=Oe(w)),O.validateSchema=this.compile(w,!0))}const it={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Oe(O){return{anyOf:[O,it]}}})(Xu);var Ka={},Ga={},Wa={};Object.defineProperty(Wa,"__esModule",{value:!0});const v0={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Wa.default=v0;var cr={};Object.defineProperty(cr,"__esModule",{value:!0});cr.callRef=cr.getValidate=void 0;const $0=jr,Gc=pe,rt=_e,hr=Tt,Wc=st,In=G,w0={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=Wc.resolveRef.call(c,l,s,r);if(d===void 0)throw new $0.default(n.opts.uriResolver,s,r);if(d instanceof Wc.SchemaEnv)return y(d);return g(d);function f(){if(o===l)return Gn(e,a,o,o.$async);const m=t.scopeValue("root",{ref:l});return Gn(e,(0,rt._)`${m}.validate`,l,l.$async)}function y(m){const v=Kd(e,m);Gn(e,v,m,m.$async)}function g(m){const v=t.scopeValue("schema",i.code.source===!0?{ref:m,code:(0,rt.stringify)(m)}:{ref:m}),_=t.name("valid"),h=e.subschema({schema:m,dataTypes:[],schemaPath:rt.nil,topSchemaRef:v,errSchemaPath:r},_);e.mergeEvaluated(h),e.ok(_)}}};function Kd(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,rt._)`${r.scopeValue("wrapper",{ref:t})}.validate`}cr.getValidate=Kd;function Gn(e,t,r,n){const{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:c}=o,l=c.passContext?hr.default.this:rt.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,rt._)`await ${(0,Gc.callValidateCode)(e,t,l)}`),g(t),a||s.assign(m,!0)},v=>{s.if((0,rt._)`!(${v} instanceof ${o.ValidationError})`,()=>s.throw(v)),y(v),a||s.assign(m,!1)}),e.ok(m)}function f(){e.result((0,Gc.callValidateCode)(e,t,l),()=>g(t),()=>y(t))}function y(m){const v=(0,rt._)`${m}.errors`;s.assign(hr.default.vErrors,(0,rt._)`${hr.default.vErrors} === null ? ${v} : ${hr.default.vErrors}.concat(${v})`),s.assign(hr.default.errors,(0,rt._)`${hr.default.vErrors}.length`)}function g(m){var v;if(!o.opts.unevaluated)return;const _=(v=r==null?void 0:r.validate)===null||v===void 0?void 0:v.evaluated;if(o.props!==!0)if(_&&!_.dynamicProps)_.props!==void 0&&(o.props=In.mergeEvaluated.props(s,_.props,o.props));else{const h=s.var("props",(0,rt._)`${m}.evaluated.props`);o.props=In.mergeEvaluated.props(s,h,o.props,rt.Name)}if(o.items!==!0)if(_&&!_.dynamicItems)_.items!==void 0&&(o.items=In.mergeEvaluated.items(s,_.items,o.items));else{const h=s.var("items",(0,rt._)`${m}.evaluated.items`);o.items=In.mergeEvaluated.items(s,h,o.items,rt.Name)}}}cr.callRef=Gn;cr.default=w0;Object.defineProperty(Ga,"__esModule",{value:!0});const b0=Wa,S0=cr,E0=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",b0.default,S0.default];Ga.default=E0;var Ba={},Ja={};Object.defineProperty(Ja,"__esModule",{value:!0});const us=_e,At=us.operators,ds={maximum:{okStr:"<=",ok:At.LTE,fail:At.GT},minimum:{okStr:">=",ok:At.GTE,fail:At.LT},exclusiveMaximum:{okStr:"<",ok:At.LT,fail:At.GTE},exclusiveMinimum:{okStr:">",ok:At.GT,fail:At.LTE}},k0={message:({keyword:e,schemaCode:t})=>(0,us.str)`must be ${ds[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,us._)`{comparison: ${ds[e].okStr}, limit: ${t}}`},P0={keyword:Object.keys(ds),type:"number",schemaType:"number",$data:!0,error:k0,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,us._)`${r} ${ds[t].fail} ${n} || isNaN(${r})`)}};Ja.default=P0;var Qa={};Object.defineProperty(Qa,"__esModule",{value:!0});const Qr=_e,T0={message:({schemaCode:e})=>(0,Qr.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,Qr._)`{multipleOf: ${e}}`},R0={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:T0,code(e){const{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0,Qr._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0,Qr._)`${a} !== parseInt(${a})`;e.fail$data((0,Qr._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};Qa.default=R0;var Ya={},Xa={};Object.defineProperty(Xa,"__esModule",{value:!0});function Gd(e){const t=e.length;let r=0,n=0,s;for(;n=55296&&s<=56319&&n(0,er._)`{limit: ${e}}`},j0={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:I0,code(e){const{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?er.operators.GT:er.operators.LT,a=s.opts.unicode===!1?(0,er._)`${r}.length`:(0,er._)`${(0,C0.useFunc)(e.gen,N0.default)}(${r})`;e.fail$data((0,er._)`${a} ${o} ${n}`)}};Ya.default=j0;var ei={};Object.defineProperty(ei,"__esModule",{value:!0});const O0=pe,A0=G,$r=_e,M0={message:({schemaCode:e})=>(0,$r.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,$r._)`{pattern: ${e}}`},z0={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:M0,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,$r._)`new RegExp`:(0,A0.useFunc)(t,c),d=t.let("valid");t.try(()=>t.assign(d,(0,$r._)`${l}(${o}, ${i}).test(${r})`),()=>t.assign(d,!1)),e.fail$data((0,$r._)`!${d}`)}else{const c=(0,O0.usePattern)(e,s);e.fail$data((0,$r._)`!${c}.test(${r})`)}}};ei.default=z0;var ti={};Object.defineProperty(ti,"__esModule",{value:!0});const Yr=_e,x0={message({keyword:e,schemaCode:t}){const r=e==="maxProperties"?"more":"fewer";return(0,Yr.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,Yr._)`{limit: ${e}}`},q0={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:x0,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?Yr.operators.GT:Yr.operators.LT;e.fail$data((0,Yr._)`Object.keys(${r}).length ${s} ${n}`)}};ti.default=q0;var ri={};Object.defineProperty(ri,"__esModule",{value:!0});const Lr=pe,Xr=_e,D0=G,U0={message:({params:{missingProperty:e}})=>(0,Xr.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,Xr._)`{missingProperty: ${e}}`},V0={keyword:"required",type:"object",schemaType:"array",$data:!0,error:U0,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 _=a.schemaEnv.baseId+a.errSchemaPath,h=`required property "${v}" is not defined at "${_}" (strictRequired)`;(0,D0.checkStrictMode)(a,h,a.opts.strictRequired)}}function l(){if(c||o)e.block$data(Xr.nil,f);else for(const g of r)(0,Lr.checkReportMissingProp)(e,g)}function d(){const g=t.let("missing");if(c||o){const m=t.let("valid",!0);e.block$data(m,()=>y(g,m)),e.ok(m)}else t.if((0,Lr.checkMissingProp)(e,r,g)),(0,Lr.reportMissingProp)(e,g),t.else()}function f(){t.forOf("prop",n,g=>{e.setParams({missingProperty:g}),t.if((0,Lr.noPropertyInData)(t,s,g,i.ownProperties),()=>e.error())})}function y(g,m){e.setParams({missingProperty:g}),t.forOf(g,n,()=>{t.assign(m,(0,Lr.propertyInData)(t,s,g,i.ownProperties)),t.if((0,Xr.not)(m),()=>{e.error(),t.break()})},Xr.nil)}}};ri.default=V0;var ni={};Object.defineProperty(ni,"__esModule",{value:!0});const en=_e,L0={message({keyword:e,schemaCode:t}){const r=e==="maxItems"?"more":"fewer";return(0,en.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,en._)`{limit: ${e}}`},F0={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:L0,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?en.operators.GT:en.operators.LT;e.fail$data((0,en._)`${r}.length ${s} ${n}`)}};ni.default=F0;var si={},En={};Object.defineProperty(En,"__esModule",{value:!0});const Wd=Ns;Wd.code='require("ajv/dist/runtime/equal").default';En.default=Wd;Object.defineProperty(si,"__esModule",{value:!0});const Ws=qe,He=_e,H0=G,Z0=En,K0={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}}`},G0={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:K0,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,Ws.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()?y:g)(m,v))}function f(){return l.length>0&&!l.some(m=>m==="object"||m==="array")}function y(m,v){const _=t.name("item"),h=(0,Ws.checkDataTypes)(l,_,i.opts.strictNumbers,Ws.DataType.Wrong),$=t.const("indices",(0,He._)`{}`);t.for((0,He._)`;${m}--;`,()=>{t.let(_,(0,He._)`${r}[${m}]`),t.if(h,(0,He._)`continue`),l.length>1&&t.if((0,He._)`typeof ${_} == "string"`,(0,He._)`${_} += "_"`),t.if((0,He._)`typeof ${$}[${_}] == "number"`,()=>{t.assign(v,(0,He._)`${$}[${_}]`),e.error(),t.assign(c,!1).break()}).code((0,He._)`${$}[${_}] = ${m}`)})}function g(m,v){const _=(0,H0.useFunc)(t,Z0.default),h=t.name("outer");t.label(h).for((0,He._)`;${m}--;`,()=>t.for((0,He._)`${v} = ${m}; ${v}--;`,()=>t.if((0,He._)`${_}(${r}[${m}], ${r}[${v}])`,()=>{e.error(),t.assign(c,!1).break(h)})))}}};si.default=G0;var oi={};Object.defineProperty(oi,"__esModule",{value:!0});const vo=_e,W0=G,B0=En,J0={message:"must be equal to constant",params:({schemaCode:e})=>(0,vo._)`{allowedValue: ${e}}`},Q0={keyword:"const",$data:!0,error:J0,code(e){const{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,vo._)`!${(0,W0.useFunc)(t,B0.default)}(${r}, ${s})`):e.fail((0,vo._)`${o} !== ${r}`)}};oi.default=Q0;var ai={};Object.defineProperty(ai,"__esModule",{value:!0});const Gr=_e,Y0=G,X0=En,eb={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,Gr._)`{allowedValues: ${e}}`},tb={keyword:"enum",schemaType:"array",$data:!0,error:eb,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,Y0.useFunc)(t,X0.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,Gr.or)(...s.map((m,v)=>y(g,v)))}e.pass(d);function f(){t.assign(d,!1),t.forOf("v",o,g=>t.if((0,Gr._)`${l()}(${r}, ${g})`,()=>t.assign(d,!0).break()))}function y(g,m){const v=s[m];return typeof v=="object"&&v!==null?(0,Gr._)`${l()}(${r}, ${g}[${m}])`:(0,Gr._)`${r} === ${v}`}}};ai.default=tb;Object.defineProperty(Ba,"__esModule",{value:!0});const rb=Ja,nb=Qa,sb=Ya,ob=ei,ab=ti,ib=ri,cb=ni,lb=si,ub=oi,db=ai,fb=[rb.default,nb.default,sb.default,ob.default,ab.default,ib.default,cb.default,lb.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},ub.default,db.default];Ba.default=fb;var ii={},Or={};Object.defineProperty(Or,"__esModule",{value:!0});Or.validateAdditionalItems=void 0;const tr=_e,$o=G,hb={message:({params:{len:e}})=>(0,tr.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,tr._)`{limit: ${e}}`},pb={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:hb,code(e){const{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,$o.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,tr._)`${s}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,tr._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0,$o.alwaysValidSchema)(a,n)){const l=r.var("valid",(0,tr._)`${i} <= ${t.length}`);r.if((0,tr.not)(l),()=>c(l)),e.ok(l)}function c(l){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:$o.Type.Num},l),a.allErrors||r.if((0,tr.not)(l),()=>r.break())})}}Or.validateAdditionalItems=Bd;Or.default=pb;var ci={},Ar={};Object.defineProperty(Ar,"__esModule",{value:!0});Ar.validateTuple=void 0;const Bc=_e,Wn=G,mb=pe,_b={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,Wn.alwaysValidSchema)(r,t)&&e.ok((0,mb.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=Wn.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),l=n.const("len",(0,Bc._)`${o}.length`);r.forEach((f,y)=>{(0,Wn.alwaysValidSchema)(i,f)||(n.if((0,Bc._)`${l} > ${y}`,()=>e.subschema({keyword:a,schemaProp:y,dataProp:y},c)),e.ok(c))});function d(f){const{opts:y,errSchemaPath:g}=i,m=r.length,v=m===f.minItems&&(m===f.maxItems||f[t]===!1);if(y.strictTuples&&!v){const _=`"${a}" is ${m}-tuple, but minItems or maxItems/${t} are not specified or different at path "${g}"`;(0,Wn.checkStrictMode)(i,_,y.strictTuples)}}}Ar.validateTuple=Jd;Ar.default=_b;Object.defineProperty(ci,"__esModule",{value:!0});const gb=Ar,yb={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,gb.validateTuple)(e,"items")};ci.default=yb;var li={};Object.defineProperty(li,"__esModule",{value:!0});const Jc=_e,vb=G,$b=pe,wb=Or,bb={message:({params:{len:e}})=>(0,Jc.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Jc._)`{limit: ${e}}`},Sb={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:bb,code(e){const{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=!0,!(0,vb.alwaysValidSchema)(n,t)&&(s?(0,wb.validateAdditionalItems)(e,s):e.ok((0,$b.validateArray)(e)))}};li.default=Sb;var ui={};Object.defineProperty(ui,"__esModule",{value:!0});const ut=_e,jn=G,Eb={message:({params:{min:e,max:t}})=>t===void 0?(0,ut.str)`must contain at least ${e} valid item(s)`:(0,ut.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,ut._)`{minContains: ${e}}`:(0,ut._)`{minContains: ${e}, maxContains: ${t}}`},kb={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:Eb,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,ut._)`${s}.length`);if(e.setParams({min:a,max:i}),i===void 0&&a===0){(0,jn.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0,jn.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,jn.alwaysValidSchema)(o,r)){let v=(0,ut._)`${d} >= ${a}`;i!==void 0&&(v=(0,ut._)`${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,ut._)`${s}.length > 0`,y)):(t.let(f,!1),y()),e.result(f,()=>e.reset());function y(){const v=t.name("_valid"),_=t.let("count",0);g(v,()=>t.if(v,()=>m(_)))}function g(v,_){t.forRange("i",0,d,h=>{e.subschema({keyword:"contains",dataProp:h,dataPropType:jn.Type.Num,compositeRule:!0},v),_()})}function m(v){t.code((0,ut._)`${v}++`),i===void 0?t.if((0,ut._)`${v} >= ${a}`,()=>t.assign(f,!0).break()):(t.if((0,ut._)`${v} > ${i}`,()=>t.assign(f,!1).break()),a===1?t.assign(f,!0):t.if((0,ut._)`${v} >= ${a}`,()=>t.assign(f,!0)))}}};ui.default=kb;var Qd={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=_e,r=G,n=pe;e.error={message:({params:{property:c,depsCount:l,deps:d}})=>{const f=l===1?"property":"properties";return(0,t.str)`must have ${f} ${d} when property ${c} is present`},params:({params:{property:c,depsCount:l,deps:d,missingProperty:f}})=>(0,t._)`{property: ${c}, + missingProperty: ${f}, + depsCount: ${l}, + deps: ${d}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(c){const[l,d]=o(c);a(c,l),i(c,d)}};function o({schema:c}){const l={},d={};for(const f in c){if(f==="__proto__")continue;const y=Array.isArray(c[f])?l:d;y[f]=c[f]}return[l,d]}function a(c,l=c.schema){const{gen:d,data:f,it:y}=c;if(Object.keys(l).length===0)return;const g=d.let("missing");for(const m in l){const v=l[m];if(v.length===0)continue;const _=(0,n.propertyInData)(d,f,m,y.opts.ownProperties);c.setParams({property:m,depsCount:v.length,deps:v.join(", ")}),y.allErrors?d.if(_,()=>{for(const h of v)(0,n.checkReportMissingProp)(c,h)}):(d.if((0,t._)`${_} && (${(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:y,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 _=c.subschema({keyword:y,schemaProp:v},m);c.mergeValidEvaluated(_,m)},()=>d.var(m,!0)),c.ok(m))}e.validateSchemaDeps=i,e.default=s})(Qd);var di={};Object.defineProperty(di,"__esModule",{value:!0});const Yd=_e,Pb=G,Tb={message:"property name must be valid",params:({params:e})=>(0,Yd._)`{propertyName: ${e.propertyName}}`},Rb={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Tb,code(e){const{gen:t,schema:r,data:n,it:s}=e;if((0,Pb.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)}};di.default=Rb;var As={};Object.defineProperty(As,"__esModule",{value:!0});const On=pe,yt=_e,Cb=Tt,An=G,Nb={message:"must NOT have additional properties",params:({params:e})=>(0,yt._)`{additionalProperty: ${e.additionalProperty}}`},Ib={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:Nb,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,An.alwaysValidSchema)(a,r))return;const l=(0,On.allSchemaProperties)(n.properties),d=(0,On.allSchemaProperties)(n.patternProperties);f(),e.ok((0,yt._)`${o} === ${Cb.default.errors}`);function f(){t.forIn("key",s,_=>{!l.length&&!d.length?m(_):t.if(y(_),()=>m(_))})}function y(_){let h;if(l.length>8){const $=(0,An.schemaRefOrVal)(a,n.properties,"properties");h=(0,On.isOwnProperty)(t,$,_)}else l.length?h=(0,yt.or)(...l.map($=>(0,yt._)`${_} === ${$}`)):h=yt.nil;return d.length&&(h=(0,yt.or)(h,...d.map($=>(0,yt._)`${(0,On.usePattern)(e,$)}.test(${_})`))),(0,yt.not)(h)}function g(_){t.code((0,yt._)`delete ${s}[${_}]`)}function m(_){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){g(_);return}if(r===!1){e.setParams({additionalProperty:_}),e.error(),i||t.break();return}if(typeof r=="object"&&!(0,An.alwaysValidSchema)(a,r)){const h=t.name("valid");c.removeAdditional==="failing"?(v(_,h,!1),t.if((0,yt.not)(h),()=>{e.reset(),g(_)})):(v(_,h),i||t.if((0,yt.not)(h),()=>t.break()))}}function v(_,h,$){const S={keyword:"additionalProperties",dataProp:_,dataPropType:An.Type.Str};$===!1&&Object.assign(S,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(S,h)}}};As.default=Ib;var fi={};Object.defineProperty(fi,"__esModule",{value:!0});const jb=bt,Qc=pe,Bs=G,Yc=As,Ob={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&&Yc.default.code(new jb.KeywordCxt(o,Yc.default,"additionalProperties"));const a=(0,Qc.allSchemaProperties)(r);for(const f of a)o.definedProperties.add(f);o.opts.unevaluated&&a.length&&o.props!==!0&&(o.props=Bs.mergeEvaluated.props(t,(0,Bs.toHash)(a),o.props));const i=a.filter(f=>!(0,Bs.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,Qc.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)}}};fi.default=Ob;var hi={};Object.defineProperty(hi,"__esModule",{value:!0});const Xc=pe,Mn=_e,el=G,tl=G,Ab={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,Xc.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 Mn.Name)&&(o.props=(0,tl.evaluatedPropsToName)(t,o.props));const{props:f}=o;y();function y(){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 _ in l)new RegExp(v).test(_)&&(0,el.checkStrictMode)(o,`property ${_} matches pattern ${v} (use allowMatchingProperties)`)}function m(v){t.forIn("key",n,_=>{t.if((0,Mn._)`${(0,Xc.usePattern)(e,v)}.test(${_})`,()=>{const h=c.includes(v);h||e.subschema({keyword:"patternProperties",schemaProp:v,dataProp:_,dataPropType:tl.Type.Str},d),o.opts.unevaluated&&f!==!0?t.assign((0,Mn._)`${f}[${_}]`,!0):!h&&!o.allErrors&&t.if((0,Mn.not)(d),()=>t.break())})})}}};hi.default=Ab;var pi={};Object.defineProperty(pi,"__esModule",{value:!0});const Mb=G,zb={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,Mb.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"}};pi.default=zb;var mi={};Object.defineProperty(mi,"__esModule",{value:!0});const xb=pe,qb={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:xb.validateUnion,error:{message:"must match a schema in anyOf"}};mi.default=qb;var _i={};Object.defineProperty(_i,"__esModule",{value:!0});const Bn=_e,Db=G,Ub={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,Bn._)`{passingSchemas: ${e.passing}}`},Vb={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:Ub,code(e){const{gen:t,schema:r,parentSchema:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;const o=r,a=t.let("valid",!1),i=t.let("passing",null),c=t.name("_valid");e.setParams({passing:i}),t.block(l),e.result(a,()=>e.reset(),()=>e.error(!0));function l(){o.forEach((d,f)=>{let y;(0,Db.alwaysValidSchema)(s,d)?t.var(c,!0):y=e.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},c),f>0&&t.if((0,Bn._)`${c} && ${a}`).assign(a,!1).assign(i,(0,Bn._)`[${i}, ${f}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,f),y&&e.mergeEvaluated(y,Bn.Name)})})}}};_i.default=Vb;var gi={};Object.defineProperty(gi,"__esModule",{value:!0});const Lb=G,Fb={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,Lb.alwaysValidSchema)(n,o))return;const i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i)})}};gi.default=Fb;var yi={};Object.defineProperty(yi,"__esModule",{value:!0});const fs=_e,Xd=G,Hb={message:({params:e})=>(0,fs.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,fs._)`{failingKeyword: ${e.ifClause}}`},Zb={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:Hb,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=rl(n,"then"),o=rl(n,"else");if(!s&&!o)return;const a=t.let("valid",!0),i=t.name("_valid");if(c(),e.reset(),s&&o){const d=t.let("ifClause");e.setParams({ifClause:d}),t.if(i,l("then",d),l("else",d))}else s?t.if(i,l("then")):t.if((0,fs.not)(i),l("else"));e.pass(a,()=>e.error(!0));function c(){const d=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},i);e.mergeEvaluated(d)}function l(d,f){return()=>{const y=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(y,a),f?t.assign(f,(0,fs._)`${d}`):e.setParams({ifClause:d})}}}};function rl(e,t){const r=e.schema[t];return r!==void 0&&!(0,Xd.alwaysValidSchema)(e,r)}yi.default=Zb;var vi={};Object.defineProperty(vi,"__esModule",{value:!0});const Kb=G,Gb={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,Kb.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};vi.default=Gb;Object.defineProperty(ii,"__esModule",{value:!0});const Wb=Or,Bb=ci,Jb=Ar,Qb=li,Yb=ui,Xb=Qd,eS=di,tS=As,rS=fi,nS=hi,sS=pi,oS=mi,aS=_i,iS=gi,cS=yi,lS=vi;function uS(e=!1){const t=[sS.default,oS.default,aS.default,iS.default,cS.default,lS.default,eS.default,tS.default,Xb.default,rS.default,nS.default];return e?t.push(Bb.default,Qb.default):t.push(Wb.default,Jb.default),t.push(Yb.default),t}ii.default=uS;var $i={},wi={};Object.defineProperty(wi,"__esModule",{value:!0});const ze=_e,dS={message:({schemaCode:e})=>(0,ze.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,ze._)`{format: ${e}}`},fS={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:dS,code(e,t){const{gen:r,data:n,$data:s,schema:o,schemaCode:a,it:i}=e,{opts:c,errSchemaPath:l,schemaEnv:d,self:f}=i;if(!c.validateFormats)return;s?y():g();function y(){const m=r.scopeValue("formats",{ref:f.formats,code:c.code.formats}),v=r.const("fDef",(0,ze._)`${m}[${a}]`),_=r.let("fType"),h=r.let("format");r.if((0,ze._)`typeof ${v} == "object" && !(${v} instanceof RegExp)`,()=>r.assign(_,(0,ze._)`${v}.type || "string"`).assign(h,(0,ze._)`${v}.validate`),()=>r.assign(_,(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 R=d.$async?(0,ze._)`(${v}.async ? await ${h}(${n}) : ${h}(${n}))`:(0,ze._)`${h}(${n})`,k=(0,ze._)`(typeof ${h} == "function" ? ${R} : ${h}.test(${n}))`;return(0,ze._)`${h} && ${h} !== true && ${_} === ${t} && !${k}`}}function g(){const m=f.formats[o];if(!m){$();return}if(m===!0)return;const[v,_,h]=S(m);v===t&&e.pass(R());function $(){if(c.strictSchema===!1){f.logger.warn(k());return}throw new Error(k());function k(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function S(k){const M=k instanceof RegExp?(0,ze.regexpCode)(k):c.code.formats?(0,ze._)`${c.code.formats}${(0,ze.getProperty)(o)}`:void 0,x=r.scopeValue("formats",{key:o,ref:k,code:M});return typeof k=="object"&&!(k instanceof RegExp)?[k.type||"string",k.validate,(0,ze._)`${x}.validate`]:["string",k,x]}function R(){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 _=="function"?(0,ze._)`${h}(${n})`:(0,ze._)`${h}.test(${n})`}}}};wi.default=fS;Object.defineProperty($i,"__esModule",{value:!0});const hS=wi,pS=[hS.default];$i.default=pS;var Rr={};Object.defineProperty(Rr,"__esModule",{value:!0});Rr.contentVocabulary=Rr.metadataVocabulary=void 0;Rr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Rr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(Ka,"__esModule",{value:!0});const mS=Ga,_S=Ba,gS=ii,yS=$i,nl=Rr,vS=[mS.default,_S.default,(0,gS.default)(),yS.default,nl.metadataVocabulary,nl.contentVocabulary];Ka.default=vS;var bi={},Ms={};Object.defineProperty(Ms,"__esModule",{value:!0});Ms.DiscrError=void 0;var sl;(function(e){e.Tag="tag",e.Mapping="mapping"})(sl||(Ms.DiscrError=sl={}));Object.defineProperty(bi,"__esModule",{value:!0});const gr=_e,wo=Ms,ol=st,$S=jr,wS=G,bS={message:({params:{discrError:e,tagName:t}})=>e===wo.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,gr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},SS={keyword:"discriminator",type:"object",schemaType:"object",error:bS,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,gr._)`${r}${(0,gr.getProperty)(i)}`);t.if((0,gr._)`typeof ${l} == "string"`,()=>d(),()=>e.error(!1,{discrError:wo.DiscrError.Tag,tag:l,tagName:i})),e.ok(c);function d(){const g=y();t.if(!1);for(const m in g)t.elseIf((0,gr._)`${l} === ${m}`),t.assign(c,f(g[m]));t.else(),e.error(!1,{discrError:wo.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,gr.Name),m}function y(){var g;const m={},v=h(s);let _=!0;for(let R=0;Rthis.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=bt;Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var d=_e;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=Sn;Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return f.default}});var y=jr;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return y.default}})})(po,po.exports);var IS=po.exports;const jS=Dl(IS);var bo={exports:{}},ef={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(Z,Q){return{validate:Z,compare:Q}}e.fullFormats={date:t(o,a),time:t(c(!0),l),"date-time":t(y(!0),g),"iso-time":t(c(),d),"iso-date-time":t(y(),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:H,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:M},int64:{type:"number",validate:x},float:{type:"number",validate:K},double:{type:"number",validate:K},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(Z){return Z%4===0&&(Z%100!==0||Z%400===0)}const n=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,s=[0,31,28,31,30,31,30,31,31,30,31,30,31];function o(Z){const Q=n.exec(Z);if(!Q)return!1;const re=+Q[1],V=+Q[2],ae=+Q[3];return V>=1&&V<=12&&ae>=1&&ae<=(V===2&&r(re)?29:s[V])}function a(Z,Q){if(Z&&Q)return Z>Q?1:Z23||w>59||Z&&!it)return!1;if(ae<=23&&ke<=59&&$e<60)return!0;const C=ke-w*Oe,b=ae-O*Oe-(C<0?1:0);return(b===23||b===-1)&&(C===59||C===-1)&&$e<61}}function l(Z,Q){if(!(Z&&Q))return;const re=new Date("2020-01-01T"+Z).valueOf(),V=new Date("2020-01-01T"+Q).valueOf();if(re&&V)return re-V}function d(Z,Q){if(!(Z&&Q))return;const re=i.exec(Z),V=i.exec(Q);if(re&&V)return Z=re[1]+re[2]+re[3],Q=V[1]+V[2]+V[3],Z>Q?1:Z=R}function x(Z){return Number.isInteger(Z)}function K(){return!0}const J=/[^\\]\\Z/;function H(Z){if(J.test(Z))return!1;try{return new RegExp(Z),!0}catch{return!1}}})(ef);var tf={},So={exports:{}},rf={},Rt={},Bt={},kn={},he={},dn={};(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,R)=>`${S}${R}`,"")}get names(){var $;return($=this._names)!==null&&$!==void 0?$:this._names=this._items.reduce((S,R)=>(R instanceof r&&(S[R.str]=(S[R.str]||0)+1),S),{})}}e._Code=n,e.nil=new n("");function s(h,...$){const S=[h[0]];let R=0;for(;R<$.length;)i(S,$[R]),S.push(h[++R]);return new n(S)}e._=s;const o=new n("+");function a(h,...$){const S=[g(h[0])];let R=0;for(;R<$.length;)S.push(o),i(S,$[R]),S.push(o,g(h[++R]));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,y=>{if(y.value===void 0)throw new Error(`CodeGen: name "${y}" has no value`);return y.value.code},d,f)}_reduceValues(l,d,f={},y){let g=t.nil;for(const m in l){const v=l[m];if(!v)continue;const _=f[m]=f[m]||new Map;v.forEach(h=>{if(_.has(h))return;_.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($=y==null?void 0:y(h))g=(0,t._)`${g}${$}${this.opts._n}`;else throw new r(h);_.set(h,n.Completed)})}return g}}e.ValueScope=i})(Eo);(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=dn,r=Eo;var n=dn;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=Eo;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 y extends o{constructor(u){super(),this.code=u}render({_n:u}){return`${this.code};`+u}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(u,p){return this.code=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)||(ae(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 _ extends m{}_.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 _(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 R 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 M 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)}}M.kind="func";class x extends g{render(u){return"return "+super.render(u)}}x.kind="return";class K 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 J extends m{constructor(u){super(),this.error=u}render(u){return`catch(${this.error})`+super.render(u)}}J.kind="catch";class H extends m{render(u){return"finally"+super.render(u)}}H.kind="finally";class Z{constructor(u,p={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...p,_n:p.lines?` +`:""},this._extScope=u,this._scope=new r.Scope({parent:u}),this._nodes=[new 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 y(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 _)}endIf(){return this._endBlockNode(h,_)}_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 R(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`,B=>{this.var(D,(0,t._)`${Y}[${B}]`),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 x;if(this._blockNode(p),this.code(u),p.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(x)}try(u,p,E){if(!p&&!E)throw new Error('CodeGen: "try" without "catch" and "finally"');const q=new K;if(this._blockNode(q),this.code(u),p){const D=this.name("e");this._currNode=q.catch=new J(D),p(D)}return E&&(this._currNode=q.finally=new H,this.code(E)),this._endBlockNode(J,H)}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 M(u,p,E)),q&&this.code(q).endFunc(),this}endFunc(){return this._endBlockNode(M)}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=Z;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 ae(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 it(...b){return b.reduce($e)}e.and=it;const Oe=w(e.operators.OR);function O(...b){return b.reduce(Oe)}e.or=O;function w(b){return(u,p)=>u===t.nil?p:p===t.nil?u:(0,t._)`${C(u)} ${b} ${C(p)}`}function C(b){return b instanceof t.Name?b:(0,t._)`(${b})`}})(he);var 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 be=he,OS=dn;function AS(e){const t={};for(const r of e)t[r]=!0;return t}W.toHash=AS;function MS(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(nf(e,t),!sf(t,e.self.RULES.all))}W.alwaysValidSchema=MS;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}"`)}W.checkUnknownRules=nf;function sf(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(t[r])return!0;return!1}W.schemaHasRules=sf;function zS(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=zS;function xS({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)}`}W.schemaRefOrVal=xS;function qS(e){return of(decodeURIComponent(e))}W.unescapeFragment=qS;function DS(e){return encodeURIComponent(Si(e))}W.escapeFragment=DS;function Si(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}W.escapeJsonPointer=Si;function of(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}W.unescapeJsonPointer=of;function US(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)}W.eachItem=US;function al({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}}W.mergeEvaluated={props:al({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} || {}`),Ei(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:af}),items:al({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&&Ei(e,r,t),r}W.evaluatedPropsToName=af;function Ei(e,t,r){Object.keys(r).forEach(n=>e.assign((0,be._)`${t}${(0,be.getProperty)(n)}`,!0))}W.setEvaluated=Ei;const il={};function VS(e,t){return e.scopeValue("func",{ref:t,code:il[t.code]||(il[t.code]=new OS._Code(t.code))})}W.useFunc=VS;var ko;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(ko||(W.Type=ko={}));function LS(e,t,r){if(e instanceof be.Name){const n=t===ko.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():"/"+Si(e)}W.getErrorPath=LS;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)}}W.checkStrictMode=cf;var zn={},cl;function Ft(){if(cl)return zn;cl=1,Object.defineProperty(zn,"__esModule",{value:!0});const e=he,t={data:new e.Name("data"),valCxt:new e.Name("valCxt"),instancePath:new e.Name("instancePath"),parentData:new e.Name("parentData"),parentDataProperty:new e.Name("parentDataProperty"),rootData:new e.Name("rootData"),dynamicAnchors:new e.Name("dynamicAnchors"),vErrors:new e.Name("vErrors"),errors:new e.Name("errors"),this:new e.Name("this"),self:new e.Name("self"),scope:new e.Name("scope"),json:new e.Name("json"),jsonPos:new e.Name("jsonPos"),jsonLen:new e.Name("jsonLen"),jsonPart:new e.Name("jsonPart")};return zn.default=t,zn}(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=W,n=Ft();e.keywordError={message:({keyword:_})=>(0,t.str)`must pass "${_}" keyword validation`},e.keyword$DataError={message:({keyword:_,schemaType:h})=>h?(0,t.str)`"${_}" keyword must be ${h} ($data)`:(0,t.str)`"${_}" keyword is invalid ($data)`};function s(_,h=e.keywordError,$,S){const{it:R}=_,{gen:k,compositeRule:M,allErrors:x}=R,K=f(_,h,$);S??(M||x)?c(k,K):l(R,(0,t._)`[${K}]`)}e.reportError=s;function o(_,h=e.keywordError,$){const{it:S}=_,{gen:R,compositeRule:k,allErrors:M}=S,x=f(_,h,$);c(R,x),k||M||l(S,n.default.vErrors)}e.reportExtraError=o;function a(_,h){_.assign(n.default.errors,h),_.if((0,t._)`${n.default.vErrors} !== null`,()=>_.if(h,()=>_.assign((0,t._)`${n.default.vErrors}.length`,h),()=>_.assign(n.default.vErrors,null)))}e.resetErrorsCount=a;function i({gen:_,keyword:h,schemaValue:$,data:S,errsCount:R,it:k}){if(R===void 0)throw new Error("ajv implementation error");const M=_.name("err");_.forRange("i",R,n.default.errors,x=>{_.const(M,(0,t._)`${n.default.vErrors}[${x}]`),_.if((0,t._)`${M}.instancePath === undefined`,()=>_.assign((0,t._)`${M}.instancePath`,(0,t.strConcat)(n.default.instancePath,k.errorPath))),_.assign((0,t._)`${M}.schemaPath`,(0,t.str)`${k.errSchemaPath}/${h}`),k.opts.verbose&&(_.assign((0,t._)`${M}.schema`,$),_.assign((0,t._)`${M}.data`,S))})}e.extendErrors=i;function c(_,h){const $=_.const("err",h);_.if((0,t._)`${n.default.vErrors} === null`,()=>_.assign(n.default.vErrors,(0,t._)`[${$}]`),(0,t._)`${n.default.vErrors}.push(${$})`),_.code((0,t._)`${n.default.errors}++`)}function l(_,h){const{gen:$,validateName:S,schemaEnv:R}=_;R.$async?$.throw((0,t._)`new ${_.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(_,h,$){const{createErrors:S}=_.it;return S===!1?(0,t._)`{}`:y(_,h,$)}function y(_,h,$={}){const{gen:S,it:R}=_,k=[g(R,$),m(_,$)];return v(_,h,k),S.object(...k)}function g({errorPath:_},{instancePath:h}){const $=h?(0,t.str)`${_}${(0,r.getErrorPath)(h,r.Type.Str)}`:_;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,$)]}function m({keyword:_,it:{errSchemaPath:h}},{schemaPath:$,parentSchema:S}){let R=S?h:(0,t.str)`${h}/${_}`;return $&&(R=(0,t.str)`${R}${(0,r.getErrorPath)($,r.Type.Str)}`),[d.schemaPath,R]}function v(_,{params:h,message:$},S){const{keyword:R,data:k,schemaValue:M,it:x}=_,{opts:K,propertyName:J,topSchemaRef:H,schemaPath:Z}=x;S.push([d.keyword,R],[d.params,typeof h=="function"?h(_):h||(0,t._)`{}`]),K.messages&&S.push([d.message,typeof $=="function"?$(_):$]),K.verbose&&S.push([d.schema,M],[d.parentSchema,(0,t._)`${H}${Z}`],[n.default.data,k]),J&&S.push([d.propertyName,J])}})(kn);var ll;function FS(){if(ll)return Bt;ll=1,Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.boolOrEmptySchema=Bt.topBoolOrEmptySchema=void 0;const e=kn,t=he,r=Ft(),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))}Bt.topBoolOrEmptySchema=s;function o(i,c){const{gen:l,schema:d}=i;d===!1?(l.var(c,!1),a(i)):l.var(c,!0)}Bt.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 Bt}var De={},lr={};Object.defineProperty(lr,"__esModule",{value:!0});lr.getRules=lr.isJSONType=void 0;const HS=["string","number","integer","boolean","null","object","array"],ZS=new Set(HS);function KS(e){return typeof e=="string"&&ZS.has(e)}lr.isJSONType=KS;function GS(){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:{}}}lr.getRules=GS;var Ct={},ul;function lf(){if(ul)return Ct;ul=1,Object.defineProperty(Ct,"__esModule",{value:!0}),Ct.shouldUseRule=Ct.shouldUseGroup=Ct.schemaHasRulesForType=void 0;function e({schema:n,self:s},o){const a=s.RULES.types[o];return a&&a!==!0&&t(n,a)}Ct.schemaHasRulesForType=e;function t(n,s){return s.rules.some(o=>r(n,o))}Ct.shouldUseGroup=t;function r(n,s){var o;return n[s.keyword]!==void 0||((o=s.definition.implements)===null||o===void 0?void 0:o.some(a=>n[a]!==void 0))}return Ct.shouldUseRule=r,Ct}Object.defineProperty(De,"__esModule",{value:!0});De.reportTypeError=De.checkDataTypes=De.checkDataType=De.coerceAndCheckDataType=De.getJSONTypes=De.getSchemaTypes=De.DataType=void 0;const WS=lr,BS=lf(),JS=kn,le=he,uf=W;var Er;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Er||(De.DataType=Er={}));function QS(e){const t=df(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}De.getSchemaTypes=QS;function df(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(WS.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}De.getJSONTypes=df;function YS(e,t){const{gen:r,data:n,opts:s}=e,o=XS(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0,BS.schemaHasRulesForType)(e,t[0]));if(a){const i=ki(t,n,s.strictNumbers,Er.Wrong);r.if(i,()=>{o.length?eE(e,t,o):Pi(e)})}return a}De.coerceAndCheckDataType=YS;const ff=new Set(["string","number","integer","boolean","null"]);function XS(e,t){return t?e.filter(r=>ff.has(r)||t==="array"&&r==="array"):[]}function eE(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(ki(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0,le._)`${i} !== undefined`);for(const l of r)(ff.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),Pi(e),n.endIf(),n.if((0,le._)`${i} !== undefined`,()=>{n.assign(s,i),tE(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 tE({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,le._)`${t} !== undefined`,()=>e.assign((0,le._)`${t}[${r}]`,n))}function Po(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)}}De.checkDataType=Po;function ki(e,t,r,n){if(e.length===1)return Po(e[0],t,r,n);let s;const o=(0,uf.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,Po(a,t,r,n));return s}De.checkDataTypes=ki;const rE={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,le._)`{type: ${e}}`:(0,le._)`{type: ${t}}`};function Pi(e){const t=nE(e);(0,JS.reportError)(t,rE)}De.reportTypeError=Pi;function nE(e){const{gen:t,data:r,schema:n}=e,s=(0,uf.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}var Fr={},dl;function sE(){if(dl)return Fr;dl=1,Object.defineProperty(Fr,"__esModule",{value:!0}),Fr.assignDefaults=void 0;const e=he,t=W;function r(s,o){const{properties:a,items:i}=s.schema;if(o==="object"&&a)for(const c in a)n(s,c,a[c].default);else o==="array"&&Array.isArray(i)&&i.forEach((c,l)=>n(s,l,c.default))}Fr.assignDefaults=r;function n(s,o,a){const{gen:i,compositeRule:c,data:l,opts:d}=s;if(a===void 0)return;const f=(0,e._)`${l}${(0,e.getProperty)(o)}`;if(c){(0,t.checkStrictMode)(s,`default is ignored for: ${f}`);return}let y=(0,e._)`${f} === undefined`;d.useDefaults==="empty"&&(y=(0,e._)`${y} || ${f} === null || ${f} === ""`),i.if(y,(0,e._)`${f} = ${(0,e.stringify)(a)}`)}return Fr}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,Ti=W,Mt=Ft(),oE=W;function aE(e,t){const{gen:r,data:n,it:s}=e;r.if(Ci(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Te._)`${t}`},!0),e.error()})}me.checkReportMissingProp=aE;function iE({gen:e,data:t,it:{opts:r}},n,s){return(0,Te.or)(...n.map(o=>(0,Te.and)(Ci(e,t,o,r.ownProperties),(0,Te._)`${s} = ${o}`)))}me.checkMissingProp=iE;function cE(e,t){e.setParams({missingProperty:t},!0),e.error()}me.reportMissingProp=cE;function hf(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Te._)`Object.prototype.hasOwnProperty`})}me.hasPropFunc=hf;function Ri(e,t,r){return(0,Te._)`${hf(e)}.call(${t}, ${r})`}me.isOwnProperty=Ri;function lE(e,t,r,n){const s=(0,Te._)`${t}${(0,Te.getProperty)(r)} !== undefined`;return n?(0,Te._)`${s} && ${Ri(e,t,r)}`:s}me.propertyInData=lE;function Ci(e,t,r,n){const s=(0,Te._)`${t}${(0,Te.getProperty)(r)} === undefined`;return n?(0,Te.or)(s,(0,Te.not)(Ri(e,t,r))):s}me.noPropertyInData=Ci;function pf(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}me.allSchemaProperties=pf;function uE(e,t){return pf(t).filter(r=>!(0,Ti.alwaysValidSchema)(e,t[r]))}me.schemaProperties=uE;function dE({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=[[Mt.default.instancePath,(0,Te.strConcat)(Mt.default.instancePath,o)],[Mt.default.parentData,a.parentData],[Mt.default.parentDataProperty,a.parentDataProperty],[Mt.default.rootData,Mt.default.rootData]];a.opts.dynamicRef&&f.push([Mt.default.dynamicAnchors,Mt.default.dynamicAnchors]);const y=(0,Te._)`${d}, ${r.object(...f)}`;return c!==Te.nil?(0,Te._)`${i}.call(${c}, ${y})`:(0,Te._)`${i}(${y})`}me.callValidateCode=dE;const fE=(0,Te._)`new RegExp`;function hE({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"?fE:(0,oE.useFunc)(e,s)}(${r}, ${n})`})}me.usePattern=hE;function pE(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:Ti.Type.Num},o),t.if((0,Te.not)(o),i)})}}me.validateArray=pE;function mE(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,Ti.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=mE;var fl;function _E(){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=Ft(),r=me,n=kn;function s(y,g){const{gen:m,keyword:v,schema:_,parentSchema:h,it:$}=y,S=g.macro.call($.self,_,h,$),R=l(m,v,S);$.opts.validateSchema!==!1&&$.self.validateSchema(S,!0);const k=m.name("valid");y.subschema({schema:S,schemaPath:e.nil,errSchemaPath:`${$.errSchemaPath}/${v}`,topSchemaRef:R,compositeRule:!0},k),y.pass(k,()=>y.error(!0))}_t.macroKeywordCode=s;function o(y,g){var m;const{gen:v,keyword:_,schema:h,parentSchema:$,$data:S,it:R}=y;c(R,g);const k=!S&&g.compile?g.compile.call(R.self,h,$,R):g.validate,M=l(v,_,k),x=v.let("valid");y.block$data(x,K),y.ok((m=g.valid)!==null&&m!==void 0?m:x);function K(){if(g.errors===!1)Z(),g.modifying&&a(y),Q(()=>y.error());else{const re=g.async?J():H();g.modifying&&a(y),Q(()=>i(y,re))}}function J(){const re=v.let("ruleErrs",null);return v.try(()=>Z((0,e._)`await `),V=>v.assign(x,!1).if((0,e._)`${V} instanceof ${R.ValidationError}`,()=>v.assign(re,(0,e._)`${V}.errors`),()=>v.throw(V))),re}function H(){const re=(0,e._)`${M}.errors`;return v.assign(re,null),Z(e.nil),re}function Z(re=g.async?(0,e._)`await `:e.nil){const V=R.opts.passContext?t.default.this:t.default.self,ae=!("compile"in g&&!S||g.schema===!1);v.assign(x,(0,e._)`${re}${(0,r.callValidateCode)(y,M,V,ae)}`,g.modifying)}function Q(re){var V;v.if((0,e.not)((V=g.valid)!==null&&V!==void 0?V:x),re)}}_t.funcKeywordCode=o;function a(y){const{gen:g,data:m,it:v}=y;g.if(v.parentData,()=>g.assign(m,(0,e._)`${v.parentData}[${v.parentDataProperty}]`))}function i(y,g){const{gen:m}=y;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)(y)},()=>y.error())}function c({schemaEnv:y},g){if(g.async&&!y.$async)throw new Error("async keyword in sync schema")}function l(y,g,m){if(m===void 0)throw new Error(`keyword "${g}" failed to compile`);return y.scopeValue("keyword",typeof m=="function"?{ref:m}:{ref:m,code:(0,e.stringify)(m)})}function d(y,g,m=!1){return!g.length||g.some(v=>v==="array"?Array.isArray(y):v==="object"?y&&typeof y=="object"&&!Array.isArray(y):typeof y==v||m&&typeof y>"u")}_t.validSchemaType=d;function f({schema:y,opts:g,self:m,errSchemaPath:v},_,h){if(Array.isArray(_.keyword)?!_.keyword.includes(h):_.keyword!==h)throw new Error("ajv implementation error");const $=_.dependencies;if($!=null&&$.some(S=>!Object.prototype.hasOwnProperty.call(y,S)))throw new Error(`parent schema must have dependencies of ${h}: ${$.join(",")}`);if(_.validateSchema&&!_.validateSchema(y[h])){const R=`keyword "${h}" value is invalid at path "${v}": `+m.errorsText(_.validateSchema.errors);if(g.validateSchema==="log")m.logger.error(R);else throw new Error(R)}}return _t.validateKeywordUsage=f,_t}var Nt={},hl;function gE(){if(hl)return Nt;hl=1,Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.extendSubschemaMode=Nt.extendSubschemaData=Nt.getSubschema=void 0;const e=he,t=W;function r(o,{keyword:a,schemaProp:i,schema:c,schemaPath:l,errSchemaPath:d,topSchemaRef:f}){if(a!==void 0&&c!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(a!==void 0){const y=o.schema[a];return i===void 0?{schema:y,schemaPath:(0,e._)`${o.schemaPath}${(0,e.getProperty)(a)}`,errSchemaPath:`${o.errSchemaPath}/${a}`}:{schema:y[i],schemaPath:(0,e._)`${o.schemaPath}${(0,e.getProperty)(a)}${(0,e.getProperty)(i)}`,errSchemaPath:`${o.errSchemaPath}/${a}/${(0,t.escapeFragment)(i)}`}}if(c!==void 0){if(l===void 0||d===void 0||f===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:c,schemaPath:l,topSchemaRef:f,errSchemaPath:d}}throw new Error('either "keyword" or "schema" must be passed')}Nt.getSubschema=r;function n(o,a,{dataProp:i,dataPropType:c,data:l,dataTypes:d,propertyName:f}){if(l!==void 0&&i!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:y}=a;if(i!==void 0){const{errorPath:m,dataPathArr:v,opts:_}=a,h=y.let("data",(0,e._)`${a.data}${(0,e.getProperty)(i)}`,!0);g(h),o.errorPath=(0,e.str)`${m}${(0,t.getErrorPath)(i,c,_.jsPropertySyntax)}`,o.parentDataProperty=(0,e._)`${i}`,o.dataPathArr=[...v,o.parentDataProperty]}if(l!==void 0){const m=l instanceof e.Name?l:y.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]}}Nt.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 Nt.extendSubschemaMode=s,Nt}var We={},mf={exports:{}},Dt=mf.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(){};Jn(t,n,s,e,"",e)};Dt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Dt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Dt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Dt.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 Jn(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 Dt.arrayKeywords)for(var y=0;yt+=_f(n)),t===1/0))return 1/0}return t}function gf(e,t="",r){r!==!1&&(t=kr(t));const n=e.parse(t);return yf(e,n)}We.getFullPath=gf;function yf(e,t){return e.serialize(t).split("#")[0]+"#"}We._getFullPath=yf;const PE=/#\/?$/;function kr(e){return e?e.replace(PE,""):""}We.normalizeId=kr;function TE(e,t,r){return r=kr(r),e.resolve(t,r)}We.resolveUrl=TE;const RE=/^[a-z_][-a-z0-9._]*$/i;function CE(e,t){if(typeof e=="boolean")return{};const{schemaId:r,uriResolver:n}=this.opts,s=kr(e[r]||t),o={"":s},a=gf(n,s,!1),i={},c=new Set;return bE(e,{allKeys:!0},(f,y,g,m)=>{if(m===void 0)return;const v=a+y;let _=o[m];typeof f[r]=="string"&&(_=h.call(this,f[r])),$.call(this,f.$anchor),$.call(this,f.$dynamicAnchor),o[y]=_;function h(S){const R=this.opts.uriResolver.resolve;if(S=kr(_?R(_,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(!RE.test(S))throw new Error(`invalid anchor "${S}"`);h.call(this,`#${S}`)}}}),i;function l(f,y,g){if(y!==void 0&&!wE(f,y))throw d(g)}function d(f){return new Error(`reference "${f}" resolves to more than one schema`)}}We.getSchemaRefs=CE;var pl;function zs(){if(pl)return Rt;pl=1,Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.getData=Rt.KeywordCxt=Rt.validateFunctionCode=void 0;const e=FS(),t=De,r=lf(),n=De,s=sE(),o=_E(),a=gE(),i=he,c=Ft(),l=We,d=W,f=kn;function y(N){if(k(N)&&(x(N),R(N))){_(N);return}g(N,()=>(0,e.topBoolOrEmptySchema)(N))}Rt.validateFunctionCode=y;function g({gen:N,validateName:j,schema:U,schemaEnv:F,opts:X},ie){X.code.es5?N.func(j,(0,i._)`${c.default.data}, ${c.default.valCxt}`,F.$async,()=>{N.code((0,i._)`"use strict"; ${$(U,X)}`),v(N,X),N.code(ie)}):N.func(j,(0,i._)`${c.default.data}, ${m(X)}`,F.$async,()=>N.code($(U,X)).code(ie))}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,j){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}`),j.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),j.dynamicRef&&N.var(c.default.dynamicAnchors,(0,i._)`{}`)})}function _(N){const{schema:j,opts:U,gen:F}=N;g(N,()=>{U.$comment&&j.$comment&&re(N),H(N),F.let(c.default.vErrors,null),F.let(c.default.errors,0),U.unevaluated&&h(N),K(N),V(N)})}function h(N){const{gen:j,validateName:U}=N;N.evaluated=j.const("evaluated",(0,i._)`${U}.evaluated`),j.if((0,i._)`${N.evaluated}.dynamicProps`,()=>j.assign((0,i._)`${N.evaluated}.props`,(0,i._)`undefined`)),j.if((0,i._)`${N.evaluated}.dynamicItems`,()=>j.assign((0,i._)`${N.evaluated}.items`,(0,i._)`undefined`))}function $(N,j){const U=typeof N=="object"&&N[j.schemaId];return U&&(j.code.source||j.code.process)?(0,i._)`/*# sourceURL=${U} */`:i.nil}function S(N,j){if(k(N)&&(x(N),R(N))){M(N,j);return}(0,e.boolOrEmptySchema)(N,j)}function R({schema:N,self:j}){if(typeof N=="boolean")return!N;for(const U in N)if(j.RULES.all[U])return!0;return!1}function k(N){return typeof N.schema!="boolean"}function M(N,j){const{schema:U,gen:F,opts:X}=N;X.$comment&&U.$comment&&re(N),Z(N),Q(N);const ie=F.const("_errs",c.default.errors);K(N,ie),F.var(j,(0,i._)`${ie} === ${c.default.errors}`)}function x(N){(0,d.checkUnknownRules)(N),J(N)}function K(N,j){if(N.opts.jtd)return ke(N,[],!1,j);const U=(0,t.getSchemaTypes)(N.schema),F=(0,t.coerceAndCheckDataType)(N,U);ke(N,U,!F,j)}function J(N){const{schema:j,errSchemaPath:U,opts:F,self:X}=N;j.$ref&&F.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(j,X.RULES)&&X.logger.warn(`$ref: keywords ignored in schema at path "${U}"`)}function H(N){const{schema:j,opts:U}=N;j.default!==void 0&&U.useDefaults&&U.strictSchema&&(0,d.checkStrictMode)(N,"default is ignored in the schema root")}function Z(N){const j=N.schema[N.opts.schemaId];j&&(N.baseId=(0,l.resolveUrl)(N.opts.uriResolver,N.baseId,j))}function Q(N){if(N.schema.$async&&!N.schemaEnv.$async)throw new Error("async schema in sync schema")}function re({gen:N,schemaEnv:j,schema:U,errSchemaPath:F,opts:X}){const ie=U.$comment;if(X.$comment===!0)N.code((0,i._)`${c.default.self}.logger.log(${ie})`);else if(typeof X.$comment=="function"){const Ae=(0,i.str)`${F}/$comment`,et=N.scopeValue("root",{ref:j.root});N.code((0,i._)`${c.default.self}.opts.$comment(${ie}, ${Ae}, ${et}.schema)`)}}function V(N){const{gen:j,schemaEnv:U,validateName:F,ValidationError:X,opts:ie}=N;U.$async?j.if((0,i._)`${c.default.errors} === 0`,()=>j.return(c.default.data),()=>j.throw((0,i._)`new ${X}(${c.default.vErrors})`)):(j.assign((0,i._)`${F}.errors`,c.default.vErrors),ie.unevaluated&&ae(N),j.return((0,i._)`${c.default.errors} === 0`))}function ae({gen:N,evaluated:j,props:U,items:F}){U instanceof i.Name&&N.assign((0,i._)`${j}.props`,U),F instanceof i.Name&&N.assign((0,i._)`${j}.items`,F)}function ke(N,j,U,F){const{gen:X,schema:ie,data:Ae,allErrors:et,opts:Ve,self:Le}=N,{RULES:Me}=Le;if(ie.$ref&&(Ve.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(ie,Me))){X.block(()=>q(N,"$ref",Me.all.$ref.definition));return}Ve.jtd||it(N,j),X.block(()=>{for(const Ye of Me.rules)St(Ye);St(Me.post)});function St(Ye){(0,r.shouldUseGroup)(ie,Ye)&&(Ye.type?(X.if((0,n.checkDataType)(Ye.type,Ae,Ve.strictNumbers)),$e(N,Ye),j.length===1&&j[0]===Ye.type&&U&&(X.else(),(0,n.reportTypeError)(N)),X.endIf()):$e(N,Ye),et||X.if((0,i._)`${c.default.errors} === ${F||0}`))}}function $e(N,j){const{gen:U,schema:F,opts:{useDefaults:X}}=N;X&&(0,s.assignDefaults)(N,j.type),U.block(()=>{for(const ie of j.rules)(0,r.shouldUseRule)(F,ie)&&q(N,ie.keyword,ie.definition,j.type)})}function it(N,j){N.schemaEnv.meta||!N.opts.strictTypes||(Oe(N,j),N.opts.allowUnionTypes||O(N,j),w(N,N.dataTypes))}function Oe(N,j){if(j.length){if(!N.dataTypes.length){N.dataTypes=j;return}j.forEach(U=>{b(N.dataTypes,U)||p(N,`type "${U}" not allowed by context "${N.dataTypes.join(",")}"`)}),u(N,j)}}function O(N,j){j.length>1&&!(j.length===2&&j.includes("null"))&&p(N,"use allowUnionTypes to allow union type keyword")}function w(N,j){const U=N.self.RULES.all;for(const F in U){const X=U[F];if(typeof X=="object"&&(0,r.shouldUseRule)(N.schema,X)){const{type:ie}=X.definition;ie.length&&!ie.some(Ae=>C(j,Ae))&&p(N,`missing type "${ie.join(",")}" for keyword "${F}"`)}}}function C(N,j){return N.includes(j)||j==="number"&&N.includes("integer")}function b(N,j){return N.includes(j)||j==="integer"&&N.includes("number")}function u(N,j){const U=[];for(const F of N.dataTypes)b(j,F)?U.push(F):j.includes("integer")&&F==="number"&&U.push("integer");N.dataTypes=U}function p(N,j){const U=N.schemaEnv.baseId+N.errSchemaPath;j+=` at "${U}" (strictTypes)`,(0,d.checkStrictMode)(N,j,N.opts.strictTypes)}class E{constructor(j,U,F){if((0,o.validateKeywordUsage)(j,U,F),this.gen=j.gen,this.allErrors=j.allErrors,this.keyword=F,this.data=j.data,this.schema=j.schema[F],this.$data=U.$data&&j.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d.schemaRefOrVal)(j,this.schema,F,this.$data),this.schemaType=U.schemaType,this.parentSchema=j.schema,this.params={},this.it=j,this.def=U,this.$data)this.schemaCode=j.gen.const("vSchema",B(this.$data,j));else if(this.schemaCode=this.schemaValue,!(0,o.validSchemaType)(this.schema,U.schemaType,U.allowUndefined))throw new Error(`${F} value must be ${JSON.stringify(U.schemaType)}`);("code"in U?U.trackErrors:U.errors!==!1)&&(this.errsCount=j.gen.const("_errs",c.default.errors))}result(j,U,F){this.failResult((0,i.not)(j),U,F)}failResult(j,U,F){this.gen.if(j),F?F():this.error(),U?(this.gen.else(),U(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(j,U){this.failResult((0,i.not)(j),void 0,U)}fail(j){if(j===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(j),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(j){if(!this.$data)return this.fail(j);const{schemaCode:U}=this;this.fail((0,i._)`${U} !== undefined && (${(0,i.or)(this.invalid$data(),j)})`)}error(j,U,F){if(U){this.setParams(U),this._error(j,F),this.setParams({});return}this._error(j,F)}_error(j,U){(j?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(j){this.allErrors||this.gen.if(j)}setParams(j,U){U?Object.assign(this.params,j):this.params=j}block$data(j,U,F=i.nil){this.gen.block(()=>{this.check$data(j,F),U()})}check$data(j=i.nil,U=i.nil){if(!this.$data)return;const{gen:F,schemaCode:X,schemaType:ie,def:Ae}=this;F.if((0,i.or)((0,i._)`${X} === undefined`,U)),j!==i.nil&&F.assign(j,!0),(ie.length||Ae.validateSchema)&&(F.elseIf(this.invalid$data()),this.$dataError(),j!==i.nil&&F.assign(j,!1)),F.else()}invalid$data(){const{gen:j,schemaCode:U,schemaType:F,def:X,it:ie}=this;return(0,i.or)(Ae(),et());function Ae(){if(F.length){if(!(U instanceof i.Name))throw new Error("ajv implementation error");const Ve=Array.isArray(F)?F:[F];return(0,i._)`${(0,n.checkDataTypes)(Ve,U,ie.opts.strictNumbers,n.DataType.Wrong)}`}return i.nil}function et(){if(X.validateSchema){const Ve=j.scopeValue("validate$data",{ref:X.validateSchema});return(0,i._)`!${Ve}(${U})`}return i.nil}}subschema(j,U){const F=(0,a.getSubschema)(this.it,j);(0,a.extendSubschemaData)(F,this.it,j),(0,a.extendSubschemaMode)(F,j);const X={...this.it,...F,items:void 0,props:void 0};return S(X,U),X}mergeEvaluated(j,U){const{it:F,gen:X}=this;F.opts.unevaluated&&(F.props!==!0&&j.props!==void 0&&(F.props=d.mergeEvaluated.props(X,j.props,F.props,U)),F.items!==!0&&j.items!==void 0&&(F.items=d.mergeEvaluated.items(X,j.items,F.items,U)))}mergeValidEvaluated(j,U){const{it:F,gen:X}=this;if(F.opts.unevaluated&&(F.props!==!0||F.items!==!0))return X.if(U,()=>this.mergeEvaluated(j,i.Name)),!0}}Rt.KeywordCxt=E;function q(N,j,U,F){const X=new E(N,U,j);"code"in U?U.code(X,F):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 B(N,{dataLevel:j,dataNames:U,dataPathArr:F}){let X,ie;if(N==="")return c.default.rootData;if(N[0]==="/"){if(!D.test(N))throw new Error(`Invalid JSON-pointer: ${N}`);X=N,ie=c.default.rootData}else{const Le=Y.exec(N);if(!Le)throw new Error(`Invalid JSON-pointer: ${N}`);const Me=+Le[1];if(X=Le[2],X==="#"){if(Me>=j)throw new Error(Ve("property/index",Me));return F[j-Me]}if(Me>j)throw new Error(Ve("data",Me));if(ie=U[j-Me],!X)return ie}let Ae=ie;const et=X.split("/");for(const Le of et)Le&&(ie=(0,i._)`${ie}${(0,i.getProperty)((0,d.unescapeJsonPointer)(Le))}`,Ae=(0,i._)`${Ae} && ${ie}`);return Ae;function Ve(Le,Me){return`Cannot access ${Le} ${Me} levels up, current level is ${j}`}}return Rt.getData=B,Rt}var xn={},ml;function Ni(){if(ml)return xn;ml=1,Object.defineProperty(xn,"__esModule",{value:!0});class e extends Error{constructor(r){super("validation failed"),this.errors=r,this.ajv=this.validation=!0}}return xn.default=e,xn}var Mr={};Object.defineProperty(Mr,"__esModule",{value:!0});const Js=We;class NE extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Js.resolveUrl)(t,r,n),this.missingSchema=(0,Js.normalizeId)((0,Js.getFullPath)(t,this.missingRef))}}Mr.default=NE;var ot={};Object.defineProperty(ot,"__esModule",{value:!0});ot.resolveSchema=ot.getCompilingSchema=ot.resolveRef=ot.compileSchema=ot.SchemaEnv=void 0;const gt=he,IE=Ni(),Jt=Ft(),wt=We,_l=W,jE=zs();class xs{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=xs;function Ii(e){const t=vf.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:IE.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,jE.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=Ii;function OE(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=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 xs({schema:a,schemaId:i,root:e,baseId:t}))}if(o!==void 0)return e.refs[r]=AE.call(this,o)}ot.resolveRef=OE;function AE(e){return(0,wt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Ii.call(this,e)}function vf(e){for(const t of this._compilations)if(ME(t,e))return t}ot.getCompilingSchema=vf;function ME(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]||qs.call(this,e,t)}function qs(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 Qs.call(this,r,e);const o=(0,wt.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){const i=qs.call(this,e,a);return typeof(i==null?void 0:i.schema)!="object"?void 0:Qs.call(this,r,i)}if(typeof(a==null?void 0:a.schema)=="object"){if(a.validate||Ii.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 xs({schema:i,schemaId:c,root:e,baseId:s})}return Qs.call(this,r,a)}}ot.resolveSchema=qs;const xE=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Qs(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,_l.unescapeFragment)(i)];if(c===void 0)return;r=c;const l=typeof r=="object"&&r[this.opts.schemaId];!xE.has(i)&&l&&(t=(0,wt.resolveUrl)(this.opts.uriResolver,t,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,_l.schemaHasRulesButRef)(r,this.RULES)){const i=(0,wt.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=qs.call(this,n,i)}const{schemaId:a}=this.opts;if(o=o||new xs({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}const qE="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",DE="Meta-schema for $data reference (JSON AnySchema extension proposal)",UE="object",VE=["$data"],LE={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},FE=!1,HE={$id:qE,description:DE,type:UE,required:VE,properties:LE,additionalProperties:FE};var ji={};Object.defineProperty(ji,"__esModule",{value:!0});const $f=Hd;$f.code='require("ajv/dist/runtime/uri").default';ji.default=$f;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=zs();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=he;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});const n=Ni(),s=Mr,o=lr,a=ot,i=he,c=We,l=De,d=W,f=HE,y=ji,g=(O,w)=>new RegExp(O,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"]),_={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(O){var w,C,b,u,p,E,q,D,Y,B,N,j,U,F,X,ie,Ae,et,Ve,Le,Me,St,Ye,Ht,Zt;const pt=O.strict,Kt=(w=O.code)===null||w===void 0?void 0:w.optimize,qr=Kt===!0||Kt===void 0?1:Kt||0,Dr=(b=(C=O.code)===null||C===void 0?void 0:C.regExp)!==null&&b!==void 0?b:g,Vs=(u=O.uriResolver)!==null&&u!==void 0?u:y.default;return{strictSchema:(E=(p=O.strictSchema)!==null&&p!==void 0?p:pt)!==null&&E!==void 0?E:!0,strictNumbers:(D=(q=O.strictNumbers)!==null&&q!==void 0?q:pt)!==null&&D!==void 0?D:!0,strictTypes:(B=(Y=O.strictTypes)!==null&&Y!==void 0?Y:pt)!==null&&B!==void 0?B:"log",strictTuples:(j=(N=O.strictTuples)!==null&&N!==void 0?N:pt)!==null&&j!==void 0?j:"log",strictRequired:(F=(U=O.strictRequired)!==null&&U!==void 0?U:pt)!==null&&F!==void 0?F:!1,code:O.code?{...O.code,optimize:qr,regExp:Dr}:{optimize:qr,regExp:Dr},loopRequired:(X=O.loopRequired)!==null&&X!==void 0?X:$,loopEnum:(ie=O.loopEnum)!==null&&ie!==void 0?ie:$,meta:(Ae=O.meta)!==null&&Ae!==void 0?Ae:!0,messages:(et=O.messages)!==null&&et!==void 0?et:!0,inlineRefs:(Ve=O.inlineRefs)!==null&&Ve!==void 0?Ve:!0,schemaId:(Le=O.schemaId)!==null&&Le!==void 0?Le:"$id",addUsedSchema:(Me=O.addUsedSchema)!==null&&Me!==void 0?Me:!0,validateSchema:(St=O.validateSchema)!==null&&St!==void 0?St:!0,validateFormats:(Ye=O.validateFormats)!==null&&Ye!==void 0?Ye:!0,unicodeRegExp:(Ht=O.unicodeRegExp)!==null&&Ht!==void 0?Ht:!0,int32range:(Zt=O.int32range)!==null&&Zt!==void 0?Zt:!0,uriResolver:Vs}}class R{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,_,w,"NOT SUPPORTED"),k.call(this,h,w,"DEPRECATED","warn"),this._metaOpts=H.call(this),w.formats&&K.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),w.keywords&&J.call(this,w.keywords),typeof w.meta=="object"&&this.addMetaSchema(w.meta),x.call(this),w.validateFormats=u}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:w,meta:C,schemaId: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(B,N){await p.call(this,B.$schema);const j=this._addSchema(B,N);return j.validate||E.call(this,j)}async function p(B){B&&!this.getSchema(B)&&await u.call(this,{$ref:B},!0)}async function E(B){try{return this._compileSchemaEnv(B)}catch(N){if(!(N instanceof s.default))throw N;return q.call(this,N),await D.call(this,N.missingSchema),E.call(this,B)}}function q({missingSchema:B,missingRef:N}){if(this.refs[B])throw new Error(`AnySchema ${B} is loaded but ${N} cannot be resolved`)}async function D(B){const N=await Y.call(this,B);this.refs[B]||await p.call(this,N.$schema),this.refs[B]||this.addSchema(N,B,C)}async function Y(B){const N=this._loading[B];if(N)return N;try{return await(this._loading[B]=b(B))}finally{delete this._loading[B]}}}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=M.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=M.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=>ae.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=>ae.call(this,p,u):p=>u.type.forEach(E=>ae.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,B=E[q];Y&&B&&(E[q]=Oe(B))}}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}}}R.ValidationError=n.default,R.MissingRefError=s.default,e.default=R;function k(O,w,C,b="error"){for(const u in O){const p=u;p in w&&this.logger[b](`${C}: option ${u}. ${O[p]}`)}}function M(O){return O=(0,c.normalizeId)(O),this.schemas[O]||this.refs[O]}function x(){const O=this.opts.schemas;if(O)if(Array.isArray(O))this.addSchema(O);else for(const w in O)this.addSchema(O[w],w)}function K(){for(const O in this.opts.formats){const w=this.opts.formats[O];w&&this.addFormat(O,w)}}function J(O){if(Array.isArray(O)){this.addVocabulary(O);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const w in O){const C=O[w];C.keyword||(C.keyword=w),this.addKeyword(C)}}function H(){const O={...this.opts};for(const w of m)delete O[w];return O}const Z={log(){},warn(){},error(){}};function Q(O){if(O===!1)return Z;if(O===void 0)return console;if(O.log&&O.warn&&O.error)return O;throw new Error("logger must implement log, warn and error methods")}const re=/^[a-z_$][a-z0-9_$:-]*$/i;function V(O,w){const{RULES:C}=this;if((0,d.eachItem)(O,b=>{if(C.keywords[b])throw new Error(`Keyword ${b} is already defined`);if(!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 ae(O,w,C){var b;const u=w==null?void 0:w.post;if(C&&u)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:p}=this;let E=u?p.post:p.rules.find(({type:D})=>D===C);if(E||(E={type:C,rules:[]},p.rules.push(E)),p.keywords[O]=!0,!w)return;const q={keyword:O,definition:{...w,type:(0,l.getJSONTypes)(w.type),schemaType:(0,l.getJSONTypes)(w.schemaType)}};w.before?ke.call(this,E,q,w.before):E.rules.push(q),p.all[O]=q,(b=w.implements)===null||b===void 0||b.forEach(D=>this.addKeyword(D))}function ke(O,w,C){const b=O.rules.findIndex(u=>u.keyword===C);b>=0?O.rules.splice(b,0,w):(O.rules.push(w),this.logger.warn(`rule ${C} is not defined`))}function $e(O){let{metaSchema:w}=O;w!==void 0&&(O.$data&&this.opts.$data&&(w=Oe(w)),O.validateSchema=this.compile(w,!0))}const it={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Oe(O){return{anyOf:[O,it]}}})(rf);var Oi={},Ai={},Mi={};Object.defineProperty(Mi,"__esModule",{value:!0});const ZE={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Mi.default=ZE;var ur={};Object.defineProperty(ur,"__esModule",{value:!0});ur.callRef=ur.getValidate=void 0;const KE=Mr,gl=me,nt=he,pr=Ft(),yl=ot,qn=W,GE={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 KE.default(n.opts.uriResolver,s,r);if(d instanceof yl.SchemaEnv)return y(d);return g(d);function f(){if(o===l)return Qn(e,a,o,o.$async);const m=t.scopeValue("root",{ref:l});return Qn(e,(0,nt._)`${m}.validate`,l,l.$async)}function y(m){const v=wf(e,m);Qn(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}),_=t.name("valid"),h=e.subschema({schema:m,dataTypes:[],schemaPath:nt.nil,topSchemaRef:v,errSchemaPath:r},_);e.mergeEvaluated(h),e.ok(_)}}};function wf(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=wf;function Qn(e,t,r,n){const{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:c}=o,l=c.passContext?pr.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,gl.callValidateCode)(e,t,l)}`),g(t),a||s.assign(m,!0)},v=>{s.if((0,nt._)`!(${v} instanceof ${o.ValidationError})`,()=>s.throw(v)),y(v),a||s.assign(m,!1)}),e.ok(m)}function f(){e.result((0,gl.callValidateCode)(e,t,l),()=>g(t),()=>y(t))}function y(m){const v=(0,nt._)`${m}.errors`;s.assign(pr.default.vErrors,(0,nt._)`${pr.default.vErrors} === null ? ${v} : ${pr.default.vErrors}.concat(${v})`),s.assign(pr.default.errors,(0,nt._)`${pr.default.vErrors}.length`)}function g(m){var v;if(!o.opts.unevaluated)return;const _=(v=r==null?void 0:r.validate)===null||v===void 0?void 0:v.evaluated;if(o.props!==!0)if(_&&!_.dynamicProps)_.props!==void 0&&(o.props=qn.mergeEvaluated.props(s,_.props,o.props));else{const h=s.var("props",(0,nt._)`${m}.evaluated.props`);o.props=qn.mergeEvaluated.props(s,h,o.props,nt.Name)}if(o.items!==!0)if(_&&!_.dynamicItems)_.items!==void 0&&(o.items=qn.mergeEvaluated.items(s,_.items,o.items));else{const h=s.var("items",(0,nt._)`${m}.evaluated.items`);o.items=qn.mergeEvaluated.items(s,h,o.items,nt.Name)}}}ur.callRef=Qn;ur.default=GE;Object.defineProperty(Ai,"__esModule",{value:!0});const WE=Mi,BE=ur,JE=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",WE.default,BE.default];Ai.default=JE;var zi={},xi={};Object.defineProperty(xi,"__esModule",{value:!0});const hs=he,zt=hs.operators,ps={maximum:{okStr:"<=",ok:zt.LTE,fail:zt.GT},minimum:{okStr:">=",ok:zt.GTE,fail:zt.LT},exclusiveMaximum:{okStr:"<",ok:zt.LT,fail:zt.GTE},exclusiveMinimum:{okStr:">",ok:zt.GT,fail:zt.LTE}},QE={message:({keyword:e,schemaCode:t})=>(0,hs.str)`must be ${ps[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,hs._)`{comparison: ${ps[e].okStr}, limit: ${t}}`},YE={keyword:Object.keys(ps),type:"number",schemaType:"number",$data:!0,error:QE,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,hs._)`${r} ${ps[t].fail} ${n} || isNaN(${r})`)}};xi.default=YE;var qi={};Object.defineProperty(qi,"__esModule",{value:!0});const tn=he,XE={message:({schemaCode:e})=>(0,tn.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,tn._)`{multipleOf: ${e}}`},ek={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:XE,code(e){const{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0,tn._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0,tn._)`${a} !== parseInt(${a})`;e.fail$data((0,tn._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};qi.default=ek;var Di={},Ui={};Object.defineProperty(Ui,"__esModule",{value:!0});function bf(e){const t=e.length;let r=0,n=0,s;for(;n=55296&&s<=56319&&n(0,rr._)`{limit: ${e}}`},sk={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:nk,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,tk.useFunc)(e.gen,rk.default)}(${r})`;e.fail$data((0,rr._)`${a} ${o} ${n}`)}};Di.default=sk;var Vi={};Object.defineProperty(Vi,"__esModule",{value:!0});const ok=me,ak=W,wr=he,ik={message:({schemaCode:e})=>(0,wr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,wr._)`{pattern: ${e}}`},ck={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:ik,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,wr._)`new RegExp`:(0,ak.useFunc)(t,c),d=t.let("valid");t.try(()=>t.assign(d,(0,wr._)`${l}(${o}, ${i}).test(${r})`),()=>t.assign(d,!1)),e.fail$data((0,wr._)`!${d}`)}else{const c=(0,ok.usePattern)(e,s);e.fail$data((0,wr._)`!${c}.test(${r})`)}}};Vi.default=ck;var Li={};Object.defineProperty(Li,"__esModule",{value:!0});const rn=he,lk={message({keyword:e,schemaCode:t}){const r=e==="maxProperties"?"more":"fewer";return(0,rn.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,rn._)`{limit: ${e}}`},uk={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:lk,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?rn.operators.GT:rn.operators.LT;e.fail$data((0,rn._)`Object.keys(${r}).length ${s} ${n}`)}};Li.default=uk;var Fi={};Object.defineProperty(Fi,"__esModule",{value:!0});const Hr=me,nn=he,dk=W,fk={message:({params:{missingProperty:e}})=>(0,nn.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,nn._)`{missingProperty: ${e}}`},hk={keyword:"required",type:"object",schemaType:"array",$data:!0,error:fk,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 _=a.schemaEnv.baseId+a.errSchemaPath,h=`required property "${v}" is not defined at "${_}" (strictRequired)`;(0,dk.checkStrictMode)(a,h,a.opts.strictRequired)}}function l(){if(c||o)e.block$data(nn.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,()=>y(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 y(g,m){e.setParams({missingProperty:g}),t.forOf(g,n,()=>{t.assign(m,(0,Hr.propertyInData)(t,s,g,i.ownProperties)),t.if((0,nn.not)(m),()=>{e.error(),t.break()})},nn.nil)}}};Fi.default=hk;var Hi={};Object.defineProperty(Hi,"__esModule",{value:!0});const sn=he,pk={message({keyword:e,schemaCode:t}){const r=e==="maxItems"?"more":"fewer";return(0,sn.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,sn._)`{limit: ${e}}`},mk={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:pk,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?sn.operators.GT:sn.operators.LT;e.fail$data((0,sn._)`${r}.length ${s} ${n}`)}};Hi.default=mk;var Zi={},Pn={};Object.defineProperty(Pn,"__esModule",{value:!0});const Sf=Ns;Sf.code='require("ajv/dist/runtime/equal").default';Pn.default=Sf;Object.defineProperty(Zi,"__esModule",{value:!0});const Ys=De,Ze=he,_k=W,gk=Pn,yk={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}}`},vk={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:yk,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,Ys.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()?y:g)(m,v))}function f(){return l.length>0&&!l.some(m=>m==="object"||m==="array")}function y(m,v){const _=t.name("item"),h=(0,Ys.checkDataTypes)(l,_,i.opts.strictNumbers,Ys.DataType.Wrong),$=t.const("indices",(0,Ze._)`{}`);t.for((0,Ze._)`;${m}--;`,()=>{t.let(_,(0,Ze._)`${r}[${m}]`),t.if(h,(0,Ze._)`continue`),l.length>1&&t.if((0,Ze._)`typeof ${_} == "string"`,(0,Ze._)`${_} += "_"`),t.if((0,Ze._)`typeof ${$}[${_}] == "number"`,()=>{t.assign(v,(0,Ze._)`${$}[${_}]`),e.error(),t.assign(c,!1).break()}).code((0,Ze._)`${$}[${_}] = ${m}`)})}function g(m,v){const _=(0,_k.useFunc)(t,gk.default),h=t.name("outer");t.label(h).for((0,Ze._)`;${m}--;`,()=>t.for((0,Ze._)`${v} = ${m}; ${v}--;`,()=>t.if((0,Ze._)`${_}(${r}[${m}], ${r}[${v}])`,()=>{e.error(),t.assign(c,!1).break(h)})))}}};Zi.default=vk;var Ki={};Object.defineProperty(Ki,"__esModule",{value:!0});const Ro=he,$k=W,wk=Pn,bk={message:"must be equal to constant",params:({schemaCode:e})=>(0,Ro._)`{allowedValue: ${e}}`},Sk={keyword:"const",$data:!0,error:bk,code(e){const{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,Ro._)`!${(0,$k.useFunc)(t,wk.default)}(${r}, ${s})`):e.fail((0,Ro._)`${o} !== ${r}`)}};Ki.default=Sk;var Gi={};Object.defineProperty(Gi,"__esModule",{value:!0});const Wr=he,Ek=W,kk=Pn,Pk={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,Wr._)`{allowedValues: ${e}}`},Tk={keyword:"enum",schemaType:"array",$data:!0,error:Pk,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,Ek.useFunc)(t,kk.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,Wr.or)(...s.map((m,v)=>y(g,v)))}e.pass(d);function f(){t.assign(d,!1),t.forOf("v",o,g=>t.if((0,Wr._)`${l()}(${r}, ${g})`,()=>t.assign(d,!0).break()))}function y(g,m){const v=s[m];return typeof v=="object"&&v!==null?(0,Wr._)`${l()}(${r}, ${g}[${m}])`:(0,Wr._)`${r} === ${v}`}}};Gi.default=Tk;Object.defineProperty(zi,"__esModule",{value:!0});const Rk=xi,Ck=qi,Nk=Di,Ik=Vi,jk=Li,Ok=Fi,Ak=Hi,Mk=Zi,zk=Ki,xk=Gi,qk=[Rk.default,Ck.default,Nk.default,Ik.default,jk.default,Ok.default,Ak.default,Mk.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},zk.default,xk.default];zi.default=qk;var Wi={},zr={};Object.defineProperty(zr,"__esModule",{value:!0});zr.validateAdditionalItems=void 0;const nr=he,Co=W,Dk={message:({params:{len:e}})=>(0,nr.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,nr._)`{limit: ${e}}`},Uk={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:Dk,code(e){const{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Co.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Ef(e,n)}};function Ef(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,Co.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:Co.Type.Num},l),a.allErrors||r.if((0,nr.not)(l),()=>r.break())})}}zr.validateAdditionalItems=Ef;zr.default=Uk;var Bi={},xr={};Object.defineProperty(xr,"__esModule",{value:!0});xr.validateTuple=void 0;const vl=he,Yn=W,Vk=me,Lk={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return kf(e,"additionalItems",t);r.items=!0,!(0,Yn.alwaysValidSchema)(r,t)&&e.ok((0,Vk.validateArray)(e))}};function kf(e,t,r=e.schema){const{gen:n,parentSchema:s,data:o,keyword:a,it:i}=e;d(s),i.opts.unevaluated&&r.length&&i.items!==!0&&(i.items=Yn.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),l=n.const("len",(0,vl._)`${o}.length`);r.forEach((f,y)=>{(0,Yn.alwaysValidSchema)(i,f)||(n.if((0,vl._)`${l} > ${y}`,()=>e.subschema({keyword:a,schemaProp:y,dataProp:y},c)),e.ok(c))});function d(f){const{opts:y,errSchemaPath:g}=i,m=r.length,v=m===f.minItems&&(m===f.maxItems||f[t]===!1);if(y.strictTuples&&!v){const _=`"${a}" is ${m}-tuple, but minItems or maxItems/${t} are not specified or different at path "${g}"`;(0,Yn.checkStrictMode)(i,_,y.strictTuples)}}}xr.validateTuple=kf;xr.default=Lk;Object.defineProperty(Bi,"__esModule",{value:!0});const Fk=xr,Hk={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,Fk.validateTuple)(e,"items")};Bi.default=Hk;var Ji={};Object.defineProperty(Ji,"__esModule",{value:!0});const $l=he,Zk=W,Kk=me,Gk=zr,Wk={message:({params:{len:e}})=>(0,$l.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,$l._)`{limit: ${e}}`},Bk={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:Wk,code(e){const{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=!0,!(0,Zk.alwaysValidSchema)(n,t)&&(s?(0,Gk.validateAdditionalItems)(e,s):e.ok((0,Kk.validateArray)(e)))}};Ji.default=Bk;var Qi={};Object.defineProperty(Qi,"__esModule",{value:!0});const dt=he,Dn=W,Jk={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}}`},Qk={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:Jk,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,Dn.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0,Dn.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Dn.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`,y)):(t.let(f,!1),y()),e.result(f,()=>e.reset());function y(){const v=t.name("_valid"),_=t.let("count",0);g(v,()=>t.if(v,()=>m(_)))}function g(v,_){t.forRange("i",0,d,h=>{e.subschema({keyword:"contains",dataProp:h,dataPropType:Dn.Type.Num,compositeRule:!0},v),_()})}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)))}}};Qi.default=Qk;var Pf={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=he,r=W,n=me;e.error={message:({params:{property:c,depsCount:l,deps:d}})=>{const f=l===1?"property":"properties";return(0,t.str)`must have ${f} ${d} when property ${c} is present`},params:({params:{property:c,depsCount:l,deps:d,missingProperty:f}})=>(0,t._)`{property: ${c}, + missingProperty: ${f}, + depsCount: ${l}, + deps: ${d}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(c){const[l,d]=o(c);a(c,l),i(c,d)}};function o({schema:c}){const l={},d={};for(const f in c){if(f==="__proto__")continue;const y=Array.isArray(c[f])?l:d;y[f]=c[f]}return[l,d]}function a(c,l=c.schema){const{gen:d,data:f,it:y}=c;if(Object.keys(l).length===0)return;const g=d.let("missing");for(const m in l){const v=l[m];if(v.length===0)continue;const _=(0,n.propertyInData)(d,f,m,y.opts.ownProperties);c.setParams({property:m,depsCount:v.length,deps:v.join(", ")}),y.allErrors?d.if(_,()=>{for(const h of v)(0,n.checkReportMissingProp)(c,h)}):(d.if((0,t._)`${_} && (${(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:y,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 _=c.subschema({keyword:y,schemaProp:v},m);c.mergeValidEvaluated(_,m)},()=>d.var(m,!0)),c.ok(m))}e.validateSchemaDeps=i,e.default=s})(Pf);var Yi={};Object.defineProperty(Yi,"__esModule",{value:!0});const Tf=he,Yk=W,Xk={message:"property name must be valid",params:({params:e})=>(0,Tf._)`{propertyName: ${e.propertyName}}`},eP={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Xk,code(e){const{gen:t,schema:r,data:n,it:s}=e;if((0,Yk.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,Tf.not)(o),()=>{e.error(!0),s.allErrors||t.break()})}),e.ok(o)}};Yi.default=eP;var Ds={};Object.defineProperty(Ds,"__esModule",{value:!0});const Un=me,vt=he,tP=Ft(),Vn=W,rP={message:"must NOT have additional properties",params:({params:e})=>(0,vt._)`{additionalProperty: ${e.additionalProperty}}`},nP={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:rP,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,Vn.alwaysValidSchema)(a,r))return;const l=(0,Un.allSchemaProperties)(n.properties),d=(0,Un.allSchemaProperties)(n.patternProperties);f(),e.ok((0,vt._)`${o} === ${tP.default.errors}`);function f(){t.forIn("key",s,_=>{!l.length&&!d.length?m(_):t.if(y(_),()=>m(_))})}function y(_){let h;if(l.length>8){const $=(0,Vn.schemaRefOrVal)(a,n.properties,"properties");h=(0,Un.isOwnProperty)(t,$,_)}else l.length?h=(0,vt.or)(...l.map($=>(0,vt._)`${_} === ${$}`)):h=vt.nil;return d.length&&(h=(0,vt.or)(h,...d.map($=>(0,vt._)`${(0,Un.usePattern)(e,$)}.test(${_})`))),(0,vt.not)(h)}function g(_){t.code((0,vt._)`delete ${s}[${_}]`)}function m(_){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){g(_);return}if(r===!1){e.setParams({additionalProperty:_}),e.error(),i||t.break();return}if(typeof r=="object"&&!(0,Vn.alwaysValidSchema)(a,r)){const h=t.name("valid");c.removeAdditional==="failing"?(v(_,h,!1),t.if((0,vt.not)(h),()=>{e.reset(),g(_)})):(v(_,h),i||t.if((0,vt.not)(h),()=>t.break()))}}function v(_,h,$){const S={keyword:"additionalProperties",dataProp:_,dataPropType:Vn.Type.Str};$===!1&&Object.assign(S,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(S,h)}}};Ds.default=nP;var Xi={};Object.defineProperty(Xi,"__esModule",{value:!0});const sP=zs(),wl=me,Xs=W,bl=Ds,oP={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 sP.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=Xs.mergeEvaluated.props(t,(0,Xs.toHash)(a),o.props));const i=a.filter(f=>!(0,Xs.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)}}};Xi.default=oP;var ec={};Object.defineProperty(ec,"__esModule",{value:!0});const Sl=me,Ln=he,El=W,kl=W,aP={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;y();function y(){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 _ in l)new RegExp(v).test(_)&&(0,El.checkStrictMode)(o,`property ${_} matches pattern ${v} (use allowMatchingProperties)`)}function m(v){t.forIn("key",n,_=>{t.if((0,Ln._)`${(0,Sl.usePattern)(e,v)}.test(${_})`,()=>{const h=c.includes(v);h||e.subschema({keyword:"patternProperties",schemaProp:v,dataProp:_,dataPropType:kl.Type.Str},d),o.opts.unevaluated&&f!==!0?t.assign((0,Ln._)`${f}[${_}]`,!0):!h&&!o.allErrors&&t.if((0,Ln.not)(d),()=>t.break())})})}}};ec.default=aP;var tc={};Object.defineProperty(tc,"__esModule",{value:!0});const iP=W,cP={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,iP.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"}};tc.default=cP;var rc={};Object.defineProperty(rc,"__esModule",{value:!0});const lP=me,uP={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:lP.validateUnion,error:{message:"must match a schema in anyOf"}};rc.default=uP;var nc={};Object.defineProperty(nc,"__esModule",{value:!0});const Xn=he,dP=W,fP={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,Xn._)`{passingSchemas: ${e.passing}}`},hP={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:fP,code(e){const{gen:t,schema:r,parentSchema:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;const o=r,a=t.let("valid",!1),i=t.let("passing",null),c=t.name("_valid");e.setParams({passing:i}),t.block(l),e.result(a,()=>e.reset(),()=>e.error(!0));function l(){o.forEach((d,f)=>{let y;(0,dP.alwaysValidSchema)(s,d)?t.var(c,!0):y=e.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},c),f>0&&t.if((0,Xn._)`${c} && ${a}`).assign(a,!1).assign(i,(0,Xn._)`[${i}, ${f}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,f),y&&e.mergeEvaluated(y,Xn.Name)})})}}};nc.default=hP;var sc={};Object.defineProperty(sc,"__esModule",{value:!0});const pP=W,mP={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,pP.alwaysValidSchema)(n,o))return;const i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i)})}};sc.default=mP;var oc={};Object.defineProperty(oc,"__esModule",{value:!0});const ms=he,Rf=W,_P={message:({params:e})=>(0,ms.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,ms._)`{failingKeyword: ${e.ifClause}}`},gP={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:_P,code(e){const{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,Rf.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const s=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,ms.not)(i),l("else"));e.pass(a,()=>e.error(!0));function c(){const d=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},i);e.mergeEvaluated(d)}function l(d,f){return()=>{const y=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(y,a),f?t.assign(f,(0,ms._)`${d}`):e.setParams({ifClause:d})}}}};function Pl(e,t){const r=e.schema[t];return r!==void 0&&!(0,Rf.alwaysValidSchema)(e,r)}oc.default=gP;var ac={};Object.defineProperty(ac,"__esModule",{value:!0});const yP=W,vP={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,yP.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};ac.default=vP;Object.defineProperty(Wi,"__esModule",{value:!0});const $P=zr,wP=Bi,bP=xr,SP=Ji,EP=Qi,kP=Pf,PP=Yi,TP=Ds,RP=Xi,CP=ec,NP=tc,IP=rc,jP=nc,OP=sc,AP=oc,MP=ac;function zP(e=!1){const t=[NP.default,IP.default,jP.default,OP.default,AP.default,MP.default,PP.default,TP.default,kP.default,RP.default,CP.default];return e?t.push(wP.default,SP.default):t.push($P.default,bP.default),t.push(EP.default),t}Wi.default=zP;var ic={},cc={};Object.defineProperty(cc,"__esModule",{value:!0});const xe=he,xP={message:({schemaCode:e})=>(0,xe.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,xe._)`{format: ${e}}`},qP={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:xP,code(e,t){const{gen:r,data:n,$data:s,schema:o,schemaCode:a,it:i}=e,{opts:c,errSchemaPath:l,schemaEnv:d,self:f}=i;if(!c.validateFormats)return;s?y():g();function y(){const m=r.scopeValue("formats",{ref:f.formats,code:c.code.formats}),v=r.const("fDef",(0,xe._)`${m}[${a}]`),_=r.let("fType"),h=r.let("format");r.if((0,xe._)`typeof ${v} == "object" && !(${v} instanceof RegExp)`,()=>r.assign(_,(0,xe._)`${v}.type || "string"`).assign(h,(0,xe._)`${v}.validate`),()=>r.assign(_,(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 R=d.$async?(0,xe._)`(${v}.async ? await ${h}(${n}) : ${h}(${n}))`:(0,xe._)`${h}(${n})`,k=(0,xe._)`(typeof ${h} == "function" ? ${R} : ${h}.test(${n}))`;return(0,xe._)`${h} && ${h} !== true && ${_} === ${t} && !${k}`}}function g(){const m=f.formats[o];if(!m){$();return}if(m===!0)return;const[v,_,h]=S(m);v===t&&e.pass(R());function $(){if(c.strictSchema===!1){f.logger.warn(k());return}throw new Error(k());function k(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function S(k){const M=k instanceof RegExp?(0,xe.regexpCode)(k):c.code.formats?(0,xe._)`${c.code.formats}${(0,xe.getProperty)(o)}`:void 0,x=r.scopeValue("formats",{key:o,ref:k,code:M});return typeof k=="object"&&!(k instanceof RegExp)?[k.type||"string",k.validate,(0,xe._)`${x}.validate`]:["string",k,x]}function R(){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 _=="function"?(0,xe._)`${h}(${n})`:(0,xe._)`${h}.test(${n})`}}}};cc.default=qP;Object.defineProperty(ic,"__esModule",{value:!0});const DP=cc,UP=[DP.default];ic.default=UP;var Cr={};Object.defineProperty(Cr,"__esModule",{value:!0});Cr.contentVocabulary=Cr.metadataVocabulary=void 0;Cr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Cr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(Oi,"__esModule",{value:!0});const VP=Ai,LP=zi,FP=Wi,HP=ic,Tl=Cr,ZP=[VP.default,LP.default,(0,FP.default)(),HP.default,Tl.metadataVocabulary,Tl.contentVocabulary];Oi.default=ZP;var lc={},Us={};Object.defineProperty(Us,"__esModule",{value:!0});Us.DiscrError=void 0;var Rl;(function(e){e.Tag="tag",e.Mapping="mapping"})(Rl||(Us.DiscrError=Rl={}));Object.defineProperty(lc,"__esModule",{value:!0});const yr=he,No=Us,Cl=ot,KP=Mr,GP=W,WP={message:({params:{discrError:e,tagName:t}})=>e===No.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,yr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},BP={keyword:"discriminator",type:"object",schemaType:"object",error:WP,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,yr._)`${r}${(0,yr.getProperty)(i)}`);t.if((0,yr._)`typeof ${l} == "string"`,()=>d(),()=>e.error(!1,{discrError:No.DiscrError.Tag,tag:l,tagName:i})),e.ok(c);function d(){const g=y();t.if(!1);for(const m in g)t.elseIf((0,yr._)`${l} === ${m}`),t.assign(c,f(g[m]));t.else(),e.error(!1,{discrError:No.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,yr.Name),m}function y(){var g;const m={},v=h(s);let _=!0;for(let R=0;Rthis.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=zs();Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var d=he;Object.defineProperty(t,"_",{enumerable:!0,get:function(){return d._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return d.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return d.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return d.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return d.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return d.CodeGen}});var f=Ni();Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return f.default}});var y=Mr;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return y.default}})})(So,So.exports);var n1=So.exports;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;const t=n1,r=he,n=r.operators,s={formatMaximum:{okStr:"<=",ok:n.LTE,fail:n.GT},formatMinimum:{okStr:">=",ok:n.GTE,fail:n.LT},formatExclusiveMaximum:{okStr:"<",ok:n.LT,fail:n.GTE},formatExclusiveMinimum:{okStr:">",ok:n.GT,fail:n.LTE}},o={message:({keyword:i,schemaCode:c})=>(0,r.str)`should be ${s[i].okStr} ${c}`,params:({keyword:i,schemaCode:c})=>(0,r._)`{comparison: ${s[i].okStr}, limit: ${c}}`};e.formatLimitDefinition={keyword:Object.keys(s),type:"string",schemaType:"string",$data:!0,error:o,code(i){const{gen:c,data:l,schemaCode:d,keyword:f,it:y}=i,{opts:g,self:m}=y;if(!g.validateFormats)return;const v=new t.KeywordCxt(y,m.RULES.all.format.definition,"format");v.$data?_():h();function _(){const S=c.scopeValue("formats",{ref:m.formats,code:g.code.formats}),R=c.const("fmt",(0,r._)`${S}[${v.schemaCode}]`);i.fail$data((0,r.or)((0,r._)`typeof ${R} != "object"`,(0,r._)`${R} instanceof RegExp`,(0,r._)`typeof ${R}.compare != "function"`,$(R)))}function h(){const S=v.schema,R=m.formats[S];if(!R||R===!0)return;if(typeof R!="object"||R instanceof RegExp||typeof R.compare!="function")throw new Error(`"${f}": format "${S}" does not define "compare" function`);const k=c.scopeValue("formats",{key:S,ref:R,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,y]=d.mode==="fast"?[r.fastFormats,a]:[r.fullFormats,o],g=d.formats||r.formatNames;return c(l,g,f,y),d.keywords&&(0,n.default)(l),l};i.get=(l,d="full")=>{const y=(d==="fast"?r.fastFormats:r.fullFormats)[l];if(!y)throw new Error(`Unknown format "${l}"`);return y};function c(l,d,f,y){var g,m;(g=(m=l.opts.code).formats)!==null&&g!==void 0||(m.formats=(0,s._)`require("ajv-formats/dist/formats").${y}`);for(const v of d)l.addFormat(v,f[v])}e.exports=t=i,Object.defineProperty(t,"__esModule",{value:!0}),t.default=i})(bo,bo.exports);var s1=bo.exports;const o1=Dl(s1);function a1(){const e=new jS({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return o1(e),e}class i1{constructor(t){this._ajv=t??a1()}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 c1{constructor(t){this._client=t}async*callToolStream(t,r=or,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(oe.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(oe.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(oe.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 l1(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 u1(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 es(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&&es(o,r[s])}}if(Array.isArray(e.anyOf))for(const r of e.anyOf)typeof r!="boolean"&&es(r,t);if(Array.isArray(e.oneOf))for(const r of e.oneOf)typeof r!="boolean"&&es(r,t)}}function d1(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 f1 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 i1,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",Ta,t.tools,async()=>(await this.listTools()).tools),t.prompts&&((o=(s=this._serverCapabilities)==null?void 0:s.prompts)!=null&&o.listChanged)&&this._setupListChangedHandler("prompts",Ea,t.prompts,async()=>(await this.listPrompts()).prompts),t.resources&&((i=(a=this._serverCapabilities)==null?void 0:a.resources)!=null&&i.listChanged)&&this._setupListChangedHandler("resources",va,t.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new c1(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=ov(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=xt(Zu,c);if(!d.success){const R=d.error instanceof Error?d.error.message:String(d.error);throw new ne(oe.InvalidParams,`Invalid elicitation request: ${R}`)}const{params:f}=d.data;f.mode=f.mode??"form";const{supportsFormMode:y,supportsUrlMode:g}=d1(this._capabilities.elicitation);if(f.mode==="form"&&!y)throw new ne(oe.InvalidParams,"Client does not support form-mode elicitation requests");if(f.mode==="url"&&!g)throw new ne(oe.InvalidParams,"Client does not support URL-mode elicitation requests");const m=await Promise.resolve(r(c,l));if(f.task){const R=xt(cn,m);if(!R.success){const k=R.error instanceof Error?R.error.message:String(R.error);throw new ne(oe.InvalidParams,`Invalid task creation result: ${k}`)}return R.data}const v=xt(Ku,m);if(!v.success){const R=v.error instanceof Error?v.error.message:String(v.error);throw new ne(oe.InvalidParams,`Invalid elicitation result: ${R}`)}const _=v.data,h=f.mode==="form"?f.requestedSchema:void 0;if(f.mode==="form"&&_.action==="accept"&&_.content&&h&&(S=($=this._capabilities.elicitation)==null?void 0:$.form)!=null&&S.applyDefaults)try{es(h,_.content)}catch{}return _};return super.setRequestHandler(t,i)}if(a==="sampling/createMessage"){const i=async(c,l)=>{const d=xt(Ra,c);if(!d.success){const _=d.error instanceof Error?d.error.message:String(d.error);throw new ne(oe.InvalidParams,`Invalid sampling request: ${_}`)}const{params:f}=d.data,y=await Promise.resolve(r(c,l));if(f.task){const _=xt(cn,y);if(!_.success){const h=_.error instanceof Error?_.error.message:String(_.error);throw new ne(oe.InvalidParams,`Invalid task creation result: ${h}`)}return _.data}const m=f.tools||f.toolChoice?Hu:Fu,v=xt(m,y);if(!v.success){const _=v.error instanceof Error?v.error.message:String(v.error);throw new ne(oe.InvalidParams,`Invalid sampling result: ${_}`)}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:ks,capabilities:this._capabilities,clientInfo:this._clientInfo}},Tu,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!Ag.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;l1((n=(r=this._serverCapabilities)==null?void 0:r.tasks)==null?void 0:n.requests,t,"Server")}assertTaskHandlerCapability(t){var r;this._capabilities&&u1((r=this._capabilities.tasks)==null?void 0:r.requests,t,"Client")}async ping(t){return this.request({method:"ping"},vr,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}},vr,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},$a,r)}async listResources(t,r){return this.request({method:"resources/list",params:t},ma,r)}async listResourceTemplates(t,r){return this.request({method:"resources/templates/list",params:t},_a,r)}async readResource(t,r){return this.request({method:"resources/read",params:t},ya,r)}async subscribeResource(t,r){return this.request({method:"resources/subscribe",params:t},vr,r)}async unsubscribeResource(t,r){return this.request({method:"resources/unsubscribe",params:t},vr,r)}async callTool(t,r=or,n){if(this.isToolTaskRequired(t.name))throw new ne(oe.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(oe.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(oe.InvalidParams,`Structured content does not match the tool's output schema: ${a.errorMessage}`)}catch(a){throw a instanceof ne?a:new ne(oe.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},Pa,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(t,r,n,s){const o=wy.safeParse(n);if(!o.success)throw new Error(`Invalid ${t} listChanged options: ${o.error.message}`);if(typeof n.onChanged!="function")throw new Error(`Invalid ${t} listChanged options: onChanged must be a function`);const{autoRefresh:a,debounceMs:i}=o.data,{onChanged:c}=n,l=async()=>{if(!a){c(null,null);return}try{const f=await s();c(null,f)}catch(f){const y=f instanceof Error?f:new Error(String(f));c(y,null)}},d=()=>{if(i){const f=this._listChangedDebounceTimers.get(t);f&&clearTimeout(f);const y=setTimeout(l,i);this._listChangedDebounceTimers.set(t,y)}else l()};this.setNotificationHandler(r,d)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}var uc={};/*! + * 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,h1=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,Cf=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,p1=/\\([\u000b\u0020-\u00ff])/g,m1=/([\\"])/g,Nf=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;uc.format=_1;uc.parse=g1;function _1(e){if(!e||typeof e!="object")throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!Nf.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&&!h1.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(m1,"\\$1")+'"'}function $1(e){this.parameters=Object.create(null),this.type=e}function w1(e){if(e)try{return uc.parse(e).type}catch{const t=(e.split(";",1)[0]??"").trim().toLowerCase();return t===""||e.slice(t.length).includes(",")?void 0:t}}function Io(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function b1(e=fetch,t){return t?async(r,n)=>{const s={...t,...n,headers:n!=null&&n.headers?{...Io(t.headers),...Io(n.headers)}:t.headers};return e(r,s)}:e}let dc;dc=globalThis.crypto;async function S1(e){return(await dc).getRandomValues(new Uint8Array(e))}async function E1(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 k1(e),r=await P1(t);return{code_verifier:t,code_challenge:r}}const Ke=V_().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:jg.custom,message:"URL must be parseable",fatal:!0}),Ch}).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"}),R1=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()}),If=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()}),C1=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()}),N1=A({...C1.shape,...If.pick({code_challenge_methods_supported:!0}).shape}),I1=A({access_token:P(),id_token:P().optional(),token_type:P(),expires_in:Og().optional(),scope:P().optional(),refresh_token:P().optional()}).strip(),j1=A({error:P(),error_description:P().optional(),error_uri:P().optional()}),Il=Ke.optional().or(I("").transform(()=>{})),O1=A({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:ta().optional(),software_id:P().optional(),software_version:P().optional(),software_statement:P().optional()}).strip(),A1=A({client_id:P(),client_secret:P().optional(),client_id_issued_at:ue().optional(),client_secret_expires_at:ue().optional()}).strip(),M1=O1.merge(A1);A({error:P(),error_description:P().optional()}).strip();A({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 x1({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 B1(e,t,r,n){const s=new URL(e),o=(n==null?void 0:n.protocolVersion)??ks;let a;if(n!=null&&n.metadataUrl)a=new URL(n.metadataUrl);else{const c=G1(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)&&W1(i,s.pathname)){const c=new URL(`/.well-known/${t}`,s);i=await Ol(c,o,r)}return i}function J1(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 Af(e,{fetchFn:t=fetch,protocolVersion:r=ks}={}){var o;const n={"MCP-Protocol-Version":r,Accept:"application/json"},s=J1(e);for(const{url:a,type:i}of s){const c=await fc(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"?If.parse(await c.json()):N1.parse(await c.json())}}}async function Q1(e,t){let r,n;try{r=await Of(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 Af(n,{fetchFn:t==null?void 0:t.fetchFn});return{authorizationServerUrl:n,authorizationServerMetadata:s,resourceMetadata:r}}async function Y1(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(eo))throw new Error(`Incompatible auth server: does not support response type ${eo}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(to))throw new Error(`Incompatible auth server: does not support code challenge method ${to}`)}else i=new URL("/authorize",e);const c=await T1(),l=c.code_verifier,d=c.code_challenge;return i.searchParams.set("response_type",eo),i.searchParams.set("client_id",r.client_id),i.searchParams.set("code_challenge",d),i.searchParams.set("code_challenge_method",to),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 X1(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}async function Mf(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=U1(n,d);V1(f,n,c,r)}const l=await(a??fetch)(i,{method:"POST",headers:c,body:r});if(!l.ok)throw await jf(l);return I1.parse(await l.json())}async function eT(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 Mf(e,{metadata:t,tokenRequestParams:i,clientInformation:r,addClientAuthentication:o,resource:s,fetchFn:a});return{refresh_token:n,...c}}async function tT(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=X1(s,l,e.redirectUrl)}const c=await e.clientInformation();return Mf(t,{metadata:r,tokenRequestParams:i,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:n,fetchFn:o})}async function rT(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 jf(a);return M1.parse(await a.json())}class so extends Error{constructor(t,r){super(t),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}}const Al=10,nT=13,Qt=32;function oo(e){}function sT(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=oo,onError:r=oo,onRetry:n=oo,onComment:s,maxBufferSize:o}=e,a=[];let i=0,c=!0,l,d="",f=0,y,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 K=_(k);K!==""&&(a.push(K),i=K.length),v();return}if(k.indexOf(` +`)===-1&&k.indexOf("\r")===-1){a.push(k),i+=k.length,v();return}a.push(k);const M=a.join("");a.length=0,i=0;const x=_(M);x!==""&&(a.push(x),i=x.length),v()}function v(){o!==void 0&&(i+d.length<=o||(g=!0,a.length=0,i=0,l=void 0,d="",f=0,y=void 0,r(new so(`Buffered data exceeded max buffer size of ${o} characters`,{type:"max-buffer-size-exceeded"}))))}function _(k){let M=0;if(k.indexOf("\r")===-1){let x=k.indexOf(` +`,M);for(;x!==-1;){if(M===x){f>0&&t({id:l,event:y,data:d}),l=void 0,d="",f=0,y=void 0,M=x+1,x=k.indexOf(` +`,M);continue}const K=k.charCodeAt(M);if(Ml(k,M,K)){const J=k.charCodeAt(M+5)===Qt?M+6:M+5,H=k.slice(J,x);if(f===0&&k.charCodeAt(x+1)===Al){t({id:l,event:y,data:H}),l=void 0,d="",y=void 0,M=x+2,x=k.indexOf(` +`,M);continue}d=f===0?H:`${d} +${H}`,f++}else zl(k,M,K)?y=k.slice(k.charCodeAt(M+6)===Qt?M+7:M+6,x)||void 0:h(k,M,x);M=x+1,x=k.indexOf(` +`,M)}return k.slice(M)}for(;M20?`${k.slice(0,20)}…`:k}"`,{type:"unknown-field",field:k,value:M,line:x}));break}}function S(){f>0&&t({id:l,event:y,data:d}),l=void 0,d="",f=0,y=void 0}function R(k={}){if(k.consume&&a.length>0){const M=a.join("");h(M,0,M.length)}c=!0,l=void 0,d="",f=0,y=void 0,a.length=0,i=0,g=!1}return{feed:m,reset:R}}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 oT extends TransformStream{constructor({onError:t,onRetry:r,onComment:n,maxBufferSize:s}={}){let o;super({start(a){o=sT({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 aT={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class _r extends Error{constructor(t,r){super(`Streamable HTTP error: ${r}`),this.code=t}}class iT{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=b1(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)??aT}async _authThenStart(){var r;if(!this._authProvider)throw new mr("No auth provider");let t;try{t=await Fn(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 mr;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=Io((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 _r(i.status,`Failed to open SSE stream: ${i.statusText}`)}this._handleSseStream(i.body,t,!0)}catch(a){throw(o=this.onerror)==null||o.call(this,a),a}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const r=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,s=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(n,t),s)}_scheduleReconnection(t,r=0){var o;const n=this._reconnectionOptions.maxRetries;if(r>=n){(o=this.onerror)==null||o.call(this,new Error(`Maximum reconnection attempts (${n}) exceeded.`));return}const s=this._getNextReconnectionDelay(r);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(a=>{var i;(i=this.onerror)==null||i.call(this,new Error(`Failed to reconnect SSE stream: ${a instanceof Error?a.message:String(a)}`)),this._scheduleReconnection(t,r+1)})},s)}_handleSseStream(t,r,n){if(!t)return;const{onresumptiontoken:s,replayMessageId:o}=r;let a,i=!1,c=!1;(async()=>{var d,f,y,g;try{const m=t.pipeThrough(new TextDecoderStream).pipeThrough(new oT({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=Hn.parse(JSON.parse(h.data));Zr(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((y=this.onerror)==null||y.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 mr("No auth provider");if(await Fn(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new mr("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:ho(t)?t.id:void 0}).catch(S=>{var R;return(R=this.onerror)==null?void 0:R.call(this,S)});return}const f=await this._commonHeaders();f.set("content-type","application/json"),f.set("accept","application/json, text/event-stream");const y={...this._requestInit,method:"POST",headers:f,body:JSON.stringify(t),signal:(n=this._abortController)==null?void 0:n.signal},g=await(this._fetch??fetch)(this._url,y),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 _r(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:R,scope:k}=jl(g);if(this._resourceMetadataUrl=R,this._scope=k,await Fn(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new mr;return this._hasCompletedAuthFlow=!0,this.send(t)}if(g.status===403&&this._authProvider){const{resourceMetadataUrl:R,scope:k,error:M}=jl(g);if(M==="insufficient_scope"){const x=g.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===x)throw new _r(403,"Server returned 403 after trying upscoping");if(k&&(this._scope=k),R&&(this._resourceMetadataUrl=R),this._lastUpscopingHeader=x??void 0,await Fn(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new mr;return this.send(t)}}throw new _r(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()),Jg(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(S=>{var R;return(R=this.onerror)==null?void 0:R.call(this,S)});return}const _=(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"),$=w1(h);if(_)if($==="text/event-stream")this._handleSseStream(g.body,{onresumptiontoken:d},!1);else if($==="application/json"){const S=await g.json(),R=Array.isArray(S)?S.map(k=>Hn.parse(k)):[Hn.parse(S)];for(const k of R)(o=this.onmessage)==null||o.call(this,k)}else throw await((a=g.body)==null?void 0:a.cancel()),new _r(-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 _r(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 cT="https://mcp.excalidraw.com/mcp",lT="mcp.excalidraw.com",uT="/api/v1/chat/mcp-apps/excalidraw",zf="ui://excalidraw/mcp-app.html",dT=["read_me","create_view"],xf=new Set(["export_to_excalidraw","save_checkpoint","read_checkpoint"]),fT=256*1024,hT=1024*1024,pT={excalidraw:{id:"excalidraw",endpoint:cT,hostname:lT,resourceUri:zf,modelTools:dT,appTools:xf}};function mT(e){return pT[e]}function _T(){return new URL(Lf(uT),window.location.origin)}class gT{constructor(){de(this,"client",new f1({name:"pwc-chat-mcp-app-host",version:"1"}));de(this,"transport",new iT(_T(),{requestInit:{credentials:"include"}}));de(this,"connected");de(this,"bytes",0)}connect(){return this.connected??(this.connected=this.client.connect(this.transport)),this.connected}async readResource(t){if(t!==zf)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 vT(n.text);return{text:n.text,digest:s}}async callTool(t,r){if(!xf.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=fT){const n=new TextEncoder().encode(t).byteLength;if(n>r||this.bytes+n>hT)throw new Error("App request exceeds host limit");this.bytes+=n}}let xl;function yT(){return xl??(xl=new gT),xl}async function vT(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)),$T=({block:e})=>{const t=fe.useRef(null),r=fe.useRef(null),[n,s]=fe.useState(),[o,a]=fe.useState(e.status),[i,c]=fe.useState(ql(e.height)),[l,d]=fe.useState(!1),[f,y]=fe.useState(0);fe.useEffect(()=>{mT(e.provider);{a("unavailable");return}},[f,e.provider,e.resource_uri,e.status]),fe.useEffect(()=>{if(!n||!t.current||o!=="ready")return;const m=t.current,v=new Rv(null,{name:"Papers with Code",version:"1"},{serverTools:{},openLinks:{},logging:{},...e.permissions.clipboardWrite?{clipboard:{write:{}}}:{}},{hostContext:{theme:document.documentElement.dataset.theme==="dark"?"dark":"light",displayMode:l?"fullscreen":"inline"}});return v.oncalltool=async({name:_,arguments:h})=>{if(e.public_fork&&_!=="export_to_excalidraw")throw new Error("Shared diagrams cannot mutate owner state");return yT().callTool(_,h??{})},v.onopenlink=async({url:_})=>{const h=new URL(_);if(h.protocol!=="https:"||h.hostname!=="excalidraw.com")throw new Error("External navigation denied");if(!window.confirm("This export opens Excalidraw and uploads the diagram to its service. Continue?"))throw new Error("Export cancelled");return window.open(h.href,"_blank","noopener,noreferrer"),{}},v.onsizechange=({height:_})=>{typeof _=="number"&&c(ql(_))},v.oninitialized=()=>{v.sendToolInput({arguments:{elements:JSON.parse(e.input.elements)}}),v.sendToolResult(e.result)},r.current=v,v.connect(new Pv(m.contentWindow??void 0,m.contentWindow)).catch(()=>a("error")),()=>{v.teardownResource({}),r.current=null}},[n,o,l,e]);const g=o==="unavailable"||o==="incompatible"||o==="error";return T.jsxs("section",{className:`chat-mcp-app${l?" chat-mcp-app-fullscreen":""}`,"aria-label":"Interactive Excalidraw diagram",children:[T.jsxs("header",{children:[T.jsx("strong",{children:"Visual explanation"}),T.jsx("span",{children:"Experimental · powered by Excalidraw"}),T.jsx("button",{type:"button",onClick:()=>d(m=>!m),children:l?"Exit fullscreen":"Fullscreen"})]}),T.jsx("p",{className:"chat-mcp-disclosure",children:"Diagram content is processed by the remote Excalidraw MCP service."}),o==="loading"&&T.jsx("div",{className:"chat-mcp-loading",role:"status",children:"Loading interactive diagram…"}),g&&T.jsxs("div",{className:"chat-mcp-error",children:["Interactive diagram unavailable. The cited text answer is still available.",T.jsx("button",{type:"button",onClick:()=>y(m=>m+1),children:"Retry diagram"})]}),n&&o==="ready"&&T.jsx("iframe",{ref:t,title:"Interactive Excalidraw diagram",sandbox:"allow-scripts",allow:e.permissions.clipboardWrite?"clipboard-write":void 0,srcDoc:n,style:{height:i}})]})};function wT(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 bT(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 ST(e,t=240){const r=e.content.trim();return r.length<=t?r:`${r.slice(0,t).trimEnd()}…`}const ET="https://huggingface.co/pro",kT="https://huggingface.co/docs/inference-providers/pricing",PT="https://paperswithcode.co/chat",qf=()=>T.jsx("span",{className:"chat-caret"}),TT=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},RT=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(T.jsxs("span",{className:"chat-inline-paper-mention",children:[T.jsx(oh,{size:13,"aria-hidden":"true"}),T.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)),T.jsx(T.Fragment,{children:r})},NT=({block:e,papers:t,citations:r,webCitations:n,onToggle:s})=>e.active?T.jsxs("div",{className:"chat-reason-live",children:[T.jsxs("div",{className:"chat-reason-live-head",children:[T.jsx(Ho,{})," ",T.jsx("span",{children:"Thinking…"})]}),T.jsxs("div",{className:"chat-reason-live-body chat-answer chat-reason-markdown",children:[T.jsx(ao,{text:e.text,streaming:!0,papers:t,citations:r,webCitations:n}),T.jsx(qf,{})]})]}):T.jsxs("div",{className:"chat-reason-done",children:[T.jsxs("button",{type:"button",className:"chat-reason-done-head",onClick:s,"aria-expanded":e.open,children:[T.jsx(Bf,{}),T.jsx("span",{children:"Thought for a few seconds"}),T.jsx(Fl,{open:e.open})]}),e.open&&T.jsx("div",{className:"chat-reason-done-body chat-answer chat-reason-markdown",children:T.jsx(ao,{text:e.text,papers:t,citations:r,webCitations:n})})]}),IT=({block:e,papers:t,onToggle:r})=>{var d,f,y,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 T.jsxs("div",{className:`chat-tool${n?" chat-tool-running":""}${o?" chat-tool-failed":""}`,children:[T.jsxs("button",{type:"button",className:"chat-tool-head",onClick:r,disabled:n,"aria-expanded":n?void 0:e.open,children:[T.jsxs("span",{className:"chat-tool-head-left",children:[n?T.jsx(Ho,{}):T.jsx(Jf,{}),T.jsx("code",{className:"chat-tool-name",children:e.name}),T.jsx("span",{className:"chat-tool-query",children:s?i:`("${a}")`})]}),T.jsxs("span",{className:"chat-tool-head-right",children:[T.jsx("span",{className:"chat-tool-status",children:l}),!n&&T.jsx(Fl,{open:e.open})]})]}),!n&&e.open&&T.jsxs("div",{className:"chat-tool-body",children:[T.jsxs("div",{className:"chat-tool-args",children:[T.jsx("span",{className:"chat-tool-label",children:"arguments"}),T.jsx("pre",{children:JSON.stringify(e.args,null,2)})]}),s?T.jsxs(T.Fragment,{children:[T.jsxs("div",{className:"chat-tool-output-head",children:[T.jsx("span",{className:"chat-tool-label",children:"result"}),T.jsx("button",{type:"button",className:"chat-tool-copy",onClick:()=>void navigator.clipboard.writeText(c),children:"Copy"})]}),T.jsx("pre",{className:"chat-tool-output",children:T.jsx("code",{children:c})}),((f=e.metadata)==null?void 0:f.output_truncated)&&T.jsx("div",{className:"chat-tool-truncated",children:"Output was truncated."})]}):T.jsxs(T.Fragment,{children:[T.jsxs("div",{className:"chat-tool-label chat-tool-results-label",children:["returned ",((y=e.results)==null?void 0:y.length)??0," papers"]}),T.jsx("ol",{className:"chat-tool-results",children:(g=e.results)==null?void 0:g.map(m=>T.jsxs("li",{className:"chat-hit",children:[T.jsx("div",{className:"chat-hit-top",children:T.jsx(Zl,{routeId:m.route_id,paper:t[m.route_id],className:"chat-hit-title",children:m.title})}),T.jsx("div",{className:"chat-hit-meta",children:[wT(m.metadata),bT(m.metadata)].filter(Boolean).join(" · ")}),T.jsxs("div",{className:"chat-hit-snippet",children:[ST(m),m.content_truncated&&T.jsx("span",{className:"chat-hit-truncated",children:" (truncated)"})]})]},m.route_id))})]})]})]})},jT=({block:e,papers:t,citations:r,webCitations:n,streaming:s})=>T.jsxs("div",{className:"chat-answer",children:[T.jsx(ao,{text:e.text,streaming:s,papers:t,citations:r,webCitations:n}),s&&!!e.text.trim()&&T.jsx(qf,{})]}),OT=({block:e})=>T.jsx($T,{block:e}),Df=e=>{const t=fe.useRef(null),r=fe.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 fe.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}},AT=({id:e,text:t,paperSelection:r,editNotice:n,onCancel:s,onResend:o,onResendDraft:a})=>{const[i,c]=fe.useState(t),[l,d]=fe.useState(r),[f,y]=fe.useState(!1),{textareaRef:g,resize:m}=Df(t);fe.useLayoutEffect(m,[m,i]);const v=!!i.trim()&&i.length<=8e3,_=()=>{if(!v||f)return;y(!0),((a==null?void 0:a({text:i,paperMentions:[],...l?{paperSelection:l}:{}}))??(o==null?void 0:o(i))??!1)||y(!1)};return T.jsx("div",{className:"chat-msg chat-msg-user chat-msg-user-editing","data-message-id":e,children:T.jsxs("div",{className:"chat-inline-editor",children:[l&&T.jsx(ws,{selection:l,editable:!0,onRemove:()=>d(void 0)}),T.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(),_())}}),n&&T.jsx("div",{className:"chat-inline-editor-notice",children:n}),T.jsxs("div",{className:"chat-inline-editor-actions",children:[T.jsx("button",{type:"button",onClick:s,children:"Cancel"}),T.jsx("button",{type:"button",className:"chat-inline-editor-send",disabled:!v||f,onClick:_,children:"Send"})]})]})})},MT=({id:e,text:t,paperMentions:r,paperSelection:n,enabled:s,editNotice:o,onCancel:a,onResend:i,onResendDraft:c})=>{const[l,d]=fe.useState({text:t,paperMentions:r,...n?{paperSelection:n}:{}}),[f,y]=fe.useState(!1),[g,m]=fe.useState(0),{textareaRef:v,resize:_}=Df(t),h=Ul({draft:l,onChange:d,enabled:s,textareaRef:v});fe.useLayoutEffect(_,[_,l.text]);const $=!!l.text.trim()&&l.text.length<=8e3&&(s||l.paperMentions.length===0),S=()=>{if(!$||f)return;y(!0),((c==null?void 0:c(l))??(i==null?void 0:i(l.text))??!1)||y(!1)};return T.jsx("div",{className:"chat-msg chat-msg-user chat-msg-user-editing","data-message-id":e,children:T.jsxs("div",{className:"chat-inline-editor",children:[l.paperSelection&&T.jsx(ws,{selection:l.paperSelection,editable:!0,onRemove:()=>d({text:l.text,paperMentions:l.paperMentions})}),T.jsxs("div",{className:"chat-inline-editor-textarea-wrap",children:[T.jsx(Vl,{text:l.text,mentions:l.paperMentions,scrollTop:g,variant:"editor"}),T.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:R=>h.updateText(R.target.value,R.target.selectionStart),onSelect:R=>h.refresh(R.currentTarget.selectionStart),onScroll:R=>m(R.currentTarget.scrollTop),onKeyDown:R=>{h.keyDown(R)||(R.key==="Escape"?(R.preventDefault(),a==null||a()):R.key==="Enter"&&!R.shiftKey&&!R.nativeEvent.isComposing&&(R.preventDefault(),S()))}}),T.jsx(Ll,{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&&T.jsx("div",{className:"chat-inline-editor-notice",role:"status",children:"Paper mentions are currently disabled. Remove them before sending."}),o&&T.jsx("div",{className:"chat-inline-editor-notice",children:o}),T.jsxs("div",{className:"chat-inline-editor-actions",children:[T.jsx("button",{type:"button",onClick:a,children:"Cancel"}),T.jsx("button",{type:"button",className:"chat-inline-editor-send",disabled:!$||f,onClick:S,children:"Send"})]})]})})},QT=({id:e,text:t,paperMentions:r=[],paperSelection:n,paperMentionsEnabled:s=!1,editingAllowed:o=!1,editing:a=!1,editNotice:i,onEdit:c,onCancel:l,onResend:d,onResendDraft:f})=>{const[y,g]=fe.useState(!1),m=fe.useRef(null);fe.useEffect(()=>()=>{m.current!==null&&window.clearTimeout(m.current)},[]);const v=async()=>{var _;if((_=navigator.clipboard)!=null&&_.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?T.jsx(AT,{id:e,text:t,paperSelection:n,editNotice:i,onCancel:l,onResend:d,onResendDraft:f}):T.jsx(MT,{id:e,text:t,paperMentions:r,paperSelection:n,enabled:s,editNotice:i,onCancel:l,onResend:d,onResendDraft:f}):T.jsx("div",{className:"chat-msg chat-msg-user","data-message-id":e,children:T.jsxs("div",{className:"chat-user-message-wrap",children:[n&&T.jsx(ws,{selection:n}),T.jsx("div",{className:"chat-bubble",onDoubleClick:RT,children:T.jsx(CT,{text:t,mentions:r})}),T.jsxs("div",{className:"chat-user-actions",children:[T.jsx("button",{type:"button",className:"chat-user-action","aria-label":y?"Message copied":"Copy message",title:y?"Copied":"Copy",onClick:()=>void v(),children:y?T.jsx(Ff,{"aria-hidden":"true"}):T.jsx(ah,{"aria-hidden":"true"})}),o&&T.jsx("button",{type:"button",className:"chat-user-action","aria-label":"Edit message",title:"Edit",onClick:c,children:T.jsx(ih,{"aria-hidden":"true"})})]})]})})},YT=({msg:e,papers:t,onToggleBlock:r,onArchiveOldChats:n,onArchiveOldestChats:s,archivePending:o=null,hfBilling:a=null,openRouterFallbackEnabled:i=!1,feedbackEnabled:c=!1})=>{var x,K,J;const[l,d]=fe.useState(null),[f,y]=fe.useState(!1),[g,m]=fe.useState(!1),[v,_]=fe.useState(!1),[h,$]=fe.useState(""),S=fe.useRef(null),R=`chat-feedback-panel-${e.id}`,k=c&&!e.streaming&&!e.error&&!!((x=e.blocks)!=null&&x.some(H=>H.kind==="answer"&&H.text.trim()));fe.useEffect(()=>{var H;v&&((H=S.current)==null||H.focus())},[v]);const M=async(H,Z)=>{if(!f){y(!0),m(!1);try{Z===void 0?await hc.reportFeedback(e.id,H):await hc.reportFeedback(e.id,H,Z),d(H),_(!1),$("")}catch{m(!0)}finally{y(!1)}}};return T.jsx("div",{className:"chat-msg chat-msg-assistant",children:T.jsxs("div",{className:"chat-msg-blocks",children:[(K=e.blocks)==null?void 0:K.map((H,Z)=>{var ke;const Q=`${e.id}-${Z}`,re="citations"in H&&H.citations!==void 0?H.citations:e.citations??[],V=Object.fromEntries(re.filter($e=>($e.kind??"paper")==="paper"&&$e.route_id).map($e=>[$e.route_id,$e])),ae=Object.fromEntries(re.filter($e=>$e.kind==="web"&&$e.url).map($e=>[$e.url,$e]));return H.kind==="reasoning"?T.jsx(NT,{block:H,papers:t,citations:V,webCitations:ae,onToggle:()=>r(e.id,Z)},Q):H.kind==="tool"?T.jsx(IT,{block:H,papers:t,onToggle:()=>r(e.id,Z)},Q):H.kind==="app"?T.jsx(OT,{block:H},Q):T.jsx(jT,{block:H,papers:t,citations:V,webCitations:ae,streaming:!!(e.streaming&&Z===(((ke=e.blocks)==null?void 0:ke.length)??0)-1)},Q)}),TT(e)&&T.jsx("div",{className:"chat-waiting",role:"status","aria-live":"polite",children:T.jsx("span",{className:"chat-thinking",children:(((J=e.blocks)==null?void 0:J.length)??0)===0?e.status??"Thinking…":"Thinking…"})}),e.error&&T.jsxs("div",{className:"chat-error",children:[T.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??"")&&T.jsx("a",{href:"/settings",children:"Re-sign in with Hugging Face"}),e.errorCode==="hf_inference_billing_exhausted"&&T.jsxs(T.Fragment,{children:[(a==null?void 0:a.account_type)==="Free"&&!a.bill_to?T.jsx("a",{href:ET,target:"_blank",rel:"noreferrer",children:"Upgrade to Hugging Face PRO — $9/month for 20× more included credits"}):T.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"}),T.jsx("a",{href:kT,target:"_blank",rel:"noreferrer",children:"Inference Providers pricing and billing details"})]}),e.errorCode==="openrouter_monthly_budget_exhausted"&&T.jsxs(T.Fragment,{children:[i?T.jsx("span",{children:"This response started on the shared allowance. Your connected OpenRouter key will be used when you explicitly retry."}):T.jsx("a",{href:"/settings#openrouter-byok",children:"Connect your own OpenRouter key"}),T.jsx("span",{children:"Or select a Hugging Face-backed model and explicitly retry."})]}),e.errorCode==="openrouter_staging_funding_disabled"&&T.jsx("a",{href:PT,children:"Continue on paperswithcode.co"}),e.errorCode==="openrouter_unavailable"&&T.jsxs(T.Fragment,{children:[T.jsx("a",{href:"/settings#openrouter-byok",children:"Bring your own key in Settings"}),T.jsx("a",{href:"https://github.com/huggingface/paperswithcode-feedback",target:"_blank",rel:"noreferrer",children:"File an issue"})]}),e.errorCode==="openrouter_byok_billing_error"&&T.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??"")&&T.jsx("a",{href:"/settings#openrouter-byok",children:"Review OpenRouter settings"}),e.errorCode==="chat_session_quota_exceeded"&&(n||s)&&T.jsxs("span",{className:"chat-error-actions",children:[n&&T.jsx("button",{type:"button",disabled:o!==null,onClick:n,children:o==="old"?"Archiving…":"Archive chats older than 30 days"}),s&&T.jsx("button",{type:"button",disabled:o!==null,onClick:s,children:o==="oldest"?"Archiving…":"Archive oldest 50 chats"})]})]}),!e.streaming&&e.finishReason&&e.finishReason!=="success"&&T.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&&T.jsxs("div",{className:"chat-feedback","aria-label":"Rate this response",children:[T.jsx("span",{className:"chat-feedback-label",children:l===null?"Was this helpful?":"Thanks for your feedback"}),T.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:()=>{_(!1),M(!0)},children:T.jsx(lh,{"aria-hidden":"true"})}),T.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":R,disabled:f,onClick:()=>{m(!1),_(!0)},children:T.jsx(ch,{"aria-hidden":"true"})}),g&&T.jsx("span",{className:"chat-feedback-error",role:"status",children:"Couldn’t send feedback."})]}),k&&v&&T.jsxs("div",{className:"chat-feedback-panel",id:R,role:"group","aria-labelledby":`${R}-title`,children:[T.jsx("div",{className:"chat-feedback-panel-title",id:`${R}-title`,children:"Additional feedback"}),T.jsx("label",{className:"chat-feedback-panel-label",htmlFor:`${R}-comment`,children:"Tell us what went wrong (optional)"}),T.jsx("textarea",{ref:S,id:`${R}-comment`,className:"chat-feedback-comment",value:h,maxLength:500,rows:4,disabled:f,onChange:H=>$(H.target.value),onKeyDown:H=>{H.key==="Escape"&&(H.preventDefault(),_(!1))}}),T.jsxs("div",{className:"chat-feedback-panel-actions",children:[T.jsx("button",{type:"button",className:"chat-feedback-skip",disabled:f,onClick:()=>void M(!1),children:"Skip"}),T.jsx("button",{type:"button",className:"chat-feedback-submit",disabled:f,onClick:()=>void M(!1,h.trim()||void 0),children:f?"Submitting…":"Submit"})]})]})]})})};export{YT as A,WT as C,QT as U};