@multiplayer-app/ai-agent-react 0.1.0-beta.97 → 0.1.0-beta.98
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/dist/ai-agent-react.cjs.js +2 -2
- package/dist/ai-agent-react.cjs.js.map +1 -1
- package/dist/ai-agent-react.es.js +29 -18
- package/dist/ai-agent-react.es.js.map +1 -1
- package/dist/components/ChatWindow/MessageList/Message/ReasoningPanel.d.ts.map +1 -1
- package/dist/components/ChatWindow/MessageList/MessageGroup.d.ts.map +1 -1
- package/dist/components/ChatWindow/MessageList/ToolCallCard/ToolCallCard.d.ts +1 -1
- package/dist/components/ChatWindow/MessageList/ToolCallCard/ToolCallCard.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -8293,7 +8293,7 @@
|
|
|
8293
8293
|
}`}),t]})},w3=()=>G.useContext(_3),d2="mp-agent-selected-model",ta="__auto__";function E3(e){return e.mode==="direct"?`${d2}-${e.mode}-${e.provider}`:`${d2}-${e.mode}`}function p2(e,t){try{const n=E3(e);localStorage.setItem(n,t)}catch(n){console.warn("Failed to save selected model to localStorage:",n)}}function b7e(e){try{const t=E3(e);return localStorage.getItem(t)}catch(t){return console.warn("Failed to load selected model from localStorage:",t),null}}function M3(e,t){return!e||e.length===0?[]:t.mode==="direct"&&t.provider!=="custom"?e.filter(n=>n.provider?n.provider===t.provider:!0):e}function k7e(e,t,n){const r=b7e(t);if(r){if(r===ta)return;if(M3(e,t).some(i=>i.id===r))return r}}const v7e="mp-agents-last-active-chat";function S3(e){return`${v7e}-${e}`}function N3(e){return typeof e=="string"&&e.length>0&&e.length<256}function _7e(e){if(typeof window>"u")return null;try{const t=localStorage.getItem(S3(e));return t&&N3(t)?t:null}catch{return null}}function x7e(e,t){if(!(typeof window>"u"))try{const n=S3(e);t&&N3(t)?localStorage.setItem(n,t):localStorage.removeItem(n)}catch{}}const xn=Object.create(null);xn.open="0";xn.close="1";xn.ping="2";xn.pong="3";xn.message="4";xn.upgrade="5";xn.noop="6";const ki=Object.create(null);Object.keys(xn).forEach(e=>{ki[xn[e]]=e});const nd={type:"error",data:"parser error"},A3=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",T3=typeof ArrayBuffer=="function",C3=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,op=({type:e,data:t},n,r)=>A3&&t instanceof Blob?n?r(t):h2(t,r):T3&&(t instanceof ArrayBuffer||C3(t))?n?r(t):h2(new Blob([t]),r):r(xn[e]+(t||"")),h2=(e,t)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];t("b"+(r||""))},n.readAsDataURL(e)};function m2(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let Jo;function w7e(e,t){if(A3&&e.data instanceof Blob)return e.data.arrayBuffer().then(m2).then(t);if(T3&&(e.data instanceof ArrayBuffer||C3(e.data)))return t(m2(e.data));op(e,!1,n=>{Jo||(Jo=new TextEncoder),t(Jo.encode(n))})}const f2="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",na=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<f2.length;e++)na[f2.charCodeAt(e)]=e;const E7e=e=>{let t=e.length*.75,n=e.length,r,a=0,i,o,s,l;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const u=new ArrayBuffer(t),d=new Uint8Array(u);for(r=0;r<n;r+=4)i=na[e.charCodeAt(r)],o=na[e.charCodeAt(r+1)],s=na[e.charCodeAt(r+2)],l=na[e.charCodeAt(r+3)],d[a++]=i<<2|o>>4,d[a++]=(o&15)<<4|s>>2,d[a++]=(s&3)<<6|l&63;return u},M7e=typeof ArrayBuffer=="function",sp=(e,t)=>{if(typeof e!="string")return{type:"message",data:R3(e,t)};const n=e.charAt(0);return n==="b"?{type:"message",data:S7e(e.substring(1),t)}:ki[n]?e.length>1?{type:ki[n],data:e.substring(1)}:{type:ki[n]}:nd},S7e=(e,t)=>{if(M7e){const n=E7e(e);return R3(n,t)}else return{base64:!0,data:e}},R3=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},I3="",N7e=(e,t)=>{const n=e.length,r=new Array(n);let a=0;e.forEach((i,o)=>{op(i,!1,s=>{r[o]=s,++a===n&&t(r.join(I3))})})},A7e=(e,t)=>{const n=e.split(I3),r=[];for(let a=0;a<n.length;a++){const i=sp(n[a],t);if(r.push(i),i.type==="error")break}return r};function T7e(){return new TransformStream({transform(e,t){w7e(e,n=>{const r=n.length;let a;if(r<126)a=new Uint8Array(1),new DataView(a.buffer).setUint8(0,r);else if(r<65536){a=new Uint8Array(3);const i=new DataView(a.buffer);i.setUint8(0,126),i.setUint16(1,r)}else{a=new Uint8Array(9);const i=new DataView(a.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!="string"&&(a[0]|=128),t.enqueue(a),t.enqueue(n)})}})}let es;function Ga(e){return e.reduce((t,n)=>t+n.length,0)}function Wa(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let a=0;a<t;a++)n[a]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function C7e(e,t){es||(es=new TextDecoder);const n=[];let r=0,a=-1,i=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(r===0){if(Ga(n)<1)break;const l=Wa(n,1);i=(l[0]&128)===128,a=l[0]&127,a<126?r=3:a===126?r=1:r=2}else if(r===1){if(Ga(n)<2)break;const l=Wa(n,2);a=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),r=3}else if(r===2){if(Ga(n)<8)break;const l=Wa(n,8),u=new DataView(l.buffer,l.byteOffset,l.length),d=u.getUint32(0);if(d>Math.pow(2,21)-1){s.enqueue(nd);break}a=d*Math.pow(2,32)+u.getUint32(4),r=3}else{if(Ga(n)<a)break;const l=Wa(n,a);s.enqueue(sp(i?l:es.decode(l),t)),r=0}if(a===0||a>e){s.enqueue(nd);break}}}})}const O3=4;function ct(e){if(e)return R7e(e)}function R7e(e){for(var t in ct.prototype)e[t]=ct.prototype[t];return e}ct.prototype.on=ct.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};ct.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this};ct.prototype.off=ct.prototype.removeListener=ct.prototype.removeAllListeners=ct.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var r,a=0;a<n.length;a++)if(r=n[a],r===t||r.fn===t){n.splice(a,1);break}return n.length===0&&delete this._callbacks["$"+e],this};ct.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,a=n.length;r<a;++r)n[r].apply(this,t)}return this};ct.prototype.emitReserved=ct.prototype.emit;ct.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};ct.prototype.hasListeners=function(e){return!!this.listeners(e).length};const ho=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0),Qt=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),I7e="arraybuffer";function L3(e,...t){return t.reduce((n,r)=>(e.hasOwnProperty(r)&&(n[r]=e[r]),n),{})}const O7e=Qt.setTimeout,L7e=Qt.clearTimeout;function mo(e,t){t.useNativeTimers?(e.setTimeoutFn=O7e.bind(Qt),e.clearTimeoutFn=L7e.bind(Qt)):(e.setTimeoutFn=Qt.setTimeout.bind(Qt),e.clearTimeoutFn=Qt.clearTimeout.bind(Qt))}const D7e=1.33;function z7e(e){return typeof e=="string"?$7e(e):Math.ceil((e.byteLength||e.size)*D7e)}function $7e(e){let t=0,n=0;for(let r=0,a=e.length;r<a;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function D3(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function F7e(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function P7e(e){let t={},n=e.split("&");for(let r=0,a=n.length;r<a;r++){let i=n[r].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t}class q7e extends Error{constructor(t,n,r){super(t),this.description=n,this.context=r,this.type="TransportError"}}class lp extends ct{constructor(t){super(),this.writable=!1,mo(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,n,r){return super.emitReserved("error",new q7e(t,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const n=sp(t,this.socket.binaryType);this.onPacket(n)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,n={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const n=F7e(t);return n.length?"?"+n:""}}class B7e extends lp{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const n=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};A7e(t,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,N7e(t,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=D3()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}let z3=!1;try{z3=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const U7e=z3;function H7e(){}class j7e extends B7e{constructor(t){if(super(t),typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||r!==t.port}}doWrite(t,n){const r=this.request({method:"POST",data:t});r.on("success",n),r.on("error",(a,i)=>{this.onError("xhr post error",a,i)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=t}}class _n extends ct{constructor(t,n,r){super(),this.createRequest=t,mo(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var t;const n=L3(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let a in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(a)&&r.setRequestHeader(a,this._opts.extraHeaders[a])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var a;r.readyState===3&&((a=this._opts.cookieJar)===null||a===void 0||a.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(a){this.setTimeoutFn(()=>{this._onError(a)},0);return}typeof document<"u"&&(this._index=_n.requestsCount++,_n.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=H7e,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete _n.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}_n.requestsCount=0;_n.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",g2);else if(typeof addEventListener=="function"){const e="onpagehide"in Qt?"pagehide":"unload";addEventListener(e,g2,!1)}}function g2(){for(let e in _n.requests)_n.requests.hasOwnProperty(e)&&_n.requests[e].abort()}const V7e=function(){const e=$3({xdomain:!1});return e&&e.responseType!==null}();class G7e extends j7e{constructor(t){super(t);const n=t&&t.forceBase64;this.supportsBinary=V7e&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new _n($3,this.uri(),t)}}function $3(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||U7e))return new XMLHttpRequest}catch{}if(!t)try{return new Qt[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const F3=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class W7e extends lp{get name(){return"websocket"}doOpen(){const t=this.uri(),n=this.opts.protocols,r=F3?{}:L3(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,n,r)}catch(a){return this.emitReserved("error",a)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],a=n===t.length-1;op(r,this.supportsBinary,i=>{try{this.doWrite(r,i)}catch{}a&&ho(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=D3()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}}const ts=Qt.WebSocket||Qt.MozWebSocket;class K7e extends W7e{createSocket(t,n,r){return F3?new ts(t,n,r):n?new ts(t,n):new ts(t)}doWrite(t,n){this.ws.send(n)}}class Y7e extends lp{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const n=C7e(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),a=T7e();a.readable.pipeTo(t.writable),this._writer=a.writable.getWriter();const i=()=>{r.read().then(({done:s,value:l})=>{s||(this.onPacket(l),i())}).catch(s=>{})};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],a=n===t.length-1;this._writer.write(r).then(()=>{a&&ho(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const Z7e={websocket:K7e,webtransport:Y7e,polling:G7e},X7e=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Q7e=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function rd(e){if(e.length>8e3)throw"URI too long";const t=e,n=e.indexOf("["),r=e.indexOf("]");n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));let a=X7e.exec(e||""),i={},o=14;for(;o--;)i[Q7e[o]]=a[o]||"";return n!=-1&&r!=-1&&(i.source=t,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=J7e(i,i.path),i.queryKey=e_e(i,i.query),i}function J7e(e,t){const n=/\/{2,9}/g,r=t.replace(n,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&r.splice(0,1),t.slice(-1)=="/"&&r.splice(r.length-1,1),r}function e_e(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,a,i){a&&(n[a]=i)}),n}const ad=typeof addEventListener=="function"&&typeof removeEventListener=="function",vi=[];ad&&addEventListener("offline",()=>{vi.forEach(e=>e())},!1);class Qn extends ct{constructor(t,n){if(super(),this.binaryType=I7e,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(n=t,t=null),t){const r=rd(t);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=rd(n.host).host);mo(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{const a=r.prototype.name;this.transports.push(a),this._transportsByName[a]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=P7e(this.opts.query)),ad&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},vi.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const n=Object.assign({},this.opts.query);n.EIO=O3,n.transport=t,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&Qn.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",Qn.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=t.data,this._onError(n);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const a=this.writeBuffer[r].data;if(a&&(n+=z7e(a)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,ho(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,n,r){return this._sendPacket("message",t,n,r),this}send(t,n,r){return this._sendPacket("message",t,n,r),this}_sendPacket(t,n,r,a){if(typeof n=="function"&&(a=n,n=void 0),typeof r=="function"&&(a=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const i={type:t,data:n,options:r};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),a&&this.once("flush",a),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),t()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}_onError(t){if(Qn.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),ad&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=vi.indexOf(this._offlineEventListener);r!==-1&&vi.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}}Qn.protocol=O3;class t_e extends Qn{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let n=this.createTransport(t),r=!1;Qn.priorWebsocketSuccess=!1;const a=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",p=>{if(!r)if(p.type==="pong"&&p.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;Qn.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(d(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const m=new Error("probe error");m.transport=n.name,this.emitReserved("upgradeError",m)}}))};function i(){r||(r=!0,d(),n.close(),n=null)}const o=p=>{const m=new Error("probe error: "+p);m.transport=n.name,i(),this.emitReserved("upgradeError",m)};function s(){o("transport closed")}function l(){o("socket closed")}function u(p){n&&p.name!==n.name&&i()}const d=()=>{n.removeListener("open",a),n.removeListener("error",o),n.removeListener("close",s),this.off("close",l),this.off("upgrading",u)};n.once("open",a),n.once("error",o),n.once("close",s),this.once("close",l),this.once("upgrading",u),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const n=[];for(let r=0;r<t.length;r++)~this.transports.indexOf(t[r])&&n.push(t[r]);return n}}let n_e=class extends t_e{constructor(t,n={}){const r=typeof t=="object"?t:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(a=>Z7e[a]).filter(a=>!!a)),super(t,r)}};function r_e(e,t="",n){let r=e;n=n||typeof location<"u"&&location,e==null&&(e=n.protocol+"//"+n.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=n.protocol+e:e=n.host+e),/^(https?|wss?):\/\//.test(e)||(typeof n<"u"?e=n.protocol+"//"+e:e="https://"+e),r=rd(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const i=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+i+":"+r.port+t,r.href=r.protocol+"://"+i+(n&&n.port===r.port?"":":"+r.port),r}const a_e=typeof ArrayBuffer=="function",i_e=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,P3=Object.prototype.toString,o_e=typeof Blob=="function"||typeof Blob<"u"&&P3.call(Blob)==="[object BlobConstructor]",s_e=typeof File=="function"||typeof File<"u"&&P3.call(File)==="[object FileConstructor]";function cp(e){return a_e&&(e instanceof ArrayBuffer||i_e(e))||o_e&&e instanceof Blob||s_e&&e instanceof File}function _i(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,r=e.length;n<r;n++)if(_i(e[n]))return!0;return!1}if(cp(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return _i(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&_i(e[n]))return!0;return!1}function l_e(e){const t=[],n=e.data,r=e;return r.data=id(n,t),r.attachments=t.length,{packet:r,buffers:t}}function id(e,t){if(!e)return e;if(cp(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){const n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=id(e[r],t);return n}else if(typeof e=="object"&&!(e instanceof Date)){const n={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=id(e[r],t));return n}return e}function c_e(e,t){return e.data=od(e.data,t),delete e.attachments,e}function od(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=od(e[n],t);else if(typeof e=="object")for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=od(e[n],t));return e}const u_e=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],d_e=5;var qe;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(qe||(qe={}));class p_e{constructor(t){this.replacer=t}encode(t){return(t.type===qe.EVENT||t.type===qe.ACK)&&_i(t)?this.encodeAsBinary({type:t.type===qe.EVENT?qe.BINARY_EVENT:qe.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===qe.BINARY_EVENT||t.type===qe.BINARY_ACK)&&(n+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(n+=t.nsp+","),t.id!=null&&(n+=t.id),t.data!=null&&(n+=JSON.stringify(t.data,this.replacer)),n}encodeAsBinary(t){const n=l_e(t),r=this.encodeAsString(n.packet),a=n.buffers;return a.unshift(r),a}}function y2(e){return Object.prototype.toString.call(e)==="[object Object]"}class up extends ct{constructor(t){super(),this.reviver=t}add(t){let n;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(t);const r=n.type===qe.BINARY_EVENT;r||n.type===qe.BINARY_ACK?(n.type=r?qe.EVENT:qe.ACK,this.reconstructor=new h_e(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(cp(t)||t.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(t),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let n=0;const r={type:Number(t.charAt(0))};if(qe[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===qe.BINARY_EVENT||r.type===qe.BINARY_ACK){const i=n+1;for(;t.charAt(++n)!=="-"&&n!=t.length;);const o=t.substring(i,n);if(o!=Number(o)||t.charAt(n)!=="-")throw new Error("Illegal attachments");r.attachments=Number(o)}if(t.charAt(n+1)==="/"){const i=n+1;for(;++n&&!(t.charAt(n)===","||n===t.length););r.nsp=t.substring(i,n)}else r.nsp="/";const a=t.charAt(n+1);if(a!==""&&Number(a)==a){const i=n+1;for(;++n;){const o=t.charAt(n);if(o==null||Number(o)!=o){--n;break}if(n===t.length)break}r.id=Number(t.substring(i,n+1))}if(t.charAt(++n)){const i=this.tryParse(t.substr(n));if(up.isPayloadValid(r.type,i))r.data=i;else throw new Error("invalid payload")}return r}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,n){switch(t){case qe.CONNECT:return y2(n);case qe.DISCONNECT:return n===void 0;case qe.CONNECT_ERROR:return typeof n=="string"||y2(n);case qe.EVENT:case qe.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&u_e.indexOf(n[0])===-1);case qe.ACK:case qe.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class h_e{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const n=c_e(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const m_e=Object.freeze(Object.defineProperty({__proto__:null,Decoder:up,Encoder:p_e,get PacketType(){return qe},protocol:d_e},Symbol.toStringTag,{value:"Module"}));function cn(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const f_e=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class q3 extends ct{constructor(t,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[cn(t,"open",this.onopen.bind(this)),cn(t,"packet",this.onpacket.bind(this)),cn(t,"error",this.onerror.bind(this)),cn(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...n){var r,a,i;if(f_e.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(n.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const o={type:qe.EVENT,data:n};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const d=this.ids++,p=n.pop();this._registerAckCallback(d,p),o.id=d}const s=(a=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||a===void 0?void 0:a.writable,l=this.connected&&!(!((i=this.io.engine)===null||i===void 0)&&i._hasPingExpired());return this.flags.volatile&&!s||(l?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(t,n){var r;const a=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(a===void 0){this.acks[t]=n;return}const i=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let s=0;s<this.sendBuffer.length;s++)this.sendBuffer[s].id===t&&this.sendBuffer.splice(s,1);n.call(this,new Error("operation has timed out"))},a),o=(...s)=>{this.io.clearTimeoutFn(i),n.apply(this,s)};o.withError=!0,this.acks[t]=o}emitWithAck(t,...n){return new Promise((r,a)=>{const i=(o,s)=>o?a(o):r(s);i.withError=!0,n.push(i),this.emit(t,...n)})}_addToQueue(t){let n;typeof t[t.length-1]=="function"&&(n=t.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((a,...i)=>r!==this._queue[0]?void 0:(a!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(a)):(this._queue.shift(),n&&n(null,...i)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!t||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:qe.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(r=>String(r.id)===t)){const r=this.acks[t];delete this.acks[t],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case qe.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case qe.EVENT:case qe.BINARY_EVENT:this.onevent(t);break;case qe.ACK:case qe.BINARY_ACK:this.onack(t);break;case qe.DISCONNECT:this.ondisconnect();break;case qe.CONNECT_ERROR:this.destroy();const r=new Error(t.data.message);r.data=t.data.data,this.emitReserved("connect_error",r);break}}onevent(t){const n=t.data||[];t.id!=null&&n.push(this.ack(t.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const n=this;let r=!1;return function(...a){r||(r=!0,n.packet({type:qe.ACK,id:t,data:a}))}}onack(t){const n=this.acks[t.id];typeof n=="function"&&(delete this.acks[t.id],n.withError&&t.data.unshift(null),n.apply(this,t.data))}onconnect(t,n){this.id=t,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:qe.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,t.data)}}}function jr(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}jr.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0};jr.prototype.reset=function(){this.attempts=0};jr.prototype.setMin=function(e){this.ms=e};jr.prototype.setMax=function(e){this.max=e};jr.prototype.setJitter=function(e){this.jitter=e};class sd extends ct{constructor(t,n){var r;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(n=t,t=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,mo(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new jr({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=t;const a=n.parser||m_e;this.encoder=new a.Encoder,this.decoder=new a.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var n;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(n=this.backoff)===null||n===void 0||n.setMin(t),this)}randomizationFactor(t){var n;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(n=this.backoff)===null||n===void 0||n.setJitter(t),this)}reconnectionDelayMax(t){var n;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(n=this.backoff)===null||n===void 0||n.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new n_e(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const a=cn(n,"open",function(){r.onopen(),t&&t()}),i=s=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",s),t?t(s):this.maybeReconnectOnOpen()},o=cn(n,"error",i);if(this._timeout!==!1){const s=this._timeout,l=this.setTimeoutFn(()=>{a(),i(new Error("timeout")),n.close()},s);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(a),this.subs.push(o),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(cn(t,"ping",this.onping.bind(this)),cn(t,"data",this.ondata.bind(this)),cn(t,"error",this.onerror.bind(this)),cn(t,"close",this.onclose.bind(this)),cn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(n){this.onclose("parse error",n)}}ondecoded(t){ho(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,n){let r=this.nsps[t];return r?this._autoConnect&&!r.active&&r.connect():(r=new q3(this,t,n),this.nsps[t]=r),r}_destroy(t){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(t){const n=this.encoder.encode(t);for(let r=0;r<n.length;r++)this.engine.write(n[r],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(a=>{a?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",a)):t.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const Zr={};function xi(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const n=r_e(e,t.path||"/socket.io"),r=n.source,a=n.id,i=n.path,o=Zr[a]&&i in Zr[a].nsps,s=t.forceNew||t["force new connection"]||t.multiplex===!1||o;let l;return s?l=new sd(r,t):(Zr[a]||(Zr[a]=new sd(r,t)),l=Zr[a]),n.query&&!t.query&&(t.query=n.queryKey),l.socket(n.path,t)}Object.assign(xi,{Manager:sd,Socket:q3,io:xi,connect:xi});const g_e=G.createContext(null),y_e=({children:e})=>{const t=$e(),n=fe(_=>_.upsertChat),r=fe(_=>_.upsertChatState),a=fe(_=>_.contextKey),i=fe(_=>_.activeChatId),o=G.useMemo(()=>t.config.user?.id??Hr(),[t.config.user?.id]),s=t.config.transport,[l,u]=G.useState(null),[d,p]=G.useState(void 0),m=G.useRef(a),h=G.useRef(n),g=G.useRef(r),f=G.useRef(void 0);G.useEffect(()=>{m.current=a,h.current=n,g.current=r},[a,n,r]),G.useEffect(()=>{if(s.mode!=="proxy"){u(null),p(void 0),t.setSocketClient(null),t.transport instanceof Or&&t.transport.setSocketId(void 0);return}const _=s.baseUrl,b=new URL(_,window.location.origin),v=`${b.protocol}//${b.host}`,E=s.socketNamespace,N=E?`${v}${E}`:v,w={},$=s;$.headers&&Object.assign(w,$.headers);const P={},C=$.apiKey&&`Bearer ${$.apiKey}`||$.headers?.Authorization;C&&(P.authorization=C,w.Authorization=C);const L=s.socketPath??Ti.Path,U=xi(N,{path:L,auth:P,transports:["websocket","polling"],withCredentials:!0,...Object.keys(w).length>0&&{extraHeaders:w}});t.setSocketClient(U),u(U);const Z=()=>{p(U.id),t.transport instanceof Or&&t.transport.setSocketId(U.id)},J=()=>{p(void 0),t.transport instanceof Or&&t.transport.setSocketId(void 0)},K=j=>{if(j.contextKey===m.current){h.current(j);const D=t.store.getState(),V=ze(D,j.id);g.current(j.id,{...V,status:ya(j.status)})}},R=j=>{const D=t.store.getState(),V=ze(D,j.chat),A=V.messages.findIndex(Y=>Y.id===j.id);if(A>=0){const Y=[...V.messages];Y[A]=j,g.current(j.chat,{...V,messages:Y});return}g.current(j.chat,{...V,messages:[...V.messages,j]})},H=j=>{h.current(j);const D=t.store.getState(),V=ze(D,j.id);g.current(j.id,{...V,status:ya(j.status)})};return U.on("connect",Z),U.on("disconnect",J),U.on("connect_error",j=>{console.error("Socket.IO connection error:",j.message)}),U.on(gi.ChatNew,K),U.on(gi.MessageNew,R),U.on(gi.ChatUpdate,H),()=>{t.transport instanceof Or&&t.transport.setSocketId(void 0),t.setSocketClient(null),p(void 0),u(null),U.disconnect()}},[t,t.transport,s.mode,s.mode==="proxy"?s.baseUrl:void 0,s.mode==="proxy"?s.apiKey:void 0,s.mode==="proxy"?s.socketPath:void 0,s.mode==="proxy"?s.socketNamespace:void 0,s.mode==="proxy"?JSON.stringify(s.headers??{}):"",o]),G.useEffect(()=>{if(!l)return;const _=f.current;_&&_!==i&&l.emit("chat:unsubscribe",{chatId:_}),i&&i!==_&&(l.emit("chat:subscribe",{chatId:i}),f.current=i),i||(f.current=void 0)},[l,i]);const x=G.useMemo(()=>({socket:l,socketId:d}),[l,d]);return S.jsx(g_e.Provider,{value:x,children:e})},dp=G.createContext(null),b_e=({config:e,children:t})=>{const n=G.useRef();n.current||(n.current=new k3(e));const[,r]=G.useState(0);G.useEffect(()=>{const o=n.current,s=()=>r(l=>l+1);return o.events.addEventListener("runtime:transport-config-changed",s),()=>{o.events.removeEventListener("runtime:transport-config-changed",s)}},[]);const a=G.useRef();if(!a.current){const o=n.current.defaultContextKey??n.current.config.contextKeys[0]?.key??"default";a.current=l7e(o),n.current.attachStore(a.current);const s=k7e(n.current.config.models,n.current.config.transport);a.current.getState().setComposerOptions({model:s})}const i=G.useMemo(()=>({runtime:n.current,store:a.current}),[]);return G.useEffect(()=>{const o=a.current;if(!o)return;let s=o.getState().activeChatId;return o.subscribe(()=>{const l=o.getState().activeChatId;if(l===s)return;s=l;const u=n.current?.config.user?.id??Hr();x7e(u,l)})},[]),S.jsx(dp.Provider,{value:i,children:S.jsx(bt.QueryClientProvider,{client:i.runtime.queryClient,children:S.jsx(x3,{value:i.runtime.config.theme,children:S.jsx(y_e,{children:t})})})})},$e=()=>{const e=G.useContext(dp);if(!e)throw new Error("useAgentRuntime must be used inside <AgentProvider />");return e.runtime},fe=e=>{const t=G.useContext(dp);if(!t)throw new Error("useAgentStore must be used inside <AgentProvider />");return o5.useStore(t.store,e)},k_e=({initialSystemPrompt:e,composerFormRef:t,multiUser:n=!1,participantIds:r=[]})=>{const a=$e(),{composer:i,contextKey:o,activeChatId:s,draftChatKey:l,queuedMessages:u,activeChatStatus:d,upsertChat:p,setChatStatus:m,setActiveChat:h,setComposerError:g,moveChatKeyState:f,removeQueuedMessage:x,setPendingAssistant:_,enqueueQueuedMessage:b,appendMessagesToChat:v,commitPendingAssistant:E,setPageContextDismissed:N}=fe(V=>{const A=V.activeChatId??V.draftChatKey,Y=ze(V,A);return{composer:V.composer,contextKey:V.contextKey,activeChatId:V.activeChatId,draftChatKey:V.draftChatKey,queuedMessages:Y.messageQueue,activeChatStatus:Y.status,upsertChat:V.upsertChat,setActiveChat:V.setActiveChat,setChatStatus:V.setChatStatus,setComposerError:V.setComposerError,moveChatKeyState:V.moveChatKeyState,setPendingAssistant:V.setPendingAssistant,removeQueuedMessage:V.removeQueuedMessage,enqueueQueuedMessage:V.enqueueQueuedMessage,appendMessagesToChat:V.appendMessagesToChat,commitPendingAssistant:V.commitPendingAssistant,setPageContextDismissed:V.setPageContextDismissed}}),w=G.useCallback(V=>!V||V.length===0?!1:V.some(A=>A.type===exports.AgentAttachmentType.Context&&A?.metadata?.kind==="pageContext"),[]),$=G.useRef(!1),P=G.useRef(!1),C=G.useRef(void 0),L=G.useRef(new Set),U=s??l,Z=G.useCallback(async(V,A)=>{if(!a.transport.generateTitle)return;const Y=a.config.features?.titleGeneration==="llm"?"llm":"local";let ee;try{ee=await a.transport.generateTitle({userId:A,content:V,strategy:Y,contextKey:o})}catch{}return ee},[a.transport,a.config.features?.titleGeneration,o]),J=G.useCallback(async(V,A=[])=>{const Y=a.config.user?.id??"guest",ee=!s,O=s??l,le={current:O};C.current=O;const ge={value:V,attachments:A};g(le.current,void 0);let ke;if(ee){const ce=await Z(V,Y);ce&&ce.trim().length>0&&(ke={...ke??{},title:ce})}const Ce=a.store.getState(),Fe=s?Ce.chats[s]:void 0,Ve=(s?Ce.chatState[s]:void 0)?.messages??[],ae=A.filter(ce=>B3(ce)?!v_e(Ve,ce):!0),Se=Fe?.model,Be=i.model!==Se;let We,Ae=!1;Be?(We=i.model,Ae=!0):Se?(We=Se,Ae=!1):(We=void 0,Ae=!1);const ve=__e(V),Ge={userId:Y,content:V,metadata:ke,contextKey:o,...ee?{}:{chatId:s},...Ae?{model:We??""}:{},...ae.length>0?{attachments:ae}:{},...n?{mentions:ve,participantIds:Array.from(new Set([Y,...r])),senderDisplayName:a.config.user?.displayName,senderAvatarUrl:a.config.user?.avatarUrl}:{}},de=()=>{_(le.current,void 0)},Ze=ce=>{if(ce?.name==="AbortError"){const Me=C.current??le.current;return L.current.has(Me)?(E(le.current),L.current.delete(Me)):(de(),t.current?.setDraft(ge)),{type:"aborted"}}throw ce},Ke=async()=>{m(le.current,pt.Sending);try{if(!a.transport.sendMultiUserMessage)throw new Error("Multi-user chat requires a transport that supports sendMultiUserMessage");const ce=await a.transport.sendMultiUserMessage(Ge);return p(ce.chat),ee&&(f(le.current,ce.chat.id),le.current=ce.chat.id,C.current=ce.chat.id,h(ce.chat.id)),v(ce.chat.id,[ce.message]),m(ce.chat.id,ya(ce.chat.status)),de(),{type:"success"}}catch(ce){return Ze(ce)}},He=async()=>{let ce=`pending-${Date.now()}`,Me="",be;m(le.current,pt.Streaming),_(le.current,{id:ce,content:"",reasoning:"",toolCalls:[],attachments:[],chat:s||"",role:exports.MessageRole.Assistant,createdAt:new Date().toISOString()});try{let Pe=s;const q=ne=>{if(ne.type===exports.StreamChunkType.Chat&&ne.chat){p(ne.chat),Pe=ne.chat.id,ee&&(C.current=ne.chat.id,f(le.current,ne.chat.id),le.current=ne.chat.id,h(ne.chat.id));return}if(ne.type===exports.StreamChunkType.Reasoning&&ne.reasoning){Me+=ne.reasoning,be={...be??{id:ce,chat:Pe,role:exports.MessageRole.Assistant,content:"",createdAt:new Date().toISOString()},reasoning:Me},_(le.current,be);return}if(ne.type===exports.StreamChunkType.Error&&ne.error)throw new Error(ne.error);if(ne.message&&ne.message.role===exports.MessageRole.User){v(ne.message.chat,[ne.message]);return}ne.message&&(ce=ne.message.id,be={...ne.message,reasoning:Me||ne.message.reasoning},_(le.current,be)),ne.done&&(be&&v(le.current,[be]),m(le.current,pt.Idle),de())},X=await a.transport.streamMessage(Ge,q,{streamKey:C.current});if(X){const ne=X.messages.map(Le=>be&&Le.id===be.id&&Le.role===exports.MessageRole.Assistant?{...Le,reasoning:Me}:Le);v(X.id,ne);const pe=a.store.getState();return(pe.activeChatId??pe.draftChatKey)===le.current&&h(X.id),de(),{type:"success"}}return de(),{type:"success"}}catch(Pe){return Ze(Pe)}};try{const ce=await(n?Ke():He());return ce.type==="success"&&($.current=!1),ce}catch(ce){de();const Me=ce?.chat;Me&&(p(Me),h(Me.id));const be=ce instanceof Error?ce:new Error("Failed to send message");return g(le.current,be.message||"Failed to send message"),m(le.current,pt.Idle),t.current?.setDraft(ge),$.current=!1,{type:"error",error:be}}finally{P.current=!1,n||m(le.current,pt.Idle),C.current=void 0}},[s,o,i.model,n,r,a.transport,a.config.user?.displayName,a.config.user?.avatarUrl,a.config.user?.id,p,h,_,m,Z,e,f,t,g]),K=G.useCallback(async()=>{if(d!==pt.Idle||P.current||!u.length||$.current)return;const V=u[0];P.current=!0,x(U,V.id);try{await J(V.content,V.attachments)}finally{P.current=!1}},[d,u,U,J,x]);G.useEffect(()=>{K()},[K]);const R=G.useCallback(async V=>{if(P.current)return;const A=u.find(Y=>Y.id===V);if(A){$.current=!1,P.current=!0,x(U,V);try{await J(A.content,A.attachments)}finally{P.current=!1}}},[u,U,x,J]),H=G.useCallback(async V=>{const Y=t.current.getDraft().attachments;if(!n&&d!==pt.Idle){b(U,V,Y),t.current?.clearDraft();return}$.current=!1,t.current?.clearDraft(),await J(V,Y)},[d,n,b,U,J,t,w,N]),j=G.useCallback(()=>{$.current=!0;const V=C.current??U;L.current.add(V),a.transport.cancelStream?.(V),E(V),m(V,pt.Idle)},[U,a.transport,E,m]),D=G.useCallback(async V=>{d===pt.Streaming&&j(),await R(V)},[d,j,R]);return{pendingKey:U,queuedMessages:u,activeChatStatus:n?pt.Idle:d,activeChatId:s,removeQueuedMessage:x,handleSubmit:H,handleStop:j,handleQueuedClick:D}},v_e=(e,t)=>{const n=JSON.stringify(t.metadata?.data);let r;for(let a=e.length-1;a>=0;a--){const o=e[a].attachments?.find(B3);if(o){r=o;break}}return!r||r.url!==t.url?!1:JSON.stringify(r.metadata?.data)===n},B3=e=>e.type===exports.AgentAttachmentType.Context&&e.metadata?.kind==="pageContext",__e=e=>{const t=e.matchAll(/(^|[\s([{])@([a-zA-Z0-9_.-]+)/g),n=new Set,r=[];for(const a of t){const i=a[2],o=i.toLowerCase();n.has(o)||(n.add(o),r.push({type:o==="agent"?"agent":"user",name:i}))}return r.length>0?r:void 0},x_e=({queuedMessages:e,onSendQueued:t,onRemoveQueued:n})=>e.length?S.jsxs("div",{className:"mp-agent-composer-queue",children:[S.jsx("div",{className:"mp-agent-composer-queue-header",children:S.jsxs("span",{children:[e.length," message",e.length>1?"s":""," queued"]})}),S.jsx("div",{className:"mp-agent-composer-queue-items",children:e.map(r=>S.jsxs("div",{className:"mp-agent-composer-queue-item",children:[S.jsxs("span",{className:"mp-agent-composer-queue-item-text",children:[r.content,r.attachments?.length?S.jsxs("span",{style:{marginLeft:8,opacity:.7,display:"inline-flex",alignItems:"center",gap:4},children:[S.jsx(Qi,{size:12}),r.attachments.length]}):null]}),S.jsxs("div",{className:"mp-agent-composer-queue-item-actions",children:[S.jsx("button",{type:"button",className:"mp-agent-composer-queue-button",onClick:()=>t(r.id),"aria-label":"Send queued message",children:S.jsx($d,{size:12})}),S.jsx("button",{type:"button",className:"mp-agent-composer-queue-button",onClick:()=>n(r.id),"aria-label":"Remove queued message",children:S.jsx(w5,{size:12})})]})]},r.id))})]}):null;function w_e(e,t){return e.size>t.maxFileSize?{type:"size",message:`File "${e.name}" exceeds maximum size of ${pp(t.maxFileSize)}`,fileName:e.name}:null}function E_e(e,t,n){if(e.length+t.filter(s=>s.type==="file").length>n.maxFilesPerMessage)return{type:"count",message:`Maximum ${n.maxFilesPerMessage} files per message allowed`};for(const s of e){const l=w_e(s,n);if(l)return l}const a=t.filter(s=>s.type==="file").reduce((s,l)=>{const u=l.metadata?.size||l.size||0;return s+u},0),i=e.reduce((s,l)=>s+l.size,0);return a+i>n.maxTotalAttachmentsSize?{type:"totalSize",message:`Total attachment size exceeds maximum of ${pp(n.maxTotalAttachmentsSize)}`}:null}function pp(e){if(e===0)return"0 Bytes";const t=1024,n=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return Math.round(e/Math.pow(t,r)*100)/100+" "+n[r]}function M_e(){return{maxFileSize:10*1024*1024,maxTotalAttachmentsSize:50*1024*1024,maxFilesPerMessage:10,allowedMimeTypes:void 0}}const U3=(e,t)=>{switch(e.type){case exports.AgentAttachmentType.Link:return S.jsx(k5,{size:12});case exports.AgentAttachmentType.Artifact:return S.jsx(Qi,{size:12});case exports.AgentAttachmentType.Context:{const n=e?.metadata?.kind;if(n&&t?.[n])return t[n];switch(n){case"pageContext":return S.jsx(Pd,{size:12});case"formSnapshot":case"formField":return S.jsx(b5,{size:12});default:return S.jsx(qd,{size:12})}}case exports.AgentAttachmentType.File:default:return S.jsx(y5,{size:12})}},S_e=({attachments:e})=>{const{config:t}=$e();return!e||e.length===0?null:S.jsx("div",{className:"mp-agent-message-attachments","aria-label":"Message attachments",children:e.map((n,r)=>{const a=S.jsxs(S.Fragment,{children:[S.jsx("span",{className:"mp-agent-message-attachment-icon",children:U3(n,t.contextAttachmentIcons)}),S.jsx("span",{className:"mp-agent-message-attachment-name",children:n.name})]});return n.url?S.jsx("a",{className:"mp-agent-message-attachment",href:n.url,target:"_blank",rel:"noreferrer",title:n.url,children:a},n.id||r):S.jsx("span",{className:"mp-agent-message-attachment",title:n.mimeType??n.name,children:a},n.id||r)})})},N_e=({attachments:e,onRemove:t,uploadProgress:n,uploadErrors:r})=>{const a=Wt(),{config:i}=$e();return!e||e.length===0?null:S.jsx("div",{className:"mp-agent-composer-attachments","aria-label":a.attachments,children:e.map(o=>{const s=n?.get(o.id),l=r?.get(o.name),u=o.metadata?.size||o.size,d=u?` (${pp(u)})`:"";return S.jsxs("span",{className:`mp-agent-attachment-chip ${l?"mp-agent-attachment-chip-error":""} ${s?.status==="uploading"?"mp-agent-attachment-chip-uploading":""}`,title:l||o.name,children:[S.jsx("span",{className:"mp-agent-attachment-chip-icon",children:U3(o,i.contextAttachmentIcons)}),S.jsxs("span",{className:"mp-agent-attachment-chip-name",title:o.name,children:[o.name,d]}),s?.status==="uploading"&&S.jsxs("span",{className:"mp-agent-attachment-chip-progress",children:[s.progress,"%"]}),l&&S.jsx("span",{className:"mp-agent-attachment-chip-error-text",title:l,children:"⚠"}),t?S.jsx(nn,{size:"sm",icon:"X",type:"button",onClick:p=>{p.preventDefault(),p.stopPropagation(),t(o.id)},"aria-label":`Remove attachment ${o.name}`}):null]},o.id)})})},A_e=e=>{const t=e.trim();if(!t||/\s/.test(t))return;const n=i=>i.replace(/[)\].,;:!?]+$/,"");if(!/^https?:\/\//i.test(t))return;const r=i=>{try{const o=new URL(i);return o.protocol!=="http:"&&o.protocol!=="https:"?void 0:o.toString()}catch{return}},a=n(t);return r(a)},T_e=e=>{try{const t=new URL(e);return t.hostname+(t.pathname&&t.pathname!=="/"?t.pathname:"")}catch{return e}},ld="mp-agent:locationchange",b2="__mp_agent_history_patched__",k2=()=>{try{window.dispatchEvent(new Event(ld))}catch{}},C_e=()=>{if(typeof window>"u")return;const e=window;if(!e[b2]){e[b2]=!0;try{const t=history.pushState;history.pushState=function(...n){const r=t.apply(this,n);return k2(),r}}catch{}try{const t=history.replaceState;history.replaceState=function(...n){const r=t.apply(this,n);return k2(),r}}catch{}}},R_e=e=>{if(typeof window>"u")return()=>{};C_e();const t=()=>e();return window.addEventListener("popstate",t),window.addEventListener("hashchange",t),window.addEventListener(ld,t),()=>{window.removeEventListener("popstate",t),window.removeEventListener("hashchange",t),window.removeEventListener(ld,t)}};async function I_e(e,t,n,r){const a=await fetch(r.presignedUrlEndpoint,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",...r.getAuthHeaders?.()||{}},body:JSON.stringify({filename:e.name,mimeType:e.type||"application/octet-stream",size:e.size,chatId:t,userId:n})});if(!a.ok){const o=await a.text();throw new Error(`Failed to get presigned URL: ${a.status} ${o}`)}const i=await a.json();return{url:i.url,key:i.key}}async function O_e(e,t,n){return new Promise((r,a)=>{const i=new XMLHttpRequest;i.upload.addEventListener("progress",o=>{if(o.lengthComputable&&n){const s=Math.round(o.loaded/o.total*100);n(s)}}),i.addEventListener("load",()=>{i.status>=200&&i.status<300?r():a(new Error(`Upload failed: ${i.status} ${i.statusText}`))}),i.addEventListener("error",()=>{a(new Error("Upload failed: network error"))}),i.addEventListener("abort",()=>{a(new Error("Upload aborted"))}),i.open("PUT",t),i.setRequestHeader("Content-Type",e.type||"application/octet-stream"),i.send(e)})}async function L_e(e,t,n){const r=_t.nanoid(),a={fileId:r,fileName:e.name,progress:0,status:"pending"};try{n.onProgress?.({...a,status:"uploading",progress:0});const{url:i,key:o}=await I_e(e,n.chatId,n.userId,t);return await O_e(e,i,s=>{n.onProgress?.({...a,status:"uploading",progress:s})}),n.onProgress?.({...a,status:"completed",progress:100}),{id:r,type:exports.AgentAttachmentType.File,name:e.name,mimeType:e.type||void 0,size:e.size,metadata:{uploadedAt:new Date().toISOString(),s3Key:o,processingStatus:"pending",size:e.size,lastModified:e.lastModified}}}catch(i){const o=i instanceof Error?i.message:"Unknown error";throw n.onProgress?.({...a,status:"error",error:o}),i}}async function D_e(e,t,n){const r=await Promise.allSettled(e.map(o=>L_e(o,t,n))),a=[],i=[];if(r.forEach((o,s)=>{o.status==="fulfilled"?a.push(o.value):i.push(new Error(`Failed to process ${e[s].name}: ${o.reason}`))}),i.length>0&&a.length===0)throw i[0];return i.length>0&&console.warn("Some files failed to upload:",i),a}const z_e=({options:e,value:t,onChange:n,placeholder:r="Select...",disabled:a=!1,className:i="",triggerClassName:o="",placement:s="bottom-start",searchable:l=!1,searchPlaceholder:u="Search...",searchFilter:d})=>{const[p,m]=G.useState(!1),[h,g]=G.useState(null),[f,x]=G.useState(""),_=G.useRef([]),b=G.useRef(null),{refs:v,floatingStyles:E,context:N,isPositioned:w}=Qd({open:p,onOpenChange:m,placement:s,strategy:"absolute",whileElementsMounted:Gd,middleware:[Wd(8),Yd({fallbackPlacements:["top-start","bottom-start","top-end","bottom-end"]}),Kd({padding:8})]}),$=Q5(N,{enabled:!a}),P=Xd(N),C=ep(N),U=Q8e(N,{listRef:_,activeIndex:h,onNavigate:g,enabled:p&&!l,virtual:!1}),{getReferenceProps:Z,getFloatingProps:J,getItemProps:K}=Jd(l?[$,P,C]:[$,P,C,U]),R=e.findIndex(Y=>Y.value===t),H=R>=0?e[R]:void 0,j=G.useMemo(()=>{const Y=f.trim().toLowerCase();if(!l||!Y)return e;const O=d?le=>d(le,Y):le=>`${le.label} ${le.description??""}`.toLowerCase().includes(Y);return e.filter(O)},[e,f,l,d]);G.useEffect(()=>{if(!p){g(null),x("");return}l&&setTimeout(()=>b.current?.focus(),0);const Y=j.findIndex(ee=>ee.value===t);g(Y>=0?Y:0)},[p,l,t,j]),G.useEffect(()=>{p&&g(j.length>0?0:null)},[f,j.length,p]);const D=Y=>j.length===0?null:Y<0?j.length-1:Y>=j.length?0:Y,V=Y=>{Y!=null&&_.current[Y]?.scrollIntoView({block:"nearest"})},A=Y=>{n(Y),m(!1),g(null),x("")};return S.jsxs("div",{className:`mp-agent-dropdown ${i}`,children:[S.jsxs("button",{ref:v.setReference,type:"button",className:`mp-agent-dropdown-trigger ${o}`,disabled:a,"aria-expanded":p,"aria-haspopup":"listbox",...Z(),children:[S.jsx("span",{className:"mp-agent-dropdown-trigger-content",children:H?S.jsxs(S.Fragment,{children:[H.icon&&S.jsx("span",{className:"mp-agent-dropdown-trigger-icon",children:H.icon}),S.jsx("span",{className:"mp-agent-dropdown-trigger-label",children:H.label})]}):S.jsx("span",{className:"mp-agent-dropdown-trigger-placeholder",children:r})}),S.jsx(Fd,{size:16,className:`mp-agent-dropdown-chevron ${p?"open":""}`})]}),p&&S.jsxs("div",{role:"listbox",ref:v.setFloating,style:{...E,opacity:w?1:0,pointerEvents:w?"auto":"none",transition:w?"opacity 0.15s ease-out":"none"},className:"mp-agent-dropdown-menu",...J(),children:[l&&S.jsx("div",{className:"mp-agent-dropdown-search",onKeyDown:Y=>Y.stopPropagation(),children:S.jsx("input",{ref:b,className:"mp-agent-dropdown-search-input",value:f,placeholder:u,onChange:Y=>x(Y.target.value),onKeyDown:Y=>{if(Y.key==="Escape"){Y.preventDefault(),m(!1),x("");return}if(Y.key==="ArrowDown"||Y.key==="ArrowUp"){Y.preventDefault();const ee=Y.key==="ArrowDown"?1:-1,O=h??(ee>0?-1:0),le=D(O+ee);g(le),V(le);return}if(Y.key==="Enter"){if(h==null)return;const ee=j[h];if(!ee)return;Y.preventDefault(),A(ee.value)}}})}),S.jsxs("div",{className:"mp-agent-dropdown-list",children:[j.map((Y,ee)=>S.jsxs("button",{ref:O=>{_.current[ee]=O},type:"button",className:`mp-agent-dropdown-item ${t===Y.value?"selected":""} ${h===ee?"active":""}`,role:"option","aria-selected":t===Y.value,...K({onClick:()=>A(Y.value),onMouseEnter:()=>{g(ee)},onKeyDown:O=>{(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),A(Y.value))}}),children:[Y.icon&&S.jsx("span",{className:"mp-agent-dropdown-item-icon",children:Y.icon}),S.jsxs("span",{className:"mp-agent-dropdown-item-content",children:[S.jsx("span",{className:"mp-agent-dropdown-item-label",children:Y.label}),Y.description&&S.jsx("span",{className:"mp-agent-dropdown-item-description",children:Y.description})]})]},Y.value)),l&&j.length===0&&S.jsx("div",{className:"mp-agent-dropdown-empty","aria-label":"No results",children:"No results"})]})]})]})},$_e=G.memo(()=>{const e=$e(),t=fe(p=>p.composer),n=fe(p=>p.contextKey),r=fe(p=>p.setComposerOptions),a=e.config.models,{data:i,isLoading:o}=s3(),s=G.useMemo(()=>{const p=i&&i.length>0?i:a;return M3(p,e.config.transport).filter(h=>!h.contexts?.length||h.contexts.includes(n))},[i,a,e.config.transport,n]),l=G.useMemo(()=>{const p=s.slice().sort((m,h)=>m.label.localeCompare(h.label,void 0,{sensitivity:"base"})).map(m=>({value:m.id,label:m.label}));return[{value:ta,label:"Auto"},...p]},[s]),u=G.useMemo(()=>t.model!==void 0?t.model:ta,[t.model]),d=G.useCallback(p=>{p===ta?(r({model:void 0}),p2(e.config.transport,ta)):(r({model:p}),p2(e.config.transport,p))},[r,e.config.transport]);return o&&!a?.length||l.length===0?null:S.jsx(z_e,{options:l,value:u,onChange:d,placeholder:"Select model...",searchable:!0,searchPlaceholder:"Search models...",placement:"top-start",triggerClassName:"mp-agent-model-selector-trigger"})}),F_e=e=>{if(!e)return"";let t=e.replace(/[_-]+/g," ");return t=t.replace(/([a-z0-9])([A-Z])/g,"$1 $2"),t=t.trim().replace(/\s+/g," "),t?t.charAt(0).toUpperCase()+t.slice(1):""},P_e=({checked:e,disabled:t,onChange:n,className:r="",...a})=>{const i=o=>{o.preventDefault(),!t&&n(!e)};return S.jsx("button",{type:"button",role:"switch","aria-checked":e,disabled:t,className:`mp-agent-switch ${e?"on":"off"} ${r}`.trim(),onClick:i,...a,children:S.jsx("span",{className:"mp-agent-switch-thumb"})})},v2=e=>e.reduce((t,n)=>(t[n.agentName]={...n.tools},t),{}),H3=({preferences:e,disabled:t})=>{const n=Wt(),{upsertSingle:r}=h3(),[a,i]=G.useState(()=>v2(e)),[o,s]=G.useState({});G.useEffect(()=>{i(v2(e))},[e]);const l=r.error?.message,u=G.useMemo(()=>e.some(p=>Object.keys(p.tools).length>0),[e]),d=(p,m,h)=>{i(g=>{const f=g[p]??{},x=f,_={...f,[m]:h},b={...g,[p]:_};return s(v=>({...v,[p]:{...v[p]??{},[m]:!0}})),r.mutate({agentName:p,input:{tools:_}},{onError:()=>{i(v=>({...v,[p]:x}))},onSettled:()=>{s(v=>{const E={...v[p]??{}};if(delete E[m],Object.keys(E).length===0){const{[p]:N,...w}=v;return w}return{...v,[p]:E}})}}),b})};return S.jsxs("div",{className:"mp-agent-preferences-panel",children:[!u&&S.jsx("div",{className:"mp-agent-preferences-empty",children:n.agentSettingsNoConfigurableTools}),e.map(p=>{const m=a[p.agentName]??{},h=Object.entries(m);return S.jsxs("div",{className:"mp-agent-preferences-agent",children:[S.jsx("div",{className:"mp-agent-preferences-agent-header",children:S.jsx("strong",{children:p.agentName})}),h.length===0?S.jsx("div",{className:"mp-agent-preferences-empty",children:n.agentSettingsNoToolsForAgent}):S.jsx("div",{className:"mp-agent-preferences-tools",children:h.map(([g,f])=>{const x=!!o[p.agentName]?.[g];return S.jsxs("label",{className:"mp-agent-preferences-tool",children:[S.jsx("span",{className:"mp-agent-preferences-tool-label",children:F_e(g)}),S.jsx(P_e,{checked:f,onChange:_=>d(p.agentName,g,_),disabled:!!t||x})]},`${p.agentName}:${g}`)})})]},p.agentName)}),l&&S.jsx("div",{className:"mp-agent-preferences-error",children:l})]})};function q_e(e){return e.map(t=>{const n=(t.tools??[]).reduce((r,a)=>(a.userConfigurable&&(r[a.title]=!a.disabledByDefault),r),{});return{agentName:t.name,tools:n}})}const B_e=()=>{const e=Wt(),t=$e(),n=fe(l=>l.contextKey),{data:r,isLoading:a,isError:i}=u3(n),o=G.useMemo(()=>q_e(r??[]),[r]),s=!!t.transport.upsertAgentPreferences&&!!t.transport.upsertAgentPreferencesBatch;return a?S.jsx(S.Fragment,{children:e.agentSettingsLoading}):i?S.jsx(S.Fragment,{children:e.agentSettingsError}):S.jsx(H3,{preferences:o,disabled:!s})},U_e=()=>{const[e,t]=G.useState(!1),n=Wt(),{refs:r,floatingStyles:a,context:i,isPositioned:o}=Qd({open:e,onOpenChange:t,placement:"top-start",strategy:"absolute",whileElementsMounted:Gd,middleware:[Wd(8),Yd({fallbackPlacements:["bottom-start","top-end","bottom-end"]}),Kd({padding:8})]}),s=Q5(i),l=Xd(i),u=ep(i),{getReferenceProps:d,getFloatingProps:p}=Jd([s,l,u]);return S.jsxs("div",{className:"mp-agent-tool-config-dropdown",children:[S.jsx(bn,{content:n.agentSettingsTooltip,children:S.jsx("button",{ref:r.setReference,type:"button",className:"mp-agent-composer-button mp-agent-composer-tool-button","aria-label":n.agentSettingsTooltip,...d(),children:S.jsx(v5,{size:16})})}),e&&S.jsx("div",{ref:r.setFloating,style:{...a,opacity:o?1:0,pointerEvents:o?"auto":"none",transition:o?"opacity 0.15s ease-out":"none"},className:"mp-agent-tool-config-panel",...p(),children:S.jsx(B_e,{})})]})},H_e=G.forwardRef(({autoFocus:e,activeChatId:t,status:n,onStop:r,onSubmit:a},i)=>{const o=Wt(),s=$e(),l=G.useRef(null),u=G.useRef(null),d=fe(ae=>ae.activeChatId??ae.draftChatKey),p=fe(ae=>ze(ae,d).composerDraft),m=fe(ae=>ze(ae,d).composerError),h=fe(ae=>ze(ae,d).pageContextDismissed),g=fe(ae=>ae.setComposerValue),f=fe(ae=>ae.setComposerDraft),x=fe(ae=>ae.clearComposerDraft),_=fe(ae=>ae.setComposerError),b=fe(ae=>ae.addComposerAttachments),v=fe(ae=>ae.removeComposerAttachment),E=fe(ae=>ae.setPageContextDismissed),N=p.value,w=p.attachments,[$,P]=G.useState(new Map),[C,L]=G.useState(new Map),U=G.useRef(N),Z=G.useRef(w),J=G.useRef(h),K=s.config.features?.pageContextAttachments!==!1,R=s.config.composerAttachmentActions,H=ae=>ae.type===exports.AgentAttachmentType.Context&&ae?.metadata?.kind==="pageContext",j=w.some(H),D=()=>{if(K)return s.buildPageContextAttachment()};G.useEffect(()=>{Z.current=w},[w]),G.useEffect(()=>{U.current=N},[N]),G.useEffect(()=>{J.current=h},[h]),G.useEffect(()=>{if(!K||h||j)return;const ae=D();ae&&b(d,[ae])},[K,h,j,d,b]),G.useEffect(()=>{if(K&&!(typeof window>"u"))return R_e(()=>{if(J.current)return;const ae=Z.current,Se=ae.find(H);if(!Se)return;const Be=D();if(!Be)return;const We={...Be,id:Se.id},Ae=ae.map(ve=>ve.id===Se.id?We:ve);f(d,{value:U.current,attachments:Ae})})},[K,d,f]),G.useImperativeHandle(i,()=>({setValue:ae=>{g(d,ae)},getDraft:()=>({value:N,attachments:w}),setDraft:ae=>{f(d,{value:ae.value,attachments:ae.attachments??[]})},clearDraft:()=>{x(d)},buildPageContextAttachment:()=>D()})),G.useEffect(()=>{const ae=l.current;ae&&(ae.style.height="auto",ae.style.height=`${Math.min(ae.scrollHeight,200)}px`)},[N]);const V=async ae=>{if(!ae||ae.length===0)return;const Se=Array.from(ae),Be=M_e(),We=E_e(Se,w,Be);if(We){L(Ae=>{const ve=new Map(Ae);return Se.forEach(Ge=>{ve.set(Ge.name,We.message)}),ve});return}L(Ae=>{const ve=new Map(Ae);return Se.forEach(Ge=>ve.delete(Ge.name)),ve});try{const Ae=s.config.transport;if(Ae.mode!=="proxy")throw new Error("File uploads are only supported with proxy transport");const ve={presignedUrlEndpoint:`${Ae.baseUrl}/files/upload/presigned`,getAuthHeaders:()=>{const de={};return Ae.headers?Ae.headers:(Ae.apiKey&&(de.Authorization=`Bearer ${Ae.apiKey}`),de)}},Ge=await D_e(Se,ve,{chatId:t,userId:s.config.user?.id,onProgress:de=>{P(Ze=>{const Ke=new Map(Ze);return Ke.set(de.fileId,de),Ke})}});b(d,Ge),setTimeout(()=>{P(de=>{const Ze=new Map(de);return Ge.forEach(Ke=>Ze.delete(Ke.id)),Ze})},2e3)}catch(Ae){const ve=Ae instanceof Error?Ae.message:"Failed to upload files";L(Ge=>{const de=new Map(Ge);return Se.forEach(Ze=>{de.set(Ze.name,ve)}),de})}},A=()=>{u.current?.click()},Y=ae=>{const Se=A_e(ae);if(!Se)return!1;if(w.some(Ae=>Ae.type===exports.AgentAttachmentType.Link&&Ae.url===Se))return!0;const Be=T_e(Se),We={id:_t.nanoid(),url:Se,name:Be,type:exports.AgentAttachmentType.Link};return b(d,[We]),!0},ee=async ae=>{await V(ae.target.files),ae.target.value=""},O=ae=>{const Se=w.find(Be=>Be.id===ae);Se&&H(Se)&&E(d,!0),v(d,ae)},le=()=>{if(typeof window>"u"||typeof document>"u")return!1;const ae=b3(),Se=ae?.selectedText??window.getSelection?.()?.toString()?.trim()??"";if(!Se)return!1;const Be=window.location?.href,We=Se.slice(0,20),Ae=Se.length>20?We+"...":Se,ve=po({kind:"webSnippet",url:Be,title:Ae,selectedText:Se,source:{app:"browser",url:Be},...ae?.target?{target:ae.target}:{}});return b(d,[ve]),!0},ge=ae=>{ae.preventDefault();const Se=N.trim();Se&&(_(d,void 0),a(Se))},ke=ae=>{ae.key==="Enter"&&!ae.shiftKey&&(ae.preventDefault(),ge(ae))},Ce=ae=>{m&&_(d,void 0),g(d,ae.target.value)},Fe=ae=>{if(ae.nativeEvent.shiftKey)return;const Se=ae.clipboardData?.getData("text/plain")??"";if(!Se)return;Y(Se)&&ae.preventDefault()},Ve=!!N.trim();return S.jsxs(S.Fragment,{children:[S.jsxs("form",{onSubmit:ge,className:"mp-agent-composer-input-wrapper",id:"composer-form",children:[S.jsx("input",{ref:u,type:"file",multiple:!0,style:{display:"none"},onChange:ee}),S.jsx(N_e,{attachments:w,onRemove:O,uploadProgress:$,uploadErrors:C}),S.jsx("textarea",{rows:2,name:"message",ref:l,value:N,autoFocus:e,className:"mp-agent-composer-textarea",placeholder:t?o.followUp:o.newChat,onChange:Ce,onKeyDown:ke,onPaste:Fe})]}),S.jsxs("div",{className:"mp-agent-composer-actions",children:[S.jsxs("div",{className:"mp-agent-composer-actions-left",children:[s.config.features?.modelSwitching&&S.jsx($_e,{}),s.config.features?.toolConfiguration&&S.jsx(U_e,{}),s.config.features?.fileAttachments&&S.jsx(bn,{content:o.attachFiles,children:S.jsx("button",{type:"button",className:"mp-agent-composer-button mp-agent-composer-tool-button",onClick:A,"aria-label":o.attachFiles,children:S.jsx(Qi,{size:16})})}),s.config.features?.selectionAttachments&&S.jsx(bn,{content:o.attachSelectionToContext,children:S.jsx("button",{type:"button",className:"mp-agent-composer-button mp-agent-composer-tool-button",onClick:()=>{le()},"aria-label":o.attachSelectionToContext,children:S.jsx(qd,{size:16})})}),K&&!j&&S.jsx(bn,{content:"Attach page context",children:S.jsx("button",{type:"button",className:"mp-agent-composer-button mp-agent-composer-tool-button",onClick:()=>{E(d,!1);const ae=D();ae&&b(d,[ae])},"aria-label":"Attach page context",children:S.jsx(Pd,{size:16})})}),R&&S.jsx(R,{chatKey:d,activeChatId:t,attachments:w,addAttachments:ae=>b(d,ae),removeAttachment:O})]}),S.jsx("div",{className:"mp-agent-composer-actions-right",children:n===pt.Streaming&&!Ve?S.jsx(bn,{content:o.stopStreaming,children:S.jsx("button",{type:"button",onClick:r,"aria-label":o.stopStreaming,className:"mp-agent-composer-button mp-agent-composer-send-button",children:S.jsx(x5,{size:12})})}):S.jsx(bn,{content:Ve?o.sendMessage:o.typeMessageToSend,children:S.jsx("button",{type:"submit",form:"composer-form",disabled:!Ve,"aria-label":o.sendMessage,className:"mp-agent-composer-button mp-agent-composer-send-button",children:S.jsx($d,{size:16})})})})]})]})}),j3=({autoFocus:e,multiUser:t=!1,participantIds:n})=>{const r=G.useRef({setValue:()=>{},getDraft:()=>({value:"",attachments:[]}),setDraft:()=>{},clearDraft:()=>{}}),{pendingKey:a,queuedMessages:i,activeChatStatus:o,activeChatId:s,handleSubmit:l,handleStop:u,handleQueuedClick:d,removeQueuedMessage:p}=k_e({composerFormRef:r,multiUser:t,participantIds:n});return S.jsx("div",{className:"mp-agent-composer-wrapper",children:S.jsxs("div",{className:"mp-agent-composer",children:[S.jsx(x_e,{queuedMessages:i,onSendQueued:d,onRemoveQueued:m=>p(a,m)}),S.jsx(H_e,{status:o,ref:r,autoFocus:e,activeChatId:s,onStop:u,onSubmit:l})]})})};function wr(e,t,n){let r=n.initialDeps??[],a,i=!0;function o(){var s,l,u;let d;n.key&&((s=n.debug)!=null&&s.call(n))&&(d=Date.now());const p=e();if(!(p.length!==r.length||p.some((g,f)=>r[f]!==g)))return a;r=p;let h;if(n.key&&((l=n.debug)!=null&&l.call(n))&&(h=Date.now()),a=t(...p),n.key&&((u=n.debug)!=null&&u.call(n))){const g=Math.round((Date.now()-d)*100)/100,f=Math.round((Date.now()-h)*100)/100,x=f/16,_=(b,v)=>{for(b=String(b);b.length<v;)b=" "+b;return b};console.info(`%c⏱ ${_(f,5)} /${_(g,5)} ms`,`
|
|
8294
8294
|
font-size: .6rem;
|
|
8295
8295
|
font-weight: bold;
|
|
8296
|
-
color: hsl(${Math.max(0,Math.min(120-120*x,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(i&&n.skipInitialOnChange)&&n.onChange(a),i=!1,a}return o.updateDeps=s=>{r=s},o}function _2(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const j_e=(e,t)=>Math.abs(e-t)<1.01,V_e=(e,t,n)=>{let r;return function(...a){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,a),n)}},x2=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},G_e=e=>e,W_e=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let a=t;a<=n;a++)r.push(a);return r},K_e=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const a=o=>{const{width:s,height:l}=o;t({width:Math.round(s),height:Math.round(l)})};if(a(x2(n)),!r.ResizeObserver)return()=>{};const i=new r.ResizeObserver(o=>{const s=()=>{const l=o[0];if(l?.borderBoxSize){const u=l.borderBoxSize[0];if(u){a({width:u.inlineSize,height:u.blockSize});return}}a(x2(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(s):s()});return i.observe(n,{box:"border-box"}),()=>{i.unobserve(n)}},w2={passive:!0},E2=typeof window>"u"?!0:"onscrollend"in window,Y_e=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;let a=0;const i=e.options.useScrollendEvent&&E2?()=>{}:V_e(r,()=>{t(a,!1)},e.options.isScrollingResetDelay),o=d=>()=>{const{horizontal:p,isRtl:m}=e.options;a=p?n.scrollLeft*(m&&-1||1):n.scrollTop,i(),t(a,d)},s=o(!0),l=o(!1);n.addEventListener("scroll",s,w2);const u=e.options.useScrollendEvent&&E2;return u&&n.addEventListener("scrollend",l,w2),()=>{n.removeEventListener("scroll",s),u&&n.removeEventListener("scrollend",l)}},Z_e=(e,t,n)=>{if(t?.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},X_e=(e,{adjustments:t=0,behavior:n},r)=>{var a,i;const o=e+t;(i=(a=r.scrollElement)==null?void 0:a.scrollTo)==null||i.call(a,{[r.options.horizontal?"left":"top"]:o,behavior:n})};class Q_e{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var n,r,a;return((a=(r=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:r.now)==null?void 0:a.call(r))??Date.now()},this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(a=>{a.forEach(i=>{const o=()=>{const s=i.target,l=this.indexFromElement(s);if(!s.isConnected){this.observer.unobserve(s);return}this.shouldMeasureDuringScroll(l)&&this.resizeItem(l,this.options.measureElement(s,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var a;(a=r())==null||a.disconnect(),n=null},observe:a=>{var i;return(i=r())==null?void 0:i.observe(a,{box:"border-box"})},unobserve:a=>{var i;return(i=r())==null?void 0:i.unobserve(a)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([r,a])=>{typeof a>"u"&&delete n[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:G_e,rangeExtractor:W_e,onChange:()=>{},measureElement:Z_e,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...n}},this.notify=n=>{var r,a;(a=(r=this.options).onChange)==null||a.call(r,this,n)},this.maybeNotify=wr(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:process.env.NODE_ENV!=="production"&&"maybeNotify",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(a=>{this.observer.observe(a)}),this.unsubs.push(this.options.observeElementRect(this,a=>{this.scrollRect=a,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(a,i)=>{this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()<a?"forward":"backward":null,this.scrollOffset=a,this.isScrolling=i,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,r)=>{const a=new Map,i=new Map;for(let o=r-1;o>=0;o--){const s=n[o];if(a.has(s.lane))continue;const l=i.get(s.lane);if(l==null||s.end>l.end?i.set(s.lane,s):s.end<l.end&&a.set(s.lane,!0),a.size===this.options.lanes)break}return i.size===this.options.lanes?Array.from(i.values()).sort((o,s)=>o.end===s.end?o.index-s.index:o.end-s.end)[0]:void 0},this.getMeasurementOptions=wr(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(n,r,a,i,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==s&&(this.lanesChangedFlag=!0),this.prevLanes=s,this.pendingMeasuredCacheIndexes=[],{count:n,paddingStart:r,scrollMargin:a,getItemKey:i,enabled:o,lanes:s}),{key:!1}),this.getMeasurements=wr(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:n,paddingStart:r,scrollMargin:a,getItemKey:i,enabled:o,lanes:s},l)=>{if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const m of this.laneAssignments.keys())m>=n&&this.laneAssignments.delete(m);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(m=>{this.itemSizeCache.set(m.key,m.size)}));const u=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1);const d=this.measurementsCache.slice(0,u),p=new Array(s).fill(void 0);for(let m=0;m<u;m++){const h=d[m];h&&(p[h.lane]=m)}for(let m=u;m<n;m++){const h=i(m),g=this.laneAssignments.get(m);let f,x;if(g!==void 0&&this.options.lanes>1){f=g;const E=p[f],N=E!==void 0?d[E]:void 0;x=N?N.end+this.options.gap:r+a}else{const E=this.options.lanes===1?d[m-1]:this.getFurthestMeasurement(d,m);x=E?E.end+this.options.gap:r+a,f=E?E.lane:m%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(m,f)}const _=l.get(h),b=typeof _=="number"?_:this.options.estimateSize(m),v=x+b;d[m]={index:m,start:x,size:b,end:v,key:h,lane:f},p[f]=m}return this.measurementsCache=d,d},{key:process.env.NODE_ENV!=="production"&&"getMeasurements",debug:()=>this.options.debug}),this.calculateRange=wr(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,a,i)=>this.range=n.length>0&&r>0?J_e({measurements:n,outerSize:r,scrollOffset:a,lanes:i}):null,{key:process.env.NODE_ENV!=="production"&&"calculateRange",debug:()=>this.options.debug}),this.getVirtualIndexes=wr(()=>{let n=null,r=null;const a=this.calculateRange();return a&&(n=a.startIndex,r=a.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,a,i,o)=>i===null||o===null?[]:n({startIndex:i,endIndex:o,overscan:r,count:a}),{key:process.env.NODE_ENV!=="production"&&"getVirtualIndexes",debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,a=n.getAttribute(r);return a?parseInt(a,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const a=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.index);if(a!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,a-i),s=Math.min(this.options.count-1,a+i);return n>=o&&n<=s}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((o,s)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(s))});return}const r=this.indexFromElement(n),a=this.options.getItemKey(r),i=this.elementsCache.get(a);i!==n&&(i&&this.observer.unobserve(i),this.observer.observe(n),this.elementsCache.set(a,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(r)&&this.resizeItem(r,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,r)=>{var a;const i=this.measurementsCache[n];if(!i)return;const o=this.itemSizeCache.get(i.key)??i.size,s=r-o;s!==0&&(((a=this.scrollState)==null?void 0:a.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(i,s,this):i.start<this.getScrollOffset()+this.scrollAdjustments)&&(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("correction",s),this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=s,behavior:void 0})),this.pendingMeasuredCacheIndexes.push(i.index),this.itemSizeCache=new Map(this.itemSizeCache.set(i.key,r)),this.notify(!1))},this.getVirtualItems=wr(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const a=[];for(let i=0,o=n.length;i<o;i++){const s=n[i],l=r[s];a.push(l)}return a},{key:process.env.NODE_ENV!=="production"&&"getVirtualItems",debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length!==0)return _2(r[V3(0,r.length-1,a=>_2(r[a]).start,n)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(n,r,a=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),o=this.getScrollOffset();r==="auto"&&(r=n>=o+i?"end":"start"),r==="center"?n+=(a-i)/2:r==="end"&&(n-=i);const s=this.getMaxScrollOffset();return Math.max(Math.min(s,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const a=this.getSize(),i=this.getScrollOffset(),o=this.measurementsCache[n];if(!o)return;if(r==="auto")if(o.end>=i+a-this.options.scrollPaddingEnd)r="end";else if(o.start<=i+this.options.scrollPaddingStart)r="start";else return[i,r];if(r==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),r];const s=r==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(s,r,o.size),r]},this.scrollToOffset=(n,{align:r="start",behavior:a="auto"}={})=>{const i=this.getOffsetForAlignment(n,r),o=this.now();this.scrollState={index:null,align:r,behavior:a,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:a}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:r="auto",behavior:a="auto"}={})=>{n=Math.max(0,Math.min(n,this.options.count-1));const i=this.getOffsetForIndex(n,r);if(!i)return;const[o,s]=i,l=this.now();this.scrollState={index:n,align:s,behavior:a,startedAt:l,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:a}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:r="auto"}={})=>{const a=this.getScrollOffset()+n,i=this.now();this.scrollState={index:null,align:"start",behavior:r,startedAt:i,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let a;if(r.length===0)a=this.options.paddingStart;else if(this.options.lanes===1)a=((n=r[r.length-1])==null?void 0:n.end)??0;else{const i=Array(this.options.lanes).fill(null);let o=r.length-1;for(;o>=0&&i.some(s=>s===null);){const s=r[o];i[s.lane]===null&&(i[s.lane]=s.end),o--}a=Math.max(...i.filter(s=>s!==null))}return Math.max(a-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(n,{adjustments:r,behavior:a})=>{this.options.scrollToFn(n,{behavior:a,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(t)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const r=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,a=r?r[0]:this.scrollState.lastTargetOffset,i=1,o=a!==this.scrollState.lastTargetOffset;if(!o&&j_e(a,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.scrollState=null;return}}else this.scrollState.stableFrames=0,o&&(this.scrollState.lastTargetOffset=a,this.scrollState.behavior="auto",this._scrollToOffset(a,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}}const V3=(e,t,n,r)=>{for(;e<=t;){const a=(e+t)/2|0,i=n(a);if(i<r)e=a+1;else if(i>r)t=a-1;else return a}return e>0?e-1:0};function J_e({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){const a=e.length-1,i=l=>e[l].start;if(e.length<=r)return{startIndex:0,endIndex:a};let o=V3(0,a,i,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){const l=Array(r).fill(0);for(;s<a&&l.some(d=>d<n+t);){const d=e[s];l[d.lane]=d.end,s++}const u=Array(r).fill(n+t);for(;o>=0&&u.some(d=>d>=n);){const d=e[o];u[d.lane]=d.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}const M2=typeof document<"u"?te.useLayoutEffect:te.useEffect;function exe({useFlushSync:e=!0,...t}){const n=te.useReducer(()=>({}),{})[1],r={...t,onChange:(i,o)=>{var s;e&&o?s5.flushSync(n):n(),(s=t.onChange)==null||s.call(t,i,o)}},[a]=te.useState(()=>new Q_e(r));return a.setOptions(r),M2(()=>a._didMount(),[]),M2(()=>a._willUpdate()),a}function txe(e){return exe({observeElementRect:K_e,observeElementOffset:Y_e,scrollToFn:X_e,...e})}const G3=G.memo(()=>{const e=fe(n=>n.activeChatId??n.draftChatKey),t=fe(n=>ze(n,e).composerError);return t?S.jsx("div",{className:"mp-agent-composer-error",children:t}):null});G3.displayName="ComposerError";const nxe=(e,t)=>{switch(e.status){case exports.AgentToolCallStatus.Running:return`Running ${t}...`;case exports.AgentToolCallStatus.Succeeded:return`Completed ${t}`;case exports.AgentToolCallStatus.Failed:return`Failed to run ${t}`;case exports.AgentToolCallStatus.Pending:return`Preparing ${t}...`;default:return`Running ${t}...`}},ns=e=>{if(e===void 0)return"undefined";try{return JSON.stringify(e,null,2)??"undefined"}catch{try{return String(e)}catch{return"[unserializable]"}}},S2=({call:e})=>$e().config.debug?S.jsxs("details",{className:"mp-agent-tool-debug-details",children:[S.jsx("summary",{className:"mp-agent-tool-debug-summary",children:"Details"}),S.jsxs("div",{className:"mp-agent-tool-debug-body",children:[S.jsxs("div",{className:"mp-agent-tool-debug-row",children:[S.jsx("div",{className:"mp-agent-tool-debug-label",children:"Tool"}),S.jsx("div",{className:"mp-agent-tool-debug-value",children:e.name})]}),S.jsxs("div",{className:"mp-agent-tool-debug-row",children:[S.jsx("div",{className:"mp-agent-tool-debug-label",children:"Status"}),S.jsx("div",{className:"mp-agent-tool-debug-value",children:e.status})]}),S.jsxs("details",{className:"mp-agent-tool-debug-section",children:[S.jsx("summary",{className:"mp-agent-tool-debug-section-summary",children:"Input"}),S.jsx("pre",{className:"mp-agent-tool-debug-code",children:S.jsx("code",{children:ns(e.input)})})]}),S.jsxs("details",{className:"mp-agent-tool-debug-section",children:[S.jsx("summary",{className:"mp-agent-tool-debug-section-summary",children:"Output"}),S.jsx("pre",{className:"mp-agent-tool-debug-code",children:S.jsx("code",{children:ns(e.output)})})]}),e.error&&S.jsxs("details",{className:"mp-agent-tool-debug-section",children:[S.jsx("summary",{className:"mp-agent-tool-debug-section-summary",children:"Error"}),S.jsx("pre",{className:"mp-agent-tool-debug-code",children:S.jsx("code",{children:ns(e.error)})})]})]})]}):null,N2=({call:e,isExpandable:t=!1,isExpanded:n=!1,onToggleExpand:r})=>{const a=$e(),i=G.useRef(!1),o=e.status===exports.AgentToolCallStatus.Succeeded||e.status===exports.AgentToolCallStatus.Failed,s=t||a.config.debug&&!o,l=s||t;if(G.useEffect(()=>{!t||o||n||i.current||(i.current=!0,r?.())},[t,o,n,r]),!l)return null;const d=a.tools.get(e.name)?.label??e.name,p=nxe(e,d);return S.jsxs("div",{className:"mp-agent-tool-header",children:[s&&S.jsx("div",{className:"mp-agent-tool-simple-message",children:p}),t&&S.jsx("button",{className:"mp-agent-subagent-preview-toggle",type:"button",onClick:r,"aria-expanded":n,children:n?S.jsx(g5,{size:14}):S.jsx(Fd,{size:14})})]})};function rxe(e){try{const t=JSON.parse(e);return{question:typeof t.question=="string"?t.question:void 0,selectedOptions:Array.isArray(t.selectedOptions)?t.selectedOptions:void 0,freeText:typeof t.freeText=="string"?t.freeText:void 0}}catch{return e}}const W3=({call:e})=>{if(e.approved===void 0)return null;const t=e.userResponse?rxe(e.userResponse):null,n=()=>{if(!t)return null;if(typeof t=="string")return S.jsx("span",{className:"mp-agent-tool-approval-response",children:t});const r=t.freeText??t.selectedOptions?.map(a=>a.label).join(", ");return!t.question&&!r?null:S.jsxs("div",{className:"mp-agent-tool-approval-result",children:[t.question&&S.jsx("span",{className:"mp-agent-tool-approval-question",children:t.question}),r&&S.jsx("span",{className:"mp-agent-tool-approval-response",children:r})]})};return S.jsxs("div",{className:"mp-agent-tool-approval-status-inline",children:[e.approved&&n(),e.approved?S.jsx("div",{className:"mp-agent-tool-approved",children:S.jsx("span",{children:"✓ Approved"})}):S.jsx("span",{className:"mp-agent-tool-denied",children:"✗ Denied"})]})},axe=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.question,n=e.selectionMode,r=e.options,a=e.allowFreeText;if(typeof t!="string"||t.trim().length<1||n!=="single"&&n!=="multiple"||!Array.isArray(r)||r.length<2||r.length>6)return null;const i=r.map(o=>{if(!o||typeof o!="object"||Array.isArray(o))return null;const s=o.id,l=o.label,u=o.description;return typeof s!="string"||s.trim().length<1||typeof l!="string"||l.trim().length<1||u!==void 0&&typeof u!="string"?null:{id:s,label:l,...typeof u=="string"?{description:u}:{}}}).filter(o=>o!==null);return i.length!==r.length?null:{question:t,selectionMode:n,options:i,allowFreeText:typeof a=="boolean"?a:!1}},ixe=({callId:e,input:t,isSubmitting:n,onSubmit:r})=>{const[a,i]=G.useState([]),[o,s]=G.useState(""),[l,u]=G.useState(void 0),d=G.useMemo(()=>axe(t),[t]);G.useEffect(()=>{i([]),s(""),u(void 0)},[e,t]);const p=h=>{if(d){if(u(void 0),d.selectionMode==="single"){i([h]);return}i(g=>g.includes(h)?g.filter(f=>f!==h):[...g,h])}},m=async()=>{if(!d)return;const h=o.trim(),g=a.length>0,f=d.allowFreeText&&h.length>0;if(!g&&!f){u(d.allowFreeText?"Select at least one option or provide a custom response.":"Select at least one option before submitting.");return}const x=d.options.filter(b=>a.includes(b.id)).map(({id:b,label:v,description:E})=>({id:b,label:v,...E?{description:E}:{}})),_={question:d.question,selectionMode:d.selectionMode,selectedOptionIds:a,selectedOptions:x,...h?{freeText:h}:{}};await r(JSON.stringify(_))};return d?S.jsxs("div",{className:"mp-agent-tool-user-action-form",children:[S.jsx("div",{className:"mp-agent-tool-user-action-question",children:d.question}),S.jsx("div",{className:"mp-agent-tool-user-action-options",children:d.options.map(h=>{const g=`${e}-${h.id}`,f=a.includes(h.id);return S.jsxs("label",{htmlFor:g,className:"mp-agent-tool-user-action-option",children:[S.jsx("input",{id:g,type:d.selectionMode==="single"?"radio":"checkbox",name:`mp-agent-tool-user-action-${e}`,checked:f,onChange:()=>p(h.id),disabled:n}),S.jsxs("span",{className:"mp-agent-tool-user-action-option-content",children:[S.jsx("span",{className:"mp-agent-tool-user-action-option-label",children:h.label}),h.description?S.jsx("span",{className:"mp-agent-tool-user-action-option-description",children:h.description}):null]})]},h.id)})}),d.allowFreeText?S.jsx("textarea",{className:"mp-agent-tool-user-action-free-text",value:o,onChange:h=>{s(h.target.value),l&&u(void 0)},placeholder:"Optional custom response",rows:3,disabled:n}):null,l?S.jsx("div",{className:"mp-agent-tool-input-error",children:l}):null,S.jsx("div",{className:"mp-agent-tool-approval-actions",children:S.jsx("button",{className:"mp-agent-tool-approve-button",onClick:m,disabled:n,children:n?"Submitting...":"Submit response"})})]}):S.jsx("div",{className:"mp-agent-tool-user-action-form",children:S.jsx("div",{className:"mp-agent-tool-input-error",children:"Invalid user action input schema in tool call."})})},oxe=({call:e,messageId:t,chatId:n,onApprovalSent:r})=>{const a=$e(),i=a.tools.get(e.name)?.label??e.name,o=fe(U=>U.appendMessagesToChat),s=fe(U=>U.setChatMessages),l=fe(U=>U.setChatStatus),u=fe(U=>U.setPendingAssistant),[d,p]=G.useState(!1),[m,h]=G.useState(!1),[g,f]=G.useState(!1),[x,_]=G.useState(JSON.stringify(e.input??{},null,2)),[b,v]=G.useState(void 0),E=a.config.user?.id??"guest",N=e.requiresUserAction;G.useEffect(()=>{m||(_(JSON.stringify(e.input??{},null,2)),v(void 0))},[e.id,e.input,m]);const w=()=>{_(JSON.stringify(e.input??{},null,2)),v(void 0),h(!0)},$=()=>{_(JSON.stringify(e.input??{},null,2)),v(void 0),h(!1)},P=async()=>{if(!(!a.transport.updateToolCall||g||d)){v(void 0),f(!0);try{const U=JSON.parse(x);if(!U||typeof U!="object"||Array.isArray(U))throw new Error("Tool input must be a JSON object.");const Z=await a.transport.updateToolCall({chatId:n,messageId:t,toolCallId:e.id,input:U});o(n,[Z]),h(!1)}catch(U){v(U instanceof Error?U.message:"Failed to update tool input.")}finally{f(!1)}}},C=U=>{s(n,Z=>Z.map(J=>J.id===t?{...J,toolCalls:(J.toolCalls??[]).map(K=>K.id===e.id?{...K,...U}:K)}:J))},L=async(U,Z)=>{if(!(!e.approvalId||d||g||m)){p(!0),C({approved:U,...Z?{userResponse:Z}:{}}),l(n,pt.Streaming),u(n,{id:`pending-approval-${e.id}`,chat:n,role:exports.MessageRole.Assistant,content:"",reasoning:"",toolCalls:[],attachments:[],createdAt:new Date().toISOString()});try{const J={chatId:n,messageId:t,approvalId:e.approvalId,approved:U,...Z?{userResponse:Z}:{},userId:E},K=await a.transport.streamMessage(J,R=>{R.type===exports.StreamChunkType.Message&&R.message&&(R.message.id!==t&&u(n,void 0),o(n,[R.message]))},{streamKey:n});K&&o(K.id,K.messages),await r()}catch(J){console.error("Failed to send approval:",J),C({approved:void 0,userResponse:void 0}),l(n,pt.Idle)}finally{u(n,void 0),p(!1)}}};return e.approved!==void 0?S.jsx(W3,{call:e}):N?S.jsx(ixe,{callId:e.id,input:e.input,isSubmitting:d,onSubmit:U=>L(!0,U)}):S.jsxs("div",{className:"mp-agent-tool-approval-buttons",children:[S.jsxs("div",{className:"mp-agent-tool-approval-request-message",children:["Agent wants to execute tool ",i,"."]}),S.jsxs("div",{className:"mp-agent-tool-input-card",children:[S.jsxs("div",{className:"mp-agent-tool-input-card-header",children:[S.jsx("span",{className:"mp-agent-tool-input-card-title",children:"Tool input"}),m?S.jsxs("div",{className:"mp-agent-tool-input-actions",children:[S.jsx(nn,{icon:"Check",size:"sm",tooltip:"Save tool input",onClick:P,disabled:g||d,"aria-label":"Save tool input"}),S.jsx(nn,{icon:"X",size:"sm",tooltip:"Cancel input edit",onClick:$,disabled:g||d,"aria-label":"Cancel tool input edit"})]}):S.jsx(nn,{icon:"Pencil",size:"sm",tooltip:"Edit tool input",onClick:w,disabled:d||g,"aria-label":"Edit tool input"})]}),m?S.jsx("textarea",{className:"mp-agent-tool-input-editor",value:x,onChange:U=>{_(U.target.value),b&&v(void 0)},rows:8,spellCheck:!1,disabled:g||d}):S.jsx("pre",{className:"mp-agent-tool-input-preview",children:JSON.stringify(e.input??{},null,2)}),b&&S.jsx("div",{className:"mp-agent-tool-input-error",children:b})]}),S.jsxs("div",{className:"mp-agent-tool-approval-actions",children:[S.jsx("button",{className:"mp-agent-tool-approve-button",onClick:()=>L(!0),disabled:d||m||g,children:d?"Processing...":"Approve"}),S.jsx("button",{className:"mp-agent-tool-deny-button",onClick:()=>L(!1),disabled:d||g,children:d?"Processing...":"Deny"})]})]})},A2=({call:e,messageId:t,chatId:n})=>{const r=$e(),a=fe(p=>p.upsertChat),i=fe(p=>p.setChatStatus),o=r.config.debug&&!!e.approvalId,s=e.requiresConfirmation&&e.approvalId||o,l=s&&e.approved===void 0,u=s&&e.approved!==void 0,d=async()=>{try{const p=await r.transport.getChat(n);a(p),i(n,ya(p.status))}catch(p){console.error("Failed to refresh chat after approval:",p),i(n,pt.Idle)}};return!l&&!u?null:S.jsxs("div",{className:"mp-agent-tool-approval",children:[l&&S.jsx(oxe,{call:e,messageId:t,chatId:n,onApprovalSent:d}),u&&S.jsx(W3,{call:e})]})},T2=({chatId:e,isExpanded:t})=>{const n=$e(),r=fe(l=>ze(l,e).messages),a=fe(l=>ze(l,e).pendingAssistant),i=fe(l=>l.chats[e]?.contextKey??l.contextKey),o=ap(e),s=G.useMemo(()=>{const l=[...r].sort((d,p)=>d.createdAt.localeCompare(p.createdAt));if(n.config.debug)return l;const u=l.findIndex(d=>d.role===exports.MessageRole.User);return u===-1?l:l.filter((d,p)=>p!==u)},[r,n.config.debug]);return S.jsx("div",{className:"mp-agent-subagent-preview",children:t&&S.jsx("div",{className:"mp-agent-subagent-preview-body",children:s.length===0&&!a?S.jsx("div",{className:"mp-agent-subagent-preview-empty",children:o.isLoading?"Loading subagent chat...":"Subagent chat started."}):S.jsxs(S.Fragment,{children:[s.map(l=>S.jsx(Zi,{message:l,contextKey:i},l.id)),a&&S.jsx(Zi,{message:a,contextKey:i,isStreaming:!0})]})})})},K3=({call:e,contextKey:t,messageId:n,chatId:r})=>{const a=$e(),i=e.subagentChatId||(typeof e.input?.subagentChatId=="string"?e.input.subagentChatId:void 0),[o,s]=G.useState(!1),l=G.useMemo(()=>a.getToolRenderer(e),[a,e]);return l?S.jsxs("div",{className:"mp-agent-tool-panel",children:[i&&S.jsx(N2,{call:e,isExpandable:!0,isExpanded:o,onToggleExpand:()=>s(u=>!u)}),S.jsx(l,{call:e,contextKey:t,chatId:r}),S.jsx(A2,{call:e,messageId:n,chatId:r}),i&&S.jsx(T2,{chatId:i,isExpanded:o}),!i&&S.jsx(S2,{call:e})]}):S.jsxs("div",{className:"mp-agent-tool-panel",children:[S.jsx(N2,{call:e,isExpandable:!!i,isExpanded:o,onToggleExpand:()=>s(u=>!u)}),S.jsx(A2,{call:e,messageId:n,chatId:r}),i&&S.jsx(T2,{chatId:i,isExpanded:o}),!i&&S.jsx(S2,{call:e})]})},sxe=e=>{const t=e.sender?.displayName||e.sender?.id||e.agentName;if(!t)return e.role===exports.MessageRole.User?"You":"AI";const n=t.split(/\s+/).filter(Boolean);return n.length>=2?`${n[0][0]}${n[1][0]}`.toUpperCase():t.slice(0,2).toUpperCase()},hp=G.memo(({message:e,isGrouped:t})=>{if(t)return S.jsx("div",{className:"mp-agent-message-avatar-spacer"});const n=e.role===exports.MessageRole.User;return S.jsx("div",{className:`mp-agent-message-avatar ${n?"mp-agent-message-avatar-user":""}`,children:e.sender?.avatarUrl?S.jsx("img",{className:"mp-agent-message-avatar-image",src:e.sender.avatarUrl,alt:""}):S.jsx("div",{className:"mp-agent-message-avatar-icon",children:sxe(e)})})});hp.displayName="MessageAvatar";const lxe=e=>e?new Date(e).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}):"",cxe=e=>e.sender?.displayName?e.sender.displayName:e.sender?.id&&e.sender.id!=="guest"?e.sender.id:e.agentName?e.agentName:e.role===exports.MessageRole.User?"You":"Assistant",mp=G.memo(({message:e,isGrouped:t})=>{if(t)return null;const n=cxe(e);return S.jsxs("div",{className:"mp-agent-message-header",children:[S.jsx("span",{className:"mp-agent-message-role",children:n}),S.jsx("span",{className:"mp-agent-message-time",children:lxe(e.createdAt)})]})});mp.displayName="MessageHeader";function C2(e){const t=[],n=String(e||"");let r=n.indexOf(","),a=0,i=!1;for(;!i;){r===-1&&(r=n.length,i=!0);const o=n.slice(a,r).trim();(o||!i)&&t.push(o),a=r+1,r=n.indexOf(",",a)}return t}function uxe(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const dxe=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,pxe=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,hxe={};function R2(e,t){return(hxe.jsx?pxe:dxe).test(e)}const mxe=/[ \t\n\f\r]/g;function fxe(e){return typeof e=="object"?e.type==="text"?I2(e.value):!1:I2(e)}function I2(e){return e.replace(mxe,"")===""}let Oa=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Oa.prototype.normal={};Oa.prototype.property={};Oa.prototype.space=void 0;function Y3(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Oa(n,r,t)}function ba(e){return e.toLowerCase()}let Ft=class{constructor(t,n){this.attribute=n,this.property=t}};Ft.prototype.attribute="";Ft.prototype.booleanish=!1;Ft.prototype.boolean=!1;Ft.prototype.commaOrSpaceSeparated=!1;Ft.prototype.commaSeparated=!1;Ft.prototype.defined=!1;Ft.prototype.mustUseProperty=!1;Ft.prototype.number=!1;Ft.prototype.overloadedBoolean=!1;Ft.prototype.property="";Ft.prototype.spaceSeparated=!1;Ft.prototype.space=void 0;let gxe=0;const Re=yr(),lt=yr(),cd=yr(),se=yr(),Qe=yr(),$r=yr(),Ut=yr();function yr(){return 2**++gxe}const ud=Object.freeze(Object.defineProperty({__proto__:null,boolean:Re,booleanish:lt,commaOrSpaceSeparated:Ut,commaSeparated:$r,number:se,overloadedBoolean:cd,spaceSeparated:Qe},Symbol.toStringTag,{value:"Module"})),rs=Object.keys(ud);let fp=class extends Ft{constructor(t,n,r,a){let i=-1;if(super(t,n),O2(this,"space",a),typeof r=="number")for(;++i<rs.length;){const o=rs[i];O2(this,rs[i],(r&ud[o])===ud[o])}}};fp.prototype.defined=!0;function O2(e,t,n){n&&(e[t]=n)}function Vr(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const i=new fp(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[ba(r)]=r,n[ba(i.attribute)]=r}return new Oa(t,n,e.space)}const Z3=Vr({properties:{ariaActiveDescendant:null,ariaAtomic:lt,ariaAutoComplete:null,ariaBusy:lt,ariaChecked:lt,ariaColCount:se,ariaColIndex:se,ariaColSpan:se,ariaControls:Qe,ariaCurrent:null,ariaDescribedBy:Qe,ariaDetails:null,ariaDisabled:lt,ariaDropEffect:Qe,ariaErrorMessage:null,ariaExpanded:lt,ariaFlowTo:Qe,ariaGrabbed:lt,ariaHasPopup:null,ariaHidden:lt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Qe,ariaLevel:se,ariaLive:null,ariaModal:lt,ariaMultiLine:lt,ariaMultiSelectable:lt,ariaOrientation:null,ariaOwns:Qe,ariaPlaceholder:null,ariaPosInSet:se,ariaPressed:lt,ariaReadOnly:lt,ariaRelevant:null,ariaRequired:lt,ariaRoleDescription:Qe,ariaRowCount:se,ariaRowIndex:se,ariaRowSpan:se,ariaSelected:lt,ariaSetSize:se,ariaSort:null,ariaValueMax:se,ariaValueMin:se,ariaValueNow:se,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function X3(e,t){return t in e?e[t]:t}function Q3(e,t){return X3(e,t.toLowerCase())}const yxe=Vr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:$r,acceptCharset:Qe,accessKey:Qe,action:null,allow:null,allowFullScreen:Re,allowPaymentRequest:Re,allowUserMedia:Re,alt:null,as:null,async:Re,autoCapitalize:null,autoComplete:Qe,autoFocus:Re,autoPlay:Re,blocking:Qe,capture:null,charSet:null,checked:Re,cite:null,className:Qe,cols:se,colSpan:null,content:null,contentEditable:lt,controls:Re,controlsList:Qe,coords:se|$r,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Re,defer:Re,dir:null,dirName:null,disabled:Re,download:cd,draggable:lt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Re,formTarget:null,headers:Qe,height:se,hidden:cd,high:se,href:null,hrefLang:null,htmlFor:Qe,httpEquiv:Qe,id:null,imageSizes:null,imageSrcSet:null,inert:Re,inputMode:null,integrity:null,is:null,isMap:Re,itemId:null,itemProp:Qe,itemRef:Qe,itemScope:Re,itemType:Qe,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Re,low:se,manifest:null,max:null,maxLength:se,media:null,method:null,min:null,minLength:se,multiple:Re,muted:Re,name:null,nonce:null,noModule:Re,noValidate:Re,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Re,optimum:se,pattern:null,ping:Qe,placeholder:null,playsInline:Re,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Re,referrerPolicy:null,rel:Qe,required:Re,reversed:Re,rows:se,rowSpan:se,sandbox:Qe,scope:null,scoped:Re,seamless:Re,selected:Re,shadowRootClonable:Re,shadowRootDelegatesFocus:Re,shadowRootMode:null,shape:null,size:se,sizes:null,slot:null,span:se,spellCheck:lt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:se,step:null,style:null,tabIndex:se,target:null,title:null,translate:null,type:null,typeMustMatch:Re,useMap:null,value:lt,width:se,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Qe,axis:null,background:null,bgColor:null,border:se,borderColor:null,bottomMargin:se,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Re,declare:Re,event:null,face:null,frame:null,frameBorder:null,hSpace:se,leftMargin:se,link:null,longDesc:null,lowSrc:null,marginHeight:se,marginWidth:se,noResize:Re,noHref:Re,noShade:Re,noWrap:Re,object:null,profile:null,prompt:null,rev:null,rightMargin:se,rules:null,scheme:null,scrolling:lt,standby:null,summary:null,text:null,topMargin:se,valueType:null,version:null,vAlign:null,vLink:null,vSpace:se,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Re,disableRemotePlayback:Re,prefix:null,property:null,results:se,security:null,unselectable:null},space:"html",transform:Q3}),bxe=Vr({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Ut,accentHeight:se,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:se,amplitude:se,arabicForm:null,ascent:se,attributeName:null,attributeType:null,azimuth:se,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:se,by:null,calcMode:null,capHeight:se,className:Qe,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:se,diffuseConstant:se,direction:null,display:null,dur:null,divisor:se,dominantBaseline:null,download:Re,dx:null,dy:null,edgeMode:null,editable:null,elevation:se,enableBackground:null,end:null,event:null,exponent:se,externalResourcesRequired:null,fill:null,fillOpacity:se,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:$r,g2:$r,glyphName:$r,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:se,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:se,horizOriginX:se,horizOriginY:se,id:null,ideographic:se,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:se,k:se,k1:se,k2:se,k3:se,k4:se,kernelMatrix:Ut,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:se,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:se,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:se,overlineThickness:se,paintOrder:null,panose1:null,path:null,pathLength:se,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Qe,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:se,pointsAtY:se,pointsAtZ:se,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ut,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ut,rev:Ut,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ut,requiredFeatures:Ut,requiredFonts:Ut,requiredFormats:Ut,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:se,specularExponent:se,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:se,strikethroughThickness:se,string:null,stroke:null,strokeDashArray:Ut,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:se,strokeOpacity:se,strokeWidth:null,style:null,surfaceScale:se,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ut,tabIndex:se,tableValues:null,target:null,targetX:se,targetY:se,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ut,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:se,underlineThickness:se,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:se,values:null,vAlphabetic:se,vMathematical:se,vectorEffect:null,vHanging:se,vIdeographic:se,version:null,vertAdvY:se,vertOriginX:se,vertOriginY:se,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:se,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:X3}),J3=Vr({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),ev=Vr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Q3}),tv=Vr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),kxe={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},vxe=/[A-Z]/g,L2=/-[a-z]/g,_xe=/^data[-\w.:]+$/i;function nv(e,t){const n=ba(t);let r=t,a=Ft;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&_xe.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(L2,wxe);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!L2.test(i)){let o=i.replace(vxe,xxe);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}a=fp}return new a(r,t)}function xxe(e){return"-"+e.toLowerCase()}function wxe(e){return e.charAt(1).toUpperCase()}const rv=Y3([Z3,yxe,J3,ev,tv],"html"),fo=Y3([Z3,bxe,J3,ev,tv],"svg");function D2(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function Exe(e){return e.join(" ").trim()}var Jn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function go(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var gp={},z2=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Mxe=/\n/g,Sxe=/^\s*/,Nxe=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Axe=/^:\s*/,Txe=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,Cxe=/^[;\s]*/,Rxe=/^\s+|\s+$/g,Ixe=`
|
|
8296
|
+
color: hsl(${Math.max(0,Math.min(120-120*x,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(i&&n.skipInitialOnChange)&&n.onChange(a),i=!1,a}return o.updateDeps=s=>{r=s},o}function _2(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const j_e=(e,t)=>Math.abs(e-t)<1.01,V_e=(e,t,n)=>{let r;return function(...a){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,a),n)}},x2=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},G_e=e=>e,W_e=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let a=t;a<=n;a++)r.push(a);return r},K_e=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const a=o=>{const{width:s,height:l}=o;t({width:Math.round(s),height:Math.round(l)})};if(a(x2(n)),!r.ResizeObserver)return()=>{};const i=new r.ResizeObserver(o=>{const s=()=>{const l=o[0];if(l?.borderBoxSize){const u=l.borderBoxSize[0];if(u){a({width:u.inlineSize,height:u.blockSize});return}}a(x2(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(s):s()});return i.observe(n,{box:"border-box"}),()=>{i.unobserve(n)}},w2={passive:!0},E2=typeof window>"u"?!0:"onscrollend"in window,Y_e=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;let a=0;const i=e.options.useScrollendEvent&&E2?()=>{}:V_e(r,()=>{t(a,!1)},e.options.isScrollingResetDelay),o=d=>()=>{const{horizontal:p,isRtl:m}=e.options;a=p?n.scrollLeft*(m&&-1||1):n.scrollTop,i(),t(a,d)},s=o(!0),l=o(!1);n.addEventListener("scroll",s,w2);const u=e.options.useScrollendEvent&&E2;return u&&n.addEventListener("scrollend",l,w2),()=>{n.removeEventListener("scroll",s),u&&n.removeEventListener("scrollend",l)}},Z_e=(e,t,n)=>{if(t?.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},X_e=(e,{adjustments:t=0,behavior:n},r)=>{var a,i;const o=e+t;(i=(a=r.scrollElement)==null?void 0:a.scrollTo)==null||i.call(a,{[r.options.horizontal?"left":"top"]:o,behavior:n})};class Q_e{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var n,r,a;return((a=(r=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:r.now)==null?void 0:a.call(r))??Date.now()},this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(a=>{a.forEach(i=>{const o=()=>{const s=i.target,l=this.indexFromElement(s);if(!s.isConnected){this.observer.unobserve(s);return}this.shouldMeasureDuringScroll(l)&&this.resizeItem(l,this.options.measureElement(s,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var a;(a=r())==null||a.disconnect(),n=null},observe:a=>{var i;return(i=r())==null?void 0:i.observe(a,{box:"border-box"})},unobserve:a=>{var i;return(i=r())==null?void 0:i.unobserve(a)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([r,a])=>{typeof a>"u"&&delete n[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:G_e,rangeExtractor:W_e,onChange:()=>{},measureElement:Z_e,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...n}},this.notify=n=>{var r,a;(a=(r=this.options).onChange)==null||a.call(r,this,n)},this.maybeNotify=wr(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:process.env.NODE_ENV!=="production"&&"maybeNotify",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(a=>{this.observer.observe(a)}),this.unsubs.push(this.options.observeElementRect(this,a=>{this.scrollRect=a,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(a,i)=>{this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()<a?"forward":"backward":null,this.scrollOffset=a,this.isScrolling=i,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,r)=>{const a=new Map,i=new Map;for(let o=r-1;o>=0;o--){const s=n[o];if(a.has(s.lane))continue;const l=i.get(s.lane);if(l==null||s.end>l.end?i.set(s.lane,s):s.end<l.end&&a.set(s.lane,!0),a.size===this.options.lanes)break}return i.size===this.options.lanes?Array.from(i.values()).sort((o,s)=>o.end===s.end?o.index-s.index:o.end-s.end)[0]:void 0},this.getMeasurementOptions=wr(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(n,r,a,i,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==s&&(this.lanesChangedFlag=!0),this.prevLanes=s,this.pendingMeasuredCacheIndexes=[],{count:n,paddingStart:r,scrollMargin:a,getItemKey:i,enabled:o,lanes:s}),{key:!1}),this.getMeasurements=wr(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:n,paddingStart:r,scrollMargin:a,getItemKey:i,enabled:o,lanes:s},l)=>{if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const m of this.laneAssignments.keys())m>=n&&this.laneAssignments.delete(m);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(m=>{this.itemSizeCache.set(m.key,m.size)}));const u=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1);const d=this.measurementsCache.slice(0,u),p=new Array(s).fill(void 0);for(let m=0;m<u;m++){const h=d[m];h&&(p[h.lane]=m)}for(let m=u;m<n;m++){const h=i(m),g=this.laneAssignments.get(m);let f,x;if(g!==void 0&&this.options.lanes>1){f=g;const E=p[f],N=E!==void 0?d[E]:void 0;x=N?N.end+this.options.gap:r+a}else{const E=this.options.lanes===1?d[m-1]:this.getFurthestMeasurement(d,m);x=E?E.end+this.options.gap:r+a,f=E?E.lane:m%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(m,f)}const _=l.get(h),b=typeof _=="number"?_:this.options.estimateSize(m),v=x+b;d[m]={index:m,start:x,size:b,end:v,key:h,lane:f},p[f]=m}return this.measurementsCache=d,d},{key:process.env.NODE_ENV!=="production"&&"getMeasurements",debug:()=>this.options.debug}),this.calculateRange=wr(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,a,i)=>this.range=n.length>0&&r>0?J_e({measurements:n,outerSize:r,scrollOffset:a,lanes:i}):null,{key:process.env.NODE_ENV!=="production"&&"calculateRange",debug:()=>this.options.debug}),this.getVirtualIndexes=wr(()=>{let n=null,r=null;const a=this.calculateRange();return a&&(n=a.startIndex,r=a.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,a,i,o)=>i===null||o===null?[]:n({startIndex:i,endIndex:o,overscan:r,count:a}),{key:process.env.NODE_ENV!=="production"&&"getVirtualIndexes",debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,a=n.getAttribute(r);return a?parseInt(a,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const a=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.index);if(a!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,a-i),s=Math.min(this.options.count-1,a+i);return n>=o&&n<=s}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((o,s)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(s))});return}const r=this.indexFromElement(n),a=this.options.getItemKey(r),i=this.elementsCache.get(a);i!==n&&(i&&this.observer.unobserve(i),this.observer.observe(n),this.elementsCache.set(a,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(r)&&this.resizeItem(r,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,r)=>{var a;const i=this.measurementsCache[n];if(!i)return;const o=this.itemSizeCache.get(i.key)??i.size,s=r-o;s!==0&&(((a=this.scrollState)==null?void 0:a.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(i,s,this):i.start<this.getScrollOffset()+this.scrollAdjustments)&&(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("correction",s),this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=s,behavior:void 0})),this.pendingMeasuredCacheIndexes.push(i.index),this.itemSizeCache=new Map(this.itemSizeCache.set(i.key,r)),this.notify(!1))},this.getVirtualItems=wr(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const a=[];for(let i=0,o=n.length;i<o;i++){const s=n[i],l=r[s];a.push(l)}return a},{key:process.env.NODE_ENV!=="production"&&"getVirtualItems",debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length!==0)return _2(r[V3(0,r.length-1,a=>_2(r[a]).start,n)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(n,r,a=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),o=this.getScrollOffset();r==="auto"&&(r=n>=o+i?"end":"start"),r==="center"?n+=(a-i)/2:r==="end"&&(n-=i);const s=this.getMaxScrollOffset();return Math.max(Math.min(s,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const a=this.getSize(),i=this.getScrollOffset(),o=this.measurementsCache[n];if(!o)return;if(r==="auto")if(o.end>=i+a-this.options.scrollPaddingEnd)r="end";else if(o.start<=i+this.options.scrollPaddingStart)r="start";else return[i,r];if(r==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),r];const s=r==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(s,r,o.size),r]},this.scrollToOffset=(n,{align:r="start",behavior:a="auto"}={})=>{const i=this.getOffsetForAlignment(n,r),o=this.now();this.scrollState={index:null,align:r,behavior:a,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:a}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:r="auto",behavior:a="auto"}={})=>{n=Math.max(0,Math.min(n,this.options.count-1));const i=this.getOffsetForIndex(n,r);if(!i)return;const[o,s]=i,l=this.now();this.scrollState={index:n,align:s,behavior:a,startedAt:l,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:a}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:r="auto"}={})=>{const a=this.getScrollOffset()+n,i=this.now();this.scrollState={index:null,align:"start",behavior:r,startedAt:i,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let a;if(r.length===0)a=this.options.paddingStart;else if(this.options.lanes===1)a=((n=r[r.length-1])==null?void 0:n.end)??0;else{const i=Array(this.options.lanes).fill(null);let o=r.length-1;for(;o>=0&&i.some(s=>s===null);){const s=r[o];i[s.lane]===null&&(i[s.lane]=s.end),o--}a=Math.max(...i.filter(s=>s!==null))}return Math.max(a-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(n,{adjustments:r,behavior:a})=>{this.options.scrollToFn(n,{behavior:a,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(t)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const r=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,a=r?r[0]:this.scrollState.lastTargetOffset,i=1,o=a!==this.scrollState.lastTargetOffset;if(!o&&j_e(a,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.scrollState=null;return}}else this.scrollState.stableFrames=0,o&&(this.scrollState.lastTargetOffset=a,this.scrollState.behavior="auto",this._scrollToOffset(a,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}}const V3=(e,t,n,r)=>{for(;e<=t;){const a=(e+t)/2|0,i=n(a);if(i<r)e=a+1;else if(i>r)t=a-1;else return a}return e>0?e-1:0};function J_e({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){const a=e.length-1,i=l=>e[l].start;if(e.length<=r)return{startIndex:0,endIndex:a};let o=V3(0,a,i,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){const l=Array(r).fill(0);for(;s<a&&l.some(d=>d<n+t);){const d=e[s];l[d.lane]=d.end,s++}const u=Array(r).fill(n+t);for(;o>=0&&u.some(d=>d>=n);){const d=e[o];u[d.lane]=d.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}const M2=typeof document<"u"?te.useLayoutEffect:te.useEffect;function exe({useFlushSync:e=!0,...t}){const n=te.useReducer(()=>({}),{})[1],r={...t,onChange:(i,o)=>{var s;e&&o?s5.flushSync(n):n(),(s=t.onChange)==null||s.call(t,i,o)}},[a]=te.useState(()=>new Q_e(r));return a.setOptions(r),M2(()=>a._didMount(),[]),M2(()=>a._willUpdate()),a}function txe(e){return exe({observeElementRect:K_e,observeElementOffset:Y_e,scrollToFn:X_e,...e})}const G3=G.memo(()=>{const e=fe(n=>n.activeChatId??n.draftChatKey),t=fe(n=>ze(n,e).composerError);return t?S.jsx("div",{className:"mp-agent-composer-error",children:t}):null});G3.displayName="ComposerError";const nxe=(e,t)=>{switch(e.status){case exports.AgentToolCallStatus.Running:return`Running ${t}...`;case exports.AgentToolCallStatus.Succeeded:return`Completed ${t}`;case exports.AgentToolCallStatus.Failed:return`Failed to run ${t}`;case exports.AgentToolCallStatus.Pending:return`Preparing ${t}...`;default:return`Running ${t}...`}},ns=e=>{if(e===void 0)return"undefined";try{return JSON.stringify(e,null,2)??"undefined"}catch{try{return String(e)}catch{return"[unserializable]"}}},S2=({call:e})=>$e().config.debug?S.jsxs("details",{className:"mp-agent-tool-debug-details",children:[S.jsx("summary",{className:"mp-agent-tool-debug-summary",children:"Details"}),S.jsxs("div",{className:"mp-agent-tool-debug-body",children:[S.jsxs("div",{className:"mp-agent-tool-debug-row",children:[S.jsx("div",{className:"mp-agent-tool-debug-label",children:"Tool"}),S.jsx("div",{className:"mp-agent-tool-debug-value",children:e.name})]}),S.jsxs("div",{className:"mp-agent-tool-debug-row",children:[S.jsx("div",{className:"mp-agent-tool-debug-label",children:"Status"}),S.jsx("div",{className:"mp-agent-tool-debug-value",children:e.status})]}),S.jsxs("details",{className:"mp-agent-tool-debug-section",children:[S.jsx("summary",{className:"mp-agent-tool-debug-section-summary",children:"Input"}),S.jsx("pre",{className:"mp-agent-tool-debug-code",children:S.jsx("code",{children:ns(e.input)})})]}),S.jsxs("details",{className:"mp-agent-tool-debug-section",children:[S.jsx("summary",{className:"mp-agent-tool-debug-section-summary",children:"Output"}),S.jsx("pre",{className:"mp-agent-tool-debug-code",children:S.jsx("code",{children:ns(e.output)})})]}),e.error&&S.jsxs("details",{className:"mp-agent-tool-debug-section",children:[S.jsx("summary",{className:"mp-agent-tool-debug-section-summary",children:"Error"}),S.jsx("pre",{className:"mp-agent-tool-debug-code",children:S.jsx("code",{children:ns(e.error)})})]})]})]}):null,N2=({call:e,isExpandable:t=!1,isExpanded:n=!1,onToggleExpand:r})=>{const a=$e(),i=G.useRef(!1),o=e.status===exports.AgentToolCallStatus.Succeeded||e.status===exports.AgentToolCallStatus.Failed,s=t||a.config.debug&&!o,l=s||t;if(G.useEffect(()=>{!t||o||n||i.current||(i.current=!0,r?.())},[t,o,n,r]),!l)return null;const d=a.tools.get(e.name)?.label??e.name,p=nxe(e,d);return S.jsxs("div",{className:"mp-agent-tool-header",children:[s&&S.jsx("div",{className:"mp-agent-tool-simple-message",children:p}),t&&S.jsx("button",{className:"mp-agent-subagent-preview-toggle",type:"button",onClick:r,"aria-expanded":n,children:n?S.jsx(g5,{size:14}):S.jsx(Fd,{size:14})})]})};function rxe(e){try{const t=JSON.parse(e);return{question:typeof t.question=="string"?t.question:void 0,selectedOptions:Array.isArray(t.selectedOptions)?t.selectedOptions:void 0,freeText:typeof t.freeText=="string"?t.freeText:void 0}}catch{return e}}const W3=({call:e})=>{if(e.approved===void 0)return null;const t=e.userResponse?rxe(e.userResponse):null,n=()=>{if(!t)return null;if(typeof t=="string")return S.jsx("span",{className:"mp-agent-tool-approval-response",children:t});const r=t.freeText??t.selectedOptions?.map(a=>a.label).join(", ");return!t.question&&!r?null:S.jsxs("div",{className:"mp-agent-tool-approval-result",children:[t.question&&S.jsx("span",{className:"mp-agent-tool-approval-question",children:t.question}),r&&S.jsx("span",{className:"mp-agent-tool-approval-response",children:r})]})};return S.jsxs("div",{className:"mp-agent-tool-approval-status-inline",children:[e.approved&&n(),e.approved?S.jsx("div",{className:"mp-agent-tool-approved",children:S.jsx("span",{children:"✓ Approved"})}):S.jsx("span",{className:"mp-agent-tool-denied",children:"✗ Denied"})]})},axe=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.question,n=e.selectionMode,r=e.options,a=e.allowFreeText;if(typeof t!="string"||t.trim().length<1||n!=="single"&&n!=="multiple"||!Array.isArray(r)||r.length<2||r.length>6)return null;const i=r.map(o=>{if(!o||typeof o!="object"||Array.isArray(o))return null;const s=o.id,l=o.label,u=o.description;return typeof s!="string"||s.trim().length<1||typeof l!="string"||l.trim().length<1||u!==void 0&&typeof u!="string"?null:{id:s,label:l,...typeof u=="string"?{description:u}:{}}}).filter(o=>o!==null);return i.length!==r.length?null:{question:t,selectionMode:n,options:i,allowFreeText:typeof a=="boolean"?a:!1}},ixe=({callId:e,input:t,isSubmitting:n,onSubmit:r})=>{const[a,i]=G.useState([]),[o,s]=G.useState(""),[l,u]=G.useState(void 0),d=G.useMemo(()=>axe(t),[t]);G.useEffect(()=>{i([]),s(""),u(void 0)},[e,t]);const p=h=>{if(d){if(u(void 0),d.selectionMode==="single"){i([h]);return}i(g=>g.includes(h)?g.filter(f=>f!==h):[...g,h])}},m=async()=>{if(!d)return;const h=o.trim(),g=a.length>0,f=d.allowFreeText&&h.length>0;if(!g&&!f){u(d.allowFreeText?"Select at least one option or provide a custom response.":"Select at least one option before submitting.");return}const x=d.options.filter(b=>a.includes(b.id)).map(({id:b,label:v,description:E})=>({id:b,label:v,...E?{description:E}:{}})),_={question:d.question,selectionMode:d.selectionMode,selectedOptionIds:a,selectedOptions:x,...h?{freeText:h}:{}};await r(JSON.stringify(_))};return d?S.jsxs("div",{className:"mp-agent-tool-user-action-form",children:[S.jsx("div",{className:"mp-agent-tool-user-action-question",children:d.question}),S.jsx("div",{className:"mp-agent-tool-user-action-options",children:d.options.map(h=>{const g=`${e}-${h.id}`,f=a.includes(h.id);return S.jsxs("label",{htmlFor:g,className:"mp-agent-tool-user-action-option",children:[S.jsx("input",{id:g,type:d.selectionMode==="single"?"radio":"checkbox",name:`mp-agent-tool-user-action-${e}`,checked:f,onChange:()=>p(h.id),disabled:n}),S.jsxs("span",{className:"mp-agent-tool-user-action-option-content",children:[S.jsx("span",{className:"mp-agent-tool-user-action-option-label",children:h.label}),h.description?S.jsx("span",{className:"mp-agent-tool-user-action-option-description",children:h.description}):null]})]},h.id)})}),d.allowFreeText?S.jsx("textarea",{className:"mp-agent-tool-user-action-free-text",value:o,onChange:h=>{s(h.target.value),l&&u(void 0)},placeholder:"Optional custom response",rows:3,disabled:n}):null,l?S.jsx("div",{className:"mp-agent-tool-input-error",children:l}):null,S.jsx("div",{className:"mp-agent-tool-approval-actions",children:S.jsx("button",{className:"mp-agent-tool-approve-button",onClick:m,disabled:n,children:n?"Submitting...":"Submit response"})})]}):S.jsx("div",{className:"mp-agent-tool-user-action-form",children:S.jsx("div",{className:"mp-agent-tool-input-error",children:"Invalid user action input schema in tool call."})})},oxe=({call:e,messageId:t,chatId:n,onApprovalSent:r})=>{const a=$e(),i=a.tools.get(e.name)?.label??e.name,o=fe(U=>U.appendMessagesToChat),s=fe(U=>U.setChatMessages),l=fe(U=>U.setChatStatus),u=fe(U=>U.setPendingAssistant),[d,p]=G.useState(!1),[m,h]=G.useState(!1),[g,f]=G.useState(!1),[x,_]=G.useState(JSON.stringify(e.input??{},null,2)),[b,v]=G.useState(void 0),E=a.config.user?.id??"guest",N=e.requiresUserAction;G.useEffect(()=>{m||(_(JSON.stringify(e.input??{},null,2)),v(void 0))},[e.id,e.input,m]);const w=()=>{_(JSON.stringify(e.input??{},null,2)),v(void 0),h(!0)},$=()=>{_(JSON.stringify(e.input??{},null,2)),v(void 0),h(!1)},P=async()=>{if(!(!a.transport.updateToolCall||g||d)){v(void 0),f(!0);try{const U=JSON.parse(x);if(!U||typeof U!="object"||Array.isArray(U))throw new Error("Tool input must be a JSON object.");const Z=await a.transport.updateToolCall({chatId:n,messageId:t,toolCallId:e.id,input:U});o(n,[Z]),h(!1)}catch(U){v(U instanceof Error?U.message:"Failed to update tool input.")}finally{f(!1)}}},C=U=>{s(n,Z=>Z.map(J=>J.id===t?{...J,toolCalls:(J.toolCalls??[]).map(K=>K.id===e.id?{...K,...U}:K)}:J))},L=async(U,Z)=>{if(!(!e.approvalId||d||g||m)){p(!0),C({approved:U,...Z?{userResponse:Z}:{}}),l(n,pt.Streaming),u(n,{id:`pending-approval-${e.id}`,chat:n,role:exports.MessageRole.Assistant,content:"",reasoning:"",toolCalls:[],attachments:[],createdAt:new Date().toISOString()});try{const J={chatId:n,messageId:t,approvalId:e.approvalId,approved:U,...Z?{userResponse:Z}:{},userId:E},K=await a.transport.streamMessage(J,R=>{R.type===exports.StreamChunkType.Message&&R.message&&(R.message.id!==t&&u(n,void 0),o(n,[R.message]))},{streamKey:n});K&&o(K.id,K.messages),await r()}catch(J){console.error("Failed to send approval:",J),C({approved:void 0,userResponse:void 0}),l(n,pt.Idle)}finally{u(n,void 0),p(!1)}}};return e.approved!==void 0?S.jsx(W3,{call:e}):N?S.jsx(ixe,{callId:e.id,input:e.input,isSubmitting:d,onSubmit:U=>L(!0,U)}):S.jsxs("div",{className:"mp-agent-tool-approval-buttons",children:[S.jsxs("div",{className:"mp-agent-tool-approval-request-message",children:["Agent wants to execute tool ",i,"."]}),S.jsxs("div",{className:"mp-agent-tool-input-card",children:[S.jsxs("div",{className:"mp-agent-tool-input-card-header",children:[S.jsx("span",{className:"mp-agent-tool-input-card-title",children:"Tool input"}),m?S.jsxs("div",{className:"mp-agent-tool-input-actions",children:[S.jsx(nn,{icon:"Check",size:"sm",tooltip:"Save tool input",onClick:P,disabled:g||d,"aria-label":"Save tool input"}),S.jsx(nn,{icon:"X",size:"sm",tooltip:"Cancel input edit",onClick:$,disabled:g||d,"aria-label":"Cancel tool input edit"})]}):S.jsx(nn,{icon:"Pencil",size:"sm",tooltip:"Edit tool input",onClick:w,disabled:d||g,"aria-label":"Edit tool input"})]}),m?S.jsx("textarea",{className:"mp-agent-tool-input-editor",value:x,onChange:U=>{_(U.target.value),b&&v(void 0)},rows:8,spellCheck:!1,disabled:g||d}):S.jsx("pre",{className:"mp-agent-tool-input-preview",children:JSON.stringify(e.input??{},null,2)}),b&&S.jsx("div",{className:"mp-agent-tool-input-error",children:b})]}),S.jsxs("div",{className:"mp-agent-tool-approval-actions",children:[S.jsx("button",{className:"mp-agent-tool-approve-button",onClick:()=>L(!0),disabled:d||m||g,children:d?"Processing...":"Approve"}),S.jsx("button",{className:"mp-agent-tool-deny-button",onClick:()=>L(!1),disabled:d||g,children:d?"Processing...":"Deny"})]})]})},A2=({call:e,messageId:t,chatId:n})=>{const r=$e(),a=fe(p=>p.upsertChat),i=fe(p=>p.setChatStatus),o=r.config.debug&&!!e.approvalId,s=e.requiresConfirmation&&e.approvalId||o,l=s&&e.approved===void 0,u=s&&e.approved!==void 0,d=async()=>{try{const p=await r.transport.getChat(n);a(p),i(n,ya(p.status))}catch(p){console.error("Failed to refresh chat after approval:",p),i(n,pt.Idle)}};return!l&&!u?null:S.jsxs("div",{className:"mp-agent-tool-approval",children:[l&&S.jsx(oxe,{call:e,messageId:t,chatId:n,onApprovalSent:d}),u&&S.jsx(W3,{call:e})]})},T2=({chatId:e,isExpanded:t})=>{const n=$e(),r=fe(l=>ze(l,e).messages),a=fe(l=>ze(l,e).pendingAssistant),i=fe(l=>l.chats[e]?.contextKey??l.contextKey),o=ap(e),s=G.useMemo(()=>{const l=[...r].sort((d,p)=>d.createdAt.localeCompare(p.createdAt));if(n.config.debug)return l;const u=l.findIndex(d=>d.role===exports.MessageRole.User);return u===-1?l:l.filter((d,p)=>p!==u)},[r,n.config.debug]);return S.jsx("div",{className:"mp-agent-subagent-preview",children:t&&S.jsx("div",{className:"mp-agent-subagent-preview-body",children:s.length===0&&!a?S.jsx("div",{className:"mp-agent-subagent-preview-empty",children:o.isLoading?"Loading subagent chat...":"Subagent chat started."}):S.jsxs(S.Fragment,{children:[s.map(l=>S.jsx(Zi,{message:l,contextKey:i},l.id)),a&&S.jsx(Zi,{message:a,contextKey:i,isStreaming:!0})]})})})},K3=({call:e,contextKey:t,messageId:n,chatId:r})=>{const a=$e(),i=e.subagentChatId||(typeof e.input?.subagentChatId=="string"?e.input.subagentChatId:void 0),[o,s]=G.useState(!1),l=G.useMemo(()=>a.getToolRenderer(e),[a,e]);if(!l){const u=!!(e.requiresConfirmation&&e.approvalId);return!!i||a.config.debug||u?S.jsxs("div",{className:"mp-agent-tool-panel",children:[S.jsx(N2,{call:e,isExpandable:!!i,isExpanded:o,onToggleExpand:()=>s(p=>!p)}),S.jsx(A2,{call:e,messageId:n,chatId:r}),i&&S.jsx(T2,{chatId:i,isExpanded:o}),!i&&S.jsx(S2,{call:e})]}):null}return S.jsxs("div",{className:"mp-agent-tool-panel",children:[i&&S.jsx(N2,{call:e,isExpandable:!0,isExpanded:o,onToggleExpand:()=>s(u=>!u)}),S.jsx(l,{call:e,contextKey:t,chatId:r}),S.jsx(A2,{call:e,messageId:n,chatId:r}),i&&S.jsx(T2,{chatId:i,isExpanded:o}),!i&&S.jsx(S2,{call:e})]})},sxe=e=>{const t=e.sender?.displayName||e.sender?.id||e.agentName;if(!t)return e.role===exports.MessageRole.User?"You":"AI";const n=t.split(/\s+/).filter(Boolean);return n.length>=2?`${n[0][0]}${n[1][0]}`.toUpperCase():t.slice(0,2).toUpperCase()},hp=G.memo(({message:e,isGrouped:t})=>{if(t)return S.jsx("div",{className:"mp-agent-message-avatar-spacer"});const n=e.role===exports.MessageRole.User;return S.jsx("div",{className:`mp-agent-message-avatar ${n?"mp-agent-message-avatar-user":""}`,children:e.sender?.avatarUrl?S.jsx("img",{className:"mp-agent-message-avatar-image",src:e.sender.avatarUrl,alt:""}):S.jsx("div",{className:"mp-agent-message-avatar-icon",children:sxe(e)})})});hp.displayName="MessageAvatar";const lxe=e=>e?new Date(e).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}):"",cxe=e=>e.sender?.displayName?e.sender.displayName:e.sender?.id&&e.sender.id!=="guest"?e.sender.id:e.agentName?e.agentName:e.role===exports.MessageRole.User?"You":"Assistant",mp=G.memo(({message:e,isGrouped:t})=>{if(t)return null;const n=cxe(e);return S.jsxs("div",{className:"mp-agent-message-header",children:[S.jsx("span",{className:"mp-agent-message-role",children:n}),S.jsx("span",{className:"mp-agent-message-time",children:lxe(e.createdAt)})]})});mp.displayName="MessageHeader";function C2(e){const t=[],n=String(e||"");let r=n.indexOf(","),a=0,i=!1;for(;!i;){r===-1&&(r=n.length,i=!0);const o=n.slice(a,r).trim();(o||!i)&&t.push(o),a=r+1,r=n.indexOf(",",a)}return t}function uxe(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const dxe=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,pxe=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,hxe={};function R2(e,t){return(hxe.jsx?pxe:dxe).test(e)}const mxe=/[ \t\n\f\r]/g;function fxe(e){return typeof e=="object"?e.type==="text"?I2(e.value):!1:I2(e)}function I2(e){return e.replace(mxe,"")===""}let Oa=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Oa.prototype.normal={};Oa.prototype.property={};Oa.prototype.space=void 0;function Y3(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Oa(n,r,t)}function ba(e){return e.toLowerCase()}let Ft=class{constructor(t,n){this.attribute=n,this.property=t}};Ft.prototype.attribute="";Ft.prototype.booleanish=!1;Ft.prototype.boolean=!1;Ft.prototype.commaOrSpaceSeparated=!1;Ft.prototype.commaSeparated=!1;Ft.prototype.defined=!1;Ft.prototype.mustUseProperty=!1;Ft.prototype.number=!1;Ft.prototype.overloadedBoolean=!1;Ft.prototype.property="";Ft.prototype.spaceSeparated=!1;Ft.prototype.space=void 0;let gxe=0;const Re=yr(),lt=yr(),cd=yr(),se=yr(),Qe=yr(),$r=yr(),Ut=yr();function yr(){return 2**++gxe}const ud=Object.freeze(Object.defineProperty({__proto__:null,boolean:Re,booleanish:lt,commaOrSpaceSeparated:Ut,commaSeparated:$r,number:se,overloadedBoolean:cd,spaceSeparated:Qe},Symbol.toStringTag,{value:"Module"})),rs=Object.keys(ud);let fp=class extends Ft{constructor(t,n,r,a){let i=-1;if(super(t,n),O2(this,"space",a),typeof r=="number")for(;++i<rs.length;){const o=rs[i];O2(this,rs[i],(r&ud[o])===ud[o])}}};fp.prototype.defined=!0;function O2(e,t,n){n&&(e[t]=n)}function Vr(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const i=new fp(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[ba(r)]=r,n[ba(i.attribute)]=r}return new Oa(t,n,e.space)}const Z3=Vr({properties:{ariaActiveDescendant:null,ariaAtomic:lt,ariaAutoComplete:null,ariaBusy:lt,ariaChecked:lt,ariaColCount:se,ariaColIndex:se,ariaColSpan:se,ariaControls:Qe,ariaCurrent:null,ariaDescribedBy:Qe,ariaDetails:null,ariaDisabled:lt,ariaDropEffect:Qe,ariaErrorMessage:null,ariaExpanded:lt,ariaFlowTo:Qe,ariaGrabbed:lt,ariaHasPopup:null,ariaHidden:lt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Qe,ariaLevel:se,ariaLive:null,ariaModal:lt,ariaMultiLine:lt,ariaMultiSelectable:lt,ariaOrientation:null,ariaOwns:Qe,ariaPlaceholder:null,ariaPosInSet:se,ariaPressed:lt,ariaReadOnly:lt,ariaRelevant:null,ariaRequired:lt,ariaRoleDescription:Qe,ariaRowCount:se,ariaRowIndex:se,ariaRowSpan:se,ariaSelected:lt,ariaSetSize:se,ariaSort:null,ariaValueMax:se,ariaValueMin:se,ariaValueNow:se,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function X3(e,t){return t in e?e[t]:t}function Q3(e,t){return X3(e,t.toLowerCase())}const yxe=Vr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:$r,acceptCharset:Qe,accessKey:Qe,action:null,allow:null,allowFullScreen:Re,allowPaymentRequest:Re,allowUserMedia:Re,alt:null,as:null,async:Re,autoCapitalize:null,autoComplete:Qe,autoFocus:Re,autoPlay:Re,blocking:Qe,capture:null,charSet:null,checked:Re,cite:null,className:Qe,cols:se,colSpan:null,content:null,contentEditable:lt,controls:Re,controlsList:Qe,coords:se|$r,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Re,defer:Re,dir:null,dirName:null,disabled:Re,download:cd,draggable:lt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Re,formTarget:null,headers:Qe,height:se,hidden:cd,high:se,href:null,hrefLang:null,htmlFor:Qe,httpEquiv:Qe,id:null,imageSizes:null,imageSrcSet:null,inert:Re,inputMode:null,integrity:null,is:null,isMap:Re,itemId:null,itemProp:Qe,itemRef:Qe,itemScope:Re,itemType:Qe,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Re,low:se,manifest:null,max:null,maxLength:se,media:null,method:null,min:null,minLength:se,multiple:Re,muted:Re,name:null,nonce:null,noModule:Re,noValidate:Re,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Re,optimum:se,pattern:null,ping:Qe,placeholder:null,playsInline:Re,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Re,referrerPolicy:null,rel:Qe,required:Re,reversed:Re,rows:se,rowSpan:se,sandbox:Qe,scope:null,scoped:Re,seamless:Re,selected:Re,shadowRootClonable:Re,shadowRootDelegatesFocus:Re,shadowRootMode:null,shape:null,size:se,sizes:null,slot:null,span:se,spellCheck:lt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:se,step:null,style:null,tabIndex:se,target:null,title:null,translate:null,type:null,typeMustMatch:Re,useMap:null,value:lt,width:se,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Qe,axis:null,background:null,bgColor:null,border:se,borderColor:null,bottomMargin:se,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Re,declare:Re,event:null,face:null,frame:null,frameBorder:null,hSpace:se,leftMargin:se,link:null,longDesc:null,lowSrc:null,marginHeight:se,marginWidth:se,noResize:Re,noHref:Re,noShade:Re,noWrap:Re,object:null,profile:null,prompt:null,rev:null,rightMargin:se,rules:null,scheme:null,scrolling:lt,standby:null,summary:null,text:null,topMargin:se,valueType:null,version:null,vAlign:null,vLink:null,vSpace:se,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Re,disableRemotePlayback:Re,prefix:null,property:null,results:se,security:null,unselectable:null},space:"html",transform:Q3}),bxe=Vr({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Ut,accentHeight:se,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:se,amplitude:se,arabicForm:null,ascent:se,attributeName:null,attributeType:null,azimuth:se,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:se,by:null,calcMode:null,capHeight:se,className:Qe,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:se,diffuseConstant:se,direction:null,display:null,dur:null,divisor:se,dominantBaseline:null,download:Re,dx:null,dy:null,edgeMode:null,editable:null,elevation:se,enableBackground:null,end:null,event:null,exponent:se,externalResourcesRequired:null,fill:null,fillOpacity:se,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:$r,g2:$r,glyphName:$r,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:se,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:se,horizOriginX:se,horizOriginY:se,id:null,ideographic:se,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:se,k:se,k1:se,k2:se,k3:se,k4:se,kernelMatrix:Ut,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:se,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:se,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:se,overlineThickness:se,paintOrder:null,panose1:null,path:null,pathLength:se,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Qe,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:se,pointsAtY:se,pointsAtZ:se,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ut,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ut,rev:Ut,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ut,requiredFeatures:Ut,requiredFonts:Ut,requiredFormats:Ut,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:se,specularExponent:se,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:se,strikethroughThickness:se,string:null,stroke:null,strokeDashArray:Ut,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:se,strokeOpacity:se,strokeWidth:null,style:null,surfaceScale:se,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ut,tabIndex:se,tableValues:null,target:null,targetX:se,targetY:se,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ut,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:se,underlineThickness:se,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:se,values:null,vAlphabetic:se,vMathematical:se,vectorEffect:null,vHanging:se,vIdeographic:se,version:null,vertAdvY:se,vertOriginX:se,vertOriginY:se,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:se,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:X3}),J3=Vr({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),ev=Vr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Q3}),tv=Vr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),kxe={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},vxe=/[A-Z]/g,L2=/-[a-z]/g,_xe=/^data[-\w.:]+$/i;function nv(e,t){const n=ba(t);let r=t,a=Ft;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&_xe.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(L2,wxe);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!L2.test(i)){let o=i.replace(vxe,xxe);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}a=fp}return new a(r,t)}function xxe(e){return"-"+e.toLowerCase()}function wxe(e){return e.charAt(1).toUpperCase()}const rv=Y3([Z3,yxe,J3,ev,tv],"html"),fo=Y3([Z3,bxe,J3,ev,tv],"svg");function D2(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function Exe(e){return e.join(" ").trim()}var Jn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function go(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var gp={},z2=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Mxe=/\n/g,Sxe=/^\s*/,Nxe=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Axe=/^:\s*/,Txe=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,Cxe=/^[;\s]*/,Rxe=/^\s+|\s+$/g,Ixe=`
|
|
8297
8297
|
`,$2="/",F2="*",dr="",Oxe="comment",Lxe="declaration";function Dxe(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function a(g){var f=g.match(Mxe);f&&(n+=f.length);var x=g.lastIndexOf(Ixe);r=~x?g.length-x:r+g.length}function i(){var g={line:n,column:r};return function(f){return f.position=new o(g),u(),f}}function o(g){this.start=g,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function s(g){var f=new Error(t.source+":"+n+":"+r+": "+g);if(f.reason=g,f.filename=t.source,f.line=n,f.column=r,f.source=e,!t.silent)throw f}function l(g){var f=g.exec(e);if(f){var x=f[0];return a(x),e=e.slice(x.length),f}}function u(){l(Sxe)}function d(g){var f;for(g=g||[];f=p();)f!==!1&&g.push(f);return g}function p(){var g=i();if(!($2!=e.charAt(0)||F2!=e.charAt(1))){for(var f=2;dr!=e.charAt(f)&&(F2!=e.charAt(f)||$2!=e.charAt(f+1));)++f;if(f+=2,dr===e.charAt(f-1))return s("End of comment missing");var x=e.slice(2,f-2);return r+=2,a(x),e=e.slice(f),r+=2,g({type:Oxe,comment:x})}}function m(){var g=i(),f=l(Nxe);if(f){if(p(),!l(Axe))return s("property missing ':'");var x=l(Txe),_=g({type:Lxe,property:P2(f[0].replace(z2,dr)),value:x?P2(x[0].replace(z2,dr)):dr});return l(Cxe),_}}function h(){var g=[];d(g);for(var f;f=m();)f!==!1&&(g.push(f),d(g));return g}return u(),h()}function P2(e){return e?e.replace(Rxe,dr):dr}var zxe=Dxe,$xe=Jn&&Jn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(gp,"__esModule",{value:!0});gp.default=Pxe;const Fxe=$xe(zxe);function Pxe(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,Fxe.default)(e),a=typeof t=="function";return r.forEach(i=>{if(i.type!=="declaration")return;const{property:o,value:s}=i;a?t(o,s,i):s&&(n=n||{},n[o]=s)}),n}var yo={};Object.defineProperty(yo,"__esModule",{value:!0});yo.camelCase=void 0;var qxe=/^--[a-zA-Z0-9_-]+$/,Bxe=/-([a-z])/g,Uxe=/^[^-]+$/,Hxe=/^-(webkit|moz|ms|o|khtml)-/,jxe=/^-(ms)-/,Vxe=function(e){return!e||Uxe.test(e)||qxe.test(e)},Gxe=function(e,t){return t.toUpperCase()},q2=function(e,t){return"".concat(t,"-")},Wxe=function(e,t){return t===void 0&&(t={}),Vxe(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(jxe,q2):e=e.replace(Hxe,q2),e.replace(Bxe,Gxe))};yo.camelCase=Wxe;var Kxe=Jn&&Jn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},Yxe=Kxe(gp),Zxe=yo;function dd(e,t){var n={};return!e||typeof e!="string"||(0,Yxe.default)(e,function(r,a){r&&a&&(n[(0,Zxe.camelCase)(r,t)]=a)}),n}dd.default=dd;var Xxe=dd;const Qxe=go(Xxe),av=iv("end"),yp=iv("start");function iv(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Jxe(e){const t=yp(e),n=av(e);if(t&&n)return{start:t,end:n}}function la(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?B2(e.position):"start"in e||"end"in e?B2(e):"line"in e||"column"in e?pd(e):""}function pd(e){return U2(e&&e.line)+":"+U2(e&&e.column)}function B2(e){return pd(e&&e.start)+"-"+pd(e&&e.end)}function U2(e){return e&&typeof e=="number"?e:1}class Et extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let a="",i={},o=!1;if(n&&("line"in n&&"column"in n?i={place:n}:"start"in n&&"end"in n?i={place:n}:"type"in n?i={ancestors:[n],place:n.position}:i={...n}),typeof t=="string"?a=t:!i.cause&&t&&(o=!0,a=t.message,i.cause=t),!i.ruleId&&!i.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?i.ruleId=r:(i.source=r.slice(0,l),i.ruleId=r.slice(l+1))}if(!i.place&&i.ancestors&&i.ancestors){const l=i.ancestors[i.ancestors.length-1];l&&(i.place=l.position)}const s=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=s?s.line:void 0,this.name=la(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=o&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Et.prototype.file="";Et.prototype.name="";Et.prototype.reason="";Et.prototype.message="";Et.prototype.stack="";Et.prototype.column=void 0;Et.prototype.line=void 0;Et.prototype.ancestors=void 0;Et.prototype.cause=void 0;Et.prototype.fatal=void 0;Et.prototype.place=void 0;Et.prototype.ruleId=void 0;Et.prototype.source=void 0;const bp={}.hasOwnProperty,ewe=new Map,twe=/[A-Z]/g,nwe=new Set(["table","tbody","thead","tfoot","tr"]),rwe=new Set(["td","th"]),ov="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function awe(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=pwe(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=dwe(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?fo:rv,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=sv(a,e,void 0);return i&&typeof i!="string"?i:a.create(e,a.Fragment,{children:i||void 0},void 0)}function sv(e,t,n){if(t.type==="element")return iwe(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return owe(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return lwe(e,t,n);if(t.type==="mdxjsEsm")return swe(e,t);if(t.type==="root")return cwe(e,t,n);if(t.type==="text")return uwe(e,t)}function iwe(e,t,n){const r=e.schema;let a=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(a=fo,e.schema=a),e.ancestors.push(t);const i=cv(e,t.tagName,!1),o=hwe(e,t);let s=vp(e,t);return nwe.has(t.tagName)&&(s=s.filter(function(l){return typeof l=="string"?!fxe(l):!0})),lv(e,o,i,t),kp(o,s),e.ancestors.pop(),e.schema=r,e.create(t,i,o,n)}function owe(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}ka(e,t.position)}function swe(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ka(e,t.position)}function lwe(e,t,n){const r=e.schema;let a=r;t.name==="svg"&&r.space==="html"&&(a=fo,e.schema=a),e.ancestors.push(t);const i=t.name===null?e.Fragment:cv(e,t.name,!0),o=mwe(e,t),s=vp(e,t);return lv(e,o,i,t),kp(o,s),e.ancestors.pop(),e.schema=r,e.create(t,i,o,n)}function cwe(e,t,n){const r={};return kp(r,vp(e,t)),e.create(t,e.Fragment,r,n)}function uwe(e,t){return t.value}function lv(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function kp(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function dwe(e,t,n){return r;function r(a,i,o,s){const u=Array.isArray(o.children)?n:t;return s?u(i,o,s):u(i,o)}}function pwe(e,t){return n;function n(r,a,i,o){const s=Array.isArray(i.children),l=yp(r);return t(a,i,o,s,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function hwe(e,t){const n={};let r,a;for(a in t.properties)if(a!=="children"&&bp.call(t.properties,a)){const i=fwe(e,a,t.properties[a]);if(i){const[o,s]=i;e.tableCellAlignToStyle&&o==="align"&&typeof s=="string"&&rwe.has(t.tagName)?r=s:n[o]=s}}if(r){const i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function mwe(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const i=r.data.estree.body[0];i.type;const o=i.expression;o.type;const s=o.properties[0];s.type,Object.assign(n,e.evaluater.evaluateExpression(s.argument))}else ka(e,t.position);else{const a=r.name;let i;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const s=r.value.data.estree.body[0];s.type,i=e.evaluater.evaluateExpression(s.expression)}else ka(e,t.position);else i=r.value===null?!0:r.value;n[a]=i}return n}function vp(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:ewe;for(;++r<t.children.length;){const i=t.children[r];let o;if(e.passKeys){const l=i.type==="element"?i.tagName:i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement"?i.name:void 0;if(l){const u=a.get(l)||0;o=l+"-"+u,a.set(l,u+1)}}const s=sv(e,i,o);s!==void 0&&n.push(s)}return n}function fwe(e,t,n){const r=nv(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?uxe(n):Exe(n)),r.property==="style"){let a=typeof n=="object"?n:gwe(e,String(n));return e.stylePropertyNameCase==="css"&&(a=ywe(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&r.space?kxe[r.property]||r.property:r.attribute,n]}}function gwe(e,t){try{return Qxe(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,a=new Et("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=ov+"#cannot-parse-style-attribute",a}}function cv(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let i=-1,o;for(;++i<a.length;){const s=R2(a[i])?{type:"Identifier",name:a[i]}:{type:"Literal",value:a[i]};o=o?{type:"MemberExpression",object:o,property:s,computed:!!(i&&s.type==="Literal"),optional:!1}:s}r=o}else r=R2(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const a=r.value;return bp.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(r);ka(e)}function ka(e,t){const n=new Et("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=ov+"#cannot-handle-mdx-estrees-without-createevaluater",n}function ywe(e){const t={};let n;for(n in e)bp.call(e,n)&&(t[bwe(n)]=e[n]);return t}function bwe(e){let t=e.replace(twe,kwe);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function kwe(e){return"-"+e.toLowerCase()}const as={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},vwe={};function _p(e,t){const n=vwe,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return uv(e,r,a)}function uv(e,t,n){if(_we(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return H2(e.children,t,n)}return Array.isArray(e)?H2(e,t,n):""}function H2(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=uv(e[a],t,n);return r.join("")}function _we(e){return!!(e&&typeof e=="object")}const j2=document.createElement("i");function va(e){const t="&"+e+";";j2.innerHTML=t;const n=j2.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Gt(e,t,n,r){const a=e.length;let i=0,o;if(t<0?t=-t>a?0:a+t:t=t>a?a:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);i<r.length;)o=r.slice(i,i+1e4),o.unshift(t,0),e.splice(...o),i+=1e4,t+=1e4}function Jt(e,t){return e.length>0?(Gt(e,e.length,0,t),e):t}const V2={}.hasOwnProperty;function dv(e){const t={};let n=-1;for(;++n<e.length;)xwe(t,e[n]);return t}function xwe(e,t){let n;for(n in t){const a=(V2.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let o;if(i)for(o in i){V2.call(a,o)||(a[o]=[]);const s=i[o];wwe(a[o],Array.isArray(s)?s:s?[s]:[])}}}function wwe(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Gt(e,0,0,r)}function pv(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function pn(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Tt=ar(/[A-Za-z]/),xt=ar(/[\dA-Za-z]/),Ewe=ar(/[#-'*+\--9=?A-Z^-~]/);function zi(e){return e!==null&&(e<32||e===127)}const hd=ar(/\d/),Mwe=ar(/[\dA-Fa-f]/),Swe=ar(/[!-/:-@[-`{-~]/);function he(e){return e!==null&&e<-2}function Ue(e){return e!==null&&(e<0||e===32)}function Oe(e){return e===-2||e===-1||e===32}const er=ar(/\p{P}|\p{S}/u),hn=ar(/\s/);function ar(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Gr(e){const t=[];let n=-1,r=0,a=0;for(;++n<e.length;){const i=e.charCodeAt(n);let o="";if(i===37&&xt(e.charCodeAt(n+1))&&xt(e.charCodeAt(n+2)))a=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(o=String.fromCharCode(i));else if(i>55295&&i<57344){const s=e.charCodeAt(n+1);i<56320&&s>56319&&s<57344?(o=String.fromCharCode(i,s),a=1):o="�"}else o=String.fromCharCode(i);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+a+1,o=""),a&&(n+=a,a=0)}return t.join("")+e.slice(r)}function Te(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let i=0;return o;function o(l){return Oe(l)?(e.enter(n),s(l)):t(l)}function s(l){return Oe(l)&&i++<a?(e.consume(l),s):(e.exit(n),t(l))}}const Nwe={tokenize:Awe};function Awe(e){const t=e.attempt(this.parser.constructs.contentInitial,r,a);let n;return t;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),Te(e,t,"linePrefix")}function a(s){return e.enter("paragraph"),i(s)}function i(s){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(s)}function o(s){if(s===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(s);return}return he(s)?(e.consume(s),e.exit("chunkText"),i):(e.consume(s),o)}}const Twe={tokenize:Cwe},G2={tokenize:Rwe};function Cwe(e){const t=this,n=[];let r=0,a,i,o;return s;function s(v){if(r<n.length){const E=n[r];return t.containerState=E[1],e.attempt(E[0].continuation,l,u)(v)}return u(v)}function l(v){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&b();const E=t.events.length;let N=E,w;for(;N--;)if(t.events[N][0]==="exit"&&t.events[N][1].type==="chunkFlow"){w=t.events[N][1].end;break}_(r);let $=E;for(;$<t.events.length;)t.events[$][1].end={...w},$++;return Gt(t.events,N+1,0,t.events.slice(E)),t.events.length=$,u(v)}return s(v)}function u(v){if(r===n.length){if(!a)return m(v);if(a.currentConstruct&&a.currentConstruct.concrete)return g(v);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(G2,d,p)(v)}function d(v){return a&&b(),_(r),m(v)}function p(v){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,g(v)}function m(v){return t.containerState={},e.attempt(G2,h,g)(v)}function h(v){return r++,n.push([t.currentConstruct,t.containerState]),m(v)}function g(v){if(v===null){a&&b(),_(0),e.consume(v);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:i}),f(v)}function f(v){if(v===null){x(e.exit("chunkFlow"),!0),_(0),e.consume(v);return}return he(v)?(e.consume(v),x(e.exit("chunkFlow")),r=0,t.interrupt=void 0,s):(e.consume(v),f)}function x(v,E){const N=t.sliceStream(v);if(E&&N.push(null),v.previous=i,i&&(i.next=v),i=v,a.defineSkip(v.start),a.write(N),t.parser.lazy[v.start.line]){let w=a.events.length;for(;w--;)if(a.events[w][1].start.offset<o&&(!a.events[w][1].end||a.events[w][1].end.offset>o))return;const $=t.events.length;let P=$,C,L;for(;P--;)if(t.events[P][0]==="exit"&&t.events[P][1].type==="chunkFlow"){if(C){L=t.events[P][1].end;break}C=!0}for(_(r),w=$;w<t.events.length;)t.events[w][1].end={...L},w++;Gt(t.events,P+1,0,t.events.slice($)),t.events.length=w}}function _(v){let E=n.length;for(;E-- >v;){const N=n[E];t.containerState=N[1],N[0].exit.call(t,e)}n.length=v}function b(){a.write([null]),i=void 0,a=void 0,t.containerState._closeFlow=void 0}}function Rwe(e,t,n){return Te(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Pr(e){if(e===null||Ue(e)||hn(e))return 1;if(er(e))return 2}function bo(e,t,n){const r=[];let a=-1;for(;++a<e.length;){const i=e[a].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}const md={name:"attention",resolveAll:Iwe,tokenize:Owe};function Iwe(e,t){let n=-1,r,a,i,o,s,l,u,d;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const p={...e[r][1].end},m={...e[n][1].start};W2(p,-l),W2(m,l),o={type:l>1?"strongSequence":"emphasisSequence",start:p,end:{...e[r][1].end}},s={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:m},i={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},a={type:l>1?"strong":"emphasis",start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Jt(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Jt(u,[["enter",a,t],["enter",o,t],["exit",o,t],["enter",i,t]]),u=Jt(u,bo(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Jt(u,[["exit",i,t],["enter",s,t],["exit",s,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=Jt(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,Gt(e,r-1,n-r+3,u),n=r+u.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function Owe(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,a=Pr(r);let i;return o;function o(l){return i=l,e.enter("attentionSequence"),s(l)}function s(l){if(l===i)return e.consume(l),s;const u=e.exit("attentionSequence"),d=Pr(l),p=!d||d===2&&a||n.includes(l),m=!a||a===2&&d||n.includes(r);return u._open=!!(i===42?p:p&&(a||!m)),u._close=!!(i===42?m:m&&(d||!p)),t(l)}}function W2(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Lwe={name:"autolink",tokenize:Dwe};function Dwe(e,t,n){let r=0;return a;function a(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(h){return Tt(h)?(e.consume(h),o):h===64?n(h):u(h)}function o(h){return h===43||h===45||h===46||xt(h)?(r=1,s(h)):u(h)}function s(h){return h===58?(e.consume(h),r=0,l):(h===43||h===45||h===46||xt(h))&&r++<32?(e.consume(h),s):(r=0,u(h))}function l(h){return h===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):h===null||h===32||h===60||zi(h)?n(h):(e.consume(h),l)}function u(h){return h===64?(e.consume(h),d):Ewe(h)?(e.consume(h),u):n(h)}function d(h){return xt(h)?p(h):n(h)}function p(h){return h===46?(e.consume(h),r=0,d):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):m(h)}function m(h){if((h===45||xt(h))&&r++<63){const g=h===45?m:p;return e.consume(h),g}return n(h)}}const La={partial:!0,tokenize:zwe};function zwe(e,t,n){return r;function r(i){return Oe(i)?Te(e,a,"linePrefix")(i):a(i)}function a(i){return i===null||he(i)?t(i):n(i)}}const hv={continuation:{tokenize:Fwe},exit:Pwe,name:"blockQuote",tokenize:$we};function $we(e,t,n){const r=this;return a;function a(o){if(o===62){const s=r.containerState;return s.open||(e.enter("blockQuote",{_container:!0}),s.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),i}return n(o)}function i(o){return Oe(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function Fwe(e,t,n){const r=this;return a;function a(o){return Oe(o)?Te(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):i(o)}function i(o){return e.attempt(hv,t,n)(o)}}function Pwe(e){e.exit("blockQuote")}const mv={name:"characterEscape",tokenize:qwe};function qwe(e,t,n){return r;function r(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),a}function a(i){return Swe(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const fv={name:"characterReference",tokenize:Bwe};function Bwe(e,t,n){const r=this;let a=0,i,o;return s;function s(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),l}function l(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),i=31,o=xt,d(p))}function u(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,o=Mwe,d):(e.enter("characterReferenceValue"),i=7,o=hd,d(p))}function d(p){if(p===59&&a){const m=e.exit("characterReferenceValue");return o===xt&&!va(r.sliceSerialize(m))?n(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(p)&&a++<i?(e.consume(p),d):n(p)}}const K2={partial:!0,tokenize:Hwe},Y2={concrete:!0,name:"codeFenced",tokenize:Uwe};function Uwe(e,t,n){const r=this,a={partial:!0,tokenize:N};let i=0,o=0,s;return l;function l(w){return u(w)}function u(w){const $=r.events[r.events.length-1];return i=$&&$[1].type==="linePrefix"?$[2].sliceSerialize($[1],!0).length:0,s=w,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(w)}function d(w){return w===s?(o++,e.consume(w),d):o<3?n(w):(e.exit("codeFencedFenceSequence"),Oe(w)?Te(e,p,"whitespace")(w):p(w))}function p(w){return w===null||he(w)?(e.exit("codeFencedFence"),r.interrupt?t(w):e.check(K2,f,E)(w)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),m(w))}function m(w){return w===null||he(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(w)):Oe(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Te(e,h,"whitespace")(w)):w===96&&w===s?n(w):(e.consume(w),m)}function h(w){return w===null||he(w)?p(w):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(w))}function g(w){return w===null||he(w)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(w)):w===96&&w===s?n(w):(e.consume(w),g)}function f(w){return e.attempt(a,E,x)(w)}function x(w){return e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),_}function _(w){return i>0&&Oe(w)?Te(e,b,"linePrefix",i+1)(w):b(w)}function b(w){return w===null||he(w)?e.check(K2,f,E)(w):(e.enter("codeFlowValue"),v(w))}function v(w){return w===null||he(w)?(e.exit("codeFlowValue"),b(w)):(e.consume(w),v)}function E(w){return e.exit("codeFenced"),t(w)}function N(w,$,P){let C=0;return L;function L(R){return w.enter("lineEnding"),w.consume(R),w.exit("lineEnding"),U}function U(R){return w.enter("codeFencedFence"),Oe(R)?Te(w,Z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):Z(R)}function Z(R){return R===s?(w.enter("codeFencedFenceSequence"),J(R)):P(R)}function J(R){return R===s?(C++,w.consume(R),J):C>=o?(w.exit("codeFencedFenceSequence"),Oe(R)?Te(w,K,"whitespace")(R):K(R)):P(R)}function K(R){return R===null||he(R)?(w.exit("codeFencedFence"),$(R)):P(R)}}}function Hwe(e,t,n){const r=this;return a;function a(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i)}function i(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const is={name:"codeIndented",tokenize:Vwe},jwe={partial:!0,tokenize:Gwe};function Vwe(e,t,n){const r=this;return a;function a(u){return e.enter("codeIndented"),Te(e,i,"linePrefix",5)(u)}function i(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?o(u):n(u)}function o(u){return u===null?l(u):he(u)?e.attempt(jwe,o,l)(u):(e.enter("codeFlowValue"),s(u))}function s(u){return u===null||he(u)?(e.exit("codeFlowValue"),o(u)):(e.consume(u),s)}function l(u){return e.exit("codeIndented"),t(u)}}function Gwe(e,t,n){const r=this;return a;function a(o){return r.parser.lazy[r.now().line]?n(o):he(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a):Te(e,i,"linePrefix",5)(o)}function i(o){const s=r.events[r.events.length-1];return s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):he(o)?a(o):n(o)}}const Wwe={name:"codeText",previous:Ywe,resolve:Kwe,tokenize:Zwe};function Kwe(e){let t=e.length-4,n=3,r,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)a===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(a=r):(r===t||e[r][1].type==="lineEnding")&&(e[a][1].type="codeTextData",r!==a+2&&(e[a][1].end=e[r-1][1].end,e.splice(a+2,r-a-2),t-=r-a-2,r=a+2),a=void 0);return e}function Ywe(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Zwe(e,t,n){let r=0,a,i;return o;function o(p){return e.enter("codeText"),e.enter("codeTextSequence"),s(p)}function s(p){return p===96?(e.consume(p),r++,s):(e.exit("codeTextSequence"),l(p))}function l(p){return p===null?n(p):p===32?(e.enter("space"),e.consume(p),e.exit("space"),l):p===96?(i=e.enter("codeTextSequence"),a=0,d(p)):he(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),l):(e.enter("codeTextData"),u(p))}function u(p){return p===null||p===32||p===96||he(p)?(e.exit("codeTextData"),l(p)):(e.consume(p),u)}function d(p){return p===96?(e.consume(p),a++,d):a===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(p)):(i.type="codeTextData",u(p))}}class Xwe{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const a=n||0;this.setCursor(Math.trunc(t));const i=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return r&&Xr(this.left,r),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Xr(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Xr(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Xr(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Xr(this.left,n.reverse())}}}function Xr(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function gv(e){const t={};let n=-1,r,a,i,o,s,l,u;const d=new Xwe(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,i=0,i<l.length&&l[i][1].type==="lineEndingBlank"&&(i+=2),i<l.length&&l[i][1].type==="content"))for(;++i<l.length&&l[i][1].type!=="content";)l[i][1].type==="chunkText"&&(l[i][1]._isInFirstContentOfListItem=!0,i++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,Qwe(d,n)),n=t[n],u=!0);else if(r[1]._container){for(i=n,a=void 0;i--;)if(o=d.get(i),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(a&&(d.get(a)[1].type="lineEndingBlank"),o[1].type="lineEnding",a=i);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;a&&(r[1].end={...d.get(a)[1].start},s=d.slice(a,n),s.unshift(r),d.splice(a,n-a+1,s))}}return Gt(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function Qwe(e,t){const n=e.get(t)[1],r=e.get(t)[2];let a=t-1;const i=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const s=o.events,l=[],u={};let d,p,m=-1,h=n,g=0,f=0;const x=[f];for(;h;){for(;e.get(++a)[1]!==h;);i.push(a),h._tokenizer||(d=r.sliceStream(h),h.next||d.push(null),p&&o.defineSkip(h.start),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(d),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),p=h,h=h.next}for(h=n;++m<s.length;)s[m][0]==="exit"&&s[m-1][0]==="enter"&&s[m][1].type===s[m-1][1].type&&s[m][1].start.line!==s[m][1].end.line&&(f=m+1,x.push(f),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(o.events=[],h?(h._tokenizer=void 0,h.previous=void 0):x.pop(),m=x.length;m--;){const _=s.slice(x[m],x[m+1]),b=i.pop();l.push([b,b+_.length-1]),e.splice(b,2,_)}for(l.reverse(),m=-1;++m<l.length;)u[g+l[m][0]]=g+l[m][1],g+=l[m][1]-l[m][0]-1;return u}const Jwe={resolve:t9e,tokenize:n9e},e9e={partial:!0,tokenize:r9e};function t9e(e){return gv(e),e}function n9e(e,t){let n;return r;function r(s){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(s)}function a(s){return s===null?i(s):he(s)?e.check(e9e,o,i)(s):(e.consume(s),a)}function i(s){return e.exit("chunkContent"),e.exit("content"),t(s)}function o(s){return e.consume(s),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}function r9e(e,t,n){const r=this;return a;function a(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Te(e,i,"linePrefix")}function i(o){if(o===null||he(o))return n(o);const s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function yv(e,t,n,r,a,i,o,s,l){const u=l||Number.POSITIVE_INFINITY;let d=0;return p;function p(_){return _===60?(e.enter(r),e.enter(a),e.enter(i),e.consume(_),e.exit(i),m):_===null||_===32||_===41||zi(_)?n(_):(e.enter(r),e.enter(o),e.enter(s),e.enter("chunkString",{contentType:"string"}),f(_))}function m(_){return _===62?(e.enter(i),e.consume(_),e.exit(i),e.exit(a),e.exit(r),t):(e.enter(s),e.enter("chunkString",{contentType:"string"}),h(_))}function h(_){return _===62?(e.exit("chunkString"),e.exit(s),m(_)):_===null||_===60||he(_)?n(_):(e.consume(_),_===92?g:h)}function g(_){return _===60||_===62||_===92?(e.consume(_),h):h(_)}function f(_){return!d&&(_===null||_===41||Ue(_))?(e.exit("chunkString"),e.exit(s),e.exit(o),e.exit(r),t(_)):d<u&&_===40?(e.consume(_),d++,f):_===41?(e.consume(_),d--,f):_===null||_===32||_===40||zi(_)?n(_):(e.consume(_),_===92?x:f)}function x(_){return _===40||_===41||_===92?(e.consume(_),f):f(_)}}function bv(e,t,n,r,a,i){const o=this;let s=0,l;return u;function u(h){return e.enter(r),e.enter(a),e.consume(h),e.exit(a),e.enter(i),d}function d(h){return s>999||h===null||h===91||h===93&&!l||h===94&&!s&&"_hiddenFootnoteSupport"in o.parser.constructs?n(h):h===93?(e.exit(i),e.enter(a),e.consume(h),e.exit(a),e.exit(r),t):he(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),p(h))}function p(h){return h===null||h===91||h===93||he(h)||s++>999?(e.exit("chunkString"),d(h)):(e.consume(h),l||(l=!Oe(h)),h===92?m:p)}function m(h){return h===91||h===92||h===93?(e.consume(h),s++,p):p(h)}}function kv(e,t,n,r,a,i){let o;return s;function s(m){return m===34||m===39||m===40?(e.enter(r),e.enter(a),e.consume(m),e.exit(a),o=m===40?41:m,l):n(m)}function l(m){return m===o?(e.enter(a),e.consume(m),e.exit(a),e.exit(r),t):(e.enter(i),u(m))}function u(m){return m===o?(e.exit(i),l(o)):m===null?n(m):he(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),Te(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(m))}function d(m){return m===o||m===null||he(m)?(e.exit("chunkString"),u(m)):(e.consume(m),m===92?p:d)}function p(m){return m===o||m===92?(e.consume(m),d):d(m)}}function On(e,t){let n;return r;function r(a){return he(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r):Oe(a)?Te(e,r,n?"linePrefix":"lineSuffix")(a):t(a)}}const a9e={name:"definition",tokenize:o9e},i9e={partial:!0,tokenize:s9e};function o9e(e,t,n){const r=this;let a;return i;function i(h){return e.enter("definition"),o(h)}function o(h){return bv.call(r,e,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function s(h){return a=pn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),l):n(h)}function l(h){return Ue(h)?On(e,u)(h):u(h)}function u(h){return yv(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function d(h){return e.attempt(i9e,p,p)(h)}function p(h){return Oe(h)?Te(e,m,"whitespace")(h):m(h)}function m(h){return h===null||he(h)?(e.exit("definition"),r.parser.defined.push(a),t(h)):n(h)}}function s9e(e,t,n){return r;function r(s){return Ue(s)?On(e,a)(s):n(s)}function a(s){return kv(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(s)}function i(s){return Oe(s)?Te(e,o,"whitespace")(s):o(s)}function o(s){return s===null||he(s)?t(s):n(s)}}const l9e={name:"hardBreakEscape",tokenize:c9e};function c9e(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),a}function a(i){return he(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const u9e={name:"headingAtx",resolve:d9e,tokenize:p9e};function d9e(e,t){let n=e.length-2,r=3,a,i;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(a={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},i={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Gt(e,r,n-r+1,[["enter",a,t],["enter",i,t],["exit",i,t],["exit",a,t]])),e}function p9e(e,t,n){let r=0;return a;function a(d){return e.enter("atxHeading"),i(d)}function i(d){return e.enter("atxHeadingSequence"),o(d)}function o(d){return d===35&&r++<6?(e.consume(d),o):d===null||Ue(d)?(e.exit("atxHeadingSequence"),s(d)):n(d)}function s(d){return d===35?(e.enter("atxHeadingSequence"),l(d)):d===null||he(d)?(e.exit("atxHeading"),t(d)):Oe(d)?Te(e,s,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function l(d){return d===35?(e.consume(d),l):(e.exit("atxHeadingSequence"),s(d))}function u(d){return d===null||d===35||Ue(d)?(e.exit("atxHeadingText"),s(d)):(e.consume(d),u)}}const h9e=["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","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Z2=["pre","script","style","textarea"],m9e={concrete:!0,name:"htmlFlow",resolveTo:y9e,tokenize:b9e},f9e={partial:!0,tokenize:v9e},g9e={partial:!0,tokenize:k9e};function y9e(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function b9e(e,t,n){const r=this;let a,i,o,s,l;return u;function u(O){return d(O)}function d(O){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(O),p}function p(O){return O===33?(e.consume(O),m):O===47?(e.consume(O),i=!0,f):O===63?(e.consume(O),a=3,r.interrupt?t:A):Tt(O)?(e.consume(O),o=String.fromCharCode(O),x):n(O)}function m(O){return O===45?(e.consume(O),a=2,h):O===91?(e.consume(O),a=5,s=0,g):Tt(O)?(e.consume(O),a=4,r.interrupt?t:A):n(O)}function h(O){return O===45?(e.consume(O),r.interrupt?t:A):n(O)}function g(O){const le="CDATA[";return O===le.charCodeAt(s++)?(e.consume(O),s===le.length?r.interrupt?t:Z:g):n(O)}function f(O){return Tt(O)?(e.consume(O),o=String.fromCharCode(O),x):n(O)}function x(O){if(O===null||O===47||O===62||Ue(O)){const le=O===47,ge=o.toLowerCase();return!le&&!i&&Z2.includes(ge)?(a=1,r.interrupt?t(O):Z(O)):h9e.includes(o.toLowerCase())?(a=6,le?(e.consume(O),_):r.interrupt?t(O):Z(O)):(a=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(O):i?b(O):v(O))}return O===45||xt(O)?(e.consume(O),o+=String.fromCharCode(O),x):n(O)}function _(O){return O===62?(e.consume(O),r.interrupt?t:Z):n(O)}function b(O){return Oe(O)?(e.consume(O),b):L(O)}function v(O){return O===47?(e.consume(O),L):O===58||O===95||Tt(O)?(e.consume(O),E):Oe(O)?(e.consume(O),v):L(O)}function E(O){return O===45||O===46||O===58||O===95||xt(O)?(e.consume(O),E):N(O)}function N(O){return O===61?(e.consume(O),w):Oe(O)?(e.consume(O),N):v(O)}function w(O){return O===null||O===60||O===61||O===62||O===96?n(O):O===34||O===39?(e.consume(O),l=O,$):Oe(O)?(e.consume(O),w):P(O)}function $(O){return O===l?(e.consume(O),l=null,C):O===null||he(O)?n(O):(e.consume(O),$)}function P(O){return O===null||O===34||O===39||O===47||O===60||O===61||O===62||O===96||Ue(O)?N(O):(e.consume(O),P)}function C(O){return O===47||O===62||Oe(O)?v(O):n(O)}function L(O){return O===62?(e.consume(O),U):n(O)}function U(O){return O===null||he(O)?Z(O):Oe(O)?(e.consume(O),U):n(O)}function Z(O){return O===45&&a===2?(e.consume(O),H):O===60&&a===1?(e.consume(O),j):O===62&&a===4?(e.consume(O),Y):O===63&&a===3?(e.consume(O),A):O===93&&a===5?(e.consume(O),V):he(O)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(f9e,ee,J)(O)):O===null||he(O)?(e.exit("htmlFlowData"),J(O)):(e.consume(O),Z)}function J(O){return e.check(g9e,K,ee)(O)}function K(O){return e.enter("lineEnding"),e.consume(O),e.exit("lineEnding"),R}function R(O){return O===null||he(O)?J(O):(e.enter("htmlFlowData"),Z(O))}function H(O){return O===45?(e.consume(O),A):Z(O)}function j(O){return O===47?(e.consume(O),o="",D):Z(O)}function D(O){if(O===62){const le=o.toLowerCase();return Z2.includes(le)?(e.consume(O),Y):Z(O)}return Tt(O)&&o.length<8?(e.consume(O),o+=String.fromCharCode(O),D):Z(O)}function V(O){return O===93?(e.consume(O),A):Z(O)}function A(O){return O===62?(e.consume(O),Y):O===45&&a===2?(e.consume(O),A):Z(O)}function Y(O){return O===null||he(O)?(e.exit("htmlFlowData"),ee(O)):(e.consume(O),Y)}function ee(O){return e.exit("htmlFlow"),t(O)}}function k9e(e,t,n){const r=this;return a;function a(o){return he(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):n(o)}function i(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function v9e(e,t,n){return r;function r(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(La,t,n)}}const _9e={name:"htmlText",tokenize:x9e};function x9e(e,t,n){const r=this;let a,i,o;return s;function s(A){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(A),l}function l(A){return A===33?(e.consume(A),u):A===47?(e.consume(A),N):A===63?(e.consume(A),v):Tt(A)?(e.consume(A),P):n(A)}function u(A){return A===45?(e.consume(A),d):A===91?(e.consume(A),i=0,g):Tt(A)?(e.consume(A),b):n(A)}function d(A){return A===45?(e.consume(A),h):n(A)}function p(A){return A===null?n(A):A===45?(e.consume(A),m):he(A)?(o=p,j(A)):(e.consume(A),p)}function m(A){return A===45?(e.consume(A),h):p(A)}function h(A){return A===62?H(A):A===45?m(A):p(A)}function g(A){const Y="CDATA[";return A===Y.charCodeAt(i++)?(e.consume(A),i===Y.length?f:g):n(A)}function f(A){return A===null?n(A):A===93?(e.consume(A),x):he(A)?(o=f,j(A)):(e.consume(A),f)}function x(A){return A===93?(e.consume(A),_):f(A)}function _(A){return A===62?H(A):A===93?(e.consume(A),_):f(A)}function b(A){return A===null||A===62?H(A):he(A)?(o=b,j(A)):(e.consume(A),b)}function v(A){return A===null?n(A):A===63?(e.consume(A),E):he(A)?(o=v,j(A)):(e.consume(A),v)}function E(A){return A===62?H(A):v(A)}function N(A){return Tt(A)?(e.consume(A),w):n(A)}function w(A){return A===45||xt(A)?(e.consume(A),w):$(A)}function $(A){return he(A)?(o=$,j(A)):Oe(A)?(e.consume(A),$):H(A)}function P(A){return A===45||xt(A)?(e.consume(A),P):A===47||A===62||Ue(A)?C(A):n(A)}function C(A){return A===47?(e.consume(A),H):A===58||A===95||Tt(A)?(e.consume(A),L):he(A)?(o=C,j(A)):Oe(A)?(e.consume(A),C):H(A)}function L(A){return A===45||A===46||A===58||A===95||xt(A)?(e.consume(A),L):U(A)}function U(A){return A===61?(e.consume(A),Z):he(A)?(o=U,j(A)):Oe(A)?(e.consume(A),U):C(A)}function Z(A){return A===null||A===60||A===61||A===62||A===96?n(A):A===34||A===39?(e.consume(A),a=A,J):he(A)?(o=Z,j(A)):Oe(A)?(e.consume(A),Z):(e.consume(A),K)}function J(A){return A===a?(e.consume(A),a=void 0,R):A===null?n(A):he(A)?(o=J,j(A)):(e.consume(A),J)}function K(A){return A===null||A===34||A===39||A===60||A===61||A===96?n(A):A===47||A===62||Ue(A)?C(A):(e.consume(A),K)}function R(A){return A===47||A===62||Ue(A)?C(A):n(A)}function H(A){return A===62?(e.consume(A),e.exit("htmlTextData"),e.exit("htmlText"),t):n(A)}function j(A){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),D}function D(A){return Oe(A)?Te(e,V,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):V(A)}function V(A){return e.enter("htmlTextData"),o(A)}}const xp={name:"labelEnd",resolveAll:S9e,resolveTo:N9e,tokenize:A9e},w9e={tokenize:T9e},E9e={tokenize:C9e},M9e={tokenize:R9e};function S9e(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const a=r.type==="labelImage"?4:2;r.type="data",t+=a}}return e.length!==n.length&&Gt(e,0,e.length,n),e}function N9e(e,t){let n=e.length,r=0,a,i,o,s;for(;n--;)if(a=e[n][1],i){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;e[n][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(i=n,a.type!=="labelLink")){r=2;break}}else a.type==="labelEnd"&&(o=n);const l={type:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[i][1].start},end:{...e[o][1].end}},d={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[o-2][1].start}};return s=[["enter",l,t],["enter",u,t]],s=Jt(s,e.slice(i+1,i+r+3)),s=Jt(s,[["enter",d,t]]),s=Jt(s,bo(t.parser.constructs.insideSpan.null,e.slice(i+r+4,o-3),t)),s=Jt(s,[["exit",d,t],e[o-2],e[o-1],["exit",u,t]]),s=Jt(s,e.slice(o+1)),s=Jt(s,[["exit",l,t]]),Gt(e,i,e.length,s),e}function A9e(e,t,n){const r=this;let a=r.events.length,i,o;for(;a--;)if((r.events[a][1].type==="labelImage"||r.events[a][1].type==="labelLink")&&!r.events[a][1]._balanced){i=r.events[a][1];break}return s;function s(m){return i?i._inactive?p(m):(o=r.parser.defined.includes(pn(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(m),e.exit("labelMarker"),e.exit("labelEnd"),l):n(m)}function l(m){return m===40?e.attempt(w9e,d,o?d:p)(m):m===91?e.attempt(E9e,d,o?u:p)(m):o?d(m):p(m)}function u(m){return e.attempt(M9e,d,p)(m)}function d(m){return t(m)}function p(m){return i._balanced=!0,n(m)}}function T9e(e,t,n){return r;function r(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),a}function a(p){return Ue(p)?On(e,i)(p):i(p)}function i(p){return p===41?d(p):yv(e,o,s,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function o(p){return Ue(p)?On(e,l)(p):d(p)}function s(p){return n(p)}function l(p){return p===34||p===39||p===40?kv(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):d(p)}function u(p){return Ue(p)?On(e,d)(p):d(p)}function d(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),t):n(p)}}function C9e(e,t,n){const r=this;return a;function a(s){return bv.call(r,e,i,o,"reference","referenceMarker","referenceString")(s)}function i(s){return r.parser.defined.includes(pn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function R9e(e,t,n){return r;function r(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),a}function a(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):n(i)}}const I9e={name:"labelStartImage",resolveAll:xp.resolveAll,tokenize:O9e};function O9e(e,t,n){const r=this;return a;function a(s){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(s),e.exit("labelImageMarker"),i}function i(s){return s===91?(e.enter("labelMarker"),e.consume(s),e.exit("labelMarker"),e.exit("labelImage"),o):n(s)}function o(s){return s===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(s):t(s)}}const L9e={name:"labelStartLink",resolveAll:xp.resolveAll,tokenize:D9e};function D9e(e,t,n){const r=this;return a;function a(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),i}function i(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const os={name:"lineEnding",tokenize:z9e};function z9e(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Te(e,t,"linePrefix")}}const wi={name:"thematicBreak",tokenize:$9e};function $9e(e,t,n){let r=0,a;return i;function i(u){return e.enter("thematicBreak"),o(u)}function o(u){return a=u,s(u)}function s(u){return u===a?(e.enter("thematicBreakSequence"),l(u)):r>=3&&(u===null||he(u))?(e.exit("thematicBreak"),t(u)):n(u)}function l(u){return u===a?(e.consume(u),r++,l):(e.exit("thematicBreakSequence"),Oe(u)?Te(e,s,"whitespace")(u):s(u))}}const Dt={continuation:{tokenize:B9e},exit:H9e,name:"list",tokenize:q9e},F9e={partial:!0,tokenize:j9e},P9e={partial:!0,tokenize:U9e};function q9e(e,t,n){const r=this,a=r.events[r.events.length-1];let i=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,o=0;return s;function s(h){const g=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:hd(h)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check(wi,n,u)(h):u(h);if(!r.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(h)}return n(h)}function l(h){return hd(h)&&++o<10?(e.consume(h),l):(!r.interrupt||o<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),u(h)):n(h)}function u(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,e.check(La,r.interrupt?n:d,e.attempt(F9e,m,p))}function d(h){return r.containerState.initialBlankLine=!0,i++,m(h)}function p(h){return Oe(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),m):n(h)}function m(h){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function B9e(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(La,a,i);function a(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Te(e,t,"listItemIndent",r.containerState.size+1)(s)}function i(s){return r.containerState.furtherBlankLines||!Oe(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(P9e,t,o)(s))}function o(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,Te(e,e.attempt(Dt,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s)}}function U9e(e,t,n){const r=this;return Te(e,a,"listItemIndent",r.containerState.size+1);function a(i){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(i):n(i)}}function H9e(e){e.exit(this.containerState.type)}function j9e(e,t,n){const r=this;return Te(e,a,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(i){const o=r.events[r.events.length-1];return!Oe(i)&&o&&o[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const X2={name:"setextUnderline",resolveTo:V9e,tokenize:G9e};function V9e(e,t){let n=e.length,r,a,i;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!i&&e[n][1].type==="definition"&&(i=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",i?(e.splice(a,0,["enter",o,t]),e.splice(i+1,0,["exit",e[r][1],t]),e[r][1].end={...e[i][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function G9e(e,t,n){const r=this;let a;return i;function i(u){let d=r.events.length,p;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){p=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||p)?(e.enter("setextHeadingLine"),a=u,o(u)):n(u)}function o(u){return e.enter("setextHeadingLineSequence"),s(u)}function s(u){return u===a?(e.consume(u),s):(e.exit("setextHeadingLineSequence"),Oe(u)?Te(e,l,"lineSuffix")(u):l(u))}function l(u){return u===null||he(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const W9e={tokenize:K9e};function K9e(e){const t=this,n=e.attempt(La,r,e.attempt(this.parser.constructs.flowInitial,a,Te(e,e.attempt(this.parser.constructs.flow,a,e.attempt(Jwe,a)),"linePrefix")));return n;function r(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Y9e={resolveAll:_v()},Z9e=vv("string"),X9e=vv("text");function vv(e){return{resolveAll:_v(e==="text"?Q9e:void 0),tokenize:t};function t(n){const r=this,a=this.parser.constructs[e],i=n.attempt(a,o,s);return o;function o(d){return u(d)?i(d):s(d)}function s(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),l}function l(d){return u(d)?(n.exit("data"),i(d)):(n.consume(d),l)}function u(d){if(d===null)return!0;const p=a[d];let m=-1;if(p)for(;++m<p.length;){const h=p[m];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function _v(e){return t;function t(n,r){let a=-1,i;for(;++a<=n.length;)i===void 0?n[a]&&n[a][1].type==="data"&&(i=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==i+2&&(n[i][1].end=n[a-1][1].end,n.splice(i+2,a-i-2),a=i+2),i=void 0);return e?e(n,r):n}}function Q9e(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],a=t.sliceStream(r);let i=a.length,o=-1,s=0,l;for(;i--;){const u=a[i];if(typeof u=="string"){for(o=u.length;u.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(u===-2)l=!0,s++;else if(u!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){const u={type:n===e.length||l||s<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?o:r.start._bufferIndex+o,_index:r.start._index+i,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const J9e={42:Dt,43:Dt,45:Dt,48:Dt,49:Dt,50:Dt,51:Dt,52:Dt,53:Dt,54:Dt,55:Dt,56:Dt,57:Dt,62:hv},eEe={91:a9e},tEe={[-2]:is,[-1]:is,32:is},nEe={35:u9e,42:wi,45:[X2,wi],60:m9e,61:X2,95:wi,96:Y2,126:Y2},rEe={38:fv,92:mv},aEe={[-5]:os,[-4]:os,[-3]:os,33:I9e,38:fv,42:md,60:[Lwe,_9e],91:L9e,92:[l9e,mv],93:xp,95:md,96:Wwe},iEe={null:[md,Y9e]},oEe={null:[42,95]},sEe={null:[]},lEe=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:oEe,contentInitial:eEe,disable:sEe,document:J9e,flow:nEe,flowInitial:tEe,insideSpan:iEe,string:rEe,text:aEe},Symbol.toStringTag,{value:"Module"}));function cEe(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},i=[];let o=[],s=[];const l={attempt:$(N),check:$(w),consume:b,enter:v,exit:E,interrupt:$(w,{interrupt:!0})},u={code:null,containerState:{},defineSkip:f,events:[],now:g,parser:e,previous:null,sliceSerialize:m,sliceStream:h,write:p};let d=t.tokenize.call(u,l);return t.resolveAll&&i.push(t),u;function p(U){return o=Jt(o,U),x(),o[o.length-1]!==null?[]:(P(t,0),u.events=bo(i,u.events,u),u.events)}function m(U,Z){return dEe(h(U),Z)}function h(U){return uEe(o,U)}function g(){const{_bufferIndex:U,_index:Z,line:J,column:K,offset:R}=r;return{_bufferIndex:U,_index:Z,line:J,column:K,offset:R}}function f(U){a[U.line]=U.column,L()}function x(){let U;for(;r._index<o.length;){const Z=o[r._index];if(typeof Z=="string")for(U=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===U&&r._bufferIndex<Z.length;)_(Z.charCodeAt(r._bufferIndex));else _(Z)}}function _(U){d=d(U)}function b(U){he(U)?(r.line++,r.column=1,r.offset+=U===-3?2:1,L()):U!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=U}function v(U,Z){const J=Z||{};return J.type=U,J.start=g(),u.events.push(["enter",J,u]),s.push(J),J}function E(U){const Z=s.pop();return Z.end=g(),u.events.push(["exit",Z,u]),Z}function N(U,Z){P(U,Z.from)}function w(U,Z){Z.restore()}function $(U,Z){return J;function J(K,R,H){let j,D,V,A;return Array.isArray(K)?ee(K):"tokenize"in K?ee([K]):Y(K);function Y(ke){return Ce;function Ce(Fe){const tt=Fe!==null&&ke[Fe],Ve=Fe!==null&&ke.null,ae=[...Array.isArray(tt)?tt:tt?[tt]:[],...Array.isArray(Ve)?Ve:Ve?[Ve]:[]];return ee(ae)(Fe)}}function ee(ke){return j=ke,D=0,ke.length===0?H:O(ke[D])}function O(ke){return Ce;function Ce(Fe){return A=C(),V=ke,ke.partial||(u.currentConstruct=ke),ke.name&&u.parser.constructs.disable.null.includes(ke.name)?ge():ke.tokenize.call(Z?Object.assign(Object.create(u),Z):u,l,le,ge)(Fe)}}function le(ke){return U(V,A),R}function ge(ke){return A.restore(),++D<j.length?O(j[D]):H}}}function P(U,Z){U.resolveAll&&!i.includes(U)&&i.push(U),U.resolve&&Gt(u.events,Z,u.events.length-Z,U.resolve(u.events.slice(Z),u)),U.resolveTo&&(u.events=U.resolveTo(u.events,u))}function C(){const U=g(),Z=u.previous,J=u.currentConstruct,K=u.events.length,R=Array.from(s);return{from:K,restore:H};function H(){r=U,u.previous=Z,u.currentConstruct=J,u.events.length=K,s=R,L()}}function L(){r.line in a&&r.column<2&&(r.column=a[r.line],r.offset+=a[r.line]-1)}}function uEe(e,t){const n=t.start._index,r=t.start._bufferIndex,a=t.end._index,i=t.end._bufferIndex;let o;if(n===a)o=[e[n].slice(r,i)];else{if(o=e.slice(n,a),r>-1){const s=o[0];typeof s=="string"?o[0]=s.slice(r):o.shift()}i>0&&o.push(e[a].slice(0,i))}return o}function dEe(e,t){let n=-1;const r=[];let a;for(;++n<e.length;){const i=e[n];let o;if(typeof i=="string")o=i;else switch(i){case-5:{o="\r";break}case-4:{o=`
|
|
8298
8298
|
`;break}case-3:{o=`\r
|
|
8299
8299
|
`;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&a)continue;o=" ";break}default:o=String.fromCharCode(i)}a=i===-2,r.push(o)}return r.join("")}function pEe(e){const r={constructs:dv([lEe,...(e||{}).extensions||[]]),content:a(Nwe),defined:[],document:a(Twe),flow:a(W9e),lazy:{},string:a(Z9e),text:a(X9e)};return r;function a(i){return o;function o(s){return cEe(r,i,s)}}}function hEe(e){for(;!gv(e););return e}const Q2=/[\0\t\n\r]/g;function mEe(){let e=1,t="",n=!0,r;return a;function a(i,o,s){const l=[];let u,d,p,m,h;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(o||void 0).decode(i)),p=0,t="",n&&(i.charCodeAt(0)===65279&&p++,n=void 0);p<i.length;){if(Q2.lastIndex=p,u=Q2.exec(i),m=u&&u.index!==void 0?u.index:i.length,h=i.charCodeAt(m),!u){t=i.slice(p);break}if(h===10&&p===m&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),p<m&&(l.push(i.slice(p,m)),e+=m-p),h){case 0:{l.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,l.push(-2);e++<d;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}p=m+1}return s&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const fEe=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function gEe(e){return e.replace(fEe,yEe)}function yEe(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),i=a===120||a===88;return pv(n.slice(i?2:1),i?16:10)}return va(n)||e}const xv={}.hasOwnProperty;function bEe(e,t,n){return typeof t!="string"&&(n=t,t=void 0),kEe(n)(hEe(pEe(n).document().write(mEe()(e,t,!0))))}function kEe(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(Ze),autolinkProtocol:C,autolinkEmail:C,atxHeading:i(Ae),blockQuote:i(Ve),characterEscape:C,characterReference:C,codeFenced:i(ae),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:i(ae,o),codeText:i(Se,o),codeTextData:C,data:C,codeFlowValue:C,definition:i(Be),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:i(We),hardBreakEscape:i(ve),hardBreakTrailing:i(ve),htmlFlow:i(Ge,o),htmlFlowData:C,htmlText:i(Ge,o),htmlTextData:C,image:i(de),label:o,link:i(Ze),listItem:i(He),listItemValue:m,listOrdered:i(Ke,p),listUnordered:i(Ke),paragraph:i(ce),reference:O,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:i(Ae),strong:i(Me),thematicBreak:i(Pe)},exit:{atxHeading:l(),atxHeadingSequence:N,autolink:l(),autolinkEmail:tt,autolinkProtocol:Fe,blockQuote:l(),characterEscapeValue:L,characterReferenceMarkerHexadecimal:ge,characterReferenceMarkerNumeric:ge,characterReferenceValue:ke,characterReference:Ce,codeFenced:l(x),codeFencedFence:f,codeFencedFenceInfo:h,codeFencedFenceMeta:g,codeFlowValue:L,codeIndented:l(_),codeText:l(R),codeTextData:L,data:L,definition:l(),definitionDestinationString:E,definitionLabelString:b,definitionTitleString:v,emphasis:l(),hardBreakEscape:l(Z),hardBreakTrailing:l(Z),htmlFlow:l(J),htmlFlowData:L,htmlText:l(K),htmlTextData:L,image:l(j),label:V,labelText:D,lineEnding:U,link:l(H),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:le,resourceDestinationString:A,resourceTitleString:Y,resource:ee,setextHeading:l(P),setextHeadingLineSequence:$,setextHeadingText:w,strong:l(),thematicBreak:l()}};wv(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(q){let X={type:"root",children:[]};const ne={stack:[X],tokenStack:[],config:t,enter:s,exit:u,buffer:o,resume:d,data:n},pe=[];let Ee=-1;for(;++Ee<q.length;)if(q[Ee][1].type==="listOrdered"||q[Ee][1].type==="listUnordered")if(q[Ee][0]==="enter")pe.push(Ee);else{const Le=pe.pop();Ee=a(q,Le,Ee)}for(Ee=-1;++Ee<q.length;){const Le=t[q[Ee][0]];xv.call(Le,q[Ee][1].type)&&Le[q[Ee][1].type].call(Object.assign({sliceSerialize:q[Ee][2].sliceSerialize},ne),q[Ee][1])}if(ne.tokenStack.length>0){const Le=ne.tokenStack[ne.tokenStack.length-1];(Le[1]||J2).call(ne,void 0,Le[0])}for(X.position={start:Vn(q.length>0?q[0][1].start:{line:1,column:1,offset:0}),end:Vn(q.length>0?q[q.length-2][1].end:{line:1,column:1,offset:0})},Ee=-1;++Ee<t.transforms.length;)X=t.transforms[Ee](X)||X;return X}function a(q,X,ne){let pe=X-1,Ee=-1,Le=!1,ft,kt,Hn,jn;for(;++pe<=ne;){const mt=q[pe];switch(mt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{mt[0]==="enter"?Ee++:Ee--,jn=void 0;break}case"lineEndingBlank":{mt[0]==="enter"&&(ft&&!jn&&!Ee&&!Hn&&(Hn=pe),jn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:jn=void 0}if(!Ee&&mt[0]==="enter"&&mt[1].type==="listItemPrefix"||Ee===-1&&mt[0]==="exit"&&(mt[1].type==="listUnordered"||mt[1].type==="listOrdered")){if(ft){let Mt=pe;for(kt=void 0;Mt--;){const It=q[Mt];if(It[1].type==="lineEnding"||It[1].type==="lineEndingBlank"){if(It[0]==="exit")continue;kt&&(q[kt][1].type="lineEndingBlank",Le=!0),It[1].type="lineEnding",kt=Mt}else if(!(It[1].type==="linePrefix"||It[1].type==="blockQuotePrefix"||It[1].type==="blockQuotePrefixWhitespace"||It[1].type==="blockQuoteMarker"||It[1].type==="listItemIndent"))break}Hn&&(!kt||Hn<kt)&&(ft._spread=!0),ft.end=Object.assign({},kt?q[kt][1].start:mt[1].end),q.splice(kt||pe,0,["exit",ft,mt[2]]),pe++,ne++}if(mt[1].type==="listItemPrefix"){const Mt={type:"listItem",_spread:!1,start:Object.assign({},mt[1].start),end:void 0};ft=Mt,q.splice(pe,0,["enter",Mt,mt[2]]),pe++,ne++,Hn=void 0,jn=!0}}}return q[X][1]._spread=Le,ne}function i(q,X){return ne;function ne(pe){s.call(this,q(pe),pe),X&&X.call(this,pe)}}function o(){this.stack.push({type:"fragment",children:[]})}function s(q,X,ne){this.stack[this.stack.length-1].children.push(q),this.stack.push(q),this.tokenStack.push([X,ne||void 0]),q.position={start:Vn(X.start),end:void 0}}function l(q){return X;function X(ne){q&&q.call(this,ne),u.call(this,ne)}}function u(q,X){const ne=this.stack.pop(),pe=this.tokenStack.pop();if(pe)pe[0].type!==q.type&&(X?X.call(this,q,pe[0]):(pe[1]||J2).call(this,q,pe[0]));else throw new Error("Cannot close `"+q.type+"` ("+la({start:q.start,end:q.end})+"): it’s not open");ne.position.end=Vn(q.end)}function d(){return _p(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function m(q){if(this.data.expectingFirstListItemValue){const X=this.stack[this.stack.length-2];X.start=Number.parseInt(this.sliceSerialize(q),10),this.data.expectingFirstListItemValue=void 0}}function h(){const q=this.resume(),X=this.stack[this.stack.length-1];X.lang=q}function g(){const q=this.resume(),X=this.stack[this.stack.length-1];X.meta=q}function f(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function x(){const q=this.resume(),X=this.stack[this.stack.length-1];X.value=q.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function _(){const q=this.resume(),X=this.stack[this.stack.length-1];X.value=q.replace(/(\r?\n|\r)$/g,"")}function b(q){const X=this.resume(),ne=this.stack[this.stack.length-1];ne.label=X,ne.identifier=pn(this.sliceSerialize(q)).toLowerCase()}function v(){const q=this.resume(),X=this.stack[this.stack.length-1];X.title=q}function E(){const q=this.resume(),X=this.stack[this.stack.length-1];X.url=q}function N(q){const X=this.stack[this.stack.length-1];if(!X.depth){const ne=this.sliceSerialize(q).length;X.depth=ne}}function w(){this.data.setextHeadingSlurpLineEnding=!0}function $(q){const X=this.stack[this.stack.length-1];X.depth=this.sliceSerialize(q).codePointAt(0)===61?1:2}function P(){this.data.setextHeadingSlurpLineEnding=void 0}function C(q){const ne=this.stack[this.stack.length-1].children;let pe=ne[ne.length-1];(!pe||pe.type!=="text")&&(pe=be(),pe.position={start:Vn(q.start),end:void 0},ne.push(pe)),this.stack.push(pe)}function L(q){const X=this.stack.pop();X.value+=this.sliceSerialize(q),X.position.end=Vn(q.end)}function U(q){const X=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ne=X.children[X.children.length-1];ne.position.end=Vn(q.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(X.type)&&(C.call(this,q),L.call(this,q))}function Z(){this.data.atHardBreak=!0}function J(){const q=this.resume(),X=this.stack[this.stack.length-1];X.value=q}function K(){const q=this.resume(),X=this.stack[this.stack.length-1];X.value=q}function R(){const q=this.resume(),X=this.stack[this.stack.length-1];X.value=q}function H(){const q=this.stack[this.stack.length-1];if(this.data.inReference){const X=this.data.referenceType||"shortcut";q.type+="Reference",q.referenceType=X,delete q.url,delete q.title}else delete q.identifier,delete q.label;this.data.referenceType=void 0}function j(){const q=this.stack[this.stack.length-1];if(this.data.inReference){const X=this.data.referenceType||"shortcut";q.type+="Reference",q.referenceType=X,delete q.url,delete q.title}else delete q.identifier,delete q.label;this.data.referenceType=void 0}function D(q){const X=this.sliceSerialize(q),ne=this.stack[this.stack.length-2];ne.label=gEe(X),ne.identifier=pn(X).toLowerCase()}function V(){const q=this.stack[this.stack.length-1],X=this.resume(),ne=this.stack[this.stack.length-1];if(this.data.inReference=!0,ne.type==="link"){const pe=q.children;ne.children=pe}else ne.alt=X}function A(){const q=this.resume(),X=this.stack[this.stack.length-1];X.url=q}function Y(){const q=this.resume(),X=this.stack[this.stack.length-1];X.title=q}function ee(){this.data.inReference=void 0}function O(){this.data.referenceType="collapsed"}function le(q){const X=this.resume(),ne=this.stack[this.stack.length-1];ne.label=X,ne.identifier=pn(this.sliceSerialize(q)).toLowerCase(),this.data.referenceType="full"}function ge(q){this.data.characterReferenceType=q.type}function ke(q){const X=this.sliceSerialize(q),ne=this.data.characterReferenceType;let pe;ne?(pe=pv(X,ne==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):pe=va(X);const Ee=this.stack[this.stack.length-1];Ee.value+=pe}function Ce(q){const X=this.stack.pop();X.position.end=Vn(q.end)}function Fe(q){L.call(this,q);const X=this.stack[this.stack.length-1];X.url=this.sliceSerialize(q)}function tt(q){L.call(this,q);const X=this.stack[this.stack.length-1];X.url="mailto:"+this.sliceSerialize(q)}function Ve(){return{type:"blockquote",children:[]}}function ae(){return{type:"code",lang:null,meta:null,value:""}}function Se(){return{type:"inlineCode",value:""}}function Be(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function We(){return{type:"emphasis",children:[]}}function Ae(){return{type:"heading",depth:0,children:[]}}function ve(){return{type:"break"}}function Ge(){return{type:"html",value:""}}function de(){return{type:"image",title:null,url:"",alt:null}}function Ze(){return{type:"link",title:null,url:"",children:[]}}function Ke(q){return{type:"list",ordered:q.type==="listOrdered",start:null,spread:q._spread,children:[]}}function He(q){return{type:"listItem",spread:q._spread,checked:null,children:[]}}function ce(){return{type:"paragraph",children:[]}}function Me(){return{type:"strong",children:[]}}function be(){return{type:"text",value:""}}function Pe(){return{type:"thematicBreak"}}}function Vn(e){return{line:e.line,column:e.column,offset:e.offset}}function wv(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?wv(e,r):vEe(e,r)}}function vEe(e,t){let n;for(n in t)if(xv.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function J2(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+la({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+la({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+la({start:t.start,end:t.end})+") is still open")}function _Ee(e){const t=this;t.parser=n;function n(r){return bEe(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function xEe(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function wEe(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
@@ -8615,5 +8615,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
8615
8615
|
`).slice(0,100).map(n=>n.length)))<=DHe}function FHe(e){const t=e.split(`
|
|
8616
8616
|
`),n=t.length;return n>Yi?{truncated:t.slice(0,Yi).join(`
|
|
8617
8617
|
`),isTruncated:!0,totalLines:n}:e.length>Dd?{truncated:e.slice(0,Dd),isTruncated:!0,totalLines:n}:{truncated:e,isTruncated:!1,totalLines:n}}const PHe={margin:0,padding:"12px 16px",background:"var(--mp-agents-surface)",fontSize:"13px",lineHeight:"1.5",overflowX:"auto"},k7=G.memo(({code:e,lang:t,highlight:n,prismStyle:r})=>n?S.jsx(b7,{language:t,style:r,PreTag:zHe,customStyle:PHe,children:e}):S.jsx("pre",{className:"mp-agent-code-block-pre",children:S.jsx("code",{children:e})}));k7.displayName="CodeContent";const v7=G.memo(({lang:e="text",codeChildren:t,allowExecution:n=!1})=>{const{colorMode:r}=w3(),a=zd(t).replace(/\n$/,""),i=r==="light"?OHe:IHe,{truncated:o,isTruncated:s,totalLines:l}=G.useMemo(()=>FHe(a),[a]),[u,d]=G.useState(!1),p=G.useCallback(()=>d(g=>!g),[]),m=u?a:o,h=G.useMemo(()=>$He(m),[m]);return S.jsxs("div",{className:"mp-agent-code-block-wrapper",children:[S.jsxs("div",{className:"mp-agent-code-block-header",children:[S.jsx("span",{className:"mp-agent-code-block-language",children:e}),S.jsx(tp,{text:a})]}),S.jsx("div",{className:"mp-agent-code-block-body",children:S.jsx(k7,{code:m,lang:e,highlight:h,prismStyle:i})}),s&&S.jsx("button",{type:"button",className:"mp-agent-code-block-toggle",onClick:p,children:u?"Show less":`Show more (${l>Yi?`${l-Yi} more lines`:`${a.length-Dd} more chars`})`})]})});v7.displayName="CodeBlock";const qHe=e=>G.isValidElement(e)?e.key?.startsWith("code-")??!1:!1,BHe=G.memo(({className:e,children:t})=>{const n=/language-(\w+)/.exec(e??""),r=n&&n[1],a=r==="math",i=typeof t=="string"&&t.split(`
|
|
8618
|
-
`).length===1;if(a)return S.jsx(S.Fragment,{children:t});if(i||!n){const o=s=>{const l=window.getSelection();if(l){const u=document.createRange();u.selectNodeContents(s.currentTarget),l.removeAllRanges(),l.addRange(u)}};return S.jsx("code",{onDoubleClick:o,className:e||"mp-agent-inline-code",children:t})}return S.jsx(v7,{lang:r||void 0,codeChildren:t,allowExecution:!1})}),UHe=G.memo(({children:e,...t})=>{const r=(Array.isArray(e)?e:[e]).find(qHe);return r?S.jsx(S.Fragment,{children:r}):S.jsx("pre",{className:"mp-agent-markdown-pre",...t,children:e})}),HHe=G.memo(({children:e,...t})=>S.jsx("div",{className:"mp-agent-markdown-p",...t,children:e})),jHe=G.memo(({href:e,children:t,...n})=>{const r=e?.startsWith("http"),a=r?"_blank":void 0,i=r?"noopener noreferrer":void 0;return S.jsx("a",{href:e||void 0,target:a,rel:i,className:"mp-agent-markdown-link",...n,children:t})}),VHe=G.memo(({src:e,alt:t,title:n,className:r,style:a,...i})=>e?S.jsx("img",{src:e||void 0,alt:t,title:n,style:a,loading:"lazy",className:r||"mp-agent-markdown-img",...i}):null),GHe={code:BHe,pre:UHe,p:HHe,a:jHe,img:VHe},WHe=[uCe,WNe,iRe,[tCe,{singleDollarTextMath:!1}]],KHe=[zRe,[nLe,{detect:!0,ignoreMissing:!0}]],$o=G.memo(({text:e,className:t="mp-agent-message-markdown"})=>S.jsx(FMe,{className:t,remarkPlugins:WHe,rehypePlugins:KHe,components:GHe,children:e}));$o.displayName="MarkdownMessage";const _7=({content:e,role:t})=>{const n=t===exports.MessageRole.User,r=t===exports.MessageRole.Error,a=t===exports.MessageRole.Reasoning;return n?S.jsx("p",{style:{margin:0,whiteSpace:"pre-wrap"},children:e}):r?S.jsx("p",{style:{margin:0,whiteSpace:"pre-wrap"},children:e}):a?S.jsx("pre",{style:{margin:0,fontSize:"13px",opacity:.8},children:e}):S.jsx($o,{text:e})},x7=({text:e,isReasoning:t})=>t?null:S.jsx("div",{className:"mp-agent-message-actions",children:S.jsx(tp,{text:e})}),Rh=({message:e,showParticipantChrome:t=!1})=>{const n=e.role===exports.MessageRole.User,r=e.role===exports.MessageRole.Error,a=e.role===exports.MessageRole.Reasoning,i=!!e.content,o=(e.attachments?.length??0)>0,s=t&&!!(e.sender||e.agentName);return S.jsxs("div",{className:`mp-agent-message-wrapper ${n?"mp-agent-message-user":r?"mp-agent-message-error":"mp-agent-message-assistant"}`,children:[s&&S.jsx(hp,{message:e}),S.jsxs("div",{className:"mp-agent-message-content-wrapper",children:[s&&S.jsx(mp,{message:e}),S.jsxs("div",{className:`mp-agent-message-bubble ${n?"mp-agent-message-bubble-user":r?"mp-agent-message-bubble-error":"mp-agent-message-bubble-assistant"}`,children:[S.jsxs("div",{className:"mp-agent-message-text",children:[o&&S.jsx(S_e,{attachments:e.attachments??[]}),i&&S.jsx(_7,{content:e.content,role:e.role})]}),!n&&i&&S.jsx(x7,{text:e.content,isReasoning:a})]})]})]})},Fo=G.memo(({reasoning:e,isStreaming:t})=>{const[n,r]=G.useState(!t),a=G.useRef(null);if(G.useEffect(()=>{r(!t)},[t]),G.useEffect(()=>{if(n)return;const o=a.current;o&&(o.scrollTop=o.scrollHeight)},[e,n,a]),!e||!e.trim())return null;const i=o=>{o.preventDefault(),o.stopPropagation(),r(s=>!s)};return S.jsxs("div",{className:`mp-agent-reasoning-panel ${n?"mp-agent-reasoning-collapsed":""}`,children:[S.jsxs("div",{className:"mp-agent-reasoning-header",children:[S.jsx("span",{className:`mp-agent-reasoning-label ${t?"mp-agent-reasoning-label-streaming":""}`,children:"Thinking"}),S.jsx(nn,{icon:n?"ChevronDown":"ChevronUp",size:"sm",onClick:i})]}),!n&&S.jsx("div",{className:"mp-agent-reasoning-body",children:S.jsx("div",{className:"mp-agent-reasoning-content",ref:a,children:S.jsx($o,{text:e,className:"mp-agent-message-markdown mp-agent-reasoning-markdown"})})})]})});Fo.displayName="ReasoningPanel";const Ih=()=>S.jsxs("span",{className:"mp-agent-message-typing-bubble",children:[S.jsx("span",{className:"mp-agent-message-typing-dot"}),S.jsx("span",{className:"mp-agent-message-typing-dot"}),S.jsx("span",{className:"mp-agent-message-typing-dot"})]}),YHe=e=>{if(e.length<=1)return e;const t=new Map;for(const n of e)t.set(n.id,n);return Array.from(t.values())},ZHe=({message:e,contextKey:t,isStreaming:n,reasoningEnabled:r,showParticipantChrome:a})=>{const i=new Map((e.toolCalls??[]).map(s=>[s.id,s])),o=(e.parts??[]).findIndex(s=>s.type==="text"&&s.text.trim().length>0);return S.jsxs("div",{className:"mp-agent-message-group",children:[(e.parts??[]).map((s,l)=>{if(s.type==="reasoning")return!r||!s.text.trim()?null:S.jsx(Fo,{reasoning:s.text,isStreaming:n},l);if(s.type==="text")return s.text.trim()?S.jsx(Rh,{message:{...e,content:s.text,reasoning:void 0,toolCalls:[]},showParticipantChrome:a&&l===o},l):null;const u=i.get(s.toolCallId);return u?S.jsx("div",{className:"mp-agent-tool-calls",children:S.jsx(K3,{call:u,contextKey:t,messageId:e.id,chatId:e.chat})},l):null}),n&&(e.parts?.length??0)===0&&S.jsx(Ih,{})]})},XHe=({message:e,contextKey:t,isStreaming:n,showParticipantChrome:r=!1})=>{const i=$e().config.features?.reasoning!==!1;if(e.role===exports.MessageRole.Assistant&&(e.parts?.length??0)>0)return S.jsx(ZHe,{message:e,contextKey:t,isStreaming:n,reasoningEnabled:i,showParticipantChrome:r});const o=i&&e.role===exports.MessageRole.Assistant&&!!e.reasoning,s=e.role===exports.MessageRole.Assistant&&typeof e.content=="string"&&e.content.trim().length>0,l=!!(n&&!o&&!s),u=typeof e.content=="string"&&e.content.trim().length>0||(e.attachments?.length??0)>0,d=YHe(e.toolCalls??[]);return S.jsxs("div",{className:"mp-agent-message-group",children:[o&&S.jsx(Fo,{reasoning:e.reasoning,isStreaming:n}),l&&S.jsx(Ih,{}),u&&S.jsx(Rh,{message:e,showParticipantChrome:r}),!n&&d.length>0&&S.jsx("div",{className:"mp-agent-tool-calls",children:d.map(p=>S.jsx(K3,{call:p,contextKey:t,messageId:e.id,chatId:e.chat},p.id))})]})},Zi=G.memo(XHe),i5=[],QHe=120,JHe=e=>{const t=e.activeChatId;return t?e.chatState[t]?.messages??i5:i5},w7=({showParticipantChrome:e=!1})=>{const t=Wt(),n=fe(N=>N.contextKey),r=fe(N=>N.draftChatKey),a=fe(N=>N.activeChatId),i=fe(JHe),o=a??r,s=ap(a),l=fe(N=>ze(N,o).pendingAssistant?.content?.length),u=fe(N=>ze(N,o).pendingAssistant?.id),d=fe(N=>ze(N,o).status),p=d===pt.Sending||d===pt.Streaming,m=G.useRef(null),h=G.useRef(!0),g=G.useRef(!1),f=G.useRef(!1),x=G.useRef(null),_=txe({count:i.length,getScrollElement:()=>m.current,estimateSize:()=>QHe,overscan:8,gap:16,getItemKey:N=>i[N]?.id??N}),b=_.getVirtualItems(),v=G.useCallback(()=>{const N=m.current;N&&(N.scrollTop=N.scrollHeight)},[]);G.useEffect(()=>{if(i.length!==0){if(!g.current){g.current=!0,f.current=!0,_.scrollToIndex(i.length-1,{align:"end"}),requestAnimationFrame(()=>{v(),requestAnimationFrame(()=>{v(),f.current=!1})});return}h.current&&requestAnimationFrame(v)}},[i.length,_,v]),G.useLayoutEffect(()=>{const N=x.current,w=m.current;!N||!w||s.isFetchingNextPage||i.length<=N.count||(f.current=!0,N.wasAtBottom?w.scrollTop=w.scrollHeight:w.scrollTop=N.scrollTop+(w.scrollHeight-N.scrollHeight),x.current=null,requestAnimationFrame(()=>{f.current=!1}))},[i.length,s.isFetchingNextPage]),G.useEffect(()=>{p&&h.current&&v()},[l,p,v]),G.useEffect(()=>{const N=m.current;if(!N)return;const w=()=>{if(f.current)return;const{scrollTop:$,scrollHeight:P,clientHeight:C}=N;h.current=P-$-C<150};return N.addEventListener("scroll",w,{passive:!0}),()=>N.removeEventListener("scroll",w)},[]);const E=b[0]?.index??Number.POSITIVE_INFINITY;return G.useEffect(()=>{if(!s.hasNextPage||s.isFetchingNextPage||E>1)return;const N=m.current;N&&(x.current={scrollHeight:N.scrollHeight,scrollTop:N.scrollTop,count:i.length,wasAtBottom:h.current}),s.fetchNextPage()},[E,s.hasNextPage,s.isFetchingNextPage,s.fetchNextPage,i.length]),!a&&i.length===0&&!u?S.jsx("div",{className:"mp-agent-messages-empty",children:S.jsxs("div",{className:"mp-agent-messages-empty-content",children:[S.jsx("h4",{children:t.helloThere}),S.jsx("p",{children:t.howCanIHelpYou})]})}):a&&i.length===0&&s.isLoading?S.jsx("div",{className:"mp-agent-messages-empty",children:S.jsx("div",{className:"mp-agent-messages-empty-content",children:S.jsx("p",{children:t.fetchingChats})})}):S.jsxs("div",{className:"mp-agent-messages",ref:m,children:[s.isFetchingNextPage&&S.jsx("div",{className:"mp-agent-messages-load-more",children:S.jsx("div",{className:"mp-agent-messages-load-more-text",children:t.fetchingChats})}),S.jsx("div",{className:"mp-agent-messages-virtual-list",style:{height:_.getTotalSize()},children:b.map(N=>{const w=i[N.index];return w?S.jsx("div",{ref:_.measureElement,"data-index":N.index,className:"mp-agent-messages-virtual-item",style:{transform:`translateY(${N.start}px)`},children:S.jsx(Zi,{message:w,contextKey:n,showParticipantChrome:e})},N.key):null})}),!!u&&S.jsx(eje,{pendingKey:o,contextKey:n,showParticipantChrome:e}),S.jsx(G3,{})]})},eje=G.memo(({pendingKey:e,contextKey:t,showParticipantChrome:n})=>{const r=fe(s=>ze(s,e)),a=r.pendingAssistant,i=r.status;if(!a)return null;const o=i===pt.Sending||i===pt.Streaming;return S.jsx(Zi,{message:a,contextKey:t,isStreaming:o,showParticipantChrome:n},a.id)}),E7=({onClose:e,agentLogo:t})=>{const n=Wt(),a=$e().config.features?.historySidebar!==!1,i=fe(u=>u.isChatHistoryOpen),o=fe(u=>u.setChatHistoryOpen),s=fe(u=>u.setActiveChat),l=()=>{s(void 0)};return S.jsxs("div",{className:"mp-agent-agent-controls",children:[S.jsxs("div",{className:"mp-agent-agent-controls-left",children:[a&&S.jsx(nn,{onClick:()=>o(!i),icon:i?"PanelLeftClose":"PanelLeftOpen",tooltip:i?n.hideChatHistory:n.showChatHistory,"aria-label":i?n.hideChatHistory:n.showChatHistory}),S.jsx(nn,{onClick:l,icon:"SquarePen","aria-label":n.newChat,tooltip:n.newChat})]}),t&&S.jsx("div",{className:"mp-agent-agent-controls-logo",children:t}),n.panelTitle&&S.jsx("div",{className:"mp-agent-agent-controls-title",children:S.jsx("h4",{children:n.panelTitle})}),e&&S.jsx("div",{className:"mp-agent-agent-controls-right",children:S.jsx(nn,{onClick:e,icon:"X","aria-label":n.close,tooltip:n.close})})]})},M7=({fetchNextPage:e,hasNextPage:t,isFetchingNextPage:n,itemRenderer:r}={})=>{const a=Wt(),{deleteChat:i,isDeleting:o}=ip(),s=fe(h=>h.chats),l=fe(h=>h.activeChatId),u=fe(h=>h.setActiveChat),d=G.useRef(null),p=G.useRef(null),m=G.useMemo(()=>Object.values(s).filter(h=>h.sessionKind!==exports.AgentSessionKind.SUBAGENT).sort((h,g)=>h.updatedAt===g.updatedAt?0:h.updatedAt<g.updatedAt?1:-1),[s]);return G.useEffect(()=>{const h=d.current,g=p.current;if(!h||!g||!e||!t)return;const f=new IntersectionObserver(x=>{x[0]?.isIntersecting&&t&&!n&&e()},{root:h,rootMargin:"100px",threshold:0});return f.observe(g),()=>f.disconnect()},[e,t,n]),S.jsxs("section",{className:"mp-agent-chat-history",children:[S.jsx("h4",{children:a.chats}),m.length===0?S.jsx("div",{className:"mp-agent-chat-history-empty",children:a.noChatsYet}):S.jsxs("ul",{ref:d,className:"mp-agent-chat-history-list",children:[m.map(h=>{const g=h.id===l;return r?S.jsx("li",{onClick:()=>u(h.id),className:`mp-agent-chat-history-item${g?" active":""}`,children:r(h)},h.id):S.jsxs("li",{onClick:()=>u(h.id),className:`mp-agent-chat-history-item${g?" active":""}`,children:[S.jsxs("div",{className:"mp-agent-chat-history-item-content",children:[S.jsx("span",{className:"mp-agent-chat-history-item-title",children:h.title||a.untitledChat}),S.jsx("span",{className:"mp-agent-chat-history-item-meta",children:new Date(h.updatedAt).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),S.jsx("div",{className:"mp-agent-chat-history-item-actions",children:S.jsx(bn,{content:a.deleteChat,children:S.jsx(nn,{size:"sm",icon:"Archive","aria-label":a.deleteChat,disabled:o(h.id),onClick:f=>{f.stopPropagation(),i(h.id)}})})})]},h.id)}),t&&S.jsxs("li",{className:"mp-agent-chat-history-sentinel","aria-hidden":!0,children:[S.jsx("div",{ref:p,className:"mp-agent-chat-history-sentinel-inner"}),n&&S.jsx("div",{className:"mp-agent-chat-history-loading",children:a.fetchingChats})]})]})]})},S7=({loadChats:e=!0,multiUser:t=!1})=>{const n=$e(),r=fe(o=>o.isChatHistoryOpen),a=n.config.features?.historySidebar!==!1,i=rp({enabled:e&&a,multiUser:t});return!a||!r?null:S.jsx("div",{className:"mp-agent-chat-history-panel",children:S.jsx(M7,{fetchNextPage:i.fetchNextPage,hasNextPage:i.hasNextPage,isFetchingNextPage:i.isFetchingNextPage})})},tje=({children:e})=>{const t=fe(n=>n.isChatHistoryOpen);return S.jsx("section",{className:`mp-agent-main ${t?"with-chat-history":""}`,children:e})},N7=({onToolSelected:e,onClose:t,agentLogo:n,multiUser:r=!1,participantIds:a,loadChats:i=!0,restoreLastActiveChat:o=!0})=>{const s=Wt(),l=$e(),u=fe(g=>g.activeChatId),d=fe(g=>g.setActiveChat),{isLoading:p}=m3(),{isLoading:m,error:h}=rp({enabled:i,multiUser:r});return G.useLayoutEffect(()=>{if(!o)return;const g=l.config.user?.id??Hr(),f=_7e(g);f&&d(f)},[o,l.config.user?.id,d]),S.jsxs("div",{className:"mp-agent-shell mp-agent-shell-panel",children:[S.jsx(S7,{loadChats:i,multiUser:r}),S.jsxs(tje,{children:[S.jsx(E7,{onClose:t,agentLogo:n}),S.jsx("div",{className:"mp-agent-main-content",children:m||p?S.jsx("div",{style:{padding:24},children:s.fetchingChats}):h?S.jsx("div",{style:{padding:24,color:"var(--mp-agents-danger)"},children:s.fetchingChatError}):S.jsx(w7,{showParticipantChrome:r},u)}),S.jsx(j3,{onToolSelected:e,multiUser:r,participantIds:a})]})]})},nje=e=>S.jsx(N7,{...e,multiUser:!0}),rje=({enabled:e=!0,className:t,pageSize:n=uo,showDelete:r=!0,onChatSelect:a})=>{const i=Wt(),o=bt.useQueryClient(),{deleteChat:s,isDeleting:l}=ip(),u=fe(v=>v.upsertChat),d=fe(v=>v.activeChatId),p=fe(v=>v.setActiveChat),m=np({enabled:e,multiUser:!0,pageSize:n}),h=G.useMemo(()=>i3(m.data).filter(v=>v.sessionKind!==exports.AgentSessionKind.SUBAGENT),[m.data]),g=G.useRef(null),f=G.useRef(null);G.useEffect(()=>{const v=g.current,E=f.current,{fetchNextPage:N,hasNextPage:w,isFetchingNextPage:$}=m;if(!v||!E||!N||!w)return;const P=new IntersectionObserver(C=>{C[0]?.isIntersecting&&w&&!$&&N()},{root:v,rootMargin:"100px",threshold:0});return P.observe(E),()=>P.disconnect()},[m,m.fetchNextPage,m.hasNextPage,m.isFetchingNextPage]);const x=v=>{u(v),p(v.id),a?.(v)},_=async(v,E)=>{v.stopPropagation(),await s(E),o.invalidateQueries({queryKey:In.all})},b=["mp-agent-chat-history","mp-agent-multiuser-chat-list",t].filter(Boolean).join(" ");return m.isError?S.jsxs("section",{className:b,children:[S.jsx("h4",{children:i.multiUserChats}),S.jsx("div",{className:"mp-agent-chat-history-empty",role:"alert",children:i.fetchingChatError})]}):m.isLoading?S.jsxs("section",{className:b,children:[S.jsx("h4",{children:i.multiUserChats}),S.jsx("div",{className:"mp-agent-chat-history-empty",children:i.fetchingChats})]}):S.jsxs("section",{className:b,children:[S.jsx("h4",{children:i.multiUserChats}),h.length===0?S.jsx("div",{className:"mp-agent-chat-history-empty",children:i.noMultiUserChats}):S.jsxs("ul",{ref:g,className:"mp-agent-chat-history-list",children:[h.map(v=>{const E=v.id===d,N=v.participantIds?.length??0;return S.jsxs("li",{onClick:()=>x(v),className:`mp-agent-chat-history-item${E?" active":""}`,children:[S.jsxs("div",{className:"mp-agent-chat-history-item-content",children:[S.jsx("span",{className:"mp-agent-chat-history-item-title",children:v.title||i.untitledChat}),S.jsxs("span",{className:"mp-agent-chat-history-item-meta",children:[N>0?`${N} · `:"",new Date(v.updatedAt).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})]})]}),r?S.jsx("div",{className:"mp-agent-chat-history-item-actions",children:S.jsx(bn,{content:i.deleteChat,children:S.jsx(nn,{size:"sm",icon:"Archive","aria-label":i.deleteChat,disabled:l(v.id),onClick:w=>void _(w,v.id)})})}):null]},v.id)}),m.hasNextPage?S.jsxs("li",{className:"mp-agent-chat-history-sentinel","aria-hidden":!0,children:[S.jsx("div",{ref:f,className:"mp-agent-chat-history-sentinel-inner"}),m.isFetchingNextPage?S.jsx("div",{className:"mp-agent-chat-history-loading",children:i.fetchingChats}):null]}):null]})]})},A7=G.forwardRef(({attachment:e,context:t,onAdded:n,onClick:r,...a},i)=>{const{addAttachments:o}=c3(),s=l=>{if(r?.(l),l.defaultPrevented)return;const d=(typeof e=="function"?e():e)??(()=>{const p=typeof t=="function"?t():t;return p?po(p):void 0})();d&&(o([d]),n?.(d))};return S.jsx("button",{ref:i,type:"button",...a,onClick:s})});A7.displayName="AttachContextButton";exports.AgentAttachmentSchema=m5;exports.AgentControls=E7;exports.AgentPreferencesPanel=H3;exports.AgentProvider=b_e;exports.AgentRuntime=k3;exports.AgentThemeProvider=x3;exports.AttachContextButton=A7;exports.BuiltinContextAttachmentKinds=p5;exports.CHATS_PAGE_SIZE=uo;exports.ChatHistory=M7;exports.ChatHistoryPanel=S7;exports.ChatWindow=N7;exports.Composer=j3;exports.ContextAttachmentMetadataSchemaV1=h5;exports.DEFAULT_MESSAGES_PAGE_SIZE=f3;exports.FormApplyRequestedEventType=Bd;exports.FormProposalToolRenderer=g3;exports.HttpError=Ku;exports.MarkdownMessage=$o;exports.MessageActions=x7;exports.MessageAvatar=hp;exports.MessageBubble=Rh;exports.MessageContent=_7;exports.MessageHeader=mp;exports.MessageList=w7;exports.MessageTypingAnimation=Ih;exports.MultiUserChatList=rje;exports.MultiUserChatWindow=nje;exports.ReasoningPanel=Fo;exports.SendMessagePayloadSchema=P7;exports.SocketIOConfig=Ti;exports.SocketIOEvents=gi;exports.activityKeys=Ht;exports.captureTextSelectionTarget=b3;exports.chatKeys=In;exports.contextKeySchema=d5;exports.createContextAttachment=po;exports.createPageContextAttachment=y3;exports.defaultTranslations=Ai;exports.flattenInfiniteActivities=e7e;exports.flattenInfiniteChats=i3;exports.frontendConfigSchema=Yu;exports.themeTokenSchema=u5;exports.translationsSchema=C7;exports.useActivitiesInfiniteList=t7e;exports.useActivitiesList=n7e;exports.useActivity=r7e;exports.useActivitySourceTypes=i7e;exports.useActivitySummary=a7e;exports.useAgentConfigurations=u3;exports.useAgentPreferences=h3;exports.useAgentRuntime=$e;exports.useAgentStore=fe;exports.useAgentTheme=w3;exports.useAutoScroll=s7e;exports.useChatBootstrap=rp;exports.useChats=o3;exports.useChatsInfiniteList=np;exports.useChatsList=o7e;exports.useComposerDraft=c3;exports.useDeleteChat=ip;exports.useEnsureActiveChat=m3;exports.useMessagesInfinite=ap;exports.useModels=s3;exports.usePageContext=c7e;exports.useProposeFormValues=u7e;exports.useRuntimeEventEmitter=d3;exports.useRuntimeEventListener=p3;exports.useTranslations=Wt;
|
|
8618
|
+
`).length===1;if(a)return S.jsx(S.Fragment,{children:t});if(i||!n){const o=s=>{const l=window.getSelection();if(l){const u=document.createRange();u.selectNodeContents(s.currentTarget),l.removeAllRanges(),l.addRange(u)}};return S.jsx("code",{onDoubleClick:o,className:e||"mp-agent-inline-code",children:t})}return S.jsx(v7,{lang:r||void 0,codeChildren:t,allowExecution:!1})}),UHe=G.memo(({children:e,...t})=>{const r=(Array.isArray(e)?e:[e]).find(qHe);return r?S.jsx(S.Fragment,{children:r}):S.jsx("pre",{className:"mp-agent-markdown-pre",...t,children:e})}),HHe=G.memo(({children:e,...t})=>S.jsx("div",{className:"mp-agent-markdown-p",...t,children:e})),jHe=G.memo(({href:e,children:t,...n})=>{const r=e?.startsWith("http"),a=r?"_blank":void 0,i=r?"noopener noreferrer":void 0;return S.jsx("a",{href:e||void 0,target:a,rel:i,className:"mp-agent-markdown-link",...n,children:t})}),VHe=G.memo(({src:e,alt:t,title:n,className:r,style:a,...i})=>e?S.jsx("img",{src:e||void 0,alt:t,title:n,style:a,loading:"lazy",className:r||"mp-agent-markdown-img",...i}):null),GHe={code:BHe,pre:UHe,p:HHe,a:jHe,img:VHe},WHe=[uCe,WNe,iRe,[tCe,{singleDollarTextMath:!1}]],KHe=[zRe,[nLe,{detect:!0,ignoreMissing:!0}]],$o=G.memo(({text:e,className:t="mp-agent-message-markdown"})=>S.jsx(FMe,{className:t,remarkPlugins:WHe,rehypePlugins:KHe,components:GHe,children:e}));$o.displayName="MarkdownMessage";const _7=({content:e,role:t})=>{const n=t===exports.MessageRole.User,r=t===exports.MessageRole.Error,a=t===exports.MessageRole.Reasoning;return n?S.jsx("p",{style:{margin:0,whiteSpace:"pre-wrap"},children:e}):r?S.jsx("p",{style:{margin:0,whiteSpace:"pre-wrap"},children:e}):a?S.jsx("pre",{style:{margin:0,fontSize:"13px",opacity:.8},children:e}):S.jsx($o,{text:e})},x7=({text:e,isReasoning:t})=>t?null:S.jsx("div",{className:"mp-agent-message-actions",children:S.jsx(tp,{text:e})}),Rh=({message:e,showParticipantChrome:t=!1})=>{const n=e.role===exports.MessageRole.User,r=e.role===exports.MessageRole.Error,a=e.role===exports.MessageRole.Reasoning,i=!!e.content,o=(e.attachments?.length??0)>0,s=t&&!!(e.sender||e.agentName);return S.jsxs("div",{className:`mp-agent-message-wrapper ${n?"mp-agent-message-user":r?"mp-agent-message-error":"mp-agent-message-assistant"}`,children:[s&&S.jsx(hp,{message:e}),S.jsxs("div",{className:"mp-agent-message-content-wrapper",children:[s&&S.jsx(mp,{message:e}),S.jsxs("div",{className:`mp-agent-message-bubble ${n?"mp-agent-message-bubble-user":r?"mp-agent-message-bubble-error":"mp-agent-message-bubble-assistant"}`,children:[S.jsxs("div",{className:"mp-agent-message-text",children:[o&&S.jsx(S_e,{attachments:e.attachments??[]}),i&&S.jsx(_7,{content:e.content,role:e.role})]}),!n&&i&&S.jsx(x7,{text:e.content,isReasoning:a})]})]})]})},Fo=G.memo(({reasoning:e,isStreaming:t})=>{const[n,r]=G.useState(!0),a=G.useRef(null);if(G.useEffect(()=>{if(n)return;const o=a.current;o&&(o.scrollTop=o.scrollHeight)},[e,n,a]),!e||!e.trim())return null;const i=o=>{o.preventDefault(),o.stopPropagation(),r(s=>!s)};return S.jsxs("div",{className:`mp-agent-reasoning-panel ${n?"mp-agent-reasoning-collapsed":""}`,children:[S.jsxs("div",{className:"mp-agent-reasoning-header",children:[S.jsx("span",{className:`mp-agent-reasoning-label ${t?"mp-agent-reasoning-label-streaming":""}`,children:"Thinking"}),S.jsx(nn,{icon:n?"ChevronDown":"ChevronUp",size:"sm",onClick:i})]}),!n&&S.jsx("div",{className:"mp-agent-reasoning-body",children:S.jsx("div",{className:"mp-agent-reasoning-content",ref:a,children:S.jsx($o,{text:e,className:"mp-agent-message-markdown mp-agent-reasoning-markdown"})})})]})});Fo.displayName="ReasoningPanel";const Ih=()=>S.jsxs("span",{className:"mp-agent-message-typing-bubble",children:[S.jsx("span",{className:"mp-agent-message-typing-dot"}),S.jsx("span",{className:"mp-agent-message-typing-dot"}),S.jsx("span",{className:"mp-agent-message-typing-dot"})]}),YHe=e=>{if(e.length<=1)return e;const t=new Map;for(const n of e)t.set(n.id,n);return Array.from(t.values())},ZHe=({message:e,contextKey:t,isStreaming:n,reasoningEnabled:r,showParticipantChrome:a})=>{const i=new Map((e.toolCalls??[]).map(s=>[s.id,s])),o=(e.parts??[]).findIndex(s=>s.type==="text"&&s.text.trim().length>0);return S.jsxs("div",{className:"mp-agent-message-group",children:[(e.parts??[]).map((s,l)=>{if(s.type==="reasoning")return!r||!s.text.trim()?null:S.jsx(Fo,{reasoning:s.text,isStreaming:n},l);if(s.type==="text")return s.text.trim()?S.jsx(Rh,{message:{...e,content:s.text,reasoning:void 0,toolCalls:[]},showParticipantChrome:a&&l===o},l):null;const u=i.get(s.toolCallId);return u?S.jsx(K3,{call:u,contextKey:t,messageId:e.id,chatId:e.chat},l):null}),n&&(e.parts?.length??0)===0&&S.jsx(Ih,{})]})},XHe=({message:e,contextKey:t,isStreaming:n,showParticipantChrome:r=!1})=>{const i=$e().config.features?.reasoning!==!1;if(e.role===exports.MessageRole.Assistant&&(e.parts?.length??0)>0)return S.jsx(ZHe,{message:e,contextKey:t,isStreaming:n,reasoningEnabled:i,showParticipantChrome:r});const o=i&&e.role===exports.MessageRole.Assistant&&!!e.reasoning,s=e.role===exports.MessageRole.Assistant&&typeof e.content=="string"&&e.content.trim().length>0,l=!!(n&&!o&&!s),u=typeof e.content=="string"&&e.content.trim().length>0||(e.attachments?.length??0)>0,d=YHe(e.toolCalls??[]);return S.jsxs("div",{className:"mp-agent-message-group",children:[o&&S.jsx(Fo,{reasoning:e.reasoning,isStreaming:n}),l&&S.jsx(Ih,{}),u&&S.jsx(Rh,{message:e,showParticipantChrome:r}),!n&&d.length>0&&S.jsx("div",{className:"mp-agent-tool-calls",children:d.map(p=>S.jsx(K3,{call:p,contextKey:t,messageId:e.id,chatId:e.chat},p.id))})]})},Zi=G.memo(XHe),i5=[],QHe=120,JHe=e=>{const t=e.activeChatId;return t?e.chatState[t]?.messages??i5:i5},w7=({showParticipantChrome:e=!1})=>{const t=Wt(),n=fe(N=>N.contextKey),r=fe(N=>N.draftChatKey),a=fe(N=>N.activeChatId),i=fe(JHe),o=a??r,s=ap(a),l=fe(N=>ze(N,o).pendingAssistant?.content?.length),u=fe(N=>ze(N,o).pendingAssistant?.id),d=fe(N=>ze(N,o).status),p=d===pt.Sending||d===pt.Streaming,m=G.useRef(null),h=G.useRef(!0),g=G.useRef(!1),f=G.useRef(!1),x=G.useRef(null),_=txe({count:i.length,getScrollElement:()=>m.current,estimateSize:()=>QHe,overscan:8,gap:16,getItemKey:N=>i[N]?.id??N}),b=_.getVirtualItems(),v=G.useCallback(()=>{const N=m.current;N&&(N.scrollTop=N.scrollHeight)},[]);G.useEffect(()=>{if(i.length!==0){if(!g.current){g.current=!0,f.current=!0,_.scrollToIndex(i.length-1,{align:"end"}),requestAnimationFrame(()=>{v(),requestAnimationFrame(()=>{v(),f.current=!1})});return}h.current&&requestAnimationFrame(v)}},[i.length,_,v]),G.useLayoutEffect(()=>{const N=x.current,w=m.current;!N||!w||s.isFetchingNextPage||i.length<=N.count||(f.current=!0,N.wasAtBottom?w.scrollTop=w.scrollHeight:w.scrollTop=N.scrollTop+(w.scrollHeight-N.scrollHeight),x.current=null,requestAnimationFrame(()=>{f.current=!1}))},[i.length,s.isFetchingNextPage]),G.useEffect(()=>{p&&h.current&&v()},[l,p,v]),G.useEffect(()=>{const N=m.current;if(!N)return;const w=()=>{if(f.current)return;const{scrollTop:$,scrollHeight:P,clientHeight:C}=N;h.current=P-$-C<150};return N.addEventListener("scroll",w,{passive:!0}),()=>N.removeEventListener("scroll",w)},[]);const E=b[0]?.index??Number.POSITIVE_INFINITY;return G.useEffect(()=>{if(!s.hasNextPage||s.isFetchingNextPage||E>1)return;const N=m.current;N&&(x.current={scrollHeight:N.scrollHeight,scrollTop:N.scrollTop,count:i.length,wasAtBottom:h.current}),s.fetchNextPage()},[E,s.hasNextPage,s.isFetchingNextPage,s.fetchNextPage,i.length]),!a&&i.length===0&&!u?S.jsx("div",{className:"mp-agent-messages-empty",children:S.jsxs("div",{className:"mp-agent-messages-empty-content",children:[S.jsx("h4",{children:t.helloThere}),S.jsx("p",{children:t.howCanIHelpYou})]})}):a&&i.length===0&&s.isLoading?S.jsx("div",{className:"mp-agent-messages-empty",children:S.jsx("div",{className:"mp-agent-messages-empty-content",children:S.jsx("p",{children:t.fetchingChats})})}):S.jsxs("div",{className:"mp-agent-messages",ref:m,children:[s.isFetchingNextPage&&S.jsx("div",{className:"mp-agent-messages-load-more",children:S.jsx("div",{className:"mp-agent-messages-load-more-text",children:t.fetchingChats})}),S.jsx("div",{className:"mp-agent-messages-virtual-list",style:{height:_.getTotalSize()},children:b.map(N=>{const w=i[N.index];return w?S.jsx("div",{ref:_.measureElement,"data-index":N.index,className:"mp-agent-messages-virtual-item",style:{transform:`translateY(${N.start}px)`},children:S.jsx(Zi,{message:w,contextKey:n,showParticipantChrome:e})},N.key):null})}),!!u&&S.jsx(eje,{pendingKey:o,contextKey:n,showParticipantChrome:e}),S.jsx(G3,{})]})},eje=G.memo(({pendingKey:e,contextKey:t,showParticipantChrome:n})=>{const r=fe(s=>ze(s,e)),a=r.pendingAssistant,i=r.status;if(!a)return null;const o=i===pt.Sending||i===pt.Streaming;return S.jsx(Zi,{message:a,contextKey:t,isStreaming:o,showParticipantChrome:n},a.id)}),E7=({onClose:e,agentLogo:t})=>{const n=Wt(),a=$e().config.features?.historySidebar!==!1,i=fe(u=>u.isChatHistoryOpen),o=fe(u=>u.setChatHistoryOpen),s=fe(u=>u.setActiveChat),l=()=>{s(void 0)};return S.jsxs("div",{className:"mp-agent-agent-controls",children:[S.jsxs("div",{className:"mp-agent-agent-controls-left",children:[a&&S.jsx(nn,{onClick:()=>o(!i),icon:i?"PanelLeftClose":"PanelLeftOpen",tooltip:i?n.hideChatHistory:n.showChatHistory,"aria-label":i?n.hideChatHistory:n.showChatHistory}),S.jsx(nn,{onClick:l,icon:"SquarePen","aria-label":n.newChat,tooltip:n.newChat})]}),t&&S.jsx("div",{className:"mp-agent-agent-controls-logo",children:t}),n.panelTitle&&S.jsx("div",{className:"mp-agent-agent-controls-title",children:S.jsx("h4",{children:n.panelTitle})}),e&&S.jsx("div",{className:"mp-agent-agent-controls-right",children:S.jsx(nn,{onClick:e,icon:"X","aria-label":n.close,tooltip:n.close})})]})},M7=({fetchNextPage:e,hasNextPage:t,isFetchingNextPage:n,itemRenderer:r}={})=>{const a=Wt(),{deleteChat:i,isDeleting:o}=ip(),s=fe(h=>h.chats),l=fe(h=>h.activeChatId),u=fe(h=>h.setActiveChat),d=G.useRef(null),p=G.useRef(null),m=G.useMemo(()=>Object.values(s).filter(h=>h.sessionKind!==exports.AgentSessionKind.SUBAGENT).sort((h,g)=>h.updatedAt===g.updatedAt?0:h.updatedAt<g.updatedAt?1:-1),[s]);return G.useEffect(()=>{const h=d.current,g=p.current;if(!h||!g||!e||!t)return;const f=new IntersectionObserver(x=>{x[0]?.isIntersecting&&t&&!n&&e()},{root:h,rootMargin:"100px",threshold:0});return f.observe(g),()=>f.disconnect()},[e,t,n]),S.jsxs("section",{className:"mp-agent-chat-history",children:[S.jsx("h4",{children:a.chats}),m.length===0?S.jsx("div",{className:"mp-agent-chat-history-empty",children:a.noChatsYet}):S.jsxs("ul",{ref:d,className:"mp-agent-chat-history-list",children:[m.map(h=>{const g=h.id===l;return r?S.jsx("li",{onClick:()=>u(h.id),className:`mp-agent-chat-history-item${g?" active":""}`,children:r(h)},h.id):S.jsxs("li",{onClick:()=>u(h.id),className:`mp-agent-chat-history-item${g?" active":""}`,children:[S.jsxs("div",{className:"mp-agent-chat-history-item-content",children:[S.jsx("span",{className:"mp-agent-chat-history-item-title",children:h.title||a.untitledChat}),S.jsx("span",{className:"mp-agent-chat-history-item-meta",children:new Date(h.updatedAt).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),S.jsx("div",{className:"mp-agent-chat-history-item-actions",children:S.jsx(bn,{content:a.deleteChat,children:S.jsx(nn,{size:"sm",icon:"Archive","aria-label":a.deleteChat,disabled:o(h.id),onClick:f=>{f.stopPropagation(),i(h.id)}})})})]},h.id)}),t&&S.jsxs("li",{className:"mp-agent-chat-history-sentinel","aria-hidden":!0,children:[S.jsx("div",{ref:p,className:"mp-agent-chat-history-sentinel-inner"}),n&&S.jsx("div",{className:"mp-agent-chat-history-loading",children:a.fetchingChats})]})]})]})},S7=({loadChats:e=!0,multiUser:t=!1})=>{const n=$e(),r=fe(o=>o.isChatHistoryOpen),a=n.config.features?.historySidebar!==!1,i=rp({enabled:e&&a,multiUser:t});return!a||!r?null:S.jsx("div",{className:"mp-agent-chat-history-panel",children:S.jsx(M7,{fetchNextPage:i.fetchNextPage,hasNextPage:i.hasNextPage,isFetchingNextPage:i.isFetchingNextPage})})},tje=({children:e})=>{const t=fe(n=>n.isChatHistoryOpen);return S.jsx("section",{className:`mp-agent-main ${t?"with-chat-history":""}`,children:e})},N7=({onToolSelected:e,onClose:t,agentLogo:n,multiUser:r=!1,participantIds:a,loadChats:i=!0,restoreLastActiveChat:o=!0})=>{const s=Wt(),l=$e(),u=fe(g=>g.activeChatId),d=fe(g=>g.setActiveChat),{isLoading:p}=m3(),{isLoading:m,error:h}=rp({enabled:i,multiUser:r});return G.useLayoutEffect(()=>{if(!o)return;const g=l.config.user?.id??Hr(),f=_7e(g);f&&d(f)},[o,l.config.user?.id,d]),S.jsxs("div",{className:"mp-agent-shell mp-agent-shell-panel",children:[S.jsx(S7,{loadChats:i,multiUser:r}),S.jsxs(tje,{children:[S.jsx(E7,{onClose:t,agentLogo:n}),S.jsx("div",{className:"mp-agent-main-content",children:m||p?S.jsx("div",{style:{padding:24},children:s.fetchingChats}):h?S.jsx("div",{style:{padding:24,color:"var(--mp-agents-danger)"},children:s.fetchingChatError}):S.jsx(w7,{showParticipantChrome:r},u)}),S.jsx(j3,{onToolSelected:e,multiUser:r,participantIds:a})]})]})},nje=e=>S.jsx(N7,{...e,multiUser:!0}),rje=({enabled:e=!0,className:t,pageSize:n=uo,showDelete:r=!0,onChatSelect:a})=>{const i=Wt(),o=bt.useQueryClient(),{deleteChat:s,isDeleting:l}=ip(),u=fe(v=>v.upsertChat),d=fe(v=>v.activeChatId),p=fe(v=>v.setActiveChat),m=np({enabled:e,multiUser:!0,pageSize:n}),h=G.useMemo(()=>i3(m.data).filter(v=>v.sessionKind!==exports.AgentSessionKind.SUBAGENT),[m.data]),g=G.useRef(null),f=G.useRef(null);G.useEffect(()=>{const v=g.current,E=f.current,{fetchNextPage:N,hasNextPage:w,isFetchingNextPage:$}=m;if(!v||!E||!N||!w)return;const P=new IntersectionObserver(C=>{C[0]?.isIntersecting&&w&&!$&&N()},{root:v,rootMargin:"100px",threshold:0});return P.observe(E),()=>P.disconnect()},[m,m.fetchNextPage,m.hasNextPage,m.isFetchingNextPage]);const x=v=>{u(v),p(v.id),a?.(v)},_=async(v,E)=>{v.stopPropagation(),await s(E),o.invalidateQueries({queryKey:In.all})},b=["mp-agent-chat-history","mp-agent-multiuser-chat-list",t].filter(Boolean).join(" ");return m.isError?S.jsxs("section",{className:b,children:[S.jsx("h4",{children:i.multiUserChats}),S.jsx("div",{className:"mp-agent-chat-history-empty",role:"alert",children:i.fetchingChatError})]}):m.isLoading?S.jsxs("section",{className:b,children:[S.jsx("h4",{children:i.multiUserChats}),S.jsx("div",{className:"mp-agent-chat-history-empty",children:i.fetchingChats})]}):S.jsxs("section",{className:b,children:[S.jsx("h4",{children:i.multiUserChats}),h.length===0?S.jsx("div",{className:"mp-agent-chat-history-empty",children:i.noMultiUserChats}):S.jsxs("ul",{ref:g,className:"mp-agent-chat-history-list",children:[h.map(v=>{const E=v.id===d,N=v.participantIds?.length??0;return S.jsxs("li",{onClick:()=>x(v),className:`mp-agent-chat-history-item${E?" active":""}`,children:[S.jsxs("div",{className:"mp-agent-chat-history-item-content",children:[S.jsx("span",{className:"mp-agent-chat-history-item-title",children:v.title||i.untitledChat}),S.jsxs("span",{className:"mp-agent-chat-history-item-meta",children:[N>0?`${N} · `:"",new Date(v.updatedAt).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})]})]}),r?S.jsx("div",{className:"mp-agent-chat-history-item-actions",children:S.jsx(bn,{content:i.deleteChat,children:S.jsx(nn,{size:"sm",icon:"Archive","aria-label":i.deleteChat,disabled:l(v.id),onClick:w=>void _(w,v.id)})})}):null]},v.id)}),m.hasNextPage?S.jsxs("li",{className:"mp-agent-chat-history-sentinel","aria-hidden":!0,children:[S.jsx("div",{ref:f,className:"mp-agent-chat-history-sentinel-inner"}),m.isFetchingNextPage?S.jsx("div",{className:"mp-agent-chat-history-loading",children:i.fetchingChats}):null]}):null]})]})},A7=G.forwardRef(({attachment:e,context:t,onAdded:n,onClick:r,...a},i)=>{const{addAttachments:o}=c3(),s=l=>{if(r?.(l),l.defaultPrevented)return;const d=(typeof e=="function"?e():e)??(()=>{const p=typeof t=="function"?t():t;return p?po(p):void 0})();d&&(o([d]),n?.(d))};return S.jsx("button",{ref:i,type:"button",...a,onClick:s})});A7.displayName="AttachContextButton";exports.AgentAttachmentSchema=m5;exports.AgentControls=E7;exports.AgentPreferencesPanel=H3;exports.AgentProvider=b_e;exports.AgentRuntime=k3;exports.AgentThemeProvider=x3;exports.AttachContextButton=A7;exports.BuiltinContextAttachmentKinds=p5;exports.CHATS_PAGE_SIZE=uo;exports.ChatHistory=M7;exports.ChatHistoryPanel=S7;exports.ChatWindow=N7;exports.Composer=j3;exports.ContextAttachmentMetadataSchemaV1=h5;exports.DEFAULT_MESSAGES_PAGE_SIZE=f3;exports.FormApplyRequestedEventType=Bd;exports.FormProposalToolRenderer=g3;exports.HttpError=Ku;exports.MarkdownMessage=$o;exports.MessageActions=x7;exports.MessageAvatar=hp;exports.MessageBubble=Rh;exports.MessageContent=_7;exports.MessageHeader=mp;exports.MessageList=w7;exports.MessageTypingAnimation=Ih;exports.MultiUserChatList=rje;exports.MultiUserChatWindow=nje;exports.ReasoningPanel=Fo;exports.SendMessagePayloadSchema=P7;exports.SocketIOConfig=Ti;exports.SocketIOEvents=gi;exports.activityKeys=Ht;exports.captureTextSelectionTarget=b3;exports.chatKeys=In;exports.contextKeySchema=d5;exports.createContextAttachment=po;exports.createPageContextAttachment=y3;exports.defaultTranslations=Ai;exports.flattenInfiniteActivities=e7e;exports.flattenInfiniteChats=i3;exports.frontendConfigSchema=Yu;exports.themeTokenSchema=u5;exports.translationsSchema=C7;exports.useActivitiesInfiniteList=t7e;exports.useActivitiesList=n7e;exports.useActivity=r7e;exports.useActivitySourceTypes=i7e;exports.useActivitySummary=a7e;exports.useAgentConfigurations=u3;exports.useAgentPreferences=h3;exports.useAgentRuntime=$e;exports.useAgentStore=fe;exports.useAgentTheme=w3;exports.useAutoScroll=s7e;exports.useChatBootstrap=rp;exports.useChats=o3;exports.useChatsInfiniteList=np;exports.useChatsList=o7e;exports.useComposerDraft=c3;exports.useDeleteChat=ip;exports.useEnsureActiveChat=m3;exports.useMessagesInfinite=ap;exports.useModels=s3;exports.usePageContext=c7e;exports.useProposeFormValues=u7e;exports.useRuntimeEventEmitter=d3;exports.useRuntimeEventListener=p3;exports.useTranslations=Wt;
|
|
8619
8619
|
//# sourceMappingURL=ai-agent-react.cjs.js.map
|