@artooi/ag-ui-web-component 0.20.1 → 0.22.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 +192 -1
- package/README.md +404 -28
- package/dist/ag-ui-web-component.bundle.js +781 -451
- package/dist/ag-ui-web-component.bundle.js.map +4 -4
- package/dist/constants.d.ts +29 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/core/ag_ui_chat.d.ts +93 -1
- package/dist/core/ag_ui_chat.d.ts.map +1 -1
- package/dist/core/create_http_agent.d.ts +9 -0
- package/dist/core/create_http_agent.d.ts.map +1 -1
- package/dist/core/remote_conversation_store.d.ts +8 -1
- package/dist/core/remote_conversation_store.d.ts.map +1 -1
- package/dist/core/run_index.d.ts +8 -1
- package/dist/core/run_index.d.ts.map +1 -1
- package/dist/core/transcribe_audio.d.ts +7 -0
- package/dist/core/transcribe_audio.d.ts.map +1 -1
- package/dist/core/upload_attachment.d.ts +9 -0
- package/dist/core/upload_attachment.d.ts.map +1 -1
- package/dist/core/utils.d.ts +12 -0
- package/dist/core/utils.d.ts.map +1 -0
- package/dist/dom/animations.d.ts +51 -11
- package/dist/dom/animations.d.ts.map +1 -1
- package/dist/dom/dom_driver.d.ts +12 -7
- package/dist/dom/dom_driver.d.ts.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1275 -520
- package/dist/index.js.map +3 -3
- package/dist/ui/styles.d.ts +1 -1
- package/dist/ui/styles.d.ts.map +1 -1
- package/dist/ui/ui_strings.d.ts +8 -1
- package/dist/ui/ui_strings.d.ts.map +1 -1
- package/dist/ui/voice_input.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +35 -0
- package/src/core/ag_ui_chat.ts +452 -55
- package/src/core/create_http_agent.ts +14 -3
- package/src/core/remote_conversation_store.ts +25 -6
- package/src/core/run_index.ts +27 -5
- package/src/core/transcribe_audio.ts +20 -5
- package/src/core/upload_attachment.ts +13 -0
- package/src/core/utils.ts +18 -0
- package/src/dom/animations.ts +175 -31
- package/src/dom/dom_driver.ts +18 -12
- package/src/index.ts +4 -0
- package/src/ui/styles.ts +751 -421
- package/src/ui/ui_strings.ts +9 -1
- package/src/ui/voice_input.ts +7 -1
- package/src/version.ts +1 -1
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
var Rd=Object.defineProperty;var $i=(t,e)=>{for(var n in e)Rd(t,n,{get:e[n],enumerable:!0})};var Rr="ag-ui-chat",Bi="ag-ui-submit",Vi="ag-ui-toggle",ji="ag-ui-state",qi="ag-ui-attachments",Ve={USER:"user",ASSISTANT:"assistant"},zn="x-destructive",Wi="x-confirm",Le="x-summary",Fn="x-navigates",Xi="read_page",Yi=10,pe={PENDING:"pending",DONE:"done",ERROR:"error",DECLINED:"declined"},Pe={UPLOADING:"uploading",READY:"ready",ERROR:"error"},Ki=10*1024*1024,dn={INLINE:"inline",MINIMAL:"minimal",COMPACT:"compact",FULL:"full"},Zi="compaction",Ji="load_capability";var Nd=/\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g;function sl(t,e){let n=[];return{text:t.replace(Nd,(o,i)=>{let s=e[i];return s==null||s===""?(n.includes(i)||n.push(i),o):String(s)}),missing:n}}function Od(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 Qi(t){return Array.isArray(t)?t.filter(Od):[]}var $n=class{#n=new Map;register(e){this.#n.set(e.name,e)}has(e){return this.#n.has(e)}get(e){let n=this.#n.get(e);if(n===void 0)throw new Error(`tool "${e}" is not registered`);return n}tools(){return[...this.#n.values()].map(e=>({name:e.name,description:e.description,parameters:e.parameters}))}};function es(t){return t[zn]===!0}function Nr(t){return t[Fn]===!0}function Or(t,e){return Object.getOwnPropertyDescriptor(t,e).set}var Md=Or(HTMLInputElement.prototype,"value"),Ld=Or(HTMLTextAreaElement.prototype,"value"),Pd=Or(HTMLSelectElement.prototype,"value"),Dd=Or(HTMLInputElement.prototype,"checked");function Rt(t,e){t instanceof HTMLTextAreaElement?Ld.call(t,e):t instanceof HTMLSelectElement?Pd.call(t,e):Md.call(t,e)}function Bn(t,e){Dd.call(t,e)}var al="#4f46e5";function Mr(t){return new Promise(e=>{setTimeout(e,t)})}async function ts(t,e,n={}){let r=n.charDelayMs??35;Rt(t,""),t.dispatchEvent(new Event("input",{bubbles:!0}));for(let o of e)Rt(t,t.value+o),t.dispatchEvent(new Event("input",{bubbles:!0})),r>0&&await Mr(r);t.dispatchEvent(new Event("change",{bubbles:!0}))}async function ns(t,e={}){let n=e.highlightMs??280,r=t.style.outline,o=t.style.outlineOffset;t.style.outline=`2px solid ${al}`,t.style.outlineOffset="2px",await Mr(n),t.style.outline=r,t.style.outlineOffset=o,t.click()}function at(t){t.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}async function rs(t,e={}){let n=e.flashMs??200;t.focus();let r=t.style.boxShadow;t.style.boxShadow="0 0 0 3px rgba(79, 70, 229, 0.4)",await Mr(n),t.style.boxShadow=r}var ll="0 0 0 3px rgba(79, 70, 229, 0.4)";function cl(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}function os(t){return t<=0||cl()?Promise.resolve():Mr(t)}async function is(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=ll,await os(n),t.style.transform=r,t.style.transition=o,t.style.boxShadow=i,t.click()}function Ud(t,e){for(let n of Array.from(t.options))if(n.value===e||n.text===e)return n;return null}async function ss(t,e,n={}){let r=Ud(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 ${al}`,t.style.outlineOffset="2px",await os(o),Rt(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 as(t,e,n={}){let r=n.flashMs??200,o=t.style.boxShadow;t.style.boxShadow=ll,await os(r),Bn(t,e),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})),t.style.boxShadow=o}var ls={SCROLL:"scroll",DRAG:"drag"};function cs(t,e){let n=[];return t.has(ls.SCROLL)&&n.push(Hd(e)),t.has(ls.DRAG)&&n.push(Gd(e)),n}function Hd(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"],[Le]:"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 at(r),{scrolled:!0,target:n}}}}function Gd(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"],[Le]:"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 zd(o,i),{dragged:!0,from:n,to:r}}}}function zd(t,e){let n=new DataTransfer;Vn(t,"dragstart",n),Vn(e,"dragenter",n),Vn(e,"dragover",n),Vn(e,"drop",n),Vn(t,"dragend",n)}function Vn(t,e,n){let r=new Event(e,{bubbles:!0,cancelable:!0});r.dataTransfer=n,t.dispatchEvent(r)}function us(t,e){return!e||t===null?[]:[{description:"page_map",value:JSON.stringify(t())}]}function Lr(t){let e=[{name:`read_${t.name}`,description:`Read the "${t.name}" state.`,parameters:{type:"object",properties:{},required:[],[Le]:`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"},[zn]:!0,[Le]:`Update ${t.name}`},handler:r=>n(r)}),e}var Fd=Lr;function ds(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;typeof o=="string"&&typeof i=="string"&&(e[o]=i)}return e}var ul=/:([A-Za-z_][A-Za-z0-9_]*)/g;function $d(t){return[...t.matchAll(ul)].map(e=>e[0].slice(1))}function Bd(t,e,n){let r={...n};return{path:e.replace(ul,(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 Vd(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 ps(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:[],[Le]:"List pages"},handler:()=>t().map(n=>({...n,pathParams:$d(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"],[Fn]:!0,[Le]:"Navigate"},handler:n=>{let r=n.route_id,o=t().find(h=>h.id===r);if(o===void 0)throw new Error(`unknown route "${String(r)}"`);let i=n.params??{},{path:s,leftover:a}=Bd(o.id,o.path,i),l=Vd(s,a),c=e();return c!==null?c(l):window.location.assign(l),{navigated:!0,path:l}}}]}var ae={title:"Assistant",chatHistory:"Chat history",newChat:"New chat",collapse:"Collapse",expand:"Expand",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",conversation:"Conversation",thinking:"Assistant is thinking\u2026",thoughts:"Thoughts",stopped:"\u23F9 Stopped",connectionLost:"Connection lost",noResult:"No result returned.",declinedAction:"User declined the action.",navigating:"Navigating\u2026",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.",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",toolRunning:"running\u2026",toolDone:"\u2713 done",toolError:"\u26A0 error",toolDeclined:"\u2298 declined",resizePanel:"Resize the chat panel",decisionApproved:"approved by you",decisionDeclined:"declined by you",argumentsLabel:"Arguments",resultLabel:"Result",errorLabel:"Error",declinedLabel:"Declined",details:"Details",confirmAction:"Confirm action",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 hs(t){let e={...ae};for(let n of Object.keys(t)){let r=t[n];r!==void 0&&(e[n]=r)}return e}function dl(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 fs(t,e,n={}){let r=n.strings??ae;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=document.createElement("div");a.className="approval-actions",a.setAttribute("part","approval-actions");let l=dl("deny",r.deny),c=dl("approve",r.approve),h=!1,m=y=>{h||(h=!0,l.disabled=!0,c.disabled=!0,i.setAttribute("data-resolved",y?"approved":"denied"),o(y))};if(l.addEventListener("click",()=>m(!1)),c.addEventListener("click",()=>m(!0)),n.signal?.addEventListener("abort",()=>m(!1),{once:!0}),a.append(l,c),i.append(s,a),t.appendChild(i),n.signal?.aborted===!0){m(!1);return}c.focus()})}function ms(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(jd(r,e)))}}function jd(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",()=>{qd(n).then(o=>{Wd(r,o?e.copied:e.copyFailed,e)})}),r}async function qd(t){let e=navigator.clipboard;if(e===void 0)return!1;try{return await e.writeText(t),!0}catch{return!1}}function Wd(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 gs(t){let e=document.createElement("div");e.className="attachment-chips",e.setAttribute("part","attachment-chips");for(let n of t)e.appendChild(Xd(n));return e}function Xd(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.textContent=vs(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=Pr(t.size),e.append(n,r,o),e}function vs(t){return t.startsWith("image/")?"\u{1F5BC}":t==="application/pdf"?"\u{1F4D5}":t.startsWith("text/")?"\u{1F4C4}":"\u{1F4CE}"}function Pr(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 xe=[];for(let t=0;t<256;++t)xe.push((t+256).toString(16).slice(1));function pl(t,e=0){return(xe[t[e+0]]+xe[t[e+1]]+xe[t[e+2]]+xe[t[e+3]]+"-"+xe[t[e+4]]+xe[t[e+5]]+"-"+xe[t[e+6]]+xe[t[e+7]]+"-"+xe[t[e+8]]+xe[t[e+9]]+"-"+xe[t[e+10]]+xe[t[e+11]]+xe[t[e+12]]+xe[t[e+13]]+xe[t[e+14]]+xe[t[e+15]]).toLowerCase()}var bs,Yd=new Uint8Array(16);function ys(){if(!bs){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");bs=crypto.getRandomValues.bind(crypto)}return bs(Yd)}var Kd=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),xs={randomUUID:Kd};function Zd(t,e,n){if(xs.randomUUID&&!e&&!t)return xs.randomUUID();t=t||{};let r=t.random??t.rng?.()??ys();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 pl(r)}var yt=Zd;var u={};$i(u,{BRAND:()=>wp,DIRTY:()=>Nt,EMPTY_PATH:()=>tp,INVALID:()=>P,NEVER:()=>ah,OK:()=>_e,ParseStatus:()=>Ee,Schema:()=>$,ZodAny:()=>Tt,ZodArray:()=>dt,ZodBigInt:()=>Mt,ZodBoolean:()=>Lt,ZodBranded:()=>qn,ZodCatch:()=>jt,ZodDate:()=>Pt,ZodDefault:()=>Vt,ZodDiscriminatedUnion:()=>Hr,ZodEffects:()=>Fe,ZodEnum:()=>$t,ZodError:()=>Ne,ZodFirstPartyTypeKind:()=>D,ZodFunction:()=>zr,ZodIntersection:()=>Gt,ZodIssueCode:()=>T,ZodLazy:()=>zt,ZodLiteral:()=>Ft,ZodMap:()=>vn,ZodNaN:()=>yn,ZodNativeEnum:()=>Bt,ZodNever:()=>je,ZodNull:()=>Ut,ZodNullable:()=>nt,ZodNumber:()=>Ot,ZodObject:()=>Oe,ZodOptional:()=>Ge,ZodParsedType:()=>I,ZodPipeline:()=>Wn,ZodPromise:()=>wt,ZodReadonly:()=>qt,ZodRecord:()=>Gr,ZodSchema:()=>$,ZodSet:()=>bn,ZodString:()=>Et,ZodSymbol:()=>mn,ZodTransformer:()=>Fe,ZodTuple:()=>tt,ZodType:()=>$,ZodUndefined:()=>Dt,ZodUnion:()=>Ht,ZodUnknown:()=>ut,ZodVoid:()=>gn,addIssueToContext:()=>k,any:()=>Op,array:()=>Dp,bigint:()=>kp,boolean:()=>wl,coerce:()=>sh,custom:()=>xl,date:()=>Ip,datetimeRegex:()=>bl,defaultErrorMap:()=>lt,discriminatedUnion:()=>zp,effect:()=>Jp,enum:()=>Yp,function:()=>qp,getErrorMap:()=>pn,getParsedType:()=>et,instanceof:()=>_p,intersection:()=>Fp,isAborted:()=>Dr,isAsync:()=>hn,isDirty:()=>Ur,isValid:()=>xt,late:()=>Sp,lazy:()=>Wp,literal:()=>Xp,makeIssue:()=>jn,map:()=>Vp,nan:()=>Ap,nativeEnum:()=>Kp,never:()=>Lp,null:()=>Np,nullable:()=>eh,number:()=>Tl,object:()=>Up,objectUtil:()=>Es,oboolean:()=>ih,onumber:()=>oh,optional:()=>Qp,ostring:()=>rh,pipeline:()=>nh,preprocess:()=>th,promise:()=>Zp,quotelessJson:()=>Jd,record:()=>Bp,set:()=>jp,setErrorMap:()=>ep,strictObject:()=>Hp,string:()=>El,symbol:()=>Cp,transformer:()=>Jp,tuple:()=>$p,undefined:()=>Rp,union:()=>Gp,unknown:()=>Mp,util:()=>V,void:()=>Pp});var V;(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})(V||(V={}));var Es;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Es||(Es={}));var I=V.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),et=t=>{switch(typeof t){case"undefined":return I.undefined;case"string":return I.string;case"number":return Number.isNaN(t)?I.nan:I.number;case"boolean":return I.boolean;case"function":return I.function;case"bigint":return I.bigint;case"symbol":return I.symbol;case"object":return Array.isArray(t)?I.array:t===null?I.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?I.promise:typeof Map<"u"&&t instanceof Map?I.map:typeof Set<"u"&&t instanceof Set?I.set:typeof Date<"u"&&t instanceof Date?I.date:I.object;default:return I.unknown}};var T=V.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"]),Jd=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Ne=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 c=s.path[l];l===s.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(s))):a[c]=a[c]||{_errors:[]},a=a[c],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,V.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()}};Ne.create=t=>new Ne(t);var Qd=(t,e)=>{let n;switch(t.code){case T.invalid_type:t.received===I.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case T.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,V.jsonStringifyReplacer)}`;break;case T.unrecognized_keys:n=`Unrecognized key(s) in object: ${V.joinValues(t.keys,", ")}`;break;case T.invalid_union:n="Invalid input";break;case T.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${V.joinValues(t.options)}`;break;case T.invalid_enum_value:n=`Invalid enum value. Expected ${V.joinValues(t.options)}, received '${t.received}'`;break;case T.invalid_arguments:n="Invalid function arguments";break;case T.invalid_return_type:n="Invalid function return type";break;case T.invalid_date:n="Invalid date";break;case T.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}"`:V.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case T.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 T.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 T.custom:n="Invalid input";break;case T.invalid_intersection_types:n="Intersection results could not be merged";break;case T.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case T.not_finite:n="Number must be finite";break;default:n=e.defaultError,V.assertNever(t)}return{message:n}},lt=Qd;var hl=lt;function ep(t){hl=t}function pn(){return hl}var jn=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(c=>!!c).slice().reverse();for(let c of l)a=c(s,{data:e,defaultError:a}).message;return{...o,path:i,message:a}},tp=[];function k(t,e){let n=pn(),r=jn({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===lt?void 0:lt].filter(o=>!!o)});t.common.issues.push(r)}var Ee=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 P;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 P;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}}},P=Object.freeze({status:"aborted"}),Nt=t=>({status:"dirty",value:t}),_e=t=>({status:"valid",value:t}),Dr=t=>t.status==="aborted",Ur=t=>t.status==="dirty",xt=t=>t.status==="valid",hn=t=>typeof Promise<"u"&&t instanceof Promise;var R;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(R||(R={}));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}},fl=(t,e)=>{if(xt(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 Ne(t.common.issues);return this._error=n,this._error}}};function z(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 $=class{get description(){return this._def.description}_getType(e){return et(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:et(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ee,ctx:{common:e.parent.common,data:e.data,parsedType:et(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:et(e)},o=this._parseSync({data:e,path:r.path,parent:r});return fl(r,o)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:et(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return xt(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=>xt(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:et(e)},o=this._parse({data:e,path:r.path,parent:r}),i=await(hn(o)?o:Promise.resolve(o));return fl(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:T.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 Fe({schema:this,typeName:D.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 Ge.create(this,this._def)}nullable(){return nt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return dt.create(this)}promise(){return wt.create(this,this._def)}or(e){return Ht.create([this,e],this._def)}and(e){return Gt.create(this,e,this._def)}transform(e){return new Fe({...z(this._def),schema:this,typeName:D.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new Vt({...z(this._def),innerType:this,defaultValue:n,typeName:D.ZodDefault})}brand(){return new qn({typeName:D.ZodBranded,type:this,...z(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new jt({...z(this._def),innerType:this,catchValue:n,typeName:D.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Wn.create(this,e)}readonly(){return qt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},np=/^c[^\s-]{8,}$/i,rp=/^[0-9a-z]+$/,op=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ip=/^[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,sp=/^[a-z0-9_-]{21}$/i,ap=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,lp=/^[-+]?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)?)??$/,cp=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,up="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ts,dp=/^(?:(?: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])$/,pp=/^(?:(?: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])$/,hp=/^(([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]))$/,fp=/^(([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])$/,mp=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,gp=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,gl="((\\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])))",vp=new RegExp(`^${gl}$`);function vl(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 bp(t){return new RegExp(`^${vl(t)}$`)}function bl(t){let e=`${gl}T${vl(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 yp(t,e){return!!((e==="v4"||!e)&&dp.test(t)||(e==="v6"||!e)&&hp.test(t))}function xp(t,e){if(!ap.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 Ep(t,e){return!!((e==="v4"||!e)&&pp.test(t)||(e==="v6"||!e)&&fp.test(t))}var Et=class t extends ${_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==I.string){let i=this._getOrReturnCtx(e);return k(i,{code:T.invalid_type,expected:I.string,received:i.parsedType}),P}let r=new Ee,o;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(o=this._getOrReturnCtx(e,o),k(o,{code:T.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),k(o,{code:T.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?k(o,{code:T.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&k(o,{code:T.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")cp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"email",code:T.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Ts||(Ts=new RegExp(up,"u")),Ts.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"emoji",code:T.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")ip.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"uuid",code:T.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")sp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"nanoid",code:T.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")np.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"cuid",code:T.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")rp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"cuid2",code:T.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")op.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"ulid",code:T.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),k(o,{validation:"url",code:T.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),k(o,{validation:"regex",code:T.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),k(o,{code:T.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),k(o,{code:T.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(o=this._getOrReturnCtx(e,o),k(o,{code:T.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?bl(i).test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{code:T.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?vp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{code:T.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?bp(i).test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{code:T.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?lp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"duration",code:T.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?yp(e.data,i.version)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"ip",code:T.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?xp(e.data,i.alg)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"jwt",code:T.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Ep(e.data,i.version)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"cidr",code:T.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?mp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"base64",code:T.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?gp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"base64url",code:T.invalid_string,message:i.message}),r.dirty()):V.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(o=>e.test(o),{validation:n,code:T.invalid_string,...R.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...R.errToObj(e)})}url(e){return this._addCheck({kind:"url",...R.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...R.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...R.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...R.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...R.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...R.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...R.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...R.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...R.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...R.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...R.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...R.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,...R.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,...R.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...R.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...R.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...R.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...R.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...R.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...R.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...R.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...R.errToObj(n)})}nonempty(e){return this.min(1,R.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}};Et.create=t=>new Et({checks:[],typeName:D.ZodString,coerce:t?.coerce??!1,...z(t)});function Tp(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 Ot=class t extends ${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)!==I.number){let i=this._getOrReturnCtx(e);return k(i,{code:T.invalid_type,expected:I.number,received:i.parsedType}),P}let r,o=new Ee;for(let i of this._def.checks)i.kind==="int"?V.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),k(r,{code:T.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),k(r,{code:T.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),k(r,{code:T.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="multipleOf"?Tp(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),k(r,{code:T.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),k(r,{code:T.not_finite,message:i.message}),o.dirty()):V.assertNever(i);return{status:o.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,R.toString(n))}gt(e,n){return this.setLimit("min",e,!1,R.toString(n))}lte(e,n){return this.setLimit("max",e,!0,R.toString(n))}lt(e,n){return this.setLimit("max",e,!1,R.toString(n))}setLimit(e,n,r,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:R.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:R.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:R.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:R.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:R.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:R.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:R.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:R.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:R.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:R.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"&&V.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)}};Ot.create=t=>new Ot({checks:[],typeName:D.ZodNumber,coerce:t?.coerce||!1,...z(t)});var Mt=class t extends ${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)!==I.bigint)return this._getInvalidInput(e);let r,o=new Ee;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),k(r,{code:T.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),k(r,{code:T.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),k(r,{code:T.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):V.assertNever(i);return{status:o.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return k(n,{code:T.invalid_type,expected:I.bigint,received:n.parsedType}),P}gte(e,n){return this.setLimit("min",e,!0,R.toString(n))}gt(e,n){return this.setLimit("min",e,!1,R.toString(n))}lte(e,n){return this.setLimit("max",e,!0,R.toString(n))}lt(e,n){return this.setLimit("max",e,!1,R.toString(n))}setLimit(e,n,r,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:R.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:R.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:R.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:R.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:R.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:R.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}};Mt.create=t=>new Mt({checks:[],typeName:D.ZodBigInt,coerce:t?.coerce??!1,...z(t)});var Lt=class extends ${_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==I.boolean){let r=this._getOrReturnCtx(e);return k(r,{code:T.invalid_type,expected:I.boolean,received:r.parsedType}),P}return _e(e.data)}};Lt.create=t=>new Lt({typeName:D.ZodBoolean,coerce:t?.coerce||!1,...z(t)});var Pt=class t extends ${_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==I.date){let i=this._getOrReturnCtx(e);return k(i,{code:T.invalid_type,expected:I.date,received:i.parsedType}),P}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return k(i,{code:T.invalid_date}),P}let r=new Ee,o;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(o=this._getOrReturnCtx(e,o),k(o,{code:T.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),k(o,{code:T.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):V.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:R.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:R.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}};Pt.create=t=>new Pt({checks:[],coerce:t?.coerce||!1,typeName:D.ZodDate,...z(t)});var mn=class extends ${_parse(e){if(this._getType(e)!==I.symbol){let r=this._getOrReturnCtx(e);return k(r,{code:T.invalid_type,expected:I.symbol,received:r.parsedType}),P}return _e(e.data)}};mn.create=t=>new mn({typeName:D.ZodSymbol,...z(t)});var Dt=class extends ${_parse(e){if(this._getType(e)!==I.undefined){let r=this._getOrReturnCtx(e);return k(r,{code:T.invalid_type,expected:I.undefined,received:r.parsedType}),P}return _e(e.data)}};Dt.create=t=>new Dt({typeName:D.ZodUndefined,...z(t)});var Ut=class extends ${_parse(e){if(this._getType(e)!==I.null){let r=this._getOrReturnCtx(e);return k(r,{code:T.invalid_type,expected:I.null,received:r.parsedType}),P}return _e(e.data)}};Ut.create=t=>new Ut({typeName:D.ZodNull,...z(t)});var Tt=class extends ${constructor(){super(...arguments),this._any=!0}_parse(e){return _e(e.data)}};Tt.create=t=>new Tt({typeName:D.ZodAny,...z(t)});var ut=class extends ${constructor(){super(...arguments),this._unknown=!0}_parse(e){return _e(e.data)}};ut.create=t=>new ut({typeName:D.ZodUnknown,...z(t)});var je=class extends ${_parse(e){let n=this._getOrReturnCtx(e);return k(n,{code:T.invalid_type,expected:I.never,received:n.parsedType}),P}};je.create=t=>new je({typeName:D.ZodNever,...z(t)});var gn=class extends ${_parse(e){if(this._getType(e)!==I.undefined){let r=this._getOrReturnCtx(e);return k(r,{code:T.invalid_type,expected:I.void,received:r.parsedType}),P}return _e(e.data)}};gn.create=t=>new gn({typeName:D.ZodVoid,...z(t)});var dt=class t extends ${_parse(e){let{ctx:n,status:r}=this._processInputParams(e),o=this._def;if(n.parsedType!==I.array)return k(n,{code:T.invalid_type,expected:I.array,received:n.parsedType}),P;if(o.exactLength!==null){let s=n.data.length>o.exactLength.value,a=n.data.length<o.exactLength.value;(s||a)&&(k(n,{code:s?T.too_big:T.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&&(k(n,{code:T.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&&(k(n,{code:T.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=>Ee.mergeArray(r,s));let i=[...n.data].map((s,a)=>o.type._parseSync(new ze(n,s,n.path,a)));return Ee.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:R.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:R.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:R.toString(n)}})}nonempty(e){return this.min(1,e)}};dt.create=(t,e)=>new dt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:D.ZodArray,...z(e)});function fn(t){if(t instanceof Oe){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=Ge.create(fn(r))}return new Oe({...t._def,shape:()=>e})}else return t instanceof dt?new dt({...t._def,type:fn(t.element)}):t instanceof Ge?Ge.create(fn(t.unwrap())):t instanceof nt?nt.create(fn(t.unwrap())):t instanceof tt?tt.create(t.items.map(e=>fn(e))):t}var Oe=class t extends ${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=V.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==I.object){let c=this._getOrReturnCtx(e);return k(c,{code:T.invalid_type,expected:I.object,received:c.parsedType}),P}let{status:r,ctx:o}=this._processInputParams(e),{shape:i,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof je&&this._def.unknownKeys==="strip"))for(let c in o.data)s.includes(c)||a.push(c);let l=[];for(let c of s){let h=i[c],m=o.data[c];l.push({key:{status:"valid",value:c},value:h._parse(new ze(o,m,o.path,c)),alwaysSet:c in o.data})}if(this._def.catchall instanceof je){let c=this._def.unknownKeys;if(c==="passthrough")for(let h of a)l.push({key:{status:"valid",value:h},value:{status:"valid",value:o.data[h]}});else if(c==="strict")a.length>0&&(k(o,{code:T.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let h of a){let m=o.data[h];l.push({key:{status:"valid",value:h},value:c._parse(new ze(o,m,o.path,h)),alwaysSet:h in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let c=[];for(let h of l){let m=await h.key,y=await h.value;c.push({key:m,value:y,alwaysSet:h.alwaysSet})}return c}).then(c=>Ee.mergeObjectSync(r,c)):Ee.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return R.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:R.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:D.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 V.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 V.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return fn(this)}partial(e){let n={};for(let r of V.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 V.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof Ge;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return yl(V.objectKeys(this.shape))}};Oe.create=(t,e)=>new Oe({shape:()=>t,unknownKeys:"strip",catchall:je.create(),typeName:D.ZodObject,...z(e)});Oe.strictCreate=(t,e)=>new Oe({shape:()=>t,unknownKeys:"strict",catchall:je.create(),typeName:D.ZodObject,...z(e)});Oe.lazycreate=(t,e)=>new Oe({shape:t,unknownKeys:"strip",catchall:je.create(),typeName:D.ZodObject,...z(e)});var Ht=class extends ${_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 Ne(a.ctx.common.issues));return k(n,{code:T.invalid_union,unionErrors:s}),P}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 c={...n,common:{...n.common,issues:[]},parent:null},h=l._parseSync({data:n.data,path:n.path,parent:c});if(h.status==="valid")return h;h.status==="dirty"&&!i&&(i={result:h,ctx:c}),c.common.issues.length&&s.push(c.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let a=s.map(l=>new Ne(l));return k(n,{code:T.invalid_union,unionErrors:a}),P}}get options(){return this._def.options}};Ht.create=(t,e)=>new Ht({options:t,typeName:D.ZodUnion,...z(e)});var ct=t=>t instanceof zt?ct(t.schema):t instanceof Fe?ct(t.innerType()):t instanceof Ft?[t.value]:t instanceof $t?t.options:t instanceof Bt?V.objectValues(t.enum):t instanceof Vt?ct(t._def.innerType):t instanceof Dt?[void 0]:t instanceof Ut?[null]:t instanceof Ge?[void 0,...ct(t.unwrap())]:t instanceof nt?[null,...ct(t.unwrap())]:t instanceof qn||t instanceof qt?ct(t.unwrap()):t instanceof jt?ct(t._def.innerType):[],Hr=class t extends ${_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==I.object)return k(n,{code:T.invalid_type,expected:I.object,received:n.parsedType}),P;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}):(k(n,{code:T.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),P)}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=ct(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:D.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:o,...z(r)})}};function ws(t,e){let n=et(t),r=et(e);if(t===e)return{valid:!0,data:t};if(n===I.object&&r===I.object){let o=V.objectKeys(e),i=V.objectKeys(t).filter(a=>o.indexOf(a)!==-1),s={...t,...e};for(let a of i){let l=ws(t[a],e[a]);if(!l.valid)return{valid:!1};s[a]=l.data}return{valid:!0,data:s}}else if(n===I.array&&r===I.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=ws(s,a);if(!l.valid)return{valid:!1};o.push(l.data)}return{valid:!0,data:o}}else return n===I.date&&r===I.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Gt=class extends ${_parse(e){let{status:n,ctx:r}=this._processInputParams(e),o=(i,s)=>{if(Dr(i)||Dr(s))return P;let a=ws(i.value,s.value);return a.valid?((Ur(i)||Ur(s))&&n.dirty(),{status:n.value,value:a.data}):(k(r,{code:T.invalid_intersection_types}),P)};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}))}};Gt.create=(t,e,n)=>new Gt({left:t,right:e,typeName:D.ZodIntersection,...z(n)});var tt=class t extends ${_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==I.array)return k(r,{code:T.invalid_type,expected:I.array,received:r.parsedType}),P;if(r.data.length<this._def.items.length)return k(r,{code:T.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),P;!this._def.rest&&r.data.length>this._def.items.length&&(k(r,{code:T.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=>Ee.mergeArray(n,s)):Ee.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};tt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new tt({items:t,typeName:D.ZodTuple,rest:null,...z(e)})};var Gr=class t extends ${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!==I.object)return k(r,{code:T.invalid_type,expected:I.object,received:r.parsedType}),P;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?Ee.mergeObjectAsync(n,o):Ee.mergeObjectSync(n,o)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof $?new t({keyType:e,valueType:n,typeName:D.ZodRecord,...z(r)}):new t({keyType:Et.create(),valueType:e,typeName:D.ZodRecord,...z(n)})}},vn=class extends ${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!==I.map)return k(r,{code:T.invalid_type,expected:I.map,received:r.parsedType}),P;let o=this._def.keyType,i=this._def.valueType,s=[...r.data.entries()].map(([a,l],c)=>({key:o._parse(new ze(r,a,r.path,[c,"key"])),value:i._parse(new ze(r,l,r.path,[c,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let l of s){let c=await l.key,h=await l.value;if(c.status==="aborted"||h.status==="aborted")return P;(c.status==="dirty"||h.status==="dirty")&&n.dirty(),a.set(c.value,h.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let l of s){let c=l.key,h=l.value;if(c.status==="aborted"||h.status==="aborted")return P;(c.status==="dirty"||h.status==="dirty")&&n.dirty(),a.set(c.value,h.value)}return{status:n.value,value:a}}}};vn.create=(t,e,n)=>new vn({valueType:e,keyType:t,typeName:D.ZodMap,...z(n)});var bn=class t extends ${_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==I.set)return k(r,{code:T.invalid_type,expected:I.set,received:r.parsedType}),P;let o=this._def;o.minSize!==null&&r.data.size<o.minSize.value&&(k(r,{code:T.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&&(k(r,{code:T.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 c=new Set;for(let h of l){if(h.status==="aborted")return P;h.status==="dirty"&&n.dirty(),c.add(h.value)}return{status:n.value,value:c}}let a=[...r.data.values()].map((l,c)=>i._parse(new ze(r,l,r.path,c)));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:R.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:R.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:D.ZodSet,...z(e)});var zr=class t extends ${constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==I.function)return k(n,{code:T.invalid_type,expected:I.function,received:n.parsedType}),P;function r(a,l){return jn({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,pn(),lt].filter(c=>!!c),issueData:{code:T.invalid_arguments,argumentsError:l}})}function o(a,l){return jn({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,pn(),lt].filter(c=>!!c),issueData:{code:T.invalid_return_type,returnTypeError:l}})}let i={errorMap:n.common.contextualErrorMap},s=n.data;if(this._def.returns instanceof wt){let a=this;return _e(async function(...l){let c=new Ne([]),h=await a._def.args.parseAsync(l,i).catch(f=>{throw c.addIssue(r(l,f)),c}),m=await Reflect.apply(s,this,h);return await a._def.returns._def.type.parseAsync(m,i).catch(f=>{throw c.addIssue(o(m,f)),c})})}else{let a=this;return _e(function(...l){let c=a._def.args.safeParse(l,i);if(!c.success)throw new Ne([r(l,c.error)]);let h=Reflect.apply(s,this,c.data),m=a._def.returns.safeParse(h,i);if(!m.success)throw new Ne([o(h,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:tt.create(e).rest(ut.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||tt.create([]).rest(ut.create()),returns:n||ut.create(),typeName:D.ZodFunction,...z(r)})}},zt=class extends ${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})}};zt.create=(t,e)=>new zt({getter:t,typeName:D.ZodLazy,...z(e)});var Ft=class extends ${_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return k(n,{received:n.data,code:T.invalid_literal,expected:this._def.value}),P}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ft.create=(t,e)=>new Ft({value:t,typeName:D.ZodLiteral,...z(e)});function yl(t,e){return new $t({values:t,typeName:D.ZodEnum,...z(e)})}var $t=class t extends ${_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return k(n,{expected:V.joinValues(r),received:n.parsedType,code:T.invalid_type}),P}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 k(n,{received:n.data,code:T.invalid_enum_value,options:r}),P}return _e(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})}};$t.create=yl;var Bt=class extends ${_parse(e){let n=V.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==I.string&&r.parsedType!==I.number){let o=V.objectValues(n);return k(r,{expected:V.joinValues(o),received:r.parsedType,code:T.invalid_type}),P}if(this._cache||(this._cache=new Set(V.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=V.objectValues(n);return k(r,{received:r.data,code:T.invalid_enum_value,options:o}),P}return _e(e.data)}get enum(){return this._def.values}};Bt.create=(t,e)=>new Bt({values:t,typeName:D.ZodNativeEnum,...z(e)});var wt=class extends ${unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==I.promise&&n.common.async===!1)return k(n,{code:T.invalid_type,expected:I.promise,received:n.parsedType}),P;let r=n.parsedType===I.promise?n.data:Promise.resolve(n.data);return _e(r.then(o=>this._def.type.parseAsync(o,{path:n.path,errorMap:n.common.contextualErrorMap})))}};wt.create=(t,e)=>new wt({type:t,typeName:D.ZodPromise,...z(e)});var Fe=class extends ${innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===D.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=>{k(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 P;let l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?P:l.status==="dirty"?Nt(l.value):n.value==="dirty"?Nt(l.value):l});{if(n.value==="aborted")return P;let a=this._def.schema._parseSync({data:s,path:r.path,parent:r});return a.status==="aborted"?P:a.status==="dirty"?Nt(a.value):n.value==="dirty"?Nt(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"?P:(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"?P:(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(!xt(s))return P;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=>xt(s)?Promise.resolve(o.transform(s.value,i)).then(a=>({status:n.value,value:a})):P);V.assertNever(o)}};Fe.create=(t,e,n)=>new Fe({schema:t,typeName:D.ZodEffects,effect:e,...z(n)});Fe.createWithPreprocess=(t,e,n)=>new Fe({schema:e,effect:{type:"preprocess",transform:t},typeName:D.ZodEffects,...z(n)});var Ge=class extends ${_parse(e){return this._getType(e)===I.undefined?_e(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ge.create=(t,e)=>new Ge({innerType:t,typeName:D.ZodOptional,...z(e)});var nt=class extends ${_parse(e){return this._getType(e)===I.null?_e(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};nt.create=(t,e)=>new nt({innerType:t,typeName:D.ZodNullable,...z(e)});var Vt=class extends ${_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===I.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};Vt.create=(t,e)=>new Vt({innerType:t,typeName:D.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...z(e)});var jt=class extends ${_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 Ne(r.common.issues)},input:r.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Ne(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};jt.create=(t,e)=>new jt({innerType:t,typeName:D.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...z(e)});var yn=class extends ${_parse(e){if(this._getType(e)!==I.nan){let r=this._getOrReturnCtx(e);return k(r,{code:T.invalid_type,expected:I.nan,received:r.parsedType}),P}return{status:"valid",value:e.data}}};yn.create=t=>new yn({typeName:D.ZodNaN,...z(t)});var wp=Symbol("zod_brand"),qn=class extends ${_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}},Wn=class t extends ${_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"?P:i.status==="dirty"?(n.dirty(),Nt(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"?P: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:D.ZodPipeline})}},qt=class extends ${_parse(e){let n=this._def.innerType._parse(e),r=o=>(xt(o)&&(o.value=Object.freeze(o.value)),o);return hn(n)?n.then(o=>r(o)):r(n)}unwrap(){return this._def.innerType}};qt.create=(t,e)=>new qt({innerType:t,typeName:D.ZodReadonly,...z(e)});function ml(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function xl(t,e={},n){return t?Tt.create().superRefine((r,o)=>{let i=t(r);if(i instanceof Promise)return i.then(s=>{if(!s){let a=ml(e,r),l=a.fatal??n??!0;o.addIssue({code:"custom",...a,fatal:l})}});if(!i){let s=ml(e,r),a=s.fatal??n??!0;o.addIssue({code:"custom",...s,fatal:a})}}):Tt.create()}var Sp={object:Oe.lazycreate},D;(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"})(D||(D={}));var _p=(t,e={message:`Input not instance of ${t.name}`})=>xl(n=>n instanceof t,e),El=Et.create,Tl=Ot.create,Ap=yn.create,kp=Mt.create,wl=Lt.create,Ip=Pt.create,Cp=mn.create,Rp=Dt.create,Np=Ut.create,Op=Tt.create,Mp=ut.create,Lp=je.create,Pp=gn.create,Dp=dt.create,Up=Oe.create,Hp=Oe.strictCreate,Gp=Ht.create,zp=Hr.create,Fp=Gt.create,$p=tt.create,Bp=Gr.create,Vp=vn.create,jp=bn.create,qp=zr.create,Wp=zt.create,Xp=Ft.create,Yp=$t.create,Kp=Bt.create,Zp=wt.create,Jp=Fe.create,Qp=Ge.create,eh=nt.create,th=Fe.createWithPreprocess,nh=Wn.create,rh=()=>El().optional(),oh=()=>Tl().optional(),ih=()=>wl().optional(),sh={string:(t=>Et.create({...t,coerce:!0})),number:(t=>Ot.create({...t,coerce:!0})),boolean:(t=>Lt.create({...t,coerce:!0})),bigint:(t=>Mt.create({...t,coerce:!0})),date:(t=>Pt.create({...t,coerce:!0}))};var ah=P;var lh=u.object({name:u.string(),arguments:u.string()}),ch=u.object({id:u.string(),type:u.literal("function"),function:lh,encryptedValue:u.string().optional()}),Fr=u.object({id:u.string(),role:u.string(),content:u.string().optional(),name:u.string().optional(),encryptedValue:u.string().optional()}),uh=u.object({type:u.literal("text"),text:u.string()}),dh=u.object({type:u.literal("data"),value:u.string(),mimeType:u.string()}),ph=u.object({type:u.literal("url"),value:u.string(),mimeType:u.string().optional()}),$r=u.discriminatedUnion("type",[dh,ph]),hh=u.object({type:u.literal("image"),source:$r,metadata:u.unknown().optional()}),fh=u.object({type:u.literal("audio"),source:$r,metadata:u.unknown().optional()}),mh=u.object({type:u.literal("video"),source:$r,metadata:u.unknown().optional()}),gh=u.object({type:u.literal("document"),source:$r,metadata:u.unknown().optional()});var Sl=u.object({type:u.literal("binary"),mimeType:u.string(),id:u.string().optional(),url:u.string().optional(),data:u.string().optional(),filename:u.string().optional()}),_l=(t,e)=>{!t.id&&!t.url&&!t.data&&e.addIssue({code:u.ZodIssueCode.custom,message:"BinaryInputContent requires at least one of id, url, or data.",path:["id"]})},iy=Sl.superRefine((t,e)=>{_l(t,e)}),vh=u.discriminatedUnion("type",[uh,hh,fh,mh,gh,Sl]),bh=vh.superRefine((t,e)=>{t.type==="binary"&&_l(t,e)}),yh=Fr.extend({role:u.literal("developer"),content:u.string()}),xh=Fr.extend({role:u.literal("system"),content:u.string()}),Eh=Fr.extend({role:u.literal("assistant"),content:u.string().optional(),toolCalls:u.array(ch).optional()}),Th=Fr.extend({role:u.literal("user"),content:u.union([u.string(),u.array(bh)])}),wh=u.object({id:u.string(),content:u.string(),role:u.literal("tool"),toolCallId:u.string(),error:u.string().optional(),encryptedValue:u.string().optional()}),Sh=u.object({id:u.string(),role:u.literal("activity"),activityType:u.string(),content:u.record(u.any())}),_h=u.object({id:u.string(),role:u.literal("reasoning"),content:u.string(),encryptedValue:u.string().optional()}),Al=u.discriminatedUnion("role",[yh,xh,Eh,Th,wh,Sh,_h]),sy=u.union([u.literal("developer"),u.literal("system"),u.literal("assistant"),u.literal("user"),u.literal("tool"),u.literal("activity"),u.literal("reasoning")]),Ah=u.object({description:u.string(),value:u.string()}),kl=u.object({name:u.string(),description:u.string(),parameters:u.any(),metadata:u.record(u.any()).optional()}),kh=u.object({id:u.string(),reason:u.string(),message:u.string().optional(),toolCallId:u.string().optional(),responseSchema:u.record(u.any()).optional(),expiresAt:u.string().optional(),metadata:u.record(u.any()).optional()}),Ih=u.object({interruptId:u.string(),status:u.enum(["resolved","cancelled"]),payload:u.any().optional()}),Ch=u.object({threadId:u.string(),runId:u.string(),parentRunId:u.string().optional(),state:u.any(),messages:u.array(Al),tools:u.array(kl),context:u.array(Ah),forwardedProps:u.any(),resume:u.array(Ih).optional()}),Rh=u.any(),ee=class extends Error{constructor(t){super(t)}},Ss=class extends ee{constructor(){super("Connect not implemented. This method is not supported by the current agent.")}},Nh=u.object({name:u.string(),description:u.string().optional()}),Oh=u.object({name:u.string().optional(),type:u.string().optional(),description:u.string().optional(),version:u.string().optional(),provider:u.string().optional(),documentationUrl:u.string().optional(),metadata:u.record(u.unknown()).optional()}),Mh=u.object({streaming:u.boolean().optional(),websocket:u.boolean().optional(),httpBinary:u.boolean().optional(),pushNotifications:u.boolean().optional(),resumable:u.boolean().optional()}),Lh=u.object({supported:u.boolean().optional(),items:u.array(kl).optional(),parallelCalls:u.boolean().optional(),clientProvided:u.boolean().optional()}),Ph=u.object({structuredOutput:u.boolean().optional(),supportedMimeTypes:u.array(u.string()).optional()}),Dh=u.object({snapshots:u.boolean().optional(),deltas:u.boolean().optional(),memory:u.boolean().optional(),persistentState:u.boolean().optional()}),Uh=u.object({supported:u.boolean().optional(),delegation:u.boolean().optional(),handoffs:u.boolean().optional(),subAgents:u.array(Nh).optional()}),Hh=u.object({supported:u.boolean().optional(),streaming:u.boolean().optional(),encrypted:u.boolean().optional()}),Gh=u.object({image:u.boolean().optional(),audio:u.boolean().optional(),video:u.boolean().optional(),pdf:u.boolean().optional(),file:u.boolean().optional()}),zh=u.object({image:u.boolean().optional(),audio:u.boolean().optional()}),Fh=u.object({input:Gh.optional(),output:zh.optional()}),$h=u.object({codeExecution:u.boolean().optional(),sandboxed:u.boolean().optional(),maxIterations:u.number().optional(),maxExecutionTime:u.number().optional()}),Bh=u.object({supported:u.boolean().optional(),approvals:u.boolean().optional(),interventions:u.boolean().optional(),feedback:u.boolean().optional(),interrupts:u.boolean().optional(),approveWithEdits:u.boolean().optional()}),ay=u.object({identity:Oh.optional(),transport:Mh.optional(),tools:Lh.optional(),output:Ph.optional(),state:Dh.optional(),multiAgent:Uh.optional(),reasoning:Hh.optional(),multimodal:Fh.optional(),execution:$h.optional(),humanInTheLoop:Bh.optional(),custom:u.record(u.unknown()).optional()}),Il=u.union([u.literal("developer"),u.literal("system"),u.literal("assistant"),u.literal("user")]),v=(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})({}),X=u.object({type:u.nativeEnum(v),timestamp:u.number().optional(),rawEvent:u.any().optional()}).passthrough(),Vh=X.extend({type:u.literal(v.TEXT_MESSAGE_START),messageId:u.string(),role:Il.default("assistant"),name:u.string().optional()}),Cl=X.extend({type:u.literal(v.TEXT_MESSAGE_CONTENT),messageId:u.string(),delta:u.string()}),jh=X.extend({type:u.literal(v.TEXT_MESSAGE_END),messageId:u.string()}),qh=X.extend({type:u.literal(v.TEXT_MESSAGE_CHUNK),messageId:u.string().optional(),role:Il.optional(),delta:u.string().optional(),name:u.string().optional()}),Wh=X.extend({type:u.literal(v.THINKING_TEXT_MESSAGE_START)}),Xh=Cl.omit({messageId:!0,type:!0}).extend({type:u.literal(v.THINKING_TEXT_MESSAGE_CONTENT)}),Yh=X.extend({type:u.literal(v.THINKING_TEXT_MESSAGE_END)}),Kh=X.extend({type:u.literal(v.TOOL_CALL_START),toolCallId:u.string(),toolCallName:u.string(),parentMessageId:u.string().optional()}),Zh=X.extend({type:u.literal(v.TOOL_CALL_ARGS),toolCallId:u.string(),delta:u.string()}),Jh=X.extend({type:u.literal(v.TOOL_CALL_END),toolCallId:u.string()}),Qh=X.extend({messageId:u.string(),type:u.literal(v.TOOL_CALL_RESULT),toolCallId:u.string(),content:u.string(),role:u.literal("tool").optional()}),ef=X.extend({type:u.literal(v.TOOL_CALL_CHUNK),toolCallId:u.string().optional(),toolCallName:u.string().optional(),parentMessageId:u.string().optional(),delta:u.string().optional()}),tf=X.extend({type:u.literal(v.THINKING_START),title:u.string().optional()}),nf=X.extend({type:u.literal(v.THINKING_END)}),rf=X.extend({type:u.literal(v.STATE_SNAPSHOT),snapshot:Rh}),of=X.extend({type:u.literal(v.STATE_DELTA),delta:u.array(u.any())}),sf=X.extend({type:u.literal(v.MESSAGES_SNAPSHOT),messages:u.array(Al)}),af=X.extend({type:u.literal(v.ACTIVITY_SNAPSHOT),messageId:u.string(),activityType:u.string(),content:u.record(u.any()),replace:u.boolean().optional().default(!0)}),lf=X.extend({type:u.literal(v.ACTIVITY_DELTA),messageId:u.string(),activityType:u.string(),patch:u.array(u.any())}),cf=X.extend({type:u.literal(v.RAW),event:u.any(),source:u.string().optional()}),uf=X.extend({type:u.literal(v.CUSTOM),name:u.string(),value:u.any()}),df=X.extend({type:u.literal(v.RUN_STARTED),threadId:u.string(),runId:u.string(),parentRunId:u.string().optional(),input:Ch.optional()}),pf=u.object({type:u.literal("success")}).strict(),hf=u.object({type:u.literal("interrupt"),interrupts:u.array(kh).min(1)}).strict(),ff=u.discriminatedUnion("type",[pf,hf]),mf=X.extend({type:u.literal(v.RUN_FINISHED),threadId:u.string(),runId:u.string(),result:u.any().optional(),outcome:ff.nullable().optional().transform(t=>t??void 0)}),gf=X.extend({type:u.literal(v.RUN_ERROR),message:u.string(),code:u.string().optional()}),vf=X.extend({type:u.literal(v.STEP_STARTED),stepName:u.string()}),bf=X.extend({type:u.literal(v.STEP_FINISHED),stepName:u.string()}),yf=u.union([u.literal("tool-call"),u.literal("message")]),xf=X.extend({type:u.literal(v.REASONING_START),messageId:u.string()}),Ef=X.extend({type:u.literal(v.REASONING_MESSAGE_START),messageId:u.string(),role:u.literal("reasoning")}),Tf=X.extend({type:u.literal(v.REASONING_MESSAGE_CONTENT),messageId:u.string(),delta:u.string()}),wf=X.extend({type:u.literal(v.REASONING_MESSAGE_END),messageId:u.string()}),Sf=X.extend({type:u.literal(v.REASONING_MESSAGE_CHUNK),messageId:u.string().optional(),delta:u.string().optional()}),_f=X.extend({type:u.literal(v.REASONING_END),messageId:u.string()}),Af=X.extend({type:u.literal(v.REASONING_ENCRYPTED_VALUE),subtype:yf,entityId:u.string(),encryptedValue:u.string()}),Br=u.discriminatedUnion("type",[Vh,Cl,jh,qh,tf,nf,Wh,Xh,Yh,Kh,Zh,Jh,ef,Qh,rf,of,sf,af,lf,cf,uf,df,mf,gf,vf,bf,xf,Ef,Tf,wf,Sf,_f,Af]);var _s={};$i(_s,{JsonPatchError:()=>he,_areEquals:()=>Kn,applyOperation:()=>Wt,applyPatch:()=>Kr,applyReducer:()=>Nf,deepClone:()=>Cf,getValueByPointer:()=>Xr,validate:()=>Nl,validator:()=>Yr});var kf=(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)}})(),If=Object.prototype.hasOwnProperty;function jr(t,e){return If.call(t,e)}function qr(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)jr(t,o)&&r.push(o);return r}function Te(t){switch(typeof t){case"object":return JSON.parse(JSON.stringify(t));case"undefined":return null;default:return t}}function Wr(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 rt(t){return t.indexOf("/")===-1&&t.indexOf("~")===-1?t:t.replace(/~/g,"~0").replace(/\//g,"~1")}function Xn(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function Vr(t){if(t===void 0)return!0;if(t){if(Array.isArray(t)){for(var e=0,n=t.length;e<n;e++)if(Vr(t[e]))return!0}else if(typeof t=="object"){for(var r=qr(t),o=r.length,i=0;i<o;i++)if(Vr(t[r[i]]))return!0}}return!1}function Rl(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 Yn=(function(t){kf(e,t);function e(n,r,o,i,s){var a=this.constructor,l=t.call(this,Rl(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=Rl(n,{name:r,index:o,operation:i,tree:s}),l}return e})(Error);var he=Yn,Cf=Te,xn={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=Xr(n,this.path);r&&(r=Te(r));var o=Wt(n,{op:"remove",path:this.from}).removed;return Wt(n,{op:"add",path:this.path,value:o}),{newDocument:n,removed:r}},copy:function(t,e,n){var r=Xr(n,this.from);return Wt(n,{op:"add",path:this.path,value:Te(r)}),{newDocument:n}},test:function(t,e,n){return{newDocument:n,test:Kn(t[e],this.value)}},_get:function(t,e,n){return this.value=t[e],{newDocument:n}}},Rf={add:function(t,e,n){return Wr(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:xn.move,copy:xn.copy,test:xn.test,_get:xn._get};function Xr(t,e){if(e=="")return t;var n={op:"_get",path:e};return Wt(t,n),n.value}function Wt(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):Yr(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=Xr(t,e.from),e.op==="move"&&(s.removed=t),s;if(e.op==="test"){if(s.test=Kn(t,e.value),s.test===!1)throw new he("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 he("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",i,e,t);return s}}else{r||(t=Te(t));var a=e.path||"",l=a.split("/"),c=t,h=1,m=l.length,y=void 0,f=void 0,p=void 0;for(typeof n=="function"?p=n:p=Yr;;){if(f=l[h],f&&f.indexOf("~")!=-1&&(f=Xn(f)),o&&(f=="__proto__"||f=="prototype"&&h>0&&l[h-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&&y===void 0&&(c[f]===void 0?y=l.slice(0,h).join("/"):h==m-1&&(y=e.path),y!==void 0&&p(e,0,t,y)),h++,Array.isArray(c)){if(f==="-")f=c.length;else{if(n&&!Wr(f))throw new he("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);Wr(f)&&(f=~~f)}if(h>=m){if(n&&e.op==="add"&&f>c.length)throw new he("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=Rf[e.op].call(e,c,f,t);if(s.test===!1)throw new he("Test operation failed","TEST_OPERATION_FAILED",i,e,t);return s}}else if(h>=m){var s=xn[e.op].call(e,c,f,t);if(s.test===!1)throw new he("Test operation failed","TEST_OPERATION_FAILED",i,e,t);return s}if(c=c[f],n&&h<m&&(!c||typeof c!="object"))throw new he("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",i,e,t)}}}function Kr(t,e,n,r,o){if(r===void 0&&(r=!0),o===void 0&&(o=!0),n&&!Array.isArray(e))throw new he("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");r||(t=Te(t));for(var i=new Array(e.length),s=0,a=e.length;s<a;s++)i[s]=Wt(t,e[s],n,!0,o,s),t=i[s].newDocument;return i.newDocument=t,i}function Nf(t,e,n){var r=Wt(t,e);if(r.test===!1)throw new he("Test operation failed","TEST_OPERATION_FAILED",n,e,t);return r.newDocument}function Yr(t,e,n,r){if(typeof t!="object"||t===null||Array.isArray(t))throw new he("Operation is not an object","OPERATION_NOT_AN_OBJECT",e,t,n);if(xn[t.op]){if(typeof t.path!="string")throw new he("Operation `path` property is not a string","OPERATION_PATH_INVALID",e,t,n);if(t.path.indexOf("/")!==0&&t.path.length>0)throw new he('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 he("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 he("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")&&Vr(t.value))throw new he("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 he("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 he("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=Nl([s],n);if(a&&a.name==="OPERATION_PATH_UNRESOLVABLE")throw new he("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",e,t,n)}}}else throw new he("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",e,t,n)}function Nl(t,e,n){try{if(!Array.isArray(t))throw new he("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(e)Kr(Te(e),Te(t),n||!0);else{n=n||Yr;for(var r=0;r<t.length;r++)n(t[r],r,e,void 0)}}catch(o){if(o instanceof he)return o;throw o}}function Kn(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(!Kn(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],!Kn(t[s],e[s]))return!1;return!0}return t!==t&&e!==e}var Cs={};$i(Cs,{compare:()=>Gf,generate:()=>As,observe:()=>Hf,unobserve:()=>Uf});var ks=new WeakMap,Of=(function(){function t(e){this.observers=new Map,this.obj=e}return t})(),Mf=(function(){function t(e,n){this.callback=e,this.observer=n}return t})();function Lf(t){return ks.get(t)}function Pf(t,e){return t.observers.get(e)}function Df(t,e){t.observers.delete(e.callback)}function Uf(t,e){e.unobserve()}function Hf(t,e){var n=[],r,o=Lf(t);if(!o)o=new Of(t),ks.set(t,o);else{var i=Pf(o,e);r=i&&i.observer}if(r)return r;if(r={},o.value=Te(t),e){r.callback=e,r.next=null;var s=function(){As(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(){As(r),clearTimeout(r.next),Df(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 Mf(e,r)),r}function As(t,e){e===void 0&&(e=!1);var n=ks.get(t.object);Is(n.value,t.object,t.patches,"",e),t.patches.length&&Kr(n.value,t.patches);var r=t.patches;return r.length>0&&(t.patches=[],t.callback&&t.callback(r)),r}function Is(t,e,n,r,o){if(e!==t){typeof e.toJSON=="function"&&(e=e.toJSON());for(var i=qr(e),s=qr(t),a=!1,l=!1,c=s.length-1;c>=0;c--){var h=s[c],m=t[h];if(jr(e,h)&&!(e[h]===void 0&&m!==void 0&&Array.isArray(e)===!1)){var y=e[h];typeof m=="object"&&m!=null&&typeof y=="object"&&y!=null&&Array.isArray(m)===Array.isArray(y)?Is(m,y,n,r+"/"+rt(h),o):m!==y&&(a=!0,o&&n.push({op:"test",path:r+"/"+rt(h),value:Te(m)}),n.push({op:"replace",path:r+"/"+rt(h),value:Te(y)}))}else Array.isArray(t)===Array.isArray(e)?(o&&n.push({op:"test",path:r+"/"+rt(h),value:Te(m)}),n.push({op:"remove",path:r+"/"+rt(h)}),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 c=0;c<i.length;c++){var h=i[c];!jr(t,h)&&e[h]!==void 0&&n.push({op:"add",path:r+"/"+rt(h),value:Te(e[h])})}}}function Gf(t,e,n){n===void 0&&(n=!1);var r=[];return Is(t,e,r,"",n),r}var Zr=Object.assign({},_s,Cs,{JsonPatchError:Yn,deepClone:Te,escapePathComponent:rt,unescapePathComponent:Xn});var Rs=function(t,e){return Rs=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])},Rs(t,e)};function ot(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Rs(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function Ol(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(h){try{c(r.next(h))}catch(m){s(m)}}function l(h){try{c(r.throw(h))}catch(m){s(m)}}function c(h){h.done?i(h.value):o(h.value).then(a,l)}c((r=r.apply(t,e||[])).next())})}function Jr(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(c){return function(h){return l([c,h])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(n=0)),n;)try{if(r=1,o&&(i=c[0]&2?o.return:c[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,c[1])).done)return i;switch(o=0,i&&(c=[c[0]&2,i.value]),c[0]){case 0:case 1:i=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,o=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){n.label=c[1];break}if(c[0]===6&&n.label<i[1]){n.label=i[1],i=c;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(c);break}i[2]&&n.ops.pop(),n.trys.pop();continue}c=e.call(t,n)}catch(h){c=[6,h],o=0}finally{r=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function pt(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 En(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 Tn(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 Xt(t){return this instanceof Xt?(this.v=t,this):new Xt(t)}function Ml(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(f){return function(p){return Promise.resolve(p).then(f,m)}}function a(f,p){r[f]&&(o[f]=function(g){return new Promise(function(x,_){i.push([f,g,x,_])>1||l(f,g)})},p&&(o[f]=p(o[f])))}function l(f,p){try{c(r[f](p))}catch(g){y(i[0][3],g)}}function c(f){f.value instanceof Xt?Promise.resolve(f.value.v).then(h,m):y(i[0][2],f)}function h(f){l("next",f)}function m(f){l("throw",f)}function y(f,p){f(p),i.shift(),i.length&&l(i[0][0],i[0][1])}}function Ll(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 pt=="function"?pt(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(c){i({value:c,done:a})},s)}}function B(t){return typeof t=="function"}function wn(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 Qr=wn(function(t){return function(n){t(this),this.message=n?n.length+` errors occurred during unsubscription:
|
|
1
|
+
var Fd=Object.defineProperty;var ji=(t,e)=>{for(var n in e)Fd(t,n,{get:e[n],enumerable:!0})};var Or="ag-ui-chat",qi="ag-ui-submit",Wi="ag-ui-toggle",Xi="ag-ui-unread",Yi="ag-ui-state",Ki="ag-ui-attachments",je={USER:"user",ASSISTANT:"assistant"},Fn="x-destructive",Zi="x-confirm",Le="x-summary",$n="x-navigates",Ji="read_page",Qi=10,pe={PENDING:"pending",DONE:"done",ERROR:"error",DECLINED:"declined"},Pe={UPLOADING:"uploading",READY:"ready",ERROR:"error"},es=10*1024*1024,pn={INLINE:"inline",MINIMAL:"minimal",COMPACT:"compact",FULL:"full"},ts="compaction",ns="load_capability",hl='<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>',fl='<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>',ml='<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>',gl='<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>',vl='<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>';var $d=/\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g;function bl(t,e){let n=[];return{text:t.replace($d,(o,i)=>{let s=e[i];return s==null||s===""?(n.includes(i)||n.push(i),o):String(s)}),missing:n}}function Bd(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 rs(t){return Array.isArray(t)?t.filter(Bd):[]}var Bn=class{#n=new Map;register(e){this.#n.set(e.name,e)}has(e){return this.#n.has(e)}get(e){let n=this.#n.get(e);if(n===void 0)throw new Error(`tool "${e}" is not registered`);return n}tools(){return[...this.#n.values()].map(e=>({name:e.name,description:e.description,parameters:e.parameters}))}};function os(t){return t[Fn]===!0}function Mr(t){return t[$n]===!0}function Lr(t,e){return Object.getOwnPropertyDescriptor(t,e).set}var Vd=Lr(HTMLInputElement.prototype,"value"),jd=Lr(HTMLTextAreaElement.prototype,"value"),qd=Lr(HTMLSelectElement.prototype,"value"),Wd=Lr(HTMLInputElement.prototype,"checked");function Nt(t,e){t instanceof HTMLTextAreaElement?jd.call(t,e):t instanceof HTMLSelectElement?qd.call(t,e):Vd.call(t,e)}function Vn(t,e){Wd.call(t,e)}var is="#4f46e5",Xd="rgba(79, 70, 229, 0.4)",Yd="--ag-ui-accent";function jn(t){return new Promise(e=>{setTimeout(e,t)})}function Pr(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}function ss(t){return t<=0||Pr()?Promise.resolve():jn(t)}function Dr(t,e){let n=window.getComputedStyle(t).getPropertyValue(Yd).trim();return n===""?e:n}function yl(t){return`0 0 0 3px ${Dr(t,Xd)}`}async function as(t,e,n={}){let r=n.charDelayMs??35;Nt(t,""),t.dispatchEvent(new Event("input",{bubbles:!0}));for(let o of e)Nt(t,t.value+o),t.dispatchEvent(new Event("input",{bubbles:!0})),r>0&&await jn(r);t.dispatchEvent(new Event("change",{bubbles:!0}))}async function ls(t,e={}){let n=e.highlightMs??280,r=t.style.outline,o=t.style.outlineOffset;t.style.outline=`2px solid ${Dr(t,is)}`,t.style.outlineOffset="2px",await jn(n),t.style.outline=r,t.style.outlineOffset=o,t.click()}var Kd=600,Zd=100;function lt(t,e={}){let n=Pr();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??Kd)};o=setTimeout(i,Zd),document.addEventListener("scroll",s,!0),document.addEventListener("scrollend",i,!0)})}var Jd=1200,Qd=1/3;async function xl(t,e,n){(e.focus??n)&&t.focus({preventScroll:!0});let r=e.flashMs??Jd;if(r<=0)return;let o=t.style.outline,i=t.style.outlineOffset,s=t.style.transition,a=e.color??Dr(t,is);t.style.outline=`3px solid ${a}`,t.style.outlineOffset="2px";let l=Pr()?0:Math.round(r*Qd);await jn(r-l),l>0&&(t.style.transition=`outline-color ${l}ms ease-out`,t.style.outline="3px solid transparent",await jn(l)),t.style.outline=o,t.style.outlineOffset=i,t.style.transition=s}function ep(t,e={}){return xl(t,e,!1)}function cs(t,e={}){return xl(t,e,!0)}async function us(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=yl(t),await ss(n),t.style.transform=r,t.style.transition=o,t.style.boxShadow=i,t.click()}function tp(t,e){for(let n of Array.from(t.options))if(n.value===e||n.text===e)return n;return null}async function ds(t,e,n={}){let r=tp(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 ${Dr(t,is)}`,t.style.outlineOffset="2px",await ss(o),Nt(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 ps(t,e,n={}){let r=n.flashMs??200,o=t.style.boxShadow;t.style.boxShadow=yl(t),await ss(r),Vn(t,e),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})),t.style.boxShadow=o}var hs={SCROLL:"scroll",DRAG:"drag"};function fs(t,e){let n=[];return t.has(hs.SCROLL)&&n.push(np(e)),t.has(hs.DRAG)&&n.push(rp(e)),n}function np(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"],[Le]:"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 lt(r),{scrolled:!0,target:n}}}}function rp(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"],[Le]:"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 op(o,i),{dragged:!0,from:n,to:r}}}}function op(t,e){let n=new DataTransfer;qn(t,"dragstart",n),qn(e,"dragenter",n),qn(e,"dragover",n),qn(e,"drop",n),qn(t,"dragend",n)}function qn(t,e,n){let r=new Event(e,{bubbles:!0,cancelable:!0});r.dataTransfer=n,t.dispatchEvent(r)}function ms(t,e){return!e||t===null?[]:[{description:"page_map",value:JSON.stringify(t())}]}function Ur(t){let e=[{name:`read_${t.name}`,description:`Read the "${t.name}" state.`,parameters:{type:"object",properties:{},required:[],[Le]:`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"},[Fn]:!0,[Le]:`Update ${t.name}`},handler:r=>n(r)}),e}var ip=Ur;function gs(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;typeof o=="string"&&typeof i=="string"&&(e[o]=i)}return e}var _l=/:([A-Za-z_][A-Za-z0-9_]*)/g;function sp(t){return[...t.matchAll(_l)].map(e=>e[0].slice(1))}function ap(t,e,n){let r={...n};return{path:e.replace(_l,(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 lp(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 vs(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:[],[Le]:"List pages"},handler:()=>t().map(n=>({...n,pathParams:sp(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"],[$n]:!0,[Le]:"Navigate"},handler:n=>{let r=n.route_id,o=t().find(h=>h.id===r);if(o===void 0)throw new Error(`unknown route "${String(r)}"`);let i=n.params??{},{path:s,leftover:a}=ap(o.id,o.path,i),l=lp(s,a),c=e();return c!==null?c(l):window.location.assign(l),{navigated:!0,path:l}}}]}var ae={title:"Assistant",chatHistory:"Chat history",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",conversation:"Conversation",thinking:"Assistant is thinking\u2026",thoughts:"Thoughts",stopped:"\u23F9 Stopped",connectionLost:"Connection lost",noResult:"No result returned.",declinedAction:"User declined the action.",navigating:"Navigating\u2026",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.",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",toolRunning:"running\u2026",toolDone:"\u2713 done",toolError:"\u26A0 error",toolDeclined:"\u2298 declined",resizePanel:"Resize the chat panel",decisionApproved:"approved by you",decisionDeclined:"declined by you",argumentsLabel:"Arguments",resultLabel:"Result",errorLabel:"Error",declinedLabel:"Declined",details:"Details",confirmAction:"Confirm action",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 bs(t){let e={...ae};for(let n of Object.keys(t)){let r=t[n];r!==void 0&&(e[n]=r)}return e}function El(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 ys(t,e,n={}){let r=n.strings??ae;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=document.createElement("div");a.className="approval-actions",a.setAttribute("part","approval-actions");let l=El("deny",r.deny),c=El("approve",r.approve),h=!1,m=y=>{h||(h=!0,l.disabled=!0,c.disabled=!0,i.setAttribute("data-resolved",y?"approved":"denied"),o(y))};if(l.addEventListener("click",()=>m(!1)),c.addEventListener("click",()=>m(!0)),n.signal?.addEventListener("abort",()=>m(!1),{once:!0}),a.append(l,c),i.append(s,a),t.appendChild(i),n.signal?.aborted===!0){m(!1);return}c.focus()})}function xs(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(cp(r,e)))}}function cp(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",()=>{up(n).then(o=>{dp(r,o?e.copied:e.copyFailed,e)})}),r}async function up(t){let e=navigator.clipboard;if(e===void 0)return!1;try{return await e.writeText(t),!0}catch{return!1}}function dp(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 _s(t){let e=document.createElement("div");e.className="attachment-chips",e.setAttribute("part","attachment-chips");for(let n of t)e.appendChild(pp(n));return e}function pp(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.textContent=Es(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=Hr(t.size),e.append(n,r,o),e}function Es(t){return t.startsWith("image/")?"\u{1F5BC}":t==="application/pdf"?"\u{1F4D5}":t.startsWith("text/")?"\u{1F4C4}":"\u{1F4CE}"}function Hr(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 xe=[];for(let t=0;t<256;++t)xe.push((t+256).toString(16).slice(1));function Tl(t,e=0){return(xe[t[e+0]]+xe[t[e+1]]+xe[t[e+2]]+xe[t[e+3]]+"-"+xe[t[e+4]]+xe[t[e+5]]+"-"+xe[t[e+6]]+xe[t[e+7]]+"-"+xe[t[e+8]]+xe[t[e+9]]+"-"+xe[t[e+10]]+xe[t[e+11]]+xe[t[e+12]]+xe[t[e+13]]+xe[t[e+14]]+xe[t[e+15]]).toLowerCase()}var Ts,hp=new Uint8Array(16);function ws(){if(!Ts){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ts=crypto.getRandomValues.bind(crypto)}return Ts(hp)}var fp=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ss={randomUUID:fp};function mp(t,e,n){if(Ss.randomUUID&&!e&&!t)return Ss.randomUUID();t=t||{};let r=t.random??t.rng?.()??ws();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 Tl(r)}var xt=mp;var u={};ji(u,{BRAND:()=>Fp,DIRTY:()=>Ot,EMPTY_PATH:()=>yp,INVALID:()=>P,NEVER:()=>Sh,OK:()=>Se,ParseStatus:()=>_e,Schema:()=>$,ZodAny:()=>Tt,ZodArray:()=>pt,ZodBigInt:()=>Lt,ZodBoolean:()=>Pt,ZodBranded:()=>Xn,ZodCatch:()=>qt,ZodDate:()=>Dt,ZodDefault:()=>jt,ZodDiscriminatedUnion:()=>Fr,ZodEffects:()=>Fe,ZodEnum:()=>Bt,ZodError:()=>Ne,ZodFirstPartyTypeKind:()=>D,ZodFunction:()=>Br,ZodIntersection:()=>Gt,ZodIssueCode:()=>E,ZodLazy:()=>Ft,ZodLiteral:()=>$t,ZodMap:()=>bn,ZodNaN:()=>xn,ZodNativeEnum:()=>Vt,ZodNever:()=>qe,ZodNull:()=>Ht,ZodNullable:()=>rt,ZodNumber:()=>Mt,ZodObject:()=>Oe,ZodOptional:()=>ze,ZodParsedType:()=>C,ZodPipeline:()=>Yn,ZodPromise:()=>wt,ZodReadonly:()=>Wt,ZodRecord:()=>$r,ZodSchema:()=>$,ZodSet:()=>yn,ZodString:()=>Et,ZodSymbol:()=>gn,ZodTransformer:()=>Fe,ZodTuple:()=>nt,ZodType:()=>$,ZodUndefined:()=>Ut,ZodUnion:()=>zt,ZodUnknown:()=>dt,ZodVoid:()=>vn,addIssueToContext:()=>k,any:()=>Kp,array:()=>eh,bigint:()=>jp,boolean:()=>Ll,coerce:()=>wh,custom:()=>Nl,date:()=>qp,datetimeRegex:()=>Il,defaultErrorMap:()=>ct,discriminatedUnion:()=>oh,effect:()=>gh,enum:()=>hh,function:()=>uh,getErrorMap:()=>hn,getParsedType:()=>tt,instanceof:()=>Bp,intersection:()=>ih,isAborted:()=>zr,isAsync:()=>fn,isDirty:()=>Gr,isValid:()=>_t,late:()=>$p,lazy:()=>dh,literal:()=>ph,makeIssue:()=>Wn,map:()=>lh,nan:()=>Vp,nativeEnum:()=>fh,never:()=>Jp,null:()=>Yp,nullable:()=>bh,number:()=>Ml,object:()=>th,objectUtil:()=>As,oboolean:()=>Th,onumber:()=>Eh,optional:()=>vh,ostring:()=>_h,pipeline:()=>xh,preprocess:()=>yh,promise:()=>mh,quotelessJson:()=>gp,record:()=>ah,set:()=>ch,setErrorMap:()=>bp,strictObject:()=>nh,string:()=>Ol,symbol:()=>Wp,transformer:()=>gh,tuple:()=>sh,undefined:()=>Xp,union:()=>rh,unknown:()=>Zp,util:()=>V,void:()=>Qp});var V;(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})(V||(V={}));var As;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(As||(As={}));var C=V.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),tt=t=>{switch(typeof t){case"undefined":return C.undefined;case"string":return C.string;case"number":return Number.isNaN(t)?C.nan:C.number;case"boolean":return C.boolean;case"function":return C.function;case"bigint":return C.bigint;case"symbol":return C.symbol;case"object":return Array.isArray(t)?C.array:t===null?C.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?C.promise:typeof Map<"u"&&t instanceof Map?C.map:typeof Set<"u"&&t instanceof Set?C.set:typeof Date<"u"&&t instanceof Date?C.date:C.object;default:return C.unknown}};var E=V.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"]),gp=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Ne=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 c=s.path[l];l===s.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(s))):a[c]=a[c]||{_errors:[]},a=a[c],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,V.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()}};Ne.create=t=>new Ne(t);var vp=(t,e)=>{let n;switch(t.code){case E.invalid_type:t.received===C.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case E.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,V.jsonStringifyReplacer)}`;break;case E.unrecognized_keys:n=`Unrecognized key(s) in object: ${V.joinValues(t.keys,", ")}`;break;case E.invalid_union:n="Invalid input";break;case E.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${V.joinValues(t.options)}`;break;case E.invalid_enum_value:n=`Invalid enum value. Expected ${V.joinValues(t.options)}, received '${t.received}'`;break;case E.invalid_arguments:n="Invalid function arguments";break;case E.invalid_return_type:n="Invalid function return type";break;case E.invalid_date:n="Invalid date";break;case E.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}"`:V.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case E.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 E.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 E.custom:n="Invalid input";break;case E.invalid_intersection_types:n="Intersection results could not be merged";break;case E.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case E.not_finite:n="Number must be finite";break;default:n=e.defaultError,V.assertNever(t)}return{message:n}},ct=vp;var wl=ct;function bp(t){wl=t}function hn(){return wl}var Wn=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(c=>!!c).slice().reverse();for(let c of l)a=c(s,{data:e,defaultError:a}).message;return{...o,path:i,message:a}},yp=[];function k(t,e){let n=hn(),r=Wn({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===ct?void 0:ct].filter(o=>!!o)});t.common.issues.push(r)}var _e=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 P;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 P;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}}},P=Object.freeze({status:"aborted"}),Ot=t=>({status:"dirty",value:t}),Se=t=>({status:"valid",value:t}),zr=t=>t.status==="aborted",Gr=t=>t.status==="dirty",_t=t=>t.status==="valid",fn=t=>typeof Promise<"u"&&t instanceof Promise;var R;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(R||(R={}));var Ge=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}},Sl=(t,e)=>{if(_t(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 Ne(t.common.issues);return this._error=n,this._error}}};function G(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 $=class{get description(){return this._def.description}_getType(e){return tt(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:tt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new _e,ctx:{common:e.parent.common,data:e.data,parsedType:tt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(fn(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:tt(e)},o=this._parseSync({data:e,path:r.path,parent:r});return Sl(r,o)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:tt(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return _t(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=>_t(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:tt(e)},o=this._parse({data:e,path:r.path,parent:r}),i=await(fn(o)?o:Promise.resolve(o));return Sl(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:E.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 Fe({schema:this,typeName:D.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 ze.create(this,this._def)}nullable(){return rt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return pt.create(this)}promise(){return wt.create(this,this._def)}or(e){return zt.create([this,e],this._def)}and(e){return Gt.create(this,e,this._def)}transform(e){return new Fe({...G(this._def),schema:this,typeName:D.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new jt({...G(this._def),innerType:this,defaultValue:n,typeName:D.ZodDefault})}brand(){return new Xn({typeName:D.ZodBranded,type:this,...G(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new qt({...G(this._def),innerType:this,catchValue:n,typeName:D.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Yn.create(this,e)}readonly(){return Wt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},xp=/^c[^\s-]{8,}$/i,_p=/^[0-9a-z]+$/,Ep=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Tp=/^[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,wp=/^[a-z0-9_-]{21}$/i,Sp=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ap=/^[-+]?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)?)??$/,kp=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Cp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ks,Ip=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Rp=/^(?:(?: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])$/,Np=/^(([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]))$/,Op=/^(([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])$/,Mp=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Lp=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,kl="((\\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])))",Pp=new RegExp(`^${kl}$`);function Cl(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 Dp(t){return new RegExp(`^${Cl(t)}$`)}function Il(t){let e=`${kl}T${Cl(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 Up(t,e){return!!((e==="v4"||!e)&&Ip.test(t)||(e==="v6"||!e)&&Np.test(t))}function Hp(t,e){if(!Sp.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 zp(t,e){return!!((e==="v4"||!e)&&Rp.test(t)||(e==="v6"||!e)&&Op.test(t))}var Et=class t extends ${_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==C.string){let i=this._getOrReturnCtx(e);return k(i,{code:E.invalid_type,expected:C.string,received:i.parsedType}),P}let r=new _e,o;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(o=this._getOrReturnCtx(e,o),k(o,{code:E.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),k(o,{code:E.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?k(o,{code:E.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&k(o,{code:E.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")kp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"email",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")ks||(ks=new RegExp(Cp,"u")),ks.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"emoji",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")Tp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"uuid",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")wp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"nanoid",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")xp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"cuid",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")_p.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"cuid2",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")Ep.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"ulid",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),k(o,{validation:"url",code:E.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),k(o,{validation:"regex",code:E.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),k(o,{code:E.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),k(o,{code:E.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(o=this._getOrReturnCtx(e,o),k(o,{code:E.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?Il(i).test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{code:E.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Pp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{code:E.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Dp(i).test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{code:E.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Ap.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"duration",code:E.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Up(e.data,i.version)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"ip",code:E.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?Hp(e.data,i.alg)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"jwt",code:E.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?zp(e.data,i.version)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"cidr",code:E.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?Mp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"base64",code:E.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Lp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"base64url",code:E.invalid_string,message:i.message}),r.dirty()):V.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(o=>e.test(o),{validation:n,code:E.invalid_string,...R.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...R.errToObj(e)})}url(e){return this._addCheck({kind:"url",...R.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...R.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...R.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...R.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...R.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...R.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...R.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...R.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...R.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...R.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...R.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...R.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,...R.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,...R.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...R.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...R.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...R.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...R.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...R.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...R.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...R.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...R.errToObj(n)})}nonempty(e){return this.min(1,R.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}};Et.create=t=>new Et({checks:[],typeName:D.ZodString,coerce:t?.coerce??!1,...G(t)});function Gp(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 Mt=class t extends ${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)!==C.number){let i=this._getOrReturnCtx(e);return k(i,{code:E.invalid_type,expected:C.number,received:i.parsedType}),P}let r,o=new _e;for(let i of this._def.checks)i.kind==="int"?V.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),k(r,{code:E.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),k(r,{code:E.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),k(r,{code:E.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="multipleOf"?Gp(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),k(r,{code:E.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),k(r,{code:E.not_finite,message:i.message}),o.dirty()):V.assertNever(i);return{status:o.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,R.toString(n))}gt(e,n){return this.setLimit("min",e,!1,R.toString(n))}lte(e,n){return this.setLimit("max",e,!0,R.toString(n))}lt(e,n){return this.setLimit("max",e,!1,R.toString(n))}setLimit(e,n,r,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:R.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:R.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:R.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:R.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:R.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:R.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:R.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:R.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:R.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:R.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"&&V.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)}};Mt.create=t=>new Mt({checks:[],typeName:D.ZodNumber,coerce:t?.coerce||!1,...G(t)});var Lt=class t extends ${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)!==C.bigint)return this._getInvalidInput(e);let r,o=new _e;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),k(r,{code:E.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),k(r,{code:E.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),k(r,{code:E.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):V.assertNever(i);return{status:o.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return k(n,{code:E.invalid_type,expected:C.bigint,received:n.parsedType}),P}gte(e,n){return this.setLimit("min",e,!0,R.toString(n))}gt(e,n){return this.setLimit("min",e,!1,R.toString(n))}lte(e,n){return this.setLimit("max",e,!0,R.toString(n))}lt(e,n){return this.setLimit("max",e,!1,R.toString(n))}setLimit(e,n,r,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:R.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:R.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:R.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:R.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:R.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:R.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}};Lt.create=t=>new Lt({checks:[],typeName:D.ZodBigInt,coerce:t?.coerce??!1,...G(t)});var Pt=class extends ${_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==C.boolean){let r=this._getOrReturnCtx(e);return k(r,{code:E.invalid_type,expected:C.boolean,received:r.parsedType}),P}return Se(e.data)}};Pt.create=t=>new Pt({typeName:D.ZodBoolean,coerce:t?.coerce||!1,...G(t)});var Dt=class t extends ${_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==C.date){let i=this._getOrReturnCtx(e);return k(i,{code:E.invalid_type,expected:C.date,received:i.parsedType}),P}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return k(i,{code:E.invalid_date}),P}let r=new _e,o;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(o=this._getOrReturnCtx(e,o),k(o,{code:E.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),k(o,{code:E.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):V.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:R.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:R.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}};Dt.create=t=>new Dt({checks:[],coerce:t?.coerce||!1,typeName:D.ZodDate,...G(t)});var gn=class extends ${_parse(e){if(this._getType(e)!==C.symbol){let r=this._getOrReturnCtx(e);return k(r,{code:E.invalid_type,expected:C.symbol,received:r.parsedType}),P}return Se(e.data)}};gn.create=t=>new gn({typeName:D.ZodSymbol,...G(t)});var Ut=class extends ${_parse(e){if(this._getType(e)!==C.undefined){let r=this._getOrReturnCtx(e);return k(r,{code:E.invalid_type,expected:C.undefined,received:r.parsedType}),P}return Se(e.data)}};Ut.create=t=>new Ut({typeName:D.ZodUndefined,...G(t)});var Ht=class extends ${_parse(e){if(this._getType(e)!==C.null){let r=this._getOrReturnCtx(e);return k(r,{code:E.invalid_type,expected:C.null,received:r.parsedType}),P}return Se(e.data)}};Ht.create=t=>new Ht({typeName:D.ZodNull,...G(t)});var Tt=class extends ${constructor(){super(...arguments),this._any=!0}_parse(e){return Se(e.data)}};Tt.create=t=>new Tt({typeName:D.ZodAny,...G(t)});var dt=class extends ${constructor(){super(...arguments),this._unknown=!0}_parse(e){return Se(e.data)}};dt.create=t=>new dt({typeName:D.ZodUnknown,...G(t)});var qe=class extends ${_parse(e){let n=this._getOrReturnCtx(e);return k(n,{code:E.invalid_type,expected:C.never,received:n.parsedType}),P}};qe.create=t=>new qe({typeName:D.ZodNever,...G(t)});var vn=class extends ${_parse(e){if(this._getType(e)!==C.undefined){let r=this._getOrReturnCtx(e);return k(r,{code:E.invalid_type,expected:C.void,received:r.parsedType}),P}return Se(e.data)}};vn.create=t=>new vn({typeName:D.ZodVoid,...G(t)});var pt=class t extends ${_parse(e){let{ctx:n,status:r}=this._processInputParams(e),o=this._def;if(n.parsedType!==C.array)return k(n,{code:E.invalid_type,expected:C.array,received:n.parsedType}),P;if(o.exactLength!==null){let s=n.data.length>o.exactLength.value,a=n.data.length<o.exactLength.value;(s||a)&&(k(n,{code:s?E.too_big:E.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&&(k(n,{code:E.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&&(k(n,{code:E.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 Ge(n,s,n.path,a)))).then(s=>_e.mergeArray(r,s));let i=[...n.data].map((s,a)=>o.type._parseSync(new Ge(n,s,n.path,a)));return _e.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:R.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:R.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:R.toString(n)}})}nonempty(e){return this.min(1,e)}};pt.create=(t,e)=>new pt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:D.ZodArray,...G(e)});function mn(t){if(t instanceof Oe){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=ze.create(mn(r))}return new Oe({...t._def,shape:()=>e})}else return t instanceof pt?new pt({...t._def,type:mn(t.element)}):t instanceof ze?ze.create(mn(t.unwrap())):t instanceof rt?rt.create(mn(t.unwrap())):t instanceof nt?nt.create(t.items.map(e=>mn(e))):t}var Oe=class t extends ${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=V.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==C.object){let c=this._getOrReturnCtx(e);return k(c,{code:E.invalid_type,expected:C.object,received:c.parsedType}),P}let{status:r,ctx:o}=this._processInputParams(e),{shape:i,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof qe&&this._def.unknownKeys==="strip"))for(let c in o.data)s.includes(c)||a.push(c);let l=[];for(let c of s){let h=i[c],m=o.data[c];l.push({key:{status:"valid",value:c},value:h._parse(new Ge(o,m,o.path,c)),alwaysSet:c in o.data})}if(this._def.catchall instanceof qe){let c=this._def.unknownKeys;if(c==="passthrough")for(let h of a)l.push({key:{status:"valid",value:h},value:{status:"valid",value:o.data[h]}});else if(c==="strict")a.length>0&&(k(o,{code:E.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let h of a){let m=o.data[h];l.push({key:{status:"valid",value:h},value:c._parse(new Ge(o,m,o.path,h)),alwaysSet:h in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let c=[];for(let h of l){let m=await h.key,y=await h.value;c.push({key:m,value:y,alwaysSet:h.alwaysSet})}return c}).then(c=>_e.mergeObjectSync(r,c)):_e.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return R.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:R.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:D.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 V.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 V.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return mn(this)}partial(e){let n={};for(let r of V.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 V.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof ze;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return Rl(V.objectKeys(this.shape))}};Oe.create=(t,e)=>new Oe({shape:()=>t,unknownKeys:"strip",catchall:qe.create(),typeName:D.ZodObject,...G(e)});Oe.strictCreate=(t,e)=>new Oe({shape:()=>t,unknownKeys:"strict",catchall:qe.create(),typeName:D.ZodObject,...G(e)});Oe.lazycreate=(t,e)=>new Oe({shape:t,unknownKeys:"strip",catchall:qe.create(),typeName:D.ZodObject,...G(e)});var zt=class extends ${_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 Ne(a.ctx.common.issues));return k(n,{code:E.invalid_union,unionErrors:s}),P}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 c={...n,common:{...n.common,issues:[]},parent:null},h=l._parseSync({data:n.data,path:n.path,parent:c});if(h.status==="valid")return h;h.status==="dirty"&&!i&&(i={result:h,ctx:c}),c.common.issues.length&&s.push(c.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let a=s.map(l=>new Ne(l));return k(n,{code:E.invalid_union,unionErrors:a}),P}}get options(){return this._def.options}};zt.create=(t,e)=>new zt({options:t,typeName:D.ZodUnion,...G(e)});var ut=t=>t instanceof Ft?ut(t.schema):t instanceof Fe?ut(t.innerType()):t instanceof $t?[t.value]:t instanceof Bt?t.options:t instanceof Vt?V.objectValues(t.enum):t instanceof jt?ut(t._def.innerType):t instanceof Ut?[void 0]:t instanceof Ht?[null]:t instanceof ze?[void 0,...ut(t.unwrap())]:t instanceof rt?[null,...ut(t.unwrap())]:t instanceof Xn||t instanceof Wt?ut(t.unwrap()):t instanceof qt?ut(t._def.innerType):[],Fr=class t extends ${_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==C.object)return k(n,{code:E.invalid_type,expected:C.object,received:n.parsedType}),P;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}):(k(n,{code:E.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),P)}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=ut(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:D.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:o,...G(r)})}};function Cs(t,e){let n=tt(t),r=tt(e);if(t===e)return{valid:!0,data:t};if(n===C.object&&r===C.object){let o=V.objectKeys(e),i=V.objectKeys(t).filter(a=>o.indexOf(a)!==-1),s={...t,...e};for(let a of i){let l=Cs(t[a],e[a]);if(!l.valid)return{valid:!1};s[a]=l.data}return{valid:!0,data:s}}else if(n===C.array&&r===C.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=Cs(s,a);if(!l.valid)return{valid:!1};o.push(l.data)}return{valid:!0,data:o}}else return n===C.date&&r===C.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Gt=class extends ${_parse(e){let{status:n,ctx:r}=this._processInputParams(e),o=(i,s)=>{if(zr(i)||zr(s))return P;let a=Cs(i.value,s.value);return a.valid?((Gr(i)||Gr(s))&&n.dirty(),{status:n.value,value:a.data}):(k(r,{code:E.invalid_intersection_types}),P)};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}))}};Gt.create=(t,e,n)=>new Gt({left:t,right:e,typeName:D.ZodIntersection,...G(n)});var nt=class t extends ${_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==C.array)return k(r,{code:E.invalid_type,expected:C.array,received:r.parsedType}),P;if(r.data.length<this._def.items.length)return k(r,{code:E.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),P;!this._def.rest&&r.data.length>this._def.items.length&&(k(r,{code:E.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 Ge(r,s,r.path,a)):null}).filter(s=>!!s);return r.common.async?Promise.all(i).then(s=>_e.mergeArray(n,s)):_e.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};nt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new nt({items:t,typeName:D.ZodTuple,rest:null,...G(e)})};var $r=class t extends ${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!==C.object)return k(r,{code:E.invalid_type,expected:C.object,received:r.parsedType}),P;let o=[],i=this._def.keyType,s=this._def.valueType;for(let a in r.data)o.push({key:i._parse(new Ge(r,a,r.path,a)),value:s._parse(new Ge(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?_e.mergeObjectAsync(n,o):_e.mergeObjectSync(n,o)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof $?new t({keyType:e,valueType:n,typeName:D.ZodRecord,...G(r)}):new t({keyType:Et.create(),valueType:e,typeName:D.ZodRecord,...G(n)})}},bn=class extends ${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!==C.map)return k(r,{code:E.invalid_type,expected:C.map,received:r.parsedType}),P;let o=this._def.keyType,i=this._def.valueType,s=[...r.data.entries()].map(([a,l],c)=>({key:o._parse(new Ge(r,a,r.path,[c,"key"])),value:i._parse(new Ge(r,l,r.path,[c,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let l of s){let c=await l.key,h=await l.value;if(c.status==="aborted"||h.status==="aborted")return P;(c.status==="dirty"||h.status==="dirty")&&n.dirty(),a.set(c.value,h.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let l of s){let c=l.key,h=l.value;if(c.status==="aborted"||h.status==="aborted")return P;(c.status==="dirty"||h.status==="dirty")&&n.dirty(),a.set(c.value,h.value)}return{status:n.value,value:a}}}};bn.create=(t,e,n)=>new bn({valueType:e,keyType:t,typeName:D.ZodMap,...G(n)});var yn=class t extends ${_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==C.set)return k(r,{code:E.invalid_type,expected:C.set,received:r.parsedType}),P;let o=this._def;o.minSize!==null&&r.data.size<o.minSize.value&&(k(r,{code:E.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&&(k(r,{code:E.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 c=new Set;for(let h of l){if(h.status==="aborted")return P;h.status==="dirty"&&n.dirty(),c.add(h.value)}return{status:n.value,value:c}}let a=[...r.data.values()].map((l,c)=>i._parse(new Ge(r,l,r.path,c)));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:R.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:R.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};yn.create=(t,e)=>new yn({valueType:t,minSize:null,maxSize:null,typeName:D.ZodSet,...G(e)});var Br=class t extends ${constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==C.function)return k(n,{code:E.invalid_type,expected:C.function,received:n.parsedType}),P;function r(a,l){return Wn({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,hn(),ct].filter(c=>!!c),issueData:{code:E.invalid_arguments,argumentsError:l}})}function o(a,l){return Wn({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,hn(),ct].filter(c=>!!c),issueData:{code:E.invalid_return_type,returnTypeError:l}})}let i={errorMap:n.common.contextualErrorMap},s=n.data;if(this._def.returns instanceof wt){let a=this;return Se(async function(...l){let c=new Ne([]),h=await a._def.args.parseAsync(l,i).catch(f=>{throw c.addIssue(r(l,f)),c}),m=await Reflect.apply(s,this,h);return await a._def.returns._def.type.parseAsync(m,i).catch(f=>{throw c.addIssue(o(m,f)),c})})}else{let a=this;return Se(function(...l){let c=a._def.args.safeParse(l,i);if(!c.success)throw new Ne([r(l,c.error)]);let h=Reflect.apply(s,this,c.data),m=a._def.returns.safeParse(h,i);if(!m.success)throw new Ne([o(h,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:nt.create(e).rest(dt.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||nt.create([]).rest(dt.create()),returns:n||dt.create(),typeName:D.ZodFunction,...G(r)})}},Ft=class extends ${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})}};Ft.create=(t,e)=>new Ft({getter:t,typeName:D.ZodLazy,...G(e)});var $t=class extends ${_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return k(n,{received:n.data,code:E.invalid_literal,expected:this._def.value}),P}return{status:"valid",value:e.data}}get value(){return this._def.value}};$t.create=(t,e)=>new $t({value:t,typeName:D.ZodLiteral,...G(e)});function Rl(t,e){return new Bt({values:t,typeName:D.ZodEnum,...G(e)})}var Bt=class t extends ${_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return k(n,{expected:V.joinValues(r),received:n.parsedType,code:E.invalid_type}),P}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 k(n,{received:n.data,code:E.invalid_enum_value,options:r}),P}return Se(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})}};Bt.create=Rl;var Vt=class extends ${_parse(e){let n=V.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==C.string&&r.parsedType!==C.number){let o=V.objectValues(n);return k(r,{expected:V.joinValues(o),received:r.parsedType,code:E.invalid_type}),P}if(this._cache||(this._cache=new Set(V.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=V.objectValues(n);return k(r,{received:r.data,code:E.invalid_enum_value,options:o}),P}return Se(e.data)}get enum(){return this._def.values}};Vt.create=(t,e)=>new Vt({values:t,typeName:D.ZodNativeEnum,...G(e)});var wt=class extends ${unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==C.promise&&n.common.async===!1)return k(n,{code:E.invalid_type,expected:C.promise,received:n.parsedType}),P;let r=n.parsedType===C.promise?n.data:Promise.resolve(n.data);return Se(r.then(o=>this._def.type.parseAsync(o,{path:n.path,errorMap:n.common.contextualErrorMap})))}};wt.create=(t,e)=>new wt({type:t,typeName:D.ZodPromise,...G(e)});var Fe=class extends ${innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===D.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=>{k(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 P;let l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?P:l.status==="dirty"?Ot(l.value):n.value==="dirty"?Ot(l.value):l});{if(n.value==="aborted")return P;let a=this._def.schema._parseSync({data:s,path:r.path,parent:r});return a.status==="aborted"?P:a.status==="dirty"?Ot(a.value):n.value==="dirty"?Ot(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"?P:(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"?P:(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(!_t(s))return P;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=>_t(s)?Promise.resolve(o.transform(s.value,i)).then(a=>({status:n.value,value:a})):P);V.assertNever(o)}};Fe.create=(t,e,n)=>new Fe({schema:t,typeName:D.ZodEffects,effect:e,...G(n)});Fe.createWithPreprocess=(t,e,n)=>new Fe({schema:e,effect:{type:"preprocess",transform:t},typeName:D.ZodEffects,...G(n)});var ze=class extends ${_parse(e){return this._getType(e)===C.undefined?Se(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ze.create=(t,e)=>new ze({innerType:t,typeName:D.ZodOptional,...G(e)});var rt=class extends ${_parse(e){return this._getType(e)===C.null?Se(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};rt.create=(t,e)=>new rt({innerType:t,typeName:D.ZodNullable,...G(e)});var jt=class extends ${_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===C.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};jt.create=(t,e)=>new jt({innerType:t,typeName:D.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...G(e)});var qt=class extends ${_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 fn(o)?o.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ne(r.common.issues)},input:r.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Ne(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};qt.create=(t,e)=>new qt({innerType:t,typeName:D.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...G(e)});var xn=class extends ${_parse(e){if(this._getType(e)!==C.nan){let r=this._getOrReturnCtx(e);return k(r,{code:E.invalid_type,expected:C.nan,received:r.parsedType}),P}return{status:"valid",value:e.data}}};xn.create=t=>new xn({typeName:D.ZodNaN,...G(t)});var Fp=Symbol("zod_brand"),Xn=class extends ${_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}},Yn=class t extends ${_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"?P:i.status==="dirty"?(n.dirty(),Ot(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"?P: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:D.ZodPipeline})}},Wt=class extends ${_parse(e){let n=this._def.innerType._parse(e),r=o=>(_t(o)&&(o.value=Object.freeze(o.value)),o);return fn(n)?n.then(o=>r(o)):r(n)}unwrap(){return this._def.innerType}};Wt.create=(t,e)=>new Wt({innerType:t,typeName:D.ZodReadonly,...G(e)});function Al(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Nl(t,e={},n){return t?Tt.create().superRefine((r,o)=>{let i=t(r);if(i instanceof Promise)return i.then(s=>{if(!s){let a=Al(e,r),l=a.fatal??n??!0;o.addIssue({code:"custom",...a,fatal:l})}});if(!i){let s=Al(e,r),a=s.fatal??n??!0;o.addIssue({code:"custom",...s,fatal:a})}}):Tt.create()}var $p={object:Oe.lazycreate},D;(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"})(D||(D={}));var Bp=(t,e={message:`Input not instance of ${t.name}`})=>Nl(n=>n instanceof t,e),Ol=Et.create,Ml=Mt.create,Vp=xn.create,jp=Lt.create,Ll=Pt.create,qp=Dt.create,Wp=gn.create,Xp=Ut.create,Yp=Ht.create,Kp=Tt.create,Zp=dt.create,Jp=qe.create,Qp=vn.create,eh=pt.create,th=Oe.create,nh=Oe.strictCreate,rh=zt.create,oh=Fr.create,ih=Gt.create,sh=nt.create,ah=$r.create,lh=bn.create,ch=yn.create,uh=Br.create,dh=Ft.create,ph=$t.create,hh=Bt.create,fh=Vt.create,mh=wt.create,gh=Fe.create,vh=ze.create,bh=rt.create,yh=Fe.createWithPreprocess,xh=Yn.create,_h=()=>Ol().optional(),Eh=()=>Ml().optional(),Th=()=>Ll().optional(),wh={string:(t=>Et.create({...t,coerce:!0})),number:(t=>Mt.create({...t,coerce:!0})),boolean:(t=>Pt.create({...t,coerce:!0})),bigint:(t=>Lt.create({...t,coerce:!0})),date:(t=>Dt.create({...t,coerce:!0}))};var Sh=P;var Ah=u.object({name:u.string(),arguments:u.string()}),kh=u.object({id:u.string(),type:u.literal("function"),function:Ah,encryptedValue:u.string().optional()}),Vr=u.object({id:u.string(),role:u.string(),content:u.string().optional(),name:u.string().optional(),encryptedValue:u.string().optional()}),Ch=u.object({type:u.literal("text"),text:u.string()}),Ih=u.object({type:u.literal("data"),value:u.string(),mimeType:u.string()}),Rh=u.object({type:u.literal("url"),value:u.string(),mimeType:u.string().optional()}),jr=u.discriminatedUnion("type",[Ih,Rh]),Nh=u.object({type:u.literal("image"),source:jr,metadata:u.unknown().optional()}),Oh=u.object({type:u.literal("audio"),source:jr,metadata:u.unknown().optional()}),Mh=u.object({type:u.literal("video"),source:jr,metadata:u.unknown().optional()}),Lh=u.object({type:u.literal("document"),source:jr,metadata:u.unknown().optional()});var Pl=u.object({type:u.literal("binary"),mimeType:u.string(),id:u.string().optional(),url:u.string().optional(),data:u.string().optional(),filename:u.string().optional()}),Dl=(t,e)=>{!t.id&&!t.url&&!t.data&&e.addIssue({code:u.ZodIssueCode.custom,message:"BinaryInputContent requires at least one of id, url, or data.",path:["id"]})},Ty=Pl.superRefine((t,e)=>{Dl(t,e)}),Ph=u.discriminatedUnion("type",[Ch,Nh,Oh,Mh,Lh,Pl]),Dh=Ph.superRefine((t,e)=>{t.type==="binary"&&Dl(t,e)}),Uh=Vr.extend({role:u.literal("developer"),content:u.string()}),Hh=Vr.extend({role:u.literal("system"),content:u.string()}),zh=Vr.extend({role:u.literal("assistant"),content:u.string().optional(),toolCalls:u.array(kh).optional()}),Gh=Vr.extend({role:u.literal("user"),content:u.union([u.string(),u.array(Dh)])}),Fh=u.object({id:u.string(),content:u.string(),role:u.literal("tool"),toolCallId:u.string(),error:u.string().optional(),encryptedValue:u.string().optional()}),$h=u.object({id:u.string(),role:u.literal("activity"),activityType:u.string(),content:u.record(u.any())}),Bh=u.object({id:u.string(),role:u.literal("reasoning"),content:u.string(),encryptedValue:u.string().optional()}),Ul=u.discriminatedUnion("role",[Uh,Hh,zh,Gh,Fh,$h,Bh]),wy=u.union([u.literal("developer"),u.literal("system"),u.literal("assistant"),u.literal("user"),u.literal("tool"),u.literal("activity"),u.literal("reasoning")]),Vh=u.object({description:u.string(),value:u.string()}),Hl=u.object({name:u.string(),description:u.string(),parameters:u.any(),metadata:u.record(u.any()).optional()}),jh=u.object({id:u.string(),reason:u.string(),message:u.string().optional(),toolCallId:u.string().optional(),responseSchema:u.record(u.any()).optional(),expiresAt:u.string().optional(),metadata:u.record(u.any()).optional()}),qh=u.object({interruptId:u.string(),status:u.enum(["resolved","cancelled"]),payload:u.any().optional()}),Wh=u.object({threadId:u.string(),runId:u.string(),parentRunId:u.string().optional(),state:u.any(),messages:u.array(Ul),tools:u.array(Hl),context:u.array(Vh),forwardedProps:u.any(),resume:u.array(qh).optional()}),Xh=u.any(),ee=class extends Error{constructor(t){super(t)}},Is=class extends ee{constructor(){super("Connect not implemented. This method is not supported by the current agent.")}},Yh=u.object({name:u.string(),description:u.string().optional()}),Kh=u.object({name:u.string().optional(),type:u.string().optional(),description:u.string().optional(),version:u.string().optional(),provider:u.string().optional(),documentationUrl:u.string().optional(),metadata:u.record(u.unknown()).optional()}),Zh=u.object({streaming:u.boolean().optional(),websocket:u.boolean().optional(),httpBinary:u.boolean().optional(),pushNotifications:u.boolean().optional(),resumable:u.boolean().optional()}),Jh=u.object({supported:u.boolean().optional(),items:u.array(Hl).optional(),parallelCalls:u.boolean().optional(),clientProvided:u.boolean().optional()}),Qh=u.object({structuredOutput:u.boolean().optional(),supportedMimeTypes:u.array(u.string()).optional()}),ef=u.object({snapshots:u.boolean().optional(),deltas:u.boolean().optional(),memory:u.boolean().optional(),persistentState:u.boolean().optional()}),tf=u.object({supported:u.boolean().optional(),delegation:u.boolean().optional(),handoffs:u.boolean().optional(),subAgents:u.array(Yh).optional()}),nf=u.object({supported:u.boolean().optional(),streaming:u.boolean().optional(),encrypted:u.boolean().optional()}),rf=u.object({image:u.boolean().optional(),audio:u.boolean().optional(),video:u.boolean().optional(),pdf:u.boolean().optional(),file:u.boolean().optional()}),of=u.object({image:u.boolean().optional(),audio:u.boolean().optional()}),sf=u.object({input:rf.optional(),output:of.optional()}),af=u.object({codeExecution:u.boolean().optional(),sandboxed:u.boolean().optional(),maxIterations:u.number().optional(),maxExecutionTime:u.number().optional()}),lf=u.object({supported:u.boolean().optional(),approvals:u.boolean().optional(),interventions:u.boolean().optional(),feedback:u.boolean().optional(),interrupts:u.boolean().optional(),approveWithEdits:u.boolean().optional()}),Sy=u.object({identity:Kh.optional(),transport:Zh.optional(),tools:Jh.optional(),output:Qh.optional(),state:ef.optional(),multiAgent:tf.optional(),reasoning:nf.optional(),multimodal:sf.optional(),execution:af.optional(),humanInTheLoop:lf.optional(),custom:u.record(u.unknown()).optional()}),zl=u.union([u.literal("developer"),u.literal("system"),u.literal("assistant"),u.literal("user")]),v=(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})({}),X=u.object({type:u.nativeEnum(v),timestamp:u.number().optional(),rawEvent:u.any().optional()}).passthrough(),cf=X.extend({type:u.literal(v.TEXT_MESSAGE_START),messageId:u.string(),role:zl.default("assistant"),name:u.string().optional()}),Gl=X.extend({type:u.literal(v.TEXT_MESSAGE_CONTENT),messageId:u.string(),delta:u.string()}),uf=X.extend({type:u.literal(v.TEXT_MESSAGE_END),messageId:u.string()}),df=X.extend({type:u.literal(v.TEXT_MESSAGE_CHUNK),messageId:u.string().optional(),role:zl.optional(),delta:u.string().optional(),name:u.string().optional()}),pf=X.extend({type:u.literal(v.THINKING_TEXT_MESSAGE_START)}),hf=Gl.omit({messageId:!0,type:!0}).extend({type:u.literal(v.THINKING_TEXT_MESSAGE_CONTENT)}),ff=X.extend({type:u.literal(v.THINKING_TEXT_MESSAGE_END)}),mf=X.extend({type:u.literal(v.TOOL_CALL_START),toolCallId:u.string(),toolCallName:u.string(),parentMessageId:u.string().optional()}),gf=X.extend({type:u.literal(v.TOOL_CALL_ARGS),toolCallId:u.string(),delta:u.string()}),vf=X.extend({type:u.literal(v.TOOL_CALL_END),toolCallId:u.string()}),bf=X.extend({messageId:u.string(),type:u.literal(v.TOOL_CALL_RESULT),toolCallId:u.string(),content:u.string(),role:u.literal("tool").optional()}),yf=X.extend({type:u.literal(v.TOOL_CALL_CHUNK),toolCallId:u.string().optional(),toolCallName:u.string().optional(),parentMessageId:u.string().optional(),delta:u.string().optional()}),xf=X.extend({type:u.literal(v.THINKING_START),title:u.string().optional()}),_f=X.extend({type:u.literal(v.THINKING_END)}),Ef=X.extend({type:u.literal(v.STATE_SNAPSHOT),snapshot:Xh}),Tf=X.extend({type:u.literal(v.STATE_DELTA),delta:u.array(u.any())}),wf=X.extend({type:u.literal(v.MESSAGES_SNAPSHOT),messages:u.array(Ul)}),Sf=X.extend({type:u.literal(v.ACTIVITY_SNAPSHOT),messageId:u.string(),activityType:u.string(),content:u.record(u.any()),replace:u.boolean().optional().default(!0)}),Af=X.extend({type:u.literal(v.ACTIVITY_DELTA),messageId:u.string(),activityType:u.string(),patch:u.array(u.any())}),kf=X.extend({type:u.literal(v.RAW),event:u.any(),source:u.string().optional()}),Cf=X.extend({type:u.literal(v.CUSTOM),name:u.string(),value:u.any()}),If=X.extend({type:u.literal(v.RUN_STARTED),threadId:u.string(),runId:u.string(),parentRunId:u.string().optional(),input:Wh.optional()}),Rf=u.object({type:u.literal("success")}).strict(),Nf=u.object({type:u.literal("interrupt"),interrupts:u.array(jh).min(1)}).strict(),Of=u.discriminatedUnion("type",[Rf,Nf]),Mf=X.extend({type:u.literal(v.RUN_FINISHED),threadId:u.string(),runId:u.string(),result:u.any().optional(),outcome:Of.nullable().optional().transform(t=>t??void 0)}),Lf=X.extend({type:u.literal(v.RUN_ERROR),message:u.string(),code:u.string().optional()}),Pf=X.extend({type:u.literal(v.STEP_STARTED),stepName:u.string()}),Df=X.extend({type:u.literal(v.STEP_FINISHED),stepName:u.string()}),Uf=u.union([u.literal("tool-call"),u.literal("message")]),Hf=X.extend({type:u.literal(v.REASONING_START),messageId:u.string()}),zf=X.extend({type:u.literal(v.REASONING_MESSAGE_START),messageId:u.string(),role:u.literal("reasoning")}),Gf=X.extend({type:u.literal(v.REASONING_MESSAGE_CONTENT),messageId:u.string(),delta:u.string()}),Ff=X.extend({type:u.literal(v.REASONING_MESSAGE_END),messageId:u.string()}),$f=X.extend({type:u.literal(v.REASONING_MESSAGE_CHUNK),messageId:u.string().optional(),delta:u.string().optional()}),Bf=X.extend({type:u.literal(v.REASONING_END),messageId:u.string()}),Vf=X.extend({type:u.literal(v.REASONING_ENCRYPTED_VALUE),subtype:Uf,entityId:u.string(),encryptedValue:u.string()}),qr=u.discriminatedUnion("type",[cf,Gl,uf,df,xf,_f,pf,hf,ff,mf,gf,vf,yf,bf,Ef,Tf,wf,Sf,Af,kf,Cf,If,Mf,Lf,Pf,Df,Hf,zf,Gf,Ff,$f,Bf,Vf]);var Rs={};ji(Rs,{JsonPatchError:()=>he,_areEquals:()=>Jn,applyOperation:()=>Xt,applyPatch:()=>Qr,applyReducer:()=>Yf,deepClone:()=>Wf,getValueByPointer:()=>Zr,validate:()=>$l,validator:()=>Jr});var jf=(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)}})(),qf=Object.prototype.hasOwnProperty;function Xr(t,e){return qf.call(t,e)}function Yr(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)Xr(t,o)&&r.push(o);return r}function Ee(t){switch(typeof t){case"object":return JSON.parse(JSON.stringify(t));case"undefined":return null;default:return t}}function Kr(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 ot(t){return t.indexOf("/")===-1&&t.indexOf("~")===-1?t:t.replace(/~/g,"~0").replace(/\//g,"~1")}function Kn(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function Wr(t){if(t===void 0)return!0;if(t){if(Array.isArray(t)){for(var e=0,n=t.length;e<n;e++)if(Wr(t[e]))return!0}else if(typeof t=="object"){for(var r=Yr(t),o=r.length,i=0;i<o;i++)if(Wr(t[r[i]]))return!0}}return!1}function Fl(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 Zn=(function(t){jf(e,t);function e(n,r,o,i,s){var a=this.constructor,l=t.call(this,Fl(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=Fl(n,{name:r,index:o,operation:i,tree:s}),l}return e})(Error);var he=Zn,Wf=Ee,_n={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=Zr(n,this.path);r&&(r=Ee(r));var o=Xt(n,{op:"remove",path:this.from}).removed;return Xt(n,{op:"add",path:this.path,value:o}),{newDocument:n,removed:r}},copy:function(t,e,n){var r=Zr(n,this.from);return Xt(n,{op:"add",path:this.path,value:Ee(r)}),{newDocument:n}},test:function(t,e,n){return{newDocument:n,test:Jn(t[e],this.value)}},_get:function(t,e,n){return this.value=t[e],{newDocument:n}}},Xf={add:function(t,e,n){return Kr(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:_n.move,copy:_n.copy,test:_n.test,_get:_n._get};function Zr(t,e){if(e=="")return t;var n={op:"_get",path:e};return Xt(t,n),n.value}function Xt(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):Jr(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=Zr(t,e.from),e.op==="move"&&(s.removed=t),s;if(e.op==="test"){if(s.test=Jn(t,e.value),s.test===!1)throw new he("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 he("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",i,e,t);return s}}else{r||(t=Ee(t));var a=e.path||"",l=a.split("/"),c=t,h=1,m=l.length,y=void 0,f=void 0,p=void 0;for(typeof n=="function"?p=n:p=Jr;;){if(f=l[h],f&&f.indexOf("~")!=-1&&(f=Kn(f)),o&&(f=="__proto__"||f=="prototype"&&h>0&&l[h-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&&y===void 0&&(c[f]===void 0?y=l.slice(0,h).join("/"):h==m-1&&(y=e.path),y!==void 0&&p(e,0,t,y)),h++,Array.isArray(c)){if(f==="-")f=c.length;else{if(n&&!Kr(f))throw new he("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);Kr(f)&&(f=~~f)}if(h>=m){if(n&&e.op==="add"&&f>c.length)throw new he("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=Xf[e.op].call(e,c,f,t);if(s.test===!1)throw new he("Test operation failed","TEST_OPERATION_FAILED",i,e,t);return s}}else if(h>=m){var s=_n[e.op].call(e,c,f,t);if(s.test===!1)throw new he("Test operation failed","TEST_OPERATION_FAILED",i,e,t);return s}if(c=c[f],n&&h<m&&(!c||typeof c!="object"))throw new he("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",i,e,t)}}}function Qr(t,e,n,r,o){if(r===void 0&&(r=!0),o===void 0&&(o=!0),n&&!Array.isArray(e))throw new he("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");r||(t=Ee(t));for(var i=new Array(e.length),s=0,a=e.length;s<a;s++)i[s]=Xt(t,e[s],n,!0,o,s),t=i[s].newDocument;return i.newDocument=t,i}function Yf(t,e,n){var r=Xt(t,e);if(r.test===!1)throw new he("Test operation failed","TEST_OPERATION_FAILED",n,e,t);return r.newDocument}function Jr(t,e,n,r){if(typeof t!="object"||t===null||Array.isArray(t))throw new he("Operation is not an object","OPERATION_NOT_AN_OBJECT",e,t,n);if(_n[t.op]){if(typeof t.path!="string")throw new he("Operation `path` property is not a string","OPERATION_PATH_INVALID",e,t,n);if(t.path.indexOf("/")!==0&&t.path.length>0)throw new he('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 he("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 he("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")&&Wr(t.value))throw new he("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 he("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 he("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=$l([s],n);if(a&&a.name==="OPERATION_PATH_UNRESOLVABLE")throw new he("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",e,t,n)}}}else throw new he("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",e,t,n)}function $l(t,e,n){try{if(!Array.isArray(t))throw new he("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(e)Qr(Ee(e),Ee(t),n||!0);else{n=n||Jr;for(var r=0;r<t.length;r++)n(t[r],r,e,void 0)}}catch(o){if(o instanceof he)return o;throw o}}function Jn(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(!Jn(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],!Jn(t[s],e[s]))return!1;return!0}return t!==t&&e!==e}var Ls={};ji(Ls,{compare:()=>rm,generate:()=>Ns,observe:()=>nm,unobserve:()=>tm});var Os=new WeakMap,Kf=(function(){function t(e){this.observers=new Map,this.obj=e}return t})(),Zf=(function(){function t(e,n){this.callback=e,this.observer=n}return t})();function Jf(t){return Os.get(t)}function Qf(t,e){return t.observers.get(e)}function em(t,e){t.observers.delete(e.callback)}function tm(t,e){e.unobserve()}function nm(t,e){var n=[],r,o=Jf(t);if(!o)o=new Kf(t),Os.set(t,o);else{var i=Qf(o,e);r=i&&i.observer}if(r)return r;if(r={},o.value=Ee(t),e){r.callback=e,r.next=null;var s=function(){Ns(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(){Ns(r),clearTimeout(r.next),em(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 Zf(e,r)),r}function Ns(t,e){e===void 0&&(e=!1);var n=Os.get(t.object);Ms(n.value,t.object,t.patches,"",e),t.patches.length&&Qr(n.value,t.patches);var r=t.patches;return r.length>0&&(t.patches=[],t.callback&&t.callback(r)),r}function Ms(t,e,n,r,o){if(e!==t){typeof e.toJSON=="function"&&(e=e.toJSON());for(var i=Yr(e),s=Yr(t),a=!1,l=!1,c=s.length-1;c>=0;c--){var h=s[c],m=t[h];if(Xr(e,h)&&!(e[h]===void 0&&m!==void 0&&Array.isArray(e)===!1)){var y=e[h];typeof m=="object"&&m!=null&&typeof y=="object"&&y!=null&&Array.isArray(m)===Array.isArray(y)?Ms(m,y,n,r+"/"+ot(h),o):m!==y&&(a=!0,o&&n.push({op:"test",path:r+"/"+ot(h),value:Ee(m)}),n.push({op:"replace",path:r+"/"+ot(h),value:Ee(y)}))}else Array.isArray(t)===Array.isArray(e)?(o&&n.push({op:"test",path:r+"/"+ot(h),value:Ee(m)}),n.push({op:"remove",path:r+"/"+ot(h)}),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 c=0;c<i.length;c++){var h=i[c];!Xr(t,h)&&e[h]!==void 0&&n.push({op:"add",path:r+"/"+ot(h),value:Ee(e[h])})}}}function rm(t,e,n){n===void 0&&(n=!1);var r=[];return Ms(t,e,r,"",n),r}var eo=Object.assign({},Rs,Ls,{JsonPatchError:Zn,deepClone:Ee,escapePathComponent:ot,unescapePathComponent:Kn});var Ps=function(t,e){return Ps=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])},Ps(t,e)};function it(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Ps(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function Bl(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(h){try{c(r.next(h))}catch(m){s(m)}}function l(h){try{c(r.throw(h))}catch(m){s(m)}}function c(h){h.done?i(h.value):o(h.value).then(a,l)}c((r=r.apply(t,e||[])).next())})}function to(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(c){return function(h){return l([c,h])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(n=0)),n;)try{if(r=1,o&&(i=c[0]&2?o.return:c[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,c[1])).done)return i;switch(o=0,i&&(c=[c[0]&2,i.value]),c[0]){case 0:case 1:i=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,o=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){n.label=c[1];break}if(c[0]===6&&n.label<i[1]){n.label=i[1],i=c;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(c);break}i[2]&&n.ops.pop(),n.trys.pop();continue}c=e.call(t,n)}catch(h){c=[6,h],o=0}finally{r=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function ht(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 En(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 Tn(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 Yt(t){return this instanceof Yt?(this.v=t,this):new Yt(t)}function Vl(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(f){return function(p){return Promise.resolve(p).then(f,m)}}function a(f,p){r[f]&&(o[f]=function(g){return new Promise(function(x,S){i.push([f,g,x,S])>1||l(f,g)})},p&&(o[f]=p(o[f])))}function l(f,p){try{c(r[f](p))}catch(g){y(i[0][3],g)}}function c(f){f.value instanceof Yt?Promise.resolve(f.value.v).then(h,m):y(i[0][2],f)}function h(f){l("next",f)}function m(f){l("throw",f)}function y(f,p){f(p),i.shift(),i.length&&l(i[0][0],i[0][1])}}function jl(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 ht=="function"?ht(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(c){i({value:c,done:a})},s)}}function B(t){return typeof t=="function"}function wn(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 no=wn(function(t){return function(n){t(this),this.message=n?n.length+` errors occurred during unsubscription:
|
|
3
3
|
`+n.map(function(r,o){return o+1+") "+r.toString()}).join(`
|
|
4
|
-
`):"",this.name="UnsubscriptionError",this.errors=n}});function Zn(t,e){if(t){var n=t.indexOf(e);0<=n&&t.splice(n,1)}}var Sn=(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=pt(s),l=a.next();!l.done;l=a.next()){var c=l.value;c.remove(this)}}catch(g){e={error:g}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}else s.remove(this);var h=this.initialTeardown;if(B(h))try{h()}catch(g){i=g instanceof Qr?g.errors:[g]}var m=this._finalizers;if(m){this._finalizers=null;try{for(var y=pt(m),f=y.next();!f.done;f=y.next()){var p=f.value;try{Pl(p)}catch(g){i=i??[],g instanceof Qr?i=Tn(Tn([],En(i)),En(g.errors)):i.push(g)}}}catch(g){r={error:g}}finally{try{f&&!f.done&&(o=y.return)&&o.call(y)}finally{if(r)throw r.error}}}if(i)throw new Qr(i)}},t.prototype.add=function(e){var n;if(e&&e!==this)if(this.closed)Pl(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)&&Zn(n,e)},t.prototype.remove=function(e){var n=this._finalizers;n&&Zn(n,e),e instanceof t&&e._removeParent(this)},t.EMPTY=(function(){var e=new t;return e.closed=!0,e})(),t})();var Ns=Sn.EMPTY;function eo(t){return t instanceof Sn||t&&"closed"in t&&B(t.remove)&&B(t.add)&&B(t.unsubscribe)}function Pl(t){B(t)?t():t.unsubscribe()}var qe={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var _n={setTimeout:function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=_n.delegate;return o?.setTimeout?o.setTimeout.apply(o,Tn([t,e],En(n))):setTimeout.apply(void 0,Tn([t,e],En(n)))},clearTimeout:function(t){var e=_n.delegate;return(e?.clearTimeout||clearTimeout)(t)},delegate:void 0};function to(t){_n.setTimeout(function(){var e=qe.onUnhandledError;if(e)e(t);else throw t})}function Jn(){}var Dl=(function(){return Os("C",void 0,void 0)})();function Ul(t){return Os("E",void 0,t)}function Hl(t){return Os("N",t,void 0)}function Os(t,e,n){return{kind:t,value:e,error:n}}var Yt=null;function An(t){if(qe.useDeprecatedSynchronousErrorHandling){var e=!Yt;if(e&&(Yt={errorThrown:!1,error:null}),t(),e){var n=Yt,r=n.errorThrown,o=n.error;if(Yt=null,r)throw o}}else t()}function Gl(t){qe.useDeprecatedSynchronousErrorHandling&&Yt&&(Yt.errorThrown=!0,Yt.error=t)}var Qn=(function(t){ot(e,t);function e(n){var r=t.call(this)||this;return r.isStopped=!1,n?(r.destination=n,eo(n)&&n.add(r)):r.destination=Bf,r}return e.create=function(n,r,o){return new ro(n,r,o)},e.prototype.next=function(n){this.isStopped?Ls(Hl(n),this):this._next(n)},e.prototype.error=function(n){this.isStopped?Ls(Ul(n),this):(this.isStopped=!0,this._error(n))},e.prototype.complete=function(){this.isStopped?Ls(Dl,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})(Sn);var zf=Function.prototype.bind;function Ms(t,e){return zf.call(t,e)}var Ff=(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){no(r)}},t.prototype.error=function(e){var n=this.partialObserver;if(n.error)try{n.error(e)}catch(r){no(r)}else no(e)},t.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(n){no(n)}},t})(),ro=(function(t){ot(e,t);function e(n,r,o){var i=t.call(this)||this,s;if(B(n)||!n)s={next:n??void 0,error:r??void 0,complete:o??void 0};else{var a;i&&qe.useDeprecatedNextContext?(a=Object.create(n),a.unsubscribe=function(){return i.unsubscribe()},s={next:n.next&&Ms(n.next,a),error:n.error&&Ms(n.error,a),complete:n.complete&&Ms(n.complete,a)}):s=n}return i.destination=new Ff(s),i}return e})(Qn);function no(t){qe.useDeprecatedSynchronousErrorHandling?Gl(t):to(t)}function $f(t){throw t}function Ls(t,e){var n=qe.onStoppedNotification;n&&_n.setTimeout(function(){return n(t,e)})}var Bf={closed:!0,next:Jn,error:$f,complete:Jn};var kn=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function In(t){return t}function oo(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Ps(t)}function Ps(t){return t.length===0?In:t.length===1?t[0]:function(n){return t.reduce(function(r,o){return o(r)},n)}}var te=(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=jf(e)?e:new ro(e,n,r);return An(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=zl(n),new n(function(o,i){var s=new ro({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[kn]=function(){return this},t.prototype.pipe=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return Ps(e)(this)},t.prototype.toPromise=function(e){var n=this;return e=zl(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 zl(t){var e;return(e=t??qe.Promise)!==null&&e!==void 0?e:Promise}function Vf(t){return t&&B(t.next)&&B(t.error)&&B(t.complete)}function jf(t){return t&&t instanceof Qn||Vf(t)&&eo(t)}function qf(t){return B(t?.lift)}function fe(t){return function(e){if(qf(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 ge(t,e,n,r,o){return new Wf(t,e,n,r,o)}var Wf=(function(t){ot(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(c){try{r(c)}catch(h){n.error(h)}}:t.prototype._next,l._error=i?function(c){try{i(c)}catch(h){n.error(h)}finally{this.unsubscribe()}}:t.prototype._error,l._complete=o?function(){try{o()}catch(c){n.error(c)}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})(Qn);var Fl=wn(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}});var it=(function(t){ot(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 $l(this,this);return r.operator=n,r},e.prototype._throwIfClosed=function(){if(this.closed)throw new Fl},e.prototype.next=function(n){var r=this;An(function(){var o,i;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var s=pt(r.currentObservers),a=s.next();!a.done;a=s.next()){var l=a.value;l.next(n)}}catch(c){o={error:c}}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;An(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;An(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?Ns:(this.currentObservers=null,a.push(n),new Sn(function(){r.currentObservers=null,Zn(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 te;return n.source=this,n},e.create=function(n,r){return new $l(n,r)},e})(te);var $l=(function(t){ot(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:Ns},e})(it);var Ds={now:function(){return(Ds.delegate||Date).now()},delegate:void 0};var io=(function(t){ot(e,t);function e(n,r,o){n===void 0&&(n=1/0),r===void 0&&(r=1/0),o===void 0&&(o=Ds);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(),c=0,h=1;h<i.length&&i[h]<=l;h+=2)c=h;c&&i.splice(0,c+1)}},e})(it);var so=new te(function(t){return t.complete()});function Bl(t){return t&&B(t.schedule)}function Xf(t){return t[t.length-1]}function Vl(t){return Bl(Xf(t))?t.pop():void 0}var ao=(function(t){return t&&typeof t.length=="number"&&typeof t!="function"});function lo(t){return B(t?.then)}function co(t){return B(t[kn])}function uo(t){return Symbol.asyncIterator&&B(t?.[Symbol.asyncIterator])}function po(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 Yf(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var ho=Yf();function fo(t){return B(t?.[ho])}function mo(t){return Ml(this,arguments,function(){var n,r,o,i;return Jr(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,Xt(n.read())];case 3:return r=s.sent(),o=r.value,i=r.done,i?[4,Xt(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,Xt(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 go(t){return B(t?.getReader)}function ve(t){if(t instanceof te)return t;if(t!=null){if(co(t))return Kf(t);if(ao(t))return Zf(t);if(lo(t))return Jf(t);if(uo(t))return jl(t);if(fo(t))return Qf(t);if(go(t))return em(t)}throw po(t)}function Kf(t){return new te(function(e){var n=t[kn]();if(B(n.subscribe))return n.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Zf(t){return new te(function(e){for(var n=0;n<t.length&&!e.closed;n++)e.next(t[n]);e.complete()})}function Jf(t){return new te(function(e){t.then(function(n){e.closed||(e.next(n),e.complete())},function(n){return e.error(n)}).then(null,to)})}function Qf(t){return new te(function(e){var n,r;try{for(var o=pt(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 jl(t){return new te(function(e){tm(t,e).catch(function(n){return e.error(n)})})}function em(t){return jl(mo(t))}function tm(t,e){var n,r,o,i;return Ol(this,void 0,void 0,function(){var s,a;return Jr(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),n=Ll(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 $e(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 vo(t,e){return e===void 0&&(e=0),fe(function(n,r){n.subscribe(ge(r,function(o){return $e(r,t,function(){return r.next(o)},e)},function(){return $e(r,t,function(){return r.complete()},e)},function(o){return $e(r,t,function(){return r.error(o)},e)}))})}function bo(t,e){return e===void 0&&(e=0),fe(function(n,r){r.add(t.schedule(function(){return n.subscribe(r)},e))})}function ql(t,e){return ve(t).pipe(bo(e),vo(e))}function Wl(t,e){return ve(t).pipe(bo(e),vo(e))}function Xl(t,e){return new te(function(n){var r=0;return e.schedule(function(){r===t.length?n.complete():(n.next(t[r++]),n.closed||this.schedule())})})}function Yl(t,e){return new te(function(n){var r;return $e(n,e,function(){r=t[ho](),$e(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 B(r?.return)&&r.return()}})}function yo(t,e){if(!t)throw new Error("Iterable cannot be null");return new te(function(n){$e(n,e,function(){var r=t[Symbol.asyncIterator]();$e(n,e,function(){r.next().then(function(o){o.done?n.complete():n.next(o.value)})},0,!0)})})}function Kl(t,e){return yo(mo(t),e)}function Zl(t,e){if(t!=null){if(co(t))return ql(t,e);if(ao(t))return Xl(t,e);if(lo(t))return Wl(t,e);if(uo(t))return yo(t,e);if(fo(t))return Yl(t,e);if(go(t))return Kl(t,e)}throw po(t)}function Kt(t,e){return e?Zl(t,e):ve(t)}function ue(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=Vl(t);return Kt(t,n)}function ne(t,e){var n=B(t)?t:function(){return t},r=function(o){return o.error(n())};return new te(e?function(o){return e.schedule(r,0,o)}:r)}var Jl=wn(function(t){return function(){t(this),this.name="EmptyError",this.message="no elements in sequence"}});function xo(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 Jl)}})})}function Zt(t,e){return fe(function(n,r){var o=0;n.subscribe(ge(r,function(i){r.next(t.call(e,i,o++))}))})}function Ql(t,e,n,r,o,i,s,a){var l=[],c=0,h=0,m=!1,y=function(){m&&!l.length&&!c&&e.complete()},f=function(g){return c<r?p(g):l.push(g)},p=function(g){i&&e.next(g),c++;var x=!1;ve(n(g,h++)).subscribe(ge(e,function(_){o?.(_),i?f(_):e.next(_)},function(){x=!0},void 0,function(){if(x)try{c--;for(var _=function(){var w=l.shift();s?$e(e,s,function(){return p(w)}):p(w)};l.length&&c<r;)_();y()}catch(w){e.error(w)}}))};return t.subscribe(ge(e,f,function(){m=!0,y()})),function(){a?.()}}function Me(t,e,n){return n===void 0&&(n=1/0),B(e)?Me(function(r,o){return Zt(function(i,s){return e(r,i,o,s)})(ve(t(r,o)))},n):(typeof e=="number"&&(n=e),fe(function(r,o){return Ql(r,o,t,n)}))}function Us(t){return t===void 0&&(t=1/0),Me(In,t)}function Eo(t){return new te(function(e){ve(t()).subscribe(e)})}function er(t){return fe(function(e,n){var r=null,o=!1,i;r=e.subscribe(ge(n,void 0,void 0,function(s){i=ve(t(s,er(t)(e))),r?(r.unsubscribe(),r=null,i.subscribe(n)):o=!0})),o&&(r.unsubscribe(),r=null,i.subscribe(n))})}function To(t,e){return B(e)?Me(t,e,1):Me(t,1)}function Hs(t){return fe(function(e,n){var r=!1;e.subscribe(ge(n,function(o){r=!0,n.next(o)},function(){r||n.next(t),n.complete()}))})}function Jt(t){return fe(function(e,n){try{e.subscribe(n)}finally{n.add(t)}})}function Gs(t,e){return fe(function(n,r){var o=null,i=0,s=!1,a=function(){return s&&!o&&r.complete()};n.subscribe(ge(r,function(l){o?.unsubscribe();var c=0,h=i++;ve(t(l,h)).subscribe(o=ge(r,function(m){return r.next(e?e(l,m,h,c++):m)},function(){o=null,a()}))},function(){s=!0,a()}))})}function wo(t){return fe(function(e,n){ve(t).subscribe(ge(n,function(){return n.complete()},Jn)),!n.closed&&e.subscribe(n)})}function zs(t,e,n){var r=B(t)||e||n?{next:t,error:e,complete:n}:t;return r?fe(function(o,i){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var a=!0;o.subscribe(ge(i,function(l){var c;(c=r.next)===null||c===void 0||c.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 c;a=!1,(c=r.error)===null||c===void 0||c.call(r,l),i.error(l)},function(){var l,c;a&&((l=r.unsubscribe)===null||l===void 0||l.call(r)),(c=r.finalize)===null||c===void 0||c.call(r)}))}):In}function ec(t){return` \r
|
|
5
|
-
`.indexOf(t)>=0}function So(t){for(var e=["topLevel"],n=0,r,o,i,s=function(w){return e.push(w)},a=function(w){return e[e.length-1]=w},l=function(w){r==null&&(r=n,o=e.length,i=w)},c=function(w){w===i&&(r=void 0,o=void 0,i=void 0)},h=function(){return e.pop()},m=function(){return n--},y=function(w){if("0"<=w&&w<="9"){s("number");return}switch(w){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}},f=t.length;n<f;n++){var p=t[n];switch(e[e.length-1]){case"topLevel":y(p);break;case"string":switch(p){case'"':h();break;case"\\":l("stringEscape"),s("stringEscaped");break}break;case"stringEscaped":p==="u"?s("stringUnicode"):(c("stringEscape"),h());break;case"stringUnicode":n-t.lastIndexOf("u",n)===4&&(c("stringEscape"),h());break;case"number":p==="."?a("numberNeedsDigit"):p==="e"||p==="E"?a("numberNeedsExponent"):(p<"0"||p>"9")&&(m(),h());break;case"numberNeedsDigit":a("number");break;case"numberNeedsExponent":a(p==="+"||p==="-"?"numberNeedsDigit":"number");break;case"true":case"false":case"null":(p<"a"||p>"z")&&(m(),h());break;case"arrayNeedsValue":p==="]"?h():ec(p)||(c("collectionItem"),a("arrayNeedsComma"),y(p));break;case"arrayNeedsComma":p==="]"?h():p===","&&(l("collectionItem"),a("arrayNeedsValue"));break;case"objectNeedsKey":p==="}"?h():p==='"'&&(l("collectionItem"),a("objectNeedsColon"),s("string"));break;case"objectNeedsColon":p===":"&&a("objectNeedsValue");break;case"objectNeedsValue":ec(p)||(c("collectionItem"),a("objectNeedsComma"),y(p));break;case"objectNeedsComma":p==="}"?h():p===","&&(l("collectionItem"),a("objectNeedsKey"));break}}o!=null&&(e.length=o);for(var g=[r!=null?t.slice(0,r):t],x=function(w){return g.push(w.slice(t.length-t.lastIndexOf(w[0])))},_=e.length-1;_>=0;_--)switch(e[_]){case"string":g.push('"');break;case"numberNeedsDigit":case"numberNeedsExponent":g.push("0");break;case"true":x("true");break;case"false":x("false");break;case"null":x("null");break;case"arrayNeedsValue":case"arrayNeedsComma":g.push("]");break;case"objectNeedsKey":case"objectNeedsColon":case"objectNeedsValue":case"objectNeedsComma":g.push("}");break}return g.join("")}function nc(){let t=0,e=0;for(let r=0;r<28;r+=7){let o=this.buf[this.pos++];if(t|=(o&127)<<r,(o&128)==0)return this.assertBounds(),[t,e]}let n=this.buf[this.pos++];if(t|=(n&15)<<28,e=(n&112)>>4,(n&128)==0)return this.assertBounds(),[t,e];for(let r=3;r<=31;r+=7){let o=this.buf[this.pos++];if(e|=(o&127)<<r,(o&128)==0)return this.assertBounds(),[t,e]}throw new Error("invalid varint")}function Ao(t,e,n){for(let i=0;i<28;i=i+7){let s=t>>>i,a=!(!(s>>>7)&&e==0),l=(a?s|128:s)&255;if(n.push(l),!a)return}let r=t>>>28&15|(e&7)<<4,o=e>>3!=0;if(n.push((o?r|128:r)&255),!!o){for(let i=3;i<31;i=i+7){let s=e>>>i,a=!!(s>>>7),l=(a?s|128:s)&255;if(n.push(l),!a)return}n.push(e>>>31&1)}}var _o=4294967296;function Fs(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>=_o&&(o=o+(r/_o|0),r=r%_o)}return i(-24,-18),i(-18,-12),i(-12,-6),i(-6),e?oc(r,o):Bs(r,o)}function rc(t,e){let n=Bs(t,e),r=n.hi&2147483648;r&&(n=oc(n.lo,n.hi));let o=$s(n.lo,n.hi);return r?"-"+o:o}function $s(t,e){if({lo:t,hi:e}=nm(t,e),e<=2097151)return String(_o*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()+tc(s)+tc(i)}function nm(t,e){return{lo:t>>>0,hi:e>>>0}}function Bs(t,e){return{lo:t|0,hi:e|0}}function oc(t,e){return e=~e,t?t=~t+1:e+=1,Bs(t,e)}var tc=t=>{let e=String(t);return"0000000".slice(e.length)+e};function Vs(t,e){if(t>=0){for(;t>127;)e.push(t&127|128),t=t>>>7;e.push(t)}else{for(let n=0;n<9;n++)e.push(t&127|128),t=t>>7;e.push(1)}}function ic(){let t=this.buf[this.pos++],e=t&127;if((t&128)==0)return this.assertBounds(),e;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 We=rm();function rm(){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()),sc(n),n},uParse(n){return typeof n!="string"&&(n=n.toString()),ac(n),n},enc(n){return typeof n!="string"&&(n=n.toString()),sc(n),Fs(n)},uEnc(n){return typeof n!="string"&&(n=n.toString()),ac(n),Fs(n)},dec(n,r){return rc(n,r)},uDec(n,r){return $s(n,r)}}}function sc(t){if(!/^-?[0-9]+$/.test(t))throw new Error("invalid int64: "+t)}function ac(t){if(!/^[0-9]+$/.test(t))throw new Error("invalid uint64: "+t)}var js=Symbol.for("@bufbuild/protobuf/text-encoding");function qs(){if(globalThis[js]==null){let t=new globalThis.TextEncoder,e=new globalThis.TextDecoder,n;globalThis[js]={encodeUtf8(r){return t.encode(r)},decodeUtf8(r,o){return o?(n===void 0&&(n=new globalThis.TextDecoder("utf-8",{fatal:!0})),n.decode(r)):e.decode(r)},checkUtf8(r){try{return encodeURIComponent(r),!0}catch{return!1}}}}return globalThis[js]}var St;(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"})(St||(St={}));var om=34028234663852886e22,im=-34028234663852886e22,sm=4294967295,am=2147483647,lm=-2147483648,F=class{constructor(e=qs().encodeUtf8){this.encodeUtf8=e,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let e=0;for(let o=0;o<this.chunks.length;o++)e+=this.chunks[o].length;let n=new Uint8Array(e),r=0;for(let o=0;o<this.chunks.length;o++)n.set(this.chunks[o],r),r+=this.chunks[o].length;return this.chunks=[],n}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),n=this.stack.pop();if(!n)throw new Error("invalid state, fork stack empty");return this.chunks=n.chunks,this.buf=n.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,n){return this.uint32((e<<3|n)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(lc(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return Ws(e),Vs(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let n=this.encodeUtf8(e);return this.uint32(n.byteLength),this.raw(n)}float(e){cm(e);let n=new Uint8Array(4);return new DataView(n.buffer).setFloat32(0,e,!0),this.raw(n)}double(e){let n=new Uint8Array(8);return new DataView(n.buffer).setFloat64(0,e,!0),this.raw(n)}fixed32(e){lc(e);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,e,!0),this.raw(n)}sfixed32(e){Ws(e);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,e,!0),this.raw(n)}sint32(e){return Ws(e),e=(e<<1^e>>31)>>>0,Vs(e,this.buf),this}sfixed64(e){let n=new Uint8Array(8),r=new DataView(n.buffer),o=We.enc(e);return r.setInt32(0,o.lo,!0),r.setInt32(4,o.hi,!0),this.raw(n)}fixed64(e){let n=new Uint8Array(8),r=new DataView(n.buffer),o=We.uEnc(e);return r.setInt32(0,o.lo,!0),r.setInt32(4,o.hi,!0),this.raw(n)}int64(e){let n=We.enc(e);return Ao(n.lo,n.hi,this.buf),this}sint64(e){let n=We.enc(e),r=n.hi>>31,o=n.lo<<1^r,i=(n.hi<<1|n.lo>>>31)^r;return Ao(o,i,this.buf),this}uint64(e){let n=We.uEnc(e);return Ao(n.lo,n.hi,this.buf),this}},A=class{constructor(e,n=qs().decodeUtf8){this.decodeUtf8=n,this.varint64=nc,this.uint32=ic,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 St.Varint:for(;this.buf[this.pos++]&128;);break;case St.Bit64:this.pos+=4;case St.Bit32:this.pos+=4;break;case St.LengthDelimited:let i=this.uint32();this.pos+=i;break;case St.StartGroup:if(r<=0)throw new Error("maximum recursion depth reached");for(;;){let[s,a]=this.tag();if(a===St.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 We.dec(...this.varint64())}uint64(){return We.uDec(...this.varint64())}sint64(){let[e,n]=this.varint64(),r=-(e&1);return e=(e>>>1|(n&1)<<31)^r,n=n>>>1^r,We.dec(e,n)}bool(){let[e,n]=this.varint64();return e!==0||n!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return We.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return We.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){return this.decodeUtf8(this.bytes(),e)}};function Ws(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>am||t<lm)throw new Error("invalid int32: "+t)}function lc(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>sm||t<0)throw new Error("invalid uint32: "+t)}function cm(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>om||t<im))throw new Error("invalid float32: "+t)}var um=(function(t){return t[t.NULL_VALUE=0]="NULL_VALUE",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t})({});function Xs(){return{fields:{}}}var tr={encode(t,e=new F){return Object.entries(t.fields).forEach(([n,r])=>{r!==void 0&&Zs.encode({key:n,value:r},e.uint32(10).fork()).join()}),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Xs();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:{if(i!==10)break;let s=Zs.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 tr.fromPartial(t??{})},fromPartial(t){let e=Xs();return e.fields=Object.entries(t.fields??{}).reduce((n,[r,o])=>(o!==void 0&&(n[r]=o),n),{}),e},wrap(t){let e=Xs();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 cc(){return{key:"",value:void 0}}var Zs={encode(t,e=new F){return t.key!==""&&e.uint32(10).string(t.key),t.value!==void 0&&O.encode(O.wrap(t.value),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=cc();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=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Zs.fromPartial(t??{})},fromPartial(t){let e=cc();return e.key=t.key??"",e.value=t.value??void 0,e}};function Ys(){return{nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0}}var O={encode(t,e=new F){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&&tr.encode(tr.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 A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Ys();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=tr.unwrap(tr.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 O.fromPartial(t??{})},fromPartial(t){let e=Ys();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=Ys();if(t===null)e.nullValue=um.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 Ks(){return{values:[]}}var nr={encode(t,e=new F){for(let n of t.values)O.encode(O.wrap(n),e.uint32(10).fork()).join();return e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Ks();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.values.push(O.unwrap(O.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=Ks();return e.values=t.values?.map(n=>n)||[],e},wrap(t){let e=Ks();return e.values=t??[],e},unwrap(t){return t?.hasOwnProperty("values")&&globalThis.Array.isArray(t.values)?t.values:t}},dm=(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 uc(){return{op:0,path:"",from:void 0,value:void 0}}var Io={encode(t,e=new F){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&&O.encode(O.wrap(t.value),e.uint32(34).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=uc();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=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Io.fromPartial(t??{})},fromPartial(t){let e=uc();return e.op=t.op??0,e.path=t.path??"",e.from=t.from??void 0,e.value=t.value??void 0,e}};function dc(){return{id:"",type:"",function:void 0}}var Co={encode(t,e=new F){return t.id!==""&&e.uint32(10).string(t.id),t.type!==""&&e.uint32(18).string(t.type),t.function!==void 0&&Ro.encode(t.function,e.uint32(26).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=dc();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=Ro.decode(n,n.uint32());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Co.fromPartial(t??{})},fromPartial(t){let e=dc();return e.id=t.id??"",e.type=t.type??"",e.function=t.function!==void 0&&t.function!==null?Ro.fromPartial(t.function):void 0,e}};function pc(){return{name:"",arguments:""}}var Ro={encode(t,e=new F){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 A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=pc();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 Ro.fromPartial(t??{})},fromPartial(t){let e=pc();return e.name=t.name??"",e.arguments=t.arguments??"",e}};function hc(){return{value:"",mimeType:""}}var No={encode(t,e=new F){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 A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=hc();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 No.fromPartial(t??{})},fromPartial(t){let e=hc();return e.value=t.value??"",e.mimeType=t.mimeType??"",e}};function fc(){return{value:"",mimeType:void 0}}var Oo={encode(t,e=new F){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 A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=fc();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 Oo.fromPartial(t??{})},fromPartial(t){let e=fc();return e.value=t.value??"",e.mimeType=t.mimeType??void 0,e}};function mc(){return{data:void 0,url:void 0}}var De={encode(t,e=new F){return t.data!==void 0&&No.encode(t.data,e.uint32(10).fork()).join(),t.url!==void 0&&Oo.encode(t.url,e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=mc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.data=No.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.url=Oo.decode(n,n.uint32());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return De.fromPartial(t??{})},fromPartial(t){let e=mc();return e.data=t.data!==void 0&&t.data!==null?No.fromPartial(t.data):void 0,e.url=t.url!==void 0&&t.url!==null?Oo.fromPartial(t.url):void 0,e}};function gc(){return{text:""}}var Mo={encode(t,e=new F){return t.text!==""&&e.uint32(10).string(t.text),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=gc();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 Mo.fromPartial(t??{})},fromPartial(t){let e=gc();return e.text=t.text??"",e}};function vc(){return{source:void 0,metadata:void 0}}var Lo={encode(t,e=new F){return t.source!==void 0&&De.encode(t.source,e.uint32(10).fork()).join(),t.metadata!==void 0&&O.encode(O.wrap(t.metadata),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=vc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=De.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Lo.fromPartial(t??{})},fromPartial(t){let e=vc();return e.source=t.source!==void 0&&t.source!==null?De.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function bc(){return{source:void 0,metadata:void 0}}var Po={encode(t,e=new F){return t.source!==void 0&&De.encode(t.source,e.uint32(10).fork()).join(),t.metadata!==void 0&&O.encode(O.wrap(t.metadata),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=bc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=De.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Po.fromPartial(t??{})},fromPartial(t){let e=bc();return e.source=t.source!==void 0&&t.source!==null?De.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function yc(){return{source:void 0,metadata:void 0}}var Do={encode(t,e=new F){return t.source!==void 0&&De.encode(t.source,e.uint32(10).fork()).join(),t.metadata!==void 0&&O.encode(O.wrap(t.metadata),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=yc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=De.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Do.fromPartial(t??{})},fromPartial(t){let e=yc();return e.source=t.source!==void 0&&t.source!==null?De.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function xc(){return{source:void 0,metadata:void 0}}var Uo={encode(t,e=new F){return t.source!==void 0&&De.encode(t.source,e.uint32(10).fork()).join(),t.metadata!==void 0&&O.encode(O.wrap(t.metadata),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=xc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=De.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Uo.fromPartial(t??{})},fromPartial(t){let e=xc();return e.source=t.source!==void 0&&t.source!==null?De.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function Ec(){return{text:void 0,image:void 0,audio:void 0,video:void 0,document:void 0}}var Ho={encode(t,e=new F){return t.text!==void 0&&Mo.encode(t.text,e.uint32(10).fork()).join(),t.image!==void 0&&Lo.encode(t.image,e.uint32(18).fork()).join(),t.audio!==void 0&&Po.encode(t.audio,e.uint32(26).fork()).join(),t.video!==void 0&&Do.encode(t.video,e.uint32(34).fork()).join(),t.document!==void 0&&Uo.encode(t.document,e.uint32(42).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Ec();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.text=Mo.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.image=Lo.decode(n,n.uint32());continue;case 3:if(i!==26)break;o.audio=Po.decode(n,n.uint32());continue;case 4:if(i!==34)break;o.video=Do.decode(n,n.uint32());continue;case 5:if(i!==42)break;o.document=Uo.decode(n,n.uint32());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Ho.fromPartial(t??{})},fromPartial(t){let e=Ec();return e.text=t.text!==void 0&&t.text!==null?Mo.fromPartial(t.text):void 0,e.image=t.image!==void 0&&t.image!==null?Lo.fromPartial(t.image):void 0,e.audio=t.audio!==void 0&&t.audio!==null?Po.fromPartial(t.audio):void 0,e.video=t.video!==void 0&&t.video!==null?Do.fromPartial(t.video):void 0,e.document=t.document!==void 0&&t.document!==null?Uo.fromPartial(t.document):void 0,e}};function Tc(){return{id:"",role:"",content:void 0,name:void 0,toolCalls:[],toolCallId:void 0,error:void 0,contentParts:[]}}var Go={encode(t,e=new F){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)Co.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)Ho.encode(n,e.uint32(66).fork()).join();return e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Tc();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(Co.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(Ho.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Go.fromPartial(t??{})},fromPartial(t){let e=Tc();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=>Co.fromPartial(n))||[],e.toolCallId=t.toolCallId??void 0,e.error=t.error??void 0,e.contentParts=t.contentParts?.map(n=>Ho.fromPartial(n))||[],e}};function wc(){return{id:"",reason:"",message:void 0,toolCallId:void 0,responseSchema:void 0,expiresAt:void 0,metadata:void 0}}var zo={encode(t,e=new F){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&&O.encode(O.wrap(t.responseSchema),e.uint32(42).fork()).join(),t.expiresAt!==void 0&&e.uint32(50).string(t.expiresAt),t.metadata!==void 0&&O.encode(O.wrap(t.metadata),e.uint32(58).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=wc();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=O.unwrap(O.decode(n,n.uint32()));continue;case 6:if(i!==50)break;o.expiresAt=n.string();continue;case 7:if(i!==58)break;o.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return zo.fromPartial(t??{})},fromPartial(t){let e=wc();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}},pm=(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.UNRECOGNIZED=-1]="UNRECOGNIZED",t})({});function Sc(){return{type:0,timestamp:void 0,rawEvent:void 0}}var M={encode(t,e=new F){return t.type!==0&&e.uint32(8).int32(t.type),t.timestamp!==void 0&&e.uint32(16).int64(t.timestamp),t.rawEvent!==void 0&&O.encode(O.wrap(t.rawEvent),e.uint32(26).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Sc();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=hm(n.int64());continue;case 3:if(i!==26)break;o.rawEvent=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return M.fromPartial(t??{})},fromPartial(t){let e=Sc();return e.type=t.type??0,e.timestamp=t.timestamp??void 0,e.rawEvent=t.rawEvent??void 0,e}};function _c(){return{baseEvent:void 0,messageId:"",role:void 0,name:void 0}}var Fo={encode(t,e=new F){return t.baseEvent!==void 0&&M.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),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=_c();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.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}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Fo.fromPartial(t??{})},fromPartial(t){let e=_c();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.messageId=t.messageId??"",e.role=t.role??void 0,e.name=t.name??void 0,e}};function Ac(){return{baseEvent:void 0,messageId:"",delta:""}}var $o={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.messageId!==""&&e.uint32(18).string(t.messageId),t.delta!==""&&e.uint32(26).string(t.delta),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Ac();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.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}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return $o.fromPartial(t??{})},fromPartial(t){let e=Ac();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.messageId=t.messageId??"",e.delta=t.delta??"",e}};function kc(){return{baseEvent:void 0,messageId:""}}var Bo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.messageId!==""&&e.uint32(18).string(t.messageId),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=kc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.messageId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Bo.fromPartial(t??{})},fromPartial(t){let e=kc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.messageId=t.messageId??"",e}};function Ic(){return{baseEvent:void 0,toolCallId:"",toolCallName:"",parentMessageId:void 0}}var Vo={encode(t,e=new F){return t.baseEvent!==void 0&&M.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),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Ic();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.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}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Vo.fromPartial(t??{})},fromPartial(t){let e=Ic();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.toolCallId=t.toolCallId??"",e.toolCallName=t.toolCallName??"",e.parentMessageId=t.parentMessageId??void 0,e}};function Cc(){return{baseEvent:void 0,toolCallId:"",delta:""}}var jo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.toolCallId!==""&&e.uint32(18).string(t.toolCallId),t.delta!==""&&e.uint32(26).string(t.delta),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Cc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.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}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return jo.fromPartial(t??{})},fromPartial(t){let e=Cc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.toolCallId=t.toolCallId??"",e.delta=t.delta??"",e}};function Rc(){return{baseEvent:void 0,toolCallId:""}}var qo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.toolCallId!==""&&e.uint32(18).string(t.toolCallId),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Rc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.toolCallId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return qo.fromPartial(t??{})},fromPartial(t){let e=Rc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.toolCallId=t.toolCallId??"",e}};function Nc(){return{baseEvent:void 0,snapshot:void 0}}var Wo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.snapshot!==void 0&&O.encode(O.wrap(t.snapshot),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Nc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.snapshot=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Wo.fromPartial(t??{})},fromPartial(t){let e=Nc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.snapshot=t.snapshot??void 0,e}};function Oc(){return{baseEvent:void 0,delta:[]}}var Xo={encode(t,e=new F){t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join();for(let n of t.delta)Io.encode(n,e.uint32(18).fork()).join();return e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Oc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.delta.push(Io.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Xo.fromPartial(t??{})},fromPartial(t){let e=Oc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.delta=t.delta?.map(n=>Io.fromPartial(n))||[],e}};function Mc(){return{baseEvent:void 0,messages:[]}}var Yo={encode(t,e=new F){t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join();for(let n of t.messages)Go.encode(n,e.uint32(18).fork()).join();return e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Mc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.messages.push(Go.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Yo.fromPartial(t??{})},fromPartial(t){let e=Mc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.messages=t.messages?.map(n=>Go.fromPartial(n))||[],e}};function Lc(){return{baseEvent:void 0,event:void 0,source:void 0}}var Ko={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.event!==void 0&&O.encode(O.wrap(t.event),e.uint32(18).fork()).join(),t.source!==void 0&&e.uint32(26).string(t.source),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Lc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.event=O.unwrap(O.decode(n,n.uint32()));continue;case 3:if(i!==26)break;o.source=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Ko.fromPartial(t??{})},fromPartial(t){let e=Lc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.event=t.event??void 0,e.source=t.source??void 0,e}};function Pc(){return{baseEvent:void 0,name:"",value:void 0}}var Zo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.name!==""&&e.uint32(18).string(t.name),t.value!==void 0&&O.encode(O.wrap(t.value),e.uint32(26).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Pc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.name=n.string();continue;case 3:if(i!==26)break;o.value=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Zo.fromPartial(t??{})},fromPartial(t){let e=Pc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.name=t.name??"",e.value=t.value??void 0,e}};function Dc(){return{baseEvent:void 0,threadId:"",runId:""}}var Jo={encode(t,e=new F){return t.baseEvent!==void 0&&M.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 A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Dc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.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 Jo.fromPartial(t??{})},fromPartial(t){let e=Dc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.threadId=t.threadId??"",e.runId=t.runId??"",e}};function Uc(){return{baseEvent:void 0,threadId:"",runId:"",result:void 0,outcome:"",interrupts:[]}}var Qo={encode(t,e=new F){t.baseEvent!==void 0&&M.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&&O.encode(O.wrap(t.result),e.uint32(34).fork()).join(),t.outcome!==""&&e.uint32(42).string(t.outcome);for(let n of t.interrupts)zo.encode(n,e.uint32(50).fork()).join();return e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Uc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.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=O.unwrap(O.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(zo.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Qo.fromPartial(t??{})},fromPartial(t){let e=Uc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.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=>zo.fromPartial(n))||[],e}};function Hc(){return{baseEvent:void 0,code:void 0,message:""}}var ei={encode(t,e=new F){return t.baseEvent!==void 0&&M.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),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Hc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.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}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return ei.fromPartial(t??{})},fromPartial(t){let e=Hc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.code=t.code??void 0,e.message=t.message??"",e}};function Gc(){return{baseEvent:void 0,stepName:""}}var ti={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.stepName!==""&&e.uint32(18).string(t.stepName),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Gc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.stepName=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return ti.fromPartial(t??{})},fromPartial(t){let e=Gc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.stepName=t.stepName??"",e}};function zc(){return{baseEvent:void 0,stepName:""}}var ni={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.stepName!==""&&e.uint32(18).string(t.stepName),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=zc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.stepName=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return ni.fromPartial(t??{})},fromPartial(t){let e=zc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.stepName=t.stepName??"",e}};function Fc(){return{baseEvent:void 0,messageId:void 0,role:void 0,delta:void 0,name:void 0}}var ri={encode(t,e=new F){return t.baseEvent!==void 0&&M.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),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Fc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.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}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return ri.fromPartial(t??{})},fromPartial(t){let e=Fc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.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}};function $c(){return{baseEvent:void 0,toolCallId:void 0,toolCallName:void 0,parentMessageId:void 0,delta:void 0}}var oi={encode(t,e=new F){return t.baseEvent!==void 0&&M.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),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=$c();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.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}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return oi.fromPartial(t??{})},fromPartial(t){let e=$c();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.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}};function Bc(){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}}var Vc={encode(t,e=new F){return t.textMessageStart!==void 0&&Fo.encode(t.textMessageStart,e.uint32(10).fork()).join(),t.textMessageContent!==void 0&&$o.encode(t.textMessageContent,e.uint32(18).fork()).join(),t.textMessageEnd!==void 0&&Bo.encode(t.textMessageEnd,e.uint32(26).fork()).join(),t.toolCallStart!==void 0&&Vo.encode(t.toolCallStart,e.uint32(34).fork()).join(),t.toolCallArgs!==void 0&&jo.encode(t.toolCallArgs,e.uint32(42).fork()).join(),t.toolCallEnd!==void 0&&qo.encode(t.toolCallEnd,e.uint32(50).fork()).join(),t.stateSnapshot!==void 0&&Wo.encode(t.stateSnapshot,e.uint32(58).fork()).join(),t.stateDelta!==void 0&&Xo.encode(t.stateDelta,e.uint32(66).fork()).join(),t.messagesSnapshot!==void 0&&Yo.encode(t.messagesSnapshot,e.uint32(74).fork()).join(),t.raw!==void 0&&Ko.encode(t.raw,e.uint32(82).fork()).join(),t.custom!==void 0&&Zo.encode(t.custom,e.uint32(90).fork()).join(),t.runStarted!==void 0&&Jo.encode(t.runStarted,e.uint32(98).fork()).join(),t.runFinished!==void 0&&Qo.encode(t.runFinished,e.uint32(106).fork()).join(),t.runError!==void 0&&ei.encode(t.runError,e.uint32(114).fork()).join(),t.stepStarted!==void 0&&ti.encode(t.stepStarted,e.uint32(122).fork()).join(),t.stepFinished!==void 0&&ni.encode(t.stepFinished,e.uint32(130).fork()).join(),t.textMessageChunk!==void 0&&ri.encode(t.textMessageChunk,e.uint32(138).fork()).join(),t.toolCallChunk!==void 0&&oi.encode(t.toolCallChunk,e.uint32(146).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Bc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.textMessageStart=Fo.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.textMessageContent=$o.decode(n,n.uint32());continue;case 3:if(i!==26)break;o.textMessageEnd=Bo.decode(n,n.uint32());continue;case 4:if(i!==34)break;o.toolCallStart=Vo.decode(n,n.uint32());continue;case 5:if(i!==42)break;o.toolCallArgs=jo.decode(n,n.uint32());continue;case 6:if(i!==50)break;o.toolCallEnd=qo.decode(n,n.uint32());continue;case 7:if(i!==58)break;o.stateSnapshot=Wo.decode(n,n.uint32());continue;case 8:if(i!==66)break;o.stateDelta=Xo.decode(n,n.uint32());continue;case 9:if(i!==74)break;o.messagesSnapshot=Yo.decode(n,n.uint32());continue;case 10:if(i!==82)break;o.raw=Ko.decode(n,n.uint32());continue;case 11:if(i!==90)break;o.custom=Zo.decode(n,n.uint32());continue;case 12:if(i!==98)break;o.runStarted=Jo.decode(n,n.uint32());continue;case 13:if(i!==106)break;o.runFinished=Qo.decode(n,n.uint32());continue;case 14:if(i!==114)break;o.runError=ei.decode(n,n.uint32());continue;case 15:if(i!==122)break;o.stepStarted=ti.decode(n,n.uint32());continue;case 16:if(i!==130)break;o.stepFinished=ni.decode(n,n.uint32());continue;case 17:if(i!==138)break;o.textMessageChunk=ri.decode(n,n.uint32());continue;case 18:if(i!==146)break;o.toolCallChunk=oi.decode(n,n.uint32());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Vc.fromPartial(t??{})},fromPartial(t){let e=Bc();return e.textMessageStart=t.textMessageStart!==void 0&&t.textMessageStart!==null?Fo.fromPartial(t.textMessageStart):void 0,e.textMessageContent=t.textMessageContent!==void 0&&t.textMessageContent!==null?$o.fromPartial(t.textMessageContent):void 0,e.textMessageEnd=t.textMessageEnd!==void 0&&t.textMessageEnd!==null?Bo.fromPartial(t.textMessageEnd):void 0,e.toolCallStart=t.toolCallStart!==void 0&&t.toolCallStart!==null?Vo.fromPartial(t.toolCallStart):void 0,e.toolCallArgs=t.toolCallArgs!==void 0&&t.toolCallArgs!==null?jo.fromPartial(t.toolCallArgs):void 0,e.toolCallEnd=t.toolCallEnd!==void 0&&t.toolCallEnd!==null?qo.fromPartial(t.toolCallEnd):void 0,e.stateSnapshot=t.stateSnapshot!==void 0&&t.stateSnapshot!==null?Wo.fromPartial(t.stateSnapshot):void 0,e.stateDelta=t.stateDelta!==void 0&&t.stateDelta!==null?Xo.fromPartial(t.stateDelta):void 0,e.messagesSnapshot=t.messagesSnapshot!==void 0&&t.messagesSnapshot!==null?Yo.fromPartial(t.messagesSnapshot):void 0,e.raw=t.raw!==void 0&&t.raw!==null?Ko.fromPartial(t.raw):void 0,e.custom=t.custom!==void 0&&t.custom!==null?Zo.fromPartial(t.custom):void 0,e.runStarted=t.runStarted!==void 0&&t.runStarted!==null?Jo.fromPartial(t.runStarted):void 0,e.runFinished=t.runFinished!==void 0&&t.runFinished!==null?Qo.fromPartial(t.runFinished):void 0,e.runError=t.runError!==void 0&&t.runError!==null?ei.fromPartial(t.runError):void 0,e.stepStarted=t.stepStarted!==void 0&&t.stepStarted!==null?ti.fromPartial(t.stepStarted):void 0,e.stepFinished=t.stepFinished!==void 0&&t.stepFinished!==null?ni.fromPartial(t.stepFinished):void 0,e.textMessageChunk=t.textMessageChunk!==void 0&&t.textMessageChunk!==null?ri.fromPartial(t.textMessageChunk):void 0,e.toolCallChunk=t.toolCallChunk!==void 0&&t.toolCallChunk!==null?oi.fromPartial(t.toolCallChunk):void 0,e}};function hm(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 ko=t=>{if(!(!t||typeof t!="object")){if(t.data)return{type:"data",value:t.data.value,mimeType:t.data.mimeType};if(t.url)return{type:"url",value:t.url.value,mimeType:t.url.mimeType}}},fm=t=>{if(!(!t||typeof t!="object")){if(t.text)return{type:"text",text:t.text.text};if(t.image)return{type:"image",source:ko(t.image.source),metadata:t.image.metadata};if(t.audio)return{type:"audio",source:ko(t.audio.source),metadata:t.audio.metadata};if(t.video)return{type:"video",source:ko(t.video.source),metadata:t.video.metadata};if(t.document)return{type:"document",source:ko(t.document.source),metadata:t.document.metadata}}};function jc(t){let e=Vc.decode(t),n=Object.values(e).find(r=>r!==void 0);if(!n)throw new Error("Invalid event");if(n.type=pm[n.baseEvent.type],n.timestamp=n.baseEvent.timestamp,n.rawEvent=n.baseEvent.rawEvent,delete n.baseEvent,n.type===v.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=>fm(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===v.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===v.STATE_DELTA)for(let r of n.delta)r.op=dm[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]}),Br.parse(n)}var Js="application/vnd.ag-ui.event+proto";var gm=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,Qs=t=>{if(typeof t!="string")throw new TypeError("Invalid argument expected string");let e=t.match(gm);if(!e)throw new Error(`Invalid argument not valid semver ('${t}' received)`);return e.shift(),e},qc=t=>t==="*"||t==="x"||t==="X",Wc=t=>{let e=parseInt(t,10);return isNaN(e)?t:e},vm=(t,e)=>typeof t!=typeof e?[String(t),String(e)]:[t,e],bm=(t,e)=>{if(qc(t)||qc(e))return 0;let[n,r]=vm(Wc(t),Wc(e));return n>r?1:n<r?-1:0},ea=(t,e)=>{for(let n=0;n<Math.max(t.length,e.length);n++){let r=bm(t[n]||"0",e[n]||"0");if(r!==0)return r}return 0};var rr=(t,e)=>{let n=Qs(t),r=Qs(e),o=n.pop(),i=r.pop(),s=ea(n,r);return s!==0?s:o&&i?ea(o.split("."),i.split(".")):o||i?o?-1:1:0};var q=t=>{if(typeof structuredClone=="function")return structuredClone(t);try{return JSON.parse(JSON.stringify(t))}catch{return Array.isArray(t)?[...t]:{...t}}};function Ue(){return yt()}function ra(t){if(Object.freeze(t),typeof t=="object"&&t)for(let e of Object.values(t))typeof e=="object"&&e&&!Object.isFrozen(e)&&ra(e);return t}var Xc=512*1024;function Yc(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 c=a[l];if(r+=c.length,r>n)return!0;o.push(s[c])}}}}return!1}async function K(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&&!Yc(e,n,Xc),l=a?q(e):e,c=a?q(n):n,h=!1,m=!1,y;for(let f of t)try{a&&(ra(l),ra(c));let p=await r(f,l,c);if(p===void 0)continue;let g=!1;if(p.messages!==void 0&&p.messages!==l&&(l=q(p.messages),h=!0,g=!0),p.state!==void 0&&p.state!==c&&(c=q(p.state),m=!0,g=!0),a&&g&&Yc(l,c,Xc)&&(a=!1),y=p.stopPropagation,y===!0)break}catch(p){if(s&&p instanceof TypeError){if(i)throw p;console.error("AG-UI: Subscriber attempted to mutate frozen inputs in-place. Return mutations via AgentStateMutation instead of mutating directly.",p)}else i||console.error("Subscriber error:",p);continue}return{...h?{messages:Object.isFrozen(l)?q(l):l}:{},...m?{state:Object.isFrozen(c)?q(c):c}:{},...y===void 0?{}:{stopPropagation:y}}}function ii(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 oa)return t;if(t===!0)return new oa(ii(!0))}var oa=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 ta(t){return t.enabled?new oa(t):void 0}function ym(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}var tu=(t,e,n,r,o)=>{let i=or(o),s=q(n.messages),a=q(t.state),l={},c=m=>{m.messages!==void 0&&(s=m.messages,l.messages=m.messages),m.state!==void 0&&(a=m.state,l.state=m.state)},h=()=>{let m=q(l);return l={},m.messages!==void 0||m.state!==void 0?ue(m):so};return e.pipe(To(async m=>{let y=await K(r,s,a,(f,p,g)=>f.onEvent?.({event:m,agent:n,input:t,messages:p,state:g}));if(c(y),y.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}),y.stopPropagation===!0)return h();switch(m.type){case v.TEXT_MESSAGE_START:{let f=await K(r,s,a,(p,g,x)=>p.onTextMessageStartEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{messageId:p,role:g="assistant",name:x}=m;if(!s.find(_=>_.id===p)){let _={id:p,role:g,content:"",...x!==void 0&&{name:x}};s.push(_),c({messages:s})}}return h()}case v.TEXT_MESSAGE_CONTENT:{let{messageId:f,delta:p}=m,g=s.find(_=>_.id===f);if(!g)return console.warn(`TEXT_MESSAGE_CONTENT: No message found with ID '${f}'`),h();let x=await K(r,s,a,(_,w,C)=>_.onTextMessageContentEvent?.({event:m,messages:w,state:C,agent:n,input:t,textMessageBuffer:typeof g.content=="string"?g.content:""}));return c(x),x.stopPropagation!==!0&&(g.content=`${typeof g.content=="string"?g.content:""}${p}`,c({messages:s})),h()}case v.TEXT_MESSAGE_END:{let{messageId:f}=m,p=s.find(g=>g.id===f);return p?(c(await K(r,s,a,(g,x,_)=>g.onTextMessageEndEvent?.({event:m,messages:x,state:_,agent:n,input:t,textMessageBuffer:typeof p.content=="string"?p.content:""}))),await Promise.all(r.map(g=>{g.onNewMessage?.({message:p,messages:s,state:a,agent:n,input:t})})),h()):(console.warn(`TEXT_MESSAGE_END: No message found with ID '${f}'`),h())}case v.TOOL_CALL_START:{let f=await K(r,s,a,(p,g,x)=>p.onToolCallStartEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{toolCallId:p,toolCallName:g,parentMessageId:x}=m,_=ym(s,x,p);_.toolCalls??=[],_.toolCalls.push({id:p,type:"function",function:{name:g,arguments:""}}),c({messages:s})}return h()}case v.TOOL_CALL_ARGS:{let{toolCallId:f,delta:p}=m,g=s.find(w=>w.toolCalls?.some(C=>C.id===f));if(!g)return console.warn(`TOOL_CALL_ARGS: No message found containing tool call with ID '${f}'`),h();let x=g.toolCalls?.find(w=>w.id===f);if(!x)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${f}'`),h();let _=await K(r,s,a,(w,C,H)=>{let U=x.function.arguments,Y=x.function.name,re={};try{re=So(U)}catch{}return w.onToolCallArgsEvent?.({event:m,messages:C,state:H,agent:n,input:t,toolCallBuffer:U,toolCallName:Y,partialToolCallArgs:re})});return c(_),_.stopPropagation!==!0&&(x.function.arguments+=p,c({messages:s})),h()}case v.TOOL_CALL_END:{let{toolCallId:f}=m,p=s.find(x=>x.toolCalls?.some(_=>_.id===f));if(!p)return console.warn(`TOOL_CALL_END: No message found containing tool call with ID '${f}'`),h();let g=p.toolCalls?.find(x=>x.id===f);return g?(c(await K(r,s,a,(x,_,w)=>{let C=g.function.arguments,H=g.function.name,U={};try{U=JSON.parse(C)}catch{}return x.onToolCallEndEvent?.({event:m,messages:_,state:w,agent:n,input:t,toolCallName:H,toolCallArgs:U})})),await Promise.all(r.map(x=>{x.onNewToolCall?.({toolCall:g,messages:s,state:a,agent:n,input:t})})),h()):(console.warn(`TOOL_CALL_END: No tool call found with ID '${f}'`),h())}case v.TOOL_CALL_RESULT:{let f=await K(r,s,a,(p,g,x)=>p.onToolCallResultEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{messageId:p,toolCallId:g,content:x,role:_}=m,w={id:p,toolCallId:g,role:_||"tool",content:x},C=s.findIndex(H=>H.role==="assistant"&&H.toolCalls?.some(U=>U.id===g));if(C===-1)s.push(w);else{let H=C+1;for(;H<s.length&&s[H].role==="tool";)H++;s.splice(H,0,w)}await Promise.all(r.map(H=>{H.onNewMessage?.({message:w,messages:s,state:a,agent:n,input:t})})),c({messages:s})}return h()}case v.STATE_SNAPSHOT:{let f=await K(r,s,a,(p,g,x)=>p.onStateSnapshotEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{snapshot:p}=m;a=p,c({state:a})}return h()}case v.STATE_DELTA:{let f=await K(r,s,a,(p,g,x)=>p.onStateDeltaEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{delta:p}=m;try{a=Zr.applyPatch(a,p,!0,!1).newDocument,c({state:a})}catch(g){let x=g instanceof Error?g.message:String(g);console.warn(`Failed to apply state patch:
|
|
4
|
+
`):"",this.name="UnsubscriptionError",this.errors=n}});function Qn(t,e){if(t){var n=t.indexOf(e);0<=n&&t.splice(n,1)}}var Sn=(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=ht(s),l=a.next();!l.done;l=a.next()){var c=l.value;c.remove(this)}}catch(g){e={error:g}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}else s.remove(this);var h=this.initialTeardown;if(B(h))try{h()}catch(g){i=g instanceof no?g.errors:[g]}var m=this._finalizers;if(m){this._finalizers=null;try{for(var y=ht(m),f=y.next();!f.done;f=y.next()){var p=f.value;try{ql(p)}catch(g){i=i??[],g instanceof no?i=Tn(Tn([],En(i)),En(g.errors)):i.push(g)}}}catch(g){r={error:g}}finally{try{f&&!f.done&&(o=y.return)&&o.call(y)}finally{if(r)throw r.error}}}if(i)throw new no(i)}},t.prototype.add=function(e){var n;if(e&&e!==this)if(this.closed)ql(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)&&Qn(n,e)},t.prototype.remove=function(e){var n=this._finalizers;n&&Qn(n,e),e instanceof t&&e._removeParent(this)},t.EMPTY=(function(){var e=new t;return e.closed=!0,e})(),t})();var Ds=Sn.EMPTY;function ro(t){return t instanceof Sn||t&&"closed"in t&&B(t.remove)&&B(t.add)&&B(t.unsubscribe)}function ql(t){B(t)?t():t.unsubscribe()}var We={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var An={setTimeout:function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=An.delegate;return o?.setTimeout?o.setTimeout.apply(o,Tn([t,e],En(n))):setTimeout.apply(void 0,Tn([t,e],En(n)))},clearTimeout:function(t){var e=An.delegate;return(e?.clearTimeout||clearTimeout)(t)},delegate:void 0};function oo(t){An.setTimeout(function(){var e=We.onUnhandledError;if(e)e(t);else throw t})}function er(){}var Wl=(function(){return Us("C",void 0,void 0)})();function Xl(t){return Us("E",void 0,t)}function Yl(t){return Us("N",t,void 0)}function Us(t,e,n){return{kind:t,value:e,error:n}}var Kt=null;function kn(t){if(We.useDeprecatedSynchronousErrorHandling){var e=!Kt;if(e&&(Kt={errorThrown:!1,error:null}),t(),e){var n=Kt,r=n.errorThrown,o=n.error;if(Kt=null,r)throw o}}else t()}function Kl(t){We.useDeprecatedSynchronousErrorHandling&&Kt&&(Kt.errorThrown=!0,Kt.error=t)}var tr=(function(t){it(e,t);function e(n){var r=t.call(this)||this;return r.isStopped=!1,n?(r.destination=n,ro(n)&&n.add(r)):r.destination=am,r}return e.create=function(n,r,o){return new so(n,r,o)},e.prototype.next=function(n){this.isStopped?zs(Yl(n),this):this._next(n)},e.prototype.error=function(n){this.isStopped?zs(Xl(n),this):(this.isStopped=!0,this._error(n))},e.prototype.complete=function(){this.isStopped?zs(Wl,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})(Sn);var om=Function.prototype.bind;function Hs(t,e){return om.call(t,e)}var im=(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){io(r)}},t.prototype.error=function(e){var n=this.partialObserver;if(n.error)try{n.error(e)}catch(r){io(r)}else io(e)},t.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(n){io(n)}},t})(),so=(function(t){it(e,t);function e(n,r,o){var i=t.call(this)||this,s;if(B(n)||!n)s={next:n??void 0,error:r??void 0,complete:o??void 0};else{var a;i&&We.useDeprecatedNextContext?(a=Object.create(n),a.unsubscribe=function(){return i.unsubscribe()},s={next:n.next&&Hs(n.next,a),error:n.error&&Hs(n.error,a),complete:n.complete&&Hs(n.complete,a)}):s=n}return i.destination=new im(s),i}return e})(tr);function io(t){We.useDeprecatedSynchronousErrorHandling?Kl(t):oo(t)}function sm(t){throw t}function zs(t,e){var n=We.onStoppedNotification;n&&An.setTimeout(function(){return n(t,e)})}var am={closed:!0,next:er,error:sm,complete:er};var Cn=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function In(t){return t}function ao(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Gs(t)}function Gs(t){return t.length===0?In:t.length===1?t[0]:function(n){return t.reduce(function(r,o){return o(r)},n)}}var te=(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=cm(e)?e:new so(e,n,r);return kn(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=Zl(n),new n(function(o,i){var s=new so({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[Cn]=function(){return this},t.prototype.pipe=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return Gs(e)(this)},t.prototype.toPromise=function(e){var n=this;return e=Zl(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 Zl(t){var e;return(e=t??We.Promise)!==null&&e!==void 0?e:Promise}function lm(t){return t&&B(t.next)&&B(t.error)&&B(t.complete)}function cm(t){return t&&t instanceof tr||lm(t)&&ro(t)}function um(t){return B(t?.lift)}function fe(t){return function(e){if(um(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 ge(t,e,n,r,o){return new dm(t,e,n,r,o)}var dm=(function(t){it(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(c){try{r(c)}catch(h){n.error(h)}}:t.prototype._next,l._error=i?function(c){try{i(c)}catch(h){n.error(h)}finally{this.unsubscribe()}}:t.prototype._error,l._complete=o?function(){try{o()}catch(c){n.error(c)}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})(tr);var Jl=wn(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}});var st=(function(t){it(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 Ql(this,this);return r.operator=n,r},e.prototype._throwIfClosed=function(){if(this.closed)throw new Jl},e.prototype.next=function(n){var r=this;kn(function(){var o,i;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var s=ht(r.currentObservers),a=s.next();!a.done;a=s.next()){var l=a.value;l.next(n)}}catch(c){o={error:c}}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;kn(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;kn(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?Ds:(this.currentObservers=null,a.push(n),new Sn(function(){r.currentObservers=null,Qn(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 te;return n.source=this,n},e.create=function(n,r){return new Ql(n,r)},e})(te);var Ql=(function(t){it(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:Ds},e})(st);var Fs={now:function(){return(Fs.delegate||Date).now()},delegate:void 0};var lo=(function(t){it(e,t);function e(n,r,o){n===void 0&&(n=1/0),r===void 0&&(r=1/0),o===void 0&&(o=Fs);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(),c=0,h=1;h<i.length&&i[h]<=l;h+=2)c=h;c&&i.splice(0,c+1)}},e})(st);var co=new te(function(t){return t.complete()});function ec(t){return t&&B(t.schedule)}function pm(t){return t[t.length-1]}function tc(t){return ec(pm(t))?t.pop():void 0}var uo=(function(t){return t&&typeof t.length=="number"&&typeof t!="function"});function po(t){return B(t?.then)}function ho(t){return B(t[Cn])}function fo(t){return Symbol.asyncIterator&&B(t?.[Symbol.asyncIterator])}function mo(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 hm(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var go=hm();function vo(t){return B(t?.[go])}function bo(t){return Vl(this,arguments,function(){var n,r,o,i;return to(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,Yt(n.read())];case 3:return r=s.sent(),o=r.value,i=r.done,i?[4,Yt(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,Yt(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 yo(t){return B(t?.getReader)}function ve(t){if(t instanceof te)return t;if(t!=null){if(ho(t))return fm(t);if(uo(t))return mm(t);if(po(t))return gm(t);if(fo(t))return nc(t);if(vo(t))return vm(t);if(yo(t))return bm(t)}throw mo(t)}function fm(t){return new te(function(e){var n=t[Cn]();if(B(n.subscribe))return n.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function mm(t){return new te(function(e){for(var n=0;n<t.length&&!e.closed;n++)e.next(t[n]);e.complete()})}function gm(t){return new te(function(e){t.then(function(n){e.closed||(e.next(n),e.complete())},function(n){return e.error(n)}).then(null,oo)})}function vm(t){return new te(function(e){var n,r;try{for(var o=ht(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 nc(t){return new te(function(e){ym(t,e).catch(function(n){return e.error(n)})})}function bm(t){return nc(bo(t))}function ym(t,e){var n,r,o,i;return Bl(this,void 0,void 0,function(){var s,a;return to(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),n=jl(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 $e(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 xo(t,e){return e===void 0&&(e=0),fe(function(n,r){n.subscribe(ge(r,function(o){return $e(r,t,function(){return r.next(o)},e)},function(){return $e(r,t,function(){return r.complete()},e)},function(o){return $e(r,t,function(){return r.error(o)},e)}))})}function _o(t,e){return e===void 0&&(e=0),fe(function(n,r){r.add(t.schedule(function(){return n.subscribe(r)},e))})}function rc(t,e){return ve(t).pipe(_o(e),xo(e))}function oc(t,e){return ve(t).pipe(_o(e),xo(e))}function ic(t,e){return new te(function(n){var r=0;return e.schedule(function(){r===t.length?n.complete():(n.next(t[r++]),n.closed||this.schedule())})})}function sc(t,e){return new te(function(n){var r;return $e(n,e,function(){r=t[go](),$e(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 B(r?.return)&&r.return()}})}function Eo(t,e){if(!t)throw new Error("Iterable cannot be null");return new te(function(n){$e(n,e,function(){var r=t[Symbol.asyncIterator]();$e(n,e,function(){r.next().then(function(o){o.done?n.complete():n.next(o.value)})},0,!0)})})}function ac(t,e){return Eo(bo(t),e)}function lc(t,e){if(t!=null){if(ho(t))return rc(t,e);if(uo(t))return ic(t,e);if(po(t))return oc(t,e);if(fo(t))return Eo(t,e);if(vo(t))return sc(t,e);if(yo(t))return ac(t,e)}throw mo(t)}function Zt(t,e){return e?lc(t,e):ve(t)}function ue(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=tc(t);return Zt(t,n)}function ne(t,e){var n=B(t)?t:function(){return t},r=function(o){return o.error(n())};return new te(e?function(o){return e.schedule(r,0,o)}:r)}var cc=wn(function(t){return function(){t(this),this.name="EmptyError",this.message="no elements in sequence"}});function To(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 cc)}})})}function Jt(t,e){return fe(function(n,r){var o=0;n.subscribe(ge(r,function(i){r.next(t.call(e,i,o++))}))})}function uc(t,e,n,r,o,i,s,a){var l=[],c=0,h=0,m=!1,y=function(){m&&!l.length&&!c&&e.complete()},f=function(g){return c<r?p(g):l.push(g)},p=function(g){i&&e.next(g),c++;var x=!1;ve(n(g,h++)).subscribe(ge(e,function(S){o?.(S),i?f(S):e.next(S)},function(){x=!0},void 0,function(){if(x)try{c--;for(var S=function(){var T=l.shift();s?$e(e,s,function(){return p(T)}):p(T)};l.length&&c<r;)S();y()}catch(T){e.error(T)}}))};return t.subscribe(ge(e,f,function(){m=!0,y()})),function(){a?.()}}function Me(t,e,n){return n===void 0&&(n=1/0),B(e)?Me(function(r,o){return Jt(function(i,s){return e(r,i,o,s)})(ve(t(r,o)))},n):(typeof e=="number"&&(n=e),fe(function(r,o){return uc(r,o,t,n)}))}function $s(t){return t===void 0&&(t=1/0),Me(In,t)}function wo(t){return new te(function(e){ve(t()).subscribe(e)})}function nr(t){return fe(function(e,n){var r=null,o=!1,i;r=e.subscribe(ge(n,void 0,void 0,function(s){i=ve(t(s,nr(t)(e))),r?(r.unsubscribe(),r=null,i.subscribe(n)):o=!0})),o&&(r.unsubscribe(),r=null,i.subscribe(n))})}function So(t,e){return B(e)?Me(t,e,1):Me(t,1)}function Bs(t){return fe(function(e,n){var r=!1;e.subscribe(ge(n,function(o){r=!0,n.next(o)},function(){r||n.next(t),n.complete()}))})}function Qt(t){return fe(function(e,n){try{e.subscribe(n)}finally{n.add(t)}})}function Vs(t,e){return fe(function(n,r){var o=null,i=0,s=!1,a=function(){return s&&!o&&r.complete()};n.subscribe(ge(r,function(l){o?.unsubscribe();var c=0,h=i++;ve(t(l,h)).subscribe(o=ge(r,function(m){return r.next(e?e(l,m,h,c++):m)},function(){o=null,a()}))},function(){s=!0,a()}))})}function Ao(t){return fe(function(e,n){ve(t).subscribe(ge(n,function(){return n.complete()},er)),!n.closed&&e.subscribe(n)})}function js(t,e,n){var r=B(t)||e||n?{next:t,error:e,complete:n}:t;return r?fe(function(o,i){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var a=!0;o.subscribe(ge(i,function(l){var c;(c=r.next)===null||c===void 0||c.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 c;a=!1,(c=r.error)===null||c===void 0||c.call(r,l),i.error(l)},function(){var l,c;a&&((l=r.unsubscribe)===null||l===void 0||l.call(r)),(c=r.finalize)===null||c===void 0||c.call(r)}))}):In}function dc(t){return` \r
|
|
5
|
+
`.indexOf(t)>=0}function ko(t){for(var e=["topLevel"],n=0,r,o,i,s=function(T){return e.push(T)},a=function(T){return e[e.length-1]=T},l=function(T){r==null&&(r=n,o=e.length,i=T)},c=function(T){T===i&&(r=void 0,o=void 0,i=void 0)},h=function(){return e.pop()},m=function(){return n--},y=function(T){if("0"<=T&&T<="9"){s("number");return}switch(T){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}},f=t.length;n<f;n++){var p=t[n];switch(e[e.length-1]){case"topLevel":y(p);break;case"string":switch(p){case'"':h();break;case"\\":l("stringEscape"),s("stringEscaped");break}break;case"stringEscaped":p==="u"?s("stringUnicode"):(c("stringEscape"),h());break;case"stringUnicode":n-t.lastIndexOf("u",n)===4&&(c("stringEscape"),h());break;case"number":p==="."?a("numberNeedsDigit"):p==="e"||p==="E"?a("numberNeedsExponent"):(p<"0"||p>"9")&&(m(),h());break;case"numberNeedsDigit":a("number");break;case"numberNeedsExponent":a(p==="+"||p==="-"?"numberNeedsDigit":"number");break;case"true":case"false":case"null":(p<"a"||p>"z")&&(m(),h());break;case"arrayNeedsValue":p==="]"?h():dc(p)||(c("collectionItem"),a("arrayNeedsComma"),y(p));break;case"arrayNeedsComma":p==="]"?h():p===","&&(l("collectionItem"),a("arrayNeedsValue"));break;case"objectNeedsKey":p==="}"?h():p==='"'&&(l("collectionItem"),a("objectNeedsColon"),s("string"));break;case"objectNeedsColon":p===":"&&a("objectNeedsValue");break;case"objectNeedsValue":dc(p)||(c("collectionItem"),a("objectNeedsComma"),y(p));break;case"objectNeedsComma":p==="}"?h():p===","&&(l("collectionItem"),a("objectNeedsKey"));break}}o!=null&&(e.length=o);for(var g=[r!=null?t.slice(0,r):t],x=function(T){return g.push(T.slice(t.length-t.lastIndexOf(T[0])))},S=e.length-1;S>=0;S--)switch(e[S]){case"string":g.push('"');break;case"numberNeedsDigit":case"numberNeedsExponent":g.push("0");break;case"true":x("true");break;case"false":x("false");break;case"null":x("null");break;case"arrayNeedsValue":case"arrayNeedsComma":g.push("]");break;case"objectNeedsKey":case"objectNeedsColon":case"objectNeedsValue":case"objectNeedsComma":g.push("}");break}return g.join("")}function hc(){let t=0,e=0;for(let r=0;r<28;r+=7){let o=this.buf[this.pos++];if(t|=(o&127)<<r,(o&128)==0)return this.assertBounds(),[t,e]}let n=this.buf[this.pos++];if(t|=(n&15)<<28,e=(n&112)>>4,(n&128)==0)return this.assertBounds(),[t,e];for(let r=3;r<=31;r+=7){let o=this.buf[this.pos++];if(e|=(o&127)<<r,(o&128)==0)return this.assertBounds(),[t,e]}throw new Error("invalid varint")}function Io(t,e,n){for(let i=0;i<28;i=i+7){let s=t>>>i,a=!(!(s>>>7)&&e==0),l=(a?s|128:s)&255;if(n.push(l),!a)return}let r=t>>>28&15|(e&7)<<4,o=e>>3!=0;if(n.push((o?r|128:r)&255),!!o){for(let i=3;i<31;i=i+7){let s=e>>>i,a=!!(s>>>7),l=(a?s|128:s)&255;if(n.push(l),!a)return}n.push(e>>>31&1)}}var Co=4294967296;function qs(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>=Co&&(o=o+(r/Co|0),r=r%Co)}return i(-24,-18),i(-18,-12),i(-12,-6),i(-6),e?mc(r,o):Xs(r,o)}function fc(t,e){let n=Xs(t,e),r=n.hi&2147483648;r&&(n=mc(n.lo,n.hi));let o=Ws(n.lo,n.hi);return r?"-"+o:o}function Ws(t,e){if({lo:t,hi:e}=xm(t,e),e<=2097151)return String(Co*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()+pc(s)+pc(i)}function xm(t,e){return{lo:t>>>0,hi:e>>>0}}function Xs(t,e){return{lo:t|0,hi:e|0}}function mc(t,e){return e=~e,t?t=~t+1:e+=1,Xs(t,e)}var pc=t=>{let e=String(t);return"0000000".slice(e.length)+e};function Ys(t,e){if(t>=0){for(;t>127;)e.push(t&127|128),t=t>>>7;e.push(t)}else{for(let n=0;n<9;n++)e.push(t&127|128),t=t>>7;e.push(1)}}function gc(){let t=this.buf[this.pos++],e=t&127;if((t&128)==0)return this.assertBounds(),e;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 Xe=_m();function _m(){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()),vc(n),n},uParse(n){return typeof n!="string"&&(n=n.toString()),bc(n),n},enc(n){return typeof n!="string"&&(n=n.toString()),vc(n),qs(n)},uEnc(n){return typeof n!="string"&&(n=n.toString()),bc(n),qs(n)},dec(n,r){return fc(n,r)},uDec(n,r){return Ws(n,r)}}}function vc(t){if(!/^-?[0-9]+$/.test(t))throw new Error("invalid int64: "+t)}function bc(t){if(!/^[0-9]+$/.test(t))throw new Error("invalid uint64: "+t)}var Ks=Symbol.for("@bufbuild/protobuf/text-encoding");function Zs(){if(globalThis[Ks]==null){let t=new globalThis.TextEncoder,e=new globalThis.TextDecoder,n;globalThis[Ks]={encodeUtf8(r){return t.encode(r)},decodeUtf8(r,o){return o?(n===void 0&&(n=new globalThis.TextDecoder("utf-8",{fatal:!0})),n.decode(r)):e.decode(r)},checkUtf8(r){try{return encodeURIComponent(r),!0}catch{return!1}}}}return globalThis[Ks]}var St;(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"})(St||(St={}));var Em=34028234663852886e22,Tm=-34028234663852886e22,wm=4294967295,Sm=2147483647,Am=-2147483648,F=class{constructor(e=Zs().encodeUtf8){this.encodeUtf8=e,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let e=0;for(let o=0;o<this.chunks.length;o++)e+=this.chunks[o].length;let n=new Uint8Array(e),r=0;for(let o=0;o<this.chunks.length;o++)n.set(this.chunks[o],r),r+=this.chunks[o].length;return this.chunks=[],n}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),n=this.stack.pop();if(!n)throw new Error("invalid state, fork stack empty");return this.chunks=n.chunks,this.buf=n.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,n){return this.uint32((e<<3|n)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(yc(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return Js(e),Ys(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let n=this.encodeUtf8(e);return this.uint32(n.byteLength),this.raw(n)}float(e){km(e);let n=new Uint8Array(4);return new DataView(n.buffer).setFloat32(0,e,!0),this.raw(n)}double(e){let n=new Uint8Array(8);return new DataView(n.buffer).setFloat64(0,e,!0),this.raw(n)}fixed32(e){yc(e);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,e,!0),this.raw(n)}sfixed32(e){Js(e);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,e,!0),this.raw(n)}sint32(e){return Js(e),e=(e<<1^e>>31)>>>0,Ys(e,this.buf),this}sfixed64(e){let n=new Uint8Array(8),r=new DataView(n.buffer),o=Xe.enc(e);return r.setInt32(0,o.lo,!0),r.setInt32(4,o.hi,!0),this.raw(n)}fixed64(e){let n=new Uint8Array(8),r=new DataView(n.buffer),o=Xe.uEnc(e);return r.setInt32(0,o.lo,!0),r.setInt32(4,o.hi,!0),this.raw(n)}int64(e){let n=Xe.enc(e);return Io(n.lo,n.hi,this.buf),this}sint64(e){let n=Xe.enc(e),r=n.hi>>31,o=n.lo<<1^r,i=(n.hi<<1|n.lo>>>31)^r;return Io(o,i,this.buf),this}uint64(e){let n=Xe.uEnc(e);return Io(n.lo,n.hi,this.buf),this}},A=class{constructor(e,n=Zs().decodeUtf8){this.decodeUtf8=n,this.varint64=hc,this.uint32=gc,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 St.Varint:for(;this.buf[this.pos++]&128;);break;case St.Bit64:this.pos+=4;case St.Bit32:this.pos+=4;break;case St.LengthDelimited:let i=this.uint32();this.pos+=i;break;case St.StartGroup:if(r<=0)throw new Error("maximum recursion depth reached");for(;;){let[s,a]=this.tag();if(a===St.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 Xe.dec(...this.varint64())}uint64(){return Xe.uDec(...this.varint64())}sint64(){let[e,n]=this.varint64(),r=-(e&1);return e=(e>>>1|(n&1)<<31)^r,n=n>>>1^r,Xe.dec(e,n)}bool(){let[e,n]=this.varint64();return e!==0||n!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return Xe.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Xe.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){return this.decodeUtf8(this.bytes(),e)}};function Js(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>Sm||t<Am)throw new Error("invalid int32: "+t)}function yc(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>wm||t<0)throw new Error("invalid uint32: "+t)}function km(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>Em||t<Tm))throw new Error("invalid float32: "+t)}var Cm=(function(t){return t[t.NULL_VALUE=0]="NULL_VALUE",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t})({});function Qs(){return{fields:{}}}var rr={encode(t,e=new F){return Object.entries(t.fields).forEach(([n,r])=>{r!==void 0&&na.encode({key:n,value:r},e.uint32(10).fork()).join()}),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Qs();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:{if(i!==10)break;let s=na.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 rr.fromPartial(t??{})},fromPartial(t){let e=Qs();return e.fields=Object.entries(t.fields??{}).reduce((n,[r,o])=>(o!==void 0&&(n[r]=o),n),{}),e},wrap(t){let e=Qs();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 xc(){return{key:"",value:void 0}}var na={encode(t,e=new F){return t.key!==""&&e.uint32(10).string(t.key),t.value!==void 0&&O.encode(O.wrap(t.value),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=xc();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=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return na.fromPartial(t??{})},fromPartial(t){let e=xc();return e.key=t.key??"",e.value=t.value??void 0,e}};function ea(){return{nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0}}var O={encode(t,e=new F){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&&rr.encode(rr.wrap(t.structValue),e.uint32(42).fork()).join(),t.listValue!==void 0&&or.encode(or.wrap(t.listValue),e.uint32(50).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=ea();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=rr.unwrap(rr.decode(n,n.uint32()));continue;case 6:if(i!==50)break;o.listValue=or.unwrap(or.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return O.fromPartial(t??{})},fromPartial(t){let e=ea();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=ea();if(t===null)e.nullValue=Cm.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 ta(){return{values:[]}}var or={encode(t,e=new F){for(let n of t.values)O.encode(O.wrap(n),e.uint32(10).fork()).join();return e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=ta();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.values.push(O.unwrap(O.decode(n,n.uint32())));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return or.fromPartial(t??{})},fromPartial(t){let e=ta();return e.values=t.values?.map(n=>n)||[],e},wrap(t){let e=ta();return e.values=t??[],e},unwrap(t){return t?.hasOwnProperty("values")&&globalThis.Array.isArray(t.values)?t.values:t}},Im=(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 _c(){return{op:0,path:"",from:void 0,value:void 0}}var No={encode(t,e=new F){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&&O.encode(O.wrap(t.value),e.uint32(34).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=_c();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=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return No.fromPartial(t??{})},fromPartial(t){let e=_c();return e.op=t.op??0,e.path=t.path??"",e.from=t.from??void 0,e.value=t.value??void 0,e}};function Ec(){return{id:"",type:"",function:void 0}}var Oo={encode(t,e=new F){return t.id!==""&&e.uint32(10).string(t.id),t.type!==""&&e.uint32(18).string(t.type),t.function!==void 0&&Mo.encode(t.function,e.uint32(26).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Ec();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=Mo.decode(n,n.uint32());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Oo.fromPartial(t??{})},fromPartial(t){let e=Ec();return e.id=t.id??"",e.type=t.type??"",e.function=t.function!==void 0&&t.function!==null?Mo.fromPartial(t.function):void 0,e}};function Tc(){return{name:"",arguments:""}}var Mo={encode(t,e=new F){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 A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Tc();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 Mo.fromPartial(t??{})},fromPartial(t){let e=Tc();return e.name=t.name??"",e.arguments=t.arguments??"",e}};function wc(){return{value:"",mimeType:""}}var Lo={encode(t,e=new F){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 A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=wc();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 Lo.fromPartial(t??{})},fromPartial(t){let e=wc();return e.value=t.value??"",e.mimeType=t.mimeType??"",e}};function Sc(){return{value:"",mimeType:void 0}}var Po={encode(t,e=new F){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 A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Sc();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 Po.fromPartial(t??{})},fromPartial(t){let e=Sc();return e.value=t.value??"",e.mimeType=t.mimeType??void 0,e}};function Ac(){return{data:void 0,url:void 0}}var De={encode(t,e=new F){return t.data!==void 0&&Lo.encode(t.data,e.uint32(10).fork()).join(),t.url!==void 0&&Po.encode(t.url,e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Ac();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.data=Lo.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.url=Po.decode(n,n.uint32());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return De.fromPartial(t??{})},fromPartial(t){let e=Ac();return e.data=t.data!==void 0&&t.data!==null?Lo.fromPartial(t.data):void 0,e.url=t.url!==void 0&&t.url!==null?Po.fromPartial(t.url):void 0,e}};function kc(){return{text:""}}var Do={encode(t,e=new F){return t.text!==""&&e.uint32(10).string(t.text),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=kc();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 Do.fromPartial(t??{})},fromPartial(t){let e=kc();return e.text=t.text??"",e}};function Cc(){return{source:void 0,metadata:void 0}}var Uo={encode(t,e=new F){return t.source!==void 0&&De.encode(t.source,e.uint32(10).fork()).join(),t.metadata!==void 0&&O.encode(O.wrap(t.metadata),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Cc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=De.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Uo.fromPartial(t??{})},fromPartial(t){let e=Cc();return e.source=t.source!==void 0&&t.source!==null?De.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function Ic(){return{source:void 0,metadata:void 0}}var Ho={encode(t,e=new F){return t.source!==void 0&&De.encode(t.source,e.uint32(10).fork()).join(),t.metadata!==void 0&&O.encode(O.wrap(t.metadata),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Ic();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=De.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Ho.fromPartial(t??{})},fromPartial(t){let e=Ic();return e.source=t.source!==void 0&&t.source!==null?De.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function Rc(){return{source:void 0,metadata:void 0}}var zo={encode(t,e=new F){return t.source!==void 0&&De.encode(t.source,e.uint32(10).fork()).join(),t.metadata!==void 0&&O.encode(O.wrap(t.metadata),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Rc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=De.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return zo.fromPartial(t??{})},fromPartial(t){let e=Rc();return e.source=t.source!==void 0&&t.source!==null?De.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function Nc(){return{source:void 0,metadata:void 0}}var Go={encode(t,e=new F){return t.source!==void 0&&De.encode(t.source,e.uint32(10).fork()).join(),t.metadata!==void 0&&O.encode(O.wrap(t.metadata),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Nc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=De.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Go.fromPartial(t??{})},fromPartial(t){let e=Nc();return e.source=t.source!==void 0&&t.source!==null?De.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function Oc(){return{text:void 0,image:void 0,audio:void 0,video:void 0,document:void 0}}var Fo={encode(t,e=new F){return t.text!==void 0&&Do.encode(t.text,e.uint32(10).fork()).join(),t.image!==void 0&&Uo.encode(t.image,e.uint32(18).fork()).join(),t.audio!==void 0&&Ho.encode(t.audio,e.uint32(26).fork()).join(),t.video!==void 0&&zo.encode(t.video,e.uint32(34).fork()).join(),t.document!==void 0&&Go.encode(t.document,e.uint32(42).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Oc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.text=Do.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.image=Uo.decode(n,n.uint32());continue;case 3:if(i!==26)break;o.audio=Ho.decode(n,n.uint32());continue;case 4:if(i!==34)break;o.video=zo.decode(n,n.uint32());continue;case 5:if(i!==42)break;o.document=Go.decode(n,n.uint32());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Fo.fromPartial(t??{})},fromPartial(t){let e=Oc();return e.text=t.text!==void 0&&t.text!==null?Do.fromPartial(t.text):void 0,e.image=t.image!==void 0&&t.image!==null?Uo.fromPartial(t.image):void 0,e.audio=t.audio!==void 0&&t.audio!==null?Ho.fromPartial(t.audio):void 0,e.video=t.video!==void 0&&t.video!==null?zo.fromPartial(t.video):void 0,e.document=t.document!==void 0&&t.document!==null?Go.fromPartial(t.document):void 0,e}};function Mc(){return{id:"",role:"",content:void 0,name:void 0,toolCalls:[],toolCallId:void 0,error:void 0,contentParts:[]}}var $o={encode(t,e=new F){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)Oo.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)Fo.encode(n,e.uint32(66).fork()).join();return e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Mc();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(Oo.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(Fo.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return $o.fromPartial(t??{})},fromPartial(t){let e=Mc();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=>Oo.fromPartial(n))||[],e.toolCallId=t.toolCallId??void 0,e.error=t.error??void 0,e.contentParts=t.contentParts?.map(n=>Fo.fromPartial(n))||[],e}};function Lc(){return{id:"",reason:"",message:void 0,toolCallId:void 0,responseSchema:void 0,expiresAt:void 0,metadata:void 0}}var Bo={encode(t,e=new F){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&&O.encode(O.wrap(t.responseSchema),e.uint32(42).fork()).join(),t.expiresAt!==void 0&&e.uint32(50).string(t.expiresAt),t.metadata!==void 0&&O.encode(O.wrap(t.metadata),e.uint32(58).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Lc();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=O.unwrap(O.decode(n,n.uint32()));continue;case 6:if(i!==50)break;o.expiresAt=n.string();continue;case 7:if(i!==58)break;o.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Bo.fromPartial(t??{})},fromPartial(t){let e=Lc();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}},Rm=(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.UNRECOGNIZED=-1]="UNRECOGNIZED",t})({});function Pc(){return{type:0,timestamp:void 0,rawEvent:void 0}}var M={encode(t,e=new F){return t.type!==0&&e.uint32(8).int32(t.type),t.timestamp!==void 0&&e.uint32(16).int64(t.timestamp),t.rawEvent!==void 0&&O.encode(O.wrap(t.rawEvent),e.uint32(26).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Pc();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=Nm(n.int64());continue;case 3:if(i!==26)break;o.rawEvent=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return M.fromPartial(t??{})},fromPartial(t){let e=Pc();return e.type=t.type??0,e.timestamp=t.timestamp??void 0,e.rawEvent=t.rawEvent??void 0,e}};function Dc(){return{baseEvent:void 0,messageId:"",role:void 0,name:void 0}}var Vo={encode(t,e=new F){return t.baseEvent!==void 0&&M.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),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Dc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.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}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Vo.fromPartial(t??{})},fromPartial(t){let e=Dc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.messageId=t.messageId??"",e.role=t.role??void 0,e.name=t.name??void 0,e}};function Uc(){return{baseEvent:void 0,messageId:"",delta:""}}var jo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.messageId!==""&&e.uint32(18).string(t.messageId),t.delta!==""&&e.uint32(26).string(t.delta),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Uc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.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}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return jo.fromPartial(t??{})},fromPartial(t){let e=Uc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.messageId=t.messageId??"",e.delta=t.delta??"",e}};function Hc(){return{baseEvent:void 0,messageId:""}}var qo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.messageId!==""&&e.uint32(18).string(t.messageId),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Hc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.messageId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return qo.fromPartial(t??{})},fromPartial(t){let e=Hc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.messageId=t.messageId??"",e}};function zc(){return{baseEvent:void 0,toolCallId:"",toolCallName:"",parentMessageId:void 0}}var Wo={encode(t,e=new F){return t.baseEvent!==void 0&&M.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),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=zc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.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}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Wo.fromPartial(t??{})},fromPartial(t){let e=zc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.toolCallId=t.toolCallId??"",e.toolCallName=t.toolCallName??"",e.parentMessageId=t.parentMessageId??void 0,e}};function Gc(){return{baseEvent:void 0,toolCallId:"",delta:""}}var Xo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.toolCallId!==""&&e.uint32(18).string(t.toolCallId),t.delta!==""&&e.uint32(26).string(t.delta),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Gc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.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}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Xo.fromPartial(t??{})},fromPartial(t){let e=Gc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.toolCallId=t.toolCallId??"",e.delta=t.delta??"",e}};function Fc(){return{baseEvent:void 0,toolCallId:""}}var Yo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.toolCallId!==""&&e.uint32(18).string(t.toolCallId),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Fc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.toolCallId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Yo.fromPartial(t??{})},fromPartial(t){let e=Fc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.toolCallId=t.toolCallId??"",e}};function $c(){return{baseEvent:void 0,snapshot:void 0}}var Ko={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.snapshot!==void 0&&O.encode(O.wrap(t.snapshot),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=$c();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.snapshot=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Ko.fromPartial(t??{})},fromPartial(t){let e=$c();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.snapshot=t.snapshot??void 0,e}};function Bc(){return{baseEvent:void 0,delta:[]}}var Zo={encode(t,e=new F){t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join();for(let n of t.delta)No.encode(n,e.uint32(18).fork()).join();return e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Bc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.delta.push(No.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Zo.fromPartial(t??{})},fromPartial(t){let e=Bc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.delta=t.delta?.map(n=>No.fromPartial(n))||[],e}};function Vc(){return{baseEvent:void 0,messages:[]}}var Jo={encode(t,e=new F){t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join();for(let n of t.messages)$o.encode(n,e.uint32(18).fork()).join();return e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Vc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.messages.push($o.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Jo.fromPartial(t??{})},fromPartial(t){let e=Vc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.messages=t.messages?.map(n=>$o.fromPartial(n))||[],e}};function jc(){return{baseEvent:void 0,event:void 0,source:void 0}}var Qo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.event!==void 0&&O.encode(O.wrap(t.event),e.uint32(18).fork()).join(),t.source!==void 0&&e.uint32(26).string(t.source),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=jc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.event=O.unwrap(O.decode(n,n.uint32()));continue;case 3:if(i!==26)break;o.source=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Qo.fromPartial(t??{})},fromPartial(t){let e=jc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.event=t.event??void 0,e.source=t.source??void 0,e}};function qc(){return{baseEvent:void 0,name:"",value:void 0}}var ei={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.name!==""&&e.uint32(18).string(t.name),t.value!==void 0&&O.encode(O.wrap(t.value),e.uint32(26).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=qc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.name=n.string();continue;case 3:if(i!==26)break;o.value=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return ei.fromPartial(t??{})},fromPartial(t){let e=qc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.name=t.name??"",e.value=t.value??void 0,e}};function Wc(){return{baseEvent:void 0,threadId:"",runId:""}}var ti={encode(t,e=new F){return t.baseEvent!==void 0&&M.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 A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Wc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.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 ti.fromPartial(t??{})},fromPartial(t){let e=Wc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.threadId=t.threadId??"",e.runId=t.runId??"",e}};function Xc(){return{baseEvent:void 0,threadId:"",runId:"",result:void 0,outcome:"",interrupts:[]}}var ni={encode(t,e=new F){t.baseEvent!==void 0&&M.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&&O.encode(O.wrap(t.result),e.uint32(34).fork()).join(),t.outcome!==""&&e.uint32(42).string(t.outcome);for(let n of t.interrupts)Bo.encode(n,e.uint32(50).fork()).join();return e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Xc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.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=O.unwrap(O.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(Bo.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=Xc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.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=>Bo.fromPartial(n))||[],e}};function Yc(){return{baseEvent:void 0,code:void 0,message:""}}var ri={encode(t,e=new F){return t.baseEvent!==void 0&&M.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),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Yc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.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}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return ri.fromPartial(t??{})},fromPartial(t){let e=Yc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.code=t.code??void 0,e.message=t.message??"",e}};function Kc(){return{baseEvent:void 0,stepName:""}}var oi={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.stepName!==""&&e.uint32(18).string(t.stepName),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Kc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.stepName=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return oi.fromPartial(t??{})},fromPartial(t){let e=Kc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.stepName=t.stepName??"",e}};function Zc(){return{baseEvent:void 0,stepName:""}}var ii={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.stepName!==""&&e.uint32(18).string(t.stepName),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Zc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.stepName=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return ii.fromPartial(t??{})},fromPartial(t){let e=Zc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.stepName=t.stepName??"",e}};function Jc(){return{baseEvent:void 0,messageId:void 0,role:void 0,delta:void 0,name:void 0}}var si={encode(t,e=new F){return t.baseEvent!==void 0&&M.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),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Jc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.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}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return si.fromPartial(t??{})},fromPartial(t){let e=Jc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.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}};function Qc(){return{baseEvent:void 0,toolCallId:void 0,toolCallName:void 0,parentMessageId:void 0,delta:void 0}}var ai={encode(t,e=new F){return t.baseEvent!==void 0&&M.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),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Qc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.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}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return ai.fromPartial(t??{})},fromPartial(t){let e=Qc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.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}};function eu(){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}}var tu={encode(t,e=new F){return t.textMessageStart!==void 0&&Vo.encode(t.textMessageStart,e.uint32(10).fork()).join(),t.textMessageContent!==void 0&&jo.encode(t.textMessageContent,e.uint32(18).fork()).join(),t.textMessageEnd!==void 0&&qo.encode(t.textMessageEnd,e.uint32(26).fork()).join(),t.toolCallStart!==void 0&&Wo.encode(t.toolCallStart,e.uint32(34).fork()).join(),t.toolCallArgs!==void 0&&Xo.encode(t.toolCallArgs,e.uint32(42).fork()).join(),t.toolCallEnd!==void 0&&Yo.encode(t.toolCallEnd,e.uint32(50).fork()).join(),t.stateSnapshot!==void 0&&Ko.encode(t.stateSnapshot,e.uint32(58).fork()).join(),t.stateDelta!==void 0&&Zo.encode(t.stateDelta,e.uint32(66).fork()).join(),t.messagesSnapshot!==void 0&&Jo.encode(t.messagesSnapshot,e.uint32(74).fork()).join(),t.raw!==void 0&&Qo.encode(t.raw,e.uint32(82).fork()).join(),t.custom!==void 0&&ei.encode(t.custom,e.uint32(90).fork()).join(),t.runStarted!==void 0&&ti.encode(t.runStarted,e.uint32(98).fork()).join(),t.runFinished!==void 0&&ni.encode(t.runFinished,e.uint32(106).fork()).join(),t.runError!==void 0&&ri.encode(t.runError,e.uint32(114).fork()).join(),t.stepStarted!==void 0&&oi.encode(t.stepStarted,e.uint32(122).fork()).join(),t.stepFinished!==void 0&&ii.encode(t.stepFinished,e.uint32(130).fork()).join(),t.textMessageChunk!==void 0&&si.encode(t.textMessageChunk,e.uint32(138).fork()).join(),t.toolCallChunk!==void 0&&ai.encode(t.toolCallChunk,e.uint32(146).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=eu();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.textMessageStart=Vo.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.textMessageContent=jo.decode(n,n.uint32());continue;case 3:if(i!==26)break;o.textMessageEnd=qo.decode(n,n.uint32());continue;case 4:if(i!==34)break;o.toolCallStart=Wo.decode(n,n.uint32());continue;case 5:if(i!==42)break;o.toolCallArgs=Xo.decode(n,n.uint32());continue;case 6:if(i!==50)break;o.toolCallEnd=Yo.decode(n,n.uint32());continue;case 7:if(i!==58)break;o.stateSnapshot=Ko.decode(n,n.uint32());continue;case 8:if(i!==66)break;o.stateDelta=Zo.decode(n,n.uint32());continue;case 9:if(i!==74)break;o.messagesSnapshot=Jo.decode(n,n.uint32());continue;case 10:if(i!==82)break;o.raw=Qo.decode(n,n.uint32());continue;case 11:if(i!==90)break;o.custom=ei.decode(n,n.uint32());continue;case 12:if(i!==98)break;o.runStarted=ti.decode(n,n.uint32());continue;case 13:if(i!==106)break;o.runFinished=ni.decode(n,n.uint32());continue;case 14:if(i!==114)break;o.runError=ri.decode(n,n.uint32());continue;case 15:if(i!==122)break;o.stepStarted=oi.decode(n,n.uint32());continue;case 16:if(i!==130)break;o.stepFinished=ii.decode(n,n.uint32());continue;case 17:if(i!==138)break;o.textMessageChunk=si.decode(n,n.uint32());continue;case 18:if(i!==146)break;o.toolCallChunk=ai.decode(n,n.uint32());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return tu.fromPartial(t??{})},fromPartial(t){let e=eu();return e.textMessageStart=t.textMessageStart!==void 0&&t.textMessageStart!==null?Vo.fromPartial(t.textMessageStart):void 0,e.textMessageContent=t.textMessageContent!==void 0&&t.textMessageContent!==null?jo.fromPartial(t.textMessageContent):void 0,e.textMessageEnd=t.textMessageEnd!==void 0&&t.textMessageEnd!==null?qo.fromPartial(t.textMessageEnd):void 0,e.toolCallStart=t.toolCallStart!==void 0&&t.toolCallStart!==null?Wo.fromPartial(t.toolCallStart):void 0,e.toolCallArgs=t.toolCallArgs!==void 0&&t.toolCallArgs!==null?Xo.fromPartial(t.toolCallArgs):void 0,e.toolCallEnd=t.toolCallEnd!==void 0&&t.toolCallEnd!==null?Yo.fromPartial(t.toolCallEnd):void 0,e.stateSnapshot=t.stateSnapshot!==void 0&&t.stateSnapshot!==null?Ko.fromPartial(t.stateSnapshot):void 0,e.stateDelta=t.stateDelta!==void 0&&t.stateDelta!==null?Zo.fromPartial(t.stateDelta):void 0,e.messagesSnapshot=t.messagesSnapshot!==void 0&&t.messagesSnapshot!==null?Jo.fromPartial(t.messagesSnapshot):void 0,e.raw=t.raw!==void 0&&t.raw!==null?Qo.fromPartial(t.raw):void 0,e.custom=t.custom!==void 0&&t.custom!==null?ei.fromPartial(t.custom):void 0,e.runStarted=t.runStarted!==void 0&&t.runStarted!==null?ti.fromPartial(t.runStarted):void 0,e.runFinished=t.runFinished!==void 0&&t.runFinished!==null?ni.fromPartial(t.runFinished):void 0,e.runError=t.runError!==void 0&&t.runError!==null?ri.fromPartial(t.runError):void 0,e.stepStarted=t.stepStarted!==void 0&&t.stepStarted!==null?oi.fromPartial(t.stepStarted):void 0,e.stepFinished=t.stepFinished!==void 0&&t.stepFinished!==null?ii.fromPartial(t.stepFinished):void 0,e.textMessageChunk=t.textMessageChunk!==void 0&&t.textMessageChunk!==null?si.fromPartial(t.textMessageChunk):void 0,e.toolCallChunk=t.toolCallChunk!==void 0&&t.toolCallChunk!==null?ai.fromPartial(t.toolCallChunk):void 0,e}};function Nm(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 Ro=t=>{if(!(!t||typeof t!="object")){if(t.data)return{type:"data",value:t.data.value,mimeType:t.data.mimeType};if(t.url)return{type:"url",value:t.url.value,mimeType:t.url.mimeType}}},Om=t=>{if(!(!t||typeof t!="object")){if(t.text)return{type:"text",text:t.text.text};if(t.image)return{type:"image",source:Ro(t.image.source),metadata:t.image.metadata};if(t.audio)return{type:"audio",source:Ro(t.audio.source),metadata:t.audio.metadata};if(t.video)return{type:"video",source:Ro(t.video.source),metadata:t.video.metadata};if(t.document)return{type:"document",source:Ro(t.document.source),metadata:t.document.metadata}}};function nu(t){let e=tu.decode(t),n=Object.values(e).find(r=>r!==void 0);if(!n)throw new Error("Invalid event");if(n.type=Rm[n.baseEvent.type],n.timestamp=n.baseEvent.timestamp,n.rawEvent=n.baseEvent.rawEvent,delete n.baseEvent,n.type===v.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=>Om(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===v.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===v.STATE_DELTA)for(let r of n.delta)r.op=Im[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]}),qr.parse(n)}var ra="application/vnd.ag-ui.event+proto";var Lm=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,oa=t=>{if(typeof t!="string")throw new TypeError("Invalid argument expected string");let e=t.match(Lm);if(!e)throw new Error(`Invalid argument not valid semver ('${t}' received)`);return e.shift(),e},ru=t=>t==="*"||t==="x"||t==="X",ou=t=>{let e=parseInt(t,10);return isNaN(e)?t:e},Pm=(t,e)=>typeof t!=typeof e?[String(t),String(e)]:[t,e],Dm=(t,e)=>{if(ru(t)||ru(e))return 0;let[n,r]=Pm(ou(t),ou(e));return n>r?1:n<r?-1:0},ia=(t,e)=>{for(let n=0;n<Math.max(t.length,e.length);n++){let r=Dm(t[n]||"0",e[n]||"0");if(r!==0)return r}return 0};var ir=(t,e)=>{let n=oa(t),r=oa(e),o=n.pop(),i=r.pop(),s=ia(n,r);return s!==0?s:o&&i?ia(o.split("."),i.split(".")):o||i?o?-1:1:0};var q=t=>{if(typeof structuredClone=="function")return structuredClone(t);try{return JSON.parse(JSON.stringify(t))}catch{return Array.isArray(t)?[...t]:{...t}}};function Ue(){return xt()}function la(t){if(Object.freeze(t),typeof t=="object"&&t)for(let e of Object.values(t))typeof e=="object"&&e&&!Object.isFrozen(e)&&la(e);return t}var iu=512*1024;function su(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 c=a[l];if(r+=c.length,r>n)return!0;o.push(s[c])}}}}return!1}async function K(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&&!su(e,n,iu),l=a?q(e):e,c=a?q(n):n,h=!1,m=!1,y;for(let f of t)try{a&&(la(l),la(c));let p=await r(f,l,c);if(p===void 0)continue;let g=!1;if(p.messages!==void 0&&p.messages!==l&&(l=q(p.messages),h=!0,g=!0),p.state!==void 0&&p.state!==c&&(c=q(p.state),m=!0,g=!0),a&&g&&su(l,c,iu)&&(a=!1),y=p.stopPropagation,y===!0)break}catch(p){if(s&&p instanceof TypeError){if(i)throw p;console.error("AG-UI: Subscriber attempted to mutate frozen inputs in-place. Return mutations via AgentStateMutation instead of mutating directly.",p)}else i||console.error("Subscriber error:",p);continue}return{...h?{messages:Object.isFrozen(l)?q(l):l}:{},...m?{state:Object.isFrozen(c)?q(c):c}:{},...y===void 0?{}:{stopPropagation:y}}}function li(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 sr(t){if(t instanceof ca)return t;if(t===!0)return new ca(li(!0))}var ca=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 sa(t){return t.enabled?new ca(t):void 0}function Um(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}var pu=(t,e,n,r,o)=>{let i=sr(o),s=q(n.messages),a=q(t.state),l={},c=m=>{m.messages!==void 0&&(s=m.messages,l.messages=m.messages),m.state!==void 0&&(a=m.state,l.state=m.state)},h=()=>{let m=q(l);return l={},m.messages!==void 0||m.state!==void 0?ue(m):co};return e.pipe(So(async m=>{let y=await K(r,s,a,(f,p,g)=>f.onEvent?.({event:m,agent:n,input:t,messages:p,state:g}));if(c(y),y.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}),y.stopPropagation===!0)return h();switch(m.type){case v.TEXT_MESSAGE_START:{let f=await K(r,s,a,(p,g,x)=>p.onTextMessageStartEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{messageId:p,role:g="assistant",name:x}=m;if(!s.find(S=>S.id===p)){let S={id:p,role:g,content:"",...x!==void 0&&{name:x}};s.push(S),c({messages:s})}}return h()}case v.TEXT_MESSAGE_CONTENT:{let{messageId:f,delta:p}=m,g=s.find(S=>S.id===f);if(!g)return console.warn(`TEXT_MESSAGE_CONTENT: No message found with ID '${f}'`),h();let x=await K(r,s,a,(S,T,I)=>S.onTextMessageContentEvent?.({event:m,messages:T,state:I,agent:n,input:t,textMessageBuffer:typeof g.content=="string"?g.content:""}));return c(x),x.stopPropagation!==!0&&(g.content=`${typeof g.content=="string"?g.content:""}${p}`,c({messages:s})),h()}case v.TEXT_MESSAGE_END:{let{messageId:f}=m,p=s.find(g=>g.id===f);return p?(c(await K(r,s,a,(g,x,S)=>g.onTextMessageEndEvent?.({event:m,messages:x,state:S,agent:n,input:t,textMessageBuffer:typeof p.content=="string"?p.content:""}))),await Promise.all(r.map(g=>{g.onNewMessage?.({message:p,messages:s,state:a,agent:n,input:t})})),h()):(console.warn(`TEXT_MESSAGE_END: No message found with ID '${f}'`),h())}case v.TOOL_CALL_START:{let f=await K(r,s,a,(p,g,x)=>p.onToolCallStartEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{toolCallId:p,toolCallName:g,parentMessageId:x}=m,S=Um(s,x,p);S.toolCalls??=[],S.toolCalls.push({id:p,type:"function",function:{name:g,arguments:""}}),c({messages:s})}return h()}case v.TOOL_CALL_ARGS:{let{toolCallId:f,delta:p}=m,g=s.find(T=>T.toolCalls?.some(I=>I.id===f));if(!g)return console.warn(`TOOL_CALL_ARGS: No message found containing tool call with ID '${f}'`),h();let x=g.toolCalls?.find(T=>T.id===f);if(!x)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${f}'`),h();let S=await K(r,s,a,(T,I,H)=>{let U=x.function.arguments,Y=x.function.name,re={};try{re=ko(U)}catch{}return T.onToolCallArgsEvent?.({event:m,messages:I,state:H,agent:n,input:t,toolCallBuffer:U,toolCallName:Y,partialToolCallArgs:re})});return c(S),S.stopPropagation!==!0&&(x.function.arguments+=p,c({messages:s})),h()}case v.TOOL_CALL_END:{let{toolCallId:f}=m,p=s.find(x=>x.toolCalls?.some(S=>S.id===f));if(!p)return console.warn(`TOOL_CALL_END: No message found containing tool call with ID '${f}'`),h();let g=p.toolCalls?.find(x=>x.id===f);return g?(c(await K(r,s,a,(x,S,T)=>{let I=g.function.arguments,H=g.function.name,U={};try{U=JSON.parse(I)}catch{}return x.onToolCallEndEvent?.({event:m,messages:S,state:T,agent:n,input:t,toolCallName:H,toolCallArgs:U})})),await Promise.all(r.map(x=>{x.onNewToolCall?.({toolCall:g,messages:s,state:a,agent:n,input:t})})),h()):(console.warn(`TOOL_CALL_END: No tool call found with ID '${f}'`),h())}case v.TOOL_CALL_RESULT:{let f=await K(r,s,a,(p,g,x)=>p.onToolCallResultEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{messageId:p,toolCallId:g,content:x,role:S}=m,T={id:p,toolCallId:g,role:S||"tool",content:x},I=s.findIndex(H=>H.role==="assistant"&&H.toolCalls?.some(U=>U.id===g));if(I===-1)s.push(T);else{let H=I+1;for(;H<s.length&&s[H].role==="tool";)H++;s.splice(H,0,T)}await Promise.all(r.map(H=>{H.onNewMessage?.({message:T,messages:s,state:a,agent:n,input:t})})),c({messages:s})}return h()}case v.STATE_SNAPSHOT:{let f=await K(r,s,a,(p,g,x)=>p.onStateSnapshotEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{snapshot:p}=m;a=p,c({state:a})}return h()}case v.STATE_DELTA:{let f=await K(r,s,a,(p,g,x)=>p.onStateDeltaEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{delta:p}=m;try{a=eo.applyPatch(a,p,!0,!1).newDocument,c({state:a})}catch(g){let x=g instanceof Error?g.message:String(g);console.warn(`Failed to apply state patch:
|
|
6
6
|
Current state: ${JSON.stringify(a,null,2)}
|
|
7
7
|
Patch operations: ${JSON.stringify(p,null,2)}
|
|
8
|
-
Error: ${x}`)}}return h()}case v.MESSAGES_SNAPSHOT:{let f=await K(r,s,a,(p,g,x)=>p.onMessagesSnapshotEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{messages:p}=m,g=new Map(p.map(C=>[C.id,C])),x=p.some(C=>C.role==="reasoning"),_=C=>C.role==="activity"||C.role==="reasoning"&&!x;s=s.filter(C=>_(C)||g.has(C.id)).map(C=>_(C)?C:g.get(C.id));let w=new Set(s.map(C=>C.id));for(let C of p)w.has(C.id)||s.push(C);c({messages:s})}return h()}case v.ACTIVITY_SNAPSHOT:{let f=m,p=s.findIndex(C=>C.id===f.messageId),g=p>=0?s[p]:void 0,x=g?.role==="activity"?g:void 0,_=f.replace??!0,w=await K(r,s,a,(C,H,U)=>C.onActivitySnapshotEvent?.({event:f,messages:H,state:U,agent:n,input:t,activityMessage:x,existingMessage:g}));if(c(w),w.stopPropagation!==!0){let C={id:f.messageId,role:"activity",activityType:f.activityType,content:q(f.content)},H;p===-1?(s.push(C),H=C):x?_&&(s[p]={...x,activityType:f.activityType,content:q(f.content)}):_&&(s[p]=C,H=C),c({messages:s}),H&&await Promise.all(r.map(U=>U.onNewMessage?.({message:H,messages:s,state:a,agent:n,input:t})))}return h()}case v.ACTIVITY_DELTA:{let f=m,p=s.findIndex(w=>w.id===f.messageId);if(p===-1)return h();let g=s[p];if(g.role!=="activity")return console.warn(`ACTIVITY_DELTA: Message '${f.messageId}' is not an activity message`),h();let x=g,_=await K(r,s,a,(w,C,H)=>w.onActivityDeltaEvent?.({event:f,messages:C,state:H,agent:n,input:t,activityMessage:x}));if(c(_),_.stopPropagation!==!0)try{let w=q(x.content??{}),C=Zr.applyPatch(w,f.patch??[],!0,!1).newDocument;s[p]={...x,content:q(C),activityType:f.activityType},c({messages:s})}catch(w){let C=w instanceof Error?w.message:String(w);console.warn(`Failed to apply activity patch for '${f.messageId}': ${C}`)}return h()}case v.RAW:return c(await K(r,s,a,(f,p,g)=>f.onRawEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.CUSTOM:return c(await K(r,s,a,(f,p,g)=>f.onCustomEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.RUN_STARTED:{let f=await K(r,s,a,(p,g,x)=>p.onRunStartedEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let p=m;if(p.input?.messages){for(let g of p.input.messages)s.find(x=>x.id===g.id)||s.push(g);c({messages:s})}}return h()}case v.RUN_FINISHED:{let f=m,p=f.outcome?.type==="interrupt"?{event:f,outcome:"interrupt",interrupts:f.outcome.interrupts}:{event:f,outcome:"success",result:f.result},g=await K(r,s,a,(x,_,w)=>x.onRunFinishedEvent?.({...p,messages:_,state:w,agent:n,input:t}));return c(g),g.stopPropagation!==!0&&(n.pendingInterrupts=p.outcome==="interrupt"?[...p.interrupts]:[]),h()}case v.RUN_ERROR:return c(await K(r,s,a,(f,p,g)=>f.onRunErrorEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.STEP_STARTED:return c(await K(r,s,a,(f,p,g)=>f.onStepStartedEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.STEP_FINISHED:return c(await K(r,s,a,(f,p,g)=>f.onStepFinishedEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.TEXT_MESSAGE_CHUNK:throw Error("TEXT_MESSAGE_CHUNK must be tranformed before being applied");case v.TOOL_CALL_CHUNK:throw Error("TOOL_CALL_CHUNK must be tranformed before being applied");case v.THINKING_START:return h();case v.THINKING_END:return h();case v.THINKING_TEXT_MESSAGE_START:return h();case v.THINKING_TEXT_MESSAGE_CONTENT:return h();case v.THINKING_TEXT_MESSAGE_END:return h();case v.REASONING_START:return c(await K(r,s,a,(f,p,g)=>f.onReasoningStartEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.REASONING_MESSAGE_START:{let f=await K(r,s,a,(p,g,x)=>p.onReasoningMessageStartEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{messageId:p}=m;if(!s.find(g=>g.id===p)){let g={id:p,role:"reasoning",content:""};s.push(g),c({messages:s})}}return h()}case v.REASONING_MESSAGE_CONTENT:{let{messageId:f,delta:p}=m,g=s.find(_=>_.id===f);if(!g)return console.warn(`REASONING_MESSAGE_CONTENT: No message found with ID '${f}'`),h();let x=await K(r,s,a,(_,w,C)=>_.onReasoningMessageContentEvent?.({event:m,messages:w,state:C,agent:n,input:t,reasoningMessageBuffer:typeof g.content=="string"?g.content:""}));return c(x),x.stopPropagation!==!0&&(g.content=`${typeof g.content=="string"?g.content:""}${p}`,c({messages:s})),h()}case v.REASONING_MESSAGE_END:{let{messageId:f}=m,p=s.find(g=>g.id===f);return p?(c(await K(r,s,a,(g,x,_)=>g.onReasoningMessageEndEvent?.({event:m,messages:x,state:_,agent:n,input:t,reasoningMessageBuffer:typeof p.content=="string"?p.content:""}))),await Promise.all(r.map(g=>{g.onNewMessage?.({message:p,messages:s,state:a,agent:n,input:t})})),h()):(console.warn(`REASONING_MESSAGE_END: No message found with ID '${f}'`),h())}case v.REASONING_MESSAGE_CHUNK:throw Error("REASONING_MESSAGE_CHUNK must be transformed before being applied");case v.REASONING_END:return c(await K(r,s,a,(f,p,g)=>f.onReasoningEndEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.REASONING_ENCRYPTED_VALUE:{let{subtype:f,entityId:p,encryptedValue:g}=m,x=await K(r,s,a,(_,w,C)=>_.onReasoningEncryptedValueEvent?.({event:m,messages:w,state:C,agent:n,input:t}));if(c(x),x.stopPropagation!==!0){let _=!1;if(f==="tool-call"){for(let w of s)if(w.role==="assistant"&&w.toolCalls){let C=w.toolCalls.find(H=>H.id===p);if(C){C.encryptedValue=g,_=!0;break}}}else{let w=s.find(C=>C.id===p);w?.role!=="activity"&&w&&(w.encryptedValue=g,_=!0)}_&&(l.messages=s)}return h()}}return m.type,h()}),Us(),r.length>0?Hs({}):m=>m)},na=t=>e=>{let n=or(t),r=new Map,o=new Map,i=!1,s=!1,a=!1,l=new Map,c=!1,h=!1,m=!1,y=()=>{r.clear(),o.clear(),l.clear(),c=!1,h=!1,i=!1,s=!1,m=!0};return e.pipe(Me(f=>{let p=f.type;if(n?.event("VERIFY","Event:",f,{type:f.type}),s)return ne(()=>new ee(`Cannot send event type '${p}': The run has already errored with 'RUN_ERROR'. No further events can be sent.`));if(i&&p!==v.RUN_ERROR&&p!==v.RUN_STARTED)return ne(()=>new ee(`Cannot send event type '${p}': The run has already finished with 'RUN_FINISHED'. Start a new run with 'RUN_STARTED'.`));if(a){if(p===v.RUN_STARTED){if(m&&!i)return ne(()=>new ee("Cannot send 'RUN_STARTED' while a run is still active. The previous run must be finished with 'RUN_FINISHED' before starting a new run."));i&&y()}}else if(a=!0,p!==v.RUN_STARTED&&p!==v.RUN_ERROR)return ne(()=>new ee("First event must be 'RUN_STARTED'"));switch(p){case v.TEXT_MESSAGE_START:{let g=f.messageId;return r.has(g)?ne(()=>new ee(`Cannot send 'TEXT_MESSAGE_START' event: A text message with ID '${g}' is already in progress. Complete it with 'TEXT_MESSAGE_END' first.`)):(r.set(g,!0),ue(f))}case v.TEXT_MESSAGE_CONTENT:{let g=f.messageId;return r.has(g)?ue(f):ne(()=>new ee(`Cannot send 'TEXT_MESSAGE_CONTENT' event: No active text message found with ID '${g}'. Start a text message with 'TEXT_MESSAGE_START' first.`))}case v.TEXT_MESSAGE_END:{let g=f.messageId;return r.has(g)?(r.delete(g),ue(f)):ne(()=>new ee(`Cannot send 'TEXT_MESSAGE_END' event: No active text message found with ID '${g}'. A 'TEXT_MESSAGE_START' event must be sent first.`))}case v.TOOL_CALL_START:{let g=f.toolCallId;return o.has(g)?ne(()=>new ee(`Cannot send 'TOOL_CALL_START' event: A tool call with ID '${g}' is already in progress. Complete it with 'TOOL_CALL_END' first.`)):(o.set(g,!0),ue(f))}case v.TOOL_CALL_ARGS:{let g=f.toolCallId;return o.has(g)?ue(f):ne(()=>new ee(`Cannot send 'TOOL_CALL_ARGS' event: No active tool call found with ID '${g}'. Start a tool call with 'TOOL_CALL_START' first.`))}case v.TOOL_CALL_END:{let g=f.toolCallId;return o.has(g)?(o.delete(g),ue(f)):ne(()=>new ee(`Cannot send 'TOOL_CALL_END' event: No active tool call found with ID '${g}'. A 'TOOL_CALL_START' event must be sent first.`))}case v.STEP_STARTED:{let g=f.stepName;return l.has(g)?ne(()=>new ee(`Step "${g}" is already active for 'STEP_STARTED'`)):(l.set(g,!0),ue(f))}case v.STEP_FINISHED:{let g=f.stepName;return l.has(g)?(l.delete(g),ue(f)):ne(()=>new ee(`Cannot send 'STEP_FINISHED' for step "${g}" that was not started`))}case v.RUN_STARTED:return m=!0,ue(f);case v.RUN_FINISHED:if(l.size>0){let g=Array.from(l.keys()).join(", ");return ne(()=>new ee(`Cannot send 'RUN_FINISHED' while steps are still active: ${g}`))}if(r.size>0){let g=Array.from(r.keys()).join(", ");return ne(()=>new ee(`Cannot send 'RUN_FINISHED' while text messages are still active: ${g}`))}if(o.size>0){let g=Array.from(o.keys()).join(", ");return ne(()=>new ee(`Cannot send 'RUN_FINISHED' while tool calls are still active: ${g}`))}return i=!0,ue(f);case v.RUN_ERROR:return s=!0,ue(f);case v.CUSTOM:return ue(f);case v.THINKING_TEXT_MESSAGE_START:return c?h?ne(()=>new ee("Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking message is already in progress. Complete it with 'THINKING_TEXT_MESSAGE_END' first.")):(h=!0,ue(f)):ne(()=>new ee("Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking step is not in progress. Create one with 'THINKING_START' first."));case v.THINKING_TEXT_MESSAGE_CONTENT:return h?ue(f):ne(()=>new ee("Cannot send 'THINKING_TEXT_MESSAGE_CONTENT' event: No active thinking message found. Start a message with 'THINKING_TEXT_MESSAGE_START' first."));case v.THINKING_TEXT_MESSAGE_END:return h?(h=!1,ue(f)):ne(()=>new ee("Cannot send 'THINKING_TEXT_MESSAGE_END' event: No active thinking message found. A 'THINKING_TEXT_MESSAGE_START' event must be sent first."));case v.THINKING_START:return c?ne(()=>new ee("Cannot send 'THINKING_START' event: A thinking step is already in progress. End it with 'THINKING_END' first.")):(c=!0,ue(f));case v.THINKING_END:return c?(c=!1,ue(f)):ne(()=>new ee("Cannot send 'THINKING_END' event: No active thinking step found. A 'THINKING_START' event must be sent first."));default:return ue(f)}}))},Qt=(function(t){return t.HEADERS="headers",t.DATA="data",t})({}),xm=t=>Eo(()=>Kt(t())).pipe(Gs(e=>{if(!e.ok){let o=e.headers.get("content-type")||"";return Kt(e.text()).pipe(Me(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,ne(()=>a)}))}let n={type:Qt.HEADERS,status:e.status,headers:e.headers},r=e.body?.getReader();return r?new te(o=>(o.next(n),(async()=>{try{for(;;){let{done:i,value:s}=await r.read();if(i)break;let a={type:Qt.DATA,data:s};o.next(a)}o.complete()}catch(i){o.error(i)}})(),()=>{r.cancel().catch(i=>{if(i?.name!=="AbortError")throw i})})):ne(()=>Error("Failed to getReader() from response"))})),Em=(t,e)=>{let n=or(e),r=new it,o=new TextDecoder("utf-8",{fatal:!1}),i="";t.subscribe({next:a=>{if(a.type!==Qt.HEADERS&&a.type===Qt.DATA&&a.data){let l=o.decode(a.data,{stream:!0});i+=l;let c=i.split(/\n\n/);i=c.pop()||"";for(let h of c)s(h)}},error:a=>r.error(a),complete:()=>{i&&(i+=o.decode(),s(i)),r.complete()}});function s(a){let l=a.split(`
|
|
8
|
+
Error: ${x}`)}}return h()}case v.MESSAGES_SNAPSHOT:{let f=await K(r,s,a,(p,g,x)=>p.onMessagesSnapshotEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{messages:p}=m,g=new Map(p.map(I=>[I.id,I])),x=p.some(I=>I.role==="reasoning"),S=I=>I.role==="activity"||I.role==="reasoning"&&!x;s=s.filter(I=>S(I)||g.has(I.id)).map(I=>S(I)?I:g.get(I.id));let T=new Set(s.map(I=>I.id));for(let I of p)T.has(I.id)||s.push(I);c({messages:s})}return h()}case v.ACTIVITY_SNAPSHOT:{let f=m,p=s.findIndex(I=>I.id===f.messageId),g=p>=0?s[p]:void 0,x=g?.role==="activity"?g:void 0,S=f.replace??!0,T=await K(r,s,a,(I,H,U)=>I.onActivitySnapshotEvent?.({event:f,messages:H,state:U,agent:n,input:t,activityMessage:x,existingMessage:g}));if(c(T),T.stopPropagation!==!0){let I={id:f.messageId,role:"activity",activityType:f.activityType,content:q(f.content)},H;p===-1?(s.push(I),H=I):x?S&&(s[p]={...x,activityType:f.activityType,content:q(f.content)}):S&&(s[p]=I,H=I),c({messages:s}),H&&await Promise.all(r.map(U=>U.onNewMessage?.({message:H,messages:s,state:a,agent:n,input:t})))}return h()}case v.ACTIVITY_DELTA:{let f=m,p=s.findIndex(T=>T.id===f.messageId);if(p===-1)return h();let g=s[p];if(g.role!=="activity")return console.warn(`ACTIVITY_DELTA: Message '${f.messageId}' is not an activity message`),h();let x=g,S=await K(r,s,a,(T,I,H)=>T.onActivityDeltaEvent?.({event:f,messages:I,state:H,agent:n,input:t,activityMessage:x}));if(c(S),S.stopPropagation!==!0)try{let T=q(x.content??{}),I=eo.applyPatch(T,f.patch??[],!0,!1).newDocument;s[p]={...x,content:q(I),activityType:f.activityType},c({messages:s})}catch(T){let I=T instanceof Error?T.message:String(T);console.warn(`Failed to apply activity patch for '${f.messageId}': ${I}`)}return h()}case v.RAW:return c(await K(r,s,a,(f,p,g)=>f.onRawEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.CUSTOM:return c(await K(r,s,a,(f,p,g)=>f.onCustomEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.RUN_STARTED:{let f=await K(r,s,a,(p,g,x)=>p.onRunStartedEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let p=m;if(p.input?.messages){for(let g of p.input.messages)s.find(x=>x.id===g.id)||s.push(g);c({messages:s})}}return h()}case v.RUN_FINISHED:{let f=m,p=f.outcome?.type==="interrupt"?{event:f,outcome:"interrupt",interrupts:f.outcome.interrupts}:{event:f,outcome:"success",result:f.result},g=await K(r,s,a,(x,S,T)=>x.onRunFinishedEvent?.({...p,messages:S,state:T,agent:n,input:t}));return c(g),g.stopPropagation!==!0&&(n.pendingInterrupts=p.outcome==="interrupt"?[...p.interrupts]:[]),h()}case v.RUN_ERROR:return c(await K(r,s,a,(f,p,g)=>f.onRunErrorEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.STEP_STARTED:return c(await K(r,s,a,(f,p,g)=>f.onStepStartedEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.STEP_FINISHED:return c(await K(r,s,a,(f,p,g)=>f.onStepFinishedEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.TEXT_MESSAGE_CHUNK:throw Error("TEXT_MESSAGE_CHUNK must be tranformed before being applied");case v.TOOL_CALL_CHUNK:throw Error("TOOL_CALL_CHUNK must be tranformed before being applied");case v.THINKING_START:return h();case v.THINKING_END:return h();case v.THINKING_TEXT_MESSAGE_START:return h();case v.THINKING_TEXT_MESSAGE_CONTENT:return h();case v.THINKING_TEXT_MESSAGE_END:return h();case v.REASONING_START:return c(await K(r,s,a,(f,p,g)=>f.onReasoningStartEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.REASONING_MESSAGE_START:{let f=await K(r,s,a,(p,g,x)=>p.onReasoningMessageStartEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{messageId:p}=m;if(!s.find(g=>g.id===p)){let g={id:p,role:"reasoning",content:""};s.push(g),c({messages:s})}}return h()}case v.REASONING_MESSAGE_CONTENT:{let{messageId:f,delta:p}=m,g=s.find(S=>S.id===f);if(!g)return console.warn(`REASONING_MESSAGE_CONTENT: No message found with ID '${f}'`),h();let x=await K(r,s,a,(S,T,I)=>S.onReasoningMessageContentEvent?.({event:m,messages:T,state:I,agent:n,input:t,reasoningMessageBuffer:typeof g.content=="string"?g.content:""}));return c(x),x.stopPropagation!==!0&&(g.content=`${typeof g.content=="string"?g.content:""}${p}`,c({messages:s})),h()}case v.REASONING_MESSAGE_END:{let{messageId:f}=m,p=s.find(g=>g.id===f);return p?(c(await K(r,s,a,(g,x,S)=>g.onReasoningMessageEndEvent?.({event:m,messages:x,state:S,agent:n,input:t,reasoningMessageBuffer:typeof p.content=="string"?p.content:""}))),await Promise.all(r.map(g=>{g.onNewMessage?.({message:p,messages:s,state:a,agent:n,input:t})})),h()):(console.warn(`REASONING_MESSAGE_END: No message found with ID '${f}'`),h())}case v.REASONING_MESSAGE_CHUNK:throw Error("REASONING_MESSAGE_CHUNK must be transformed before being applied");case v.REASONING_END:return c(await K(r,s,a,(f,p,g)=>f.onReasoningEndEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.REASONING_ENCRYPTED_VALUE:{let{subtype:f,entityId:p,encryptedValue:g}=m,x=await K(r,s,a,(S,T,I)=>S.onReasoningEncryptedValueEvent?.({event:m,messages:T,state:I,agent:n,input:t}));if(c(x),x.stopPropagation!==!0){let S=!1;if(f==="tool-call"){for(let T of s)if(T.role==="assistant"&&T.toolCalls){let I=T.toolCalls.find(H=>H.id===p);if(I){I.encryptedValue=g,S=!0;break}}}else{let T=s.find(I=>I.id===p);T?.role!=="activity"&&T&&(T.encryptedValue=g,S=!0)}S&&(l.messages=s)}return h()}}return m.type,h()}),$s(),r.length>0?Bs({}):m=>m)},aa=t=>e=>{let n=sr(t),r=new Map,o=new Map,i=!1,s=!1,a=!1,l=new Map,c=!1,h=!1,m=!1,y=()=>{r.clear(),o.clear(),l.clear(),c=!1,h=!1,i=!1,s=!1,m=!0};return e.pipe(Me(f=>{let p=f.type;if(n?.event("VERIFY","Event:",f,{type:f.type}),s)return ne(()=>new ee(`Cannot send event type '${p}': The run has already errored with 'RUN_ERROR'. No further events can be sent.`));if(i&&p!==v.RUN_ERROR&&p!==v.RUN_STARTED)return ne(()=>new ee(`Cannot send event type '${p}': The run has already finished with 'RUN_FINISHED'. Start a new run with 'RUN_STARTED'.`));if(a){if(p===v.RUN_STARTED){if(m&&!i)return ne(()=>new ee("Cannot send 'RUN_STARTED' while a run is still active. The previous run must be finished with 'RUN_FINISHED' before starting a new run."));i&&y()}}else if(a=!0,p!==v.RUN_STARTED&&p!==v.RUN_ERROR)return ne(()=>new ee("First event must be 'RUN_STARTED'"));switch(p){case v.TEXT_MESSAGE_START:{let g=f.messageId;return r.has(g)?ne(()=>new ee(`Cannot send 'TEXT_MESSAGE_START' event: A text message with ID '${g}' is already in progress. Complete it with 'TEXT_MESSAGE_END' first.`)):(r.set(g,!0),ue(f))}case v.TEXT_MESSAGE_CONTENT:{let g=f.messageId;return r.has(g)?ue(f):ne(()=>new ee(`Cannot send 'TEXT_MESSAGE_CONTENT' event: No active text message found with ID '${g}'. Start a text message with 'TEXT_MESSAGE_START' first.`))}case v.TEXT_MESSAGE_END:{let g=f.messageId;return r.has(g)?(r.delete(g),ue(f)):ne(()=>new ee(`Cannot send 'TEXT_MESSAGE_END' event: No active text message found with ID '${g}'. A 'TEXT_MESSAGE_START' event must be sent first.`))}case v.TOOL_CALL_START:{let g=f.toolCallId;return o.has(g)?ne(()=>new ee(`Cannot send 'TOOL_CALL_START' event: A tool call with ID '${g}' is already in progress. Complete it with 'TOOL_CALL_END' first.`)):(o.set(g,!0),ue(f))}case v.TOOL_CALL_ARGS:{let g=f.toolCallId;return o.has(g)?ue(f):ne(()=>new ee(`Cannot send 'TOOL_CALL_ARGS' event: No active tool call found with ID '${g}'. Start a tool call with 'TOOL_CALL_START' first.`))}case v.TOOL_CALL_END:{let g=f.toolCallId;return o.has(g)?(o.delete(g),ue(f)):ne(()=>new ee(`Cannot send 'TOOL_CALL_END' event: No active tool call found with ID '${g}'. A 'TOOL_CALL_START' event must be sent first.`))}case v.STEP_STARTED:{let g=f.stepName;return l.has(g)?ne(()=>new ee(`Step "${g}" is already active for 'STEP_STARTED'`)):(l.set(g,!0),ue(f))}case v.STEP_FINISHED:{let g=f.stepName;return l.has(g)?(l.delete(g),ue(f)):ne(()=>new ee(`Cannot send 'STEP_FINISHED' for step "${g}" that was not started`))}case v.RUN_STARTED:return m=!0,ue(f);case v.RUN_FINISHED:if(l.size>0){let g=Array.from(l.keys()).join(", ");return ne(()=>new ee(`Cannot send 'RUN_FINISHED' while steps are still active: ${g}`))}if(r.size>0){let g=Array.from(r.keys()).join(", ");return ne(()=>new ee(`Cannot send 'RUN_FINISHED' while text messages are still active: ${g}`))}if(o.size>0){let g=Array.from(o.keys()).join(", ");return ne(()=>new ee(`Cannot send 'RUN_FINISHED' while tool calls are still active: ${g}`))}return i=!0,ue(f);case v.RUN_ERROR:return s=!0,ue(f);case v.CUSTOM:return ue(f);case v.THINKING_TEXT_MESSAGE_START:return c?h?ne(()=>new ee("Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking message is already in progress. Complete it with 'THINKING_TEXT_MESSAGE_END' first.")):(h=!0,ue(f)):ne(()=>new ee("Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking step is not in progress. Create one with 'THINKING_START' first."));case v.THINKING_TEXT_MESSAGE_CONTENT:return h?ue(f):ne(()=>new ee("Cannot send 'THINKING_TEXT_MESSAGE_CONTENT' event: No active thinking message found. Start a message with 'THINKING_TEXT_MESSAGE_START' first."));case v.THINKING_TEXT_MESSAGE_END:return h?(h=!1,ue(f)):ne(()=>new ee("Cannot send 'THINKING_TEXT_MESSAGE_END' event: No active thinking message found. A 'THINKING_TEXT_MESSAGE_START' event must be sent first."));case v.THINKING_START:return c?ne(()=>new ee("Cannot send 'THINKING_START' event: A thinking step is already in progress. End it with 'THINKING_END' first.")):(c=!0,ue(f));case v.THINKING_END:return c?(c=!1,ue(f)):ne(()=>new ee("Cannot send 'THINKING_END' event: No active thinking step found. A 'THINKING_START' event must be sent first."));default:return ue(f)}}))},en=(function(t){return t.HEADERS="headers",t.DATA="data",t})({}),Hm=t=>wo(()=>Zt(t())).pipe(Vs(e=>{if(!e.ok){let o=e.headers.get("content-type")||"";return Zt(e.text()).pipe(Me(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,ne(()=>a)}))}let n={type:en.HEADERS,status:e.status,headers:e.headers},r=e.body?.getReader();return r?new te(o=>(o.next(n),(async()=>{try{for(;;){let{done:i,value:s}=await r.read();if(i)break;let a={type:en.DATA,data:s};o.next(a)}o.complete()}catch(i){o.error(i)}})(),()=>{r.cancel().catch(i=>{if(i?.name!=="AbortError")throw i})})):ne(()=>Error("Failed to getReader() from response"))})),zm=(t,e)=>{let n=sr(e),r=new st,o=new TextDecoder("utf-8",{fatal:!1}),i="";t.subscribe({next:a=>{if(a.type!==en.HEADERS&&a.type===en.DATA&&a.data){let l=o.decode(a.data,{stream:!0});i+=l;let c=i.split(/\n\n/);i=c.pop()||"";for(let h of c)s(h)}},error:a=>r.error(a),complete:()=>{i&&(i+=o.decode(),s(i)),r.complete()}});function s(a){let l=a.split(`
|
|
9
9
|
`),c=[];for(let h of l)h.startsWith("data:")&&c.push(h.slice(5).replace(/^ /,""));if(c.length>0)try{let h=c.join(`
|
|
10
|
-
`),m=JSON.parse(h);n?.event("SSE","Event received:",m,{type:m.type}),r.next(m)}catch(h){r.error(h)}}return r.asObservable()},
|
|
11
|
-
`)},Dm=(t,e,n)=>r=>{let o={},i=!0,s=!0,a="",l=null,c=null,h=[],m={},y=f=>{typeof f=="object"&&f&&("messages"in f&&delete f.messages,o=f)};return r.pipe(Me(f=>{switch(f.type){case v.TEXT_MESSAGE_START:{let p=f;return[{type:Q.enum.TextMessageStart,messageId:p.messageId,role:p.role}]}case v.TEXT_MESSAGE_CONTENT:{let p=f;return[{type:Q.enum.TextMessageContent,messageId:p.messageId,content:p.delta}]}case v.TEXT_MESSAGE_END:{let p=f;return[{type:Q.enum.TextMessageEnd,messageId:p.messageId}]}case v.TOOL_CALL_START:{let p=f;return h.push({id:p.toolCallId,type:"function",function:{name:p.toolCallName,arguments:""}}),s=!0,m[p.toolCallId]=p.toolCallName,[{type:Q.enum.ActionExecutionStart,actionExecutionId:p.toolCallId,actionName:p.toolCallName,parentMessageId:p.parentMessageId}]}case v.TOOL_CALL_ARGS:{let p=f,g=h.find(_=>_.id===p.toolCallId);if(!g)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${p.toolCallId}'`),[];g.function.arguments+=p.delta;let x=!1;if(c){let _=c.find(w=>w.tool==g.function.name);if(_)try{let w=JSON.parse(So(g.function.arguments));_.tool_argument&&_.tool_argument in w?(y({...o,[_.state_key]:w[_.tool_argument]}),x=!0):_.tool_argument||(y({...o,[_.state_key]:w}),x=!0)}catch{}}return[{type:Q.enum.ActionExecutionArgs,actionExecutionId:p.toolCallId,args:p.delta},...x?[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:s}]:[]]}case v.TOOL_CALL_END:{let p=f;return[{type:Q.enum.ActionExecutionEnd,actionExecutionId:p.toolCallId}]}case v.TOOL_CALL_RESULT:{let p=f;return[{type:Q.enum.ActionExecutionResult,actionExecutionId:p.toolCallId,result:p.content,actionName:m[p.toolCallId]||"unknown"}]}case v.RAW:return[];case v.CUSTOM:{let p=f;switch(p.name){case"Exit":i=!1;break;case"PredictState":c=p.value;break}return[{type:Q.enum.MetaEvent,name:p.name,value:p.value}]}case v.STATE_SNAPSHOT:return y(f.snapshot),[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:s}];case v.STATE_DELTA:{let p=f,g=Zr.applyPatch(o,p.delta,!0,!1);return g?(y(g.newDocument),[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:s}]):[]}case v.MESSAGES_SNAPSHOT:return l=f.messages,[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify({...o,...l?{messages:l}:{}}),active:!0}];case v.RUN_STARTED:return[];case v.RUN_FINISHED:return l&&(o.messages=l),Object.keys(o).length===0?[]:[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify({...o,...l?{messages:Um(l)}:{}}),active:!1}];case v.RUN_ERROR:{let p=f;return[{type:Q.enum.RunError,message:p.message,code:p.code}]}case v.STEP_STARTED:return a=f.stepName,h=[],c=null,[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:!0}];case v.STEP_FINISHED:return h=[],c=null,[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:!1}];default:return[]}}))};function Um(t){let e=[];for(let n of t)if(n.role==="assistant"||n.role==="user"||n.role==="system"){let r=Pm(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 si=t=>e=>{let n=or(t),r,o,i,s,a=()=>{if(!r||s!=="text")throw Error("No text message to close");let m={type:v.TEXT_MESSAGE_END,messageId:r.messageId};return s=void 0,r=void 0,n?.event("TRANSFORM","TEXT_MESSAGE_END",m,{messageId:m.messageId}),m},l=()=>{if(!o||s!=="tool")throw Error("No tool call to close");let m={type:v.TOOL_CALL_END,toolCallId:o.toolCallId};return s=void 0,o=void 0,n?.event("TRANSFORM","TOOL_CALL_END",m,{toolCallId:m.toolCallId}),m},c=()=>{if(!i||s!=="reasoning")throw Error("No reasoning message to close");let m={type:v.REASONING_MESSAGE_END,messageId:i.messageId};return s=void 0,i=void 0,n?.event("TRANSFORM","REASONING_MESSAGE_END",m,{messageId:m.messageId}),m},h=()=>s==="text"?[a()]:s==="tool"?[l()]:s==="reasoning"?[c()]:[];return e.pipe(Me(m=>{switch(m.type){case v.TEXT_MESSAGE_START:case v.TEXT_MESSAGE_CONTENT:case v.TEXT_MESSAGE_END:case v.TOOL_CALL_START:case v.TOOL_CALL_ARGS:case v.TOOL_CALL_END:case v.TOOL_CALL_RESULT:case v.STATE_SNAPSHOT:case v.STATE_DELTA:case v.MESSAGES_SNAPSHOT:case v.CUSTOM:case v.RUN_STARTED:case v.RUN_FINISHED:case v.RUN_ERROR:case v.STEP_STARTED:case v.STEP_FINISHED:case v.THINKING_START:case v.THINKING_END:case v.THINKING_TEXT_MESSAGE_START:case v.THINKING_TEXT_MESSAGE_CONTENT:case v.THINKING_TEXT_MESSAGE_END:case v.REASONING_START:case v.REASONING_MESSAGE_START:case v.REASONING_MESSAGE_CONTENT:case v.REASONING_MESSAGE_END:case v.REASONING_END:return[...h(),m];case v.RAW:case v.ACTIVITY_SNAPSHOT:case v.ACTIVITY_DELTA:case v.REASONING_ENCRYPTED_VALUE:return[m];case v.TEXT_MESSAGE_CHUNK:let y=m,f=[];if((s!=="text"||y.messageId!==void 0&&y.messageId!==r?.messageId)&&f.push(...h()),s!=="text"){if(y.messageId===void 0)throw Error("First TEXT_MESSAGE_CHUNK must have a messageId");r={messageId:y.messageId,name:y.name},s="text";let w={type:v.TEXT_MESSAGE_START,messageId:y.messageId,role:y.role||"assistant",...y.name!==void 0&&{name:y.name}};f.push(w),n?.event("TRANSFORM","TEXT_MESSAGE_START",w,{messageId:y.messageId})}if(y.delta!==void 0){let w={type:v.TEXT_MESSAGE_CONTENT,messageId:r.messageId,delta:y.delta};f.push(w),n?.event("TRANSFORM","TEXT_MESSAGE_CONTENT",w,{messageId:r.messageId})}return f;case v.TOOL_CALL_CHUNK:let p=m,g=[];if((s!=="tool"||p.toolCallId!==void 0&&p.toolCallId!==o?.toolCallId)&&g.push(...h()),s!=="tool"){if(p.toolCallId===void 0)throw Error("First TOOL_CALL_CHUNK must have a toolCallId");if(p.toolCallName===void 0)throw Error("First TOOL_CALL_CHUNK must have a toolCallName");o={toolCallId:p.toolCallId,toolCallName:p.toolCallName,parentMessageId:p.parentMessageId},s="tool";let w={type:v.TOOL_CALL_START,toolCallId:p.toolCallId,toolCallName:p.toolCallName,parentMessageId:p.parentMessageId};g.push(w),n?.event("TRANSFORM","TOOL_CALL_START",w,{toolCallId:p.toolCallId,toolCallName:p.toolCallName})}if(p.delta!==void 0){let w={type:v.TOOL_CALL_ARGS,toolCallId:o.toolCallId,delta:p.delta};g.push(w),n?.event("TRANSFORM","TOOL_CALL_ARGS",w,{toolCallId:o.toolCallId})}return g;case v.REASONING_MESSAGE_CHUNK:let x=m,_=[];if((s!=="reasoning"||x.messageId&&x.messageId!==i?.messageId)&&_.push(...h()),s!=="reasoning"){if(x.messageId===void 0)throw Error("First REASONING_MESSAGE_CHUNK must have a messageId");i={messageId:x.messageId},s="reasoning";let w={type:v.REASONING_MESSAGE_START,messageId:x.messageId};_.push(w),n?.event("TRANSFORM","REASONING_MESSAGE_START",w,{messageId:x.messageId})}if(x.delta!==void 0){let w={type:v.REASONING_MESSAGE_CONTENT,messageId:i.messageId,delta:x.delta};_.push(w),n?.event("TRANSFORM","REASONING_MESSAGE_CONTENT",w,{messageId:i.messageId})}return _}return m.type,[]}),Jt(()=>{h()}))};function Hm(t,e=new Date){return t.expiresAt===void 0?!1:new Date(t.expiresAt)<=e}function nu(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];if(a.status==="resolved"){let l={interruptId:s.id,status:"resolved"};return a.payload!==void 0&&(l.payload=a.payload),l}return{interruptId:s.id,status:"cancelled"}})}var ai=class{runNext(t,e){return e.run(t).pipe(si(!1))}runNextWithState(t,e){let n=q(t.messages||[]),r=q(t.state||{}),o=new io;return tu(t,o,e,[]).subscribe(i=>{i.messages!==void 0&&(n=i.messages),i.state!==void 0&&(r=i.state)}),this.runNext(t,e).pipe(To(async i=>(o.next(i),await new Promise(s=>setTimeout(s,0)),{event:i,messages:q(n),state:q(r)})))}},Gm=class extends ai{constructor(t){super(),this.fn=t}run(t,e){return this.fn(t,e)}};function zm(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 Fm=class extends ai{run(t,e){let{parentRunId:n,...r}=t,o={...r,messages:r.messages.map(zm)};return this.runNext(o,e)}},Kc="THINKING_START",Zc="THINKING_END",Jc="THINKING_TEXT_MESSAGE_START",Qc="THINKING_TEXT_MESSAGE_CONTENT",eu="THINKING_TEXT_MESSAGE_END",$m=class extends ai{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(Zt(n=>this.transformEvent(n)))}transformEvent(t){switch(t.type){case Kc:{this.currentReasoningId=Ue();let{title:e,...n}=t;return this.warnAboutTransformation(Kc,v.REASONING_START),{...n,type:v.REASONING_START,messageId:this.currentReasoningId}}case Jc:return this.currentMessageId=Ue(),this.warnAboutTransformation(Jc,v.REASONING_MESSAGE_START),{...t,type:v.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:"assistant"};case Qc:{let{delta:e,...n}=t;return this.warnAboutTransformation(Qc,v.REASONING_MESSAGE_CONTENT),{...n,type:v.REASONING_MESSAGE_CONTENT,messageId:this.currentMessageId??Ue(),delta:e}}case eu:{let e=this.currentMessageId??Ue();return this.warnAboutTransformation(eu,v.REASONING_MESSAGE_END),{...t,type:v.REASONING_MESSAGE_END,messageId:e}}case Zc:{let e=this.currentReasoningId??Ue();return this.warnAboutTransformation(Zc,v.REASONING_END),{...t,type:v.REASONING_END,messageId:e}}default:return t}}};function Bm(t){return t.startsWith("image/")?"image":t.startsWith("audio/")?"audio":t.startsWith("video/")?"video":"document"}function Vm(t){return typeof t=="object"&&!!t&&"type"in t&&t.type==="binary"&&"mimeType"in t&&typeof t.mimeType=="string"}function jm(t){let e=Bm(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 qm(t){let e=t.content;if(!Array.isArray(e))return t;let n=e.map(r=>Vm(r)?jm(r):r);return{...t,content:n}}var Wm=class extends ai{run(t,e){let n={...t,messages:t.messages.map(qm)};return this.runNext(n,e)}},Xm="0.0.57",Ym=class{get maxVersion(){return Xm}get debug(){return this._debug}set debug(t){this._debug=ii(t),this._debugLogger=ta(this._debug)}get debugLogger(){return this._debugLogger}set debugLogger(t){typeof t=="boolean"?this._debugLogger=t?ta(ii(!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??yt(),this.messages=q(r??[]),this.state=q(o??{}),this._debug=ii(i),this._debugLogger=ta(this._debug),rr(this.maxVersion,"0.0.39")<=0&&this.middlewares.unshift(new Fm),rr(this.maxVersion,"0.0.45")<=0&&this.middlewares.unshift(new $m),rr(this.maxVersion,"0.0.47")<=0&&this.middlewares.unshift(new Wm)}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 Gm(n):n);return this.middlewares.push(...e),this}async runAgent(t,e){try{this.isRunning=!0,this.agentId=this.agentId??yt();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 it;let s;this.activeRunCompletionPromise=new Promise(l=>{s=l}),await xo(oo(()=>this.middlewares.length===0?this.run(n):this.middlewares.reduceRight((l,c)=>({run:h=>c.run(h,l),get messages(){return l.messages},get state(){return l.state}}),this).run(n),si(this.debugLogger),na(this.debugLogger),l=>l.pipe(wo(this.activeRunDetach$)),l=>this.apply(n,l,i),l=>this.processApplyEvents(n,l,i),er(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))),Jt(()=>{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}))(ue(null)));let a=q(this.messages).filter(l=>!o.has(l.id));return{result:r,newMessages:a}}finally{this.isRunning=!1}}connect(t){throw new Ss}async connectAgent(t,e){try{this.isRunning=!0,this.agentId=this.agentId??yt();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 it;let s;this.activeRunCompletionPromise=new Promise(l=>{s=l}),await xo(oo(()=>Eo(()=>this.connect(n)),si(this.debugLogger),na(this.debugLogger),l=>l.pipe(wo(this.activeRunDetach$)),l=>this.apply(n,l,i),l=>this.processApplyEvents(n,l,i),er(l=>(this.isRunning=!1,l instanceof Ss?so:this.onError(n,l,i))),Jt(()=>{this.isRunning=!1,this.onFinalize(n,i),s?.(),s=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(ue(null)),{defaultValue:void 0});let a=q(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 tu(t,e,this,n,this.debugLogger)}processApplyEvents(t,e,n){return e.pipe(zs(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=q(this.messages).filter(n=>n.role!=="activity");return{threadId:this.threadId,runId:t?.runId||yt(),tools:q(t?.tools??[]),context:q(t?.context??[]),forwardedProps:q(t?.forwardedProps??{}),state:q(this.state),messages:e,...t?.resume===void 0?{}:{resume:q(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 ee(`Thread has ${o.length} pending interrupt(s) not addressed by resume: ${o.join(", ")}`);for(let i of this.pendingInterrupts)if(Hm(i))throw new ee(`Interrupt ${i.id} expired at ${i.expiresAt}`)}let n=await K(e,this.messages,this.state,(r,o,i)=>r.onRunInitialized?.({messages:o,state:i,agent:this,input:t}));(n.messages!==void 0||n.state!==void 0)&&(n.messages&&(this.messages=n.messages,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 Kt(K(n,this.messages,this.state,(r,o,i)=>r.onRunFailed?.({error:e,messages:o,state:i,agent:this,input:t}))).pipe(Zt(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 K(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=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 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=q(t),(async()=>{for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setState(t){this.state=q(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??yt();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(si(this.debugLogger),na(this.debugLogger),Dm(this.threadId,e.runId,this.agentId),n=>n.pipe(Zt(r=>(this.debugLogger?.event("LEGACY","Event:",r,{type:r.type}),r))))}},ru=class extends Ym{requestInit(t){return{method:"POST",headers:{...this.headers,"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(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=q(t.headers??{}),this.fetch=t.fetch??((e,n)=>fetch(e,n))}run(t){return wm(xm(()=>this.fetch(this.url,this.requestInit(t))),this.debugLogger)}clone(){let t=super.clone();t.url=this.url,t.headers=q(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}};var li=class{element;#n;#e;#t=[];constructor(e){this.#n=e,this.#e=e.strings??ae,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:Ue(),file:e,status:Pe.UPLOADING,progress:0,ref:null,error:"",controller:null};this.#t.push(n);let r=this.#s(e);if(r!==null){n.status=Pe.ERROR,n.error=r,this.#o(),this.#n.onChange?.();return}this.#o(),this.#n.onChange?.(),this.#r(n)}readyRefs(){let e=[];for(let n of this.#t)n.ref!==null&&e.push(n.ref);return e}hasPending(){return this.#t.some(e=>e.status===Pe.UPLOADING)}pendingCount(){return this.#t.filter(e=>e.status===Pe.UPLOADING).length}isEmpty(){return this.#t.length===0}clearReady(){this.#t=this.#t.filter(e=>e.status===Pe.UPLOADING),this.#o()}clear(){for(let e of this.#t)e.controller?.abort();this.#t=[],this.#o()}dispose(){for(let e of this.#t)e.controller?.abort()}#s(e){return this.#n.maxBytes>0&&e.size>this.#n.maxBytes?this.#e.tooLarge.replace("{size}",Pr(this.#n.maxBytes)):Km(this.#n.accept,e)?null:this.#e.fileTypeNotAllowed}#r(e){let n=this.#s(e.file);if(n!==null){e.status=Pe.ERROR,e.error=n,this.#o(),this.#n.onChange?.();return}e.status=Pe.UPLOADING,e.progress=0,e.error="";let r=new AbortController;e.controller=r,this.#o(),this.#n.upload(e.file,o=>{e.progress=o,this.#o()},r.signal).then(o=>{e.status=Pe.READY,e.ref=o}).catch(o=>{e.status=Pe.ERROR,e.error=o instanceof Error?o.message:this.#e.uploadFailed}).finally(()=>{e.controller=null,this.#o(),this.#n.onChange?.()})}#a(e){e.controller?.abort(),this.#t=this.#t.filter(n=>n!==e),this.#o(),this.#n.onChange?.()}#o(){this.element.replaceChildren(),this.element.hidden=this.#t.length===0;for(let e of this.#t)this.element.appendChild(this.#i(e))}#i(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.textContent=vs(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===Pe.ERROR?e.error:Pr(e.file.size),n.append(r,o,i),e.status===Pe.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===Pe.ERROR){let a=document.createElement("button");a.type="button",a.className="attachment-chip-retry",a.setAttribute("part","attachment-chip-retry"),a.title=this.#e.retry,a.setAttribute("aria-label",this.#e.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.#e.remove,s.setAttribute("aria-label",this.#e.removeAttachment),s.textContent="\u2715",s.addEventListener("click",()=>this.#a(e)),n.appendChild(s),n}};function Km(t,e){let n=t.split(",").map(i=>i.trim().toLowerCase()).filter(i=>i!=="");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)}function ci(t,e=Date.now(),n=ae){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 n.minutesAgo.replace("{n}",String(o));let i=Math.round(o/60);if(i<24)return n.hoursAgo.replace("{n}",String(i));let s=Math.round(i/24);return s<7?n.daysAgo.replace("{n}",String(s)):n.weeksAgo.replace("{n}",String(Math.round(s/7)))}var ir=class{element;#n;#e;#t;#s=null;#r;#a=[];constructor(e,n=ae){this.#n=e,this.#r=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.#t=document.createElement("span"),this.#t.className="checkpoints-title",this.#t.setAttribute("part","checkpoints-title"),this.#t.textContent=n.checkpoints,r.append(this.#t),this.#e=document.createElement("div"),this.#e.className="checkpoints-list",this.#e.setAttribute("part","checkpoints-list"),this.element.append(r,this.#e),this.element.addEventListener("keydown",o=>this.#l(o))}setRuns(e){this.#a=e,this.#c()}setStrings(e){this.#r=e,this.element.setAttribute("aria-label",e.checkpoints),this.#t.textContent=e.checkpoints,this.#c()}open(){this.open_||(this.#s=this.#o(),this.element.hidden=!1,(this.#i()[0]??this.element).focus())}close(){this.open_&&(this.element.hidden=!0,this.#s?.focus(),this.#s=null)}#o(){return this.element.getRootNode().activeElement}#i(){return Array.from(this.element.querySelectorAll("button, [tabindex]")).filter(e=>!e.hidden)}#l(e){if(e.key==="Escape"){e.stopPropagation(),this.close();return}if(e.key!=="Tab")return;let n=this.#i(),r=n[0],o=n[n.length-1],i=this.#o();e.shiftKey&&i===r?(e.preventDefault(),o?.focus()):!e.shiftKey&&i===o&&(e.preventDefault(),r?.focus())}get open_(){return!this.element.hidden}#c(){if(this.#e.replaceChildren(),this.#a.length===0){let e=document.createElement("div");e.className="checkpoints-empty",e.setAttribute("part","checkpoints-empty"),e.textContent=this.#r.noCheckpoints,this.#e.append(e);return}for(let e of this.#a)this.#e.append(this.#d(e))}#d(e){let n=document.createElement("div");n.className="checkpoint-row",n.setAttribute("part","checkpoint-row");let r=document.createElement("span");if(r.className="checkpoint-label",r.setAttribute("part","checkpoint-label"),r.textContent=e.started_at===null?e.run_id:ci(Date.parse(e.started_at),Date.now(),this.#r),r.title=e.run_id,n.append(r),e.parent_run_id!==null){let o=document.createElement("span");o.className="checkpoint-branch",o.setAttribute("part","checkpoint-branch"),o.textContent=this.#r.forkedRun,o.title=e.parent_run_id,n.append(o)}return n.append(this.#u(e.run_id,"resume",this.#r.resumeRun),this.#u(e.run_id,"fork",this.#r.forkRun)),n}#u(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.#n(e,n)}),o}};function ou(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 ia(t,e,n={}){let r=n.strings??ae;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??r.confirmRun.replace("{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 c=ou("cancel",r.cancel),h=ou("confirm",r.confirm),m=!1,y=f=>{m||(m=!0,i.remove(),o(f))};if(c.addEventListener("click",()=>y(!1)),h.addEventListener("click",()=>y(!0)),n.signal?.addEventListener("abort",()=>y(!1),{once:!0}),l.append(c,h),i.append(s,a,l),t.appendChild(i),n.signal?.aborted===!0){y(!1);return}h.focus()})}function sa(t){let e=t.replace(/[._-]+/g," ").trim();return e===""?t:e.charAt(0).toUpperCase()+e.slice(1)}function Zm(t){let e=document.createElement("input");return e.type="text",e.className="question-input",e.setAttribute("part","question-input"),e.placeholder=t,e}function aa(t,e,n={}){let r=n.strings??ae,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 c=document.createElement("div");c.className="question-body",c.setAttribute("part","question-body"),c.textContent=e.question;let h=document.createElement("div");h.className="question-options",h.setAttribute("part","question-options");let m=`q-${o.length}-${e.question.length}`,y=[];for(let U of o){let Y=document.createElement("label");Y.className="question-choice",Y.setAttribute("part","question-choice");let re=document.createElement("input");re.type="radio",re.name=m,re.value=U,re.setAttribute("part","question-radio");let Be=document.createElement("span");Be.setAttribute("part","question-choice-text"),Be.textContent=U,Y.append(re,Be),h.appendChild(Y),y.push(re)}let f=null,p=null;if(s){if(p=Zm(r.answerPlaceholder),i){let U=document.createElement("label");U.className="question-choice",U.setAttribute("part","question-choice"),f=document.createElement("input"),f.type="radio",f.name=m,f.value="",f.setAttribute("part","question-radio");let Y=document.createElement("span");Y.setAttribute("part","question-choice-text"),Y.textContent=r.otherOption,U.append(f,Y),h.appendChild(U),p.disabled=!0}h.appendChild(p)}let g=document.createElement("div");g.className="question-actions",g.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,g.appendChild(x);let _=!1,w=()=>{let U=y.find(Y=>Y.checked);if(U!==void 0)return U.value;if(p!==null&&(f===null||f.checked)){let Y=p.value.trim();return Y===""?null:Y}return null},C=()=>{p!==null&&f!==null&&(p.disabled=!f.checked),x.disabled=w()===null},H=U=>{if(!_){_=!0,x.disabled=!0;for(let Y of y)Y.disabled=!0;f!==null&&(f.disabled=!0),p!==null&&(p.disabled=!0),l.setAttribute("data-resolved",U===""?"cancelled":"answered"),a(U)}};for(let U of[...y,...f!==null?[f]:[]])U.addEventListener("change",C);if(p?.addEventListener("input",C),p?.addEventListener("keydown",U=>{if(U.key==="Enter"){U.preventDefault();let Y=w();Y!==null&&H(Y)}}),x.addEventListener("click",()=>{let U=w();U!==null&&H(U)}),n.signal?.addEventListener("abort",()=>H(""),{once:!0}),l.append(c,h,g),t.appendChild(l),n.signal?.aborted===!0){H("");return}C(),(i?y[0]:p)?.focus()})}function iu(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Jm(t){if(Array.isArray(t))return t}function Qm(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,o,i,s,a=[],l=!0,c=!1;try{if(i=(n=n.call(t)).next,e!==0)for(;!(l=(r=i.call(n)).done)&&(a.push(r.value),a.length!==e);l=!0);}catch(h){c=!0,o=h}finally{try{if(!l&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw o}}return a}}function eg(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
12
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function tg(t,e){return Jm(t)||Qm(t,e)||ng(t,e)||eg()}function ng(t,e){if(t){if(typeof t=="string")return iu(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)?iu(t,e):void 0}}var xu=Object.entries,su=Object.setPrototypeOf,rg=Object.isFrozen,og=Object.getPrototypeOf,ig=Object.getOwnPropertyDescriptor,we=Object.freeze,Se=Object.seal,Nn=Object.create,Eu=typeof Reflect<"u"&&Reflect,ha=Eu.apply,fa=Eu.construct;we||(we=function(e){return e});Se||(Se=function(e){return e});ha||(ha=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)});fa||(fa=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 Cn=me(Array.prototype.forEach),sg=me(Array.prototype.lastIndexOf),au=me(Array.prototype.pop),Rn=me(Array.prototype.push),ag=me(Array.prototype.splice),At=Array.isArray,lr=me(String.prototype.toLowerCase),la=me(String.prototype.toString),lu=me(String.prototype.match),sr=me(String.prototype.replace),cu=me(String.prototype.indexOf),lg=me(String.prototype.trim),cg=me(Number.prototype.toString),ug=me(Boolean.prototype.toString),uu=typeof BigInt>"u"?null:me(BigInt.prototype.toString),du=typeof Symbol>"u"?null:me(Symbol.prototype.toString),ye=me(Object.prototype.hasOwnProperty),ar=me(Object.prototype.toString),be=me(RegExp.prototype.test),en=dg(TypeError);function me(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 ha(t,e,r)}}function dg(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return fa(t,n)}}function W(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:lr;if(su&&su(t,null),!At(e))return t;let r=e.length;for(;r--;){let o=e[r];if(typeof o=="string"){let i=n(o);i!==o&&(rg(e)||(e[r]=i),o=i)}t[o]=!0}return t}function pg(t){for(let e=0;e<t.length;e++)ye(t,e)||(t[e]=null);return t}function Ae(t){let e=Nn(null);for(let r of xu(t)){var n=tg(r,2);let o=n[0],i=n[1];ye(t,o)&&(At(i)?e[o]=pg(i):i&&typeof i=="object"&&i.constructor===Object?e[o]=Ae(i):e[o]=i)}return e}function hg(t){switch(typeof t){case"string":return t;case"number":return cg(t);case"boolean":return ug(t);case"bigint":return uu?uu(t):"0";case"symbol":return du?du(t):"Symbol()";case"undefined":return ar(t);case"function":case"object":{if(t===null)return ar(t);let e=t,n=Xe(e,"toString");if(typeof n=="function"){let r=n(e);return typeof r=="string"?r:ar(r)}return ar(t)}default:return ar(t)}}function Xe(t,e){for(;t!==null;){let r=ig(t,e);if(r){if(r.get)return me(r.get);if(typeof r.value=="function")return me(r.value)}t=og(t)}function n(){return null}return n}function fg(t){try{return be(t,""),!0}catch{return!1}}var pu=we(["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"]),ca=we(["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"]),ua=we(["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"]),mg=we(["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"]),da=we(["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"]),gg=we(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),hu=we(["#text"]),fu=we(["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"]),pa=we(["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","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","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"]),mu=we(["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"]),ui=we(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),vg=Se(/{{[\w\W]*|^[\w\W]*}}/g),bg=Se(/<%[\w\W]*|^[\w\W]*%>/g),yg=Se(/\${[\w\W]*/g),xg=Se(/^data-[\-\w.\u00B7-\uFFFF]+$/),Eg=Se(/^aria-[\-\w]+$/),gu=Se(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Tg=Se(/^(?:\w+script|data):/i),wg=Se(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Sg=Se(/^html$/i),_g=Se(/^[a-z][.\w]*(-[.\w]+)+$/i),vu=Se(/<[/\w!]/g),bu=Se(/<[/\w]/g),Ag=Se(/<\/no(script|embed|frames)/i),kg=Se(/\/>/i),He={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Ig=function(){return typeof window>"u"?null:window},Cg=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}},yu=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},_t=function(e,n,r,o){return ye(e,n)&&At(e[n])?W(o.base?Ae(o.base):{},e[n],o.transform):r};function Tu(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ig(),e=S=>Tu(S);if(e.version="3.4.13",e.removed=[],!t||!t.document||t.document.nodeType!==He.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,c=t.NamedNodeMap;c===void 0&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;let h=t.DOMParser,m=t.trustedTypes,y=a.prototype,f=Xe(y,"cloneNode"),p=Xe(y,"remove"),g=Xe(y,"nextSibling"),x=Xe(y,"childNodes"),_=Xe(y,"parentNode"),w=Xe(y,"shadowRoot"),C=Xe(y,"attributes"),H=s&&s.prototype?Xe(s.prototype,"nodeType"):null,U=s&&s.prototype?Xe(s.prototype,"nodeName"):null,Y=s&&s.prototype?Xe(s.prototype,"ownerDocument"):null;if(typeof i=="function"){let S=n.createElement("template");S.content&&S.content.ownerDocument&&(n=S.content.ownerDocument)}let re,Be="",Si,Ma=!1,Pn=0,La=function(){if(Pn>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.')},on=function(d){La(),Pn++;try{return re.createHTML(d)}finally{Pn--}},nd=function(d){La(),Pn++;try{return re.createScriptURL(d)}finally{Pn--}},rd=function(){return Ma||(Si=Cg(m,o),Ma=!0),Si},br=n,_i=br.implementation,Pa=br.createNodeIterator,od=br.createDocumentFragment,id=br.getElementsByTagName,sd=r.importNode,oe=yu();e.isSupported=typeof xu=="function"&&typeof _=="function"&&_i&&_i.createHTMLDocument!==void 0;let ad=vg,ld=bg,cd=yg,ud=xg,dd=Eg,pd=Tg,Da=wg,hd=_g,Ua=gu,ie=null,Ai=W({},[...pu,...ca,...ua,...da,...hu]),se=null,ki=W({},[...fu,...pa,...mu,...ui]),de=Object.seal(Nn(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}})),Dn=null,Ha=null,mt=Object.seal(Nn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ga=!0,Ii=!0,za=!1,Fa=!0,gt=!1,vt=!0,It=!1,Ci=!1,yr=null,xr=null,Ri=!1,sn=!1,Er=!1,Tr=!1,$a=!0,Ba=!1,Va="user-content-",Ni=!0,wr=!1,an={},Ze=null,Oi=W({},["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"]),ja=null,qa=W({},["audio","video","img","source","image","track"]),Mi=null,Wa=W({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Sr="http://www.w3.org/1998/Math/MathML",_r="http://www.w3.org/2000/svg",Je="http://www.w3.org/1999/xhtml",ln=Je,Li=!1,Pi=null,fd=W({},[Sr,_r,Je],la),Xa=we(["mi","mo","mn","ms","mtext"]),Di=W({},Xa),Ya=we(["annotation-xml"]),Ui=W({},Ya),md=W({},["title","style","font","a","script"]),Un=null,gd=["application/xhtml+xml","text/html"],vd="text/html",le=null,cn=null,bd=n.createElement("form"),Ka=function(d){return d instanceof RegExp||d instanceof Function},Hi=function(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(cn&&cn===d)return;(!d||typeof d!="object")&&(d={}),d=Ae(d),Un=gd.indexOf(d.PARSER_MEDIA_TYPE)===-1?vd:d.PARSER_MEDIA_TYPE,le=Un==="application/xhtml+xml"?la:lr,ie=_t(d,"ALLOWED_TAGS",Ai,{transform:le}),se=_t(d,"ALLOWED_ATTR",ki,{transform:le}),Pi=_t(d,"ALLOWED_NAMESPACES",fd,{transform:la}),Mi=_t(d,"ADD_URI_SAFE_ATTR",Wa,{transform:le,base:Wa}),ja=_t(d,"ADD_DATA_URI_TAGS",qa,{transform:le,base:qa}),Ze=_t(d,"FORBID_CONTENTS",Oi,{transform:le}),Dn=_t(d,"FORBID_TAGS",Ae({}),{transform:le}),Ha=_t(d,"FORBID_ATTR",Ae({}),{transform:le}),an=ye(d,"USE_PROFILES")?d.USE_PROFILES&&typeof d.USE_PROFILES=="object"?Ae(d.USE_PROFILES):d.USE_PROFILES:!1,Ga=d.ALLOW_ARIA_ATTR!==!1,Ii=d.ALLOW_DATA_ATTR!==!1,za=d.ALLOW_UNKNOWN_PROTOCOLS||!1,Fa=d.ALLOW_SELF_CLOSE_IN_ATTR!==!1,gt=d.SAFE_FOR_TEMPLATES||!1,vt=d.SAFE_FOR_XML!==!1,It=d.WHOLE_DOCUMENT||!1,sn=d.RETURN_DOM||!1,Er=d.RETURN_DOM_FRAGMENT||!1,Tr=d.RETURN_TRUSTED_TYPE||!1,Ri=d.FORCE_BODY||!1,$a=d.SANITIZE_DOM!==!1,Ba=d.SANITIZE_NAMED_PROPS||!1,Ni=d.KEEP_CONTENT!==!1,wr=d.IN_PLACE||!1,Ua=fg(d.ALLOWED_URI_REGEXP)?d.ALLOWED_URI_REGEXP:gu,ln=typeof d.NAMESPACE=="string"?d.NAMESPACE:Je,Di=ye(d,"MATHML_TEXT_INTEGRATION_POINTS")&&d.MATHML_TEXT_INTEGRATION_POINTS&&typeof d.MATHML_TEXT_INTEGRATION_POINTS=="object"?Ae(d.MATHML_TEXT_INTEGRATION_POINTS):W({},Xa),Ui=ye(d,"HTML_INTEGRATION_POINTS")&&d.HTML_INTEGRATION_POINTS&&typeof d.HTML_INTEGRATION_POINTS=="object"?Ae(d.HTML_INTEGRATION_POINTS):W({},Ya);let b=ye(d,"CUSTOM_ELEMENT_HANDLING")&&d.CUSTOM_ELEMENT_HANDLING&&typeof d.CUSTOM_ELEMENT_HANDLING=="object"?Ae(d.CUSTOM_ELEMENT_HANDLING):Nn(null);if(de=Nn(null),ye(b,"tagNameCheck")&&Ka(b.tagNameCheck)&&(de.tagNameCheck=b.tagNameCheck),ye(b,"attributeNameCheck")&&Ka(b.attributeNameCheck)&&(de.attributeNameCheck=b.attributeNameCheck),ye(b,"allowCustomizedBuiltInElements")&&typeof b.allowCustomizedBuiltInElements=="boolean"&&(de.allowCustomizedBuiltInElements=b.allowCustomizedBuiltInElements),Se(de),gt&&(Ii=!1),Er&&(sn=!0),an&&(ie=W({},hu),se=Nn(null),an.html===!0&&(W(ie,pu),W(se,fu)),an.svg===!0&&(W(ie,ca),W(se,pa),W(se,ui)),an.svgFilters===!0&&(W(ie,ua),W(se,pa),W(se,ui)),an.mathMl===!0&&(W(ie,da),W(se,mu),W(se,ui))),mt.tagCheck=null,mt.attributeCheck=null,ye(d,"ADD_TAGS")&&(typeof d.ADD_TAGS=="function"?mt.tagCheck=d.ADD_TAGS:At(d.ADD_TAGS)&&(ie===Ai&&(ie=Ae(ie)),W(ie,d.ADD_TAGS,le))),ye(d,"ADD_ATTR")&&(typeof d.ADD_ATTR=="function"?mt.attributeCheck=d.ADD_ATTR:At(d.ADD_ATTR)&&(se===ki&&(se=Ae(se)),W(se,d.ADD_ATTR,le))),ye(d,"ADD_URI_SAFE_ATTR")&&At(d.ADD_URI_SAFE_ATTR)&&W(Mi,d.ADD_URI_SAFE_ATTR,le),ye(d,"FORBID_CONTENTS")&&At(d.FORBID_CONTENTS)&&(Ze===Oi&&(Ze=Ae(Ze)),W(Ze,d.FORBID_CONTENTS,le)),ye(d,"ADD_FORBID_CONTENTS")&&At(d.ADD_FORBID_CONTENTS)&&(Ze===Oi&&(Ze=Ae(Ze)),W(Ze,d.ADD_FORBID_CONTENTS,le)),Ni&&(ie["#text"]=!0),It&&W(ie,["html","head","body"]),ie.table&&(W(ie,["tbody"]),delete Dn.tbody),d.TRUSTED_TYPES_POLICY){if(typeof d.TRUSTED_TYPES_POLICY.createHTML!="function")throw en('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof d.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw en('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let E=re;re=d.TRUSTED_TYPES_POLICY;try{Be=on("")}catch(N){throw re=E,N}}else d.TRUSTED_TYPES_POLICY===null?(re=void 0,Be=""):(re===void 0&&(re=rd()),re&&typeof Be=="string"&&(Be=on("")));we&&we(d),cn=d},Za=W({},[...ca,...ua,...mg]),Ja=W({},[...da,...gg]),yd=function(d,b,E){return b.namespaceURI===Je?d==="svg":b.namespaceURI===Sr?d==="svg"&&(E==="annotation-xml"||Di[E]):!!Za[d]},xd=function(d,b,E){return b.namespaceURI===Je?d==="math":b.namespaceURI===_r?d==="math"&&Ui[E]:!!Ja[d]},Ed=function(d,b,E){return b.namespaceURI===_r&&!Ui[E]||b.namespaceURI===Sr&&!Di[E]?!1:!Ja[d]&&(md[d]||!Za[d])},Td=function(d){let b=_(d);(!b||!b.tagName)&&(b={namespaceURI:ln,tagName:"template"});let E=lr(d.tagName),N=lr(b.tagName);return Pi[d.namespaceURI]?d.namespaceURI===_r?yd(E,b,N):d.namespaceURI===Sr?xd(E,b,N):d.namespaceURI===Je?Ed(E,b,N):!!(Un==="application/xhtml+xml"&&Pi[d.namespaceURI]):!1},bt=function(d){Rn(e.removed,{element:d});try{_(d).removeChild(d)}catch{if(p(d),!_(d))throw en("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ar=function(d){Hn(d);let b=x(d);if(b){let N=[];Cn(b,L=>{Rn(N,L)}),Cn(N,L=>{try{p(L)}catch{}})}let E=C(d);if(E)for(let N=E.length-1;N>=0;--N){let L=E[N],G=L&&L.name;if(typeof G=="string")try{d.removeAttribute(G)}catch{}}},Ct=function(d,b){try{Rn(e.removed,{attribute:b.getAttributeNode(d),from:b})}catch{Rn(e.removed,{attribute:null,from:b})}if(b.removeAttribute(d),d==="is")if(sn||Er)try{bt(b)}catch{}else try{b.setAttribute(d,"")}catch{}},wd=function(d){let b=C(d);if(b)for(let E=b.length-1;E>=0;--E){let N=b[E],L=N&&N.name;if(!(typeof L!="string"||se[le(L)]))try{d.removeAttribute(L)}catch{}}},Hn=function(d){let b=[d];for(;b.length>0;){let E=b.pop();(H?H(E):E.nodeType)===He.element&&wd(E);let L=x(E);if(L)for(let G=L.length-1;G>=0;--G)b.push(L[G])}},Sd=function(d){if(!vt)return;let b=[d];for(;b.length>0;){let E=b.pop(),N=H?H(E):E.nodeType;if(N===He.processingInstruction||N===He.comment&&be(bu,E.data)){try{p(E)}catch{}continue}if(N===He.element){let G=E,Z=le(U?U(E):E.nodeName);try{G.hasAttribute&&G.hasAttribute("patchsrc")&&G.removeAttribute("patchsrc"),G.hasAttribute&&G.hasAttribute("for")&&Z!=="label"&&Z!=="output"&&G.removeAttribute("for")}catch{}}let L=x(E);if(L)for(let G=L.length-1;G>=0;--G)b.push(L[G])}},Qa=function(d){let b=null,E=null;if(Ri)d="<remove></remove>"+d;else{let G=lu(d,/^[\r\n\t ]+/);E=G&&G[0]}Un==="application/xhtml+xml"&&ln===Je&&(d='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+d+"</body></html>");let N=re?on(d):d;if(ln===Je)try{b=new h().parseFromString(N,Un)}catch{}if(!b||!b.documentElement){b=_i.createDocument(ln,"template",null);try{b.documentElement.innerHTML=Li?Be:N}catch{}}let L=b.body||b.documentElement;return d&&E&&L.insertBefore(n.createTextNode(E),L.childNodes[0]||null),ln===Je?id.call(b,It?"html":"body")[0]:It?b.documentElement:L},el=function(d){let b=Y?Y(d):d.ownerDocument;return Pa.call(b||d,d,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},kr=function(d){return d=sr(d,ad," "),d=sr(d,ld," "),d=sr(d,cd," "),d},Gi=function(d){var b;d.normalize();let E=Y?Y(d):d.ownerDocument,N=Pa.call(E||d,d,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),L=N.nextNode();for(;L;)L.data=kr(L.data),L=N.nextNode();let G=(b=d.querySelectorAll)===null||b===void 0?void 0:b.call(d,"template");G&&Cn(G,Z=>{un(Z.content)&&Gi(Z.content)})},Ir=function(d){let b=U?U(d):null;return typeof b!="string"||le(b)!=="form"?!1:typeof d.nodeName!="string"||typeof d.textContent!="string"||typeof d.removeChild!="function"||d.attributes!==C(d)||typeof d.removeAttribute!="function"||typeof d.setAttribute!="function"||typeof d.namespaceURI!="string"||typeof d.insertBefore!="function"||typeof d.hasChildNodes!="function"||d.nodeType!==H(d)||d.childNodes!==x(d)},un=function(d){if(!H||typeof d!="object"||d===null)return!1;try{return H(d)===He.documentFragment}catch{return!1}},Gn=function(d){if(!H||typeof d!="object"||d===null)return!1;try{return typeof H(d)=="number"}catch{return!1}};function Qe(S,d,b){S.length!==0&&Cn(S,E=>{E.call(e,d,b,cn)})}let _d=function(d,b){return!!(vt&&d.hasChildNodes()&&!Gn(d.firstElementChild)&&be(vu,d.textContent)&&be(vu,d.innerHTML)||vt&&d.namespaceURI===Je&&b==="style"&&Gn(d.firstElementChild)||d.nodeType===He.processingInstruction||vt&&d.nodeType===He.comment&&be(bu,d.data))},Ad=function(d,b,E){if(!Dn[b]&&ol(b)&&(de.tagNameCheck instanceof RegExp&&be(de.tagNameCheck,b)||de.tagNameCheck instanceof Function&&de.tagNameCheck(b)))return!1;if(Ni&&!Ze[b]){let N=_(d),L=x(d);if(L&&N){let G=L.length;for(let Z=G-1;Z>=0;--Z){let ce=d===E?f(L[Z],!0):L[Z];N.insertBefore(ce,g(d))}}}return bt(d),!0},tl=function(d,b,E,N){return d.length===0?b:b===E||b===N?Ae(b):b},nl=function(d,b){if(Qe(oe.beforeSanitizeElements,d,null),d!==b&&_(d)===null)return wr&&Hn(d),!0;if(Ir(d))return bt(d),!0;let E=le(U?U(d):d.nodeName);if(ie=tl(oe.uponSanitizeElement,ie,Ai,yr),Qe(oe.uponSanitizeElement,d,{tagName:E,allowedTags:ie}),d!==b&&_(d)===null)return wr&&Hn(d),!0;if(_d(d,E))return bt(d),!0;if(Dn[E]||!(mt.tagCheck instanceof Function&&mt.tagCheck(E))&&!ie[E]){let L=Ad(d,E,b);return L===!1&&Qe(oe.afterSanitizeElements,d,null),L}if((H?H(d):d.nodeType)===He.element&&!Td(d)||(E==="noscript"||E==="noembed"||E==="noframes")&&be(Ag,d.innerHTML))return bt(d),!0;if(gt&&d.nodeType===He.text){let L=kr(d.textContent);d.textContent!==L&&(Rn(e.removed,{element:d.cloneNode()}),d.textContent=L)}return Qe(oe.afterSanitizeElements,d,null),!1},rl=function(d,b,E){if(Ha[b]||vt&&b==="patchsrc"||vt&&b==="for"&&d!=="label"&&d!=="output"||$a&&(b==="id"||b==="name")&&(E in n||E in bd))return!1;let N=se[b]||mt.attributeCheck instanceof Function&&mt.attributeCheck(b,d);if(!(Ii&&be(ud,b))){if(!(Ga&&be(dd,b))){if(N){if(!Mi[b]){if(!be(Ua,sr(E,Da,""))){if(!((b==="src"||b==="xlink:href"||b==="href")&&d!=="script"&&cu(E,"data:")===0&&ja[d])){if(!(za&&!be(pd,sr(E,Da,"")))){if(E)return!1}}}}}else if(!(ol(d)&&(de.tagNameCheck instanceof RegExp&&be(de.tagNameCheck,d)||de.tagNameCheck instanceof Function&&de.tagNameCheck(d))&&(de.attributeNameCheck instanceof RegExp&&be(de.attributeNameCheck,b)||de.attributeNameCheck instanceof Function&&de.attributeNameCheck(b,d))||b==="is"&&de.allowCustomizedBuiltInElements&&(de.tagNameCheck instanceof RegExp&&be(de.tagNameCheck,E)||de.tagNameCheck instanceof Function&&de.tagNameCheck(E))))return!1}}return!0},kd=W({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),ol=function(d){return!kd[lr(d)]&&be(hd,d)},Id=function(d,b,E,N){if(re&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!E)switch(m.getAttributeType(d,b)){case"TrustedHTML":return on(N);case"TrustedScriptURL":return nd(N)}return N},Cd=function(d,b,E,N){try{E?d.setAttributeNS(E,b,N):d.setAttribute(b,N),Ir(d)?bt(d):au(e.removed)}catch{Ct(b,d)}},il=function(d){Qe(oe.beforeSanitizeAttributes,d,null);let b=d.attributes;if(!b||Ir(d))return;se=tl(oe.uponSanitizeAttribute,se,ki,xr);let E={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:se,forceKeepAttr:void 0},N=b.length,L=le(d.nodeName);for(;N--;){let G=b[N],Z=G.name,ce=G.namespaceURI,Ce=G.value,Re=le(Z),Fi=Ce,Ie=Z==="value"?Fi:lg(Fi);if(E.attrName=Re,E.attrValue=Ie,E.keepAttr=!0,E.forceKeepAttr=void 0,Qe(oe.uponSanitizeAttribute,d,E),Ie=E.attrValue,Ba&&(Re==="id"||Re==="name")&&cu(Ie,Va)!==0&&(Ct(Z,d),Ie=Va+Ie),vt&&be(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ie)){Ct(Z,d);continue}if(Re==="attributename"&&lu(Ie,"href")){Ct(Z,d);continue}if(!E.forceKeepAttr){if(!E.keepAttr){Ct(Z,d);continue}if(!Fa&&be(kg,Ie)){Ct(Z,d);continue}if(gt&&(Ie=kr(Ie)),!rl(L,Re,Ie)){Ct(Z,d);continue}Ie=Id(L,Re,ce,Ie),Ie!==Fi&&Cd(d,Z,ce,Ie)}}Qe(oe.afterSanitizeAttributes,d,null)},Cr=function(d){let b=null,E=el(d);for(Qe(oe.beforeSanitizeShadowDOM,d,null);b=E.nextNode();)if(Qe(oe.uponSanitizeShadowNode,b,null),nl(b,d),il(b),un(b.content)&&Cr(b.content),(H?H(b):b.nodeType)===He.element){let L=w(b);un(L)&&(zi(L),Cr(L))}Qe(oe.afterSanitizeShadowDOM,d,null)},zi=function(d){let b=[{node:d,shadow:null}];for(;b.length>0;){let E=b.pop();if(E.shadow){Cr(E.shadow);continue}let N=E.node,G=(H?H(N):N.nodeType)===He.element,Z=x(N);if(Z)for(let ce=Z.length-1;ce>=0;--ce)b.push({node:Z[ce],shadow:null});if(G){let ce=U?U(N):null;if(typeof ce=="string"&&le(ce)==="template"){let Ce=N.content;un(Ce)&&b.push({node:Ce,shadow:null})}}if(G){let ce=w(N);un(ce)&&b.push({node:null,shadow:ce},{node:ce,shadow:null})}}};return e.sanitize=function(S){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},b=null,E=null,N=null,L=null;if(Li=!S,Li&&(S="<!-->"),typeof S!="string"&&!Gn(S)&&(S=hg(S),typeof S!="string"))throw en("dirty is not a string, aborting");if(!e.isSupported)return S;Ci?(ie=yr,se=xr):Hi(d),(oe.uponSanitizeElement.length>0||oe.uponSanitizeAttribute.length>0)&&(ie=Ae(ie)),oe.uponSanitizeAttribute.length>0&&(se=Ae(se)),e.removed=[];let G=wr&&typeof S!="string"&&Gn(S);if(G){Sd(S);let Ce=U?U(S):S.nodeName;if(typeof Ce=="string"){let Re=le(Ce);if(!ie[Re]||Dn[Re])throw Ar(S),en("root node is forbidden and cannot be sanitized in-place")}if(Ir(S))throw Ar(S),en("root node is clobbered and cannot be sanitized in-place");try{zi(S)}catch(Re){throw Ar(S),Re}}else if(Gn(S))b=Qa("<!---->"),E=b.ownerDocument.importNode(S,!0),E.nodeType===He.element&&E.nodeName==="BODY"||E.nodeName==="HTML"?b=E:b.appendChild(E),zi(E);else{if(!sn&&!gt&&!It&&S.indexOf("<")===-1)return re&&Tr?on(S):S;if(b=Qa(S),!b)return sn?null:Tr?Be:""}b&&Ri&&bt(b.firstChild);let Z=G?S:b;try{let Ce=el(Z);for(;N=Ce.nextNode();)nl(N,Z),il(N),un(N.content)&&Cr(N.content)}catch(Ce){throw G&&(Ar(S),Cn(e.removed,Re=>{Re.element&&Hn(Re.element)})),Ce}if(G)return Cn(e.removed,Ce=>{Ce.element&&Hn(Ce.element)}),gt&&Gi(S),S;if(sn){if(gt&&Gi(b),Er)for(L=od.call(b.ownerDocument);b.firstChild;)L.appendChild(b.firstChild);else L=b;return(se.shadowroot||se.shadowrootmode)&&(L=sd.call(r,L,!0)),L}let ce=It?b.outerHTML:b.innerHTML;return It&&ie["!doctype"]&&b.ownerDocument&&b.ownerDocument.doctype&&b.ownerDocument.doctype.name&&be(Sg,b.ownerDocument.doctype.name)&&(ce="<!DOCTYPE "+b.ownerDocument.doctype.name+`>
|
|
13
|
-
`+ce),
|
|
14
|
-
]`).replace("lheading",
|
|
10
|
+
`),m=JSON.parse(h);n?.event("SSE","Event received:",m,{type:m.type}),r.next(m)}catch(h){r.error(h)}}return r.asObservable()},Gm=t=>{let e=new st,n=new Uint8Array;t.subscribe({next:o=>{if(o.type!==en.HEADERS&&o.type===en.DATA&&o.data){let i=new Uint8Array(n.length+o.data.length);i.set(n,0),i.set(o.data,n.length),n=i,r()}},error:o=>e.error(o),complete:()=>{if(n.length>0)try{r()}catch{console.warn("Incomplete or invalid protocol buffer data at stream end")}e.complete()}});function r(){for(;n.length>=4;){let o=4+new DataView(n.buffer,n.byteOffset,4).getUint32(0,!1);if(n.length<o)break;try{let i=n.slice(4,o),s=nu(i);e.next(s),n=n.slice(o)}catch(i){let s=i instanceof Error?i.message:String(i);e.error(Error(`Failed to decode protocol buffer message: ${s}`));return}}}return e.asObservable()},Fm=(t,e)=>{let n=sr(e),r=new st,o=new lo,i=!1;return t.subscribe({next:s=>{if(o.next(s),s.type===en.HEADERS&&!i){i=!0;let a=s.headers.get("content-type");n?.lifecycle("HTTP","Stream format detected:",{contentType:a,parser:a===ra?"protobuf":"sse"}),a===ra?Gm(o).subscribe({next:l=>r.next(l),error:l=>r.error(l),complete:()=>r.complete()}):zm(o,n).subscribe({next:l=>{try{let c=qr.parse(l);n?.event("HTTP","Event validated:",c,{type:c.type,valid:!0}),r.next(c)}catch(c){n?.event("HTTP","Event invalid:",{json:l,error:String(c)}),r.error(c)}},error:l=>{if(l?.name==="AbortError"){r.next({type:v.RUN_ERROR,message:l.message||"Request aborted",code:"abort",rawEvent:l}),r.complete();return}return r.error(l)},complete:()=>r.complete()})}else i||r.error(Error("No headers event received before data events"))},error:s=>{o.error(s),r.error(s)},complete:()=>{o.complete()}}),r.asObservable()},Q=u.enum(["TextMessageStart","TextMessageContent","TextMessageEnd","ActionExecutionStart","ActionExecutionArgs","ActionExecutionEnd","ActionExecutionResult","AgentStateMessage","MetaEvent","RunStarted","RunFinished","RunError","NodeStarted","NodeFinished"]),$m=u.enum(["LangGraphInterruptEvent","PredictState","Exit"]),Bm=u.object({type:u.literal(Q.enum.TextMessageStart),messageId:u.string(),parentMessageId:u.string().optional(),role:u.string().optional()}),Vm=u.object({type:u.literal(Q.enum.TextMessageContent),messageId:u.string(),content:u.string()}),jm=u.object({type:u.literal(Q.enum.TextMessageEnd),messageId:u.string()}),qm=u.object({type:u.literal(Q.enum.ActionExecutionStart),actionExecutionId:u.string(),actionName:u.string(),parentMessageId:u.string().optional()}),Wm=u.object({type:u.literal(Q.enum.ActionExecutionArgs),actionExecutionId:u.string(),args:u.string()}),Xm=u.object({type:u.literal(Q.enum.ActionExecutionEnd),actionExecutionId:u.string()}),Ym=u.object({type:u.literal(Q.enum.ActionExecutionResult),actionName:u.string(),actionExecutionId:u.string(),result:u.string()}),Km=u.object({type:u.literal(Q.enum.AgentStateMessage),threadId:u.string(),agentName:u.string(),nodeName:u.string(),runId:u.string(),active:u.boolean(),role:u.string(),state:u.string(),running:u.boolean()}),Zm=u.object({type:u.literal(Q.enum.MetaEvent),name:$m,value:u.any()}),Jm=u.object({type:u.literal(Q.enum.RunError),message:u.string(),code:u.string().optional()});u.discriminatedUnion("type",[Bm,Vm,jm,qm,Wm,Xm,Ym,Km,Zm,Jm]),u.object({id:u.string(),role:u.string(),content:u.string(),parentMessageId:u.string().optional()}),u.object({id:u.string(),name:u.string(),arguments:u.any(),parentMessageId:u.string().optional()}),u.object({id:u.string(),result:u.any(),actionExecutionId:u.string(),actionName:u.string()});var Qm=t=>{if(typeof t=="string")return t;if(!Array.isArray(t))return;let e=t.filter(n=>n.type==="text").map(n=>n.text).filter(n=>n.length>0);if(e.length!==0)return e.join(`
|
|
11
|
+
`)},eg=(t,e,n)=>r=>{let o={},i=!0,s=!0,a="",l=null,c=null,h=[],m={},y=f=>{typeof f=="object"&&f&&("messages"in f&&delete f.messages,o=f)};return r.pipe(Me(f=>{switch(f.type){case v.TEXT_MESSAGE_START:{let p=f;return[{type:Q.enum.TextMessageStart,messageId:p.messageId,role:p.role}]}case v.TEXT_MESSAGE_CONTENT:{let p=f;return[{type:Q.enum.TextMessageContent,messageId:p.messageId,content:p.delta}]}case v.TEXT_MESSAGE_END:{let p=f;return[{type:Q.enum.TextMessageEnd,messageId:p.messageId}]}case v.TOOL_CALL_START:{let p=f;return h.push({id:p.toolCallId,type:"function",function:{name:p.toolCallName,arguments:""}}),s=!0,m[p.toolCallId]=p.toolCallName,[{type:Q.enum.ActionExecutionStart,actionExecutionId:p.toolCallId,actionName:p.toolCallName,parentMessageId:p.parentMessageId}]}case v.TOOL_CALL_ARGS:{let p=f,g=h.find(S=>S.id===p.toolCallId);if(!g)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${p.toolCallId}'`),[];g.function.arguments+=p.delta;let x=!1;if(c){let S=c.find(T=>T.tool==g.function.name);if(S)try{let T=JSON.parse(ko(g.function.arguments));S.tool_argument&&S.tool_argument in T?(y({...o,[S.state_key]:T[S.tool_argument]}),x=!0):S.tool_argument||(y({...o,[S.state_key]:T}),x=!0)}catch{}}return[{type:Q.enum.ActionExecutionArgs,actionExecutionId:p.toolCallId,args:p.delta},...x?[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:s}]:[]]}case v.TOOL_CALL_END:{let p=f;return[{type:Q.enum.ActionExecutionEnd,actionExecutionId:p.toolCallId}]}case v.TOOL_CALL_RESULT:{let p=f;return[{type:Q.enum.ActionExecutionResult,actionExecutionId:p.toolCallId,result:p.content,actionName:m[p.toolCallId]||"unknown"}]}case v.RAW:return[];case v.CUSTOM:{let p=f;switch(p.name){case"Exit":i=!1;break;case"PredictState":c=p.value;break}return[{type:Q.enum.MetaEvent,name:p.name,value:p.value}]}case v.STATE_SNAPSHOT:return y(f.snapshot),[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:s}];case v.STATE_DELTA:{let p=f,g=eo.applyPatch(o,p.delta,!0,!1);return g?(y(g.newDocument),[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:s}]):[]}case v.MESSAGES_SNAPSHOT:return l=f.messages,[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify({...o,...l?{messages:l}:{}}),active:!0}];case v.RUN_STARTED:return[];case v.RUN_FINISHED:return l&&(o.messages=l),Object.keys(o).length===0?[]:[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify({...o,...l?{messages:tg(l)}:{}}),active:!1}];case v.RUN_ERROR:{let p=f;return[{type:Q.enum.RunError,message:p.message,code:p.code}]}case v.STEP_STARTED:return a=f.stepName,h=[],c=null,[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:!0}];case v.STEP_FINISHED:return h=[],c=null,[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:!1}];default:return[]}}))};function tg(t){let e=[];for(let n of t)if(n.role==="assistant"||n.role==="user"||n.role==="system"){let r=Qm(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 ci=t=>e=>{let n=sr(t),r,o,i,s,a=()=>{if(!r||s!=="text")throw Error("No text message to close");let m={type:v.TEXT_MESSAGE_END,messageId:r.messageId};return s=void 0,r=void 0,n?.event("TRANSFORM","TEXT_MESSAGE_END",m,{messageId:m.messageId}),m},l=()=>{if(!o||s!=="tool")throw Error("No tool call to close");let m={type:v.TOOL_CALL_END,toolCallId:o.toolCallId};return s=void 0,o=void 0,n?.event("TRANSFORM","TOOL_CALL_END",m,{toolCallId:m.toolCallId}),m},c=()=>{if(!i||s!=="reasoning")throw Error("No reasoning message to close");let m={type:v.REASONING_MESSAGE_END,messageId:i.messageId};return s=void 0,i=void 0,n?.event("TRANSFORM","REASONING_MESSAGE_END",m,{messageId:m.messageId}),m},h=()=>s==="text"?[a()]:s==="tool"?[l()]:s==="reasoning"?[c()]:[];return e.pipe(Me(m=>{switch(m.type){case v.TEXT_MESSAGE_START:case v.TEXT_MESSAGE_CONTENT:case v.TEXT_MESSAGE_END:case v.TOOL_CALL_START:case v.TOOL_CALL_ARGS:case v.TOOL_CALL_END:case v.TOOL_CALL_RESULT:case v.STATE_SNAPSHOT:case v.STATE_DELTA:case v.MESSAGES_SNAPSHOT:case v.CUSTOM:case v.RUN_STARTED:case v.RUN_FINISHED:case v.RUN_ERROR:case v.STEP_STARTED:case v.STEP_FINISHED:case v.THINKING_START:case v.THINKING_END:case v.THINKING_TEXT_MESSAGE_START:case v.THINKING_TEXT_MESSAGE_CONTENT:case v.THINKING_TEXT_MESSAGE_END:case v.REASONING_START:case v.REASONING_MESSAGE_START:case v.REASONING_MESSAGE_CONTENT:case v.REASONING_MESSAGE_END:case v.REASONING_END:return[...h(),m];case v.RAW:case v.ACTIVITY_SNAPSHOT:case v.ACTIVITY_DELTA:case v.REASONING_ENCRYPTED_VALUE:return[m];case v.TEXT_MESSAGE_CHUNK:let y=m,f=[];if((s!=="text"||y.messageId!==void 0&&y.messageId!==r?.messageId)&&f.push(...h()),s!=="text"){if(y.messageId===void 0)throw Error("First TEXT_MESSAGE_CHUNK must have a messageId");r={messageId:y.messageId,name:y.name},s="text";let T={type:v.TEXT_MESSAGE_START,messageId:y.messageId,role:y.role||"assistant",...y.name!==void 0&&{name:y.name}};f.push(T),n?.event("TRANSFORM","TEXT_MESSAGE_START",T,{messageId:y.messageId})}if(y.delta!==void 0){let T={type:v.TEXT_MESSAGE_CONTENT,messageId:r.messageId,delta:y.delta};f.push(T),n?.event("TRANSFORM","TEXT_MESSAGE_CONTENT",T,{messageId:r.messageId})}return f;case v.TOOL_CALL_CHUNK:let p=m,g=[];if((s!=="tool"||p.toolCallId!==void 0&&p.toolCallId!==o?.toolCallId)&&g.push(...h()),s!=="tool"){if(p.toolCallId===void 0)throw Error("First TOOL_CALL_CHUNK must have a toolCallId");if(p.toolCallName===void 0)throw Error("First TOOL_CALL_CHUNK must have a toolCallName");o={toolCallId:p.toolCallId,toolCallName:p.toolCallName,parentMessageId:p.parentMessageId},s="tool";let T={type:v.TOOL_CALL_START,toolCallId:p.toolCallId,toolCallName:p.toolCallName,parentMessageId:p.parentMessageId};g.push(T),n?.event("TRANSFORM","TOOL_CALL_START",T,{toolCallId:p.toolCallId,toolCallName:p.toolCallName})}if(p.delta!==void 0){let T={type:v.TOOL_CALL_ARGS,toolCallId:o.toolCallId,delta:p.delta};g.push(T),n?.event("TRANSFORM","TOOL_CALL_ARGS",T,{toolCallId:o.toolCallId})}return g;case v.REASONING_MESSAGE_CHUNK:let x=m,S=[];if((s!=="reasoning"||x.messageId&&x.messageId!==i?.messageId)&&S.push(...h()),s!=="reasoning"){if(x.messageId===void 0)throw Error("First REASONING_MESSAGE_CHUNK must have a messageId");i={messageId:x.messageId},s="reasoning";let T={type:v.REASONING_MESSAGE_START,messageId:x.messageId};S.push(T),n?.event("TRANSFORM","REASONING_MESSAGE_START",T,{messageId:x.messageId})}if(x.delta!==void 0){let T={type:v.REASONING_MESSAGE_CONTENT,messageId:i.messageId,delta:x.delta};S.push(T),n?.event("TRANSFORM","REASONING_MESSAGE_CONTENT",T,{messageId:i.messageId})}return S}return m.type,[]}),Qt(()=>{h()}))};function ng(t,e=new Date){return t.expiresAt===void 0?!1:new Date(t.expiresAt)<=e}function hu(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];if(a.status==="resolved"){let l={interruptId:s.id,status:"resolved"};return a.payload!==void 0&&(l.payload=a.payload),l}return{interruptId:s.id,status:"cancelled"}})}var ui=class{runNext(t,e){return e.run(t).pipe(ci(!1))}runNextWithState(t,e){let n=q(t.messages||[]),r=q(t.state||{}),o=new lo;return pu(t,o,e,[]).subscribe(i=>{i.messages!==void 0&&(n=i.messages),i.state!==void 0&&(r=i.state)}),this.runNext(t,e).pipe(So(async i=>(o.next(i),await new Promise(s=>setTimeout(s,0)),{event:i,messages:q(n),state:q(r)})))}},rg=class extends ui{constructor(t){super(),this.fn=t}run(t,e){return this.fn(t,e)}};function og(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 ig=class extends ui{run(t,e){let{parentRunId:n,...r}=t,o={...r,messages:r.messages.map(og)};return this.runNext(o,e)}},au="THINKING_START",lu="THINKING_END",cu="THINKING_TEXT_MESSAGE_START",uu="THINKING_TEXT_MESSAGE_CONTENT",du="THINKING_TEXT_MESSAGE_END",sg=class extends ui{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(Jt(n=>this.transformEvent(n)))}transformEvent(t){switch(t.type){case au:{this.currentReasoningId=Ue();let{title:e,...n}=t;return this.warnAboutTransformation(au,v.REASONING_START),{...n,type:v.REASONING_START,messageId:this.currentReasoningId}}case cu:return this.currentMessageId=Ue(),this.warnAboutTransformation(cu,v.REASONING_MESSAGE_START),{...t,type:v.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:"assistant"};case uu:{let{delta:e,...n}=t;return this.warnAboutTransformation(uu,v.REASONING_MESSAGE_CONTENT),{...n,type:v.REASONING_MESSAGE_CONTENT,messageId:this.currentMessageId??Ue(),delta:e}}case du:{let e=this.currentMessageId??Ue();return this.warnAboutTransformation(du,v.REASONING_MESSAGE_END),{...t,type:v.REASONING_MESSAGE_END,messageId:e}}case lu:{let e=this.currentReasoningId??Ue();return this.warnAboutTransformation(lu,v.REASONING_END),{...t,type:v.REASONING_END,messageId:e}}default:return t}}};function ag(t){return t.startsWith("image/")?"image":t.startsWith("audio/")?"audio":t.startsWith("video/")?"video":"document"}function lg(t){return typeof t=="object"&&!!t&&"type"in t&&t.type==="binary"&&"mimeType"in t&&typeof t.mimeType=="string"}function cg(t){let e=ag(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 ug(t){let e=t.content;if(!Array.isArray(e))return t;let n=e.map(r=>lg(r)?cg(r):r);return{...t,content:n}}var dg=class extends ui{run(t,e){let n={...t,messages:t.messages.map(ug)};return this.runNext(n,e)}},pg="0.0.57",hg=class{get maxVersion(){return pg}get debug(){return this._debug}set debug(t){this._debug=li(t),this._debugLogger=sa(this._debug)}get debugLogger(){return this._debugLogger}set debugLogger(t){typeof t=="boolean"?this._debugLogger=t?sa(li(!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??xt(),this.messages=q(r??[]),this.state=q(o??{}),this._debug=li(i),this._debugLogger=sa(this._debug),ir(this.maxVersion,"0.0.39")<=0&&this.middlewares.unshift(new ig),ir(this.maxVersion,"0.0.45")<=0&&this.middlewares.unshift(new sg),ir(this.maxVersion,"0.0.47")<=0&&this.middlewares.unshift(new dg)}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 rg(n):n);return this.middlewares.push(...e),this}async runAgent(t,e){try{this.isRunning=!0,this.agentId=this.agentId??xt();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 st;let s;this.activeRunCompletionPromise=new Promise(l=>{s=l}),await To(ao(()=>this.middlewares.length===0?this.run(n):this.middlewares.reduceRight((l,c)=>({run:h=>c.run(h,l),get messages(){return l.messages},get state(){return l.state}}),this).run(n),ci(this.debugLogger),aa(this.debugLogger),l=>l.pipe(Ao(this.activeRunDetach$)),l=>this.apply(n,l,i),l=>this.processApplyEvents(n,l,i),nr(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))),Qt(()=>{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}))(ue(null)));let a=q(this.messages).filter(l=>!o.has(l.id));return{result:r,newMessages:a}}finally{this.isRunning=!1}}connect(t){throw new Is}async connectAgent(t,e){try{this.isRunning=!0,this.agentId=this.agentId??xt();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 st;let s;this.activeRunCompletionPromise=new Promise(l=>{s=l}),await To(ao(()=>wo(()=>this.connect(n)),ci(this.debugLogger),aa(this.debugLogger),l=>l.pipe(Ao(this.activeRunDetach$)),l=>this.apply(n,l,i),l=>this.processApplyEvents(n,l,i),nr(l=>(this.isRunning=!1,l instanceof Is?co:this.onError(n,l,i))),Qt(()=>{this.isRunning=!1,this.onFinalize(n,i),s?.(),s=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(ue(null)),{defaultValue:void 0});let a=q(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 pu(t,e,this,n,this.debugLogger)}processApplyEvents(t,e,n){return e.pipe(js(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=q(this.messages).filter(n=>n.role!=="activity");return{threadId:this.threadId,runId:t?.runId||xt(),tools:q(t?.tools??[]),context:q(t?.context??[]),forwardedProps:q(t?.forwardedProps??{}),state:q(this.state),messages:e,...t?.resume===void 0?{}:{resume:q(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 ee(`Thread has ${o.length} pending interrupt(s) not addressed by resume: ${o.join(", ")}`);for(let i of this.pendingInterrupts)if(ng(i))throw new ee(`Interrupt ${i.id} expired at ${i.expiresAt}`)}let n=await K(e,this.messages,this.state,(r,o,i)=>r.onRunInitialized?.({messages:o,state:i,agent:this,input:t}));(n.messages!==void 0||n.state!==void 0)&&(n.messages&&(this.messages=n.messages,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 Zt(K(n,this.messages,this.state,(r,o,i)=>r.onRunFailed?.({error:e,messages:o,state:i,agent:this,input:t}))).pipe(Jt(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 K(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=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 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=q(t),(async()=>{for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setState(t){this.state=q(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??xt();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(ci(this.debugLogger),aa(this.debugLogger),eg(this.threadId,e.runId,this.agentId),n=>n.pipe(Jt(r=>(this.debugLogger?.event("LEGACY","Event:",r,{type:r.type}),r))))}},fu=class extends hg{requestInit(t){return{method:"POST",headers:{...this.headers,"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(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=q(t.headers??{}),this.fetch=t.fetch??((e,n)=>fetch(e,n))}run(t){return Fm(Hm(()=>this.fetch(this.url,this.requestInit(t))),this.debugLogger)}clone(){let t=super.clone();t.url=this.url,t.headers=q(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}};var di=class{element;#n;#e;#t=[];constructor(e){this.#n=e,this.#e=e.strings??ae,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:Ue(),file:e,status:Pe.UPLOADING,progress:0,ref:null,error:"",controller:null};this.#t.push(n);let r=this.#s(e);if(r!==null){n.status=Pe.ERROR,n.error=r,this.#i(),this.#n.onChange?.();return}this.#i(),this.#n.onChange?.(),this.#r(n)}readyRefs(){let e=[];for(let n of this.#t)n.ref!==null&&e.push(n.ref);return e}hasPending(){return this.#t.some(e=>e.status===Pe.UPLOADING)}pendingCount(){return this.#t.filter(e=>e.status===Pe.UPLOADING).length}isEmpty(){return this.#t.length===0}clearReady(){this.#t=this.#t.filter(e=>e.status===Pe.UPLOADING),this.#i()}clear(){for(let e of this.#t)e.controller?.abort();this.#t=[],this.#i()}dispose(){for(let e of this.#t)e.controller?.abort()}#s(e){return this.#n.maxBytes>0&&e.size>this.#n.maxBytes?this.#e.tooLarge.replace("{size}",Hr(this.#n.maxBytes)):fg(this.#n.accept,e)?null:this.#e.fileTypeNotAllowed}#r(e){let n=this.#s(e.file);if(n!==null){e.status=Pe.ERROR,e.error=n,this.#i(),this.#n.onChange?.();return}e.status=Pe.UPLOADING,e.progress=0,e.error="";let r=new AbortController;e.controller=r,this.#i(),this.#n.upload(e.file,o=>{e.progress=o,this.#i()},r.signal).then(o=>{e.status=Pe.READY,e.ref=o}).catch(o=>{e.status=Pe.ERROR,e.error=o instanceof Error?o.message:this.#e.uploadFailed}).finally(()=>{e.controller=null,this.#i(),this.#n.onChange?.()})}#a(e){e.controller?.abort(),this.#t=this.#t.filter(n=>n!==e),this.#i(),this.#n.onChange?.()}#i(){this.element.replaceChildren(),this.element.hidden=this.#t.length===0;for(let e of this.#t)this.element.appendChild(this.#o(e))}#o(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.textContent=Es(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===Pe.ERROR?e.error:Hr(e.file.size),n.append(r,o,i),e.status===Pe.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===Pe.ERROR){let a=document.createElement("button");a.type="button",a.className="attachment-chip-retry",a.setAttribute("part","attachment-chip-retry"),a.title=this.#e.retry,a.setAttribute("aria-label",this.#e.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.#e.remove,s.setAttribute("aria-label",this.#e.removeAttachment),s.textContent="\u2715",s.addEventListener("click",()=>this.#a(e)),n.appendChild(s),n}};function fg(t,e){let n=t.split(",").map(i=>i.trim().toLowerCase()).filter(i=>i!=="");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)}function pi(t,e=Date.now(),n=ae){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 n.minutesAgo.replace("{n}",String(o));let i=Math.round(o/60);if(i<24)return n.hoursAgo.replace("{n}",String(i));let s=Math.round(i/24);return s<7?n.daysAgo.replace("{n}",String(s)):n.weeksAgo.replace("{n}",String(Math.round(s/7)))}var ar=class{element;#n;#e;#t;#s=null;#r;#a=[];constructor(e,n=ae){this.#n=e,this.#r=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.#t=document.createElement("span"),this.#t.className="checkpoints-title",this.#t.setAttribute("part","checkpoints-title"),this.#t.textContent=n.checkpoints,r.append(this.#t),this.#e=document.createElement("div"),this.#e.className="checkpoints-list",this.#e.setAttribute("part","checkpoints-list"),this.element.append(r,this.#e),this.element.addEventListener("keydown",o=>this.#l(o))}setRuns(e){this.#a=e,this.#c()}setStrings(e){this.#r=e,this.element.setAttribute("aria-label",e.checkpoints),this.#t.textContent=e.checkpoints,this.#c()}open(){this.open_||(this.#s=this.#i(),this.element.hidden=!1,(this.#o()[0]??this.element).focus())}close(){this.open_&&(this.element.hidden=!0,this.#s?.focus(),this.#s=null)}#i(){return this.element.getRootNode().activeElement}#o(){return Array.from(this.element.querySelectorAll("button, [tabindex]")).filter(e=>!e.hidden)}#l(e){if(e.key==="Escape"){e.stopPropagation(),this.close();return}if(e.key!=="Tab")return;let n=this.#o(),r=n[0],o=n[n.length-1],i=this.#i();e.shiftKey&&i===r?(e.preventDefault(),o?.focus()):!e.shiftKey&&i===o&&(e.preventDefault(),r?.focus())}get open_(){return!this.element.hidden}#c(){if(this.#e.replaceChildren(),this.#a.length===0){let e=document.createElement("div");e.className="checkpoints-empty",e.setAttribute("part","checkpoints-empty"),e.textContent=this.#r.noCheckpoints,this.#e.append(e);return}for(let e of this.#a)this.#e.append(this.#d(e))}#d(e){let n=document.createElement("div");n.className="checkpoint-row",n.setAttribute("part","checkpoint-row");let r=document.createElement("span");if(r.className="checkpoint-label",r.setAttribute("part","checkpoint-label"),r.textContent=e.started_at===null?e.run_id:pi(Date.parse(e.started_at),Date.now(),this.#r),r.title=e.run_id,n.append(r),e.parent_run_id!==null){let o=document.createElement("span");o.className="checkpoint-branch",o.setAttribute("part","checkpoint-branch"),o.textContent=this.#r.forkedRun,o.title=e.parent_run_id,n.append(o)}return n.append(this.#u(e.run_id,"resume",this.#r.resumeRun),this.#u(e.run_id,"fork",this.#r.forkRun)),n}#u(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.#n(e,n)}),o}};function mu(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 ua(t,e,n={}){let r=n.strings??ae;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??r.confirmRun.replace("{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 c=mu("cancel",r.cancel),h=mu("confirm",r.confirm),m=!1,y=f=>{m||(m=!0,i.remove(),o(f))};if(c.addEventListener("click",()=>y(!1)),h.addEventListener("click",()=>y(!0)),n.signal?.addEventListener("abort",()=>y(!1),{once:!0}),l.append(c,h),i.append(s,a,l),t.appendChild(i),n.signal?.aborted===!0){y(!1);return}h.focus()})}function da(t){let e=t.replace(/[._-]+/g," ").trim();return e===""?t:e.charAt(0).toUpperCase()+e.slice(1)}function mg(t){let e=document.createElement("input");return e.type="text",e.className="question-input",e.setAttribute("part","question-input"),e.placeholder=t,e}function pa(t,e,n={}){let r=n.strings??ae,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 c=document.createElement("div");c.className="question-body",c.setAttribute("part","question-body"),c.textContent=e.question;let h=document.createElement("div");h.className="question-options",h.setAttribute("part","question-options");let m=`q-${o.length}-${e.question.length}`,y=[];for(let U of o){let Y=document.createElement("label");Y.className="question-choice",Y.setAttribute("part","question-choice");let re=document.createElement("input");re.type="radio",re.name=m,re.value=U,re.setAttribute("part","question-radio");let Ve=document.createElement("span");Ve.setAttribute("part","question-choice-text"),Ve.textContent=U,Y.append(re,Ve),h.appendChild(Y),y.push(re)}let f=null,p=null;if(s){if(p=mg(r.answerPlaceholder),i){let U=document.createElement("label");U.className="question-choice",U.setAttribute("part","question-choice"),f=document.createElement("input"),f.type="radio",f.name=m,f.value="",f.setAttribute("part","question-radio");let Y=document.createElement("span");Y.setAttribute("part","question-choice-text"),Y.textContent=r.otherOption,U.append(f,Y),h.appendChild(U),p.disabled=!0}h.appendChild(p)}let g=document.createElement("div");g.className="question-actions",g.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,g.appendChild(x);let S=!1,T=()=>{let U=y.find(Y=>Y.checked);if(U!==void 0)return U.value;if(p!==null&&(f===null||f.checked)){let Y=p.value.trim();return Y===""?null:Y}return null},I=()=>{p!==null&&f!==null&&(p.disabled=!f.checked),x.disabled=T()===null},H=U=>{if(!S){S=!0,x.disabled=!0;for(let Y of y)Y.disabled=!0;f!==null&&(f.disabled=!0),p!==null&&(p.disabled=!0),l.setAttribute("data-resolved",U===""?"cancelled":"answered"),a(U)}};for(let U of[...y,...f!==null?[f]:[]])U.addEventListener("change",I);if(p?.addEventListener("input",I),p?.addEventListener("keydown",U=>{if(U.key==="Enter"){U.preventDefault();let Y=T();Y!==null&&H(Y)}}),x.addEventListener("click",()=>{let U=T();U!==null&&H(U)}),n.signal?.addEventListener("abort",()=>H(""),{once:!0}),l.append(c,h,g),t.appendChild(l),n.signal?.aborted===!0){H("");return}I(),(i?y[0]:p)?.focus()})}function gu(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function gg(t){if(Array.isArray(t))return t}function vg(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,o,i,s,a=[],l=!0,c=!1;try{if(i=(n=n.call(t)).next,e!==0)for(;!(l=(r=i.call(n)).done)&&(a.push(r.value),a.length!==e);l=!0);}catch(h){c=!0,o=h}finally{try{if(!l&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw o}}return a}}function bg(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
12
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function yg(t,e){return gg(t)||vg(t,e)||xg(t,e)||bg()}function xg(t,e){if(t){if(typeof t=="string")return gu(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)?gu(t,e):void 0}}var Nu=Object.entries,vu=Object.setPrototypeOf,_g=Object.isFrozen,Eg=Object.getPrototypeOf,Tg=Object.getOwnPropertyDescriptor,Te=Object.freeze,we=Object.seal,On=Object.create,Ou=typeof Reflect<"u"&&Reflect,ba=Ou.apply,ya=Ou.construct;Te||(Te=function(e){return e});we||(we=function(e){return e});ba||(ba=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)});ya||(ya=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 Rn=me(Array.prototype.forEach),wg=me(Array.prototype.lastIndexOf),bu=me(Array.prototype.pop),Nn=me(Array.prototype.push),Sg=me(Array.prototype.splice),kt=Array.isArray,ur=me(String.prototype.toLowerCase),ha=me(String.prototype.toString),yu=me(String.prototype.match),lr=me(String.prototype.replace),xu=me(String.prototype.indexOf),Ag=me(String.prototype.trim),kg=me(Number.prototype.toString),Cg=me(Boolean.prototype.toString),_u=typeof BigInt>"u"?null:me(BigInt.prototype.toString),Eu=typeof Symbol>"u"?null:me(Symbol.prototype.toString),ye=me(Object.prototype.hasOwnProperty),cr=me(Object.prototype.toString),be=me(RegExp.prototype.test),tn=Ig(TypeError);function me(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 ba(t,e,r)}}function Ig(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return ya(t,n)}}function W(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ur;if(vu&&vu(t,null),!kt(e))return t;let r=e.length;for(;r--;){let o=e[r];if(typeof o=="string"){let i=n(o);i!==o&&(_g(e)||(e[r]=i),o=i)}t[o]=!0}return t}function Rg(t){for(let e=0;e<t.length;e++)ye(t,e)||(t[e]=null);return t}function Ae(t){let e=On(null);for(let r of Nu(t)){var n=yg(r,2);let o=n[0],i=n[1];ye(t,o)&&(kt(i)?e[o]=Rg(i):i&&typeof i=="object"&&i.constructor===Object?e[o]=Ae(i):e[o]=i)}return e}function Ng(t){switch(typeof t){case"string":return t;case"number":return kg(t);case"boolean":return Cg(t);case"bigint":return _u?_u(t):"0";case"symbol":return Eu?Eu(t):"Symbol()";case"undefined":return cr(t);case"function":case"object":{if(t===null)return cr(t);let e=t,n=Ye(e,"toString");if(typeof n=="function"){let r=n(e);return typeof r=="string"?r:cr(r)}return cr(t)}default:return cr(t)}}function Ye(t,e){for(;t!==null;){let r=Tg(t,e);if(r){if(r.get)return me(r.get);if(typeof r.value=="function")return me(r.value)}t=Eg(t)}function n(){return null}return n}function Og(t){try{return be(t,""),!0}catch{return!1}}var Tu=Te(["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"]),fa=Te(["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"]),ma=Te(["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"]),Mg=Te(["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"]),ga=Te(["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"]),Lg=Te(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),wu=Te(["#text"]),Su=Te(["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"]),va=Te(["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","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","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"]),Au=Te(["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"]),hi=Te(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Pg=we(/{{[\w\W]*|^[\w\W]*}}/g),Dg=we(/<%[\w\W]*|^[\w\W]*%>/g),Ug=we(/\${[\w\W]*/g),Hg=we(/^data-[\-\w.\u00B7-\uFFFF]+$/),zg=we(/^aria-[\-\w]+$/),ku=we(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Gg=we(/^(?:\w+script|data):/i),Fg=we(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),$g=we(/^html$/i),Bg=we(/^[a-z][.\w]*(-[.\w]+)+$/i),Cu=we(/<[/\w!]/g),Iu=we(/<[/\w]/g),Vg=we(/<\/no(script|embed|frames)/i),jg=we(/\/>/i),He={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},qg=function(){return typeof window>"u"?null:window},Wg=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}},Ru=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},At=function(e,n,r,o){return ye(e,n)&&kt(e[n])?W(o.base?Ae(o.base):{},e[n],o.transform):r};function Mu(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:qg(),e=w=>Mu(w);if(e.version="3.4.13",e.removed=[],!t||!t.document||t.document.nodeType!==He.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,c=t.NamedNodeMap;c===void 0&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;let h=t.DOMParser,m=t.trustedTypes,y=a.prototype,f=Ye(y,"cloneNode"),p=Ye(y,"remove"),g=Ye(y,"nextSibling"),x=Ye(y,"childNodes"),S=Ye(y,"parentNode"),T=Ye(y,"shadowRoot"),I=Ye(y,"attributes"),H=s&&s.prototype?Ye(s.prototype,"nodeType"):null,U=s&&s.prototype?Ye(s.prototype,"nodeName"):null,Y=s&&s.prototype?Ye(s.prototype,"ownerDocument"):null;if(typeof i=="function"){let w=n.createElement("template");w.content&&w.content.ownerDocument&&(n=w.content.ownerDocument)}let re,Ve="",ki,Ga=!1,Dn=0,Fa=function(){if(Dn>0)throw tn('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(d){Fa(),Dn++;try{return re.createHTML(d)}finally{Dn--}},hd=function(d){Fa(),Dn++;try{return re.createScriptURL(d)}finally{Dn--}},fd=function(){return Ga||(ki=Wg(m,o),Ga=!0),ki},xr=n,Ci=xr.implementation,$a=xr.createNodeIterator,md=xr.createDocumentFragment,gd=xr.getElementsByTagName,vd=r.importNode,oe=Ru();e.isSupported=typeof Nu=="function"&&typeof S=="function"&&Ci&&Ci.createHTMLDocument!==void 0;let bd=Pg,yd=Dg,xd=Ug,_d=Hg,Ed=zg,Td=Gg,Ba=Fg,wd=Bg,Va=ku,ie=null,Ii=W({},[...Tu,...fa,...ma,...ga,...wu]),se=null,Ri=W({},[...Su,...va,...Au,...hi]),de=Object.seal(On(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}})),Un=null,ja=null,gt=Object.seal(On(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),qa=!0,Ni=!0,Wa=!1,Xa=!0,vt=!1,bt=!0,It=!1,Oi=!1,_r=null,Er=null,Mi=!1,an=!1,Tr=!1,wr=!1,Ya=!0,Ka=!1,Za="user-content-",Li=!0,Sr=!1,ln={},Je=null,Pi=W({},["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"]),Ja=null,Qa=W({},["audio","video","img","source","image","track"]),Di=null,el=W({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ar="http://www.w3.org/1998/Math/MathML",kr="http://www.w3.org/2000/svg",Qe="http://www.w3.org/1999/xhtml",cn=Qe,Ui=!1,Hi=null,Sd=W({},[Ar,kr,Qe],ha),tl=Te(["mi","mo","mn","ms","mtext"]),zi=W({},tl),nl=Te(["annotation-xml"]),Gi=W({},nl),Ad=W({},["title","style","font","a","script"]),Hn=null,kd=["application/xhtml+xml","text/html"],Cd="text/html",le=null,un=null,Id=n.createElement("form"),rl=function(d){return d instanceof RegExp||d instanceof Function},Fi=function(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(un&&un===d)return;(!d||typeof d!="object")&&(d={}),d=Ae(d),Hn=kd.indexOf(d.PARSER_MEDIA_TYPE)===-1?Cd:d.PARSER_MEDIA_TYPE,le=Hn==="application/xhtml+xml"?ha:ur,ie=At(d,"ALLOWED_TAGS",Ii,{transform:le}),se=At(d,"ALLOWED_ATTR",Ri,{transform:le}),Hi=At(d,"ALLOWED_NAMESPACES",Sd,{transform:ha}),Di=At(d,"ADD_URI_SAFE_ATTR",el,{transform:le,base:el}),Ja=At(d,"ADD_DATA_URI_TAGS",Qa,{transform:le,base:Qa}),Je=At(d,"FORBID_CONTENTS",Pi,{transform:le}),Un=At(d,"FORBID_TAGS",Ae({}),{transform:le}),ja=At(d,"FORBID_ATTR",Ae({}),{transform:le}),ln=ye(d,"USE_PROFILES")?d.USE_PROFILES&&typeof d.USE_PROFILES=="object"?Ae(d.USE_PROFILES):d.USE_PROFILES:!1,qa=d.ALLOW_ARIA_ATTR!==!1,Ni=d.ALLOW_DATA_ATTR!==!1,Wa=d.ALLOW_UNKNOWN_PROTOCOLS||!1,Xa=d.ALLOW_SELF_CLOSE_IN_ATTR!==!1,vt=d.SAFE_FOR_TEMPLATES||!1,bt=d.SAFE_FOR_XML!==!1,It=d.WHOLE_DOCUMENT||!1,an=d.RETURN_DOM||!1,Tr=d.RETURN_DOM_FRAGMENT||!1,wr=d.RETURN_TRUSTED_TYPE||!1,Mi=d.FORCE_BODY||!1,Ya=d.SANITIZE_DOM!==!1,Ka=d.SANITIZE_NAMED_PROPS||!1,Li=d.KEEP_CONTENT!==!1,Sr=d.IN_PLACE||!1,Va=Og(d.ALLOWED_URI_REGEXP)?d.ALLOWED_URI_REGEXP:ku,cn=typeof d.NAMESPACE=="string"?d.NAMESPACE:Qe,zi=ye(d,"MATHML_TEXT_INTEGRATION_POINTS")&&d.MATHML_TEXT_INTEGRATION_POINTS&&typeof d.MATHML_TEXT_INTEGRATION_POINTS=="object"?Ae(d.MATHML_TEXT_INTEGRATION_POINTS):W({},tl),Gi=ye(d,"HTML_INTEGRATION_POINTS")&&d.HTML_INTEGRATION_POINTS&&typeof d.HTML_INTEGRATION_POINTS=="object"?Ae(d.HTML_INTEGRATION_POINTS):W({},nl);let b=ye(d,"CUSTOM_ELEMENT_HANDLING")&&d.CUSTOM_ELEMENT_HANDLING&&typeof d.CUSTOM_ELEMENT_HANDLING=="object"?Ae(d.CUSTOM_ELEMENT_HANDLING):On(null);if(de=On(null),ye(b,"tagNameCheck")&&rl(b.tagNameCheck)&&(de.tagNameCheck=b.tagNameCheck),ye(b,"attributeNameCheck")&&rl(b.attributeNameCheck)&&(de.attributeNameCheck=b.attributeNameCheck),ye(b,"allowCustomizedBuiltInElements")&&typeof b.allowCustomizedBuiltInElements=="boolean"&&(de.allowCustomizedBuiltInElements=b.allowCustomizedBuiltInElements),we(de),vt&&(Ni=!1),Tr&&(an=!0),ln&&(ie=W({},wu),se=On(null),ln.html===!0&&(W(ie,Tu),W(se,Su)),ln.svg===!0&&(W(ie,fa),W(se,va),W(se,hi)),ln.svgFilters===!0&&(W(ie,ma),W(se,va),W(se,hi)),ln.mathMl===!0&&(W(ie,ga),W(se,Au),W(se,hi))),gt.tagCheck=null,gt.attributeCheck=null,ye(d,"ADD_TAGS")&&(typeof d.ADD_TAGS=="function"?gt.tagCheck=d.ADD_TAGS:kt(d.ADD_TAGS)&&(ie===Ii&&(ie=Ae(ie)),W(ie,d.ADD_TAGS,le))),ye(d,"ADD_ATTR")&&(typeof d.ADD_ATTR=="function"?gt.attributeCheck=d.ADD_ATTR:kt(d.ADD_ATTR)&&(se===Ri&&(se=Ae(se)),W(se,d.ADD_ATTR,le))),ye(d,"ADD_URI_SAFE_ATTR")&&kt(d.ADD_URI_SAFE_ATTR)&&W(Di,d.ADD_URI_SAFE_ATTR,le),ye(d,"FORBID_CONTENTS")&&kt(d.FORBID_CONTENTS)&&(Je===Pi&&(Je=Ae(Je)),W(Je,d.FORBID_CONTENTS,le)),ye(d,"ADD_FORBID_CONTENTS")&&kt(d.ADD_FORBID_CONTENTS)&&(Je===Pi&&(Je=Ae(Je)),W(Je,d.ADD_FORBID_CONTENTS,le)),Li&&(ie["#text"]=!0),It&&W(ie,["html","head","body"]),ie.table&&(W(ie,["tbody"]),delete Un.tbody),d.TRUSTED_TYPES_POLICY){if(typeof d.TRUSTED_TYPES_POLICY.createHTML!="function")throw tn('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof d.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw tn('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let _=re;re=d.TRUSTED_TYPES_POLICY;try{Ve=sn("")}catch(N){throw re=_,N}}else d.TRUSTED_TYPES_POLICY===null?(re=void 0,Ve=""):(re===void 0&&(re=fd()),re&&typeof Ve=="string"&&(Ve=sn("")));Te&&Te(d),un=d},ol=W({},[...fa,...ma,...Mg]),il=W({},[...ga,...Lg]),Rd=function(d,b,_){return b.namespaceURI===Qe?d==="svg":b.namespaceURI===Ar?d==="svg"&&(_==="annotation-xml"||zi[_]):!!ol[d]},Nd=function(d,b,_){return b.namespaceURI===Qe?d==="math":b.namespaceURI===kr?d==="math"&&Gi[_]:!!il[d]},Od=function(d,b,_){return b.namespaceURI===kr&&!Gi[_]||b.namespaceURI===Ar&&!zi[_]?!1:!il[d]&&(Ad[d]||!ol[d])},Md=function(d){let b=S(d);(!b||!b.tagName)&&(b={namespaceURI:cn,tagName:"template"});let _=ur(d.tagName),N=ur(b.tagName);return Hi[d.namespaceURI]?d.namespaceURI===kr?Rd(_,b,N):d.namespaceURI===Ar?Nd(_,b,N):d.namespaceURI===Qe?Od(_,b,N):!!(Hn==="application/xhtml+xml"&&Hi[d.namespaceURI]):!1},yt=function(d){Nn(e.removed,{element:d});try{S(d).removeChild(d)}catch{if(p(d),!S(d))throw tn("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Cr=function(d){zn(d);let b=x(d);if(b){let N=[];Rn(b,L=>{Nn(N,L)}),Rn(N,L=>{try{p(L)}catch{}})}let _=I(d);if(_)for(let N=_.length-1;N>=0;--N){let L=_[N],z=L&&L.name;if(typeof z=="string")try{d.removeAttribute(z)}catch{}}},Rt=function(d,b){try{Nn(e.removed,{attribute:b.getAttributeNode(d),from:b})}catch{Nn(e.removed,{attribute:null,from:b})}if(b.removeAttribute(d),d==="is")if(an||Tr)try{yt(b)}catch{}else try{b.setAttribute(d,"")}catch{}},Ld=function(d){let b=I(d);if(b)for(let _=b.length-1;_>=0;--_){let N=b[_],L=N&&N.name;if(!(typeof L!="string"||se[le(L)]))try{d.removeAttribute(L)}catch{}}},zn=function(d){let b=[d];for(;b.length>0;){let _=b.pop();(H?H(_):_.nodeType)===He.element&&Ld(_);let L=x(_);if(L)for(let z=L.length-1;z>=0;--z)b.push(L[z])}},Pd=function(d){if(!bt)return;let b=[d];for(;b.length>0;){let _=b.pop(),N=H?H(_):_.nodeType;if(N===He.processingInstruction||N===He.comment&&be(Iu,_.data)){try{p(_)}catch{}continue}if(N===He.element){let z=_,Z=le(U?U(_):_.nodeName);try{z.hasAttribute&&z.hasAttribute("patchsrc")&&z.removeAttribute("patchsrc"),z.hasAttribute&&z.hasAttribute("for")&&Z!=="label"&&Z!=="output"&&z.removeAttribute("for")}catch{}}let L=x(_);if(L)for(let z=L.length-1;z>=0;--z)b.push(L[z])}},sl=function(d){let b=null,_=null;if(Mi)d="<remove></remove>"+d;else{let z=yu(d,/^[\r\n\t ]+/);_=z&&z[0]}Hn==="application/xhtml+xml"&&cn===Qe&&(d='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+d+"</body></html>");let N=re?sn(d):d;if(cn===Qe)try{b=new h().parseFromString(N,Hn)}catch{}if(!b||!b.documentElement){b=Ci.createDocument(cn,"template",null);try{b.documentElement.innerHTML=Ui?Ve:N}catch{}}let L=b.body||b.documentElement;return d&&_&&L.insertBefore(n.createTextNode(_),L.childNodes[0]||null),cn===Qe?gd.call(b,It?"html":"body")[0]:It?b.documentElement:L},al=function(d){let b=Y?Y(d):d.ownerDocument;return $a.call(b||d,d,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Ir=function(d){return d=lr(d,bd," "),d=lr(d,yd," "),d=lr(d,xd," "),d},$i=function(d){var b;d.normalize();let _=Y?Y(d):d.ownerDocument,N=$a.call(_||d,d,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),L=N.nextNode();for(;L;)L.data=Ir(L.data),L=N.nextNode();let z=(b=d.querySelectorAll)===null||b===void 0?void 0:b.call(d,"template");z&&Rn(z,Z=>{dn(Z.content)&&$i(Z.content)})},Rr=function(d){let b=U?U(d):null;return typeof b!="string"||le(b)!=="form"?!1:typeof d.nodeName!="string"||typeof d.textContent!="string"||typeof d.removeChild!="function"||d.attributes!==I(d)||typeof d.removeAttribute!="function"||typeof d.setAttribute!="function"||typeof d.namespaceURI!="string"||typeof d.insertBefore!="function"||typeof d.hasChildNodes!="function"||d.nodeType!==H(d)||d.childNodes!==x(d)},dn=function(d){if(!H||typeof d!="object"||d===null)return!1;try{return H(d)===He.documentFragment}catch{return!1}},Gn=function(d){if(!H||typeof d!="object"||d===null)return!1;try{return typeof H(d)=="number"}catch{return!1}};function et(w,d,b){w.length!==0&&Rn(w,_=>{_.call(e,d,b,un)})}let Dd=function(d,b){return!!(bt&&d.hasChildNodes()&&!Gn(d.firstElementChild)&&be(Cu,d.textContent)&&be(Cu,d.innerHTML)||bt&&d.namespaceURI===Qe&&b==="style"&&Gn(d.firstElementChild)||d.nodeType===He.processingInstruction||bt&&d.nodeType===He.comment&&be(Iu,d.data))},Ud=function(d,b,_){if(!Un[b]&&dl(b)&&(de.tagNameCheck instanceof RegExp&&be(de.tagNameCheck,b)||de.tagNameCheck instanceof Function&&de.tagNameCheck(b)))return!1;if(Li&&!Je[b]){let N=S(d),L=x(d);if(L&&N){let z=L.length;for(let Z=z-1;Z>=0;--Z){let ce=d===_?f(L[Z],!0):L[Z];N.insertBefore(ce,g(d))}}}return yt(d),!0},ll=function(d,b,_,N){return d.length===0?b:b===_||b===N?Ae(b):b},cl=function(d,b){if(et(oe.beforeSanitizeElements,d,null),d!==b&&S(d)===null)return Sr&&zn(d),!0;if(Rr(d))return yt(d),!0;let _=le(U?U(d):d.nodeName);if(ie=ll(oe.uponSanitizeElement,ie,Ii,_r),et(oe.uponSanitizeElement,d,{tagName:_,allowedTags:ie}),d!==b&&S(d)===null)return Sr&&zn(d),!0;if(Dd(d,_))return yt(d),!0;if(Un[_]||!(gt.tagCheck instanceof Function&>.tagCheck(_))&&!ie[_]){let L=Ud(d,_,b);return L===!1&&et(oe.afterSanitizeElements,d,null),L}if((H?H(d):d.nodeType)===He.element&&!Md(d)||(_==="noscript"||_==="noembed"||_==="noframes")&&be(Vg,d.innerHTML))return yt(d),!0;if(vt&&d.nodeType===He.text){let L=Ir(d.textContent);d.textContent!==L&&(Nn(e.removed,{element:d.cloneNode()}),d.textContent=L)}return et(oe.afterSanitizeElements,d,null),!1},ul=function(d,b,_){if(ja[b]||bt&&b==="patchsrc"||bt&&b==="for"&&d!=="label"&&d!=="output"||Ya&&(b==="id"||b==="name")&&(_ in n||_ in Id))return!1;let N=se[b]||gt.attributeCheck instanceof Function&>.attributeCheck(b,d);if(!(Ni&&be(_d,b))){if(!(qa&&be(Ed,b))){if(N){if(!Di[b]){if(!be(Va,lr(_,Ba,""))){if(!((b==="src"||b==="xlink:href"||b==="href")&&d!=="script"&&xu(_,"data:")===0&&Ja[d])){if(!(Wa&&!be(Td,lr(_,Ba,"")))){if(_)return!1}}}}}else if(!(dl(d)&&(de.tagNameCheck instanceof RegExp&&be(de.tagNameCheck,d)||de.tagNameCheck instanceof Function&&de.tagNameCheck(d))&&(de.attributeNameCheck instanceof RegExp&&be(de.attributeNameCheck,b)||de.attributeNameCheck instanceof Function&&de.attributeNameCheck(b,d))||b==="is"&&de.allowCustomizedBuiltInElements&&(de.tagNameCheck instanceof RegExp&&be(de.tagNameCheck,_)||de.tagNameCheck instanceof Function&&de.tagNameCheck(_))))return!1}}return!0},Hd=W({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),dl=function(d){return!Hd[ur(d)]&&be(wd,d)},zd=function(d,b,_,N){if(re&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!_)switch(m.getAttributeType(d,b)){case"TrustedHTML":return sn(N);case"TrustedScriptURL":return hd(N)}return N},Gd=function(d,b,_,N){try{_?d.setAttributeNS(_,b,N):d.setAttribute(b,N),Rr(d)?yt(d):bu(e.removed)}catch{Rt(b,d)}},pl=function(d){et(oe.beforeSanitizeAttributes,d,null);let b=d.attributes;if(!b||Rr(d))return;se=ll(oe.uponSanitizeAttribute,se,Ri,Er);let _={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:se,forceKeepAttr:void 0},N=b.length,L=le(d.nodeName);for(;N--;){let z=b[N],Z=z.name,ce=z.namespaceURI,Ie=z.value,Re=le(Z),Vi=Ie,Ce=Z==="value"?Vi:Ag(Vi);if(_.attrName=Re,_.attrValue=Ce,_.keepAttr=!0,_.forceKeepAttr=void 0,et(oe.uponSanitizeAttribute,d,_),Ce=_.attrValue,Ka&&(Re==="id"||Re==="name")&&xu(Ce,Za)!==0&&(Rt(Z,d),Ce=Za+Ce),bt&&be(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ce)){Rt(Z,d);continue}if(Re==="attributename"&&yu(Ce,"href")){Rt(Z,d);continue}if(!_.forceKeepAttr){if(!_.keepAttr){Rt(Z,d);continue}if(!Xa&&be(jg,Ce)){Rt(Z,d);continue}if(vt&&(Ce=Ir(Ce)),!ul(L,Re,Ce)){Rt(Z,d);continue}Ce=zd(L,Re,ce,Ce),Ce!==Vi&&Gd(d,Z,ce,Ce)}}et(oe.afterSanitizeAttributes,d,null)},Nr=function(d){let b=null,_=al(d);for(et(oe.beforeSanitizeShadowDOM,d,null);b=_.nextNode();)if(et(oe.uponSanitizeShadowNode,b,null),cl(b,d),pl(b),dn(b.content)&&Nr(b.content),(H?H(b):b.nodeType)===He.element){let L=T(b);dn(L)&&(Bi(L),Nr(L))}et(oe.afterSanitizeShadowDOM,d,null)},Bi=function(d){let b=[{node:d,shadow:null}];for(;b.length>0;){let _=b.pop();if(_.shadow){Nr(_.shadow);continue}let N=_.node,z=(H?H(N):N.nodeType)===He.element,Z=x(N);if(Z)for(let ce=Z.length-1;ce>=0;--ce)b.push({node:Z[ce],shadow:null});if(z){let ce=U?U(N):null;if(typeof ce=="string"&&le(ce)==="template"){let Ie=N.content;dn(Ie)&&b.push({node:Ie,shadow:null})}}if(z){let ce=T(N);dn(ce)&&b.push({node:null,shadow:ce},{node:ce,shadow:null})}}};return e.sanitize=function(w){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},b=null,_=null,N=null,L=null;if(Ui=!w,Ui&&(w="<!-->"),typeof w!="string"&&!Gn(w)&&(w=Ng(w),typeof w!="string"))throw tn("dirty is not a string, aborting");if(!e.isSupported)return w;Oi?(ie=_r,se=Er):Fi(d),(oe.uponSanitizeElement.length>0||oe.uponSanitizeAttribute.length>0)&&(ie=Ae(ie)),oe.uponSanitizeAttribute.length>0&&(se=Ae(se)),e.removed=[];let z=Sr&&typeof w!="string"&&Gn(w);if(z){Pd(w);let Ie=U?U(w):w.nodeName;if(typeof Ie=="string"){let Re=le(Ie);if(!ie[Re]||Un[Re])throw Cr(w),tn("root node is forbidden and cannot be sanitized in-place")}if(Rr(w))throw Cr(w),tn("root node is clobbered and cannot be sanitized in-place");try{Bi(w)}catch(Re){throw Cr(w),Re}}else if(Gn(w))b=sl("<!---->"),_=b.ownerDocument.importNode(w,!0),_.nodeType===He.element&&_.nodeName==="BODY"||_.nodeName==="HTML"?b=_:b.appendChild(_),Bi(_);else{if(!an&&!vt&&!It&&w.indexOf("<")===-1)return re&&wr?sn(w):w;if(b=sl(w),!b)return an?null:wr?Ve:""}b&&Mi&&yt(b.firstChild);let Z=z?w:b;try{let Ie=al(Z);for(;N=Ie.nextNode();)cl(N,Z),pl(N),dn(N.content)&&Nr(N.content)}catch(Ie){throw z&&(Cr(w),Rn(e.removed,Re=>{Re.element&&zn(Re.element)})),Ie}if(z)return Rn(e.removed,Ie=>{Ie.element&&zn(Ie.element)}),vt&&$i(w),w;if(an){if(vt&&$i(b),Tr)for(L=md.call(b.ownerDocument);b.firstChild;)L.appendChild(b.firstChild);else L=b;return(se.shadowroot||se.shadowrootmode)&&(L=vd.call(r,L,!0)),L}let ce=It?b.outerHTML:b.innerHTML;return It&&ie["!doctype"]&&b.ownerDocument&&b.ownerDocument.doctype&&b.ownerDocument.doctype.name&&be($g,b.ownerDocument.doctype.name)&&(ce="<!DOCTYPE "+b.ownerDocument.doctype.name+`>
|
|
13
|
+
`+ce),vt&&(ce=Ir(ce)),re&&wr?sn(ce):ce},e.setConfig=function(){let w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Fi(w),Oi=!0,_r=ie,Er=se},e.clearConfig=function(){un=null,Oi=!1,_r=null,Er=null,re=ki,Ve=""},e.isValidAttribute=function(w,d,b){un||Fi({});let _=le(w),N=le(d);return ul(_,N,b)},e.addHook=function(w,d){typeof d=="function"&&ye(oe,w)&&Nn(oe[w],d)},e.removeHook=function(w,d){if(ye(oe,w)){if(d!==void 0){let b=wg(oe[w],d);return b===-1?void 0:Sg(oe[w],b,1)[0]}return bu(oe[w])}},e.removeHooks=function(w){ye(oe,w)&&(oe[w]=[])},e.removeAllHooks=function(){oe=Ru()},e}var Lu=Mu();function Ta(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var on=Ta();function $u(t){on=t}var nn={exec:()=>null};function Mn(t){let e=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),o=e[r];return o||(o=t(r),e[r]=o),o}}function j(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(o,i)=>{let s=typeof i=="string"?i:i.source;return s=s.replace(ke.caret,"$1"),n=n.replace(o,s),r},getRegex:()=>new RegExp(n,e)};return r}var Xg=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),ke={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,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:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Mn(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Mn(t=>new RegExp(`^ {0,${t}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Mn(t=>new RegExp(`^ {0,${t}}(?:\`\`\`|~~~)`)),headingBeginRegex:Mn(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:Mn(t=>new RegExp(`^ {0,${t}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:Mn(t=>new RegExp(`^ {0,${t}}>`))},Yg=/^(?:[ \t]*(?:\n|$))+/,Kg=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Zg=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Jg=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,wa=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Bu=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Vu=j(Bu).replace(/bull/g,wa).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(),Qg=j(Bu).replace(/bull/g,wa).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(),Sa=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,ev=/^[^\n]+/,Aa=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,tv=j(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Aa).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),nv=j(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,wa).getRegex(),bi="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",ka=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,rv=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][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",ka).replace("tag",bi).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ju=t=>j(Sa).replace("hr",hr).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",t).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",bi).getRegex(),ov=ju(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),iv=ju(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),sv=j(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",iv).getRegex(),Ca={blockquote:sv,code:Kg,def:tv,fences:Zg,heading:Jg,hr,html:rv,lheading:Vu,list:nv,newline:Yg,paragraph:ov,table:nn,text:ev},Pu=j("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",hr).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",bi).getRegex(),av={...Ca,lheading:Qg,table:Pu,paragraph:j(Sa).replace("hr",hr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Pu).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",bi).getRegex()},lv={...Ca,html:j(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ka).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:nn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:j(Sa).replace("hr",hr).replace("heading",` *#{1,6} *[^
|
|
14
|
+
]`).replace("lheading",Vu).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},cv=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,uv=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,qu=/^( {2,}|\\)\n(?!\s*$)/,dv=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ft=/[\p{P}\p{S}]/u,Ln=/[\s\p{P}\p{S}]/u,fr=/[^\s\p{P}\p{S}]/u,pv=j(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ln).getRegex(),hv=/[\p{Pi}\p{Ps}"']/u,Wu=/(?!~)[\p{P}\p{S}]/u,fv=/(?!~)[\s\p{P}\p{S}]/u,mv=/(?:[^\s\p{P}\p{S}]|~)/u,gv=j(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Xg?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Xu=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,vv=j(Xu,"u").replace(/punct/g,ft).getRegex(),bv=j(Xu,"u").replace(/punct/g,Wu).getRegex(),yv=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,xv=j(yv,"u").replace(/openQuote/g,hv).replace(/punct/g,ft).getRegex(),Yu="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",_v=j(Yu,"gu").replace(/notPunctSpace/g,fr).replace(/punctSpace/g,Ln).replace(/punct/g,ft).getRegex(),Ev=j(Yu,"gu").replace(/notPunctSpace/g,mv).replace(/punctSpace/g,fv).replace(/punct/g,Wu).getRegex(),Tv="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",wv=j(Tv,"gu").replace(/notPunctSpace/g,fr).replace(/punctSpace/g,Ln).replace(/punct/g,ft).getRegex(),Sv=j("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,fr).replace(/punctSpace/g,Ln).replace(/punct/g,ft).getRegex(),Av="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",kv=j(Av,"gu").replace(/notPunctSpace/g,fr).replace(/punctSpace/g,Ln).replace(/punct/g,ft).getRegex(),Cv=j(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,ft).getRegex(),Iv="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Rv=j(Iv,"gu").replace(/notPunctSpace/g,fr).replace(/punctSpace/g,Ln).replace(/punct/g,ft).getRegex(),Nv=j(/\\(punct)/,"gu").replace(/punct/g,ft).getRegex(),Ov=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(),Mv=j(ka).replace("(?:-->|$)","-->").getRegex(),Lv=j("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Mv).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),mi=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Pv=j(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",mi).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ku=j(/^!?\[(label)\]\[(ref)\]/).replace("label",mi).replace("ref",Aa).getRegex(),Zu=j(/^!?\[(ref)\](?:\[\])?/).replace("ref",Aa).getRegex(),Dv=j("reflink|nolink(?!\\()","g").replace("reflink",Ku).replace("nolink",Zu).getRegex(),Du=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ia={_backpedal:nn,anyPunctuation:Nv,autolink:Ov,blockSkip:gv,br:qu,code:uv,del:nn,delLDelim:nn,delRDelim:nn,emStrongLDelim:vv,emStrongRDelimAst:_v,emStrongRDelimUnd:Sv,escape:cv,link:Pv,nolink:Zu,punctuation:pv,reflink:Ku,reflinkSearch:Dv,tag:Lv,text:dv,url:nn},Uv={...Ia,emStrongLDelim:xv,emStrongRDelimAst:wv,emStrongRDelimUnd:kv,link:j(/^!?\[(label)\]\((.*?)\)/).replace("label",mi).getRegex(),reflink:j(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",mi).getRegex()},xa={...Ia,emStrongRDelimAst:Ev,emStrongLDelim:bv,delLDelim:Cv,delRDelim:Rv,url:j(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Du).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).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",Du).getRegex()},Hv={...xa,br:j(qu).replace("{2,}","*").getRegex(),text:j(xa.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},fi={normal:Ca,gfm:av,pedantic:lv},dr={normal:Ia,gfm:xa,breaks:Hv,pedantic:Uv},zv={"&":"&","<":"<",">":">",'"':""","'":"'"},Uu=t=>zv[t];function at(t,e){if(e){if(ke.escapeTest.test(t))return t.replace(ke.escapeReplace,Uu)}else if(ke.escapeTestNoEncode.test(t))return t.replace(ke.escapeReplaceNoEncode,Uu);return t}function Hu(t){try{t=encodeURI(t).replace(ke.percentDecode,"%")}catch{return null}return t}function zu(t,e){let n=t.replace(ke.findPipe,(i,s,a)=>{let l=!1,c=s;for(;--c>=0&&a[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(ke.splitPipe),o=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(ke.slashPipe,"|");return r}function Ct(t,e,n){let r=t.length;if(r===0)return"";let o=0;for(;o<r;){let i=t.charAt(r-o-1);if(i===e&&!n)o++;else if(i!==e&&n)o++;else break}return t.slice(0,r-o)}function Gu(t){let e=t.split(`
|
|
15
15
|
`),n=e.length-1;for(;n>=0&&ke.blankLine.test(e[n]);)n--;return e.length-n<=2?t:e.slice(0,n+1).join(`
|
|
16
|
-
`)}function
|
|
16
|
+
`)}function Gv(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function Fv(t,e=0){let n=e,r="";for(let o of t)if(o===" "){let i=4-n%4;r+=" ".repeat(i),n+=i}else r+=o,n++;return r}function Fu(t,e,n,r,o){let i=e.href,s=e.title||null,a=t[1].replace(o.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:s,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,l}function $v(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let o=r[1];return e.split(`
|
|
17
17
|
`).map(i=>{let s=i.match(n.other.beginningSpace);if(s===null)return i;let[a]=s;return a.length>=o.length?i.slice(o.length):i}).join(`
|
|
18
|
-
`)}var
|
|
19
|
-
`),depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:
|
|
20
|
-
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=
|
|
18
|
+
`)}var gi=class{options;rules;lexer;constructor(t){this.options=t||on}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=this.options.pedantic?e[0]:Gu(e[0]),r=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:r}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=$v(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let r=Ct(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:Ct(e[0],`
|
|
19
|
+
`),depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:Ct(e[0],`
|
|
20
|
+
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=Ct(e[0],`
|
|
21
21
|
`).split(`
|
|
22
22
|
`),r="",o="",i=[];for(;n.length>0;){let s=!1,a=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))a.push(n[l]),s=!0;else if(!s)a.push(n[l]);else break;n=n.slice(l);let c=a.join(`
|
|
23
23
|
`),h=c.replace(this.rules.other.blockquoteSetextReplace,`
|
|
@@ -29,19 +29,19 @@ ${h}`:h;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
29
29
|
${p}`,o=o.substring(0,o.length-f.text.length)+x.text;break}else if(y?.type==="list"){let f=y,p=f.raw+`
|
|
30
30
|
`+n.join(`
|
|
31
31
|
`),g=this.list(p);i[i.length-1]=g,r=r.substring(0,r.length-y.raw.length)+g.raw,o=o.substring(0,o.length-f.raw.length)+g.raw,n=p.substring(i.at(-1).raw.length).split(`
|
|
32
|
-
`);continue}}return{type:"blockquote",raw:r,tokens:i,text:o}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),r=n.length>1,o={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let i=this.rules.other.listItemRegex(n),s=!1;for(;t;){let l=!1,c="",h="";if(!(e=i.exec(t))||this.rules.block.hr.test(t))break;c=e[0],t=t.substring(c.length);let m=
|
|
32
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:i,text:o}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),r=n.length>1,o={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let i=this.rules.other.listItemRegex(n),s=!1;for(;t;){let l=!1,c="",h="";if(!(e=i.exec(t))||this.rules.block.hr.test(t))break;c=e[0],t=t.substring(c.length);let m=Fv(e[2].split(`
|
|
33
33
|
`,1)[0],e[1].length),y=t.split(`
|
|
34
34
|
`,1)[0],f=!m.trim(),p=0;if(this.options.pedantic?(p=2,h=m.trimStart()):f?p=e[1].length+1:(p=m.search(this.rules.other.nonSpaceChar),p=p>4?1:p,h=m.slice(p),p+=e[1].length),f&&this.rules.other.blankLine.test(y)&&(c+=y+`
|
|
35
|
-
`,t=t.substring(y.length+1),l=!0),!l){let g=this.rules.other.nextBulletRegex(p),x=this.rules.other.hrRegex(p),
|
|
36
|
-
`,1)[0],Y;if(y=U,this.options.pedantic?(y=y.replace(this.rules.other.listReplaceNesting," "),Y=y):Y=y.replace(this.rules.other.tabCharGlobal," "),
|
|
37
|
-
`+Y.slice(p);else{if(f||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||
|
|
35
|
+
`,t=t.substring(y.length+1),l=!0),!l){let g=this.rules.other.nextBulletRegex(p),x=this.rules.other.hrRegex(p),S=this.rules.other.fencesBeginRegex(p),T=this.rules.other.headingBeginRegex(p),I=this.rules.other.htmlBeginRegex(p),H=this.rules.other.blockquoteBeginRegex(p);for(;t;){let U=t.split(`
|
|
36
|
+
`,1)[0],Y;if(y=U,this.options.pedantic?(y=y.replace(this.rules.other.listReplaceNesting," "),Y=y):Y=y.replace(this.rules.other.tabCharGlobal," "),S.test(y)||T.test(y)||I.test(y)||H.test(y)||g.test(y)||x.test(y))break;if(Y.search(this.rules.other.nonSpaceChar)>=p||!y.trim())h+=`
|
|
37
|
+
`+Y.slice(p);else{if(f||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||S.test(m)||T.test(m)||x.test(m))break;h+=`
|
|
38
38
|
`+y}f=!y.trim(),c+=U+`
|
|
39
|
-
`,t=t.substring(U.length+1),m=Y.slice(p)}}o.loose||(s?o.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(s=!0)),o.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(h),loose:!1,text:h,tokens:[]}),o.raw+=c}let a=o.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let l of o.items){this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]);let c=l.tokens[0];if(l.task&&(c?.type==="text"||c?.type==="paragraph")){l.text=l.text.replace(this.rules.other.listReplaceTask,""),c.raw=c.raw.replace(this.rules.other.listReplaceTask,""),c.text=c.text.replace(this.rules.other.listReplaceTask,"");for(let m=this.lexer.inlineQueue.length-1;m>=0;m--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[m].src)){this.lexer.inlineQueue[m].src=this.lexer.inlineQueue[m].src.replace(this.rules.other.listReplaceTask,"");break}let h=this.rules.other.listTaskCheckbox.exec(l.raw);if(h){let m={type:"checkbox",raw:h[0]+" ",checked:h[0]!=="[ ]"};l.checked=m.checked,o.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=m.raw+l.tokens[0].raw,l.tokens[0].text=m.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(m)):l.tokens.unshift({type:"paragraph",raw:m.raw,text:m.raw,tokens:[m]}):l.tokens.unshift(m)}}else l.task&&(l.task=!1);if(!o.loose){let h=l.tokens.filter(y=>y.type==="space"),m=h.length>0&&h.some(y=>this.rules.other.anyLine.test(y.raw));o.loose=m}}if(o.loose)for(let l of o.items){l.loose=!0;for(let c of l.tokens)c.type==="text"&&(c.type="paragraph")}return o}}html(t){let e=this.rules.block.html.exec(t);if(e){let n=
|
|
40
|
-
`),href:r,title:o}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=
|
|
41
|
-
`):[],i={type:"table",raw:
|
|
42
|
-
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let s of r)this.rules.other.tableAlignRight.test(s)?i.align.push("right"):this.rules.other.tableAlignCenter.test(s)?i.align.push("center"):this.rules.other.tableAlignLeft.test(s)?i.align.push("left"):i.align.push(null);for(let s=0;s<n.length;s++)i.header.push({text:n[s],tokens:this.lexer.inline(n[s]),header:!0,align:i.align[s]});for(let s of o)i.rows.push(
|
|
39
|
+
`,t=t.substring(U.length+1),m=Y.slice(p)}}o.loose||(s?o.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(s=!0)),o.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(h),loose:!1,text:h,tokens:[]}),o.raw+=c}let a=o.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let l of o.items){this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]);let c=l.tokens[0];if(l.task&&(c?.type==="text"||c?.type==="paragraph")){l.text=l.text.replace(this.rules.other.listReplaceTask,""),c.raw=c.raw.replace(this.rules.other.listReplaceTask,""),c.text=c.text.replace(this.rules.other.listReplaceTask,"");for(let m=this.lexer.inlineQueue.length-1;m>=0;m--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[m].src)){this.lexer.inlineQueue[m].src=this.lexer.inlineQueue[m].src.replace(this.rules.other.listReplaceTask,"");break}let h=this.rules.other.listTaskCheckbox.exec(l.raw);if(h){let m={type:"checkbox",raw:h[0]+" ",checked:h[0]!=="[ ]"};l.checked=m.checked,o.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=m.raw+l.tokens[0].raw,l.tokens[0].text=m.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(m)):l.tokens.unshift({type:"paragraph",raw:m.raw,text:m.raw,tokens:[m]}):l.tokens.unshift(m)}}else l.task&&(l.task=!1);if(!o.loose){let h=l.tokens.filter(y=>y.type==="space"),m=h.length>0&&h.some(y=>this.rules.other.anyLine.test(y.raw));o.loose=m}}if(o.loose)for(let l of o.items){l.loose=!0;for(let c of l.tokens)c.type==="text"&&(c.type="paragraph")}return o}}html(t){let e=this.rules.block.html.exec(t);if(e){let n=Gu(e[0]);return{type:"html",block:!0,raw:n,pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:n}}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",o=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:Ct(e[0],`
|
|
40
|
+
`),href:r,title:o}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=zu(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),o=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
41
|
+
`):[],i={type:"table",raw:Ct(e[0],`
|
|
42
|
+
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let s of r)this.rules.other.tableAlignRight.test(s)?i.align.push("right"):this.rules.other.tableAlignCenter.test(s)?i.align.push("center"):this.rules.other.tableAlignLeft.test(s)?i.align.push("left"):i.align.push(null);for(let s=0;s<n.length;s++)i.header.push({text:n[s],tokens:this.lexer.inline(n[s]),header:!0,align:i.align[s]});for(let s of o)i.rows.push(zu(s,i.header.length).map((a,l)=>({text:a,tokens:this.lexer.inline(a),header:!1,align:i.align[l]})));return i}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:Ct(e[0],`
|
|
43
43
|
`),depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`
|
|
44
|
-
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=
|
|
44
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=Ct(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=Gv(e[2],"()");if(i===-2)return;if(i>-1){let s=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,s).trim(),e[3]=""}}let r=e[2],o="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(r);i&&(r=i[1],o=i[3])}else o=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),Fu(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:o&&o.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),o=e[r.toLowerCase()];if(!o){let i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return Fu(n,o,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let o=[...r[0]].length-1,i,s,a=o,l=0,c=r[0][0],h=n===c,m=c==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(m.lastIndex=0,e=e.slice(-1*t.length+o);(r=m.exec(e))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(s=[...i].length,r[3]||r[4]){a+=s;continue}else if(r[5]||r[6]){if(o%3&&!((o+s)%3)){l+=s;continue}if(h)break}if(a-=s,a>0)continue;s=Math.min(s,s+a+l);let y=[...r[0]][0].length,f=t.slice(0,o+r.index+y+s);if(Math.min(o,s)%2){let g=f.slice(1,-1);return{type:"em",raw:f,text:g,tokens:this.lexer.inlineTokens(g)}}let p=f.slice(2,-2);return{type:"strong",raw:f,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),o=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&o&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let r=this.rules.inline.delLDelim.exec(t);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let o=[...r[0]].length-1,i,s,a=o,l=this.rules.inline.delRDelim;for(l.lastIndex=0,e=e.slice(-1*t.length+o);(r=l.exec(e))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(s=[...i].length,s!==o))continue;if(r[3]||r[4]){a+=s;continue}if(a-=s,a>0)continue;s=Math.min(s,s+a);let c=[...r[0]][0].length,h=t.slice(0,o+r.index+c+s),m=h.slice(o,-o);return{type:"del",raw:h,text:m,tokens:this.lexer.inlineTokens(m)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,r;if(e[2]==="@")n=e[0],r="mailto:"+n;else{let o;do o=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(o!==e[0]);n=e[0],e[1]==="www."?r="http://"+e[0]:r=e[0]}return{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},Ke=class _a{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||on,this.options.tokenizer=this.options.tokenizer||new gi,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:ke,block:fi.normal,inline:dr.normal};this.options.pedantic?(n.block=fi.pedantic,n.inline=dr.pedantic):this.options.gfm&&(n.block=fi.gfm,this.options.breaks?n.inline=dr.breaks:n.inline=dr.gfm),this.tokenizer.rules=n}static get rules(){return{block:fi,inline:dr}}static lex(e,n){return new _a(n).lex(e)}static lexInline(e,n){return new _a(n).inlineTokens(e)}lex(e){e=e.replace(ke.carriageReturn,`
|
|
45
45
|
`),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(ke.tabCharGlobal," ").replace(ke.spaceLine,""));let o=1/0;for(;e;){if(e.length<o)o=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(a=>(i=a.call({lexer:this},e,n))?(e=e.substring(i.raw.length),n.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let a=n.at(-1);i.raw.length===1&&a!==void 0?a.raw+=`
|
|
46
46
|
`:n.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let a=n.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
|
47
47
|
`)?"":`
|
|
@@ -55,9 +55,9 @@ ${p}`,o=o.substring(0,o.length-f.text.length)+x.text;break}else if(y?.type==="li
|
|
|
55
55
|
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(i),r=s.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let a=n.at(-1);a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
|
56
56
|
`)?"":`
|
|
57
57
|
`)+i.raw,a.text+=`
|
|
58
|
-
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let r=e;if(this.tokens.links){let a=Object.keys(this.tokens.links);a.length>0&&(r=r.replace(this.tokenizer.rules.inline.reflinkSearch,l=>a.includes(l.slice(l.lastIndexOf("[")+1,-1))?"["+"a".repeat(l.length-2)+"]":l))}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,"++"),r=r.replace(this.tokenizer.rules.inline.blockSkip,(a,l,c)=>{let h=c?c.length:0;return a.slice(0,h)+"["+"a".repeat(a.length-h-2)+"]"}),r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let o=!1,i="",s=1/0;for(;e;){if(e.length<s)s=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}o||(i=""),o=!1;let a;if(this.options.extensions?.inline?.some(c=>(a=c.call({lexer:this},e,n))?(e=e.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.escape(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.tag(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.link(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(a.raw.length);let c=n.at(-1);a.type==="text"&&c?.type==="text"?(c.raw+=a.raw,c.text+=a.text):n.push(a);continue}if(a=this.tokenizer.emStrong(e,r,i)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.codespan(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.br(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.del(e,r,i)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.autolink(e)){e=e.substring(a.raw.length),n.push(a);continue}if(!this.state.inLink&&(a=this.tokenizer.url(e))){e=e.substring(a.raw.length),n.push(a);continue}let l=e;if(this.options.extensions?.startInline){let c=1/0,h=e.slice(1),m;this.options.extensions.startInline.forEach(y=>{m=y.call({lexer:this},h),typeof m=="number"&&m>=0&&(c=Math.min(c,m))}),c<1/0&&c>=0&&(l=e.substring(0,c+1))}if(a=this.tokenizer.inlineText(l)){e=e.substring(a.raw.length),a.raw.slice(-1)!=="_"&&(i=a.raw.slice(-1)),o=!0;let c=n.at(-1);c?.type==="text"?(c.raw+=a.raw,c.text+=a.text):n.push(a);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return n}infiniteLoopError(e){let n="Infinite loop on byte: "+e;if(this.options.silent)console.error(n);else throw new Error(n)}},
|
|
59
|
-
`;return r?'<pre><code class="language-'+
|
|
60
|
-
`:"<pre><code>"+(n?o:
|
|
58
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let r=e;if(this.tokens.links){let a=Object.keys(this.tokens.links);a.length>0&&(r=r.replace(this.tokenizer.rules.inline.reflinkSearch,l=>a.includes(l.slice(l.lastIndexOf("[")+1,-1))?"["+"a".repeat(l.length-2)+"]":l))}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,"++"),r=r.replace(this.tokenizer.rules.inline.blockSkip,(a,l,c)=>{let h=c?c.length:0;return a.slice(0,h)+"["+"a".repeat(a.length-h-2)+"]"}),r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let o=!1,i="",s=1/0;for(;e;){if(e.length<s)s=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}o||(i=""),o=!1;let a;if(this.options.extensions?.inline?.some(c=>(a=c.call({lexer:this},e,n))?(e=e.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.escape(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.tag(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.link(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(a.raw.length);let c=n.at(-1);a.type==="text"&&c?.type==="text"?(c.raw+=a.raw,c.text+=a.text):n.push(a);continue}if(a=this.tokenizer.emStrong(e,r,i)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.codespan(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.br(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.del(e,r,i)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.autolink(e)){e=e.substring(a.raw.length),n.push(a);continue}if(!this.state.inLink&&(a=this.tokenizer.url(e))){e=e.substring(a.raw.length),n.push(a);continue}let l=e;if(this.options.extensions?.startInline){let c=1/0,h=e.slice(1),m;this.options.extensions.startInline.forEach(y=>{m=y.call({lexer:this},h),typeof m=="number"&&m>=0&&(c=Math.min(c,m))}),c<1/0&&c>=0&&(l=e.substring(0,c+1))}if(a=this.tokenizer.inlineText(l)){e=e.substring(a.raw.length),a.raw.slice(-1)!=="_"&&(i=a.raw.slice(-1)),o=!0;let c=n.at(-1);c?.type==="text"?(c.raw+=a.raw,c.text+=a.text):n.push(a);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return n}infiniteLoopError(e){let n="Infinite loop on byte: "+e;if(this.options.silent)console.error(n);else throw new Error(n)}},vi=class{options;parser;constructor(t){this.options=t||on}space(t){return""}code({text:t,lang:e,escaped:n}){let r=(e||"").match(ke.notSpaceStart)?.[0],o=t.replace(ke.endingNewline,"")+`
|
|
59
|
+
`;return r?'<pre><code class="language-'+at(r)+'">'+(n?o:at(o,!0))+`</code></pre>
|
|
60
|
+
`:"<pre><code>"+(n?o:at(o,!0))+`</code></pre>
|
|
61
61
|
`}blockquote({tokens:t}){return`<blockquote>
|
|
62
62
|
${this.parser.parse(t)}</blockquote>
|
|
63
63
|
`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
|
|
@@ -73,153 +73,218 @@ ${this.parser.parse(t)}</blockquote>
|
|
|
73
73
|
`}tablerow({text:t}){return`<tr>
|
|
74
74
|
${t}</tr>
|
|
75
75
|
`}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
|
76
|
-
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${
|
|
77
|
-
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+
|
|
76
|
+
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${at(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),o=Hu(t);if(o===null)return r;t=o;let i='<a href="'+t+'"';return e&&(i+=' title="'+at(e)+'"'),i+=">"+r+"</a>",i}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let o=Hu(t);if(o===null)return at(n);t=o;let i=`<img src="${t}" alt="${at(n)}"`;return e&&(i+=` title="${at(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:at(t.text)}},Ra=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},Ze=class Ea{options;renderer;textRenderer;constructor(e){this.options=e||on,this.options.renderer=this.options.renderer||new vi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ra}static parse(e,n){return new Ea(n).parse(e)}static parseInline(e,n){return new Ea(n).parseInline(e)}parse(e){this.renderer.parser=this;let n="";for(let r=0;r<e.length;r++){let o=e[r];if(this.options.extensions?.renderers?.[o.type]){let s=o,a=this.options.extensions.renderers[s.type].call({parser:this},s);if(a!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(s.type)){n+=a||"";continue}}let i=o;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 s='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return n}parseInline(e,n=this.renderer){this.renderer.parser=this;let r="";for(let o=0;o<e.length;o++){let i=e[o];if(this.options.extensions?.renderers?.[i.type]){let a=this.options.extensions.renderers[i.type].call({parser:this},i);if(a!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(i.type)){r+=a||"";continue}}let s=i;switch(s.type){case"escape":{r+=n.text(s);break}case"html":{r+=n.html(s);break}case"link":{r+=n.link(s);break}case"image":{r+=n.image(s);break}case"checkbox":{r+=n.checkbox(s);break}case"strong":{r+=n.strong(s);break}case"em":{r+=n.em(s);break}case"codespan":{r+=n.codespan(s);break}case"br":{r+=n.br(s);break}case"del":{r+=n.del(s);break}case"text":{r+=n.text(s);break}default:{let a='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return r}},pr=class{options;block;constructor(t){this.options=t||on}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?Ke.lex:Ke.lexInline}provideParser(t=this.block){return t?Ze.parse:Ze.parseInline}},Na=class{defaults=Ta();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ze;Renderer=vi;TextRenderer=Ra;Lexer=Ke;Tokenizer=gi;Hooks=pr;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let r of t)switch(n=n.concat(e.call(this,r)),r.type){case"table":{let o=r;for(let i of o.header)n=n.concat(this.walkTokens(i.tokens,e));for(let i of o.rows)for(let s of i)n=n.concat(this.walkTokens(s.tokens,e));break}case"list":{let o=r;n=n.concat(this.walkTokens(o.items,e));break}default:{let o=r;this.defaults.extensions?.childTokens?.[o.type]?this.defaults.extensions.childTokens[o.type].forEach(i=>{let s=o[i].flat(1/0);n=n.concat(this.walkTokens(s,e))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if("renderer"in o){let i=e.renderers[o.name];i?e.renderers[o.name]=function(...s){let a=o.renderer.apply(this,s);return a===!1&&(a=i.apply(this,s)),a}:e.renderers[o.name]=o.renderer}if("tokenizer"in o){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=e[o.level];i?i.unshift(o.tokenizer):e[o.level]=[o.tokenizer],o.start&&(o.level==="block"?e.startBlock?e.startBlock.push(o.start):e.startBlock=[o.start]:o.level==="inline"&&(e.startInline?e.startInline.push(o.start):e.startInline=[o.start]))}"childTokens"in o&&o.childTokens&&(e.childTokens[o.name]=o.childTokens)}),r.extensions=e),n.renderer){let o=this.defaults.renderer||new vi(this.defaults);for(let i in n.renderer){if(!(i in o))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let s=i,a=n.renderer[s],l=o[s];o[s]=(...c)=>{let h=a.apply(o,c);return h===!1&&(h=l.apply(o,c)),h||""}}r.renderer=o}if(n.tokenizer){let o=this.defaults.tokenizer||new gi(this.defaults);for(let i in n.tokenizer){if(!(i in o))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let s=i,a=n.tokenizer[s],l=o[s];o[s]=(...c)=>{let h=a.apply(o,c);return h===!1&&(h=l.apply(o,c)),h}}r.tokenizer=o}if(n.hooks){let o=this.defaults.hooks||new pr;for(let i in n.hooks){if(!(i in o))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let s=i,a=n.hooks[s],l=o[s];pr.passThroughHooks.has(i)?o[s]=c=>{if(this.defaults.async&&pr.passThroughHooksRespectAsync.has(i))return(async()=>{let m=await a.call(o,c);return l.call(o,m)})();let h=a.call(o,c);return l.call(o,h)}:o[s]=(...c)=>{if(this.defaults.async)return(async()=>{let m=await a.apply(o,c);return m===!1&&(m=await l.apply(o,c)),m})();let h=a.apply(o,c);return h===!1&&(h=l.apply(o,c)),h}}r.hooks=o}if(n.walkTokens){let o=this.defaults.walkTokens,i=n.walkTokens;r.walkTokens=function(s){let a=[];return a.push(i.call(this,s)),o&&(a=a.concat(o.call(this,s))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return Ke.lex(t,e??this.defaults)}parser(t,e){return Ze.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},o={...this.defaults,...r},i=this.onError(!!o.silent,!!o.async);if(this.defaults.async===!0&&r.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 e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(o.hooks&&(o.hooks.options=o,o.hooks.block=t),o.async)return(async()=>{let s=o.hooks?await o.hooks.preprocess(e):e,a=await(o.hooks?await o.hooks.provideLexer(t):t?Ke.lex:Ke.lexInline)(s,o),l=o.hooks?await o.hooks.processAllTokens(a):a;o.walkTokens&&await Promise.all(this.walkTokens(l,o.walkTokens));let c=await(o.hooks?await o.hooks.provideParser(t):t?Ze.parse:Ze.parseInline)(l,o);return o.hooks?await o.hooks.postprocess(c):c})().catch(i);try{o.hooks&&(e=o.hooks.preprocess(e));let s=(o.hooks?o.hooks.provideLexer(t):t?Ke.lex:Ke.lexInline)(e,o);o.hooks&&(s=o.hooks.processAllTokens(s)),o.walkTokens&&this.walkTokens(s,o.walkTokens);let a=(o.hooks?o.hooks.provideParser(t):t?Ze.parse:Ze.parseInline)(s,o);return o.hooks&&(a=o.hooks.postprocess(a)),a}catch(s){return i(s)}}}onError(t,e){return n=>{if(n.message+=`
|
|
77
|
+
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+at(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},rn=new Na;function J(t,e){return rn.parse(t,e)}J.options=J.setOptions=function(t){return rn.setOptions(t),J.defaults=rn.defaults,$u(J.defaults),J};J.getDefaults=Ta;J.defaults=on;function Bv(...t){return rn.use(...t),J.defaults=rn.defaults,$u(J.defaults),J}J.use=Bv;J.walkTokens=function(t,e){return rn.walkTokens(t,e)};J.parseInline=rn.parseInline;J.Parser=Ze;J.parser=Ze.parse;J.Renderer=vi;J.TextRenderer=Ra;J.Lexer=Ke;J.lexer=Ke.lex;J.Tokenizer=gi;J.Hooks=pr;J.parse=J;var Fw=J.options,$w=J.setOptions,Bw=J.walkTokens,Vw=J.parseInline;var jw=Ze.parse,qw=Ke.lex;var Vv=new Na({gfm:!0,breaks:!0}),Ju=["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"],Qu=["href","title","class"],jv=[...Ju,"img"],qv=[...Qu,"src","alt","width","height"];function yi(t,e){let n=e?.allowImages===!0,r=Vv.parse(t,{async:!1}),o=Lu.sanitize(r,{ALLOWED_TAGS:n?jv:Ju,ALLOWED_ATTR:n?qv:Qu}),i=document.createElement("template");i.innerHTML=o;for(let s of i.content.querySelectorAll("a[href]"))s.setAttribute("target","_blank"),s.setAttribute("rel","noopener noreferrer");return i.innerHTML.trim()}function ed(t){let e=document.createElement("div");e.className="resize-handle",e.setAttribute("part","resize-handle"),e.setAttribute("role","separator"),e.setAttribute("aria-label",t.label),e.tabIndex=0;let n=(r,o,i,s,a)=>{let l=o.x==="right"?i.right-s:s-i.left,c={width:Math.max(280,l)};if(r!=="both")return c;let h=o.y==="bottom"?i.bottom-a:a-i.top;return{...c,height:Math.max(240,h)}};return e.addEventListener("pointerdown",r=>{let o=t.axis();if(o==="none")return;let i=t.anchor(),s=t.rect(),a=c=>{t.apply(n(o,i,s,c.clientX,c.clientY))},l=c=>{window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",l),e.removeAttribute("data-dragging"),t.commit(n(o,i,s,c.clientX,c.clientY))};e.setAttribute("data-dragging","true"),window.addEventListener("pointermove",a),window.addEventListener("pointerup",l),r.preventDefault()}),e.addEventListener("keydown",r=>{let o=t.axis();if(o==="none")return;let i=t.anchor(),s=t.rect(),a=r.shiftKey?64:16,l=i.x==="right"?-1:1,c=s.right-s.left,h=s.bottom-s.top,m=null;if(r.key==="ArrowLeft")m={width:Math.max(280,c-a*l)};else if(r.key==="ArrowRight")m={width:Math.max(280,c+a*l)};else if(o==="both"&&(r.key==="ArrowUp"||r.key==="ArrowDown")){let y=r.key===(i.y==="bottom"?"ArrowUp":"ArrowDown");m={height:Math.max(240,h+(y?a:-a))}}m!==null&&(r.preventDefault(),t.apply(m),t.commit(m))}),e}function td(t,e){for(let n of Array.from(t.childNodes))n.nodeType===Node.TEXT_NODE?e.push({node:n,parent:t}):td(n,e)}function nd(t){let e=[];td(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 rd(t,e,n){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 o=document.createElement("span");o.className="run-notice-icon",o.setAttribute("part","run-notice-icon"),o.textContent=t,o.setAttribute("aria-hidden","true");let i=document.createElement("span");return i.className="run-notice-text",i.setAttribute("part","run-notice-text"),i.textContent=e,r.append(o,i),r}var xi=class{chips;palette;#n;#e=[];#t=!1;#s=!1;#r=[];#a=0;constructor(e){this.#n=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.#e=e,this.#c()}enableChips(e){this.#t=e,this.#c()}enableSlash(e){this.#s=e}isOpen(){return!this.palette.hidden}onInput(e){this.#s&&e.startsWith("/")?this.#i(e.slice(1)):this.close()}onKeydown(e){return this.isOpen()?e.key==="ArrowDown"?(this.#o(1),!0):e.key==="ArrowUp"?(this.#o(-1),!0):e.key==="Escape"?(this.close(),!0):e.key==="Enter"?(this.#r.slice(this.#a,this.#a+1).forEach(n=>{this.#l(n)}),!0):!1:!1}close(){this.palette.hidden=!0,this.palette.replaceChildren()}#i(e){let n=e.trim().toLowerCase(),r=this.#e.filter(o=>o.name.toLowerCase().includes(n)||o.title.toLowerCase().includes(n));if(r.length===0){this.close();return}this.#r=r,this.#a=0,this.#d(),this.palette.hidden=!1}#o(e){let n=this.#r.length;this.#a=(this.#a+e+n)%n,this.#d()}#l(e){this.close(),this.#n(e)}#c(){this.chips.replaceChildren();let e=this.#t?this.#e.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.#l(n)),this.chips.appendChild(r)}}#d(){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.#a?"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.#l(e)),this.palette.appendChild(r)})}};var od=`
|
|
78
|
+
/* \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
|
|
79
|
+
Every public --ag-ui-* token is read here into a private --_* alias, and
|
|
80
|
+
only the alias is used by the rules below.
|
|
81
|
+
|
|
82
|
+
The indirection is what makes ancestor theming work. Declaring the public
|
|
83
|
+
name on :host would set it *on the host element*, and a value on an element
|
|
84
|
+
always beats one inherited from an ancestor \u2014 so a page that put the tokens
|
|
85
|
+
on a wrapper would see no effect at all, which is the one thing the API is
|
|
86
|
+
documented to support. Reading the public name with the default as a var()
|
|
87
|
+
fallback leaves it undeclared on the element, so an ancestor's value is
|
|
88
|
+
inherited normally while a value aimed at the element still wins over it.
|
|
89
|
+
|
|
90
|
+
Two invariants hold this together:
|
|
91
|
+
1. No rule outside this file's :host blocks may reference a public name
|
|
92
|
+
directly. A public name read outside these blocks resolves to nothing and
|
|
93
|
+
silently drops its declaration rather than erroring, so the miss shows up
|
|
94
|
+
as a missing colour, not a failure.
|
|
95
|
+
2. Every --_* alias in use is declared here. Aliases inherit like any custom
|
|
96
|
+
property, so an undeclared one would pick up a same-named property from
|
|
97
|
+
the host page; declaring it on :host shields the shadow tree from that. */
|
|
78
98
|
:host {
|
|
79
99
|
/* Colors */
|
|
80
|
-
--ag-ui-bg
|
|
81
|
-
--ag-ui-fg
|
|
82
|
-
--ag-ui-accent
|
|
83
|
-
--ag-ui-user-bg
|
|
84
|
-
--ag-ui-user-fg
|
|
85
|
-
--ag-ui-assistant-bg
|
|
86
|
-
--ag-ui-hover
|
|
87
|
-
--
|
|
88
|
-
--
|
|
89
|
-
--ag-ui-tool-fg
|
|
90
|
-
--ag-ui-header-bg
|
|
91
|
-
--ag-ui-header-fg
|
|
92
|
-
--ag-ui-border
|
|
93
|
-
--ag-ui-radius
|
|
100
|
+
--_bg: var(--ag-ui-bg, #ffffff);
|
|
101
|
+
--_fg: var(--ag-ui-fg, #1a1a2e);
|
|
102
|
+
--_accent: var(--ag-ui-accent, #4f46e5);
|
|
103
|
+
--_user-bg: var(--ag-ui-user-bg, #4f46e5);
|
|
104
|
+
--_user-fg: var(--ag-ui-user-fg, #ffffff);
|
|
105
|
+
--_assistant-bg: var(--ag-ui-assistant-bg, #f1f1f6);
|
|
106
|
+
--_hover: var(--ag-ui-hover, #e7e7ee);
|
|
107
|
+
--_input-bg: var(--ag-ui-input-bg, var(--_bg));
|
|
108
|
+
--_tool-bg: var(--ag-ui-tool-bg, var(--_assistant-bg));
|
|
109
|
+
--_tool-fg: var(--ag-ui-tool-fg, var(--_accent));
|
|
110
|
+
--_header-bg: var(--ag-ui-header-bg, var(--_accent));
|
|
111
|
+
--_header-fg: var(--ag-ui-header-fg, #ffffff);
|
|
112
|
+
--_border: var(--ag-ui-border, #e2e2ec);
|
|
113
|
+
--_radius: var(--ag-ui-radius, 12px);
|
|
114
|
+
|
|
115
|
+
/* Body text and raised chrome. Both are referenced by the code-block copy
|
|
116
|
+
button; neither had a default before, so the declarations reading them
|
|
117
|
+
were dropped and the button fell back to the inherited colour over a
|
|
118
|
+
transparent box. The defaults below restate exactly that, so this is a
|
|
119
|
+
rename with no repaint \u2014 see the note on .code-copy. */
|
|
120
|
+
--_text: var(--ag-ui-text, var(--_fg));
|
|
121
|
+
--_surface: var(--ag-ui-surface, transparent);
|
|
94
122
|
|
|
95
123
|
/* Status accents for tool-call cards. */
|
|
96
|
-
--ag-ui-success
|
|
97
|
-
--ag-ui-danger
|
|
98
|
-
--ag-ui-muted
|
|
124
|
+
--_success: var(--ag-ui-success, #15803d);
|
|
125
|
+
--_danger: var(--ag-ui-danger, #b91c1c);
|
|
126
|
+
--_muted: var(--ag-ui-muted, #6b7280);
|
|
99
127
|
|
|
100
128
|
/* Tool-call status icon glyphs (override to re-theme) + spinner speed.
|
|
101
129
|
The pending state is the animated ring; the settled states use these. */
|
|
102
|
-
--ag-ui-tool-icon-done
|
|
103
|
-
--ag-ui-tool-icon-error
|
|
104
|
-
--ag-ui-tool-icon-declined
|
|
105
|
-
--ag-ui-tool-spin-duration
|
|
130
|
+
--_tool-icon-done: var(--ag-ui-tool-icon-done, "\u2713");
|
|
131
|
+
--_tool-icon-error: var(--ag-ui-tool-icon-error, "\u2715");
|
|
132
|
+
--_tool-icon-declined: var(--ag-ui-tool-icon-declined, "\u2298");
|
|
133
|
+
--_tool-spin-duration: var(--ag-ui-tool-spin-duration, 0.7s);
|
|
106
134
|
|
|
107
135
|
/* Answer well (opt-in via data-answer-well) \u2014 boxes a whole assistant turn. */
|
|
108
|
-
--ag-ui-well-bg
|
|
109
|
-
--
|
|
136
|
+
--_well-bg: var(--ag-ui-well-bg, transparent);
|
|
137
|
+
--_well-border: var(--ag-ui-well-border, var(--_border));
|
|
110
138
|
|
|
111
139
|
/* Surface \u2014 set --ag-ui-shadow: none for a flush, embedded panel. */
|
|
112
|
-
--ag-ui-shadow
|
|
113
|
-
--ag-ui-font
|
|
114
|
-
--ag-ui-font-size
|
|
115
|
-
--ag-ui-code-font
|
|
140
|
+
--_shadow: var(--ag-ui-shadow, 0 12px 32px rgba(20, 20, 50, 0.18));
|
|
141
|
+
--_font: var(--ag-ui-font, inherit);
|
|
142
|
+
--_font-size: var(--ag-ui-font-size, 14px);
|
|
143
|
+
--_code-font: var(--ag-ui-code-font, ui-monospace, "SF Mono", Menlo, monospace);
|
|
144
|
+
|
|
145
|
+
/* Header / launcher icon box. */
|
|
146
|
+
--_icon-size: var(--ag-ui-icon-size, 22px);
|
|
147
|
+
--_icon-radius: var(--ag-ui-icon-radius, 4px);
|
|
148
|
+
|
|
149
|
+
/* Composer \u2014 one bordered surface holding the field and its tool row. */
|
|
150
|
+
--_composer-radius: var(--ag-ui-composer-radius, 14px);
|
|
151
|
+
--_composer-max-height: var(--ag-ui-composer-max-height, 40vh);
|
|
152
|
+
--_tool-btn-size: var(--ag-ui-tool-btn-size, 30px);
|
|
153
|
+
--_send-size: var(--ag-ui-send-size, 30px);
|
|
154
|
+
--_glyph-size: var(--ag-ui-glyph-size, 18px);
|
|
155
|
+
--_glyph-stroke: var(--ag-ui-glyph-stroke, 1.75);
|
|
156
|
+
|
|
157
|
+
/* Unread badge on the launcher. */
|
|
158
|
+
--_badge-bg: var(--ag-ui-badge-bg, var(--_danger));
|
|
159
|
+
--_badge-fg: var(--ag-ui-badge-fg, #ffffff);
|
|
160
|
+
--_badge-size: var(--ag-ui-badge-size, 18px);
|
|
161
|
+
--_badge-font-size: var(--ag-ui-badge-font-size, 11px);
|
|
162
|
+
|
|
163
|
+
/* The floating launcher a collapsed widget shrinks to. */
|
|
164
|
+
--_launcher-size: var(--ag-ui-launcher-size, 56px);
|
|
165
|
+
--_launcher-bg: var(--ag-ui-launcher-bg, var(--_header-bg));
|
|
166
|
+
--_launcher-fg: var(--ag-ui-launcher-fg, var(--_header-fg));
|
|
167
|
+
--_launcher-radius: var(--ag-ui-launcher-radius, 50%);
|
|
168
|
+
--_launcher-icon-size: var(--ag-ui-launcher-icon-size, 26px);
|
|
169
|
+
--_launcher-inset: var(--ag-ui-launcher-inset, auto 0 0 auto);
|
|
170
|
+
|
|
171
|
+
/* Motion. One duration and two curves drive every collapse, expand and
|
|
172
|
+
slide-over, so the whole widget accelerates and settles as one thing.
|
|
173
|
+
The default curve is a long-tailed ease-out (a fast start that decelerates
|
|
174
|
+
into place); the pop curve overshoots slightly, for something arriving. */
|
|
175
|
+
--_motion: var(--ag-ui-motion, 0.28s);
|
|
176
|
+
--_ease: var(--ag-ui-ease, cubic-bezier(0.32, 0.72, 0, 1));
|
|
177
|
+
--_ease-pop: var(--ag-ui-ease-pop, cubic-bezier(0.34, 1.36, 0.64, 1));
|
|
116
178
|
|
|
117
179
|
/* Spacing \u2014 the density preset overrides these. */
|
|
118
|
-
--ag-ui-space
|
|
119
|
-
--ag-ui-pad
|
|
120
|
-
--ag-ui-msg-pad
|
|
121
|
-
--ag-ui-msg-radius
|
|
180
|
+
--_space: var(--ag-ui-space, 10px);
|
|
181
|
+
--_pad: var(--ag-ui-pad, 16px);
|
|
182
|
+
--_msg-pad: var(--ag-ui-msg-pad, 8px 12px);
|
|
183
|
+
--_msg-radius: var(--ag-ui-msg-radius, 14px);
|
|
122
184
|
|
|
123
185
|
/* Layout \u2014 override from outside to dock the widget anywhere.
|
|
124
186
|
Set --ag-ui-position: static (and place this element in your own
|
|
125
187
|
grid/flex layout) to embed it in the page flow instead of floating. */
|
|
126
|
-
--ag-ui-position
|
|
127
|
-
--ag-ui-z-index
|
|
128
|
-
--ag-ui-width
|
|
129
|
-
--ag-ui-height
|
|
130
|
-
--ag-ui-inset
|
|
131
|
-
--ag-ui-max-width
|
|
132
|
-
--ag-ui-max-height
|
|
188
|
+
--_position: var(--ag-ui-position, fixed);
|
|
189
|
+
--_z-index: var(--ag-ui-z-index, 2147483000);
|
|
190
|
+
--_width: var(--ag-ui-width, 380px);
|
|
191
|
+
--_height: var(--ag-ui-height, 560px);
|
|
192
|
+
--_inset: var(--ag-ui-inset, auto 24px 24px auto);
|
|
193
|
+
--_max-width: var(--ag-ui-max-width, calc(100vw - 48px));
|
|
194
|
+
--_max-height: var(--ag-ui-max-height, calc(100vh - 48px));
|
|
133
195
|
/* Reading-column width for placement="page" (full-bleed, centred content). */
|
|
134
|
-
--ag-ui-content-max-width
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
196
|
+
--_content-max-width: var(--ag-ui-content-max-width, 820px);
|
|
197
|
+
/* Slim rail the sidebar placement collapses to. Only that placement reads
|
|
198
|
+
it, but it is declared here so invariant 2 holds for every alias. */
|
|
199
|
+
--_rail-width: var(--ag-ui-rail-width, 52px);
|
|
200
|
+
|
|
201
|
+
position: var(--_position);
|
|
202
|
+
inset: var(--_inset);
|
|
203
|
+
z-index: var(--_z-index);
|
|
204
|
+
width: var(--_width);
|
|
205
|
+
max-width: var(--_max-width);
|
|
206
|
+
height: var(--_height);
|
|
207
|
+
max-height: var(--_max-height);
|
|
143
208
|
display: flex;
|
|
144
|
-
font-family: var(--
|
|
145
|
-
font-size: var(--
|
|
146
|
-
color: var(--
|
|
209
|
+
font-family: var(--_font);
|
|
210
|
+
font-size: var(--_font-size);
|
|
211
|
+
color: var(--_fg);
|
|
147
212
|
}
|
|
148
213
|
|
|
149
214
|
/* \u2500\u2500 Themes \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\u2500\u2500\u2500\u2500
|
|
150
215
|
Themes only re-set the colour variables; layout/spacing are unaffected.
|
|
151
216
|
theme="auto" follows the OS via prefers-color-scheme. */
|
|
152
217
|
:host([theme="dark"]) {
|
|
153
|
-
--ag-ui-bg
|
|
154
|
-
--ag-ui-fg
|
|
155
|
-
--ag-ui-assistant-bg
|
|
156
|
-
--ag-ui-hover
|
|
157
|
-
--ag-ui-header-bg
|
|
158
|
-
--ag-ui-header-fg
|
|
159
|
-
--ag-ui-border
|
|
160
|
-
--ag-ui-muted
|
|
161
|
-
--ag-ui-shadow
|
|
218
|
+
--_bg: var(--ag-ui-bg, #15151f);
|
|
219
|
+
--_fg: var(--ag-ui-fg, #e8e8f2);
|
|
220
|
+
--_assistant-bg: var(--ag-ui-assistant-bg, #25253a);
|
|
221
|
+
--_hover: var(--ag-ui-hover, #303049);
|
|
222
|
+
--_header-bg: var(--ag-ui-header-bg, #1f1f30);
|
|
223
|
+
--_header-fg: var(--ag-ui-header-fg, #e8e8f2);
|
|
224
|
+
--_border: var(--ag-ui-border, #33334a);
|
|
225
|
+
--_muted: var(--ag-ui-muted, #9aa0b4);
|
|
226
|
+
--_shadow: var(--ag-ui-shadow, 0 12px 32px rgba(0, 0, 0, 0.5));
|
|
162
227
|
}
|
|
163
228
|
|
|
164
229
|
@media (prefers-color-scheme: dark) {
|
|
165
230
|
:host([theme="auto"]) {
|
|
166
|
-
--ag-ui-bg
|
|
167
|
-
--ag-ui-fg
|
|
168
|
-
--ag-ui-assistant-bg
|
|
169
|
-
--ag-ui-hover
|
|
170
|
-
--ag-ui-header-bg
|
|
171
|
-
--ag-ui-header-fg
|
|
172
|
-
--ag-ui-border
|
|
173
|
-
--ag-ui-muted
|
|
174
|
-
--ag-ui-shadow
|
|
231
|
+
--_bg: var(--ag-ui-bg, #15151f);
|
|
232
|
+
--_fg: var(--ag-ui-fg, #e8e8f2);
|
|
233
|
+
--_assistant-bg: var(--ag-ui-assistant-bg, #25253a);
|
|
234
|
+
--_hover: var(--ag-ui-hover, #303049);
|
|
235
|
+
--_header-bg: var(--ag-ui-header-bg, #1f1f30);
|
|
236
|
+
--_header-fg: var(--ag-ui-header-fg, #e8e8f2);
|
|
237
|
+
--_border: var(--ag-ui-border, #33334a);
|
|
238
|
+
--_muted: var(--ag-ui-muted, #9aa0b4);
|
|
239
|
+
--_shadow: var(--ag-ui-shadow, 0 12px 32px rgba(0, 0, 0, 0.5));
|
|
175
240
|
}
|
|
176
241
|
}
|
|
177
242
|
|
|
178
243
|
/* A terminal-flavoured "code" theme: dark, monospace, green accent. */
|
|
179
244
|
:host([theme="code"]) {
|
|
180
|
-
--ag-ui-bg
|
|
181
|
-
--ag-ui-fg
|
|
182
|
-
--ag-ui-accent
|
|
183
|
-
--ag-ui-user-bg
|
|
184
|
-
--ag-ui-assistant-bg
|
|
185
|
-
--ag-ui-hover
|
|
186
|
-
--ag-ui-header-bg
|
|
187
|
-
--ag-ui-header-fg
|
|
188
|
-
--ag-ui-border
|
|
189
|
-
--ag-ui-muted
|
|
190
|
-
--ag-ui-font
|
|
191
|
-
--ag-ui-shadow
|
|
245
|
+
--_bg: var(--ag-ui-bg, #0d1117);
|
|
246
|
+
--_fg: var(--ag-ui-fg, #c9d1d9);
|
|
247
|
+
--_accent: var(--ag-ui-accent, #3fb950);
|
|
248
|
+
--_user-bg: var(--ag-ui-user-bg, #238636);
|
|
249
|
+
--_assistant-bg: var(--ag-ui-assistant-bg, #161b22);
|
|
250
|
+
--_hover: var(--ag-ui-hover, #21262d);
|
|
251
|
+
--_header-bg: var(--ag-ui-header-bg, #010409);
|
|
252
|
+
--_header-fg: var(--ag-ui-header-fg, #c9d1d9);
|
|
253
|
+
--_border: var(--ag-ui-border, #30363d);
|
|
254
|
+
--_muted: var(--ag-ui-muted, #8b949e);
|
|
255
|
+
--_font: var(--ag-ui-font, var(--_code-font));
|
|
256
|
+
--_shadow: var(--ag-ui-shadow, 0 12px 32px rgba(0, 0, 0, 0.6));
|
|
192
257
|
}
|
|
193
258
|
|
|
194
259
|
/* \u2500\u2500 Density \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\u2500\u2500\u2500\u2500\u2500 */
|
|
195
260
|
:host([density="compact"]) {
|
|
196
|
-
--ag-ui-font-size
|
|
197
|
-
--ag-ui-space
|
|
198
|
-
--ag-ui-pad
|
|
199
|
-
--ag-ui-msg-pad
|
|
200
|
-
--ag-ui-msg-radius
|
|
261
|
+
--_font-size: var(--ag-ui-font-size, 13px);
|
|
262
|
+
--_space: var(--ag-ui-space, 6px);
|
|
263
|
+
--_pad: var(--ag-ui-pad, 10px);
|
|
264
|
+
--_msg-pad: var(--ag-ui-msg-pad, 5px 9px);
|
|
265
|
+
--_msg-radius: var(--ag-ui-msg-radius, 10px);
|
|
201
266
|
}
|
|
202
267
|
|
|
203
268
|
/* \u2500\u2500 Placement presets \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 */
|
|
204
269
|
:host([placement="bottom-left"]) {
|
|
205
|
-
--ag-ui-inset
|
|
270
|
+
--_inset: var(--ag-ui-inset, auto auto 24px 24px);
|
|
206
271
|
}
|
|
207
272
|
|
|
208
273
|
:host([placement="side"]) {
|
|
209
|
-
--ag-ui-inset
|
|
210
|
-
--ag-ui-width
|
|
211
|
-
--ag-ui-height
|
|
212
|
-
--ag-ui-max-height
|
|
213
|
-
--ag-ui-radius
|
|
274
|
+
--_inset: var(--ag-ui-inset, 0 0 0 auto);
|
|
275
|
+
--_width: var(--ag-ui-width, 420px);
|
|
276
|
+
--_height: var(--ag-ui-height, 100vh);
|
|
277
|
+
--_max-height: var(--ag-ui-max-height, 100vh);
|
|
278
|
+
--_radius: var(--ag-ui-radius, 0);
|
|
214
279
|
}
|
|
215
280
|
|
|
216
281
|
:host([placement="full"]) {
|
|
217
|
-
--ag-ui-inset
|
|
218
|
-
--ag-ui-width
|
|
219
|
-
--ag-ui-height
|
|
220
|
-
--ag-ui-max-width
|
|
221
|
-
--ag-ui-max-height
|
|
222
|
-
--ag-ui-radius
|
|
282
|
+
--_inset: var(--ag-ui-inset, 0);
|
|
283
|
+
--_width: var(--ag-ui-width, 100vw);
|
|
284
|
+
--_height: var(--ag-ui-height, 100vh);
|
|
285
|
+
--_max-width: var(--ag-ui-max-width, 100vw);
|
|
286
|
+
--_max-height: var(--ag-ui-max-height, 100vh);
|
|
287
|
+
--_radius: var(--ag-ui-radius, 0);
|
|
223
288
|
}
|
|
224
289
|
|
|
225
290
|
/* Page: full-bleed background with a centred reading column. Unlike
|
|
@@ -228,85 +293,20 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
228
293
|
padding on the scroll area + composer (no per-row wrapper), so user pills
|
|
229
294
|
still right-align and the assistant well spans the column. */
|
|
230
295
|
:host([placement="page"]) {
|
|
231
|
-
--ag-ui-inset
|
|
232
|
-
--ag-ui-width
|
|
233
|
-
--ag-ui-height
|
|
234
|
-
--ag-ui-max-width
|
|
235
|
-
--ag-ui-max-height
|
|
236
|
-
--ag-ui-radius
|
|
296
|
+
--_inset: var(--ag-ui-inset, 0);
|
|
297
|
+
--_width: var(--ag-ui-width, 100vw);
|
|
298
|
+
--_height: var(--ag-ui-height, 100vh);
|
|
299
|
+
--_max-width: var(--ag-ui-max-width, 100vw);
|
|
300
|
+
--_max-height: var(--ag-ui-max-height, 100vh);
|
|
301
|
+
--_radius: var(--ag-ui-radius, 0);
|
|
237
302
|
}
|
|
238
303
|
|
|
239
304
|
:host([placement="page"]) .messages {
|
|
240
|
-
padding-inline: max(var(--
|
|
305
|
+
padding-inline: max(var(--_pad), calc((100% - var(--_content-max-width)) / 2));
|
|
241
306
|
}
|
|
242
307
|
|
|
243
|
-
:host([placement="page"])
|
|
244
|
-
|
|
245
|
-
nothing to drag. */
|
|
246
|
-
.resize-handle {
|
|
247
|
-
position: absolute;
|
|
248
|
-
z-index: 2;
|
|
249
|
-
background: transparent;
|
|
250
|
-
touch-action: none;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
.resize-handle:focus-visible {
|
|
254
|
-
outline: 2px solid var(--ag-ui-accent);
|
|
255
|
-
outline-offset: -2px;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/* The grip sits at the corner the panel grows toward. Which corner that is
|
|
259
|
-
depends on the host's layout, not on placement, so the element measures it
|
|
260
|
-
and stamps data-resize-anchor with the edges that stay put.
|
|
261
|
-
|
|
262
|
-
Default (bottom-right pinned, the floating case) puts the grip top-left. */
|
|
263
|
-
.resize-handle {
|
|
264
|
-
top: 0;
|
|
265
|
-
left: 0;
|
|
266
|
-
width: 14px;
|
|
267
|
-
height: 14px;
|
|
268
|
-
cursor: nwse-resize;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
:host([data-resize-anchor~="left"]) .resize-handle {
|
|
272
|
-
left: auto;
|
|
273
|
-
right: 0;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
:host([data-resize-anchor~="top"]) .resize-handle {
|
|
277
|
-
top: auto;
|
|
278
|
-
bottom: 0;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/* One axis flipped means the drag runs along the other diagonal. */
|
|
282
|
-
:host([data-resize-anchor="top-right"]) .resize-handle,
|
|
283
|
-
:host([data-resize-anchor="bottom-left"]) .resize-handle {
|
|
284
|
-
cursor: nesw-resize;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
/* Docked: the placement owns the height, so only the inner edge is the user's. */
|
|
288
|
-
:host([placement="sidebar"]) .resize-handle,
|
|
289
|
-
:host([placement="side"]) .resize-handle {
|
|
290
|
-
top: 0;
|
|
291
|
-
bottom: auto;
|
|
292
|
-
width: 8px;
|
|
293
|
-
height: 100%;
|
|
294
|
-
cursor: ew-resize;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
/* Full-bleed: nothing to drag. */
|
|
298
|
-
:host([placement="full"]) .resize-handle,
|
|
299
|
-
:host([placement="page"]) .resize-handle {
|
|
300
|
-
display: none;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
.resize-handle[data-dragging] {
|
|
304
|
-
background: var(--ag-ui-accent);
|
|
305
|
-
opacity: 0.35;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
.input-row {
|
|
309
|
-
padding-inline: max(12px, calc((100% - var(--ag-ui-content-max-width)) / 2));
|
|
308
|
+
:host([placement="page"]) .input-row {
|
|
309
|
+
padding-inline: max(12px, calc((100% - var(--_content-max-width)) / 2));
|
|
310
310
|
}
|
|
311
311
|
|
|
312
312
|
/* The rows between the message list and the composer (skill chips, the
|
|
@@ -315,12 +315,12 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
315
315
|
margin-based, so each gets its own inline axis nudged by the same gutter. */
|
|
316
316
|
:host([placement="page"]) .skill-chips,
|
|
317
317
|
:host([placement="page"]) .attachment-tray {
|
|
318
|
-
padding-inline: max(12px, calc((100% - var(--
|
|
318
|
+
padding-inline: max(12px, calc((100% - var(--_content-max-width)) / 2));
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
:host([placement="page"]) .skill-palette,
|
|
322
322
|
:host([placement="page"]) .skill-hint {
|
|
323
|
-
margin-inline: max(12px, calc((100% - var(--
|
|
323
|
+
margin-inline: max(12px, calc((100% - var(--_content-max-width)) / 2));
|
|
324
324
|
}
|
|
325
325
|
|
|
326
326
|
/* In the reading column the assistant well uses the full width; the user
|
|
@@ -335,75 +335,179 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
335
335
|
--ag-ui-position: static (and place this element in your own layout) for a
|
|
336
336
|
host-managed push instead. */
|
|
337
337
|
:host([placement="sidebar"]) {
|
|
338
|
-
--ag-ui-inset
|
|
339
|
-
--ag-ui-width
|
|
340
|
-
--ag-ui-height
|
|
341
|
-
--ag-ui-max-height
|
|
342
|
-
--ag-ui-radius
|
|
343
|
-
|
|
344
|
-
transition: width 0.28s ease;
|
|
338
|
+
--_inset: var(--ag-ui-inset, 0 0 0 auto);
|
|
339
|
+
--_width: var(--ag-ui-width, 420px);
|
|
340
|
+
--_height: var(--ag-ui-height, 100vh);
|
|
341
|
+
--_max-height: var(--ag-ui-max-height, 100vh);
|
|
342
|
+
--_radius: var(--ag-ui-radius, 0);
|
|
343
|
+
transition: width var(--_motion) var(--_ease);
|
|
345
344
|
}
|
|
346
345
|
|
|
347
346
|
:host([placement="sidebar"][data-side="left"]) {
|
|
348
|
-
--ag-ui-inset
|
|
347
|
+
--_inset: var(--ag-ui-inset, 0 auto 0 0);
|
|
349
348
|
}
|
|
350
349
|
|
|
350
|
+
/* The docked panel is pinned to the edge it docks against rather than filling
|
|
351
|
+
the host as a flex child. Collapsing shrinks the host to the rail width, and
|
|
352
|
+
a flex child would be squashed to 52px on the way out instead of sliding out
|
|
353
|
+
at full width. */
|
|
351
354
|
:host([placement="sidebar"]) .chat {
|
|
352
|
-
|
|
355
|
+
position: absolute;
|
|
356
|
+
inset: 0 0 0 auto;
|
|
357
|
+
width: var(--_width);
|
|
358
|
+
transform-origin: right center;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
:host([placement="sidebar"][data-side="left"]) .chat {
|
|
362
|
+
inset: 0 auto 0 0;
|
|
363
|
+
transform-origin: left center;
|
|
353
364
|
}
|
|
354
365
|
|
|
355
|
-
/* Collapsed sidebar: shrink the host to the rail width
|
|
356
|
-
|
|
357
|
-
wins regardless of source order. */
|
|
366
|
+
/* Collapsed sidebar: shrink the host to the rail width and slide the panel out
|
|
367
|
+
through the edge it docks against. Higher specificity than the generic
|
|
368
|
+
collapse rules, so it wins regardless of source order. */
|
|
358
369
|
:host([placement="sidebar"][collapsed]) {
|
|
359
|
-
width: var(--
|
|
370
|
+
width: var(--_rail-width);
|
|
360
371
|
height: 100vh;
|
|
361
372
|
max-height: 100vh;
|
|
362
373
|
bottom: 0;
|
|
374
|
+
pointer-events: auto;
|
|
363
375
|
}
|
|
364
376
|
|
|
365
377
|
:host([placement="sidebar"][collapsed]) .chat {
|
|
366
|
-
|
|
378
|
+
transform: translateX(100%);
|
|
367
379
|
}
|
|
368
380
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
381
|
+
:host([placement="sidebar"][data-side="left"][collapsed]) .chat {
|
|
382
|
+
transform: translateX(-100%);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
@media (prefers-reduced-motion: reduce) {
|
|
386
|
+
:host([placement="sidebar"]),
|
|
387
|
+
:host([placement="sidebar"]) .chat {
|
|
388
|
+
transition: none;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/* \u2500\u2500 Launcher \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\u2500\u2500\u2500\u2500\u2500\u2500
|
|
393
|
+
What a collapsed widget shrinks to: a round floating button by default, the
|
|
394
|
+
sidebar's slim edge rail under that placement. A sibling of the panel, so it
|
|
395
|
+
survives the panel being hidden, and the only part of a collapsed widget
|
|
396
|
+
that takes pointer events. */
|
|
397
|
+
.launcher {
|
|
398
|
+
display: flex;
|
|
399
|
+
position: absolute;
|
|
400
|
+
inset: var(--_launcher-inset);
|
|
401
|
+
align-items: center;
|
|
402
|
+
justify-content: center;
|
|
403
|
+
width: var(--_launcher-size);
|
|
404
|
+
height: var(--_launcher-size);
|
|
405
|
+
padding: 0;
|
|
373
406
|
border: none;
|
|
407
|
+
border-radius: var(--_launcher-radius);
|
|
408
|
+
background: var(--_launcher-bg);
|
|
409
|
+
color: var(--_launcher-fg);
|
|
410
|
+
box-shadow: var(--_shadow);
|
|
374
411
|
font: inherit;
|
|
412
|
+
cursor: pointer;
|
|
413
|
+
pointer-events: auto;
|
|
414
|
+
opacity: 0;
|
|
415
|
+
transform: scale(0.4);
|
|
416
|
+
visibility: hidden;
|
|
417
|
+
transition:
|
|
418
|
+
opacity var(--_motion) var(--_ease),
|
|
419
|
+
transform var(--_motion) var(--_ease-pop),
|
|
420
|
+
visibility var(--_motion) var(--_ease);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/* The launcher grows out of the corner the panel shrank into.
|
|
424
|
+
It is laid out at rest rather than display:none, which is what lets it
|
|
425
|
+
animate in *and* out: an element that was not rendered has no before-change
|
|
426
|
+
style to transition from, and one whose display flips to none cannot
|
|
427
|
+
transition at all. visibility keeps it unpaintable, untabbable and
|
|
428
|
+
unclickable in between -- the expanded panel's own controls sit under it and
|
|
429
|
+
must stay reachable. */
|
|
430
|
+
:host([collapsed]) .launcher {
|
|
431
|
+
opacity: 1;
|
|
432
|
+
transform: none;
|
|
433
|
+
visibility: visible;
|
|
375
434
|
}
|
|
376
435
|
|
|
377
|
-
:host([
|
|
378
|
-
|
|
436
|
+
:host([collapsed]) .launcher:hover {
|
|
437
|
+
transform: scale(1.06);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
:host([collapsed]) .launcher:active {
|
|
441
|
+
transform: scale(0.94);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
.launcher .icon-holder {
|
|
445
|
+
width: var(--_launcher-icon-size);
|
|
446
|
+
height: var(--_launcher-icon-size);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/* The unread badge rides the launcher's top-right corner. The ring in the
|
|
450
|
+
widget's own background is what separates it from the launcher underneath,
|
|
451
|
+
whatever colour the host themes either one. */
|
|
452
|
+
.launcher-badge {
|
|
379
453
|
position: absolute;
|
|
454
|
+
top: -2px;
|
|
455
|
+
right: -2px;
|
|
456
|
+
display: inline-flex;
|
|
457
|
+
align-items: center;
|
|
458
|
+
justify-content: center;
|
|
459
|
+
box-sizing: border-box;
|
|
460
|
+
min-width: var(--_badge-size);
|
|
461
|
+
height: var(--_badge-size);
|
|
462
|
+
padding: 0 5px;
|
|
463
|
+
border-radius: 999px;
|
|
464
|
+
background: var(--_badge-bg);
|
|
465
|
+
color: var(--_badge-fg);
|
|
466
|
+
font-size: var(--_badge-font-size);
|
|
467
|
+
font-weight: 600;
|
|
468
|
+
line-height: 1;
|
|
469
|
+
box-shadow: 0 0 0 2px var(--_bg);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
.launcher-badge[hidden] {
|
|
473
|
+
display: none;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/* The sidebar collapses to an edge rail instead: full height, square, flush
|
|
477
|
+
against the dock. It slides in with the panel rather than popping. */
|
|
478
|
+
:host([placement="sidebar"][collapsed]) .launcher {
|
|
380
479
|
inset: 0;
|
|
480
|
+
width: auto;
|
|
481
|
+
height: auto;
|
|
381
482
|
align-items: flex-start;
|
|
382
|
-
justify-content: center;
|
|
383
483
|
padding-top: 16px;
|
|
384
|
-
border: 1px solid var(--
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
484
|
+
border: 1px solid var(--_border);
|
|
485
|
+
border-radius: 0;
|
|
486
|
+
background: var(--_header-bg);
|
|
487
|
+
color: var(--_header-fg);
|
|
488
|
+
box-shadow: none;
|
|
489
|
+
transform: none;
|
|
388
490
|
}
|
|
389
491
|
|
|
492
|
+
/* Every transition in this file is timed by --_motion, so collapsing it to a
|
|
493
|
+
frame is the whole reduced-motion story: states still change (and display
|
|
494
|
+
still flips at the end of its discrete transition), nothing travels. */
|
|
390
495
|
@media (prefers-reduced-motion: reduce) {
|
|
391
|
-
:host
|
|
392
|
-
|
|
393
|
-
transition: none;
|
|
496
|
+
:host {
|
|
497
|
+
--_motion: var(--ag-ui-motion, 0.001s);
|
|
394
498
|
}
|
|
395
499
|
}
|
|
396
500
|
|
|
397
501
|
/* Embedded: drop the floating chrome and the high z-index stacking context so
|
|
398
502
|
the widget lives in the host's own layout (fixes overlay/z-index clashes). */
|
|
399
503
|
:host([placement="embedded"]) {
|
|
400
|
-
--ag-ui-position
|
|
401
|
-
--ag-ui-width
|
|
402
|
-
--ag-ui-height
|
|
403
|
-
--ag-ui-max-width
|
|
404
|
-
--ag-ui-max-height
|
|
405
|
-
--ag-ui-shadow
|
|
406
|
-
--ag-ui-z-index
|
|
504
|
+
--_position: var(--ag-ui-position, static);
|
|
505
|
+
--_width: var(--ag-ui-width, 100%);
|
|
506
|
+
--_height: var(--ag-ui-height, 100%);
|
|
507
|
+
--_max-width: var(--ag-ui-max-width, 100%);
|
|
508
|
+
--_max-height: var(--ag-ui-max-height, 100%);
|
|
509
|
+
--_shadow: var(--ag-ui-shadow, none);
|
|
510
|
+
--_z-index: var(--ag-ui-z-index, auto);
|
|
407
511
|
}
|
|
408
512
|
|
|
409
513
|
.chat {
|
|
@@ -412,10 +516,10 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
412
516
|
flex-direction: column;
|
|
413
517
|
flex: 1;
|
|
414
518
|
min-height: 0;
|
|
415
|
-
background: var(--
|
|
416
|
-
border: 1px solid var(--
|
|
417
|
-
border-radius: var(--
|
|
418
|
-
box-shadow: var(--
|
|
519
|
+
background: var(--_bg);
|
|
520
|
+
border: 1px solid var(--_border);
|
|
521
|
+
border-radius: var(--_radius);
|
|
522
|
+
box-shadow: var(--_shadow);
|
|
419
523
|
overflow: hidden;
|
|
420
524
|
}
|
|
421
525
|
|
|
@@ -425,9 +529,9 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
425
529
|
justify-content: space-between;
|
|
426
530
|
gap: 8px;
|
|
427
531
|
padding: 10px 14px;
|
|
428
|
-
border-bottom: 1px solid var(--
|
|
429
|
-
background: var(--
|
|
430
|
-
color: var(--
|
|
532
|
+
border-bottom: 1px solid var(--_border);
|
|
533
|
+
background: var(--_header-bg);
|
|
534
|
+
color: var(--_header-fg);
|
|
431
535
|
}
|
|
432
536
|
|
|
433
537
|
.header-title {
|
|
@@ -446,8 +550,8 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
446
550
|
align-items: center;
|
|
447
551
|
justify-content: center;
|
|
448
552
|
flex: none;
|
|
449
|
-
width: var(--
|
|
450
|
-
height: var(--
|
|
553
|
+
width: var(--_icon-size);
|
|
554
|
+
height: var(--_icon-size);
|
|
451
555
|
line-height: 1;
|
|
452
556
|
}
|
|
453
557
|
|
|
@@ -455,7 +559,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
455
559
|
width: 100%;
|
|
456
560
|
height: 100%;
|
|
457
561
|
object-fit: contain;
|
|
458
|
-
border-radius: var(--
|
|
562
|
+
border-radius: var(--_icon-radius);
|
|
459
563
|
}
|
|
460
564
|
|
|
461
565
|
.header-controls {
|
|
@@ -481,36 +585,87 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
481
585
|
background: rgba(255, 255, 255, 0.18);
|
|
482
586
|
}
|
|
483
587
|
|
|
484
|
-
/*
|
|
485
|
-
|
|
588
|
+
/* \u2500\u2500 Collapse \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\u2500\u2500\u2500\u2500\u2500\u2500
|
|
589
|
+
Collapsing shrinks the widget to the round floating launcher: the panel
|
|
590
|
+
scales down toward the launcher's corner and fades out, the launcher pops in
|
|
591
|
+
from that same point. Both halves are transform and opacity only, so the
|
|
592
|
+
morph runs on the compositor and never reflows the host page.
|
|
593
|
+
|
|
594
|
+
The host box keeps its expanded size. Animating it would animate layout, and
|
|
595
|
+
a dragged --ag-ui-width would then fight the launcher's own size. Nothing
|
|
596
|
+
paints there once the panel is gone, so the box only has to stop swallowing
|
|
597
|
+
clicks: pointer events go to none, and the launcher takes them back.
|
|
598
|
+
|
|
599
|
+
Two placements collapse to something else and restore what they need:
|
|
600
|
+
"sidebar" slides to its rail (below), while "embedded" and "page" keep the
|
|
601
|
+
original header bar \u2014 embedded is laid out by the host page, where a
|
|
602
|
+
floating circle would escape the layout, and page is a full-screen route
|
|
603
|
+
with no corner to float in. */
|
|
486
604
|
:host([collapsed]) {
|
|
605
|
+
pointer-events: none;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
:host([collapsed]) .chat {
|
|
609
|
+
opacity: 0;
|
|
610
|
+
transform: scale(0.94);
|
|
611
|
+
visibility: hidden;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/* visibility is what keeps the panel out of the tab order and the a11y tree at
|
|
615
|
+
rest without display:none killing the transition. It interpolates so that any
|
|
616
|
+
progress below 1 still counts as visible: the panel stays on screen for the
|
|
617
|
+
whole collapse and flips hidden exactly at the end, and on expand it is
|
|
618
|
+
visible from the first frame. */
|
|
619
|
+
.chat {
|
|
620
|
+
transform-origin: bottom right;
|
|
621
|
+
transition:
|
|
622
|
+
opacity var(--_motion) var(--_ease),
|
|
623
|
+
transform var(--_motion) var(--_ease),
|
|
624
|
+
visibility var(--_motion) var(--_ease);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
:host([placement="bottom-left"]) .chat {
|
|
628
|
+
transform-origin: bottom left;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/* The two in-flow placements keep the original collapse: hide the body, let
|
|
632
|
+
the host shrink to the header bar. */
|
|
633
|
+
:host([collapsed]:is([placement="embedded"], [placement="page"])) {
|
|
487
634
|
height: auto;
|
|
488
635
|
max-height: none;
|
|
636
|
+
pointer-events: auto;
|
|
489
637
|
}
|
|
490
638
|
|
|
491
|
-
:host([collapsed]) .
|
|
492
|
-
:
|
|
493
|
-
:
|
|
494
|
-
:
|
|
495
|
-
:host([collapsed]) .skill-hint {
|
|
496
|
-
display: none;
|
|
639
|
+
:host([collapsed]:is([placement="embedded"], [placement="page"])) .chat {
|
|
640
|
+
opacity: 1;
|
|
641
|
+
transform: none;
|
|
642
|
+
visibility: visible;
|
|
497
643
|
}
|
|
498
644
|
|
|
499
|
-
/*
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
:host([collapsed][placement="
|
|
504
|
-
|
|
645
|
+
/* These two keep the header bar, so the launcher must stay out of the way \u2014
|
|
646
|
+
an embedded host is position: static, which would otherwise leave an
|
|
647
|
+
absolutely-positioned circle to escape the layout entirely and land against
|
|
648
|
+
whatever the page happens to position. */
|
|
649
|
+
:host([collapsed]:is([placement="embedded"], [placement="page"])) .launcher {
|
|
650
|
+
visibility: hidden;
|
|
651
|
+
opacity: 0;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
:host([collapsed]:is([placement="embedded"], [placement="page"])) .messages,
|
|
655
|
+
:host([collapsed]:is([placement="embedded"], [placement="page"])) .input-row,
|
|
656
|
+
:host([collapsed]:is([placement="embedded"], [placement="page"])) .skill-chips,
|
|
657
|
+
:host([collapsed]:is([placement="embedded"], [placement="page"])) .skill-palette,
|
|
658
|
+
:host([collapsed]:is([placement="embedded"], [placement="page"])) .skill-hint {
|
|
659
|
+
display: none;
|
|
505
660
|
}
|
|
506
661
|
|
|
507
662
|
.messages {
|
|
508
663
|
flex: 1;
|
|
509
664
|
overflow-y: auto;
|
|
510
|
-
padding: var(--
|
|
665
|
+
padding: var(--_pad);
|
|
511
666
|
display: flex;
|
|
512
667
|
flex-direction: column;
|
|
513
|
-
gap: var(--
|
|
668
|
+
gap: var(--_space);
|
|
514
669
|
}
|
|
515
670
|
|
|
516
671
|
/* Empty-state region (slot): centred while it's the only thing in the
|
|
@@ -518,7 +673,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
518
673
|
.empty {
|
|
519
674
|
margin: auto;
|
|
520
675
|
text-align: center;
|
|
521
|
-
color: var(--
|
|
676
|
+
color: var(--_muted);
|
|
522
677
|
}
|
|
523
678
|
|
|
524
679
|
.empty[hidden] {
|
|
@@ -534,22 +689,22 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
534
689
|
.answer {
|
|
535
690
|
display: flex;
|
|
536
691
|
flex-direction: column;
|
|
537
|
-
gap: var(--
|
|
692
|
+
gap: var(--_space);
|
|
538
693
|
align-self: stretch;
|
|
539
694
|
min-width: 0;
|
|
540
695
|
}
|
|
541
696
|
|
|
542
697
|
:host([data-answer-well]) .answer {
|
|
543
|
-
padding: var(--
|
|
544
|
-
background: var(--
|
|
545
|
-
border: 1px solid var(--
|
|
546
|
-
border-radius: var(--
|
|
698
|
+
padding: var(--_pad);
|
|
699
|
+
background: var(--_well-bg);
|
|
700
|
+
border: 1px solid var(--_well-border);
|
|
701
|
+
border-radius: var(--_radius);
|
|
547
702
|
}
|
|
548
703
|
|
|
549
704
|
.message {
|
|
550
705
|
max-width: 80%;
|
|
551
|
-
padding: var(--
|
|
552
|
-
border-radius: var(--
|
|
706
|
+
padding: var(--_msg-pad);
|
|
707
|
+
border-radius: var(--_msg-radius);
|
|
553
708
|
line-height: 1.4;
|
|
554
709
|
white-space: pre-wrap;
|
|
555
710
|
word-break: break-word;
|
|
@@ -587,14 +742,14 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
587
742
|
|
|
588
743
|
.message--user {
|
|
589
744
|
align-self: flex-end;
|
|
590
|
-
background: var(--
|
|
591
|
-
color: var(--
|
|
745
|
+
background: var(--_user-bg);
|
|
746
|
+
color: var(--_user-fg);
|
|
592
747
|
border-bottom-right-radius: 4px;
|
|
593
748
|
}
|
|
594
749
|
|
|
595
750
|
.message--assistant {
|
|
596
751
|
align-self: flex-start;
|
|
597
|
-
background: var(--
|
|
752
|
+
background: var(--_assistant-bg);
|
|
598
753
|
border-bottom-left-radius: 4px;
|
|
599
754
|
/* Assistant bubbles hold rendered markdown/HTML, so collapse the source
|
|
600
755
|
whitespace the renderer leaves between block tags. */
|
|
@@ -624,7 +779,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
624
779
|
}
|
|
625
780
|
|
|
626
781
|
.message--assistant a {
|
|
627
|
-
color: var(--
|
|
782
|
+
color: var(--_accent);
|
|
628
783
|
text-decoration: underline;
|
|
629
784
|
}
|
|
630
785
|
|
|
@@ -639,8 +794,8 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
639
794
|
.message--assistant pre {
|
|
640
795
|
padding: 8px 10px;
|
|
641
796
|
overflow: auto;
|
|
642
|
-
background: var(--
|
|
643
|
-
border: 1px solid var(--
|
|
797
|
+
background: var(--_bg);
|
|
798
|
+
border: 1px solid var(--_border);
|
|
644
799
|
border-radius: 6px;
|
|
645
800
|
}
|
|
646
801
|
|
|
@@ -656,6 +811,13 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
656
811
|
position: relative;
|
|
657
812
|
}
|
|
658
813
|
|
|
814
|
+
/* This button is the only reader of --ag-ui-surface and --ag-ui-text, and
|
|
815
|
+
neither had a default until the alias layer gave them one. Both references
|
|
816
|
+
used to resolve to nothing, dropping the declaration: the background fell
|
|
817
|
+
back to the initial transparent, and the hover/copied colour to the
|
|
818
|
+
inherited body colour. The defaults chosen upstream (transparent, and the
|
|
819
|
+
body foreground) reproduce that, so the rename repaints nothing. A raised
|
|
820
|
+
surface behind the button is a separate design question. */
|
|
659
821
|
.code-copy {
|
|
660
822
|
position: absolute;
|
|
661
823
|
top: 4px;
|
|
@@ -664,9 +826,9 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
664
826
|
font: inherit;
|
|
665
827
|
font-size: 0.75em;
|
|
666
828
|
line-height: 1.6;
|
|
667
|
-
color: var(--
|
|
668
|
-
background: var(--
|
|
669
|
-
border: 1px solid var(--
|
|
829
|
+
color: var(--_muted);
|
|
830
|
+
background: var(--_surface);
|
|
831
|
+
border: 1px solid var(--_border);
|
|
670
832
|
border-radius: 4px;
|
|
671
833
|
cursor: pointer;
|
|
672
834
|
opacity: 0;
|
|
@@ -681,24 +843,24 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
681
843
|
}
|
|
682
844
|
|
|
683
845
|
.code-copy:hover {
|
|
684
|
-
color: var(--
|
|
685
|
-
background: var(--
|
|
846
|
+
color: var(--_text);
|
|
847
|
+
background: var(--_hover);
|
|
686
848
|
}
|
|
687
849
|
|
|
688
850
|
.code-copy[data-state="copied"] {
|
|
689
851
|
opacity: 1;
|
|
690
|
-
color: var(--
|
|
852
|
+
color: var(--_text);
|
|
691
853
|
}
|
|
692
854
|
|
|
693
855
|
.code-copy[data-state="failed"] {
|
|
694
856
|
opacity: 1;
|
|
695
|
-
color: var(--
|
|
857
|
+
color: var(--_danger, var(--_text));
|
|
696
858
|
}
|
|
697
859
|
|
|
698
860
|
.message--assistant blockquote {
|
|
699
861
|
padding-left: 10px;
|
|
700
|
-
border-left: 3px solid var(--
|
|
701
|
-
color: var(--
|
|
862
|
+
border-left: 3px solid var(--_border);
|
|
863
|
+
color: var(--_muted);
|
|
702
864
|
}
|
|
703
865
|
|
|
704
866
|
/* Markdown tables. table/thead/tbody/tr/th/td are all in
|
|
@@ -719,13 +881,13 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
719
881
|
.message--assistant th,
|
|
720
882
|
.message--assistant td {
|
|
721
883
|
padding: 6px 10px;
|
|
722
|
-
border: 1px solid var(--
|
|
884
|
+
border: 1px solid var(--_border);
|
|
723
885
|
text-align: left;
|
|
724
886
|
vertical-align: top;
|
|
725
887
|
}
|
|
726
888
|
|
|
727
889
|
.message--assistant th {
|
|
728
|
-
background: var(--
|
|
890
|
+
background: var(--_hover);
|
|
729
891
|
font-weight: 600;
|
|
730
892
|
}
|
|
731
893
|
|
|
@@ -735,7 +897,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
735
897
|
gap: 4px;
|
|
736
898
|
align-items: center;
|
|
737
899
|
padding: 12px 14px;
|
|
738
|
-
background: var(--
|
|
900
|
+
background: var(--_assistant-bg);
|
|
739
901
|
border-radius: 14px;
|
|
740
902
|
border-bottom-left-radius: 4px;
|
|
741
903
|
}
|
|
@@ -744,7 +906,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
744
906
|
width: 6px;
|
|
745
907
|
height: 6px;
|
|
746
908
|
border-radius: 50%;
|
|
747
|
-
background: var(--
|
|
909
|
+
background: var(--_muted);
|
|
748
910
|
animation: ag-ui-pending 1.2s infinite ease-in-out both;
|
|
749
911
|
}
|
|
750
912
|
|
|
@@ -777,7 +939,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
777
939
|
flex-direction: column;
|
|
778
940
|
gap: 4px;
|
|
779
941
|
font-size: 12px;
|
|
780
|
-
color: var(--
|
|
942
|
+
color: var(--_muted);
|
|
781
943
|
}
|
|
782
944
|
|
|
783
945
|
.thoughts-toggle {
|
|
@@ -788,7 +950,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
788
950
|
font: inherit;
|
|
789
951
|
font-size: 12px;
|
|
790
952
|
font-weight: 600;
|
|
791
|
-
color: var(--
|
|
953
|
+
color: var(--_muted);
|
|
792
954
|
cursor: pointer;
|
|
793
955
|
}
|
|
794
956
|
|
|
@@ -813,7 +975,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
813
975
|
.thoughts-body {
|
|
814
976
|
margin: 0;
|
|
815
977
|
padding: 4px 0 4px 10px;
|
|
816
|
-
border-left: 2px solid var(--
|
|
978
|
+
border-left: 2px solid var(--_border);
|
|
817
979
|
max-height: 220px;
|
|
818
980
|
overflow: auto;
|
|
819
981
|
white-space: pre-wrap;
|
|
@@ -842,9 +1004,9 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
842
1004
|
font-family: ui-monospace, "SF Mono", Menlo, monospace;
|
|
843
1005
|
padding: 8px 10px;
|
|
844
1006
|
border-radius: 8px;
|
|
845
|
-
background: var(--
|
|
846
|
-
border: 1px solid var(--
|
|
847
|
-
color: var(--
|
|
1007
|
+
background: var(--_tool-bg);
|
|
1008
|
+
border: 1px solid var(--_border);
|
|
1009
|
+
color: var(--_tool-fg);
|
|
848
1010
|
}
|
|
849
1011
|
|
|
850
1012
|
.tool-call-head {
|
|
@@ -877,10 +1039,10 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
877
1039
|
|
|
878
1040
|
/* Pending: a real spinning ring. Speed is tunable; reduced motion stops it. */
|
|
879
1041
|
.tool-call[data-status="pending"] .tool-call-icon {
|
|
880
|
-
border: 2px solid var(--
|
|
1042
|
+
border: 2px solid var(--_muted);
|
|
881
1043
|
border-top-color: transparent;
|
|
882
1044
|
border-radius: 50%;
|
|
883
|
-
animation: ag-ui-tool-spin var(--
|
|
1045
|
+
animation: ag-ui-tool-spin var(--_tool-spin-duration) linear infinite;
|
|
884
1046
|
}
|
|
885
1047
|
|
|
886
1048
|
@keyframes ag-ui-tool-spin {
|
|
@@ -889,18 +1051,18 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
889
1051
|
|
|
890
1052
|
/* Settled: a themeable glyph coloured by outcome. */
|
|
891
1053
|
.tool-call[data-status="done"] .tool-call-icon::before {
|
|
892
|
-
content: var(--
|
|
893
|
-
color: var(--
|
|
1054
|
+
content: var(--_tool-icon-done);
|
|
1055
|
+
color: var(--_success);
|
|
894
1056
|
}
|
|
895
1057
|
|
|
896
1058
|
.tool-call[data-status="error"] .tool-call-icon::before {
|
|
897
|
-
content: var(--
|
|
898
|
-
color: var(--
|
|
1059
|
+
content: var(--_tool-icon-error);
|
|
1060
|
+
color: var(--_danger);
|
|
899
1061
|
}
|
|
900
1062
|
|
|
901
1063
|
.tool-call[data-status="declined"] .tool-call-icon::before {
|
|
902
|
-
content: var(--
|
|
903
|
-
color: var(--
|
|
1064
|
+
content: var(--_tool-icon-declined);
|
|
1065
|
+
color: var(--_muted);
|
|
904
1066
|
}
|
|
905
1067
|
|
|
906
1068
|
@media (prefers-reduced-motion: reduce) {
|
|
@@ -926,19 +1088,19 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
926
1088
|
font-size: 11px;
|
|
927
1089
|
font-weight: 600;
|
|
928
1090
|
background: rgba(127, 127, 127, 0.16);
|
|
929
|
-
color: var(--
|
|
1091
|
+
color: var(--_muted);
|
|
930
1092
|
}
|
|
931
1093
|
|
|
932
1094
|
.tool-call[data-status="done"] .tool-call-status {
|
|
933
|
-
color: var(--
|
|
1095
|
+
color: var(--_success);
|
|
934
1096
|
}
|
|
935
1097
|
|
|
936
1098
|
.tool-call[data-status="error"] .tool-call-status {
|
|
937
|
-
color: var(--
|
|
1099
|
+
color: var(--_danger);
|
|
938
1100
|
}
|
|
939
1101
|
|
|
940
1102
|
.tool-call[data-status="declined"] .tool-call-status {
|
|
941
|
-
color: var(--
|
|
1103
|
+
color: var(--_muted);
|
|
942
1104
|
}
|
|
943
1105
|
|
|
944
1106
|
.tool-call-body {
|
|
@@ -960,7 +1122,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
960
1122
|
font-weight: 700;
|
|
961
1123
|
letter-spacing: 0.06em;
|
|
962
1124
|
text-transform: uppercase;
|
|
963
|
-
color: var(--
|
|
1125
|
+
color: var(--_muted);
|
|
964
1126
|
}
|
|
965
1127
|
|
|
966
1128
|
/* The record of a human decision on a gated call. An approved call used to
|
|
@@ -968,7 +1130,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
968
1130
|
.skill-item-token {
|
|
969
1131
|
font-family: ui-monospace, "SF Mono", Menlo, monospace;
|
|
970
1132
|
font-size: 0.92em;
|
|
971
|
-
color: var(--
|
|
1133
|
+
color: var(--_accent);
|
|
972
1134
|
margin-right: 6px;
|
|
973
1135
|
}
|
|
974
1136
|
|
|
@@ -976,7 +1138,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
976
1138
|
flex: none;
|
|
977
1139
|
font-size: 11px;
|
|
978
1140
|
font-style: italic;
|
|
979
|
-
color: var(--
|
|
1141
|
+
color: var(--_muted);
|
|
980
1142
|
}
|
|
981
1143
|
|
|
982
1144
|
.tool-call-args,
|
|
@@ -985,12 +1147,12 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
985
1147
|
padding: 6px 8px;
|
|
986
1148
|
max-height: 160px;
|
|
987
1149
|
overflow: auto;
|
|
988
|
-
background: var(--
|
|
989
|
-
border: 1px solid var(--
|
|
1150
|
+
background: var(--_bg);
|
|
1151
|
+
border: 1px solid var(--_border);
|
|
990
1152
|
border-radius: 6px;
|
|
991
1153
|
white-space: pre-wrap;
|
|
992
1154
|
word-break: break-word;
|
|
993
|
-
color: var(--
|
|
1155
|
+
color: var(--_fg);
|
|
994
1156
|
}
|
|
995
1157
|
|
|
996
1158
|
/* Display modes are pure visibility over one DOM shape, selected from the host
|
|
@@ -1037,7 +1199,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1037
1199
|
background: none;
|
|
1038
1200
|
font: inherit;
|
|
1039
1201
|
font-weight: 600;
|
|
1040
|
-
color: var(--
|
|
1202
|
+
color: var(--_accent);
|
|
1041
1203
|
cursor: pointer;
|
|
1042
1204
|
}
|
|
1043
1205
|
|
|
@@ -1060,13 +1222,12 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1060
1222
|
}
|
|
1061
1223
|
|
|
1062
1224
|
.resize-handle:focus-visible {
|
|
1063
|
-
outline: 2px solid var(--
|
|
1225
|
+
outline: 2px solid var(--_accent);
|
|
1064
1226
|
outline-offset: -2px;
|
|
1065
1227
|
}
|
|
1066
1228
|
|
|
1067
1229
|
/* The grip sits on the corner opposite the panel's anchor, because a resize
|
|
1068
|
-
measures from whichever edge is not moving.
|
|
1069
|
-
so switching placement moves the grip immediately.
|
|
1230
|
+
measures from whichever edge is not moving.
|
|
1070
1231
|
|
|
1071
1232
|
Default is floating: pinned bottom-right, so the grip is top-left. */
|
|
1072
1233
|
.resize-handle {
|
|
@@ -1077,7 +1238,9 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1077
1238
|
cursor: nwse-resize;
|
|
1078
1239
|
}
|
|
1079
1240
|
|
|
1080
|
-
/*
|
|
1241
|
+
/* Placement is only the opening guess, and these two rules are all it is good
|
|
1242
|
+
for. Embedded sits in normal flow, pinned top-left, so it grows bottom-right;
|
|
1243
|
+
bottom-left is pinned there, so its free corner is top-right. */
|
|
1081
1244
|
:host([placement="embedded"]) .resize-handle {
|
|
1082
1245
|
top: auto;
|
|
1083
1246
|
left: auto;
|
|
@@ -1086,16 +1249,64 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1086
1249
|
cursor: nwse-resize;
|
|
1087
1250
|
}
|
|
1088
1251
|
|
|
1089
|
-
/* Pinned bottom-left, so the free corner is top-right. */
|
|
1090
1252
|
:host([placement="bottom-left"]) .resize-handle {
|
|
1091
1253
|
left: auto;
|
|
1092
1254
|
right: 0;
|
|
1093
1255
|
cursor: nesw-resize;
|
|
1094
1256
|
}
|
|
1095
1257
|
|
|
1096
|
-
/*
|
|
1258
|
+
/* Then the measurement corrects it. Which edges are held still belongs to the
|
|
1259
|
+
host's layout rather than to placement -- a floating panel a host right-aligns
|
|
1260
|
+
is anchored bottom-left, not bottom-right -- so the element measures the edges
|
|
1261
|
+
that stay put and stamps them here as "<y>-<x>". Equal specificity to the
|
|
1262
|
+
rules above, so source order is what lets the measured value win.
|
|
1263
|
+
|
|
1264
|
+
These must not be written as [data-resize-anchor~="left"]: the stamped value
|
|
1265
|
+
is one hyphenated token, and ~= matches whitespace-separated words, so such a
|
|
1266
|
+
selector cannot ever match. It did not, which left the grip drawn at the
|
|
1267
|
+
corner that moves while the cursor pointed along the right diagonal.
|
|
1268
|
+
|
|
1269
|
+
Each rule also sets both sides of its axis rather than only the side it
|
|
1270
|
+
moves. One that flipped a single way could not undo a placement guess that
|
|
1271
|
+
had flipped the other, which put the grip on the anchored corner for an
|
|
1272
|
+
embedded panel its host right-aligns. */
|
|
1273
|
+
:host([data-resize-anchor$="-left"]) .resize-handle {
|
|
1274
|
+
left: auto;
|
|
1275
|
+
right: 0;
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
:host([data-resize-anchor$="-right"]) .resize-handle {
|
|
1279
|
+
left: 0;
|
|
1280
|
+
right: auto;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
:host([data-resize-anchor^="top-"]) .resize-handle {
|
|
1284
|
+
top: auto;
|
|
1285
|
+
bottom: 0;
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
:host([data-resize-anchor^="bottom-"]) .resize-handle {
|
|
1289
|
+
top: 0;
|
|
1290
|
+
bottom: auto;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
/* One axis flipped means the drag runs along the other diagonal. */
|
|
1294
|
+
:host([data-resize-anchor="top-left"]) .resize-handle,
|
|
1295
|
+
:host([data-resize-anchor="bottom-right"]) .resize-handle {
|
|
1296
|
+
cursor: nwse-resize;
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
:host([data-resize-anchor="top-right"]) .resize-handle,
|
|
1300
|
+
:host([data-resize-anchor="bottom-left"]) .resize-handle {
|
|
1301
|
+
cursor: nesw-resize;
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
/* Docked: the placement owns the height, so only the inner edge is the user's --
|
|
1305
|
+
an edge, not a corner, so this outranks the measured anchor by coming after. */
|
|
1097
1306
|
:host([placement="sidebar"]) .resize-handle,
|
|
1098
1307
|
:host([placement="side"]) .resize-handle {
|
|
1308
|
+
top: 0;
|
|
1309
|
+
bottom: auto;
|
|
1099
1310
|
width: 8px;
|
|
1100
1311
|
height: 100%;
|
|
1101
1312
|
cursor: ew-resize;
|
|
@@ -1114,106 +1325,191 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1114
1325
|
}
|
|
1115
1326
|
|
|
1116
1327
|
.resize-handle[data-dragging] {
|
|
1117
|
-
background: var(--
|
|
1328
|
+
background: var(--_accent);
|
|
1118
1329
|
opacity: 0.35;
|
|
1119
1330
|
}
|
|
1120
1331
|
|
|
1332
|
+
/* \u2500\u2500 Composer \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\u2500\u2500\u2500\u2500\u2500\u2500
|
|
1333
|
+
One surface owns the border, the background and the focus ring; the field and
|
|
1334
|
+
its tool row sit inside it. The row used to be four siblings stretched to the
|
|
1335
|
+
textarea's height, which gave a paperclip the same visual weight as the field
|
|
1336
|
+
and turned Send into a full-height slab. */
|
|
1121
1337
|
.input-row {
|
|
1122
1338
|
display: flex;
|
|
1123
|
-
gap: 8px;
|
|
1124
1339
|
padding: 12px;
|
|
1125
|
-
border-top: 1px solid var(--
|
|
1340
|
+
border-top: 1px solid var(--_border);
|
|
1126
1341
|
}
|
|
1127
1342
|
|
|
1128
|
-
.
|
|
1343
|
+
.composer {
|
|
1129
1344
|
flex: 1;
|
|
1345
|
+
min-width: 0;
|
|
1346
|
+
display: flex;
|
|
1347
|
+
flex-direction: column;
|
|
1348
|
+
gap: 4px;
|
|
1349
|
+
padding: 6px 6px 6px 10px;
|
|
1350
|
+
background: var(--_input-bg);
|
|
1351
|
+
border: 1px solid var(--_border);
|
|
1352
|
+
border-radius: var(--_composer-radius);
|
|
1353
|
+
transition: border-color var(--_motion) var(--_ease);
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
.composer:focus-within {
|
|
1357
|
+
border-color: var(--_accent);
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
/* The field grows with its content (sized by #autoGrow) up to the ceiling,
|
|
1361
|
+
then scrolls. border-box keeps that measurement stable: with content-box the
|
|
1362
|
+
padding would be added to every scrollHeight read and the field would creep
|
|
1363
|
+
taller on each keystroke. */
|
|
1364
|
+
.input {
|
|
1365
|
+
box-sizing: border-box;
|
|
1130
1366
|
resize: none;
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1367
|
+
max-height: var(--_composer-max-height);
|
|
1368
|
+
overflow-y: auto;
|
|
1369
|
+
padding: 6px 4px 2px;
|
|
1370
|
+
background: transparent;
|
|
1371
|
+
border: none;
|
|
1135
1372
|
font: inherit;
|
|
1136
1373
|
color: inherit;
|
|
1137
1374
|
outline: none;
|
|
1138
1375
|
}
|
|
1139
1376
|
|
|
1140
|
-
.
|
|
1141
|
-
|
|
1377
|
+
.composer-tools {
|
|
1378
|
+
display: flex;
|
|
1379
|
+
align-items: center;
|
|
1380
|
+
gap: 2px;
|
|
1142
1381
|
}
|
|
1143
1382
|
|
|
1144
|
-
.
|
|
1383
|
+
/* Icon buttons: quiet at rest, so the field is what the eye lands on. */
|
|
1384
|
+
.attach-btn,
|
|
1385
|
+
.voice-btn {
|
|
1386
|
+
display: inline-flex;
|
|
1387
|
+
align-items: center;
|
|
1388
|
+
justify-content: center;
|
|
1389
|
+
width: var(--_tool-btn-size);
|
|
1390
|
+
height: var(--_tool-btn-size);
|
|
1391
|
+
padding: 0;
|
|
1145
1392
|
border: none;
|
|
1146
1393
|
border-radius: 8px;
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
color: #ffffff;
|
|
1394
|
+
background: transparent;
|
|
1395
|
+
color: var(--_muted);
|
|
1150
1396
|
font: inherit;
|
|
1151
|
-
|
|
1397
|
+
line-height: 1;
|
|
1152
1398
|
cursor: pointer;
|
|
1399
|
+
transition:
|
|
1400
|
+
background-color var(--_motion) var(--_ease),
|
|
1401
|
+
color var(--_motion) var(--_ease);
|
|
1153
1402
|
}
|
|
1154
1403
|
|
|
1155
|
-
.
|
|
1156
|
-
|
|
1157
|
-
|
|
1404
|
+
.attach-btn:hover,
|
|
1405
|
+
.voice-btn:hover {
|
|
1406
|
+
background: var(--_hover);
|
|
1407
|
+
color: var(--_fg);
|
|
1158
1408
|
}
|
|
1159
1409
|
|
|
1160
|
-
|
|
1161
|
-
.
|
|
1162
|
-
|
|
1410
|
+
.attach-btn:disabled,
|
|
1411
|
+
.voice-btn:disabled {
|
|
1412
|
+
cursor: default;
|
|
1413
|
+
opacity: 0.6;
|
|
1163
1414
|
}
|
|
1164
1415
|
|
|
1165
|
-
/*
|
|
1166
|
-
|
|
1167
|
-
.
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1416
|
+
/* Send closes the row on the right: a circle, the only filled control in the
|
|
1417
|
+
composer, so "the thing that acts" reads at a glance. */
|
|
1418
|
+
.send {
|
|
1419
|
+
margin-left: auto;
|
|
1420
|
+
display: inline-flex;
|
|
1421
|
+
align-items: center;
|
|
1422
|
+
justify-content: center;
|
|
1423
|
+
flex: none;
|
|
1424
|
+
width: var(--_send-size);
|
|
1425
|
+
height: var(--_send-size);
|
|
1426
|
+
padding: 0;
|
|
1427
|
+
border: none;
|
|
1428
|
+
border-radius: 50%;
|
|
1429
|
+
background: var(--_accent);
|
|
1430
|
+
color: #ffffff;
|
|
1173
1431
|
font: inherit;
|
|
1432
|
+
line-height: 1;
|
|
1174
1433
|
cursor: pointer;
|
|
1434
|
+
transition:
|
|
1435
|
+
background-color var(--_motion) var(--_ease),
|
|
1436
|
+
transform var(--_motion) var(--_ease-pop);
|
|
1175
1437
|
}
|
|
1176
1438
|
|
|
1177
|
-
.
|
|
1178
|
-
|
|
1439
|
+
.send:hover {
|
|
1440
|
+
transform: scale(1.08);
|
|
1179
1441
|
}
|
|
1180
1442
|
|
|
1181
|
-
.
|
|
1443
|
+
.send:active {
|
|
1444
|
+
transform: scale(0.92);
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
.send:disabled {
|
|
1448
|
+
opacity: 0.5;
|
|
1449
|
+
cursor: default;
|
|
1450
|
+
transform: none;
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
/* The composer button doubles as the Stop control while a run is in flight \u2014
|
|
1454
|
+
same circle, different glyph, so nothing moves when a run starts. */
|
|
1455
|
+
.send[data-state="running"] {
|
|
1456
|
+
background: var(--_muted);
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
.send[data-state="idle"] .send-stop,
|
|
1460
|
+
.send[data-state="running"] .send-send {
|
|
1182
1461
|
display: none;
|
|
1183
1462
|
}
|
|
1184
1463
|
|
|
1185
|
-
/*
|
|
1186
|
-
.
|
|
1187
|
-
|
|
1464
|
+
/* Glyphs \u2014 one class, painted from the button's own colour so every state
|
|
1465
|
+
(hover, recording, running) carries the icon with it. */
|
|
1466
|
+
.glyph {
|
|
1467
|
+
width: var(--_glyph-size);
|
|
1468
|
+
height: var(--_glyph-size);
|
|
1469
|
+
fill: none;
|
|
1470
|
+
stroke: currentColor;
|
|
1471
|
+
stroke-width: var(--_glyph-stroke);
|
|
1472
|
+
stroke-linecap: round;
|
|
1473
|
+
stroke-linejoin: round;
|
|
1188
1474
|
}
|
|
1189
1475
|
|
|
1190
|
-
.
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
padding: 0 10px;
|
|
1194
|
-
background: var(--ag-ui-input-bg);
|
|
1195
|
-
color: inherit;
|
|
1196
|
-
font: inherit;
|
|
1197
|
-
cursor: pointer;
|
|
1476
|
+
.glyph--solid {
|
|
1477
|
+
fill: currentColor;
|
|
1478
|
+
stroke: none;
|
|
1198
1479
|
}
|
|
1199
1480
|
|
|
1200
|
-
|
|
1201
|
-
|
|
1481
|
+
/* In an icon holder (header brand, launcher) the glyph takes the holder's size
|
|
1482
|
+
rather than the composer's. */
|
|
1483
|
+
.icon-holder .glyph {
|
|
1484
|
+
width: 100%;
|
|
1485
|
+
height: 100%;
|
|
1202
1486
|
}
|
|
1203
1487
|
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1488
|
+
/* \u2500\u2500 File attachments \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 */
|
|
1489
|
+
/* The picker button sits in the composer's tool row; hidden until
|
|
1490
|
+
data-attachments-url. */
|
|
1491
|
+
.attach-input {
|
|
1492
|
+
display: none;
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
/* The mic button's mount point; filled only once #wireVoice mounts the
|
|
1496
|
+
control. */
|
|
1497
|
+
.voice-slot {
|
|
1498
|
+
display: contents;
|
|
1207
1499
|
}
|
|
1208
1500
|
|
|
1209
1501
|
/* Recording: a red tint + a gentle pulse so it's clearly "live". */
|
|
1210
1502
|
.voice-btn[data-state="recording"] {
|
|
1211
|
-
|
|
1212
|
-
background: var(--ag-ui-danger);
|
|
1503
|
+
background: var(--_danger);
|
|
1213
1504
|
color: #ffffff;
|
|
1214
1505
|
animation: ag-ui-voice-pulse 1.2s ease-in-out infinite;
|
|
1215
1506
|
}
|
|
1216
1507
|
|
|
1508
|
+
.voice-btn[data-state="recording"]:hover {
|
|
1509
|
+
background: var(--_danger);
|
|
1510
|
+
color: #ffffff;
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1217
1513
|
@keyframes ag-ui-voice-pulse {
|
|
1218
1514
|
0%, 100% { opacity: 1; }
|
|
1219
1515
|
50% { opacity: 0.6; }
|
|
@@ -1252,10 +1548,10 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1252
1548
|
max-width: 100%;
|
|
1253
1549
|
margin: 2px 0;
|
|
1254
1550
|
padding: 3px 10px;
|
|
1255
|
-
border: 1px dashed var(--
|
|
1551
|
+
border: 1px dashed var(--_border);
|
|
1256
1552
|
border-radius: 999px;
|
|
1257
1553
|
background: transparent;
|
|
1258
|
-
color: var(--
|
|
1554
|
+
color: var(--_muted);
|
|
1259
1555
|
font-size: 0.8em;
|
|
1260
1556
|
line-height: 1.4;
|
|
1261
1557
|
}
|
|
@@ -1276,16 +1572,16 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1276
1572
|
gap: 6px;
|
|
1277
1573
|
max-width: 100%;
|
|
1278
1574
|
padding: 4px 8px;
|
|
1279
|
-
border: 1px solid var(--
|
|
1575
|
+
border: 1px solid var(--_border);
|
|
1280
1576
|
border-radius: 999px;
|
|
1281
|
-
background: var(--
|
|
1577
|
+
background: var(--_assistant-bg);
|
|
1282
1578
|
font-size: 0.85em;
|
|
1283
1579
|
position: relative;
|
|
1284
1580
|
}
|
|
1285
1581
|
|
|
1286
1582
|
.attachment-chip--error {
|
|
1287
|
-
border-color: var(--
|
|
1288
|
-
color: var(--
|
|
1583
|
+
border-color: var(--_danger);
|
|
1584
|
+
color: var(--_danger);
|
|
1289
1585
|
}
|
|
1290
1586
|
|
|
1291
1587
|
.attachment-chip-name {
|
|
@@ -1296,12 +1592,12 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1296
1592
|
}
|
|
1297
1593
|
|
|
1298
1594
|
.attachment-chip-size {
|
|
1299
|
-
color: var(--
|
|
1595
|
+
color: var(--_muted);
|
|
1300
1596
|
white-space: nowrap;
|
|
1301
1597
|
}
|
|
1302
1598
|
|
|
1303
1599
|
.attachment-chip--error .attachment-chip-size {
|
|
1304
|
-
color: var(--
|
|
1600
|
+
color: var(--_danger);
|
|
1305
1601
|
}
|
|
1306
1602
|
|
|
1307
1603
|
/* The progress bar fills as the file uploads. */
|
|
@@ -1309,13 +1605,13 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1309
1605
|
flex-basis: 100%;
|
|
1310
1606
|
height: 3px;
|
|
1311
1607
|
border-radius: 2px;
|
|
1312
|
-
background: var(--
|
|
1608
|
+
background: var(--_border);
|
|
1313
1609
|
overflow: hidden;
|
|
1314
1610
|
}
|
|
1315
1611
|
|
|
1316
1612
|
.attachment-chip-bar-fill {
|
|
1317
1613
|
height: 100%;
|
|
1318
|
-
background: var(--
|
|
1614
|
+
background: var(--_accent);
|
|
1319
1615
|
transition: width 0.15s ease;
|
|
1320
1616
|
}
|
|
1321
1617
|
|
|
@@ -1337,14 +1633,14 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1337
1633
|
|
|
1338
1634
|
/* A subtle outline while a file is dragged over the shell. */
|
|
1339
1635
|
.chat--dragover {
|
|
1340
|
-
outline: 2px dashed var(--
|
|
1636
|
+
outline: 2px dashed var(--_accent);
|
|
1341
1637
|
outline-offset: -4px;
|
|
1342
1638
|
}
|
|
1343
1639
|
|
|
1344
1640
|
/* Muted "\u23F9 Stopped" line after a cancelled run \u2014 a note, not an error bubble. */
|
|
1345
1641
|
.stopped-note {
|
|
1346
1642
|
align-self: flex-start;
|
|
1347
|
-
color: var(--
|
|
1643
|
+
color: var(--_muted);
|
|
1348
1644
|
font-size: 12px;
|
|
1349
1645
|
padding: 2px 4px;
|
|
1350
1646
|
}
|
|
@@ -1357,14 +1653,14 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1357
1653
|
flex-direction: column;
|
|
1358
1654
|
gap: 8px;
|
|
1359
1655
|
padding: 12px;
|
|
1360
|
-
background: var(--
|
|
1361
|
-
border: 1px solid var(--
|
|
1656
|
+
background: var(--_bg);
|
|
1657
|
+
border: 1px solid var(--_accent);
|
|
1362
1658
|
border-radius: 10px;
|
|
1363
1659
|
}
|
|
1364
1660
|
|
|
1365
1661
|
.confirm[data-resolved] {
|
|
1366
1662
|
opacity: 0.7;
|
|
1367
|
-
border-color: var(--
|
|
1663
|
+
border-color: var(--_border);
|
|
1368
1664
|
}
|
|
1369
1665
|
|
|
1370
1666
|
.confirm-body {
|
|
@@ -1378,7 +1674,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1378
1674
|
overflow: auto;
|
|
1379
1675
|
font-size: 12px;
|
|
1380
1676
|
font-family: ui-monospace, "SF Mono", Menlo, monospace;
|
|
1381
|
-
background: var(--
|
|
1677
|
+
background: var(--_assistant-bg);
|
|
1382
1678
|
border-radius: 8px;
|
|
1383
1679
|
white-space: pre-wrap;
|
|
1384
1680
|
word-break: break-word;
|
|
@@ -1391,14 +1687,14 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1391
1687
|
}
|
|
1392
1688
|
|
|
1393
1689
|
.confirm-btn {
|
|
1394
|
-
border: 1px solid var(--
|
|
1690
|
+
border: 1px solid var(--_border);
|
|
1395
1691
|
border-radius: 8px;
|
|
1396
1692
|
padding: 8px 14px;
|
|
1397
1693
|
font: inherit;
|
|
1398
1694
|
font-weight: 600;
|
|
1399
1695
|
cursor: pointer;
|
|
1400
|
-
background: var(--
|
|
1401
|
-
color: var(--
|
|
1696
|
+
background: var(--_bg);
|
|
1697
|
+
color: var(--_fg);
|
|
1402
1698
|
}
|
|
1403
1699
|
|
|
1404
1700
|
.confirm-btn:disabled {
|
|
@@ -1407,8 +1703,8 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1407
1703
|
}
|
|
1408
1704
|
|
|
1409
1705
|
.confirm-btn--confirm {
|
|
1410
|
-
border-color: var(--
|
|
1411
|
-
background: var(--
|
|
1706
|
+
border-color: var(--_accent);
|
|
1707
|
+
background: var(--_accent);
|
|
1412
1708
|
color: #ffffff;
|
|
1413
1709
|
}
|
|
1414
1710
|
|
|
@@ -1420,14 +1716,14 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1420
1716
|
flex-direction: column;
|
|
1421
1717
|
gap: 8px;
|
|
1422
1718
|
padding: 12px;
|
|
1423
|
-
background: var(--
|
|
1424
|
-
border: 1px solid var(--
|
|
1719
|
+
background: var(--_bg);
|
|
1720
|
+
border: 1px solid var(--_accent);
|
|
1425
1721
|
border-radius: 10px;
|
|
1426
1722
|
}
|
|
1427
1723
|
|
|
1428
1724
|
.approval[data-resolved] {
|
|
1429
1725
|
opacity: 0.7;
|
|
1430
|
-
border-color: var(--
|
|
1726
|
+
border-color: var(--_border);
|
|
1431
1727
|
}
|
|
1432
1728
|
|
|
1433
1729
|
.approval-body {
|
|
@@ -1441,14 +1737,14 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1441
1737
|
}
|
|
1442
1738
|
|
|
1443
1739
|
.approval-btn {
|
|
1444
|
-
border: 1px solid var(--
|
|
1740
|
+
border: 1px solid var(--_border);
|
|
1445
1741
|
border-radius: 8px;
|
|
1446
1742
|
padding: 8px 14px;
|
|
1447
1743
|
font: inherit;
|
|
1448
1744
|
font-weight: 600;
|
|
1449
1745
|
cursor: pointer;
|
|
1450
|
-
background: var(--
|
|
1451
|
-
color: var(--
|
|
1746
|
+
background: var(--_bg);
|
|
1747
|
+
color: var(--_fg);
|
|
1452
1748
|
}
|
|
1453
1749
|
|
|
1454
1750
|
.approval-btn:disabled {
|
|
@@ -1457,8 +1753,8 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1457
1753
|
}
|
|
1458
1754
|
|
|
1459
1755
|
.approval-btn--approve {
|
|
1460
|
-
border-color: var(--
|
|
1461
|
-
background: var(--
|
|
1756
|
+
border-color: var(--_accent);
|
|
1757
|
+
background: var(--_accent);
|
|
1462
1758
|
color: #ffffff;
|
|
1463
1759
|
}
|
|
1464
1760
|
|
|
@@ -1470,14 +1766,14 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1470
1766
|
flex-direction: column;
|
|
1471
1767
|
gap: 8px;
|
|
1472
1768
|
padding: 12px;
|
|
1473
|
-
background: var(--
|
|
1474
|
-
border: 1px solid var(--
|
|
1769
|
+
background: var(--_bg);
|
|
1770
|
+
border: 1px solid var(--_accent);
|
|
1475
1771
|
border-radius: 10px;
|
|
1476
1772
|
}
|
|
1477
1773
|
|
|
1478
1774
|
.question[data-resolved] {
|
|
1479
1775
|
opacity: 0.7;
|
|
1480
|
-
border-color: var(--
|
|
1776
|
+
border-color: var(--_border);
|
|
1481
1777
|
}
|
|
1482
1778
|
|
|
1483
1779
|
.question-body {
|
|
@@ -1502,9 +1798,9 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1502
1798
|
width: 100%;
|
|
1503
1799
|
padding: 8px 10px;
|
|
1504
1800
|
font: inherit;
|
|
1505
|
-
color: var(--
|
|
1506
|
-
background: var(--
|
|
1507
|
-
border: 1px solid var(--
|
|
1801
|
+
color: var(--_fg);
|
|
1802
|
+
background: var(--_bg);
|
|
1803
|
+
border: 1px solid var(--_border);
|
|
1508
1804
|
border-radius: 8px;
|
|
1509
1805
|
}
|
|
1510
1806
|
|
|
@@ -1518,13 +1814,13 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1518
1814
|
}
|
|
1519
1815
|
|
|
1520
1816
|
.question-btn {
|
|
1521
|
-
border: 1px solid var(--
|
|
1817
|
+
border: 1px solid var(--_accent);
|
|
1522
1818
|
border-radius: 8px;
|
|
1523
1819
|
padding: 8px 14px;
|
|
1524
1820
|
font: inherit;
|
|
1525
1821
|
font-weight: 600;
|
|
1526
1822
|
cursor: pointer;
|
|
1527
|
-
background: var(--
|
|
1823
|
+
background: var(--_accent);
|
|
1528
1824
|
color: #ffffff;
|
|
1529
1825
|
}
|
|
1530
1826
|
|
|
@@ -1542,18 +1838,18 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1542
1838
|
}
|
|
1543
1839
|
|
|
1544
1840
|
.skill-chip {
|
|
1545
|
-
border: 1px solid var(--
|
|
1841
|
+
border: 1px solid var(--_border);
|
|
1546
1842
|
border-radius: 999px;
|
|
1547
1843
|
padding: 4px 12px;
|
|
1548
1844
|
font: inherit;
|
|
1549
1845
|
font-size: 0.9em;
|
|
1550
1846
|
cursor: pointer;
|
|
1551
|
-
background: var(--
|
|
1552
|
-
color: var(--
|
|
1847
|
+
background: var(--_assistant-bg);
|
|
1848
|
+
color: var(--_fg);
|
|
1553
1849
|
}
|
|
1554
1850
|
|
|
1555
1851
|
.skill-chip:hover {
|
|
1556
|
-
border-color: var(--
|
|
1852
|
+
border-color: var(--_accent);
|
|
1557
1853
|
}
|
|
1558
1854
|
|
|
1559
1855
|
.skill-palette {
|
|
@@ -1562,8 +1858,8 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1562
1858
|
flex-direction: column;
|
|
1563
1859
|
max-height: 220px;
|
|
1564
1860
|
overflow: auto;
|
|
1565
|
-
background: var(--
|
|
1566
|
-
border: 1px solid var(--
|
|
1861
|
+
background: var(--_bg);
|
|
1862
|
+
border: 1px solid var(--_border);
|
|
1567
1863
|
border-radius: 8px;
|
|
1568
1864
|
box-shadow: 0 8px 24px rgba(20, 20, 50, 0.16);
|
|
1569
1865
|
}
|
|
@@ -1579,11 +1875,11 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1579
1875
|
font: inherit;
|
|
1580
1876
|
text-align: left;
|
|
1581
1877
|
cursor: pointer;
|
|
1582
|
-
color: var(--
|
|
1878
|
+
color: var(--_fg);
|
|
1583
1879
|
}
|
|
1584
1880
|
|
|
1585
1881
|
.skill-item[aria-selected="true"] {
|
|
1586
|
-
background: var(--
|
|
1882
|
+
background: var(--_assistant-bg);
|
|
1587
1883
|
}
|
|
1588
1884
|
|
|
1589
1885
|
.skill-item-title {
|
|
@@ -1592,7 +1888,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1592
1888
|
|
|
1593
1889
|
.skill-item-desc {
|
|
1594
1890
|
font-size: 0.85em;
|
|
1595
|
-
color: var(--
|
|
1891
|
+
color: var(--_muted);
|
|
1596
1892
|
}
|
|
1597
1893
|
|
|
1598
1894
|
/* The hint sits directly above the composer's top border, so a zero bottom
|
|
@@ -1601,19 +1897,38 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1601
1897
|
margin: 8px 12px;
|
|
1602
1898
|
font-size: 0.85em;
|
|
1603
1899
|
line-height: 1.4;
|
|
1604
|
-
color: var(--
|
|
1900
|
+
color: var(--_danger);
|
|
1605
1901
|
}
|
|
1606
1902
|
|
|
1607
|
-
/* Chat-history drawer \u2014 a slide-over within the chat panel.
|
|
1903
|
+
/* Chat-history drawer \u2014 a slide-over within the chat panel.
|
|
1904
|
+
The hidden attribute stays the single source of truth for open/closed (no
|
|
1905
|
+
JS-driven animation state): display is transitioned discretely, so on close
|
|
1906
|
+
the drawer stays displayed for the whole exit and is removed only at the end,
|
|
1907
|
+
which is what lets the backdrop fade and the panel slide out. */
|
|
1608
1908
|
.drawer {
|
|
1609
1909
|
position: absolute;
|
|
1610
1910
|
inset: 0;
|
|
1611
1911
|
z-index: 5;
|
|
1612
1912
|
display: flex;
|
|
1913
|
+
transition: visibility var(--_motion) var(--_ease);
|
|
1613
1914
|
}
|
|
1614
1915
|
|
|
1916
|
+
/* Closed. The overlay keeps its box (display, not none) so the backdrop and
|
|
1917
|
+
panel inside it stay rendered and can transition both ways; visibility is
|
|
1918
|
+
what takes the whole subtree out of the tab order, the a11y tree and hit
|
|
1919
|
+
testing at rest, and it holds off until the slide has finished. */
|
|
1615
1920
|
.drawer[hidden] {
|
|
1616
|
-
display:
|
|
1921
|
+
display: flex;
|
|
1922
|
+
visibility: hidden;
|
|
1923
|
+
pointer-events: none;
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
.drawer[hidden] .drawer-backdrop {
|
|
1927
|
+
opacity: 0;
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
.drawer[hidden] .drawer-panel {
|
|
1931
|
+
transform: translateX(-100%);
|
|
1617
1932
|
}
|
|
1618
1933
|
|
|
1619
1934
|
.checkpoints {
|
|
@@ -1625,16 +1940,27 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1625
1940
|
flex-direction: column;
|
|
1626
1941
|
gap: 0.25rem;
|
|
1627
1942
|
padding: 0.5rem;
|
|
1628
|
-
border: 1px solid var(--
|
|
1943
|
+
border: 1px solid var(--_border);
|
|
1629
1944
|
border-radius: 0.5rem;
|
|
1630
|
-
background: var(--
|
|
1945
|
+
background: var(--_assistant-bg);
|
|
1631
1946
|
box-shadow: 0 6px 24px rgb(0 0 0 / 12%);
|
|
1632
1947
|
max-height: 60%;
|
|
1633
1948
|
overflow-y: auto;
|
|
1949
|
+
transform-origin: top center;
|
|
1950
|
+
transition:
|
|
1951
|
+
opacity var(--_motion) var(--_ease),
|
|
1952
|
+
transform var(--_motion) var(--_ease),
|
|
1953
|
+
visibility var(--_motion) var(--_ease);
|
|
1634
1954
|
}
|
|
1635
1955
|
|
|
1956
|
+
/* Same idiom as the drawer: laid out at rest, hidden by visibility, so the
|
|
1957
|
+
popover can animate open and closed. */
|
|
1636
1958
|
.checkpoints[hidden] {
|
|
1637
|
-
display:
|
|
1959
|
+
display: flex;
|
|
1960
|
+
visibility: hidden;
|
|
1961
|
+
pointer-events: none;
|
|
1962
|
+
opacity: 0;
|
|
1963
|
+
transform: scale(0.96) translateY(-6px);
|
|
1638
1964
|
}
|
|
1639
1965
|
|
|
1640
1966
|
.checkpoints-title {
|
|
@@ -1658,7 +1984,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1658
1984
|
}
|
|
1659
1985
|
|
|
1660
1986
|
.checkpoint-row:hover {
|
|
1661
|
-
background: var(--
|
|
1987
|
+
background: var(--_hover);
|
|
1662
1988
|
}
|
|
1663
1989
|
|
|
1664
1990
|
.checkpoint-label {
|
|
@@ -1673,7 +1999,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1673
1999
|
font-size: 0.6875rem;
|
|
1674
2000
|
padding: 0 0.375rem;
|
|
1675
2001
|
border-radius: 999px;
|
|
1676
|
-
background: var(--
|
|
2002
|
+
background: var(--_hover);
|
|
1677
2003
|
opacity: 0.8;
|
|
1678
2004
|
}
|
|
1679
2005
|
|
|
@@ -1682,20 +2008,22 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1682
2008
|
font-size: 0.75rem;
|
|
1683
2009
|
cursor: pointer;
|
|
1684
2010
|
padding: 0.125rem 0.5rem;
|
|
1685
|
-
border: 1px solid var(--
|
|
2011
|
+
border: 1px solid var(--_border);
|
|
1686
2012
|
border-radius: 0.375rem;
|
|
1687
2013
|
background: transparent;
|
|
1688
2014
|
color: inherit;
|
|
1689
2015
|
}
|
|
1690
2016
|
|
|
1691
2017
|
.checkpoint-action:hover {
|
|
1692
|
-
background: var(--
|
|
2018
|
+
background: var(--_hover);
|
|
1693
2019
|
}
|
|
1694
2020
|
|
|
1695
2021
|
.drawer-backdrop {
|
|
1696
2022
|
position: absolute;
|
|
1697
2023
|
inset: 0;
|
|
1698
2024
|
background: rgba(20, 20, 50, 0.32);
|
|
2025
|
+
opacity: 1;
|
|
2026
|
+
transition: opacity var(--_motion) var(--_ease);
|
|
1699
2027
|
}
|
|
1700
2028
|
|
|
1701
2029
|
.drawer-panel {
|
|
@@ -1704,19 +2032,21 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1704
2032
|
flex-direction: column;
|
|
1705
2033
|
width: min(300px, 85%);
|
|
1706
2034
|
height: 100%;
|
|
1707
|
-
background: var(--
|
|
1708
|
-
border-right: 1px solid var(--
|
|
1709
|
-
box-shadow: var(--
|
|
2035
|
+
background: var(--_bg);
|
|
2036
|
+
border-right: 1px solid var(--_border);
|
|
2037
|
+
box-shadow: var(--_shadow);
|
|
1710
2038
|
overflow: hidden;
|
|
2039
|
+
transform: none;
|
|
2040
|
+
transition: transform var(--_motion) var(--_ease);
|
|
1711
2041
|
}
|
|
1712
2042
|
|
|
1713
2043
|
.drawer-header {
|
|
1714
2044
|
display: flex;
|
|
1715
2045
|
align-items: center;
|
|
1716
2046
|
justify-content: space-between;
|
|
1717
|
-
gap: var(--
|
|
1718
|
-
padding: var(--
|
|
1719
|
-
border-bottom: 1px solid var(--
|
|
2047
|
+
gap: var(--_space);
|
|
2048
|
+
padding: var(--_pad);
|
|
2049
|
+
border-bottom: 1px solid var(--_border);
|
|
1720
2050
|
}
|
|
1721
2051
|
|
|
1722
2052
|
.drawer-title {
|
|
@@ -1724,10 +2054,10 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1724
2054
|
}
|
|
1725
2055
|
|
|
1726
2056
|
.drawer-new {
|
|
1727
|
-
border: 1px solid var(--
|
|
1728
|
-
border-radius: var(--
|
|
1729
|
-
background: var(--
|
|
1730
|
-
color: var(--
|
|
2057
|
+
border: 1px solid var(--_border);
|
|
2058
|
+
border-radius: var(--_radius);
|
|
2059
|
+
background: var(--_bg);
|
|
2060
|
+
color: var(--_accent);
|
|
1731
2061
|
padding: 4px 10px;
|
|
1732
2062
|
font: inherit;
|
|
1733
2063
|
font-size: 0.85em;
|
|
@@ -1741,19 +2071,19 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1741
2071
|
}
|
|
1742
2072
|
|
|
1743
2073
|
.drawer-empty {
|
|
1744
|
-
padding: var(--
|
|
2074
|
+
padding: var(--_pad);
|
|
1745
2075
|
font-size: 0.9em;
|
|
1746
|
-
color: var(--
|
|
2076
|
+
color: var(--_muted);
|
|
1747
2077
|
}
|
|
1748
2078
|
|
|
1749
2079
|
.drawer-row {
|
|
1750
2080
|
display: flex;
|
|
1751
2081
|
align-items: stretch;
|
|
1752
|
-
border-bottom: 1px solid var(--
|
|
2082
|
+
border-bottom: 1px solid var(--_border);
|
|
1753
2083
|
}
|
|
1754
2084
|
|
|
1755
2085
|
.drawer-row--active {
|
|
1756
|
-
background: var(--
|
|
2086
|
+
background: var(--_assistant-bg);
|
|
1757
2087
|
}
|
|
1758
2088
|
|
|
1759
2089
|
.drawer-row-select {
|
|
@@ -1780,12 +2110,12 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1780
2110
|
|
|
1781
2111
|
.drawer-row-time {
|
|
1782
2112
|
font-size: 0.72em;
|
|
1783
|
-
color: var(--
|
|
2113
|
+
color: var(--_muted);
|
|
1784
2114
|
}
|
|
1785
2115
|
|
|
1786
2116
|
.drawer-row-preview {
|
|
1787
2117
|
font-size: 0.8em;
|
|
1788
|
-
color: var(--
|
|
2118
|
+
color: var(--_muted);
|
|
1789
2119
|
overflow: hidden;
|
|
1790
2120
|
white-space: nowrap;
|
|
1791
2121
|
text-overflow: ellipsis;
|
|
@@ -1802,7 +2132,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1802
2132
|
.drawer-row-delete {
|
|
1803
2133
|
border: none;
|
|
1804
2134
|
background: none;
|
|
1805
|
-
color: var(--
|
|
2135
|
+
color: var(--_muted);
|
|
1806
2136
|
font-size: 0.9em;
|
|
1807
2137
|
padding: 4px;
|
|
1808
2138
|
cursor: pointer;
|
|
@@ -1813,10 +2143,10 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1813
2143
|
min-width: 0;
|
|
1814
2144
|
margin: 6px 10px;
|
|
1815
2145
|
padding: 4px 8px;
|
|
1816
|
-
border: 1px solid var(--
|
|
2146
|
+
border: 1px solid var(--_accent);
|
|
1817
2147
|
border-radius: 6px;
|
|
1818
|
-
background: var(--
|
|
1819
|
-
color: var(--
|
|
2148
|
+
background: var(--_input-bg);
|
|
2149
|
+
color: var(--_fg);
|
|
1820
2150
|
font: inherit;
|
|
1821
2151
|
}
|
|
1822
2152
|
|
|
@@ -1829,13 +2159,13 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1829
2159
|
}
|
|
1830
2160
|
|
|
1831
2161
|
.drawer-confirm-label {
|
|
1832
|
-
color: var(--
|
|
2162
|
+
color: var(--_danger);
|
|
1833
2163
|
}
|
|
1834
2164
|
|
|
1835
2165
|
.drawer-confirm-yes {
|
|
1836
2166
|
border: none;
|
|
1837
2167
|
border-radius: 6px;
|
|
1838
|
-
background: var(--
|
|
2168
|
+
background: var(--_danger);
|
|
1839
2169
|
color: #ffffff;
|
|
1840
2170
|
padding: 3px 10px;
|
|
1841
2171
|
font: inherit;
|
|
@@ -1843,7 +2173,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1843
2173
|
}
|
|
1844
2174
|
|
|
1845
2175
|
.drawer-confirm-no {
|
|
1846
|
-
border: 1px solid var(--
|
|
2176
|
+
border: 1px solid var(--_border);
|
|
1847
2177
|
border-radius: 6px;
|
|
1848
2178
|
background: none;
|
|
1849
2179
|
color: inherit;
|
|
@@ -1863,9 +2193,9 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1863
2193
|
border-right: none;
|
|
1864
2194
|
box-shadow: none;
|
|
1865
2195
|
}
|
|
1866
|
-
`;var bi=class{element;#n;#e;#t;#s;#r=!1;constructor(e=ae){this.#s=e,this.element=document.createElement("div"),this.element.className="thoughts",this.element.setAttribute("part","thoughts"),this.element.setAttribute("data-streaming",""),this.#t=document.createElement("button"),this.#t.type="button",this.#t.className="thoughts-toggle",this.#t.setAttribute("part","thoughts-toggle"),this.#t.setAttribute("aria-expanded","true"),this.#n=document.createElement("span"),this.#n.className="thoughts-label",this.#n.setAttribute("part","thoughts-label"),this.#n.textContent=e.thinking,this.#t.append(this.#n),this.#e=document.createElement("pre"),this.#e.className="thoughts-body",this.#e.setAttribute("part","thoughts-body"),this.#t.addEventListener("click",()=>{this.#a(!this.#r)}),this.element.append(this.#t,this.#e)}stream(e){this.#e.textContent=e}collapse(){this.#r||(this.element.removeAttribute("data-streaming"),this.#n.textContent=this.#s.thoughts,this.#a(!0))}#a(e){this.#r=e,this.#e.hidden=e,this.#t.setAttribute("aria-expanded",String(!e))}};var yi=class{element;#n;#e;#t;#s;#r;#a;#o=[];#i="";#l=null;constructor(e,n=ae){this.#n=e,this.#a=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.#e=document.createElement("div"),this.#e.className="drawer-panel",this.#e.setAttribute("part","drawer-panel"),this.#e.setAttribute("role","dialog"),this.#e.setAttribute("aria-modal","true"),this.#e.setAttribute("aria-label",n.chatHistory),this.#e.addEventListener("keydown",i=>this.#d(i));let o=document.createElement("div");o.className="drawer-header",o.setAttribute("part","drawer-header"),this.#t=document.createElement("span"),this.#t.className="drawer-title",this.#t.setAttribute("part","drawer-title"),this.#t.textContent=n.chats,this.#s=document.createElement("button"),this.#s.type="button",this.#s.className="drawer-new",this.#s.setAttribute("part","drawer-new"),this.#s.textContent=n.newChat,this.#s.addEventListener("click",()=>{this.close(),this.#n.onNew()}),o.append(this.#t,this.#s),this.#r=document.createElement("div"),this.#r.className="drawer-list",this.#r.setAttribute("part","drawer-list"),this.#e.append(o,this.#r),this.element.append(r,this.#e)}setStrings(e){this.#a=e,this.#e.setAttribute("aria-label",e.chatHistory),this.#t.textContent=e.chats,this.#s.textContent=e.newChat,this.#u()}isOpen(){return!this.element.hidden}open(){this.isOpen()||(this.#l=this.#c(),this.element.hidden=!1,this.#s.focus())}close(){this.isOpen()&&(this.element.hidden=!0,this.#l?.focus(),this.#l=null)}toggle(){this.isOpen()?this.close():this.open()}#c(){return this.element.getRootNode().activeElement}#d(e){if(e.key==="Escape"){e.preventDefault(),this.close();return}if(e.key!=="Tab")return;let n=Array.from(this.#e.querySelectorAll("button, input, [tabindex]")).filter(s=>!s.hidden),r=n[0],o=n[n.length-1],i=this.#c();e.shiftKey&&i===r?(e.preventDefault(),o?.focus()):!e.shiftKey&&i===o&&(e.preventDefault(),r?.focus())}setThreads(e,n){this.#o=e,this.#i=n,this.#u()}#u(){if(this.#r.replaceChildren(),this.#o.length===0){let e=document.createElement("div");e.className="drawer-empty",e.setAttribute("part","drawer-empty"),e.textContent=this.#a.noConversations,this.#r.appendChild(e);return}for(let e of this.#o)this.#r.appendChild(this.#f(e))}#f(e){let n=document.createElement("div");n.className="drawer-row",n.setAttribute("part","drawer-row"),e.threadId===this.#i&&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=ci(e.updatedAt,void 0,this.#a);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.#n.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.#a.rename,a.setAttribute("aria-label",this.#a.renameConversation),a.textContent="\u270E",a.addEventListener("click",()=>this.#h(n,e));let l=document.createElement("button");l.type="button",l.className="drawer-row-delete",l.setAttribute("part","drawer-row-delete"),l.title=this.#a.delete,l.setAttribute("aria-label",this.#a.deleteConversation),l.textContent="\u{1F5D1}",l.addEventListener("click",()=>this.#k(n,e));let c=document.createElement("div");return c.className="drawer-row-actions",c.setAttribute("part","drawer-row-actions"),c.append(a,l),n.append(r,c),n}#h(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.#u():this.#n.onRename(n.threadId,a)},s=()=>{o||(o=!0,this.#u())};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()}#k(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.#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.#n.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.#a.cancel,s.addEventListener("click",()=>this.#u()),r.append(o,i,s),e.replaceChildren(r)}};function Xu(t){return{[pe.PENDING]:t.toolRunning,[pe.DONE]:t.toolDone,[pe.ERROR]:t.toolError,[pe.DECLINED]:t.toolDeclined}}function Cv(t){return{[pe.DONE]:t.resultLabel,[pe.ERROR]:t.errorLabel,[pe.DECLINED]:t.declinedLabel}}function Rv(t){try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}var hr=class{element;#n;#e;#t;#s;#r;#a;#o;#i=!1;constructor(e,n,r,o=ae){this.#o=o,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",pe.PENDING),this.element.setAttribute("data-expanded","false");let i=document.createElement("div");i.className="tool-call-head",i.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 a=document.createElement("span");a.className="tool-call-name",a.setAttribute("part","tool-card-name"),a.textContent=r??e,this.#n=document.createElement("span"),this.#n.className="tool-call-status",this.#n.setAttribute("part","tool-card-status"),this.#n.textContent=Xu(o)[pe.PENDING],this.#e=document.createElement("span"),this.#e.className="tool-call-decision",this.#e.setAttribute("part","tool-card-decision"),this.#e.hidden=!0,i.append(s,a,this.#n,this.#e);let l=this.#l("args",o.argumentsLabel);l.body.textContent=JSON.stringify(n,null,2),l.root.hidden=Object.keys(n).length===0;let c=this.#l("result",o.resultLabel);this.#s=c.root,this.#r=c.label,this.#a=c.body,c.root.hidden=!0,this.#t=document.createElement("button"),this.#t.type="button",this.#t.className="tool-call-toggle",this.#t.setAttribute("part","tool-card-toggle"),this.#t.setAttribute("aria-expanded","false"),this.#t.textContent=o.details,this.#t.addEventListener("click",()=>this.#d(!this.#c()));let h=document.createElement("div");h.className="tool-call-body",h.setAttribute("part","tool-card-body"),h.append(l.root,c.root),this.element.append(i,this.#t,h)}recordDecision(e){this.element.setAttribute("data-decision",e),this.#e.textContent=e==="approved"?this.#o.decisionApproved:this.#o.decisionDeclined,this.#e.hidden=!1}get settled(){return this.#i}settle(e,n){this.#i||(this.#i=!0,this.element.setAttribute("data-status",e),this.#n.textContent=Xu(this.#o)[e],this.#r.textContent=Cv(this.#o)[e],this.#a.textContent=Rv(n),this.#s.hidden=!1)}#l(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}}#c(){return this.element.getAttribute("data-expanded")==="true"}#d(e){this.element.setAttribute("data-expanded",String(e)),this.#t.setAttribute("aria-expanded",String(e))}};var xi=class{element;#n;#e;#t;#s="idle";#r=null;#a=null;#o=[];#i=!1;constructor(e){this.#n=e.transcribe,this.#e=e.onText,this.#t=e.strings??ae,this.element=document.createElement("button"),this.element.type="button",this.element.className="voice-btn",this.element.setAttribute("part","voice-button"),this.element.textContent="\u{1F3A4}",this.#h("idle"),this.element.addEventListener("click",()=>{this.toggle()})}async toggle(){if(this.#s==="recording"){this.#c();return}this.#s!=="transcribing"&&await this.#l()}async#l(){let e;try{e=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{this.#f(this.#t.transcriptionFailed);return}this.#a=e,this.#o=[];let n=new MediaRecorder(e);n.addEventListener("dataavailable",r=>{this.#o.push(r.data)}),n.addEventListener("stop",()=>{this.#d(n.mimeType)}),this.#r=n,n.start(),this.#h("recording")}#c(){this.#r?.stop()}dispose(){this.#i=!0,this.#r!==null&&this.#r.state!=="inactive"&&this.#r.stop(),this.#r=null,this.#u()}async#d(e){if(this.#i)return;this.#u(),this.#h("transcribing");let n=new Blob(this.#o,{type:e||"audio/webm"});try{let r=await this.#n(n);this.#h("idle"),r!==""&&this.#e(r)}catch(r){this.#f(r instanceof Error?r.message:this.#t.transcriptionFailed)}finally{this.#r=null}}#u(){for(let e of this.#a?.getTracks()??[])e.stop();this.#a=null}#f(e){this.#u(),this.#r=null,this.#h("idle"),this.element.title=e}#h(e){this.#s=e,this.element.dataset.state=e;let n=this.#k(e);this.element.title=n,this.element.setAttribute("aria-label",n),this.element.setAttribute("aria-pressed",String(e==="recording")),this.element.disabled=e==="transcribing"}#k(e){return e==="recording"?this.#t.stopRecording:e==="transcribing"?this.#t.transcribing:this.#t.recordVoice}};var Ei=class extends Error{constructor(e){super(e),this.name="ConnectionLostError"}},Ln=class{#n;#e;#t;#s;#r;#a;#o;#i=new Set;#l;#c=!1;constructor(e){this.#n=e.agent,this.#e=e.handlers,this.#t=e.getTools??(()=>[]),this.#s=e.getContext??(()=>[]),this.#r=e.executeTool??null,this.#a=e.resolveInterrupts??null,this.#o=e.onPersist??(()=>{}),this.#l=e.connectionLostMessage??"Connection lost";let n=e.onStateChanged;n!==void 0&&this.#n.subscribe({onStateChanged:({state:r})=>{n(r)}})}get state(){return this.#n.state}setState(e){this.#n.setState({...e})}get running(){return this.#n.isRunning}get messages(){return this.#n.messages}async send(e,n=[]){let r={id:Ue(),role:"user",content:e};n.length>0&&(r.attachments=n),this.#n.addMessage(r),this.#o(this.#n.messages),await this.#d()}async resume(){await this.#d()}addToolResult(e,n){this.#n.addMessage({id:Ue(),role:"tool",content:n,toolCallId:e}),this.#o(this.#n.messages)}cancel(){this.#c=!0,this.#n.abortRun()}async#d(){this.#c=!1;try{await this.#f(),this.#c&&this.#u()}catch(e){this.#c||Nv(e)?this.#u():this.#e.onError(e instanceof Error?e.message:String(e))}finally{this.#e.onSettled()}}#u(){this.#o(this.#n.messages),this.#e.onCancelled()}async#f(){let e;for(let n=0;n<Yi;n+=1){if(this.#c)return;let r=[],o={terminal:!1,errored:!1,interrupts:[]},i={tools:this.#t(),context:this.#s()};if(e!==void 0&&(i.resume=e),await this.#n.runAgent(i,this.#h(r,o)),e=void 0,this.#o(this.#n.messages),this.#c)return;if(!o.terminal)throw new Ei(this.#l);if(o.errored)return;if(o.interrupts.length>0){if(this.#a===null)return;let a=await this.#a(o.interrupts);if(this.#c)return;e=nu(o.interrupts,a);continue}if(this.#r===null||r.length===0)return;let s=!1;for(let a of r){let l=await this.#r(a);if(l!==null){if(l.halt===!0)return;this.#n.addMessage({id:Ue(),role:"tool",content:l.content,toolCallId:a.id}),this.#o(this.#n.messages),s=!0}}if(!s)return}}#h(e,n){let r=this.#e,o=this.#i;return{onRunInitialized(){r.onRunStart()},onTextMessageStartEvent({event:i}){o.has(i.messageId)&&console.warn(`<ag-ui-chat>: the server reused message id "${i.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:i}){r.onTextDelta(i)},onTextMessageEndEvent({event:i,textMessageBuffer:s}){o.add(i.messageId),r.onTextEnd(s)},onToolCallEndEvent({event:i,toolCallName:s,toolCallArgs:a}){let l={id:i.toolCallId,name:s,args:a};e.push(l),r.onToolCall(l)},onToolCallResultEvent({event:i}){r.onToolResult(i.toolCallId,i.content)},onActivitySnapshotEvent({event:i}){r.onActivity(i.activityType,i.content)},onReasoningStartEvent(){r.onReasoningStart()},onReasoningMessageContentEvent({reasoningMessageBuffer:i}){r.onReasoningDelta(i)},onReasoningEndEvent(){r.onReasoningEnd()},onRunFinishedEvent(i){n.terminal=!0,i.outcome==="interrupt"&&(n.interrupts=i.interrupts)},onRunErrorEvent({event:i}){n.terminal=!0,n.errored=!0,r.onError(i.message)},onRunFinalized(){n.terminal=!0,r.onRunEnd()}}}};function Nv(t){return t instanceof Error&&t.name==="AbortError"}function ka(t){let e=t.attachments;return Array.isArray(e)?e.filter(Ov):[]}function Ov(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 Ia="ag-ui-chat",fr="thread",Ca="threads",Ti="messages:",wi="checkpoint:",Mv=60,Lv=100,Pv="New conversation",ft=class{#n;constructor(e=""){this.#n=e===""?Ia:`${Ia}@${e}`,e!==""&&this.#a()}threadId(){let e=this.#r(fr),n=sessionStorage.getItem(e);if(n!==null)return n;let r=Ue();return sessionStorage.setItem(e,r),r}loadMessages(e){return Promise.resolve(this.#o(this.#r(Ti+e)))}saveMessages(e,n){sessionStorage.setItem(this.#r(Ti+e),JSON.stringify(n)),this.#e(e,n)}loadCheckpoint(e){return this.#o(this.#r(wi+e))}saveCheckpoint(e,n){let r=this.#r(wi+e);if(n===null){sessionStorage.removeItem(r);return}sessionStorage.setItem(r,JSON.stringify(n))}clear(e){sessionStorage.removeItem(this.#r(Ti+e)),sessionStorage.removeItem(this.#r(wi+e)),this.#s(this.#t().filter(n=>n.threadId!==e)),sessionStorage.getItem(this.#r(fr))===e&&sessionStorage.removeItem(this.#r(fr))}listThreads(){let e=this.#t().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){sessionStorage.setItem(this.#r(fr),e)}renameThread(e,n){let r=this.#t(),o=r.find(i=>i.threadId===e);o!==void 0&&(o.title=n,o.titleCustom=!0,this.#s(r))}#e(e,n){let r=this.#t(),o=r.find(a=>a.threadId===e),i=Uv(n),s=Date.now();o===void 0?r.push({threadId:e,title:Yu(n),titleCustom:!1,preview:i,updatedAt:s}):(o.preview=i,o.updatedAt=s,o.titleCustom||(o.title=Yu(n))),this.#s(r)}#t(){return this.#o(this.#r(Ca))??[]}#s(e){let n=this.#r(Ca);if(e.length===0){sessionStorage.removeItem(n);return}sessionStorage.setItem(n,JSON.stringify(e))}#r(e){return`${this.#n}:${e}`}#a(){let e=`${Ia}:`,n=[];for(let r=0;r<sessionStorage.length;r+=1){let o=sessionStorage.key(r);if(o===null||!o.startsWith(e))continue;let i=o.slice(e.length);Dv(i)&&n.push([o,this.#r(i)])}for(let[r,o]of n){let i=sessionStorage.getItem(r);i!==null&&sessionStorage.getItem(o)===null&&sessionStorage.setItem(o,i),sessionStorage.removeItem(r)}}#o(e){let n=sessionStorage.getItem(e);if(n===null)return null;try{return JSON.parse(n)}catch{return null}}};function Dv(t){return t===fr||t===Ca||t.startsWith(Ti)||t.startsWith(wi)}function Yu(t){for(let e of t)if(e.role==="user"){let n=Ku(e.content);if(n!=="")return Zu(n,Mv)}return Pv}function Uv(t){for(let e of[...t].reverse()){let n=Ku(e.content);if(n!=="")return Zu(n,Lv)}return""}function Ku(t){return typeof t=="string"?t.replace(/\s+/g," ").trim():""}function Zu(t,e){return t.length<=e?t:`${t.slice(0,e-1).trimEnd()}\u2026`}function Ra(t){return new ru({url:t.endpoint,headers:t.headers??{},initialState:{...t.initialState??{}},fetch:(e,n)=>{let r=t.getHeaders?.();if(r===void 0)return fetch(e,n);let o=new Headers(n?.headers);for(let[i,s]of Object.entries(r))o.set(i,s);return fetch(e,{...n,headers:o})},...t.threadId!==void 0?{threadId:t.threadId}:{},...t.initialMessages!==void 0?{initialMessages:[...t.initialMessages]}:{}})}var mr=class{#n;#e;#t;#s=new Set;#r=new Map;constructor(e,n=()=>({}),r=new ft){this.#n=e.endsWith("/")?e:`${e}/`,this.#e=n,this.#t=r}threadId(){return this.#t.threadId()}setActiveThread(e){this.#t.setActiveThread(e)}saveMessages(e,n){this.#t.saveMessages(e,n)}loadCheckpoint(e){return this.#t.loadCheckpoint(e)}saveCheckpoint(e,n){this.#t.saveCheckpoint(e,n)}renameThread(e,n){this.#t.renameThread(e,n),this.#r.set(e,n),this.#c(e,"PATCH",{title:n})}clear(e){this.#t.clear(e),this.#s.add(e),this.#c(e,"DELETE")}async listThreads(){let e=await this.#a();return e===null?this.#t.listThreads():e.filter(n=>!this.#s.has(n.thread_id)).map(n=>this.#i(n))}async loadMessages(e){let n=await this.#l(`${this.#n}${encodeURIComponent(e)}/`);if(n===null||!n.ok)return this.#t.loadMessages(e);let r=await this.#o(n);return r===null?this.#t.loadMessages(e):r.messages??null}async#a(){let e=await this.#l(this.#n);if(e===null||!e.ok)return null;let n=await this.#o(e);return n===null?null:n.threads??[]}async#o(e){try{return await e.json()}catch{return null}}#i(e){return{threadId:e.thread_id,title:this.#r.get(e.thread_id)??e.title,updatedAt:e.updated_at===null?Number.NaN:Date.parse(e.updated_at),preview:e.preview}}async#l(e){try{return await fetch(e,{headers:this.#e()})}catch{return null}}async#c(e,n,r){let o=this.#e();try{await fetch(`${this.#n}${encodeURIComponent(e)}/`,{method:n,headers:r===void 0?o:{...o,"content-type":"application/json"},body:r===void 0?null:JSON.stringify(r)})}catch{}}};var gr=class{#n;#e;constructor(e,n=()=>({})){this.#n=e.endsWith("/")?e:`${e}/`,this.#e=n}async list(){try{let e=await fetch(this.#n,{method:"GET",headers:{Accept:"application/json",...this.#e()}});return e.ok?(await e.json()).runs??[]:[]}catch{return[]}}async continuable(){return(await this.list()).filter(e=>e.continuable)}resumeUrl(e){return this.#t("resume",e)}forkUrl(e){return this.#t("fork",e)}#t(e,n){return`${this.#n.slice(0,-5)}${e}/${encodeURIComponent(n)}/`}};async function Na(t,e){let n=new FormData;n.append("audio",t,"recording.webm");let r=await fetch(e.url,{method:"POST",headers:{...e.headers??{}},body:n});if(!r.ok)throw new Error(await Hv(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 Hv(t){try{let e=await t.json();if(typeof e.error=="string")return e.error}catch{}return`transcription failed (${t.status})`}function Oa(t,e){return new Promise((n,r)=>{let o=new FormData;o.append("file",t);let i=new XMLHttpRequest;i.open("POST",e.url);for(let[l,c]of Object.entries(e.headers??{}))i.setRequestHeader(l,c);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(Gv(JSON.parse(i.responseText)))}catch{r(new Error("upload returned an unreadable response"))}else r(new Error(zv(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 Gv(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 zv(t){try{let e=JSON.parse(t.responseText);if(typeof e.error=="string")return e.error}catch{}return`upload failed (${t.status})`}var Fv=["data-attachments-url","data-attachment-accept","data-attachment-max-bytes","data-transcribe-url","data-threads-url","data-tools-url","data-skills-url","data-skills","data-prompt-chips","data-slash-commands","data-theme-toggle","data-strings","data-icon-url"],Ju="ag-ui-chat:collapsed",Qu="ag-ui-chat:size",ed="ag-ui-chat:theme",vr=class extends HTMLElement{agentFactory=Ra;headers={};allowImages=!1;autoConfirm=!1;askUser=!1;askUserRenderer=null;approvalRenderer=null;confirmPredicate=null;getTools=()=>[...this.#ce().map(e=>({name:e.name,description:e.description,parameters:e.parameters})),...this.#t.tools()];getContext=()=>[...us(this.getPageMap,this.autoInjectPageMap),...this.#je()];routeMap=[];navigate=null;getPageMap=null;autoInjectPageMap=!0;conversationStore=new ft;uploadHandler=null;transcribeHandler=null;navigationResult=()=>({navigated:!0,url:window.location.href});skillContext=()=>({});toolSummaries={};strings={};resolvePageTarget=e=>document.querySelector(e);#n={};#e=ae;#t=new $n;#s=new Map;#r=new Set;#a;#o;#i;#l;#c;#d;#u;#f;#h;#k=null;#y;#v;#b;#H;#S;#_;#I;#m=null;#G;#q=null;#z=!1;#L=[];#C=null;#N={};#P=!1;#W=null;#x=null;#E=null;#X=0;#F=null;#A=null;#R=null;#p="";#O="";#Y=0;#K=[];#se=[];#ae=[];#le=[];constructor(){super(),this.#a=this.attachShadow({mode:"open"}),this.#o=document.createElement("div"),this.#i=document.createElement("div"),this.#l=document.createElement("textarea"),this.#c=document.createElement("button"),this.#d=document.createElement("span"),this.#y=document.createElement("div"),this.#v=document.createElement("button"),this.#b=document.createElement("input"),this.#H=document.createElement("div"),this.#G=document.createElement("span"),this.#S=document.createElement("button"),this.#_=document.createElement("button"),this.#I=document.createElement("div"),this.#u=new vi(e=>this.#Ze(e)),this.#f=new yi({onSelect:e=>{this.#tt(e)},onNew:()=>{this.newChat(),this.#B()},onRename:(e,n)=>{this.conversationStore.renameThread(e,n),this.#B()},onDelete:e=>{this.#nt(e)}}),this.#h=new ir((e,n)=>{this.#Ce(e,n)})}#Z(){let e=this.getAttribute("data-runs-url");return e===null||e===""?null:(this.#k===null&&(this.#k=new gr(e,()=>this.headers)),this.#k)}async#Ce(e,n){let r=this.#Z();if(r===null)return;let o=this.#l.value.trim();if(o==="")return;this.#l.value="";let i=n==="resume"?r.resumeUrl(e):r.forkUrl(e),s=this.agentFactory({endpoint:i,headers:this.headers,getHeaders:()=>this.headers,threadId:this.#p,initialMessages:[]});await new Ln({agent:s,handlers:this.#_e(),getTools:()=>this.getTools(),getContext:()=>this.#ve(),executeTool:l=>this.#we(l),resolveInterrupts:l=>this.#Se(l),connectionLostMessage:this.#e.connectionLost}).send(o)}async#Re(){let e=this.#Z();this.#h.setRuns(e===null?[]:await e.continuable())}static get observedAttributes(){return["title-text","placement",...Fv]}attributeChangedCallback(e,n,r){if(e==="placement"){this.#Qe(),requestAnimationFrame(()=>this.#ee());return}if(e==="title-text"){this.#d.textContent=r??this.#e.title;return}n===r||!this.#z||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.#t.register(e)}get sharedState(){return this.#C?.state??this.#N}set sharedState(e){this.#N={...e},this.#C?.setState(this.#N)}registerPageState(e){for(let n of Lr(e))this.#t.register(n)}registerStateHook(e){this.registerPageState(e)}#Ne(){return this.routeMap.length===0?[]:ps(()=>this.routeMap,()=>this.navigate)}#Oe(){let e=this.getPageMap;return e===null?[]:[{name:Xi,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:[],[Le]:"Read the page"},handler:()=>e()}]}#Me(){let e=this.getAttribute("data-page-actions");if(e===null)return[];let n=new Set(e.split(",").map(r=>r.trim()).filter(r=>r!==""));return cs(n,r=>this.resolvePageTarget(r))}#ce(){return[...this.#Ne(),...this.#Oe(),...this.#Me(),...this.#Le()]}#Le(){return this.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=>this.#Pe(e)}]:[]}async#Pe(e){let r={question:typeof e.question=="string"?e.question:""},o=e.options;Array.isArray(o)&&(r.options=o.filter(a=>typeof a=="string")),e.allow_custom===!0&&(r.allowCustom=!0),this.#x=new AbortController;let i=this.#x.signal;this.#w();let s=this.askUserRenderer!==null?await this.askUserRenderer(r,{signal:i}):await aa(this.#T(),r,{signal:i,strings:this.#e});return this.#x=null,this.#g(),this.#i.scrollTop=this.#i.scrollHeight,s}#ue(e){let n=this.#ce().find(r=>r.name===e);return n!==void 0?n:this.#t.has(e)?this.#t.get(e):null}get endpoint(){return this.getAttribute("endpoint")??""}set endpoint(e){this.setAttribute("endpoint",e)}get toolDisplay(){let e=this.getAttribute("data-tool-display");return e===dn.INLINE||e===dn.MINIMAL||e===dn.COMPACT?e:dn.FULL}set toolDisplay(e){this.setAttribute("data-tool-display",e)}connectedCallback(){if(this.#O=this.id!==""?this.id:this.endpoint,this.#te(this.#fe()),requestAnimationFrame(()=>this.#ee()),this.#e=hs({...this.#De(),...this.strings}),this.getAttribute("data-theme-toggle")!==null){let e=this.#ne(ed);e!==null&&this.setAttribute("theme",e)}this.#lt(),this.#f.setStrings(this.#e),this.#h.setStrings(this.#e),this.#ne(Ju)==="1"&&this.setAttribute("collapsed",""),this.#xe(),this.#Xe(),this.#We(),this.#O!==""&&this.conversationStore instanceof ft&&(this.conversationStore=new ft(this.#O)),this.#qe(),this.#Ue(),this.#Ge(),this.#p=this.conversationStore.threadId(),this.#ge(),this.#z=!0}disconnectedCallback(){this.#z=!1,this.#M(),this.#m?.dispose(),this.#q?.dispose()}#de(e){let n=this.getAttribute(e);return n!==null&&n!=="false"}#De(){let e=this.getAttribute("data-strings");if(e===null)return{};try{let n=JSON.parse(e);if(typeof n=="object"&&n!==null)return n}catch{}return{}}#Ue(){let e=this.getAttribute("data-attachments-url"),n=this.uploadHandler??this.#He(e);if(n===null)return;let r=this.getAttribute("data-attachment-accept")??"",o=new li({upload:n,maxBytes:this.#$e(),accept:r,strings:this.#e,onChange:()=>this.#ut(o)});this.#m=o,this.#H.appendChild(this.#m.element),this.#b.accept=r,this.#v.hidden=!1,this.#Ve()}#He(e){return e===null?null:(n,r,o)=>Oa(n,{url:e,headers:this.headers,onProgress:r,signal:o})}#Ge(){let e=this.getAttribute("data-transcribe-url"),n=this.transcribeHandler??this.#ze(e);n!==null&&(this.#q=new xi({transcribe:n,onText:r=>this.#Fe(r),strings:this.#e}),this.#G.appendChild(this.#q.element))}#ze(e){return e===null?null:n=>Na(n,{url:e,headers:this.headers})}#Fe(e){let n=this.#l.value.trim();this.#l.value=n===""?e:`${n} ${e}`,this.#Ee(),this.#l.focus()}#$e(){let e=this.getAttribute("data-attachment-max-bytes");if(e===null)return Ki;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>=0?n:Ki}#Be(){let e=this.#b.files;if(e!==null)for(let n of Array.from(e))this.#m?.add(n);this.#b.value=""}#Ve(){this.#o.addEventListener("dragover",e=>{e.preventDefault(),this.#o.classList.add("chat--dragover")}),this.#o.addEventListener("dragleave",()=>{this.#o.classList.remove("chat--dragover")}),this.#o.addEventListener("drop",e=>{e.preventDefault(),this.#o.classList.remove("chat--dragover");let n=e.dataTransfer?.files;if(n!==void 0)for(let r of Array.from(n))this.#m?.add(r)})}#je(){return this.#L.length===0?[]:[{description:"Files the user attached to this message",value:`${this.#L.map(n=>`- ${n.name} (id: ${n.id}, ${n.mime||"unknown type"}, ${n.size} bytes)`).join(`
|
|
2196
|
+
`;var _i=class{element;#n;#e;#t;#s;#r=!1;constructor(e=ae){this.#s=e,this.element=document.createElement("div"),this.element.className="thoughts",this.element.setAttribute("part","thoughts"),this.element.setAttribute("data-streaming",""),this.#t=document.createElement("button"),this.#t.type="button",this.#t.className="thoughts-toggle",this.#t.setAttribute("part","thoughts-toggle"),this.#t.setAttribute("aria-expanded","true"),this.#n=document.createElement("span"),this.#n.className="thoughts-label",this.#n.setAttribute("part","thoughts-label"),this.#n.textContent=e.thinking,this.#t.append(this.#n),this.#e=document.createElement("pre"),this.#e.className="thoughts-body",this.#e.setAttribute("part","thoughts-body"),this.#t.addEventListener("click",()=>{this.#a(!this.#r)}),this.element.append(this.#t,this.#e)}stream(e){this.#e.textContent=e}collapse(){this.#r||(this.element.removeAttribute("data-streaming"),this.#n.textContent=this.#s.thoughts,this.#a(!0))}#a(e){this.#r=e,this.#e.hidden=e,this.#t.setAttribute("aria-expanded",String(!e))}};var Ei=class{element;#n;#e;#t;#s;#r;#a;#i=[];#o="";#l=null;constructor(e,n=ae){this.#n=e,this.#a=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.#e=document.createElement("div"),this.#e.className="drawer-panel",this.#e.setAttribute("part","drawer-panel"),this.#e.setAttribute("role","dialog"),this.#e.setAttribute("aria-modal","true"),this.#e.setAttribute("aria-label",n.chatHistory),this.#e.addEventListener("keydown",i=>this.#d(i));let o=document.createElement("div");o.className="drawer-header",o.setAttribute("part","drawer-header"),this.#t=document.createElement("span"),this.#t.className="drawer-title",this.#t.setAttribute("part","drawer-title"),this.#t.textContent=n.chats,this.#s=document.createElement("button"),this.#s.type="button",this.#s.className="drawer-new",this.#s.setAttribute("part","drawer-new"),this.#s.textContent=n.newChat,this.#s.addEventListener("click",()=>{this.close(),this.#n.onNew()}),o.append(this.#t,this.#s),this.#r=document.createElement("div"),this.#r.className="drawer-list",this.#r.setAttribute("part","drawer-list"),this.#e.append(o,this.#r),this.element.append(r,this.#e)}setStrings(e){this.#a=e,this.#e.setAttribute("aria-label",e.chatHistory),this.#t.textContent=e.chats,this.#s.textContent=e.newChat,this.#u()}isOpen(){return!this.element.hidden}open(){this.isOpen()||(this.#l=this.#c(),this.element.hidden=!1,this.#s.focus())}close(){this.isOpen()&&(this.element.hidden=!0,this.#l?.focus(),this.#l=null)}toggle(){this.isOpen()?this.close():this.open()}#c(){return this.element.getRootNode().activeElement}#d(e){if(e.key==="Escape"){e.preventDefault(),this.close();return}if(e.key!=="Tab")return;let n=Array.from(this.#e.querySelectorAll("button, input, [tabindex]")).filter(s=>!s.hidden),r=n[0],o=n[n.length-1],i=this.#c();e.shiftKey&&i===r?(e.preventDefault(),o?.focus()):!e.shiftKey&&i===o&&(e.preventDefault(),r?.focus())}setThreads(e,n){this.#i=e,this.#o=n,this.#u()}#u(){if(this.#r.replaceChildren(),this.#i.length===0){let e=document.createElement("div");e.className="drawer-empty",e.setAttribute("part","drawer-empty"),e.textContent=this.#a.noConversations,this.#r.appendChild(e);return}for(let e of this.#i)this.#r.appendChild(this.#f(e))}#f(e){let n=document.createElement("div");n.className="drawer-row",n.setAttribute("part","drawer-row"),e.threadId===this.#o&&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=pi(e.updatedAt,void 0,this.#a);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.#n.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.#a.rename,a.setAttribute("aria-label",this.#a.renameConversation),a.textContent="\u270E",a.addEventListener("click",()=>this.#h(n,e));let l=document.createElement("button");l.type="button",l.className="drawer-row-delete",l.setAttribute("part","drawer-row-delete"),l.title=this.#a.delete,l.setAttribute("aria-label",this.#a.deleteConversation),l.textContent="\u{1F5D1}",l.addEventListener("click",()=>this.#I(n,e));let c=document.createElement("div");return c.className="drawer-row-actions",c.setAttribute("part","drawer-row-actions"),c.append(a,l),n.append(r,c),n}#h(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.#u():this.#n.onRename(n.threadId,a)},s=()=>{o||(o=!0,this.#u())};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()}#I(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.#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.#n.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.#a.cancel,s.addEventListener("click",()=>this.#u()),r.append(o,i,s),e.replaceChildren(r)}};function id(t){return{[pe.PENDING]:t.toolRunning,[pe.DONE]:t.toolDone,[pe.ERROR]:t.toolError,[pe.DECLINED]:t.toolDeclined}}function Wv(t){return{[pe.DONE]:t.resultLabel,[pe.ERROR]:t.errorLabel,[pe.DECLINED]:t.declinedLabel}}function Xv(t){try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}var mr=class{element;#n;#e;#t;#s;#r;#a;#i;#o=!1;constructor(e,n,r,o=ae){this.#i=o,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",pe.PENDING),this.element.setAttribute("data-expanded","false");let i=document.createElement("div");i.className="tool-call-head",i.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 a=document.createElement("span");a.className="tool-call-name",a.setAttribute("part","tool-card-name"),a.textContent=r??e,this.#n=document.createElement("span"),this.#n.className="tool-call-status",this.#n.setAttribute("part","tool-card-status"),this.#n.textContent=id(o)[pe.PENDING],this.#e=document.createElement("span"),this.#e.className="tool-call-decision",this.#e.setAttribute("part","tool-card-decision"),this.#e.hidden=!0,i.append(s,a,this.#n,this.#e);let l=this.#l("args",o.argumentsLabel);l.body.textContent=JSON.stringify(n,null,2),l.root.hidden=Object.keys(n).length===0;let c=this.#l("result",o.resultLabel);this.#s=c.root,this.#r=c.label,this.#a=c.body,c.root.hidden=!0,this.#t=document.createElement("button"),this.#t.type="button",this.#t.className="tool-call-toggle",this.#t.setAttribute("part","tool-card-toggle"),this.#t.setAttribute("aria-expanded","false"),this.#t.textContent=o.details,this.#t.addEventListener("click",()=>this.#d(!this.#c()));let h=document.createElement("div");h.className="tool-call-body",h.setAttribute("part","tool-card-body"),h.append(l.root,c.root),this.element.append(i,this.#t,h)}recordDecision(e){this.element.setAttribute("data-decision",e),this.#e.textContent=e==="approved"?this.#i.decisionApproved:this.#i.decisionDeclined,this.#e.hidden=!1}get settled(){return this.#o}settle(e,n){this.#o||(this.#o=!0,this.element.setAttribute("data-status",e),this.#n.textContent=id(this.#i)[e],this.#r.textContent=Wv(this.#i)[e],this.#a.textContent=Xv(n),this.#s.hidden=!1)}#l(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}}#c(){return this.element.getAttribute("data-expanded")==="true"}#d(e){this.element.setAttribute("data-expanded",String(e)),this.#t.setAttribute("aria-expanded",String(e))}};var Ti=class{element;#n;#e;#t;#s="idle";#r=null;#a=null;#i=[];#o=!1;constructor(e){this.#n=e.transcribe,this.#e=e.onText,this.#t=e.strings??ae,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=gl,this.element.append(n),this.#h("idle"),this.element.addEventListener("click",()=>{this.toggle()})}async toggle(){if(this.#s==="recording"){this.#c();return}this.#s!=="transcribing"&&await this.#l()}async#l(){let e;try{e=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{this.#f(this.#t.transcriptionFailed);return}this.#a=e,this.#i=[];let n=new MediaRecorder(e);n.addEventListener("dataavailable",r=>{this.#i.push(r.data)}),n.addEventListener("stop",()=>{this.#d(n.mimeType)}),this.#r=n,n.start(),this.#h("recording")}#c(){this.#r?.stop()}dispose(){this.#o=!0,this.#r!==null&&this.#r.state!=="inactive"&&this.#r.stop(),this.#r=null,this.#u()}async#d(e){if(this.#o)return;this.#u(),this.#h("transcribing");let n=new Blob(this.#i,{type:e||"audio/webm"});try{let r=await this.#n(n);this.#h("idle"),r!==""&&this.#e(r)}catch(r){this.#f(r instanceof Error?r.message:this.#t.transcriptionFailed)}finally{this.#r=null}}#u(){for(let e of this.#a?.getTracks()??[])e.stop();this.#a=null}#f(e){this.#u(),this.#r=null,this.#h("idle"),this.element.title=e}#h(e){this.#s=e,this.element.dataset.state=e;let n=this.#I(e);this.element.title=n,this.element.setAttribute("aria-label",n),this.element.setAttribute("aria-pressed",String(e==="recording")),this.element.disabled=e==="transcribing"}#I(e){return e==="recording"?this.#t.stopRecording:e==="transcribing"?this.#t.transcribing:this.#t.recordVoice}};var wi=class extends Error{constructor(e){super(e),this.name="ConnectionLostError"}},Pn=class{#n;#e;#t;#s;#r;#a;#i;#o=new Set;#l;#c=!1;constructor(e){this.#n=e.agent,this.#e=e.handlers,this.#t=e.getTools??(()=>[]),this.#s=e.getContext??(()=>[]),this.#r=e.executeTool??null,this.#a=e.resolveInterrupts??null,this.#i=e.onPersist??(()=>{}),this.#l=e.connectionLostMessage??"Connection lost";let n=e.onStateChanged;n!==void 0&&this.#n.subscribe({onStateChanged:({state:r})=>{n(r)}})}get state(){return this.#n.state}setState(e){this.#n.setState({...e})}get running(){return this.#n.isRunning}get messages(){return this.#n.messages}async send(e,n=[]){let r={id:Ue(),role:"user",content:e};n.length>0&&(r.attachments=n),this.#n.addMessage(r),this.#i(this.#n.messages),await this.#d()}async resume(){await this.#d()}addToolResult(e,n){this.#n.addMessage({id:Ue(),role:"tool",content:n,toolCallId:e}),this.#i(this.#n.messages)}cancel(){this.#c=!0,this.#n.abortRun()}async#d(){this.#c=!1;try{await this.#f(),this.#c&&this.#u()}catch(e){this.#c||Yv(e)?this.#u():this.#e.onError(e instanceof Error?e.message:String(e))}finally{this.#e.onSettled()}}#u(){this.#i(this.#n.messages),this.#e.onCancelled()}async#f(){let e;for(let n=0;n<Qi;n+=1){if(this.#c)return;let r=[],o={terminal:!1,errored:!1,interrupts:[]},i={tools:this.#t(),context:this.#s()};if(e!==void 0&&(i.resume=e),await this.#n.runAgent(i,this.#h(r,o)),e=void 0,this.#i(this.#n.messages),this.#c)return;if(!o.terminal)throw new wi(this.#l);if(o.errored)return;if(o.interrupts.length>0){if(this.#a===null)return;let a=await this.#a(o.interrupts);if(this.#c)return;e=hu(o.interrupts,a);continue}if(this.#r===null||r.length===0)return;let s=!1;for(let a of r){let l=await this.#r(a);if(l!==null){if(l.halt===!0)return;this.#n.addMessage({id:Ue(),role:"tool",content:l.content,toolCallId:a.id}),this.#i(this.#n.messages),s=!0}}if(!s)return}}#h(e,n){let r=this.#e,o=this.#o;return{onRunInitialized(){r.onRunStart()},onTextMessageStartEvent({event:i}){o.has(i.messageId)&&console.warn(`<ag-ui-chat>: the server reused message id "${i.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:i}){r.onTextDelta(i)},onTextMessageEndEvent({event:i,textMessageBuffer:s}){o.add(i.messageId),r.onTextEnd(s)},onToolCallEndEvent({event:i,toolCallName:s,toolCallArgs:a}){let l={id:i.toolCallId,name:s,args:a};e.push(l),r.onToolCall(l)},onToolCallResultEvent({event:i}){r.onToolResult(i.toolCallId,i.content)},onActivitySnapshotEvent({event:i}){r.onActivity(i.activityType,i.content)},onReasoningStartEvent(){r.onReasoningStart()},onReasoningMessageContentEvent({reasoningMessageBuffer:i}){r.onReasoningDelta(i)},onReasoningEndEvent(){r.onReasoningEnd()},onRunFinishedEvent(i){n.terminal=!0,i.outcome==="interrupt"&&(n.interrupts=i.interrupts)},onRunErrorEvent({event:i}){n.terminal=!0,n.errored=!0,r.onError(i.message)},onRunFinalized(){n.terminal=!0,r.onRunEnd()}}}};function Yv(t){return t instanceof Error&&t.name==="AbortError"}function Oa(t){let e=t.attachments;return Array.isArray(e)?e.filter(Kv):[]}function Kv(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 Ma="ag-ui-chat",gr="thread",La="threads",Si="messages:",Ai="checkpoint:",Zv=60,Jv=100,Qv="New conversation",mt=class{#n;constructor(e=""){this.#n=e===""?Ma:`${Ma}@${e}`,e!==""&&this.#a()}threadId(){let e=this.#r(gr),n=sessionStorage.getItem(e);if(n!==null)return n;let r=Ue();return sessionStorage.setItem(e,r),r}loadMessages(e){return Promise.resolve(this.#i(this.#r(Si+e)))}saveMessages(e,n){sessionStorage.setItem(this.#r(Si+e),JSON.stringify(n)),this.#e(e,n)}loadCheckpoint(e){return this.#i(this.#r(Ai+e))}saveCheckpoint(e,n){let r=this.#r(Ai+e);if(n===null){sessionStorage.removeItem(r);return}sessionStorage.setItem(r,JSON.stringify(n))}clear(e){sessionStorage.removeItem(this.#r(Si+e)),sessionStorage.removeItem(this.#r(Ai+e)),this.#s(this.#t().filter(n=>n.threadId!==e)),sessionStorage.getItem(this.#r(gr))===e&&sessionStorage.removeItem(this.#r(gr))}listThreads(){let e=this.#t().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){sessionStorage.setItem(this.#r(gr),e)}renameThread(e,n){let r=this.#t(),o=r.find(i=>i.threadId===e);o!==void 0&&(o.title=n,o.titleCustom=!0,this.#s(r))}#e(e,n){let r=this.#t(),o=r.find(a=>a.threadId===e),i=tb(n),s=Date.now();o===void 0?r.push({threadId:e,title:sd(n),titleCustom:!1,preview:i,updatedAt:s}):(o.preview=i,o.updatedAt=s,o.titleCustom||(o.title=sd(n))),this.#s(r)}#t(){return this.#i(this.#r(La))??[]}#s(e){let n=this.#r(La);if(e.length===0){sessionStorage.removeItem(n);return}sessionStorage.setItem(n,JSON.stringify(e))}#r(e){return`${this.#n}:${e}`}#a(){let e=`${Ma}:`,n=[];for(let r=0;r<sessionStorage.length;r+=1){let o=sessionStorage.key(r);if(o===null||!o.startsWith(e))continue;let i=o.slice(e.length);eb(i)&&n.push([o,this.#r(i)])}for(let[r,o]of n){let i=sessionStorage.getItem(r);i!==null&&sessionStorage.getItem(o)===null&&sessionStorage.setItem(o,i),sessionStorage.removeItem(r)}}#i(e){let n=sessionStorage.getItem(e);if(n===null)return null;try{return JSON.parse(n)}catch{return null}}};function eb(t){return t===gr||t===La||t.startsWith(Si)||t.startsWith(Ai)}function sd(t){for(let e of t)if(e.role==="user"){let n=ad(e.content);if(n!=="")return ld(n,Zv)}return Qv}function tb(t){for(let e of[...t].reverse()){let n=ad(e.content);if(n!=="")return ld(n,Jv)}return""}function ad(t){return typeof t=="string"?t.replace(/\s+/g," ").trim():""}function ld(t,e){return t.length<=e?t:`${t.slice(0,e-1).trimEnd()}\u2026`}function Be(t,e){return e===void 0?t:{...t,credentials:e}}function Pa(t){return new fu({url:t.endpoint,headers:t.headers??{},initialState:{...t.initialState??{}},fetch:(e,n)=>{let r=t.getHeaders?.();if(r===void 0)return fetch(e,Be(n,t.credentials));let o=new Headers(n?.headers);for(let[i,s]of Object.entries(r))o.set(i,s);return fetch(e,Be({...n,headers:o},t.credentials))},...t.threadId!==void 0?{threadId:t.threadId}:{},...t.initialMessages!==void 0?{initialMessages:[...t.initialMessages]}:{}})}var vr=class{#n;#e;#t;#s;#r=new Set;#a=new Map;constructor(e,n=()=>({}),r=new mt,o=()=>{}){this.#n=e.endsWith("/")?e:`${e}/`,this.#e=n,this.#t=r,this.#s=o}threadId(){return this.#t.threadId()}setActiveThread(e){this.#t.setActiveThread(e)}saveMessages(e,n){this.#t.saveMessages(e,n)}loadCheckpoint(e){return this.#t.loadCheckpoint(e)}saveCheckpoint(e,n){this.#t.saveCheckpoint(e,n)}renameThread(e,n){this.#t.renameThread(e,n),this.#a.set(e,n),this.#d(e,"PATCH",{title:n})}clear(e){this.#t.clear(e),this.#r.add(e),this.#d(e,"DELETE")}async listThreads(){let e=await this.#i();return e===null?this.#t.listThreads():e.filter(n=>!this.#r.has(n.thread_id)).map(n=>this.#l(n))}async loadMessages(e){let n=await this.#c(`${this.#n}${encodeURIComponent(e)}/`);if(n===null||!n.ok)return this.#t.loadMessages(e);let r=await this.#o(n);return r===null?this.#t.loadMessages(e):r.messages??null}async#i(){let e=await this.#c(this.#n);if(e===null||!e.ok)return null;let n=await this.#o(e);return n===null?null:n.threads??[]}async#o(e){try{return await e.json()}catch{return null}}#l(e){return{threadId:e.thread_id,title:this.#a.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,Be({headers:this.#e()},this.#s()))}catch{return null}}async#d(e,n,r){let o=this.#e();try{await fetch(`${this.#n}${encodeURIComponent(e)}/`,Be({method:n,headers:r===void 0?o:{...o,"content-type":"application/json"},body:r===void 0?null:JSON.stringify(r)},this.#s()))}catch{}}};var br=class{#n;#e;#t;constructor(e,n=()=>({}),r=()=>{}){this.#n=e.endsWith("/")?e:`${e}/`,this.#e=n,this.#t=r}async list(){try{let e=await fetch(this.#n,Be({method:"GET",headers:{Accept:"application/json",...this.#e()}},this.#t()));return e.ok?(await e.json()).runs??[]:[]}catch{return[]}}async continuable(){return(await this.list()).filter(e=>e.continuable)}resumeUrl(e){return this.#s("resume",e)}forkUrl(e){return this.#s("fork",e)}#s(e,n){return`${this.#n.slice(0,-5)}${e}/${encodeURIComponent(n)}/`}};async function Da(t,e){let n=new FormData;n.append("audio",t,"recording.webm");let r=await fetch(e.url,Be({method:"POST",headers:{...e.headers??{}},body:n},e.credentials));if(!r.ok)throw new Error(await nb(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 nb(t){try{let e=await t.json();if(typeof e.error=="string")return e.error}catch{}return`transcription failed (${t.status})`}function Ua(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,c]of Object.entries(e.headers??{}))i.setRequestHeader(l,c);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(rb(JSON.parse(i.responseText)))}catch{r(new Error("upload returned an unreadable response"))}else r(new Error(ob(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 rb(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 ob(t){try{let e=JSON.parse(t.responseText);if(typeof e.error=="string")return e.error}catch{}return`upload failed (${t.status})`}var ib=["data-attachments-url","data-attachment-accept","data-attachment-max-bytes","data-transcribe-url","data-threads-url","data-tools-url","data-skills-url","data-skills","data-prompt-chips","data-slash-commands","data-theme-toggle","data-strings","data-icon-url"],za=["omit","same-origin","include"];function Ha(t){return za.includes(t)}var cd="ag-ui-chat:collapsed",ud="ag-ui-chat:size",dd="ag-ui-chat:theme",yr=class extends HTMLElement{agentFactory=Pa;headers={};getHeaders=null;allowImages=!1;autoConfirm=!1;askUser=!1;askUserRenderer=null;approvalRenderer=null;confirmPredicate=null;getTools=()=>[...this.#be().map(e=>({name:e.name,description:e.description,parameters:e.parameters})),...this.#t.tools()];getContext=()=>[...ms(this.getPageMap,this.autoInjectPageMap),...this.#rt()];routeMap=[];navigate=null;getPageMap=null;autoInjectPageMap=!0;conversationStore=new mt;uploadHandler=null;transcribeHandler=null;navigationResult=()=>({navigated:!0,url:window.location.href});skillContext=()=>({});toolSummaries={};strings={};resolvePageTarget=e=>document.querySelector(e);#n={};#e=ae;#t=new Bn;#s=new Map;#r=new Set;#a;#i;#o;#l;#c;#d;#u;#f;#h;#I=null;#x;#v;#b;#$;#S;#y;#A;#B=0;#R;#m=null;#V;#Q=null;#U=!1;#H=[];#N=null;#L={};#z=!1;#ee=null;#_=null;#E=null;#te=0;#j=null;#k=null;#O=null;#p="";#P="";#ne=0;#re=[];#me=[];#ge=[];#ve=[];constructor(){super(),this.#a=this.attachShadow({mode:"open"}),this.#i=document.createElement("div"),this.#o=document.createElement("div"),this.#l=document.createElement("textarea"),this.#c=document.createElement("button"),this.#d=document.createElement("span"),this.#x=document.createElement("div"),this.#v=document.createElement("button"),this.#b=document.createElement("input"),this.#$=document.createElement("div"),this.#V=document.createElement("span"),this.#S=document.createElement("button"),this.#y=document.createElement("button"),this.#A=document.createElement("span"),this.#R=document.createElement("div"),this.#u=new xi(e=>this.#at(e)),this.#f=new Ei({onSelect:e=>{this.#dt(e)},onNew:()=>{this.newChat(),this.#K()},onRename:(e,n)=>{this.conversationStore.renameThread(e,n),this.#K()},onDelete:e=>{this.#pt(e)}}),this.#h=new ar((e,n)=>{this.#Ge(e,n)})}#oe(){let e=this.getAttribute("data-runs-url");return e===null||e===""?null:(this.#I===null&&(this.#I=new br(e,()=>this.#C(),()=>this.#q())),this.#I)}async#Ge(e,n){let r=this.#oe();if(r===null)return;let o=this.#l.value.trim();if(o==="")return;this.#l.value="",this.#G();let i=n==="resume"?r.resumeUrl(e):r.forkUrl(e),s=this.agentFactory({endpoint:i,headers:this.#C(),getHeaders:()=>this.#C(),...this.#W(),threadId:this.#p,initialMessages:[]});await new Pn({agent:s,handlers:this.#De(),getTools:()=>this.getTools(),getContext:()=>this.#Ce(),executeTool:l=>this.#Le(l),resolveInterrupts:l=>this.#Pe(l),connectionLostMessage:this.#e.connectionLost}).send(o)}async#Fe(){let e=this.#oe();this.#h.setRuns(e===null?[]:await e.continuable())}static get observedAttributes(){return["title-text","placement","credentials",...ib]}attributeChangedCallback(e,n,r){if(e==="credentials"){r!==null&&!Ha(r)&&console.error(`<ag-ui-chat>: credentials="${r}" is not a fetch credentials mode (${za.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.#ct(),requestAnimationFrame(()=>this.#ae());return}if(e==="title-text"){this.#d.textContent=r??this.#e.title;return}n===r||!this.#U||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.#t.register(e)}get sharedState(){return this.#N?.state??this.#L}set sharedState(e){this.#L={...e},this.#N?.setState(this.#L)}registerPageState(e){for(let n of Ur(e))this.#t.register(n)}registerStateHook(e){this.registerPageState(e)}#$e(){return this.routeMap.length===0?[]:vs(()=>this.routeMap,()=>this.navigate)}#Be(){let e=this.getPageMap;return e===null?[]:[{name:Ji,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:[],[Le]:"Read the page"},handler:()=>e()}]}#Ve(){let e=this.getAttribute("data-page-actions");if(e===null)return[];let n=new Set(e.split(",").map(r=>r.trim()).filter(r=>r!==""));return fs(n,r=>this.resolvePageTarget(r))}#be(){return[...this.#$e(),...this.#Be(),...this.#Ve(),...this.#je()]}#je(){return this.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=>this.#qe(e)}]:[]}async#qe(e){let r={question:typeof e.question=="string"?e.question:""},o=e.options;Array.isArray(o)&&(r.options=o.filter(a=>typeof a=="string")),e.allow_custom===!0&&(r.allowCustom=!0),this.#_=new AbortController;let i=this.#_.signal;this.#w();let s=this.askUserRenderer!==null?await this.askUserRenderer(r,{signal:i}):await pa(this.#T(),r,{signal:i,strings:this.#e});return this.#_=null,this.#g(),this.#o.scrollTop=this.#o.scrollHeight,s}#ye(e){let n=this.#be().find(r=>r.name===e);return n!==void 0?n:this.#t.has(e)?this.#t.get(e):null}get endpoint(){return this.getAttribute("endpoint")??""}set endpoint(e){this.setAttribute("endpoint",e)}get credentials(){let e=this.getAttribute("credentials");return e!==null&&Ha(e)?e:null}set credentials(e){if(e===null){this.removeAttribute("credentials");return}if(!Ha(e))throw new TypeError(`<ag-ui-chat>: credentials must be one of ${za.map(n=>`"${n}"`).join(", ")} (got ${JSON.stringify(e)}).`);this.setAttribute("credentials",e)}#C(){return{...this.headers,...this.getHeaders?.()}}#q(){return this.credentials??void 0}#W(){let e=this.#q();return e===void 0?{}:{credentials:e}}#xe(){return Be({headers:this.#C()},this.#q())}get toolDisplay(){let e=this.getAttribute("data-tool-display");return e===pn.INLINE||e===pn.MINIMAL||e===pn.COMPACT?e:pn.FULL}set toolDisplay(e){this.setAttribute("data-tool-display",e)}connectedCallback(){if(this.#P=this.id!==""?this.id:this.endpoint,this.#le(this.#Ae()),requestAnimationFrame(()=>this.#ae()),this.#e=bs({...this.#Xe(),...this.strings}),this.getAttribute("data-theme-toggle")!==null){let e=this.#ce(dd);e!==null&&this.setAttribute("theme",e)}this.#bt(),this.#f.setStrings(this.#e),this.#h.setStrings(this.#e),this.#ce(cd)==="1"&&this.setAttribute("collapsed",""),this.#Ne(),this.#it(),this.#P!==""&&this.conversationStore instanceof mt&&(this.conversationStore=new mt(this.#P)),this.#ot(),this.#Ye(),this.#Ze(),this.#p=this.conversationStore.threadId(),queueMicrotask(()=>this.#We()),this.#ue(),this.#U=!0}#We(){this.#U&&(this.#Ee(),this.#Te())}async reload(){this.#M(),this.#Y(),this.#D(!1),await Promise.all([this.#Ee(),this.#Te(),this.#ue()])}disconnectedCallback(){this.#U=!1,this.#M(),this.#m?.dispose(),this.#Q?.dispose()}#_e(e){let n=this.getAttribute(e);return n!==null&&n!=="false"}#Xe(){let e=this.getAttribute("data-strings");if(e===null)return{};try{let n=JSON.parse(e);if(typeof n=="object"&&n!==null)return n}catch{}return{}}#Ye(){let e=this.getAttribute("data-attachments-url"),n=this.uploadHandler??this.#Ke(e);if(n===null)return;let r=this.getAttribute("data-attachment-accept")??"",o=new di({upload:n,maxBytes:this.#et(),accept:r,strings:this.#e,onChange:()=>this.#Tt(o)});this.#m=o,this.#$.appendChild(this.#m.element),this.#b.accept=r,this.#v.hidden=!1,this.#nt()}#Ke(e){return e===null?null:(n,r,o)=>Ua(n,{url:e,headers:this.#C(),...this.#W(),onProgress:r,signal:o})}#Ze(){let e=this.getAttribute("data-transcribe-url"),n=this.transcribeHandler??this.#Je(e);n!==null&&(this.#Q=new Ti({transcribe:n,onText:r=>this.#Qe(r),strings:this.#e}),this.#V.appendChild(this.#Q.element))}#Je(e){return e===null?null:n=>Da(n,{url:e,headers:this.#C(),...this.#W()})}#Qe(e){let n=this.#l.value.trim();this.#l.value=n===""?e:`${n} ${e}`,this.#Oe(),this.#l.focus()}#et(){let e=this.getAttribute("data-attachment-max-bytes");if(e===null)return es;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>=0?n:es}#tt(){let e=this.#b.files;if(e!==null)for(let n of Array.from(e))this.#m?.add(n);this.#b.value=""}#nt(){this.#i.addEventListener("dragover",e=>{e.preventDefault(),this.#i.classList.add("chat--dragover")}),this.#i.addEventListener("dragleave",()=>{this.#i.classList.remove("chat--dragover")}),this.#i.addEventListener("drop",e=>{e.preventDefault(),this.#i.classList.remove("chat--dragover");let n=e.dataTransfer?.files;if(n!==void 0)for(let r of Array.from(n))this.#m?.add(r)})}#rt(){return this.#H.length===0?[]:[{description:"Files the user attached to this message",value:`${this.#H.map(n=>`- ${n.name} (id: ${n.id}, ${n.mime||"unknown type"}, ${n.size} bytes)`).join(`
|
|
1867
2197
|
`)}
|
|
1868
|
-
Use the read_attachment tool with an id to read a file's contents.`}]}#qe(){let e=this.getAttribute("data-threads-url");e!==null&&(this.conversationStore=new mr(e,()=>this.headers,this.conversationStore))}async#We(){let e=this.getAttribute("data-tools-url");if(e!==null)try{let n=await fetch(e,{headers:this.headers});this.#n=ds(await n.json())}catch{}}setSkills(e){this.#le=e,this.#J()}#Xe(){this.#u.enableChips(this.#de("data-prompt-chips")),this.#u.enableSlash(this.#de("data-slash-commands")),this.#ae=this.#Ye(),this.#J(),this.#Ke()}#Ye(){let e=this.getAttribute("data-skills");if(e===null)return[];try{return Qi(JSON.parse(e))}catch{return[]}}async#Ke(){let e=this.getAttribute("data-skills-url");if(e!==null)try{let n=await fetch(e,{headers:this.headers});this.#se=Qi(await n.json()),this.#J()}catch{}}#J(){let e=new Map;for(let n of[...this.#se,...this.#ae,...this.#le])e.set(n.name,n);this.#u.setSkills([...e.values()])}#Ze(e){if(e.prompt===void 0){this.#y.hidden=!0,this.sendMessage(`/${e.name}`);return}let{text:n,missing:r}=sl(e.prompt,this.skillContext());if(r.length>0){this.#y.textContent=this.#e.skillNeeds.replace("{title}",e.title).replace("{fields}",r.join(", ")),this.#y.hidden=!1,this.#l.value=n,this.#l.focus(),this.#Je(n);return}if(this.#y.hidden=!0,this.#l.value=n,e.sendImmediately===!1){this.#l.focus();return}this.#oe()}#Je(e){let n=e.indexOf("{");this.#l.setSelectionRange(n,e.indexOf("}",n)+1)}get collapsed(){return this.hasAttribute("collapsed")}set collapsed(e){this.setCollapsed(e)}setCollapsed(e){e?this.setAttribute("collapsed",""):this.removeAttribute("collapsed"),sessionStorage.setItem(this.#$(Ju),e?"1":"0"),this.#xe(),this.dispatchEvent(new CustomEvent(Vi,{detail:{collapsed:e},bubbles:!0,composed:!0}))}toggleCollapsed(){this.setCollapsed(!this.collapsed)}toggleTheme(){let e=this.getAttribute("theme")==="dark"?"light":"dark";this.setAttribute("theme",e),sessionStorage.setItem(this.#$(ed),e),this.#me()}#Q(){switch(this.getAttribute("placement")){case"full":case"page":return"none";case"sidebar":case"side":return"width";default:return"both"}}#pe(){let e=this.getBoundingClientRect(),n=this.style.getPropertyValue("--ag-ui-width"),r=this.style.getPropertyValue("--ag-ui-height");this.#te({width:e.width+1,height:e.height+1});let o=this.getBoundingClientRect();return this.#he("--ag-ui-width",n),this.#he("--ag-ui-height",r),{x:Math.abs(o.left-e.left)<.5?"left":"right",y:Math.abs(o.top-e.top)<.5?"top":"bottom"}}#ee(){if(!this.#z)return;let e=this.#pe();this.setAttribute("data-resize-anchor",`${e.y}-${e.x}`)}#he(e,n){if(n===""){this.style.removeProperty(e);return}this.style.setProperty(e,n)}#te(e){let n=this.#Q();n!=="none"&&(e.width!==void 0&&this.style.setProperty("--ag-ui-width",`${e.width}px`),e.height!==void 0&&n==="both"&&this.style.setProperty("--ag-ui-height",`${e.height}px`))}#Qe(){let e=this.#Q();e!=="both"&&this.style.removeProperty("--ag-ui-height"),e==="none"&&this.style.removeProperty("--ag-ui-width")}#et(e){let n={...this.#fe(),...e};sessionStorage.setItem(this.#$(Qu),JSON.stringify(n))}#fe(){let e=this.#ne(Qu);if(e===null)return{};try{let n=JSON.parse(e);return typeof n=="object"&&n!==null?n:{}}catch{return{}}}#$(e){return this.#O===""?e:`${e}:${this.#O}`}#ne(e){let n=sessionStorage.getItem(this.#$(e));return n!==null||this.#O===""?n:sessionStorage.getItem(e)}#me(){let e=this.getAttribute("theme")==="dark";this.#S.textContent=e?"\u2600\uFE0F":"\u{1F319}"}newChat(){this.#M(),this.conversationStore.clear(this.#p),this.#re(),this.#p=this.conversationStore.threadId(),this.#D(!1)}#re(){this.#C=null,this.#E=null,this.#A=null,this.#R=null,this.#w(),this.#s.clear(),this.#r.clear(),this.#K=[],this.#L=[],this.#m?.clear(),this.#i.replaceChildren(this.#I),this.#g()}async#tt(e){e!==this.#p&&(this.#M(),this.#re(),this.conversationStore.setActiveThread(e),this.#p=e,this.#D(!1),await this.#ge())}#nt(e){let n=e===this.#p;n&&this.#M(),this.conversationStore.clear(e),n&&(this.#re(),this.#p=this.conversationStore.threadId(),this.#D(!1)),this.#B()}async#B(){this.#f.setThreads(await this.conversationStore.listThreads(),this.#p)}async#ge(){this.#Y+=1;let e=this.#Y,n=await this.conversationStore.loadMessages(this.#p);if(e!==this.#Y)return;if(n!==null){this.#K=n;for(let o of n)this.#it(o)}let r=this.conversationStore.loadCheckpoint(this.#p);if(r!==null){await this.#at(r);return}this.#ot(n)}#ve(){return this.#W=window.location.href,this.getContext()}#rt(){return this.#W!==null&&this.#W!==window.location.href}#ot(e){let n=e?.at(-1);n===void 0||n.role!==Ve.USER||this.#j("\u26A0",this.#e.runInterrupted,"interrupted")}#it(e){let n=typeof e.content=="string"?e.content:"";if(e.role===Ve.USER){let r=ka(e);if(n!==""||r.length>0){let o=this.appendMessage(Ve.USER,n);r.length>0&&o.appendChild(gs(r))}return}if(e.role===Ve.ASSISTANT){n!==""&&this.appendMessage(Ve.ASSISTANT,n).classList.add("message--restored");let r=e.toolCalls;if(r!==void 0)for(let o of r){let i={id:o.id,name:o.function.name,args:this.#st(o.function.arguments)};this.#Ie(i)||this.#ie(i)}return}if(e.role==="tool"){let r=this.#s.get(e.toolCallId);r!==void 0&&r.settle(pe.DONE,e.content)}}#st(e){try{let n=JSON.parse(e);if(typeof n=="object"&&n!==null)return n}catch{}return{}}#be(e){this.getAttribute("data-text-animation")==="word"&&ju(e)}async#at(e){this.conversationStore.saveCheckpoint(this.#p,null);let n=this.#Te();n.addToolResult(e.toolCallId,JSON.stringify(this.navigationResult(e))),await n.resume()}appendMessage(e,n){let r=document.createElement("div");return r.className=`message message--${e}`,r.setAttribute("part",`message message-${e}`),e===Ve.ASSISTANT?(r.innerHTML=gi(n,{allowImages:this.allowImages}),ms(r,this.#e),this.#T().appendChild(r)):(this.#A=null,r.textContent=n,this.#i.appendChild(r)),this.#g(),this.#i.scrollTop=this.#i.scrollHeight,r}#T(){if(this.#A===null){let e=document.createElement("div");e.className="answer",e.setAttribute("part","answer"),this.#A=e,this.#i.appendChild(e),this.#g()}return this.#A}#lt(){let e=document.createElement("style");e.textContent=Wu,this.#o.className="chat",this.#o.setAttribute("part","panel");let n=document.createElement("div");n.className="header",n.setAttribute("part","header");let r=this.#d;r.className="header-title",r.setAttribute("part","title"),r.textContent=this.getAttribute("title-text")??this.#e.title,(this.querySelector('[slot="icon"]')!==null||this.getAttribute("data-icon-url")!==null)&&n.append(this.#ye("icon","icon",null));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=this.#V("history",this.#e.chatHistory,"\u2630");s.addEventListener("click",()=>{this.#B(),this.#f.open()});let a=this.#V("checkpoints",this.#e.checkpoints,"\u2B6F");a.addEventListener("click",()=>{this.#Re(),this.#h.open()});let l=this.#V("new",this.#e.newChat,"\u271A");l.addEventListener("click",()=>this.newChat());let c=this.#V("collapse",this.#e.collapse,"\u2014");c.addEventListener("click",()=>this.toggleCollapsed()),this.#Z()!==null?i.append(s,a,l):i.append(s,l),this.getAttribute("data-theme-toggle")!==null&&(this.#S.type="button",this.#S.className="header-btn header-btn--theme",this.#S.setAttribute("part","header-button theme-toggle"),this.#S.title=this.#e.toggleTheme,this.#S.setAttribute("aria-label",this.#e.toggleTheme),this.#S.addEventListener("click",()=>this.toggleTheme()),this.#me(),i.append(this.#S)),i.append(c),n.append(r,o,i),this.#i.className="messages",this.#i.setAttribute("part","messages"),this.#i.setAttribute("role","log"),this.#i.setAttribute("aria-live","polite"),this.#i.setAttribute("aria-label",this.#e.conversation),this.#I.className="empty",this.#I.setAttribute("part","empty");let h=document.createElement("slot");h.name="empty",this.#I.append(h),this.#i.append(this.#I);let m=document.createElement("div");m.className="input-row",m.setAttribute("part","composer"),this.#l.className="input",this.#l.setAttribute("part","input"),this.#l.setAttribute("aria-label",this.#e.message),this.#l.rows=2,this.#l.placeholder=this.#e.inputPlaceholder,this.#l.addEventListener("keydown",f=>this.#ct(f)),this.#l.addEventListener("input",()=>this.#Ee()),this.#c.className="send",this.#c.type="button",this.#c.setAttribute("part","send"),this.#c.textContent=this.#e.send,this.#c.setAttribute("aria-label",this.#e.send),this.#c.dataset.state="idle",this.#c.addEventListener("click",()=>{if(this.#P){this.#M();return}this.#oe()}),this.#y.className="skill-hint",this.#y.setAttribute("part","skill-hint"),this.#y.hidden=!0,this.#v.className="attach-btn",this.#v.type="button",this.#v.setAttribute("part","attach-button"),this.#v.textContent="\u{1F4CE}",this.#v.title=this.#e.attachFiles,this.#v.setAttribute("aria-label",this.#e.attachFiles),this.#v.hidden=!0,this.#v.addEventListener("click",()=>this.#b.click()),this.#b.className="attach-input",this.#b.type="file",this.#b.multiple=!0,this.#b.hidden=!0,this.#b.addEventListener("change",()=>this.#Be()),this.#H.className="attachment-slot",this.#G.className="voice-slot";let y=document.createElement("slot");y.name="footer",m.append(this.#v,this.#G,this.#l,this.#c,this.#b),this.#o.append(n,this.#i,this.#u.palette,this.#u.chips,this.#y,this.#H,m,y,this.#f.element,this.#h.element),this.#_.className="rail",this.#_.type="button",this.#_.setAttribute("part","launcher"),this.#_.setAttribute("aria-label",this.#e.expand),this.#_.append(this.#ye("launcher","launcher-icon","\u{1F4AC}")),this.#_.addEventListener("click",()=>this.setCollapsed(!1)),this.#o.append(Bu({axis:()=>this.#Q(),anchor:()=>this.#pe(),rect:()=>this.getBoundingClientRect(),apply:f=>this.#te(f),commit:f=>{this.#et(f),this.#ee()},label:this.#e.resizePanel})),this.#a.append(e,this.#o,this.#_)}#V(e,n,r){let o=document.createElement("button");o.type="button",o.className=`header-btn header-btn--${e}`,o.setAttribute("part",`header-button ${e}-button`),o.title=n,o.setAttribute("aria-label",n);let i=document.createElement("slot");return i.name=`icon-${e}`,i.append(document.createTextNode(r)),o.append(i),o}#ye(e,n,r){let o=document.createElement("span");o.className="icon-holder",o.setAttribute("part",n);let i=document.createElement("slot");i.name=e;let s=this.getAttribute("data-icon-url");if(s!==null){let a=document.createElement("img");a.className="icon-img",a.src=s,a.alt="",i.append(a)}else r!==null&&i.append(document.createTextNode(r));return o.append(i),o}#xe(){this.#_.setAttribute("aria-expanded",String(!this.collapsed))}#g(){this.#I.hidden=this.#i.childElementCount>1}#Ee(){this.#u.onInput(this.#l.value),this.#y.hidden=!0}#ct(e){if(this.#u.onKeydown(e)){e.preventDefault();return}if(e.key==="Escape"&&this.#P){e.preventDefault(),this.#M();return}e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),this.#oe())}#M(){this.#x?.abort(),this.#C?.cancel()}#D(e){this.#P=e;let n=e?this.#e.stop:this.#e.send;this.#c.textContent=n,this.#c.setAttribute("aria-label",n),this.#c.dataset.state=e?"running":"idle"}async#oe(){if(this.#P)return;let e=this.#l.value.trim(),n=this.#m?.readyRefs()??[];e===""&&n.length===0||(this.#l.value="",this.#m?.hasPending()===!0&&this.#j("\u{1F4CE}",this.#e.attachmentsStillUploading.replace("{n}",String(this.#m.pendingCount())),"attachment-pending"),this.#m?.clearReady(),await this.sendMessage(e,n))}async sendMessage(e,n=[]){if(this.#P||e===""&&n.length===0)return;let r=this.appendMessage(Ve.USER,e);n.length>0&&r.appendChild(gs(n)),this.#L=n,this.dispatchEvent(new CustomEvent(Bi,{detail:{content:e,attachments:n},bubbles:!0,composed:!0})),await this.#dt(e,n)}attachFile(e){return this.#m===null?!1:(this.#m.add(e),!0)}#ut(e){this.dispatchEvent(new CustomEvent(qi,{detail:{attachments:e.readyRefs(),pending:e.pendingCount()},bubbles:!0,composed:!0}))}async#dt(e,n){this.endpoint!==""&&await this.#Te().send(e,n)}#Te(){if(this.#C===null){let e=this.agentFactory({endpoint:this.endpoint,headers:this.headers,getHeaders:()=>this.headers,threadId:this.#p,initialMessages:this.#K,initialState:this.#N});this.#C=new Ln({agent:e,handlers:this.#_e(),getTools:()=>this.getTools(),getContext:()=>this.#ve(),executeTool:n=>this.#we(n),resolveInterrupts:n=>this.#Se(n),onPersist:n=>this.conversationStore.saveMessages(this.#p,n),onStateChanged:n=>this.#pt(n),connectionLostMessage:this.#e.connectionLost})}return this.#C}#pt(e){this.#N={...e},this.dispatchEvent(new CustomEvent(ji,{detail:{state:this.#N},bubbles:!0,composed:!0}))}async#ht(e,n){return this.autoConfirm?!1:this.confirmPredicate!==null?await this.confirmPredicate(e.name,e.args)===!0:es(n.parameters)}async#we(e){if(td(e)!==null)return null;let n=this.#ie(e);this.#s.delete(e.id);let r=this.#ue(e.name);if(r===null)return this.#r.has(e.id)||n.settle(pe.DONE,this.#e.noResult),null;if(this.getPageMap!==null&&e.name!==Xi&&!Nr(r.parameters)&&this.#rt()){let i=this.#e.pageMoved;return n.settle(pe.ERROR,i),this.#U(),{content:`Error: ${i}`,error:i}}if(await this.#ht(e,r)){let i={toolName:e.name,args:e.args},s=r.parameters[Wi];typeof s=="string"&&(i.message=s),this.#x=new AbortController;let a=ia(this.#T(),i,{signal:this.#x.signal,strings:this.#e});this.#g(),this.#i.scrollTop=this.#i.scrollHeight;let l=await a;if(this.#x=null,n.recordDecision(l?"approved":"declined"),!l){let c=this.#e.declinedAction;return n.settle(pe.DECLINED,c),this.#U(),{content:c}}}let o=Nr(r.parameters)&&this.navigate===null;o&&this.conversationStore.saveCheckpoint(this.#p,{toolCallId:e.id});try{let i=await r.handler(e.args);if(o)return n.settle(pe.DONE,this.#e.navigating),{content:"",halt:!0};let s=JSON.stringify(i??null);return n.settle(pe.DONE,s),this.#U(),{content:s}}catch(i){o&&this.conversationStore.saveCheckpoint(this.#p,null);let s=i instanceof Error?i.message:String(i);return n.settle(pe.ERROR,s),this.#U(),{content:`Error: ${s}`,error:s}}}async#Se(e){let n={};this.#x=new AbortController,this.#w();for(let r of e){let o={};r.message!==void 0&&(o.message=r.message);let i=r.toolCallId!==void 0?this.#s.get(r.toolCallId):void 0,s=i?.element.getAttribute("data-tool-name");s!=null&&(o.toolName=s);let a=this.#x.signal,l=this.approvalRenderer!==null?await this.approvalRenderer(o,{signal:a}):await fs(this.#T(),o,{signal:a,strings:this.#e});this.#g(),this.#i.scrollTop=this.#i.scrollHeight,i?.recordDecision(l?"approved":"declined"),l?n[r.id]={status:"resolved",payload:{approved:!0}}:(n[r.id]={status:"cancelled"},i?.settle(pe.DECLINED,this.#e.declinedAction))}return this.#x=null,n}#_e(){return{onRunStart:()=>{this.#D(!0),this.#T(),this.#U()},onReasoningStart:()=>{this.#w(),this.#Ae()},onReasoningDelta:e=>{this.#Ae().stream(e)},onReasoningEnd:()=>{},onTextDelta:e=>{this.#w(),this.#R?.collapse(),this.#ke(e),this.#X+=1},onTextEnd:e=>{let n=this.#ke(e);this.#X<=1&&this.#be(n),ms(n,this.#e),this.#E=null},onToolCall:e=>{this.#w(),!this.#Ie(e)&&this.#ie(e)},onActivity:(e,n)=>{if(e!==Zi)return;let r=$v(n);r!==null&&this.#j("\u{1F5DC}",this.#e.historyCompacted.replace("{count}",String(r)),"compaction")},onToolResult:(e,n)=>{let r=this.#s.get(e);r!==void 0&&(r.settle(pe.DONE,n),this.#r.add(e))},onRunEnd:()=>{this.#w(),this.#E=null},onError:e=>{this.#w(),this.#be(this.appendMessage(Ve.ASSISTANT,`\u26A0\uFE0F ${e}`)),this.#E=null},onCancelled:()=>{this.#w(),this.#ft(),this.#E=null},onSettled:()=>{this.#w(),this.#D(!1),this.#E=null,this.#L=[];for(let e of this.#s.values())e.settled||e.settle(pe.DONE,this.#e.noResult);this.#A!==null&&this.#A.childElementCount===0&&(this.#A.remove(),this.#g()),this.#A=null,this.#R=null}}}#ft(){let e=document.createElement("div");e.className="stopped-note",e.setAttribute("part","stopped"),e.setAttribute("role","status"),e.textContent=this.#e.stopped,this.#T().appendChild(e),this.#g(),this.#i.scrollTop=this.#i.scrollHeight}#U(){if(this.#F!==null)return;let e=document.createElement("div");e.className="pending",e.setAttribute("part","pending"),e.setAttribute("role","status"),e.setAttribute("aria-label",this.#e.thinking);for(let n=0;n<3;n+=1){let r=document.createElement("span");r.className="pending-dot",e.appendChild(r)}this.#F=e,this.#T().appendChild(e),this.#g(),this.#i.scrollTop=this.#i.scrollHeight}#w(){this.#F?.remove(),this.#F=null}#Ae(){if(this.#R===null){this.#R=new bi(this.#e);let e=this.#T();e.insertBefore(this.#R.element,e.firstChild),this.#g(),this.#i.scrollTop=this.#i.scrollHeight}return this.#R}#ke(e){return this.#E===null&&(this.#E=this.appendMessage(Ve.ASSISTANT,""),this.#X=0),this.#E.innerHTML=gi(e,{allowImages:this.allowImages}),this.#i.scrollTop=this.#i.scrollHeight,this.#E}#Ie(e){let n=td(e);return n===null?!1:(this.#j("\u2728",this.#e.usingSkill.replace("{name}",n),"skill"),!0)}#j(e,n,r){this.#T().appendChild(qu(e,n,r)),this.#g(),this.#i.scrollTop=this.#i.scrollHeight}#ie(e){let n=this.#s.get(e.id);if(n!==void 0)return n;let r=this.#ue(e.name)?.parameters[Le],o=typeof r=="string"?r:this.toolSummaries[e.name]??this.#n[e.name]??sa(e.name),i=new hr(e.name,e.args,o,this.#e);return this.#s.set(e.id,i),this.#T().appendChild(i.element),this.#g(),this.#i.scrollTop=this.#i.scrollHeight,i}};function td(t){if(t.name!==Ji)return null;let e=t.args?.id;return typeof e=="string"&&e!==""?e:null}function $v(t){let e=t?.removed;return typeof e=="number"?e:null}function Bv(){customElements.get(Rr)===void 0&&customElements.define(Rr,vr)}async function Vv(t,e,n={}){at(t),await rs(t,{flashMs:n.flashMs??0}),await ts(t,e,n)}async function jv(t,e={}){at(t),await ns(t,e)}async function qv(t,e={}){at(t),await is(t,e)}async function Wv(t,e,n={}){at(t),await ss(t,e,n)}async function Xv(t,e,n={}){at(t),await as(t,e,n)}function Yv(t,e){t instanceof HTMLInputElement&&t.type==="checkbox"?Bn(t,!!e):Rt(t,String(e)),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}var Kv="0.20.1";export{qi as ATTACHMENT_EVENT,vr as AgUiChat,Ln as AgUiClient,Zi as COMPACTION_ACTIVITY_TYPE,ir as CheckpointMenu,$n as ClientToolRegistry,Ei as ConnectionLostError,ae as DEFAULT_UI_STRINGS,Rr as ELEMENT_TAG,Ji as LOAD_CAPABILITY_TOOL,Yi as MAX_TOOL_ROUNDS,Ve as MESSAGE_ROLE,ls as PAGE_ACTIONS,mr as RemoteConversationStore,gr as RunIndex,ji as STATE_EVENT,Bi as SUBMIT_EVENT,ft as SessionStorageStore,Vi as TOGGLE_EVENT,pe as TOOL_CALL_STATUS,dn as TOOL_DISPLAY,hr as ToolCallCard,Kv as VERSION,Wi as X_CONFIRM_KEY,zn as X_DESTRUCTIVE_KEY,Fn as X_NAVIGATES_KEY,Le as X_SUMMARY_KEY,jv as clickElement,Ra as createHttpAgent,cs as createPageActionTools,us as createPageMapContext,Lr as createPageStateTools,ps as createRouteTools,Fd as createStateHookTools,Bv as defineAgUiChat,Vv as fillField,rs as focusWithFlash,ns as highlightThenClick,es as isDestructive,Nr as isNavigates,hs as mergeUiStrings,ka as messageAttachments,ds as parseToolCatalog,cl as prefersReducedMotion,qv as pressButton,is as pressThenClick,sa as prettifyToolName,gi as renderMarkdown,fs as requestApproval,ia as requestConfirmation,aa as requestQuestion,at as scrollIntoCenterView,Wv as selectControl,ss as selectOption,Yv as setControlValue,Bn as setNativeChecked,Rt as setNativeValue,Xv as toggleCheckbox,as as toggleControl,Na as transcribeAudio,ts as typeInto,Oa as uploadAttachment};
|
|
2198
|
+
Use the read_attachment tool with an id to read a file's contents.`}]}#ot(){let e=this.getAttribute("data-threads-url");e!==null&&(this.conversationStore=new vr(e,()=>this.#C(),this.conversationStore,()=>this.#q()))}async#Ee(){let e=this.getAttribute("data-tools-url");if(e!==null)try{let n=await fetch(e,this.#xe());this.#n=gs(await n.json())}catch{}}setSkills(e){this.#ve=e,this.#ie()}#it(){this.#u.enableChips(this.#_e("data-prompt-chips")),this.#u.enableSlash(this.#_e("data-slash-commands")),this.#ge=this.#st(),this.#ie()}#st(){let e=this.getAttribute("data-skills");if(e===null)return[];try{return rs(JSON.parse(e))}catch{return[]}}async#Te(){let e=this.getAttribute("data-skills-url");if(e!==null)try{let n=await fetch(e,this.#xe());this.#me=rs(await n.json()),this.#ie()}catch{}}#ie(){let e=new Map;for(let n of[...this.#me,...this.#ge,...this.#ve])e.set(n.name,n);this.#u.setSkills([...e.values()])}#at(e){if(e.prompt===void 0){this.#x.hidden=!0,this.sendMessage(`/${e.name}`);return}let{text:n,missing:r}=bl(e.prompt,this.skillContext());if(r.length>0){this.#x.textContent=this.#e.skillNeeds.replace("{title}",e.title).replace("{fields}",r.join(", ")),this.#x.hidden=!1,this.#l.value=n,this.#G(),this.#l.focus(),this.#lt(n);return}if(this.#x.hidden=!0,this.#l.value=n,this.#G(),e.sendImmediately===!1){this.#l.focus();return}this.#he()}#lt(e){let n=e.indexOf("{");this.#l.setSelectionRange(n,e.indexOf("}",n)+1)}get collapsed(){return this.hasAttribute("collapsed")}set collapsed(e){this.setCollapsed(e)}setCollapsed(e){e?this.setAttribute("collapsed",""):this.removeAttribute("collapsed"),sessionStorage.setItem(this.#X(cd),e?"1":"0"),this.#pe(0),this.dispatchEvent(new CustomEvent(Wi,{detail:{collapsed:e},bubbles:!0,composed:!0}))}get unread(){return this.#B}toggleCollapsed(){this.setCollapsed(!this.collapsed)}toggleTheme(){let e=this.getAttribute("theme")==="dark"?"light":"dark";this.setAttribute("theme",e),sessionStorage.setItem(this.#X(dd),e),this.#ke()}#se(){switch(this.getAttribute("placement")){case"full":case"page":return"none";case"sidebar":case"side":return"width";default:return"both"}}#we(){let e=this.getBoundingClientRect(),n=this.style.getPropertyValue("--ag-ui-width"),r=this.style.getPropertyValue("--ag-ui-height");this.#le({width:e.width+1,height:e.height+1});let o=this.getBoundingClientRect();return this.#Se("--ag-ui-width",n),this.#Se("--ag-ui-height",r),{x:Math.abs(o.left-e.left)<.5?"left":"right",y:Math.abs(o.top-e.top)<.5?"top":"bottom"}}#ae(){if(!this.#U)return;let e=this.#we();this.setAttribute("data-resize-anchor",`${e.y}-${e.x}`)}#Se(e,n){if(n===""){this.style.removeProperty(e);return}this.style.setProperty(e,n)}#le(e){let n=this.#se();n!=="none"&&(e.width!==void 0&&this.style.setProperty("--ag-ui-width",`${e.width}px`),e.height!==void 0&&n==="both"&&this.style.setProperty("--ag-ui-height",`${e.height}px`))}#ct(){let e=this.#se();e!=="both"&&this.style.removeProperty("--ag-ui-height"),e==="none"&&this.style.removeProperty("--ag-ui-width")}#ut(e){let n={...this.#Ae(),...e};sessionStorage.setItem(this.#X(ud),JSON.stringify(n))}#Ae(){let e=this.#ce(ud);if(e===null)return{};try{let n=JSON.parse(e);return typeof n=="object"&&n!==null?n:{}}catch{return{}}}#X(e){return this.#P===""?e:`${e}:${this.#P}`}#ce(e){let n=sessionStorage.getItem(this.#X(e));return n!==null||this.#P===""?n:sessionStorage.getItem(e)}#ke(){let e=this.getAttribute("theme")==="dark";this.#S.textContent=e?"\u2600\uFE0F":"\u{1F319}"}openThreads(){this.#K(),this.#f.open()}openCheckpoints(){this.#Fe(),this.#h.open()}newChat(){this.#M(),this.conversationStore.clear(this.#p),this.#Y(),this.#p=this.conversationStore.threadId(),this.#D(!1),this.#pe(0)}#Y(){this.#N=null,this.#E=null,this.#k=null,this.#O=null,this.#w(),this.#s.clear(),this.#r.clear(),this.#re=[],this.#H=[],this.#m?.clear(),this.#o.replaceChildren(this.#R),this.#g()}async#dt(e){e!==this.#p&&(this.#M(),this.#Y(),this.conversationStore.setActiveThread(e),this.#p=e,this.#D(!1),await this.#ue())}#pt(e){let n=e===this.#p;n&&this.#M(),this.conversationStore.clear(e),n&&(this.#Y(),this.#p=this.conversationStore.threadId(),this.#D(!1)),this.#K()}async#K(){this.#f.setThreads(await this.conversationStore.listThreads(),this.#p)}async#ue(){this.#ne+=1;let e=this.#ne,n=await this.conversationStore.loadMessages(this.#p);if(e!==this.#ne)return;if(n!==null){this.#re=n;for(let o of n)this.#mt(o)}let r=this.conversationStore.loadCheckpoint(this.#p);if(r!==null){await this.#vt(r);return}this.#ft(n)}#Ce(){return this.#ee=window.location.href,this.getContext()}#ht(){return this.#ee!==null&&this.#ee!==window.location.href}#ft(e){let n=e?.at(-1);n===void 0||n.role!==je.USER||this.#J("\u26A0",this.#e.runInterrupted,"interrupted")}#mt(e){let n=typeof e.content=="string"?e.content:"";if(e.role===je.USER){let r=Oa(e);if(n!==""||r.length>0){let o=this.appendMessage(je.USER,n);r.length>0&&o.appendChild(_s(r))}return}if(e.role===je.ASSISTANT){n!==""&&this.appendMessage(je.ASSISTANT,n).classList.add("message--restored");let r=e.toolCalls;if(r!==void 0)for(let o of r){let i={id:o.id,name:o.function.name,args:this.#gt(o.function.arguments)};this.#ze(i)||this.#fe(i)}return}if(e.role==="tool"){let r=this.#s.get(e.toolCallId);r!==void 0&&r.settle(pe.DONE,e.content)}}#gt(e){try{let n=JSON.parse(e);if(typeof n=="object"&&n!==null)return n}catch{}return{}}#Ie(e){this.getAttribute("data-text-animation")==="word"&&nd(e)}async#vt(e){this.conversationStore.saveCheckpoint(this.#p,null);let n=this.#Me();n.addToolResult(e.toolCallId,JSON.stringify(this.navigationResult(e))),await n.resume()}appendMessage(e,n){let r=document.createElement("div");return r.className=`message message--${e}`,r.setAttribute("part",`message message-${e}`),e===je.ASSISTANT?(r.innerHTML=yi(n,{allowImages:this.allowImages}),xs(r,this.#e),this.#T().appendChild(r)):(this.#k=null,r.textContent=n,this.#o.appendChild(r)),this.#g(),this.#o.scrollTop=this.#o.scrollHeight,r}#T(){if(this.#k===null){let e=document.createElement("div");e.className="answer",e.setAttribute("part","answer"),this.#k=e,this.#o.appendChild(e),this.#g()}return this.#k}#bt(){let e=document.createElement("style");e.textContent=od,this.#i.className="chat",this.#i.setAttribute("part","panel");let n=document.createElement("div");n.className="header",n.setAttribute("part","header");let r=this.#d;r.className="header-title",r.setAttribute("part","title"),r.textContent=this.getAttribute("title-text")??this.#e.title,(this.querySelector('[slot="icon"]')!==null||this.getAttribute("data-icon-url")!==null)&&n.append(this.#Re("icon","icon",null));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=this.#Z("history",this.#e.chatHistory,"\u2630");s.addEventListener("click",()=>this.openThreads());let a=this.#Z("checkpoints",this.#e.checkpoints,"\u2B6F");a.addEventListener("click",()=>this.openCheckpoints());let l=this.#Z("new",this.#e.newChat,"\u271A");l.addEventListener("click",()=>this.newChat());let c=this.#Z("collapse",this.#e.collapse,"\u2014");c.addEventListener("click",()=>this.toggleCollapsed()),this.#oe()!==null?i.append(s,a,l):i.append(s,l),this.getAttribute("data-theme-toggle")!==null&&(this.#S.type="button",this.#S.className="header-btn header-btn--theme",this.#S.setAttribute("part","header-button theme-toggle"),this.#S.title=this.#e.toggleTheme,this.#S.setAttribute("aria-label",this.#e.toggleTheme),this.#S.addEventListener("click",()=>this.toggleTheme()),this.#ke(),i.append(this.#S)),i.append(c),n.append(r,o,i),this.#o.className="messages",this.#o.setAttribute("part","messages"),this.#o.setAttribute("role","log"),this.#o.setAttribute("aria-live","polite"),this.#o.setAttribute("aria-label",this.#e.conversation),this.#R.className="empty",this.#R.setAttribute("part","empty");let h=document.createElement("slot");h.name="empty",this.#R.append(h),this.#o.append(this.#R);let m=document.createElement("div");m.className="input-row",m.setAttribute("part","composer");let y=document.createElement("div");y.className="composer",y.setAttribute("part","composer-surface");let f=document.createElement("div");f.className="composer-tools",f.setAttribute("part","composer-tools"),this.#l.className="input",this.#l.setAttribute("part","input"),this.#l.setAttribute("aria-label",this.#e.message),this.#l.rows=1,this.#l.placeholder=this.#e.inputPlaceholder,this.#l.addEventListener("keydown",g=>this.#Et(g)),this.#l.addEventListener("input",()=>this.#Oe()),this.#c.className="send",this.#c.type="button",this.#c.setAttribute("part","send"),this.#c.append(this.#de("icon-send","send-send",hl),this.#de("icon-stop","send-stop",fl)),this.#c.title=this.#e.send,this.#c.setAttribute("aria-label",this.#e.send),this.#c.dataset.state="idle",this.#c.addEventListener("click",()=>{if(this.#z){this.#M();return}this.#he()}),this.#x.className="skill-hint",this.#x.setAttribute("part","skill-hint"),this.#x.hidden=!0,this.#v.className="attach-btn",this.#v.type="button",this.#v.setAttribute("part","attach-button"),this.#v.append(this.#de("icon-attach","attach-glyph",ml)),this.#v.title=this.#e.attachFiles,this.#v.setAttribute("aria-label",this.#e.attachFiles),this.#v.hidden=!0,this.#v.addEventListener("click",()=>this.#b.click()),this.#b.className="attach-input",this.#b.type="file",this.#b.multiple=!0,this.#b.hidden=!0,this.#b.addEventListener("change",()=>this.#tt()),this.#$.className="attachment-slot",this.#V.className="voice-slot";let p=document.createElement("slot");p.name="footer",f.append(this.#v,this.#V,this.#c),y.append(this.#l,f),m.append(y,this.#b),this.#i.append(n,this.#o,this.#u.palette,this.#u.chips,this.#x,this.#$,m,p,this.#f.element,this.#h.element),this.#y.className="launcher",this.#y.type="button",this.#y.setAttribute("part","launcher"),this.#y.setAttribute("aria-label",this.#e.expand),this.#A.className="launcher-badge",this.#A.setAttribute("part","launcher-badge"),this.#A.setAttribute("aria-hidden","true"),this.#A.hidden=!0,this.#y.append(this.#Re("launcher","launcher-icon",vl,this.#yt()),this.#A),this.#y.addEventListener("click",()=>this.setCollapsed(!1)),this.#i.append(ed({axis:()=>this.#se(),anchor:()=>this.#we(),rect:()=>this.getBoundingClientRect(),apply:g=>this.#le(g),commit:g=>{this.#ut(g),this.#ae()},label:this.#e.resizePanel})),this.#a.append(e,this.#i,this.#y)}#Z(e,n,r){let o=document.createElement("button");o.type="button",o.className=`header-btn header-btn--${e}`,o.setAttribute("part",`header-button ${e}-button`),o.title=n,o.setAttribute("aria-label",n);let i=document.createElement("slot");return i.name=`icon-${e}`,i.append(document.createTextNode(r)),o.append(i),o}#de(e,n,r){let o=document.createElement("slot");return o.name=e,o.className=n,o.innerHTML=r,o}#yt(){return this.getAttribute("data-launcher-icon-url")??this.getAttribute("data-icon-url")}#Re(e,n,r,o=this.getAttribute("data-icon-url")){let i=document.createElement("span");i.className="icon-holder",i.setAttribute("part",n);let s=document.createElement("slot");if(s.name=e,o!==null){let a=document.createElement("img");a.className="icon-img",a.src=o,a.alt="",s.append(a)}else r!==null&&(s.innerHTML=r);return i.append(s),i}#Ne(){this.#y.setAttribute("aria-expanded",String(!this.collapsed));let e=this.#B;this.#A.textContent=e>9?"9+":String(e),this.#A.hidden=e===0||!this.#xt();let n=this.#A.hidden?this.#e.expand:this.#e.expandUnread.replace("{count}",String(e));this.#y.setAttribute("aria-label",n),this.#y.title=n}#xt(){return this.getAttribute("data-unread-badge")!=="false"}#pe(e){this.#B=e,this.#Ne(),this.dispatchEvent(new CustomEvent(Xi,{detail:{unread:e},bubbles:!0,composed:!0}))}#_t(){this.collapsed&&this.#pe(this.#B+1)}#g(){this.#R.hidden=this.#o.childElementCount>1}#Oe(){this.#u.onInput(this.#l.value),this.#x.hidden=!0,this.#G()}#Et(e){if(this.#u.onKeydown(e)){e.preventDefault();return}if(e.key==="Escape"&&this.#z){e.preventDefault(),this.#M();return}e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),this.#he())}#M(){this.#_?.abort(),this.#N?.cancel()}#D(e){this.#z=e;let n=e?this.#e.stop:this.#e.send;this.#c.title=n,this.#c.setAttribute("aria-label",n),this.#c.dataset.state=e?"running":"idle"}#G(){this.#l.style.height="auto",this.#l.style.height=`${this.#l.scrollHeight}px`}async#he(){if(this.#z)return;let e=this.#l.value.trim(),n=this.#m?.readyRefs()??[];e===""&&n.length===0||(this.#l.value="",this.#G(),this.#m?.hasPending()===!0&&this.#J("\u{1F4CE}",this.#e.attachmentsStillUploading.replace("{n}",String(this.#m.pendingCount())),"attachment-pending"),this.#m?.clearReady(),await this.sendMessage(e,n))}async sendMessage(e,n=[]){if(this.#z||e===""&&n.length===0)return;let r=this.appendMessage(je.USER,e);n.length>0&&r.appendChild(_s(n)),this.#H=n,this.dispatchEvent(new CustomEvent(qi,{detail:{content:e,attachments:n},bubbles:!0,composed:!0})),await this.#wt(e,n)}attachFile(e){return this.#m===null?!1:(this.#m.add(e),!0)}#Tt(e){this.dispatchEvent(new CustomEvent(Ki,{detail:{attachments:e.readyRefs(),pending:e.pendingCount()},bubbles:!0,composed:!0}))}async#wt(e,n){this.endpoint!==""&&await this.#Me().send(e,n)}#Me(){if(this.#N===null){let e=this.agentFactory({endpoint:this.endpoint,headers:this.#C(),getHeaders:()=>this.#C(),...this.#W(),threadId:this.#p,initialMessages:this.#re,initialState:this.#L});this.#N=new Pn({agent:e,handlers:this.#De(),getTools:()=>this.getTools(),getContext:()=>this.#Ce(),executeTool:n=>this.#Le(n),resolveInterrupts:n=>this.#Pe(n),onPersist:n=>this.conversationStore.saveMessages(this.#p,n),onStateChanged:n=>this.#St(n),connectionLostMessage:this.#e.connectionLost})}return this.#N}#St(e){this.#L={...e},this.dispatchEvent(new CustomEvent(Yi,{detail:{state:this.#L},bubbles:!0,composed:!0}))}async#At(e,n){return this.autoConfirm?!1:this.confirmPredicate!==null?await this.confirmPredicate(e.name,e.args)===!0:os(n.parameters)}async#Le(e){if(pd(e)!==null)return null;let n=this.#fe(e);this.#s.delete(e.id);let r=this.#ye(e.name);if(r===null)return this.#r.has(e.id)||n.settle(pe.DONE,this.#e.noResult),null;if(this.getPageMap!==null&&e.name!==Ji&&!Mr(r.parameters)&&this.#ht()){let i=this.#e.pageMoved;return n.settle(pe.ERROR,i),this.#F(),{content:`Error: ${i}`,error:i}}if(await this.#At(e,r)){let i={toolName:e.name,args:e.args},s=r.parameters[Zi];typeof s=="string"&&(i.message=s),this.#_=new AbortController;let a=ua(this.#T(),i,{signal:this.#_.signal,strings:this.#e});this.#g(),this.#o.scrollTop=this.#o.scrollHeight;let l=await a;if(this.#_=null,n.recordDecision(l?"approved":"declined"),!l){let c=this.#e.declinedAction;return n.settle(pe.DECLINED,c),this.#F(),{content:c}}}let o=Mr(r.parameters)&&this.navigate===null;o&&this.conversationStore.saveCheckpoint(this.#p,{toolCallId:e.id});try{let i=await r.handler(e.args);if(o)return n.settle(pe.DONE,this.#e.navigating),{content:"",halt:!0};let s=JSON.stringify(i??null);return n.settle(pe.DONE,s),this.#F(),{content:s}}catch(i){o&&this.conversationStore.saveCheckpoint(this.#p,null);let s=i instanceof Error?i.message:String(i);return n.settle(pe.ERROR,s),this.#F(),{content:`Error: ${s}`,error:s}}}async#Pe(e){let n={};this.#_=new AbortController,this.#w();for(let r of e){let o={};r.message!==void 0&&(o.message=r.message);let i=r.toolCallId!==void 0?this.#s.get(r.toolCallId):void 0,s=i?.element.getAttribute("data-tool-name");s!=null&&(o.toolName=s);let a=this.#_.signal,l=this.approvalRenderer!==null?await this.approvalRenderer(o,{signal:a}):await ys(this.#T(),o,{signal:a,strings:this.#e});this.#g(),this.#o.scrollTop=this.#o.scrollHeight,i?.recordDecision(l?"approved":"declined"),l?n[r.id]={status:"resolved",payload:{approved:!0}}:(n[r.id]={status:"cancelled"},i?.settle(pe.DECLINED,this.#e.declinedAction))}return this.#_=null,n}#De(){return{onRunStart:()=>{this.#D(!0),this.#T(),this.#F()},onReasoningStart:()=>{this.#w(),this.#Ue()},onReasoningDelta:e=>{this.#Ue().stream(e)},onReasoningEnd:()=>{},onTextDelta:e=>{this.#w(),this.#O?.collapse(),this.#He(e),this.#te+=1},onTextEnd:e=>{let n=this.#He(e);this.#te<=1&&this.#Ie(n),xs(n,this.#e),this.#E=null,this.#_t()},onToolCall:e=>{this.#w(),!this.#ze(e)&&this.#fe(e)},onActivity:(e,n)=>{if(e!==ts)return;let r=sb(n);r!==null&&this.#J("\u{1F5DC}",this.#e.historyCompacted.replace("{count}",String(r)),"compaction")},onToolResult:(e,n)=>{let r=this.#s.get(e);r!==void 0&&(r.settle(pe.DONE,n),this.#r.add(e))},onRunEnd:()=>{this.#w(),this.#E=null},onError:e=>{this.#w(),this.#Ie(this.appendMessage(je.ASSISTANT,`\u26A0\uFE0F ${e}`)),this.#E=null},onCancelled:()=>{this.#w(),this.#kt(),this.#E=null},onSettled:()=>{this.#w(),this.#D(!1),this.#E=null,this.#H=[];for(let e of this.#s.values())e.settled||e.settle(pe.DONE,this.#e.noResult);this.#k!==null&&this.#k.childElementCount===0&&(this.#k.remove(),this.#g()),this.#k=null,this.#O=null}}}#kt(){let e=document.createElement("div");e.className="stopped-note",e.setAttribute("part","stopped"),e.setAttribute("role","status"),e.textContent=this.#e.stopped,this.#T().appendChild(e),this.#g(),this.#o.scrollTop=this.#o.scrollHeight}#F(){if(this.#j!==null)return;let e=document.createElement("div");e.className="pending",e.setAttribute("part","pending"),e.setAttribute("role","status"),e.setAttribute("aria-label",this.#e.thinking);for(let n=0;n<3;n+=1){let r=document.createElement("span");r.className="pending-dot",e.appendChild(r)}this.#j=e,this.#T().appendChild(e),this.#g(),this.#o.scrollTop=this.#o.scrollHeight}#w(){this.#j?.remove(),this.#j=null}#Ue(){if(this.#O===null){this.#O=new _i(this.#e);let e=this.#T();e.insertBefore(this.#O.element,e.firstChild),this.#g(),this.#o.scrollTop=this.#o.scrollHeight}return this.#O}#He(e){return this.#E===null&&(this.#E=this.appendMessage(je.ASSISTANT,""),this.#te=0),this.#E.innerHTML=yi(e,{allowImages:this.allowImages}),this.#o.scrollTop=this.#o.scrollHeight,this.#E}#ze(e){let n=pd(e);return n===null?!1:(this.#J("\u2728",this.#e.usingSkill.replace("{name}",n),"skill"),!0)}#J(e,n,r){this.#T().appendChild(rd(e,n,r)),this.#g(),this.#o.scrollTop=this.#o.scrollHeight}#fe(e){let n=this.#s.get(e.id);if(n!==void 0)return n;let r=this.#ye(e.name)?.parameters[Le],o=typeof r=="string"?r:this.toolSummaries[e.name]??this.#n[e.name]??da(e.name),i=new mr(e.name,e.args,o,this.#e);return this.#s.set(e.id,i),this.#T().appendChild(i.element),this.#g(),this.#o.scrollTop=this.#o.scrollHeight,i}};function pd(t){if(t.name!==ns)return null;let e=t.args?.id;return typeof e=="string"&&e!==""?e:null}function sb(t){let e=t?.removed;return typeof e=="number"?e:null}function ab(){customElements.get(Or)===void 0&&customElements.define(Or,yr)}async function lb(t,e,n={}){await lt(t),await cs(t,{...n,flashMs:n.flashMs??0}),await as(t,e,n)}async function cb(t,e={}){await lt(t),await ls(t,e)}async function ub(t,e={}){await lt(t),await us(t,e)}async function db(t,e,n={}){await lt(t),await ds(t,e,n)}async function pb(t,e,n={}){await lt(t),await ps(t,e,n)}function hb(t,e){t instanceof HTMLInputElement&&t.type==="checkbox"?Vn(t,!!e):Nt(t,String(e)),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}var fb="0.22.0";export{Ki as ATTACHMENT_EVENT,yr as AgUiChat,Pn as AgUiClient,ts as COMPACTION_ACTIVITY_TYPE,ar as CheckpointMenu,Bn as ClientToolRegistry,wi as ConnectionLostError,ae as DEFAULT_UI_STRINGS,Or as ELEMENT_TAG,ns as LOAD_CAPABILITY_TOOL,Qi as MAX_TOOL_ROUNDS,je as MESSAGE_ROLE,hs as PAGE_ACTIONS,vr as RemoteConversationStore,br as RunIndex,Yi as STATE_EVENT,qi as SUBMIT_EVENT,mt as SessionStorageStore,Wi as TOGGLE_EVENT,pe as TOOL_CALL_STATUS,pn as TOOL_DISPLAY,mr as ToolCallCard,Xi as UNREAD_EVENT,fb as VERSION,Zi as X_CONFIRM_KEY,Fn as X_DESTRUCTIVE_KEY,$n as X_NAVIGATES_KEY,Le as X_SUMMARY_KEY,cb as clickElement,Pa as createHttpAgent,fs as createPageActionTools,ms as createPageMapContext,Ur as createPageStateTools,vs as createRouteTools,ip as createStateHookTools,ab as defineAgUiChat,lb as fillField,ep as flash,cs as focusWithFlash,ls as highlightThenClick,os as isDestructive,Mr as isNavigates,bs as mergeUiStrings,Oa as messageAttachments,gs as parseToolCatalog,Pr as prefersReducedMotion,ub as pressButton,us as pressThenClick,da as prettifyToolName,yi as renderMarkdown,ys as requestApproval,ua as requestConfirmation,pa as requestQuestion,lt as scrollIntoCenterView,db as selectControl,ds as selectOption,hb as setControlValue,Vn as setNativeChecked,Nt as setNativeValue,pb as toggleCheckbox,ps as toggleControl,Da as transcribeAudio,as as typeInto,Ua as uploadAttachment};
|
|
1869
2199
|
/*! Bundled license information:
|
|
1870
2200
|
|
|
1871
2201
|
fast-json-patch/module/helpers.mjs:
|