@artooi/ag-ui-web-component 0.40.0 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -1
- package/README.md +46 -24
- package/dist/ag-ui-web-component.bundle.js +118 -87
- package/dist/ag-ui-web-component.bundle.js.map +4 -4
- package/dist/constants.d.ts +3 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/core/agui_client.d.ts +25 -16
- package/dist/core/agui_client.d.ts.map +1 -1
- package/dist/core/attachment.d.ts +11 -4
- package/dist/core/attachment.d.ts.map +1 -1
- package/dist/core/tool_outcome.d.ts +4 -3
- package/dist/core/tool_outcome.d.ts.map +1 -1
- package/dist/core/utils.d.ts +19 -0
- package/dist/core/utils.d.ts.map +1 -1
- package/dist/index.js +461 -452
- package/dist/index.js.map +4 -4
- package/dist/ui/history/conversation_history.d.ts +1 -1
- package/dist/ui/history/conversation_history.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/constants.ts +3 -2
- package/src/core/agui_client.ts +149 -131
- package/src/core/attachment.ts +13 -5
- package/src/core/tool_outcome.ts +4 -3
- package/src/core/utils.ts +23 -0
- package/src/ui/history/conversation_history.ts +25 -22
- package/src/version.ts +1 -1
|
@@ -1,21 +1,52 @@
|
|
|
1
|
-
var Ff=Object.defineProperty;var ba=(t,e)=>{for(var n in e)Ff(t,n,{get:e[n],enumerable:!0})};var xo="ag-ui-chat",ya="ag-ui-submit",wa="ag-ui-toggle",xa="ag-ui-unread",Ea="ag-ui-state",Ta="ag-ui-attachments",_a="ag-ui-run-finished",Sa="ag-ui-custom",Aa="ag-ui-invalidate",ka="ag-ui-feedback",Ra="suggestions",Ia="ag_ui.invalidate",sc="ag_ui.subagent",On={STARTED:"started",TOOL_CALL:"tool_call",TOOL_RESULT:"tool_result",FINISHED:"finished",FAILED:"failed"},Le={USER:"user",ASSISTANT:"assistant"},fr="x-destructive",Eo="x-confirm",xe="x-summary",mr="x-navigates",To="read_page",Mn=10,jt={COPY:"copy",RETRY:"retry",FEEDBACK:"feedback"},te={PENDING:"pending",DEFERRED:"deferred",DONE:"done",ERROR:"error",DECLINED:"declined",INTERRUPTED:"interrupted"},Pe={SUCCESS:"success",FAILED:"failed",DENIED:"denied",INTERRUPTED:"interrupted"},$e={UPLOADING:"uploading",READY:"ready",ERROR:"error"},Ca=10*1024*1024,Ln={INLINE:"inline",MINIMAL:"minimal",COMPACT:"compact",FULL:"full"},Na="compaction",Oa="load_capability",ac='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 19.5V5m-6.5 6.5L12 5l6.5 6.5"/></svg>',lc='<svg class="glyph glyph--solid" viewBox="0 0 24 24" aria-hidden="true"><rect x="7" y="7" width="10" height="10" rx="2.5"/></svg>',dc='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M17 8.5V15a5 5 0 0 1-10 0V7a3 3 0 0 1 6 0v7.5a1 1 0 0 1-2 0V8.5"/></svg>',cc='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 4a3 3 0 0 1 3 3v5a3 3 0 0 1-6 0V7a3 3 0 0 1 3-3z"/><path d="M5 11v1a7 7 0 0 0 14 0v-1"/><path d="M12 19v3"/></svg>',uc='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 14.5A8.5 8.5 0 0 1 9.5 4a8.5 8.5 0 1 0 10.5 10.5z"/></svg>',hc='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>',pc='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v8a2.5 2.5 0 0 1-2.5 2.5H9l-5 4z"/></svg>',fc='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><rect x="9" y="9" width="11" height="11" rx="2"/><path d="M5 15V6a2 2 0 0 1 2-2h8"/></svg>',mc='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 12a8 8 0 1 1-2.5-5.8"/><path d="M20 4v4h-4"/></svg>',gc='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M7 10v10H4V10z"/><path d="M7 10l4.5-7a2 2 0 0 1 3.4 2L13.5 9H19a2 2 0 0 1 2 2.3l-1.1 6.4A2 2 0 0 1 17.9 20H7"/></svg>',vc='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M17 14V4h3v10z"/><path d="M17 14l-4.5 7a2 2 0 0 1-3.4-2l1.4-4H5a2 2 0 0 1-2-2.3l1.1-6.4A2 2 0 0 1 6.1 4H17"/></svg>',bc='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/></svg>',yc='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><rect x="3.5" y="4.5" width="17" height="15" rx="2.5"/><circle cx="9" cy="10" r="1.5"/><path d="M4.5 17.5 9 13.5l3.5 3 3-2.5 4.5 4"/></svg>',wc='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/><rect class="glyph--solid" x="7.5" y="13.5" width="9" height="4.5" rx="1"/></svg>',xc='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/><path d="M8.5 13.5h7M8.5 17h4.5"/></svg>',_o="chart",Vt=24,Ec=150,Tc=2147483001,So=5e3,tt=8;var $f=/\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g;function oe(t,e){return t.replace($f,(n,r)=>Object.hasOwn(e,r)?String(e[r]):n)}var Bf=/\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g;function _c(t,e){let n=[];return{text:t.replace(Bf,(o,i)=>{let s=e[i];return s==null||s===""?(n.includes(i)||n.push(i),o):String(s)}),missing:n}}function jf(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.name=="string"&&typeof e.title=="string"&&(e.prompt===void 0||typeof e.prompt=="string")}function Ma(t){return Array.isArray(t)?t.filter(jf):[]}var Ao=class{#e;#t=[];#n=[];#o=[];constructor(e){this.#e=e}setClientSkills(e){this.#o=e,this.#i()}init(){this.#e.menu.enableChips(this.#e.flag("data-prompt-chips")),this.#e.menu.enableSlash(this.#e.flag("data-slash-commands")),this.#n=this.#r(),this.#i()}async fetch(){let e=this.#e.element.getAttribute("data-skills-url");if(e!==null)try{let n=await fetch(e,this.#e.fetchInit(e));this.#t=Ma(await n.json()),this.#i()}catch{}}apply(e){let{input:n,hint:r}=this.#e;if(e.prompt===void 0){r.hidden=!0,this.#e.send(`/${e.name}`);return}let{text:o,missing:i}=_c(e.prompt,this.#e.context());if(i.length>0){r.textContent=oe(this.#e.strings().skillNeeds,{title:e.title,fields:i.join(", ")}),r.hidden=!1,n.value=o,this.#e.autoGrow(),n.focus(),this.#s(o);return}if(r.hidden=!0,n.value=o,this.#e.autoGrow(),e.sendImmediately===!1){n.focus();return}this.#e.submit()}#r(){return Ma(this.#e.readJsonAttribute("data-skills"))}#i(){let e=new Map;for(let n of[...this.#t,...this.#n,...this.#o])e.set(n.name,n);this.#e.menu.setSkills([...e.values()])}#s(e){let n=e.indexOf("{");this.#e.input.setSelectionRange(n,e.indexOf("}",n)+1)}};var ko=["top-left","top-right","bottom-left","bottom-right"];function Sc(t){return ko.includes(t)}function La(t){return[{name:"read_chat_surface",description:"Describe the chat panel you are speaking from: its placement, whether it is collapsed, whether it can be moved, and the box it occupies. Read this before moving or minimising yourself, since a full-screen panel has nowhere to move to. Read-only.",parameters:{type:"object",properties:{},required:[],[xe]:"Read the chat's own position"},handler:()=>t.describeSurface()},{name:"move_chat",description:"Move your own panel to a corner, to uncover something the user needs to see. `corner` is top-left, top-right, bottom-left or bottom-right. Answers `moved: false` with a reason when the placement owns its position or the panel fills the screen; check `read_chat_surface` first, and prefer minimise_chat when there is nowhere to move to.",parameters:{type:"object",properties:{corner:{type:"string",enum:[...ko]}},required:["corner"],[xe]:"Move the chat out of the way"},handler:e=>{let n=String(e.corner??""),r=t.describeSurface();return Sc(n)?r.movable?{moved:t.moveTo(n,{announce:!0}),corner:n}:{moved:!1,reason:r.fullBleed?"the panel fills the screen, so there is nowhere to move it to":r.draggable===!1?"this page has turned off moving the panel":`the "${r.placement??""}" placement owns the panel's position`,suggestion:r.collapsible?"minimise_chat":null}:{moved:!1,reason:`"${n}" is not a corner; use one of ${ko.join(", ")}`}}},{name:"minimise_chat",description:"Collapse your own panel to its launcher, so the user can see the whole page. The launcher stays visible and reopens it. Answers `minimised: false` when the placement has no collapsed state, which is the case for a full-page chat.",parameters:{type:"object",properties:{},required:[],[xe]:"Minimise the chat"},handler:()=>t.describeSurface().collapsible?(t.setCollapsed(!0,{announce:!0}),{minimised:!0}):{minimised:!1,reason:"this placement has no collapsed state, so there is no launcher to return to"}},{name:"restore_chat",description:"Open your own panel again after minimising it.",parameters:{type:"object",properties:{},required:[],[xe]:"Restore the chat"},handler:()=>(t.setCollapsed(!1),{restored:!0})}]}var gr=class{#e=new Map;register(e){this.#e.set(e.name,e)}has(e){return this.#e.has(e)}get(e){let n=this.#e.get(e);if(n===void 0)throw new Error(`tool "${e}" is not registered`);return n}tools(){return[...this.#e.values()].map(e=>({name:e.name,description:e.description,parameters:e.parameters}))}};var Vf="#4f46e5";function Pn(t,e,n){let r=window.getComputedStyle(t).getPropertyValue(e).trim();return r===""?n:r}var qf=4;function Pa(t,e={}){let n=document.createElement("div");n.setAttribute("data-ag-ui-highlight",""),n.setAttribute("aria-hidden","true"),n.style.cssText=["position: fixed","inset: 0","pointer-events: none",`z-index: ${Pn(t,"--ag-ui-highlight-z-index",String(Tc))}`].join(";");let r=document.createElement("div"),o=document.createElement("div");n.className="ag-ui-highlight",r.className="ag-ui-highlight-scrim",o.className="ag-ui-highlight-ring",e.scrim===!0&&n.append(r),n.append(o);let i=e.ringWidth??Number.parseFloat(Pn(t,"--ag-ui-highlight-ring-width","3")),s=e.flowMs??Number.parseFloat(Pn(t,"--ag-ui-highlight-flow-ms","2400")),a=()=>{let u=t.getBoundingClientRect(),m=e.padding??qf,w=e.radius??Number.parseFloat(getComputedStyle(t).borderRadius),p=u.left-m,h=u.top-m,v=u.width+m*2,x=u.height+m*2;e.scrim===!0&&(r.style.cssText=["position: absolute","inset: 0",`background: ${Pn(t,"--ag-ui-highlight-scrim","rgba(15, 15, 25, 0.45)")}`,`clip-path: path(evenodd, '${Yf(p,h,v,x,w+m)}')`].join(";")),o.style.cssText=["position: absolute",`left: ${p}px`,`top: ${h}px`,`width: ${v}px`,`height: ${x}px`,`border-radius: ${w+m}px`,`border: ${i}px solid transparent`,"box-sizing: border-box",Xf(t,e)].join(";")};a();let l=null;e.gradient===!0&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches&&(l=o.animate([{backgroundPosition:"100% 0"},{backgroundPosition:"-100% 0"}],{duration:s,iterations:Number.POSITIVE_INFINITY,easing:"linear"}));let d={capture:!0,passive:!0};return window.addEventListener("scroll",a,d),window.addEventListener("resize",a,d),document.body.appendChild(n),()=>{window.removeEventListener("scroll",a,d),window.removeEventListener("resize",a,d),l?.cancel(),n.remove()}}function Wf(t){return t===void 0?null:CSS.supports("color",t)?t:null}function Xf(t,e){let n=Wf(e.color)??Pn(t,"--ag-ui-accent",Vf);if(e.gradient!==!0)return`border-color: ${n}`;let r=Pn(t,"--ag-ui-highlight-gradient",`linear-gradient(115deg, transparent 20%, ${n} 50%, transparent 80%)`),o="linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)";return[`background-image: ${r}`,"background-origin: border-box","background-size: 300% 100%",`-webkit-mask: ${o}`,`mask: ${o}`,"-webkit-mask-composite: xor","mask-composite: exclude","background-position: 50% 0"].join(";")}function Yf(t,e,n,r,o){let i=Math.max(0,Math.min(o,n/2,r/2)),s=t+n,a=e+r,l=`M 0 0 H ${window.innerWidth} V ${window.innerHeight} H 0 Z`,d=[`M ${t+i} ${e}`,`H ${s-i}`,`A ${i} ${i} 0 0 1 ${s} ${e+i}`,`V ${a-i}`,`A ${i} ${i} 0 0 1 ${s-i} ${a}`,`H ${t+i}`,`A ${i} ${i} 0 0 1 ${t} ${a-i}`,`V ${e+i}`,`A ${i} ${i} 0 0 1 ${t+i} ${e}`,"Z"].join(" ");return`${l} ${d}`}function Ro(t,e){return Object.getOwnPropertyDescriptor(t,e).set}var Kf=Ro(HTMLInputElement.prototype,"value"),Zf=Ro(HTMLTextAreaElement.prototype,"value"),Qf=Ro(HTMLSelectElement.prototype,"value"),Jf=Ro(HTMLInputElement.prototype,"checked");function qt(t,e){t instanceof HTMLTextAreaElement?Zf.call(t,e):t instanceof HTMLSelectElement?Qf.call(t,e):Kf.call(t,e)}function vr(t,e){Jf.call(t,e)}var Da="#4f46e5",em="rgba(79, 70, 229, 0.4)",tm="--ag-ui-accent";function Dn(t){return new Promise(e=>{setTimeout(e,t)})}function Io(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}function Ua(t){return t<=0||Io()?Promise.resolve():Dn(t)}function Co(t,e){let n=window.getComputedStyle(t).getPropertyValue(tm).trim();return n===""?e:n}function Ac(t){return`0 0 0 3px ${Co(t,em)}`}async function Ha(t,e,n={}){let r=n.charDelayMs??35;qt(t,""),t.dispatchEvent(new Event("input",{bubbles:!0}));for(let o of e)qt(t,t.value+o),t.dispatchEvent(new Event("input",{bubbles:!0})),r>0&&await Dn(r);t.dispatchEvent(new Event("change",{bubbles:!0}))}async function Ga(t,e={}){let n=e.highlightMs??280,r=t.style.outline,o=t.style.outlineOffset;t.style.outline=`2px solid ${Co(t,Da)}`,t.style.outlineOffset="2px",await Dn(n),t.style.outline=r,t.style.outlineOffset=o,t.click()}var nm=600,rm=100;function wt(t,e={}){let n=Io();return t.scrollIntoView({block:"center",inline:"nearest",behavior:n?"auto":"smooth"}),n?Promise.resolve():new Promise(r=>{let o,i=()=>{clearTimeout(o),document.removeEventListener("scroll",s,!0),document.removeEventListener("scrollend",i,!0),r()},s=()=>{document.removeEventListener("scroll",s,!0),clearTimeout(o),o=setTimeout(i,e.settleMs??nm)};o=setTimeout(i,rm),document.addEventListener("scroll",s,!0),document.addEventListener("scrollend",i,!0)})}var om=1200,im=1/3;async function kc(t,e,n){(e.focus??n)&&t.focus({preventScroll:!0});let r=e.flashMs??om;if(r<=0)return;if(e.scrim===!0||e.gradient===!0){let d=Pa(t,{scrim:e.scrim===!0,gradient:e.gradient===!0,...e.color===void 0?{}:{color:e.color},...e.ringPadding===void 0?{}:{padding:e.ringPadding}});await Dn(r),d();return}let o=t.style.outline,i=t.style.outlineOffset,s=t.style.transition,a=e.color??Co(t,Da);t.style.outline=`3px solid ${a}`,t.style.outlineOffset="2px";let l=Io()?0:Math.round(r*im);await Dn(r-l),l>0&&(t.style.transition=`outline-color ${l}ms ease-out`,t.style.outline="3px solid transparent",await Dn(l)),t.style.outline=o,t.style.outlineOffset=i,t.style.transition=s}function sm(t,e={}){return kc(t,e,!1)}function za(t,e={}){return kc(t,e,!0)}async function Fa(t,e={}){let n=e.pressMs??140,r=t.style.transform,o=t.style.transition,i=t.style.boxShadow;t.style.transition="transform 80ms ease",t.style.transform="scale(0.96)",t.style.boxShadow=Ac(t),await Ua(n),t.style.transform=r,t.style.transition=o,t.style.boxShadow=i,t.click()}function am(t,e){for(let n of Array.from(t.options))if(n.value===e||n.text===e)return n;return null}async function $a(t,e,n={}){let r=am(t,e);if(r===null)throw new Error(`no <option> matching "${e}"`);let o=n.highlightMs??220,i=t.style.outline,s=t.style.outlineOffset;t.style.outline=`2px solid ${Co(t,Da)}`,t.style.outlineOffset="2px",await Ua(o),qt(t,r.value),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})),t.style.outline=i,t.style.outlineOffset=s}async function Ba(t,e,n={}){let r=n.flashMs??200,o=t.style.boxShadow;t.style.boxShadow=Ac(t),await Ua(r),vr(t,e),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})),t.style.boxShadow=o}var yr={SCROLL:"scroll",DRAG:"drag",CHAT:"chat"};function ja(t,e){let n=[];return t.has(yr.SCROLL)&&n.push(lm(e)),t.has(yr.DRAG)&&n.push(dm(e)),n}function lm(t){return{name:"scroll_to",description:"Scroll a target into view. `target` is `top`, `bottom`, or a CSS selector / page-map element id. Read-only: it changes nothing on the page.",parameters:{type:"object",properties:{target:{type:"string"}},required:["target"],[xe]:"Scroll into view"},handler:e=>{let n=String(e.target??"");if(n==="top"||n==="bottom"){let o=n==="top"?0:document.body.scrollHeight;return window.scrollTo({top:o,behavior:"smooth"}),{scrolled:!0,target:n}}let r=t(n);if(r===null)throw new Error(`no element matching "${n}"`);return wt(r),{scrolled:!0,target:n}}}}function dm(t){return{name:"drag_and_drop",description:"Drag the `from` element onto the `to` element (CSS selectors or page-map element ids), firing the page's native drag-and-drop. Use for reordering sortable lists. The page decides what the drop commits.",parameters:{type:"object",properties:{from:{type:"string"},to:{type:"string"}},required:["from","to"],[xe]:"Drag and drop"},handler:e=>{let n=String(e.from??""),r=String(e.to??""),o=t(n);if(o===null)throw new Error(`no element matching "${n}"`);let i=t(r);if(i===null)throw new Error(`no element matching "${r}"`);return cm(o,i),{dragged:!0,from:n,to:r}}}}function cm(t,e){let n=new DataTransfer;br(t,"dragstart",n),br(e,"dragenter",n),br(e,"dragover",n),br(e,"drop",n),br(t,"dragend",n)}function br(t,e,n){let r=new Event(e,{bubbles:!0,cancelable:!0});r.dataTransfer=n,t.dispatchEvent(r)}function Va(t,e){return!e||t===null?[]:[{description:"page_map",value:JSON.stringify(t())}]}function No(t){let e=[{name:`read_${t.name}`,description:`Read the "${t.name}" state.`,parameters:{type:"object",properties:{},required:[],[xe]:`Read ${t.name}`},handler:()=>t.read()}],n=t.write;return n!==void 0&&e.push({name:`set_${t.name}`,description:`Update the "${t.name}" state.`,parameters:{...t.schema??{type:"object"},[fr]:!0,[xe]:`Update ${t.name}`},handler:r=>n(r)}),e}var um=No;var Rc=/:([A-Za-z_][A-Za-z0-9_]*)/g;function hm(t){return[...t.matchAll(Rc)].map(e=>e[0].slice(1))}function pm(t,e,n){let r={...n};return{path:e.replace(Rc,(i,s)=>{let a=n[s];if(a==null||String(a)==="")throw new Error(`route "${t}" requires path param "${s}"`);return delete r[s],encodeURIComponent(String(a))}),leftover:r}}function fm(t,e){let n=new URLSearchParams;for(let[o,i]of Object.entries(e))n.set(o,String(i));let r=n.toString();return r===""?t:`${t}?${r}`}function qa(t,e){return[{name:"list_routes",description:"List the routes the app can navigate to. Each route's `pathParams` names the dynamic segments to pass as `params` to `navigate_to_route`.",parameters:{type:"object",properties:{},required:[],[xe]:"List pages"},handler:()=>t().map(n=>({...n,pathParams:hm(n.path)}))},{name:"navigate_to_route",description:"Navigate to one of the app's routes by its id, filling any dynamic `:name` path segments (and extra query params) from `params`.",parameters:{type:"object",properties:{route_id:{type:"string"},params:{type:"object"}},required:["route_id"],[mr]:!0,[xe]:"Navigate"},handler:n=>{let r=n.route_id,o=t().find(u=>u.id===r);if(o===void 0)throw new Error(`unknown route "${String(r)}"`);let i=n.params??{},{path:s,leftover:a}=pm(o.id,o.path,i),l=fm(s,a),d=e();return d!==null?d(l):window.location.assign(l),{navigated:!0,path:l}}}]}var Ae=[];for(let t=0;t<256;++t)Ae.push((t+256).toString(16).slice(1));function Ic(t,e=0){return(Ae[t[e+0]]+Ae[t[e+1]]+Ae[t[e+2]]+Ae[t[e+3]]+"-"+Ae[t[e+4]]+Ae[t[e+5]]+"-"+Ae[t[e+6]]+Ae[t[e+7]]+"-"+Ae[t[e+8]]+Ae[t[e+9]]+"-"+Ae[t[e+10]]+Ae[t[e+11]]+Ae[t[e+12]]+Ae[t[e+13]]+Ae[t[e+14]]+Ae[t[e+15]]).toLowerCase()}var Wa,mm=new Uint8Array(16);function Xa(){if(!Wa){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Wa=crypto.getRandomValues.bind(crypto)}return Wa(mm)}var gm=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ya={randomUUID:gm};function vm(t,e,n){if(Ya.randomUUID&&!e&&!t)return Ya.randomUUID();t=t||{};let r=t.random??t.rng?.()??Xa();if(r.length<16)throw new Error("Random bytes length must be >= 16");if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){if(n=n||0,n<0||n+16>e.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let o=0;o<16;++o)e[n+o]=r[o];return e}return Ic(r)}var Ct=vm;var c={};ba(c,{BRAND:()=>Bm,DIRTY:()=>Wt,EMPTY_PATH:()=>xm,INVALID:()=>F,NEVER:()=>kg,OK:()=>Ce,ParseStatus:()=>ke,Schema:()=>X,ZodAny:()=>Mt,ZodArray:()=>_t,ZodBigInt:()=>Yt,ZodBoolean:()=>Kt,ZodBranded:()=>xr,ZodCatch:()=>ln,ZodDate:()=>Zt,ZodDefault:()=>an,ZodDiscriminatedUnion:()=>Lo,ZodEffects:()=>Qe,ZodEnum:()=>on,ZodError:()=>He,ZodFirstPartyTypeKind:()=>$,ZodFunction:()=>Do,ZodIntersection:()=>tn,ZodIssueCode:()=>k,ZodLazy:()=>nn,ZodLiteral:()=>rn,ZodMap:()=>$n,ZodNaN:()=>jn,ZodNativeEnum:()=>sn,ZodNever:()=>nt,ZodNull:()=>Jt,ZodNullable:()=>ft,ZodNumber:()=>Xt,ZodObject:()=>Ge,ZodOptional:()=>Ke,ZodParsedType:()=>L,ZodPipeline:()=>Er,ZodPromise:()=>Lt,ZodReadonly:()=>dn,ZodRecord:()=>Po,ZodSchema:()=>X,ZodSet:()=>Bn,ZodString:()=>Ot,ZodSymbol:()=>zn,ZodTransformer:()=>Qe,ZodTuple:()=>pt,ZodType:()=>X,ZodUndefined:()=>Qt,ZodUnion:()=>en,ZodUnknown:()=>Tt,ZodVoid:()=>Fn,addIssueToContext:()=>N,any:()=>Qm,array:()=>ng,bigint:()=>Wm,boolean:()=>zc,coerce:()=>Ag,custom:()=>Uc,date:()=>Xm,datetimeRegex:()=>Pc,defaultErrorMap:()=>xt,discriminatedUnion:()=>sg,effect:()=>bg,enum:()=>mg,function:()=>hg,getErrorMap:()=>Un,getParsedType:()=>ht,instanceof:()=>Vm,intersection:()=>ag,isAborted:()=>Oo,isAsync:()=>Hn,isDirty:()=>Mo,isValid:()=>Nt,late:()=>jm,lazy:()=>pg,literal:()=>fg,makeIssue:()=>wr,map:()=>cg,nan:()=>qm,nativeEnum:()=>gg,never:()=>eg,null:()=>Zm,nullable:()=>wg,number:()=>Gc,object:()=>rg,objectUtil:()=>Ka,oboolean:()=>Sg,onumber:()=>_g,optional:()=>yg,ostring:()=>Tg,pipeline:()=>Eg,preprocess:()=>xg,promise:()=>vg,quotelessJson:()=>bm,record:()=>dg,set:()=>ug,setErrorMap:()=>wm,strictObject:()=>og,string:()=>Hc,symbol:()=>Ym,transformer:()=>bg,tuple:()=>lg,undefined:()=>Km,union:()=>ig,unknown:()=>Jm,util:()=>K,void:()=>tg});var K;(function(t){t.assertEqual=o=>{};function e(o){}t.assertIs=e;function n(o){throw new Error}t.assertNever=n,t.arrayToEnum=o=>{let i={};for(let s of o)i[s]=s;return i},t.getValidEnumValues=o=>{let i=t.objectKeys(o).filter(a=>typeof o[o[a]]!="number"),s={};for(let a of i)s[a]=o[a];return t.objectValues(s)},t.objectValues=o=>t.objectKeys(o).map(function(i){return o[i]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let i=[];for(let s in o)Object.prototype.hasOwnProperty.call(o,s)&&i.push(s);return i},t.find=(o,i)=>{for(let s of o)if(i(s))return s},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function r(o,i=" | "){return o.map(s=>typeof s=="string"?`'${s}'`:s).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(o,i)=>typeof i=="bigint"?i.toString():i})(K||(K={}));var Ka;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Ka||(Ka={}));var L=K.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ht=t=>{switch(typeof t){case"undefined":return L.undefined;case"string":return L.string;case"number":return Number.isNaN(t)?L.nan:L.number;case"boolean":return L.boolean;case"function":return L.function;case"bigint":return L.bigint;case"symbol":return L.symbol;case"object":return Array.isArray(t)?L.array:t===null?L.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?L.promise:typeof Map<"u"&&t instanceof Map?L.map:typeof Set<"u"&&t instanceof Set?L.set:typeof Date<"u"&&t instanceof Date?L.date:L.object;default:return L.unknown}};var k=K.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),bm=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),He=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){let n=e||function(i){return i.message},r={_errors:[]},o=i=>{for(let s of i.issues)if(s.code==="invalid_union")s.unionErrors.map(o);else if(s.code==="invalid_return_type")o(s.returnTypeError);else if(s.code==="invalid_arguments")o(s.argumentsError);else if(s.path.length===0)r._errors.push(n(s));else{let a=r,l=0;for(;l<s.path.length;){let d=s.path[l];l===s.path.length-1?(a[d]=a[d]||{_errors:[]},a[d]._errors.push(n(s))):a[d]=a[d]||{_errors:[]},a=a[d],l++}}};return o(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,K.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let o of this.issues)if(o.path.length>0){let i=o.path[0];n[i]=n[i]||[],n[i].push(e(o))}else r.push(e(o));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};He.create=t=>new He(t);var ym=(t,e)=>{let n;switch(t.code){case k.invalid_type:t.received===L.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case k.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,K.jsonStringifyReplacer)}`;break;case k.unrecognized_keys:n=`Unrecognized key(s) in object: ${K.joinValues(t.keys,", ")}`;break;case k.invalid_union:n="Invalid input";break;case k.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${K.joinValues(t.options)}`;break;case k.invalid_enum_value:n=`Invalid enum value. Expected ${K.joinValues(t.options)}, received '${t.received}'`;break;case k.invalid_arguments:n="Invalid function arguments";break;case k.invalid_return_type:n="Invalid function return type";break;case k.invalid_date:n="Invalid date";break;case k.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:K.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case k.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case k.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case k.custom:n="Invalid input";break;case k.invalid_intersection_types:n="Intersection results could not be merged";break;case k.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case k.not_finite:n="Number must be finite";break;default:n=e.defaultError,K.assertNever(t)}return{message:n}},xt=ym;var Cc=xt;function wm(t){Cc=t}function Un(){return Cc}var wr=t=>{let{data:e,path:n,errorMaps:r,issueData:o}=t,i=[...n,...o.path||[]],s={...o,path:i};if(o.message!==void 0)return{...o,path:i,message:o.message};let a="",l=r.filter(d=>!!d).slice().reverse();for(let d of l)a=d(s,{data:e,defaultError:a}).message;return{...o,path:i,message:a}},xm=[];function N(t,e){let n=Un(),r=wr({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===xt?void 0:xt].filter(o=>!!o)});t.common.issues.push(r)}var ke=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let o of n){if(o.status==="aborted")return F;o.status==="dirty"&&e.dirty(),r.push(o.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let o of n){let i=await o.key,s=await o.value;r.push({key:i,value:s})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let o of n){let{key:i,value:s}=o;if(i.status==="aborted"||s.status==="aborted")return F;i.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof s.value<"u"||o.alwaysSet)&&(r[i.value]=s.value)}return{status:e.value,value:r}}},F=Object.freeze({status:"aborted"}),Wt=t=>({status:"dirty",value:t}),Ce=t=>({status:"valid",value:t}),Oo=t=>t.status==="aborted",Mo=t=>t.status==="dirty",Nt=t=>t.status==="valid",Hn=t=>typeof Promise<"u"&&t instanceof Promise;var D;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(D||(D={}));var Ze=class{constructor(e,n,r,o){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Nc=(t,e)=>{if(Nt(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new He(t.common.issues);return this._error=n,this._error}}};function W(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:o}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:o}:{errorMap:(s,a)=>{let{message:l}=t;return s.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:o}}var X=class{get description(){return this._def.description}_getType(e){return ht(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:ht(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ke,ctx:{common:e.parent.common,data:e.data,parsedType:ht(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(Hn(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ht(e)},o=this._parseSync({data:e,path:r.path,parent:r});return Nc(r,o)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ht(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return Nt(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>Nt(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ht(e)},o=this._parse({data:e,path:r.path,parent:r}),i=await(Hn(o)?o:Promise.resolve(o));return Nc(r,i)}refine(e,n){let r=o=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(o):n;return this._refinement((o,i)=>{let s=e(o),a=()=>i.addIssue({code:k.custom,...r(o)});return typeof Promise<"u"&&s instanceof Promise?s.then(l=>l?!0:(a(),!1)):s?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,o)=>e(r)?!0:(o.addIssue(typeof n=="function"?n(r,o):n),!1))}_refinement(e){return new Qe({schema:this,typeName:$.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Ke.create(this,this._def)}nullable(){return ft.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return _t.create(this)}promise(){return Lt.create(this,this._def)}or(e){return en.create([this,e],this._def)}and(e){return tn.create(this,e,this._def)}transform(e){return new Qe({...W(this._def),schema:this,typeName:$.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new an({...W(this._def),innerType:this,defaultValue:n,typeName:$.ZodDefault})}brand(){return new xr({typeName:$.ZodBranded,type:this,...W(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new ln({...W(this._def),innerType:this,catchValue:n,typeName:$.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Er.create(this,e)}readonly(){return dn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Em=/^c[^\s-]{8,}$/i,Tm=/^[0-9a-z]+$/,_m=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Sm=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Am=/^[a-z0-9_-]{21}$/i,km=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Rm=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Im=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Cm="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Za,Nm=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Om=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,Mm=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Lm=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Pm=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Dm=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Mc="((\\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])))",Um=new RegExp(`^${Mc}$`);function Lc(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function Hm(t){return new RegExp(`^${Lc(t)}$`)}function Pc(t){let e=`${Mc}T${Lc(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Gm(t,e){return!!((e==="v4"||!e)&&Nm.test(t)||(e==="v6"||!e)&&Mm.test(t))}function zm(t,e){if(!km.test(t))return!1;try{let[n]=t.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),o=JSON.parse(atob(r));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||e&&o.alg!==e)}catch{return!1}}function Fm(t,e){return!!((e==="v4"||!e)&&Om.test(t)||(e==="v6"||!e)&&Lm.test(t))}var Ot=class t extends X{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==L.string){let i=this._getOrReturnCtx(e);return N(i,{code:k.invalid_type,expected:L.string,received:i.parsedType}),F}let r=new ke,o;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(o=this._getOrReturnCtx(e,o),N(o,{code:k.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(o=this._getOrReturnCtx(e,o),N(o,{code:k.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){let s=e.data.length>i.value,a=e.data.length<i.value;(s||a)&&(o=this._getOrReturnCtx(e,o),s?N(o,{code:k.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&N(o,{code:k.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")Im.test(e.data)||(o=this._getOrReturnCtx(e,o),N(o,{validation:"email",code:k.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Za||(Za=new RegExp(Cm,"u")),Za.test(e.data)||(o=this._getOrReturnCtx(e,o),N(o,{validation:"emoji",code:k.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")Sm.test(e.data)||(o=this._getOrReturnCtx(e,o),N(o,{validation:"uuid",code:k.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Am.test(e.data)||(o=this._getOrReturnCtx(e,o),N(o,{validation:"nanoid",code:k.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")Em.test(e.data)||(o=this._getOrReturnCtx(e,o),N(o,{validation:"cuid",code:k.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")Tm.test(e.data)||(o=this._getOrReturnCtx(e,o),N(o,{validation:"cuid2",code:k.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")_m.test(e.data)||(o=this._getOrReturnCtx(e,o),N(o,{validation:"ulid",code:k.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),N(o,{validation:"url",code:k.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),N(o,{validation:"regex",code:k.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(o=this._getOrReturnCtx(e,o),N(o,{code:k.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(o=this._getOrReturnCtx(e,o),N(o,{code:k.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(o=this._getOrReturnCtx(e,o),N(o,{code:k.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?Pc(i).test(e.data)||(o=this._getOrReturnCtx(e,o),N(o,{code:k.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Um.test(e.data)||(o=this._getOrReturnCtx(e,o),N(o,{code:k.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Hm(i).test(e.data)||(o=this._getOrReturnCtx(e,o),N(o,{code:k.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Rm.test(e.data)||(o=this._getOrReturnCtx(e,o),N(o,{validation:"duration",code:k.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Gm(e.data,i.version)||(o=this._getOrReturnCtx(e,o),N(o,{validation:"ip",code:k.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?zm(e.data,i.alg)||(o=this._getOrReturnCtx(e,o),N(o,{validation:"jwt",code:k.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Fm(e.data,i.version)||(o=this._getOrReturnCtx(e,o),N(o,{validation:"cidr",code:k.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?Pm.test(e.data)||(o=this._getOrReturnCtx(e,o),N(o,{validation:"base64",code:k.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Dm.test(e.data)||(o=this._getOrReturnCtx(e,o),N(o,{validation:"base64url",code:k.invalid_string,message:i.message}),r.dirty()):K.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(o=>e.test(o),{validation:n,code:k.invalid_string,...D.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...D.errToObj(e)})}url(e){return this._addCheck({kind:"url",...D.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...D.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...D.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...D.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...D.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...D.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...D.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...D.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...D.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...D.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...D.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...D.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...D.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...D.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...D.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...D.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...D.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...D.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...D.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...D.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...D.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...D.errToObj(n)})}nonempty(e){return this.min(1,D.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Ot.create=t=>new Ot({checks:[],typeName:$.ZodString,coerce:t?.coerce??!1,...W(t)});function $m(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,o=n>r?n:r,i=Number.parseInt(t.toFixed(o).replace(".","")),s=Number.parseInt(e.toFixed(o).replace(".",""));return i%s/10**o}var Xt=class t extends X{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==L.number){let i=this._getOrReturnCtx(e);return N(i,{code:k.invalid_type,expected:L.number,received:i.parsedType}),F}let r,o=new ke;for(let i of this._def.checks)i.kind==="int"?K.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),N(r,{code:k.invalid_type,expected:"integer",received:"float",message:i.message}),o.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),N(r,{code:k.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),N(r,{code:k.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="multipleOf"?$m(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),N(r,{code:k.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),N(r,{code:k.not_finite,message:i.message}),o.dirty()):K.assertNever(i);return{status:o.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,D.toString(n))}gt(e,n){return this.setLimit("min",e,!1,D.toString(n))}lte(e,n){return this.setLimit("max",e,!0,D.toString(n))}lt(e,n){return this.setLimit("max",e,!1,D.toString(n))}setLimit(e,n,r,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:D.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:D.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:D.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:D.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:D.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:D.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:D.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:D.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:D.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:D.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&K.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};Xt.create=t=>new Xt({checks:[],typeName:$.ZodNumber,coerce:t?.coerce||!1,...W(t)});var Yt=class t extends X{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==L.bigint)return this._getInvalidInput(e);let r,o=new ke;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),N(r,{code:k.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),o.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),N(r,{code:k.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),o.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),N(r,{code:k.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):K.assertNever(i);return{status:o.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return N(n,{code:k.invalid_type,expected:L.bigint,received:n.parsedType}),F}gte(e,n){return this.setLimit("min",e,!0,D.toString(n))}gt(e,n){return this.setLimit("min",e,!1,D.toString(n))}lte(e,n){return this.setLimit("max",e,!0,D.toString(n))}lt(e,n){return this.setLimit("max",e,!1,D.toString(n))}setLimit(e,n,r,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:D.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:D.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:D.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:D.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:D.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:D.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Yt.create=t=>new Yt({checks:[],typeName:$.ZodBigInt,coerce:t?.coerce??!1,...W(t)});var Kt=class extends X{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==L.boolean){let r=this._getOrReturnCtx(e);return N(r,{code:k.invalid_type,expected:L.boolean,received:r.parsedType}),F}return Ce(e.data)}};Kt.create=t=>new Kt({typeName:$.ZodBoolean,coerce:t?.coerce||!1,...W(t)});var Zt=class t extends X{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==L.date){let i=this._getOrReturnCtx(e);return N(i,{code:k.invalid_type,expected:L.date,received:i.parsedType}),F}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return N(i,{code:k.invalid_date}),F}let r=new ke,o;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(o=this._getOrReturnCtx(e,o),N(o,{code:k.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(o=this._getOrReturnCtx(e,o),N(o,{code:k.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):K.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:D.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:D.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};Zt.create=t=>new Zt({checks:[],coerce:t?.coerce||!1,typeName:$.ZodDate,...W(t)});var zn=class extends X{_parse(e){if(this._getType(e)!==L.symbol){let r=this._getOrReturnCtx(e);return N(r,{code:k.invalid_type,expected:L.symbol,received:r.parsedType}),F}return Ce(e.data)}};zn.create=t=>new zn({typeName:$.ZodSymbol,...W(t)});var Qt=class extends X{_parse(e){if(this._getType(e)!==L.undefined){let r=this._getOrReturnCtx(e);return N(r,{code:k.invalid_type,expected:L.undefined,received:r.parsedType}),F}return Ce(e.data)}};Qt.create=t=>new Qt({typeName:$.ZodUndefined,...W(t)});var Jt=class extends X{_parse(e){if(this._getType(e)!==L.null){let r=this._getOrReturnCtx(e);return N(r,{code:k.invalid_type,expected:L.null,received:r.parsedType}),F}return Ce(e.data)}};Jt.create=t=>new Jt({typeName:$.ZodNull,...W(t)});var Mt=class extends X{constructor(){super(...arguments),this._any=!0}_parse(e){return Ce(e.data)}};Mt.create=t=>new Mt({typeName:$.ZodAny,...W(t)});var Tt=class extends X{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ce(e.data)}};Tt.create=t=>new Tt({typeName:$.ZodUnknown,...W(t)});var nt=class extends X{_parse(e){let n=this._getOrReturnCtx(e);return N(n,{code:k.invalid_type,expected:L.never,received:n.parsedType}),F}};nt.create=t=>new nt({typeName:$.ZodNever,...W(t)});var Fn=class extends X{_parse(e){if(this._getType(e)!==L.undefined){let r=this._getOrReturnCtx(e);return N(r,{code:k.invalid_type,expected:L.void,received:r.parsedType}),F}return Ce(e.data)}};Fn.create=t=>new Fn({typeName:$.ZodVoid,...W(t)});var _t=class t extends X{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),o=this._def;if(n.parsedType!==L.array)return N(n,{code:k.invalid_type,expected:L.array,received:n.parsedType}),F;if(o.exactLength!==null){let s=n.data.length>o.exactLength.value,a=n.data.length<o.exactLength.value;(s||a)&&(N(n,{code:s?k.too_big:k.too_small,minimum:a?o.exactLength.value:void 0,maximum:s?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),r.dirty())}if(o.minLength!==null&&n.data.length<o.minLength.value&&(N(n,{code:k.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),r.dirty()),o.maxLength!==null&&n.data.length>o.maxLength.value&&(N(n,{code:k.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((s,a)=>o.type._parseAsync(new Ze(n,s,n.path,a)))).then(s=>ke.mergeArray(r,s));let i=[...n.data].map((s,a)=>o.type._parseSync(new Ze(n,s,n.path,a)));return ke.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:D.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:D.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:D.toString(n)}})}nonempty(e){return this.min(1,e)}};_t.create=(t,e)=>new _t({type:t,minLength:null,maxLength:null,exactLength:null,typeName:$.ZodArray,...W(e)});function Gn(t){if(t instanceof Ge){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=Ke.create(Gn(r))}return new Ge({...t._def,shape:()=>e})}else return t instanceof _t?new _t({...t._def,type:Gn(t.element)}):t instanceof Ke?Ke.create(Gn(t.unwrap())):t instanceof ft?ft.create(Gn(t.unwrap())):t instanceof pt?pt.create(t.items.map(e=>Gn(e))):t}var Ge=class t extends X{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=K.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==L.object){let d=this._getOrReturnCtx(e);return N(d,{code:k.invalid_type,expected:L.object,received:d.parsedType}),F}let{status:r,ctx:o}=this._processInputParams(e),{shape:i,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof nt&&this._def.unknownKeys==="strip"))for(let d in o.data)s.includes(d)||a.push(d);let l=[];for(let d of s){let u=i[d],m=o.data[d];l.push({key:{status:"valid",value:d},value:u._parse(new Ze(o,m,o.path,d)),alwaysSet:d in o.data})}if(this._def.catchall instanceof nt){let d=this._def.unknownKeys;if(d==="passthrough")for(let u of a)l.push({key:{status:"valid",value:u},value:{status:"valid",value:o.data[u]}});else if(d==="strict")a.length>0&&(N(o,{code:k.unrecognized_keys,keys:a}),r.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let d=this._def.catchall;for(let u of a){let m=o.data[u];l.push({key:{status:"valid",value:u},value:d._parse(new Ze(o,m,o.path,u)),alwaysSet:u in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let d=[];for(let u of l){let m=await u.key,w=await u.value;d.push({key:m,value:w,alwaysSet:u.alwaysSet})}return d}).then(d=>ke.mergeObjectSync(r,d)):ke.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return D.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let o=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:D.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:$.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of K.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of K.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return Gn(this)}partial(e){let n={};for(let r of K.objectKeys(this.shape)){let o=this.shape[r];e&&!e[r]?n[r]=o:n[r]=o.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of K.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof Ke;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return Dc(K.objectKeys(this.shape))}};Ge.create=(t,e)=>new Ge({shape:()=>t,unknownKeys:"strip",catchall:nt.create(),typeName:$.ZodObject,...W(e)});Ge.strictCreate=(t,e)=>new Ge({shape:()=>t,unknownKeys:"strict",catchall:nt.create(),typeName:$.ZodObject,...W(e)});Ge.lazycreate=(t,e)=>new Ge({shape:t,unknownKeys:"strip",catchall:nt.create(),typeName:$.ZodObject,...W(e)});var en=class extends X{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function o(i){for(let a of i)if(a.result.status==="valid")return a.result;for(let a of i)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;let s=i.map(a=>new He(a.ctx.common.issues));return N(n,{code:k.invalid_union,unionErrors:s}),F}if(n.common.async)return Promise.all(r.map(async i=>{let s={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:s}),ctx:s}})).then(o);{let i,s=[];for(let l of r){let d={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:d});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:d}),d.common.issues.length&&s.push(d.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let a=s.map(l=>new He(l));return N(n,{code:k.invalid_union,unionErrors:a}),F}}get options(){return this._def.options}};en.create=(t,e)=>new en({options:t,typeName:$.ZodUnion,...W(e)});var Et=t=>t instanceof nn?Et(t.schema):t instanceof Qe?Et(t.innerType()):t instanceof rn?[t.value]:t instanceof on?t.options:t instanceof sn?K.objectValues(t.enum):t instanceof an?Et(t._def.innerType):t instanceof Qt?[void 0]:t instanceof Jt?[null]:t instanceof Ke?[void 0,...Et(t.unwrap())]:t instanceof ft?[null,...Et(t.unwrap())]:t instanceof xr||t instanceof dn?Et(t.unwrap()):t instanceof ln?Et(t._def.innerType):[],Lo=class t extends X{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==L.object)return N(n,{code:k.invalid_type,expected:L.object,received:n.parsedType}),F;let r=this.discriminator,o=n.data[r],i=this.optionsMap.get(o);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(N(n,{code:k.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),F)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let o=new Map;for(let i of n){let s=Et(i.shape[e]);if(!s.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of s){if(o.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);o.set(a,i)}}return new t({typeName:$.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:o,...W(r)})}};function Qa(t,e){let n=ht(t),r=ht(e);if(t===e)return{valid:!0,data:t};if(n===L.object&&r===L.object){let o=K.objectKeys(e),i=K.objectKeys(t).filter(a=>o.indexOf(a)!==-1),s={...t,...e};for(let a of i){let l=Qa(t[a],e[a]);if(!l.valid)return{valid:!1};s[a]=l.data}return{valid:!0,data:s}}else if(n===L.array&&r===L.array){if(t.length!==e.length)return{valid:!1};let o=[];for(let i=0;i<t.length;i++){let s=t[i],a=e[i],l=Qa(s,a);if(!l.valid)return{valid:!1};o.push(l.data)}return{valid:!0,data:o}}else return n===L.date&&r===L.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var tn=class extends X{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),o=(i,s)=>{if(Oo(i)||Oo(s))return F;let a=Qa(i.value,s.value);return a.valid?((Mo(i)||Mo(s))&&n.dirty(),{status:n.value,value:a.data}):(N(r,{code:k.invalid_intersection_types}),F)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,s])=>o(i,s)):o(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};tn.create=(t,e,n)=>new tn({left:t,right:e,typeName:$.ZodIntersection,...W(n)});var pt=class t extends X{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==L.array)return N(r,{code:k.invalid_type,expected:L.array,received:r.parsedType}),F;if(r.data.length<this._def.items.length)return N(r,{code:k.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),F;!this._def.rest&&r.data.length>this._def.items.length&&(N(r,{code:k.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...r.data].map((s,a)=>{let l=this._def.items[a]||this._def.rest;return l?l._parse(new Ze(r,s,r.path,a)):null}).filter(s=>!!s);return r.common.async?Promise.all(i).then(s=>ke.mergeArray(n,s)):ke.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};pt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new pt({items:t,typeName:$.ZodTuple,rest:null,...W(e)})};var Po=class t extends X{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==L.object)return N(r,{code:k.invalid_type,expected:L.object,received:r.parsedType}),F;let o=[],i=this._def.keyType,s=this._def.valueType;for(let a in r.data)o.push({key:i._parse(new Ze(r,a,r.path,a)),value:s._parse(new Ze(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?ke.mergeObjectAsync(n,o):ke.mergeObjectSync(n,o)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof X?new t({keyType:e,valueType:n,typeName:$.ZodRecord,...W(r)}):new t({keyType:Ot.create(),valueType:e,typeName:$.ZodRecord,...W(n)})}},$n=class extends X{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==L.map)return N(r,{code:k.invalid_type,expected:L.map,received:r.parsedType}),F;let o=this._def.keyType,i=this._def.valueType,s=[...r.data.entries()].map(([a,l],d)=>({key:o._parse(new Ze(r,a,r.path,[d,"key"])),value:i._parse(new Ze(r,l,r.path,[d,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let l of s){let d=await l.key,u=await l.value;if(d.status==="aborted"||u.status==="aborted")return F;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(d.value,u.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let l of s){let d=l.key,u=l.value;if(d.status==="aborted"||u.status==="aborted")return F;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(d.value,u.value)}return{status:n.value,value:a}}}};$n.create=(t,e,n)=>new $n({valueType:e,keyType:t,typeName:$.ZodMap,...W(n)});var Bn=class t extends X{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==L.set)return N(r,{code:k.invalid_type,expected:L.set,received:r.parsedType}),F;let o=this._def;o.minSize!==null&&r.data.size<o.minSize.value&&(N(r,{code:k.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),n.dirty()),o.maxSize!==null&&r.data.size>o.maxSize.value&&(N(r,{code:k.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),n.dirty());let i=this._def.valueType;function s(l){let d=new Set;for(let u of l){if(u.status==="aborted")return F;u.status==="dirty"&&n.dirty(),d.add(u.value)}return{status:n.value,value:d}}let a=[...r.data.values()].map((l,d)=>i._parse(new Ze(r,l,r.path,d)));return r.common.async?Promise.all(a).then(l=>s(l)):s(a)}min(e,n){return new t({...this._def,minSize:{value:e,message:D.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:D.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};Bn.create=(t,e)=>new Bn({valueType:t,minSize:null,maxSize:null,typeName:$.ZodSet,...W(e)});var Do=class t extends X{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==L.function)return N(n,{code:k.invalid_type,expected:L.function,received:n.parsedType}),F;function r(a,l){return wr({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Un(),xt].filter(d=>!!d),issueData:{code:k.invalid_arguments,argumentsError:l}})}function o(a,l){return wr({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Un(),xt].filter(d=>!!d),issueData:{code:k.invalid_return_type,returnTypeError:l}})}let i={errorMap:n.common.contextualErrorMap},s=n.data;if(this._def.returns instanceof Lt){let a=this;return Ce(async function(...l){let d=new He([]),u=await a._def.args.parseAsync(l,i).catch(p=>{throw d.addIssue(r(l,p)),d}),m=await Reflect.apply(s,this,u);return await a._def.returns._def.type.parseAsync(m,i).catch(p=>{throw d.addIssue(o(m,p)),d})})}else{let a=this;return Ce(function(...l){let d=a._def.args.safeParse(l,i);if(!d.success)throw new He([r(l,d.error)]);let u=Reflect.apply(s,this,d.data),m=a._def.returns.safeParse(u,i);if(!m.success)throw new He([o(u,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:pt.create(e).rest(Tt.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||pt.create([]).rest(Tt.create()),returns:n||Tt.create(),typeName:$.ZodFunction,...W(r)})}},nn=class extends X{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};nn.create=(t,e)=>new nn({getter:t,typeName:$.ZodLazy,...W(e)});var rn=class extends X{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return N(n,{received:n.data,code:k.invalid_literal,expected:this._def.value}),F}return{status:"valid",value:e.data}}get value(){return this._def.value}};rn.create=(t,e)=>new rn({value:t,typeName:$.ZodLiteral,...W(e)});function Dc(t,e){return new on({values:t,typeName:$.ZodEnum,...W(e)})}var on=class t extends X{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return N(n,{expected:K.joinValues(r),received:n.parsedType,code:k.invalid_type}),F}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return N(n,{received:n.data,code:k.invalid_enum_value,options:r}),F}return Ce(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};on.create=Dc;var sn=class extends X{_parse(e){let n=K.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==L.string&&r.parsedType!==L.number){let o=K.objectValues(n);return N(r,{expected:K.joinValues(o),received:r.parsedType,code:k.invalid_type}),F}if(this._cache||(this._cache=new Set(K.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=K.objectValues(n);return N(r,{received:r.data,code:k.invalid_enum_value,options:o}),F}return Ce(e.data)}get enum(){return this._def.values}};sn.create=(t,e)=>new sn({values:t,typeName:$.ZodNativeEnum,...W(e)});var Lt=class extends X{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==L.promise&&n.common.async===!1)return N(n,{code:k.invalid_type,expected:L.promise,received:n.parsedType}),F;let r=n.parsedType===L.promise?n.data:Promise.resolve(n.data);return Ce(r.then(o=>this._def.type.parseAsync(o,{path:n.path,errorMap:n.common.contextualErrorMap})))}};Lt.create=(t,e)=>new Lt({type:t,typeName:$.ZodPromise,...W(e)});var Qe=class extends X{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===$.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),o=this._def.effect||null,i={addIssue:s=>{N(r,s),s.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),o.type==="preprocess"){let s=o.transform(r.data,i);if(r.common.async)return Promise.resolve(s).then(async a=>{if(n.value==="aborted")return F;let l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?F:l.status==="dirty"?Wt(l.value):n.value==="dirty"?Wt(l.value):l});{if(n.value==="aborted")return F;let a=this._def.schema._parseSync({data:s,path:r.path,parent:r});return a.status==="aborted"?F:a.status==="dirty"?Wt(a.value):n.value==="dirty"?Wt(a.value):a}}if(o.type==="refinement"){let s=a=>{let l=o.refinement(a,i);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?F:(a.status==="dirty"&&n.dirty(),s(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?F:(a.status==="dirty"&&n.dirty(),s(a.value).then(()=>({status:n.value,value:a.value}))))}if(o.type==="transform")if(r.common.async===!1){let s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Nt(s))return F;let a=o.transform(s.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>Nt(s)?Promise.resolve(o.transform(s.value,i)).then(a=>({status:n.value,value:a})):F);K.assertNever(o)}};Qe.create=(t,e,n)=>new Qe({schema:t,typeName:$.ZodEffects,effect:e,...W(n)});Qe.createWithPreprocess=(t,e,n)=>new Qe({schema:e,effect:{type:"preprocess",transform:t},typeName:$.ZodEffects,...W(n)});var Ke=class extends X{_parse(e){return this._getType(e)===L.undefined?Ce(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ke.create=(t,e)=>new Ke({innerType:t,typeName:$.ZodOptional,...W(e)});var ft=class extends X{_parse(e){return this._getType(e)===L.null?Ce(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ft.create=(t,e)=>new ft({innerType:t,typeName:$.ZodNullable,...W(e)});var an=class extends X{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===L.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};an.create=(t,e)=>new an({innerType:t,typeName:$.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...W(e)});var ln=class extends X{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},o=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Hn(o)?o.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new He(r.common.issues)},input:r.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new He(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};ln.create=(t,e)=>new ln({innerType:t,typeName:$.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...W(e)});var jn=class extends X{_parse(e){if(this._getType(e)!==L.nan){let r=this._getOrReturnCtx(e);return N(r,{code:k.invalid_type,expected:L.nan,received:r.parsedType}),F}return{status:"valid",value:e.data}}};jn.create=t=>new jn({typeName:$.ZodNaN,...W(t)});var Bm=Symbol("zod_brand"),xr=class extends X{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},Er=class t extends X{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?F:i.status==="dirty"?(n.dirty(),Wt(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{let o=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?F:o.status==="dirty"?(n.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:$.ZodPipeline})}},dn=class extends X{_parse(e){let n=this._def.innerType._parse(e),r=o=>(Nt(o)&&(o.value=Object.freeze(o.value)),o);return Hn(n)?n.then(o=>r(o)):r(n)}unwrap(){return this._def.innerType}};dn.create=(t,e)=>new dn({innerType:t,typeName:$.ZodReadonly,...W(e)});function Oc(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Uc(t,e={},n){return t?Mt.create().superRefine((r,o)=>{let i=t(r);if(i instanceof Promise)return i.then(s=>{if(!s){let a=Oc(e,r),l=a.fatal??n??!0;o.addIssue({code:"custom",...a,fatal:l})}});if(!i){let s=Oc(e,r),a=s.fatal??n??!0;o.addIssue({code:"custom",...s,fatal:a})}}):Mt.create()}var jm={object:Ge.lazycreate},$;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})($||($={}));var Vm=(t,e={message:`Input not instance of ${t.name}`})=>Uc(n=>n instanceof t,e),Hc=Ot.create,Gc=Xt.create,qm=jn.create,Wm=Yt.create,zc=Kt.create,Xm=Zt.create,Ym=zn.create,Km=Qt.create,Zm=Jt.create,Qm=Mt.create,Jm=Tt.create,eg=nt.create,tg=Fn.create,ng=_t.create,rg=Ge.create,og=Ge.strictCreate,ig=en.create,sg=Lo.create,ag=tn.create,lg=pt.create,dg=Po.create,cg=$n.create,ug=Bn.create,hg=Do.create,pg=nn.create,fg=rn.create,mg=on.create,gg=sn.create,vg=Lt.create,bg=Qe.create,yg=Ke.create,wg=ft.create,xg=Qe.createWithPreprocess,Eg=Er.create,Tg=()=>Hc().optional(),_g=()=>Gc().optional(),Sg=()=>zc().optional(),Ag={string:(t=>Ot.create({...t,coerce:!0})),number:(t=>Xt.create({...t,coerce:!0})),boolean:(t=>Kt.create({...t,coerce:!0})),bigint:(t=>Yt.create({...t,coerce:!0})),date:(t=>Zt.create({...t,coerce:!0}))};var kg=F;var Rg=c.record(c.any()),cn=Rg.optional();function Fc(t,e){return e===void 0?t:t===void 0?{...e}:{...t,...e}}var Ig=c.object({name:c.string(),arguments:c.string()}),Cg=c.object({id:c.string(),type:c.literal("function"),function:Ig,encryptedValue:c.string().optional(),metadata:cn}),Uo=c.object({id:c.string(),role:c.string(),content:c.string().optional(),name:c.string().optional(),encryptedValue:c.string().optional(),subagentRunId:c.string().optional(),metadata:cn}),Ng=c.object({type:c.literal("text"),text:c.string()}),Og=c.object({type:c.literal("data"),value:c.string(),mimeType:c.string()}),Mg=c.object({type:c.literal("url"),value:c.string(),mimeType:c.string().optional()}),Ho=c.discriminatedUnion("type",[Og,Mg]),Lg=c.object({type:c.literal("image"),source:Ho,metadata:c.unknown().optional()}),Pg=c.object({type:c.literal("audio"),source:Ho,metadata:c.unknown().optional()}),Dg=c.object({type:c.literal("video"),source:Ho,metadata:c.unknown().optional()}),Ug=c.object({type:c.literal("document"),source:Ho,metadata:c.unknown().optional()});var $c=c.object({type:c.literal("binary"),mimeType:c.string(),id:c.string().optional(),url:c.string().optional(),data:c.string().optional(),filename:c.string().optional()}),Bc=(t,e)=>{!t.id&&!t.url&&!t.data&&e.addIssue({code:c.ZodIssueCode.custom,message:"BinaryInputContent requires at least one of id, url, or data.",path:["id"]})},l_=$c.superRefine((t,e)=>{Bc(t,e)}),Hg=c.discriminatedUnion("type",[Ng,Lg,Pg,Dg,Ug,$c]),Gg=Hg.superRefine((t,e)=>{t.type==="binary"&&Bc(t,e)}),zg=Uo.extend({role:c.literal("developer"),content:c.string()}),Fg=Uo.extend({role:c.literal("system"),content:c.string()}),$g=Uo.extend({role:c.literal("assistant"),content:c.string().optional(),toolCalls:c.array(Cg).optional()}),Bg=Uo.extend({role:c.literal("user"),content:c.union([c.string(),c.array(Gg)])}),jg=c.object({id:c.string(),content:c.string(),role:c.literal("tool"),toolCallId:c.string(),error:c.string().optional(),encryptedValue:c.string().optional(),subagentRunId:c.string().optional(),metadata:cn}),Vg=c.object({id:c.string(),role:c.literal("activity"),activityType:c.string(),content:c.record(c.any()),subagentRunId:c.string().optional(),metadata:cn}),qg=c.object({id:c.string(),role:c.literal("reasoning"),content:c.string(),encryptedValue:c.string().optional(),subagentRunId:c.string().optional(),metadata:cn}),jc=c.discriminatedUnion("role",[zg,Fg,$g,Bg,jg,Vg,qg]),d_=c.union([c.literal("developer"),c.literal("system"),c.literal("assistant"),c.literal("user"),c.literal("tool"),c.literal("activity"),c.literal("reasoning")]),Wg=c.object({description:c.string(),value:c.string()}),Vc=c.object({name:c.string(),description:c.string(),parameters:c.any(),metadata:c.record(c.any()).optional()}),Xg=c.object({id:c.string(),reason:c.string(),message:c.string().optional(),toolCallId:c.string().optional(),responseSchema:c.record(c.any()).optional(),expiresAt:c.string().optional(),metadata:c.record(c.any()).optional(),subagentRunId:c.string().optional()}),Yg=c.object({interruptId:c.string(),status:c.enum(["resolved","cancelled"]),payload:c.any().optional(),metadata:cn}),Kg=c.object({threadId:c.string(),runId:c.string(),parentRunId:c.string().optional(),state:c.any().transform(t=>t??void 0),messages:c.array(jc),tools:c.array(Vc),context:c.array(Wg),forwardedProps:c.any(),resume:c.array(Yg).optional()}),Zg=c.any(),V=class extends Error{constructor(t){super(t)}},Ja=class extends V{constructor(){super("Connect not implemented. This method is not supported by the current agent.")}},Qg=c.object({name:c.string(),description:c.string().optional()}),Jg=c.object({name:c.string().optional(),type:c.string().optional(),description:c.string().optional(),version:c.string().optional(),provider:c.string().optional(),documentationUrl:c.string().optional(),metadata:c.record(c.unknown()).optional()}),ev=c.object({streaming:c.boolean().optional(),websocket:c.boolean().optional(),httpBinary:c.boolean().optional(),pushNotifications:c.boolean().optional(),resumable:c.boolean().optional()}),tv=c.object({supported:c.boolean().optional(),items:c.array(Vc).optional(),parallelCalls:c.boolean().optional(),clientProvided:c.boolean().optional()}),nv=c.object({structuredOutput:c.boolean().optional(),supportedMimeTypes:c.array(c.string()).optional()}),rv=c.object({snapshots:c.boolean().optional(),deltas:c.boolean().optional(),memory:c.boolean().optional(),persistentState:c.boolean().optional()}),ov=c.object({supported:c.boolean().optional(),delegation:c.boolean().optional(),handoffs:c.boolean().optional(),subAgents:c.array(Qg).optional()}),iv=c.object({supported:c.boolean().optional(),streaming:c.boolean().optional(),encrypted:c.boolean().optional()}),sv=c.object({image:c.boolean().optional(),audio:c.boolean().optional(),video:c.boolean().optional(),pdf:c.boolean().optional(),file:c.boolean().optional()}),av=c.object({image:c.boolean().optional(),audio:c.boolean().optional()}),lv=c.object({input:sv.optional(),output:av.optional()}),dv=c.object({codeExecution:c.boolean().optional(),sandboxed:c.boolean().optional(),maxIterations:c.number().optional(),maxExecutionTime:c.number().optional()}),cv=c.object({supported:c.boolean().optional(),approvals:c.boolean().optional(),interventions:c.boolean().optional(),feedback:c.boolean().optional(),interrupts:c.boolean().optional(),approveWithEdits:c.boolean().optional()}),c_=c.object({identity:Jg.optional(),transport:ev.optional(),tools:tv.optional(),output:nv.optional(),state:rv.optional(),multiAgent:ov.optional(),reasoning:iv.optional(),multimodal:lv.optional(),execution:dv.optional(),humanInTheLoop:cv.optional(),custom:c.record(c.unknown()).optional()}),qc=c.union([c.literal("developer"),c.literal("system"),c.literal("assistant"),c.literal("user")]),g=(function(t){return t.TEXT_MESSAGE_START="TEXT_MESSAGE_START",t.TEXT_MESSAGE_CONTENT="TEXT_MESSAGE_CONTENT",t.TEXT_MESSAGE_END="TEXT_MESSAGE_END",t.TEXT_MESSAGE_CHUNK="TEXT_MESSAGE_CHUNK",t.TOOL_CALL_START="TOOL_CALL_START",t.TOOL_CALL_ARGS="TOOL_CALL_ARGS",t.TOOL_CALL_END="TOOL_CALL_END",t.TOOL_CALL_CHUNK="TOOL_CALL_CHUNK",t.TOOL_CALL_RESULT="TOOL_CALL_RESULT",t.THINKING_START="THINKING_START",t.THINKING_END="THINKING_END",t.THINKING_TEXT_MESSAGE_START="THINKING_TEXT_MESSAGE_START",t.THINKING_TEXT_MESSAGE_CONTENT="THINKING_TEXT_MESSAGE_CONTENT",t.THINKING_TEXT_MESSAGE_END="THINKING_TEXT_MESSAGE_END",t.STATE_SNAPSHOT="STATE_SNAPSHOT",t.STATE_DELTA="STATE_DELTA",t.MESSAGES_SNAPSHOT="MESSAGES_SNAPSHOT",t.ACTIVITY_SNAPSHOT="ACTIVITY_SNAPSHOT",t.ACTIVITY_DELTA="ACTIVITY_DELTA",t.RAW="RAW",t.CUSTOM="CUSTOM",t.RUN_STARTED="RUN_STARTED",t.RUN_FINISHED="RUN_FINISHED",t.RUN_ERROR="RUN_ERROR",t.STEP_STARTED="STEP_STARTED",t.STEP_FINISHED="STEP_FINISHED",t.REASONING_START="REASONING_START",t.REASONING_MESSAGE_START="REASONING_MESSAGE_START",t.REASONING_MESSAGE_CONTENT="REASONING_MESSAGE_CONTENT",t.REASONING_MESSAGE_END="REASONING_MESSAGE_END",t.REASONING_MESSAGE_CHUNK="REASONING_MESSAGE_CHUNK",t.REASONING_END="REASONING_END",t.REASONING_ENCRYPTED_VALUE="REASONING_ENCRYPTED_VALUE",t.SUBAGENT_STARTED="SUBAGENT_STARTED",t.SUBAGENT_FINISHED="SUBAGENT_FINISHED",t.SUBAGENT_ERROR="SUBAGENT_ERROR",t})({}),Q=c.object({type:c.nativeEnum(g),timestamp:c.number().optional(),rawEvent:c.any().optional(),metadata:cn}).passthrough(),uv=Q.extend({type:c.literal(g.TEXT_MESSAGE_START),messageId:c.string(),role:qc.default("assistant"),name:c.string().optional(),subagentRunId:c.string().optional()}),Wc=Q.extend({type:c.literal(g.TEXT_MESSAGE_CONTENT),messageId:c.string(),delta:c.string(),subagentRunId:c.string().optional()}),hv=Q.extend({type:c.literal(g.TEXT_MESSAGE_END),messageId:c.string(),subagentRunId:c.string().optional()}),pv=Q.extend({type:c.literal(g.TEXT_MESSAGE_CHUNK),messageId:c.string().optional(),role:qc.optional(),delta:c.string().optional(),name:c.string().optional(),subagentRunId:c.string().optional()}),fv=Q.extend({type:c.literal(g.THINKING_TEXT_MESSAGE_START)}),mv=Wc.omit({messageId:!0,type:!0,subagentRunId:!0}).extend({type:c.literal(g.THINKING_TEXT_MESSAGE_CONTENT)}),gv=Q.extend({type:c.literal(g.THINKING_TEXT_MESSAGE_END)}),vv=Q.extend({type:c.literal(g.TOOL_CALL_START),toolCallId:c.string(),toolCallName:c.string(),parentMessageId:c.string().nullable().optional().transform(t=>t??void 0),subagentRunId:c.string().optional()}),bv=Q.extend({type:c.literal(g.TOOL_CALL_ARGS),toolCallId:c.string(),delta:c.string(),subagentRunId:c.string().optional()}),yv=Q.extend({type:c.literal(g.TOOL_CALL_END),toolCallId:c.string(),subagentRunId:c.string().optional()}),wv=Q.extend({messageId:c.string(),type:c.literal(g.TOOL_CALL_RESULT),toolCallId:c.string(),content:c.string(),role:c.literal("tool").optional(),subagentRunId:c.string().optional()}),xv=Q.extend({type:c.literal(g.TOOL_CALL_CHUNK),toolCallId:c.string().optional(),toolCallName:c.string().optional(),parentMessageId:c.string().nullable().optional().transform(t=>t??void 0),delta:c.string().optional(),subagentRunId:c.string().optional()}),Ev=Q.extend({type:c.literal(g.THINKING_START),title:c.string().optional()}),Tv=Q.extend({type:c.literal(g.THINKING_END)}),_v=Q.extend({type:c.literal(g.STATE_SNAPSHOT),snapshot:Zg,subagentRunId:c.string().optional()}),Sv=Q.extend({type:c.literal(g.STATE_DELTA),delta:c.array(c.any()),subagentRunId:c.string().optional()}),Av=Q.extend({type:c.literal(g.MESSAGES_SNAPSHOT),messages:c.array(jc)}),kv=Q.extend({type:c.literal(g.ACTIVITY_SNAPSHOT),messageId:c.string(),activityType:c.string(),content:c.record(c.any()),replace:c.boolean().optional().default(!0),subagentRunId:c.string().optional()}),Rv=Q.extend({type:c.literal(g.ACTIVITY_DELTA),messageId:c.string(),activityType:c.string(),patch:c.array(c.any()),subagentRunId:c.string().optional()}),Iv=Q.extend({type:c.literal(g.RAW),event:c.any(),source:c.string().optional(),subagentRunId:c.string().optional()}),Cv=Q.extend({type:c.literal(g.CUSTOM),name:c.string(),value:c.any(),subagentRunId:c.string().optional()}),Nv=Q.extend({type:c.literal(g.RUN_STARTED),threadId:c.string(),runId:c.string(),parentRunId:c.string().optional(),input:Kg.optional()}),Ov=c.object({type:c.literal("success")}).strict(),Mv=c.object({type:c.literal("interrupt"),interrupts:c.array(Xg).min(1)}).strict(),Lv=c.discriminatedUnion("type",[Ov,Mv]),Xc=c.object({provider:c.string().optional(),model:c.string().optional(),inputTokens:c.number().int().nonnegative().optional(),outputTokens:c.number().int().nonnegative().optional(),totalTokens:c.number().int().nonnegative().optional(),reasoningTokens:c.number().int().nonnegative().optional(),cachedInputTokens:c.number().int().nonnegative().optional()}),Pv=Q.extend({type:c.literal(g.RUN_FINISHED),threadId:c.string(),runId:c.string(),result:c.any().optional(),outcome:Lv.nullable().optional().transform(t=>t??void 0),usage:c.array(Xc).optional()}),Dv=Q.extend({type:c.literal(g.RUN_ERROR),message:c.string(),code:c.string().optional(),usage:c.array(Xc).optional()}),Uv=Q.extend({type:c.literal(g.STEP_STARTED),stepName:c.string(),subagentRunId:c.string().optional()}),Hv=Q.extend({type:c.literal(g.STEP_FINISHED),stepName:c.string(),subagentRunId:c.string().optional()}),Gv=c.union([c.literal("tool-call"),c.literal("message")]),zv=Q.extend({type:c.literal(g.REASONING_START),messageId:c.string(),subagentRunId:c.string().optional()}),Fv=Q.extend({type:c.literal(g.REASONING_MESSAGE_START),messageId:c.string(),role:c.literal("reasoning"),subagentRunId:c.string().optional()}),$v=Q.extend({type:c.literal(g.REASONING_MESSAGE_CONTENT),messageId:c.string(),delta:c.string(),subagentRunId:c.string().optional()}),Bv=Q.extend({type:c.literal(g.REASONING_MESSAGE_END),messageId:c.string(),subagentRunId:c.string().optional()}),jv=Q.extend({type:c.literal(g.REASONING_MESSAGE_CHUNK),messageId:c.string().optional(),delta:c.string().optional(),subagentRunId:c.string().optional()}),Vv=Q.extend({type:c.literal(g.REASONING_END),messageId:c.string(),subagentRunId:c.string().optional()}),qv=Q.extend({type:c.literal(g.REASONING_ENCRYPTED_VALUE),subtype:Gv,entityId:c.string(),encryptedValue:c.string(),subagentRunId:c.string().optional()}),Wv=Q.extend({type:c.literal(g.SUBAGENT_STARTED),subagentRunId:c.string(),name:c.string(),description:c.string().optional(),parentSubagentRunId:c.string().optional(),parentToolCallId:c.string().optional(),parentMessageId:c.string().optional()}),Xv=c.object({type:c.literal("success")}).strict(),Yv=c.object({type:c.literal("suspended"),interruptIds:c.array(c.string()).optional()}).strict(),Kv=c.discriminatedUnion("type",[Xv,Yv]),Zv=Q.extend({type:c.literal(g.SUBAGENT_FINISHED),subagentRunId:c.string(),result:c.any().optional(),outcome:Kv.optional()}),Qv=Q.extend({type:c.literal(g.SUBAGENT_ERROR),subagentRunId:c.string(),message:c.string(),code:c.string().optional()}),Go=c.discriminatedUnion("type",[uv,Wc,hv,pv,Ev,Tv,fv,mv,gv,vv,bv,yv,xv,wv,_v,Sv,Av,kv,Rv,Iv,Cv,Nv,Pv,Dv,Uv,Hv,zv,Fv,$v,Bv,jv,Vv,qv,Wv,Zv,Qv]);var el={};ba(el,{JsonPatchError:()=>me,_areEquals:()=>Sr,applyOperation:()=>un,applyPatch:()=>qo,applyReducer:()=>rb,deepClone:()=>tb,getValueByPointer:()=>jo,validate:()=>Kc,validator:()=>Vo});var Jv=(function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,o){r.__proto__=o}||function(r,o){for(var i in o)o.hasOwnProperty(i)&&(r[i]=o[i])},t(e,n)};return function(e,n){t(e,n);function r(){this.constructor=e}e.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})(),eb=Object.prototype.hasOwnProperty;function Fo(t,e){return eb.call(t,e)}function $o(t){if(Array.isArray(t)){for(var e=new Array(t.length),n=0;n<e.length;n++)e[n]=""+n;return e}if(Object.keys)return Object.keys(t);var r=[];for(var o in t)Fo(t,o)&&r.push(o);return r}function Re(t){switch(typeof t){case"object":return JSON.parse(JSON.stringify(t));case"undefined":return null;default:return t}}function Bo(t){for(var e=0,n=t.length,r;e<n;){if(r=t.charCodeAt(e),r>=48&&r<=57){e++;continue}return!1}return!0}function mt(t){return t.indexOf("/")===-1&&t.indexOf("~")===-1?t:t.replace(/~/g,"~0").replace(/\//g,"~1")}function Tr(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function zo(t){if(t===void 0)return!0;if(t){if(Array.isArray(t)){for(var e=0,n=t.length;e<n;e++)if(zo(t[e]))return!0}else if(typeof t=="object"){for(var r=$o(t),o=r.length,i=0;i<o;i++)if(zo(t[r[i]]))return!0}}return!1}function Yc(t,e){var n=[t];for(var r in e){var o=typeof e[r]=="object"?JSON.stringify(e[r],null,2):e[r];typeof o<"u"&&n.push(r+": "+o)}return n.join(`
|
|
2
|
-
`)}var _r=(function(t){Jv(e,t);function e(n,r,o,i,s){var a=this.constructor,l=t.call(this,Yc(n,{name:r,index:o,operation:i,tree:s}))||this;return l.name=r,l.index=o,l.operation=i,l.tree=s,Object.setPrototypeOf(l,a.prototype),l.message=Yc(n,{name:r,index:o,operation:i,tree:s}),l}return e})(Error);var me=_r,tb=Re,Vn={add:function(t,e,n){return t[e]=this.value,{newDocument:n}},remove:function(t,e,n){var r=t[e];return delete t[e],{newDocument:n,removed:r}},replace:function(t,e,n){var r=t[e];return t[e]=this.value,{newDocument:n,removed:r}},move:function(t,e,n){var r=jo(n,this.path);r&&(r=Re(r));var o=un(n,{op:"remove",path:this.from}).removed;return un(n,{op:"add",path:this.path,value:o}),{newDocument:n,removed:r}},copy:function(t,e,n){var r=jo(n,this.from);return un(n,{op:"add",path:this.path,value:Re(r)}),{newDocument:n}},test:function(t,e,n){return{newDocument:n,test:Sr(t[e],this.value)}},_get:function(t,e,n){return this.value=t[e],{newDocument:n}}},nb={add:function(t,e,n){return Bo(e)?t.splice(e,0,this.value):t[e]=this.value,{newDocument:n,index:e}},remove:function(t,e,n){var r=t.splice(e,1);return{newDocument:n,removed:r[0]}},replace:function(t,e,n){var r=t[e];return t[e]=this.value,{newDocument:n,removed:r}},move:Vn.move,copy:Vn.copy,test:Vn.test,_get:Vn._get};function jo(t,e){if(e=="")return t;var n={op:"_get",path:e};return un(t,n),n.value}function un(t,e,n,r,o,i){if(n===void 0&&(n=!1),r===void 0&&(r=!0),o===void 0&&(o=!0),i===void 0&&(i=0),n&&(typeof n=="function"?n(e,0,t,e.path):Vo(e,0)),e.path===""){var s={newDocument:t};if(e.op==="add")return s.newDocument=e.value,s;if(e.op==="replace")return s.newDocument=e.value,s.removed=t,s;if(e.op==="move"||e.op==="copy")return s.newDocument=jo(t,e.from),e.op==="move"&&(s.removed=t),s;if(e.op==="test"){if(s.test=Sr(t,e.value),s.test===!1)throw new me("Test operation failed","TEST_OPERATION_FAILED",i,e,t);return s.newDocument=t,s}else{if(e.op==="remove")return s.removed=t,s.newDocument=null,s;if(e.op==="_get")return e.value=t,s;if(n)throw new me("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",i,e,t);return s}}else{r||(t=Re(t));var a=e.path||"",l=a.split("/"),d=t,u=1,m=l.length,w=void 0,p=void 0,h=void 0;for(typeof n=="function"?h=n:h=Vo;;){if(p=l[u],p&&p.indexOf("~")!=-1&&(p=Tr(p)),o&&(p=="__proto__"||p=="prototype"&&u>0&&l[u-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(n&&w===void 0&&(d[p]===void 0?w=l.slice(0,u).join("/"):u==m-1&&(w=e.path),w!==void 0&&h(e,0,t,w)),u++,Array.isArray(d)){if(p==="-")p=d.length;else{if(n&&!Bo(p))throw new me("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",i,e,t);Bo(p)&&(p=~~p)}if(u>=m){if(n&&e.op==="add"&&p>d.length)throw new me("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",i,e,t);var s=nb[e.op].call(e,d,p,t);if(s.test===!1)throw new me("Test operation failed","TEST_OPERATION_FAILED",i,e,t);return s}}else if(u>=m){var s=Vn[e.op].call(e,d,p,t);if(s.test===!1)throw new me("Test operation failed","TEST_OPERATION_FAILED",i,e,t);return s}if(d=d[p],n&&u<m&&(!d||typeof d!="object"))throw new me("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",i,e,t)}}}function qo(t,e,n,r,o){if(r===void 0&&(r=!0),o===void 0&&(o=!0),n&&!Array.isArray(e))throw new me("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");r||(t=Re(t));for(var i=new Array(e.length),s=0,a=e.length;s<a;s++)i[s]=un(t,e[s],n,!0,o,s),t=i[s].newDocument;return i.newDocument=t,i}function rb(t,e,n){var r=un(t,e);if(r.test===!1)throw new me("Test operation failed","TEST_OPERATION_FAILED",n,e,t);return r.newDocument}function Vo(t,e,n,r){if(typeof t!="object"||t===null||Array.isArray(t))throw new me("Operation is not an object","OPERATION_NOT_AN_OBJECT",e,t,n);if(Vn[t.op]){if(typeof t.path!="string")throw new me("Operation `path` property is not a string","OPERATION_PATH_INVALID",e,t,n);if(t.path.indexOf("/")!==0&&t.path.length>0)throw new me('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",e,t,n);if((t.op==="move"||t.op==="copy")&&typeof t.from!="string")throw new me("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",e,t,n);if((t.op==="add"||t.op==="replace"||t.op==="test")&&t.value===void 0)throw new me("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",e,t,n);if((t.op==="add"||t.op==="replace"||t.op==="test")&&zo(t.value))throw new me("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",e,t,n);if(n){if(t.op=="add"){var o=t.path.split("/").length,i=r.split("/").length;if(o!==i+1&&o!==i)throw new me("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",e,t,n)}else if(t.op==="replace"||t.op==="remove"||t.op==="_get"){if(t.path!==r)throw new me("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",e,t,n)}else if(t.op==="move"||t.op==="copy"){var s={op:"_get",path:t.from,value:void 0},a=Kc([s],n);if(a&&a.name==="OPERATION_PATH_UNRESOLVABLE")throw new me("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",e,t,n)}}}else throw new me("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",e,t,n)}function Kc(t,e,n){try{if(!Array.isArray(t))throw new me("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(e)qo(Re(e),Re(t),n||!0);else{n=n||Vo;for(var r=0;r<t.length;r++)n(t[r],r,e,void 0)}}catch(o){if(o instanceof me)return o;throw o}}function Sr(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){var n=Array.isArray(t),r=Array.isArray(e),o,i,s;if(n&&r){if(i=t.length,i!=e.length)return!1;for(o=i;o--!==0;)if(!Sr(t[o],e[o]))return!1;return!0}if(n!=r)return!1;var a=Object.keys(t);if(i=a.length,i!==Object.keys(e).length)return!1;for(o=i;o--!==0;)if(!e.hasOwnProperty(a[o]))return!1;for(o=i;o--!==0;)if(s=a[o],!Sr(t[s],e[s]))return!1;return!0}return t!==t&&e!==e}var ol={};ba(ol,{compare:()=>ub,generate:()=>tl,observe:()=>cb,unobserve:()=>db});var nl=new WeakMap,ob=(function(){function t(e){this.observers=new Map,this.obj=e}return t})(),ib=(function(){function t(e,n){this.callback=e,this.observer=n}return t})();function sb(t){return nl.get(t)}function ab(t,e){return t.observers.get(e)}function lb(t,e){t.observers.delete(e.callback)}function db(t,e){e.unobserve()}function cb(t,e){var n=[],r,o=sb(t);if(!o)o=new ob(t),nl.set(t,o);else{var i=ab(o,e);r=i&&i.observer}if(r)return r;if(r={},o.value=Re(t),e){r.callback=e,r.next=null;var s=function(){tl(r)},a=function(){clearTimeout(r.next),r.next=setTimeout(s)};typeof window<"u"&&(window.addEventListener("mouseup",a),window.addEventListener("keyup",a),window.addEventListener("mousedown",a),window.addEventListener("keydown",a),window.addEventListener("change",a))}return r.patches=n,r.object=t,r.unobserve=function(){tl(r),clearTimeout(r.next),lb(o,r),typeof window<"u"&&(window.removeEventListener("mouseup",a),window.removeEventListener("keyup",a),window.removeEventListener("mousedown",a),window.removeEventListener("keydown",a),window.removeEventListener("change",a))},o.observers.set(e,new ib(e,r)),r}function tl(t,e){e===void 0&&(e=!1);var n=nl.get(t.object);rl(n.value,t.object,t.patches,"",e),t.patches.length&&qo(n.value,t.patches);var r=t.patches;return r.length>0&&(t.patches=[],t.callback&&t.callback(r)),r}function rl(t,e,n,r,o){if(e!==t){typeof e.toJSON=="function"&&(e=e.toJSON());for(var i=$o(e),s=$o(t),a=!1,l=!1,d=s.length-1;d>=0;d--){var u=s[d],m=t[u];if(Fo(e,u)&&!(e[u]===void 0&&m!==void 0&&Array.isArray(e)===!1)){var w=e[u];typeof m=="object"&&m!=null&&typeof w=="object"&&w!=null&&Array.isArray(m)===Array.isArray(w)?rl(m,w,n,r+"/"+mt(u),o):m!==w&&(a=!0,o&&n.push({op:"test",path:r+"/"+mt(u),value:Re(m)}),n.push({op:"replace",path:r+"/"+mt(u),value:Re(w)}))}else Array.isArray(t)===Array.isArray(e)?(o&&n.push({op:"test",path:r+"/"+mt(u),value:Re(m)}),n.push({op:"remove",path:r+"/"+mt(u)}),l=!0):(o&&n.push({op:"test",path:r,value:t}),n.push({op:"replace",path:r,value:e}),a=!0)}if(!(!l&&i.length==s.length))for(var d=0;d<i.length;d++){var u=i[d];!Fo(t,u)&&e[u]!==void 0&&n.push({op:"add",path:r+"/"+mt(u),value:Re(e[u])})}}}function ub(t,e,n){n===void 0&&(n=!1);var r=[];return rl(t,e,r,"",n),r}var Wo=Object.assign({},el,ol,{JsonPatchError:_r,deepClone:Re,escapePathComponent:mt,unescapePathComponent:Tr});var il=function(t,e){return il=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])},il(t,e)};function gt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");il(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function Zc(t,e,n,r){function o(i){return i instanceof n?i:new n(function(s){s(i)})}return new(n||(n=Promise))(function(i,s){function a(u){try{d(r.next(u))}catch(m){s(m)}}function l(u){try{d(r.throw(u))}catch(m){s(m)}}function d(u){u.done?i(u.value):o(u.value).then(a,l)}d((r=r.apply(t,e||[])).next())})}function Xo(t,e){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(d){return function(u){return l([d,u])}}function l(d){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,d[0]&&(n=0)),n;)try{if(r=1,o&&(i=d[0]&2?o.return:d[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,d[1])).done)return i;switch(o=0,i&&(d=[d[0]&2,i.value]),d[0]){case 0:case 1:i=d;break;case 4:return n.label++,{value:d[1],done:!1};case 5:n.label++,o=d[1],d=[0];continue;case 7:d=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(d[0]===6||d[0]===2)){n=0;continue}if(d[0]===3&&(!i||d[1]>i[0]&&d[1]<i[3])){n.label=d[1];break}if(d[0]===6&&n.label<i[1]){n.label=i[1],i=d;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(d);break}i[2]&&n.ops.pop(),n.trys.pop();continue}d=e.call(t,n)}catch(u){d=[6,u],o=0}finally{r=i=0}if(d[0]&5)throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}}function St(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function qn(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),o,i=[],s;try{for(;(e===void 0||e-- >0)&&!(o=r.next()).done;)i.push(o.value)}catch(a){s={error:a}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(s)throw s.error}}return i}function Wn(t,e,n){if(n||arguments.length===2)for(var r=0,o=e.length,i;r<o;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return t.concat(i||Array.prototype.slice.call(e))}function hn(t){return this instanceof hn?(this.v=t,this):new hn(t)}function Qc(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(t,e||[]),o,i=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",s),o[Symbol.asyncIterator]=function(){return this},o;function s(p){return function(h){return Promise.resolve(h).then(p,m)}}function a(p,h){r[p]&&(o[p]=function(v){return new Promise(function(x,S){i.push([p,v,x,S])>1||l(p,v)})},h&&(o[p]=h(o[p])))}function l(p,h){try{d(r[p](h))}catch(v){w(i[0][3],v)}}function d(p){p.value instanceof hn?Promise.resolve(p.value.v).then(u,m):w(i[0][2],p)}function u(p){l("next",p)}function m(p){l("throw",p)}function w(p,h){p(h),i.shift(),i.length&&l(i[0][0],i[0][1])}}function Jc(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof St=="function"?St(t):t[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(i){n[i]=t[i]&&function(s){return new Promise(function(a,l){s=t[i](s),o(a,l,s.done,s.value)})}}function o(i,s,a,l){Promise.resolve(l).then(function(d){i({value:d,done:a})},s)}}function Y(t){return typeof t=="function"}function Xn(t){var e=function(r){Error.call(r),r.stack=new Error().stack},n=t(e);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var Yo=Xn(function(t){return function(n){t(this),this.message=n?n.length+` errors occurred during unsubscription:
|
|
3
|
-
`+n.map(function(r
|
|
4
|
-
`):"",this.name="UnsubscriptionError",this.errors=n}});function Ar(t,e){if(t){var n=t.indexOf(e);0<=n&&t.splice(n,1)}}var Yn=(function(){function t(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var e,n,r,o,i;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var a=St(s),l=a.next();!l.done;l=a.next()){var d=l.value;d.remove(this)}}catch(v){e={error:v}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}else s.remove(this);var u=this.initialTeardown;if(Y(u))try{u()}catch(v){i=v instanceof Yo?v.errors:[v]}var m=this._finalizers;if(m){this._finalizers=null;try{for(var w=St(m),p=w.next();!p.done;p=w.next()){var h=p.value;try{eu(h)}catch(v){i=i??[],v instanceof Yo?i=Wn(Wn([],qn(i)),qn(v.errors)):i.push(v)}}}catch(v){r={error:v}}finally{try{p&&!p.done&&(o=w.return)&&o.call(w)}finally{if(r)throw r.error}}}if(i)throw new Yo(i)}},t.prototype.add=function(e){var n;if(e&&e!==this)if(this.closed)eu(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(e)}},t.prototype._hasParent=function(e){var n=this._parentage;return n===e||Array.isArray(n)&&n.includes(e)},t.prototype._addParent=function(e){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(e),n):n?[n,e]:e},t.prototype._removeParent=function(e){var n=this._parentage;n===e?this._parentage=null:Array.isArray(n)&&Ar(n,e)},t.prototype.remove=function(e){var n=this._finalizers;n&&Ar(n,e),e instanceof t&&e._removeParent(this)},t.EMPTY=(function(){var e=new t;return e.closed=!0,e})(),t})();var sl=Yn.EMPTY;function Ko(t){return t instanceof Yn||t&&"closed"in t&&Y(t.remove)&&Y(t.add)&&Y(t.unsubscribe)}function eu(t){Y(t)?t():t.unsubscribe()}var rt={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var Kn={setTimeout:function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=Kn.delegate;return o?.setTimeout?o.setTimeout.apply(o,Wn([t,e],qn(n))):setTimeout.apply(void 0,Wn([t,e],qn(n)))},clearTimeout:function(t){var e=Kn.delegate;return(e?.clearTimeout||clearTimeout)(t)},delegate:void 0};function Zo(t){Kn.setTimeout(function(){var e=rt.onUnhandledError;if(e)e(t);else throw t})}function kr(){}var tu=(function(){return al("C",void 0,void 0)})();function nu(t){return al("E",void 0,t)}function ru(t){return al("N",t,void 0)}function al(t,e,n){return{kind:t,value:e,error:n}}var pn=null;function Zn(t){if(rt.useDeprecatedSynchronousErrorHandling){var e=!pn;if(e&&(pn={errorThrown:!1,error:null}),t(),e){var n=pn,r=n.errorThrown,o=n.error;if(pn=null,r)throw o}}else t()}function ou(t){rt.useDeprecatedSynchronousErrorHandling&&pn&&(pn.errorThrown=!0,pn.error=t)}var Rr=(function(t){gt(e,t);function e(n){var r=t.call(this)||this;return r.isStopped=!1,n?(r.destination=n,Ko(n)&&n.add(r)):r.destination=mb,r}return e.create=function(n,r,o){return new Jo(n,r,o)},e.prototype.next=function(n){this.isStopped?dl(ru(n),this):this._next(n)},e.prototype.error=function(n){this.isStopped?dl(nu(n),this):(this.isStopped=!0,this._error(n))},e.prototype.complete=function(){this.isStopped?dl(tu,this):(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(n){this.destination.next(n)},e.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e})(Yn);var hb=Function.prototype.bind;function ll(t,e){return hb.call(t,e)}var pb=(function(){function t(e){this.partialObserver=e}return t.prototype.next=function(e){var n=this.partialObserver;if(n.next)try{n.next(e)}catch(r){Qo(r)}},t.prototype.error=function(e){var n=this.partialObserver;if(n.error)try{n.error(e)}catch(r){Qo(r)}else Qo(e)},t.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(n){Qo(n)}},t})(),Jo=(function(t){gt(e,t);function e(n,r,o){var i=t.call(this)||this,s;if(Y(n)||!n)s={next:n??void 0,error:r??void 0,complete:o??void 0};else{var a;i&&rt.useDeprecatedNextContext?(a=Object.create(n),a.unsubscribe=function(){return i.unsubscribe()},s={next:n.next&&ll(n.next,a),error:n.error&&ll(n.error,a),complete:n.complete&&ll(n.complete,a)}):s=n}return i.destination=new pb(s),i}return e})(Rr);function Qo(t){rt.useDeprecatedSynchronousErrorHandling?ou(t):Zo(t)}function fb(t){throw t}function dl(t,e){var n=rt.onStoppedNotification;n&&Kn.setTimeout(function(){return n(t,e)})}var mb={closed:!0,next:kr,error:fb,complete:kr};var Qn=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Jn(t){return t}function ei(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return cl(t)}function cl(t){return t.length===0?Jn:t.length===1?t[0]:function(n){return t.reduce(function(r,o){return o(r)},n)}}var ce=(function(){function t(e){e&&(this._subscribe=e)}return t.prototype.lift=function(e){var n=new t;return n.source=this,n.operator=e,n},t.prototype.subscribe=function(e,n,r){var o=this,i=vb(e)?e:new Jo(e,n,r);return Zn(function(){var s=o,a=s.operator,l=s.source;i.add(a?a.call(i,l):l?o._subscribe(i):o._trySubscribe(i))}),i},t.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(n){e.error(n)}},t.prototype.forEach=function(e,n){var r=this;return n=iu(n),new n(function(o,i){var s=new Jo({next:function(a){try{e(a)}catch(l){i(l),s.unsubscribe()}},error:i,complete:o});r.subscribe(s)})},t.prototype._subscribe=function(e){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(e)},t.prototype[Qn]=function(){return this},t.prototype.pipe=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return cl(e)(this)},t.prototype.toPromise=function(e){var n=this;return e=iu(e),new e(function(r,o){var i;n.subscribe(function(s){return i=s},function(s){return o(s)},function(){return r(i)})})},t.create=function(e){return new t(e)},t})();function iu(t){var e;return(e=t??rt.Promise)!==null&&e!==void 0?e:Promise}function gb(t){return t&&Y(t.next)&&Y(t.error)&&Y(t.complete)}function vb(t){return t&&t instanceof Rr||gb(t)&&Ko(t)}function bb(t){return Y(t?.lift)}function ge(t){return function(e){if(bb(e))return e.lift(function(n){try{return t(n,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function ye(t,e,n,r,o){return new yb(t,e,n,r,o)}var yb=(function(t){gt(e,t);function e(n,r,o,i,s,a){var l=t.call(this,n)||this;return l.onFinalize=s,l.shouldUnsubscribe=a,l._next=r?function(d){try{r(d)}catch(u){n.error(u)}}:t.prototype._next,l._error=i?function(d){try{i(d)}catch(u){n.error(u)}finally{this.unsubscribe()}}:t.prototype._error,l._complete=o?function(){try{o()}catch(d){n.error(d)}finally{this.unsubscribe()}}:t.prototype._complete,l}return e.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;t.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},e})(Rr);var su=Xn(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}});var vt=(function(t){gt(e,t);function e(){var n=t.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return e.prototype.lift=function(n){var r=new au(this,this);return r.operator=n,r},e.prototype._throwIfClosed=function(){if(this.closed)throw new su},e.prototype.next=function(n){var r=this;Zn(function(){var o,i;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var s=St(r.currentObservers),a=s.next();!a.done;a=s.next()){var l=a.value;l.next(n)}}catch(d){o={error:d}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(o)throw o.error}}}})},e.prototype.error=function(n){var r=this;Zn(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var o=r.observers;o.length;)o.shift().error(n)}})},e.prototype.complete=function(){var n=this;Zn(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(n){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,n)},e.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},e.prototype._innerSubscribe=function(n){var r=this,o=this,i=o.hasError,s=o.isStopped,a=o.observers;return i||s?sl:(this.currentObservers=null,a.push(n),new Yn(function(){r.currentObservers=null,Ar(a,n)}))},e.prototype._checkFinalizedStatuses=function(n){var r=this,o=r.hasError,i=r.thrownError,s=r.isStopped;o?n.error(i):s&&n.complete()},e.prototype.asObservable=function(){var n=new ce;return n.source=this,n},e.create=function(n,r){return new au(n,r)},e})(ce);var au=(function(t){gt(e,t);function e(n,r){var o=t.call(this)||this;return o.destination=n,o.source=r,o}return e.prototype.next=function(n){var r,o;(o=(r=this.destination)===null||r===void 0?void 0:r.next)===null||o===void 0||o.call(r,n)},e.prototype.error=function(n){var r,o;(o=(r=this.destination)===null||r===void 0?void 0:r.error)===null||o===void 0||o.call(r,n)},e.prototype.complete=function(){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||r===void 0||r.call(n)},e.prototype._subscribe=function(n){var r,o;return(o=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&o!==void 0?o:sl},e})(vt);var ul={now:function(){return(ul.delegate||Date).now()},delegate:void 0};var ti=(function(t){gt(e,t);function e(n,r,o){n===void 0&&(n=1/0),r===void 0&&(r=1/0),o===void 0&&(o=ul);var i=t.call(this)||this;return i._bufferSize=n,i._windowTime=r,i._timestampProvider=o,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=r===1/0,i._bufferSize=Math.max(1,n),i._windowTime=Math.max(1,r),i}return e.prototype.next=function(n){var r=this,o=r.isStopped,i=r._buffer,s=r._infiniteTimeWindow,a=r._timestampProvider,l=r._windowTime;o||(i.push(n),!s&&i.push(a.now()+l)),this._trimBuffer(),t.prototype.next.call(this,n)},e.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(n),o=this,i=o._infiniteTimeWindow,s=o._buffer,a=s.slice(),l=0;l<a.length&&!n.closed;l+=i?1:2)n.next(a[l]);return this._checkFinalizedStatuses(n),r},e.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,o=n._timestampProvider,i=n._buffer,s=n._infiniteTimeWindow,a=(s?1:2)*r;if(r<1/0&&a<i.length&&i.splice(0,i.length-a),!s){for(var l=o.now(),d=0,u=1;u<i.length&&i[u]<=l;u+=2)d=u;d&&i.splice(0,d+1)}},e})(vt);var ni=new ce(function(t){return t.complete()});function lu(t){return t&&Y(t.schedule)}function wb(t){return t[t.length-1]}function du(t){return lu(wb(t))?t.pop():void 0}var ri=(function(t){return t&&typeof t.length=="number"&&typeof t!="function"});function oi(t){return Y(t?.then)}function ii(t){return Y(t[Qn])}function si(t){return Symbol.asyncIterator&&Y(t?.[Symbol.asyncIterator])}function ai(t){return new TypeError("You provided "+(t!==null&&typeof t=="object"?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function xb(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var li=xb();function di(t){return Y(t?.[li])}function ci(t){return Qc(this,arguments,function(){var n,r,o,i;return Xo(this,function(s){switch(s.label){case 0:n=t.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,hn(n.read())];case 3:return r=s.sent(),o=r.value,i=r.done,i?[4,hn(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,hn(o)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function ui(t){return Y(t?.getReader)}function _e(t){if(t instanceof ce)return t;if(t!=null){if(ii(t))return Eb(t);if(ri(t))return Tb(t);if(oi(t))return _b(t);if(si(t))return cu(t);if(di(t))return Sb(t);if(ui(t))return Ab(t)}throw ai(t)}function Eb(t){return new ce(function(e){var n=t[Qn]();if(Y(n.subscribe))return n.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Tb(t){return new ce(function(e){for(var n=0;n<t.length&&!e.closed;n++)e.next(t[n]);e.complete()})}function _b(t){return new ce(function(e){t.then(function(n){e.closed||(e.next(n),e.complete())},function(n){return e.error(n)}).then(null,Zo)})}function Sb(t){return new ce(function(e){var n,r;try{for(var o=St(t),i=o.next();!i.done;i=o.next()){var s=i.value;if(e.next(s),e.closed)return}}catch(a){n={error:a}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}e.complete()})}function cu(t){return new ce(function(e){kb(t,e).catch(function(n){return e.error(n)})})}function Ab(t){return cu(ci(t))}function kb(t,e){var n,r,o,i;return Zc(this,void 0,void 0,function(){var s,a;return Xo(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),n=Jc(t),l.label=1;case 1:return[4,n.next()];case 2:if(r=l.sent(),!!r.done)return[3,4];if(s=r.value,e.next(s),e.closed)return[2];l.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=l.sent(),o={error:a},[3,11];case 6:return l.trys.push([6,,9,10]),r&&!r.done&&(i=n.return)?[4,i.call(n)]:[3,8];case 7:l.sent(),l.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function Je(t,e,n,r,o){r===void 0&&(r=0),o===void 0&&(o=!1);var i=e.schedule(function(){n(),o?t.add(this.schedule(null,r)):this.unsubscribe()},r);if(t.add(i),!o)return i}function hi(t,e){return e===void 0&&(e=0),ge(function(n,r){n.subscribe(ye(r,function(o){return Je(r,t,function(){return r.next(o)},e)},function(){return Je(r,t,function(){return r.complete()},e)},function(o){return Je(r,t,function(){return r.error(o)},e)}))})}function pi(t,e){return e===void 0&&(e=0),ge(function(n,r){r.add(t.schedule(function(){return n.subscribe(r)},e))})}function uu(t,e){return _e(t).pipe(pi(e),hi(e))}function hu(t,e){return _e(t).pipe(pi(e),hi(e))}function pu(t,e){return new ce(function(n){var r=0;return e.schedule(function(){r===t.length?n.complete():(n.next(t[r++]),n.closed||this.schedule())})})}function fu(t,e){return new ce(function(n){var r;return Je(n,e,function(){r=t[li](),Je(n,e,function(){var o,i,s;try{o=r.next(),i=o.value,s=o.done}catch(a){n.error(a);return}s?n.complete():n.next(i)},0,!0)}),function(){return Y(r?.return)&&r.return()}})}function fi(t,e){if(!t)throw new Error("Iterable cannot be null");return new ce(function(n){Je(n,e,function(){var r=t[Symbol.asyncIterator]();Je(n,e,function(){r.next().then(function(o){o.done?n.complete():n.next(o.value)})},0,!0)})})}function mu(t,e){return fi(ci(t),e)}function gu(t,e){if(t!=null){if(ii(t))return uu(t,e);if(ri(t))return pu(t,e);if(oi(t))return hu(t,e);if(si(t))return fi(t,e);if(di(t))return fu(t,e);if(ui(t))return mu(t,e)}throw ai(t)}function fn(t,e){return e?gu(t,e):_e(t)}function ne(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=du(t);return fn(t,n)}function z(t,e){var n=Y(t)?t:function(){return t},r=function(o){return o.error(n())};return new ce(e?function(o){return e.schedule(r,0,o)}:r)}var vu=Xn(function(t){return function(){t(this),this.name="EmptyError",this.message="no elements in sequence"}});function mi(t,e){var n=typeof e=="object";return new Promise(function(r,o){var i=!1,s;t.subscribe({next:function(a){s=a,i=!0},error:o,complete:function(){i?r(s):n?r(e.defaultValue):o(new vu)}})})}function Pt(t,e){return ge(function(n,r){var o=0;n.subscribe(ye(r,function(i){r.next(t.call(e,i,o++))}))})}function bu(t,e,n,r,o,i,s,a){var l=[],d=0,u=0,m=!1,w=function(){m&&!l.length&&!d&&e.complete()},p=function(v){return d<r?h(v):l.push(v)},h=function(v){i&&e.next(v),d++;var x=!1;_e(n(v,u++)).subscribe(ye(e,function(S){o?.(S),i?p(S):e.next(S)},function(){x=!0},void 0,function(){if(x)try{d--;for(var S=function(){var _=l.shift();s?Je(e,s,function(){return h(_)}):h(_)};l.length&&d<r;)S();w()}catch(_){e.error(_)}}))};return t.subscribe(ye(e,p,function(){m=!0,w()})),function(){a?.()}}function ze(t,e,n){return n===void 0&&(n=1/0),Y(e)?ze(function(r,o){return Pt(function(i,s){return e(r,i,o,s)})(_e(t(r,o)))},n):(typeof e=="number"&&(n=e),ge(function(r,o){return bu(r,o,t,n)}))}function hl(t){return t===void 0&&(t=1/0),ze(Jn,t)}function gi(t){return new ce(function(e){_e(t()).subscribe(e)})}function pl(t,e){return ge(function(n,r){var o=0;n.subscribe(ye(r,function(i){return t.call(e,i,o++)&&r.next(i)}))})}function Ir(t){return ge(function(e,n){var r=null,o=!1,i;r=e.subscribe(ye(n,void 0,void 0,function(s){i=_e(t(s,Ir(t)(e))),r?(r.unsubscribe(),r=null,i.subscribe(n)):o=!0})),o&&(r.unsubscribe(),r=null,i.subscribe(n))})}function vi(t,e){return Y(e)?ze(t,e,1):ze(t,1)}function fl(t){return ge(function(e,n){var r=!1;e.subscribe(ye(n,function(o){r=!0,n.next(o)},function(){r||n.next(t),n.complete()}))})}function mn(t){return ge(function(e,n){try{e.subscribe(n)}finally{n.add(t)}})}function ml(t,e){return ge(function(n,r){var o=null,i=0,s=!1,a=function(){return s&&!o&&r.complete()};n.subscribe(ye(r,function(l){o?.unsubscribe();var d=0,u=i++;_e(t(l,u)).subscribe(o=ye(r,function(m){return r.next(e?e(l,m,u,d++):m)},function(){o=null,a()}))},function(){s=!0,a()}))})}function bi(t){return ge(function(e,n){_e(t).subscribe(ye(n,function(){return n.complete()},kr)),!n.closed&&e.subscribe(n)})}function yi(t,e,n){var r=Y(t)||e||n?{next:t,error:e,complete:n}:t;return r?ge(function(o,i){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var a=!0;o.subscribe(ye(i,function(l){var d;(d=r.next)===null||d===void 0||d.call(r,l),i.next(l)},function(){var l;a=!1,(l=r.complete)===null||l===void 0||l.call(r),i.complete()},function(l){var d;a=!1,(d=r.error)===null||d===void 0||d.call(r,l),i.error(l)},function(){var l,d;a&&((l=r.unsubscribe)===null||l===void 0||l.call(r)),(d=r.finalize)===null||d===void 0||d.call(r)}))}):Jn}function yu(t){return` \r
|
|
5
|
-
`.indexOf(t)>=0}function wi(t){for(var e=["topLevel"],n=0,r,o,i,s=function(_){return e.push(_)},a=function(_){return e[e.length-1]=_},l=function(_){r==null&&(r=n,o=e.length,i=_)},d=function(_){_===i&&(r=void 0,o=void 0,i=void 0)},u=function(){return e.pop()},m=function(){return n--},w=function(_){if("0"<=_&&_<="9"){s("number");return}switch(_){case'"':s("string");return;case"-":s("numberNeedsDigit");return;case"t":s("true");return;case"f":s("false");return;case"n":s("null");return;case"[":s("arrayNeedsValue");return;case"{":s("objectNeedsKey");return}},p=t.length;n<p;n++){var h=t[n];switch(e[e.length-1]){case"topLevel":w(h);break;case"string":switch(h){case'"':u();break;case"\\":l("stringEscape"),s("stringEscaped");break}break;case"stringEscaped":h==="u"?s("stringUnicode"):(d("stringEscape"),u());break;case"stringUnicode":n-t.lastIndexOf("u",n)===4&&(d("stringEscape"),u());break;case"number":h==="."?a("numberNeedsDigit"):h==="e"||h==="E"?a("numberNeedsExponent"):(h<"0"||h>"9")&&(m(),u());break;case"numberNeedsDigit":a("number");break;case"numberNeedsExponent":a(h==="+"||h==="-"?"numberNeedsDigit":"number");break;case"true":case"false":case"null":(h<"a"||h>"z")&&(m(),u());break;case"arrayNeedsValue":h==="]"?u():yu(h)||(d("collectionItem"),a("arrayNeedsComma"),w(h));break;case"arrayNeedsComma":h==="]"?u():h===","&&(l("collectionItem"),a("arrayNeedsValue"));break;case"objectNeedsKey":h==="}"?u():h==='"'&&(l("collectionItem"),a("objectNeedsColon"),s("string"));break;case"objectNeedsColon":h===":"&&a("objectNeedsValue");break;case"objectNeedsValue":yu(h)||(d("collectionItem"),a("objectNeedsComma"),w(h));break;case"objectNeedsComma":h==="}"?u():h===","&&(l("collectionItem"),a("objectNeedsKey"));break}}o!=null&&(e.length=o);for(var v=[r!=null?t.slice(0,r):t],x=function(_){return v.push(_.slice(t.length-t.lastIndexOf(_[0])))},S=e.length-1;S>=0;S--)switch(e[S]){case"string":v.push('"');break;case"numberNeedsDigit":case"numberNeedsExponent":v.push("0");break;case"true":x("true");break;case"false":x("false");break;case"null":x("null");break;case"arrayNeedsValue":case"arrayNeedsComma":v.push("]");break;case"objectNeedsKey":case"objectNeedsColon":case"objectNeedsValue":case"objectNeedsComma":v.push("}");break}return v.join("")}function xu(){let t=this.buf,e=this.pos,n=0,r=0;for(let i=0;i<28;i+=7){let s=t[e++];if(n|=(s&127)<<i,(s&128)==0){this.pos=e,this.assertBounds(),this.varint64Lo=n,this.varint64Hi=r;return}}let o=t[e++];if(n|=(o&15)<<28,r=(o&112)>>4,(o&128)==0){this.pos=e,this.assertBounds(),this.varint64Lo=n,this.varint64Hi=r;return}for(let i=3;i<=31;i+=7){let s=t[e++];if(r|=(s&127)<<i,(s&128)==0){this.pos=e,this.assertBounds(),this.varint64Lo=n,this.varint64Hi=r;return}}throw new Error("invalid varint")}var xi=4294967296;function gl(t){let e=t[0]==="-";e&&(t=t.slice(1));let n=1e6,r=0,o=0;function i(s,a){let l=Number(t.slice(s,a));o*=n,r=r*n+l,r>=xi&&(o=o+(r/xi|0),r=r%xi)}return i(-24,-18),i(-18,-12),i(-12,-6),i(-6),e?Tu(r,o):bl(r,o)}function Eu(t,e){let n=bl(t,e),r=n.hi&2147483648;r&&(n=Tu(n.lo,n.hi));let o=vl(n.lo,n.hi);return r?"-"+o:o}function vl(t,e){if({lo:t,hi:e}=Rb(t,e),e<=2097151)return String(xi*e+t);let n=t&16777215,r=(t>>>24|e<<8)&16777215,o=e>>16&65535,i=n+r*6777216+o*6710656,s=r+o*8147497,a=o*2,l=1e7;return i>=l&&(s+=Math.floor(i/l),i%=l),s>=l&&(a+=Math.floor(s/l),s%=l),a.toString()+wu(s)+wu(i)}function Rb(t,e){return{lo:t>>>0,hi:e>>>0}}function bl(t,e){return{lo:t|0,hi:e|0}}function Tu(t,e){return e=~e,t?t=~t+1:e+=1,bl(t,e)}var wu=t=>{let e=String(t);return"0000000".slice(e.length)+e};function _u(){let t=this.buf[this.pos++];if((t&128)===0)return this.assertBounds(),t;let e=t&127;if(t=this.buf[this.pos++],e|=(t&127)<<7,(t&128)===0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<14,(t&128)===0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<21,(t&128)===0)return this.assertBounds(),e;t=this.buf[this.pos++],e|=(t&15)<<28;for(let n=5;(t&128)!==0&&n<10;n++)t=this.buf[this.pos++];if((t&128)!==0)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var ot=Ib();function Ib(){let t=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof t.getBigInt64=="function"&&typeof t.getBigUint64=="function"&&typeof t.setBigInt64=="function"&&typeof t.setBigUint64=="function"&&(!!globalThis.Deno||!!globalThis.Bun||typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){let n=BigInt("-9223372036854775808"),r=BigInt("9223372036854775807"),o=BigInt("0"),i=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(s){let a=typeof s=="bigint"?s:BigInt(s);if(a>r||a<n)throw new Error(`invalid int64: ${s}`);return a},uParse(s){let a=typeof s=="bigint"?s:BigInt(s);if(a>i||a<o)throw new Error(`invalid uint64: ${s}`);return a},enc(s){return t.setBigInt64(0,this.parse(s),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},uEnc(s){return t.setBigInt64(0,this.uParse(s),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},dec(s,a){return t.setInt32(0,s,!0),t.setInt32(4,a,!0),t.getBigInt64(0,!0)},uDec(s,a){return t.setInt32(0,s,!0),t.setInt32(4,a,!0),t.getBigUint64(0,!0)}}}return{zero:"0",supported:!1,parse(n){return typeof n!="string"&&(n=n.toString()),Su(n),n},uParse(n){return typeof n!="string"&&(n=n.toString()),Au(n),n},enc(n){return typeof n!="string"&&(n=n.toString()),Su(n),gl(n)},uEnc(n){return typeof n!="string"&&(n=n.toString()),Au(n),gl(n)},dec(n,r){return Eu(n,r)},uDec(n,r){return vl(n,r)}}}function Su(t){if(!/^-?[0-9]+$/.test(t))throw new Error("invalid int64: "+t)}function Au(t){if(!/^[0-9]+$/.test(t))throw new Error("invalid uint64: "+t)}var yl=Symbol.for("@bufbuild/protobuf/text-encoding");function Cb(t){var e;globalThis[yl]=Object.assign(Object.assign({},t),{encodeUtf8Into:(e=t.encodeUtf8Into)!==null&&e!==void 0?e:xl(t.encodeUtf8.bind(t))})}function wl(){let t=globalThis;if(!t[yl]){let e=new t.TextEncoder,n=new t.TextDecoder,r,o={encodeUtf8(s){return e.encode(s)},decodeUtf8(s,a){return a?(r||(r=new t.TextDecoder("utf-8",{fatal:!0})),r.decode(s)):n.decode(s)},checkUtf8(s){try{return encodeURIComponent(s),!0}catch{return!1}}};e.encodeInto&&(o.encodeUtf8Into=e.encodeInto.bind(e));let i=String.prototype.isWellFormed;i&&(o.checkUtf8=s=>i.call(s)),Cb(o)}return t[yl]}function xl(t){return(e,n)=>{let r=t(e);return n.set(r),{written:r.byteLength}}}var Dt;(function(t){t[t.Varint=0]="Varint",t[t.Bit64=1]="Bit64",t[t.LengthDelimited=2]="LengthDelimited",t[t.StartGroup=3]="StartGroup",t[t.EndGroup=4]="EndGroup",t[t.Bit32=5]="Bit32"})(Dt||(Dt={}));var Nb=34028234663852886e22,Ob=-34028234663852886e22,Mb=4294967295,Lb=2147483647,Pb=-2147483648,q=class{constructor(e){this.stackPos=[],this.encodeUtf8Into=e?xl(e):wl().encodeUtf8Into,this.buffer=Ru,this.viewCache=Ub,this.pos=0}ensureCapacity(e){let n=this.pos+e;if(n>this.buffer.length){let r=this.buffer.length||Db;for(;r<n;)r*=2;let o=new Uint8Array(r);this.pos>0&&o.set(this.buffer),this.buffer=o}}view(){let e=this.buffer,n=this.viewCache;if(n.byteLength===e.byteLength)return n;let r=new DataView(e.buffer);return this.viewCache=r,r}finish(){let e=this.buffer.slice(0,this.pos);return this.pos=0,this.stackPos=[],e}fork(){return this.stackPos.push(this.pos),this.ensureCapacity(Cr),this.buffer[this.pos++]=0,this}join(){let e=this.stackPos.pop();if(e===void 0)throw new Error("invalid state, fork stack empty");let n=this.pos-e-Cr,r=El(n);return r>Cr&&(this.ensureCapacity(r-Cr),this.buffer.copyWithin(e+r,e+Cr,this.pos)),this.pos=e,this.uint32(n),this.pos+=n,this}tag(e,n){return this.uint32((e<<3|n)>>>0)}raw(e){return this.ensureCapacity(e.length),this.buffer.set(e,this.pos),this.pos+=e.length,this}uint32(e){if(ku(e),this.ensureCapacity(5),e<128)return this.buffer[this.pos++]=e,this;for(;e>127;)this.buffer[this.pos++]=e&127|128,e>>>=7;return this.buffer[this.pos++]=e,this}int32(e){if(Tl(e),e>=0)return this.uint32(e);this.ensureCapacity(10);for(let n=0;n<9;n++)this.buffer[this.pos++]=e&127|128,e>>=7;return this.buffer[this.pos++]=1,this}bool(e){return this.ensureCapacity(1),this.buffer[this.pos++]=e?1:0,this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){typeof e!="string"&&(e=String(e));let n=e.length;if(n<=Iu){this.ensureCapacity(n+1);let l=this.buffer,d=this.pos;l[d++]=n;let u=0;for(;u<n;u++){let m=e.charCodeAt(u);if(m>127)break;l[d++]=m}if(u==n)return this.pos=d,this}this.ensureCapacity(n*3+5);let r=El(n),o=this.buffer,i=this.pos,{written:s}=this.encodeUtf8Into(e,o.subarray(i+r)),a=El(s);return a!=r&&o.copyWithin(i+a,i+r,i+r+s),this.uint32(s),this.pos+=s,this}float(e){return Hb(e),this.ensureCapacity(4),this.view().setFloat32(this.pos,e,!0),this.pos+=4,this}double(e){return this.ensureCapacity(8),this.view().setFloat64(this.pos,e,!0),this.pos+=8,this}fixed32(e){return ku(e),this.ensureCapacity(4),this.view().setUint32(this.pos,e,!0),this.pos+=4,this}sfixed32(e){return Tl(e),this.ensureCapacity(4),this.view().setInt32(this.pos,e,!0),this.pos+=4,this}sint32(e){return Tl(e),this.uint32((e<<1^e>>31)>>>0)}sfixed64(e){let n=ot.enc(e);this.ensureCapacity(8);let r=this.view();return r.setInt32(this.pos,n.lo,!0),r.setInt32(this.pos+4,n.hi,!0),this.pos+=8,this}fixed64(e){let n=ot.uEnc(e);this.ensureCapacity(8);let r=this.view();return r.setInt32(this.pos,n.lo,!0),r.setInt32(this.pos+4,n.hi,!0),this.pos+=8,this}int64(e){let n=ot.enc(e);return this.writeVarint64(n.lo,n.hi)}sint64(e){let n=ot.enc(e),r=n.hi>>31,o=n.lo<<1^r,i=(n.hi<<1|n.lo>>>31)^r;return this.writeVarint64(o,i)}uint64(e){let n=ot.uEnc(e);return this.writeVarint64(n.lo,n.hi)}writeVarint64(e,n){this.ensureCapacity(10);let r=this.buffer,o=this.pos;for(let a=0;a<28;a=a+7){let l=e>>>a,d=!(!(l>>>7)&&n==0);if(r[o++]=(d?l|128:l)&255,!d)return this.pos=o,this}let i=e>>>28&15|(n&7)<<4,s=n>>3!=0;if(r[o++]=(s?i|128:i)&255,!s)return this.pos=o,this;for(let a=3;a<31;a=a+7){let l=n>>>a,d=!!(l>>>7);if(r[o++]=(d?l|128:l)&255,!d)return this.pos=o,this}return r[o++]=n>>>31&1,this.pos=o,this}},Db=128,Cr=1,Ru=new Uint8Array(0),Ub=new DataView(Ru.buffer),Iu=32;function El(t){return t<128?1:t<16384?2:t<2097152?3:t<268435456?4:5}var C=class{constructor(e,n=wl().decodeUtf8){this.decodeUtf8=n,this.varint64Lo=0,this.varint64Hi=0,this.varint64=xu,this.uint32=_u,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){let e=this.pos,n=this.uint32(),r=this.pos-e;if(r>5||r==5&&this.buf[this.pos-1]>15)throw new Error("illegal tag: varint overflows uint32");let o=n>>>3,i=n&7;if(o<=0||i>5)throw new Error("illegal tag: field no "+o+" wire type "+i);return[o,i]}skip(e,n,r=100){let o=this.pos;switch(e){case Dt.Varint:for(;this.buf[this.pos++]&128;);break;case Dt.Bit64:this.pos+=4;case Dt.Bit32:this.pos+=4;break;case Dt.LengthDelimited:let i=this.uint32();this.pos+=i;break;case Dt.StartGroup:if(r<=0)throw new Error("maximum recursion depth reached");for(;;){let[s,a]=this.tag();if(a===Dt.EndGroup){if(n!==void 0&&s!==n)throw new Error("invalid end group tag");break}this.skip(a,s,r-1)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(o,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return this.varint64(),ot.dec(this.varint64Lo,this.varint64Hi)}uint64(){return this.varint64(),ot.uDec(this.varint64Lo,this.varint64Hi)}sint64(){this.varint64();let e=this.varint64Lo,n=this.varint64Hi,r=-(e&1);return e=(e>>>1|(n&1)<<31)^r,n=n>>>1^r,ot.dec(e,n)}bool(){let e=this.buf[this.pos];return e<128?(this.pos++,e!==0):(this.varint64(),this.varint64Lo!==0||this.varint64Hi!==0)}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return ot.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return ot.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),n=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(n,n+e)}string(e){let n=this.bytes(),r=n.length;if(r<=Iu){let o=new Array(r);for(let i=0;i<r;i++){let s=n[i];if(s>127)return this.decodeUtf8(n,e);o[i]=s}return String.fromCharCode.apply(String,o)}return this.decodeUtf8(n,e)}};function Tl(t){if(typeof t=="string")t=Number(t);else if(typeof t!="number")throw new Error("invalid int32: "+typeof t);if(!Number.isInteger(t)||t>Lb||t<Pb)throw new Error("invalid int32: "+t)}function ku(t){if(typeof t=="string")t=Number(t);else if(typeof t!="number")throw new Error("invalid uint32: "+typeof t);if(!Number.isInteger(t)||t>Mb||t<0)throw new Error("invalid uint32: "+t)}function Hb(t){if(typeof t=="string"){let e=t;if(t=Number(t),Number.isNaN(t)&&e!=="NaN")throw new Error("invalid float32: "+e)}else if(typeof t!="number")throw new Error("invalid float32: "+typeof t);if(Number.isFinite(t)&&(t>Nb||t<Ob))throw new Error("invalid float32: "+t)}var Gb=(function(t){return t[t.NULL_VALUE=0]="NULL_VALUE",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t})({});function _l(){return{fields:{}}}var Ie={encode(t,e=new q){return Object.entries(t.fields).forEach(([n,r])=>{r!==void 0&&kl.encode({key:n,value:r},e.uint32(10).fork()).join()}),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=_l();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:{if(i!==10)break;let s=kl.decode(n,n.uint32());s.value!==void 0&&(o.fields[s.key]=s.value);continue}}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Ie.fromPartial(t??{})},fromPartial(t){let e=_l();return e.fields=Object.entries(t.fields??{}).reduce((n,[r,o])=>(o!==void 0&&(n[r]=o),n),{}),e},wrap(t){let e=_l();if(t!==void 0)for(let n of Object.keys(t))e.fields[n]=t[n];return e},unwrap(t){let e={};if(t.fields)for(let n of Object.keys(t.fields))e[n]=t.fields[n];return e}};function Cu(){return{key:"",value:void 0}}var kl={encode(t,e=new q){return t.key!==""&&e.uint32(10).string(t.key),t.value!==void 0&&U.encode(U.wrap(t.value),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=Cu();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.key=n.string();continue;case 2:if(i!==18)break;o.value=U.unwrap(U.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return kl.fromPartial(t??{})},fromPartial(t){let e=Cu();return e.key=t.key??"",e.value=t.value??void 0,e}};function Sl(){return{nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0}}var U={encode(t,e=new q){return t.nullValue!==void 0&&e.uint32(8).int32(t.nullValue),t.numberValue!==void 0&&e.uint32(17).double(t.numberValue),t.stringValue!==void 0&&e.uint32(26).string(t.stringValue),t.boolValue!==void 0&&e.uint32(32).bool(t.boolValue),t.structValue!==void 0&&Ie.encode(Ie.wrap(t.structValue),e.uint32(42).fork()).join(),t.listValue!==void 0&&Nr.encode(Nr.wrap(t.listValue),e.uint32(50).fork()).join(),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=Sl();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==8)break;o.nullValue=n.int32();continue;case 2:if(i!==17)break;o.numberValue=n.double();continue;case 3:if(i!==26)break;o.stringValue=n.string();continue;case 4:if(i!==32)break;o.boolValue=n.bool();continue;case 5:if(i!==42)break;o.structValue=Ie.unwrap(Ie.decode(n,n.uint32()));continue;case 6:if(i!==50)break;o.listValue=Nr.unwrap(Nr.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return U.fromPartial(t??{})},fromPartial(t){let e=Sl();return e.nullValue=t.nullValue??void 0,e.numberValue=t.numberValue??void 0,e.stringValue=t.stringValue??void 0,e.boolValue=t.boolValue??void 0,e.structValue=t.structValue??void 0,e.listValue=t.listValue??void 0,e},wrap(t){let e=Sl();if(t===null)e.nullValue=Gb.NULL_VALUE;else if(typeof t=="boolean")e.boolValue=t;else if(typeof t=="number")e.numberValue=t;else if(typeof t=="string")e.stringValue=t;else if(globalThis.Array.isArray(t))e.listValue=t;else if(typeof t=="object")e.structValue=t;else if(typeof t<"u")throw new globalThis.Error("Unsupported any value type: "+typeof t);return e},unwrap(t){if(t.stringValue!==void 0)return t.stringValue;if(t?.numberValue!==void 0)return t.numberValue;if(t?.boolValue!==void 0)return t.boolValue;if(t?.structValue!==void 0)return t.structValue;if(t?.listValue!==void 0)return t.listValue;if(t?.nullValue!==void 0)return null}};function Al(){return{values:[]}}var Nr={encode(t,e=new q){for(let n of t.values)U.encode(U.wrap(n),e.uint32(10).fork()).join();return e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=Al();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.values.push(U.unwrap(U.decode(n,n.uint32())));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Nr.fromPartial(t??{})},fromPartial(t){let e=Al();return e.values=t.values?.map(n=>n)||[],e},wrap(t){let e=Al();return e.values=t??[],e},unwrap(t){return t?.hasOwnProperty("values")&&globalThis.Array.isArray(t.values)?t.values:t}},zb=(function(t){return t[t.ADD=0]="ADD",t[t.REMOVE=1]="REMOVE",t[t.REPLACE=2]="REPLACE",t[t.MOVE=3]="MOVE",t[t.COPY=4]="COPY",t[t.TEST=5]="TEST",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t})({});function Nu(){return{op:0,path:"",from:void 0,value:void 0}}var Ti={encode(t,e=new q){return t.op!==0&&e.uint32(8).int32(t.op),t.path!==""&&e.uint32(18).string(t.path),t.from!==void 0&&e.uint32(26).string(t.from),t.value!==void 0&&U.encode(U.wrap(t.value),e.uint32(34).fork()).join(),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=Nu();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==8)break;o.op=n.int32();continue;case 2:if(i!==18)break;o.path=n.string();continue;case 3:if(i!==26)break;o.from=n.string();continue;case 4:if(i!==34)break;o.value=U.unwrap(U.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Ti.fromPartial(t??{})},fromPartial(t){let e=Nu();return e.op=t.op??0,e.path=t.path??"",e.from=t.from??void 0,e.value=t.value??void 0,e}};function Ou(){return{id:"",type:"",function:void 0,metadata:void 0}}var _i={encode(t,e=new q){return t.id!==""&&e.uint32(10).string(t.id),t.type!==""&&e.uint32(18).string(t.type),t.function!==void 0&&Si.encode(t.function,e.uint32(26).fork()).join(),t.metadata!==void 0&&Ie.encode(Ie.wrap(t.metadata),e.uint32(34).fork()).join(),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=Ou();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.id=n.string();continue;case 2:if(i!==18)break;o.type=n.string();continue;case 3:if(i!==26)break;o.function=Si.decode(n,n.uint32());continue;case 4:if(i!==34)break;o.metadata=Ie.unwrap(Ie.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return _i.fromPartial(t??{})},fromPartial(t){let e=Ou();return e.id=t.id??"",e.type=t.type??"",e.function=t.function!==void 0&&t.function!==null?Si.fromPartial(t.function):void 0,e.metadata=t.metadata??void 0,e}};function Mu(){return{name:"",arguments:""}}var Si={encode(t,e=new q){return t.name!==""&&e.uint32(10).string(t.name),t.arguments!==""&&e.uint32(18).string(t.arguments),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=Mu();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.name=n.string();continue;case 2:if(i!==18)break;o.arguments=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Si.fromPartial(t??{})},fromPartial(t){let e=Mu();return e.name=t.name??"",e.arguments=t.arguments??"",e}};function Lu(){return{value:"",mimeType:""}}var Ai={encode(t,e=new q){return t.value!==""&&e.uint32(10).string(t.value),t.mimeType!==""&&e.uint32(18).string(t.mimeType),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=Lu();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.value=n.string();continue;case 2:if(i!==18)break;o.mimeType=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Ai.fromPartial(t??{})},fromPartial(t){let e=Lu();return e.value=t.value??"",e.mimeType=t.mimeType??"",e}};function Pu(){return{value:"",mimeType:void 0}}var ki={encode(t,e=new q){return t.value!==""&&e.uint32(10).string(t.value),t.mimeType!==void 0&&e.uint32(18).string(t.mimeType),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=Pu();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.value=n.string();continue;case 2:if(i!==18)break;o.mimeType=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return ki.fromPartial(t??{})},fromPartial(t){let e=Pu();return e.value=t.value??"",e.mimeType=t.mimeType??void 0,e}};function Du(){return{data:void 0,url:void 0}}var Be={encode(t,e=new q){return t.data!==void 0&&Ai.encode(t.data,e.uint32(10).fork()).join(),t.url!==void 0&&ki.encode(t.url,e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=Du();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.data=Ai.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.url=ki.decode(n,n.uint32());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Be.fromPartial(t??{})},fromPartial(t){let e=Du();return e.data=t.data!==void 0&&t.data!==null?Ai.fromPartial(t.data):void 0,e.url=t.url!==void 0&&t.url!==null?ki.fromPartial(t.url):void 0,e}};function Uu(){return{text:""}}var Ri={encode(t,e=new q){return t.text!==""&&e.uint32(10).string(t.text),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=Uu();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.text=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Ri.fromPartial(t??{})},fromPartial(t){let e=Uu();return e.text=t.text??"",e}};function Hu(){return{source:void 0,metadata:void 0}}var Ii={encode(t,e=new q){return t.source!==void 0&&Be.encode(t.source,e.uint32(10).fork()).join(),t.metadata!==void 0&&U.encode(U.wrap(t.metadata),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=Hu();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=Be.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.metadata=U.unwrap(U.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Ii.fromPartial(t??{})},fromPartial(t){let e=Hu();return e.source=t.source!==void 0&&t.source!==null?Be.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function Gu(){return{source:void 0,metadata:void 0}}var Ci={encode(t,e=new q){return t.source!==void 0&&Be.encode(t.source,e.uint32(10).fork()).join(),t.metadata!==void 0&&U.encode(U.wrap(t.metadata),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=Gu();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=Be.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.metadata=U.unwrap(U.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Ci.fromPartial(t??{})},fromPartial(t){let e=Gu();return e.source=t.source!==void 0&&t.source!==null?Be.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function zu(){return{source:void 0,metadata:void 0}}var Ni={encode(t,e=new q){return t.source!==void 0&&Be.encode(t.source,e.uint32(10).fork()).join(),t.metadata!==void 0&&U.encode(U.wrap(t.metadata),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=zu();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=Be.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.metadata=U.unwrap(U.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Ni.fromPartial(t??{})},fromPartial(t){let e=zu();return e.source=t.source!==void 0&&t.source!==null?Be.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function Fu(){return{source:void 0,metadata:void 0}}var Oi={encode(t,e=new q){return t.source!==void 0&&Be.encode(t.source,e.uint32(10).fork()).join(),t.metadata!==void 0&&U.encode(U.wrap(t.metadata),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=Fu();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=Be.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.metadata=U.unwrap(U.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Oi.fromPartial(t??{})},fromPartial(t){let e=Fu();return e.source=t.source!==void 0&&t.source!==null?Be.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function $u(){return{text:void 0,image:void 0,audio:void 0,video:void 0,document:void 0}}var Mi={encode(t,e=new q){return t.text!==void 0&&Ri.encode(t.text,e.uint32(10).fork()).join(),t.image!==void 0&&Ii.encode(t.image,e.uint32(18).fork()).join(),t.audio!==void 0&&Ci.encode(t.audio,e.uint32(26).fork()).join(),t.video!==void 0&&Ni.encode(t.video,e.uint32(34).fork()).join(),t.document!==void 0&&Oi.encode(t.document,e.uint32(42).fork()).join(),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=$u();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.text=Ri.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.image=Ii.decode(n,n.uint32());continue;case 3:if(i!==26)break;o.audio=Ci.decode(n,n.uint32());continue;case 4:if(i!==34)break;o.video=Ni.decode(n,n.uint32());continue;case 5:if(i!==42)break;o.document=Oi.decode(n,n.uint32());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Mi.fromPartial(t??{})},fromPartial(t){let e=$u();return e.text=t.text!==void 0&&t.text!==null?Ri.fromPartial(t.text):void 0,e.image=t.image!==void 0&&t.image!==null?Ii.fromPartial(t.image):void 0,e.audio=t.audio!==void 0&&t.audio!==null?Ci.fromPartial(t.audio):void 0,e.video=t.video!==void 0&&t.video!==null?Ni.fromPartial(t.video):void 0,e.document=t.document!==void 0&&t.document!==null?Oi.fromPartial(t.document):void 0,e}};function Bu(){return{id:"",role:"",content:void 0,name:void 0,toolCalls:[],toolCallId:void 0,error:void 0,contentParts:[],metadata:void 0,subagentRunId:void 0}}var Li={encode(t,e=new q){t.id!==""&&e.uint32(10).string(t.id),t.role!==""&&e.uint32(18).string(t.role),t.content!==void 0&&e.uint32(26).string(t.content),t.name!==void 0&&e.uint32(34).string(t.name);for(let n of t.toolCalls)_i.encode(n,e.uint32(42).fork()).join();t.toolCallId!==void 0&&e.uint32(50).string(t.toolCallId),t.error!==void 0&&e.uint32(58).string(t.error);for(let n of t.contentParts)Mi.encode(n,e.uint32(66).fork()).join();return t.metadata!==void 0&&Ie.encode(Ie.wrap(t.metadata),e.uint32(74).fork()).join(),t.subagentRunId!==void 0&&e.uint32(82).string(t.subagentRunId),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=Bu();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.id=n.string();continue;case 2:if(i!==18)break;o.role=n.string();continue;case 3:if(i!==26)break;o.content=n.string();continue;case 4:if(i!==34)break;o.name=n.string();continue;case 5:if(i!==42)break;o.toolCalls.push(_i.decode(n,n.uint32()));continue;case 6:if(i!==50)break;o.toolCallId=n.string();continue;case 7:if(i!==58)break;o.error=n.string();continue;case 8:if(i!==66)break;o.contentParts.push(Mi.decode(n,n.uint32()));continue;case 9:if(i!==74)break;o.metadata=Ie.unwrap(Ie.decode(n,n.uint32()));continue;case 10:if(i!==82)break;o.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Li.fromPartial(t??{})},fromPartial(t){let e=Bu();return e.id=t.id??"",e.role=t.role??"",e.content=t.content??void 0,e.name=t.name??void 0,e.toolCalls=t.toolCalls?.map(n=>_i.fromPartial(n))||[],e.toolCallId=t.toolCallId??void 0,e.error=t.error??void 0,e.contentParts=t.contentParts?.map(n=>Mi.fromPartial(n))||[],e.metadata=t.metadata??void 0,e.subagentRunId=t.subagentRunId??void 0,e}};function ju(){return{id:"",reason:"",message:void 0,toolCallId:void 0,responseSchema:void 0,expiresAt:void 0,metadata:void 0,subagentRunId:void 0}}var Pi={encode(t,e=new q){return t.id!==""&&e.uint32(10).string(t.id),t.reason!==""&&e.uint32(18).string(t.reason),t.message!==void 0&&e.uint32(26).string(t.message),t.toolCallId!==void 0&&e.uint32(34).string(t.toolCallId),t.responseSchema!==void 0&&U.encode(U.wrap(t.responseSchema),e.uint32(42).fork()).join(),t.expiresAt!==void 0&&e.uint32(50).string(t.expiresAt),t.metadata!==void 0&&U.encode(U.wrap(t.metadata),e.uint32(58).fork()).join(),t.subagentRunId!==void 0&&e.uint32(66).string(t.subagentRunId),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=ju();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.id=n.string();continue;case 2:if(i!==18)break;o.reason=n.string();continue;case 3:if(i!==26)break;o.message=n.string();continue;case 4:if(i!==34)break;o.toolCallId=n.string();continue;case 5:if(i!==42)break;o.responseSchema=U.unwrap(U.decode(n,n.uint32()));continue;case 6:if(i!==50)break;o.expiresAt=n.string();continue;case 7:if(i!==58)break;o.metadata=U.unwrap(U.decode(n,n.uint32()));continue;case 8:if(i!==66)break;o.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Pi.fromPartial(t??{})},fromPartial(t){let e=ju();return e.id=t.id??"",e.reason=t.reason??"",e.message=t.message??void 0,e.toolCallId=t.toolCallId??void 0,e.responseSchema=t.responseSchema??void 0,e.expiresAt=t.expiresAt??void 0,e.metadata=t.metadata??void 0,e.subagentRunId=t.subagentRunId??void 0,e}},Fb=(function(t){return t[t.TEXT_MESSAGE_START=0]="TEXT_MESSAGE_START",t[t.TEXT_MESSAGE_CONTENT=1]="TEXT_MESSAGE_CONTENT",t[t.TEXT_MESSAGE_END=2]="TEXT_MESSAGE_END",t[t.TOOL_CALL_START=3]="TOOL_CALL_START",t[t.TOOL_CALL_ARGS=4]="TOOL_CALL_ARGS",t[t.TOOL_CALL_END=5]="TOOL_CALL_END",t[t.STATE_SNAPSHOT=6]="STATE_SNAPSHOT",t[t.STATE_DELTA=7]="STATE_DELTA",t[t.MESSAGES_SNAPSHOT=8]="MESSAGES_SNAPSHOT",t[t.RAW=9]="RAW",t[t.CUSTOM=10]="CUSTOM",t[t.RUN_STARTED=11]="RUN_STARTED",t[t.RUN_FINISHED=12]="RUN_FINISHED",t[t.RUN_ERROR=13]="RUN_ERROR",t[t.STEP_STARTED=14]="STEP_STARTED",t[t.STEP_FINISHED=15]="STEP_FINISHED",t[t.SUBAGENT_STARTED=16]="SUBAGENT_STARTED",t[t.SUBAGENT_FINISHED=17]="SUBAGENT_FINISHED",t[t.SUBAGENT_ERROR=18]="SUBAGENT_ERROR",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t})({});function Vu(){return{type:0,timestamp:void 0,rawEvent:void 0,metadata:void 0}}var P={encode(t,e=new q){return t.type!==0&&e.uint32(8).int32(t.type),t.timestamp!==void 0&&e.uint32(16).int64(t.timestamp),t.rawEvent!==void 0&&U.encode(U.wrap(t.rawEvent),e.uint32(26).fork()).join(),t.metadata!==void 0&&Ie.encode(Ie.wrap(t.metadata),e.uint32(34).fork()).join(),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=Vu();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==8)break;o.type=n.int32();continue;case 2:if(i!==16)break;o.timestamp=er(n.int64());continue;case 3:if(i!==26)break;o.rawEvent=U.unwrap(U.decode(n,n.uint32()));continue;case 4:if(i!==34)break;o.metadata=Ie.unwrap(Ie.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return P.fromPartial(t??{})},fromPartial(t){let e=Vu();return e.type=t.type??0,e.timestamp=t.timestamp??void 0,e.rawEvent=t.rawEvent??void 0,e.metadata=t.metadata??void 0,e}};function qu(){return{baseEvent:void 0,messageId:"",role:void 0,name:void 0,subagentRunId:void 0}}var Di={encode(t,e=new q){return t.baseEvent!==void 0&&P.encode(t.baseEvent,e.uint32(10).fork()).join(),t.messageId!==""&&e.uint32(18).string(t.messageId),t.role!==void 0&&e.uint32(26).string(t.role),t.name!==void 0&&e.uint32(34).string(t.name),t.subagentRunId!==void 0&&e.uint32(42).string(t.subagentRunId),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=qu();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=P.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.messageId=n.string();continue;case 3:if(i!==26)break;o.role=n.string();continue;case 4:if(i!==34)break;o.name=n.string();continue;case 5:if(i!==42)break;o.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Di.fromPartial(t??{})},fromPartial(t){let e=qu();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?P.fromPartial(t.baseEvent):void 0,e.messageId=t.messageId??"",e.role=t.role??void 0,e.name=t.name??void 0,e.subagentRunId=t.subagentRunId??void 0,e}};function Wu(){return{baseEvent:void 0,messageId:"",delta:"",subagentRunId:void 0}}var Ui={encode(t,e=new q){return t.baseEvent!==void 0&&P.encode(t.baseEvent,e.uint32(10).fork()).join(),t.messageId!==""&&e.uint32(18).string(t.messageId),t.delta!==""&&e.uint32(26).string(t.delta),t.subagentRunId!==void 0&&e.uint32(34).string(t.subagentRunId),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=Wu();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=P.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.messageId=n.string();continue;case 3:if(i!==26)break;o.delta=n.string();continue;case 4:if(i!==34)break;o.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Ui.fromPartial(t??{})},fromPartial(t){let e=Wu();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?P.fromPartial(t.baseEvent):void 0,e.messageId=t.messageId??"",e.delta=t.delta??"",e.subagentRunId=t.subagentRunId??void 0,e}};function Xu(){return{baseEvent:void 0,messageId:"",subagentRunId:void 0}}var Hi={encode(t,e=new q){return t.baseEvent!==void 0&&P.encode(t.baseEvent,e.uint32(10).fork()).join(),t.messageId!==""&&e.uint32(18).string(t.messageId),t.subagentRunId!==void 0&&e.uint32(26).string(t.subagentRunId),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=Xu();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=P.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.messageId=n.string();continue;case 3:if(i!==26)break;o.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Hi.fromPartial(t??{})},fromPartial(t){let e=Xu();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?P.fromPartial(t.baseEvent):void 0,e.messageId=t.messageId??"",e.subagentRunId=t.subagentRunId??void 0,e}};function Yu(){return{baseEvent:void 0,toolCallId:"",toolCallName:"",parentMessageId:void 0,subagentRunId:void 0}}var Gi={encode(t,e=new q){return t.baseEvent!==void 0&&P.encode(t.baseEvent,e.uint32(10).fork()).join(),t.toolCallId!==""&&e.uint32(18).string(t.toolCallId),t.toolCallName!==""&&e.uint32(26).string(t.toolCallName),t.parentMessageId!==void 0&&e.uint32(34).string(t.parentMessageId),t.subagentRunId!==void 0&&e.uint32(42).string(t.subagentRunId),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=Yu();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=P.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.toolCallId=n.string();continue;case 3:if(i!==26)break;o.toolCallName=n.string();continue;case 4:if(i!==34)break;o.parentMessageId=n.string();continue;case 5:if(i!==42)break;o.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Gi.fromPartial(t??{})},fromPartial(t){let e=Yu();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?P.fromPartial(t.baseEvent):void 0,e.toolCallId=t.toolCallId??"",e.toolCallName=t.toolCallName??"",e.parentMessageId=t.parentMessageId??void 0,e.subagentRunId=t.subagentRunId??void 0,e}};function Ku(){return{baseEvent:void 0,toolCallId:"",delta:"",subagentRunId:void 0}}var zi={encode(t,e=new q){return t.baseEvent!==void 0&&P.encode(t.baseEvent,e.uint32(10).fork()).join(),t.toolCallId!==""&&e.uint32(18).string(t.toolCallId),t.delta!==""&&e.uint32(26).string(t.delta),t.subagentRunId!==void 0&&e.uint32(34).string(t.subagentRunId),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=Ku();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=P.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.toolCallId=n.string();continue;case 3:if(i!==26)break;o.delta=n.string();continue;case 4:if(i!==34)break;o.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return zi.fromPartial(t??{})},fromPartial(t){let e=Ku();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?P.fromPartial(t.baseEvent):void 0,e.toolCallId=t.toolCallId??"",e.delta=t.delta??"",e.subagentRunId=t.subagentRunId??void 0,e}};function Zu(){return{baseEvent:void 0,toolCallId:"",subagentRunId:void 0}}var Fi={encode(t,e=new q){return t.baseEvent!==void 0&&P.encode(t.baseEvent,e.uint32(10).fork()).join(),t.toolCallId!==""&&e.uint32(18).string(t.toolCallId),t.subagentRunId!==void 0&&e.uint32(26).string(t.subagentRunId),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=Zu();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=P.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.toolCallId=n.string();continue;case 3:if(i!==26)break;o.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Fi.fromPartial(t??{})},fromPartial(t){let e=Zu();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?P.fromPartial(t.baseEvent):void 0,e.toolCallId=t.toolCallId??"",e.subagentRunId=t.subagentRunId??void 0,e}};function Qu(){return{baseEvent:void 0,snapshot:void 0,subagentRunId:void 0}}var $i={encode(t,e=new q){return t.baseEvent!==void 0&&P.encode(t.baseEvent,e.uint32(10).fork()).join(),t.snapshot!==void 0&&U.encode(U.wrap(t.snapshot),e.uint32(18).fork()).join(),t.subagentRunId!==void 0&&e.uint32(26).string(t.subagentRunId),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=Qu();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=P.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.snapshot=U.unwrap(U.decode(n,n.uint32()));continue;case 3:if(i!==26)break;o.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return $i.fromPartial(t??{})},fromPartial(t){let e=Qu();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?P.fromPartial(t.baseEvent):void 0,e.snapshot=t.snapshot??void 0,e.subagentRunId=t.subagentRunId??void 0,e}};function Ju(){return{baseEvent:void 0,delta:[],subagentRunId:void 0}}var Bi={encode(t,e=new q){t.baseEvent!==void 0&&P.encode(t.baseEvent,e.uint32(10).fork()).join();for(let n of t.delta)Ti.encode(n,e.uint32(18).fork()).join();return t.subagentRunId!==void 0&&e.uint32(26).string(t.subagentRunId),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=Ju();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=P.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.delta.push(Ti.decode(n,n.uint32()));continue;case 3:if(i!==26)break;o.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Bi.fromPartial(t??{})},fromPartial(t){let e=Ju();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?P.fromPartial(t.baseEvent):void 0,e.delta=t.delta?.map(n=>Ti.fromPartial(n))||[],e.subagentRunId=t.subagentRunId??void 0,e}};function eh(){return{baseEvent:void 0,messages:[]}}var ji={encode(t,e=new q){t.baseEvent!==void 0&&P.encode(t.baseEvent,e.uint32(10).fork()).join();for(let n of t.messages)Li.encode(n,e.uint32(18).fork()).join();return e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=eh();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=P.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.messages.push(Li.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return ji.fromPartial(t??{})},fromPartial(t){let e=eh();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?P.fromPartial(t.baseEvent):void 0,e.messages=t.messages?.map(n=>Li.fromPartial(n))||[],e}};function th(){return{baseEvent:void 0,event:void 0,source:void 0,subagentRunId:void 0}}var Vi={encode(t,e=new q){return t.baseEvent!==void 0&&P.encode(t.baseEvent,e.uint32(10).fork()).join(),t.event!==void 0&&U.encode(U.wrap(t.event),e.uint32(18).fork()).join(),t.source!==void 0&&e.uint32(26).string(t.source),t.subagentRunId!==void 0&&e.uint32(34).string(t.subagentRunId),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=th();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=P.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.event=U.unwrap(U.decode(n,n.uint32()));continue;case 3:if(i!==26)break;o.source=n.string();continue;case 4:if(i!==34)break;o.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Vi.fromPartial(t??{})},fromPartial(t){let e=th();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?P.fromPartial(t.baseEvent):void 0,e.event=t.event??void 0,e.source=t.source??void 0,e.subagentRunId=t.subagentRunId??void 0,e}};function nh(){return{baseEvent:void 0,name:"",value:void 0,subagentRunId:void 0}}var qi={encode(t,e=new q){return t.baseEvent!==void 0&&P.encode(t.baseEvent,e.uint32(10).fork()).join(),t.name!==""&&e.uint32(18).string(t.name),t.value!==void 0&&U.encode(U.wrap(t.value),e.uint32(26).fork()).join(),t.subagentRunId!==void 0&&e.uint32(34).string(t.subagentRunId),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=nh();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=P.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.name=n.string();continue;case 3:if(i!==26)break;o.value=U.unwrap(U.decode(n,n.uint32()));continue;case 4:if(i!==34)break;o.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return qi.fromPartial(t??{})},fromPartial(t){let e=nh();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?P.fromPartial(t.baseEvent):void 0,e.name=t.name??"",e.value=t.value??void 0,e.subagentRunId=t.subagentRunId??void 0,e}};function rh(){return{baseEvent:void 0,threadId:"",runId:""}}var Wi={encode(t,e=new q){return t.baseEvent!==void 0&&P.encode(t.baseEvent,e.uint32(10).fork()).join(),t.threadId!==""&&e.uint32(18).string(t.threadId),t.runId!==""&&e.uint32(26).string(t.runId),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=rh();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=P.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.threadId=n.string();continue;case 3:if(i!==26)break;o.runId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Wi.fromPartial(t??{})},fromPartial(t){let e=rh();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?P.fromPartial(t.baseEvent):void 0,e.threadId=t.threadId??"",e.runId=t.runId??"",e}};function oh(){return{provider:void 0,model:void 0,inputTokens:void 0,outputTokens:void 0,totalTokens:void 0,reasoningTokens:void 0,cachedInputTokens:void 0}}var gn={encode(t,e=new q){return t.provider!==void 0&&e.uint32(10).string(t.provider),t.model!==void 0&&e.uint32(18).string(t.model),t.inputTokens!==void 0&&e.uint32(24).int64(t.inputTokens),t.outputTokens!==void 0&&e.uint32(32).int64(t.outputTokens),t.totalTokens!==void 0&&e.uint32(40).int64(t.totalTokens),t.reasoningTokens!==void 0&&e.uint32(48).int64(t.reasoningTokens),t.cachedInputTokens!==void 0&&e.uint32(56).int64(t.cachedInputTokens),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=oh();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.provider=n.string();continue;case 2:if(i!==18)break;o.model=n.string();continue;case 3:if(i!==24)break;o.inputTokens=er(n.int64());continue;case 4:if(i!==32)break;o.outputTokens=er(n.int64());continue;case 5:if(i!==40)break;o.totalTokens=er(n.int64());continue;case 6:if(i!==48)break;o.reasoningTokens=er(n.int64());continue;case 7:if(i!==56)break;o.cachedInputTokens=er(n.int64());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return gn.fromPartial(t??{})},fromPartial(t){let e=oh();return e.provider=t.provider??void 0,e.model=t.model??void 0,e.inputTokens=t.inputTokens??void 0,e.outputTokens=t.outputTokens??void 0,e.totalTokens=t.totalTokens??void 0,e.reasoningTokens=t.reasoningTokens??void 0,e.cachedInputTokens=t.cachedInputTokens??void 0,e}};function ih(){return{baseEvent:void 0,threadId:"",runId:"",result:void 0,outcome:"",interrupts:[],usage:[]}}var Xi={encode(t,e=new q){t.baseEvent!==void 0&&P.encode(t.baseEvent,e.uint32(10).fork()).join(),t.threadId!==""&&e.uint32(18).string(t.threadId),t.runId!==""&&e.uint32(26).string(t.runId),t.result!==void 0&&U.encode(U.wrap(t.result),e.uint32(34).fork()).join(),t.outcome!==""&&e.uint32(42).string(t.outcome);for(let n of t.interrupts)Pi.encode(n,e.uint32(50).fork()).join();for(let n of t.usage)gn.encode(n,e.uint32(58).fork()).join();return e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=ih();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=P.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.threadId=n.string();continue;case 3:if(i!==26)break;o.runId=n.string();continue;case 4:if(i!==34)break;o.result=U.unwrap(U.decode(n,n.uint32()));continue;case 5:if(i!==42)break;o.outcome=n.string();continue;case 6:if(i!==50)break;o.interrupts.push(Pi.decode(n,n.uint32()));continue;case 7:if(i!==58)break;o.usage.push(gn.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Xi.fromPartial(t??{})},fromPartial(t){let e=ih();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?P.fromPartial(t.baseEvent):void 0,e.threadId=t.threadId??"",e.runId=t.runId??"",e.result=t.result??void 0,e.outcome=t.outcome??"",e.interrupts=t.interrupts?.map(n=>Pi.fromPartial(n))||[],e.usage=t.usage?.map(n=>gn.fromPartial(n))||[],e}};function sh(){return{baseEvent:void 0,code:void 0,message:"",usage:[]}}var Yi={encode(t,e=new q){t.baseEvent!==void 0&&P.encode(t.baseEvent,e.uint32(10).fork()).join(),t.code!==void 0&&e.uint32(18).string(t.code),t.message!==""&&e.uint32(26).string(t.message);for(let n of t.usage)gn.encode(n,e.uint32(34).fork()).join();return e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=sh();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=P.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.code=n.string();continue;case 3:if(i!==26)break;o.message=n.string();continue;case 4:if(i!==34)break;o.usage.push(gn.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Yi.fromPartial(t??{})},fromPartial(t){let e=sh();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?P.fromPartial(t.baseEvent):void 0,e.code=t.code??void 0,e.message=t.message??"",e.usage=t.usage?.map(n=>gn.fromPartial(n))||[],e}};function ah(){return{baseEvent:void 0,stepName:"",subagentRunId:void 0}}var Ki={encode(t,e=new q){return t.baseEvent!==void 0&&P.encode(t.baseEvent,e.uint32(10).fork()).join(),t.stepName!==""&&e.uint32(18).string(t.stepName),t.subagentRunId!==void 0&&e.uint32(26).string(t.subagentRunId),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=ah();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=P.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.stepName=n.string();continue;case 3:if(i!==26)break;o.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Ki.fromPartial(t??{})},fromPartial(t){let e=ah();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?P.fromPartial(t.baseEvent):void 0,e.stepName=t.stepName??"",e.subagentRunId=t.subagentRunId??void 0,e}};function lh(){return{baseEvent:void 0,stepName:"",subagentRunId:void 0}}var Zi={encode(t,e=new q){return t.baseEvent!==void 0&&P.encode(t.baseEvent,e.uint32(10).fork()).join(),t.stepName!==""&&e.uint32(18).string(t.stepName),t.subagentRunId!==void 0&&e.uint32(26).string(t.subagentRunId),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=lh();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=P.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.stepName=n.string();continue;case 3:if(i!==26)break;o.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Zi.fromPartial(t??{})},fromPartial(t){let e=lh();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?P.fromPartial(t.baseEvent):void 0,e.stepName=t.stepName??"",e.subagentRunId=t.subagentRunId??void 0,e}};function dh(){return{baseEvent:void 0,messageId:void 0,role:void 0,delta:void 0,name:void 0,subagentRunId:void 0}}var Qi={encode(t,e=new q){return t.baseEvent!==void 0&&P.encode(t.baseEvent,e.uint32(10).fork()).join(),t.messageId!==void 0&&e.uint32(18).string(t.messageId),t.role!==void 0&&e.uint32(26).string(t.role),t.delta!==void 0&&e.uint32(34).string(t.delta),t.name!==void 0&&e.uint32(42).string(t.name),t.subagentRunId!==void 0&&e.uint32(50).string(t.subagentRunId),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=dh();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=P.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.messageId=n.string();continue;case 3:if(i!==26)break;o.role=n.string();continue;case 4:if(i!==34)break;o.delta=n.string();continue;case 5:if(i!==42)break;o.name=n.string();continue;case 6:if(i!==50)break;o.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Qi.fromPartial(t??{})},fromPartial(t){let e=dh();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?P.fromPartial(t.baseEvent):void 0,e.messageId=t.messageId??void 0,e.role=t.role??void 0,e.delta=t.delta??void 0,e.name=t.name??void 0,e.subagentRunId=t.subagentRunId??void 0,e}};function ch(){return{baseEvent:void 0,toolCallId:void 0,toolCallName:void 0,parentMessageId:void 0,delta:void 0,subagentRunId:void 0}}var Ji={encode(t,e=new q){return t.baseEvent!==void 0&&P.encode(t.baseEvent,e.uint32(10).fork()).join(),t.toolCallId!==void 0&&e.uint32(18).string(t.toolCallId),t.toolCallName!==void 0&&e.uint32(26).string(t.toolCallName),t.parentMessageId!==void 0&&e.uint32(34).string(t.parentMessageId),t.delta!==void 0&&e.uint32(42).string(t.delta),t.subagentRunId!==void 0&&e.uint32(50).string(t.subagentRunId),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=ch();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=P.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.toolCallId=n.string();continue;case 3:if(i!==26)break;o.toolCallName=n.string();continue;case 4:if(i!==34)break;o.parentMessageId=n.string();continue;case 5:if(i!==42)break;o.delta=n.string();continue;case 6:if(i!==50)break;o.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Ji.fromPartial(t??{})},fromPartial(t){let e=ch();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?P.fromPartial(t.baseEvent):void 0,e.toolCallId=t.toolCallId??void 0,e.toolCallName=t.toolCallName??void 0,e.parentMessageId=t.parentMessageId??void 0,e.delta=t.delta??void 0,e.subagentRunId=t.subagentRunId??void 0,e}};function uh(){return{baseEvent:void 0,subagentRunId:"",name:"",description:void 0,parentSubagentRunId:void 0,parentToolCallId:void 0,parentMessageId:void 0}}var es={encode(t,e=new q){return t.baseEvent!==void 0&&P.encode(t.baseEvent,e.uint32(10).fork()).join(),t.subagentRunId!==""&&e.uint32(18).string(t.subagentRunId),t.name!==""&&e.uint32(26).string(t.name),t.description!==void 0&&e.uint32(34).string(t.description),t.parentSubagentRunId!==void 0&&e.uint32(42).string(t.parentSubagentRunId),t.parentToolCallId!==void 0&&e.uint32(50).string(t.parentToolCallId),t.parentMessageId!==void 0&&e.uint32(58).string(t.parentMessageId),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=uh();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=P.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.subagentRunId=n.string();continue;case 3:if(i!==26)break;o.name=n.string();continue;case 4:if(i!==34)break;o.description=n.string();continue;case 5:if(i!==42)break;o.parentSubagentRunId=n.string();continue;case 6:if(i!==50)break;o.parentToolCallId=n.string();continue;case 7:if(i!==58)break;o.parentMessageId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return es.fromPartial(t??{})},fromPartial(t){let e=uh();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?P.fromPartial(t.baseEvent):void 0,e.subagentRunId=t.subagentRunId??"",e.name=t.name??"",e.description=t.description??void 0,e.parentSubagentRunId=t.parentSubagentRunId??void 0,e.parentToolCallId=t.parentToolCallId??void 0,e.parentMessageId=t.parentMessageId??void 0,e}};function hh(){return{baseEvent:void 0,subagentRunId:"",result:void 0,outcome:"",interruptIds:[]}}var ts={encode(t,e=new q){t.baseEvent!==void 0&&P.encode(t.baseEvent,e.uint32(10).fork()).join(),t.subagentRunId!==""&&e.uint32(18).string(t.subagentRunId),t.result!==void 0&&U.encode(U.wrap(t.result),e.uint32(26).fork()).join(),t.outcome!==""&&e.uint32(34).string(t.outcome);for(let n of t.interruptIds)e.uint32(42).string(n);return e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=hh();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=P.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.subagentRunId=n.string();continue;case 3:if(i!==26)break;o.result=U.unwrap(U.decode(n,n.uint32()));continue;case 4:if(i!==34)break;o.outcome=n.string();continue;case 5:if(i!==42)break;o.interruptIds.push(n.string());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return ts.fromPartial(t??{})},fromPartial(t){let e=hh();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?P.fromPartial(t.baseEvent):void 0,e.subagentRunId=t.subagentRunId??"",e.result=t.result??void 0,e.outcome=t.outcome??"",e.interruptIds=t.interruptIds?.map(n=>n)||[],e}};function ph(){return{baseEvent:void 0,subagentRunId:"",message:"",code:void 0}}var ns={encode(t,e=new q){return t.baseEvent!==void 0&&P.encode(t.baseEvent,e.uint32(10).fork()).join(),t.subagentRunId!==""&&e.uint32(18).string(t.subagentRunId),t.message!==""&&e.uint32(26).string(t.message),t.code!==void 0&&e.uint32(34).string(t.code),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=ph();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=P.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.subagentRunId=n.string();continue;case 3:if(i!==26)break;o.message=n.string();continue;case 4:if(i!==34)break;o.code=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return ns.fromPartial(t??{})},fromPartial(t){let e=ph();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?P.fromPartial(t.baseEvent):void 0,e.subagentRunId=t.subagentRunId??"",e.message=t.message??"",e.code=t.code??void 0,e}};function fh(){return{textMessageStart:void 0,textMessageContent:void 0,textMessageEnd:void 0,toolCallStart:void 0,toolCallArgs:void 0,toolCallEnd:void 0,stateSnapshot:void 0,stateDelta:void 0,messagesSnapshot:void 0,raw:void 0,custom:void 0,runStarted:void 0,runFinished:void 0,runError:void 0,stepStarted:void 0,stepFinished:void 0,textMessageChunk:void 0,toolCallChunk:void 0,subagentStarted:void 0,subagentFinished:void 0,subagentError:void 0}}var mh={encode(t,e=new q){return t.textMessageStart!==void 0&&Di.encode(t.textMessageStart,e.uint32(10).fork()).join(),t.textMessageContent!==void 0&&Ui.encode(t.textMessageContent,e.uint32(18).fork()).join(),t.textMessageEnd!==void 0&&Hi.encode(t.textMessageEnd,e.uint32(26).fork()).join(),t.toolCallStart!==void 0&&Gi.encode(t.toolCallStart,e.uint32(34).fork()).join(),t.toolCallArgs!==void 0&&zi.encode(t.toolCallArgs,e.uint32(42).fork()).join(),t.toolCallEnd!==void 0&&Fi.encode(t.toolCallEnd,e.uint32(50).fork()).join(),t.stateSnapshot!==void 0&&$i.encode(t.stateSnapshot,e.uint32(58).fork()).join(),t.stateDelta!==void 0&&Bi.encode(t.stateDelta,e.uint32(66).fork()).join(),t.messagesSnapshot!==void 0&&ji.encode(t.messagesSnapshot,e.uint32(74).fork()).join(),t.raw!==void 0&&Vi.encode(t.raw,e.uint32(82).fork()).join(),t.custom!==void 0&&qi.encode(t.custom,e.uint32(90).fork()).join(),t.runStarted!==void 0&&Wi.encode(t.runStarted,e.uint32(98).fork()).join(),t.runFinished!==void 0&&Xi.encode(t.runFinished,e.uint32(106).fork()).join(),t.runError!==void 0&&Yi.encode(t.runError,e.uint32(114).fork()).join(),t.stepStarted!==void 0&&Ki.encode(t.stepStarted,e.uint32(122).fork()).join(),t.stepFinished!==void 0&&Zi.encode(t.stepFinished,e.uint32(130).fork()).join(),t.textMessageChunk!==void 0&&Qi.encode(t.textMessageChunk,e.uint32(138).fork()).join(),t.toolCallChunk!==void 0&&Ji.encode(t.toolCallChunk,e.uint32(146).fork()).join(),t.subagentStarted!==void 0&&es.encode(t.subagentStarted,e.uint32(154).fork()).join(),t.subagentFinished!==void 0&&ts.encode(t.subagentFinished,e.uint32(162).fork()).join(),t.subagentError!==void 0&&ns.encode(t.subagentError,e.uint32(170).fork()).join(),e},decode(t,e){let n=t instanceof C?t:new C(t),r=e===void 0?n.len:n.pos+e,o=fh();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.textMessageStart=Di.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.textMessageContent=Ui.decode(n,n.uint32());continue;case 3:if(i!==26)break;o.textMessageEnd=Hi.decode(n,n.uint32());continue;case 4:if(i!==34)break;o.toolCallStart=Gi.decode(n,n.uint32());continue;case 5:if(i!==42)break;o.toolCallArgs=zi.decode(n,n.uint32());continue;case 6:if(i!==50)break;o.toolCallEnd=Fi.decode(n,n.uint32());continue;case 7:if(i!==58)break;o.stateSnapshot=$i.decode(n,n.uint32());continue;case 8:if(i!==66)break;o.stateDelta=Bi.decode(n,n.uint32());continue;case 9:if(i!==74)break;o.messagesSnapshot=ji.decode(n,n.uint32());continue;case 10:if(i!==82)break;o.raw=Vi.decode(n,n.uint32());continue;case 11:if(i!==90)break;o.custom=qi.decode(n,n.uint32());continue;case 12:if(i!==98)break;o.runStarted=Wi.decode(n,n.uint32());continue;case 13:if(i!==106)break;o.runFinished=Xi.decode(n,n.uint32());continue;case 14:if(i!==114)break;o.runError=Yi.decode(n,n.uint32());continue;case 15:if(i!==122)break;o.stepStarted=Ki.decode(n,n.uint32());continue;case 16:if(i!==130)break;o.stepFinished=Zi.decode(n,n.uint32());continue;case 17:if(i!==138)break;o.textMessageChunk=Qi.decode(n,n.uint32());continue;case 18:if(i!==146)break;o.toolCallChunk=Ji.decode(n,n.uint32());continue;case 19:if(i!==154)break;o.subagentStarted=es.decode(n,n.uint32());continue;case 20:if(i!==162)break;o.subagentFinished=ts.decode(n,n.uint32());continue;case 21:if(i!==170)break;o.subagentError=ns.decode(n,n.uint32());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return mh.fromPartial(t??{})},fromPartial(t){let e=fh();return e.textMessageStart=t.textMessageStart!==void 0&&t.textMessageStart!==null?Di.fromPartial(t.textMessageStart):void 0,e.textMessageContent=t.textMessageContent!==void 0&&t.textMessageContent!==null?Ui.fromPartial(t.textMessageContent):void 0,e.textMessageEnd=t.textMessageEnd!==void 0&&t.textMessageEnd!==null?Hi.fromPartial(t.textMessageEnd):void 0,e.toolCallStart=t.toolCallStart!==void 0&&t.toolCallStart!==null?Gi.fromPartial(t.toolCallStart):void 0,e.toolCallArgs=t.toolCallArgs!==void 0&&t.toolCallArgs!==null?zi.fromPartial(t.toolCallArgs):void 0,e.toolCallEnd=t.toolCallEnd!==void 0&&t.toolCallEnd!==null?Fi.fromPartial(t.toolCallEnd):void 0,e.stateSnapshot=t.stateSnapshot!==void 0&&t.stateSnapshot!==null?$i.fromPartial(t.stateSnapshot):void 0,e.stateDelta=t.stateDelta!==void 0&&t.stateDelta!==null?Bi.fromPartial(t.stateDelta):void 0,e.messagesSnapshot=t.messagesSnapshot!==void 0&&t.messagesSnapshot!==null?ji.fromPartial(t.messagesSnapshot):void 0,e.raw=t.raw!==void 0&&t.raw!==null?Vi.fromPartial(t.raw):void 0,e.custom=t.custom!==void 0&&t.custom!==null?qi.fromPartial(t.custom):void 0,e.runStarted=t.runStarted!==void 0&&t.runStarted!==null?Wi.fromPartial(t.runStarted):void 0,e.runFinished=t.runFinished!==void 0&&t.runFinished!==null?Xi.fromPartial(t.runFinished):void 0,e.runError=t.runError!==void 0&&t.runError!==null?Yi.fromPartial(t.runError):void 0,e.stepStarted=t.stepStarted!==void 0&&t.stepStarted!==null?Ki.fromPartial(t.stepStarted):void 0,e.stepFinished=t.stepFinished!==void 0&&t.stepFinished!==null?Zi.fromPartial(t.stepFinished):void 0,e.textMessageChunk=t.textMessageChunk!==void 0&&t.textMessageChunk!==null?Qi.fromPartial(t.textMessageChunk):void 0,e.toolCallChunk=t.toolCallChunk!==void 0&&t.toolCallChunk!==null?Ji.fromPartial(t.toolCallChunk):void 0,e.subagentStarted=t.subagentStarted!==void 0&&t.subagentStarted!==null?es.fromPartial(t.subagentStarted):void 0,e.subagentFinished=t.subagentFinished!==void 0&&t.subagentFinished!==null?ts.fromPartial(t.subagentFinished):void 0,e.subagentError=t.subagentError!==void 0&&t.subagentError!==null?ns.fromPartial(t.subagentError):void 0,e}};function er(t){let e=globalThis.Number(t.toString());if(e>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");if(e<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");return e}var gh=t=>t&&typeof t=="object"?t:void 0;var Ei=t=>{let e=gh(t);if(e){if(e.data){let n=e.data;return{type:"data",value:n.value,mimeType:n.mimeType}}if(e.url){let n=e.url;return{type:"url",value:n.value,mimeType:n.mimeType}}}},$b=t=>{let e=gh(t);if(e){if(e.text)return{type:"text",text:e.text.text};if(e.image){let n=e.image;return{type:"image",source:Ei(n.source),metadata:n.metadata}}if(e.audio){let n=e.audio;return{type:"audio",source:Ei(n.source),metadata:n.metadata}}if(e.video){let n=e.video;return{type:"video",source:Ei(n.source),metadata:n.metadata}}if(e.document){let n=e.document;return{type:"document",source:Ei(n.source),metadata:n.metadata}}}};function vh(t){let e=mh.decode(t),n=Object.values(e).find(r=>r!==void 0);if(!n)throw new Error("Invalid event");if(n.type=Fb[n.baseEvent.type],n.timestamp=n.baseEvent.timestamp,n.rawEvent=n.baseEvent.rawEvent,n.baseEvent.metadata!==void 0&&(n.metadata=n.baseEvent.metadata),delete n.baseEvent,n.type===g.MESSAGES_SNAPSHOT)for(let r of n.messages){let o=r;if(o.role==="user"&&Array.isArray(o.contentParts)){let i=o.contentParts.map(s=>$b(s)).filter(s=>s!==void 0);i.length>0&&(o.content=i)}Array.isArray(o.contentParts)&&o.contentParts.length===0&&(o.contentParts=void 0),o.toolCalls?.length===0&&(o.toolCalls=void 0)}if(n.type===g.RUN_FINISHED){let r=n,o=typeof r.outcome=="string"&&r.outcome!==""?r.outcome:void 0,i=Array.isArray(r.interrupts)?r.interrupts:[];delete r.interrupts,o==="interrupt"?r.outcome={type:"interrupt",interrupts:i}:o==="success"?r.outcome={type:"success"}:delete r.outcome}if(n.type===g.SUBAGENT_FINISHED){let r=n,o=typeof r.outcome=="string"&&r.outcome!==""?r.outcome:void 0,i=Array.isArray(r.interruptIds)?r.interruptIds:[];delete r.interruptIds,o==="suspended"?r.outcome={type:"suspended",...i.length>0&&{interruptIds:i}}:o==="success"?r.outcome={type:"success"}:delete r.outcome}if((n.type===g.RUN_FINISHED||n.type===g.RUN_ERROR)&&Array.isArray(n.usage)&&n.usage.length===0&&delete n.usage,n.type===g.STATE_DELTA)for(let r of n.delta)r.op=zb[r.op].toLowerCase(),Object.keys(r).forEach(o=>{r[o]===void 0&&delete r[o]});return Object.keys(n).forEach(r=>{n[r]===void 0&&delete n[r]}),Go.parse(n)}var Rl="application/vnd.ag-ui.event+proto";var jb=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,Il=t=>{if(typeof t!="string")throw new TypeError("Invalid argument expected string");let e=t.match(jb);if(!e)throw new Error(`Invalid argument not valid semver ('${t}' received)`);return e.shift(),e},bh=t=>t==="*"||t==="x"||t==="X",yh=t=>{let e=parseInt(t,10);return isNaN(e)?t:e},Vb=(t,e)=>typeof t!=typeof e?[String(t),String(e)]:[t,e],qb=(t,e)=>{if(bh(t)||bh(e))return 0;let[n,r]=Vb(yh(t),yh(e));return n>r?1:n<r?-1:0},Cl=(t,e)=>{for(let n=0;n<Math.max(t.length,e.length);n++){let r=qb(t[n]||"0",e[n]||"0");if(r!==0)return r}return 0};var tr=(t,e)=>{let n=Il(t),r=Il(e),o=n.pop(),i=r.pop(),s=Cl(n,r);return s!==0?s:o&&i?Cl(o.split("."),i.split(".")):o||i?o?-1:1:0};var J=t=>{if(typeof structuredClone=="function")return structuredClone(t);try{return JSON.parse(JSON.stringify(t))}catch{return Array.isArray(t)?[...t]:{...t}}};function be(){return Ct()}function Ml(t){if(Object.freeze(t),typeof t=="object"&&t)for(let e of Object.values(t))typeof e=="object"&&e&&!Object.isFrozen(e)&&Ml(e);return t}var wh=512*1024;function xh(t,e,n){let r=0,o=[t,e],i=new WeakSet;for(;o.length>0;){let s=o.pop();if(typeof s=="string"){if(r+=s.length,r>n)return!0}else if(typeof s=="object"&&s){if(i.has(s))continue;if(i.add(s),Array.isArray(s))for(let a=0;a<s.length;a++)o.push(s[a]);else{let a=Object.keys(s);for(let l=0;l<a.length;l++){let d=a[l];if(r+=d.length,r>n)return!0;o.push(s[d])}}}}return!1}async function re(t,e,n,r){let o=typeof process<"u"&&process.env!==void 0,i=o&&!!process.env.VITEST_WORKER_ID,s=o&&!!process.env.VITEST_WORKER_ID,a=s&&!xh(e,n,wh),l=a?J(e):e,d=a?J(n):n,u=!1,m=!1,w;for(let p of t)try{a&&(Ml(l),Ml(d));let h=await r(p,l,d);if(h===void 0)continue;let v=!1;if(h.messages!==void 0&&h.messages!==l&&(l=J(h.messages),u=!0,v=!0),h.state!==void 0&&h.state!==d&&(d=J(h.state),m=!0,v=!0),a&&v&&xh(l,d,wh)&&(a=!1),w=h.stopPropagation,w===!0)break}catch(h){if(s&&h instanceof TypeError){if(i)throw h;console.error("AG-UI: Subscriber attempted to mutate frozen inputs in-place. Return mutations via AgentStateMutation instead of mutating directly.",h)}else i||console.error("Subscriber error:",h);continue}return{...u?{messages:Object.isFrozen(l)?J(l):l}:{},...m?{state:Object.isFrozen(d)?J(d):d}:{},...w===void 0?{}:{stopPropagation:w}}}function rs(t){if(!t)return{enabled:!1,events:!1,lifecycle:!1,verbose:!1};if(t===!0)return{enabled:!0,events:!0,lifecycle:!0,verbose:!0};let e=t.events??!0,n=t.lifecycle??!0,r=t.verbose??!1;return{enabled:e||n,events:e,lifecycle:n,verbose:r}}function Or(t){if(t instanceof Ll)return t;if(t===!0)return new Ll(rs(!0))}var Ll=class{constructor(t){this.config=t}event(t,e,n,r){this.config.events&&(this.config.verbose?console.debug(`[${t}] ${e}`,typeof n=="string"?n:JSON.stringify(n)):console.debug(`[${t}] ${e}`,r??n))}lifecycle(t,e,n){this.config.lifecycle&&(n?console.debug(`[${t}] ${e}`,n):console.debug(`[${t}] ${e}`))}get eventsEnabled(){return this.config.events}get lifecycleEnabled(){return this.config.lifecycle}get enabled(){return this.config.enabled}};function Nl(t){return t.enabled?new Ll(t):void 0}function Wb(t,e,n){if(e){let o=t.find(s=>s.id===e);if(o?.role==="assistant")return o;o&&console.warn(`TOOL_CALL_START: parentMessageId '${e}' matches a '${o.role}' message, not assistant \u2014 falling back to toolCallId`);let i={id:o?n:e,role:"assistant",toolCalls:[]};return t.push(i),i}let r={id:n,role:"assistant",toolCalls:[]};return t.push(r),r}function je(t,e){return!t||e.metadata===void 0?!1:(t.metadata=Fc(t.metadata,J(e.metadata)),!0)}var Nh=(t,e,n,r,o)=>{let i=Or(o),s=J(n.messages),a=J(t.state),l={},d=m=>{m.messages!==void 0&&(s=m.messages,l.messages=m.messages),m.state!==void 0&&(a=m.state,l.state=m.state)},u=()=>{let m=J(l);return l={},m.messages!==void 0||m.state!==void 0?ne(m):ni};return e.pipe(vi(async m=>{let w=await re(r,s,a,(p,h,v)=>p.onEvent?.({event:m,agent:n,input:t,messages:h,state:v}));if(d(w),w.stopPropagation===!0?i?.event("APPLY","Event dropped:",m,{type:m.type,reason:"stopPropagation by subscriber"}):i?.event("APPLY","Event applied:",m,{type:m.type,subscribers:r.length}),w.stopPropagation===!0)return u();switch(m.type){case g.TEXT_MESSAGE_START:{let p=await re(r,s,a,(h,v,x)=>h.onTextMessageStartEvent?.({event:m,messages:v,state:x,agent:n,input:t}));if(d(p),p.stopPropagation!==!0){let{messageId:h,role:v="assistant",name:x,subagentRunId:S}=m,_=s.find(b=>b.id===h);if(_?.role==="activity")return console.warn(`TEXT_MESSAGE_START: Message '${h}' is an activity message \u2014 message ids must be unique across activity and text messages`),u();let O=_;if(!O){let b={id:h,role:v,content:"",...x!==void 0&&{name:x},...S!=null&&{subagentRunId:S}};s.push(b),O=b}let G=je(O,m);(!_||G)&&d({messages:s})}return u()}case g.TEXT_MESSAGE_CONTENT:{let{messageId:p,delta:h}=m,v=s.find(S=>S.id===p);if(!v)return console.warn(`TEXT_MESSAGE_CONTENT: No message found with ID '${p}'`),u();if(v.role==="activity")return console.warn(`TEXT_MESSAGE_CONTENT: Message '${p}' is an activity message \u2014 message ids must be unique across activity and text messages`),u();let x=await re(r,s,a,(S,_,O)=>S.onTextMessageContentEvent?.({event:m,messages:_,state:O,agent:n,input:t,textMessageBuffer:typeof v.content=="string"?v.content:""}));return d(x),x.stopPropagation!==!0&&(v.content=`${typeof v.content=="string"?v.content:""}${h}`,je(v,m),d({messages:s})),u()}case g.TEXT_MESSAGE_END:{let{messageId:p}=m,h=s.find(x=>x.id===p);if(!h)return console.warn(`TEXT_MESSAGE_END: No message found with ID '${p}'`),u();if(h.role==="activity")return console.warn(`TEXT_MESSAGE_END: Message '${p}' is an activity message \u2014 message ids must be unique across activity and text messages`),u();let v=await re(r,s,a,(x,S,_)=>x.onTextMessageEndEvent?.({event:m,messages:S,state:_,agent:n,input:t,textMessageBuffer:typeof h.content=="string"?h.content:""}));return d(v),v.stopPropagation!==!0&&je(h,m)&&d({messages:s}),await Promise.all(r.map(x=>{x.onNewMessage?.({message:h,messages:s,state:a,agent:n,input:t})})),u()}case g.TOOL_CALL_START:{let p=await re(r,s,a,(h,v,x)=>h.onToolCallStartEvent?.({event:m,messages:v,state:x,agent:n,input:t}));if(d(p),p.stopPropagation!==!0){let{toolCallId:h,toolCallName:v,parentMessageId:x,subagentRunId:S}=m,_=s.find(A=>A.toolCalls?.some(E=>E.id===h))?.toolCalls?.find(A=>A.id===h);if(_){let A=_.function.name!==v;return A&&(console.warn(`TOOL_CALL_START: tool call '${h}' already exists with name '${_.function.name}' \u2014 updating it to '${v}'`),_.function.name=v),(je(_,m)||A)&&d({messages:s}),u()}let O=new Set(s.map(A=>A.id)),G=Wb(s,x,h);!O.has(G.id)&&S!=null&&G.subagentRunId===void 0&&(G.subagentRunId=S),G.toolCalls??=[];let b={id:h,type:"function",function:{name:v,arguments:""}};G.toolCalls.push(b),je(b,m),d({messages:s})}return u()}case g.TOOL_CALL_ARGS:{let{toolCallId:p,delta:h}=m,v=s.find(_=>_.toolCalls?.some(O=>O.id===p));if(!v)return console.warn(`TOOL_CALL_ARGS: No message found containing tool call with ID '${p}'`),u();let x=v.toolCalls?.find(_=>_.id===p);if(!x)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${p}'`),u();let S=await re(r,s,a,(_,O,G)=>{let b=x.function.arguments,A=x.function.name,E={};try{E=wi(b)}catch{}return _.onToolCallArgsEvent?.({event:m,messages:O,state:G,agent:n,input:t,toolCallBuffer:b,toolCallName:A,partialToolCallArgs:E})});return d(S),S.stopPropagation!==!0&&(x.function.arguments+=h,je(x,m),d({messages:s})),u()}case g.TOOL_CALL_END:{let{toolCallId:p}=m,h=s.find(S=>S.toolCalls?.some(_=>_.id===p));if(!h)return console.warn(`TOOL_CALL_END: No message found containing tool call with ID '${p}'`),u();let v=h.toolCalls?.find(S=>S.id===p);if(!v)return console.warn(`TOOL_CALL_END: No tool call found with ID '${p}'`),u();let x=await re(r,s,a,(S,_,O)=>{let G=v.function.arguments,b=v.function.name,A={};try{A=JSON.parse(G)}catch{}return S.onToolCallEndEvent?.({event:m,messages:_,state:O,agent:n,input:t,toolCallName:b,toolCallArgs:A})});return d(x),x.stopPropagation!==!0&&je(v,m)&&d({messages:s}),await Promise.all(r.map(S=>{S.onNewToolCall?.({toolCall:v,messages:s,state:a,agent:n,input:t})})),u()}case g.TOOL_CALL_RESULT:{let p=await re(r,s,a,(h,v,x)=>h.onToolCallResultEvent?.({event:m,messages:v,state:x,agent:n,input:t}));if(d(p),p.stopPropagation!==!0){let{messageId:h,toolCallId:v,content:x,role:S,subagentRunId:_}=m,O={id:h,toolCallId:v,role:S||"tool",content:x,..._!=null&&{subagentRunId:_}};je(O,m);let G=s.findIndex(b=>b.role==="assistant"&&b.toolCalls?.some(A=>A.id===v));if(G===-1)s.push(O);else{let b=G+1;for(;b<s.length&&s[b].role==="tool";)b++;s.splice(b,0,O)}await Promise.all(r.map(b=>{b.onNewMessage?.({message:O,messages:s,state:a,agent:n,input:t})})),d({messages:s})}return u()}case g.STATE_SNAPSHOT:{let p=await re(r,s,a,(h,v,x)=>h.onStateSnapshotEvent?.({event:m,messages:v,state:x,agent:n,input:t}));if(d(p),p.stopPropagation!==!0){let{snapshot:h}=m;a=h,d({state:a})}return u()}case g.STATE_DELTA:{let p=await re(r,s,a,(h,v,x)=>h.onStateDeltaEvent?.({event:m,messages:v,state:x,agent:n,input:t}));if(d(p),p.stopPropagation!==!0){let{delta:h}=m;try{a=Wo.applyPatch(a,h,!0,!1).newDocument,d({state:a})}catch(v){let x=v instanceof Error?v.message:String(v);console.warn(`Failed to apply state patch:
|
|
6
|
-
Current state: ${JSON.stringify(a,null,2)}
|
|
7
|
-
|
|
8
|
-
Error: ${x}`)}}return u()}case g.MESSAGES_SNAPSHOT:{let p=await re(r,s,a,(h,v,x)=>h.onMessagesSnapshotEvent?.({event:m,messages:v,state:x,agent:n,input:t}));if(d(p),p.stopPropagation!==!0){let{messages:h}=m,v=h.map(b=>{if(b.subagentRunId!==null)return b;let A={...b};return delete A.subagentRunId,A}),x=new Map(v.map(b=>[b.id,b])),S=v.some(b=>b.role==="activity"),_=v.some(b=>b.role==="reasoning"),O=b=>b.role==="activity"&&!S||b.role==="reasoning"&&!_;s=s.filter(b=>O(b)||x.has(b.id)).map(b=>O(b)?b:x.get(b.id));let G=new Set(s.map(b=>b.id));for(let b of v)G.has(b.id)||s.push(b);d({messages:s})}return u()}case g.ACTIVITY_SNAPSHOT:{let p=m,h=s.findIndex(O=>O.id===p.messageId),v=h>=0?s[h]:void 0,x=v?.role==="activity"?v:void 0,S=p.replace??!0,_=await re(r,s,a,(O,G,b)=>O.onActivitySnapshotEvent?.({event:p,messages:G,state:b,agent:n,input:t,activityMessage:x,existingMessage:v}));if(d(_),_.stopPropagation!==!0){let O={id:p.messageId,role:"activity",activityType:p.activityType,content:J(p.content),...p.subagentRunId!=null&&{subagentRunId:p.subagentRunId}},G,b;h===-1?(s.push(O),G=O,b=O):x?(S&&(s[h]={...x,activityType:p.activityType,content:J(p.content),subagentRunId:p.subagentRunId},p.subagentRunId??delete s[h].subagentRunId),b=s[h]):S&&(s[h]=O,G=O,b=O),je(b,p),d({messages:s}),G&&await Promise.all(r.map(A=>A.onNewMessage?.({message:G,messages:s,state:a,agent:n,input:t})))}return u()}case g.ACTIVITY_DELTA:{let p=m,h=s.findIndex(_=>_.id===p.messageId);if(h===-1)return u();let v=s[h];if(v.role!=="activity")return console.warn(`ACTIVITY_DELTA: Message '${p.messageId}' is not an activity message`),u();let x=v,S=await re(r,s,a,(_,O,G)=>_.onActivityDeltaEvent?.({event:p,messages:O,state:G,agent:n,input:t,activityMessage:x}));if(d(S),S.stopPropagation!==!0)try{je(x,p)&&d({messages:s});let _=J(x.content??{}),O=Wo.applyPatch(_,p.patch??[],!0,!1).newDocument;s[h]={...x,content:J(O),activityType:p.activityType},d({messages:s})}catch(_){let O=_ instanceof Error?_.message:String(_);console.warn(`Failed to apply activity patch for '${p.messageId}': ${O}`)}return u()}case g.RAW:return d(await re(r,s,a,(p,h,v)=>p.onRawEvent?.({event:m,messages:h,state:v,agent:n,input:t}))),u();case g.CUSTOM:return d(await re(r,s,a,(p,h,v)=>p.onCustomEvent?.({event:m,messages:h,state:v,agent:n,input:t}))),u();case g.RUN_STARTED:{let p=await re(r,s,a,(h,v,x)=>h.onRunStartedEvent?.({event:m,messages:v,state:x,agent:n,input:t}));if(d(p),p.stopPropagation!==!0){let h=m;if(h.input?.messages){for(let v of h.input.messages){let x=v;if(v.subagentRunId===null){let S={...v};delete S.subagentRunId,x=S}s.find(S=>S.id===x.id)||s.push(x)}d({messages:s})}}return u()}case g.RUN_FINISHED:{let p=m,h=p.outcome?.type==="interrupt"?{event:p,outcome:"interrupt",interrupts:p.outcome.interrupts}:{event:p,outcome:"success",result:p.result},v=await re(r,s,a,(x,S,_)=>x.onRunFinishedEvent?.({...h,messages:S,state:_,agent:n,input:t}));return d(v),v.stopPropagation!==!0&&(n.pendingInterrupts=h.outcome==="interrupt"?h.interrupts.map(x=>{if(x.subagentRunId!==null)return x;let S={...x};return delete S.subagentRunId,S}):[]),u()}case g.RUN_ERROR:return d(await re(r,s,a,(p,h,v)=>p.onRunErrorEvent?.({event:m,messages:h,state:v,agent:n,input:t}))),u();case g.STEP_STARTED:return d(await re(r,s,a,(p,h,v)=>p.onStepStartedEvent?.({event:m,messages:h,state:v,agent:n,input:t}))),u();case g.STEP_FINISHED:return d(await re(r,s,a,(p,h,v)=>p.onStepFinishedEvent?.({event:m,messages:h,state:v,agent:n,input:t}))),u();case g.TEXT_MESSAGE_CHUNK:throw Error("TEXT_MESSAGE_CHUNK must be transformed before being applied");case g.TOOL_CALL_CHUNK:throw Error("TOOL_CALL_CHUNK must be transformed before being applied");case g.THINKING_START:return u();case g.THINKING_END:return u();case g.THINKING_TEXT_MESSAGE_START:return u();case g.THINKING_TEXT_MESSAGE_CONTENT:return u();case g.THINKING_TEXT_MESSAGE_END:return u();case g.REASONING_START:return d(await re(r,s,a,(p,h,v)=>p.onReasoningStartEvent?.({event:m,messages:h,state:v,agent:n,input:t}))),u();case g.REASONING_MESSAGE_START:{let p=await re(r,s,a,(h,v,x)=>h.onReasoningMessageStartEvent?.({event:m,messages:v,state:x,agent:n,input:t}));if(d(p),p.stopPropagation!==!0){let{messageId:h,subagentRunId:v}=m,x=s.find(O=>O.id===h),S=x;if(!S){let O={id:h,role:"reasoning",content:"",...v!=null&&{subagentRunId:v}};s.push(O),S=O}let _=je(S,m);(!x||_)&&d({messages:s})}return u()}case g.REASONING_MESSAGE_CONTENT:{let{messageId:p,delta:h}=m,v=s.find(S=>S.id===p);if(!v)return console.warn(`REASONING_MESSAGE_CONTENT: No message found with ID '${p}'`),u();let x=await re(r,s,a,(S,_,O)=>S.onReasoningMessageContentEvent?.({event:m,messages:_,state:O,agent:n,input:t,reasoningMessageBuffer:typeof v.content=="string"?v.content:""}));return d(x),x.stopPropagation!==!0&&(v.content=`${typeof v.content=="string"?v.content:""}${h}`,je(v,m),d({messages:s})),u()}case g.REASONING_MESSAGE_END:{let{messageId:p}=m,h=s.find(x=>x.id===p);if(!h)return console.warn(`REASONING_MESSAGE_END: No message found with ID '${p}'`),u();let v=await re(r,s,a,(x,S,_)=>x.onReasoningMessageEndEvent?.({event:m,messages:S,state:_,agent:n,input:t,reasoningMessageBuffer:typeof h.content=="string"?h.content:""}));return d(v),v.stopPropagation!==!0&&je(h,m)&&d({messages:s}),await Promise.all(r.map(x=>{x.onNewMessage?.({message:h,messages:s,state:a,agent:n,input:t})})),u()}case g.REASONING_MESSAGE_CHUNK:throw Error("REASONING_MESSAGE_CHUNK must be transformed before being applied");case g.REASONING_END:return d(await re(r,s,a,(p,h,v)=>p.onReasoningEndEvent?.({event:m,messages:h,state:v,agent:n,input:t}))),u();case g.REASONING_ENCRYPTED_VALUE:{let{subtype:p,entityId:h,encryptedValue:v}=m,x=await re(r,s,a,(S,_,O)=>S.onReasoningEncryptedValueEvent?.({event:m,messages:_,state:O,agent:n,input:t}));if(d(x),x.stopPropagation!==!0){let S=!1;if(p==="tool-call"){for(let _ of s)if(_.role==="assistant"&&_.toolCalls){let O=_.toolCalls.find(G=>G.id===h);if(O){O.encryptedValue=v,S=!0;break}}}else{let _=s.find(O=>O.id===h);_?.role!=="activity"&&_&&(_.encryptedValue=v,S=!0)}S&&(l.messages=s)}return u()}case g.SUBAGENT_STARTED:return d(await re(r,s,a,(p,h,v)=>p.onSubagentStartedEvent?.({event:m,messages:h,state:v,agent:n,input:t}))),u();case g.SUBAGENT_FINISHED:return d(await re(r,s,a,(p,h,v)=>p.onSubagentFinishedEvent?.({event:m,messages:h,state:v,agent:n,input:t}))),u();case g.SUBAGENT_ERROR:return d(await re(r,s,a,(p,h,v)=>p.onSubagentErrorEvent?.({event:m,messages:h,state:v,agent:n,input:t}))),u()}return m.type,u()}),hl(),r.length>0?fl({}):m=>m)},Ol=t=>e=>{let n=Or(t),r=new Set,o=new Set,i=new Set,s={message:new Map,toolCall:new Map,activity:new Map,reasoning:new Map},a=!1,l=!1,d=!1,u=new Map,m=b=>{let A=u.get(b);return A||(A=new Map,u.set(b,A)),A},w=()=>{for(let b of u.values())if(b.size>0)return!0;return!1},p=new Map,h=new Set,v=!1,x=!1,S=!1,_=()=>{r.clear(),o.clear(),i.clear(),s.message.clear(),s.toolCall.clear(),s.activity.clear(),s.reasoning.clear(),u.clear(),p.clear(),h.clear(),v=!1,x=!1,a=!1,l=!1,S=!0},O=(b,A)=>{let E=b??[];if(Array.isArray(E))for(let I of E){if(!I||typeof I.id!="string")continue;if(I.subagentRunId===null)return new V(`Cannot send a message (id '${I.id}') with 'subagentRunId: null'. The field is optional \u2014 omit it entirely.`);let B=I.role==="reasoning"?s.reasoning:I.role==="activity"?s.activity:s.message;(A||!B.has(I.id))&&B.set(I.id,{subagentRunId:I.subagentRunId});for(let de of I.toolCalls??[])de&&typeof de.id=="string"&&(A||!s.toolCall.has(de.id))&&s.toolCall.set(de.id,{subagentRunId:I.subagentRunId??void 0})}},G=(b,A,E,I,B)=>{if(A!==void 0&&E&&E.subagentRunId!==A)return new V(`Cannot send '${b}': subagentRunId '${A}' does not match the ${I} '${B}' opener's subagent '${E.subagentRunId??"(the parent agent)"}'.`)};return e.pipe(ze(b=>{let A=b.type;if(n?.event("VERIFY","Event:",b,{type:b.type}),l&&A!==g.RUN_STARTED)return z(()=>new V(`Cannot send event type '${A}': The run has already errored with 'RUN_ERROR'. No further events can be sent.`));if(a&&A!==g.RUN_ERROR&&A!==g.RUN_STARTED)return z(()=>new V(`Cannot send event type '${A}': The run has already finished with 'RUN_FINISHED'. Start a new run with 'RUN_STARTED'.`));if(d){if(A===g.RUN_STARTED){if(S&&!a&&!l)return z(()=>new V("Cannot send 'RUN_STARTED' while a run is still active. The previous run must be finished with 'RUN_FINISHED' before starting a new run."));(a||l)&&_()}}else if(d=!0,A!==g.RUN_STARTED&&A!==g.RUN_ERROR)return z(()=>new V("First event must be 'RUN_STARTED'"));if(b.subagentRunId===null)return z(()=>new V(`Cannot send '${A}' with 'subagentRunId: null'. The field is optional \u2014 omit it entirely.`));if(A===g.SUBAGENT_STARTED||A===g.SUBAGENT_FINISHED||A===g.SUBAGENT_ERROR){let E=A===g.SUBAGENT_STARTED?["description","parentSubagentRunId","parentToolCallId","parentMessageId"]:A===g.SUBAGENT_FINISHED?["outcome"]:["code"];for(let B of E)if(b[B]===null)return z(()=>new V(`Cannot send '${A}' with '${B}: null'. The field is optional \u2014 omit it entirely.`));let I=b.outcome;if(I!=null&&I.type!=="success"&&I.type!=="suspended")return z(()=>new V(`Cannot send '${A}' with outcome type '${String(I.type)}'. The outcome is either { type: "success" } or { type: "suspended" }.`));if(I&&I.interruptIds===null)return z(()=>new V(`Cannot send '${A}' with 'outcome.interruptIds: null'. The field is optional \u2014 omit it entirely.`));if(I&&Array.isArray(I.interruptIds)&&I.interruptIds.some(B=>typeof B!="string"))return z(()=>new V(`Cannot send '${A}' with a non-string entry in 'outcome.interruptIds'. Interrupt ids are strings.`))}if(A===g.RUN_FINISHED){let E=b.outcome;if(E?.type==="interrupt"&&Array.isArray(E.interrupts)){for(let I of E.interrupts)if(I&&I.subagentRunId===null)return z(()=>new V(`Cannot send 'RUN_FINISHED' with an interrupt (id '${I.id}') carrying 'subagentRunId: null'. The field is optional \u2014 omit it entirely.`))}}switch(A){case g.TEXT_MESSAGE_START:{let E=b.messageId;if(r.has(E))return z(()=>new V(`Cannot send 'TEXT_MESSAGE_START' event: A text message with ID '${E}' is already in progress. Complete it with 'TEXT_MESSAGE_END' first.`));let I=s.message.get(E);if(I){let B=G(A,b.subagentRunId,I,"message",E);if(B)return z(()=>B)}return r.add(E),I||s.message.set(E,{subagentRunId:b.subagentRunId}),ne(b)}case g.TEXT_MESSAGE_CONTENT:{let E=b.messageId;if(!r.has(E))return z(()=>new V(`Cannot send 'TEXT_MESSAGE_CONTENT' event: No active text message found with ID '${E}'. Start a text message with 'TEXT_MESSAGE_START' first.`));let I=G(A,b.subagentRunId,s.message.get(E),"message",E);return I?z(()=>I):ne(b)}case g.TEXT_MESSAGE_END:{let E=b.messageId;if(!r.has(E))return z(()=>new V(`Cannot send 'TEXT_MESSAGE_END' event: No active text message found with ID '${E}'. A 'TEXT_MESSAGE_START' event must be sent first.`));let I=G(A,b.subagentRunId,s.message.get(E),"message",E);return I?z(()=>I):(r.delete(E),ne(b))}case g.TOOL_CALL_START:{let E=b.toolCallId;if(o.has(E))return z(()=>new V(`Cannot send 'TOOL_CALL_START' event: A tool call with ID '${E}' is already in progress. Complete it with 'TOOL_CALL_END' first.`));let I=b.parentMessageId,B=b.subagentRunId,de;if(I!==void 0){let Ye=s.message.get(I);if(Ye){if(B!==void 0&&B!==Ye.subagentRunId)return z(()=>new V(`Cannot send 'TOOL_CALL_START': subagentRunId '${B}' does not match its parent message '${I}' owner '${Ye.subagentRunId??"(the parent agent)"}'. A tool call belongs to the message that carries it.`));de=Ye}}let Te=s.toolCall.get(E);if(Te){let Ye=G(A,B,Te,"tool call",E);if(Ye)return z(()=>Ye);if(B===void 0&&de&&de.subagentRunId!==Te.subagentRunId)return z(()=>new V(`Cannot send 'TOOL_CALL_START': tool call '${E}' is owned by '${Te.subagentRunId??"(the parent agent)"}' but its parent message '${I}' is owned by '${de.subagentRunId??"(the parent agent)"}'. A tool call belongs to the message that carries it.`))}return o.add(E),Te||s.toolCall.set(E,B===void 0?de??{subagentRunId:void 0}:{subagentRunId:B}),ne(b)}case g.TOOL_CALL_ARGS:{let E=b.toolCallId;if(!o.has(E))return z(()=>new V(`Cannot send 'TOOL_CALL_ARGS' event: No active tool call found with ID '${E}'. Start a tool call with 'TOOL_CALL_START' first.`));let I=G(A,b.subagentRunId,s.toolCall.get(E),"tool call",E);return I?z(()=>I):ne(b)}case g.TOOL_CALL_END:{let E=b.toolCallId;if(!o.has(E))return z(()=>new V(`Cannot send 'TOOL_CALL_END' event: No active tool call found with ID '${E}'. A 'TOOL_CALL_START' event must be sent first.`));let I=G(A,b.subagentRunId,s.toolCall.get(E),"tool call",E);return I?z(()=>I):(o.delete(E),ne(b))}case g.STEP_STARTED:{let E=b.stepName,I=b.subagentRunId;return m(I).has(E)?z(()=>new V(`Step "${E}" is already active for 'STEP_STARTED'${I===void 0?"":` in subagent '${I}'`}`)):(m(I).set(E,!0),ne(b))}case g.STEP_FINISHED:{let E=b.stepName,I=b.subagentRunId;if(!m(I).has(E)){let B,de=!1;for(let[Te,Ye]of u)if(Te!==I&&Ye.has(E)){B=Te,de=!0;break}return z(de?()=>new V(`Cannot send 'STEP_FINISHED' for step "${E}" attributed to ${I===void 0?"the parent agent":`subagent '${I}'`}: that step is open under ${B===void 0?"the parent agent":`subagent '${B}'`}. A step must be finished by whoever started it.`):()=>new V(`Cannot send 'STEP_FINISHED' for step "${E}" that was not started`))}return m(I).delete(E),ne(b)}case g.ACTIVITY_SNAPSHOT:{let E=b.messageId;return(!s.activity.has(E)||b.replace!==!1)&&s.activity.set(E,{subagentRunId:b.subagentRunId}),ne(b)}case g.TOOL_CALL_RESULT:{let E=b.messageId;return typeof E=="string"&&s.message.set(E,{subagentRunId:b.subagentRunId}),ne(b)}case g.REASONING_START:case g.REASONING_MESSAGE_START:{let E=b.messageId,I=s.reasoning.get(E);if(I){let B=G(A,b.subagentRunId,I,"reasoning message",E);if(B)return z(()=>B)}return i.add(E),I||s.reasoning.set(E,{subagentRunId:b.subagentRunId}),ne(b)}case g.REASONING_MESSAGE_CONTENT:case g.REASONING_MESSAGE_END:case g.REASONING_END:{let E=b.messageId,I=G(A,b.subagentRunId,s.reasoning.get(E),"reasoning message",E);return I?z(()=>I):(A===g.REASONING_END&&i.delete(E),ne(b))}case g.REASONING_ENCRYPTED_VALUE:{let E=b.entityId,I=b.subtype,B=I==="tool-call"?s.toolCall.get(E):I==="message"?s.message.get(E)??s.reasoning.get(E):s.reasoning.get(E),de=I==="tool-call"?"tool call":I==="message"?"message":"reasoning message",Te=G(A,b.subagentRunId,B,de,E);return Te?z(()=>Te):ne(b)}case g.ACTIVITY_DELTA:{let E=b.messageId,I=G(A,b.subagentRunId,s.activity.get(E),"activity",E);return I?z(()=>I):ne(b)}case g.SUBAGENT_STARTED:{if(typeof b.subagentRunId!="string")return z(()=>new V("Cannot send 'SUBAGENT_STARTED' without a 'subagentRunId'."));if(typeof b.name!="string")return z(()=>new V("Cannot send 'SUBAGENT_STARTED' without a 'name'."));let E=b.subagentRunId,I=b.parentSubagentRunId;return p.has(E)?z(()=>new V(`Cannot send 'SUBAGENT_STARTED': subagent '${E}' is already active. Finish it with 'SUBAGENT_FINISHED' first.`)):h.has(E)?z(()=>new V(`Cannot send 'SUBAGENT_STARTED': subagent '${E}' has already finished in this run. Subagent IDs are per-invocation and cannot be reused.`)):I!==void 0&&!p.has(I)&&!h.has(I)?z(()=>new V(`Cannot send 'SUBAGENT_STARTED': parentSubagentRunId '${I}' has not been started in this run.`)):(p.set(E,!0),ne(b))}case g.SUBAGENT_FINISHED:case g.SUBAGENT_ERROR:{if(typeof b.subagentRunId!="string")return z(()=>new V(`Cannot send '${A}' without a 'subagentRunId'.`));if(A===g.SUBAGENT_ERROR&&typeof b.message!="string")return z(()=>new V("Cannot send 'SUBAGENT_ERROR' without a 'message'."));let E=b.subagentRunId;return p.has(E)?(p.delete(E),h.add(E),ne(b)):z(()=>new V(`Cannot send '${A}': no active subagent found with ID '${E}'. A 'SUBAGENT_STARTED' event must be sent first.`))}case g.MESSAGES_SNAPSHOT:{let E=O(b.messages,!0);if(E)return z(()=>E)}return ne(b);case g.RUN_STARTED:S=!0;{let E=O((b.input??{}).messages,!1);if(E)return z(()=>E)}return ne(b);case g.RUN_FINISHED:if(w()){let E=[];for(let[B,de]of u)for(let Te of de.keys())E.push(B===void 0?Te:`${Te} (subagent '${B}')`);let I=E.join(", ");return z(()=>new V(`Cannot send 'RUN_FINISHED' while steps are still active: ${I}`))}if(r.size>0){let E=Array.from(r.keys()).join(", ");return z(()=>new V(`Cannot send 'RUN_FINISHED' while text messages are still active: ${E}`))}if(o.size>0){let E=Array.from(o.keys()).join(", ");return z(()=>new V(`Cannot send 'RUN_FINISHED' while tool calls are still active: ${E}`))}if(p.size>0){let E=Array.from(p.keys()).join(", ");return z(()=>new V(`Cannot send 'RUN_FINISHED' while subagents are still active: ${E}`))}return a=!0,ne(b);case g.RUN_ERROR:return l=!0,ne(b);case g.CUSTOM:return ne(b);case g.THINKING_TEXT_MESSAGE_START:return v?x?z(()=>new V("Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking message is already in progress. Complete it with 'THINKING_TEXT_MESSAGE_END' first.")):(x=!0,ne(b)):z(()=>new V("Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking step is not in progress. Create one with 'THINKING_START' first."));case g.THINKING_TEXT_MESSAGE_CONTENT:return x?ne(b):z(()=>new V("Cannot send 'THINKING_TEXT_MESSAGE_CONTENT' event: No active thinking message found. Start a message with 'THINKING_TEXT_MESSAGE_START' first."));case g.THINKING_TEXT_MESSAGE_END:return x?(x=!1,ne(b)):z(()=>new V("Cannot send 'THINKING_TEXT_MESSAGE_END' event: No active thinking message found. A 'THINKING_TEXT_MESSAGE_START' event must be sent first."));case g.THINKING_START:return v?z(()=>new V("Cannot send 'THINKING_START' event: A thinking step is already in progress. End it with 'THINKING_END' first.")):(v=!0,ne(b));case g.THINKING_END:return v?(v=!1,ne(b)):z(()=>new V("Cannot send 'THINKING_END' event: No active thinking step found. A 'THINKING_START' event must be sent first."));default:return ne(b)}}))},vn=(function(t){return t.HEADERS="headers",t.DATA="data",t})({}),Xb=t=>gi(()=>fn(t())).pipe(ml(e=>{if(!e.ok){let o=e.headers.get("content-type")||"";return fn(e.text()).pipe(ze(i=>{let s=i;if(o.includes("application/json"))try{s=JSON.parse(i)}catch{}let a=Error(`HTTP ${e.status}: ${typeof s=="string"?s:JSON.stringify(s)}`);return a.status=e.status,a.payload=s,z(()=>a)}))}let n={type:vn.HEADERS,status:e.status,headers:e.headers},r=e.body?.getReader();return r?new ce(o=>(o.next(n),(async()=>{try{for(;;){let{done:i,value:s}=await r.read();if(i)break;let a={type:vn.DATA,data:s};o.next(a)}o.complete()}catch(i){o.error(i)}})(),()=>{r.cancel().catch(i=>{if(i?.name!=="AbortError")throw i})})):z(()=>Error("Failed to getReader() from response"))})),Yb=(t,e)=>{let n=Or(e),r=new vt,o=new TextDecoder("utf-8",{fatal:!1}),i="";t.subscribe({next:a=>{if(a.type!==vn.HEADERS&&a.type===vn.DATA&&a.data){let l=o.decode(a.data,{stream:!0});i+=l;let d=i.split(/\n\n/);i=d.pop()||"";for(let u of d)s(u)}},error:a=>r.error(a),complete:()=>{i&&(i+=o.decode(),s(i)),r.complete()}});function s(a){let l=a.split(`
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
`)},cy=(t,e,n)=>r=>{let o={},i=!0,s=!0,a="",l=null,d=null,u=[],m={},w=p=>{typeof p=="object"&&p&&("messages"in p&&delete p.messages,o=p)};return r.pipe(ze(p=>{switch(p.type){case g.TEXT_MESSAGE_START:{let h=p;return[{type:ae.enum.TextMessageStart,messageId:h.messageId,role:h.role}]}case g.TEXT_MESSAGE_CONTENT:{let h=p;return[{type:ae.enum.TextMessageContent,messageId:h.messageId,content:h.delta}]}case g.TEXT_MESSAGE_END:{let h=p;return[{type:ae.enum.TextMessageEnd,messageId:h.messageId}]}case g.TOOL_CALL_START:{let h=p;return u.push({id:h.toolCallId,type:"function",function:{name:h.toolCallName,arguments:""}}),s=!0,m[h.toolCallId]=h.toolCallName,[{type:ae.enum.ActionExecutionStart,actionExecutionId:h.toolCallId,actionName:h.toolCallName,parentMessageId:h.parentMessageId}]}case g.TOOL_CALL_ARGS:{let h=p,v=u.find(S=>S.id===h.toolCallId);if(!v)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${h.toolCallId}'`),[];v.function.arguments+=h.delta;let x=!1;if(d){let S=d.find(_=>_.tool==v.function.name);if(S)try{let _=JSON.parse(wi(v.function.arguments));S.tool_argument&&S.tool_argument in _?(w({...o,[S.state_key]:_[S.tool_argument]}),x=!0):S.tool_argument||(w({...o,[S.state_key]:_}),x=!0)}catch{}}return[{type:ae.enum.ActionExecutionArgs,actionExecutionId:h.toolCallId,args:h.delta},...x?[{type:ae.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:s}]:[]]}case g.TOOL_CALL_END:{let h=p;return[{type:ae.enum.ActionExecutionEnd,actionExecutionId:h.toolCallId}]}case g.TOOL_CALL_RESULT:{let h=p;return[{type:ae.enum.ActionExecutionResult,actionExecutionId:h.toolCallId,result:h.content,actionName:m[h.toolCallId]||"unknown"}]}case g.RAW:return[];case g.CUSTOM:{let h=p;switch(h.name){case"Exit":i=!1;break;case"PredictState":d=h.value;break}return[{type:ae.enum.MetaEvent,name:h.name,value:h.value}]}case g.STATE_SNAPSHOT:return w(p.snapshot),[{type:ae.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:s}];case g.STATE_DELTA:{let h=p,v=Wo.applyPatch(o,h.delta,!0,!1);return v?(w(v.newDocument),[{type:ae.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:s}]):[]}case g.MESSAGES_SNAPSHOT:return l=p.messages,[{type:ae.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify({...o,...l?{messages:l}:{}}),active:!0}];case g.RUN_STARTED:return[];case g.RUN_FINISHED:return l&&(o.messages=l),Object.keys(o).length===0?[]:[{type:ae.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify({...o,...l?{messages:uy(l)}:{}}),active:!1}];case g.RUN_ERROR:{let h=p;return[{type:ae.enum.RunError,message:h.message,code:h.code}]}case g.STEP_STARTED:return a=p.stepName,u=[],d=null,[{type:ae.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:!0}];case g.STEP_FINISHED:return u=[],d=null,[{type:ae.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:!1}];default:return[]}}))};function uy(t){let e=[];for(let n of t)if(n.role==="assistant"||n.role==="user"||n.role==="system"){let r=dy(n.content);if(r){let o={id:n.id,role:n.role,content:r};e.push(o)}if(n.role==="assistant"&&n.toolCalls&&n.toolCalls.length>0)for(let o of n.toolCalls){let i={id:o.id,name:o.function.name,arguments:JSON.parse(o.function.arguments),parentMessageId:n.id};e.push(i)}}else if(n.role==="tool"){let r="unknown";for(let i of t)if(i.role==="assistant"&&i.toolCalls?.length){for(let s of i.toolCalls)if(s.id===n.toolCallId){r=s.function.name;break}}let o={id:n.id,result:n.content,actionExecutionId:n.toolCallId,actionName:r};e.push(o)}return e}var hy=t=>t.kind==="tool"?t.fields.toolCallId:t.fields.messageId,py=t=>t==="tool"?"toolCallId":"messageId",nr=(t,e)=>e.metadata===void 0?t:{...t,metadata:e.metadata},os=t=>e=>{let n=Or(t),r=new Map,o=l=>{let d=r.get(l);if(!d)return[];switch(r.delete(l),d.kind){case"text":{let u={type:g.TEXT_MESSAGE_END,messageId:d.fields.messageId,...d.fields.subagentRunId!=null&&{subagentRunId:d.fields.subagentRunId}};return n?.event("TRANSFORM","TEXT_MESSAGE_END",u,{messageId:u.messageId}),[u]}case"tool":{let u={type:g.TOOL_CALL_END,toolCallId:d.fields.toolCallId,...d.fields.subagentRunId!=null&&{subagentRunId:d.fields.subagentRunId}};return n?.event("TRANSFORM","TOOL_CALL_END",u,{toolCallId:u.toolCallId}),[u]}case"reasoning":{let u={type:g.REASONING_MESSAGE_END,messageId:d.fields.messageId,...d.fields.subagentRunId!=null&&{subagentRunId:d.fields.subagentRunId}};return n?.event("TRANSFORM","REASONING_MESSAGE_END",u,{messageId:u.messageId}),[u]}}},i=()=>[...r.keys()].flatMap(l=>o(l)),s=(l,d)=>{for(let[u,m]of r)if(m.kind===l&&hy(m)===d)return{owner:u}},a=(l,d,u,m,w)=>{if(d!==void 0){let h=s(l,d);if(h){if(u!==void 0&&u!==h.owner)throw Error(`Cannot continue ${w} '${d}': chunk subagentRunId '${u}' does not match the open stream's subagent '${h.owner??"(the parent agent)"}'.`);return h.owner}return u}if(u!==void 0)return u;if(r.get(void 0)?.kind===l)return;let p=[...r.entries()].filter(([,h])=>h.kind===l);if(p.length===1)return p[0][0];if(p.length>1)throw Error(`Ambiguous ${m}: it carries neither a ${py(l)} nor a subagentRunId, but ${p.length} lanes have an open ${w}. Attribute the chunk to the subagent it belongs to.`)};return e.pipe(ze(l=>{switch(l.type){case g.TEXT_MESSAGE_START:case g.TEXT_MESSAGE_CONTENT:case g.TEXT_MESSAGE_END:case g.TOOL_CALL_START:case g.TOOL_CALL_ARGS:case g.TOOL_CALL_END:case g.TOOL_CALL_RESULT:case g.STATE_SNAPSHOT:case g.STATE_DELTA:case g.CUSTOM:case g.STEP_STARTED:case g.STEP_FINISHED:case g.THINKING_START:case g.THINKING_END:case g.THINKING_TEXT_MESSAGE_START:case g.THINKING_TEXT_MESSAGE_CONTENT:case g.THINKING_TEXT_MESSAGE_END:case g.REASONING_START:case g.REASONING_MESSAGE_START:case g.REASONING_MESSAGE_CONTENT:case g.REASONING_MESSAGE_END:case g.REASONING_END:return[...o(l.subagentRunId??void 0),l];case g.RUN_STARTED:case g.RUN_FINISHED:case g.RUN_ERROR:case g.MESSAGES_SNAPSHOT:return[...i(),l];case g.RAW:case g.ACTIVITY_SNAPSHOT:case g.ACTIVITY_DELTA:case g.REASONING_ENCRYPTED_VALUE:case g.SUBAGENT_STARTED:return[l];case g.SUBAGENT_FINISHED:case g.SUBAGENT_ERROR:{let d=l.subagentRunId;return d==null?[l]:[...o(d),l]}case g.TEXT_MESSAGE_CHUNK:{let d=l,u=a("text",d.messageId,d.subagentRunId??void 0,"TEXT_MESSAGE_CHUNK","text message"),m=r.get(u),w=[],p;if(m?.kind==="text"&&(d.messageId===void 0||d.messageId===m.fields.messageId))p=m.fields;else{if(w.push(...o(u)),d.messageId===void 0)throw Error("First TEXT_MESSAGE_CHUNK must have a messageId");p={messageId:d.messageId,name:d.name,subagentRunId:d.subagentRunId},r.set(u,{kind:"text",fields:p});let h=nr({type:g.TEXT_MESSAGE_START,messageId:d.messageId,role:d.role||"assistant",...d.name!==void 0&&{name:d.name},...d.subagentRunId!=null&&{subagentRunId:d.subagentRunId}},d);w.push(h),n?.event("TRANSFORM","TEXT_MESSAGE_START",h,{messageId:d.messageId})}if(d.delta!==void 0){let h=d.subagentRunId??p.subagentRunId,v=nr({type:g.TEXT_MESSAGE_CONTENT,messageId:p.messageId,delta:d.delta,...h!=null&&{subagentRunId:h}},d);w.push(v),n?.event("TRANSFORM","TEXT_MESSAGE_CONTENT",v,{messageId:p.messageId})}if(w.length===0&&d.metadata!==void 0){let h=d.subagentRunId??p.subagentRunId;w.push({type:g.TEXT_MESSAGE_CONTENT,messageId:p.messageId,delta:"",metadata:d.metadata,...h!=null&&{subagentRunId:h}})}return w}case g.TOOL_CALL_CHUNK:{let d=l,u=a("tool",d.toolCallId,d.subagentRunId??void 0,"TOOL_CALL_CHUNK","tool call"),m=r.get(u),w=[],p;if(m?.kind==="tool"&&(d.toolCallId===void 0||d.toolCallId===m.fields.toolCallId))p=m.fields;else{if(w.push(...o(u)),d.toolCallId===void 0)throw Error("First TOOL_CALL_CHUNK must have a toolCallId");if(d.toolCallName===void 0)throw Error("First TOOL_CALL_CHUNK must have a toolCallName");p={toolCallId:d.toolCallId,toolCallName:d.toolCallName,parentMessageId:d.parentMessageId,subagentRunId:d.subagentRunId},r.set(u,{kind:"tool",fields:p});let h=nr({type:g.TOOL_CALL_START,toolCallId:d.toolCallId,toolCallName:d.toolCallName,parentMessageId:d.parentMessageId,...d.subagentRunId!=null&&{subagentRunId:d.subagentRunId}},d);w.push(h),n?.event("TRANSFORM","TOOL_CALL_START",h,{toolCallId:d.toolCallId,toolCallName:d.toolCallName})}if(d.delta!==void 0){let h=d.subagentRunId??p.subagentRunId,v=nr({type:g.TOOL_CALL_ARGS,toolCallId:p.toolCallId,delta:d.delta,...h!=null&&{subagentRunId:h}},d);w.push(v),n?.event("TRANSFORM","TOOL_CALL_ARGS",v,{toolCallId:p.toolCallId})}if(w.length===0&&d.metadata!==void 0){let h=d.subagentRunId??p.subagentRunId;w.push({type:g.TOOL_CALL_ARGS,toolCallId:p.toolCallId,delta:"",metadata:d.metadata,...h!=null&&{subagentRunId:h}})}return w}case g.REASONING_MESSAGE_CHUNK:{let d=l,u=a("reasoning",d.messageId,d.subagentRunId??void 0,"REASONING_MESSAGE_CHUNK","reasoning message"),m=r.get(u),w=[],p;if(m?.kind==="reasoning"&&(d.messageId===void 0||d.messageId===m.fields.messageId))p=m.fields;else{if(w.push(...o(u)),d.messageId===void 0)throw Error("First REASONING_MESSAGE_CHUNK must have a messageId");p={messageId:d.messageId,subagentRunId:d.subagentRunId},r.set(u,{kind:"reasoning",fields:p});let h=nr({type:g.REASONING_MESSAGE_START,messageId:d.messageId,role:"reasoning",...d.subagentRunId!=null&&{subagentRunId:d.subagentRunId}},d);w.push(h),n?.event("TRANSFORM","REASONING_MESSAGE_START",h,{messageId:d.messageId})}if(d.delta!==void 0){let h=d.subagentRunId??p.subagentRunId,v=nr({type:g.REASONING_MESSAGE_CONTENT,messageId:p.messageId,delta:d.delta,...h!=null&&{subagentRunId:h}},d);w.push(v),n?.event("TRANSFORM","REASONING_MESSAGE_CONTENT",v,{messageId:p.messageId})}if(w.length===0&&d.metadata!==void 0){let h=d.subagentRunId??p.subagentRunId;w.push({type:g.REASONING_MESSAGE_CONTENT,messageId:p.messageId,delta:"",metadata:d.metadata,...h!=null&&{subagentRunId:h}})}return w}}return l.type,[]}),mn(()=>{i()}))};function fy(t,e=new Date){return t.expiresAt===void 0?!1:new Date(t.expiresAt)<=e}function Oh(t,e){let n=new Set(t.map(s=>s.id)),r=new Set(Object.keys(e)),o=[...n].filter(s=>!r.has(s));if(o.length>0)throw Error(`buildResumeArray: missing responses for open interrupts: ${o.join(", ")}`);let i=[...r].filter(s=>!n.has(s));if(i.length>0)throw Error(`buildResumeArray: responses reference unknown interrupt ids: ${i.join(", ")}`);return t.map(s=>{let a=e[s.id],l={interruptId:s.id,status:a.status};return a.status==="resolved"&&a.payload!==void 0&&(l.payload=a.payload),a.metadata!==void 0&&(l.metadata=a.metadata),l})}var Mr=class{runNext(t,e){return e.run(t).pipe(os(!1))}runNextWithState(t,e){let n=J(t.messages||[]),r=J(t.state||{}),o=new ti;return Nh(t,o,e,[]).subscribe(i=>{i.messages!==void 0&&(n=i.messages),i.state!==void 0&&(r=i.state)}),this.runNext(t,e).pipe(vi(async i=>(o.next(i),await new Promise(s=>setTimeout(s,0)),{event:i,messages:J(n),state:J(r)})))}},my=class extends Mr{constructor(t){super(),this.fn=t}run(t,e){return this.fn(t,e)}};function gy(t){let e=t.content;if(Array.isArray(e)){let n=e.filter(r=>typeof r=="object"&&!!r&&"type"in r&&r.type==="text"&&typeof r.text=="string").map(r=>r.text).join("");return{...t,content:n}}return typeof e=="string"?t:{...t,content:""}}var vy=class extends Mr{run(t,e){let{parentRunId:n,...r}=t,o={...r,messages:r.messages.map(gy)};return this.runNext(o,e)}},Eh="THINKING_START",Th="THINKING_END",_h="THINKING_TEXT_MESSAGE_START",Sh="THINKING_TEXT_MESSAGE_CONTENT",Ah="THINKING_TEXT_MESSAGE_END",by=class extends Mr{constructor(...t){super(...t),this.currentReasoningId=null,this.currentMessageId=null}warnAboutTransformation(t,e){typeof process<"u"&&process.env!==void 0&&process.env.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`AG-UI is converting ${t} to ${e}. To remove this warning, upgrade your AG-UI integration package (e.g. @ag-ui/langgraph). To surpress it, set SUPPRESS_TRANSFORMATION_WARNINGS=true in your .env file.`)}run(t,e){return this.currentReasoningId=null,this.currentMessageId=null,this.runNext(t,e).pipe(Pt(n=>this.transformEvent(n)))}transformEvent(t){switch(t.type){case Eh:{this.currentReasoningId=be();let{title:e,...n}=t;return this.warnAboutTransformation(Eh,g.REASONING_START),{...n,type:g.REASONING_START,messageId:this.currentReasoningId}}case _h:return this.currentMessageId=be(),this.warnAboutTransformation(_h,g.REASONING_MESSAGE_START),{...t,type:g.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:"assistant"};case Sh:{let{delta:e,...n}=t;return this.warnAboutTransformation(Sh,g.REASONING_MESSAGE_CONTENT),{...n,type:g.REASONING_MESSAGE_CONTENT,messageId:this.currentMessageId??be(),delta:e}}case Ah:{let e=this.currentMessageId??be();return this.warnAboutTransformation(Ah,g.REASONING_MESSAGE_END),{...t,type:g.REASONING_MESSAGE_END,messageId:e}}case Th:{let e=this.currentReasoningId??be();return this.warnAboutTransformation(Th,g.REASONING_END),{...t,type:g.REASONING_END,messageId:e}}default:return t}}};function yy(t){return t.startsWith("image/")?"image":t.startsWith("audio/")?"audio":t.startsWith("video/")?"video":"document"}function wy(t){return typeof t=="object"&&!!t&&"type"in t&&t.type==="binary"&&"mimeType"in t&&typeof t.mimeType=="string"}function xy(t){let e=yy(t.mimeType);return t.data?{type:e,source:{type:"data",value:t.data,mimeType:t.mimeType},...t.filename?{metadata:{filename:t.filename}}:{}}:t.url?{type:e,source:{type:"url",value:t.url,mimeType:t.mimeType},...t.filename?{metadata:{filename:t.filename}}:{}}:t}function Ey(t){let e=t.content;if(!Array.isArray(e))return t;let n=e.map(r=>wy(r)?xy(r):r);return{...t,content:n}}var Ty=class extends Mr{run(t,e){let n={...t,messages:t.messages.map(Ey)};return this.runNext(n,e)}},kh="SUBAGENT_STARTED",Rh="SUBAGENT_FINISHED",Ih="SUBAGENT_ERROR";function is(t){if(t&&typeof t=="object"&&"subagentRunId"in t){let{subagentRunId:e,...n}=t;return n}return t}function Ch(t){return t.map(e=>is(e))}var _y=class extends Mr{warnDroppedLifecycleEvent(t){typeof process<"u"&&process.env!==void 0&&process.env.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`AG-UI is dropping ${t} because the target agent predates subagent support. To remove this warning, upgrade your AG-UI integration package. To suppress it, set SUPPRESS_TRANSFORMATION_WARNINGS=true in your .env file.`)}run(t,e){let n={...t,messages:(t.messages??[]).map(r=>is(r))};return this.runNext(n,e).pipe(yi(r=>{let o=r.type;(o===kh||o===Rh||o===Ih)&&this.warnDroppedLifecycleEvent(o)}),pl(r=>{let o=r.type;return o!==kh&&o!==Rh&&o!==Ih}),Pt(r=>{let o=is(r);if(o.type===g.MESSAGES_SNAPSHOT){let i=o;if(Array.isArray(i.messages))return{...i,messages:Ch(i.messages)}}if(o.type===g.RUN_FINISHED){let i=o;if(i.outcome&&Array.isArray(i.outcome.interrupts))return{...i,outcome:{...i.outcome,interrupts:i.outcome.interrupts.map(s=>is(s))}}}if(o.type===g.RUN_STARTED){let i=o;if(i.input&&Array.isArray(i.input.messages))return{...i,input:{...i.input,messages:Ch(i.input.messages)}}}return o}))}},Sy="0.0.59",Ay=class{get maxVersion(){return Sy}get debug(){return this._debug}set debug(t){this._debug=rs(t),this._debugLogger=Nl(this._debug)}get debugLogger(){return this._debugLogger}set debugLogger(t){typeof t=="boolean"?this._debugLogger=t?Nl(rs(!0)):void 0:this._debugLogger=t}constructor({agentId:t,description:e,threadId:n,initialMessages:r,initialState:o,debug:i}={}){this.subscribers=[],this.isRunning=!1,this.pendingInterrupts=[],this.middlewares=[],this.agentId=t,this.description=e??"",this.threadId=n??Ct(),this.messages=J(r??[]),this.state=J(o??{}),this._debug=rs(i),this._debugLogger=Nl(this._debug),tr(this.maxVersion,"0.0.39")<=0&&this.middlewares.unshift(new vy),tr(this.maxVersion,"0.0.45")<=0&&this.middlewares.unshift(new by),tr(this.maxVersion,"0.0.47")<=0&&this.middlewares.unshift(new Ty),tr(this.maxVersion,"0.0.57")<=0&&this.middlewares.unshift(new _y)}subscribe(t){return this.subscribers.push(t),{unsubscribe:()=>{this.subscribers=this.subscribers.filter(e=>e!==t)}}}use(...t){let e=t.map(n=>typeof n=="function"?new my(n):n);return this.middlewares.push(...e),this}async runAgent(t,e){try{this.isRunning=!0,this.agentId=this.agentId??Ct();let n=this.prepareRunAgentInput(t);this.debugLogger?.lifecycle("LIFECYCLE","Run started:",{agentId:this.agentId,threadId:this.threadId});let r,o=new Set(this.messages.map(l=>l.id)),i=[{onRunFinishedEvent:l=>{l.outcome==="success"&&(r=l.result)}},...this.subscribers,e??{}];await this.onInitialize(n,i),this.activeRunDetach$=new vt;let s;this.activeRunCompletionPromise=new Promise(l=>{s=l}),await mi(ei(()=>this.middlewares.length===0?this.run(n):this.middlewares.reduceRight((l,d)=>({run:u=>d.run(u,l),get messages(){return l.messages},get state(){return l.state}}),this).run(n),os(this.debugLogger),Ol(this.debugLogger),l=>l.pipe(bi(this.activeRunDetach$)),l=>this.apply(n,l,i),l=>this.processApplyEvents(n,l,i),Ir(l=>(this.debugLogger?.lifecycle("LIFECYCLE","Run errored:",{agentId:this.agentId,error:l instanceof Error?l.message:String(l)}),this.isRunning=!1,this.onError(n,l,i))),mn(()=>{this.debugLogger?.lifecycle("LIFECYCLE","Run finished:",{agentId:this.agentId,threadId:this.threadId}),this.isRunning=!1,this.onFinalize(n,i),s?.(),s=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(ne(null)));let a=J(this.messages).filter(l=>!o.has(l.id));return{result:r,newMessages:a}}finally{this.isRunning=!1}}connect(t){throw new Ja}async connectAgent(t,e){try{this.isRunning=!0,this.agentId=this.agentId??Ct();let n=this.prepareRunAgentInput(t),r,o=new Set(this.messages.map(l=>l.id)),i=[{onRunFinishedEvent:l=>{l.outcome==="success"&&(r=l.result)}},...this.subscribers,e??{}];await this.onInitialize(n,i),this.activeRunDetach$=new vt;let s;this.activeRunCompletionPromise=new Promise(l=>{s=l}),await mi(ei(()=>gi(()=>this.connect(n)),os(this.debugLogger),Ol(this.debugLogger),l=>l.pipe(bi(this.activeRunDetach$)),l=>this.apply(n,l,i),l=>this.processApplyEvents(n,l,i),Ir(l=>(this.isRunning=!1,l instanceof Ja?ni:this.onError(n,l,i))),mn(()=>{this.isRunning=!1,this.onFinalize(n,i),s?.(),s=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(ne(null)),{defaultValue:void 0});let a=J(this.messages).filter(l=>!o.has(l.id));return{result:r,newMessages:a}}finally{this.isRunning=!1}}abortRun(){}async detachActiveRun(){if(!this.activeRunDetach$)return;let t=this.activeRunCompletionPromise??Promise.resolve();this.activeRunDetach$.next(),this.activeRunDetach$?.complete(),await t}apply(t,e,n){return Nh(t,e,this,n,this.debugLogger)}processApplyEvents(t,e,n){return e.pipe(yi(r=>{r.messages&&(this.messages=r.messages,n.forEach(o=>{o.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:t})})),r.state&&(this.state=r.state,n.forEach(o=>{o.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:t})}))}))}prepareRunAgentInput(t){let e=J(this.messages);for(let r of e)r.subagentRunId===null&&delete r.subagentRunId;let n=e.filter(r=>r.role!=="activity");return{threadId:this.threadId,runId:t?.runId||Ct(),tools:J(t?.tools??[]),context:J(t?.context??[]),forwardedProps:J(t?.forwardedProps??{}),state:J(this.state),messages:n,...t?.resume===void 0?{}:{resume:J(t.resume)}}}async onInitialize(t,e){if(this.pendingInterrupts.length>0){let r=new Set((t.resume??[]).map(i=>i.interruptId)),o=this.pendingInterrupts.map(i=>i.id).filter(i=>!r.has(i));if(o.length>0)throw new V(`Thread has ${o.length} pending interrupt(s) not addressed by resume: ${o.join(", ")}`);for(let i of this.pendingInterrupts)if(fy(i))throw new V(`Interrupt ${i.id} expired at ${i.expiresAt}`)}let n=await re(e,this.messages,this.state,(r,o,i)=>r.onRunInitialized?.({messages:o,state:i,agent:this,input:t}));if(n.messages!==void 0||n.state!==void 0){if(n.messages){this.messages=n.messages;for(let r of n.messages)r.subagentRunId===null&&delete r.subagentRunId;t.messages=n.messages,e.forEach(r=>{r.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:t})})}n.state&&(this.state=n.state,t.state=n.state,e.forEach(r=>{r.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:t})}))}}onError(t,e,n){return fn(re(n,this.messages,this.state,(r,o,i)=>r.onRunFailed?.({error:e,messages:o,state:i,agent:this,input:t}))).pipe(Pt(r=>{let o=r;if((o.messages!==void 0||o.state!==void 0)&&(o.messages!==void 0&&(this.messages=o.messages,n.forEach(i=>{i.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:t})})),o.state!==void 0&&(this.state=o.state,n.forEach(i=>{i.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:t})}))),o.stopPropagation!==!0){let i=String(e);if(!(e.name==="AbortError"||e.message==="Fetch is aborted"||e.message==="signal is aborted without reason"||e.message==="component unmounted"||i==="component unmounted"))throw console.error("Agent execution failed:",e),e}return{}}))}async onFinalize(t,e){let n=await re(e,this.messages,this.state,(r,o,i)=>r.onRunFinalized?.({messages:o,state:i,agent:this,input:t}));(n.messages!==void 0||n.state!==void 0)&&(n.messages!==void 0&&(this.messages=n.messages,e.forEach(r=>{r.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:t})})),n.state!==void 0&&(this.state=n.state,e.forEach(r=>{r.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:t})})))}clone(){let t=Object.create(Object.getPrototypeOf(this));return t.agentId=this.agentId,t.description=this.description,t.threadId=this.threadId,t.messages=J(this.messages),t.state=J(this.state),t._debug=this._debug,t._debugLogger=this._debugLogger,t.isRunning=this.isRunning,t.subscribers=[...this.subscribers],t.middlewares=[...this.middlewares],t.pendingInterrupts=J(this.pendingInterrupts),t}addMessage(t){this.messages.push(t),(async()=>{for(let e of this.subscribers)await e.onNewMessage?.({message:t,messages:this.messages,state:this.state,agent:this});if(t.role==="assistant"&&t.toolCalls)for(let e of t.toolCalls)for(let n of this.subscribers)await n.onNewToolCall?.({toolCall:e,messages:this.messages,state:this.state,agent:this});for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}addMessages(t){this.messages.push(...t),(async()=>{for(let e of t){for(let n of this.subscribers)await n.onNewMessage?.({message:e,messages:this.messages,state:this.state,agent:this});if(e.role==="assistant"&&e.toolCalls)for(let n of e.toolCalls)for(let r of this.subscribers)await r.onNewToolCall?.({toolCall:n,messages:this.messages,state:this.state,agent:this})}for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setMessages(t){this.messages=J(t),(async()=>{for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setState(t){this.state=J(t),(async()=>{for(let e of this.subscribers)await e.onStateChanged?.({messages:this.messages,state:this.state,agent:this})})()}legacy_to_be_removed_runAgentBridged(t){this.agentId=this.agentId??Ct();let e=this.prepareRunAgentInput(t);return(this.middlewares.length===0?this.run(e):this.middlewares.reduceRight((n,r)=>({run:o=>r.run(o,n),get messages(){return n.messages},get state(){return n.state}}),this).run(e)).pipe(os(this.debugLogger),Ol(this.debugLogger),cy(this.threadId,e.runId,this.agentId),n=>n.pipe(Pt(r=>(this.debugLogger?.event("LEGACY","Event:",r,{type:r.type}),r))))}};function ky(t){if(!Array.isArray(t.messages))return t;let e=!1,n=t.messages.map(r=>{if(r.subagentRunId===null){e=!0;let o={...r};return delete o.subagentRunId,o}return r});return e?{...t,messages:n}:t}var Mh=class extends Ay{requestInit(t){return{method:"POST",headers:{...this.headers,"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(ky(t)),signal:this.abortController.signal}}runAgent(t,e){return this.abortController=t?.abortController??new AbortController,super.runAgent(t,e)}abortRun(){this.abortController.abort(),super.abortRun()}constructor(t){super(t),this.abortController=new AbortController,this.url=t.url,this.headers=J(t.headers??{}),this.fetch=t.fetch??((e,n)=>fetch(e,n))}run(t){return Zb(Xb(()=>this.fetch(this.url,this.requestInit(t))),this.debugLogger)}clone(){let t=super.clone();t.url=this.url,t.headers=J(this.headers??{}),t.fetch=this.fetch;let e=new AbortController,n=this.abortController.signal;return n.aborted&&e.abort(n.reason),t.abortController=e,t}};function et(t,e){return e===void 0?t:{...t,credentials:e}}function ss(t){if(t.newThread!==void 0)return t.newThread();let e=be();return t.setActiveThread(e),e}function as(t,e,n,r){if(e.length===0)return;let o=new URL(String(t),location.href).origin;o===location.origin||n.includes(o)||r.has(o)||(r.add(o),console.warn(`<ag-ui-chat>: sending host credentials (${e.join(", ")}) to ${o}, which is not this page's origin (${location.origin}). Those headers are the page's own authentication, and whichever server answers the browser's preflight receives them \u2014 so a URL attribute built from a query parameter or from tenant-authored configuration is a channel for the token to leave on. If this destination is deliberate, name it in \`trustedOrigins\` to confirm it and silence this notice. Reported once per origin.`))}function rr(t){return t.split(",").map(e=>e.trim()).filter(e=>e!=="")}function ls(t,e,n=new Set){let r=new Set(n);for(let a of t)a.role==="tool"&&r.add(a.toolCallId);let o=[],i=[],s=!1;for(let a of t){let l=a.role==="assistant"?Ry(a.toolCalls):[];a.role==="tool"||l.length>0&&!s||(o.push(...i.map(e)),i=[]),o.push(a),s=a.role==="tool";for(let u of l)r.has(u)||(r.add(u),i.push(u))}return o.length+i.length===t.length?t:(o.push(...i.map(e)),o)}function Ry(t){return Array.isArray(t)?t.map(e=>Object(e).id).filter(e=>typeof e=="string"):[]}var le={title:"Assistant",chatHistory:"Chat history",closeHistory:"Close history",searchConversations:"Search conversations",queued:"Waiting to send",removeQueued:'Do not send "{text}"',noMatches:"No conversations match that.",chatMoved:"Moved this panel out of the way",chatMinimised:"Minimised this panel",undo:"Undo",newChat:"New chat",collapse:"Collapse",expand:"Expand",expandUnread:"Expand \u2014 {count} unread",toggleTheme:"Toggle theme",copyCode:"Copy",copied:"Copied",copyFailed:"Copy failed",checkpoints:"Continue a run",noCheckpoints:"Nothing to continue yet.",resumeRun:"Resume",forkRun:"Fork",forkedRun:"branched",greeting:"Hello, {name}",greetingNoName:"Hello there",conversation:"Conversation",jumpToLatest:"Jump to latest",announceResponding:"Assistant is responding",announceAnswerReady:"Assistant answered",announceAwaitingDecision:"{count} action is waiting for your approval",announceStopped:"Response stopped",announceFailed:"The response failed",thinking:"Assistant is thinking\u2026",thoughts:"Thoughts",stopped:"\u23F9 Stopped",connectionLost:"Connection lost",noResult:"No result returned.",callNotFinished:"Not finished: the run ended or moved on before this tool call returned a result.",declinedAction:"User declined the action.",confirmCheckFailed:"Not run: the check that decides whether this action needs the user's confirmation failed.",navigating:"Navigating\u2026",historyReplaced:"The server replaced this conversation's history. Reload to see the updated transcript.",chartUndrawable:"A chart could not be drawn from the data sent, so it was removed.",historyCompacted:"Earlier turns condensed to fit the context window ({count} removed)",usingSkill:"Using skill {name}",runInterrupted:"The previous response didn\u2019t finish \u2014 the page changed before it arrived.",pageMoved:"The page changed since you last looked at it. Call read_page to see the current page, then retry.",attachmentsStillUploading:"{n} file still uploading \u2014 it was not sent with this message and is still attached.",notConnected:"This chat isn\u2019t connected to an agent, so the message wasn\u2019t sent.",continueNeedsTurn:"Type the next turn in the composer first, then pick a run to continue.",continueWhileRunning:"Wait for the current answer or stop it, then pick a run to continue.",skillNeeds:"\u201C{title}\u201D needs {fields} \u2014 fill it in below, then send.",message:"Message",inputPlaceholder:"Ask anything\u2026",send:"Send",stop:"Stop",attachFiles:"Attach files",recordVoice:"Record voice",stopRecording:"Stop recording",transcribing:"Transcribing\u2026",transcriptionFailed:"Transcription failed",recordingLimit:"Stopped at the {n}-minute limit \u2014 transcribing what was recorded.",toolRunning:"running\u2026",toolDeferred:"waiting for you",toolDone:"\u2713 done",toolError:"\u26A0 error",toolDeclined:"\u2298 declined",toolInterrupted:"\u25CC not finished",resizePanel:"Resize the chat panel",decisionApproved:"approved by you",decisionDeclined:"declined by you",argumentsLabel:"Arguments",resultLabel:"Result",errorLabel:"Error",declinedLabel:"Declined",interruptedLabel:"Not finished",details:"Details",subAgentWorking:"Working\u2026",subAgentDelegatedTo:"Delegated to {agent}",subAgentFinished:"{agent} finished",subAgentFailed:"The sub-agent failed",subAgentSteps:"Steps the sub-agent took",approvalEditArgs:"Edit the arguments before approving",approvalArgsInvalid:"That is not valid JSON, so nothing was sent.",approvalArgsNotAnObject:"Arguments have to be a JSON object.",suggestions:"Suggested follow-ups",messageActions:"Message actions",quoteSelection:"Quote",copyMessage:"Copy message",retryMessage:"Try again",feedbackUp:"Good answer",feedbackDown:"Poor answer",confirmAction:"Confirm action",confirmAlways:"Always allow",confirmRun:"Run \u201C{tool}\u201D?",confirm:"Confirm",cancel:"Cancel",approveAction:"Approve action",approvalPrompt:"Approve this action?",approve:"Approve",deny:"Deny",askUserAction:"Question",otherOption:"Other\u2026",answerPlaceholder:"Type your answer\u2026",submit:"Submit",chats:"Chats",noConversations:"No conversations yet.",rename:"Rename",renameConversation:"Rename conversation",delete:"Delete",deleteConversation:"Delete conversation",deletePrompt:"Delete?",tooLarge:"Too large (max {size})",fileTypeNotAllowed:"File type not allowed",uploadFailed:"upload failed",retry:"Retry",retryUpload:"Retry upload",remove:"Remove",removeAttachment:"Remove attachment",justNow:"just now",minutesAgo:"{n}m ago",hoursAgo:"{n}h ago",daysAgo:"{n}d ago",weeksAgo:"{n}w ago"};function Pl(t){let e={...le};for(let n of Object.keys(t)){let r=t[n];r!==void 0&&(e[n]=r)}return e}function Iy(t){let e=document.createElement("input");return e.type="text",e.className="question-input",e.setAttribute("part","question-input"),e.placeholder=t,e}function Dl(t,e,n={}){let r=n.strings??le,o=e.options??[],i=o.length>0,s=!i||e.allowCustom===!0;return new Promise(a=>{let l=document.createElement("div");l.className="question",l.setAttribute("part","question"),l.setAttribute("role","group"),l.setAttribute("aria-label",r.askUserAction);let d=document.createElement("div");d.className="question-body",d.setAttribute("part","question-body"),d.textContent=e.question;let u=document.createElement("div");u.className="question-options",u.setAttribute("part","question-options");let m=`q-${o.length}-${e.question.length}`,w=[];for(let b of o){let A=document.createElement("label");A.className="question-choice",A.setAttribute("part","question-choice");let E=document.createElement("input");E.type="radio",E.name=m,E.value=b,E.setAttribute("part","question-radio");let I=document.createElement("span");I.setAttribute("part","question-choice-text"),I.textContent=b,A.append(E,I),u.appendChild(A),w.push(E)}let p=null,h=null;if(s){if(h=Iy(r.answerPlaceholder),i){let b=document.createElement("label");b.className="question-choice",b.setAttribute("part","question-choice"),p=document.createElement("input"),p.type="radio",p.name=m,p.value="",p.setAttribute("part","question-radio");let A=document.createElement("span");A.setAttribute("part","question-choice-text"),A.textContent=r.otherOption,b.append(p,A),u.appendChild(b),h.disabled=!0}u.appendChild(h)}let v=document.createElement("div");v.className="question-actions",v.setAttribute("part","question-actions");let x=document.createElement("button");x.type="button",x.className="question-btn",x.setAttribute("part","question-button"),x.textContent=r.submit,v.appendChild(x);let S=!1,_=()=>{let b=w.find(A=>A.checked);if(b!==void 0)return b.value;if(h!==null&&(p===null||p.checked)){let A=h.value.trim();return A===""?null:A}return null},O=()=>{h!==null&&p!==null&&(h.disabled=!p.checked),x.disabled=_()===null},G=b=>{if(!S){S=!0,x.disabled=!0;for(let A of w)A.disabled=!0;p!==null&&(p.disabled=!0),h!==null&&(h.disabled=!0),l.setAttribute("data-resolved",b===""?"cancelled":"answered"),a(b)}};for(let b of[...w,...p!==null?[p]:[]])b.addEventListener("change",O);if(h?.addEventListener("input",O),h?.addEventListener("keydown",b=>{if(b.key==="Enter"){b.preventDefault();let A=_();A!==null&&G(A)}}),x.addEventListener("click",()=>{let b=_();b!==null&&G(b)}),n.signal?.addEventListener("abort",()=>G(""),{once:!0}),l.append(d,u,v),t.appendChild(l),n.signal?.aborted===!0){G("");return}O(),(i?w[0]:h)?.focus()})}function Ul(t){let e={};if(!Array.isArray(t))return e;for(let n of t){if(n===null||typeof n!="object")continue;let r=n,o=r.name,i=r.summary,s=r.description;typeof o=="string"&&typeof i=="string"&&(e[o]=typeof s=="string"?{name:o,summary:i,description:s}:{name:o,summary:i})}return e}var ds=class{#e;#t={};#n=new Set;#o=new gr;constructor(e){this.#e=e}register(e){this.#o.register(e)}registerPageState(e){for(let n of No(e))this.#o.register(n)}has(e){return this.#o.has(e)}defaultTools(){return[...this.#a().map(e=>({name:e.name,description:e.description,parameters:e.parameters})),...this.#o.tools()]}advertise(){let e=this.#e.getTools();return this.#n=new Set(e.map(n=>n.name)),e}wasAdvertised(e){return this.#n.has(e)}resolve(e){let n=this.#a().find(r=>r.name===e);return n!==void 0?n:this.#o.has(e)?this.#o.get(e):null}summary(e){return this.#t[e]?.summary}async fetchCatalog(){let e=this.#e.element.getAttribute("data-tools-url");if(e!==null)try{let n=await fetch(e,this.#e.fetchInit(e));this.#t=Ul(await n.json())}catch{}}#r(){return this.#e.routeMap().length===0?[]:qa(()=>this.#e.routeMap(),()=>this.#e.navigate())}#i(){let e=this.#e.getPageMap();return e===null?[]:[{name:To,description:"Read the current page's structure (fields, buttons, route). Call after acting to observe the result within the same turn.",parameters:{type:"object",properties:{},required:[],[xe]:"Read the page"},handler:()=>e()}]}#s(){let e=this.#e.element.getAttribute("data-page-actions");if(e===null)return[];let n=new Set(rr(e));return[...ja(n,r=>this.#e.resolvePageTarget(r)),...n.has(yr.CHAT)?La(this.#e.element):[]]}#a(){return[...this.#r(),...this.#i(),...this.#s(),...this.#d()]}#d(){return this.#e.askUser()?[{name:"ask_user",description:"Ask the user a question and wait for their answer. Provide `options` for a multiple-choice prompt; set `allow_custom` to also accept a free-text answer.",parameters:{type:"object",properties:{question:{type:"string",description:"The question to ask the user."},options:{type:"array",items:{type:"string"},description:"Preset choices offered as radio buttons."},allow_custom:{type:"boolean",description:"Allow a free-text answer in addition to any options."}},required:["question"]},handler:(e,n)=>this.#u(e,n)}]:[]}async#u(e,n){let o={question:typeof e.question=="string"?e.question:""},i=e.options;Array.isArray(i)&&(o.options=i.filter(u=>typeof u=="string")),e.allow_custom===!0&&(o.allowCustom=!0);let s=this.#e.decision.open();this.#e.hidePending();let a=()=>Dl(this.#e.ensureGroup(),o,{signal:s,strings:this.#e.strings()}),l=this.#e.askUserRenderer(),d;if(l===null)d=await a();else try{d=await l.call(this.#e.element,o,{signal:s})}catch(u){d=await this.#c(u,s,n,a)}return this.#e.decision.close(),this.#e.updateEmptyState(),this.#e.follow(),d}#c(e,n,r,o){return n.aborted?Promise.resolve(""):(console.warn(`ag-ui-chat: askUserRenderer failed for tool call ${r}, so the built-in question card asks instead`,e),o())}};function cs(t){if(t.name!==Oa)return null;let e=t.args?.id;return typeof e=="string"&&e!==""?e:null}function Lh(t,e){let n=document.createElement("button");return n.type="button",n.className=`approval-btn approval-btn--${t}`,n.setAttribute("part",`approval-button approval-${t}`),n.textContent=e,n}function Hl(t,e,n={}){let r=n.strings??le;return new Promise(o=>{let i=document.createElement("div");i.className="approval",i.setAttribute("part","approval"),e.toolName!==void 0&&i.setAttribute("data-tool-name",e.toolName),i.setAttribute("role","group"),i.setAttribute("aria-label",r.approveAction);let s=document.createElement("div");s.className="approval-body",s.setAttribute("part","approval-body"),s.textContent=e.message??r.approvalPrompt;let a=Cy(e,n,r),l=document.createElement("div");l.className="approval-actions",l.setAttribute("part","approval-actions");let d=Lh("deny",r.deny),u=Lh("approve",r.approve),m=!1,w=p=>{m||(m=!0,d.disabled=!0,u.disabled=!0,i.setAttribute("data-resolved",p?"approved":"denied"),o(p))};if(d.addEventListener("click",()=>w(!1)),u.addEventListener("click",()=>{a!==null&&!a.commit()||w(!0)}),n.signal?.addEventListener("abort",()=>w(!1),{once:!0}),l.append(d,u),i.append(s,...a===null?[]:[a.root],l),t.appendChild(i),n.signal?.aborted===!0){w(!1);return}u.focus()})}function Cy(t,e,n){let{onEdit:r}=e;if(r===void 0||t.args===void 0)return null;let o=JSON.stringify(t.args,null,2),i=document.createElement("div");i.className="approval-edit",i.setAttribute("part","approval-edit");let s=document.createElement("textarea");s.className="approval-args",s.setAttribute("part","approval-args"),s.setAttribute("aria-label",n.approvalEditArgs),s.rows=Math.min(10,o.split(`
|
|
12
|
-
`).length),s.value=o;let a=document.createElement("div");return a.className="approval-error",a.setAttribute("part","approval-error"),a.setAttribute("role","alert"),a.hidden=!0,i.append(s,a),{root:i,commit:()=>{if(s.value===o)return!0;let l;try{l=JSON.parse(s.value)}catch{return a.textContent=n.approvalArgsInvalid,a.hidden=!1,s.focus(),!1}return typeof l!="object"||l===null||Array.isArray(l)?(a.textContent=n.approvalArgsNotAnObject,a.hidden=!1,s.focus(),!1):(a.hidden=!0,r(l),!0)}}}function Gl(t,e){let n=document.createElement("button");return n.type="button",n.className=`confirm-btn confirm-btn--${t}`,n.setAttribute("part",`confirm-button confirm-${t}`),n.textContent=e,n}function zl(t,e,n={}){let r=n.strings??le;return new Promise(o=>{let i=document.createElement("div");i.className="confirm",i.setAttribute("part","confirm"),i.setAttribute("data-tool-name",e.toolName),i.setAttribute("role","group"),i.setAttribute("aria-label",r.confirmAction);let s=document.createElement("div");s.className="confirm-body",s.setAttribute("part","confirm-body"),s.textContent=e.message??oe(r.confirmRun,{tool:e.toolName});let a=document.createElement("pre");a.className="confirm-args",a.setAttribute("part","confirm-args"),a.textContent=JSON.stringify(e.args,null,2),a.hidden=Object.keys(e.args).length===0;let l=document.createElement("div");l.className="confirm-actions",l.setAttribute("part","confirm-actions");let d=Gl("cancel",r.cancel),u=n.onAlwaysAllow===void 0?null:Gl("always",oe(r.confirmAlways,{tool:e.toolName})),m=Gl("confirm",r.confirm),w=!1,p=h=>{w||(w=!0,i.remove(),o(h))};if(d.addEventListener("click",()=>p(!1)),m.addEventListener("click",()=>p(!0)),u?.addEventListener("click",()=>{n.onAlwaysAllow?.(),p(!0)}),n.signal?.addEventListener("abort",()=>p(!1),{once:!0}),l.append(d,...u===null?[]:[u],m),i.append(s,a,l),t.appendChild(i),n.signal?.aborted===!0){p(!1);return}m.focus()})}function Fl(t){return t[fr]===!0}function us(t){return t[mr]===!0}var hs=class{#e;#t=new Set;#n=null;constructor(e){this.#e=e}forgetWaivers(){this.#t.clear()}buildContext(){return this.#n=window.location.href,this.#e.getContext()}async execute(e){if(cs(e)!==null)return null;let n=this.#e.transcript.cardFor(e);this.#e.transcript.forgetCard(e.id),this.#e.transcript.setCardElement(e.id,n.element);let r=this.#e.tools.wasAdvertised(e.name)?this.#e.tools.resolve(e.name):null;if(r===null)return this.#e.transcript.isServerSettled(e.id)||n.settle(te.INTERRUPTED,this.#e.strings().callNotFinished),null;if(this.#e.getPageMap()!==null&&e.name!==To&&!us(r.parameters)&&this.#i()){let s=this.#e.strings().pageMoved;return n.settle(te.ERROR,s),this.#e.transcript.showPending(),{content:`Error: ${s}`,error:s,outcome:Pe.FAILED}}let o=await this.#r(e,r);if(o==="unanswered"){let s=this.#e.strings().confirmCheckFailed;return n.settle(te.DECLINED,s),this.#e.transcript.showPending(),{content:s,outcome:Pe.DENIED}}if(o!==null){let s={toolName:e.name,args:e.args},a=r.parameters[Eo];typeof a=="string"&&(s.message=a);let l=this.#e.decision.open(),d=zl(this.#e.transcript.ensureGroup(),s,{signal:l,strings:this.#e.strings(),...o==="destructive"?{onAlwaysAllow:()=>this.#t.add(e.name)}:{}});this.#e.transcript.updateEmptyState(),this.#e.transcript.follow();let u=await d;if(this.#e.decision.close(),n.recordDecision(u?"approved":"declined"),!u){let m=this.#e.strings().declinedAction;return n.settle(te.DECLINED,m),this.#e.transcript.showPending(),{content:m,outcome:Pe.DENIED}}}let i=us(r.parameters)&&this.#e.navigate()===null;i&&this.#e.conversationStore().saveCheckpoint(this.#e.threadId(),{toolCallId:e.id});try{let s=await r.handler(e.args,e.id);if(r.render!==void 0&&this.#e.transcript.renderToolOutput(r.render,e),i)return n.settle(te.DONE,this.#e.strings().navigating),{content:"",halt:!0};let a=JSON.stringify(s??null);return n.settle(te.DONE,a),this.#e.transcript.showPending(),{content:a}}catch(s){i&&this.#e.conversationStore().saveCheckpoint(this.#e.threadId(),null);let a=s instanceof Error?s.message:String(s);return n.settle(te.ERROR,a),this.#e.transcript.showPending(),{content:`Error: ${a}`,error:a,outcome:Pe.FAILED}}}async resolveInterrupts(e){let n=this.#e.decision.open();this.#e.announce(oe(this.#e.strings().announceAwaitingDecision,{count:e.length})),this.#e.transcript.hidePending();let r=await Promise.all(e.map(async i=>{let s=i.toolCallId!==void 0?this.#e.transcript.card(i.toolCallId):void 0,a={},l=Ny(i)??i.message;l!==void 0&&(a.message=l);let d=s?.element.getAttribute("data-tool-name");d!=null&&(a.toolName=d);let u,m=this.#e.approveWithEdits()&&s!==void 0;m&&(a.args=s.args),s?.mark(te.DEFERRED);let w=()=>Hl(s?.approvalSlot??this.#e.transcript.ensureGroup(),a,{signal:n,strings:this.#e.strings(),...m?{onEdit:v=>{u=v}}:{}}),p=this.#e.approvalRenderer(),h;if(p===null)h=await w();else try{h=await p.call(this.#e.element,a,{signal:n})}catch(v){h=await this.#o(v,n,i.id,w)}return s?.recordDecision(h?"approved":"declined"),h?s?.mark(te.PENDING):s?.settle(te.DECLINED,this.#e.strings().declinedAction),{id:i.id,approved:h,editedArgs:u}}));this.#e.transcript.updateEmptyState(),this.#e.transcript.follow(),this.#e.decision.close();let o={};for(let{id:i,approved:s,editedArgs:a}of r)o[i]=s?{status:"resolved",payload:a===void 0?{approved:!0}:{approved:!0,editedArgs:a}}:{status:"cancelled"};return o}#o(e,n,r,o){return n.aborted?Promise.resolve(!1):(console.warn(`ag-ui-chat: approvalRenderer failed for interrupt ${r}, so the built-in approval card asks instead`,e),o())}async#r(e,n){if(this.#e.autoConfirm())return null;let r=this.#e.confirmPredicate();if(r!==null)try{return await r.call(this.#e.element,e.name,e.args)===!0?"predicate":null}catch(o){return console.warn(`ag-ui-chat: confirmPredicate failed for tool ${e.name}, so the call was refused`,o),"unanswered"}return this.#t.has(e.name)?null:Fl(n.parameters)?"destructive":null}#i(){return this.#n!==null&&this.#n!==window.location.href}};function Ny(t){let e=t.metadata?.[Eo];return typeof e=="string"&&e.trim()!==""?e:void 0}var Oy="http://www.w3.org/2000/svg",Ve={top:20,right:12,bottom:30,left:44},My=480,Ly=220,Py=220/480,Dy=160,Uy=320,Ph=8,Hy=5.6,Dh=["var(--ag-ui-chart-1, #4f7cff)","var(--ag-ui-chart-2, #21b573)","var(--ag-ui-chart-3, #e0803c)","var(--ag-ui-chart-4, #b563d8)","var(--ag-ui-chart-5, #d84f6e)","var(--ag-ui-chart-6, #3ba7c4)"];function bn(t){return Dh[t%Dh.length]}function Uh(t){let e=Math.max(Ly,t),n=Math.min(Uy,Math.max(Dy,Math.round(e*Py)));return{width:e,height:n,plotW:e-Ve.left-Ve.right,plotH:n-Ve.top-Ve.bottom}}function bt(t,e){let n=document.createElementNS(Oy,t);for(let[r,o]of Object.entries(e))n.setAttribute(r,String(o));return n}function Hh(t,e){let n=bt("text",{"font-size":10,fill:"currentColor","fill-opacity":.65,...e});return n.textContent=t,n}function Gy(t){let e=[];return t.labels.forEach((n,r)=>{let o=0;for(let i of t.series)o+=i.points[r]??0,e.push(o)}),e}function zy(t){let e=t.kind==="stacked"?Gy(t):t.series.flatMap(o=>[...o.points]),n=Math.max(0,...e),r=Math.min(0,...e);return n===r?{min:r,max:n+1}:{min:r,max:n}}function yn(t,e,n,r){return Ve.top+r.plotH-(t-e)/(n-e)*r.plotH}function $l(t,e,n){let r=n.plotW/e;return Ve.left+r*t+r/2}function Fy(t,e){let n=e.plotW/t.length,r=Math.max(...t.map(o=>o.length))*Hy;return Math.max(1,Math.ceil(r/n))}function $y(t,e,n,r,o){for(let s of[r,o]){let a=yn(s,r,o,n);t.appendChild(bt("line",{x1:Ve.left,y1:a,x2:n.width-Ve.right,y2:a,stroke:"currentColor","stroke-opacity":s===r?.35:.12})),t.appendChild(Hh(String(Math.round(s)),{x:Ve.left-6,y:a+4,"text-anchor":"end"}))}let i=Fy(e.labels,n);e.labels.forEach((s,a)=>{a%i===0&&t.appendChild(Hh(s,{x:$l(a,e.labels.length,n),y:n.height-Ve.bottom+16,"text-anchor":"middle"}))})}function By(t,e,n,r,o){let i=n.plotW/e.labels.length,s=i*.7/e.series.length,a=yn(r,r,o,n);e.series.forEach((l,d)=>{l.points.forEach((u,m)=>{let w=yn(u,r,o,n);t.appendChild(bt("rect",{x:Ve.left+i*m+i*.15+s*d,y:w,width:s,height:Math.max(1,a-w),fill:bn(d),rx:2}))})})}function jy(t,e,n,r,o){let i=n.plotW/e.labels.length,s=i*.7,a=e.labels.map(()=>0);e.series.forEach((l,d)=>{l.points.forEach((u,m)=>{let w=a[m]??0,p=w+u;a[m]=p;let h=yn(p,r,o,n);t.appendChild(bt("rect",{x:Ve.left+i*m+i*.15,y:h,width:s,height:Math.max(1,yn(w,r,o,n)-h),fill:bn(d)}))})})}function Vy(t,e,n,r,o){e.series.forEach((i,s)=>{let a=i.points.map((l,d)=>`${$l(d,e.labels.length,n)},${yn(l,r,o,n)}`).join(" ");t.appendChild(bt("polyline",{points:a,fill:"none",stroke:bn(s),"stroke-width":2,"stroke-linejoin":"round"}))})}function qy(t,e,n,r,o){e.series.forEach((i,s)=>{i.points.forEach((a,l)=>{t.appendChild(bt("circle",{cx:$l(l,e.labels.length,n),cy:yn(a,r,o,n),r:4,fill:bn(s),"fill-opacity":.85}))})})}function Wy(t,e,n){let r=e.reduce((l,d)=>l+d,0),o=n.width/2,i=Ve.top+n.plotH/2,s=Math.min(n.plotW,n.plotH)/2;if(r===0){t.appendChild(bt("circle",{cx:o,cy:i,r:s,fill:"none",stroke:"currentColor","stroke-opacity":.3}));return}let a=-Math.PI/2;e.forEach((l,d)=>{let u=l/r*Math.PI*2,m=a+u;if(u>=Math.PI*2)t.appendChild(bt("circle",{cx:o,cy:i,r:s,fill:bn(d)}));else{let w=o+s*Math.cos(a),p=i+s*Math.sin(a),h=o+s*Math.cos(m),v=i+s*Math.sin(m),x=u>Math.PI?1:0;t.appendChild(bt("path",{d:`M ${o} ${i} L ${w} ${p} A ${s} ${s} 0 ${x} 1 ${h} ${v} Z`,fill:bn(d)}))}a=m})}function Gh(t,e){let n=bt("svg",{viewBox:`0 0 ${e.width} ${e.height}`,width:"100%",role:"img"});if(n.setAttribute("aria-label",t.title??`${t.kind} chart`),t.kind==="pie"){let i=t.series[0];return Wy(n,i.points.map(s=>Math.max(0,s)),e),n}let{min:r,max:o}=zy(t);return $y(n,t,e,r,o),t.kind==="bar"?By(n,t,e,r,o):t.kind==="stacked"?jy(n,t,e,r,o):t.kind==="line"?Vy(n,t,e,r,o):qy(n,t,e,r,o),n}function Xy(t){if(t.length<2)return null;let e=document.createElement("div");return e.className="chart-legend",e.setAttribute("part","chart-legend"),t.forEach((n,r)=>{let o=document.createElement("span");o.className="chart-legend-item";let i=document.createElement("span");i.className="chart-legend-swatch",i.style.background=bn(r),o.append(i,document.createTextNode(n)),e.appendChild(o)}),e}function Yy(t,e){new ResizeObserver(()=>{e(Math.round(t.clientWidth/Ph)*Ph)}).observe(t)}function Lr(t){if(t.labels.length===0||t.series.length===0)return null;let e=document.createElement("div");if(e.className="chart-block",e.setAttribute("part","chart-block"),t.title!==void 0&&t.title!==""){let i=document.createElement("div");i.className="chart-title",i.setAttribute("part","chart-title"),i.textContent=t.title,e.appendChild(i)}let n=My,r=Gh(t,Uh(n));e.appendChild(r);let o=Xy(t.kind==="pie"?t.labels:t.series.map(i=>i.label));return o!==null&&e.appendChild(o),Yy(e,i=>{if(i===n)return;n=i;let s=Gh(t,Uh(n));r.replaceWith(s),r=s}),e}var Ky=["bar","line","pie","scatter","stacked"];function Zy(t){return Ky.includes(t)?t:"bar"}function Qy(t){if(!Array.isArray(t))return null;let e=[];for(let n of t){if(typeof n!="number"||!Number.isFinite(n)||Math.abs(n)>1e15)return null;e.push(n)}return e}function Jy(t){if(!Array.isArray(t))return null;for(let e=0;e<t.length;e+=1)if(typeof t[e]!="string")return null;return t}function or(t){if(typeof t!="object"||t===null)return null;let e=t,n=Jy(e.labels);if(n===null||!Array.isArray(e.series))return null;let r=[];for(let s of e.series){if(typeof s!="object"||s===null)return null;let a=s,l=Qy(a.points);if(l===null||l.length!==n.length)return null;r.push({label:typeof a.label=="string"?a.label:"",points:l})}if(r.length===0||r.length*n.length>2e4||n.length>2e3)return null;let o=Zy(e.kind),i=e.title;return typeof i=="string"?{kind:o,title:i,labels:n,series:r}:{kind:o,labels:n,series:r}}var ps="render_chart";function ew(t){let e=or(t);return e===null?null:Lr(e)}function tw(t){let e=or(t);return e!==null&&e.labels.length>0&&e.series.length>0}var nw="chart not rendered: expected labels (strings) and series, each with one finite number per label";function zh(){return{name:ps,description:"Show a chart in the conversation. Supply the data and the page draws it. Every series must have exactly one point per label.",parameters:{type:"object",properties:{kind:{type:"string",enum:["bar","line","pie","scatter","stacked"]},title:{type:"string"},labels:{type:"array",items:{type:"string"}},series:{type:"array",items:{type:"object",properties:{label:{type:"string"},points:{type:"array",items:{type:"number"}}},required:["points"]}}},required:["labels","series"],"x-summary":"Draw a chart"},handler:t=>tw(t)?"chart rendered":nw,render:ew}}function Ut(t){t.style.height="auto",t.style.height=`${t.scrollHeight}px`}function Bl(t,e){return new Promise((n,r)=>{let o=new FormData;o.append("file",t);let i=new XMLHttpRequest;i.open("POST",e.url),i.withCredentials=e.credentials==="include";for(let[l,d]of Object.entries(e.headers??{}))i.setRequestHeader(l,d);let s=e.onProgress;s!==void 0&&i.upload.addEventListener("progress",l=>{l.lengthComputable&&s(l.total===0?0:l.loaded/l.total)}),i.addEventListener("load",()=>{if(i.status>=200&&i.status<300)try{n(rw(JSON.parse(i.responseText)))}catch{r(new Error("upload returned an unreadable response"))}else r(new Error(ow(i)))}),i.addEventListener("error",()=>r(new Error("upload failed"))),i.addEventListener("abort",()=>r(new Error("upload cancelled")));let a=e.signal;a!==void 0&&a.addEventListener("abort",()=>i.abort()),i.send(o)})}function rw(t){if(typeof t!="object"||t===null)throw new Error("not an object");let e=t,n=e.id,r=e.name,o=e.mime,i=e.size,s=e.url;if(typeof n!="string"||typeof r!="string"||typeof o!="string"||typeof i!="number")throw new Error("missing fields");return typeof s=="string"?{id:n,name:r,mime:o,size:i,url:s}:{id:n,name:r,mime:o,size:i}}function ow(t){try{let e=JSON.parse(t.responseText);if(typeof e.error=="string")return e.error}catch{}return`upload failed (${t.status})`}function fs(t){let e=document.createElement("div");e.className="attachment-chips",e.setAttribute("part","attachment-chips");for(let n of t)e.appendChild(iw(n));return e}function iw(t){let e=document.createElement("div");e.className="attachment-chip attachment-chip--ready",e.setAttribute("part","attachment-chip");let n=document.createElement("span");n.className="attachment-chip-icon",n.setAttribute("part","attachment-chip-icon"),n.innerHTML=jl(t.mime),n.setAttribute("aria-hidden","true");let r=document.createElement("span");r.className="attachment-chip-name",r.setAttribute("part","attachment-chip-name"),r.textContent=t.name,r.title=t.name;let o=document.createElement("span");return o.className="attachment-chip-size",o.setAttribute("part","attachment-chip-size"),o.textContent=ms(t.size),e.append(n,r,o),e}function jl(t){return t.startsWith("image/")?yc:t==="application/pdf"?wc:t.startsWith("text/")?xc:bc}function ms(t){if(t<1024)return`${t} B`;let e=["KB","MB","GB"],n=t/1024,r=0;for(;n>=1024&&r<e.length-1;)n/=1024,r+=1;return`${n<10?Math.round(n*10)/10:Math.round(n)} ${e[r]}`}var gs=class{element;#e;#t;#n=[];constructor(e){this.#e=e,this.#t=e.strings??le,this.element=document.createElement("div"),this.element.className="attachment-tray",this.element.setAttribute("part","attachment-tray"),this.element.hidden=!0}add(e){let n={localId:be(),file:e,status:$e.UPLOADING,progress:0,ref:null,error:"",controller:null};this.#n.push(n);let r=this.#o(e);if(r!==null){n.status=$e.ERROR,n.error=r,this.#s(),this.#e.onChange?.();return}this.#s(),this.#e.onChange?.(),this.#r(n)}readyRefs(){let e=[];for(let n of this.#n)n.ref!==null&&e.push(n.ref);return e}hasPending(){return this.#n.some(e=>e.status===$e.UPLOADING)}pendingCount(){return this.#n.filter(e=>e.status===$e.UPLOADING).length}isEmpty(){return this.#n.length===0}clearReady(){this.#n=this.#n.filter(e=>e.status===$e.UPLOADING),this.#s()}clear(){for(let e of this.#n)e.controller?.abort();this.#n=[],this.#s()}dispose(){for(let e of this.#n)e.controller?.abort()}#o(e){return this.#e.maxBytes>0&&e.size>this.#e.maxBytes?oe(this.#t.tooLarge,{size:ms(this.#e.maxBytes)}):sw(this.#e.accept,e)?null:this.#t.fileTypeNotAllowed}#r(e){let n=this.#o(e.file);if(n!==null){e.status=$e.ERROR,e.error=n,this.#s(),this.#e.onChange?.();return}e.status=$e.UPLOADING,e.progress=0,e.error="";let r=new AbortController;e.controller=r,this.#s(),this.#e.upload(e.file,o=>{e.progress=o,this.#s()},r.signal).then(o=>{e.status=$e.READY,e.ref=o}).catch(o=>{e.status=$e.ERROR,e.error=o instanceof Error?o.message:this.#t.uploadFailed}).finally(()=>{e.controller=null,this.#s(),this.#e.onChange?.()})}#i(e){e.controller?.abort(),this.#n=this.#n.filter(n=>n!==e),this.#s(),this.#e.onChange?.()}#s(){this.element.replaceChildren(),this.element.hidden=this.#n.length===0;for(let e of this.#n)this.element.appendChild(this.#a(e))}#a(e){let n=document.createElement("div");n.className=`attachment-chip attachment-chip--${e.status}`,n.setAttribute("part","attachment-chip");let r=document.createElement("span");r.className="attachment-chip-icon",r.setAttribute("part","attachment-chip-icon"),r.innerHTML=jl(e.file.type),r.setAttribute("aria-hidden","true");let o=document.createElement("span");o.className="attachment-chip-name",o.setAttribute("part","attachment-chip-name"),o.textContent=e.file.name,o.title=e.file.name;let i=document.createElement("span");if(i.className="attachment-chip-size",i.setAttribute("part","attachment-chip-size"),i.textContent=e.status===$e.ERROR?e.error:ms(e.file.size),n.append(r,o,i),e.status===$e.UPLOADING){let a=document.createElement("div");a.className="attachment-chip-bar",a.setAttribute("part","attachment-chip-bar");let l=document.createElement("div");l.className="attachment-chip-bar-fill",l.setAttribute("part","attachment-chip-bar-fill"),l.style.width=`${Math.round(e.progress*100)}%`,a.appendChild(l),n.appendChild(a)}if(e.status===$e.ERROR){let a=document.createElement("button");a.type="button",a.className="attachment-chip-retry",a.setAttribute("part","attachment-chip-retry"),a.title=this.#t.retry,a.setAttribute("aria-label",this.#t.retryUpload),a.textContent="\u21BB",a.addEventListener("click",()=>this.#r(e)),n.appendChild(a)}let s=document.createElement("button");return s.type="button",s.className="attachment-chip-remove",s.setAttribute("part","attachment-chip-remove"),s.title=this.#t.remove,s.setAttribute("aria-label",this.#t.removeAttachment),s.textContent="\u2715",s.addEventListener("click",()=>this.#i(e)),n.appendChild(s),n}};function sw(t,e){let n=rr(t).map(i=>i.toLowerCase());if(n.length===0)return!0;let r=e.type.toLowerCase(),o=e.name.toLowerCase();return n.some(i=>i.startsWith(".")?o.endsWith(i):i.endsWith("/*")?r.startsWith(i.slice(0,-1)):r===i)}var vs=class{#e;#t=null;constructor(e){this.#e=e}get tray(){return this.#t}wire(e){this.#t?.element.remove(),this.#t=null;let n=this.#e.element.getAttribute("data-attachments-url"),r=this.#e.uploadHandler()??this.#n(n);if(r===null)return;let o=this.#e.element.getAttribute("data-attachment-accept")??"",i=new gs({upload:r,maxBytes:this.#o(),accept:o,strings:this.#e.strings(),onChange:()=>this.#d(i)});this.#t=i,this.#e.slot.appendChild(this.#t.element),this.#e.fileInput.accept=o,this.#e.button.hidden=!1,this.#r(e),this.#a(i,e)}attach(e){return this.#t===null?!1:(this.#t.add(e),!0)}onFilesPicked(){let e=this.#e.fileInput,n=e.files;if(n!==null)for(let r of Array.from(n))this.#t?.add(r);e.value=""}#n(e){return e===null?null:(n,r,o)=>Bl(n,{url:e,headers:this.#e.headersFor(e),...this.#e.credentialsOption(),onProgress:r,signal:o})}#o(){let e=this.#e.element.getAttribute("data-attachment-max-bytes");if(e===null)return Ca;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>=0?n:Ca}#r(e){let n=this.#e.chat;n.addEventListener("dragover",r=>{r.preventDefault(),n.classList.add("chat--dragover")},{signal:e}),n.addEventListener("dragleave",()=>{n.classList.remove("chat--dragover")},{signal:e}),n.addEventListener("drop",r=>{r.preventDefault(),n.classList.remove("chat--dragover");let o=r.dataTransfer?.files;if(o!==void 0)for(let i of Array.from(o))this.#t?.add(i)},{signal:e})}#i(e,n,r){let o=this.#s(),i=n.getData("text/plain");o===null||i.length<o||(e.preventDefault(),r.add(new File([i],`pasted-${Fh()}.txt`,{type:"text/plain"})))}#s(){let e=this.#e.element.getAttribute("data-paste-attach");if(e===null)return So;if(e==="off")return null;let n=Number.parseInt(e,10);return Number.isNaN(n)||n<=0?(console.warn(`<ag-ui-chat>: data-paste-attach="${e}" is neither "off" nor a positive number of characters, so the default of ${So} is used.`),So):n}#a(e,n){this.#e.chat.addEventListener("paste",r=>{let o=r.clipboardData??null;if(o===null)return;let i=Array.from(o.files);if(i.length===0){this.#i(r,o,e);return}o.getData("text/plain")===""&&r.preventDefault();for(let s of i)this.#t?.add(aw(s))},{signal:n})}#d(e){this.#e.element.dispatchEvent(new CustomEvent(Ta,{detail:{attachments:e.readyRefs(),pending:e.pendingCount()},bubbles:!0,composed:!0}))}};function Fh(){return new Date().toISOString().replace(/[:.]/g,"-")}function aw(t){if(t.name!=="")return t;let e=t.type.split("/")[1]??t.type,n=Fh();return new File([t],e===""?`pasted-${n}`:`pasted-${n}.${e}`,{type:t.type})}async function Vl(t,e){let n=new FormData;n.append("audio",t,"recording.webm");let r=await fetch(e.url,et({method:"POST",headers:{...e.headers??{}},body:n},e.credentials));if(!r.ok)throw new Error(await lw(r));let o=await r.json();if(typeof o=="object"&&o!==null&&typeof o.text=="string")return o.text;throw new Error("transcription returned an unreadable response")}async function lw(t){try{let e=await t.json();if(typeof e.error=="string")return e.error}catch{}return`transcription failed (${t.status})`}var $h=12e4,bs=class{element;#e;#t;#n;#o="idle";#r=null;#i=null;#s=[];#a=null;#d=!1;#u=!1;constructor(e){this.#e=e.transcribe,this.#t=e.onText,this.#n=e.strings??le,this.element=document.createElement("button"),this.element.type="button",this.element.className="voice-btn",this.element.setAttribute("part","voice-button");let n=document.createElement("slot");n.name="icon-voice",n.innerHTML=cc,this.element.append(n),this.#g("idle"),this.element.addEventListener("click",()=>{this.toggle()})}async toggle(){if(this.#o==="recording"){this.#p();return}this.#o!=="transcribing"&&await this.#c()}async#c(){let e;try{e=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{this.#b(this.#n.transcriptionFailed);return}this.#i=e,this.#s=[],this.#d=!1;let n=new MediaRecorder(e);n.addEventListener("dataavailable",r=>{this.#s.push(r.data)}),n.addEventListener("stop",()=>{this.#h(n.mimeType)}),this.#r=n,n.start(),this.#a=setTimeout(()=>{this.#d=!0,this.#p()},$h),this.#g("recording")}#p(){this.#l(),this.#r?.stop()}#l(){this.#a!==null&&(clearTimeout(this.#a),this.#a=null)}dispose(){this.#u=!0,this.#l(),this.#r!==null&&this.#r.state!=="inactive"&&this.#r.stop(),this.#r=null,this.#m()}async#h(e){if(this.#u)return;this.#m(),this.#g("transcribing");let n=new Blob(this.#s,{type:e||"audio/webm"});try{let r=await this.#e(n);this.#g("idle"),this.#d&&(this.element.title=oe(this.#n.recordingLimit,{n:$h/6e4})),r!==""&&this.#t(r)}catch(r){this.#b(r instanceof Error?r.message:this.#n.transcriptionFailed)}finally{this.#r=null}}#m(){for(let e of this.#i?.getTracks()??[])e.stop();this.#i=null}#b(e){this.#m(),this.#r=null,this.#g("idle"),this.element.title=e}#g(e){this.#o=e,this.element.dataset.state=e;let n=this.#w(e);this.element.title=n,this.element.setAttribute("aria-label",n),this.element.setAttribute("aria-pressed",String(e==="recording")),this.element.disabled=e==="transcribing"}#w(e){return e==="recording"?this.#n.stopRecording:e==="transcribing"?this.#n.transcribing:this.#n.recordVoice}};var ys=class{#e;#t=null;constructor(e){this.#e=e}wire(){this.#t?.element.remove(),this.#t=null;let e=this.#e.element.getAttribute("data-transcribe-url"),n=this.#e.transcribeHandler()??this.#n(e);n!==null&&(this.#t=new bs({transcribe:n,onText:r=>this.#o(r),strings:this.#e.strings()}),this.#e.slot.appendChild(this.#t.element))}dispose(){this.#t?.dispose()}#n(e){return e===null?null:n=>Vl(n,{url:e,headers:this.#e.headersFor(e),...this.#e.credentialsOption()})}#o(e){let n=this.#e.input,r=n.value.trim();n.value=r===""?e:`${r} ${e}`,this.#e.onInput(),n.focus()}};var ws=class{chips;palette;#e;#t=[];#n=!1;#o=!1;#r=[];#i=0;constructor(e){this.#e=e,this.chips=document.createElement("div"),this.chips.className="skill-chips",this.chips.setAttribute("part","skill-chips"),this.chips.hidden=!0,this.palette=document.createElement("div"),this.palette.className="skill-palette",this.palette.setAttribute("part","skill-palette"),this.palette.setAttribute("role","listbox"),this.palette.hidden=!0}setSkills(e){this.#t=e,this.#u()}enableChips(e){this.#n=e,this.#u()}enableSlash(e){this.#o=e}isOpen(){return!this.palette.hidden}onInput(e){this.#o&&e.startsWith("/")?this.#s(e.slice(1)):this.close()}onKeydown(e){return this.isOpen()?e.key==="ArrowDown"?(this.#a(1),!0):e.key==="ArrowUp"?(this.#a(-1),!0):e.key==="Escape"?(this.close(),!0):e.key==="Enter"?(this.#r.slice(this.#i,this.#i+1).forEach(n=>{this.#d(n)}),!0):!1:!1}close(){this.palette.hidden=!0,this.palette.replaceChildren()}#s(e){let n=e.trim().toLowerCase(),r=this.#t.filter(o=>o.name.toLowerCase().includes(n)||o.title.toLowerCase().includes(n));if(r.length===0){this.close();return}this.#r=r,this.#i=0,this.#c(),this.palette.hidden=!1}#a(e){let n=this.#r.length;this.#i=(this.#i+e+n)%n,this.#c()}#d(e){this.close(),this.#e(e)}#u(){this.chips.replaceChildren();let e=this.#n?this.#t.filter(n=>n.chip===!0):[];this.chips.hidden=e.length===0;for(let n of e){let r=document.createElement("button");r.type="button",r.className="skill-chip",r.setAttribute("part","skill-chip"),r.textContent=n.title,r.title=`/${n.name}`,r.addEventListener("click",()=>this.#d(n)),this.chips.appendChild(r)}}#c(){this.palette.replaceChildren(),this.#r.forEach((e,n)=>{let r=document.createElement("button");r.type="button",r.className="skill-item",r.setAttribute("part","skill-item"),r.setAttribute("role","option"),r.setAttribute("aria-selected",n===this.#i?"true":"false");let o=document.createElement("span");o.className="skill-item-title",o.setAttribute("part","skill-item-title");let i=document.createElement("code");if(i.className="skill-item-token",i.setAttribute("part","skill-item-token"),i.textContent=`/${e.name}`,o.append(i,document.createTextNode(` ${e.title}`)),r.appendChild(o),e.description!==void 0){let s=document.createElement("span");s.className="skill-item-desc",s.setAttribute("part","skill-item-desc"),s.textContent=e.description,r.appendChild(s)}r.addEventListener("click",()=>this.#d(e)),this.palette.appendChild(r)})}};var dw=500;function Pr(t,e=[],n){for(let r of ww(e)){if(!t.contains(r.startContainer)||!t.contains(r.endContainer))continue;let o=document.createRange();o.setStart(r.startContainer,r.startOffset),o.setEnd(r.endContainer,r.endOffset);let i=pw(o).trim();if(i!=="")return{text:i,rect:yw(o,n)}}return null}function ql(t){let e=cw(t);return e.length===0?"":`${hw(e.join(`
|
|
1
|
+
var kE=Object.defineProperty;var _t=(e,t)=>{for(var n in t)kE(e,n,{get:t[n],enumerable:!0})};var fi="ag-ui-chat",_u="ag-ui-submit",Eu="ag-ui-toggle",Su="ag-ui-unread",Tu="ag-ui-state",ku="ag-ui-attachments",Iu="ag-ui-run-finished",Au="ag-ui-custom",Ru="ag-ui-invalidate",Cu="ag-ui-feedback",Nu="suggestions",Ou="ag_ui.invalidate",wg="ag_ui.subagent",Mn={STARTED:"started",TOOL_CALL:"tool_call",TOOL_RESULT:"tool_result",FINISHED:"finished",FAILED:"failed"},De={USER:"user",ASSISTANT:"assistant"},Er="x-destructive",mi="x-confirm",ke="x-summary",Sr="x-navigates",gi="read_page",Ln=10,qt={COPY:"copy",RETRY:"retry",FEEDBACK:"feedback"},ne={PENDING:"pending",DEFERRED:"deferred",DONE:"done",ERROR:"error",DECLINED:"declined",INTERRUPTED:"interrupted"},Ue={SUCCESS:"success",FAILED:"failed",DENIED:"denied",INTERRUPTED:"interrupted"},Be={UPLOADING:"uploading",READY:"ready",ERROR:"error"},$u=10*1024*1024,zn={INLINE:"inline",MINIMAL:"minimal",COMPACT:"compact",FULL:"full"},Pu="compaction",Mu="load_capability",xg='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 19.5V5m-6.5 6.5L12 5l6.5 6.5"/></svg>',_g='<svg class="glyph glyph--solid" viewBox="0 0 24 24" aria-hidden="true"><rect x="7" y="7" width="10" height="10" rx="2.5"/></svg>',Eg='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M17 8.5V15a5 5 0 0 1-10 0V7a3 3 0 0 1 6 0v7.5a1 1 0 0 1-2 0V8.5"/></svg>',Sg='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 4a3 3 0 0 1 3 3v5a3 3 0 0 1-6 0V7a3 3 0 0 1 3-3z"/><path d="M5 11v1a7 7 0 0 0 14 0v-1"/><path d="M12 19v3"/></svg>',Tg='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 14.5A8.5 8.5 0 0 1 9.5 4a8.5 8.5 0 1 0 10.5 10.5z"/></svg>',kg='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>',Ig='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v8a2.5 2.5 0 0 1-2.5 2.5H9l-5 4z"/></svg>',Ag='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><rect x="9" y="9" width="11" height="11" rx="2"/><path d="M5 15V6a2 2 0 0 1 2-2h8"/></svg>',Rg='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 12a8 8 0 1 1-2.5-5.8"/><path d="M20 4v4h-4"/></svg>',Cg='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M7 10v10H4V10z"/><path d="M7 10l4.5-7a2 2 0 0 1 3.4 2L13.5 9H19a2 2 0 0 1 2 2.3l-1.1 6.4A2 2 0 0 1 17.9 20H7"/></svg>',Ng='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M17 14V4h3v10z"/><path d="M17 14l-4.5 7a2 2 0 0 1-3.4-2l1.4-4H5a2 2 0 0 1-2-2.3l1.1-6.4A2 2 0 0 1 6.1 4H17"/></svg>',Og='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/></svg>',$g='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><rect x="3.5" y="4.5" width="17" height="15" rx="2.5"/><circle cx="9" cy="10" r="1.5"/><path d="M4.5 17.5 9 13.5l3.5 3 3-2.5 4.5 4"/></svg>',Pg='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/><rect class="glyph--solid" x="7.5" y="13.5" width="9" height="4.5" rx="1"/></svg>',Mg='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/><path d="M8.5 13.5h7M8.5 17h4.5"/></svg>',vi="chart",Xt=24,Lg=150,zg=2147483001,bi=5e3,at=8;var IE=/\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g;function ae(e,t){return e.replace(IE,(n,o)=>Object.hasOwn(t,o)?String(t[o]):n)}var AE=/\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g;function Dg(e,t){let n=[];return{text:e.replace(AE,(r,i)=>{let a=t[i];return a==null||a===""?(n.includes(i)||n.push(i),r):String(a)}),missing:n}}function RE(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.name=="string"&&typeof t.title=="string"&&(t.prompt===void 0||typeof t.prompt=="string")}function Lu(e){return Array.isArray(e)?e.filter(RE):[]}var yi=class{#e;#t=[];#n=[];#o=[];constructor(t){this.#e=t}setClientSkills(t){this.#o=t,this.#i()}init(){this.#e.menu.enableChips(this.#e.flag("data-prompt-chips")),this.#e.menu.enableSlash(this.#e.flag("data-slash-commands")),this.#n=this.#r(),this.#i()}async fetch(){let t=this.#e.element.getAttribute("data-skills-url");if(t!==null)try{let n=await fetch(t,this.#e.fetchInit(t));this.#t=Lu(await n.json()),this.#i()}catch{}}apply(t){let{input:n,hint:o}=this.#e;if(t.prompt===void 0){o.hidden=!0,this.#e.send(`/${t.name}`);return}let{text:r,missing:i}=Dg(t.prompt,this.#e.context());if(i.length>0){o.textContent=ae(this.#e.strings().skillNeeds,{title:t.title,fields:i.join(", ")}),o.hidden=!1,n.value=r,this.#e.autoGrow(),n.focus(),this.#a(r);return}if(o.hidden=!0,n.value=r,this.#e.autoGrow(),t.sendImmediately===!1){n.focus();return}this.#e.submit()}#r(){return Lu(this.#e.readJsonAttribute("data-skills"))}#i(){let t=new Map;for(let n of[...this.#t,...this.#n,...this.#o])t.set(n.name,n);this.#e.menu.setSkills([...t.values()])}#a(t){let n=t.indexOf("{");this.#e.input.setSelectionRange(n,t.indexOf("}",n)+1)}};var wi=["top-left","top-right","bottom-left","bottom-right"];function Ug(e){return wi.includes(e)}function zu(e){return[{name:"read_chat_surface",description:"Describe the chat panel you are speaking from: its placement, whether it is collapsed, whether it can be moved, and the box it occupies. Read this before moving or minimising yourself, since a full-screen panel has nowhere to move to. Read-only.",parameters:{type:"object",properties:{},required:[],[ke]:"Read the chat's own position"},handler:()=>e.describeSurface()},{name:"move_chat",description:"Move your own panel to a corner, to uncover something the user needs to see. `corner` is top-left, top-right, bottom-left or bottom-right. Answers `moved: false` with a reason when the placement owns its position or the panel fills the screen; check `read_chat_surface` first, and prefer minimise_chat when there is nowhere to move to.",parameters:{type:"object",properties:{corner:{type:"string",enum:[...wi]}},required:["corner"],[ke]:"Move the chat out of the way"},handler:t=>{let n=String(t.corner??""),o=e.describeSurface();return Ug(n)?o.movable?{moved:e.moveTo(n,{announce:!0}),corner:n}:{moved:!1,reason:o.fullBleed?"the panel fills the screen, so there is nowhere to move it to":o.draggable===!1?"this page has turned off moving the panel":`the "${o.placement??""}" placement owns the panel's position`,suggestion:o.collapsible?"minimise_chat":null}:{moved:!1,reason:`"${n}" is not a corner; use one of ${wi.join(", ")}`}}},{name:"minimise_chat",description:"Collapse your own panel to its launcher, so the user can see the whole page. The launcher stays visible and reopens it. Answers `minimised: false` when the placement has no collapsed state, which is the case for a full-page chat.",parameters:{type:"object",properties:{},required:[],[ke]:"Minimise the chat"},handler:()=>e.describeSurface().collapsible?(e.setCollapsed(!0,{announce:!0}),{minimised:!0}):{minimised:!1,reason:"this placement has no collapsed state, so there is no launcher to return to"}},{name:"restore_chat",description:"Open your own panel again after minimising it.",parameters:{type:"object",properties:{},required:[],[ke]:"Restore the chat"},handler:()=>(e.setCollapsed(!1),{restored:!0})}]}var Tr=class{#e=new Map;register(t){this.#e.set(t.name,t)}has(t){return this.#e.has(t)}get(t){let n=this.#e.get(t);if(n===void 0)throw new Error(`tool "${t}" is not registered`);return n}tools(){return[...this.#e.values()].map(t=>({name:t.name,description:t.description,parameters:t.parameters}))}};var CE="#4f46e5";function Dn(e,t,n){let o=window.getComputedStyle(e).getPropertyValue(t).trim();return o===""?n:o}var NE=4;function Du(e,t={}){let n=document.createElement("div");n.setAttribute("data-ag-ui-highlight",""),n.setAttribute("aria-hidden","true"),n.style.cssText=["position: fixed","inset: 0","pointer-events: none",`z-index: ${Dn(e,"--ag-ui-highlight-z-index",String(zg))}`].join(";");let o=document.createElement("div"),r=document.createElement("div");n.className="ag-ui-highlight",o.className="ag-ui-highlight-scrim",r.className="ag-ui-highlight-ring",t.scrim===!0&&n.append(o),n.append(r);let i=t.ringWidth??Number.parseFloat(Dn(e,"--ag-ui-highlight-ring-width","3")),a=t.flowMs??Number.parseFloat(Dn(e,"--ag-ui-highlight-flow-ms","2400")),s=()=>{let d=e.getBoundingClientRect(),h=t.padding??NE,g=t.radius??Number.parseFloat(getComputedStyle(e).borderRadius),f=d.left-h,p=d.top-h,b=d.width+h*2,v=d.height+h*2;t.scrim===!0&&(o.style.cssText=["position: absolute","inset: 0",`background: ${Dn(e,"--ag-ui-highlight-scrim","rgba(15, 15, 25, 0.45)")}`,`clip-path: path(evenodd, '${PE(f,p,b,v,g+h)}')`].join(";")),r.style.cssText=["position: absolute",`left: ${f}px`,`top: ${p}px`,`width: ${b}px`,`height: ${v}px`,`border-radius: ${g+h}px`,`border: ${i}px solid transparent`,"box-sizing: border-box",$E(e,t)].join(";")};s();let u=null;t.gradient===!0&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches&&(u=r.animate([{backgroundPosition:"100% 0"},{backgroundPosition:"-100% 0"}],{duration:a,iterations:Number.POSITIVE_INFINITY,easing:"linear"}));let l={capture:!0,passive:!0};return window.addEventListener("scroll",s,l),window.addEventListener("resize",s,l),document.body.appendChild(n),()=>{window.removeEventListener("scroll",s,l),window.removeEventListener("resize",s,l),u?.cancel(),n.remove()}}function OE(e){return e===void 0?null:CSS.supports("color",e)?e:null}function $E(e,t){let n=OE(t.color)??Dn(e,"--ag-ui-accent",CE);if(t.gradient!==!0)return`border-color: ${n}`;let o=Dn(e,"--ag-ui-highlight-gradient",`linear-gradient(115deg, transparent 20%, ${n} 50%, transparent 80%)`),r="linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)";return[`background-image: ${o}`,"background-origin: border-box","background-size: 300% 100%",`-webkit-mask: ${r}`,`mask: ${r}`,"-webkit-mask-composite: xor","mask-composite: exclude","background-position: 50% 0"].join(";")}function PE(e,t,n,o,r){let i=Math.max(0,Math.min(r,n/2,o/2)),a=e+n,s=t+o,u=`M 0 0 H ${window.innerWidth} V ${window.innerHeight} H 0 Z`,l=[`M ${e+i} ${t}`,`H ${a-i}`,`A ${i} ${i} 0 0 1 ${a} ${t+i}`,`V ${s-i}`,`A ${i} ${i} 0 0 1 ${a-i} ${s}`,`H ${e+i}`,`A ${i} ${i} 0 0 1 ${e} ${s-i}`,`V ${t+i}`,`A ${i} ${i} 0 0 1 ${e+i} ${t}`,"Z"].join(" ");return`${u} ${l}`}function xi(e,t){return Object.getOwnPropertyDescriptor(e,t).set}var ME=xi(HTMLInputElement.prototype,"value"),LE=xi(HTMLTextAreaElement.prototype,"value"),zE=xi(HTMLSelectElement.prototype,"value"),DE=xi(HTMLInputElement.prototype,"checked");function Kt(e,t){e instanceof HTMLTextAreaElement?LE.call(e,t):e instanceof HTMLSelectElement?zE.call(e,t):ME.call(e,t)}function kr(e,t){DE.call(e,t)}var Uu="#4f46e5",UE="rgba(79, 70, 229, 0.4)",jE="--ag-ui-accent";function Un(e){return new Promise(t=>{setTimeout(t,e)})}function _i(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}function ju(e){return e<=0||_i()?Promise.resolve():Un(e)}function Ei(e,t){let n=window.getComputedStyle(e).getPropertyValue(jE).trim();return n===""?t:n}function jg(e){return`0 0 0 3px ${Ei(e,UE)}`}async function Hu(e,t,n={}){let o=n.charDelayMs??35;Kt(e,""),e.dispatchEvent(new Event("input",{bubbles:!0}));for(let r of t)Kt(e,e.value+r),e.dispatchEvent(new Event("input",{bubbles:!0})),o>0&&await Un(o);e.dispatchEvent(new Event("change",{bubbles:!0}))}async function Gu(e,t={}){let n=t.highlightMs??280,o=e.style.outline,r=e.style.outlineOffset;e.style.outline=`2px solid ${Ei(e,Uu)}`,e.style.outlineOffset="2px",await Un(n),e.style.outline=o,e.style.outlineOffset=r,e.click()}var HE=600,GE=100;function Et(e,t={}){let n=_i();return e.scrollIntoView({block:"center",inline:"nearest",behavior:n?"auto":"smooth"}),n?Promise.resolve():new Promise(o=>{let r,i=()=>{clearTimeout(r),document.removeEventListener("scroll",a,!0),document.removeEventListener("scrollend",i,!0),o()},a=()=>{document.removeEventListener("scroll",a,!0),clearTimeout(r),r=setTimeout(i,t.settleMs??HE)};r=setTimeout(i,GE),document.addEventListener("scroll",a,!0),document.addEventListener("scrollend",i,!0)})}var FE=1200,VE=1/3;async function Hg(e,t,n){(t.focus??n)&&e.focus({preventScroll:!0});let o=t.flashMs??FE;if(o<=0)return;if(t.scrim===!0||t.gradient===!0){let l=Du(e,{scrim:t.scrim===!0,gradient:t.gradient===!0,...t.color===void 0?{}:{color:t.color},...t.ringPadding===void 0?{}:{padding:t.ringPadding}});await Un(o),l();return}let r=e.style.outline,i=e.style.outlineOffset,a=e.style.transition,s=t.color??Ei(e,Uu);e.style.outline=`3px solid ${s}`,e.style.outlineOffset="2px";let u=_i()?0:Math.round(o*VE);await Un(o-u),u>0&&(e.style.transition=`outline-color ${u}ms ease-out`,e.style.outline="3px solid transparent",await Un(u)),e.style.outline=r,e.style.outlineOffset=i,e.style.transition=a}function ZE(e,t={}){return Hg(e,t,!1)}function Fu(e,t={}){return Hg(e,t,!0)}async function Vu(e,t={}){let n=t.pressMs??140,o=e.style.transform,r=e.style.transition,i=e.style.boxShadow;e.style.transition="transform 80ms ease",e.style.transform="scale(0.96)",e.style.boxShadow=jg(e),await ju(n),e.style.transform=o,e.style.transition=r,e.style.boxShadow=i,e.click()}function BE(e,t){for(let n of Array.from(e.options))if(n.value===t||n.text===t)return n;return null}async function Zu(e,t,n={}){let o=BE(e,t);if(o===null)throw new Error(`no <option> matching "${t}"`);let r=n.highlightMs??220,i=e.style.outline,a=e.style.outlineOffset;e.style.outline=`2px solid ${Ei(e,Uu)}`,e.style.outlineOffset="2px",await ju(r),Kt(e,o.value),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),e.style.outline=i,e.style.outlineOffset=a}async function Bu(e,t,n={}){let o=n.flashMs??200,r=e.style.boxShadow;e.style.boxShadow=jg(e),await ju(o),kr(e,t),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),e.style.boxShadow=r}var Ar={SCROLL:"scroll",DRAG:"drag",CHAT:"chat"};function Wu(e,t){let n=[];return e.has(Ar.SCROLL)&&n.push(WE(t)),e.has(Ar.DRAG)&&n.push(qE(t)),n}function WE(e){return{name:"scroll_to",description:"Scroll a target into view. `target` is `top`, `bottom`, or a CSS selector / page-map element id. Read-only: it changes nothing on the page.",parameters:{type:"object",properties:{target:{type:"string"}},required:["target"],[ke]:"Scroll into view"},handler:t=>{let n=String(t.target??"");if(n==="top"||n==="bottom"){let r=n==="top"?0:document.body.scrollHeight;return window.scrollTo({top:r,behavior:"smooth"}),{scrolled:!0,target:n}}let o=e(n);if(o===null)throw new Error(`no element matching "${n}"`);return Et(o),{scrolled:!0,target:n}}}}function qE(e){return{name:"drag_and_drop",description:"Drag the `from` element onto the `to` element (CSS selectors or page-map element ids), firing the page's native drag-and-drop. Use for reordering sortable lists. The page decides what the drop commits.",parameters:{type:"object",properties:{from:{type:"string"},to:{type:"string"}},required:["from","to"],[ke]:"Drag and drop"},handler:t=>{let n=String(t.from??""),o=String(t.to??""),r=e(n);if(r===null)throw new Error(`no element matching "${n}"`);let i=e(o);if(i===null)throw new Error(`no element matching "${o}"`);return XE(r,i),{dragged:!0,from:n,to:o}}}}function XE(e,t){let n=new DataTransfer;Ir(e,"dragstart",n),Ir(t,"dragenter",n),Ir(t,"dragover",n),Ir(t,"drop",n),Ir(e,"dragend",n)}function Ir(e,t,n){let o=new Event(t,{bubbles:!0,cancelable:!0});o.dataTransfer=n,e.dispatchEvent(o)}function qu(e,t){return!t||e===null?[]:[{description:"page_map",value:JSON.stringify(e())}]}function Si(e){let t=[{name:`read_${e.name}`,description:`Read the "${e.name}" state.`,parameters:{type:"object",properties:{},required:[],[ke]:`Read ${e.name}`},handler:()=>e.read()}],n=e.write;return n!==void 0&&t.push({name:`set_${e.name}`,description:`Update the "${e.name}" state.`,parameters:{...e.schema??{type:"object"},[Er]:!0,[ke]:`Update ${e.name}`},handler:o=>n(o)}),t}var KE=Si;var Gg=/:([A-Za-z_][A-Za-z0-9_]*)/g;function YE(e){return[...e.matchAll(Gg)].map(t=>t[0].slice(1))}function JE(e,t,n){let o={...n};return{path:t.replace(Gg,(i,a)=>{let s=n[a];if(s==null||String(s)==="")throw new Error(`route "${e}" requires path param "${a}"`);return delete o[a],encodeURIComponent(String(s))}),leftover:o}}function QE(e,t){let n=new URLSearchParams;for(let[r,i]of Object.entries(t))n.set(r,String(i));let o=n.toString();return o===""?e:`${e}?${o}`}function Xu(e,t){return[{name:"list_routes",description:"List the routes the app can navigate to. Each route's `pathParams` names the dynamic segments to pass as `params` to `navigate_to_route`.",parameters:{type:"object",properties:{},required:[],[ke]:"List pages"},handler:()=>e().map(n=>({...n,pathParams:YE(n.path)}))},{name:"navigate_to_route",description:"Navigate to one of the app's routes by its id, filling any dynamic `:name` path segments (and extra query params) from `params`.",parameters:{type:"object",properties:{route_id:{type:"string"},params:{type:"object"}},required:["route_id"],[Sr]:!0,[ke]:"Navigate"},handler:n=>{let o=n.route_id,r=e().find(d=>d.id===o);if(r===void 0)throw new Error(`unknown route "${String(o)}"`);let i=n.params??{},{path:a,leftover:s}=JE(r.id,r.path,i),u=QE(a,s),l=t();return l!==null?l(u):window.location.assign(u),{navigated:!0,path:u}}}]}var Oe=[];for(let e=0;e<256;++e)Oe.push((e+256).toString(16).slice(1));function Fg(e,t=0){return(Oe[e[t+0]]+Oe[e[t+1]]+Oe[e[t+2]]+Oe[e[t+3]]+"-"+Oe[e[t+4]]+Oe[e[t+5]]+"-"+Oe[e[t+6]]+Oe[e[t+7]]+"-"+Oe[e[t+8]]+Oe[e[t+9]]+"-"+Oe[e[t+10]]+Oe[e[t+11]]+Oe[e[t+12]]+Oe[e[t+13]]+Oe[e[t+14]]+Oe[e[t+15]]).toLowerCase()}var Ku,eS=new Uint8Array(16);function Yu(){if(!Ku){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ku=crypto.getRandomValues.bind(crypto)}return Ku(eS)}var tS=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ju={randomUUID:tS};function nS(e,t,n){if(Ju.randomUUID&&!t&&!e)return Ju.randomUUID();e=e||{};let o=e.random??e.rng?.()??Yu();if(o.length<16)throw new Error("Random bytes length must be >= 16");if(o[6]=o[6]&15|64,o[8]=o[8]&63|128,t){if(n=n||0,n<0||n+16>t.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let r=0;r<16;++r)t[n+r]=o[r];return t}return Fg(o)}var Mt=nS;var x=(function(e){return e.TEXT_MESSAGE_START="TEXT_MESSAGE_START",e.TEXT_MESSAGE_CONTENT="TEXT_MESSAGE_CONTENT",e.TEXT_MESSAGE_END="TEXT_MESSAGE_END",e.TEXT_MESSAGE_CHUNK="TEXT_MESSAGE_CHUNK",e.TOOL_CALL_START="TOOL_CALL_START",e.TOOL_CALL_ARGS="TOOL_CALL_ARGS",e.TOOL_CALL_END="TOOL_CALL_END",e.TOOL_CALL_CHUNK="TOOL_CALL_CHUNK",e.TOOL_CALL_RESULT="TOOL_CALL_RESULT",e.STATE_SNAPSHOT="STATE_SNAPSHOT",e.STATE_DELTA="STATE_DELTA",e.MESSAGES_SNAPSHOT="MESSAGES_SNAPSHOT",e.ACTIVITY_SNAPSHOT="ACTIVITY_SNAPSHOT",e.ACTIVITY_DELTA="ACTIVITY_DELTA",e.RAW="RAW",e.CUSTOM="CUSTOM",e.RUN_STARTED="RUN_STARTED",e.RUN_FINISHED="RUN_FINISHED",e.RUN_ERROR="RUN_ERROR",e.STEP_STARTED="STEP_STARTED",e.STEP_FINISHED="STEP_FINISHED",e.REASONING_START="REASONING_START",e.REASONING_MESSAGE_START="REASONING_MESSAGE_START",e.REASONING_MESSAGE_CONTENT="REASONING_MESSAGE_CONTENT",e.REASONING_MESSAGE_END="REASONING_MESSAGE_END",e.REASONING_MESSAGE_CHUNK="REASONING_MESSAGE_CHUNK",e.REASONING_END="REASONING_END",e.REASONING_ENCRYPTED_VALUE="REASONING_ENCRYPTED_VALUE",e.SUBAGENT_STARTED="SUBAGENT_STARTED",e.SUBAGENT_FINISHED="SUBAGENT_FINISHED",e.SUBAGENT_ERROR="SUBAGENT_ERROR",e})({}),Yt="1.0";var rS={TextMessageStartEvent:{optional:["timestamp","rawEvent","metadata","subagentRunId","role","name"],fields:{}},TextMessageContentEvent:{optional:["timestamp","rawEvent","metadata","subagentRunId"],fields:{}},TextMessageEndEvent:{optional:["timestamp","rawEvent","metadata","subagentRunId"],fields:{}},TextMessageChunkEvent:{optional:["timestamp","rawEvent","metadata","subagentRunId","messageId","role","delta","name"],fields:{}},ToolCallStartEvent:{optional:["timestamp","rawEvent","metadata","subagentRunId","parentMessageId"],fields:{}},ToolCallArgsEvent:{optional:["timestamp","rawEvent","metadata","subagentRunId"],fields:{}},ToolCallEndEvent:{optional:["timestamp","rawEvent","metadata","subagentRunId"],fields:{}},ToolCallChunkEvent:{optional:["timestamp","rawEvent","metadata","subagentRunId","toolCallId","toolCallName","parentMessageId","delta"],fields:{}},TextPart:{optional:["id","metadata"],fields:{}},DataSource:{optional:[],fields:{}},UrlSource:{optional:["mimeType"],fields:{}},FileSource:{optional:["provider","mimeType"],fields:{}},PartSource:{discriminator:"type",variants:{data:"DataSource",url:"UrlSource",file:"FileSource"}},ImagePart:{optional:["id","metadata"],fields:{source:"PartSource"}},AudioPart:{optional:["id","metadata"],fields:{source:"PartSource"}},VideoPart:{optional:["id","metadata"],fields:{source:"PartSource"}},DocumentPart:{optional:["id","metadata"],fields:{source:"PartSource"}},ContentPart:{discriminator:"type",variants:{text:"TextPart",image:"ImagePart",audio:"AudioPart",video:"VideoPart",document:"DocumentPart"}},ToolCallResultEvent:{optional:["timestamp","rawEvent","metadata","subagentRunId","role"],fields:{content:{array:"ContentPart"}}},StateSnapshotEvent:{optional:["timestamp","rawEvent","metadata","subagentRunId"],fields:{}},AddOperation:{optional:[],fields:{}},RemoveOperation:{optional:[],fields:{}},ReplaceOperation:{optional:[],fields:{}},MoveOperation:{optional:[],fields:{}},CopyOperation:{optional:[],fields:{}},TestOperation:{optional:[],fields:{}},JsonPatchOperation:{discriminator:"op",variants:{add:"AddOperation",remove:"RemoveOperation",replace:"ReplaceOperation",move:"MoveOperation",copy:"CopyOperation",test:"TestOperation"}},StateDeltaEvent:{optional:["timestamp","rawEvent","metadata","subagentRunId"],fields:{delta:{array:"JsonPatchOperation"}}},DeveloperMessage:{optional:["subagentRunId","name","encryptedValue","metadata"],fields:{}},SystemMessage:{optional:["subagentRunId","name","encryptedValue","metadata"],fields:{}},FunctionCall:{optional:[],fields:{}},ToolCall:{optional:["encryptedValue","metadata"],fields:{function:"FunctionCall"}},AssistantMessage:{optional:["subagentRunId","name","encryptedValue","metadata","content","toolCalls"],fields:{toolCalls:{array:"ToolCall"}}},UserMessage:{optional:["subagentRunId","name","encryptedValue","metadata"],fields:{content:{array:"ContentPart"}}},ToolMessage:{optional:["subagentRunId","error","encryptedValue","metadata"],fields:{content:{array:"ContentPart"}}},ActivityMessage:{optional:["subagentRunId","metadata"],fields:{}},ReasoningMessage:{optional:["subagentRunId","encryptedValue","metadata"],fields:{}},Message:{discriminator:"role",variants:{developer:"DeveloperMessage",system:"SystemMessage",assistant:"AssistantMessage",user:"UserMessage",tool:"ToolMessage",activity:"ActivityMessage",reasoning:"ReasoningMessage"}},MessagesSnapshotEvent:{optional:["timestamp","rawEvent","metadata"],fields:{messages:{array:"Message"}}},ActivitySnapshotEvent:{optional:["timestamp","rawEvent","metadata","subagentRunId","replace"],fields:{}},ActivityDeltaEvent:{optional:["timestamp","rawEvent","metadata","subagentRunId"],fields:{patch:{array:"JsonPatchOperation"}}},RawEvent:{optional:["timestamp","rawEvent","metadata","subagentRunId","source"],fields:{}},CustomEvent:{optional:["timestamp","rawEvent","metadata","subagentRunId"],fields:{}},Tool:{optional:["parameters","metadata"],fields:{}},Context:{optional:[],fields:{}},ResumeEntry:{optional:["payload","metadata"],fields:{}},RunAgentInput:{optional:["protocolVersion","parentRunId","state","tools","context","forwardedProps","resume"],fields:{messages:{array:"Message"},tools:{array:"Tool"},context:{array:"Context"},resume:{array:"ResumeEntry"}}},RunStartedEvent:{optional:["timestamp","rawEvent","metadata","protocolVersion","parentRunId","input"],fields:{input:"RunAgentInput"}},RunFinishedSuccessOutcome:{optional:["pendingToolCallIds"],fields:{}},Interrupt:{optional:["subagentRunId","message","toolCallId","responseSchema","expiresAt","metadata"],fields:{}},RunFinishedInterruptOutcome:{optional:[],fields:{interrupts:{array:"Interrupt"}}},RunFinishedCancelledOutcome:{optional:[],fields:{}},RunFinishedOutcome:{discriminator:"type",variants:{success:"RunFinishedSuccessOutcome",interrupt:"RunFinishedInterruptOutcome",cancelled:"RunFinishedCancelledOutcome"}},TokenUsage:{optional:["provider","model","inputTokens","outputTokens","totalTokens","reasoningTokens","cachedInputTokens","cacheWriteInputTokens"],fields:{}},RunFinishedEvent:{optional:["timestamp","rawEvent","metadata","result","outcome","usage"],fields:{outcome:"RunFinishedOutcome",usage:{array:"TokenUsage"}}},RunErrorEvent:{optional:["timestamp","rawEvent","metadata","code","usage"],fields:{usage:{array:"TokenUsage"}}},StepStartedEvent:{optional:["timestamp","rawEvent","metadata","subagentRunId"],fields:{}},StepFinishedEvent:{optional:["timestamp","rawEvent","metadata","subagentRunId"],fields:{}},ReasoningStartEvent:{optional:["timestamp","rawEvent","metadata","subagentRunId"],fields:{}},ReasoningMessageStartEvent:{optional:["timestamp","rawEvent","metadata","subagentRunId"],fields:{}},ReasoningMessageContentEvent:{optional:["timestamp","rawEvent","metadata","subagentRunId"],fields:{}},ReasoningMessageEndEvent:{optional:["timestamp","rawEvent","metadata","subagentRunId"],fields:{}},ReasoningMessageChunkEvent:{optional:["timestamp","rawEvent","metadata","subagentRunId","messageId","delta"],fields:{}},ReasoningEndEvent:{optional:["timestamp","rawEvent","metadata","subagentRunId"],fields:{}},ReasoningEncryptedValueEvent:{optional:["timestamp","rawEvent","metadata","subagentRunId"],fields:{}},SubagentStartedEvent:{optional:["timestamp","rawEvent","metadata","description","parentSubagentRunId","parentToolCallId","parentMessageId"],fields:{}},SubagentFinishedSuccessOutcome:{optional:[],fields:{}},SubagentFinishedSuspendedOutcome:{optional:["interruptIds"],fields:{}},SubagentFinishedOutcome:{discriminator:"type",variants:{success:"SubagentFinishedSuccessOutcome",suspended:"SubagentFinishedSuspendedOutcome"}},SubagentFinishedEvent:{optional:["timestamp","rawEvent","metadata","result","outcome"],fields:{outcome:"SubagentFinishedOutcome"}},SubagentErrorEvent:{optional:["timestamp","rawEvent","metadata","code"],fields:{}},Event:{discriminator:"type",variants:{TEXT_MESSAGE_START:"TextMessageStartEvent",TEXT_MESSAGE_CONTENT:"TextMessageContentEvent",TEXT_MESSAGE_END:"TextMessageEndEvent",TEXT_MESSAGE_CHUNK:"TextMessageChunkEvent",TOOL_CALL_START:"ToolCallStartEvent",TOOL_CALL_ARGS:"ToolCallArgsEvent",TOOL_CALL_END:"ToolCallEndEvent",TOOL_CALL_CHUNK:"ToolCallChunkEvent",TOOL_CALL_RESULT:"ToolCallResultEvent",STATE_SNAPSHOT:"StateSnapshotEvent",STATE_DELTA:"StateDeltaEvent",MESSAGES_SNAPSHOT:"MessagesSnapshotEvent",ACTIVITY_SNAPSHOT:"ActivitySnapshotEvent",ACTIVITY_DELTA:"ActivityDeltaEvent",RAW:"RawEvent",CUSTOM:"CustomEvent",RUN_STARTED:"RunStartedEvent",RUN_FINISHED:"RunFinishedEvent",RUN_ERROR:"RunErrorEvent",STEP_STARTED:"StepStartedEvent",STEP_FINISHED:"StepFinishedEvent",REASONING_START:"ReasoningStartEvent",REASONING_MESSAGE_START:"ReasoningMessageStartEvent",REASONING_MESSAGE_CONTENT:"ReasoningMessageContentEvent",REASONING_MESSAGE_END:"ReasoningMessageEndEvent",REASONING_MESSAGE_CHUNK:"ReasoningMessageChunkEvent",REASONING_END:"ReasoningEndEvent",REASONING_ENCRYPTED_VALUE:"ReasoningEncryptedValueEvent",SUBAGENT_STARTED:"SubagentStartedEvent",SUBAGENT_FINISHED:"SubagentFinishedEvent",SUBAGENT_ERROR:"SubagentErrorEvent"}},SubagentInfo:{optional:["description"],fields:{}},IdentityCapabilities:{optional:["name","type","description","version","provider","documentationUrl","metadata"],fields:{}},TransportCapabilities:{optional:["streaming","websocket","httpBinary","pushNotifications","resumable"],fields:{}},ToolsCapabilities:{optional:["supported","items","parallelCalls","clientProvided"],fields:{items:{array:"Tool"}}},OutputCapabilities:{optional:["structuredOutput","supportedMimeTypes"],fields:{}},StateCapabilities:{optional:["snapshots","deltas","memory","persistentState"],fields:{}},MultiAgentCapabilities:{optional:["supported","delegation","handoffs","subagents"],fields:{subagents:{array:"SubagentInfo"}}},ReasoningCapabilities:{optional:["supported","streaming","encrypted"],fields:{}},MultimodalInputCapabilities:{optional:["image","audio","video","pdf","file"],fields:{}},MultimodalOutputCapabilities:{optional:["image","audio"],fields:{}},MultimodalCapabilities:{optional:["input","output"],fields:{input:"MultimodalInputCapabilities",output:"MultimodalOutputCapabilities"}},ExecutionCapabilities:{optional:["codeExecution","sandboxed","maxIterations","maxExecutionTime"],fields:{}},HumanInTheLoopCapabilities:{optional:["supported","approvals","interventions","feedback","interrupts","approveWithEdits"],fields:{}},AgentCapabilities:{optional:["identity","transport","tools","output","state","multiAgent","reasoning","multimodal","execution","humanInTheLoop","custom"],fields:{identity:"IdentityCapabilities",transport:"TransportCapabilities",tools:"ToolsCapabilities",output:"OutputCapabilities",state:"StateCapabilities",multiAgent:"MultiAgentCapabilities",reasoning:"ReasoningCapabilities",multimodal:"MultimodalCapabilities",execution:"ExecutionCapabilities",humanInTheLoop:"HumanInTheLoopCapabilities"}}};function Rr(e,t){if(typeof t=="string")return Rr(e,rS[t]);if("array"in t){if(!Array.isArray(e))return e;let r=e.map(i=>Rr(i,t.array));return r.every((i,a)=>i===e[a])?e:r}if(typeof e!="object"||e===null||Array.isArray(e))return e;let n=e;if("discriminator"in t){let r=n[t.discriminator];return typeof r=="string"&&Object.prototype.hasOwnProperty.call(t.variants,r)?Rr(e,t.variants[r]):e}let o=n;for(let r of t.optional)Object.prototype.hasOwnProperty.call(n,r)&&n[r]===null&&(o===n&&(o={...n}),delete o[r]);for(let[r,i]of Object.entries(t.fields)){if(!Object.prototype.hasOwnProperty.call(o,r))continue;let a=Rr(o[r],i);a!==o[r]&&(o===n&&(o={...n}),o[r]=a)}return o}function Qu(e,t){return Rr(e,t)}var W=class extends Error{constructor(e){super(e)}},ec=class extends W{constructor(){super("Connect not implemented. This method is not supported by the current agent.")}};function Vg(e,t){return t===void 0?e:e===void 0?{...t}:{...e,...t}}function jn(e){return e===void 0?"":typeof e=="string"?e:e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Zg(e){return Array.isArray(e)&&e.some(t=>t.type!=="text")}var tc={};_t(tc,{JsonPatchError:()=>we,_areEquals:()=>Or,applyOperation:()=>Jt,applyPatch:()=>Ni,applyReducer:()=>lS,deepClone:()=>aS,getValueByPointer:()=>Ri,validate:()=>Wg,validator:()=>Ci});var oS=(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(o,r){o.__proto__=r}||function(o,r){for(var i in r)r.hasOwnProperty(i)&&(o[i]=r[i])},e(t,n)};return function(t,n){e(t,n);function o(){this.constructor=t}t.prototype=n===null?Object.create(n):(o.prototype=n.prototype,new o)}})(),iS=Object.prototype.hasOwnProperty;function ki(e,t){return iS.call(e,t)}function Ii(e){if(Array.isArray(e)){for(var t=new Array(e.length),n=0;n<t.length;n++)t[n]=""+n;return t}if(Object.keys)return Object.keys(e);var o=[];for(var r in e)ki(e,r)&&o.push(r);return o}function $e(e){switch(typeof e){case"object":return JSON.parse(JSON.stringify(e));case"undefined":return null;default:return e}}function Ai(e){for(var t=0,n=e.length,o;t<n;){if(o=e.charCodeAt(t),o>=48&&o<=57){t++;continue}return!1}return!0}function mt(e){return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function Cr(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Ti(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(var t=0,n=e.length;t<n;t++)if(Ti(e[t]))return!0}else if(typeof e=="object"){for(var o=Ii(e),r=o.length,i=0;i<r;i++)if(Ti(e[o[i]]))return!0}}return!1}function Bg(e,t){var n=[e];for(var o in t){var r=typeof t[o]=="object"?JSON.stringify(t[o],null,2):t[o];typeof r<"u"&&n.push(o+": "+r)}return n.join(`
|
|
2
|
+
`)}var Nr=(function(e){oS(t,e);function t(n,o,r,i,a){var s=this.constructor,u=e.call(this,Bg(n,{name:o,index:r,operation:i,tree:a}))||this;return u.name=o,u.index=r,u.operation=i,u.tree=a,Object.setPrototypeOf(u,s.prototype),u.message=Bg(n,{name:o,index:r,operation:i,tree:a}),u}return t})(Error);var we=Nr,aS=$e,Hn={add:function(e,t,n){return e[t]=this.value,{newDocument:n}},remove:function(e,t,n){var o=e[t];return delete e[t],{newDocument:n,removed:o}},replace:function(e,t,n){var o=e[t];return e[t]=this.value,{newDocument:n,removed:o}},move:function(e,t,n){var o=Ri(n,this.path);o&&(o=$e(o));var r=Jt(n,{op:"remove",path:this.from}).removed;return Jt(n,{op:"add",path:this.path,value:r}),{newDocument:n,removed:o}},copy:function(e,t,n){var o=Ri(n,this.from);return Jt(n,{op:"add",path:this.path,value:$e(o)}),{newDocument:n}},test:function(e,t,n){return{newDocument:n,test:Or(e[t],this.value)}},_get:function(e,t,n){return this.value=e[t],{newDocument:n}}},sS={add:function(e,t,n){return Ai(t)?e.splice(t,0,this.value):e[t]=this.value,{newDocument:n,index:t}},remove:function(e,t,n){var o=e.splice(t,1);return{newDocument:n,removed:o[0]}},replace:function(e,t,n){var o=e[t];return e[t]=this.value,{newDocument:n,removed:o}},move:Hn.move,copy:Hn.copy,test:Hn.test,_get:Hn._get};function Ri(e,t){if(t=="")return e;var n={op:"_get",path:t};return Jt(e,n),n.value}function Jt(e,t,n,o,r,i){if(n===void 0&&(n=!1),o===void 0&&(o=!0),r===void 0&&(r=!0),i===void 0&&(i=0),n&&(typeof n=="function"?n(t,0,e,t.path):Ci(t,0)),t.path===""){var a={newDocument:e};if(t.op==="add")return a.newDocument=t.value,a;if(t.op==="replace")return a.newDocument=t.value,a.removed=e,a;if(t.op==="move"||t.op==="copy")return a.newDocument=Ri(e,t.from),t.op==="move"&&(a.removed=e),a;if(t.op==="test"){if(a.test=Or(e,t.value),a.test===!1)throw new we("Test operation failed","TEST_OPERATION_FAILED",i,t,e);return a.newDocument=e,a}else{if(t.op==="remove")return a.removed=e,a.newDocument=null,a;if(t.op==="_get")return t.value=e,a;if(n)throw new we("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",i,t,e);return a}}else{o||(e=$e(e));var s=t.path||"",u=s.split("/"),l=e,d=1,h=u.length,g=void 0,f=void 0,p=void 0;for(typeof n=="function"?p=n:p=Ci;;){if(f=u[d],f&&f.indexOf("~")!=-1&&(f=Cr(f)),r&&(f=="__proto__"||f=="prototype"&&d>0&&u[d-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(n&&g===void 0&&(l[f]===void 0?g=u.slice(0,d).join("/"):d==h-1&&(g=t.path),g!==void 0&&p(t,0,e,g)),d++,Array.isArray(l)){if(f==="-")f=l.length;else{if(n&&!Ai(f))throw new we("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",i,t,e);Ai(f)&&(f=~~f)}if(d>=h){if(n&&t.op==="add"&&f>l.length)throw new we("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",i,t,e);var a=sS[t.op].call(t,l,f,e);if(a.test===!1)throw new we("Test operation failed","TEST_OPERATION_FAILED",i,t,e);return a}}else if(d>=h){var a=Hn[t.op].call(t,l,f,e);if(a.test===!1)throw new we("Test operation failed","TEST_OPERATION_FAILED",i,t,e);return a}if(l=l[f],n&&d<h&&(!l||typeof l!="object"))throw new we("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",i,t,e)}}}function Ni(e,t,n,o,r){if(o===void 0&&(o=!0),r===void 0&&(r=!0),n&&!Array.isArray(t))throw new we("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");o||(e=$e(e));for(var i=new Array(t.length),a=0,s=t.length;a<s;a++)i[a]=Jt(e,t[a],n,!0,r,a),e=i[a].newDocument;return i.newDocument=e,i}function lS(e,t,n){var o=Jt(e,t);if(o.test===!1)throw new we("Test operation failed","TEST_OPERATION_FAILED",n,t,e);return o.newDocument}function Ci(e,t,n,o){if(typeof e!="object"||e===null||Array.isArray(e))throw new we("Operation is not an object","OPERATION_NOT_AN_OBJECT",t,e,n);if(Hn[e.op]){if(typeof e.path!="string")throw new we("Operation `path` property is not a string","OPERATION_PATH_INVALID",t,e,n);if(e.path.indexOf("/")!==0&&e.path.length>0)throw new we('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",t,e,n);if((e.op==="move"||e.op==="copy")&&typeof e.from!="string")throw new we("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",t,e,n);if((e.op==="add"||e.op==="replace"||e.op==="test")&&e.value===void 0)throw new we("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",t,e,n);if((e.op==="add"||e.op==="replace"||e.op==="test")&&Ti(e.value))throw new we("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",t,e,n);if(n){if(e.op=="add"){var r=e.path.split("/").length,i=o.split("/").length;if(r!==i+1&&r!==i)throw new we("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",t,e,n)}else if(e.op==="replace"||e.op==="remove"||e.op==="_get"){if(e.path!==o)throw new we("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",t,e,n)}else if(e.op==="move"||e.op==="copy"){var a={op:"_get",path:e.from,value:void 0},s=Wg([a],n);if(s&&s.name==="OPERATION_PATH_UNRESOLVABLE")throw new we("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",t,e,n)}}}else throw new we("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",t,e,n)}function Wg(e,t,n){try{if(!Array.isArray(e))throw new we("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(t)Ni($e(t),$e(e),n||!0);else{n=n||Ci;for(var o=0;o<e.length;o++)n(e[o],o,t,void 0)}}catch(r){if(r instanceof we)return r;throw r}}function Or(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){var n=Array.isArray(e),o=Array.isArray(t),r,i,a;if(n&&o){if(i=e.length,i!=t.length)return!1;for(r=i;r--!==0;)if(!Or(e[r],t[r]))return!1;return!0}if(n!=o)return!1;var s=Object.keys(e);if(i=s.length,i!==Object.keys(t).length)return!1;for(r=i;r--!==0;)if(!t.hasOwnProperty(s[r]))return!1;for(r=i;r--!==0;)if(a=s[r],!Or(e[a],t[a]))return!1;return!0}return e!==e&&t!==t}var ic={};_t(ic,{compare:()=>gS,generate:()=>nc,observe:()=>mS,unobserve:()=>fS});var rc=new WeakMap,uS=(function(){function e(t){this.observers=new Map,this.obj=t}return e})(),cS=(function(){function e(t,n){this.callback=t,this.observer=n}return e})();function dS(e){return rc.get(e)}function pS(e,t){return e.observers.get(t)}function hS(e,t){e.observers.delete(t.callback)}function fS(e,t){t.unobserve()}function mS(e,t){var n=[],o,r=dS(e);if(!r)r=new uS(e),rc.set(e,r);else{var i=pS(r,t);o=i&&i.observer}if(o)return o;if(o={},r.value=$e(e),t){o.callback=t,o.next=null;var a=function(){nc(o)},s=function(){clearTimeout(o.next),o.next=setTimeout(a)};typeof window<"u"&&(window.addEventListener("mouseup",s),window.addEventListener("keyup",s),window.addEventListener("mousedown",s),window.addEventListener("keydown",s),window.addEventListener("change",s))}return o.patches=n,o.object=e,o.unobserve=function(){nc(o),clearTimeout(o.next),hS(r,o),typeof window<"u"&&(window.removeEventListener("mouseup",s),window.removeEventListener("keyup",s),window.removeEventListener("mousedown",s),window.removeEventListener("keydown",s),window.removeEventListener("change",s))},r.observers.set(t,new cS(t,o)),o}function nc(e,t){t===void 0&&(t=!1);var n=rc.get(e.object);oc(n.value,e.object,e.patches,"",t),e.patches.length&&Ni(n.value,e.patches);var o=e.patches;return o.length>0&&(e.patches=[],e.callback&&e.callback(o)),o}function oc(e,t,n,o,r){if(t!==e){typeof t.toJSON=="function"&&(t=t.toJSON());for(var i=Ii(t),a=Ii(e),s=!1,u=!1,l=a.length-1;l>=0;l--){var d=a[l],h=e[d];if(ki(t,d)&&!(t[d]===void 0&&h!==void 0&&Array.isArray(t)===!1)){var g=t[d];typeof h=="object"&&h!=null&&typeof g=="object"&&g!=null&&Array.isArray(h)===Array.isArray(g)?oc(h,g,n,o+"/"+mt(d),r):h!==g&&(s=!0,r&&n.push({op:"test",path:o+"/"+mt(d),value:$e(h)}),n.push({op:"replace",path:o+"/"+mt(d),value:$e(g)}))}else Array.isArray(e)===Array.isArray(t)?(r&&n.push({op:"test",path:o+"/"+mt(d),value:$e(h)}),n.push({op:"remove",path:o+"/"+mt(d)}),u=!0):(r&&n.push({op:"test",path:o,value:e}),n.push({op:"replace",path:o,value:t}),s=!0)}if(!(!u&&i.length==a.length))for(var l=0;l<i.length;l++){var d=i[l];!ki(e,d)&&t[d]!==void 0&&n.push({op:"add",path:o+"/"+mt(d),value:$e(t[d])})}}}function gS(e,t,n){n===void 0&&(n=!1);var o=[];return oc(e,t,o,"",n),o}var Oi=Object.assign({},tc,ic,{JsonPatchError:Nr,deepClone:$e,escapePathComponent:mt,unescapePathComponent:Cr});var ac=function(e,t){return ac=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(n[r]=o[r])},ac(e,t)};function gt(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");ac(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function qg(e,t,n,o){function r(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function s(d){try{l(o.next(d))}catch(h){a(h)}}function u(d){try{l(o.throw(d))}catch(h){a(h)}}function l(d){d.done?i(d.value):r(d.value).then(s,u)}l((o=o.apply(e,t||[])).next())})}function $i(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,r,i,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(l){return function(d){return u([l,d])}}function u(l){if(o)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(n=0)),n;)try{if(o=1,r&&(i=l[0]&2?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[l[0]&2,i.value]),l[0]){case 0:case 1:i=l;break;case 4:return n.label++,{value:l[1],done:!1};case 5:n.label++,r=l[1],l=[0];continue;case 7:l=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(l[0]===6||l[0]===2)){n=0;continue}if(l[0]===3&&(!i||l[1]>i[0]&&l[1]<i[3])){n.label=l[1];break}if(l[0]===6&&n.label<i[1]){n.label=i[1],i=l;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(l);break}i[2]&&n.ops.pop(),n.trys.pop();continue}l=t.call(e,n)}catch(d){l=[6,d],r=0}finally{o=i=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function St(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],o=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Gn(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var o=n.call(e),r,i=[],a;try{for(;(t===void 0||t-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(s){a={error:s}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i}function Fn(e,t,n){if(n||arguments.length===2)for(var o=0,r=t.length,i;o<r;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}function Qt(e){return this instanceof Qt?(this.v=e,this):new Qt(e)}function Xg(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=n.apply(e,t||[]),r,i=[];return r=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),s("next"),s("throw"),s("return",a),r[Symbol.asyncIterator]=function(){return this},r;function a(f){return function(p){return Promise.resolve(p).then(f,h)}}function s(f,p){o[f]&&(r[f]=function(b){return new Promise(function(v,_){i.push([f,b,v,_])>1||u(f,b)})},p&&(r[f]=p(r[f])))}function u(f,p){try{l(o[f](p))}catch(b){g(i[0][3],b)}}function l(f){f.value instanceof Qt?Promise.resolve(f.value.v).then(d,h):g(i[0][2],f)}function d(f){u("next",f)}function h(f){u("throw",f)}function g(f,p){f(p),i.shift(),i.length&&u(i[0][0],i[0][1])}}function Kg(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof St=="function"?St(e):e[Symbol.iterator](),n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n);function o(i){n[i]=e[i]&&function(a){return new Promise(function(s,u){a=e[i](a),r(s,u,a.done,a.value)})}}function r(i,a,s,u){Promise.resolve(u).then(function(l){i({value:l,done:s})},a)}}function K(e){return typeof e=="function"}function Vn(e){var t=function(o){Error.call(o),o.stack=new Error().stack},n=e(t);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var Pi=Vn(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
|
|
3
|
+
`+n.map(function(o,r){return r+1+") "+o.toString()}).join(`
|
|
4
|
+
`):"",this.name="UnsubscriptionError",this.errors=n}});function $r(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var Zn=(function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,n,o,r,i;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var s=St(a),u=s.next();!u.done;u=s.next()){var l=u.value;l.remove(this)}}catch(b){t={error:b}}finally{try{u&&!u.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}else a.remove(this);var d=this.initialTeardown;if(K(d))try{d()}catch(b){i=b instanceof Pi?b.errors:[b]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var g=St(h),f=g.next();!f.done;f=g.next()){var p=f.value;try{Yg(p)}catch(b){i=i??[],b instanceof Pi?i=Fn(Fn([],Gn(i)),Gn(b.errors)):i.push(b)}}}catch(b){o={error:b}}finally{try{f&&!f.done&&(r=g.return)&&r.call(g)}finally{if(o)throw o.error}}}if(i)throw new Pi(i)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)Yg(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(t)}},e.prototype._hasParent=function(t){var n=this._parentage;return n===t||Array.isArray(n)&&n.includes(t)},e.prototype._addParent=function(t){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(t),n):n?[n,t]:t},e.prototype._removeParent=function(t){var n=this._parentage;n===t?this._parentage=null:Array.isArray(n)&&$r(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&$r(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})();var sc=Zn.EMPTY;function Mi(e){return e instanceof Zn||e&&"closed"in e&&K(e.remove)&&K(e.add)&&K(e.unsubscribe)}function Yg(e){K(e)?e():e.unsubscribe()}var st={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var Bn={setTimeout:function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];var r=Bn.delegate;return r?.setTimeout?r.setTimeout.apply(r,Fn([e,t],Gn(n))):setTimeout.apply(void 0,Fn([e,t],Gn(n)))},clearTimeout:function(e){var t=Bn.delegate;return(t?.clearTimeout||clearTimeout)(e)},delegate:void 0};function Li(e){Bn.setTimeout(function(){var t=st.onUnhandledError;if(t)t(e);else throw e})}function Pr(){}var Jg=(function(){return lc("C",void 0,void 0)})();function Qg(e){return lc("E",void 0,e)}function ev(e){return lc("N",e,void 0)}function lc(e,t,n){return{kind:e,value:t,error:n}}var en=null;function Wn(e){if(st.useDeprecatedSynchronousErrorHandling){var t=!en;if(t&&(en={errorThrown:!1,error:null}),e(),t){var n=en,o=n.errorThrown,r=n.error;if(en=null,o)throw r}}else e()}function tv(e){st.useDeprecatedSynchronousErrorHandling&&en&&(en.errorThrown=!0,en.error=e)}var Mr=(function(e){gt(t,e);function t(n){var o=e.call(this)||this;return o.isStopped=!1,n?(o.destination=n,Mi(n)&&n.add(o)):o.destination=wS,o}return t.create=function(n,o,r){return new Di(n,o,r)},t.prototype.next=function(n){this.isStopped?cc(ev(n),this):this._next(n)},t.prototype.error=function(n){this.isStopped?cc(Qg(n),this):(this.isStopped=!0,this._error(n))},t.prototype.complete=function(){this.isStopped?cc(Jg,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(n){this.destination.next(n)},t.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(Zn);var vS=Function.prototype.bind;function uc(e,t){return vS.call(e,t)}var bS=(function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var n=this.partialObserver;if(n.next)try{n.next(t)}catch(o){zi(o)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(o){zi(o)}else zi(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){zi(n)}},e})(),Di=(function(e){gt(t,e);function t(n,o,r){var i=e.call(this)||this,a;if(K(n)||!n)a={next:n??void 0,error:o??void 0,complete:r??void 0};else{var s;i&&st.useDeprecatedNextContext?(s=Object.create(n),s.unsubscribe=function(){return i.unsubscribe()},a={next:n.next&&uc(n.next,s),error:n.error&&uc(n.error,s),complete:n.complete&&uc(n.complete,s)}):a=n}return i.destination=new bS(a),i}return t})(Mr);function zi(e){st.useDeprecatedSynchronousErrorHandling?tv(e):Li(e)}function yS(e){throw e}function cc(e,t){var n=st.onStoppedNotification;n&&Bn.setTimeout(function(){return n(e,t)})}var wS={closed:!0,next:Pr,error:yS,complete:Pr};var qn=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Xn(e){return e}function Ui(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return dc(e)}function dc(e){return e.length===0?Xn:e.length===1?e[0]:function(n){return e.reduce(function(o,r){return r(o)},n)}}var he=(function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(t,n,o){var r=this,i=_S(t)?t:new Di(t,n,o);return Wn(function(){var a=r,s=a.operator,u=a.source;i.add(s?s.call(i,u):u?r._subscribe(i):r._trySubscribe(i))}),i},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},e.prototype.forEach=function(t,n){var o=this;return n=nv(n),new n(function(r,i){var a=new Di({next:function(s){try{t(s)}catch(u){i(u),a.unsubscribe()}},error:i,complete:r});o.subscribe(a)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[qn]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return dc(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=nv(t),new t(function(o,r){var i;n.subscribe(function(a){return i=a},function(a){return r(a)},function(){return o(i)})})},e.create=function(t){return new e(t)},e})();function nv(e){var t;return(t=e??st.Promise)!==null&&t!==void 0?t:Promise}function xS(e){return e&&K(e.next)&&K(e.error)&&K(e.complete)}function _S(e){return e&&e instanceof Mr||xS(e)&&Mi(e)}function ES(e){return K(e?.lift)}function xe(e){return function(t){if(ES(t))return t.lift(function(n){try{return e(n,this)}catch(o){this.error(o)}});throw new TypeError("Unable to lift unknown Observable type")}}function Ee(e,t,n,o,r){return new SS(e,t,n,o,r)}var SS=(function(e){gt(t,e);function t(n,o,r,i,a,s){var u=e.call(this,n)||this;return u.onFinalize=a,u.shouldUnsubscribe=s,u._next=o?function(l){try{o(l)}catch(d){n.error(d)}}:e.prototype._next,u._error=i?function(l){try{i(l)}catch(d){n.error(d)}finally{this.unsubscribe()}}:e.prototype._error,u._complete=r?function(){try{r()}catch(l){n.error(l)}finally{this.unsubscribe()}}:e.prototype._complete,u}return t.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var o=this.closed;e.prototype.unsubscribe.call(this),!o&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},t})(Mr);var rv=Vn(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}});var vt=(function(e){gt(t,e);function t(){var n=e.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return t.prototype.lift=function(n){var o=new ov(this,this);return o.operator=n,o},t.prototype._throwIfClosed=function(){if(this.closed)throw new rv},t.prototype.next=function(n){var o=this;Wn(function(){var r,i;if(o._throwIfClosed(),!o.isStopped){o.currentObservers||(o.currentObservers=Array.from(o.observers));try{for(var a=St(o.currentObservers),s=a.next();!s.done;s=a.next()){var u=s.value;u.next(n)}}catch(l){r={error:l}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}}})},t.prototype.error=function(n){var o=this;Wn(function(){if(o._throwIfClosed(),!o.isStopped){o.hasError=o.isStopped=!0,o.thrownError=n;for(var r=o.observers;r.length;)r.shift().error(n)}})},t.prototype.complete=function(){var n=this;Wn(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var o=n.observers;o.length;)o.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(n){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,n)},t.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},t.prototype._innerSubscribe=function(n){var o=this,r=this,i=r.hasError,a=r.isStopped,s=r.observers;return i||a?sc:(this.currentObservers=null,s.push(n),new Zn(function(){o.currentObservers=null,$r(s,n)}))},t.prototype._checkFinalizedStatuses=function(n){var o=this,r=o.hasError,i=o.thrownError,a=o.isStopped;r?n.error(i):a&&n.complete()},t.prototype.asObservable=function(){var n=new he;return n.source=this,n},t.create=function(n,o){return new ov(n,o)},t})(he);var ov=(function(e){gt(t,e);function t(n,o){var r=e.call(this)||this;return r.destination=n,r.source=o,r}return t.prototype.next=function(n){var o,r;(r=(o=this.destination)===null||o===void 0?void 0:o.next)===null||r===void 0||r.call(o,n)},t.prototype.error=function(n){var o,r;(r=(o=this.destination)===null||o===void 0?void 0:o.error)===null||r===void 0||r.call(o,n)},t.prototype.complete=function(){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||o===void 0||o.call(n)},t.prototype._subscribe=function(n){var o,r;return(r=(o=this.source)===null||o===void 0?void 0:o.subscribe(n))!==null&&r!==void 0?r:sc},t})(vt);var pc={now:function(){return(pc.delegate||Date).now()},delegate:void 0};var ji=(function(e){gt(t,e);function t(n,o,r){n===void 0&&(n=1/0),o===void 0&&(o=1/0),r===void 0&&(r=pc);var i=e.call(this)||this;return i._bufferSize=n,i._windowTime=o,i._timestampProvider=r,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=o===1/0,i._bufferSize=Math.max(1,n),i._windowTime=Math.max(1,o),i}return t.prototype.next=function(n){var o=this,r=o.isStopped,i=o._buffer,a=o._infiniteTimeWindow,s=o._timestampProvider,u=o._windowTime;r||(i.push(n),!a&&i.push(s.now()+u)),this._trimBuffer(),e.prototype.next.call(this,n)},t.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var o=this._innerSubscribe(n),r=this,i=r._infiniteTimeWindow,a=r._buffer,s=a.slice(),u=0;u<s.length&&!n.closed;u+=i?1:2)n.next(s[u]);return this._checkFinalizedStatuses(n),o},t.prototype._trimBuffer=function(){var n=this,o=n._bufferSize,r=n._timestampProvider,i=n._buffer,a=n._infiniteTimeWindow,s=(a?1:2)*o;if(o<1/0&&s<i.length&&i.splice(0,i.length-s),!a){for(var u=r.now(),l=0,d=1;d<i.length&&i[d]<=u;d+=2)l=d;l&&i.splice(0,l+1)}},t})(vt);var Lr=new he(function(e){return e.complete()});function iv(e){return e&&K(e.schedule)}function TS(e){return e[e.length-1]}function av(e){return iv(TS(e))?e.pop():void 0}var Hi=(function(e){return e&&typeof e.length=="number"&&typeof e!="function"});function Gi(e){return K(e?.then)}function Fi(e){return K(e[qn])}function Vi(e){return Symbol.asyncIterator&&K(e?.[Symbol.asyncIterator])}function Zi(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function kS(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Bi=kS();function Wi(e){return K(e?.[Bi])}function qi(e){return Xg(this,arguments,function(){var n,o,r,i;return $i(this,function(a){switch(a.label){case 0:n=e.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,Qt(n.read())];case 3:return o=a.sent(),r=o.value,i=o.done,i?[4,Qt(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,Qt(r)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function Xi(e){return K(e?.getReader)}function Re(e){if(e instanceof he)return e;if(e!=null){if(Fi(e))return IS(e);if(Hi(e))return AS(e);if(Gi(e))return RS(e);if(Vi(e))return sv(e);if(Wi(e))return CS(e);if(Xi(e))return NS(e)}throw Zi(e)}function IS(e){return new he(function(t){var n=e[qn]();if(K(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function AS(e){return new he(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function RS(e){return new he(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,Li)})}function CS(e){return new he(function(t){var n,o;try{for(var r=St(e),i=r.next();!i.done;i=r.next()){var a=i.value;if(t.next(a),t.closed)return}}catch(s){n={error:s}}finally{try{i&&!i.done&&(o=r.return)&&o.call(r)}finally{if(n)throw n.error}}t.complete()})}function sv(e){return new he(function(t){OS(e,t).catch(function(n){return t.error(n)})})}function NS(e){return sv(qi(e))}function OS(e,t){var n,o,r,i;return qg(this,void 0,void 0,function(){var a,s;return $i(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=Kg(e),u.label=1;case 1:return[4,n.next()];case 2:if(o=u.sent(),!!o.done)return[3,4];if(a=o.value,t.next(a),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return s=u.sent(),r={error:s},[3,11];case 6:return u.trys.push([6,,9,10]),o&&!o.done&&(i=n.return)?[4,i.call(n)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(r)throw r.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function nt(e,t,n,o,r){o===void 0&&(o=0),r===void 0&&(r=!1);var i=t.schedule(function(){n(),r?e.add(this.schedule(null,o)):this.unsubscribe()},o);if(e.add(i),!r)return i}function Ki(e,t){return t===void 0&&(t=0),xe(function(n,o){n.subscribe(Ee(o,function(r){return nt(o,e,function(){return o.next(r)},t)},function(){return nt(o,e,function(){return o.complete()},t)},function(r){return nt(o,e,function(){return o.error(r)},t)}))})}function Yi(e,t){return t===void 0&&(t=0),xe(function(n,o){o.add(e.schedule(function(){return n.subscribe(o)},t))})}function lv(e,t){return Re(e).pipe(Yi(t),Ki(t))}function uv(e,t){return Re(e).pipe(Yi(t),Ki(t))}function cv(e,t){return new he(function(n){var o=0;return t.schedule(function(){o===e.length?n.complete():(n.next(e[o++]),n.closed||this.schedule())})})}function dv(e,t){return new he(function(n){var o;return nt(n,t,function(){o=e[Bi](),nt(n,t,function(){var r,i,a;try{r=o.next(),i=r.value,a=r.done}catch(s){n.error(s);return}a?n.complete():n.next(i)},0,!0)}),function(){return K(o?.return)&&o.return()}})}function Ji(e,t){if(!e)throw new Error("Iterable cannot be null");return new he(function(n){nt(n,t,function(){var o=e[Symbol.asyncIterator]();nt(n,t,function(){o.next().then(function(r){r.done?n.complete():n.next(r.value)})},0,!0)})})}function pv(e,t){return Ji(qi(e),t)}function hv(e,t){if(e!=null){if(Fi(e))return lv(e,t);if(Hi(e))return cv(e,t);if(Gi(e))return uv(e,t);if(Vi(e))return Ji(e,t);if(Wi(e))return dv(e,t);if(Xi(e))return pv(e,t)}throw Zi(e)}function tn(e,t){return t?hv(e,t):Re(e)}function ie(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=av(e);return tn(e,n)}function F(e,t){var n=K(e)?e:function(){return e},o=function(r){return r.error(n())};return new he(t?function(r){return t.schedule(o,0,r)}:o)}var fv=Vn(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function Qi(e,t){var n=typeof t=="object";return new Promise(function(o,r){var i=!1,a;e.subscribe({next:function(s){a=s,i=!0},error:r,complete:function(){i?o(a):n?o(t.defaultValue):r(new fv)}})})}function bt(e,t){return xe(function(n,o){var r=0;n.subscribe(Ee(o,function(i){o.next(e.call(t,i,r++))}))})}function mv(e,t,n,o,r,i,a,s){var u=[],l=0,d=0,h=!1,g=function(){h&&!u.length&&!l&&t.complete()},f=function(b){return l<o?p(b):u.push(b)},p=function(b){i&&t.next(b),l++;var v=!1;Re(n(b,d++)).subscribe(Ee(t,function(_){r?.(_),i?f(_):t.next(_)},function(){v=!0},void 0,function(){if(v)try{l--;for(var _=function(){var y=u.shift();a?nt(t,a,function(){return p(y)}):p(y)};u.length&&l<o;)_();g()}catch(y){t.error(y)}}))};return e.subscribe(Ee(t,f,function(){h=!0,g()})),function(){s?.()}}function je(e,t,n){return n===void 0&&(n=1/0),K(t)?je(function(o,r){return bt(function(i,a){return t(o,i,r,a)})(Re(e(o,r)))},n):(typeof t=="number"&&(n=t),xe(function(o,r){return mv(o,r,e,n)}))}function hc(e){return e===void 0&&(e=1/0),je(Xn,e)}function zr(e){return new he(function(t){Re(e()).subscribe(t)})}function fc(e,t){return xe(function(n,o){var r=0;n.subscribe(Ee(o,function(i){return e.call(t,i,r++)&&o.next(i)}))})}function Dr(e){return xe(function(t,n){var o=null,r=!1,i;o=t.subscribe(Ee(n,void 0,void 0,function(a){i=Re(e(a,Dr(e)(t))),o?(o.unsubscribe(),o=null,i.subscribe(n)):r=!0})),r&&(o.unsubscribe(),o=null,i.subscribe(n))})}function ea(e,t){return K(t)?je(e,t,1):je(e,1)}function mc(e){return xe(function(t,n){var o=!1;t.subscribe(Ee(n,function(r){o=!0,n.next(r)},function(){o||n.next(e),n.complete()}))})}function nn(e){return xe(function(t,n){try{t.subscribe(n)}finally{n.add(e)}})}function gc(e,t){return xe(function(n,o){var r=null,i=0,a=!1,s=function(){return a&&!r&&o.complete()};n.subscribe(Ee(o,function(u){r?.unsubscribe();var l=0,d=i++;Re(e(u,d)).subscribe(r=Ee(o,function(h){return o.next(t?t(u,h,d,l++):h)},function(){r=null,s()}))},function(){a=!0,s()}))})}function ta(e){return xe(function(t,n){Re(e).subscribe(Ee(n,function(){return n.complete()},Pr)),!n.closed&&t.subscribe(n)})}function na(e,t,n){var o=K(e)||t||n?{next:e,error:t,complete:n}:e;return o?xe(function(r,i){var a;(a=o.subscribe)===null||a===void 0||a.call(o);var s=!0;r.subscribe(Ee(i,function(u){var l;(l=o.next)===null||l===void 0||l.call(o,u),i.next(u)},function(){var u;s=!1,(u=o.complete)===null||u===void 0||u.call(o),i.complete()},function(u){var l;s=!1,(l=o.error)===null||l===void 0||l.call(o,u),i.error(u)},function(){var u,l;s&&((u=o.unsubscribe)===null||u===void 0||u.call(o)),(l=o.finalize)===null||l===void 0||l.call(o)}))}):Xn}function gv(e){return` \r
|
|
5
|
+
`.indexOf(e)>=0}function ra(e){for(var t=["topLevel"],n=0,o,r,i,a=function(y){return t.push(y)},s=function(y){return t[t.length-1]=y},u=function(y){o==null&&(o=n,r=t.length,i=y)},l=function(y){y===i&&(o=void 0,r=void 0,i=void 0)},d=function(){return t.pop()},h=function(){return n--},g=function(y){if("0"<=y&&y<="9"){a("number");return}switch(y){case'"':a("string");return;case"-":a("numberNeedsDigit");return;case"t":a("true");return;case"f":a("false");return;case"n":a("null");return;case"[":a("arrayNeedsValue");return;case"{":a("objectNeedsKey");return}},f=e.length;n<f;n++){var p=e[n];switch(t[t.length-1]){case"topLevel":g(p);break;case"string":switch(p){case'"':d();break;case"\\":u("stringEscape"),a("stringEscaped");break}break;case"stringEscaped":p==="u"?a("stringUnicode"):(l("stringEscape"),d());break;case"stringUnicode":n-e.lastIndexOf("u",n)===4&&(l("stringEscape"),d());break;case"number":p==="."?s("numberNeedsDigit"):p==="e"||p==="E"?s("numberNeedsExponent"):(p<"0"||p>"9")&&(h(),d());break;case"numberNeedsDigit":s("number");break;case"numberNeedsExponent":s(p==="+"||p==="-"?"numberNeedsDigit":"number");break;case"true":case"false":case"null":(p<"a"||p>"z")&&(h(),d());break;case"arrayNeedsValue":p==="]"?d():gv(p)||(l("collectionItem"),s("arrayNeedsComma"),g(p));break;case"arrayNeedsComma":p==="]"?d():p===","&&(u("collectionItem"),s("arrayNeedsValue"));break;case"objectNeedsKey":p==="}"?d():p==='"'&&(u("collectionItem"),s("objectNeedsColon"),a("string"));break;case"objectNeedsColon":p===":"&&s("objectNeedsValue");break;case"objectNeedsValue":gv(p)||(l("collectionItem"),s("objectNeedsComma"),g(p));break;case"objectNeedsComma":p==="}"?d():p===","&&(u("collectionItem"),s("objectNeedsKey"));break}}r!=null&&(t.length=r);for(var b=[o!=null?e.slice(0,o):e],v=function(y){return b.push(y.slice(e.length-e.lastIndexOf(y[0])))},_=t.length-1;_>=0;_--)switch(t[_]){case"string":b.push('"');break;case"numberNeedsDigit":case"numberNeedsExponent":b.push("0");break;case"true":v("true");break;case"false":v("false");break;case"null":v("null");break;case"arrayNeedsValue":case"arrayNeedsComma":b.push("]");break;case"objectNeedsKey":case"objectNeedsColon":case"objectNeedsValue":case"objectNeedsComma":b.push("}");break}return b.join("")}var c={};_t(c,{$brand:()=>bc,$input:()=>Op,$output:()=>Np,NEVER:()=>vc,TimePrecision:()=>Mp,ZodAny:()=>Mb,ZodArray:()=>Ub,ZodBase64:()=>Zh,ZodBase64URL:()=>Bh,ZodBigInt:()=>_o,ZodBigIntFormat:()=>Xh,ZodBoolean:()=>xo,ZodCIDRv4:()=>Fh,ZodCIDRv6:()=>Vh,ZodCUID:()=>Lh,ZodCUID2:()=>zh,ZodCatch:()=>oy,ZodCustom:()=>rs,ZodCustomStringFormat:()=>Ab,ZodDate:()=>es,ZodDefault:()=>Jb,ZodDiscriminatedUnion:()=>jb,ZodE164:()=>Wh,ZodEmail:()=>Oh,ZodEmoji:()=>Ph,ZodEnum:()=>bo,ZodError:()=>vT,ZodFile:()=>Kb,ZodGUID:()=>qa,ZodIPv4:()=>Hh,ZodIPv6:()=>Gh,ZodISODate:()=>Va,ZodISODateTime:()=>Fa,ZodISODuration:()=>Ba,ZodISOTime:()=>Za,ZodIntersection:()=>Hb,ZodIssueCode:()=>xk,ZodJWT:()=>qh,ZodKSUID:()=>jh,ZodLazy:()=>cy,ZodLiteral:()=>qb,ZodMap:()=>Zb,ZodNaN:()=>ay,ZodNanoID:()=>Mh,ZodNever:()=>zb,ZodNonOptional:()=>nf,ZodNull:()=>$b,ZodNullable:()=>Yb,ZodNumber:()=>wo,ZodNumberFormat:()=>sr,ZodObject:()=>ts,ZodOptional:()=>tf,ZodPipe:()=>rf,ZodPrefault:()=>ey,ZodPromise:()=>py,ZodReadonly:()=>sy,ZodRealError:()=>ar,ZodRecord:()=>Jh,ZodSet:()=>Bb,ZodString:()=>yo,ZodStringFormat:()=>ce,ZodSuccess:()=>ry,ZodSymbol:()=>Nb,ZodTemplateLiteral:()=>uy,ZodTransform:()=>Qh,ZodTuple:()=>Fb,ZodType:()=>X,ZodULID:()=>Dh,ZodURL:()=>$h,ZodUUID:()=>Ct,ZodUndefined:()=>Ob,ZodUnion:()=>Yh,ZodUnknown:()=>Lb,ZodVoid:()=>Db,ZodXID:()=>Uh,_ZodString:()=>Nh,_default:()=>Qb,any:()=>YT,array:()=>Kh,base64:()=>zT,base64url:()=>DT,bigint:()=>BT,boolean:()=>Cb,catch:()=>iy,check:()=>hy,cidrv4:()=>MT,cidrv6:()=>LT,clone:()=>We,coerce:()=>of,config:()=>Se,core:()=>Rt,cuid:()=>AT,cuid2:()=>RT,custom:()=>gk,date:()=>QT,discriminatedUnion:()=>ok,e164:()=>UT,email:()=>yT,emoji:()=>kT,endsWith:()=>uo,enum:()=>Wb,file:()=>ck,flattenError:()=>qr,float32:()=>GT,float64:()=>FT,formatError:()=>Xr,function:()=>yh,getErrorMap:()=>Ek,globalRegistry:()=>wt,gt:()=>It,gte:()=>Ve,guid:()=>wT,includes:()=>so,instanceof:()=>vk,int:()=>Ch,int32:()=>VT,int64:()=>WT,intersection:()=>Gb,ipv4:()=>$T,ipv6:()=>PT,iso:()=>Wa,json:()=>yk,jwt:()=>jT,keyof:()=>ek,ksuid:()=>OT,lazy:()=>dy,length:()=>ir,literal:()=>Xb,locales:()=>to,looseObject:()=>rk,lowercase:()=>io,lt:()=>kt,lte:()=>rt,map:()=>sk,maxLength:()=>or,maxSize:()=>rr,mime:()=>co,minLength:()=>zt,minSize:()=>dn,multipleOf:()=>cn,nan:()=>hk,nanoid:()=>IT,nativeEnum:()=>uk,negative:()=>uh,never:()=>Qa,nonnegative:()=>dh,nonoptional:()=>ny,nonpositive:()=>ch,normalize:()=>po,null:()=>Pb,nullable:()=>Ya,nullish:()=>dk,number:()=>Rb,object:()=>tk,optional:()=>Ka,overwrite:()=>At,parse:()=>Th,parseAsync:()=>kh,partialRecord:()=>ak,pipe:()=>Ja,positive:()=>lh,prefault:()=>ty,preprocess:()=>wk,prettifyError:()=>Nc,promise:()=>mk,property:()=>ph,readonly:()=>ly,record:()=>Vb,refine:()=>fy,regex:()=>oo,regexes:()=>sn,registry:()=>wa,safeParse:()=>Ih,safeParseAsync:()=>Ah,set:()=>lk,setErrorMap:()=>_k,size:()=>ro,startsWith:()=>lo,strictObject:()=>nk,string:()=>Rh,stringFormat:()=>HT,stringbool:()=>bk,success:()=>pk,superRefine:()=>my,symbol:()=>XT,templateLiteral:()=>fk,toJSONSchema:()=>wh,toLowerCase:()=>fo,toUpperCase:()=>mo,transform:()=>ef,treeifyError:()=>Cc,trim:()=>ho,tuple:()=>ik,uint32:()=>ZT,uint64:()=>qT,ulid:()=>CT,undefined:()=>KT,union:()=>ns,unknown:()=>Xa,uppercase:()=>ao,url:()=>TT,uuid:()=>xT,uuidv4:()=>_T,uuidv6:()=>ET,uuidv7:()=>ST,void:()=>JT,xid:()=>NT});var Rt={};_t(Rt,{$ZodAny:()=>ip,$ZodArray:()=>Jr,$ZodAsyncError:()=>yt,$ZodBase64:()=>Xd,$ZodBase64URL:()=>Kd,$ZodBigInt:()=>va,$ZodBigIntFormat:()=>tp,$ZodBoolean:()=>Yr,$ZodCIDRv4:()=>Bd,$ZodCIDRv6:()=>Wd,$ZodCUID:()=>Md,$ZodCUID2:()=>Ld,$ZodCatch:()=>Sp,$ZodCheck:()=>ye,$ZodCheckBigIntFormat:()=>dd,$ZodCheckEndsWith:()=>Ed,$ZodCheckGreaterThan:()=>ha,$ZodCheckIncludes:()=>xd,$ZodCheckLengthEquals:()=>vd,$ZodCheckLessThan:()=>pa,$ZodCheckLowerCase:()=>yd,$ZodCheckMaxLength:()=>md,$ZodCheckMaxSize:()=>pd,$ZodCheckMimeType:()=>Td,$ZodCheckMinLength:()=>gd,$ZodCheckMinSize:()=>hd,$ZodCheckMultipleOf:()=>ud,$ZodCheckNumberFormat:()=>cd,$ZodCheckOverwrite:()=>kd,$ZodCheckProperty:()=>Sd,$ZodCheckRegex:()=>bd,$ZodCheckSizeEquals:()=>fd,$ZodCheckStartsWith:()=>_d,$ZodCheckStringFormat:()=>Qn,$ZodCheckUpperCase:()=>wd,$ZodCustom:()=>Cp,$ZodCustomStringFormat:()=>Qd,$ZodDate:()=>lp,$ZodDefault:()=>wp,$ZodDiscriminatedUnion:()=>cp,$ZodE164:()=>Yd,$ZodEmail:()=>Nd,$ZodEmoji:()=>$d,$ZodEnum:()=>mp,$ZodError:()=>Wr,$ZodFile:()=>vp,$ZodFunction:()=>Ga,$ZodGUID:()=>Rd,$ZodIPv4:()=>Vd,$ZodIPv6:()=>Zd,$ZodISODate:()=>Hd,$ZodISODateTime:()=>jd,$ZodISODuration:()=>Fd,$ZodISOTime:()=>Gd,$ZodIntersection:()=>dp,$ZodJWT:()=>Jd,$ZodKSUID:()=>Ud,$ZodLazy:()=>Rp,$ZodLiteral:()=>gp,$ZodMap:()=>hp,$ZodNaN:()=>Tp,$ZodNanoID:()=>Pd,$ZodNever:()=>ap,$ZodNonOptional:()=>_p,$ZodNull:()=>op,$ZodNullable:()=>yp,$ZodNumber:()=>ga,$ZodNumberFormat:()=>ep,$ZodObject:()=>up,$ZodOptional:()=>bp,$ZodPipe:()=>eo,$ZodPrefault:()=>xp,$ZodPromise:()=>Ap,$ZodReadonly:()=>kp,$ZodRealError:()=>Jn,$ZodRecord:()=>pp,$ZodRegistry:()=>tr,$ZodSet:()=>fp,$ZodString:()=>ln,$ZodStringFormat:()=>se,$ZodSuccess:()=>Ep,$ZodSymbol:()=>np,$ZodTemplateLiteral:()=>Ip,$ZodTransform:()=>Qr,$ZodTuple:()=>un,$ZodType:()=>Z,$ZodULID:()=>zd,$ZodURL:()=>Od,$ZodUUID:()=>Cd,$ZodUndefined:()=>rp,$ZodUnion:()=>ba,$ZodUnknown:()=>er,$ZodVoid:()=>sp,$ZodXID:()=>Dd,$brand:()=>bc,$constructor:()=>T,$input:()=>Op,$output:()=>Np,Doc:()=>Kr,JSONSchema:()=>Tb,JSONSchemaGenerator:()=>vo,NEVER:()=>vc,TimePrecision:()=>Mp,_any:()=>nh,_array:()=>go,_base64:()=>Da,_base64url:()=>Ua,_bigint:()=>Xp,_boolean:()=>Wp,_catch:()=>cT,_cidrv4:()=>La,_cidrv6:()=>za,_coercedBigint:()=>Kp,_coercedBoolean:()=>qp,_coercedDate:()=>ah,_coercedNumber:()=>Hp,_coercedString:()=>Pp,_cuid:()=>Ra,_cuid2:()=>Ca,_custom:()=>mh,_date:()=>ih,_default:()=>sT,_discriminatedUnion:()=>K0,_e164:()=>ja,_email:()=>xa,_emoji:()=>Ia,_endsWith:()=>uo,_enum:()=>tT,_file:()=>fh,_float32:()=>Fp,_float64:()=>Vp,_gt:()=>It,_gte:()=>Ve,_guid:()=>no,_includes:()=>so,_int:()=>Gp,_int32:()=>Zp,_int64:()=>Yp,_intersection:()=>Y0,_ipv4:()=>Pa,_ipv6:()=>Ma,_isoDate:()=>zp,_isoDateTime:()=>Lp,_isoDuration:()=>Up,_isoTime:()=>Dp,_jwt:()=>Ha,_ksuid:()=>$a,_lazy:()=>fT,_length:()=>ir,_literal:()=>rT,_lowercase:()=>io,_lt:()=>kt,_lte:()=>rt,_map:()=>Q0,_max:()=>rt,_maxLength:()=>or,_maxSize:()=>rr,_mime:()=>co,_min:()=>Ve,_minLength:()=>zt,_minSize:()=>dn,_multipleOf:()=>cn,_nan:()=>sh,_nanoid:()=>Aa,_nativeEnum:()=>nT,_negative:()=>uh,_never:()=>rh,_nonnegative:()=>dh,_nonoptional:()=>lT,_nonpositive:()=>ch,_normalize:()=>po,_null:()=>th,_nullable:()=>aT,_number:()=>jp,_optional:()=>iT,_overwrite:()=>At,_parse:()=>ia,_parseAsync:()=>sa,_pipe:()=>dT,_positive:()=>lh,_promise:()=>mT,_property:()=>ph,_readonly:()=>pT,_record:()=>J0,_refine:()=>gh,_regex:()=>oo,_safeParse:()=>ua,_safeParseAsync:()=>ca,_set:()=>eT,_size:()=>ro,_startsWith:()=>lo,_string:()=>$p,_stringFormat:()=>bh,_stringbool:()=>vh,_success:()=>uT,_symbol:()=>Qp,_templateLiteral:()=>hT,_toLowerCase:()=>fo,_toUpperCase:()=>mo,_transform:()=>oT,_trim:()=>ho,_tuple:()=>hh,_uint32:()=>Bp,_uint64:()=>Jp,_ulid:()=>Na,_undefined:()=>eh,_union:()=>X0,_unknown:()=>nr,_uppercase:()=>ao,_url:()=>ka,_uuid:()=>_a,_uuidv4:()=>Ea,_uuidv6:()=>Sa,_uuidv7:()=>Ta,_void:()=>oh,_xid:()=>Oa,clone:()=>We,config:()=>Se,flattenError:()=>qr,formatError:()=>Xr,function:()=>yh,globalConfig:()=>Ur,globalRegistry:()=>wt,isValidBase64:()=>qd,isValidBase64URL:()=>Lv,isValidJWT:()=>zv,locales:()=>to,parse:()=>aa,parseAsync:()=>la,prettifyError:()=>Nc,regexes:()=>sn,registry:()=>wa,safeParse:()=>Oc,safeParseAsync:()=>$c,toDotPath:()=>bv,toJSONSchema:()=>wh,treeifyError:()=>Cc,util:()=>D,version:()=>Id});var vc=Object.freeze({status:"aborted"});function T(e,t,n){function o(s,u){var l;Object.defineProperty(s,"_zod",{value:s._zod??{},enumerable:!1}),(l=s._zod).traits??(l.traits=new Set),s._zod.traits.add(e),t(s,u);for(let d in a.prototype)d in s||Object.defineProperty(s,d,{value:a.prototype[d].bind(s)});s._zod.constr=a,s._zod.def=u}let r=n?.Parent??Object;class i extends r{}Object.defineProperty(i,"name",{value:e});function a(s){var u;let l=n?.Parent?new i:this;o(l,s),(u=l._zod).deferred??(u.deferred=[]);for(let d of l._zod.deferred)d();return l}return Object.defineProperty(a,"init",{value:o}),Object.defineProperty(a,Symbol.hasInstance,{value:s=>n?.Parent&&s instanceof n.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}var bc=Symbol("zod_brand"),yt=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Ur={};function Se(e){return e&&Object.assign(Ur,e),Ur}var D={};_t(D,{BIGINT_FORMAT_RANGES:()=>Ac,Class:()=>wc,NUMBER_FORMAT_RANGES:()=>Ic,aborted:()=>on,allowsEval:()=>Sc,assert:()=>zS,assertEqual:()=>$S,assertIs:()=>MS,assertNever:()=>LS,assertNotEqual:()=>PS,assignProp:()=>Ec,cached:()=>Gr,captureStackTrace:()=>oa,cleanEnum:()=>KS,cleanRegex:()=>Fr,clone:()=>We,createTransparentProxy:()=>FS,defineLazy:()=>oe,esc:()=>rn,escapeRegex:()=>Tt,extend:()=>BS,finalizeIssue:()=>qe,floatSafeRemainder:()=>_c,getElementAtPath:()=>DS,getEnumValues:()=>Hr,getLengthableOrigin:()=>Br,getParsedType:()=>GS,getSizableOrigin:()=>Zr,isObject:()=>Kn,isPlainObject:()=>Yn,issue:()=>Rc,joinValues:()=>R,jsonStringifyReplacer:()=>xc,merge:()=>WS,normalizeParams:()=>P,nullish:()=>Lt,numKeys:()=>HS,omit:()=>ZS,optionalKeys:()=>kc,partial:()=>qS,pick:()=>VS,prefixIssues:()=>Fe,primitiveTypes:()=>Tc,promiseAllObject:()=>US,propertyKeyTypes:()=>Vr,randomString:()=>jS,required:()=>XS,stringifyPrimitive:()=>z,unwrapMessage:()=>jr});function $S(e){return e}function PS(e){return e}function MS(e){}function LS(e){throw new Error}function zS(e){}function Hr(e){let t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,r])=>t.indexOf(+o)===-1).map(([o,r])=>r)}function R(e,t="|"){return e.map(n=>z(n)).join(t)}function xc(e,t){return typeof t=="bigint"?t.toString():t}function Gr(e){return{get value(){{let n=e();return Object.defineProperty(this,"value",{value:n}),n}throw new Error("cached value already set")}}}function Lt(e){return e==null}function Fr(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function _c(e,t){let n=(e.toString().split(".")[1]||"").length,o=(t.toString().split(".")[1]||"").length,r=n>o?n:o,i=Number.parseInt(e.toFixed(r).replace(".","")),a=Number.parseInt(t.toFixed(r).replace(".",""));return i%a/10**r}function oe(e,t,n){Object.defineProperty(e,t,{get(){{let r=n();return e[t]=r,r}throw new Error("cached value already set")},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function Ec(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function DS(e,t){return t?t.reduce((n,o)=>n?.[o],e):e}function US(e){let t=Object.keys(e),n=t.map(o=>e[o]);return Promise.all(n).then(o=>{let r={};for(let i=0;i<t.length;i++)r[t[i]]=o[i];return r})}function jS(e=10){let t="abcdefghijklmnopqrstuvwxyz",n="";for(let o=0;o<e;o++)n+=t[Math.floor(Math.random()*t.length)];return n}function rn(e){return JSON.stringify(e)}var oa=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function Kn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Sc=Gr(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Yn(e){if(Kn(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(Kn(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function HS(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}var GS=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},Vr=new Set(["string","number","symbol"]),Tc=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Tt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function We(e,t,n){let o=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(o._zod.parent=e),o}function P(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(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 FS(e){let t;return new Proxy({},{get(n,o,r){return t??(t=e()),Reflect.get(t,o,r)},set(n,o,r,i){return t??(t=e()),Reflect.set(t,o,r,i)},has(n,o){return t??(t=e()),Reflect.has(t,o)},deleteProperty(n,o){return t??(t=e()),Reflect.deleteProperty(t,o)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,o){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,o)},defineProperty(n,o,r){return t??(t=e()),Reflect.defineProperty(t,o,r)}})}function z(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function kc(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Ic={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]},Ac={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function VS(e,t){let n={},o=e._zod.def;for(let r in t){if(!(r in o.shape))throw new Error(`Unrecognized key: "${r}"`);t[r]&&(n[r]=o.shape[r])}return We(e,{...e._zod.def,shape:n,checks:[]})}function ZS(e,t){let n={...e._zod.def.shape},o=e._zod.def;for(let r in t){if(!(r in o.shape))throw new Error(`Unrecognized key: "${r}"`);t[r]&&delete n[r]}return We(e,{...e._zod.def,shape:n,checks:[]})}function BS(e,t){if(!Yn(t))throw new Error("Invalid input to extend: expected a plain object");let n={...e._zod.def,get shape(){let o={...e._zod.def.shape,...t};return Ec(this,"shape",o),o},checks:[]};return We(e,n)}function WS(e,t){return We(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Ec(this,"shape",n),n},catchall:t._zod.def.catchall,checks:[]})}function qS(e,t,n){let o=t._zod.def.shape,r={...o};if(n)for(let i in n){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(r[i]=e?new e({type:"optional",innerType:o[i]}):o[i])}else for(let i in o)r[i]=e?new e({type:"optional",innerType:o[i]}):o[i];return We(t,{...t._zod.def,shape:r,checks:[]})}function XS(e,t,n){let o=t._zod.def.shape,r={...o};if(n)for(let i in n){if(!(i in r))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(r[i]=new e({type:"nonoptional",innerType:o[i]}))}else for(let i in o)r[i]=new e({type:"nonoptional",innerType:o[i]});return We(t,{...t._zod.def,shape:r,checks:[]})}function on(e,t=0){for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Fe(e,t){return t.map(n=>{var o;return(o=n).path??(o.path=[]),n.path.unshift(e),n})}function jr(e){return typeof e=="string"?e:e?.message}function qe(e,t,n){let o={...e,path:e.path??[]};if(!e.message){let r=jr(e.inst?._zod.def?.error?.(e))??jr(t?.error?.(e))??jr(n.customError?.(e))??jr(n.localeError?.(e))??"Invalid input";o.message=r}return delete o.inst,delete o.continue,t?.reportInput||delete o.input,o}function Zr(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Br(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Rc(...e){let[t,n,o]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:o}:{...t}}function KS(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}var wc=class{constructor(...t){}};var vv=(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,xc,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Wr=T("$ZodError",vv),Jn=T("$ZodError",vv,{Parent:Error});function qr(e,t=n=>n.message){let n={},o=[];for(let r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):o.push(t(r));return{formErrors:o,fieldErrors:n}}function Xr(e,t){let n=t||function(i){return i.message},o={_errors:[]},r=i=>{for(let a of i.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(s=>r({issues:s}));else if(a.code==="invalid_key")r({issues:a.issues});else if(a.code==="invalid_element")r({issues:a.issues});else if(a.path.length===0)o._errors.push(n(a));else{let s=o,u=0;for(;u<a.path.length;){let l=a.path[u];u===a.path.length-1?(s[l]=s[l]||{_errors:[]},s[l]._errors.push(n(a))):s[l]=s[l]||{_errors:[]},s=s[l],u++}}};return r(e),o}function Cc(e,t){let n=t||function(i){return i.message},o={errors:[]},r=(i,a=[])=>{var s,u;for(let l of i.issues)if(l.code==="invalid_union"&&l.errors.length)l.errors.map(d=>r({issues:d},l.path));else if(l.code==="invalid_key")r({issues:l.issues},l.path);else if(l.code==="invalid_element")r({issues:l.issues},l.path);else{let d=[...a,...l.path];if(d.length===0){o.errors.push(n(l));continue}let h=o,g=0;for(;g<d.length;){let f=d[g],p=g===d.length-1;typeof f=="string"?(h.properties??(h.properties={}),(s=h.properties)[f]??(s[f]={errors:[]}),h=h.properties[f]):(h.items??(h.items=[]),(u=h.items)[f]??(u[f]={errors:[]}),h=h.items[f]),p&&h.errors.push(n(l)),g++}}};return r(e),o}function bv(e){let t=[];for(let n of e)typeof n=="number"?t.push(`[${n}]`):typeof n=="symbol"?t.push(`[${JSON.stringify(String(n))}]`):/[^\w$]/.test(n)?t.push(`[${JSON.stringify(n)}]`):(t.length&&t.push("."),t.push(n));return t.join("")}function Nc(e){let t=[],n=[...e.issues].sort((o,r)=>o.path.length-r.path.length);for(let o of n)t.push(`\u2716 ${o.message}`),o.path?.length&&t.push(` \u2192 at ${bv(o.path)}`);return t.join(`
|
|
6
|
+
`)}var ia=e=>(t,n,o,r)=>{let i=o?Object.assign(o,{async:!1}):{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new yt;if(a.issues.length){let s=new(r?.Err??e)(a.issues.map(u=>qe(u,i,Se())));throw oa(s,r?.callee),s}return a.value},aa=ia(Jn),sa=e=>async(t,n,o,r)=>{let i=o?Object.assign(o,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){let s=new(r?.Err??e)(a.issues.map(u=>qe(u,i,Se())));throw oa(s,r?.callee),s}return a.value},la=sa(Jn),ua=e=>(t,n,o)=>{let r=o?{...o,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},r);if(i instanceof Promise)throw new yt;return i.issues.length?{success:!1,error:new(e??Wr)(i.issues.map(a=>qe(a,r,Se())))}:{success:!0,data:i.value}},Oc=ua(Jn),ca=e=>async(t,n,o)=>{let r=o?Object.assign(o,{async:!0}):{async:!0},i=t._zod.run({value:n,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(a=>qe(a,r,Se())))}:{success:!0,data:i.value}},$c=ca(Jn);var sn={};_t(sn,{_emoji:()=>yv,base64:()=>qc,base64url:()=>da,bigint:()=>td,boolean:()=>od,browserEmail:()=>i0,cidrv4:()=>Bc,cidrv6:()=>Wc,cuid:()=>Pc,cuid2:()=>Mc,date:()=>Yc,datetime:()=>Qc,domain:()=>a0,duration:()=>jc,e164:()=>Kc,email:()=>Gc,emoji:()=>Fc,extendedDuration:()=>JS,guid:()=>Hc,hostname:()=>Xc,html5Email:()=>n0,integer:()=>nd,ipv4:()=>Vc,ipv6:()=>Zc,ksuid:()=>Dc,lowercase:()=>sd,nanoid:()=>Uc,null:()=>id,number:()=>rd,rfc5322Email:()=>r0,string:()=>ed,time:()=>Jc,ulid:()=>Lc,undefined:()=>ad,unicodeEmail:()=>o0,uppercase:()=>ld,uuid:()=>an,uuid4:()=>QS,uuid6:()=>e0,uuid7:()=>t0,xid:()=>zc});var Pc=/^[cC][^\s-]{8,}$/,Mc=/^[0-9a-z]+$/,Lc=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,zc=/^[0-9a-vA-V]{20}$/,Dc=/^[A-Za-z0-9]{27}$/,Uc=/^[a-zA-Z0-9_-]{21}$/,jc=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,JS=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Hc=/^([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})$/,an=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)$/,QS=an(4),e0=an(6),t0=an(7),Gc=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,n0=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,r0=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,o0=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,i0=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,yv="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Fc(){return new RegExp(yv,"u")}var Vc=/^(?:(?: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])$/,Zc=/^(([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})$/,Bc=/^((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])$/,Wc=/^(([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])$/,qc=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,da=/^[A-Za-z0-9_-]*$/,Xc=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,a0=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,Kc=/^\+(?:[0-9]){6,14}[0-9]$/,wv="(?:(?:\\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])))",Yc=new RegExp(`^${wv}$`);function xv(e){let 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 Jc(e){return new RegExp(`^${xv(e)}$`)}function Qc(e){let t=xv({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-]\\d{2}:\\d{2})");let o=`${t}(?:${n.join("|")})`;return new RegExp(`^${wv}T(?:${o})$`)}var ed=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},td=/^\d+n?$/,nd=/^\d+$/,rd=/^-?\d+(?:\.\d+)?/i,od=/true|false/i,id=/null/i;var ad=/undefined/i;var sd=/^[^A-Z]*$/,ld=/^[^a-z]*$/;var ye=T("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Ev={number:"number",bigint:"bigint",object:"date"},pa=T("$ZodCheckLessThan",(e,t)=>{ye.init(e,t);let n=Ev[typeof t.value];e._zod.onattach.push(o=>{let r=o._zod.bag,i=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:n,code:"too_big",maximum:t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ha=T("$ZodCheckGreaterThan",(e,t)=>{ye.init(e,t);let n=Ev[typeof t.value];e._zod.onattach.push(o=>{let r=o._zod.bag,i=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:n,code:"too_small",minimum:t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ud=T("$ZodCheckMultipleOf",(e,t)=>{ye.init(e,t),e._zod.onattach.push(n=>{var o;(o=n._zod.bag).multipleOf??(o.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):_c(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),cd=T("$ZodCheckNumberFormat",(e,t)=>{ye.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),o=n?"int":"number",[r,i]=Ic[t.format];e._zod.onattach.push(a=>{let s=a._zod.bag;s.format=t.format,s.minimum=r,s.maximum=i,n&&(s.pattern=nd)}),e._zod.check=a=>{let s=a.value;if(n){if(!Number.isInteger(s)){a.issues.push({expected:o,format:t.format,code:"invalid_type",input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,continue:!t.abort});return}}s<r&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),s>i&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inst:e})}}),dd=T("$ZodCheckBigIntFormat",(e,t)=>{ye.init(e,t);let[n,o]=Ac[t.format];e._zod.onattach.push(r=>{let i=r._zod.bag;i.format=t.format,i.minimum=n,i.maximum=o}),e._zod.check=r=>{let i=r.value;i<n&&r.issues.push({origin:"bigint",input:i,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),i>o&&r.issues.push({origin:"bigint",input:i,code:"too_big",maximum:o,inst:e})}}),pd=T("$ZodCheckMaxSize",(e,t)=>{var n;ye.init(e,t),(n=e._zod.def).when??(n.when=o=>{let r=o.value;return!Lt(r)&&r.size!==void 0}),e._zod.onattach.push(o=>{let r=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{let r=o.value;r.size<=t.maximum||o.issues.push({origin:Zr(r),code:"too_big",maximum:t.maximum,input:r,inst:e,continue:!t.abort})}}),hd=T("$ZodCheckMinSize",(e,t)=>{var n;ye.init(e,t),(n=e._zod.def).when??(n.when=o=>{let r=o.value;return!Lt(r)&&r.size!==void 0}),e._zod.onattach.push(o=>{let r=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{let r=o.value;r.size>=t.minimum||o.issues.push({origin:Zr(r),code:"too_small",minimum:t.minimum,input:r,inst:e,continue:!t.abort})}}),fd=T("$ZodCheckSizeEquals",(e,t)=>{var n;ye.init(e,t),(n=e._zod.def).when??(n.when=o=>{let r=o.value;return!Lt(r)&&r.size!==void 0}),e._zod.onattach.push(o=>{let r=o._zod.bag;r.minimum=t.size,r.maximum=t.size,r.size=t.size}),e._zod.check=o=>{let r=o.value,i=r.size;if(i===t.size)return;let a=i>t.size;o.issues.push({origin:Zr(r),...a?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),md=T("$ZodCheckMaxLength",(e,t)=>{var n;ye.init(e,t),(n=e._zod.def).when??(n.when=o=>{let r=o.value;return!Lt(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{let r=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{let r=o.value;if(r.length<=t.maximum)return;let a=Br(r);o.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),gd=T("$ZodCheckMinLength",(e,t)=>{var n;ye.init(e,t),(n=e._zod.def).when??(n.when=o=>{let r=o.value;return!Lt(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{let r=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{let r=o.value;if(r.length>=t.minimum)return;let a=Br(r);o.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),vd=T("$ZodCheckLengthEquals",(e,t)=>{var n;ye.init(e,t),(n=e._zod.def).when??(n.when=o=>{let r=o.value;return!Lt(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{let r=o._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=o=>{let r=o.value,i=r.length;if(i===t.length)return;let a=Br(r),s=i>t.length;o.issues.push({origin:a,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),Qn=T("$ZodCheckStringFormat",(e,t)=>{var n,o;ye.init(e,t),e._zod.onattach.push(r=>{let i=r._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),bd=T("$ZodCheckRegex",(e,t)=>{Qn.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),yd=T("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=sd),Qn.init(e,t)}),wd=T("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ld),Qn.init(e,t)}),xd=T("$ZodCheckIncludes",(e,t)=>{ye.init(e,t);let n=Tt(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=o,e._zod.onattach.push(r=>{let i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(o)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),_d=T("$ZodCheckStartsWith",(e,t)=>{ye.init(e,t);let n=new RegExp(`^${Tt(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{let r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.startsWith(t.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),Ed=T("$ZodCheckEndsWith",(e,t)=>{ye.init(e,t);let n=new RegExp(`.*${Tt(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{let r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.endsWith(t.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}});function _v(e,t,n){e.issues.length&&t.issues.push(...Fe(n,e.issues))}var Sd=T("$ZodCheckProperty",(e,t)=>{ye.init(e,t),e._zod.check=n=>{let o=t.schema._zod.run({value:n.value[t.property],issues:[]},{});if(o instanceof Promise)return o.then(r=>_v(r,n,t.property));_v(o,n,t.property)}}),Td=T("$ZodCheckMimeType",(e,t)=>{ye.init(e,t);let n=new Set(t.mime);e._zod.onattach.push(o=>{o._zod.bag.mime=t.mime}),e._zod.check=o=>{n.has(o.value.type)||o.issues.push({code:"invalid_value",values:t.mime,input:o.value.type,inst:e})}}),kd=T("$ZodCheckOverwrite",(e,t)=>{ye.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});var Kr=class{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}let o=t.split(`
|
|
7
|
+
`).filter(a=>a),r=Math.min(...o.map(a=>a.length-a.trimStart().length)),i=o.map(a=>a.slice(r)).map(a=>" ".repeat(this.indent*2)+a);for(let a of i)this.content.push(a)}compile(){let t=Function,n=this?.args,r=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...n,r.join(`
|
|
8
|
+
`))}};var Id={major:4,minor:0,patch:0};var Z=T("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Id;let o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(let r of o)for(let i of r._zod.onattach)i(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let r=(i,a,s)=>{let u=on(i),l;for(let d of a){if(d._zod.def.when){if(!d._zod.def.when(i))continue}else if(u)continue;let h=i.issues.length,g=d._zod.check(i);if(g instanceof Promise&&s?.async===!1)throw new yt;if(l||g instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await g,i.issues.length!==h&&(u||(u=on(i,h)))});else{if(i.issues.length===h)continue;u||(u=on(i,h))}}return l?l.then(()=>i):i};e._zod.run=(i,a)=>{let s=e._zod.parse(i,a);if(s instanceof Promise){if(a.async===!1)throw new yt;return s.then(u=>r(u,o,a))}return r(s,o,a)}}e["~standard"]={validate:r=>{try{let i=Oc(e,r);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return $c(e,r).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}}),ln=T("$ZodString",(e,t)=>{Z.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??ed(e._zod.bag),e._zod.parse=(n,o)=>{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}}),se=T("$ZodStringFormat",(e,t)=>{Qn.init(e,t),ln.init(e,t)}),Rd=T("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Hc),se.init(e,t)}),Cd=T("$ZodUUID",(e,t)=>{if(t.version){let o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=an(o))}else t.pattern??(t.pattern=an());se.init(e,t)}),Nd=T("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Gc),se.init(e,t)}),Od=T("$ZodURL",(e,t)=>{se.init(e,t),e._zod.check=n=>{try{let o=n.value,r=new URL(o),i=r.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Xc.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),!o.endsWith("/")&&i.endsWith("/")?n.value=i.slice(0,-1):n.value=i;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),$d=T("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Fc()),se.init(e,t)}),Pd=T("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Uc),se.init(e,t)}),Md=T("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Pc),se.init(e,t)}),Ld=T("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Mc),se.init(e,t)}),zd=T("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Lc),se.init(e,t)}),Dd=T("$ZodXID",(e,t)=>{t.pattern??(t.pattern=zc),se.init(e,t)}),Ud=T("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Dc),se.init(e,t)}),jd=T("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Qc(t)),se.init(e,t)}),Hd=T("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Yc),se.init(e,t)}),Gd=T("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Jc(t)),se.init(e,t)}),Fd=T("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=jc),se.init(e,t)}),Vd=T("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Vc),se.init(e,t),e._zod.onattach.push(n=>{let o=n._zod.bag;o.format="ipv4"})}),Zd=T("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Zc),se.init(e,t),e._zod.onattach.push(n=>{let o=n._zod.bag;o.format="ipv6"}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),Bd=T("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Bc),se.init(e,t)}),Wd=T("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Wc),se.init(e,t),e._zod.check=n=>{let[o,r]=n.value.split("/");try{if(!r)throw new Error;let i=Number(r);if(`${i}`!==r)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function qd(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Xd=T("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=qc),se.init(e,t),e._zod.onattach.push(n=>{n._zod.bag.contentEncoding="base64"}),e._zod.check=n=>{qd(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Lv(e){if(!da.test(e))return!1;let t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return qd(n)}var Kd=T("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=da),se.init(e,t),e._zod.onattach.push(n=>{n._zod.bag.contentEncoding="base64url"}),e._zod.check=n=>{Lv(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Yd=T("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Kc),se.init(e,t)});function zv(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[o]=n;if(!o)return!1;let r=JSON.parse(atob(o));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}var Jd=T("$ZodJWT",(e,t)=>{se.init(e,t),e._zod.check=n=>{zv(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Qd=T("$ZodCustomStringFormat",(e,t)=>{se.init(e,t),e._zod.check=n=>{t.fn(n.value)||n.issues.push({code:"invalid_format",format:t.format,input:n.value,inst:e,continue:!t.abort})}}),ga=T("$ZodNumber",(e,t)=>{Z.init(e,t),e._zod.pattern=e._zod.bag.pattern??rd,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let i=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...i?{received:i}:{}}),n}}),ep=T("$ZodNumber",(e,t)=>{cd.init(e,t),ga.init(e,t)}),Yr=T("$ZodBoolean",(e,t)=>{Z.init(e,t),e._zod.pattern=od,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=!!n.value}catch{}let r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),va=T("$ZodBigInt",(e,t)=>{Z.init(e,t),e._zod.pattern=td,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value=="bigint"||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}}),tp=T("$ZodBigInt",(e,t)=>{dd.init(e,t),va.init(e,t)}),np=T("$ZodSymbol",(e,t)=>{Z.init(e,t),e._zod.parse=(n,o)=>{let r=n.value;return typeof r=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:r,inst:e}),n}}),rp=T("$ZodUndefined",(e,t)=>{Z.init(e,t),e._zod.pattern=ad,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(n,o)=>{let r=n.value;return typeof r>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:e}),n}}),op=T("$ZodNull",(e,t)=>{Z.init(e,t),e._zod.pattern=id,e._zod.values=new Set([null]),e._zod.parse=(n,o)=>{let r=n.value;return r===null||n.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),n}}),ip=T("$ZodAny",(e,t)=>{Z.init(e,t),e._zod.parse=n=>n}),er=T("$ZodUnknown",(e,t)=>{Z.init(e,t),e._zod.parse=n=>n}),ap=T("$ZodNever",(e,t)=>{Z.init(e,t),e._zod.parse=(n,o)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),sp=T("$ZodVoid",(e,t)=>{Z.init(e,t),e._zod.parse=(n,o)=>{let r=n.value;return typeof r>"u"||n.issues.push({expected:"void",code:"invalid_type",input:r,inst:e}),n}}),lp=T("$ZodDate",(e,t)=>{Z.init(e,t),e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}let r=n.value,i=r instanceof Date;return i&&!Number.isNaN(r.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:r,...i?{received:"Invalid Date"}:{},inst:e}),n}});function Tv(e,t,n){e.issues.length&&t.issues.push(...Fe(n,e.issues)),t.value[n]=e.value}var Jr=T("$ZodArray",(e,t)=>{Z.init(e,t),e._zod.parse=(n,o)=>{let r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);let i=[];for(let a=0;a<r.length;a++){let s=r[a],u=t.element._zod.run({value:s,issues:[]},o);u instanceof Promise?i.push(u.then(l=>Tv(l,n,a))):Tv(u,n,a)}return i.length?Promise.all(i).then(()=>n):n}});function fa(e,t,n){e.issues.length&&t.issues.push(...Fe(n,e.issues)),t.value[n]=e.value}function kv(e,t,n,o){e.issues.length?o[n]===void 0?n in o?t.value[n]=void 0:t.value[n]=e.value:t.issues.push(...Fe(n,e.issues)):e.value===void 0?n in o&&(t.value[n]=void 0):t.value[n]=e.value}var up=T("$ZodObject",(e,t)=>{Z.init(e,t);let n=Gr(()=>{let h=Object.keys(t.shape);for(let f of h)if(!(t.shape[f]instanceof Z))throw new Error(`Invalid element at key "${f}": expected a Zod schema`);let g=kc(t.shape);return{shape:t.shape,keys:h,keySet:new Set(h),numKeys:h.length,optionalKeys:new Set(g)}});oe(e._zod,"propValues",()=>{let h=t.shape,g={};for(let f in h){let p=h[f]._zod;if(p.values){g[f]??(g[f]=new Set);for(let b of p.values)g[f].add(b)}}return g});let o=h=>{let g=new Kr(["shape","payload","ctx"]),f=n.value,p=y=>{let k=rn(y);return`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`};g.write("const input = payload.value;");let b=Object.create(null),v=0;for(let y of f.keys)b[y]=`key_${v++}`;g.write("const newResult = {}");for(let y of f.keys)if(f.optionalKeys.has(y)){let k=b[y];g.write(`const ${k} = ${p(y)};`);let E=rn(y);g.write(`
|
|
9
|
+
if (${k}.issues.length) {
|
|
10
|
+
if (input[${E}] === undefined) {
|
|
11
|
+
if (${E} in input) {
|
|
12
|
+
newResult[${E}] = undefined;
|
|
13
|
+
}
|
|
14
|
+
} else {
|
|
15
|
+
payload.issues = payload.issues.concat(
|
|
16
|
+
${k}.issues.map((iss) => ({
|
|
17
|
+
...iss,
|
|
18
|
+
path: iss.path ? [${E}, ...iss.path] : [${E}],
|
|
19
|
+
}))
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
} else if (${k}.value === undefined) {
|
|
23
|
+
if (${E} in input) newResult[${E}] = undefined;
|
|
24
|
+
} else {
|
|
25
|
+
newResult[${E}] = ${k}.value;
|
|
26
|
+
}
|
|
27
|
+
`)}else{let k=b[y];g.write(`const ${k} = ${p(y)};`),g.write(`
|
|
28
|
+
if (${k}.issues.length) payload.issues = payload.issues.concat(${k}.issues.map(iss => ({
|
|
29
|
+
...iss,
|
|
30
|
+
path: iss.path ? [${rn(y)}, ...iss.path] : [${rn(y)}]
|
|
31
|
+
})));`),g.write(`newResult[${rn(y)}] = ${k}.value`)}g.write("payload.value = newResult;"),g.write("return payload;");let _=g.compile();return(y,k)=>_(h,y,k)},r,i=Kn,a=!Ur.jitless,u=a&&Sc.value,l=t.catchall,d;e._zod.parse=(h,g)=>{d??(d=n.value);let f=h.value;if(!i(f))return h.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),h;let p=[];if(a&&u&&g?.async===!1&&g.jitless!==!0)r||(r=o(t.shape)),h=r(h,g);else{h.value={};let k=d.shape;for(let E of d.keys){let I=k[E],w=I._zod.run({value:f[E],issues:[]},g),A=I._zod.optin==="optional"&&I._zod.optout==="optional";w instanceof Promise?p.push(w.then(L=>A?kv(L,h,E,f):fa(L,h,E))):A?kv(w,h,E,f):fa(w,h,E)}}if(!l)return p.length?Promise.all(p).then(()=>h):h;let b=[],v=d.keySet,_=l._zod,y=_.def.type;for(let k of Object.keys(f)){if(v.has(k))continue;if(y==="never"){b.push(k);continue}let E=_.run({value:f[k],issues:[]},g);E instanceof Promise?p.push(E.then(I=>fa(I,h,k))):fa(E,h,k)}return b.length&&h.issues.push({code:"unrecognized_keys",keys:b,input:f,inst:e}),p.length?Promise.all(p).then(()=>h):h}});function Iv(e,t,n,o){for(let r of e)if(r.issues.length===0)return t.value=r.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(r=>r.issues.map(i=>qe(i,o,Se())))}),t}var ba=T("$ZodUnion",(e,t)=>{Z.init(e,t),oe(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),oe(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),oe(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),oe(e._zod,"pattern",()=>{if(t.options.every(n=>n._zod.pattern)){let n=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${n.map(o=>Fr(o.source)).join("|")})$`)}}),e._zod.parse=(n,o)=>{let r=!1,i=[];for(let a of t.options){let s=a._zod.run({value:n.value,issues:[]},o);if(s instanceof Promise)i.push(s),r=!0;else{if(s.issues.length===0)return s;i.push(s)}}return r?Promise.all(i).then(a=>Iv(a,n,e,o)):Iv(i,n,e,o)}}),cp=T("$ZodDiscriminatedUnion",(e,t)=>{ba.init(e,t);let n=e._zod.parse;oe(e._zod,"propValues",()=>{let r={};for(let i of t.options){let a=i._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let[s,u]of Object.entries(a)){r[s]||(r[s]=new Set);for(let l of u)r[s].add(l)}}return r});let o=Gr(()=>{let r=t.options,i=new Map;for(let a of r){let s=a._zod.propValues[t.discriminator];if(!s||s.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(let u of s){if(i.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);i.set(u,a)}}return i});e._zod.parse=(r,i)=>{let a=r.value;if(!Kn(a))return r.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),r;let s=o.value.get(a?.[t.discriminator]);return s?s._zod.run(r,i):t.unionFallback?n(r,i):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:a,path:[t.discriminator],inst:e}),r)}}),dp=T("$ZodIntersection",(e,t)=>{Z.init(e,t),e._zod.parse=(n,o)=>{let r=n.value,i=t.left._zod.run({value:r,issues:[]},o),a=t.right._zod.run({value:r,issues:[]},o);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([u,l])=>Av(n,u,l)):Av(n,i,a)}});function Ad(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(Yn(e)&&Yn(t)){let n=Object.keys(t),o=Object.keys(e).filter(i=>n.indexOf(i)!==-1),r={...e,...t};for(let i of o){let a=Ad(e[i],t[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};r[i]=a.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let o=0;o<e.length;o++){let r=e[o],i=t[o],a=Ad(r,i);if(!a.valid)return{valid:!1,mergeErrorPath:[o,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Av(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),on(e))return e;let o=Ad(t.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var un=T("$ZodTuple",(e,t)=>{Z.init(e,t);let n=t.items,o=n.length-[...n].reverse().findIndex(r=>r._zod.optin!=="optional");e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({input:a,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=[];let s=[];if(!t.rest){let l=a.length>n.length,d=a.length<o-1;if(l||d)return r.issues.push({input:a,inst:e,origin:"array",...l?{code:"too_big",maximum:n.length}:{code:"too_small",minimum:n.length}}),r}let u=-1;for(let l of n){if(u++,u>=a.length&&u>=o)continue;let d=l._zod.run({value:a[u],issues:[]},i);d instanceof Promise?s.push(d.then(h=>ma(h,r,u))):ma(d,r,u)}if(t.rest){let l=a.slice(n.length);for(let d of l){u++;let h=t.rest._zod.run({value:d,issues:[]},i);h instanceof Promise?s.push(h.then(g=>ma(g,r,u))):ma(h,r,u)}}return s.length?Promise.all(s).then(()=>r):r}});function ma(e,t,n){e.issues.length&&t.issues.push(...Fe(n,e.issues)),t.value[n]=e.value}var pp=T("$ZodRecord",(e,t)=>{Z.init(e,t),e._zod.parse=(n,o)=>{let r=n.value;if(!Yn(r))return n.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),n;let i=[];if(t.keyType._zod.values){let a=t.keyType._zod.values;n.value={};for(let u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){let l=t.valueType._zod.run({value:r[u],issues:[]},o);l instanceof Promise?i.push(l.then(d=>{d.issues.length&&n.issues.push(...Fe(u,d.issues)),n.value[u]=d.value})):(l.issues.length&&n.issues.push(...Fe(u,l.issues)),n.value[u]=l.value)}let s;for(let u in r)a.has(u)||(s=s??[],s.push(u));s&&s.length>0&&n.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:s})}else{n.value={};for(let a of Reflect.ownKeys(r)){if(a==="__proto__")continue;let s=t.keyType._zod.run({value:a,issues:[]},o);if(s instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(s.issues.length){n.issues.push({origin:"record",code:"invalid_key",issues:s.issues.map(l=>qe(l,o,Se())),input:a,path:[a],inst:e}),n.value[s.value]=s.value;continue}let u=t.valueType._zod.run({value:r[a],issues:[]},o);u instanceof Promise?i.push(u.then(l=>{l.issues.length&&n.issues.push(...Fe(a,l.issues)),n.value[s.value]=l.value})):(u.issues.length&&n.issues.push(...Fe(a,u.issues)),n.value[s.value]=u.value)}}return i.length?Promise.all(i).then(()=>n):n}}),hp=T("$ZodMap",(e,t)=>{Z.init(e,t),e._zod.parse=(n,o)=>{let r=n.value;if(!(r instanceof Map))return n.issues.push({expected:"map",code:"invalid_type",input:r,inst:e}),n;let i=[];n.value=new Map;for(let[a,s]of r){let u=t.keyType._zod.run({value:a,issues:[]},o),l=t.valueType._zod.run({value:s,issues:[]},o);u instanceof Promise||l instanceof Promise?i.push(Promise.all([u,l]).then(([d,h])=>{Rv(d,h,n,a,r,e,o)})):Rv(u,l,n,a,r,e,o)}return i.length?Promise.all(i).then(()=>n):n}});function Rv(e,t,n,o,r,i,a){e.issues.length&&(Vr.has(typeof o)?n.issues.push(...Fe(o,e.issues)):n.issues.push({origin:"map",code:"invalid_key",input:r,inst:i,issues:e.issues.map(s=>qe(s,a,Se()))})),t.issues.length&&(Vr.has(typeof o)?n.issues.push(...Fe(o,t.issues)):n.issues.push({origin:"map",code:"invalid_element",input:r,inst:i,key:o,issues:t.issues.map(s=>qe(s,a,Se()))})),n.value.set(e.value,t.value)}var fp=T("$ZodSet",(e,t)=>{Z.init(e,t),e._zod.parse=(n,o)=>{let r=n.value;if(!(r instanceof Set))return n.issues.push({input:r,inst:e,expected:"set",code:"invalid_type"}),n;let i=[];n.value=new Set;for(let a of r){let s=t.valueType._zod.run({value:a,issues:[]},o);s instanceof Promise?i.push(s.then(u=>Cv(u,n))):Cv(s,n)}return i.length?Promise.all(i).then(()=>n):n}});function Cv(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var mp=T("$ZodEnum",(e,t)=>{Z.init(e,t);let n=Hr(t.entries);e._zod.values=new Set(n),e._zod.pattern=new RegExp(`^(${n.filter(o=>Vr.has(typeof o)).map(o=>typeof o=="string"?Tt(o):o.toString()).join("|")})$`),e._zod.parse=(o,r)=>{let i=o.value;return e._zod.values.has(i)||o.issues.push({code:"invalid_value",values:n,input:i,inst:e}),o}}),gp=T("$ZodLiteral",(e,t)=>{Z.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?Tt(n):n?n.toString():String(n)).join("|")})$`),e._zod.parse=(n,o)=>{let r=n.value;return e._zod.values.has(r)||n.issues.push({code:"invalid_value",values:t.values,input:r,inst:e}),n}}),vp=T("$ZodFile",(e,t)=>{Z.init(e,t),e._zod.parse=(n,o)=>{let r=n.value;return r instanceof File||n.issues.push({expected:"file",code:"invalid_type",input:r,inst:e}),n}}),Qr=T("$ZodTransform",(e,t)=>{Z.init(e,t),e._zod.parse=(n,o)=>{let r=t.transform(n.value,n);if(o.async)return(r instanceof Promise?r:Promise.resolve(r)).then(a=>(n.value=a,n));if(r instanceof Promise)throw new yt;return n.value=r,n}}),bp=T("$ZodOptional",(e,t)=>{Z.init(e,t),e._zod.optin="optional",e._zod.optout="optional",oe(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),oe(e._zod,"pattern",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${Fr(n.source)})?$`):void 0}),e._zod.parse=(n,o)=>t.innerType._zod.optin==="optional"?t.innerType._zod.run(n,o):n.value===void 0?n:t.innerType._zod.run(n,o)}),yp=T("$ZodNullable",(e,t)=>{Z.init(e,t),oe(e._zod,"optin",()=>t.innerType._zod.optin),oe(e._zod,"optout",()=>t.innerType._zod.optout),oe(e._zod,"pattern",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${Fr(n.source)}|null)$`):void 0}),oe(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,o)=>n.value===null?n:t.innerType._zod.run(n,o)}),wp=T("$ZodDefault",(e,t)=>{Z.init(e,t),e._zod.optin="optional",oe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(i=>Nv(i,t)):Nv(r,t)}});function Nv(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var xp=T("$ZodPrefault",(e,t)=>{Z.init(e,t),e._zod.optin="optional",oe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>(n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,o))}),_p=T("$ZodNonOptional",(e,t)=>{Z.init(e,t),oe(e._zod,"values",()=>{let n=t.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(n,o)=>{let r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(i=>Ov(i,e)):Ov(r,e)}});function Ov(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var Ep=T("$ZodSuccess",(e,t)=>{Z.init(e,t),e._zod.parse=(n,o)=>{let r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(i=>(n.value=i.issues.length===0,n)):(n.value=r.issues.length===0,n)}}),Sp=T("$ZodCatch",(e,t)=>{Z.init(e,t),e._zod.optin="optional",oe(e._zod,"optout",()=>t.innerType._zod.optout),oe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{let r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(a=>qe(a,o,Se()))},input:n.value}),n.issues=[]),n)):(n.value=r.value,r.issues.length&&(n.value=t.catchValue({...n,error:{issues:r.issues.map(i=>qe(i,o,Se()))},input:n.value}),n.issues=[]),n)}}),Tp=T("$ZodNaN",(e,t)=>{Z.init(e,t),e._zod.parse=(n,o)=>((typeof n.value!="number"||!Number.isNaN(n.value))&&n.issues.push({input:n.value,inst:e,expected:"nan",code:"invalid_type"}),n)}),eo=T("$ZodPipe",(e,t)=>{Z.init(e,t),oe(e._zod,"values",()=>t.in._zod.values),oe(e._zod,"optin",()=>t.in._zod.optin),oe(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(n,o)=>{let r=t.in._zod.run(n,o);return r instanceof Promise?r.then(i=>$v(i,t,o)):$v(r,t,o)}});function $v(e,t,n){return on(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}var kp=T("$ZodReadonly",(e,t)=>{Z.init(e,t),oe(e._zod,"propValues",()=>t.innerType._zod.propValues),oe(e._zod,"values",()=>t.innerType._zod.values),oe(e._zod,"optin",()=>t.innerType._zod.optin),oe(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(n,o)=>{let r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(Pv):Pv(r)}});function Pv(e){return e.value=Object.freeze(e.value),e}var Ip=T("$ZodTemplateLiteral",(e,t)=>{Z.init(e,t);let n=[];for(let o of t.parts)if(o instanceof Z){if(!o._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...o._zod.traits].shift()}`);let r=o._zod.pattern instanceof RegExp?o._zod.pattern.source:o._zod.pattern;if(!r)throw new Error(`Invalid template literal part: ${o._zod.traits}`);let i=r.startsWith("^")?1:0,a=r.endsWith("$")?r.length-1:r.length;n.push(r.slice(i,a))}else if(o===null||Tc.has(typeof o))n.push(Tt(`${o}`));else throw new Error(`Invalid template literal part: ${o}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(o,r)=>typeof o.value!="string"?(o.issues.push({input:o.value,inst:e,expected:"template_literal",code:"invalid_type"}),o):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(o.value)||o.issues.push({input:o.value,inst:e,code:"invalid_format",format:"template_literal",pattern:e._zod.pattern.source}),o)}),Ap=T("$ZodPromise",(e,t)=>{Z.init(e,t),e._zod.parse=(n,o)=>Promise.resolve(n.value).then(r=>t.innerType._zod.run({value:r,issues:[]},o))}),Rp=T("$ZodLazy",(e,t)=>{Z.init(e,t),oe(e._zod,"innerType",()=>t.getter()),oe(e._zod,"pattern",()=>e._zod.innerType._zod.pattern),oe(e._zod,"propValues",()=>e._zod.innerType._zod.propValues),oe(e._zod,"optin",()=>e._zod.innerType._zod.optin),oe(e._zod,"optout",()=>e._zod.innerType._zod.optout),e._zod.parse=(n,o)=>e._zod.innerType._zod.run(n,o)}),Cp=T("$ZodCustom",(e,t)=>{ye.init(e,t),Z.init(e,t),e._zod.parse=(n,o)=>n,e._zod.check=n=>{let o=n.value,r=t.fn(o);if(r instanceof Promise)return r.then(i=>Mv(i,n,o,e));Mv(r,n,o,e)}});function Mv(e,t,n,o){if(!e){let r={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(r.params=o._zod.def.params),t.issues.push(Rc(r))}}var to={};_t(to,{ar:()=>Uv,az:()=>jv,be:()=>Gv,ca:()=>Fv,cs:()=>Vv,de:()=>Zv,en:()=>ya,eo:()=>Bv,es:()=>Wv,fa:()=>qv,fi:()=>Xv,fr:()=>Kv,frCA:()=>Yv,he:()=>Jv,hu:()=>Qv,id:()=>eb,it:()=>tb,ja:()=>nb,kh:()=>rb,ko:()=>ob,mk:()=>ib,ms:()=>ab,nl:()=>sb,no:()=>lb,ota:()=>ub,pl:()=>db,ps:()=>cb,pt:()=>pb,ru:()=>fb,sl:()=>mb,sv:()=>gb,ta:()=>vb,th:()=>bb,tr:()=>yb,ua:()=>wb,ur:()=>xb,vi:()=>_b,zhCN:()=>Eb,zhTW:()=>Sb});var s0=()=>{let e={string:{unit:"\u062D\u0631\u0641",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},file:{unit:"\u0628\u0627\u064A\u062A",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},array:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},set:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"\u0645\u062F\u062E\u0644",email:"\u0628\u0631\u064A\u062F \u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A",url:"\u0631\u0627\u0628\u0637",emoji:"\u0625\u064A\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u064A\u062E \u0648\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",date:"\u062A\u0627\u0631\u064A\u062E \u0628\u0645\u0639\u064A\u0627\u0631 ISO",time:"\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",duration:"\u0645\u062F\u0629 \u0628\u0645\u0639\u064A\u0627\u0631 ISO",ipv4:"\u0639\u0646\u0648\u0627\u0646 IPv4",ipv6:"\u0639\u0646\u0648\u0627\u0646 IPv6",cidrv4:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv4",cidrv6:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv6",base64:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64-encoded",base64url:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64url-encoded",json_string:"\u0646\u064E\u0635 \u0639\u0644\u0649 \u0647\u064A\u0626\u0629 JSON",e164:"\u0631\u0642\u0645 \u0647\u0627\u062A\u0641 \u0628\u0645\u0639\u064A\u0627\u0631 E.164",jwt:"JWT",template_literal:"\u0645\u062F\u062E\u0644"};return r=>{switch(r.code){case"invalid_type":return`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${r.expected}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${n(r.input)}`;case"invalid_value":return r.values.length===1?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${z(r.values[0])}`:`\u0627\u062E\u062A\u064A\u0627\u0631 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062A\u0648\u0642\u0639 \u0627\u0646\u062A\u0642\u0627\u0621 \u0623\u062D\u062F \u0647\u0630\u0647 \u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A: ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${r.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${i} ${r.maximum.toString()} ${a.unit??"\u0639\u0646\u0635\u0631"}`:`\u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${r.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${i} ${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${r.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${i} ${r.minimum.toString()} ${a.unit}`:`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${r.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${i} ${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0628\u062F\u0623 \u0628\u0640 "${r.prefix}"`:i.format==="ends_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0646\u062A\u0647\u064A \u0628\u0640 "${i.suffix}"`:i.format==="includes"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062A\u0636\u0645\u0651\u064E\u0646 "${i.includes}"`:i.format==="regex"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0637\u0627\u0628\u0642 \u0627\u0644\u0646\u0645\u0637 ${i.pattern}`:`${o[i.format]??r.format} \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644`}case"not_multiple_of":return`\u0631\u0642\u0645 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0646 \u0645\u0636\u0627\u0639\u0641\u0627\u062A ${r.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${r.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${r.keys.length>1?"\u0629":""}: ${R(r.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${r.origin}`;case"invalid_union":return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644";case"invalid_element":return`\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${r.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}}};function Uv(){return{localeError:s0()}}var l0=()=>{let e={string:{unit:"simvol",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"element",verb:"olmal\u0131d\u0131r"},set:{unit:"element",verb:"olmal\u0131d\u0131r"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return r=>{switch(r.code){case"invalid_type":return`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${r.expected}, daxil olan ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${z(r.values[0])}`:`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${r.origin??"d\u0259y\u0259r"} ${i}${r.maximum.toString()} ${a.unit??"element"}`:`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${r.origin??"d\u0259y\u0259r"} ${i}${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${r.origin} ${i}${r.minimum.toString()} ${a.unit}`:`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${r.origin} ${i}${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`Yanl\u0131\u015F m\u0259tn: "${i.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`:i.format==="ends_with"?`Yanl\u0131\u015F m\u0259tn: "${i.suffix}" il\u0259 bitm\u0259lidir`:i.format==="includes"?`Yanl\u0131\u015F m\u0259tn: "${i.includes}" daxil olmal\u0131d\u0131r`:i.format==="regex"?`Yanl\u0131\u015F m\u0259tn: ${i.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`:`Yanl\u0131\u015F ${o[i.format]??r.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${r.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${r.keys.length>1?"lar":""}: ${R(r.keys,", ")}`;case"invalid_key":return`${r.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${r.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}}};function jv(){return{localeError:l0()}}function Hv(e,t,n,o){let r=Math.abs(e),i=r%10,a=r%100;return a>=11&&a<=19?o:i===1?t:i>=2&&i<=4?n:o}var u0=()=>{let e={string:{unit:{one:"\u0441\u0456\u043C\u0432\u0430\u043B",few:"\u0441\u0456\u043C\u0432\u0430\u043B\u044B",many:"\u0441\u0456\u043C\u0432\u0430\u043B\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u044B",many:"\u0431\u0430\u0439\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"\u043B\u0456\u043A";case"object":{if(Array.isArray(r))return"\u043C\u0430\u0441\u0456\u045E";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"\u0443\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0430\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0456 \u0447\u0430\u0441",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0447\u0430\u0441",duration:"ISO \u043F\u0440\u0430\u0446\u044F\u0433\u043B\u0430\u0441\u0446\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0430\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0430\u0441",cidrv4:"IPv4 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",base64:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64",base64url:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64url",json_string:"JSON \u0440\u0430\u0434\u043E\u043A",e164:"\u043D\u0443\u043C\u0430\u0440 E.164",jwt:"JWT",template_literal:"\u0443\u0432\u043E\u0434"};return r=>{switch(r.code){case"invalid_type":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F ${r.expected}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${n(r.input)}`;case"invalid_value":return r.values.length===1?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F ${z(r.values[0])}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0432\u0430\u0440\u044B\u044F\u043D\u0442: \u0447\u0430\u043A\u0430\u045E\u0441\u044F \u0430\u0434\u0437\u0456\u043D \u0437 ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);if(a){let s=Number(r.maximum),u=Hv(s,a.unit.one,a.unit.few,a.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${a.verb} ${i}${r.maximum.toString()} ${u}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${i}${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);if(a){let s=Number(r.minimum),u=Hv(s,a.unit.one,a.unit.few,a.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${r.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${a.verb} ${i}${r.minimum.toString()} ${u}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${r.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${i}${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u043F\u0430\u0447\u044B\u043D\u0430\u0446\u0446\u0430 \u0437 "${i.prefix}"`:i.format==="ends_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u0430\u043A\u0430\u043D\u0447\u0432\u0430\u0446\u0446\u0430 \u043D\u0430 "${i.suffix}"`:i.format==="includes"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u043C\u044F\u0448\u0447\u0430\u0446\u044C "${i.includes}"`:i.format==="regex"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0430\u0434\u043F\u0430\u0432\u044F\u0434\u0430\u0446\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${i.pattern}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${o[i.format]??r.format}`}case"not_multiple_of":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043B\u0456\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0431\u044B\u0446\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${r.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${r.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${R(r.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${r.origin}`;case"invalid_union":return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434";case"invalid_element":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u0430\u0435 \u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435 \u045E ${r.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}}};function Gv(){return{localeError:u0()}}var c0=()=>{let e={string:{unit:"car\xE0cters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"entrada",email:"adre\xE7a electr\xF2nica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adre\xE7a IPv4",ipv6:"adre\xE7a IPv6",cidrv4:"rang IPv4",cidrv6:"rang IPv6",base64:"cadena codificada en base64",base64url:"cadena codificada en base64url",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"};return r=>{switch(r.code){case"invalid_type":return`Tipus inv\xE0lid: s'esperava ${r.expected}, s'ha rebut ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Valor inv\xE0lid: s'esperava ${z(r.values[0])}`:`Opci\xF3 inv\xE0lida: s'esperava una de ${R(r.values," o ")}`;case"too_big":{let i=r.inclusive?"com a m\xE0xim":"menys de",a=t(r.origin);return a?`Massa gran: s'esperava que ${r.origin??"el valor"} contingu\xE9s ${i} ${r.maximum.toString()} ${a.unit??"elements"}`:`Massa gran: s'esperava que ${r.origin??"el valor"} fos ${i} ${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?"com a m\xEDnim":"m\xE9s de",a=t(r.origin);return a?`Massa petit: s'esperava que ${r.origin} contingu\xE9s ${i} ${r.minimum.toString()} ${a.unit}`:`Massa petit: s'esperava que ${r.origin} fos ${i} ${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`Format inv\xE0lid: ha de comen\xE7ar amb "${i.prefix}"`:i.format==="ends_with"?`Format inv\xE0lid: ha d'acabar amb "${i.suffix}"`:i.format==="includes"?`Format inv\xE0lid: ha d'incloure "${i.includes}"`:i.format==="regex"?`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${i.pattern}`:`Format inv\xE0lid per a ${o[i.format]??r.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${r.divisor}`;case"unrecognized_keys":return`Clau${r.keys.length>1?"s":""} no reconeguda${r.keys.length>1?"s":""}: ${R(r.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${r.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${r.origin}`;default:return"Entrada inv\xE0lida"}}};function Fv(){return{localeError:c0()}}var d0=()=>{let e={string:{unit:"znak\u016F",verb:"m\xEDt"},file:{unit:"bajt\u016F",verb:"m\xEDt"},array:{unit:"prvk\u016F",verb:"m\xEDt"},set:{unit:"prvk\u016F",verb:"m\xEDt"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"\u010D\xEDslo";case"string":return"\u0159et\u011Bzec";case"boolean":return"boolean";case"bigint":return"bigint";case"function":return"funkce";case"symbol":return"symbol";case"undefined":return"undefined";case"object":{if(Array.isArray(r))return"pole";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"regul\xE1rn\xED v\xFDraz",email:"e-mailov\xE1 adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a \u010Das ve form\xE1tu ISO",date:"datum ve form\xE1tu ISO",time:"\u010Das ve form\xE1tu ISO",duration:"doba trv\xE1n\xED ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64",base64url:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64url",json_string:"\u0159et\u011Bzec ve form\xE1tu JSON",e164:"\u010D\xEDslo E.164",jwt:"JWT",template_literal:"vstup"};return r=>{switch(r.code){case"invalid_type":return`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${r.expected}, obdr\u017Eeno ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${z(r.values[0])}`:`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${r.origin??"hodnota"} mus\xED m\xEDt ${i}${r.maximum.toString()} ${a.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${r.origin??"hodnota"} mus\xED b\xFDt ${i}${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${r.origin??"hodnota"} mus\xED m\xEDt ${i}${r.minimum.toString()} ${a.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${r.origin??"hodnota"} mus\xED b\xFDt ${i}${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${i.prefix}"`:i.format==="ends_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${i.suffix}"`:i.format==="includes"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${i.includes}"`:i.format==="regex"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${i.pattern}`:`Neplatn\xFD form\xE1t ${o[i.format]??r.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${r.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${R(r.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${r.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${r.origin}`;default:return"Neplatn\xFD vstup"}}};function Vv(){return{localeError:d0()}}var p0=()=>{let e={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"Zahl";case"object":{if(Array.isArray(r))return"Array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",jwt:"JWT",template_literal:"Eingabe"};return r=>{switch(r.code){case"invalid_type":return`Ung\xFCltige Eingabe: erwartet ${r.expected}, erhalten ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Ung\xFCltige Eingabe: erwartet ${z(r.values[0])}`:`Ung\xFCltige Option: erwartet eine von ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Zu gro\xDF: erwartet, dass ${r.origin??"Wert"} ${i}${r.maximum.toString()} ${a.unit??"Elemente"} hat`:`Zu gro\xDF: erwartet, dass ${r.origin??"Wert"} ${i}${r.maximum.toString()} ist`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`Zu klein: erwartet, dass ${r.origin} ${i}${r.minimum.toString()} ${a.unit} hat`:`Zu klein: erwartet, dass ${r.origin} ${i}${r.minimum.toString()} ist`}case"invalid_format":{let i=r;return i.format==="starts_with"?`Ung\xFCltiger String: muss mit "${i.prefix}" beginnen`:i.format==="ends_with"?`Ung\xFCltiger String: muss mit "${i.suffix}" enden`:i.format==="includes"?`Ung\xFCltiger String: muss "${i.includes}" enthalten`:i.format==="regex"?`Ung\xFCltiger String: muss dem Muster ${i.pattern} entsprechen`:`Ung\xFCltig: ${o[i.format]??r.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${r.divisor} sein`;case"unrecognized_keys":return`${r.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${R(r.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${r.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${r.origin}`;default:return"Ung\xFCltige Eingabe"}}};function Zv(){return{localeError:p0()}}var h0=e=>{let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"number";case"object":{if(Array.isArray(e))return"array";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},f0=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function t(o){return e[o]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return o=>{switch(o.code){case"invalid_type":return`Invalid input: expected ${o.expected}, received ${h0(o.input)}`;case"invalid_value":return o.values.length===1?`Invalid input: expected ${z(o.values[0])}`:`Invalid option: expected one of ${R(o.values,"|")}`;case"too_big":{let r=o.inclusive?"<=":"<",i=t(o.origin);return i?`Too big: expected ${o.origin??"value"} to have ${r}${o.maximum.toString()} ${i.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${r}${o.maximum.toString()}`}case"too_small":{let r=o.inclusive?">=":">",i=t(o.origin);return i?`Too small: expected ${o.origin} to have ${r}${o.minimum.toString()} ${i.unit}`:`Too small: expected ${o.origin} to be ${r}${o.minimum.toString()}`}case"invalid_format":{let r=o;return r.format==="starts_with"?`Invalid string: must start with "${r.prefix}"`:r.format==="ends_with"?`Invalid string: must end with "${r.suffix}"`:r.format==="includes"?`Invalid string: must include "${r.includes}"`:r.format==="regex"?`Invalid string: must match pattern ${r.pattern}`:`Invalid ${n[r.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${R(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function ya(){return{localeError:f0()}}var m0=e=>{let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"nombro";case"object":{if(Array.isArray(e))return"tabelo";if(e===null)return"senvalora";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},g0=()=>{let e={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"}};function t(o){return e[o]??null}let n={regex:"enigo",email:"retadreso",url:"URL",emoji:"emo\u011Dio",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datotempo",date:"ISO-dato",time:"ISO-tempo",duration:"ISO-da\u016Dro",ipv4:"IPv4-adreso",ipv6:"IPv6-adreso",cidrv4:"IPv4-rango",cidrv6:"IPv6-rango",base64:"64-ume kodita karaktraro",base64url:"URL-64-ume kodita karaktraro",json_string:"JSON-karaktraro",e164:"E.164-nombro",jwt:"JWT",template_literal:"enigo"};return o=>{switch(o.code){case"invalid_type":return`Nevalida enigo: atendi\u011Dis ${o.expected}, ricevi\u011Dis ${m0(o.input)}`;case"invalid_value":return o.values.length===1?`Nevalida enigo: atendi\u011Dis ${z(o.values[0])}`:`Nevalida opcio: atendi\u011Dis unu el ${R(o.values,"|")}`;case"too_big":{let r=o.inclusive?"<=":"<",i=t(o.origin);return i?`Tro granda: atendi\u011Dis ke ${o.origin??"valoro"} havu ${r}${o.maximum.toString()} ${i.unit??"elementojn"}`:`Tro granda: atendi\u011Dis ke ${o.origin??"valoro"} havu ${r}${o.maximum.toString()}`}case"too_small":{let r=o.inclusive?">=":">",i=t(o.origin);return i?`Tro malgranda: atendi\u011Dis ke ${o.origin} havu ${r}${o.minimum.toString()} ${i.unit}`:`Tro malgranda: atendi\u011Dis ke ${o.origin} estu ${r}${o.minimum.toString()}`}case"invalid_format":{let r=o;return r.format==="starts_with"?`Nevalida karaktraro: devas komenci\u011Di per "${r.prefix}"`:r.format==="ends_with"?`Nevalida karaktraro: devas fini\u011Di per "${r.suffix}"`:r.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${r.includes}"`:r.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${r.pattern}`:`Nevalida ${n[r.format]??o.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${o.divisor}`;case"unrecognized_keys":return`Nekonata${o.keys.length>1?"j":""} \u015Dlosilo${o.keys.length>1?"j":""}: ${R(o.keys,", ")}`;case"invalid_key":return`Nevalida \u015Dlosilo en ${o.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${o.origin}`;default:return"Nevalida enigo"}}};function Bv(){return{localeError:g0()}}var v0=()=>{let e={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"n\xFAmero";case"object":{if(Array.isArray(r))return"arreglo";if(r===null)return"nulo";if(Object.getPrototypeOf(r)!==Object.prototype)return r.constructor.name}}return i},o={regex:"entrada",email:"direcci\xF3n de correo electr\xF3nico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duraci\xF3n ISO",ipv4:"direcci\xF3n IPv4",ipv6:"direcci\xF3n IPv6",cidrv4:"rango IPv4",cidrv6:"rango IPv6",base64:"cadena codificada en base64",base64url:"URL codificada en base64",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"};return r=>{switch(r.code){case"invalid_type":return`Entrada inv\xE1lida: se esperaba ${r.expected}, recibido ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Entrada inv\xE1lida: se esperaba ${z(r.values[0])}`:`Opci\xF3n inv\xE1lida: se esperaba una de ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Demasiado grande: se esperaba que ${r.origin??"valor"} tuviera ${i}${r.maximum.toString()} ${a.unit??"elementos"}`:`Demasiado grande: se esperaba que ${r.origin??"valor"} fuera ${i}${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`Demasiado peque\xF1o: se esperaba que ${r.origin} tuviera ${i}${r.minimum.toString()} ${a.unit}`:`Demasiado peque\xF1o: se esperaba que ${r.origin} fuera ${i}${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`Cadena inv\xE1lida: debe comenzar con "${i.prefix}"`:i.format==="ends_with"?`Cadena inv\xE1lida: debe terminar en "${i.suffix}"`:i.format==="includes"?`Cadena inv\xE1lida: debe incluir "${i.includes}"`:i.format==="regex"?`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${i.pattern}`:`Inv\xE1lido ${o[i.format]??r.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${r.divisor}`;case"unrecognized_keys":return`Llave${r.keys.length>1?"s":""} desconocida${r.keys.length>1?"s":""}: ${R(r.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${r.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${r.origin}`;default:return"Entrada inv\xE1lida"}}};function Wv(){return{localeError:v0()}}var b0=()=>{let e={string:{unit:"\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},array:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},set:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"\u0639\u062F\u062F";case"object":{if(Array.isArray(r))return"\u0622\u0631\u0627\u06CC\u0647";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"\u0648\u0631\u0648\u062F\u06CC",email:"\u0622\u062F\u0631\u0633 \u0627\u06CC\u0645\u06CC\u0644",url:"URL",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u06CC\u062E \u0648 \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",date:"\u062A\u0627\u0631\u06CC\u062E \u0627\u06CC\u0632\u0648",time:"\u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",duration:"\u0645\u062F\u062A \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",ipv4:"IPv4 \u0622\u062F\u0631\u0633",ipv6:"IPv6 \u0622\u062F\u0631\u0633",cidrv4:"IPv4 \u062F\u0627\u0645\u0646\u0647",cidrv6:"IPv6 \u062F\u0627\u0645\u0646\u0647",base64:"base64-encoded \u0631\u0634\u062A\u0647",base64url:"base64url-encoded \u0631\u0634\u062A\u0647",json_string:"JSON \u0631\u0634\u062A\u0647",e164:"E.164 \u0639\u062F\u062F",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u06CC"};return r=>{switch(r.code){case"invalid_type":return`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${r.expected} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${n(r.input)} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`;case"invalid_value":return r.values.length===1?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${z(r.values[0])} \u0645\u06CC\u200C\u0628\u0648\u062F`:`\u06AF\u0632\u06CC\u0646\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A \u06CC\u06A9\u06CC \u0627\u0632 ${R(r.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${r.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${i}${r.maximum.toString()} ${a.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${r.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${i}${r.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${r.origin} \u0628\u0627\u06CC\u062F ${i}${r.minimum.toString()} ${a.unit} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${r.origin} \u0628\u0627\u06CC\u062F ${i}${r.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let i=r;return i.format==="starts_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${i.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`:i.format==="ends_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${i.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`:i.format==="includes"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${i.includes}" \u0628\u0627\u0634\u062F`:i.format==="regex"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC ${i.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`:`${o[i.format]??r.format} \u0646\u0627\u0645\u0639\u062A\u0628\u0631`}case"not_multiple_of":return`\u0639\u062F\u062F \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0645\u0636\u0631\u0628 ${r.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${r.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${R(r.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${r.origin}`;case"invalid_union":return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631";case"invalid_element":return`\u0645\u0642\u062F\u0627\u0631 \u0646\u0627\u0645\u0639\u062A\u0628\u0631 \u062F\u0631 ${r.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}}};function qv(){return{localeError:b0()}}var y0=()=>{let e={string:{unit:"merkki\xE4",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"p\xE4iv\xE4m\xE4\xE4r\xE4n"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"s\xE4\xE4nn\xF6llinen lauseke",email:"s\xE4hk\xF6postiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-p\xE4iv\xE4m\xE4\xE4r\xE4",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",jwt:"JWT",template_literal:"templaattimerkkijono"};return r=>{switch(r.code){case"invalid_type":return`Virheellinen tyyppi: odotettiin ${r.expected}, oli ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Virheellinen sy\xF6te: t\xE4ytyy olla ${z(r.values[0])}`:`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Liian suuri: ${a.subject} t\xE4ytyy olla ${i}${r.maximum.toString()} ${a.unit}`.trim():`Liian suuri: arvon t\xE4ytyy olla ${i}${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`Liian pieni: ${a.subject} t\xE4ytyy olla ${i}${r.minimum.toString()} ${a.unit}`.trim():`Liian pieni: arvon t\xE4ytyy olla ${i}${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${i.prefix}"`:i.format==="ends_with"?`Virheellinen sy\xF6te: t\xE4ytyy loppua "${i.suffix}"`:i.format==="includes"?`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${i.includes}"`:i.format==="regex"?`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${i.pattern}`:`Virheellinen ${o[i.format]??r.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${r.divisor} monikerta`;case"unrecognized_keys":return`${r.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${R(r.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen sy\xF6te"}}};function Xv(){return{localeError:y0()}}var w0=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"nombre";case"object":{if(Array.isArray(r))return"tableau";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"entr\xE9e",email:"adresse e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date et heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"};return r=>{switch(r.code){case"invalid_type":return`Entr\xE9e invalide : ${r.expected} attendu, ${n(r.input)} re\xE7u`;case"invalid_value":return r.values.length===1?`Entr\xE9e invalide : ${z(r.values[0])} attendu`:`Option invalide : une valeur parmi ${R(r.values,"|")} attendue`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Trop grand : ${r.origin??"valeur"} doit ${a.verb} ${i}${r.maximum.toString()} ${a.unit??"\xE9l\xE9ment(s)"}`:`Trop grand : ${r.origin??"valeur"} doit \xEAtre ${i}${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`Trop petit : ${r.origin} doit ${a.verb} ${i}${r.minimum.toString()} ${a.unit}`:`Trop petit : ${r.origin} doit \xEAtre ${i}${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${i.prefix}"`:i.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${i.suffix}"`:i.format==="includes"?`Cha\xEEne invalide : doit inclure "${i.includes}"`:i.format==="regex"?`Cha\xEEne invalide : doit correspondre au mod\xE8le ${i.pattern}`:`${o[i.format]??r.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${r.divisor}`;case"unrecognized_keys":return`Cl\xE9${r.keys.length>1?"s":""} non reconnue${r.keys.length>1?"s":""} : ${R(r.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${r.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${r.origin}`;default:return"Entr\xE9e invalide"}}};function Kv(){return{localeError:w0()}}var x0=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"entr\xE9e",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"};return r=>{switch(r.code){case"invalid_type":return`Entr\xE9e invalide : attendu ${r.expected}, re\xE7u ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Entr\xE9e invalide : attendu ${z(r.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"\u2264":"<",a=t(r.origin);return a?`Trop grand : attendu que ${r.origin??"la valeur"} ait ${i}${r.maximum.toString()} ${a.unit}`:`Trop grand : attendu que ${r.origin??"la valeur"} soit ${i}${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?"\u2265":">",a=t(r.origin);return a?`Trop petit : attendu que ${r.origin} ait ${i}${r.minimum.toString()} ${a.unit}`:`Trop petit : attendu que ${r.origin} soit ${i}${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${i.prefix}"`:i.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${i.suffix}"`:i.format==="includes"?`Cha\xEEne invalide : doit inclure "${i.includes}"`:i.format==="regex"?`Cha\xEEne invalide : doit correspondre au motif ${i.pattern}`:`${o[i.format]??r.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${r.divisor}`;case"unrecognized_keys":return`Cl\xE9${r.keys.length>1?"s":""} non reconnue${r.keys.length>1?"s":""} : ${R(r.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${r.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${r.origin}`;default:return"Entr\xE9e invalide"}}};function Yv(){return{localeError:x0()}}var _0=()=>{let e={string:{unit:"\u05D0\u05D5\u05EA\u05D9\u05D5\u05EA",verb:"\u05DC\u05DB\u05DC\u05D5\u05DC"},file:{unit:"\u05D1\u05D9\u05D9\u05D8\u05D9\u05DD",verb:"\u05DC\u05DB\u05DC\u05D5\u05DC"},array:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",verb:"\u05DC\u05DB\u05DC\u05D5\u05DC"},set:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",verb:"\u05DC\u05DB\u05DC\u05D5\u05DC"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"\u05E7\u05DC\u05D8",email:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05D0\u05D9\u05DE\u05D9\u05D9\u05DC",url:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05E8\u05E9\u05EA",emoji:"\u05D0\u05D9\u05DE\u05D5\u05D2'\u05D9",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u05EA\u05D0\u05E8\u05D9\u05DA \u05D5\u05D6\u05DE\u05DF ISO",date:"\u05EA\u05D0\u05E8\u05D9\u05DA ISO",time:"\u05D6\u05DE\u05DF ISO",duration:"\u05DE\u05E9\u05DA \u05D6\u05DE\u05DF ISO",ipv4:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv4",ipv6:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv6",cidrv4:"\u05D8\u05D5\u05D5\u05D7 IPv4",cidrv6:"\u05D8\u05D5\u05D5\u05D7 IPv6",base64:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64",base64url:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64 \u05DC\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05E8\u05E9\u05EA",json_string:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA JSON",e164:"\u05DE\u05E1\u05E4\u05E8 E.164",jwt:"JWT",template_literal:"\u05E7\u05DC\u05D8"};return r=>{switch(r.code){case"invalid_type":return`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA ${r.expected}, \u05D4\u05EA\u05E7\u05D1\u05DC ${n(r.input)}`;case"invalid_value":return r.values.length===1?`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA ${z(r.values[0])}`:`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05D0\u05D7\u05EA \u05DE\u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${r.origin??"value"} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${i}${r.maximum.toString()} ${a.unit??"elements"}`:`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${r.origin??"value"} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${i}${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${r.origin} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${i}${r.minimum.toString()} ${a.unit}`:`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${r.origin} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${i}${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05E0\u05D4: \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1"${i.prefix}"`:i.format==="ends_with"?`\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05E0\u05D4: \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${i.suffix}"`:i.format==="includes"?`\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05E0\u05D4: \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${i.includes}"`:i.format==="regex"?`\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05E0\u05D4: \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D0\u05D9\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA ${i.pattern}`:`${o[i.format]??r.format} \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF`}case"not_multiple_of":return`\u05DE\u05E1\u05E4\u05E8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05DB\u05E4\u05DC\u05D4 \u05E9\u05DC ${r.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${r.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${r.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${R(r.keys,", ")}`;case"invalid_key":return`\u05DE\u05E4\u05EA\u05D7 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${r.origin}`;case"invalid_union":return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF";case"invalid_element":return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${r.origin}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}}};function Jv(){return{localeError:_0()}}var E0=()=>{let e={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"sz\xE1m";case"object":{if(Array.isArray(r))return"t\xF6mb";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"bemenet",email:"email c\xEDm",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO id\u0151b\xE9lyeg",date:"ISO d\xE1tum",time:"ISO id\u0151",duration:"ISO id\u0151intervallum",ipv4:"IPv4 c\xEDm",ipv6:"IPv6 c\xEDm",cidrv4:"IPv4 tartom\xE1ny",cidrv6:"IPv6 tartom\xE1ny",base64:"base64-k\xF3dolt string",base64url:"base64url-k\xF3dolt string",json_string:"JSON string",e164:"E.164 sz\xE1m",jwt:"JWT",template_literal:"bemenet"};return r=>{switch(r.code){case"invalid_type":return`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${r.expected}, a kapott \xE9rt\xE9k ${n(r.input)}`;case"invalid_value":return r.values.length===1?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${z(r.values[0])}`:`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`T\xFAl nagy: ${r.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${i}${r.maximum.toString()} ${a.unit??"elem"}`:`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${r.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${i}${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${r.origin} m\xE9rete t\xFAl kicsi ${i}${r.minimum.toString()} ${a.unit}`:`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${r.origin} t\xFAl kicsi ${i}${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`\xC9rv\xE9nytelen string: "${i.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`:i.format==="ends_with"?`\xC9rv\xE9nytelen string: "${i.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`:i.format==="includes"?`\xC9rv\xE9nytelen string: "${i.includes}" \xE9rt\xE9ket kell tartalmaznia`:i.format==="regex"?`\xC9rv\xE9nytelen string: ${i.pattern} mint\xE1nak kell megfelelnie`:`\xC9rv\xE9nytelen ${o[i.format]??r.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${r.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${r.keys.length>1?"s":""}: ${R(r.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${r.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${r.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}}};function Qv(){return{localeError:E0()}}var S0=()=>{let e={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"rentang alamat IPv4",cidrv6:"rentang alamat IPv6",base64:"string dengan enkode base64",base64url:"string dengan enkode base64url",json_string:"string JSON",e164:"angka E.164",jwt:"JWT",template_literal:"input"};return r=>{switch(r.code){case"invalid_type":return`Input tidak valid: diharapkan ${r.expected}, diterima ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Input tidak valid: diharapkan ${z(r.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Terlalu besar: diharapkan ${r.origin??"value"} memiliki ${i}${r.maximum.toString()} ${a.unit??"elemen"}`:`Terlalu besar: diharapkan ${r.origin??"value"} menjadi ${i}${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`Terlalu kecil: diharapkan ${r.origin} memiliki ${i}${r.minimum.toString()} ${a.unit}`:`Terlalu kecil: diharapkan ${r.origin} menjadi ${i}${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`String tidak valid: harus dimulai dengan "${i.prefix}"`:i.format==="ends_with"?`String tidak valid: harus berakhir dengan "${i.suffix}"`:i.format==="includes"?`String tidak valid: harus menyertakan "${i.includes}"`:i.format==="regex"?`String tidak valid: harus sesuai pola ${i.pattern}`:`${o[i.format]??r.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${r.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${r.keys.length>1?"s":""}: ${R(r.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${r.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${r.origin}`;default:return"Input tidak valid"}}};function eb(){return{localeError:S0()}}var T0=()=>{let e={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"numero";case"object":{if(Array.isArray(r))return"vettore";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",jwt:"JWT",template_literal:"input"};return r=>{switch(r.code){case"invalid_type":return`Input non valido: atteso ${r.expected}, ricevuto ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Input non valido: atteso ${z(r.values[0])}`:`Opzione non valida: atteso uno tra ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Troppo grande: ${r.origin??"valore"} deve avere ${i}${r.maximum.toString()} ${a.unit??"elementi"}`:`Troppo grande: ${r.origin??"valore"} deve essere ${i}${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`Troppo piccolo: ${r.origin} deve avere ${i}${r.minimum.toString()} ${a.unit}`:`Troppo piccolo: ${r.origin} deve essere ${i}${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`Stringa non valida: deve iniziare con "${i.prefix}"`:i.format==="ends_with"?`Stringa non valida: deve terminare con "${i.suffix}"`:i.format==="includes"?`Stringa non valida: deve includere "${i.includes}"`:i.format==="regex"?`Stringa non valida: deve corrispondere al pattern ${i.pattern}`:`Invalid ${o[i.format]??r.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${r.divisor}`;case"unrecognized_keys":return`Chiav${r.keys.length>1?"i":"e"} non riconosciut${r.keys.length>1?"e":"a"}: ${R(r.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${r.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${r.origin}`;default:return"Input non valido"}}};function tb(){return{localeError:T0()}}var k0=()=>{let e={string:{unit:"\u6587\u5B57",verb:"\u3067\u3042\u308B"},file:{unit:"\u30D0\u30A4\u30C8",verb:"\u3067\u3042\u308B"},array:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"},set:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"\u6570\u5024";case"object":{if(Array.isArray(r))return"\u914D\u5217";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"\u5165\u529B\u5024",email:"\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",url:"URL",emoji:"\u7D75\u6587\u5B57",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u6642",date:"ISO\u65E5\u4ED8",time:"ISO\u6642\u523B",duration:"ISO\u671F\u9593",ipv4:"IPv4\u30A2\u30C9\u30EC\u30B9",ipv6:"IPv6\u30A2\u30C9\u30EC\u30B9",cidrv4:"IPv4\u7BC4\u56F2",cidrv6:"IPv6\u7BC4\u56F2",base64:"base64\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",base64url:"base64url\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",json_string:"JSON\u6587\u5B57\u5217",e164:"E.164\u756A\u53F7",jwt:"JWT",template_literal:"\u5165\u529B\u5024"};return r=>{switch(r.code){case"invalid_type":return`\u7121\u52B9\u306A\u5165\u529B: ${r.expected}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${n(r.input)}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`;case"invalid_value":return r.values.length===1?`\u7121\u52B9\u306A\u5165\u529B: ${z(r.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u9078\u629E: ${R(r.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let i=r.inclusive?"\u4EE5\u4E0B\u3067\u3042\u308B":"\u3088\u308A\u5C0F\u3055\u3044",a=t(r.origin);return a?`\u5927\u304D\u3059\u304E\u308B\u5024: ${r.origin??"\u5024"}\u306F${r.maximum.toString()}${a.unit??"\u8981\u7D20"}${i}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5927\u304D\u3059\u304E\u308B\u5024: ${r.origin??"\u5024"}\u306F${r.maximum.toString()}${i}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let i=r.inclusive?"\u4EE5\u4E0A\u3067\u3042\u308B":"\u3088\u308A\u5927\u304D\u3044",a=t(r.origin);return a?`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${r.origin}\u306F${r.minimum.toString()}${a.unit}${i}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${r.origin}\u306F${r.minimum.toString()}${i}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let i=r;return i.format==="starts_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${i.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:i.format==="ends_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${i.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:i.format==="includes"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${i.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:i.format==="regex"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${i.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u7121\u52B9\u306A${o[i.format]??r.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${r.divisor}\u306E\u500D\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"unrecognized_keys":return`\u8A8D\u8B58\u3055\u308C\u3066\u3044\u306A\u3044\u30AD\u30FC${r.keys.length>1?"\u7FA4":""}: ${R(r.keys,"\u3001")}`;case"invalid_key":return`${r.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${r.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}}};function nb(){return{localeError:k0()}}var I0=()=>{let e={string:{unit:"\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},file:{unit:"\u1794\u17C3",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},array:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},set:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"\u1798\u17B7\u1793\u1798\u17C2\u1793\u1787\u17B6\u179B\u17C1\u1781 (NaN)":"\u179B\u17C1\u1781";case"object":{if(Array.isArray(r))return"\u17A2\u17B6\u179A\u17C1 (Array)";if(r===null)return"\u1782\u17D2\u1798\u17B6\u1793\u178F\u1798\u17D2\u179B\u17C3 (null)";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B",email:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793\u17A2\u17CA\u17B8\u1798\u17C2\u179B",url:"URL",emoji:"\u179F\u1789\u17D2\u1789\u17B6\u17A2\u17B6\u179A\u1798\u17D2\u1798\u178E\u17CD",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 \u1793\u17B7\u1784\u1798\u17C9\u17C4\u1784 ISO",date:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 ISO",time:"\u1798\u17C9\u17C4\u1784 ISO",duration:"\u179A\u1799\u17C8\u1796\u17C1\u179B ISO",ipv4:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",ipv6:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",cidrv4:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",cidrv6:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",base64:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64",base64url:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64url",json_string:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A JSON",e164:"\u179B\u17C1\u1781 E.164",jwt:"JWT",template_literal:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B"};return r=>{switch(r.code){case"invalid_type":return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.expected} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${n(r.input)}`;case"invalid_value":return r.values.length===1?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${z(r.values[0])}`:`\u1787\u1798\u17D2\u179A\u17BE\u179F\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1787\u17B6\u1798\u17BD\u1799\u1780\u17D2\u1793\u17BB\u1784\u1785\u17C6\u178E\u17C4\u1798 ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${i} ${r.maximum.toString()} ${a.unit??"\u1792\u17B6\u178F\u17BB"}`:`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${i} ${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.origin} ${i} ${r.minimum.toString()} ${a.unit}`:`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.origin} ${i} ${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1785\u17B6\u1794\u17CB\u1795\u17D2\u178F\u17BE\u1798\u178A\u17C4\u1799 "${i.prefix}"`:i.format==="ends_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1794\u1789\u17D2\u1785\u1794\u17CB\u178A\u17C4\u1799 "${i.suffix}"`:i.format==="includes"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1798\u17B6\u1793 "${i.includes}"`:i.format==="regex"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1795\u17D2\u1782\u17BC\u1795\u17D2\u1782\u1784\u1793\u17B9\u1784\u1791\u1798\u17D2\u179A\u1784\u17CB\u178A\u17C2\u179B\u1794\u17B6\u1793\u1780\u17C6\u178E\u178F\u17CB ${i.pattern}`:`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${o[i.format]??r.format}`}case"not_multiple_of":return`\u179B\u17C1\u1781\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1787\u17B6\u1796\u17A0\u17BB\u1782\u17BB\u178E\u1793\u17C3 ${r.divisor}`;case"unrecognized_keys":return`\u179A\u1780\u1783\u17BE\u1789\u179F\u17C4\u1798\u17B7\u1793\u179F\u17D2\u1782\u17B6\u179B\u17CB\u17D6 ${R(r.keys,", ")}`;case"invalid_key":return`\u179F\u17C4\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${r.origin}`;case"invalid_union":return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C";case"invalid_element":return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${r.origin}`;default:return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C"}}};function rb(){return{localeError:I0()}}var A0=()=>{let e={string:{unit:"\uBB38\uC790",verb:"to have"},file:{unit:"\uBC14\uC774\uD2B8",verb:"to have"},array:{unit:"\uAC1C",verb:"to have"},set:{unit:"\uAC1C",verb:"to have"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"\uC785\uB825",email:"\uC774\uBA54\uC77C \uC8FC\uC18C",url:"URL",emoji:"\uC774\uBAA8\uC9C0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \uB0A0\uC9DC\uC2DC\uAC04",date:"ISO \uB0A0\uC9DC",time:"ISO \uC2DC\uAC04",duration:"ISO \uAE30\uAC04",ipv4:"IPv4 \uC8FC\uC18C",ipv6:"IPv6 \uC8FC\uC18C",cidrv4:"IPv4 \uBC94\uC704",cidrv6:"IPv6 \uBC94\uC704",base64:"base64 \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",base64url:"base64url \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",json_string:"JSON \uBB38\uC790\uC5F4",e164:"E.164 \uBC88\uD638",jwt:"JWT",template_literal:"\uC785\uB825"};return r=>{switch(r.code){case"invalid_type":return`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${r.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${n(r.input)}\uC785\uB2C8\uB2E4`;case"invalid_value":return r.values.length===1?`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${z(r.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC635\uC158: ${R(r.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let i=r.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",a=i==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",s=t(r.origin),u=s?.unit??"\uC694\uC18C";return s?`${r.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${r.maximum.toString()}${u} ${i}${a}`:`${r.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${r.maximum.toString()} ${i}${a}`}case"too_small":{let i=r.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",a=i==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",s=t(r.origin),u=s?.unit??"\uC694\uC18C";return s?`${r.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${r.minimum.toString()}${u} ${i}${a}`:`${r.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${r.minimum.toString()} ${i}${a}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${i.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`:i.format==="ends_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${i.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`:i.format==="includes"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${i.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`:i.format==="regex"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${i.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C ${o[i.format]??r.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${r.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${R(r.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${r.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${r.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}}};function ob(){return{localeError:A0()}}var R0=()=>{let e={string:{unit:"\u0437\u043D\u0430\u0446\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},file:{unit:"\u0431\u0430\u0458\u0442\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},array:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},set:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"\u0431\u0440\u043E\u0458";case"object":{if(Array.isArray(r))return"\u043D\u0438\u0437\u0430";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"\u0432\u043D\u0435\u0441",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u043D\u0430 \u0435-\u043F\u043E\u0448\u0442\u0430",url:"URL",emoji:"\u0435\u043C\u043E\u045F\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0443\u043C \u0438 \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0443\u043C",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u0432\u0440\u0435\u043C\u0435\u0442\u0440\u0430\u0435\u045A\u0435",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441\u0430",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441\u0430",cidrv4:"IPv4 \u043E\u043F\u0441\u0435\u0433",cidrv6:"IPv6 \u043E\u043F\u0441\u0435\u0433",base64:"base64-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",base64url:"base64url-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",json_string:"JSON \u043D\u0438\u0437\u0430",e164:"E.164 \u0431\u0440\u043E\u0458",jwt:"JWT",template_literal:"\u0432\u043D\u0435\u0441"};return r=>{switch(r.code){case"invalid_type":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.expected}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Invalid input: expected ${z(r.values[0])}`:`\u0413\u0440\u0435\u0448\u0430\u043D\u0430 \u043E\u043F\u0446\u0438\u0458\u0430: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 \u0435\u0434\u043D\u0430 ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${i}${r.maximum.toString()} ${a.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438"}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${i}${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.origin} \u0434\u0430 \u0438\u043C\u0430 ${i}${r.minimum.toString()} ${a.unit}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${i}${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u043D\u0443\u0432\u0430 \u0441\u043E "${i.prefix}"`:i.format==="ends_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u0432\u0440\u0448\u0443\u0432\u0430 \u0441\u043E "${i.suffix}"`:i.format==="includes"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0432\u043A\u043B\u0443\u0447\u0443\u0432\u0430 "${i.includes}"`:i.format==="regex"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u043E\u0434\u0433\u043E\u0430\u0440\u0430 \u043D\u0430 \u043F\u0430\u0442\u0435\u0440\u043D\u043E\u0442 ${i.pattern}`:`Invalid ${o[i.format]??r.format}`}case"not_multiple_of":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0431\u0440\u043E\u0458: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0431\u0438\u0434\u0435 \u0434\u0435\u043B\u0438\u0432 \u0441\u043E ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D\u0438 \u043A\u043B\u0443\u0447\u0435\u0432\u0438":"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D \u043A\u043B\u0443\u0447"}: ${R(r.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${r.origin}`;case"invalid_union":return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441";case"invalid_element":return`\u0413\u0440\u0435\u0448\u043D\u0430 \u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442 \u0432\u043E ${r.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}}};function ib(){return{localeError:R0()}}var C0=()=>{let e={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"nombor";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",jwt:"JWT",template_literal:"input"};return r=>{switch(r.code){case"invalid_type":return`Input tidak sah: dijangka ${r.expected}, diterima ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Input tidak sah: dijangka ${z(r.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Terlalu besar: dijangka ${r.origin??"nilai"} ${a.verb} ${i}${r.maximum.toString()} ${a.unit??"elemen"}`:`Terlalu besar: dijangka ${r.origin??"nilai"} adalah ${i}${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`Terlalu kecil: dijangka ${r.origin} ${a.verb} ${i}${r.minimum.toString()} ${a.unit}`:`Terlalu kecil: dijangka ${r.origin} adalah ${i}${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`String tidak sah: mesti bermula dengan "${i.prefix}"`:i.format==="ends_with"?`String tidak sah: mesti berakhir dengan "${i.suffix}"`:i.format==="includes"?`String tidak sah: mesti mengandungi "${i.includes}"`:i.format==="regex"?`String tidak sah: mesti sepadan dengan corak ${i.pattern}`:`${o[i.format]??r.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${r.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${R(r.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${r.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${r.origin}`;default:return"Input tidak sah"}}};function ab(){return{localeError:C0()}}var N0=()=>{let e={string:{unit:"tekens"},file:{unit:"bytes"},array:{unit:"elementen"},set:{unit:"elementen"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"getal";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",jwt:"JWT",template_literal:"invoer"};return r=>{switch(r.code){case"invalid_type":return`Ongeldige invoer: verwacht ${r.expected}, ontving ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Ongeldige invoer: verwacht ${z(r.values[0])}`:`Ongeldige optie: verwacht \xE9\xE9n van ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Te lang: verwacht dat ${r.origin??"waarde"} ${i}${r.maximum.toString()} ${a.unit??"elementen"} bevat`:`Te lang: verwacht dat ${r.origin??"waarde"} ${i}${r.maximum.toString()} is`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`Te kort: verwacht dat ${r.origin} ${i}${r.minimum.toString()} ${a.unit} bevat`:`Te kort: verwacht dat ${r.origin} ${i}${r.minimum.toString()} is`}case"invalid_format":{let i=r;return i.format==="starts_with"?`Ongeldige tekst: moet met "${i.prefix}" beginnen`:i.format==="ends_with"?`Ongeldige tekst: moet op "${i.suffix}" eindigen`:i.format==="includes"?`Ongeldige tekst: moet "${i.includes}" bevatten`:i.format==="regex"?`Ongeldige tekst: moet overeenkomen met patroon ${i.pattern}`:`Ongeldig: ${o[i.format]??r.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${r.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${r.keys.length>1?"s":""}: ${R(r.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${r.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${r.origin}`;default:return"Ongeldige invoer"}}};function sb(){return{localeError:N0()}}var O0=()=>{let e={string:{unit:"tegn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"elementer",verb:"\xE5 inneholde"},set:{unit:"elementer",verb:"\xE5 inneholde"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"tall";case"object":{if(Array.isArray(r))return"liste";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"};return r=>{switch(r.code){case"invalid_type":return`Ugyldig input: forventet ${r.expected}, fikk ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Ugyldig verdi: forventet ${z(r.values[0])}`:`Ugyldig valg: forventet en av ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`For stor(t): forventet ${r.origin??"value"} til \xE5 ha ${i}${r.maximum.toString()} ${a.unit??"elementer"}`:`For stor(t): forventet ${r.origin??"value"} til \xE5 ha ${i}${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`For lite(n): forventet ${r.origin} til \xE5 ha ${i}${r.minimum.toString()} ${a.unit}`:`For lite(n): forventet ${r.origin} til \xE5 ha ${i}${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${i.prefix}"`:i.format==="ends_with"?`Ugyldig streng: m\xE5 ende med "${i.suffix}"`:i.format==="includes"?`Ugyldig streng: m\xE5 inneholde "${i.includes}"`:i.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${i.pattern}`:`Ugyldig ${o[i.format]??r.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${R(r.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${r.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${r.origin}`;default:return"Ugyldig input"}}};function lb(){return{localeError:O0()}}var $0=()=>{let e={string:{unit:"harf",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"unsur",verb:"olmal\u0131d\u0131r"},set:{unit:"unsur",verb:"olmal\u0131d\u0131r"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"numara";case"object":{if(Array.isArray(r))return"saf";if(r===null)return"gayb";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"giren",email:"epostag\xE2h",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO heng\xE2m\u0131",date:"ISO tarihi",time:"ISO zaman\u0131",duration:"ISO m\xFCddeti",ipv4:"IPv4 ni\u015F\xE2n\u0131",ipv6:"IPv6 ni\u015F\xE2n\u0131",cidrv4:"IPv4 menzili",cidrv6:"IPv6 menzili",base64:"base64-\u015Fifreli metin",base64url:"base64url-\u015Fifreli metin",json_string:"JSON metin",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"giren"};return r=>{switch(r.code){case"invalid_type":return`F\xE2sit giren: umulan ${r.expected}, al\u0131nan ${n(r.input)}`;case"invalid_value":return r.values.length===1?`F\xE2sit giren: umulan ${z(r.values[0])}`:`F\xE2sit tercih: m\xFBteberler ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Fazla b\xFCy\xFCk: ${r.origin??"value"}, ${i}${r.maximum.toString()} ${a.unit??"elements"} sahip olmal\u0131yd\u0131.`:`Fazla b\xFCy\xFCk: ${r.origin??"value"}, ${i}${r.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`Fazla k\xFC\xE7\xFCk: ${r.origin}, ${i}${r.minimum.toString()} ${a.unit} sahip olmal\u0131yd\u0131.`:`Fazla k\xFC\xE7\xFCk: ${r.origin}, ${i}${r.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let i=r;return i.format==="starts_with"?`F\xE2sit metin: "${i.prefix}" ile ba\u015Flamal\u0131.`:i.format==="ends_with"?`F\xE2sit metin: "${i.suffix}" ile bitmeli.`:i.format==="includes"?`F\xE2sit metin: "${i.includes}" ihtiv\xE2 etmeli.`:i.format==="regex"?`F\xE2sit metin: ${i.pattern} nak\u015F\u0131na uymal\u0131.`:`F\xE2sit ${o[i.format]??r.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${r.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${r.keys.length>1?"s":""}: ${R(r.keys,", ")}`;case"invalid_key":return`${r.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${r.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}}};function ub(){return{localeError:$0()}}var P0=()=>{let e={string:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},file:{unit:"\u0628\u0627\u06CC\u067C\u0633",verb:"\u0648\u0644\u0631\u064A"},array:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},set:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"\u0639\u062F\u062F";case"object":{if(Array.isArray(r))return"\u0627\u0631\u06D0";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"\u0648\u0631\u0648\u062F\u064A",email:"\u0628\u0631\u06CC\u069A\u0646\u0627\u0644\u06CC\u06A9",url:"\u06CC\u0648 \u0622\u0631 \u0627\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0646\u06CC\u067C\u0647 \u0627\u0648 \u0648\u062E\u062A",date:"\u0646\u06D0\u067C\u0647",time:"\u0648\u062E\u062A",duration:"\u0645\u0648\u062F\u0647",ipv4:"\u062F IPv4 \u067E\u062A\u0647",ipv6:"\u062F IPv6 \u067E\u062A\u0647",cidrv4:"\u062F IPv4 \u0633\u0627\u062D\u0647",cidrv6:"\u062F IPv6 \u0633\u0627\u062D\u0647",base64:"base64-encoded \u0645\u062A\u0646",base64url:"base64url-encoded \u0645\u062A\u0646",json_string:"JSON \u0645\u062A\u0646",e164:"\u062F E.164 \u0634\u0645\u06D0\u0631\u0647",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u064A"};return r=>{switch(r.code){case"invalid_type":return`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${r.expected} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${n(r.input)} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`;case"invalid_value":return r.values.length===1?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${z(r.values[0])} \u0648\u0627\u06CC`:`\u0646\u0627\u0633\u0645 \u0627\u0646\u062A\u062E\u0627\u0628: \u0628\u0627\u06CC\u062F \u06CC\u0648 \u0644\u0647 ${R(r.values,"|")} \u0685\u062E\u0647 \u0648\u0627\u06CC`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${r.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${i}${r.maximum.toString()} ${a.unit??"\u0639\u0646\u0635\u0631\u0648\u0646\u0647"} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${r.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${i}${r.maximum.toString()} \u0648\u064A`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${r.origin} \u0628\u0627\u06CC\u062F ${i}${r.minimum.toString()} ${a.unit} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${r.origin} \u0628\u0627\u06CC\u062F ${i}${r.minimum.toString()} \u0648\u064A`}case"invalid_format":{let i=r;return i.format==="starts_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${i.prefix}" \u0633\u0631\u0647 \u067E\u06CC\u0644 \u0634\u064A`:i.format==="ends_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${i.suffix}" \u0633\u0631\u0647 \u067E\u0627\u06CC \u062A\u0647 \u0648\u0631\u0633\u064A\u0696\u064A`:i.format==="includes"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F "${i.includes}" \u0648\u0644\u0631\u064A`:i.format==="regex"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F ${i.pattern} \u0633\u0631\u0647 \u0645\u0637\u0627\u0628\u0642\u062A \u0648\u0644\u0631\u064A`:`${o[i.format]??r.format} \u0646\u0627\u0633\u0645 \u062F\u06CC`}case"not_multiple_of":return`\u0646\u0627\u0633\u0645 \u0639\u062F\u062F: \u0628\u0627\u06CC\u062F \u062F ${r.divisor} \u0645\u0636\u0631\u0628 \u0648\u064A`;case"unrecognized_keys":return`\u0646\u0627\u0633\u0645 ${r.keys.length>1?"\u06A9\u0644\u06CC\u0689\u0648\u0646\u0647":"\u06A9\u0644\u06CC\u0689"}: ${R(r.keys,", ")}`;case"invalid_key":return`\u0646\u0627\u0633\u0645 \u06A9\u0644\u06CC\u0689 \u067E\u0647 ${r.origin} \u06A9\u06D0`;case"invalid_union":return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A";case"invalid_element":return`\u0646\u0627\u0633\u0645 \u0639\u0646\u0635\u0631 \u067E\u0647 ${r.origin} \u06A9\u06D0`;default:return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A"}}};function cb(){return{localeError:P0()}}var M0=()=>{let e={string:{unit:"znak\xF3w",verb:"mie\u0107"},file:{unit:"bajt\xF3w",verb:"mie\u0107"},array:{unit:"element\xF3w",verb:"mie\u0107"},set:{unit:"element\xF3w",verb:"mie\u0107"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"liczba";case"object":{if(Array.isArray(r))return"tablica";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"wyra\u017Cenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",cidrv4:"zakres IPv4",cidrv6:"zakres IPv6",base64:"ci\u0105g znak\xF3w zakodowany w formacie base64",base64url:"ci\u0105g znak\xF3w zakodowany w formacie base64url",json_string:"ci\u0105g znak\xF3w w formacie JSON",e164:"liczba E.164",jwt:"JWT",template_literal:"wej\u015Bcie"};return r=>{switch(r.code){case"invalid_type":return`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${r.expected}, otrzymano ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${z(r.values[0])}`:`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${r.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${i}${r.maximum.toString()} ${a.unit??"element\xF3w"}`:`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${r.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${i}${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${r.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${i}${r.minimum.toString()} ${a.unit??"element\xF3w"}`:`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${r.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${i}${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${i.prefix}"`:i.format==="ends_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${i.suffix}"`:i.format==="includes"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${i.includes}"`:i.format==="regex"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${i.pattern}`:`Nieprawid\u0142ow(y/a/e) ${o[i.format]??r.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${r.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${r.keys.length>1?"s":""}: ${R(r.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${r.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${r.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}}};function db(){return{localeError:M0()}}var L0=()=>{let e={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"n\xFAmero";case"object":{if(Array.isArray(r))return"array";if(r===null)return"nulo";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"padr\xE3o",email:"endere\xE7o de e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e hora ISO",date:"data ISO",time:"hora ISO",duration:"dura\xE7\xE3o ISO",ipv4:"endere\xE7o IPv4",ipv6:"endere\xE7o IPv6",cidrv4:"faixa de IPv4",cidrv6:"faixa de IPv6",base64:"texto codificado em base64",base64url:"URL codificada em base64",json_string:"texto JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"};return r=>{switch(r.code){case"invalid_type":return`Tipo inv\xE1lido: esperado ${r.expected}, recebido ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Entrada inv\xE1lida: esperado ${z(r.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperada uma das ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Muito grande: esperado que ${r.origin??"valor"} tivesse ${i}${r.maximum.toString()} ${a.unit??"elementos"}`:`Muito grande: esperado que ${r.origin??"valor"} fosse ${i}${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`Muito pequeno: esperado que ${r.origin} tivesse ${i}${r.minimum.toString()} ${a.unit}`:`Muito pequeno: esperado que ${r.origin} fosse ${i}${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar com "${i.prefix}"`:i.format==="ends_with"?`Texto inv\xE1lido: deve terminar com "${i.suffix}"`:i.format==="includes"?`Texto inv\xE1lido: deve incluir "${i.includes}"`:i.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${i.pattern}`:`${o[i.format]??r.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${r.divisor}`;case"unrecognized_keys":return`Chave${r.keys.length>1?"s":""} desconhecida${r.keys.length>1?"s":""}: ${R(r.keys,", ")}`;case"invalid_key":return`Chave inv\xE1lida em ${r.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido em ${r.origin}`;default:return"Campo inv\xE1lido"}}};function pb(){return{localeError:L0()}}function hb(e,t,n,o){let r=Math.abs(e),i=r%10,a=r%100;return a>=11&&a<=19?o:i===1?t:i>=2&&i<=4?n:o}var z0=()=>{let e={string:{unit:{one:"\u0441\u0438\u043C\u0432\u043E\u043B",few:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",many:"\u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u0430",many:"\u0431\u0430\u0439\u0442"},verb:"\u0438\u043C\u0435\u0442\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"\u0447\u0438\u0441\u043B\u043E";case"object":{if(Array.isArray(r))return"\u043C\u0430\u0441\u0441\u0438\u0432";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"\u0432\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043C\u044F",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u044F",duration:"ISO \u0434\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64",base64url:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64url",json_string:"JSON \u0441\u0442\u0440\u043E\u043A\u0430",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0432\u043E\u0434"};return r=>{switch(r.code){case"invalid_type":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${r.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${n(r.input)}`;case"invalid_value":return r.values.length===1?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${z(r.values[0])}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0430\u0440\u0438\u0430\u043D\u0442: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0434\u043D\u043E \u0438\u0437 ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);if(a){let s=Number(r.maximum),u=hb(s,a.unit.one,a.unit.few,a.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${i}${r.maximum.toString()} ${u}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${i}${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);if(a){let s=Number(r.minimum),u=hb(s,a.unit.one,a.unit.few,a.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${r.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${i}${r.minimum.toString()} ${u}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${r.origin} \u0431\u0443\u0434\u0435\u0442 ${i}${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u043D\u0430\u0447\u0438\u043D\u0430\u0442\u044C\u0441\u044F \u0441 "${i.prefix}"`:i.format==="ends_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0437\u0430\u043A\u0430\u043D\u0447\u0438\u0432\u0430\u0442\u044C\u0441\u044F \u043D\u0430 "${i.suffix}"`:i.format==="includes"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C "${i.includes}"`:i.format==="regex"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${i.pattern}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${o[i.format]??r.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0447\u0438\u0441\u043B\u043E: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${r.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${r.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${r.keys.length>1?"\u0438":""}: ${R(r.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${r.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435";case"invalid_element":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0432 ${r.origin}`;default:return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435"}}};function fb(){return{localeError:z0()}}var D0=()=>{let e={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"\u0161tevilo";case"object":{if(Array.isArray(r))return"tabela";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"vnos",email:"e-po\u0161tni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in \u010Das",date:"ISO datum",time:"ISO \u010Das",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 \u0161tevilka",jwt:"JWT",template_literal:"vnos"};return r=>{switch(r.code){case"invalid_type":return`Neveljaven vnos: pri\u010Dakovano ${r.expected}, prejeto ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Neveljaven vnos: pri\u010Dakovano ${z(r.values[0])}`:`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Preveliko: pri\u010Dakovano, da bo ${r.origin??"vrednost"} imelo ${i}${r.maximum.toString()} ${a.unit??"elementov"}`:`Preveliko: pri\u010Dakovano, da bo ${r.origin??"vrednost"} ${i}${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`Premajhno: pri\u010Dakovano, da bo ${r.origin} imelo ${i}${r.minimum.toString()} ${a.unit}`:`Premajhno: pri\u010Dakovano, da bo ${r.origin} ${i}${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`Neveljaven niz: mora se za\u010Deti z "${i.prefix}"`:i.format==="ends_with"?`Neveljaven niz: mora se kon\u010Dati z "${i.suffix}"`:i.format==="includes"?`Neveljaven niz: mora vsebovati "${i.includes}"`:i.format==="regex"?`Neveljaven niz: mora ustrezati vzorcu ${i.pattern}`:`Neveljaven ${o[i.format]??r.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${r.divisor}`;case"unrecognized_keys":return`Neprepoznan${r.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${R(r.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${r.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${r.origin}`;default:return"Neveljaven vnos"}}};function mb(){return{localeError:D0()}}var U0=()=>{let e={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att inneh\xE5lla"},set:{unit:"objekt",verb:"att inneh\xE5lla"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"antal";case"object":{if(Array.isArray(r))return"lista";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"regulj\xE4rt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-intervall",ipv6:"IPv6-intervall",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodad str\xE4ng",base64url:"base64url-kodad str\xE4ng",json_string:"JSON-str\xE4ng",e164:"E.164-nummer",jwt:"JWT",template_literal:"mall-literal"};return r=>{switch(r.code){case"invalid_type":return`Ogiltig inmatning: f\xF6rv\xE4ntat ${r.expected}, fick ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Ogiltig inmatning: f\xF6rv\xE4ntat ${z(r.values[0])}`:`Ogiltigt val: f\xF6rv\xE4ntade en av ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`F\xF6r stor(t): f\xF6rv\xE4ntade ${r.origin??"v\xE4rdet"} att ha ${i}${r.maximum.toString()} ${a.unit??"element"}`:`F\xF6r stor(t): f\xF6rv\xE4ntat ${r.origin??"v\xE4rdet"} att ha ${i}${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`F\xF6r lite(t): f\xF6rv\xE4ntade ${r.origin??"v\xE4rdet"} att ha ${i}${r.minimum.toString()} ${a.unit}`:`F\xF6r lite(t): f\xF6rv\xE4ntade ${r.origin??"v\xE4rdet"} att ha ${i}${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${i.prefix}"`:i.format==="ends_with"?`Ogiltig str\xE4ng: m\xE5ste sluta med "${i.suffix}"`:i.format==="includes"?`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${i.includes}"`:i.format==="regex"?`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${i.pattern}"`:`Ogiltig(t) ${o[i.format]??r.format}`}case"not_multiple_of":return`Ogiltigt tal: m\xE5ste vara en multipel av ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Ok\xE4nda nycklar":"Ok\xE4nd nyckel"}: ${R(r.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${r.origin??"v\xE4rdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt v\xE4rde i ${r.origin??"v\xE4rdet"}`;default:return"Ogiltig input"}}};function gb(){return{localeError:U0()}}var j0=()=>{let e={string:{unit:"\u0B8E\u0BB4\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0B95\u0BCD\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},file:{unit:"\u0BAA\u0BC8\u0B9F\u0BCD\u0B9F\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},array:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},set:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"\u0B8E\u0BA3\u0BCD \u0B85\u0BB2\u0BCD\u0BB2\u0BBE\u0BA4\u0BA4\u0BC1":"\u0B8E\u0BA3\u0BCD";case"object":{if(Array.isArray(r))return"\u0B85\u0BA3\u0BBF";if(r===null)return"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"\u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1",email:"\u0BAE\u0BBF\u0BA9\u0BCD\u0BA9\u0B9E\u0BCD\u0B9A\u0BB2\u0BCD \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0BA4\u0BC7\u0BA4\u0BBF \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",date:"ISO \u0BA4\u0BC7\u0BA4\u0BBF",time:"ISO \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",duration:"ISO \u0B95\u0BBE\u0BB2 \u0B85\u0BB3\u0BB5\u0BC1",ipv4:"IPv4 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",ipv6:"IPv6 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",cidrv4:"IPv4 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",cidrv6:"IPv6 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",base64:"base64-encoded \u0B9A\u0BB0\u0BAE\u0BCD",base64url:"base64url-encoded \u0B9A\u0BB0\u0BAE\u0BCD",json_string:"JSON \u0B9A\u0BB0\u0BAE\u0BCD",e164:"E.164 \u0B8E\u0BA3\u0BCD",jwt:"JWT",template_literal:"input"};return r=>{switch(r.code){case"invalid_type":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.expected}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n(r.input)}`;case"invalid_value":return r.values.length===1?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${z(r.values[0])}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0BB0\u0BC1\u0BAA\u0BCD\u0BAA\u0BAE\u0BCD: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${R(r.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${i}${r.maximum.toString()} ${a.unit??"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD"} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${i}${r.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.origin} ${i}${r.minimum.toString()} ${a.unit} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.origin} ${i}${r.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let i=r;return i.format==="starts_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${i.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:i.format==="ends_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${i.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:i.format==="includes"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${i.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:i.format==="regex"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${i.pattern} \u0BAE\u0BC1\u0BB1\u0BC8\u0BAA\u0BBE\u0B9F\u0BCD\u0B9F\u0BC1\u0B9F\u0BA9\u0BCD \u0BAA\u0BCA\u0BB0\u0BC1\u0BA8\u0BCD\u0BA4 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 ${o[i.format]??r.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${r.divisor} \u0B87\u0BA9\u0BCD \u0BAA\u0BB2\u0BAE\u0BBE\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;case"unrecognized_keys":return`\u0B85\u0B9F\u0BC8\u0BAF\u0BBE\u0BB3\u0BAE\u0BCD \u0BA4\u0BC6\u0BB0\u0BBF\u0BAF\u0BBE\u0BA4 \u0BB5\u0BBF\u0B9A\u0BC8${r.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${R(r.keys,", ")}`;case"invalid_key":return`${r.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0B9A\u0BC8`;case"invalid_union":return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1";case"invalid_element":return`${r.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1`;default:return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1"}}};function vb(){return{localeError:j0()}}var H0=()=>{let e={string:{unit:"\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},file:{unit:"\u0E44\u0E1A\u0E15\u0E4C",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},array:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},set:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"\u0E44\u0E21\u0E48\u0E43\u0E0A\u0E48\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02 (NaN)":"\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02";case"object":{if(Array.isArray(r))return"\u0E2D\u0E32\u0E23\u0E4C\u0E40\u0E23\u0E22\u0E4C (Array)";if(r===null)return"\u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32 (null)";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19",email:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E2D\u0E35\u0E40\u0E21\u0E25",url:"URL",emoji:"\u0E2D\u0E34\u0E42\u0E21\u0E08\u0E34",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",date:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E41\u0E1A\u0E1A ISO",time:"\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",duration:"\u0E0A\u0E48\u0E27\u0E07\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",ipv4:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv4",ipv6:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv6",cidrv4:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv4",cidrv6:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv6",base64:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64",base64url:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64 \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A URL",json_string:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A JSON",e164:"\u0E40\u0E1A\u0E2D\u0E23\u0E4C\u0E42\u0E17\u0E23\u0E28\u0E31\u0E1E\u0E17\u0E4C\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07\u0E1B\u0E23\u0E30\u0E40\u0E17\u0E28 (E.164)",jwt:"\u0E42\u0E17\u0E40\u0E04\u0E19 JWT",template_literal:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19"};return r=>{switch(r.code){case"invalid_type":return`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${r.expected} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${n(r.input)}`;case"invalid_value":return r.values.length===1?`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${z(r.values[0])}`:`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19\u0E2B\u0E19\u0E36\u0E48\u0E07\u0E43\u0E19 ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",a=t(r.origin);return a?`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${r.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${i} ${r.maximum.toString()} ${a.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`:`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${r.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${i} ${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",a=t(r.origin);return a?`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${r.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${i} ${r.minimum.toString()} ${a.unit}`:`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${r.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${i} ${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E02\u0E36\u0E49\u0E19\u0E15\u0E49\u0E19\u0E14\u0E49\u0E27\u0E22 "${i.prefix}"`:i.format==="ends_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E25\u0E07\u0E17\u0E49\u0E32\u0E22\u0E14\u0E49\u0E27\u0E22 "${i.suffix}"`:i.format==="includes"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35 "${i.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`:i.format==="regex"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 ${i.pattern}`:`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${o[i.format]??r.format}`}case"not_multiple_of":return`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E08\u0E33\u0E19\u0E27\u0E19\u0E17\u0E35\u0E48\u0E2B\u0E32\u0E23\u0E14\u0E49\u0E27\u0E22 ${r.divisor} \u0E44\u0E14\u0E49\u0E25\u0E07\u0E15\u0E31\u0E27`;case"unrecognized_keys":return`\u0E1E\u0E1A\u0E04\u0E35\u0E22\u0E4C\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E23\u0E39\u0E49\u0E08\u0E31\u0E01: ${R(r.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${r.origin}`;case"invalid_union":return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E22\u0E39\u0E40\u0E19\u0E35\u0E22\u0E19\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49";case"invalid_element":return`\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${r.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}}};function bb(){return{localeError:H0()}}var G0=e=>{let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"number";case"object":{if(Array.isArray(e))return"array";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},F0=()=>{let e={string:{unit:"karakter",verb:"olmal\u0131"},file:{unit:"bayt",verb:"olmal\u0131"},array:{unit:"\xF6\u011Fe",verb:"olmal\u0131"},set:{unit:"\xF6\u011Fe",verb:"olmal\u0131"}};function t(o){return e[o]??null}let n={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO s\xFCre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",cidrv4:"IPv4 aral\u0131\u011F\u0131",cidrv6:"IPv6 aral\u0131\u011F\u0131",base64:"base64 ile \u015Fifrelenmi\u015F metin",base64url:"base64url ile \u015Fifrelenmi\u015F metin",json_string:"JSON dizesi",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"\u015Eablon dizesi"};return o=>{switch(o.code){case"invalid_type":return`Ge\xE7ersiz de\u011Fer: beklenen ${o.expected}, al\u0131nan ${G0(o.input)}`;case"invalid_value":return o.values.length===1?`Ge\xE7ersiz de\u011Fer: beklenen ${z(o.values[0])}`:`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${R(o.values,"|")}`;case"too_big":{let r=o.inclusive?"<=":"<",i=t(o.origin);return i?`\xC7ok b\xFCy\xFCk: beklenen ${o.origin??"de\u011Fer"} ${r}${o.maximum.toString()} ${i.unit??"\xF6\u011Fe"}`:`\xC7ok b\xFCy\xFCk: beklenen ${o.origin??"de\u011Fer"} ${r}${o.maximum.toString()}`}case"too_small":{let r=o.inclusive?">=":">",i=t(o.origin);return i?`\xC7ok k\xFC\xE7\xFCk: beklenen ${o.origin} ${r}${o.minimum.toString()} ${i.unit}`:`\xC7ok k\xFC\xE7\xFCk: beklenen ${o.origin} ${r}${o.minimum.toString()}`}case"invalid_format":{let r=o;return r.format==="starts_with"?`Ge\xE7ersiz metin: "${r.prefix}" ile ba\u015Flamal\u0131`:r.format==="ends_with"?`Ge\xE7ersiz metin: "${r.suffix}" ile bitmeli`:r.format==="includes"?`Ge\xE7ersiz metin: "${r.includes}" i\xE7ermeli`:r.format==="regex"?`Ge\xE7ersiz metin: ${r.pattern} desenine uymal\u0131`:`Ge\xE7ersiz ${n[r.format]??o.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${o.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${o.keys.length>1?"lar":""}: ${R(o.keys,", ")}`;case"invalid_key":return`${o.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${o.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}}};function yb(){return{localeError:F0()}}var V0=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},file:{unit:"\u0431\u0430\u0439\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"\u0447\u0438\u0441\u043B\u043E";case"object":{if(Array.isArray(r))return"\u043C\u0430\u0441\u0438\u0432";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u0435\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u043E\u0457 \u043F\u043E\u0448\u0442\u0438",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0434\u0430\u0442\u0430 \u0442\u0430 \u0447\u0430\u0441 ISO",date:"\u0434\u0430\u0442\u0430 ISO",time:"\u0447\u0430\u0441 ISO",duration:"\u0442\u0440\u0438\u0432\u0430\u043B\u0456\u0441\u0442\u044C ISO",ipv4:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv4",ipv6:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv6",cidrv4:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv4",cidrv6:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv6",base64:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64",base64url:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64url",json_string:"\u0440\u044F\u0434\u043E\u043A JSON",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"};return r=>{switch(r.code){case"invalid_type":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${r.expected}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${n(r.input)}`;case"invalid_value":return r.values.length===1?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${z(r.values[0])}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0430 \u043E\u043F\u0446\u0456\u044F: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F \u043E\u0434\u043D\u0435 \u0437 ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${a.verb} ${i}${r.maximum.toString()} ${a.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432"}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${i}${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${r.origin} ${a.verb} ${i}${r.minimum.toString()} ${a.unit}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${r.origin} \u0431\u0443\u0434\u0435 ${i}${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043F\u043E\u0447\u0438\u043D\u0430\u0442\u0438\u0441\u044F \u0437 "${i.prefix}"`:i.format==="ends_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0437\u0430\u043A\u0456\u043D\u0447\u0443\u0432\u0430\u0442\u0438\u0441\u044F \u043D\u0430 "${i.suffix}"`:i.format==="includes"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043C\u0456\u0441\u0442\u0438\u0442\u0438 "${i.includes}"`:i.format==="regex"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0442\u0438 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${i.pattern}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${o[i.format]??r.format}`}case"not_multiple_of":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0447\u0438\u0441\u043B\u043E: \u043F\u043E\u0432\u0438\u043D\u043D\u043E \u0431\u0443\u0442\u0438 \u043A\u0440\u0430\u0442\u043D\u0438\u043C ${r.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${r.keys.length>1?"\u0456":""}: ${R(r.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${r.origin}`;case"invalid_union":return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456";case"invalid_element":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0443 ${r.origin}`;default:return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"}}};function wb(){return{localeError:V0()}}var Z0=()=>{let e={string:{unit:"\u062D\u0631\u0648\u0641",verb:"\u06C1\u0648\u0646\u0627"},file:{unit:"\u0628\u0627\u0626\u0679\u0633",verb:"\u06C1\u0648\u0646\u0627"},array:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"},set:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"\u0646\u0645\u0628\u0631";case"object":{if(Array.isArray(r))return"\u0622\u0631\u06D2";if(r===null)return"\u0646\u0644";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"\u0627\u0646 \u067E\u0679",email:"\u0627\u06CC \u0645\u06CC\u0644 \u0627\u06CC\u0688\u0631\u06CC\u0633",url:"\u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",uuidv4:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 4",uuidv6:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 6",nanoid:"\u0646\u06CC\u0646\u0648 \u0622\u0626\u06CC \u0688\u06CC",guid:"\u062C\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid2:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC 2",ulid:"\u06CC\u0648 \u0627\u06CC\u0644 \u0622\u0626\u06CC \u0688\u06CC",xid:"\u0627\u06CC\u06A9\u0633 \u0622\u0626\u06CC \u0688\u06CC",ksuid:"\u06A9\u06D2 \u0627\u06CC\u0633 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",datetime:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0688\u06CC\u0679 \u0679\u0627\u0626\u0645",date:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u062A\u0627\u0631\u06CC\u062E",time:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0648\u0642\u062A",duration:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0645\u062F\u062A",ipv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0627\u06CC\u0688\u0631\u06CC\u0633",ipv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0627\u06CC\u0688\u0631\u06CC\u0633",cidrv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0631\u06CC\u0646\u062C",cidrv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0631\u06CC\u0646\u062C",base64:"\u0628\u06CC\u0633 64 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",base64url:"\u0628\u06CC\u0633 64 \u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",json_string:"\u062C\u06D2 \u0627\u06CC\u0633 \u0627\u0648 \u0627\u06CC\u0646 \u0633\u0679\u0631\u0646\u06AF",e164:"\u0627\u06CC 164 \u0646\u0645\u0628\u0631",jwt:"\u062C\u06D2 \u0688\u0628\u0644\u06CC\u0648 \u0679\u06CC",template_literal:"\u0627\u0646 \u067E\u0679"};return r=>{switch(r.code){case"invalid_type":return`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${r.expected} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${n(r.input)} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`;case"invalid_value":return r.values.length===1?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${z(r.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`:`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${R(r.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u0628\u06C1\u062A \u0628\u0691\u0627: ${r.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${i}${r.maximum.toString()} ${a.unit??"\u0639\u0646\u0627\u0635\u0631"} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0628\u0691\u0627: ${r.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${i}${r.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${r.origin} \u06A9\u06D2 ${i}${r.minimum.toString()} ${a.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${r.origin} \u06A9\u0627 ${i}${r.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let i=r;return i.format==="starts_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${i.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:i.format==="ends_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${i.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:i.format==="includes"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${i.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:i.format==="regex"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${i.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:`\u063A\u0644\u0637 ${o[i.format]??r.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${r.divisor} \u06A9\u0627 \u0645\u0636\u0627\u0639\u0641 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;case"unrecognized_keys":return`\u063A\u06CC\u0631 \u062A\u0633\u0644\u06CC\u0645 \u0634\u062F\u06C1 \u06A9\u06CC${r.keys.length>1?"\u0632":""}: ${R(r.keys,"\u060C ")}`;case"invalid_key":return`${r.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${r.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}}};function xb(){return{localeError:Z0()}}var B0=()=>{let e={string:{unit:"k\xFD t\u1EF1",verb:"c\xF3"},file:{unit:"byte",verb:"c\xF3"},array:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"},set:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"s\u1ED1";case"object":{if(Array.isArray(r))return"m\u1EA3ng";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"\u0111\u1EA7u v\xE0o",email:"\u0111\u1ECBa ch\u1EC9 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ng\xE0y gi\u1EDD ISO",date:"ng\xE0y ISO",time:"gi\u1EDD ISO",duration:"kho\u1EA3ng th\u1EDDi gian ISO",ipv4:"\u0111\u1ECBa ch\u1EC9 IPv4",ipv6:"\u0111\u1ECBa ch\u1EC9 IPv6",cidrv4:"d\u1EA3i IPv4",cidrv6:"d\u1EA3i IPv6",base64:"chu\u1ED7i m\xE3 h\xF3a base64",base64url:"chu\u1ED7i m\xE3 h\xF3a base64url",json_string:"chu\u1ED7i JSON",e164:"s\u1ED1 E.164",jwt:"JWT",template_literal:"\u0111\u1EA7u v\xE0o"};return r=>{switch(r.code){case"invalid_type":return`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${r.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${n(r.input)}`;case"invalid_value":return r.values.length===1?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${z(r.values[0])}`:`T\xF9y ch\u1ECDn kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i m\u1ED9t trong c\xE1c gi\xE1 tr\u1ECB ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${r.origin??"gi\xE1 tr\u1ECB"} ${a.verb} ${i}${r.maximum.toString()} ${a.unit??"ph\u1EA7n t\u1EED"}`:`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${r.origin??"gi\xE1 tr\u1ECB"} ${i}${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${r.origin} ${a.verb} ${i}${r.minimum.toString()} ${a.unit}`:`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${r.origin} ${i}${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${i.prefix}"`:i.format==="ends_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${i.suffix}"`:i.format==="includes"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${i.includes}"`:i.format==="regex"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${i.pattern}`:`${o[i.format]??r.format} kh\xF4ng h\u1EE3p l\u1EC7`}case"not_multiple_of":return`S\u1ED1 kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i l\xE0 b\u1ED9i s\u1ED1 c\u1EE7a ${r.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${R(r.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${r.origin}`;case"invalid_union":return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7";case"invalid_element":return`Gi\xE1 tr\u1ECB kh\xF4ng h\u1EE3p l\u1EC7 trong ${r.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}}};function _b(){return{localeError:B0()}}var W0=()=>{let e={string:{unit:"\u5B57\u7B26",verb:"\u5305\u542B"},file:{unit:"\u5B57\u8282",verb:"\u5305\u542B"},array:{unit:"\u9879",verb:"\u5305\u542B"},set:{unit:"\u9879",verb:"\u5305\u542B"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"\u975E\u6570\u5B57(NaN)":"\u6570\u5B57";case"object":{if(Array.isArray(r))return"\u6570\u7EC4";if(r===null)return"\u7A7A\u503C(null)";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"\u8F93\u5165",email:"\u7535\u5B50\u90AE\u4EF6",url:"URL",emoji:"\u8868\u60C5\u7B26\u53F7",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u671F\u65F6\u95F4",date:"ISO\u65E5\u671F",time:"ISO\u65F6\u95F4",duration:"ISO\u65F6\u957F",ipv4:"IPv4\u5730\u5740",ipv6:"IPv6\u5730\u5740",cidrv4:"IPv4\u7F51\u6BB5",cidrv6:"IPv6\u7F51\u6BB5",base64:"base64\u7F16\u7801\u5B57\u7B26\u4E32",base64url:"base64url\u7F16\u7801\u5B57\u7B26\u4E32",json_string:"JSON\u5B57\u7B26\u4E32",e164:"E.164\u53F7\u7801",jwt:"JWT",template_literal:"\u8F93\u5165"};return r=>{switch(r.code){case"invalid_type":return`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${r.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${n(r.input)}`;case"invalid_value":return r.values.length===1?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${z(r.values[0])}`:`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${r.origin??"\u503C"} ${i}${r.maximum.toString()} ${a.unit??"\u4E2A\u5143\u7D20"}`:`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${r.origin??"\u503C"} ${i}${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${r.origin} ${i}${r.minimum.toString()} ${a.unit}`:`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${r.origin} ${i}${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${i.prefix}" \u5F00\u5934`:i.format==="ends_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${i.suffix}" \u7ED3\u5C3E`:i.format==="includes"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${i.includes}"`:i.format==="regex"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${i.pattern}`:`\u65E0\u6548${o[i.format]??r.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${r.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${R(r.keys,", ")}`;case"invalid_key":return`${r.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${r.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}}};function Eb(){return{localeError:W0()}}var q0=()=>{let e={string:{unit:"\u5B57\u5143",verb:"\u64C1\u6709"},file:{unit:"\u4F4D\u5143\u7D44",verb:"\u64C1\u6709"},array:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"},set:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"}};function t(r){return e[r]??null}let n=r=>{let i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"\u8F38\u5165",email:"\u90F5\u4EF6\u5730\u5740",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u65E5\u671F\u6642\u9593",date:"ISO \u65E5\u671F",time:"ISO \u6642\u9593",duration:"ISO \u671F\u9593",ipv4:"IPv4 \u4F4D\u5740",ipv6:"IPv6 \u4F4D\u5740",cidrv4:"IPv4 \u7BC4\u570D",cidrv6:"IPv6 \u7BC4\u570D",base64:"base64 \u7DE8\u78BC\u5B57\u4E32",base64url:"base64url \u7DE8\u78BC\u5B57\u4E32",json_string:"JSON \u5B57\u4E32",e164:"E.164 \u6578\u503C",jwt:"JWT",template_literal:"\u8F38\u5165"};return r=>{switch(r.code){case"invalid_type":return`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${r.expected}\uFF0C\u4F46\u6536\u5230 ${n(r.input)}`;case"invalid_value":return r.values.length===1?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${z(r.values[0])}`:`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${R(r.values,"|")}`;case"too_big":{let i=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${r.origin??"\u503C"} \u61C9\u70BA ${i}${r.maximum.toString()} ${a.unit??"\u500B\u5143\u7D20"}`:`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${r.origin??"\u503C"} \u61C9\u70BA ${i}${r.maximum.toString()}`}case"too_small":{let i=r.inclusive?">=":">",a=t(r.origin);return a?`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${r.origin} \u61C9\u70BA ${i}${r.minimum.toString()} ${a.unit}`:`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${r.origin} \u61C9\u70BA ${i}${r.minimum.toString()}`}case"invalid_format":{let i=r;return i.format==="starts_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${i.prefix}" \u958B\u982D`:i.format==="ends_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${i.suffix}" \u7D50\u5C3E`:i.format==="includes"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${i.includes}"`:i.format==="regex"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${i.pattern}`:`\u7121\u6548\u7684 ${o[i.format]??r.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${r.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${r.keys.length>1?"\u5011":""}\uFF1A${R(r.keys,"\u3001")}`;case"invalid_key":return`${r.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${r.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}}};function Sb(){return{localeError:q0()}}var Np=Symbol("ZodOutput"),Op=Symbol("ZodInput"),tr=class{constructor(){this._map=new Map,this._idmap=new Map}add(t,...n){let o=n[0];if(this._map.set(t,o),o&&typeof o=="object"&&"id"in o){if(this._idmap.has(o.id))throw new Error(`ID ${o.id} already exists in the registry`);this._idmap.set(o.id,t)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(t){let n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){let n=t._zod.parent;if(n){let o={...this.get(n)??{}};return delete o.id,{...o,...this._map.get(t)}}return this._map.get(t)}has(t){return this._map.has(t)}};function wa(){return new tr}var wt=wa();function $p(e,t){return new e({type:"string",...P(t)})}function Pp(e,t){return new e({type:"string",coerce:!0,...P(t)})}function xa(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...P(t)})}function no(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...P(t)})}function _a(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...P(t)})}function Ea(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...P(t)})}function Sa(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...P(t)})}function Ta(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...P(t)})}function ka(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...P(t)})}function Ia(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...P(t)})}function Aa(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...P(t)})}function Ra(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...P(t)})}function Ca(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...P(t)})}function Na(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...P(t)})}function Oa(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...P(t)})}function $a(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...P(t)})}function Pa(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...P(t)})}function Ma(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...P(t)})}function La(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...P(t)})}function za(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...P(t)})}function Da(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...P(t)})}function Ua(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...P(t)})}function ja(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...P(t)})}function Ha(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...P(t)})}var Mp={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Lp(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...P(t)})}function zp(e,t){return new e({type:"string",format:"date",check:"string_format",...P(t)})}function Dp(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...P(t)})}function Up(e,t){return new e({type:"string",format:"duration",check:"string_format",...P(t)})}function jp(e,t){return new e({type:"number",checks:[],...P(t)})}function Hp(e,t){return new e({type:"number",coerce:!0,checks:[],...P(t)})}function Gp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...P(t)})}function Fp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...P(t)})}function Vp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...P(t)})}function Zp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...P(t)})}function Bp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...P(t)})}function Wp(e,t){return new e({type:"boolean",...P(t)})}function qp(e,t){return new e({type:"boolean",coerce:!0,...P(t)})}function Xp(e,t){return new e({type:"bigint",...P(t)})}function Kp(e,t){return new e({type:"bigint",coerce:!0,...P(t)})}function Yp(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...P(t)})}function Jp(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...P(t)})}function Qp(e,t){return new e({type:"symbol",...P(t)})}function eh(e,t){return new e({type:"undefined",...P(t)})}function th(e,t){return new e({type:"null",...P(t)})}function nh(e){return new e({type:"any"})}function nr(e){return new e({type:"unknown"})}function rh(e,t){return new e({type:"never",...P(t)})}function oh(e,t){return new e({type:"void",...P(t)})}function ih(e,t){return new e({type:"date",...P(t)})}function ah(e,t){return new e({type:"date",coerce:!0,...P(t)})}function sh(e,t){return new e({type:"nan",...P(t)})}function kt(e,t){return new pa({check:"less_than",...P(t),value:e,inclusive:!1})}function rt(e,t){return new pa({check:"less_than",...P(t),value:e,inclusive:!0})}function It(e,t){return new ha({check:"greater_than",...P(t),value:e,inclusive:!1})}function Ve(e,t){return new ha({check:"greater_than",...P(t),value:e,inclusive:!0})}function lh(e){return It(0,e)}function uh(e){return kt(0,e)}function ch(e){return rt(0,e)}function dh(e){return Ve(0,e)}function cn(e,t){return new ud({check:"multiple_of",...P(t),value:e})}function rr(e,t){return new pd({check:"max_size",...P(t),maximum:e})}function dn(e,t){return new hd({check:"min_size",...P(t),minimum:e})}function ro(e,t){return new fd({check:"size_equals",...P(t),size:e})}function or(e,t){return new md({check:"max_length",...P(t),maximum:e})}function zt(e,t){return new gd({check:"min_length",...P(t),minimum:e})}function ir(e,t){return new vd({check:"length_equals",...P(t),length:e})}function oo(e,t){return new bd({check:"string_format",format:"regex",...P(t),pattern:e})}function io(e){return new yd({check:"string_format",format:"lowercase",...P(e)})}function ao(e){return new wd({check:"string_format",format:"uppercase",...P(e)})}function so(e,t){return new xd({check:"string_format",format:"includes",...P(t),includes:e})}function lo(e,t){return new _d({check:"string_format",format:"starts_with",...P(t),prefix:e})}function uo(e,t){return new Ed({check:"string_format",format:"ends_with",...P(t),suffix:e})}function ph(e,t,n){return new Sd({check:"property",property:e,schema:t,...P(n)})}function co(e,t){return new Td({check:"mime_type",mime:e,...P(t)})}function At(e){return new kd({check:"overwrite",tx:e})}function po(e){return At(t=>t.normalize(e))}function ho(){return At(e=>e.trim())}function fo(){return At(e=>e.toLowerCase())}function mo(){return At(e=>e.toUpperCase())}function go(e,t,n){return new e({type:"array",element:t,...P(n)})}function X0(e,t,n){return new e({type:"union",options:t,...P(n)})}function K0(e,t,n,o){return new e({type:"union",options:n,discriminator:t,...P(o)})}function Y0(e,t,n){return new e({type:"intersection",left:t,right:n})}function hh(e,t,n,o){let r=n instanceof Z,i=r?o:n,a=r?n:null;return new e({type:"tuple",items:t,rest:a,...P(i)})}function J0(e,t,n,o){return new e({type:"record",keyType:t,valueType:n,...P(o)})}function Q0(e,t,n,o){return new e({type:"map",keyType:t,valueType:n,...P(o)})}function eT(e,t,n){return new e({type:"set",valueType:t,...P(n)})}function tT(e,t,n){let o=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new e({type:"enum",entries:o,...P(n)})}function nT(e,t,n){return new e({type:"enum",entries:t,...P(n)})}function rT(e,t,n){return new e({type:"literal",values:Array.isArray(t)?t:[t],...P(n)})}function fh(e,t){return new e({type:"file",...P(t)})}function oT(e,t){return new e({type:"transform",transform:t})}function iT(e,t){return new e({type:"optional",innerType:t})}function aT(e,t){return new e({type:"nullable",innerType:t})}function sT(e,t,n){return new e({type:"default",innerType:t,get defaultValue(){return typeof n=="function"?n():n}})}function lT(e,t,n){return new e({type:"nonoptional",innerType:t,...P(n)})}function uT(e,t){return new e({type:"success",innerType:t})}function cT(e,t,n){return new e({type:"catch",innerType:t,catchValue:typeof n=="function"?n:()=>n})}function dT(e,t,n){return new e({type:"pipe",in:t,out:n})}function pT(e,t){return new e({type:"readonly",innerType:t})}function hT(e,t,n){return new e({type:"template_literal",parts:t,...P(n)})}function fT(e,t){return new e({type:"lazy",getter:t})}function mT(e,t){return new e({type:"promise",innerType:t})}function mh(e,t,n){let o=P(n);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function gh(e,t,n){return new e({type:"custom",check:"custom",fn:t,...P(n)})}function vh(e,t){let n=P(t),o=n.truthy??["true","1","yes","on","y","enabled"],r=n.falsy??["false","0","no","off","n","disabled"];n.case!=="sensitive"&&(o=o.map(p=>typeof p=="string"?p.toLowerCase():p),r=r.map(p=>typeof p=="string"?p.toLowerCase():p));let i=new Set(o),a=new Set(r),s=e.Pipe??eo,u=e.Boolean??Yr,l=e.String??ln,d=e.Transform??Qr,h=new d({type:"transform",transform:(p,b)=>{let v=p;return n.case!=="sensitive"&&(v=v.toLowerCase()),i.has(v)?!0:a.has(v)?!1:(b.issues.push({code:"invalid_value",expected:"stringbool",values:[...i,...a],input:b.value,inst:h}),{})},error:n.error}),g=new s({type:"pipe",in:new l({type:"string",error:n.error}),out:h,error:n.error});return new s({type:"pipe",in:g,out:new u({type:"boolean",error:n.error}),error:n.error})}function bh(e,t,n,o={}){let r=P(o),i={...P(o),check:"string_format",type:"string",format:t,fn:typeof n=="function"?n:s=>n.test(s),...r};return n instanceof RegExp&&(i.pattern=n),new e(i)}var Ga=class{constructor(t){this._def=t,this.def=t}implement(t){if(typeof t!="function")throw new Error("implement() must be called with a function");let n=((...o)=>{let r=this._def.input?aa(this._def.input,o,void 0,{callee:n}):o;if(!Array.isArray(r))throw new Error("Invalid arguments schema: not an array or tuple schema.");let i=t(...r);return this._def.output?aa(this._def.output,i,void 0,{callee:n}):i});return n}implementAsync(t){if(typeof t!="function")throw new Error("implement() must be called with a function");let n=(async(...o)=>{let r=this._def.input?await la(this._def.input,o,void 0,{callee:n}):o;if(!Array.isArray(r))throw new Error("Invalid arguments schema: not an array or tuple schema.");let i=await t(...r);return this._def.output?la(this._def.output,i,void 0,{callee:n}):i});return n}input(...t){let n=this.constructor;return Array.isArray(t[0])?new n({type:"function",input:new un({type:"tuple",items:t[0],rest:t[1]}),output:this._def.output}):new n({type:"function",input:t[0],output:this._def.output})}output(t){let n=this.constructor;return new n({type:"function",input:this._def.input,output:t})}};function yh(e){return new Ga({type:"function",input:Array.isArray(e?.input)?hh(un,e?.input):e?.input??go(Jr,nr(er)),output:e?.output??nr(er)})}var vo=class{constructor(t){this.counter=0,this.metadataRegistry=t?.metadata??wt,this.target=t?.target??"draft-2020-12",this.unrepresentable=t?.unrepresentable??"throw",this.override=t?.override??(()=>{}),this.io=t?.io??"output",this.seen=new Map}process(t,n={path:[],schemaPath:[]}){var o;let r=t._zod.def,i={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},a=this.seen.get(t);if(a)return a.count++,n.schemaPath.includes(t)&&(a.cycle=n.path),a.schema;let s={schema:{},count:1,cycle:void 0,path:n.path};this.seen.set(t,s);let u=t._zod.toJSONSchema?.();if(u)s.schema=u;else{let h={...n,schemaPath:[...n.schemaPath,t],path:n.path},g=t._zod.parent;if(g)s.ref=g,this.process(g,h),this.seen.get(g).isParent=!0;else{let f=s.schema;switch(r.type){case"string":{let p=f;p.type="string";let{minimum:b,maximum:v,format:_,patterns:y,contentEncoding:k}=t._zod.bag;if(typeof b=="number"&&(p.minLength=b),typeof v=="number"&&(p.maxLength=v),_&&(p.format=i[_]??_,p.format===""&&delete p.format),k&&(p.contentEncoding=k),y&&y.size>0){let E=[...y];E.length===1?p.pattern=E[0].source:E.length>1&&(s.schema.allOf=[...E.map(I=>({...this.target==="draft-7"?{type:"string"}:{},pattern:I.source}))])}break}case"number":{let p=f,{minimum:b,maximum:v,format:_,multipleOf:y,exclusiveMaximum:k,exclusiveMinimum:E}=t._zod.bag;typeof _=="string"&&_.includes("int")?p.type="integer":p.type="number",typeof E=="number"&&(p.exclusiveMinimum=E),typeof b=="number"&&(p.minimum=b,typeof E=="number"&&(E>=b?delete p.minimum:delete p.exclusiveMinimum)),typeof k=="number"&&(p.exclusiveMaximum=k),typeof v=="number"&&(p.maximum=v,typeof k=="number"&&(k<=v?delete p.maximum:delete p.exclusiveMaximum)),typeof y=="number"&&(p.multipleOf=y);break}case"boolean":{let p=f;p.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"null":{f.type="null";break}case"any":break;case"unknown":break;case"undefined":{if(this.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema");break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"never":{f.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{let p=f,{minimum:b,maximum:v}=t._zod.bag;typeof b=="number"&&(p.minItems=b),typeof v=="number"&&(p.maxItems=v),p.type="array",p.items=this.process(r.element,{...h,path:[...h.path,"items"]});break}case"object":{let p=f;p.type="object",p.properties={};let b=r.shape;for(let y in b)p.properties[y]=this.process(b[y],{...h,path:[...h.path,"properties",y]});let v=new Set(Object.keys(b)),_=new Set([...v].filter(y=>{let k=r.shape[y]._zod;return this.io==="input"?k.optin===void 0:k.optout===void 0}));_.size>0&&(p.required=Array.from(_)),r.catchall?._zod.def.type==="never"?p.additionalProperties=!1:r.catchall?r.catchall&&(p.additionalProperties=this.process(r.catchall,{...h,path:[...h.path,"additionalProperties"]})):this.io==="output"&&(p.additionalProperties=!1);break}case"union":{let p=f;p.anyOf=r.options.map((b,v)=>this.process(b,{...h,path:[...h.path,"anyOf",v]}));break}case"intersection":{let p=f,b=this.process(r.left,{...h,path:[...h.path,"allOf",0]}),v=this.process(r.right,{...h,path:[...h.path,"allOf",1]}),_=k=>"allOf"in k&&Object.keys(k).length===1,y=[..._(b)?b.allOf:[b],..._(v)?v.allOf:[v]];p.allOf=y;break}case"tuple":{let p=f;p.type="array";let b=r.items.map((y,k)=>this.process(y,{...h,path:[...h.path,"prefixItems",k]}));if(this.target==="draft-2020-12"?p.prefixItems=b:p.items=b,r.rest){let y=this.process(r.rest,{...h,path:[...h.path,"items"]});this.target==="draft-2020-12"?p.items=y:p.additionalItems=y}r.rest&&(p.items=this.process(r.rest,{...h,path:[...h.path,"items"]}));let{minimum:v,maximum:_}=t._zod.bag;typeof v=="number"&&(p.minItems=v),typeof _=="number"&&(p.maxItems=_);break}case"record":{let p=f;p.type="object",p.propertyNames=this.process(r.keyType,{...h,path:[...h.path,"propertyNames"]}),p.additionalProperties=this.process(r.valueType,{...h,path:[...h.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{let p=f,b=Hr(r.entries);b.every(v=>typeof v=="number")&&(p.type="number"),b.every(v=>typeof v=="string")&&(p.type="string"),p.enum=b;break}case"literal":{let p=f,b=[];for(let v of r.values)if(v===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof v=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");b.push(Number(v))}else b.push(v);if(b.length!==0)if(b.length===1){let v=b[0];p.type=v===null?"null":typeof v,p.const=v}else b.every(v=>typeof v=="number")&&(p.type="number"),b.every(v=>typeof v=="string")&&(p.type="string"),b.every(v=>typeof v=="boolean")&&(p.type="string"),b.every(v=>v===null)&&(p.type="null"),p.enum=b;break}case"file":{let p=f,b={type:"string",format:"binary",contentEncoding:"binary"},{minimum:v,maximum:_,mime:y}=t._zod.bag;v!==void 0&&(b.minLength=v),_!==void 0&&(b.maxLength=_),y?y.length===1?(b.contentMediaType=y[0],Object.assign(p,b)):p.anyOf=y.map(k=>({...b,contentMediaType:k})):Object.assign(p,b);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{let p=this.process(r.innerType,h);f.anyOf=[p,{type:"null"}];break}case"nonoptional":{this.process(r.innerType,h),s.ref=r.innerType;break}case"success":{let p=f;p.type="boolean";break}case"default":{this.process(r.innerType,h),s.ref=r.innerType,f.default=JSON.parse(JSON.stringify(r.defaultValue));break}case"prefault":{this.process(r.innerType,h),s.ref=r.innerType,this.io==="input"&&(f._prefault=JSON.parse(JSON.stringify(r.defaultValue)));break}case"catch":{this.process(r.innerType,h),s.ref=r.innerType;let p;try{p=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}f.default=p;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{let p=f,b=t._zod.pattern;if(!b)throw new Error("Pattern not found in template literal");p.type="string",p.pattern=b.source;break}case"pipe":{let p=this.io==="input"?r.in._zod.def.type==="transform"?r.out:r.in:r.out;this.process(p,h),s.ref=p;break}case"readonly":{this.process(r.innerType,h),s.ref=r.innerType,f.readOnly=!0;break}case"promise":{this.process(r.innerType,h),s.ref=r.innerType;break}case"optional":{this.process(r.innerType,h),s.ref=r.innerType;break}case"lazy":{let p=t._zod.innerType;this.process(p,h),s.ref=p;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}default:}}}let l=this.metadataRegistry.get(t);return l&&Object.assign(s.schema,l),this.io==="input"&&Ie(t)&&(delete s.schema.examples,delete s.schema.default),this.io==="input"&&s.schema._prefault&&((o=s.schema).default??(o.default=s.schema._prefault)),delete s.schema._prefault,this.seen.get(t).schema}emit(t,n){let o={cycles:n?.cycles??"ref",reused:n?.reused??"inline",external:n?.external??void 0},r=this.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=d=>{let h=this.target==="draft-2020-12"?"$defs":"definitions";if(o.external){let b=o.external.registry.get(d[0])?.id,v=o.external.uri??(y=>y);if(b)return{ref:v(b)};let _=d[1].defId??d[1].schema.id??`schema${this.counter++}`;return d[1].defId=_,{defId:_,ref:`${v("__shared")}#/${h}/${_}`}}if(d[1]===r)return{ref:"#"};let f=`#/${h}/`,p=d[1].schema.id??`__schema${this.counter++}`;return{defId:p,ref:f+p}},a=d=>{if(d[1].schema.$ref)return;let h=d[1],{ref:g,defId:f}=i(d);h.def={...h.schema},f&&(h.defId=f);let p=h.schema;for(let b in p)delete p[b];p.$ref=g};if(o.cycles==="throw")for(let d of this.seen.entries()){let h=d[1];if(h.cycle)throw new Error(`Cycle detected: #/${h.cycle?.join("/")}/<root>
|
|
32
|
+
|
|
33
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let d of this.seen.entries()){let h=d[1];if(t===d[0]){a(d);continue}if(o.external){let f=o.external.registry.get(d[0])?.id;if(t!==d[0]&&f){a(d);continue}}if(this.metadataRegistry.get(d[0])?.id){a(d);continue}if(h.cycle){a(d);continue}if(h.count>1&&o.reused==="ref"){a(d);continue}}let s=(d,h)=>{let g=this.seen.get(d),f=g.def??g.schema,p={...f};if(g.ref===null)return;let b=g.ref;if(g.ref=null,b){s(b,h);let v=this.seen.get(b).schema;v.$ref&&h.target==="draft-7"?(f.allOf=f.allOf??[],f.allOf.push(v)):(Object.assign(f,v),Object.assign(f,p))}g.isParent||this.override({zodSchema:d,jsonSchema:f,path:g.path??[]})};for(let d of[...this.seen.entries()].reverse())s(d[0],{target:this.target});let u={};if(this.target==="draft-2020-12"?u.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?u.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),o.external?.uri){let d=o.external.registry.get(t)?.id;if(!d)throw new Error("Schema is missing an `id` property");u.$id=o.external.uri(d)}Object.assign(u,r.def);let l=o.external?.defs??{};for(let d of this.seen.entries()){let h=d[1];h.def&&h.defId&&(l[h.defId]=h.def)}o.external||Object.keys(l).length>0&&(this.target==="draft-2020-12"?u.$defs=l:u.definitions=l);try{return JSON.parse(JSON.stringify(u))}catch{throw new Error("Error converting schema to JSON.")}}};function wh(e,t){if(e instanceof tr){let o=new vo(t),r={};for(let s of e._idmap.entries()){let[u,l]=s;o.process(l)}let i={},a={registry:e,uri:t?.uri,defs:r};for(let s of e._idmap.entries()){let[u,l]=s;i[u]=o.emit(l,{...t,external:a})}if(Object.keys(r).length>0){let s=o.target==="draft-2020-12"?"$defs":"definitions";i.__shared={[s]:r}}return{schemas:i}}let n=new vo(t);return n.process(e),n.emit(e,t)}function Ie(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;switch(r.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":return!1;case"array":return Ie(r.element,n);case"object":{for(let i in r.shape)if(Ie(r.shape[i],n))return!0;return!1}case"union":{for(let i of r.options)if(Ie(i,n))return!0;return!1}case"intersection":return Ie(r.left,n)||Ie(r.right,n);case"tuple":{for(let i of r.items)if(Ie(i,n))return!0;return!!(r.rest&&Ie(r.rest,n))}case"record":return Ie(r.keyType,n)||Ie(r.valueType,n);case"map":return Ie(r.keyType,n)||Ie(r.valueType,n);case"set":return Ie(r.valueType,n);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return Ie(r.innerType,n);case"lazy":return Ie(r.getter(),n);case"default":return Ie(r.innerType,n);case"prefault":return Ie(r.innerType,n);case"custom":return!1;case"transform":return!0;case"pipe":return Ie(r.in,n)||Ie(r.out,n);case"success":return!1;case"catch":return!1;default:}throw new Error(`Unknown schema type: ${r.type}`)}var Tb={};var Wa={};_t(Wa,{ZodISODate:()=>Va,ZodISODateTime:()=>Fa,ZodISODuration:()=>Ba,ZodISOTime:()=>Za,date:()=>_h,datetime:()=>xh,duration:()=>Sh,time:()=>Eh});var Fa=T("ZodISODateTime",(e,t)=>{jd.init(e,t),ce.init(e,t)});function xh(e){return Lp(Fa,e)}var Va=T("ZodISODate",(e,t)=>{Hd.init(e,t),ce.init(e,t)});function _h(e){return zp(Va,e)}var Za=T("ZodISOTime",(e,t)=>{Gd.init(e,t),ce.init(e,t)});function Eh(e){return Dp(Za,e)}var Ba=T("ZodISODuration",(e,t)=>{Fd.init(e,t),ce.init(e,t)});function Sh(e){return Up(Ba,e)}var Ib=(e,t)=>{Wr.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Xr(e,n)},flatten:{value:n=>qr(e,n)},addIssue:{value:n=>e.issues.push(n)},addIssues:{value:n=>e.issues.push(...n)},isEmpty:{get(){return e.issues.length===0}}})},vT=T("ZodError",Ib),ar=T("ZodError",Ib,{Parent:Error});var Th=ia(ar),kh=sa(ar),Ih=ua(ar),Ah=ca(ar);var X=T("ZodType",(e,t)=>(Z.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),e.clone=(n,o)=>We(e,n,o),e.brand=()=>e,e.register=((n,o)=>(n.add(e,o),e)),e.parse=(n,o)=>Th(e,n,o,{callee:e.parse}),e.safeParse=(n,o)=>Ih(e,n,o),e.parseAsync=async(n,o)=>kh(e,n,o,{callee:e.parseAsync}),e.safeParseAsync=async(n,o)=>Ah(e,n,o),e.spa=e.safeParseAsync,e.refine=(n,o)=>e.check(fy(n,o)),e.superRefine=n=>e.check(my(n)),e.overwrite=n=>e.check(At(n)),e.optional=()=>Ka(e),e.nullable=()=>Ya(e),e.nullish=()=>Ka(Ya(e)),e.nonoptional=n=>ny(e,n),e.array=()=>Kh(e),e.or=n=>ns([e,n]),e.and=n=>Gb(e,n),e.transform=n=>Ja(e,ef(n)),e.default=n=>Qb(e,n),e.prefault=n=>ty(e,n),e.catch=n=>iy(e,n),e.pipe=n=>Ja(e,n),e.readonly=()=>ly(e),e.describe=n=>{let o=e.clone();return wt.add(o,{description:n}),o},Object.defineProperty(e,"description",{get(){return wt.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return wt.get(e);let o=e.clone();return wt.add(o,n[0]),o},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Nh=T("_ZodString",(e,t)=>{ln.init(e,t),X.init(e,t);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...o)=>e.check(oo(...o)),e.includes=(...o)=>e.check(so(...o)),e.startsWith=(...o)=>e.check(lo(...o)),e.endsWith=(...o)=>e.check(uo(...o)),e.min=(...o)=>e.check(zt(...o)),e.max=(...o)=>e.check(or(...o)),e.length=(...o)=>e.check(ir(...o)),e.nonempty=(...o)=>e.check(zt(1,...o)),e.lowercase=o=>e.check(io(o)),e.uppercase=o=>e.check(ao(o)),e.trim=()=>e.check(ho()),e.normalize=(...o)=>e.check(po(...o)),e.toLowerCase=()=>e.check(fo()),e.toUpperCase=()=>e.check(mo())}),yo=T("ZodString",(e,t)=>{ln.init(e,t),Nh.init(e,t),e.email=n=>e.check(xa(Oh,n)),e.url=n=>e.check(ka($h,n)),e.jwt=n=>e.check(Ha(qh,n)),e.emoji=n=>e.check(Ia(Ph,n)),e.guid=n=>e.check(no(qa,n)),e.uuid=n=>e.check(_a(Ct,n)),e.uuidv4=n=>e.check(Ea(Ct,n)),e.uuidv6=n=>e.check(Sa(Ct,n)),e.uuidv7=n=>e.check(Ta(Ct,n)),e.nanoid=n=>e.check(Aa(Mh,n)),e.guid=n=>e.check(no(qa,n)),e.cuid=n=>e.check(Ra(Lh,n)),e.cuid2=n=>e.check(Ca(zh,n)),e.ulid=n=>e.check(Na(Dh,n)),e.base64=n=>e.check(Da(Zh,n)),e.base64url=n=>e.check(Ua(Bh,n)),e.xid=n=>e.check(Oa(Uh,n)),e.ksuid=n=>e.check($a(jh,n)),e.ipv4=n=>e.check(Pa(Hh,n)),e.ipv6=n=>e.check(Ma(Gh,n)),e.cidrv4=n=>e.check(La(Fh,n)),e.cidrv6=n=>e.check(za(Vh,n)),e.e164=n=>e.check(ja(Wh,n)),e.datetime=n=>e.check(xh(n)),e.date=n=>e.check(_h(n)),e.time=n=>e.check(Eh(n)),e.duration=n=>e.check(Sh(n))});function Rh(e){return $p(yo,e)}var ce=T("ZodStringFormat",(e,t)=>{se.init(e,t),Nh.init(e,t)}),Oh=T("ZodEmail",(e,t)=>{Nd.init(e,t),ce.init(e,t)});function yT(e){return xa(Oh,e)}var qa=T("ZodGUID",(e,t)=>{Rd.init(e,t),ce.init(e,t)});function wT(e){return no(qa,e)}var Ct=T("ZodUUID",(e,t)=>{Cd.init(e,t),ce.init(e,t)});function xT(e){return _a(Ct,e)}function _T(e){return Ea(Ct,e)}function ET(e){return Sa(Ct,e)}function ST(e){return Ta(Ct,e)}var $h=T("ZodURL",(e,t)=>{Od.init(e,t),ce.init(e,t)});function TT(e){return ka($h,e)}var Ph=T("ZodEmoji",(e,t)=>{$d.init(e,t),ce.init(e,t)});function kT(e){return Ia(Ph,e)}var Mh=T("ZodNanoID",(e,t)=>{Pd.init(e,t),ce.init(e,t)});function IT(e){return Aa(Mh,e)}var Lh=T("ZodCUID",(e,t)=>{Md.init(e,t),ce.init(e,t)});function AT(e){return Ra(Lh,e)}var zh=T("ZodCUID2",(e,t)=>{Ld.init(e,t),ce.init(e,t)});function RT(e){return Ca(zh,e)}var Dh=T("ZodULID",(e,t)=>{zd.init(e,t),ce.init(e,t)});function CT(e){return Na(Dh,e)}var Uh=T("ZodXID",(e,t)=>{Dd.init(e,t),ce.init(e,t)});function NT(e){return Oa(Uh,e)}var jh=T("ZodKSUID",(e,t)=>{Ud.init(e,t),ce.init(e,t)});function OT(e){return $a(jh,e)}var Hh=T("ZodIPv4",(e,t)=>{Vd.init(e,t),ce.init(e,t)});function $T(e){return Pa(Hh,e)}var Gh=T("ZodIPv6",(e,t)=>{Zd.init(e,t),ce.init(e,t)});function PT(e){return Ma(Gh,e)}var Fh=T("ZodCIDRv4",(e,t)=>{Bd.init(e,t),ce.init(e,t)});function MT(e){return La(Fh,e)}var Vh=T("ZodCIDRv6",(e,t)=>{Wd.init(e,t),ce.init(e,t)});function LT(e){return za(Vh,e)}var Zh=T("ZodBase64",(e,t)=>{Xd.init(e,t),ce.init(e,t)});function zT(e){return Da(Zh,e)}var Bh=T("ZodBase64URL",(e,t)=>{Kd.init(e,t),ce.init(e,t)});function DT(e){return Ua(Bh,e)}var Wh=T("ZodE164",(e,t)=>{Yd.init(e,t),ce.init(e,t)});function UT(e){return ja(Wh,e)}var qh=T("ZodJWT",(e,t)=>{Jd.init(e,t),ce.init(e,t)});function jT(e){return Ha(qh,e)}var Ab=T("ZodCustomStringFormat",(e,t)=>{Qd.init(e,t),ce.init(e,t)});function HT(e,t,n={}){return bh(Ab,e,t,n)}var wo=T("ZodNumber",(e,t)=>{ga.init(e,t),X.init(e,t),e.gt=(o,r)=>e.check(It(o,r)),e.gte=(o,r)=>e.check(Ve(o,r)),e.min=(o,r)=>e.check(Ve(o,r)),e.lt=(o,r)=>e.check(kt(o,r)),e.lte=(o,r)=>e.check(rt(o,r)),e.max=(o,r)=>e.check(rt(o,r)),e.int=o=>e.check(Ch(o)),e.safe=o=>e.check(Ch(o)),e.positive=o=>e.check(It(0,o)),e.nonnegative=o=>e.check(Ve(0,o)),e.negative=o=>e.check(kt(0,o)),e.nonpositive=o=>e.check(rt(0,o)),e.multipleOf=(o,r)=>e.check(cn(o,r)),e.step=(o,r)=>e.check(cn(o,r)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Rb(e){return jp(wo,e)}var sr=T("ZodNumberFormat",(e,t)=>{ep.init(e,t),wo.init(e,t)});function Ch(e){return Gp(sr,e)}function GT(e){return Fp(sr,e)}function FT(e){return Vp(sr,e)}function VT(e){return Zp(sr,e)}function ZT(e){return Bp(sr,e)}var xo=T("ZodBoolean",(e,t)=>{Yr.init(e,t),X.init(e,t)});function Cb(e){return Wp(xo,e)}var _o=T("ZodBigInt",(e,t)=>{va.init(e,t),X.init(e,t),e.gte=(o,r)=>e.check(Ve(o,r)),e.min=(o,r)=>e.check(Ve(o,r)),e.gt=(o,r)=>e.check(It(o,r)),e.gte=(o,r)=>e.check(Ve(o,r)),e.min=(o,r)=>e.check(Ve(o,r)),e.lt=(o,r)=>e.check(kt(o,r)),e.lte=(o,r)=>e.check(rt(o,r)),e.max=(o,r)=>e.check(rt(o,r)),e.positive=o=>e.check(It(BigInt(0),o)),e.negative=o=>e.check(kt(BigInt(0),o)),e.nonpositive=o=>e.check(rt(BigInt(0),o)),e.nonnegative=o=>e.check(Ve(BigInt(0),o)),e.multipleOf=(o,r)=>e.check(cn(o,r));let n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null});function BT(e){return Xp(_o,e)}var Xh=T("ZodBigIntFormat",(e,t)=>{tp.init(e,t),_o.init(e,t)});function WT(e){return Yp(Xh,e)}function qT(e){return Jp(Xh,e)}var Nb=T("ZodSymbol",(e,t)=>{np.init(e,t),X.init(e,t)});function XT(e){return Qp(Nb,e)}var Ob=T("ZodUndefined",(e,t)=>{rp.init(e,t),X.init(e,t)});function KT(e){return eh(Ob,e)}var $b=T("ZodNull",(e,t)=>{op.init(e,t),X.init(e,t)});function Pb(e){return th($b,e)}var Mb=T("ZodAny",(e,t)=>{ip.init(e,t),X.init(e,t)});function YT(){return nh(Mb)}var Lb=T("ZodUnknown",(e,t)=>{er.init(e,t),X.init(e,t)});function Xa(){return nr(Lb)}var zb=T("ZodNever",(e,t)=>{ap.init(e,t),X.init(e,t)});function Qa(e){return rh(zb,e)}var Db=T("ZodVoid",(e,t)=>{sp.init(e,t),X.init(e,t)});function JT(e){return oh(Db,e)}var es=T("ZodDate",(e,t)=>{lp.init(e,t),X.init(e,t),e.min=(o,r)=>e.check(Ve(o,r)),e.max=(o,r)=>e.check(rt(o,r));let n=e._zod.bag;e.minDate=n.minimum?new Date(n.minimum):null,e.maxDate=n.maximum?new Date(n.maximum):null});function QT(e){return ih(es,e)}var Ub=T("ZodArray",(e,t)=>{Jr.init(e,t),X.init(e,t),e.element=t.element,e.min=(n,o)=>e.check(zt(n,o)),e.nonempty=n=>e.check(zt(1,n)),e.max=(n,o)=>e.check(or(n,o)),e.length=(n,o)=>e.check(ir(n,o)),e.unwrap=()=>e.element});function Kh(e,t){return go(Ub,e,t)}function ek(e){let t=e._zod.def.shape;return Xb(Object.keys(t))}var ts=T("ZodObject",(e,t)=>{up.init(e,t),X.init(e,t),D.defineLazy(e,"shape",()=>t.shape),e.keyof=()=>Wb(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Xa()}),e.loose=()=>e.clone({...e._zod.def,catchall:Xa()}),e.strict=()=>e.clone({...e._zod.def,catchall:Qa()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>D.extend(e,n),e.merge=n=>D.merge(e,n),e.pick=n=>D.pick(e,n),e.omit=n=>D.omit(e,n),e.partial=(...n)=>D.partial(tf,e,n[0]),e.required=(...n)=>D.required(nf,e,n[0])});function tk(e,t){let n={type:"object",get shape(){return D.assignProp(this,"shape",{...e}),this.shape},...D.normalizeParams(t)};return new ts(n)}function nk(e,t){return new ts({type:"object",get shape(){return D.assignProp(this,"shape",{...e}),this.shape},catchall:Qa(),...D.normalizeParams(t)})}function rk(e,t){return new ts({type:"object",get shape(){return D.assignProp(this,"shape",{...e}),this.shape},catchall:Xa(),...D.normalizeParams(t)})}var Yh=T("ZodUnion",(e,t)=>{ba.init(e,t),X.init(e,t),e.options=t.options});function ns(e,t){return new Yh({type:"union",options:e,...D.normalizeParams(t)})}var jb=T("ZodDiscriminatedUnion",(e,t)=>{Yh.init(e,t),cp.init(e,t)});function ok(e,t,n){return new jb({type:"union",options:t,discriminator:e,...D.normalizeParams(n)})}var Hb=T("ZodIntersection",(e,t)=>{dp.init(e,t),X.init(e,t)});function Gb(e,t){return new Hb({type:"intersection",left:e,right:t})}var Fb=T("ZodTuple",(e,t)=>{un.init(e,t),X.init(e,t),e.rest=n=>e.clone({...e._zod.def,rest:n})});function ik(e,t,n){let o=t instanceof Z,r=o?n:t,i=o?t:null;return new Fb({type:"tuple",items:e,rest:i,...D.normalizeParams(r)})}var Jh=T("ZodRecord",(e,t)=>{pp.init(e,t),X.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function Vb(e,t,n){return new Jh({type:"record",keyType:e,valueType:t,...D.normalizeParams(n)})}function ak(e,t,n){return new Jh({type:"record",keyType:ns([e,Qa()]),valueType:t,...D.normalizeParams(n)})}var Zb=T("ZodMap",(e,t)=>{hp.init(e,t),X.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function sk(e,t,n){return new Zb({type:"map",keyType:e,valueType:t,...D.normalizeParams(n)})}var Bb=T("ZodSet",(e,t)=>{fp.init(e,t),X.init(e,t),e.min=(...n)=>e.check(dn(...n)),e.nonempty=n=>e.check(dn(1,n)),e.max=(...n)=>e.check(rr(...n)),e.size=(...n)=>e.check(ro(...n))});function lk(e,t){return new Bb({type:"set",valueType:e,...D.normalizeParams(t)})}var bo=T("ZodEnum",(e,t)=>{mp.init(e,t),X.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(o,r)=>{let i={};for(let a of o)if(n.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new bo({...t,checks:[],...D.normalizeParams(r),entries:i})},e.exclude=(o,r)=>{let i={...t.entries};for(let a of o)if(n.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new bo({...t,checks:[],...D.normalizeParams(r),entries:i})}});function Wb(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new bo({type:"enum",entries:n,...D.normalizeParams(t)})}function uk(e,t){return new bo({type:"enum",entries:e,...D.normalizeParams(t)})}var qb=T("ZodLiteral",(e,t)=>{gp.init(e,t),X.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 Xb(e,t){return new qb({type:"literal",values:Array.isArray(e)?e:[e],...D.normalizeParams(t)})}var Kb=T("ZodFile",(e,t)=>{vp.init(e,t),X.init(e,t),e.min=(n,o)=>e.check(dn(n,o)),e.max=(n,o)=>e.check(rr(n,o)),e.mime=(n,o)=>e.check(co(Array.isArray(n)?n:[n],o))});function ck(e){return fh(Kb,e)}var Qh=T("ZodTransform",(e,t)=>{Qr.init(e,t),X.init(e,t),e._zod.parse=(n,o)=>{n.addIssue=i=>{if(typeof i=="string")n.issues.push(D.issue(i,n.value,t));else{let a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=n.value),a.inst??(a.inst=e),a.continue??(a.continue=!0),n.issues.push(D.issue(a))}};let r=t.transform(n.value,n);return r instanceof Promise?r.then(i=>(n.value=i,n)):(n.value=r,n)}});function ef(e){return new Qh({type:"transform",transform:e})}var tf=T("ZodOptional",(e,t)=>{bp.init(e,t),X.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ka(e){return new tf({type:"optional",innerType:e})}var Yb=T("ZodNullable",(e,t)=>{yp.init(e,t),X.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ya(e){return new Yb({type:"nullable",innerType:e})}function dk(e){return Ka(Ya(e))}var Jb=T("ZodDefault",(e,t)=>{wp.init(e,t),X.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Qb(e,t){return new Jb({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}var ey=T("ZodPrefault",(e,t)=>{xp.init(e,t),X.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ty(e,t){return new ey({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}var nf=T("ZodNonOptional",(e,t)=>{_p.init(e,t),X.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ny(e,t){return new nf({type:"nonoptional",innerType:e,...D.normalizeParams(t)})}var ry=T("ZodSuccess",(e,t)=>{Ep.init(e,t),X.init(e,t),e.unwrap=()=>e._zod.def.innerType});function pk(e){return new ry({type:"success",innerType:e})}var oy=T("ZodCatch",(e,t)=>{Sp.init(e,t),X.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function iy(e,t){return new oy({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var ay=T("ZodNaN",(e,t)=>{Tp.init(e,t),X.init(e,t)});function hk(e){return sh(ay,e)}var rf=T("ZodPipe",(e,t)=>{eo.init(e,t),X.init(e,t),e.in=t.in,e.out=t.out});function Ja(e,t){return new rf({type:"pipe",in:e,out:t})}var sy=T("ZodReadonly",(e,t)=>{kp.init(e,t),X.init(e,t)});function ly(e){return new sy({type:"readonly",innerType:e})}var uy=T("ZodTemplateLiteral",(e,t)=>{Ip.init(e,t),X.init(e,t)});function fk(e,t){return new uy({type:"template_literal",parts:e,...D.normalizeParams(t)})}var cy=T("ZodLazy",(e,t)=>{Rp.init(e,t),X.init(e,t),e.unwrap=()=>e._zod.def.getter()});function dy(e){return new cy({type:"lazy",getter:e})}var py=T("ZodPromise",(e,t)=>{Ap.init(e,t),X.init(e,t),e.unwrap=()=>e._zod.def.innerType});function mk(e){return new py({type:"promise",innerType:e})}var rs=T("ZodCustom",(e,t)=>{Cp.init(e,t),X.init(e,t)});function hy(e){let t=new ye({check:"custom"});return t._zod.check=e,t}function gk(e,t){return mh(rs,e??(()=>!0),t)}function fy(e,t={}){return gh(rs,e,t)}function my(e){let t=hy(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(D.issue(o,n.value,t._zod.def));else{let r=o;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),n.issues.push(D.issue(r))}},e(n.value,n)));return t}function vk(e,t={error:`Input not instance of ${e.name}`}){let n=new rs({type:"custom",check:"custom",fn:o=>o instanceof e,abort:!0,...D.normalizeParams(t)});return n._zod.bag.Class=e,n}var bk=(...e)=>vh({Pipe:rf,Boolean:xo,String:yo,Transform:Qh},...e);function yk(e){let t=dy(()=>ns([Rh(e),Rb(),Cb(),Pb(),Kh(t),Vb(Rh(),t)]));return t}function wk(e,t){return Ja(ef(e),t)}var xk={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function _k(e){Se({customError:e})}function Ek(){return Se().customError}var of={};_t(of,{bigint:()=>Ik,boolean:()=>kk,date:()=>Ak,number:()=>Tk,string:()=>Sk});function Sk(e){return Pp(yo,e)}function Tk(e){return Hp(wo,e)}function kk(e){return qp(xo,e)}function Ik(e){return Kp(_o,e)}function Ak(e){return ah(es,e)}Se(ya());var Rk=c.enum(x),B=c.custom(e=>typeof e=="object"&&e!==null&&!Array.isArray(e)),Y=c.string(),gy=c.enum(["developer","system","assistant","user"]),Ck=c.looseObject({type:c.literal(x.TEXT_MESSAGE_START),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y.optional(),messageId:c.string(),role:gy.optional(),name:c.string().optional()}),Nk=c.looseObject({type:c.literal(x.TEXT_MESSAGE_CONTENT),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y.optional(),messageId:c.string(),delta:c.string()}),Ok=c.looseObject({type:c.literal(x.TEXT_MESSAGE_END),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y.optional(),messageId:c.string()}),af=c.looseObject({type:c.literal(x.TEXT_MESSAGE_CHUNK),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y.optional(),messageId:c.string().optional(),role:gy.optional(),delta:c.string().optional(),name:c.string().optional()}),$k=c.looseObject({type:c.literal(x.TOOL_CALL_START),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y.optional(),toolCallId:c.string(),toolCallName:c.string(),parentMessageId:c.string().optional()}),Pk=c.looseObject({type:c.literal(x.TOOL_CALL_ARGS),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y.optional(),toolCallId:c.string(),delta:c.string()}),Mk=c.looseObject({type:c.literal(x.TOOL_CALL_END),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y.optional(),toolCallId:c.string()}),sf=c.looseObject({type:c.literal(x.TOOL_CALL_CHUNK),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y.optional(),toolCallId:c.string().optional(),toolCallName:c.string().optional(),parentMessageId:c.string().optional(),delta:c.string().optional()}),Lk=c.looseObject({type:c.literal("text"),id:c.string().optional(),text:c.string(),metadata:c.any().refine(e=>e!==null).optional()}),zk=c.looseObject({type:c.literal("data"),value:c.string(),mimeType:c.string()}),Dk=c.looseObject({type:c.literal("url"),value:c.string(),mimeType:c.string().optional()}),Uk=c.looseObject({type:c.literal("file"),value:c.string(),provider:c.string().optional(),mimeType:c.string().optional()}),os=c.discriminatedUnion("type",[zk,Dk,Uk]),jk=c.looseObject({type:c.literal("image"),id:c.string().optional(),source:os,metadata:c.any().refine(e=>e!==null).optional()}),Hk=c.looseObject({type:c.literal("audio"),id:c.string().optional(),source:os,metadata:c.any().refine(e=>e!==null).optional()}),Gk=c.looseObject({type:c.literal("video"),id:c.string().optional(),source:os,metadata:c.any().refine(e=>e!==null).optional()}),Fk=c.looseObject({type:c.literal("document"),id:c.string().optional(),source:os,metadata:c.any().refine(e=>e!==null).optional()}),lf=c.discriminatedUnion("type",[Lk,jk,Hk,Gk,Fk]),Vk=c.looseObject({type:c.literal(x.TOOL_CALL_RESULT),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y.optional(),messageId:c.string(),toolCallId:c.string(),content:c.union([c.string(),c.array(lf)]),role:c.literal("tool").optional()}),vy=c.any(),Zk=c.looseObject({type:c.literal(x.STATE_SNAPSHOT),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y.optional(),snapshot:vy.refine(e=>e!==void 0)}),Dt=c.string().regex(new RegExp("^(/([^/~]|~[01])*)*$")),Bk=c.looseObject({op:c.literal("add"),path:Dt,value:c.any().refine(e=>e!==void 0)}).meta({specOpen:!0}),Wk=c.looseObject({op:c.literal("remove"),path:Dt}).meta({specOpen:!0}),qk=c.looseObject({op:c.literal("replace"),path:Dt,value:c.any().refine(e=>e!==void 0)}).meta({specOpen:!0}),Xk=c.looseObject({op:c.literal("move"),from:Dt,path:Dt}).meta({specOpen:!0}),Kk=c.looseObject({op:c.literal("copy"),from:Dt,path:Dt}).meta({specOpen:!0}),Yk=c.looseObject({op:c.literal("test"),path:Dt,value:c.any().refine(e=>e!==void 0)}).meta({specOpen:!0}),Jk=c.discriminatedUnion("op",[Bk,Wk,qk,Xk,Kk,Yk]),by=c.array(Jk),Qk=c.looseObject({type:c.literal(x.STATE_DELTA),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y.optional(),delta:by}),eI=c.looseObject({subagentRunId:Y.optional(),id:c.string(),role:c.literal("developer"),name:c.string().optional(),encryptedValue:c.string().optional(),metadata:B.optional(),content:c.string()}),tI=c.looseObject({subagentRunId:Y.optional(),id:c.string(),role:c.literal("system"),name:c.string().optional(),encryptedValue:c.string().optional(),metadata:B.optional(),content:c.string()}),nI=c.looseObject({name:c.string(),arguments:c.string()}),rI=c.looseObject({id:c.string(),type:c.literal("function"),function:nI,encryptedValue:c.string().optional(),metadata:B.optional()}),oI=c.looseObject({subagentRunId:Y.optional(),id:c.string(),role:c.literal("assistant"),name:c.string().optional(),encryptedValue:c.string().optional(),metadata:B.optional(),content:c.string().optional(),toolCalls:c.array(rI).optional()}),iI=c.looseObject({subagentRunId:Y.optional(),id:c.string(),role:c.literal("user"),name:c.string().optional(),encryptedValue:c.string().optional(),metadata:B.optional(),content:c.union([c.string(),c.array(lf)])}),aI=c.looseObject({subagentRunId:Y.optional(),id:c.string(),role:c.literal("tool"),content:c.union([c.string(),c.array(lf)]),toolCallId:c.string(),error:c.string().optional(),encryptedValue:c.string().optional(),metadata:B.optional()}),sI=c.looseObject({subagentRunId:Y.optional(),id:c.string(),role:c.literal("activity"),activityType:c.string(),content:c.custom(e=>typeof e=="object"&&e!==null&&!Array.isArray(e)),metadata:B.optional()}),lI=c.looseObject({subagentRunId:Y.optional(),id:c.string(),role:c.literal("reasoning"),content:c.string(),encryptedValue:c.string().optional(),metadata:B.optional()}),yy=c.discriminatedUnion("role",[eI,tI,oI,iI,aI,sI,lI]),uI=c.looseObject({type:c.literal(x.MESSAGES_SNAPSHOT),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),messages:c.array(yy)}),cI=c.looseObject({type:c.literal(x.ACTIVITY_SNAPSHOT),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y.optional(),messageId:c.string(),activityType:c.string(),content:c.custom(e=>typeof e=="object"&&e!==null&&!Array.isArray(e)),replace:c.boolean().optional()}),dI=c.looseObject({type:c.literal(x.ACTIVITY_DELTA),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y.optional(),messageId:c.string(),activityType:c.string(),patch:by}),pI=c.looseObject({type:c.literal(x.RAW),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y.optional(),event:c.any().refine(e=>e!==void 0),source:c.string().optional()}),hI=c.looseObject({type:c.literal(x.CUSTOM),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y.optional(),name:c.string(),value:c.any().refine(e=>e!==void 0)}),wy=c.looseObject({name:c.string(),description:c.string(),parameters:c.any().refine(e=>e!==null).optional(),metadata:B.optional()}),fI=c.looseObject({description:c.string(),value:c.string()}),mI=c.looseObject({interruptId:c.string(),status:c.enum(["resolved","cancelled"]),payload:c.any().refine(e=>e!==null).optional(),metadata:B.optional()}),is=c.looseObject({threadId:c.string(),runId:c.string(),protocolVersion:c.string().optional(),parentRunId:c.string().optional(),state:vy.refine(e=>e!==null).nullable().transform(e=>e??void 0).optional(),messages:c.array(yy),tools:c.array(wy).default(()=>[]),context:c.array(fI).default(()=>[]),forwardedProps:c.any().refine(e=>e!==null).optional(),resume:c.array(mI).optional()}),gI=c.looseObject({type:c.literal(x.RUN_STARTED),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),threadId:c.string(),runId:c.string(),protocolVersion:c.string().optional(),parentRunId:c.string().optional(),input:is.optional()}),vI=c.looseObject({type:c.literal("success"),pendingToolCallIds:c.array(c.string()).optional()}),bI=c.looseObject({subagentRunId:Y.optional(),id:c.string(),reason:c.string(),message:c.string().optional(),toolCallId:c.string().optional(),responseSchema:c.custom(e=>typeof e=="object"&&e!==null&&!Array.isArray(e)).optional(),expiresAt:c.string().optional(),metadata:B.optional()}),yI=c.looseObject({type:c.literal("interrupt"),interrupts:c.array(bI).min(1)}),wI=c.looseObject({type:c.literal("cancelled")}),xI=c.discriminatedUnion("type",[vI,yI,wI]),xy=c.looseObject({provider:c.string().optional(),model:c.string().optional(),inputTokens:c.int().min(0).max(9007199254740991).optional(),outputTokens:c.int().min(0).max(9007199254740991).optional(),totalTokens:c.int().min(0).max(9007199254740991).optional(),reasoningTokens:c.int().min(0).max(9007199254740991).optional(),cachedInputTokens:c.int().min(0).max(9007199254740991).optional(),cacheWriteInputTokens:c.int().min(0).max(9007199254740991).optional()}),_I=c.looseObject({type:c.literal(x.RUN_FINISHED),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),threadId:c.string(),runId:c.string(),result:c.any().refine(e=>e!==null).optional(),outcome:xI.optional(),usage:c.array(xy).optional()}),EI=c.looseObject({type:c.literal(x.RUN_ERROR),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),message:c.string(),code:c.string().optional(),usage:c.array(xy).optional()}),SI=c.looseObject({type:c.literal(x.STEP_STARTED),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y.optional(),stepName:c.string()}),TI=c.looseObject({type:c.literal(x.STEP_FINISHED),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y.optional(),stepName:c.string()}),kI=c.looseObject({type:c.literal(x.REASONING_START),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y.optional(),messageId:c.string()}),II=c.looseObject({type:c.literal(x.REASONING_MESSAGE_START),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y.optional(),messageId:c.string(),role:c.literal("reasoning")}),AI=c.looseObject({type:c.literal(x.REASONING_MESSAGE_CONTENT),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y.optional(),messageId:c.string(),delta:c.string()}),RI=c.looseObject({type:c.literal(x.REASONING_MESSAGE_END),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y.optional(),messageId:c.string()}),uf=c.looseObject({type:c.literal(x.REASONING_MESSAGE_CHUNK),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y.optional(),messageId:c.string().optional(),delta:c.string().optional()}),CI=c.looseObject({type:c.literal(x.REASONING_END),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y.optional(),messageId:c.string()}),NI=c.enum(["tool-call","message"]),OI=c.looseObject({type:c.literal(x.REASONING_ENCRYPTED_VALUE),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y.optional(),subtype:NI,entityId:c.string(),encryptedValue:c.string()}),$I=c.looseObject({type:c.literal(x.SUBAGENT_STARTED),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y,name:c.string(),description:c.string().optional(),parentSubagentRunId:Y.optional(),parentToolCallId:c.string().optional(),parentMessageId:c.string().optional()}),PI=c.looseObject({type:c.literal("success")}),MI=c.looseObject({type:c.literal("suspended"),interruptIds:c.array(c.string()).optional()}),LI=c.discriminatedUnion("type",[PI,MI]),zI=c.looseObject({type:c.literal(x.SUBAGENT_FINISHED),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y,result:c.any().refine(e=>e!==null).optional(),outcome:LI.optional()}),DI=c.looseObject({type:c.literal(x.SUBAGENT_ERROR),timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional(),subagentRunId:Y,message:c.string(),code:c.string().optional()}),cf=c.discriminatedUnion("type",[Ck,Nk,Ok,af,$k,Pk,Mk,sf,Vk,Zk,Qk,uI,cI,dI,pI,hI,gI,_I,EI,SI,TI,kI,II,AI,RI,uf,CI,OI,$I,zI,DI]),lD=c.enum(["developer","system","assistant","user","tool","activity","reasoning"]),UI=c.looseObject({name:c.string(),description:c.string().optional()}),jI=c.looseObject({name:c.string().optional(),type:c.string().optional(),description:c.string().optional(),version:c.string().optional(),provider:c.string().optional(),documentationUrl:c.string().optional(),metadata:B.optional()}),HI=c.looseObject({streaming:c.boolean().optional(),websocket:c.boolean().optional(),httpBinary:c.boolean().optional(),pushNotifications:c.boolean().optional(),resumable:c.boolean().optional()}),GI=c.looseObject({supported:c.boolean().optional(),items:c.array(wy).optional(),parallelCalls:c.boolean().optional(),clientProvided:c.boolean().optional()}),FI=c.looseObject({structuredOutput:c.boolean().optional(),supportedMimeTypes:c.array(c.string()).optional()}),VI=c.looseObject({snapshots:c.boolean().optional(),deltas:c.boolean().optional(),memory:c.boolean().optional(),persistentState:c.boolean().optional()}),ZI=c.looseObject({supported:c.boolean().optional(),delegation:c.boolean().optional(),handoffs:c.boolean().optional(),subagents:c.array(UI).optional()}),BI=c.looseObject({supported:c.boolean().optional(),streaming:c.boolean().optional(),encrypted:c.boolean().optional()}),WI=c.looseObject({image:c.boolean().optional(),audio:c.boolean().optional(),video:c.boolean().optional(),pdf:c.boolean().optional(),file:c.boolean().optional()}),qI=c.looseObject({image:c.boolean().optional(),audio:c.boolean().optional()}),XI=c.looseObject({input:WI.optional(),output:qI.optional()}),KI=c.looseObject({codeExecution:c.boolean().optional(),sandboxed:c.boolean().optional(),maxIterations:c.int().min(0).max(9007199254740991).optional(),maxExecutionTime:c.int().min(0).max(9007199254740991).optional()}),YI=c.looseObject({supported:c.boolean().optional(),approvals:c.boolean().optional(),interventions:c.boolean().optional(),feedback:c.boolean().optional(),interrupts:c.boolean().optional(),approveWithEdits:c.boolean().optional()}),uD=c.looseObject({identity:jI.optional(),transport:HI.optional(),tools:GI.optional(),output:FI.optional(),state:VI.optional(),multiAgent:ZI.optional(),reasoning:BI.optional(),multimodal:XI.optional(),execution:KI.optional(),humanInTheLoop:YI.optional(),custom:c.custom(e=>typeof e=="object"&&e!==null&&!Array.isArray(e)).optional()}),cD=c.looseObject({subagentRunId:Y.optional()}),dD=c.looseObject({type:Rk,timestamp:c.int().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:c.any().refine(e=>e!==null).optional(),metadata:B.optional()}),pD=c.looseObject({subagentRunId:Y.optional(),id:c.string(),role:c.string(),name:c.string().optional(),encryptedValue:c.string().optional(),metadata:B.optional()}),hD=B.optional();function Ey(){let e=this.buf,t=this.pos,n=0,o=0;for(let i=0;i<28;i+=7){let a=e[t++];if(n|=(a&127)<<i,(a&128)==0){this.pos=t,this.assertBounds(),this.varint64Lo=n,this.varint64Hi=o;return}}let r=e[t++];if(n|=(r&15)<<28,o=(r&112)>>4,(r&128)==0){this.pos=t,this.assertBounds(),this.varint64Lo=n,this.varint64Hi=o;return}for(let i=3;i<=31;i+=7){let a=e[t++];if(o|=(a&127)<<i,(a&128)==0){this.pos=t,this.assertBounds(),this.varint64Lo=n,this.varint64Hi=o;return}}throw new Error("invalid varint")}var as=4294967296;function df(e){let t=e[0]==="-";t&&(e=e.slice(1));let n=1e6,o=0,r=0;function i(a,s){let u=Number(e.slice(a,s));r*=n,o=o*n+u,o>=as&&(r=r+(o/as|0),o=o%as)}return i(-24,-18),i(-18,-12),i(-12,-6),i(-6),t?Ty(o,r):hf(o,r)}function Sy(e,t){let n=hf(e,t),o=n.hi&2147483648;o&&(n=Ty(n.lo,n.hi));let r=pf(n.lo,n.hi);return o?"-"+r:r}function pf(e,t){if({lo:e,hi:t}=JI(e,t),t<=2097151)return String(as*t+e);let n=e&16777215,o=(e>>>24|t<<8)&16777215,r=t>>16&65535,i=n+o*6777216+r*6710656,a=o+r*8147497,s=r*2,u=1e7;return i>=u&&(a+=Math.floor(i/u),i%=u),a>=u&&(s+=Math.floor(a/u),a%=u),s.toString()+_y(a)+_y(i)}function JI(e,t){return{lo:e>>>0,hi:t>>>0}}function hf(e,t){return{lo:e|0,hi:t|0}}function Ty(e,t){return t=~t,e?e=~e+1:t+=1,hf(e,t)}var _y=e=>{let t=String(e);return"0000000".slice(t.length)+t};function ky(){let e=this.buf[this.pos++];if((e&128)===0)return this.assertBounds(),e;let t=e&127;if(e=this.buf[this.pos++],t|=(e&127)<<7,(e&128)===0)return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(e&127)<<14,(e&128)===0)return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(e&127)<<21,(e&128)===0)return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let n=5;(e&128)!==0&&n<10;n++)e=this.buf[this.pos++];if((e&128)!==0)throw new Error("invalid varint");return this.assertBounds(),t>>>0}var lt=QI();function QI(){let e=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof e.getBigInt64=="function"&&typeof e.getBigUint64=="function"&&typeof e.setBigInt64=="function"&&typeof e.setBigUint64=="function"&&(!!globalThis.Deno||!!globalThis.Bun||typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){let n=BigInt("-9223372036854775808"),o=BigInt("9223372036854775807"),r=BigInt("0"),i=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(a){let s=typeof a=="bigint"?a:BigInt(a);if(s>o||s<n)throw new Error(`invalid int64: ${a}`);return s},uParse(a){let s=typeof a=="bigint"?a:BigInt(a);if(s>i||s<r)throw new Error(`invalid uint64: ${a}`);return s},enc(a){return e.setBigInt64(0,this.parse(a),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(a){return e.setBigInt64(0,this.uParse(a),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec(a,s){return e.setInt32(0,a,!0),e.setInt32(4,s,!0),e.getBigInt64(0,!0)},uDec(a,s){return e.setInt32(0,a,!0),e.setInt32(4,s,!0),e.getBigUint64(0,!0)}}}return{zero:"0",supported:!1,parse(n){return typeof n!="string"&&(n=n.toString()),Iy(n),n},uParse(n){return typeof n!="string"&&(n=n.toString()),Ay(n),n},enc(n){return typeof n!="string"&&(n=n.toString()),Iy(n),df(n)},uEnc(n){return typeof n!="string"&&(n=n.toString()),Ay(n),df(n)},dec(n,o){return Sy(n,o)},uDec(n,o){return pf(n,o)}}}function Iy(e){if(!/^-?[0-9]+$/.test(e))throw new Error("invalid int64: "+e)}function Ay(e){if(!/^[0-9]+$/.test(e))throw new Error("invalid uint64: "+e)}var ff=Symbol.for("@bufbuild/protobuf/text-encoding");function eA(e){var t;globalThis[ff]=Object.assign(Object.assign({},e),{encodeUtf8Into:(t=e.encodeUtf8Into)!==null&&t!==void 0?t:gf(e.encodeUtf8.bind(e))})}function mf(){let e=globalThis;if(!e[ff]){let t=new e.TextEncoder,n=new e.TextDecoder,o,r={encodeUtf8(a){return t.encode(a)},decodeUtf8(a,s){return s?(o||(o=new e.TextDecoder("utf-8",{fatal:!0})),o.decode(a)):n.decode(a)},checkUtf8(a){try{return encodeURIComponent(a),!0}catch{return!1}}};t.encodeInto&&(r.encodeUtf8Into=t.encodeInto.bind(t));let i=String.prototype.isWellFormed;i&&(r.checkUtf8=a=>i.call(a)),eA(r)}return e[ff]}function gf(e){return(t,n)=>{let o=e(t);return n.set(o),{written:o.byteLength}}}var Ut;(function(e){e[e.Varint=0]="Varint",e[e.Bit64=1]="Bit64",e[e.LengthDelimited=2]="LengthDelimited",e[e.StartGroup=3]="StartGroup",e[e.EndGroup=4]="EndGroup",e[e.Bit32=5]="Bit32"})(Ut||(Ut={}));var tA=34028234663852886e22,nA=-34028234663852886e22,rA=4294967295,oA=2147483647,iA=-2147483648,H=class{constructor(t){this.stackPos=[],this.encodeUtf8Into=t?gf(t):mf().encodeUtf8Into,this.buffer=Cy,this.viewCache=sA,this.pos=0}ensureCapacity(t){let n=this.pos+t;if(n>this.buffer.length){let o=this.buffer.length||aA;for(;o<n;)o*=2;let r=new Uint8Array(o);this.pos>0&&r.set(this.buffer),this.buffer=r}}view(){let t=this.buffer,n=this.viewCache;if(n.byteLength===t.byteLength)return n;let o=new DataView(t.buffer);return this.viewCache=o,o}finish(){let t=this.buffer.slice(0,this.pos);return this.pos=0,this.stackPos=[],t}fork(){return this.stackPos.push(this.pos),this.ensureCapacity(Eo),this.buffer[this.pos++]=0,this}join(){let t=this.stackPos.pop();if(t===void 0)throw new Error("invalid state, fork stack empty");let n=this.pos-t-Eo,o=vf(n);return o>Eo&&(this.ensureCapacity(o-Eo),this.buffer.copyWithin(t+o,t+Eo,this.pos)),this.pos=t,this.uint32(n),this.pos+=n,this}tag(t,n){return this.uint32((t<<3|n)>>>0)}raw(t){return this.ensureCapacity(t.length),this.buffer.set(t,this.pos),this.pos+=t.length,this}uint32(t){if(Ry(t),this.ensureCapacity(5),t<128)return this.buffer[this.pos++]=t,this;for(;t>127;)this.buffer[this.pos++]=t&127|128,t>>>=7;return this.buffer[this.pos++]=t,this}int32(t){if(bf(t),t>=0)return this.uint32(t);this.ensureCapacity(10);for(let n=0;n<9;n++)this.buffer[this.pos++]=t&127|128,t>>=7;return this.buffer[this.pos++]=1,this}bool(t){return this.ensureCapacity(1),this.buffer[this.pos++]=t?1:0,this}bytes(t){return this.uint32(t.byteLength),this.raw(t)}string(t){typeof t!="string"&&(t=String(t));let n=t.length;if(n<=Ny){this.ensureCapacity(n+1);let u=this.buffer,l=this.pos;u[l++]=n;let d=0;for(;d<n;d++){let h=t.charCodeAt(d);if(h>127)break;u[l++]=h}if(d==n)return this.pos=l,this}this.ensureCapacity(n*3+5);let o=vf(n),r=this.buffer,i=this.pos,{written:a}=this.encodeUtf8Into(t,r.subarray(i+o)),s=vf(a);return s!=o&&r.copyWithin(i+s,i+o,i+o+a),this.uint32(a),this.pos+=a,this}float(t){return lA(t),this.ensureCapacity(4),this.view().setFloat32(this.pos,t,!0),this.pos+=4,this}double(t){return this.ensureCapacity(8),this.view().setFloat64(this.pos,t,!0),this.pos+=8,this}fixed32(t){return Ry(t),this.ensureCapacity(4),this.view().setUint32(this.pos,t,!0),this.pos+=4,this}sfixed32(t){return bf(t),this.ensureCapacity(4),this.view().setInt32(this.pos,t,!0),this.pos+=4,this}sint32(t){return bf(t),this.uint32((t<<1^t>>31)>>>0)}sfixed64(t){let n=lt.enc(t);this.ensureCapacity(8);let o=this.view();return o.setInt32(this.pos,n.lo,!0),o.setInt32(this.pos+4,n.hi,!0),this.pos+=8,this}fixed64(t){let n=lt.uEnc(t);this.ensureCapacity(8);let o=this.view();return o.setInt32(this.pos,n.lo,!0),o.setInt32(this.pos+4,n.hi,!0),this.pos+=8,this}int64(t){let n=lt.enc(t);return this.writeVarint64(n.lo,n.hi)}sint64(t){let n=lt.enc(t),o=n.hi>>31,r=n.lo<<1^o,i=(n.hi<<1|n.lo>>>31)^o;return this.writeVarint64(r,i)}uint64(t){let n=lt.uEnc(t);return this.writeVarint64(n.lo,n.hi)}writeVarint64(t,n){this.ensureCapacity(10);let o=this.buffer,r=this.pos;for(let s=0;s<28;s=s+7){let u=t>>>s,l=!(!(u>>>7)&&n==0);if(o[r++]=(l?u|128:u)&255,!l)return this.pos=r,this}let i=t>>>28&15|(n&7)<<4,a=n>>3!=0;if(o[r++]=(a?i|128:i)&255,!a)return this.pos=r,this;for(let s=3;s<31;s=s+7){let u=n>>>s,l=!!(u>>>7);if(o[r++]=(l?u|128:u)&255,!l)return this.pos=r,this}return o[r++]=n>>>31&1,this.pos=r,this}},aA=128,Eo=1,Cy=new Uint8Array(0),sA=new DataView(Cy.buffer),Ny=32;function vf(e){return e<128?1:e<16384?2:e<2097152?3:e<268435456?4:5}var C=class{constructor(t,n=mf().decodeUtf8){this.decodeUtf8=n,this.varint64Lo=0,this.varint64Hi=0,this.varint64=Ey,this.uint32=ky,this.buf=t,this.len=t.length,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength)}tag(){let t=this.pos,n=this.uint32(),o=this.pos-t;if(o>5||o==5&&this.buf[this.pos-1]>15)throw new Error("illegal tag: varint overflows uint32");let r=n>>>3,i=n&7;if(r<=0||i>5)throw new Error("illegal tag: field no "+r+" wire type "+i);return[r,i]}skip(t,n,o=100){let r=this.pos;switch(t){case Ut.Varint:for(;this.buf[this.pos++]&128;);break;case Ut.Bit64:this.pos+=4;case Ut.Bit32:this.pos+=4;break;case Ut.LengthDelimited:let i=this.uint32();this.pos+=i;break;case Ut.StartGroup:if(o<=0)throw new Error("maximum recursion depth reached");for(;;){let[a,s]=this.tag();if(s===Ut.EndGroup){if(n!==void 0&&a!==n)throw new Error("invalid end group tag");break}this.skip(s,a,o-1)}break;default:throw new Error("cant skip wire type "+t)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)}int64(){return this.varint64(),lt.dec(this.varint64Lo,this.varint64Hi)}uint64(){return this.varint64(),lt.uDec(this.varint64Lo,this.varint64Hi)}sint64(){this.varint64();let t=this.varint64Lo,n=this.varint64Hi,o=-(t&1);return t=(t>>>1|(n&1)<<31)^o,n=n>>>1^o,lt.dec(t,n)}bool(){let t=this.buf[this.pos];return t<128?(this.pos++,t!==0):(this.varint64(),this.varint64Lo!==0||this.varint64Hi!==0)}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return lt.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return lt.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let t=this.uint32(),n=this.pos;return this.pos+=t,this.assertBounds(),this.buf.subarray(n,n+t)}string(t){let n=this.bytes(),o=n.length;if(o<=Ny){let r=new Array(o);for(let i=0;i<o;i++){let a=n[i];if(a>127)return this.decodeUtf8(n,t);r[i]=a}return String.fromCharCode.apply(String,r)}return this.decodeUtf8(n,t)}};function bf(e){if(typeof e=="string")e=Number(e);else if(typeof e!="number")throw new Error("invalid int32: "+typeof e);if(!Number.isInteger(e)||e>oA||e<iA)throw new Error("invalid int32: "+e)}function Ry(e){if(typeof e=="string")e=Number(e);else if(typeof e!="number")throw new Error("invalid uint32: "+typeof e);if(!Number.isInteger(e)||e>rA||e<0)throw new Error("invalid uint32: "+e)}function lA(e){if(typeof e=="string"){let t=e;if(e=Number(e),Number.isNaN(e)&&t!=="NaN")throw new Error("invalid float32: "+t)}else if(typeof e!="number")throw new Error("invalid float32: "+typeof e);if(Number.isFinite(e)&&(e>tA||e<nA))throw new Error("invalid float32: "+e)}var uA=(function(e){return e[e.NULL_VALUE=0]="NULL_VALUE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e})({});function yf(){return{fields:{}}}var ee={encode(e,t=new H){return Object.entries(e.fields).forEach(([n,o])=>{o!==void 0&&_f.encode({key:n,value:o},t.uint32(10).fork()).join()}),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=yf();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:{if(i!==10)break;let a=_f.decode(n,n.uint32());a.value!==void 0&&(r.fields[a.key]=a.value);continue}}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return ee.fromPartial(e??{})},fromPartial(e){let t=yf();return t.fields=Object.entries(e.fields??{}).reduce((n,[o,r])=>(r!==void 0&&(n[o]=r),n),{}),t},wrap(e){let t=yf();if(e!==void 0)for(let n of Object.keys(e))t.fields[n]=e[n];return t},unwrap(e){let t={};if(e.fields)for(let n of Object.keys(e.fields))t[n]=e.fields[n];return t}};function Oy(){return{key:"",value:void 0}}var _f={encode(e,t=new H){return e.key!==""&&t.uint32(10).string(e.key),e.value!==void 0&&M.encode(M.wrap(e.value),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Oy();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.key=n.string();continue;case 2:if(i!==18)break;r.value=M.unwrap(M.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return _f.fromPartial(e??{})},fromPartial(e){let t=Oy();return t.key=e.key??"",t.value=e.value??void 0,t}};function wf(){return{nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0}}var M={encode(e,t=new H){return e.nullValue!==void 0&&t.uint32(8).int32(e.nullValue),e.numberValue!==void 0&&t.uint32(17).double(e.numberValue),e.stringValue!==void 0&&t.uint32(26).string(e.stringValue),e.boolValue!==void 0&&t.uint32(32).bool(e.boolValue),e.structValue!==void 0&&ee.encode(ee.wrap(e.structValue),t.uint32(42).fork()).join(),e.listValue!==void 0&&So.encode(So.wrap(e.listValue),t.uint32(50).fork()).join(),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=wf();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==8)break;r.nullValue=n.int32();continue;case 2:if(i!==17)break;r.numberValue=n.double();continue;case 3:if(i!==26)break;r.stringValue=n.string();continue;case 4:if(i!==32)break;r.boolValue=n.bool();continue;case 5:if(i!==42)break;r.structValue=ee.unwrap(ee.decode(n,n.uint32()));continue;case 6:if(i!==50)break;r.listValue=So.unwrap(So.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return M.fromPartial(e??{})},fromPartial(e){let t=wf();return t.nullValue=e.nullValue??void 0,t.numberValue=e.numberValue??void 0,t.stringValue=e.stringValue??void 0,t.boolValue=e.boolValue??void 0,t.structValue=e.structValue??void 0,t.listValue=e.listValue??void 0,t},wrap(e){let t=wf();if(e===null)t.nullValue=uA.NULL_VALUE;else if(typeof e=="boolean")t.boolValue=e;else if(typeof e=="number")t.numberValue=e;else if(typeof e=="string")t.stringValue=e;else if(globalThis.Array.isArray(e))t.listValue=e;else if(typeof e=="object")t.structValue=e;else if(typeof e<"u")throw new globalThis.Error("Unsupported any value type: "+typeof e);return t},unwrap(e){if(e.stringValue!==void 0)return e.stringValue;if(e?.numberValue!==void 0)return e.numberValue;if(e?.boolValue!==void 0)return e.boolValue;if(e?.structValue!==void 0)return e.structValue;if(e?.listValue!==void 0)return e.listValue;if(e?.nullValue!==void 0)return null}};function xf(){return{values:[]}}var So={encode(e,t=new H){for(let n of e.values)M.encode(M.wrap(n),t.uint32(10).fork()).join();return t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=xf();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.values.push(M.unwrap(M.decode(n,n.uint32())));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return So.fromPartial(e??{})},fromPartial(e){let t=xf();return t.values=e.values?.map(n=>n)||[],t},wrap(e){let t=xf();return t.values=e??[],t},unwrap(e){return e?.hasOwnProperty("values")&&globalThis.Array.isArray(e.values)?e.values:e}},$y=(function(e){return e[e.ADD=0]="ADD",e[e.REMOVE=1]="REMOVE",e[e.REPLACE=2]="REPLACE",e[e.MOVE=3]="MOVE",e[e.COPY=4]="COPY",e[e.TEST=5]="TEST",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e})({});function Py(){return{op:0,path:"",from:void 0,value:void 0}}var fn={encode(e,t=new H){return e.op!==0&&t.uint32(8).int32(e.op),e.path!==""&&t.uint32(18).string(e.path),e.from!==void 0&&t.uint32(26).string(e.from),e.value!==void 0&&M.encode(M.wrap(e.value),t.uint32(34).fork()).join(),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Py();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==8)break;r.op=n.int32();continue;case 2:if(i!==18)break;r.path=n.string();continue;case 3:if(i!==26)break;r.from=n.string();continue;case 4:if(i!==34)break;r.value=M.unwrap(M.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return fn.fromPartial(e??{})},fromPartial(e){let t=Py();return t.op=e.op??0,t.path=e.path??"",t.from=e.from??void 0,t.value=e.value??void 0,t}};function My(){return{text:"",id:void 0,metadata:void 0}}var ss={encode(e,t=new H){return e.text!==""&&t.uint32(10).string(e.text),e.id!==void 0&&t.uint32(18).string(e.id),e.metadata!==void 0&&M.encode(M.wrap(e.metadata),t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=My();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.text=n.string();continue;case 2:if(i!==18)break;r.id=n.string();continue;case 3:if(i!==26)break;r.metadata=M.unwrap(M.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return ss.fromPartial(e??{})},fromPartial(e){let t=My();return t.text=e.text??"",t.id=e.id??void 0,t.metadata=e.metadata??void 0,t}};function Ly(){return{source:void 0,metadata:void 0,id:void 0}}var ls={encode(e,t=new H){return e.source!==void 0&&Xe.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&M.encode(M.wrap(e.metadata),t.uint32(18).fork()).join(),e.id!==void 0&&t.uint32(26).string(e.id),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Ly();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.source=Xe.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.metadata=M.unwrap(M.decode(n,n.uint32()));continue;case 3:if(i!==26)break;r.id=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return ls.fromPartial(e??{})},fromPartial(e){let t=Ly();return t.source=e.source!==void 0&&e.source!==null?Xe.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t.id=e.id??void 0,t}};function zy(){return{value:"",mimeType:""}}var us={encode(e,t=new H){return e.value!==""&&t.uint32(10).string(e.value),e.mimeType!==""&&t.uint32(18).string(e.mimeType),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=zy();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.value=n.string();continue;case 2:if(i!==18)break;r.mimeType=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return us.fromPartial(e??{})},fromPartial(e){let t=zy();return t.value=e.value??"",t.mimeType=e.mimeType??"",t}};function Dy(){return{value:"",mimeType:void 0}}var cs={encode(e,t=new H){return e.value!==""&&t.uint32(10).string(e.value),e.mimeType!==void 0&&t.uint32(18).string(e.mimeType),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Dy();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.value=n.string();continue;case 2:if(i!==18)break;r.mimeType=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return cs.fromPartial(e??{})},fromPartial(e){let t=Dy();return t.value=e.value??"",t.mimeType=e.mimeType??void 0,t}};function Uy(){return{value:"",provider:void 0,mimeType:void 0}}var ds={encode(e,t=new H){return e.value!==""&&t.uint32(10).string(e.value),e.provider!==void 0&&t.uint32(18).string(e.provider),e.mimeType!==void 0&&t.uint32(26).string(e.mimeType),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Uy();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.value=n.string();continue;case 2:if(i!==18)break;r.provider=n.string();continue;case 3:if(i!==26)break;r.mimeType=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return ds.fromPartial(e??{})},fromPartial(e){let t=Uy();return t.value=e.value??"",t.provider=e.provider??void 0,t.mimeType=e.mimeType??void 0,t}};function jy(){return{data:void 0,url:void 0,file:void 0}}var Xe={encode(e,t=new H){return e.data!==void 0&&us.encode(e.data,t.uint32(10).fork()).join(),e.url!==void 0&&cs.encode(e.url,t.uint32(18).fork()).join(),e.file!==void 0&&ds.encode(e.file,t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=jy();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.data=us.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.url=cs.decode(n,n.uint32());continue;case 3:if(i!==26)break;r.file=ds.decode(n,n.uint32());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Xe.fromPartial(e??{})},fromPartial(e){let t=jy();return t.data=e.data!==void 0&&e.data!==null?us.fromPartial(e.data):void 0,t.url=e.url!==void 0&&e.url!==null?cs.fromPartial(e.url):void 0,t.file=e.file!==void 0&&e.file!==null?ds.fromPartial(e.file):void 0,t}};function Hy(){return{source:void 0,metadata:void 0,id:void 0}}var ps={encode(e,t=new H){return e.source!==void 0&&Xe.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&M.encode(M.wrap(e.metadata),t.uint32(18).fork()).join(),e.id!==void 0&&t.uint32(26).string(e.id),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Hy();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.source=Xe.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.metadata=M.unwrap(M.decode(n,n.uint32()));continue;case 3:if(i!==26)break;r.id=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return ps.fromPartial(e??{})},fromPartial(e){let t=Hy();return t.source=e.source!==void 0&&e.source!==null?Xe.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t.id=e.id??void 0,t}};function Gy(){return{source:void 0,metadata:void 0,id:void 0}}var hs={encode(e,t=new H){return e.source!==void 0&&Xe.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&M.encode(M.wrap(e.metadata),t.uint32(18).fork()).join(),e.id!==void 0&&t.uint32(26).string(e.id),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Gy();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.source=Xe.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.metadata=M.unwrap(M.decode(n,n.uint32()));continue;case 3:if(i!==26)break;r.id=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return hs.fromPartial(e??{})},fromPartial(e){let t=Gy();return t.source=e.source!==void 0&&e.source!==null?Xe.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t.id=e.id??void 0,t}};function Fy(){return{source:void 0,metadata:void 0,id:void 0}}var fs={encode(e,t=new H){return e.source!==void 0&&Xe.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&M.encode(M.wrap(e.metadata),t.uint32(18).fork()).join(),e.id!==void 0&&t.uint32(26).string(e.id),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Fy();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.source=Xe.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.metadata=M.unwrap(M.decode(n,n.uint32()));continue;case 3:if(i!==26)break;r.id=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return fs.fromPartial(e??{})},fromPartial(e){let t=Fy();return t.source=e.source!==void 0&&e.source!==null?Xe.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t.id=e.id??void 0,t}};function Vy(){return{text:void 0,image:void 0,audio:void 0,video:void 0,document:void 0}}var mn={encode(e,t=new H){return e.text!==void 0&&ss.encode(e.text,t.uint32(10).fork()).join(),e.image!==void 0&&ls.encode(e.image,t.uint32(18).fork()).join(),e.audio!==void 0&&ps.encode(e.audio,t.uint32(26).fork()).join(),e.video!==void 0&&hs.encode(e.video,t.uint32(34).fork()).join(),e.document!==void 0&&fs.encode(e.document,t.uint32(42).fork()).join(),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Vy();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.text=ss.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.image=ls.decode(n,n.uint32());continue;case 3:if(i!==26)break;r.audio=ps.decode(n,n.uint32());continue;case 4:if(i!==34)break;r.video=hs.decode(n,n.uint32());continue;case 5:if(i!==42)break;r.document=fs.decode(n,n.uint32());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return mn.fromPartial(e??{})},fromPartial(e){let t=Vy();return t.text=e.text!==void 0&&e.text!==null?ss.fromPartial(e.text):void 0,t.image=e.image!==void 0&&e.image!==null?ls.fromPartial(e.image):void 0,t.audio=e.audio!==void 0&&e.audio!==null?ps.fromPartial(e.audio):void 0,t.video=e.video!==void 0&&e.video!==null?hs.fromPartial(e.video):void 0,t.document=e.document!==void 0&&e.document!==null?fs.fromPartial(e.document):void 0,t}};function Zy(){return{id:"",type:"",function:void 0,metadata:void 0,encryptedValue:void 0}}var ms={encode(e,t=new H){return e.id!==""&&t.uint32(10).string(e.id),e.type!==""&&t.uint32(18).string(e.type),e.function!==void 0&&gs.encode(e.function,t.uint32(26).fork()).join(),e.metadata!==void 0&&ee.encode(ee.wrap(e.metadata),t.uint32(34).fork()).join(),e.encryptedValue!==void 0&&t.uint32(42).string(e.encryptedValue),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Zy();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.id=n.string();continue;case 2:if(i!==18)break;r.type=n.string();continue;case 3:if(i!==26)break;r.function=gs.decode(n,n.uint32());continue;case 4:if(i!==34)break;r.metadata=ee.unwrap(ee.decode(n,n.uint32()));continue;case 5:if(i!==42)break;r.encryptedValue=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return ms.fromPartial(e??{})},fromPartial(e){let t=Zy();return t.id=e.id??"",t.type=e.type??"",t.function=e.function!==void 0&&e.function!==null?gs.fromPartial(e.function):void 0,t.metadata=e.metadata??void 0,t.encryptedValue=e.encryptedValue??void 0,t}};function By(){return{name:"",arguments:""}}var gs={encode(e,t=new H){return e.name!==""&&t.uint32(10).string(e.name),e.arguments!==""&&t.uint32(18).string(e.arguments),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=By();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.name=n.string();continue;case 2:if(i!==18)break;r.arguments=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return gs.fromPartial(e??{})},fromPartial(e){let t=By();return t.name=e.name??"",t.arguments=e.arguments??"",t}};function Wy(){return{id:"",role:"",content:void 0,name:void 0,toolCalls:[],toolCallId:void 0,error:void 0,contentParts:[],metadata:void 0,subagentRunId:void 0,encryptedValue:void 0,activityType:void 0,activityContent:void 0}}var gn={encode(e,t=new H){e.id!==""&&t.uint32(10).string(e.id),e.role!==""&&t.uint32(18).string(e.role),e.content!==void 0&&t.uint32(26).string(e.content),e.name!==void 0&&t.uint32(34).string(e.name);for(let n of e.toolCalls)ms.encode(n,t.uint32(42).fork()).join();e.toolCallId!==void 0&&t.uint32(50).string(e.toolCallId),e.error!==void 0&&t.uint32(58).string(e.error);for(let n of e.contentParts)mn.encode(n,t.uint32(66).fork()).join();return e.metadata!==void 0&&ee.encode(ee.wrap(e.metadata),t.uint32(74).fork()).join(),e.subagentRunId!==void 0&&t.uint32(82).string(e.subagentRunId),e.encryptedValue!==void 0&&t.uint32(90).string(e.encryptedValue),e.activityType!==void 0&&t.uint32(98).string(e.activityType),e.activityContent!==void 0&&ee.encode(ee.wrap(e.activityContent),t.uint32(106).fork()).join(),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Wy();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.id=n.string();continue;case 2:if(i!==18)break;r.role=n.string();continue;case 3:if(i!==26)break;r.content=n.string();continue;case 4:if(i!==34)break;r.name=n.string();continue;case 5:if(i!==42)break;r.toolCalls.push(ms.decode(n,n.uint32()));continue;case 6:if(i!==50)break;r.toolCallId=n.string();continue;case 7:if(i!==58)break;r.error=n.string();continue;case 8:if(i!==66)break;r.contentParts.push(mn.decode(n,n.uint32()));continue;case 9:if(i!==74)break;r.metadata=ee.unwrap(ee.decode(n,n.uint32()));continue;case 10:if(i!==82)break;r.subagentRunId=n.string();continue;case 11:if(i!==90)break;r.encryptedValue=n.string();continue;case 12:if(i!==98)break;r.activityType=n.string();continue;case 13:if(i!==106)break;r.activityContent=ee.unwrap(ee.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return gn.fromPartial(e??{})},fromPartial(e){let t=Wy();return t.id=e.id??"",t.role=e.role??"",t.content=e.content??void 0,t.name=e.name??void 0,t.toolCalls=e.toolCalls?.map(n=>ms.fromPartial(n))||[],t.toolCallId=e.toolCallId??void 0,t.error=e.error??void 0,t.contentParts=e.contentParts?.map(n=>mn.fromPartial(n))||[],t.metadata=e.metadata??void 0,t.subagentRunId=e.subagentRunId??void 0,t.encryptedValue=e.encryptedValue??void 0,t.activityType=e.activityType??void 0,t.activityContent=e.activityContent??void 0,t}};function qy(){return{name:"",description:"",parameters:void 0,metadata:void 0}}var vs={encode(e,t=new H){return e.name!==""&&t.uint32(10).string(e.name),e.description!==""&&t.uint32(18).string(e.description),e.parameters!==void 0&&M.encode(M.wrap(e.parameters),t.uint32(26).fork()).join(),e.metadata!==void 0&&ee.encode(ee.wrap(e.metadata),t.uint32(34).fork()).join(),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=qy();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.name=n.string();continue;case 2:if(i!==18)break;r.description=n.string();continue;case 3:if(i!==26)break;r.parameters=M.unwrap(M.decode(n,n.uint32()));continue;case 4:if(i!==34)break;r.metadata=ee.unwrap(ee.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return vs.fromPartial(e??{})},fromPartial(e){let t=qy();return t.name=e.name??"",t.description=e.description??"",t.parameters=e.parameters??void 0,t.metadata=e.metadata??void 0,t}};function Xy(){return{description:"",value:""}}var bs={encode(e,t=new H){return e.description!==""&&t.uint32(10).string(e.description),e.value!==""&&t.uint32(18).string(e.value),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Xy();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.description=n.string();continue;case 2:if(i!==18)break;r.value=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return bs.fromPartial(e??{})},fromPartial(e){let t=Xy();return t.description=e.description??"",t.value=e.value??"",t}};function Ky(){return{interruptId:"",status:"",payload:void 0,metadata:void 0}}var ys={encode(e,t=new H){return e.interruptId!==""&&t.uint32(10).string(e.interruptId),e.status!==""&&t.uint32(18).string(e.status),e.payload!==void 0&&M.encode(M.wrap(e.payload),t.uint32(26).fork()).join(),e.metadata!==void 0&&ee.encode(ee.wrap(e.metadata),t.uint32(34).fork()).join(),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Ky();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.interruptId=n.string();continue;case 2:if(i!==18)break;r.status=n.string();continue;case 3:if(i!==26)break;r.payload=M.unwrap(M.decode(n,n.uint32()));continue;case 4:if(i!==34)break;r.metadata=ee.unwrap(ee.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return ys.fromPartial(e??{})},fromPartial(e){let t=Ky();return t.interruptId=e.interruptId??"",t.status=e.status??"",t.payload=e.payload??void 0,t.metadata=e.metadata??void 0,t}};function Yy(){return{threadId:"",runId:"",parentRunId:void 0,state:void 0,messages:[],tools:[],context:[],forwardedProps:void 0,resume:[],protocolVersion:void 0}}var ws={encode(e,t=new H){e.threadId!==""&&t.uint32(10).string(e.threadId),e.runId!==""&&t.uint32(18).string(e.runId),e.parentRunId!==void 0&&t.uint32(26).string(e.parentRunId),e.state!==void 0&&M.encode(M.wrap(e.state),t.uint32(34).fork()).join();for(let n of e.messages)gn.encode(n,t.uint32(42).fork()).join();for(let n of e.tools)vs.encode(n,t.uint32(50).fork()).join();for(let n of e.context)bs.encode(n,t.uint32(58).fork()).join();e.forwardedProps!==void 0&&M.encode(M.wrap(e.forwardedProps),t.uint32(66).fork()).join();for(let n of e.resume)ys.encode(n,t.uint32(74).fork()).join();return e.protocolVersion!==void 0&&t.uint32(82).string(e.protocolVersion),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Yy();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.threadId=n.string();continue;case 2:if(i!==18)break;r.runId=n.string();continue;case 3:if(i!==26)break;r.parentRunId=n.string();continue;case 4:if(i!==34)break;r.state=M.unwrap(M.decode(n,n.uint32()));continue;case 5:if(i!==42)break;r.messages.push(gn.decode(n,n.uint32()));continue;case 6:if(i!==50)break;r.tools.push(vs.decode(n,n.uint32()));continue;case 7:if(i!==58)break;r.context.push(bs.decode(n,n.uint32()));continue;case 8:if(i!==66)break;r.forwardedProps=M.unwrap(M.decode(n,n.uint32()));continue;case 9:if(i!==74)break;r.resume.push(ys.decode(n,n.uint32()));continue;case 10:if(i!==82)break;r.protocolVersion=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return ws.fromPartial(e??{})},fromPartial(e){let t=Yy();return t.threadId=e.threadId??"",t.runId=e.runId??"",t.parentRunId=e.parentRunId??void 0,t.state=e.state??void 0,t.messages=e.messages?.map(n=>gn.fromPartial(n))||[],t.tools=e.tools?.map(n=>vs.fromPartial(n))||[],t.context=e.context?.map(n=>bs.fromPartial(n))||[],t.forwardedProps=e.forwardedProps??void 0,t.resume=e.resume?.map(n=>ys.fromPartial(n))||[],t.protocolVersion=e.protocolVersion??void 0,t}};function Jy(){return{id:"",reason:"",message:void 0,toolCallId:void 0,responseSchema:void 0,expiresAt:void 0,metadata:void 0,subagentRunId:void 0}}var xs={encode(e,t=new H){return e.id!==""&&t.uint32(10).string(e.id),e.reason!==""&&t.uint32(18).string(e.reason),e.message!==void 0&&t.uint32(26).string(e.message),e.toolCallId!==void 0&&t.uint32(34).string(e.toolCallId),e.responseSchema!==void 0&&M.encode(M.wrap(e.responseSchema),t.uint32(42).fork()).join(),e.expiresAt!==void 0&&t.uint32(50).string(e.expiresAt),e.metadata!==void 0&&M.encode(M.wrap(e.metadata),t.uint32(58).fork()).join(),e.subagentRunId!==void 0&&t.uint32(66).string(e.subagentRunId),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Jy();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.id=n.string();continue;case 2:if(i!==18)break;r.reason=n.string();continue;case 3:if(i!==26)break;r.message=n.string();continue;case 4:if(i!==34)break;r.toolCallId=n.string();continue;case 5:if(i!==42)break;r.responseSchema=M.unwrap(M.decode(n,n.uint32()));continue;case 6:if(i!==50)break;r.expiresAt=n.string();continue;case 7:if(i!==58)break;r.metadata=M.unwrap(M.decode(n,n.uint32()));continue;case 8:if(i!==66)break;r.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return xs.fromPartial(e??{})},fromPartial(e){let t=Jy();return t.id=e.id??"",t.reason=e.reason??"",t.message=e.message??void 0,t.toolCallId=e.toolCallId??void 0,t.responseSchema=e.responseSchema??void 0,t.expiresAt=e.expiresAt??void 0,t.metadata=e.metadata??void 0,t.subagentRunId=e.subagentRunId??void 0,t}},cA=(function(e){return e[e.TEXT_MESSAGE_START=0]="TEXT_MESSAGE_START",e[e.TEXT_MESSAGE_CONTENT=1]="TEXT_MESSAGE_CONTENT",e[e.TEXT_MESSAGE_END=2]="TEXT_MESSAGE_END",e[e.TOOL_CALL_START=3]="TOOL_CALL_START",e[e.TOOL_CALL_ARGS=4]="TOOL_CALL_ARGS",e[e.TOOL_CALL_END=5]="TOOL_CALL_END",e[e.STATE_SNAPSHOT=6]="STATE_SNAPSHOT",e[e.STATE_DELTA=7]="STATE_DELTA",e[e.MESSAGES_SNAPSHOT=8]="MESSAGES_SNAPSHOT",e[e.RAW=9]="RAW",e[e.CUSTOM=10]="CUSTOM",e[e.RUN_STARTED=11]="RUN_STARTED",e[e.RUN_FINISHED=12]="RUN_FINISHED",e[e.RUN_ERROR=13]="RUN_ERROR",e[e.STEP_STARTED=14]="STEP_STARTED",e[e.STEP_FINISHED=15]="STEP_FINISHED",e[e.SUBAGENT_STARTED=16]="SUBAGENT_STARTED",e[e.SUBAGENT_FINISHED=17]="SUBAGENT_FINISHED",e[e.SUBAGENT_ERROR=18]="SUBAGENT_ERROR",e[e.TEXT_MESSAGE_CHUNK=19]="TEXT_MESSAGE_CHUNK",e[e.TOOL_CALL_CHUNK=20]="TOOL_CALL_CHUNK",e[e.TOOL_CALL_RESULT=21]="TOOL_CALL_RESULT",e[e.ACTIVITY_SNAPSHOT=22]="ACTIVITY_SNAPSHOT",e[e.ACTIVITY_DELTA=23]="ACTIVITY_DELTA",e[e.REASONING_START=24]="REASONING_START",e[e.REASONING_MESSAGE_START=25]="REASONING_MESSAGE_START",e[e.REASONING_MESSAGE_CONTENT=26]="REASONING_MESSAGE_CONTENT",e[e.REASONING_MESSAGE_END=27]="REASONING_MESSAGE_END",e[e.REASONING_MESSAGE_CHUNK=28]="REASONING_MESSAGE_CHUNK",e[e.REASONING_END=29]="REASONING_END",e[e.REASONING_ENCRYPTED_VALUE=30]="REASONING_ENCRYPTED_VALUE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e})({});function Qy(){return{type:0,timestamp:void 0,rawEvent:void 0,metadata:void 0}}var O={encode(e,t=new H){return e.type!==0&&t.uint32(8).int32(e.type),e.timestamp!==void 0&&t.uint32(16).int64(e.timestamp),e.rawEvent!==void 0&&M.encode(M.wrap(e.rawEvent),t.uint32(26).fork()).join(),e.metadata!==void 0&&ee.encode(ee.wrap(e.metadata),t.uint32(34).fork()).join(),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Qy();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==8)break;r.type=n.int32();continue;case 2:if(i!==16)break;r.timestamp=pn(n.int64());continue;case 3:if(i!==26)break;r.rawEvent=M.unwrap(M.decode(n,n.uint32()));continue;case 4:if(i!==34)break;r.metadata=ee.unwrap(ee.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return O.fromPartial(e??{})},fromPartial(e){let t=Qy();return t.type=e.type??0,t.timestamp=e.timestamp??void 0,t.rawEvent=e.rawEvent??void 0,t.metadata=e.metadata??void 0,t}};function ew(){return{baseEvent:void 0,messageId:"",role:void 0,name:void 0,subagentRunId:void 0}}var _s={encode(e,t=new H){return e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==""&&t.uint32(18).string(e.messageId),e.role!==void 0&&t.uint32(26).string(e.role),e.name!==void 0&&t.uint32(34).string(e.name),e.subagentRunId!==void 0&&t.uint32(42).string(e.subagentRunId),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=ew();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.messageId=n.string();continue;case 3:if(i!==26)break;r.role=n.string();continue;case 4:if(i!==34)break;r.name=n.string();continue;case 5:if(i!==42)break;r.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return _s.fromPartial(e??{})},fromPartial(e){let t=ew();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??"",t.role=e.role??void 0,t.name=e.name??void 0,t.subagentRunId=e.subagentRunId??void 0,t}};function tw(){return{baseEvent:void 0,messageId:"",delta:"",subagentRunId:void 0}}var Es={encode(e,t=new H){return e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==""&&t.uint32(18).string(e.messageId),e.delta!==""&&t.uint32(26).string(e.delta),e.subagentRunId!==void 0&&t.uint32(34).string(e.subagentRunId),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=tw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.messageId=n.string();continue;case 3:if(i!==26)break;r.delta=n.string();continue;case 4:if(i!==34)break;r.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Es.fromPartial(e??{})},fromPartial(e){let t=tw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??"",t.delta=e.delta??"",t.subagentRunId=e.subagentRunId??void 0,t}};function nw(){return{baseEvent:void 0,messageId:"",subagentRunId:void 0}}var Ss={encode(e,t=new H){return e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==""&&t.uint32(18).string(e.messageId),e.subagentRunId!==void 0&&t.uint32(26).string(e.subagentRunId),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=nw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.messageId=n.string();continue;case 3:if(i!==26)break;r.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Ss.fromPartial(e??{})},fromPartial(e){let t=nw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??"",t.subagentRunId=e.subagentRunId??void 0,t}};function rw(){return{baseEvent:void 0,messageId:void 0,role:void 0,delta:void 0,name:void 0,subagentRunId:void 0}}var Ts={encode(e,t=new H){return e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==void 0&&t.uint32(18).string(e.messageId),e.role!==void 0&&t.uint32(26).string(e.role),e.delta!==void 0&&t.uint32(34).string(e.delta),e.name!==void 0&&t.uint32(42).string(e.name),e.subagentRunId!==void 0&&t.uint32(50).string(e.subagentRunId),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=rw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.messageId=n.string();continue;case 3:if(i!==26)break;r.role=n.string();continue;case 4:if(i!==34)break;r.delta=n.string();continue;case 5:if(i!==42)break;r.name=n.string();continue;case 6:if(i!==50)break;r.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Ts.fromPartial(e??{})},fromPartial(e){let t=rw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??void 0,t.role=e.role??void 0,t.delta=e.delta??void 0,t.name=e.name??void 0,t.subagentRunId=e.subagentRunId??void 0,t}};function ow(){return{baseEvent:void 0,toolCallId:"",toolCallName:"",parentMessageId:void 0,subagentRunId:void 0}}var ks={encode(e,t=new H){return e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==""&&t.uint32(18).string(e.toolCallId),e.toolCallName!==""&&t.uint32(26).string(e.toolCallName),e.parentMessageId!==void 0&&t.uint32(34).string(e.parentMessageId),e.subagentRunId!==void 0&&t.uint32(42).string(e.subagentRunId),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=ow();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.toolCallId=n.string();continue;case 3:if(i!==26)break;r.toolCallName=n.string();continue;case 4:if(i!==34)break;r.parentMessageId=n.string();continue;case 5:if(i!==42)break;r.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return ks.fromPartial(e??{})},fromPartial(e){let t=ow();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??"",t.toolCallName=e.toolCallName??"",t.parentMessageId=e.parentMessageId??void 0,t.subagentRunId=e.subagentRunId??void 0,t}};function iw(){return{baseEvent:void 0,toolCallId:"",delta:"",subagentRunId:void 0}}var Is={encode(e,t=new H){return e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==""&&t.uint32(18).string(e.toolCallId),e.delta!==""&&t.uint32(26).string(e.delta),e.subagentRunId!==void 0&&t.uint32(34).string(e.subagentRunId),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=iw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.toolCallId=n.string();continue;case 3:if(i!==26)break;r.delta=n.string();continue;case 4:if(i!==34)break;r.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Is.fromPartial(e??{})},fromPartial(e){let t=iw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??"",t.delta=e.delta??"",t.subagentRunId=e.subagentRunId??void 0,t}};function aw(){return{baseEvent:void 0,toolCallId:"",subagentRunId:void 0}}var As={encode(e,t=new H){return e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==""&&t.uint32(18).string(e.toolCallId),e.subagentRunId!==void 0&&t.uint32(26).string(e.subagentRunId),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=aw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.toolCallId=n.string();continue;case 3:if(i!==26)break;r.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return As.fromPartial(e??{})},fromPartial(e){let t=aw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??"",t.subagentRunId=e.subagentRunId??void 0,t}};function sw(){return{baseEvent:void 0,toolCallId:void 0,toolCallName:void 0,parentMessageId:void 0,delta:void 0,subagentRunId:void 0}}var Rs={encode(e,t=new H){return e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==void 0&&t.uint32(18).string(e.toolCallId),e.toolCallName!==void 0&&t.uint32(26).string(e.toolCallName),e.parentMessageId!==void 0&&t.uint32(34).string(e.parentMessageId),e.delta!==void 0&&t.uint32(42).string(e.delta),e.subagentRunId!==void 0&&t.uint32(50).string(e.subagentRunId),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=sw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.toolCallId=n.string();continue;case 3:if(i!==26)break;r.toolCallName=n.string();continue;case 4:if(i!==34)break;r.parentMessageId=n.string();continue;case 5:if(i!==42)break;r.delta=n.string();continue;case 6:if(i!==50)break;r.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Rs.fromPartial(e??{})},fromPartial(e){let t=sw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??void 0,t.toolCallName=e.toolCallName??void 0,t.parentMessageId=e.parentMessageId??void 0,t.delta=e.delta??void 0,t.subagentRunId=e.subagentRunId??void 0,t}};function lw(){return{baseEvent:void 0,subagentRunId:void 0,messageId:"",toolCallId:"",content:void 0,role:void 0,contentParts:[]}}var Cs={encode(e,t=new H){e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==void 0&&t.uint32(18).string(e.subagentRunId),e.messageId!==""&&t.uint32(26).string(e.messageId),e.toolCallId!==""&&t.uint32(34).string(e.toolCallId),e.content!==void 0&&t.uint32(42).string(e.content),e.role!==void 0&&t.uint32(50).string(e.role);for(let n of e.contentParts)mn.encode(n,t.uint32(58).fork()).join();return t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=lw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.subagentRunId=n.string();continue;case 3:if(i!==26)break;r.messageId=n.string();continue;case 4:if(i!==34)break;r.toolCallId=n.string();continue;case 5:if(i!==42)break;r.content=n.string();continue;case 6:if(i!==50)break;r.role=n.string();continue;case 7:if(i!==58)break;r.contentParts.push(mn.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Cs.fromPartial(e??{})},fromPartial(e){let t=lw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??void 0,t.messageId=e.messageId??"",t.toolCallId=e.toolCallId??"",t.content=e.content??void 0,t.role=e.role??void 0,t.contentParts=e.contentParts?.map(n=>mn.fromPartial(n))||[],t}};function uw(){return{baseEvent:void 0,snapshot:void 0,subagentRunId:void 0}}var Ns={encode(e,t=new H){return e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.snapshot!==void 0&&M.encode(M.wrap(e.snapshot),t.uint32(18).fork()).join(),e.subagentRunId!==void 0&&t.uint32(26).string(e.subagentRunId),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=uw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.snapshot=M.unwrap(M.decode(n,n.uint32()));continue;case 3:if(i!==26)break;r.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Ns.fromPartial(e??{})},fromPartial(e){let t=uw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.snapshot=e.snapshot??void 0,t.subagentRunId=e.subagentRunId??void 0,t}};function cw(){return{baseEvent:void 0,delta:[],subagentRunId:void 0}}var Os={encode(e,t=new H){e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join();for(let n of e.delta)fn.encode(n,t.uint32(18).fork()).join();return e.subagentRunId!==void 0&&t.uint32(26).string(e.subagentRunId),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=cw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.delta.push(fn.decode(n,n.uint32()));continue;case 3:if(i!==26)break;r.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Os.fromPartial(e??{})},fromPartial(e){let t=cw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.delta=e.delta?.map(n=>fn.fromPartial(n))||[],t.subagentRunId=e.subagentRunId??void 0,t}};function dw(){return{baseEvent:void 0,messages:[]}}var $s={encode(e,t=new H){e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join();for(let n of e.messages)gn.encode(n,t.uint32(18).fork()).join();return t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=dw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.messages.push(gn.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return $s.fromPartial(e??{})},fromPartial(e){let t=dw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.messages=e.messages?.map(n=>gn.fromPartial(n))||[],t}};function pw(){return{baseEvent:void 0,subagentRunId:void 0,messageId:"",activityType:"",content:void 0,replace:void 0}}var Ps={encode(e,t=new H){return e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==void 0&&t.uint32(18).string(e.subagentRunId),e.messageId!==""&&t.uint32(26).string(e.messageId),e.activityType!==""&&t.uint32(34).string(e.activityType),e.content!==void 0&&ee.encode(ee.wrap(e.content),t.uint32(42).fork()).join(),e.replace!==void 0&&t.uint32(48).bool(e.replace),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=pw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.subagentRunId=n.string();continue;case 3:if(i!==26)break;r.messageId=n.string();continue;case 4:if(i!==34)break;r.activityType=n.string();continue;case 5:if(i!==42)break;r.content=ee.unwrap(ee.decode(n,n.uint32()));continue;case 6:if(i!==48)break;r.replace=n.bool();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Ps.fromPartial(e??{})},fromPartial(e){let t=pw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??void 0,t.messageId=e.messageId??"",t.activityType=e.activityType??"",t.content=e.content??void 0,t.replace=e.replace??void 0,t}};function hw(){return{baseEvent:void 0,subagentRunId:void 0,messageId:"",activityType:"",patch:[]}}var Ms={encode(e,t=new H){e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==void 0&&t.uint32(18).string(e.subagentRunId),e.messageId!==""&&t.uint32(26).string(e.messageId),e.activityType!==""&&t.uint32(34).string(e.activityType);for(let n of e.patch)fn.encode(n,t.uint32(42).fork()).join();return t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=hw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.subagentRunId=n.string();continue;case 3:if(i!==26)break;r.messageId=n.string();continue;case 4:if(i!==34)break;r.activityType=n.string();continue;case 5:if(i!==42)break;r.patch.push(fn.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Ms.fromPartial(e??{})},fromPartial(e){let t=hw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??void 0,t.messageId=e.messageId??"",t.activityType=e.activityType??"",t.patch=e.patch?.map(n=>fn.fromPartial(n))||[],t}};function fw(){return{baseEvent:void 0,event:void 0,source:void 0,subagentRunId:void 0}}var Ls={encode(e,t=new H){return e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.event!==void 0&&M.encode(M.wrap(e.event),t.uint32(18).fork()).join(),e.source!==void 0&&t.uint32(26).string(e.source),e.subagentRunId!==void 0&&t.uint32(34).string(e.subagentRunId),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=fw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.event=M.unwrap(M.decode(n,n.uint32()));continue;case 3:if(i!==26)break;r.source=n.string();continue;case 4:if(i!==34)break;r.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Ls.fromPartial(e??{})},fromPartial(e){let t=fw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.event=e.event??void 0,t.source=e.source??void 0,t.subagentRunId=e.subagentRunId??void 0,t}};function mw(){return{baseEvent:void 0,name:"",value:void 0,subagentRunId:void 0}}var zs={encode(e,t=new H){return e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.name!==""&&t.uint32(18).string(e.name),e.value!==void 0&&M.encode(M.wrap(e.value),t.uint32(26).fork()).join(),e.subagentRunId!==void 0&&t.uint32(34).string(e.subagentRunId),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=mw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.name=n.string();continue;case 3:if(i!==26)break;r.value=M.unwrap(M.decode(n,n.uint32()));continue;case 4:if(i!==34)break;r.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return zs.fromPartial(e??{})},fromPartial(e){let t=mw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.name=e.name??"",t.value=e.value??void 0,t.subagentRunId=e.subagentRunId??void 0,t}};function gw(){return{baseEvent:void 0,threadId:"",runId:"",parentRunId:void 0,input:void 0,protocolVersion:void 0}}var Ds={encode(e,t=new H){return e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.threadId!==""&&t.uint32(18).string(e.threadId),e.runId!==""&&t.uint32(26).string(e.runId),e.parentRunId!==void 0&&t.uint32(34).string(e.parentRunId),e.input!==void 0&&ws.encode(e.input,t.uint32(42).fork()).join(),e.protocolVersion!==void 0&&t.uint32(50).string(e.protocolVersion),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=gw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.threadId=n.string();continue;case 3:if(i!==26)break;r.runId=n.string();continue;case 4:if(i!==34)break;r.parentRunId=n.string();continue;case 5:if(i!==42)break;r.input=ws.decode(n,n.uint32());continue;case 6:if(i!==50)break;r.protocolVersion=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Ds.fromPartial(e??{})},fromPartial(e){let t=gw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.threadId=e.threadId??"",t.runId=e.runId??"",t.parentRunId=e.parentRunId??void 0,t.input=e.input!==void 0&&e.input!==null?ws.fromPartial(e.input):void 0,t.protocolVersion=e.protocolVersion??void 0,t}};function vw(){return{baseEvent:void 0,threadId:"",runId:"",result:void 0,outcome:"",interrupts:[],usage:[],pendingToolCallIds:[]}}var Us={encode(e,t=new H){e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.threadId!==""&&t.uint32(18).string(e.threadId),e.runId!==""&&t.uint32(26).string(e.runId),e.result!==void 0&&M.encode(M.wrap(e.result),t.uint32(34).fork()).join(),e.outcome!==""&&t.uint32(42).string(e.outcome);for(let n of e.interrupts)xs.encode(n,t.uint32(50).fork()).join();for(let n of e.usage)vn.encode(n,t.uint32(58).fork()).join();for(let n of e.pendingToolCallIds)t.uint32(66).string(n);return t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=vw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.threadId=n.string();continue;case 3:if(i!==26)break;r.runId=n.string();continue;case 4:if(i!==34)break;r.result=M.unwrap(M.decode(n,n.uint32()));continue;case 5:if(i!==42)break;r.outcome=n.string();continue;case 6:if(i!==50)break;r.interrupts.push(xs.decode(n,n.uint32()));continue;case 7:if(i!==58)break;r.usage.push(vn.decode(n,n.uint32()));continue;case 8:if(i!==66)break;r.pendingToolCallIds.push(n.string());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Us.fromPartial(e??{})},fromPartial(e){let t=vw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.threadId=e.threadId??"",t.runId=e.runId??"",t.result=e.result??void 0,t.outcome=e.outcome??"",t.interrupts=e.interrupts?.map(n=>xs.fromPartial(n))||[],t.usage=e.usage?.map(n=>vn.fromPartial(n))||[],t.pendingToolCallIds=e.pendingToolCallIds?.map(n=>n)||[],t}};function bw(){return{baseEvent:void 0,code:void 0,message:"",usage:[]}}var js={encode(e,t=new H){e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.code!==void 0&&t.uint32(18).string(e.code),e.message!==""&&t.uint32(26).string(e.message);for(let n of e.usage)vn.encode(n,t.uint32(34).fork()).join();return t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=bw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.code=n.string();continue;case 3:if(i!==26)break;r.message=n.string();continue;case 4:if(i!==34)break;r.usage.push(vn.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return js.fromPartial(e??{})},fromPartial(e){let t=bw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.code=e.code??void 0,t.message=e.message??"",t.usage=e.usage?.map(n=>vn.fromPartial(n))||[],t}};function yw(){return{baseEvent:void 0,stepName:"",subagentRunId:void 0}}var Hs={encode(e,t=new H){return e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.stepName!==""&&t.uint32(18).string(e.stepName),e.subagentRunId!==void 0&&t.uint32(26).string(e.subagentRunId),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=yw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.stepName=n.string();continue;case 3:if(i!==26)break;r.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Hs.fromPartial(e??{})},fromPartial(e){let t=yw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.stepName=e.stepName??"",t.subagentRunId=e.subagentRunId??void 0,t}};function ww(){return{baseEvent:void 0,stepName:"",subagentRunId:void 0}}var Gs={encode(e,t=new H){return e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.stepName!==""&&t.uint32(18).string(e.stepName),e.subagentRunId!==void 0&&t.uint32(26).string(e.subagentRunId),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=ww();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.stepName=n.string();continue;case 3:if(i!==26)break;r.subagentRunId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Gs.fromPartial(e??{})},fromPartial(e){let t=ww();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.stepName=e.stepName??"",t.subagentRunId=e.subagentRunId??void 0,t}};function xw(){return{baseEvent:void 0,subagentRunId:void 0,messageId:""}}var Fs={encode(e,t=new H){return e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==void 0&&t.uint32(18).string(e.subagentRunId),e.messageId!==""&&t.uint32(26).string(e.messageId),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=xw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.subagentRunId=n.string();continue;case 3:if(i!==26)break;r.messageId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Fs.fromPartial(e??{})},fromPartial(e){let t=xw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??void 0,t.messageId=e.messageId??"",t}};function _w(){return{baseEvent:void 0,subagentRunId:void 0,messageId:"",role:""}}var Vs={encode(e,t=new H){return e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==void 0&&t.uint32(18).string(e.subagentRunId),e.messageId!==""&&t.uint32(26).string(e.messageId),e.role!==""&&t.uint32(34).string(e.role),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=_w();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.subagentRunId=n.string();continue;case 3:if(i!==26)break;r.messageId=n.string();continue;case 4:if(i!==34)break;r.role=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Vs.fromPartial(e??{})},fromPartial(e){let t=_w();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??void 0,t.messageId=e.messageId??"",t.role=e.role??"",t}};function Ew(){return{baseEvent:void 0,subagentRunId:void 0,messageId:"",delta:""}}var Zs={encode(e,t=new H){return e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==void 0&&t.uint32(18).string(e.subagentRunId),e.messageId!==""&&t.uint32(26).string(e.messageId),e.delta!==""&&t.uint32(34).string(e.delta),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Ew();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.subagentRunId=n.string();continue;case 3:if(i!==26)break;r.messageId=n.string();continue;case 4:if(i!==34)break;r.delta=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Zs.fromPartial(e??{})},fromPartial(e){let t=Ew();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??void 0,t.messageId=e.messageId??"",t.delta=e.delta??"",t}};function Sw(){return{baseEvent:void 0,subagentRunId:void 0,messageId:""}}var Bs={encode(e,t=new H){return e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==void 0&&t.uint32(18).string(e.subagentRunId),e.messageId!==""&&t.uint32(26).string(e.messageId),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Sw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.subagentRunId=n.string();continue;case 3:if(i!==26)break;r.messageId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Bs.fromPartial(e??{})},fromPartial(e){let t=Sw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??void 0,t.messageId=e.messageId??"",t}};function Tw(){return{baseEvent:void 0,subagentRunId:void 0,messageId:void 0,delta:void 0}}var Ws={encode(e,t=new H){return e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==void 0&&t.uint32(18).string(e.subagentRunId),e.messageId!==void 0&&t.uint32(26).string(e.messageId),e.delta!==void 0&&t.uint32(34).string(e.delta),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Tw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.subagentRunId=n.string();continue;case 3:if(i!==26)break;r.messageId=n.string();continue;case 4:if(i!==34)break;r.delta=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Ws.fromPartial(e??{})},fromPartial(e){let t=Tw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??void 0,t.messageId=e.messageId??void 0,t.delta=e.delta??void 0,t}};function kw(){return{baseEvent:void 0,subagentRunId:void 0,messageId:""}}var qs={encode(e,t=new H){return e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==void 0&&t.uint32(18).string(e.subagentRunId),e.messageId!==""&&t.uint32(26).string(e.messageId),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=kw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.subagentRunId=n.string();continue;case 3:if(i!==26)break;r.messageId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return qs.fromPartial(e??{})},fromPartial(e){let t=kw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??void 0,t.messageId=e.messageId??"",t}};function Iw(){return{baseEvent:void 0,subagentRunId:void 0,subtype:"",entityId:"",encryptedValue:""}}var Xs={encode(e,t=new H){return e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==void 0&&t.uint32(18).string(e.subagentRunId),e.subtype!==""&&t.uint32(26).string(e.subtype),e.entityId!==""&&t.uint32(34).string(e.entityId),e.encryptedValue!==""&&t.uint32(42).string(e.encryptedValue),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Iw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.subagentRunId=n.string();continue;case 3:if(i!==26)break;r.subtype=n.string();continue;case 4:if(i!==34)break;r.entityId=n.string();continue;case 5:if(i!==42)break;r.encryptedValue=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Xs.fromPartial(e??{})},fromPartial(e){let t=Iw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??void 0,t.subtype=e.subtype??"",t.entityId=e.entityId??"",t.encryptedValue=e.encryptedValue??"",t}};function Aw(){return{baseEvent:void 0,subagentRunId:"",name:"",description:void 0,parentSubagentRunId:void 0,parentToolCallId:void 0,parentMessageId:void 0}}var Ks={encode(e,t=new H){return e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==""&&t.uint32(18).string(e.subagentRunId),e.name!==""&&t.uint32(26).string(e.name),e.description!==void 0&&t.uint32(34).string(e.description),e.parentSubagentRunId!==void 0&&t.uint32(42).string(e.parentSubagentRunId),e.parentToolCallId!==void 0&&t.uint32(50).string(e.parentToolCallId),e.parentMessageId!==void 0&&t.uint32(58).string(e.parentMessageId),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Aw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.subagentRunId=n.string();continue;case 3:if(i!==26)break;r.name=n.string();continue;case 4:if(i!==34)break;r.description=n.string();continue;case 5:if(i!==42)break;r.parentSubagentRunId=n.string();continue;case 6:if(i!==50)break;r.parentToolCallId=n.string();continue;case 7:if(i!==58)break;r.parentMessageId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Ks.fromPartial(e??{})},fromPartial(e){let t=Aw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??"",t.name=e.name??"",t.description=e.description??void 0,t.parentSubagentRunId=e.parentSubagentRunId??void 0,t.parentToolCallId=e.parentToolCallId??void 0,t.parentMessageId=e.parentMessageId??void 0,t}};function Rw(){return{baseEvent:void 0,subagentRunId:"",result:void 0,outcome:"",interruptIds:[]}}var Ys={encode(e,t=new H){e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==""&&t.uint32(18).string(e.subagentRunId),e.result!==void 0&&M.encode(M.wrap(e.result),t.uint32(26).fork()).join(),e.outcome!==""&&t.uint32(34).string(e.outcome);for(let n of e.interruptIds)t.uint32(42).string(n);return t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Rw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.subagentRunId=n.string();continue;case 3:if(i!==26)break;r.result=M.unwrap(M.decode(n,n.uint32()));continue;case 4:if(i!==34)break;r.outcome=n.string();continue;case 5:if(i!==42)break;r.interruptIds.push(n.string());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Ys.fromPartial(e??{})},fromPartial(e){let t=Rw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??"",t.result=e.result??void 0,t.outcome=e.outcome??"",t.interruptIds=e.interruptIds?.map(n=>n)||[],t}};function Cw(){return{baseEvent:void 0,subagentRunId:"",message:"",code:void 0}}var Js={encode(e,t=new H){return e.baseEvent!==void 0&&O.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==""&&t.uint32(18).string(e.subagentRunId),e.message!==""&&t.uint32(26).string(e.message),e.code!==void 0&&t.uint32(34).string(e.code),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Cw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.baseEvent=O.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.subagentRunId=n.string();continue;case 3:if(i!==26)break;r.message=n.string();continue;case 4:if(i!==34)break;r.code=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Js.fromPartial(e??{})},fromPartial(e){let t=Cw();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?O.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??"",t.message=e.message??"",t.code=e.code??void 0,t}};function Nw(){return{textMessageStart:void 0,textMessageContent:void 0,textMessageEnd:void 0,toolCallStart:void 0,toolCallArgs:void 0,toolCallEnd:void 0,stateSnapshot:void 0,stateDelta:void 0,messagesSnapshot:void 0,raw:void 0,custom:void 0,runStarted:void 0,runFinished:void 0,runError:void 0,stepStarted:void 0,stepFinished:void 0,textMessageChunk:void 0,toolCallChunk:void 0,subagentStarted:void 0,subagentFinished:void 0,subagentError:void 0,toolCallResult:void 0,activitySnapshot:void 0,activityDelta:void 0,reasoningStart:void 0,reasoningMessageStart:void 0,reasoningMessageContent:void 0,reasoningMessageEnd:void 0,reasoningMessageChunk:void 0,reasoningEnd:void 0,reasoningEncryptedValue:void 0}}var Pw={encode(e,t=new H){return e.textMessageStart!==void 0&&_s.encode(e.textMessageStart,t.uint32(10).fork()).join(),e.textMessageContent!==void 0&&Es.encode(e.textMessageContent,t.uint32(18).fork()).join(),e.textMessageEnd!==void 0&&Ss.encode(e.textMessageEnd,t.uint32(26).fork()).join(),e.toolCallStart!==void 0&&ks.encode(e.toolCallStart,t.uint32(34).fork()).join(),e.toolCallArgs!==void 0&&Is.encode(e.toolCallArgs,t.uint32(42).fork()).join(),e.toolCallEnd!==void 0&&As.encode(e.toolCallEnd,t.uint32(50).fork()).join(),e.stateSnapshot!==void 0&&Ns.encode(e.stateSnapshot,t.uint32(58).fork()).join(),e.stateDelta!==void 0&&Os.encode(e.stateDelta,t.uint32(66).fork()).join(),e.messagesSnapshot!==void 0&&$s.encode(e.messagesSnapshot,t.uint32(74).fork()).join(),e.raw!==void 0&&Ls.encode(e.raw,t.uint32(82).fork()).join(),e.custom!==void 0&&zs.encode(e.custom,t.uint32(90).fork()).join(),e.runStarted!==void 0&&Ds.encode(e.runStarted,t.uint32(98).fork()).join(),e.runFinished!==void 0&&Us.encode(e.runFinished,t.uint32(106).fork()).join(),e.runError!==void 0&&js.encode(e.runError,t.uint32(114).fork()).join(),e.stepStarted!==void 0&&Hs.encode(e.stepStarted,t.uint32(122).fork()).join(),e.stepFinished!==void 0&&Gs.encode(e.stepFinished,t.uint32(130).fork()).join(),e.textMessageChunk!==void 0&&Ts.encode(e.textMessageChunk,t.uint32(138).fork()).join(),e.toolCallChunk!==void 0&&Rs.encode(e.toolCallChunk,t.uint32(146).fork()).join(),e.subagentStarted!==void 0&&Ks.encode(e.subagentStarted,t.uint32(154).fork()).join(),e.subagentFinished!==void 0&&Ys.encode(e.subagentFinished,t.uint32(162).fork()).join(),e.subagentError!==void 0&&Js.encode(e.subagentError,t.uint32(170).fork()).join(),e.toolCallResult!==void 0&&Cs.encode(e.toolCallResult,t.uint32(178).fork()).join(),e.activitySnapshot!==void 0&&Ps.encode(e.activitySnapshot,t.uint32(186).fork()).join(),e.activityDelta!==void 0&&Ms.encode(e.activityDelta,t.uint32(194).fork()).join(),e.reasoningStart!==void 0&&Fs.encode(e.reasoningStart,t.uint32(202).fork()).join(),e.reasoningMessageStart!==void 0&&Vs.encode(e.reasoningMessageStart,t.uint32(210).fork()).join(),e.reasoningMessageContent!==void 0&&Zs.encode(e.reasoningMessageContent,t.uint32(218).fork()).join(),e.reasoningMessageEnd!==void 0&&Bs.encode(e.reasoningMessageEnd,t.uint32(226).fork()).join(),e.reasoningMessageChunk!==void 0&&Ws.encode(e.reasoningMessageChunk,t.uint32(234).fork()).join(),e.reasoningEnd!==void 0&&qs.encode(e.reasoningEnd,t.uint32(242).fork()).join(),e.reasoningEncryptedValue!==void 0&&Xs.encode(e.reasoningEncryptedValue,t.uint32(250).fork()).join(),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Nw();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.textMessageStart=_s.decode(n,n.uint32());continue;case 2:if(i!==18)break;r.textMessageContent=Es.decode(n,n.uint32());continue;case 3:if(i!==26)break;r.textMessageEnd=Ss.decode(n,n.uint32());continue;case 4:if(i!==34)break;r.toolCallStart=ks.decode(n,n.uint32());continue;case 5:if(i!==42)break;r.toolCallArgs=Is.decode(n,n.uint32());continue;case 6:if(i!==50)break;r.toolCallEnd=As.decode(n,n.uint32());continue;case 7:if(i!==58)break;r.stateSnapshot=Ns.decode(n,n.uint32());continue;case 8:if(i!==66)break;r.stateDelta=Os.decode(n,n.uint32());continue;case 9:if(i!==74)break;r.messagesSnapshot=$s.decode(n,n.uint32());continue;case 10:if(i!==82)break;r.raw=Ls.decode(n,n.uint32());continue;case 11:if(i!==90)break;r.custom=zs.decode(n,n.uint32());continue;case 12:if(i!==98)break;r.runStarted=Ds.decode(n,n.uint32());continue;case 13:if(i!==106)break;r.runFinished=Us.decode(n,n.uint32());continue;case 14:if(i!==114)break;r.runError=js.decode(n,n.uint32());continue;case 15:if(i!==122)break;r.stepStarted=Hs.decode(n,n.uint32());continue;case 16:if(i!==130)break;r.stepFinished=Gs.decode(n,n.uint32());continue;case 17:if(i!==138)break;r.textMessageChunk=Ts.decode(n,n.uint32());continue;case 18:if(i!==146)break;r.toolCallChunk=Rs.decode(n,n.uint32());continue;case 19:if(i!==154)break;r.subagentStarted=Ks.decode(n,n.uint32());continue;case 20:if(i!==162)break;r.subagentFinished=Ys.decode(n,n.uint32());continue;case 21:if(i!==170)break;r.subagentError=Js.decode(n,n.uint32());continue;case 22:if(i!==178)break;r.toolCallResult=Cs.decode(n,n.uint32());continue;case 23:if(i!==186)break;r.activitySnapshot=Ps.decode(n,n.uint32());continue;case 24:if(i!==194)break;r.activityDelta=Ms.decode(n,n.uint32());continue;case 25:if(i!==202)break;r.reasoningStart=Fs.decode(n,n.uint32());continue;case 26:if(i!==210)break;r.reasoningMessageStart=Vs.decode(n,n.uint32());continue;case 27:if(i!==218)break;r.reasoningMessageContent=Zs.decode(n,n.uint32());continue;case 28:if(i!==226)break;r.reasoningMessageEnd=Bs.decode(n,n.uint32());continue;case 29:if(i!==234)break;r.reasoningMessageChunk=Ws.decode(n,n.uint32());continue;case 30:if(i!==242)break;r.reasoningEnd=qs.decode(n,n.uint32());continue;case 31:if(i!==250)break;r.reasoningEncryptedValue=Xs.decode(n,n.uint32());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return Pw.fromPartial(e??{})},fromPartial(e){let t=Nw();return t.textMessageStart=e.textMessageStart!==void 0&&e.textMessageStart!==null?_s.fromPartial(e.textMessageStart):void 0,t.textMessageContent=e.textMessageContent!==void 0&&e.textMessageContent!==null?Es.fromPartial(e.textMessageContent):void 0,t.textMessageEnd=e.textMessageEnd!==void 0&&e.textMessageEnd!==null?Ss.fromPartial(e.textMessageEnd):void 0,t.toolCallStart=e.toolCallStart!==void 0&&e.toolCallStart!==null?ks.fromPartial(e.toolCallStart):void 0,t.toolCallArgs=e.toolCallArgs!==void 0&&e.toolCallArgs!==null?Is.fromPartial(e.toolCallArgs):void 0,t.toolCallEnd=e.toolCallEnd!==void 0&&e.toolCallEnd!==null?As.fromPartial(e.toolCallEnd):void 0,t.stateSnapshot=e.stateSnapshot!==void 0&&e.stateSnapshot!==null?Ns.fromPartial(e.stateSnapshot):void 0,t.stateDelta=e.stateDelta!==void 0&&e.stateDelta!==null?Os.fromPartial(e.stateDelta):void 0,t.messagesSnapshot=e.messagesSnapshot!==void 0&&e.messagesSnapshot!==null?$s.fromPartial(e.messagesSnapshot):void 0,t.raw=e.raw!==void 0&&e.raw!==null?Ls.fromPartial(e.raw):void 0,t.custom=e.custom!==void 0&&e.custom!==null?zs.fromPartial(e.custom):void 0,t.runStarted=e.runStarted!==void 0&&e.runStarted!==null?Ds.fromPartial(e.runStarted):void 0,t.runFinished=e.runFinished!==void 0&&e.runFinished!==null?Us.fromPartial(e.runFinished):void 0,t.runError=e.runError!==void 0&&e.runError!==null?js.fromPartial(e.runError):void 0,t.stepStarted=e.stepStarted!==void 0&&e.stepStarted!==null?Hs.fromPartial(e.stepStarted):void 0,t.stepFinished=e.stepFinished!==void 0&&e.stepFinished!==null?Gs.fromPartial(e.stepFinished):void 0,t.textMessageChunk=e.textMessageChunk!==void 0&&e.textMessageChunk!==null?Ts.fromPartial(e.textMessageChunk):void 0,t.toolCallChunk=e.toolCallChunk!==void 0&&e.toolCallChunk!==null?Rs.fromPartial(e.toolCallChunk):void 0,t.subagentStarted=e.subagentStarted!==void 0&&e.subagentStarted!==null?Ks.fromPartial(e.subagentStarted):void 0,t.subagentFinished=e.subagentFinished!==void 0&&e.subagentFinished!==null?Ys.fromPartial(e.subagentFinished):void 0,t.subagentError=e.subagentError!==void 0&&e.subagentError!==null?Js.fromPartial(e.subagentError):void 0,t.toolCallResult=e.toolCallResult!==void 0&&e.toolCallResult!==null?Cs.fromPartial(e.toolCallResult):void 0,t.activitySnapshot=e.activitySnapshot!==void 0&&e.activitySnapshot!==null?Ps.fromPartial(e.activitySnapshot):void 0,t.activityDelta=e.activityDelta!==void 0&&e.activityDelta!==null?Ms.fromPartial(e.activityDelta):void 0,t.reasoningStart=e.reasoningStart!==void 0&&e.reasoningStart!==null?Fs.fromPartial(e.reasoningStart):void 0,t.reasoningMessageStart=e.reasoningMessageStart!==void 0&&e.reasoningMessageStart!==null?Vs.fromPartial(e.reasoningMessageStart):void 0,t.reasoningMessageContent=e.reasoningMessageContent!==void 0&&e.reasoningMessageContent!==null?Zs.fromPartial(e.reasoningMessageContent):void 0,t.reasoningMessageEnd=e.reasoningMessageEnd!==void 0&&e.reasoningMessageEnd!==null?Bs.fromPartial(e.reasoningMessageEnd):void 0,t.reasoningMessageChunk=e.reasoningMessageChunk!==void 0&&e.reasoningMessageChunk!==null?Ws.fromPartial(e.reasoningMessageChunk):void 0,t.reasoningEnd=e.reasoningEnd!==void 0&&e.reasoningEnd!==null?qs.fromPartial(e.reasoningEnd):void 0,t.reasoningEncryptedValue=e.reasoningEncryptedValue!==void 0&&e.reasoningEncryptedValue!==null?Xs.fromPartial(e.reasoningEncryptedValue):void 0,t}};function Ow(){return{provider:void 0,model:void 0,inputTokens:void 0,outputTokens:void 0,totalTokens:void 0,reasoningTokens:void 0,cachedInputTokens:void 0,cacheWriteInputTokens:void 0}}var vn={encode(e,t=new H){return e.provider!==void 0&&t.uint32(10).string(e.provider),e.model!==void 0&&t.uint32(18).string(e.model),e.inputTokens!==void 0&&t.uint32(24).int64(e.inputTokens),e.outputTokens!==void 0&&t.uint32(32).int64(e.outputTokens),e.totalTokens!==void 0&&t.uint32(40).int64(e.totalTokens),e.reasoningTokens!==void 0&&t.uint32(48).int64(e.reasoningTokens),e.cachedInputTokens!==void 0&&t.uint32(56).int64(e.cachedInputTokens),e.cacheWriteInputTokens!==void 0&&t.uint32(64).int64(e.cacheWriteInputTokens),t},decode(e,t){let n=e instanceof C?e:new C(e),o=t===void 0?n.len:n.pos+t,r=Ow();for(;n.pos<o;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;r.provider=n.string();continue;case 2:if(i!==18)break;r.model=n.string();continue;case 3:if(i!==24)break;r.inputTokens=pn(n.int64());continue;case 4:if(i!==32)break;r.outputTokens=pn(n.int64());continue;case 5:if(i!==40)break;r.totalTokens=pn(n.int64());continue;case 6:if(i!==48)break;r.reasoningTokens=pn(n.int64());continue;case 7:if(i!==56)break;r.cachedInputTokens=pn(n.int64());continue;case 8:if(i!==64)break;r.cacheWriteInputTokens=pn(n.int64());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return r},create(e){return vn.fromPartial(e??{})},fromPartial(e){let t=Ow();return t.provider=e.provider??void 0,t.model=e.model??void 0,t.inputTokens=e.inputTokens??void 0,t.outputTokens=e.outputTokens??void 0,t.totalTokens=e.totalTokens??void 0,t.reasoningTokens=e.reasoningTokens??void 0,t.cachedInputTokens=e.cachedInputTokens??void 0,t.cacheWriteInputTokens=e.cacheWriteInputTokens??void 0,t}};function pn(e){let t=globalThis.Number(e.toString());if(t>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");if(t<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");return t}var ur=e=>e&&typeof e=="object"?e:void 0,de=e=>Array.isArray(e)?e:[],dA=()=>typeof process<"u"&&typeof process.env<"u"&&!!process.env.SUPPRESS_TRANSFORMATION_WARNINGS,Mw=()=>{dA()||console.warn("[ag-ui][proto] Dropped a content part this build does not know: the protocol has a variant this SDK predates.")};var kD=new Set(Object.values(x)),pA={textMessageStart:"TEXT_MESSAGE_START",textMessageContent:"TEXT_MESSAGE_CONTENT",textMessageEnd:"TEXT_MESSAGE_END",textMessageChunk:"TEXT_MESSAGE_CHUNK",toolCallStart:"TOOL_CALL_START",toolCallArgs:"TOOL_CALL_ARGS",toolCallEnd:"TOOL_CALL_END",toolCallChunk:"TOOL_CALL_CHUNK",toolCallResult:"TOOL_CALL_RESULT",stateSnapshot:"STATE_SNAPSHOT",stateDelta:"STATE_DELTA",messagesSnapshot:"MESSAGES_SNAPSHOT",activitySnapshot:"ACTIVITY_SNAPSHOT",activityDelta:"ACTIVITY_DELTA",raw:"RAW",custom:"CUSTOM",runStarted:"RUN_STARTED",runFinished:"RUN_FINISHED",runError:"RUN_ERROR",stepStarted:"STEP_STARTED",stepFinished:"STEP_FINISHED",reasoningStart:"REASONING_START",reasoningMessageStart:"REASONING_MESSAGE_START",reasoningMessageContent:"REASONING_MESSAGE_CONTENT",reasoningMessageEnd:"REASONING_MESSAGE_END",reasoningMessageChunk:"REASONING_MESSAGE_CHUNK",reasoningEnd:"REASONING_END",reasoningEncryptedValue:"REASONING_ENCRYPTED_VALUE",subagentStarted:"SUBAGENT_STARTED",subagentFinished:"SUBAGENT_FINISHED",subagentError:"SUBAGENT_ERROR"},hn=new Set([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]);var jt=e=>{let t=ur(e);if(t){if([t.data,t.url,t.file].filter(Boolean).length>1)throw new Error("Invalid event: source carries more than one arm");if(t.data){let n=t.data;return{type:"data",value:n.value,mimeType:n.mimeType}}if(t.url){let n=t.url;return{type:"url",value:n.value,mimeType:n.mimeType}}if(t.file){let n=t.file;return{type:"file",value:n.value,provider:n.provider,mimeType:n.mimeType}}}};var Lw=e=>{let t=ur(e);if(t){if([t.text,t.image,t.audio,t.video,t.document].filter(Boolean).length>1)throw new Error("Invalid event: content part carries more than one arm");if(t.text){let n=t.text;return{type:"text",id:n.id,text:n.text,metadata:n.metadata}}if(t.image){let n=t.image;return n.source!==void 0&&jt(n.source)===void 0?void 0:{type:"image",id:n.id,source:jt(n.source),metadata:n.metadata}}if(t.audio){let n=t.audio;return n.source!==void 0&&jt(n.source)===void 0?void 0:{type:"audio",id:n.id,source:jt(n.source),metadata:n.metadata}}if(t.video){let n=t.video;return n.source!==void 0&&jt(n.source)===void 0?void 0:{type:"video",id:n.id,source:jt(n.source),metadata:n.metadata}}if(t.document){let n=t.document;return n.source!==void 0&&jt(n.source)===void 0?void 0:{type:"document",id:n.id,source:jt(n.source),metadata:n.metadata}}}},hA=new Set(["activity"]),fA=new Set(["user","tool"]),mA=new Set(["developer","system","assistant","user","tool","activity","reasoning"]);var zw=e=>{let t=ur(e)??{},n={...t},o=typeof t.role=="string"?t.role:"",r=mA.has(o),i=r?fA.has(o):de(t.contentParts).length>0,a=r?hA.has(o):!i&&t.activityContent!==void 0;if(!r&&(t.content!==void 0?1:0)+(de(t.contentParts).length>0?1:0)+(t.activityContent!==void 0?1:0)>1)throw new Error("Invalid event: message carries more than one content form");if(r){if(!i&&de(t.contentParts).length>0)throw new Error("Invalid event: message carries content parts for a role that has none");if(t.activityContent!==void 0&&!a)throw new Error("Invalid event: message carries activity content for a non-activity role");if(a&&t.content!==void 0)throw new Error("Invalid event: activity content cannot ride with other content forms");if(i&&t.content!==void 0&&de(t.contentParts).length>0)throw new Error("Invalid event: message carries both string content and content parts")}return i&&t.content===void 0&&(n.content=de(t.contentParts).map(s=>{let u=Lw(s);return u===void 0&&Mw(),u}).filter(s=>s!==void 0)),a&&t.activityContent!==void 0&&(n.content=t.activityContent),delete n.activityContent,delete n.contentParts,de(t.toolCalls).length===0&&delete n.toolCalls,Object.keys(n).forEach(s=>{n[s]===void 0&&delete n[s]}),n},Ef=e=>{if(Array.isArray(e)){for(let n of e)Ef(n);return}let t=ur(e);if(t)for(let n of Object.keys(t))t[n]===void 0?delete t[n]:Ef(t[n])};var gA=e=>{let t=ur(e);if(!t)return;let n={};return t.threadId!==void 0&&(n.threadId=t.threadId),t.runId!==void 0&&(n.runId=t.runId),t.protocolVersion!==void 0&&(n.protocolVersion=t.protocolVersion),t.parentRunId!==void 0&&(n.parentRunId=t.parentRunId),t.state!==void 0&&(n.state=t.state),n.messages=de(t.messages).map(zw).filter(o=>o!==void 0),n.tools=de(t.tools),n.context=de(t.context),t.forwardedProps!==void 0&&(n.forwardedProps=t.forwardedProps),n.resume=de(t.resume),n};var Sf={TextMessageStartEvent:{singular:new Set([1]),descend:{1:"BaseEvent"}},BaseEvent:{singular:new Set([3,4]),descend:{},google:{3:"google.protobuf.Value",4:"google.protobuf.Struct"}},TextMessageContentEvent:{singular:new Set([1]),descend:{1:"BaseEvent"}},TextMessageEndEvent:{singular:new Set([1]),descend:{1:"BaseEvent"}},ToolCallStartEvent:{singular:new Set([1]),descend:{1:"BaseEvent"}},ToolCallArgsEvent:{singular:new Set([1]),descend:{1:"BaseEvent"}},ToolCallEndEvent:{singular:new Set([1]),descend:{1:"BaseEvent"}},StateSnapshotEvent:{singular:new Set([1,2]),descend:{1:"BaseEvent"},google:{2:"google.protobuf.Value"}},StateDeltaEvent:{singular:new Set([1]),descend:{1:"BaseEvent",2:"JsonPatchOperation"}},JsonPatchOperation:{singular:new Set([4]),descend:{},google:{4:"google.protobuf.Value"}},MessagesSnapshotEvent:{singular:new Set([1]),descend:{1:"BaseEvent",2:"Message"}},Message:{singular:new Set([9,13]),descend:{5:"ToolCall",8:"InputContent"},google:{9:"google.protobuf.Struct",13:"google.protobuf.Struct"}},ToolCall:{singular:new Set([3,4]),descend:{},google:{4:"google.protobuf.Struct"}},InputContent:{singular:new Set([1,2,3,4,5]),descend:{1:"TextInputPart",2:"ImageInputPart",3:"AudioInputPart",4:"VideoInputPart",5:"DocumentInputPart"},arms:new Set([1,2,3,4,5])},TextInputPart:{singular:new Set([3]),descend:{},google:{3:"google.protobuf.Value"}},ImageInputPart:{singular:new Set([1,2]),descend:{1:"InputContentSource"},google:{2:"google.protobuf.Value"}},InputContentSource:{singular:new Set([1,2,3]),descend:{},arms:new Set([1,2,3])},AudioInputPart:{singular:new Set([1,2]),descend:{1:"InputContentSource"},google:{2:"google.protobuf.Value"}},VideoInputPart:{singular:new Set([1,2]),descend:{1:"InputContentSource"},google:{2:"google.protobuf.Value"}},DocumentInputPart:{singular:new Set([1,2]),descend:{1:"InputContentSource"},google:{2:"google.protobuf.Value"}},RawEvent:{singular:new Set([1,2]),descend:{1:"BaseEvent"},google:{2:"google.protobuf.Value"}},CustomEvent:{singular:new Set([1,3]),descend:{1:"BaseEvent"},google:{3:"google.protobuf.Value"}},RunStartedEvent:{singular:new Set([1,5]),descend:{1:"BaseEvent",5:"RunAgentInput"}},RunAgentInput:{singular:new Set([4,8]),descend:{5:"Message",6:"Tool",9:"ResumeEntry"},google:{4:"google.protobuf.Value",8:"google.protobuf.Value"}},Tool:{singular:new Set([3,4]),descend:{},google:{3:"google.protobuf.Value",4:"google.protobuf.Struct"}},ResumeEntry:{singular:new Set([3,4]),descend:{},google:{3:"google.protobuf.Value",4:"google.protobuf.Struct"}},RunFinishedEvent:{singular:new Set([1,4]),descend:{1:"BaseEvent",6:"Interrupt"},google:{4:"google.protobuf.Value"}},Interrupt:{singular:new Set([5,7]),descend:{},google:{5:"google.protobuf.Value",7:"google.protobuf.Value"}},RunErrorEvent:{singular:new Set([1]),descend:{1:"BaseEvent"}},StepStartedEvent:{singular:new Set([1]),descend:{1:"BaseEvent"}},StepFinishedEvent:{singular:new Set([1]),descend:{1:"BaseEvent"}},TextMessageChunkEvent:{singular:new Set([1]),descend:{1:"BaseEvent"}},ToolCallChunkEvent:{singular:new Set([1]),descend:{1:"BaseEvent"}},SubagentStartedEvent:{singular:new Set([1]),descend:{1:"BaseEvent"}},SubagentFinishedEvent:{singular:new Set([1,3]),descend:{1:"BaseEvent"},google:{3:"google.protobuf.Value"}},SubagentErrorEvent:{singular:new Set([1]),descend:{1:"BaseEvent"}},ToolCallResultEvent:{singular:new Set([1]),descend:{1:"BaseEvent",7:"InputContent"}},ActivitySnapshotEvent:{singular:new Set([1,5]),descend:{1:"BaseEvent"},google:{5:"google.protobuf.Struct"}},ActivityDeltaEvent:{singular:new Set([1]),descend:{1:"BaseEvent",5:"JsonPatchOperation"}},ReasoningStartEvent:{singular:new Set([1]),descend:{1:"BaseEvent"}},ReasoningMessageStartEvent:{singular:new Set([1]),descend:{1:"BaseEvent"}},ReasoningMessageContentEvent:{singular:new Set([1]),descend:{1:"BaseEvent"}},ReasoningMessageEndEvent:{singular:new Set([1]),descend:{1:"BaseEvent"}},ReasoningMessageChunkEvent:{singular:new Set([1]),descend:{1:"BaseEvent"}},ReasoningEndEvent:{singular:new Set([1]),descend:{1:"BaseEvent"}},ReasoningEncryptedValueEvent:{singular:new Set([1]),descend:{1:"BaseEvent"}},"google.protobuf.Struct":{singular:new Set,descend:{1:"google.protobuf.Struct.FieldsEntry"}},"google.protobuf.Struct.FieldsEntry":{singular:new Set([2]),descend:{2:"google.protobuf.Value"}},"google.protobuf.Value":{singular:new Set([5,6]),descend:{5:"google.protobuf.Struct",6:"google.protobuf.ListValue"},arms:new Set([1,2,3,4,5,6]),armWireTypes:{1:0,2:1,3:2,4:0,5:2,6:2}},"google.protobuf.ListValue":{singular:new Set,descend:{1:"google.protobuf.Value"}}},Dw={1:"TextMessageStartEvent",2:"TextMessageContentEvent",3:"TextMessageEndEvent",4:"ToolCallStartEvent",5:"ToolCallArgsEvent",6:"ToolCallEndEvent",7:"StateSnapshotEvent",8:"StateDeltaEvent",9:"MessagesSnapshotEvent",10:"RawEvent",11:"CustomEvent",12:"RunStartedEvent",13:"RunFinishedEvent",14:"RunErrorEvent",15:"StepStartedEvent",16:"StepFinishedEvent",17:"TextMessageChunkEvent",18:"ToolCallChunkEvent",19:"SubagentStartedEvent",20:"SubagentFinishedEvent",21:"SubagentErrorEvent",22:"ToolCallResultEvent",23:"ActivitySnapshotEvent",24:"ActivityDeltaEvent",25:"ReasoningStartEvent",26:"ReasoningMessageStartEvent",27:"ReasoningMessageContentEvent",28:"ReasoningMessageEndEvent",29:"ReasoningMessageChunkEvent",30:"ReasoningEndEvent",31:"ReasoningEncryptedValueEvent"};function lr(e,t){let n=0,o=0;for(;;){if(t.offset>=e.length)throw new Error("Invalid event");let r=e[t.offset++];if(o<28?n+=(r&127)*2**o:o===28&&(n+=(r&15)*2**28),o+=7,(r&128)===0)return n}}function Uw(e,t){let n={offset:0},o=0,r=0;for(;n.offset<e.length;){let i=lr(e,n),a=Math.floor(i/8),s=i%8;if(a===0)throw new Error("Invalid event");if(s===3){o+=1;continue}if(s===4){if(o-=1,o<0)throw new Error("Invalid event");continue}if(s===0)lr(e,n);else if(s===1)n.offset+=8;else if(s===2){let u=lr(e,n);if(n.offset+u>e.length)throw new Error("Invalid event");if(o===0){if(t.arms?.has(a)){if(r!==0&&r!==a)throw new Error("Invalid event");r=a}let l=t.descend[a];if(l!==void 0){let d=Sf[l];d!==void 0&&Uw(e.subarray(n.offset,n.offset+u),d)}}n.offset+=u}else if(s===5)n.offset+=4;else throw new Error("Invalid event");if(n.offset>e.length)throw new Error("Invalid event")}if(o!==0)throw new Error("Invalid event")}function vA(e){let t=new Set,n={offset:0},o=0;for(;n.offset<e.length;){let r=lr(e,n),i=Math.floor(r/8),a=r%8;if(i===0)throw new Error("Invalid event");if(a===3){o+=1;continue}if(a===4){if(o-=1,o<0)throw new Error("Invalid event");continue}if(o===0&&hn.has(i)){if(t.size>0&&!t.has(i))throw new Error("Invalid event");t.add(i)}if(a===0)lr(e,n);else if(a===1)n.offset+=8;else if(a===2){let s=lr(e,n);if(n.offset+s>e.length)throw new Error("Invalid event");if(o===0){let u=Dw[i];if(u!==void 0){let l=Sf[u];l!==void 0&&Uw(e.subarray(n.offset,n.offset+s),l)}}n.offset+=s}else if(a===5)n.offset+=4;else throw new Error("Invalid event");if(n.offset>e.length)throw new Error("Invalid event")}if(o!==0)throw new Error("Invalid event")}function $w(e){if(e.length===1)return e[0];let t=new Uint8Array(e.reduce((o,r)=>o+r.length,0)),n=0;for(let o of e)t.set(o,n),n+=o.length;return t}function jw(e,t){let n=new C(e),o=[],r=new Map,i,a=!1;for(;n.pos<n.len;){let u=n.pos,[l,d]=n.tag(),h=d===2?n.bytes():void 0;h===void 0&&n.skip(d,l);let g=t.arms?.has(l)&&d===(t.armWireTypes?.[l]??2);if(g){if(i!==void 0&&i!==l){let _=r.get(i);_!==void 0&&(o[_]=void 0),r.delete(i),a=!0}if(i=l,!t.singular.has(l)){let _=r.get(l);_!==void 0&&(o[_]=void 0,r.delete(l),a=!0)}}let f=t.descend[l]??t.google?.[l],p=h!==void 0&&(t.singular.has(l)||f!==void 0),b=r.get(l),v=b===void 0?void 0:o[b]?.payloads;if(p&&t.singular.has(l)&&v!==void 0){v.push(h),a=!0;continue}(p||g)&&r.set(l,o.length),o.push({number:l,raw:e.subarray(u,n.pos),...p&&{payloads:[h]},child:f===void 0?void 0:Sf[f]})}let s=[];for(let u of o)if(u!==void 0){if(u.payloads!==void 0){let l=$w(u.payloads),d=u.child===void 0?l:jw(l,u.child);if(u.payloads.length>1||d!==l){s.push(new H().uint32(u.number*8+2).bytes(d).finish()),a=!0;continue}}s.push(u.raw)}return a?$w(s):e}var Tf=class extends Error{constructor(e="Unknown event type"){super(e),this.name="AGUIUnknownEventTypeError"}};function Hw(e,t,n,o){let r=0,i=0,a=0;for(;;){if(t.offset>=e.length||a>=n)return-1;let s=e[t.offset++];if(a+=1,a===n&&s>o)return-1;if(r+=(s&127)*2**i,i+=7,(s&128)===0)return r}}var Qs=(e,t)=>Hw(e,t,5,15),Gw=(e,t)=>Hw(e,t,10,1);function bA(e){let t={offset:0},n=[];for(;t.offset<e.length;){let o=Qs(e,t);if(o<0)return!1;let r=Math.floor(o/8),i=o%8;if(r===0)return!1;if(i===3)n.push(r);else if(i===4){if(n.pop()!==r)return!1}else if(i===0){if(Gw(e,t)<0)return!1}else if(i===1)t.offset+=8;else if(i===5)t.offset+=4;else if(i===2){let a=Qs(e,t);if(a<0||t.offset+a>e.length)return!1;t.offset+=a}else return!1;if(t.offset>e.length)return!1}return n.length===0}function yA(e){let t={offset:0},n=[],o=0;for(;t.offset<e.length;){let r=Qs(e,t);if(r<0)return!1;let i=Math.floor(r/8),a=r%8;if(i===0)return!1;let s=n.length===0;if(a===3){if(s&&hn.has(i))return!1;n.push(i)}else if(a===4){if(n.pop()!==i)return!1}else if(a===0){if(s&&hn.has(i)||Gw(e,t)<0)return!1}else if(a===1){if(s&&hn.has(i))return!1;t.offset+=8}else if(a===5){if(s&&hn.has(i))return!1;t.offset+=4}else if(a===2){let u=Qs(e,t);if(u<0||t.offset+u>e.length)return!1;if(s){if(hn.has(i)||!bA(e.subarray(t.offset,t.offset+u)))return!1;o+=1}t.offset+=u}else return!1;if(t.offset>e.length)return!1}return n.length===0&&o>0}function Fw(e){vA(e);let t=Pw.decode(jw(e,{singular:hn,descend:Dw})),n=Object.entries(t).filter(([,u])=>u!==void 0);if(n.length!==1)throw n.length===0&&yA(e)?new Tf:new Error("Invalid event");let o=n[0],r=pA[o[0]];if(r===void 0)throw new Error("Invalid event");let i=o[1],a=ur(i.baseEvent);if(!a)throw new Error("Invalid event");let s=cA[a.type];if(s!==r)throw new Error("Invalid event: envelope carries "+r+" but the base event declares "+String(s));if(i.type=r,i.timestamp=a.timestamp,i.rawEvent=a.rawEvent,a.metadata!==void 0&&(i.metadata=a.metadata),delete i.baseEvent,i.type==="MESSAGES_SNAPSHOT"&&Array.isArray(i.messages)&&(i.messages=i.messages.map(zw).filter(u=>u!==void 0)),i.type==="RUN_FINISHED"){let u=i,l=typeof u.outcome=="string"&&u.outcome!==""?u.outcome:void 0,d={};d.pendingToolCallIds=u.pendingToolCallIds,delete u.pendingToolCallIds,d.interrupts=u.interrupts,delete u.interrupts,delete u.outcome,l===void 0&&(de(d.pendingToolCallIds).length>0&&(u.pendingToolCallIds=d.pendingToolCallIds),de(d.interrupts).length>0&&(u.interrupts=d.interrupts)),l==="success"&&(u.outcome={type:"success",...de(d.pendingToolCallIds).length>0?{pendingToolCallIds:d.pendingToolCallIds}:{},...de(d.interrupts).length>0?{interrupts:d.interrupts}:{}}),l==="interrupt"&&(u.outcome={type:"interrupt",interrupts:de(d.interrupts),...de(d.pendingToolCallIds).length>0?{pendingToolCallIds:d.pendingToolCallIds}:{}}),l==="cancelled"&&(u.outcome={type:"cancelled",...de(d.pendingToolCallIds).length>0?{pendingToolCallIds:d.pendingToolCallIds}:{},...de(d.interrupts).length>0?{interrupts:d.interrupts}:{}}),l!==void 0&&!["success","interrupt","cancelled"].includes(l)&&(u.outcome={type:l,...de(d.pendingToolCallIds).length>0?{pendingToolCallIds:d.pendingToolCallIds}:{},...de(d.interrupts).length>0?{interrupts:d.interrupts}:{}})}if(i.type==="SUBAGENT_FINISHED"){let u=i,l=typeof u.outcome=="string"&&u.outcome!==""?u.outcome:void 0,d={};d.interruptIds=u.interruptIds,delete u.interruptIds,delete u.outcome,l===void 0&&de(d.interruptIds).length>0&&(u.interruptIds=d.interruptIds),l==="success"&&(u.outcome={type:"success",...de(d.interruptIds).length>0?{interruptIds:d.interruptIds}:{}}),l==="suspended"&&(u.outcome={type:"suspended",...de(d.interruptIds).length>0?{interruptIds:d.interruptIds}:{}}),l!==void 0&&!["success","suspended"].includes(l)&&(u.outcome={type:l,...de(d.interruptIds).length>0?{interruptIds:d.interruptIds}:{}})}if(i.type==="STATE_DELTA"&&Array.isArray(i.delta)&&(i.delta=i.delta.map(u=>{let l=$y[u.op];return u.op=typeof l=="string"&&l!=="UNRECOGNIZED"?l.toLowerCase():String(u.op),Object.keys(u).forEach(d=>{u[d]===void 0&&delete u[d]}),u})),i.type==="ACTIVITY_DELTA"&&Array.isArray(i.patch)&&(i.patch=i.patch.map(u=>{let l=$y[u.op];return u.op=typeof l=="string"&&l!=="UNRECOGNIZED"?l.toLowerCase():String(u.op),Object.keys(u).forEach(d=>{u[d]===void 0&&delete u[d]}),u})),i.type==="RUN_FINISHED"&&Array.isArray(i.usage)&&i.usage.length===0&&delete i.usage,i.type==="RUN_ERROR"&&Array.isArray(i.usage)&&i.usage.length===0&&delete i.usage,i.type==="TOOL_CALL_RESULT"){let u=i;if(u.content!==void 0&&de(u.contentParts).length>0)throw new Error("Invalid event: content carries both string content and content parts");u.content===void 0&&(u.content=de(u.contentParts).map(l=>{let d=Lw(l);return d===void 0&&Mw(),d}).filter(l=>l!==void 0)),delete u.contentParts}return i.type==="RUN_STARTED"&&i.input!==void 0&&(i.input=gA(i.input)),Ef(i),i}var kf="application/vnd.ag-ui.event+proto";var If=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,Af=e=>{if(typeof e!="string")throw new TypeError("Invalid argument expected string");let t=e.match(If);if(!t)throw new Error(`Invalid argument not valid semver ('${e}' received)`);return t.shift(),t},Vw=e=>e==="*"||e==="x"||e==="X",Zw=e=>{let t=parseInt(e,10);return isNaN(t)?e:t},xA=(e,t)=>typeof e!=typeof t?[String(e),String(t)]:[e,t],_A=(e,t)=>{if(Vw(e)||Vw(t))return 0;let[n,o]=xA(Zw(e),Zw(t));return n>o?1:n<o?-1:0},Rf=(e,t)=>{for(let n=0;n<Math.max(e.length,t.length);n++){let o=_A(e[n]||"0",t[n]||"0");if(o!==0)return o}return 0};var bn=(e,t)=>{let n=Af(e),o=Af(t),r=n.pop(),i=o.pop(),a=Rf(n,o);return a!==0?a:r&&i?Rf(r.split("."),i.split(".")):r||i?r?-1:1:0};var Cf=e=>typeof e=="string"&&/^[v\d]/.test(e)&&If.test(e);var Bw="@ag-ui/client";function EA(e){if(!e.metadata||!Object.prototype.hasOwnProperty.call(e.metadata,Bw))return;let t=e.metadata?.[Bw];if(!t||typeof t!="object"||Array.isArray(t))return[];if(!Object.prototype.hasOwnProperty.call(t,"authoritativeActivityTypes"))return;let n=t.authoritativeActivityTypes;return n===null?null:Array.isArray(n)&&n.every(o=>typeof o=="string")?n:[]}var Q=e=>{if(typeof structuredClone=="function")return structuredClone(e);try{return JSON.parse(JSON.stringify(e))}catch{return Array.isArray(e)?[...e]:{...e}}};function ve(){return Mt()}function SA(e){return e instanceof TypeError?/read[- ]?only|not extensible|cannot add property|cannot delete property|can't be deleted|unable to delete property|object is frozen|is not writable/i.test(e.message):!1}function Hf(e){if(Object.freeze(e),typeof e=="object"&&e)for(let t of Object.values(e))typeof t=="object"&&t&&!Object.isFrozen(t)&&Hf(t);return e}var Ww=512*1024;function qw(e,t,n){let o=0,r=[e,t],i=new WeakSet;for(;r.length>0;){let a=r.pop();if(typeof a=="string"){if(o+=a.length,o>n)return!0}else if(typeof a=="object"&&a){if(i.has(a))continue;if(i.add(a),Array.isArray(a))for(let s=0;s<a.length;s++)r.push(a[s]);else{let s=Object.keys(a);for(let u=0;u<s.length;u++){let l=s[u];if(o+=l.length,o>n)return!0;r.push(a[l])}}}}return!1}async function re(e,t,n,o){let r=typeof process<"u"&&process.env!==void 0,i=r&&!!process.env.VITEST_WORKER_ID,a=r&&!!process.env.VITEST_WORKER_ID,s=a&&!qw(t,n,Ww),u=s?Q(t):t,l=s?Q(n):n,d=!1,h=!1,g;for(let f of e)try{s&&(Hf(u),Hf(l));let p=await o(f,u,l);if(p===void 0)continue;let b=!1;if(p.messages!==void 0&&p.messages!==u&&(u=Q(p.messages),d=!0,b=!0),p.state!==void 0&&p.state!==l&&(l=Q(p.state),h=!0,b=!0),s&&b&&qw(u,l,Ww)&&(s=!1),g=p.stopPropagation,g===!0)break}catch(p){if(i&&p instanceof TypeError)throw p;s&&a&&SA(p)?console.error("AG-UI: Subscriber attempted to mutate frozen inputs in-place. Return mutations via AgentStateMutation instead of mutating directly.",p):console.error("Subscriber error:",p);continue}return{...d?{messages:Object.isFrozen(u)?Q(u):u}:{},...h?{state:Object.isFrozen(l)?Q(l):l}:{},...g===void 0?{}:{stopPropagation:g}}}function nl(e){if(!e)return{enabled:!1,events:!1,lifecycle:!1,verbose:!1};if(e===!0)return{enabled:!0,events:!0,lifecycle:!0,verbose:!0};let t=e.events??!0,n=e.lifecycle??!0,o=e.verbose??!1;return{enabled:t||n,events:t,lifecycle:n,verbose:o}}function wn(e){if(e instanceof Gf)return e;if(e===!0)return new Gf(nl(!0))}var Gf=class{constructor(e){this.config=e}event(e,t,n,o){this.config.events&&(this.config.verbose?console.debug(`[${e}] ${t}`,typeof n=="string"?n:JSON.stringify(n)):console.debug(`[${e}] ${t}`,o??n))}lifecycle(e,t,n){this.config.lifecycle&&(n?console.debug(`[${e}] ${t}`,n):console.debug(`[${e}] ${t}`))}get eventsEnabled(){return this.config.events}get lifecycleEnabled(){return this.config.lifecycle}get enabled(){return this.config.enabled}};function Nf(e){return e.enabled?new Gf(e):void 0}function TA(e,t,n){if(t){let r=e.find(a=>a.id===t);if(r?.role==="assistant")return r;r&&console.warn(`TOOL_CALL_START: parentMessageId '${t}' matches a '${r.role}' message, not assistant \u2014 falling back to toolCallId`);let i={id:r?n:t,role:"assistant",toolCalls:[]};return e.push(i),i}let o={id:n,role:"assistant",toolCalls:[]};return e.push(o),o}function Ke(e,t){return!e||t.metadata===void 0?!1:(e.metadata=Vg(e.metadata,Q(t.metadata)),!0)}var cx=(e,t,n,o,r)=>{let i=wn(r),a=Q(n.messages),s=Q(e.state),u={},l=[],d=new Set,h=p=>{let b=p.outcome?.type==="success"?p.outcome.pendingToolCallIds:void 0;return b!==void 0&&b.length>0?[...b]:l.filter(v=>!d.has(v))},g=p=>{p.messages!==void 0&&(a=p.messages,u.messages=p.messages),p.state!==void 0&&(s=p.state,u.state=p.state)},f=()=>{let p=Q(u);return u={},p.messages!==void 0||p.state!==void 0?ie(p):Lr};return t.pipe(ea(async p=>{let b=await re(o,a,s,(v,_,y)=>v.onEvent?.({event:p,agent:n,input:e,messages:_,state:y}));if(g(b),b.stopPropagation===!0?i?.event("APPLY","Event dropped:",p,{type:p.type,reason:"stopPropagation by subscriber"}):i?.event("APPLY","Event applied:",p,{type:p.type,subscribers:o.length}),b.stopPropagation===!0)return f();switch(p.type){case x.TEXT_MESSAGE_START:{let v=await re(o,a,s,(_,y,k)=>_.onTextMessageStartEvent?.({event:p,messages:y,state:k,agent:n,input:e}));if(g(v),v.stopPropagation!==!0){let{messageId:_,role:y="assistant",name:k,subagentRunId:E}=p,I=a.find(L=>L.id===_);if(I?.role==="activity")return console.warn(`TEXT_MESSAGE_START: Message '${_}' is an activity message \u2014 message ids must be unique across activity and text messages`),f();let w=I;if(!w){let L={id:_,role:y,content:"",...k!==void 0&&{name:k},...E!=null&&{subagentRunId:E}};a.push(L),w=L}let A=Ke(w,p);(!I||A)&&g({messages:a})}return f()}case x.TEXT_MESSAGE_CONTENT:{let{messageId:v,delta:_}=p,y=a.find(E=>E.id===v);if(!y)return console.warn(`TEXT_MESSAGE_CONTENT: No message found with ID '${v}'`),f();if(y.role==="activity")return console.warn(`TEXT_MESSAGE_CONTENT: Message '${v}' is an activity message \u2014 message ids must be unique across activity and text messages`),f();let k=await re(o,a,s,(E,I,w)=>E.onTextMessageContentEvent?.({event:p,messages:I,state:w,agent:n,input:e,textMessageBuffer:typeof y.content=="string"?y.content:""}));return g(k),k.stopPropagation!==!0&&(y.content=`${typeof y.content=="string"?y.content:""}${_}`,Ke(y,p),g({messages:a})),f()}case x.TEXT_MESSAGE_END:{let{messageId:v}=p,_=a.find(k=>k.id===v);if(!_)return console.warn(`TEXT_MESSAGE_END: No message found with ID '${v}'`),f();if(_.role==="activity")return console.warn(`TEXT_MESSAGE_END: Message '${v}' is an activity message \u2014 message ids must be unique across activity and text messages`),f();let y=await re(o,a,s,(k,E,I)=>k.onTextMessageEndEvent?.({event:p,messages:E,state:I,agent:n,input:e,textMessageBuffer:typeof _.content=="string"?_.content:""}));return g(y),y.stopPropagation!==!0&&Ke(_,p)&&g({messages:a}),await Promise.all(o.map(k=>{k.onNewMessage?.({message:_,messages:a,state:s,agent:n,input:e})})),f()}case x.TOOL_CALL_START:{let v=await re(o,a,s,(_,y,k)=>_.onToolCallStartEvent?.({event:p,messages:y,state:k,agent:n,input:e}));if(g(v),v.stopPropagation!==!0){let{toolCallId:_,toolCallName:y,parentMessageId:k,subagentRunId:E}=p;l.includes(_)||l.push(_);let I=a.find(U=>U.toolCalls?.some(q=>q.id===_))?.toolCalls?.find(U=>U.id===_);if(I){let U=I.function.name!==y;return U&&(console.warn(`TOOL_CALL_START: tool call '${_}' already exists with name '${I.function.name}' \u2014 updating it to '${y}'`),I.function.name=y),(Ke(I,p)||U)&&g({messages:a}),f()}let w=new Set(a.map(U=>U.id)),A=TA(a,k,_);!w.has(A.id)&&E!=null&&A.subagentRunId===void 0&&(A.subagentRunId=E),A.toolCalls??=[];let L={id:_,type:"function",function:{name:y,arguments:""}};A.toolCalls.push(L),Ke(L,p),g({messages:a})}return f()}case x.TOOL_CALL_ARGS:{let{toolCallId:v,delta:_}=p,y=a.find(I=>I.toolCalls?.some(w=>w.id===v));if(!y)return console.warn(`TOOL_CALL_ARGS: No message found containing tool call with ID '${v}'`),f();let k=y.toolCalls?.find(I=>I.id===v);if(!k)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${v}'`),f();let E=await re(o,a,s,(I,w,A)=>{let L=k.function.arguments,U=k.function.name,q={};try{q=ra(L)}catch{}return I.onToolCallArgsEvent?.({event:p,messages:w,state:A,agent:n,input:e,toolCallBuffer:L,toolCallName:U,partialToolCallArgs:q})});return g(E),E.stopPropagation!==!0&&(k.function.arguments+=_,Ke(k,p),g({messages:a})),f()}case x.TOOL_CALL_END:{let{toolCallId:v}=p,_=a.find(E=>E.toolCalls?.some(I=>I.id===v));if(!_)return console.warn(`TOOL_CALL_END: No message found containing tool call with ID '${v}'`),f();let y=_.toolCalls?.find(E=>E.id===v);if(!y)return console.warn(`TOOL_CALL_END: No tool call found with ID '${v}'`),f();let k=await re(o,a,s,(E,I,w)=>{let A=y.function.arguments,L=y.function.name,U={};try{U=JSON.parse(A)}catch{}return E.onToolCallEndEvent?.({event:p,messages:I,state:w,agent:n,input:e,toolCallName:L,toolCallArgs:U})});return g(k),k.stopPropagation!==!0&&Ke(y,p)&&g({messages:a}),await Promise.all(o.map(E=>{E.onNewToolCall?.({toolCall:y,messages:a,state:s,agent:n,input:e})})),f()}case x.TOOL_CALL_RESULT:{let v=await re(o,a,s,(_,y,k)=>_.onToolCallResultEvent?.({event:p,messages:y,state:k,agent:n,input:e}));if(g(v),v.stopPropagation!==!0){let{messageId:_,toolCallId:y,content:k,role:E,subagentRunId:I}=p;d.add(y);let w={id:_,toolCallId:y,role:E||"tool",content:k,...I!=null&&{subagentRunId:I}};Ke(w,p);let A=a.findIndex(L=>L.role==="assistant"&&L.toolCalls?.some(U=>U.id===y));if(A===-1)a.push(w);else{let L=A+1;for(;L<a.length&&a[L].role==="tool";)L++;a.splice(L,0,w)}await Promise.all(o.map(L=>{L.onNewMessage?.({message:w,messages:a,state:s,agent:n,input:e})})),g({messages:a})}return f()}case x.STATE_SNAPSHOT:{let v=await re(o,a,s,(_,y,k)=>_.onStateSnapshotEvent?.({event:p,messages:y,state:k,agent:n,input:e}));if(g(v),v.stopPropagation!==!0){let{snapshot:_}=p;s=_,g({state:s})}return f()}case x.STATE_DELTA:{let v=await re(o,a,s,(_,y,k)=>_.onStateDeltaEvent?.({event:p,messages:y,state:k,agent:n,input:e}));if(g(v),v.stopPropagation!==!0){let{delta:_}=p;try{s=Oi.applyPatch(s,_,!0,!1).newDocument,g({state:s})}catch(y){let k=y instanceof Error?y.message:String(y);console.warn(`Failed to apply state patch:
|
|
34
|
+
Current state: ${JSON.stringify(s,null,2)}
|
|
35
|
+
Patch operations: ${JSON.stringify(_,null,2)}
|
|
36
|
+
Error: ${k}`)}}return f()}case x.MESSAGES_SNAPSHOT:{let v=await re(o,a,s,(_,y,k)=>_.onMessagesSnapshotEvent?.({event:p,messages:y,state:k,agent:n,input:e}));if(g(v),v.stopPropagation!==!0){let{messages:_}=p,y=_.map(U=>{if(U.subagentRunId!==null)return U;let q={...U};return delete q.subagentRunId,q}),k=new Map(y.map(U=>[U.id,U])),E=EA(p),I=y.some(U=>U.role==="activity"),w=y.some(U=>U.role==="reasoning"),A=U=>U.role==="activity"&&(E?!E.includes(U.activityType):E!==null&&!I)||U.role==="reasoning"&&!w;a=a.filter(U=>k.has(U.id)||A(U)).map(U=>k.get(U.id)??U);let L=new Set(a.map(U=>U.id));for(let U of y)L.has(U.id)||a.push(U);g({messages:a})}return f()}case x.ACTIVITY_SNAPSHOT:{let v=p,_=a.findIndex(w=>w.id===v.messageId),y=_>=0?a[_]:void 0,k=y?.role==="activity"?y:void 0,E=v.replace??!0,I=await re(o,a,s,(w,A,L)=>w.onActivitySnapshotEvent?.({event:v,messages:A,state:L,agent:n,input:e,activityMessage:k,existingMessage:y}));if(g(I),I.stopPropagation!==!0){let w={id:v.messageId,role:"activity",activityType:v.activityType,content:Q(v.content),...v.subagentRunId!=null&&{subagentRunId:v.subagentRunId}},A,L;_===-1?(a.push(w),A=w,L=w):k?(E&&(a[_]={...k,activityType:v.activityType,content:Q(v.content),subagentRunId:v.subagentRunId},v.subagentRunId??delete a[_].subagentRunId),L=a[_]):E&&(a[_]=w,A=w,L=w),Ke(L,v),g({messages:a}),A&&await Promise.all(o.map(U=>U.onNewMessage?.({message:A,messages:a,state:s,agent:n,input:e})))}return f()}case x.ACTIVITY_DELTA:{let v=p,_=a.findIndex(I=>I.id===v.messageId);if(_===-1)return f();let y=a[_];if(y.role!=="activity")return console.warn(`ACTIVITY_DELTA: Message '${v.messageId}' is not an activity message`),f();let k=y,E=await re(o,a,s,(I,w,A)=>I.onActivityDeltaEvent?.({event:v,messages:w,state:A,agent:n,input:e,activityMessage:k}));if(g(E),E.stopPropagation!==!0)try{Ke(k,v)&&g({messages:a});let I=Q(k.content??{}),w=Oi.applyPatch(I,v.patch??[],!0,!1).newDocument;a[_]={...k,content:Q(w),activityType:v.activityType},g({messages:a})}catch(I){let w=I instanceof Error?I.message:String(I);console.warn(`Failed to apply activity patch for '${v.messageId}': ${w}`)}return f()}case x.RAW:return g(await re(o,a,s,(v,_,y)=>v.onRawEvent?.({event:p,messages:_,state:y,agent:n,input:e}))),f();case x.CUSTOM:return g(await re(o,a,s,(v,_,y)=>v.onCustomEvent?.({event:p,messages:_,state:y,agent:n,input:e}))),f();case x.RUN_STARTED:{let v=await re(o,a,s,(_,y,k)=>_.onRunStartedEvent?.({event:p,messages:y,state:k,agent:n,input:e}));if(g(v),l=[],d=new Set,v.stopPropagation!==!0){let _=p;if(_.input?.messages){for(let y of _.input.messages){let k=y;if(y.subagentRunId===null){let E={...y};delete E.subagentRunId,k=E}a.find(E=>E.id===k.id)||a.push(k)}g({messages:a})}}return f()}case x.RUN_FINISHED:{let v=p,_=v.outcome?.type==="interrupt"?{event:v,outcome:"interrupt",interrupts:v.outcome.interrupts}:v.outcome?.type==="cancelled"?{event:v,outcome:"cancelled"}:{event:v,outcome:"success",result:v.result,pendingToolCallIds:h(v)},y=await re(o,a,s,(k,E,I)=>k.onRunFinishedEvent?.({..._,messages:E,state:I,agent:n,input:e}));return g(y),y.stopPropagation!==!0&&(n.pendingInterrupts=_.outcome==="interrupt"?_.interrupts.map(k=>{if(k.subagentRunId!==null)return k;let E={...k};return delete E.subagentRunId,E}):[]),f()}case x.RUN_ERROR:return g(await re(o,a,s,(v,_,y)=>v.onRunErrorEvent?.({event:p,messages:_,state:y,agent:n,input:e}))),f();case x.STEP_STARTED:return g(await re(o,a,s,(v,_,y)=>v.onStepStartedEvent?.({event:p,messages:_,state:y,agent:n,input:e}))),f();case x.STEP_FINISHED:return g(await re(o,a,s,(v,_,y)=>v.onStepFinishedEvent?.({event:p,messages:_,state:y,agent:n,input:e}))),f();case x.TEXT_MESSAGE_CHUNK:throw Error("TEXT_MESSAGE_CHUNK must be transformed before being applied");case x.TOOL_CALL_CHUNK:throw Error("TOOL_CALL_CHUNK must be transformed before being applied");case x.REASONING_START:return g(await re(o,a,s,(v,_,y)=>v.onReasoningStartEvent?.({event:p,messages:_,state:y,agent:n,input:e}))),f();case x.REASONING_MESSAGE_START:{let v=await re(o,a,s,(_,y,k)=>_.onReasoningMessageStartEvent?.({event:p,messages:y,state:k,agent:n,input:e}));if(g(v),v.stopPropagation!==!0){let{messageId:_,subagentRunId:y}=p,k=a.find(w=>w.id===_);if(k?.role==="activity")return console.warn(`REASONING_MESSAGE_START: Message '${_}' is an activity message \u2014 message ids must be unique across activity and reasoning messages`),f();let E=k;if(!E){let w={id:_,role:"reasoning",content:"",...y!=null&&{subagentRunId:y}};a.push(w),E=w}let I=Ke(E,p);(!k||I)&&g({messages:a})}return f()}case x.REASONING_MESSAGE_CONTENT:{let{messageId:v,delta:_}=p,y=a.find(E=>E.id===v);if(!y)return console.warn(`REASONING_MESSAGE_CONTENT: No message found with ID '${v}'`),f();if(y.role==="activity")return console.warn(`REASONING_MESSAGE_CONTENT: Message '${v}' is an activity message \u2014 message ids must be unique across activity and reasoning messages`),f();let k=await re(o,a,s,(E,I,w)=>E.onReasoningMessageContentEvent?.({event:p,messages:I,state:w,agent:n,input:e,reasoningMessageBuffer:typeof y.content=="string"?y.content:""}));return g(k),k.stopPropagation!==!0&&(y.content=`${typeof y.content=="string"?y.content:""}${_}`,Ke(y,p),g({messages:a})),f()}case x.REASONING_MESSAGE_END:{let{messageId:v}=p,_=a.find(k=>k.id===v);if(!_)return console.warn(`REASONING_MESSAGE_END: No message found with ID '${v}'`),f();if(_.role==="activity")return console.warn(`REASONING_MESSAGE_END: Message '${v}' is an activity message \u2014 message ids must be unique across activity and reasoning messages`),f();let y=await re(o,a,s,(k,E,I)=>k.onReasoningMessageEndEvent?.({event:p,messages:E,state:I,agent:n,input:e,reasoningMessageBuffer:typeof _.content=="string"?_.content:""}));return g(y),y.stopPropagation!==!0&&Ke(_,p)&&g({messages:a}),await Promise.all(o.map(k=>{k.onNewMessage?.({message:_,messages:a,state:s,agent:n,input:e})})),f()}case x.REASONING_MESSAGE_CHUNK:throw Error("REASONING_MESSAGE_CHUNK must be transformed before being applied");case x.REASONING_END:return g(await re(o,a,s,(v,_,y)=>v.onReasoningEndEvent?.({event:p,messages:_,state:y,agent:n,input:e}))),f();case x.REASONING_ENCRYPTED_VALUE:{let{subtype:v,entityId:_,encryptedValue:y}=p,k=await re(o,a,s,(E,I,w)=>E.onReasoningEncryptedValueEvent?.({event:p,messages:I,state:w,agent:n,input:e}));if(g(k),k.stopPropagation!==!0){let E=!1;if(v==="tool-call"){for(let I of a)if(I.role==="assistant"&&I.toolCalls){let w=I.toolCalls.find(A=>A.id===_);if(w){w.encryptedValue=y,E=!0;break}}}else{let I=a.find(w=>w.id===_);I?.role!=="activity"&&I&&(I.encryptedValue=y,E=!0)}E&&(u.messages=a)}return f()}case x.SUBAGENT_STARTED:return g(await re(o,a,s,(v,_,y)=>v.onSubagentStartedEvent?.({event:p,messages:_,state:y,agent:n,input:e}))),f();case x.SUBAGENT_FINISHED:return g(await re(o,a,s,(v,_,y)=>v.onSubagentFinishedEvent?.({event:p,messages:_,state:y,agent:n,input:e}))),f();case x.SUBAGENT_ERROR:return g(await re(o,a,s,(v,_,y)=>v.onSubagentErrorEvent?.({event:p,messages:_,state:y,agent:n,input:e}))),f()}return p.type,f()}),hc(),o.length>0?mc({}):p=>p)},Of=e=>t=>{let n=wn(e),o=new Set,r=new Set,i=new Set,a=new Set,s={message:new Map,toolCall:new Map,activity:new Map,reasoning:new Map},u=!1,l=!1,d=!1,h=new Map,g=E=>{let I=h.get(E);return I||(I=new Map,h.set(E,I)),I},f=()=>{for(let E of h.values())if(E.size>0)return!0;return!1},p=new Map,b=new Set,v=!1,_=()=>{o.clear(),r.clear(),i.clear(),a.clear(),s.message.clear(),s.toolCall.clear(),s.activity.clear(),s.reasoning.clear(),h.clear(),p.clear(),b.clear(),u=!1,l=!1,v=!0},y=(E,I)=>{let w=E??[];if(Array.isArray(w))for(let A of w){if(!A||typeof A.id!="string")continue;if(A.subagentRunId===null)return new W(`Cannot send a message (id '${A.id}') with 'subagentRunId: null'. The field is optional \u2014 omit it entirely.`);let L=A.role==="reasoning"?s.reasoning:A.role==="activity"?s.activity:s.message;(I||!L.has(A.id))&&L.set(A.id,{subagentRunId:A.subagentRunId});for(let U of A.toolCalls??[])U&&typeof U.id=="string"&&(I||!s.toolCall.has(U.id))&&s.toolCall.set(U.id,{subagentRunId:A.subagentRunId??void 0})}},k=(E,I,w,A,L)=>{if(I!==void 0&&w&&w.subagentRunId!==I)return new W(`Cannot send '${E}': subagentRunId '${I}' does not match the ${A} '${L}' opener's subagent '${w.subagentRunId??"(the parent agent)"}'.`)};return t.pipe(je(E=>{let I=E.type;if(n?.event("VERIFY","Event:",E,{type:E.type}),l&&I!==x.RUN_STARTED)return F(()=>new W(`Cannot send event type '${I}': The run has already errored with 'RUN_ERROR'. No further events can be sent.`));if(u&&I!==x.RUN_ERROR&&I!==x.RUN_STARTED)return F(()=>new W(`Cannot send event type '${I}': The run has already finished with 'RUN_FINISHED'. Start a new run with 'RUN_STARTED'.`));if(d){if(I===x.RUN_STARTED){if(v&&!u&&!l)return F(()=>new W("Cannot send 'RUN_STARTED' while a run is still active. The previous run must be finished with 'RUN_FINISHED' before starting a new run."));(u||l)&&_()}}else if(d=!0,I!==x.RUN_STARTED&&I!==x.RUN_ERROR)return F(()=>new W("First event must be 'RUN_STARTED'"));if(E.subagentRunId===null)return F(()=>new W(`Cannot send '${I}' with 'subagentRunId: null'. The field is optional \u2014 omit it entirely.`));if(I===x.SUBAGENT_STARTED||I===x.SUBAGENT_FINISHED||I===x.SUBAGENT_ERROR){let w=I===x.SUBAGENT_STARTED?["description","parentSubagentRunId","parentToolCallId","parentMessageId"]:I===x.SUBAGENT_FINISHED?["outcome"]:["code"];for(let L of w)if(E[L]===null)return F(()=>new W(`Cannot send '${I}' with '${L}: null'. The field is optional \u2014 omit it entirely.`));let A=E.outcome;if(A!=null&&A.type!=="success"&&A.type!=="suspended")return F(()=>new W(`Cannot send '${I}' with outcome type '${String(A.type)}'. The outcome is either { type: "success" } or { type: "suspended" }.`));if(A&&A.interruptIds===null)return F(()=>new W(`Cannot send '${I}' with 'outcome.interruptIds: null'. The field is optional \u2014 omit it entirely.`));if(A&&Array.isArray(A.interruptIds)&&A.interruptIds.some(L=>typeof L!="string"))return F(()=>new W(`Cannot send '${I}' with a non-string entry in 'outcome.interruptIds'. Interrupt ids are strings.`))}if(I===x.RUN_FINISHED){let w=E.outcome;if(w?.type==="interrupt"&&Array.isArray(w.interrupts)){for(let A of w.interrupts)if(A&&A.subagentRunId===null)return F(()=>new W(`Cannot send 'RUN_FINISHED' with an interrupt (id '${A.id}') carrying 'subagentRunId: null'. The field is optional \u2014 omit it entirely.`))}}switch(I){case x.TEXT_MESSAGE_START:{let w=E.messageId;if(o.has(w))return F(()=>new W(`Cannot send 'TEXT_MESSAGE_START' event: A text message with ID '${w}' is already in progress. Complete it with 'TEXT_MESSAGE_END' first.`));let A=s.message.get(w);if(A){let L=k(I,E.subagentRunId,A,"message",w);if(L)return F(()=>L)}return o.add(w),A||s.message.set(w,{subagentRunId:E.subagentRunId}),ie(E)}case x.TEXT_MESSAGE_CONTENT:{let w=E.messageId;if(!o.has(w))return F(()=>new W(`Cannot send 'TEXT_MESSAGE_CONTENT' event: No active text message found with ID '${w}'. Start a text message with 'TEXT_MESSAGE_START' first.`));let A=k(I,E.subagentRunId,s.message.get(w),"message",w);return A?F(()=>A):ie(E)}case x.TEXT_MESSAGE_END:{let w=E.messageId;if(!o.has(w))return F(()=>new W(`Cannot send 'TEXT_MESSAGE_END' event: No active text message found with ID '${w}'. A 'TEXT_MESSAGE_START' event must be sent first.`));let A=k(I,E.subagentRunId,s.message.get(w),"message",w);return A?F(()=>A):(o.delete(w),ie(E))}case x.TOOL_CALL_START:{let w=E.toolCallId;if(r.has(w))return F(()=>new W(`Cannot send 'TOOL_CALL_START' event: A tool call with ID '${w}' is already in progress. Complete it with 'TOOL_CALL_END' first.`));let A=E.parentMessageId,L=E.subagentRunId,U;if(A!==void 0){let Ne=s.message.get(A);if(Ne){if(L!==void 0&&L!==Ne.subagentRunId)return F(()=>new W(`Cannot send 'TOOL_CALL_START': subagentRunId '${L}' does not match its parent message '${A}' owner '${Ne.subagentRunId??"(the parent agent)"}'. A tool call belongs to the message that carries it.`));U=Ne}}let q=s.toolCall.get(w);if(q){let Ne=k(I,L,q,"tool call",w);if(Ne)return F(()=>Ne);if(L===void 0&&U&&U.subagentRunId!==q.subagentRunId)return F(()=>new W(`Cannot send 'TOOL_CALL_START': tool call '${w}' is owned by '${q.subagentRunId??"(the parent agent)"}' but its parent message '${A}' is owned by '${U.subagentRunId??"(the parent agent)"}'. A tool call belongs to the message that carries it.`))}return r.add(w),q||s.toolCall.set(w,L===void 0?U??{subagentRunId:void 0}:{subagentRunId:L}),ie(E)}case x.TOOL_CALL_ARGS:{let w=E.toolCallId;if(!r.has(w))return F(()=>new W(`Cannot send 'TOOL_CALL_ARGS' event: No active tool call found with ID '${w}'. Start a tool call with 'TOOL_CALL_START' first.`));let A=k(I,E.subagentRunId,s.toolCall.get(w),"tool call",w);return A?F(()=>A):ie(E)}case x.TOOL_CALL_END:{let w=E.toolCallId;if(!r.has(w))return F(()=>new W(`Cannot send 'TOOL_CALL_END' event: No active tool call found with ID '${w}'. A 'TOOL_CALL_START' event must be sent first.`));let A=k(I,E.subagentRunId,s.toolCall.get(w),"tool call",w);return A?F(()=>A):(r.delete(w),ie(E))}case x.STEP_STARTED:{let w=E.stepName,A=E.subagentRunId;return g(A).has(w)?F(()=>new W(`Step "${w}" is already active for 'STEP_STARTED'${A===void 0?"":` in subagent '${A}'`}`)):(g(A).set(w,!0),ie(E))}case x.STEP_FINISHED:{let w=E.stepName,A=E.subagentRunId;if(!g(A).has(w)){let L,U=!1;for(let[q,Ne]of h)if(q!==A&&Ne.has(w)){L=q,U=!0;break}return F(U?()=>new W(`Cannot send 'STEP_FINISHED' for step "${w}" attributed to ${A===void 0?"the parent agent":`subagent '${A}'`}: that step is open under ${L===void 0?"the parent agent":`subagent '${L}'`}. A step must be finished by whoever started it.`):()=>new W(`Cannot send 'STEP_FINISHED' for step "${w}" that was not started`))}return g(A).delete(w),ie(E)}case x.ACTIVITY_SNAPSHOT:{let w=E.messageId;return(!s.activity.has(w)||E.replace!==!1)&&s.activity.set(w,{subagentRunId:E.subagentRunId}),ie(E)}case x.TOOL_CALL_RESULT:{let w=E.messageId;return typeof w=="string"&&s.message.set(w,{subagentRunId:E.subagentRunId}),ie(E)}case x.REASONING_START:case x.REASONING_MESSAGE_START:{let w=E.messageId,A=I===x.REASONING_START,L=A?i:a;if(L.has(w))return F(()=>new W(A?`Cannot send 'REASONING_START' event: A reasoning span with ID '${w}' is already in progress. Complete it with 'REASONING_END' first.`:`Cannot send 'REASONING_MESSAGE_START' event: A reasoning message with ID '${w}' is already in progress. Complete it with 'REASONING_MESSAGE_END' first.`));let U=s.reasoning.get(w);if(U){let q=k(I,E.subagentRunId,U,"reasoning message",w);if(q)return F(()=>q)}return L.add(w),U||s.reasoning.set(w,{subagentRunId:E.subagentRunId}),ie(E)}case x.REASONING_MESSAGE_CONTENT:case x.REASONING_MESSAGE_END:case x.REASONING_END:{let w=E.messageId,A=I===x.REASONING_END,L=A?i:a;if(!L.has(w))return F(()=>new W(A?`Cannot send 'REASONING_END' event: No active reasoning span found with ID '${w}'. A 'REASONING_START' event must be sent first.`:`Cannot send '${I}' event: No active reasoning message found with ID '${w}'. Start a reasoning message with 'REASONING_MESSAGE_START' first.`));let U=k(I,E.subagentRunId,s.reasoning.get(w),"reasoning message",w);return U?F(()=>U):((I===x.REASONING_END||I===x.REASONING_MESSAGE_END)&&L.delete(w),ie(E))}case x.REASONING_ENCRYPTED_VALUE:{let w=E.entityId,A=E.subtype,L=A==="tool-call"?s.toolCall.get(w):A==="message"?s.message.get(w)??s.reasoning.get(w):s.reasoning.get(w),U=A==="tool-call"?"tool call":A==="message"?"message":"reasoning message",q=k(I,E.subagentRunId,L,U,w);return q?F(()=>q):ie(E)}case x.ACTIVITY_DELTA:{let w=E.messageId,A=k(I,E.subagentRunId,s.activity.get(w),"activity",w);return A?F(()=>A):ie(E)}case x.SUBAGENT_STARTED:{if(typeof E.subagentRunId!="string")return F(()=>new W("Cannot send 'SUBAGENT_STARTED' without a 'subagentRunId'."));if(typeof E.name!="string")return F(()=>new W("Cannot send 'SUBAGENT_STARTED' without a 'name'."));let w=E.subagentRunId,A=E.parentSubagentRunId;return p.has(w)?F(()=>new W(`Cannot send 'SUBAGENT_STARTED': subagent '${w}' is already active. Finish it with 'SUBAGENT_FINISHED' first.`)):b.has(w)?F(()=>new W(`Cannot send 'SUBAGENT_STARTED': subagent '${w}' has already finished in this run. Subagent IDs are per-invocation and cannot be reused.`)):A!==void 0&&!p.has(A)&&!b.has(A)?F(()=>new W(`Cannot send 'SUBAGENT_STARTED': parentSubagentRunId '${A}' has not been started in this run.`)):(p.set(w,!0),ie(E))}case x.SUBAGENT_FINISHED:case x.SUBAGENT_ERROR:{if(typeof E.subagentRunId!="string")return F(()=>new W(`Cannot send '${I}' without a 'subagentRunId'.`));if(I===x.SUBAGENT_ERROR&&typeof E.message!="string")return F(()=>new W("Cannot send 'SUBAGENT_ERROR' without a 'message'."));let w=E.subagentRunId;return p.has(w)?(p.delete(w),b.add(w),ie(E)):F(()=>new W(`Cannot send '${I}': no active subagent found with ID '${w}'. A 'SUBAGENT_STARTED' event must be sent first.`))}case x.MESSAGES_SNAPSHOT:{let w=y(E.messages,!0);if(w)return F(()=>w)}return ie(E);case x.RUN_STARTED:v=!0;{let w=y((E.input??{}).messages,!1);if(w)return F(()=>w)}return ie(E);case x.RUN_FINISHED:if(f()){let w=[];for(let[L,U]of h)for(let q of U.keys())w.push(L===void 0?q:`${q} (subagent '${L}')`);let A=w.join(", ");return F(()=>new W(`Cannot send 'RUN_FINISHED' while steps are still active: ${A}`))}if(o.size>0){let w=Array.from(o.keys()).join(", ");return F(()=>new W(`Cannot send 'RUN_FINISHED' while text messages are still active: ${w}`))}if(a.size>0){let w=Array.from(a.keys()).join(", ");return F(()=>new W(`Cannot send 'RUN_FINISHED' while reasoning messages are still active: ${w}`))}if(i.size>0){let w=Array.from(i.keys()).join(", ");return F(()=>new W(`Cannot send 'RUN_FINISHED' while reasoning spans are still active: ${w}`))}if(r.size>0){let w=Array.from(r.keys()).join(", ");return F(()=>new W(`Cannot send 'RUN_FINISHED' while tool calls are still active: ${w}`))}if(p.size>0){let w=Array.from(p.keys()).join(", ");return F(()=>new W(`Cannot send 'RUN_FINISHED' while subagents are still active: ${w}`))}return u=!0,ie(E);case x.RUN_ERROR:return l=!0,ie(E);case x.CUSTOM:return ie(E);default:return ie(E)}}))},yn=(function(e){return e.HEADERS="headers",e.DATA="data",e})({}),kA=e=>zr(()=>tn(e())).pipe(gc(t=>{if(!t.ok){let r=t.headers.get("content-type")||"";return tn(t.text()).pipe(je(i=>{let a=i;if(r.includes("application/json"))try{a=JSON.parse(i)}catch{}let s=Error(`HTTP ${t.status}: ${typeof a=="string"?a:JSON.stringify(a)}`);return s.status=t.status,s.payload=a,F(()=>s)}))}let n={type:yn.HEADERS,status:t.status,headers:t.headers},o=t.body?.getReader();return o?new he(r=>(r.next(n),(async()=>{try{for(;;){let{done:i,value:a}=await o.read();if(i)break;let s={type:yn.DATA,data:a};r.next(s)}r.complete()}catch(i){r.error(i)}})(),()=>{o.cancel().catch(i=>{if(i?.name!=="AbortError")throw i})})):F(()=>Error("Failed to getReader() from response"))})),Xw=10*1024*1024,IA=(e,t)=>{let n=wn(t),o=new vt,r=new TextDecoder("utf-8",{fatal:!1}),i="";e.subscribe({next:s=>{if(s.type!==yn.HEADERS&&s.type===yn.DATA&&s.data){let u=r.decode(s.data,{stream:!0});i+=u;let l=i.split(/\n\n/);i=l.pop()||"";for(let d of l)a(d);if(i.length>Xw){o.error(Error(`SSE buffer size exceeded maximum limit of ${Xw/(1024*1024)} MB`));return}}},error:s=>o.error(s),complete:()=>{i&&(i+=r.decode(),a(i)),o.complete()}});function a(s){let u=s.split(`
|
|
37
|
+
`),l=[];for(let d of u)d.startsWith("data:")&&l.push(d.slice(5).replace(/^ /,""));if(l.length>0)try{let d=l.join(`
|
|
38
|
+
`),h=JSON.parse(d);n?.event("SSE","Event received:",h,{type:h?.type}),o.next(h)}catch(d){o.error(d)}}return o.asObservable()},Kw=10*1024*1024,AA=()=>typeof process<"u"&&process.env!==void 0&&!!process.env.SUPPRESS_TRANSFORMATION_WARNINGS,RA=(e,t)=>{let n=wn(t),o=new vt,r=new Uint8Array,i=!1;e.subscribe({next:s=>{if(s.type!==yn.HEADERS&&s.type===yn.DATA&&s.data){let u=new Uint8Array(r.length+s.data.length);u.set(r,0),u.set(s.data,r.length),r=u,a()}},error:s=>o.error(s),complete:()=>{if(a(),!i){if(r.length>0){o.error(Error(`The binary stream ended mid-frame: ${r.length} trailing bytes could not be read as a complete message.`));return}o.complete()}}});function a(){if(!i)for(;r.length>=4;){let s=4+new DataView(r.buffer,r.byteOffset,4).getUint32(0,!1);if(s>Kw){o.error(Error(`Protobuf message size exceeded maximum limit of ${Kw/(1024*1024)} MB`));return}if(r.length<s)break;try{let u=r.slice(4,s),l=Fw(u);n?.event("PROTO","Event received:",l,{type:l.type}),o.next(l)}catch(u){if(u instanceof Tf)AA()||console.warn("[ag-ui][proto] Dropped an event this build does not know: the protocol has a variant this SDK predates.");else{let l=u instanceof Error?u.message:String(u);i=!0,o.error(Error(`Failed to decode protocol buffer message: ${l}`));return}}r=r.slice(s)}}return o.asObservable()},CA=(e,t)=>{let n=wn(t),o=new vt,r=new ji(1),i=!1,a,s=!1,u=()=>{s=!0,a?.unsubscribe()},l=h=>{u(),o.error(h)},d=()=>{u(),o.complete()};return a=e.subscribe({next:h=>{if(r.next(h),h.type===yn.HEADERS&&!i){i=!0;let g=h.headers.get("content-type");n?.lifecycle("HTTP","Stream format detected:",{contentType:g,parser:g===kf?"protobuf":"sse"}),g===kf?RA(r,n).subscribe({next:f=>o.next(f),error:f=>l(f),complete:()=>d()}):IA(r,n).subscribe({next:f=>{if(typeof f!="object"||!f||Array.isArray(f)){let b=Error("Invalid event: the frame is not a JSON object.");n?.event("HTTP","Event invalid:",{json:f,error:String(b)}),l(b);return}let p=f;if(typeof p.type!="string"||p.type.length===0){let b=Error("Invalid event: the frame carries no event type.");n?.event("HTTP","Event invalid:",{json:f,error:String(b)}),l(b);return}n?.event("HTTP","Event received:",f,{type:p.type}),o.next(f)},error:f=>{if(f?.name==="AbortError"){o.next({type:x.RUN_ERROR,message:f.message||"Request aborted",code:"abort",rawEvent:f}),d();return}return l(f)},complete:()=>d()})}else i||l(Error("No headers event received before data events"))},error:h=>{r.error(h),l(h)},complete:()=>{r.complete()}}),s&&a.unsubscribe(),o.asObservable()},Pe={TextMessageStart:"TextMessageStart",TextMessageContent:"TextMessageContent",TextMessageEnd:"TextMessageEnd",ActionExecutionStart:"ActionExecutionStart",ActionExecutionArgs:"ActionExecutionArgs",ActionExecutionEnd:"ActionExecutionEnd",ActionExecutionResult:"ActionExecutionResult",AgentStateMessage:"AgentStateMessage",MetaEvent:"MetaEvent",RunStarted:"RunStarted",RunFinished:"RunFinished",RunError:"RunError",NodeStarted:"NodeStarted",NodeFinished:"NodeFinished"},NA=e=>{if(typeof e=="string")return e;if(!Array.isArray(e))return;let t=e.filter(n=>n.type==="text").map(n=>n.text).filter(n=>n.length>0);if(t.length!==0)return t.join(`
|
|
39
|
+
`)};function dx(e,t){return Zg(t)&&To(`[ag-ui][legacy] The result of tool call '${e}' carries content parts the legacy protocol cannot represent; only its text parts are bridged and the rest is dropped.`),jn(t)}var To=e=>{typeof process<"u"&&process.env!==void 0&&process.env.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(e)},OA=(e,t,n)=>o=>{let r={},i=!0,a=!0,s="",u=null,l=null,d=[],h={},g=!1,f=p=>{typeof p=="object"&&p&&("messages"in p&&delete p.messages,r=p)};return o.pipe(je(p=>{switch(p.type){case x.TEXT_MESSAGE_START:{let b=p;return[{type:Pe.TextMessageStart,messageId:b.messageId,role:b.role}]}case x.TEXT_MESSAGE_CONTENT:{let b=p;return[{type:Pe.TextMessageContent,messageId:b.messageId,content:b.delta}]}case x.TEXT_MESSAGE_END:{let b=p;return[{type:Pe.TextMessageEnd,messageId:b.messageId}]}case x.TOOL_CALL_START:{let b=p;return d.push({id:b.toolCallId,type:"function",function:{name:b.toolCallName,arguments:""}}),a=!0,h[b.toolCallId]=b.toolCallName,[{type:Pe.ActionExecutionStart,actionExecutionId:b.toolCallId,actionName:b.toolCallName,parentMessageId:b.parentMessageId}]}case x.TOOL_CALL_ARGS:{let b=p,v=d.find(y=>y.id===b.toolCallId);if(!v)return To(`[ag-ui][legacy] TOOL_CALL_ARGS: No tool call found with ID '${b.toolCallId}'`),[];v.function.arguments+=b.delta;let _=!1;if(l){let y=l.find(k=>k.tool==v.function.name);if(y)try{let k=JSON.parse(ra(v.function.arguments));y.tool_argument&&y.tool_argument in k?(f({...r,[y.state_key]:k[y.tool_argument]}),_=!0):y.tool_argument||(f({...r,[y.state_key]:k}),_=!0)}catch{}}return[{type:Pe.ActionExecutionArgs,actionExecutionId:b.toolCallId,args:b.delta},..._?[{type:Pe.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:i,role:"assistant",state:JSON.stringify(r),active:a}]:[]]}case x.TOOL_CALL_END:{let b=p;return[{type:Pe.ActionExecutionEnd,actionExecutionId:b.toolCallId}]}case x.TOOL_CALL_RESULT:{let b=p,v=h[b.toolCallId];return(v===void 0||v==="")&&To(`[ag-ui][legacy] No usable tool name was seen for tool call '${b.toolCallId}' (${v===void 0?"no TOOL_CALL_START reached this bridge":"its TOOL_CALL_START carried an empty toolCallName"}), so its result is being bridged with the fabricated action name "unknown". Downstream consumers route on that name.`),[{type:Pe.ActionExecutionResult,actionExecutionId:b.toolCallId,result:dx(b.toolCallId,b.content),actionName:v||"unknown"}]}case x.RAW:return g||(g=!0,To("[ag-ui][legacy] Dropping RAW events: the legacy runtime protocol has no equivalent, so the provider payloads they carry do not reach the legacy stream. Reported once per stream.")),[];case x.CUSTOM:{let b=p;switch(b.name){case"Exit":i=!1;break;case"PredictState":l=b.value;break}return[{type:Pe.MetaEvent,name:b.name,value:b.value}]}case x.STATE_SNAPSHOT:return f(p.snapshot),[{type:Pe.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:i,role:"assistant",state:JSON.stringify(r),active:a}];case x.STATE_DELTA:{let b=p,v;try{v=Oi.applyPatch(r,b.delta,!0,!1).newDocument}catch(_){let y=_ instanceof Error?_.message:String(_);return To(`[ag-ui][legacy] Failed to apply state patch:
|
|
40
|
+
Current state: ${JSON.stringify(r,null,2)}
|
|
41
|
+
Patch operations: ${JSON.stringify(b.delta,null,2)}
|
|
42
|
+
Error: ${y}`),[]}return f(v),[{type:Pe.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:i,role:"assistant",state:JSON.stringify(r),active:a}]}case x.MESSAGES_SNAPSHOT:return u=p.messages,[{type:Pe.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:i,role:"assistant",state:JSON.stringify({...r,...u?{messages:u}:{}}),active:!0}];case x.RUN_STARTED:return[];case x.RUN_FINISHED:{if(u&&(r.messages=u),Object.keys(r).length===0)return[];let b=null;if(u)try{b=$A(u)}catch(v){return[{type:Pe.RunError,message:v.message}]}return[{type:Pe.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:i,role:"assistant",state:JSON.stringify({...r,...b?{messages:b}:{}}),active:!1}]}case x.RUN_ERROR:{let b=p;return[{type:Pe.RunError,message:b.message,code:b.code}]}case x.STEP_STARTED:return s=p.stepName,d=[],l=null,[{type:Pe.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:i,role:"assistant",state:JSON.stringify(r),active:!0}];case x.STEP_FINISHED:return d=[],l=null,[{type:Pe.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:i,role:"assistant",state:JSON.stringify(r),active:!1}];default:return[]}}))};function $A(e){let t=[];for(let n of e)if(n.role==="assistant"||n.role==="user"||n.role==="system"){let o=NA(n.content);if(o){let r={id:n.id,role:n.role,content:o};t.push(r)}if(n.role==="assistant"&&n.toolCalls&&n.toolCalls.length>0)for(let r of n.toolCalls){let i;try{i=JSON.parse(r.function.arguments)}catch(s){throw Error(`Failed to parse arguments for tool call '${r.id}' (${r.function.name}): ${s.message}`)}let a={id:r.id,name:r.function.name,arguments:i,parentMessageId:n.id};t.push(a)}}else if(n.role==="tool"){let o="unknown";for(let i of e)if(i.role==="assistant"&&i.toolCalls?.length){for(let a of i.toolCalls)if(a.id===n.toolCallId){o=a.function.name;break}}let r={id:n.id,result:dx(n.toolCallId,n.content),actionExecutionId:n.toolCallId,actionName:o};t.push(r)}return t}var PA=e=>e.kind==="tool"?e.fields.toolCallId:e.fields.messageId,MA=e=>e==="tool"?"toolCallId":"messageId",el=(e,t,n,o,r)=>{if(o!==void 0&&o!==r)throw Error(`Cannot continue ${e} '${t}': chunk ${n} '${o}' does not match the open stream's ${n} ${r===void 0?"(absent)":`'${r}'`}.`)},rl=(e,t)=>t.metadata===void 0?e:{...e,metadata:t.metadata},$f=(e,t)=>{let n=rl(e,t);return t.rawEvent===void 0?n:{...n,rawEvent:t.rawEvent}},Zf=e=>new Set(Object.keys(e.shape)),LA=Zf(af),zA=Zf(sf),DA=Zf(uf),Pf=(e,t)=>{let n;for(let o of Object.keys(e))t.has(o)||((n??={})[o]=e[o]);return n},UA=e=>{typeof process<"u"&&process.env!==void 0&&process.env.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`[ag-ui][transform] ${e} Set SUPPRESS_TRANSFORMATION_WARNINGS=true to silence.`)},Mf=(e,t,n,o)=>{if(t===void 0||n||e.length===0)return;let r=e[e.length-1],i=Object.keys(t).filter(a=>Object.prototype.hasOwnProperty.call(r,a));i.length>0&&UA(`A ${o} carried ${i.map(a=>`'${a}'`).join(", ")}, which the synthesized ${String(r.type)} already describes. The synthesized value is kept and the chunk's is dropped \u2014 this stage does not judge a described field, so the producer's value cannot be substituted for its own.`),e[e.length-1]={...t,...r}},ol=e=>t=>{let n=wn(e),o=new Map,r=u=>{let l=o.get(u);if(!l)return[];switch(o.delete(u),l.kind){case"text":{let d={type:x.TEXT_MESSAGE_END,messageId:l.fields.messageId,...l.fields.subagentRunId!==void 0&&{subagentRunId:l.fields.subagentRunId}};return n?.event("TRANSFORM","TEXT_MESSAGE_END",d,{messageId:d.messageId}),[d]}case"tool":{let d={type:x.TOOL_CALL_END,toolCallId:l.fields.toolCallId,...l.fields.subagentRunId!==void 0&&{subagentRunId:l.fields.subagentRunId}};return n?.event("TRANSFORM","TOOL_CALL_END",d,{toolCallId:d.toolCallId}),[d]}case"reasoning":{let d={type:x.REASONING_MESSAGE_END,messageId:l.fields.messageId,...l.fields.subagentRunId!==void 0&&{subagentRunId:l.fields.subagentRunId}};return n?.event("TRANSFORM","REASONING_MESSAGE_END",d,{messageId:d.messageId}),[d]}}},i=()=>[...o.keys()].flatMap(u=>r(u)),a=(u,l)=>{for(let[d,h]of o)if(h.kind===u&&PA(h)===l)return{owner:d}},s=(u,l,d,h,g)=>{if(l!==void 0){let p=a(u,l);if(p){if(d!==void 0&&d!==p.owner)throw Error(`Cannot continue ${g} '${l}': chunk subagentRunId '${d}' does not match the open stream's subagent '${p.owner??"(the parent agent)"}'.`);return p.owner}return d}if(d!==void 0)return d;if(o.get(void 0)?.kind===u)return;let f=[...o.entries()].filter(([,p])=>p.kind===u);if(f.length===1)return f[0][0];if(f.length>1)throw Error(`Ambiguous ${h}: it carries neither a ${MA(u)} nor a subagentRunId, but ${f.length} lanes have an open ${g}. Attribute the chunk to the subagent it belongs to.`)};return t.pipe(je(u=>{switch(u.type){case x.TEXT_MESSAGE_START:case x.TEXT_MESSAGE_CONTENT:case x.TEXT_MESSAGE_END:case x.TOOL_CALL_START:case x.TOOL_CALL_ARGS:case x.TOOL_CALL_END:case x.TOOL_CALL_RESULT:case x.STATE_SNAPSHOT:case x.STATE_DELTA:case x.CUSTOM:case x.STEP_STARTED:case x.STEP_FINISHED:case x.REASONING_START:case x.REASONING_MESSAGE_START:case x.REASONING_MESSAGE_CONTENT:case x.REASONING_MESSAGE_END:case x.REASONING_END:return[...r(u.subagentRunId??void 0),u];case x.RUN_STARTED:case x.RUN_FINISHED:case x.RUN_ERROR:case x.MESSAGES_SNAPSHOT:return[...i(),u];case x.RAW:case x.ACTIVITY_SNAPSHOT:case x.ACTIVITY_DELTA:case x.REASONING_ENCRYPTED_VALUE:case x.SUBAGENT_STARTED:return[u];case x.SUBAGENT_FINISHED:case x.SUBAGENT_ERROR:{let l=u.subagentRunId;return l==null?[u]:[...r(l),u]}case x.TEXT_MESSAGE_CHUNK:{let l=u,d=Pf(u,LA),h=s("text",l.messageId,l.subagentRunId??void 0,"TEXT_MESSAGE_CHUNK","text message"),g=o.get(h),f=[],p=!1,b;if(g?.kind==="text"&&(l.messageId===void 0||l.messageId===g.fields.messageId))el("text message",g.fields.messageId,"role",l.role,g.fields.role),el("text message",g.fields.messageId,"name",l.name,g.fields.name),b=g.fields;else{if(f.push(...r(h)),l.messageId===void 0)throw Error("First TEXT_MESSAGE_CHUNK must have a messageId");b={messageId:l.messageId,role:l.role===void 0?"assistant":l.role,name:l.name,subagentRunId:l.subagentRunId},o.set(h,{kind:"text",fields:b});let v=rl({type:x.TEXT_MESSAGE_START,messageId:l.messageId,role:b.role,...l.name!==void 0&&{name:l.name},...l.subagentRunId!==void 0&&{subagentRunId:l.subagentRunId}},l);f.push(v),n?.event("TRANSFORM","TEXT_MESSAGE_START",v,{messageId:l.messageId})}if(l.delta!==void 0||l.rawEvent!==void 0){let v=l.subagentRunId===void 0?b.subagentRunId:l.subagentRunId,_=$f({...d,type:x.TEXT_MESSAGE_CONTENT,messageId:b.messageId,delta:l.delta===void 0?"":l.delta,...v!==void 0&&{subagentRunId:v}},l);f.push(_),p=!0,n?.event("TRANSFORM","TEXT_MESSAGE_CONTENT",_,{messageId:b.messageId})}if(f.length===0&&(l.metadata!==void 0||l.rawEvent!==void 0||l.subagentRunId===null||d!==void 0)){let v=l.subagentRunId===void 0?b.subagentRunId:l.subagentRunId;f.push({...d,type:x.TEXT_MESSAGE_CONTENT,messageId:b.messageId,delta:"",...l.metadata!==void 0&&{metadata:l.metadata},...l.rawEvent!==void 0&&{rawEvent:l.rawEvent},...v!==void 0&&{subagentRunId:v}}),p=!0}return Mf(f,d,p,"TEXT_MESSAGE_CHUNK"),f}case x.TOOL_CALL_CHUNK:{let l=u,d=Pf(u,zA),h=s("tool",l.toolCallId,l.subagentRunId??void 0,"TOOL_CALL_CHUNK","tool call"),g=o.get(h),f=[],p=!1,b;if(g?.kind==="tool"&&(l.toolCallId===void 0||l.toolCallId===g.fields.toolCallId))el("tool call",g.fields.toolCallId,"toolCallName",l.toolCallName,g.fields.toolCallName),el("tool call",g.fields.toolCallId,"parentMessageId",l.parentMessageId,g.fields.parentMessageId),b=g.fields;else{if(f.push(...r(h)),l.toolCallId===void 0)throw Error("First TOOL_CALL_CHUNK must have a toolCallId");if(l.toolCallName===void 0)throw Error("First TOOL_CALL_CHUNK must have a toolCallName");b={toolCallId:l.toolCallId,toolCallName:l.toolCallName,parentMessageId:l.parentMessageId,subagentRunId:l.subagentRunId},o.set(h,{kind:"tool",fields:b});let v=rl({type:x.TOOL_CALL_START,toolCallId:l.toolCallId,toolCallName:l.toolCallName,...l.parentMessageId!==void 0&&{parentMessageId:l.parentMessageId},...l.subagentRunId!==void 0&&{subagentRunId:l.subagentRunId}},l);f.push(v),n?.event("TRANSFORM","TOOL_CALL_START",v,{toolCallId:l.toolCallId,toolCallName:l.toolCallName})}if(l.delta!==void 0||l.rawEvent!==void 0){let v=l.subagentRunId===void 0?b.subagentRunId:l.subagentRunId,_=$f({...d,type:x.TOOL_CALL_ARGS,toolCallId:b.toolCallId,delta:l.delta===void 0?"":l.delta,...v!==void 0&&{subagentRunId:v}},l);f.push(_),p=!0,n?.event("TRANSFORM","TOOL_CALL_ARGS",_,{toolCallId:b.toolCallId})}if(f.length===0&&(l.metadata!==void 0||l.rawEvent!==void 0||l.subagentRunId===null||d!==void 0)){let v=l.subagentRunId===void 0?b.subagentRunId:l.subagentRunId;f.push({...d,type:x.TOOL_CALL_ARGS,toolCallId:b.toolCallId,delta:"",...l.metadata!==void 0&&{metadata:l.metadata},...l.rawEvent!==void 0&&{rawEvent:l.rawEvent},...v!==void 0&&{subagentRunId:v}}),p=!0}return Mf(f,d,p,"TOOL_CALL_CHUNK"),f}case x.REASONING_MESSAGE_CHUNK:{let l=u,d=Pf(u,DA),h=s("reasoning",l.messageId,l.subagentRunId??void 0,"REASONING_MESSAGE_CHUNK","reasoning message"),g=o.get(h),f=[],p=!1,b;if(g?.kind==="reasoning"&&(l.messageId===void 0||l.messageId===g.fields.messageId))b=g.fields;else{if(f.push(...r(h)),l.messageId===void 0)throw Error("First REASONING_MESSAGE_CHUNK must have a messageId");b={messageId:l.messageId,subagentRunId:l.subagentRunId},o.set(h,{kind:"reasoning",fields:b});let v=rl({type:x.REASONING_MESSAGE_START,messageId:l.messageId,role:"reasoning",...l.subagentRunId!==void 0&&{subagentRunId:l.subagentRunId}},l);f.push(v),n?.event("TRANSFORM","REASONING_MESSAGE_START",v,{messageId:l.messageId})}if(l.delta!==void 0||l.rawEvent!==void 0){let v=l.subagentRunId===void 0?b.subagentRunId:l.subagentRunId,_=$f({...d,type:x.REASONING_MESSAGE_CONTENT,messageId:b.messageId,delta:l.delta===void 0?"":l.delta,...v!==void 0&&{subagentRunId:v}},l);f.push(_),p=!0,n?.event("TRANSFORM","REASONING_MESSAGE_CONTENT",_,{messageId:b.messageId})}if(f.length===0&&(l.metadata!==void 0||l.rawEvent!==void 0||l.subagentRunId===null||d!==void 0)){let v=l.subagentRunId===void 0?b.subagentRunId:l.subagentRunId;f.push({...d,type:x.REASONING_MESSAGE_CONTENT,messageId:b.messageId,delta:"",...l.metadata!==void 0&&{metadata:l.metadata},...l.rawEvent!==void 0&&{rawEvent:l.rawEvent},...v!==void 0&&{subagentRunId:v}}),p=!0}return Mf(f,d,p,"REASONING_MESSAGE_CHUNK"),f}}return u.type,[u]}),nn(()=>{i()}))},cr=Symbol("agui.strip.drop");function ko(e){let t=e;for(;;){if(t instanceof c.ZodOptional||t instanceof c.ZodNullable||t instanceof c.ZodDefault||t instanceof c.ZodReadonly||t instanceof c.ZodCatch){t=t.unwrap();continue}if(t instanceof c.ZodPipe){t=t.def.in;continue}if(t instanceof c.ZodLazy){t=t.def.getter();continue}return t}}function jA(e){let t=e.def;return typeof t?.discriminator=="string"?t.discriminator:void 0}function px(e){let t=e,n=Array.isArray(t.def?.values)?t.def.values:t.values?Array.from(t.values):void 0;return n&&n.length===1?n[0]:t.value}function HA(e){let t=ko(e);return t instanceof c.ZodLiteral?px(t):void 0}function dr(e,t,n,o){let r=ko(t);if(r instanceof c.ZodObject){if(typeof e!="object"||!e||Array.isArray(e))return e;let i=r.shape,a=e,s={},u=r.meta()?.specOpen===!0;for(let l of Object.keys(a)){let d=Object.prototype.hasOwnProperty.call(i,l)?i[l]:void 0;if(d===void 0){if(u){s[l]=a[l];continue}o.push(`${n}/${l}`);continue}let h=o.length,g=dr(a[l],d,`${n}/${l}`,o);if(g===cr){if(o.length=h,d.safeParse(void 0).success){o.push(`${n}/${l}`);continue}return cr}s[l]=g}return s}if(r instanceof c.ZodArray){if(!Array.isArray(e))return e;let i=r.element,a=[];return e.forEach((s,u)=>{let l=o.length,d=dr(s,i,`${n}/${u}`,o);if(d===cr){o.length=l,o.push(`${n}/${u}`);return}a.push(d)}),a}if(r instanceof c.ZodRecord){if(typeof e!="object"||!e||Array.isArray(e))return e;let i=r.def.valueType,a=e,s={};for(let u of Object.keys(a)){let l=o.length,d=dr(a[u],i,`${n}/${u}`,o);if(d===cr){o.length=l,o.push(`${n}/${u}`);continue}s[u]=d}return s}if(r instanceof c.ZodUnion){let i=r.options,a=jA(r);if(a!==void 0){if(typeof e!="object"||!e||Array.isArray(e))return e;let l=e[a];for(let d of i){let h=ko(d);if(!(h instanceof c.ZodObject))continue;let g=h.shape;if(HA(g[a])===l)return dr(e,d,n,o)}return cr}let s=i.filter(l=>ko(l)instanceof c.ZodObject),u=typeof e=="object"&&!!e&&!Array.isArray(e);if(s.length>1&&u)return e;for(let l of i){let d=ko(l);if(d instanceof c.ZodArray&&Array.isArray(e)||d instanceof c.ZodObject&&u)return dr(e,l,n,o)}return e}return e}function hx(e,t){let n=[],o=dr(e,t,"",n);if(o===cr)throw Error("Internal error: the stripper found the whole value unrecognisable, which the schemas are not supposed to allow \u2014 schema/stripper mismatch.");return{value:o,stripped:n}}var GA=new Set(Object.values(x));function FA(e){return GA.has(e.type)}var VA=new Map(cf.options.map(e=>{let t=e.shape;return[String(px(t.type)),e]})),ZA=()=>typeof process<"u"&&process.env!==void 0&&!!process.env.SUPPRESS_TRANSFORMATION_WARNINGS;function Ff(e){ZA()||console.warn(`[ag-ui][enforce] ${e}`)}var Lf=e=>t=>{let n=wn(e);return t.pipe(je(o=>{if(!FA(o))return Ff(`Dropping unrecognised event '${String(o.type)}': no middleware translated it and the protocol does not describe it.`),n?.event("ENFORCE","Unrecognised event dropped:",o,{type:o.type}),Lr;let r=VA.get(o.type);if(r===void 0)throw Error(`No validator for recognised event type '${String(o.type)}'`);let{value:i,stripped:a}=hx(o,r);for(let s of a)Ff(`Removed unrecognised material at '${s}' on ${String(o.type)}. Nothing handled it; see the repo-root DEPRECATIONS.md if it is a retired shape.`);return ie(r.parse(i))}))};function BA(e){let{value:t,stripped:n}=hx(Qu(e,"RunAgentInput"),is);for(let o of n)Ff(`Removed unrecognised material at '${o}' from the outgoing input.`);return is.parse(t)}var Io=class{runNext(e,t){return t.run(e).pipe(ol(!1))}runNextWithState(e,t){let n=Q(e.messages||[]),o=Q(e.state===void 0?{}:e.state),r=new ji;return cx(e,r,t,[]).subscribe({next:i=>{i.messages!==void 0&&(n=i.messages),i.state!==void 0&&(o=i.state)},error:()=>{}}),this.runNext(e,t).pipe(ea(async i=>(r.next(i),await new Promise(a=>setTimeout(a,0)),{event:i,messages:Q(n),state:Q(o)})))}},WA=class extends Io{constructor(e){super(),this.fn=e}run(e,t){return this.fn(e,t)}};function qA(e){return e.startsWith("image/")?"image":e.startsWith("audio/")?"audio":e.startsWith("video/")?"video":"document"}function XA(e){return typeof e=="object"&&!!e&&"type"in e&&e.type==="binary"&&"mimeType"in e&&typeof e.mimeType=="string"}function KA(e){let t=qA(e.mimeType);return e.data?{type:t,source:{type:"data",value:e.data,mimeType:e.mimeType},...e.filename?{metadata:{filename:e.filename}}:{}}:e.url?{type:t,source:{type:"url",value:e.url,mimeType:e.mimeType},...e.filename?{metadata:{filename:e.filename}}:{}}:((typeof process>"u"||process.env===void 0||!process.env.SUPPRESS_TRANSFORMATION_WARNINGS)&&console.warn(`[ag-ui][compat] A binary content part carries only an id ('${e.id??""}') and cannot be converted to a modern media part; a 1.0 peer will not accept it. Provide data or a url. See the repo-root DEPRECATIONS.md.`),e)}function YA(e,t,n){if(typeof e!="object"||!e||!("type"in e)||e.type!==t.type||!("source"in e))return!1;let o=e.source;return typeof o!="object"||!o||!("type"in o)||o.type!==t.source.type||!("value"in o)||o.value!==t.source.value||!("mimeType"in o)||o.mimeType!==t.source.mimeType?!1:!n||"metadata"in e&&typeof e.metadata=="object"&&e.metadata!==null&&"filename"in e.metadata&&e.metadata.filename===n}function Yw(e){let t=e.content;if(!Array.isArray(t))return e;let n=t.flatMap(o=>{if(XA(o)){let r=KA(o);return r.type!=="binary"&&t.some(i=>YA(i,r,o.filename))?[]:[r]}return[o]});return{...e,content:n}}var zf="THINKING_START",Df="THINKING_END",Jw="THINKING_TEXT_MESSAGE_START",Uf="THINKING_TEXT_MESSAGE_CONTENT",jf="THINKING_TEXT_MESSAGE_END";function fx(e,t){typeof process<"u"&&process.env!==void 0&&process.env.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`[ag-ui][compat] Converting deprecated ${e} to ${t}. The old shape leaves the protocol after its shim window \u2014 see the repo-root DEPRECATIONS.md. Set SUPPRESS_TRANSFORMATION_WARNINGS=true to silence.`)}function Bf(e){return typeof e=="object"&&!!e&&!Array.isArray(e)}function il(e,t,n){if(!Bf(e)||e[t]!==null)return e;fx(`${n}.${t}: null`,"an absent field");let{[t]:o,...r}=e;return r}function al(e,t,n){if(!Bf(e)||!Array.isArray(e[t]))return e;let o=e[t],r=o.map(n);return r.some((i,a)=>i!==o[a])?{...e,[t]:r}:e}function mx(e){return al(e,"content",t=>{if(!Bf(t))return t;switch(t.type){case"image":case"audio":case"video":case"document":return il(t,"metadata",`${t.type} input content`);default:return t}})}function JA(e){let t=il(e,"forwardedProps","RunAgentInput");return t=al(t,"tools",n=>il(n,"parameters","Tool")),t=al(t,"resume",n=>il(n,"payload","ResumeEntry")),al(t,"messages",mx)}var Vf=class extends Io{constructor(...e){super(...e),this.currentReasoningId=null,this.currentMessageId=null}warn(e,t){fx(e,t)}mintedContinuationId(e,t){if(t!==null)return t;let n=ve();return this.warnAside(`Minting a messageId ('${n}') for ${e}: no THINKING opener preceded it, so there was no id to continue. The id is this client's invention, not the producer's, and verification will reject the translated event for naming something nothing opened.`),n}warnAside(e){typeof process<"u"&&process.env!==void 0&&process.env.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`[ag-ui][compat] ${e} Set SUPPRESS_TRANSFORMATION_WARNINGS=true to silence.`)}run(e,t){return this.currentReasoningId=null,this.currentMessageId=null,e.messages=e.messages.map(Yw),t.run(e).pipe(bt(n=>this.transformEvent(n)))}transformEvent(e){if(e.rawEvent===null){this.warn(`${e.type}.rawEvent: null`,"an absent field");let{rawEvent:t,...n}=e;e=n}if((e.type===x.RUN_FINISHED||e.type===x.SUBAGENT_FINISHED)&&e.result===null){this.warn(`${e.type}.result: null`,"an absent field");let{result:t,...n}=e;e=n}switch(e.type){case zf:{this.currentReasoningId=ve();let{title:t,...n}=e;return this.warn(zf,x.REASONING_START),t!==void 0&&this.warnAside(`Dropping ${zf}.title ${JSON.stringify(t)}: ${x.REASONING_START} has no title field, so the span's label cannot be carried and nothing downstream can recover it.`),{...n,type:x.REASONING_START,messageId:this.currentReasoningId}}case Jw:return this.currentMessageId=ve(),this.warn(Jw,x.REASONING_MESSAGE_START),{...e,type:x.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:"reasoning"};case Uf:{let{delta:t,...n}=e;return this.warn(Uf,x.REASONING_MESSAGE_CONTENT),{...n,type:x.REASONING_MESSAGE_CONTENT,messageId:this.mintedContinuationId(Uf,this.currentMessageId),delta:t}}case jf:{let t=this.mintedContinuationId(jf,this.currentMessageId);return this.currentMessageId=null,this.warn(jf,x.REASONING_MESSAGE_END),{...e,type:x.REASONING_MESSAGE_END,messageId:t}}case Df:{let t=this.mintedContinuationId(Df,this.currentReasoningId);return this.currentReasoningId=null,this.warn(Df,x.REASONING_END),{...e,type:x.REASONING_END,messageId:t}}case x.TOOL_CALL_START:case x.TOOL_CALL_CHUNK:{let t=e;if(t.parentMessageId===null){this.warn(`${e.type}.parentMessageId: null`,"an absent field");let{parentMessageId:n,...o}=t;return o}return e}case x.RUN_FINISHED:{let t=e;if(t.outcome===null){this.warn("RUN_FINISHED.outcome: null","an absent field");let{outcome:n,...o}=t;return o}return e}case x.MESSAGES_SNAPSHOT:{let t=e;return Array.isArray(t.messages)?{...t,messages:t.messages.map(n=>this.upgradeInboundMessage(n))}:e}case x.RUN_STARTED:{let t=JA(e.input),n=t===e.input?e:{...e,input:t},o=n;return!o.input||!Array.isArray(o.input.messages)?n:{...o,input:{...o.input,messages:o.input.messages.map(r=>this.upgradeInboundMessage(r))}}}default:return e}}upgradeInboundMessage(e){e=mx(e);let t=e.content;return!Array.isArray(t)||!t.some(n=>typeof n=="object"&&!!n&&n.type==="binary")?e:(this.warn("binary input content","the modern media content parts"),Yw(e))}},QA=()=>e=>zr(()=>{let t=new Vf;return e.pipe(bt(n=>t.transformEvent(n)))});function eR(e,t=new Date){return e.expiresAt===void 0?!1:new Date(e.expiresAt)<=t}function gx(e,t){let n=new Set(e.map(a=>a.id)),o=new Set(Object.keys(t)),r=[...n].filter(a=>!o.has(a));if(r.length>0)throw Error(`buildResumeArray: missing responses for open interrupts: ${r.join(", ")}`);let i=[...o].filter(a=>!n.has(a));if(i.length>0)throw Error(`buildResumeArray: responses reference unknown interrupt ids: ${i.join(", ")}`);return e.map(a=>{let s=t[a.id],u={interruptId:a.id,status:s.status};return s.status==="resolved"&&s.payload!==void 0&&(u.payload=s.payload),s.metadata!==void 0&&(u.metadata=s.metadata),u})}function vx(){return typeof process<"u"&&process.env!==void 0&&!!process.env.SUPPRESS_TRANSFORMATION_WARNINGS}function tR(e){vx()||console.warn(`[ag-ui][compat] Flattening message content for a <=0.0.39 peer DROPS non-text parts (${e.join(", ")}). The peer cannot receive them; upgrade it to keep media content. See the repo-root DEPRECATIONS.md.`)}function nR(e){vx()||console.warn(`[ag-ui][compat] Not flattening message content for a <=0.0.39 peer: ${e} content part(s) claim type "text" but carry a malformed 'text' value. That is a defect in the message, not media the peer cannot represent, and a downgrade must not repair it \u2014 the content is passed on unchanged so the outgoing enforcement boundary reports it. See the repo-root DEPRECATIONS.md.`)}function rR(e){let t=e.content;if(Array.isArray(t)){let n=s=>typeof s=="object"&&!!s&&"type"in s&&s.type==="text",o=s=>n(s)&&typeof s.text=="string",r=t.filter(s=>n(s)&&!o(s));if(r.length>0)return nR(r.length),e;let i=t.filter(s=>!o(s)).map(s=>typeof s=="object"&&s&&"type"in s?String(s.type):typeof s);i.length>0&&tR(i);let a=t.filter(o).map(s=>s.text).join("");return{...e,content:a}}return typeof t=="string"?e:t===void 0?{...e,content:""}:e}var oR=class extends Io{run(e,t){let{parentRunId:n,...o}=e,r={...o,messages:o.messages.map(rR)};return this.runNext(r,t)}},Qw="THINKING_START",ex="THINKING_END",tx="THINKING_TEXT_MESSAGE_START",nx="THINKING_TEXT_MESSAGE_CONTENT",rx="THINKING_TEXT_MESSAGE_END",iR=class extends Io{constructor(...e){super(...e),this.currentReasoningId=null,this.currentMessageId=null}warnAboutTransformation(e,t){typeof process<"u"&&process.env!==void 0&&process.env.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`AG-UI is converting ${e} to ${t}. To remove this warning, upgrade your AG-UI integration package (e.g. @ag-ui/langgraph). To surpress it, set SUPPRESS_TRANSFORMATION_WARNINGS=true in your .env file.`)}run(e,t){return this.currentReasoningId=null,this.currentMessageId=null,this.runNext(e,t).pipe(bt(n=>this.transformEvent(n)))}transformEvent(e){switch(e.type){case Qw:{this.currentReasoningId=ve();let{title:t,...n}=e;return this.warnAboutTransformation(Qw,x.REASONING_START),{...n,type:x.REASONING_START,messageId:this.currentReasoningId}}case tx:return this.currentMessageId=ve(),this.warnAboutTransformation(tx,x.REASONING_MESSAGE_START),{...e,type:x.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:"reasoning"};case nx:{let{delta:t,...n}=e;return this.warnAboutTransformation(nx,x.REASONING_MESSAGE_CONTENT),{...n,type:x.REASONING_MESSAGE_CONTENT,messageId:this.currentMessageId??ve(),delta:t}}case rx:{let t=this.currentMessageId??ve();return this.warnAboutTransformation(rx,x.REASONING_MESSAGE_END),{...e,type:x.REASONING_MESSAGE_END,messageId:t}}case ex:{let t=this.currentReasoningId??ve();return this.warnAboutTransformation(ex,x.REASONING_END),{...e,type:x.REASONING_END,messageId:t}}default:return e}}},ox="SUBAGENT_STARTED",ix="SUBAGENT_FINISHED",ax="SUBAGENT_ERROR";function sl(e){if(e&&typeof e=="object"&&"subagentRunId"in e){let{subagentRunId:t,...n}=e;return n}return e}function sx(e){return e.map(t=>sl(t))}var aR=class extends Io{warnDroppedLifecycleEvent(e){typeof process<"u"&&process.env!==void 0&&process.env.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`AG-UI is dropping ${e} because the target agent predates subagent support. To remove this warning, upgrade your AG-UI integration package. To suppress it, set SUPPRESS_TRANSFORMATION_WARNINGS=true in your .env file.`)}run(e,t){let n={...e,messages:(e.messages??[]).map(o=>sl(o))};return this.runNext(n,t).pipe(na(o=>{let r=o.type;(r===ox||r===ix||r===ax)&&this.warnDroppedLifecycleEvent(r)}),fc(o=>{let r=o.type;return r!==ox&&r!==ix&&r!==ax}),bt(o=>{let r=sl(o);if(r.type===x.MESSAGES_SNAPSHOT){let i=r;if(Array.isArray(i.messages))return{...i,messages:sx(i.messages)}}if(r.type===x.RUN_FINISHED){let i=r;if(i.outcome&&Array.isArray(i.outcome.interrupts))return{...i,outcome:{...i.outcome,interrupts:i.outcome.interrupts.map(a=>sl(a))}}}if(r.type===x.RUN_STARTED){let i=r;if(i.input&&Array.isArray(i.input.messages))return{...i,input:{...i.input,messages:sx(i.input.messages)}}}return r}))}},tl="1.0.0",lx=!1,sR=(e,t)=>/^\d+\.\d+$/.test(e)?bn(e,t)>0?"newer":"not-newer":"uninterpretable",ux=e=>{let t=e.protocolVersion;if(!(t===void 0||t===Yt))switch(sR(t,Yt)){case"uninterpretable":console.warn(`[ag-ui] The producer declared protocol version '${t}', which this client cannot interpret.`);return;case"newer":console.warn(`[ag-ui] The producer speaks protocol ${t}; this client speaks ${Yt}. Unrecognised material will be stripped with warnings.`);return;case"not-newer":return}},lR=class bx{resolvePeerCeiling(t){if(this.resolvingPeerCeiling)return tl;let n=Object.getOwnPropertyDescriptor(this,"maxVersion"),o=Object.getOwnPropertyDescriptor(this,"maxProtocolVersion"),r=Object.getPrototypeOf(this);for(;r&&r!==bx.prototype;)n??=Object.getOwnPropertyDescriptor(r,"maxVersion"),o??=Object.getOwnPropertyDescriptor(r,"maxProtocolVersion"),r=Object.getPrototypeOf(r);if(t==="maxVersion"&&n)return tl;let i=t==="maxProtocolVersion"?n:o;if(!i)return tl;this.resolvingPeerCeiling=!0;try{return i.get?i.get.call(this):i.value}finally{this.resolvingPeerCeiling=!1}}get maxProtocolVersion(){return this.resolvePeerCeiling("maxProtocolVersion")}get maxVersion(){return!this.resolvingPeerCeiling&&!lx&&(lx=!0,console.warn("[ag-ui] AbstractAgent.maxVersion is deprecated \u2014 use maxProtocolVersion. Same value; the new name says whose version it is and that it is a ceiling.")),this.resolvePeerCeiling("maxVersion")}get debug(){return this._debug}set debug(t){this._debug=nl(t),this._debugLogger=Nf(this._debug)}get debugLogger(){return this._debugLogger}set debugLogger(t){typeof t=="boolean"?this._debugLogger=t?Nf(nl(!0)):void 0:this._debugLogger=t}resolvedCeilingDuringConstruction(){let t=this.maxProtocolVersion;if(typeof t!="string"||!Cf(t))throw new W(`maxProtocolVersion resolved to ${JSON.stringify(t)} during construction, which is not a version this client can compare. A ceiling read from an instance field is not available yet \u2014 return a literal from the getter.`);return t}constructor({agentId:t,description:n,threadId:o,initialMessages:r,initialState:i,debug:a}={}){this.subscribers=[],this.isRunning=!1,this.pendingInterrupts=[],this.middlewares=[],this.resolvingPeerCeiling=!1,this.agentId=t,this.description=n??"",this.threadId=o??Mt(),this.messages=Q(r??[]),this.state=Q(i??{}),this._debug=nl(a),this._debugLogger=Nf(this._debug);let s=this.resolvedCeilingDuringConstruction();bn(s,"0.0.39")<=0&&this.middlewares.unshift(new oR),bn(s,"0.0.45")<=0&&this.middlewares.unshift(new iR),bn(s,"0.0.57")<=0&&this.middlewares.unshift(new aR)}subscribe(t){return this.subscribers.push(t),{unsubscribe:()=>{this.subscribers=this.subscribers.filter(n=>n!==t)}}}use(...t){let n=t.map(o=>typeof o=="function"?new WA(o):o);return this.middlewares.push(...n),this}async runAgent(t,n){try{this.isRunning=!0,this.agentId=this.agentId??Mt();let o=this.prepareRunAgentInput(t);this.debugLogger?.lifecycle("LIFECYCLE","Run started:",{agentId:this.agentId,threadId:this.threadId});let r,i=new Set(this.messages.map(l=>l.id)),a=[{onRunStartedEvent:({event:l})=>ux(l),onRunFinishedEvent:l=>{l.outcome==="success"&&(r=l.result)}},...this.subscribers,n??{}];await this.onInitialize(o,a),this.activeRunDetach$=new vt;let s;this.activeRunCompletionPromise=new Promise(l=>{s=l}),await Qi(Ui(()=>[...this.middlewares,new Vf].reduceRight((l,d)=>({run:h=>d.run(h,l),get messages(){return l.messages},get state(){return l.state}}),this).run(o),Lf(this.debugLogger),ol(this.debugLogger),Of(this.debugLogger),l=>l.pipe(ta(this.activeRunDetach$)),l=>this.apply(o,l,a),l=>this.processApplyEvents(o,l,a),Dr(l=>(this.debugLogger?.lifecycle("LIFECYCLE","Run errored:",{agentId:this.agentId,error:l instanceof Error?l.message:String(l)}),this.isRunning=!1,this.onError(o,l,a))),nn(()=>{this.debugLogger?.lifecycle("LIFECYCLE","Run finished:",{agentId:this.agentId,threadId:this.threadId}),this.isRunning=!1,this.onFinalize(o,a),s?.(),s=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(ie(null)));let u=Q(this.messages).filter(l=>!i.has(l.id));return{result:r,newMessages:u}}finally{this.isRunning=!1}}connect(t){throw new ec}async connectAgent(t,n){try{this.isRunning=!0,this.agentId=this.agentId??Mt();let o=this.prepareRunAgentInput(t),r,i=new Set(this.messages.map(l=>l.id)),a=[{onRunStartedEvent:({event:l})=>ux(l),onRunFinishedEvent:l=>{l.outcome==="success"&&(r=l.result)}},...this.subscribers,n??{}];await this.onInitialize(o,a),this.activeRunDetach$=new vt;let s;this.activeRunCompletionPromise=new Promise(l=>{s=l}),await Qi(Ui(()=>zr(()=>this.connect(o)),l=>Lf(this.debugLogger)(QA()(l)),ol(this.debugLogger),Of(this.debugLogger),l=>l.pipe(ta(this.activeRunDetach$)),l=>this.apply(o,l,a),l=>this.processApplyEvents(o,l,a),Dr(l=>(this.isRunning=!1,l instanceof ec?Lr:this.onError(o,l,a))),nn(()=>{this.isRunning=!1,this.onFinalize(o,a),s?.(),s=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(ie(null)),{defaultValue:void 0});let u=Q(this.messages).filter(l=>!i.has(l.id));return{result:r,newMessages:u}}finally{this.isRunning=!1}}abortRun(){}async detachActiveRun(){if(!this.activeRunDetach$)return;let t=this.activeRunCompletionPromise??Promise.resolve();this.activeRunDetach$.next(),this.activeRunDetach$?.complete(),await t}apply(t,n,o){return cx(t,n,this,o,this.debugLogger)}processApplyEvents(t,n,o){return n.pipe(na(r=>{r.messages&&(this.messages=r.messages,o.forEach(i=>{i.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:t})})),r.state!==void 0&&(this.state=r.state,o.forEach(i=>{i.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:t})}))}))}prepareRunAgentInput(t){let n=Q(this.messages);for(let r of n)r.subagentRunId===null&&delete r.subagentRunId;let o=n.filter(r=>r.role!=="activity");return{threadId:this.threadId,runId:t?.runId||Mt(),...bn(this.maxProtocolVersion,tl)>=0&&{protocolVersion:Yt},tools:Q(t?.tools??[]),context:Q(t?.context??[]),forwardedProps:Q(t?.forwardedProps??{}),state:Q(this.state),messages:o,...t?.resume===void 0?{}:{resume:Q(t.resume)}}}async onInitialize(t,n){if(this.pendingInterrupts.length>0){let r=new Set((t.resume??[]).map(a=>a.interruptId)),i=this.pendingInterrupts.map(a=>a.id).filter(a=>!r.has(a));if(i.length>0)throw new W(`Thread has ${i.length} pending interrupt(s) not addressed by resume: ${i.join(", ")}`);for(let a of this.pendingInterrupts)if(eR(a)&&(t.resume??[]).find(s=>s.interruptId===a.id)?.status!=="cancelled")throw new W(`Interrupt ${a.id} expired at ${a.expiresAt} and can no longer be answered. Cancel it to continue the thread.`)}let o=await re(n,this.messages,this.state,(r,i,a)=>r.onRunInitialized?.({messages:i,state:a,agent:this,input:t}));if(o.messages!==void 0||o.state!==void 0){if(o.messages){this.messages=o.messages;for(let r of o.messages)r.subagentRunId===null&&delete r.subagentRunId;t.messages=o.messages.filter(r=>r.role!=="activity"),n.forEach(r=>{r.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:t})})}o.state!==void 0&&(this.state=o.state,t.state=o.state,n.forEach(r=>{r.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:t})}))}}onError(t,n,o){return tn(re(o,this.messages,this.state,(r,i,a)=>r.onRunFailed?.({error:n,messages:i,state:a,agent:this,input:t}))).pipe(bt(r=>{let i=r;if((i.messages!==void 0||i.state!==void 0)&&(i.messages!==void 0&&(this.messages=i.messages,o.forEach(a=>{a.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:t})})),i.state!==void 0&&(this.state=i.state,o.forEach(a=>{a.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:t})}))),i.stopPropagation!==!0){let a=String(n);if(!(n.name==="AbortError"||n.message==="Fetch is aborted"||n.message==="signal is aborted without reason"||n.message==="component unmounted"||a==="component unmounted"))throw console.error("Agent execution failed:",n),n}return{}}))}async onFinalize(t,n){let o=await re(n,this.messages,this.state,(r,i,a)=>r.onRunFinalized?.({messages:i,state:a,agent:this,input:t}));(o.messages!==void 0||o.state!==void 0)&&(o.messages!==void 0&&(this.messages=o.messages,n.forEach(r=>{r.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:t})})),o.state!==void 0&&(this.state=o.state,n.forEach(r=>{r.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:t})})))}clone(){let t=Object.create(Object.getPrototypeOf(this));return t.agentId=this.agentId,t.description=this.description,t.threadId=this.threadId,t.messages=Q(this.messages),t.state=Q(this.state),t._debug=this._debug,t._debugLogger=this._debugLogger,t.isRunning=this.isRunning,t.subscribers=[...this.subscribers],t.middlewares=[...this.middlewares],t.pendingInterrupts=Q(this.pendingInterrupts),t}addMessage(t){this.messages.push(t),(async()=>{for(let n of this.subscribers)await n.onNewMessage?.({message:t,messages:this.messages,state:this.state,agent:this});if(t.role==="assistant"&&t.toolCalls)for(let n of t.toolCalls)for(let o of this.subscribers)await o.onNewToolCall?.({toolCall:n,messages:this.messages,state:this.state,agent:this});for(let n of this.subscribers)await n.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}addMessages(t){this.messages.push(...t),(async()=>{for(let n of t){for(let o of this.subscribers)await o.onNewMessage?.({message:n,messages:this.messages,state:this.state,agent:this});if(n.role==="assistant"&&n.toolCalls)for(let o of n.toolCalls)for(let r of this.subscribers)await r.onNewToolCall?.({toolCall:o,messages:this.messages,state:this.state,agent:this})}for(let n of this.subscribers)await n.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setMessages(t){this.messages=Q(t),(async()=>{for(let n of this.subscribers)await n.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setState(t){this.state=Q(t),(async()=>{for(let n of this.subscribers)await n.onStateChanged?.({messages:this.messages,state:this.state,agent:this})})()}legacy_to_be_removed_runAgentBridged(t){this.agentId=this.agentId??Mt();let n=this.prepareRunAgentInput(t);return[...this.middlewares,new Vf].reduceRight((o,r)=>({run:i=>r.run(i,o),get messages(){return o.messages},get state(){return o.state}}),this).run(n).pipe(Lf(this.debugLogger),ol(this.debugLogger),Of(this.debugLogger),OA(this.threadId,n.runId,this.agentId),o=>o.pipe(bt(r=>(this.debugLogger?.event("LEGACY","Event:",r,{type:r.type}),r))))}};function uR(e){if(!Array.isArray(e.messages))return e;let t=!1,n=e.messages.map(o=>{if(o.subagentRunId===null){t=!0;let r={...o};return delete r.subagentRunId,r}return o});return t?{...e,messages:n}:e}var yx=class extends lR{requestInit(e){return{method:"POST",headers:{...this.headers,"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(uR(e)),signal:this.abortController.signal}}runAgent(e,t){return this.abortController=e?.abortController??new AbortController,super.runAgent(e,t)}abortRun(){this.abortController.abort(),super.abortRun()}constructor(e){super(e),this.abortController=new AbortController,this.url=e.url,this.headers=Q(e.headers??{}),this.fetch=e.fetch??((t,n)=>fetch(t,n))}run(e){return CA(kA(()=>this.fetch(this.url,this.requestInit(BA(e)))),this.debugLogger)}clone(){let e=super.clone();e.url=this.url,e.headers=Q(this.headers??{}),e.fetch=this.fetch;let t=new AbortController,n=this.abortController.signal;return n.aborted&&t.abort(n.reason),e.abortController=t,e}};function ot(e,t){return t===void 0?e:{...e,credentials:t}}function ll(e){if(e.newThread!==void 0)return e.newThread();let t=ve();return e.setActiveThread(t),t}function ul(e,t,n,o){if(t.length===0)return;let r=new URL(String(e),location.href).origin;r===location.origin||n.includes(r)||o.has(r)||(o.add(r),console.warn(`<ag-ui-chat>: sending host credentials (${t.join(", ")}) to ${r}, which is not this page's origin (${location.origin}). Those headers are the page's own authentication, and whichever server answers the browser's preflight receives them \u2014 so a URL attribute built from a query parameter or from tenant-authored configuration is a channel for the token to leave on. If this destination is deliberate, name it in \`trustedOrigins\` to confirm it and silence this notice. Reported once per origin.`))}function pr(e){return e.split(",").map(t=>t.trim()).filter(t=>t!=="")}function cl(e,t,n=new Set){let o=new Set(n);for(let s of e)s.role==="tool"&&o.add(s.toolCallId);let r=[],i=[],a=!1;for(let s of e){let u=s.role==="assistant"?cR(s.toolCalls):[];s.role==="tool"||u.length>0&&!a||(r.push(...i.map(t)),i=[]),r.push(s),a=s.role==="tool";for(let d of u)o.has(d)||(o.add(d),i.push(d))}return r.length+i.length===e.length?e:(r.push(...i.map(t)),r)}function cR(e){return Array.isArray(e)?e.map(t=>Object(t).id).filter(t=>typeof t=="string"):[]}function dl(e,t){return Object(e.metadata)[t]??e[t]}var pe={title:"Assistant",chatHistory:"Chat history",closeHistory:"Close history",searchConversations:"Search conversations",queued:"Waiting to send",removeQueued:'Do not send "{text}"',noMatches:"No conversations match that.",chatMoved:"Moved this panel out of the way",chatMinimised:"Minimised this panel",undo:"Undo",newChat:"New chat",collapse:"Collapse",expand:"Expand",expandUnread:"Expand \u2014 {count} unread",toggleTheme:"Toggle theme",copyCode:"Copy",copied:"Copied",copyFailed:"Copy failed",checkpoints:"Continue a run",noCheckpoints:"Nothing to continue yet.",resumeRun:"Resume",forkRun:"Fork",forkedRun:"branched",greeting:"Hello, {name}",greetingNoName:"Hello there",conversation:"Conversation",jumpToLatest:"Jump to latest",announceResponding:"Assistant is responding",announceAnswerReady:"Assistant answered",announceAwaitingDecision:"{count} action is waiting for your approval",announceStopped:"Response stopped",announceFailed:"The response failed",thinking:"Assistant is thinking\u2026",thoughts:"Thoughts",stopped:"\u23F9 Stopped",connectionLost:"Connection lost",noResult:"No result returned.",callNotFinished:"Not finished: the run ended or moved on before this tool call returned a result.",declinedAction:"User declined the action.",confirmCheckFailed:"Not run: the check that decides whether this action needs the user's confirmation failed.",navigating:"Navigating\u2026",historyReplaced:"The server replaced this conversation's history. Reload to see the updated transcript.",chartUndrawable:"A chart could not be drawn from the data sent, so it was removed.",historyCompacted:"Earlier turns condensed to fit the context window ({count} removed)",usingSkill:"Using skill {name}",runInterrupted:"The previous response didn\u2019t finish \u2014 the page changed before it arrived.",pageMoved:"The page changed since you last looked at it. Call read_page to see the current page, then retry.",attachmentsStillUploading:"{n} file still uploading \u2014 it was not sent with this message and is still attached.",notConnected:"This chat isn\u2019t connected to an agent, so the message wasn\u2019t sent.",continueNeedsTurn:"Type the next turn in the composer first, then pick a run to continue.",continueWhileRunning:"Wait for the current answer or stop it, then pick a run to continue.",skillNeeds:"\u201C{title}\u201D needs {fields} \u2014 fill it in below, then send.",message:"Message",inputPlaceholder:"Ask anything\u2026",send:"Send",stop:"Stop",attachFiles:"Attach files",recordVoice:"Record voice",stopRecording:"Stop recording",transcribing:"Transcribing\u2026",transcriptionFailed:"Transcription failed",recordingLimit:"Stopped at the {n}-minute limit \u2014 transcribing what was recorded.",toolRunning:"running\u2026",toolDeferred:"waiting for you",toolDone:"\u2713 done",toolError:"\u26A0 error",toolDeclined:"\u2298 declined",toolInterrupted:"\u25CC not finished",resizePanel:"Resize the chat panel",decisionApproved:"approved by you",decisionDeclined:"declined by you",argumentsLabel:"Arguments",resultLabel:"Result",errorLabel:"Error",declinedLabel:"Declined",interruptedLabel:"Not finished",details:"Details",subAgentWorking:"Working\u2026",subAgentDelegatedTo:"Delegated to {agent}",subAgentFinished:"{agent} finished",subAgentFailed:"The sub-agent failed",subAgentSteps:"Steps the sub-agent took",approvalEditArgs:"Edit the arguments before approving",approvalArgsInvalid:"That is not valid JSON, so nothing was sent.",approvalArgsNotAnObject:"Arguments have to be a JSON object.",suggestions:"Suggested follow-ups",messageActions:"Message actions",quoteSelection:"Quote",copyMessage:"Copy message",retryMessage:"Try again",feedbackUp:"Good answer",feedbackDown:"Poor answer",confirmAction:"Confirm action",confirmAlways:"Always allow",confirmRun:"Run \u201C{tool}\u201D?",confirm:"Confirm",cancel:"Cancel",approveAction:"Approve action",approvalPrompt:"Approve this action?",approve:"Approve",deny:"Deny",askUserAction:"Question",otherOption:"Other\u2026",answerPlaceholder:"Type your answer\u2026",submit:"Submit",chats:"Chats",noConversations:"No conversations yet.",rename:"Rename",renameConversation:"Rename conversation",delete:"Delete",deleteConversation:"Delete conversation",deletePrompt:"Delete?",tooLarge:"Too large (max {size})",fileTypeNotAllowed:"File type not allowed",uploadFailed:"upload failed",retry:"Retry",retryUpload:"Retry upload",remove:"Remove",removeAttachment:"Remove attachment",justNow:"just now",minutesAgo:"{n}m ago",hoursAgo:"{n}h ago",daysAgo:"{n}d ago",weeksAgo:"{n}w ago"};function Wf(e){let t={...pe};for(let n of Object.keys(e)){let o=e[n];o!==void 0&&(t[n]=o)}return t}function dR(e){let t=document.createElement("input");return t.type="text",t.className="question-input",t.setAttribute("part","question-input"),t.placeholder=e,t}function qf(e,t,n={}){let o=n.strings??pe,r=t.options??[],i=r.length>0,a=!i||t.allowCustom===!0;return new Promise(s=>{let u=document.createElement("div");u.className="question",u.setAttribute("part","question"),u.setAttribute("role","group"),u.setAttribute("aria-label",o.askUserAction);let l=document.createElement("div");l.className="question-body",l.setAttribute("part","question-body"),l.textContent=t.question;let d=document.createElement("div");d.className="question-options",d.setAttribute("part","question-options");let h=`q-${r.length}-${t.question.length}`,g=[];for(let I of r){let w=document.createElement("label");w.className="question-choice",w.setAttribute("part","question-choice");let A=document.createElement("input");A.type="radio",A.name=h,A.value=I,A.setAttribute("part","question-radio");let L=document.createElement("span");L.setAttribute("part","question-choice-text"),L.textContent=I,w.append(A,L),d.appendChild(w),g.push(A)}let f=null,p=null;if(a){if(p=dR(o.answerPlaceholder),i){let I=document.createElement("label");I.className="question-choice",I.setAttribute("part","question-choice"),f=document.createElement("input"),f.type="radio",f.name=h,f.value="",f.setAttribute("part","question-radio");let w=document.createElement("span");w.setAttribute("part","question-choice-text"),w.textContent=o.otherOption,I.append(f,w),d.appendChild(I),p.disabled=!0}d.appendChild(p)}let b=document.createElement("div");b.className="question-actions",b.setAttribute("part","question-actions");let v=document.createElement("button");v.type="button",v.className="question-btn",v.setAttribute("part","question-button"),v.textContent=o.submit,b.appendChild(v);let _=!1,y=()=>{let I=g.find(w=>w.checked);if(I!==void 0)return I.value;if(p!==null&&(f===null||f.checked)){let w=p.value.trim();return w===""?null:w}return null},k=()=>{p!==null&&f!==null&&(p.disabled=!f.checked),v.disabled=y()===null},E=I=>{if(!_){_=!0,v.disabled=!0;for(let w of g)w.disabled=!0;f!==null&&(f.disabled=!0),p!==null&&(p.disabled=!0),u.setAttribute("data-resolved",I===""?"cancelled":"answered"),s(I)}};for(let I of[...g,...f!==null?[f]:[]])I.addEventListener("change",k);if(p?.addEventListener("input",k),p?.addEventListener("keydown",I=>{if(I.key==="Enter"){I.preventDefault();let w=y();w!==null&&E(w)}}),v.addEventListener("click",()=>{let I=y();I!==null&&E(I)}),n.signal?.addEventListener("abort",()=>E(""),{once:!0}),u.append(l,d,b),e.appendChild(u),n.signal?.aborted===!0){E("");return}k(),(i?g[0]:p)?.focus()})}function Xf(e){let t={};if(!Array.isArray(e))return t;for(let n of e){if(n===null||typeof n!="object")continue;let o=n,r=o.name,i=o.summary,a=o.description;typeof r=="string"&&typeof i=="string"&&(t[r]=typeof a=="string"?{name:r,summary:i,description:a}:{name:r,summary:i})}return t}var pl=class{#e;#t={};#n=new Set;#o=new Tr;constructor(t){this.#e=t}register(t){this.#o.register(t)}registerPageState(t){for(let n of Si(t))this.#o.register(n)}has(t){return this.#o.has(t)}defaultTools(){return[...this.#l().map(t=>({name:t.name,description:t.description,parameters:t.parameters})),...this.#o.tools()]}advertise(){let t=this.#e.getTools();return this.#n=new Set(t.map(n=>n.name)),t}wasAdvertised(t){return this.#n.has(t)}resolve(t){let n=this.#l().find(o=>o.name===t);return n!==void 0?n:this.#o.has(t)?this.#o.get(t):null}summary(t){return this.#t[t]?.summary}async fetchCatalog(){let t=this.#e.element.getAttribute("data-tools-url");if(t!==null)try{let n=await fetch(t,this.#e.fetchInit(t));this.#t=Xf(await n.json())}catch{}}#r(){return this.#e.routeMap().length===0?[]:Xu(()=>this.#e.routeMap(),()=>this.#e.navigate())}#i(){let t=this.#e.getPageMap();return t===null?[]:[{name:gi,description:"Read the current page's structure (fields, buttons, route). Call after acting to observe the result within the same turn.",parameters:{type:"object",properties:{},required:[],[ke]:"Read the page"},handler:()=>t()}]}#a(){let t=this.#e.element.getAttribute("data-page-actions");if(t===null)return[];let n=new Set(pr(t));return[...Wu(n,o=>this.#e.resolvePageTarget(o)),...n.has(Ar.CHAT)?zu(this.#e.element):[]]}#l(){return[...this.#r(),...this.#i(),...this.#a(),...this.#c()]}#c(){return this.#e.askUser()?[{name:"ask_user",description:"Ask the user a question and wait for their answer. Provide `options` for a multiple-choice prompt; set `allow_custom` to also accept a free-text answer.",parameters:{type:"object",properties:{question:{type:"string",description:"The question to ask the user."},options:{type:"array",items:{type:"string"},description:"Preset choices offered as radio buttons."},allow_custom:{type:"boolean",description:"Allow a free-text answer in addition to any options."}},required:["question"]},handler:(t,n)=>this.#d(t,n)}]:[]}async#d(t,n){let r={question:typeof t.question=="string"?t.question:""},i=t.options;Array.isArray(i)&&(r.options=i.filter(d=>typeof d=="string")),t.allow_custom===!0&&(r.allowCustom=!0);let a=this.#e.decision.open();this.#e.hidePending();let s=()=>qf(this.#e.ensureGroup(),r,{signal:a,strings:this.#e.strings()}),u=this.#e.askUserRenderer(),l;if(u===null)l=await s();else try{l=await u.call(this.#e.element,r,{signal:a})}catch(d){l=await this.#u(d,a,n,s)}return this.#e.decision.close(),this.#e.updateEmptyState(),this.#e.follow(),l}#u(t,n,o,r){return n.aborted?Promise.resolve(""):(console.warn(`ag-ui-chat: askUserRenderer failed for tool call ${o}, so the built-in question card asks instead`,t),r())}};function hl(e){if(e.name!==Mu)return null;let t=e.args?.id;return typeof t=="string"&&t!==""?t:null}function wx(e,t){let n=document.createElement("button");return n.type="button",n.className=`approval-btn approval-btn--${e}`,n.setAttribute("part",`approval-button approval-${e}`),n.textContent=t,n}function Kf(e,t,n={}){let o=n.strings??pe;return new Promise(r=>{let i=document.createElement("div");i.className="approval",i.setAttribute("part","approval"),t.toolName!==void 0&&i.setAttribute("data-tool-name",t.toolName),i.setAttribute("role","group"),i.setAttribute("aria-label",o.approveAction);let a=document.createElement("div");a.className="approval-body",a.setAttribute("part","approval-body"),a.textContent=t.message??o.approvalPrompt;let s=pR(t,n,o),u=document.createElement("div");u.className="approval-actions",u.setAttribute("part","approval-actions");let l=wx("deny",o.deny),d=wx("approve",o.approve),h=!1,g=f=>{h||(h=!0,l.disabled=!0,d.disabled=!0,i.setAttribute("data-resolved",f?"approved":"denied"),r(f))};if(l.addEventListener("click",()=>g(!1)),d.addEventListener("click",()=>{s!==null&&!s.commit()||g(!0)}),n.signal?.addEventListener("abort",()=>g(!1),{once:!0}),u.append(l,d),i.append(a,...s===null?[]:[s.root],u),e.appendChild(i),n.signal?.aborted===!0){g(!1);return}d.focus()})}function pR(e,t,n){let{onEdit:o}=t;if(o===void 0||e.args===void 0)return null;let r=JSON.stringify(e.args,null,2),i=document.createElement("div");i.className="approval-edit",i.setAttribute("part","approval-edit");let a=document.createElement("textarea");a.className="approval-args",a.setAttribute("part","approval-args"),a.setAttribute("aria-label",n.approvalEditArgs),a.rows=Math.min(10,r.split(`
|
|
43
|
+
`).length),a.value=r;let s=document.createElement("div");return s.className="approval-error",s.setAttribute("part","approval-error"),s.setAttribute("role","alert"),s.hidden=!0,i.append(a,s),{root:i,commit:()=>{if(a.value===r)return!0;let u;try{u=JSON.parse(a.value)}catch{return s.textContent=n.approvalArgsInvalid,s.hidden=!1,a.focus(),!1}return typeof u!="object"||u===null||Array.isArray(u)?(s.textContent=n.approvalArgsNotAnObject,s.hidden=!1,a.focus(),!1):(s.hidden=!0,o(u),!0)}}}function Yf(e,t){let n=document.createElement("button");return n.type="button",n.className=`confirm-btn confirm-btn--${e}`,n.setAttribute("part",`confirm-button confirm-${e}`),n.textContent=t,n}function Jf(e,t,n={}){let o=n.strings??pe;return new Promise(r=>{let i=document.createElement("div");i.className="confirm",i.setAttribute("part","confirm"),i.setAttribute("data-tool-name",t.toolName),i.setAttribute("role","group"),i.setAttribute("aria-label",o.confirmAction);let a=document.createElement("div");a.className="confirm-body",a.setAttribute("part","confirm-body"),a.textContent=t.message??ae(o.confirmRun,{tool:t.toolName});let s=document.createElement("pre");s.className="confirm-args",s.setAttribute("part","confirm-args"),s.textContent=JSON.stringify(t.args,null,2),s.hidden=Object.keys(t.args).length===0;let u=document.createElement("div");u.className="confirm-actions",u.setAttribute("part","confirm-actions");let l=Yf("cancel",o.cancel),d=n.onAlwaysAllow===void 0?null:Yf("always",ae(o.confirmAlways,{tool:t.toolName})),h=Yf("confirm",o.confirm),g=!1,f=p=>{g||(g=!0,i.remove(),r(p))};if(l.addEventListener("click",()=>f(!1)),h.addEventListener("click",()=>f(!0)),d?.addEventListener("click",()=>{n.onAlwaysAllow?.(),f(!0)}),n.signal?.addEventListener("abort",()=>f(!1),{once:!0}),u.append(l,...d===null?[]:[d],h),i.append(a,s,u),e.appendChild(i),n.signal?.aborted===!0){f(!1);return}h.focus()})}function Qf(e){return e[Er]===!0}function fl(e){return e[Sr]===!0}var ml=class{#e;#t=new Set;#n=null;constructor(t){this.#e=t}forgetWaivers(){this.#t.clear()}buildContext(){return this.#n=window.location.href,this.#e.getContext()}async execute(t){if(hl(t)!==null)return null;let n=this.#e.transcript.cardFor(t);this.#e.transcript.forgetCard(t.id),this.#e.transcript.setCardElement(t.id,n.element);let o=this.#e.tools.wasAdvertised(t.name)?this.#e.tools.resolve(t.name):null;if(o===null)return this.#e.transcript.isServerSettled(t.id)||n.settle(ne.INTERRUPTED,this.#e.strings().callNotFinished),null;if(this.#e.getPageMap()!==null&&t.name!==gi&&!fl(o.parameters)&&this.#i()){let a=this.#e.strings().pageMoved;return n.settle(ne.ERROR,a),this.#e.transcript.showPending(),{content:`Error: ${a}`,error:a,outcome:Ue.FAILED}}let r=await this.#r(t,o);if(r==="unanswered"){let a=this.#e.strings().confirmCheckFailed;return n.settle(ne.DECLINED,a),this.#e.transcript.showPending(),{content:a,outcome:Ue.DENIED}}if(r!==null){let a={toolName:t.name,args:t.args},s=o.parameters[mi];typeof s=="string"&&(a.message=s);let u=this.#e.decision.open(),l=Jf(this.#e.transcript.ensureGroup(),a,{signal:u,strings:this.#e.strings(),...r==="destructive"?{onAlwaysAllow:()=>this.#t.add(t.name)}:{}});this.#e.transcript.updateEmptyState(),this.#e.transcript.follow();let d=await l;if(this.#e.decision.close(),n.recordDecision(d?"approved":"declined"),!d){let h=this.#e.strings().declinedAction;return n.settle(ne.DECLINED,h),this.#e.transcript.showPending(),{content:h,outcome:Ue.DENIED}}}let i=fl(o.parameters)&&this.#e.navigate()===null;i&&this.#e.conversationStore().saveCheckpoint(this.#e.threadId(),{toolCallId:t.id});try{let a=await o.handler(t.args,t.id);if(o.render!==void 0&&this.#e.transcript.renderToolOutput(o.render,t),i)return n.settle(ne.DONE,this.#e.strings().navigating),{content:"",halt:!0};let s=JSON.stringify(a??null);return n.settle(ne.DONE,s),this.#e.transcript.showPending(),{content:s}}catch(a){i&&this.#e.conversationStore().saveCheckpoint(this.#e.threadId(),null);let s=a instanceof Error?a.message:String(a);return n.settle(ne.ERROR,s),this.#e.transcript.showPending(),{content:`Error: ${s}`,error:s,outcome:Ue.FAILED}}}async resolveInterrupts(t){let n=this.#e.decision.open();this.#e.announce(ae(this.#e.strings().announceAwaitingDecision,{count:t.length})),this.#e.transcript.hidePending();let o=await Promise.all(t.map(async i=>{let a=i.toolCallId!==void 0?this.#e.transcript.card(i.toolCallId):void 0,s={},u=hR(i)??i.message;u!==void 0&&(s.message=u);let l=a?.element.getAttribute("data-tool-name");l!=null&&(s.toolName=l);let d,h=this.#e.approveWithEdits()&&a!==void 0;h&&(s.args=a.args),a?.mark(ne.DEFERRED);let g=()=>Kf(a?.approvalSlot??this.#e.transcript.ensureGroup(),s,{signal:n,strings:this.#e.strings(),...h?{onEdit:b=>{d=b}}:{}}),f=this.#e.approvalRenderer(),p;if(f===null)p=await g();else try{p=await f.call(this.#e.element,s,{signal:n})}catch(b){p=await this.#o(b,n,i.id,g)}return a?.recordDecision(p?"approved":"declined"),p?a?.mark(ne.PENDING):a?.settle(ne.DECLINED,this.#e.strings().declinedAction),{id:i.id,approved:p,editedArgs:d}}));this.#e.transcript.updateEmptyState(),this.#e.transcript.follow(),this.#e.decision.close();let r={};for(let{id:i,approved:a,editedArgs:s}of o)r[i]=a?{status:"resolved",payload:s===void 0?{approved:!0}:{approved:!0,editedArgs:s}}:{status:"cancelled"};return r}#o(t,n,o,r){return n.aborted?Promise.resolve(!1):(console.warn(`ag-ui-chat: approvalRenderer failed for interrupt ${o}, so the built-in approval card asks instead`,t),r())}async#r(t,n){if(this.#e.autoConfirm())return null;let o=this.#e.confirmPredicate();if(o!==null)try{return await o.call(this.#e.element,t.name,t.args)===!0?"predicate":null}catch(r){return console.warn(`ag-ui-chat: confirmPredicate failed for tool ${t.name}, so the call was refused`,r),"unanswered"}return this.#t.has(t.name)?null:Qf(n.parameters)?"destructive":null}#i(){return this.#n!==null&&this.#n!==window.location.href}};function hR(e){let t=e.metadata?.[mi];return typeof t=="string"&&t.trim()!==""?t:void 0}var fR="http://www.w3.org/2000/svg",Ye={top:20,right:12,bottom:30,left:44},mR=480,gR=220,vR=220/480,bR=160,yR=320,xx=8,wR=5.6,_x=["var(--ag-ui-chart-1, #4f7cff)","var(--ag-ui-chart-2, #21b573)","var(--ag-ui-chart-3, #e0803c)","var(--ag-ui-chart-4, #b563d8)","var(--ag-ui-chart-5, #d84f6e)","var(--ag-ui-chart-6, #3ba7c4)"];function xn(e){return _x[e%_x.length]}function Ex(e){let t=Math.max(gR,e),n=Math.min(yR,Math.max(bR,Math.round(t*vR)));return{width:t,height:n,plotW:t-Ye.left-Ye.right,plotH:n-Ye.top-Ye.bottom}}function xt(e,t){let n=document.createElementNS(fR,e);for(let[o,r]of Object.entries(t))n.setAttribute(o,String(r));return n}function Sx(e,t){let n=xt("text",{"font-size":10,fill:"currentColor","fill-opacity":.65,...t});return n.textContent=e,n}function xR(e){let t=[];return e.labels.forEach((n,o)=>{let r=0;for(let i of e.series)r+=i.points[o]??0,t.push(r)}),t}function _R(e){let t=e.kind==="stacked"?xR(e):e.series.flatMap(r=>[...r.points]),n=Math.max(0,...t),o=Math.min(0,...t);return n===o?{min:o,max:n+1}:{min:o,max:n}}function _n(e,t,n,o){return Ye.top+o.plotH-(e-t)/(n-t)*o.plotH}function em(e,t,n){let o=n.plotW/t;return Ye.left+o*e+o/2}function ER(e,t){let n=t.plotW/e.length,o=Math.max(...e.map(r=>r.length))*wR;return Math.max(1,Math.ceil(o/n))}function SR(e,t,n,o,r){for(let a of[o,r]){let s=_n(a,o,r,n);e.appendChild(xt("line",{x1:Ye.left,y1:s,x2:n.width-Ye.right,y2:s,stroke:"currentColor","stroke-opacity":a===o?.35:.12})),e.appendChild(Sx(String(Math.round(a)),{x:Ye.left-6,y:s+4,"text-anchor":"end"}))}let i=ER(t.labels,n);t.labels.forEach((a,s)=>{s%i===0&&e.appendChild(Sx(a,{x:em(s,t.labels.length,n),y:n.height-Ye.bottom+16,"text-anchor":"middle"}))})}function TR(e,t,n,o,r){let i=n.plotW/t.labels.length,a=i*.7/t.series.length,s=_n(o,o,r,n);t.series.forEach((u,l)=>{u.points.forEach((d,h)=>{let g=_n(d,o,r,n);e.appendChild(xt("rect",{x:Ye.left+i*h+i*.15+a*l,y:g,width:a,height:Math.max(1,s-g),fill:xn(l),rx:2}))})})}function kR(e,t,n,o,r){let i=n.plotW/t.labels.length,a=i*.7,s=t.labels.map(()=>0);t.series.forEach((u,l)=>{u.points.forEach((d,h)=>{let g=s[h]??0,f=g+d;s[h]=f;let p=_n(f,o,r,n);e.appendChild(xt("rect",{x:Ye.left+i*h+i*.15,y:p,width:a,height:Math.max(1,_n(g,o,r,n)-p),fill:xn(l)}))})})}function IR(e,t,n,o,r){t.series.forEach((i,a)=>{let s=i.points.map((u,l)=>`${em(l,t.labels.length,n)},${_n(u,o,r,n)}`).join(" ");e.appendChild(xt("polyline",{points:s,fill:"none",stroke:xn(a),"stroke-width":2,"stroke-linejoin":"round"}))})}function AR(e,t,n,o,r){t.series.forEach((i,a)=>{i.points.forEach((s,u)=>{e.appendChild(xt("circle",{cx:em(u,t.labels.length,n),cy:_n(s,o,r,n),r:4,fill:xn(a),"fill-opacity":.85}))})})}function RR(e,t,n){let o=t.reduce((u,l)=>u+l,0),r=n.width/2,i=Ye.top+n.plotH/2,a=Math.min(n.plotW,n.plotH)/2;if(o===0){e.appendChild(xt("circle",{cx:r,cy:i,r:a,fill:"none",stroke:"currentColor","stroke-opacity":.3}));return}let s=-Math.PI/2;t.forEach((u,l)=>{let d=u/o*Math.PI*2,h=s+d;if(d>=Math.PI*2)e.appendChild(xt("circle",{cx:r,cy:i,r:a,fill:xn(l)}));else{let g=r+a*Math.cos(s),f=i+a*Math.sin(s),p=r+a*Math.cos(h),b=i+a*Math.sin(h),v=d>Math.PI?1:0;e.appendChild(xt("path",{d:`M ${r} ${i} L ${g} ${f} A ${a} ${a} 0 ${v} 1 ${p} ${b} Z`,fill:xn(l)}))}s=h})}function Tx(e,t){let n=xt("svg",{viewBox:`0 0 ${t.width} ${t.height}`,width:"100%",role:"img"});if(n.setAttribute("aria-label",e.title??`${e.kind} chart`),e.kind==="pie"){let i=e.series[0];return RR(n,i.points.map(a=>Math.max(0,a)),t),n}let{min:o,max:r}=_R(e);return SR(n,e,t,o,r),e.kind==="bar"?TR(n,e,t,o,r):e.kind==="stacked"?kR(n,e,t,o,r):e.kind==="line"?IR(n,e,t,o,r):AR(n,e,t,o,r),n}function CR(e){if(e.length<2)return null;let t=document.createElement("div");return t.className="chart-legend",t.setAttribute("part","chart-legend"),e.forEach((n,o)=>{let r=document.createElement("span");r.className="chart-legend-item";let i=document.createElement("span");i.className="chart-legend-swatch",i.style.background=xn(o),r.append(i,document.createTextNode(n)),t.appendChild(r)}),t}function NR(e,t){new ResizeObserver(()=>{t(Math.round(e.clientWidth/xx)*xx)}).observe(e)}function Ao(e){if(e.labels.length===0||e.series.length===0)return null;let t=document.createElement("div");if(t.className="chart-block",t.setAttribute("part","chart-block"),e.title!==void 0&&e.title!==""){let i=document.createElement("div");i.className="chart-title",i.setAttribute("part","chart-title"),i.textContent=e.title,t.appendChild(i)}let n=mR,o=Tx(e,Ex(n));t.appendChild(o);let r=CR(e.kind==="pie"?e.labels:e.series.map(i=>i.label));return r!==null&&t.appendChild(r),NR(t,i=>{if(i===n)return;n=i;let a=Tx(e,Ex(n));o.replaceWith(a),o=a}),t}var OR=["bar","line","pie","scatter","stacked"];function $R(e){return OR.includes(e)?e:"bar"}function PR(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){if(typeof n!="number"||!Number.isFinite(n)||Math.abs(n)>1e15)return null;t.push(n)}return t}function MR(e){if(!Array.isArray(e))return null;for(let t=0;t<e.length;t+=1)if(typeof e[t]!="string")return null;return e}function hr(e){if(typeof e!="object"||e===null)return null;let t=e,n=MR(t.labels);if(n===null||!Array.isArray(t.series))return null;let o=[];for(let a of t.series){if(typeof a!="object"||a===null)return null;let s=a,u=PR(s.points);if(u===null||u.length!==n.length)return null;o.push({label:typeof s.label=="string"?s.label:"",points:u})}if(o.length===0||o.length*n.length>2e4||n.length>2e3)return null;let r=$R(t.kind),i=t.title;return typeof i=="string"?{kind:r,title:i,labels:n,series:o}:{kind:r,labels:n,series:o}}var gl="render_chart";function LR(e){let t=hr(e);return t===null?null:Ao(t)}function zR(e){let t=hr(e);return t!==null&&t.labels.length>0&&t.series.length>0}var DR="chart not rendered: expected labels (strings) and series, each with one finite number per label";function kx(){return{name:gl,description:"Show a chart in the conversation. Supply the data and the page draws it. Every series must have exactly one point per label.",parameters:{type:"object",properties:{kind:{type:"string",enum:["bar","line","pie","scatter","stacked"]},title:{type:"string"},labels:{type:"array",items:{type:"string"}},series:{type:"array",items:{type:"object",properties:{label:{type:"string"},points:{type:"array",items:{type:"number"}}},required:["points"]}}},required:["labels","series"],"x-summary":"Draw a chart"},handler:e=>zR(e)?"chart rendered":DR,render:LR}}function Ht(e){e.style.height="auto",e.style.height=`${e.scrollHeight}px`}function tm(e,t){return new Promise((n,o)=>{let r=new FormData;r.append("file",e);let i=new XMLHttpRequest;i.open("POST",t.url),i.withCredentials=t.credentials==="include";for(let[u,l]of Object.entries(t.headers??{}))i.setRequestHeader(u,l);let a=t.onProgress;a!==void 0&&i.upload.addEventListener("progress",u=>{u.lengthComputable&&a(u.total===0?0:u.loaded/u.total)}),i.addEventListener("load",()=>{if(i.status>=200&&i.status<300)try{n(UR(JSON.parse(i.responseText)))}catch{o(new Error("upload returned an unreadable response"))}else o(new Error(jR(i)))}),i.addEventListener("error",()=>o(new Error("upload failed"))),i.addEventListener("abort",()=>o(new Error("upload cancelled")));let s=t.signal;s!==void 0&&s.addEventListener("abort",()=>i.abort()),i.send(r)})}function UR(e){if(typeof e!="object"||e===null)throw new Error("not an object");let t=e,n=t.id,o=t.name,r=t.mime,i=t.size,a=t.url;if(typeof n!="string"||typeof o!="string"||typeof r!="string"||typeof i!="number")throw new Error("missing fields");return typeof a=="string"?{id:n,name:o,mime:r,size:i,url:a}:{id:n,name:o,mime:r,size:i}}function jR(e){try{let t=JSON.parse(e.responseText);if(typeof t.error=="string")return t.error}catch{}return`upload failed (${e.status})`}function vl(e){let t=document.createElement("div");t.className="attachment-chips",t.setAttribute("part","attachment-chips");for(let n of e)t.appendChild(HR(n));return t}function HR(e){let t=document.createElement("div");t.className="attachment-chip attachment-chip--ready",t.setAttribute("part","attachment-chip");let n=document.createElement("span");n.className="attachment-chip-icon",n.setAttribute("part","attachment-chip-icon"),n.innerHTML=nm(e.mime),n.setAttribute("aria-hidden","true");let o=document.createElement("span");o.className="attachment-chip-name",o.setAttribute("part","attachment-chip-name"),o.textContent=e.name,o.title=e.name;let r=document.createElement("span");return r.className="attachment-chip-size",r.setAttribute("part","attachment-chip-size"),r.textContent=bl(e.size),t.append(n,o,r),t}function nm(e){return e.startsWith("image/")?$g:e==="application/pdf"?Pg:e.startsWith("text/")?Mg:Og}function bl(e){if(e<1024)return`${e} B`;let t=["KB","MB","GB"],n=e/1024,o=0;for(;n>=1024&&o<t.length-1;)n/=1024,o+=1;return`${n<10?Math.round(n*10)/10:Math.round(n)} ${t[o]}`}var yl=class{element;#e;#t;#n=[];constructor(t){this.#e=t,this.#t=t.strings??pe,this.element=document.createElement("div"),this.element.className="attachment-tray",this.element.setAttribute("part","attachment-tray"),this.element.hidden=!0}add(t){let n={localId:ve(),file:t,status:Be.UPLOADING,progress:0,ref:null,error:"",controller:null};this.#n.push(n);let o=this.#o(t);if(o!==null){n.status=Be.ERROR,n.error=o,this.#a(),this.#e.onChange?.();return}this.#a(),this.#e.onChange?.(),this.#r(n)}readyRefs(){let t=[];for(let n of this.#n)n.ref!==null&&t.push(n.ref);return t}hasPending(){return this.#n.some(t=>t.status===Be.UPLOADING)}pendingCount(){return this.#n.filter(t=>t.status===Be.UPLOADING).length}isEmpty(){return this.#n.length===0}clearReady(){this.#n=this.#n.filter(t=>t.status===Be.UPLOADING),this.#a()}clear(){for(let t of this.#n)t.controller?.abort();this.#n=[],this.#a()}dispose(){for(let t of this.#n)t.controller?.abort()}#o(t){return this.#e.maxBytes>0&&t.size>this.#e.maxBytes?ae(this.#t.tooLarge,{size:bl(this.#e.maxBytes)}):GR(this.#e.accept,t)?null:this.#t.fileTypeNotAllowed}#r(t){let n=this.#o(t.file);if(n!==null){t.status=Be.ERROR,t.error=n,this.#a(),this.#e.onChange?.();return}t.status=Be.UPLOADING,t.progress=0,t.error="";let o=new AbortController;t.controller=o,this.#a(),this.#e.upload(t.file,r=>{t.progress=r,this.#a()},o.signal).then(r=>{t.status=Be.READY,t.ref=r}).catch(r=>{t.status=Be.ERROR,t.error=r instanceof Error?r.message:this.#t.uploadFailed}).finally(()=>{t.controller=null,this.#a(),this.#e.onChange?.()})}#i(t){t.controller?.abort(),this.#n=this.#n.filter(n=>n!==t),this.#a(),this.#e.onChange?.()}#a(){this.element.replaceChildren(),this.element.hidden=this.#n.length===0;for(let t of this.#n)this.element.appendChild(this.#l(t))}#l(t){let n=document.createElement("div");n.className=`attachment-chip attachment-chip--${t.status}`,n.setAttribute("part","attachment-chip");let o=document.createElement("span");o.className="attachment-chip-icon",o.setAttribute("part","attachment-chip-icon"),o.innerHTML=nm(t.file.type),o.setAttribute("aria-hidden","true");let r=document.createElement("span");r.className="attachment-chip-name",r.setAttribute("part","attachment-chip-name"),r.textContent=t.file.name,r.title=t.file.name;let i=document.createElement("span");if(i.className="attachment-chip-size",i.setAttribute("part","attachment-chip-size"),i.textContent=t.status===Be.ERROR?t.error:bl(t.file.size),n.append(o,r,i),t.status===Be.UPLOADING){let s=document.createElement("div");s.className="attachment-chip-bar",s.setAttribute("part","attachment-chip-bar");let u=document.createElement("div");u.className="attachment-chip-bar-fill",u.setAttribute("part","attachment-chip-bar-fill"),u.style.width=`${Math.round(t.progress*100)}%`,s.appendChild(u),n.appendChild(s)}if(t.status===Be.ERROR){let s=document.createElement("button");s.type="button",s.className="attachment-chip-retry",s.setAttribute("part","attachment-chip-retry"),s.title=this.#t.retry,s.setAttribute("aria-label",this.#t.retryUpload),s.textContent="\u21BB",s.addEventListener("click",()=>this.#r(t)),n.appendChild(s)}let a=document.createElement("button");return a.type="button",a.className="attachment-chip-remove",a.setAttribute("part","attachment-chip-remove"),a.title=this.#t.remove,a.setAttribute("aria-label",this.#t.removeAttachment),a.textContent="\u2715",a.addEventListener("click",()=>this.#i(t)),n.appendChild(a),n}};function GR(e,t){let n=pr(e).map(i=>i.toLowerCase());if(n.length===0)return!0;let o=t.type.toLowerCase(),r=t.name.toLowerCase();return n.some(i=>i.startsWith(".")?r.endsWith(i):i.endsWith("/*")?o.startsWith(i.slice(0,-1)):o===i)}var wl=class{#e;#t=null;constructor(t){this.#e=t}get tray(){return this.#t}wire(t){this.#t?.element.remove(),this.#t=null;let n=this.#e.element.getAttribute("data-attachments-url"),o=this.#e.uploadHandler()??this.#n(n);if(o===null)return;let r=this.#e.element.getAttribute("data-attachment-accept")??"",i=new yl({upload:o,maxBytes:this.#o(),accept:r,strings:this.#e.strings(),onChange:()=>this.#c(i)});this.#t=i,this.#e.slot.appendChild(this.#t.element),this.#e.fileInput.accept=r,this.#e.button.hidden=!1,this.#r(t),this.#l(i,t)}attach(t){return this.#t===null?!1:(this.#t.add(t),!0)}onFilesPicked(){let t=this.#e.fileInput,n=t.files;if(n!==null)for(let o of Array.from(n))this.#t?.add(o);t.value=""}#n(t){return t===null?null:(n,o,r)=>tm(n,{url:t,headers:this.#e.headersFor(t),...this.#e.credentialsOption(),onProgress:o,signal:r})}#o(){let t=this.#e.element.getAttribute("data-attachment-max-bytes");if(t===null)return $u;let n=Number.parseInt(t,10);return Number.isFinite(n)&&n>=0?n:$u}#r(t){let n=this.#e.chat;n.addEventListener("dragover",o=>{o.preventDefault(),n.classList.add("chat--dragover")},{signal:t}),n.addEventListener("dragleave",()=>{n.classList.remove("chat--dragover")},{signal:t}),n.addEventListener("drop",o=>{o.preventDefault(),n.classList.remove("chat--dragover");let r=o.dataTransfer?.files;if(r!==void 0)for(let i of Array.from(r))this.#t?.add(i)},{signal:t})}#i(t,n,o){let r=this.#a(),i=n.getData("text/plain");r===null||i.length<r||(t.preventDefault(),o.add(new File([i],`pasted-${Ix()}.txt`,{type:"text/plain"})))}#a(){let t=this.#e.element.getAttribute("data-paste-attach");if(t===null)return bi;if(t==="off")return null;let n=Number.parseInt(t,10);return Number.isNaN(n)||n<=0?(console.warn(`<ag-ui-chat>: data-paste-attach="${t}" is neither "off" nor a positive number of characters, so the default of ${bi} is used.`),bi):n}#l(t,n){this.#e.chat.addEventListener("paste",o=>{let r=o.clipboardData??null;if(r===null)return;let i=Array.from(r.files);if(i.length===0){this.#i(o,r,t);return}r.getData("text/plain")===""&&o.preventDefault();for(let a of i)this.#t?.add(FR(a))},{signal:n})}#c(t){this.#e.element.dispatchEvent(new CustomEvent(ku,{detail:{attachments:t.readyRefs(),pending:t.pendingCount()},bubbles:!0,composed:!0}))}};function Ix(){return new Date().toISOString().replace(/[:.]/g,"-")}function FR(e){if(e.name!=="")return e;let t=e.type.split("/")[1]??e.type,n=Ix();return new File([e],t===""?`pasted-${n}`:`pasted-${n}.${t}`,{type:e.type})}async function rm(e,t){let n=new FormData;n.append("audio",e,"recording.webm");let o=await fetch(t.url,ot({method:"POST",headers:{...t.headers??{}},body:n},t.credentials));if(!o.ok)throw new Error(await VR(o));let r=await o.json();if(typeof r=="object"&&r!==null&&typeof r.text=="string")return r.text;throw new Error("transcription returned an unreadable response")}async function VR(e){try{let t=await e.json();if(typeof t.error=="string")return t.error}catch{}return`transcription failed (${e.status})`}var Ax=12e4,xl=class{element;#e;#t;#n;#o="idle";#r=null;#i=null;#a=[];#l=null;#c=!1;#d=!1;constructor(t){this.#e=t.transcribe,this.#t=t.onText,this.#n=t.strings??pe,this.element=document.createElement("button"),this.element.type="button",this.element.className="voice-btn",this.element.setAttribute("part","voice-button");let n=document.createElement("slot");n.name="icon-voice",n.innerHTML=Sg,this.element.append(n),this.#g("idle"),this.element.addEventListener("click",()=>{this.toggle()})}async toggle(){if(this.#o==="recording"){this.#h();return}this.#o!=="transcribing"&&await this.#u()}async#u(){let t;try{t=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{this.#b(this.#n.transcriptionFailed);return}this.#i=t,this.#a=[],this.#c=!1;let n=new MediaRecorder(t);n.addEventListener("dataavailable",o=>{this.#a.push(o.data)}),n.addEventListener("stop",()=>{this.#f(n.mimeType)}),this.#r=n,n.start(),this.#l=setTimeout(()=>{this.#c=!0,this.#h()},Ax),this.#g("recording")}#h(){this.#s(),this.#r?.stop()}#s(){this.#l!==null&&(clearTimeout(this.#l),this.#l=null)}dispose(){this.#d=!0,this.#s(),this.#r!==null&&this.#r.state!=="inactive"&&this.#r.stop(),this.#r=null,this.#m()}async#f(t){if(this.#d)return;this.#m(),this.#g("transcribing");let n=new Blob(this.#a,{type:t||"audio/webm"});try{let o=await this.#e(n);this.#g("idle"),this.#c&&(this.element.title=ae(this.#n.recordingLimit,{n:Ax/6e4})),o!==""&&this.#t(o)}catch(o){this.#b(o instanceof Error?o.message:this.#n.transcriptionFailed)}finally{this.#r=null}}#m(){for(let t of this.#i?.getTracks()??[])t.stop();this.#i=null}#b(t){this.#m(),this.#r=null,this.#g("idle"),this.element.title=t}#g(t){this.#o=t,this.element.dataset.state=t;let n=this.#y(t);this.element.title=n,this.element.setAttribute("aria-label",n),this.element.setAttribute("aria-pressed",String(t==="recording")),this.element.disabled=t==="transcribing"}#y(t){return t==="recording"?this.#n.stopRecording:t==="transcribing"?this.#n.transcribing:this.#n.recordVoice}};var _l=class{#e;#t=null;constructor(t){this.#e=t}wire(){this.#t?.element.remove(),this.#t=null;let t=this.#e.element.getAttribute("data-transcribe-url"),n=this.#e.transcribeHandler()??this.#n(t);n!==null&&(this.#t=new xl({transcribe:n,onText:o=>this.#o(o),strings:this.#e.strings()}),this.#e.slot.appendChild(this.#t.element))}dispose(){this.#t?.dispose()}#n(t){return t===null?null:n=>rm(n,{url:t,headers:this.#e.headersFor(t),...this.#e.credentialsOption()})}#o(t){let n=this.#e.input,o=n.value.trim();n.value=o===""?t:`${o} ${t}`,this.#e.onInput(),n.focus()}};var El=class{chips;palette;#e;#t=[];#n=!1;#o=!1;#r=[];#i=0;constructor(t){this.#e=t,this.chips=document.createElement("div"),this.chips.className="skill-chips",this.chips.setAttribute("part","skill-chips"),this.chips.hidden=!0,this.palette=document.createElement("div"),this.palette.className="skill-palette",this.palette.setAttribute("part","skill-palette"),this.palette.setAttribute("role","listbox"),this.palette.hidden=!0}setSkills(t){this.#t=t,this.#d()}enableChips(t){this.#n=t,this.#d()}enableSlash(t){this.#o=t}isOpen(){return!this.palette.hidden}onInput(t){this.#o&&t.startsWith("/")?this.#a(t.slice(1)):this.close()}onKeydown(t){return this.isOpen()?t.key==="ArrowDown"?(this.#l(1),!0):t.key==="ArrowUp"?(this.#l(-1),!0):t.key==="Escape"?(this.close(),!0):t.key==="Enter"?(this.#r.slice(this.#i,this.#i+1).forEach(n=>{this.#c(n)}),!0):!1:!1}close(){this.palette.hidden=!0,this.palette.replaceChildren()}#a(t){let n=t.trim().toLowerCase(),o=this.#t.filter(r=>r.name.toLowerCase().includes(n)||r.title.toLowerCase().includes(n));if(o.length===0){this.close();return}this.#r=o,this.#i=0,this.#u(),this.palette.hidden=!1}#l(t){let n=this.#r.length;this.#i=(this.#i+t+n)%n,this.#u()}#c(t){this.close(),this.#e(t)}#d(){this.chips.replaceChildren();let t=this.#n?this.#t.filter(n=>n.chip===!0):[];this.chips.hidden=t.length===0;for(let n of t){let o=document.createElement("button");o.type="button",o.className="skill-chip",o.setAttribute("part","skill-chip"),o.textContent=n.title,o.title=`/${n.name}`,o.addEventListener("click",()=>this.#c(n)),this.chips.appendChild(o)}}#u(){this.palette.replaceChildren(),this.#r.forEach((t,n)=>{let o=document.createElement("button");o.type="button",o.className="skill-item",o.setAttribute("part","skill-item"),o.setAttribute("role","option"),o.setAttribute("aria-selected",n===this.#i?"true":"false");let r=document.createElement("span");r.className="skill-item-title",r.setAttribute("part","skill-item-title");let i=document.createElement("code");if(i.className="skill-item-token",i.setAttribute("part","skill-item-token"),i.textContent=`/${t.name}`,r.append(i,document.createTextNode(` ${t.title}`)),o.appendChild(r),t.description!==void 0){let a=document.createElement("span");a.className="skill-item-desc",a.setAttribute("part","skill-item-desc"),a.textContent=t.description,o.appendChild(a)}o.addEventListener("click",()=>this.#c(t)),this.palette.appendChild(o)})}};var ZR=500;function Ro(e,t=[],n){for(let o of nC(t)){if(!e.contains(o.startContainer)||!e.contains(o.endContainer))continue;let r=document.createRange();r.setStart(o.startContainer,o.startOffset),r.setEnd(o.endContainer,o.endOffset);let i=XR(r).trim();if(i!=="")return{text:i,rect:tC(r,n)}}return null}function om(e){let t=BR(e);return t.length===0?"":`${qR(t.join(`
|
|
13
44
|
`)).split(`
|
|
14
|
-
`).map(
|
|
45
|
+
`).map(r=>`> ${r}`.trimEnd()).join(`
|
|
15
46
|
`)}
|
|
16
47
|
|
|
17
|
-
`}function
|
|
18
|
-
`).replace(/[^\S\n]+/g," ")}var
|
|
48
|
+
`}function BR(e){let t=e.split(/\r\n?|\n/).map(i=>i.trimEnd()),n=t.filter(i=>i!=="").map(WR),o=n.length===0?0:Math.min(...n),r=[];for(let i of t){let a=i.slice(o);a===""&&(r.length===0||r[r.length-1]==="")||r.push(a)}for(;r[r.length-1]==="";)r.pop();return r}function WR(e){return e.length-e.trimStart().length}function qR(e){return e.length>500?`${e.slice(0,500).trimEnd()}...`:e}function XR(e){let t="";for(let n of QR(e)){let o=n.parentElement;if(!eC(o))continue;let r=n===e.startContainer?e.startOffset:0,i=n===e.endContainer?e.endOffset:n.data.length;t+=KR(n.data.slice(r,i),o)}return t}function KR(e,t){return YR.has(JR(t))?e:e.replace(/[^\S\n]*\n[^\S\n]*/g,`
|
|
49
|
+
`).replace(/[^\S\n]+/g," ")}var YR=new Set(["pre","pre-wrap","break-spaces"]);function JR(e){return window.getComputedStyle(e).whiteSpace}function QR(e){let t=e.commonAncestorContainer;if(t.nodeType===Node.TEXT_NODE)return[t];let n=[],o=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(let r=o.nextNode();r!==null;r=o.nextNode())e.intersectsNode(r)&&n.push(r);return n}function eC(e){return typeof e.checkVisibility!="function"?!0:e.checkVisibility({contentVisibilityAuto:!0,opacityProperty:!0,visibilityProperty:!0})}function tC(e,t){let n=[...e.getClientRects()];if(n.length===0)return e.getBoundingClientRect();if(t===void 0)return n[0];let o=n[0],r=Rx(o,t);for(let i of n.slice(1)){let a=Rx(i,t);a<r&&(r=a,o=i)}return o}function Rx(e,t){let n=Math.max(e.left-t.x,0,t.x-e.right),o=Math.max(e.top-t.y,0,t.y-e.bottom);return Math.hypot(n,o)}function nC(e){let t=window.getSelection();if(t===null)return[];let n=[...rC(t,e)];return t.rangeCount>0&&n.push(t.getRangeAt(0)),n}function rC(e,t){let n=e.getComposedRanges;if(n===void 0)return[];try{return n.call(e,{shadowRoots:t})}catch{return n.call(e,...t)}}var im=6,oC=`
|
|
19
50
|
.ag-ui-quote-offer {
|
|
20
51
|
position: fixed;
|
|
21
52
|
z-index: 2147483000;
|
|
@@ -37,9 +68,9 @@ Error: ${x}`)}}return u()}case g.MESSAGES_SNAPSHOT:{let p=await re(r,s,a,(h,v,x)
|
|
|
37
68
|
.ag-ui-quote-offer[data-below="true"] {
|
|
38
69
|
transform: translate(-50%, 0);
|
|
39
70
|
}
|
|
40
|
-
`;function
|
|
71
|
+
`;function am(e){let{within:t,exclude:n,onQuote:o}=e,r=new CSSStyleSheet;r.replaceSync(oC),document.adoptedStyleSheets=[...document.adoptedStyleSheets,r];let i=document.createElement("button");i.type="button",i.className="ag-ui-quote-offer",i.textContent=e.label,i.hidden=!0,document.body.append(i);let a="",s=()=>{i.hidden=!0,a=""},u=d=>{if(d.composedPath().includes(n)){s();return}if(iC()){s();return}let h=d instanceof MouseEvent?{x:d.clientX,y:d.clientY}:void 0,g=Ro(t,[],h);if(g===null){s();return}a=g.text,aC(i,g.rect)},l=d=>{i.contains(d.target)||s()};return t.addEventListener("mouseup",u),t.addEventListener("keyup",u),t.addEventListener("mousedown",l),document.addEventListener("scroll",s,!0),window.addEventListener("resize",s),i.addEventListener("mousedown",d=>{d.preventDefault()}),i.addEventListener("click",()=>{let d=a;window.getSelection()?.removeAllRanges(),s(),o(d)}),{element:i,detach(){t.removeEventListener("mouseup",u),t.removeEventListener("keyup",u),t.removeEventListener("mousedown",l),document.removeEventListener("scroll",s,!0),window.removeEventListener("resize",s),i.remove(),document.adoptedStyleSheets=document.adoptedStyleSheets.filter(d=>d!==r)}}}function iC(){let e=document.activeElement;return e===null?!1:e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable===!0}function aC(e,t){e.hidden=!1;let n=t.top<im+e.offsetHeight;e.dataset.below=String(n),e.style.top=`${n?t.bottom+im:t.top-im}px`;let o=e.offsetWidth/2,r=t.left+t.width/2,i=document.documentElement.clientWidth;e.style.left=`${Math.min(Math.max(r,o),i-o)}px`}var sm=6,Sl=class{button=document.createElement("button");#e;#t="";#n=null;constructor(t){this.#e=t}insert(t){let n=om(t);if(n==="")return;let o=this.#e.input,r=o.value.replace(/\s+$/,"");o.value=r===""?n:`${r}
|
|
41
72
|
|
|
42
|
-
${n}`,this.#e.autoGrow(),r.focus();let i=r.value.length;r.setSelectionRange(i,i)}offerInPage(e){this.#n?.detach();let n=Xl({within:e,label:this.#e.strings().quoteSelection,exclude:this.#e.element,onQuote:r=>this.#e.quote(r)});return this.#n=n,()=>{n.detach(),this.#n===n&&(this.#n=null)}}detachPageOffer(){this.#n?.detach(),this.#n=null}mount(e){let n=this.button;n.className="quote-selection",n.type="button",n.setAttribute("part","quote-selection"),n.textContent=this.#e.strings().quoteSelection,n.hidden=!0,n.addEventListener("mousedown",o=>{o.preventDefault()},{signal:e}),n.addEventListener("click",()=>{this.#e.quote(this.#t),window.getSelection()?.removeAllRanges(),this.#s()},{signal:e});let r=this.#e.messages;r.addEventListener("mouseup",o=>this.#r(o),{signal:e}),r.addEventListener("keyup",()=>this.#r(),{signal:e}),r.addEventListener("mousedown",()=>this.#s(),{signal:e})}#o(){return this.#e.element.getAttribute("data-quote-selection")!=="false"}#r(e){if(!this.#o())return;let n=e===void 0?void 0:{x:e.clientX,y:e.clientY},r=Pr(this.#e.messages,[this.#e.root],n);if(r===null){this.#s();return}this.#t=r.text,this.#i(r.rect)}#i(e){let n=this.button;n.hidden=!1;let r=this.#e.messagesWrap.getBoundingClientRect(),o=e.top-r.top,i=o<Yl+n.offsetHeight;n.dataset.below=String(i),n.style.top=`${i?e.bottom-r.top+Yl:o-Yl}px`;let s=n.offsetWidth/2,a=e.left+e.width/2-r.left;n.style.left=`${Math.min(Math.max(a,s),r.width-s)}px`}#s(){this.button.hidden=!0,this.#t=""}};function Dr(t,e=Date.now(),n=le){if(!Number.isFinite(t))return n.justNow;let r=Math.round((e-t)/1e3);if(r<60)return n.justNow;let o=Math.round(r/60);if(o<60)return oe(n.minutesAgo,{n:o});let i=Math.round(o/60);if(i<24)return oe(n.hoursAgo,{n:i});let s=Math.round(i/24);return s<7?oe(n.daysAgo,{n:s}):oe(n.weeksAgo,{n:Math.round(s/7)})}function jh(t){return t.preview!==void 0&&t.preview!==null&&t.preview!==""?t.preview:null}function Vh(t){return t.replace(/\s+/g," ").trim()}var Ur=class{element;#e;#t;#n;#o=null;#r=null;#i;#s=[];constructor(e,n=le){this.#e=e,this.#i=n,this.element=document.createElement("div"),this.element.className="checkpoints",this.element.setAttribute("part","checkpoints"),this.element.setAttribute("role","dialog"),this.element.setAttribute("aria-label",n.checkpoints),this.element.tabIndex=-1,this.element.hidden=!0;let r=document.createElement("div");r.className="checkpoints-header",r.setAttribute("part","checkpoints-header"),this.#n=document.createElement("span"),this.#n.className="checkpoints-title",this.#n.setAttribute("part","checkpoints-title"),this.#n.textContent=n.checkpoints,r.append(this.#n),this.#t=document.createElement("div"),this.#t.className="checkpoints-list",this.#t.setAttribute("part","checkpoints-list"),this.element.append(r,this.#t),this.element.addEventListener("keydown",o=>this.#c(o))}setRuns(e){this.#s=e,this.#p()}setRelativeTimeFormatter(e){this.#r=e}#a(e){return this.#r!==null?this.#r(e):Dr(e,Date.now(),this.#i)}setStrings(e){this.#i=e,this.element.setAttribute("aria-label",e.checkpoints),this.#n.textContent=e.checkpoints,this.#p()}open(){this.open_||(this.#o=this.#d(),this.element.hidden=!1,(this.#u()[0]??this.element).focus())}close(){this.open_&&(this.element.hidden=!0,this.#o?.focus(),this.#o=null)}#d(){return this.element.getRootNode().activeElement}#u(){return Array.from(this.element.querySelectorAll("button, [tabindex]")).filter(e=>!e.hidden)}#c(e){if(e.key==="Escape"){e.stopPropagation(),this.close();return}if(e.key!=="Tab")return;let n=this.#u(),r=n[0],o=n[n.length-1],i=this.#d();e.shiftKey&&i===r?(e.preventDefault(),o?.focus()):!e.shiftKey&&i===o&&(e.preventDefault(),r?.focus())}get open_(){return!this.element.hidden}#p(){if(this.#t.replaceChildren(),this.#s.length===0){let n=document.createElement("div");n.className="checkpoints-empty",n.setAttribute("part","checkpoints-empty"),n.textContent=this.#i.noCheckpoints,this.#t.append(n);return}let e=this.#l();for(let n of this.#s)this.#t.append(this.#h(n,e))}#l(){let e=new Set,n=new Set;for(let r of this.#s){let o=jh(r);if(o===null)continue;let i=Vh(o);e.has(i)&&n.add(i),e.add(i)}return n}#h(e,n){let r=document.createElement("div");r.className="checkpoint-row",r.setAttribute("part","checkpoint-row");let o=jh(e),i=e.started_at===null?null:this.#a(Date.parse(e.started_at)),s=document.createElement("span");if(s.className="checkpoint-label",s.setAttribute("part","checkpoint-label"),s.textContent=o??i??e.run_id,r.append(s),o!==null&&i!==null){let l=document.createElement("span");l.className="checkpoint-time",l.setAttribute("part","checkpoint-time"),l.textContent=i,r.append(l)}if((o===null?i!==null:n.has(Vh(o)))&&e.run_id!==""){let l=document.createElement("span");l.className="checkpoint-id",l.setAttribute("part","checkpoint-id"),l.textContent=e.run_id.slice(0,8),l.title=e.run_id,r.append(l)}if(e.parent_run_id!==null){let l=document.createElement("span");l.className="checkpoint-branch",l.setAttribute("part","checkpoint-branch"),l.textContent=this.#i.forkedRun,l.title=e.parent_run_id,r.append(l)}return r.append(this.#m(e.run_id,"resume",this.#i.resumeRun),this.#m(e.run_id,"fork",this.#i.forkRun)),r}#m(e,n,r){let o=document.createElement("button");return o.type="button",o.className=`checkpoint-action checkpoint-${n}`,o.setAttribute("part",`checkpoint-action checkpoint-${n}`),o.textContent=r,o.addEventListener("click",()=>{this.close(),this.#e(e,n)}),o}};function Kl(t){let e=t.attachments;return Array.isArray(e)?e.filter(Sw):[]}function Sw(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.id=="string"&&typeof e.name=="string"&&typeof e.mime=="string"&&typeof e.size=="number"&&(e.url===void 0||typeof e.url=="string")}var Hr=class{#e;#t;#n;constructor(e,n=()=>({}),r=()=>{}){this.#e=e.endsWith("/")?e:`${e}/`,this.#t=n,this.#n=r}async list(){try{let e=await fetch(this.#e,et({method:"GET",headers:{Accept:"application/json",...this.#t()}},this.#n()));return e.ok?(await e.json()).runs??[]:[]}catch{return[]}}async continuable(){return(await this.list()).filter(e=>e.continuable)}resumeUrl(e){return this.#o("resume",e)}forkUrl(e){return this.#o("fork",e)}#o(e,n){return`${this.#e.slice(0,-5)}${e}/${encodeURIComponent(n)}/`}};function Gr(t){return t===Pe.FAILED?te.ERROR:t===Pe.DENIED?te.DECLINED:t===Pe.INTERRUPTED?te.INTERRUPTED:te.DONE}var Es=class{#e;#t="";#n=[];#o=0;#r=0;#i=null;#s=null;constructor(e){this.#e=e}get threadId(){return this.#t}get restored(){return this.#n}get continuation(){return this.#s}adoptActiveThread(){this.#t=this.#e.conversationStore().threadId()}startThread(){this.#t=ss(this.#e.conversationStore())}stopContinuation(){this.#s?.cancel(),this.#s=null}forgetRestored(){this.#n=[],this.#o+=1}reapUnsent(){this.#e.conversationStore().isUnsent?.(this.#t)===!0&&this.#e.conversationStore().clear(this.#t)}runs(){let e=this.#e.element.getAttribute("data-runs-url");return e===null||e===""?null:(this.#i===null&&(this.#i=new Hr(e,()=>this.#e.headersFor(e),()=>this.#e.requestCredentials())),this.#i)}openThreads(){this.#e.checkpoints.close(),this.refreshDrawer(),this.#e.drawer.open()}openCheckpoints(){this.#e.drawer.close(),this.#a(),this.#e.checkpoints.open()}async switchThread(e){e!==this.#t&&(this.#e.cancelRun(),this.#e.resetState(),this.#e.conversationStore().setActiveThread(e),this.#t=e,this.#e.setRunning(!1),await this.rehydrate())}renameThread(e,n){this.#e.conversationStore().renameThread(e,n),this.refreshDrawer()}deleteThread(e){let n=e===this.#t;n&&this.#e.cancelRun(),this.#e.conversationStore().clear(e),n&&(this.#e.resetState(),this.adoptActiveThread(),this.#e.setRunning(!1)),this.refreshDrawer()}async refreshDrawer(){this.#e.drawer.setRelativeTimeFormatter(this.#e.formatRelativeTime()),this.#e.drawer.setThreads(await this.#e.conversationStore().listThreads(),this.#t)}async#a(){let e=this.runs();this.#e.checkpoints.setRelativeTimeFormatter(this.#e.formatRelativeTime()),this.#e.checkpoints.setRuns(e===null?[]:await e.continuable())}async continueRun(e,n){let r=this.runs();if(r===null)return;if(this.#e.running()||this.#s!==null){this.#d(this.#e.strings().continueWhileRunning);return}let o=this.#e.input.value.trim();if(o===""){this.#d(this.#e.strings().continueNeedsTurn);return}this.#e.input.value="",this.#e.autoGrow();let i=this.#o,s=this.#e.buildClient({endpoint:n==="resume"?r.resumeUrl(e):r.forkUrl(e),initialMessages:[],follows:this.#e.client()?.annotatedMessages??this.#n,onSaved:a=>{i===this.#o&&(this.#n=a,this.#e.releaseClient())}});this.#s=s;try{await s.send(o)}finally{this.#s===s&&(this.#s=null,this.#e.continuationEnded())}}#d(e){this.#e.hint.textContent=e,this.#e.hint.hidden=!1,this.#e.input.focus()}async rehydrate(){this.#r+=1;let e=this.#r;this.#e.element.setAttribute("data-restoring","");let n;try{n=await this.#e.conversationStore().loadMessages(this.#t)}finally{e===this.#r&&this.#e.element.removeAttribute("data-restoring")}if(e!==this.#r)return;let r=this.#e.conversationStore().loadCheckpoint(this.#t);if(n!==null){let o=this.#e.strings().callNotFinished,i=ls(n,s=>({id:be(),role:"tool",content:o,toolCallId:s,outcome:Pe.INTERRUPTED}),new Set(r===null?[]:[r.toolCallId]));this.#n=i;for(let s of i)this.replay(s)}if(r!==null){await this.#p(r);return}this.#u(n)}#u(e){let n=e?.at(-1);n===void 0||n.role!==Le.USER||this.#e.transcript.appendNotice("\u26A0",this.#e.strings().runInterrupted,"interrupted")}replay(e){let n=typeof e.content=="string"?e.content:"";if(e.role===Le.USER){let r=Kl(e);if(n!==""||r.length>0){let o=this.#e.appendMessage(Le.USER,n);r.length>0&&o.appendChild(fs(r))}return}if(e.role===Le.ASSISTANT){if(n!==""){let r=this.#e.appendMessage(Le.ASSISTANT,n);r.classList.add("message--restored"),this.#e.actions.attach(r)}for(let r of Aw(e.toolCalls)){let o={id:r.id,name:r.function.name,args:this.#c(r.function.arguments)};if(this.#e.transcript.noticeIfSkillLoad(o))continue;this.#e.transcript.setCardElement(o.id,this.#e.transcript.cardFor(o).element);let i=this.#e.tools.resolve(o.name)?.render;i!==void 0&&this.#e.transcript.renderToolOutput(i,o)}return}if(e.role==="activity"){let r=e;typeof r.activityType=="string"&&this.#e.activities.draw(e.id,r.activityType,r.content);return}if(e.role==="tool"){let r=this.#e.transcript.card(e.toolCallId);r!==void 0&&r.settle(Gr(e.outcome),e.content)}}#c(e){if(typeof e!="string")return{};try{let n=JSON.parse(e);if(typeof n=="object"&&n!==null)return n}catch{}return{}}async#p(e){this.#e.conversationStore().saveCheckpoint(this.#t,null);let n=this.#e.ensureClient();n.addToolResult(e.toolCallId,JSON.stringify(this.#e.navigationResult().call(this.#e.element,e))),await n.resume()}};function Aw(t){return Array.isArray(t)?t.filter(kw):[]}function kw(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.id=="string"&&typeof e.function?.name=="string"}var Rw=8,Ts=class{element;#e;#t;#n;#o;#r;#i=null;#s;#a=[];#d="";#u;#c;#p="";#l=null;constructor(e,n=le){this.#e=e,this.#s=n,this.element=document.createElement("div"),this.element.className="drawer",this.element.setAttribute("part","drawer"),this.element.hidden=!0;let r=document.createElement("div");r.className="drawer-backdrop",r.setAttribute("part","drawer-backdrop"),r.addEventListener("click",()=>this.close()),this.#t=document.createElement("div"),this.#t.className="drawer-panel",this.#t.setAttribute("part","drawer-panel"),this.#t.setAttribute("role","dialog"),this.#t.setAttribute("aria-modal","true"),this.#t.setAttribute("aria-label",n.chatHistory),this.#t.addEventListener("keydown",i=>this.#b(i));let o=document.createElement("div");o.className="drawer-header",o.setAttribute("part","drawer-header"),this.#n=document.createElement("span"),this.#n.className="drawer-title",this.#n.setAttribute("part","drawer-title"),this.#n.textContent=n.chats,this.#o=document.createElement("button"),this.#o.type="button",this.#o.className="drawer-new",this.#o.setAttribute("part","drawer-new"),this.#o.textContent=n.newChat,this.#o.addEventListener("click",()=>{this.close(),this.#e.onNew()}),this.#u=document.createElement("button"),this.#u.type="button",this.#u.className="drawer-close",this.#u.setAttribute("part","drawer-close"),this.#u.title=n.closeHistory,this.#u.setAttribute("aria-label",n.closeHistory),this.#u.append(document.createTextNode("\xD7")),this.#u.addEventListener("click",()=>this.close()),o.append(this.#n,this.#o,this.#u),this.#c=document.createElement("input"),this.#c.type="search",this.#c.className="drawer-filter",this.#c.setAttribute("part","drawer-filter"),this.#c.placeholder=n.searchConversations,this.#c.setAttribute("aria-label",n.searchConversations),this.#c.addEventListener("input",()=>{this.#p=this.#c.value.trim().toLowerCase(),this.#g()}),this.#r=document.createElement("div"),this.#r.className="drawer-list",this.#r.setAttribute("part","drawer-list"),this.#t.append(o,this.#c,this.#r),this.element.append(r,this.#t)}setRelativeTimeFormatter(e){this.#i=e}#h(e){return this.#i!==null?this.#i(e):Dr(e,void 0,this.#s)}setStrings(e){this.#s=e,this.#t.setAttribute("aria-label",e.chatHistory),this.#n.textContent=e.chats,this.#o.textContent=e.newChat,this.#u.title=e.closeHistory,this.#u.setAttribute("aria-label",e.closeHistory),this.#c.placeholder=e.searchConversations,this.#c.setAttribute("aria-label",e.searchConversations),this.#g()}isOpen(){return!this.element.hidden}open(){this.isOpen()||(this.#l=this.#m(),this.element.hidden=!1,this.#o.focus())}close(){this.isOpen()&&(this.element.hidden=!0,this.#l?.focus(),this.#l=null)}toggle(){this.isOpen()?this.close():this.open()}#m(){return this.element.getRootNode().activeElement}#b(e){if(e.key==="Escape"){e.preventDefault(),this.close();return}if(e.key!=="Tab")return;let n=Array.from(this.#t.querySelectorAll("button, input, [tabindex]")).filter(s=>!s.hidden),r=n[0],o=n[n.length-1],i=this.#m();e.shiftKey&&i===r?(e.preventDefault(),o?.focus()):!e.shiftKey&&i===o&&(e.preventDefault(),r?.focus())}setThreads(e,n){this.#a=e,this.#d=n,this.#g()}#g(){this.#r.replaceChildren();let e=this.#a.length<Rw;this.#c.hidden=e,e&&this.#p!==""&&(this.#c.value="",this.#p="");let n=this.#w();if(n.length===0){let r=document.createElement("div");r.className="drawer-empty",r.setAttribute("part","drawer-empty"),r.textContent=this.#a.length===0?this.#s.noConversations:this.#s.noMatches,this.#r.appendChild(r);return}for(let r of n)this.#r.appendChild(this.#f(r))}#w(){return this.#p===""?this.#a:this.#a.filter(e=>e.title.toLowerCase().includes(this.#p)||e.preview.toLowerCase().includes(this.#p))}#f(e){let n=document.createElement("div");n.className="drawer-row",n.setAttribute("part","drawer-row"),e.threadId===this.#d&&n.classList.add("drawer-row--active");let r=document.createElement("button");r.type="button",r.className="drawer-row-select",r.setAttribute("part","drawer-row-select");let o=document.createElement("span");o.className="drawer-row-title",o.setAttribute("part","drawer-row-title"),o.textContent=e.title;let i=document.createElement("span");i.className="drawer-row-time",i.setAttribute("part","drawer-row-time"),i.textContent=this.#h(e.updatedAt);let s=document.createElement("span");s.className="drawer-row-preview",s.setAttribute("part","drawer-row-preview"),s.textContent=e.preview,r.append(o,i,s),r.addEventListener("click",()=>{this.close(),this.#e.onSelect(e.threadId)});let a=document.createElement("button");a.type="button",a.className="drawer-row-rename",a.setAttribute("part","drawer-row-rename"),a.title=this.#s.rename,a.setAttribute("aria-label",this.#s.renameConversation),a.textContent="\u270E",a.addEventListener("click",()=>this.#y(n,e));let l=document.createElement("button");l.type="button",l.className="drawer-row-delete",l.setAttribute("part","drawer-row-delete"),l.title=this.#s.delete,l.setAttribute("aria-label",this.#s.deleteConversation),l.textContent="\u{1F5D1}",l.addEventListener("click",()=>this.#x(n,e));let d=document.createElement("div");return d.className="drawer-row-actions",d.setAttribute("part","drawer-row-actions"),d.append(a,l),n.append(r,d),n}#y(e,n){let r=document.createElement("input");r.type="text",r.className="drawer-rename-input",r.setAttribute("part","drawer-rename-input"),r.value=n.title;let o=!1,i=()=>{if(o)return;o=!0;let a=r.value.trim();a===""||a===n.title?this.#g():this.#e.onRename(n.threadId,a)},s=()=>{o||(o=!0,this.#g())};r.addEventListener("keydown",a=>{a.key==="Enter"?(a.preventDefault(),i()):a.key==="Escape"&&(a.preventDefault(),a.stopPropagation(),s())}),r.addEventListener("blur",()=>i()),e.replaceChildren(r),r.focus(),r.select()}#x(e,n){let r=document.createElement("div");r.className="drawer-confirm",r.setAttribute("part","drawer-confirm");let o=document.createElement("span");o.className="drawer-confirm-label",o.setAttribute("part","drawer-confirm-label"),o.textContent=this.#s.deletePrompt;let i=document.createElement("button");i.type="button",i.className="drawer-confirm-yes",i.setAttribute("part","drawer-confirm-yes"),i.textContent=this.#s.delete,i.addEventListener("click",()=>this.#e.onDelete(n.threadId));let s=document.createElement("button");s.type="button",s.className="drawer-confirm-no",s.setAttribute("part","drawer-confirm-no"),s.textContent=this.#s.cancel,s.addEventListener("click",()=>this.#g()),r.append(o,i,s),e.replaceChildren(r)}};var _s=class{#e=null;open(){return this.#e=new AbortController,this.#e.signal}close(){this.#e=null}abort(){this.#e?.abort()}};function zr(t){return t!=="page"}var Iw=new Set([null,"","floating","bottom-left"]);function Ss(t){return Iw.has(t)}function Ht(t,e,n=tt){let r=Math.min(n,Math.max(0,(e.width-t.width)/2)),o=Math.min(n,Math.max(0,(e.height-t.height)/2));return{left:Math.max(e.left+r,Math.min(t.left,e.left+e.width-t.width-r)),top:Math.max(e.top+o,Math.min(t.top,e.top+e.height-t.height-o))}}function Fr(t,e,n=Vt){let r=t.right-t.left,o=t.bottom-t.top,i=Math.max(e.left+n,Math.min(t.left,e.left+e.width-n-r)),s=Math.max(e.top+n,Math.min(t.top,e.top+e.height-n-o));return{left:i,top:s,right:i+r,bottom:s+o}}var Cw=4,Nw=16,Ow=64;function qh(t,e){let n=!1,{signal:r}=e;t.addEventListener("click",s=>{!n||s.detail===0||(n=!1,s.stopPropagation(),s.preventDefault())},{capture:!0,signal:r}),t.addEventListener("pointerdown",s=>{if(n=!1,!e.enabled())return;let a=e.rect(),l=s.clientX,d=s.clientY,u=!1,m=p=>{let h=p.clientX-l,v=p.clientY-d;if(!u&&Math.hypot(h,v)<Cw)return;u=!0,t.setAttribute("data-dragging","true");let x=Ht({...a,left:a.left+h,top:a.top+v},e.viewport());e.apply(x.left,x.top)},w=p=>{if(window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w),!u)return;t.removeAttribute("data-dragging"),n=!0;let h=Ht({...a,left:a.left+(p.clientX-l),top:a.top+(p.clientY-d)},e.viewport());e.commit(h.left,h.top)};window.addEventListener("pointermove",m),window.addEventListener("pointerup",w),window.addEventListener("pointercancel",w)},{signal:r});let o=null,i=()=>{if(o===null)return;let{left:s,top:a}=o;o=null,e.commit(s,a)};t.addEventListener("keydown",s=>{if(!e.enabled())return;let a=s.shiftKey?Ow:Nw,l=e.rect(),d=null;if(s.key==="ArrowLeft"?d={left:l.left-a,top:l.top}:s.key==="ArrowRight"?d={left:l.left+a,top:l.top}:s.key==="ArrowUp"?d={left:l.left,top:l.top-a}:s.key==="ArrowDown"&&(d={left:l.left,top:l.top+a}),d===null)return;s.preventDefault();let u=Ht({...l,...d},e.viewport());e.apply(u.left,u.top),o=u},{signal:r}),t.addEventListener("keyup",i,{signal:r}),t.addEventListener("blur",i,{signal:r})}function $r(t,e,n,r){return{hostInset:Wh({top:n.y==="top"?t.top:null,right:n.x==="right"?r.width-t.right:null,bottom:n.y==="bottom"?r.height-t.bottom:null,left:n.x==="left"?t.left:null}),launcherInset:Wh({top:n.y==="top"?e.top-t.top:null,right:n.x==="right"?t.right-(e.left+e.width):null,bottom:n.y==="bottom"?t.bottom-(e.top+e.height):null,left:n.x==="left"?e.left-t.left:null})}}function Wh(t){let e=n=>n===null?"auto":`${Math.round(n)}px`;return`${e(t.top)} ${e(t.right)} ${e(t.bottom)} ${e(t.left)}`}function Zl(t,e,n,r,o=tt){let i=n.left+n.width-t.left,s=t.left+t.width-n.left,a=n.top+n.height-t.top,l=t.top+t.height-n.top,d={x:i>=s?"left":"right",y:a>=l?"top":"bottom"},u=d.x==="left"?t.left:t.left+t.width-e.width,m=d.y==="top"?t.top:t.top+t.height-e.height,w=Fr({left:u,top:m,right:u+e.width,bottom:m+e.height},n,o);return{corner:d,...$r(w,t,d,r)}}var Mw="button, a[href], input, select, textarea, [contenteditable]";function Xh(t,e){t.addEventListener("pointerdown",n=>{if(n.button!==0||!e.enabled()||Lw(n,t))return;let r=e.rect(),o=n.clientX,i=n.clientY,s=!1,a=(u,m)=>{let w=u-o,p=m-i;return{left:r.left+w,top:r.top+p,right:r.right+w,bottom:r.bottom+p}},l=u=>{!s&&Math.hypot(u.clientX-o,u.clientY-i)<4||(s=!0,t.setAttribute("data-dragging","true"),e.apply(a(u.clientX,u.clientY),r))},d=u=>{window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",d),s&&(t.removeAttribute("data-dragging"),e.commit(a(u.clientX,u.clientY),r))};n.preventDefault(),window.addEventListener("pointermove",l),window.addEventListener("pointerup",d),window.addEventListener("pointercancel",d)})}function Lw(t,e){let n=t.composedPath();return n.slice(0,n.indexOf(e)).some(r=>r instanceof Element&&r.matches(Mw))}function Kh(t,e){let n=document.createElement("div");n.className=`resize-handle resize-handle--${As(t)}`,n.setAttribute("part",`resize-handle resize-handle-${As(t)}`),n.setAttribute("role","separator"),t.x===void 0?n.setAttribute("aria-orientation","horizontal"):t.y===void 0&&n.setAttribute("aria-orientation","vertical"),n.setAttribute("aria-label",e.label),n.tabIndex=0,n.addEventListener("pointerdown",i=>{let s=e.axis();if(s==="none"||!Yh(t,s))return;let a=e.rect(),l=u=>{e.apply(Ql(t,s,a,u.clientX,u.clientY))},d=u=>{window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",d),n.removeAttribute("data-dragging"),e.commit(Ql(t,s,a,u.clientX,u.clientY))};n.setAttribute("data-dragging","true"),window.addEventListener("pointermove",l),window.addEventListener("pointerup",d),i.preventDefault()});let r=null,o=()=>{if(r===null)return;let i=r;r=null,e.commit(i)};return n.addEventListener("keydown",i=>{let s=e.axis();if(s==="none"||!Yh(t,s))return;let a=i.shiftKey?64:16,l=e.rect(),d=Pw[i.key];if(d===void 0||d.x!==0&&t.x===void 0||d.y!==0&&t.y===void 0)return;i.preventDefault();let u=(t.x==="left"?l.left:l.right)+d.x*a,m=(t.y==="top"?l.top:l.bottom)+d.y*a,w=Ql(t,s,l,u,m);e.apply(w),r=w}),n.addEventListener("keyup",o),n.addEventListener("blur",o),n}var Pw={ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0},ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1}};function As(t){return[t.y,t.x].filter(e=>e!==void 0).join("-")}function Yh(t,e){return e==="both"||t.x!==void 0}function Ql(t,e,n,r,o){let i=t.x==="left"?Math.min(r,n.right-280):n.left,s=t.x==="right"?Math.max(r,n.left+280):n.right,a=e==="both",l=a&&t.y==="top"?Math.min(o,n.bottom-240):n.top,d=a&&t.y==="bottom"?Math.max(o,n.top+240):n.bottom;return{left:i,top:l,right:s,bottom:d}}var Zh="ag-ui-chat:size",Jl="ag-ui-chat:launcher";function Dw(t){if(typeof t!="object"||t===null)return null;let{left:e,top:n}=t;return typeof e=="number"&&typeof n=="number"?{left:e,top:n}:null}function Qh(t,e){return t.width>=e.width-1&&t.height>=e.height-1}function Jh(t,e,n){let r=o=>`${Math.round(o)}px`;return[t.y==="top"?r(e.top):"auto",t.x==="right"?r(n.width-e.right):"auto",t.y==="bottom"?r(n.height-e.bottom):"auto",t.x==="left"?r(e.left):"auto"].join(" ")}var Uw=[{y:"top"},{y:"bottom"},{x:"left"},{x:"right"},{x:"left",y:"top"},{x:"right",y:"top"},{x:"left",y:"bottom"},{x:"right",y:"bottom"}],ks=class{#e;constructor(e){this.#e=e}enablePanelDrag(e){Xh(e,{enabled:()=>!this.#e.collapsed()&&this.#h(),rect:()=>this.#e.element.getBoundingClientRect(),apply:(n,r)=>this.#x(n,r),commit:(n,r)=>this.#_(n,r)})}enableLauncherDrag(e){qh(this.#e.launcher,{signal:e,enabled:()=>this.#e.collapsed()&&this.#h(),rect:()=>this.#g(),viewport:()=>this.#m(),apply:(n,r)=>this.#f(n,r),commit:(n,r)=>this.#y(n,r)})}mountResizeGrips(e){for(let n of Uw){let r=Kh(n,{axis:()=>this.#d(),rect:()=>this.#e.element.getBoundingClientRect(),apply:o=>this.#N(n,o),commit:o=>this.#F(n,o),label:this.#e.strings().resizePanel});r.tabIndex=-1,r.setAttribute("aria-hidden","true"),this.#i.set(As(n),r),e.appendChild(r)}this.#O()}restoreSize(){this.#l(this.#P())}probe=document.createElement("div");#t=null;#n=null;#o=null;#r={x:"right",y:"bottom"};#i=new Map;#s(e){let n=this.#m(),r=n.left+tt,o=n.top+tt,i=n.left+n.width-tt,s=n.top+n.height-tt;return{left:Math.min(Math.max(e.left,r),e.right),top:Math.min(Math.max(e.top,o),e.bottom),right:Math.max(Math.min(e.right,i),e.left),bottom:Math.max(Math.min(e.bottom,s),e.top)}}dragging(){return this.#e.launcher.hasAttribute("data-dragging")||this.#e.root.querySelector(".header[data-dragging]")!==null}describeSurface(){let e=this.#e.element.getBoundingClientRect(),n=this.#m(),r=Qh(e,n);return{placement:this.#e.element.getAttribute("placement"),collapsed:this.#e.collapsed(),collapsible:this.#e.collapsible(),movable:this.#h()&&!r,draggable:this.#h(),fullBleed:r,box:{left:Math.round(e.left),top:Math.round(e.top),width:Math.round(e.width),height:Math.round(e.height)},viewport:{left:Math.round(n.left),top:Math.round(n.top),width:Math.round(n.width),height:Math.round(n.height)}}}moveTo(e,n={}){if(!this.#h())return!1;let r=n.announce===!0?this.#a():null,o=this.#m(),i=this.#e.element.getBoundingClientRect();if(Qh(i,o))return!1;let[s,a]=e.split("-"),l=o.left+Vt,d=o.top+Vt,u=a==="left"?l:Math.max(l,o.left+o.width-Vt-i.width),m=s==="top"?d:Math.max(d,o.top+o.height-Vt-i.height),w={left:u,top:m,right:u+i.width,bottom:m+i.height},p=this.#e.launcher.offsetWidth,h=this.#e.launcher.offsetHeight;return this.#L(w,{left:a==="left"?w.left:w.right-p,top:s==="top"?w.top:w.bottom-h,width:p,height:h}),this.#E(),r!==null&&this.#e.announceSurfaceChange(this.#e.strings().chatMoved,r),!0}#a(){let e=this.#e.element.style.getPropertyValue("--ag-ui-inset"),n=this.#e.element.style.getPropertyValue("--ag-ui-launcher-inset"),r=this.#e.element.getAttribute("data-expand-corner"),o=this.#t,i=this.#n,s=this.#o;return()=>{this.#p("--ag-ui-inset",e),this.#p("--ag-ui-launcher-inset",n),r===null?this.#e.element.removeAttribute("data-expand-corner"):this.#e.element.setAttribute("data-expand-corner",r),this.#t=o,this.#n=i,this.#o=s,o===null?this.#e.clearPreference(Jl):this.#E(),this.syncResizeAnchor()}}#d(){switch(this.#e.element.getAttribute("placement")){case"full":case"page":return"none";case"sidebar":case"side":return"width";default:return"both"}}#u(){let e=this.#e.element.getBoundingClientRect(),n=this.#e.element.style.getPropertyValue("--ag-ui-width"),r=this.#e.element.style.getPropertyValue("--ag-ui-height"),o=this.#c(e,-1),i=o.x===null||o.y===null?this.#c(e,1):o;return this.#p("--ag-ui-width",n),this.#p("--ag-ui-height",r),{x:o.x??i.x??"right",y:o.y??i.y??"bottom"}}#c(e,n){this.#l({width:e.width+n,height:e.height+n});let r=this.#e.element.getBoundingClientRect(),o=(i,s)=>Math.abs(i-s)>=.5;return{x:o(r.width,e.width)?o(r.left,e.left)?"right":"left":null,y:o(r.height,e.height)?o(r.top,e.top)?"bottom":"top":null}}syncResizeAnchor(){if(!this.#e.connected())return;let e=this.#o??this.#u();this.#r=e,this.#e.element.setAttribute("data-resize-anchor",`${e.y}-${e.x}`),this.#O()}#p(e,n){if(n===""){this.#e.element.style.removeProperty(e);return}this.#e.element.style.setProperty(e,n)}#l(e){let n=this.#d();n!=="none"&&(e.width!==void 0&&this.#e.element.style.setProperty("--ag-ui-width",`${e.width}px`),e.height!==void 0&&n==="both"&&this.#e.element.style.setProperty("--ag-ui-height",`${e.height}px`))}releaseOwnedAxes(){let e=this.#d();e!=="both"&&this.#e.element.style.removeProperty("--ag-ui-height"),e==="none"&&this.#e.element.style.removeProperty("--ag-ui-width")}#h(){return this.#e.element.getAttribute("data-launcher-drag")!=="false"&&Ss(this.#e.element.getAttribute("placement"))}#m(){let e=window.visualViewport,n=e?.width??window.innerWidth,r=e?.height??window.innerHeight,o=getComputedStyle(this.probe),i=l=>{let d=Number.parseFloat(o.getPropertyValue(l));return Number.isFinite(d)?d:0},s=i("padding-left"),a=i("padding-top");return{left:s,top:a,width:Math.max(0,n-s-i("padding-right")),height:Math.max(0,r-a-i("padding-bottom"))}}#b(){let e=document.documentElement;return{width:e.clientWidth||window.innerWidth,height:e.clientHeight||window.innerHeight}}publishVisualViewport(){let e=window.visualViewport;if(e==null)return;let n=this.#b().height;if(Math.abs(e.height-n)<1){this.#e.element.style.removeProperty("--ag-ui-visual-viewport-height"),this.#e.element.style.removeProperty("--ag-ui-visual-viewport-inset-bottom"),this.#e.element.style.removeProperty("--ag-ui-visual-viewport-inset-top");return}this.#e.element.style.setProperty("--ag-ui-visual-viewport-height",`${Math.round(e.height)}px`);let r=n-e.height-e.offsetTop;this.#e.element.style.setProperty("--ag-ui-visual-viewport-inset-bottom",`${Math.max(0,Math.round(r))}px`),this.#e.element.style.setProperty("--ag-ui-visual-viewport-inset-top",`${Math.max(0,Math.round(e.offsetTop))}px`)}#g(){let e=this.#e.launcher.offsetWidth,n=this.#e.launcher.offsetHeight,r=this.#t;if(r!==null)return{left:r.left,top:r.top,width:e,height:n};let o=this.#e.launcher.getBoundingClientRect();return{left:o.left+o.width/2-e/2,top:o.top+o.height/2-n/2,width:e,height:n}}#w(e){if(!this.#h())return;this.#t=e,this.#n=null;let n=this.#e.element.getBoundingClientRect(),r=Zl(this.#g(),{width:n.width,height:n.height},this.#m(),this.#b());this.#e.element.style.setProperty("--ag-ui-inset",r.hostInset),this.#e.element.style.setProperty("--ag-ui-launcher-inset",r.launcherInset),this.#o=r.corner,this.#e.element.setAttribute("data-expand-corner",`${r.corner.y}-${r.corner.x}`),this.syncResizeAnchor()}#f(e,n){this.#w({left:e,top:n})}#y(e,n){this.#f(e,n),this.#E()}#x(e,n){if(!this.#h())return{held:e,launcher:null};if(this.#t===null){let l=this.#g();this.#t={left:l.left,top:l.top}}let r=this.#t,o=Fr(e,this.#m(),tt),i=this.#o??this.#r;this.#e.element.style.setProperty("--ag-ui-inset",Jh(i,o,this.#b())),this.#n={left:o.left,top:o.top};let s={...this.#g(),left:r.left+(o.left-n.left),top:r.top+(o.top-n.top)},a={...s,...Ht(s,this.#m())};return this.#e.element.style.setProperty("--ag-ui-launcher-inset",$r(o,a,i,this.#b()).launcherInset),{held:o,launcher:a}}#_(e,n){let{held:r,launcher:o}=this.#x(e,n);o!==null&&(this.#L(r,o),this.#E())}#L(e,n){let r=this.#m(),o=this.#b(),i={width:e.right-e.left,height:e.bottom-e.top},{corner:s}=Zl(n,i,r,o),a=$r(e,n,s,o);this.#e.element.style.setProperty("--ag-ui-inset",a.hostInset),this.#e.element.style.setProperty("--ag-ui-launcher-inset",a.launcherInset),this.#t={left:n.left,top:n.top},this.#n={left:e.left,top:e.top},this.#o=s,this.#e.element.setAttribute("data-expand-corner",`${s.y}-${s.x}`),this.syncResizeAnchor()}#A(e){if(!this.#h())return;let n=this.#e.element.getBoundingClientRect(),r=Fr({left:e.left,top:e.top,right:e.left+n.width,bottom:e.top+n.height},this.#m(),tt),o=this.#g(),i={...o,left:o.left+(r.left-e.left),top:o.top+(r.top-e.top)};this.#L(r,{...i,...Ht(i,this.#m())})}#E(){let e=this.#t;if(e===null)return;let n=this.#n;this.#e.writePreference(Jl,JSON.stringify(n===null?e:{...e,panel:n}))}restoreLauncherPosition(){let e=this.#k(),n=this.#t??e;if(n===null)return;let r=this.#n??e?.panel??null;if(r!==null){this.#t={left:n.left,top:n.top},this.#A(r);return}let o=this.#g();this.#w(Ht({...o,left:n.left,top:n.top},this.#m()))}#k(){let e=this.#e.readPreference(Jl);if(e===null)return null;try{let n=JSON.parse(e);if(typeof n!="object"||n===null)return null;let{left:r,top:o,panel:i}=n;if(typeof r!="number"||typeof o!="number")return null;let s=Dw(i);return s===null?{left:r,top:o}:{left:r,top:o,panel:s}}catch{return null}}releaseLauncherPosition(){this.#h()||(this.#t=null,this.#n=null,this.#o=null,this.#e.element.style.removeProperty("--ag-ui-inset"),this.#e.element.style.removeProperty("--ag-ui-launcher-inset"),this.#e.element.removeAttribute("data-expand-corner"))}#N(e,n){if(n=this.#s(n),this.#l({width:n.right-n.left,height:n.bottom-n.top}),e.x!==this.#r.x&&e.y!==this.#r.y)return n;let r=this.#r;if(this.#e.element.style.setProperty("--ag-ui-inset",Jh(r,n,this.#b())),this.#t!==null){let o=this.#e.launcher.offsetWidth;this.#t={left:r.x==="left"?n.left:n.right-o,top:r.y==="top"?n.top:n.bottom-o}}return this.#n!==null&&(this.#n={left:n.left,top:n.top}),n}#F(e,n){let r=this.#N(e,n);this.#v({width:r.right-r.left,height:r.bottom-r.top}),this.#E(),this.syncResizeAnchor()}#O(){let e=`${this.#r.y==="top"?"bottom":"top"}-${this.#r.x==="left"?"right":"left"}`;for(let[n,r]of this.#i){let o=n===e;r.tabIndex=o?0:-1,o?r.removeAttribute("aria-hidden"):r.setAttribute("aria-hidden","true")}}#v(e){let n={...this.#P(),...e};this.#e.writePreference(Zh,JSON.stringify(n))}#P(){let e=this.#e.readPreference(Zh);if(e===null)return{};try{let n=JSON.parse(e);return typeof n=="object"&&n!==null?n:{}}catch{return{}}}};var Rs=class{region=document.createElement("div");#e=null;mount(){this.region.className="sr-only",this.region.setAttribute("role","status"),this.region.setAttribute("aria-live","polite"),this.region.setAttribute("aria-atomic","true")}announce(e){this.#e!==null&&clearTimeout(this.#e),this.region.textContent=e,this.#e=setTimeout(()=>{this.#e=null,this.region.textContent=""},Ec)}dispose(){this.#e!==null&&(clearTimeout(this.#e),this.#e=null)}};function Is(t,e,n,r){let o=document.createElement("div");o.className=`run-notice run-notice--${n}`,o.setAttribute("part",`run-notice run-notice-${n}`),o.setAttribute("role","status");let i=document.createElement("span");i.className="run-notice-icon",i.setAttribute("part","run-notice-icon"),i.textContent=t,i.setAttribute("aria-hidden","true");let s=document.createElement("span");if(s.className="run-notice-text",s.setAttribute("part","run-notice-text"),s.textContent=e,o.append(i,s),r!==void 0){let a=document.createElement("button");a.type="button",a.className="run-notice-undo",a.setAttribute("part","run-notice-undo"),a.textContent=r.label,a.addEventListener("click",()=>{a.disabled=!0,r.onActivate()}),o.append(a)}return o}var Cs=class{element;get agent(){return this.#r}#e;#t;#n;#o=new Map;#r=null;constructor(e=le){this.element=document.createElement("div"),this.element.className="subagent",this.element.setAttribute("part","subagent"),this.#e=document.createElement("button"),this.#e.type="button",this.#e.className="subagent-row",this.#e.setAttribute("part","subagent-row"),this.#e.setAttribute("aria-expanded","false"),this.#e.disabled=!0;let n=document.createElement("span");n.className="subagent-icon",n.setAttribute("part","subagent-icon"),n.setAttribute("aria-hidden","true"),this.#t=document.createElement("span"),this.#t.className="subagent-status",this.#t.setAttribute("part","subagent-status"),this.#t.textContent=e.subAgentWorking,this.#e.append(n,this.#t),this.#n=document.createElement("div"),this.#n.className="subagent-steps",this.#n.setAttribute("part","subagent-steps"),this.#n.setAttribute("role","list"),this.#n.setAttribute("aria-label",e.subAgentSteps),this.#n.hidden=!0,this.#e.addEventListener("click",()=>{this.#a(this.#e.getAttribute("aria-expanded")!=="true")}),this.element.append(this.#e,this.#n)}report(e){this.element.setAttribute("data-phase",e.phase),e.agent!==null&&(this.#r=e.agent,this.element.setAttribute("data-agent",e.agent)),e.status!==null&&(this.#t.textContent=e.status),e.tool!==null&&this.#i(e.tool)}#i(e){let n=this.#o.get(e.toolCallId)??this.#s(e);if(e.ok===null){n.removeAttribute("data-ok");return}n.setAttribute("data-ok",String(e.ok))}#s(e){let n=document.createElement("div");n.className="subagent-step",n.setAttribute("part","subagent-step"),n.setAttribute("role","listitem"),n.setAttribute("data-tool-call-id",e.toolCallId);let r=document.createElement("span");r.className="subagent-step-icon",r.setAttribute("part","subagent-step-icon"),r.setAttribute("aria-hidden","true");let o=document.createElement("span");return o.className="subagent-step-name",o.setAttribute("part","subagent-step-name"),o.textContent=e.name,n.append(r,o),this.#n.appendChild(n),this.#o.set(e.toolCallId,n),this.#e.disabled=!1,n}#a(e){this.#n.hidden=!e,this.#e.setAttribute("aria-expanded",String(e))}};var Hw=Object.values(On);function ep(t){return typeof t!="object"||t===null||Array.isArray(t)?null:t}function Br(t){return typeof t=="string"&&t!==""?t:null}function Gw(t){let e=ep(t);if(e===null)return null;let n=Br(e.toolCallId),r=Br(e.name),o=e.ok;return n===null||r===null||o!==null&&typeof o!="boolean"?null:{toolCallId:n,name:r,ok:o}}function tp(t){let e=ep(t);if(e===null)return null;let n=Br(e.delegationId),r=e.phase;return n===null||typeof r!="string"||!Hw.includes(r)?null:{delegationId:n,phase:r,agent:Br(e.agent),status:Br(e.status),tool:Gw(e.tool)}}var Ns=class{#e;#t=new Map;#n=new Map;constructor(e){this.#e=e}report(e){let n=tp(e);n!==null&&this.#i(n)}start(e,n,r){r!==null&&(this.#n.set(e,r),this.#i({delegationId:r,agent:n===""?null:n,phase:On.STARTED,status:oe(this.#e.strings().subAgentDelegatedTo,{agent:n}),tool:null}))}finish(e){this.#o(e,On.FINISHED,null)}fail(e,n){this.#o(e,On.FAILED,n===""?this.#e.strings().subAgentFailed:n)}clear(){this.#t.clear(),this.#n.clear()}#o(e,n,r){let o=this.#n.get(e);if(o===void 0)return;let i=this.#t.get(o)?.agent??null;this.#i({delegationId:o,agent:i,phase:n,status:r===null?this.#r(i):r,tool:null})}#r(e){let n=this.#e.strings();return e===null?n.subAgentWorking:oe(n.subAgentFinished,{agent:e})}#i(e){let n=this.#e.card(e.delegationId);if(n===void 0)return;let r=this.#t.get(e.delegationId);r===void 0&&(r=new Cs(this.#e.strings()),this.#t.set(e.delegationId,r),n.subagentSlot.appendChild(r.element)),r.report(e),this.#e.follow()}};function ed(t){return{[te.PENDING]:t.toolRunning,[te.DEFERRED]:t.toolDeferred,[te.DONE]:t.toolDone,[te.ERROR]:t.toolError,[te.DECLINED]:t.toolDeclined,[te.INTERRUPTED]:t.toolInterrupted}}function zw(t){return{[te.DONE]:t.resultLabel,[te.ERROR]:t.errorLabel,[te.DECLINED]:t.declinedLabel,[te.INTERRUPTED]:t.interruptedLabel}}function Fw(t){try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}var jr=class{element;approvalSlot;subagentSlot;#e;#t;#n;#o;#r;#i;#s;args;#a;#d;#u=!1;constructor(e,n,r,o=le,i={}){this.#s=o,this.args=n,this.#a=e,this.#d=i.formatPayload??null,this.element=document.createElement("div"),this.element.className="tool-call",this.element.setAttribute("part","tool-card"),this.element.setAttribute("data-tool-name",e),this.element.setAttribute("data-status",te.PENDING),this.element.setAttribute("data-expanded","false");let s=document.createElement("div");s.className="tool-call-head",s.setAttribute("part","tool-card-head");let a=document.createElement("span");a.className="tool-call-icon",a.setAttribute("part","tool-card-icon"),a.setAttribute("aria-hidden","true");let l=document.createElement("span");l.className="tool-call-name",l.setAttribute("part","tool-card-name"),l.textContent=r??e,this.#e=document.createElement("span"),this.#e.className="tool-call-status",this.#e.setAttribute("part","tool-card-status"),this.#e.textContent=ed(o)[te.PENDING],this.#t=document.createElement("span"),this.#t.className="tool-call-decision",this.#t.setAttribute("part","tool-card-decision"),this.#t.hidden=!0,s.append(a,l,this.#e,this.#t);let d=this.#p("args",o.argumentsLabel);this.#c(d.body,{kind:"arguments",toolName:e,args:n},JSON.stringify(n,null,2)),d.root.hidden=Object.keys(n).length===0;let u=this.#p("result",o.resultLabel);this.#o=u.root,this.#r=u.label,this.#i=u.body,u.root.hidden=!0,this.#n=document.createElement("button"),this.#n.type="button",this.#n.className="tool-call-toggle",this.#n.setAttribute("part","tool-card-toggle"),this.#n.setAttribute("aria-expanded","false"),this.#n.textContent=o.details,this.#n.addEventListener("click",()=>this.#h(!this.#l()));let m=document.createElement("div");m.className="tool-call-body",m.setAttribute("part","tool-card-body"),m.append(d.root,u.root),this.approvalSlot=document.createElement("div"),this.approvalSlot.className="tool-call-approval",this.approvalSlot.setAttribute("part","tool-card-approval"),this.subagentSlot=document.createElement("div"),this.subagentSlot.className="tool-call-subagent",this.subagentSlot.setAttribute("part","tool-card-subagent"),this.element.append(s,this.subagentSlot,this.#n,m,this.approvalSlot)}mark(e){this.#u||(this.element.setAttribute("data-status",e),this.#e.textContent=ed(this.#s)[e])}recordDecision(e){this.element.setAttribute("data-decision",e),this.#t.textContent=e==="approved"?this.#s.decisionApproved:this.#s.decisionDeclined,this.#t.hidden=!1}get settled(){return this.#u}settle(e,n){this.#u||(this.#u=!0,this.element.setAttribute("data-status",e),this.#e.textContent=ed(this.#s)[e],this.#r.textContent=zw(this.#s)[e],this.#c(this.#i,{kind:"result",toolName:this.#a,status:e,text:n},Fw(n)),this.#o.hidden=!1)}#c(e,n,r){let o=this.#d===null?null:this.#d(n);if(o===null){e.textContent=r;return}if(e.setAttribute("data-formatted","true"),typeof o=="string"){e.textContent=o;return}e.replaceChildren(o)}#p(e,n){let r=document.createElement("div");r.className=`tool-call-section tool-call-section--${e}`,r.setAttribute("part",`tool-card-section tool-card-${e}-section`);let o=document.createElement("span");o.className="tool-call-section-label",o.setAttribute("part",`tool-card-section-label tool-card-${e}-label`),o.textContent=n;let i=document.createElement("pre");return i.className=`tool-call-${e}`,i.setAttribute("part",`tool-card-${e}`),r.append(o,i),{root:r,label:o,body:i}}#l(){return this.element.getAttribute("data-expanded")==="true"}#h(e){this.element.setAttribute("data-expanded",String(e)),this.#n.setAttribute("aria-expanded",String(e))}};var np=`
|
|
73
|
+
${n}`,this.#e.autoGrow(),o.focus();let i=o.value.length;o.setSelectionRange(i,i)}offerInPage(t){this.#n?.detach();let n=am({within:t,label:this.#e.strings().quoteSelection,exclude:this.#e.element,onQuote:o=>this.#e.quote(o)});return this.#n=n,()=>{n.detach(),this.#n===n&&(this.#n=null)}}detachPageOffer(){this.#n?.detach(),this.#n=null}mount(t){let n=this.button;n.className="quote-selection",n.type="button",n.setAttribute("part","quote-selection"),n.textContent=this.#e.strings().quoteSelection,n.hidden=!0,n.addEventListener("mousedown",r=>{r.preventDefault()},{signal:t}),n.addEventListener("click",()=>{this.#e.quote(this.#t),window.getSelection()?.removeAllRanges(),this.#a()},{signal:t});let o=this.#e.messages;o.addEventListener("mouseup",r=>this.#r(r),{signal:t}),o.addEventListener("keyup",()=>this.#r(),{signal:t}),o.addEventListener("mousedown",()=>this.#a(),{signal:t})}#o(){return this.#e.element.getAttribute("data-quote-selection")!=="false"}#r(t){if(!this.#o())return;let n=t===void 0?void 0:{x:t.clientX,y:t.clientY},o=Ro(this.#e.messages,[this.#e.root],n);if(o===null){this.#a();return}this.#t=o.text,this.#i(o.rect)}#i(t){let n=this.button;n.hidden=!1;let o=this.#e.messagesWrap.getBoundingClientRect(),r=t.top-o.top,i=r<sm+n.offsetHeight;n.dataset.below=String(i),n.style.top=`${i?t.bottom-o.top+sm:r-sm}px`;let a=n.offsetWidth/2,s=t.left+t.width/2-o.left;n.style.left=`${Math.min(Math.max(s,a),o.width-a)}px`}#a(){this.button.hidden=!0,this.#t=""}};function Co(e,t=Date.now(),n=pe){if(!Number.isFinite(e))return n.justNow;let o=Math.round((t-e)/1e3);if(o<60)return n.justNow;let r=Math.round(o/60);if(r<60)return ae(n.minutesAgo,{n:r});let i=Math.round(r/60);if(i<24)return ae(n.hoursAgo,{n:i});let a=Math.round(i/24);return a<7?ae(n.daysAgo,{n:a}):ae(n.weeksAgo,{n:Math.round(a/7)})}function Cx(e){return e.preview!==void 0&&e.preview!==null&&e.preview!==""?e.preview:null}function Nx(e){return e.replace(/\s+/g," ").trim()}var No=class{element;#e;#t;#n;#o=null;#r=null;#i;#a=[];constructor(t,n=pe){this.#e=t,this.#i=n,this.element=document.createElement("div"),this.element.className="checkpoints",this.element.setAttribute("part","checkpoints"),this.element.setAttribute("role","dialog"),this.element.setAttribute("aria-label",n.checkpoints),this.element.tabIndex=-1,this.element.hidden=!0;let o=document.createElement("div");o.className="checkpoints-header",o.setAttribute("part","checkpoints-header"),this.#n=document.createElement("span"),this.#n.className="checkpoints-title",this.#n.setAttribute("part","checkpoints-title"),this.#n.textContent=n.checkpoints,o.append(this.#n),this.#t=document.createElement("div"),this.#t.className="checkpoints-list",this.#t.setAttribute("part","checkpoints-list"),this.element.append(o,this.#t),this.element.addEventListener("keydown",r=>this.#u(r))}setRuns(t){this.#a=t,this.#h()}setRelativeTimeFormatter(t){this.#r=t}#l(t){return this.#r!==null?this.#r(t):Co(t,Date.now(),this.#i)}setStrings(t){this.#i=t,this.element.setAttribute("aria-label",t.checkpoints),this.#n.textContent=t.checkpoints,this.#h()}open(){this.open_||(this.#o=this.#c(),this.element.hidden=!1,(this.#d()[0]??this.element).focus())}close(){this.open_&&(this.element.hidden=!0,this.#o?.focus(),this.#o=null)}#c(){return this.element.getRootNode().activeElement}#d(){return Array.from(this.element.querySelectorAll("button, [tabindex]")).filter(t=>!t.hidden)}#u(t){if(t.key==="Escape"){t.stopPropagation(),this.close();return}if(t.key!=="Tab")return;let n=this.#d(),o=n[0],r=n[n.length-1],i=this.#c();t.shiftKey&&i===o?(t.preventDefault(),r?.focus()):!t.shiftKey&&i===r&&(t.preventDefault(),o?.focus())}get open_(){return!this.element.hidden}#h(){if(this.#t.replaceChildren(),this.#a.length===0){let n=document.createElement("div");n.className="checkpoints-empty",n.setAttribute("part","checkpoints-empty"),n.textContent=this.#i.noCheckpoints,this.#t.append(n);return}let t=this.#s();for(let n of this.#a)this.#t.append(this.#f(n,t))}#s(){let t=new Set,n=new Set;for(let o of this.#a){let r=Cx(o);if(r===null)continue;let i=Nx(r);t.has(i)&&n.add(i),t.add(i)}return n}#f(t,n){let o=document.createElement("div");o.className="checkpoint-row",o.setAttribute("part","checkpoint-row");let r=Cx(t),i=t.started_at===null?null:this.#l(Date.parse(t.started_at)),a=document.createElement("span");if(a.className="checkpoint-label",a.setAttribute("part","checkpoint-label"),a.textContent=r??i??t.run_id,o.append(a),r!==null&&i!==null){let u=document.createElement("span");u.className="checkpoint-time",u.setAttribute("part","checkpoint-time"),u.textContent=i,o.append(u)}if((r===null?i!==null:n.has(Nx(r)))&&t.run_id!==""){let u=document.createElement("span");u.className="checkpoint-id",u.setAttribute("part","checkpoint-id"),u.textContent=t.run_id.slice(0,8),u.title=t.run_id,o.append(u)}if(t.parent_run_id!==null){let u=document.createElement("span");u.className="checkpoint-branch",u.setAttribute("part","checkpoint-branch"),u.textContent=this.#i.forkedRun,u.title=t.parent_run_id,o.append(u)}return o.append(this.#m(t.run_id,"resume",this.#i.resumeRun),this.#m(t.run_id,"fork",this.#i.forkRun)),o}#m(t,n,o){let r=document.createElement("button");return r.type="button",r.className=`checkpoint-action checkpoint-${n}`,r.setAttribute("part",`checkpoint-action checkpoint-${n}`),r.textContent=o,r.addEventListener("click",()=>{this.close(),this.#e(t,n)}),r}};function lm(e){let t=dl(e,"attachments");return Array.isArray(t)?t.filter(sC):[]}function sC(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.id=="string"&&typeof t.name=="string"&&typeof t.mime=="string"&&typeof t.size=="number"&&(t.url===void 0||typeof t.url=="string")}var Oo=class{#e;#t;#n;constructor(t,n=()=>({}),o=()=>{}){this.#e=t.endsWith("/")?t:`${t}/`,this.#t=n,this.#n=o}async list(){try{let t=await fetch(this.#e,ot({method:"GET",headers:{Accept:"application/json",...this.#t()}},this.#n()));return t.ok?(await t.json()).runs??[]:[]}catch{return[]}}async continuable(){return(await this.list()).filter(t=>t.continuable)}resumeUrl(t){return this.#o("resume",t)}forkUrl(t){return this.#o("fork",t)}#o(t,n){return`${this.#e.slice(0,-5)}${t}/${encodeURIComponent(n)}/`}};function $o(e){return e===Ue.FAILED?ne.ERROR:e===Ue.DENIED?ne.DECLINED:e===Ue.INTERRUPTED?ne.INTERRUPTED:ne.DONE}var Tl=class{#e;#t="";#n=[];#o=0;#r=0;#i=null;#a=null;constructor(t){this.#e=t}get threadId(){return this.#t}get restored(){return this.#n}get continuation(){return this.#a}adoptActiveThread(){this.#t=this.#e.conversationStore().threadId()}startThread(){this.#t=ll(this.#e.conversationStore())}stopContinuation(){this.#a?.cancel(),this.#a=null}forgetRestored(){this.#n=[],this.#o+=1}reapUnsent(){this.#e.conversationStore().isUnsent?.(this.#t)===!0&&this.#e.conversationStore().clear(this.#t)}runs(){let t=this.#e.element.getAttribute("data-runs-url");return t===null||t===""?null:(this.#i===null&&(this.#i=new Oo(t,()=>this.#e.headersFor(t),()=>this.#e.requestCredentials())),this.#i)}openThreads(){this.#e.checkpoints.close(),this.refreshDrawer(),this.#e.drawer.open()}openCheckpoints(){this.#e.drawer.close(),this.#l(),this.#e.checkpoints.open()}async switchThread(t){t!==this.#t&&(this.#e.cancelRun(),this.#e.resetState(),this.#e.conversationStore().setActiveThread(t),this.#t=t,this.#e.setRunning(!1),await this.rehydrate())}renameThread(t,n){this.#e.conversationStore().renameThread(t,n),this.refreshDrawer()}deleteThread(t){let n=t===this.#t;n&&this.#e.cancelRun(),this.#e.conversationStore().clear(t),n&&(this.#e.resetState(),this.adoptActiveThread(),this.#e.setRunning(!1)),this.refreshDrawer()}async refreshDrawer(){this.#e.drawer.setRelativeTimeFormatter(this.#e.formatRelativeTime()),this.#e.drawer.setThreads(await this.#e.conversationStore().listThreads(),this.#t)}async#l(){let t=this.runs();this.#e.checkpoints.setRelativeTimeFormatter(this.#e.formatRelativeTime()),this.#e.checkpoints.setRuns(t===null?[]:await t.continuable())}async continueRun(t,n){let o=this.runs();if(o===null)return;if(this.#e.running()||this.#a!==null){this.#c(this.#e.strings().continueWhileRunning);return}let r=this.#e.input.value.trim();if(r===""){this.#c(this.#e.strings().continueNeedsTurn);return}this.#e.input.value="",this.#e.autoGrow();let i=this.#o,a=this.#e.buildClient({endpoint:n==="resume"?o.resumeUrl(t):o.forkUrl(t),initialMessages:[],follows:this.#e.client()?.messages??this.#n,onSaved:s=>{i===this.#o&&(this.#n=s,this.#e.releaseClient())}});this.#a=a;try{await a.send(r)}finally{this.#a===a&&(this.#a=null,this.#e.continuationEnded())}}#c(t){this.#e.hint.textContent=t,this.#e.hint.hidden=!1,this.#e.input.focus()}async rehydrate(){this.#r+=1;let t=this.#r;this.#e.element.setAttribute("data-restoring","");let n;try{n=await this.#e.conversationStore().loadMessages(this.#t)}finally{t===this.#r&&this.#e.element.removeAttribute("data-restoring")}if(t!==this.#r)return;let o=this.#e.conversationStore().loadCheckpoint(this.#t);if(n!==null){let r=this.#e.strings().callNotFinished,i=cl(n,a=>({id:ve(),role:"tool",content:r,toolCallId:a,metadata:{outcome:Ue.INTERRUPTED}}),new Set(o===null?[]:[o.toolCallId]));this.#n=i;for(let a of i)this.replay(a)}if(o!==null){await this.#h(o);return}this.#d(n)}#d(t){let n=t?.at(-1);n===void 0||n.role!==De.USER||this.#e.transcript.appendNotice("\u26A0",this.#e.strings().runInterrupted,"interrupted")}replay(t){let n=typeof t.content=="string"?t.content:"";if(t.role===De.USER){let o=lm(t);if(n!==""||o.length>0){let r=this.#e.appendMessage(De.USER,n);o.length>0&&r.appendChild(vl(o))}return}if(t.role===De.ASSISTANT){if(n!==""){let o=this.#e.appendMessage(De.ASSISTANT,n);o.classList.add("message--restored"),this.#e.actions.attach(o)}for(let o of lC(t.toolCalls)){let r={id:o.id,name:o.function.name,args:this.#u(o.function.arguments)};if(this.#e.transcript.noticeIfSkillLoad(r))continue;this.#e.transcript.setCardElement(r.id,this.#e.transcript.cardFor(r).element);let i=this.#e.tools.resolve(r.name)?.render;i!==void 0&&this.#e.transcript.renderToolOutput(i,r)}return}if(t.role==="activity"){let o=t;typeof o.activityType=="string"&&this.#e.activities.draw(t.id,o.activityType,o.content);return}if(t.role==="tool"){let o=this.#e.transcript.card(t.toolCallId);o!==void 0&&o.settle($o(dl(t,"outcome")),jn(t.content))}}#u(t){if(typeof t!="string")return{};try{let n=JSON.parse(t);if(typeof n=="object"&&n!==null)return n}catch{}return{}}async#h(t){this.#e.conversationStore().saveCheckpoint(this.#t,null);let n=this.#e.ensureClient();n.addToolResult(t.toolCallId,JSON.stringify(this.#e.navigationResult().call(this.#e.element,t))),await n.resume()}};function lC(e){return Array.isArray(e)?e.filter(uC):[]}function uC(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.id=="string"&&typeof t.function?.name=="string"}var cC=8,kl=class{element;#e;#t;#n;#o;#r;#i=null;#a;#l=[];#c="";#d;#u;#h="";#s=null;constructor(t,n=pe){this.#e=t,this.#a=n,this.element=document.createElement("div"),this.element.className="drawer",this.element.setAttribute("part","drawer"),this.element.hidden=!0;let o=document.createElement("div");o.className="drawer-backdrop",o.setAttribute("part","drawer-backdrop"),o.addEventListener("click",()=>this.close()),this.#t=document.createElement("div"),this.#t.className="drawer-panel",this.#t.setAttribute("part","drawer-panel"),this.#t.setAttribute("role","dialog"),this.#t.setAttribute("aria-modal","true"),this.#t.setAttribute("aria-label",n.chatHistory),this.#t.addEventListener("keydown",i=>this.#b(i));let r=document.createElement("div");r.className="drawer-header",r.setAttribute("part","drawer-header"),this.#n=document.createElement("span"),this.#n.className="drawer-title",this.#n.setAttribute("part","drawer-title"),this.#n.textContent=n.chats,this.#o=document.createElement("button"),this.#o.type="button",this.#o.className="drawer-new",this.#o.setAttribute("part","drawer-new"),this.#o.textContent=n.newChat,this.#o.addEventListener("click",()=>{this.close(),this.#e.onNew()}),this.#d=document.createElement("button"),this.#d.type="button",this.#d.className="drawer-close",this.#d.setAttribute("part","drawer-close"),this.#d.title=n.closeHistory,this.#d.setAttribute("aria-label",n.closeHistory),this.#d.append(document.createTextNode("\xD7")),this.#d.addEventListener("click",()=>this.close()),r.append(this.#n,this.#o,this.#d),this.#u=document.createElement("input"),this.#u.type="search",this.#u.className="drawer-filter",this.#u.setAttribute("part","drawer-filter"),this.#u.placeholder=n.searchConversations,this.#u.setAttribute("aria-label",n.searchConversations),this.#u.addEventListener("input",()=>{this.#h=this.#u.value.trim().toLowerCase(),this.#g()}),this.#r=document.createElement("div"),this.#r.className="drawer-list",this.#r.setAttribute("part","drawer-list"),this.#t.append(r,this.#u,this.#r),this.element.append(o,this.#t)}setRelativeTimeFormatter(t){this.#i=t}#f(t){return this.#i!==null?this.#i(t):Co(t,void 0,this.#a)}setStrings(t){this.#a=t,this.#t.setAttribute("aria-label",t.chatHistory),this.#n.textContent=t.chats,this.#o.textContent=t.newChat,this.#d.title=t.closeHistory,this.#d.setAttribute("aria-label",t.closeHistory),this.#u.placeholder=t.searchConversations,this.#u.setAttribute("aria-label",t.searchConversations),this.#g()}isOpen(){return!this.element.hidden}open(){this.isOpen()||(this.#s=this.#m(),this.element.hidden=!1,this.#o.focus())}close(){this.isOpen()&&(this.element.hidden=!0,this.#s?.focus(),this.#s=null)}toggle(){this.isOpen()?this.close():this.open()}#m(){return this.element.getRootNode().activeElement}#b(t){if(t.key==="Escape"){t.preventDefault(),this.close();return}if(t.key!=="Tab")return;let n=Array.from(this.#t.querySelectorAll("button, input, [tabindex]")).filter(a=>!a.hidden),o=n[0],r=n[n.length-1],i=this.#m();t.shiftKey&&i===o?(t.preventDefault(),r?.focus()):!t.shiftKey&&i===r&&(t.preventDefault(),o?.focus())}setThreads(t,n){this.#l=t,this.#c=n,this.#g()}#g(){this.#r.replaceChildren();let t=this.#l.length<cC;this.#u.hidden=t,t&&this.#h!==""&&(this.#u.value="",this.#h="");let n=this.#y();if(n.length===0){let o=document.createElement("div");o.className="drawer-empty",o.setAttribute("part","drawer-empty"),o.textContent=this.#l.length===0?this.#a.noConversations:this.#a.noMatches,this.#r.appendChild(o);return}for(let o of n)this.#r.appendChild(this.#p(o))}#y(){return this.#h===""?this.#l:this.#l.filter(t=>t.title.toLowerCase().includes(this.#h)||t.preview.toLowerCase().includes(this.#h))}#p(t){let n=document.createElement("div");n.className="drawer-row",n.setAttribute("part","drawer-row"),t.threadId===this.#c&&n.classList.add("drawer-row--active");let o=document.createElement("button");o.type="button",o.className="drawer-row-select",o.setAttribute("part","drawer-row-select");let r=document.createElement("span");r.className="drawer-row-title",r.setAttribute("part","drawer-row-title"),r.textContent=t.title;let i=document.createElement("span");i.className="drawer-row-time",i.setAttribute("part","drawer-row-time"),i.textContent=this.#f(t.updatedAt);let a=document.createElement("span");a.className="drawer-row-preview",a.setAttribute("part","drawer-row-preview"),a.textContent=t.preview,o.append(r,i,a),o.addEventListener("click",()=>{this.close(),this.#e.onSelect(t.threadId)});let s=document.createElement("button");s.type="button",s.className="drawer-row-rename",s.setAttribute("part","drawer-row-rename"),s.title=this.#a.rename,s.setAttribute("aria-label",this.#a.renameConversation),s.textContent="\u270E",s.addEventListener("click",()=>this.#E(n,t));let u=document.createElement("button");u.type="button",u.className="drawer-row-delete",u.setAttribute("part","drawer-row-delete"),u.title=this.#a.delete,u.setAttribute("aria-label",this.#a.deleteConversation),u.textContent="\u{1F5D1}",u.addEventListener("click",()=>this.#w(n,t));let l=document.createElement("div");return l.className="drawer-row-actions",l.setAttribute("part","drawer-row-actions"),l.append(s,u),n.append(o,l),n}#E(t,n){let o=document.createElement("input");o.type="text",o.className="drawer-rename-input",o.setAttribute("part","drawer-rename-input"),o.value=n.title;let r=!1,i=()=>{if(r)return;r=!0;let s=o.value.trim();s===""||s===n.title?this.#g():this.#e.onRename(n.threadId,s)},a=()=>{r||(r=!0,this.#g())};o.addEventListener("keydown",s=>{s.key==="Enter"?(s.preventDefault(),i()):s.key==="Escape"&&(s.preventDefault(),s.stopPropagation(),a())}),o.addEventListener("blur",()=>i()),t.replaceChildren(o),o.focus(),o.select()}#w(t,n){let o=document.createElement("div");o.className="drawer-confirm",o.setAttribute("part","drawer-confirm");let r=document.createElement("span");r.className="drawer-confirm-label",r.setAttribute("part","drawer-confirm-label"),r.textContent=this.#a.deletePrompt;let i=document.createElement("button");i.type="button",i.className="drawer-confirm-yes",i.setAttribute("part","drawer-confirm-yes"),i.textContent=this.#a.delete,i.addEventListener("click",()=>this.#e.onDelete(n.threadId));let a=document.createElement("button");a.type="button",a.className="drawer-confirm-no",a.setAttribute("part","drawer-confirm-no"),a.textContent=this.#a.cancel,a.addEventListener("click",()=>this.#g()),o.append(r,i,a),t.replaceChildren(o)}};var Il=class{#e=null;open(){return this.#e=new AbortController,this.#e.signal}close(){this.#e=null}abort(){this.#e?.abort()}};function Po(e){return e!=="page"}var dC=new Set([null,"","floating","bottom-left"]);function Al(e){return dC.has(e)}function Gt(e,t,n=at){let o=Math.min(n,Math.max(0,(t.width-e.width)/2)),r=Math.min(n,Math.max(0,(t.height-e.height)/2));return{left:Math.max(t.left+o,Math.min(e.left,t.left+t.width-e.width-o)),top:Math.max(t.top+r,Math.min(e.top,t.top+t.height-e.height-r))}}function Mo(e,t,n=Xt){let o=e.right-e.left,r=e.bottom-e.top,i=Math.max(t.left+n,Math.min(e.left,t.left+t.width-n-o)),a=Math.max(t.top+n,Math.min(e.top,t.top+t.height-n-r));return{left:i,top:a,right:i+o,bottom:a+r}}var pC=4,hC=16,fC=64;function Ox(e,t){let n=!1,{signal:o}=t;e.addEventListener("click",a=>{!n||a.detail===0||(n=!1,a.stopPropagation(),a.preventDefault())},{capture:!0,signal:o}),e.addEventListener("pointerdown",a=>{if(n=!1,!t.enabled())return;let s=t.rect(),u=a.clientX,l=a.clientY,d=!1,h=f=>{let p=f.clientX-u,b=f.clientY-l;if(!d&&Math.hypot(p,b)<pC)return;d=!0,e.setAttribute("data-dragging","true");let v=Gt({...s,left:s.left+p,top:s.top+b},t.viewport());t.apply(v.left,v.top)},g=f=>{if(window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",g),!d)return;e.removeAttribute("data-dragging"),n=!0;let p=Gt({...s,left:s.left+(f.clientX-u),top:s.top+(f.clientY-l)},t.viewport());t.commit(p.left,p.top)};window.addEventListener("pointermove",h),window.addEventListener("pointerup",g),window.addEventListener("pointercancel",g)},{signal:o});let r=null,i=()=>{if(r===null)return;let{left:a,top:s}=r;r=null,t.commit(a,s)};e.addEventListener("keydown",a=>{if(!t.enabled())return;let s=a.shiftKey?fC:hC,u=t.rect(),l=null;if(a.key==="ArrowLeft"?l={left:u.left-s,top:u.top}:a.key==="ArrowRight"?l={left:u.left+s,top:u.top}:a.key==="ArrowUp"?l={left:u.left,top:u.top-s}:a.key==="ArrowDown"&&(l={left:u.left,top:u.top+s}),l===null)return;a.preventDefault();let d=Gt({...u,...l},t.viewport());t.apply(d.left,d.top),r=d},{signal:o}),e.addEventListener("keyup",i,{signal:o}),e.addEventListener("blur",i,{signal:o})}function Lo(e,t,n,o){return{hostInset:$x({top:n.y==="top"?e.top:null,right:n.x==="right"?o.width-e.right:null,bottom:n.y==="bottom"?o.height-e.bottom:null,left:n.x==="left"?e.left:null}),launcherInset:$x({top:n.y==="top"?t.top-e.top:null,right:n.x==="right"?e.right-(t.left+t.width):null,bottom:n.y==="bottom"?e.bottom-(t.top+t.height):null,left:n.x==="left"?t.left-e.left:null})}}function $x(e){let t=n=>n===null?"auto":`${Math.round(n)}px`;return`${t(e.top)} ${t(e.right)} ${t(e.bottom)} ${t(e.left)}`}function um(e,t,n,o,r=at){let i=n.left+n.width-e.left,a=e.left+e.width-n.left,s=n.top+n.height-e.top,u=e.top+e.height-n.top,l={x:i>=a?"left":"right",y:s>=u?"top":"bottom"},d=l.x==="left"?e.left:e.left+e.width-t.width,h=l.y==="top"?e.top:e.top+e.height-t.height,g=Mo({left:d,top:h,right:d+t.width,bottom:h+t.height},n,r);return{corner:l,...Lo(g,e,l,o)}}var mC="button, a[href], input, select, textarea, [contenteditable]";function Px(e,t){e.addEventListener("pointerdown",n=>{if(n.button!==0||!t.enabled()||gC(n,e))return;let o=t.rect(),r=n.clientX,i=n.clientY,a=!1,s=(d,h)=>{let g=d-r,f=h-i;return{left:o.left+g,top:o.top+f,right:o.right+g,bottom:o.bottom+f}},u=d=>{!a&&Math.hypot(d.clientX-r,d.clientY-i)<4||(a=!0,e.setAttribute("data-dragging","true"),t.apply(s(d.clientX,d.clientY),o))},l=d=>{window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",l),window.removeEventListener("pointercancel",l),a&&(e.removeAttribute("data-dragging"),t.commit(s(d.clientX,d.clientY),o))};n.preventDefault(),window.addEventListener("pointermove",u),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",l)})}function gC(e,t){let n=e.composedPath();return n.slice(0,n.indexOf(t)).some(o=>o instanceof Element&&o.matches(mC))}function Lx(e,t){let n=document.createElement("div");n.className=`resize-handle resize-handle--${Rl(e)}`,n.setAttribute("part",`resize-handle resize-handle-${Rl(e)}`),n.setAttribute("role","separator"),e.x===void 0?n.setAttribute("aria-orientation","horizontal"):e.y===void 0&&n.setAttribute("aria-orientation","vertical"),n.setAttribute("aria-label",t.label),n.tabIndex=0,n.addEventListener("pointerdown",i=>{let a=t.axis();if(a==="none"||!Mx(e,a))return;let s=t.rect(),u=d=>{t.apply(cm(e,a,s,d.clientX,d.clientY))},l=d=>{window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",l),n.removeAttribute("data-dragging"),t.commit(cm(e,a,s,d.clientX,d.clientY))};n.setAttribute("data-dragging","true"),window.addEventListener("pointermove",u),window.addEventListener("pointerup",l),i.preventDefault()});let o=null,r=()=>{if(o===null)return;let i=o;o=null,t.commit(i)};return n.addEventListener("keydown",i=>{let a=t.axis();if(a==="none"||!Mx(e,a))return;let s=i.shiftKey?64:16,u=t.rect(),l=vC[i.key];if(l===void 0||l.x!==0&&e.x===void 0||l.y!==0&&e.y===void 0)return;i.preventDefault();let d=(e.x==="left"?u.left:u.right)+l.x*s,h=(e.y==="top"?u.top:u.bottom)+l.y*s,g=cm(e,a,u,d,h);t.apply(g),o=g}),n.addEventListener("keyup",r),n.addEventListener("blur",r),n}var vC={ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0},ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1}};function Rl(e){return[e.y,e.x].filter(t=>t!==void 0).join("-")}function Mx(e,t){return t==="both"||e.x!==void 0}function cm(e,t,n,o,r){let i=e.x==="left"?Math.min(o,n.right-280):n.left,a=e.x==="right"?Math.max(o,n.left+280):n.right,s=t==="both",u=s&&e.y==="top"?Math.min(r,n.bottom-240):n.top,l=s&&e.y==="bottom"?Math.max(r,n.top+240):n.bottom;return{left:i,top:u,right:a,bottom:l}}var zx="ag-ui-chat:size",dm="ag-ui-chat:launcher";function bC(e){if(typeof e!="object"||e===null)return null;let{left:t,top:n}=e;return typeof t=="number"&&typeof n=="number"?{left:t,top:n}:null}function Dx(e,t){return e.width>=t.width-1&&e.height>=t.height-1}function Ux(e,t,n){let o=r=>`${Math.round(r)}px`;return[e.y==="top"?o(t.top):"auto",e.x==="right"?o(n.width-t.right):"auto",e.y==="bottom"?o(n.height-t.bottom):"auto",e.x==="left"?o(t.left):"auto"].join(" ")}var yC=[{y:"top"},{y:"bottom"},{x:"left"},{x:"right"},{x:"left",y:"top"},{x:"right",y:"top"},{x:"left",y:"bottom"},{x:"right",y:"bottom"}],Cl=class{#e;constructor(t){this.#e=t}enablePanelDrag(t){Px(t,{enabled:()=>!this.#e.collapsed()&&this.#f(),rect:()=>this.#e.element.getBoundingClientRect(),apply:(n,o)=>this.#w(n,o),commit:(n,o)=>this.#T(n,o)})}enableLauncherDrag(t){Ox(this.#e.launcher,{signal:t,enabled:()=>this.#e.collapsed()&&this.#f(),rect:()=>this.#g(),viewport:()=>this.#m(),apply:(n,o)=>this.#p(n,o),commit:(n,o)=>this.#E(n,o)})}mountResizeGrips(t){for(let n of yC){let o=Lx(n,{axis:()=>this.#c(),rect:()=>this.#e.element.getBoundingClientRect(),apply:r=>this.#N(n,r),commit:r=>this.#H(n,r),label:this.#e.strings().resizePanel});o.tabIndex=-1,o.setAttribute("aria-hidden","true"),this.#i.set(Rl(n),o),t.appendChild(o)}this.#O()}restoreSize(){this.#s(this.#M())}probe=document.createElement("div");#t=null;#n=null;#o=null;#r={x:"right",y:"bottom"};#i=new Map;#a(t){let n=this.#m(),o=n.left+at,r=n.top+at,i=n.left+n.width-at,a=n.top+n.height-at;return{left:Math.min(Math.max(t.left,o),t.right),top:Math.min(Math.max(t.top,r),t.bottom),right:Math.max(Math.min(t.right,i),t.left),bottom:Math.max(Math.min(t.bottom,a),t.top)}}dragging(){return this.#e.launcher.hasAttribute("data-dragging")||this.#e.root.querySelector(".header[data-dragging]")!==null}describeSurface(){let t=this.#e.element.getBoundingClientRect(),n=this.#m(),o=Dx(t,n);return{placement:this.#e.element.getAttribute("placement"),collapsed:this.#e.collapsed(),collapsible:this.#e.collapsible(),movable:this.#f()&&!o,draggable:this.#f(),fullBleed:o,box:{left:Math.round(t.left),top:Math.round(t.top),width:Math.round(t.width),height:Math.round(t.height)},viewport:{left:Math.round(n.left),top:Math.round(n.top),width:Math.round(n.width),height:Math.round(n.height)}}}moveTo(t,n={}){if(!this.#f())return!1;let o=n.announce===!0?this.#l():null,r=this.#m(),i=this.#e.element.getBoundingClientRect();if(Dx(i,r))return!1;let[a,s]=t.split("-"),u=r.left+Xt,l=r.top+Xt,d=s==="left"?u:Math.max(u,r.left+r.width-Xt-i.width),h=a==="top"?l:Math.max(l,r.top+r.height-Xt-i.height),g={left:d,top:h,right:d+i.width,bottom:h+i.height},f=this.#e.launcher.offsetWidth,p=this.#e.launcher.offsetHeight;return this.#P(g,{left:s==="left"?g.left:g.right-f,top:a==="top"?g.top:g.bottom-p,width:f,height:p}),this.#x(),o!==null&&this.#e.announceSurfaceChange(this.#e.strings().chatMoved,o),!0}#l(){let t=this.#e.element.style.getPropertyValue("--ag-ui-inset"),n=this.#e.element.style.getPropertyValue("--ag-ui-launcher-inset"),o=this.#e.element.getAttribute("data-expand-corner"),r=this.#t,i=this.#n,a=this.#o;return()=>{this.#h("--ag-ui-inset",t),this.#h("--ag-ui-launcher-inset",n),o===null?this.#e.element.removeAttribute("data-expand-corner"):this.#e.element.setAttribute("data-expand-corner",o),this.#t=r,this.#n=i,this.#o=a,r===null?this.#e.clearPreference(dm):this.#x(),this.syncResizeAnchor()}}#c(){switch(this.#e.element.getAttribute("placement")){case"full":case"page":return"none";case"sidebar":case"side":return"width";default:return"both"}}#d(){let t=this.#e.element.getBoundingClientRect(),n=this.#e.element.style.getPropertyValue("--ag-ui-width"),o=this.#e.element.style.getPropertyValue("--ag-ui-height"),r=this.#u(t,-1),i=r.x===null||r.y===null?this.#u(t,1):r;return this.#h("--ag-ui-width",n),this.#h("--ag-ui-height",o),{x:r.x??i.x??"right",y:r.y??i.y??"bottom"}}#u(t,n){this.#s({width:t.width+n,height:t.height+n});let o=this.#e.element.getBoundingClientRect(),r=(i,a)=>Math.abs(i-a)>=.5;return{x:r(o.width,t.width)?r(o.left,t.left)?"right":"left":null,y:r(o.height,t.height)?r(o.top,t.top)?"bottom":"top":null}}syncResizeAnchor(){if(!this.#e.connected())return;let t=this.#o??this.#d();this.#r=t,this.#e.element.setAttribute("data-resize-anchor",`${t.y}-${t.x}`),this.#O()}#h(t,n){if(n===""){this.#e.element.style.removeProperty(t);return}this.#e.element.style.setProperty(t,n)}#s(t){let n=this.#c();n!=="none"&&(t.width!==void 0&&this.#e.element.style.setProperty("--ag-ui-width",`${t.width}px`),t.height!==void 0&&n==="both"&&this.#e.element.style.setProperty("--ag-ui-height",`${t.height}px`))}releaseOwnedAxes(){let t=this.#c();t!=="both"&&this.#e.element.style.removeProperty("--ag-ui-height"),t==="none"&&this.#e.element.style.removeProperty("--ag-ui-width")}#f(){return this.#e.element.getAttribute("data-launcher-drag")!=="false"&&Al(this.#e.element.getAttribute("placement"))}#m(){let t=window.visualViewport,n=t?.width??window.innerWidth,o=t?.height??window.innerHeight,r=getComputedStyle(this.probe),i=u=>{let l=Number.parseFloat(r.getPropertyValue(u));return Number.isFinite(l)?l:0},a=i("padding-left"),s=i("padding-top");return{left:a,top:s,width:Math.max(0,n-a-i("padding-right")),height:Math.max(0,o-s-i("padding-bottom"))}}#b(){let t=document.documentElement;return{width:t.clientWidth||window.innerWidth,height:t.clientHeight||window.innerHeight}}publishVisualViewport(){let t=window.visualViewport;if(t==null)return;let n=this.#b().height;if(Math.abs(t.height-n)<1){this.#e.element.style.removeProperty("--ag-ui-visual-viewport-height"),this.#e.element.style.removeProperty("--ag-ui-visual-viewport-inset-bottom"),this.#e.element.style.removeProperty("--ag-ui-visual-viewport-inset-top");return}this.#e.element.style.setProperty("--ag-ui-visual-viewport-height",`${Math.round(t.height)}px`);let o=n-t.height-t.offsetTop;this.#e.element.style.setProperty("--ag-ui-visual-viewport-inset-bottom",`${Math.max(0,Math.round(o))}px`),this.#e.element.style.setProperty("--ag-ui-visual-viewport-inset-top",`${Math.max(0,Math.round(t.offsetTop))}px`)}#g(){let t=this.#e.launcher.offsetWidth,n=this.#e.launcher.offsetHeight,o=this.#t;if(o!==null)return{left:o.left,top:o.top,width:t,height:n};let r=this.#e.launcher.getBoundingClientRect();return{left:r.left+r.width/2-t/2,top:r.top+r.height/2-n/2,width:t,height:n}}#y(t){if(!this.#f())return;this.#t=t,this.#n=null;let n=this.#e.element.getBoundingClientRect(),o=um(this.#g(),{width:n.width,height:n.height},this.#m(),this.#b());this.#e.element.style.setProperty("--ag-ui-inset",o.hostInset),this.#e.element.style.setProperty("--ag-ui-launcher-inset",o.launcherInset),this.#o=o.corner,this.#e.element.setAttribute("data-expand-corner",`${o.corner.y}-${o.corner.x}`),this.syncResizeAnchor()}#p(t,n){this.#y({left:t,top:n})}#E(t,n){this.#p(t,n),this.#x()}#w(t,n){if(!this.#f())return{held:t,launcher:null};if(this.#t===null){let u=this.#g();this.#t={left:u.left,top:u.top}}let o=this.#t,r=Mo(t,this.#m(),at),i=this.#o??this.#r;this.#e.element.style.setProperty("--ag-ui-inset",Ux(i,r,this.#b())),this.#n={left:r.left,top:r.top};let a={...this.#g(),left:o.left+(r.left-n.left),top:o.top+(r.top-n.top)},s={...a,...Gt(a,this.#m())};return this.#e.element.style.setProperty("--ag-ui-launcher-inset",Lo(r,s,i,this.#b()).launcherInset),{held:r,launcher:s}}#T(t,n){let{held:o,launcher:r}=this.#w(t,n);r!==null&&(this.#P(o,r),this.#x())}#P(t,n){let o=this.#m(),r=this.#b(),i={width:t.right-t.left,height:t.bottom-t.top},{corner:a}=um(n,i,o,r),s=Lo(t,n,a,r);this.#e.element.style.setProperty("--ag-ui-inset",s.hostInset),this.#e.element.style.setProperty("--ag-ui-launcher-inset",s.launcherInset),this.#t={left:n.left,top:n.top},this.#n={left:t.left,top:t.top},this.#o=a,this.#e.element.setAttribute("data-expand-corner",`${a.y}-${a.x}`),this.syncResizeAnchor()}#k(t){if(!this.#f())return;let n=this.#e.element.getBoundingClientRect(),o=Mo({left:t.left,top:t.top,right:t.left+n.width,bottom:t.top+n.height},this.#m(),at),r=this.#g(),i={...r,left:r.left+(o.left-t.left),top:r.top+(o.top-t.top)};this.#P(o,{...i,...Gt(i,this.#m())})}#x(){let t=this.#t;if(t===null)return;let n=this.#n;this.#e.writePreference(dm,JSON.stringify(n===null?t:{...t,panel:n}))}restoreLauncherPosition(){let t=this.#I(),n=this.#t??t;if(n===null)return;let o=this.#n??t?.panel??null;if(o!==null){this.#t={left:n.left,top:n.top},this.#k(o);return}let r=this.#g();this.#y(Gt({...r,left:n.left,top:n.top},this.#m()))}#I(){let t=this.#e.readPreference(dm);if(t===null)return null;try{let n=JSON.parse(t);if(typeof n!="object"||n===null)return null;let{left:o,top:r,panel:i}=n;if(typeof o!="number"||typeof r!="number")return null;let a=bC(i);return a===null?{left:o,top:r}:{left:o,top:r,panel:a}}catch{return null}}releaseLauncherPosition(){this.#f()||(this.#t=null,this.#n=null,this.#o=null,this.#e.element.style.removeProperty("--ag-ui-inset"),this.#e.element.style.removeProperty("--ag-ui-launcher-inset"),this.#e.element.removeAttribute("data-expand-corner"))}#N(t,n){if(n=this.#a(n),this.#s({width:n.right-n.left,height:n.bottom-n.top}),t.x!==this.#r.x&&t.y!==this.#r.y)return n;let o=this.#r;if(this.#e.element.style.setProperty("--ag-ui-inset",Ux(o,n,this.#b())),this.#t!==null){let r=this.#e.launcher.offsetWidth;this.#t={left:o.x==="left"?n.left:n.right-r,top:o.y==="top"?n.top:n.bottom-r}}return this.#n!==null&&(this.#n={left:n.left,top:n.top}),n}#H(t,n){let o=this.#N(t,n);this.#v({width:o.right-o.left,height:o.bottom-o.top}),this.#x(),this.syncResizeAnchor()}#O(){let t=`${this.#r.y==="top"?"bottom":"top"}-${this.#r.x==="left"?"right":"left"}`;for(let[n,o]of this.#i){let r=n===t;o.tabIndex=r?0:-1,r?o.removeAttribute("aria-hidden"):o.setAttribute("aria-hidden","true")}}#v(t){let n={...this.#M(),...t};this.#e.writePreference(zx,JSON.stringify(n))}#M(){let t=this.#e.readPreference(zx);if(t===null)return{};try{let n=JSON.parse(t);return typeof n=="object"&&n!==null?n:{}}catch{return{}}}};var Nl=class{region=document.createElement("div");#e=null;mount(){this.region.className="sr-only",this.region.setAttribute("role","status"),this.region.setAttribute("aria-live","polite"),this.region.setAttribute("aria-atomic","true")}announce(t){this.#e!==null&&clearTimeout(this.#e),this.region.textContent=t,this.#e=setTimeout(()=>{this.#e=null,this.region.textContent=""},Lg)}dispose(){this.#e!==null&&(clearTimeout(this.#e),this.#e=null)}};function Ol(e,t,n,o){let r=document.createElement("div");r.className=`run-notice run-notice--${n}`,r.setAttribute("part",`run-notice run-notice-${n}`),r.setAttribute("role","status");let i=document.createElement("span");i.className="run-notice-icon",i.setAttribute("part","run-notice-icon"),i.textContent=e,i.setAttribute("aria-hidden","true");let a=document.createElement("span");if(a.className="run-notice-text",a.setAttribute("part","run-notice-text"),a.textContent=t,r.append(i,a),o!==void 0){let s=document.createElement("button");s.type="button",s.className="run-notice-undo",s.setAttribute("part","run-notice-undo"),s.textContent=o.label,s.addEventListener("click",()=>{s.disabled=!0,o.onActivate()}),r.append(s)}return r}var $l=class{element;get agent(){return this.#r}#e;#t;#n;#o=new Map;#r=null;constructor(t=pe){this.element=document.createElement("div"),this.element.className="subagent",this.element.setAttribute("part","subagent"),this.#e=document.createElement("button"),this.#e.type="button",this.#e.className="subagent-row",this.#e.setAttribute("part","subagent-row"),this.#e.setAttribute("aria-expanded","false"),this.#e.disabled=!0;let n=document.createElement("span");n.className="subagent-icon",n.setAttribute("part","subagent-icon"),n.setAttribute("aria-hidden","true"),this.#t=document.createElement("span"),this.#t.className="subagent-status",this.#t.setAttribute("part","subagent-status"),this.#t.textContent=t.subAgentWorking,this.#e.append(n,this.#t),this.#n=document.createElement("div"),this.#n.className="subagent-steps",this.#n.setAttribute("part","subagent-steps"),this.#n.setAttribute("role","list"),this.#n.setAttribute("aria-label",t.subAgentSteps),this.#n.hidden=!0,this.#e.addEventListener("click",()=>{this.#l(this.#e.getAttribute("aria-expanded")!=="true")}),this.element.append(this.#e,this.#n)}report(t){this.element.setAttribute("data-phase",t.phase),t.agent!==null&&(this.#r=t.agent,this.element.setAttribute("data-agent",t.agent)),t.status!==null&&(this.#t.textContent=t.status),t.tool!==null&&this.#i(t.tool)}#i(t){let n=this.#o.get(t.toolCallId)??this.#a(t);if(t.ok===null){n.removeAttribute("data-ok");return}n.setAttribute("data-ok",String(t.ok))}#a(t){let n=document.createElement("div");n.className="subagent-step",n.setAttribute("part","subagent-step"),n.setAttribute("role","listitem"),n.setAttribute("data-tool-call-id",t.toolCallId);let o=document.createElement("span");o.className="subagent-step-icon",o.setAttribute("part","subagent-step-icon"),o.setAttribute("aria-hidden","true");let r=document.createElement("span");return r.className="subagent-step-name",r.setAttribute("part","subagent-step-name"),r.textContent=t.name,n.append(o,r),this.#n.appendChild(n),this.#o.set(t.toolCallId,n),this.#e.disabled=!1,n}#l(t){this.#n.hidden=!t,this.#e.setAttribute("aria-expanded",String(t))}};var wC=Object.values(Mn);function jx(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}function zo(e){return typeof e=="string"&&e!==""?e:null}function xC(e){let t=jx(e);if(t===null)return null;let n=zo(t.toolCallId),o=zo(t.name),r=t.ok;return n===null||o===null||r!==null&&typeof r!="boolean"?null:{toolCallId:n,name:o,ok:r}}function Hx(e){let t=jx(e);if(t===null)return null;let n=zo(t.delegationId),o=t.phase;return n===null||typeof o!="string"||!wC.includes(o)?null:{delegationId:n,phase:o,agent:zo(t.agent),status:zo(t.status),tool:xC(t.tool)}}var Pl=class{#e;#t=new Map;#n=new Map;constructor(t){this.#e=t}report(t){let n=Hx(t);n!==null&&this.#i(n)}start(t,n,o){o!==null&&(this.#n.set(t,o),this.#i({delegationId:o,agent:n===""?null:n,phase:Mn.STARTED,status:ae(this.#e.strings().subAgentDelegatedTo,{agent:n}),tool:null}))}finish(t){this.#o(t,Mn.FINISHED,null)}fail(t,n){this.#o(t,Mn.FAILED,n===""?this.#e.strings().subAgentFailed:n)}clear(){this.#t.clear(),this.#n.clear()}#o(t,n,o){let r=this.#n.get(t);if(r===void 0)return;let i=this.#t.get(r)?.agent??null;this.#i({delegationId:r,agent:i,phase:n,status:o===null?this.#r(i):o,tool:null})}#r(t){let n=this.#e.strings();return t===null?n.subAgentWorking:ae(n.subAgentFinished,{agent:t})}#i(t){let n=this.#e.card(t.delegationId);if(n===void 0)return;let o=this.#t.get(t.delegationId);o===void 0&&(o=new $l(this.#e.strings()),this.#t.set(t.delegationId,o),n.subagentSlot.appendChild(o.element)),o.report(t),this.#e.follow()}};function pm(e){return{[ne.PENDING]:e.toolRunning,[ne.DEFERRED]:e.toolDeferred,[ne.DONE]:e.toolDone,[ne.ERROR]:e.toolError,[ne.DECLINED]:e.toolDeclined,[ne.INTERRUPTED]:e.toolInterrupted}}function _C(e){return{[ne.DONE]:e.resultLabel,[ne.ERROR]:e.errorLabel,[ne.DECLINED]:e.declinedLabel,[ne.INTERRUPTED]:e.interruptedLabel}}function EC(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}var Do=class{element;approvalSlot;subagentSlot;#e;#t;#n;#o;#r;#i;#a;args;#l;#c;#d=!1;constructor(t,n,o,r=pe,i={}){this.#a=r,this.args=n,this.#l=t,this.#c=i.formatPayload??null,this.element=document.createElement("div"),this.element.className="tool-call",this.element.setAttribute("part","tool-card"),this.element.setAttribute("data-tool-name",t),this.element.setAttribute("data-status",ne.PENDING),this.element.setAttribute("data-expanded","false");let a=document.createElement("div");a.className="tool-call-head",a.setAttribute("part","tool-card-head");let s=document.createElement("span");s.className="tool-call-icon",s.setAttribute("part","tool-card-icon"),s.setAttribute("aria-hidden","true");let u=document.createElement("span");u.className="tool-call-name",u.setAttribute("part","tool-card-name"),u.textContent=o??t,this.#e=document.createElement("span"),this.#e.className="tool-call-status",this.#e.setAttribute("part","tool-card-status"),this.#e.textContent=pm(r)[ne.PENDING],this.#t=document.createElement("span"),this.#t.className="tool-call-decision",this.#t.setAttribute("part","tool-card-decision"),this.#t.hidden=!0,a.append(s,u,this.#e,this.#t);let l=this.#h("args",r.argumentsLabel);this.#u(l.body,{kind:"arguments",toolName:t,args:n},JSON.stringify(n,null,2)),l.root.hidden=Object.keys(n).length===0;let d=this.#h("result",r.resultLabel);this.#o=d.root,this.#r=d.label,this.#i=d.body,d.root.hidden=!0,this.#n=document.createElement("button"),this.#n.type="button",this.#n.className="tool-call-toggle",this.#n.setAttribute("part","tool-card-toggle"),this.#n.setAttribute("aria-expanded","false"),this.#n.textContent=r.details,this.#n.addEventListener("click",()=>this.#f(!this.#s()));let h=document.createElement("div");h.className="tool-call-body",h.setAttribute("part","tool-card-body"),h.append(l.root,d.root),this.approvalSlot=document.createElement("div"),this.approvalSlot.className="tool-call-approval",this.approvalSlot.setAttribute("part","tool-card-approval"),this.subagentSlot=document.createElement("div"),this.subagentSlot.className="tool-call-subagent",this.subagentSlot.setAttribute("part","tool-card-subagent"),this.element.append(a,this.subagentSlot,this.#n,h,this.approvalSlot)}mark(t){this.#d||(this.element.setAttribute("data-status",t),this.#e.textContent=pm(this.#a)[t])}recordDecision(t){this.element.setAttribute("data-decision",t),this.#t.textContent=t==="approved"?this.#a.decisionApproved:this.#a.decisionDeclined,this.#t.hidden=!1}get settled(){return this.#d}settle(t,n){this.#d||(this.#d=!0,this.element.setAttribute("data-status",t),this.#e.textContent=pm(this.#a)[t],this.#r.textContent=_C(this.#a)[t],this.#u(this.#i,{kind:"result",toolName:this.#l,status:t,text:n},EC(n)),this.#o.hidden=!1)}#u(t,n,o){let r=this.#c===null?null:this.#c(n);if(r===null){t.textContent=o;return}if(t.setAttribute("data-formatted","true"),typeof r=="string"){t.textContent=r;return}t.replaceChildren(r)}#h(t,n){let o=document.createElement("div");o.className=`tool-call-section tool-call-section--${t}`,o.setAttribute("part",`tool-card-section tool-card-${t}-section`);let r=document.createElement("span");r.className="tool-call-section-label",r.setAttribute("part",`tool-card-section-label tool-card-${t}-label`),r.textContent=n;let i=document.createElement("pre");return i.className=`tool-call-${t}`,i.setAttribute("part",`tool-card-${t}`),o.append(r,i),{root:o,label:r,body:i}}#s(){return this.element.getAttribute("data-expanded")==="true"}#f(t){this.element.setAttribute("data-expanded",String(t)),this.#n.setAttribute("aria-expanded",String(t))}};var Gx=`
|
|
43
74
|
/* \u2500\u2500 Token defaults \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
44
75
|
Every public --ag-ui-* token is read here into a private --_* alias, and
|
|
45
76
|
only the alias is used by the rules below.
|
|
@@ -3808,95 +3839,95 @@ ${n}`,this.#e.autoGrow(),r.focus();let i=r.value.length;r.setSelectionRange(i,i)
|
|
|
3808
3839
|
border-right: none;
|
|
3809
3840
|
box-shadow: none;
|
|
3810
3841
|
}
|
|
3811
|
-
`;function
|
|
3842
|
+
`;function Fx(e){let t=new CSSStyleSheet;t.replaceSync(Gx),e.adoptedStyleSheets=[t]}function Ml(e,t,n){let o=document.createElement("slot");return o.name=e,o.className=t,o.innerHTML=n,o}function Uo(e,t,n){let o=document.createElement("button");o.type="button",o.className=`header-btn header-btn--${e}`,o.setAttribute("part",`header-button ${e}-button`),o.title=t,o.setAttribute("aria-label",t);let r=document.createElement("slot");return r.name=`icon-${e}`,r.append(document.createTextNode(n)),o.append(r),o}function Ll(e,t,n,o){let r=document.createElement("span");r.className="icon-holder",r.setAttribute("part",t);let i=document.createElement("slot");if(i.name=e,o!==null){let a=document.createElement("img");a.className="icon-img",a.src=o,a.alt="",i.append(a)}else n!==null&&(i.innerHTML=n);return r.append(i),r}function Vx(e){return e.getAttribute("data-unread-badge")!=="false"}function Zx(e){return e.getAttribute("data-launcher-icon-url")??e.getAttribute("data-icon-url")}var SC=new Set(["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DD","DIV","DL","DT","FIGCAPTION","FIGURE","FOOTER","H1","H2","H3","H4","H5","H6","HEADER","HR","MAIN","NAV","OL","P","SECTION","UL"]);function zl(e){let t=e.cloneNode(!0);for(let n of Array.from(t.querySelectorAll("button")))n.remove();return{text:IC(Bx(t)),html:t.innerHTML}}function Bx(e){if(e.nodeType===Node.TEXT_NODE)return e.nodeValue.replace(/\s+/g," ");if(e.nodeType!==Node.ELEMENT_NODE)return"";let t=e,n=t.tagName;if(n==="BR")return`
|
|
3812
3843
|
`;if(n==="PRE")return`
|
|
3813
3844
|
|
|
3814
|
-
${
|
|
3845
|
+
${qx(t)}
|
|
3815
3846
|
|
|
3816
3847
|
`;if(n==="TABLE")return`
|
|
3817
3848
|
|
|
3818
|
-
${
|
|
3849
|
+
${kC(t)}
|
|
3819
3850
|
|
|
3820
3851
|
`;if(n==="UL"||n==="OL")return`
|
|
3821
3852
|
|
|
3822
|
-
${
|
|
3853
|
+
${TC(t,n==="OL")}
|
|
3823
3854
|
|
|
3824
|
-
`;let
|
|
3855
|
+
`;let o=Wx(t);return SC.has(n)?`
|
|
3825
3856
|
|
|
3826
|
-
${
|
|
3857
|
+
${o}
|
|
3827
3858
|
|
|
3828
|
-
`:
|
|
3829
|
-
`)}function
|
|
3830
|
-
`)}function
|
|
3859
|
+
`:o}function Wx(e){let t="";for(let n of Array.from(e.childNodes))t+=Bx(n);return t}function TC(e,t){return Array.from(e.children).map((n,o)=>`${t?`${o+1}. `:"- "}${Wx(n).trim()}`).join(`
|
|
3860
|
+
`)}function kC(e){return Array.from(e.querySelectorAll("tr")).map(t=>Array.from(t.children).map(n=>qx(n).replace(/\s+/g," ").trim()).join(" ")).join(`
|
|
3861
|
+
`)}function qx(e){return e.textContent}function IC(e){return e.replace(/[^\S\n]+\n/g,`
|
|
3831
3862
|
`).replace(/\n{3,}/g,`
|
|
3832
3863
|
|
|
3833
|
-
`).trim()}var
|
|
3834
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Jw(t,e){return Kw(t)||Zw(t,e)||ex(t,e)||Qw()}function ex(t,e){if(t){if(typeof t=="string")return up(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?up(t,e):void 0}}var Ap=Object.entries,hp=Object.setPrototypeOf,tx=Object.isFrozen,nx=Object.getPrototypeOf,rx=Object.getOwnPropertyDescriptor,Ee=Object.freeze,Se=Object.seal,ir=Object.create,kp=typeof Reflect<"u"&&Reflect,dd=kp.apply,cd=kp.construct;Ee||(Ee=function(e){return e});Se||(Se=function(e){return e});dd||(dd=function(e,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];return e.apply(n,o)});cd||(cd=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return new e(...r)});var xn=we(Array.prototype.forEach),ox=we(Array.prototype.lastIndexOf),pp=we(Array.prototype.pop),qr=we(Array.prototype.push),ix=we(Array.prototype.splice),sr=Array.isArray,Yr=we(String.prototype.toLowerCase),rd=we(String.prototype.toString),fp=we(String.prototype.match),Wr=we(String.prototype.replace),mp=we(String.prototype.indexOf),sx=we(String.prototype.trim),ax=we(Number.prototype.toString),lx=we(Boolean.prototype.toString),gp=typeof BigInt>"u"?null:we(BigInt.prototype.toString),vp=typeof Symbol>"u"?null:we(Symbol.prototype.toString),Fe=we(Object.prototype.hasOwnProperty),Xr=we(Object.prototype.toString),Ne=we(RegExp.prototype.test),wn=dx(TypeError);function we(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return dd(t,e,r)}}function dx(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return cd(t,n)}}function ee(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Yr;if(hp&&hp(t,null),!sr(e))return t;let r=e.length;for(;r--;){let o=e[r];if(typeof o=="string"){let i=n(o);i!==o&&(tx(e)||(e[r]=i),o=i)}t[o]=!0}return t}function cx(t){for(let e=0;e<t.length;e++)Fe(t,e)||(t[e]=null);return t}function We(t){let e=ir(null);for(let r of Ap(t)){var n=Jw(r,2);let o=n[0],i=n[1];Fe(t,o)&&(sr(i)?e[o]=cx(i):i&&typeof i=="object"&&i.constructor===Object?e[o]=We(i):e[o]=i)}return e}function ux(t){switch(typeof t){case"string":return t;case"number":return ax(t);case"boolean":return lx(t);case"bigint":return gp?gp(t):"0";case"symbol":return vp?vp(t):"Symbol()";case"undefined":return Xr(t);case"function":case"object":{if(t===null)return Xr(t);let e=t,n=it(e,"toString");if(typeof n=="function"){let r=n(e);return typeof r=="string"?r:Xr(r)}return Xr(t)}default:return Xr(t)}}function it(t,e){for(;t!==null;){let r=rx(t,e);if(r){if(r.get)return we(r.get);if(typeof r.value=="function")return we(r.value)}t=nx(t)}function n(){return null}return n}function hx(t){try{return Ne(t,""),!0}catch{return!1}}var bp=Ee(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),od=Ee(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),id=Ee(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),px=Ee(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),sd=Ee(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),fx=Ee(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),yp=Ee(["#text"]),wp=Ee(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),ad=Ee(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),xp=Ee(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Hs=Ee(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),mx=Se(/{{[\w\W]*|^[\w\W]*}}/g),gx=Se(/<%[\w\W]*|^[\w\W]*%>/g),vx=Se(/\${[\w\W]*/g),bx=Se(/^data-[\-\w.\u00B7-\uFFFF]+$/),yx=Se(/^aria-[\-\w]+$/),Ep=Se(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),wx=Se(/^(?:\w+script|data):/i),xx=Se(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ex=Se(/^html$/i),Tx=Se(/^[a-z][.\w]*(-[.\w]+)+$/i),Tp=Se(/<[/\w!]/g),_p=Se(/<[/\w]/g),_x=Se(/<\/no(script|embed|frames)/i),Sx=Se(/\/>/i),qe={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Rp=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],Ax=Ee(ee({},Rp)),kx=(function(){let t={};return xn(Rp,e=>{t[e]=Se(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),Ee(t)})(),Rx=function(){return typeof window>"u"?null:window},Ix=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null,o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));let i="dompurify"+(r?"#"+r:"");try{return e.createPolicy(i,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},Sp=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Gt=function(e,n,r,o){return Fe(e,n)&&sr(e[n])?ee(o.base?We(o.base):{},e[n],o.transform):r},ld=function(e,n,r){let o=Fe(e,n)?e[n]:void 0;return o&&typeof o=="object"?We(o):r()};function Ip(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Rx(),e=R=>Ip(R);if(e.version="3.4.14",e.removed=[],!t||!t.document||t.document.nodeType!==qe.document||!t.Element)return e.isSupported=!1,e;let n=t.document,r=n,o=r.currentScript;t.DocumentFragment;let i=t.HTMLTemplateElement,s=t.Node,a=t.Element,l=t.NodeFilter,d=t.NamedNodeMap;d===void 0&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;let u=t.DOMParser,m=t.trustedTypes,w=a.prototype,p=it(w,"cloneNode"),h=it(w,"remove"),v=it(w,"nextSibling"),x=it(w,"childNodes"),S=it(w,"parentNode"),_=it(w,"shadowRoot"),O=it(w,"attributes"),G=s&&s.prototype?it(s.prototype,"nodeType"):null,b=s&&s.prototype?it(s.prototype,"nodeName"):null,A=s&&s.prototype?it(s.prototype,"ownerDocument"):null,E=function(f){return G?G(f):f.nodeType},I=function(f){return b?b(f):f.nodeName};if(typeof i=="function"){let R=n.createElement("template");R.content&&R.content.ownerDocument&&(n=R.content.ownerDocument)}let B,de="",Te,Ye=!1,cr=0,Id=function(){if(cr>0)throw wn('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},Sn=function(f){Id(),cr++;try{return B.createHTML(f)}finally{cr--}},pf=function(f){Id(),cr++;try{return B.createScriptURL(f)}finally{cr--}},ff=function(){return Ye||(Te=Ix(m,o),Ye=!0),Te},ao=n,na=ao.implementation,Cd=ao.createNodeIterator,mf=ao.createDocumentFragment,gf=ao.getElementsByTagName,vf=r.importNode,ue=Sp();e.isSupported=typeof Ap=="function"&&typeof S=="function"&&na&&na.createHTMLDocument!==void 0;let bf=mx,yf=gx,wf=vx,xf=bx,Ef=yx,Tf=wx,Nd=xx,_f=Tx,Od=Ep,he=null,ra=ee({},[...bp,...od,...id,...sd,...yp]),pe=null,oa=ee({},[...wp,...ad,...xp,...Hs]),dt=Object.seal(ir(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ur=null,Md=null,kt=Object.seal(ir(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ld=!0,ia=!0,Pd=!1,Dd=!0,Rt=!1,Ft=!0,$t=!1,sa=!1,lo=null,co=null,aa=!1,An=!1,uo=!1,ho=!1,Ud=!0,Hd=!1,Gd="user-content-",la=!0,da=!1,kn={},Rn=null,zd=ee({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),Fd=null,$d=ee({},["audio","video","img","source","image","track"]),Bd=null,jd=ee({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),po="http://www.w3.org/1998/Math/MathML",fo="http://www.w3.org/2000/svg",ct="http://www.w3.org/1999/xhtml",In=ct,ca=!1,ua=null,Sf=ee({},[po,fo,ct],rd),Vd=Ee(["mi","mo","mn","ms","mtext"]),ha=ee({},Vd),qd=Ee(["annotation-xml"]),pa=ee({},qd),Af=ee({},["title","style","font","a","script"]),hr=null,kf=["application/xhtml+xml","text/html"],Rf="text/html",ve=null,Cn=null,If=n.createElement("form"),Wd=function(f){return f instanceof RegExp||f instanceof Function},fa=function(){let f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Cn&&Cn===f)return;(!f||typeof f!="object")&&(f={}),f=We(f),hr=kf.indexOf(f.PARSER_MEDIA_TYPE)===-1?Rf:f.PARSER_MEDIA_TYPE,ve=hr==="application/xhtml+xml"?rd:Yr,he=Gt(f,"ALLOWED_TAGS",ra,{transform:ve}),pe=Gt(f,"ALLOWED_ATTR",oa,{transform:ve}),ua=Gt(f,"ALLOWED_NAMESPACES",Sf,{transform:rd}),Bd=Gt(f,"ADD_URI_SAFE_ATTR",jd,{transform:ve,base:jd}),Fd=Gt(f,"ADD_DATA_URI_TAGS",$d,{transform:ve,base:$d}),Rn=Gt(f,"FORBID_CONTENTS",zd,{transform:ve}),ur=Gt(f,"FORBID_TAGS",We({}),{transform:ve}),Md=Gt(f,"FORBID_ATTR",We({}),{transform:ve}),kn=Fe(f,"USE_PROFILES")?f.USE_PROFILES&&typeof f.USE_PROFILES=="object"?We(f.USE_PROFILES):f.USE_PROFILES:!1,Ld=f.ALLOW_ARIA_ATTR!==!1,ia=f.ALLOW_DATA_ATTR!==!1,Pd=f.ALLOW_UNKNOWN_PROTOCOLS||!1,Dd=f.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Rt=f.SAFE_FOR_TEMPLATES||!1,Ft=f.SAFE_FOR_XML!==!1,$t=f.WHOLE_DOCUMENT||!1,An=f.RETURN_DOM||!1,uo=f.RETURN_DOM_FRAGMENT||!1,ho=f.RETURN_TRUSTED_TYPE||!1,aa=f.FORCE_BODY||!1,Ud=f.SANITIZE_DOM!==!1,Hd=f.SANITIZE_NAMED_PROPS||!1,la=f.KEEP_CONTENT!==!1,da=f.IN_PLACE||!1,Od=hx(f.ALLOWED_URI_REGEXP)?f.ALLOWED_URI_REGEXP:Ep,In=typeof f.NAMESPACE=="string"?f.NAMESPACE:ct,ha=ld(f,"MATHML_TEXT_INTEGRATION_POINTS",()=>ee({},Vd)),pa=ld(f,"HTML_INTEGRATION_POINTS",()=>ee({},qd));let y=ld(f,"CUSTOM_ELEMENT_HANDLING",()=>ir(null));if(dt=ir(null),Fe(y,"tagNameCheck")&&Wd(y.tagNameCheck)&&(dt.tagNameCheck=y.tagNameCheck),Fe(y,"attributeNameCheck")&&Wd(y.attributeNameCheck)&&(dt.attributeNameCheck=y.attributeNameCheck),Fe(y,"allowCustomizedBuiltInElements")&&typeof y.allowCustomizedBuiltInElements=="boolean"&&(dt.allowCustomizedBuiltInElements=y.allowCustomizedBuiltInElements),Se(dt),Rt&&(ia=!1),uo&&(An=!0),kn&&(he=ee({},yp),pe=ir(null),kn.html===!0&&(ee(he,bp),ee(pe,wp)),kn.svg===!0&&(ee(he,od),ee(pe,ad),ee(pe,Hs)),kn.svgFilters===!0&&(ee(he,id),ee(pe,ad),ee(pe,Hs)),kn.mathMl===!0&&(ee(he,sd),ee(pe,xp),ee(pe,Hs))),kt.tagCheck=null,kt.attributeCheck=null,Fe(f,"ADD_TAGS")&&(typeof f.ADD_TAGS=="function"?kt.tagCheck=f.ADD_TAGS:sr(f.ADD_TAGS)&&(he===ra&&(he=We(he)),ee(he,f.ADD_TAGS,ve))),Fe(f,"ADD_ATTR")&&(typeof f.ADD_ATTR=="function"?kt.attributeCheck=f.ADD_ATTR:sr(f.ADD_ATTR)&&(pe===oa&&(pe=We(pe)),ee(pe,f.ADD_ATTR,ve))),Fe(f,"ADD_FORBID_CONTENTS")&&sr(f.ADD_FORBID_CONTENTS)&&(Rn===zd&&(Rn=We(Rn)),ee(Rn,f.ADD_FORBID_CONTENTS,ve)),la&&(he["#text"]=!0),$t&&ee(he,["html","head","body"]),he.table&&(ee(he,["tbody"]),delete ur.tbody),f.TRUSTED_TYPES_POLICY){if(typeof f.TRUSTED_TYPES_POLICY.createHTML!="function")throw wn('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof f.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw wn('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let T=B;B=f.TRUSTED_TYPES_POLICY;try{de=Sn("")}catch(M){throw B=T,M}}else f.TRUSTED_TYPES_POLICY===null?(B=void 0,de=""):(B===void 0&&(B=ff()),B&&typeof de=="string"&&(de=Sn("")));Ee&&Ee(f),Cn=f},Xd=ee({},[...od,...id,...px]),Yd=ee({},[...sd,...fx]),Cf=function(f,y,T){return y.namespaceURI===ct?f==="svg":y.namespaceURI===po?f==="svg"&&(T==="annotation-xml"||ha[T]):!!Xd[f]},Nf=function(f,y,T){return y.namespaceURI===ct?f==="math":y.namespaceURI===fo?f==="math"&&pa[T]:!!Yd[f]},Of=function(f,y,T){return y.namespaceURI===fo&&!pa[T]||y.namespaceURI===po&&!ha[T]?!1:!Yd[f]&&(Af[f]||!Xd[f])},Mf=function(f){let y=S(f);(!y||!y.tagName)&&(y={namespaceURI:In,tagName:"template"});let T=Yr(f.tagName),M=Yr(y.tagName);return ua[f.namespaceURI]?f.namespaceURI===fo?Cf(T,y,M):f.namespaceURI===po?Nf(T,y,M):f.namespaceURI===ct?Of(T,y,M):!!(hr==="application/xhtml+xml"&&ua[f.namespaceURI]):!1},It=function(f){qr(e.removed,{element:f});try{S(f).removeChild(f)}catch{if(h(f),!S(f))throw wn("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Kd=function(f,y,T){try{f.removeAttributeNode(y)}catch{try{f.removeAttribute(T)}catch{}}},mo=function(f){go(f);let y=x(f);if(y){let M=[];xn(y,H=>{qr(M,H)}),xn(M,H=>{try{h(H)}catch{}})}let T=O(f);if(T)for(let M=T.length-1;M>=0;--M){let H=T[M],j=H&&H.name;typeof j=="string"&&Kd(f,H,j)}},Bt=function(f,y,T){if(!T)try{T=y.getAttributeNode(f)}catch{T=null}qr(e.removed,{attribute:T||null,from:y});try{T?y.removeAttributeNode(T):y.removeAttribute(f)}catch{try{y.removeAttribute(f)}catch{}}if(f==="is")if(An||uo)try{It(y)}catch{}else try{y.setAttribute(f,"")}catch{}},Lf=function(f){let y=O(f);if(y)for(let T=y.length-1;T>=0;--T){let M=y[T],H=M&&M.name;typeof H!="string"||pe[ve(H)]||Kd(f,M,H)}},go=function(f){let y=[f];for(;y.length>0;){let T=y.pop();E(T)===qe.element&&Lf(T);let H=x(T);if(H)for(let j=H.length-1;j>=0;--j)y.push(H[j])}},Zd=function(f,y){return Ft?f==="patchsrc"?!0:f==="for"&&y!=="label"&&y!=="output":!1},Pf=function(f){if(!Ft)return;let y=[f];for(;y.length>0;){let T=y.pop(),M=E(T);if(M===qe.processingInstruction||M===qe.comment&&Ne(_p,T.data)){try{h(T)}catch{}continue}if(M===qe.element){let j=T,se=ve(I(T));try{j.hasAttribute&&j.hasAttribute("patchsrc")&&j.removeAttribute("patchsrc"),j.hasAttribute&&j.hasAttribute("for")&&Zd("for",se)&&j.removeAttribute("for")}catch{}}let H=x(T);if(H)for(let j=H.length-1;j>=0;--j)y.push(H[j])}},Qd=function(f){let y=null,T=null;if(aa)f="<remove></remove>"+f;else{let j=fp(f,/^[\r\n\t ]+/);T=j&&j[0]}hr==="application/xhtml+xml"&&In===ct&&(f='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+f+"</body></html>");let M=B?Sn(f):f;if(In===ct)try{y=new u().parseFromString(M,hr)}catch{}if(!y||!y.documentElement){y=na.createDocument(In,"template",null);try{y.documentElement.innerHTML=ca?de:M}catch{}}let H=y.body||y.documentElement;return f&&T&&H.insertBefore(n.createTextNode(T),H.childNodes[0]||null),In===ct?gf.call(y,$t?"html":"body")[0]:$t?y.documentElement:H},Jd=function(f){let y=A?A(f):f.ownerDocument;return Cd.call(y||f,f,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},vo=function(f){return f=Wr(f,bf," "),f=Wr(f,yf," "),f=Wr(f,wf," "),f},ma=function(f){var y;f.normalize();let T=A?A(f):f.ownerDocument,M=Cd.call(T||f,f,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),H=M.nextNode();for(;H;)H.data=vo(H.data),H=M.nextNode();let j=(y=f.querySelectorAll)===null||y===void 0?void 0:y.call(f,"template");j&&xn(j,se=>{Nn(se.content)&&ma(se.content)})},bo=function(f){let y=b?b(f):null;return typeof y!="string"||ve(y)!=="form"?!1:typeof f.nodeName!="string"||typeof f.textContent!="string"||typeof f.removeChild!="function"||f.attributes!==O(f)||typeof f.removeAttribute!="function"||typeof f.setAttribute!="function"||typeof f.namespaceURI!="string"||typeof f.insertBefore!="function"||typeof f.hasChildNodes!="function"||f.nodeType!==G(f)||f.childNodes!==x(f)},Nn=function(f){if(!G||typeof f!="object"||f===null)return!1;try{return G(f)===qe.documentFragment}catch{return!1}},pr=function(f){if(!G||typeof f!="object"||f===null)return!1;try{return typeof G(f)=="number"}catch{return!1}};function ut(R,f,y){R.length!==0&&xn(R,T=>{T.call(e,f,y,Cn)})}let Df=function(f,y){return!!(Ft&&f.hasChildNodes()&&!pr(f.firstElementChild)&&Ne(Tp,f.textContent)&&Ne(Tp,f.innerHTML)||Ft&&f.namespaceURI===ct&&Ax[y]&&(pr(f.firstElementChild)||typeof f.textContent=="string"&&Ne(kx[y],f.textContent))||f.nodeType===qe.processingInstruction||Ft&&f.nodeType===qe.comment&&Ne(_p,f.data))},yo=function(f,y){if(f instanceof RegExp)return Ne(f,y);if(f instanceof Function){for(var T=arguments.length,M=new Array(T>2?T-2:0),H=2;H<T;H++)M[H-2]=arguments[H];return!!f(y,...M)}return!1},Uf=function(f,y,T){if(!ur[y]&&oc(y)&&yo(dt.tagNameCheck,y))return!1;if(la&&!Rn[y]){let M=S(f),H=x(f);if(H&&M){let j=H.length;for(let se=j-1;se>=0;--se){let fe=f===T?p(H[se],!0):H[se];M.insertBefore(fe,v(f))}}}return It(f),!0},ec=function(f,y,T,M){return f.length===0?y:y===T||y===M?We(y):y},tc=function(f,y){return f===y||S(f)!==null?!1:(da&&go(f),!0)},nc=function(f,y){if(ut(ue.beforeSanitizeElements,f,null),tc(f,y))return!0;if(bo(f))return It(f),!0;let T=ve(I(f));if(he=ec(ue.uponSanitizeElement,he,ra,lo),ut(ue.uponSanitizeElement,f,{tagName:T,allowedTags:he}),tc(f,y))return!0;if(Df(f,T))return It(f),!0;if(ur[T]||!(kt.tagCheck instanceof Function&&kt.tagCheck(T))&&!he[T]){let H=Uf(f,T,y);return H===!1&&ut(ue.afterSanitizeElements,f,null),H}if(E(f)===qe.element&&!Mf(f)||(T==="noscript"||T==="noembed"||T==="noframes")&&Ne(_x,f.innerHTML))return It(f),!0;if(Rt&&f.nodeType===qe.text){let H=vo(f.textContent);f.textContent!==H&&(qr(e.removed,{element:f.cloneNode()}),f.textContent=H)}return ut(ue.afterSanitizeElements,f,null),!1},rc=function(f,y,T){if(Md[y]||Zd(y,f)||Ud&&(y==="id"||y==="name")&&(T in n||T in If))return!1;let M=pe[y]||kt.attributeCheck instanceof Function&&kt.attributeCheck(y,f);return ia&&Ne(xf,y)||Ld&&Ne(Ef,y)?!0:M?Bd[y]||Ne(Od,Wr(T,Nd,""))||(y==="src"||y==="xlink:href"||y==="href")&&f!=="script"&&mp(T,"data:")===0&&Fd[f]||Pd&&!Ne(Tf,Wr(T,Nd,""))?!0:!T:oc(f)&&yo(dt.tagNameCheck,f)&&yo(dt.attributeNameCheck,y,f)||y==="is"&&dt.allowCustomizedBuiltInElements&&yo(dt.tagNameCheck,T)},Hf=ee({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),oc=function(f){return!Hf[Yr(f)]&&Ne(_f,f)},Gf=function(f,y,T,M){if(B&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!T)switch(m.getAttributeType(f,y)){case"TrustedHTML":return Sn(M);case"TrustedScriptURL":return pf(M)}return M},zf=function(f,y,T,M){try{T?f.setAttributeNS(T,y,M):f.setAttribute(y,M),bo(f)?It(f):pp(e.removed)}catch{Bt(y,f)}},ic=function(f){ut(ue.beforeSanitizeAttributes,f,null);let y=f.attributes;if(!y||bo(f))return;pe=ec(ue.uponSanitizeAttribute,pe,oa,co);let T={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:pe,forceKeepAttr:void 0},M=y.length,H=ve(f.nodeName);for(;M--;){let j=y[M],se=j.name,fe=j.namespaceURI,De=j.value,Ue=ve(se),va=De,Me=se==="value"?va:sx(va);if(T.attrName=Ue,T.attrValue=Me,T.keepAttr=!0,T.forceKeepAttr=void 0,ut(ue.uponSanitizeAttribute,f,T),Me=T.attrValue,Hd&&(Ue==="id"||Ue==="name")&&mp(Me,Gd)!==0&&(Bt(se,f,j),Me=Gd+Me),Ft&&Ne(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Me)){Bt(se,f,j);continue}if(Ue==="attributename"&&fp(Me,"href")){Bt(se,f,j);continue}if(!T.forceKeepAttr){if(!T.keepAttr){Bt(se,f,j);continue}if(!Dd&&Ne(Sx,Me)){Bt(se,f,j);continue}if(Rt&&(Me=vo(Me)),!rc(H,Ue,Me)){Bt(se,f,j);continue}Me=Gf(H,Ue,fe,Me),Me!==va&&zf(f,se,fe,Me)}}ut(ue.afterSanitizeAttributes,f,null)},wo=function(f){let y=null,T=Jd(f);for(ut(ue.beforeSanitizeShadowDOM,f,null);y=T.nextNode();)if(ut(ue.uponSanitizeShadowNode,y,null),nc(y,f),ic(y),Nn(y.content)&&wo(y.content),E(y)===qe.element){let M=_(y);Nn(M)&&(ga(M),wo(M))}ut(ue.afterSanitizeShadowDOM,f,null)},ga=function(f){let y=[{node:f,shadow:null}];for(;y.length>0;){let T=y.pop();if(T.shadow){wo(T.shadow);continue}let M=T.node,j=E(M)===qe.element,se=x(M);if(se)for(let fe=se.length-1;fe>=0;--fe)y.push({node:se[fe],shadow:null});if(j){let fe=b?b(M):null;if(typeof fe=="string"&&ve(fe)==="template"){let De=M.content;Nn(De)&&y.push({node:De,shadow:null})}}if(j){let fe=_(M);Nn(fe)&&y.push({node:null,shadow:fe},{node:fe,shadow:null})}}};return e.sanitize=function(R){let f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},y=null,T=null,M=null,H=null;if(ca=!R,ca&&(R="<!-->"),typeof R!="string"&&!pr(R)&&(R=ux(R),typeof R!="string"))throw wn("dirty is not a string, aborting");if(!e.isSupported)return R;sa?(he=lo,pe=co):fa(f),(ue.uponSanitizeElement.length>0||ue.uponSanitizeAttribute.length>0)&&(he=We(he)),ue.uponSanitizeAttribute.length>0&&(pe=We(pe)),e.removed=[];let j=da&&typeof R!="string"&&pr(R);if(j){Pf(R);let De=I(R);if(typeof De=="string"){let Ue=ve(De);if(!he[Ue]||ur[Ue])throw mo(R),wn("root node is forbidden and cannot be sanitized in-place")}if(bo(R))throw mo(R),wn("root node is clobbered and cannot be sanitized in-place");try{ga(R)}catch(Ue){throw mo(R),Ue}}else if(pr(R))y=Qd("<!---->"),T=y.ownerDocument.importNode(R,!0),T.nodeType===qe.element&&T.nodeName==="BODY"||T.nodeName==="HTML"?y=T:y.appendChild(T),ga(T);else{if(!An&&!Rt&&!$t&&R.indexOf("<")===-1)return B&&ho?Sn(R):R;if(y=Qd(R),!y)return An?null:ho?de:""}y&&aa&&It(y.firstChild);let se=j?R:y;try{let De=Jd(se);for(;M=De.nextNode();)nc(M,se),ic(M),Nn(M.content)&&wo(M.content)}catch(De){throw j&&(mo(R),xn(e.removed,Ue=>{Ue.element&&go(Ue.element)})),De}if(j)return xn(e.removed,De=>{De.element&&go(De.element)}),Rt&&ma(R),R;if(An){if(Rt&&ma(y),uo)for(H=mf.call(y.ownerDocument);y.firstChild;)H.appendChild(y.firstChild);else H=y;return(pe.shadowroot||pe.shadowrootmode)&&(H=vf.call(r,H,!0)),H}let fe=$t?y.outerHTML:y.innerHTML;return $t&&he["!doctype"]&&y.ownerDocument&&y.ownerDocument.doctype&&y.ownerDocument.doctype.name&&Ne(Ex,y.ownerDocument.doctype.name)&&(fe="<!DOCTYPE "+y.ownerDocument.doctype.name+`>
|
|
3835
|
-
`+
|
|
3836
|
-
]`).replace("lheading",
|
|
3837
|
-
`),n=
|
|
3838
|
-
`)}function
|
|
3839
|
-
`).map(i=>{let
|
|
3840
|
-
`)}var
|
|
3841
|
-
`),depth:
|
|
3842
|
-
`)}}blockquote(
|
|
3864
|
+
`).trim()}var AC=1500;function fm(e,t){if(Kx(e)!==null)return;let n=Dl(e,t.strings),o=t.text;o!==void 0&&n.appendChild(RC(t.strings,o,t.html)),t.onFeedback!==void 0&&n.append(Xx("up",t.strings.feedbackUp,t.onFeedback),Xx("down",t.strings.feedbackDown,t.onFeedback))}function Dl(e,t){let n=Kx(e);if(n!==null)return n;let o=document.createElement("div");return o.className="message-actions",o.setAttribute("part","message-actions"),o.setAttribute("role","group"),o.setAttribute("aria-label",t.messageActions),e.after(o),o}function Kx(e){let t=e.nextElementSibling;return t?.classList.contains("message-actions")===!0?t:null}function Ul(e,t,n){let o=document.createElement("button");o.type="button",o.className=`message-action message-action--${e}`,o.setAttribute("part",`message-action message-action-${e}`),hm(o,t);let r=document.createElement("span");return r.className="message-action-icon",r.setAttribute("part",`message-action-icon message-action-icon-${e}`),r.setAttribute("aria-hidden","true"),r.innerHTML=n,o.appendChild(r),o}function hm(e,t){e.title=t,e.setAttribute("aria-label",t),e.dataset.tooltip=t}function RC(e,t,n){let o=Ul("copy",e.copyMessage,Ag);return o.addEventListener("click",()=>{CC(t(),n?.()).then(r=>{NC(o,r?e.copied:e.copyFailed,e.copyMessage)})}),o}async function CC(e,t){let n=navigator.clipboard;if(n===void 0)return!1;if(t!==void 0&&typeof ClipboardItem=="function")try{return await n.write([new ClipboardItem({"text/plain":new Blob([e],{type:"text/plain"}),"text/html":new Blob([t],{type:"text/html"})})]),!0}catch{}try{return await n.writeText(e),!0}catch{return!1}}function Xx(e,t,n){let o=Ul(e==="up"?"up":"down",t,e==="up"?Cg:Ng);return o.addEventListener("click",()=>{let r=o.getAttribute("aria-pressed")==="true";o.setAttribute("aria-pressed",r?"false":"true"),n(e)}),o.setAttribute("aria-pressed","false"),o}function NC(e,t,n){hm(e,t),e.classList.add("message-action--confirmed"),setTimeout(()=>{hm(e,n),e.classList.remove("message-action--confirmed")},AC)}var jl=class{#e;#t=null;constructor(t){this.#e=t}forget(){this.#t=null}attach(t,n={}){let o=this.#o(),r=o.has(qt.COPY),i=n.rateable!==!1&&o.has(qt.FEEDBACK);(r||i)&&fm(t,{strings:this.#e.strings(),...r?{text:()=>zl(t).text,html:()=>zl(t).html}:{},...i?{onFeedback:a=>{this.#e.element.dispatchEvent(new CustomEvent(Cu,{detail:{content:zl(t).text,rating:a},bubbles:!0,composed:!0}))}}:{}}),o.has(qt.RETRY)&&this.#n(Dl(t,this.#e.strings()))}#n(t){this.#t?.querySelector(".message-action--retry")?.remove();let n=Ul("retry",this.#e.strings().retryMessage,Rg);n.addEventListener("click",()=>{this.#e.retry()}),t.prepend(n),this.#t=t}#o(){let t=this.#e.element.getAttribute("data-message-actions");return t===null?new Set([qt.COPY,qt.RETRY]):new Set(pr(t))}};function Yx(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function OC(e){if(Array.isArray(e))return e}function $C(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var o,r,i,a,s=[],u=!0,l=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(u=(o=i.call(n)).done)&&(s.push(o.value),s.length!==t);u=!0);}catch(d){l=!0,r=d}finally{try{if(!u&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(l)throw r}}return s}}function PC(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3865
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function MC(e,t){return OC(e)||$C(e,t)||LC(e,t)||PC()}function LC(e,t){if(e){if(typeof e=="string")return Yx(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Yx(e,t):void 0}}var p_=Object.entries,Jx=Object.setPrototypeOf,zC=Object.isFrozen,DC=Object.getPrototypeOf,UC=Object.getOwnPropertyDescriptor,Ae=Object.freeze,Ce=Object.seal,fr=Object.create,h_=typeof Reflect<"u"&&Reflect,xm=h_.apply,_m=h_.construct;Ae||(Ae=function(t){return t});Ce||(Ce=function(t){return t});xm||(xm=function(t,n){for(var o=arguments.length,r=new Array(o>2?o-2:0),i=2;i<o;i++)r[i-2]=arguments[i];return t.apply(n,r)});_m||(_m=function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return new t(...o)});var Sn=Te(Array.prototype.forEach),jC=Te(Array.prototype.lastIndexOf),Qx=Te(Array.prototype.pop),jo=Te(Array.prototype.push),HC=Te(Array.prototype.splice),mr=Array.isArray,Fo=Te(String.prototype.toLowerCase),mm=Te(String.prototype.toString),e_=Te(String.prototype.match),Ho=Te(String.prototype.replace),t_=Te(String.prototype.indexOf),GC=Te(String.prototype.trim),FC=Te(Number.prototype.toString),VC=Te(Boolean.prototype.toString),n_=typeof BigInt>"u"?null:Te(BigInt.prototype.toString),r_=typeof Symbol>"u"?null:Te(Symbol.prototype.toString),Ze=Te(Object.prototype.hasOwnProperty),Go=Te(Object.prototype.toString),Me=Te(RegExp.prototype.test),En=ZC(TypeError);function Te(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return xm(e,t,o)}}function ZC(e){return function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return _m(e,n)}}function te(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Fo;if(Jx&&Jx(e,null),!mr(t))return e;let o=t.length;for(;o--;){let r=t[o];if(typeof r=="string"){let i=n(r);i!==r&&(zC(t)||(t[o]=i),r=i)}e[r]=!0}return e}function BC(e){for(let t=0;t<e.length;t++)Ze(e,t)||(e[t]=null);return e}function Qe(e){let t=fr(null);for(let o of p_(e)){var n=MC(o,2);let r=n[0],i=n[1];Ze(e,r)&&(mr(i)?t[r]=BC(i):i&&typeof i=="object"&&i.constructor===Object?t[r]=Qe(i):t[r]=i)}return t}function WC(e){switch(typeof e){case"string":return e;case"number":return FC(e);case"boolean":return VC(e);case"bigint":return n_?n_(e):"0";case"symbol":return r_?r_(e):"Symbol()";case"undefined":return Go(e);case"function":case"object":{if(e===null)return Go(e);let t=e,n=it(t,"toString");if(typeof n=="function"){let o=n(t);return typeof o=="string"?o:Go(o)}return Go(e)}default:return Go(e)}}function it(e,t){for(;e!==null;){let o=UC(e,t);if(o){if(o.get)return Te(o.get);if(typeof o.value=="function")return Te(o.value)}e=DC(e)}function n(){return null}return n}function qC(e){try{return Me(e,""),!0}catch{return!1}}var o_=Ae(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),gm=Ae(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),vm=Ae(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),XC=Ae(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),bm=Ae(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),KC=Ae(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),i_=Ae(["#text"]),a_=Ae(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),ym=Ae(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),s_=Ae(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Hl=Ae(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),YC=Ce(/{{[\w\W]*|^[\w\W]*}}/g),JC=Ce(/<%[\w\W]*|^[\w\W]*%>/g),QC=Ce(/\${[\w\W]*/g),eN=Ce(/^data-[\-\w.\u00B7-\uFFFF]+$/),tN=Ce(/^aria-[\-\w]+$/),l_=Ce(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),nN=Ce(/^(?:\w+script|data):/i),rN=Ce(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),oN=Ce(/^html$/i),iN=Ce(/^[a-z][.\w]*(-[.\w]+)+$/i),u_=Ce(/<[/\w!]/g),c_=Ce(/<[/\w]/g),aN=Ce(/<\/no(script|embed|frames)/i),sN=Ce(/\/>/i),Je={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},f_=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],lN=Ae(te({},f_)),uN=(function(){let e={};return Sn(f_,t=>{e[t]=Ce(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),Ae(e)})(),cN=function(){return typeof window>"u"?null:window},dN=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let o=null,r="data-tt-policy-suffix";n&&n.hasAttribute(r)&&(o=n.getAttribute(r));let i="dompurify"+(o?"#"+o:"");try{return t.createPolicy(i,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},d_=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Ft=function(t,n,o,r){return Ze(t,n)&&mr(t[n])?te(r.base?Qe(r.base):{},t[n],r.transform):o},wm=function(t,n,o){let r=Ze(t,n)?t[n]:void 0;return r&&typeof r=="object"?Qe(r):o()};function m_(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:cN(),t=$=>m_($);if(t.version="3.4.15",t.removed=[],!e||!e.document||e.document.nodeType!==Je.document||!e.Element)return t.isSupported=!1,t;let n=e.document,o=n,r=o.currentScript;e.DocumentFragment;let i=e.HTMLTemplateElement,a=e.Node,s=e.Element,u=e.NodeFilter,l=e.NamedNodeMap;l===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let d=e.DOMParser,h=e.trustedTypes,g=s.prototype,f=it(g,"cloneNode"),p=it(g,"remove"),b=it(g,"removeAttributeNode"),v=it(g,"nextSibling"),_=it(g,"childNodes"),y=it(g,"parentNode"),k=it(g,"shadowRoot"),E=it(g,"attributes"),I=a&&a.prototype?it(a.prototype,"nodeType"):null,w=a&&a.prototype?it(a.prototype,"nodeName"):null,A=a&&a.prototype?it(a.prototype,"ownerDocument"):null,L=function(m){return I?I(m):m.nodeType},U=function(m){return w?w(m):m.nodeName};if(typeof i=="function"){let $=n.createElement("template");$.content&&$.content.ownerDocument&&(n=$.content.ownerDocument)}let q,Ne="",iu,Hm=!1,yr=0,Gm=function(){if(yr>0)throw En('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},An=function(m){Gm(),yr++;try{return q.createHTML(m)}finally{yr--}},J_=function(m){Gm(),yr++;try{return q.createScriptURL(m)}finally{yr--}},Q_=function(){return Hm||(iu=dN(h,r),Hm=!0),iu},ti=n,au=ti.implementation,Fm=ti.createNodeIterator,eE=ti.createDocumentFragment,tE=ti.getElementsByTagName,nE=o.importNode,fe=d_();t.isSupported=typeof p_=="function"&&typeof y=="function"&&au&&au.createHTMLDocument!==void 0;let rE=YC,oE=JC,iE=QC,aE=eN,sE=tN,lE=nN,Vm=rN,uE=iN,Zm=l_,me=null,su=te({},[...o_,...gm,...vm,...bm,...i_]),ge=null,lu=te({},[...a_,...ym,...s_,...Hl]),pt=Object.seal(fr(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),wr=null,Bm=null,Ot=Object.seal(fr(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Wm=!0,uu=!0,qm=!1,Xm=!0,$t=!1,Zt=!0,Bt=!1,cu=!1,ni=null,ri=null,du=!1,Rn=!1,oi=!1,ii=!1,Km=!0,Ym=!1,Jm="user-content-",pu=!0,hu=!1,Cn={},Nn=null,Qm=te({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),eg=null,tg=te({},["audio","video","img","source","image","track"]),ng=null,rg=te({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ai="http://www.w3.org/1998/Math/MathML",si="http://www.w3.org/2000/svg",ht="http://www.w3.org/1999/xhtml",On=ht,fu=!1,mu=null,cE=te({},[ai,si,ht],mm),og=Ae(["mi","mo","mn","ms","mtext"]),gu=te({},og),ig=Ae(["annotation-xml"]),vu=te({},ig),dE=te({},["title","style","font","a","script"]),xr=null,pE=["application/xhtml+xml","text/html"],hE="text/html",_e=null,$n=null,fE=n.createElement("form"),ag=function(m){return m instanceof RegExp||m instanceof Function},bu=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if($n&&$n===m)return;(!m||typeof m!="object")&&(m={}),m=Qe(m),xr=pE.indexOf(m.PARSER_MEDIA_TYPE)===-1?hE:m.PARSER_MEDIA_TYPE,_e=xr==="application/xhtml+xml"?mm:Fo,me=Ft(m,"ALLOWED_TAGS",su,{transform:_e}),ge=Ft(m,"ALLOWED_ATTR",lu,{transform:_e}),mu=Ft(m,"ALLOWED_NAMESPACES",cE,{transform:mm}),ng=Ft(m,"ADD_URI_SAFE_ATTR",rg,{transform:_e,base:rg}),eg=Ft(m,"ADD_DATA_URI_TAGS",tg,{transform:_e,base:tg}),Nn=Ft(m,"FORBID_CONTENTS",Qm,{transform:_e}),wr=Ft(m,"FORBID_TAGS",Qe({}),{transform:_e}),Bm=Ft(m,"FORBID_ATTR",Qe({}),{transform:_e}),Cn=Ze(m,"USE_PROFILES")?m.USE_PROFILES&&typeof m.USE_PROFILES=="object"?Qe(m.USE_PROFILES):m.USE_PROFILES:!1,Wm=m.ALLOW_ARIA_ATTR!==!1,uu=m.ALLOW_DATA_ATTR!==!1,qm=m.ALLOW_UNKNOWN_PROTOCOLS||!1,Xm=m.ALLOW_SELF_CLOSE_IN_ATTR!==!1,$t=m.SAFE_FOR_TEMPLATES||!1,Zt=m.SAFE_FOR_XML!==!1,Bt=m.WHOLE_DOCUMENT||!1,Rn=m.RETURN_DOM||!1,oi=m.RETURN_DOM_FRAGMENT||!1,ii=m.RETURN_TRUSTED_TYPE||!1,du=m.FORCE_BODY||!1,Km=m.SANITIZE_DOM!==!1,Ym=m.SANITIZE_NAMED_PROPS||!1,pu=m.KEEP_CONTENT!==!1,hu=m.IN_PLACE||!1,Zm=qC(m.ALLOWED_URI_REGEXP)?m.ALLOWED_URI_REGEXP:l_,On=typeof m.NAMESPACE=="string"?m.NAMESPACE:ht,gu=wm(m,"MATHML_TEXT_INTEGRATION_POINTS",()=>te({},og)),vu=wm(m,"HTML_INTEGRATION_POINTS",()=>te({},ig));let S=wm(m,"CUSTOM_ELEMENT_HANDLING",()=>fr(null));if(pt=fr(null),Ze(S,"tagNameCheck")&&ag(S.tagNameCheck)&&(pt.tagNameCheck=S.tagNameCheck),Ze(S,"attributeNameCheck")&&ag(S.attributeNameCheck)&&(pt.attributeNameCheck=S.attributeNameCheck),Ze(S,"allowCustomizedBuiltInElements")&&typeof S.allowCustomizedBuiltInElements=="boolean"&&(pt.allowCustomizedBuiltInElements=S.allowCustomizedBuiltInElements),Ce(pt),$t&&(uu=!1),oi&&(Rn=!0),Cn&&(me=te({},i_),ge=fr(null),Cn.html===!0&&(te(me,o_),te(ge,a_)),Cn.svg===!0&&(te(me,gm),te(ge,ym),te(ge,Hl)),Cn.svgFilters===!0&&(te(me,vm),te(ge,ym),te(ge,Hl)),Cn.mathMl===!0&&(te(me,bm),te(ge,s_),te(ge,Hl))),Ot.tagCheck=null,Ot.attributeCheck=null,Ze(m,"ADD_TAGS")&&(typeof m.ADD_TAGS=="function"?Ot.tagCheck=m.ADD_TAGS:mr(m.ADD_TAGS)&&(me===su&&(me=Qe(me)),te(me,m.ADD_TAGS,_e))),Ze(m,"ADD_ATTR")&&(typeof m.ADD_ATTR=="function"?Ot.attributeCheck=m.ADD_ATTR:mr(m.ADD_ATTR)&&(ge===lu&&(ge=Qe(ge)),te(ge,m.ADD_ATTR,_e))),Ze(m,"ADD_FORBID_CONTENTS")&&mr(m.ADD_FORBID_CONTENTS)&&(Nn===Qm&&(Nn=Qe(Nn)),te(Nn,m.ADD_FORBID_CONTENTS,_e)),pu&&(me["#text"]=!0),Bt&&te(me,["html","head","body"]),me.table&&(te(me,["tbody"]),delete wr.tbody),m.TRUSTED_TYPES_POLICY){if(typeof m.TRUSTED_TYPES_POLICY.createHTML!="function")throw En('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof m.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw En('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let N=q;q=m.TRUSTED_TYPES_POLICY;try{Ne=An("")}catch(j){throw q=N,j}}else m.TRUSTED_TYPES_POLICY===null?(q=void 0,Ne=""):(q===void 0&&(q=Q_()),q&&typeof Ne=="string"&&(Ne=An("")));Ae&&Ae(m),$n=m},sg=te({},[...gm,...vm,...XC]),lg=te({},[...bm,...KC]),mE=function(m,S,N){return S.namespaceURI===ht?m==="svg":S.namespaceURI===ai?m==="svg"&&(N==="annotation-xml"||gu[N]):!!sg[m]},gE=function(m,S,N){return S.namespaceURI===ht?m==="math":S.namespaceURI===si?m==="math"&&vu[N]:!!lg[m]},vE=function(m,S,N){return S.namespaceURI===si&&!vu[N]||S.namespaceURI===ai&&!gu[N]?!1:!lg[m]&&(dE[m]||!sg[m])},bE=function(m){let S=y(m);(!S||!S.tagName)&&(S={namespaceURI:On,tagName:"template"});let N=Fo(m.tagName),j=Fo(S.tagName);return mu[m.namespaceURI]?m.namespaceURI===si?mE(N,S,j):m.namespaceURI===ai?gE(N,S,j):m.namespaceURI===ht?vE(N,S,j):!!(xr==="application/xhtml+xml"&&mu[m.namespaceURI]):!1},Pt=function(m){jo(t.removed,{element:m});try{y(m).removeChild(m)}catch{if(p(m),!y(m))throw En("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},ug=function(m,S,N){try{b(m,S)}catch{try{m.removeAttribute(N)}catch{}}},li=function(m){ui(m);let S=_(m);if(S){let j=[];Sn(S,G=>{jo(j,G)}),Sn(j,G=>{try{p(G)}catch{}})}let N=E(m);if(N)for(let j=N.length-1;j>=0;--j){let G=N[j],V=G&&G.name;typeof V=="string"&&ug(m,G,V)}},Wt=function(m,S,N){if(!N)try{N=S.getAttributeNode(m)}catch{N=null}jo(t.removed,{attribute:N||null,from:S});try{N?b(S,N):S.removeAttribute(m)}catch{try{S.removeAttribute(m)}catch{}}if(m==="is")if(Rn||oi)try{Pt(S)}catch{}else try{S.setAttribute(m,"")}catch{}},yE=function(m){let S=E(m);if(S)for(let N=S.length-1;N>=0;--N){let j=S[N],G=j&&j.name;typeof G!="string"||ge[_e(G)]||ug(m,j,G)}},ui=function(m){let S=[m];for(;S.length>0;){let N=S.pop();L(N)===Je.element&&yE(N);let G=_(N);if(G)for(let V=G.length-1;V>=0;--V)S.push(G[V])}},cg=function(m,S){return Zt?m==="patchsrc"?!0:m==="for"&&S!=="label"&&S!=="output":!1},wE=function(m){if(!Zt)return;let S=[m];for(;S.length>0;){let N=S.pop(),j=L(N);if(j===Je.processingInstruction||j===Je.comment&&Me(c_,N.data)){try{p(N)}catch{}continue}if(j===Je.element){let V=N,ue=_e(U(N));try{V.hasAttribute&&V.hasAttribute("patchsrc")&&V.removeAttribute("patchsrc"),V.hasAttribute&&V.hasAttribute("for")&&cg("for",ue)&&V.removeAttribute("for")}catch{}}let G=_(N);if(G)for(let V=G.length-1;V>=0;--V)S.push(G[V])}},dg=function(m){let S=null,N=null;if(du)m="<remove></remove>"+m;else{let V=e_(m,/^[\r\n\t ]+/);N=V&&V[0]}xr==="application/xhtml+xml"&&On===ht&&(m='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+m+"</body></html>");let j=q?An(m):m;if(On===ht)try{S=new d().parseFromString(j,xr)}catch{}if(!S||!S.documentElement){S=au.createDocument(On,"template",null);try{S.documentElement.innerHTML=fu?Ne:j}catch{}}let G=S.body||S.documentElement;return m&&N&&G.insertBefore(n.createTextNode(N),G.childNodes[0]||null),On===ht?tE.call(S,Bt?"html":"body")[0]:Bt?S.documentElement:G},pg=function(m){let S=A?A(m):m.ownerDocument;return Fm.call(S||m,m,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},ci=function(m){return m=Ho(m,rE," "),m=Ho(m,oE," "),m=Ho(m,iE," "),m},yu=function(m){var S;m.normalize();let N=A?A(m):m.ownerDocument,j=Fm.call(N||m,m,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null),G=j.nextNode();for(;G;)G.data=ci(G.data),G=j.nextNode();let V=(S=m.querySelectorAll)===null||S===void 0?void 0:S.call(m,"template");V&&Sn(V,ue=>{Pn(ue.content)&&yu(ue.content)})},di=function(m){let S=w?w(m):null;return typeof S!="string"||_e(S)!=="form"?!1:typeof m.nodeName!="string"||typeof m.textContent!="string"||typeof m.removeChild!="function"||m.attributes!==E(m)||typeof m.removeAttribute!="function"||typeof m.removeAttributeNode!="function"||typeof m.getAttributeNode!="function"||typeof m.setAttribute!="function"||typeof m.namespaceURI!="string"||typeof m.insertBefore!="function"||typeof m.hasChildNodes!="function"||m.nodeType!==I(m)||m.childNodes!==_(m)},Pn=function(m){if(!I||typeof m!="object"||m===null)return!1;try{return I(m)===Je.documentFragment}catch{return!1}},_r=function(m){if(!I||typeof m!="object"||m===null)return!1;try{return typeof I(m)=="number"}catch{return!1}};function ft($,m,S){$.length!==0&&Sn($,N=>{N.call(t,m,S,$n)})}let xE=function(m,S){return!!(Zt&&m.hasChildNodes()&&!_r(m.firstElementChild)&&Me(u_,m.textContent)&&Me(u_,m.innerHTML)||Zt&&m.namespaceURI===ht&&lN[S]&&(_r(m.firstElementChild)||typeof m.textContent=="string"&&Me(uN[S],m.textContent))||m.nodeType===Je.processingInstruction||Zt&&m.nodeType===Je.comment&&Me(c_,m.data))},pi=function(m,S){if(m instanceof RegExp)return Me(m,S);if(m instanceof Function){for(var N=arguments.length,j=new Array(N>2?N-2:0),G=2;G<N;G++)j[G-2]=arguments[G];return!!m(S,...j)}return!1},_E=function(m,S,N){if(!wr[S]&&vg(S)&&pi(pt.tagNameCheck,S))return!1;if(pu&&!Nn[S]){let j=y(m),G=_(m);if(G&&j){let V=G.length;for(let ue=V-1;ue>=0;--ue){let be=m===N?f(G[ue],!0):G[ue];j.insertBefore(be,v(m))}}}return Pt(m),!0},hg=function(m,S,N,j){return m.length===0?S:S===N||S===j?Qe(S):S},fg=function(m,S){return m===S||y(m)!==null?!1:(hu&&ui(m),!0)},mg=function(m,S){if(ft(fe.beforeSanitizeElements,m,null),fg(m,S))return!0;if(di(m))return Pt(m),!0;let N=_e(U(m));if(me=hg(fe.uponSanitizeElement,me,su,ni),ft(fe.uponSanitizeElement,m,{tagName:N,allowedTags:me}),fg(m,S))return!0;if(xE(m,N))return Pt(m),!0;if(wr[N]||!(Ot.tagCheck instanceof Function&&Ot.tagCheck(N))&&!me[N]){let G=_E(m,N,S);return G===!1&&ft(fe.afterSanitizeElements,m,null),G}if(L(m)===Je.element&&!bE(m)||(N==="noscript"||N==="noembed"||N==="noframes")&&Me(aN,m.innerHTML))return Pt(m),!0;if($t&&m.nodeType===Je.text){let G=ci(m.textContent);m.textContent!==G&&(jo(t.removed,{element:m.cloneNode()}),m.textContent=G)}return ft(fe.afterSanitizeElements,m,null),!1},gg=function(m,S,N){if(Bm[S]||cg(S,m)||Km&&(S==="id"||S==="name")&&(N in n||N in fE))return!1;let j=ge[S]||Ot.attributeCheck instanceof Function&&Ot.attributeCheck(S,m);return uu&&Me(aE,S)||Wm&&Me(sE,S)?!0:j?ng[S]||Me(Zm,Ho(N,Vm,""))||(S==="src"||S==="xlink:href"||S==="href")&&m!=="script"&&t_(N,"data:")===0&&eg[m]||qm&&!Me(lE,Ho(N,Vm,""))?!0:!N:vg(m)&&pi(pt.tagNameCheck,m)&&pi(pt.attributeNameCheck,S,m)||S==="is"&&pt.allowCustomizedBuiltInElements&&pi(pt.tagNameCheck,N)},EE=te({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),vg=function(m){return!EE[Fo(m)]&&Me(uE,m)},SE=function(m,S,N,j){if(q&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!N)switch(h.getAttributeType(m,S)){case"TrustedHTML":return An(j);case"TrustedScriptURL":return J_(j)}return j},TE=function(m,S,N,j){try{return N?m.setAttributeNS(N,S,j):m.setAttribute(S,j),di(m)?(Pt(m),!1):!0}catch{return Wt(S,m),!1}},bg=function(m){ft(fe.beforeSanitizeAttributes,m,null);let S=m.attributes;if(!S||di(m))return;ge=hg(fe.uponSanitizeAttribute,ge,lu,ri);let N={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ge,forceKeepAttr:void 0},j=S.length,G=_e(m.nodeName);for(;j--;){let V=S[j],ue=V.name,be=V.namespaceURI,He=V.value,Ge=_e(ue),xu=He,ze=ue==="value"?xu:GC(xu),yg=!1;if(N.attrName=Ge,N.attrValue=ze,N.keepAttr=!0,N.forceKeepAttr=void 0,ft(fe.uponSanitizeAttribute,m,N),ze=N.attrValue,Ym&&(Ge==="id"||Ge==="name")&&t_(ze,Jm)!==0&&(Wt(ue,m,V),ze=Jm+ze,yg=!0),Zt&&Me(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,ze)){Wt(ue,m,V);continue}if(Ge==="attributename"&&e_(ze,"href")){Wt(ue,m,V);continue}if(!N.forceKeepAttr){if(!N.keepAttr){Wt(ue,m,V);continue}if(!Xm&&Me(sN,ze)){Wt(ue,m,V);continue}if($t&&(ze=ci(ze)),!gg(G,Ge,ze)){Wt(ue,m,V);continue}ze=SE(G,Ge,be,ze),ze!==xu&&TE(m,ue,be,ze)&&yg&&Qx(t.removed)}}ft(fe.afterSanitizeAttributes,m,null)},hi=function(m){let S=null,N=pg(m);for(ft(fe.beforeSanitizeShadowDOM,m,null);S=N.nextNode();)if(ft(fe.uponSanitizeShadowNode,S,null),mg(S,m),bg(S),Pn(S.content)&&hi(S.content),L(S)===Je.element){let j=k(S);Pn(j)&&(wu(j),hi(j))}ft(fe.afterSanitizeShadowDOM,m,null)},wu=function(m){let S=[{node:m,shadow:null}];for(;S.length>0;){let N=S.pop();if(N.shadow){hi(N.shadow);continue}let j=N.node,V=L(j)===Je.element,ue=_(j);if(ue)for(let be=ue.length-1;be>=0;--be)S.push({node:ue[be],shadow:null});if(V){let be=w?w(j):null;if(typeof be=="string"&&_e(be)==="template"){let He=j.content;Pn(He)&&S.push({node:He,shadow:null})}}if(V){let be=k(j);Pn(be)&&S.push({node:null,shadow:be},{node:be,shadow:null})}}};return t.sanitize=function($){let m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},S=null,N=null,j=null,G=null;if(fu=!$,fu&&($="<!-->"),typeof $!="string"&&!_r($)&&($=WC($),typeof $!="string"))throw En("dirty is not a string, aborting");if(!t.isSupported)return $;cu?(me=ni,ge=ri):bu(m),(fe.uponSanitizeElement.length>0||fe.uponSanitizeAttribute.length>0)&&(me=Qe(me)),fe.uponSanitizeAttribute.length>0&&(ge=Qe(ge)),t.removed=[];let V=hu&&typeof $!="string"&&_r($);if(V){wE($);let He=U($);if(typeof He=="string"){let Ge=_e(He);if(!me[Ge]||wr[Ge])throw li($),En("root node is forbidden and cannot be sanitized in-place")}if(di($))throw li($),En("root node is clobbered and cannot be sanitized in-place");try{wu($)}catch(Ge){throw li($),Ge}}else if(_r($))S=dg("<!---->"),N=S.ownerDocument.importNode($,!0),N.nodeType===Je.element&&N.nodeName==="BODY"||N.nodeName==="HTML"?S=N:S.appendChild(N),wu(S);else{if(!Rn&&!$t&&!Bt&&$.indexOf("<")===-1)return q&&ii?An($):$;if(S=dg($),!S)return Rn?null:ii?Ne:""}S&&du&&Pt(S.firstChild);let ue=V?$:S;try{let He=pg(ue);for(;j=He.nextNode();)mg(j,ue),bg(j),Pn(j.content)&&hi(j.content)}catch(He){throw V&&(li($),Sn(t.removed,Ge=>{Ge.element&&ui(Ge.element)})),He}if(V)return Sn(t.removed,He=>{He.element&&ui(He.element)}),$t&&yu($),$;if(Rn){if($t&&yu(S),oi)for(G=eE.call(S.ownerDocument);S.firstChild;)G.appendChild(S.firstChild);else G=S;return(ge.shadowroot||ge.shadowrootmode)&&(G=nE.call(o,G,!0)),G}let be=Bt?S.outerHTML:S.innerHTML;return Bt&&me["!doctype"]&&S.ownerDocument&&S.ownerDocument.doctype&&S.ownerDocument.doctype.name&&Me(oN,S.ownerDocument.doctype.name)&&(be="<!DOCTYPE "+S.ownerDocument.doctype.name+`>
|
|
3866
|
+
`+be),$t&&(be=ci(be)),q&&ii?An(be):be},t.setConfig=function(){let $=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};bu($),cu=!0,ni=me,ri=ge},t.clearConfig=function(){$n=null,cu=!1,ni=null,ri=null,q=iu,Ne=""},t.isValidAttribute=function($,m,S){$n||bu({});let N=_e($),j=_e(m);return gg(N,j,S)},t.addHook=function($,m){typeof m=="function"&&Ze(fe,$)&&jo(fe[$],m)},t.removeHook=function($,m){if(Ze(fe,$)){if(m!==void 0){let S=jC(fe[$],m);return S===-1?void 0:HC(fe[$],S,1)[0]}return Qx(fe[$])}},t.removeHooks=function($){Ze(fe,$)&&(fe[$]=[])},t.removeAllHooks=function(){fe=d_()},t}var g_=m_();function km(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var In=km();function S_(e){In=e}var Tn={exec:()=>null};function gr(e){let t=[];return n=>{let o=Math.max(0,Math.min(3,n-1)),r=t[o];return r||(r=e(o),t[o]=r),r}}function J(e,t=""){let n=typeof e=="string"?e:e.source,o={replace:(r,i)=>{let a=typeof i=="string"?i:i.source;return a=a.replace(Le.caret,"$1"),n=n.replace(r,a),o},getRegex:()=>new RegExp(n,t)};return o}var pN=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),Le={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:gr(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:gr(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:gr(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:gr(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:gr(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:gr(e=>new RegExp(`^ {0,${e}}>`))},hN=/^(?:[ \t]*(?:\n|$))+/,fN=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,mN=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Bo=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,gN=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Im=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,T_=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,k_=J(T_).replace(/bull/g,Im).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),vN=J(T_).replace(/bull/g,Im).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Am=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,bN=/^[^\n]+/,Rm=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,yN=J(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Rm).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),wN=J(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Im).getRegex(),Bl="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Cm=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,xN=J("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Cm).replace("tag",Bl).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),I_=e=>J(Am).replace("hr",Bo).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list",e).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Bl).getRegex(),_N=I_(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),EN=I_(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),SN=J(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",EN).getRegex(),Nm={blockquote:SN,code:fN,def:yN,fences:mN,heading:gN,hr:Bo,html:xN,lheading:k_,list:wN,newline:hN,paragraph:_N,table:Tn,text:bN},v_=J("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Bo).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Bl).getRegex(),TN={...Nm,lheading:vN,table:v_,paragraph:J(Am).replace("hr",Bo).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",v_).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Bl).getRegex()},kN={...Nm,html:J(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Cm).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Tn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:J(Am).replace("hr",Bo).replace("heading",` *#{1,6} *[^
|
|
3867
|
+
]`).replace("lheading",k_).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},IN=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,AN=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,A_=/^( {2,}|\\)\n(?!\s*$)/,RN=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Nt=/[\p{P}\p{S}]/u,vr=/[\s\p{P}\p{S}]/u,Wo=/[^\s\p{P}\p{S}]/u,CN=J(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,vr).getRegex(),NN=/[\p{Pi}\p{Ps}"']/u,R_=/(?!~)[\p{P}\p{S}]/u,ON=/(?!~)[\s\p{P}\p{S}]/u,$N=/(?:[^\s\p{P}\p{S}]|~)/u,PN=J(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",pN?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),C_=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,MN=J(C_,"u").replace(/punct/g,Nt).getRegex(),LN=J(C_,"u").replace(/punct/g,R_).getRegex(),zN=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,DN=J(zN,"u").replace(/openQuote/g,NN).replace(/punct/g,Nt).getRegex(),N_="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",UN=J(N_,"gu").replace(/notPunctSpace/g,Wo).replace(/punctSpace/g,vr).replace(/punct/g,Nt).getRegex(),jN=J(N_,"gu").replace(/notPunctSpace/g,$N).replace(/punctSpace/g,ON).replace(/punct/g,R_).getRegex(),HN="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",GN=J(HN,"gu").replace(/notPunctSpace/g,Wo).replace(/punctSpace/g,vr).replace(/punct/g,Nt).getRegex(),FN=J("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Wo).replace(/punctSpace/g,vr).replace(/punct/g,Nt).getRegex(),VN="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",ZN=J(VN,"gu").replace(/notPunctSpace/g,Wo).replace(/punctSpace/g,vr).replace(/punct/g,Nt).getRegex(),BN=J(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Nt).getRegex(),WN="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",qN=J(WN,"gu").replace(/notPunctSpace/g,Wo).replace(/punctSpace/g,vr).replace(/punct/g,Nt).getRegex(),XN=J(/\\(punct)/,"gu").replace(/punct/g,Nt).getRegex(),KN=J(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),YN=J(Cm).replace("(?:-->|$)","-->").getRegex(),JN=J("^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",YN).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),QN=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,Fl=J(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets",QN).getRegex(),eO=J(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Fl).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),O_=J(/^!?\[(label)\]\[(ref)\]/).replace("label",Fl).replace("ref",Rm).getRegex(),$_=J(/^!?\[(ref)\](?:\[\])?/).replace("ref",Rm).getRegex(),tO=J("reflink|nolink(?!\\()","g").replace("reflink",O_).replace("nolink",$_).getRegex(),b_=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Om={_backpedal:Tn,anyPunctuation:XN,autolink:KN,blockSkip:PN,br:A_,code:AN,del:Tn,delLDelim:Tn,delRDelim:Tn,emStrongLDelim:MN,emStrongRDelimAst:UN,emStrongRDelimUnd:FN,escape:IN,link:eO,nolink:$_,punctuation:CN,reflink:O_,reflinkSearch:tO,tag:JN,text:RN,url:Tn},nO={...Om,emStrongLDelim:DN,emStrongRDelimAst:GN,emStrongRDelimUnd:ZN,link:J(/^!?\[(label)\]\((.*?)\)/).replace("label",Fl).getRegex(),reflink:J(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Fl).getRegex()},Em={...Om,emStrongRDelimAst:jN,emStrongLDelim:LN,delLDelim:BN,delRDelim:qN,url:J(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",b_).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:J(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",b_).getRegex()},rO={...Em,br:J(A_).replace("{2,}","*").getRegex(),text:J(Em.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Gl={normal:Nm,gfm:TN,pedantic:kN},Vo={normal:Om,gfm:Em,breaks:rO,pedantic:nO},oO={"&":"&","<":"<",">":">",'"':""","'":"'"},y_=e=>oO[e];function et(e,t){if(t){if(Le.escapeTest.test(e))return e.replace(Le.escapeReplace,y_)}else if(Le.escapeTestNoEncode.test(e))return e.replace(Le.escapeReplaceNoEncode,y_);return e}function w_(e){try{e=encodeURI(e).replace(Le.percentDecode,"%")}catch{return null}return e}function x_(e,t){let n=e.replace(Le.findPipe,(i,a,s)=>{let u=!1,l=a;for(;--l>=0&&s[l]==="\\";)u=!u;return u?"|":" |"}),o=n.split(Le.splitPipe),r=0;if(o[0].trim()||o.shift(),o.length>0&&!o.at(-1)?.trim()&&o.pop(),t)if(o.length>t)o.splice(t);else for(;o.length<t;)o.push("");for(;r<o.length;r++)o[r]=o[r].trim().replace(Le.slashPipe,"|");return o}function Vt(e,t,n){let o=e.length;if(o===0)return"";let r=0;for(;r<o;){let i=e.charAt(o-r-1);if(i===t&&!n)r++;else if(i!==t&&n)r++;else break}return e.slice(0,o-r)}function __(e){let t=e.split(`
|
|
3868
|
+
`),n=t.length-1;for(;n>=0&&Le.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
3869
|
+
`)}function iO(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let o=0;o<e.length;o++)if(e[o]==="\\")o++;else if(e[o]===t[0])n++;else if(e[o]===t[1]&&(n--,n<0))return o;return n>0?-2:-1}function aO(e,t=0){let n=t,o="";for(let r of e)if(r===" "){let i=4-n%4;o+=" ".repeat(i),n+=i}else o+=r,n++;return o}function E_(e,t,n,o,r){let i=t.href,a=t.title||null,s=e[1].replace(r.other.outputLinkReplace,"$1"),u=e[0].charAt(0)==="!";o.state.inLink=!0;let l=o.state.linkEmitted,d=o.state.inRawBlock;o.state.linkEmitted=!1;let h=o.inlineTokens(s),g=o.state.linkEmitted;if(o.state.linkEmitted=l,o.state.inLink=!1,!u){if(g){o.state.inRawBlock=d;return}o.state.linkEmitted=!0}return{type:u?"image":"link",raw:n,href:i,title:a,text:s,tokens:h}}function sO(e,t,n){let o=e.match(n.other.indentCodeCompensation);if(o===null)return t;let r=o[1];return t.split(`
|
|
3870
|
+
`).map(i=>{let a=i.match(n.other.beginningSpace);if(a===null)return i;let[s]=a;return i.slice(Math.min(s.length,r.length))}).join(`
|
|
3871
|
+
`)}var Vl=class{options;rules;lexer;constructor(e){this.options=e||In}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=this.options.pedantic?t[0]:__(t[0]),o=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:o}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],o=sO(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:o}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let o=Vt(n,"#");(this.options.pedantic||!o||this.rules.other.endingSpaceTabChar.test(o))&&(n=o.trim())}return{type:"heading",raw:Vt(t[0],`
|
|
3872
|
+
`),depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Vt(t[0],`
|
|
3873
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=Vt(t[0],`
|
|
3843
3874
|
`).split(`
|
|
3844
|
-
`),
|
|
3845
|
-
`),
|
|
3846
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");
|
|
3847
|
-
${
|
|
3848
|
-
${
|
|
3849
|
-
`),
|
|
3850
|
-
`+
|
|
3851
|
-
${
|
|
3875
|
+
`),o="",r="",i=[];for(;n.length>0;){let a=!1,s=[],u;for(u=0;u<n.length;u++)if(this.rules.other.blockquoteStart.test(n[u]))s.push(n[u]),a=!0;else if(!a)s.push(n[u]);else break;n=n.slice(u);let l=s.join(`
|
|
3876
|
+
`),d=l.replace(this.rules.other.blockquoteSetextReplace,`
|
|
3877
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");o=o?`${o}
|
|
3878
|
+
${l}`:l,r=r?`${r}
|
|
3879
|
+
${d}`:d;let h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,i,!0),this.lexer.state.top=h,n.length===0)break;let g=i.at(-1);if(g?.type==="code")break;if(g?.type==="blockquote"){let f=g,p=n.join(`
|
|
3880
|
+
`),b=f.raw+`
|
|
3881
|
+
`+p.replace(this.rules.other.blockquoteSetextReplace2,""),v=this.blockquote(b);i[i.length-1]=v,o=`${o}
|
|
3882
|
+
${p}`,r=r.substring(0,r.length-f.text.length)+v.text;break}else if(g?.type==="list"){let f=g,p=f.raw+`
|
|
3852
3883
|
`+n.join(`
|
|
3853
|
-
`),
|
|
3854
|
-
`);continue}}return{type:"blockquote",raw:
|
|
3855
|
-
`,1)[0],
|
|
3856
|
-
`,1)[0],
|
|
3857
|
-
`,
|
|
3858
|
-
`,1)[0],
|
|
3859
|
-
`+
|
|
3860
|
-
`+
|
|
3861
|
-
`,
|
|
3862
|
-
`),href:
|
|
3863
|
-
`):[],i={type:"table",raw:
|
|
3864
|
-
`),header:[],align:[],rows:[]};if(n.length===
|
|
3865
|
-
`),depth:
|
|
3866
|
-
`?
|
|
3867
|
-
`),this.blockTokens(
|
|
3868
|
-
`:n.push(i);continue}if(i=this.tokenizer.code(
|
|
3884
|
+
`),b=this.list(p);i[i.length-1]=b,o=o.substring(0,o.length-g.raw.length)+b.raw,r=r.substring(0,r.length-f.raw.length)+b.raw,n=p.substring(i.at(-1).raw.length).split(`
|
|
3885
|
+
`);continue}}return{type:"blockquote",raw:o,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),o=n.length>1,r={type:"list",raw:"",ordered:o,start:o?+n.slice(0,-1):"",loose:!1,items:[]};n=o?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=o?n:"[*+-]");let i=this.rules.other.listItemRegex(n),a=!1;for(;e;){let u=!1,l="",d="";if(!(t=i.exec(e))||this.rules.block.hr.test(e))break;l=t[0],e=e.substring(l.length);let h=aO(t[2].split(`
|
|
3886
|
+
`,1)[0],t[1].length),g=e.split(`
|
|
3887
|
+
`,1)[0],f=!h.trim(),p=0;if(this.options.pedantic?(p=2,d=h.trimStart()):f?p=t[1].length+1:(p=h.search(this.rules.other.nonSpaceChar),p=p>4?1:p,d=h.slice(p),p+=t[1].length),f&&this.rules.other.blankLine.test(g)&&(l+=g+`
|
|
3888
|
+
`,e=e.substring(g.length+1),u=!0),!u){let b=this.rules.other.nextBulletRegex(p),v=this.rules.other.hrRegex(p),_=this.rules.other.fencesBeginRegex(p),y=this.rules.other.headingBeginRegex(p),k=this.rules.other.htmlBeginRegex(p),E=this.rules.other.blockquoteBeginRegex(p);for(;e;){let I=e.split(`
|
|
3889
|
+
`,1)[0],w;if(g=I,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),w=g):w=g.replace(this.rules.other.tabCharGlobal," "),_.test(g)||y.test(g)||k.test(g)||E.test(g)||b.test(g)||v.test(g))break;if(w.search(this.rules.other.nonSpaceChar)>=p||!g.trim())d+=`
|
|
3890
|
+
`+w.slice(p);else{if(f||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||_.test(h)||y.test(h)||v.test(h))break;d+=`
|
|
3891
|
+
`+g}f=!g.trim(),l+=I+`
|
|
3892
|
+
`,e=e.substring(I.length+1),h=w.slice(p)}}r.loose||(a?r.loose=!0:this.rules.other.doubleBlankLine.test(l)&&(a=!0)),r.items.push({type:"list_item",raw:l,task:!!this.options.gfm&&this.rules.other.listIsTask.test(d),loose:!1,text:d,tokens:[]}),r.raw+=l}let s=r.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let u of r.items)if(this.lexer.state.top=!1,u.tokens=this.lexer.blockTokens(u.text,[]),!r.loose){let l=u.tokens.filter(h=>h.type==="space"),d=l.length>0&&l.some(h=>this.rules.other.anyLine.test(h.raw));r.loose=d}for(let u of r.items){let l=u.tokens[0];if(u.task&&(l?.type==="text"||l?.type==="paragraph")){u.text=u.text.replace(this.rules.other.listReplaceTask,""),l.raw=l.raw.replace(this.rules.other.listReplaceTask,""),l.text=l.text.replace(this.rules.other.listReplaceTask,"");for(let h=this.lexer.inlineQueue.length-1;h>=0;h--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)){this.lexer.inlineQueue[h].src=this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask,"");break}let d=this.rules.other.listTaskCheckbox.exec(u.raw);if(d){let h={type:"checkbox",raw:d[0]+" ",checked:d[0]!=="[ ]"};u.checked=h.checked,r.loose?u.tokens[0]&&["paragraph","text"].includes(u.tokens[0].type)&&"tokens"in u.tokens[0]&&u.tokens[0].tokens?(u.tokens[0].raw=h.raw+u.tokens[0].raw,u.tokens[0].text=h.raw+u.tokens[0].text,u.tokens[0].tokens.unshift(h)):u.tokens.unshift({type:"paragraph",raw:h.raw,text:h.raw,tokens:[h]}):u.tokens.unshift(h)}}else u.task&&(u.task=!1)}if(r.loose)for(let u of r.items){u.loose=!0;for(let l of u.tokens)l.type==="text"&&(l.type="paragraph")}return r}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=__(t[0]);return{type:"html",block:!0,raw:n,pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:n}}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),o=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:Vt(t[0],`
|
|
3893
|
+
`),href:o,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=x_(t[1]),o=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
3894
|
+
`):[],i={type:"table",raw:Vt(t[0],`
|
|
3895
|
+
`),header:[],align:[],rows:[]};if(n.length===o.length){for(let a of o)this.rules.other.tableAlignRight.test(a)?i.align.push("right"):this.rules.other.tableAlignCenter.test(a)?i.align.push("center"):this.rules.other.tableAlignLeft.test(a)?i.align.push("left"):i.align.push(null);for(let a=0;a<n.length;a++)i.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:i.align[a]});for(let a of r)i.rows.push(x_(a,i.header.length).map((s,u)=>({text:s,tokens:this.lexer.inline(s),header:!1,align:i.align[u]})));return i}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:Vt(t[0],`
|
|
3896
|
+
`),depth:t[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
|
|
3897
|
+
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=Vt(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=iO(t[2],"()");if(i===-2)return;if(i>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+i;t[2]=t[2].substring(0,i),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let o=t[2],r="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(o);i&&(o=i[1],r=i[3])}else r=t[3]?t[3].slice(1,-1):"";return o=o.trim(),this.rules.other.startAngleBracket.test(o)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?o=o.slice(1):o=o.slice(1,-1)),E_(t,{href:o&&o.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let o=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=t[o.toLowerCase()];if(!r){let i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return E_(n,r,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let o=this.rules.inline.emStrongLDelim.exec(e);if(!(!o||!o[1]&&!o[2]&&!o[3]&&!o[4]||o[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(o[1]||o[3])||!n||this.rules.inline.punctuation.exec(n))){let r=[...o[0]].length-1,i,a,s=r,u=0,l=o[0][0],d=n===l,h=l==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,t=t.slice(-1*e.length+r);(o=h.exec(t))!==null;){if(i=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!i)continue;if(a=[...i].length,o[3]||o[4]){s+=a;continue}else if(o[5]||o[6]){if(r%3&&!((r+a)%3)){u+=a;continue}if(d)break}if(s-=a,s>0)continue;a=Math.min(a,a+s+u);let g=[...o[0]][0].length,f=e.slice(0,r+o.index+g+a);if(Math.min(r,a)%2){let b=f.slice(1,-1);return{type:"em",raw:f,text:b,tokens:this.lexer.inlineTokens(b)}}let p=f.slice(2,-2);return{type:"strong",raw:f,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),o=this.rules.other.nonSpaceChar.test(n),r=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return o&&r&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let o=this.rules.inline.delLDelim.exec(e);if(o&&(!o[1]||!n||this.rules.inline.punctuation.exec(n))){let r=[...o[0]].length-1,i,a,s=r,u=this.rules.inline.delRDelim;for(u.lastIndex=0,t=t.slice(-1*e.length+r);(o=u.exec(t))!==null;){if(i=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!i||(a=[...i].length,a!==r))continue;if(o[3]||o[4]){s+=a;continue}if(s-=a,s>0)continue;a=Math.min(a,a+s);let l=[...o[0]][0].length,d=e.slice(0,r+o.index+l+a),h=d.slice(r,-r);return{type:"del",raw:d,text:h,tokens:this.lexer.inlineTokens(h)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,o;return t[2]==="@"?(n=t[1],o="mailto:"+n):(n=t[1],o=n),{type:"link",raw:t[0],text:n,href:o,autolink:!0,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,o;if(t[2]==="@")n=t[0],o="mailto:"+n;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(r!==t[0]);n=t[0],t[1]==="www."?o="http://"+t[0]:o=t[0]}return{type:"link",raw:t[0],text:n,href:o,autolink:!0,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},ut=class Sm{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||In,this.options.tokenizer=this.options.tokenizer||new Vl,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,top:!0};let n={other:Le,block:Gl.normal,inline:Vo.normal};this.options.pedantic?(n.block=Gl.pedantic,n.inline=Vo.pedantic):this.options.gfm&&(n.block=Gl.gfm,this.options.breaks?n.inline=Vo.breaks:n.inline=Vo.gfm),this.tokenizer.rules=n}static get rules(){return{block:Gl,inline:Vo}}static lex(t,n){return new Sm(n).lex(t)}static lexInline(t,n){return new Sm(n).inlineTokens(t)}lex(t){t=t.replace(Le.carriageReturn,`
|
|
3898
|
+
`),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let o=this.inlineQueue[n];this.inlineTokens(o.src,o.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],o=!1){this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(Le.tabCharGlobal," ").replace(Le.spaceLine,""));let r=1/0;for(;t;){if(t.length<r)r=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(s=>(i=s.call({lexer:this},t,n))?(t=t.substring(i.raw.length),n.push(i),!0):!1))continue;if(i=this.tokenizer.space(t)){t=t.substring(i.raw.length);let s=n.at(-1);i.raw.length===1&&s!==void 0?s.raw+=`
|
|
3899
|
+
`:n.push(i);continue}if(i=this.tokenizer.code(t)){t=t.substring(i.raw.length);let s=n.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
|
|
3869
3900
|
`)?"":`
|
|
3870
|
-
`)+i.raw,
|
|
3871
|
-
`+i.text,this.inlineQueue.at(-1).src=
|
|
3901
|
+
`)+i.raw,s.text+=`
|
|
3902
|
+
`+i.text,this.inlineQueue.at(-1).src=s.text):n.push(i);continue}if(i=this.tokenizer.fences(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.heading(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.hr(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.blockquote(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.list(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.html(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.def(t)){t=t.substring(i.raw.length);let s=n.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
|
|
3872
3903
|
`)?"":`
|
|
3873
|
-
`)+i.raw,
|
|
3874
|
-
`+i.raw,this.inlineQueue.at(-1).src=
|
|
3904
|
+
`)+i.raw,s.text+=`
|
|
3905
|
+
`+i.raw,this.inlineQueue.at(-1).src=s.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},n.push(i));continue}if(i=this.tokenizer.table(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.lheading(t)){t=t.substring(i.raw.length),n.push(i);continue}let a=t;if(this.options.extensions?.startBlock){let s=1/0,u=t.slice(1),l;this.options.extensions.startBlock.forEach(d=>{l=d.call({lexer:this},u),typeof l=="number"&&l>=0&&(s=Math.min(s,l))}),s<1/0&&s>=0&&(a=t.substring(0,s+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let s=n.at(-1);o&&s?.type==="paragraph"?(s.raw+=(s.raw.endsWith(`
|
|
3875
3906
|
`)?"":`
|
|
3876
|
-
`)+i.raw,
|
|
3877
|
-
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=
|
|
3907
|
+
`)+i.raw,s.text+=`
|
|
3908
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(i),o=a.length!==t.length,t=t.substring(i.raw.length);continue}if(i=this.tokenizer.text(t)){t=t.substring(i.raw.length);let s=n.at(-1);s?.type==="text"?(s.raw+=(s.raw.endsWith(`
|
|
3878
3909
|
`)?"":`
|
|
3879
|
-
`)+i.raw,
|
|
3880
|
-
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=
|
|
3881
|
-
|
|
3882
|
-
`:"<pre><code>"+(n?
|
|
3883
|
-
`}blockquote({tokens:
|
|
3884
|
-
${this.parser.parse(
|
|
3885
|
-
`}html({text:
|
|
3886
|
-
`}hr(
|
|
3887
|
-
`}list(
|
|
3888
|
-
`+
|
|
3889
|
-
`}listitem(
|
|
3890
|
-
`}checkbox({checked:
|
|
3891
|
-
`}table(
|
|
3910
|
+
`)+i.raw,s.text+=`
|
|
3911
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(i);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}linkInText(t){if(!t.includes("["))return!1;let n=this.tokenizer.rules.inline.link;for(let o of t.matchAll(this.tokenizer.rules.inline.blockSkip))if(n.test(o[0])&&t.charAt(o.index-1)!=="!")return!0;for(let o of t.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let r=o[0],i=r.lastIndexOf("[");if(!(r.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,r.slice(i+1,-1)))&&!(i>1&&this.linkInText(r.slice(1,i-1))))return!0}return!1}inlineTokens(t,n=[]){this.tokenizer.lexer=this;let o=t;if(this.tokens.links&&t.includes("[")){let s=this.tokenizer.rules.inline.reflinkSearch,u=l=>{let d=l.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,l.slice(d+1,-1)))return l;if(d>1&&l.charAt(0)!=="!"){let h=l.slice(1,d-1);if(this.linkInText(h))return"["+h.replace(s,u)+"]["+"a".repeat(l.length-d-2)+"]"}return"["+"a".repeat(l.length-2)+"]"};o=o.replace(s,u)}o=o.replace(this.tokenizer.rules.inline.anyPunctuation,s=>"+".repeat(s.length)),o=o.replace(this.tokenizer.rules.inline.blockSkip,(s,u,l)=>{let d=l?l.length:0;return s.slice(0,d)+"["+"a".repeat(s.length-d-2)+"]"}),o=this.options.hooks?.emStrongMask?.call({lexer:this},o)??o;let r=!1,i="",a=1/0;for(;t;){if(t.length<a)a=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}r||(i=""),r=!1;let s;if(this.options.extensions?.inline?.some(l=>(s=l.call({lexer:this},t,n))?(t=t.substring(s.raw.length),n.push(s),!0):!1))continue;if(s=this.tokenizer.escape(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.tag(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.link(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(s.raw.length);let l=n.at(-1);s.type==="text"&&l?.type==="text"?(l.raw+=s.raw,l.text+=s.text):n.push(s);continue}if(s=this.tokenizer.emStrong(t,o,i)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.codespan(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.br(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.del(t,o,i)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.autolink(t)){t=t.substring(s.raw.length),n.push(s);continue}if(!this.state.inLink&&(s=this.tokenizer.url(t))){t=t.substring(s.raw.length),n.push(s);continue}let u=t;if(this.options.extensions?.startInline){let l=1/0,d=t.slice(1),h;this.options.extensions.startInline.forEach(g=>{h=g.call({lexer:this},d),typeof h=="number"&&h>=0&&(l=Math.min(l,h))}),l<1/0&&l>=0&&(u=t.substring(0,l+1))}if(s=this.tokenizer.inlineText(u)){t=t.substring(s.raw.length),s.raw.slice(-1)!=="_"&&(i=s.raw.slice(-1)),r=!0;let l=n.at(-1);l?.type==="text"?(l.raw+=s.raw,l.text+=s.text):n.push(s);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return n}infiniteLoopError(t){let n="Infinite loop on byte: "+t;if(this.options.silent)console.error(n);else throw new Error(n)}},Zl=class{options;parser;constructor(e){this.options=e||In}space(e){return""}code({text:e,lang:t,escaped:n}){let o=(t||"").match(Le.notSpaceStart)?.[0],r=e?e.replace(Le.endingNewline,"")+`
|
|
3912
|
+
`:"";return o?'<pre><code class="language-'+et(o)+'">'+(n?r:et(r,!0))+`</code></pre>
|
|
3913
|
+
`:"<pre><code>"+(n?r:et(r,!0))+`</code></pre>
|
|
3914
|
+
`}blockquote({tokens:e}){return`<blockquote>
|
|
3915
|
+
${this.parser.parse(e)}</blockquote>
|
|
3916
|
+
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
3917
|
+
`}hr(e){return`<hr>
|
|
3918
|
+
`}list(e){let t=e.ordered,n=e.start,o="";for(let a=0;a<e.items.length;a++){let s=e.items[a];o+=this.listitem(s)}let r=t?"ol":"ul",i=t&&n!==1?' start="'+n+'"':"";return"<"+r+i+`>
|
|
3919
|
+
`+o+"</"+r+`>
|
|
3920
|
+
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
3921
|
+
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
3922
|
+
`}table(e){let t="",n="";for(let r=0;r<e.header.length;r++)n+=this.tablecell(e.header[r]);t+=this.tablerow({text:n});let o="";for(let r=0;r<e.rows.length;r++){let i=e.rows[r];n="";for(let a=0;a<i.length;a++)n+=this.tablecell(i[a]);o+=this.tablerow({text:n})}return o&&(o=`<tbody>${o}</tbody>`),`<table>
|
|
3892
3923
|
<thead>
|
|
3893
|
-
`+
|
|
3894
|
-
`+
|
|
3895
|
-
`}tablerow({text:
|
|
3896
|
-
${
|
|
3897
|
-
`}tablecell(
|
|
3898
|
-
`}strong({tokens:
|
|
3899
|
-
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+yt(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Tn=new Ed;function ie(t,e){return Tn.parse(t,e)}ie.options=ie.setOptions=function(t){return Tn.setOptions(t),ie.defaults=Tn.defaults,Hp(ie.defaults),ie};ie.getDefaults=fd;ie.defaults=_n;function SE(...t){return Tn.use(...t),ie.defaults=Tn.defaults,Hp(ie.defaults),ie}ie.use=SE;ie.walkTokens=function(t,e){return Tn.walkTokens(t,e)};ie.parseInline=Tn.parseInline;ie.Parser=at;ie.parser=at.parse;ie.Renderer=$s;ie.TextRenderer=xd;ie.Lexer=st;ie.lexer=st.lex;ie.Tokenizer=Fs;ie.Hooks=Zr;ie.parse=ie;var rN=ie.options,oN=ie.setOptions,iN=ie.walkTokens,sN=ie.parseInline;var aN=at.parse,lN=st.lex;var AE=new Ed({gfm:!0,breaks:!0}),Xp=["a","p","br","strong","em","b","i","u","s","del","code","pre","ul","ol","li","blockquote","h1","h2","h3","h4","h5","h6","hr","span","table","thead","tbody","tr","th","td"],Yp=["href","title","class","target","rel"],Kp={ALLOWED_TAGS:Xp,ALLOWED_ATTR:Yp,ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1},kE={...Kp,ALLOWED_TAGS:[...Xp,"img"],ALLOWED_ATTR:[...Yp,"src","alt","width","height"]},RE=/^language-[A-Za-z0-9_+#.-]+$/,IE=new Set(["CODE","PRE"]);function CE(t){t.nodeName==="A"&&t.hasAttribute("href")?(t.setAttribute("target","_blank"),t.setAttribute("rel","noopener noreferrer")):(t.removeAttribute("target"),t.removeAttribute("rel"));let e=t.getAttribute("class");if(e===null)return;let n=IE.has(t.nodeName)?e.split(/\s+/).filter(r=>RE.test(r)):[];if(n.length===0){t.removeAttribute("class");return}t.setAttribute("class",n.join(" "))}var js=null;function NE(){return js===null&&(js=Cp(),js.addHook("afterSanitizeAttributes",CE)),js}function eo(t,e){let n=e?.allowImages===!0,r=AE.parse(t,{async:!1});return NE().sanitize(r,n?kE:Kp).trim()}var Vs=class{#e;#t=null;#n=0;#o="";#r=null;constructor(e){this.#e=e}get deltas(){return this.#n}countDelta(){this.#n+=1}queue(e){this.#o=e,this.#i(),this.#r===null&&(this.#r=requestAnimationFrame(()=>{this.#r=null,this.into(this.#o)}))}into(e){this.#r!==null&&(cancelAnimationFrame(this.#r),this.#r=null),this.#o=e;let n=this.#i();return n.innerHTML=eo(e,{allowImages:this.#e.allowImages()}),this.#e.follow(),n}end(){this.#r!==null&&this.into(this.#o),this.#t=null}#i(){return this.#t===null&&(this.#t=this.#e.openBubble(),this.#n=0),this.#t}};var OE=4,ME=120;function Zp(t){if(typeof t!="object"||t===null)return null;let e=t.prompts;if(!Array.isArray(e))return null;let n=e.filter(r=>typeof r=="string").map(r=>r.trim()).filter(r=>r!==""&&r.length<=120).slice(0,4);return n.length===0?null:n}function to(t,e,n){let r=Zp(t);if(r===null)return null;let o=document.createElement("div");o.className="suggestions",o.setAttribute("part","suggestions"),o.setAttribute("role","group"),o.setAttribute("aria-label",e.suggestions);for(let i of r){let s=document.createElement("button");s.type="button",s.className="suggestion-chip",s.setAttribute("part","suggestion-chip"),s.textContent=i,s.addEventListener("click",()=>n(i)),o.appendChild(s)}return o}function Qp(t,e,n){let r=t.getAttribute("data-starters");if(r===null)return null;let o;try{o=JSON.parse(r)}catch{return console.warn(`<ag-ui-chat>: data-starters is not valid JSON, so no starters are shown. It takes an array of strings, e.g. data-starters='["Summarise this page"]'.`),null}return to({prompts:o},e,n)}function qs(t,e){for(let n of Array.from(t.querySelectorAll("pre"))){let r=n.querySelector("code");r===null||n.querySelector(".code-copy")!==null||(n.classList.add("has-copy"),n.append(LE(r,e)))}}function LE(t,e){let n=t.textContent,r=document.createElement("button");return r.type="button",r.className="code-copy",r.setAttribute("part","code-copy"),r.textContent=e.copyCode,r.title=e.copyCode,r.setAttribute("aria-label",e.copyCode),r.addEventListener("click",()=>{PE(n).then(o=>{DE(r,o?e.copied:e.copyFailed,e)})}),r}async function PE(t){let e=navigator.clipboard;if(e===void 0)return!1;try{return await e.writeText(t),!0}catch{return!1}}function DE(t,e,n){t.textContent=e,t.dataset.state=e===n.copied?"copied":"failed",setTimeout(()=>{t.textContent=n.copyCode,delete t.dataset.state},1500)}function Td(t){let e=t.replace(/[._-]+/g," ").trim();return e===""?t:e.charAt(0).toUpperCase()+e.slice(1)}var Ws=class{element;#e;#t;#n;#o;#r=!1;constructor(e=le){this.#o=e,this.element=document.createElement("div"),this.element.className="thoughts",this.element.setAttribute("part","thoughts"),this.element.setAttribute("data-streaming",""),this.#n=document.createElement("button"),this.#n.type="button",this.#n.className="thoughts-toggle",this.#n.setAttribute("part","thoughts-toggle"),this.#n.setAttribute("aria-expanded","true"),this.#e=document.createElement("span"),this.#e.className="thoughts-label",this.#e.setAttribute("part","thoughts-label"),this.#e.textContent=e.thinking,this.#n.append(this.#e),this.#t=document.createElement("pre"),this.#t.className="thoughts-body",this.#t.setAttribute("part","thoughts-body"),this.#n.addEventListener("click",()=>{this.#i(!this.#r)}),this.element.append(this.#n,this.#t)}stream(e){this.#t.textContent=e}collapse(){this.#r||(this.element.removeAttribute("data-streaming"),this.#e.textContent=this.#o.thoughts,this.#i(!0))}#i(e){this.#r=e,this.#t.hidden=e,this.#n.setAttribute("aria-expanded",String(!e))}};function Xs(t,e){try{return t()}catch(n){return console.warn(`ag-ui-chat: render failed for ${e}`,n),null}}function Jp(t,e){for(let n of Array.from(t.childNodes))n.nodeType===Node.TEXT_NODE?e.push({node:n,parent:t}):Jp(n,e)}function ef(t){let e=[];Jp(t,e);let n=0;for(let{node:r,parent:o}of e){let i=document.createDocumentFragment();for(let s of r.data.split(/(\s+)/)){if(s==="")continue;if(/\s/.test(s)){i.appendChild(document.createTextNode(s));continue}let a=document.createElement("span");a.className="word",a.style.setProperty("--ag-ui-word-index",String(n)),a.textContent=s,i.appendChild(a),n+=1}o.replaceChild(i,r)}}function tf({viewport:t,onMissedContent:e}){let n=!0,r=!1,o=()=>t.scrollHeight-t.scrollTop-t.clientHeight<=4,i=u=>{u!==r&&(r=u,e(r))},s=()=>{t.scrollTop=t.scrollHeight},a=()=>{n=o(),n&&i(!1)},l=()=>{if(n){s();return}i(!0)};t.addEventListener("scroll",a,{passive:!0});let d=new ResizeObserver(()=>{n&&s()});return d.observe(t),{follow:l,jump:()=>{n=!0,i(!1),s()},following:()=>n,dispose:()=>{t.removeEventListener("scroll",a),d.disconnect()}}}var Ys=class{#e;#t=new Map;#n=new Map;#o=new Set;#r;#i=null;#s=null;#a=null;constructor(e){this.#e=e}mountScroller(e,n){e.addEventListener("click",()=>{this.jump()},{signal:n}),this.#r=tf({viewport:this.#e.messages,onMissedContent:r=>{e.dataset.missed=String(r)}})}disposeScroller(){this.#r.dispose()}follow(){this.#r.follow()}jump(){this.#r.jump()}isEmpty(){return!this.#e.emptyWrap.hidden}card(e){return this.#t.get(e)}cards(){return this.#t.values()}forgetCard(e){this.#t.delete(e)}setCardElement(e,n){this.#n.set(e,n)}markServerSettled(e){this.#o.add(e)}isServerSettled(e){return this.#o.has(e)}collapseThoughts(){this.#a?.collapse()}closeGroup(){this.#s!==null&&this.#s.childElementCount===0&&(this.#s.remove(),this.updateEmptyState()),this.#s=null,this.#a=null}releaseTurn(){this.#s=null,this.#a=null,this.hidePending(),this.#t.clear()}forgetCards(){this.#o.clear(),this.#n.clear()}empty(){this.#e.messages.replaceChildren(this.#e.emptyWrap),this.updateEmptyState()}append(e,n){let r=document.createElement("div");return r.className=`message message--${e}`,r.setAttribute("part",`message message-${e}`),e===Le.ASSISTANT?(r.innerHTML=eo(n,{allowImages:this.#e.allowImages()}),qs(r,this.#e.strings()),this.ensureGroup().appendChild(r)):(this.#s=null,r.textContent=n,this.#e.messages.appendChild(r)),this.updateEmptyState(),e===Le.USER?this.jump():this.follow(),r}ensureGroup(){if(this.#s===null){let e=document.createElement("div");e.className="answer",e.setAttribute("part","answer"),this.#s=e,this.#e.messages.appendChild(e),this.updateEmptyState()}return this.#s}revealWords(e){this.#e.element.getAttribute("data-text-animation")==="word"&&ef(e)}updateEmptyState(){this.#e.emptyWrap.hidden=this.#e.messages.childElementCount>1,this.#e.element.toggleAttribute("data-empty",!this.#e.emptyWrap.hidden)}appendStoppedNote(){let e=document.createElement("div");e.className="stopped-note",e.setAttribute("part","stopped"),e.setAttribute("role","status"),e.textContent=this.#e.strings().stopped,this.ensureGroup().appendChild(e),this.updateEmptyState(),this.follow()}showPending(){if(this.#i!==null)return;let e=document.createElement("div");e.className="pending",e.setAttribute("part","pending"),e.setAttribute("role","status"),e.setAttribute("aria-label",this.#e.strings().thinking);for(let n=0;n<3;n+=1){let r=document.createElement("span");r.className="pending-dot",e.appendChild(r)}this.#i=e,this.ensureGroup().appendChild(e),this.updateEmptyState(),this.follow()}hidePending(){this.#i?.remove(),this.#i=null}showThoughts(){if(this.#a===null){this.#a=new Ws(this.#e.strings());let e=this.ensureGroup();e.insertBefore(this.#a.element,e.firstChild),this.updateEmptyState(),this.follow()}return this.#a}noticeIfSkillLoad(e){let n=cs(e);return n===null?!1:(this.appendNotice("\u2728",oe(this.#e.strings().usingSkill,{name:n}),"skill"),!0)}appendNotice(e,n,r,o){this.ensureGroup().appendChild(Is(e,n,r,o)),this.updateEmptyState(),this.follow()}renderToolOutput(e,n){let r=Xs(()=>e(n.args),`tool ${n.name}`);r!==null&&(this.#n.get(n.id)?.after(r),this.afterGrew())}afterGrew(){this.updateEmptyState(),this.follow()}cardFor(e){let n=this.#t.get(e.id);if(n!==void 0)return n;let r=this.#e.resolveTool(e.name)?.parameters[xe],o=typeof r=="string"?r:this.#e.toolSummaries()[e.name]??this.#e.serverSummary(e.name)??Td(e.name),i=new jr(e.name,e.args,o,this.#e.strings(),{formatPayload:s=>this.#e.formatToolPayload(s)});return this.#t.set(e.id,i),this.ensureGroup().appendChild(i.element),this.updateEmptyState(),this.follow(),i}};var Ks=class{#e;#t=new Map;#n=new Set;#o=new Map;constructor(e){this.#e=e}register(e){this.#t.set(e.type,e),this.#n.delete(e.type)}has(e){return this.#t.has(e)}unhandledTypes(){return[...this.#n]}clearBlocks(){this.#o.clear()}draw(e,n,r){let o=this.#t.get(n);if(o===void 0){this.#n.add(n);return}let i=Xs(()=>o.render(r),`activity ${n}`);if(i===null){this.#r(e,n,o.removedNotice,r);return}let s=this.#o.get(e);s===void 0?this.#e.ensureGroup().appendChild(i):s.replaceWith(i),this.#o.set(e,i),this.#e.afterTranscriptGrew()}#r(e,n,r,o){let i=this.#o.has(e);this.#o.get(e)?.remove(),this.#o.delete(e),console.warn(`ag-ui-chat: activity ${e} (${n}) was not drawable and has been removed. A chart's points must each be a finite JSON number; a numeric column serialised as a string (a Decimal, typically) is rejected rather than coerced.`,o),i&&r!==void 0&&this.#e.appendNotice("\u{1F4C9}",r,"chart-undrawable")}};var Zs=class extends Error{constructor(e){super(e),this.name="ConnectionLostError"}},no=class{#e;#t;#n;#o;#r;#i;#s;#a=new Set;#d=new Map;#u;#c;#p;#l;#h=!1;constructor(e){this.#e=e.agent,this.#t=e.handlers,this.#n=e.getTools??(()=>[]),this.#o=e.getContext??(()=>[]),this.#r=e.executeTool??null,this.#i=e.resolveInterrupts??null,this.#s=e.onPersist??(()=>{}),this.#u=e.connectionLostMessage??"Connection lost",this.#c=e.unfinishedMessage??"Not finished: the run ended or moved on before this tool call returned a result.",this.#p=e.declinedMessage??"User declined the action.";let n=e.maxToolRounds??Mn;this.#l=n>=1?Math.floor(n):Mn,this.#g();let r=e.onStateChanged;r!==void 0&&this.#e.subscribe({onStateChanged:({state:o})=>{r(o)}})}get state(){return this.#e.state}setState(e){this.#e.setState({...e})}get running(){return this.#e.isRunning}get messages(){return this.#e.messages}async send(e,n=[]){let r={id:be(),role:"user",content:e};n.length>0&&(r.attachments=n),this.#e.addMessage(r),this.#y(),await this.#m()}truncateToLastUser(){let e=[...this.#e.messages],n=-1;for(let[o,i]of e.entries())i.role==="user"&&(n=o);if(n===-1)return null;let r=e.slice(0,n+1);return this.#e.setMessages(r),this.#y(),r}async resume(){await this.#m()}addToolResult(e,n){this.#e.addMessage({id:be(),role:"tool",content:n,toolCallId:e}),this.#y()}cancel(){this.#h=!0,this.#e.abortRun()}async#m(){this.#h=!1;try{await this.#x(),this.#h&&this.#b()}catch(e){this.#h||UE(e)?this.#b():this.#t.onError(e instanceof Error?e.message:String(e))}finally{this.#t.onSettled()}}#b(){this.#y(),this.#t.onCancelled()}#g(){let e=this.#e.messages;e.some(n=>"outcome"in n)&&this.#e.setMessages(e.map(n=>{if(n.role!=="tool")return n;let{outcome:r,...o}=n;return this.#d.set(n.toolCallId,r),o}))}#w(e){let n=this.#e.messages,r=ls(n,o=>(this.#d.set(o,Pe.INTERRUPTED),{id:be(),role:"tool",content:this.#c,toolCallId:o}),e);r!==n&&(this.#e.setMessages([...r]),this.#y())}#f(e,n){for(let r of e){let o=r.toolCallId;o!==void 0&&n[r.id]?.status==="cancelled"&&(this.#d.set(o,Pe.DENIED),this.#e.addMessage({id:be(),role:"tool",content:this.#p,toolCallId:o}))}this.#y()}#y(){this.#s(this.annotatedMessages)}get annotatedMessages(){let e=this.#e.messages;return this.#d.size===0?e:e.map(n=>{if(n.role!=="tool")return n;let r=this.#d.get(n.toolCallId);return r===void 0?n:{...n,outcome:r}})}async#x(){let e,n=new Set;for(let r=0;r<this.#l;r+=1){if(this.#h)return;let o=[],i={terminal:!1,errored:!1,interrupts:[]},s={tools:this.#n(),context:this.#o()};if(e!==void 0&&(s.resume=e),this.#w(n),await this.#e.runAgent(s,this.#_(o,i)),e=void 0,n=new Set,this.#y(),this.#h)return;if(!i.terminal)throw new Zs(this.#u);if(i.errored)return;if(i.interrupts.length>0){if(this.#i===null)return;let l=await this.#i(i.interrupts);if(this.#h){this.#f(i.interrupts,l);return}e=Oh(i.interrupts,l),n=new Set(i.interrupts.flatMap(({toolCallId:d})=>d??[]));continue}if(this.#r===null||o.length===0)return;let a=!1;for(let l of o){if(this.#h)return;let d=await this.#r(l);if(d!==null){if(d.halt===!0)return;d.outcome!==void 0&&this.#d.set(l.id,d.outcome),this.#e.addMessage({id:be(),role:"tool",content:d.content,toolCallId:l.id}),this.#y(),a=!0}}if(!a)return}}#_(e,n){let r=this.#t,o=this.#a,i=this.#d,s=()=>this.#h,a=new Set;return{onRunInitialized(){r.onRunStart()},onTextMessageStartEvent({event:l}){o.has(l.messageId)&&console.warn(`<ag-ui-chat>: the server reused message id "${l.messageId}", which was already closed. Its content will be appended to that earlier message rather than starting a new one, and the merged result is what gets persisted. Issue a fresh id per message.`)},onTextMessageContentEvent({textMessageBuffer:l}){r.onTextDelta(l)},onTextMessageEndEvent({event:l,textMessageBuffer:d}){o.add(l.messageId),r.onTextEnd(d)},onToolCallEndEvent({event:l,toolCallName:d,toolCallArgs:u}){let m={id:l.toolCallId,name:d,args:u};e.push(m),r.onToolCall(m)},onToolCallResultEvent({event:l}){let d=l.outcome;typeof d=="string"&&i.set(l.toolCallId,d),r.onToolResult(l.toolCallId,l.content,d)},onActivitySnapshotEvent({event:l,messages:d}){if(d.some(m=>m.id===l.messageId&&m.role==="activity")){r.onActivityChanged(l.messageId,l.activityType,l.content);return}r.onActivity(l.activityType,l.content,l.messageId)},onActivityDeltaEvent({event:l}){a.add(l.messageId)},onCustomEvent({event:l}){r.onCustomEvent(l.name,l.value)},onSubagentStartedEvent({event:l}){r.onSubAgentStarted(l.subagentRunId,l.name,l.parentToolCallId??null)},onSubagentFinishedEvent({event:l}){r.onSubAgentFinished(l.subagentRunId)},onSubagentErrorEvent({event:l}){r.onSubAgentError(l.subagentRunId,l.message)},onMessagesSnapshotEvent({event:l}){r.onMessagesSnapshot(l.messages)},onMessagesChanged({messages:l}){if(a.size!==0){for(let d of a){let u=l.find(m=>m.id===d);u!==void 0&&u.role==="activity"&&r.onActivityChanged(d,u.activityType,u.content)}a.clear()}},onReasoningStartEvent(){r.onReasoningStart()},onReasoningMessageContentEvent({reasoningMessageBuffer:l}){r.onReasoningDelta(l)},onReasoningMessageEndEvent({reasoningMessageBuffer:l}){r.onReasoningDelta(l)},onReasoningEndEvent(){r.onReasoningEnd()},onRunFinishedEvent(l){n.terminal=!0,l.outcome==="interrupt"&&(n.interrupts=l.interrupts)},onRunErrorEvent({event:l}){n.terminal=!0,n.errored=!0,!s()&&r.onError(l.message)},onRunFinalized(){n.terminal=!0,r.onRunEnd()}}}};function UE(t){return t instanceof Error?t.name==="AbortError"||t instanceof TypeError&&/abort/i.test(t.message):!1}var nf="ag-ui-chat",dr="thread",_d="threads",ro="messages:",Js="checkpoint:",oo="minted:",HE=60,GE=100,zE="New conversation",rf=!1;function lt(t,e){try{sessionStorage.setItem(t,e)}catch{if(rf)return;rf=!0,console.warn("<ag-ui-chat>: the browser refused a sessionStorage write \u2014 the quota is full, or storage is disabled for this context. The conversation continues, but it will not survive a page reload. Deleting a long conversation from the history drawer frees the quota.")}}function Qs(t){return t===""?nf:`${nf}@${t}`}var Xe=class t{#e;constructor(e=""){this.#e=Qs(e),e!==""&&t.adopt("",e)}static adopt(e,n){let r=`${Qs(e)}:`,o=`${Qs(n)}:`;for(let[i,s]of of(r)){let a=sessionStorage.getItem(i),l=o+s;a!==null&&sessionStorage.getItem(l)===null&<(l,a),sessionStorage.removeItem(i)}}static purge(e){for(let[n]of of(`${Qs(e)}:`))sessionStorage.removeItem(n)}threadId(){return sessionStorage.getItem(this.#r(dr))??this.newThread()}newThread(){let e=be();return lt(this.#r(dr),e),lt(this.#r(oo+e),"1"),e}isUnsent(e){return sessionStorage.getItem(this.#r(oo+e))!==null&&sessionStorage.getItem(this.#r(ro+e))===null}loadMessages(e){return Promise.resolve(this.#i(this.#r(ro+e)))}saveMessages(e,n){lt(this.#r(ro+e),JSON.stringify(n)),sessionStorage.removeItem(this.#r(oo+e)),this.#t(e,n)}loadCheckpoint(e){return this.#i(this.#r(Js+e))}saveCheckpoint(e,n){let r=this.#r(Js+e);if(n===null){sessionStorage.removeItem(r);return}lt(r,JSON.stringify(n))}clear(e){sessionStorage.removeItem(this.#r(ro+e)),sessionStorage.removeItem(this.#r(Js+e)),sessionStorage.removeItem(this.#r(oo+e)),this.#o(this.#n().filter(n=>n.threadId!==e)),sessionStorage.getItem(this.#r(dr))===e&&sessionStorage.removeItem(this.#r(dr))}listThreads(){let e=this.#n().sort((n,r)=>r.updatedAt-n.updatedAt).map(({threadId:n,title:r,updatedAt:o,preview:i})=>({threadId:n,title:r,updatedAt:o,preview:i}));return Promise.resolve(e)}setActiveThread(e){lt(this.#r(dr),e)}renameThread(e,n){let r=this.#n(),o=r.find(i=>i.threadId===e);o!==void 0&&(o.title=n,o.titleCustom=!0,this.#o(r))}#t(e,n){let r=this.#n(),o=r.find(a=>a.threadId===e),i=$E(n),s=Date.now();o===void 0?r.push({threadId:e,title:sf(n),titleCustom:!1,preview:i,updatedAt:s}):(o.preview=i,o.updatedAt=s,o.titleCustom||(o.title=sf(n))),this.#o(r)}#n(){return this.#i(this.#r(_d))??[]}#o(e){let n=this.#r(_d);if(e.length===0){sessionStorage.removeItem(n);return}lt(n,JSON.stringify(e))}#r(e){return`${this.#e}:${e}`}#i(e){let n=sessionStorage.getItem(e);if(n===null)return null;try{return JSON.parse(n)}catch{return null}}};function of(t){let e=[];for(let n=0;n<sessionStorage.length;n+=1){let r=sessionStorage.key(n);if(r===null||!r.startsWith(t))continue;let o=r.slice(t.length);FE(o)&&e.push([r,o])}return e}function FE(t){return t===dr||t===_d||t.startsWith(ro)||t.startsWith(Js)||t.startsWith(oo)}function sf(t){for(let e of t)if(e.role==="user"){let n=af(e.content);if(n!=="")return lf(n,HE)}return zE}function $E(t){for(let e of[...t].reverse()){let n=af(e.content);if(n!=="")return lf(n,GE)}return""}function af(t){return typeof t=="string"?t.replace(/\s+/g," ").trim():""}function lf(t,e){return t.length<=e?t:`${t.slice(0,e-1).trimEnd()}\u2026`}function Sd(t){let e=t.headers??{},n=new Set;return new Mh({url:t.endpoint,headers:e,initialState:{...t.initialState??{}},fetch:(r,o)=>{let i=t.getHeaders?.(),s=[...new Set([...Object.keys(e),...Object.keys(i??{})])].sort();if(as(r,s,t.trustedOrigins??[],n),i===void 0)return fetch(r,et(o,t.credentials));let a=new Headers(o?.headers);for(let[l,d]of Object.entries(i))a.set(l,d);return fetch(r,et({...o,headers:a},t.credentials))},...t.threadId!==void 0?{threadId:t.threadId}:{},...t.initialMessages!==void 0?{initialMessages:[...t.initialMessages]}:{}})}function df(t){let e=t.getAttribute("data-max-tool-rounds");return e===null?Mn:Number.parseInt(e,10)}var io=class{#e;#t;#n;#o;#r;#i=new Set;#s=new Map;constructor(e,n=()=>({}),r=new Xe,o=()=>{},i=!0){this.#e=e.endsWith("/")?e:`${e}/`,this.#t=n,this.#n=r,this.#o=o,this.#r=i}threadId(){return this.#n.threadId()}setActiveThread(e){this.#n.setActiveThread(e)}newThread(){return ss(this.#n)}isUnsent(e){return this.#n.isUnsent?.(e)===!0}saveMessages(e,n){this.#n.saveMessages(e,this.#r?n:[])}loadCheckpoint(e){return this.#n.loadCheckpoint(e)}saveCheckpoint(e,n){this.#n.saveCheckpoint(e,n)}renameThread(e,n){this.#n.renameThread(e,n),this.#s.set(e,n),this.#p(e,"PATCH",{title:n})}clear(e){this.#n.clear(e),this.#i.add(e),this.#p(e,"DELETE")}async listThreads(){let e=await this.#a();return e===null?this.#n.listThreads():e.filter(n=>!this.#i.has(n.thread_id)).map(n=>this.#u(n))}async loadMessages(e){if(this.#n.isUnsent?.(e)===!0)return null;let n=await this.#c(`${this.#e}${encodeURIComponent(e)}/`);if(n===null||!n.ok)return this.#n.loadMessages(e);let r=await this.#d(n);return r===null?this.#n.loadMessages(e):r.messages??null}async#a(){let e=await this.#c(this.#e);if(e===null||!e.ok)return null;let n=await this.#d(e);return n===null?null:n.threads??[]}async#d(e){try{return await e.json()}catch{return null}}#u(e){return{threadId:e.thread_id,title:this.#s.get(e.thread_id)??e.title,updatedAt:e.updated_at===null?Number.NaN:Date.parse(e.updated_at),preview:e.preview}}async#c(e){try{return await fetch(e,et({headers:this.#t()},this.#o()))}catch{return null}}async#p(e,n,r){let o=this.#t();try{await fetch(`${this.#e}${encodeURIComponent(e)}/`,et({method:n,headers:r===void 0?o:{...o,"content-type":"application/json"},body:r===void 0?null:JSON.stringify(r)},this.#o()))}catch{}}};function cf(){return{tools:[],serverSettled:new Set,invalidated:new Set,announcedOutcome:!1}}function BE(t,e){let n={};for(let[r,o]of Object.entries(t))n[r]=(...i)=>{e()&&o(...i)};return n}var ea=class{#e;#t=cf();constructor(e){this.#e=e}detach(){this.#t=cf()}forClient(){let e=this.#t,n=()=>e===this.#t,{onSettled:r,...o}=this.#n(e);return{...BE(o,n),onSettled:()=>{n()&&r(),this.#o(e)}}}#n(e){return{onRunStart:()=>{this.#e.running()||(e.announcedOutcome=!1,this.#e.announcer.announce(this.#e.strings().announceResponding)),this.#e.setRunning(!0),this.#e.transcript.ensureGroup(),this.#e.transcript.showPending()},onReasoningStart:()=>{this.#e.transcript.hidePending(),this.#e.transcript.showThoughts()},onReasoningDelta:n=>{this.#e.transcript.showThoughts().stream(n)},onReasoningEnd:()=>{},onTextDelta:n=>{this.#e.transcript.hidePending(),this.#e.transcript.collapseThoughts(),this.#e.stream.queue(n),this.#e.stream.countDelta()},onTextEnd:n=>{if(n===""){this.#e.stream.end();return}let r=this.#e.stream.into(n);this.#e.stream.deltas<=1&&this.#e.transcript.revealWords(r),qs(r,this.#e.strings()),this.#e.actions.attach(r),this.#e.stream.end(),this.#e.noteUnread()},onToolCall:n=>{this.#e.transcript.hidePending(),!this.#e.transcript.noticeIfSkillLoad(n)&&(e.tools.push({id:n.id,name:n.name}),this.#e.transcript.cardFor(n))},onActivity:(n,r,o)=>{this.#e.activities.draw(o,n,r)},onCustomEvent:(n,r)=>{if(n===Ia){this.#r(e,r);return}if(n===sc){this.#e.subagents.report(r);return}this.#e.element.dispatchEvent(new CustomEvent(Sa,{detail:{name:n,value:r},bubbles:!0,composed:!0}))},onSubAgentStarted:(n,r,o)=>{this.#e.subagents.start(n,r,o)},onSubAgentFinished:n=>{this.#e.subagents.finish(n)},onSubAgentError:(n,r)=>{this.#e.subagents.fail(n,r)},onMessagesSnapshot:()=>{this.#e.transcript.appendNotice("\u{1F504}",this.#e.strings().historyReplaced,"history-replaced")},onToolResult:(n,r,o)=>{let i=this.#e.transcript.card(n);i!==void 0&&(i.settle(Gr(o),r),this.#e.transcript.markServerSettled(n),e.serverSettled.add(n),this.#e.transcript.showPending())},onActivityChanged:(n,r,o)=>{this.#e.activities.draw(n,r,o)},onRunEnd:()=>{this.#e.transcript.hidePending(),this.#e.stream.end()},onError:n=>{e.announcedOutcome=!0,this.#e.announcer.announce(this.#e.strings().announceFailed),this.#e.transcript.hidePending();let r=this.#e.appendMessage(Le.ASSISTANT,`\u26A0\uFE0F ${n}`);r.classList.add("message--failed"),this.#e.actions.attach(r,{rateable:!1}),this.#e.transcript.revealWords(r),this.#e.stream.end()},onCancelled:()=>{e.announcedOutcome=!0,this.#e.announcer.announce(this.#e.strings().announceStopped),this.#e.transcript.hidePending(),this.#e.transcript.appendStoppedNote(),this.#e.stream.end()},onSettled:()=>{e.announcedOutcome||this.#e.announcer.announce(this.#e.strings().announceAnswerReady),this.#e.transcript.hidePending(),this.#e.setRunning(!1),this.#e.stream.end();for(let n of this.#e.transcript.cards())n.settled||n.settle(te.INTERRUPTED,this.#e.strings().callNotFinished);this.#e.transcript.closeGroup()}}}#o(e){let n=e.tools.map(({id:o,name:i})=>({name:i,side:e.serverSettled.has(o)?"server":"client"})),r=[...e.invalidated];e.tools.length=0,e.serverSettled.clear(),e.invalidated.clear(),this.#e.element.dispatchEvent(new CustomEvent(_a,{detail:{tools:n,invalidated:r},bubbles:!0,composed:!0}))}#r(e,n){let r=n??{},o=Array.isArray(r.keys)?r.keys.filter(i=>typeof i=="string"):[];if(o.length!==0){for(let i of o)e.invalidated.add(i);this.#e.element.dispatchEvent(new CustomEvent(Aa,{detail:{keys:o,reason:typeof r.reason=="string"?r.reason:null},bubbles:!0,composed:!0}))}}};var Ad=new Set,ta=class{#e;#t="";#n=null;#o="";#r="";#i=null;constructor(e){this.#e=e}claim(){this.#t=this.#s()}release(){this.#n!==null&&(Ad.delete(this.#n),this.#n=null)}conversationNamespace(e){return e===""?this.#t:`${this.#t}#${e}`}scopeStore(e,n){if(!(e instanceof Xe))return e;let r=this.conversationNamespace(n);return this.#i=r===""?e:new Xe(r),this.#i}rescopeStore(e){return this.#i===null?null:(this.#i=new Xe(e),this.#i)}key(e){return this.#t===""?e:`${e}:${this.#t}`}readScopedItem(e){let n=sessionStorage.getItem(this.key(e));return n!==null||this.#t===""?n:sessionStorage.getItem(e)}readPreference(e){try{let n=localStorage.getItem(this.key(e));if(n!==null)return n}catch{}return this.readScopedItem(e)}writePreference(e,n){let r=this.key(e);try{localStorage.setItem(r,n)}catch{}lt(r,n)}clearPreference(e){let n=this.key(e);try{localStorage.removeItem(n)}catch{}try{sessionStorage.removeItem(n)}catch{}}#s(){let e=this.#e.id(),n=e!==""?e:this.#e.endpoint();return n===""?"":this.#r===n?this.#o:Ad.has(n)?(this.#r=n,this.#o=`${n}~${be()}`,console.warn(`<ag-ui-chat>: another element on this page already stores its conversation under "${n}", so this one has been given a throwaway namespace of its own \u2014 the two would otherwise share a thread pointer, a history drawer and every message. Give each <ag-ui-chat> its own id to keep them apart and let this one restore its conversation across reloads.`),this.#o):(Ad.add(n),this.#n=n,n)}};var jE=["data-attachments-url","data-attachment-accept","data-attachment-max-bytes","data-transcribe-url","data-threads-url","data-threads-cache","data-tools-url","data-skills-url","data-skills","data-prompt-chips","data-slash-commands","data-theme-toggle","data-strings","data-icon-url"],Rd=["omit","same-origin","include"];function kd(t){return Rd.includes(t)}var uf="ag-ui-chat:collapsed",hf="ag-ui-chat:theme",so=class extends HTMLElement{agentFactory=Sd;headers={};getHeaders=null;trustedOrigins=[];allowImages=!1;formatRelativeTime=null;autoConfirm=!1;askUser=!1;askUserRenderer=null;approvalRenderer=null;approveWithEdits=!1;confirmPredicate=null;getTools=()=>this.#R.defaultTools();getContext=()=>[...Va(this.getPageMap,this.autoInjectPageMap)];routeMap=[];navigate=null;getPageMap=null;autoInjectPageMap=!0;conversationStore=new Xe;uploadHandler=null;transcribeHandler=null;navigationResult=()=>({navigated:!0,url:window.location.href});skillContext=()=>({});toolSummaries={};formatToolPayload=null;strings={};resolvePageTarget=e=>document.querySelector(e);#e=new Set;#t=le;#n=new Ns({card:e=>this.#v.card(e),strings:()=>this.#t,follow:()=>this.#v.follow()});#o=new Ks({ensureGroup:()=>this.#v.ensureGroup(),afterTranscriptGrew:()=>this.#v.afterGrew(),appendNotice:(e,n,r)=>this.#v.appendNotice(e,n,r)});#r=new Us({element:this,strings:()=>this.#t,retry:()=>{this.retryLastTurn()}});#i;#s=new Rs;#a=document.createElement("button");#d;#u=document.createElement("div");#c;#p;#l;#h;#m;#b;#g;#w;#f;#y;#x;#_;#L;#A;#E;#k;#N=document.createElement("span");#F=0;#O;#v;#P;#ee;#le=document.createElement("span");#I;#T;#$=[];#U=[];#M=document.createElement("div");#H=null;#B=()=>{this.#T.publishVisualViewport(),!this.#T.dragging()&&this.#T.restoreLauncherPosition()};#X;#te;#j=!1;#Y=new AbortController;#de=!1;#ne=null;#D=null;#G={};#C=!1;#re=new _s;#R=new ds({element:this,routeMap:()=>this.routeMap,navigate:()=>this.navigate,getPageMap:()=>this.getPageMap,resolvePageTarget:e=>this.resolvePageTarget(e),getTools:()=>this.getTools(),askUser:()=>this.askUser,askUserRenderer:()=>this.askUserRenderer,decision:this.#re,ensureGroup:()=>this.#v.ensureGroup(),strings:()=>this.#t,hidePending:()=>this.#v.hidePending(),updateEmptyState:()=>this.#v.updateEmptyState(),follow:()=>this.#v.follow(),fetchInit:e=>this.#pe(e)});#ce=new Vs({openBubble:()=>this.appendMessage(Le.ASSISTANT,""),allowImages:()=>this.allowImages,follow:()=>this.#v.follow()});#S=new ta({id:()=>this.id,endpoint:()=>this.endpoint});#V;constructor(){super(),this.#i=this.attachShadow({mode:"open"}),this.#c=document.createElement("div"),this.#p=document.createElement("div"),this.#l=document.createElement("textarea"),this.#h=document.createElement("button"),this.#m=document.createElement("span"),this.#y=document.createElement("div"),this.#x=document.createElement("button"),this.#_=document.createElement("input"),this.#L=document.createElement("div"),this.#X=document.createElement("span"),this.#A=document.createElement("button"),this.#E=document.createElement("button"),this.#k=document.createElement("span"),this.#O=document.createElement("div"),this.#v=new Ys({element:this,messages:this.#p,emptyWrap:this.#O,strings:()=>this.#t,allowImages:()=>this.allowImages,resolveTool:e=>this.#R.resolve(e),toolSummaries:()=>this.toolSummaries,serverSummary:e=>this.#R.summary(e),formatToolPayload:e=>this.formatToolPayload?.(e)??null}),this.#P=new hs({element:this,transcript:this.#v,tools:this.#R,decision:this.#re,strings:()=>this.#t,announce:e=>this.#s.announce(e),autoConfirm:()=>this.autoConfirm,confirmPredicate:()=>this.confirmPredicate,getPageMap:()=>this.getPageMap,navigate:()=>this.navigate,approveWithEdits:()=>this.approveWithEdits,approvalRenderer:()=>this.approvalRenderer,getContext:()=>this.getContext(),conversationStore:()=>this.conversationStore,threadId:()=>this.#f.threadId}),this.#ee=new ea({element:this,transcript:this.#v,stream:this.#ce,actions:this.#r,activities:this.#o,subagents:this.#n,announcer:this.#s,strings:()=>this.#t,running:()=>this.#C,setRunning:e=>this.#W(e),appendMessage:(e,n)=>this.appendMessage(e,n),noteUnread:()=>this.#Oe()}),this.#T=new ks({element:this,launcher:this.#E,root:this.#i,connected:()=>this.#j,collapsed:()=>this.collapsed,collapsible:()=>zr(this.getAttribute("placement")),strings:()=>this.#t,readPreference:e=>this.#S.readPreference(e),writePreference:(e,n)=>this.#S.writePreference(e,n),clearPreference:e=>this.#S.clearPreference(e),announceSurfaceChange:(e,n)=>this.#_e(e,n)}),this.#d=new xs({element:this,root:this.#i,messages:this.#p,messagesWrap:this.#u,input:this.#l,strings:()=>this.#t,autoGrow:()=>Ut(this.#l),quote:e=>this.quote(e)}),this.#I=new vs({element:this,chat:this.#c,slot:this.#L,fileInput:this.#_,button:this.#x,strings:()=>this.#t,uploadHandler:()=>this.uploadHandler,headersFor:e=>this.#q(e),credentialsOption:()=>this.#ie()}),this.#te=new ys({element:this,slot:this.#X,input:this.#l,strings:()=>this.#t,transcribeHandler:()=>this.transcribeHandler,headersFor:e=>this.#q(e),credentialsOption:()=>this.#ie(),onInput:()=>this.#xe()}),this.registerActivityRenderer({type:Na,render:e=>{let n=VE(e);return n===null?null:Is("\u{1F5DC}",oe(this.#t.historyCompacted,{count:n}),"compaction")}}),this.registerActivityRenderer({type:Ra,render:e=>to(e,this.#t,n=>{this.sendMessage(n)})}),this.#b=new ws(e=>this.#V.apply(e)),this.#V=new Ao({element:this,menu:this.#b,input:this.#l,hint:this.#y,strings:()=>this.#t,context:()=>this.skillContext(),flag:e=>this.#Ae(e),readJsonAttribute:e=>this.#fe(e),fetchInit:e=>this.#pe(e),send:e=>{this.sendMessage(e)},submit:()=>{this.#se()},autoGrow:()=>Ut(this.#l)}),this.#g=new Ts({onSelect:e=>{this.#f.switchThread(e)},onNew:()=>{this.newChat(),this.#f.refreshDrawer()},onRename:(e,n)=>{this.#f.renameThread(e,n)},onDelete:e=>{this.#f.deleteThread(e)}}),this.#w=new Ur((e,n)=>{this.#f.continueRun(e,n).catch(r=>{console.warn("<ag-ui-chat>: continuing a run failed",r)})}),this.#f=new Es({element:this,drawer:this.#g,checkpoints:this.#w,transcript:this.#v,actions:this.#r,activities:this.#o,tools:this.#R,input:this.#l,hint:this.#y,strings:()=>this.#t,conversationStore:()=>this.conversationStore,formatRelativeTime:()=>this.formatRelativeTime,navigationResult:()=>this.navigationResult,headersFor:e=>this.#q(e),requestCredentials:()=>this.#K(),appendMessage:(e,n)=>this.appendMessage(e,n),autoGrow:()=>Ut(this.#l),continuationEnded:()=>this.#Ee(),client:()=>this.#D,ensureClient:()=>this.#ae(),buildClient:e=>this.#Te(e),releaseClient:()=>{this.#D=null},running:()=>this.#C,cancelRun:()=>this.#z(),resetState:()=>this.#Z(),setRunning:e=>this.#W(e)})}static get observedAttributes(){return["title-text","placement","credentials","user-key","user-name",...jE]}attributeChangedCallback(e,n,r){if(e==="credentials"){r!==null&&!kd(r)&&console.error(`<ag-ui-chat>: credentials="${r}" is not a fetch credentials mode (${Rd.join(" / ")}) \u2014 it is being ignored, so requests use the browser default and cross-origin cookies will not be sent.`);return}if(e==="placement"){this.#T.releaseOwnedAxes(),this.#T.releaseLauncherPosition(),!zr(this.getAttribute("placement"))&&this.collapsed&&this.setCollapsed(!1),requestAnimationFrame(()=>this.#T.syncResizeAnchor());return}if(e==="title-text"){this.#m.textContent=r??this.#t.title,this.#N.textContent=this.#m.textContent;return}if(e==="user-name"){this.#he();return}if(e==="user-key"){this.#j&&(n??"")!==(r??"")&&this.#Ce(n??"",r??"");return}n===r||!this.#j||console.warn(`<ag-ui-chat>: "${e}" was changed after the element connected, and is read only while connecting \u2014 this assignment has no effect. Set it before the element enters the DOM (in the markup, or on the element before appending it); frameworks that patch attributes after mount should bind it at creation. To apply a new value now, remove and re-insert the element.`)}registerTool(e){this.#R.register(e)}get sharedState(){return this.#ue()?.state??this.#G}set sharedState(e){this.#G={...e},this.#ue()?.setState(this.#G)}#ue(){return this.#f.continuation??this.#D}registerPageState(e){this.#R.registerPageState(e)}registerStateHook(e){this.registerPageState(e)}get endpoint(){return this.getAttribute("endpoint")??""}set endpoint(e){this.setAttribute("endpoint",e)}get userKey(){return this.getAttribute("user-key")??""}set userKey(e){this.setAttribute("user-key",e)}get userName(){return this.getAttribute("user-name")??""}set userName(e){this.setAttribute("user-name",e)}#he(){let e=this.userName.trim();this.#le.textContent=e===""?this.#t.greetingNoName:oe(this.#t.greeting,{name:e})}get credentials(){let e=this.getAttribute("credentials");return e!==null&&kd(e)?e:null}set credentials(e){if(e===null){this.removeAttribute("credentials");return}if(!kd(e))throw new TypeError(`<ag-ui-chat>: credentials must be one of ${Rd.map(n=>`"${n}"`).join(", ")} (got ${JSON.stringify(e)}).`);this.setAttribute("credentials",e)}#oe(){return{...this.headers,...this.getHeaders?.()}}#q(e){let n=this.#oe();return as(e,Object.keys(n),this.trustedOrigins,this.#e),n}#K(){return this.credentials??void 0}#ie(){let e=this.#K();return e===void 0?{}:{credentials:e}}#pe(e){return et({headers:this.#q(e)},this.#K())}get toolDisplay(){let e=this.getAttribute("data-tool-display");return e===Ln.INLINE||e===Ln.MINIMAL||e===Ln.COMPACT?e:Ln.FULL}set toolDisplay(e){this.setAttribute("data-tool-display",e)}connectedCallback(){if(this.#Y=new AbortController,this.#de&&this.#be(),this.#de=!0,this.#S.claim(),this.#T.restoreSize(),requestAnimationFrame(()=>{this.#T.restoreLauncherPosition(),this.#T.syncResizeAnchor()}),this.#t=Pl({...this.#ke(),...this.strings}),this.getAttribute("data-theme-toggle")!==null){let e=this.#S.readPreference(hf);e!==null&&this.setAttribute("theme",e)}this.#Ne(),this.#g.setStrings(this.#t),this.#w.setStrings(this.#t),zr(this.getAttribute("placement"))&&this.#Ie()&&this.setAttribute("collapsed",""),this.#we(),this.#V.init(),this.conversationStore=this.#S.scopeStore(this.#Re(),this.userKey),window.addEventListener("resize",this.#B),window.visualViewport?.addEventListener("resize",this.#B),window.visualViewport?.addEventListener("scroll",this.#B),this.#T.publishVisualViewport(),this.#me(),this.#I.wire(this.#Y.signal),this.#te.wire(),this.#f.adoptActiveThread(),queueMicrotask(()=>this.#Se()),this.#f.rehydrate(),this.#j=!0}#Se(){this.#j&&(this.#R.fetchCatalog(),this.#V.fetch())}async reload(){this.#z(),this.#Z(),this.#W(!1),await Promise.all([this.#R.fetchCatalog(),this.#V.fetch(),this.#f.rehydrate()])}disconnectedCallback(){this.#j=!1,this.#Y.abort(),window.removeEventListener("resize",this.#B),window.visualViewport?.removeEventListener("resize",this.#B),window.visualViewport?.removeEventListener("scroll",this.#B),this.#S.release(),this.#z(),this.#d.detachPageOffer(),this.#I.tray?.dispose(),this.#te.dispose(),this.#v.disposeScroller(),this.#s.dispose()}#Ae(e){let n=this.getAttribute(e);return n!==null&&n!=="false"}#fe(e){let n=this.getAttribute(e);if(n===null)return null;try{return JSON.parse(n)}catch{return console.warn(`<ag-ui-chat>: ${e} is not valid JSON, so it was ignored entirely and the built-in default is being used. Check the quoting -- JSON inside an HTML attribute needs single quotes around the attribute value, or its own double quotes escaped.`),null}}#ke(){let e=this.#fe("data-strings");return typeof e=="object"&&e!==null?e:{}}quote(e){this.#d.insert(e)}offerQuoteInPage(e=document.body){return this.#d.offerInPage(e)}#me(){this.#ne=null;let e=this.getAttribute("data-threads-url");if(e!==null){let n=this.conversationStore,r=new io(e,()=>this.#q(e),n,()=>this.#K(),this.getAttribute("data-threads-cache")!=="false");this.#ne={remote:r,inner:n},this.conversationStore=r}}#Re(){let e=this.#ne;return e!==null&&this.conversationStore===e.remote?e.inner:this.conversationStore}setSkills(e){this.#V.setClientSkills(e)}get collapsed(){return this.hasAttribute("collapsed")}set collapsed(e){this.setCollapsed(e)}setCollapsed(e,n={}){e&&!zr(this.getAttribute("placement"))||(n.announce===!0&&e&&!this.collapsed&&this.#_e(this.#t.chatMinimised,null),e||this.#T.restoreLauncherPosition(),e?this.setAttribute("collapsed",""):this.removeAttribute("collapsed"),lt(this.#S.key(uf),e?"1":"0"),this.#Q(0),this.dispatchEvent(new CustomEvent(wa,{detail:{collapsed:e},bubbles:!0,composed:!0})))}get unread(){return this.#F}#Ie(){let e=this.#S.readScopedItem(uf);return e!==null?e==="1":Ss(this.getAttribute("placement"))&&!this.hasAttribute("data-start-open")}describeSurface(){return this.#T.describeSurface()}moveTo(e,n={}){return this.#T.moveTo(e,n)}toggleCollapsed(){this.setCollapsed(!this.collapsed)}toggleTheme(){let e=this.getAttribute("theme")==="dark"?"light":"dark";this.setAttribute("theme",e),this.#S.writePreference(hf,e),this.#ve()}#Ce(e,n){let r=this.#S.conversationNamespace(e),o=this.#S.conversationNamespace(n);if(e===""){Xe.adopt(r,o),this.#ge(o);return}Xe.purge(r),this.#ge(o),this.#P.forgetWaivers(),this.#z(),this.#Z(),this.#G={},this.#W(!1),this.#Q(0),this.#f.adoptActiveThread(),this.#f.rehydrate(),this.#f.refreshDrawer()}#ge(e){let n=this.#S.rescopeStore(e);n!==null&&(this.conversationStore=n,this.#me())}#ve(){let e=this.getAttribute("theme")==="dark";this.#A.replaceChildren(Ms("theme","theme-icon",e?hc:uc,null))}openThreads(){this.#f.openThreads()}openCheckpoints(){this.#f.openCheckpoints()}closeThreads(){this.#g.close()}closeCheckpoints(){this.#w.close()}toggleCheckpoints(){if(this.#w.open_){this.#w.close();return}this.openCheckpoints()}newChat(){this.#z(),this.#f.reapUnsent(),this.#Z(),this.#f.startThread(),this.#W(!1),this.#Q(0),this.collapsed||this.#l.focus({preventScroll:!0})}#Z(){this.#be(),this.#$.length=0,this.#H=null}#be(){this.#D=null,this.#ee.detach(),this.#ye(),this.#f.forgetRestored()}#ye(){this.#ce.end(),this.#v.releaseTurn(),this.#n.clear(),this.#v.forgetCards(),this.#o.clearBlocks(),this.#r.forget(),this.#I.tray?.clear(),this.removeAttribute("data-composer-settling"),this.removeAttribute("data-restoring"),this.#v.empty()}async retryLastTurn(){if(this.#C)return!1;let e=this.#ae(),n=e.truncateToLastUser();if(n===null)return!1;this.#ye();for(let r of n)this.#f.replay(r);return await e.resume(),!0}appendMessage(e,n){return this.#v.append(e,n)}#Ne(){let{signal:e}=this.#Y;this.#c.className="chat",this.#c.setAttribute("part","panel");let n=document.createElement("div");n.className="header",n.setAttribute("part","header");let r=this.#m;r.className="header-title",r.setAttribute("part","title"),r.textContent=this.getAttribute("title-text")??this.#t.title,(this.querySelector('[slot="icon"]')!==null||this.getAttribute("data-icon-url")!==null)&&n.append(Ms("icon","icon",null,this.getAttribute("data-icon-url")));let o=document.createElement("slot");o.name="header-actions";let i=document.createElement("div");i.className="header-controls",i.setAttribute("part","header-controls");let s=Vr("history",this.#t.chatHistory,"\u2630");s.addEventListener("click",()=>this.openThreads());let a=Vr("checkpoints",this.#t.checkpoints,"\u21BA");a.addEventListener("click",()=>this.toggleCheckpoints());let l=Vr("new",this.#t.newChat,"\u271A");l.addEventListener("click",()=>this.newChat());let d=Vr("collapse",this.#t.collapse,"\u2014");d.addEventListener("click",()=>this.toggleCollapsed()),this.#f.runs()!==null?i.append(s,a,l):i.append(s,l),this.getAttribute("data-theme-toggle")!==null&&(this.#A.type="button",this.#A.className="header-btn header-btn--theme",this.#A.setAttribute("part","header-button theme-toggle"),this.#A.title=this.#t.toggleTheme,this.#A.setAttribute("aria-label",this.#t.toggleTheme),this.#A.addEventListener("click",()=>this.toggleTheme(),{signal:e}),this.#ve(),i.append(this.#A)),i.append(d),n.append(r,o,i),this.#T.enablePanelDrag(n),this.#p.className="messages",this.#p.setAttribute("part","messages"),this.#p.setAttribute("role","log"),this.#p.setAttribute("aria-live","off"),this.#p.setAttribute("aria-label",this.#t.conversation),this.#a.className="jump-latest",this.#a.type="button",this.#a.setAttribute("part","jump-latest"),this.#a.textContent=this.#t.jumpToLatest,this.#d.mount(e),this.#v.mountScroller(this.#a,e),this.#s.mount(),this.#O.className="empty",this.#O.setAttribute("part","empty");let u=document.createElement("div");u.className="greeting",u.setAttribute("part","greeting");let m=document.createElement("slot");m.name="greeting",m.append(this.#le),u.append(m),this.#he();let w=document.createElement("slot");w.name="empty";let p=Qp(this,this.#t,O=>{this.sendMessage(O)});p!==null&&w.append(p),this.#O.replaceChildren(u,w),this.#M.className="queued",this.#M.setAttribute("part","queued"),this.#M.setAttribute("role","group"),this.#M.setAttribute("aria-label",this.#t.queued),this.#M.hidden=!0,this.#p.append(this.#O),this.#v.updateEmptyState();let h=document.createElement("div");h.className="input-row",h.setAttribute("part","composer");let v=document.createElement("div");v.className="composer",v.setAttribute("part","composer-surface");let x=document.createElement("div");x.className="composer-tools",x.setAttribute("part","composer-tools"),this.#l.className="input",this.#l.setAttribute("part","input"),this.#l.setAttribute("aria-label",this.#t.message),this.#l.rows=1,this.#l.placeholder=this.#t.inputPlaceholder,this.#l.addEventListener("keydown",O=>this.#Me(O),{signal:e}),this.#l.addEventListener("input",()=>this.#xe(),{signal:e}),this.#h.className="send",this.#h.type="button",this.#h.setAttribute("part","send"),this.#h.replaceChildren(Os("icon-send","send-send",ac),Os("icon-stop","send-stop",lc)),this.#h.title=this.#t.send,this.#h.setAttribute("aria-label",this.#t.send),this.#h.dataset.state="idle",this.#h.addEventListener("click",()=>{if(this.#C){this.#z();return}this.#se()},{signal:e}),this.#y.className="skill-hint",this.#y.setAttribute("part","skill-hint"),this.#y.hidden=!0,this.#x.className="attach-btn",this.#x.type="button",this.#x.setAttribute("part","attach-button"),this.#x.replaceChildren(Os("icon-attach","attach-glyph",dc)),this.#x.title=this.#t.attachFiles,this.#x.setAttribute("aria-label",this.#t.attachFiles),this.#x.hidden=!0,this.#x.addEventListener("click",()=>this.#_.click(),{signal:e}),this.#_.className="attach-input",this.#_.type="file",this.#_.multiple=!0,this.#_.hidden=!0,this.#_.addEventListener("change",()=>this.#I.onFilesPicked(),{signal:e}),this.#L.className="attachment-slot",this.#X.className="voice-slot";let S=document.createElement("slot");S.name="footer",x.append(this.#x,this.#X,this.#h),v.append(this.#l,x),h.append(v,this.#_),this.#u.className="messages-wrap",this.#u.replaceChildren(this.#p,this.#a,this.#d.button),this.#c.replaceChildren(n,this.#u,this.#b.palette,this.#b.chips,this.#y,this.#M,this.#L,h,S,this.#g.element,this.#w.element),this.#c.addEventListener("pointerdown",O=>{if(!this.#w.open_)return;let G=O.composedPath();G.includes(this.#w.element)||G.includes(a)||this.#w.close()},{signal:e}),this.#E.className="launcher",this.#E.type="button",this.#E.setAttribute("part","launcher"),this.#E.setAttribute("aria-label",this.#t.expand),this.#k.className="launcher-badge",this.#k.setAttribute("part","launcher-badge"),this.#k.setAttribute("aria-hidden","true"),this.#k.hidden=!0,this.#N.className="rail-label",this.#N.setAttribute("part","rail-label"),this.#N.setAttribute("aria-hidden","true"),this.#N.textContent=this.getAttribute("title-text")??this.#t.title,this.#E.replaceChildren(Ms("launcher","launcher-icon",pc,ip(this)),this.#N,this.#k),this.#E.addEventListener("click",()=>this.setCollapsed(!1),{signal:e}),this.#T.enableLauncherDrag(e),this.#T.mountResizeGrips(this.#c),rp(this.#i);let _=this.#T.probe;_.className="viewport-probe",_.setAttribute("aria-hidden","true"),this.#i.replaceChildren(_,this.#s.region,this.#c,this.#E)}#we(){this.#E.setAttribute("aria-expanded",String(!this.collapsed));let e=this.#F;this.#k.textContent=e>9?"9+":String(e),this.#k.hidden=e===0||!op(this);let n=this.#k.hidden?this.#t.expand:oe(this.#t.expandUnread,{count:e});this.#E.setAttribute("aria-label",n),this.#E.title=n}#Q(e){this.#F=e,this.#we(),this.dispatchEvent(new CustomEvent(xa,{detail:{unread:e},bubbles:!0,composed:!0}))}#Oe(){this.collapsed&&this.#Q(this.#F+1)}#xe(){this.#b.onInput(this.#l.value),this.#y.hidden=!0,Ut(this.#l),this.#H=null}#Me(e){if(this.#b.onKeydown(e)){e.preventDefault();return}if(e.key==="Escape"&&this.#C){e.preventDefault(),this.#z();return}if(e.key==="Enter"&&!e.shiftKey){e.preventDefault(),this.#se();return}this.#Le(e)}#Le(e){let n=e.key==="ArrowUp";if(!n&&e.key!=="ArrowDown"||this.#b.isOpen())return;let r=this.#$;if(r.length===0||this.#H===null&&(!n||this.#l.value!==""))return;let o=this.#H===null?0:this.#H+(n?1:-1);o>=r.length||(e.preventDefault(),this.#H=o<0?null:o,this.#l.value=o<0?"":r[o],this.#l.setSelectionRange(this.#l.value.length,this.#l.value.length),Ut(this.#l))}#z(){for(let e of this.#U)this.#$[0]!==e&&this.#$.unshift(e);this.#U.length=0,this.#J(),this.#re.abort(),this.#D?.cancel(),this.#f.stopContinuation()}#W(e){let n=this.#C&&!e;this.#C=e;let r=e?this.#t.stop:this.#t.send;this.#h.title=r,this.#h.setAttribute("aria-label",r),this.#h.dataset.state=e?"running":"idle",n&&this.#Ee()}#Ee(){if(this.#C||this.#f.continuation!==null)return;let e=this.#U.shift();this.#J(),e!==void 0&&this.sendMessage(e)}#J(){this.#M.replaceChildren(),this.#M.hidden=this.#U.length===0;for(let[e,n]of this.#U.entries()){let r=document.createElement("button");r.type="button",r.className="queued-chip",r.setAttribute("part","queued-chip"),r.textContent=n,r.title=oe(this.#t.removeQueued,{text:n}),r.setAttribute("aria-label",r.title),r.addEventListener("click",()=>{this.#U.splice(e,1),this.#J()}),this.#M.appendChild(r)}}async#se(){let e=this.#l.value.trim(),n=this.#I.tray?.readyRefs()??[];if(!(e===""&&n.length===0)){if(this.#C||this.#f.continuation!==null){e!==""&&(this.#U.push(e),this.#J(),this.#l.value="",Ut(this.#l));return}e!==""&&this.#$[0]!==e&&this.#$.unshift(e),this.#H=null,this.#l.value="",Ut(this.#l),this.#I.tray?.hasPending()===!0&&this.#v.appendNotice("\u{1F4CE}",oe(this.#t.attachmentsStillUploading,{n:this.#I.tray.pendingCount()}),"attachment-pending"),this.#I.tray?.clearReady(),await this.sendMessage(e,n)}}async sendMessage(e,n=[]){if(this.#C||this.#f.continuation!==null||e===""&&n.length===0)return;this.#v.isEmpty()&&this.setAttribute("data-composer-settling","");let r=this.appendMessage(Le.USER,e);n.length>0&&r.appendChild(fs(n)),this.dispatchEvent(new CustomEvent(ya,{detail:{content:e,attachments:n},bubbles:!0,composed:!0})),await this.#Pe(e,n)}attachFile(e){return this.#I.attach(e)}async#Pe(e,n){if(this.endpoint===""){console.error('<ag-ui-chat>: no endpoint is set, so this message was not sent and no request was made. Point the element at your AG-UI mount with the endpoint attribute (endpoint="/agent/"), or assign chat.endpoint before sending.'),this.#v.appendNotice("\u26A0",this.#t.notConnected,"not-connected");return}await this.#ae().send(e,n)}#ae(){return this.#D===null&&(this.#D=this.#Te({endpoint:this.endpoint,initialMessages:this.#f.restored,follows:[]})),this.#D}#Te(e){let n=this.#f.threadId,r=this.agentFactory({endpoint:e.endpoint,headers:this.#oe(),getHeaders:()=>this.#oe(),trustedOrigins:this.trustedOrigins,...this.#ie(),threadId:n,initialMessages:e.initialMessages,initialState:this.#G});return new no({agent:r,handlers:this.#ee.forClient(),getTools:()=>this.#R.advertise(),getContext:()=>this.#P.buildContext(),executeTool:o=>this.#P.execute(o),resolveInterrupts:o=>this.#P.resolveInterrupts(o),onPersist:o=>{let i=[...e.follows,...o];this.conversationStore.saveMessages(n,i),e.onSaved?.(i)},onStateChanged:o=>this.#De(o),connectionLostMessage:this.#t.connectionLost,unfinishedMessage:this.#t.callNotFinished,declinedMessage:this.#t.declinedAction,maxToolRounds:df(this)})}#De(e){this.#G={...e},this.dispatchEvent(new CustomEvent(Ea,{detail:{state:this.#G},bubbles:!0,composed:!0}))}#_e(e,n){this.#v.appendNotice("\u2922",e,"surface",n===null?void 0:{label:this.#t.undo,onActivate:n})}enableCharts(e=["tool","activity"]){let n=!this.#o.has(_o)&&!this.#R.has(ps);e.includes("activity")&&this.registerActivityRenderer({type:_o,render:r=>{let o=or(r);return o===null?null:Lr(o)},removedNotice:this.#t.chartUndrawable}),e.includes("tool")&&this.registerTool(zh()),n&&this.isConnected&&this.reload()}registerActivityRenderer(e){this.#o.register(e)}get unhandledActivityTypes(){return this.#o.unhandledTypes()}};function VE(t){let e=t?.removed;return typeof e=="number"?e:null}function qE(){customElements.get(xo)===void 0&&customElements.define(xo,so)}async function WE(t,e,n={}){await wt(t),await za(t,{...n,flashMs:n.flashMs??0}),await Ha(t,e,n)}async function XE(t,e={}){await wt(t),await Ga(t,e)}async function YE(t,e={}){await wt(t),await Fa(t,e)}async function KE(t,e,n={}){await wt(t),await $a(t,e,n)}async function ZE(t,e,n={}){await wt(t),await Ba(t,e,n)}function QE(t,e){t instanceof HTMLInputElement&&t.type==="checkbox"?vr(t,!!e):qt(t,String(e)),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}var JE="0.40.0";export{Ta as ATTACHMENT_EVENT,so as AgUiChat,no as AgUiClient,_o as CHART_ACTIVITY_TYPE,ps as CHART_TOOL_NAME,ko as CHAT_CORNERS,Na as COMPACTION_ACTIVITY_TYPE,Sa as CUSTOM_AGENT_EVENT,Ur as CheckpointMenu,gr as ClientToolRegistry,Zs as ConnectionLostError,le as DEFAULT_UI_STRINGS,xo as ELEMENT_TAG,ka as FEEDBACK_EVENT,Ia as INVALIDATE_CUSTOM_NAME,Aa as INVALIDATE_EVENT,Oa as LOAD_CAPABILITY_TOOL,dw as MAX_QUOTE_CHARS,OE as MAX_SUGGESTIONS,ME as MAX_SUGGESTION_CHARS,Mn as MAX_TOOL_ROUNDS,jt as MESSAGE_ACTIONS,Le as MESSAGE_ROLE,yr as PAGE_ACTIONS,_a as RUN_FINISHED_EVENT,io as RemoteConversationStore,Hr as RunIndex,Ea as STATE_EVENT,ya as SUBMIT_EVENT,Ra as SUGGESTIONS_ACTIVITY_TYPE,Xe as SessionStorageStore,wa as TOGGLE_EVENT,te as TOOL_CALL_STATUS,Ln as TOOL_DISPLAY,Pe as TOOL_OUTCOME,jr as ToolCallCard,xa as UNREAD_EVENT,JE as VERSION,Eo as X_CONFIRM_KEY,fr as X_DESTRUCTIVE_KEY,mr as X_NAVIGATES_KEY,xe as X_SUMMARY_KEY,ql as asQuote,nd as attachMessageActions,Xl as attachQuoteOffer,or as chartSpecFrom,XE as clickElement,La as createChatSurfaceTools,Sd as createHttpAgent,ja as createPageActionTools,Va as createPageMapContext,No as createPageStateTools,qa as createRouteTools,um as createStateHookTools,qE as defineAgUiChat,WE as fillField,sm as flash,za as focusWithFlash,Ga as highlightThenClick,Sc as isChatCorner,Fl as isDestructive,us as isNavigates,Pl as mergeUiStrings,Ps as messageActionBar,Kl as messageAttachments,Ul as parseToolCatalog,Io as prefersReducedMotion,YE as pressButton,Fa as pressThenClick,Td as prettifyToolName,Pr as quotableSelection,Dr as relativeTime,Lr as renderChart,eo as renderMarkdown,to as renderSuggestionChips,Hl as requestApproval,zl as requestConfirmation,Dl as requestQuestion,wt as scrollIntoCenterView,KE as selectControl,$a as selectOption,QE as setControlValue,vr as setNativeChecked,qt as setNativeValue,Pa as showHighlightOverlay,Zp as suggestionPrompts,ZE as toggleCheckbox,Ba as toggleControl,Gr as toolStatusFromOutcome,Vl as transcribeAudio,Ha as typeInto,Bl as uploadAttachment};
|
|
3924
|
+
`+t+`</thead>
|
|
3925
|
+
`+o+`</table>
|
|
3926
|
+
`}tablerow({text:e}){return`<tr>
|
|
3927
|
+
${e}</tr>
|
|
3928
|
+
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
3929
|
+
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${et(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,text:n,tokens:o,autolink:r}){let i=r?et(n,!0):this.parser.parseInline(o),a=w_(e);if(a===null)return i;e=et(a,r);let s='<a href="'+e+'"';return t&&(s+=' title="'+et(t)+'"'),s+=">"+i+"</a>",s}image({href:e,title:t,text:n,tokens:o}){o&&(n=this.parser.parseInline(o,this.parser.textRenderer));let r=w_(e);if(r===null)return et(n);e=r;let i=`<img src="${et(e)}" alt="${et(n)}"`;return t&&(i+=` title="${et(t)}"`),i+=">",i}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:et(e.text)}},$m=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},ct=class Tm{options;renderer;textRenderer;constructor(t){this.options=t||In,this.options.renderer=this.options.renderer||new Zl,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new $m}static parse(t,n){return new Tm(n).parse(t)}static parseInline(t,n){return new Tm(n).parseInline(t)}parse(t){this.renderer.parser=this;let n="";for(let o=0;o<t.length;o++){let r=t[o];if(this.options.extensions?.renderers?.[r.type]){let a=r,s=this.options.extensions.renderers[a.type].call({parser:this},a);if(s!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(a.type)){n+=s||"";continue}}let i=r;switch(i.type){case"space":{n+=this.renderer.space(i);break}case"hr":{n+=this.renderer.hr(i);break}case"heading":{n+=this.renderer.heading(i);break}case"code":{n+=this.renderer.code(i);break}case"table":{n+=this.renderer.table(i);break}case"blockquote":{n+=this.renderer.blockquote(i);break}case"list":{n+=this.renderer.list(i);break}case"checkbox":{n+=this.renderer.checkbox(i);break}case"html":{n+=this.renderer.html(i);break}case"def":{n+=this.renderer.def(i);break}case"paragraph":{n+=this.renderer.paragraph(i);break}case"text":{n+=this.renderer.text(i);break}default:{let a='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return n}parseInline(t,n=this.renderer){this.renderer.parser=this;let o="";for(let r=0;r<t.length;r++){let i=t[r];if(this.options.extensions?.renderers?.[i.type]){let s=this.options.extensions.renderers[i.type].call({parser:this},i);if(s!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(i.type)){o+=s||"";continue}}let a=i;switch(a.type){case"escape":{o+=n.text(a);break}case"html":{o+=n.html(a);break}case"link":{o+=n.link(a);break}case"image":{o+=n.image(a);break}case"checkbox":{o+=n.checkbox(a);break}case"strong":{o+=n.strong(a);break}case"em":{o+=n.em(a);break}case"codespan":{o+=n.codespan(a);break}case"br":{o+=n.br(a);break}case"del":{o+=n.del(a);break}case"text":{o+=n.text(a);break}default:{let s='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return o}},Zo=class{options;block;constructor(e){this.options=e||In}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?ut.lex:ut.lexInline}provideParser(e=this.block){return e?ct.parse:ct.parseInline}},Pm=class{defaults=km();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ct;Renderer=Zl;TextRenderer=$m;Lexer=ut;Tokenizer=Vl;Hooks=Zo;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let o of e)switch(n=n.concat(t.call(this,o)),o.type){case"table":{let r=o;for(let i of r.header)n=n.concat(this.walkTokens(i.tokens,t));for(let i of r.rows)for(let a of i)n=n.concat(this.walkTokens(a.tokens,t));break}case"list":{let r=o;n=n.concat(this.walkTokens(r.items,t));break}default:{let r=o;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach(i=>{let a=r[i].flat(1/0);n=n.concat(this.walkTokens(a,t))}):r.tokens&&(n=n.concat(this.walkTokens(r.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let o={...n};if(o.async=this.defaults.async||o.async||!1,n.extensions&&(n.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let i=t.renderers[r.name];i?t.renderers[r.name]=function(...a){let s=r.renderer.apply(this,a);return s===!1&&(s=i.apply(this,a)),s}:t.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=t[r.level];i?i.unshift(r.tokenizer):t[r.level]=[r.tokenizer],r.start&&(r.level==="block"?t.startBlock?t.startBlock.push(r.start):t.startBlock=[r.start]:r.level==="inline"&&(t.startInline?t.startInline.push(r.start):t.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(t.childTokens[r.name]=r.childTokens)}),o.extensions=t),n.renderer){let r=this.defaults.renderer||new Zl(this.defaults);for(let i in n.renderer){if(!(i in r))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let a=i,s=n.renderer[a],u=r[a];r[a]=(...l)=>{let d=s.apply(r,l);return d===!1&&(d=u.apply(r,l)),d||""}}o.renderer=r}if(n.tokenizer){let r=this.defaults.tokenizer||new Vl(this.defaults);for(let i in n.tokenizer){if(!(i in r))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let a=i,s=n.tokenizer[a],u=r[a];r[a]=(...l)=>{let d=s.apply(r,l);return d===!1&&(d=u.apply(r,l)),d}}o.tokenizer=r}if(n.hooks){let r=this.defaults.hooks||new Zo;for(let i in n.hooks){if(!(i in r))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let a=i,s=n.hooks[a],u=r[a];Zo.passThroughHooks.has(i)?r[a]=l=>{if(this.defaults.async&&Zo.passThroughHooksRespectAsync.has(i))return(async()=>{let h=await s.call(r,l);return u.call(r,h)})();let d=s.call(r,l);return u.call(r,d)}:r[a]=(...l)=>{if(this.defaults.async)return(async()=>{let h=await s.apply(r,l);return h===!1&&(h=await u.apply(r,l)),h})();let d=s.apply(r,l);return d===!1&&(d=u.apply(r,l)),d}}o.hooks=r}if(n.walkTokens){let r=this.defaults.walkTokens,i=n.walkTokens;o.walkTokens=function(a){let s=[];return s.push(i.call(this,a)),r&&(s=s.concat(r.call(this,a))),s}}this.defaults={...this.defaults,...o}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ut.lex(e,t??this.defaults)}parser(e,t){return ct.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let o={...n},r={...this.defaults,...o},i=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&o.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=e),r.async)return(async()=>{let a=r.hooks?await r.hooks.preprocess(t):t,s=await(r.hooks?await r.hooks.provideLexer(e):e?ut.lex:ut.lexInline)(a,r),u=r.hooks?await r.hooks.processAllTokens(s):s;r.walkTokens&&await Promise.all(this.walkTokens(u,r.walkTokens));let l=await(r.hooks?await r.hooks.provideParser(e):e?ct.parse:ct.parseInline)(u,r);return r.hooks?await r.hooks.postprocess(l):l})().catch(i);try{r.hooks&&(t=r.hooks.preprocess(t));let a=(r.hooks?r.hooks.provideLexer(e):e?ut.lex:ut.lexInline)(t,r);r.hooks&&(a=r.hooks.processAllTokens(a)),r.walkTokens&&this.walkTokens(a,r.walkTokens);let s=(r.hooks?r.hooks.provideParser(e):e?ct.parse:ct.parseInline)(a,r);return r.hooks&&(s=r.hooks.postprocess(s)),s}catch(a){return i(a)}}}onError(e,t){return n=>{if(n.message+=`
|
|
3930
|
+
Please report this to https://github.com/markedjs/marked.`,e){let o="<p>An error occurred:</p><pre>"+et(n.message+"",!0)+"</pre>";return t?Promise.resolve(o):o}if(t)return Promise.reject(n);throw n}}},kn=new Pm;function le(e,t){return kn.parse(e,t)}le.options=le.setOptions=function(e){return kn.setOptions(e),le.defaults=kn.defaults,S_(le.defaults),le};le.getDefaults=km;le.defaults=In;function lO(...e){return kn.use(...e),le.defaults=kn.defaults,S_(le.defaults),le}le.use=lO;le.walkTokens=function(e,t){return kn.walkTokens(e,t)};le.parseInline=kn.parseInline;le.Parser=ct;le.parser=ct.parse;le.Renderer=Zl;le.TextRenderer=$m;le.Lexer=ut;le.lexer=ut.lex;le.Tokenizer=Vl;le.Hooks=Zo;le.parse=le;var W3=le.options,q3=le.setOptions,X3=le.walkTokens,K3=le.parseInline;var Y3=ct.parse,J3=ut.lex;var uO=new Pm({gfm:!0,breaks:!0}),P_=["a","p","br","strong","em","b","i","u","s","del","code","pre","ul","ol","li","blockquote","h1","h2","h3","h4","h5","h6","hr","span","table","thead","tbody","tr","th","td"],M_=["href","title","class","target","rel"],L_={ALLOWED_TAGS:P_,ALLOWED_ATTR:M_,ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1},cO={...L_,ALLOWED_TAGS:[...P_,"img"],ALLOWED_ATTR:[...M_,"src","alt","width","height"]},dO=/^language-[A-Za-z0-9_+#.-]+$/,pO=new Set(["CODE","PRE"]);function hO(e){e.nodeName==="A"&&e.hasAttribute("href")?(e.setAttribute("target","_blank"),e.setAttribute("rel","noopener noreferrer")):(e.removeAttribute("target"),e.removeAttribute("rel"));let t=e.getAttribute("class");if(t===null)return;let n=pO.has(e.nodeName)?t.split(/\s+/).filter(o=>dO.test(o)):[];if(n.length===0){e.removeAttribute("class");return}e.setAttribute("class",n.join(" "))}var Wl=null;function fO(){return Wl===null&&(Wl=g_(),Wl.addHook("afterSanitizeAttributes",hO)),Wl}function qo(e,t){let n=t?.allowImages===!0,o=uO.parse(e,{async:!1});return fO().sanitize(o,n?cO:L_).trim()}var ql=class{#e;#t=null;#n=0;#o="";#r=null;constructor(t){this.#e=t}get deltas(){return this.#n}countDelta(){this.#n+=1}queue(t){this.#o=t,this.#i(),this.#r===null&&(this.#r=requestAnimationFrame(()=>{this.#r=null,this.into(this.#o)}))}into(t){this.#r!==null&&(cancelAnimationFrame(this.#r),this.#r=null),this.#o=t;let n=this.#i();return n.innerHTML=qo(t,{allowImages:this.#e.allowImages()}),this.#e.follow(),n}end(){this.#r!==null&&this.into(this.#o),this.#t=null}#i(){return this.#t===null&&(this.#t=this.#e.openBubble(),this.#n=0),this.#t}};var mO=4,gO=120;function z_(e){if(typeof e!="object"||e===null)return null;let t=e.prompts;if(!Array.isArray(t))return null;let n=t.filter(o=>typeof o=="string").map(o=>o.trim()).filter(o=>o!==""&&o.length<=120).slice(0,4);return n.length===0?null:n}function Xo(e,t,n){let o=z_(e);if(o===null)return null;let r=document.createElement("div");r.className="suggestions",r.setAttribute("part","suggestions"),r.setAttribute("role","group"),r.setAttribute("aria-label",t.suggestions);for(let i of o){let a=document.createElement("button");a.type="button",a.className="suggestion-chip",a.setAttribute("part","suggestion-chip"),a.textContent=i,a.addEventListener("click",()=>n(i)),r.appendChild(a)}return r}function D_(e,t,n){let o=e.getAttribute("data-starters");if(o===null)return null;let r;try{r=JSON.parse(o)}catch{return console.warn(`<ag-ui-chat>: data-starters is not valid JSON, so no starters are shown. It takes an array of strings, e.g. data-starters='["Summarise this page"]'.`),null}return Xo({prompts:r},t,n)}function Xl(e,t){for(let n of Array.from(e.querySelectorAll("pre"))){let o=n.querySelector("code");o===null||n.querySelector(".code-copy")!==null||(n.classList.add("has-copy"),n.append(vO(o,t)))}}function vO(e,t){let n=e.textContent,o=document.createElement("button");return o.type="button",o.className="code-copy",o.setAttribute("part","code-copy"),o.textContent=t.copyCode,o.title=t.copyCode,o.setAttribute("aria-label",t.copyCode),o.addEventListener("click",()=>{bO(n).then(r=>{yO(o,r?t.copied:t.copyFailed,t)})}),o}async function bO(e){let t=navigator.clipboard;if(t===void 0)return!1;try{return await t.writeText(e),!0}catch{return!1}}function yO(e,t,n){e.textContent=t,e.dataset.state=t===n.copied?"copied":"failed",setTimeout(()=>{e.textContent=n.copyCode,delete e.dataset.state},1500)}function Mm(e){let t=e.replace(/[._-]+/g," ").trim();return t===""?e:t.charAt(0).toUpperCase()+t.slice(1)}var Kl=class{element;#e;#t;#n;#o;#r=!1;constructor(t=pe){this.#o=t,this.element=document.createElement("div"),this.element.className="thoughts",this.element.setAttribute("part","thoughts"),this.element.setAttribute("data-streaming",""),this.#n=document.createElement("button"),this.#n.type="button",this.#n.className="thoughts-toggle",this.#n.setAttribute("part","thoughts-toggle"),this.#n.setAttribute("aria-expanded","true"),this.#e=document.createElement("span"),this.#e.className="thoughts-label",this.#e.setAttribute("part","thoughts-label"),this.#e.textContent=t.thinking,this.#n.append(this.#e),this.#t=document.createElement("pre"),this.#t.className="thoughts-body",this.#t.setAttribute("part","thoughts-body"),this.#n.addEventListener("click",()=>{this.#i(!this.#r)}),this.element.append(this.#n,this.#t)}stream(t){this.#t.textContent=t}collapse(){this.#r||(this.element.removeAttribute("data-streaming"),this.#e.textContent=this.#o.thoughts,this.#i(!0))}#i(t){this.#r=t,this.#t.hidden=t,this.#n.setAttribute("aria-expanded",String(!t))}};function Yl(e,t){try{return e()}catch(n){return console.warn(`ag-ui-chat: render failed for ${t}`,n),null}}function U_(e,t){for(let n of Array.from(e.childNodes))n.nodeType===Node.TEXT_NODE?t.push({node:n,parent:e}):U_(n,t)}function j_(e){let t=[];U_(e,t);let n=0;for(let{node:o,parent:r}of t){let i=document.createDocumentFragment();for(let a of o.data.split(/(\s+)/)){if(a==="")continue;if(/\s/.test(a)){i.appendChild(document.createTextNode(a));continue}let s=document.createElement("span");s.className="word",s.style.setProperty("--ag-ui-word-index",String(n)),s.textContent=a,i.appendChild(s),n+=1}r.replaceChild(i,o)}}function H_({viewport:e,onMissedContent:t}){let n=!0,o=!1,r=()=>e.scrollHeight-e.scrollTop-e.clientHeight<=4,i=d=>{d!==o&&(o=d,t(o))},a=()=>{e.scrollTop=e.scrollHeight},s=()=>{n=r(),n&&i(!1)},u=()=>{if(n){a();return}i(!0)};e.addEventListener("scroll",s,{passive:!0});let l=new ResizeObserver(()=>{n&&a()});return l.observe(e),{follow:u,jump:()=>{n=!0,i(!1),a()},following:()=>n,dispose:()=>{e.removeEventListener("scroll",s),l.disconnect()}}}var Jl=class{#e;#t=new Map;#n=new Map;#o=new Set;#r;#i=null;#a=null;#l=null;constructor(t){this.#e=t}mountScroller(t,n){t.addEventListener("click",()=>{this.jump()},{signal:n}),this.#r=H_({viewport:this.#e.messages,onMissedContent:o=>{t.dataset.missed=String(o)}})}disposeScroller(){this.#r.dispose()}follow(){this.#r.follow()}jump(){this.#r.jump()}isEmpty(){return!this.#e.emptyWrap.hidden}card(t){return this.#t.get(t)}cards(){return this.#t.values()}forgetCard(t){this.#t.delete(t)}setCardElement(t,n){this.#n.set(t,n)}markServerSettled(t){this.#o.add(t)}isServerSettled(t){return this.#o.has(t)}collapseThoughts(){this.#l?.collapse()}closeGroup(){this.#a!==null&&this.#a.childElementCount===0&&(this.#a.remove(),this.updateEmptyState()),this.#a=null,this.#l=null}releaseTurn(){this.#a=null,this.#l=null,this.hidePending(),this.#t.clear()}forgetCards(){this.#o.clear(),this.#n.clear()}empty(){this.#e.messages.replaceChildren(this.#e.emptyWrap),this.updateEmptyState()}append(t,n){let o=document.createElement("div");return o.className=`message message--${t}`,o.setAttribute("part",`message message-${t}`),t===De.ASSISTANT?(o.innerHTML=qo(n,{allowImages:this.#e.allowImages()}),Xl(o,this.#e.strings()),this.ensureGroup().appendChild(o)):(this.#a=null,o.textContent=n,this.#e.messages.appendChild(o)),this.updateEmptyState(),t===De.USER?this.jump():this.follow(),o}ensureGroup(){if(this.#a===null){let t=document.createElement("div");t.className="answer",t.setAttribute("part","answer"),this.#a=t,this.#e.messages.appendChild(t),this.updateEmptyState()}return this.#a}revealWords(t){this.#e.element.getAttribute("data-text-animation")==="word"&&j_(t)}updateEmptyState(){this.#e.emptyWrap.hidden=this.#e.messages.childElementCount>1,this.#e.element.toggleAttribute("data-empty",!this.#e.emptyWrap.hidden)}appendStoppedNote(){let t=document.createElement("div");t.className="stopped-note",t.setAttribute("part","stopped"),t.setAttribute("role","status"),t.textContent=this.#e.strings().stopped,this.ensureGroup().appendChild(t),this.updateEmptyState(),this.follow()}showPending(){if(this.#i!==null)return;let t=document.createElement("div");t.className="pending",t.setAttribute("part","pending"),t.setAttribute("role","status"),t.setAttribute("aria-label",this.#e.strings().thinking);for(let n=0;n<3;n+=1){let o=document.createElement("span");o.className="pending-dot",t.appendChild(o)}this.#i=t,this.ensureGroup().appendChild(t),this.updateEmptyState(),this.follow()}hidePending(){this.#i?.remove(),this.#i=null}showThoughts(){if(this.#l===null){this.#l=new Kl(this.#e.strings());let t=this.ensureGroup();t.insertBefore(this.#l.element,t.firstChild),this.updateEmptyState(),this.follow()}return this.#l}noticeIfSkillLoad(t){let n=hl(t);return n===null?!1:(this.appendNotice("\u2728",ae(this.#e.strings().usingSkill,{name:n}),"skill"),!0)}appendNotice(t,n,o,r){this.ensureGroup().appendChild(Ol(t,n,o,r)),this.updateEmptyState(),this.follow()}renderToolOutput(t,n){let o=Yl(()=>t(n.args),`tool ${n.name}`);o!==null&&(this.#n.get(n.id)?.after(o),this.afterGrew())}afterGrew(){this.updateEmptyState(),this.follow()}cardFor(t){let n=this.#t.get(t.id);if(n!==void 0)return n;let o=this.#e.resolveTool(t.name)?.parameters[ke],r=typeof o=="string"?o:this.#e.toolSummaries()[t.name]??this.#e.serverSummary(t.name)??Mm(t.name),i=new Do(t.name,t.args,r,this.#e.strings(),{formatPayload:a=>this.#e.formatToolPayload(a)});return this.#t.set(t.id,i),this.ensureGroup().appendChild(i.element),this.updateEmptyState(),this.follow(),i}};var Ql=class{#e;#t=new Map;#n=new Set;#o=new Map;constructor(t){this.#e=t}register(t){this.#t.set(t.type,t),this.#n.delete(t.type)}has(t){return this.#t.has(t)}unhandledTypes(){return[...this.#n]}clearBlocks(){this.#o.clear()}draw(t,n,o){let r=this.#t.get(n);if(r===void 0){this.#n.add(n);return}let i=Yl(()=>r.render(o),`activity ${n}`);if(i===null){this.#r(t,n,r.removedNotice,o);return}let a=this.#o.get(t);a===void 0?this.#e.ensureGroup().appendChild(i):a.replaceWith(i),this.#o.set(t,i),this.#e.afterTranscriptGrew()}#r(t,n,o,r){let i=this.#o.has(t);this.#o.get(t)?.remove(),this.#o.delete(t),console.warn(`ag-ui-chat: activity ${t} (${n}) was not drawable and has been removed. A chart's points must each be a finite JSON number; a numeric column serialised as a string (a Decimal, typically) is rejected rather than coerced.`,r),i&&o!==void 0&&this.#e.appendNotice("\u{1F4C9}",o,"chart-undrawable")}};var eu=class extends Error{constructor(t){super(t),this.name="ConnectionLostError"}},Ko=class{#e;#t;#n;#o;#r;#i;#a;#l=new Set;#c;#d;#u;#h;#s=!1;constructor(t){this.#e=t.agent,this.#t=t.handlers,this.#n=t.getTools??(()=>[]),this.#o=t.getContext??(()=>[]),this.#r=t.executeTool??null,this.#i=t.resolveInterrupts??null,this.#a=t.onPersist??(()=>{}),this.#c=t.connectionLostMessage??"Connection lost",this.#d=t.unfinishedMessage??"Not finished: the run ended or moved on before this tool call returned a result.",this.#u=t.declinedMessage??"User declined the action.";let n=t.maxToolRounds??Ln;this.#h=n>=1?Math.floor(n):Ln,this.#b();let o=t.onStateChanged;o!==void 0&&this.#e.subscribe({onStateChanged:({state:r})=>{o(r)}})}get state(){return this.#e.state}setState(t){this.#e.setState({...t})}get running(){return this.#e.isRunning}get messages(){return this.#e.messages}async send(t,n=[]){let o={id:ve(),role:"user",content:t,...n.length>0?{metadata:{attachments:n}}:{}};this.#e.addMessage(o),this.#p(),await this.#f()}truncateToLastUser(){let t=[...this.#e.messages],n=-1;for(let[r,i]of t.entries())i.role==="user"&&(n=r);if(n===-1)return null;let o=t.slice(0,n+1);return this.#e.setMessages(o),this.#p(),o}async resume(){await this.#f()}addToolResult(t,n){this.#e.addMessage({id:ve(),role:"tool",content:n,toolCallId:t}),this.#p()}cancel(){this.#s=!0,this.#e.abortRun()}async#f(){this.#s=!1;try{await this.#E(),this.#s&&this.#m()}catch(t){this.#s||wO(t)?this.#m():this.#t.onError(t instanceof Error?t.message:String(t))}finally{this.#t.onSettled()}}#m(){this.#p(),this.#t.onCancelled()}#b(){let t=this.#e.messages,n=t.map(xO);n.some((o,r)=>o!==t[r])&&this.#e.setMessages(n)}#g(t){let n=this.#e.messages,o=cl(n,r=>({id:ve(),role:"tool",content:this.#d,toolCallId:r,metadata:{outcome:Ue.INTERRUPTED}}),t);o!==n&&(this.#e.setMessages([...o]),this.#p())}#y(t,n){for(let o of t){let r=o.toolCallId;r!==void 0&&n[o.id]?.status==="cancelled"&&this.#e.addMessage({id:ve(),role:"tool",content:this.#u,toolCallId:r,metadata:{outcome:Ue.DENIED}})}this.#p()}#p(){this.#a(this.#e.messages)}get annotatedMessages(){return this.messages}async#E(){let t,n=new Set;for(let o=0;o<this.#h;o+=1){if(this.#s)return;let r=[],i={terminal:!1,errored:!1,interrupts:[]},a={tools:this.#n(),context:this.#o()};if(t!==void 0&&(a.resume=t),this.#g(n),await this.#e.runAgent(a,this.#w(r,i)),t=void 0,n=new Set,this.#p(),this.#s)return;if(!i.terminal)throw new eu(this.#c);if(i.errored)return;if(i.interrupts.length>0){if(this.#i===null)return;let u=await this.#i(i.interrupts);if(this.#s){this.#y(i.interrupts,u);return}t=gx(i.interrupts,u),n=new Set(i.interrupts.flatMap(({toolCallId:l})=>l??[]));continue}if(this.#r===null||r.length===0)return;let s=!1;for(let u of r){if(this.#s)return;let l=await this.#r(u);if(l!==null){if(l.halt===!0)return;this.#e.addMessage({id:ve(),role:"tool",content:l.content,toolCallId:u.id,...l.outcome===void 0?{}:{metadata:{outcome:l.outcome}}}),this.#p(),s=!0}}if(!s)return}}#w(t,n){let o=this.#t,r=this.#l,i=()=>this.#s,a=new Set;return{onRunInitialized(){o.onRunStart()},onTextMessageStartEvent({event:s}){r.has(s.messageId)&&console.warn(`<ag-ui-chat>: the server reused message id "${s.messageId}", which was already closed. Its content will be appended to that earlier message rather than starting a new one, and the merged result is what gets persisted. Issue a fresh id per message.`)},onTextMessageContentEvent({textMessageBuffer:s}){o.onTextDelta(s)},onTextMessageEndEvent({event:s,textMessageBuffer:u}){r.add(s.messageId),o.onTextEnd(u)},onToolCallEndEvent({event:s,toolCallName:u,toolCallArgs:l}){let d={id:s.toolCallId,name:u,args:l};t.push(d),o.onToolCall(d)},onToolCallResultEvent({event:s}){let u=s.metadata?.outcome;o.onToolResult(s.toolCallId,jn(s.content),u)},onActivitySnapshotEvent({event:s,messages:u}){if(u.some(d=>d.id===s.messageId&&d.role==="activity")){o.onActivityChanged(s.messageId,s.activityType,s.content);return}o.onActivity(s.activityType,s.content,s.messageId)},onActivityDeltaEvent({event:s}){a.add(s.messageId)},onCustomEvent({event:s}){o.onCustomEvent(s.name,s.value)},onSubagentStartedEvent({event:s}){o.onSubAgentStarted(s.subagentRunId,s.name,s.parentToolCallId??null)},onSubagentFinishedEvent({event:s}){o.onSubAgentFinished(s.subagentRunId)},onSubagentErrorEvent({event:s}){o.onSubAgentError(s.subagentRunId,s.message)},onMessagesSnapshotEvent({event:s}){o.onMessagesSnapshot(s.messages)},onMessagesChanged({messages:s}){if(a.size!==0){for(let u of a){let l=s.find(d=>d.id===u);l!==void 0&&l.role==="activity"&&o.onActivityChanged(u,l.activityType,l.content)}a.clear()}},onReasoningStartEvent(){o.onReasoningStart()},onReasoningMessageContentEvent({reasoningMessageBuffer:s}){o.onReasoningDelta(s)},onReasoningMessageEndEvent({reasoningMessageBuffer:s}){o.onReasoningDelta(s)},onReasoningEndEvent(){o.onReasoningEnd()},onRunFinishedEvent(s){n.terminal=!0,s.outcome==="interrupt"&&(n.interrupts=s.interrupts)},onRunErrorEvent({event:s}){n.terminal=!0,n.errored=!0,!i()&&o.onError(s.message)},onRunFinalized(){n.terminal=!0,o.onRunEnd()}}}};function wO(e){return e instanceof Error?e.name==="AbortError"||e instanceof TypeError&&/abort/i.test(e.message):!1}function xO(e){let{outcome:t,attachments:n,...o}=e;if(t===void 0&&n===void 0)return e;let r=o.metadata;return{...o,metadata:{...t===void 0?{}:{outcome:t},...n===void 0?{}:{attachments:n},...typeof r=="object"?r:{}}}}var G_="ag-ui-chat",br="thread",Lm="threads",Yo="messages:",nu="checkpoint:",Jo="minted:",_O=60,EO=100,SO="New conversation",F_=!1;function dt(e,t){try{sessionStorage.setItem(e,t)}catch{if(F_)return;F_=!0,console.warn("<ag-ui-chat>: the browser refused a sessionStorage write \u2014 the quota is full, or storage is disabled for this context. The conversation continues, but it will not survive a page reload. Deleting a long conversation from the history drawer frees the quota.")}}function tu(e){return e===""?G_:`${G_}@${e}`}var tt=class e{#e;constructor(t=""){this.#e=tu(t),t!==""&&e.adopt("",t)}static adopt(t,n){let o=`${tu(t)}:`,r=`${tu(n)}:`;for(let[i,a]of V_(o)){let s=sessionStorage.getItem(i),u=r+a;s!==null&&sessionStorage.getItem(u)===null&&dt(u,s),sessionStorage.removeItem(i)}}static purge(t){for(let[n]of V_(`${tu(t)}:`))sessionStorage.removeItem(n)}threadId(){return sessionStorage.getItem(this.#r(br))??this.newThread()}newThread(){let t=ve();return dt(this.#r(br),t),dt(this.#r(Jo+t),"1"),t}isUnsent(t){return sessionStorage.getItem(this.#r(Jo+t))!==null&&sessionStorage.getItem(this.#r(Yo+t))===null}loadMessages(t){return Promise.resolve(this.#i(this.#r(Yo+t)))}saveMessages(t,n){dt(this.#r(Yo+t),JSON.stringify(n)),sessionStorage.removeItem(this.#r(Jo+t)),this.#t(t,n)}loadCheckpoint(t){return this.#i(this.#r(nu+t))}saveCheckpoint(t,n){let o=this.#r(nu+t);if(n===null){sessionStorage.removeItem(o);return}dt(o,JSON.stringify(n))}clear(t){sessionStorage.removeItem(this.#r(Yo+t)),sessionStorage.removeItem(this.#r(nu+t)),sessionStorage.removeItem(this.#r(Jo+t)),this.#o(this.#n().filter(n=>n.threadId!==t)),sessionStorage.getItem(this.#r(br))===t&&sessionStorage.removeItem(this.#r(br))}listThreads(){let t=this.#n().sort((n,o)=>o.updatedAt-n.updatedAt).map(({threadId:n,title:o,updatedAt:r,preview:i})=>({threadId:n,title:o,updatedAt:r,preview:i}));return Promise.resolve(t)}setActiveThread(t){dt(this.#r(br),t)}renameThread(t,n){let o=this.#n(),r=o.find(i=>i.threadId===t);r!==void 0&&(r.title=n,r.titleCustom=!0,this.#o(o))}#t(t,n){let o=this.#n(),r=o.find(s=>s.threadId===t),i=kO(n),a=Date.now();r===void 0?o.push({threadId:t,title:Z_(n),titleCustom:!1,preview:i,updatedAt:a}):(r.preview=i,r.updatedAt=a,r.titleCustom||(r.title=Z_(n))),this.#o(o)}#n(){return this.#i(this.#r(Lm))??[]}#o(t){let n=this.#r(Lm);if(t.length===0){sessionStorage.removeItem(n);return}dt(n,JSON.stringify(t))}#r(t){return`${this.#e}:${t}`}#i(t){let n=sessionStorage.getItem(t);if(n===null)return null;try{return JSON.parse(n)}catch{return null}}};function V_(e){let t=[];for(let n=0;n<sessionStorage.length;n+=1){let o=sessionStorage.key(n);if(o===null||!o.startsWith(e))continue;let r=o.slice(e.length);TO(r)&&t.push([o,r])}return t}function TO(e){return e===br||e===Lm||e.startsWith(Yo)||e.startsWith(nu)||e.startsWith(Jo)}function Z_(e){for(let t of e)if(t.role==="user"){let n=B_(t.content);if(n!=="")return W_(n,_O)}return SO}function kO(e){for(let t of[...e].reverse()){let n=B_(t.content);if(n!=="")return W_(n,EO)}return""}function B_(e){return typeof e=="string"?e.replace(/\s+/g," ").trim():""}function W_(e,t){return e.length<=t?e:`${e.slice(0,t-1).trimEnd()}\u2026`}function zm(e){let t=e.headers??{},n=new Set;return new yx({url:e.endpoint,headers:t,initialState:{...e.initialState??{}},fetch:(o,r)=>{let i=e.getHeaders?.(),a=[...new Set([...Object.keys(t),...Object.keys(i??{})])].sort();if(ul(o,a,e.trustedOrigins??[],n),i===void 0)return fetch(o,ot(r,e.credentials));let s=new Headers(r?.headers);for(let[u,l]of Object.entries(i))s.set(u,l);return fetch(o,ot({...r,headers:s},e.credentials))},...e.threadId!==void 0?{threadId:e.threadId}:{},...e.initialMessages!==void 0?{initialMessages:[...e.initialMessages]}:{}})}function q_(e){let t=e.getAttribute("data-max-tool-rounds");return t===null?Ln:Number.parseInt(t,10)}var Qo=class{#e;#t;#n;#o;#r;#i=new Set;#a=new Map;constructor(t,n=()=>({}),o=new tt,r=()=>{},i=!0){this.#e=t.endsWith("/")?t:`${t}/`,this.#t=n,this.#n=o,this.#o=r,this.#r=i}threadId(){return this.#n.threadId()}setActiveThread(t){this.#n.setActiveThread(t)}newThread(){return ll(this.#n)}isUnsent(t){return this.#n.isUnsent?.(t)===!0}saveMessages(t,n){this.#n.saveMessages(t,this.#r?n:[])}loadCheckpoint(t){return this.#n.loadCheckpoint(t)}saveCheckpoint(t,n){this.#n.saveCheckpoint(t,n)}renameThread(t,n){this.#n.renameThread(t,n),this.#a.set(t,n),this.#h(t,"PATCH",{title:n})}clear(t){this.#n.clear(t),this.#i.add(t),this.#h(t,"DELETE")}async listThreads(){let t=await this.#l();return t===null?this.#n.listThreads():t.filter(n=>!this.#i.has(n.thread_id)).map(n=>this.#d(n))}async loadMessages(t){if(this.#n.isUnsent?.(t)===!0)return null;let n=await this.#u(`${this.#e}${encodeURIComponent(t)}/`);if(n===null||!n.ok)return this.#n.loadMessages(t);let o=await this.#c(n);return o===null?this.#n.loadMessages(t):o.messages??null}async#l(){let t=await this.#u(this.#e);if(t===null||!t.ok)return null;let n=await this.#c(t);return n===null?null:n.threads??[]}async#c(t){try{return await t.json()}catch{return null}}#d(t){return{threadId:t.thread_id,title:this.#a.get(t.thread_id)??t.title,updatedAt:t.updated_at===null?Number.NaN:Date.parse(t.updated_at),preview:t.preview}}async#u(t){try{return await fetch(t,ot({headers:this.#t()},this.#o()))}catch{return null}}async#h(t,n,o){let r=this.#t();try{await fetch(`${this.#e}${encodeURIComponent(t)}/`,ot({method:n,headers:o===void 0?r:{...r,"content-type":"application/json"},body:o===void 0?null:JSON.stringify(o)},this.#o()))}catch{}}};function X_(){return{tools:[],serverSettled:new Set,invalidated:new Set,announcedOutcome:!1}}function IO(e,t){let n={};for(let[o,r]of Object.entries(e))n[o]=(...i)=>{t()&&r(...i)};return n}var ru=class{#e;#t=X_();constructor(t){this.#e=t}detach(){this.#t=X_()}forClient(){let t=this.#t,n=()=>t===this.#t,{onSettled:o,...r}=this.#n(t);return{...IO(r,n),onSettled:()=>{n()&&o(),this.#o(t)}}}#n(t){return{onRunStart:()=>{this.#e.running()||(t.announcedOutcome=!1,this.#e.announcer.announce(this.#e.strings().announceResponding)),this.#e.setRunning(!0),this.#e.transcript.ensureGroup(),this.#e.transcript.showPending()},onReasoningStart:()=>{this.#e.transcript.hidePending(),this.#e.transcript.showThoughts()},onReasoningDelta:n=>{this.#e.transcript.showThoughts().stream(n)},onReasoningEnd:()=>{},onTextDelta:n=>{this.#e.transcript.hidePending(),this.#e.transcript.collapseThoughts(),this.#e.stream.queue(n),this.#e.stream.countDelta()},onTextEnd:n=>{if(n===""){this.#e.stream.end();return}let o=this.#e.stream.into(n);this.#e.stream.deltas<=1&&this.#e.transcript.revealWords(o),Xl(o,this.#e.strings()),this.#e.actions.attach(o),this.#e.stream.end(),this.#e.noteUnread()},onToolCall:n=>{this.#e.transcript.hidePending(),!this.#e.transcript.noticeIfSkillLoad(n)&&(t.tools.push({id:n.id,name:n.name}),this.#e.transcript.cardFor(n))},onActivity:(n,o,r)=>{this.#e.activities.draw(r,n,o)},onCustomEvent:(n,o)=>{if(n===Ou){this.#r(t,o);return}if(n===wg){this.#e.subagents.report(o);return}this.#e.element.dispatchEvent(new CustomEvent(Au,{detail:{name:n,value:o},bubbles:!0,composed:!0}))},onSubAgentStarted:(n,o,r)=>{this.#e.subagents.start(n,o,r)},onSubAgentFinished:n=>{this.#e.subagents.finish(n)},onSubAgentError:(n,o)=>{this.#e.subagents.fail(n,o)},onMessagesSnapshot:()=>{this.#e.transcript.appendNotice("\u{1F504}",this.#e.strings().historyReplaced,"history-replaced")},onToolResult:(n,o,r)=>{let i=this.#e.transcript.card(n);i!==void 0&&(i.settle($o(r),o),this.#e.transcript.markServerSettled(n),t.serverSettled.add(n),this.#e.transcript.showPending())},onActivityChanged:(n,o,r)=>{this.#e.activities.draw(n,o,r)},onRunEnd:()=>{this.#e.transcript.hidePending(),this.#e.stream.end()},onError:n=>{t.announcedOutcome=!0,this.#e.announcer.announce(this.#e.strings().announceFailed),this.#e.transcript.hidePending();let o=this.#e.appendMessage(De.ASSISTANT,`\u26A0\uFE0F ${n}`);o.classList.add("message--failed"),this.#e.actions.attach(o,{rateable:!1}),this.#e.transcript.revealWords(o),this.#e.stream.end()},onCancelled:()=>{t.announcedOutcome=!0,this.#e.announcer.announce(this.#e.strings().announceStopped),this.#e.transcript.hidePending(),this.#e.transcript.appendStoppedNote(),this.#e.stream.end()},onSettled:()=>{t.announcedOutcome||this.#e.announcer.announce(this.#e.strings().announceAnswerReady),this.#e.transcript.hidePending(),this.#e.setRunning(!1),this.#e.stream.end();for(let n of this.#e.transcript.cards())n.settled||n.settle(ne.INTERRUPTED,this.#e.strings().callNotFinished);this.#e.transcript.closeGroup()}}}#o(t){let n=t.tools.map(({id:r,name:i})=>({name:i,side:t.serverSettled.has(r)?"server":"client"})),o=[...t.invalidated];t.tools.length=0,t.serverSettled.clear(),t.invalidated.clear(),this.#e.element.dispatchEvent(new CustomEvent(Iu,{detail:{tools:n,invalidated:o},bubbles:!0,composed:!0}))}#r(t,n){let o=n??{},r=Array.isArray(o.keys)?o.keys.filter(i=>typeof i=="string"):[];if(r.length!==0){for(let i of r)t.invalidated.add(i);this.#e.element.dispatchEvent(new CustomEvent(Ru,{detail:{keys:r,reason:typeof o.reason=="string"?o.reason:null},bubbles:!0,composed:!0}))}}};var Dm=new Set,ou=class{#e;#t="";#n=null;#o="";#r="";#i=null;constructor(t){this.#e=t}claim(){this.#t=this.#a()}release(){this.#n!==null&&(Dm.delete(this.#n),this.#n=null)}conversationNamespace(t){return t===""?this.#t:`${this.#t}#${t}`}scopeStore(t,n){if(!(t instanceof tt))return t;let o=this.conversationNamespace(n);return this.#i=o===""?t:new tt(o),this.#i}rescopeStore(t){return this.#i===null?null:(this.#i=new tt(t),this.#i)}key(t){return this.#t===""?t:`${t}:${this.#t}`}readScopedItem(t){let n=sessionStorage.getItem(this.key(t));return n!==null||this.#t===""?n:sessionStorage.getItem(t)}readPreference(t){try{let n=localStorage.getItem(this.key(t));if(n!==null)return n}catch{}return this.readScopedItem(t)}writePreference(t,n){let o=this.key(t);try{localStorage.setItem(o,n)}catch{}dt(o,n)}clearPreference(t){let n=this.key(t);try{localStorage.removeItem(n)}catch{}try{sessionStorage.removeItem(n)}catch{}}#a(){let t=this.#e.id(),n=t!==""?t:this.#e.endpoint();return n===""?"":this.#r===n?this.#o:Dm.has(n)?(this.#r=n,this.#o=`${n}~${ve()}`,console.warn(`<ag-ui-chat>: another element on this page already stores its conversation under "${n}", so this one has been given a throwaway namespace of its own \u2014 the two would otherwise share a thread pointer, a history drawer and every message. Give each <ag-ui-chat> its own id to keep them apart and let this one restore its conversation across reloads.`),this.#o):(Dm.add(n),this.#n=n,n)}};var AO=["data-attachments-url","data-attachment-accept","data-attachment-max-bytes","data-transcribe-url","data-threads-url","data-threads-cache","data-tools-url","data-skills-url","data-skills","data-prompt-chips","data-slash-commands","data-theme-toggle","data-strings","data-icon-url"],jm=["omit","same-origin","include"];function Um(e){return jm.includes(e)}var K_="ag-ui-chat:collapsed",Y_="ag-ui-chat:theme",ei=class extends HTMLElement{agentFactory=zm;headers={};getHeaders=null;trustedOrigins=[];allowImages=!1;formatRelativeTime=null;autoConfirm=!1;askUser=!1;askUserRenderer=null;approvalRenderer=null;approveWithEdits=!1;confirmPredicate=null;getTools=()=>this.#A.defaultTools();getContext=()=>[...qu(this.getPageMap,this.autoInjectPageMap)];routeMap=[];navigate=null;getPageMap=null;autoInjectPageMap=!0;conversationStore=new tt;uploadHandler=null;transcribeHandler=null;navigationResult=()=>({navigated:!0,url:window.location.href});skillContext=()=>({});toolSummaries={};formatToolPayload=null;strings={};resolvePageTarget=t=>document.querySelector(t);#e=new Set;#t=pe;#n=new Pl({card:t=>this.#v.card(t),strings:()=>this.#t,follow:()=>this.#v.follow()});#o=new Ql({ensureGroup:()=>this.#v.ensureGroup(),afterTranscriptGrew:()=>this.#v.afterGrew(),appendNotice:(t,n,o)=>this.#v.appendNotice(t,n,o)});#r=new jl({element:this,strings:()=>this.#t,retry:()=>{this.retryLastTurn()}});#i;#a=new Nl;#l=document.createElement("button");#c;#d=document.createElement("div");#u;#h;#s;#f;#m;#b;#g;#y;#p;#E;#w;#T;#P;#k;#x;#I;#N=document.createElement("span");#H=0;#O;#v;#M;#ee;#le=document.createElement("span");#R;#_;#G=[];#z=[];#$=document.createElement("div");#D=null;#F=()=>{this.#_.publishVisualViewport(),!this.#_.dragging()&&this.#_.restoreLauncherPosition()};#q;#te;#V=!1;#X=new AbortController;#ue=!1;#ne=null;#L=null;#U={};#C=!1;#re=new Il;#A=new pl({element:this,routeMap:()=>this.routeMap,navigate:()=>this.navigate,getPageMap:()=>this.getPageMap,resolvePageTarget:t=>this.resolvePageTarget(t),getTools:()=>this.getTools(),askUser:()=>this.askUser,askUserRenderer:()=>this.askUserRenderer,decision:this.#re,ensureGroup:()=>this.#v.ensureGroup(),strings:()=>this.#t,hidePending:()=>this.#v.hidePending(),updateEmptyState:()=>this.#v.updateEmptyState(),follow:()=>this.#v.follow(),fetchInit:t=>this.#he(t)});#ce=new ql({openBubble:()=>this.appendMessage(De.ASSISTANT,""),allowImages:()=>this.allowImages,follow:()=>this.#v.follow()});#S=new ou({id:()=>this.id,endpoint:()=>this.endpoint});#Z;constructor(){super(),this.#i=this.attachShadow({mode:"open"}),this.#u=document.createElement("div"),this.#h=document.createElement("div"),this.#s=document.createElement("textarea"),this.#f=document.createElement("button"),this.#m=document.createElement("span"),this.#E=document.createElement("div"),this.#w=document.createElement("button"),this.#T=document.createElement("input"),this.#P=document.createElement("div"),this.#q=document.createElement("span"),this.#k=document.createElement("button"),this.#x=document.createElement("button"),this.#I=document.createElement("span"),this.#O=document.createElement("div"),this.#v=new Jl({element:this,messages:this.#h,emptyWrap:this.#O,strings:()=>this.#t,allowImages:()=>this.allowImages,resolveTool:t=>this.#A.resolve(t),toolSummaries:()=>this.toolSummaries,serverSummary:t=>this.#A.summary(t),formatToolPayload:t=>this.formatToolPayload?.(t)??null}),this.#M=new ml({element:this,transcript:this.#v,tools:this.#A,decision:this.#re,strings:()=>this.#t,announce:t=>this.#a.announce(t),autoConfirm:()=>this.autoConfirm,confirmPredicate:()=>this.confirmPredicate,getPageMap:()=>this.getPageMap,navigate:()=>this.navigate,approveWithEdits:()=>this.approveWithEdits,approvalRenderer:()=>this.approvalRenderer,getContext:()=>this.getContext(),conversationStore:()=>this.conversationStore,threadId:()=>this.#p.threadId}),this.#ee=new ru({element:this,transcript:this.#v,stream:this.#ce,actions:this.#r,activities:this.#o,subagents:this.#n,announcer:this.#a,strings:()=>this.#t,running:()=>this.#C,setRunning:t=>this.#W(t),appendMessage:(t,n)=>this.appendMessage(t,n),noteUnread:()=>this.#Oe()}),this.#_=new Cl({element:this,launcher:this.#x,root:this.#i,connected:()=>this.#V,collapsed:()=>this.collapsed,collapsible:()=>Po(this.getAttribute("placement")),strings:()=>this.#t,readPreference:t=>this.#S.readPreference(t),writePreference:(t,n)=>this.#S.writePreference(t,n),clearPreference:t=>this.#S.clearPreference(t),announceSurfaceChange:(t,n)=>this.#Se(t,n)}),this.#c=new Sl({element:this,root:this.#i,messages:this.#h,messagesWrap:this.#d,input:this.#s,strings:()=>this.#t,autoGrow:()=>Ht(this.#s),quote:t=>this.quote(t)}),this.#R=new wl({element:this,chat:this.#u,slot:this.#P,fileInput:this.#T,button:this.#w,strings:()=>this.#t,uploadHandler:()=>this.uploadHandler,headersFor:t=>this.#B(t),credentialsOption:()=>this.#ie()}),this.#te=new _l({element:this,slot:this.#q,input:this.#s,strings:()=>this.#t,transcribeHandler:()=>this.transcribeHandler,headersFor:t=>this.#B(t),credentialsOption:()=>this.#ie(),onInput:()=>this.#xe()}),this.registerActivityRenderer({type:Pu,render:t=>{let n=RO(t);return n===null?null:Ol("\u{1F5DC}",ae(this.#t.historyCompacted,{count:n}),"compaction")}}),this.registerActivityRenderer({type:Nu,render:t=>Xo(t,this.#t,n=>{this.sendMessage(n)})}),this.#b=new El(t=>this.#Z.apply(t)),this.#Z=new yi({element:this,menu:this.#b,input:this.#s,hint:this.#E,strings:()=>this.#t,context:()=>this.skillContext(),flag:t=>this.#ke(t),readJsonAttribute:t=>this.#fe(t),fetchInit:t=>this.#he(t),send:t=>{this.sendMessage(t)},submit:()=>{this.#ae()},autoGrow:()=>Ht(this.#s)}),this.#g=new kl({onSelect:t=>{this.#p.switchThread(t)},onNew:()=>{this.newChat(),this.#p.refreshDrawer()},onRename:(t,n)=>{this.#p.renameThread(t,n)},onDelete:t=>{this.#p.deleteThread(t)}}),this.#y=new No((t,n)=>{this.#p.continueRun(t,n).catch(o=>{console.warn("<ag-ui-chat>: continuing a run failed",o)})}),this.#p=new Tl({element:this,drawer:this.#g,checkpoints:this.#y,transcript:this.#v,actions:this.#r,activities:this.#o,tools:this.#A,input:this.#s,hint:this.#E,strings:()=>this.#t,conversationStore:()=>this.conversationStore,formatRelativeTime:()=>this.formatRelativeTime,navigationResult:()=>this.navigationResult,headersFor:t=>this.#B(t),requestCredentials:()=>this.#K(),appendMessage:(t,n)=>this.appendMessage(t,n),autoGrow:()=>Ht(this.#s),continuationEnded:()=>this.#_e(),client:()=>this.#L,ensureClient:()=>this.#se(),buildClient:t=>this.#Ee(t),releaseClient:()=>{this.#L=null},running:()=>this.#C,cancelRun:()=>this.#j(),resetState:()=>this.#Y(),setRunning:t=>this.#W(t)})}static get observedAttributes(){return["title-text","placement","credentials","user-key","user-name",...AO]}attributeChangedCallback(t,n,o){if(t==="credentials"){o!==null&&!Um(o)&&console.error(`<ag-ui-chat>: credentials="${o}" is not a fetch credentials mode (${jm.join(" / ")}) \u2014 it is being ignored, so requests use the browser default and cross-origin cookies will not be sent.`);return}if(t==="placement"){this.#_.releaseOwnedAxes(),this.#_.releaseLauncherPosition(),!Po(this.getAttribute("placement"))&&this.collapsed&&this.setCollapsed(!1),requestAnimationFrame(()=>this.#_.syncResizeAnchor());return}if(t==="title-text"){this.#m.textContent=o??this.#t.title,this.#N.textContent=this.#m.textContent;return}if(t==="user-name"){this.#pe();return}if(t==="user-key"){this.#V&&(n??"")!==(o??"")&&this.#Ce(n??"",o??"");return}n===o||!this.#V||console.warn(`<ag-ui-chat>: "${t}" was changed after the element connected, and is read only while connecting \u2014 this assignment has no effect. Set it before the element enters the DOM (in the markup, or on the element before appending it); frameworks that patch attributes after mount should bind it at creation. To apply a new value now, remove and re-insert the element.`)}registerTool(t){this.#A.register(t)}get sharedState(){return this.#de()?.state??this.#U}set sharedState(t){this.#U={...t},this.#de()?.setState(this.#U)}#de(){return this.#p.continuation??this.#L}registerPageState(t){this.#A.registerPageState(t)}registerStateHook(t){this.registerPageState(t)}get endpoint(){return this.getAttribute("endpoint")??""}set endpoint(t){this.setAttribute("endpoint",t)}get userKey(){return this.getAttribute("user-key")??""}set userKey(t){this.setAttribute("user-key",t)}get userName(){return this.getAttribute("user-name")??""}set userName(t){this.setAttribute("user-name",t)}#pe(){let t=this.userName.trim();this.#le.textContent=t===""?this.#t.greetingNoName:ae(this.#t.greeting,{name:t})}get credentials(){let t=this.getAttribute("credentials");return t!==null&&Um(t)?t:null}set credentials(t){if(t===null){this.removeAttribute("credentials");return}if(!Um(t))throw new TypeError(`<ag-ui-chat>: credentials must be one of ${jm.map(n=>`"${n}"`).join(", ")} (got ${JSON.stringify(t)}).`);this.setAttribute("credentials",t)}#oe(){return{...this.headers,...this.getHeaders?.()}}#B(t){let n=this.#oe();return ul(t,Object.keys(n),this.trustedOrigins,this.#e),n}#K(){return this.credentials??void 0}#ie(){let t=this.#K();return t===void 0?{}:{credentials:t}}#he(t){return ot({headers:this.#B(t)},this.#K())}get toolDisplay(){let t=this.getAttribute("data-tool-display");return t===zn.INLINE||t===zn.MINIMAL||t===zn.COMPACT?t:zn.FULL}set toolDisplay(t){this.setAttribute("data-tool-display",t)}connectedCallback(){if(this.#X=new AbortController,this.#ue&&this.#be(),this.#ue=!0,this.#S.claim(),this.#_.restoreSize(),requestAnimationFrame(()=>{this.#_.restoreLauncherPosition(),this.#_.syncResizeAnchor()}),this.#t=Wf({...this.#Ie(),...this.strings}),this.getAttribute("data-theme-toggle")!==null){let t=this.#S.readPreference(Y_);t!==null&&this.setAttribute("theme",t)}this.#Ne(),this.#g.setStrings(this.#t),this.#y.setStrings(this.#t),Po(this.getAttribute("placement"))&&this.#Re()&&this.setAttribute("collapsed",""),this.#we(),this.#Z.init(),this.conversationStore=this.#S.scopeStore(this.#Ae(),this.userKey),window.addEventListener("resize",this.#F),window.visualViewport?.addEventListener("resize",this.#F),window.visualViewport?.addEventListener("scroll",this.#F),this.#_.publishVisualViewport(),this.#me(),this.#R.wire(this.#X.signal),this.#te.wire(),this.#p.adoptActiveThread(),queueMicrotask(()=>this.#Te()),this.#p.rehydrate(),this.#V=!0}#Te(){this.#V&&(this.#A.fetchCatalog(),this.#Z.fetch())}async reload(){this.#j(),this.#Y(),this.#W(!1),await Promise.all([this.#A.fetchCatalog(),this.#Z.fetch(),this.#p.rehydrate()])}disconnectedCallback(){this.#V=!1,this.#X.abort(),window.removeEventListener("resize",this.#F),window.visualViewport?.removeEventListener("resize",this.#F),window.visualViewport?.removeEventListener("scroll",this.#F),this.#S.release(),this.#j(),this.#c.detachPageOffer(),this.#R.tray?.dispose(),this.#te.dispose(),this.#v.disposeScroller(),this.#a.dispose()}#ke(t){let n=this.getAttribute(t);return n!==null&&n!=="false"}#fe(t){let n=this.getAttribute(t);if(n===null)return null;try{return JSON.parse(n)}catch{return console.warn(`<ag-ui-chat>: ${t} is not valid JSON, so it was ignored entirely and the built-in default is being used. Check the quoting -- JSON inside an HTML attribute needs single quotes around the attribute value, or its own double quotes escaped.`),null}}#Ie(){let t=this.#fe("data-strings");return typeof t=="object"&&t!==null?t:{}}quote(t){this.#c.insert(t)}offerQuoteInPage(t=document.body){return this.#c.offerInPage(t)}#me(){this.#ne=null;let t=this.getAttribute("data-threads-url");if(t!==null){let n=this.conversationStore,o=new Qo(t,()=>this.#B(t),n,()=>this.#K(),this.getAttribute("data-threads-cache")!=="false");this.#ne={remote:o,inner:n},this.conversationStore=o}}#Ae(){let t=this.#ne;return t!==null&&this.conversationStore===t.remote?t.inner:this.conversationStore}setSkills(t){this.#Z.setClientSkills(t)}get collapsed(){return this.hasAttribute("collapsed")}set collapsed(t){this.setCollapsed(t)}setCollapsed(t,n={}){t&&!Po(this.getAttribute("placement"))||(n.announce===!0&&t&&!this.collapsed&&this.#Se(this.#t.chatMinimised,null),t||this.#_.restoreLauncherPosition(),t?this.setAttribute("collapsed",""):this.removeAttribute("collapsed"),dt(this.#S.key(K_),t?"1":"0"),this.#J(0),this.dispatchEvent(new CustomEvent(Eu,{detail:{collapsed:t},bubbles:!0,composed:!0})))}get unread(){return this.#H}#Re(){let t=this.#S.readScopedItem(K_);return t!==null?t==="1":Al(this.getAttribute("placement"))&&!this.hasAttribute("data-start-open")}describeSurface(){return this.#_.describeSurface()}moveTo(t,n={}){return this.#_.moveTo(t,n)}toggleCollapsed(){this.setCollapsed(!this.collapsed)}toggleTheme(){let t=this.getAttribute("theme")==="dark"?"light":"dark";this.setAttribute("theme",t),this.#S.writePreference(Y_,t),this.#ve()}#Ce(t,n){let o=this.#S.conversationNamespace(t),r=this.#S.conversationNamespace(n);if(t===""){tt.adopt(o,r),this.#ge(r);return}tt.purge(o),this.#ge(r),this.#M.forgetWaivers(),this.#j(),this.#Y(),this.#U={},this.#W(!1),this.#J(0),this.#p.adoptActiveThread(),this.#p.rehydrate(),this.#p.refreshDrawer()}#ge(t){let n=this.#S.rescopeStore(t);n!==null&&(this.conversationStore=n,this.#me())}#ve(){let t=this.getAttribute("theme")==="dark";this.#k.replaceChildren(Ll("theme","theme-icon",t?kg:Tg,null))}openThreads(){this.#p.openThreads()}openCheckpoints(){this.#p.openCheckpoints()}closeThreads(){this.#g.close()}closeCheckpoints(){this.#y.close()}toggleCheckpoints(){if(this.#y.open_){this.#y.close();return}this.openCheckpoints()}newChat(){this.#j(),this.#p.reapUnsent(),this.#Y(),this.#p.startThread(),this.#W(!1),this.#J(0),this.collapsed||this.#s.focus({preventScroll:!0})}#Y(){this.#be(),this.#G.length=0,this.#D=null}#be(){this.#L=null,this.#ee.detach(),this.#ye(),this.#p.forgetRestored()}#ye(){this.#ce.end(),this.#v.releaseTurn(),this.#n.clear(),this.#v.forgetCards(),this.#o.clearBlocks(),this.#r.forget(),this.#R.tray?.clear(),this.removeAttribute("data-composer-settling"),this.removeAttribute("data-restoring"),this.#v.empty()}async retryLastTurn(){if(this.#C)return!1;let t=this.#se(),n=t.truncateToLastUser();if(n===null)return!1;this.#ye();for(let o of n)this.#p.replay(o);return await t.resume(),!0}appendMessage(t,n){return this.#v.append(t,n)}#Ne(){let{signal:t}=this.#X;this.#u.className="chat",this.#u.setAttribute("part","panel");let n=document.createElement("div");n.className="header",n.setAttribute("part","header");let o=this.#m;o.className="header-title",o.setAttribute("part","title"),o.textContent=this.getAttribute("title-text")??this.#t.title,(this.querySelector('[slot="icon"]')!==null||this.getAttribute("data-icon-url")!==null)&&n.append(Ll("icon","icon",null,this.getAttribute("data-icon-url")));let r=document.createElement("slot");r.name="header-actions";let i=document.createElement("div");i.className="header-controls",i.setAttribute("part","header-controls");let a=Uo("history",this.#t.chatHistory,"\u2630");a.addEventListener("click",()=>this.openThreads());let s=Uo("checkpoints",this.#t.checkpoints,"\u21BA");s.addEventListener("click",()=>this.toggleCheckpoints());let u=Uo("new",this.#t.newChat,"\u271A");u.addEventListener("click",()=>this.newChat());let l=Uo("collapse",this.#t.collapse,"\u2014");l.addEventListener("click",()=>this.toggleCollapsed()),this.#p.runs()!==null?i.append(a,s,u):i.append(a,u),this.getAttribute("data-theme-toggle")!==null&&(this.#k.type="button",this.#k.className="header-btn header-btn--theme",this.#k.setAttribute("part","header-button theme-toggle"),this.#k.title=this.#t.toggleTheme,this.#k.setAttribute("aria-label",this.#t.toggleTheme),this.#k.addEventListener("click",()=>this.toggleTheme(),{signal:t}),this.#ve(),i.append(this.#k)),i.append(l),n.append(o,r,i),this.#_.enablePanelDrag(n),this.#h.className="messages",this.#h.setAttribute("part","messages"),this.#h.setAttribute("role","log"),this.#h.setAttribute("aria-live","off"),this.#h.setAttribute("aria-label",this.#t.conversation),this.#l.className="jump-latest",this.#l.type="button",this.#l.setAttribute("part","jump-latest"),this.#l.textContent=this.#t.jumpToLatest,this.#c.mount(t),this.#v.mountScroller(this.#l,t),this.#a.mount(),this.#O.className="empty",this.#O.setAttribute("part","empty");let d=document.createElement("div");d.className="greeting",d.setAttribute("part","greeting");let h=document.createElement("slot");h.name="greeting",h.append(this.#le),d.append(h),this.#pe();let g=document.createElement("slot");g.name="empty";let f=D_(this,this.#t,k=>{this.sendMessage(k)});f!==null&&g.append(f),this.#O.replaceChildren(d,g),this.#$.className="queued",this.#$.setAttribute("part","queued"),this.#$.setAttribute("role","group"),this.#$.setAttribute("aria-label",this.#t.queued),this.#$.hidden=!0,this.#h.append(this.#O),this.#v.updateEmptyState();let p=document.createElement("div");p.className="input-row",p.setAttribute("part","composer");let b=document.createElement("div");b.className="composer",b.setAttribute("part","composer-surface");let v=document.createElement("div");v.className="composer-tools",v.setAttribute("part","composer-tools"),this.#s.className="input",this.#s.setAttribute("part","input"),this.#s.setAttribute("aria-label",this.#t.message),this.#s.rows=1,this.#s.placeholder=this.#t.inputPlaceholder,this.#s.addEventListener("keydown",k=>this.#$e(k),{signal:t}),this.#s.addEventListener("input",()=>this.#xe(),{signal:t}),this.#f.className="send",this.#f.type="button",this.#f.setAttribute("part","send"),this.#f.replaceChildren(Ml("icon-send","send-send",xg),Ml("icon-stop","send-stop",_g)),this.#f.title=this.#t.send,this.#f.setAttribute("aria-label",this.#t.send),this.#f.dataset.state="idle",this.#f.addEventListener("click",()=>{if(this.#C){this.#j();return}this.#ae()},{signal:t}),this.#E.className="skill-hint",this.#E.setAttribute("part","skill-hint"),this.#E.hidden=!0,this.#w.className="attach-btn",this.#w.type="button",this.#w.setAttribute("part","attach-button"),this.#w.replaceChildren(Ml("icon-attach","attach-glyph",Eg)),this.#w.title=this.#t.attachFiles,this.#w.setAttribute("aria-label",this.#t.attachFiles),this.#w.hidden=!0,this.#w.addEventListener("click",()=>this.#T.click(),{signal:t}),this.#T.className="attach-input",this.#T.type="file",this.#T.multiple=!0,this.#T.hidden=!0,this.#T.addEventListener("change",()=>this.#R.onFilesPicked(),{signal:t}),this.#P.className="attachment-slot",this.#q.className="voice-slot";let _=document.createElement("slot");_.name="footer",v.append(this.#w,this.#q,this.#f),b.append(this.#s,v),p.append(b,this.#T),this.#d.className="messages-wrap",this.#d.replaceChildren(this.#h,this.#l,this.#c.button),this.#u.replaceChildren(n,this.#d,this.#b.palette,this.#b.chips,this.#E,this.#$,this.#P,p,_,this.#g.element,this.#y.element),this.#u.addEventListener("pointerdown",k=>{if(!this.#y.open_)return;let E=k.composedPath();E.includes(this.#y.element)||E.includes(s)||this.#y.close()},{signal:t}),this.#x.className="launcher",this.#x.type="button",this.#x.setAttribute("part","launcher"),this.#x.setAttribute("aria-label",this.#t.expand),this.#I.className="launcher-badge",this.#I.setAttribute("part","launcher-badge"),this.#I.setAttribute("aria-hidden","true"),this.#I.hidden=!0,this.#N.className="rail-label",this.#N.setAttribute("part","rail-label"),this.#N.setAttribute("aria-hidden","true"),this.#N.textContent=this.getAttribute("title-text")??this.#t.title,this.#x.replaceChildren(Ll("launcher","launcher-icon",Ig,Zx(this)),this.#N,this.#I),this.#x.addEventListener("click",()=>this.setCollapsed(!1),{signal:t}),this.#_.enableLauncherDrag(t),this.#_.mountResizeGrips(this.#u),Fx(this.#i);let y=this.#_.probe;y.className="viewport-probe",y.setAttribute("aria-hidden","true"),this.#i.replaceChildren(y,this.#a.region,this.#u,this.#x)}#we(){this.#x.setAttribute("aria-expanded",String(!this.collapsed));let t=this.#H;this.#I.textContent=t>9?"9+":String(t),this.#I.hidden=t===0||!Vx(this);let n=this.#I.hidden?this.#t.expand:ae(this.#t.expandUnread,{count:t});this.#x.setAttribute("aria-label",n),this.#x.title=n}#J(t){this.#H=t,this.#we(),this.dispatchEvent(new CustomEvent(Su,{detail:{unread:t},bubbles:!0,composed:!0}))}#Oe(){this.collapsed&&this.#J(this.#H+1)}#xe(){this.#b.onInput(this.#s.value),this.#E.hidden=!0,Ht(this.#s),this.#D=null}#$e(t){if(this.#b.onKeydown(t)){t.preventDefault();return}if(t.key==="Escape"&&this.#C){t.preventDefault(),this.#j();return}if(t.key==="Enter"&&!t.shiftKey){t.preventDefault(),this.#ae();return}this.#Pe(t)}#Pe(t){let n=t.key==="ArrowUp";if(!n&&t.key!=="ArrowDown"||this.#b.isOpen())return;let o=this.#G;if(o.length===0||this.#D===null&&(!n||this.#s.value!==""))return;let r=this.#D===null?0:this.#D+(n?1:-1);r>=o.length||(t.preventDefault(),this.#D=r<0?null:r,this.#s.value=r<0?"":o[r],this.#s.setSelectionRange(this.#s.value.length,this.#s.value.length),Ht(this.#s))}#j(){for(let t of this.#z)this.#G[0]!==t&&this.#G.unshift(t);this.#z.length=0,this.#Q(),this.#re.abort(),this.#L?.cancel(),this.#p.stopContinuation()}#W(t){let n=this.#C&&!t;this.#C=t;let o=t?this.#t.stop:this.#t.send;this.#f.title=o,this.#f.setAttribute("aria-label",o),this.#f.dataset.state=t?"running":"idle",n&&this.#_e()}#_e(){if(this.#C||this.#p.continuation!==null)return;let t=this.#z.shift();this.#Q(),t!==void 0&&this.sendMessage(t)}#Q(){this.#$.replaceChildren(),this.#$.hidden=this.#z.length===0;for(let[t,n]of this.#z.entries()){let o=document.createElement("button");o.type="button",o.className="queued-chip",o.setAttribute("part","queued-chip"),o.textContent=n,o.title=ae(this.#t.removeQueued,{text:n}),o.setAttribute("aria-label",o.title),o.addEventListener("click",()=>{this.#z.splice(t,1),this.#Q()}),this.#$.appendChild(o)}}async#ae(){let t=this.#s.value.trim(),n=this.#R.tray?.readyRefs()??[];if(!(t===""&&n.length===0)){if(this.#C||this.#p.continuation!==null){t!==""&&(this.#z.push(t),this.#Q(),this.#s.value="",Ht(this.#s));return}t!==""&&this.#G[0]!==t&&this.#G.unshift(t),this.#D=null,this.#s.value="",Ht(this.#s),this.#R.tray?.hasPending()===!0&&this.#v.appendNotice("\u{1F4CE}",ae(this.#t.attachmentsStillUploading,{n:this.#R.tray.pendingCount()}),"attachment-pending"),this.#R.tray?.clearReady(),await this.sendMessage(t,n)}}async sendMessage(t,n=[]){if(this.#C||this.#p.continuation!==null||t===""&&n.length===0)return;this.#v.isEmpty()&&this.setAttribute("data-composer-settling","");let o=this.appendMessage(De.USER,t);n.length>0&&o.appendChild(vl(n)),this.dispatchEvent(new CustomEvent(_u,{detail:{content:t,attachments:n},bubbles:!0,composed:!0})),await this.#Me(t,n)}attachFile(t){return this.#R.attach(t)}async#Me(t,n){if(this.endpoint===""){console.error('<ag-ui-chat>: no endpoint is set, so this message was not sent and no request was made. Point the element at your AG-UI mount with the endpoint attribute (endpoint="/agent/"), or assign chat.endpoint before sending.'),this.#v.appendNotice("\u26A0",this.#t.notConnected,"not-connected");return}await this.#se().send(t,n)}#se(){return this.#L===null&&(this.#L=this.#Ee({endpoint:this.endpoint,initialMessages:this.#p.restored,follows:[]})),this.#L}#Ee(t){let n=this.#p.threadId,o=this.agentFactory({endpoint:t.endpoint,headers:this.#oe(),getHeaders:()=>this.#oe(),trustedOrigins:this.trustedOrigins,...this.#ie(),threadId:n,initialMessages:t.initialMessages,initialState:this.#U});return new Ko({agent:o,handlers:this.#ee.forClient(),getTools:()=>this.#A.advertise(),getContext:()=>this.#M.buildContext(),executeTool:r=>this.#M.execute(r),resolveInterrupts:r=>this.#M.resolveInterrupts(r),onPersist:r=>{let i=[...t.follows,...r];this.conversationStore.saveMessages(n,i),t.onSaved?.(i)},onStateChanged:r=>this.#Le(r),connectionLostMessage:this.#t.connectionLost,unfinishedMessage:this.#t.callNotFinished,declinedMessage:this.#t.declinedAction,maxToolRounds:q_(this)})}#Le(t){this.#U={...t},this.dispatchEvent(new CustomEvent(Tu,{detail:{state:this.#U},bubbles:!0,composed:!0}))}#Se(t,n){this.#v.appendNotice("\u2922",t,"surface",n===null?void 0:{label:this.#t.undo,onActivate:n})}enableCharts(t=["tool","activity"]){let n=!this.#o.has(vi)&&!this.#A.has(gl);t.includes("activity")&&this.registerActivityRenderer({type:vi,render:o=>{let r=hr(o);return r===null?null:Ao(r)},removedNotice:this.#t.chartUndrawable}),t.includes("tool")&&this.registerTool(kx()),n&&this.isConnected&&this.reload()}registerActivityRenderer(t){this.#o.register(t)}get unhandledActivityTypes(){return this.#o.unhandledTypes()}};function RO(e){let t=e?.removed;return typeof t=="number"?t:null}function CO(){customElements.get(fi)===void 0&&customElements.define(fi,ei)}async function NO(e,t,n={}){await Et(e),await Fu(e,{...n,flashMs:n.flashMs??0}),await Hu(e,t,n)}async function OO(e,t={}){await Et(e),await Gu(e,t)}async function $O(e,t={}){await Et(e),await Vu(e,t)}async function PO(e,t,n={}){await Et(e),await Zu(e,t,n)}async function MO(e,t,n={}){await Et(e),await Bu(e,t,n)}function LO(e,t){e instanceof HTMLInputElement&&e.type==="checkbox"?kr(e,!!t):Kt(e,String(t)),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0}))}var zO="0.41.0";export{ku as ATTACHMENT_EVENT,ei as AgUiChat,Ko as AgUiClient,vi as CHART_ACTIVITY_TYPE,gl as CHART_TOOL_NAME,wi as CHAT_CORNERS,Pu as COMPACTION_ACTIVITY_TYPE,Au as CUSTOM_AGENT_EVENT,No as CheckpointMenu,Tr as ClientToolRegistry,eu as ConnectionLostError,pe as DEFAULT_UI_STRINGS,fi as ELEMENT_TAG,Cu as FEEDBACK_EVENT,Ou as INVALIDATE_CUSTOM_NAME,Ru as INVALIDATE_EVENT,Mu as LOAD_CAPABILITY_TOOL,ZR as MAX_QUOTE_CHARS,mO as MAX_SUGGESTIONS,gO as MAX_SUGGESTION_CHARS,Ln as MAX_TOOL_ROUNDS,qt as MESSAGE_ACTIONS,De as MESSAGE_ROLE,Ar as PAGE_ACTIONS,Iu as RUN_FINISHED_EVENT,Qo as RemoteConversationStore,Oo as RunIndex,Tu as STATE_EVENT,_u as SUBMIT_EVENT,Nu as SUGGESTIONS_ACTIVITY_TYPE,tt as SessionStorageStore,Eu as TOGGLE_EVENT,ne as TOOL_CALL_STATUS,zn as TOOL_DISPLAY,Ue as TOOL_OUTCOME,Do as ToolCallCard,Su as UNREAD_EVENT,zO as VERSION,mi as X_CONFIRM_KEY,Er as X_DESTRUCTIVE_KEY,Sr as X_NAVIGATES_KEY,ke as X_SUMMARY_KEY,om as asQuote,fm as attachMessageActions,am as attachQuoteOffer,hr as chartSpecFrom,OO as clickElement,zu as createChatSurfaceTools,zm as createHttpAgent,Wu as createPageActionTools,qu as createPageMapContext,Si as createPageStateTools,Xu as createRouteTools,KE as createStateHookTools,CO as defineAgUiChat,NO as fillField,ZE as flash,Fu as focusWithFlash,Gu as highlightThenClick,Ug as isChatCorner,Qf as isDestructive,fl as isNavigates,Wf as mergeUiStrings,Dl as messageActionBar,lm as messageAttachments,Xf as parseToolCatalog,_i as prefersReducedMotion,$O as pressButton,Vu as pressThenClick,Mm as prettifyToolName,Ro as quotableSelection,Co as relativeTime,Ao as renderChart,qo as renderMarkdown,Xo as renderSuggestionChips,Kf as requestApproval,Jf as requestConfirmation,qf as requestQuestion,Et as scrollIntoCenterView,PO as selectControl,Zu as selectOption,LO as setControlValue,kr as setNativeChecked,Kt as setNativeValue,Du as showHighlightOverlay,z_ as suggestionPrompts,MO as toggleCheckbox,Bu as toggleControl,$o as toolStatusFromOutcome,rm as transcribeAudio,Hu as typeInto,tm as uploadAttachment};
|
|
3900
3931
|
/*! Bundled license information:
|
|
3901
3932
|
|
|
3902
3933
|
fast-json-patch/module/helpers.mjs:
|
|
@@ -3914,6 +3945,6 @@ fast-json-patch/module/duplex.mjs:
|
|
|
3914
3945
|
*)
|
|
3915
3946
|
|
|
3916
3947
|
dompurify/dist/purify.es.mjs:
|
|
3917
|
-
(*! @license DOMPurify 3.4.
|
|
3948
|
+
(*! @license DOMPurify 3.4.15 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.15/LICENSE *)
|
|
3918
3949
|
*/
|
|
3919
3950
|
//# sourceMappingURL=ag-ui-web-component.bundle.js.map
|