diff --git "a/assets/ChatMessage-DDK82kBP.js" "b/assets/ChatMessage-DDK82kBP.js" new file mode 100644--- /dev/null +++ "b/assets/ChatMessage-DDK82kBP.js" @@ -0,0 +1,111 @@ +var yh=Object.defineProperty;var vh=(e,t,r)=>t in e?yh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var ne=(e,t,r)=>vh(e,typeof t!="symbol"?t+"":t,r);import{d as Ms,r as yt,j as T,z as Q,N as eu,E as $h,C as wh}from"./index-DcjpE9z8.js";import{u as tu,a as ru,b as nu,M as bh,R as Sh,W as Eh,d as ia,A as kh,n as Ph,K as Th,L as su,N as Rh}from"./chatSessions-Bx7YuodS.js";import"./katex.min-BSBacQyE.js";import{H as ca,a as la,b as ua}from"./hover-card-BhGDQBmN.js";import{u as Ch}from"./useQuery-CBni80yB.js";import{f as Ih,p as Nh}from"./github-vfsGL4M_.js";import{G as da}from"./github-DLnHUoN7.js";import{r as jh,a as Oh,P as ou}from"./PaperPreviewLink-D2iLXjXD.js";import{M as Mh,r as xh,d as Ah}from"./index-Ct92Xh0P.js";import{c as Nc}from"./chat-hzy1XwwB.js";import{F as zh}from"./file-text-_Ts3CZDt.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 Dh=Ms("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 qh=Ms("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 Uh=Ms("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 Fh=Ms("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 xs({selection:e,editable:t=!1,onRemove:r}){const n=yt.useId(),s=yt.useRef(null),[o,a]=yt.useState(!1),[i,c]=yt.useState(!1),l=`Selection · Page ${e.page}`;return yt.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 Vh=Ph(),MC=({onSend:e,busy:t,placeholder:r,autoFocus:n,draft:s,onDraftChange:o,onStop:a,models:i=[],selectedModel:c,onModelChange:l,disabled:d=!1,describedBy:f,paperMentionsEnabled:_=!1,paperSelectionEnabled:y=!0,webSearchAvailable:g=!1,webSearchEnabled:$=!1,onWebSearchChange:m,reasoningEffort:h="low",onReasoningEffortChange:v})=>{const[S,R]=yt.useState(Vh),P=s??S,O=yt.useRef(null),[A,L]=yt.useState(0),V=q=>{s||R(q),o==null||o(q)},D=tu({draft:P,onChange:V,enabled:_,textareaRef:O});yt.useEffect(()=>{const q=O.current;q&&(q.style.height="auto",q.style.height=`${Math.min(q.scrollHeight,200)}px`)},[P.text]),yt.useEffect(()=>{var q;n&&((q=O.current)==null||q.focus())},[n]);const F=()=>{const q=P.text.length-P.text.trimStart().length,le=P.text.trim(),Ce=!!P.paperSelection&&!y;if(!le||t||d||Ce)return;const _e=q+le.length,ct={text:le,paperMentions:P.paperMentions.filter(je=>je.start>=q&&je.end<=_e).map(je=>({...je,start:je.start-q,end:je.end-q})),...P.paperSelection?{paperSelection:P.paperSelection}:{}};e(ct)},K=!!P.paperSelection&&!y,ce=!!P.text.trim()&&!K;return T.jsxs("div",{className:"chat-composer",children:[P.paperSelection&&T.jsx(xs,{selection:P.paperSelection,editable:!0,onRemove:()=>{var q;V({text:P.text,paperMentions:P.paperMentions}),(q=O.current)==null||q.focus()}}),K&&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(ru,{text:P.text,mentions:P.paperMentions,scrollTop:A}),T.jsx("textarea",{ref:O,rows:1,value:P.text,placeholder:r||(P.paperSelection?"Ask about this selection…":"Ask anything about research…"),onChange:q=>D.updateText(q.target.value,q.target.selectionStart),onSelect:q=>D.refresh(q.currentTarget.selectionStart),onClick:q=>D.refresh(q.currentTarget.selectionStart),onScroll:q=>L(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(D.close,0)},onKeyDown:q=>{D.keyDown(q)||q.key==="Enter"&&!q.shiftKey&&!q.nativeEvent.isComposing&&(q.preventDefault(),F())},role:"combobox","aria-expanded":D.open,"aria-controls":D.open?D.pickerId:void 0,"aria-activedescendant":D.open&&D.results.length?`${D.optionIdPrefix}-${D.activeIndex}`:void 0,"aria-autocomplete":"list","aria-describedby":[f,D.message?"chat-paper-mention-message":null].filter(Boolean).join(" ")||void 0}),T.jsx(nu,{open:D.open,query:D.query,results:D.results,activeIndex:D.activeIndex,loading:D.loading,error:D.error,onSelect:D.select,id:D.pickerId,optionIdPrefix:D.optionIdPrefix})]}),D.message&&T.jsx("div",{id:"chat-paper-mention-message",className:"chat-paper-mention-message",role:"alert",children:D.message}),T.jsxs("div",{className:"chat-composer-row",children:[T.jsxs("div",{className:"chat-composer-tools",children:[i.length>0&&c&&l&&T.jsx(bh,{models:i,selectedModel:c,onModelChange:l,disabled:t}),v&&T.jsx(Sh,{value:h,onChange:v,disabled:t}),g&&m&&T.jsx(Eh,{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:F,disabled:d||(t?!a:!ce),"aria-label":t?"Stop generating":"Send message",children:t?a?T.jsx("span",{"aria-hidden":"true",children:"■"}):T.jsx(ia,{light:!0}):T.jsx(kh,{})})]})]})},no=new Map,Lh=e=>{if(!e)return Promise.resolve();const t=no.get(e);if(t)return t;const r=new Promise(n=>{const s=new Image;s.onload=()=>{n()},s.onerror=()=>{no.delete(e),n()},s.src=e});return no.set(e,r),r},Hh=new Set(["huggingface.co","www.huggingface.co"]),Zh=new Set(["api","blog","chat","collections","docs","enterprise","join","login","models","new","organizations","papers","posts","pricing","search","settings","spaces","tasks"]);function Kh(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!=="https:"||!Hh.has(t.hostname))return null;const r=t.pathname.split("/").filter(Boolean),n=r[0]==="datasets"?"dataset":"model",s=n==="dataset"?r.slice(1):r;if(s.length!==2||n==="model"&&Zh.has(s[0])||s.some(l=>!l||l==="."||l===".."))return null;const o=s.join("/"),a=s.map(encodeURIComponent).join("/"),i=n==="dataset"?`datasets/${a}`:a,c=n==="dataset"?"datasets":"models";return{type:n,repoId:o,url:`https://huggingface.co/${i}`,thumbnailUrl:`https://cdn-thumbnails.huggingface.co/social-thumbnails/${c}/${a}.png`}}const Gh=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,Wh=({repo:e})=>{const[t,r]=Q.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"})]})]})},Bh=({repo:e,children:t})=>{const[r,n]=Q.useState(!1),s=Q.useRef(null),o=Q.useCallback(()=>{Lh(e.thumbnailUrl)},[e.thumbnailUrl]);return Q.useEffect(()=>{const a=s.current;if(!a||typeof IntersectionObserver>"u")return;const i=new IntersectionObserver(([c])=>{c.isIntersecting&&(o(),i.disconnect())},{rootMargin:"200px"});return i.observe(a),()=>i.disconnect()},[o]),T.jsxs(ca,{open:r,onOpenChange:a=>{(!a||!Gh())&&n(a)},openDelay:150,closeDelay:100,children:[T.jsx(la,{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(ua,{className:"hf-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:T.jsx(Wh,{repo:e})})]})},Jh=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,Yh=({repo:e,preview:t,unavailable:r})=>{const[n,s]=Q.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(da,{})}),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…"})]})]})},Qh=({repo:e,children:t})=>{const[r,n]=Q.useState(!1),s=Ch({queryKey:["github-repository-preview",e.repoId.toLowerCase()],queryFn:({signal:o})=>Ih(e,o),enabled:r,staleTime:30*60*1e3,gcTime:60*60*1e3,retry:!1});return T.jsxs(ca,{open:r,onOpenChange:o=>{(!o||!Jh())&&n(o)},openDelay:150,closeDelay:100,children:[T.jsx(la,{asChild:!0,children:T.jsxs("a",{className:"chat-github-link",href:e.url,target:"_blank",rel:"noopener noreferrer",children:[T.jsx(da,{"aria-hidden":"true"}),t]})}),T.jsx(ua,{className:"github-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:T.jsx(Yh,{repo:e,preview:s.data,unavailable:s.isError})})]})},Xh=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches;function ep(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return"Web source"}}const tp=({citation:e})=>{const[t,r]=Q.useState(!1),[n,s]=Q.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:ep(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()})]})]})},rp=({citation:e,children:t})=>{const[r,n]=Q.useState(!1),s=e.url??"";return T.jsxs(ca,{open:r,onOpenChange:o=>{(!o||!Xh())&&n(o)},openDelay:150,closeDelay:100,children:[T.jsx(la,{asChild:!0,children:T.jsx("a",{href:s,className:"chat-web-citation",target:"_blank",rel:"noopener noreferrer",children:t})}),T.jsx(ua,{className:"web-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:T.jsx(tp,{citation:e})})]})};function np(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 au=({routeId:e,paper:t,citation:r,className:n="chat-paper-link",children:s})=>T.jsx(ou,{routeId:e,initialData:np(e,t,r),className:n,target:"_blank",children:s});function sp(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 op=e=>e.startsWith("paper:")?e:Ah(e);function ap(e){try{const t=new URL(e);return t.protocol==="https:"&&(t.hostname==="github.com"||t.hostname==="www.github.com")}catch{return!1}}const So=({text:e,streaming:t,papers:r,citations:n,webCitations:s})=>{const o=t?sp(e):e;return T.jsx(Mh,{remarkPlugins:[xh,Oh],rehypePlugins:[jh],urlTransform:op,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(au,{routeId:d,paper:r[d],citation:n==null?void 0:n[d],children:i})}const c=a?Kh(a):null;if(c)return T.jsx(Bh,{repo:c,children:i});const l=a?Nh(a):null;return l?T.jsx(Qh,{repo:l,children:i}):a&&ap(a)?T.jsxs("a",{href:a,className:"chat-github-link",target:"_blank",rel:"noopener noreferrer",children:[T.jsx(da,{"aria-hidden":"true"}),i]}):a!=null&&a.startsWith("https://")&&(s!=null&&s[a])?T.jsx(rp,{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})},ip=Object.freeze({status:"aborted"});function M(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 yn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const iu={};function qt(e){return iu}function cp(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 lp(e,t){return typeof t=="bigint"?t.toString():t}function fa(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ha(e){return e==null}function pa(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function up(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 As(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Yr(e){return JSON.stringify(e)}const cu=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function ps(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const dp=fa(()=>{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 ms(e){if(ps(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(ps(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}const fp=new Set(["string","number","symbol"]);function kn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $r(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 W(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 hp(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const pp={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 mp(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 $r(e,{...e._zod.def,shape:r,checks:[]})}function gp(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 $r(e,{...e._zod.def,shape:r,checks:[]})}function _p(e,t){if(!ms(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 As(this,"shape",n),n},checks:[]};return $r(e,r)}function yp(e,t){return $r(e,{...e._zod.def,get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return As(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function vp(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 $r(t,{...t._zod.def,shape:s,checks:[]})}function $p(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 $r(t,{...t._zod.def,shape:s,checks:[]})}function an(e,t=0){var r;for(let n=t;n{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Fn(e){return typeof e=="string"?e:e==null?void 0:e.message}function Ut(e,t,r){var s,o,a,i,c,l;const n={...e,path:e.path??[]};if(!e.message){const d=Fn((a=(o=(s=e.inst)==null?void 0:s._zod.def)==null?void 0:o.error)==null?void 0:a.call(o,e))??Fn((i=t==null?void 0:t.error)==null?void 0:i.call(t,e))??Fn((c=r.customError)==null?void 0:c.call(r,e))??Fn((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 ma(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function vn(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const lu=(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,lp,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},uu=M("$ZodError",lu),du=M("$ZodError",lu,{Parent:Error});function wp(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 bp(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 yn;if(a.issues.length){const i=new((s==null?void 0:s.Err)??e)(a.issues.map(c=>Ut(c,o,qt())));throw cu(i,s==null?void 0:s.callee),i}return a.value},Ep=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=>Ut(c,o,qt())));throw cu(i,s==null?void 0:s.callee),i}return a.value},fu=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 yn;return o.issues.length?{success:!1,error:new(e??uu)(o.issues.map(a=>Ut(a,s,qt())))}:{success:!0,data:o.value}},hu=fu(du),pu=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=>Ut(a,s,qt())))}:{success:!0,data:o.value}},kp=pu(du),Pp=/^[cC][^\s-]{8,}$/,Tp=/^[0-9a-z]+$/,Rp=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Cp=/^[0-9a-vA-V]{20}$/,Ip=/^[A-Za-z0-9]{27}$/,Np=/^[a-zA-Z0-9_-]{21}$/,jp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Op=/^([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})$/,jc=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,Mp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,xp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Ap(){return new RegExp(xp,"u")}const zp=/^(?:(?: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])$/,Dp=/^(([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})$/,qp=/^((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])$/,Up=/^(([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])$/,Fp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,mu=/^[A-Za-z0-9_-]*$/,Vp=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,Lp=/^\+(?:[0-9]){6,14}[0-9]$/,gu="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Hp=new RegExp(`^${gu}$`);function _u(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 Zp(e){return new RegExp(`^${_u(e)}$`)}function Kp(e){const t=_u({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(`^${gu}T(?:${n})$`)}const Gp=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Wp=/^\d+$/,Bp=/^-?\d+(?:\.\d+)?/i,Jp=/true|false/i,Yp=/null/i,Qp=/undefined/i,Xp=/^[^A-Z]*$/,em=/^[^a-z]*$/,et=M("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),yu={number:"number",bigint:"bigint",object:"date"},vu=M("$ZodCheckLessThan",(e,t)=>{et.init(e,t);const r=yu[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{et.init(e,t);const r=yu[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})}}),tm=M("$ZodCheckMultipleOf",(e,t)=>{et.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):up(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})}}),rm=M("$ZodCheckNumberFormat",(e,t)=>{var a;et.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]=pp[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=Wp)}),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})}}),nm=M("$ZodCheckMaxLength",(e,t)=>{var r;et.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!ha(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=ma(s);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),sm=M("$ZodCheckMinLength",(e,t)=>{var r;et.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!ha(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=ma(s);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),om=M("$ZodCheckLengthEquals",(e,t)=>{var r;et.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!ha(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=ma(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})}}),zs=M("$ZodCheckStringFormat",(e,t)=>{var r,n;et.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=()=>{})}),am=M("$ZodCheckRegex",(e,t)=>{zs.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})}}),im=M("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Xp),zs.init(e,t)}),cm=M("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=em),zs.init(e,t)}),lm=M("$ZodCheckIncludes",(e,t)=>{et.init(e,t);const r=kn(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})}}),um=M("$ZodCheckStartsWith",(e,t)=>{et.init(e,t);const r=new RegExp(`^${kn(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})}}),dm=M("$ZodCheckEndsWith",(e,t)=>{et.init(e,t);const r=new RegExp(`.*${kn(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})}}),fm=M("$ZodCheckOverwrite",(e,t)=>{et.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class hm{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 pm={major:4,minor:0,patch:0},we=M("$ZodType",(e,t)=>{var s;var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=pm;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=an(a),d;for(const f of i){if(f._zod.def.when){if(!f._zod.def.when(a))continue}else if(l)continue;const _=a.issues.length,y=f._zod.check(a);if(y instanceof Promise&&(c==null?void 0:c.async)===!1)throw new yn;if(d||y instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await y,a.issues.length!==_&&(l||(l=an(a,_)))});else{if(a.issues.length===_)continue;l||(l=an(a,_))}}return d?d.then(()=>a):a};e._zod.run=(a,i)=>{const c=e._zod.parse(a,i);if(c instanceof Promise){if(i.async===!1)throw new yn;return c.then(l=>o(l,n,i))}return o(c,n,i)}}e["~standard"]={validate:o=>{var a;try{const i=hu(e,o);return i.success?{value:i.data}:{issues:(a=i.error)==null?void 0:a.issues}}catch{return kp(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}}),ga=M("$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()??Gp(e._zod.bag),e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Pe=M("$ZodStringFormat",(e,t)=>{zs.init(e,t),ga.init(e,t)}),mm=M("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Op),Pe.init(e,t)}),gm=M("$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=jc(n))}else t.pattern??(t.pattern=jc());Pe.init(e,t)}),_m=M("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Mp),Pe.init(e,t)}),ym=M("$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:Vp.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})}}}),vm=M("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Ap()),Pe.init(e,t)}),$m=M("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Np),Pe.init(e,t)}),wm=M("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Pp),Pe.init(e,t)}),bm=M("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Tp),Pe.init(e,t)}),Sm=M("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Rp),Pe.init(e,t)}),Em=M("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Cp),Pe.init(e,t)}),km=M("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ip),Pe.init(e,t)}),Pm=M("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Kp(t)),Pe.init(e,t)}),Tm=M("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Hp),Pe.init(e,t)}),Rm=M("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Zp(t)),Pe.init(e,t)}),Cm=M("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=jp),Pe.init(e,t)}),Im=M("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=zp),Pe.init(e,t),e._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv4"})}),Nm=M("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Dp),Pe.init(e,t),e._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv6"}),e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),jm=M("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=qp),Pe.init(e,t)}),Om=M("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Up),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 wu(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Mm=M("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Fp),Pe.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),e._zod.check=r=>{wu(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function xm(e){if(!mu.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return wu(r)}const Am=M("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=mu),Pe.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),e._zod.check=r=>{xm(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),zm=M("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Lp),Pe.init(e,t)});function Dm(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 qm=M("$ZodJWT",(e,t)=>{Pe.init(e,t),e._zod.check=r=>{Dm(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),bu=M("$ZodNumber",(e,t)=>{we.init(e,t),e._zod.pattern=e._zod.bag.pattern??Bp,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}}),Um=M("$ZodNumber",(e,t)=>{rm.init(e,t),bu.init(e,t)}),Fm=M("$ZodBoolean",(e,t)=>{we.init(e,t),e._zod.pattern=Jp,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}}),Vm=M("$ZodUndefined",(e,t)=>{we.init(e,t),e._zod.pattern=Qp,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}}),Lm=M("$ZodNull",(e,t)=>{we.init(e,t),e._zod.pattern=Yp,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{const s=r.value;return s===null||r.issues.push({expected:"null",code:"invalid_type",input:s,inst:e}),r}}),Hm=M("$ZodAny",(e,t)=>{we.init(e,t),e._zod.parse=r=>r}),Zm=M("$ZodUnknown",(e,t)=>{we.init(e,t),e._zod.parse=r=>r}),Km=M("$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 Oc(e,t,r){e.issues.length&&t.issues.push(...hr(r,e.issues)),t.value[r]=e.value}const Gm=M("$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;aOc(l,r,a))):Oc(c,r,a)}return o.length?Promise.all(o).then(()=>r):r}});function Vn(e,t,r){e.issues.length&&t.issues.push(...hr(r,e.issues)),t.value[r]=e.value}function Mc(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(...hr(r,e.issues)):e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}const Wm=M("$ZodObject",(e,t)=>{we.init(e,t);const r=fa(()=>{const f=Object.keys(t.shape);for(const y of f)if(!(t.shape[y]instanceof we))throw new Error(`Invalid element at key "${y}": expected a Zod schema`);const _=hp(t.shape);return{shape:t.shape,keys:f,keySet:new Set(f),numKeys:f.length,optionalKeys:new Set(_)}});Ee(e._zod,"propValues",()=>{const f=t.shape,_={};for(const y in f){const g=f[y]._zod;if(g.values){_[y]??(_[y]=new Set);for(const $ of g.values)_[y].add($)}}return _});const n=f=>{const _=new hm(["shape","payload","ctx"]),y=r.value,g=v=>{const S=Yr(v);return`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`};_.write("const input = payload.value;");const $=Object.create(null);let m=0;for(const v of y.keys)$[v]=`key_${m++}`;_.write("const newResult = {}");for(const v of y.keys)if(y.optionalKeys.has(v)){const S=$[v];_.write(`const ${S} = ${g(v)};`);const R=Yr(v);_.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];_.write(`const ${S} = ${g(v)};`),_.write(` + if (${S}.issues.length) payload.issues = payload.issues.concat(${S}.issues.map(iss => ({ + ...iss, + path: iss.path ? [${Yr(v)}, ...iss.path] : [${Yr(v)}] + })));`),_.write(`newResult[${Yr(v)}] = ${S}.value`)}_.write("payload.value = newResult;"),_.write("return payload;");const h=_.compile();return(v,S)=>h(f,v,S)};let s;const o=ps,a=!iu.jitless,c=a&&dp.value,l=t.catchall;let d;e._zod.parse=(f,_)=>{d??(d=r.value);const y=f.value;if(!o(y))return f.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),f;const g=[];if(a&&c&&(_==null?void 0:_.async)===!1&&_.jitless!==!0)s||(s=n(t.shape)),f=s(f,_);else{f.value={};const S=d.shape;for(const R of d.keys){const P=S[R],O=P._zod.run({value:y[R],issues:[]},_),A=P._zod.optin==="optional"&&P._zod.optout==="optional";O instanceof Promise?g.push(O.then(L=>A?Mc(L,f,R,y):Vn(L,f,R))):A?Mc(O,f,R,y):Vn(O,f,R)}}if(!l)return g.length?Promise.all(g).then(()=>f):f;const $=[],m=d.keySet,h=l._zod,v=h.def.type;for(const S of Object.keys(y)){if(m.has(S))continue;if(v==="never"){$.push(S);continue}const R=h.run({value:y[S],issues:[]},_);R instanceof Promise?g.push(R.then(P=>Vn(P,f,S))):Vn(R,f,S)}return $.length&&f.issues.push({code:"unrecognized_keys",keys:$,input:y,inst:e}),g.length?Promise.all(g).then(()=>f):f}});function xc(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=>Ut(o,n,qt())))}),t}const Su=M("$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=>pa(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=>xc(a,r,e,n)):xc(o,r,e,n)}}),Bm=M("$ZodDiscriminatedUnion",(e,t)=>{Su.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=fa(()=>{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(!ps(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)}}),Jm=M("$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])=>Ac(r,c,l)):Ac(r,o,a)}});function Eo(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(ms(e)&&ms(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=Eo(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(!ms(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(...hr(c,d.issues)),r.value[c]=d.value})):(l.issues.length&&r.issues.push(...hr(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=>Ut(l,n,qt())),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(...hr(a,l.issues)),r.value[i.value]=l.value})):(c.issues.length&&r.issues.push(...hr(a,c.issues)),r.value[i.value]=c.value)}}return o.length?Promise.all(o).then(()=>r):r}}),Qm=M("$ZodEnum",(e,t)=>{we.init(e,t);const r=cp(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(n=>fp.has(typeof n)).map(n=>typeof n=="string"?kn(n):n.toString()).join("|")})$`),e._zod.parse=(n,s)=>{const o=n.value;return e._zod.values.has(o)||n.issues.push({code:"invalid_value",values:r,input:o,inst:e}),n}}),Xm=M("$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"?kn(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}}),eg=M("$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 yn;return r.value=s,r}}),tg=M("$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(`^(${pa(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)}),rg=M("$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(`^(${pa(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)}),ng=M("$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=>zc(o,t)):zc(s,t)}});function zc(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const sg=M("$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))}),og=M("$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=>Dc(o,e)):Dc(s,e)}});function Dc(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 ag=M("$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=>Ut(a,n,qt()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=t.catchValue({...r,error:{issues:s.issues.map(o=>Ut(o,n,qt()))},input:r.value}),r.issues=[]),r)}}),ig=M("$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=>qc(o,t,n)):qc(s,t,n)}});function qc(e,t,r){return an(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}const cg=M("$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(Uc):Uc(s)}});function Uc(e){return e.value=Object.freeze(e.value),e}const lg=M("$ZodCustom",(e,t)=>{et.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=>Fc(o,r,n,e));Fc(s,r,n,e)}});function Fc(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(vn(s))}}class ug{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 dg(){return new ug}const Ln=dg();function fg(e,t){return new e({type:"string",...W(t)})}function hg(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...W(t)})}function Vc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...W(t)})}function pg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...W(t)})}function mg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...W(t)})}function gg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...W(t)})}function _g(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...W(t)})}function Eu(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...W(t)})}function yg(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...W(t)})}function vg(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...W(t)})}function $g(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...W(t)})}function wg(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...W(t)})}function bg(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...W(t)})}function Sg(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...W(t)})}function Eg(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...W(t)})}function kg(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...W(t)})}function Pg(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...W(t)})}function Tg(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...W(t)})}function Rg(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...W(t)})}function Cg(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...W(t)})}function Ig(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...W(t)})}function Ng(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...W(t)})}function jg(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...W(t)})}function Og(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...W(t)})}function Mg(e,t){return new e({type:"string",format:"date",check:"string_format",...W(t)})}function xg(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...W(t)})}function Ag(e,t){return new e({type:"string",format:"duration",check:"string_format",...W(t)})}function zg(e,t){return new e({type:"number",checks:[],...W(t)})}function Dg(e,t){return new e({type:"number",coerce:!0,checks:[],...W(t)})}function qg(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...W(t)})}function Ug(e,t){return new e({type:"boolean",...W(t)})}function Fg(e,t){return new e({type:"undefined",...W(t)})}function Vg(e,t){return new e({type:"null",...W(t)})}function Lg(e){return new e({type:"any"})}function Hg(e){return new e({type:"unknown"})}function Zg(e,t){return new e({type:"never",...W(t)})}function Lc(e,t){return new vu({check:"less_than",...W(t),value:e,inclusive:!1})}function so(e,t){return new vu({check:"less_than",...W(t),value:e,inclusive:!0})}function Hc(e,t){return new $u({check:"greater_than",...W(t),value:e,inclusive:!1})}function oo(e,t){return new $u({check:"greater_than",...W(t),value:e,inclusive:!0})}function Zc(e,t){return new tm({check:"multiple_of",...W(t),value:e})}function ku(e,t){return new nm({check:"max_length",...W(t),maximum:e})}function gs(e,t){return new sm({check:"min_length",...W(t),minimum:e})}function Pu(e,t){return new om({check:"length_equals",...W(t),length:e})}function Kg(e,t){return new am({check:"string_format",format:"regex",...W(t),pattern:e})}function Gg(e){return new im({check:"string_format",format:"lowercase",...W(e)})}function Wg(e){return new cm({check:"string_format",format:"uppercase",...W(e)})}function Bg(e,t){return new lm({check:"string_format",format:"includes",...W(t),includes:e})}function Jg(e,t){return new um({check:"string_format",format:"starts_with",...W(t),prefix:e})}function Yg(e,t){return new dm({check:"string_format",format:"ends_with",...W(t),suffix:e})}function Pn(e){return new fm({check:"overwrite",tx:e})}function Qg(e){return Pn(t=>t.normalize(e))}function Xg(){return Pn(e=>e.trim())}function e_(){return Pn(e=>e.toLowerCase())}function t_(){return Pn(e=>e.toUpperCase())}function r_(e,t,r){return new e({type:"array",element:t,...W(r)})}function n_(e,t,r){const n=W(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function s_(e,t,r){return new e({type:"custom",check:"custom",fn:t,...W(r)})}const o_=M("ZodISODateTime",(e,t)=>{Pm.init(e,t),Re.init(e,t)});function Tu(e){return Og(o_,e)}const a_=M("ZodISODate",(e,t)=>{Tm.init(e,t),Re.init(e,t)});function i_(e){return Mg(a_,e)}const c_=M("ZodISOTime",(e,t)=>{Rm.init(e,t),Re.init(e,t)});function l_(e){return xg(c_,e)}const u_=M("ZodISODuration",(e,t)=>{Cm.init(e,t),Re.init(e,t)});function d_(e){return Ag(u_,e)}const f_=(e,t)=>{uu.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>bp(e,r)},flatten:{value:r=>wp(e,r)},addIssue:{value:r=>e.issues.push(r)},addIssues:{value:r=>e.issues.push(...r)},isEmpty:{get(){return e.issues.length===0}}})},Ds=M("ZodError",f_,{Parent:Error}),h_=Sp(Ds),p_=Ep(Ds),m_=fu(Ds),g_=pu(Ds),ke=M("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)=>$r(e,r,n),e.brand=()=>e,e.register=(r,n)=>(r.add(e,n),e),e.parse=(r,n)=>h_(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>m_(e,r,n),e.parseAsync=async(r,n)=>p_(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>g_(e,r,n),e.spa=e.safeParseAsync,e.refine=(r,n)=>e.check(cy(r,n)),e.superRefine=r=>e.check(ly(r)),e.overwrite=r=>e.check(Pn(r)),e.optional=()=>Te(e),e.nullable=()=>Wc(e),e.nullish=()=>Te(Wc(e)),e.nonoptional=r=>ey(e,r),e.array=()=>U(e),e.or=r=>pe([e,r]),e.and=r=>va(e,r),e.transform=r=>Ro(e,Ou(r)),e.default=r=>Y_(e,r),e.prefault=r=>X_(e,r),e.catch=r=>ry(e,r),e.pipe=r=>Ro(e,r),e.readonly=()=>oy(e),e.describe=r=>{const n=e.clone();return Ln.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){var r;return(r=Ln.get(e))==null?void 0:r.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return Ln.get(e);const n=e.clone();return Ln.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Ru=M("_ZodString",(e,t)=>{ga.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(Kg(...n)),e.includes=(...n)=>e.check(Bg(...n)),e.startsWith=(...n)=>e.check(Jg(...n)),e.endsWith=(...n)=>e.check(Yg(...n)),e.min=(...n)=>e.check(gs(...n)),e.max=(...n)=>e.check(ku(...n)),e.length=(...n)=>e.check(Pu(...n)),e.nonempty=(...n)=>e.check(gs(1,...n)),e.lowercase=n=>e.check(Gg(n)),e.uppercase=n=>e.check(Wg(n)),e.trim=()=>e.check(Xg()),e.normalize=(...n)=>e.check(Qg(...n)),e.toLowerCase=()=>e.check(e_()),e.toUpperCase=()=>e.check(t_())}),__=M("ZodString",(e,t)=>{ga.init(e,t),Ru.init(e,t),e.email=r=>e.check(hg(y_,r)),e.url=r=>e.check(Eu(Cu,r)),e.jwt=r=>e.check(jg(M_,r)),e.emoji=r=>e.check(yg($_,r)),e.guid=r=>e.check(Vc(Kc,r)),e.uuid=r=>e.check(pg(Hn,r)),e.uuidv4=r=>e.check(mg(Hn,r)),e.uuidv6=r=>e.check(gg(Hn,r)),e.uuidv7=r=>e.check(_g(Hn,r)),e.nanoid=r=>e.check(vg(w_,r)),e.guid=r=>e.check(Vc(Kc,r)),e.cuid=r=>e.check($g(b_,r)),e.cuid2=r=>e.check(wg(S_,r)),e.ulid=r=>e.check(bg(E_,r)),e.base64=r=>e.check(Cg(N_,r)),e.base64url=r=>e.check(Ig(j_,r)),e.xid=r=>e.check(Sg(k_,r)),e.ksuid=r=>e.check(Eg(P_,r)),e.ipv4=r=>e.check(kg(T_,r)),e.ipv6=r=>e.check(Pg(R_,r)),e.cidrv4=r=>e.check(Tg(C_,r)),e.cidrv6=r=>e.check(Rg(I_,r)),e.e164=r=>e.check(Ng(O_,r)),e.datetime=r=>e.check(Tu(r)),e.date=r=>e.check(i_(r)),e.time=r=>e.check(l_(r)),e.duration=r=>e.check(d_(r))});function k(e){return fg(__,e)}const Re=M("ZodStringFormat",(e,t)=>{Pe.init(e,t),Ru.init(e,t)}),y_=M("ZodEmail",(e,t)=>{_m.init(e,t),Re.init(e,t)}),Kc=M("ZodGUID",(e,t)=>{mm.init(e,t),Re.init(e,t)}),Hn=M("ZodUUID",(e,t)=>{gm.init(e,t),Re.init(e,t)}),Cu=M("ZodURL",(e,t)=>{ym.init(e,t),Re.init(e,t)});function v_(e){return Eu(Cu,e)}const $_=M("ZodEmoji",(e,t)=>{vm.init(e,t),Re.init(e,t)}),w_=M("ZodNanoID",(e,t)=>{$m.init(e,t),Re.init(e,t)}),b_=M("ZodCUID",(e,t)=>{wm.init(e,t),Re.init(e,t)}),S_=M("ZodCUID2",(e,t)=>{bm.init(e,t),Re.init(e,t)}),E_=M("ZodULID",(e,t)=>{Sm.init(e,t),Re.init(e,t)}),k_=M("ZodXID",(e,t)=>{Em.init(e,t),Re.init(e,t)}),P_=M("ZodKSUID",(e,t)=>{km.init(e,t),Re.init(e,t)}),T_=M("ZodIPv4",(e,t)=>{Im.init(e,t),Re.init(e,t)}),R_=M("ZodIPv6",(e,t)=>{Nm.init(e,t),Re.init(e,t)}),C_=M("ZodCIDRv4",(e,t)=>{jm.init(e,t),Re.init(e,t)}),I_=M("ZodCIDRv6",(e,t)=>{Om.init(e,t),Re.init(e,t)}),N_=M("ZodBase64",(e,t)=>{Mm.init(e,t),Re.init(e,t)}),j_=M("ZodBase64URL",(e,t)=>{Am.init(e,t),Re.init(e,t)}),O_=M("ZodE164",(e,t)=>{zm.init(e,t),Re.init(e,t)}),M_=M("ZodJWT",(e,t)=>{qm.init(e,t),Re.init(e,t)}),_a=M("ZodNumber",(e,t)=>{bu.init(e,t),ke.init(e,t),e.gt=(n,s)=>e.check(Hc(n,s)),e.gte=(n,s)=>e.check(oo(n,s)),e.min=(n,s)=>e.check(oo(n,s)),e.lt=(n,s)=>e.check(Lc(n,s)),e.lte=(n,s)=>e.check(so(n,s)),e.max=(n,s)=>e.check(so(n,s)),e.int=n=>e.check(Gc(n)),e.safe=n=>e.check(Gc(n)),e.positive=n=>e.check(Hc(0,n)),e.nonnegative=n=>e.check(oo(0,n)),e.negative=n=>e.check(Lc(0,n)),e.nonpositive=n=>e.check(so(0,n)),e.multipleOf=(n,s)=>e.check(Zc(n,s)),e.step=(n,s)=>e.check(Zc(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 ae(e){return zg(_a,e)}const x_=M("ZodNumberFormat",(e,t)=>{Um.init(e,t),_a.init(e,t)});function Gc(e){return qg(x_,e)}const A_=M("ZodBoolean",(e,t)=>{Fm.init(e,t),ke.init(e,t)});function me(e){return Ug(A_,e)}const z_=M("ZodUndefined",(e,t)=>{Vm.init(e,t),ke.init(e,t)});function ko(e){return Fg(z_,e)}const D_=M("ZodNull",(e,t)=>{Lm.init(e,t),ke.init(e,t)});function q_(e){return Vg(D_,e)}const U_=M("ZodAny",(e,t)=>{Hm.init(e,t),ke.init(e,t)});function ya(){return Lg(U_)}const F_=M("ZodUnknown",(e,t)=>{Zm.init(e,t),ke.init(e,t)});function $e(){return Hg(F_)}const V_=M("ZodNever",(e,t)=>{Km.init(e,t),ke.init(e,t)});function Po(e){return Zg(V_,e)}const L_=M("ZodArray",(e,t)=>{Gm.init(e,t),ke.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(gs(r,n)),e.nonempty=r=>e.check(gs(1,r)),e.max=(r,n)=>e.check(ku(r,n)),e.length=(r,n)=>e.check(Pu(r,n)),e.unwrap=()=>e.element});function U(e,t){return r_(L_,e,t)}const Iu=M("ZodObject",(e,t)=>{Wm.init(e,t),ke.init(e,t),Ee(e,"shape",()=>t.shape),e.keyof=()=>rt(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:Po()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>_p(e,r),e.merge=r=>yp(e,r),e.pick=r=>mp(e,r),e.omit=r=>gp(e,r),e.partial=(...r)=>vp(Mu,e,r[0]),e.required=(...r)=>$p(xu,e,r[0])});function j(e,t){const r={type:"object",get shape(){return As(this,"shape",{...e}),this.shape},...W(t)};return new Iu(r)}function Ve(e,t){return new Iu({type:"object",get shape(){return As(this,"shape",{...e}),this.shape},catchall:$e(),...W(t)})}const Nu=M("ZodUnion",(e,t)=>{Su.init(e,t),ke.init(e,t),e.options=t.options});function pe(e,t){return new Nu({type:"union",options:e,...W(t)})}const H_=M("ZodDiscriminatedUnion",(e,t)=>{Nu.init(e,t),Bm.init(e,t)});function ju(e,t,r){return new H_({type:"union",options:t,discriminator:e,...W(r)})}const Z_=M("ZodIntersection",(e,t)=>{Jm.init(e,t),ke.init(e,t)});function va(e,t){return new Z_({type:"intersection",left:e,right:t})}const K_=M("ZodRecord",(e,t)=>{Ym.init(e,t),ke.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function ge(e,t,r){return new K_({type:"record",keyType:e,valueType:t,...W(r)})}const To=M("ZodEnum",(e,t)=>{Qm.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 To({...t,checks:[],...W(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 To({...t,checks:[],...W(s),entries:o})}});function rt(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new To({type:"enum",entries:r,...W(t)})}const G_=M("ZodLiteral",(e,t)=>{Xm.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 I(e,t){return new G_({type:"literal",values:Array.isArray(e)?e:[e],...W(t)})}const W_=M("ZodTransform",(e,t)=>{eg.init(e,t),ke.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=o=>{if(typeof o=="string")r.issues.push(vn(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(vn(a))}};const s=t.transform(r.value,r);return s instanceof Promise?s.then(o=>(r.value=o,r)):(r.value=s,r)}});function Ou(e){return new W_({type:"transform",transform:e})}const Mu=M("ZodOptional",(e,t)=>{tg.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Te(e){return new Mu({type:"optional",innerType:e})}const B_=M("ZodNullable",(e,t)=>{rg.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Wc(e){return new B_({type:"nullable",innerType:e})}const J_=M("ZodDefault",(e,t)=>{ng.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Y_(e,t){return new J_({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const Q_=M("ZodPrefault",(e,t)=>{sg.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType});function X_(e,t){return new Q_({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const xu=M("ZodNonOptional",(e,t)=>{og.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ey(e,t){return new xu({type:"nonoptional",innerType:e,...W(t)})}const ty=M("ZodCatch",(e,t)=>{ag.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ry(e,t){return new ty({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const ny=M("ZodPipe",(e,t)=>{ig.init(e,t),ke.init(e,t),e.in=t.in,e.out=t.out});function Ro(e,t){return new ny({type:"pipe",in:e,out:t})}const sy=M("ZodReadonly",(e,t)=>{cg.init(e,t),ke.init(e,t)});function oy(e){return new sy({type:"readonly",innerType:e})}const Au=M("ZodCustom",(e,t)=>{lg.init(e,t),ke.init(e,t)});function ay(e){const t=new et({check:"custom"});return t._zod.check=e,t}function iy(e,t){return n_(Au,e??(()=>!0),t)}function cy(e,t={}){return s_(Au,e,t)}function ly(e){const t=ay(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(vn(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(vn(s))}},e(r.value,r)));return t}function zu(e,t){return Ro(Ou(e),t)}const uy={custom:"custom"};function dy(e){return Dg(_a,e)}const qs="2025-11-25",fy=[qs,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],ar="io.modelcontextprotocol/related-task",Us="2.0",xe=iy(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Du=pe([k(),ae().int()]),qu=k();Ve({ttl:ae().optional(),pollInterval:ae().optional()});const hy=j({ttl:ae().optional()}),py=j({taskId:k()}),$a=Ve({progressToken:Du.optional(),[ar]:py.optional()}),nt=j({_meta:$a.optional()}),Tn=nt.extend({task:hy.optional()}),my=e=>Tn.safeParse(e).success,Le=j({method:k(),params:nt.loose().optional()}),at=j({_meta:$a.optional()}),it=j({method:k(),params:at.loose().optional()}),He=Ve({_meta:$a.optional()}),Rn=pe([k(),ae().int()]),Uu=j({jsonrpc:I(Us),id:Rn,...Le.shape}).strict(),Co=e=>Uu.safeParse(e).success,Fu=j({jsonrpc:I(Us),...it.shape}).strict(),gy=e=>Fu.safeParse(e).success,wa=j({jsonrpc:I(Us),id:Rn,result:He}).strict(),rn=e=>wa.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 ba=j({jsonrpc:I(Us),id:Rn.optional(),error:j({code:ae().int(),message:k(),data:$e().optional()})}).strict(),_y=e=>ba.safeParse(e).success,rs=pe([Uu,Fu,wa,ba]);pe([wa,ba]);const Cr=He.strict(),yy=at.extend({requestId:Rn.optional(),reason:k().optional()}),Sa=it.extend({method:I("notifications/cancelled"),params:yy}),vy=j({src:k(),mimeType:k().optional(),sizes:U(k()).optional(),theme:rt(["light","dark"]).optional()}),Cn=j({icons:U(vy).optional()}),Ar=j({name:k(),title:k().optional()}),Fs=Ar.extend({...Ar.shape,...Cn.shape,version:k(),websiteUrl:k().optional(),description:k().optional()}),$y=va(j({applyDefaults:me().optional()}),ge(k(),$e())),wy=zu(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,va(j({form:$y.optional(),url:xe.optional()}),ge(k(),$e()).optional())),by=Ve({list:xe.optional(),cancel:xe.optional(),requests:Ve({sampling:Ve({createMessage:xe.optional()}).optional(),elicitation:Ve({create:xe.optional()}).optional()}).optional()}),Sy=Ve({list:xe.optional(),cancel:xe.optional(),requests:Ve({tools:Ve({call:xe.optional()}).optional()}).optional()}),Ey=j({experimental:ge(k(),xe).optional(),sampling:j({context:xe.optional(),tools:xe.optional()}).optional(),elicitation:wy.optional(),roots:j({listChanged:me().optional()}).optional(),tasks:by.optional(),extensions:ge(k(),xe).optional()}),ky=nt.extend({protocolVersion:k(),capabilities:Ey,clientInfo:Fs}),Py=Le.extend({method:I("initialize"),params:ky}),Ty=j({experimental:ge(k(),xe).optional(),logging:xe.optional(),completions:xe.optional(),prompts:j({listChanged:me().optional()}).optional(),resources:j({subscribe:me().optional(),listChanged:me().optional()}).optional(),tools:j({listChanged:me().optional()}).optional(),tasks:Sy.optional(),extensions:ge(k(),xe).optional()}),Vu=He.extend({protocolVersion:k(),capabilities:Ty,serverInfo:Fs,instructions:k().optional()}),Lu=it.extend({method:I("notifications/initialized"),params:at.optional()}),Ry=e=>Lu.safeParse(e).success,Vs=Le.extend({method:I("ping"),params:nt.optional()}),Cy=j({progress:ae(),total:Te(ae()),message:Te(k())}),Iy=j({...at.shape,...Cy.shape,progressToken:Du}),Ea=it.extend({method:I("notifications/progress"),params:Iy}),Ny=nt.extend({cursor:qu.optional()}),In=Le.extend({params:Ny.optional()}),Nn=He.extend({nextCursor:qu.optional()}),jy=rt(["working","input_required","completed","failed","cancelled"]),jn=j({taskId:k(),status:jy,ttl:pe([ae(),q_()]),createdAt:k(),lastUpdatedAt:k(),pollInterval:Te(ae()),statusMessage:Te(k())}),$n=He.extend({task:jn}),Oy=at.merge(jn),_s=it.extend({method:I("notifications/tasks/status"),params:Oy}),ka=Le.extend({method:I("tasks/get"),params:nt.extend({taskId:k()})}),Pa=He.merge(jn),Ta=Le.extend({method:I("tasks/result"),params:nt.extend({taskId:k()})});He.loose();const Ra=In.extend({method:I("tasks/list")}),Ca=Nn.extend({tasks:U(jn)}),Ia=Le.extend({method:I("tasks/cancel"),params:nt.extend({taskId:k()})}),My=He.merge(jn),Hu=j({uri:k(),mimeType:Te(k()),_meta:ge(k(),$e()).optional()}),Zu=Hu.extend({text:k()}),Na=k().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Ku=Hu.extend({blob:Na}),On=rt(["user","assistant"]),Vr=j({audience:U(On).optional(),priority:ae().min(0).max(1).optional(),lastModified:Tu({offset:!0}).optional()}),Gu=j({...Ar.shape,...Cn.shape,uri:k(),description:Te(k()),mimeType:Te(k()),size:Te(ae()),annotations:Vr.optional(),_meta:Te(Ve({}))}),xy=j({...Ar.shape,...Cn.shape,uriTemplate:k(),description:Te(k()),mimeType:Te(k()),annotations:Vr.optional(),_meta:Te(Ve({}))}),Wu=In.extend({method:I("resources/list")}),ja=Nn.extend({resources:U(Gu)}),Bu=In.extend({method:I("resources/templates/list")}),Oa=Nn.extend({resourceTemplates:U(xy)}),Ma=nt.extend({uri:k()}),Ay=Ma,Ju=Le.extend({method:I("resources/read"),params:Ay}),xa=He.extend({contents:U(pe([Zu,Ku]))}),Aa=it.extend({method:I("notifications/resources/list_changed"),params:at.optional()}),zy=Ma,Dy=Le.extend({method:I("resources/subscribe"),params:zy}),qy=Ma,Uy=Le.extend({method:I("resources/unsubscribe"),params:qy}),Fy=at.extend({uri:k()}),Vy=it.extend({method:I("notifications/resources/updated"),params:Fy}),Ly=j({name:k(),description:Te(k()),required:Te(me())}),Hy=j({...Ar.shape,...Cn.shape,description:Te(k()),arguments:Te(U(Ly)),_meta:Te(Ve({}))}),Yu=In.extend({method:I("prompts/list")}),za=Nn.extend({prompts:U(Hy)}),Zy=nt.extend({name:k(),arguments:ge(k(),k()).optional()}),Ky=Le.extend({method:I("prompts/get"),params:Zy}),Da=j({type:I("text"),text:k(),annotations:Vr.optional(),_meta:ge(k(),$e()).optional()}),qa=j({type:I("image"),data:Na,mimeType:k(),annotations:Vr.optional(),_meta:ge(k(),$e()).optional()}),Ua=j({type:I("audio"),data:Na,mimeType:k(),annotations:Vr.optional(),_meta:ge(k(),$e()).optional()}),Gy=j({type:I("tool_use"),name:k(),id:k(),input:ge(k(),$e()),_meta:ge(k(),$e()).optional()}),Qu=j({type:I("resource"),resource:pe([Zu,Ku]),annotations:Vr.optional(),_meta:ge(k(),$e()).optional()}),Xu=Gu.extend({type:I("resource_link")}),Mn=pe([Da,qa,Ua,Xu,Qu]),Wy=j({role:On,content:Mn}),ed=He.extend({description:k().optional(),messages:U(Wy)}),Fa=it.extend({method:I("notifications/prompts/list_changed"),params:at.optional()}),By=j({title:k().optional(),readOnlyHint:me().optional(),destructiveHint:me().optional(),idempotentHint:me().optional(),openWorldHint:me().optional()}),Jy=j({taskSupport:rt(["required","optional","forbidden"]).optional()}),Va=j({...Ar.shape,...Cn.shape,description:k().optional(),inputSchema:j({type:I("object"),properties:ge(k(),xe).optional(),required:U(k()).optional()}).catchall($e()),outputSchema:j({type:I("object"),properties:ge(k(),xe).optional(),required:U(k()).optional()}).catchall($e()).optional(),annotations:By.optional(),execution:Jy.optional(),_meta:ge(k(),$e()).optional()}),Yy=In.extend({method:I("tools/list")}),La=Nn.extend({tools:U(Va)}),pr=He.extend({content:U(Mn).default([]),structuredContent:ge(k(),$e()).optional(),isError:me().optional()});pr.or(He.extend({toolResult:$e()}));const Qy=Tn.extend({name:k(),arguments:ge(k(),$e()).optional()}),td=Le.extend({method:I("tools/call"),params:Qy}),Ha=it.extend({method:I("notifications/tools/list_changed"),params:at.optional()}),Xy=j({autoRefresh:me().default(!0),debounceMs:ae().int().nonnegative().default(300)}),rd=rt(["debug","info","notice","warning","error","critical","alert","emergency"]),ev=nt.extend({level:rd}),tv=Le.extend({method:I("logging/setLevel"),params:ev}),rv=at.extend({level:rd,logger:k().optional(),data:$e()}),nd=it.extend({method:I("notifications/message"),params:rv}),nv=j({name:k().optional()}),sv=j({hints:U(nv).optional(),costPriority:ae().min(0).max(1).optional(),speedPriority:ae().min(0).max(1).optional(),intelligencePriority:ae().min(0).max(1).optional()}),ov=j({mode:rt(["auto","required","none"]).optional()}),av=j({type:I("tool_result"),toolUseId:k().describe("The unique identifier for the corresponding tool call."),content:U(Mn).default([]),structuredContent:j({}).loose().optional(),isError:me().optional(),_meta:ge(k(),$e()).optional()}),iv=ju("type",[Da,qa,Ua]),ys=ju("type",[Da,qa,Ua,Gy,av]),cv=j({role:On,content:pe([ys,U(ys)]),_meta:ge(k(),$e()).optional()}),lv=Tn.extend({messages:U(cv),modelPreferences:sv.optional(),systemPrompt:k().optional(),includeContext:rt(["none","thisServer","allServers"]).optional(),temperature:ae().optional(),maxTokens:ae().int(),stopSequences:U(k()).optional(),metadata:xe.optional(),tools:U(Va).optional(),toolChoice:ov.optional()}),Za=Le.extend({method:I("sampling/createMessage"),params:lv}),sd=He.extend({model:k(),stopReason:Te(rt(["endTurn","stopSequence","maxTokens"]).or(k())),role:On,content:iv}),od=He.extend({model:k(),stopReason:Te(rt(["endTurn","stopSequence","maxTokens","toolUse"]).or(k())),role:On,content:pe([ys,U(ys)])}),uv=j({type:I("boolean"),title:k().optional(),description:k().optional(),default:me().optional()}),dv=j({type:I("string"),title:k().optional(),description:k().optional(),minLength:ae().optional(),maxLength:ae().optional(),format:rt(["email","uri","date","date-time"]).optional(),default:k().optional()}),fv=j({type:rt(["number","integer"]),title:k().optional(),description:k().optional(),minimum:ae().optional(),maximum:ae().optional(),default:ae().optional()}),hv=j({type:I("string"),title:k().optional(),description:k().optional(),enum:U(k()),default:k().optional()}),pv=j({type:I("string"),title:k().optional(),description:k().optional(),oneOf:U(j({const:k(),title:k()})),default:k().optional()}),mv=j({type:I("string"),title:k().optional(),description:k().optional(),enum:U(k()),enumNames:U(k()).optional(),default:k().optional()}),gv=pe([hv,pv]),_v=j({type:I("array"),title:k().optional(),description:k().optional(),minItems:ae().optional(),maxItems:ae().optional(),items:j({type:I("string"),enum:U(k())}),default:U(k()).optional()}),yv=j({type:I("array"),title:k().optional(),description:k().optional(),minItems:ae().optional(),maxItems:ae().optional(),items:j({anyOf:U(j({const:k(),title:k()}))}),default:U(k()).optional()}),vv=pe([_v,yv]),$v=pe([mv,gv,vv]),wv=pe([$v,uv,dv,fv]),bv=Tn.extend({mode:I("form").optional(),message:k(),requestedSchema:j({type:I("object"),properties:ge(k(),wv),required:U(k()).optional()})}),Sv=Tn.extend({mode:I("url"),message:k(),elicitationId:k(),url:k().url()}),Ev=pe([bv,Sv]),ad=Le.extend({method:I("elicitation/create"),params:Ev}),kv=at.extend({elicitationId:k()}),Pv=it.extend({method:I("notifications/elicitation/complete"),params:kv}),id=He.extend({action:rt(["accept","decline","cancel"]),content:zu(e=>e===null?void 0:e,ge(k(),pe([k(),ae(),me(),U(k())])).optional())}),Tv=j({type:I("ref/resource"),uri:k()}),Rv=j({type:I("ref/prompt"),name:k()}),Cv=nt.extend({ref:pe([Rv,Tv]),argument:j({name:k(),value:k()}),context:j({arguments:ge(k(),k()).optional()}).optional()}),Iv=Le.extend({method:I("completion/complete"),params:Cv}),cd=He.extend({completion:Ve({values:U(k()).max(100),total:Te(ae().int()),hasMore:Te(me())})}),Nv=j({uri:k().startsWith("file://"),name:k().optional(),_meta:ge(k(),$e()).optional()}),jv=Le.extend({method:I("roots/list"),params:nt.optional()}),Ov=He.extend({roots:U(Nv)}),Mv=it.extend({method:I("notifications/roots/list_changed"),params:at.optional()});pe([Vs,Py,Iv,tv,Ky,Yu,Wu,Bu,Ju,Dy,Uy,td,Yy,ka,Ta,Ra,Ia]);pe([Sa,Ea,Lu,Mv,_s]);pe([Cr,sd,od,id,Ov,Pa,Ca,$n]);pe([Vs,Za,ad,jv,ka,Ta,Ra,Ia]);pe([Sa,Ea,nd,Vy,Aa,Ha,Fa,_s,Pv]);pe([Cr,Vu,cd,ed,za,ja,Oa,xa,pr,La,Pa,Ca,$n]);class X extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===re.UrlElicitationRequired&&n){const s=n;if(s.elicitations)return new xv(s.elicitations,r)}return new X(t,r,n)}}class xv extends X{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(re.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){var t;return((t=this.data)==null?void 0:t.elicitations)??[]}}function Ka(e){return!!e._zod}function Ot(e,t){return Ka(e)?hu(e,t):e.safeParse(t)}function ld(e){var r,n;if(!e)return;let t;if(Ka(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 ud(e){var s;if(Ka(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 tr(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Bc(e){const t=ld(e),r=t==null?void 0:t.method;if(!r)throw new Error("Schema is missing a method literal");const n=ud(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Jc(e,t){const r=Ot(e,t);if(!r.success)throw r.error;return r.data}const Av=6e4;class dd{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(Sa,r=>{this._oncancel(r)}),this.setNotificationHandler(Ea,r=>{this._onprogress(r)}),this.setRequestHandler(Vs,r=>({})),this._taskStore=t==null?void 0:t.taskStore,this._taskMessageQueue=t==null?void 0:t.taskMessageQueue,this._taskStore&&(this.setRequestHandler(ka,async(r,n)=>{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new X(re.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(Ta,async(r,n)=>{const s=async()=>{var i;const o=r.params.taskId;if(this._taskMessageQueue){let c;for(;c=await this._taskMessageQueue.dequeue(o,n.sessionId);){if(c.type==="response"||c.type==="error"){const l=c.message,d=l.id,f=this._requestResolvers.get(d);if(f)if(this._requestResolvers.delete(d),c.type==="response")f(l);else{const _=l,y=new X(_.error.code,_.error.message,_.error.data);f(y)}else{const _=c.type==="response"?"Response":"Error";this._onerror(new Error(`${_} handler missing for request ${d}`))}continue}await((i=this._transport)==null?void 0:i.send(c.message,{relatedRequestId:n.requestId}))}}const a=await this._taskStore.getTask(o,n.sessionId);if(!a)throw new X(re.InvalidParams,`Task not found: ${o}`);if(!tr(a.status))return await this._waitForTaskUpdate(o,n.signal),await s();if(tr(a.status)){const c=await this._taskStore.getTaskResult(o,n.sessionId);return this._clearTaskQueue(o),{...c,_meta:{...c._meta,[ar]:{taskId:o}}}}return await s()};return await s()}),this.setRequestHandler(Ra,async(r,n)=>{var s;try{const{tasks:o,nextCursor:a}=await this._taskStore.listTasks((s=r.params)==null?void 0:s.cursor,n.sessionId);return{tasks:o,nextCursor:a,_meta:{}}}catch(o){throw new X(re.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Ia,async(r,n)=>{try{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new X(re.InvalidParams,`Task not found: ${r.params.taskId}`);if(tr(s.status))throw new X(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 X(re.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(s){throw s instanceof X?s:new X(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),X.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),rn(c)||_y(c)?this._onresponse(c):Co(c)?this._onrequest(c,l):gy(c)?this._onnotification(c):this._onerror(new Error(`Unknown message type: ${JSON.stringify(c)}`))},await this._transport.start()}_onclose(){var n;const t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const s of this._timeoutInfo.values())clearTimeout(s.timeoutId);this._timeoutInfo.clear();for(const s of this._requestHandlerAbortControllers.values())s.abort();this._requestHandlerAbortControllers.clear();const r=X.fromError(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,f,_,y;const n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,s=this._transport,o=(_=(f=(d=t.params)==null?void 0:d._meta)==null?void 0:f[ar])==null?void 0:_.taskId;if(n===void 0){const g={jsonrpc:"2.0",id:t.id,error:{code:re.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:g,timestamp:Date.now()},s==null?void 0:s.sessionId).catch($=>this._onerror(new Error(`Failed to enqueue error response: ${$}`))):s==null||s.send(g).catch($=>this._onerror(new Error(`Failed to send an error response: ${$}`)));return}const a=new AbortController;this._requestHandlerAbortControllers.set(t.id,a);const i=my(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:(y=t.params)==null?void 0:y._meta,sendNotification:async g=>{if(a.signal.aborted)return;const $={relatedRequestId:t.id};o&&($.relatedTask={taskId:o}),await this.notification(g,$)},sendRequest:async(g,$,m)=>{var S;if(a.signal.aborted)throw new X(re.ConnectionClosed,"Request was cancelled");const h={...m,relatedRequestId:t.id};o&&!h.relatedTask&&(h.relatedTask={taskId:o});const v=((S=h.relatedTask)==null?void 0:S.taskId)??o;return v&&c&&await c.updateTaskStatus(v,"input_required"),await this.request(g,$,h)},authInfo:r==null?void 0:r.authInfo,requestId:t.id,requestInfo:r==null?void 0:r.requestInfo,taskId:o,taskStore:c,taskRequestedTtl:i==null?void 0:i.ttl,closeSSEStream:r==null?void 0:r.closeSSEStream,closeStandaloneSSEStream:r==null?void 0:r.closeStandaloneSSEStream};Promise.resolve().then(()=>{i&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,l)).then(async g=>{if(a.signal.aborted)return;const $={result:g,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 g=>{if(a.signal.aborted)return;const $={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(g.code)?g.code:re.InternalError,message:g.message??"Internal error",...g.data!==void 0&&{data:g.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(g=>this._onerror(new Error(`Failed to send response: ${g}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===a&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){const{progressToken:r,...n}=t.params,s=Number(r),o=this._progressHandlers.get(s);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}const a=this._responseHandlers.get(s),i=this._timeoutInfo.get(s);if(i&&a&&i.resetTimeoutOnProgress)try{this._resetTimeout(s)}catch(c){this._responseHandlers.delete(s),this._progressHandlers.delete(s),this._cleanupTimeout(s),a(c);return}o(n)}_onresponse(t){const r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),rn(t))n(t);else{const a=new X(t.error.code,t.error.message,t.error.data);n(a)}return}const s=this._responseHandlers.get(r);if(s===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let o=!1;if(rn(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),rn(t))s(t);else{const a=X.fromError(t.error.code,t.error.message,t.error.data);s(a)}}get transport(){return this._transport}async close(){var t;await((t=this._transport)==null?void 0:t.close())}async*requestStream(t,r,n){var a,i;const{task:s}=n??{};if(!s){try{yield{type:"result",result:await this.request(t,r,n)}}catch(c){yield{type:"error",error:c instanceof X?c:new X(re.InternalError,String(c))}}return}let o;try{const c=await this.request(t,$n,n);if(c.task)o=c.task.taskId,yield{type:"taskCreated",task:c.task};else throw new X(re.InternalError,"Task creation did not return a task");for(;;){const l=await this.getTask({taskId:o},n);if(yield{type:"taskStatus",task:l},tr(l.status)){l.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)}:l.status==="failed"?yield{type:"error",error:new X(re.InternalError,`Task ${o} failed`)}:l.status==="cancelled"&&(yield{type:"error",error:new X(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(f=>setTimeout(f,d)),(i=n==null?void 0:n.signal)==null||i.throwIfAborted()}}catch(c){yield{type:"error",error:c instanceof X?c:new X(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,O;const f=A=>{d(A)};if(!this._transport){f(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){f(A);return}(S=n==null?void 0:n.signal)==null||S.throwIfAborted();const _=this._requestMessageId++,y={...t,jsonrpc:"2.0",id:_};n!=null&&n.onprogress&&(this._progressHandlers.set(_,n.onprogress),y.params={...t.params,_meta:{...((R=t.params)==null?void 0:R._meta)||{},progressToken:_}}),i&&(y.params={...y.params,task:i}),c&&(y.params={...y.params,_meta:{...((P=y.params)==null?void 0:P._meta)||{},[ar]:c}});const g=A=>{var V;this._responseHandlers.delete(_),this._progressHandlers.delete(_),this._cleanupTimeout(_),(V=this._transport)==null||V.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:_,reason:String(A)}},{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a}).catch(D=>this._onerror(new Error(`Failed to send cancellation: ${D}`)));const L=A instanceof X?A:new X(re.RequestTimeout,String(A));d(L)};this._responseHandlers.set(_,A=>{var L;if(!((L=n==null?void 0:n.signal)!=null&&L.aborted)){if(A instanceof Error)return d(A);try{const V=Ot(r,A.result);V.success?l(V.data):d(V.error)}catch(V){d(V)}}}),(O=n==null?void 0:n.signal)==null||O.addEventListener("abort",()=>{var A;g((A=n==null?void 0:n.signal)==null?void 0:A.reason)});const $=(n==null?void 0:n.timeout)??Av,m=()=>g(X.fromError(re.RequestTimeout,"Request timed out",{timeout:$}));this._setupTimeout(_,$,n==null?void 0:n.maxTotalTimeout,m,(n==null?void 0:n.resetTimeoutOnProgress)??!1);const h=c==null?void 0:c.taskId;if(h){const A=L=>{const V=this._responseHandlers.get(_);V?V(L):this._onerror(new Error(`Response handler missing for side-channeled request ${_}`))};this._requestResolvers.set(_,A),this._enqueueTaskMessage(h,{type:"request",message:y,timestamp:Date.now()}).catch(L=>{this._cleanupTimeout(_),d(L)})}else this._transport.send(y,{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a}).catch(A=>{this._cleanupTimeout(_),d(A)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},Pa,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},Ca,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},My,r)}async notification(t,r){var i,c,l,d;if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);const n=(i=r==null?void 0:r.relatedTask)==null?void 0:i.taskId;if(n){const f={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...((c=t.params)==null?void 0:c._meta)||{},[ar]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:f,timestamp:Date.now()});return}if((((l=this._options)==null?void 0:l.debouncedNotificationMethods)??[]).includes(t.method)&&!t.params&&!(r!=null&&r.relatedRequestId)&&!(r!=null&&r.relatedTask)){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{var _,y;if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let f={...t,jsonrpc:"2.0"};r!=null&&r.relatedTask&&(f={...f,params:{...f.params,_meta:{...((_=f.params)==null?void 0:_._meta)||{},[ar]:r.relatedTask}}}),(y=this._transport)==null||y.send(f,r).catch(g=>this._onerror(g))});return}let a={...t,jsonrpc:"2.0"};r!=null&&r.relatedTask&&(a={...a,params:{...a.params,_meta:{...((d=a.params)==null?void 0:d._meta)||{},[ar]:r.relatedTask}}}),await this._transport.send(a,r)}setRequestHandler(t,r){const n=Bc(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,o)=>{const a=Jc(t,s);return Promise.resolve(r(a,o))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){const n=Bc(t);this._notificationHandlers.set(n,s=>{const o=Jc(t,s);return Promise.resolve(r(o))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){const r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,n){var o;if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const s=(o=this._options)==null?void 0:o.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,n,s)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){const n=await this._taskMessageQueue.dequeueAll(t,r);for(const s of n)if(s.type==="request"&&Co(s.message)){const o=s.message.id,a=this._requestResolvers.get(o);a?(a(new X(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 X(re.InvalidRequest,"Request cancelled"));return}const c=setTimeout(a,n);r.addEventListener("abort",()=>{clearTimeout(c),i(new X(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 X(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=_s.parse({method:"notifications/tasks/status",params:i});await this.notification(c),tr(i.status)&&this._cleanupTaskProgressHandler(s)}},getTaskResult:s=>n.getTaskResult(s,r),updateTaskStatus:async(s,o,a)=>{const i=await n.getTask(s,r);if(!i)throw new X(re.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(tr(i.status))throw new X(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=_s.parse({method:"notifications/tasks/status",params:c});await this.notification(l),tr(c.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>n.listTasks(s,r)}}}function Yc(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function zv(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];Yc(a)&&Yc(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 Dv extends dd{constructor(){super(...arguments);ne(this,"_registeredMethods",new Set);ne(this,"_eventSlots",new Map);ne(this,"setRequestHandler",(r,n)=>{this._assertMethodNotRegistered(r,"setRequestHandler"),super.setRequestHandler(r,n)});ne(this,"setNotificationHandler",(r,n)=>{this._assertMethodNotRegistered(r,"setNotificationHandler"),super.setNotificationHandler(r,n)});ne(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 fd="2026-01-26",qv="ui/notifications/tool-input-partial",Uv=pe([I("light"),I("dark")]).describe("Color theme preference for the host environment."),wn=pe([I("inline"),I("fullscreen"),I("pip")]).describe("Display mode for UI presentation."),Fv=pe([I("--color-background-primary"),I("--color-background-secondary"),I("--color-background-tertiary"),I("--color-background-inverse"),I("--color-background-ghost"),I("--color-background-info"),I("--color-background-danger"),I("--color-background-success"),I("--color-background-warning"),I("--color-background-disabled"),I("--color-text-primary"),I("--color-text-secondary"),I("--color-text-tertiary"),I("--color-text-inverse"),I("--color-text-ghost"),I("--color-text-info"),I("--color-text-danger"),I("--color-text-success"),I("--color-text-warning"),I("--color-text-disabled"),I("--color-border-primary"),I("--color-border-secondary"),I("--color-border-tertiary"),I("--color-border-inverse"),I("--color-border-ghost"),I("--color-border-info"),I("--color-border-danger"),I("--color-border-success"),I("--color-border-warning"),I("--color-border-disabled"),I("--color-ring-primary"),I("--color-ring-secondary"),I("--color-ring-inverse"),I("--color-ring-info"),I("--color-ring-danger"),I("--color-ring-success"),I("--color-ring-warning"),I("--font-sans"),I("--font-mono"),I("--font-weight-normal"),I("--font-weight-medium"),I("--font-weight-semibold"),I("--font-weight-bold"),I("--font-text-xs-size"),I("--font-text-sm-size"),I("--font-text-md-size"),I("--font-text-lg-size"),I("--font-heading-xs-size"),I("--font-heading-sm-size"),I("--font-heading-md-size"),I("--font-heading-lg-size"),I("--font-heading-xl-size"),I("--font-heading-2xl-size"),I("--font-heading-3xl-size"),I("--font-text-xs-line-height"),I("--font-text-sm-line-height"),I("--font-text-md-line-height"),I("--font-text-lg-line-height"),I("--font-heading-xs-line-height"),I("--font-heading-sm-line-height"),I("--font-heading-md-line-height"),I("--font-heading-lg-line-height"),I("--font-heading-xl-line-height"),I("--font-heading-2xl-line-height"),I("--font-heading-3xl-line-height"),I("--border-radius-xs"),I("--border-radius-sm"),I("--border-radius-md"),I("--border-radius-lg"),I("--border-radius-xl"),I("--border-radius-full"),I("--border-width-regular"),I("--shadow-hairline"),I("--shadow-sm"),I("--shadow-md"),I("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),Vv=ge(Fv.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(),ko()]).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.`),Lv=j({method:I("ui/open-link"),params:j({url:k().describe("URL to open in the host's browser")})});j({isError:me().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough();j({isError:me().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough();j({isError:me().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();var Hv=j({method:I("ui/notifications/sandbox-proxy-ready"),params:j({})}),Ga=j({connectDomains:U(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:U(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:U(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:U(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'`)")}),Wa=j({camera:j({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:j({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:j({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:j({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),Zv=j({method:I("ui/notifications/size-changed"),params:j({width:ae().optional().describe("New width in pixels."),height:ae().optional().describe("New height in pixels.")})});j({method:I("ui/notifications/tool-input"),params:j({arguments:ge(k(),$e().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})});j({method:I("ui/notifications/tool-input-partial"),params:j({arguments:ge(k(),$e().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})});j({method:I("ui/notifications/tool-cancelled"),params:j({reason:k().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})});var Kv=j({fonts:k().optional()}),Gv=j({variables:Vv.optional().describe("CSS variables for theming the app."),css:Kv.optional().describe("CSS blocks that apps can inject.")});j({method:I("ui/resource-teardown"),params:j({})});var Wv=ge(k(),$e()),Qc=j({text:j({}).optional().describe("Host supports text content blocks."),image:j({}).optional().describe("Host supports image content blocks."),audio:j({}).optional().describe("Host supports audio content blocks."),resource:j({}).optional().describe("Host supports resource content blocks."),resourceLink:j({}).optional().describe("Host supports resource link content blocks."),structuredContent:j({}).optional().describe("Host supports structured content.")}),Bv=j({method:I("ui/notifications/request-teardown"),params:j({}).optional()}),Jv=j({experimental:ge(k(),ge(k(),ya()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:j({}).optional().describe("Host supports opening external URLs."),downloadFile:j({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:j({listChanged:me().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:j({listChanged:me().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:j({}).optional().describe("Host accepts log messages."),sandbox:j({permissions:Wa.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:Ga.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:Qc.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:Qc.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:j({tools:j({}).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.")}),Yv=j({experimental:ge(k(),ge(k(),ya()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:j({listChanged:me().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:U(wn).optional().describe("Display modes the app supports.")}),Qv=j({method:I("ui/notifications/initialized"),params:j({}).optional()});j({csp:Ga.optional().describe("Content Security Policy configuration for UI resources."),permissions:Wa.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 Xc=j({method:I("ui/request-display-mode"),params:j({mode:wn.describe("The display mode being requested.")})});j({mode:wn.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough();var Xv=pe([I("model"),I("app")]).describe("Tool visibility scope - who can access the tool.");j({resourceUri:k().optional(),visibility:U(Xv).optional().describe(`Who can access this tool. Default: ["model", "app"] +- "model": Tool visible to and callable by the agent +- "app": Tool callable by the app from this server only`),csp:Po().optional(),permissions:Po().optional()});j({mimeTypes:U(k()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});var e$=j({method:I("ui/download-file"),params:j({contents:U(pe([Qu,Xu])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),t$=j({method:I("ui/message"),params:j({role:I("user").describe('Message role, currently only "user" is supported.'),content:U(Mn).describe("Message content blocks (text, image, etc.).")})});j({method:I("ui/notifications/sandbox-resource-ready"),params:j({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:Ga.optional().describe("CSP configuration from resource metadata."),permissions:Wa.optional().describe("Sandbox permissions from resource metadata.")})});j({method:I("ui/notifications/tool-result"),params:pr.describe("Standard MCP tool execution result.")});var hd=j({toolInfo:j({id:Rn.optional().describe("JSON-RPC id of the tools/call request."),tool:Va.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:Uv.optional().describe("Current color theme preference."),styles:Gv.optional().describe("Style configuration for theming the app."),displayMode:wn.optional().describe("How the UI is currently displayed."),availableDisplayModes:U(wn).optional().describe("Display modes the host supports."),containerDimensions:pe([j({height:ae().describe("Fixed container height in pixels.")}),j({maxHeight:pe([ae(),ko()]).optional().describe("Maximum container height in pixels.")})]).and(pe([j({width:ae().describe("Fixed container width in pixels.")}),j({maxWidth:pe([ae(),ko()]).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([I("web"),I("desktop"),I("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:j({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:j({top:ae().describe("Top safe area inset in pixels."),right:ae().describe("Right safe area inset in pixels."),bottom:ae().describe("Bottom safe area inset in pixels."),left:ae().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough();j({method:I("ui/notifications/host-context-changed"),params:hd.describe("Partial context update containing only changed fields.")});var r$=j({method:I("ui/update-model-context"),params:j({content:U(Mn).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:ge(k(),$e().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),n$=j({method:I("ui/initialize"),params:j({appInfo:Fs.describe("App identification (name and version)."),appCapabilities:Yv.describe("Features and capabilities this app provides."),protocolVersion:k().describe("Protocol version this app supports.")})});j({protocolVersion:k().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Fs.describe("Host application identification and version."),hostCapabilities:Jv.describe("Features and capabilities provided by the host."),hostContext:hd.describe("Rich context about the host environment.")}).passthrough();class s${constructor(t=window.parent,r){ne(this,"eventTarget");ne(this,"eventSource");ne(this,"messageListener");ne(this,"onclose");ne(this,"onerror");ne(this,"onmessage");ne(this,"sessionId");ne(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=rs.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!==qv&&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 o$=[fd];class a$ extends Dv{constructor(r,n,s,o){super(o);ne(this,"_client");ne(this,"_hostInfo");ne(this,"_capabilities");ne(this,"_appCapabilities");ne(this,"_hostContext",{});ne(this,"_appInfo");ne(this,"_initializedReceived",!1);ne(this,"_baseReplaceRequestHandler",this.replaceRequestHandler);ne(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)))});ne(this,"eventSchemas",{sizechange:Zv,sandboxready:Hv,initialized:Qv,requestteardown:Bv,loggingmessage:nd});ne(this,"onping");ne(this,"_onmessage");ne(this,"_onopenlink");ne(this,"_ondownloadfile");ne(this,"_onrequestdisplaymode");ne(this,"_onupdatemodelcontext");ne(this,"_oncalltool");ne(this,"_onlistresources");ne(this,"_onlistresourcetemplates");ne(this,"_onreadresource");ne(this,"_onlistprompts");ne(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(n$,a=>this._oninitialize(a)),this.setRequestHandler(Vs,(a,i)=>{var c;return(c=this.onping)==null||c.call(this,a.params,i),{}}),this.replaceRequestHandler(Xc,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(t$,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(Lv,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(e$,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(Xc,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(r$,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(td,async(n,s)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,s)})}set oncreatesamplingmessage(r){this.setRequestHandler(Za,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(Wu,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(Bu,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(Ju,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(Yu,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:o$.includes(n)?n:fd,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];i$(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},Wv,n)}callTool(r,n){return this.request({method:"tools/call",params:r},pr,n)}listTools(r,n){return this.request({method:"tools/list",params:r},La,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},pr,{signal:o.signal}),n.tools.listChanged&&this._client.setNotificationHandler(Ha,s=>this.sendToolListChanged(s.params))),n.resources&&(this.onlistresources=async(s,o)=>this._client.request({method:"resources/list",params:s},ja,{signal:o.signal}),this.onlistresourcetemplates=async(s,o)=>this._client.request({method:"resources/templates/list",params:s},Oa,{signal:o.signal}),this.onreadresource=async(s,o)=>this._client.request({method:"resources/read",params:s},xa,{signal:o.signal}),n.resources.listChanged&&this._client.setNotificationHandler(Aa,s=>this.sendResourceListChanged(s.params))),n.prompts&&(this.onlistprompts=async(s,o)=>this._client.request({method:"prompts/list",params:s},za,{signal:o.signal}),n.prompts.listChanged&&this._client.setNotificationHandler(Fa,s=>this.sendPromptListChanged(s.params)))}return super.connect(r)}}function i$(e,t){return JSON.stringify(e)===JSON.stringify(t)}const c$=1024,ns=16,l$=11;function Ge(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function u$(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return e}function pd(e){return e.type!=="cameraUpdate"&&e.type!=="delete"&&e.type!=="restoreCheckpoint"}function bn(e){return e.type==="text"&&typeof(e.text??e.originalText)=="string"}function Ls(e){const t=Ge(e.width);if(t!==void 0&&t>0)return t;const r=String(e.text??e.originalText??""),n=Ge(e.fontSize)??20;return r.length*n*.65}function Io(e){const t=Ge(e.x),r=Ge(e.y);if(t===void 0||r===void 0)return null;let n=t,s=r,o=t,a=r;const i=bn(e)?Ls(e):Ge(e.width),c=Ge(e.height)??(bn(e)?(Ge(e.fontSize)??20)*1.4:0);if(i!==void 0&&i>0&&(o=Math.max(o,t+i)),c!==void 0&&c>0&&(a=Math.max(a,r+c)),Array.isArray(e.points))for(const l of e.points)!Array.isArray(l)||l.length<2||(n=Math.min(n,t+(Ge(l[0])??0)),s=Math.min(s,r+(Ge(l[1])??0)),o=Math.max(o,t+(Ge(l[0])??0)),a=Math.max(a,r+(Ge(l[1])??0)));return o<=n?null:{x:n,y:s,width:o-n,height:Math.max(0,a-s)}}function md(e,t){const r=Math.min(e.x,t.x),n=Math.min(e.y,t.y);return{x:r,y:n,width:Math.max(e.x+e.width,t.x+t.width)-r,height:Math.max(e.y+e.height,t.y+t.height)-n}}function d$(e){let t=null;for(const r of e){if(!pd(r)||bn(r))continue;const n=Io(r);n&&(t=t?md(t,n):n)}return t}function f$(e){let t=-1,r=1/0,n=-1;return e.forEach((s,o)=>{if(!bn(s))return;const a=Ge(s.y);if(a===void 0)return;const i=Ge(s.fontSize)??Ls(s);(an)&&(t=o,r=a,n=i)}),t}function h$(e,t,r){const n={...e};let s=Ls(n);const o=Math.max(1,t.width-ns*2),a=Ge(n.fontSize)??20;if(s>o){const i=Math.max(l$/a,o/s);n.fontSize=a*i,typeof n.height=="number"&&(n.height*=i),s=Math.min(o,s*i)}if(n.width=s,r)n.textAlign="center",n.x=t.x+(t.width-s)/2;else{const i=Ge(n.x)??t.x,c=t.x+ns,l=t.x+t.width-ns-s;n.x=Math.min(Math.max(i,c),Math.max(c,l))}return n}function p$(e){const t=e.map(u$);if(t.some(c=>c===void 0))return e;const r=t,n=f$(r);let s=d$(r);if(!s){if(n<0)return e;for(let c=0;c0?s.width:c$,i={x:o,y:(s==null?void 0:s.y)??0,width:a,height:(s==null?void 0:s.height)??0};return r.map((c,l)=>{if(!bn(c))return c;const d=Io(c),f=d!==null&&d.y+d.height<=i.y+8,_=Ls(c)>i.width-ns*2;return l===n||f||_?h$(c,i,l===n||f):c})}const m$=20,el=4/3;function rr(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function g$(e){const t=e.type;if(t==="cameraUpdate"||t==="delete"||t==="restoreCheckpoint")return null;const r=rr(e.x),n=rr(e.y);if(r===void 0||n===void 0)return null;let s=r,o=n,a=r,i=n;const c=rr(e.width),l=rr(e.height);if(c!==void 0&&(a=Math.max(a,r+c)),l!==void 0&&(i=Math.max(i,n+l)),t==="text"&&(c===void 0||c<=0)&&typeof(e.text??e.originalText)=="string"){const d=rr(e.fontSize)??20,f=String(e.text??e.originalText??"");a=Math.max(a,r+f.length*d*.65),i=Math.max(i,n+d*1.5)}if(Array.isArray(e.points))for(const d of e.points){if(!Array.isArray(d)||d.length<2)continue;const f=r+(rr(d[0])??0),_=n+(rr(d[1])??0);s=Math.min(s,f),o=Math.min(o,_),a=Math.max(a,f),i=Math.max(i,_)}return a<=s?null:{x:s,y:o,width:a-s,height:Math.max(0,i-o)}}function _$(e,t){const r=Math.min(e.x,t.x),n=Math.min(e.y,t.y);return{x:r,y:n,width:Math.max(e.x+e.width,t.x+t.width)-r,height:Math.max(e.y+e.height,t.y+t.height)-n}}function y$(e){return Math.max(m$,Math.round(Math.max(e.width,e.height)*.03))}function v$(e){const t=y$(e),r={x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2},n=r.width/r.height;if(Math.abs(n-el)<.01)return r;if(n>el){const o=Math.round(r.width*3/4);return{x:r.x,y:r.y-Math.round((o-r.height)/2),width:r.width,height:o}}const s=Math.round(r.height*4/3);return{x:r.x-Math.round((s-r.width)/2),y:r.y,width:s,height:r.height}}function $$(e){let t=null;const r=[];for(const n of e){if(!n||typeof n!="object"||Array.isArray(n))continue;const s=n;if(s.type==="cameraUpdate")continue;r.push(s);const o=g$(s);o&&(t=t?_$(t,o):o)}return!t||t.width<=0||t.height<=0?e:[...r,{type:"cameraUpdate",...v$(t)}]}function w$(e){return $$(p$(e))}var No={exports:{}},gd={},gt={},zr={},xn={},fe={},Sn={};(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(h,...v){const S=[h[0]];let R=0;for(;R{if(f.scopePath===void 0)throw new Error(`CodeGen: name "${f}" has no value`);return(0,t._)`${l}${f.scopePath}`})}scopeCode(l=this._values,d,f){return this._reduceValues(l,_=>{if(_.value===void 0)throw new Error(`CodeGen: name "${_}" has no value`);return _.value.code},d,f)}_reduceValues(l,d,f={},_){let y=t.nil;for(const g in l){const $=l[g];if(!$)continue;const m=f[g]=f[g]||new Map;$.forEach(h=>{if(m.has(h))return;m.set(h,n.Started);let v=d(h);if(v){const S=this.opts.es5?e.varKinds.var:e.varKinds.const;y=(0,t._)`${y}${S} ${h} = ${v};${this.opts._n}`}else if(v=_==null?void 0:_(h))y=(0,t._)`${y}${v}${this.opts._n}`;else throw new r(h);m.set(h,n.Completed)})}return y}}e.ValueScope=i})(jo);(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=Sn,r=jo;var n=Sn;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=jo;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,x=this.rhs===void 0?"":` = ${this.rhs}`;return`${E} ${this.name}${x};`+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,x){super(u,E,x),this.op=p}render({_n:u}){return`${this.lhs} ${this.op}= ${this.rhs};`+u}}class l extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`${this.label}:`+u}}class d extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`break${this.label?` ${this.label}`:""};`+u}}class f extends o{constructor(u){super(),this.error=u}render({_n:u}){return`throw ${this.error};`+u}get names(){return this.error.names}}class _ extends o{constructor(u){super(),this.code=u}render({_n:u}){return`${this.code};`+u}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(u,p){return this.code=q(this.code,u,p),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}}class y 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 x=E.length;for(;x--;){const z=E[x];z.optimizeNames(u,p)||(le(u,z.names),E.splice(x,1))}return E.length>0?this:void 0}get names(){return this.nodes.reduce((u,p)=>K(u,p.names),{})}}class g extends y{render(u){return"{"+u._n+super.render(u)+"}"+u._n}}class $ extends y{}class m extends g{}m.kind="else";class h extends g{constructor(u,p){super(p),this.condition=u}render(u){let p=`if(${this.condition})`+super.render(u);return this.else&&(p+="else "+this.else.render(u)),p}optimizeNodes(){super.optimizeNodes();const u=this.condition;if(u===!0)return this.nodes;let p=this.else;if(p){const E=p.optimizeNodes();p=this.else=Array.isArray(E)?new m(E):E}if(p)return u===!1?p instanceof h?p:p.nodes:this.nodes.length?this:new h(Ce(u),p instanceof h?[p]:p.nodes);if(!(u===!1||!this.nodes.length))return this}optimizeNames(u,p){var E;if(this.else=(E=this.else)===null||E===void 0?void 0:E.optimizeNames(u,p),!!(super.optimizeNames(u,p)||this.else))return this.condition=q(this.condition,u,p),this}get names(){const u=super.names;return ce(u,this.condition),this.else&&K(u,this.else.names),u}}h.kind="if";class v extends g{}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 K(super.names,this.iteration.names)}}class R extends v{constructor(u,p,E,x){super(),this.varKind=u,this.name=p,this.from=E,this.to=x}render(u){const p=u.es5?r.varKinds.var:this.varKind,{name:E,from:x,to:z}=this;return`for(${p} ${E}=${x}; ${E}<${z}; ${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,x){super(),this.loop=u,this.varKind=p,this.name=E,this.iterable=x}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 K(super.names,this.iterable.names)}}class O extends g{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)}}O.kind="func";class A extends y{render(u){return"return "+super.render(u)}}A.kind="return";class L extends g{render(u){let p="try"+super.render(u);return this.catch&&(p+=this.catch.render(u)),this.finally&&(p+=this.finally.render(u)),p}optimizeNodes(){var u,p;return super.optimizeNodes(),(u=this.catch)===null||u===void 0||u.optimizeNodes(),(p=this.finally)===null||p===void 0||p.optimizeNodes(),this}optimizeNames(u,p){var E,x;return super.optimizeNames(u,p),(E=this.catch)===null||E===void 0||E.optimizeNames(u,p),(x=this.finally)===null||x===void 0||x.optimizeNames(u,p),this}get names(){const u=super.names;return this.catch&&K(u,this.catch.names),this.finally&&K(u,this.finally.names),u}}class V extends g{constructor(u){super(),this.error=u}render(u){return`catch(${this.error})`+super.render(u)}}V.kind="catch";class D extends g{render(u){return"finally"+super.render(u)}}D.kind="finally";class F{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,x){const z=this._scope.toName(p);return E!==void 0&&x&&(this._constants[z.str]=E),this._leafNode(new a(u,z,E)),z}const(u,p,E){return this._def(r.varKinds.const,u,p,E)}let(u,p,E){return this._def(r.varKinds.let,u,p,E)}var(u,p,E){return this._def(r.varKinds.var,u,p,E)}assign(u,p,E){return this._leafNode(new i(u,p,E))}add(u,p){return this._leafNode(new c(u,e.operators.ADD,p))}code(u){return typeof u=="function"?u():u!==t.nil&&this._leafNode(new _(u)),this}object(...u){const p=["{"];for(const[E,x]of u)p.length>1&&p.push(","),p.push(E),(E!==x||this.opts.es5)&&(p.push(":"),(0,t.addCodeArg)(p,x));return p.push("}"),new t._Code(p)}if(u,p,E){if(this._blockNode(new h(u)),p&&E)this.code(p).else().code(E).endIf();else if(p)this.code(p).endIf();else if(E)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(u){return this._elseNode(new h(u))}else(){return this._elseNode(new m)}endIf(){return this._endBlockNode(h,m)}_for(u,p){return this._blockNode(u),p&&this.code(p).endFor(),this}for(u,p){return this._for(new S(u),p)}forRange(u,p,E,x,z=this.opts.es5?r.varKinds.var:r.varKinds.let){const B=this._scope.toName(u);return this._for(new R(z,B,p,E),()=>x(B))}forOf(u,p,E,x=r.varKinds.const){const z=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`,G=>{this.var(z,(0,t._)`${B}[${G}]`),E(z)})}return this._for(new P("of",x,z,p),()=>E(z))}forIn(u,p,E,x=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(u,(0,t._)`Object.keys(${p})`,E);const z=this._scope.toName(u);return this._for(new P("in",x,z,p),()=>E(z))}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 x=new L;if(this._blockNode(x),this.code(u),p){const z=this.name("e");this._currNode=x.catch=new V(z),p(z)}return E&&(this._currNode=x.finally=new D,this.code(E)),this._endBlockNode(V,D)}throw(u){return this._leafNode(new f(u))}block(u,p){return this._blockStarts.push(this._nodes.length),u&&this.code(u).endBlock(p),this}endBlock(u){const p=this._blockStarts.pop();if(p===void 0)throw new Error("CodeGen: not in self-balancing block");const E=this._nodes.length-p;if(E<0||u!==void 0&&E!==u)throw new Error(`CodeGen: wrong number of nodes: ${E} vs ${u} expected`);return this._nodes.length=p,this}func(u,p=t.nil,E,x){return this._blockNode(new O(u,p,E)),x&&this.code(x).endFunc(),this}endFunc(){return this._endBlockNode(O)}optimize(u=1){for(;u-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(u){return this._currNode.nodes.push(u),this}_blockNode(u){this._currNode.nodes.push(u),this._nodes.push(u)}_endBlockNode(u,p){const E=this._currNode;if(E instanceof u||p&&E instanceof p)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${p?`${u.kind}/${p.kind}`:u.kind}"`)}_elseNode(u){const p=this._currNode;if(!(p instanceof h))throw new Error('CodeGen: "else" without "if"');return this._currNode=p.else=u,this}get _root(){return this._nodes[0]}get _currNode(){const u=this._nodes;return u[u.length-1]}set _currNode(u){const p=this._nodes;p[p.length-1]=u}}e.CodeGen=F;function K(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?K(b,u.names):b}function q(b,u,p){if(b instanceof t.Name)return E(b);if(!x(b))return b;return new t._Code(b._items.reduce((z,B)=>(B instanceof t.Name&&(B=E(B)),B instanceof t._Code?z.push(...B._items):z.push(B),z),[]));function E(z){const B=p[z.str];return B===void 0||u[z.str]!==1?z:(delete u[z.str],B)}function x(z){return z instanceof t._Code&&z._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 _e=w(e.operators.AND);function ct(...b){return b.reduce(_e)}e.and=ct;const je=w(e.operators.OR);function N(...b){return b.reduce(je)}e.or=N;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 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 ye=fe,b$=Sn;function S$(e){const t={};for(const r of e)t[r]=!0;return t}H.toHash=S$;function E$(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(_d(e,t),!yd(t,e.self.RULES.all))}H.alwaysValidSchema=E$;function _d(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]||wd(e,`unknown keyword: "${o}"`)}H.checkUnknownRules=_d;function yd(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(t[r])return!0;return!1}H.schemaHasRules=yd;function k$(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=k$;function P$({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)}`}H.schemaRefOrVal=P$;function T$(e){return vd(decodeURIComponent(e))}H.unescapeFragment=T$;function R$(e){return encodeURIComponent(Ba(e))}H.escapeFragment=R$;function Ba(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}H.escapeJsonPointer=Ba;function vd(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}H.unescapeJsonPointer=vd;function C$(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)}H.eachItem=C$;function tl({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}}H.mergeEvaluated={props:tl({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} || {}`),Ja(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:$d}),items:tl({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 $d(e,t){if(t===!0)return e.var("props",!0);const r=e.var("props",(0,ye._)`{}`);return t!==void 0&&Ja(e,r,t),r}H.evaluatedPropsToName=$d;function Ja(e,t,r){Object.keys(r).forEach(n=>e.assign((0,ye._)`${t}${(0,ye.getProperty)(n)}`,!0))}H.setEvaluated=Ja;const rl={};function I$(e,t){return e.scopeValue("func",{ref:t,code:rl[t.code]||(rl[t.code]=new b$._Code(t.code))})}H.useFunc=I$;var Oo;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Oo||(H.Type=Oo={}));function N$(e,t,r){if(e instanceof ye.Name){const n=t===Oo.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():"/"+Ba(e)}H.getErrorPath=N$;function wd(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=wd;var St={};Object.defineProperty(St,"__esModule",{value:!0});const Ze=fe,j$={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")};St.default=j$;(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=H,n=St;e.keywordError={message:({keyword:m})=>(0,t.str)`must pass "${m}" keyword validation`},e.keyword$DataError={message:({keyword:m,schemaType:h})=>h?(0,t.str)`"${m}" keyword must be ${h} ($data)`:(0,t.str)`"${m}" keyword is invalid ($data)`};function s(m,h=e.keywordError,v,S){const{it:R}=m,{gen:P,compositeRule:O,allErrors:A}=R,L=f(m,h,v);S??(O||A)?c(P,L):l(R,(0,t._)`[${L}]`)}e.reportError=s;function o(m,h=e.keywordError,v){const{it:S}=m,{gen:R,compositeRule:P,allErrors:O}=S,A=f(m,h,v);c(R,A),P||O||l(S,n.default.vErrors)}e.reportExtraError=o;function a(m,h){m.assign(n.default.errors,h),m.if((0,t._)`${n.default.vErrors} !== null`,()=>m.if(h,()=>m.assign((0,t._)`${n.default.vErrors}.length`,h),()=>m.assign(n.default.vErrors,null)))}e.resetErrorsCount=a;function i({gen:m,keyword:h,schemaValue:v,data:S,errsCount:R,it:P}){if(R===void 0)throw new Error("ajv implementation error");const O=m.name("err");m.forRange("i",R,n.default.errors,A=>{m.const(O,(0,t._)`${n.default.vErrors}[${A}]`),m.if((0,t._)`${O}.instancePath === undefined`,()=>m.assign((0,t._)`${O}.instancePath`,(0,t.strConcat)(n.default.instancePath,P.errorPath))),m.assign((0,t._)`${O}.schemaPath`,(0,t.str)`${P.errSchemaPath}/${h}`),P.opts.verbose&&(m.assign((0,t._)`${O}.schema`,v),m.assign((0,t._)`${O}.data`,S))})}e.extendErrors=i;function c(m,h){const v=m.const("err",h);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,h){const{gen:v,validateName:S,schemaEnv:R}=m;R.$async?v.throw((0,t._)`new ${m.ValidationError}(${h})`):(v.assign((0,t._)`${S}.errors`,h),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 f(m,h,v){const{createErrors:S}=m.it;return S===!1?(0,t._)`{}`:_(m,h,v)}function _(m,h,v={}){const{gen:S,it:R}=m,P=[y(R,v),g(m,v)];return $(m,h,P),S.object(...P)}function y({errorPath:m},{instancePath:h}){const v=h?(0,t.str)`${m}${(0,r.getErrorPath)(h,r.Type.Str)}`:m;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,v)]}function g({keyword:m,it:{errSchemaPath:h}},{schemaPath:v,parentSchema:S}){let R=S?h:(0,t.str)`${h}/${m}`;return v&&(R=(0,t.str)`${R}${(0,r.getErrorPath)(v,r.Type.Str)}`),[d.schemaPath,R]}function $(m,{params:h,message:v},S){const{keyword:R,data:P,schemaValue:O,it:A}=m,{opts:L,propertyName:V,topSchemaRef:D,schemaPath:F}=A;S.push([d.keyword,R],[d.params,typeof h=="function"?h(m):h||(0,t._)`{}`]),L.messages&&S.push([d.message,typeof v=="function"?v(m):v]),L.verbose&&S.push([d.schema,O],[d.parentSchema,(0,t._)`${D}${F}`],[n.default.data,P]),V&&S.push([d.propertyName,V])}})(xn);Object.defineProperty(zr,"__esModule",{value:!0});zr.boolOrEmptySchema=zr.topBoolOrEmptySchema=void 0;const O$=xn,M$=fe,x$=St,A$={message:"boolean schema is false"};function z$(e){const{gen:t,schema:r,validateName:n}=e;r===!1?bd(e,!1):typeof r=="object"&&r.$async===!0?t.return(x$.default.data):(t.assign((0,M$._)`${n}.errors`,null),t.return(!0))}zr.topBoolOrEmptySchema=z$;function D$(e,t){const{gen:r,schema:n}=e;n===!1?(r.var(t,!1),bd(e)):r.var(t,!0)}zr.boolOrEmptySchema=D$;function bd(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,O$.reportError)(s,A$,void 0,t)}var Oe={},mr={};Object.defineProperty(mr,"__esModule",{value:!0});mr.getRules=mr.isJSONType=void 0;const q$=["string","number","integer","boolean","null","object","array"],U$=new Set(q$);function F$(e){return typeof e=="string"&&U$.has(e)}mr.isJSONType=F$;function V$(){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=V$;var kt={};Object.defineProperty(kt,"__esModule",{value:!0});kt.shouldUseRule=kt.shouldUseGroup=kt.schemaHasRulesForType=void 0;function L$({schema:e,self:t},r){const n=t.RULES.types[r];return n&&n!==!0&&Sd(e,n)}kt.schemaHasRulesForType=L$;function Sd(e,t){return t.rules.some(r=>Ed(e,r))}kt.shouldUseGroup=Sd;function Ed(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))}kt.shouldUseRule=Ed;Object.defineProperty(Oe,"__esModule",{value:!0});Oe.reportTypeError=Oe.checkDataTypes=Oe.checkDataType=Oe.coerceAndCheckDataType=Oe.getJSONTypes=Oe.getSchemaTypes=Oe.DataType=void 0;const H$=mr,Z$=kt,K$=xn,se=fe,kd=H;var jr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(jr||(Oe.DataType=jr={}));function G$(e){const t=Pd(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=G$;function Pd(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(H$.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Oe.getJSONTypes=Pd;function W$(e,t){const{gen:r,data:n,opts:s}=e,o=B$(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0,Z$.schemaHasRulesForType)(e,t[0]));if(a){const i=Ya(t,n,s.strictNumbers,jr.Wrong);r.if(i,()=>{o.length?J$(e,t,o):Qa(e)})}return a}Oe.coerceAndCheckDataType=W$;const Td=new Set(["string","number","integer","boolean","null"]);function B$(e,t){return t?e.filter(r=>Td.has(r)||t==="array"&&r==="array"):[]}function J$(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(Ya(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0,se._)`${i} !== undefined`);for(const l of r)(Td.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),Qa(e),n.endIf(),n.if((0,se._)`${i} !== undefined`,()=>{n.assign(s,i),Y$(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 Y$({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=jr.Correct){const s=n===jr.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===jr.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)}}Oe.checkDataType=Mo;function Ya(e,t,r,n){if(e.length===1)return Mo(e[0],t,r,n);let s;const o=(0,kd.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}Oe.checkDataTypes=Ya;const Q$={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,se._)`{type: ${e}}`:(0,se._)`{type: ${t}}`};function Qa(e){const t=X$(e);(0,K$.reportError)(t,Q$)}Oe.reportTypeError=Qa;function X$(e){const{gen:t,data:r,schema:n}=e,s=(0,kd.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}var Hs={};Object.defineProperty(Hs,"__esModule",{value:!0});Hs.assignDefaults=void 0;const wr=fe,e0=H;function t0(e,t){const{properties:r,items:n}=e.schema;if(t==="object"&&r)for(const s in r)nl(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>nl(e,o,s.default))}Hs.assignDefaults=t0;function nl(e,t,r){const{gen:n,compositeRule:s,data:o,opts:a}=e;if(r===void 0)return;const i=(0,wr._)`${o}${(0,wr.getProperty)(t)}`;if(s){(0,e0.checkStrictMode)(e,`default is ignored for: ${i}`);return}let c=(0,wr._)`${i} === undefined`;a.useDefaults==="empty"&&(c=(0,wr._)`${c} || ${i} === null || ${i} === ""`),n.if(c,(0,wr._)`${i} = ${(0,wr.stringify)(r)}`)}var wt={},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,Xa=H,Ct=St,r0=H;function n0(e,t){const{gen:r,data:n,it:s}=e;r.if(ti(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0,be._)`${t}`},!0),e.error()})}ue.checkReportMissingProp=n0;function s0({gen:e,data:t,it:{opts:r}},n,s){return(0,be.or)(...n.map(o=>(0,be.and)(ti(e,t,o,r.ownProperties),(0,be._)`${s} = ${o}`)))}ue.checkMissingProp=s0;function o0(e,t){e.setParams({missingProperty:t},!0),e.error()}ue.reportMissingProp=o0;function Rd(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,be._)`Object.prototype.hasOwnProperty`})}ue.hasPropFunc=Rd;function ei(e,t,r){return(0,be._)`${Rd(e)}.call(${t}, ${r})`}ue.isOwnProperty=ei;function a0(e,t,r,n){const s=(0,be._)`${t}${(0,be.getProperty)(r)} !== undefined`;return n?(0,be._)`${s} && ${ei(e,t,r)}`:s}ue.propertyInData=a0;function ti(e,t,r,n){const s=(0,be._)`${t}${(0,be.getProperty)(r)} === undefined`;return n?(0,be.or)(s,(0,be.not)(ei(e,t,r))):s}ue.noPropertyInData=ti;function Cd(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}ue.allSchemaProperties=Cd;function i0(e,t){return Cd(t).filter(r=>!(0,Xa.alwaysValidSchema)(e,t[r]))}ue.schemaProperties=i0;function c0({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,f=[[Ct.default.instancePath,(0,be.strConcat)(Ct.default.instancePath,o)],[Ct.default.parentData,a.parentData],[Ct.default.parentDataProperty,a.parentDataProperty],[Ct.default.rootData,Ct.default.rootData]];a.opts.dynamicRef&&f.push([Ct.default.dynamicAnchors,Ct.default.dynamicAnchors]);const _=(0,be._)`${d}, ${r.object(...f)}`;return c!==be.nil?(0,be._)`${i}.call(${c}, ${_})`:(0,be._)`${i}(${_})`}ue.callValidateCode=c0;const l0=(0,be._)`new RegExp`;function u0({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"?l0:(0,r0.useFunc)(e,s)}(${r}, ${n})`})}ue.usePattern=u0;function d0(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:Xa.Type.Num},o),t.if((0,be.not)(o),i)})}}ue.validateArray=d0;function f0(e){const{gen:t,schema:r,keyword:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,Xa.alwaysValidSchema)(s,c))&&!s.opts.unevaluated)return;const a=t.let("valid",!1),i=t.name("_valid");t.block(()=>r.forEach((c,l)=>{const d=e.subschema({keyword:n,schemaProp:l,compositeRule:!0},i);t.assign(a,(0,be._)`${a} || ${i}`),e.mergeValidEvaluated(d,i)||t.if((0,be.not)(a))})),e.result(a,()=>e.reset(),()=>e.error(!0))}ue.validateUnion=f0;Object.defineProperty(wt,"__esModule",{value:!0});wt.validateKeywordUsage=wt.validSchemaType=wt.funcKeywordCode=wt.macroKeywordCode=void 0;const We=fe,ir=St,h0=ue,p0=xn;function m0(e,t){const{gen:r,keyword:n,schema:s,parentSchema:o,it:a}=e,i=t.macro.call(a.self,s,o,a),c=Id(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=m0;function g0(e,t){var r;const{gen:n,keyword:s,schema:o,parentSchema:a,$data:i,it:c}=e;y0(c,t);const l=!i&&t.compile?t.compile.call(c.self,o,a,c):t.validate,d=Id(n,s,l),f=n.let("valid");e.block$data(f,_),e.ok((r=t.valid)!==null&&r!==void 0?r:f);function _(){if(t.errors===!1)$(),t.modifying&&sl(e),m(()=>e.error());else{const h=t.async?y():g();t.modifying&&sl(e),m(()=>_0(e,h))}}function y(){const h=n.let("ruleErrs",null);return n.try(()=>$((0,We._)`await `),v=>n.assign(f,!1).if((0,We._)`${v} instanceof ${c.ValidationError}`,()=>n.assign(h,(0,We._)`${v}.errors`),()=>n.throw(v))),h}function g(){const h=(0,We._)`${d}.errors`;return n.assign(h,null),$(We.nil),h}function $(h=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(f,(0,We._)`${h}${(0,h0.callValidateCode)(e,d,v,S)}`,t.modifying)}function m(h){var v;n.if((0,We.not)((v=t.valid)!==null&&v!==void 0?v:f),h)}}wt.funcKeywordCode=g0;function sl(e){const{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,We._)`${n.parentData}[${n.parentDataProperty}]`))}function _0(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,p0.extendErrors)(e)},()=>e.error())}function y0({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function Id(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 v0(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=v0;function $0({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=$0;var zt={};Object.defineProperty(zt,"__esModule",{value:!0});zt.extendSubschemaMode=zt.extendSubschemaData=zt.getSubschema=void 0;const vt=fe,Nd=H;function w0(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,Nd.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=w0;function b0(e,t,{dataProp:r,dataPropType:n,data:s,dataTypes:o,propertyName:a}){if(s!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:i}=t;if(r!==void 0){const{errorPath:l,dataPathArr:d,opts:f}=t,_=i.let("data",(0,vt._)`${t.data}${(0,vt.getProperty)(r)}`,!0);c(_),e.errorPath=(0,vt.str)`${l}${(0,Nd.getErrorPath)(r,n,f.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]}}zt.extendSubschemaData=b0;function S0(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=S0;var Ue={},Zs=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},jd={exports:{}},Mt=jd.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)};Mt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Mt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Mt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Mt.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function 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 f=n[d];if(Array.isArray(f)){if(d in Mt.arrayKeywords)for(var _=0;_t+=Od(n)),t===1/0))return 1/0}return t}function Md(e,t="",r){r!==!1&&(t=Or(t));const n=e.parse(t);return xd(e,n)}Ue.getFullPath=Md;function xd(e,t){return e.serialize(t).split("#")[0]+"#"}Ue._getFullPath=xd;const j0=/#\/?$/;function Or(e){return e?e.replace(j0,""):""}Ue.normalizeId=Or;function O0(e,t,r){return r=Or(r),e.resolve(t,r)}Ue.resolveUrl=O0;const M0=/^[a-z_][-a-z0-9._]*$/i;function x0(e,t){if(typeof e=="boolean")return{};const{schemaId:r,uriResolver:n}=this.opts,s=Or(e[r]||t),o={"":s},a=Md(n,s,!1),i={},c=new Set;return R0(e,{allKeys:!0},(f,_,y,g)=>{if(g===void 0)return;const $=a+_;let m=o[g];typeof f[r]=="string"&&(m=h.call(this,f[r])),v.call(this,f.$anchor),v.call(this,f.$dynamicAnchor),o[_]=m;function h(S){const R=this.opts.uriResolver.resolve;if(S=Or(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(f,P.schema,S):S!==Or($)&&(S[0]==="#"?(l(f,i[S],S),i[S]=f):this.refs[S]=$),S}function v(S){if(typeof S=="string"){if(!M0.test(S))throw new Error(`invalid anchor "${S}"`);h.call(this,`#${S}`)}}}),i;function l(f,_,y){if(_!==void 0&&!T0(f,_))throw d(y)}function d(f){return new Error(`reference "${f}" resolves to more than one schema`)}}Ue.getSchemaRefs=x0;Object.defineProperty(gt,"__esModule",{value:!0});gt.getData=gt.KeywordCxt=gt.validateFunctionCode=void 0;const Ad=zr,ol=Oe,ri=kt,vs=Oe,A0=Hs,cn=wt,ao=zt,J=fe,ee=St,z0=Ue,Pt=H,Qr=xn;function D0(e){if(qd(e)&&(Ud(e),Dd(e))){F0(e);return}zd(e,()=>(0,Ad.topBoolOrEmptySchema)(e))}gt.validateFunctionCode=D0;function zd({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"; ${al(r,s)}`),U0(e,s),e.code(o)}):e.func(t,(0,J._)`${ee.default.data}, ${q0(s)}`,n.$async,()=>e.code(al(r,s)).code(o))}function q0(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 U0(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 F0(e){const{schema:t,opts:r,gen:n}=e;zd(e,()=>{r.$comment&&t.$comment&&Vd(e),K0(e),n.let(ee.default.vErrors,null),n.let(ee.default.errors,0),r.unevaluated&&V0(e),Fd(e),B0(e)})}function V0(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 al(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 L0(e,t){if(qd(e)&&(Ud(e),Dd(e))){H0(e,t);return}(0,Ad.boolOrEmptySchema)(e,t)}function Dd({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 qd(e){return typeof e.schema!="boolean"}function H0(e,t){const{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&Vd(e),G0(e),W0(e);const o=n.const("_errs",ee.default.errors);Fd(e,o),n.var(t,(0,J._)`${o} === ${ee.default.errors}`)}function Ud(e){(0,Pt.checkUnknownRules)(e),Z0(e)}function Fd(e,t){if(e.opts.jtd)return il(e,[],!1,t);const r=(0,ol.getSchemaTypes)(e.schema),n=(0,ol.coerceAndCheckDataType)(e,r);il(e,r,!n,t)}function Z0(e){const{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,Pt.schemaHasRulesButRef)(t,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function K0(e){const{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Pt.checkStrictMode)(e,"default is ignored in the schema root")}function G0(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,z0.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function W0(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Vd({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 B0(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&&J0(e),t.return((0,J._)`${ee.default.errors} === 0`))}function J0({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 il(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,Pt.schemaHasRulesButRef)(o,d))){s.block(()=>Zd(e,"$ref",d.all.$ref.definition));return}c.jtd||Y0(e,t),s.block(()=>{for(const _ of d.rules)f(_);f(d.post)});function f(_){(0,ri.shouldUseGroup)(o,_)&&(_.type?(s.if((0,vs.checkDataType)(_.type,a,c.strictNumbers)),cl(e,_),t.length===1&&t[0]===_.type&&r&&(s.else(),(0,vs.reportTypeError)(e)),s.endIf()):cl(e,_),i||s.if((0,J._)`${ee.default.errors} === ${n||0}`))}}function cl(e,t){const{gen:r,schema:n,opts:{useDefaults:s}}=e;s&&(0,A0.assignDefaults)(e,t.type),r.block(()=>{for(const o of t.rules)(0,ri.shouldUseRule)(n,o)&&Zd(e,o.keyword,o.definition,t.type)})}function Y0(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(Q0(e,t),e.opts.allowUnionTypes||X0(e,t),ew(e,e.dataTypes))}function Q0(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{Ld(e.dataTypes,r)||ni(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),rw(e,t)}}function X0(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&ni(e,"use allowUnionTypes to allow union type keyword")}function ew(e,t){const r=e.self.RULES.all;for(const n in r){const s=r[n];if(typeof s=="object"&&(0,ri.shouldUseRule)(e.schema,s)){const{type:o}=s.definition;o.length&&!o.some(a=>tw(t,a))&&ni(e,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function tw(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function Ld(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function rw(e,t){const r=[];for(const n of e.dataTypes)Ld(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function ni(e,t){const r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,Pt.checkStrictMode)(e,t,e.opts.strictTypes)}let Hd=class{constructor(t,r,n){if((0,cn.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,Pt.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",Kd(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,cn.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?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=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,vs.checkDataTypes)(c,r,o.opts.strictNumbers,vs.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,ao.getSubschema)(this.it,t);(0,ao.extendSubschemaData)(n,this.it,t),(0,ao.extendSubschemaMode)(n,t);const s={...this.it,...n,items:void 0,props:void 0};return L0(s,r),s}mergeEvaluated(t,r){const{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=Pt.mergeEvaluated.props(s,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=Pt.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}};gt.KeywordCxt=Hd;function Zd(e,t,r,n){const s=new Hd(e,r,t);"code"in r?r.code(s,n):s.$data&&r.validate?(0,cn.funcKeywordCode)(s,r):"macro"in r?(0,cn.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,cn.funcKeywordCode)(s,r)}const nw=/^\/(?:[^~]|~0|~1)*$/,sw=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Kd(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,o;if(e==="")return ee.default.rootData;if(e[0]==="/"){if(!nw.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,o=ee.default.rootData}else{const l=sw.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,Pt.unescapeJsonPointer)(l))}`,a=(0,J._)`${a} && ${o}`);return a;function c(l,d){return`Cannot access ${l} ${d} levels up, current level is ${t}`}}gt.getData=Kd;var An={};Object.defineProperty(An,"__esModule",{value:!0});let ow=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};An.default=ow;var Lr={};Object.defineProperty(Lr,"__esModule",{value:!0});const io=Ue;let aw=class extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,io.resolveUrl)(t,r,n),this.missingSchema=(0,io.normalizeId)((0,io.getFullPath)(t,this.missingRef))}};Lr.default=aw;var Qe={};Object.defineProperty(Qe,"__esModule",{value:!0});Qe.resolveSchema=Qe.getCompilingSchema=Qe.resolveRef=Qe.compileSchema=Qe.SchemaEnv=void 0;const ut=fe,iw=An,nr=St,pt=Ue,ll=H,cw=gt;let Ks=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,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={}}};Qe.SchemaEnv=Ks;function si(e){const t=Gd.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:iw.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:nr.default.data,parentData:nr.default.parentData,parentDataProperty:nr.default.parentDataProperty,dataNames:[nr.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,cw.validateFunctionCode)(l),a.optimize(this.opts.code.optimize);const f=a.toString();d=`${a.scopeRefs(nr.default.scope)}return ${f}`,this.opts.code.process&&(d=this.opts.code.process(d,e));const y=new Function(`${nr.default.self}`,`${nr.default.scope}`,d)(this,this.scope.get());if(this.scope.value(c,{ref:y}),y.errors=null,y.schema=e.schema,y.schemaEnv=e,e.$async&&(y.$async=!0),this.opts.code.source===!0&&(y.source={validateName:c,validateCode:f,scopeValues:a._values}),this.opts.unevaluated){const{props:g,items:$}=l;y.evaluated={props:g instanceof ut.Name?void 0:g,items:$ instanceof ut.Name?void 0:$,dynamicProps:g instanceof ut.Name,dynamicItems:$ instanceof ut.Name},y.source&&(y.source.evaluated=(0,ut.stringify)(y.evaluated))}return e.validate=y,e}catch(f){throw delete e.validate,delete e.validateName,d&&this.logger.error("Error compiling schema, function code:",d),f}finally{this._compilations.delete(e)}}Qe.compileSchema=si;function lw(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=fw.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]=uw.call(this,o)}Qe.resolveRef=lw;function uw(e){return(0,pt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:si.call(this,e)}function Gd(e){for(const t of this._compilations)if(dw(t,e))return t}Qe.getCompilingSchema=Gd;function dw(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function fw(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 co.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:co.call(this,r,i)}if(typeof(a==null?void 0:a.schema)=="object"){if(a.validate||si.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 co.call(this,r,a)}}Qe.resolveSchema=Gs;const hw=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function co(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,ll.unescapeFragment)(i)];if(c===void 0)return;r=c;const l=typeof r=="object"&&r[this.opts.schemaId];!hw.has(i)&&l&&(t=(0,pt.resolveUrl)(this.opts.uriResolver,t,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,ll.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 pw="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",mw="Meta-schema for $data reference (JSON AnySchema extension proposal)",gw="object",_w=["$data"],yw={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},vw=!1,$w={$id:pw,description:mw,type:gw,required:_w,properties:yw,additionalProperties:vw};var oi={},Ws={exports:{}};const ww=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Wd=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),ai=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),Bd=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),bw=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function Jd(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 Sw=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function ul(e){return e.length=0,!0}function Ew(e,t,r){if(e.length){const n=Jd(e);if(n!=="")t.push(n);else return r.error=!0,!1;e.length=0}return!0}function kw(e){let t=0;const r={error:!1,address:"",zone:""},n=[],s=[];let o=!1,a=!1,i=Ew;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=ul}else{s.push(l);continue}}return s.length&&(i===ul?r.zone=s.join(""):a?n.push(s.join("")):n.push(Jd(s))),r.address=n.join(""),r}function Yd(e){if(Pw(e,":")<2)return{host:e,isIPV6:!1};const t=kw(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 Pw(e,t){let r=0;for(let n=0;nRw[n])}function Nw(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n65535))return"URI port is malformed."}function ws(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(ib);a!==null&&a[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",s=!0);const i=e.match(cb);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(ab);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=lb(n,c);if(l!==void 0&&(n.error=n.error||l,s=!0),n.host)if(eb(n.host)===!1){const _=Ww(n.host);n.host=_.host.toLowerCase(),o=_.isIPV6}else o=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");const d=sf(r.scheme||n.scheme);if(!r.unicodeSupport&&(!d||!d.unicodeSupport)&&n.host&&(r.domainHost||d&&d.domainHost)&&o===!1&&tb(n.host))try{n.host=new URL("http://"+n.host).hostname}catch(f){n.error=n.error||"Host's domain name can not be converted to ASCII: "+f}if((!d||d&&!d.skipNormalize)&&(e.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=Xw(unescape(n.host),o))),n.path&&(n.path=Yw(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 bs(e,t){return ws(e,t).parsed}function ub(e,t){return af(e,t).normalized}function af(e,t){const{parsed:r,malformedAuthorityOrPort:n}=ws(e,t);return{normalized:n?e:gr(r,t),malformedAuthorityOrPort:n}}function dl(e,t){if(typeof e=="string"){const{normalized:r,malformedAuthorityOrPort:n}=af(e,t);return n?void 0:r}if(typeof e=="object")return gr(e,t)}const ci={SCHEMES:rb,normalize:nb,resolve:sb,resolveComponent:of,equal:ob,serialize:gr,parse:bs};Ws.exports=ci;Ws.exports.default=ci;Ws.exports.fastUri=ci;var cf=Ws.exports;Object.defineProperty(oi,"__esModule",{value:!0});const lf=cf;lf.code='require("ajv/dist/runtime/uri").default';oi.default=lf;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=gt;Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=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=An,s=Lr,o=mr,a=Qe,i=fe,c=Ue,l=Oe,d=H,f=$w,_=oi,y=(N,w)=>new RegExp(N,w);y.code="new RegExp";const g=["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."},h={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},v=200;function S(N){var w,C,b,u,p,E,x,z,B,G,he,tt,Ft,Vt,Lt,Ht,Zt,Kt,Gt,Wt,Bt,Jt,Yt,Qt,Xt;const lt=N.strict,er=(w=N.code)===null||w===void 0?void 0:w.optimize,Br=er===!0||er===void 0?1:er||0,Jr=(b=(C=N.code)===null||C===void 0?void 0:C.regExp)!==null&&b!==void 0?b:y,ro=(u=N.uriResolver)!==null&&u!==void 0?u:_.default;return{strictSchema:(E=(p=N.strictSchema)!==null&&p!==void 0?p:lt)!==null&&E!==void 0?E:!0,strictNumbers:(z=(x=N.strictNumbers)!==null&&x!==void 0?x:lt)!==null&&z!==void 0?z:!0,strictTypes:(G=(B=N.strictTypes)!==null&&B!==void 0?B:lt)!==null&&G!==void 0?G:"log",strictTuples:(tt=(he=N.strictTuples)!==null&&he!==void 0?he:lt)!==null&&tt!==void 0?tt:"log",strictRequired:(Vt=(Ft=N.strictRequired)!==null&&Ft!==void 0?Ft:lt)!==null&&Vt!==void 0?Vt:!1,code:N.code?{...N.code,optimize:Br,regExp:Jr}:{optimize:Br,regExp:Jr},loopRequired:(Lt=N.loopRequired)!==null&&Lt!==void 0?Lt:v,loopEnum:(Ht=N.loopEnum)!==null&&Ht!==void 0?Ht:v,meta:(Zt=N.meta)!==null&&Zt!==void 0?Zt:!0,messages:(Kt=N.messages)!==null&&Kt!==void 0?Kt:!0,inlineRefs:(Gt=N.inlineRefs)!==null&&Gt!==void 0?Gt:!0,schemaId:(Wt=N.schemaId)!==null&&Wt!==void 0?Wt:"$id",addUsedSchema:(Bt=N.addUsedSchema)!==null&&Bt!==void 0?Bt:!0,validateSchema:(Jt=N.validateSchema)!==null&&Jt!==void 0?Jt:!0,validateFormats:(Yt=N.validateFormats)!==null&&Yt!==void 0?Yt:!0,unicodeRegExp:(Qt=N.unicodeRegExp)!==null&&Qt!==void 0?Qt:!0,int32range:(Xt=N.int32range)!==null&&Xt!==void 0?Xt:!0,uriResolver:ro}}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=K(w.logger);const u=w.validateFormats;w.validateFormats=!1,this.RULES=(0,o.getRules)(),P.call(this,m,w,"NOT SUPPORTED"),P.call(this,h,w,"DEPRECATED","warn"),this._metaOpts=D.call(this),w.formats&&L.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),w.keywords&&V.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=f;b==="id"&&(u={...f},u.id=u.$id,delete u.$id),C&&w&&this.addMetaSchema(u,u[b],!1)}defaultMeta(){const{meta:w,schemaId:C}=this.opts;return this.opts.defaultMeta=typeof w=="object"?w[C]||w:void 0}validate(w,C){let b;if(typeof w=="string"){if(b=this.getSchema(w),!b)throw new Error(`no schema with key or ref "${w}"`)}else b=this.compile(w);const u=b(C);return"$async"in b||(this.errors=b.errors),u}compile(w,C){const b=this._addSchema(w,C);return b.validate||this._compileSchemaEnv(b)}compileAsync(w,C){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:b}=this.opts;return u.call(this,w,C);async function u(G,he){await p.call(this,G.$schema);const tt=this._addSchema(G,he);return tt.validate||E.call(this,tt)}async function p(G){G&&!this.getSchema(G)&&await u.call(this,{$ref:G},!0)}async function E(G){try{return this._compileSchemaEnv(G)}catch(he){if(!(he instanceof s.default))throw he;return x.call(this,he),await z.call(this,he.missingSchema),E.call(this,G)}}function x({missingSchema:G,missingRef:he}){if(this.refs[G])throw new Error(`AnySchema ${G} is loaded but ${he} cannot be resolved`)}async function z(G){const he=await B.call(this,G);this.refs[G]||await p.call(this,he.$schema),this.refs[G]||this.addSchema(he,G,C)}async function B(G){const he=this._loading[G];if(he)return he;try{return await(this._loading[G]=b(G))}finally{delete this._loading[G]}}}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=O.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=O.call(this,w);return typeof C=="object"&&this._cache.delete(C.schema),delete this.schemas[w],delete this.refs[w],this}case"object":{const C=w;this._cache.delete(C);let 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;_e.call(this,C);const u={...C,type:(0,l.getJSONTypes)(C.type),schemaType:(0,l.getJSONTypes)(C.schemaType)};return(0,d.eachItem)(b,u.type.length===0?p=>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 x of p)E=E[x];for(const x in b){const z=b[x];if(typeof z!="object")continue;const{$data:B}=z.definition,G=E[x];B&&G&&(E[x]=je(G))}}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:x}=this.opts;if(typeof w=="object")E=w[x];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof w!="boolean")throw new Error("schema must be object or boolean")}let z=this._cache.get(w);if(z!==void 0)return z;b=(0,c.normalizeId)(E||b);const B=c.getSchemaRefs.call(this,w,b);return z=new a.SchemaEnv({schema:w,schemaId:x,meta:C,baseId:b,localRefs:B}),this._cache.set(z.schema,z),p&&!b.startsWith("#")&&(b&&this._checkUnique(b),this.refs[b]=z),u&&this.validateSchema(w,!0),z}_checkUnique(w){if(this.schemas[w]||this.refs[w])throw new Error(`schema with key or id "${w}" already exists`)}_compileSchemaEnv(w){if(w.meta?this._compileMetaSchema(w):a.compileSchema.call(this,w),!w.validate)throw new Error("ajv implementation error");return w.validate}_compileMetaSchema(w){const C=this.opts;this.opts=this._metaOpts;try{a.compileSchema.call(this,w)}finally{this.opts=C}}}R.ValidationError=n.default,R.MissingRefError=s.default,e.default=R;function P(N,w,C,b="error"){for(const u in N){const p=u;p in w&&this.logger[b](`${C}: option ${u}. ${N[p]}`)}}function O(N){return N=(0,c.normalizeId)(N),this.schemas[N]||this.refs[N]}function A(){const N=this.opts.schemas;if(N)if(Array.isArray(N))this.addSchema(N);else for(const w in N)this.addSchema(N[w],w)}function L(){for(const N in this.opts.formats){const w=this.opts.formats[N];w&&this.addFormat(N,w)}}function V(N){if(Array.isArray(N)){this.addVocabulary(N);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const w in N){const C=N[w];C.keyword||(C.keyword=w),this.addKeyword(C)}}function D(){const N={...this.opts};for(const w of g)delete N[w];return N}const F={log(){},warn(){},error(){}};function K(N){if(N===!1)return F;if(N===void 0)return console;if(N.log&&N.warn&&N.error)return N;throw new Error("logger must implement log, warn and error methods")}const ce=/^[a-z_$][a-z0-9_$:-]*$/i;function q(N,w){const{RULES:C}=this;if((0,d.eachItem)(N,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(N,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:z})=>z===C);if(E||(E={type:C,rules:[]},p.rules.push(E)),p.keywords[N]=!0,!w)return;const x={keyword:N,definition:{...w,type:(0,l.getJSONTypes)(w.type),schemaType:(0,l.getJSONTypes)(w.schemaType)}};w.before?Ce.call(this,E,x,w.before):E.rules.push(x),p.all[N]=x,(b=w.implements)===null||b===void 0||b.forEach(z=>this.addKeyword(z))}function Ce(N,w,C){const b=N.rules.findIndex(u=>u.keyword===C);b>=0?N.rules.splice(b,0,w):(N.rules.push(w),this.logger.warn(`rule ${C} is not defined`))}function _e(N){let{metaSchema:w}=N;w!==void 0&&(N.$data&&this.opts.$data&&(w=je(w)),N.validateSchema=this.compile(w,!0))}const ct={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function je(N){return{anyOf:[N,ct]}}})(gd);var li={},ui={},di={};Object.defineProperty(di,"__esModule",{value:!0});const db={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};di.default=db;var _r={};Object.defineProperty(_r,"__esModule",{value:!0});_r.callRef=_r.getValidate=void 0;const fb=Lr,fl=ue,Je=fe,br=St,hl=Qe,Zn=H,hb={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:r,it:n}=e,{baseId:s,schemaEnv:o,validateName:a,opts:i,self:c}=n,{root:l}=o;if((r==="#"||r==="#/")&&s===l.baseId)return f();const d=hl.resolveRef.call(c,l,s,r);if(d===void 0)throw new fb.default(n.opts.uriResolver,s,r);if(d instanceof hl.SchemaEnv)return _(d);return y(d);function f(){if(o===l)return as(e,a,o,o.$async);const g=t.scopeValue("root",{ref:l});return as(e,(0,Je._)`${g}.validate`,l,l.$async)}function _(g){const $=uf(e,g);as(e,$,g,g.$async)}function y(g){const $=t.scopeValue("schema",i.code.source===!0?{ref:g,code:(0,Je.stringify)(g)}:{ref:g}),m=t.name("valid"),h=e.subschema({schema:g,dataTypes:[],schemaPath:Je.nil,topSchemaRef:$,errSchemaPath:r},m);e.mergeEvaluated(h),e.ok(m)}}};function uf(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=uf;function as(e,t,r,n){const{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:c}=o,l=c.passContext?br.default.this:Je.nil;n?d():f();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");const g=s.let("valid");s.try(()=>{s.code((0,Je._)`await ${(0,fl.callValidateCode)(e,t,l)}`),y(t),a||s.assign(g,!0)},$=>{s.if((0,Je._)`!(${$} instanceof ${o.ValidationError})`,()=>s.throw($)),_($),a||s.assign(g,!1)}),e.ok(g)}function f(){e.result((0,fl.callValidateCode)(e,t,l),()=>y(t),()=>_(t))}function _(g){const $=(0,Je._)`${g}.errors`;s.assign(br.default.vErrors,(0,Je._)`${br.default.vErrors} === null ? ${$} : ${br.default.vErrors}.concat(${$})`),s.assign(br.default.errors,(0,Je._)`${br.default.vErrors}.length`)}function y(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=Zn.mergeEvaluated.props(s,m.props,o.props));else{const h=s.var("props",(0,Je._)`${g}.evaluated.props`);o.props=Zn.mergeEvaluated.props(s,h,o.props,Je.Name)}if(o.items!==!0)if(m&&!m.dynamicItems)m.items!==void 0&&(o.items=Zn.mergeEvaluated.items(s,m.items,o.items));else{const h=s.var("items",(0,Je._)`${g}.evaluated.items`);o.items=Zn.mergeEvaluated.items(s,h,o.items,Je.Name)}}}_r.callRef=as;_r.default=hb;Object.defineProperty(ui,"__esModule",{value:!0});const pb=di,mb=_r,gb=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",pb.default,mb.default];ui.default=gb;var fi={},hi={};Object.defineProperty(hi,"__esModule",{value:!0});const Ss=fe,It=Ss.operators,Es={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}},_b={message:({keyword:e,schemaCode:t})=>(0,Ss.str)`must be ${Es[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Ss._)`{comparison: ${Es[e].okStr}, limit: ${t}}`},yb={keyword:Object.keys(Es),type:"number",schemaType:"number",$data:!0,error:_b,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,Ss._)`${r} ${Es[t].fail} ${n} || isNaN(${r})`)}};hi.default=yb;var pi={};Object.defineProperty(pi,"__esModule",{value:!0});const ln=fe,vb={message:({schemaCode:e})=>(0,ln.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,ln._)`{multipleOf: ${e}}`},$b={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:vb,code(e){const{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0,ln._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0,ln._)`${a} !== parseInt(${a})`;e.fail$data((0,ln._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};pi.default=$b;var mi={},gi={};Object.defineProperty(gi,"__esModule",{value:!0});function df(e){const t=e.length;let r=0,n=0,s;for(;n=55296&&s<=56319&&n(0,cr._)`{limit: ${e}}`},Eb={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:Sb,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,wb.useFunc)(e.gen,bb.default)}(${r})`;e.fail$data((0,cr._)`${a} ${o} ${n}`)}};mi.default=Eb;var _i={};Object.defineProperty(_i,"__esModule",{value:!0});const kb=ue,Pb=H,Ir=fe,Tb={message:({schemaCode:e})=>(0,Ir.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Ir._)`{pattern: ${e}}`},Rb={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:Tb,code(e){const{gen:t,data:r,$data:n,schema:s,schemaCode:o,it:a}=e,i=a.opts.unicodeRegExp?"u":"";if(n){const{regExp:c}=a.opts.code,l=c.code==="new RegExp"?(0,Ir._)`new RegExp`:(0,Pb.useFunc)(t,c),d=t.let("valid");t.try(()=>t.assign(d,(0,Ir._)`${l}(${o}, ${i}).test(${r})`),()=>t.assign(d,!1)),e.fail$data((0,Ir._)`!${d}`)}else{const c=(0,kb.usePattern)(e,s);e.fail$data((0,Ir._)`!${c}.test(${r})`)}}};_i.default=Rb;var yi={};Object.defineProperty(yi,"__esModule",{value:!0});const un=fe,Cb={message({keyword:e,schemaCode:t}){const r=e==="maxProperties"?"more":"fewer";return(0,un.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,un._)`{limit: ${e}}`},Ib={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:Cb,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?un.operators.GT:un.operators.LT;e.fail$data((0,un._)`Object.keys(${r}).length ${s} ${n}`)}};yi.default=Ib;var vi={};Object.defineProperty(vi,"__esModule",{value:!0});const Xr=ue,dn=fe,Nb=H,jb={message:({params:{missingProperty:e}})=>(0,dn.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,dn._)`{missingProperty: ${e}}`},Ob={keyword:"required",type:"object",schemaType:"array",$data:!0,error:jb,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 y=e.parentSchema.properties,{definedProperties:g}=e.it;for(const $ of r)if((y==null?void 0:y[$])===void 0&&!g.has($)){const m=a.schemaEnv.baseId+a.errSchemaPath,h=`required property "${$}" is not defined at "${m}" (strictRequired)`;(0,Nb.checkStrictMode)(a,h,a.opts.strictRequired)}}function l(){if(c||o)e.block$data(dn.nil,f);else for(const y of r)(0,Xr.checkReportMissingProp)(e,y)}function d(){const y=t.let("missing");if(c||o){const g=t.let("valid",!0);e.block$data(g,()=>_(y,g)),e.ok(g)}else t.if((0,Xr.checkMissingProp)(e,r,y)),(0,Xr.reportMissingProp)(e,y),t.else()}function f(){t.forOf("prop",n,y=>{e.setParams({missingProperty:y}),t.if((0,Xr.noPropertyInData)(t,s,y,i.ownProperties),()=>e.error())})}function _(y,g){e.setParams({missingProperty:y}),t.forOf(y,n,()=>{t.assign(g,(0,Xr.propertyInData)(t,s,y,i.ownProperties)),t.if((0,dn.not)(g),()=>{e.error(),t.break()})},dn.nil)}}};vi.default=Ob;var $i={};Object.defineProperty($i,"__esModule",{value:!0});const fn=fe,Mb={message({keyword:e,schemaCode:t}){const r=e==="maxItems"?"more":"fewer";return(0,fn.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,fn._)`{limit: ${e}}`},xb={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Mb,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?fn.operators.GT:fn.operators.LT;e.fail$data((0,fn._)`${r}.length ${s} ${n}`)}};$i.default=xb;var wi={},zn={};Object.defineProperty(zn,"__esModule",{value:!0});const ff=Zs;ff.code='require("ajv/dist/runtime/equal").default';zn.default=ff;Object.defineProperty(wi,"__esModule",{value:!0});const lo=Oe,ze=fe,Ab=H,zb=zn,Db={message:({params:{i:e,j:t}})=>(0,ze.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,ze._)`{i: ${e}, j: ${t}}`},qb={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:Db,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,lo.getSchemaTypes)(o.items):[];e.block$data(c,d,(0,ze._)`${a} === false`),e.ok(c);function d(){const g=t.let("i",(0,ze._)`${r}.length`),$=t.let("j");e.setParams({i:g,j:$}),t.assign(c,!0),t.if((0,ze._)`${g} > 1`,()=>(f()?_:y)(g,$))}function f(){return l.length>0&&!l.some(g=>g==="object"||g==="array")}function _(g,$){const m=t.name("item"),h=(0,lo.checkDataTypes)(l,m,i.opts.strictNumbers,lo.DataType.Wrong),v=t.const("indices",(0,ze._)`{}`);t.for((0,ze._)`;${g}--;`,()=>{t.let(m,(0,ze._)`${r}[${g}]`),t.if(h,(0,ze._)`continue`),l.length>1&&t.if((0,ze._)`typeof ${m} == "string"`,(0,ze._)`${m} += "_"`),t.if((0,ze._)`typeof ${v}[${m}] == "number"`,()=>{t.assign($,(0,ze._)`${v}[${m}]`),e.error(),t.assign(c,!1).break()}).code((0,ze._)`${v}[${m}] = ${g}`)})}function y(g,$){const m=(0,Ab.useFunc)(t,zb.default),h=t.name("outer");t.label(h).for((0,ze._)`;${g}--;`,()=>t.for((0,ze._)`${$} = ${g}; ${$}--;`,()=>t.if((0,ze._)`${m}(${r}[${g}], ${r}[${$}])`,()=>{e.error(),t.assign(c,!1).break(h)})))}}};wi.default=qb;var bi={};Object.defineProperty(bi,"__esModule",{value:!0});const Ao=fe,Ub=H,Fb=zn,Vb={message:"must be equal to constant",params:({schemaCode:e})=>(0,Ao._)`{allowedValue: ${e}}`},Lb={keyword:"const",$data:!0,error:Vb,code(e){const{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,Ao._)`!${(0,Ub.useFunc)(t,Fb.default)}(${r}, ${s})`):e.fail((0,Ao._)`${o} !== ${r}`)}};bi.default=Lb;var Si={};Object.defineProperty(Si,"__esModule",{value:!0});const sn=fe,Hb=H,Zb=zn,Kb={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,sn._)`{allowedValues: ${e}}`},Gb={keyword:"enum",schemaType:"array",$data:!0,error:Kb,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,Hb.useFunc)(t,Zb.default));let d;if(i||n)d=t.let("valid"),e.block$data(d,f);else{if(!Array.isArray(s))throw new Error("ajv implementation error");const y=t.const("vSchema",o);d=(0,sn.or)(...s.map((g,$)=>_(y,$)))}e.pass(d);function f(){t.assign(d,!1),t.forOf("v",o,y=>t.if((0,sn._)`${l()}(${r}, ${y})`,()=>t.assign(d,!0).break()))}function _(y,g){const $=s[g];return typeof $=="object"&&$!==null?(0,sn._)`${l()}(${r}, ${y}[${g}])`:(0,sn._)`${r} === ${$}`}}};Si.default=Gb;Object.defineProperty(fi,"__esModule",{value:!0});const Wb=hi,Bb=pi,Jb=mi,Yb=_i,Qb=yi,Xb=vi,eS=$i,tS=wi,rS=bi,nS=Si,sS=[Wb.default,Bb.default,Jb.default,Yb.default,Qb.default,Xb.default,eS.default,tS.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},rS.default,nS.default];fi.default=sS;var Ei={},Hr={};Object.defineProperty(Hr,"__esModule",{value:!0});Hr.validateAdditionalItems=void 0;const lr=fe,zo=H,oS={message:({params:{len:e}})=>(0,lr.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,lr._)`{limit: ${e}}`},aS={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:oS,code(e){const{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,zo.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}hf(e,n)}};function hf(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,zo.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:zo.Type.Num},l),a.allErrors||r.if((0,lr.not)(l),()=>r.break())})}}Hr.validateAdditionalItems=hf;Hr.default=aS;var ki={},Zr={};Object.defineProperty(Zr,"__esModule",{value:!0});Zr.validateTuple=void 0;const pl=fe,is=H,iS=ue,cS={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return pf(e,"additionalItems",t);r.items=!0,!(0,is.alwaysValidSchema)(r,t)&&e.ok((0,iS.validateArray)(e))}};function pf(e,t,r=e.schema){const{gen:n,parentSchema:s,data:o,keyword:a,it:i}=e;d(s),i.opts.unevaluated&&r.length&&i.items!==!0&&(i.items=is.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),l=n.const("len",(0,pl._)`${o}.length`);r.forEach((f,_)=>{(0,is.alwaysValidSchema)(i,f)||(n.if((0,pl._)`${l} > ${_}`,()=>e.subschema({keyword:a,schemaProp:_,dataProp:_},c)),e.ok(c))});function d(f){const{opts:_,errSchemaPath:y}=i,g=r.length,$=g===f.minItems&&(g===f.maxItems||f[t]===!1);if(_.strictTuples&&!$){const m=`"${a}" is ${g}-tuple, but minItems or maxItems/${t} are not specified or different at path "${y}"`;(0,is.checkStrictMode)(i,m,_.strictTuples)}}}Zr.validateTuple=pf;Zr.default=cS;Object.defineProperty(ki,"__esModule",{value:!0});const lS=Zr,uS={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,lS.validateTuple)(e,"items")};ki.default=uS;var Pi={};Object.defineProperty(Pi,"__esModule",{value:!0});const ml=fe,dS=H,fS=ue,hS=Hr,pS={message:({params:{len:e}})=>(0,ml.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,ml._)`{limit: ${e}}`},mS={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:pS,code(e){const{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=!0,!(0,dS.alwaysValidSchema)(n,t)&&(s?(0,hS.validateAdditionalItems)(e,s):e.ok((0,fS.validateArray)(e)))}};Pi.default=mS;var Ti={};Object.defineProperty(Ti,"__esModule",{value:!0});const st=fe,Kn=H,gS={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}}`},_S={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:gS,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,Kn.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0,Kn.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Kn.alwaysValidSchema)(o,r)){let $=(0,st._)`${d} >= ${a}`;i!==void 0&&($=(0,st._)`${$} && ${d} <= ${i}`),e.pass($);return}o.items=!0;const f=t.name("valid");i===void 0&&a===1?y(f,()=>t.if(f,()=>t.break())):a===0?(t.let(f,!0),i!==void 0&&t.if((0,st._)`${s}.length > 0`,_)):(t.let(f,!1),_()),e.result(f,()=>e.reset());function _(){const $=t.name("_valid"),m=t.let("count",0);y($,()=>t.if($,()=>g(m)))}function y($,m){t.forRange("i",0,d,h=>{e.subschema({keyword:"contains",dataProp:h,dataPropType:Kn.Type.Num,compositeRule:!0},$),m()})}function g($){t.code((0,st._)`${$}++`),i===void 0?t.if((0,st._)`${$} >= ${a}`,()=>t.assign(f,!0).break()):(t.if((0,st._)`${$} > ${i}`,()=>t.assign(f,!1).break()),a===1?t.assign(f,!0):t.if((0,st._)`${$} >= ${a}`,()=>t.assign(f,!0)))}}};Ti.default=_S;var mf={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=fe,r=H,n=ue;e.error={message:({params:{property:c,depsCount:l,deps:d}})=>{const f=l===1?"property":"properties";return(0,t.str)`must have ${f} ${d} when property ${c} is present`},params:({params:{property:c,depsCount:l,deps:d,missingProperty:f}})=>(0,t._)`{property: ${c}, + missingProperty: ${f}, + depsCount: ${l}, + deps: ${d}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(c){const[l,d]=o(c);a(c,l),i(c,d)}};function o({schema:c}){const l={},d={};for(const f in c){if(f==="__proto__")continue;const _=Array.isArray(c[f])?l:d;_[f]=c[f]}return[l,d]}function a(c,l=c.schema){const{gen:d,data:f,it:_}=c;if(Object.keys(l).length===0)return;const y=d.let("missing");for(const g in l){const $=l[g];if($.length===0)continue;const m=(0,n.propertyInData)(d,f,g,_.opts.ownProperties);c.setParams({property:g,depsCount:$.length,deps:$.join(", ")}),_.allErrors?d.if(m,()=>{for(const h of $)(0,n.checkReportMissingProp)(c,h)}):(d.if((0,t._)`${m} && (${(0,n.checkMissingProp)(c,$,y)})`),(0,n.reportMissingProp)(c,y),d.else())}}e.validatePropertyDeps=a;function i(c,l=c.schema){const{gen:d,data:f,keyword:_,it:y}=c,g=d.name("valid");for(const $ in l)(0,r.alwaysValidSchema)(y,l[$])||(d.if((0,n.propertyInData)(d,f,$,y.opts.ownProperties),()=>{const m=c.subschema({keyword:_,schemaProp:$},g);c.mergeValidEvaluated(m,g)},()=>d.var(g,!0)),c.ok(g))}e.validateSchemaDeps=i,e.default=s})(mf);var Ri={};Object.defineProperty(Ri,"__esModule",{value:!0});const gf=fe,yS=H,vS={message:"property name must be valid",params:({params:e})=>(0,gf._)`{propertyName: ${e.propertyName}}`},$S={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:vS,code(e){const{gen:t,schema:r,data:n,it:s}=e;if((0,yS.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,gf.not)(o),()=>{e.error(!0),s.allErrors||t.break()})}),e.ok(o)}};Ri.default=$S;var Bs={};Object.defineProperty(Bs,"__esModule",{value:!0});const Gn=ue,ft=fe,wS=St,Wn=H,bS={message:"must NOT have additional properties",params:({params:e})=>(0,ft._)`{additionalProperty: ${e.additionalProperty}}`},SS={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:bS,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,Wn.alwaysValidSchema)(a,r))return;const l=(0,Gn.allSchemaProperties)(n.properties),d=(0,Gn.allSchemaProperties)(n.patternProperties);f(),e.ok((0,ft._)`${o} === ${wS.default.errors}`);function f(){t.forIn("key",s,m=>{!l.length&&!d.length?g(m):t.if(_(m),()=>g(m))})}function _(m){let h;if(l.length>8){const v=(0,Wn.schemaRefOrVal)(a,n.properties,"properties");h=(0,Gn.isOwnProperty)(t,v,m)}else l.length?h=(0,ft.or)(...l.map(v=>(0,ft._)`${m} === ${v}`)):h=ft.nil;return d.length&&(h=(0,ft.or)(h,...d.map(v=>(0,ft._)`${(0,Gn.usePattern)(e,v)}.test(${m})`))),(0,ft.not)(h)}function y(m){t.code((0,ft._)`delete ${s}[${m}]`)}function g(m){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){y(m);return}if(r===!1){e.setParams({additionalProperty:m}),e.error(),i||t.break();return}if(typeof r=="object"&&!(0,Wn.alwaysValidSchema)(a,r)){const h=t.name("valid");c.removeAdditional==="failing"?($(m,h,!1),t.if((0,ft.not)(h),()=>{e.reset(),y(m)})):($(m,h),i||t.if((0,ft.not)(h),()=>t.break()))}}function $(m,h,v){const S={keyword:"additionalProperties",dataProp:m,dataPropType:Wn.Type.Str};v===!1&&Object.assign(S,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(S,h)}}};Bs.default=SS;var Ci={};Object.defineProperty(Ci,"__esModule",{value:!0});const ES=gt,gl=ue,uo=H,_l=Bs,kS={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&&_l.default.code(new ES.KeywordCxt(o,_l.default,"additionalProperties"));const a=(0,gl.allSchemaProperties)(r);for(const f of a)o.definedProperties.add(f);o.opts.unevaluated&&a.length&&o.props!==!0&&(o.props=uo.mergeEvaluated.props(t,(0,uo.toHash)(a),o.props));const i=a.filter(f=>!(0,uo.alwaysValidSchema)(o,r[f]));if(i.length===0)return;const c=t.name("valid");for(const f of i)l(f)?d(f):(t.if((0,gl.propertyInData)(t,s,f,o.opts.ownProperties)),d(f),o.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(f),e.ok(c);function l(f){return o.opts.useDefaults&&!o.compositeRule&&r[f].default!==void 0}function d(f){e.subschema({keyword:"properties",schemaProp:f,dataProp:f},c)}}};Ci.default=kS;var Ii={};Object.defineProperty(Ii,"__esModule",{value:!0});const yl=ue,Bn=fe,vl=H,$l=H,PS={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,yl.allSchemaProperties)(r),c=i.filter($=>(0,vl.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 Bn.Name)&&(o.props=(0,$l.evaluatedPropsToName)(t,o.props));const{props:f}=o;_();function _(){for(const $ of i)l&&y($),o.allErrors?g($):(t.var(d,!0),g($),t.if(d))}function y($){for(const m in l)new RegExp($).test(m)&&(0,vl.checkStrictMode)(o,`property ${m} matches pattern ${$} (use allowMatchingProperties)`)}function g($){t.forIn("key",n,m=>{t.if((0,Bn._)`${(0,yl.usePattern)(e,$)}.test(${m})`,()=>{const h=c.includes($);h||e.subschema({keyword:"patternProperties",schemaProp:$,dataProp:m,dataPropType:$l.Type.Str},d),o.opts.unevaluated&&f!==!0?t.assign((0,Bn._)`${f}[${m}]`,!0):!h&&!o.allErrors&&t.if((0,Bn.not)(d),()=>t.break())})})}}};Ii.default=PS;var Ni={};Object.defineProperty(Ni,"__esModule",{value:!0});const TS=H,RS={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,TS.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"}};Ni.default=RS;var ji={};Object.defineProperty(ji,"__esModule",{value:!0});const CS=ue,IS={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:CS.validateUnion,error:{message:"must match a schema in anyOf"}};ji.default=IS;var Oi={};Object.defineProperty(Oi,"__esModule",{value:!0});const cs=fe,NS=H,jS={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,cs._)`{passingSchemas: ${e.passing}}`},OS={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:jS,code(e){const{gen:t,schema:r,parentSchema:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;const o=r,a=t.let("valid",!1),i=t.let("passing",null),c=t.name("_valid");e.setParams({passing:i}),t.block(l),e.result(a,()=>e.reset(),()=>e.error(!0));function l(){o.forEach((d,f)=>{let _;(0,NS.alwaysValidSchema)(s,d)?t.var(c,!0):_=e.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},c),f>0&&t.if((0,cs._)`${c} && ${a}`).assign(a,!1).assign(i,(0,cs._)`[${i}, ${f}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,f),_&&e.mergeEvaluated(_,cs.Name)})})}}};Oi.default=OS;var Mi={};Object.defineProperty(Mi,"__esModule",{value:!0});const MS=H,xS={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,MS.alwaysValidSchema)(n,o))return;const i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i)})}};Mi.default=xS;var xi={};Object.defineProperty(xi,"__esModule",{value:!0});const ks=fe,_f=H,AS={message:({params:e})=>(0,ks.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,ks._)`{failingKeyword: ${e.ifClause}}`},zS={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:AS,code(e){const{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,_f.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const s=wl(n,"then"),o=wl(n,"else");if(!s&&!o)return;const a=t.let("valid",!0),i=t.name("_valid");if(c(),e.reset(),s&&o){const d=t.let("ifClause");e.setParams({ifClause:d}),t.if(i,l("then",d),l("else",d))}else s?t.if(i,l("then")):t.if((0,ks.not)(i),l("else"));e.pass(a,()=>e.error(!0));function c(){const d=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},i);e.mergeEvaluated(d)}function l(d,f){return()=>{const _=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(_,a),f?t.assign(f,(0,ks._)`${d}`):e.setParams({ifClause:d})}}}};function wl(e,t){const r=e.schema[t];return r!==void 0&&!(0,_f.alwaysValidSchema)(e,r)}xi.default=zS;var Ai={};Object.defineProperty(Ai,"__esModule",{value:!0});const DS=H,qS={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,DS.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Ai.default=qS;Object.defineProperty(Ei,"__esModule",{value:!0});const US=Hr,FS=ki,VS=Zr,LS=Pi,HS=Ti,ZS=mf,KS=Ri,GS=Bs,WS=Ci,BS=Ii,JS=Ni,YS=ji,QS=Oi,XS=Mi,eE=xi,tE=Ai;function rE(e=!1){const t=[JS.default,YS.default,QS.default,XS.default,eE.default,tE.default,KS.default,GS.default,ZS.default,WS.default,BS.default];return e?t.push(FS.default,LS.default):t.push(US.default,VS.default),t.push(HS.default),t}Ei.default=rE;var zi={},Di={};Object.defineProperty(Di,"__esModule",{value:!0});const Ie=fe,nE={message:({schemaCode:e})=>(0,Ie.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,Ie._)`{format: ${e}}`},sE={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:nE,code(e,t){const{gen:r,data:n,$data:s,schema:o,schemaCode:a,it:i}=e,{opts:c,errSchemaPath:l,schemaEnv:d,self:f}=i;if(!c.validateFormats)return;s?_():y();function _(){const g=r.scopeValue("formats",{ref:f.formats,code:c.code.formats}),$=r.const("fDef",(0,Ie._)`${g}[${a}]`),m=r.let("fType"),h=r.let("format");r.if((0,Ie._)`typeof ${$} == "object" && !(${$} instanceof RegExp)`,()=>r.assign(m,(0,Ie._)`${$}.type || "string"`).assign(h,(0,Ie._)`${$}.validate`),()=>r.assign(m,(0,Ie._)`"string"`).assign(h,$)),e.fail$data((0,Ie.or)(v(),S()));function v(){return c.strictSchema===!1?Ie.nil:(0,Ie._)`${a} && !${h}`}function S(){const R=d.$async?(0,Ie._)`(${$}.async ? await ${h}(${n}) : ${h}(${n}))`:(0,Ie._)`${h}(${n})`,P=(0,Ie._)`(typeof ${h} == "function" ? ${R} : ${h}.test(${n}))`;return(0,Ie._)`${h} && ${h} !== true && ${m} === ${t} && !${P}`}}function y(){const g=f.formats[o];if(!g){v();return}if(g===!0)return;const[$,m,h]=S(g);$===t&&e.pass(R());function v(){if(c.strictSchema===!1){f.logger.warn(P());return}throw new Error(P());function P(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function S(P){const O=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:O});return typeof P=="object"&&!(P instanceof RegExp)?[P.type||"string",P.validate,(0,Ie._)`${A}.validate`]:["string",P,A]}function R(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!d.$async)throw new Error("async format in sync schema");return(0,Ie._)`await ${h}(${n})`}return typeof m=="function"?(0,Ie._)`${h}(${n})`:(0,Ie._)`${h}.test(${n})`}}}};Di.default=sE;Object.defineProperty(zi,"__esModule",{value:!0});const oE=Di,aE=[oE.default];zi.default=aE;var Dr={};Object.defineProperty(Dr,"__esModule",{value:!0});Dr.contentVocabulary=Dr.metadataVocabulary=void 0;Dr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Dr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(li,"__esModule",{value:!0});const iE=ui,cE=fi,lE=Ei,uE=zi,bl=Dr,dE=[iE.default,cE.default,(0,lE.default)(),uE.default,bl.metadataVocabulary,bl.contentVocabulary];li.default=dE;var qi={},Js={};Object.defineProperty(Js,"__esModule",{value:!0});Js.DiscrError=void 0;var Sl;(function(e){e.Tag="tag",e.Mapping="mapping"})(Sl||(Js.DiscrError=Sl={}));Object.defineProperty(qi,"__esModule",{value:!0});const Tr=fe,Do=Js,El=Qe,fE=Lr,hE=H,pE={message:({params:{discrError:e,tagName:t}})=>e===Do.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Tr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},mE={keyword:"discriminator",type:"object",schemaType:"object",error:pE,code(e){const{gen:t,data:r,schema:n,parentSchema:s,it:o}=e,{oneOf:a}=s;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");const i=n.propertyName;if(typeof i!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!a)throw new Error("discriminator: requires oneOf keyword");const c=t.let("valid",!1),l=t.const("tag",(0,Tr._)`${r}${(0,Tr.getProperty)(i)}`);t.if((0,Tr._)`typeof ${l} == "string"`,()=>d(),()=>e.error(!1,{discrError:Do.DiscrError.Tag,tag:l,tagName:i})),e.ok(c);function d(){const y=_();t.if(!1);for(const g in y)t.elseIf((0,Tr._)`${l} === ${g}`),t.assign(c,f(y[g]));t.else(),e.error(!1,{discrError:Do.DiscrError.Mapping,tag:l,tagName:i}),t.endIf()}function f(y){const g=t.name("valid"),$=e.subschema({keyword:"oneOf",schemaProp:y},g);return e.mergeEvaluated($,Tr.Name),g}function _(){var y;const g={},$=h(s);let m=!0;for(let R=0;Rthis.addVocabulary(g)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const g=this.opts.$data?this.$dataMetaSchema(o,a):o;this.addMetaSchema(g,i,!1),this.refs["http://json-schema.org/schema"]=i}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(i)?i:void 0)}}t.Ajv=c,e.exports=t=c,e.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var l=gt;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 f=An;Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return f.default}});var _=Lr;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return _.default}})})(No,No.exports);var SE=No.exports;const EE=eu(SE);var qo={exports:{}},yf={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(F,K){return{validate:F,compare:K}}e.fullFormats={date:t(o,a),time:t(c(!0),l),"date-time":t(_(!0),y),"iso-time":t(c(),d),"iso-date-time":t(_(),g),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:h,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:D,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:O},int64:{type:"number",validate:A},float:{type:"number",validate:L},double:{type:"number",validate:L},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,a),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,l),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,y),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,d),"iso-date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,g),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);function r(F){return F%4===0&&(F%100!==0||F%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(F){const K=n.exec(F);if(!K)return!1;const ce=+K[1],q=+K[2],le=+K[3];return q>=1&&q<=12&&le>=1&&le<=(q===2&&r(ce)?29:s[q])}function a(F,K){if(F&&K)return F>K?1:F23||w>59||F&&!ct)return!1;if(le<=23&&Ce<=59&&_e<60)return!0;const C=Ce-w*je,b=le-N*je-(C<0?1:0);return(b===23||b===-1)&&(C===59||C===-1)&&_e<61}}function l(F,K){if(!(F&&K))return;const ce=new Date("2020-01-01T"+F).valueOf(),q=new Date("2020-01-01T"+K).valueOf();if(ce&&q)return ce-q}function d(F,K){if(!(F&&K))return;const ce=i.exec(F),q=i.exec(K);if(ce&&q)return F=ce[1]+ce[2]+ce[3],K=q[1]+q[2]+q[3],F>K?1:F=R}function A(F){return Number.isInteger(F)}function L(){return!0}const V=/[^\\]\\Z/;function D(F){if(V.test(F))return!1;try{return new RegExp(F),!0}catch{return!1}}})(yf);var vf={},Uo={exports:{}},$f={},_t={},qr={},Dn={},ie={},En={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class t{}e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends t{constructor(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(h,...v){const S=[h[0]];let R=0;for(;R{if(f.scopePath===void 0)throw new Error(`CodeGen: name "${f}" has no value`);return(0,t._)`${l}${f.scopePath}`})}scopeCode(l=this._values,d,f){return this._reduceValues(l,_=>{if(_.value===void 0)throw new Error(`CodeGen: name "${_}" has no value`);return _.value.code},d,f)}_reduceValues(l,d,f={},_){let y=t.nil;for(const g in l){const $=l[g];if(!$)continue;const m=f[g]=f[g]||new Map;$.forEach(h=>{if(m.has(h))return;m.set(h,n.Started);let v=d(h);if(v){const S=this.opts.es5?e.varKinds.var:e.varKinds.const;y=(0,t._)`${y}${S} ${h} = ${v};${this.opts._n}`}else if(v=_==null?void 0:_(h))y=(0,t._)`${y}${v}${this.opts._n}`;else throw new r(h);m.set(h,n.Completed)})}return y}}e.ValueScope=i})(Fo);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=En,r=Fo;var n=En;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}});var s=Fo;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,x=this.rhs===void 0?"":` = ${this.rhs}`;return`${E} ${this.name}${x};`+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,x){super(u,E,x),this.op=p}render({_n:u}){return`${this.lhs} ${this.op}= ${this.rhs};`+u}}class l extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`${this.label}:`+u}}class d extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`break${this.label?` ${this.label}`:""};`+u}}class f extends o{constructor(u){super(),this.error=u}render({_n:u}){return`throw ${this.error};`+u}get names(){return this.error.names}}class _ extends o{constructor(u){super(),this.code=u}render({_n:u}){return`${this.code};`+u}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(u,p){return this.code=q(this.code,u,p),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}}class y 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 x=E.length;for(;x--;){const z=E[x];z.optimizeNames(u,p)||(le(u,z.names),E.splice(x,1))}return E.length>0?this:void 0}get names(){return this.nodes.reduce((u,p)=>K(u,p.names),{})}}class g extends y{render(u){return"{"+u._n+super.render(u)+"}"+u._n}}class $ extends y{}class m extends g{}m.kind="else";class h extends g{constructor(u,p){super(p),this.condition=u}render(u){let p=`if(${this.condition})`+super.render(u);return this.else&&(p+="else "+this.else.render(u)),p}optimizeNodes(){super.optimizeNodes();const u=this.condition;if(u===!0)return this.nodes;let p=this.else;if(p){const E=p.optimizeNodes();p=this.else=Array.isArray(E)?new m(E):E}if(p)return u===!1?p instanceof h?p:p.nodes:this.nodes.length?this:new h(Ce(u),p instanceof h?[p]:p.nodes);if(!(u===!1||!this.nodes.length))return this}optimizeNames(u,p){var E;if(this.else=(E=this.else)===null||E===void 0?void 0:E.optimizeNames(u,p),!!(super.optimizeNames(u,p)||this.else))return this.condition=q(this.condition,u,p),this}get names(){const u=super.names;return ce(u,this.condition),this.else&&K(u,this.else.names),u}}h.kind="if";class v extends g{}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 K(super.names,this.iteration.names)}}class R extends v{constructor(u,p,E,x){super(),this.varKind=u,this.name=p,this.from=E,this.to=x}render(u){const p=u.es5?r.varKinds.var:this.varKind,{name:E,from:x,to:z}=this;return`for(${p} ${E}=${x}; ${E}<${z}; ${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,x){super(),this.loop=u,this.varKind=p,this.name=E,this.iterable=x}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 K(super.names,this.iterable.names)}}class O extends g{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)}}O.kind="func";class A extends y{render(u){return"return "+super.render(u)}}A.kind="return";class L extends g{render(u){let p="try"+super.render(u);return this.catch&&(p+=this.catch.render(u)),this.finally&&(p+=this.finally.render(u)),p}optimizeNodes(){var u,p;return super.optimizeNodes(),(u=this.catch)===null||u===void 0||u.optimizeNodes(),(p=this.finally)===null||p===void 0||p.optimizeNodes(),this}optimizeNames(u,p){var E,x;return super.optimizeNames(u,p),(E=this.catch)===null||E===void 0||E.optimizeNames(u,p),(x=this.finally)===null||x===void 0||x.optimizeNames(u,p),this}get names(){const u=super.names;return this.catch&&K(u,this.catch.names),this.finally&&K(u,this.finally.names),u}}class V extends g{constructor(u){super(),this.error=u}render(u){return`catch(${this.error})`+super.render(u)}}V.kind="catch";class D extends g{render(u){return"finally"+super.render(u)}}D.kind="finally";class F{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,x){const z=this._scope.toName(p);return E!==void 0&&x&&(this._constants[z.str]=E),this._leafNode(new a(u,z,E)),z}const(u,p,E){return this._def(r.varKinds.const,u,p,E)}let(u,p,E){return this._def(r.varKinds.let,u,p,E)}var(u,p,E){return this._def(r.varKinds.var,u,p,E)}assign(u,p,E){return this._leafNode(new i(u,p,E))}add(u,p){return this._leafNode(new c(u,e.operators.ADD,p))}code(u){return typeof u=="function"?u():u!==t.nil&&this._leafNode(new _(u)),this}object(...u){const p=["{"];for(const[E,x]of u)p.length>1&&p.push(","),p.push(E),(E!==x||this.opts.es5)&&(p.push(":"),(0,t.addCodeArg)(p,x));return p.push("}"),new t._Code(p)}if(u,p,E){if(this._blockNode(new h(u)),p&&E)this.code(p).else().code(E).endIf();else if(p)this.code(p).endIf();else if(E)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(u){return this._elseNode(new h(u))}else(){return this._elseNode(new m)}endIf(){return this._endBlockNode(h,m)}_for(u,p){return this._blockNode(u),p&&this.code(p).endFor(),this}for(u,p){return this._for(new S(u),p)}forRange(u,p,E,x,z=this.opts.es5?r.varKinds.var:r.varKinds.let){const B=this._scope.toName(u);return this._for(new R(z,B,p,E),()=>x(B))}forOf(u,p,E,x=r.varKinds.const){const z=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`,G=>{this.var(z,(0,t._)`${B}[${G}]`),E(z)})}return this._for(new P("of",x,z,p),()=>E(z))}forIn(u,p,E,x=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(u,(0,t._)`Object.keys(${p})`,E);const z=this._scope.toName(u);return this._for(new P("in",x,z,p),()=>E(z))}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 x=new L;if(this._blockNode(x),this.code(u),p){const z=this.name("e");this._currNode=x.catch=new V(z),p(z)}return E&&(this._currNode=x.finally=new D,this.code(E)),this._endBlockNode(V,D)}throw(u){return this._leafNode(new f(u))}block(u,p){return this._blockStarts.push(this._nodes.length),u&&this.code(u).endBlock(p),this}endBlock(u){const p=this._blockStarts.pop();if(p===void 0)throw new Error("CodeGen: not in self-balancing block");const E=this._nodes.length-p;if(E<0||u!==void 0&&E!==u)throw new Error(`CodeGen: wrong number of nodes: ${E} vs ${u} expected`);return this._nodes.length=p,this}func(u,p=t.nil,E,x){return this._blockNode(new O(u,p,E)),x&&this.code(x).endFunc(),this}endFunc(){return this._endBlockNode(O)}optimize(u=1){for(;u-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(u){return this._currNode.nodes.push(u),this}_blockNode(u){this._currNode.nodes.push(u),this._nodes.push(u)}_endBlockNode(u,p){const E=this._currNode;if(E instanceof u||p&&E instanceof p)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${p?`${u.kind}/${p.kind}`:u.kind}"`)}_elseNode(u){const p=this._currNode;if(!(p instanceof h))throw new Error('CodeGen: "else" without "if"');return this._currNode=p.else=u,this}get _root(){return this._nodes[0]}get _currNode(){const u=this._nodes;return u[u.length-1]}set _currNode(u){const p=this._nodes;p[p.length-1]=u}}e.CodeGen=F;function K(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?K(b,u.names):b}function q(b,u,p){if(b instanceof t.Name)return E(b);if(!x(b))return b;return new t._Code(b._items.reduce((z,B)=>(B instanceof t.Name&&(B=E(B)),B instanceof t._Code?z.push(...B._items):z.push(B),z),[]));function E(z){const B=p[z.str];return B===void 0||u[z.str]!==1?z:(delete u[z.str],B)}function x(z){return z instanceof t._Code&&z._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 _e=w(e.operators.AND);function ct(...b){return b.reduce(_e)}e.and=ct;const je=w(e.operators.OR);function N(...b){return b.reduce(je)}e.or=N;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 Z={};Object.defineProperty(Z,"__esModule",{value:!0});Z.checkStrictMode=Z.getErrorPath=Z.Type=Z.useFunc=Z.setEvaluated=Z.evaluatedPropsToName=Z.mergeEvaluated=Z.eachItem=Z.unescapeJsonPointer=Z.escapeJsonPointer=Z.escapeFragment=Z.unescapeFragment=Z.schemaRefOrVal=Z.schemaHasRulesButRef=Z.schemaHasRules=Z.checkUnknownRules=Z.alwaysValidSchema=Z.toHash=void 0;const ve=ie,kE=En;function PE(e){const t={};for(const r of e)t[r]=!0;return t}Z.toHash=PE;function TE(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(wf(e,t),!bf(t,e.self.RULES.all))}Z.alwaysValidSchema=TE;function wf(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]||kf(e,`unknown keyword: "${o}"`)}Z.checkUnknownRules=wf;function bf(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(t[r])return!0;return!1}Z.schemaHasRules=bf;function RE(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}Z.schemaHasRulesButRef=RE;function CE({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)}`}Z.schemaRefOrVal=CE;function IE(e){return Sf(decodeURIComponent(e))}Z.unescapeFragment=IE;function NE(e){return encodeURIComponent(Ui(e))}Z.escapeFragment=NE;function Ui(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}Z.escapeJsonPointer=Ui;function Sf(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}Z.unescapeJsonPointer=Sf;function jE(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)}Z.eachItem=jE;function kl({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}}Z.mergeEvaluated={props:kl({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} || {}`),Fi(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Ef}),items:kl({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 Ef(e,t){if(t===!0)return e.var("props",!0);const r=e.var("props",(0,ve._)`{}`);return t!==void 0&&Fi(e,r,t),r}Z.evaluatedPropsToName=Ef;function Fi(e,t,r){Object.keys(r).forEach(n=>e.assign((0,ve._)`${t}${(0,ve.getProperty)(n)}`,!0))}Z.setEvaluated=Fi;const Pl={};function OE(e,t){return e.scopeValue("func",{ref:t,code:Pl[t.code]||(Pl[t.code]=new kE._Code(t.code))})}Z.useFunc=OE;var Vo;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Vo||(Z.Type=Vo={}));function ME(e,t,r){if(e instanceof ve.Name){const n=t===Vo.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():"/"+Ui(e)}Z.getErrorPath=ME;function kf(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}Z.checkStrictMode=kf;var Et={};Object.defineProperty(Et,"__esModule",{value:!0});const Ke=ie,xE={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")};Et.default=xE;(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=Z,n=Et;e.keywordError={message:({keyword:m})=>(0,t.str)`must pass "${m}" keyword validation`},e.keyword$DataError={message:({keyword:m,schemaType:h})=>h?(0,t.str)`"${m}" keyword must be ${h} ($data)`:(0,t.str)`"${m}" keyword is invalid ($data)`};function s(m,h=e.keywordError,v,S){const{it:R}=m,{gen:P,compositeRule:O,allErrors:A}=R,L=f(m,h,v);S??(O||A)?c(P,L):l(R,(0,t._)`[${L}]`)}e.reportError=s;function o(m,h=e.keywordError,v){const{it:S}=m,{gen:R,compositeRule:P,allErrors:O}=S,A=f(m,h,v);c(R,A),P||O||l(S,n.default.vErrors)}e.reportExtraError=o;function a(m,h){m.assign(n.default.errors,h),m.if((0,t._)`${n.default.vErrors} !== null`,()=>m.if(h,()=>m.assign((0,t._)`${n.default.vErrors}.length`,h),()=>m.assign(n.default.vErrors,null)))}e.resetErrorsCount=a;function i({gen:m,keyword:h,schemaValue:v,data:S,errsCount:R,it:P}){if(R===void 0)throw new Error("ajv implementation error");const O=m.name("err");m.forRange("i",R,n.default.errors,A=>{m.const(O,(0,t._)`${n.default.vErrors}[${A}]`),m.if((0,t._)`${O}.instancePath === undefined`,()=>m.assign((0,t._)`${O}.instancePath`,(0,t.strConcat)(n.default.instancePath,P.errorPath))),m.assign((0,t._)`${O}.schemaPath`,(0,t.str)`${P.errSchemaPath}/${h}`),P.opts.verbose&&(m.assign((0,t._)`${O}.schema`,v),m.assign((0,t._)`${O}.data`,S))})}e.extendErrors=i;function c(m,h){const v=m.const("err",h);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,h){const{gen:v,validateName:S,schemaEnv:R}=m;R.$async?v.throw((0,t._)`new ${m.ValidationError}(${h})`):(v.assign((0,t._)`${S}.errors`,h),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 f(m,h,v){const{createErrors:S}=m.it;return S===!1?(0,t._)`{}`:_(m,h,v)}function _(m,h,v={}){const{gen:S,it:R}=m,P=[y(R,v),g(m,v)];return $(m,h,P),S.object(...P)}function y({errorPath:m},{instancePath:h}){const v=h?(0,t.str)`${m}${(0,r.getErrorPath)(h,r.Type.Str)}`:m;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,v)]}function g({keyword:m,it:{errSchemaPath:h}},{schemaPath:v,parentSchema:S}){let R=S?h:(0,t.str)`${h}/${m}`;return v&&(R=(0,t.str)`${R}${(0,r.getErrorPath)(v,r.Type.Str)}`),[d.schemaPath,R]}function $(m,{params:h,message:v},S){const{keyword:R,data:P,schemaValue:O,it:A}=m,{opts:L,propertyName:V,topSchemaRef:D,schemaPath:F}=A;S.push([d.keyword,R],[d.params,typeof h=="function"?h(m):h||(0,t._)`{}`]),L.messages&&S.push([d.message,typeof v=="function"?v(m):v]),L.verbose&&S.push([d.schema,O],[d.parentSchema,(0,t._)`${D}${F}`],[n.default.data,P]),V&&S.push([d.propertyName,V])}})(Dn);Object.defineProperty(qr,"__esModule",{value:!0});qr.boolOrEmptySchema=qr.topBoolOrEmptySchema=void 0;const AE=Dn,zE=ie,DE=Et,qE={message:"boolean schema is false"};function UE(e){const{gen:t,schema:r,validateName:n}=e;r===!1?Pf(e,!1):typeof r=="object"&&r.$async===!0?t.return(DE.default.data):(t.assign((0,zE._)`${n}.errors`,null),t.return(!0))}qr.topBoolOrEmptySchema=UE;function FE(e,t){const{gen:r,schema:n}=e;n===!1?(r.var(t,!1),Pf(e)):r.var(t,!0)}qr.boolOrEmptySchema=FE;function Pf(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,AE.reportError)(s,qE,void 0,t)}var Me={},yr={};Object.defineProperty(yr,"__esModule",{value:!0});yr.getRules=yr.isJSONType=void 0;const VE=["string","number","integer","boolean","null","object","array"],LE=new Set(VE);function HE(e){return typeof e=="string"&&LE.has(e)}yr.isJSONType=HE;function ZE(){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:{}}}yr.getRules=ZE;var Tt={};Object.defineProperty(Tt,"__esModule",{value:!0});Tt.shouldUseRule=Tt.shouldUseGroup=Tt.schemaHasRulesForType=void 0;function KE({schema:e,self:t},r){const n=t.RULES.types[r];return n&&n!==!0&&Tf(e,n)}Tt.schemaHasRulesForType=KE;function Tf(e,t){return t.rules.some(r=>Rf(e,r))}Tt.shouldUseGroup=Tf;function Rf(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))}Tt.shouldUseRule=Rf;Object.defineProperty(Me,"__esModule",{value:!0});Me.reportTypeError=Me.checkDataTypes=Me.checkDataType=Me.coerceAndCheckDataType=Me.getJSONTypes=Me.getSchemaTypes=Me.DataType=void 0;const GE=yr,WE=Tt,BE=Dn,oe=ie,Cf=Z;var Mr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Mr||(Me.DataType=Mr={}));function JE(e){const t=If(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}Me.getSchemaTypes=JE;function If(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(GE.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Me.getJSONTypes=If;function YE(e,t){const{gen:r,data:n,opts:s}=e,o=QE(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0,WE.schemaHasRulesForType)(e,t[0]));if(a){const i=Vi(t,n,s.strictNumbers,Mr.Wrong);r.if(i,()=>{o.length?XE(e,t,o):Li(e)})}return a}Me.coerceAndCheckDataType=YE;const Nf=new Set(["string","number","integer","boolean","null"]);function QE(e,t){return t?e.filter(r=>Nf.has(r)||t==="array"&&r==="array"):[]}function XE(e,t,r){const{gen:n,data:s,opts:o}=e,a=n.let("dataType",(0,oe._)`typeof ${s}`),i=n.let("coerced",(0,oe._)`undefined`);o.coerceTypes==="array"&&n.if((0,oe._)`${a} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,oe._)`${s}[0]`).assign(a,(0,oe._)`typeof ${s}`).if(Vi(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0,oe._)`${i} !== undefined`);for(const l of r)(Nf.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),Li(e),n.endIf(),n.if((0,oe._)`${i} !== undefined`,()=>{n.assign(s,i),ek(e,i)});function c(l){switch(l){case"string":n.elseIf((0,oe._)`${a} == "number" || ${a} == "boolean"`).assign(i,(0,oe._)`"" + ${s}`).elseIf((0,oe._)`${s} === null`).assign(i,(0,oe._)`""`);return;case"number":n.elseIf((0,oe._)`${a} == "boolean" || ${s} === null + || (${a} == "string" && ${s} && ${s} == +${s})`).assign(i,(0,oe._)`+${s}`);return;case"integer":n.elseIf((0,oe._)`${a} === "boolean" || ${s} === null + || (${a} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(i,(0,oe._)`+${s}`);return;case"boolean":n.elseIf((0,oe._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(i,!1).elseIf((0,oe._)`${s} === "true" || ${s} === 1`).assign(i,!0);return;case"null":n.elseIf((0,oe._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(i,null);return;case"array":n.elseIf((0,oe._)`${a} === "string" || ${a} === "number" + || ${a} === "boolean" || ${s} === null`).assign(i,(0,oe._)`[${s}]`)}}}function ek({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,oe._)`${t} !== undefined`,()=>e.assign((0,oe._)`${t}[${r}]`,n))}function Lo(e,t,r,n=Mr.Correct){const s=n===Mr.Correct?oe.operators.EQ:oe.operators.NEQ;let o;switch(e){case"null":return(0,oe._)`${t} ${s} null`;case"array":o=(0,oe._)`Array.isArray(${t})`;break;case"object":o=(0,oe._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=a((0,oe._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=a();break;default:return(0,oe._)`typeof ${t} ${s} ${e}`}return n===Mr.Correct?o:(0,oe.not)(o);function a(i=oe.nil){return(0,oe.and)((0,oe._)`typeof ${t} == "number"`,i,r?(0,oe._)`isFinite(${t})`:oe.nil)}}Me.checkDataType=Lo;function Vi(e,t,r,n){if(e.length===1)return Lo(e[0],t,r,n);let s;const o=(0,Cf.toHash)(e);if(o.array&&o.object){const a=(0,oe._)`typeof ${t} != "object"`;s=o.null?a:(0,oe._)`!${t} || ${a}`,delete o.null,delete o.array,delete o.object}else s=oe.nil;o.number&&delete o.integer;for(const a in o)s=(0,oe.and)(s,Lo(a,t,r,n));return s}Me.checkDataTypes=Vi;const tk={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,oe._)`{type: ${e}}`:(0,oe._)`{type: ${t}}`};function Li(e){const t=rk(e);(0,BE.reportError)(t,tk)}Me.reportTypeError=Li;function rk(e){const{gen:t,data:r,schema:n}=e,s=(0,Cf.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}var Ys={};Object.defineProperty(Ys,"__esModule",{value:!0});Ys.assignDefaults=void 0;const Sr=ie,nk=Z;function sk(e,t){const{properties:r,items:n}=e.schema;if(t==="object"&&r)for(const s in r)Tl(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>Tl(e,o,s.default))}Ys.assignDefaults=sk;function Tl(e,t,r){const{gen:n,compositeRule:s,data:o,opts:a}=e;if(r===void 0)return;const i=(0,Sr._)`${o}${(0,Sr.getProperty)(t)}`;if(s){(0,nk.checkStrictMode)(e,`default is ignored for: ${i}`);return}let c=(0,Sr._)`${i} === undefined`;a.useDefaults==="empty"&&(c=(0,Sr._)`${c} || ${i} === null || ${i} === ""`),n.if(c,(0,Sr._)`${i} = ${(0,Sr.stringify)(r)}`)}var bt={},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,Hi=Z,Nt=Et,ok=Z;function ak(e,t){const{gen:r,data:n,it:s}=e;r.if(Ki(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Se._)`${t}`},!0),e.error()})}de.checkReportMissingProp=ak;function ik({gen:e,data:t,it:{opts:r}},n,s){return(0,Se.or)(...n.map(o=>(0,Se.and)(Ki(e,t,o,r.ownProperties),(0,Se._)`${s} = ${o}`)))}de.checkMissingProp=ik;function ck(e,t){e.setParams({missingProperty:t},!0),e.error()}de.reportMissingProp=ck;function jf(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Se._)`Object.prototype.hasOwnProperty`})}de.hasPropFunc=jf;function Zi(e,t,r){return(0,Se._)`${jf(e)}.call(${t}, ${r})`}de.isOwnProperty=Zi;function lk(e,t,r,n){const s=(0,Se._)`${t}${(0,Se.getProperty)(r)} !== undefined`;return n?(0,Se._)`${s} && ${Zi(e,t,r)}`:s}de.propertyInData=lk;function Ki(e,t,r,n){const s=(0,Se._)`${t}${(0,Se.getProperty)(r)} === undefined`;return n?(0,Se.or)(s,(0,Se.not)(Zi(e,t,r))):s}de.noPropertyInData=Ki;function Of(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}de.allSchemaProperties=Of;function uk(e,t){return Of(t).filter(r=>!(0,Hi.alwaysValidSchema)(e,t[r]))}de.schemaProperties=uk;function dk({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,f=[[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&&f.push([Nt.default.dynamicAnchors,Nt.default.dynamicAnchors]);const _=(0,Se._)`${d}, ${r.object(...f)}`;return c!==Se.nil?(0,Se._)`${i}.call(${c}, ${_})`:(0,Se._)`${i}(${_})`}de.callValidateCode=dk;const fk=(0,Se._)`new RegExp`;function hk({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"?fk:(0,ok.useFunc)(e,s)}(${r}, ${n})`})}de.usePattern=hk;function pk(e){const{gen:t,data:r,keyword:n,it:s}=e,o=t.name("valid");if(s.allErrors){const i=t.let("valid",!0);return a(()=>t.assign(i,!1)),i}return t.var(o,!0),a(()=>t.break()),o;function a(i){const c=t.const("len",(0,Se._)`${r}.length`);t.forRange("i",0,c,l=>{e.subschema({keyword:n,dataProp:l,dataPropType:Hi.Type.Num},o),t.if((0,Se.not)(o),i)})}}de.validateArray=pk;function mk(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,Hi.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=mk;Object.defineProperty(bt,"__esModule",{value:!0});bt.validateKeywordUsage=bt.validSchemaType=bt.funcKeywordCode=bt.macroKeywordCode=void 0;const Be=ie,ur=Et,gk=de,_k=Dn;function yk(e,t){const{gen:r,keyword:n,schema:s,parentSchema:o,it:a}=e,i=t.macro.call(a.self,s,o,a),c=Mf(r,n,i);a.opts.validateSchema!==!1&&a.self.validateSchema(i,!0);const l=r.name("valid");e.subschema({schema:i,schemaPath:Be.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},l),e.pass(l,()=>e.error(!0))}bt.macroKeywordCode=yk;function vk(e,t){var r;const{gen:n,keyword:s,schema:o,parentSchema:a,$data:i,it:c}=e;wk(c,t);const l=!i&&t.compile?t.compile.call(c.self,o,a,c):t.validate,d=Mf(n,s,l),f=n.let("valid");e.block$data(f,_),e.ok((r=t.valid)!==null&&r!==void 0?r:f);function _(){if(t.errors===!1)$(),t.modifying&&Rl(e),m(()=>e.error());else{const h=t.async?y():g();t.modifying&&Rl(e),m(()=>$k(e,h))}}function y(){const h=n.let("ruleErrs",null);return n.try(()=>$((0,Be._)`await `),v=>n.assign(f,!1).if((0,Be._)`${v} instanceof ${c.ValidationError}`,()=>n.assign(h,(0,Be._)`${v}.errors`),()=>n.throw(v))),h}function g(){const h=(0,Be._)`${d}.errors`;return n.assign(h,null),$(Be.nil),h}function $(h=t.async?(0,Be._)`await `:Be.nil){const v=c.opts.passContext?ur.default.this:ur.default.self,S=!("compile"in t&&!i||t.schema===!1);n.assign(f,(0,Be._)`${h}${(0,gk.callValidateCode)(e,d,v,S)}`,t.modifying)}function m(h){var v;n.if((0,Be.not)((v=t.valid)!==null&&v!==void 0?v:f),h)}}bt.funcKeywordCode=vk;function Rl(e){const{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Be._)`${n.parentData}[${n.parentDataProperty}]`))}function $k(e,t){const{gen:r}=e;r.if((0,Be._)`Array.isArray(${t})`,()=>{r.assign(ur.default.vErrors,(0,Be._)`${ur.default.vErrors} === null ? ${t} : ${ur.default.vErrors}.concat(${t})`).assign(ur.default.errors,(0,Be._)`${ur.default.vErrors}.length`),(0,_k.extendErrors)(e)},()=>e.error())}function wk({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function Mf(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,Be.stringify)(r)})}function bk(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")}bt.validSchemaType=bk;function Sk({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)}}bt.validateKeywordUsage=Sk;var Dt={};Object.defineProperty(Dt,"__esModule",{value:!0});Dt.extendSubschemaMode=Dt.extendSubschemaData=Dt.getSubschema=void 0;const $t=ie,xf=Z;function Ek(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,$t._)`${e.schemaPath}${(0,$t.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:i[r],schemaPath:(0,$t._)`${e.schemaPath}${(0,$t.getProperty)(t)}${(0,$t.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,xf.escapeFragment)(r)}`}}if(n!==void 0){if(s===void 0||o===void 0||a===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:s,topSchemaRef:a,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}Dt.getSubschema=Ek;function kk(e,t,{dataProp:r,dataPropType:n,data:s,dataTypes:o,propertyName:a}){if(s!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:i}=t;if(r!==void 0){const{errorPath:l,dataPathArr:d,opts:f}=t,_=i.let("data",(0,$t._)`${t.data}${(0,$t.getProperty)(r)}`,!0);c(_),e.errorPath=(0,$t.str)`${l}${(0,xf.getErrorPath)(r,n,f.jsPropertySyntax)}`,e.parentDataProperty=(0,$t._)`${r}`,e.dataPathArr=[...d,e.parentDataProperty]}if(s!==void 0){const l=s instanceof $t.Name?s:i.let("data",s,!0);c(l),a!==void 0&&(e.propertyName=a)}o&&(e.dataTypes=o);function c(l){e.data=l,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,l]}}Dt.extendSubschemaData=kk;function Pk(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:s,allErrors:o}){n!==void 0&&(e.compositeRule=n),s!==void 0&&(e.createErrors=s),o!==void 0&&(e.allErrors=o),e.jtdDiscriminator=t,e.jtdMetadata=r}Dt.extendSubschemaMode=Pk;var Fe={},Af={exports:{}},xt=Af.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(){};ls(t,n,s,e,"",e)};xt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};xt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};xt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};xt.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 ls(e,t,r,n,s,o,a,i,c,l){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,s,o,a,i,c,l);for(var d in n){var f=n[d];if(Array.isArray(f)){if(d in xt.arrayKeywords)for(var _=0;_t+=zf(n)),t===1/0))return 1/0}return t}function Df(e,t="",r){r!==!1&&(t=xr(t));const n=e.parse(t);return qf(e,n)}Fe.getFullPath=Df;function qf(e,t){return e.serialize(t).split("#")[0]+"#"}Fe._getFullPath=qf;const xk=/#\/?$/;function xr(e){return e?e.replace(xk,""):""}Fe.normalizeId=xr;function Ak(e,t,r){return r=xr(r),e.resolve(t,r)}Fe.resolveUrl=Ak;const zk=/^[a-z_][-a-z0-9._]*$/i;function Dk(e,t){if(typeof e=="boolean")return{};const{schemaId:r,uriResolver:n}=this.opts,s=xr(e[r]||t),o={"":s},a=Df(n,s,!1),i={},c=new Set;return Nk(e,{allKeys:!0},(f,_,y,g)=>{if(g===void 0)return;const $=a+_;let m=o[g];typeof f[r]=="string"&&(m=h.call(this,f[r])),v.call(this,f.$anchor),v.call(this,f.$dynamicAnchor),o[_]=m;function h(S){const R=this.opts.uriResolver.resolve;if(S=xr(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(f,P.schema,S):S!==xr($)&&(S[0]==="#"?(l(f,i[S],S),i[S]=f):this.refs[S]=$),S}function v(S){if(typeof S=="string"){if(!zk.test(S))throw new Error(`invalid anchor "${S}"`);h.call(this,`#${S}`)}}}),i;function l(f,_,y){if(_!==void 0&&!Ik(f,_))throw d(y)}function d(f){return new Error(`reference "${f}" resolves to more than one schema`)}}Fe.getSchemaRefs=Dk;Object.defineProperty(_t,"__esModule",{value:!0});_t.getData=_t.KeywordCxt=_t.validateFunctionCode=void 0;const Uf=qr,Cl=Me,Gi=Tt,Ps=Me,qk=Ys,hn=bt,fo=Dt,Y=ie,te=Et,Uk=Fe,Rt=Z,en=Dn;function Fk(e){if(Lf(e)&&(Hf(e),Vf(e))){Hk(e);return}Ff(e,()=>(0,Uf.topBoolOrEmptySchema)(e))}_t.validateFunctionCode=Fk;function Ff({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},o){s.code.es5?e.func(t,(0,Y._)`${te.default.data}, ${te.default.valCxt}`,n.$async,()=>{e.code((0,Y._)`"use strict"; ${Il(r,s)}`),Lk(e,s),e.code(o)}):e.func(t,(0,Y._)`${te.default.data}, ${Vk(s)}`,n.$async,()=>e.code(Il(r,s)).code(o))}function Vk(e){return(0,Y._)`{${te.default.instancePath}="", ${te.default.parentData}, ${te.default.parentDataProperty}, ${te.default.rootData}=${te.default.data}${e.dynamicRef?(0,Y._)`, ${te.default.dynamicAnchors}={}`:Y.nil}}={}`}function Lk(e,t){e.if(te.default.valCxt,()=>{e.var(te.default.instancePath,(0,Y._)`${te.default.valCxt}.${te.default.instancePath}`),e.var(te.default.parentData,(0,Y._)`${te.default.valCxt}.${te.default.parentData}`),e.var(te.default.parentDataProperty,(0,Y._)`${te.default.valCxt}.${te.default.parentDataProperty}`),e.var(te.default.rootData,(0,Y._)`${te.default.valCxt}.${te.default.rootData}`),t.dynamicRef&&e.var(te.default.dynamicAnchors,(0,Y._)`${te.default.valCxt}.${te.default.dynamicAnchors}`)},()=>{e.var(te.default.instancePath,(0,Y._)`""`),e.var(te.default.parentData,(0,Y._)`undefined`),e.var(te.default.parentDataProperty,(0,Y._)`undefined`),e.var(te.default.rootData,te.default.data),t.dynamicRef&&e.var(te.default.dynamicAnchors,(0,Y._)`{}`)})}function Hk(e){const{schema:t,opts:r,gen:n}=e;Ff(e,()=>{r.$comment&&t.$comment&&Kf(e),Bk(e),n.let(te.default.vErrors,null),n.let(te.default.errors,0),r.unevaluated&&Zk(e),Zf(e),Qk(e)})}function Zk(e){const{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,Y._)`${r}.evaluated`),t.if((0,Y._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,Y._)`${e.evaluated}.props`,(0,Y._)`undefined`)),t.if((0,Y._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,Y._)`${e.evaluated}.items`,(0,Y._)`undefined`))}function Il(e,t){const r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,Y._)`/*# sourceURL=${r} */`:Y.nil}function Kk(e,t){if(Lf(e)&&(Hf(e),Vf(e))){Gk(e,t);return}(0,Uf.boolOrEmptySchema)(e,t)}function Vf({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 Lf(e){return typeof e.schema!="boolean"}function Gk(e,t){const{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&Kf(e),Jk(e),Yk(e);const o=n.const("_errs",te.default.errors);Zf(e,o),n.var(t,(0,Y._)`${o} === ${te.default.errors}`)}function Hf(e){(0,Rt.checkUnknownRules)(e),Wk(e)}function Zf(e,t){if(e.opts.jtd)return Nl(e,[],!1,t);const r=(0,Cl.getSchemaTypes)(e.schema),n=(0,Cl.coerceAndCheckDataType)(e,r);Nl(e,r,!n,t)}function Wk(e){const{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,Rt.schemaHasRulesButRef)(t,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function Bk(e){const{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Rt.checkStrictMode)(e,"default is ignored in the schema root")}function Jk(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,Uk.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function Yk(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Kf({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:s}){const o=r.$comment;if(s.$comment===!0)e.code((0,Y._)`${te.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){const a=(0,Y.str)`${n}/$comment`,i=e.scopeValue("root",{ref:t.root});e.code((0,Y._)`${te.default.self}.opts.$comment(${o}, ${a}, ${i}.schema)`)}}function Qk(e){const{gen:t,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=e;r.$async?t.if((0,Y._)`${te.default.errors} === 0`,()=>t.return(te.default.data),()=>t.throw((0,Y._)`new ${s}(${te.default.vErrors})`)):(t.assign((0,Y._)`${n}.errors`,te.default.vErrors),o.unevaluated&&Xk(e),t.return((0,Y._)`${te.default.errors} === 0`))}function Xk({gen:e,evaluated:t,props:r,items:n}){r instanceof Y.Name&&e.assign((0,Y._)`${t}.props`,r),n instanceof Y.Name&&e.assign((0,Y._)`${t}.items`,n)}function Nl(e,t,r,n){const{gen:s,schema:o,data:a,allErrors:i,opts:c,self:l}=e,{RULES:d}=l;if(o.$ref&&(c.ignoreKeywordsWithRef||!(0,Rt.schemaHasRulesButRef)(o,d))){s.block(()=>Bf(e,"$ref",d.all.$ref.definition));return}c.jtd||eP(e,t),s.block(()=>{for(const _ of d.rules)f(_);f(d.post)});function f(_){(0,Gi.shouldUseGroup)(o,_)&&(_.type?(s.if((0,Ps.checkDataType)(_.type,a,c.strictNumbers)),jl(e,_),t.length===1&&t[0]===_.type&&r&&(s.else(),(0,Ps.reportTypeError)(e)),s.endIf()):jl(e,_),i||s.if((0,Y._)`${te.default.errors} === ${n||0}`))}}function jl(e,t){const{gen:r,schema:n,opts:{useDefaults:s}}=e;s&&(0,qk.assignDefaults)(e,t.type),r.block(()=>{for(const o of t.rules)(0,Gi.shouldUseRule)(n,o)&&Bf(e,o.keyword,o.definition,t.type)})}function eP(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(tP(e,t),e.opts.allowUnionTypes||rP(e,t),nP(e,e.dataTypes))}function tP(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{Gf(e.dataTypes,r)||Wi(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),oP(e,t)}}function rP(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Wi(e,"use allowUnionTypes to allow union type keyword")}function nP(e,t){const r=e.self.RULES.all;for(const n in r){const s=r[n];if(typeof s=="object"&&(0,Gi.shouldUseRule)(e.schema,s)){const{type:o}=s.definition;o.length&&!o.some(a=>sP(t,a))&&Wi(e,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function sP(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function Gf(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function oP(e,t){const r=[];for(const n of e.dataTypes)Gf(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function Wi(e,t){const r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,Rt.checkStrictMode)(e,t,e.opts.strictTypes)}class Wf{constructor(t,r,n){if((0,hn.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Rt.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",Jf(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,hn.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",te.default.errors))}result(t,r,n){this.failResult((0,Y.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,Y.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);const{schemaCode:r}=this;this.fail((0,Y._)`${r} !== undefined && (${(0,Y.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?en.reportExtraError:en.reportError)(this,this.def.error,r)}$dataError(){(0,en.reportError)(this,this.def.$dataError||en.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,en.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=Y.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=Y.nil,r=Y.nil){if(!this.$data)return;const{gen:n,schemaCode:s,schemaType:o,def:a}=this;n.if((0,Y.or)((0,Y._)`${s} === undefined`,r)),t!==Y.nil&&n.assign(t,!0),(o.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==Y.nil&&n.assign(t,!1)),n.else()}invalid$data(){const{gen:t,schemaCode:r,schemaType:n,def:s,it:o}=this;return(0,Y.or)(a(),i());function a(){if(n.length){if(!(r instanceof Y.Name))throw new Error("ajv implementation error");const c=Array.isArray(n)?n:[n];return(0,Y._)`${(0,Ps.checkDataTypes)(c,r,o.opts.strictNumbers,Ps.DataType.Wrong)}`}return Y.nil}function i(){if(s.validateSchema){const c=t.scopeValue("validate$data",{ref:s.validateSchema});return(0,Y._)`!${c}(${r})`}return Y.nil}}subschema(t,r){const n=(0,fo.getSubschema)(this.it,t);(0,fo.extendSubschemaData)(n,this.it,t),(0,fo.extendSubschemaMode)(n,t);const s={...this.it,...n,items:void 0,props:void 0};return Kk(s,r),s}mergeEvaluated(t,r){const{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=Rt.mergeEvaluated.props(s,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=Rt.mergeEvaluated.items(s,t.items,n.items,r)))}mergeValidEvaluated(t,r){const{it:n,gen:s}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return s.if(r,()=>this.mergeEvaluated(t,Y.Name)),!0}}_t.KeywordCxt=Wf;function Bf(e,t,r,n){const s=new Wf(e,r,t);"code"in r?r.code(s,n):s.$data&&r.validate?(0,hn.funcKeywordCode)(s,r):"macro"in r?(0,hn.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,hn.funcKeywordCode)(s,r)}const aP=/^\/(?:[^~]|~0|~1)*$/,iP=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Jf(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,o;if(e==="")return te.default.rootData;if(e[0]==="/"){if(!aP.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,o=te.default.rootData}else{const l=iP.exec(e);if(!l)throw new Error(`Invalid JSON-pointer: ${e}`);const d=+l[1];if(s=l[2],s==="#"){if(d>=t)throw new Error(c("property/index",d));return n[t-d]}if(d>t)throw new Error(c("data",d));if(o=r[t-d],!s)return o}let a=o;const i=s.split("/");for(const l of i)l&&(o=(0,Y._)`${o}${(0,Y.getProperty)((0,Rt.unescapeJsonPointer)(l))}`,a=(0,Y._)`${a} && ${o}`);return a;function c(l,d){return`Cannot access ${l} ${d} levels up, current level is ${t}`}}_t.getData=Jf;var qn={};Object.defineProperty(qn,"__esModule",{value:!0});class cP extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}}qn.default=cP;var Kr={};Object.defineProperty(Kr,"__esModule",{value:!0});const ho=Fe;class lP extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,ho.resolveUrl)(t,r,n),this.missingSchema=(0,ho.normalizeId)((0,ho.getFullPath)(t,this.missingRef))}}Kr.default=lP;var Xe={};Object.defineProperty(Xe,"__esModule",{value:!0});Xe.resolveSchema=Xe.getCompilingSchema=Xe.resolveRef=Xe.compileSchema=Xe.SchemaEnv=void 0;const dt=ie,uP=qn,sr=Et,mt=Fe,Ol=Z,dP=_t;class Qs{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,mt.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={}}}Xe.SchemaEnv=Qs;function Bi(e){const t=Yf.call(this,e);if(t)return t;const r=(0,mt.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,a=new dt.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o});let i;e.$async&&(i=a.scopeValue("Error",{ref:uP.default,code:(0,dt._)`require("ajv/dist/runtime/validation_error").default`}));const c=a.scopeName("validate");e.validateName=c;const l={gen:a,allErrors:this.opts.allErrors,data:sr.default.data,parentData:sr.default.parentData,parentDataProperty:sr.default.parentDataProperty,dataNames:[sr.default.data],dataPathArr:[dt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,dt.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:dt.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,dt._)`""`,opts:this.opts,self:this};let d;try{this._compilations.add(e),(0,dP.validateFunctionCode)(l),a.optimize(this.opts.code.optimize);const f=a.toString();d=`${a.scopeRefs(sr.default.scope)}return ${f}`,this.opts.code.process&&(d=this.opts.code.process(d,e));const y=new Function(`${sr.default.self}`,`${sr.default.scope}`,d)(this,this.scope.get());if(this.scope.value(c,{ref:y}),y.errors=null,y.schema=e.schema,y.schemaEnv=e,e.$async&&(y.$async=!0),this.opts.code.source===!0&&(y.source={validateName:c,validateCode:f,scopeValues:a._values}),this.opts.unevaluated){const{props:g,items:$}=l;y.evaluated={props:g instanceof dt.Name?void 0:g,items:$ instanceof dt.Name?void 0:$,dynamicProps:g instanceof dt.Name,dynamicItems:$ instanceof dt.Name},y.source&&(y.source.evaluated=(0,dt.stringify)(y.evaluated))}return e.validate=y,e}catch(f){throw delete e.validate,delete e.validateName,d&&this.logger.error("Error compiling schema, function code:",d),f}finally{this._compilations.delete(e)}}Xe.compileSchema=Bi;function fP(e,t,r){var n;r=(0,mt.resolveUrl)(this.opts.uriResolver,t,r);const s=e.refs[r];if(s)return s;let o=mP.call(this,e,r);if(o===void 0){const a=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:i}=this.opts;a&&(o=new Qs({schema:a,schemaId:i,root:e,baseId:t}))}if(o!==void 0)return e.refs[r]=hP.call(this,o)}Xe.resolveRef=fP;function hP(e){return(0,mt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Bi.call(this,e)}function Yf(e){for(const t of this._compilations)if(pP(t,e))return t}Xe.getCompilingSchema=Yf;function pP(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function mP(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Xs.call(this,e,t)}function Xs(e,t){const r=this.opts.uriResolver.parse(t),n=(0,mt._getFullPath)(this.opts.uriResolver,r);let s=(0,mt.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===s)return po.call(this,r,e);const o=(0,mt.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){const i=Xs.call(this,e,a);return typeof(i==null?void 0:i.schema)!="object"?void 0:po.call(this,r,i)}if(typeof(a==null?void 0:a.schema)=="object"){if(a.validate||Bi.call(this,a),o===(0,mt.normalizeId)(t)){const{schema:i}=a,{schemaId:c}=this.opts,l=i[c];return l&&(s=(0,mt.resolveUrl)(this.opts.uriResolver,s,l)),new Qs({schema:i,schemaId:c,root:e,baseId:s})}return po.call(this,r,a)}}Xe.resolveSchema=Xs;const gP=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function po(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,Ol.unescapeFragment)(i)];if(c===void 0)return;r=c;const l=typeof r=="object"&&r[this.opts.schemaId];!gP.has(i)&&l&&(t=(0,mt.resolveUrl)(this.opts.uriResolver,t,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,Ol.schemaHasRulesButRef)(r,this.RULES)){const i=(0,mt.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=Xs.call(this,n,i)}const{schemaId:a}=this.opts;if(o=o||new Qs({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}const _P="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",yP="Meta-schema for $data reference (JSON AnySchema extension proposal)",vP="object",$P=["$data"],wP={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},bP=!1,SP={$id:_P,description:yP,type:vP,required:$P,properties:wP,additionalProperties:bP};var Ji={};Object.defineProperty(Ji,"__esModule",{value:!0});const Qf=cf;Qf.code='require("ajv/dist/runtime/uri").default';Ji.default=Qf;(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=qn,s=Kr,o=yr,a=Xe,i=ie,c=Fe,l=Me,d=Z,f=SP,_=Ji,y=(N,w)=>new RegExp(N,w);y.code="new RegExp";const g=["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."},h={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},v=200;function S(N){var w,C,b,u,p,E,x,z,B,G,he,tt,Ft,Vt,Lt,Ht,Zt,Kt,Gt,Wt,Bt,Jt,Yt,Qt,Xt;const lt=N.strict,er=(w=N.code)===null||w===void 0?void 0:w.optimize,Br=er===!0||er===void 0?1:er||0,Jr=(b=(C=N.code)===null||C===void 0?void 0:C.regExp)!==null&&b!==void 0?b:y,ro=(u=N.uriResolver)!==null&&u!==void 0?u:_.default;return{strictSchema:(E=(p=N.strictSchema)!==null&&p!==void 0?p:lt)!==null&&E!==void 0?E:!0,strictNumbers:(z=(x=N.strictNumbers)!==null&&x!==void 0?x:lt)!==null&&z!==void 0?z:!0,strictTypes:(G=(B=N.strictTypes)!==null&&B!==void 0?B:lt)!==null&&G!==void 0?G:"log",strictTuples:(tt=(he=N.strictTuples)!==null&&he!==void 0?he:lt)!==null&&tt!==void 0?tt:"log",strictRequired:(Vt=(Ft=N.strictRequired)!==null&&Ft!==void 0?Ft:lt)!==null&&Vt!==void 0?Vt:!1,code:N.code?{...N.code,optimize:Br,regExp:Jr}:{optimize:Br,regExp:Jr},loopRequired:(Lt=N.loopRequired)!==null&&Lt!==void 0?Lt:v,loopEnum:(Ht=N.loopEnum)!==null&&Ht!==void 0?Ht:v,meta:(Zt=N.meta)!==null&&Zt!==void 0?Zt:!0,messages:(Kt=N.messages)!==null&&Kt!==void 0?Kt:!0,inlineRefs:(Gt=N.inlineRefs)!==null&&Gt!==void 0?Gt:!0,schemaId:(Wt=N.schemaId)!==null&&Wt!==void 0?Wt:"$id",addUsedSchema:(Bt=N.addUsedSchema)!==null&&Bt!==void 0?Bt:!0,validateSchema:(Jt=N.validateSchema)!==null&&Jt!==void 0?Jt:!0,validateFormats:(Yt=N.validateFormats)!==null&&Yt!==void 0?Yt:!0,unicodeRegExp:(Qt=N.unicodeRegExp)!==null&&Qt!==void 0?Qt:!0,int32range:(Xt=N.int32range)!==null&&Xt!==void 0?Xt:!0,uriResolver:ro}}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=K(w.logger);const u=w.validateFormats;w.validateFormats=!1,this.RULES=(0,o.getRules)(),P.call(this,m,w,"NOT SUPPORTED"),P.call(this,h,w,"DEPRECATED","warn"),this._metaOpts=D.call(this),w.formats&&L.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),w.keywords&&V.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=f;b==="id"&&(u={...f},u.id=u.$id,delete u.$id),C&&w&&this.addMetaSchema(u,u[b],!1)}defaultMeta(){const{meta:w,schemaId:C}=this.opts;return this.opts.defaultMeta=typeof w=="object"?w[C]||w:void 0}validate(w,C){let b;if(typeof w=="string"){if(b=this.getSchema(w),!b)throw new Error(`no schema with key or ref "${w}"`)}else b=this.compile(w);const u=b(C);return"$async"in b||(this.errors=b.errors),u}compile(w,C){const b=this._addSchema(w,C);return b.validate||this._compileSchemaEnv(b)}compileAsync(w,C){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:b}=this.opts;return u.call(this,w,C);async function u(G,he){await p.call(this,G.$schema);const tt=this._addSchema(G,he);return tt.validate||E.call(this,tt)}async function p(G){G&&!this.getSchema(G)&&await u.call(this,{$ref:G},!0)}async function E(G){try{return this._compileSchemaEnv(G)}catch(he){if(!(he instanceof s.default))throw he;return x.call(this,he),await z.call(this,he.missingSchema),E.call(this,G)}}function x({missingSchema:G,missingRef:he}){if(this.refs[G])throw new Error(`AnySchema ${G} is loaded but ${he} cannot be resolved`)}async function z(G){const he=await B.call(this,G);this.refs[G]||await p.call(this,he.$schema),this.refs[G]||this.addSchema(he,G,C)}async function B(G){const he=this._loading[G];if(he)return he;try{return await(this._loading[G]=b(G))}finally{delete this._loading[G]}}}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=O.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=O.call(this,w);return typeof C=="object"&&this._cache.delete(C.schema),delete this.schemas[w],delete this.refs[w],this}case"object":{const C=w;this._cache.delete(C);let 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;_e.call(this,C);const u={...C,type:(0,l.getJSONTypes)(C.type),schemaType:(0,l.getJSONTypes)(C.schemaType)};return(0,d.eachItem)(b,u.type.length===0?p=>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 x of p)E=E[x];for(const x in b){const z=b[x];if(typeof z!="object")continue;const{$data:B}=z.definition,G=E[x];B&&G&&(E[x]=je(G))}}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:x}=this.opts;if(typeof w=="object")E=w[x];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof w!="boolean")throw new Error("schema must be object or boolean")}let z=this._cache.get(w);if(z!==void 0)return z;b=(0,c.normalizeId)(E||b);const B=c.getSchemaRefs.call(this,w,b);return z=new a.SchemaEnv({schema:w,schemaId:x,meta:C,baseId:b,localRefs:B}),this._cache.set(z.schema,z),p&&!b.startsWith("#")&&(b&&this._checkUnique(b),this.refs[b]=z),u&&this.validateSchema(w,!0),z}_checkUnique(w){if(this.schemas[w]||this.refs[w])throw new Error(`schema with key or id "${w}" already exists`)}_compileSchemaEnv(w){if(w.meta?this._compileMetaSchema(w):a.compileSchema.call(this,w),!w.validate)throw new Error("ajv implementation error");return w.validate}_compileMetaSchema(w){const C=this.opts;this.opts=this._metaOpts;try{a.compileSchema.call(this,w)}finally{this.opts=C}}}R.ValidationError=n.default,R.MissingRefError=s.default,e.default=R;function P(N,w,C,b="error"){for(const u in N){const p=u;p in w&&this.logger[b](`${C}: option ${u}. ${N[p]}`)}}function O(N){return N=(0,c.normalizeId)(N),this.schemas[N]||this.refs[N]}function A(){const N=this.opts.schemas;if(N)if(Array.isArray(N))this.addSchema(N);else for(const w in N)this.addSchema(N[w],w)}function L(){for(const N in this.opts.formats){const w=this.opts.formats[N];w&&this.addFormat(N,w)}}function V(N){if(Array.isArray(N)){this.addVocabulary(N);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const w in N){const C=N[w];C.keyword||(C.keyword=w),this.addKeyword(C)}}function D(){const N={...this.opts};for(const w of g)delete N[w];return N}const F={log(){},warn(){},error(){}};function K(N){if(N===!1)return F;if(N===void 0)return console;if(N.log&&N.warn&&N.error)return N;throw new Error("logger must implement log, warn and error methods")}const ce=/^[a-z_$][a-z0-9_$:-]*$/i;function q(N,w){const{RULES:C}=this;if((0,d.eachItem)(N,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(N,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:z})=>z===C);if(E||(E={type:C,rules:[]},p.rules.push(E)),p.keywords[N]=!0,!w)return;const x={keyword:N,definition:{...w,type:(0,l.getJSONTypes)(w.type),schemaType:(0,l.getJSONTypes)(w.schemaType)}};w.before?Ce.call(this,E,x,w.before):E.rules.push(x),p.all[N]=x,(b=w.implements)===null||b===void 0||b.forEach(z=>this.addKeyword(z))}function Ce(N,w,C){const b=N.rules.findIndex(u=>u.keyword===C);b>=0?N.rules.splice(b,0,w):(N.rules.push(w),this.logger.warn(`rule ${C} is not defined`))}function _e(N){let{metaSchema:w}=N;w!==void 0&&(N.$data&&this.opts.$data&&(w=je(w)),N.validateSchema=this.compile(w,!0))}const ct={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function je(N){return{anyOf:[N,ct]}}})($f);var Yi={},Qi={},Xi={};Object.defineProperty(Xi,"__esModule",{value:!0});const EP={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Xi.default=EP;var vr={};Object.defineProperty(vr,"__esModule",{value:!0});vr.callRef=vr.getValidate=void 0;const kP=Kr,Ml=de,Ye=ie,Er=Et,xl=Xe,Jn=Z,PP={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:r,it:n}=e,{baseId:s,schemaEnv:o,validateName:a,opts:i,self:c}=n,{root:l}=o;if((r==="#"||r==="#/")&&s===l.baseId)return f();const d=xl.resolveRef.call(c,l,s,r);if(d===void 0)throw new kP.default(n.opts.uriResolver,s,r);if(d instanceof xl.SchemaEnv)return _(d);return y(d);function f(){if(o===l)return us(e,a,o,o.$async);const g=t.scopeValue("root",{ref:l});return us(e,(0,Ye._)`${g}.validate`,l,l.$async)}function _(g){const $=Xf(e,g);us(e,$,g,g.$async)}function y(g){const $=t.scopeValue("schema",i.code.source===!0?{ref:g,code:(0,Ye.stringify)(g)}:{ref:g}),m=t.name("valid"),h=e.subschema({schema:g,dataTypes:[],schemaPath:Ye.nil,topSchemaRef:$,errSchemaPath:r},m);e.mergeEvaluated(h),e.ok(m)}}};function Xf(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Ye._)`${r.scopeValue("wrapper",{ref:t})}.validate`}vr.getValidate=Xf;function us(e,t,r,n){const{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:c}=o,l=c.passContext?Er.default.this:Ye.nil;n?d():f();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");const g=s.let("valid");s.try(()=>{s.code((0,Ye._)`await ${(0,Ml.callValidateCode)(e,t,l)}`),y(t),a||s.assign(g,!0)},$=>{s.if((0,Ye._)`!(${$} instanceof ${o.ValidationError})`,()=>s.throw($)),_($),a||s.assign(g,!1)}),e.ok(g)}function f(){e.result((0,Ml.callValidateCode)(e,t,l),()=>y(t),()=>_(t))}function _(g){const $=(0,Ye._)`${g}.errors`;s.assign(Er.default.vErrors,(0,Ye._)`${Er.default.vErrors} === null ? ${$} : ${Er.default.vErrors}.concat(${$})`),s.assign(Er.default.errors,(0,Ye._)`${Er.default.vErrors}.length`)}function y(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=Jn.mergeEvaluated.props(s,m.props,o.props));else{const h=s.var("props",(0,Ye._)`${g}.evaluated.props`);o.props=Jn.mergeEvaluated.props(s,h,o.props,Ye.Name)}if(o.items!==!0)if(m&&!m.dynamicItems)m.items!==void 0&&(o.items=Jn.mergeEvaluated.items(s,m.items,o.items));else{const h=s.var("items",(0,Ye._)`${g}.evaluated.items`);o.items=Jn.mergeEvaluated.items(s,h,o.items,Ye.Name)}}}vr.callRef=us;vr.default=PP;Object.defineProperty(Qi,"__esModule",{value:!0});const TP=Xi,RP=vr,CP=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",TP.default,RP.default];Qi.default=CP;var ec={},tc={};Object.defineProperty(tc,"__esModule",{value:!0});const Ts=ie,jt=Ts.operators,Rs={maximum:{okStr:"<=",ok:jt.LTE,fail:jt.GT},minimum:{okStr:">=",ok:jt.GTE,fail:jt.LT},exclusiveMaximum:{okStr:"<",ok:jt.LT,fail:jt.GTE},exclusiveMinimum:{okStr:">",ok:jt.GT,fail:jt.LTE}},IP={message:({keyword:e,schemaCode:t})=>(0,Ts.str)`must be ${Rs[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Ts._)`{comparison: ${Rs[e].okStr}, limit: ${t}}`},NP={keyword:Object.keys(Rs),type:"number",schemaType:"number",$data:!0,error:IP,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,Ts._)`${r} ${Rs[t].fail} ${n} || isNaN(${r})`)}};tc.default=NP;var rc={};Object.defineProperty(rc,"__esModule",{value:!0});const pn=ie,jP={message:({schemaCode:e})=>(0,pn.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,pn._)`{multipleOf: ${e}}`},OP={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:jP,code(e){const{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0,pn._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0,pn._)`${a} !== parseInt(${a})`;e.fail$data((0,pn._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};rc.default=OP;var nc={},sc={};Object.defineProperty(sc,"__esModule",{value:!0});function eh(e){const t=e.length;let r=0,n=0,s;for(;n=55296&&s<=56319&&n(0,dr._)`{limit: ${e}}`},zP={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:AP,code(e){const{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?dr.operators.GT:dr.operators.LT,a=s.opts.unicode===!1?(0,dr._)`${r}.length`:(0,dr._)`${(0,MP.useFunc)(e.gen,xP.default)}(${r})`;e.fail$data((0,dr._)`${a} ${o} ${n}`)}};nc.default=zP;var oc={};Object.defineProperty(oc,"__esModule",{value:!0});const DP=de,qP=Z,Nr=ie,UP={message:({schemaCode:e})=>(0,Nr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Nr._)`{pattern: ${e}}`},FP={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:UP,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,Nr._)`new RegExp`:(0,qP.useFunc)(t,c),d=t.let("valid");t.try(()=>t.assign(d,(0,Nr._)`${l}(${o}, ${i}).test(${r})`),()=>t.assign(d,!1)),e.fail$data((0,Nr._)`!${d}`)}else{const c=(0,DP.usePattern)(e,s);e.fail$data((0,Nr._)`!${c}.test(${r})`)}}};oc.default=FP;var ac={};Object.defineProperty(ac,"__esModule",{value:!0});const mn=ie,VP={message({keyword:e,schemaCode:t}){const r=e==="maxProperties"?"more":"fewer";return(0,mn.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,mn._)`{limit: ${e}}`},LP={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:VP,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?mn.operators.GT:mn.operators.LT;e.fail$data((0,mn._)`Object.keys(${r}).length ${s} ${n}`)}};ac.default=LP;var ic={};Object.defineProperty(ic,"__esModule",{value:!0});const tn=de,gn=ie,HP=Z,ZP={message:({params:{missingProperty:e}})=>(0,gn.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,gn._)`{missingProperty: ${e}}`},KP={keyword:"required",type:"object",schemaType:"array",$data:!0,error:ZP,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 y=e.parentSchema.properties,{definedProperties:g}=e.it;for(const $ of r)if((y==null?void 0:y[$])===void 0&&!g.has($)){const m=a.schemaEnv.baseId+a.errSchemaPath,h=`required property "${$}" is not defined at "${m}" (strictRequired)`;(0,HP.checkStrictMode)(a,h,a.opts.strictRequired)}}function l(){if(c||o)e.block$data(gn.nil,f);else for(const y of r)(0,tn.checkReportMissingProp)(e,y)}function d(){const y=t.let("missing");if(c||o){const g=t.let("valid",!0);e.block$data(g,()=>_(y,g)),e.ok(g)}else t.if((0,tn.checkMissingProp)(e,r,y)),(0,tn.reportMissingProp)(e,y),t.else()}function f(){t.forOf("prop",n,y=>{e.setParams({missingProperty:y}),t.if((0,tn.noPropertyInData)(t,s,y,i.ownProperties),()=>e.error())})}function _(y,g){e.setParams({missingProperty:y}),t.forOf(y,n,()=>{t.assign(g,(0,tn.propertyInData)(t,s,y,i.ownProperties)),t.if((0,gn.not)(g),()=>{e.error(),t.break()})},gn.nil)}}};ic.default=KP;var cc={};Object.defineProperty(cc,"__esModule",{value:!0});const _n=ie,GP={message({keyword:e,schemaCode:t}){const r=e==="maxItems"?"more":"fewer";return(0,_n.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,_n._)`{limit: ${e}}`},WP={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:GP,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?_n.operators.GT:_n.operators.LT;e.fail$data((0,_n._)`${r}.length ${s} ${n}`)}};cc.default=WP;var lc={},Un={};Object.defineProperty(Un,"__esModule",{value:!0});const th=Zs;th.code='require("ajv/dist/runtime/equal").default';Un.default=th;Object.defineProperty(lc,"__esModule",{value:!0});const mo=Me,De=ie,BP=Z,JP=Un,YP={message:({params:{i:e,j:t}})=>(0,De.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,De._)`{i: ${e}, j: ${t}}`},QP={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:YP,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,mo.getSchemaTypes)(o.items):[];e.block$data(c,d,(0,De._)`${a} === false`),e.ok(c);function d(){const g=t.let("i",(0,De._)`${r}.length`),$=t.let("j");e.setParams({i:g,j:$}),t.assign(c,!0),t.if((0,De._)`${g} > 1`,()=>(f()?_:y)(g,$))}function f(){return l.length>0&&!l.some(g=>g==="object"||g==="array")}function _(g,$){const m=t.name("item"),h=(0,mo.checkDataTypes)(l,m,i.opts.strictNumbers,mo.DataType.Wrong),v=t.const("indices",(0,De._)`{}`);t.for((0,De._)`;${g}--;`,()=>{t.let(m,(0,De._)`${r}[${g}]`),t.if(h,(0,De._)`continue`),l.length>1&&t.if((0,De._)`typeof ${m} == "string"`,(0,De._)`${m} += "_"`),t.if((0,De._)`typeof ${v}[${m}] == "number"`,()=>{t.assign($,(0,De._)`${v}[${m}]`),e.error(),t.assign(c,!1).break()}).code((0,De._)`${v}[${m}] = ${g}`)})}function y(g,$){const m=(0,BP.useFunc)(t,JP.default),h=t.name("outer");t.label(h).for((0,De._)`;${g}--;`,()=>t.for((0,De._)`${$} = ${g}; ${$}--;`,()=>t.if((0,De._)`${m}(${r}[${g}], ${r}[${$}])`,()=>{e.error(),t.assign(c,!1).break(h)})))}}};lc.default=QP;var uc={};Object.defineProperty(uc,"__esModule",{value:!0});const Zo=ie,XP=Z,e1=Un,t1={message:"must be equal to constant",params:({schemaCode:e})=>(0,Zo._)`{allowedValue: ${e}}`},r1={keyword:"const",$data:!0,error:t1,code(e){const{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,Zo._)`!${(0,XP.useFunc)(t,e1.default)}(${r}, ${s})`):e.fail((0,Zo._)`${o} !== ${r}`)}};uc.default=r1;var dc={};Object.defineProperty(dc,"__esModule",{value:!0});const on=ie,n1=Z,s1=Un,o1={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,on._)`{allowedValues: ${e}}`},a1={keyword:"enum",schemaType:"array",$data:!0,error:o1,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,n1.useFunc)(t,s1.default));let d;if(i||n)d=t.let("valid"),e.block$data(d,f);else{if(!Array.isArray(s))throw new Error("ajv implementation error");const y=t.const("vSchema",o);d=(0,on.or)(...s.map((g,$)=>_(y,$)))}e.pass(d);function f(){t.assign(d,!1),t.forOf("v",o,y=>t.if((0,on._)`${l()}(${r}, ${y})`,()=>t.assign(d,!0).break()))}function _(y,g){const $=s[g];return typeof $=="object"&&$!==null?(0,on._)`${l()}(${r}, ${y}[${g}])`:(0,on._)`${r} === ${$}`}}};dc.default=a1;Object.defineProperty(ec,"__esModule",{value:!0});const i1=tc,c1=rc,l1=nc,u1=oc,d1=ac,f1=ic,h1=cc,p1=lc,m1=uc,g1=dc,_1=[i1.default,c1.default,l1.default,u1.default,d1.default,f1.default,h1.default,p1.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},m1.default,g1.default];ec.default=_1;var fc={},Gr={};Object.defineProperty(Gr,"__esModule",{value:!0});Gr.validateAdditionalItems=void 0;const fr=ie,Ko=Z,y1={message:({params:{len:e}})=>(0,fr.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,fr._)`{limit: ${e}}`},v1={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:y1,code(e){const{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Ko.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}rh(e,n)}};function rh(e,t){const{gen:r,schema:n,data:s,keyword:o,it:a}=e;a.items=!0;const i=r.const("len",(0,fr._)`${s}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,fr._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0,Ko.alwaysValidSchema)(a,n)){const l=r.var("valid",(0,fr._)`${i} <= ${t.length}`);r.if((0,fr.not)(l),()=>c(l)),e.ok(l)}function c(l){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:Ko.Type.Num},l),a.allErrors||r.if((0,fr.not)(l),()=>r.break())})}}Gr.validateAdditionalItems=rh;Gr.default=v1;var hc={},Wr={};Object.defineProperty(Wr,"__esModule",{value:!0});Wr.validateTuple=void 0;const Al=ie,ds=Z,$1=de,w1={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return nh(e,"additionalItems",t);r.items=!0,!(0,ds.alwaysValidSchema)(r,t)&&e.ok((0,$1.validateArray)(e))}};function nh(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=ds.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),l=n.const("len",(0,Al._)`${o}.length`);r.forEach((f,_)=>{(0,ds.alwaysValidSchema)(i,f)||(n.if((0,Al._)`${l} > ${_}`,()=>e.subschema({keyword:a,schemaProp:_,dataProp:_},c)),e.ok(c))});function d(f){const{opts:_,errSchemaPath:y}=i,g=r.length,$=g===f.minItems&&(g===f.maxItems||f[t]===!1);if(_.strictTuples&&!$){const m=`"${a}" is ${g}-tuple, but minItems or maxItems/${t} are not specified or different at path "${y}"`;(0,ds.checkStrictMode)(i,m,_.strictTuples)}}}Wr.validateTuple=nh;Wr.default=w1;Object.defineProperty(hc,"__esModule",{value:!0});const b1=Wr,S1={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,b1.validateTuple)(e,"items")};hc.default=S1;var pc={};Object.defineProperty(pc,"__esModule",{value:!0});const zl=ie,E1=Z,k1=de,P1=Gr,T1={message:({params:{len:e}})=>(0,zl.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,zl._)`{limit: ${e}}`},R1={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:T1,code(e){const{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=!0,!(0,E1.alwaysValidSchema)(n,t)&&(s?(0,P1.validateAdditionalItems)(e,s):e.ok((0,k1.validateArray)(e)))}};pc.default=R1;var mc={};Object.defineProperty(mc,"__esModule",{value:!0});const ot=ie,Yn=Z,C1={message:({params:{min:e,max:t}})=>t===void 0?(0,ot.str)`must contain at least ${e} valid item(s)`:(0,ot.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,ot._)`{minContains: ${e}}`:(0,ot._)`{minContains: ${e}, maxContains: ${t}}`},I1={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:C1,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,ot._)`${s}.length`);if(e.setParams({min:a,max:i}),i===void 0&&a===0){(0,Yn.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0,Yn.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Yn.alwaysValidSchema)(o,r)){let $=(0,ot._)`${d} >= ${a}`;i!==void 0&&($=(0,ot._)`${$} && ${d} <= ${i}`),e.pass($);return}o.items=!0;const f=t.name("valid");i===void 0&&a===1?y(f,()=>t.if(f,()=>t.break())):a===0?(t.let(f,!0),i!==void 0&&t.if((0,ot._)`${s}.length > 0`,_)):(t.let(f,!1),_()),e.result(f,()=>e.reset());function _(){const $=t.name("_valid"),m=t.let("count",0);y($,()=>t.if($,()=>g(m)))}function y($,m){t.forRange("i",0,d,h=>{e.subschema({keyword:"contains",dataProp:h,dataPropType:Yn.Type.Num,compositeRule:!0},$),m()})}function g($){t.code((0,ot._)`${$}++`),i===void 0?t.if((0,ot._)`${$} >= ${a}`,()=>t.assign(f,!0).break()):(t.if((0,ot._)`${$} > ${i}`,()=>t.assign(f,!1).break()),a===1?t.assign(f,!0):t.if((0,ot._)`${$} >= ${a}`,()=>t.assign(f,!0)))}}};mc.default=I1;var sh={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=ie,r=Z,n=de;e.error={message:({params:{property:c,depsCount:l,deps:d}})=>{const f=l===1?"property":"properties";return(0,t.str)`must have ${f} ${d} when property ${c} is present`},params:({params:{property:c,depsCount:l,deps:d,missingProperty:f}})=>(0,t._)`{property: ${c}, + missingProperty: ${f}, + depsCount: ${l}, + deps: ${d}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(c){const[l,d]=o(c);a(c,l),i(c,d)}};function o({schema:c}){const l={},d={};for(const f in c){if(f==="__proto__")continue;const _=Array.isArray(c[f])?l:d;_[f]=c[f]}return[l,d]}function a(c,l=c.schema){const{gen:d,data:f,it:_}=c;if(Object.keys(l).length===0)return;const y=d.let("missing");for(const g in l){const $=l[g];if($.length===0)continue;const m=(0,n.propertyInData)(d,f,g,_.opts.ownProperties);c.setParams({property:g,depsCount:$.length,deps:$.join(", ")}),_.allErrors?d.if(m,()=>{for(const h of $)(0,n.checkReportMissingProp)(c,h)}):(d.if((0,t._)`${m} && (${(0,n.checkMissingProp)(c,$,y)})`),(0,n.reportMissingProp)(c,y),d.else())}}e.validatePropertyDeps=a;function i(c,l=c.schema){const{gen:d,data:f,keyword:_,it:y}=c,g=d.name("valid");for(const $ in l)(0,r.alwaysValidSchema)(y,l[$])||(d.if((0,n.propertyInData)(d,f,$,y.opts.ownProperties),()=>{const m=c.subschema({keyword:_,schemaProp:$},g);c.mergeValidEvaluated(m,g)},()=>d.var(g,!0)),c.ok(g))}e.validateSchemaDeps=i,e.default=s})(sh);var gc={};Object.defineProperty(gc,"__esModule",{value:!0});const oh=ie,N1=Z,j1={message:"property name must be valid",params:({params:e})=>(0,oh._)`{propertyName: ${e.propertyName}}`},O1={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:j1,code(e){const{gen:t,schema:r,data:n,it:s}=e;if((0,N1.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,oh.not)(o),()=>{e.error(!0),s.allErrors||t.break()})}),e.ok(o)}};gc.default=O1;var eo={};Object.defineProperty(eo,"__esModule",{value:!0});const Qn=de,ht=ie,M1=Et,Xn=Z,x1={message:"must NOT have additional properties",params:({params:e})=>(0,ht._)`{additionalProperty: ${e.additionalProperty}}`},A1={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:x1,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,Xn.alwaysValidSchema)(a,r))return;const l=(0,Qn.allSchemaProperties)(n.properties),d=(0,Qn.allSchemaProperties)(n.patternProperties);f(),e.ok((0,ht._)`${o} === ${M1.default.errors}`);function f(){t.forIn("key",s,m=>{!l.length&&!d.length?g(m):t.if(_(m),()=>g(m))})}function _(m){let h;if(l.length>8){const v=(0,Xn.schemaRefOrVal)(a,n.properties,"properties");h=(0,Qn.isOwnProperty)(t,v,m)}else l.length?h=(0,ht.or)(...l.map(v=>(0,ht._)`${m} === ${v}`)):h=ht.nil;return d.length&&(h=(0,ht.or)(h,...d.map(v=>(0,ht._)`${(0,Qn.usePattern)(e,v)}.test(${m})`))),(0,ht.not)(h)}function y(m){t.code((0,ht._)`delete ${s}[${m}]`)}function g(m){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){y(m);return}if(r===!1){e.setParams({additionalProperty:m}),e.error(),i||t.break();return}if(typeof r=="object"&&!(0,Xn.alwaysValidSchema)(a,r)){const h=t.name("valid");c.removeAdditional==="failing"?($(m,h,!1),t.if((0,ht.not)(h),()=>{e.reset(),y(m)})):($(m,h),i||t.if((0,ht.not)(h),()=>t.break()))}}function $(m,h,v){const S={keyword:"additionalProperties",dataProp:m,dataPropType:Xn.Type.Str};v===!1&&Object.assign(S,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(S,h)}}};eo.default=A1;var _c={};Object.defineProperty(_c,"__esModule",{value:!0});const z1=_t,Dl=de,go=Z,ql=eo,D1={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&&ql.default.code(new z1.KeywordCxt(o,ql.default,"additionalProperties"));const a=(0,Dl.allSchemaProperties)(r);for(const f of a)o.definedProperties.add(f);o.opts.unevaluated&&a.length&&o.props!==!0&&(o.props=go.mergeEvaluated.props(t,(0,go.toHash)(a),o.props));const i=a.filter(f=>!(0,go.alwaysValidSchema)(o,r[f]));if(i.length===0)return;const c=t.name("valid");for(const f of i)l(f)?d(f):(t.if((0,Dl.propertyInData)(t,s,f,o.opts.ownProperties)),d(f),o.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(f),e.ok(c);function l(f){return o.opts.useDefaults&&!o.compositeRule&&r[f].default!==void 0}function d(f){e.subschema({keyword:"properties",schemaProp:f,dataProp:f},c)}}};_c.default=D1;var yc={};Object.defineProperty(yc,"__esModule",{value:!0});const Ul=de,es=ie,Fl=Z,Vl=Z,q1={keyword:"patternProperties",type:"object",schemaType:"object",code(e){const{gen:t,schema:r,data:n,parentSchema:s,it:o}=e,{opts:a}=o,i=(0,Ul.allSchemaProperties)(r),c=i.filter($=>(0,Fl.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 es.Name)&&(o.props=(0,Vl.evaluatedPropsToName)(t,o.props));const{props:f}=o;_();function _(){for(const $ of i)l&&y($),o.allErrors?g($):(t.var(d,!0),g($),t.if(d))}function y($){for(const m in l)new RegExp($).test(m)&&(0,Fl.checkStrictMode)(o,`property ${m} matches pattern ${$} (use allowMatchingProperties)`)}function g($){t.forIn("key",n,m=>{t.if((0,es._)`${(0,Ul.usePattern)(e,$)}.test(${m})`,()=>{const h=c.includes($);h||e.subschema({keyword:"patternProperties",schemaProp:$,dataProp:m,dataPropType:Vl.Type.Str},d),o.opts.unevaluated&&f!==!0?t.assign((0,es._)`${f}[${m}]`,!0):!h&&!o.allErrors&&t.if((0,es.not)(d),()=>t.break())})})}}};yc.default=q1;var vc={};Object.defineProperty(vc,"__esModule",{value:!0});const U1=Z,F1={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,U1.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"}};vc.default=F1;var $c={};Object.defineProperty($c,"__esModule",{value:!0});const V1=de,L1={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:V1.validateUnion,error:{message:"must match a schema in anyOf"}};$c.default=L1;var wc={};Object.defineProperty(wc,"__esModule",{value:!0});const fs=ie,H1=Z,Z1={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,fs._)`{passingSchemas: ${e.passing}}`},K1={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:Z1,code(e){const{gen:t,schema:r,parentSchema:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;const o=r,a=t.let("valid",!1),i=t.let("passing",null),c=t.name("_valid");e.setParams({passing:i}),t.block(l),e.result(a,()=>e.reset(),()=>e.error(!0));function l(){o.forEach((d,f)=>{let _;(0,H1.alwaysValidSchema)(s,d)?t.var(c,!0):_=e.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},c),f>0&&t.if((0,fs._)`${c} && ${a}`).assign(a,!1).assign(i,(0,fs._)`[${i}, ${f}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,f),_&&e.mergeEvaluated(_,fs.Name)})})}}};wc.default=K1;var bc={};Object.defineProperty(bc,"__esModule",{value:!0});const G1=Z,W1={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,G1.alwaysValidSchema)(n,o))return;const i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i)})}};bc.default=W1;var Sc={};Object.defineProperty(Sc,"__esModule",{value:!0});const Cs=ie,ah=Z,B1={message:({params:e})=>(0,Cs.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,Cs._)`{failingKeyword: ${e.ifClause}}`},J1={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:B1,code(e){const{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,ah.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const s=Ll(n,"then"),o=Ll(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,Cs.not)(i),l("else"));e.pass(a,()=>e.error(!0));function c(){const d=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},i);e.mergeEvaluated(d)}function l(d,f){return()=>{const _=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(_,a),f?t.assign(f,(0,Cs._)`${d}`):e.setParams({ifClause:d})}}}};function Ll(e,t){const r=e.schema[t];return r!==void 0&&!(0,ah.alwaysValidSchema)(e,r)}Sc.default=J1;var Ec={};Object.defineProperty(Ec,"__esModule",{value:!0});const Y1=Z,Q1={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,Y1.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Ec.default=Q1;Object.defineProperty(fc,"__esModule",{value:!0});const X1=Gr,eT=hc,tT=Wr,rT=pc,nT=mc,sT=sh,oT=gc,aT=eo,iT=_c,cT=yc,lT=vc,uT=$c,dT=wc,fT=bc,hT=Sc,pT=Ec;function mT(e=!1){const t=[lT.default,uT.default,dT.default,fT.default,hT.default,pT.default,oT.default,aT.default,sT.default,iT.default,cT.default];return e?t.push(eT.default,rT.default):t.push(X1.default,tT.default),t.push(nT.default),t}fc.default=mT;var kc={},Pc={};Object.defineProperty(Pc,"__esModule",{value:!0});const Ne=ie,gT={message:({schemaCode:e})=>(0,Ne.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,Ne._)`{format: ${e}}`},_T={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:gT,code(e,t){const{gen:r,data:n,$data:s,schema:o,schemaCode:a,it:i}=e,{opts:c,errSchemaPath:l,schemaEnv:d,self:f}=i;if(!c.validateFormats)return;s?_():y();function _(){const g=r.scopeValue("formats",{ref:f.formats,code:c.code.formats}),$=r.const("fDef",(0,Ne._)`${g}[${a}]`),m=r.let("fType"),h=r.let("format");r.if((0,Ne._)`typeof ${$} == "object" && !(${$} instanceof RegExp)`,()=>r.assign(m,(0,Ne._)`${$}.type || "string"`).assign(h,(0,Ne._)`${$}.validate`),()=>r.assign(m,(0,Ne._)`"string"`).assign(h,$)),e.fail$data((0,Ne.or)(v(),S()));function v(){return c.strictSchema===!1?Ne.nil:(0,Ne._)`${a} && !${h}`}function S(){const R=d.$async?(0,Ne._)`(${$}.async ? await ${h}(${n}) : ${h}(${n}))`:(0,Ne._)`${h}(${n})`,P=(0,Ne._)`(typeof ${h} == "function" ? ${R} : ${h}.test(${n}))`;return(0,Ne._)`${h} && ${h} !== true && ${m} === ${t} && !${P}`}}function y(){const g=f.formats[o];if(!g){v();return}if(g===!0)return;const[$,m,h]=S(g);$===t&&e.pass(R());function v(){if(c.strictSchema===!1){f.logger.warn(P());return}throw new Error(P());function P(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function S(P){const O=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:O});return typeof P=="object"&&!(P instanceof RegExp)?[P.type||"string",P.validate,(0,Ne._)`${A}.validate`]:["string",P,A]}function R(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!d.$async)throw new Error("async format in sync schema");return(0,Ne._)`await ${h}(${n})`}return typeof m=="function"?(0,Ne._)`${h}(${n})`:(0,Ne._)`${h}.test(${n})`}}}};Pc.default=_T;Object.defineProperty(kc,"__esModule",{value:!0});const yT=Pc,vT=[yT.default];kc.default=vT;var Ur={};Object.defineProperty(Ur,"__esModule",{value:!0});Ur.contentVocabulary=Ur.metadataVocabulary=void 0;Ur.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Ur.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(Yi,"__esModule",{value:!0});const $T=Qi,wT=ec,bT=fc,ST=kc,Hl=Ur,ET=[$T.default,wT.default,(0,bT.default)(),ST.default,Hl.metadataVocabulary,Hl.contentVocabulary];Yi.default=ET;var Tc={},to={};Object.defineProperty(to,"__esModule",{value:!0});to.DiscrError=void 0;var Zl;(function(e){e.Tag="tag",e.Mapping="mapping"})(Zl||(to.DiscrError=Zl={}));Object.defineProperty(Tc,"__esModule",{value:!0});const Rr=ie,Go=to,Kl=Xe,kT=Kr,PT=Z,TT={message:({params:{discrError:e,tagName:t}})=>e===Go.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Rr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},RT={keyword:"discriminator",type:"object",schemaType:"object",error:TT,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,Rr._)`${r}${(0,Rr.getProperty)(i)}`);t.if((0,Rr._)`typeof ${l} == "string"`,()=>d(),()=>e.error(!1,{discrError:Go.DiscrError.Tag,tag:l,tagName:i})),e.ok(c);function d(){const y=_();t.if(!1);for(const g in y)t.elseIf((0,Rr._)`${l} === ${g}`),t.assign(c,f(y[g]));t.else(),e.error(!1,{discrError:Go.DiscrError.Mapping,tag:l,tagName:i}),t.endIf()}function f(y){const g=t.name("valid"),$=e.subschema({keyword:"oneOf",schemaProp:y},g);return e.mergeEvaluated($,Rr.Name),g}function _(){var y;const g={},$=h(s);let m=!0;for(let R=0;Rthis.addVocabulary(g)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const g=this.opts.$data?this.$dataMetaSchema(o,a):o;this.addMetaSchema(g,i,!1),this.refs["http://json-schema.org/schema"]=i}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(i)?i:void 0)}}t.Ajv=c,e.exports=t=c,e.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var l=_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 f=qn;Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return f.default}});var _=Kr;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return _.default}})})(Uo,Uo.exports);var AT=Uo.exports;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;const t=AT,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:f,it:_}=i,{opts:y,self:g}=_;if(!y.validateFormats)return;const $=new t.KeywordCxt(_,g.RULES.all.format.definition,"format");$.$data?m():h();function m(){const S=c.scopeValue("formats",{ref:g.formats,code:y.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 h(){const S=$.schema,R=g.formats[S];if(!R||R===!0)return;if(typeof R!="object"||R instanceof RegExp||typeof R.compare!="function")throw new Error(`"${f}": format "${S}" does not define "compare" function`);const P=c.scopeValue("formats",{key:S,ref:R,code:y.code.formats?(0,r._)`${y.code.formats}${(0,r.getProperty)(S)}`:void 0});i.fail$data(v(P))}function v(S){return(0,r._)`${S}.compare(${l}, ${d}) ${s[f].fail} 0`}},dependencies:["format"]};const a=i=>(i.addKeyword(e.formatLimitDefinition),i);e.default=a})(vf);(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r=yf,n=vf,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[f,_]=d.mode==="fast"?[r.fastFormats,a]:[r.fullFormats,o],y=d.formats||r.formatNames;return c(l,y,f,_),d.keywords&&(0,n.default)(l),l};i.get=(l,d="full")=>{const _=(d==="fast"?r.fastFormats:r.fullFormats)[l];if(!_)throw new Error(`Unknown format "${l}"`);return _};function c(l,d,f,_){var y,g;(y=(g=l.opts.code).formats)!==null&&y!==void 0||(g.formats=(0,s._)`require("ajv-formats/dist/formats").${_}`);for(const $ of d)l.addFormat($,f[$])}e.exports=t=i,Object.defineProperty(t,"__esModule",{value:!0}),t.default=i})(qo,qo.exports);var zT=qo.exports;const DT=eu(zT);function qT(){const e=new EE({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return DT(e),e}class UT{constructor(t){this._ajv=t??qT()}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 FT{constructor(t){this._client=t}async*callToolStream(t,r=pr,n){const s=this._client,o={...n,task:(n==null?void 0:n.task)??(s.isToolTask(t.name)?{}:void 0)},a=s.requestStream({method:"tools/call",params:t},r,o),i=s.getToolOutputValidator(t.name);for await(const c of a){if(c.type==="result"&&i){const l=c.result;if(!l.structuredContent&&!l.isError){yield{type:"error",error:new X(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 X(re.InvalidParams,`Structured content does not match the tool's output schema: ${d.errorMessage}`)};return}}catch(d){if(d instanceof X){yield{type:"error",error:d};return}yield{type:"error",error:new X(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 VT(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 LT(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 hs(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&&hs(o,r[s])}}if(Array.isArray(e.anyOf))for(const r of e.anyOf)typeof r!="boolean"&&hs(r,t);if(Array.isArray(e.oneOf))for(const r of e.oneOf)typeof r!="boolean"&&hs(r,t)}}function HT(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 ZT extends dd{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 UT,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",Ha,t.tools,async()=>(await this.listTools()).tools),t.prompts&&((o=(s=this._serverCapabilities)==null?void 0:s.prompts)!=null&&o.listChanged)&&this._setupListChangedHandler("prompts",Fa,t.prompts,async()=>(await this.listPrompts()).prompts),t.resources&&((i=(a=this._serverCapabilities)==null?void 0:a.resources)!=null&&i.listChanged)&&this._setupListChangedHandler("resources",Aa,t.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new FT(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=zv(this._capabilities,t)}setRequestHandler(t,r){const n=ld(t),s=n==null?void 0:n.method;if(!s)throw new Error("Schema is missing a method literal");const o=ud(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=Ot(ad,c);if(!d.success){const R=d.error instanceof Error?d.error.message:String(d.error);throw new X(re.InvalidParams,`Invalid elicitation request: ${R}`)}const{params:f}=d.data;f.mode=f.mode??"form";const{supportsFormMode:_,supportsUrlMode:y}=HT(this._capabilities.elicitation);if(f.mode==="form"&&!_)throw new X(re.InvalidParams,"Client does not support form-mode elicitation requests");if(f.mode==="url"&&!y)throw new X(re.InvalidParams,"Client does not support URL-mode elicitation requests");const g=await Promise.resolve(r(c,l));if(f.task){const R=Ot($n,g);if(!R.success){const P=R.error instanceof Error?R.error.message:String(R.error);throw new X(re.InvalidParams,`Invalid task creation result: ${P}`)}return R.data}const $=Ot(id,g);if(!$.success){const R=$.error instanceof Error?$.error.message:String($.error);throw new X(re.InvalidParams,`Invalid elicitation result: ${R}`)}const m=$.data,h=f.mode==="form"?f.requestedSchema:void 0;if(f.mode==="form"&&m.action==="accept"&&m.content&&h&&(S=(v=this._capabilities.elicitation)==null?void 0:v.form)!=null&&S.applyDefaults)try{hs(h,m.content)}catch{}return m};return super.setRequestHandler(t,i)}if(a==="sampling/createMessage"){const i=async(c,l)=>{const d=Ot(Za,c);if(!d.success){const m=d.error instanceof Error?d.error.message:String(d.error);throw new X(re.InvalidParams,`Invalid sampling request: ${m}`)}const{params:f}=d.data,_=await Promise.resolve(r(c,l));if(f.task){const m=Ot($n,_);if(!m.success){const h=m.error instanceof Error?m.error.message:String(m.error);throw new X(re.InvalidParams,`Invalid task creation result: ${h}`)}return m.data}const g=f.tools||f.toolChoice?od:sd,$=Ot(g,_);if(!$.success){const m=$.error instanceof Error?$.error.message:String($.error);throw new X(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:qs,capabilities:this._capabilities,clientInfo:this._clientInfo}},Vu,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!fy.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;VT((n=(r=this._serverCapabilities)==null?void 0:r.tasks)==null?void 0:n.requests,t,"Server")}assertTaskHandlerCapability(t){var r;this._capabilities&<((r=this._capabilities.tasks)==null?void 0:r.requests,t,"Client")}async ping(t){return this.request({method:"ping"},Cr,t)}async complete(t,r){return this.request({method:"completion/complete",params:t},cd,r)}async setLoggingLevel(t,r){return this.request({method:"logging/setLevel",params:{level:t}},Cr,r)}async getPrompt(t,r){return this.request({method:"prompts/get",params:t},ed,r)}async listPrompts(t,r){return this.request({method:"prompts/list",params:t},za,r)}async listResources(t,r){return this.request({method:"resources/list",params:t},ja,r)}async listResourceTemplates(t,r){return this.request({method:"resources/templates/list",params:t},Oa,r)}async readResource(t,r){return this.request({method:"resources/read",params:t},xa,r)}async subscribeResource(t,r){return this.request({method:"resources/subscribe",params:t},Cr,r)}async unsubscribeResource(t,r){return this.request({method:"resources/unsubscribe",params:t},Cr,r)}async callTool(t,r=pr,n){if(this.isToolTaskRequired(t.name))throw new X(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 X(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 X(re.InvalidParams,`Structured content does not match the tool's output schema: ${a.errorMessage}`)}catch(a){throw a instanceof X?a:new X(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},La,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(t,r,n,s){const o=Xy.safeParse(n);if(!o.success)throw new Error(`Invalid ${t} listChanged options: ${o.error.message}`);if(typeof n.onChanged!="function")throw new Error(`Invalid ${t} listChanged options: onChanged must be a function`);const{autoRefresh:a,debounceMs:i}=o.data,{onChanged:c}=n,l=async()=>{if(!a){c(null,null);return}try{const f=await s();c(null,f)}catch(f){const _=f instanceof Error?f:new Error(String(f));c(_,null)}},d=()=>{if(i){const f=this._listChangedDebounceTimers.get(t);f&&clearTimeout(f);const _=setTimeout(l,i);this._listChangedDebounceTimers.set(t,_)}else l()};this.setNotificationHandler(r,d)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}var Rc={};/*! + * content-type + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */var Gl=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,KT=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,ih=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,GT=/\\([\u000b\u0020-\u00ff])/g,WT=/([\\"])/g,ch=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;Rc.format=BT;Rc.parse=JT;function BT(e){if(!e||typeof e!="object")throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!ch.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&&!KT.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(WT,"\\$1")+'"'}function XT(e){this.parameters=Object.create(null),this.type=e}function eR(e){if(e)try{return Rc.parse(e).type}catch{const t=(e.split(";",1)[0]??"").trim().toLowerCase();return t===""||e.slice(t.length).includes(",")?void 0:t}}function Wo(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function tR(e=fetch,t){return t?async(r,n)=>{const s={...t,...n,headers:n!=null&&n.headers?{...Wo(t.headers),...Wo(n.headers)}:t.headers};return e(r,s)}:e}let Cc;Cc=globalThis.crypto;async function rR(e){return(await Cc).getRandomValues(new Uint8Array(e))}async function nR(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 sR(e),r=await oR(t);return{code_verifier:t,code_challenge:r}}const qe=v_().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:uy.custom,message:"URL must be parseable",fatal:!0}),ip}).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"}),iR=Ve({resource:k().url(),authorization_servers:U(qe).optional(),jwks_uri:k().url().optional(),scopes_supported:U(k()).optional(),bearer_methods_supported:U(k()).optional(),resource_signing_alg_values_supported:U(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:U(k()).optional(),dpop_signing_alg_values_supported:U(k()).optional(),dpop_bound_access_tokens_required:me().optional()}),lh=Ve({issuer:k(),authorization_endpoint:qe,token_endpoint:qe,registration_endpoint:qe.optional(),scopes_supported:U(k()).optional(),response_types_supported:U(k()),response_modes_supported:U(k()).optional(),grant_types_supported:U(k()).optional(),token_endpoint_auth_methods_supported:U(k()).optional(),token_endpoint_auth_signing_alg_values_supported:U(k()).optional(),service_documentation:qe.optional(),revocation_endpoint:qe.optional(),revocation_endpoint_auth_methods_supported:U(k()).optional(),revocation_endpoint_auth_signing_alg_values_supported:U(k()).optional(),introspection_endpoint:k().optional(),introspection_endpoint_auth_methods_supported:U(k()).optional(),introspection_endpoint_auth_signing_alg_values_supported:U(k()).optional(),code_challenge_methods_supported:U(k()).optional(),client_id_metadata_document_supported:me().optional()}),cR=Ve({issuer:k(),authorization_endpoint:qe,token_endpoint:qe,userinfo_endpoint:qe.optional(),jwks_uri:qe,registration_endpoint:qe.optional(),scopes_supported:U(k()).optional(),response_types_supported:U(k()),response_modes_supported:U(k()).optional(),grant_types_supported:U(k()).optional(),acr_values_supported:U(k()).optional(),subject_types_supported:U(k()),id_token_signing_alg_values_supported:U(k()),id_token_encryption_alg_values_supported:U(k()).optional(),id_token_encryption_enc_values_supported:U(k()).optional(),userinfo_signing_alg_values_supported:U(k()).optional(),userinfo_encryption_alg_values_supported:U(k()).optional(),userinfo_encryption_enc_values_supported:U(k()).optional(),request_object_signing_alg_values_supported:U(k()).optional(),request_object_encryption_alg_values_supported:U(k()).optional(),request_object_encryption_enc_values_supported:U(k()).optional(),token_endpoint_auth_methods_supported:U(k()).optional(),token_endpoint_auth_signing_alg_values_supported:U(k()).optional(),display_values_supported:U(k()).optional(),claim_types_supported:U(k()).optional(),claims_supported:U(k()).optional(),service_documentation:k().optional(),claims_locales_supported:U(k()).optional(),ui_locales_supported:U(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:qe.optional(),op_tos_uri:qe.optional(),client_id_metadata_document_supported:me().optional()}),lR=j({...cR.shape,...lh.pick({code_challenge_methods_supported:!0}).shape}),uR=j({access_token:k(),id_token:k().optional(),token_type:k(),expires_in:dy().optional(),scope:k().optional(),refresh_token:k().optional()}).strip(),dR=j({error:k(),error_description:k().optional(),error_uri:k().optional()}),Wl=qe.optional().or(I("").transform(()=>{})),fR=j({redirect_uris:U(qe),token_endpoint_auth_method:k().optional(),grant_types:U(k()).optional(),response_types:U(k()).optional(),client_name:k().optional(),client_uri:qe.optional(),logo_uri:Wl,scope:k().optional(),contacts:U(k()).optional(),tos_uri:Wl,policy_uri:k().optional(),jwks_uri:qe.optional(),jwks:ya().optional(),software_id:k().optional(),software_version:k().optional(),software_statement:k().optional()}).strip(),hR=j({client_id:k(),client_secret:k().optional(),client_id_issued_at:ae().optional(),client_secret_expires_at:ae().optional()}).strip(),pR=fR.merge(hR);j({error:k(),error_description:k().optional()}).strip();j({token:k(),token_type_hint:k().optional()}).strip();function mR(e){const t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function gR({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 RR(e,t,r,n){const s=new URL(e),o=(n==null?void 0:n.protocolVersion)??qs;let a;if(n!=null&&n.metadataUrl)a=new URL(n.metadataUrl);else{const c=PR(t,s.pathname);a=new URL(c,(n==null?void 0:n.metadataServerUrl)??s),a.search=s.search}let i=await Jl(a,o,r);if(!(n!=null&&n.metadataUrl)&&TR(i,s.pathname)){const c=new URL(`/.well-known/${t}`,s);i=await Jl(c,o,r)}return i}function CR(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 fh(e,{fetchFn:t=fetch,protocolVersion:r=qs}={}){var o;const n={"MCP-Protocol-Version":r,Accept:"application/json"},s=CR(e);for(const{url:a,type:i}of s){const c=await Ic(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"?lh.parse(await c.json()):lR.parse(await c.json())}}}async function IR(e,t){let r,n;try{r=await dh(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 fh(n,{fetchFn:t==null?void 0:t.fetchFn});return{authorizationServerUrl:n,authorizationServerMetadata:s,resourceMetadata:r}}async function NR(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(_o))throw new Error(`Incompatible auth server: does not support response type ${_o}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(yo))throw new Error(`Incompatible auth server: does not support code challenge method ${yo}`)}else i=new URL("/authorize",e);const c=await aR(),l=c.code_verifier,d=c.code_challenge;return i.searchParams.set("response_type",_o),i.searchParams.set("client_id",r.client_id),i.searchParams.set("code_challenge",d),i.searchParams.set("code_challenge_method",yo),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 jR(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}async function hh(e,{metadata:t,tokenRequestParams:r,clientInformation:n,addClientAuthentication:s,resource:o,fetchFn:a}){const i=t!=null&&t.token_endpoint?new URL(t.token_endpoint):new URL("/token",e),c=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(o&&r.set("resource",o.href),s)await s(c,r,i,t);else if(n){const d=(t==null?void 0:t.token_endpoint_auth_methods_supported)??[],f=vR(n,d);$R(f,n,c,r)}const l=await(a??fetch)(i,{method:"POST",headers:c,body:r});if(!l.ok)throw await uh(l);return uR.parse(await l.json())}async function OR(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 hh(e,{metadata:t,tokenRequestParams:i,clientInformation:r,addClientAuthentication:o,resource:s,fetchFn:a});return{refresh_token:n,...c}}async function MR(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=jR(s,l,e.redirectUrl)}const c=await e.clientInformation();return hh(t,{metadata:r,tokenRequestParams:i,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:n,fetchFn:o})}async function xR(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 uh(a);return pR.parse(await a.json())}class wo 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 Yl=10,AR=13,or=32;function bo(e){}function zR(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=bo,onError:r=bo,onRetry:n=bo,onComment:s,maxBufferSize:o}=e,a=[];let i=0,c=!0,l,d="",f=0,_,y=!1;function g(P){if(y)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 L=m(P);L!==""&&(a.push(L),i=L.length),$();return}if(P.indexOf(` +`)===-1&&P.indexOf("\r")===-1){a.push(P),i+=P.length,$();return}a.push(P);const O=a.join("");a.length=0,i=0;const A=m(O);A!==""&&(a.push(A),i=A.length),$()}function $(){o!==void 0&&(i+d.length<=o||(y=!0,a.length=0,i=0,l=void 0,d="",f=0,_=void 0,r(new wo(`Buffered data exceeded max buffer size of ${o} characters`,{type:"max-buffer-size-exceeded"}))))}function m(P){let O=0;if(P.indexOf("\r")===-1){let A=P.indexOf(` +`,O);for(;A!==-1;){if(O===A){f>0&&t({id:l,event:_,data:d}),l=void 0,d="",f=0,_=void 0,O=A+1,A=P.indexOf(` +`,O);continue}const L=P.charCodeAt(O);if(Ql(P,O,L)){const V=P.charCodeAt(O+5)===or?O+6:O+5,D=P.slice(V,A);if(f===0&&P.charCodeAt(A+1)===Yl){t({id:l,event:_,data:D}),l=void 0,d="",_=void 0,O=A+2,A=P.indexOf(` +`,O);continue}d=f===0?D:`${d} +${D}`,f++}else Xl(P,O,L)?_=P.slice(P.charCodeAt(O+6)===or?O+7:O+6,A)||void 0:h(P,O,A);O=A+1,A=P.indexOf(` +`,O)}return P.slice(O)}for(;O20?`${P.slice(0,20)}…`:P}"`,{type:"unknown-field",field:P,value:O,line:A}));break}}function S(){f>0&&t({id:l,event:_,data:d}),l=void 0,d="",f=0,_=void 0}function R(P={}){if(P.consume&&a.length>0){const O=a.join("");h(O,0,O.length)}c=!0,l=void 0,d="",f=0,_=void 0,a.length=0,i=0,y=!1}return{feed:g,reset:R}}function Ql(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 Xl(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 DR extends TransformStream{constructor({onError:t,onRetry:r,onComment:n,maxBufferSize:s}={}){let o;super({start(a){o=zR({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 qR={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Pr extends Error{constructor(t,r){super(`Streamable HTTP error: ${r}`),this.code=t}}class UR{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=tR(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)??qR}async _authThenStart(){var r;if(!this._authProvider)throw new kr("No auth provider");let t;try{t=await ts(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 kr;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=Wo((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 Pr(i.status,`Failed to open SSE stream: ${i.statusText}`)}this._handleSseStream(i.body,t,!0)}catch(a){throw(o=this.onerror)==null||o.call(this,a),a}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const r=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,s=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(n,t),s)}_scheduleReconnection(t,r=0){var o;const n=this._reconnectionOptions.maxRetries;if(r>=n){(o=this.onerror)==null||o.call(this,new Error(`Maximum reconnection attempts (${n}) exceeded.`));return}const s=this._getNextReconnectionDelay(r);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(a=>{var i;(i=this.onerror)==null||i.call(this,new Error(`Failed to reconnect SSE stream: ${a instanceof Error?a.message:String(a)}`)),this._scheduleReconnection(t,r+1)})},s)}_handleSseStream(t,r,n){if(!t)return;const{onresumptiontoken:s,replayMessageId:o}=r;let a,i=!1,c=!1;(async()=>{var d,f,_,y;try{const g=t.pipeThrough(new TextDecoderStream).pipeThrough(new DR({onRetry:h=>{this._serverRetryMs=h}})).getReader();for(;;){const{value:h,done:v}=await g.read();if(v)break;if(h.id&&(a=h.id,i=!0,s==null||s(h.id)),!!h.data&&(!h.event||h.event==="message"))try{const S=rs.parse(JSON.parse(h.data));rn(S)&&(c=!0,o!==void 0&&(S.id=o)),(d=this.onmessage)==null||d.call(this,S)}catch(S){(f=this.onerror)==null||f.call(this,S)}}(n||i)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:a,onresumptiontoken:s,replayMessageId:o},0)}catch(g){if((_=this.onerror)==null||_.call(this,new Error(`SSE stream disconnected: ${g}`)),(n||i)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:a,onresumptiontoken:s,replayMessageId:o},0)}catch(h){(y=this.onerror)==null||y.call(this,new Error(`Failed to reconnect: ${h instanceof Error?h.message:String(h)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(t){if(!this._authProvider)throw new kr("No auth provider");if(await ts(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new kr("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:Co(t)?t.id:void 0}).catch(S=>{var R;return(R=this.onerror)==null?void 0:R.call(this,S)});return}const f=await this._commonHeaders();f.set("content-type","application/json"),f.set("accept","application/json, text/event-stream");const _={...this._requestInit,method:"POST",headers:f,body:JSON.stringify(t),signal:(n=this._abortController)==null?void 0:n.signal},y=await(this._fetch??fetch)(this._url,_),g=y.headers.get("mcp-session-id");if(g&&(this._sessionId=g),!y.ok){const S=await y.text().catch(()=>null);if(y.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Pr(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:R,scope:P}=Bl(y);if(this._resourceMetadataUrl=R,this._scope=P,await ts(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new kr;return this._hasCompletedAuthFlow=!0,this.send(t)}if(y.status===403&&this._authProvider){const{resourceMetadataUrl:R,scope:P,error:O}=Bl(y);if(O==="insufficient_scope"){const A=y.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===A)throw new Pr(403,"Server returned 403 after trying upscoping");if(P&&(this._scope=P),R&&(this._resourceMetadataUrl=R),this._lastUpscopingHeader=A??void 0,await ts(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new kr;return this.send(t)}}throw new Pr(y.status,`Error POSTing to endpoint: ${S}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,y.status===202){await((s=y.body)==null?void 0:s.cancel()),Ry(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,h=y.headers.get("content-type"),v=eR(h);if(m)if(v==="text/event-stream")this._handleSseStream(y.body,{onresumptiontoken:d},!1);else if(v==="application/json"){const S=await y.json(),R=Array.isArray(S)?S.map(P=>rs.parse(P)):[rs.parse(S)];for(const P of R)(o=this.onmessage)==null||o.call(this,P)}else throw await((a=y.body)==null?void 0:a.cancel()),new Pr(-1,`Unexpected content type: ${h}`);else await((i=y.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 Pr(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 FR="https://mcp.excalidraw.com/mcp",VR="mcp.excalidraw.com",LR="/api/v1/chat/mcp-apps/excalidraw",ph="ui://excalidraw/mcp-app.html",HR=["read_me","create_view"],mh=new Set(["export_to_excalidraw","save_checkpoint","read_checkpoint"]),ZR=256*1024,KR=1024*1024,GR=1024*1024,WR=240,BR=720,JR=525;function YR(e){return!Number.isFinite(e)||e<=0?JR:Math.max(WR,Math.min(BR,Math.round(e*3/4)))}const QR={excalidraw:{id:"excalidraw",endpoint:FR,hostname:VR,resourceUri:ph,modelTools:HR,appTools:mh}};function XR(e){return QR[e]}function eC(){return new URL($h(LR),window.location.origin)}class tC{constructor(){ne(this,"client",new ZT({name:"pwc-chat-mcp-app-host",version:"1"}));ne(this,"transport",new UR(eC(),{requestInit:{credentials:"include"}}));ne(this,"connected");ne(this,"bytes",0);ne(this,"closed",!1)}connect(){return this.closed?Promise.reject(new Error("App host client is closed")):(this.connected||(this.connected=this.client.connect(this.transport).then(()=>{},t=>{throw this.connected=void 0,this.retire(),t})),this.connected)}async readResource(t){if(t!==ph)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,GR);const s=await oC(n.text);return{text:n.text,digest:s}}async callTool(t,r){if(!mh.has(t))throw new Error("Unapproved App tool");const n=JSON.stringify(r);this.consume(n);try{await this.connect();const s=await this.client.callTool({name:t,arguments:r});return this.consume(JSON.stringify(s)),s}catch(s){throw this.retire(),s}}close(){this.closed=!0,this.connected=void 0,this.transport.close()}retire(){this.close(),At===this&&(At=void 0)}consume(t,r=ZR){const n=new TextEncoder().encode(t).byteLength;if(n>r||this.bytes+n>KR)throw new Error("App request exceeds host limit");this.bytes+=n}}let At;function rC(){return At??(At=new tC),At}function nC(){At==null||At.close(),At=void 0}function sC(e){nC()}async function oC(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 aC=({block:e})=>{const t=Q.useRef(null),r=Q.useRef(null),n=Q.useRef(!1),s=Q.useRef(e),o=Q.useRef(!1);s.current=e;const[a,i]=Q.useState(),[c,l]=Q.useState(e.status),[d,f]=Q.useState(e.height),[_,y]=Q.useState(!1),[g,$]=Q.useState(0),[m,h]=Q.useState(!1),v=Q.useRef(null),S=e.input.elements,R=!!e.permissions.clipboardWrite;o.current=_;const P=Q.useCallback(()=>{y(!1),document.fullscreenElement&&document.exitFullscreen()},[]),O=Q.useCallback(()=>{var V,D;if(_){P();return}y(!0),(D=(V=v.current)==null?void 0:V.requestFullscreen)==null||D.call(V).catch(()=>{})},[P,_]),A=Q.useCallback(()=>{sC(),i(void 0),h(!1),$(V=>V+1)},[]);Q.useEffect(()=>{const V=v.current;if(!V)return;const D=()=>{o.current||f(YR(V.clientWidth))};D();const F=new ResizeObserver(D);return F.observe(V),()=>F.disconnect()},[]),Q.useEffect(()=>{if(!_)return;const V=v.current,D=K=>{K.key==="Escape"&&(document.fullscreenElement||P())},F=()=>{document.fullscreenElement||y(!1)};return window.addEventListener("keydown",D),document.addEventListener("fullscreenchange",F),()=>{window.removeEventListener("keydown",D),document.removeEventListener("fullscreenchange",F),document.fullscreenElement===V&&document.exitFullscreen()}},[P,_]),Q.useEffect(()=>{XR(e.provider);{l("unavailable");return}},[g,e.provider,e.resource_uri]),Q.useEffect(()=>{if(!a||!t.current||c!=="ready"||!m)return;const V=t.current,D=new a$(null,{name:"Papers with Code",version:"1"},{serverTools:{},openLinks:{},logging:{},...R?{clipboard:{write:{}}}:{}},{hostContext:{theme:document.documentElement.dataset.theme==="dark"?"dark":"light",displayMode:_?"fullscreen":"inline"}});return D.oncalltool=async({name:F,arguments:K})=>{if(s.current.public_fork&&F!=="export_to_excalidraw")throw new Error("Shared diagrams cannot mutate owner state");return rC().callTool(F,K??{})},D.onopenlink=async({url:F})=>{const K=new URL(F);if(K.protocol!=="https:"||K.hostname!=="excalidraw.com")throw new Error("External navigation denied");if(!window.confirm("This export opens Excalidraw and uploads the diagram to its service. Continue?"))throw new Error("Export cancelled");return window.open(K.href,"_blank","noopener,noreferrer"),{}},D.onsizechange=()=>{},D.oninitialized=()=>{n.current=!0;try{const F=JSON.parse(S);D.sendToolInput({arguments:{elements:Array.isArray(F)?w$(F):F}}),D.sendToolResult(s.current.result)}catch{l("error")}},r.current=D,D.connect(new s$(V.contentWindow??void 0,V.contentWindow)).catch(()=>l("error")),()=>{n.current=!1,D.teardownResource({}).catch(()=>{}),r.current===D&&(r.current=null)}},[a,c,_,S,R,m]),Q.useEffect(()=>{var V;c!=="ready"||!n.current||(V=r.current)==null||V.sendToolResult(e.result).catch(()=>{})},[e.result,c]);const L=c==="unavailable"||c==="incompatible"||c==="error";return T.jsxs("section",{ref:v,className:`chat-mcp-app${_?" chat-mcp-app-fullscreen":""}`,"aria-label":"Interactive Excalidraw diagram",children:[T.jsx("header",{children:T.jsx("button",{type:"button",onClick:O,children:_?"Exit fullscreen":"Fullscreen"})}),c==="loading"&&T.jsx("div",{className:"chat-mcp-loading",role:"status",children:"Loading interactive diagram…"}),L&&T.jsxs("div",{className:"chat-mcp-error",children:["Interactive diagram unavailable. The cited text answer is still available.",T.jsx("button",{type:"button",onClick:A,children:"Retry diagram"})]}),a&&c==="ready"&&T.jsx("iframe",{ref:t,title:"Interactive Excalidraw diagram",sandbox:"allow-scripts",allow:R?"clipboard-write":void 0,srcDoc:a,onLoad:()=>h(!0),style:{height:d}})]})};function iC(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 cC(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 lC(e,t=240){const r=e.content.trim();return r.length<=t?r:`${r.slice(0,t).trimEnd()}…`}const uC="https://huggingface.co/pro",dC="https://huggingface.co/docs/inference-providers/pricing",fC="https://paperswithcode.co/chat",gh=()=>T.jsx("span",{className:"chat-caret"}),hC=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},pC=e=>{var y,g;const t=e.currentTarget,r=t.ownerDocument,n=(y=r.caretPositionFromPoint)==null?void 0:y.call(r,e.clientX,e.clientY),s=n?null:(g=r.caretRangeFromPoint)==null?void 0:g.call(r,e.clientX,e.clientY),o=(n==null?void 0:n.offsetNode)??(s==null?void 0:s.startContainer),a=(n==null?void 0:n.offset)??(s==null?void 0:s.startOffset);if(!(o instanceof Text)||a===void 0||!t.contains(o))return;const i=o.data,c=/[\p{L}\p{M}\p{N}_'-]/u;let l=Math.min(a,i.length),d=l;for(;l>0&&c.test(i[l-1]);)l-=1;for(;d{const r=[];let n=0;for(const s of[...t].sort((o,a)=>o.start-a.start)){const o=e.slice(s.start,s.end);s.starte.length||o!==s.title&&o!==`@${s.title}`||(r.push(e.slice(n,s.start)),r.push(T.jsxs("span",{className:"chat-inline-paper-mention",children:[T.jsx(zh,{size:13,"aria-hidden":"true"}),T.jsx(ou,{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})},gC=({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(ia,{})," ",T.jsx("span",{children:"Thinking…"})]}),T.jsxs("div",{className:"chat-reason-live-body chat-answer chat-reason-markdown",children:[T.jsx(So,{text:e.text,streaming:!0,papers:t,citations:r,webCitations:n}),T.jsx(gh,{})]})]}):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(Th,{}),T.jsx("span",{children:"Thought for a few seconds"}),T.jsx(su,{open:e.open})]}),e.open&&T.jsx("div",{className:"chat-reason-done-body chat-answer chat-reason-markdown",children:T.jsx(So,{text:e.text,papers:t,citations:r,webCitations:n})})]}),_C=({block:e,papers:t,onToggle:r})=>{var d,f,_,y;const n=e.status==="running",s=e.schema_version===2||!!e.content,o=e.status==="error"||e.status==="denied",a=typeof e.args.query=="string"?e.args.query:"",i=typeof e.args.command=="string"?e.args.command:typeof e.args.file_path=="string"?e.args.file_path:a,c=((d=e.content)==null?void 0:d.map(g=>g.text).join(""))??"",l=n?"running…":s?`${e.status} · ${e.took_ms??0} ms`:`${e.hits} results · ${e.took_ms} ms`;return 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(ia,{}):T.jsx(Rh,{}),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(su,{open:e.open})]})]}),!n&&e.open&&T.jsxs("div",{className:"chat-tool-body",children:[T.jsxs("div",{className:"chat-tool-args",children:[T.jsx("span",{className:"chat-tool-label",children:"arguments"}),T.jsx("pre",{children:JSON.stringify(e.args,null,2)})]}),s?T.jsxs(T.Fragment,{children:[T.jsxs("div",{className:"chat-tool-output-head",children:[T.jsx("span",{className:"chat-tool-label",children:"result"}),T.jsx("button",{type:"button",className:"chat-tool-copy",onClick:()=>void navigator.clipboard.writeText(c),children:"Copy"})]}),T.jsx("pre",{className:"chat-tool-output",children:T.jsx("code",{children:c})}),((f=e.metadata)==null?void 0:f.output_truncated)&&T.jsx("div",{className:"chat-tool-truncated",children:"Output was truncated."})]}):T.jsxs(T.Fragment,{children:[T.jsxs("div",{className:"chat-tool-label chat-tool-results-label",children:["returned ",((_=e.results)==null?void 0:_.length)??0," papers"]}),T.jsx("ol",{className:"chat-tool-results",children:(y=e.results)==null?void 0:y.map(g=>T.jsxs("li",{className:"chat-hit",children:[T.jsx("div",{className:"chat-hit-top",children:T.jsx(au,{routeId:g.route_id,paper:t[g.route_id],className:"chat-hit-title",children:g.title})}),T.jsx("div",{className:"chat-hit-meta",children:[iC(g.metadata),cC(g.metadata)].filter(Boolean).join(" · ")}),T.jsxs("div",{className:"chat-hit-snippet",children:[lC(g),g.content_truncated&&T.jsx("span",{className:"chat-hit-truncated",children:" (truncated)"})]})]},g.route_id))})]})]})]})},yC=({block:e,papers:t,citations:r,webCitations:n,streaming:s})=>T.jsxs("div",{className:"chat-answer",children:[T.jsx(So,{text:e.text,streaming:s,papers:t,citations:r,webCitations:n}),s&&!!e.text.trim()&&T.jsx(gh,{})]}),vC=({block:e})=>T.jsx(aC,{block:e}),_h=e=>{const t=Q.useRef(null),r=Q.useCallback(()=>{const n=t.current;if(!n)return;n.style.height="auto";const s=Math.max(120,window.innerHeight*.4);n.style.height=`${Math.min(n.scrollHeight,s)}px`,n.style.overflowY=n.scrollHeight>s?"auto":"hidden"},[]);return Q.useLayoutEffect(()=>{var n,s;(n=t.current)==null||n.focus(),(s=t.current)==null||s.setSelectionRange(e.length,e.length),r()},[r,e.length]),{textareaRef:t,resize:r}},$C=({id:e,text:t,paperSelection:r,editNotice:n,onCancel:s,onResend:o,onResendDraft:a})=>{const[i,c]=Q.useState(t),[l,d]=Q.useState(r),[f,_]=Q.useState(!1),{textareaRef:y,resize:g}=_h(t);Q.useLayoutEffect(g,[g,i]);const $=!!i.trim()&&i.length<=8e3,m=()=>{if(!$||f)return;_(!0),((a==null?void 0:a({text:i,paperMentions:[],...l?{paperSelection:l}:{}}))??(o==null?void 0:o(i))??!1)||_(!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(xs,{selection:l,editable:!0,onRemove:()=>d(void 0)}),T.jsx("textarea",{ref:y,className:"chat-inline-editor-textarea","aria-label":"Edit message",value:i,maxLength:8e3,onChange:h=>c(h.target.value),onKeyDown:h=>{h.key==="Escape"?(h.preventDefault(),s==null||s()):h.key==="Enter"&&!h.shiftKey&&!h.nativeEvent.isComposing&&(h.preventDefault(),m())}}),n&&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:!$||f,onClick:m,children:"Send"})]})]})})},wC=({id:e,text:t,paperMentions:r,paperSelection:n,enabled:s,editNotice:o,onCancel:a,onResend:i,onResendDraft:c})=>{const[l,d]=Q.useState({text:t,paperMentions:r,...n?{paperSelection:n}:{}}),[f,_]=Q.useState(!1),[y,g]=Q.useState(0),{textareaRef:$,resize:m}=_h(t),h=tu({draft:l,onChange:d,enabled:s,textareaRef:$});Q.useLayoutEffect(m,[m,l.text]);const v=!!l.text.trim()&&l.text.length<=8e3&&(s||l.paperMentions.length===0),S=()=>{if(!v||f)return;_(!0),((c==null?void 0:c(l))??(i==null?void 0:i(l.text))??!1)||_(!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(xs,{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(ru,{text:l.text,mentions:l.paperMentions,scrollTop:y,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":h.open,"aria-controls":h.open?h.pickerId:void 0,"aria-activedescendant":h.open&&h.results.length?`${h.optionIdPrefix}-${h.activeIndex}`:void 0,onChange:R=>h.updateText(R.target.value,R.target.selectionStart),onSelect:R=>h.refresh(R.currentTarget.selectionStart),onScroll:R=>g(R.currentTarget.scrollTop),onKeyDown:R=>{h.keyDown(R)||(R.key==="Escape"?(R.preventDefault(),a==null||a()):R.key==="Enter"&&!R.shiftKey&&!R.nativeEvent.isComposing&&(R.preventDefault(),S()))}}),T.jsx(nu,{open:h.open,query:h.query,results:h.results,activeIndex:h.activeIndex,loading:h.loading,error:h.error,onSelect:h.select,id:h.pickerId,optionIdPrefix:h.optionIdPrefix})]}),!s&&l.paperMentions.length>0&&T.jsx("div",{className:"chat-inline-editor-notice",role:"status",children:"Paper mentions are currently disabled. Remove them before sending."}),o&&T.jsx("div",{className:"chat-inline-editor-notice",children:o}),T.jsxs("div",{className:"chat-inline-editor-actions",children:[T.jsx("button",{type:"button",onClick:a,children:"Cancel"}),T.jsx("button",{type:"button",className:"chat-inline-editor-send",disabled:!v||f,onClick:S,children:"Send"})]})]})})},qC=({id:e,text:t,paperMentions:r=[],paperSelection:n,paperMentionsEnabled:s=!1,editingAllowed:o=!1,editing:a=!1,editNotice:i,onEdit:c,onCancel:l,onResend:d,onResendDraft:f})=>{const[_,y]=Q.useState(!1),g=Q.useRef(null);Q.useEffect(()=>()=>{g.current!==null&&window.clearTimeout(g.current)},[]);const $=async()=>{var m;if((m=navigator.clipboard)!=null&&m.writeText)try{await navigator.clipboard.writeText(t),y(!0),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>y(!1),1500)}catch{}};return a?!s&&r.length===0?T.jsx($C,{id:e,text:t,paperSelection:n,editNotice:i,onCancel:l,onResend:d,onResendDraft:f}):T.jsx(wC,{id:e,text:t,paperMentions:r,paperSelection:n,enabled:s,editNotice:i,onCancel:l,onResend:d,onResendDraft:f}):T.jsx("div",{className:"chat-msg chat-msg-user","data-message-id":e,children:T.jsxs("div",{className:"chat-user-message-wrap",children:[n&&T.jsx(xs,{selection:n}),T.jsx("div",{className:"chat-bubble",onDoubleClick:pC,children:T.jsx(mC,{text:t,mentions:r})}),T.jsxs("div",{className:"chat-user-actions",children:[T.jsx("button",{type:"button",className:"chat-user-action","aria-label":_?"Message copied":"Copy message",title:_?"Copied":"Copy",onClick:()=>void $(),children:_?T.jsx(wh,{"aria-hidden":"true"}):T.jsx(Dh,{"aria-hidden":"true"})}),o&&T.jsx("button",{type:"button",className:"chat-user-action","aria-label":"Edit message",title:"Edit",onClick:c,children:T.jsx(qh,{"aria-hidden":"true"})})]})]})})},UC=({msg:e,papers:t,onToggleBlock:r,onArchiveOldChats:n,onArchiveOldestChats:s,archivePending:o=null,hfBilling:a=null,openRouterFallbackEnabled:i=!1,feedbackEnabled:c=!1})=>{var A,L,V;const[l,d]=Q.useState(null),[f,_]=Q.useState(!1),[y,g]=Q.useState(!1),[$,m]=Q.useState(!1),[h,v]=Q.useState(""),S=Q.useRef(null),R=`chat-feedback-panel-${e.id}`,P=c&&!e.streaming&&!e.error&&!!((A=e.blocks)!=null&&A.some(D=>D.kind==="answer"&&D.text.trim()));Q.useEffect(()=>{var D;$&&((D=S.current)==null||D.focus())},[$]);const O=async(D,F)=>{if(!f){_(!0),g(!1);try{F===void 0?await Nc.reportFeedback(e.id,D):await Nc.reportFeedback(e.id,D,F),d(D),m(!1),v("")}catch{g(!0)}finally{_(!1)}}};return T.jsx("div",{className:"chat-msg chat-msg-assistant",children:T.jsxs("div",{className:"chat-msg-blocks",children:[(L=e.blocks)==null?void 0:L.map((D,F)=>{var Ce;const K=`${e.id}-${F}`,ce="citations"in D&&D.citations!==void 0?D.citations:e.citations??[],q=Object.fromEntries(ce.filter(_e=>(_e.kind??"paper")==="paper"&&_e.route_id).map(_e=>[_e.route_id,_e])),le=Object.fromEntries(ce.filter(_e=>_e.kind==="web"&&_e.url).map(_e=>[_e.url,_e]));return D.kind==="reasoning"?T.jsx(gC,{block:D,papers:t,citations:q,webCitations:le,onToggle:()=>r(e.id,F)},K):D.kind==="tool"?T.jsx(_C,{block:D,papers:t,onToggle:()=>r(e.id,F)},K):D.kind==="app"?T.jsx(vC,{block:D},K):T.jsx(yC,{block:D,papers:t,citations:q,webCitations:le,streaming:!!(e.streaming&&F===(((Ce=e.blocks)==null?void 0:Ce.length)??0)-1)},K)}),hC(e)&&T.jsx("div",{className:"chat-waiting",role:"status","aria-live":"polite",children:T.jsx("span",{className:"chat-thinking",children:(((V=e.blocks)==null?void 0:V.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:uC,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:dC,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:fC,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:f,onClick:()=>{m(!1),O(!0)},children:T.jsx(Fh,{"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:f,onClick:()=>{g(!1),m(!0)},children:T.jsx(Uh,{"aria-hidden":"true"})}),y&&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:h,maxLength:500,rows:4,disabled:f,onChange:D=>v(D.target.value),onKeyDown:D=>{D.key==="Escape"&&(D.preventDefault(),m(!1))}}),T.jsxs("div",{className:"chat-feedback-panel-actions",children:[T.jsx("button",{type:"button",className:"chat-feedback-skip",disabled:f,onClick:()=>void O(!1),children:"Skip"}),T.jsx("button",{type:"button",className:"chat-feedback-submit",disabled:f,onClick:()=>void O(!1,h.trim()||void 0),children:f?"Submitting…":"Submit"})]})]})]})})};export{UC as A,MC as C,qC as U};