@multiplayer-app/ai-agent-react 0.1.0-beta.13 → 0.1.0-beta.14-test

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.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("zod"),ee=require("react"),io=require("@tanstack/react-query"),Gk=require("zustand"),Tt=require("nanoid"),k7=require("react-dom");function Wk(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const ne=Wk(ee),Kk=Wk(k7),Yk=H.z.object({background:H.z.string(),surface:H.z.string(),text:H.z.string(),subtext:H.z.string(),border:H.z.string(),accent:H.z.string(),accentSoft:H.z.string(),warning:H.z.string(),danger:H.z.string(),fontFamily:H.z.string(),radius:H.z.string(),fontSize:H.z.string()}),Zk=H.z.object({key:H.z.string(),label:H.z.string(),description:H.z.string().optional(),tools:H.z.array(H.z.string()).default([]),defaultModel:H.z.string().optional(),autoConfirmTools:H.z.array(H.z.string()).optional()}),td=H.z.object({appId:H.z.string(),workspaceId:H.z.string().optional(),user:H.z.object({id:H.z.string(),displayName:H.z.string().optional(),email:H.z.string().optional(),avatarUrl:H.z.string().optional()}).optional(),contextKeys:H.z.array(Zk),transport:H.z.union([H.z.object({mode:H.z.literal("proxy"),baseUrl:H.z.string(),apiKey:H.z.string().optional(),path:H.z.string().optional(),timeoutMs:H.z.number().optional(),headers:H.z.record(H.z.string()).optional()}),H.z.object({mode:H.z.literal("direct"),provider:H.z.enum(["openrouter","openai","custom"]),endpoint:H.z.string().optional(),apiKey:H.z.string().optional(),model:H.z.string().optional(),titleGenerationModel:H.z.string().optional(),timeoutMs:H.z.number().optional(),headers:H.z.record(H.z.string()).optional()})]),theme:Yk.partial().optional(),tools:H.z.array(H.z.object({name:H.z.string(),label:H.z.string(),description:H.z.string().optional(),icon:H.z.string().optional(),schema:H.z.record(H.z.any()).optional(),confirmation:H.z.enum(["auto","manual"]).optional(),category:H.z.string().optional()})).optional(),models:H.z.array(H.z.object({id:H.z.string(),label:H.z.string(),provider:H.z.string().optional(),reasoning:H.z.enum(["disabled","concise","deep"]).optional(),contexts:H.z.array(H.z.string()).optional()})).optional(),features:H.z.object({reasoning:H.z.boolean().optional(),artifactsPanel:H.z.boolean().optional(),modelSwitching:H.z.boolean().optional(),multiAgentControl:H.z.boolean().optional(),sandboxControls:H.z.boolean().optional(),historySidebar:H.z.boolean().optional(),titleGeneration:H.z.enum(["local","llm"]).optional(),pageContextAttachments:H.z.boolean().optional()}).optional(),pageContext:H.z.object({includeUserAgent:H.z.boolean().optional(),includeReferrer:H.z.boolean().optional(),includeViewport:H.z.boolean().optional(),includeTitle:H.z.boolean().optional(),name:H.z.string().optional()}).optional(),defaultContextKey:H.z.string().optional(),translations:H.z.object({newChat:H.z.string().optional(),followUp:H.z.string().optional(),sendMessage:H.z.string().optional(),stopStreaming:H.z.string().optional(),typeMessageToSend:H.z.string().optional(),attachFiles:H.z.string().optional(),attachSelectionToContext:H.z.string().optional(),attachments:H.z.string().optional(),chats:H.z.string().optional(),noChatsYet:H.z.string().optional(),untitledChat:H.z.string().optional(),deleteChat:H.z.string().optional(),showChatHistory:H.z.string().optional(),hideChatHistory:H.z.string().optional(),fetchingChats:H.z.string().optional(),fetchingChatError:H.z.string().optional(),helloThere:H.z.string().optional(),howCanIHelpYou:H.z.string().optional()}).optional()}),Fi={panelTitle:"",newChat:"New chat",followUp:"Follow up...",sendMessage:"Send message",stopStreaming:"Stop streaming",typeMessageToSend:"Type a message to send",attachFiles:"Attach files",attachSelectionToContext:"Attach selected text to context",attachments:"Attachments",chats:"Chats",noChatsYet:"No chats yet.",untitledChat:"Untitled chat",deleteChat:"Delete chat",showChatHistory:"Show chat history",hideChatHistory:"Hide chat history",close:"Close",fetchingChats:"Fetching chats…",fetchingChatError:"Fetching chats failed",helloThere:"Hello there!",howCanIHelpYou:"How can I help you today?"},v7={panelTitle:String,newChat:String,followUp:String,sendMessage:String,stopStreaming:String,typeMessageToSend:String,attachFiles:String,attachSelectionToContext:String,attachments:String,chats:String,noChatsYet:String,untitledChat:String,deleteChat:String,showChatHistory:String,hideChatHistory:String,fetchingChats:String,fetchingChatError:String,helloThere:String,howCanIHelpYou:String,close:String};var or=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function oo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var nd={exports:{}},oa={};/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("zod"),ee=require("react"),io=require("@tanstack/react-query"),Gk=require("zustand"),Tt=require("nanoid"),k7=require("react-dom");function Wk(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const ne=Wk(ee),Kk=Wk(k7),Yk=H.z.object({background:H.z.string(),surface:H.z.string(),text:H.z.string(),subtext:H.z.string(),border:H.z.string(),accent:H.z.string(),accentSoft:H.z.string(),warning:H.z.string(),danger:H.z.string(),fontFamily:H.z.string(),radius:H.z.string(),fontSize:H.z.string()}),Zk=H.z.object({key:H.z.string(),label:H.z.string(),description:H.z.string().optional(),tools:H.z.array(H.z.string()).default([]),defaultModel:H.z.string().optional(),autoConfirmTools:H.z.array(H.z.string()).optional()}),td=H.z.object({appId:H.z.string(),workspaceId:H.z.string().optional(),user:H.z.object({id:H.z.string(),displayName:H.z.string().optional(),email:H.z.string().optional(),avatarUrl:H.z.string().optional()}).optional(),contextKeys:H.z.array(Zk),transport:H.z.union([H.z.object({mode:H.z.literal("proxy"),baseUrl:H.z.string(),apiKey:H.z.string().optional(),socketPath:H.z.string().optional(),timeoutMs:H.z.number().optional(),headers:H.z.record(H.z.string()).optional()}),H.z.object({mode:H.z.literal("direct"),provider:H.z.enum(["openrouter","openai","custom"]),endpoint:H.z.string().optional(),apiKey:H.z.string().optional(),model:H.z.string().optional(),titleGenerationModel:H.z.string().optional(),timeoutMs:H.z.number().optional(),headers:H.z.record(H.z.string()).optional()})]),theme:Yk.partial().optional(),tools:H.z.array(H.z.object({name:H.z.string(),label:H.z.string(),description:H.z.string().optional(),icon:H.z.string().optional(),schema:H.z.record(H.z.any()).optional(),confirmation:H.z.enum(["auto","manual"]).optional(),category:H.z.string().optional()})).optional(),models:H.z.array(H.z.object({id:H.z.string(),label:H.z.string(),provider:H.z.string().optional(),reasoning:H.z.enum(["disabled","concise","deep"]).optional(),contexts:H.z.array(H.z.string()).optional()})).optional(),features:H.z.object({reasoning:H.z.boolean().optional(),artifactsPanel:H.z.boolean().optional(),modelSwitching:H.z.boolean().optional(),multiAgentControl:H.z.boolean().optional(),sandboxControls:H.z.boolean().optional(),historySidebar:H.z.boolean().optional(),titleGeneration:H.z.enum(["local","llm"]).optional(),pageContextAttachments:H.z.boolean().optional()}).optional(),pageContext:H.z.object({includeUserAgent:H.z.boolean().optional(),includeReferrer:H.z.boolean().optional(),includeViewport:H.z.boolean().optional(),includeTitle:H.z.boolean().optional(),name:H.z.string().optional()}).optional(),defaultContextKey:H.z.string().optional(),translations:H.z.object({newChat:H.z.string().optional(),followUp:H.z.string().optional(),sendMessage:H.z.string().optional(),stopStreaming:H.z.string().optional(),typeMessageToSend:H.z.string().optional(),attachFiles:H.z.string().optional(),attachSelectionToContext:H.z.string().optional(),attachments:H.z.string().optional(),chats:H.z.string().optional(),noChatsYet:H.z.string().optional(),untitledChat:H.z.string().optional(),deleteChat:H.z.string().optional(),showChatHistory:H.z.string().optional(),hideChatHistory:H.z.string().optional(),fetchingChats:H.z.string().optional(),fetchingChatError:H.z.string().optional(),helloThere:H.z.string().optional(),howCanIHelpYou:H.z.string().optional()}).optional()}),Fi={panelTitle:"",newChat:"New chat",followUp:"Follow up...",sendMessage:"Send message",stopStreaming:"Stop streaming",typeMessageToSend:"Type a message to send",attachFiles:"Attach files",attachSelectionToContext:"Attach selected text to context",attachments:"Attachments",chats:"Chats",noChatsYet:"No chats yet.",untitledChat:"Untitled chat",deleteChat:"Delete chat",showChatHistory:"Show chat history",hideChatHistory:"Hide chat history",close:"Close",fetchingChats:"Fetching chats…",fetchingChatError:"Fetching chats failed",helloThere:"Hello there!",howCanIHelpYou:"How can I help you today?"},v7={panelTitle:String,newChat:String,followUp:String,sendMessage:String,stopStreaming:String,typeMessageToSend:String,attachFiles:String,attachSelectionToContext:String,attachments:String,chats:String,noChatsYet:String,untitledChat:String,deleteChat:String,showChatHistory:String,hideChatHistory:String,fetchingChats:String,fetchingChatError:String,helloThere:String,howCanIHelpYou:String,close:String};var or=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function oo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var nd={exports:{}},oa={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -8319,7 +8319,7 @@ React keys must be passed directly to JSX without using spread:
8319
8319
  */var u6e=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],od=u6e.join(","),h5=typeof Element>"u",Ea=h5?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,ji=!h5&&Element.prototype.getRootNode?function(e){var t;return e==null||(t=e.getRootNode)===null||t===void 0?void 0:t.call(e)}:function(e){return e?.ownerDocument},Ma=function(t,n){var r;n===void 0&&(n=!0);var a=t==null||(r=t.getAttribute)===null||r===void 0?void 0:r.call(t,"inert"),i=a===""||a==="true",o=i||n&&t&&Ma(t.parentNode);return o},d6e=function(t){var n,r=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return r===""||r==="true"},p6e=function(t,n,r){if(Ma(t))return[];var a=Array.prototype.slice.apply(t.querySelectorAll(od));return n&&Ea.call(t,od)&&a.unshift(t),a=a.filter(r),a},sd=function(t,n,r){for(var a=[],i=Array.from(t);i.length;){var o=i.shift();if(!Ma(o,!1))if(o.tagName==="SLOT"){var s=o.assignedElements(),l=s.length?s:o.children,u=sd(l,!0,r);r.flatten?a.push.apply(a,u):a.push({scopeParent:o,candidates:u})}else{var d=Ea.call(o,od);d&&r.filter(o)&&(n||!t.includes(o))&&a.push(o);var p=o.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(o),m=!Ma(p,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(o));if(p&&m){var h=sd(p===!0?o.children:p.children,!0,r);r.flatten?a.push.apply(a,h):a.push({scopeParent:o,candidates:h})}else i.unshift.apply(i,o.children)}}return a},m5=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},f5=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||d6e(t))&&!m5(t)?0:t.tabIndex},h6e=function(t,n){var r=f5(t);return r<0&&n&&!m5(t)?0:r},m6e=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},g5=function(t){return t.tagName==="INPUT"},f6e=function(t){return g5(t)&&t.type==="hidden"},g6e=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(r){return r.tagName==="SUMMARY"});return n},y6e=function(t,n){for(var r=0;r<t.length;r++)if(t[r].checked&&t[r].form===n)return t[r]},b6e=function(t){if(!t.name)return!0;var n=t.form||ji(t),r=function(s){return n.querySelectorAll('input[type="radio"][name="'+s+'"]')},a;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")a=r(window.CSS.escape(t.name));else try{a=r(t.name)}catch(o){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",o.message),!1}var i=y6e(a,t.form);return!i||i===t},k6e=function(t){return g5(t)&&t.type==="radio"},v6e=function(t){return k6e(t)&&!b6e(t)},_6e=function(t){var n,r=t&&ji(t),a=(n=r)===null||n===void 0?void 0:n.host,i=!1;if(r&&r!==t){var o,s,l;for(i=!!((o=a)!==null&&o!==void 0&&(s=o.ownerDocument)!==null&&s!==void 0&&s.contains(a)||t!=null&&(l=t.ownerDocument)!==null&&l!==void 0&&l.contains(t));!i&&a;){var u,d,p;r=ji(a),a=(u=r)===null||u===void 0?void 0:u.host,i=!!((d=a)!==null&&d!==void 0&&(p=d.ownerDocument)!==null&&p!==void 0&&p.contains(a))}}return i},Dh=function(t){var n=t.getBoundingClientRect(),r=n.width,a=n.height;return r===0&&a===0},w6e=function(t,n){var r=n.displayCheck,a=n.getShadowRoot;if(r==="full-native"&&"checkVisibility"in t){var i=t.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!i}if(getComputedStyle(t).visibility==="hidden")return!0;var o=Ea.call(t,"details>summary:first-of-type"),s=o?t.parentElement:t;if(Ea.call(s,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="full-native"||r==="legacy-full"){if(typeof a=="function"){for(var l=t;t;){var u=t.parentElement,d=ji(t);if(u&&!u.shadowRoot&&a(u)===!0)return Dh(t);t.assignedSlot?t=t.assignedSlot:!u&&d!==t.ownerDocument?t=d.host:t=u}t=l}if(_6e(t))return!t.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return Dh(t);return!1},x6e=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var n=t.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r<n.children.length;r++){var a=n.children.item(r);if(a.tagName==="LEGEND")return Ea.call(n,"fieldset[disabled] *")?!0:!a.contains(t)}return!0}n=n.parentElement}return!1},E6e=function(t,n){return!(n.disabled||Ma(n)||f6e(n)||w6e(n,t)||g6e(n)||x6e(n))},zh=function(t,n){return!(v6e(n)||f5(n)<0||!E6e(t,n))},M6e=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},y5=function(t){var n=[],r=[];return t.forEach(function(a,i){var o=!!a.scopeParent,s=o?a.scopeParent:a,l=h6e(s,o),u=o?y5(a.candidates):s;l===0?o?n.push.apply(n,u):n.push(s):r.push({documentOrder:i,tabIndex:l,item:a,isScope:o,content:u})}),r.sort(m6e).reduce(function(a,i){return i.isScope?a.push.apply(a,i.content):a.push(i.content),a},[]).concat(n)},b5=function(t,n){n=n||{};var r;return n.getShadowRoot?r=sd([t],n.includeContainer,{filter:zh.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:M6e}):r=p6e(t,n.includeContainer,zh.bind(null,n)),y5(r)};function k5(){const e=navigator.userAgentData;return e!=null&&e.platform?e.platform:navigator.platform}function v5(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(t=>{let{brand:n,version:r}=t;return n+"/"+r}).join(" "):navigator.userAgent}function _5(){return/apple/i.test(navigator.vendor)}function ld(){const e=/android/i;return e.test(k5())||e.test(v5())}function S6e(){return k5().toLowerCase().startsWith("mac")&&!navigator.maxTouchPoints}function w5(){return v5().includes("jsdom/")}const $h="data-floating-ui-focusable",N6e="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",Ko="ArrowLeft",Yo="ArrowRight",A6e="ArrowUp",T6e="ArrowDown";function Sa(e){let t=e.activeElement;for(;((n=t)==null||(n=n.shadowRoot)==null?void 0:n.activeElement)!=null;){var n;t=t.shadowRoot.activeElement}return t}function xr(e,t){if(!e||!t)return!1;const n=t.getRootNode==null?void 0:t.getRootNode();if(e.contains(t))return!0;if(n&&rd(n)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function Pr(e){return"composedPath"in e?e.composedPath()[0]:e.target}function Zo(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return n.target!=null&&t.contains(n.target)}function C6e(e){return e.matches("html,body")}function yn(e){return e?.ownerDocument||document}function Kd(e){return Rt(e)&&e.matches(N6e)}function R6e(e){return e?e.getAttribute("role")==="combobox"&&Kd(e):!1}function I6e(e){if(!e||w5())return!0;try{return e.matches(":focus-visible")}catch{return!0}}function x5(e){return e?e.hasAttribute($h)?e:e.querySelector("["+$h+"]")||e:null}function ba(e,t,n){return n===void 0&&(n=!0),e.filter(a=>{var i;return a.parentId===t&&(!n||((i=a.context)==null?void 0:i.open))}).flatMap(a=>[a,...ba(e,a.id,n)])}function O6e(e,t){let n,r=-1;function a(i,o){o>r&&(n=i,r=o),ba(e,i).forEach(l=>{a(l.id,o+1)})}return a(t,0),e.find(i=>i.id===n)}function rn(e){e.preventDefault(),e.stopPropagation()}function L6e(e){return"nativeEvent"in e}function D6e(e){return e.mozInputSource===0&&e.isTrusted?!0:ld()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function z6e(e){return w5()?!1:!ld()&&e.width===0&&e.height===0||ld()&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function Na(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}var $6e=typeof document<"u",F6e=function(){},Nt=$6e?ee.useLayoutEffect:F6e;const P6e={...ne};function Pn(e){const t=ne.useRef(e);return Nt(()=>{t.current=e}),t}const B6e=P6e.useInsertionEffect,q6e=B6e||(e=>e());function Xt(e){const t=ne.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return q6e(()=>{t.current=e}),ne.useCallback(function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return t.current==null?void 0:t.current(...r)},[])}function Ja(e,t,n){return Math.floor(e/t)!==n}function ka(e,t){return t<0||t>=e.current.length}function Xo(e,t){return At(e,{disabledIndices:t})}function Fh(e,t){return At(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function At(e,t){let{startingIndex:n=-1,decrement:r=!1,disabledIndices:a,amount:i=1}=t===void 0?{}:t,o=n;do o+=r?-i:i;while(o>=0&&o<=e.current.length-1&&Ni(e,o,a));return o}function U6e(e,t){let{event:n,orientation:r,loop:a,rtl:i,cols:o,disabledIndices:s,minIndex:l,maxIndex:u,prevIndex:d,stopEvent:p=!1}=t,m=d;if(n.key===A6e){if(p&&rn(n),d===-1)m=u;else if(m=At(e,{startingIndex:m,amount:o,decrement:!0,disabledIndices:s}),a&&(d-o<l||m<0)){const h=d%o,g=u%o,y=u-(g-h);g===h?m=u:m=g>h?y:y-o}ka(e,m)&&(m=d)}if(n.key===T6e&&(p&&rn(n),d===-1?m=l:(m=At(e,{startingIndex:d,amount:o,disabledIndices:s}),a&&d+o>u&&(m=At(e,{startingIndex:d%o-o,amount:o,disabledIndices:s}))),ka(e,m)&&(m=d)),r==="both"){const h=Vr(d/o);n.key===(i?Ko:Yo)&&(p&&rn(n),d%o!==o-1?(m=At(e,{startingIndex:d,disabledIndices:s}),a&&Ja(m,o,h)&&(m=At(e,{startingIndex:d-d%o-1,disabledIndices:s}))):a&&(m=At(e,{startingIndex:d-d%o-1,disabledIndices:s})),Ja(m,o,h)&&(m=d)),n.key===(i?Yo:Ko)&&(p&&rn(n),d%o!==0?(m=At(e,{startingIndex:d,decrement:!0,disabledIndices:s}),a&&Ja(m,o,h)&&(m=At(e,{startingIndex:d+(o-d%o),decrement:!0,disabledIndices:s}))):a&&(m=At(e,{startingIndex:d+(o-d%o),decrement:!0,disabledIndices:s})),Ja(m,o,h)&&(m=d));const g=Vr(u/o)===h;ka(e,m)&&(a&&g?m=n.key===(i?Yo:Ko)?u:At(e,{startingIndex:d-d%o-1,disabledIndices:s}):m=d)}return m}function H6e(e,t,n){const r=[];let a=0;return e.forEach((i,o)=>{let{width:s,height:l}=i;if(s>t&&process.env.NODE_ENV!=="production")throw new Error("[Floating UI]: Invalid grid - item width at index "+o+" is greater than grid columns");let u=!1;for(n&&(a=0);!u;){const d=[];for(let p=0;p<s;p++)for(let m=0;m<l;m++)d.push(a+p+m*t);a%t+s<=t&&d.every(p=>r[p]==null)?(d.forEach(p=>{r[p]=o}),u=!0):a++}}),[...r]}function j6e(e,t,n,r,a){if(e===-1)return-1;const i=n.indexOf(e),o=t[e];switch(a){case"tl":return i;case"tr":return o?i+o.width-1:i;case"bl":return o?i+(o.height-1)*r:i;case"br":return n.lastIndexOf(e)}}function V6e(e,t){return t.flatMap((n,r)=>e.includes(n)?[r]:[])}function Ni(e,t,n){if(typeof n=="function")return n(t);if(n)return n.includes(t);const r=e.current[t];return r==null||r.hasAttribute("disabled")||r.getAttribute("aria-disabled")==="true"}const E5=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function M5(e,t){const n=b5(e,E5()),r=n.length;if(r===0)return;const a=Sa(yn(e)),i=n.indexOf(a),o=i===-1?t===1?0:r-1:i+t;return n[o]}function G6e(e){return M5(yn(e).body,1)||e}function W6e(e){return M5(yn(e).body,-1)||e}function Qo(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!xr(n,r)}function K6e(e){b5(e,E5()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function Ph(e){e.querySelectorAll("[data-tabindex]").forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}function Bh(e,t,n){let{reference:r,floating:a}=e;const i=er(t),o=p5(t),s=d5(o),l=wr(t),u=i==="y",d=r.x+r.width/2-a.width/2,p=r.y+r.height/2-a.height/2,m=r[s]/2-a[s]/2;let h;switch(l){case"top":h={x:d,y:r.y-a.height};break;case"bottom":h={x:d,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:p};break;case"left":h={x:r.x-a.width,y:p};break;default:h={x:r.x,y:r.y}}switch(fo(t)){case"start":h[o]-=m*(n&&u?-1:1);break;case"end":h[o]+=m*(n&&u?-1:1);break}return h}const Y6e=async(e,t,n)=>{const{placement:r="bottom",strategy:a="absolute",middleware:i=[],platform:o}=n,s=i.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(t));let u=await o.getElementRects({reference:e,floating:t,strategy:a}),{x:d,y:p}=Bh(u,r,l),m=r,h={},g=0;for(let y=0;y<s.length;y++){const{name:_,fn:v}=s[y],{x:k,y:w,data:M,reset:S}=await v({x:d,y:p,initialPlacement:r,placement:m,strategy:a,middlewareData:h,rects:u,platform:o,elements:{reference:e,floating:t}});d=k??d,p=w??p,h={...h,[_]:{...h[_],...M}},S&&g<=50&&(g++,typeof S=="object"&&(S.placement&&(m=S.placement),S.rects&&(u=S.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:a}):S.rects),{x:d,y:p}=Bh(u,m,l)),y=-1)}return{x:d,y:p,placement:m,strategy:a,middlewareData:h}};async function S5(e,t){var n;t===void 0&&(t={});const{x:r,y:a,platform:i,rects:o,elements:s,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:p="floating",altBoundary:m=!1,padding:h=0}=mo(t,e),g=c6e(h),_=s[m?p==="floating"?"reference":"floating":p],v=Hi(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(_)))==null||n?_:_.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(s.floating)),boundary:u,rootBoundary:d,strategy:l})),k=p==="floating"?{x:r,y:a,width:o.floating.width,height:o.floating.height}:o.reference,w=await(i.getOffsetParent==null?void 0:i.getOffsetParent(s.floating)),M=await(i.isElement==null?void 0:i.isElement(w))?await(i.getScale==null?void 0:i.getScale(w))||{x:1,y:1}:{x:1,y:1},S=Hi(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:k,offsetParent:w,strategy:l}):k);return{top:(v.top-S.top+g.top)/M.y,bottom:(S.bottom-v.bottom+g.bottom)/M.y,left:(v.left-S.left+g.left)/M.x,right:(S.right-v.right+g.right)/M.x}}const Z6e=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:a,middlewareData:i,rects:o,initialPlacement:s,platform:l,elements:u}=t,{mainAxis:d=!0,crossAxis:p=!0,fallbackPlacements:m,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:y=!0,..._}=mo(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const v=wr(a),k=er(s),w=wr(s)===s,M=await(l.isRTL==null?void 0:l.isRTL(u.floating)),S=m||(w||!y?[Ui(s)]:r6e(s)),E=g!=="none";!m&&E&&S.push(...s6e(s,y,g,M));const F=[s,...S],P=await S5(t,_),C=[];let D=((r=i.flip)==null?void 0:r.overflows)||[];if(d&&C.push(P[v]),p){const V=n6e(a,o,M);C.push(P[V[0]],P[V[1]])}if(D=[...D,{placement:a,overflows:C}],!C.every(V=>V<=0)){var W,K;const V=(((W=i.flip)==null?void 0:W.index)||0)+1,R=F[V];if(R&&(!(p==="alignment"?k!==er(R):!1)||D.every(T=>er(T.placement)===k?T.overflows[0]>0:!0)))return{data:{index:V,overflows:D},reset:{placement:R}};let q=(K=D.filter(G=>G.overflows[0]<=0).sort((G,T)=>G.overflows[1]-T.overflows[1])[0])==null?void 0:K.placement;if(!q)switch(h){case"bestFit":{var J;const G=(J=D.filter(T=>{if(E){const Y=er(T.placement);return Y===k||Y==="y"}return!0}).map(T=>[T.placement,T.overflows.filter(Y=>Y>0).reduce((Y,N)=>Y+N,0)]).sort((T,Y)=>T[1]-Y[1])[0])==null?void 0:J[0];G&&(q=G);break}case"initialPlacement":q=s;break}if(a!==q)return{reset:{placement:q}}}return{}}}},X6e=new Set(["left","top"]);async function Q6e(e,t){const{placement:n,platform:r,elements:a}=e,i=await(r.isRTL==null?void 0:r.isRTL(a.floating)),o=wr(n),s=fo(n),l=er(n)==="y",u=X6e.has(o)?-1:1,d=i&&l?-1:1,p=mo(t,e);let{mainAxis:m,crossAxis:h,alignmentAxis:g}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return s&&typeof g=="number"&&(h=s==="end"?g*-1:g),l?{x:h*d,y:m*u}:{x:m*u,y:h*d}}const J6e=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:a,y:i,placement:o,middlewareData:s}=t,l=await Q6e(t,e);return o===((n=s.offset)==null?void 0:n.placement)&&(r=s.arrow)!=null&&r.alignmentOffset?{}:{x:a+l.x,y:i+l.y,data:{...l,placement:o}}}}},e8e=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:a}=t,{mainAxis:i=!0,crossAxis:o=!1,limiter:s={fn:_=>{let{x:v,y:k}=_;return{x:v,y:k}}},...l}=mo(e,t),u={x:n,y:r},d=await S5(t,l),p=er(wr(a)),m=u5(p);let h=u[m],g=u[p];if(i){const _=m==="y"?"top":"left",v=m==="y"?"bottom":"right",k=h+d[_],w=h-d[v];h=Ih(k,h,w)}if(o){const _=p==="y"?"top":"left",v=p==="y"?"bottom":"right",k=g+d[_],w=g-d[v];g=Ih(k,g,w)}const y=s.fn({...t,[m]:h,[p]:g});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[m]:i,[p]:o}}}}}};function N5(e){const t=dn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const a=Rt(e),i=a?e.offsetWidth:n,o=a?e.offsetHeight:r,s=qi(n)!==i||qi(r)!==o;return s&&(n=i,r=o),{width:n,height:r,$:s}}function Yd(e){return ot(e)?e:e.contextElement}function Wr(e){const t=Yd(e);if(!Rt(t))return Nn(1);const n=t.getBoundingClientRect(),{width:r,height:a,$:i}=N5(t);let o=(i?qi(n.width):n.width)/r,s=(i?qi(n.height):n.height)/a;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}const t8e=Nn(0);function A5(e){const t=jt(e);return!po()||!t.visualViewport?t8e:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function n8e(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==jt(e)?!1:t}function Er(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const a=e.getBoundingClientRect(),i=Yd(e);let o=Nn(1);t&&(r?ot(r)&&(o=Wr(r)):o=Wr(e));const s=n8e(i,n,r)?A5(i):Nn(0);let l=(a.left+s.x)/o.x,u=(a.top+s.y)/o.y,d=a.width/o.x,p=a.height/o.y;if(i){const m=jt(i),h=r&&ot(r)?jt(r):r;let g=m,y=ad(g);for(;y&&r&&h!==g;){const _=Wr(y),v=y.getBoundingClientRect(),k=dn(y),w=v.left+(y.clientLeft+parseFloat(k.paddingLeft))*_.x,M=v.top+(y.clientTop+parseFloat(k.paddingTop))*_.y;l*=_.x,u*=_.y,d*=_.x,p*=_.y,l+=w,u+=M,g=jt(y),y=ad(g)}}return Hi({width:d,height:p,x:l,y:u})}function go(e,t){const n=ho(e).scrollLeft;return t?t.left+n:Er(Cn(e)).left+n}function T5(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-go(e,n),a=n.top+t.scrollTop;return{x:r,y:a}}function r8e(e){let{elements:t,rect:n,offsetParent:r,strategy:a}=e;const i=a==="fixed",o=Cn(r),s=t?uo(t.floating):!1;if(r===o||s&&i)return n;let l={scrollLeft:0,scrollTop:0},u=Nn(1);const d=Nn(0),p=Rt(r);if((p||!p&&!i)&&((Jr(r)!=="body"||Fa(o))&&(l=ho(r)),Rt(r))){const h=Er(r);u=Wr(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}const m=o&&!p&&!i?T5(o,l):Nn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+m.x,y:n.y*u.y-l.scrollTop*u.y+d.y+m.y}}function a8e(e){return Array.from(e.getClientRects())}function i8e(e){const t=Cn(e),n=ho(e),r=e.ownerDocument.body,a=vr(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=vr(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+go(e);const s=-n.scrollTop;return dn(r).direction==="rtl"&&(o+=vr(t.clientWidth,r.clientWidth)-a),{width:a,height:i,x:o,y:s}}const qh=25;function o8e(e,t){const n=jt(e),r=Cn(e),a=n.visualViewport;let i=r.clientWidth,o=r.clientHeight,s=0,l=0;if(a){i=a.width,o=a.height;const d=po();(!d||d&&t==="fixed")&&(s=a.offsetLeft,l=a.offsetTop)}const u=go(r);if(u<=0){const d=r.ownerDocument,p=d.body,m=getComputedStyle(p),h=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,g=Math.abs(r.clientWidth-p.clientWidth-h);g<=qh&&(i-=g)}else u<=qh&&(i+=u);return{width:i,height:o,x:s,y:l}}const s8e=new Set(["absolute","fixed"]);function l8e(e,t){const n=Er(e,!0,t==="fixed"),r=n.top+e.clientTop,a=n.left+e.clientLeft,i=Rt(e)?Wr(e):Nn(1),o=e.clientWidth*i.x,s=e.clientHeight*i.y,l=a*i.x,u=r*i.y;return{width:o,height:s,x:l,y:u}}function Uh(e,t,n){let r;if(t==="viewport")r=o8e(e,n);else if(t==="document")r=i8e(Cn(e));else if(ot(t))r=l8e(t,n);else{const a=A5(e);r={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return Hi(r)}function C5(e,t){const n=jn(e);return n===t||!ot(n)||qn(n)?!1:dn(n).position==="fixed"||C5(n,t)}function c8e(e,t){const n=t.get(e);if(n)return n;let r=rr(e,[],!1).filter(s=>ot(s)&&Jr(s)!=="body"),a=null;const i=dn(e).position==="fixed";let o=i?jn(e):e;for(;ot(o)&&!qn(o);){const s=dn(o),l=Wd(o);!l&&s.position==="fixed"&&(a=null),(i?!l&&!a:!l&&s.position==="static"&&!!a&&s8e.has(a.position)||Fa(o)&&!l&&C5(e,o))?r=r.filter(d=>d!==o):a=s,o=jn(o)}return t.set(e,r),r}function u8e(e){let{element:t,boundary:n,rootBoundary:r,strategy:a}=e;const o=[...n==="clippingAncestors"?uo(t)?[]:c8e(t,this._c):[].concat(n),r],s=o[0],l=o.reduce((u,d)=>{const p=Uh(t,d,a);return u.top=vr(p.top,u.top),u.right=Bi(p.right,u.right),u.bottom=Bi(p.bottom,u.bottom),u.left=vr(p.left,u.left),u},Uh(t,s,a));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function d8e(e){const{width:t,height:n}=N5(e);return{width:t,height:n}}function p8e(e,t,n){const r=Rt(t),a=Cn(t),i=n==="fixed",o=Er(e,!0,i,t);let s={scrollLeft:0,scrollTop:0};const l=Nn(0);function u(){l.x=go(a)}if(r||!r&&!i)if((Jr(t)!=="body"||Fa(a))&&(s=ho(t)),r){const h=Er(t,!0,i,t);l.x=h.x+t.clientLeft,l.y=h.y+t.clientTop}else a&&u();i&&!r&&a&&u();const d=a&&!r&&!i?T5(a,s):Nn(0),p=o.left+s.scrollLeft-l.x-d.x,m=o.top+s.scrollTop-l.y-d.y;return{x:p,y:m,width:o.width,height:o.height}}function Jo(e){return dn(e).position==="static"}function Hh(e,t){if(!Rt(e)||dn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Cn(e)===n&&(n=n.ownerDocument.body),n}function R5(e,t){const n=jt(e);if(uo(e))return n;if(!Rt(e)){let a=jn(e);for(;a&&!qn(a);){if(ot(a)&&!Jo(a))return a;a=jn(a)}return n}let r=Hh(e,t);for(;r&&Gve(r)&&Jo(r);)r=Hh(r,t);return r&&qn(r)&&Jo(r)&&!Wd(r)?n:r||Xve(e)||n}const h8e=async function(e){const t=this.getOffsetParent||R5,n=this.getDimensions,r=await n(e.floating);return{reference:p8e(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function m8e(e){return dn(e).direction==="rtl"}const f8e={convertOffsetParentRelativeRectToViewportRelativeRect:r8e,getDocumentElement:Cn,getClippingRect:u8e,getOffsetParent:R5,getElementRects:h8e,getClientRects:a8e,getDimensions:d8e,getScale:Wr,isElement:ot,isRTL:m8e};function I5(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function g8e(e,t){let n=null,r;const a=Cn(e);function i(){var s;clearTimeout(r),(s=n)==null||s.disconnect(),n=null}function o(s,l){s===void 0&&(s=!1),l===void 0&&(l=1),i();const u=e.getBoundingClientRect(),{left:d,top:p,width:m,height:h}=u;if(s||t(),!m||!h)return;const g=Vr(p),y=Vr(a.clientWidth-(d+m)),_=Vr(a.clientHeight-(p+h)),v=Vr(d),w={rootMargin:-g+"px "+-y+"px "+-_+"px "+-v+"px",threshold:vr(0,Bi(1,l))||1};let M=!0;function S(E){const F=E[0].intersectionRatio;if(F!==l){if(!M)return o();F?o(!1,F):r=setTimeout(()=>{o(!1,1e-7)},1e3)}F===1&&!I5(u,e.getBoundingClientRect())&&o(),M=!1}try{n=new IntersectionObserver(S,{...w,root:a.ownerDocument})}catch{n=new IntersectionObserver(S,w)}n.observe(e)}return o(!0),i}function O5(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:a=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,u=Yd(e),d=a||i?[...u?rr(u):[],...rr(t)]:[];d.forEach(v=>{a&&v.addEventListener("scroll",n,{passive:!0}),i&&v.addEventListener("resize",n)});const p=u&&s?g8e(u,n):null;let m=-1,h=null;o&&(h=new ResizeObserver(v=>{let[k]=v;k&&k.target===u&&h&&(h.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var w;(w=h)==null||w.observe(t)})),n()}),u&&!l&&h.observe(u),h.observe(t));let g,y=l?Er(e):null;l&&_();function _(){const v=Er(e);y&&!I5(y,v)&&n(),y=v,g=requestAnimationFrame(_)}return n(),()=>{var v;d.forEach(k=>{a&&k.removeEventListener("scroll",n),i&&k.removeEventListener("resize",n)}),p?.(),(v=h)==null||v.disconnect(),h=null,l&&cancelAnimationFrame(g)}}const y8e=J6e,b8e=e8e,k8e=Z6e,v8e=(e,t,n)=>{const r=new Map,a={platform:f8e,...n},i={...a.platform,_c:r};return Y6e(e,t,{...a,platform:i})};var _8e=typeof document<"u",w8e=function(){},Ai=_8e?ee.useLayoutEffect:w8e;function Vi(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,a;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Vi(e[r],t[r]))return!1;return!0}if(a=Object.keys(e),n=a.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,a[r]))return!1;for(r=n;r--!==0;){const i=a[r];if(!(i==="_owner"&&e.$$typeof)&&!Vi(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function L5(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function jh(e,t){const n=L5(e);return Math.round(t*n)/n}function es(e){const t=ne.useRef(e);return Ai(()=>{t.current=e}),t}function x8e(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:a,elements:{reference:i,floating:o}={},transform:s=!0,whileElementsMounted:l,open:u}=e,[d,p]=ne.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,h]=ne.useState(r);Vi(m,r)||h(r);const[g,y]=ne.useState(null),[_,v]=ne.useState(null),k=ne.useCallback(T=>{T!==E.current&&(E.current=T,y(T))},[]),w=ne.useCallback(T=>{T!==F.current&&(F.current=T,v(T))},[]),M=i||g,S=o||_,E=ne.useRef(null),F=ne.useRef(null),P=ne.useRef(d),C=l!=null,D=es(l),W=es(a),K=es(u),J=ne.useCallback(()=>{if(!E.current||!F.current)return;const T={placement:t,strategy:n,middleware:m};W.current&&(T.platform=W.current),v8e(E.current,F.current,T).then(Y=>{const N={...Y,isPositioned:K.current!==!1};V.current&&!Vi(P.current,N)&&(P.current=N,Kk.flushSync(()=>{p(N)}))})},[m,t,n,W,K]);Ai(()=>{u===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,p(T=>({...T,isPositioned:!1})))},[u]);const V=ne.useRef(!1);Ai(()=>(V.current=!0,()=>{V.current=!1}),[]),Ai(()=>{if(M&&(E.current=M),S&&(F.current=S),M&&S){if(D.current)return D.current(M,S,J);J()}},[M,S,J,D,C]);const R=ne.useMemo(()=>({reference:E,floating:F,setReference:k,setFloating:w}),[k,w]),q=ne.useMemo(()=>({reference:M,floating:S}),[M,S]),G=ne.useMemo(()=>{const T={position:n,left:0,top:0};if(!q.floating)return T;const Y=jh(q.floating,d.x),N=jh(q.floating,d.y);return s?{...T,transform:"translate("+Y+"px, "+N+"px)",...L5(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:Y,top:N}},[n,s,q.floating,d.x,d.y]);return ne.useMemo(()=>({...d,update:J,refs:R,elements:q,floatingStyles:G}),[d,J,R,q,G])}const D5=(e,t)=>({...y8e(e),options:[e,t]}),z5=(e,t)=>({...b8e(e),options:[e,t]}),$5=(e,t)=>({...k8e(e),options:[e,t]}),E8e="data-floating-ui-focusable",Vh="active",Gh="selected",Pa="ArrowLeft",Ba="ArrowRight",F5="ArrowUp",yo="ArrowDown",M8e={...ne};let Wh=!1,S8e=0;const Kh=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+S8e++;function N8e(){const[e,t]=ne.useState(()=>Wh?Kh():void 0);return Nt(()=>{e==null&&t(Kh())},[]),ne.useEffect(()=>{Wh=!0},[]),e}const A8e=M8e.useId,Zd=A8e||N8e;let Aa;process.env.NODE_ENV!=="production"&&(Aa=new Set);function ts(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const a="Floating UI: "+n.join(" ");if(!((e=Aa)!=null&&e.has(a))){var i;(i=Aa)==null||i.add(a),console.warn(a)}}function T8e(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const a="Floating UI: "+n.join(" ");if(!((e=Aa)!=null&&e.has(a))){var i;(i=Aa)==null||i.add(a),console.error(a)}}function C8e(){const e=new Map;return{emit(t,n){var r;(r=e.get(t))==null||r.forEach(a=>a(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){var r;(r=e.get(t))==null||r.delete(n)}}}const R8e=ne.createContext(null),I8e=ne.createContext(null),bo=()=>{var e;return((e=ne.useContext(R8e))==null?void 0:e.id)||null},ko=()=>ne.useContext(I8e);function qa(e){return"data-floating-ui-"+e}function nn(e){e.current!==-1&&(clearTimeout(e.current),e.current=-1)}const Yh=qa("safe-polygon");function ns(e,t,n){if(n&&!Na(n))return 0;if(typeof e=="number")return e;if(typeof e=="function"){const r=e();return typeof r=="number"?r:r?.[t]}return e?.[t]}function rs(e){return typeof e=="function"?e():e}function O8e(e,t){t===void 0&&(t={});const{open:n,onOpenChange:r,dataRef:a,events:i,elements:o}=e,{enabled:s=!0,delay:l=0,handleClose:u=null,mouseOnly:d=!1,restMs:p=0,move:m=!0}=t,h=ko(),g=bo(),y=Pn(u),_=Pn(l),v=Pn(n),k=Pn(p),w=ne.useRef(),M=ne.useRef(-1),S=ne.useRef(),E=ne.useRef(-1),F=ne.useRef(!0),P=ne.useRef(!1),C=ne.useRef(()=>{}),D=ne.useRef(!1),W=Xt(()=>{var G;const T=(G=a.current.openEvent)==null?void 0:G.type;return T?.includes("mouse")&&T!=="mousedown"});ne.useEffect(()=>{if(!s)return;function G(T){let{open:Y}=T;Y||(nn(M),nn(E),F.current=!0,D.current=!1)}return i.on("openchange",G),()=>{i.off("openchange",G)}},[s,i]),ne.useEffect(()=>{if(!s||!y.current||!n)return;function G(Y){W()&&r(!1,Y,"hover")}const T=yn(o.floating).documentElement;return T.addEventListener("mouseleave",G),()=>{T.removeEventListener("mouseleave",G)}},[o.floating,n,r,s,y,W]);const K=ne.useCallback(function(G,T,Y){T===void 0&&(T=!0),Y===void 0&&(Y="hover");const N=ns(_.current,"close",w.current);N&&!S.current?(nn(M),M.current=window.setTimeout(()=>r(!1,G,Y),N)):T&&(nn(M),r(!1,G,Y))},[_,r]),J=Xt(()=>{C.current(),S.current=void 0}),V=Xt(()=>{if(P.current){const G=yn(o.floating).body;G.style.pointerEvents="",G.removeAttribute(Yh),P.current=!1}}),R=Xt(()=>a.current.openEvent?["click","mousedown"].includes(a.current.openEvent.type):!1);ne.useEffect(()=>{if(!s)return;function G(te){if(nn(M),F.current=!1,d&&!Na(w.current)||rs(k.current)>0&&!ns(_.current,"open"))return;const I=ns(_.current,"open",w.current);I?M.current=window.setTimeout(()=>{v.current||r(!0,te,"hover")},I):n||r(!0,te,"hover")}function T(te){if(R()){V();return}C.current();const I=yn(o.floating);if(nn(E),D.current=!1,y.current&&a.current.floatingContext){n||nn(M),S.current=y.current({...a.current.floatingContext,tree:h,x:te.clientX,y:te.clientY,onClose(){V(),J(),R()||K(te,!0,"safe-polygon")}});const ge=S.current;I.addEventListener("mousemove",ge),C.current=()=>{I.removeEventListener("mousemove",ge)};return}(w.current==="touch"?!xr(o.floating,te.relatedTarget):!0)&&K(te)}function Y(te){R()||a.current.floatingContext&&(y.current==null||y.current({...a.current.floatingContext,tree:h,x:te.clientX,y:te.clientY,onClose(){V(),J(),R()||K(te)}})(te))}function N(){nn(M)}function Z(te){R()||K(te,!1)}if(ot(o.domReference)){const te=o.domReference,I=o.floating;return n&&te.addEventListener("mouseleave",Y),m&&te.addEventListener("mousemove",G,{once:!0}),te.addEventListener("mouseenter",G),te.addEventListener("mouseleave",T),I&&(I.addEventListener("mouseleave",Y),I.addEventListener("mouseenter",N),I.addEventListener("mouseleave",Z)),()=>{n&&te.removeEventListener("mouseleave",Y),m&&te.removeEventListener("mousemove",G),te.removeEventListener("mouseenter",G),te.removeEventListener("mouseleave",T),I&&(I.removeEventListener("mouseleave",Y),I.removeEventListener("mouseenter",N),I.removeEventListener("mouseleave",Z))}}},[o,s,e,d,m,K,J,V,r,n,v,h,_,y,a,R,k]),Nt(()=>{var G;if(s&&n&&(G=y.current)!=null&&(G=G.__options)!=null&&G.blockPointerEvents&&W()){P.current=!0;const Y=o.floating;if(ot(o.domReference)&&Y){var T;const N=yn(o.floating).body;N.setAttribute(Yh,"");const Z=o.domReference,te=h==null||(T=h.nodesRef.current.find(I=>I.id===g))==null||(T=T.context)==null?void 0:T.elements.floating;return te&&(te.style.pointerEvents=""),N.style.pointerEvents="none",Z.style.pointerEvents="auto",Y.style.pointerEvents="auto",()=>{N.style.pointerEvents="",Z.style.pointerEvents="",Y.style.pointerEvents=""}}}},[s,n,g,o,h,y,W]),Nt(()=>{n||(w.current=void 0,D.current=!1,J(),V())},[n,J,V]),ne.useEffect(()=>()=>{J(),nn(M),nn(E),V()},[s,o.domReference,J,V]);const q=ne.useMemo(()=>{function G(T){w.current=T.pointerType}return{onPointerDown:G,onPointerEnter:G,onMouseMove(T){const{nativeEvent:Y}=T;function N(){!F.current&&!v.current&&r(!0,Y,"hover")}d&&!Na(w.current)||n||rs(k.current)===0||D.current&&T.movementX**2+T.movementY**2<2||(nn(E),w.current==="touch"?N():(D.current=!0,E.current=window.setTimeout(N,rs(k.current))))}}},[d,r,n,v,k]);return ne.useMemo(()=>s?{reference:q}:{},[s,q])}let Zh=0;function L8e(e,t){t===void 0&&(t={});const{preventScroll:n=!1,cancelPrevious:r=!0,sync:a=!1}=t;r&&cancelAnimationFrame(Zh);const i=()=>e?.focus({preventScroll:n});a?i():Zh=requestAnimationFrame(i)}const P5={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},Xh=ne.forwardRef(function(t,n){const[r,a]=ne.useState();Nt(()=>{_5()&&a("button")},[]);const i={ref:n,tabIndex:0,role:r,"aria-hidden":r?void 0:!0,[qa("focus-guard")]:"",style:P5};return O.jsx("span",{...t,...i})}),B5=ne.createContext(null),Qh=qa("portal");function D8e(e){e===void 0&&(e={});const{id:t,root:n}=e,r=Zd(),a=$8e(),[i,o]=ne.useState(null),s=ne.useRef(null);return Nt(()=>()=>{i?.remove(),queueMicrotask(()=>{s.current=null})},[i]),Nt(()=>{if(!r||s.current)return;const l=t?document.getElementById(t):null;if(!l)return;const u=document.createElement("div");u.id=r,u.setAttribute(Qh,""),l.appendChild(u),s.current=u,o(u)},[t,r]),Nt(()=>{if(n===null||!r||s.current)return;let l=n||a?.portalNode;l&&!Gd(l)&&(l=l.current),l=l||document.body;let u=null;t&&(u=document.createElement("div"),u.id=t,l.appendChild(u));const d=document.createElement("div");d.id=r,d.setAttribute(Qh,""),l=u||l,l.appendChild(d),s.current=d,o(d)},[t,n,r,a]),i}function z8e(e){const{children:t,id:n,root:r,preserveTabOrder:a=!0}=e,i=D8e({id:n,root:r}),[o,s]=ne.useState(null),l=ne.useRef(null),u=ne.useRef(null),d=ne.useRef(null),p=ne.useRef(null),m=o?.modal,h=o?.open,g=!!o&&!o.modal&&o.open&&a&&!!(r||i);return ne.useEffect(()=>{if(!i||!a||m)return;function y(_){i&&Qo(_)&&(_.type==="focusin"?Ph:K6e)(i)}return i.addEventListener("focusin",y,!0),i.addEventListener("focusout",y,!0),()=>{i.removeEventListener("focusin",y,!0),i.removeEventListener("focusout",y,!0)}},[i,a,m]),ne.useEffect(()=>{i&&(h||Ph(i))},[h,i]),O.jsxs(B5.Provider,{value:ne.useMemo(()=>({preserveTabOrder:a,beforeOutsideRef:l,afterOutsideRef:u,beforeInsideRef:d,afterInsideRef:p,portalNode:i,setFocusManagerState:s}),[a,i]),children:[g&&i&&O.jsx(Xh,{"data-type":"outside",ref:l,onFocus:y=>{if(Qo(y,i)){var _;(_=d.current)==null||_.focus()}else{const v=o?o.domReference:null,k=W6e(v);k?.focus()}}}),g&&i&&O.jsx("span",{"aria-owns":i.id,style:P5}),i&&Kk.createPortal(t,i),g&&i&&O.jsx(Xh,{"data-type":"outside",ref:u,onFocus:y=>{if(Qo(y,i)){var _;(_=p.current)==null||_.focus()}else{const v=o?o.domReference:null,k=G6e(v);k?.focus(),o?.closeOnFocusOut&&o?.onOpenChange(!1,y.nativeEvent,"focus-out")}}})]})}const $8e=()=>ne.useContext(B5);function Jh(e){return Rt(e.target)&&e.target.tagName==="BUTTON"}function F8e(e){return Rt(e.target)&&e.target.tagName==="A"}function e2(e){return Kd(e)}function P8e(e,t){t===void 0&&(t={});const{open:n,onOpenChange:r,dataRef:a,elements:{domReference:i}}=e,{enabled:o=!0,event:s="click",toggle:l=!0,ignoreMouse:u=!1,keyboardHandlers:d=!0,stickIfOpen:p=!0}=t,m=ne.useRef(),h=ne.useRef(!1),g=ne.useMemo(()=>({onPointerDown(y){m.current=y.pointerType},onMouseDown(y){const _=m.current;y.button===0&&s!=="click"&&(Na(_,!0)&&u||(n&&l&&(!(a.current.openEvent&&p)||a.current.openEvent.type==="mousedown")?r(!1,y.nativeEvent,"click"):(y.preventDefault(),r(!0,y.nativeEvent,"click"))))},onClick(y){const _=m.current;if(s==="mousedown"&&m.current){m.current=void 0;return}Na(_,!0)&&u||(n&&l&&(!(a.current.openEvent&&p)||a.current.openEvent.type==="click")?r(!1,y.nativeEvent,"click"):r(!0,y.nativeEvent,"click"))},onKeyDown(y){m.current=void 0,!(y.defaultPrevented||!d||Jh(y))&&(y.key===" "&&!e2(i)&&(y.preventDefault(),h.current=!0),!F8e(y)&&y.key==="Enter"&&r(!(n&&l),y.nativeEvent,"click"))},onKeyUp(y){y.defaultPrevented||!d||Jh(y)||e2(i)||y.key===" "&&h.current&&(h.current=!1,r(!(n&&l),y.nativeEvent,"click"))}}),[a,i,s,u,d,r,n,p,l]);return ne.useMemo(()=>o?{reference:g}:{},[o,g])}const B8e={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},q8e={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},t2=e=>{var t,n;return{escapeKey:typeof e=="boolean"?e:(t=e?.escapeKey)!=null?t:!1,outsidePress:typeof e=="boolean"?e:(n=e?.outsidePress)!=null?n:!0}};function q5(e,t){t===void 0&&(t={});const{open:n,onOpenChange:r,elements:a,dataRef:i}=e,{enabled:o=!0,escapeKey:s=!0,outsidePress:l=!0,outsidePressEvent:u="pointerdown",referencePress:d=!1,referencePressEvent:p="pointerdown",ancestorScroll:m=!1,bubbles:h,capture:g}=t,y=ko(),_=Xt(typeof l=="function"?l:()=>!1),v=typeof l=="function"?_:l,k=ne.useRef(!1),{escapeKey:w,outsidePress:M}=t2(h),{escapeKey:S,outsidePress:E}=t2(g),F=ne.useRef(!1),P=Xt(V=>{var R;if(!n||!o||!s||V.key!=="Escape"||F.current)return;const q=(R=i.current.floatingContext)==null?void 0:R.nodeId,G=y?ba(y.nodesRef.current,q):[];if(!w&&(V.stopPropagation(),G.length>0)){let T=!0;if(G.forEach(Y=>{var N;if((N=Y.context)!=null&&N.open&&!Y.context.dataRef.current.__escapeKeyBubbles){T=!1;return}}),!T)return}r(!1,L6e(V)?V.nativeEvent:V,"escape-key")}),C=Xt(V=>{var R;const q=()=>{var G;P(V),(G=Pr(V))==null||G.removeEventListener("keydown",q)};(R=Pr(V))==null||R.addEventListener("keydown",q)}),D=Xt(V=>{var R;const q=i.current.insideReactTree;i.current.insideReactTree=!1;const G=k.current;if(k.current=!1,u==="click"&&G||q||typeof v=="function"&&!v(V))return;const T=Pr(V),Y="["+qa("inert")+"]",N=yn(a.floating).querySelectorAll(Y);let Z=ot(T)?T:null;for(;Z&&!qn(Z);){const ge=jn(Z);if(qn(ge)||!ot(ge))break;Z=ge}if(N.length&&ot(T)&&!C6e(T)&&!xr(T,a.floating)&&Array.from(N).every(ge=>!xr(Z,ge)))return;if(Rt(T)&&J){const ge=qn(T),ve=dn(T),Ce=/auto|scroll/,Be=ge||Ce.test(ve.overflowX),He=ge||Ce.test(ve.overflowY),re=Be&&T.clientWidth>0&&T.scrollWidth>T.clientWidth,Me=He&&T.clientHeight>0&&T.scrollHeight>T.clientHeight,Ge=ve.direction==="rtl",Je=Me&&(Ge?V.offsetX<=T.offsetWidth-T.clientWidth:V.offsetX>T.clientWidth),qe=re&&V.offsetY>T.clientHeight;if(Je||qe)return}const te=(R=i.current.floatingContext)==null?void 0:R.nodeId,I=y&&ba(y.nodesRef.current,te).some(ge=>{var ve;return Zo(V,(ve=ge.context)==null?void 0:ve.elements.floating)});if(Zo(V,a.floating)||Zo(V,a.domReference)||I)return;const pe=y?ba(y.nodesRef.current,te):[];if(pe.length>0){let ge=!0;if(pe.forEach(ve=>{var Ce;if((Ce=ve.context)!=null&&Ce.open&&!ve.context.dataRef.current.__outsidePressBubbles){ge=!1;return}}),!ge)return}r(!1,V,"outside-press")}),W=Xt(V=>{var R;const q=()=>{var G;D(V),(G=Pr(V))==null||G.removeEventListener(u,q)};(R=Pr(V))==null||R.addEventListener(u,q)});ne.useEffect(()=>{if(!n||!o)return;i.current.__escapeKeyBubbles=w,i.current.__outsidePressBubbles=M;let V=-1;function R(N){r(!1,N,"ancestor-scroll")}function q(){window.clearTimeout(V),F.current=!0}function G(){V=window.setTimeout(()=>{F.current=!1},po()?5:0)}const T=yn(a.floating);s&&(T.addEventListener("keydown",S?C:P,S),T.addEventListener("compositionstart",q),T.addEventListener("compositionend",G)),v&&T.addEventListener(u,E?W:D,E);let Y=[];return m&&(ot(a.domReference)&&(Y=rr(a.domReference)),ot(a.floating)&&(Y=Y.concat(rr(a.floating))),!ot(a.reference)&&a.reference&&a.reference.contextElement&&(Y=Y.concat(rr(a.reference.contextElement)))),Y=Y.filter(N=>{var Z;return N!==((Z=T.defaultView)==null?void 0:Z.visualViewport)}),Y.forEach(N=>{N.addEventListener("scroll",R,{passive:!0})}),()=>{s&&(T.removeEventListener("keydown",S?C:P,S),T.removeEventListener("compositionstart",q),T.removeEventListener("compositionend",G)),v&&T.removeEventListener(u,E?W:D,E),Y.forEach(N=>{N.removeEventListener("scroll",R)}),window.clearTimeout(V)}},[i,a,s,v,u,n,r,m,o,w,M,P,S,C,D,E,W]),ne.useEffect(()=>{i.current.insideReactTree=!1},[i,v,u]);const K=ne.useMemo(()=>({onKeyDown:P,...d&&{[B8e[p]]:V=>{r(!1,V.nativeEvent,"reference-press")},...p!=="click"&&{onClick(V){r(!1,V.nativeEvent,"reference-press")}}}}),[P,r,d,p]),J=ne.useMemo(()=>({onKeyDown:P,onMouseDown(){k.current=!0},onMouseUp(){k.current=!0},[q8e[u]]:()=>{i.current.insideReactTree=!0}}),[P,u,i]);return ne.useMemo(()=>o?{reference:K,floating:J}:{},[o,K,J])}function U8e(e){const{open:t=!1,onOpenChange:n,elements:r}=e,a=Zd(),i=ne.useRef({}),[o]=ne.useState(()=>C8e()),s=bo()!=null;if(process.env.NODE_ENV!=="production"){const h=r.reference;h&&!ot(h)&&T8e("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[l,u]=ne.useState(r.reference),d=Xt((h,g,y)=>{i.current.openEvent=h?g:void 0,o.emit("openchange",{open:h,event:g,reason:y,nested:s}),n?.(h,g,y)}),p=ne.useMemo(()=>({setPositionReference:u}),[]),m=ne.useMemo(()=>({reference:l||r.reference||null,floating:r.floating||null,domReference:r.reference}),[l,r.reference,r.floating]);return ne.useMemo(()=>({dataRef:i,open:t,onOpenChange:d,elements:m,events:o,floatingId:a,refs:p}),[t,d,m,o,a,p])}function U5(e){e===void 0&&(e={});const{nodeId:t}=e,n=U8e({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||n,a=r.elements,[i,o]=ne.useState(null),[s,l]=ne.useState(null),d=a?.domReference||i,p=ne.useRef(null),m=ko();Nt(()=>{d&&(p.current=d)},[d]);const h=x8e({...e,elements:{...a,...s&&{reference:s}}}),g=ne.useCallback(w=>{const M=ot(w)?{getBoundingClientRect:()=>w.getBoundingClientRect(),getClientRects:()=>w.getClientRects(),contextElement:w}:w;l(M),h.refs.setReference(M)},[h.refs]),y=ne.useCallback(w=>{(ot(w)||w===null)&&(p.current=w,o(w)),(ot(h.refs.reference.current)||h.refs.reference.current===null||w!==null&&!ot(w))&&h.refs.setReference(w)},[h.refs]),_=ne.useMemo(()=>({...h.refs,setReference:y,setPositionReference:g,domReference:p}),[h.refs,y,g]),v=ne.useMemo(()=>({...h.elements,domReference:d}),[h.elements,d]),k=ne.useMemo(()=>({...h,...r,refs:_,elements:v,nodeId:t}),[h,_,v,t,r]);return Nt(()=>{r.dataRef.current.floatingContext=k;const w=m?.nodesRef.current.find(M=>M.id===t);w&&(w.context=k)}),ne.useMemo(()=>({...h,context:k,refs:_,elements:v}),[h,_,v,k])}function as(){return S6e()&&_5()}function H8e(e,t){t===void 0&&(t={});const{open:n,onOpenChange:r,events:a,dataRef:i,elements:o}=e,{enabled:s=!0,visibleOnly:l=!0}=t,u=ne.useRef(!1),d=ne.useRef(-1),p=ne.useRef(!0);ne.useEffect(()=>{if(!s)return;const h=jt(o.domReference);function g(){!n&&Rt(o.domReference)&&o.domReference===Sa(yn(o.domReference))&&(u.current=!0)}function y(){p.current=!0}function _(){p.current=!1}return h.addEventListener("blur",g),as()&&(h.addEventListener("keydown",y,!0),h.addEventListener("pointerdown",_,!0)),()=>{h.removeEventListener("blur",g),as()&&(h.removeEventListener("keydown",y,!0),h.removeEventListener("pointerdown",_,!0))}},[o.domReference,n,s]),ne.useEffect(()=>{if(!s)return;function h(g){let{reason:y}=g;(y==="reference-press"||y==="escape-key")&&(u.current=!0)}return a.on("openchange",h),()=>{a.off("openchange",h)}},[a,s]),ne.useEffect(()=>()=>{nn(d)},[]);const m=ne.useMemo(()=>({onMouseLeave(){u.current=!1},onFocus(h){if(u.current)return;const g=Pr(h.nativeEvent);if(l&&ot(g)){if(as()&&!h.relatedTarget){if(!p.current&&!Kd(g))return}else if(!I6e(g))return}r(!0,h.nativeEvent,"focus")},onBlur(h){u.current=!1;const g=h.relatedTarget,y=h.nativeEvent,_=ot(g)&&g.hasAttribute(qa("focus-guard"))&&g.getAttribute("data-type")==="outside";d.current=window.setTimeout(()=>{var v;const k=Sa(o.domReference?o.domReference.ownerDocument:document);!g&&k===o.domReference||xr((v=i.current.floatingContext)==null?void 0:v.refs.floating.current,k)||xr(o.domReference,k)||_||r(!1,y,"focus")})}}),[i,o.domReference,r,l]);return ne.useMemo(()=>s?{reference:m}:{},[s,m])}function is(e,t,n){const r=new Map,a=n==="item";let i=e;if(a&&e){const{[Vh]:o,[Gh]:s,...l}=e;i=l}return{...n==="floating"&&{tabIndex:-1,[E8e]:""},...i,...t.map(o=>{const s=o?o[n]:null;return typeof s=="function"?e?s(e):null:s}).concat(e).reduce((o,s)=>(s&&Object.entries(s).forEach(l=>{let[u,d]=l;if(!(a&&[Vh,Gh].includes(u)))if(u.indexOf("on")===0){if(r.has(u)||r.set(u,[]),typeof d=="function"){var p;(p=r.get(u))==null||p.push(d),o[u]=function(){for(var m,h=arguments.length,g=new Array(h),y=0;y<h;y++)g[y]=arguments[y];return(m=r.get(u))==null?void 0:m.map(_=>_(...g)).find(_=>_!==void 0)}}}else o[u]=d}),o),{})}}function H5(e){e===void 0&&(e=[]);const t=e.map(s=>s?.reference),n=e.map(s=>s?.floating),r=e.map(s=>s?.item),a=ne.useCallback(s=>is(s,e,"reference"),t),i=ne.useCallback(s=>is(s,e,"floating"),n),o=ne.useCallback(s=>is(s,e,"item"),r);return ne.useMemo(()=>({getReferenceProps:a,getFloatingProps:i,getItemProps:o}),[a,i,o])}const j8e="Escape";function vo(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function ei(e,t){return vo(t,e===F5||e===yo,e===Pa||e===Ba)}function os(e,t,n){return vo(t,e===yo,n?e===Pa:e===Ba)||e==="Enter"||e===" "||e===""}function n2(e,t,n){return vo(t,n?e===Pa:e===Ba,e===yo)}function r2(e,t,n,r){const a=n?e===Ba:e===Pa,i=e===F5;return t==="both"||t==="horizontal"&&r&&r>1?e===j8e:vo(t,a,i)}function V8e(e,t){const{open:n,onOpenChange:r,elements:a,floatingId:i}=e,{listRef:o,activeIndex:s,onNavigate:l=()=>{},enabled:u=!0,selectedIndex:d=null,allowEscape:p=!1,loop:m=!1,nested:h=!1,rtl:g=!1,virtual:y=!1,focusItemOnOpen:_="auto",focusItemOnHover:v=!0,openOnArrowKeyDown:k=!0,disabledIndices:w=void 0,orientation:M="vertical",parentOrientation:S,cols:E=1,scrollItemIntoView:F=!0,virtualItemRef:P,itemSizes:C,dense:D=!1}=t;process.env.NODE_ENV!=="production"&&(p&&(m||ts("`useListNavigation` looping must be enabled to allow escaping."),y||ts("`useListNavigation` must be virtual to allow escaping.")),M==="vertical"&&E>1&&ts("In grid list navigation mode (`cols` > 1), the `orientation` should",'be either "horizontal" or "both".'));const W=x5(a.floating),K=Pn(W),J=bo(),V=ko();Nt(()=>{e.dataRef.current.orientation=M},[e,M]);const R=Xt(()=>{l(T.current===-1?null:T.current)}),q=R6e(a.domReference),G=ne.useRef(_),T=ne.useRef(d??-1),Y=ne.useRef(null),N=ne.useRef(!0),Z=ne.useRef(R),te=ne.useRef(!!a.floating),I=ne.useRef(n),pe=ne.useRef(!1),ge=ne.useRef(!1),ve=Pn(w),Ce=Pn(n),Be=Pn(F),He=Pn(d),[re,Me]=ne.useState(),[Ge,Je]=ne.useState(),qe=Xt(()=>{function _e(B){if(y){var X;(X=B.id)!=null&&X.endsWith("-fui-option")&&(B.id=i+"-"+Math.random().toString(16).slice(2,10)),Me(B.id),V?.events.emit("virtualfocus",B),P&&(P.current=B)}else L8e(B,{sync:pe.current,preventScroll:!0})}const $e=o.current[T.current],xe=ge.current;$e&&_e($e),(pe.current?B=>B():requestAnimationFrame)(()=>{const B=o.current[T.current]||$e;if(!B)return;$e||_e(B);const X=Be.current;X&&ke&&(xe||!N.current)&&(B.scrollIntoView==null||B.scrollIntoView(typeof X=="boolean"?{block:"nearest",inline:"nearest"}:X))})});Nt(()=>{u&&(n&&a.floating?G.current&&d!=null&&(ge.current=!0,T.current=d,R()):te.current&&(T.current=-1,Z.current()))},[u,n,a.floating,d,R]),Nt(()=>{if(u&&n&&a.floating)if(s==null){if(pe.current=!1,He.current!=null)return;if(te.current&&(T.current=-1,qe()),(!I.current||!te.current)&&G.current&&(Y.current!=null||G.current===!0&&Y.current==null)){let _e=0;const $e=()=>{o.current[0]==null?(_e<2&&(_e?requestAnimationFrame:queueMicrotask)($e),_e++):(T.current=Y.current==null||os(Y.current,M,g)||h?Xo(o,ve.current):Fh(o,ve.current),Y.current=null,R())};$e()}}else ka(o,s)||(T.current=s,qe(),ge.current=!1)},[u,n,a.floating,s,He,h,o,M,g,R,qe,ve]),Nt(()=>{var _e;if(!u||a.floating||!V||y||!te.current)return;const $e=V.nodesRef.current,xe=(_e=$e.find(X=>X.id===J))==null||(_e=_e.context)==null?void 0:_e.elements.floating,Xe=Sa(yn(a.floating)),B=$e.some(X=>X.context&&xr(X.context.elements.floating,Xe));xe&&!B&&N.current&&xe.focus({preventScroll:!0})},[u,a.floating,V,J,y]),Nt(()=>{if(!u||!V||!y||J)return;function _e($e){Je($e.id),P&&(P.current=$e)}return V.events.on("virtualfocus",_e),()=>{V.events.off("virtualfocus",_e)}},[u,V,y,J,P]),Nt(()=>{Z.current=R,I.current=n,te.current=!!a.floating}),Nt(()=>{n||(Y.current=null,G.current=_)},[n,_]);const we=s!=null,ke=ne.useMemo(()=>{function _e(xe){if(!Ce.current)return;const Xe=o.current.indexOf(xe);Xe!==-1&&T.current!==Xe&&(T.current=Xe,R())}return{onFocus(xe){let{currentTarget:Xe}=xe;pe.current=!0,_e(Xe)},onClick:xe=>{let{currentTarget:Xe}=xe;return Xe.focus({preventScroll:!0})},onMouseMove(xe){let{currentTarget:Xe}=xe;pe.current=!0,ge.current=!1,v&&_e(Xe)},onPointerLeave(xe){let{pointerType:Xe}=xe;if(!(!N.current||Xe==="touch")&&(pe.current=!0,!!v&&(T.current=-1,R(),!y))){var B;(B=K.current)==null||B.focus({preventScroll:!0})}}}},[Ce,K,v,o,R,y]),Le=ne.useCallback(()=>{var _e;return S??(V==null||(_e=V.nodesRef.current.find($e=>$e.id===J))==null||(_e=_e.context)==null||(_e=_e.dataRef)==null?void 0:_e.current.orientation)},[J,V,S]),de=Xt(_e=>{if(N.current=!1,pe.current=!0,_e.which===229||!Ce.current&&_e.currentTarget===K.current)return;if(h&&r2(_e.key,M,g,E)){ei(_e.key,Le())||rn(_e),r(!1,_e.nativeEvent,"list-navigation"),Rt(a.domReference)&&(y?V?.events.emit("virtualfocus",a.domReference):a.domReference.focus());return}const $e=T.current,xe=Xo(o,w),Xe=Fh(o,w);if(q||(_e.key==="Home"&&(rn(_e),T.current=xe,R()),_e.key==="End"&&(rn(_e),T.current=Xe,R())),E>1){const B=C||Array.from({length:o.current.length},()=>({width:1,height:1})),X=H6e(B,E,D),le=X.findIndex(je=>je!=null&&!Ni(o,je,w)),he=X.reduce((je,wt,Et)=>wt!=null&&!Ni(o,wt,w)?Et:je,-1),Se=X[U6e({current:X.map(je=>je!=null?o.current[je]:null)},{event:_e,orientation:M,loop:m,rtl:g,cols:E,disabledIndices:V6e([...(typeof w!="function"?w:null)||o.current.map((je,wt)=>Ni(o,wt,w)?wt:void 0),void 0],X),minIndex:le,maxIndex:he,prevIndex:j6e(T.current>Xe?xe:T.current,B,X,E,_e.key===yo?"bl":_e.key===(g?Pa:Ba)?"tr":"tl"),stopEvent:!0})];if(Se!=null&&(T.current=Se,R()),M==="both")return}if(ei(_e.key,M)){if(rn(_e),n&&!y&&Sa(_e.currentTarget.ownerDocument)===_e.currentTarget){T.current=os(_e.key,M,g)?xe:Xe,R();return}os(_e.key,M,g)?m?T.current=$e>=Xe?p&&$e!==o.current.length?-1:xe:At(o,{startingIndex:$e,disabledIndices:w}):T.current=Math.min(Xe,At(o,{startingIndex:$e,disabledIndices:w})):m?T.current=$e<=xe?p&&$e!==-1?o.current.length:Xe:At(o,{startingIndex:$e,decrement:!0,disabledIndices:w}):T.current=Math.max(xe,At(o,{startingIndex:$e,decrement:!0,disabledIndices:w})),ka(o,T.current)&&(T.current=-1),R()}}),et=ne.useMemo(()=>y&&n&&we&&{"aria-activedescendant":Ge||re},[y,n,we,Ge,re]),Te=ne.useMemo(()=>({"aria-orientation":M==="both"?void 0:M,...q?{}:et,onKeyDown:de,onPointerMove(){N.current=!0}}),[et,de,M,q]),We=ne.useMemo(()=>{function _e(xe){_==="auto"&&D6e(xe.nativeEvent)&&(G.current=!0)}function $e(xe){G.current=_,_==="auto"&&z6e(xe.nativeEvent)&&(G.current=!0)}return{...et,onKeyDown(xe){N.current=!1;const Xe=xe.key.startsWith("Arrow"),B=["Home","End"].includes(xe.key),X=Xe||B,le=n2(xe.key,M,g),he=r2(xe.key,M,g,E),Se=n2(xe.key,Le(),g),je=ei(xe.key,M),wt=(h?Se:je)||xe.key==="Enter"||xe.key.trim()==="";if(y&&n){const ft=V?.nodesRef.current.find(Mt=>Mt.parentId==null),St=V&&ft?O6e(V.nodesRef.current,ft.id):null;if(X&&St&&P){const Mt=new KeyboardEvent("keydown",{key:xe.key,bubbles:!0});if(le||he){var Et,vn;const Xa=((Et=St.context)==null?void 0:Et.elements.domReference)===xe.currentTarget,zn=he&&!Xa?(vn=St.context)==null?void 0:vn.elements.domReference:le?o.current.find(Ir=>Ir?.id===re):null;zn&&(rn(xe),zn.dispatchEvent(Mt),Je(void 0))}if((je||B)&&St.context&&St.context.open&&St.parentId&&xe.currentTarget!==St.context.elements.domReference){var _n;rn(xe),(_n=St.context.elements.domReference)==null||_n.dispatchEvent(Mt);return}}return de(xe)}if(!(!n&&!k&&Xe)){if(wt){const ft=ei(xe.key,Le());Y.current=h&&ft?null:xe.key}if(h){Se&&(rn(xe),n?(T.current=Xo(o,ve.current),R()):r(!0,xe.nativeEvent,"list-navigation"));return}je&&(d!=null&&(T.current=d),rn(xe),!n&&k?r(!0,xe.nativeEvent,"list-navigation"):de(xe),n&&R())}},onFocus(){n&&!y&&(T.current=-1,R())},onPointerDown:$e,onPointerEnter:$e,onMouseDown:_e,onClick:_e}},[re,et,E,de,ve,_,o,h,R,r,n,k,M,Le,g,d,V,y,P]);return ne.useMemo(()=>u?{reference:We,floating:Te,item:ke}:{},[u,We,Te,ke])}const G8e=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function j5(e,t){var n,r;t===void 0&&(t={});const{open:a,elements:i,floatingId:o}=e,{enabled:s=!0,role:l="dialog"}=t,u=Zd(),d=((n=i.domReference)==null?void 0:n.id)||u,p=ne.useMemo(()=>{var k;return((k=x5(i.floating))==null?void 0:k.id)||o},[i.floating,o]),m=(r=G8e.get(l))!=null?r:l,g=bo()!=null,y=ne.useMemo(()=>m==="tooltip"||l==="label"?{["aria-"+(l==="label"?"labelledby":"describedby")]:a?p:void 0}:{"aria-expanded":a?"true":"false","aria-haspopup":m==="alertdialog"?"dialog":m,"aria-controls":a?p:void 0,...m==="listbox"&&{role:"combobox"},...m==="menu"&&{id:d},...m==="menu"&&g&&{role:"menuitem"},...l==="select"&&{"aria-autocomplete":"none"},...l==="combobox"&&{"aria-autocomplete":"list"}},[m,p,g,a,d,l]),_=ne.useMemo(()=>{const k={id:p,...m&&{role:m}};return m==="tooltip"||l==="label"?k:{...k,...m==="menu"&&{"aria-labelledby":d}}},[m,p,d,l]),v=ne.useCallback(k=>{let{active:w,selected:M}=k;const S={role:"option",...w&&{id:p+"-fui-option"}};switch(l){case"select":case"combobox":return{...S,"aria-selected":M}}return{}},[p,l]);return ne.useMemo(()=>s?{reference:y,floating:_,item:v}:{},[s,y,_,v])}const Jn=({content:e,children:t,placement:n="top",delay:r=300,disabled:a=!1,className:i=""})=>{const[o,s]=ee.useState(!1),{refs:l,floatingStyles:u,context:d,isPositioned:p}=U5({open:o,onOpenChange:s,placement:n,strategy:"absolute",whileElementsMounted:O5,middleware:[D5(8),$5(),z5({padding:8})]}),m=O8e(d,{delay:{open:r,close:0},enabled:!a}),h=H8e(d,{enabled:!a}),g=q5(d,{enabled:!0,outsidePress:!0,outsidePressEvent:"mousedown",referencePress:!0,referencePressEvent:"mousedown",escapeKey:!0,ancestorScroll:!0}),y=j5(d,{role:"tooltip"}),{getReferenceProps:_,getFloatingProps:v}=H5([m,h,g,y]);return ee.useEffect(()=>{if(!o||a)return;const k=()=>{s(!1)};return window.addEventListener("scroll",k,!0),document.addEventListener("scroll",k,!0),()=>{window.removeEventListener("scroll",k,!0),document.removeEventListener("scroll",k,!0)}},[o,a]),a||!e?O.jsx(O.Fragment,{children:t}):O.jsxs(O.Fragment,{children:[O.jsx("span",{ref:l.setReference,..._(),children:t}),o&&O.jsx(z8e,{children:O.jsx("div",{ref:l.setFloating,style:{...u,opacity:p?1:0,pointerEvents:"none",transition:p?"opacity 0.15s ease-out":"none"},className:`mp-agent-tooltip ${i}`.trim(),...v(),children:e})})]})},ar=({icon:e,size:t="md",iconSize:n,type:r="button",className:a="",tooltip:i,tooltipPlacement:o,...s})=>{const l=Hve[e],u=n??(t==="sm"?14:20),d=O.jsx("button",{type:r,className:`mp-agent-icon-button mp-agent-icon-button-${t} ${a}`.trim(),...s,children:l&&O.jsx(l,{size:u})});return i?O.jsx(Jn,{content:i,placement:o,children:d}):d},Xd=({text:e})=>{const[t,n]=ee.useState(!1),r=async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),2e3)}catch(a){console.error("Failed to copy:",a)}};return O.jsx(Jn,{content:"Copy to clipboard",children:O.jsx(ar,{icon:t?"Check":"Copy",onClick:r,"aria-label":"Copy message",size:"sm"})})},a2=300,V5=ee.memo(({field:e,isExpanded:t,canApply:n,onToggleExpand:r,onApply:a})=>{const i=e.value.length>a2,o=i&&!t?`${e.value.slice(0,a2)}...`:e.value,s=ee.useCallback(()=>{r(e.name)},[e.name,r]),l=ee.useCallback(()=>{a(e)},[e,a]);return O.jsxs("div",{className:"mp-agent-form-proposal-row",children:[O.jsxs("div",{className:"mp-agent-form-proposal-main",children:[O.jsx("div",{className:"mp-agent-form-proposal-label",children:e.label||e.name}),O.jsx("div",{className:"mp-agent-form-proposal-value-container",children:O.jsxs("div",{className:"mp-agent-form-proposal-value",children:[o,i&&O.jsx("button",{type:"button",onClick:s,className:"mp-agent-form-proposal-show-all",children:t?"Show less":"Show all"})]})})]}),O.jsxs("div",{className:"mp-agent-form-proposal-actions-row",children:[n&&O.jsx(ar,{icon:"Check",onClick:l,tooltip:`Apply ${e.name}`,size:"sm"}),O.jsx(Xd,{text:e.value})]})]})});V5.displayName="FormFieldRow";const W8e=e=>{if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(typeof e=="object")try{return JSON.stringify(e)}catch{return String(e)}return String(e)},K8e=e=>{const t=e.output??e.input??{},n=Array.isArray(t.fields)?t.fields.map(r=>({name:typeof r?.name=="string"?r.name:"",label:typeof r?.label=="string"?r.label:void 0,value:W8e(r?.value),inputType:typeof r?.inputType=="string"?r.inputType:void 0,options:Array.isArray(r?.options)?r.options:void 0})).filter(r=>r.name.length>0):[];return{formId:typeof t.formId=="string"?t.formId:void 0,formName:typeof t.formName=="string"?t.formName:void 0,fields:n,notes:typeof t.notes=="string"?t.notes:void 0}},Y8e=({call:e,chatId:t})=>{const n=vt(),r=ee.useMemo(()=>K8e(e),[e]),[a,i]=ee.useState(new Set),o=ee.useMemo(()=>{const M=(e.output??{})?._mp?.lastAction,S=typeof M?.action=="string"?M.action:void 0,E=typeof M?.at=="string"?M.at:void 0;return{action:S,at:E}},[e.output]),s=ee.useMemo(()=>o.action==="apply",[o.action]),l=ee.useMemo(()=>o.action==="reject",[o.action]),u=ee.useMemo(()=>e.status===exports.AgentToolCallStatus.Succeeded&&!!r.formId&&r.fields.length>0&&!s,[e.status,r.formId,r.fields.length,s]),d=ee.useMemo(()=>e.status===exports.AgentToolCallStatus.Succeeded&&!!r.formId&&r.fields.length>0&&!s&&!l,[e.status,r.formId,r.fields.length,s,l]),p=ee.useCallback(async k=>{r.formId&&n.transport.recordToolCallAction&&await n.transport.recordToolCallAction(t,{toolCallId:e.id,action:k.action,data:{formId:r.formId,formName:r.formName,fields:k.fields},systemMessage:k.action==="apply"?`Applied ${k.fields.length} field(s) to ${r.formName??r.formId}.`:`Rejected ${r.formName??r.formId} suggestion.`},{excludeSocketId:!1})},[r.formId,r.formName,t,e.id,n.transport]),m=ee.useCallback(async k=>{if(r.formId){try{await p({action:"apply",fields:k})}catch{return}n.events.dispatchEvent(new CustomEvent(e5,{detail:{chatId:t,toolCallId:e.id,formId:r.formId,...r.formName?{formName:r.formName}:{},fields:k}}))}},[r.formId,r.formName,t,e.id,n.events,p]),h=ee.useCallback(async()=>{if(r.formId)try{await p({action:"reject",fields:r.fields})}catch{return}},[r.formId,r.fields,p]),g=ee.useCallback(k=>{i(w=>{if(w.has(k)){if(w.size===1)return new Set;const M=new Set(w);return M.delete(k),M}else{const M=new Set(w);return M.add(k),M}})},[]),y=ee.useCallback(k=>{m([k])},[m]),_=ee.useCallback(()=>{m(r.fields)},[m,r.fields]);if(e.status===exports.AgentToolCallStatus.Failed&&e.error)return O.jsx("div",{className:"mp-agent-tool-body",children:O.jsx("div",{className:"mp-agent-tool-simple-message",children:"Failed to propose form values"})});if(e.status!==exports.AgentToolCallStatus.Succeeded)return O.jsx("div",{className:"mp-agent-tool-simple-message",children:"Preparing form fill proposal…"});if(!r.formId||r.fields.length===0)return O.jsx("div",{className:"mp-agent-tool-simple-message",children:"No form fields proposed."});const v=ee.useMemo(()=>r.formName?`Proposed values for ${r.formName} (${r.formId})`:`Proposed values for ${r.formId}`,[r.formName,r.formId]);return O.jsxs("div",{className:"mp-agent-tool-body",children:[O.jsx("div",{className:"mp-agent-tool-simple-message",children:v}),r.notes?O.jsx("div",{className:"mp-agent-tool-simple-message",children:r.notes}):null,O.jsx("div",{className:"mp-agent-form-proposal-fields",children:r.fields.map(k=>O.jsx(V5,{field:k,isExpanded:a.has(k.name),canApply:u,onToggleExpand:g,onApply:y},k.name))}),O.jsxs("div",{className:"mp-agent-form-proposal-actions",children:[(s||l)&&O.jsxs("div",{className:"mp-agent-form-proposal-status",children:[O.jsx("span",{className:`mp-agent-form-proposal-badge ${s?"is-applied":"is-rejected"}`,children:s?"Applied":"Rejected"}),o.at?O.jsx("span",{className:"mp-agent-form-proposal-status-time",children:O.jsx(B7,{date:o.at})}):null]}),!d&&!u?null:O.jsxs(O.Fragment,{children:[O.jsx("button",{type:"button",disabled:!d,onClick:h,className:"mp-agent-form-proposal-reject",children:"Reject"}),O.jsx("button",{type:"button",disabled:!u,onClick:_,className:"mp-agent-form-proposal-apply-all",children:"Apply all"})]})]})]})},_o=e=>{const{id:t,name:n,url:r,capturedAt:a,source:i,security:o,target:s,kind:l,...u}=e,d=r??i?.url,p=i||d?{...i??{},...d?{url:d}:{}}:void 0,m=l==="webSnippet"||l==="formSnapshot"||l==="formField"?!0:void 0,h=o||(m!==void 0?{containsPII:m,redactionsApplied:[]}:void 0),g=typeof n=="string"&&n.trim().length?n.trim():l==="webSnippet"?u?.title?`Selection: ${String(u.title)}`:"Selection":l==="formField"?"Form field":l==="formSnapshot"?"Form snapshot":"Context";return{id:t??Tt.nanoid(),type:exports.AgentAttachmentType.Context,name:g,...d?{url:d}:{},metadata:{schemaVersion:1,kind:l,capturedAt:a??new Date().toISOString(),...p?{source:p}:{},...h?{security:h}:{},...s?{target:s}:{},...u}}},Z8e=e=>{try{const t=new URL(e),n=`${t.searchParams.toString()} ${t.hash}`.toLowerCase();return/(token|key|auth|session|code|password|secret|email)/.test(n)}catch{return/(token|key|auth|session|code|password|secret|email)/.test(e.toLowerCase())}},G5=(e={})=>{if(typeof window>"u")return;const t=e.url??window.location?.href;if(!t)return;const n=e.includeTitle!==!1,r=e.includeReferrer!==!1,a=e.includeViewport!==!1,i=e.includeUserAgent===!0,o=n&&typeof document<"u"?document.title:void 0,s=r&&typeof document<"u"?document.referrer:void 0;let l;try{l=new URL(t)}catch{}const u={url:t,...l?{origin:l.origin,pathname:l.pathname,search:l.search,hash:l.hash}:{},...n&&o?{title:o}:{},...r&&s?{referrer:s}:{},...i&&typeof navigator<"u"?{userAgent:navigator.userAgent}:{},...typeof navigator<"u"&&navigator.language?{language:navigator.language}:{},...typeof Intl<"u"?{timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,locale:Intl.DateTimeFormat().resolvedOptions().locale}:{},...a&&typeof window<"u"?{viewport:{width:window.innerWidth,height:window.innerHeight,devicePixelRatio:window.devicePixelRatio}}:{},...e.extra?e.extra:{}},d=Z8e(t)?!0:void 0;return _o({kind:"pageContext",name:e.name??"Page context",url:t,title:o,summary:l?`${l.pathname}${l.search}${l.hash}`:void 0,data:u,source:{app:"browser",url:t,route:l?`${l.pathname}${l.search}${l.hash}`:void 0},...d?{security:{containsPII:!0,redactionsApplied:[]}}:{}})},W5=()=>{if(typeof window>"u"||typeof document>"u")return;const e=window.getSelection?.();if(!e||e.rangeCount===0)return;const t=e.getRangeAt(0),n=e.toString().trim();if(!n)return;const r=(t.commonAncestorContainer.nodeType===Node.ELEMENT_NODE?t.commonAncestorContainer:t.commonAncestorContainer.parentElement)??void 0,a=r?X8e(r):void 0,i=r?.textContent??"",o=i.indexOf(n),s=o>=0?o:void 0,l=o>=0?o+n.length:void 0,u=o>=0?i.slice(Math.max(0,o-80),o).trim():void 0,d=o>=0?i.slice(o+n.length,o+n.length+80).trim():void 0;return{selectedText:n,target:{type:"text",exact:n,...u?{prefix:u}:{},...d?{suffix:d}:{},...a?{domPath:a}:{},...s!==void 0?{startOffset:s}:{},...l!==void 0?{endOffset:l}:{}}}},X8e=e=>{if(e.id)return`#${i2(e.id)}`;const t=[];let n=e;for(;n&&n.nodeType===1&&t.length<6;){const r=n.tagName.toLowerCase();if(n.id){t.unshift(`#${i2(n.id)}`);break}const a=n.parentElement;if(!a){t.unshift(r);break}const o=Array.from(a.children).filter(s=>s.tagName===n.tagName).indexOf(n)+1;t.unshift(`${r}:nth-of-type(${o})`),n=a}return t.join(" > ")},i2=e=>e.replace(/[^a-zA-Z0-9_-]/g,"\\$&");class K5{constructor(t){this.rawConfig=t,this.events=new EventTarget;const n=td.parse(t);this.config={...n,toolRenderers:t.toolRenderers,tools:t.tools,pageContext:t.pageContext?{...n.pageContext,...t.pageContext}:n.pageContext,translations:t.translations?{...Fi,...t.translations}:Fi},this.transport=this.createTransport(this.config.transport),this.tools=new $7(this.config.tools),this.tools.bindInvoke(this.invokeTool.bind(this)),this.configureTransportAfterCreate(this.transport),Object.entries(t.toolRenderers??{}).forEach(([r,a])=>{a&&this.toolRendererMap.set(r,a)}),this.toolRendererMap.has("propose_form_values")||this.toolRendererMap.set("propose_form_values",Y8e),this.queryClient=new io.QueryClient({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1}}})}config;transport;tools;queryClient;events;toolRendererMap=new Map;storeRef;pageContextProviders=new Set;createTransport(t){return t.mode==="proxy"?new jr(t):new Wo(t)}configureTransportAfterCreate(t){this.config.transport.mode==="direct"&&t instanceof Wo&&(t.setToolRegistry(this.tools),t.setContextKeys(this.config.contextKeys.map(n=>({key:n.key,tools:n.tools}))),this.config.models&&t.setModels(this.config.models),t.setUntitledChatText(this.config.translations.untitledChat))}updateTransportConfig(t){const n=td.parse({...this.rawConfig,transport:t}),r=this.config.transport,a=this.transport;this.rawConfig={...this.rawConfig,transport:t},this.config.transport=n.transport;const i=this.config.transport.mode;if(r.mode!==i){a.cancelStream?.(),this.transport=this.createTransport(this.config.transport),this.configureTransportAfterCreate(this.transport),this.events.dispatchEvent(new CustomEvent("runtime:transport-config-changed",{detail:{previous:r,next:this.config.transport}}));return}i==="proxy"&&a instanceof jr?a.updateConfig(this.config.transport):i==="direct"&&a instanceof Wo?(a.updateConfig(this.config.transport),this.configureTransportAfterCreate(a)):(a.cancelStream?.(),this.transport=this.createTransport(this.config.transport),this.configureTransportAfterCreate(this.transport)),this.events.dispatchEvent(new CustomEvent("runtime:transport-config-changed",{detail:{previous:r,next:this.config.transport}}))}setTransportHeaders(t){const n=this.config.transport;this.updateTransportConfig({...n,headers:t})}mergeTransportHeaders(t){const n=this.config.transport;this.updateTransportConfig({...n,headers:{...n.headers??{},...t}})}removeTransportHeaders(t){const n=this.config.transport;if(!n.headers||t.length===0)return;const r={...n.headers};for(const a of t)delete r[a];this.updateTransportConfig({...n,headers:Object.keys(r).length?r:void 0})}get defaultContextKey(){return this.config.defaultContextKey??this.config.contextKeys[0]?.key}get store(){if(!this.storeRef)throw new Error("AgentRuntime store has not been attached yet");return this.storeRef}attachStore(t){this.storeRef=t}registerTool(t){this.tools.register(t)}registerToolRenderer(t,n){this.toolRendererMap.set(t,n)}registerPageContextProvider(t){return this.pageContextProviders.add(t),()=>{this.pageContextProviders.delete(t)}}getPageContextInput(){if(typeof window>"u")return{};const t=window.location?.href;let n;if(t)try{const a=new URL(t);n=`${a.pathname}${a.search}${a.hash}`}catch{}const r=typeof document<"u"?document.title:void 0;return{url:t,route:n,title:r}}getPageContextData(t){const n=t??this.getPageContextInput(),r={};let a=!1;const i=this.config.pageContext?.getData;if(i)try{const o=i(n);o&&typeof o=="object"&&(Object.assign(r,o),a=!0)}catch{}for(const o of this.pageContextProviders)try{const s=o(n);s&&typeof s=="object"&&(Object.assign(r,s),a=!0)}catch{}return a?r:void 0}buildPageContextAttachment(){const t=this.config.pageContext,n=this.getPageContextData();return G5({...t?.includeUserAgent!==void 0?{includeUserAgent:t.includeUserAgent}:{},...t?.includeReferrer!==void 0?{includeReferrer:t.includeReferrer}:{},...t?.includeViewport!==void 0?{includeViewport:t.includeViewport}:{},...t?.includeTitle!==void 0?{includeTitle:t.includeTitle}:{},...t?.name?{name:t.name}:{},...n?{extra:n}:{}})}getToolRenderer(t){return this.toolRendererMap.get(t.name)}ensureStore(t){if(!this.storeRef)throw new Error(`Cannot ${t} before AgentRuntime is mounted`);return this.storeRef}resolveChatId(t){const r=this.ensureStore("invoke tools").getState(),a=t?.chatId??r.activeChatId;if(!a||!r.chats[a])throw new Error("Tool invocation requires an active chat. Select or create a chat first.");return a}buildToolContext(t){const n=this.ensureStore("create tool context");return{chatId:t,agentId:this.config.appId,workspaceId:this.config.workspaceId,appendSystemMessage:r=>{n.getState().appendSystemMessage(t,r)}}}writeToolCall(t,n){this.ensureStore("write tool call").getState().upsertToolCall(t,{...n})}async invokeTool(t,n={},r){const a=this.resolveChatId(r),i={id:Tt.nanoid(),name:t,input:n,status:exports.AgentToolCallStatus.Running};this.writeToolCall(a,i);const o=this.buildToolContext(a);try{const s=await this.tools.execute(t,n,o,i);return this.writeToolCall(a,s),s}catch(s){const l={...i,status:exports.AgentToolCallStatus.Failed,error:s instanceof Error?s.message:"Unknown tool error"};throw this.writeToolCall(a,l),s}}}const Q8e={background:"#050505",surface:"#0f0f11",text:"#f7f7f7",subtext:"#8f9baa",border:"#1f2229",accent:"#6c63ff",accentSoft:"rgba(108, 99, 255, 0.14)",warning:"#ffb347",danger:"#ff5f56",fontFamily:'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',radius:"12px",fontSize:"14px"},Y5=e=>({...Q8e,...e}),Z5=ee.createContext(Y5()),J8e=e=>({"--mp-agents-bg":e.background,"--mp-agents-surface":e.surface,"--mp-agents-text":e.text,"--mp-agents-subtext":e.subtext,"--mp-agents-border":e.border,"--mp-agents-accent":e.accent,"--mp-agents-accent-soft":e.accentSoft,"--mp-agents-warning":e.warning,"--mp-agents-danger":e.danger,"--mp-agents-radius":e.radius,"--mp-agents-font-size":e.fontSize}),X5=({value:e,children:t})=>{const n=ee.useMemo(()=>Y5(e),[e]);return O.jsxs(Z5.Provider,{value:n,children:[O.jsx("style",{children:`:root {
8320
8320
  ${Object.entries(J8e(n)).map(([r,a])=>`${r}: ${a};`).join(`
8321
8321
  `)}
8322
- }`}),t]})},e7e=()=>ee.useContext(Z5),ti=e=>e.type===exports.AgentAttachmentType.Context&&e?.metadata?.kind==="pageContext";var an=(e=>(e.Idle="idle",e.Sending="sending",e.Streaming="streaming",e))(an||{});const t7e=e=>Gk.create()((t,n)=>({contextKey:e,activeChatId:void 0,draftChatKey:`draft-${Tt.nanoid()}`,chats:{},reasoningByChat:{},artifactsByChat:{},messageQueueByChat:{},pendingAssistantByChat:{},isChatHistoryOpen:!1,composerDraftByChat:{},composerErrorByChat:{},pageContextDismissedByChatKey:{},composer:{temperature:.4},statusByChat:{},setContextKey:r=>t({contextKey:r}),setActiveChat:r=>{t(a=>{let i=a.contextKey,o;if(r){const l=a.chats[r];l?.contextKey&&(i=l.contextKey),o=l?.model}return{activeChatId:r,contextKey:i,composer:r?{...a.composer,model:o}:a.composer}})},upsertChat:r=>t(a=>{const i=a.activeChatId===r.id;return{chats:{...a.chats,[r.id]:r},...i?{composer:{...a.composer,model:r.model}}:{}}}),hydrateChats:r=>t(a=>{const i={};r.forEach(l=>{i[l.id]=l});const o=a.activeChatId&&i[a.activeChatId]?a.activeChatId:r[0]?.id,s=o?i[o]:void 0;return{chats:i,activeChatId:o,composer:{...a.composer,model:s?.model}}}),removeChat:r=>t(a=>{if(!a.chats[r])return a;const{[r]:i,...o}=a.chats,{[r]:s,...l}=a.reasoningByChat,{[r]:u,...d}=a.artifactsByChat,{[r]:p,...m}=a.pendingAssistantByChat,{[r]:h,...g}=a.messageQueueByChat,{[r]:y,..._}=a.statusByChat,{[r]:v,...k}=a.pageContextDismissedByChatKey,w=a.activeChatId===r;return{chats:o,statusByChat:_,reasoningByChat:l,artifactsByChat:d,messageQueueByChat:g,pendingAssistantByChat:m,pageContextDismissedByChatKey:k,...w?{activeChatId:void 0}:{}}}),pushReasoning:(r,a)=>t(i=>({reasoningByChat:{...i.reasoningByChat,[r]:[...i.reasoningByChat[r]??[],a]}})),consumeStreamChunk:(r,a)=>t(i=>{if(!a.message)return i;const o=i.chats[r];if(!o)return i;const s=o.messages.filter(l=>l.id!==a.message.id);return s.push(a.message),{chats:{...i.chats,[r]:{...o,messages:s}}}}),setArtifacts:(r,a)=>t(i=>({artifactsByChat:{...i.artifactsByChat,[r]:a}})),setComposerOptions:r=>t(a=>({composer:{...a.composer,...r}})),setComposerDraft:(r,a)=>t(i=>({composerDraftByChat:{...i.composerDraftByChat,[r]:{value:a.value??"",attachments:a.attachments??[]}}})),setComposerValue:(r,a)=>t(i=>{const o=i.composerDraftByChat[r]??{value:"",attachments:[]};return{composerDraftByChat:{...i.composerDraftByChat,[r]:{...o,value:a}}}}),addComposerAttachments:(r,a)=>t(i=>{const o=i.composerDraftByChat[r]??{value:"",attachments:[]};if(!a||a.length===0)return i;const s=o.attachments??[],l=s.find(ti),u=a.find(ti);if(u){const m=a.filter(v=>!ti(v)),h=s.filter(v=>!ti(v)),y=[l?{...u,id:l.id}:u,...m,...h],_=new Map;for(const v of y)_.set(v.id,v);return{composerDraftByChat:{...i.composerDraftByChat,[r]:{...o,attachments:Array.from(_.values())}}}}const d=[...a,...s],p=new Map;for(const m of d)p.set(m.id,m);return{composerDraftByChat:{...i.composerDraftByChat,[r]:{...o,attachments:Array.from(p.values())}}}}),removeComposerAttachment:(r,a)=>t(i=>{const o=i.composerDraftByChat[r];return o?{composerDraftByChat:{...i.composerDraftByChat,[r]:{...o,attachments:o.attachments.filter(s=>s.id!==a)}}}:i}),clearComposerDraft:r=>t(a=>({composerDraftByChat:{...a.composerDraftByChat,[r]:{value:"",attachments:[]}}})),setComposerError:(r,a)=>t(i=>({composerErrorByChat:{...i.composerErrorByChat,[r]:a}})),setPageContextDismissed:(r,a)=>t(i=>({pageContextDismissedByChatKey:{...i.pageContextDismissedByChatKey,[r]:a}})),setChatStatus:(r,a)=>t(i=>({statusByChat:{...i.statusByChat,[r]:a}})),setPendingAssistant:(r,a)=>t(i=>({pendingAssistantByChat:{...i.pendingAssistantByChat,[r]:a}})),commitPendingAssistant:r=>t(a=>{const i=a.pendingAssistantByChat[r];if(!i)return a;const o=a.chats[r];if(!o)return{pendingAssistantByChat:{...a.pendingAssistantByChat,[r]:void 0}};const l=typeof i.content=="string"&&i.content.trim().length>0?(()=>{if(o.messages[o.messages.length-1]?.id===i.id)return o.messages;const d={...i,chat:r};return[...o.messages,d]})():o.messages;return{chats:{...a.chats,[r]:{...o,messages:l}},pendingAssistantByChat:{...a.pendingAssistantByChat,[r]:void 0}}}),enqueueQueuedMessage:(r,a,i)=>t(o=>{const s={id:Tt.nanoid(),content:a,...i&&i.length>0?{attachments:i}:{},createdAt:new Date().toISOString()},l=o.messageQueueByChat[r]??[];return{messageQueueByChat:{...o.messageQueueByChat,[r]:[...l,s]}}}),removeQueuedMessage:(r,a)=>t(i=>{const o=i.messageQueueByChat[r];if(!o||o.length===0)return i;const s=o.filter(l=>l.id!==a);return{messageQueueByChat:{...i.messageQueueByChat,[r]:s}}}),moveChatKeyState:(r,a)=>t(i=>{if(r===a)return i;const o=i.messageQueueByChat[r]??[],s=i.messageQueueByChat[a]??[],l=i.pendingAssistantByChat[r],u=i.statusByChat[r],d=i.composerDraftByChat[r],p=i.composerDraftByChat[a],m=i.composerErrorByChat[r],h=i.composerErrorByChat[a],g=i.pageContextDismissedByChatKey[r],y=i.pageContextDismissedByChatKey[a];return o.length>0||!!l||u!==void 0&&u!=="idle"||!!d||!!m?{messageQueueByChat:{...i.messageQueueByChat,[r]:[],...o.length>0?{[a]:[...s,...o]}:{}},pendingAssistantByChat:{...i.pendingAssistantByChat,...l?{[a]:l}:{},[r]:void 0},statusByChat:{...i.statusByChat,...u?{[a]:u}:{},[r]:"idle"},composerDraftByChat:{...i.composerDraftByChat,...d&&!p?{[a]:d}:{},[r]:{value:"",attachments:[]}},composerErrorByChat:{...i.composerErrorByChat,...m&&!h?{[a]:m}:{},[r]:void 0},pageContextDismissedByChatKey:{...i.pageContextDismissedByChatKey,...g!==void 0&&y===void 0?{[a]:g}:{},[r]:!1}}:i}),appendSystemMessage:(r,a)=>t(i=>{const o=i.chats[r];if(!o)return i;const s={id:Tt.nanoid(),chat:r,content:a,role:exports.MessageRole.System,createdAt:new Date().toISOString()};return{chats:{...i.chats,[r]:{...o,messages:[...o.messages,s]}}}}),upsertToolCall:(r,a)=>t(i=>{const o=i.chats[r];if(!o)return i;const s=[...o.messages],l=s.findIndex(u=>u.role===exports.MessageRole.Tool&&u.toolCalls?.some(d=>d.id===a.id));if(l>=0){const u=s[l],d=(u.toolCalls??[]).map(p=>p.id===a.id?a:p);s[l]={...u,toolCalls:d}}else s.push({id:`tool-${a.id}`,chat:r,role:exports.MessageRole.Tool,content:"",createdAt:new Date().toISOString(),toolCalls:[a]});return{chats:{...i.chats,[r]:{...o,messages:s}}}}),setChatHistoryOpen:r=>t({isChatHistoryOpen:r}),toggleChatHistory:()=>t(r=>({isChatHistoryOpen:!r.isChatHistoryOpen}))})),o2="mp-agent-selected-model",ha="__auto__";function Q5(e){return e.mode==="direct"?`${o2}-${e.mode}-${e.provider}`:`${o2}-${e.mode}`}function s2(e,t){try{const n=Q5(e);localStorage.setItem(n,t)}catch(n){console.warn("Failed to save selected model to localStorage:",n)}}function n7e(e){try{const t=Q5(e);return localStorage.getItem(t)}catch(t){return console.warn("Failed to load selected model from localStorage:",t),null}}function J5(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 r7e(e,t,n){const r=n7e(t);if(r){if(r===ha)return;if(J5(e,t).some(i=>i.id===r))return r}}const Tn=Object.create(null);Tn.open="0";Tn.close="1";Tn.ping="2";Tn.pong="3";Tn.message="4";Tn.upgrade="5";Tn.noop="6";const Ti=Object.create(null);Object.keys(Tn).forEach(e=>{Ti[Tn[e]]=e});const cd={type:"error",data:"parser error"},e3=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",t3=typeof ArrayBuffer=="function",n3=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Qd=({type:e,data:t},n,r)=>e3&&t instanceof Blob?n?r(t):l2(t,r):t3&&(t instanceof ArrayBuffer||n3(t))?n?r(t):l2(new Blob([t]),r):r(Tn[e]+(t||"")),l2=(e,t)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];t("b"+(r||""))},n.readAsDataURL(e)};function c2(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let ss;function a7e(e,t){if(e3&&e.data instanceof Blob)return e.data.arrayBuffer().then(c2).then(t);if(t3&&(e.data instanceof ArrayBuffer||n3(e.data)))return t(c2(e.data));Qd(e,!1,n=>{ss||(ss=new TextEncoder),t(ss.encode(n))})}const u2="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ma=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<u2.length;e++)ma[u2.charCodeAt(e)]=e;const i7e=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=ma[e.charCodeAt(r)],o=ma[e.charCodeAt(r+1)],s=ma[e.charCodeAt(r+2)],l=ma[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},o7e=typeof ArrayBuffer=="function",Jd=(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)}:Ti[n]?e.length>1?{type:Ti[n],data:e.substring(1)}:{type:Ti[n]}:cd},s7e=(e,t)=>{if(o7e){const n=i7e(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}},a3="",l7e=(e,t)=>{const n=e.length,r=new Array(n);let a=0;e.forEach((i,o)=>{Qd(i,!1,s=>{r[o]=s,++a===n&&t(r.join(a3))})})},c7e=(e,t)=>{const n=e.split(a3),r=[];for(let a=0;a<n.length;a++){const i=Jd(n[a],t);if(r.push(i),i.type==="error")break}return r};function u7e(){return new TransformStream({transform(e,t){a7e(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 ls;function ni(e){return e.reduce((t,n)=>t+n.length,0)}function ri(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 d7e(e,t){ls||(ls=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(ni(n)<1)break;const l=ri(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(ni(n)<2)break;const l=ri(n,2);a=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),r=3}else if(r===2){if(ni(n)<8)break;const l=ri(n,8),u=new DataView(l.buffer,l.byteOffset,l.length),d=u.getUint32(0);if(d>Math.pow(2,21)-1){s.enqueue(cd);break}a=d*Math.pow(2,32)+u.getUint32(4),r=3}else{if(ni(n)<a)break;const l=ri(n,a);s.enqueue(Jd(i?l:ls.decode(l),t)),r=0}if(a===0||a>e){s.enqueue(cd);break}}}})}const i3=4;function bt(e){if(e)return p7e(e)}function p7e(e){for(var t in bt.prototype)e[t]=bt.prototype[t];return e}bt.prototype.on=bt.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};bt.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this};bt.prototype.off=bt.prototype.removeListener=bt.prototype.removeAllListeners=bt.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};bt.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};bt.prototype.emitReserved=bt.prototype.emit;bt.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};bt.prototype.hasListeners=function(e){return!!this.listeners(e).length};const wo=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0),on=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),h7e="arraybuffer";function o3(e,...t){return t.reduce((n,r)=>(e.hasOwnProperty(r)&&(n[r]=e[r]),n),{})}const m7e=on.setTimeout,f7e=on.clearTimeout;function xo(e,t){t.useNativeTimers?(e.setTimeoutFn=m7e.bind(on),e.clearTimeoutFn=f7e.bind(on)):(e.setTimeoutFn=on.setTimeout.bind(on),e.clearTimeoutFn=on.clearTimeout.bind(on))}const g7e=1.33;function y7e(e){return typeof e=="string"?b7e(e):Math.ceil((e.byteLength||e.size)*g7e)}function b7e(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 s3(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function k7e(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function v7e(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 _7e extends Error{constructor(t,n,r){super(t),this.description=n,this.context=r,this.type="TransportError"}}class ep extends bt{constructor(t){super(),this.writable=!1,xo(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 _7e(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=Jd(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=k7e(t);return n.length?"?"+n:""}}class w7e extends ep{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)};c7e(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,l7e(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]=s3()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}let l3=!1;try{l3=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const x7e=l3;function E7e(){}class M7e extends w7e{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 An extends bt{constructor(t,n,r){super(),this.createRequest=t,xo(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=o3(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=An.requestsCount++,An.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=E7e,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete An.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()}}An.requestsCount=0;An.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",d2);else if(typeof addEventListener=="function"){const e="onpagehide"in on?"pagehide":"unload";addEventListener(e,d2,!1)}}function d2(){for(let e in An.requests)An.requests.hasOwnProperty(e)&&An.requests[e].abort()}const S7e=function(){const e=c3({xdomain:!1});return e&&e.responseType!==null}();class N7e extends M7e{constructor(t){super(t);const n=t&&t.forceBase64;this.supportsBinary=S7e&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new An(c3,this.uri(),t)}}function c3(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||x7e))return new XMLHttpRequest}catch{}if(!t)try{return new on[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const u3=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class A7e extends ep{get name(){return"websocket"}doOpen(){const t=this.uri(),n=this.opts.protocols,r=u3?{}:o3(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;Qd(r,this.supportsBinary,i=>{try{this.doWrite(r,i)}catch{}a&&wo(()=>{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]=s3()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}}const cs=on.WebSocket||on.MozWebSocket;class T7e extends A7e{createSocket(t,n,r){return u3?new cs(t,n,r):n?new cs(t,n):new cs(t)}doWrite(t,n){this.ws.send(n)}}class C7e extends ep{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=d7e(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),a=u7e();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&&wo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const R7e={websocket:T7e,webtransport:C7e,polling:N7e},I7e=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,O7e=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ud(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=I7e.exec(e||""),i={},o=14;for(;o--;)i[O7e[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=L7e(i,i.path),i.queryKey=D7e(i,i.query),i}function L7e(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 D7e(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,a,i){a&&(n[a]=i)}),n}const dd=typeof addEventListener=="function"&&typeof removeEventListener=="function",Ci=[];dd&&addEventListener("offline",()=>{Ci.forEach(e=>e())},!1);class ir extends bt{constructor(t,n){if(super(),this.binaryType=h7e,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=ud(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=ud(n.host).host);xo(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=v7e(this.opts.query)),dd&&(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"})},Ci.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const n=Object.assign({},this.opts.query);n.EIO=i3,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&&ir.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",ir.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+=y7e(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,wo(()=>{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(ir.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(),dd&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=Ci.indexOf(this._offlineEventListener);r!==-1&&Ci.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}}ir.protocol=i3;class z7e extends ir{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;ir.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;ir.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 $7e=class extends z7e{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=>R7e[a]).filter(a=>!!a)),super(t,r)}};function F7e(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=ud(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 P7e=typeof ArrayBuffer=="function",B7e=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,d3=Object.prototype.toString,q7e=typeof Blob=="function"||typeof Blob<"u"&&d3.call(Blob)==="[object BlobConstructor]",U7e=typeof File=="function"||typeof File<"u"&&d3.call(File)==="[object FileConstructor]";function tp(e){return P7e&&(e instanceof ArrayBuffer||B7e(e))||q7e&&e instanceof Blob||U7e&&e instanceof File}function Ri(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,r=e.length;n<r;n++)if(Ri(e[n]))return!0;return!1}if(tp(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Ri(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&Ri(e[n]))return!0;return!1}function H7e(e){const t=[],n=e.data,r=e;return r.data=pd(n,t),r.attachments=t.length,{packet:r,buffers:t}}function pd(e,t){if(!e)return e;if(tp(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]=pd(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]=pd(e[r],t));return n}return e}function j7e(e,t){return e.data=hd(e.data,t),delete e.attachments,e}function hd(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]=hd(e[n],t);else if(typeof e=="object")for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=hd(e[n],t));return e}const V7e=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],G7e=5;var Ke;(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"})(Ke||(Ke={}));class W7e{constructor(t){this.replacer=t}encode(t){return(t.type===Ke.EVENT||t.type===Ke.ACK)&&Ri(t)?this.encodeAsBinary({type:t.type===Ke.EVENT?Ke.BINARY_EVENT:Ke.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===Ke.BINARY_EVENT||t.type===Ke.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=H7e(t),r=this.encodeAsString(n.packet),a=n.buffers;return a.unshift(r),a}}function p2(e){return Object.prototype.toString.call(e)==="[object Object]"}class np extends bt{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===Ke.BINARY_EVENT;r||n.type===Ke.BINARY_ACK?(n.type=r?Ke.EVENT:Ke.ACK,this.reconstructor=new K7e(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(tp(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(Ke[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===Ke.BINARY_EVENT||r.type===Ke.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(np.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 Ke.CONNECT:return p2(n);case Ke.DISCONNECT:return n===void 0;case Ke.CONNECT_ERROR:return typeof n=="string"||p2(n);case Ke.EVENT:case Ke.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&V7e.indexOf(n[0])===-1);case Ke.ACK:case Ke.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class K7e{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=j7e(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const Y7e=Object.freeze(Object.defineProperty({__proto__:null,Decoder:np,Encoder:W7e,get PacketType(){return Ke},protocol:G7e},Symbol.toStringTag,{value:"Module"}));function fn(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const Z7e=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class p3 extends bt{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=[fn(t,"open",this.onopen.bind(this)),fn(t,"packet",this.onpacket.bind(this)),fn(t,"error",this.onerror.bind(this)),fn(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(Z7e.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:Ke.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:Ke.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 Ke.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 Ke.EVENT:case Ke.BINARY_EVENT:this.onevent(t);break;case Ke.ACK:case Ke.BINARY_ACK:this.onack(t);break;case Ke.DISCONNECT:this.ondisconnect();break;case Ke.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:Ke.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:Ke.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 ea(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}ea.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};ea.prototype.reset=function(){this.attempts=0};ea.prototype.setMin=function(e){this.ms=e};ea.prototype.setMax=function(e){this.max=e};ea.prototype.setJitter=function(e){this.jitter=e};class md extends bt{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,xo(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 ea({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||Y7e;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 $7e(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const a=fn(n,"open",function(){r.onopen(),t&&t()}),i=s=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",s),t?t(s):this.maybeReconnectOnOpen()},o=fn(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(fn(t,"ping",this.onping.bind(this)),fn(t,"data",this.ondata.bind(this)),fn(t,"error",this.onerror.bind(this)),fn(t,"close",this.onclose.bind(this)),fn(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){wo(()=>{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 p3(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 la={};function Ii(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const n=F7e(e,t.path||"/socket.io"),r=n.source,a=n.id,i=n.path,o=la[a]&&i in la[a].nsps,s=t.forceNew||t["force new connection"]||t.multiplex===!1||o;let l;return s?l=new md(r,t):(la[a]||(la[a]=new md(r,t)),l=la[a]),n.query&&!t.query&&(t.query=n.queryKey),l.socket(n.path,t)}Object.assign(Ii,{Manager:md,Socket:p3,io:Ii,connect:Ii});const h2="mp-agents-guest-user-id";function rp(){if(typeof window>"u")return`${Pi.DefaultUserId}-${Tt.nanoid()}`;const e=localStorage.getItem(h2);if(e)return e;const t=`${Pi.DefaultUserId}-${Tt.nanoid()}`;return localStorage.setItem(h2,t),t}const X7e=ee.createContext(null),Q7e=({children:e})=>{const t=vt(),{upsertChat:n,contextKey:r}=Fe(h=>({upsertChat:h.upsertChat,contextKey:h.contextKey})),a=ee.useMemo(()=>t.config.user?.id??rp(),[t.config.user?.id]),i=t.config.transport,[o,s]=ee.useState(null),[l,u]=ee.useState(void 0),d=ee.useRef(r),p=ee.useRef(n);ee.useEffect(()=>{d.current=r,p.current=n},[r,n]),ee.useEffect(()=>{if(i.mode!=="proxy"){s(null),u(void 0),t.transport instanceof jr&&t.transport.setSocketId(void 0);return}const h=i.baseUrl,g=new URL(h,window.location.origin),y=`${g.protocol}//${g.host}`,_={},v=i;v.headers&&Object.assign(_,v.headers);const k={},w=v.apiKey&&`Bearer ${v.apiKey}`||v.headers?.Authorization||v.headers?.authorization;w&&(k.authorization=w,_.Authorization=w);const M=i.path??Pi.Path,S=Ii(y,{path:M,auth:k,transports:["websocket","polling"],...Object.keys(_).length>0&&{extraHeaders:_}});s(S);const E=()=>{u(S.id),t.transport instanceof jr&&t.transport.setSocketId(S.id)},F=()=>{u(void 0),t.transport instanceof jr&&t.transport.setSocketId(void 0)},P=W=>{W.contextKey===d.current&&p.current(W)},C=W=>{const J=t.store.getState().chats[W.chat];if(!J)return;const V=J.messages.findIndex(R=>R.id===W.id);if(V>=0){const R=[...J.messages];R[V]=W,p.current({...J,messages:R});return}p.current({...J,messages:[...J.messages,W]})},D=W=>{const J=t.store.getState().chats[W.id];p.current({...W,messages:J?J.messages:[]})};return S.on("connect",E),S.on("disconnect",F),S.on("connect_error",W=>{console.error("Socket.IO connection error:",W)}),S.on(Si.ChatNew,P),S.on(Si.MessageNew,C),S.on(Si.ChatUpdate,D),()=>{t.transport instanceof jr&&t.transport.setSocketId(void 0),u(void 0),s(null),S.disconnect()}},[t,t.transport,i.mode,i.mode==="proxy"?i.baseUrl:void 0,i.mode==="proxy"?i.apiKey:void 0,i.mode==="proxy"?i.path:void 0,i.mode==="proxy"?JSON.stringify(i.headers??{}):"",a]);const m=ee.useMemo(()=>({socket:o,socketId:l}),[o,l]);return O.jsx(X7e.Provider,{value:m,children:e})},ap=ee.createContext(null),J7e=({config:e,children:t})=>{const n=ee.useRef();n.current||(n.current=new K5(e));const[,r]=ee.useState(0);ee.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=ee.useRef();if(!a.current){const o=n.current.defaultContextKey??n.current.config.contextKeys[0]?.key??"default";a.current=t7e(o),n.current.attachStore(a.current);const s=r7e(n.current.config.models,n.current.config.transport);a.current.getState().setComposerOptions({model:s})}const i=ee.useMemo(()=>({runtime:n.current,store:a.current}),[]);return O.jsx(ap.Provider,{value:i,children:O.jsx(io.QueryClientProvider,{client:i.runtime.queryClient,children:O.jsx(X5,{value:i.runtime.config.theme,children:O.jsx(Q7e,{children:t})})})})},vt=()=>{const e=ee.useContext(ap);if(!e)throw new Error("useAgentRuntime must be used inside <AgentProvider />");return e.runtime},Fe=e=>{const t=ee.useContext(ap);if(!t)throw new Error("useAgentStore must be used inside <AgentProvider />");return Gk.useStore(t.store,e)},h3=()=>{const e=vt(),{hydrateChats:t}=Fe(a=>({hydrateChats:a.hydrateChats})),n=e.config.user?.id??rp(),r=io.useQuery({queryKey:["mp-agents","chats",n],queryFn:()=>e.transport.listChats({userId:n}),enabled:!!n});return ee.useEffect(()=>{r.data&&t(r.data)},[r.data,t]),r},m3=(e={},t=[])=>{const{threshold:n=50,scrollOnMount:r=!0}=e,a=ee.useRef(null),i=ee.useRef(null),[o,s]=ee.useState(!0),l=ee.useRef(!1),u=ee.useRef(!1),d=ee.useRef(),p=ee.useCallback(()=>{const g=a.current;if(!g)return!1;const{scrollTop:y,scrollHeight:_,clientHeight:v}=g;return _-y-v<=n},[n]),m=ee.useCallback(()=>{const g=a.current,y=i.current;!g||!y||y.scrollIntoView({behavior:"auto",block:"end"})},[]),h=ee.useCallback(()=>{const g=p();s(g),g&&(l.current=!1)},[p]);return ee.useEffect(()=>{const g=a.current;if(!g)return;let y=g.scrollTop,_;const v=()=>{const k=g.scrollTop;if(!u.current){const w=k<y,M=k>y;(w||M&&!p())&&(l.current=!0)}y=k,h(),_&&clearTimeout(_),_=window.setTimeout(()=>{u.current=!1},150)};return g.addEventListener("scroll",v,{passive:!0}),()=>{g.removeEventListener("scroll",v),_&&clearTimeout(_)}},[p,h]),ee.useEffect(()=>{const g=a.current;if(!g)return;const y=new MutationObserver(()=>{!l.current&&o&&(d.current&&cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{u.current=!0,m(),setTimeout(()=>{u.current=!1},50)})),h()});return y.observe(g,{childList:!0,subtree:!0,characterData:!0,attributes:!1}),()=>{y.disconnect(),d.current&&cancelAnimationFrame(d.current)}},[o,m,h]),ee.useEffect(()=>{t.length!==0&&!l.current&&o&&(d.current&&cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{u.current=!0,m(),setTimeout(()=>{u.current=!1},50)}))},[...t]),ee.useEffect(()=>{if(r&&a.current){const g=window.setTimeout(()=>{u.current=!0,m(),setTimeout(()=>{u.current=!1},50)},100);return()=>{clearTimeout(g)}}},[r,m]),{containerRef:a,sentinelRef:i,isNearBottom:o,scrollToBottom:m,checkIsNearBottom:p}},f3=()=>{const e=vt();return io.useQuery({queryKey:["mp-agents","models"],queryFn:async()=>e.transport.listModels?await e.transport.listModels():[],staleTime:5*60*1e3,refetchOnWindowFocus:!1})},g3=()=>{const e=Fe(s=>s.activeChatId??s.draftChatKey),t=Fe(s=>s.composerDraftByChat[e]??{value:"",attachments:[]}),n=Fe(s=>s.setComposerValue),r=Fe(s=>s.setComposerDraft),a=Fe(s=>s.clearComposerDraft),i=Fe(s=>s.addComposerAttachments),o=Fe(s=>s.removeComposerAttachment);return{chatKey:e,draft:t,setValue:s=>n(e,s),setDraft:s=>r(e,s),clearDraft:()=>a(e),addAttachments:s=>i(e,s),removeAttachment:s=>o(e,s)}},Mr=()=>vt().config.translations??Fi,e_e=(e,t=[])=>{const n=vt(),r=ee.useRef(e),a=ee.useCallback(e,t);r.current=a;const i=ee.useCallback(o=>r.current(o),[]);ee.useEffect(()=>n.registerPageContextProvider(i),[n,i])},t_e=({initialSystemPrompt:e,composerFormRef:t})=>{const n=vt(),{statusByChat:r,composer:a,contextKey:i,activeChatId:o,draftChatKey:s,messageQueueByChat:l,setPageContextDismissed:u,setChatStatus:d,upsertChat:p,setActiveChat:m,setPendingAssistant:h,commitPendingAssistant:g,setComposerError:y,enqueueQueuedMessage:_,removeQueuedMessage:v,moveChatKeyState:k}=Fe(T=>({statusByChat:T.statusByChat,composer:T.composer,contextKey:T.contextKey,activeChatId:T.activeChatId,draftChatKey:T.draftChatKey,messageQueueByChat:T.messageQueueByChat,setPageContextDismissed:T.setPageContextDismissed,setChatStatus:T.setChatStatus,upsertChat:T.upsertChat,setActiveChat:T.setActiveChat,setPendingAssistant:T.setPendingAssistant,commitPendingAssistant:T.commitPendingAssistant,setComposerError:T.setComposerError,enqueueQueuedMessage:T.enqueueQueuedMessage,removeQueuedMessage:T.removeQueuedMessage,moveChatKeyState:T.moveChatKeyState})),w=ee.useCallback(T=>!T||T.length===0?!1:T.some(Y=>Y.type===exports.AgentAttachmentType.Context&&Y?.metadata?.kind==="pageContext"),[]),M=ee.useRef(!1),S=ee.useRef(!1),E=ee.useRef(new Set),F=ee.useRef(void 0),P=o??s,C=l[P]??[],D=r[P]??an.Idle,W=ee.useCallback(async(T,Y)=>{if(!n.transport.generateTitle)return;const N=n.config.features?.titleGeneration==="llm"?"llm":"local";let Z;try{Z=await n.transport.generateTitle({userId:Y,content:T,strategy:N,contextKey:i})}catch{}return Z},[n.transport,n.config.features?.titleGeneration,i]),K=ee.useCallback(async(T,Y)=>{const N=n.config.user?.id??"guest",Z=!o,te=o??s,I={current:te};F.current=te;const pe={value:T,attachments:Y??[]};y(I.current,void 0);let ge;if(Z){const we=await W(T,N);we&&we.trim().length>0&&(ge={...ge??{},title:we})}const Ce=(o?n.store.getState().chats[o]:void 0)?.model,Be=a.model!==Ce;let He,re=!1;Be?(He=a.model,re=!0):Ce?(He=Ce,re=!1):(He=void 0,re=!1);const Me={userId:N,content:T,metadata:ge,contextKey:i,...Z?{}:{chatId:o},...re?{model:He}:{},...Y&&Y.length>0?{attachments:Y}:{}},Ge=()=>{h(I.current,void 0)},Je=we=>{if(we?.name==="AbortError"){const ke=F.current??I.current;return E.current.has(ke)?(g(I.current),E.current.delete(ke)):(Ge(),t.current.setDraft(pe)),{type:"aborted"}}throw we},qe=async()=>{let we=`pending-${Date.now()}`,ke="",Le;d(I.current,an.Streaming),h(I.current,{id:we,chat:o||"",content:"",role:exports.MessageRole.Assistant,createdAt:new Date().toISOString(),reasoning:"",toolCalls:[],attachments:[]});try{let de=o;const et=await n.transport.streamMessage(Me,Te=>{if(Te.type===exports.StreamChunkType.Chat&&Te.chat){p({...Te.chat,messages:[]}),de=Te.chat.id,Z&&(F.current=Te.chat.id,k(I.current,Te.chat.id),I.current=Te.chat.id,m(Te.chat.id));return}if(Te.type===exports.StreamChunkType.Reasoning&&Te.reasoning){ke+=Te.reasoning,Le={...Le??{id:we,chat:de,role:exports.MessageRole.Assistant,content:"",createdAt:new Date().toISOString()},reasoning:ke},h(I.current,Le);return}if(Te.type===exports.StreamChunkType.Error&&Te.error)throw new Error(Te.error);Te.message&&Te.message.role===exports.MessageRole.User||Te.message&&(we=Te.message.id,Le={...Te.message,reasoning:ke||Te.message.reasoning},h(I.current,Le))},{streamKey:F.current});if(et){const Te=ke&&Le?{...et,messages:et.messages.map(_e=>_e.id===Le.id&&_e.role===exports.MessageRole.Assistant?{..._e,reasoning:ke}:_e)}:et;return p(Te),(n.store.getState().activeChatId??n.store.getState().draftChatKey)===I.current&&m(Te.id),Ge(),{type:"success"}}return Ge(),{type:"success"}}catch(de){return Je(de)}};try{const we=await qe();return we.type==="success"&&(S.current=!1),we}catch(we){Ge();const ke=we?.chat;ke&&(p(ke),m(ke.id));const Le=we instanceof Error?we:new Error("Failed to send message");return y(I.current,Le.message||"Failed to send message"),t.current.setDraft(pe),S.current=!1,{type:"error",error:Le}}finally{M.current=!1,d(I.current,an.Idle),F.current=void 0}},[o,i,a.model,n.transport,n.config.user?.id,p,m,h,d,W,e,k,t,y]),J=ee.useCallback(async()=>{if(D!==an.Idle||M.current||!C.length||S.current)return;const T=C[0];M.current=!0,v(P,T.id);try{await K(T.content,T.attachments)}finally{M.current=!1}},[D,C,P,K,v]);ee.useEffect(()=>{J()},[J]);const V=ee.useCallback(async T=>{if(M.current)return;const Y=C.find(N=>N.id===T);if(Y){S.current=!1,M.current=!0,v(P,T);try{await K(Y.content,Y.attachments)}finally{M.current=!1}}},[C,P,v,K]),R=ee.useCallback(async T=>{const N=t.current.getDraft().attachments;if(w(N)&&u(P,!0),D!==an.Idle){_(P,T,N),t.current.clearDraft();return}S.current=!1,t.current.clearDraft(),await K(T,N)},[D,_,P,K,t,w,u]),q=ee.useCallback(()=>{S.current=!0;const T=F.current??P;E.current.add(T),n.transport.cancelStream?.(T),g(T),d(T,an.Idle)},[P,n.transport,g,d]),G=ee.useCallback(async T=>{D===an.Streaming&&q(),await V(T)},[D,q,V]);return{pendingKey:P,queuedMessages:C,activeChatStatus:D,activeChatId:o,removeQueuedMessage:v,handleSubmit:R,handleStop:q,handleQueuedClick:G}},n_e=({queuedMessages:e,onSendQueued:t,onRemoveQueued:n})=>e.length?O.jsxs("div",{className:"mp-agent-composer-queue",children:[O.jsx("div",{className:"mp-agent-composer-queue-header",children:O.jsxs("span",{children:[e.length," message",e.length>1?"s":""," queued"]})}),O.jsx("div",{className:"mp-agent-composer-queue-items",children:e.map(r=>O.jsxs("div",{className:"mp-agent-composer-queue-item",children:[O.jsxs("span",{className:"mp-agent-composer-queue-item-text",children:[r.content,r.attachments?.length?O.jsxs("span",{style:{marginLeft:8,opacity:.7,display:"inline-flex",alignItems:"center",gap:4},children:[O.jsx(lo,{size:12}),r.attachments.length]}):null]}),O.jsxs("div",{className:"mp-agent-composer-queue-item-actions",children:[O.jsx("button",{type:"button",className:"mp-agent-composer-queue-button",onClick:()=>t(r.id),"aria-label":"Send queued message",children:O.jsx(Hd,{size:12})}),O.jsx("button",{type:"button",className:"mp-agent-composer-queue-button",onClick:()=>n(r.id),"aria-label":"Remove queued message",children:O.jsx(s5,{size:12})})]})]},r.id))})]}):null,r_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]=ee.useState(!1),[h,g]=ee.useState(null),[y,_]=ee.useState(""),v=ee.useRef([]),k=ee.useRef(null),{refs:w,floatingStyles:M,context:S,isPositioned:E}=U5({open:p,onOpenChange:m,placement:s,strategy:"absolute",whileElementsMounted:O5,middleware:[D5(8),$5({fallbackPlacements:["top-start","bottom-start","top-end","bottom-end"]}),z5({padding:8})]}),F=P8e(S,{enabled:!a}),P=q5(S),C=j5(S),W=V8e(S,{listRef:v,activeIndex:h,onNavigate:g,enabled:p&&!l,virtual:!1}),{getReferenceProps:K,getFloatingProps:J,getItemProps:V}=H5(l?[F,P,C]:[F,P,C,W]),R=e.findIndex(Z=>Z.value===t),q=R>=0?e[R]:void 0,G=ee.useMemo(()=>{const Z=y.trim().toLowerCase();if(!l||!Z)return e;const I=d?pe=>d(pe,Z):pe=>`${pe.label} ${pe.description??""}`.toLowerCase().includes(Z);return e.filter(I)},[e,y,l,d]);ee.useEffect(()=>{if(!p){g(null),_("");return}l&&setTimeout(()=>k.current?.focus(),0);const Z=G.findIndex(te=>te.value===t);g(Z>=0?Z:0)},[p,l,t,G]),ee.useEffect(()=>{p&&g(G.length>0?0:null)},[y,G.length,p]);const T=Z=>G.length===0?null:Z<0?G.length-1:Z>=G.length?0:Z,Y=Z=>{Z!=null&&v.current[Z]?.scrollIntoView({block:"nearest"})},N=Z=>{n(Z),m(!1),g(null),_("")};return O.jsxs("div",{className:`mp-agent-dropdown ${i}`,children:[O.jsxs("button",{ref:w.setReference,type:"button",className:`mp-agent-dropdown-trigger ${o}`,disabled:a,"aria-expanded":p,"aria-haspopup":"listbox",...K(),children:[O.jsx("span",{className:"mp-agent-dropdown-trigger-content",children:q?O.jsxs(O.Fragment,{children:[q.icon&&O.jsx("span",{className:"mp-agent-dropdown-trigger-icon",children:q.icon}),O.jsx("span",{className:"mp-agent-dropdown-trigger-label",children:q.label})]}):O.jsx("span",{className:"mp-agent-dropdown-trigger-placeholder",children:r})}),O.jsx(n5,{size:16,className:`mp-agent-dropdown-chevron ${p?"open":""}`})]}),p&&O.jsxs("div",{role:"listbox",ref:w.setFloating,style:{...M,opacity:E?1:0,pointerEvents:E?"auto":"none",transition:E?"opacity 0.15s ease-out":"none"},className:"mp-agent-dropdown-menu",...J(),children:[l&&O.jsx("div",{className:"mp-agent-dropdown-search",onKeyDown:Z=>Z.stopPropagation(),children:O.jsx("input",{ref:k,className:"mp-agent-dropdown-search-input",value:y,placeholder:u,onChange:Z=>_(Z.target.value),onKeyDown:Z=>{if(Z.key==="Escape"){Z.preventDefault(),m(!1),_("");return}if(Z.key==="ArrowDown"||Z.key==="ArrowUp"){Z.preventDefault();const te=Z.key==="ArrowDown"?1:-1,I=h??(te>0?-1:0),pe=T(I+te);g(pe),Y(pe);return}if(Z.key==="Enter"){if(h==null)return;const te=G[h];if(!te)return;Z.preventDefault(),N(te.value)}}})}),O.jsxs("div",{className:"mp-agent-dropdown-list",children:[G.map((Z,te)=>O.jsxs("button",{ref:I=>{v.current[te]=I},type:"button",className:`mp-agent-dropdown-item ${t===Z.value?"selected":""} ${h===te?"active":""}`,role:"option","aria-selected":t===Z.value,...V({onClick:()=>N(Z.value),onMouseEnter:()=>{g(te)},onKeyDown:I=>{(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),N(Z.value))}}),children:[Z.icon&&O.jsx("span",{className:"mp-agent-dropdown-item-icon",children:Z.icon}),O.jsxs("span",{className:"mp-agent-dropdown-item-content",children:[O.jsx("span",{className:"mp-agent-dropdown-item-label",children:Z.label}),Z.description&&O.jsx("span",{className:"mp-agent-dropdown-item-description",children:Z.description})]})]},Z.value)),l&&G.length===0&&O.jsx("div",{className:"mp-agent-dropdown-empty","aria-label":"No results",children:"No results"})]})]})]})},a_e=ee.memo(()=>{const e=vt(),{contextKey:t,composer:n,setComposerOptions:r}=Fe(p=>({contextKey:p.contextKey,composer:p.composer,setComposerOptions:p.setComposerOptions})),a=e.config.models,{data:i,isLoading:o}=f3(),s=ee.useMemo(()=>{const p=i&&i.length>0?i:a;return J5(p,e.config.transport).filter(h=>!h.contexts?.length||h.contexts.includes(t))},[i,a,e.config.transport,t]),l=ee.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:ha,label:"Auto"},...p]},[s]),u=ee.useMemo(()=>n.model!==void 0?n.model:ha,[n.model]),d=ee.useCallback(p=>{p===ha?(r({model:void 0}),s2(e.config.transport,ha)):(r({model:p}),s2(e.config.transport,p))},[r,e.config.transport]);return o&&!a?.length||l.length===0?null:O.jsx(r_e,{options:l,value:u,onChange:d,placeholder:"Select model...",searchable:!0,searchPlaceholder:"Search models...",placement:"top-start",triggerClassName:"mp-agent-model-selector-trigger"})}),i_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)},o_e=e=>{try{const t=new URL(e);return t.hostname+(t.pathname&&t.pathname!=="/"?t.pathname:"")}catch{return e}};function s_e(e,t){return e.size>t.maxFileSize?{type:"size",message:`File "${e.name}" exceeds maximum size of ${ip(t.maxFileSize)}`,fileName:e.name}:null}function l_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=s_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 ${ip(n.maxTotalAttachmentsSize)}`}:null}function ip(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 c_e(){return{maxFileSize:10*1024*1024,maxTotalAttachmentsSize:50*1024*1024,maxFilesPerMessage:10,allowedMimeTypes:void 0}}const y3=e=>{switch(e.type){case exports.AgentAttachmentType.Link:return O.jsx(i5,{size:12});case exports.AgentAttachmentType.Artifact:return O.jsx(lo,{size:12});case exports.AgentAttachmentType.Context:switch(e?.metadata?.kind){case"pageContext":return O.jsx(jd,{size:12});case"formSnapshot":case"formField":return O.jsx(a5,{size:12});default:return O.jsx(Vd,{size:12})}case exports.AgentAttachmentType.File:default:return O.jsx(r5,{size:12})}},u_e=({attachments:e})=>!e||e.length===0?null:O.jsx("div",{className:"mp-agent-message-attachments","aria-label":"Message attachments",children:e.map(t=>{const n=O.jsxs(O.Fragment,{children:[O.jsx("span",{className:"mp-agent-message-attachment-icon",children:y3(t)}),O.jsx("span",{className:"mp-agent-message-attachment-name",children:t.name})]});return t.url?O.jsx("a",{className:"mp-agent-message-attachment",href:t.url,target:"_blank",rel:"noreferrer",title:t.url,children:n},t.id):O.jsx("span",{className:"mp-agent-message-attachment",title:t.mimeType??t.name,children:n},t.id)})}),d_e=({attachments:e,onRemove:t,uploadProgress:n,uploadErrors:r})=>{const a=Mr();return!e||e.length===0?null:O.jsx("div",{className:"mp-agent-composer-attachments","aria-label":a.attachments,children:e.map(i=>{const o=n?.get(i.id),s=r?.get(i.name),l=i.metadata?.size||i.size,u=l?` (${ip(l)})`:"";return O.jsxs("span",{className:`mp-agent-attachment-chip ${s?"mp-agent-attachment-chip-error":""} ${o?.status==="uploading"?"mp-agent-attachment-chip-uploading":""}`,title:s||i.name,children:[O.jsx("span",{className:"mp-agent-attachment-chip-icon",children:y3(i)}),O.jsxs("span",{className:"mp-agent-attachment-chip-name",title:i.name,children:[i.name,u]}),o?.status==="uploading"&&O.jsxs("span",{className:"mp-agent-attachment-chip-progress",children:[o.progress,"%"]}),s&&O.jsx("span",{className:"mp-agent-attachment-chip-error-text",title:s,children:"⚠"}),t?O.jsx(ar,{size:"sm",icon:"X",type:"button",onClick:d=>{d.preventDefault(),d.stopPropagation(),t(i.id)},"aria-label":`Remove attachment ${i.name}`}):null]},i.id)})})};async function p_e(e,t,n,r){const a=await fetch(r.presignedUrlEndpoint,{method:"POST",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 h_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 m_e(e,t,n){const r=Tt.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 p_e(e,n.chatId,n.userId,t);return await h_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 f_e(e,t,n){const r=await Promise.allSettled(e.map(o=>m_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 fd="mp-agent:locationchange",m2="__mp_agent_history_patched__",f2=()=>{try{window.dispatchEvent(new Event(fd))}catch{}},g_e=()=>{if(typeof window>"u")return;const e=window;if(!e[m2]){e[m2]=!0;try{const t=history.pushState;history.pushState=function(...n){const r=t.apply(this,n);return f2(),r}}catch{}try{const t=history.replaceState;history.replaceState=function(...n){const r=t.apply(this,n);return f2(),r}}catch{}}},y_e=e=>{if(typeof window>"u")return()=>{};g_e();const t=()=>e();return window.addEventListener("popstate",t),window.addEventListener("hashchange",t),window.addEventListener(fd,t),()=>{window.removeEventListener("popstate",t),window.removeEventListener("hashchange",t),window.removeEventListener(fd,t)}},b_e=ee.forwardRef(({autoFocus:e,activeChatId:t,status:n,onStop:r,onSubmit:a},i)=>{const o=Mr(),s=vt(),l=ee.useRef(null),u=ee.useRef(null),d=Fe(re=>re.activeChatId??re.draftChatKey),p=Fe(re=>re.composerDraftByChat[d]??{value:"",attachments:[]}),m=Fe(re=>re.composerErrorByChat[d]),h=Fe(re=>re.pageContextDismissedByChatKey[d]??!1),g=Fe(re=>re.setComposerValue),y=Fe(re=>re.setComposerDraft),_=Fe(re=>re.clearComposerDraft),v=Fe(re=>re.setComposerError),k=Fe(re=>re.addComposerAttachments),w=Fe(re=>re.removeComposerAttachment),M=Fe(re=>re.setPageContextDismissed),S=p.value,E=p.attachments,[F,P]=ee.useState(new Map),[C,D]=ee.useState(new Map),W=ee.useRef(S),K=ee.useRef(E),J=ee.useRef(h),V=s.config.features?.pageContextAttachments!==!1,R=re=>re.type===exports.AgentAttachmentType.Context&&re?.metadata?.kind==="pageContext",q=E.some(R),G=()=>{if(V)return s.buildPageContextAttachment()};ee.useEffect(()=>{K.current=E},[E]),ee.useEffect(()=>{W.current=S},[S]),ee.useEffect(()=>{J.current=h},[h]),ee.useEffect(()=>{if(!V||h||q)return;const re=G();re&&k(d,[re])},[V,h,q,d,k]),ee.useEffect(()=>{if(V&&!(typeof window>"u"))return y_e(()=>{if(J.current)return;const re=K.current,Me=re.find(R);if(!Me)return;const Ge=G();if(!Ge)return;const Je={...Ge,id:Me.id},qe=re.map(we=>we.id===Me.id?Je:we);y(d,{value:W.current,attachments:qe})})},[V,d,y]),ee.useImperativeHandle(i,()=>({setValue:re=>{g(d,re)},getDraft:()=>({value:S,attachments:E}),setDraft:re=>{y(d,{value:re.value,attachments:re.attachments??[]})},clearDraft:()=>{_(d)}})),ee.useEffect(()=>{const re=l.current;re&&(re.style.height="auto",re.style.height=`${Math.min(re.scrollHeight,200)}px`)},[S]);const T=async re=>{if(!re||re.length===0)return;const Me=Array.from(re),Ge=c_e(),Je=l_e(Me,E,Ge);if(Je){D(qe=>{const we=new Map(qe);return Me.forEach(ke=>{we.set(ke.name,Je.message)}),we});return}D(qe=>{const we=new Map(qe);return Me.forEach(ke=>we.delete(ke.name)),we});try{const qe=s.config.transport;if(qe.mode!=="proxy")throw new Error("File uploads are only supported with proxy transport");const we={presignedUrlEndpoint:`${qe.baseUrl}/files/upload/presigned`,getAuthHeaders:()=>{const Le={};return qe.apiKey&&(Le.Authorization=`Bearer ${qe.apiKey}`),Le}},ke=await f_e(Me,we,{chatId:t,userId:s.config.user?.id,onProgress:Le=>{P(de=>{const et=new Map(de);return et.set(Le.fileId,Le),et})}});k(d,ke),setTimeout(()=>{P(Le=>{const de=new Map(Le);return ke.forEach(et=>de.delete(et.id)),de})},2e3)}catch(qe){const we=qe instanceof Error?qe.message:"Failed to upload files";D(ke=>{const Le=new Map(ke);return Me.forEach(de=>{Le.set(de.name,we)}),Le})}},Y=()=>{u.current?.click()},N=re=>{const Me=i_e(re);if(!Me)return!1;if(E.some(qe=>qe.type===exports.AgentAttachmentType.Link&&qe.url===Me))return!0;const Ge=o_e(Me),Je={id:Tt.nanoid(),url:Me,name:Ge,type:exports.AgentAttachmentType.Link};return k(d,[Je]),!0},Z=async re=>{await T(re.target.files),re.target.value=""},te=re=>{const Me=E.find(Ge=>Ge.id===re);Me&&R(Me)&&M(d,!0),w(d,re)},I=()=>{if(typeof window>"u"||typeof document>"u")return!1;const re=W5(),Me=re?.selectedText??window.getSelection?.()?.toString()?.trim()??"";if(!Me)return!1;const Ge=window.location?.href,Je=Me.slice(0,20),qe=Me.length>20?Je+"...":Me,we=_o({kind:"webSnippet",url:Ge,title:qe,selectedText:Me,source:{app:"browser",url:Ge},...re?.target?{target:re.target}:{}});return k(d,[we]),!0},pe=re=>{re.preventDefault();const Me=S.trim();Me&&(v(d,void 0),a(Me))},ge=re=>{re.key==="Enter"&&!re.shiftKey&&(re.preventDefault(),pe(re))},ve=re=>{m&&v(d,void 0),g(d,re.target.value)},Ce=re=>{if(re.nativeEvent.shiftKey)return;const Me=re.clipboardData?.getData("text/plain")??"";if(!Me)return;N(Me)&&re.preventDefault()},He=!!S.trim();return O.jsxs("form",{onSubmit:pe,className:"mp-agent-composer-input-wrapper",children:[O.jsx("input",{ref:u,type:"file",multiple:!0,style:{display:"none"},onChange:Z}),O.jsx(d_e,{attachments:E,onRemove:te,uploadProgress:F,uploadErrors:C}),O.jsx("textarea",{rows:2,name:"message",ref:l,value:S,autoFocus:e,className:"mp-agent-composer-textarea",placeholder:t?o.followUp:o.newChat,onChange:ve,onKeyDown:ge,onPaste:Ce}),O.jsxs("div",{className:"mp-agent-composer-actions",children:[O.jsxs("div",{className:"mp-agent-composer-actions-left",children:[s.config.features?.modelSwitching&&O.jsx(a_e,{}),O.jsx(Jn,{content:o.attachFiles,children:O.jsx("button",{type:"button",className:"mp-agent-composer-button mp-agent-composer-tool-button",onClick:Y,"aria-label":o.attachFiles,children:O.jsx(lo,{size:16})})}),O.jsx(Jn,{content:o.attachSelectionToContext,children:O.jsx("button",{type:"button",className:"mp-agent-composer-button mp-agent-composer-tool-button",onClick:()=>{I()},"aria-label":o.attachSelectionToContext,children:O.jsx(Vd,{size:16})})}),V&&!q&&O.jsx(Jn,{content:"Attach page context",children:O.jsx("button",{type:"button",className:"mp-agent-composer-button mp-agent-composer-tool-button",onClick:()=>{M(d,!1);const re=G();re&&k(d,[re])},"aria-label":"Attach page context",children:O.jsx(jd,{size:16})})})]}),O.jsx("div",{className:"mp-agent-composer-actions-right",children:n===an.Streaming&&!He?O.jsx(Jn,{content:o.stopStreaming,children:O.jsx("button",{type:"button",onClick:r,"aria-label":o.stopStreaming,className:"mp-agent-composer-button mp-agent-composer-send-button",children:O.jsx(o5,{size:12})})}):O.jsx(Jn,{content:He?o.sendMessage:o.typeMessageToSend,children:O.jsx("button",{type:"submit",disabled:!He,"aria-label":o.sendMessage,className:"mp-agent-composer-button mp-agent-composer-send-button",children:O.jsx(Hd,{size:16})})})})]}),m?O.jsx("div",{className:"mp-agent-composer-error",children:m}):null]})}),b3=({autoFocus:e})=>{const t=ee.useRef({setValue:()=>{},getDraft:()=>({value:"",attachments:[]}),setDraft:()=>{},clearDraft:()=>{}}),{pendingKey:n,queuedMessages:r,activeChatStatus:a,activeChatId:i,handleSubmit:o,handleStop:s,handleQueuedClick:l,removeQueuedMessage:u}=t_e({composerFormRef:t});return O.jsx("div",{className:"mp-agent-composer-wrapper",children:O.jsxs("div",{className:"mp-agent-composer",children:[O.jsx(n_e,{queuedMessages:r,onSendQueued:l,onRemoveQueued:d=>u(n,d)}),O.jsx(b_e,{status:a,ref:t,autoFocus:e,activeChatId:i,onStop:s,onSubmit:o})]})})},k_e=()=>{const e=vt(),t=e.config.user?.id??rp(),{activeChatId:n,setActiveChat:r,removeChat:a}=Fe(u=>({activeChatId:u.activeChatId,setActiveChat:u.setActiveChat,removeChat:u.removeChat})),[i,o]=ee.useState(new Set),s=ee.useCallback(async u=>{o(d=>new Set(d).add(u));try{await e.transport.deleteChat(u),a(u),n===u&&r(void 0),e.queryClient.invalidateQueries({queryKey:["mp-agents","chats",t]})}finally{o(d=>{const p=new Set(d);return p.delete(u),p})}},[n,a,e.queryClient,e.transport,r,t]),l=ee.useCallback(u=>i.has(u),[i]);return{deleteChat:s,isDeleting:l}},v_e=()=>{const e=Mr(),{deleteChat:t,isDeleting:n}=k_e(),{chats:r,activeChatId:a,setActiveChat:i}=Fe(s=>({chats:s.chats,activeChatId:s.activeChatId,setActiveChat:s.setActiveChat})),o=ee.useMemo(()=>Object.values(r).sort((s,l)=>s.updatedAt===l.updatedAt?0:s.updatedAt<l.updatedAt?1:-1),[r]);return O.jsxs("section",{className:"mp-agent-chat-history",children:[O.jsx("h4",{children:e.chats}),o.length===0?O.jsx("div",{className:"mp-agent-chat-history-empty",children:e.noChatsYet}):O.jsx("ul",{className:"mp-agent-chat-history-list",children:o.map(s=>{const l=s.id===a;return O.jsxs("li",{onClick:()=>i(s.id),className:`mp-agent-chat-history-item${l?" active":""}`,children:[O.jsxs("div",{className:"mp-agent-chat-history-item-content",children:[O.jsx("span",{className:"mp-agent-chat-history-item-title",children:s.title||e.untitledChat}),O.jsx("span",{className:"mp-agent-chat-history-item-meta",children:new Date(s.updatedAt).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),O.jsx("div",{className:"mp-agent-chat-history-item-actions",children:O.jsx(Jn,{content:e.deleteChat,children:O.jsx(ar,{size:"sm",icon:"Archive","aria-label":e.deleteChat,disabled:n(s.id),onClick:u=>{u.stopPropagation(),t(s.id)}})})})]},s.id)})})]})},__e=e=>{const t=vt(),n=Fe(a=>a.isChatHistoryOpen);return!(t.config.features?.historySidebar!==!1)||!n?null:O.jsx("div",{className:"mp-agent-chat-history-panel",children:O.jsx(v_e,{})})},w_e=({onClose:e})=>{const t=Mr(),r=vt().config.features?.historySidebar!==!1,{isChatHistoryOpen:a,setChatHistoryOpen:i,setActiveChat:o}=Fe(l=>({isChatHistoryOpen:l.isChatHistoryOpen,setActiveChat:l.setActiveChat,setChatHistoryOpen:l.setChatHistoryOpen})),s=()=>{o(void 0)};return O.jsxs("div",{className:"mp-agent-agent-controls",children:[O.jsxs("div",{className:"mp-agent-agent-controls-left",children:[r&&O.jsx(ar,{onClick:()=>i(!a),icon:a?"PanelLeftClose":"PanelLeftOpen",tooltip:a?t.hideChatHistory:t.showChatHistory,"aria-label":a?t.hideChatHistory:t.showChatHistory}),O.jsx(ar,{onClick:s,icon:"SquarePen","aria-label":t.newChat,tooltip:t.newChat})]}),t.panelTitle&&O.jsx("div",{className:"mp-agent-agent-controls-title",children:O.jsx("h4",{children:t.panelTitle})}),e&&O.jsx("div",{className:"mp-agent-agent-controls-right",children:O.jsx(ar,{onClick:e,icon:"X","aria-label":t.close,tooltip:t.close})})]})},x_e=({children:e})=>{const t=Fe(n=>n.isChatHistoryOpen);return O.jsx("section",{className:`mp-agent-main ${t?"with-chat-history":""}`,children:e})},k3=ee.memo(({role:e,isGrouped:t})=>{if(t)return O.jsx("div",{className:"mp-agent-message-avatar-spacer"});const n=e===exports.MessageRole.User,r=n?"You":"AI";return O.jsx("div",{className:`mp-agent-message-avatar ${n?"mp-agent-message-avatar-user":""}`,children:O.jsx("div",{className:"mp-agent-message-avatar-icon",children:r})})});k3.displayName="MessageAvatar";const E_e=e=>e?new Date(e).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}):"",v3=ee.memo(({role:e,createdAt:t,isGrouped:n})=>{if(n)return null;const a=e===exports.MessageRole.User?"You":"Assistant";return O.jsxs("div",{className:"mp-agent-message-header",children:[O.jsx("span",{className:"mp-agent-message-role",children:a}),O.jsx("span",{className:"mp-agent-message-time",children:E_e(t)})]})});v3.displayName="MessageHeader";function g2(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 M_e(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const S_e=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,N_e=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,A_e={};function y2(e,t){return(A_e.jsx?N_e:S_e).test(e)}const T_e=/[ \t\n\f\r]/g;function C_e(e){return typeof e=="object"?e.type==="text"?b2(e.value):!1:b2(e)}function b2(e){return e.replace(T_e,"")===""}let Ua=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Ua.prototype.normal={};Ua.prototype.property={};Ua.prototype.space=void 0;function _3(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Ua(n,r,t)}function Ta(e){return e.toLowerCase()}let Vt=class{constructor(t,n){this.attribute=n,this.property=t}};Vt.prototype.attribute="";Vt.prototype.booleanish=!1;Vt.prototype.boolean=!1;Vt.prototype.commaOrSpaceSeparated=!1;Vt.prototype.commaSeparated=!1;Vt.prototype.defined=!1;Vt.prototype.mustUseProperty=!1;Vt.prototype.number=!1;Vt.prototype.overloadedBoolean=!1;Vt.prototype.property="";Vt.prototype.spaceSeparated=!1;Vt.prototype.space=void 0;let R_e=0;const De=Sr(),yt=Sr(),gd=Sr(),ce=Sr(),it=Sr(),Kr=Sr(),Yt=Sr();function Sr(){return 2**++R_e}const yd=Object.freeze(Object.defineProperty({__proto__:null,boolean:De,booleanish:yt,commaOrSpaceSeparated:Yt,commaSeparated:Kr,number:ce,overloadedBoolean:gd,spaceSeparated:it},Symbol.toStringTag,{value:"Module"})),us=Object.keys(yd);let op=class extends Vt{constructor(t,n,r,a){let i=-1;if(super(t,n),k2(this,"space",a),typeof r=="number")for(;++i<us.length;){const o=us[i];k2(this,us[i],(r&yd[o])===yd[o])}}};op.prototype.defined=!0;function k2(e,t,n){n&&(e[t]=n)}function ta(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const i=new op(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[Ta(r)]=r,n[Ta(i.attribute)]=r}return new Ua(t,n,e.space)}const w3=ta({properties:{ariaActiveDescendant:null,ariaAtomic:yt,ariaAutoComplete:null,ariaBusy:yt,ariaChecked:yt,ariaColCount:ce,ariaColIndex:ce,ariaColSpan:ce,ariaControls:it,ariaCurrent:null,ariaDescribedBy:it,ariaDetails:null,ariaDisabled:yt,ariaDropEffect:it,ariaErrorMessage:null,ariaExpanded:yt,ariaFlowTo:it,ariaGrabbed:yt,ariaHasPopup:null,ariaHidden:yt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:it,ariaLevel:ce,ariaLive:null,ariaModal:yt,ariaMultiLine:yt,ariaMultiSelectable:yt,ariaOrientation:null,ariaOwns:it,ariaPlaceholder:null,ariaPosInSet:ce,ariaPressed:yt,ariaReadOnly:yt,ariaRelevant:null,ariaRequired:yt,ariaRoleDescription:it,ariaRowCount:ce,ariaRowIndex:ce,ariaRowSpan:ce,ariaSelected:yt,ariaSetSize:ce,ariaSort:null,ariaValueMax:ce,ariaValueMin:ce,ariaValueNow:ce,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 E3(e,t){return x3(e,t.toLowerCase())}const I_e=ta({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Kr,acceptCharset:it,accessKey:it,action:null,allow:null,allowFullScreen:De,allowPaymentRequest:De,allowUserMedia:De,alt:null,as:null,async:De,autoCapitalize:null,autoComplete:it,autoFocus:De,autoPlay:De,blocking:it,capture:null,charSet:null,checked:De,cite:null,className:it,cols:ce,colSpan:null,content:null,contentEditable:yt,controls:De,controlsList:it,coords:ce|Kr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:De,defer:De,dir:null,dirName:null,disabled:De,download:gd,draggable:yt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:De,formTarget:null,headers:it,height:ce,hidden:gd,high:ce,href:null,hrefLang:null,htmlFor:it,httpEquiv:it,id:null,imageSizes:null,imageSrcSet:null,inert:De,inputMode:null,integrity:null,is:null,isMap:De,itemId:null,itemProp:it,itemRef:it,itemScope:De,itemType:it,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:De,low:ce,manifest:null,max:null,maxLength:ce,media:null,method:null,min:null,minLength:ce,multiple:De,muted:De,name:null,nonce:null,noModule:De,noValidate:De,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:De,optimum:ce,pattern:null,ping:it,placeholder:null,playsInline:De,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:De,referrerPolicy:null,rel:it,required:De,reversed:De,rows:ce,rowSpan:ce,sandbox:it,scope:null,scoped:De,seamless:De,selected:De,shadowRootClonable:De,shadowRootDelegatesFocus:De,shadowRootMode:null,shape:null,size:ce,sizes:null,slot:null,span:ce,spellCheck:yt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ce,step:null,style:null,tabIndex:ce,target:null,title:null,translate:null,type:null,typeMustMatch:De,useMap:null,value:yt,width:ce,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:it,axis:null,background:null,bgColor:null,border:ce,borderColor:null,bottomMargin:ce,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:De,declare:De,event:null,face:null,frame:null,frameBorder:null,hSpace:ce,leftMargin:ce,link:null,longDesc:null,lowSrc:null,marginHeight:ce,marginWidth:ce,noResize:De,noHref:De,noShade:De,noWrap:De,object:null,profile:null,prompt:null,rev:null,rightMargin:ce,rules:null,scheme:null,scrolling:yt,standby:null,summary:null,text:null,topMargin:ce,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ce,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:De,disableRemotePlayback:De,prefix:null,property:null,results:ce,security:null,unselectable:null},space:"html",transform:E3}),O_e=ta({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:Yt,accentHeight:ce,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ce,amplitude:ce,arabicForm:null,ascent:ce,attributeName:null,attributeType:null,azimuth:ce,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ce,by:null,calcMode:null,capHeight:ce,className:it,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:ce,diffuseConstant:ce,direction:null,display:null,dur:null,divisor:ce,dominantBaseline:null,download:De,dx:null,dy:null,edgeMode:null,editable:null,elevation:ce,enableBackground:null,end:null,event:null,exponent:ce,externalResourcesRequired:null,fill:null,fillOpacity:ce,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:Kr,g2:Kr,glyphName:Kr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ce,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ce,horizOriginX:ce,horizOriginY:ce,id:null,ideographic:ce,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ce,k:ce,k1:ce,k2:ce,k3:ce,k4:ce,kernelMatrix:Yt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ce,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:ce,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:ce,overlineThickness:ce,paintOrder:null,panose1:null,path:null,pathLength:ce,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:it,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ce,pointsAtY:ce,pointsAtZ:ce,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Yt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Yt,rev:Yt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Yt,requiredFeatures:Yt,requiredFonts:Yt,requiredFormats:Yt,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:ce,specularExponent:ce,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ce,strikethroughThickness:ce,string:null,stroke:null,strokeDashArray:Yt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ce,strokeOpacity:ce,strokeWidth:null,style:null,surfaceScale:ce,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Yt,tabIndex:ce,tableValues:null,target:null,targetX:ce,targetY:ce,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Yt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ce,underlineThickness:ce,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ce,values:null,vAlphabetic:ce,vMathematical:ce,vectorEffect:null,vHanging:ce,vIdeographic:ce,version:null,vertAdvY:ce,vertOriginX:ce,vertOriginY:ce,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ce,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:x3}),M3=ta({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()}}),S3=ta({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:E3}),N3=ta({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),L_e={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"},D_e=/[A-Z]/g,v2=/-[a-z]/g,z_e=/^data[-\w.:]+$/i;function A3(e,t){const n=Ta(t);let r=t,a=Vt;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&z_e.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(v2,F_e);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!v2.test(i)){let o=i.replace(D_e,$_e);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}a=op}return new a(r,t)}function $_e(e){return"-"+e.toLowerCase()}function F_e(e){return e.charAt(1).toUpperCase()}const T3=_3([w3,I_e,M3,S3,N3],"html"),Eo=_3([w3,O_e,M3,S3,N3],"svg");function _2(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function P_e(e){return e.join(" ").trim()}var sp={},w2=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,B_e=/\n/g,q_e=/^\s*/,U_e=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,H_e=/^:\s*/,j_e=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,V_e=/^[;\s]*/,G_e=/^\s+|\s+$/g,W_e=`
8322
+ }`}),t]})},e7e=()=>ee.useContext(Z5),ti=e=>e.type===exports.AgentAttachmentType.Context&&e?.metadata?.kind==="pageContext";var an=(e=>(e.Idle="idle",e.Sending="sending",e.Streaming="streaming",e))(an||{});const t7e=e=>Gk.create()((t,n)=>({contextKey:e,activeChatId:void 0,draftChatKey:`draft-${Tt.nanoid()}`,chats:{},reasoningByChat:{},artifactsByChat:{},messageQueueByChat:{},pendingAssistantByChat:{},isChatHistoryOpen:!1,composerDraftByChat:{},composerErrorByChat:{},pageContextDismissedByChatKey:{},composer:{temperature:.4},statusByChat:{},setContextKey:r=>t({contextKey:r}),setActiveChat:r=>{t(a=>{let i=a.contextKey,o;if(r){const l=a.chats[r];l?.contextKey&&(i=l.contextKey),o=l?.model}return{activeChatId:r,contextKey:i,composer:r?{...a.composer,model:o}:a.composer}})},upsertChat:r=>t(a=>{const i=a.activeChatId===r.id;return{chats:{...a.chats,[r.id]:r},...i?{composer:{...a.composer,model:r.model}}:{}}}),hydrateChats:r=>t(a=>{const i={};r.forEach(l=>{i[l.id]=l});const o=a.activeChatId&&i[a.activeChatId]?a.activeChatId:r[0]?.id,s=o?i[o]:void 0;return{chats:i,activeChatId:o,composer:{...a.composer,model:s?.model}}}),removeChat:r=>t(a=>{if(!a.chats[r])return a;const{[r]:i,...o}=a.chats,{[r]:s,...l}=a.reasoningByChat,{[r]:u,...d}=a.artifactsByChat,{[r]:p,...m}=a.pendingAssistantByChat,{[r]:h,...g}=a.messageQueueByChat,{[r]:y,..._}=a.statusByChat,{[r]:v,...k}=a.pageContextDismissedByChatKey,w=a.activeChatId===r;return{chats:o,statusByChat:_,reasoningByChat:l,artifactsByChat:d,messageQueueByChat:g,pendingAssistantByChat:m,pageContextDismissedByChatKey:k,...w?{activeChatId:void 0}:{}}}),pushReasoning:(r,a)=>t(i=>({reasoningByChat:{...i.reasoningByChat,[r]:[...i.reasoningByChat[r]??[],a]}})),consumeStreamChunk:(r,a)=>t(i=>{if(!a.message)return i;const o=i.chats[r];if(!o)return i;const s=o.messages.filter(l=>l.id!==a.message.id);return s.push(a.message),{chats:{...i.chats,[r]:{...o,messages:s}}}}),setArtifacts:(r,a)=>t(i=>({artifactsByChat:{...i.artifactsByChat,[r]:a}})),setComposerOptions:r=>t(a=>({composer:{...a.composer,...r}})),setComposerDraft:(r,a)=>t(i=>({composerDraftByChat:{...i.composerDraftByChat,[r]:{value:a.value??"",attachments:a.attachments??[]}}})),setComposerValue:(r,a)=>t(i=>{const o=i.composerDraftByChat[r]??{value:"",attachments:[]};return{composerDraftByChat:{...i.composerDraftByChat,[r]:{...o,value:a}}}}),addComposerAttachments:(r,a)=>t(i=>{const o=i.composerDraftByChat[r]??{value:"",attachments:[]};if(!a||a.length===0)return i;const s=o.attachments??[],l=s.find(ti),u=a.find(ti);if(u){const m=a.filter(v=>!ti(v)),h=s.filter(v=>!ti(v)),y=[l?{...u,id:l.id}:u,...m,...h],_=new Map;for(const v of y)_.set(v.id,v);return{composerDraftByChat:{...i.composerDraftByChat,[r]:{...o,attachments:Array.from(_.values())}}}}const d=[...a,...s],p=new Map;for(const m of d)p.set(m.id,m);return{composerDraftByChat:{...i.composerDraftByChat,[r]:{...o,attachments:Array.from(p.values())}}}}),removeComposerAttachment:(r,a)=>t(i=>{const o=i.composerDraftByChat[r];return o?{composerDraftByChat:{...i.composerDraftByChat,[r]:{...o,attachments:o.attachments.filter(s=>s.id!==a)}}}:i}),clearComposerDraft:r=>t(a=>({composerDraftByChat:{...a.composerDraftByChat,[r]:{value:"",attachments:[]}}})),setComposerError:(r,a)=>t(i=>({composerErrorByChat:{...i.composerErrorByChat,[r]:a}})),setPageContextDismissed:(r,a)=>t(i=>({pageContextDismissedByChatKey:{...i.pageContextDismissedByChatKey,[r]:a}})),setChatStatus:(r,a)=>t(i=>({statusByChat:{...i.statusByChat,[r]:a}})),setPendingAssistant:(r,a)=>t(i=>({pendingAssistantByChat:{...i.pendingAssistantByChat,[r]:a}})),commitPendingAssistant:r=>t(a=>{const i=a.pendingAssistantByChat[r];if(!i)return a;const o=a.chats[r];if(!o)return{pendingAssistantByChat:{...a.pendingAssistantByChat,[r]:void 0}};const l=typeof i.content=="string"&&i.content.trim().length>0?(()=>{if(o.messages[o.messages.length-1]?.id===i.id)return o.messages;const d={...i,chat:r};return[...o.messages,d]})():o.messages;return{chats:{...a.chats,[r]:{...o,messages:l}},pendingAssistantByChat:{...a.pendingAssistantByChat,[r]:void 0}}}),enqueueQueuedMessage:(r,a,i)=>t(o=>{const s={id:Tt.nanoid(),content:a,...i&&i.length>0?{attachments:i}:{},createdAt:new Date().toISOString()},l=o.messageQueueByChat[r]??[];return{messageQueueByChat:{...o.messageQueueByChat,[r]:[...l,s]}}}),removeQueuedMessage:(r,a)=>t(i=>{const o=i.messageQueueByChat[r];if(!o||o.length===0)return i;const s=o.filter(l=>l.id!==a);return{messageQueueByChat:{...i.messageQueueByChat,[r]:s}}}),moveChatKeyState:(r,a)=>t(i=>{if(r===a)return i;const o=i.messageQueueByChat[r]??[],s=i.messageQueueByChat[a]??[],l=i.pendingAssistantByChat[r],u=i.statusByChat[r],d=i.composerDraftByChat[r],p=i.composerDraftByChat[a],m=i.composerErrorByChat[r],h=i.composerErrorByChat[a],g=i.pageContextDismissedByChatKey[r],y=i.pageContextDismissedByChatKey[a];return o.length>0||!!l||u!==void 0&&u!=="idle"||!!d||!!m?{messageQueueByChat:{...i.messageQueueByChat,[r]:[],...o.length>0?{[a]:[...s,...o]}:{}},pendingAssistantByChat:{...i.pendingAssistantByChat,...l?{[a]:l}:{},[r]:void 0},statusByChat:{...i.statusByChat,...u?{[a]:u}:{},[r]:"idle"},composerDraftByChat:{...i.composerDraftByChat,...d&&!p?{[a]:d}:{},[r]:{value:"",attachments:[]}},composerErrorByChat:{...i.composerErrorByChat,...m&&!h?{[a]:m}:{},[r]:void 0},pageContextDismissedByChatKey:{...i.pageContextDismissedByChatKey,...g!==void 0&&y===void 0?{[a]:g}:{},[r]:!1}}:i}),appendSystemMessage:(r,a)=>t(i=>{const o=i.chats[r];if(!o)return i;const s={id:Tt.nanoid(),chat:r,content:a,role:exports.MessageRole.System,createdAt:new Date().toISOString()};return{chats:{...i.chats,[r]:{...o,messages:[...o.messages,s]}}}}),upsertToolCall:(r,a)=>t(i=>{const o=i.chats[r];if(!o)return i;const s=[...o.messages],l=s.findIndex(u=>u.role===exports.MessageRole.Tool&&u.toolCalls?.some(d=>d.id===a.id));if(l>=0){const u=s[l],d=(u.toolCalls??[]).map(p=>p.id===a.id?a:p);s[l]={...u,toolCalls:d}}else s.push({id:`tool-${a.id}`,chat:r,role:exports.MessageRole.Tool,content:"",createdAt:new Date().toISOString(),toolCalls:[a]});return{chats:{...i.chats,[r]:{...o,messages:s}}}}),setChatHistoryOpen:r=>t({isChatHistoryOpen:r}),toggleChatHistory:()=>t(r=>({isChatHistoryOpen:!r.isChatHistoryOpen}))})),o2="mp-agent-selected-model",ha="__auto__";function Q5(e){return e.mode==="direct"?`${o2}-${e.mode}-${e.provider}`:`${o2}-${e.mode}`}function s2(e,t){try{const n=Q5(e);localStorage.setItem(n,t)}catch(n){console.warn("Failed to save selected model to localStorage:",n)}}function n7e(e){try{const t=Q5(e);return localStorage.getItem(t)}catch(t){return console.warn("Failed to load selected model from localStorage:",t),null}}function J5(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 r7e(e,t,n){const r=n7e(t);if(r){if(r===ha)return;if(J5(e,t).some(i=>i.id===r))return r}}const Tn=Object.create(null);Tn.open="0";Tn.close="1";Tn.ping="2";Tn.pong="3";Tn.message="4";Tn.upgrade="5";Tn.noop="6";const Ti=Object.create(null);Object.keys(Tn).forEach(e=>{Ti[Tn[e]]=e});const cd={type:"error",data:"parser error"},e3=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",t3=typeof ArrayBuffer=="function",n3=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Qd=({type:e,data:t},n,r)=>e3&&t instanceof Blob?n?r(t):l2(t,r):t3&&(t instanceof ArrayBuffer||n3(t))?n?r(t):l2(new Blob([t]),r):r(Tn[e]+(t||"")),l2=(e,t)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];t("b"+(r||""))},n.readAsDataURL(e)};function c2(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let ss;function a7e(e,t){if(e3&&e.data instanceof Blob)return e.data.arrayBuffer().then(c2).then(t);if(t3&&(e.data instanceof ArrayBuffer||n3(e.data)))return t(c2(e.data));Qd(e,!1,n=>{ss||(ss=new TextEncoder),t(ss.encode(n))})}const u2="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ma=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<u2.length;e++)ma[u2.charCodeAt(e)]=e;const i7e=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=ma[e.charCodeAt(r)],o=ma[e.charCodeAt(r+1)],s=ma[e.charCodeAt(r+2)],l=ma[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},o7e=typeof ArrayBuffer=="function",Jd=(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)}:Ti[n]?e.length>1?{type:Ti[n],data:e.substring(1)}:{type:Ti[n]}:cd},s7e=(e,t)=>{if(o7e){const n=i7e(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}},a3="",l7e=(e,t)=>{const n=e.length,r=new Array(n);let a=0;e.forEach((i,o)=>{Qd(i,!1,s=>{r[o]=s,++a===n&&t(r.join(a3))})})},c7e=(e,t)=>{const n=e.split(a3),r=[];for(let a=0;a<n.length;a++){const i=Jd(n[a],t);if(r.push(i),i.type==="error")break}return r};function u7e(){return new TransformStream({transform(e,t){a7e(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 ls;function ni(e){return e.reduce((t,n)=>t+n.length,0)}function ri(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 d7e(e,t){ls||(ls=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(ni(n)<1)break;const l=ri(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(ni(n)<2)break;const l=ri(n,2);a=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),r=3}else if(r===2){if(ni(n)<8)break;const l=ri(n,8),u=new DataView(l.buffer,l.byteOffset,l.length),d=u.getUint32(0);if(d>Math.pow(2,21)-1){s.enqueue(cd);break}a=d*Math.pow(2,32)+u.getUint32(4),r=3}else{if(ni(n)<a)break;const l=ri(n,a);s.enqueue(Jd(i?l:ls.decode(l),t)),r=0}if(a===0||a>e){s.enqueue(cd);break}}}})}const i3=4;function bt(e){if(e)return p7e(e)}function p7e(e){for(var t in bt.prototype)e[t]=bt.prototype[t];return e}bt.prototype.on=bt.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};bt.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this};bt.prototype.off=bt.prototype.removeListener=bt.prototype.removeAllListeners=bt.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};bt.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};bt.prototype.emitReserved=bt.prototype.emit;bt.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};bt.prototype.hasListeners=function(e){return!!this.listeners(e).length};const wo=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0),on=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),h7e="arraybuffer";function o3(e,...t){return t.reduce((n,r)=>(e.hasOwnProperty(r)&&(n[r]=e[r]),n),{})}const m7e=on.setTimeout,f7e=on.clearTimeout;function xo(e,t){t.useNativeTimers?(e.setTimeoutFn=m7e.bind(on),e.clearTimeoutFn=f7e.bind(on)):(e.setTimeoutFn=on.setTimeout.bind(on),e.clearTimeoutFn=on.clearTimeout.bind(on))}const g7e=1.33;function y7e(e){return typeof e=="string"?b7e(e):Math.ceil((e.byteLength||e.size)*g7e)}function b7e(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 s3(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function k7e(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function v7e(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 _7e extends Error{constructor(t,n,r){super(t),this.description=n,this.context=r,this.type="TransportError"}}class ep extends bt{constructor(t){super(),this.writable=!1,xo(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 _7e(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=Jd(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=k7e(t);return n.length?"?"+n:""}}class w7e extends ep{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)};c7e(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,l7e(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]=s3()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}let l3=!1;try{l3=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const x7e=l3;function E7e(){}class M7e extends w7e{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 An extends bt{constructor(t,n,r){super(),this.createRequest=t,xo(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=o3(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=An.requestsCount++,An.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=E7e,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete An.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()}}An.requestsCount=0;An.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",d2);else if(typeof addEventListener=="function"){const e="onpagehide"in on?"pagehide":"unload";addEventListener(e,d2,!1)}}function d2(){for(let e in An.requests)An.requests.hasOwnProperty(e)&&An.requests[e].abort()}const S7e=function(){const e=c3({xdomain:!1});return e&&e.responseType!==null}();class N7e extends M7e{constructor(t){super(t);const n=t&&t.forceBase64;this.supportsBinary=S7e&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new An(c3,this.uri(),t)}}function c3(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||x7e))return new XMLHttpRequest}catch{}if(!t)try{return new on[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const u3=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class A7e extends ep{get name(){return"websocket"}doOpen(){const t=this.uri(),n=this.opts.protocols,r=u3?{}:o3(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;Qd(r,this.supportsBinary,i=>{try{this.doWrite(r,i)}catch{}a&&wo(()=>{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]=s3()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}}const cs=on.WebSocket||on.MozWebSocket;class T7e extends A7e{createSocket(t,n,r){return u3?new cs(t,n,r):n?new cs(t,n):new cs(t)}doWrite(t,n){this.ws.send(n)}}class C7e extends ep{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=d7e(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),a=u7e();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&&wo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const R7e={websocket:T7e,webtransport:C7e,polling:N7e},I7e=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,O7e=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ud(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=I7e.exec(e||""),i={},o=14;for(;o--;)i[O7e[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=L7e(i,i.path),i.queryKey=D7e(i,i.query),i}function L7e(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 D7e(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,a,i){a&&(n[a]=i)}),n}const dd=typeof addEventListener=="function"&&typeof removeEventListener=="function",Ci=[];dd&&addEventListener("offline",()=>{Ci.forEach(e=>e())},!1);class ir extends bt{constructor(t,n){if(super(),this.binaryType=h7e,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=ud(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=ud(n.host).host);xo(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=v7e(this.opts.query)),dd&&(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"})},Ci.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const n=Object.assign({},this.opts.query);n.EIO=i3,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&&ir.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",ir.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+=y7e(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,wo(()=>{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(ir.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(),dd&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=Ci.indexOf(this._offlineEventListener);r!==-1&&Ci.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}}ir.protocol=i3;class z7e extends ir{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;ir.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;ir.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 $7e=class extends z7e{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=>R7e[a]).filter(a=>!!a)),super(t,r)}};function F7e(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=ud(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 P7e=typeof ArrayBuffer=="function",B7e=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,d3=Object.prototype.toString,q7e=typeof Blob=="function"||typeof Blob<"u"&&d3.call(Blob)==="[object BlobConstructor]",U7e=typeof File=="function"||typeof File<"u"&&d3.call(File)==="[object FileConstructor]";function tp(e){return P7e&&(e instanceof ArrayBuffer||B7e(e))||q7e&&e instanceof Blob||U7e&&e instanceof File}function Ri(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,r=e.length;n<r;n++)if(Ri(e[n]))return!0;return!1}if(tp(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Ri(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&Ri(e[n]))return!0;return!1}function H7e(e){const t=[],n=e.data,r=e;return r.data=pd(n,t),r.attachments=t.length,{packet:r,buffers:t}}function pd(e,t){if(!e)return e;if(tp(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]=pd(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]=pd(e[r],t));return n}return e}function j7e(e,t){return e.data=hd(e.data,t),delete e.attachments,e}function hd(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]=hd(e[n],t);else if(typeof e=="object")for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=hd(e[n],t));return e}const V7e=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],G7e=5;var Ke;(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"})(Ke||(Ke={}));class W7e{constructor(t){this.replacer=t}encode(t){return(t.type===Ke.EVENT||t.type===Ke.ACK)&&Ri(t)?this.encodeAsBinary({type:t.type===Ke.EVENT?Ke.BINARY_EVENT:Ke.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===Ke.BINARY_EVENT||t.type===Ke.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=H7e(t),r=this.encodeAsString(n.packet),a=n.buffers;return a.unshift(r),a}}function p2(e){return Object.prototype.toString.call(e)==="[object Object]"}class np extends bt{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===Ke.BINARY_EVENT;r||n.type===Ke.BINARY_ACK?(n.type=r?Ke.EVENT:Ke.ACK,this.reconstructor=new K7e(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(tp(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(Ke[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===Ke.BINARY_EVENT||r.type===Ke.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(np.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 Ke.CONNECT:return p2(n);case Ke.DISCONNECT:return n===void 0;case Ke.CONNECT_ERROR:return typeof n=="string"||p2(n);case Ke.EVENT:case Ke.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&V7e.indexOf(n[0])===-1);case Ke.ACK:case Ke.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class K7e{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=j7e(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const Y7e=Object.freeze(Object.defineProperty({__proto__:null,Decoder:np,Encoder:W7e,get PacketType(){return Ke},protocol:G7e},Symbol.toStringTag,{value:"Module"}));function fn(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const Z7e=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class p3 extends bt{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=[fn(t,"open",this.onopen.bind(this)),fn(t,"packet",this.onpacket.bind(this)),fn(t,"error",this.onerror.bind(this)),fn(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(Z7e.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:Ke.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:Ke.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 Ke.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 Ke.EVENT:case Ke.BINARY_EVENT:this.onevent(t);break;case Ke.ACK:case Ke.BINARY_ACK:this.onack(t);break;case Ke.DISCONNECT:this.ondisconnect();break;case Ke.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:Ke.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:Ke.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 ea(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}ea.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};ea.prototype.reset=function(){this.attempts=0};ea.prototype.setMin=function(e){this.ms=e};ea.prototype.setMax=function(e){this.max=e};ea.prototype.setJitter=function(e){this.jitter=e};class md extends bt{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,xo(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 ea({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||Y7e;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 $7e(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const a=fn(n,"open",function(){r.onopen(),t&&t()}),i=s=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",s),t?t(s):this.maybeReconnectOnOpen()},o=fn(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(fn(t,"ping",this.onping.bind(this)),fn(t,"data",this.ondata.bind(this)),fn(t,"error",this.onerror.bind(this)),fn(t,"close",this.onclose.bind(this)),fn(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){wo(()=>{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 p3(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 la={};function Ii(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const n=F7e(e,t.path||"/socket.io"),r=n.source,a=n.id,i=n.path,o=la[a]&&i in la[a].nsps,s=t.forceNew||t["force new connection"]||t.multiplex===!1||o;let l;return s?l=new md(r,t):(la[a]||(la[a]=new md(r,t)),l=la[a]),n.query&&!t.query&&(t.query=n.queryKey),l.socket(n.path,t)}Object.assign(Ii,{Manager:md,Socket:p3,io:Ii,connect:Ii});const h2="mp-agents-guest-user-id";function rp(){if(typeof window>"u")return`${Pi.DefaultUserId}-${Tt.nanoid()}`;const e=localStorage.getItem(h2);if(e)return e;const t=`${Pi.DefaultUserId}-${Tt.nanoid()}`;return localStorage.setItem(h2,t),t}const X7e=ee.createContext(null),Q7e=({children:e})=>{const t=vt(),{upsertChat:n,contextKey:r}=Fe(h=>({upsertChat:h.upsertChat,contextKey:h.contextKey})),a=ee.useMemo(()=>t.config.user?.id??rp(),[t.config.user?.id]),i=t.config.transport,[o,s]=ee.useState(null),[l,u]=ee.useState(void 0),d=ee.useRef(r),p=ee.useRef(n);ee.useEffect(()=>{d.current=r,p.current=n},[r,n]),ee.useEffect(()=>{if(i.mode!=="proxy"){s(null),u(void 0),t.transport instanceof jr&&t.transport.setSocketId(void 0);return}const h=i.baseUrl,g=new URL(h,window.location.origin),y=`${g.protocol}//${g.host}`,_={},v=i;v.headers&&Object.assign(_,v.headers);const k={},w=v.apiKey&&`Bearer ${v.apiKey}`||v.headers?.Authorization||v.headers?.authorization;w&&(k.authorization=w,_.Authorization=w);const M=i.socketPath??Pi.Path,S=Ii(y,{path:M,auth:k,transports:["websocket","polling"],...Object.keys(_).length>0&&{extraHeaders:_}});s(S);const E=()=>{u(S.id),t.transport instanceof jr&&t.transport.setSocketId(S.id)},F=()=>{u(void 0),t.transport instanceof jr&&t.transport.setSocketId(void 0)},P=W=>{W.contextKey===d.current&&p.current(W)},C=W=>{const J=t.store.getState().chats[W.chat];if(!J)return;const V=J.messages.findIndex(R=>R.id===W.id);if(V>=0){const R=[...J.messages];R[V]=W,p.current({...J,messages:R});return}p.current({...J,messages:[...J.messages,W]})},D=W=>{const J=t.store.getState().chats[W.id];p.current({...W,messages:J?J.messages:[]})};return S.on("connect",E),S.on("disconnect",F),S.on("connect_error",W=>{console.error("Socket.IO connection error:",W)}),S.on(Si.ChatNew,P),S.on(Si.MessageNew,C),S.on(Si.ChatUpdate,D),()=>{t.transport instanceof jr&&t.transport.setSocketId(void 0),u(void 0),s(null),S.disconnect()}},[t,t.transport,i.mode,i.mode==="proxy"?i.baseUrl:void 0,i.mode==="proxy"?i.apiKey:void 0,i.mode==="proxy"?i.socketPath:void 0,i.mode==="proxy"?JSON.stringify(i.headers??{}):"",a]);const m=ee.useMemo(()=>({socket:o,socketId:l}),[o,l]);return O.jsx(X7e.Provider,{value:m,children:e})},ap=ee.createContext(null),J7e=({config:e,children:t})=>{const n=ee.useRef();n.current||(n.current=new K5(e));const[,r]=ee.useState(0);ee.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=ee.useRef();if(!a.current){const o=n.current.defaultContextKey??n.current.config.contextKeys[0]?.key??"default";a.current=t7e(o),n.current.attachStore(a.current);const s=r7e(n.current.config.models,n.current.config.transport);a.current.getState().setComposerOptions({model:s})}const i=ee.useMemo(()=>({runtime:n.current,store:a.current}),[]);return O.jsx(ap.Provider,{value:i,children:O.jsx(io.QueryClientProvider,{client:i.runtime.queryClient,children:O.jsx(X5,{value:i.runtime.config.theme,children:O.jsx(Q7e,{children:t})})})})},vt=()=>{const e=ee.useContext(ap);if(!e)throw new Error("useAgentRuntime must be used inside <AgentProvider />");return e.runtime},Fe=e=>{const t=ee.useContext(ap);if(!t)throw new Error("useAgentStore must be used inside <AgentProvider />");return Gk.useStore(t.store,e)},h3=()=>{const e=vt(),{hydrateChats:t}=Fe(a=>({hydrateChats:a.hydrateChats})),n=e.config.user?.id??rp(),r=io.useQuery({queryKey:["mp-agents","chats",n],queryFn:()=>e.transport.listChats({userId:n}),enabled:!!n});return ee.useEffect(()=>{r.data&&t(r.data)},[r.data,t]),r},m3=(e={},t=[])=>{const{threshold:n=50,scrollOnMount:r=!0}=e,a=ee.useRef(null),i=ee.useRef(null),[o,s]=ee.useState(!0),l=ee.useRef(!1),u=ee.useRef(!1),d=ee.useRef(),p=ee.useCallback(()=>{const g=a.current;if(!g)return!1;const{scrollTop:y,scrollHeight:_,clientHeight:v}=g;return _-y-v<=n},[n]),m=ee.useCallback(()=>{const g=a.current,y=i.current;!g||!y||y.scrollIntoView({behavior:"auto",block:"end"})},[]),h=ee.useCallback(()=>{const g=p();s(g),g&&(l.current=!1)},[p]);return ee.useEffect(()=>{const g=a.current;if(!g)return;let y=g.scrollTop,_;const v=()=>{const k=g.scrollTop;if(!u.current){const w=k<y,M=k>y;(w||M&&!p())&&(l.current=!0)}y=k,h(),_&&clearTimeout(_),_=window.setTimeout(()=>{u.current=!1},150)};return g.addEventListener("scroll",v,{passive:!0}),()=>{g.removeEventListener("scroll",v),_&&clearTimeout(_)}},[p,h]),ee.useEffect(()=>{const g=a.current;if(!g)return;const y=new MutationObserver(()=>{!l.current&&o&&(d.current&&cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{u.current=!0,m(),setTimeout(()=>{u.current=!1},50)})),h()});return y.observe(g,{childList:!0,subtree:!0,characterData:!0,attributes:!1}),()=>{y.disconnect(),d.current&&cancelAnimationFrame(d.current)}},[o,m,h]),ee.useEffect(()=>{t.length!==0&&!l.current&&o&&(d.current&&cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{u.current=!0,m(),setTimeout(()=>{u.current=!1},50)}))},[...t]),ee.useEffect(()=>{if(r&&a.current){const g=window.setTimeout(()=>{u.current=!0,m(),setTimeout(()=>{u.current=!1},50)},100);return()=>{clearTimeout(g)}}},[r,m]),{containerRef:a,sentinelRef:i,isNearBottom:o,scrollToBottom:m,checkIsNearBottom:p}},f3=()=>{const e=vt();return io.useQuery({queryKey:["mp-agents","models"],queryFn:async()=>e.transport.listModels?await e.transport.listModels():[],staleTime:5*60*1e3,refetchOnWindowFocus:!1})},g3=()=>{const e=Fe(s=>s.activeChatId??s.draftChatKey),t=Fe(s=>s.composerDraftByChat[e]??{value:"",attachments:[]}),n=Fe(s=>s.setComposerValue),r=Fe(s=>s.setComposerDraft),a=Fe(s=>s.clearComposerDraft),i=Fe(s=>s.addComposerAttachments),o=Fe(s=>s.removeComposerAttachment);return{chatKey:e,draft:t,setValue:s=>n(e,s),setDraft:s=>r(e,s),clearDraft:()=>a(e),addAttachments:s=>i(e,s),removeAttachment:s=>o(e,s)}},Mr=()=>vt().config.translations??Fi,e_e=(e,t=[])=>{const n=vt(),r=ee.useRef(e),a=ee.useCallback(e,t);r.current=a;const i=ee.useCallback(o=>r.current(o),[]);ee.useEffect(()=>n.registerPageContextProvider(i),[n,i])},t_e=({initialSystemPrompt:e,composerFormRef:t})=>{const n=vt(),{statusByChat:r,composer:a,contextKey:i,activeChatId:o,draftChatKey:s,messageQueueByChat:l,setPageContextDismissed:u,setChatStatus:d,upsertChat:p,setActiveChat:m,setPendingAssistant:h,commitPendingAssistant:g,setComposerError:y,enqueueQueuedMessage:_,removeQueuedMessage:v,moveChatKeyState:k}=Fe(T=>({statusByChat:T.statusByChat,composer:T.composer,contextKey:T.contextKey,activeChatId:T.activeChatId,draftChatKey:T.draftChatKey,messageQueueByChat:T.messageQueueByChat,setPageContextDismissed:T.setPageContextDismissed,setChatStatus:T.setChatStatus,upsertChat:T.upsertChat,setActiveChat:T.setActiveChat,setPendingAssistant:T.setPendingAssistant,commitPendingAssistant:T.commitPendingAssistant,setComposerError:T.setComposerError,enqueueQueuedMessage:T.enqueueQueuedMessage,removeQueuedMessage:T.removeQueuedMessage,moveChatKeyState:T.moveChatKeyState})),w=ee.useCallback(T=>!T||T.length===0?!1:T.some(Y=>Y.type===exports.AgentAttachmentType.Context&&Y?.metadata?.kind==="pageContext"),[]),M=ee.useRef(!1),S=ee.useRef(!1),E=ee.useRef(new Set),F=ee.useRef(void 0),P=o??s,C=l[P]??[],D=r[P]??an.Idle,W=ee.useCallback(async(T,Y)=>{if(!n.transport.generateTitle)return;const N=n.config.features?.titleGeneration==="llm"?"llm":"local";let Z;try{Z=await n.transport.generateTitle({userId:Y,content:T,strategy:N,contextKey:i})}catch{}return Z},[n.transport,n.config.features?.titleGeneration,i]),K=ee.useCallback(async(T,Y)=>{const N=n.config.user?.id??"guest",Z=!o,te=o??s,I={current:te};F.current=te;const pe={value:T,attachments:Y??[]};y(I.current,void 0);let ge;if(Z){const we=await W(T,N);we&&we.trim().length>0&&(ge={...ge??{},title:we})}const Ce=(o?n.store.getState().chats[o]:void 0)?.model,Be=a.model!==Ce;let He,re=!1;Be?(He=a.model,re=!0):Ce?(He=Ce,re=!1):(He=void 0,re=!1);const Me={userId:N,content:T,metadata:ge,contextKey:i,...Z?{}:{chatId:o},...re?{model:He}:{},...Y&&Y.length>0?{attachments:Y}:{}},Ge=()=>{h(I.current,void 0)},Je=we=>{if(we?.name==="AbortError"){const ke=F.current??I.current;return E.current.has(ke)?(g(I.current),E.current.delete(ke)):(Ge(),t.current.setDraft(pe)),{type:"aborted"}}throw we},qe=async()=>{let we=`pending-${Date.now()}`,ke="",Le;d(I.current,an.Streaming),h(I.current,{id:we,chat:o||"",content:"",role:exports.MessageRole.Assistant,createdAt:new Date().toISOString(),reasoning:"",toolCalls:[],attachments:[]});try{let de=o;const et=await n.transport.streamMessage(Me,Te=>{if(Te.type===exports.StreamChunkType.Chat&&Te.chat){p({...Te.chat,messages:[]}),de=Te.chat.id,Z&&(F.current=Te.chat.id,k(I.current,Te.chat.id),I.current=Te.chat.id,m(Te.chat.id));return}if(Te.type===exports.StreamChunkType.Reasoning&&Te.reasoning){ke+=Te.reasoning,Le={...Le??{id:we,chat:de,role:exports.MessageRole.Assistant,content:"",createdAt:new Date().toISOString()},reasoning:ke},h(I.current,Le);return}if(Te.type===exports.StreamChunkType.Error&&Te.error)throw new Error(Te.error);Te.message&&Te.message.role===exports.MessageRole.User||Te.message&&(we=Te.message.id,Le={...Te.message,reasoning:ke||Te.message.reasoning},h(I.current,Le))},{streamKey:F.current});if(et){const Te=ke&&Le?{...et,messages:et.messages.map(_e=>_e.id===Le.id&&_e.role===exports.MessageRole.Assistant?{..._e,reasoning:ke}:_e)}:et;return p(Te),(n.store.getState().activeChatId??n.store.getState().draftChatKey)===I.current&&m(Te.id),Ge(),{type:"success"}}return Ge(),{type:"success"}}catch(de){return Je(de)}};try{const we=await qe();return we.type==="success"&&(S.current=!1),we}catch(we){Ge();const ke=we?.chat;ke&&(p(ke),m(ke.id));const Le=we instanceof Error?we:new Error("Failed to send message");return y(I.current,Le.message||"Failed to send message"),t.current.setDraft(pe),S.current=!1,{type:"error",error:Le}}finally{M.current=!1,d(I.current,an.Idle),F.current=void 0}},[o,i,a.model,n.transport,n.config.user?.id,p,m,h,d,W,e,k,t,y]),J=ee.useCallback(async()=>{if(D!==an.Idle||M.current||!C.length||S.current)return;const T=C[0];M.current=!0,v(P,T.id);try{await K(T.content,T.attachments)}finally{M.current=!1}},[D,C,P,K,v]);ee.useEffect(()=>{J()},[J]);const V=ee.useCallback(async T=>{if(M.current)return;const Y=C.find(N=>N.id===T);if(Y){S.current=!1,M.current=!0,v(P,T);try{await K(Y.content,Y.attachments)}finally{M.current=!1}}},[C,P,v,K]),R=ee.useCallback(async T=>{const N=t.current.getDraft().attachments;if(w(N)&&u(P,!0),D!==an.Idle){_(P,T,N),t.current.clearDraft();return}S.current=!1,t.current.clearDraft(),await K(T,N)},[D,_,P,K,t,w,u]),q=ee.useCallback(()=>{S.current=!0;const T=F.current??P;E.current.add(T),n.transport.cancelStream?.(T),g(T),d(T,an.Idle)},[P,n.transport,g,d]),G=ee.useCallback(async T=>{D===an.Streaming&&q(),await V(T)},[D,q,V]);return{pendingKey:P,queuedMessages:C,activeChatStatus:D,activeChatId:o,removeQueuedMessage:v,handleSubmit:R,handleStop:q,handleQueuedClick:G}},n_e=({queuedMessages:e,onSendQueued:t,onRemoveQueued:n})=>e.length?O.jsxs("div",{className:"mp-agent-composer-queue",children:[O.jsx("div",{className:"mp-agent-composer-queue-header",children:O.jsxs("span",{children:[e.length," message",e.length>1?"s":""," queued"]})}),O.jsx("div",{className:"mp-agent-composer-queue-items",children:e.map(r=>O.jsxs("div",{className:"mp-agent-composer-queue-item",children:[O.jsxs("span",{className:"mp-agent-composer-queue-item-text",children:[r.content,r.attachments?.length?O.jsxs("span",{style:{marginLeft:8,opacity:.7,display:"inline-flex",alignItems:"center",gap:4},children:[O.jsx(lo,{size:12}),r.attachments.length]}):null]}),O.jsxs("div",{className:"mp-agent-composer-queue-item-actions",children:[O.jsx("button",{type:"button",className:"mp-agent-composer-queue-button",onClick:()=>t(r.id),"aria-label":"Send queued message",children:O.jsx(Hd,{size:12})}),O.jsx("button",{type:"button",className:"mp-agent-composer-queue-button",onClick:()=>n(r.id),"aria-label":"Remove queued message",children:O.jsx(s5,{size:12})})]})]},r.id))})]}):null,r_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]=ee.useState(!1),[h,g]=ee.useState(null),[y,_]=ee.useState(""),v=ee.useRef([]),k=ee.useRef(null),{refs:w,floatingStyles:M,context:S,isPositioned:E}=U5({open:p,onOpenChange:m,placement:s,strategy:"absolute",whileElementsMounted:O5,middleware:[D5(8),$5({fallbackPlacements:["top-start","bottom-start","top-end","bottom-end"]}),z5({padding:8})]}),F=P8e(S,{enabled:!a}),P=q5(S),C=j5(S),W=V8e(S,{listRef:v,activeIndex:h,onNavigate:g,enabled:p&&!l,virtual:!1}),{getReferenceProps:K,getFloatingProps:J,getItemProps:V}=H5(l?[F,P,C]:[F,P,C,W]),R=e.findIndex(Z=>Z.value===t),q=R>=0?e[R]:void 0,G=ee.useMemo(()=>{const Z=y.trim().toLowerCase();if(!l||!Z)return e;const I=d?pe=>d(pe,Z):pe=>`${pe.label} ${pe.description??""}`.toLowerCase().includes(Z);return e.filter(I)},[e,y,l,d]);ee.useEffect(()=>{if(!p){g(null),_("");return}l&&setTimeout(()=>k.current?.focus(),0);const Z=G.findIndex(te=>te.value===t);g(Z>=0?Z:0)},[p,l,t,G]),ee.useEffect(()=>{p&&g(G.length>0?0:null)},[y,G.length,p]);const T=Z=>G.length===0?null:Z<0?G.length-1:Z>=G.length?0:Z,Y=Z=>{Z!=null&&v.current[Z]?.scrollIntoView({block:"nearest"})},N=Z=>{n(Z),m(!1),g(null),_("")};return O.jsxs("div",{className:`mp-agent-dropdown ${i}`,children:[O.jsxs("button",{ref:w.setReference,type:"button",className:`mp-agent-dropdown-trigger ${o}`,disabled:a,"aria-expanded":p,"aria-haspopup":"listbox",...K(),children:[O.jsx("span",{className:"mp-agent-dropdown-trigger-content",children:q?O.jsxs(O.Fragment,{children:[q.icon&&O.jsx("span",{className:"mp-agent-dropdown-trigger-icon",children:q.icon}),O.jsx("span",{className:"mp-agent-dropdown-trigger-label",children:q.label})]}):O.jsx("span",{className:"mp-agent-dropdown-trigger-placeholder",children:r})}),O.jsx(n5,{size:16,className:`mp-agent-dropdown-chevron ${p?"open":""}`})]}),p&&O.jsxs("div",{role:"listbox",ref:w.setFloating,style:{...M,opacity:E?1:0,pointerEvents:E?"auto":"none",transition:E?"opacity 0.15s ease-out":"none"},className:"mp-agent-dropdown-menu",...J(),children:[l&&O.jsx("div",{className:"mp-agent-dropdown-search",onKeyDown:Z=>Z.stopPropagation(),children:O.jsx("input",{ref:k,className:"mp-agent-dropdown-search-input",value:y,placeholder:u,onChange:Z=>_(Z.target.value),onKeyDown:Z=>{if(Z.key==="Escape"){Z.preventDefault(),m(!1),_("");return}if(Z.key==="ArrowDown"||Z.key==="ArrowUp"){Z.preventDefault();const te=Z.key==="ArrowDown"?1:-1,I=h??(te>0?-1:0),pe=T(I+te);g(pe),Y(pe);return}if(Z.key==="Enter"){if(h==null)return;const te=G[h];if(!te)return;Z.preventDefault(),N(te.value)}}})}),O.jsxs("div",{className:"mp-agent-dropdown-list",children:[G.map((Z,te)=>O.jsxs("button",{ref:I=>{v.current[te]=I},type:"button",className:`mp-agent-dropdown-item ${t===Z.value?"selected":""} ${h===te?"active":""}`,role:"option","aria-selected":t===Z.value,...V({onClick:()=>N(Z.value),onMouseEnter:()=>{g(te)},onKeyDown:I=>{(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),N(Z.value))}}),children:[Z.icon&&O.jsx("span",{className:"mp-agent-dropdown-item-icon",children:Z.icon}),O.jsxs("span",{className:"mp-agent-dropdown-item-content",children:[O.jsx("span",{className:"mp-agent-dropdown-item-label",children:Z.label}),Z.description&&O.jsx("span",{className:"mp-agent-dropdown-item-description",children:Z.description})]})]},Z.value)),l&&G.length===0&&O.jsx("div",{className:"mp-agent-dropdown-empty","aria-label":"No results",children:"No results"})]})]})]})},a_e=ee.memo(()=>{const e=vt(),{contextKey:t,composer:n,setComposerOptions:r}=Fe(p=>({contextKey:p.contextKey,composer:p.composer,setComposerOptions:p.setComposerOptions})),a=e.config.models,{data:i,isLoading:o}=f3(),s=ee.useMemo(()=>{const p=i&&i.length>0?i:a;return J5(p,e.config.transport).filter(h=>!h.contexts?.length||h.contexts.includes(t))},[i,a,e.config.transport,t]),l=ee.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:ha,label:"Auto"},...p]},[s]),u=ee.useMemo(()=>n.model!==void 0?n.model:ha,[n.model]),d=ee.useCallback(p=>{p===ha?(r({model:void 0}),s2(e.config.transport,ha)):(r({model:p}),s2(e.config.transport,p))},[r,e.config.transport]);return o&&!a?.length||l.length===0?null:O.jsx(r_e,{options:l,value:u,onChange:d,placeholder:"Select model...",searchable:!0,searchPlaceholder:"Search models...",placement:"top-start",triggerClassName:"mp-agent-model-selector-trigger"})}),i_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)},o_e=e=>{try{const t=new URL(e);return t.hostname+(t.pathname&&t.pathname!=="/"?t.pathname:"")}catch{return e}};function s_e(e,t){return e.size>t.maxFileSize?{type:"size",message:`File "${e.name}" exceeds maximum size of ${ip(t.maxFileSize)}`,fileName:e.name}:null}function l_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=s_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 ${ip(n.maxTotalAttachmentsSize)}`}:null}function ip(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 c_e(){return{maxFileSize:10*1024*1024,maxTotalAttachmentsSize:50*1024*1024,maxFilesPerMessage:10,allowedMimeTypes:void 0}}const y3=e=>{switch(e.type){case exports.AgentAttachmentType.Link:return O.jsx(i5,{size:12});case exports.AgentAttachmentType.Artifact:return O.jsx(lo,{size:12});case exports.AgentAttachmentType.Context:switch(e?.metadata?.kind){case"pageContext":return O.jsx(jd,{size:12});case"formSnapshot":case"formField":return O.jsx(a5,{size:12});default:return O.jsx(Vd,{size:12})}case exports.AgentAttachmentType.File:default:return O.jsx(r5,{size:12})}},u_e=({attachments:e})=>!e||e.length===0?null:O.jsx("div",{className:"mp-agent-message-attachments","aria-label":"Message attachments",children:e.map(t=>{const n=O.jsxs(O.Fragment,{children:[O.jsx("span",{className:"mp-agent-message-attachment-icon",children:y3(t)}),O.jsx("span",{className:"mp-agent-message-attachment-name",children:t.name})]});return t.url?O.jsx("a",{className:"mp-agent-message-attachment",href:t.url,target:"_blank",rel:"noreferrer",title:t.url,children:n},t.id):O.jsx("span",{className:"mp-agent-message-attachment",title:t.mimeType??t.name,children:n},t.id)})}),d_e=({attachments:e,onRemove:t,uploadProgress:n,uploadErrors:r})=>{const a=Mr();return!e||e.length===0?null:O.jsx("div",{className:"mp-agent-composer-attachments","aria-label":a.attachments,children:e.map(i=>{const o=n?.get(i.id),s=r?.get(i.name),l=i.metadata?.size||i.size,u=l?` (${ip(l)})`:"";return O.jsxs("span",{className:`mp-agent-attachment-chip ${s?"mp-agent-attachment-chip-error":""} ${o?.status==="uploading"?"mp-agent-attachment-chip-uploading":""}`,title:s||i.name,children:[O.jsx("span",{className:"mp-agent-attachment-chip-icon",children:y3(i)}),O.jsxs("span",{className:"mp-agent-attachment-chip-name",title:i.name,children:[i.name,u]}),o?.status==="uploading"&&O.jsxs("span",{className:"mp-agent-attachment-chip-progress",children:[o.progress,"%"]}),s&&O.jsx("span",{className:"mp-agent-attachment-chip-error-text",title:s,children:"⚠"}),t?O.jsx(ar,{size:"sm",icon:"X",type:"button",onClick:d=>{d.preventDefault(),d.stopPropagation(),t(i.id)},"aria-label":`Remove attachment ${i.name}`}):null]},i.id)})})};async function p_e(e,t,n,r){const a=await fetch(r.presignedUrlEndpoint,{method:"POST",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 h_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 m_e(e,t,n){const r=Tt.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 p_e(e,n.chatId,n.userId,t);return await h_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 f_e(e,t,n){const r=await Promise.allSettled(e.map(o=>m_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 fd="mp-agent:locationchange",m2="__mp_agent_history_patched__",f2=()=>{try{window.dispatchEvent(new Event(fd))}catch{}},g_e=()=>{if(typeof window>"u")return;const e=window;if(!e[m2]){e[m2]=!0;try{const t=history.pushState;history.pushState=function(...n){const r=t.apply(this,n);return f2(),r}}catch{}try{const t=history.replaceState;history.replaceState=function(...n){const r=t.apply(this,n);return f2(),r}}catch{}}},y_e=e=>{if(typeof window>"u")return()=>{};g_e();const t=()=>e();return window.addEventListener("popstate",t),window.addEventListener("hashchange",t),window.addEventListener(fd,t),()=>{window.removeEventListener("popstate",t),window.removeEventListener("hashchange",t),window.removeEventListener(fd,t)}},b_e=ee.forwardRef(({autoFocus:e,activeChatId:t,status:n,onStop:r,onSubmit:a},i)=>{const o=Mr(),s=vt(),l=ee.useRef(null),u=ee.useRef(null),d=Fe(re=>re.activeChatId??re.draftChatKey),p=Fe(re=>re.composerDraftByChat[d]??{value:"",attachments:[]}),m=Fe(re=>re.composerErrorByChat[d]),h=Fe(re=>re.pageContextDismissedByChatKey[d]??!1),g=Fe(re=>re.setComposerValue),y=Fe(re=>re.setComposerDraft),_=Fe(re=>re.clearComposerDraft),v=Fe(re=>re.setComposerError),k=Fe(re=>re.addComposerAttachments),w=Fe(re=>re.removeComposerAttachment),M=Fe(re=>re.setPageContextDismissed),S=p.value,E=p.attachments,[F,P]=ee.useState(new Map),[C,D]=ee.useState(new Map),W=ee.useRef(S),K=ee.useRef(E),J=ee.useRef(h),V=s.config.features?.pageContextAttachments!==!1,R=re=>re.type===exports.AgentAttachmentType.Context&&re?.metadata?.kind==="pageContext",q=E.some(R),G=()=>{if(V)return s.buildPageContextAttachment()};ee.useEffect(()=>{K.current=E},[E]),ee.useEffect(()=>{W.current=S},[S]),ee.useEffect(()=>{J.current=h},[h]),ee.useEffect(()=>{if(!V||h||q)return;const re=G();re&&k(d,[re])},[V,h,q,d,k]),ee.useEffect(()=>{if(V&&!(typeof window>"u"))return y_e(()=>{if(J.current)return;const re=K.current,Me=re.find(R);if(!Me)return;const Ge=G();if(!Ge)return;const Je={...Ge,id:Me.id},qe=re.map(we=>we.id===Me.id?Je:we);y(d,{value:W.current,attachments:qe})})},[V,d,y]),ee.useImperativeHandle(i,()=>({setValue:re=>{g(d,re)},getDraft:()=>({value:S,attachments:E}),setDraft:re=>{y(d,{value:re.value,attachments:re.attachments??[]})},clearDraft:()=>{_(d)}})),ee.useEffect(()=>{const re=l.current;re&&(re.style.height="auto",re.style.height=`${Math.min(re.scrollHeight,200)}px`)},[S]);const T=async re=>{if(!re||re.length===0)return;const Me=Array.from(re),Ge=c_e(),Je=l_e(Me,E,Ge);if(Je){D(qe=>{const we=new Map(qe);return Me.forEach(ke=>{we.set(ke.name,Je.message)}),we});return}D(qe=>{const we=new Map(qe);return Me.forEach(ke=>we.delete(ke.name)),we});try{const qe=s.config.transport;if(qe.mode!=="proxy")throw new Error("File uploads are only supported with proxy transport");const we={presignedUrlEndpoint:`${qe.baseUrl}/files/upload/presigned`,getAuthHeaders:()=>{const Le={};return qe.apiKey&&(Le.Authorization=`Bearer ${qe.apiKey}`),Le}},ke=await f_e(Me,we,{chatId:t,userId:s.config.user?.id,onProgress:Le=>{P(de=>{const et=new Map(de);return et.set(Le.fileId,Le),et})}});k(d,ke),setTimeout(()=>{P(Le=>{const de=new Map(Le);return ke.forEach(et=>de.delete(et.id)),de})},2e3)}catch(qe){const we=qe instanceof Error?qe.message:"Failed to upload files";D(ke=>{const Le=new Map(ke);return Me.forEach(de=>{Le.set(de.name,we)}),Le})}},Y=()=>{u.current?.click()},N=re=>{const Me=i_e(re);if(!Me)return!1;if(E.some(qe=>qe.type===exports.AgentAttachmentType.Link&&qe.url===Me))return!0;const Ge=o_e(Me),Je={id:Tt.nanoid(),url:Me,name:Ge,type:exports.AgentAttachmentType.Link};return k(d,[Je]),!0},Z=async re=>{await T(re.target.files),re.target.value=""},te=re=>{const Me=E.find(Ge=>Ge.id===re);Me&&R(Me)&&M(d,!0),w(d,re)},I=()=>{if(typeof window>"u"||typeof document>"u")return!1;const re=W5(),Me=re?.selectedText??window.getSelection?.()?.toString()?.trim()??"";if(!Me)return!1;const Ge=window.location?.href,Je=Me.slice(0,20),qe=Me.length>20?Je+"...":Me,we=_o({kind:"webSnippet",url:Ge,title:qe,selectedText:Me,source:{app:"browser",url:Ge},...re?.target?{target:re.target}:{}});return k(d,[we]),!0},pe=re=>{re.preventDefault();const Me=S.trim();Me&&(v(d,void 0),a(Me))},ge=re=>{re.key==="Enter"&&!re.shiftKey&&(re.preventDefault(),pe(re))},ve=re=>{m&&v(d,void 0),g(d,re.target.value)},Ce=re=>{if(re.nativeEvent.shiftKey)return;const Me=re.clipboardData?.getData("text/plain")??"";if(!Me)return;N(Me)&&re.preventDefault()},He=!!S.trim();return O.jsxs("form",{onSubmit:pe,className:"mp-agent-composer-input-wrapper",children:[O.jsx("input",{ref:u,type:"file",multiple:!0,style:{display:"none"},onChange:Z}),O.jsx(d_e,{attachments:E,onRemove:te,uploadProgress:F,uploadErrors:C}),O.jsx("textarea",{rows:2,name:"message",ref:l,value:S,autoFocus:e,className:"mp-agent-composer-textarea",placeholder:t?o.followUp:o.newChat,onChange:ve,onKeyDown:ge,onPaste:Ce}),O.jsxs("div",{className:"mp-agent-composer-actions",children:[O.jsxs("div",{className:"mp-agent-composer-actions-left",children:[s.config.features?.modelSwitching&&O.jsx(a_e,{}),O.jsx(Jn,{content:o.attachFiles,children:O.jsx("button",{type:"button",className:"mp-agent-composer-button mp-agent-composer-tool-button",onClick:Y,"aria-label":o.attachFiles,children:O.jsx(lo,{size:16})})}),O.jsx(Jn,{content:o.attachSelectionToContext,children:O.jsx("button",{type:"button",className:"mp-agent-composer-button mp-agent-composer-tool-button",onClick:()=>{I()},"aria-label":o.attachSelectionToContext,children:O.jsx(Vd,{size:16})})}),V&&!q&&O.jsx(Jn,{content:"Attach page context",children:O.jsx("button",{type:"button",className:"mp-agent-composer-button mp-agent-composer-tool-button",onClick:()=>{M(d,!1);const re=G();re&&k(d,[re])},"aria-label":"Attach page context",children:O.jsx(jd,{size:16})})})]}),O.jsx("div",{className:"mp-agent-composer-actions-right",children:n===an.Streaming&&!He?O.jsx(Jn,{content:o.stopStreaming,children:O.jsx("button",{type:"button",onClick:r,"aria-label":o.stopStreaming,className:"mp-agent-composer-button mp-agent-composer-send-button",children:O.jsx(o5,{size:12})})}):O.jsx(Jn,{content:He?o.sendMessage:o.typeMessageToSend,children:O.jsx("button",{type:"submit",disabled:!He,"aria-label":o.sendMessage,className:"mp-agent-composer-button mp-agent-composer-send-button",children:O.jsx(Hd,{size:16})})})})]}),m?O.jsx("div",{className:"mp-agent-composer-error",children:m}):null]})}),b3=({autoFocus:e})=>{const t=ee.useRef({setValue:()=>{},getDraft:()=>({value:"",attachments:[]}),setDraft:()=>{},clearDraft:()=>{}}),{pendingKey:n,queuedMessages:r,activeChatStatus:a,activeChatId:i,handleSubmit:o,handleStop:s,handleQueuedClick:l,removeQueuedMessage:u}=t_e({composerFormRef:t});return O.jsx("div",{className:"mp-agent-composer-wrapper",children:O.jsxs("div",{className:"mp-agent-composer",children:[O.jsx(n_e,{queuedMessages:r,onSendQueued:l,onRemoveQueued:d=>u(n,d)}),O.jsx(b_e,{status:a,ref:t,autoFocus:e,activeChatId:i,onStop:s,onSubmit:o})]})})},k_e=()=>{const e=vt(),t=e.config.user?.id??rp(),{activeChatId:n,setActiveChat:r,removeChat:a}=Fe(u=>({activeChatId:u.activeChatId,setActiveChat:u.setActiveChat,removeChat:u.removeChat})),[i,o]=ee.useState(new Set),s=ee.useCallback(async u=>{o(d=>new Set(d).add(u));try{await e.transport.deleteChat(u),a(u),n===u&&r(void 0),e.queryClient.invalidateQueries({queryKey:["mp-agents","chats",t]})}finally{o(d=>{const p=new Set(d);return p.delete(u),p})}},[n,a,e.queryClient,e.transport,r,t]),l=ee.useCallback(u=>i.has(u),[i]);return{deleteChat:s,isDeleting:l}},v_e=()=>{const e=Mr(),{deleteChat:t,isDeleting:n}=k_e(),{chats:r,activeChatId:a,setActiveChat:i}=Fe(s=>({chats:s.chats,activeChatId:s.activeChatId,setActiveChat:s.setActiveChat})),o=ee.useMemo(()=>Object.values(r).sort((s,l)=>s.updatedAt===l.updatedAt?0:s.updatedAt<l.updatedAt?1:-1),[r]);return O.jsxs("section",{className:"mp-agent-chat-history",children:[O.jsx("h4",{children:e.chats}),o.length===0?O.jsx("div",{className:"mp-agent-chat-history-empty",children:e.noChatsYet}):O.jsx("ul",{className:"mp-agent-chat-history-list",children:o.map(s=>{const l=s.id===a;return O.jsxs("li",{onClick:()=>i(s.id),className:`mp-agent-chat-history-item${l?" active":""}`,children:[O.jsxs("div",{className:"mp-agent-chat-history-item-content",children:[O.jsx("span",{className:"mp-agent-chat-history-item-title",children:s.title||e.untitledChat}),O.jsx("span",{className:"mp-agent-chat-history-item-meta",children:new Date(s.updatedAt).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),O.jsx("div",{className:"mp-agent-chat-history-item-actions",children:O.jsx(Jn,{content:e.deleteChat,children:O.jsx(ar,{size:"sm",icon:"Archive","aria-label":e.deleteChat,disabled:n(s.id),onClick:u=>{u.stopPropagation(),t(s.id)}})})})]},s.id)})})]})},__e=e=>{const t=vt(),n=Fe(a=>a.isChatHistoryOpen);return!(t.config.features?.historySidebar!==!1)||!n?null:O.jsx("div",{className:"mp-agent-chat-history-panel",children:O.jsx(v_e,{})})},w_e=({onClose:e})=>{const t=Mr(),r=vt().config.features?.historySidebar!==!1,{isChatHistoryOpen:a,setChatHistoryOpen:i,setActiveChat:o}=Fe(l=>({isChatHistoryOpen:l.isChatHistoryOpen,setActiveChat:l.setActiveChat,setChatHistoryOpen:l.setChatHistoryOpen})),s=()=>{o(void 0)};return O.jsxs("div",{className:"mp-agent-agent-controls",children:[O.jsxs("div",{className:"mp-agent-agent-controls-left",children:[r&&O.jsx(ar,{onClick:()=>i(!a),icon:a?"PanelLeftClose":"PanelLeftOpen",tooltip:a?t.hideChatHistory:t.showChatHistory,"aria-label":a?t.hideChatHistory:t.showChatHistory}),O.jsx(ar,{onClick:s,icon:"SquarePen","aria-label":t.newChat,tooltip:t.newChat})]}),t.panelTitle&&O.jsx("div",{className:"mp-agent-agent-controls-title",children:O.jsx("h4",{children:t.panelTitle})}),e&&O.jsx("div",{className:"mp-agent-agent-controls-right",children:O.jsx(ar,{onClick:e,icon:"X","aria-label":t.close,tooltip:t.close})})]})},x_e=({children:e})=>{const t=Fe(n=>n.isChatHistoryOpen);return O.jsx("section",{className:`mp-agent-main ${t?"with-chat-history":""}`,children:e})},k3=ee.memo(({role:e,isGrouped:t})=>{if(t)return O.jsx("div",{className:"mp-agent-message-avatar-spacer"});const n=e===exports.MessageRole.User,r=n?"You":"AI";return O.jsx("div",{className:`mp-agent-message-avatar ${n?"mp-agent-message-avatar-user":""}`,children:O.jsx("div",{className:"mp-agent-message-avatar-icon",children:r})})});k3.displayName="MessageAvatar";const E_e=e=>e?new Date(e).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}):"",v3=ee.memo(({role:e,createdAt:t,isGrouped:n})=>{if(n)return null;const a=e===exports.MessageRole.User?"You":"Assistant";return O.jsxs("div",{className:"mp-agent-message-header",children:[O.jsx("span",{className:"mp-agent-message-role",children:a}),O.jsx("span",{className:"mp-agent-message-time",children:E_e(t)})]})});v3.displayName="MessageHeader";function g2(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 M_e(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const S_e=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,N_e=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,A_e={};function y2(e,t){return(A_e.jsx?N_e:S_e).test(e)}const T_e=/[ \t\n\f\r]/g;function C_e(e){return typeof e=="object"?e.type==="text"?b2(e.value):!1:b2(e)}function b2(e){return e.replace(T_e,"")===""}let Ua=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Ua.prototype.normal={};Ua.prototype.property={};Ua.prototype.space=void 0;function _3(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Ua(n,r,t)}function Ta(e){return e.toLowerCase()}let Vt=class{constructor(t,n){this.attribute=n,this.property=t}};Vt.prototype.attribute="";Vt.prototype.booleanish=!1;Vt.prototype.boolean=!1;Vt.prototype.commaOrSpaceSeparated=!1;Vt.prototype.commaSeparated=!1;Vt.prototype.defined=!1;Vt.prototype.mustUseProperty=!1;Vt.prototype.number=!1;Vt.prototype.overloadedBoolean=!1;Vt.prototype.property="";Vt.prototype.spaceSeparated=!1;Vt.prototype.space=void 0;let R_e=0;const De=Sr(),yt=Sr(),gd=Sr(),ce=Sr(),it=Sr(),Kr=Sr(),Yt=Sr();function Sr(){return 2**++R_e}const yd=Object.freeze(Object.defineProperty({__proto__:null,boolean:De,booleanish:yt,commaOrSpaceSeparated:Yt,commaSeparated:Kr,number:ce,overloadedBoolean:gd,spaceSeparated:it},Symbol.toStringTag,{value:"Module"})),us=Object.keys(yd);let op=class extends Vt{constructor(t,n,r,a){let i=-1;if(super(t,n),k2(this,"space",a),typeof r=="number")for(;++i<us.length;){const o=us[i];k2(this,us[i],(r&yd[o])===yd[o])}}};op.prototype.defined=!0;function k2(e,t,n){n&&(e[t]=n)}function ta(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const i=new op(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[Ta(r)]=r,n[Ta(i.attribute)]=r}return new Ua(t,n,e.space)}const w3=ta({properties:{ariaActiveDescendant:null,ariaAtomic:yt,ariaAutoComplete:null,ariaBusy:yt,ariaChecked:yt,ariaColCount:ce,ariaColIndex:ce,ariaColSpan:ce,ariaControls:it,ariaCurrent:null,ariaDescribedBy:it,ariaDetails:null,ariaDisabled:yt,ariaDropEffect:it,ariaErrorMessage:null,ariaExpanded:yt,ariaFlowTo:it,ariaGrabbed:yt,ariaHasPopup:null,ariaHidden:yt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:it,ariaLevel:ce,ariaLive:null,ariaModal:yt,ariaMultiLine:yt,ariaMultiSelectable:yt,ariaOrientation:null,ariaOwns:it,ariaPlaceholder:null,ariaPosInSet:ce,ariaPressed:yt,ariaReadOnly:yt,ariaRelevant:null,ariaRequired:yt,ariaRoleDescription:it,ariaRowCount:ce,ariaRowIndex:ce,ariaRowSpan:ce,ariaSelected:yt,ariaSetSize:ce,ariaSort:null,ariaValueMax:ce,ariaValueMin:ce,ariaValueNow:ce,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 E3(e,t){return x3(e,t.toLowerCase())}const I_e=ta({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Kr,acceptCharset:it,accessKey:it,action:null,allow:null,allowFullScreen:De,allowPaymentRequest:De,allowUserMedia:De,alt:null,as:null,async:De,autoCapitalize:null,autoComplete:it,autoFocus:De,autoPlay:De,blocking:it,capture:null,charSet:null,checked:De,cite:null,className:it,cols:ce,colSpan:null,content:null,contentEditable:yt,controls:De,controlsList:it,coords:ce|Kr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:De,defer:De,dir:null,dirName:null,disabled:De,download:gd,draggable:yt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:De,formTarget:null,headers:it,height:ce,hidden:gd,high:ce,href:null,hrefLang:null,htmlFor:it,httpEquiv:it,id:null,imageSizes:null,imageSrcSet:null,inert:De,inputMode:null,integrity:null,is:null,isMap:De,itemId:null,itemProp:it,itemRef:it,itemScope:De,itemType:it,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:De,low:ce,manifest:null,max:null,maxLength:ce,media:null,method:null,min:null,minLength:ce,multiple:De,muted:De,name:null,nonce:null,noModule:De,noValidate:De,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:De,optimum:ce,pattern:null,ping:it,placeholder:null,playsInline:De,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:De,referrerPolicy:null,rel:it,required:De,reversed:De,rows:ce,rowSpan:ce,sandbox:it,scope:null,scoped:De,seamless:De,selected:De,shadowRootClonable:De,shadowRootDelegatesFocus:De,shadowRootMode:null,shape:null,size:ce,sizes:null,slot:null,span:ce,spellCheck:yt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ce,step:null,style:null,tabIndex:ce,target:null,title:null,translate:null,type:null,typeMustMatch:De,useMap:null,value:yt,width:ce,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:it,axis:null,background:null,bgColor:null,border:ce,borderColor:null,bottomMargin:ce,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:De,declare:De,event:null,face:null,frame:null,frameBorder:null,hSpace:ce,leftMargin:ce,link:null,longDesc:null,lowSrc:null,marginHeight:ce,marginWidth:ce,noResize:De,noHref:De,noShade:De,noWrap:De,object:null,profile:null,prompt:null,rev:null,rightMargin:ce,rules:null,scheme:null,scrolling:yt,standby:null,summary:null,text:null,topMargin:ce,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ce,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:De,disableRemotePlayback:De,prefix:null,property:null,results:ce,security:null,unselectable:null},space:"html",transform:E3}),O_e=ta({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:Yt,accentHeight:ce,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ce,amplitude:ce,arabicForm:null,ascent:ce,attributeName:null,attributeType:null,azimuth:ce,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ce,by:null,calcMode:null,capHeight:ce,className:it,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:ce,diffuseConstant:ce,direction:null,display:null,dur:null,divisor:ce,dominantBaseline:null,download:De,dx:null,dy:null,edgeMode:null,editable:null,elevation:ce,enableBackground:null,end:null,event:null,exponent:ce,externalResourcesRequired:null,fill:null,fillOpacity:ce,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:Kr,g2:Kr,glyphName:Kr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ce,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ce,horizOriginX:ce,horizOriginY:ce,id:null,ideographic:ce,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ce,k:ce,k1:ce,k2:ce,k3:ce,k4:ce,kernelMatrix:Yt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ce,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:ce,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:ce,overlineThickness:ce,paintOrder:null,panose1:null,path:null,pathLength:ce,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:it,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ce,pointsAtY:ce,pointsAtZ:ce,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Yt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Yt,rev:Yt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Yt,requiredFeatures:Yt,requiredFonts:Yt,requiredFormats:Yt,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:ce,specularExponent:ce,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ce,strikethroughThickness:ce,string:null,stroke:null,strokeDashArray:Yt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ce,strokeOpacity:ce,strokeWidth:null,style:null,surfaceScale:ce,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Yt,tabIndex:ce,tableValues:null,target:null,targetX:ce,targetY:ce,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Yt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ce,underlineThickness:ce,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ce,values:null,vAlphabetic:ce,vMathematical:ce,vectorEffect:null,vHanging:ce,vIdeographic:ce,version:null,vertAdvY:ce,vertOriginX:ce,vertOriginY:ce,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ce,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:x3}),M3=ta({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()}}),S3=ta({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:E3}),N3=ta({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),L_e={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"},D_e=/[A-Z]/g,v2=/-[a-z]/g,z_e=/^data[-\w.:]+$/i;function A3(e,t){const n=Ta(t);let r=t,a=Vt;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&z_e.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(v2,F_e);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!v2.test(i)){let o=i.replace(D_e,$_e);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}a=op}return new a(r,t)}function $_e(e){return"-"+e.toLowerCase()}function F_e(e){return e.charAt(1).toUpperCase()}const T3=_3([w3,I_e,M3,S3,N3],"html"),Eo=_3([w3,O_e,M3,S3,N3],"svg");function _2(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function P_e(e){return e.join(" ").trim()}var sp={},w2=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,B_e=/\n/g,q_e=/^\s*/,U_e=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,H_e=/^:\s*/,j_e=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,V_e=/^[;\s]*/,G_e=/^\s+|\s+$/g,W_e=`
8323
8323
  `,x2="/",E2="*",kr="",K_e="comment",Y_e="declaration";function Z_e(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 y=g.match(B_e);y&&(n+=y.length);var _=g.lastIndexOf(W_e);r=~_?g.length-_:r+g.length}function i(){var g={line:n,column:r};return function(y){return y.position=new o(g),u(),y}}function o(g){this.start=g,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function s(g){var y=new Error(t.source+":"+n+":"+r+": "+g);if(y.reason=g,y.filename=t.source,y.line=n,y.column=r,y.source=e,!t.silent)throw y}function l(g){var y=g.exec(e);if(y){var _=y[0];return a(_),e=e.slice(_.length),y}}function u(){l(q_e)}function d(g){var y;for(g=g||[];y=p();)y!==!1&&g.push(y);return g}function p(){var g=i();if(!(x2!=e.charAt(0)||E2!=e.charAt(1))){for(var y=2;kr!=e.charAt(y)&&(E2!=e.charAt(y)||x2!=e.charAt(y+1));)++y;if(y+=2,kr===e.charAt(y-1))return s("End of comment missing");var _=e.slice(2,y-2);return r+=2,a(_),e=e.slice(y),r+=2,g({type:K_e,comment:_})}}function m(){var g=i(),y=l(U_e);if(y){if(p(),!l(H_e))return s("property missing ':'");var _=l(j_e),v=g({type:Y_e,property:M2(y[0].replace(w2,kr)),value:_?M2(_[0].replace(w2,kr)):kr});return l(V_e),v}}function h(){var g=[];d(g);for(var y;y=m();)y!==!1&&(g.push(y),d(g));return g}return u(),h()}function M2(e){return e?e.replace(G_e,kr):kr}var X_e=Z_e,Q_e=or&&or.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(sp,"__esModule",{value:!0});sp.default=ewe;const J_e=Q_e(X_e);function ewe(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,J_e.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 Mo={};Object.defineProperty(Mo,"__esModule",{value:!0});Mo.camelCase=void 0;var twe=/^--[a-zA-Z0-9_-]+$/,nwe=/-([a-z])/g,rwe=/^[^-]+$/,awe=/^-(webkit|moz|ms|o|khtml)-/,iwe=/^-(ms)-/,owe=function(e){return!e||rwe.test(e)||twe.test(e)},swe=function(e,t){return t.toUpperCase()},S2=function(e,t){return"".concat(t,"-")},lwe=function(e,t){return t===void 0&&(t={}),owe(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(iwe,S2):e=e.replace(awe,S2),e.replace(nwe,swe))};Mo.camelCase=lwe;var cwe=or&&or.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},uwe=cwe(sp),dwe=Mo;function bd(e,t){var n={};return!e||typeof e!="string"||(0,uwe.default)(e,function(r,a){r&&a&&(n[(0,dwe.camelCase)(r,t)]=a)}),n}bd.default=bd;var pwe=bd;const hwe=oo(pwe),C3=R3("end"),lp=R3("start");function R3(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 mwe(e){const t=lp(e),n=C3(e);if(t&&n)return{start:t,end:n}}function va(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?N2(e.position):"start"in e||"end"in e?N2(e):"line"in e||"column"in e?kd(e):""}function kd(e){return A2(e&&e.line)+":"+A2(e&&e.column)}function N2(e){return kd(e&&e.start)+"-"+kd(e&&e.end)}function A2(e){return e&&typeof e=="number"?e:1}class It 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=va(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}}It.prototype.file="";It.prototype.name="";It.prototype.reason="";It.prototype.message="";It.prototype.stack="";It.prototype.column=void 0;It.prototype.line=void 0;It.prototype.ancestors=void 0;It.prototype.cause=void 0;It.prototype.fatal=void 0;It.prototype.place=void 0;It.prototype.ruleId=void 0;It.prototype.source=void 0;const cp={}.hasOwnProperty,fwe=new Map,gwe=/[A-Z]/g,ywe=new Set(["table","tbody","thead","tfoot","tr"]),bwe=new Set(["td","th"]),I3="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function kwe(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=Nwe(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=Swe(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"?Eo:T3,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=O3(a,e,void 0);return i&&typeof i!="string"?i:a.create(e,a.Fragment,{children:i||void 0},void 0)}function O3(e,t,n){if(t.type==="element")return vwe(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return _we(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return xwe(e,t,n);if(t.type==="mdxjsEsm")return wwe(e,t);if(t.type==="root")return Ewe(e,t,n);if(t.type==="text")return Mwe(e,t)}function vwe(e,t,n){const r=e.schema;let a=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(a=Eo,e.schema=a),e.ancestors.push(t);const i=D3(e,t.tagName,!1),o=Awe(e,t);let s=dp(e,t);return ywe.has(t.tagName)&&(s=s.filter(function(l){return typeof l=="string"?!C_e(l):!0})),L3(e,o,i,t),up(o,s),e.ancestors.pop(),e.schema=r,e.create(t,i,o,n)}function _we(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)}Ca(e,t.position)}function wwe(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Ca(e,t.position)}function xwe(e,t,n){const r=e.schema;let a=r;t.name==="svg"&&r.space==="html"&&(a=Eo,e.schema=a),e.ancestors.push(t);const i=t.name===null?e.Fragment:D3(e,t.name,!0),o=Twe(e,t),s=dp(e,t);return L3(e,o,i,t),up(o,s),e.ancestors.pop(),e.schema=r,e.create(t,i,o,n)}function Ewe(e,t,n){const r={};return up(r,dp(e,t)),e.create(t,e.Fragment,r,n)}function Mwe(e,t){return t.value}function L3(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function up(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Swe(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 Nwe(e,t){return n;function n(r,a,i,o){const s=Array.isArray(i.children),l=lp(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 Awe(e,t){const n={};let r,a;for(a in t.properties)if(a!=="children"&&cp.call(t.properties,a)){const i=Cwe(e,a,t.properties[a]);if(i){const[o,s]=i;e.tableCellAlignToStyle&&o==="align"&&typeof s=="string"&&bwe.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 Twe(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 Ca(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 Ca(e,t.position);else i=r.value===null?!0:r.value;n[a]=i}return n}function dp(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:fwe;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=O3(e,i,o);s!==void 0&&n.push(s)}return n}function Cwe(e,t,n){const r=A3(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?M_e(n):P_e(n)),r.property==="style"){let a=typeof n=="object"?n:Rwe(e,String(n));return e.stylePropertyNameCase==="css"&&(a=Iwe(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&r.space?L_e[r.property]||r.property:r.attribute,n]}}function Rwe(e,t){try{return hwe(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,a=new It("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=I3+"#cannot-parse-style-attribute",a}}function D3(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=y2(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=y2(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const a=r.value;return cp.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(r);Ca(e)}function Ca(e,t){const n=new It("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=I3+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Iwe(e){const t={};let n;for(n in e)cp.call(e,n)&&(t[Owe(n)]=e[n]);return t}function Owe(e){let t=e.replace(gwe,Lwe);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Lwe(e){return"-"+e.toLowerCase()}const ds={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"]},Dwe={};function pp(e,t){const n=Dwe,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return z3(e,r,a)}function z3(e,t,n){if(zwe(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 T2(e.children,t,n)}return Array.isArray(e)?T2(e,t,n):""}function T2(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=z3(e[a],t,n);return r.join("")}function zwe(e){return!!(e&&typeof e=="object")}const C2=document.createElement("i");function Ra(e){const t="&"+e+";";C2.innerHTML=t;const n=C2.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Qt(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 sn(e,t){return e.length>0?(Qt(e,e.length,0,t),e):t}const R2={}.hasOwnProperty;function $3(e){const t={};let n=-1;for(;++n<e.length;)$we(t,e[n]);return t}function $we(e,t){let n;for(n in t){const a=(R2.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let o;if(i)for(o in i){R2.call(a,o)||(a[o]=[]);const s=i[o];Fwe(a[o],Array.isArray(s)?s:s?[s]:[])}}}function Fwe(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Qt(e,0,0,r)}function F3(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 bn(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const $t=dr(/[A-Za-z]/),Ct=dr(/[\dA-Za-z]/),Pwe=dr(/[#-'*+\--9=?A-Z^-~]/);function Gi(e){return e!==null&&(e<32||e===127)}const vd=dr(/\d/),Bwe=dr(/[\dA-Fa-f]/),qwe=dr(/[!-/:-@[-`{-~]/);function me(e){return e!==null&&e<-2}function Ze(e){return e!==null&&(e<0||e===32)}function Pe(e){return e===-2||e===-1||e===32}const sr=dr(/\p{P}|\p{S}/u),kn=dr(/\s/);function dr(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function na(e){const t=[];let n=-1,r=0,a=0;for(;++n<e.length;){const i=e.charCodeAt(n);let o="";if(i===37&&Ct(e.charCodeAt(n+1))&&Ct(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 Oe(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let i=0;return o;function o(l){return Pe(l)?(e.enter(n),s(l)):t(l)}function s(l){return Pe(l)&&i++<a?(e.consume(l),s):(e.exit(n),t(l))}}const Uwe={tokenize:Hwe};function Hwe(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"),Oe(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 me(s)?(e.consume(s),e.exit("chunkText"),i):(e.consume(s),o)}}const jwe={tokenize:Vwe},I2={tokenize:Gwe};function Vwe(e){const t=this,n=[];let r=0,a,i,o;return s;function s(w){if(r<n.length){const M=n[r];return t.containerState=M[1],e.attempt(M[0].continuation,l,u)(w)}return u(w)}function l(w){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&k();const M=t.events.length;let S=M,E;for(;S--;)if(t.events[S][0]==="exit"&&t.events[S][1].type==="chunkFlow"){E=t.events[S][1].end;break}v(r);let F=M;for(;F<t.events.length;)t.events[F][1].end={...E},F++;return Qt(t.events,S+1,0,t.events.slice(M)),t.events.length=F,u(w)}return s(w)}function u(w){if(r===n.length){if(!a)return m(w);if(a.currentConstruct&&a.currentConstruct.concrete)return g(w);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(I2,d,p)(w)}function d(w){return a&&k(),v(r),m(w)}function p(w){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,g(w)}function m(w){return t.containerState={},e.attempt(I2,h,g)(w)}function h(w){return r++,n.push([t.currentConstruct,t.containerState]),m(w)}function g(w){if(w===null){a&&k(),v(0),e.consume(w);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:i}),y(w)}function y(w){if(w===null){_(e.exit("chunkFlow"),!0),v(0),e.consume(w);return}return me(w)?(e.consume(w),_(e.exit("chunkFlow")),r=0,t.interrupt=void 0,s):(e.consume(w),y)}function _(w,M){const S=t.sliceStream(w);if(M&&S.push(null),w.previous=i,i&&(i.next=w),i=w,a.defineSkip(w.start),a.write(S),t.parser.lazy[w.start.line]){let E=a.events.length;for(;E--;)if(a.events[E][1].start.offset<o&&(!a.events[E][1].end||a.events[E][1].end.offset>o))return;const F=t.events.length;let P=F,C,D;for(;P--;)if(t.events[P][0]==="exit"&&t.events[P][1].type==="chunkFlow"){if(C){D=t.events[P][1].end;break}C=!0}for(v(r),E=F;E<t.events.length;)t.events[E][1].end={...D},E++;Qt(t.events,P+1,0,t.events.slice(F)),t.events.length=E}}function v(w){let M=n.length;for(;M-- >w;){const S=n[M];t.containerState=S[1],S[0].exit.call(t,e)}n.length=w}function k(){a.write([null]),i=void 0,a=void 0,t.containerState._closeFlow=void 0}}function Gwe(e,t,n){return Oe(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Zr(e){if(e===null||Ze(e)||kn(e))return 1;if(sr(e))return 2}function So(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 _d={name:"attention",resolveAll:Wwe,tokenize:Kwe};function Wwe(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};O2(p,-l),O2(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=sn(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=sn(u,[["enter",a,t],["enter",o,t],["exit",o,t],["enter",i,t]]),u=sn(u,So(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=sn(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=sn(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,Qt(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 Kwe(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,a=Zr(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=Zr(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 O2(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Ywe={name:"autolink",tokenize:Zwe};function Zwe(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 $t(h)?(e.consume(h),o):h===64?n(h):u(h)}function o(h){return h===43||h===45||h===46||Ct(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||Ct(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||Gi(h)?n(h):(e.consume(h),l)}function u(h){return h===64?(e.consume(h),d):Pwe(h)?(e.consume(h),u):n(h)}function d(h){return Ct(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||Ct(h))&&r++<63){const g=h===45?m:p;return e.consume(h),g}return n(h)}}const Ha={partial:!0,tokenize:Xwe};function Xwe(e,t,n){return r;function r(i){return Pe(i)?Oe(e,a,"linePrefix")(i):a(i)}function a(i){return i===null||me(i)?t(i):n(i)}}const P3={continuation:{tokenize:Jwe},exit:exe,name:"blockQuote",tokenize:Qwe};function Qwe(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 Pe(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function Jwe(e,t,n){const r=this;return a;function a(o){return Pe(o)?Oe(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):i(o)}function i(o){return e.attempt(P3,t,n)(o)}}function exe(e){e.exit("blockQuote")}const B3={name:"characterEscape",tokenize:txe};function txe(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 qwe(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const q3={name:"characterReference",tokenize:nxe};function nxe(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=Ct,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=Bwe,d):(e.enter("characterReferenceValue"),i=7,o=vd,d(p))}function d(p){if(p===59&&a){const m=e.exit("characterReferenceValue");return o===Ct&&!Ra(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 L2={partial:!0,tokenize:axe},D2={concrete:!0,name:"codeFenced",tokenize:rxe};function rxe(e,t,n){const r=this,a={partial:!0,tokenize:S};let i=0,o=0,s;return l;function l(E){return u(E)}function u(E){const F=r.events[r.events.length-1];return i=F&&F[1].type==="linePrefix"?F[2].sliceSerialize(F[1],!0).length:0,s=E,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(E)}function d(E){return E===s?(o++,e.consume(E),d):o<3?n(E):(e.exit("codeFencedFenceSequence"),Pe(E)?Oe(e,p,"whitespace")(E):p(E))}function p(E){return E===null||me(E)?(e.exit("codeFencedFence"),r.interrupt?t(E):e.check(L2,y,M)(E)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),m(E))}function m(E){return E===null||me(E)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(E)):Pe(E)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Oe(e,h,"whitespace")(E)):E===96&&E===s?n(E):(e.consume(E),m)}function h(E){return E===null||me(E)?p(E):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(E))}function g(E){return E===null||me(E)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(E)):E===96&&E===s?n(E):(e.consume(E),g)}function y(E){return e.attempt(a,M,_)(E)}function _(E){return e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),v}function v(E){return i>0&&Pe(E)?Oe(e,k,"linePrefix",i+1)(E):k(E)}function k(E){return E===null||me(E)?e.check(L2,y,M)(E):(e.enter("codeFlowValue"),w(E))}function w(E){return E===null||me(E)?(e.exit("codeFlowValue"),k(E)):(e.consume(E),w)}function M(E){return e.exit("codeFenced"),t(E)}function S(E,F,P){let C=0;return D;function D(R){return E.enter("lineEnding"),E.consume(R),E.exit("lineEnding"),W}function W(R){return E.enter("codeFencedFence"),Pe(R)?Oe(E,K,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):K(R)}function K(R){return R===s?(E.enter("codeFencedFenceSequence"),J(R)):P(R)}function J(R){return R===s?(C++,E.consume(R),J):C>=o?(E.exit("codeFencedFenceSequence"),Pe(R)?Oe(E,V,"whitespace")(R):V(R)):P(R)}function V(R){return R===null||me(R)?(E.exit("codeFencedFence"),F(R)):P(R)}}}function axe(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 ps={name:"codeIndented",tokenize:oxe},ixe={partial:!0,tokenize:sxe};function oxe(e,t,n){const r=this;return a;function a(u){return e.enter("codeIndented"),Oe(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):me(u)?e.attempt(ixe,o,l)(u):(e.enter("codeFlowValue"),s(u))}function s(u){return u===null||me(u)?(e.exit("codeFlowValue"),o(u)):(e.consume(u),s)}function l(u){return e.exit("codeIndented"),t(u)}}function sxe(e,t,n){const r=this;return a;function a(o){return r.parser.lazy[r.now().line]?n(o):me(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a):Oe(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):me(o)?a(o):n(o)}}const lxe={name:"codeText",previous:uxe,resolve:cxe,tokenize:dxe};function cxe(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 uxe(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function dxe(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)):me(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||me(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 pxe{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&&ca(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),ca(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),ca(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);ca(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);ca(this.left,n.reverse())}}}function ca(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 U3(e){const t={};let n=-1,r,a,i,o,s,l,u;const d=new pxe(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,hxe(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 Qt(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function hxe(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,y=0;const _=[y];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&&(y=m+1,_.push(y),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(o.events=[],h?(h._tokenizer=void 0,h.previous=void 0):_.pop(),m=_.length;m--;){const v=s.slice(_[m],_[m+1]),k=i.pop();l.push([k,k+v.length-1]),e.splice(k,2,v)}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 mxe={resolve:gxe,tokenize:yxe},fxe={partial:!0,tokenize:bxe};function gxe(e){return U3(e),e}function yxe(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):me(s)?e.check(fxe,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 bxe(e,t,n){const r=this;return a;function a(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Oe(e,i,"linePrefix")}function i(o){if(o===null||me(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 H3(e,t,n,r,a,i,o,s,l){const u=l||Number.POSITIVE_INFINITY;let d=0;return p;function p(v){return v===60?(e.enter(r),e.enter(a),e.enter(i),e.consume(v),e.exit(i),m):v===null||v===32||v===41||Gi(v)?n(v):(e.enter(r),e.enter(o),e.enter(s),e.enter("chunkString",{contentType:"string"}),y(v))}function m(v){return v===62?(e.enter(i),e.consume(v),e.exit(i),e.exit(a),e.exit(r),t):(e.enter(s),e.enter("chunkString",{contentType:"string"}),h(v))}function h(v){return v===62?(e.exit("chunkString"),e.exit(s),m(v)):v===null||v===60||me(v)?n(v):(e.consume(v),v===92?g:h)}function g(v){return v===60||v===62||v===92?(e.consume(v),h):h(v)}function y(v){return!d&&(v===null||v===41||Ze(v))?(e.exit("chunkString"),e.exit(s),e.exit(o),e.exit(r),t(v)):d<u&&v===40?(e.consume(v),d++,y):v===41?(e.consume(v),d--,y):v===null||v===32||v===40||Gi(v)?n(v):(e.consume(v),v===92?_:y)}function _(v){return v===40||v===41||v===92?(e.consume(v),y):y(v)}}function j3(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):me(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||me(h)||s++>999?(e.exit("chunkString"),d(h)):(e.consume(h),l||(l=!Pe(h)),h===92?m:p)}function m(h){return h===91||h===92||h===93?(e.consume(h),s++,p):p(h)}}function V3(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):me(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),Oe(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(m))}function d(m){return m===o||m===null||me(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 Bn(e,t){let n;return r;function r(a){return me(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r):Pe(a)?Oe(e,r,n?"linePrefix":"lineSuffix")(a):t(a)}}const kxe={name:"definition",tokenize:_xe},vxe={partial:!0,tokenize:wxe};function _xe(e,t,n){const r=this;let a;return i;function i(h){return e.enter("definition"),o(h)}function o(h){return j3.call(r,e,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function s(h){return a=bn(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 Ze(h)?Bn(e,u)(h):u(h)}function u(h){return H3(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function d(h){return e.attempt(vxe,p,p)(h)}function p(h){return Pe(h)?Oe(e,m,"whitespace")(h):m(h)}function m(h){return h===null||me(h)?(e.exit("definition"),r.parser.defined.push(a),t(h)):n(h)}}function wxe(e,t,n){return r;function r(s){return Ze(s)?Bn(e,a)(s):n(s)}function a(s){return V3(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(s)}function i(s){return Pe(s)?Oe(e,o,"whitespace")(s):o(s)}function o(s){return s===null||me(s)?t(s):n(s)}}const xxe={name:"hardBreakEscape",tokenize:Exe};function Exe(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),a}function a(i){return me(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const Mxe={name:"headingAtx",resolve:Sxe,tokenize:Nxe};function Sxe(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"},Qt(e,r,n-r+1,[["enter",a,t],["enter",i,t],["exit",i,t],["exit",a,t]])),e}function Nxe(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||Ze(d)?(e.exit("atxHeadingSequence"),s(d)):n(d)}function s(d){return d===35?(e.enter("atxHeadingSequence"),l(d)):d===null||me(d)?(e.exit("atxHeading"),t(d)):Pe(d)?Oe(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||Ze(d)?(e.exit("atxHeadingText"),s(d)):(e.consume(d),u)}}const Axe=["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"],Txe={concrete:!0,name:"htmlFlow",resolveTo:Ixe,tokenize:Oxe},Cxe={partial:!0,tokenize:Dxe},Rxe={partial:!0,tokenize:Lxe};function Ixe(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 Oxe(e,t,n){const r=this;let a,i,o,s,l;return u;function u(I){return d(I)}function d(I){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(I),p}function p(I){return I===33?(e.consume(I),m):I===47?(e.consume(I),i=!0,y):I===63?(e.consume(I),a=3,r.interrupt?t:N):$t(I)?(e.consume(I),o=String.fromCharCode(I),_):n(I)}function m(I){return I===45?(e.consume(I),a=2,h):I===91?(e.consume(I),a=5,s=0,g):$t(I)?(e.consume(I),a=4,r.interrupt?t:N):n(I)}function h(I){return I===45?(e.consume(I),r.interrupt?t:N):n(I)}function g(I){const pe="CDATA[";return I===pe.charCodeAt(s++)?(e.consume(I),s===pe.length?r.interrupt?t:K:g):n(I)}function y(I){return $t(I)?(e.consume(I),o=String.fromCharCode(I),_):n(I)}function _(I){if(I===null||I===47||I===62||Ze(I)){const pe=I===47,ge=o.toLowerCase();return!pe&&!i&&z2.includes(ge)?(a=1,r.interrupt?t(I):K(I)):Axe.includes(o.toLowerCase())?(a=6,pe?(e.consume(I),v):r.interrupt?t(I):K(I)):(a=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(I):i?k(I):w(I))}return I===45||Ct(I)?(e.consume(I),o+=String.fromCharCode(I),_):n(I)}function v(I){return I===62?(e.consume(I),r.interrupt?t:K):n(I)}function k(I){return Pe(I)?(e.consume(I),k):D(I)}function w(I){return I===47?(e.consume(I),D):I===58||I===95||$t(I)?(e.consume(I),M):Pe(I)?(e.consume(I),w):D(I)}function M(I){return I===45||I===46||I===58||I===95||Ct(I)?(e.consume(I),M):S(I)}function S(I){return I===61?(e.consume(I),E):Pe(I)?(e.consume(I),S):w(I)}function E(I){return I===null||I===60||I===61||I===62||I===96?n(I):I===34||I===39?(e.consume(I),l=I,F):Pe(I)?(e.consume(I),E):P(I)}function F(I){return I===l?(e.consume(I),l=null,C):I===null||me(I)?n(I):(e.consume(I),F)}function P(I){return I===null||I===34||I===39||I===47||I===60||I===61||I===62||I===96||Ze(I)?S(I):(e.consume(I),P)}function C(I){return I===47||I===62||Pe(I)?w(I):n(I)}function D(I){return I===62?(e.consume(I),W):n(I)}function W(I){return I===null||me(I)?K(I):Pe(I)?(e.consume(I),W):n(I)}function K(I){return I===45&&a===2?(e.consume(I),q):I===60&&a===1?(e.consume(I),G):I===62&&a===4?(e.consume(I),Z):I===63&&a===3?(e.consume(I),N):I===93&&a===5?(e.consume(I),Y):me(I)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(Cxe,te,J)(I)):I===null||me(I)?(e.exit("htmlFlowData"),J(I)):(e.consume(I),K)}function J(I){return e.check(Rxe,V,te)(I)}function V(I){return e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),R}function R(I){return I===null||me(I)?J(I):(e.enter("htmlFlowData"),K(I))}function q(I){return I===45?(e.consume(I),N):K(I)}function G(I){return I===47?(e.consume(I),o="",T):K(I)}function T(I){if(I===62){const pe=o.toLowerCase();return z2.includes(pe)?(e.consume(I),Z):K(I)}return $t(I)&&o.length<8?(e.consume(I),o+=String.fromCharCode(I),T):K(I)}function Y(I){return I===93?(e.consume(I),N):K(I)}function N(I){return I===62?(e.consume(I),Z):I===45&&a===2?(e.consume(I),N):K(I)}function Z(I){return I===null||me(I)?(e.exit("htmlFlowData"),te(I)):(e.consume(I),Z)}function te(I){return e.exit("htmlFlow"),t(I)}}function Lxe(e,t,n){const r=this;return a;function a(o){return me(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 Dxe(e,t,n){return r;function r(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(Ha,t,n)}}const zxe={name:"htmlText",tokenize:$xe};function $xe(e,t,n){const r=this;let a,i,o;return s;function s(N){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(N),l}function l(N){return N===33?(e.consume(N),u):N===47?(e.consume(N),S):N===63?(e.consume(N),w):$t(N)?(e.consume(N),P):n(N)}function u(N){return N===45?(e.consume(N),d):N===91?(e.consume(N),i=0,g):$t(N)?(e.consume(N),k):n(N)}function d(N){return N===45?(e.consume(N),h):n(N)}function p(N){return N===null?n(N):N===45?(e.consume(N),m):me(N)?(o=p,G(N)):(e.consume(N),p)}function m(N){return N===45?(e.consume(N),h):p(N)}function h(N){return N===62?q(N):N===45?m(N):p(N)}function g(N){const Z="CDATA[";return N===Z.charCodeAt(i++)?(e.consume(N),i===Z.length?y:g):n(N)}function y(N){return N===null?n(N):N===93?(e.consume(N),_):me(N)?(o=y,G(N)):(e.consume(N),y)}function _(N){return N===93?(e.consume(N),v):y(N)}function v(N){return N===62?q(N):N===93?(e.consume(N),v):y(N)}function k(N){return N===null||N===62?q(N):me(N)?(o=k,G(N)):(e.consume(N),k)}function w(N){return N===null?n(N):N===63?(e.consume(N),M):me(N)?(o=w,G(N)):(e.consume(N),w)}function M(N){return N===62?q(N):w(N)}function S(N){return $t(N)?(e.consume(N),E):n(N)}function E(N){return N===45||Ct(N)?(e.consume(N),E):F(N)}function F(N){return me(N)?(o=F,G(N)):Pe(N)?(e.consume(N),F):q(N)}function P(N){return N===45||Ct(N)?(e.consume(N),P):N===47||N===62||Ze(N)?C(N):n(N)}function C(N){return N===47?(e.consume(N),q):N===58||N===95||$t(N)?(e.consume(N),D):me(N)?(o=C,G(N)):Pe(N)?(e.consume(N),C):q(N)}function D(N){return N===45||N===46||N===58||N===95||Ct(N)?(e.consume(N),D):W(N)}function W(N){return N===61?(e.consume(N),K):me(N)?(o=W,G(N)):Pe(N)?(e.consume(N),W):C(N)}function K(N){return N===null||N===60||N===61||N===62||N===96?n(N):N===34||N===39?(e.consume(N),a=N,J):me(N)?(o=K,G(N)):Pe(N)?(e.consume(N),K):(e.consume(N),V)}function J(N){return N===a?(e.consume(N),a=void 0,R):N===null?n(N):me(N)?(o=J,G(N)):(e.consume(N),J)}function V(N){return N===null||N===34||N===39||N===60||N===61||N===96?n(N):N===47||N===62||Ze(N)?C(N):(e.consume(N),V)}function R(N){return N===47||N===62||Ze(N)?C(N):n(N)}function q(N){return N===62?(e.consume(N),e.exit("htmlTextData"),e.exit("htmlText"),t):n(N)}function G(N){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),T}function T(N){return Pe(N)?Oe(e,Y,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(N):Y(N)}function Y(N){return e.enter("htmlTextData"),o(N)}}const hp={name:"labelEnd",resolveAll:qxe,resolveTo:Uxe,tokenize:Hxe},Fxe={tokenize:jxe},Pxe={tokenize:Vxe},Bxe={tokenize:Gxe};function qxe(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&&Qt(e,0,e.length,n),e}function Uxe(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=sn(s,e.slice(i+1,i+r+3)),s=sn(s,[["enter",d,t]]),s=sn(s,So(t.parser.constructs.insideSpan.null,e.slice(i+r+4,o-3),t)),s=sn(s,[["exit",d,t],e[o-2],e[o-1],["exit",u,t]]),s=sn(s,e.slice(o+1)),s=sn(s,[["exit",l,t]]),Qt(e,i,e.length,s),e}function Hxe(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(bn(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(Fxe,d,o?d:p)(m):m===91?e.attempt(Pxe,d,o?u:p)(m):o?d(m):p(m)}function u(m){return e.attempt(Bxe,d,p)(m)}function d(m){return t(m)}function p(m){return i._balanced=!0,n(m)}}function jxe(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 Ze(p)?Bn(e,i)(p):i(p)}function i(p){return p===41?d(p):H3(e,o,s,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function o(p){return Ze(p)?Bn(e,l)(p):d(p)}function s(p){return n(p)}function l(p){return p===34||p===39||p===40?V3(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):d(p)}function u(p){return Ze(p)?Bn(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 Vxe(e,t,n){const r=this;return a;function a(s){return j3.call(r,e,i,o,"reference","referenceMarker","referenceString")(s)}function i(s){return r.parser.defined.includes(bn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function Gxe(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 Wxe={name:"labelStartImage",resolveAll:hp.resolveAll,tokenize:Kxe};function Kxe(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 Yxe={name:"labelStartLink",resolveAll:hp.resolveAll,tokenize:Zxe};function Zxe(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 hs={name:"lineEnding",tokenize:Xxe};function Xxe(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Oe(e,t,"linePrefix")}}const Oi={name:"thematicBreak",tokenize:Qxe};function Qxe(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||me(u))?(e.exit("thematicBreak"),t(u)):n(u)}function l(u){return u===a?(e.consume(u),r++,l):(e.exit("thematicBreakSequence"),Pe(u)?Oe(e,s,"whitespace")(u):s(u))}}const Ut={continuation:{tokenize:n9e},exit:a9e,name:"list",tokenize:t9e},Jxe={partial:!0,tokenize:i9e},e9e={partial:!0,tokenize:r9e};function t9e(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:vd(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(Oi,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 vd(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(Ha,r.interrupt?n:d,e.attempt(Jxe,m,p))}function d(h){return r.containerState.initialBlankLine=!0,i++,m(h)}function p(h){return Pe(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 n9e(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Ha,a,i);function a(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Oe(e,t,"listItemIndent",r.containerState.size+1)(s)}function i(s){return r.containerState.furtherBlankLines||!Pe(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(e9e,t,o)(s))}function o(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,Oe(e,e.attempt(Ut,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s)}}function r9e(e,t,n){const r=this;return Oe(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 a9e(e){e.exit(this.containerState.type)}function i9e(e,t,n){const r=this;return Oe(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!Pe(i)&&o&&o[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const $2={name:"setextUnderline",resolveTo:o9e,tokenize:s9e};function o9e(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 s9e(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"),Pe(u)?Oe(e,l,"lineSuffix")(u):l(u))}function l(u){return u===null||me(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const l9e={tokenize:c9e};function c9e(e){const t=this,n=e.attempt(Ha,r,e.attempt(this.parser.constructs.flowInitial,a,Oe(e,e.attempt(this.parser.constructs.flow,a,e.attempt(mxe,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 u9e={resolveAll:W3()},d9e=G3("string"),p9e=G3("text");function G3(e){return{resolveAll:W3(e==="text"?h9e: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 W3(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 h9e(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 m9e={42:Ut,43:Ut,45:Ut,48:Ut,49:Ut,50:Ut,51:Ut,52:Ut,53:Ut,54:Ut,55:Ut,56:Ut,57:Ut,62:P3},f9e={91:kxe},g9e={[-2]:ps,[-1]:ps,32:ps},y9e={35:Mxe,42:Oi,45:[$2,Oi],60:Txe,61:$2,95:Oi,96:D2,126:D2},b9e={38:q3,92:B3},k9e={[-5]:hs,[-4]:hs,[-3]:hs,33:Wxe,38:q3,42:_d,60:[Ywe,zxe],91:Yxe,92:[xxe,B3],93:hp,95:_d,96:lxe},v9e={null:[_d,u9e]},_9e={null:[42,95]},w9e={null:[]},x9e=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:_9e,contentInitial:f9e,disable:w9e,document:m9e,flow:y9e,flowInitial:g9e,insideSpan:v9e,string:b9e,text:k9e},Symbol.toStringTag,{value:"Module"}));function E9e(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:F(S),check:F(E),consume:k,enter:w,exit:M,interrupt:F(E,{interrupt:!0})},u={code:null,containerState:{},defineSkip:y,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(W){return o=sn(o,W),_(),o[o.length-1]!==null?[]:(P(t,0),u.events=So(i,u.events,u),u.events)}function m(W,K){return S9e(h(W),K)}function h(W){return M9e(o,W)}function g(){const{_bufferIndex:W,_index:K,line:J,column:V,offset:R}=r;return{_bufferIndex:W,_index:K,line:J,column:V,offset:R}}function y(W){a[W.line]=W.column,D()}function _(){let W;for(;r._index<o.length;){const K=o[r._index];if(typeof K=="string")for(W=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===W&&r._bufferIndex<K.length;)v(K.charCodeAt(r._bufferIndex));else v(K)}}function v(W){d=d(W)}function k(W){me(W)?(r.line++,r.column=1,r.offset+=W===-3?2:1,D()):W!==-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=W}function w(W,K){const J=K||{};return J.type=W,J.start=g(),u.events.push(["enter",J,u]),s.push(J),J}function M(W){const K=s.pop();return K.end=g(),u.events.push(["exit",K,u]),K}function S(W,K){P(W,K.from)}function E(W,K){K.restore()}function F(W,K){return J;function J(V,R,q){let G,T,Y,N;return Array.isArray(V)?te(V):"tokenize"in V?te([V]):Z(V);function Z(ve){return Ce;function Ce(Be){const He=Be!==null&&ve[Be],re=Be!==null&&ve.null,Me=[...Array.isArray(He)?He:He?[He]:[],...Array.isArray(re)?re:re?[re]:[]];return te(Me)(Be)}}function te(ve){return G=ve,T=0,ve.length===0?q:I(ve[T])}function I(ve){return Ce;function Ce(Be){return N=C(),Y=ve,ve.partial||(u.currentConstruct=ve),ve.name&&u.parser.constructs.disable.null.includes(ve.name)?ge():ve.tokenize.call(K?Object.assign(Object.create(u),K):u,l,pe,ge)(Be)}}function pe(ve){return W(Y,N),R}function ge(ve){return N.restore(),++T<G.length?I(G[T]):q}}}function P(W,K){W.resolveAll&&!i.includes(W)&&i.push(W),W.resolve&&Qt(u.events,K,u.events.length-K,W.resolve(u.events.slice(K),u)),W.resolveTo&&(u.events=W.resolveTo(u.events,u))}function C(){const W=g(),K=u.previous,J=u.currentConstruct,V=u.events.length,R=Array.from(s);return{from:V,restore:q};function q(){r=W,u.previous=K,u.currentConstruct=J,u.events.length=V,s=R,D()}}function D(){r.line in a&&r.column<2&&(r.column=a[r.line],r.offset+=a[r.line]-1)}}function M9e(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 S9e(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=`
8324
8324
  `;break}case-3:{o=`\r
8325
8325
  `;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 N9e(e){const r={constructs:$3([x9e,...(e||{}).extensions||[]]),content:a(Uwe),defined:[],document:a(jwe),flow:a(l9e),lazy:{},string:a(d9e),text:a(p9e)};return r;function a(i){return o;function o(s){return E9e(r,i,s)}}}function A9e(e){for(;!U3(e););return e}const F2=/[\0\t\n\r]/g;function T9e(){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(F2.lastIndex=p,u=F2.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 C9e=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function R9e(e){return e.replace(C9e,I9e)}function I9e(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),i=a===120||a===88;return F3(n.slice(i?2:1),i?16:10)}return Ra(n)||e}const K3={}.hasOwnProperty;function O9e(e,t,n){return typeof t!="string"&&(n=t,t=void 0),L9e(n)(A9e(N9e(n).document().write(T9e()(e,t,!0))))}function L9e(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(et),autolinkProtocol:C,autolinkEmail:C,atxHeading:i(we),blockQuote:i(re),characterEscape:C,characterReference:C,codeFenced:i(Me),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:i(Me,o),codeText:i(Ge,o),codeTextData:C,data:C,codeFlowValue:C,definition:i(Je),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:i(qe),hardBreakEscape:i(ke),hardBreakTrailing:i(ke),htmlFlow:i(Le,o),htmlFlowData:C,htmlText:i(Le,o),htmlTextData:C,image:i(de),label:o,link:i(et),listItem:i(We),listItemValue:m,listOrdered:i(Te,p),listUnordered:i(Te),paragraph:i(_e),reference:I,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:i(we),strong:i($e),thematicBreak:i(Xe)},exit:{atxHeading:l(),atxHeadingSequence:S,autolink:l(),autolinkEmail:He,autolinkProtocol:Be,blockQuote:l(),characterEscapeValue:D,characterReferenceMarkerHexadecimal:ge,characterReferenceMarkerNumeric:ge,characterReferenceValue:ve,characterReference:Ce,codeFenced:l(_),codeFencedFence:y,codeFencedFenceInfo:h,codeFencedFenceMeta:g,codeFlowValue:D,codeIndented:l(v),codeText:l(R),codeTextData:D,data:D,definition:l(),definitionDestinationString:M,definitionLabelString:k,definitionTitleString:w,emphasis:l(),hardBreakEscape:l(K),hardBreakTrailing:l(K),htmlFlow:l(J),htmlFlowData:D,htmlText:l(V),htmlTextData:D,image:l(G),label:Y,labelText:T,lineEnding:W,link:l(q),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:pe,resourceDestinationString:N,resourceTitleString:Z,resource:te,setextHeading:l(P),setextHeadingLineSequence:F,setextHeadingText:E,strong:l(),thematicBreak:l()}};Y3(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(B){let X={type:"root",children:[]};const le={stack:[X],tokenStack:[],config:t,enter:s,exit:u,buffer:o,resume:d,data:n},he=[];let Se=-1;for(;++Se<B.length;)if(B[Se][1].type==="listOrdered"||B[Se][1].type==="listUnordered")if(B[Se][0]==="enter")he.push(Se);else{const je=he.pop();Se=a(B,je,Se)}for(Se=-1;++Se<B.length;){const je=t[B[Se][0]];K3.call(je,B[Se][1].type)&&je[B[Se][1].type].call(Object.assign({sliceSerialize:B[Se][2].sliceSerialize},le),B[Se][1])}if(le.tokenStack.length>0){const je=le.tokenStack[le.tokenStack.length-1];(je[1]||P2).call(le,void 0,je[0])}for(X.position={start:Zn(B.length>0?B[0][1].start:{line:1,column:1,offset:0}),end:Zn(B.length>0?B[B.length-2][1].end:{line:1,column:1,offset:0})},Se=-1;++Se<t.transforms.length;)X=t.transforms[Se](X)||X;return X}function a(B,X,le){let he=X-1,Se=-1,je=!1,wt,Et,vn,_n;for(;++he<=le;){const ft=B[he];switch(ft[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ft[0]==="enter"?Se++:Se--,_n=void 0;break}case"lineEndingBlank":{ft[0]==="enter"&&(wt&&!_n&&!Se&&!vn&&(vn=he),_n=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:_n=void 0}if(!Se&&ft[0]==="enter"&&ft[1].type==="listItemPrefix"||Se===-1&&ft[0]==="exit"&&(ft[1].type==="listUnordered"||ft[1].type==="listOrdered")){if(wt){let St=he;for(Et=void 0;St--;){const Mt=B[St];if(Mt[1].type==="lineEnding"||Mt[1].type==="lineEndingBlank"){if(Mt[0]==="exit")continue;Et&&(B[Et][1].type="lineEndingBlank",je=!0),Mt[1].type="lineEnding",Et=St}else if(!(Mt[1].type==="linePrefix"||Mt[1].type==="blockQuotePrefix"||Mt[1].type==="blockQuotePrefixWhitespace"||Mt[1].type==="blockQuoteMarker"||Mt[1].type==="listItemIndent"))break}vn&&(!Et||vn<Et)&&(wt._spread=!0),wt.end=Object.assign({},Et?B[Et][1].start:ft[1].end),B.splice(Et||he,0,["exit",wt,ft[2]]),he++,le++}if(ft[1].type==="listItemPrefix"){const St={type:"listItem",_spread:!1,start:Object.assign({},ft[1].start),end:void 0};wt=St,B.splice(he,0,["enter",St,ft[2]]),he++,le++,vn=void 0,_n=!0}}}return B[X][1]._spread=je,le}function i(B,X){return le;function le(he){s.call(this,B(he),he),X&&X.call(this,he)}}function o(){this.stack.push({type:"fragment",children:[]})}function s(B,X,le){this.stack[this.stack.length-1].children.push(B),this.stack.push(B),this.tokenStack.push([X,le||void 0]),B.position={start:Zn(X.start),end:void 0}}function l(B){return X;function X(le){B&&B.call(this,le),u.call(this,le)}}function u(B,X){const le=this.stack.pop(),he=this.tokenStack.pop();if(he)he[0].type!==B.type&&(X?X.call(this,B,he[0]):(he[1]||P2).call(this,B,he[0]));else throw new Error("Cannot close `"+B.type+"` ("+va({start:B.start,end:B.end})+"): it’s not open");le.position.end=Zn(B.end)}function d(){return pp(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function m(B){if(this.data.expectingFirstListItemValue){const X=this.stack[this.stack.length-2];X.start=Number.parseInt(this.sliceSerialize(B),10),this.data.expectingFirstListItemValue=void 0}}function h(){const B=this.resume(),X=this.stack[this.stack.length-1];X.lang=B}function g(){const B=this.resume(),X=this.stack[this.stack.length-1];X.meta=B}function y(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function _(){const B=this.resume(),X=this.stack[this.stack.length-1];X.value=B.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function v(){const B=this.resume(),X=this.stack[this.stack.length-1];X.value=B.replace(/(\r?\n|\r)$/g,"")}function k(B){const X=this.resume(),le=this.stack[this.stack.length-1];le.label=X,le.identifier=bn(this.sliceSerialize(B)).toLowerCase()}function w(){const B=this.resume(),X=this.stack[this.stack.length-1];X.title=B}function M(){const B=this.resume(),X=this.stack[this.stack.length-1];X.url=B}function S(B){const X=this.stack[this.stack.length-1];if(!X.depth){const le=this.sliceSerialize(B).length;X.depth=le}}function E(){this.data.setextHeadingSlurpLineEnding=!0}function F(B){const X=this.stack[this.stack.length-1];X.depth=this.sliceSerialize(B).codePointAt(0)===61?1:2}function P(){this.data.setextHeadingSlurpLineEnding=void 0}function C(B){const le=this.stack[this.stack.length-1].children;let he=le[le.length-1];(!he||he.type!=="text")&&(he=xe(),he.position={start:Zn(B.start),end:void 0},le.push(he)),this.stack.push(he)}function D(B){const X=this.stack.pop();X.value+=this.sliceSerialize(B),X.position.end=Zn(B.end)}function W(B){const X=this.stack[this.stack.length-1];if(this.data.atHardBreak){const le=X.children[X.children.length-1];le.position.end=Zn(B.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(X.type)&&(C.call(this,B),D.call(this,B))}function K(){this.data.atHardBreak=!0}function J(){const B=this.resume(),X=this.stack[this.stack.length-1];X.value=B}function V(){const B=this.resume(),X=this.stack[this.stack.length-1];X.value=B}function R(){const B=this.resume(),X=this.stack[this.stack.length-1];X.value=B}function q(){const B=this.stack[this.stack.length-1];if(this.data.inReference){const X=this.data.referenceType||"shortcut";B.type+="Reference",B.referenceType=X,delete B.url,delete B.title}else delete B.identifier,delete B.label;this.data.referenceType=void 0}function G(){const B=this.stack[this.stack.length-1];if(this.data.inReference){const X=this.data.referenceType||"shortcut";B.type+="Reference",B.referenceType=X,delete B.url,delete B.title}else delete B.identifier,delete B.label;this.data.referenceType=void 0}function T(B){const X=this.sliceSerialize(B),le=this.stack[this.stack.length-2];le.label=R9e(X),le.identifier=bn(X).toLowerCase()}function Y(){const B=this.stack[this.stack.length-1],X=this.resume(),le=this.stack[this.stack.length-1];if(this.data.inReference=!0,le.type==="link"){const he=B.children;le.children=he}else le.alt=X}function N(){const B=this.resume(),X=this.stack[this.stack.length-1];X.url=B}function Z(){const B=this.resume(),X=this.stack[this.stack.length-1];X.title=B}function te(){this.data.inReference=void 0}function I(){this.data.referenceType="collapsed"}function pe(B){const X=this.resume(),le=this.stack[this.stack.length-1];le.label=X,le.identifier=bn(this.sliceSerialize(B)).toLowerCase(),this.data.referenceType="full"}function ge(B){this.data.characterReferenceType=B.type}function ve(B){const X=this.sliceSerialize(B),le=this.data.characterReferenceType;let he;le?(he=F3(X,le==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):he=Ra(X);const Se=this.stack[this.stack.length-1];Se.value+=he}function Ce(B){const X=this.stack.pop();X.position.end=Zn(B.end)}function Be(B){D.call(this,B);const X=this.stack[this.stack.length-1];X.url=this.sliceSerialize(B)}function He(B){D.call(this,B);const X=this.stack[this.stack.length-1];X.url="mailto:"+this.sliceSerialize(B)}function re(){return{type:"blockquote",children:[]}}function Me(){return{type:"code",lang:null,meta:null,value:""}}function Ge(){return{type:"inlineCode",value:""}}function Je(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function qe(){return{type:"emphasis",children:[]}}function we(){return{type:"heading",depth:0,children:[]}}function ke(){return{type:"break"}}function Le(){return{type:"html",value:""}}function de(){return{type:"image",title:null,url:"",alt:null}}function et(){return{type:"link",title:null,url:"",children:[]}}function Te(B){return{type:"list",ordered:B.type==="listOrdered",start:null,spread:B._spread,children:[]}}function We(B){return{type:"listItem",spread:B._spread,checked:null,children:[]}}function _e(){return{type:"paragraph",children:[]}}function $e(){return{type:"strong",children:[]}}function xe(){return{type:"text",value:""}}function Xe(){return{type:"thematicBreak"}}}function Zn(e){return{line:e.line,column:e.column,offset:e.offset}}function Y3(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Y3(e,r):D9e(e,r)}}function D9e(e,t){let n;for(n in t)if(K3.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 P2(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+va({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+va({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+va({start:t.start,end:t.end})+") is still open")}function z9e(e){const t=this;t.parser=n;function n(r){return O9e(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function $9e(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 F9e(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`