diff --git "a/assets/ChatMessage-L2qQ6E3r.js" "b/assets/ChatMessage-L2qQ6E3r.js" new file mode 100644--- /dev/null +++ "b/assets/ChatMessage-L2qQ6E3r.js" @@ -0,0 +1,111 @@ +var uh=Object.defineProperty;var dh=(e,t,r)=>t in e?uh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var ae=(e,t,r)=>dh(e,typeof t!="symbol"?t+"":t,r);import{d as Cs,r as gt,j as T,z as X,N as Wl,E as fh,C as hh}from"./index-FwVyZRtU.js";import{u as Bl,a as Jl,b as Ql,M as ph,R as mh,W as _h,d as ea,A as gh,n as yh,K as vh,L as Yl,N as $h}from"./chatSessions-CzdrU0s_.js";import"./katex.min-BSBacQyE.js";import{H as ta,a as ra,b as na}from"./hover-card-Sltev1bS.js";import{u as wh}from"./useQuery-pMKyh_fK.js";import{f as bh,p as Sh}from"./github-D7CP6Evv.js";import{G as sa}from"./github-DM2q9fSd.js";import{r as Eh,a as kh,P as Xl}from"./PaperPreviewLink-B9aeYb6V.js";import{M as Ph,r as Th,d as Rh}from"./index-DJ3-xVkS.js";import{c as Ec}from"./chat-Da1wOy04.js";import{F as Ch}from"./file-text-DVrnbsAY.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 Nh=Cs("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=Cs("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 jh=Cs("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 Oh=Cs("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 Ns({selection:e,editable:t=!1,onRemove:r}){const n=gt.useId(),s=gt.useRef(null),[o,a]=gt.useState(!1),[i,c]=gt.useState(!1),l=`Selection · Page ${e.page}`;return gt.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 Ah=yh(),oC=({onSend:e,busy:t,placeholder:r,autoFocus:n,draft:s,onDraftChange:o,onStop:a,models:i=[],selectedModel:c,onModelChange:l,disabled:d=!1,describedBy:h,paperMentionsEnabled:y=!1,paperSelectionEnabled:g=!0,webSearchAvailable:_=!1,webSearchEnabled:$=!1,onWebSearchChange:m,reasoningEffort:f="low",onReasoningEffortChange:v})=>{const[S,R]=gt.useState(Ah),P=s??S,I=gt.useRef(null),[A,U]=gt.useState(0),Z=q=>{s||R(q),o==null||o(q)},V=Bl({draft:P,onChange:Z,enabled:y,textareaRef:I});gt.useEffect(()=>{const q=I.current;q&&(q.style.height="auto",q.style.height=`${Math.min(q.scrollHeight,200)}px`)},[P.text]),gt.useEffect(()=>{var q;n&&((q=I.current)==null||q.focus())},[n]);const L=()=>{const q=P.text.length-P.text.trimStart().length,le=P.text.trim(),Ce=!!P.paperSelection&&!g;if(!le||t||d||Ce)return;const ge=q+le.length,it={text:le,paperMentions:P.paperMentions.filter(je=>je.start>=q&&je.end<=ge).map(je=>({...je,start:je.start-q,end:je.end-q})),...P.paperSelection?{paperSelection:P.paperSelection}:{}};e(it)},W=!!P.paperSelection&&!g,ce=!!P.text.trim()&&!W;return T.jsxs("div",{className:"chat-composer",children:[P.paperSelection&&T.jsx(Ns,{selection:P.paperSelection,editable:!0,onRemove:()=>{var q;Z({text:P.text,paperMentions:P.paperMentions}),(q=I.current)==null||q.focus()}}),W&&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(Jl,{text:P.text,mentions:P.paperMentions,scrollTop:A}),T.jsx("textarea",{ref:I,rows:1,value:P.text,placeholder:r||(P.paperSelection?"Ask about this selection…":"Ask anything about research…"),onChange:q=>V.updateText(q.target.value,q.target.selectionStart),onSelect:q=>V.refresh(q.currentTarget.selectionStart),onClick:q=>V.refresh(q.currentTarget.selectionStart),onScroll:q=>U(q.currentTarget.scrollTop),onBlur:q=>{var le,Ce;(Ce=(le=q.relatedTarget)==null?void 0:le.closest)!=null&&Ce.call(le,".chat-paper-picker")||window.setTimeout(V.close,0)},onKeyDown:q=>{V.keyDown(q)||q.key==="Enter"&&!q.shiftKey&&!q.nativeEvent.isComposing&&(q.preventDefault(),L())},role:"combobox","aria-expanded":V.open,"aria-controls":V.open?V.pickerId:void 0,"aria-activedescendant":V.open&&V.results.length?`${V.optionIdPrefix}-${V.activeIndex}`:void 0,"aria-autocomplete":"list","aria-describedby":[h,V.message?"chat-paper-mention-message":null].filter(Boolean).join(" ")||void 0}),T.jsx(Ql,{open:V.open,query:V.query,results:V.results,activeIndex:V.activeIndex,loading:V.loading,error:V.error,onSelect:V.select,id:V.pickerId,optionIdPrefix:V.optionIdPrefix})]}),V.message&&T.jsx("div",{id:"chat-paper-mention-message",className:"chat-paper-mention-message",role:"alert",children:V.message}),T.jsxs("div",{className:"chat-composer-row",children:[T.jsxs("div",{className:"chat-composer-tools",children:[i.length>0&&c&&l&&T.jsx(ph,{models:i,selectedModel:c,onModelChange:l,disabled:t}),v&&T.jsx(mh,{value:f,onChange:v,disabled:t}),_&&m&&T.jsx(_h,{enabled:$,onChange:m,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||ce?" chat-send-on":""}`,onClick:t?a:L,disabled:d||(t?!a:!ce),"aria-label":t?"Stop generating":"Send message",children:t?a?T.jsx("span",{"aria-hidden":"true",children:"■"}):T.jsx(ea,{light:!0}):T.jsx(gh,{})})]})]})},Qs=new Map,zh=e=>{if(!e)return Promise.resolve();const t=Qs.get(e);if(t)return t;const r=new Promise(n=>{const s=new Image;s.onload=()=>{n()},s.onerror=()=>{Qs.delete(e),n()},s.src=e});return Qs.set(e,r),r},Mh=new Set(["huggingface.co","www.huggingface.co"]),xh=new Set(["api","blog","chat","collections","docs","enterprise","join","login","models","new","organizations","papers","posts","pricing","search","settings","spaces","tasks"]);function qh(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!=="https:"||!Mh.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"&&xh.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 Dh=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,Uh=({repo:e})=>{const[t,r]=X.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"})]})]})},Vh=({repo:e,children:t})=>{const[r,n]=X.useState(!1),s=X.useRef(null),o=X.useCallback(()=>{zh(e.thumbnailUrl)},[e.thumbnailUrl]);return X.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(ta,{open:r,onOpenChange:a=>{(!a||!Dh())&&n(a)},openDelay:150,closeDelay:100,children:[T.jsx(ra,{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(na,{className:"hf-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:T.jsx(Uh,{repo:e})})]})},Lh=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,Fh=({repo:e,preview:t,unavailable:r})=>{const[n,s]=X.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(sa,{})}),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…"})]})]})},Hh=({repo:e,children:t})=>{const[r,n]=X.useState(!1),s=wh({queryKey:["github-repository-preview",e.repoId.toLowerCase()],queryFn:({signal:o})=>bh(e,o),enabled:r,staleTime:30*60*1e3,gcTime:60*60*1e3,retry:!1});return T.jsxs(ta,{open:r,onOpenChange:o=>{(!o||!Lh())&&n(o)},openDelay:150,closeDelay:100,children:[T.jsx(ra,{asChild:!0,children:T.jsxs("a",{className:"chat-github-link",href:e.url,target:"_blank",rel:"noopener noreferrer",children:[T.jsx(sa,{"aria-hidden":"true"}),t]})}),T.jsx(na,{className:"github-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:T.jsx(Fh,{repo:e,preview:s.data,unavailable:s.isError})})]})},Zh=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches;function Kh(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return"Web source"}}const Gh=({citation:e})=>{const[t,r]=X.useState(!1),[n,s]=X.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:Kh(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()})]})]})},Wh=({citation:e,children:t})=>{const[r,n]=X.useState(!1),s=e.url??"";return T.jsxs(ta,{open:r,onOpenChange:o=>{(!o||!Zh())&&n(o)},openDelay:150,closeDelay:100,children:[T.jsx(ra,{asChild:!0,children:T.jsx("a",{href:s,className:"chat-web-citation",target:"_blank",rel:"noopener noreferrer",children:t})}),T.jsx(na,{className:"web-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:T.jsx(Gh,{citation:e})})]})};function Bh(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 eu=({routeId:e,paper:t,citation:r,className:n="chat-paper-link",children:s})=>T.jsx(Xl,{routeId:e,initialData:Bh(e,t,r),className:n,target:"_blank",children:s});function Jh(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 Qh=e=>e.startsWith("paper:")?e:Rh(e);function Yh(e){try{const t=new URL(e);return t.protocol==="https:"&&(t.hostname==="github.com"||t.hostname==="www.github.com")}catch{return!1}}const go=({text:e,streaming:t,papers:r,citations:n,webCitations:s})=>{const o=t?Jh(e):e;return T.jsx(Ph,{remarkPlugins:[Th,kh],rehypePlugins:[Eh],urlTransform:Qh,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(eu,{routeId:d,paper:r[d],citation:n==null?void 0:n[d],children:i})}const c=a?qh(a):null;if(c)return T.jsx(Vh,{repo:c,children:i});const l=a?Sh(a):null;return l?T.jsx(Hh,{repo:l,children:i}):a&&Yh(a)?T.jsxs("a",{href:a,className:"chat-github-link",target:"_blank",rel:"noopener noreferrer",children:[T.jsx(sa,{"aria-hidden":"true"}),i]}):a!=null&&a.startsWith("https://")&&(s!=null&&s[a])?T.jsx(Wh,{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})},Xh=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 mn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const tu={};function xt(e){return tu}function ep(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,s])=>t.indexOf(+n)===-1).map(([n,s])=>s)}function tp(e,t){return typeof t=="bigint"?t.toString():t}function oa(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function aa(e){return e==null}function ia(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function rp(e,t){const r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,s=r>n?r:n,o=Number.parseInt(e.toFixed(s).replace(".","")),a=Number.parseInt(t.toFixed(s).replace(".",""));return o%a/10**s}function Ee(e,t,r){Object.defineProperty(e,t,{get(){{const n=r();return e[t]=n,n}},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Is(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Wr(e){return JSON.stringify(e)}const ru=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function ls(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const np=oa(()=>{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 us(e){if(ls(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(ls(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}const sp=new Set(["string","number","symbol"]);function wn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function gr(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r!=null&&r.parent)&&(n._zod.parent=e),n}function G(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 op(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const ap={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 ip(e,t){const r={},n=e._zod.def;for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(r[s]=n.shape[s])}return gr(e,{...e._zod.def,shape:r,checks:[]})}function cp(e,t){const r={...e._zod.def.shape},n=e._zod.def;for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete r[s]}return gr(e,{...e._zod.def,shape:r,checks:[]})}function lp(e,t){if(!us(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 Is(this,"shape",n),n},checks:[]};return gr(e,r)}function up(e,t){return gr(e,{...e._zod.def,get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Is(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function dp(e,t,r){const n=t._zod.def.shape,s={...n};if(r)for(const o in r){if(!(o in n))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(s[o]=e?new e({type:"optional",innerType:n[o]}):n[o])}else for(const o in n)s[o]=e?new e({type:"optional",innerType:n[o]}):n[o];return gr(t,{...t._zod.def,shape:s,checks:[]})}function fp(e,t,r){const n=t._zod.def.shape,s={...n};if(r)for(const o in r){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(s[o]=new e({type:"nonoptional",innerType:n[o]}))}else for(const o in n)s[o]=new e({type:"nonoptional",innerType:n[o]});return gr(t,{...t._zod.def,shape:s,checks:[]})}function nn(e,t=0){var r;for(let n=t;n{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function xn(e){return typeof e=="string"?e:e==null?void 0:e.message}function qt(e,t,r){var s,o,a,i,c,l;const n={...e,path:e.path??[]};if(!e.message){const d=xn((a=(o=(s=e.inst)==null?void 0:s._zod.def)==null?void 0:o.error)==null?void 0:a.call(o,e))??xn((i=t==null?void 0:t.error)==null?void 0:i.call(t,e))??xn((c=r.customError)==null?void 0:c.call(r,e))??xn((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 ca(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function _n(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const nu=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,tp,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},su=z("$ZodError",nu),ou=z("$ZodError",nu,{Parent:Error});function hp(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 pp(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 mn;if(a.issues.length){const i=new((s==null?void 0:s.Err)??e)(a.issues.map(c=>qt(c,o,xt())));throw ru(i,s==null?void 0:s.callee),i}return a.value},_p=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=>qt(c,o,xt())));throw ru(i,s==null?void 0:s.callee),i}return a.value},au=e=>(t,r,n)=>{const s=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},s);if(o instanceof Promise)throw new mn;return o.issues.length?{success:!1,error:new(e??su)(o.issues.map(a=>qt(a,s,xt())))}:{success:!0,data:o.value}},iu=au(ou),cu=e=>async(t,r,n)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let o=t._zod.run({value:r,issues:[]},s);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(a=>qt(a,s,xt())))}:{success:!0,data:o.value}},gp=cu(ou),yp=/^[cC][^\s-]{8,}$/,vp=/^[0-9a-z]+$/,$p=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,wp=/^[0-9a-vA-V]{20}$/,bp=/^[A-Za-z0-9]{27}$/,Sp=/^[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)?)?)$/,kp=/^([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})$/,kc=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)$/,Pp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Tp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Rp(){return new RegExp(Tp,"u")}const Cp=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Np=/^(([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])$/,jp=/^(([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])$/,Op=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,lu=/^[A-Za-z0-9_-]*$/,Ap=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,zp=/^\+(?:[0-9]){6,14}[0-9]$/,uu="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Mp=new RegExp(`^${uu}$`);function du(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function xp(e){return new RegExp(`^${du(e)}$`)}function qp(e){const t=du({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-]\\d{2}:\\d{2})");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${uu}T(?:${n})$`)}const Dp=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}$`)},Up=/^\d+$/,Vp=/^-?\d+(?:\.\d+)?/i,Lp=/true|false/i,Fp=/null/i,Hp=/undefined/i,Zp=/^[^A-Z]*$/,Kp=/^[^a-z]*$/,Xe=z("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),fu={number:"number",bigint:"bigint",object:"date"},hu=z("$ZodCheckLessThan",(e,t)=>{Xe.init(e,t);const r=fu[typeof t.value];e._zod.onattach.push(n=>{const s=n._zod.bag,o=(t.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value{(t.inclusive?n.value<=t.value:n.value{Xe.init(e,t);const r=fu[typeof t.value];e._zod.onattach.push(n=>{const s=n._zod.bag,o=(t.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?s.minimum=t.value:s.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Gp=z("$ZodCheckMultipleOf",(e,t)=>{Xe.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):rp(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})}}),Wp=z("$ZodCheckNumberFormat",(e,t)=>{var a;Xe.init(e,t),t.format=t.format||"float64";const r=(a=t.format)==null?void 0:a.includes("int"),n=r?"int":"number",[s,o]=ap[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=Up)}),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})}}),Bp=z("$ZodCheckMaxLength",(e,t)=>{var r;Xe.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!aa(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=ca(s);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Jp=z("$ZodCheckMinLength",(e,t)=>{var r;Xe.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!aa(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=ca(s);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Qp=z("$ZodCheckLengthEquals",(e,t)=>{var r;Xe.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!aa(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=ca(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})}}),js=z("$ZodCheckStringFormat",(e,t)=>{var r,n;Xe.init(e,t),e._zod.onattach.push(s=>{const o=s._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=s=>{t.pattern.lastIndex=0,!t.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:t.format,input:s.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Yp=z("$ZodCheckRegex",(e,t)=>{js.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})}}),Xp=z("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Zp),js.init(e,t)}),em=z("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Kp),js.init(e,t)}),tm=z("$ZodCheckIncludes",(e,t)=>{Xe.init(e,t);const r=wn(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})}}),rm=z("$ZodCheckStartsWith",(e,t)=>{Xe.init(e,t);const r=new RegExp(`^${wn(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})}}),nm=z("$ZodCheckEndsWith",(e,t)=>{Xe.init(e,t);const r=new RegExp(`.*${wn(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})}}),sm=z("$ZodCheckOverwrite",(e,t)=>{Xe.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class om{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 am={major:4,minor:0,patch:0},we=z("$ZodType",(e,t)=>{var s;var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=am;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=nn(a),d;for(const h of i){if(h._zod.def.when){if(!h._zod.def.when(a))continue}else if(l)continue;const y=a.issues.length,g=h._zod.check(a);if(g instanceof Promise&&(c==null?void 0:c.async)===!1)throw new mn;if(d||g instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await g,a.issues.length!==y&&(l||(l=nn(a,y)))});else{if(a.issues.length===y)continue;l||(l=nn(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 mn;return c.then(l=>o(l,n,i))}return o(c,n,i)}}e["~standard"]={validate:o=>{var a;try{const i=iu(e,o);return i.success?{value:i.data}:{issues:(a=i.error)==null?void 0:a.issues}}catch{return gp(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}}),la=z("$ZodString",(e,t)=>{var r;we.init(e,t),e._zod.pattern=[...((r=e==null?void 0:e._zod.bag)==null?void 0:r.patterns)??[]].pop()??Dp(e._zod.bag),e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Pe=z("$ZodStringFormat",(e,t)=>{js.init(e,t),la.init(e,t)}),im=z("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=kp),Pe.init(e,t)}),cm=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=kc(n))}else t.pattern??(t.pattern=kc());Pe.init(e,t)}),lm=z("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Pp),Pe.init(e,t)}),um=z("$ZodURL",(e,t)=>{Pe.init(e,t),e._zod.check=r=>{try{const n=r.value,s=new URL(n),o=s.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(s.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Ap.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),!n.endsWith("/")&&o.endsWith("/")?r.value=o.slice(0,-1):r.value=o;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),dm=z("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Rp()),Pe.init(e,t)}),fm=z("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Sp),Pe.init(e,t)}),hm=z("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=yp),Pe.init(e,t)}),pm=z("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=vp),Pe.init(e,t)}),mm=z("$ZodULID",(e,t)=>{t.pattern??(t.pattern=$p),Pe.init(e,t)}),_m=z("$ZodXID",(e,t)=>{t.pattern??(t.pattern=wp),Pe.init(e,t)}),gm=z("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=bp),Pe.init(e,t)}),ym=z("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=qp(t)),Pe.init(e,t)}),vm=z("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Mp),Pe.init(e,t)}),$m=z("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=xp(t)),Pe.init(e,t)}),wm=z("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ep),Pe.init(e,t)}),bm=z("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Cp),Pe.init(e,t),e._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv4"})}),Sm=z("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Np),Pe.init(e,t),e._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv6"}),e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),Em=z("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ip),Pe.init(e,t)}),km=z("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=jp),Pe.init(e,t),e._zod.check=r=>{const[n,s]=r.value.split("/");try{if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function mu(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Pm=z("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Op),Pe.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),e._zod.check=r=>{mu(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Tm(e){if(!lu.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return mu(r)}const Rm=z("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=lu),Pe.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),e._zod.check=r=>{Tm(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Cm=z("$ZodE164",(e,t)=>{t.pattern??(t.pattern=zp),Pe.init(e,t)});function Nm(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)=>{Pe.init(e,t),e._zod.check=r=>{Nm(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),_u=z("$ZodNumber",(e,t)=>{we.init(e,t),e._zod.pattern=e._zod.bag.pattern??Vp,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}}),jm=z("$ZodNumber",(e,t)=>{Wp.init(e,t),_u.init(e,t)}),Om=z("$ZodBoolean",(e,t)=>{we.init(e,t),e._zod.pattern=Lp,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}}),Am=z("$ZodUndefined",(e,t)=>{we.init(e,t),e._zod.pattern=Hp,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}}),zm=z("$ZodNull",(e,t)=>{we.init(e,t),e._zod.pattern=Fp,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}}),Mm=z("$ZodAny",(e,t)=>{we.init(e,t),e._zod.parse=r=>r}),xm=z("$ZodUnknown",(e,t)=>{we.init(e,t),e._zod.parse=r=>r}),qm=z("$ZodNever",(e,t)=>{we.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Pc(e,t,r){e.issues.length&&t.issues.push(...ur(r,e.issues)),t.value[r]=e.value}const Dm=z("$ZodArray",(e,t)=>{we.init(e,t),e._zod.parse=(r,n)=>{const s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),r;r.value=Array(s.length);const o=[];for(let a=0;aPc(l,r,a))):Pc(c,r,a)}return o.length?Promise.all(o).then(()=>r):r}});function qn(e,t,r){e.issues.length&&t.issues.push(...ur(r,e.issues)),t.value[r]=e.value}function Tc(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(...ur(r,e.issues)):e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}const Um=z("$ZodObject",(e,t)=>{we.init(e,t);const r=oa(()=>{const h=Object.keys(t.shape);for(const g of h)if(!(t.shape[g]instanceof we))throw new Error(`Invalid element at key "${g}": expected a Zod schema`);const y=op(t.shape);return{shape:t.shape,keys:h,keySet:new Set(h),numKeys:h.length,optionalKeys:new Set(y)}});Ee(e._zod,"propValues",()=>{const h=t.shape,y={};for(const g in h){const _=h[g]._zod;if(_.values){y[g]??(y[g]=new Set);for(const $ of _.values)y[g].add($)}}return y});const n=h=>{const y=new om(["shape","payload","ctx"]),g=r.value,_=v=>{const S=Wr(v);return`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`};y.write("const input = payload.value;");const $=Object.create(null);let m=0;for(const v of g.keys)$[v]=`key_${m++}`;y.write("const newResult = {}");for(const v of g.keys)if(g.optionalKeys.has(v)){const S=$[v];y.write(`const ${S} = ${_(v)};`);const R=Wr(v);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} = ${_(v)};`),y.write(` + if (${S}.issues.length) payload.issues = payload.issues.concat(${S}.issues.map(iss => ({ + ...iss, + path: iss.path ? [${Wr(v)}, ...iss.path] : [${Wr(v)}] + })));`),y.write(`newResult[${Wr(v)}] = ${S}.value`)}y.write("payload.value = newResult;"),y.write("return payload;");const f=y.compile();return(v,S)=>f(h,v,S)};let s;const o=ls,a=!tu.jitless,c=a&&np.value,l=t.catchall;let d;e._zod.parse=(h,y)=>{d??(d=r.value);const g=h.value;if(!o(g))return h.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),h;const _=[];if(a&&c&&(y==null?void 0:y.async)===!1&&y.jitless!==!0)s||(s=n(t.shape)),h=s(h,y);else{h.value={};const S=d.shape;for(const R of d.keys){const P=S[R],I=P._zod.run({value:g[R],issues:[]},y),A=P._zod.optin==="optional"&&P._zod.optout==="optional";I instanceof Promise?_.push(I.then(U=>A?Tc(U,h,R,g):qn(U,h,R))):A?Tc(I,h,R,g):qn(I,h,R)}}if(!l)return _.length?Promise.all(_).then(()=>h):h;const $=[],m=d.keySet,f=l._zod,v=f.def.type;for(const S of Object.keys(g)){if(m.has(S))continue;if(v==="never"){$.push(S);continue}const R=f.run({value:g[S],issues:[]},y);R instanceof Promise?_.push(R.then(P=>qn(P,h,S))):qn(R,h,S)}return $.length&&h.issues.push({code:"unrecognized_keys",keys:$,input:g,inst:e}),_.length?Promise.all(_).then(()=>h):h}});function Rc(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=>qt(o,n,xt())))}),t}const gu=z("$ZodUnion",(e,t)=>{we.init(e,t),Ee(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),Ee(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),Ee(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),Ee(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>ia(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=>Rc(a,r,e,n)):Rc(o,r,e,n)}}),Vm=z("$ZodDiscriminatedUnion",(e,t)=>{gu.init(e,t);const r=e._zod.parse;Ee(e._zod,"propValues",()=>{const s={};for(const o of t.options){const a=o._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const[i,c]of Object.entries(a)){s[i]||(s[i]=new Set);for(const l of c)s[i].add(l)}}return s});const n=oa(()=>{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(!ls(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)}}),Lm=z("$ZodIntersection",(e,t)=>{we.init(e,t),e._zod.parse=(r,n)=>{const s=r.value,o=t.left._zod.run({value:s,issues:[]},n),a=t.right._zod.run({value:s,issues:[]},n);return o instanceof Promise||a instanceof Promise?Promise.all([o,a]).then(([c,l])=>Cc(r,c,l)):Cc(r,o,a)}});function yo(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(us(e)&&us(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=yo(e[o],t[o]);if(!a.valid)return{valid:!1,mergeErrorPath:[o,...a.mergeErrorPath]};s[o]=a.data}return{valid:!0,data:s}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n{we.init(e,t),e._zod.parse=(r,n)=>{const s=r.value;if(!us(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(...ur(c,d.issues)),r.value[c]=d.value})):(l.issues.length&&r.issues.push(...ur(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=>qt(l,n,xt())),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(...ur(a,l.issues)),r.value[i.value]=l.value})):(c.issues.length&&r.issues.push(...ur(a,c.issues)),r.value[i.value]=c.value)}}return o.length?Promise.all(o).then(()=>r):r}}),Hm=z("$ZodEnum",(e,t)=>{we.init(e,t);const r=ep(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(n=>sp.has(typeof n)).map(n=>typeof n=="string"?wn(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}}),Zm=z("$ZodLiteral",(e,t)=>{we.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?wn(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}}),Km=z("$ZodTransform",(e,t)=>{we.init(e,t),e._zod.parse=(r,n)=>{const s=t.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(a=>(r.value=a,r));if(s instanceof Promise)throw new mn;return r.value=s,r}}),Gm=z("$ZodOptional",(e,t)=>{we.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ee(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ee(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${ia(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)}),Wm=z("$ZodNullable",(e,t)=>{we.init(e,t),Ee(e._zod,"optin",()=>t.innerType._zod.optin),Ee(e._zod,"optout",()=>t.innerType._zod.optout),Ee(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${ia(r.source)}|null)$`):void 0}),Ee(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Bm=z("$ZodDefault",(e,t)=>{we.init(e,t),e._zod.optin="optional",Ee(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=t.defaultValue,r;const s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>Nc(o,t)):Nc(s,t)}});function Nc(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Jm=z("$ZodPrefault",(e,t)=>{we.init(e,t),e._zod.optin="optional",Ee(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Qm=z("$ZodNonOptional",(e,t)=>{we.init(e,t),Ee(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{const s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>Ic(o,e)):Ic(s,e)}});function Ic(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 Ym=z("$ZodCatch",(e,t)=>{we.init(e,t),e._zod.optin="optional",Ee(e._zod,"optout",()=>t.innerType._zod.optout),Ee(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{const s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(a=>qt(a,n,xt()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=t.catchValue({...r,error:{issues:s.issues.map(o=>qt(o,n,xt()))},input:r.value}),r.issues=[]),r)}}),Xm=z("$ZodPipe",(e,t)=>{we.init(e,t),Ee(e._zod,"values",()=>t.in._zod.values),Ee(e._zod,"optin",()=>t.in._zod.optin),Ee(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(r,n)=>{const s=t.in._zod.run(r,n);return s instanceof Promise?s.then(o=>jc(o,t,n)):jc(s,t,n)}});function jc(e,t,r){return nn(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}const e_=z("$ZodReadonly",(e,t)=>{we.init(e,t),Ee(e._zod,"propValues",()=>t.innerType._zod.propValues),Ee(e._zod,"values",()=>t.innerType._zod.values),Ee(e._zod,"optin",()=>t.innerType._zod.optin),Ee(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(r,n)=>{const s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(Oc):Oc(s)}});function Oc(e){return e.value=Object.freeze(e.value),e}const t_=z("$ZodCustom",(e,t)=>{Xe.init(e,t),we.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,s=t.fn(n);if(s instanceof Promise)return s.then(o=>Ac(o,r,n,e));Ac(s,r,n,e)}});function Ac(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(_n(s))}}class r_{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 n_(){return new r_}const Dn=n_();function s_(e,t){return new e({type:"string",...G(t)})}function o_(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...G(t)})}function zc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...G(t)})}function a_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...G(t)})}function i_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...G(t)})}function c_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...G(t)})}function l_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...G(t)})}function yu(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...G(t)})}function u_(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...G(t)})}function d_(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...G(t)})}function f_(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...G(t)})}function h_(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...G(t)})}function p_(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...G(t)})}function m_(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...G(t)})}function __(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...G(t)})}function g_(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...G(t)})}function y_(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...G(t)})}function v_(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...G(t)})}function $_(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...G(t)})}function w_(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...G(t)})}function b_(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...G(t)})}function S_(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...G(t)})}function E_(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...G(t)})}function k_(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...G(t)})}function P_(e,t){return new e({type:"string",format:"date",check:"string_format",...G(t)})}function T_(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...G(t)})}function R_(e,t){return new e({type:"string",format:"duration",check:"string_format",...G(t)})}function C_(e,t){return new e({type:"number",checks:[],...G(t)})}function N_(e,t){return new e({type:"number",coerce:!0,checks:[],...G(t)})}function I_(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...G(t)})}function j_(e,t){return new e({type:"boolean",...G(t)})}function O_(e,t){return new e({type:"undefined",...G(t)})}function A_(e,t){return new e({type:"null",...G(t)})}function z_(e){return new e({type:"any"})}function M_(e){return new e({type:"unknown"})}function x_(e,t){return new e({type:"never",...G(t)})}function Mc(e,t){return new hu({check:"less_than",...G(t),value:e,inclusive:!1})}function Ys(e,t){return new hu({check:"less_than",...G(t),value:e,inclusive:!0})}function xc(e,t){return new pu({check:"greater_than",...G(t),value:e,inclusive:!1})}function Xs(e,t){return new pu({check:"greater_than",...G(t),value:e,inclusive:!0})}function qc(e,t){return new Gp({check:"multiple_of",...G(t),value:e})}function vu(e,t){return new Bp({check:"max_length",...G(t),maximum:e})}function ds(e,t){return new Jp({check:"min_length",...G(t),minimum:e})}function $u(e,t){return new Qp({check:"length_equals",...G(t),length:e})}function q_(e,t){return new Yp({check:"string_format",format:"regex",...G(t),pattern:e})}function D_(e){return new Xp({check:"string_format",format:"lowercase",...G(e)})}function U_(e){return new em({check:"string_format",format:"uppercase",...G(e)})}function V_(e,t){return new tm({check:"string_format",format:"includes",...G(t),includes:e})}function L_(e,t){return new rm({check:"string_format",format:"starts_with",...G(t),prefix:e})}function F_(e,t){return new nm({check:"string_format",format:"ends_with",...G(t),suffix:e})}function bn(e){return new sm({check:"overwrite",tx:e})}function H_(e){return bn(t=>t.normalize(e))}function Z_(){return bn(e=>e.trim())}function K_(){return bn(e=>e.toLowerCase())}function G_(){return bn(e=>e.toUpperCase())}function W_(e,t,r){return new e({type:"array",element:t,...G(r)})}function B_(e,t,r){const n=G(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function J_(e,t,r){return new e({type:"custom",check:"custom",fn:t,...G(r)})}const Q_=z("ZodISODateTime",(e,t)=>{ym.init(e,t),Re.init(e,t)});function wu(e){return k_(Q_,e)}const Y_=z("ZodISODate",(e,t)=>{vm.init(e,t),Re.init(e,t)});function X_(e){return P_(Y_,e)}const eg=z("ZodISOTime",(e,t)=>{$m.init(e,t),Re.init(e,t)});function tg(e){return T_(eg,e)}const rg=z("ZodISODuration",(e,t)=>{wm.init(e,t),Re.init(e,t)});function ng(e){return R_(rg,e)}const sg=(e,t)=>{su.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>pp(e,r)},flatten:{value:r=>hp(e,r)},addIssue:{value:r=>e.issues.push(r)},addIssues:{value:r=>e.issues.push(...r)},isEmpty:{get(){return e.issues.length===0}}})},Os=z("ZodError",sg,{Parent:Error}),og=mp(Os),ag=_p(Os),ig=au(Os),cg=cu(Os),ke=z("ZodType",(e,t)=>(we.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(r,n)=>gr(e,r,n),e.brand=()=>e,e.register=(r,n)=>(r.add(e,n),e),e.parse=(r,n)=>og(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>ig(e,r,n),e.parseAsync=async(r,n)=>ag(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>cg(e,r,n),e.spa=e.safeParseAsync,e.refine=(r,n)=>e.check(ey(r,n)),e.superRefine=r=>e.check(ty(r)),e.overwrite=r=>e.check(bn(r)),e.optional=()=>Te(e),e.nullable=()=>Vc(e),e.nullish=()=>Te(Vc(e)),e.nonoptional=r=>Kg(e,r),e.array=()=>D(e),e.or=r=>pe([e,r]),e.and=r=>fa(e,r),e.transform=r=>bo(e,Tu(r)),e.default=r=>Fg(e,r),e.prefault=r=>Zg(e,r),e.catch=r=>Wg(e,r),e.pipe=r=>bo(e,r),e.readonly=()=>Qg(e),e.describe=r=>{const n=e.clone();return Dn.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){var r;return(r=Dn.get(e))==null?void 0:r.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return Dn.get(e);const n=e.clone();return Dn.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),bu=z("_ZodString",(e,t)=>{la.init(e,t),ke.init(e,t);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(q_(...n)),e.includes=(...n)=>e.check(V_(...n)),e.startsWith=(...n)=>e.check(L_(...n)),e.endsWith=(...n)=>e.check(F_(...n)),e.min=(...n)=>e.check(ds(...n)),e.max=(...n)=>e.check(vu(...n)),e.length=(...n)=>e.check($u(...n)),e.nonempty=(...n)=>e.check(ds(1,...n)),e.lowercase=n=>e.check(D_(n)),e.uppercase=n=>e.check(U_(n)),e.trim=()=>e.check(Z_()),e.normalize=(...n)=>e.check(H_(...n)),e.toLowerCase=()=>e.check(K_()),e.toUpperCase=()=>e.check(G_())}),lg=z("ZodString",(e,t)=>{la.init(e,t),bu.init(e,t),e.email=r=>e.check(o_(ug,r)),e.url=r=>e.check(yu(Su,r)),e.jwt=r=>e.check(E_(Pg,r)),e.emoji=r=>e.check(u_(fg,r)),e.guid=r=>e.check(zc(Dc,r)),e.uuid=r=>e.check(a_(Un,r)),e.uuidv4=r=>e.check(i_(Un,r)),e.uuidv6=r=>e.check(c_(Un,r)),e.uuidv7=r=>e.check(l_(Un,r)),e.nanoid=r=>e.check(d_(hg,r)),e.guid=r=>e.check(zc(Dc,r)),e.cuid=r=>e.check(f_(pg,r)),e.cuid2=r=>e.check(h_(mg,r)),e.ulid=r=>e.check(p_(_g,r)),e.base64=r=>e.check(w_(Sg,r)),e.base64url=r=>e.check(b_(Eg,r)),e.xid=r=>e.check(m_(gg,r)),e.ksuid=r=>e.check(__(yg,r)),e.ipv4=r=>e.check(g_(vg,r)),e.ipv6=r=>e.check(y_($g,r)),e.cidrv4=r=>e.check(v_(wg,r)),e.cidrv6=r=>e.check($_(bg,r)),e.e164=r=>e.check(S_(kg,r)),e.datetime=r=>e.check(wu(r)),e.date=r=>e.check(X_(r)),e.time=r=>e.check(tg(r)),e.duration=r=>e.check(ng(r))});function k(e){return s_(lg,e)}const Re=z("ZodStringFormat",(e,t)=>{Pe.init(e,t),bu.init(e,t)}),ug=z("ZodEmail",(e,t)=>{lm.init(e,t),Re.init(e,t)}),Dc=z("ZodGUID",(e,t)=>{im.init(e,t),Re.init(e,t)}),Un=z("ZodUUID",(e,t)=>{cm.init(e,t),Re.init(e,t)}),Su=z("ZodURL",(e,t)=>{um.init(e,t),Re.init(e,t)});function dg(e){return yu(Su,e)}const fg=z("ZodEmoji",(e,t)=>{dm.init(e,t),Re.init(e,t)}),hg=z("ZodNanoID",(e,t)=>{fm.init(e,t),Re.init(e,t)}),pg=z("ZodCUID",(e,t)=>{hm.init(e,t),Re.init(e,t)}),mg=z("ZodCUID2",(e,t)=>{pm.init(e,t),Re.init(e,t)}),_g=z("ZodULID",(e,t)=>{mm.init(e,t),Re.init(e,t)}),gg=z("ZodXID",(e,t)=>{_m.init(e,t),Re.init(e,t)}),yg=z("ZodKSUID",(e,t)=>{gm.init(e,t),Re.init(e,t)}),vg=z("ZodIPv4",(e,t)=>{bm.init(e,t),Re.init(e,t)}),$g=z("ZodIPv6",(e,t)=>{Sm.init(e,t),Re.init(e,t)}),wg=z("ZodCIDRv4",(e,t)=>{Em.init(e,t),Re.init(e,t)}),bg=z("ZodCIDRv6",(e,t)=>{km.init(e,t),Re.init(e,t)}),Sg=z("ZodBase64",(e,t)=>{Pm.init(e,t),Re.init(e,t)}),Eg=z("ZodBase64URL",(e,t)=>{Rm.init(e,t),Re.init(e,t)}),kg=z("ZodE164",(e,t)=>{Cm.init(e,t),Re.init(e,t)}),Pg=z("ZodJWT",(e,t)=>{Im.init(e,t),Re.init(e,t)}),ua=z("ZodNumber",(e,t)=>{_u.init(e,t),ke.init(e,t),e.gt=(n,s)=>e.check(xc(n,s)),e.gte=(n,s)=>e.check(Xs(n,s)),e.min=(n,s)=>e.check(Xs(n,s)),e.lt=(n,s)=>e.check(Mc(n,s)),e.lte=(n,s)=>e.check(Ys(n,s)),e.max=(n,s)=>e.check(Ys(n,s)),e.int=n=>e.check(Uc(n)),e.safe=n=>e.check(Uc(n)),e.positive=n=>e.check(xc(0,n)),e.nonnegative=n=>e.check(Xs(0,n)),e.negative=n=>e.check(Mc(0,n)),e.nonpositive=n=>e.check(Ys(0,n)),e.multipleOf=(n,s)=>e.check(qc(n,s)),e.step=(n,s)=>e.check(qc(n,s)),e.finite=()=>e;const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function oe(e){return C_(ua,e)}const Tg=z("ZodNumberFormat",(e,t)=>{jm.init(e,t),ua.init(e,t)});function Uc(e){return I_(Tg,e)}const Rg=z("ZodBoolean",(e,t)=>{Om.init(e,t),ke.init(e,t)});function me(e){return j_(Rg,e)}const Cg=z("ZodUndefined",(e,t)=>{Am.init(e,t),ke.init(e,t)});function vo(e){return O_(Cg,e)}const Ng=z("ZodNull",(e,t)=>{zm.init(e,t),ke.init(e,t)});function Ig(e){return A_(Ng,e)}const jg=z("ZodAny",(e,t)=>{Mm.init(e,t),ke.init(e,t)});function da(){return z_(jg)}const Og=z("ZodUnknown",(e,t)=>{xm.init(e,t),ke.init(e,t)});function $e(){return M_(Og)}const Ag=z("ZodNever",(e,t)=>{qm.init(e,t),ke.init(e,t)});function $o(e){return x_(Ag,e)}const zg=z("ZodArray",(e,t)=>{Dm.init(e,t),ke.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(ds(r,n)),e.nonempty=r=>e.check(ds(1,r)),e.max=(r,n)=>e.check(vu(r,n)),e.length=(r,n)=>e.check($u(r,n)),e.unwrap=()=>e.element});function D(e,t){return W_(zg,e,t)}const Eu=z("ZodObject",(e,t)=>{Um.init(e,t),ke.init(e,t),Ee(e,"shape",()=>t.shape),e.keyof=()=>tt(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:$e()}),e.loose=()=>e.clone({...e._zod.def,catchall:$e()}),e.strict=()=>e.clone({...e._zod.def,catchall:$o()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>lp(e,r),e.merge=r=>up(e,r),e.pick=r=>ip(e,r),e.omit=r=>cp(e,r),e.partial=(...r)=>dp(Ru,e,r[0]),e.required=(...r)=>fp(Cu,e,r[0])});function O(e,t){const r={type:"object",get shape(){return Is(this,"shape",{...e}),this.shape},...G(t)};return new Eu(r)}function Le(e,t){return new Eu({type:"object",get shape(){return Is(this,"shape",{...e}),this.shape},catchall:$e(),...G(t)})}const ku=z("ZodUnion",(e,t)=>{gu.init(e,t),ke.init(e,t),e.options=t.options});function pe(e,t){return new ku({type:"union",options:e,...G(t)})}const Mg=z("ZodDiscriminatedUnion",(e,t)=>{ku.init(e,t),Vm.init(e,t)});function Pu(e,t,r){return new Mg({type:"union",options:t,discriminator:e,...G(r)})}const xg=z("ZodIntersection",(e,t)=>{Lm.init(e,t),ke.init(e,t)});function fa(e,t){return new xg({type:"intersection",left:e,right:t})}const qg=z("ZodRecord",(e,t)=>{Fm.init(e,t),ke.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function _e(e,t,r){return new qg({type:"record",keyType:e,valueType:t,...G(r)})}const wo=z("ZodEnum",(e,t)=>{Hm.init(e,t),ke.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(n,s)=>{const o={};for(const a of n)if(r.has(a))o[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new wo({...t,checks:[],...G(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 wo({...t,checks:[],...G(s),entries:o})}});function tt(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new wo({type:"enum",entries:r,...G(t)})}const Dg=z("ZodLiteral",(e,t)=>{Zm.init(e,t),ke.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function N(e,t){return new Dg({type:"literal",values:Array.isArray(e)?e:[e],...G(t)})}const Ug=z("ZodTransform",(e,t)=>{Km.init(e,t),ke.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=o=>{if(typeof o=="string")r.issues.push(_n(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(_n(a))}};const s=t.transform(r.value,r);return s instanceof Promise?s.then(o=>(r.value=o,r)):(r.value=s,r)}});function Tu(e){return new Ug({type:"transform",transform:e})}const Ru=z("ZodOptional",(e,t)=>{Gm.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Te(e){return new Ru({type:"optional",innerType:e})}const Vg=z("ZodNullable",(e,t)=>{Wm.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Vc(e){return new Vg({type:"nullable",innerType:e})}const Lg=z("ZodDefault",(e,t)=>{Bm.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Fg(e,t){return new Lg({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const Hg=z("ZodPrefault",(e,t)=>{Jm.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Zg(e,t){return new Hg({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const Cu=z("ZodNonOptional",(e,t)=>{Qm.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Kg(e,t){return new Cu({type:"nonoptional",innerType:e,...G(t)})}const Gg=z("ZodCatch",(e,t)=>{Ym.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Wg(e,t){return new Gg({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Bg=z("ZodPipe",(e,t)=>{Xm.init(e,t),ke.init(e,t),e.in=t.in,e.out=t.out});function bo(e,t){return new Bg({type:"pipe",in:e,out:t})}const Jg=z("ZodReadonly",(e,t)=>{e_.init(e,t),ke.init(e,t)});function Qg(e){return new Jg({type:"readonly",innerType:e})}const Nu=z("ZodCustom",(e,t)=>{t_.init(e,t),ke.init(e,t)});function Yg(e){const t=new Xe({check:"custom"});return t._zod.check=e,t}function Xg(e,t){return B_(Nu,e??(()=>!0),t)}function ey(e,t={}){return J_(Nu,e,t)}function ty(e){const t=Yg(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(_n(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(_n(s))}},e(r.value,r)));return t}function Iu(e,t){return bo(Tu(e),t)}const ry={custom:"custom"};function ny(e){return N_(ua,e)}const As="2025-11-25",sy=[As,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],nr="io.modelcontextprotocol/related-task",zs="2.0",ze=Xg(e=>e!==null&&(typeof e=="object"||typeof e=="function")),ju=pe([k(),oe().int()]),Ou=k();Le({ttl:oe().optional(),pollInterval:oe().optional()});const oy=O({ttl:oe().optional()}),ay=O({taskId:k()}),ha=Le({progressToken:ju.optional(),[nr]:ay.optional()}),rt=O({_meta:ha.optional()}),Sn=rt.extend({task:oy.optional()}),iy=e=>Sn.safeParse(e).success,Fe=O({method:k(),params:rt.loose().optional()}),ot=O({_meta:ha.optional()}),at=O({method:k(),params:ot.loose().optional()}),He=Le({_meta:ha.optional()}),En=pe([k(),oe().int()]),Au=O({jsonrpc:N(zs),id:En,...Fe.shape}).strict(),So=e=>Au.safeParse(e).success,zu=O({jsonrpc:N(zs),...at.shape}).strict(),cy=e=>zu.safeParse(e).success,pa=O({jsonrpc:N(zs),id:En,result:He}).strict(),Xr=e=>pa.safeParse(e).success;var re;(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"})(re||(re={}));const ma=O({jsonrpc:N(zs),id:En.optional(),error:O({code:oe().int(),message:k(),data:$e().optional()})}).strict(),ly=e=>ma.safeParse(e).success,Yn=pe([Au,zu,pa,ma]);pe([pa,ma]);const Pr=He.strict(),uy=ot.extend({requestId:En.optional(),reason:k().optional()}),_a=at.extend({method:N("notifications/cancelled"),params:uy}),dy=O({src:k(),mimeType:k().optional(),sizes:D(k()).optional(),theme:tt(["light","dark"]).optional()}),kn=O({icons:D(dy).optional()}),Or=O({name:k(),title:k().optional()}),Ms=Or.extend({...Or.shape,...kn.shape,version:k(),websiteUrl:k().optional(),description:k().optional()}),fy=fa(O({applyDefaults:me().optional()}),_e(k(),$e())),hy=Iu(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,fa(O({form:fy.optional(),url:ze.optional()}),_e(k(),$e()).optional())),py=Le({list:ze.optional(),cancel:ze.optional(),requests:Le({sampling:Le({createMessage:ze.optional()}).optional(),elicitation:Le({create:ze.optional()}).optional()}).optional()}),my=Le({list:ze.optional(),cancel:ze.optional(),requests:Le({tools:Le({call:ze.optional()}).optional()}).optional()}),_y=O({experimental:_e(k(),ze).optional(),sampling:O({context:ze.optional(),tools:ze.optional()}).optional(),elicitation:hy.optional(),roots:O({listChanged:me().optional()}).optional(),tasks:py.optional(),extensions:_e(k(),ze).optional()}),gy=rt.extend({protocolVersion:k(),capabilities:_y,clientInfo:Ms}),yy=Fe.extend({method:N("initialize"),params:gy}),vy=O({experimental:_e(k(),ze).optional(),logging:ze.optional(),completions:ze.optional(),prompts:O({listChanged:me().optional()}).optional(),resources:O({subscribe:me().optional(),listChanged:me().optional()}).optional(),tools:O({listChanged:me().optional()}).optional(),tasks:my.optional(),extensions:_e(k(),ze).optional()}),Mu=He.extend({protocolVersion:k(),capabilities:vy,serverInfo:Ms,instructions:k().optional()}),xu=at.extend({method:N("notifications/initialized"),params:ot.optional()}),$y=e=>xu.safeParse(e).success,xs=Fe.extend({method:N("ping"),params:rt.optional()}),wy=O({progress:oe(),total:Te(oe()),message:Te(k())}),by=O({...ot.shape,...wy.shape,progressToken:ju}),ga=at.extend({method:N("notifications/progress"),params:by}),Sy=rt.extend({cursor:Ou.optional()}),Pn=Fe.extend({params:Sy.optional()}),Tn=He.extend({nextCursor:Ou.optional()}),Ey=tt(["working","input_required","completed","failed","cancelled"]),Rn=O({taskId:k(),status:Ey,ttl:pe([oe(),Ig()]),createdAt:k(),lastUpdatedAt:k(),pollInterval:Te(oe()),statusMessage:Te(k())}),gn=He.extend({task:Rn}),ky=ot.merge(Rn),fs=at.extend({method:N("notifications/tasks/status"),params:ky}),ya=Fe.extend({method:N("tasks/get"),params:rt.extend({taskId:k()})}),va=He.merge(Rn),$a=Fe.extend({method:N("tasks/result"),params:rt.extend({taskId:k()})});He.loose();const wa=Pn.extend({method:N("tasks/list")}),ba=Tn.extend({tasks:D(Rn)}),Sa=Fe.extend({method:N("tasks/cancel"),params:rt.extend({taskId:k()})}),Py=He.merge(Rn),qu=O({uri:k(),mimeType:Te(k()),_meta:_e(k(),$e()).optional()}),Du=qu.extend({text:k()}),Ea=k().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Uu=qu.extend({blob:Ea}),Cn=tt(["user","assistant"]),Dr=O({audience:D(Cn).optional(),priority:oe().min(0).max(1).optional(),lastModified:wu({offset:!0}).optional()}),Vu=O({...Or.shape,...kn.shape,uri:k(),description:Te(k()),mimeType:Te(k()),size:Te(oe()),annotations:Dr.optional(),_meta:Te(Le({}))}),Ty=O({...Or.shape,...kn.shape,uriTemplate:k(),description:Te(k()),mimeType:Te(k()),annotations:Dr.optional(),_meta:Te(Le({}))}),Lu=Pn.extend({method:N("resources/list")}),ka=Tn.extend({resources:D(Vu)}),Fu=Pn.extend({method:N("resources/templates/list")}),Pa=Tn.extend({resourceTemplates:D(Ty)}),Ta=rt.extend({uri:k()}),Ry=Ta,Hu=Fe.extend({method:N("resources/read"),params:Ry}),Ra=He.extend({contents:D(pe([Du,Uu]))}),Ca=at.extend({method:N("notifications/resources/list_changed"),params:ot.optional()}),Cy=Ta,Ny=Fe.extend({method:N("resources/subscribe"),params:Cy}),Iy=Ta,jy=Fe.extend({method:N("resources/unsubscribe"),params:Iy}),Oy=ot.extend({uri:k()}),Ay=at.extend({method:N("notifications/resources/updated"),params:Oy}),zy=O({name:k(),description:Te(k()),required:Te(me())}),My=O({...Or.shape,...kn.shape,description:Te(k()),arguments:Te(D(zy)),_meta:Te(Le({}))}),Zu=Pn.extend({method:N("prompts/list")}),Na=Tn.extend({prompts:D(My)}),xy=rt.extend({name:k(),arguments:_e(k(),k()).optional()}),qy=Fe.extend({method:N("prompts/get"),params:xy}),Ia=O({type:N("text"),text:k(),annotations:Dr.optional(),_meta:_e(k(),$e()).optional()}),ja=O({type:N("image"),data:Ea,mimeType:k(),annotations:Dr.optional(),_meta:_e(k(),$e()).optional()}),Oa=O({type:N("audio"),data:Ea,mimeType:k(),annotations:Dr.optional(),_meta:_e(k(),$e()).optional()}),Dy=O({type:N("tool_use"),name:k(),id:k(),input:_e(k(),$e()),_meta:_e(k(),$e()).optional()}),Ku=O({type:N("resource"),resource:pe([Du,Uu]),annotations:Dr.optional(),_meta:_e(k(),$e()).optional()}),Gu=Vu.extend({type:N("resource_link")}),Nn=pe([Ia,ja,Oa,Gu,Ku]),Uy=O({role:Cn,content:Nn}),Wu=He.extend({description:k().optional(),messages:D(Uy)}),Aa=at.extend({method:N("notifications/prompts/list_changed"),params:ot.optional()}),Vy=O({title:k().optional(),readOnlyHint:me().optional(),destructiveHint:me().optional(),idempotentHint:me().optional(),openWorldHint:me().optional()}),Ly=O({taskSupport:tt(["required","optional","forbidden"]).optional()}),za=O({...Or.shape,...kn.shape,description:k().optional(),inputSchema:O({type:N("object"),properties:_e(k(),ze).optional(),required:D(k()).optional()}).catchall($e()),outputSchema:O({type:N("object"),properties:_e(k(),ze).optional(),required:D(k()).optional()}).catchall($e()).optional(),annotations:Vy.optional(),execution:Ly.optional(),_meta:_e(k(),$e()).optional()}),Fy=Pn.extend({method:N("tools/list")}),Ma=Tn.extend({tools:D(za)}),dr=He.extend({content:D(Nn).default([]),structuredContent:_e(k(),$e()).optional(),isError:me().optional()});dr.or(He.extend({toolResult:$e()}));const Hy=Sn.extend({name:k(),arguments:_e(k(),$e()).optional()}),Bu=Fe.extend({method:N("tools/call"),params:Hy}),xa=at.extend({method:N("notifications/tools/list_changed"),params:ot.optional()}),Zy=O({autoRefresh:me().default(!0),debounceMs:oe().int().nonnegative().default(300)}),Ju=tt(["debug","info","notice","warning","error","critical","alert","emergency"]),Ky=rt.extend({level:Ju}),Gy=Fe.extend({method:N("logging/setLevel"),params:Ky}),Wy=ot.extend({level:Ju,logger:k().optional(),data:$e()}),Qu=at.extend({method:N("notifications/message"),params:Wy}),By=O({name:k().optional()}),Jy=O({hints:D(By).optional(),costPriority:oe().min(0).max(1).optional(),speedPriority:oe().min(0).max(1).optional(),intelligencePriority:oe().min(0).max(1).optional()}),Qy=O({mode:tt(["auto","required","none"]).optional()}),Yy=O({type:N("tool_result"),toolUseId:k().describe("The unique identifier for the corresponding tool call."),content:D(Nn).default([]),structuredContent:O({}).loose().optional(),isError:me().optional(),_meta:_e(k(),$e()).optional()}),Xy=Pu("type",[Ia,ja,Oa]),hs=Pu("type",[Ia,ja,Oa,Dy,Yy]),ev=O({role:Cn,content:pe([hs,D(hs)]),_meta:_e(k(),$e()).optional()}),tv=Sn.extend({messages:D(ev),modelPreferences:Jy.optional(),systemPrompt:k().optional(),includeContext:tt(["none","thisServer","allServers"]).optional(),temperature:oe().optional(),maxTokens:oe().int(),stopSequences:D(k()).optional(),metadata:ze.optional(),tools:D(za).optional(),toolChoice:Qy.optional()}),qa=Fe.extend({method:N("sampling/createMessage"),params:tv}),Yu=He.extend({model:k(),stopReason:Te(tt(["endTurn","stopSequence","maxTokens"]).or(k())),role:Cn,content:Xy}),Xu=He.extend({model:k(),stopReason:Te(tt(["endTurn","stopSequence","maxTokens","toolUse"]).or(k())),role:Cn,content:pe([hs,D(hs)])}),rv=O({type:N("boolean"),title:k().optional(),description:k().optional(),default:me().optional()}),nv=O({type:N("string"),title:k().optional(),description:k().optional(),minLength:oe().optional(),maxLength:oe().optional(),format:tt(["email","uri","date","date-time"]).optional(),default:k().optional()}),sv=O({type:tt(["number","integer"]),title:k().optional(),description:k().optional(),minimum:oe().optional(),maximum:oe().optional(),default:oe().optional()}),ov=O({type:N("string"),title:k().optional(),description:k().optional(),enum:D(k()),default:k().optional()}),av=O({type:N("string"),title:k().optional(),description:k().optional(),oneOf:D(O({const:k(),title:k()})),default:k().optional()}),iv=O({type:N("string"),title:k().optional(),description:k().optional(),enum:D(k()),enumNames:D(k()).optional(),default:k().optional()}),cv=pe([ov,av]),lv=O({type:N("array"),title:k().optional(),description:k().optional(),minItems:oe().optional(),maxItems:oe().optional(),items:O({type:N("string"),enum:D(k())}),default:D(k()).optional()}),uv=O({type:N("array"),title:k().optional(),description:k().optional(),minItems:oe().optional(),maxItems:oe().optional(),items:O({anyOf:D(O({const:k(),title:k()}))}),default:D(k()).optional()}),dv=pe([lv,uv]),fv=pe([iv,cv,dv]),hv=pe([fv,rv,nv,sv]),pv=Sn.extend({mode:N("form").optional(),message:k(),requestedSchema:O({type:N("object"),properties:_e(k(),hv),required:D(k()).optional()})}),mv=Sn.extend({mode:N("url"),message:k(),elicitationId:k(),url:k().url()}),_v=pe([pv,mv]),ed=Fe.extend({method:N("elicitation/create"),params:_v}),gv=ot.extend({elicitationId:k()}),yv=at.extend({method:N("notifications/elicitation/complete"),params:gv}),td=He.extend({action:tt(["accept","decline","cancel"]),content:Iu(e=>e===null?void 0:e,_e(k(),pe([k(),oe(),me(),D(k())])).optional())}),vv=O({type:N("ref/resource"),uri:k()}),$v=O({type:N("ref/prompt"),name:k()}),wv=rt.extend({ref:pe([$v,vv]),argument:O({name:k(),value:k()}),context:O({arguments:_e(k(),k()).optional()}).optional()}),bv=Fe.extend({method:N("completion/complete"),params:wv}),rd=He.extend({completion:Le({values:D(k()).max(100),total:Te(oe().int()),hasMore:Te(me())})}),Sv=O({uri:k().startsWith("file://"),name:k().optional(),_meta:_e(k(),$e()).optional()}),Ev=Fe.extend({method:N("roots/list"),params:rt.optional()}),kv=He.extend({roots:D(Sv)}),Pv=at.extend({method:N("notifications/roots/list_changed"),params:ot.optional()});pe([xs,yy,bv,Gy,qy,Zu,Lu,Fu,Hu,Ny,jy,Bu,Fy,ya,$a,wa,Sa]);pe([_a,ga,xu,Pv,fs]);pe([Pr,Yu,Xu,td,kv,va,ba,gn]);pe([xs,qa,ed,Ev,ya,$a,wa,Sa]);pe([_a,ga,Qu,Ay,Ca,xa,Aa,fs,yv]);pe([Pr,Mu,rd,Wu,Na,ka,Pa,Ra,dr,Ma,va,ba,gn]);class Y 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===re.UrlElicitationRequired&&n){const s=n;if(s.elicitations)return new Tv(s.elicitations,r)}return new Y(t,r,n)}}class Tv extends Y{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(re.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){var t;return((t=this.data)==null?void 0:t.elicitations)??[]}}function Da(e){return!!e._zod}function jt(e,t){return Da(e)?iu(e,t):e.safeParse(t)}function nd(e){var r,n;if(!e)return;let t;if(Da(e)?t=(n=(r=e._zod)==null?void 0:r.def)==null?void 0:n.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function sd(e){var s;if(Da(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 Xt(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Lc(e){const t=nd(e),r=t==null?void 0:t.method;if(!r)throw new Error("Schema is missing a method literal");const n=sd(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Fc(e,t){const r=jt(e,t);if(!r.success)throw r.error;return r.data}const Rv=6e4;class od{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(_a,r=>{this._oncancel(r)}),this.setNotificationHandler(ga,r=>{this._onprogress(r)}),this.setRequestHandler(xs,r=>({})),this._taskStore=t==null?void 0:t.taskStore,this._taskMessageQueue=t==null?void 0:t.taskMessageQueue,this._taskStore&&(this.setRequestHandler(ya,async(r,n)=>{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new Y(re.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler($a,async(r,n)=>{const s=async()=>{var i;const o=r.params.taskId;if(this._taskMessageQueue){let c;for(;c=await this._taskMessageQueue.dequeue(o,n.sessionId);){if(c.type==="response"||c.type==="error"){const l=c.message,d=l.id,h=this._requestResolvers.get(d);if(h)if(this._requestResolvers.delete(d),c.type==="response")h(l);else{const y=l,g=new Y(y.error.code,y.error.message,y.error.data);h(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 Y(re.InvalidParams,`Task not found: ${o}`);if(!Xt(a.status))return await this._waitForTaskUpdate(o,n.signal),await s();if(Xt(a.status)){const c=await this._taskStore.getTaskResult(o,n.sessionId);return this._clearTaskQueue(o),{...c,_meta:{...c._meta,[nr]:{taskId:o}}}}return await s()};return await s()}),this.setRequestHandler(wa,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 Y(re.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Sa,async(r,n)=>{try{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new Y(re.InvalidParams,`Task not found: ${r.params.taskId}`);if(Xt(s.status))throw new Y(re.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 Y(re.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(s){throw s instanceof Y?s:new Y(re.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),Y.fromError(re.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),Xr(c)||ly(c)?this._onresponse(c):So(c)?this._onrequest(c,l):cy(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=Y.fromError(re.ConnectionClosed,"Connection closed");this._transport=void 0,(n=this.onclose)==null||n.call(this);for(const s of t.values())s(r)}_onerror(t){var r;(r=this.onerror)==null||r.call(this,t)}_onnotification(t){const r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){var d,h,y,g;const n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,s=this._transport,o=(y=(h=(d=t.params)==null?void 0:d._meta)==null?void 0:h[nr])==null?void 0:y.taskId;if(n===void 0){const _={jsonrpc:"2.0",id:t.id,error:{code:re.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:_,timestamp:Date.now()},s==null?void 0:s.sessionId).catch($=>this._onerror(new Error(`Failed to enqueue error response: ${$}`))):s==null||s.send(_).catch($=>this._onerror(new Error(`Failed to send an error response: ${$}`)));return}const a=new AbortController;this._requestHandlerAbortControllers.set(t.id,a);const i=iy(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 _=>{if(a.signal.aborted)return;const $={relatedRequestId:t.id};o&&($.relatedTask={taskId:o}),await this.notification(_,$)},sendRequest:async(_,$,m)=>{var S;if(a.signal.aborted)throw new Y(re.ConnectionClosed,"Request was cancelled");const f={...m,relatedRequestId:t.id};o&&!f.relatedTask&&(f.relatedTask={taskId:o});const v=((S=f.relatedTask)==null?void 0:S.taskId)??o;return v&&c&&await c.updateTaskStatus(v,"input_required"),await this.request(_,$,f)},authInfo:r==null?void 0:r.authInfo,requestId:t.id,requestInfo:r==null?void 0:r.requestInfo,taskId:o,taskStore:c,taskRequestedTtl:i==null?void 0:i.ttl,closeSSEStream:r==null?void 0:r.closeSSEStream,closeStandaloneSSEStream:r==null?void 0:r.closeStandaloneSSEStream};Promise.resolve().then(()=>{i&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,l)).then(async _=>{if(a.signal.aborted)return;const $={result:_,jsonrpc:"2.0",id:t.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:$,timestamp:Date.now()},s==null?void 0:s.sessionId):await(s==null?void 0:s.send($))},async _=>{if(a.signal.aborted)return;const $={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(_.code)?_.code:re.InternalError,message:_.message??"Internal error",..._.data!==void 0&&{data:_.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:$,timestamp:Date.now()},s==null?void 0:s.sessionId):await(s==null?void 0:s.send($))}).catch(_=>this._onerror(new Error(`Failed to send response: ${_}`))).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),Xr(t))n(t);else{const a=new Y(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(Xr(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),Xr(t))s(t);else{const a=Y.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 Y?c:new Y(re.InternalError,String(c))}}return}let o;try{const c=await this.request(t,gn,n);if(c.task)o=c.task.taskId,yield{type:"taskCreated",task:c.task};else throw new Y(re.InternalError,"Task creation did not return a task");for(;;){const l=await this.getTask({taskId:o},n);if(yield{type:"taskStatus",task:l},Xt(l.status)){l.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)}:l.status==="failed"?yield{type:"error",error:new Y(re.InternalError,`Task ${o} failed`)}:l.status==="cancelled"&&(yield{type:"error",error:new Y(re.InternalError,`Task ${o} was cancelled`)});return}if(l.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)};return}const d=l.pollInterval??((a=this._options)==null?void 0:a.defaultTaskPollInterval)??1e3;await new Promise(h=>setTimeout(h,d)),(i=n==null?void 0:n.signal)==null||i.throwIfAborted()}}catch(c){yield{type:"error",error:c instanceof Y?c:new Y(re.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 v,S,R,P,I;const h=A=>{d(A)};if(!this._transport){h(new Error("Not connected"));return}if(((v=this._options)==null?void 0:v.enforceStrictCapabilities)===!0)try{this.assertCapabilityForMethod(t.method),i&&this.assertTaskCapability(t.method)}catch(A){h(A);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:{...((P=g.params)==null?void 0:P._meta)||{},[nr]:c}});const _=A=>{var Z;this._responseHandlers.delete(y),this._progressHandlers.delete(y),this._cleanupTimeout(y),(Z=this._transport)==null||Z.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:y,reason:String(A)}},{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a}).catch(V=>this._onerror(new Error(`Failed to send cancellation: ${V}`)));const U=A instanceof Y?A:new Y(re.RequestTimeout,String(A));d(U)};this._responseHandlers.set(y,A=>{var U;if(!((U=n==null?void 0:n.signal)!=null&&U.aborted)){if(A instanceof Error)return d(A);try{const Z=jt(r,A.result);Z.success?l(Z.data):d(Z.error)}catch(Z){d(Z)}}}),(I=n==null?void 0:n.signal)==null||I.addEventListener("abort",()=>{var A;_((A=n==null?void 0:n.signal)==null?void 0:A.reason)});const $=(n==null?void 0:n.timeout)??Rv,m=()=>_(Y.fromError(re.RequestTimeout,"Request timed out",{timeout:$}));this._setupTimeout(y,$,n==null?void 0:n.maxTotalTimeout,m,(n==null?void 0:n.resetTimeoutOnProgress)??!1);const f=c==null?void 0:c.taskId;if(f){const A=U=>{const Z=this._responseHandlers.get(y);Z?Z(U):this._onerror(new Error(`Response handler missing for side-channeled request ${y}`))};this._requestResolvers.set(y,A),this._enqueueTaskMessage(f,{type:"request",message:g,timestamp:Date.now()}).catch(U=>{this._cleanupTimeout(y),d(U)})}else this._transport.send(g,{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a}).catch(A=>{this._cleanupTimeout(y),d(A)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},va,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},ba,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},Py,r)}async notification(t,r){var i,c,l,d;if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);const n=(i=r==null?void 0:r.relatedTask)==null?void 0:i.taskId;if(n){const h={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...((c=t.params)==null?void 0:c._meta)||{},[nr]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:h,timestamp:Date.now()});return}if((((l=this._options)==null?void 0:l.debouncedNotificationMethods)??[]).includes(t.method)&&!t.params&&!(r!=null&&r.relatedRequestId)&&!(r!=null&&r.relatedTask)){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{var y,g;if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let h={...t,jsonrpc:"2.0"};r!=null&&r.relatedTask&&(h={...h,params:{...h.params,_meta:{...((y=h.params)==null?void 0:y._meta)||{},[nr]:r.relatedTask}}}),(g=this._transport)==null||g.send(h,r).catch(_=>this._onerror(_))});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)||{},[nr]:r.relatedTask}}}),await this._transport.send(a,r)}setRequestHandler(t,r){const n=Lc(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,o)=>{const a=Fc(t,s);return Promise.resolve(r(a,o))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){const n=Lc(t);this._notificationHandlers.set(n,s=>{const o=Fc(t,s);return Promise.resolve(r(o))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){const r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,n){var o;if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const s=(o=this._options)==null?void 0:o.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,n,s)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){const n=await this._taskMessageQueue.dequeueAll(t,r);for(const s of n)if(s.type==="request"&&So(s.message)){const o=s.message.id,a=this._requestResolvers.get(o);a?(a(new Y(re.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 Y(re.InvalidRequest,"Request cancelled"));return}const c=setTimeout(a,n);r.addEventListener("abort",()=>{clearTimeout(c),i(new Y(re.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 Y(re.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=fs.parse({method:"notifications/tasks/status",params:i});await this.notification(c),Xt(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 Y(re.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(Xt(i.status))throw new Y(re.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=fs.parse({method:"notifications/tasks/status",params:c});await this.notification(l),Xt(c.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>n.listTasks(s,r)}}}function Hc(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Cv(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];Hc(a)&&Hc(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 Nv extends od{constructor(){super(...arguments);ae(this,"_registeredMethods",new Set);ae(this,"_eventSlots",new Map);ae(this,"setRequestHandler",(r,n)=>{this._assertMethodNotRegistered(r,"setRequestHandler"),super.setRequestHandler(r,n)});ae(this,"setNotificationHandler",(r,n)=>{this._assertMethodNotRegistered(r,"setNotificationHandler"),super.setNotificationHandler(r,n)});ae(this,"replaceRequestHandler",(r,n)=>{let s=r.shape.method.value;this._registeredMethods.add(s),super.setRequestHandler(r,n)})}onEventDispatch(r,n){}_ensureEventSlot(r){let n=this._eventSlots.get(r);if(!n){let s=this.eventSchemas[r];if(!s)throw Error(`Unknown event: ${String(r)}`);n={listeners:[]},this._eventSlots.set(r,n);let o=s.shape.method.value;this._registeredMethods.add(o);let a=n;super.setNotificationHandler(s,i=>{var l;let c=i.params;this.onEventDispatch(r,c),(l=a.onHandler)==null||l.call(a,c);for(let d of[...a.listeners])d(c)})}return n}setEventHandler(r,n){let s=this._ensureEventSlot(r);s.onHandler&&n&&console.warn(`[MCP Apps] on${String(r)} handler replaced. Use addEventListener("${String(r)}", …) to add multiple listeners without replacing.`),s.onHandler=n}getEventHandler(r){var n;return(n=this._eventSlots.get(r))==null?void 0:n.onHandler}addEventListener(r,n){this._ensureEventSlot(r).listeners.push(n)}removeEventListener(r,n){let s=this._eventSlots.get(r);if(!s)return;let o=s.listeners.indexOf(n);o!==-1&&s.listeners.splice(o,1)}warnIfRequestHandlerReplaced(r,n,s){n&&s&&console.warn(`[MCP Apps] ${r} handler replaced. Previous handler will no longer be called.`)}_assertMethodNotRegistered(r,n){let s=r.shape.method.value;if(this._registeredMethods.has(s))throw Error(`Handler for "${s}" already registered (via ${n}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._registeredMethods.add(s)}}var ad="2026-01-26",Iv="ui/notifications/tool-input-partial",jv=pe([N("light"),N("dark")]).describe("Color theme preference for the host environment."),yn=pe([N("inline"),N("fullscreen"),N("pip")]).describe("Display mode for UI presentation."),Ov=pe([N("--color-background-primary"),N("--color-background-secondary"),N("--color-background-tertiary"),N("--color-background-inverse"),N("--color-background-ghost"),N("--color-background-info"),N("--color-background-danger"),N("--color-background-success"),N("--color-background-warning"),N("--color-background-disabled"),N("--color-text-primary"),N("--color-text-secondary"),N("--color-text-tertiary"),N("--color-text-inverse"),N("--color-text-ghost"),N("--color-text-info"),N("--color-text-danger"),N("--color-text-success"),N("--color-text-warning"),N("--color-text-disabled"),N("--color-border-primary"),N("--color-border-secondary"),N("--color-border-tertiary"),N("--color-border-inverse"),N("--color-border-ghost"),N("--color-border-info"),N("--color-border-danger"),N("--color-border-success"),N("--color-border-warning"),N("--color-border-disabled"),N("--color-ring-primary"),N("--color-ring-secondary"),N("--color-ring-inverse"),N("--color-ring-info"),N("--color-ring-danger"),N("--color-ring-success"),N("--color-ring-warning"),N("--font-sans"),N("--font-mono"),N("--font-weight-normal"),N("--font-weight-medium"),N("--font-weight-semibold"),N("--font-weight-bold"),N("--font-text-xs-size"),N("--font-text-sm-size"),N("--font-text-md-size"),N("--font-text-lg-size"),N("--font-heading-xs-size"),N("--font-heading-sm-size"),N("--font-heading-md-size"),N("--font-heading-lg-size"),N("--font-heading-xl-size"),N("--font-heading-2xl-size"),N("--font-heading-3xl-size"),N("--font-text-xs-line-height"),N("--font-text-sm-line-height"),N("--font-text-md-line-height"),N("--font-text-lg-line-height"),N("--font-heading-xs-line-height"),N("--font-heading-sm-line-height"),N("--font-heading-md-line-height"),N("--font-heading-lg-line-height"),N("--font-heading-xl-line-height"),N("--font-heading-2xl-line-height"),N("--font-heading-3xl-line-height"),N("--border-radius-xs"),N("--border-radius-sm"),N("--border-radius-md"),N("--border-radius-lg"),N("--border-radius-xl"),N("--border-radius-full"),N("--border-width-regular"),N("--shadow-hairline"),N("--shadow-sm"),N("--shadow-md"),N("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),Av=_e(Ov.describe(`Style variables for theming MCP apps. + +Individual style keys are optional - hosts may provide any subset of these values. +Values are strings containing CSS values (colors, sizes, font stacks, etc.). + +Note: This type uses \`Record\` rather than \`Partial>\` +for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),pe([k(),vo()]).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.`),zv=O({method:N("ui/open-link"),params:O({url:k().describe("URL to open in the host's browser")})});O({isError:me().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough();O({isError:me().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough();O({isError:me().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();var Mv=O({method:N("ui/notifications/sandbox-proxy-ready"),params:O({})}),Ua=O({connectDomains:D(k()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket). + +- Maps to CSP \`connect-src\` directive +- Empty or omitted → no network connections (secure default)`),resourceDomains:D(k()).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:D(k()).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:D(k()).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'`)")}),Va=O({camera:O({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:O({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:O({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:O({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),xv=O({method:N("ui/notifications/size-changed"),params:O({width:oe().optional().describe("New width in pixels."),height:oe().optional().describe("New height in pixels.")})});O({method:N("ui/notifications/tool-input"),params:O({arguments:_e(k(),$e().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})});O({method:N("ui/notifications/tool-input-partial"),params:O({arguments:_e(k(),$e().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})});O({method:N("ui/notifications/tool-cancelled"),params:O({reason:k().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})});var qv=O({fonts:k().optional()}),Dv=O({variables:Av.optional().describe("CSS variables for theming the app."),css:qv.optional().describe("CSS blocks that apps can inject.")});O({method:N("ui/resource-teardown"),params:O({})});var Uv=_e(k(),$e()),Zc=O({text:O({}).optional().describe("Host supports text content blocks."),image:O({}).optional().describe("Host supports image content blocks."),audio:O({}).optional().describe("Host supports audio content blocks."),resource:O({}).optional().describe("Host supports resource content blocks."),resourceLink:O({}).optional().describe("Host supports resource link content blocks."),structuredContent:O({}).optional().describe("Host supports structured content.")}),Vv=O({method:N("ui/notifications/request-teardown"),params:O({}).optional()}),Lv=O({experimental:_e(k(),_e(k(),da()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:O({}).optional().describe("Host supports opening external URLs."),downloadFile:O({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:O({listChanged:me().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:O({listChanged:me().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:O({}).optional().describe("Host accepts log messages."),sandbox:O({permissions:Va.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:Ua.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:Zc.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:Zc.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:O({tools:O({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.")}).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")}),Fv=O({experimental:_e(k(),_e(k(),da()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:O({listChanged:me().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:D(yn).optional().describe("Display modes the app supports.")}),Hv=O({method:N("ui/notifications/initialized"),params:O({}).optional()});O({csp:Ua.optional().describe("Content Security Policy configuration for UI resources."),permissions:Va.optional().describe("Sandbox permissions requested by the UI resource."),domain:k().optional().describe(`Dedicated origin for view sandbox. + +Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists. + +**Host-dependent:** The format and validation rules for this field are determined by each host. Servers MUST consult host-specific documentation for the expected domain format. Common patterns include: +- Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`) +- URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`) + +If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:me().optional().describe(`Visual boundary preference - true if view prefers a visible border. + +Boolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary. + +- \`true\`: request visible border + background +- \`false\`: request no visible border + background +- omitted: host decides border`)});var Kc=O({method:N("ui/request-display-mode"),params:O({mode:yn.describe("The display mode being requested.")})});O({mode:yn.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough();var Zv=pe([N("model"),N("app")]).describe("Tool visibility scope - who can access the tool.");O({resourceUri:k().optional(),visibility:D(Zv).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:$o().optional(),permissions:$o().optional()});O({mimeTypes:D(k()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});var Kv=O({method:N("ui/download-file"),params:O({contents:D(pe([Ku,Gu])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),Gv=O({method:N("ui/message"),params:O({role:N("user").describe('Message role, currently only "user" is supported.'),content:D(Nn).describe("Message content blocks (text, image, etc.).")})});O({method:N("ui/notifications/sandbox-resource-ready"),params:O({html:k().describe("HTML content to load into the inner iframe."),sandbox:k().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Ua.optional().describe("CSP configuration from resource metadata."),permissions:Va.optional().describe("Sandbox permissions from resource metadata.")})});O({method:N("ui/notifications/tool-result"),params:dr.describe("Standard MCP tool execution result.")});var id=O({toolInfo:O({id:En.optional().describe("JSON-RPC id of the tools/call request."),tool:za.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:jv.optional().describe("Current color theme preference."),styles:Dv.optional().describe("Style configuration for theming the app."),displayMode:yn.optional().describe("How the UI is currently displayed."),availableDisplayModes:D(yn).optional().describe("Display modes the host supports."),containerDimensions:pe([O({height:oe().describe("Fixed container height in pixels.")}),O({maxHeight:pe([oe(),vo()]).optional().describe("Maximum container height in pixels.")})]).and(pe([O({width:oe().describe("Fixed container width in pixels.")}),O({maxWidth:pe([oe(),vo()]).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:k().optional().describe("User's language and region preference in BCP 47 format."),timeZone:k().optional().describe("User's timezone in IANA format."),userAgent:k().optional().describe("Host application identifier."),platform:pe([N("web"),N("desktop"),N("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:O({touch:me().optional().describe("Whether the device supports touch input."),hover:me().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:O({top:oe().describe("Top safe area inset in pixels."),right:oe().describe("Right safe area inset in pixels."),bottom:oe().describe("Bottom safe area inset in pixels."),left:oe().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough();O({method:N("ui/notifications/host-context-changed"),params:id.describe("Partial context update containing only changed fields.")});var Wv=O({method:N("ui/update-model-context"),params:O({content:D(Nn).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:_e(k(),$e().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),Bv=O({method:N("ui/initialize"),params:O({appInfo:Ms.describe("App identification (name and version)."),appCapabilities:Fv.describe("Features and capabilities this app provides."),protocolVersion:k().describe("Protocol version this app supports.")})});O({protocolVersion:k().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Ms.describe("Host application identification and version."),hostCapabilities:Lv.describe("Features and capabilities provided by the host."),hostContext:id.describe("Rich context about the host environment.")}).passthrough();class Jv{constructor(t=window.parent,r){ae(this,"eventTarget");ae(this,"eventSource");ae(this,"messageListener");ae(this,"onclose");ae(this,"onerror");ae(this,"onmessage");ae(this,"sessionId");ae(this,"setProtocolVersion");this.eventTarget=t,this.eventSource=r,this.messageListener=n=>{var o,a,i;if(r&&n.source!==this.eventSource){console.debug("Ignoring message from unknown source",n);return}let s=Yn.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 Qv=[ad];class Yv extends Nv{constructor(r,n,s,o){super(o);ae(this,"_client");ae(this,"_hostInfo");ae(this,"_capabilities");ae(this,"_appCapabilities");ae(this,"_hostContext",{});ae(this,"_appInfo");ae(this,"_initializedReceived",!1);ae(this,"_baseReplaceRequestHandler",this.replaceRequestHandler);ae(this,"replaceRequestHandler",(r,n)=>{this._baseReplaceRequestHandler(r,(s,o)=>(this._initializedReceived||console.warn(`[ext-apps] AppBridge received '${s.method}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`),n(s,o)))});ae(this,"eventSchemas",{sizechange:xv,sandboxready:Mv,initialized:Hv,requestteardown:Vv,loggingmessage:Qu});ae(this,"onping");ae(this,"_onmessage");ae(this,"_onopenlink");ae(this,"_ondownloadfile");ae(this,"_onrequestdisplaymode");ae(this,"_onupdatemodelcontext");ae(this,"_oncalltool");ae(this,"_onlistresources");ae(this,"_onlistresourcetemplates");ae(this,"_onreadresource");ae(this,"_onlistprompts");ae(this,"sendResourceTeardown",this.teardownResource);this._client=r,this._hostInfo=n,this._capabilities=s,this.addEventListener("initialized",()=>{this._initializedReceived=!0}),this._hostContext=(o==null?void 0:o.hostContext)||{},this.setRequestHandler(Bv,a=>this._oninitialize(a)),this.setRequestHandler(xs,(a,i)=>{var c;return(c=this.onping)==null||c.call(this,a.params,i),{}}),this.replaceRequestHandler(Kc,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(Gv,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(zv,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(Kv,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(Kc,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(Wv,async(n,s)=>{if(!this._onupdatemodelcontext)throw Error("No onupdatemodelcontext handler set");return this._onupdatemodelcontext(n.params,s)})}get oncalltool(){return this._oncalltool}set oncalltool(r){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,r),this._oncalltool=r,this.replaceRequestHandler(Bu,async(n,s)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,s)})}set oncreatesamplingmessage(r){this.setRequestHandler(qa,async(n,s)=>r(n.params,s))}sendToolListChanged(r={}){return this.notification({method:"notifications/tools/list_changed",params:r})}get onlistresources(){return this._onlistresources}set onlistresources(r){this.warnIfRequestHandlerReplaced("onlistresources",this._onlistresources,r),this._onlistresources=r,this.replaceRequestHandler(Lu,async(n,s)=>{if(!this._onlistresources)throw Error("No onlistresources handler set");return this._onlistresources(n.params,s)})}get onlistresourcetemplates(){return this._onlistresourcetemplates}set onlistresourcetemplates(r){this.warnIfRequestHandlerReplaced("onlistresourcetemplates",this._onlistresourcetemplates,r),this._onlistresourcetemplates=r,this.replaceRequestHandler(Fu,async(n,s)=>{if(!this._onlistresourcetemplates)throw Error("No onlistresourcetemplates handler set");return this._onlistresourcetemplates(n.params,s)})}get onreadresource(){return this._onreadresource}set onreadresource(r){this.warnIfRequestHandlerReplaced("onreadresource",this._onreadresource,r),this._onreadresource=r,this.replaceRequestHandler(Hu,async(n,s)=>{if(!this._onreadresource)throw Error("No onreadresource handler set");return this._onreadresource(n.params,s)})}sendResourceListChanged(r={}){return this.notification({method:"notifications/resources/list_changed",params:r})}get onlistprompts(){return this._onlistprompts}set onlistprompts(r){this.warnIfRequestHandlerReplaced("onlistprompts",this._onlistprompts,r),this._onlistprompts=r,this.replaceRequestHandler(Zu,async(n,s)=>{if(!this._onlistprompts)throw Error("No onlistprompts handler set");return this._onlistprompts(n.params,s)})}sendPromptListChanged(r={}){return this.notification({method:"notifications/prompts/list_changed",params:r})}assertCapabilityForMethod(r){}assertRequestHandlerCapability(r){}assertNotificationCapability(r){}assertTaskCapability(r){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(r){throw Error("Task handlers are not supported in MCP Apps")}getCapabilities(){return this._capabilities}async _oninitialize(r){let n=r.params.protocolVersion;return this._appInfo!==void 0&&console.warn("[ext-apps] AppBridge received a second ui/initialize. The View may be double-mounting (e.g. React StrictMode in dev) without closing the previous App instance. Responding normally; the latest appInfo/appCapabilities replace the previous values."),this._appCapabilities=r.params.appCapabilities,this._appInfo=r.params.appInfo,{protocolVersion:Qv.includes(n)?n:ad,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(r){let n={},s=!1;for(let o of Object.keys(r)){let a=this._hostContext[o],i=r[o];Xv(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},Uv,n)}callTool(r,n){return this.request({method:"tools/call",params:r},dr,n)}listTools(r,n){return this.request({method:"tools/list",params:r},Ma,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},dr,{signal:o.signal}),n.tools.listChanged&&this._client.setNotificationHandler(xa,s=>this.sendToolListChanged(s.params))),n.resources&&(this.onlistresources=async(s,o)=>this._client.request({method:"resources/list",params:s},ka,{signal:o.signal}),this.onlistresourcetemplates=async(s,o)=>this._client.request({method:"resources/templates/list",params:s},Pa,{signal:o.signal}),this.onreadresource=async(s,o)=>this._client.request({method:"resources/read",params:s},Ra,{signal:o.signal}),n.resources.listChanged&&this._client.setNotificationHandler(Ca,s=>this.sendResourceListChanged(s.params))),n.prompts&&(this.onlistprompts=async(s,o)=>this._client.request({method:"prompts/list",params:s},Na,{signal:o.signal}),n.prompts.listChanged&&this._client.setNotificationHandler(Aa,s=>this.sendPromptListChanged(s.params)))}return super.connect(r)}}function Xv(e,t){return JSON.stringify(e)===JSON.stringify(t)}var Eo={exports:{}},cd={},mt={},Ar={},In={},fe={},vn={};(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(v){if(super(),!e.IDENTIFIER.test(v))throw new Error("CodeGen: name must be a valid identifier");this.str=v}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=r;class n extends t{constructor(v){super(),this._items=typeof v=="string"?[v]:v}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const v=this._items[0];return v===""||v==='""'}get str(){var v;return(v=this._str)!==null&&v!==void 0?v:this._str=this._items.reduce((S,R)=>`${S}${R}`,"")}get names(){var v;return(v=this._names)!==null&&v!==void 0?v: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(f,...v){const S=[f[0]];let R=0;for(;R{if(h.scopePath===void 0)throw new Error(`CodeGen: name "${h}" has no value`);return(0,t._)`${l}${h.scopePath}`})}scopeCode(l=this._values,d,h){return this._reduceValues(l,y=>{if(y.value===void 0)throw new Error(`CodeGen: name "${y}" has no value`);return y.value.code},d,h)}_reduceValues(l,d,h={},y){let g=t.nil;for(const _ in l){const $=l[_];if(!$)continue;const m=h[_]=h[_]||new Map;$.forEach(f=>{if(m.has(f))return;m.set(f,n.Started);let v=d(f);if(v){const S=this.opts.es5?e.varKinds.var:e.varKinds.const;g=(0,t._)`${g}${S} ${f} = ${v};${this.opts._n}`}else if(v=y==null?void 0:y(f))g=(0,t._)`${g}${v}${this.opts._n}`;else throw new r(f);m.set(f,n.Completed)})}return g}}e.ValueScope=i})(ko);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=vn,r=ko;var n=vn;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}});var s=ko;Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class o{optimizeNodes(){return this}optimizeNames(u,p){return this}}class a extends o{constructor(u,p,E){super(),this.varKind=u,this.name=p,this.rhs=E}render({es5:u,_n:p}){const E=u?r.varKinds.var:this.varKind,M=this.rhs===void 0?"":` = ${this.rhs}`;return`${E} ${this.name}${M};`+p}optimizeNames(u,p){if(u[this.name.str])return this.rhs&&(this.rhs=q(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=q(this.rhs,u,p),this}get names(){const u=this.lhs instanceof t.Name?{}:{...this.lhs.names};return ce(u,this.rhs)}}class c extends i{constructor(u,p,E,M){super(u,E,M),this.op=p}render({_n:u}){return`${this.lhs} ${this.op}= ${this.rhs};`+u}}class l extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`${this.label}:`+u}}class d extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`break${this.label?` ${this.label}`:""};`+u}}class h extends o{constructor(u){super(),this.error=u}render({_n:u}){return`throw ${this.error};`+u}get names(){return this.error.names}}class 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=q(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 M=E.length;for(;M--;){const x=E[M];x.optimizeNames(u,p)||(le(u,x.names),E.splice(M,1))}return E.length>0?this:void 0}get names(){return this.nodes.reduce((u,p)=>W(u,p.names),{})}}class _ extends g{render(u){return"{"+u._n+super.render(u)+"}"+u._n}}class $ extends g{}class m extends _{}m.kind="else";class f extends _{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 m(E):E}if(p)return u===!1?p instanceof f?p:p.nodes:this.nodes.length?this:new f(Ce(u),p instanceof f?[p]:p.nodes);if(!(u===!1||!this.nodes.length))return this}optimizeNames(u,p){var 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=q(this.condition,u,p),this}get names(){const u=super.names;return ce(u,this.condition),this.else&&W(u,this.else.names),u}}f.kind="if";class v extends _{}v.kind="for";class S extends v{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=q(this.iteration,u,p),this}get names(){return W(super.names,this.iteration.names)}}class R extends v{constructor(u,p,E,M){super(),this.varKind=u,this.name=p,this.from=E,this.to=M}render(u){const p=u.es5?r.varKinds.var:this.varKind,{name:E,from:M,to:x}=this;return`for(${p} ${E}=${M}; ${E}<${x}; ${E}++)`+super.render(u)}get names(){const u=ce(super.names,this.from);return ce(u,this.to)}}class P extends v{constructor(u,p,E,M){super(),this.loop=u,this.varKind=p,this.name=E,this.iterable=M}render(u){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(u)}optimizeNames(u,p){if(super.optimizeNames(u,p))return this.iterable=q(this.iterable,u,p),this}get names(){return W(super.names,this.iterable.names)}}class I extends _{constructor(u,p,E){super(),this.name=u,this.args=p,this.async=E}render(u){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(u)}}I.kind="func";class A extends g{render(u){return"return "+super.render(u)}}A.kind="return";class U extends _{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,M;return super.optimizeNames(u,p),(E=this.catch)===null||E===void 0||E.optimizeNames(u,p),(M=this.finally)===null||M===void 0||M.optimizeNames(u,p),this}get names(){const u=super.names;return this.catch&&W(u,this.catch.names),this.finally&&W(u,this.finally.names),u}}class Z extends _{constructor(u){super(),this.error=u}render(u){return`catch(${this.error})`+super.render(u)}}Z.kind="catch";class V extends _{render(u){return"finally"+super.render(u)}}V.kind="finally";class L{constructor(u,p={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...p,_n:p.lines?` +`:""},this._extScope=u,this._scope=new r.Scope({parent:u}),this._nodes=[new $]}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,M){const x=this._scope.toName(p);return E!==void 0&&M&&(this._constants[x.str]=E),this._leafNode(new a(u,x,E)),x}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,M]of u)p.length>1&&p.push(","),p.push(E),(E!==M||this.opts.es5)&&(p.push(":"),(0,t.addCodeArg)(p,M));return p.push("}"),new t._Code(p)}if(u,p,E){if(this._blockNode(new f(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 f(u))}else(){return this._elseNode(new m)}endIf(){return this._endBlockNode(f,m)}_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,M,x=this.opts.es5?r.varKinds.var:r.varKinds.let){const B=this._scope.toName(u);return this._for(new R(x,B,p,E),()=>M(B))}forOf(u,p,E,M=r.varKinds.const){const x=this._scope.toName(u);if(this.opts.es5){const B=p instanceof t.Name?p:this.var("_arr",p);return this.forRange("_i",0,(0,t._)`${B}.length`,K=>{this.var(x,(0,t._)`${B}[${K}]`),E(x)})}return this._for(new P("of",M,x,p),()=>E(x))}forIn(u,p,E,M=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(u,(0,t._)`Object.keys(${p})`,E);const x=this._scope.toName(u);return this._for(new P("in",M,x,p),()=>E(x))}endFor(){return this._endBlockNode(v)}label(u){return this._leafNode(new l(u))}break(u){return this._leafNode(new d(u))}return(u){const p=new A;if(this._blockNode(p),this.code(u),p.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(A)}try(u,p,E){if(!p&&!E)throw new Error('CodeGen: "try" without "catch" and "finally"');const M=new U;if(this._blockNode(M),this.code(u),p){const x=this.name("e");this._currNode=M.catch=new Z(x),p(x)}return E&&(this._currNode=M.finally=new V,this.code(E)),this._endBlockNode(Z,V)}throw(u){return this._leafNode(new h(u))}block(u,p){return this._blockStarts.push(this._nodes.length),u&&this.code(u).endBlock(p),this}endBlock(u){const p=this._blockStarts.pop();if(p===void 0)throw new Error("CodeGen: not in self-balancing block");const 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,M){return this._blockNode(new I(u,p,E)),M&&this.code(M).endFunc(),this}endFunc(){return this._endBlockNode(I)}optimize(u=1){for(;u-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(u){return this._currNode.nodes.push(u),this}_blockNode(u){this._currNode.nodes.push(u),this._nodes.push(u)}_endBlockNode(u,p){const E=this._currNode;if(E instanceof u||p&&E instanceof p)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${p?`${u.kind}/${p.kind}`:u.kind}"`)}_elseNode(u){const p=this._currNode;if(!(p instanceof f))throw new Error('CodeGen: "else" without "if"');return this._currNode=p.else=u,this}get _root(){return this._nodes[0]}get _currNode(){const u=this._nodes;return u[u.length-1]}set _currNode(u){const p=this._nodes;p[p.length-1]=u}}e.CodeGen=L;function W(b,u){for(const p in u)b[p]=(b[p]||0)+(u[p]||0);return b}function ce(b,u){return u instanceof t._CodeOrName?W(b,u.names):b}function q(b,u,p){if(b instanceof t.Name)return E(b);if(!M(b))return b;return new t._Code(b._items.reduce((x,B)=>(B instanceof t.Name&&(B=E(B)),B instanceof t._Code?x.push(...B._items):x.push(B),x),[]));function E(x){const B=p[x.str];return B===void 0||u[x.str]!==1?x:(delete u[x.str],B)}function M(x){return x instanceof t._Code&&x._items.some(B=>B instanceof t.Name&&u[B.str]===1&&p[B.str]!==void 0)}}function le(b,u){for(const p in u)b[p]=(b[p]||0)-(u[p]||0)}function Ce(b){return typeof b=="boolean"||typeof b=="number"||b===null?!b:(0,t._)`!${C(b)}`}e.not=Ce;const ge=w(e.operators.AND);function it(...b){return b.reduce(ge)}e.and=it;const je=w(e.operators.OR);function j(...b){return b.reduce(je)}e.or=j;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})`}})(fe);var F={};Object.defineProperty(F,"__esModule",{value:!0});F.checkStrictMode=F.getErrorPath=F.Type=F.useFunc=F.setEvaluated=F.evaluatedPropsToName=F.mergeEvaluated=F.eachItem=F.unescapeJsonPointer=F.escapeJsonPointer=F.escapeFragment=F.unescapeFragment=F.schemaRefOrVal=F.schemaHasRulesButRef=F.schemaHasRules=F.checkUnknownRules=F.alwaysValidSchema=F.toHash=void 0;const ye=fe,e$=vn;function t$(e){const t={};for(const r of e)t[r]=!0;return t}F.toHash=t$;function r$(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(ld(e,t),!ud(t,e.self.RULES.all))}F.alwaysValidSchema=r$;function ld(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]||hd(e,`unknown keyword: "${o}"`)}F.checkUnknownRules=ld;function ud(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(t[r])return!0;return!1}F.schemaHasRules=ud;function n$(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}F.schemaHasRulesButRef=n$;function s$({topSchemaRef:e,schemaPath:t},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,ye._)`${r}`}return(0,ye._)`${e}${t}${(0,ye.getProperty)(n)}`}F.schemaRefOrVal=s$;function o$(e){return dd(decodeURIComponent(e))}F.unescapeFragment=o$;function a$(e){return encodeURIComponent(La(e))}F.escapeFragment=a$;function La(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}F.escapeJsonPointer=La;function dd(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}F.unescapeJsonPointer=dd;function i$(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)}F.eachItem=i$;function Gc({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(s,o,a,i)=>{const c=a===void 0?o:a instanceof ye.Name?(o instanceof ye.Name?e(s,o,a):t(s,o,a),a):o instanceof ye.Name?(t(s,a,o),o):r(o,a);return i===ye.Name&&!(c instanceof ye.Name)?n(s,c):c}}F.mergeEvaluated={props:Gc({mergeNames:(e,t,r)=>e.if((0,ye._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,ye._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,ye._)`${r} || {}`).code((0,ye._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,ye._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,ye._)`${r} || {}`),Fa(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:fd}),items:Gc({mergeNames:(e,t,r)=>e.if((0,ye._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,ye._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,ye._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,ye._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function fd(e,t){if(t===!0)return e.var("props",!0);const r=e.var("props",(0,ye._)`{}`);return t!==void 0&&Fa(e,r,t),r}F.evaluatedPropsToName=fd;function Fa(e,t,r){Object.keys(r).forEach(n=>e.assign((0,ye._)`${t}${(0,ye.getProperty)(n)}`,!0))}F.setEvaluated=Fa;const Wc={};function c$(e,t){return e.scopeValue("func",{ref:t,code:Wc[t.code]||(Wc[t.code]=new e$._Code(t.code))})}F.useFunc=c$;var Po;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Po||(F.Type=Po={}));function l$(e,t,r){if(e instanceof ye.Name){const n=t===Po.Num;return r?n?(0,ye._)`"[" + ${e} + "]"`:(0,ye._)`"['" + ${e} + "']"`:n?(0,ye._)`"/" + ${e}`:(0,ye._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,ye.getProperty)(e).toString():"/"+La(e)}F.getErrorPath=l$;function hd(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}F.checkStrictMode=hd;var bt={};Object.defineProperty(bt,"__esModule",{value:!0});const Ze=fe,u$={data:new Ze.Name("data"),valCxt:new Ze.Name("valCxt"),instancePath:new Ze.Name("instancePath"),parentData:new Ze.Name("parentData"),parentDataProperty:new Ze.Name("parentDataProperty"),rootData:new Ze.Name("rootData"),dynamicAnchors:new Ze.Name("dynamicAnchors"),vErrors:new Ze.Name("vErrors"),errors:new Ze.Name("errors"),this:new Ze.Name("this"),self:new Ze.Name("self"),scope:new Ze.Name("scope"),json:new Ze.Name("json"),jsonPos:new Ze.Name("jsonPos"),jsonLen:new Ze.Name("jsonLen"),jsonPart:new Ze.Name("jsonPart")};bt.default=u$;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;const t=fe,r=F,n=bt;e.keywordError={message:({keyword:m})=>(0,t.str)`must pass "${m}" keyword validation`},e.keyword$DataError={message:({keyword:m,schemaType:f})=>f?(0,t.str)`"${m}" keyword must be ${f} ($data)`:(0,t.str)`"${m}" keyword is invalid ($data)`};function s(m,f=e.keywordError,v,S){const{it:R}=m,{gen:P,compositeRule:I,allErrors:A}=R,U=h(m,f,v);S??(I||A)?c(P,U):l(R,(0,t._)`[${U}]`)}e.reportError=s;function o(m,f=e.keywordError,v){const{it:S}=m,{gen:R,compositeRule:P,allErrors:I}=S,A=h(m,f,v);c(R,A),P||I||l(S,n.default.vErrors)}e.reportExtraError=o;function a(m,f){m.assign(n.default.errors,f),m.if((0,t._)`${n.default.vErrors} !== null`,()=>m.if(f,()=>m.assign((0,t._)`${n.default.vErrors}.length`,f),()=>m.assign(n.default.vErrors,null)))}e.resetErrorsCount=a;function i({gen:m,keyword:f,schemaValue:v,data:S,errsCount:R,it:P}){if(R===void 0)throw new Error("ajv implementation error");const I=m.name("err");m.forRange("i",R,n.default.errors,A=>{m.const(I,(0,t._)`${n.default.vErrors}[${A}]`),m.if((0,t._)`${I}.instancePath === undefined`,()=>m.assign((0,t._)`${I}.instancePath`,(0,t.strConcat)(n.default.instancePath,P.errorPath))),m.assign((0,t._)`${I}.schemaPath`,(0,t.str)`${P.errSchemaPath}/${f}`),P.opts.verbose&&(m.assign((0,t._)`${I}.schema`,v),m.assign((0,t._)`${I}.data`,S))})}e.extendErrors=i;function c(m,f){const v=m.const("err",f);m.if((0,t._)`${n.default.vErrors} === null`,()=>m.assign(n.default.vErrors,(0,t._)`[${v}]`),(0,t._)`${n.default.vErrors}.push(${v})`),m.code((0,t._)`${n.default.errors}++`)}function l(m,f){const{gen:v,validateName:S,schemaEnv:R}=m;R.$async?v.throw((0,t._)`new ${m.ValidationError}(${f})`):(v.assign((0,t._)`${S}.errors`,f),v.return(!1))}const d={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function h(m,f,v){const{createErrors:S}=m.it;return S===!1?(0,t._)`{}`:y(m,f,v)}function y(m,f,v={}){const{gen:S,it:R}=m,P=[g(R,v),_(m,v)];return $(m,f,P),S.object(...P)}function g({errorPath:m},{instancePath:f}){const v=f?(0,t.str)`${m}${(0,r.getErrorPath)(f,r.Type.Str)}`:m;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,v)]}function _({keyword:m,it:{errSchemaPath:f}},{schemaPath:v,parentSchema:S}){let R=S?f:(0,t.str)`${f}/${m}`;return v&&(R=(0,t.str)`${R}${(0,r.getErrorPath)(v,r.Type.Str)}`),[d.schemaPath,R]}function $(m,{params:f,message:v},S){const{keyword:R,data:P,schemaValue:I,it:A}=m,{opts:U,propertyName:Z,topSchemaRef:V,schemaPath:L}=A;S.push([d.keyword,R],[d.params,typeof f=="function"?f(m):f||(0,t._)`{}`]),U.messages&&S.push([d.message,typeof v=="function"?v(m):v]),U.verbose&&S.push([d.schema,I],[d.parentSchema,(0,t._)`${V}${L}`],[n.default.data,P]),Z&&S.push([d.propertyName,Z])}})(In);Object.defineProperty(Ar,"__esModule",{value:!0});Ar.boolOrEmptySchema=Ar.topBoolOrEmptySchema=void 0;const d$=In,f$=fe,h$=bt,p$={message:"boolean schema is false"};function m$(e){const{gen:t,schema:r,validateName:n}=e;r===!1?pd(e,!1):typeof r=="object"&&r.$async===!0?t.return(h$.default.data):(t.assign((0,f$._)`${n}.errors`,null),t.return(!0))}Ar.topBoolOrEmptySchema=m$;function _$(e,t){const{gen:r,schema:n}=e;n===!1?(r.var(t,!1),pd(e)):r.var(t,!0)}Ar.boolOrEmptySchema=_$;function pd(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,d$.reportError)(s,p$,void 0,t)}var Oe={},fr={};Object.defineProperty(fr,"__esModule",{value:!0});fr.getRules=fr.isJSONType=void 0;const g$=["string","number","integer","boolean","null","object","array"],y$=new Set(g$);function v$(e){return typeof e=="string"&&y$.has(e)}fr.isJSONType=v$;function $$(){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:{}}}fr.getRules=$$;var Et={};Object.defineProperty(Et,"__esModule",{value:!0});Et.shouldUseRule=Et.shouldUseGroup=Et.schemaHasRulesForType=void 0;function w$({schema:e,self:t},r){const n=t.RULES.types[r];return n&&n!==!0&&md(e,n)}Et.schemaHasRulesForType=w$;function md(e,t){return t.rules.some(r=>_d(e,r))}Et.shouldUseGroup=md;function _d(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}Et.shouldUseRule=_d;Object.defineProperty(Oe,"__esModule",{value:!0});Oe.reportTypeError=Oe.checkDataTypes=Oe.checkDataType=Oe.coerceAndCheckDataType=Oe.getJSONTypes=Oe.getSchemaTypes=Oe.DataType=void 0;const b$=fr,S$=Et,E$=In,ne=fe,gd=F;var Cr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Cr||(Oe.DataType=Cr={}));function k$(e){const t=yd(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}Oe.getSchemaTypes=k$;function yd(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(b$.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Oe.getJSONTypes=yd;function P$(e,t){const{gen:r,data:n,opts:s}=e,o=T$(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0,S$.schemaHasRulesForType)(e,t[0]));if(a){const i=Ha(t,n,s.strictNumbers,Cr.Wrong);r.if(i,()=>{o.length?R$(e,t,o):Za(e)})}return a}Oe.coerceAndCheckDataType=P$;const vd=new Set(["string","number","integer","boolean","null"]);function T$(e,t){return t?e.filter(r=>vd.has(r)||t==="array"&&r==="array"):[]}function R$(e,t,r){const{gen:n,data:s,opts:o}=e,a=n.let("dataType",(0,ne._)`typeof ${s}`),i=n.let("coerced",(0,ne._)`undefined`);o.coerceTypes==="array"&&n.if((0,ne._)`${a} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,ne._)`${s}[0]`).assign(a,(0,ne._)`typeof ${s}`).if(Ha(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0,ne._)`${i} !== undefined`);for(const l of r)(vd.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),Za(e),n.endIf(),n.if((0,ne._)`${i} !== undefined`,()=>{n.assign(s,i),C$(e,i)});function c(l){switch(l){case"string":n.elseIf((0,ne._)`${a} == "number" || ${a} == "boolean"`).assign(i,(0,ne._)`"" + ${s}`).elseIf((0,ne._)`${s} === null`).assign(i,(0,ne._)`""`);return;case"number":n.elseIf((0,ne._)`${a} == "boolean" || ${s} === null + || (${a} == "string" && ${s} && ${s} == +${s})`).assign(i,(0,ne._)`+${s}`);return;case"integer":n.elseIf((0,ne._)`${a} === "boolean" || ${s} === null + || (${a} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(i,(0,ne._)`+${s}`);return;case"boolean":n.elseIf((0,ne._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(i,!1).elseIf((0,ne._)`${s} === "true" || ${s} === 1`).assign(i,!0);return;case"null":n.elseIf((0,ne._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(i,null);return;case"array":n.elseIf((0,ne._)`${a} === "string" || ${a} === "number" + || ${a} === "boolean" || ${s} === null`).assign(i,(0,ne._)`[${s}]`)}}}function C$({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,ne._)`${t} !== undefined`,()=>e.assign((0,ne._)`${t}[${r}]`,n))}function To(e,t,r,n=Cr.Correct){const s=n===Cr.Correct?ne.operators.EQ:ne.operators.NEQ;let o;switch(e){case"null":return(0,ne._)`${t} ${s} null`;case"array":o=(0,ne._)`Array.isArray(${t})`;break;case"object":o=(0,ne._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=a((0,ne._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=a();break;default:return(0,ne._)`typeof ${t} ${s} ${e}`}return n===Cr.Correct?o:(0,ne.not)(o);function a(i=ne.nil){return(0,ne.and)((0,ne._)`typeof ${t} == "number"`,i,r?(0,ne._)`isFinite(${t})`:ne.nil)}}Oe.checkDataType=To;function Ha(e,t,r,n){if(e.length===1)return To(e[0],t,r,n);let s;const o=(0,gd.toHash)(e);if(o.array&&o.object){const a=(0,ne._)`typeof ${t} != "object"`;s=o.null?a:(0,ne._)`!${t} || ${a}`,delete o.null,delete o.array,delete o.object}else s=ne.nil;o.number&&delete o.integer;for(const a in o)s=(0,ne.and)(s,To(a,t,r,n));return s}Oe.checkDataTypes=Ha;const N$={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,ne._)`{type: ${e}}`:(0,ne._)`{type: ${t}}`};function Za(e){const t=I$(e);(0,E$.reportError)(t,N$)}Oe.reportTypeError=Za;function I$(e){const{gen:t,data:r,schema:n}=e,s=(0,gd.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}var qs={};Object.defineProperty(qs,"__esModule",{value:!0});qs.assignDefaults=void 0;const yr=fe,j$=F;function O$(e,t){const{properties:r,items:n}=e.schema;if(t==="object"&&r)for(const s in r)Bc(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>Bc(e,o,s.default))}qs.assignDefaults=O$;function Bc(e,t,r){const{gen:n,compositeRule:s,data:o,opts:a}=e;if(r===void 0)return;const i=(0,yr._)`${o}${(0,yr.getProperty)(t)}`;if(s){(0,j$.checkStrictMode)(e,`default is ignored for: ${i}`);return}let c=(0,yr._)`${i} === undefined`;a.useDefaults==="empty"&&(c=(0,yr._)`${c} || ${i} === null || ${i} === ""`),n.if(c,(0,yr._)`${i} = ${(0,yr.stringify)(r)}`)}var $t={},ue={};Object.defineProperty(ue,"__esModule",{value:!0});ue.validateUnion=ue.validateArray=ue.usePattern=ue.callValidateCode=ue.schemaProperties=ue.allSchemaProperties=ue.noPropertyInData=ue.propertyInData=ue.isOwnProperty=ue.hasPropFunc=ue.reportMissingProp=ue.checkMissingProp=ue.checkReportMissingProp=void 0;const be=fe,Ka=F,Rt=bt,A$=F;function z$(e,t){const{gen:r,data:n,it:s}=e;r.if(Wa(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0,be._)`${t}`},!0),e.error()})}ue.checkReportMissingProp=z$;function M$({gen:e,data:t,it:{opts:r}},n,s){return(0,be.or)(...n.map(o=>(0,be.and)(Wa(e,t,o,r.ownProperties),(0,be._)`${s} = ${o}`)))}ue.checkMissingProp=M$;function x$(e,t){e.setParams({missingProperty:t},!0),e.error()}ue.reportMissingProp=x$;function $d(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,be._)`Object.prototype.hasOwnProperty`})}ue.hasPropFunc=$d;function Ga(e,t,r){return(0,be._)`${$d(e)}.call(${t}, ${r})`}ue.isOwnProperty=Ga;function q$(e,t,r,n){const s=(0,be._)`${t}${(0,be.getProperty)(r)} !== undefined`;return n?(0,be._)`${s} && ${Ga(e,t,r)}`:s}ue.propertyInData=q$;function Wa(e,t,r,n){const s=(0,be._)`${t}${(0,be.getProperty)(r)} === undefined`;return n?(0,be.or)(s,(0,be.not)(Ga(e,t,r))):s}ue.noPropertyInData=Wa;function wd(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}ue.allSchemaProperties=wd;function D$(e,t){return wd(t).filter(r=>!(0,Ka.alwaysValidSchema)(e,t[r]))}ue.schemaProperties=D$;function U$({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:a},i,c,l){const d=l?(0,be._)`${e}, ${t}, ${n}${s}`:t,h=[[Rt.default.instancePath,(0,be.strConcat)(Rt.default.instancePath,o)],[Rt.default.parentData,a.parentData],[Rt.default.parentDataProperty,a.parentDataProperty],[Rt.default.rootData,Rt.default.rootData]];a.opts.dynamicRef&&h.push([Rt.default.dynamicAnchors,Rt.default.dynamicAnchors]);const y=(0,be._)`${d}, ${r.object(...h)}`;return c!==be.nil?(0,be._)`${i}.call(${c}, ${y})`:(0,be._)`${i}(${y})`}ue.callValidateCode=U$;const V$=(0,be._)`new RegExp`;function L$({gen:e,it:{opts:t}},r){const n=t.unicodeRegExp?"u":"",{regExp:s}=t.code,o=s(r,n);return e.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,be._)`${s.code==="new RegExp"?V$:(0,A$.useFunc)(e,s)}(${r}, ${n})`})}ue.usePattern=L$;function F$(e){const{gen:t,data:r,keyword:n,it:s}=e,o=t.name("valid");if(s.allErrors){const i=t.let("valid",!0);return a(()=>t.assign(i,!1)),i}return t.var(o,!0),a(()=>t.break()),o;function a(i){const c=t.const("len",(0,be._)`${r}.length`);t.forRange("i",0,c,l=>{e.subschema({keyword:n,dataProp:l,dataPropType:Ka.Type.Num},o),t.if((0,be.not)(o),i)})}}ue.validateArray=F$;function H$(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,Ka.alwaysValidSchema)(s,c))&&!s.opts.unevaluated)return;const a=t.let("valid",!1),i=t.name("_valid");t.block(()=>r.forEach((c,l)=>{const d=e.subschema({keyword:n,schemaProp:l,compositeRule:!0},i);t.assign(a,(0,be._)`${a} || ${i}`),e.mergeValidEvaluated(d,i)||t.if((0,be.not)(a))})),e.result(a,()=>e.reset(),()=>e.error(!0))}ue.validateUnion=H$;Object.defineProperty($t,"__esModule",{value:!0});$t.validateKeywordUsage=$t.validSchemaType=$t.funcKeywordCode=$t.macroKeywordCode=void 0;const Ge=fe,sr=bt,Z$=ue,K$=In;function G$(e,t){const{gen:r,keyword:n,schema:s,parentSchema:o,it:a}=e,i=t.macro.call(a.self,s,o,a),c=bd(r,n,i);a.opts.validateSchema!==!1&&a.self.validateSchema(i,!0);const l=r.name("valid");e.subschema({schema:i,schemaPath:Ge.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},l),e.pass(l,()=>e.error(!0))}$t.macroKeywordCode=G$;function W$(e,t){var r;const{gen:n,keyword:s,schema:o,parentSchema:a,$data:i,it:c}=e;J$(c,t);const l=!i&&t.compile?t.compile.call(c.self,o,a,c):t.validate,d=bd(n,s,l),h=n.let("valid");e.block$data(h,y),e.ok((r=t.valid)!==null&&r!==void 0?r:h);function y(){if(t.errors===!1)$(),t.modifying&&Jc(e),m(()=>e.error());else{const f=t.async?g():_();t.modifying&&Jc(e),m(()=>B$(e,f))}}function g(){const f=n.let("ruleErrs",null);return n.try(()=>$((0,Ge._)`await `),v=>n.assign(h,!1).if((0,Ge._)`${v} instanceof ${c.ValidationError}`,()=>n.assign(f,(0,Ge._)`${v}.errors`),()=>n.throw(v))),f}function _(){const f=(0,Ge._)`${d}.errors`;return n.assign(f,null),$(Ge.nil),f}function $(f=t.async?(0,Ge._)`await `:Ge.nil){const v=c.opts.passContext?sr.default.this:sr.default.self,S=!("compile"in t&&!i||t.schema===!1);n.assign(h,(0,Ge._)`${f}${(0,Z$.callValidateCode)(e,d,v,S)}`,t.modifying)}function m(f){var v;n.if((0,Ge.not)((v=t.valid)!==null&&v!==void 0?v:h),f)}}$t.funcKeywordCode=W$;function Jc(e){const{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Ge._)`${n.parentData}[${n.parentDataProperty}]`))}function B$(e,t){const{gen:r}=e;r.if((0,Ge._)`Array.isArray(${t})`,()=>{r.assign(sr.default.vErrors,(0,Ge._)`${sr.default.vErrors} === null ? ${t} : ${sr.default.vErrors}.concat(${t})`).assign(sr.default.errors,(0,Ge._)`${sr.default.vErrors}.length`),(0,K$.extendErrors)(e)},()=>e.error())}function J$({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function bd(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Ge.stringify)(r)})}function Q$(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}$t.validSchemaType=Q$;function Y$({schema:e,opts:t,self:r,errSchemaPath:n},s,o){if(Array.isArray(s.keyword)?!s.keyword.includes(o):s.keyword!==o)throw new Error("ajv implementation error");const a=s.dependencies;if(a!=null&&a.some(i=>!Object.prototype.hasOwnProperty.call(e,i)))throw new Error(`parent schema must have dependencies of ${o}: ${a.join(",")}`);if(s.validateSchema&&!s.validateSchema(e[o])){const c=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(s.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}$t.validateKeywordUsage=Y$;var zt={};Object.defineProperty(zt,"__esModule",{value:!0});zt.extendSubschemaMode=zt.extendSubschemaData=zt.getSubschema=void 0;const yt=fe,Sd=F;function X$(e,{keyword:t,schemaProp:r,schema:n,schemaPath:s,errSchemaPath:o,topSchemaRef:a}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){const i=e.schema[t];return r===void 0?{schema:i,schemaPath:(0,yt._)`${e.schemaPath}${(0,yt.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:i[r],schemaPath:(0,yt._)`${e.schemaPath}${(0,yt.getProperty)(t)}${(0,yt.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,Sd.escapeFragment)(r)}`}}if(n!==void 0){if(s===void 0||o===void 0||a===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:s,topSchemaRef:a,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}zt.getSubschema=X$;function ew(e,t,{dataProp:r,dataPropType:n,data:s,dataTypes:o,propertyName:a}){if(s!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:i}=t;if(r!==void 0){const{errorPath:l,dataPathArr:d,opts:h}=t,y=i.let("data",(0,yt._)`${t.data}${(0,yt.getProperty)(r)}`,!0);c(y),e.errorPath=(0,yt.str)`${l}${(0,Sd.getErrorPath)(r,n,h.jsPropertySyntax)}`,e.parentDataProperty=(0,yt._)`${r}`,e.dataPathArr=[...d,e.parentDataProperty]}if(s!==void 0){const l=s instanceof yt.Name?s:i.let("data",s,!0);c(l),a!==void 0&&(e.propertyName=a)}o&&(e.dataTypes=o);function c(l){e.data=l,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,l]}}zt.extendSubschemaData=ew;function tw(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:s,allErrors:o}){n!==void 0&&(e.compositeRule=n),s!==void 0&&(e.createErrors=s),o!==void 0&&(e.allErrors=o),e.jtdDiscriminator=t,e.jtdMetadata=r}zt.extendSubschemaMode=tw;var Ue={},Ds=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},Ed={exports:{}},Ot=Ed.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(){};Xn(t,n,s,e,"",e)};Ot.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Ot.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Ot.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Ot.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 Xn(e,t,r,n,s,o,a,i,c,l){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,s,o,a,i,c,l);for(var d in n){var h=n[d];if(Array.isArray(h)){if(d in Ot.arrayKeywords)for(var y=0;yt+=kd(n)),t===1/0))return 1/0}return t}function Pd(e,t="",r){r!==!1&&(t=Nr(t));const n=e.parse(t);return Td(e,n)}Ue.getFullPath=Pd;function Td(e,t){return e.serialize(t).split("#")[0]+"#"}Ue._getFullPath=Td;const uw=/#\/?$/;function Nr(e){return e?e.replace(uw,""):""}Ue.normalizeId=Nr;function dw(e,t,r){return r=Nr(r),e.resolve(t,r)}Ue.resolveUrl=dw;const fw=/^[a-z_][-a-z0-9._]*$/i;function hw(e,t){if(typeof e=="boolean")return{};const{schemaId:r,uriResolver:n}=this.opts,s=Nr(e[r]||t),o={"":s},a=Pd(n,s,!1),i={},c=new Set;return aw(e,{allKeys:!0},(h,y,g,_)=>{if(_===void 0)return;const $=a+y;let m=o[_];typeof h[r]=="string"&&(m=f.call(this,h[r])),v.call(this,h.$anchor),v.call(this,h.$dynamicAnchor),o[y]=m;function f(S){const R=this.opts.uriResolver.resolve;if(S=Nr(m?R(m,S):S),c.has(S))throw d(S);c.add(S);let P=this.refs[S];return typeof P=="string"&&(P=this.refs[P]),typeof P=="object"?l(h,P.schema,S):S!==Nr($)&&(S[0]==="#"?(l(h,i[S],S),i[S]=h):this.refs[S]=$),S}function v(S){if(typeof S=="string"){if(!fw.test(S))throw new Error(`invalid anchor "${S}"`);f.call(this,`#${S}`)}}}),i;function l(h,y,g){if(y!==void 0&&!ow(h,y))throw d(g)}function d(h){return new Error(`reference "${h}" resolves to more than one schema`)}}Ue.getSchemaRefs=hw;Object.defineProperty(mt,"__esModule",{value:!0});mt.getData=mt.KeywordCxt=mt.validateFunctionCode=void 0;const Rd=Ar,Qc=Oe,Ba=Et,ps=Oe,pw=qs,sn=$t,eo=zt,J=fe,ee=bt,mw=Ue,kt=F,Br=In;function _w(e){if(Id(e)&&(jd(e),Nd(e))){vw(e);return}Cd(e,()=>(0,Rd.topBoolOrEmptySchema)(e))}mt.validateFunctionCode=_w;function Cd({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},o){s.code.es5?e.func(t,(0,J._)`${ee.default.data}, ${ee.default.valCxt}`,n.$async,()=>{e.code((0,J._)`"use strict"; ${Yc(r,s)}`),yw(e,s),e.code(o)}):e.func(t,(0,J._)`${ee.default.data}, ${gw(s)}`,n.$async,()=>e.code(Yc(r,s)).code(o))}function gw(e){return(0,J._)`{${ee.default.instancePath}="", ${ee.default.parentData}, ${ee.default.parentDataProperty}, ${ee.default.rootData}=${ee.default.data}${e.dynamicRef?(0,J._)`, ${ee.default.dynamicAnchors}={}`:J.nil}}={}`}function yw(e,t){e.if(ee.default.valCxt,()=>{e.var(ee.default.instancePath,(0,J._)`${ee.default.valCxt}.${ee.default.instancePath}`),e.var(ee.default.parentData,(0,J._)`${ee.default.valCxt}.${ee.default.parentData}`),e.var(ee.default.parentDataProperty,(0,J._)`${ee.default.valCxt}.${ee.default.parentDataProperty}`),e.var(ee.default.rootData,(0,J._)`${ee.default.valCxt}.${ee.default.rootData}`),t.dynamicRef&&e.var(ee.default.dynamicAnchors,(0,J._)`${ee.default.valCxt}.${ee.default.dynamicAnchors}`)},()=>{e.var(ee.default.instancePath,(0,J._)`""`),e.var(ee.default.parentData,(0,J._)`undefined`),e.var(ee.default.parentDataProperty,(0,J._)`undefined`),e.var(ee.default.rootData,ee.default.data),t.dynamicRef&&e.var(ee.default.dynamicAnchors,(0,J._)`{}`)})}function vw(e){const{schema:t,opts:r,gen:n}=e;Cd(e,()=>{r.$comment&&t.$comment&&Ad(e),Ew(e),n.let(ee.default.vErrors,null),n.let(ee.default.errors,0),r.unevaluated&&$w(e),Od(e),Tw(e)})}function $w(e){const{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,J._)`${r}.evaluated`),t.if((0,J._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,J._)`${e.evaluated}.props`,(0,J._)`undefined`)),t.if((0,J._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,J._)`${e.evaluated}.items`,(0,J._)`undefined`))}function Yc(e,t){const r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,J._)`/*# sourceURL=${r} */`:J.nil}function ww(e,t){if(Id(e)&&(jd(e),Nd(e))){bw(e,t);return}(0,Rd.boolOrEmptySchema)(e,t)}function Nd({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 Id(e){return typeof e.schema!="boolean"}function bw(e,t){const{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&Ad(e),kw(e),Pw(e);const o=n.const("_errs",ee.default.errors);Od(e,o),n.var(t,(0,J._)`${o} === ${ee.default.errors}`)}function jd(e){(0,kt.checkUnknownRules)(e),Sw(e)}function Od(e,t){if(e.opts.jtd)return Xc(e,[],!1,t);const r=(0,Qc.getSchemaTypes)(e.schema),n=(0,Qc.coerceAndCheckDataType)(e,r);Xc(e,r,!n,t)}function Sw(e){const{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,kt.schemaHasRulesButRef)(t,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function Ew(e){const{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,kt.checkStrictMode)(e,"default is ignored in the schema root")}function kw(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,mw.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function Pw(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Ad({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:s}){const o=r.$comment;if(s.$comment===!0)e.code((0,J._)`${ee.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){const a=(0,J.str)`${n}/$comment`,i=e.scopeValue("root",{ref:t.root});e.code((0,J._)`${ee.default.self}.opts.$comment(${o}, ${a}, ${i}.schema)`)}}function Tw(e){const{gen:t,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=e;r.$async?t.if((0,J._)`${ee.default.errors} === 0`,()=>t.return(ee.default.data),()=>t.throw((0,J._)`new ${s}(${ee.default.vErrors})`)):(t.assign((0,J._)`${n}.errors`,ee.default.vErrors),o.unevaluated&&Rw(e),t.return((0,J._)`${ee.default.errors} === 0`))}function Rw({gen:e,evaluated:t,props:r,items:n}){r instanceof J.Name&&e.assign((0,J._)`${t}.props`,r),n instanceof J.Name&&e.assign((0,J._)`${t}.items`,n)}function Xc(e,t,r,n){const{gen:s,schema:o,data:a,allErrors:i,opts:c,self:l}=e,{RULES:d}=l;if(o.$ref&&(c.ignoreKeywordsWithRef||!(0,kt.schemaHasRulesButRef)(o,d))){s.block(()=>xd(e,"$ref",d.all.$ref.definition));return}c.jtd||Cw(e,t),s.block(()=>{for(const y of d.rules)h(y);h(d.post)});function h(y){(0,Ba.shouldUseGroup)(o,y)&&(y.type?(s.if((0,ps.checkDataType)(y.type,a,c.strictNumbers)),el(e,y),t.length===1&&t[0]===y.type&&r&&(s.else(),(0,ps.reportTypeError)(e)),s.endIf()):el(e,y),i||s.if((0,J._)`${ee.default.errors} === ${n||0}`))}}function el(e,t){const{gen:r,schema:n,opts:{useDefaults:s}}=e;s&&(0,pw.assignDefaults)(e,t.type),r.block(()=>{for(const o of t.rules)(0,Ba.shouldUseRule)(n,o)&&xd(e,o.keyword,o.definition,t.type)})}function Cw(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(Nw(e,t),e.opts.allowUnionTypes||Iw(e,t),jw(e,e.dataTypes))}function Nw(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{zd(e.dataTypes,r)||Ja(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),Aw(e,t)}}function Iw(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Ja(e,"use allowUnionTypes to allow union type keyword")}function jw(e,t){const r=e.self.RULES.all;for(const n in r){const s=r[n];if(typeof s=="object"&&(0,Ba.shouldUseRule)(e.schema,s)){const{type:o}=s.definition;o.length&&!o.some(a=>Ow(t,a))&&Ja(e,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function Ow(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function zd(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function Aw(e,t){const r=[];for(const n of e.dataTypes)zd(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function Ja(e,t){const r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,kt.checkStrictMode)(e,t,e.opts.strictTypes)}let Md=class{constructor(t,r,n){if((0,sn.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,kt.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",qd(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,sn.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",ee.default.errors))}result(t,r,n){this.failResult((0,J.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,J.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,J._)`${r} !== undefined && (${(0,J.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?Br.reportExtraError:Br.reportError)(this,this.def.error,r)}$dataError(){(0,Br.reportError)(this,this.def.$dataError||Br.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Br.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=J.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=J.nil,r=J.nil){if(!this.$data)return;const{gen:n,schemaCode:s,schemaType:o,def:a}=this;n.if((0,J.or)((0,J._)`${s} === undefined`,r)),t!==J.nil&&n.assign(t,!0),(o.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==J.nil&&n.assign(t,!1)),n.else()}invalid$data(){const{gen:t,schemaCode:r,schemaType:n,def:s,it:o}=this;return(0,J.or)(a(),i());function a(){if(n.length){if(!(r instanceof J.Name))throw new Error("ajv implementation error");const c=Array.isArray(n)?n:[n];return(0,J._)`${(0,ps.checkDataTypes)(c,r,o.opts.strictNumbers,ps.DataType.Wrong)}`}return J.nil}function i(){if(s.validateSchema){const c=t.scopeValue("validate$data",{ref:s.validateSchema});return(0,J._)`!${c}(${r})`}return J.nil}}subschema(t,r){const n=(0,eo.getSubschema)(this.it,t);(0,eo.extendSubschemaData)(n,this.it,t),(0,eo.extendSubschemaMode)(n,t);const s={...this.it,...n,items:void 0,props:void 0};return ww(s,r),s}mergeEvaluated(t,r){const{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=kt.mergeEvaluated.props(s,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=kt.mergeEvaluated.items(s,t.items,n.items,r)))}mergeValidEvaluated(t,r){const{it:n,gen:s}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return s.if(r,()=>this.mergeEvaluated(t,J.Name)),!0}};mt.KeywordCxt=Md;function xd(e,t,r,n){const s=new Md(e,r,t);"code"in r?r.code(s,n):s.$data&&r.validate?(0,sn.funcKeywordCode)(s,r):"macro"in r?(0,sn.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,sn.funcKeywordCode)(s,r)}const zw=/^\/(?:[^~]|~0|~1)*$/,Mw=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function qd(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,o;if(e==="")return ee.default.rootData;if(e[0]==="/"){if(!zw.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,o=ee.default.rootData}else{const l=Mw.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,J._)`${o}${(0,J.getProperty)((0,kt.unescapeJsonPointer)(l))}`,a=(0,J._)`${a} && ${o}`);return a;function c(l,d){return`Cannot access ${l} ${d} levels up, current level is ${t}`}}mt.getData=qd;var jn={};Object.defineProperty(jn,"__esModule",{value:!0});let xw=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};jn.default=xw;var Ur={};Object.defineProperty(Ur,"__esModule",{value:!0});const to=Ue;let qw=class extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,to.resolveUrl)(t,r,n),this.missingSchema=(0,to.normalizeId)((0,to.getFullPath)(t,this.missingRef))}};Ur.default=qw;var Qe={};Object.defineProperty(Qe,"__esModule",{value:!0});Qe.resolveSchema=Qe.getCompilingSchema=Qe.resolveRef=Qe.compileSchema=Qe.SchemaEnv=void 0;const lt=fe,Dw=jn,er=bt,ht=Ue,tl=F,Uw=mt;let Us=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,ht.normalizeId)(n==null?void 0:n[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n==null?void 0:n.$async,this.refs={}}};Qe.SchemaEnv=Us;function Qa(e){const t=Dd.call(this,e);if(t)return t;const r=(0,ht.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,a=new lt.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o});let i;e.$async&&(i=a.scopeValue("Error",{ref:Dw.default,code:(0,lt._)`require("ajv/dist/runtime/validation_error").default`}));const c=a.scopeName("validate");e.validateName=c;const l={gen:a,allErrors:this.opts.allErrors,data:er.default.data,parentData:er.default.parentData,parentDataProperty:er.default.parentDataProperty,dataNames:[er.default.data],dataPathArr:[lt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,lt.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:lt.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,lt._)`""`,opts:this.opts,self:this};let d;try{this._compilations.add(e),(0,Uw.validateFunctionCode)(l),a.optimize(this.opts.code.optimize);const h=a.toString();d=`${a.scopeRefs(er.default.scope)}return ${h}`,this.opts.code.process&&(d=this.opts.code.process(d,e));const g=new Function(`${er.default.self}`,`${er.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:h,scopeValues:a._values}),this.opts.unevaluated){const{props:_,items:$}=l;g.evaluated={props:_ instanceof lt.Name?void 0:_,items:$ instanceof lt.Name?void 0:$,dynamicProps:_ instanceof lt.Name,dynamicItems:$ instanceof lt.Name},g.source&&(g.source.evaluated=(0,lt.stringify)(g.evaluated))}return e.validate=g,e}catch(h){throw delete e.validate,delete e.validateName,d&&this.logger.error("Error compiling schema, function code:",d),h}finally{this._compilations.delete(e)}}Qe.compileSchema=Qa;function Vw(e,t,r){var n;r=(0,ht.resolveUrl)(this.opts.uriResolver,t,r);const s=e.refs[r];if(s)return s;let o=Hw.call(this,e,r);if(o===void 0){const a=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:i}=this.opts;a&&(o=new Us({schema:a,schemaId:i,root:e,baseId:t}))}if(o!==void 0)return e.refs[r]=Lw.call(this,o)}Qe.resolveRef=Vw;function Lw(e){return(0,ht.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Qa.call(this,e)}function Dd(e){for(const t of this._compilations)if(Fw(t,e))return t}Qe.getCompilingSchema=Dd;function Fw(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function Hw(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Vs.call(this,e,t)}function Vs(e,t){const r=this.opts.uriResolver.parse(t),n=(0,ht._getFullPath)(this.opts.uriResolver,r);let s=(0,ht.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===s)return ro.call(this,r,e);const o=(0,ht.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){const i=Vs.call(this,e,a);return typeof(i==null?void 0:i.schema)!="object"?void 0:ro.call(this,r,i)}if(typeof(a==null?void 0:a.schema)=="object"){if(a.validate||Qa.call(this,a),o===(0,ht.normalizeId)(t)){const{schema:i}=a,{schemaId:c}=this.opts,l=i[c];return l&&(s=(0,ht.resolveUrl)(this.opts.uriResolver,s,l)),new Us({schema:i,schemaId:c,root:e,baseId:s})}return ro.call(this,r,a)}}Qe.resolveSchema=Vs;const Zw=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function ro(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,tl.unescapeFragment)(i)];if(c===void 0)return;r=c;const l=typeof r=="object"&&r[this.opts.schemaId];!Zw.has(i)&&l&&(t=(0,ht.resolveUrl)(this.opts.uriResolver,t,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,tl.schemaHasRulesButRef)(r,this.RULES)){const i=(0,ht.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=Vs.call(this,n,i)}const{schemaId:a}=this.opts;if(o=o||new Us({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}const Kw="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",Gw="Meta-schema for $data reference (JSON AnySchema extension proposal)",Ww="object",Bw=["$data"],Jw={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},Qw=!1,Yw={$id:Kw,description:Gw,type:Ww,required:Bw,properties:Jw,additionalProperties:Qw};var Ya={},Ls={exports:{}};const Xw=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Ud=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),Xa=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),Vd=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),e0=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function Ld(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 t0=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function rl(e){return e.length=0,!0}function r0(e,t,r){if(e.length){const n=Ld(e);if(n!=="")t.push(n);else return r.error=!0,!1;e.length=0}return!0}function n0(e){let t=0;const r={error:!1,address:"",zone:""},n=[],s=[];let o=!1,a=!1,i=r0;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=rl}else{s.push(l);continue}}return s.length&&(i===rl?r.zone=s.join(""):a?n.push(s.join("")):n.push(Ld(s))),r.address=n.join(""),r}function Fd(e){if(s0(e,":")<2)return{host:e,isIPV6:!1};const t=n0(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 s0(e,t){let r=0;for(let n=0;na0[n])}function l0(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n65535))return"URI port is malformed."}function _s(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(D0);a!==null&&a[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",s=!0);const i=e.match(U0);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(q0);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=V0(n,c);if(l!==void 0&&(n.error=n.error||l,s=!0),n.host)if(j0(n.host)===!1){const y=P0(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=Jd(r.scheme||n.scheme);if(!r.unicodeSupport&&(!d||!d.unicodeSupport)&&n.host&&(r.domainHost||d&&d.domainHost)&&o===!1&&O0(n.host))try{n.host=new URL("http://"+n.host).hostname}catch(h){n.error=n.error||"Host's domain name can not be converted to ASCII: "+h}if((!d||d&&!d.skipNormalize)&&(e.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=I0(unescape(n.host),o))),n.path&&(n.path=C0(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 gs(e,t){return _s(e,t).parsed}function L0(e,t){return Yd(e,t).normalized}function Yd(e,t){const{parsed:r,malformedAuthorityOrPort:n}=_s(e,t);return{normalized:n?e:hr(r,t),malformedAuthorityOrPort:n}}function nl(e,t){if(typeof e=="string"){const{normalized:r,malformedAuthorityOrPort:n}=Yd(e,t);return n?void 0:r}if(typeof e=="object")return hr(e,t)}const ti={SCHEMES:A0,normalize:z0,resolve:M0,resolveComponent:Qd,equal:x0,serialize:hr,parse:gs};Ls.exports=ti;Ls.exports.default=ti;Ls.exports.fastUri=ti;var Xd=Ls.exports;Object.defineProperty(Ya,"__esModule",{value:!0});const ef=Xd;ef.code='require("ajv/dist/runtime/uri").default';Ya.default=ef;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=mt;Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=fe;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});const n=jn,s=Ur,o=fr,a=Qe,i=fe,c=Ue,l=Oe,d=F,h=Yw,y=Ya,g=(j,w)=>new RegExp(j,w);g.code="new RegExp";const _=["removeAdditional","useDefaults","coerceTypes"],$=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),m={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},f={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},v=200;function S(j){var w,C,b,u,p,E,M,x,B,K,he,et,Dt,Ut,Vt,Lt,Ft,Ht,Zt,Kt,Gt,Wt,Bt,Jt,Qt;const ct=j.strict,Yt=(w=j.code)===null||w===void 0?void 0:w.optimize,Kr=Yt===!0||Yt===void 0?1:Yt||0,Gr=(b=(C=j.code)===null||C===void 0?void 0:C.regExp)!==null&&b!==void 0?b:g,Js=(u=j.uriResolver)!==null&&u!==void 0?u:y.default;return{strictSchema:(E=(p=j.strictSchema)!==null&&p!==void 0?p:ct)!==null&&E!==void 0?E:!0,strictNumbers:(x=(M=j.strictNumbers)!==null&&M!==void 0?M:ct)!==null&&x!==void 0?x:!0,strictTypes:(K=(B=j.strictTypes)!==null&&B!==void 0?B:ct)!==null&&K!==void 0?K:"log",strictTuples:(et=(he=j.strictTuples)!==null&&he!==void 0?he:ct)!==null&&et!==void 0?et:"log",strictRequired:(Ut=(Dt=j.strictRequired)!==null&&Dt!==void 0?Dt:ct)!==null&&Ut!==void 0?Ut:!1,code:j.code?{...j.code,optimize:Kr,regExp:Gr}:{optimize:Kr,regExp:Gr},loopRequired:(Vt=j.loopRequired)!==null&&Vt!==void 0?Vt:v,loopEnum:(Lt=j.loopEnum)!==null&&Lt!==void 0?Lt:v,meta:(Ft=j.meta)!==null&&Ft!==void 0?Ft:!0,messages:(Ht=j.messages)!==null&&Ht!==void 0?Ht:!0,inlineRefs:(Zt=j.inlineRefs)!==null&&Zt!==void 0?Zt:!0,schemaId:(Kt=j.schemaId)!==null&&Kt!==void 0?Kt:"$id",addUsedSchema:(Gt=j.addUsedSchema)!==null&&Gt!==void 0?Gt:!0,validateSchema:(Wt=j.validateSchema)!==null&&Wt!==void 0?Wt:!0,validateFormats:(Bt=j.validateFormats)!==null&&Bt!==void 0?Bt:!0,unicodeRegExp:(Jt=j.unicodeRegExp)!==null&&Jt!==void 0?Jt:!0,int32range:(Qt=j.int32range)!==null&&Qt!==void 0?Qt:!0,uriResolver:Js}}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:$,es5:C,lines:b}),this.logger=W(w.logger);const u=w.validateFormats;w.validateFormats=!1,this.RULES=(0,o.getRules)(),P.call(this,m,w,"NOT SUPPORTED"),P.call(this,f,w,"DEPRECATED","warn"),this._metaOpts=V.call(this),w.formats&&U.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),w.keywords&&Z.call(this,w.keywords),typeof w.meta=="object"&&this.addMetaSchema(w.meta),A.call(this),w.validateFormats=u}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:w,meta:C,schemaId:b}=this.opts;let u=h;b==="id"&&(u={...h},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(K,he){await p.call(this,K.$schema);const et=this._addSchema(K,he);return et.validate||E.call(this,et)}async function p(K){K&&!this.getSchema(K)&&await u.call(this,{$ref:K},!0)}async function E(K){try{return this._compileSchemaEnv(K)}catch(he){if(!(he instanceof s.default))throw he;return M.call(this,he),await x.call(this,he.missingSchema),E.call(this,K)}}function M({missingSchema:K,missingRef:he}){if(this.refs[K])throw new Error(`AnySchema ${K} is loaded but ${he} cannot be resolved`)}async function x(K){const he=await B.call(this,K);this.refs[K]||await p.call(this,he.$schema),this.refs[K]||this.addSchema(he,K,C)}async function B(K){const he=this._loading[K];if(he)return he;try{return await(this._loading[K]=b(K))}finally{delete this._loading[K]}}}addSchema(w,C,b,u=this.opts.validateSchema){if(Array.isArray(w)){for(const E of w)this.addSchema(E,void 0,b,u);return this}let p;if(typeof w=="object"){const{schemaId:E}=this.opts;if(p=w[E],p!==void 0&&typeof p!="string")throw new Error(`schema ${E} must be string`)}return C=(0,c.normalizeId)(C||p),this._checkUnique(C),this.schemas[C]=this._addSchema(w,b,C,u,!0),this}addMetaSchema(w,C,b=this.opts.validateSchema){return this.addSchema(w,C,!0,b),this}validateSchema(w,C){if(typeof w=="boolean")return!0;let b;if(b=w.$schema,b!==void 0&&typeof b!="string")throw new Error("$schema must be a string");if(b=b||this.opts.defaultMeta||this.defaultMeta(),!b)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const u=this.validate(b,w);if(!u&&C){const p="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(p);else throw new Error(p)}return u}getSchema(w){let C;for(;typeof(C=I.call(this,w))=="string";)w=C;if(C===void 0){const{schemaId:b}=this.opts,u=new a.SchemaEnv({schema:{},schemaId:b});if(C=a.resolveSchema.call(this,u,w),!C)return;this.refs[w]=C}return C.validate||this._compileSchemaEnv(C)}removeSchema(w){if(w instanceof RegExp)return this._removeAllSchemas(this.schemas,w),this._removeAllSchemas(this.refs,w),this;switch(typeof w){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const C=I.call(this,w);return typeof C=="object"&&this._cache.delete(C.schema),delete this.schemas[w],delete this.refs[w],this}case"object":{const C=w;this._cache.delete(C);let b=w[this.opts.schemaId];return b&&(b=(0,c.normalizeId)(b),delete this.schemas[b],delete this.refs[b]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(w){for(const C of w)this.addKeyword(C);return this}addKeyword(w,C){let b;if(typeof w=="string")b=w,typeof C=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),C.keyword=b);else if(typeof w=="object"&&C===void 0){if(C=w,b=C.keyword,Array.isArray(b)&&!b.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(q.call(this,b,C),!C)return(0,d.eachItem)(b,p=>le.call(this,p)),this;ge.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=>le.call(this,p,u):p=>u.type.forEach(E=>le.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 M of p)E=E[M];for(const M in b){const x=b[M];if(typeof x!="object")continue;const{$data:B}=x.definition,K=E[M];B&&K&&(E[M]=je(K))}}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:M}=this.opts;if(typeof w=="object")E=w[M];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof w!="boolean")throw new Error("schema must be object or boolean")}let x=this._cache.get(w);if(x!==void 0)return x;b=(0,c.normalizeId)(E||b);const B=c.getSchemaRefs.call(this,w,b);return x=new a.SchemaEnv({schema:w,schemaId:M,meta:C,baseId:b,localRefs:B}),this._cache.set(x.schema,x),p&&!b.startsWith("#")&&(b&&this._checkUnique(b),this.refs[b]=x),u&&this.validateSchema(w,!0),x}_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 P(j,w,C,b="error"){for(const u in j){const p=u;p in w&&this.logger[b](`${C}: option ${u}. ${j[p]}`)}}function I(j){return j=(0,c.normalizeId)(j),this.schemas[j]||this.refs[j]}function A(){const j=this.opts.schemas;if(j)if(Array.isArray(j))this.addSchema(j);else for(const w in j)this.addSchema(j[w],w)}function U(){for(const j in this.opts.formats){const w=this.opts.formats[j];w&&this.addFormat(j,w)}}function Z(j){if(Array.isArray(j)){this.addVocabulary(j);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const w in j){const C=j[w];C.keyword||(C.keyword=w),this.addKeyword(C)}}function V(){const j={...this.opts};for(const w of _)delete j[w];return j}const L={log(){},warn(){},error(){}};function W(j){if(j===!1)return L;if(j===void 0)return console;if(j.log&&j.warn&&j.error)return j;throw new Error("logger must implement log, warn and error methods")}const ce=/^[a-z_$][a-z0-9_$:-]*$/i;function q(j,w){const{RULES:C}=this;if((0,d.eachItem)(j,b=>{if(C.keywords[b])throw new Error(`Keyword ${b} is already defined`);if(!ce.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 le(j,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:x})=>x===C);if(E||(E={type:C,rules:[]},p.rules.push(E)),p.keywords[j]=!0,!w)return;const M={keyword:j,definition:{...w,type:(0,l.getJSONTypes)(w.type),schemaType:(0,l.getJSONTypes)(w.schemaType)}};w.before?Ce.call(this,E,M,w.before):E.rules.push(M),p.all[j]=M,(b=w.implements)===null||b===void 0||b.forEach(x=>this.addKeyword(x))}function Ce(j,w,C){const b=j.rules.findIndex(u=>u.keyword===C);b>=0?j.rules.splice(b,0,w):(j.rules.push(w),this.logger.warn(`rule ${C} is not defined`))}function ge(j){let{metaSchema:w}=j;w!==void 0&&(j.$data&&this.opts.$data&&(w=je(w)),j.validateSchema=this.compile(w,!0))}const it={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function je(j){return{anyOf:[j,it]}}})(cd);var ri={},ni={},si={};Object.defineProperty(si,"__esModule",{value:!0});const F0={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};si.default=F0;var pr={};Object.defineProperty(pr,"__esModule",{value:!0});pr.callRef=pr.getValidate=void 0;const H0=Ur,sl=ue,Be=fe,vr=bt,ol=Qe,Vn=F,Z0={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:r,it:n}=e,{baseId:s,schemaEnv:o,validateName:a,opts:i,self:c}=n,{root:l}=o;if((r==="#"||r==="#/")&&s===l.baseId)return h();const d=ol.resolveRef.call(c,l,s,r);if(d===void 0)throw new H0.default(n.opts.uriResolver,s,r);if(d instanceof ol.SchemaEnv)return y(d);return g(d);function h(){if(o===l)return ts(e,a,o,o.$async);const _=t.scopeValue("root",{ref:l});return ts(e,(0,Be._)`${_}.validate`,l,l.$async)}function y(_){const $=tf(e,_);ts(e,$,_,_.$async)}function g(_){const $=t.scopeValue("schema",i.code.source===!0?{ref:_,code:(0,Be.stringify)(_)}:{ref:_}),m=t.name("valid"),f=e.subschema({schema:_,dataTypes:[],schemaPath:Be.nil,topSchemaRef:$,errSchemaPath:r},m);e.mergeEvaluated(f),e.ok(m)}}};function tf(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Be._)`${r.scopeValue("wrapper",{ref:t})}.validate`}pr.getValidate=tf;function ts(e,t,r,n){const{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:c}=o,l=c.passContext?vr.default.this:Be.nil;n?d():h();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");const _=s.let("valid");s.try(()=>{s.code((0,Be._)`await ${(0,sl.callValidateCode)(e,t,l)}`),g(t),a||s.assign(_,!0)},$=>{s.if((0,Be._)`!(${$} instanceof ${o.ValidationError})`,()=>s.throw($)),y($),a||s.assign(_,!1)}),e.ok(_)}function h(){e.result((0,sl.callValidateCode)(e,t,l),()=>g(t),()=>y(t))}function y(_){const $=(0,Be._)`${_}.errors`;s.assign(vr.default.vErrors,(0,Be._)`${vr.default.vErrors} === null ? ${$} : ${vr.default.vErrors}.concat(${$})`),s.assign(vr.default.errors,(0,Be._)`${vr.default.vErrors}.length`)}function g(_){var $;if(!o.opts.unevaluated)return;const m=($=r==null?void 0:r.validate)===null||$===void 0?void 0:$.evaluated;if(o.props!==!0)if(m&&!m.dynamicProps)m.props!==void 0&&(o.props=Vn.mergeEvaluated.props(s,m.props,o.props));else{const f=s.var("props",(0,Be._)`${_}.evaluated.props`);o.props=Vn.mergeEvaluated.props(s,f,o.props,Be.Name)}if(o.items!==!0)if(m&&!m.dynamicItems)m.items!==void 0&&(o.items=Vn.mergeEvaluated.items(s,m.items,o.items));else{const f=s.var("items",(0,Be._)`${_}.evaluated.items`);o.items=Vn.mergeEvaluated.items(s,f,o.items,Be.Name)}}}pr.callRef=ts;pr.default=Z0;Object.defineProperty(ni,"__esModule",{value:!0});const K0=si,G0=pr,W0=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",K0.default,G0.default];ni.default=W0;var oi={},ai={};Object.defineProperty(ai,"__esModule",{value:!0});const ys=fe,Ct=ys.operators,vs={maximum:{okStr:"<=",ok:Ct.LTE,fail:Ct.GT},minimum:{okStr:">=",ok:Ct.GTE,fail:Ct.LT},exclusiveMaximum:{okStr:"<",ok:Ct.LT,fail:Ct.GTE},exclusiveMinimum:{okStr:">",ok:Ct.GT,fail:Ct.LTE}},B0={message:({keyword:e,schemaCode:t})=>(0,ys.str)`must be ${vs[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,ys._)`{comparison: ${vs[e].okStr}, limit: ${t}}`},J0={keyword:Object.keys(vs),type:"number",schemaType:"number",$data:!0,error:B0,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,ys._)`${r} ${vs[t].fail} ${n} || isNaN(${r})`)}};ai.default=J0;var ii={};Object.defineProperty(ii,"__esModule",{value:!0});const on=fe,Q0={message:({schemaCode:e})=>(0,on.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,on._)`{multipleOf: ${e}}`},Y0={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:Q0,code(e){const{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0,on._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0,on._)`${a} !== parseInt(${a})`;e.fail$data((0,on._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};ii.default=Y0;var ci={},li={};Object.defineProperty(li,"__esModule",{value:!0});function rf(e){const t=e.length;let r=0,n=0,s;for(;n=55296&&s<=56319&&n(0,or._)`{limit: ${e}}`},rb={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:tb,code(e){const{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?or.operators.GT:or.operators.LT,a=s.opts.unicode===!1?(0,or._)`${r}.length`:(0,or._)`${(0,X0.useFunc)(e.gen,eb.default)}(${r})`;e.fail$data((0,or._)`${a} ${o} ${n}`)}};ci.default=rb;var ui={};Object.defineProperty(ui,"__esModule",{value:!0});const nb=ue,sb=F,Tr=fe,ob={message:({schemaCode:e})=>(0,Tr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Tr._)`{pattern: ${e}}`},ab={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:ob,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,Tr._)`new RegExp`:(0,sb.useFunc)(t,c),d=t.let("valid");t.try(()=>t.assign(d,(0,Tr._)`${l}(${o}, ${i}).test(${r})`),()=>t.assign(d,!1)),e.fail$data((0,Tr._)`!${d}`)}else{const c=(0,nb.usePattern)(e,s);e.fail$data((0,Tr._)`!${c}.test(${r})`)}}};ui.default=ab;var di={};Object.defineProperty(di,"__esModule",{value:!0});const an=fe,ib={message({keyword:e,schemaCode:t}){const r=e==="maxProperties"?"more":"fewer";return(0,an.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,an._)`{limit: ${e}}`},cb={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:ib,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?an.operators.GT:an.operators.LT;e.fail$data((0,an._)`Object.keys(${r}).length ${s} ${n}`)}};di.default=cb;var fi={};Object.defineProperty(fi,"__esModule",{value:!0});const Jr=ue,cn=fe,lb=F,ub={message:({params:{missingProperty:e}})=>(0,cn.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,cn._)`{missingProperty: ${e}}`},db={keyword:"required",type:"object",schemaType:"array",$data:!0,error:ub,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:_}=e.it;for(const $ of r)if((g==null?void 0:g[$])===void 0&&!_.has($)){const m=a.schemaEnv.baseId+a.errSchemaPath,f=`required property "${$}" is not defined at "${m}" (strictRequired)`;(0,lb.checkStrictMode)(a,f,a.opts.strictRequired)}}function l(){if(c||o)e.block$data(cn.nil,h);else for(const g of r)(0,Jr.checkReportMissingProp)(e,g)}function d(){const g=t.let("missing");if(c||o){const _=t.let("valid",!0);e.block$data(_,()=>y(g,_)),e.ok(_)}else t.if((0,Jr.checkMissingProp)(e,r,g)),(0,Jr.reportMissingProp)(e,g),t.else()}function h(){t.forOf("prop",n,g=>{e.setParams({missingProperty:g}),t.if((0,Jr.noPropertyInData)(t,s,g,i.ownProperties),()=>e.error())})}function y(g,_){e.setParams({missingProperty:g}),t.forOf(g,n,()=>{t.assign(_,(0,Jr.propertyInData)(t,s,g,i.ownProperties)),t.if((0,cn.not)(_),()=>{e.error(),t.break()})},cn.nil)}}};fi.default=db;var hi={};Object.defineProperty(hi,"__esModule",{value:!0});const ln=fe,fb={message({keyword:e,schemaCode:t}){const r=e==="maxItems"?"more":"fewer";return(0,ln.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,ln._)`{limit: ${e}}`},hb={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:fb,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?ln.operators.GT:ln.operators.LT;e.fail$data((0,ln._)`${r}.length ${s} ${n}`)}};hi.default=hb;var pi={},On={};Object.defineProperty(On,"__esModule",{value:!0});const nf=Ds;nf.code='require("ajv/dist/runtime/equal").default';On.default=nf;Object.defineProperty(pi,"__esModule",{value:!0});const no=Oe,xe=fe,pb=F,mb=On,_b={message:({params:{i:e,j:t}})=>(0,xe.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,xe._)`{i: ${e}, j: ${t}}`},gb={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:_b,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,no.getSchemaTypes)(o.items):[];e.block$data(c,d,(0,xe._)`${a} === false`),e.ok(c);function d(){const _=t.let("i",(0,xe._)`${r}.length`),$=t.let("j");e.setParams({i:_,j:$}),t.assign(c,!0),t.if((0,xe._)`${_} > 1`,()=>(h()?y:g)(_,$))}function h(){return l.length>0&&!l.some(_=>_==="object"||_==="array")}function y(_,$){const m=t.name("item"),f=(0,no.checkDataTypes)(l,m,i.opts.strictNumbers,no.DataType.Wrong),v=t.const("indices",(0,xe._)`{}`);t.for((0,xe._)`;${_}--;`,()=>{t.let(m,(0,xe._)`${r}[${_}]`),t.if(f,(0,xe._)`continue`),l.length>1&&t.if((0,xe._)`typeof ${m} == "string"`,(0,xe._)`${m} += "_"`),t.if((0,xe._)`typeof ${v}[${m}] == "number"`,()=>{t.assign($,(0,xe._)`${v}[${m}]`),e.error(),t.assign(c,!1).break()}).code((0,xe._)`${v}[${m}] = ${_}`)})}function g(_,$){const m=(0,pb.useFunc)(t,mb.default),f=t.name("outer");t.label(f).for((0,xe._)`;${_}--;`,()=>t.for((0,xe._)`${$} = ${_}; ${$}--;`,()=>t.if((0,xe._)`${m}(${r}[${_}], ${r}[${$}])`,()=>{e.error(),t.assign(c,!1).break(f)})))}}};pi.default=gb;var mi={};Object.defineProperty(mi,"__esModule",{value:!0});const Co=fe,yb=F,vb=On,$b={message:"must be equal to constant",params:({schemaCode:e})=>(0,Co._)`{allowedValue: ${e}}`},wb={keyword:"const",$data:!0,error:$b,code(e){const{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,Co._)`!${(0,yb.useFunc)(t,vb.default)}(${r}, ${s})`):e.fail((0,Co._)`${o} !== ${r}`)}};mi.default=wb;var _i={};Object.defineProperty(_i,"__esModule",{value:!0});const tn=fe,bb=F,Sb=On,Eb={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,tn._)`{allowedValues: ${e}}`},kb={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,bb.useFunc)(t,Sb.default));let d;if(i||n)d=t.let("valid"),e.block$data(d,h);else{if(!Array.isArray(s))throw new Error("ajv implementation error");const g=t.const("vSchema",o);d=(0,tn.or)(...s.map((_,$)=>y(g,$)))}e.pass(d);function h(){t.assign(d,!1),t.forOf("v",o,g=>t.if((0,tn._)`${l()}(${r}, ${g})`,()=>t.assign(d,!0).break()))}function y(g,_){const $=s[_];return typeof $=="object"&&$!==null?(0,tn._)`${l()}(${r}, ${g}[${_}])`:(0,tn._)`${r} === ${$}`}}};_i.default=kb;Object.defineProperty(oi,"__esModule",{value:!0});const Pb=ai,Tb=ii,Rb=ci,Cb=ui,Nb=di,Ib=fi,jb=hi,Ob=pi,Ab=mi,zb=_i,Mb=[Pb.default,Tb.default,Rb.default,Cb.default,Nb.default,Ib.default,jb.default,Ob.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},Ab.default,zb.default];oi.default=Mb;var gi={},Vr={};Object.defineProperty(Vr,"__esModule",{value:!0});Vr.validateAdditionalItems=void 0;const ar=fe,No=F,xb={message:({params:{len:e}})=>(0,ar.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,ar._)`{limit: ${e}}`},qb={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:xb,code(e){const{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,No.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}sf(e,n)}};function sf(e,t){const{gen:r,schema:n,data:s,keyword:o,it:a}=e;a.items=!0;const i=r.const("len",(0,ar._)`${s}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,ar._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0,No.alwaysValidSchema)(a,n)){const l=r.var("valid",(0,ar._)`${i} <= ${t.length}`);r.if((0,ar.not)(l),()=>c(l)),e.ok(l)}function c(l){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:No.Type.Num},l),a.allErrors||r.if((0,ar.not)(l),()=>r.break())})}}Vr.validateAdditionalItems=sf;Vr.default=qb;var yi={},Lr={};Object.defineProperty(Lr,"__esModule",{value:!0});Lr.validateTuple=void 0;const al=fe,rs=F,Db=ue,Ub={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return of(e,"additionalItems",t);r.items=!0,!(0,rs.alwaysValidSchema)(r,t)&&e.ok((0,Db.validateArray)(e))}};function of(e,t,r=e.schema){const{gen:n,parentSchema:s,data:o,keyword:a,it:i}=e;d(s),i.opts.unevaluated&&r.length&&i.items!==!0&&(i.items=rs.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),l=n.const("len",(0,al._)`${o}.length`);r.forEach((h,y)=>{(0,rs.alwaysValidSchema)(i,h)||(n.if((0,al._)`${l} > ${y}`,()=>e.subschema({keyword:a,schemaProp:y,dataProp:y},c)),e.ok(c))});function d(h){const{opts:y,errSchemaPath:g}=i,_=r.length,$=_===h.minItems&&(_===h.maxItems||h[t]===!1);if(y.strictTuples&&!$){const m=`"${a}" is ${_}-tuple, but minItems or maxItems/${t} are not specified or different at path "${g}"`;(0,rs.checkStrictMode)(i,m,y.strictTuples)}}}Lr.validateTuple=of;Lr.default=Ub;Object.defineProperty(yi,"__esModule",{value:!0});const Vb=Lr,Lb={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,Vb.validateTuple)(e,"items")};yi.default=Lb;var vi={};Object.defineProperty(vi,"__esModule",{value:!0});const il=fe,Fb=F,Hb=ue,Zb=Vr,Kb={message:({params:{len:e}})=>(0,il.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,il._)`{limit: ${e}}`},Gb={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:Kb,code(e){const{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=!0,!(0,Fb.alwaysValidSchema)(n,t)&&(s?(0,Zb.validateAdditionalItems)(e,s):e.ok((0,Hb.validateArray)(e)))}};vi.default=Gb;var $i={};Object.defineProperty($i,"__esModule",{value:!0});const nt=fe,Ln=F,Wb={message:({params:{min:e,max:t}})=>t===void 0?(0,nt.str)`must contain at least ${e} valid item(s)`:(0,nt.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,nt._)`{minContains: ${e}}`:(0,nt._)`{minContains: ${e}, maxContains: ${t}}`},Bb={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:Wb,code(e){const{gen:t,schema:r,parentSchema:n,data:s,it:o}=e;let a,i;const{minContains:c,maxContains:l}=n;o.opts.next?(a=c===void 0?1:c,i=l):a=1;const d=t.const("len",(0,nt._)`${s}.length`);if(e.setParams({min:a,max:i}),i===void 0&&a===0){(0,Ln.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0,Ln.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Ln.alwaysValidSchema)(o,r)){let $=(0,nt._)`${d} >= ${a}`;i!==void 0&&($=(0,nt._)`${$} && ${d} <= ${i}`),e.pass($);return}o.items=!0;const h=t.name("valid");i===void 0&&a===1?g(h,()=>t.if(h,()=>t.break())):a===0?(t.let(h,!0),i!==void 0&&t.if((0,nt._)`${s}.length > 0`,y)):(t.let(h,!1),y()),e.result(h,()=>e.reset());function y(){const $=t.name("_valid"),m=t.let("count",0);g($,()=>t.if($,()=>_(m)))}function g($,m){t.forRange("i",0,d,f=>{e.subschema({keyword:"contains",dataProp:f,dataPropType:Ln.Type.Num,compositeRule:!0},$),m()})}function _($){t.code((0,nt._)`${$}++`),i===void 0?t.if((0,nt._)`${$} >= ${a}`,()=>t.assign(h,!0).break()):(t.if((0,nt._)`${$} > ${i}`,()=>t.assign(h,!1).break()),a===1?t.assign(h,!0):t.if((0,nt._)`${$} >= ${a}`,()=>t.assign(h,!0)))}}};$i.default=Bb;var af={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=fe,r=F,n=ue;e.error={message:({params:{property:c,depsCount:l,deps:d}})=>{const h=l===1?"property":"properties";return(0,t.str)`must have ${h} ${d} when property ${c} is present`},params:({params:{property:c,depsCount:l,deps:d,missingProperty:h}})=>(0,t._)`{property: ${c}, + missingProperty: ${h}, + depsCount: ${l}, + deps: ${d}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(c){const[l,d]=o(c);a(c,l),i(c,d)}};function o({schema:c}){const l={},d={};for(const h in c){if(h==="__proto__")continue;const y=Array.isArray(c[h])?l:d;y[h]=c[h]}return[l,d]}function a(c,l=c.schema){const{gen:d,data:h,it:y}=c;if(Object.keys(l).length===0)return;const g=d.let("missing");for(const _ in l){const $=l[_];if($.length===0)continue;const m=(0,n.propertyInData)(d,h,_,y.opts.ownProperties);c.setParams({property:_,depsCount:$.length,deps:$.join(", ")}),y.allErrors?d.if(m,()=>{for(const f of $)(0,n.checkReportMissingProp)(c,f)}):(d.if((0,t._)`${m} && (${(0,n.checkMissingProp)(c,$,g)})`),(0,n.reportMissingProp)(c,g),d.else())}}e.validatePropertyDeps=a;function i(c,l=c.schema){const{gen:d,data:h,keyword:y,it:g}=c,_=d.name("valid");for(const $ in l)(0,r.alwaysValidSchema)(g,l[$])||(d.if((0,n.propertyInData)(d,h,$,g.opts.ownProperties),()=>{const m=c.subschema({keyword:y,schemaProp:$},_);c.mergeValidEvaluated(m,_)},()=>d.var(_,!0)),c.ok(_))}e.validateSchemaDeps=i,e.default=s})(af);var wi={};Object.defineProperty(wi,"__esModule",{value:!0});const cf=fe,Jb=F,Qb={message:"property name must be valid",params:({params:e})=>(0,cf._)`{propertyName: ${e.propertyName}}`},Yb={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Qb,code(e){const{gen:t,schema:r,data:n,it:s}=e;if((0,Jb.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,cf.not)(o),()=>{e.error(!0),s.allErrors||t.break()})}),e.ok(o)}};wi.default=Yb;var Fs={};Object.defineProperty(Fs,"__esModule",{value:!0});const Fn=ue,dt=fe,Xb=bt,Hn=F,eS={message:"must NOT have additional properties",params:({params:e})=>(0,dt._)`{additionalProperty: ${e.additionalProperty}}`},tS={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:eS,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,Hn.alwaysValidSchema)(a,r))return;const l=(0,Fn.allSchemaProperties)(n.properties),d=(0,Fn.allSchemaProperties)(n.patternProperties);h(),e.ok((0,dt._)`${o} === ${Xb.default.errors}`);function h(){t.forIn("key",s,m=>{!l.length&&!d.length?_(m):t.if(y(m),()=>_(m))})}function y(m){let f;if(l.length>8){const v=(0,Hn.schemaRefOrVal)(a,n.properties,"properties");f=(0,Fn.isOwnProperty)(t,v,m)}else l.length?f=(0,dt.or)(...l.map(v=>(0,dt._)`${m} === ${v}`)):f=dt.nil;return d.length&&(f=(0,dt.or)(f,...d.map(v=>(0,dt._)`${(0,Fn.usePattern)(e,v)}.test(${m})`))),(0,dt.not)(f)}function g(m){t.code((0,dt._)`delete ${s}[${m}]`)}function _(m){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){g(m);return}if(r===!1){e.setParams({additionalProperty:m}),e.error(),i||t.break();return}if(typeof r=="object"&&!(0,Hn.alwaysValidSchema)(a,r)){const f=t.name("valid");c.removeAdditional==="failing"?($(m,f,!1),t.if((0,dt.not)(f),()=>{e.reset(),g(m)})):($(m,f),i||t.if((0,dt.not)(f),()=>t.break()))}}function $(m,f,v){const S={keyword:"additionalProperties",dataProp:m,dataPropType:Hn.Type.Str};v===!1&&Object.assign(S,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(S,f)}}};Fs.default=tS;var bi={};Object.defineProperty(bi,"__esModule",{value:!0});const rS=mt,cl=ue,so=F,ll=Fs,nS={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&&ll.default.code(new rS.KeywordCxt(o,ll.default,"additionalProperties"));const a=(0,cl.allSchemaProperties)(r);for(const h of a)o.definedProperties.add(h);o.opts.unevaluated&&a.length&&o.props!==!0&&(o.props=so.mergeEvaluated.props(t,(0,so.toHash)(a),o.props));const i=a.filter(h=>!(0,so.alwaysValidSchema)(o,r[h]));if(i.length===0)return;const c=t.name("valid");for(const h of i)l(h)?d(h):(t.if((0,cl.propertyInData)(t,s,h,o.opts.ownProperties)),d(h),o.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(h),e.ok(c);function l(h){return o.opts.useDefaults&&!o.compositeRule&&r[h].default!==void 0}function d(h){e.subschema({keyword:"properties",schemaProp:h,dataProp:h},c)}}};bi.default=nS;var Si={};Object.defineProperty(Si,"__esModule",{value:!0});const ul=ue,Zn=fe,dl=F,fl=F,sS={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,ul.allSchemaProperties)(r),c=i.filter($=>(0,dl.alwaysValidSchema)(o,r[$]));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 Zn.Name)&&(o.props=(0,fl.evaluatedPropsToName)(t,o.props));const{props:h}=o;y();function y(){for(const $ of i)l&&g($),o.allErrors?_($):(t.var(d,!0),_($),t.if(d))}function g($){for(const m in l)new RegExp($).test(m)&&(0,dl.checkStrictMode)(o,`property ${m} matches pattern ${$} (use allowMatchingProperties)`)}function _($){t.forIn("key",n,m=>{t.if((0,Zn._)`${(0,ul.usePattern)(e,$)}.test(${m})`,()=>{const f=c.includes($);f||e.subschema({keyword:"patternProperties",schemaProp:$,dataProp:m,dataPropType:fl.Type.Str},d),o.opts.unevaluated&&h!==!0?t.assign((0,Zn._)`${h}[${m}]`,!0):!f&&!o.allErrors&&t.if((0,Zn.not)(d),()=>t.break())})})}}};Si.default=sS;var Ei={};Object.defineProperty(Ei,"__esModule",{value:!0});const oS=F,aS={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,oS.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"}};Ei.default=aS;var ki={};Object.defineProperty(ki,"__esModule",{value:!0});const iS=ue,cS={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:iS.validateUnion,error:{message:"must match a schema in anyOf"}};ki.default=cS;var Pi={};Object.defineProperty(Pi,"__esModule",{value:!0});const ns=fe,lS=F,uS={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,ns._)`{passingSchemas: ${e.passing}}`},dS={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:uS,code(e){const{gen:t,schema:r,parentSchema:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;const o=r,a=t.let("valid",!1),i=t.let("passing",null),c=t.name("_valid");e.setParams({passing:i}),t.block(l),e.result(a,()=>e.reset(),()=>e.error(!0));function l(){o.forEach((d,h)=>{let y;(0,lS.alwaysValidSchema)(s,d)?t.var(c,!0):y=e.subschema({keyword:"oneOf",schemaProp:h,compositeRule:!0},c),h>0&&t.if((0,ns._)`${c} && ${a}`).assign(a,!1).assign(i,(0,ns._)`[${i}, ${h}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,h),y&&e.mergeEvaluated(y,ns.Name)})})}}};Pi.default=dS;var Ti={};Object.defineProperty(Ti,"__esModule",{value:!0});const fS=F,hS={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,fS.alwaysValidSchema)(n,o))return;const i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i)})}};Ti.default=hS;var Ri={};Object.defineProperty(Ri,"__esModule",{value:!0});const $s=fe,lf=F,pS={message:({params:e})=>(0,$s.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,$s._)`{failingKeyword: ${e.ifClause}}`},mS={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:pS,code(e){const{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,lf.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const s=hl(n,"then"),o=hl(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,$s.not)(i),l("else"));e.pass(a,()=>e.error(!0));function c(){const d=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},i);e.mergeEvaluated(d)}function l(d,h){return()=>{const y=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(y,a),h?t.assign(h,(0,$s._)`${d}`):e.setParams({ifClause:d})}}}};function hl(e,t){const r=e.schema[t];return r!==void 0&&!(0,lf.alwaysValidSchema)(e,r)}Ri.default=mS;var Ci={};Object.defineProperty(Ci,"__esModule",{value:!0});const _S=F,gS={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,_S.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Ci.default=gS;Object.defineProperty(gi,"__esModule",{value:!0});const yS=Vr,vS=yi,$S=Lr,wS=vi,bS=$i,SS=af,ES=wi,kS=Fs,PS=bi,TS=Si,RS=Ei,CS=ki,NS=Pi,IS=Ti,jS=Ri,OS=Ci;function AS(e=!1){const t=[RS.default,CS.default,NS.default,IS.default,jS.default,OS.default,ES.default,kS.default,SS.default,PS.default,TS.default];return e?t.push(vS.default,wS.default):t.push(yS.default,$S.default),t.push(bS.default),t}gi.default=AS;var Ni={},Ii={};Object.defineProperty(Ii,"__esModule",{value:!0});const Ne=fe,zS={message:({schemaCode:e})=>(0,Ne.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,Ne._)`{format: ${e}}`},MS={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:zS,code(e,t){const{gen:r,data:n,$data:s,schema:o,schemaCode:a,it:i}=e,{opts:c,errSchemaPath:l,schemaEnv:d,self:h}=i;if(!c.validateFormats)return;s?y():g();function y(){const _=r.scopeValue("formats",{ref:h.formats,code:c.code.formats}),$=r.const("fDef",(0,Ne._)`${_}[${a}]`),m=r.let("fType"),f=r.let("format");r.if((0,Ne._)`typeof ${$} == "object" && !(${$} instanceof RegExp)`,()=>r.assign(m,(0,Ne._)`${$}.type || "string"`).assign(f,(0,Ne._)`${$}.validate`),()=>r.assign(m,(0,Ne._)`"string"`).assign(f,$)),e.fail$data((0,Ne.or)(v(),S()));function v(){return c.strictSchema===!1?Ne.nil:(0,Ne._)`${a} && !${f}`}function S(){const R=d.$async?(0,Ne._)`(${$}.async ? await ${f}(${n}) : ${f}(${n}))`:(0,Ne._)`${f}(${n})`,P=(0,Ne._)`(typeof ${f} == "function" ? ${R} : ${f}.test(${n}))`;return(0,Ne._)`${f} && ${f} !== true && ${m} === ${t} && !${P}`}}function g(){const _=h.formats[o];if(!_){v();return}if(_===!0)return;const[$,m,f]=S(_);$===t&&e.pass(R());function v(){if(c.strictSchema===!1){h.logger.warn(P());return}throw new Error(P());function P(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function S(P){const I=P instanceof RegExp?(0,Ne.regexpCode)(P):c.code.formats?(0,Ne._)`${c.code.formats}${(0,Ne.getProperty)(o)}`:void 0,A=r.scopeValue("formats",{key:o,ref:P,code:I});return typeof P=="object"&&!(P instanceof RegExp)?[P.type||"string",P.validate,(0,Ne._)`${A}.validate`]:["string",P,A]}function R(){if(typeof _=="object"&&!(_ instanceof RegExp)&&_.async){if(!d.$async)throw new Error("async format in sync schema");return(0,Ne._)`await ${f}(${n})`}return typeof m=="function"?(0,Ne._)`${f}(${n})`:(0,Ne._)`${f}.test(${n})`}}}};Ii.default=MS;Object.defineProperty(Ni,"__esModule",{value:!0});const xS=Ii,qS=[xS.default];Ni.default=qS;var zr={};Object.defineProperty(zr,"__esModule",{value:!0});zr.contentVocabulary=zr.metadataVocabulary=void 0;zr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];zr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(ri,"__esModule",{value:!0});const DS=ni,US=oi,VS=gi,LS=Ni,pl=zr,FS=[DS.default,US.default,(0,VS.default)(),LS.default,pl.metadataVocabulary,pl.contentVocabulary];ri.default=FS;var ji={},Hs={};Object.defineProperty(Hs,"__esModule",{value:!0});Hs.DiscrError=void 0;var ml;(function(e){e.Tag="tag",e.Mapping="mapping"})(ml||(Hs.DiscrError=ml={}));Object.defineProperty(ji,"__esModule",{value:!0});const Er=fe,Io=Hs,_l=Qe,HS=Ur,ZS=F,KS={message:({params:{discrError:e,tagName:t}})=>e===Io.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Er._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},GS={keyword:"discriminator",type:"object",schemaType:"object",error:KS,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,Er._)`${r}${(0,Er.getProperty)(i)}`);t.if((0,Er._)`typeof ${l} == "string"`,()=>d(),()=>e.error(!1,{discrError:Io.DiscrError.Tag,tag:l,tagName:i})),e.ok(c);function d(){const g=y();t.if(!1);for(const _ in g)t.elseIf((0,Er._)`${l} === ${_}`),t.assign(c,h(g[_]));t.else(),e.error(!1,{discrError:Io.DiscrError.Mapping,tag:l,tagName:i}),t.endIf()}function h(g){const _=t.name("valid"),$=e.subschema({keyword:"oneOf",schemaProp:g},_);return e.mergeEvaluated($,Er.Name),_}function y(){var g;const _={},$=f(s);let m=!0;for(let R=0;Rthis.addVocabulary(_)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const _=this.opts.$data?this.$dataMetaSchema(o,a):o;this.addMetaSchema(_,i,!1),this.refs["http://json-schema.org/schema"]=i}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(i)?i:void 0)}}t.Ajv=c,e.exports=t=c,e.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var l=mt;Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var d=fe;Object.defineProperty(t,"_",{enumerable:!0,get:function(){return d._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return d.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return d.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return d.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return d.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return d.CodeGen}});var h=jn;Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return h.default}});var y=Ur;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return y.default}})})(Eo,Eo.exports);var tE=Eo.exports;const rE=Wl(tE);var jo={exports:{}},uf={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(L,W){return{validate:L,compare:W}}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(),_),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:f,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:V,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:S,int32:{type:"number",validate:I},int64:{type:"number",validate:A},float:{type:"number",validate:U},double:{type:"number",validate:U},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,a),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,l),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,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,_),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);function r(L){return L%4===0&&(L%100!==0||L%400===0)}const n=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,s=[0,31,28,31,30,31,30,31,31,30,31,30,31];function o(L){const W=n.exec(L);if(!W)return!1;const ce=+W[1],q=+W[2],le=+W[3];return q>=1&&q<=12&&le>=1&&le<=(q===2&&r(ce)?29:s[q])}function a(L,W){if(L&&W)return L>W?1:L23||w>59||L&&!it)return!1;if(le<=23&&Ce<=59&&ge<60)return!0;const C=Ce-w*je,b=le-j*je-(C<0?1:0);return(b===23||b===-1)&&(C===59||C===-1)&&ge<61}}function l(L,W){if(!(L&&W))return;const ce=new Date("2020-01-01T"+L).valueOf(),q=new Date("2020-01-01T"+W).valueOf();if(ce&&q)return ce-q}function d(L,W){if(!(L&&W))return;const ce=i.exec(L),q=i.exec(W);if(ce&&q)return L=ce[1]+ce[2]+ce[3],W=q[1]+q[2]+q[3],L>W?1:L=R}function A(L){return Number.isInteger(L)}function U(){return!0}const Z=/[^\\]\\Z/;function V(L){if(Z.test(L))return!1;try{return new RegExp(L),!0}catch{return!1}}})(uf);var df={},Oo={exports:{}},ff={},_t={},Mr={},An={},ie={},$n={};(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(v){if(super(),!e.IDENTIFIER.test(v))throw new Error("CodeGen: name must be a valid identifier");this.str=v}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=r;class n extends t{constructor(v){super(),this._items=typeof v=="string"?[v]:v}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const v=this._items[0];return v===""||v==='""'}get str(){var v;return(v=this._str)!==null&&v!==void 0?v:this._str=this._items.reduce((S,R)=>`${S}${R}`,"")}get names(){var v;return(v=this._names)!==null&&v!==void 0?v: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(f,...v){const S=[f[0]];let R=0;for(;R{if(h.scopePath===void 0)throw new Error(`CodeGen: name "${h}" has no value`);return(0,t._)`${l}${h.scopePath}`})}scopeCode(l=this._values,d,h){return this._reduceValues(l,y=>{if(y.value===void 0)throw new Error(`CodeGen: name "${y}" has no value`);return y.value.code},d,h)}_reduceValues(l,d,h={},y){let g=t.nil;for(const _ in l){const $=l[_];if(!$)continue;const m=h[_]=h[_]||new Map;$.forEach(f=>{if(m.has(f))return;m.set(f,n.Started);let v=d(f);if(v){const S=this.opts.es5?e.varKinds.var:e.varKinds.const;g=(0,t._)`${g}${S} ${f} = ${v};${this.opts._n}`}else if(v=y==null?void 0:y(f))g=(0,t._)`${g}${v}${this.opts._n}`;else throw new r(f);m.set(f,n.Completed)})}return g}}e.ValueScope=i})(Ao);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=$n,r=Ao;var n=$n;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}});var s=Ao;Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class o{optimizeNodes(){return this}optimizeNames(u,p){return this}}class a extends o{constructor(u,p,E){super(),this.varKind=u,this.name=p,this.rhs=E}render({es5:u,_n:p}){const E=u?r.varKinds.var:this.varKind,M=this.rhs===void 0?"":` = ${this.rhs}`;return`${E} ${this.name}${M};`+p}optimizeNames(u,p){if(u[this.name.str])return this.rhs&&(this.rhs=q(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=q(this.rhs,u,p),this}get names(){const u=this.lhs instanceof t.Name?{}:{...this.lhs.names};return ce(u,this.rhs)}}class c extends i{constructor(u,p,E,M){super(u,E,M),this.op=p}render({_n:u}){return`${this.lhs} ${this.op}= ${this.rhs};`+u}}class l extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`${this.label}:`+u}}class d extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`break${this.label?` ${this.label}`:""};`+u}}class h extends o{constructor(u){super(),this.error=u}render({_n:u}){return`throw ${this.error};`+u}get names(){return this.error.names}}class 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=q(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 M=E.length;for(;M--;){const x=E[M];x.optimizeNames(u,p)||(le(u,x.names),E.splice(M,1))}return E.length>0?this:void 0}get names(){return this.nodes.reduce((u,p)=>W(u,p.names),{})}}class _ extends g{render(u){return"{"+u._n+super.render(u)+"}"+u._n}}class $ extends g{}class m extends _{}m.kind="else";class f extends _{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 m(E):E}if(p)return u===!1?p instanceof f?p:p.nodes:this.nodes.length?this:new f(Ce(u),p instanceof f?[p]:p.nodes);if(!(u===!1||!this.nodes.length))return this}optimizeNames(u,p){var 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=q(this.condition,u,p),this}get names(){const u=super.names;return ce(u,this.condition),this.else&&W(u,this.else.names),u}}f.kind="if";class v extends _{}v.kind="for";class S extends v{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=q(this.iteration,u,p),this}get names(){return W(super.names,this.iteration.names)}}class R extends v{constructor(u,p,E,M){super(),this.varKind=u,this.name=p,this.from=E,this.to=M}render(u){const p=u.es5?r.varKinds.var:this.varKind,{name:E,from:M,to:x}=this;return`for(${p} ${E}=${M}; ${E}<${x}; ${E}++)`+super.render(u)}get names(){const u=ce(super.names,this.from);return ce(u,this.to)}}class P extends v{constructor(u,p,E,M){super(),this.loop=u,this.varKind=p,this.name=E,this.iterable=M}render(u){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(u)}optimizeNames(u,p){if(super.optimizeNames(u,p))return this.iterable=q(this.iterable,u,p),this}get names(){return W(super.names,this.iterable.names)}}class I extends _{constructor(u,p,E){super(),this.name=u,this.args=p,this.async=E}render(u){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(u)}}I.kind="func";class A extends g{render(u){return"return "+super.render(u)}}A.kind="return";class U extends _{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,M;return super.optimizeNames(u,p),(E=this.catch)===null||E===void 0||E.optimizeNames(u,p),(M=this.finally)===null||M===void 0||M.optimizeNames(u,p),this}get names(){const u=super.names;return this.catch&&W(u,this.catch.names),this.finally&&W(u,this.finally.names),u}}class Z extends _{constructor(u){super(),this.error=u}render(u){return`catch(${this.error})`+super.render(u)}}Z.kind="catch";class V extends _{render(u){return"finally"+super.render(u)}}V.kind="finally";class L{constructor(u,p={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...p,_n:p.lines?` +`:""},this._extScope=u,this._scope=new r.Scope({parent:u}),this._nodes=[new $]}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,M){const x=this._scope.toName(p);return E!==void 0&&M&&(this._constants[x.str]=E),this._leafNode(new a(u,x,E)),x}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,M]of u)p.length>1&&p.push(","),p.push(E),(E!==M||this.opts.es5)&&(p.push(":"),(0,t.addCodeArg)(p,M));return p.push("}"),new t._Code(p)}if(u,p,E){if(this._blockNode(new f(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 f(u))}else(){return this._elseNode(new m)}endIf(){return this._endBlockNode(f,m)}_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,M,x=this.opts.es5?r.varKinds.var:r.varKinds.let){const B=this._scope.toName(u);return this._for(new R(x,B,p,E),()=>M(B))}forOf(u,p,E,M=r.varKinds.const){const x=this._scope.toName(u);if(this.opts.es5){const B=p instanceof t.Name?p:this.var("_arr",p);return this.forRange("_i",0,(0,t._)`${B}.length`,K=>{this.var(x,(0,t._)`${B}[${K}]`),E(x)})}return this._for(new P("of",M,x,p),()=>E(x))}forIn(u,p,E,M=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(u,(0,t._)`Object.keys(${p})`,E);const x=this._scope.toName(u);return this._for(new P("in",M,x,p),()=>E(x))}endFor(){return this._endBlockNode(v)}label(u){return this._leafNode(new l(u))}break(u){return this._leafNode(new d(u))}return(u){const p=new A;if(this._blockNode(p),this.code(u),p.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(A)}try(u,p,E){if(!p&&!E)throw new Error('CodeGen: "try" without "catch" and "finally"');const M=new U;if(this._blockNode(M),this.code(u),p){const x=this.name("e");this._currNode=M.catch=new Z(x),p(x)}return E&&(this._currNode=M.finally=new V,this.code(E)),this._endBlockNode(Z,V)}throw(u){return this._leafNode(new h(u))}block(u,p){return this._blockStarts.push(this._nodes.length),u&&this.code(u).endBlock(p),this}endBlock(u){const p=this._blockStarts.pop();if(p===void 0)throw new Error("CodeGen: not in self-balancing block");const 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,M){return this._blockNode(new I(u,p,E)),M&&this.code(M).endFunc(),this}endFunc(){return this._endBlockNode(I)}optimize(u=1){for(;u-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(u){return this._currNode.nodes.push(u),this}_blockNode(u){this._currNode.nodes.push(u),this._nodes.push(u)}_endBlockNode(u,p){const E=this._currNode;if(E instanceof u||p&&E instanceof p)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${p?`${u.kind}/${p.kind}`:u.kind}"`)}_elseNode(u){const p=this._currNode;if(!(p instanceof f))throw new Error('CodeGen: "else" without "if"');return this._currNode=p.else=u,this}get _root(){return this._nodes[0]}get _currNode(){const u=this._nodes;return u[u.length-1]}set _currNode(u){const p=this._nodes;p[p.length-1]=u}}e.CodeGen=L;function W(b,u){for(const p in u)b[p]=(b[p]||0)+(u[p]||0);return b}function ce(b,u){return u instanceof t._CodeOrName?W(b,u.names):b}function q(b,u,p){if(b instanceof t.Name)return E(b);if(!M(b))return b;return new t._Code(b._items.reduce((x,B)=>(B instanceof t.Name&&(B=E(B)),B instanceof t._Code?x.push(...B._items):x.push(B),x),[]));function E(x){const B=p[x.str];return B===void 0||u[x.str]!==1?x:(delete u[x.str],B)}function M(x){return x instanceof t._Code&&x._items.some(B=>B instanceof t.Name&&u[B.str]===1&&p[B.str]!==void 0)}}function le(b,u){for(const p in u)b[p]=(b[p]||0)-(u[p]||0)}function Ce(b){return typeof b=="boolean"||typeof b=="number"||b===null?!b:(0,t._)`!${C(b)}`}e.not=Ce;const ge=w(e.operators.AND);function it(...b){return b.reduce(ge)}e.and=it;const je=w(e.operators.OR);function j(...b){return b.reduce(je)}e.or=j;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})`}})(ie);var H={};Object.defineProperty(H,"__esModule",{value:!0});H.checkStrictMode=H.getErrorPath=H.Type=H.useFunc=H.setEvaluated=H.evaluatedPropsToName=H.mergeEvaluated=H.eachItem=H.unescapeJsonPointer=H.escapeJsonPointer=H.escapeFragment=H.unescapeFragment=H.schemaRefOrVal=H.schemaHasRulesButRef=H.schemaHasRules=H.checkUnknownRules=H.alwaysValidSchema=H.toHash=void 0;const ve=ie,nE=$n;function sE(e){const t={};for(const r of e)t[r]=!0;return t}H.toHash=sE;function oE(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(hf(e,t),!pf(t,e.self.RULES.all))}H.alwaysValidSchema=oE;function hf(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]||gf(e,`unknown keyword: "${o}"`)}H.checkUnknownRules=hf;function pf(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(t[r])return!0;return!1}H.schemaHasRules=pf;function aE(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}H.schemaHasRulesButRef=aE;function iE({topSchemaRef:e,schemaPath:t},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,ve._)`${r}`}return(0,ve._)`${e}${t}${(0,ve.getProperty)(n)}`}H.schemaRefOrVal=iE;function cE(e){return mf(decodeURIComponent(e))}H.unescapeFragment=cE;function lE(e){return encodeURIComponent(Oi(e))}H.escapeFragment=lE;function Oi(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}H.escapeJsonPointer=Oi;function mf(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}H.unescapeJsonPointer=mf;function uE(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)}H.eachItem=uE;function gl({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(s,o,a,i)=>{const c=a===void 0?o:a instanceof ve.Name?(o instanceof ve.Name?e(s,o,a):t(s,o,a),a):o instanceof ve.Name?(t(s,a,o),o):r(o,a);return i===ve.Name&&!(c instanceof ve.Name)?n(s,c):c}}H.mergeEvaluated={props:gl({mergeNames:(e,t,r)=>e.if((0,ve._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,ve._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,ve._)`${r} || {}`).code((0,ve._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,ve._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,ve._)`${r} || {}`),Ai(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:_f}),items:gl({mergeNames:(e,t,r)=>e.if((0,ve._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,ve._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,ve._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,ve._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function _f(e,t){if(t===!0)return e.var("props",!0);const r=e.var("props",(0,ve._)`{}`);return t!==void 0&&Ai(e,r,t),r}H.evaluatedPropsToName=_f;function Ai(e,t,r){Object.keys(r).forEach(n=>e.assign((0,ve._)`${t}${(0,ve.getProperty)(n)}`,!0))}H.setEvaluated=Ai;const yl={};function dE(e,t){return e.scopeValue("func",{ref:t,code:yl[t.code]||(yl[t.code]=new nE._Code(t.code))})}H.useFunc=dE;var zo;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(zo||(H.Type=zo={}));function fE(e,t,r){if(e instanceof ve.Name){const n=t===zo.Num;return r?n?(0,ve._)`"[" + ${e} + "]"`:(0,ve._)`"['" + ${e} + "']"`:n?(0,ve._)`"/" + ${e}`:(0,ve._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,ve.getProperty)(e).toString():"/"+Oi(e)}H.getErrorPath=fE;function gf(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}H.checkStrictMode=gf;var St={};Object.defineProperty(St,"__esModule",{value:!0});const Ke=ie,hE={data:new Ke.Name("data"),valCxt:new Ke.Name("valCxt"),instancePath:new Ke.Name("instancePath"),parentData:new Ke.Name("parentData"),parentDataProperty:new Ke.Name("parentDataProperty"),rootData:new Ke.Name("rootData"),dynamicAnchors:new Ke.Name("dynamicAnchors"),vErrors:new Ke.Name("vErrors"),errors:new Ke.Name("errors"),this:new Ke.Name("this"),self:new Ke.Name("self"),scope:new Ke.Name("scope"),json:new Ke.Name("json"),jsonPos:new Ke.Name("jsonPos"),jsonLen:new Ke.Name("jsonLen"),jsonPart:new Ke.Name("jsonPart")};St.default=hE;(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=ie,r=H,n=St;e.keywordError={message:({keyword:m})=>(0,t.str)`must pass "${m}" keyword validation`},e.keyword$DataError={message:({keyword:m,schemaType:f})=>f?(0,t.str)`"${m}" keyword must be ${f} ($data)`:(0,t.str)`"${m}" keyword is invalid ($data)`};function s(m,f=e.keywordError,v,S){const{it:R}=m,{gen:P,compositeRule:I,allErrors:A}=R,U=h(m,f,v);S??(I||A)?c(P,U):l(R,(0,t._)`[${U}]`)}e.reportError=s;function o(m,f=e.keywordError,v){const{it:S}=m,{gen:R,compositeRule:P,allErrors:I}=S,A=h(m,f,v);c(R,A),P||I||l(S,n.default.vErrors)}e.reportExtraError=o;function a(m,f){m.assign(n.default.errors,f),m.if((0,t._)`${n.default.vErrors} !== null`,()=>m.if(f,()=>m.assign((0,t._)`${n.default.vErrors}.length`,f),()=>m.assign(n.default.vErrors,null)))}e.resetErrorsCount=a;function i({gen:m,keyword:f,schemaValue:v,data:S,errsCount:R,it:P}){if(R===void 0)throw new Error("ajv implementation error");const I=m.name("err");m.forRange("i",R,n.default.errors,A=>{m.const(I,(0,t._)`${n.default.vErrors}[${A}]`),m.if((0,t._)`${I}.instancePath === undefined`,()=>m.assign((0,t._)`${I}.instancePath`,(0,t.strConcat)(n.default.instancePath,P.errorPath))),m.assign((0,t._)`${I}.schemaPath`,(0,t.str)`${P.errSchemaPath}/${f}`),P.opts.verbose&&(m.assign((0,t._)`${I}.schema`,v),m.assign((0,t._)`${I}.data`,S))})}e.extendErrors=i;function c(m,f){const v=m.const("err",f);m.if((0,t._)`${n.default.vErrors} === null`,()=>m.assign(n.default.vErrors,(0,t._)`[${v}]`),(0,t._)`${n.default.vErrors}.push(${v})`),m.code((0,t._)`${n.default.errors}++`)}function l(m,f){const{gen:v,validateName:S,schemaEnv:R}=m;R.$async?v.throw((0,t._)`new ${m.ValidationError}(${f})`):(v.assign((0,t._)`${S}.errors`,f),v.return(!1))}const d={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function h(m,f,v){const{createErrors:S}=m.it;return S===!1?(0,t._)`{}`:y(m,f,v)}function y(m,f,v={}){const{gen:S,it:R}=m,P=[g(R,v),_(m,v)];return $(m,f,P),S.object(...P)}function g({errorPath:m},{instancePath:f}){const v=f?(0,t.str)`${m}${(0,r.getErrorPath)(f,r.Type.Str)}`:m;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,v)]}function _({keyword:m,it:{errSchemaPath:f}},{schemaPath:v,parentSchema:S}){let R=S?f:(0,t.str)`${f}/${m}`;return v&&(R=(0,t.str)`${R}${(0,r.getErrorPath)(v,r.Type.Str)}`),[d.schemaPath,R]}function $(m,{params:f,message:v},S){const{keyword:R,data:P,schemaValue:I,it:A}=m,{opts:U,propertyName:Z,topSchemaRef:V,schemaPath:L}=A;S.push([d.keyword,R],[d.params,typeof f=="function"?f(m):f||(0,t._)`{}`]),U.messages&&S.push([d.message,typeof v=="function"?v(m):v]),U.verbose&&S.push([d.schema,I],[d.parentSchema,(0,t._)`${V}${L}`],[n.default.data,P]),Z&&S.push([d.propertyName,Z])}})(An);Object.defineProperty(Mr,"__esModule",{value:!0});Mr.boolOrEmptySchema=Mr.topBoolOrEmptySchema=void 0;const pE=An,mE=ie,_E=St,gE={message:"boolean schema is false"};function yE(e){const{gen:t,schema:r,validateName:n}=e;r===!1?yf(e,!1):typeof r=="object"&&r.$async===!0?t.return(_E.default.data):(t.assign((0,mE._)`${n}.errors`,null),t.return(!0))}Mr.topBoolOrEmptySchema=yE;function vE(e,t){const{gen:r,schema:n}=e;n===!1?(r.var(t,!1),yf(e)):r.var(t,!0)}Mr.boolOrEmptySchema=vE;function yf(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,pE.reportError)(s,gE,void 0,t)}var Ae={},mr={};Object.defineProperty(mr,"__esModule",{value:!0});mr.getRules=mr.isJSONType=void 0;const $E=["string","number","integer","boolean","null","object","array"],wE=new Set($E);function bE(e){return typeof e=="string"&&wE.has(e)}mr.isJSONType=bE;function SE(){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:{}}}mr.getRules=SE;var Pt={};Object.defineProperty(Pt,"__esModule",{value:!0});Pt.shouldUseRule=Pt.shouldUseGroup=Pt.schemaHasRulesForType=void 0;function EE({schema:e,self:t},r){const n=t.RULES.types[r];return n&&n!==!0&&vf(e,n)}Pt.schemaHasRulesForType=EE;function vf(e,t){return t.rules.some(r=>$f(e,r))}Pt.shouldUseGroup=vf;function $f(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}Pt.shouldUseRule=$f;Object.defineProperty(Ae,"__esModule",{value:!0});Ae.reportTypeError=Ae.checkDataTypes=Ae.checkDataType=Ae.coerceAndCheckDataType=Ae.getJSONTypes=Ae.getSchemaTypes=Ae.DataType=void 0;const kE=mr,PE=Pt,TE=An,se=ie,wf=H;var Ir;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Ir||(Ae.DataType=Ir={}));function RE(e){const t=bf(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}Ae.getSchemaTypes=RE;function bf(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(kE.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Ae.getJSONTypes=bf;function CE(e,t){const{gen:r,data:n,opts:s}=e,o=NE(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0,PE.schemaHasRulesForType)(e,t[0]));if(a){const i=zi(t,n,s.strictNumbers,Ir.Wrong);r.if(i,()=>{o.length?IE(e,t,o):Mi(e)})}return a}Ae.coerceAndCheckDataType=CE;const Sf=new Set(["string","number","integer","boolean","null"]);function NE(e,t){return t?e.filter(r=>Sf.has(r)||t==="array"&&r==="array"):[]}function IE(e,t,r){const{gen:n,data:s,opts:o}=e,a=n.let("dataType",(0,se._)`typeof ${s}`),i=n.let("coerced",(0,se._)`undefined`);o.coerceTypes==="array"&&n.if((0,se._)`${a} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,se._)`${s}[0]`).assign(a,(0,se._)`typeof ${s}`).if(zi(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0,se._)`${i} !== undefined`);for(const l of r)(Sf.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),Mi(e),n.endIf(),n.if((0,se._)`${i} !== undefined`,()=>{n.assign(s,i),jE(e,i)});function c(l){switch(l){case"string":n.elseIf((0,se._)`${a} == "number" || ${a} == "boolean"`).assign(i,(0,se._)`"" + ${s}`).elseIf((0,se._)`${s} === null`).assign(i,(0,se._)`""`);return;case"number":n.elseIf((0,se._)`${a} == "boolean" || ${s} === null + || (${a} == "string" && ${s} && ${s} == +${s})`).assign(i,(0,se._)`+${s}`);return;case"integer":n.elseIf((0,se._)`${a} === "boolean" || ${s} === null + || (${a} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(i,(0,se._)`+${s}`);return;case"boolean":n.elseIf((0,se._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(i,!1).elseIf((0,se._)`${s} === "true" || ${s} === 1`).assign(i,!0);return;case"null":n.elseIf((0,se._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(i,null);return;case"array":n.elseIf((0,se._)`${a} === "string" || ${a} === "number" + || ${a} === "boolean" || ${s} === null`).assign(i,(0,se._)`[${s}]`)}}}function jE({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,se._)`${t} !== undefined`,()=>e.assign((0,se._)`${t}[${r}]`,n))}function Mo(e,t,r,n=Ir.Correct){const s=n===Ir.Correct?se.operators.EQ:se.operators.NEQ;let o;switch(e){case"null":return(0,se._)`${t} ${s} null`;case"array":o=(0,se._)`Array.isArray(${t})`;break;case"object":o=(0,se._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=a((0,se._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=a();break;default:return(0,se._)`typeof ${t} ${s} ${e}`}return n===Ir.Correct?o:(0,se.not)(o);function a(i=se.nil){return(0,se.and)((0,se._)`typeof ${t} == "number"`,i,r?(0,se._)`isFinite(${t})`:se.nil)}}Ae.checkDataType=Mo;function zi(e,t,r,n){if(e.length===1)return Mo(e[0],t,r,n);let s;const o=(0,wf.toHash)(e);if(o.array&&o.object){const a=(0,se._)`typeof ${t} != "object"`;s=o.null?a:(0,se._)`!${t} || ${a}`,delete o.null,delete o.array,delete o.object}else s=se.nil;o.number&&delete o.integer;for(const a in o)s=(0,se.and)(s,Mo(a,t,r,n));return s}Ae.checkDataTypes=zi;const OE={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,se._)`{type: ${e}}`:(0,se._)`{type: ${t}}`};function Mi(e){const t=AE(e);(0,TE.reportError)(t,OE)}Ae.reportTypeError=Mi;function AE(e){const{gen:t,data:r,schema:n}=e,s=(0,wf.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}var Zs={};Object.defineProperty(Zs,"__esModule",{value:!0});Zs.assignDefaults=void 0;const $r=ie,zE=H;function ME(e,t){const{properties:r,items:n}=e.schema;if(t==="object"&&r)for(const s in r)vl(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>vl(e,o,s.default))}Zs.assignDefaults=ME;function vl(e,t,r){const{gen:n,compositeRule:s,data:o,opts:a}=e;if(r===void 0)return;const i=(0,$r._)`${o}${(0,$r.getProperty)(t)}`;if(s){(0,zE.checkStrictMode)(e,`default is ignored for: ${i}`);return}let c=(0,$r._)`${i} === undefined`;a.useDefaults==="empty"&&(c=(0,$r._)`${c} || ${i} === null || ${i} === ""`),n.if(c,(0,$r._)`${i} = ${(0,$r.stringify)(r)}`)}var wt={},de={};Object.defineProperty(de,"__esModule",{value:!0});de.validateUnion=de.validateArray=de.usePattern=de.callValidateCode=de.schemaProperties=de.allSchemaProperties=de.noPropertyInData=de.propertyInData=de.isOwnProperty=de.hasPropFunc=de.reportMissingProp=de.checkMissingProp=de.checkReportMissingProp=void 0;const Se=ie,xi=H,Nt=St,xE=H;function qE(e,t){const{gen:r,data:n,it:s}=e;r.if(Di(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Se._)`${t}`},!0),e.error()})}de.checkReportMissingProp=qE;function DE({gen:e,data:t,it:{opts:r}},n,s){return(0,Se.or)(...n.map(o=>(0,Se.and)(Di(e,t,o,r.ownProperties),(0,Se._)`${s} = ${o}`)))}de.checkMissingProp=DE;function UE(e,t){e.setParams({missingProperty:t},!0),e.error()}de.reportMissingProp=UE;function Ef(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Se._)`Object.prototype.hasOwnProperty`})}de.hasPropFunc=Ef;function qi(e,t,r){return(0,Se._)`${Ef(e)}.call(${t}, ${r})`}de.isOwnProperty=qi;function VE(e,t,r,n){const s=(0,Se._)`${t}${(0,Se.getProperty)(r)} !== undefined`;return n?(0,Se._)`${s} && ${qi(e,t,r)}`:s}de.propertyInData=VE;function Di(e,t,r,n){const s=(0,Se._)`${t}${(0,Se.getProperty)(r)} === undefined`;return n?(0,Se.or)(s,(0,Se.not)(qi(e,t,r))):s}de.noPropertyInData=Di;function kf(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}de.allSchemaProperties=kf;function LE(e,t){return kf(t).filter(r=>!(0,xi.alwaysValidSchema)(e,t[r]))}de.schemaProperties=LE;function FE({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:a},i,c,l){const d=l?(0,Se._)`${e}, ${t}, ${n}${s}`:t,h=[[Nt.default.instancePath,(0,Se.strConcat)(Nt.default.instancePath,o)],[Nt.default.parentData,a.parentData],[Nt.default.parentDataProperty,a.parentDataProperty],[Nt.default.rootData,Nt.default.rootData]];a.opts.dynamicRef&&h.push([Nt.default.dynamicAnchors,Nt.default.dynamicAnchors]);const y=(0,Se._)`${d}, ${r.object(...h)}`;return c!==Se.nil?(0,Se._)`${i}.call(${c}, ${y})`:(0,Se._)`${i}(${y})`}de.callValidateCode=FE;const HE=(0,Se._)`new RegExp`;function ZE({gen:e,it:{opts:t}},r){const n=t.unicodeRegExp?"u":"",{regExp:s}=t.code,o=s(r,n);return e.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,Se._)`${s.code==="new RegExp"?HE:(0,xE.useFunc)(e,s)}(${r}, ${n})`})}de.usePattern=ZE;function KE(e){const{gen:t,data:r,keyword:n,it:s}=e,o=t.name("valid");if(s.allErrors){const i=t.let("valid",!0);return a(()=>t.assign(i,!1)),i}return t.var(o,!0),a(()=>t.break()),o;function a(i){const c=t.const("len",(0,Se._)`${r}.length`);t.forRange("i",0,c,l=>{e.subschema({keyword:n,dataProp:l,dataPropType:xi.Type.Num},o),t.if((0,Se.not)(o),i)})}}de.validateArray=KE;function GE(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,xi.alwaysValidSchema)(s,c))&&!s.opts.unevaluated)return;const a=t.let("valid",!1),i=t.name("_valid");t.block(()=>r.forEach((c,l)=>{const d=e.subschema({keyword:n,schemaProp:l,compositeRule:!0},i);t.assign(a,(0,Se._)`${a} || ${i}`),e.mergeValidEvaluated(d,i)||t.if((0,Se.not)(a))})),e.result(a,()=>e.reset(),()=>e.error(!0))}de.validateUnion=GE;Object.defineProperty(wt,"__esModule",{value:!0});wt.validateKeywordUsage=wt.validSchemaType=wt.funcKeywordCode=wt.macroKeywordCode=void 0;const We=ie,ir=St,WE=de,BE=An;function JE(e,t){const{gen:r,keyword:n,schema:s,parentSchema:o,it:a}=e,i=t.macro.call(a.self,s,o,a),c=Pf(r,n,i);a.opts.validateSchema!==!1&&a.self.validateSchema(i,!0);const l=r.name("valid");e.subschema({schema:i,schemaPath:We.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},l),e.pass(l,()=>e.error(!0))}wt.macroKeywordCode=JE;function QE(e,t){var r;const{gen:n,keyword:s,schema:o,parentSchema:a,$data:i,it:c}=e;XE(c,t);const l=!i&&t.compile?t.compile.call(c.self,o,a,c):t.validate,d=Pf(n,s,l),h=n.let("valid");e.block$data(h,y),e.ok((r=t.valid)!==null&&r!==void 0?r:h);function y(){if(t.errors===!1)$(),t.modifying&&$l(e),m(()=>e.error());else{const f=t.async?g():_();t.modifying&&$l(e),m(()=>YE(e,f))}}function g(){const f=n.let("ruleErrs",null);return n.try(()=>$((0,We._)`await `),v=>n.assign(h,!1).if((0,We._)`${v} instanceof ${c.ValidationError}`,()=>n.assign(f,(0,We._)`${v}.errors`),()=>n.throw(v))),f}function _(){const f=(0,We._)`${d}.errors`;return n.assign(f,null),$(We.nil),f}function $(f=t.async?(0,We._)`await `:We.nil){const v=c.opts.passContext?ir.default.this:ir.default.self,S=!("compile"in t&&!i||t.schema===!1);n.assign(h,(0,We._)`${f}${(0,WE.callValidateCode)(e,d,v,S)}`,t.modifying)}function m(f){var v;n.if((0,We.not)((v=t.valid)!==null&&v!==void 0?v:h),f)}}wt.funcKeywordCode=QE;function $l(e){const{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,We._)`${n.parentData}[${n.parentDataProperty}]`))}function YE(e,t){const{gen:r}=e;r.if((0,We._)`Array.isArray(${t})`,()=>{r.assign(ir.default.vErrors,(0,We._)`${ir.default.vErrors} === null ? ${t} : ${ir.default.vErrors}.concat(${t})`).assign(ir.default.errors,(0,We._)`${ir.default.vErrors}.length`),(0,BE.extendErrors)(e)},()=>e.error())}function XE({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function Pf(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,We.stringify)(r)})}function ek(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}wt.validSchemaType=ek;function tk({schema:e,opts:t,self:r,errSchemaPath:n},s,o){if(Array.isArray(s.keyword)?!s.keyword.includes(o):s.keyword!==o)throw new Error("ajv implementation error");const a=s.dependencies;if(a!=null&&a.some(i=>!Object.prototype.hasOwnProperty.call(e,i)))throw new Error(`parent schema must have dependencies of ${o}: ${a.join(",")}`);if(s.validateSchema&&!s.validateSchema(e[o])){const c=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(s.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}wt.validateKeywordUsage=tk;var Mt={};Object.defineProperty(Mt,"__esModule",{value:!0});Mt.extendSubschemaMode=Mt.extendSubschemaData=Mt.getSubschema=void 0;const vt=ie,Tf=H;function rk(e,{keyword:t,schemaProp:r,schema:n,schemaPath:s,errSchemaPath:o,topSchemaRef:a}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){const i=e.schema[t];return r===void 0?{schema:i,schemaPath:(0,vt._)`${e.schemaPath}${(0,vt.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:i[r],schemaPath:(0,vt._)`${e.schemaPath}${(0,vt.getProperty)(t)}${(0,vt.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,Tf.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')}Mt.getSubschema=rk;function nk(e,t,{dataProp:r,dataPropType:n,data:s,dataTypes:o,propertyName:a}){if(s!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:i}=t;if(r!==void 0){const{errorPath:l,dataPathArr:d,opts:h}=t,y=i.let("data",(0,vt._)`${t.data}${(0,vt.getProperty)(r)}`,!0);c(y),e.errorPath=(0,vt.str)`${l}${(0,Tf.getErrorPath)(r,n,h.jsPropertySyntax)}`,e.parentDataProperty=(0,vt._)`${r}`,e.dataPathArr=[...d,e.parentDataProperty]}if(s!==void 0){const l=s instanceof vt.Name?s:i.let("data",s,!0);c(l),a!==void 0&&(e.propertyName=a)}o&&(e.dataTypes=o);function c(l){e.data=l,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,l]}}Mt.extendSubschemaData=nk;function sk(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}Mt.extendSubschemaMode=sk;var Ve={},Rf={exports:{}},At=Rf.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(){};ss(t,n,s,e,"",e)};At.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};At.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};At.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};At.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function ss(e,t,r,n,s,o,a,i,c,l){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,s,o,a,i,c,l);for(var d in n){var h=n[d];if(Array.isArray(h)){if(d in At.arrayKeywords)for(var y=0;yt+=Cf(n)),t===1/0))return 1/0}return t}function Nf(e,t="",r){r!==!1&&(t=jr(t));const n=e.parse(t);return If(e,n)}Ve.getFullPath=Nf;function If(e,t){return e.serialize(t).split("#")[0]+"#"}Ve._getFullPath=If;const hk=/#\/?$/;function jr(e){return e?e.replace(hk,""):""}Ve.normalizeId=jr;function pk(e,t,r){return r=jr(r),e.resolve(t,r)}Ve.resolveUrl=pk;const mk=/^[a-z_][-a-z0-9._]*$/i;function _k(e,t){if(typeof e=="boolean")return{};const{schemaId:r,uriResolver:n}=this.opts,s=jr(e[r]||t),o={"":s},a=Nf(n,s,!1),i={},c=new Set;return lk(e,{allKeys:!0},(h,y,g,_)=>{if(_===void 0)return;const $=a+y;let m=o[_];typeof h[r]=="string"&&(m=f.call(this,h[r])),v.call(this,h.$anchor),v.call(this,h.$dynamicAnchor),o[y]=m;function f(S){const R=this.opts.uriResolver.resolve;if(S=jr(m?R(m,S):S),c.has(S))throw d(S);c.add(S);let P=this.refs[S];return typeof P=="string"&&(P=this.refs[P]),typeof P=="object"?l(h,P.schema,S):S!==jr($)&&(S[0]==="#"?(l(h,i[S],S),i[S]=h):this.refs[S]=$),S}function v(S){if(typeof S=="string"){if(!mk.test(S))throw new Error(`invalid anchor "${S}"`);f.call(this,`#${S}`)}}}),i;function l(h,y,g){if(y!==void 0&&!ck(h,y))throw d(g)}function d(h){return new Error(`reference "${h}" resolves to more than one schema`)}}Ve.getSchemaRefs=_k;Object.defineProperty(_t,"__esModule",{value:!0});_t.getData=_t.KeywordCxt=_t.validateFunctionCode=void 0;const jf=Mr,wl=Ae,Ui=Pt,ws=Ae,gk=Zs,un=wt,oo=Mt,Q=ie,te=St,yk=Ve,Tt=H,Qr=An;function vk(e){if(zf(e)&&(Mf(e),Af(e))){bk(e);return}Of(e,()=>(0,jf.topBoolOrEmptySchema)(e))}_t.validateFunctionCode=vk;function Of({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},o){s.code.es5?e.func(t,(0,Q._)`${te.default.data}, ${te.default.valCxt}`,n.$async,()=>{e.code((0,Q._)`"use strict"; ${bl(r,s)}`),wk(e,s),e.code(o)}):e.func(t,(0,Q._)`${te.default.data}, ${$k(s)}`,n.$async,()=>e.code(bl(r,s)).code(o))}function $k(e){return(0,Q._)`{${te.default.instancePath}="", ${te.default.parentData}, ${te.default.parentDataProperty}, ${te.default.rootData}=${te.default.data}${e.dynamicRef?(0,Q._)`, ${te.default.dynamicAnchors}={}`:Q.nil}}={}`}function wk(e,t){e.if(te.default.valCxt,()=>{e.var(te.default.instancePath,(0,Q._)`${te.default.valCxt}.${te.default.instancePath}`),e.var(te.default.parentData,(0,Q._)`${te.default.valCxt}.${te.default.parentData}`),e.var(te.default.parentDataProperty,(0,Q._)`${te.default.valCxt}.${te.default.parentDataProperty}`),e.var(te.default.rootData,(0,Q._)`${te.default.valCxt}.${te.default.rootData}`),t.dynamicRef&&e.var(te.default.dynamicAnchors,(0,Q._)`${te.default.valCxt}.${te.default.dynamicAnchors}`)},()=>{e.var(te.default.instancePath,(0,Q._)`""`),e.var(te.default.parentData,(0,Q._)`undefined`),e.var(te.default.parentDataProperty,(0,Q._)`undefined`),e.var(te.default.rootData,te.default.data),t.dynamicRef&&e.var(te.default.dynamicAnchors,(0,Q._)`{}`)})}function bk(e){const{schema:t,opts:r,gen:n}=e;Of(e,()=>{r.$comment&&t.$comment&&qf(e),Tk(e),n.let(te.default.vErrors,null),n.let(te.default.errors,0),r.unevaluated&&Sk(e),xf(e),Nk(e)})}function Sk(e){const{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,Q._)`${r}.evaluated`),t.if((0,Q._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,Q._)`${e.evaluated}.props`,(0,Q._)`undefined`)),t.if((0,Q._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,Q._)`${e.evaluated}.items`,(0,Q._)`undefined`))}function bl(e,t){const r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,Q._)`/*# sourceURL=${r} */`:Q.nil}function Ek(e,t){if(zf(e)&&(Mf(e),Af(e))){kk(e,t);return}(0,jf.boolOrEmptySchema)(e,t)}function Af({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 zf(e){return typeof e.schema!="boolean"}function kk(e,t){const{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&qf(e),Rk(e),Ck(e);const o=n.const("_errs",te.default.errors);xf(e,o),n.var(t,(0,Q._)`${o} === ${te.default.errors}`)}function Mf(e){(0,Tt.checkUnknownRules)(e),Pk(e)}function xf(e,t){if(e.opts.jtd)return Sl(e,[],!1,t);const r=(0,wl.getSchemaTypes)(e.schema),n=(0,wl.coerceAndCheckDataType)(e,r);Sl(e,r,!n,t)}function Pk(e){const{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,Tt.schemaHasRulesButRef)(t,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function Tk(e){const{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Tt.checkStrictMode)(e,"default is ignored in the schema root")}function Rk(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,yk.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function Ck(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function qf({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:s}){const o=r.$comment;if(s.$comment===!0)e.code((0,Q._)`${te.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){const a=(0,Q.str)`${n}/$comment`,i=e.scopeValue("root",{ref:t.root});e.code((0,Q._)`${te.default.self}.opts.$comment(${o}, ${a}, ${i}.schema)`)}}function Nk(e){const{gen:t,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=e;r.$async?t.if((0,Q._)`${te.default.errors} === 0`,()=>t.return(te.default.data),()=>t.throw((0,Q._)`new ${s}(${te.default.vErrors})`)):(t.assign((0,Q._)`${n}.errors`,te.default.vErrors),o.unevaluated&&Ik(e),t.return((0,Q._)`${te.default.errors} === 0`))}function Ik({gen:e,evaluated:t,props:r,items:n}){r instanceof Q.Name&&e.assign((0,Q._)`${t}.props`,r),n instanceof Q.Name&&e.assign((0,Q._)`${t}.items`,n)}function Sl(e,t,r,n){const{gen:s,schema:o,data:a,allErrors:i,opts:c,self:l}=e,{RULES:d}=l;if(o.$ref&&(c.ignoreKeywordsWithRef||!(0,Tt.schemaHasRulesButRef)(o,d))){s.block(()=>Vf(e,"$ref",d.all.$ref.definition));return}c.jtd||jk(e,t),s.block(()=>{for(const y of d.rules)h(y);h(d.post)});function h(y){(0,Ui.shouldUseGroup)(o,y)&&(y.type?(s.if((0,ws.checkDataType)(y.type,a,c.strictNumbers)),El(e,y),t.length===1&&t[0]===y.type&&r&&(s.else(),(0,ws.reportTypeError)(e)),s.endIf()):El(e,y),i||s.if((0,Q._)`${te.default.errors} === ${n||0}`))}}function El(e,t){const{gen:r,schema:n,opts:{useDefaults:s}}=e;s&&(0,gk.assignDefaults)(e,t.type),r.block(()=>{for(const o of t.rules)(0,Ui.shouldUseRule)(n,o)&&Vf(e,o.keyword,o.definition,t.type)})}function jk(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(Ok(e,t),e.opts.allowUnionTypes||Ak(e,t),zk(e,e.dataTypes))}function Ok(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{Df(e.dataTypes,r)||Vi(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),xk(e,t)}}function Ak(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Vi(e,"use allowUnionTypes to allow union type keyword")}function zk(e,t){const r=e.self.RULES.all;for(const n in r){const s=r[n];if(typeof s=="object"&&(0,Ui.shouldUseRule)(e.schema,s)){const{type:o}=s.definition;o.length&&!o.some(a=>Mk(t,a))&&Vi(e,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function Mk(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function Df(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function xk(e,t){const r=[];for(const n of e.dataTypes)Df(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function Vi(e,t){const r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,Tt.checkStrictMode)(e,t,e.opts.strictTypes)}class Uf{constructor(t,r,n){if((0,un.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Tt.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",Lf(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,un.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",te.default.errors))}result(t,r,n){this.failResult((0,Q.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,Q.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);const{schemaCode:r}=this;this.fail((0,Q._)`${r} !== undefined && (${(0,Q.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?Qr.reportExtraError:Qr.reportError)(this,this.def.error,r)}$dataError(){(0,Qr.reportError)(this,this.def.$dataError||Qr.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Qr.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=Q.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=Q.nil,r=Q.nil){if(!this.$data)return;const{gen:n,schemaCode:s,schemaType:o,def:a}=this;n.if((0,Q.or)((0,Q._)`${s} === undefined`,r)),t!==Q.nil&&n.assign(t,!0),(o.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==Q.nil&&n.assign(t,!1)),n.else()}invalid$data(){const{gen:t,schemaCode:r,schemaType:n,def:s,it:o}=this;return(0,Q.or)(a(),i());function a(){if(n.length){if(!(r instanceof Q.Name))throw new Error("ajv implementation error");const c=Array.isArray(n)?n:[n];return(0,Q._)`${(0,ws.checkDataTypes)(c,r,o.opts.strictNumbers,ws.DataType.Wrong)}`}return Q.nil}function i(){if(s.validateSchema){const c=t.scopeValue("validate$data",{ref:s.validateSchema});return(0,Q._)`!${c}(${r})`}return Q.nil}}subschema(t,r){const n=(0,oo.getSubschema)(this.it,t);(0,oo.extendSubschemaData)(n,this.it,t),(0,oo.extendSubschemaMode)(n,t);const s={...this.it,...n,items:void 0,props:void 0};return Ek(s,r),s}mergeEvaluated(t,r){const{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=Tt.mergeEvaluated.props(s,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=Tt.mergeEvaluated.items(s,t.items,n.items,r)))}mergeValidEvaluated(t,r){const{it:n,gen:s}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return s.if(r,()=>this.mergeEvaluated(t,Q.Name)),!0}}_t.KeywordCxt=Uf;function Vf(e,t,r,n){const s=new Uf(e,r,t);"code"in r?r.code(s,n):s.$data&&r.validate?(0,un.funcKeywordCode)(s,r):"macro"in r?(0,un.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,un.funcKeywordCode)(s,r)}const qk=/^\/(?:[^~]|~0|~1)*$/,Dk=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Lf(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,o;if(e==="")return te.default.rootData;if(e[0]==="/"){if(!qk.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,o=te.default.rootData}else{const l=Dk.exec(e);if(!l)throw new Error(`Invalid JSON-pointer: ${e}`);const d=+l[1];if(s=l[2],s==="#"){if(d>=t)throw new Error(c("property/index",d));return n[t-d]}if(d>t)throw new Error(c("data",d));if(o=r[t-d],!s)return o}let a=o;const i=s.split("/");for(const l of i)l&&(o=(0,Q._)`${o}${(0,Q.getProperty)((0,Tt.unescapeJsonPointer)(l))}`,a=(0,Q._)`${a} && ${o}`);return a;function c(l,d){return`Cannot access ${l} ${d} levels up, current level is ${t}`}}_t.getData=Lf;var zn={};Object.defineProperty(zn,"__esModule",{value:!0});class Uk extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}}zn.default=Uk;var Fr={};Object.defineProperty(Fr,"__esModule",{value:!0});const ao=Ve;class Vk extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,ao.resolveUrl)(t,r,n),this.missingSchema=(0,ao.normalizeId)((0,ao.getFullPath)(t,this.missingRef))}}Fr.default=Vk;var Ye={};Object.defineProperty(Ye,"__esModule",{value:!0});Ye.resolveSchema=Ye.getCompilingSchema=Ye.resolveRef=Ye.compileSchema=Ye.SchemaEnv=void 0;const ut=ie,Lk=zn,tr=St,pt=Ve,kl=H,Fk=_t;class Ks{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,pt.normalizeId)(n==null?void 0:n[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n==null?void 0:n.$async,this.refs={}}}Ye.SchemaEnv=Ks;function Li(e){const t=Ff.call(this,e);if(t)return t;const r=(0,pt.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,a=new ut.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o});let i;e.$async&&(i=a.scopeValue("Error",{ref:Lk.default,code:(0,ut._)`require("ajv/dist/runtime/validation_error").default`}));const c=a.scopeName("validate");e.validateName=c;const l={gen:a,allErrors:this.opts.allErrors,data:tr.default.data,parentData:tr.default.parentData,parentDataProperty:tr.default.parentDataProperty,dataNames:[tr.default.data],dataPathArr:[ut.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,ut.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:ut.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,ut._)`""`,opts:this.opts,self:this};let d;try{this._compilations.add(e),(0,Fk.validateFunctionCode)(l),a.optimize(this.opts.code.optimize);const h=a.toString();d=`${a.scopeRefs(tr.default.scope)}return ${h}`,this.opts.code.process&&(d=this.opts.code.process(d,e));const g=new Function(`${tr.default.self}`,`${tr.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:h,scopeValues:a._values}),this.opts.unevaluated){const{props:_,items:$}=l;g.evaluated={props:_ instanceof ut.Name?void 0:_,items:$ instanceof ut.Name?void 0:$,dynamicProps:_ instanceof ut.Name,dynamicItems:$ instanceof ut.Name},g.source&&(g.source.evaluated=(0,ut.stringify)(g.evaluated))}return e.validate=g,e}catch(h){throw delete e.validate,delete e.validateName,d&&this.logger.error("Error compiling schema, function code:",d),h}finally{this._compilations.delete(e)}}Ye.compileSchema=Li;function Hk(e,t,r){var n;r=(0,pt.resolveUrl)(this.opts.uriResolver,t,r);const s=e.refs[r];if(s)return s;let o=Gk.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 Ks({schema:a,schemaId:i,root:e,baseId:t}))}if(o!==void 0)return e.refs[r]=Zk.call(this,o)}Ye.resolveRef=Hk;function Zk(e){return(0,pt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Li.call(this,e)}function Ff(e){for(const t of this._compilations)if(Kk(t,e))return t}Ye.getCompilingSchema=Ff;function Kk(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function Gk(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Gs.call(this,e,t)}function Gs(e,t){const r=this.opts.uriResolver.parse(t),n=(0,pt._getFullPath)(this.opts.uriResolver,r);let s=(0,pt.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===s)return io.call(this,r,e);const o=(0,pt.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){const i=Gs.call(this,e,a);return typeof(i==null?void 0:i.schema)!="object"?void 0:io.call(this,r,i)}if(typeof(a==null?void 0:a.schema)=="object"){if(a.validate||Li.call(this,a),o===(0,pt.normalizeId)(t)){const{schema:i}=a,{schemaId:c}=this.opts,l=i[c];return l&&(s=(0,pt.resolveUrl)(this.opts.uriResolver,s,l)),new Ks({schema:i,schemaId:c,root:e,baseId:s})}return io.call(this,r,a)}}Ye.resolveSchema=Gs;const Wk=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function io(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,kl.unescapeFragment)(i)];if(c===void 0)return;r=c;const l=typeof r=="object"&&r[this.opts.schemaId];!Wk.has(i)&&l&&(t=(0,pt.resolveUrl)(this.opts.uriResolver,t,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,kl.schemaHasRulesButRef)(r,this.RULES)){const i=(0,pt.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=Gs.call(this,n,i)}const{schemaId:a}=this.opts;if(o=o||new Ks({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}const Bk="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",Jk="Meta-schema for $data reference (JSON AnySchema extension proposal)",Qk="object",Yk=["$data"],Xk={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},eP=!1,tP={$id:Bk,description:Jk,type:Qk,required:Yk,properties:Xk,additionalProperties:eP};var Fi={};Object.defineProperty(Fi,"__esModule",{value:!0});const Hf=Xd;Hf.code='require("ajv/dist/runtime/uri").default';Fi.default=Hf;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=_t;Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=ie;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});const n=zn,s=Fr,o=mr,a=Ye,i=ie,c=Ve,l=Ae,d=H,h=tP,y=Fi,g=(j,w)=>new RegExp(j,w);g.code="new RegExp";const _=["removeAdditional","useDefaults","coerceTypes"],$=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),m={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},f={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},v=200;function S(j){var w,C,b,u,p,E,M,x,B,K,he,et,Dt,Ut,Vt,Lt,Ft,Ht,Zt,Kt,Gt,Wt,Bt,Jt,Qt;const ct=j.strict,Yt=(w=j.code)===null||w===void 0?void 0:w.optimize,Kr=Yt===!0||Yt===void 0?1:Yt||0,Gr=(b=(C=j.code)===null||C===void 0?void 0:C.regExp)!==null&&b!==void 0?b:g,Js=(u=j.uriResolver)!==null&&u!==void 0?u:y.default;return{strictSchema:(E=(p=j.strictSchema)!==null&&p!==void 0?p:ct)!==null&&E!==void 0?E:!0,strictNumbers:(x=(M=j.strictNumbers)!==null&&M!==void 0?M:ct)!==null&&x!==void 0?x:!0,strictTypes:(K=(B=j.strictTypes)!==null&&B!==void 0?B:ct)!==null&&K!==void 0?K:"log",strictTuples:(et=(he=j.strictTuples)!==null&&he!==void 0?he:ct)!==null&&et!==void 0?et:"log",strictRequired:(Ut=(Dt=j.strictRequired)!==null&&Dt!==void 0?Dt:ct)!==null&&Ut!==void 0?Ut:!1,code:j.code?{...j.code,optimize:Kr,regExp:Gr}:{optimize:Kr,regExp:Gr},loopRequired:(Vt=j.loopRequired)!==null&&Vt!==void 0?Vt:v,loopEnum:(Lt=j.loopEnum)!==null&&Lt!==void 0?Lt:v,meta:(Ft=j.meta)!==null&&Ft!==void 0?Ft:!0,messages:(Ht=j.messages)!==null&&Ht!==void 0?Ht:!0,inlineRefs:(Zt=j.inlineRefs)!==null&&Zt!==void 0?Zt:!0,schemaId:(Kt=j.schemaId)!==null&&Kt!==void 0?Kt:"$id",addUsedSchema:(Gt=j.addUsedSchema)!==null&&Gt!==void 0?Gt:!0,validateSchema:(Wt=j.validateSchema)!==null&&Wt!==void 0?Wt:!0,validateFormats:(Bt=j.validateFormats)!==null&&Bt!==void 0?Bt:!0,unicodeRegExp:(Jt=j.unicodeRegExp)!==null&&Jt!==void 0?Jt:!0,int32range:(Qt=j.int32range)!==null&&Qt!==void 0?Qt:!0,uriResolver:Js}}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:$,es5:C,lines:b}),this.logger=W(w.logger);const u=w.validateFormats;w.validateFormats=!1,this.RULES=(0,o.getRules)(),P.call(this,m,w,"NOT SUPPORTED"),P.call(this,f,w,"DEPRECATED","warn"),this._metaOpts=V.call(this),w.formats&&U.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),w.keywords&&Z.call(this,w.keywords),typeof w.meta=="object"&&this.addMetaSchema(w.meta),A.call(this),w.validateFormats=u}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:w,meta:C,schemaId:b}=this.opts;let u=h;b==="id"&&(u={...h},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(K,he){await p.call(this,K.$schema);const et=this._addSchema(K,he);return et.validate||E.call(this,et)}async function p(K){K&&!this.getSchema(K)&&await u.call(this,{$ref:K},!0)}async function E(K){try{return this._compileSchemaEnv(K)}catch(he){if(!(he instanceof s.default))throw he;return M.call(this,he),await x.call(this,he.missingSchema),E.call(this,K)}}function M({missingSchema:K,missingRef:he}){if(this.refs[K])throw new Error(`AnySchema ${K} is loaded but ${he} cannot be resolved`)}async function x(K){const he=await B.call(this,K);this.refs[K]||await p.call(this,he.$schema),this.refs[K]||this.addSchema(he,K,C)}async function B(K){const he=this._loading[K];if(he)return he;try{return await(this._loading[K]=b(K))}finally{delete this._loading[K]}}}addSchema(w,C,b,u=this.opts.validateSchema){if(Array.isArray(w)){for(const E of w)this.addSchema(E,void 0,b,u);return this}let p;if(typeof w=="object"){const{schemaId:E}=this.opts;if(p=w[E],p!==void 0&&typeof p!="string")throw new Error(`schema ${E} must be string`)}return C=(0,c.normalizeId)(C||p),this._checkUnique(C),this.schemas[C]=this._addSchema(w,b,C,u,!0),this}addMetaSchema(w,C,b=this.opts.validateSchema){return this.addSchema(w,C,!0,b),this}validateSchema(w,C){if(typeof w=="boolean")return!0;let b;if(b=w.$schema,b!==void 0&&typeof b!="string")throw new Error("$schema must be a string");if(b=b||this.opts.defaultMeta||this.defaultMeta(),!b)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const u=this.validate(b,w);if(!u&&C){const p="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(p);else throw new Error(p)}return u}getSchema(w){let C;for(;typeof(C=I.call(this,w))=="string";)w=C;if(C===void 0){const{schemaId:b}=this.opts,u=new a.SchemaEnv({schema:{},schemaId:b});if(C=a.resolveSchema.call(this,u,w),!C)return;this.refs[w]=C}return C.validate||this._compileSchemaEnv(C)}removeSchema(w){if(w instanceof RegExp)return this._removeAllSchemas(this.schemas,w),this._removeAllSchemas(this.refs,w),this;switch(typeof w){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const C=I.call(this,w);return typeof C=="object"&&this._cache.delete(C.schema),delete this.schemas[w],delete this.refs[w],this}case"object":{const C=w;this._cache.delete(C);let b=w[this.opts.schemaId];return b&&(b=(0,c.normalizeId)(b),delete this.schemas[b],delete this.refs[b]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(w){for(const C of w)this.addKeyword(C);return this}addKeyword(w,C){let b;if(typeof w=="string")b=w,typeof C=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),C.keyword=b);else if(typeof w=="object"&&C===void 0){if(C=w,b=C.keyword,Array.isArray(b)&&!b.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(q.call(this,b,C),!C)return(0,d.eachItem)(b,p=>le.call(this,p)),this;ge.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=>le.call(this,p,u):p=>u.type.forEach(E=>le.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 M of p)E=E[M];for(const M in b){const x=b[M];if(typeof x!="object")continue;const{$data:B}=x.definition,K=E[M];B&&K&&(E[M]=je(K))}}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:M}=this.opts;if(typeof w=="object")E=w[M];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof w!="boolean")throw new Error("schema must be object or boolean")}let x=this._cache.get(w);if(x!==void 0)return x;b=(0,c.normalizeId)(E||b);const B=c.getSchemaRefs.call(this,w,b);return x=new a.SchemaEnv({schema:w,schemaId:M,meta:C,baseId:b,localRefs:B}),this._cache.set(x.schema,x),p&&!b.startsWith("#")&&(b&&this._checkUnique(b),this.refs[b]=x),u&&this.validateSchema(w,!0),x}_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 P(j,w,C,b="error"){for(const u in j){const p=u;p in w&&this.logger[b](`${C}: option ${u}. ${j[p]}`)}}function I(j){return j=(0,c.normalizeId)(j),this.schemas[j]||this.refs[j]}function A(){const j=this.opts.schemas;if(j)if(Array.isArray(j))this.addSchema(j);else for(const w in j)this.addSchema(j[w],w)}function U(){for(const j in this.opts.formats){const w=this.opts.formats[j];w&&this.addFormat(j,w)}}function Z(j){if(Array.isArray(j)){this.addVocabulary(j);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const w in j){const C=j[w];C.keyword||(C.keyword=w),this.addKeyword(C)}}function V(){const j={...this.opts};for(const w of _)delete j[w];return j}const L={log(){},warn(){},error(){}};function W(j){if(j===!1)return L;if(j===void 0)return console;if(j.log&&j.warn&&j.error)return j;throw new Error("logger must implement log, warn and error methods")}const ce=/^[a-z_$][a-z0-9_$:-]*$/i;function q(j,w){const{RULES:C}=this;if((0,d.eachItem)(j,b=>{if(C.keywords[b])throw new Error(`Keyword ${b} is already defined`);if(!ce.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 le(j,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:x})=>x===C);if(E||(E={type:C,rules:[]},p.rules.push(E)),p.keywords[j]=!0,!w)return;const M={keyword:j,definition:{...w,type:(0,l.getJSONTypes)(w.type),schemaType:(0,l.getJSONTypes)(w.schemaType)}};w.before?Ce.call(this,E,M,w.before):E.rules.push(M),p.all[j]=M,(b=w.implements)===null||b===void 0||b.forEach(x=>this.addKeyword(x))}function Ce(j,w,C){const b=j.rules.findIndex(u=>u.keyword===C);b>=0?j.rules.splice(b,0,w):(j.rules.push(w),this.logger.warn(`rule ${C} is not defined`))}function ge(j){let{metaSchema:w}=j;w!==void 0&&(j.$data&&this.opts.$data&&(w=je(w)),j.validateSchema=this.compile(w,!0))}const it={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function je(j){return{anyOf:[j,it]}}})(ff);var Hi={},Zi={},Ki={};Object.defineProperty(Ki,"__esModule",{value:!0});const rP={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Ki.default=rP;var _r={};Object.defineProperty(_r,"__esModule",{value:!0});_r.callRef=_r.getValidate=void 0;const nP=Fr,Pl=de,Je=ie,wr=St,Tl=Ye,Kn=H,sP={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:r,it:n}=e,{baseId:s,schemaEnv:o,validateName:a,opts:i,self:c}=n,{root:l}=o;if((r==="#"||r==="#/")&&s===l.baseId)return h();const d=Tl.resolveRef.call(c,l,s,r);if(d===void 0)throw new nP.default(n.opts.uriResolver,s,r);if(d instanceof Tl.SchemaEnv)return y(d);return g(d);function h(){if(o===l)return os(e,a,o,o.$async);const _=t.scopeValue("root",{ref:l});return os(e,(0,Je._)`${_}.validate`,l,l.$async)}function y(_){const $=Zf(e,_);os(e,$,_,_.$async)}function g(_){const $=t.scopeValue("schema",i.code.source===!0?{ref:_,code:(0,Je.stringify)(_)}:{ref:_}),m=t.name("valid"),f=e.subschema({schema:_,dataTypes:[],schemaPath:Je.nil,topSchemaRef:$,errSchemaPath:r},m);e.mergeEvaluated(f),e.ok(m)}}};function Zf(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Je._)`${r.scopeValue("wrapper",{ref:t})}.validate`}_r.getValidate=Zf;function os(e,t,r,n){const{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:c}=o,l=c.passContext?wr.default.this:Je.nil;n?d():h();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");const _=s.let("valid");s.try(()=>{s.code((0,Je._)`await ${(0,Pl.callValidateCode)(e,t,l)}`),g(t),a||s.assign(_,!0)},$=>{s.if((0,Je._)`!(${$} instanceof ${o.ValidationError})`,()=>s.throw($)),y($),a||s.assign(_,!1)}),e.ok(_)}function h(){e.result((0,Pl.callValidateCode)(e,t,l),()=>g(t),()=>y(t))}function y(_){const $=(0,Je._)`${_}.errors`;s.assign(wr.default.vErrors,(0,Je._)`${wr.default.vErrors} === null ? ${$} : ${wr.default.vErrors}.concat(${$})`),s.assign(wr.default.errors,(0,Je._)`${wr.default.vErrors}.length`)}function g(_){var $;if(!o.opts.unevaluated)return;const m=($=r==null?void 0:r.validate)===null||$===void 0?void 0:$.evaluated;if(o.props!==!0)if(m&&!m.dynamicProps)m.props!==void 0&&(o.props=Kn.mergeEvaluated.props(s,m.props,o.props));else{const f=s.var("props",(0,Je._)`${_}.evaluated.props`);o.props=Kn.mergeEvaluated.props(s,f,o.props,Je.Name)}if(o.items!==!0)if(m&&!m.dynamicItems)m.items!==void 0&&(o.items=Kn.mergeEvaluated.items(s,m.items,o.items));else{const f=s.var("items",(0,Je._)`${_}.evaluated.items`);o.items=Kn.mergeEvaluated.items(s,f,o.items,Je.Name)}}}_r.callRef=os;_r.default=sP;Object.defineProperty(Zi,"__esModule",{value:!0});const oP=Ki,aP=_r,iP=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",oP.default,aP.default];Zi.default=iP;var Gi={},Wi={};Object.defineProperty(Wi,"__esModule",{value:!0});const bs=ie,It=bs.operators,Ss={maximum:{okStr:"<=",ok:It.LTE,fail:It.GT},minimum:{okStr:">=",ok:It.GTE,fail:It.LT},exclusiveMaximum:{okStr:"<",ok:It.LT,fail:It.GTE},exclusiveMinimum:{okStr:">",ok:It.GT,fail:It.LTE}},cP={message:({keyword:e,schemaCode:t})=>(0,bs.str)`must be ${Ss[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,bs._)`{comparison: ${Ss[e].okStr}, limit: ${t}}`},lP={keyword:Object.keys(Ss),type:"number",schemaType:"number",$data:!0,error:cP,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,bs._)`${r} ${Ss[t].fail} ${n} || isNaN(${r})`)}};Wi.default=lP;var Bi={};Object.defineProperty(Bi,"__esModule",{value:!0});const dn=ie,uP={message:({schemaCode:e})=>(0,dn.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,dn._)`{multipleOf: ${e}}`},dP={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:uP,code(e){const{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0,dn._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0,dn._)`${a} !== parseInt(${a})`;e.fail$data((0,dn._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};Bi.default=dP;var Ji={},Qi={};Object.defineProperty(Qi,"__esModule",{value:!0});function Kf(e){const t=e.length;let r=0,n=0,s;for(;n=55296&&s<=56319&&n(0,cr._)`{limit: ${e}}`},mP={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:pP,code(e){const{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?cr.operators.GT:cr.operators.LT,a=s.opts.unicode===!1?(0,cr._)`${r}.length`:(0,cr._)`${(0,fP.useFunc)(e.gen,hP.default)}(${r})`;e.fail$data((0,cr._)`${a} ${o} ${n}`)}};Ji.default=mP;var Yi={};Object.defineProperty(Yi,"__esModule",{value:!0});const _P=de,gP=H,Rr=ie,yP={message:({schemaCode:e})=>(0,Rr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Rr._)`{pattern: ${e}}`},vP={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:yP,code(e){const{gen:t,data:r,$data:n,schema:s,schemaCode:o,it:a}=e,i=a.opts.unicodeRegExp?"u":"";if(n){const{regExp:c}=a.opts.code,l=c.code==="new RegExp"?(0,Rr._)`new RegExp`:(0,gP.useFunc)(t,c),d=t.let("valid");t.try(()=>t.assign(d,(0,Rr._)`${l}(${o}, ${i}).test(${r})`),()=>t.assign(d,!1)),e.fail$data((0,Rr._)`!${d}`)}else{const c=(0,_P.usePattern)(e,s);e.fail$data((0,Rr._)`!${c}.test(${r})`)}}};Yi.default=vP;var Xi={};Object.defineProperty(Xi,"__esModule",{value:!0});const fn=ie,$P={message({keyword:e,schemaCode:t}){const r=e==="maxProperties"?"more":"fewer";return(0,fn.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,fn._)`{limit: ${e}}`},wP={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:$P,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?fn.operators.GT:fn.operators.LT;e.fail$data((0,fn._)`Object.keys(${r}).length ${s} ${n}`)}};Xi.default=wP;var ec={};Object.defineProperty(ec,"__esModule",{value:!0});const Yr=de,hn=ie,bP=H,SP={message:({params:{missingProperty:e}})=>(0,hn.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,hn._)`{missingProperty: ${e}}`},EP={keyword:"required",type:"object",schemaType:"array",$data:!0,error:SP,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:_}=e.it;for(const $ of r)if((g==null?void 0:g[$])===void 0&&!_.has($)){const m=a.schemaEnv.baseId+a.errSchemaPath,f=`required property "${$}" is not defined at "${m}" (strictRequired)`;(0,bP.checkStrictMode)(a,f,a.opts.strictRequired)}}function l(){if(c||o)e.block$data(hn.nil,h);else for(const g of r)(0,Yr.checkReportMissingProp)(e,g)}function d(){const g=t.let("missing");if(c||o){const _=t.let("valid",!0);e.block$data(_,()=>y(g,_)),e.ok(_)}else t.if((0,Yr.checkMissingProp)(e,r,g)),(0,Yr.reportMissingProp)(e,g),t.else()}function h(){t.forOf("prop",n,g=>{e.setParams({missingProperty:g}),t.if((0,Yr.noPropertyInData)(t,s,g,i.ownProperties),()=>e.error())})}function y(g,_){e.setParams({missingProperty:g}),t.forOf(g,n,()=>{t.assign(_,(0,Yr.propertyInData)(t,s,g,i.ownProperties)),t.if((0,hn.not)(_),()=>{e.error(),t.break()})},hn.nil)}}};ec.default=EP;var tc={};Object.defineProperty(tc,"__esModule",{value:!0});const pn=ie,kP={message({keyword:e,schemaCode:t}){const r=e==="maxItems"?"more":"fewer";return(0,pn.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,pn._)`{limit: ${e}}`},PP={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:kP,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?pn.operators.GT:pn.operators.LT;e.fail$data((0,pn._)`${r}.length ${s} ${n}`)}};tc.default=PP;var rc={},Mn={};Object.defineProperty(Mn,"__esModule",{value:!0});const Gf=Ds;Gf.code='require("ajv/dist/runtime/equal").default';Mn.default=Gf;Object.defineProperty(rc,"__esModule",{value:!0});const co=Ae,qe=ie,TP=H,RP=Mn,CP={message:({params:{i:e,j:t}})=>(0,qe.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,qe._)`{i: ${e}, j: ${t}}`},NP={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:CP,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,co.getSchemaTypes)(o.items):[];e.block$data(c,d,(0,qe._)`${a} === false`),e.ok(c);function d(){const _=t.let("i",(0,qe._)`${r}.length`),$=t.let("j");e.setParams({i:_,j:$}),t.assign(c,!0),t.if((0,qe._)`${_} > 1`,()=>(h()?y:g)(_,$))}function h(){return l.length>0&&!l.some(_=>_==="object"||_==="array")}function y(_,$){const m=t.name("item"),f=(0,co.checkDataTypes)(l,m,i.opts.strictNumbers,co.DataType.Wrong),v=t.const("indices",(0,qe._)`{}`);t.for((0,qe._)`;${_}--;`,()=>{t.let(m,(0,qe._)`${r}[${_}]`),t.if(f,(0,qe._)`continue`),l.length>1&&t.if((0,qe._)`typeof ${m} == "string"`,(0,qe._)`${m} += "_"`),t.if((0,qe._)`typeof ${v}[${m}] == "number"`,()=>{t.assign($,(0,qe._)`${v}[${m}]`),e.error(),t.assign(c,!1).break()}).code((0,qe._)`${v}[${m}] = ${_}`)})}function g(_,$){const m=(0,TP.useFunc)(t,RP.default),f=t.name("outer");t.label(f).for((0,qe._)`;${_}--;`,()=>t.for((0,qe._)`${$} = ${_}; ${$}--;`,()=>t.if((0,qe._)`${m}(${r}[${_}], ${r}[${$}])`,()=>{e.error(),t.assign(c,!1).break(f)})))}}};rc.default=NP;var nc={};Object.defineProperty(nc,"__esModule",{value:!0});const qo=ie,IP=H,jP=Mn,OP={message:"must be equal to constant",params:({schemaCode:e})=>(0,qo._)`{allowedValue: ${e}}`},AP={keyword:"const",$data:!0,error:OP,code(e){const{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,qo._)`!${(0,IP.useFunc)(t,jP.default)}(${r}, ${s})`):e.fail((0,qo._)`${o} !== ${r}`)}};nc.default=AP;var sc={};Object.defineProperty(sc,"__esModule",{value:!0});const rn=ie,zP=H,MP=Mn,xP={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,rn._)`{allowedValues: ${e}}`},qP={keyword:"enum",schemaType:"array",$data:!0,error:xP,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,zP.useFunc)(t,MP.default));let d;if(i||n)d=t.let("valid"),e.block$data(d,h);else{if(!Array.isArray(s))throw new Error("ajv implementation error");const g=t.const("vSchema",o);d=(0,rn.or)(...s.map((_,$)=>y(g,$)))}e.pass(d);function h(){t.assign(d,!1),t.forOf("v",o,g=>t.if((0,rn._)`${l()}(${r}, ${g})`,()=>t.assign(d,!0).break()))}function y(g,_){const $=s[_];return typeof $=="object"&&$!==null?(0,rn._)`${l()}(${r}, ${g}[${_}])`:(0,rn._)`${r} === ${$}`}}};sc.default=qP;Object.defineProperty(Gi,"__esModule",{value:!0});const DP=Wi,UP=Bi,VP=Ji,LP=Yi,FP=Xi,HP=ec,ZP=tc,KP=rc,GP=nc,WP=sc,BP=[DP.default,UP.default,VP.default,LP.default,FP.default,HP.default,ZP.default,KP.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},GP.default,WP.default];Gi.default=BP;var oc={},Hr={};Object.defineProperty(Hr,"__esModule",{value:!0});Hr.validateAdditionalItems=void 0;const lr=ie,Do=H,JP={message:({params:{len:e}})=>(0,lr.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,lr._)`{limit: ${e}}`},QP={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:JP,code(e){const{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Do.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Wf(e,n)}};function Wf(e,t){const{gen:r,schema:n,data:s,keyword:o,it:a}=e;a.items=!0;const i=r.const("len",(0,lr._)`${s}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,lr._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0,Do.alwaysValidSchema)(a,n)){const l=r.var("valid",(0,lr._)`${i} <= ${t.length}`);r.if((0,lr.not)(l),()=>c(l)),e.ok(l)}function c(l){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:Do.Type.Num},l),a.allErrors||r.if((0,lr.not)(l),()=>r.break())})}}Hr.validateAdditionalItems=Wf;Hr.default=QP;var ac={},Zr={};Object.defineProperty(Zr,"__esModule",{value:!0});Zr.validateTuple=void 0;const Rl=ie,as=H,YP=de,XP={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return Bf(e,"additionalItems",t);r.items=!0,!(0,as.alwaysValidSchema)(r,t)&&e.ok((0,YP.validateArray)(e))}};function Bf(e,t,r=e.schema){const{gen:n,parentSchema:s,data:o,keyword:a,it:i}=e;d(s),i.opts.unevaluated&&r.length&&i.items!==!0&&(i.items=as.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),l=n.const("len",(0,Rl._)`${o}.length`);r.forEach((h,y)=>{(0,as.alwaysValidSchema)(i,h)||(n.if((0,Rl._)`${l} > ${y}`,()=>e.subschema({keyword:a,schemaProp:y,dataProp:y},c)),e.ok(c))});function d(h){const{opts:y,errSchemaPath:g}=i,_=r.length,$=_===h.minItems&&(_===h.maxItems||h[t]===!1);if(y.strictTuples&&!$){const m=`"${a}" is ${_}-tuple, but minItems or maxItems/${t} are not specified or different at path "${g}"`;(0,as.checkStrictMode)(i,m,y.strictTuples)}}}Zr.validateTuple=Bf;Zr.default=XP;Object.defineProperty(ac,"__esModule",{value:!0});const e1=Zr,t1={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,e1.validateTuple)(e,"items")};ac.default=t1;var ic={};Object.defineProperty(ic,"__esModule",{value:!0});const Cl=ie,r1=H,n1=de,s1=Hr,o1={message:({params:{len:e}})=>(0,Cl.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Cl._)`{limit: ${e}}`},a1={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:o1,code(e){const{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=!0,!(0,r1.alwaysValidSchema)(n,t)&&(s?(0,s1.validateAdditionalItems)(e,s):e.ok((0,n1.validateArray)(e)))}};ic.default=a1;var cc={};Object.defineProperty(cc,"__esModule",{value:!0});const st=ie,Gn=H,i1={message:({params:{min:e,max:t}})=>t===void 0?(0,st.str)`must contain at least ${e} valid item(s)`:(0,st.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,st._)`{minContains: ${e}}`:(0,st._)`{minContains: ${e}, maxContains: ${t}}`},c1={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:i1,code(e){const{gen:t,schema:r,parentSchema:n,data:s,it:o}=e;let a,i;const{minContains:c,maxContains:l}=n;o.opts.next?(a=c===void 0?1:c,i=l):a=1;const d=t.const("len",(0,st._)`${s}.length`);if(e.setParams({min:a,max:i}),i===void 0&&a===0){(0,Gn.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0,Gn.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Gn.alwaysValidSchema)(o,r)){let $=(0,st._)`${d} >= ${a}`;i!==void 0&&($=(0,st._)`${$} && ${d} <= ${i}`),e.pass($);return}o.items=!0;const h=t.name("valid");i===void 0&&a===1?g(h,()=>t.if(h,()=>t.break())):a===0?(t.let(h,!0),i!==void 0&&t.if((0,st._)`${s}.length > 0`,y)):(t.let(h,!1),y()),e.result(h,()=>e.reset());function y(){const $=t.name("_valid"),m=t.let("count",0);g($,()=>t.if($,()=>_(m)))}function g($,m){t.forRange("i",0,d,f=>{e.subschema({keyword:"contains",dataProp:f,dataPropType:Gn.Type.Num,compositeRule:!0},$),m()})}function _($){t.code((0,st._)`${$}++`),i===void 0?t.if((0,st._)`${$} >= ${a}`,()=>t.assign(h,!0).break()):(t.if((0,st._)`${$} > ${i}`,()=>t.assign(h,!1).break()),a===1?t.assign(h,!0):t.if((0,st._)`${$} >= ${a}`,()=>t.assign(h,!0)))}}};cc.default=c1;var Jf={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=ie,r=H,n=de;e.error={message:({params:{property:c,depsCount:l,deps:d}})=>{const h=l===1?"property":"properties";return(0,t.str)`must have ${h} ${d} when property ${c} is present`},params:({params:{property:c,depsCount:l,deps:d,missingProperty:h}})=>(0,t._)`{property: ${c}, + missingProperty: ${h}, + depsCount: ${l}, + deps: ${d}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(c){const[l,d]=o(c);a(c,l),i(c,d)}};function o({schema:c}){const l={},d={};for(const h in c){if(h==="__proto__")continue;const y=Array.isArray(c[h])?l:d;y[h]=c[h]}return[l,d]}function a(c,l=c.schema){const{gen:d,data:h,it:y}=c;if(Object.keys(l).length===0)return;const g=d.let("missing");for(const _ in l){const $=l[_];if($.length===0)continue;const m=(0,n.propertyInData)(d,h,_,y.opts.ownProperties);c.setParams({property:_,depsCount:$.length,deps:$.join(", ")}),y.allErrors?d.if(m,()=>{for(const f of $)(0,n.checkReportMissingProp)(c,f)}):(d.if((0,t._)`${m} && (${(0,n.checkMissingProp)(c,$,g)})`),(0,n.reportMissingProp)(c,g),d.else())}}e.validatePropertyDeps=a;function i(c,l=c.schema){const{gen:d,data:h,keyword:y,it:g}=c,_=d.name("valid");for(const $ in l)(0,r.alwaysValidSchema)(g,l[$])||(d.if((0,n.propertyInData)(d,h,$,g.opts.ownProperties),()=>{const m=c.subschema({keyword:y,schemaProp:$},_);c.mergeValidEvaluated(m,_)},()=>d.var(_,!0)),c.ok(_))}e.validateSchemaDeps=i,e.default=s})(Jf);var lc={};Object.defineProperty(lc,"__esModule",{value:!0});const Qf=ie,l1=H,u1={message:"property name must be valid",params:({params:e})=>(0,Qf._)`{propertyName: ${e.propertyName}}`},d1={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:u1,code(e){const{gen:t,schema:r,data:n,it:s}=e;if((0,l1.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,Qf.not)(o),()=>{e.error(!0),s.allErrors||t.break()})}),e.ok(o)}};lc.default=d1;var Ws={};Object.defineProperty(Ws,"__esModule",{value:!0});const Wn=de,ft=ie,f1=St,Bn=H,h1={message:"must NOT have additional properties",params:({params:e})=>(0,ft._)`{additionalProperty: ${e.additionalProperty}}`},p1={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:h1,code(e){const{gen:t,schema:r,parentSchema:n,data:s,errsCount:o,it:a}=e;if(!o)throw new Error("ajv implementation error");const{allErrors:i,opts:c}=a;if(a.props=!0,c.removeAdditional!=="all"&&(0,Bn.alwaysValidSchema)(a,r))return;const l=(0,Wn.allSchemaProperties)(n.properties),d=(0,Wn.allSchemaProperties)(n.patternProperties);h(),e.ok((0,ft._)`${o} === ${f1.default.errors}`);function h(){t.forIn("key",s,m=>{!l.length&&!d.length?_(m):t.if(y(m),()=>_(m))})}function y(m){let f;if(l.length>8){const v=(0,Bn.schemaRefOrVal)(a,n.properties,"properties");f=(0,Wn.isOwnProperty)(t,v,m)}else l.length?f=(0,ft.or)(...l.map(v=>(0,ft._)`${m} === ${v}`)):f=ft.nil;return d.length&&(f=(0,ft.or)(f,...d.map(v=>(0,ft._)`${(0,Wn.usePattern)(e,v)}.test(${m})`))),(0,ft.not)(f)}function g(m){t.code((0,ft._)`delete ${s}[${m}]`)}function _(m){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){g(m);return}if(r===!1){e.setParams({additionalProperty:m}),e.error(),i||t.break();return}if(typeof r=="object"&&!(0,Bn.alwaysValidSchema)(a,r)){const f=t.name("valid");c.removeAdditional==="failing"?($(m,f,!1),t.if((0,ft.not)(f),()=>{e.reset(),g(m)})):($(m,f),i||t.if((0,ft.not)(f),()=>t.break()))}}function $(m,f,v){const S={keyword:"additionalProperties",dataProp:m,dataPropType:Bn.Type.Str};v===!1&&Object.assign(S,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(S,f)}}};Ws.default=p1;var uc={};Object.defineProperty(uc,"__esModule",{value:!0});const m1=_t,Nl=de,lo=H,Il=Ws,_1={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&&Il.default.code(new m1.KeywordCxt(o,Il.default,"additionalProperties"));const a=(0,Nl.allSchemaProperties)(r);for(const h of a)o.definedProperties.add(h);o.opts.unevaluated&&a.length&&o.props!==!0&&(o.props=lo.mergeEvaluated.props(t,(0,lo.toHash)(a),o.props));const i=a.filter(h=>!(0,lo.alwaysValidSchema)(o,r[h]));if(i.length===0)return;const c=t.name("valid");for(const h of i)l(h)?d(h):(t.if((0,Nl.propertyInData)(t,s,h,o.opts.ownProperties)),d(h),o.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(h),e.ok(c);function l(h){return o.opts.useDefaults&&!o.compositeRule&&r[h].default!==void 0}function d(h){e.subschema({keyword:"properties",schemaProp:h,dataProp:h},c)}}};uc.default=_1;var dc={};Object.defineProperty(dc,"__esModule",{value:!0});const jl=de,Jn=ie,Ol=H,Al=H,g1={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,jl.allSchemaProperties)(r),c=i.filter($=>(0,Ol.alwaysValidSchema)(o,r[$]));if(i.length===0||c.length===i.length&&(!o.opts.unevaluated||o.props===!0))return;const l=a.strictSchema&&!a.allowMatchingProperties&&s.properties,d=t.name("valid");o.props!==!0&&!(o.props instanceof Jn.Name)&&(o.props=(0,Al.evaluatedPropsToName)(t,o.props));const{props:h}=o;y();function y(){for(const $ of i)l&&g($),o.allErrors?_($):(t.var(d,!0),_($),t.if(d))}function g($){for(const m in l)new RegExp($).test(m)&&(0,Ol.checkStrictMode)(o,`property ${m} matches pattern ${$} (use allowMatchingProperties)`)}function _($){t.forIn("key",n,m=>{t.if((0,Jn._)`${(0,jl.usePattern)(e,$)}.test(${m})`,()=>{const f=c.includes($);f||e.subschema({keyword:"patternProperties",schemaProp:$,dataProp:m,dataPropType:Al.Type.Str},d),o.opts.unevaluated&&h!==!0?t.assign((0,Jn._)`${h}[${m}]`,!0):!f&&!o.allErrors&&t.if((0,Jn.not)(d),()=>t.break())})})}}};dc.default=g1;var fc={};Object.defineProperty(fc,"__esModule",{value:!0});const y1=H,v1={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,y1.alwaysValidSchema)(n,r)){e.fail();return}const s=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},s),e.failResult(s,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};fc.default=v1;var hc={};Object.defineProperty(hc,"__esModule",{value:!0});const $1=de,w1={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:$1.validateUnion,error:{message:"must match a schema in anyOf"}};hc.default=w1;var pc={};Object.defineProperty(pc,"__esModule",{value:!0});const is=ie,b1=H,S1={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,is._)`{passingSchemas: ${e.passing}}`},E1={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:S1,code(e){const{gen:t,schema:r,parentSchema:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;const o=r,a=t.let("valid",!1),i=t.let("passing",null),c=t.name("_valid");e.setParams({passing:i}),t.block(l),e.result(a,()=>e.reset(),()=>e.error(!0));function l(){o.forEach((d,h)=>{let y;(0,b1.alwaysValidSchema)(s,d)?t.var(c,!0):y=e.subschema({keyword:"oneOf",schemaProp:h,compositeRule:!0},c),h>0&&t.if((0,is._)`${c} && ${a}`).assign(a,!1).assign(i,(0,is._)`[${i}, ${h}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,h),y&&e.mergeEvaluated(y,is.Name)})})}}};pc.default=E1;var mc={};Object.defineProperty(mc,"__esModule",{value:!0});const k1=H,P1={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,k1.alwaysValidSchema)(n,o))return;const i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i)})}};mc.default=P1;var _c={};Object.defineProperty(_c,"__esModule",{value:!0});const Es=ie,Yf=H,T1={message:({params:e})=>(0,Es.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,Es._)`{failingKeyword: ${e.ifClause}}`},R1={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:T1,code(e){const{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,Yf.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const s=zl(n,"then"),o=zl(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,Es.not)(i),l("else"));e.pass(a,()=>e.error(!0));function c(){const d=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},i);e.mergeEvaluated(d)}function l(d,h){return()=>{const y=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(y,a),h?t.assign(h,(0,Es._)`${d}`):e.setParams({ifClause:d})}}}};function zl(e,t){const r=e.schema[t];return r!==void 0&&!(0,Yf.alwaysValidSchema)(e,r)}_c.default=R1;var gc={};Object.defineProperty(gc,"__esModule",{value:!0});const C1=H,N1={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,C1.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};gc.default=N1;Object.defineProperty(oc,"__esModule",{value:!0});const I1=Hr,j1=ac,O1=Zr,A1=ic,z1=cc,M1=Jf,x1=lc,q1=Ws,D1=uc,U1=dc,V1=fc,L1=hc,F1=pc,H1=mc,Z1=_c,K1=gc;function G1(e=!1){const t=[V1.default,L1.default,F1.default,H1.default,Z1.default,K1.default,x1.default,q1.default,M1.default,D1.default,U1.default];return e?t.push(j1.default,A1.default):t.push(I1.default,O1.default),t.push(z1.default),t}oc.default=G1;var yc={},vc={};Object.defineProperty(vc,"__esModule",{value:!0});const Ie=ie,W1={message:({schemaCode:e})=>(0,Ie.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,Ie._)`{format: ${e}}`},B1={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:W1,code(e,t){const{gen:r,data:n,$data:s,schema:o,schemaCode:a,it:i}=e,{opts:c,errSchemaPath:l,schemaEnv:d,self:h}=i;if(!c.validateFormats)return;s?y():g();function y(){const _=r.scopeValue("formats",{ref:h.formats,code:c.code.formats}),$=r.const("fDef",(0,Ie._)`${_}[${a}]`),m=r.let("fType"),f=r.let("format");r.if((0,Ie._)`typeof ${$} == "object" && !(${$} instanceof RegExp)`,()=>r.assign(m,(0,Ie._)`${$}.type || "string"`).assign(f,(0,Ie._)`${$}.validate`),()=>r.assign(m,(0,Ie._)`"string"`).assign(f,$)),e.fail$data((0,Ie.or)(v(),S()));function v(){return c.strictSchema===!1?Ie.nil:(0,Ie._)`${a} && !${f}`}function S(){const R=d.$async?(0,Ie._)`(${$}.async ? await ${f}(${n}) : ${f}(${n}))`:(0,Ie._)`${f}(${n})`,P=(0,Ie._)`(typeof ${f} == "function" ? ${R} : ${f}.test(${n}))`;return(0,Ie._)`${f} && ${f} !== true && ${m} === ${t} && !${P}`}}function g(){const _=h.formats[o];if(!_){v();return}if(_===!0)return;const[$,m,f]=S(_);$===t&&e.pass(R());function v(){if(c.strictSchema===!1){h.logger.warn(P());return}throw new Error(P());function P(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function S(P){const I=P instanceof RegExp?(0,Ie.regexpCode)(P):c.code.formats?(0,Ie._)`${c.code.formats}${(0,Ie.getProperty)(o)}`:void 0,A=r.scopeValue("formats",{key:o,ref:P,code:I});return typeof P=="object"&&!(P instanceof RegExp)?[P.type||"string",P.validate,(0,Ie._)`${A}.validate`]:["string",P,A]}function R(){if(typeof _=="object"&&!(_ instanceof RegExp)&&_.async){if(!d.$async)throw new Error("async format in sync schema");return(0,Ie._)`await ${f}(${n})`}return typeof m=="function"?(0,Ie._)`${f}(${n})`:(0,Ie._)`${f}.test(${n})`}}}};vc.default=B1;Object.defineProperty(yc,"__esModule",{value:!0});const J1=vc,Q1=[J1.default];yc.default=Q1;var xr={};Object.defineProperty(xr,"__esModule",{value:!0});xr.contentVocabulary=xr.metadataVocabulary=void 0;xr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];xr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(Hi,"__esModule",{value:!0});const Y1=Zi,X1=Gi,eT=oc,tT=yc,Ml=xr,rT=[Y1.default,X1.default,(0,eT.default)(),tT.default,Ml.metadataVocabulary,Ml.contentVocabulary];Hi.default=rT;var $c={},Bs={};Object.defineProperty(Bs,"__esModule",{value:!0});Bs.DiscrError=void 0;var xl;(function(e){e.Tag="tag",e.Mapping="mapping"})(xl||(Bs.DiscrError=xl={}));Object.defineProperty($c,"__esModule",{value:!0});const kr=ie,Uo=Bs,ql=Ye,nT=Fr,sT=H,oT={message:({params:{discrError:e,tagName:t}})=>e===Uo.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,kr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},aT={keyword:"discriminator",type:"object",schemaType:"object",error:oT,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,kr._)`${r}${(0,kr.getProperty)(i)}`);t.if((0,kr._)`typeof ${l} == "string"`,()=>d(),()=>e.error(!1,{discrError:Uo.DiscrError.Tag,tag:l,tagName:i})),e.ok(c);function d(){const g=y();t.if(!1);for(const _ in g)t.elseIf((0,kr._)`${l} === ${_}`),t.assign(c,h(g[_]));t.else(),e.error(!1,{discrError:Uo.DiscrError.Mapping,tag:l,tagName:i}),t.endIf()}function h(g){const _=t.name("valid"),$=e.subschema({keyword:"oneOf",schemaProp:g},_);return e.mergeEvaluated($,kr.Name),_}function y(){var g;const _={},$=f(s);let m=!0;for(let R=0;Rthis.addVocabulary(_)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const _=this.opts.$data?this.$dataMetaSchema(o,a):o;this.addMetaSchema(_,i,!1),this.refs["http://json-schema.org/schema"]=i}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(i)?i:void 0)}}t.Ajv=c,e.exports=t=c,e.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var l=_t;Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var d=ie;Object.defineProperty(t,"_",{enumerable:!0,get:function(){return d._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return d.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return d.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return d.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return d.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return d.CodeGen}});var h=zn;Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return h.default}});var y=Fr;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return y.default}})})(Oo,Oo.exports);var pT=Oo.exports;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;const t=pT,r=ie,n=r.operators,s={formatMaximum:{okStr:"<=",ok:n.LTE,fail:n.GT},formatMinimum:{okStr:">=",ok:n.GTE,fail:n.LT},formatExclusiveMaximum:{okStr:"<",ok:n.LT,fail:n.GTE},formatExclusiveMinimum:{okStr:">",ok:n.GT,fail:n.LTE}},o={message:({keyword:i,schemaCode:c})=>(0,r.str)`should be ${s[i].okStr} ${c}`,params:({keyword:i,schemaCode:c})=>(0,r._)`{comparison: ${s[i].okStr}, limit: ${c}}`};e.formatLimitDefinition={keyword:Object.keys(s),type:"string",schemaType:"string",$data:!0,error:o,code(i){const{gen:c,data:l,schemaCode:d,keyword:h,it:y}=i,{opts:g,self:_}=y;if(!g.validateFormats)return;const $=new t.KeywordCxt(y,_.RULES.all.format.definition,"format");$.$data?m():f();function m(){const S=c.scopeValue("formats",{ref:_.formats,code:g.code.formats}),R=c.const("fmt",(0,r._)`${S}[${$.schemaCode}]`);i.fail$data((0,r.or)((0,r._)`typeof ${R} != "object"`,(0,r._)`${R} instanceof RegExp`,(0,r._)`typeof ${R}.compare != "function"`,v(R)))}function f(){const S=$.schema,R=_.formats[S];if(!R||R===!0)return;if(typeof R!="object"||R instanceof RegExp||typeof R.compare!="function")throw new Error(`"${h}": format "${S}" does not define "compare" function`);const P=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(v(P))}function v(S){return(0,r._)`${S}.compare(${l}, ${d}) ${s[h].fail} 0`}},dependencies:["format"]};const a=i=>(i.addKeyword(e.formatLimitDefinition),i);e.default=a})(df);(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r=uf,n=df,s=ie,o=new s.Name("fullFormats"),a=new s.Name("fastFormats"),i=(l,d={keywords:!0})=>{if(Array.isArray(d))return c(l,d,r.fullFormats,o),l;const[h,y]=d.mode==="fast"?[r.fastFormats,a]:[r.fullFormats,o],g=d.formats||r.formatNames;return c(l,g,h,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,h,y){var g,_;(g=(_=l.opts.code).formats)!==null&&g!==void 0||(_.formats=(0,s._)`require("ajv-formats/dist/formats").${y}`);for(const $ of d)l.addFormat($,h[$])}e.exports=t=i,Object.defineProperty(t,"__esModule",{value:!0}),t.default=i})(jo,jo.exports);var mT=jo.exports;const _T=Wl(mT);function gT(){const e=new rE({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return _T(e),e}class yT{constructor(t){this._ajv=t??gT()}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 vT{constructor(t){this._client=t}async*callToolStream(t,r=dr,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 Y(re.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 Y(re.InvalidParams,`Structured content does not match the tool's output schema: ${d.errorMessage}`)};return}}catch(d){if(d instanceof Y){yield{type:"error",error:d};return}yield{type:"error",error:new Y(re.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 $T(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 wT(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 cs(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&&cs(o,r[s])}}if(Array.isArray(e.anyOf))for(const r of e.anyOf)typeof r!="boolean"&&cs(r,t);if(Array.isArray(e.oneOf))for(const r of e.oneOf)typeof r!="boolean"&&cs(r,t)}}function bT(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};const t=e.form!==void 0,r=e.url!==void 0;return{supportsFormMode:t||!t&&!r,supportsUrlMode:r}}class ST extends od{constructor(t,r){super(r),this._clientInfo=t,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=(r==null?void 0:r.capabilities)??{},this._jsonSchemaValidator=(r==null?void 0:r.jsonSchemaValidator)??new yT,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",xa,t.tools,async()=>(await this.listTools()).tools),t.prompts&&((o=(s=this._serverCapabilities)==null?void 0:s.prompts)!=null&&o.listChanged)&&this._setupListChangedHandler("prompts",Aa,t.prompts,async()=>(await this.listPrompts()).prompts),t.resources&&((i=(a=this._serverCapabilities)==null?void 0:a.resources)!=null&&i.listChanged)&&this._setupListChangedHandler("resources",Ca,t.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new vT(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Cv(this._capabilities,t)}setRequestHandler(t,r){const n=nd(t),s=n==null?void 0:n.method;if(!s)throw new Error("Schema is missing a method literal");const o=sd(s);if(typeof o!="string")throw new Error("Schema method literal must be a string");const a=o;if(a==="elicitation/create"){const i=async(c,l)=>{var v,S;const d=jt(ed,c);if(!d.success){const R=d.error instanceof Error?d.error.message:String(d.error);throw new Y(re.InvalidParams,`Invalid elicitation request: ${R}`)}const{params:h}=d.data;h.mode=h.mode??"form";const{supportsFormMode:y,supportsUrlMode:g}=bT(this._capabilities.elicitation);if(h.mode==="form"&&!y)throw new Y(re.InvalidParams,"Client does not support form-mode elicitation requests");if(h.mode==="url"&&!g)throw new Y(re.InvalidParams,"Client does not support URL-mode elicitation requests");const _=await Promise.resolve(r(c,l));if(h.task){const R=jt(gn,_);if(!R.success){const P=R.error instanceof Error?R.error.message:String(R.error);throw new Y(re.InvalidParams,`Invalid task creation result: ${P}`)}return R.data}const $=jt(td,_);if(!$.success){const R=$.error instanceof Error?$.error.message:String($.error);throw new Y(re.InvalidParams,`Invalid elicitation result: ${R}`)}const m=$.data,f=h.mode==="form"?h.requestedSchema:void 0;if(h.mode==="form"&&m.action==="accept"&&m.content&&f&&(S=(v=this._capabilities.elicitation)==null?void 0:v.form)!=null&&S.applyDefaults)try{cs(f,m.content)}catch{}return m};return super.setRequestHandler(t,i)}if(a==="sampling/createMessage"){const i=async(c,l)=>{const d=jt(qa,c);if(!d.success){const m=d.error instanceof Error?d.error.message:String(d.error);throw new Y(re.InvalidParams,`Invalid sampling request: ${m}`)}const{params:h}=d.data,y=await Promise.resolve(r(c,l));if(h.task){const m=jt(gn,y);if(!m.success){const f=m.error instanceof Error?m.error.message:String(m.error);throw new Y(re.InvalidParams,`Invalid task creation result: ${f}`)}return m.data}const _=h.tools||h.toolChoice?Xu:Yu,$=jt(_,y);if(!$.success){const m=$.error instanceof Error?$.error.message:String($.error);throw new Y(re.InvalidParams,`Invalid sampling result: ${m}`)}return $.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:As,capabilities:this._capabilities,clientInfo:this._clientInfo}},Mu,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!sy.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;$T((n=(r=this._serverCapabilities)==null?void 0:r.tasks)==null?void 0:n.requests,t,"Server")}assertTaskHandlerCapability(t){var r;this._capabilities&&wT((r=this._capabilities.tasks)==null?void 0:r.requests,t,"Client")}async ping(t){return this.request({method:"ping"},Pr,t)}async complete(t,r){return this.request({method:"completion/complete",params:t},rd,r)}async setLoggingLevel(t,r){return this.request({method:"logging/setLevel",params:{level:t}},Pr,r)}async getPrompt(t,r){return this.request({method:"prompts/get",params:t},Wu,r)}async listPrompts(t,r){return this.request({method:"prompts/list",params:t},Na,r)}async listResources(t,r){return this.request({method:"resources/list",params:t},ka,r)}async listResourceTemplates(t,r){return this.request({method:"resources/templates/list",params:t},Pa,r)}async readResource(t,r){return this.request({method:"resources/read",params:t},Ra,r)}async subscribeResource(t,r){return this.request({method:"resources/subscribe",params:t},Pr,r)}async unsubscribeResource(t,r){return this.request({method:"resources/unsubscribe",params:t},Pr,r)}async callTool(t,r=dr,n){if(this.isToolTaskRequired(t.name))throw new Y(re.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 Y(re.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 Y(re.InvalidParams,`Structured content does not match the tool's output schema: ${a.errorMessage}`)}catch(a){throw a instanceof Y?a:new Y(re.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},Ma,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(t,r,n,s){const o=Zy.safeParse(n);if(!o.success)throw new Error(`Invalid ${t} listChanged options: ${o.error.message}`);if(typeof n.onChanged!="function")throw new Error(`Invalid ${t} listChanged options: onChanged must be a function`);const{autoRefresh:a,debounceMs:i}=o.data,{onChanged:c}=n,l=async()=>{if(!a){c(null,null);return}try{const h=await s();c(null,h)}catch(h){const y=h instanceof Error?h:new Error(String(h));c(y,null)}},d=()=>{if(i){const h=this._listChangedDebounceTimers.get(t);h&&clearTimeout(h);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 wc={};/*! + * content-type + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */var Dl=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,ET=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,Xf=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,kT=/\\([\u000b\u0020-\u00ff])/g,PT=/([\\"])/g,eh=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;wc.format=TT;wc.parse=RT;function TT(e){if(!e||typeof e!="object")throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!eh.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&&!ET.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(PT,"\\$1")+'"'}function IT(e){this.parameters=Object.create(null),this.type=e}function jT(e){if(e)try{return wc.parse(e).type}catch{const t=(e.split(";",1)[0]??"").trim().toLowerCase();return t===""||e.slice(t.length).includes(",")?void 0:t}}function Vo(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function OT(e=fetch,t){return t?async(r,n)=>{const s={...t,...n,headers:n!=null&&n.headers?{...Vo(t.headers),...Vo(n.headers)}:t.headers};return e(r,s)}:e}let bc;bc=globalThis.crypto;async function AT(e){return(await bc).getRandomValues(new Uint8Array(e))}async function zT(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 MT(e),r=await xT(t);return{code_verifier:t,code_challenge:r}}const De=dg().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:ry.custom,message:"URL must be parseable",fatal:!0}),Xh}).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"}),DT=Le({resource:k().url(),authorization_servers:D(De).optional(),jwks_uri:k().url().optional(),scopes_supported:D(k()).optional(),bearer_methods_supported:D(k()).optional(),resource_signing_alg_values_supported:D(k()).optional(),resource_name:k().optional(),resource_documentation:k().optional(),resource_policy_uri:k().url().optional(),resource_tos_uri:k().url().optional(),tls_client_certificate_bound_access_tokens:me().optional(),authorization_details_types_supported:D(k()).optional(),dpop_signing_alg_values_supported:D(k()).optional(),dpop_bound_access_tokens_required:me().optional()}),th=Le({issuer:k(),authorization_endpoint:De,token_endpoint:De,registration_endpoint:De.optional(),scopes_supported:D(k()).optional(),response_types_supported:D(k()),response_modes_supported:D(k()).optional(),grant_types_supported:D(k()).optional(),token_endpoint_auth_methods_supported:D(k()).optional(),token_endpoint_auth_signing_alg_values_supported:D(k()).optional(),service_documentation:De.optional(),revocation_endpoint:De.optional(),revocation_endpoint_auth_methods_supported:D(k()).optional(),revocation_endpoint_auth_signing_alg_values_supported:D(k()).optional(),introspection_endpoint:k().optional(),introspection_endpoint_auth_methods_supported:D(k()).optional(),introspection_endpoint_auth_signing_alg_values_supported:D(k()).optional(),code_challenge_methods_supported:D(k()).optional(),client_id_metadata_document_supported:me().optional()}),UT=Le({issuer:k(),authorization_endpoint:De,token_endpoint:De,userinfo_endpoint:De.optional(),jwks_uri:De,registration_endpoint:De.optional(),scopes_supported:D(k()).optional(),response_types_supported:D(k()),response_modes_supported:D(k()).optional(),grant_types_supported:D(k()).optional(),acr_values_supported:D(k()).optional(),subject_types_supported:D(k()),id_token_signing_alg_values_supported:D(k()),id_token_encryption_alg_values_supported:D(k()).optional(),id_token_encryption_enc_values_supported:D(k()).optional(),userinfo_signing_alg_values_supported:D(k()).optional(),userinfo_encryption_alg_values_supported:D(k()).optional(),userinfo_encryption_enc_values_supported:D(k()).optional(),request_object_signing_alg_values_supported:D(k()).optional(),request_object_encryption_alg_values_supported:D(k()).optional(),request_object_encryption_enc_values_supported:D(k()).optional(),token_endpoint_auth_methods_supported:D(k()).optional(),token_endpoint_auth_signing_alg_values_supported:D(k()).optional(),display_values_supported:D(k()).optional(),claim_types_supported:D(k()).optional(),claims_supported:D(k()).optional(),service_documentation:k().optional(),claims_locales_supported:D(k()).optional(),ui_locales_supported:D(k()).optional(),claims_parameter_supported:me().optional(),request_parameter_supported:me().optional(),request_uri_parameter_supported:me().optional(),require_request_uri_registration:me().optional(),op_policy_uri:De.optional(),op_tos_uri:De.optional(),client_id_metadata_document_supported:me().optional()}),VT=O({...UT.shape,...th.pick({code_challenge_methods_supported:!0}).shape}),LT=O({access_token:k(),id_token:k().optional(),token_type:k(),expires_in:ny().optional(),scope:k().optional(),refresh_token:k().optional()}).strip(),FT=O({error:k(),error_description:k().optional(),error_uri:k().optional()}),Ul=De.optional().or(N("").transform(()=>{})),HT=O({redirect_uris:D(De),token_endpoint_auth_method:k().optional(),grant_types:D(k()).optional(),response_types:D(k()).optional(),client_name:k().optional(),client_uri:De.optional(),logo_uri:Ul,scope:k().optional(),contacts:D(k()).optional(),tos_uri:Ul,policy_uri:k().optional(),jwks_uri:De.optional(),jwks:da().optional(),software_id:k().optional(),software_version:k().optional(),software_statement:k().optional()}).strip(),ZT=O({client_id:k(),client_secret:k().optional(),client_id_issued_at:oe().optional(),client_secret_expires_at:oe().optional()}).strip(),KT=HT.merge(ZT);O({error:k(),error_description:k().optional()}).strip();O({token:k(),token_type_hint:k().optional()}).strip();function GT(e){const t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function WT({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 aR(e,t,r,n){const s=new URL(e),o=(n==null?void 0:n.protocolVersion)??As;let a;if(n!=null&&n.metadataUrl)a=new URL(n.metadataUrl);else{const c=sR(t,s.pathname);a=new URL(c,(n==null?void 0:n.metadataServerUrl)??s),a.search=s.search}let i=await Ll(a,o,r);if(!(n!=null&&n.metadataUrl)&&oR(i,s.pathname)){const c=new URL(`/.well-known/${t}`,s);i=await Ll(c,o,r)}return i}function iR(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 sh(e,{fetchFn:t=fetch,protocolVersion:r=As}={}){var o;const n={"MCP-Protocol-Version":r,Accept:"application/json"},s=iR(e);for(const{url:a,type:i}of s){const c=await Sc(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"?th.parse(await c.json()):VT.parse(await c.json())}}}async function cR(e,t){let r,n;try{r=await nh(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 sh(n,{fetchFn:t==null?void 0:t.fetchFn});return{authorizationServerUrl:n,authorizationServerMetadata:s,resourceMetadata:r}}async function lR(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(uo))throw new Error(`Incompatible auth server: does not support response type ${uo}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(fo))throw new Error(`Incompatible auth server: does not support code challenge method ${fo}`)}else i=new URL("/authorize",e);const c=await qT(),l=c.code_verifier,d=c.code_challenge;return i.searchParams.set("response_type",uo),i.searchParams.set("client_id",r.client_id),i.searchParams.set("code_challenge",d),i.searchParams.set("code_challenge_method",fo),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 uR(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}async function oh(e,{metadata:t,tokenRequestParams:r,clientInformation:n,addClientAuthentication:s,resource:o,fetchFn:a}){const i=t!=null&&t.token_endpoint?new URL(t.token_endpoint):new URL("/token",e),c=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(o&&r.set("resource",o.href),s)await s(c,r,i,t);else if(n){const d=(t==null?void 0:t.token_endpoint_auth_methods_supported)??[],h=QT(n,d);YT(h,n,c,r)}const l=await(a??fetch)(i,{method:"POST",headers:c,body:r});if(!l.ok)throw await rh(l);return LT.parse(await l.json())}async function dR(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 oh(e,{metadata:t,tokenRequestParams:i,clientInformation:r,addClientAuthentication:o,resource:s,fetchFn:a});return{refresh_token:n,...c}}async function fR(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=uR(s,l,e.redirectUrl)}const c=await e.clientInformation();return oh(t,{metadata:r,tokenRequestParams:i,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:n,fetchFn:o})}async function hR(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 rh(a);return KT.parse(await a.json())}class mo 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 Fl=10,pR=13,rr=32;function _o(e){}function mR(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=_o,onError:r=_o,onRetry:n=_o,onComment:s,maxBufferSize:o}=e,a=[];let i=0,c=!0,l,d="",h=0,y,g=!1;function _(P){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,P.charCodeAt(0)===239&&P.charCodeAt(1)===187&&P.charCodeAt(2)===191&&(P=P.slice(3))),a.length===0){const U=m(P);U!==""&&(a.push(U),i=U.length),$();return}if(P.indexOf(` +`)===-1&&P.indexOf("\r")===-1){a.push(P),i+=P.length,$();return}a.push(P);const I=a.join("");a.length=0,i=0;const A=m(I);A!==""&&(a.push(A),i=A.length),$()}function $(){o!==void 0&&(i+d.length<=o||(g=!0,a.length=0,i=0,l=void 0,d="",h=0,y=void 0,r(new mo(`Buffered data exceeded max buffer size of ${o} characters`,{type:"max-buffer-size-exceeded"}))))}function m(P){let I=0;if(P.indexOf("\r")===-1){let A=P.indexOf(` +`,I);for(;A!==-1;){if(I===A){h>0&&t({id:l,event:y,data:d}),l=void 0,d="",h=0,y=void 0,I=A+1,A=P.indexOf(` +`,I);continue}const U=P.charCodeAt(I);if(Hl(P,I,U)){const Z=P.charCodeAt(I+5)===rr?I+6:I+5,V=P.slice(Z,A);if(h===0&&P.charCodeAt(A+1)===Fl){t({id:l,event:y,data:V}),l=void 0,d="",y=void 0,I=A+2,A=P.indexOf(` +`,I);continue}d=h===0?V:`${d} +${V}`,h++}else Zl(P,I,U)?y=P.slice(P.charCodeAt(I+6)===rr?I+7:I+6,A)||void 0:f(P,I,A);I=A+1,A=P.indexOf(` +`,I)}return P.slice(I)}for(;I20?`${P.slice(0,20)}…`:P}"`,{type:"unknown-field",field:P,value:I,line:A}));break}}function S(){h>0&&t({id:l,event:y,data:d}),l=void 0,d="",h=0,y=void 0}function R(P={}){if(P.consume&&a.length>0){const I=a.join("");f(I,0,I.length)}c=!0,l=void 0,d="",h=0,y=void 0,a.length=0,i=0,g=!1}return{feed:_,reset:R}}function Hl(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 _R extends TransformStream{constructor({onError:t,onRetry:r,onComment:n,maxBufferSize:s}={}){let o;super({start(a){o=mR({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 gR={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Sr extends Error{constructor(t,r){super(`Streamable HTTP error: ${r}`),this.code=t}}class yR{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=OT(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)??gR}async _authThenStart(){var r;if(!this._authProvider)throw new br("No auth provider");let t;try{t=await Qn(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 br;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=Vo((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 Sr(i.status,`Failed to open SSE stream: ${i.statusText}`)}this._handleSseStream(i.body,t,!0)}catch(a){throw(o=this.onerror)==null||o.call(this,a),a}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const r=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,s=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(n,t),s)}_scheduleReconnection(t,r=0){var o;const n=this._reconnectionOptions.maxRetries;if(r>=n){(o=this.onerror)==null||o.call(this,new Error(`Maximum reconnection attempts (${n}) exceeded.`));return}const s=this._getNextReconnectionDelay(r);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(a=>{var i;(i=this.onerror)==null||i.call(this,new Error(`Failed to reconnect SSE stream: ${a instanceof Error?a.message:String(a)}`)),this._scheduleReconnection(t,r+1)})},s)}_handleSseStream(t,r,n){if(!t)return;const{onresumptiontoken:s,replayMessageId:o}=r;let a,i=!1,c=!1;(async()=>{var d,h,y,g;try{const _=t.pipeThrough(new TextDecoderStream).pipeThrough(new _R({onRetry:f=>{this._serverRetryMs=f}})).getReader();for(;;){const{value:f,done:v}=await _.read();if(v)break;if(f.id&&(a=f.id,i=!0,s==null||s(f.id)),!!f.data&&(!f.event||f.event==="message"))try{const S=Yn.parse(JSON.parse(f.data));Xr(S)&&(c=!0,o!==void 0&&(S.id=o)),(d=this.onmessage)==null||d.call(this,S)}catch(S){(h=this.onerror)==null||h.call(this,S)}}(n||i)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:a,onresumptiontoken:s,replayMessageId:o},0)}catch(_){if((y=this.onerror)==null||y.call(this,new Error(`SSE stream disconnected: ${_}`)),(n||i)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:a,onresumptiontoken:s,replayMessageId:o},0)}catch(f){(g=this.onerror)==null||g.call(this,new Error(`Failed to reconnect: ${f instanceof Error?f.message:String(f)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(t){if(!this._authProvider)throw new br("No auth provider");if(await Qn(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new br("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:So(t)?t.id:void 0}).catch(S=>{var R;return(R=this.onerror)==null?void 0:R.call(this,S)});return}const h=await this._commonHeaders();h.set("content-type","application/json"),h.set("accept","application/json, text/event-stream");const y={...this._requestInit,method:"POST",headers:h,body:JSON.stringify(t),signal:(n=this._abortController)==null?void 0:n.signal},g=await(this._fetch??fetch)(this._url,y),_=g.headers.get("mcp-session-id");if(_&&(this._sessionId=_),!g.ok){const S=await g.text().catch(()=>null);if(g.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Sr(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:R,scope:P}=Vl(g);if(this._resourceMetadataUrl=R,this._scope=P,await Qn(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new br;return this._hasCompletedAuthFlow=!0,this.send(t)}if(g.status===403&&this._authProvider){const{resourceMetadataUrl:R,scope:P,error:I}=Vl(g);if(I==="insufficient_scope"){const A=g.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===A)throw new Sr(403,"Server returned 403 after trying upscoping");if(P&&(this._scope=P),R&&(this._resourceMetadataUrl=R),this._lastUpscopingHeader=A??void 0,await Qn(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new br;return this.send(t)}}throw new Sr(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()),$y(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(S=>{var R;return(R=this.onerror)==null?void 0:R.call(this,S)});return}const m=(Array.isArray(t)?t:[t]).filter(S=>"method"in S&&"id"in S&&S.id!==void 0).length>0,f=g.headers.get("content-type"),v=jT(f);if(m)if(v==="text/event-stream")this._handleSseStream(g.body,{onresumptiontoken:d},!1);else if(v==="application/json"){const S=await g.json(),R=Array.isArray(S)?S.map(P=>Yn.parse(P)):[Yn.parse(S)];for(const P of R)(o=this.onmessage)==null||o.call(this,P)}else throw await((a=g.body)==null?void 0:a.cancel()),new Sr(-1,`Unexpected content type: ${f}`);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 Sr(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 vR="https://mcp.excalidraw.com/mcp",$R="mcp.excalidraw.com",wR="/api/v1/chat/mcp-apps/excalidraw",ah="ui://excalidraw/mcp-app.html",bR=["read_me","create_view"],ih=new Set(["export_to_excalidraw","save_checkpoint","read_checkpoint"]),SR=256*1024,ER=1024*1024,kR={excalidraw:{id:"excalidraw",endpoint:vR,hostname:$R,resourceUri:ah,modelTools:bR,appTools:ih}};function PR(e){return kR[e]}function TR(){return new URL(fh(wR),window.location.origin)}class RR{constructor(){ae(this,"client",new ST({name:"pwc-chat-mcp-app-host",version:"1"}));ae(this,"transport",new yR(TR(),{requestInit:{credentials:"include"}}));ae(this,"connected");ae(this,"bytes",0)}connect(){return this.connected??(this.connected=this.client.connect(this.transport)),this.connected}async readResource(t){if(t!==ah)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 NR(n.text);return{text:n.text,digest:s}}async callTool(t,r){if(!ih.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=SR){const n=new TextEncoder().encode(t).byteLength;if(n>r||this.bytes+n>ER)throw new Error("App request exceeds host limit");this.bytes+=n}}let Kl;function CR(){return Kl??(Kl=new RR),Kl}async function NR(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 Gl=e=>Math.max(240,Math.min(720,e)),IR=({block:e})=>{const t=X.useRef(null),r=X.useRef(null),n=X.useRef(!1),s=X.useRef(e),o=X.useRef(e.status);s.current=e,o.current=e.status;const[a,i]=X.useState(),[c,l]=X.useState(e.status),[d,h]=X.useState(Gl(e.height)),[y,g]=X.useState(!1),[_,$]=X.useState(0),m=X.useRef(null),f=e.input.elements,v=!!e.permissions.clipboardWrite,S=X.useCallback(()=>{g(!1),document.fullscreenElement&&document.exitFullscreen()},[]),R=X.useCallback(()=>{var I,A;if(y){S();return}g(!0),(A=(I=m.current)==null?void 0:I.requestFullscreen)==null||A.call(I).catch(()=>{})},[S,y]);X.useEffect(()=>{if(!y)return;const I=m.current,A=Z=>{Z.key==="Escape"&&(document.fullscreenElement||S())},U=()=>{document.fullscreenElement||g(!1)};return window.addEventListener("keydown",A),document.addEventListener("fullscreenchange",U),()=>{window.removeEventListener("keydown",A),document.removeEventListener("fullscreenchange",U),document.fullscreenElement===I&&document.exitFullscreen()}},[S,y]),X.useEffect(()=>{PR(e.provider);{l("unavailable");return}},[_,e.provider,e.resource_uri]),X.useEffect(()=>{if(!a||!t.current||c!=="ready")return;const I=t.current,A=new Yv(null,{name:"Papers with Code",version:"1"},{serverTools:{},openLinks:{},logging:{},...v?{clipboard:{write:{}}}:{}},{hostContext:{theme:document.documentElement.dataset.theme==="dark"?"dark":"light",displayMode:y?"fullscreen":"inline"}});return A.oncalltool=async({name:U,arguments:Z})=>{if(s.current.public_fork&&U!=="export_to_excalidraw")throw new Error("Shared diagrams cannot mutate owner state");return CR().callTool(U,Z??{})},A.onopenlink=async({url:U})=>{const Z=new URL(U);if(Z.protocol!=="https:"||Z.hostname!=="excalidraw.com")throw new Error("External navigation denied");if(!window.confirm("This export opens Excalidraw and uploads the diagram to its service. Continue?"))throw new Error("Export cancelled");return window.open(Z.href,"_blank","noopener,noreferrer"),{}},A.onsizechange=({height:U})=>{typeof U=="number"&&h(Gl(U))},A.oninitialized=()=>{n.current=!0;try{A.sendToolInput({arguments:{elements:JSON.parse(f)}}),A.sendToolResult(s.current.result)}catch{l("error")}},r.current=A,A.connect(new Jv(I.contentWindow??void 0,I.contentWindow)).catch(()=>l("error")),()=>{n.current=!1,A.teardownResource({}).catch(()=>{}),r.current===A&&(r.current=null)}},[a,c,y,f,v]),X.useEffect(()=>{var I;c!=="ready"||!n.current||(I=r.current)==null||I.sendToolResult(e.result).catch(()=>{})},[e.result,c]);const P=c==="unavailable"||c==="incompatible"||c==="error";return T.jsxs("section",{ref:m,className:`chat-mcp-app${y?" chat-mcp-app-fullscreen":""}`,"aria-label":"Interactive Excalidraw diagram",children:[T.jsx("header",{children:T.jsx("button",{type:"button",onClick:R,children:y?"Exit fullscreen":"Fullscreen"})}),c==="loading"&&T.jsx("div",{className:"chat-mcp-loading",role:"status",children:"Loading interactive diagram…"}),P&&T.jsxs("div",{className:"chat-mcp-error",children:["Interactive diagram unavailable. The cited text answer is still available.",T.jsx("button",{type:"button",onClick:()=>$(I=>I+1),children:"Retry diagram"})]}),a&&c==="ready"&&T.jsx("iframe",{ref:t,title:"Interactive Excalidraw diagram",sandbox:"allow-scripts",allow:v?"clipboard-write":void 0,srcDoc:a,style:{height:d}})]})};function jR(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 OR(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 AR(e,t=240){const r=e.content.trim();return r.length<=t?r:`${r.slice(0,t).trimEnd()}…`}const zR="https://huggingface.co/pro",MR="https://huggingface.co/docs/inference-providers/pricing",xR="https://paperswithcode.co/chat",ch=()=>T.jsx("span",{className:"chat-caret"}),qR=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},DR=e=>{var g,_;const t=e.currentTarget,r=t.ownerDocument,n=(g=r.caretPositionFromPoint)==null?void 0:g.call(r,e.clientX,e.clientY),s=n?null:(_=r.caretRangeFromPoint)==null?void 0:_.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(Ch,{size:13,"aria-hidden":"true"}),T.jsx(Xl,{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})},VR=({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(ea,{})," ",T.jsx("span",{children:"Thinking…"})]}),T.jsxs("div",{className:"chat-reason-live-body chat-answer chat-reason-markdown",children:[T.jsx(go,{text:e.text,streaming:!0,papers:t,citations:r,webCitations:n}),T.jsx(ch,{})]})]}):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(vh,{}),T.jsx("span",{children:"Thought for a few seconds"}),T.jsx(Yl,{open:e.open})]}),e.open&&T.jsx("div",{className:"chat-reason-done-body chat-answer chat-reason-markdown",children:T.jsx(go,{text:e.text,papers:t,citations:r,webCitations:n})})]}),LR=({block:e,papers:t,onToggle:r})=>{var d,h,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(_=>_.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(ea,{}):T.jsx($h,{}),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(Yl,{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})}),((h=e.metadata)==null?void 0:h.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(_=>T.jsxs("li",{className:"chat-hit",children:[T.jsx("div",{className:"chat-hit-top",children:T.jsx(eu,{routeId:_.route_id,paper:t[_.route_id],className:"chat-hit-title",children:_.title})}),T.jsx("div",{className:"chat-hit-meta",children:[jR(_.metadata),OR(_.metadata)].filter(Boolean).join(" · ")}),T.jsxs("div",{className:"chat-hit-snippet",children:[AR(_),_.content_truncated&&T.jsx("span",{className:"chat-hit-truncated",children:" (truncated)"})]})]},_.route_id))})]})]})]})},FR=({block:e,papers:t,citations:r,webCitations:n,streaming:s})=>T.jsxs("div",{className:"chat-answer",children:[T.jsx(go,{text:e.text,streaming:s,papers:t,citations:r,webCitations:n}),s&&!!e.text.trim()&&T.jsx(ch,{})]}),HR=({block:e})=>T.jsx(IR,{block:e}),lh=e=>{const t=X.useRef(null),r=X.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 X.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}},ZR=({id:e,text:t,paperSelection:r,editNotice:n,onCancel:s,onResend:o,onResendDraft:a})=>{const[i,c]=X.useState(t),[l,d]=X.useState(r),[h,y]=X.useState(!1),{textareaRef:g,resize:_}=lh(t);X.useLayoutEffect(_,[_,i]);const $=!!i.trim()&&i.length<=8e3,m=()=>{if(!$||h)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(Ns,{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:f=>c(f.target.value),onKeyDown:f=>{f.key==="Escape"?(f.preventDefault(),s==null||s()):f.key==="Enter"&&!f.shiftKey&&!f.nativeEvent.isComposing&&(f.preventDefault(),m())}}),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:!$||h,onClick:m,children:"Send"})]})]})})},KR=({id:e,text:t,paperMentions:r,paperSelection:n,enabled:s,editNotice:o,onCancel:a,onResend:i,onResendDraft:c})=>{const[l,d]=X.useState({text:t,paperMentions:r,...n?{paperSelection:n}:{}}),[h,y]=X.useState(!1),[g,_]=X.useState(0),{textareaRef:$,resize:m}=lh(t),f=Bl({draft:l,onChange:d,enabled:s,textareaRef:$});X.useLayoutEffect(m,[m,l.text]);const v=!!l.text.trim()&&l.text.length<=8e3&&(s||l.paperMentions.length===0),S=()=>{if(!v||h)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(Ns,{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(Jl,{text:l.text,mentions:l.paperMentions,scrollTop:g,variant:"editor"}),T.jsx("textarea",{ref:$,className:"chat-inline-editor-textarea","aria-label":"Edit message",value:l.text,maxLength:8e3,role:"combobox","aria-autocomplete":"list","aria-expanded":f.open,"aria-controls":f.open?f.pickerId:void 0,"aria-activedescendant":f.open&&f.results.length?`${f.optionIdPrefix}-${f.activeIndex}`:void 0,onChange:R=>f.updateText(R.target.value,R.target.selectionStart),onSelect:R=>f.refresh(R.currentTarget.selectionStart),onScroll:R=>_(R.currentTarget.scrollTop),onKeyDown:R=>{f.keyDown(R)||(R.key==="Escape"?(R.preventDefault(),a==null||a()):R.key==="Enter"&&!R.shiftKey&&!R.nativeEvent.isComposing&&(R.preventDefault(),S()))}}),T.jsx(Ql,{open:f.open,query:f.query,results:f.results,activeIndex:f.activeIndex,loading:f.loading,error:f.error,onSelect:f.select,id:f.pickerId,optionIdPrefix:f.optionIdPrefix})]}),!s&&l.paperMentions.length>0&&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:!v||h,onClick:S,children:"Send"})]})]})})},uC=({id:e,text:t,paperMentions:r=[],paperSelection:n,paperMentionsEnabled:s=!1,editingAllowed:o=!1,editing:a=!1,editNotice:i,onEdit:c,onCancel:l,onResend:d,onResendDraft:h})=>{const[y,g]=X.useState(!1),_=X.useRef(null);X.useEffect(()=>()=>{_.current!==null&&window.clearTimeout(_.current)},[]);const $=async()=>{var m;if((m=navigator.clipboard)!=null&&m.writeText)try{await navigator.clipboard.writeText(t),g(!0),_.current!==null&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>g(!1),1500)}catch{}};return a?!s&&r.length===0?T.jsx(ZR,{id:e,text:t,paperSelection:n,editNotice:i,onCancel:l,onResend:d,onResendDraft:h}):T.jsx(KR,{id:e,text:t,paperMentions:r,paperSelection:n,enabled:s,editNotice:i,onCancel:l,onResend:d,onResendDraft:h}):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(Ns,{selection:n}),T.jsx("div",{className:"chat-bubble",onDoubleClick:DR,children:T.jsx(UR,{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 $(),children:y?T.jsx(hh,{"aria-hidden":"true"}):T.jsx(Nh,{"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"})})]})]})})},dC=({msg:e,papers:t,onToggleBlock:r,onArchiveOldChats:n,onArchiveOldestChats:s,archivePending:o=null,hfBilling:a=null,openRouterFallbackEnabled:i=!1,feedbackEnabled:c=!1})=>{var A,U,Z;const[l,d]=X.useState(null),[h,y]=X.useState(!1),[g,_]=X.useState(!1),[$,m]=X.useState(!1),[f,v]=X.useState(""),S=X.useRef(null),R=`chat-feedback-panel-${e.id}`,P=c&&!e.streaming&&!e.error&&!!((A=e.blocks)!=null&&A.some(V=>V.kind==="answer"&&V.text.trim()));X.useEffect(()=>{var V;$&&((V=S.current)==null||V.focus())},[$]);const I=async(V,L)=>{if(!h){y(!0),_(!1);try{L===void 0?await Ec.reportFeedback(e.id,V):await Ec.reportFeedback(e.id,V,L),d(V),m(!1),v("")}catch{_(!0)}finally{y(!1)}}};return T.jsx("div",{className:"chat-msg chat-msg-assistant",children:T.jsxs("div",{className:"chat-msg-blocks",children:[(U=e.blocks)==null?void 0:U.map((V,L)=>{var Ce;const W=`${e.id}-${L}`,ce="citations"in V&&V.citations!==void 0?V.citations:e.citations??[],q=Object.fromEntries(ce.filter(ge=>(ge.kind??"paper")==="paper"&&ge.route_id).map(ge=>[ge.route_id,ge])),le=Object.fromEntries(ce.filter(ge=>ge.kind==="web"&&ge.url).map(ge=>[ge.url,ge]));return V.kind==="reasoning"?T.jsx(VR,{block:V,papers:t,citations:q,webCitations:le,onToggle:()=>r(e.id,L)},W):V.kind==="tool"?T.jsx(LR,{block:V,papers:t,onToggle:()=>r(e.id,L)},W):V.kind==="app"?T.jsx(HR,{block:V},W):T.jsx(FR,{block:V,papers:t,citations:q,webCitations:le,streaming:!!(e.streaming&&L===(((Ce=e.blocks)==null?void 0:Ce.length)??0)-1)},W)}),qR(e)&&T.jsx("div",{className:"chat-waiting",role:"status","aria-live":"polite",children:T.jsx("span",{className:"chat-thinking",children:(((Z=e.blocks)==null?void 0:Z.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:zR,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:MR,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:xR,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," ")}).`}),P&&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:h,onClick:()=>{m(!1),I(!0)},children:T.jsx(Oh,{"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":$,"aria-controls":R,disabled:h,onClick:()=>{_(!1),m(!0)},children:T.jsx(jh,{"aria-hidden":"true"})}),g&&T.jsx("span",{className:"chat-feedback-error",role:"status",children:"Couldn’t send feedback."})]}),P&&$&&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:f,maxLength:500,rows:4,disabled:h,onChange:V=>v(V.target.value),onKeyDown:V=>{V.key==="Escape"&&(V.preventDefault(),m(!1))}}),T.jsxs("div",{className:"chat-feedback-panel-actions",children:[T.jsx("button",{type:"button",className:"chat-feedback-skip",disabled:h,onClick:()=>void I(!1),children:"Skip"}),T.jsx("button",{type:"button",className:"chat-feedback-submit",disabled:h,onClick:()=>void I(!1,f.trim()||void 0),children:h?"Submitting…":"Submit"})]})]})]})})};export{dC as A,oC as C,uC as U};