@shytv/ai-chart 0.0.1 → 0.0.3

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.
@@ -0,0 +1,117 @@
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("react"),require("react-dom"),require("monaco-editor")):typeof define==`function`&&define.amd?define([`exports`,`react`,`react-dom`,`monaco-editor`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.AIChart={},e.react,e.react_dom,e.monaco_editor))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=Object.create,a=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,c=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty,u=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),d=(e,t)=>{let n={};for(var r in e)a(n,r,{get:e[r],enumerable:!0});return t||a(n,Symbol.toStringTag,{value:`Module`}),n},f=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=s(t),c=0,u=i.length,d;c<u;c++)d=i[c],!l.call(e,d)&&d!==n&&a(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=o(t,d))||r.enumerable});return e},p=(e,t,n)=>(f(e,t,`default`),n&&f(n,t,`default`)),m=(e,t,n)=>(n=e==null?{}:i(c(e)),f(t||!e||!e.__esModule||!l.call(e,`default`)?a(n,`default`,{value:e,enumerable:!0}):n,e));let h=m(t,1);t=m(t),n=m(n,1);var g=((e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i-->0;)r+=e[Math.random()*e.length|0];return r})(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7),_=`__error__`,v=e=>e.startsWith(_);function y(e){"@babel/helpers - typeof";return y=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},y(e)}function b(e,t){if(y(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(y(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function x(e){var t=b(e,`string`);return y(t)==`symbol`?t:t+``}function S(e,t,n){return(t=x(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function C(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function w(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){C(a,r,i,o,s,`next`,e)}function s(e){C(a,r,i,o,s,`throw`,e)}o(void 0)})}}function T(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function E(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?T(Object(n),!0).forEach(function(t){S(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):T(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var D=e=>{let t=globalThis.Buffer;if(t)return t.from(e).toString(`base64`);let n=``,r=32768;for(let t=0;t<e.length;t+=r)n+=String.fromCharCode(...e.subarray(t,t+r));return btoa(n)},O=e=>{if((e==null?void 0:e.reason)!==void 0)return e.reason;let t=Error(`The attachment read was aborted`);return t.name=`AbortError`,t},k=e=>{if(e!=null&&e.aborted)throw O(e)},A=(e,t)=>new Promise((n,r)=>{let i=new FileReader,a=()=>{i.abort(),r(O(t))};i.onload=()=>{t==null||t.removeEventListener(`abort`,a),n(i.result)},i.onerror=e=>{t==null||t.removeEventListener(`abort`,a),r(e)},t==null||t.addEventListener(`abort`,a,{once:!0});try{e(i)}catch(e){t==null||t.removeEventListener(`abort`,a),r(e)}});(function(){var e=w(function*(e,t){let n=t==null?void 0:t.signal;if(k(n),typeof FileReader>`u`){let t=yield e.arrayBuffer();return k(n),`data:${e.type||`application/octet-stream`};base64,${D(new Uint8Array(t))}`}return A(t=>t.readAsDataURL(e),n)});return function(t,n){return e.apply(this,arguments)}})(),function(){var e=w(function*(e,t){let n=t==null?void 0:t.signal;if(k(n),typeof FileReader>`u`){let t=yield e.text();return k(n),t}return A(t=>t.readAsText(e),n)});return function(t,n){return e.apply(this,arguments)}}();function j(e,t){if(t===`*`)return!0;let n=t.split(`,`).map(e=>e.trim().toLowerCase()),r=e.name.toLowerCase(),i=e.type.split(`;`,1)[0].trim().toLowerCase();for(let e of n){if(e.startsWith(`.`)&&r.endsWith(e)||e.includes(`/`)&&e===i)return!0;if(e.endsWith(`/*`)){let t=e.split(`/`)[0];if(i.startsWith(`${t}/`))return!0}}return!1}function M(e){var t,n;let r=g();return e.type===`image`?{id:r,type:`image`,name:(t=e.filename)==null?`image`:t,content:[e],status:{type:`complete`}}:e.type===`file`?{id:r,type:`document`,name:(n=e.filename)==null?`document`:n,contentType:e.mimeType,content:[e],status:{type:`complete`}}:e.type===`audio`?{id:r,type:`audio`,name:`audio.${e.audio.format}`,contentType:`audio/${e.audio.format}`,content:[e],status:{type:`complete`}}:{id:r,type:`data`,name:e.name,content:[e],status:{type:`complete`}}}function N(e){let t=[];for(let n of e)n.type!==`text`&&t.push(M(n));return t}var P=String.raw`"(?:[^"\\\u0000-\u001f]|\\(?:["\\/bfnrt]|u[\da-fA-F]{4})){1,1024}"`,F=new RegExp(String.raw`:([\w-]{1,64})(?:\[([^\]\n]{1,1024})\](?:\{name=([^}\n]{1,1024})\})?|\{label=(${P})(?: name=(${P}))?\})`,`gu`),I={serialize(e){if(e.label.includes(`]`)||e.id!==e.label&&e.id.includes(`}`)){let t=e.id===e.label?``:` name=${JSON.stringify(e.id)}`;return`:${e.type}{label=${JSON.stringify(e.label)}${t}}`}let t=e.id===e.label?``:`{name=${e.id}}`;return`:${e.type}[${e.label}]${t}`},parse(e){let t=[],n=0;for(let i of e.matchAll(F)){var r;i.index>n&&t.push({kind:`text`,text:e.slice(n,i.index)});let a=i[4]===void 0?i[2]:JSON.parse(i[4]),o=i[5]===void 0?(r=i[3])==null?a:r:JSON.parse(i[5]);t.push({kind:`mention`,type:i[1],label:a,id:o}),n=i.index+i[0].length}return n<e.length&&t.push({kind:`text`,text:e.slice(n)}),t}},L=(e,t,n)=>{let r=e=>{console.error(`[assistant-ui] ${n} listener threw an error`,e)};for(let n of e)try{let e=n(typeof t==`function`?t():t);e!==null&&(typeof e==`object`||typeof e==`function`)&&`then`in e&&typeof e.then==`function`&&Promise.resolve(e).catch(r)}catch(e){r(e)}},R=e=>e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
2
+
3
+ `);function z(e){var t,n,r,i=2;for(typeof Symbol<`u`&&(n=Symbol.asyncIterator,r=Symbol.iterator);i--;){if(n&&(t=e[n])!=null)return t.call(e);if(r&&(t=e[r])!=null)return new B(t.call(e));n=`@@asyncIterator`,r=`@@iterator`}throw TypeError(`Object is not async iterable`)}function B(e){function t(e){if(Object(e)!==e)return Promise.reject(TypeError(e+` is not an object.`));var t=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:t}})}return B=function(e){this.s=e,this.n=e.next},B.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var n=this.s.return;return n===void 0?Promise.resolve({value:e,done:!0}):t(n.apply(this.s,arguments))},throw:function(e){var n=this.s.throw;return n===void 0?Promise.reject(e):t(n.apply(this.s,arguments))}},new B(e)}var ee=`ui://`,V=e=>!!(e!=null&&e.startsWith(ee)),te=e=>e.display===`text`||e.display!==`questions`&&e.allowFreeform===!0,H=(e,...t)=>Object.assign(Object.create(null),e,...t);function U(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function W(e,t){if(e==null)return{};var n,r,i=U(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var ne=[`overwrite`],re=`
4
+
5
+ `,ie=e=>e>=55296&&e<=56319,ae=(e,t)=>{let n=``;for(let{system:r}of e){let e=n?re:``,i=t-n.length-e.length,a=i<r.length&&ie(r.charCodeAt(i-1))?i-1:i;if(a<=0||(n+=e+r.slice(0,a),r.length>a))break}return n},oe=(e,t)=>{if(t.mergeSystem){if(t.maxSystemLength!==void 0)throw Error(`Pass either maxSystemLength or mergeSystem, not both. Apply the cap inside mergeSystem instead.`);return t.mergeSystem(e)}return t.maxSystemLength===void 0?e.map(e=>e.system).join(re):ae(e,t.maxSystemLength)},se=e=>{if(!e.overwrite)return e;let{overwrite:t}=e;return W(e,ne)},ce=(e,t={})=>{let n=Array.from(e).map(e=>e.getModelContext()).sort((e,t)=>{var n,r;return((n=t.priority)==null?0:n)-((r=e.priority)==null?0:r)}),r=H(),i=[],a=n.reduce((e,t)=>{var n;let a=(n=t.priority)==null?0:n;if(t.system&&i.push({system:t.system,priority:a}),t.tools)for(let[n,i]of Object.entries(t.tools)){let t=e.tools!==void 0&&Object.hasOwn(e.tools,n)?e.tools[n]:void 0;if(t&&t!==i){let o=r[n];if(o===a){if(!i.overwrite)throw Error(`You tried to define a tool with the name ${n}, but it already exists.`);e.tools[n]=se(i);continue}let s=o>a?t:i,c=o>a?i:t;e.tools[n]=se(E(E({},c),s)),r[n]=Math.max(o,a)}else e.tools||(e.tools=H()),e.tools[n]=se(i),Object.hasOwn(r,n)||(r[n]=a)}return t.config&&(e.config=E(E({},t.config),e.config)),t.callSettings&&(e.callSettings=E(E({},t.callSettings),e.callSettings)),t.unstable_composerMetadata&&(e.unstable_composerMetadata=E(E({},t.unstable_composerMetadata),e.unstable_composerMetadata)),e},{}),o=oe(i,t);return o&&(a.system=o),a};function le(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ue(e,t=0){return t>100?!1:e===null||typeof e==`string`||typeof e==`boolean`?!0:typeof e==`number`?!Number.isNaN(e)&&Number.isFinite(e):Array.isArray(e)?e.every(e=>ue(e,t+1)):le(e)?Object.entries(e).every(([e,n])=>typeof e==`string`&&ue(n,t+1)):!1}var de=100,fe=(e,t,n)=>{if(e===t)return!0;if(n>de||e==null||t==null)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.every((e,r)=>fe(e,t[r],n+1));if(Array.isArray(t)||!le(e)||!le(t))return!1;let r=Object.keys(e),i=Object.keys(t);return r.length===i.length&&r.every(r=>Object.hasOwn(t,r)&&fe(e[r],t[r],n+1))},pe=(e,t)=>!ue(e)||!ue(t)?!1:fe(e,t,0),me=[`id`],he=[`interactables`];function ge(e){let t=e.metadata;if(!t||typeof t!=`object`)return;let n=t.custom;if(!n||typeof n!=`object`)return;let r=n.interactables;return Array.isArray(r)?r:void 0}function _e(e){return`update_${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}`}var ve=e=>{if(!le(e))return;let t=e.id;return typeof t==`string`||typeof t==`number`?t:void 0};function ye(e,t,n=[]){if(!le(e)||!le(t))return t;let r=E(E({},e),t),[i,...a]=n;return i!==void 0&&Object.hasOwn(t,i)&&(r[i]=ye(e[i],t[i],a)),r}function be(e,t,n,r){let i=Array.isArray(t.set)?[...t.set]:[...e];if(t.clear===!0&&(i=[]),Array.isArray(t.remove)&&t.remove.length>0){let e=new Set(t.remove);i=i.filter(t=>{let n=ve(t);return n===void 0?!e.has(t):!e.has(n)})}let a=t.update;if(Array.isArray(a)&&a.length>0){let e=new Map;for(let t of a){let n=ve(t);n!==void 0&&!Number.isNaN(n)&&!e.has(n)&&e.set(n,t)}let t=(r==null?void 0:r[0])===`update`?{patch:a[Number(r[1])],rest:r.slice(2)}:void 0;i=i.map(n=>{let r=ve(n);if(r===void 0||!le(n))return n;let i=e.get(r);return i?t&&i===t.patch?ye(n,i,t.rest):E(E({},n),i):n})}if(Array.isArray(t.add)&&t.add.length>0){let e=n?t.add.map(e=>{if(!le(e)||e.id!==void 0)return e;let t=n();return t===void 0?e:E(E({},e),{},{id:t})}):t.add;i=[...i,...e]}return i}function xe(e,t,n){if(!le(e)||!le(t))return t;let r=le(n==null?void 0:n.arrayBaseline)?n.arrayBaseline:e,i=n==null?void 0:n.partialPath,a=Object.entries(e);for(let[o,s]of Object.entries(t)){let t=r[o],c=(i==null?void 0:i[0])===o?i.slice(1):void 0;if(Array.isArray(t)&&le(s)){let e=n!=null&&n.idFactory&&(n.idKeyedFields===void 0||n.idKeyedFields.has(o))?()=>{var e;return(e=n.idFactory)==null?void 0:e.call(n,o)}:void 0;a.push([o,be(t,s,e,c)])}else c?a.push([o,ye(e[o],s,c)]):a.push([o,s])}return Object.fromEntries(a)}function Se(e,t){if(!le(e)||!le(t))return;for(let n of Object.keys(e))if(!Object.hasOwn(t,n))return;let n=[];for(let[r,i]of Object.entries(t))Object.hasOwn(e,r)&&pe(e[r],i)||n.push([r,i]);let r=n.length;if(r!==0&&r!==Object.keys(t).length)return Object.fromEntries(n)}var Ce=e=>{if(!e||typeof e!=`object`)return;let t=e;return t.type===`tool-call`?t:void 0},we=e=>{if(typeof e==`string`&&e.startsWith(`{`))try{e=JSON.parse(e)}catch(e){return}return le(e)?e:void 0},Te=(e,t,n)=>{var r;return e.toolCallId===t&&(e.toolName===n||((r=we(e.result))==null?void 0:r.interactable)===n)},Ee=(e,t)=>{if(!e.args||typeof e.args!=`object`)return!1;let n=we(e.result);if((n==null?void 0:n.success)===!1)return!1;if(typeof(n==null?void 0:n.id)==`string`)return n.id===t;let r=e.args.id;return r===t||r===void 0},De=e=>{var t;let n=(t=we(e))==null?void 0:t.addedItemIds;if(!le(n))return;let r=new Map;for(let[e,t]of Object.entries(n)){if(!Array.isArray(t))continue;let n=t.filter(e=>typeof e==`string`);n.length>0&&r.set(e,n)}if(r.size!==0)return e=>{var t;return(t=r.get(e))==null?void 0:t.shift()}},Oe=new WeakMap;function ke(e,t,n){let r=Oe.get(e);r||(r=new Map,Oe.set(e,r));let i=r.get(n);i||(i=new Map,r.set(n,i));let a=i.get(t);if(a)return a;let o=_e(n),s=[],c=()=>s[s.length-1];for(let r of e){var l;if(r.role===`user`){var u;let e=(u=ge(r))==null?void 0:u.find(e=>e.id===t);if(!e)continue;if(e.partial){let t=c();t&&s.push({state:xe(t.state,e.state),origin:`user-edit`})}else s.push({state:e.state,origin:`user-edit`})}else if(r.role===`assistant`)for(let e of(l=r.content)==null?[]:l){let r=Ce(e);if(r){if(Te(r,t,n))r.args&&typeof r.args==`object`&&s.push({state:r.args,origin:`create`,toolCallId:t});else if(r.toolName===o&&Ee(r,t)){let e=c();if(e){let t=r.args,{id:n}=t,i=W(t,me),a=De(r.result);s.push({state:a?xe(e.state,i,{idFactory:a}):xe(e.state,i),origin:`update`,toolCallId:r.toolCallId})}}}}}return i.set(t,s),s}function Ae(e,t,n){let r=ke(e,t,n),i=r[r.length-1];return i?{state:i.state}:void 0}function je(e,t){if(!e)return;let{interactables:n}=e,r=E({},W(e,he));if(Array.isArray(n)){let e=[];for(let r of n){process.env.NODE_ENV!==`production`&&!ue(r.state)&&console.warn(`[Interactables] state for "${r.name}" (${r.id}) is not JSON-equatable (an undefined, NaN, Infinity, function, or symbol value?). It will be re-snapshotted on every send, recreating per-message growth. Use plain JSON values.`);let n=Ae(t,r.id,r.name);if(!n){e.push({id:r.id,name:r.name,state:r.state});continue}if(pe(r.state,n.state))continue;let i=Se(n.state,r.state);e.push(i?{id:r.id,name:r.name,state:i,partial:!0}:{id:r.id,name:r.name,state:r.state})}e.length&&(r.interactables=e)}return Object.keys(r).length?r:void 0}var Me=e=>e,Ne=new Set([`$$typeof`,`nodeType`,`then`,`__v_raw`,`__v_isRef`,`__v_isReactive`,`__v_isReadonly`,`__v_isShallow`,`__v_skip`]),Pe=(e,t)=>{if(e===Symbol.toStringTag)return t;if(typeof e!=`symbol`){if(e===`toJSON`)return()=>t;if(!Ne.has(e))return!1}},Fe=class{getOwnPropertyDescriptor(e,t){let n=this.get(e,t);if(n!==void 0)return{value:n,writable:!1,enumerable:!0,configurable:!0}}set(){return!1}setPrototypeOf(){return!1}defineProperty(){return!1}deleteProperty(){return!1}preventExtensions(){return!1}},Ie=Symbol(`assistant-ui.store.clientId`),Le=Symbol(`assistant-ui.store.instanceTag`),Re=new WeakSet,ze=new Set([`call`,`apply`,`bind`]),Be=(e,t)=>{let n=new Proxy((()=>{}),{apply:()=>(t(),n),get:(n,r)=>ze.has(r)?Reflect.get(n,r):r===`source`?e.source:r===`query`?e.query:r===`name`?e.name:r===Ie?Ge(t()):t()[r],has:(e,n)=>n===`source`||n===`query`||n===`name`||n===Ie||n in t(),ownKeys:()=>Reflect.ownKeys(t()),getOwnPropertyDescriptor:(e,n)=>{if(typeof n!=`symbol`&&n in t())return{value:t()[n],writable:!1,enumerable:!0,configurable:!0}}});return Re.add(n),n},Ve=(e,t)=>{let n=()=>{throw Error(e)},r=new Proxy((()=>{}),{apply:n,get:(e,r)=>{if(ze.has(r))return Reflect.get(e,r);if(r===`source`||r===`query`)return null;if(r===`name`)return t;if(r===Ie)return n();let i=Pe(r,`AssistantClientAccessor`);return i===!1?n():i},has:(e,t)=>t===`source`||t===`query`||t===`name`,ownKeys:()=>[],getOwnPropertyDescriptor:()=>void 0});return Re.add(r),r},He=e=>{if(Re.has(e))return!1;let t=e[Ie];return t!==void 0&&t!==e},Ue=e=>(e==null?void 0:e.source)!=null,We=e=>(e==null?void 0:e.source)===null,Ge=e=>{var t;return(t=e[Ie])==null?e:t},Ke=e=>{var t;return(t=e[Le])==null?Ge(e):t},qe=e=>e===`optional`||e===`subscribe`||e===`on`||e===`__proto__`||typeof e==`symbol`,Je=e=>{let t=[];for(let n in e)qe(n)||t.push(n);return t};function Ye(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function Xe(e,t,n){Ye(e,t),t.set(e,n)}function Ze(e,t,n){if(typeof e==`function`?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError(`Private element is not present on this object`)}function Qe(e,t,n){return e.set(Ze(e,t),n),n}function $e(e,t){return e.get(Ze(e,t))}var et=new WeakMap,tt=class extends Fe{constructor(e){super(),Xe(this,et,void 0),Qe(et,this,e)}get(e,t){let n=Pe(t,`OptionalAssistantClient`);if(n!==!1)return n;if(qe(t))return;let r=$e(et,this)[t];return Ue(r)?r:void 0}ownKeys(){return Je($e(et,this))}has(e,t){return!qe(t)&&t in $e(et,this)}},nt=e=>new Proxy({},new tt(e)),rt=null;function it(e,t){e.currentIndex=0,e.wipContextDeps=null,e.wipCommitCallbacks=[];let n=rt;rt=e;try{if(t(),e.isFirstRender=!1,e.cells.length!==e.currentIndex)throw Error(`Rendered ${e.currentIndex} hooks but expected ${e.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{rt=n}}function at(){if(!rt)throw Error(`No resource fiber available`);return rt}function ot(){return rt}var st=typeof process<`u`&&(process.env.NODE_ENV===`development`||process.env.NODE_ENV===`test`),ct=(e,t)=>({onError:t,version:0,committedVersion:0,dispatchUpdate:e,changelog:[],committedLog:[],unsettledCount:0,rollbackCallbacks:[]}),lt=e=>{e.committedVersion=e.version;for(let t of e.changelog)t.logged=!1,t.settled||(t.settled=!0,e.unsettledCount--),e.committedLog.push(t);e.changelog.length=0,e.unsettledCount===0&&(e.committedLog.length=0),e.rollbackCallbacks.length=0},ut=(e,t)=>{let n=e.version>t;if(e.version=t,n){for(let t=0;t<e.rollbackCallbacks.length;t++)e.rollbackCallbacks[t]();if(e.rollbackCallbacks.length=0,t<=e.committedVersion){let n=[];for(;e.committedVersion-n.length>t;){let t=e.committedLog.pop();if(t===void 0){if(st)throw Error(`tap: committed history is shorter than the replay base.`);break}mt(t.fiber,t.cell),t.cell.workInProgress=t.prevState,n.push({record:t,prevState:t.prevState,eagerState:t.eagerState,hasEagerState:t.hasEagerState})}if(n.length>0){let t=e.committedVersion;pt(e,()=>{for(let t=n.length-1;t>=0;t--){let r=n[t];r.record.prevState=r.prevState,r.record.eagerState=r.eagerState,r.record.hasEagerState=r.hasEagerState,e.committedLog.push(r.record)}e.committedVersion=t})}e.committedVersion=t;for(let t of e.changelog)t.logged=!1;e.changelog.length=0}else{for(;e.committedVersion+e.changelog.length>t;)e.changelog.pop().logged=!1;for(let t=0;t<e.changelog.length;t++)dt(e.changelog[t]);lt(e)}}},dt=e=>{if(mt(e.fiber,e.cell),!e.queued){var t,n;e.queued=!0,((n=(t=e.cell).queue)==null?t.queue=[]:n).push(e)}},ft=(e,t)=>{e.wipCommitCallbacks.push(t)},pt=(e,t)=>{e.rollbackCallbacks.push(t)},mt=(e,t)=>{var n;t.isDirty||(t.isDirty=!0,(n=e.markDirty)==null||n.call(e),pt(e.root,()=>{if(t.queue!==null){for(let e of t.queue)e.queued=!1;t.queue=null}t.workInProgress=t.current,t.isDirty=!1}))},ht=()=>{throw Error(`Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.`)},gt=()=>{throw Error(`Hook order changed between renders`)},_t=e=>({type:e,setup:void 0,setupDeps:void 0,cleanup:void 0,deps:null,generation:0});function vt(e,t,n){let r=at(),i=r.currentIndex++,a=r.cells[i],o=a===void 0?_t(n):a.type===n?a:gt();if(a===void 0){var s;r.isFirstRender||ht(),r.cells[i]=o,n===`insertion`?((s=r.insertionCells)==null?r.insertionCells=[]:s).push(o):r.effectCells.push(o)}if(o.deps!==null&&!!t!=!!o.deps)throw Error(`useEffect called with and without dependencies across re-renders`);let c=r.isRefreshing;ft(r,()=>{o.setup=e,o.setupDeps=t,c&&(o.deps=null),o.generation++})}function yt(e,t){vt(e,t,`effect`)}function bt(e){let t=at(),n=t.currentIndex++,r=t.cells[n];if(r===void 0){t.isFirstRender||ht();let r={current:e};return t.cells[n]={type:`ref`,ref:r},r}return r.type===`ref`?r.ref:gt()}var xt=Symbol(`tap.Context.defaultValue`),St=e=>e,Ct=new Map,wt=new Set,Tt=()=>new Map(Ct),Et=(e,t)=>{let n=Ct;Ct=e;try{return t()}finally{Ct=n}},Dt=(e,t)=>{e[xt]=t},Ot=e=>typeof e==`object`&&!!e&&xt in e,kt=e=>typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Symbol.for(`react.context`),At=e=>Ot(e)||kt(e),jt=e=>{if(!Ot(e)){if(kt(e)){var t;Dt(e,(t=e._currentValue)==null?e._currentValue2:t)}else throw Error("A tap resource's `use()` only accepts a tap context.")}},Mt=(e,t,n)=>{if(typeof e!=`object`||!e)throw Error(`useContextProvider only accepts a React context.`);jt(e);let r=e,i=at(),a=bt(void 0),o=a.current===void 0||!Object.is(a.current.value,t);yt(()=>{a.current={value:t}},[t]);let s=Ct.get(r),c=s!==void 0||Ct.has(r);Ct.set(r,{value:t,source:i});try{return Nt(r,o,n)}finally{c?Ct.set(r,s):Ct.delete(r)}},Nt=(e,t,n)=>{let r=wt.has(e);t?wt.add(e):wt.delete(e);try{return n()}finally{r?wt.add(e):wt.delete(e)}},Pt=e=>{var t;jt(e);let n=e,r=Ft(n,e),i=at();return((t=i.wipContextDeps)==null?i.wipContextDeps=new Map:t).set(n,r.source),r.value},Ft=(e,t)=>{var n;return(n=Ct.get(e))==null?{value:St(t)[xt],source:null}:n},It=(e,t,n,r)=>{if(!r)return n;let i=n;for(let[n,o]of r){var a;o!==t&&o!==e&&((a=i)==null?i=new Map:a).set(n,o)}return i},Lt=(e,t=e.wipContextDeps)=>{let n=ot();n&&t&&(n.wipContextDeps=It(n,e,n.wipContextDeps,t))},Rt=()=>wt.size>0,zt=e=>{if(!e.contextDeps||!Rt())return!1;for(let t of wt.keys())if(e.contextDeps.has(t))return!0;return!1},Bt=(e,t,n)=>{if(e.isNeverMounted)throw Error(`Resource updated before mount`);let r=!1,i=!0;e.root.unsettledCount++,e.root.dispatchUpdate(()=>(r||(r=!0,n&&e.root.changelog.length===0&&!t.cell.isDirty&&!t.hasEagerState&&(t.prevState=t.cell.workInProgress,t.eagerState=n(t.cell.workInProgress,t.action),t.hasEagerState=!0,i=!Object.is(t.cell.current,t.eagerState),!i&&!t.settled&&(t.settled=!0,e.root.unsettledCount--))),i),()=>(r=!0,i=!0,dt(t),t.logged||(t.logged=!0,e.root.changelog.push(t)),!0))},Vt=(e,t,n,r,i)=>{let a=r?r(n):n;st&&e.devStrictMode&&r&&r(n);let o={type:`reducer`,workInProgress:a,current:a,isDirty:!1,queue:null,renderQueue:null,reducer:t,dispatch:n=>{let r=ot();if(r!==null){var a,s;if(r!==e)throw Error(`Cannot update a resource while rendering a different resource.`);((a=e.renderPendingCells)==null?e.renderPendingCells=new Set:a).add(o),((s=o.renderQueue)==null?o.renderQueue=[]:s).push(n)}else Bt(e,{fiber:e,cell:o,action:n,hasEagerState:!1,eagerState:void 0,prevState:o.current,settled:!1,queued:!1,logged:!1},i?t:void 0)}};return o};function Ht(e,t,n,r){let i=at(),a=i.currentIndex++,o=i.cells[a],s=(()=>{if(o!==void 0)return o.type===`reducer`?o:gt();i.isFirstRender||ht();let s=Vt(i,e,t,n,r);return i.cells[a]=s,s})(),c=s.queue;if(c!==null){let t=e===s.reducer;for(let n=0;n<c.length;n++){let r=c[n];!r.hasEagerState||!t||!Object.is(r.prevState,s.workInProgress)?(r.prevState=s.workInProgress,r.eagerState=e(s.workInProgress,r.action),r.hasEagerState=!0,st&&i.devStrictMode&&(r.eagerState=e(s.workInProgress,r.action))):st&&i.devStrictMode&&e(s.workInProgress,r.action),r.queued=!1,s.workInProgress=r.eagerState}s.queue=null}if(s.reducer=e,s.renderQueue!==null){var l;let t=s.workInProgress;for(let n of s.renderQueue)t=e(t,n);s.renderQueue=null,(l=i.renderPendingCells)==null||l.delete(s),Object.is(t,s.workInProgress)||(mt(i,s),s.workInProgress=t)}return s.isDirty&&ft(i,()=>{s.current=s.workInProgress,s.isDirty=!1}),[s.workInProgress,s.dispatch]}function Ut(e,t,n){return Ht(e,t,n,!1)}var Wt=(e,t)=>typeof t==`function`?t(e):t,Gt=e=>e===void 0?void 0:typeof e==`function`?e():e;function Kt(e){return Ht(Wt,e,Gt,!0)}var qt=(e,t)=>{st&&e.length!==t.length&&console.error(`The final argument passed to a hook changed size between renders. The order and size of this array must remain constant.
6
+
7
+ Previous: [${e.join(`, `)}]\nIncoming: [${t.join(`, `)}]`);for(let n=0;n<e.length&&n<t.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0},Jt=(e,t)=>{ft(e,()=>{t.current=t.wip,t.currentDeps=t.wipDeps,t.wipIsRefreshing=!1,t.isDirty=!1})},Yt=(e,t)=>{let n=at(),r=n.currentIndex++,i=n.cells[r];if(i===void 0){n.isFirstRender||ht();let a=e();return st&&n.devStrictMode&&e(),i={type:`memo`,current:a,currentDeps:t,wip:a,wipDeps:t,wipIsRefreshing:!1,isDirty:!1},n.cells[r]=i,a}i.type!==`memo`&&gt();let a=i;if(a.wipIsRefreshing&&!n.isRefreshing&&(a.wip=a.current,a.wipDeps=a.currentDeps,a.wipIsRefreshing=!1,a.isDirty=!1),!n.isRefreshing&&qt(a.wipDeps,t))return a.isDirty&&Jt(n,a),a.wip;let o=e();return st&&n.devStrictMode&&e(),a.wip=o,a.wipDeps=t,a.wipIsRefreshing=n.isRefreshing,a.isDirty||(a.isDirty=!0,pt(n.root,()=>{a.wip=a.current,a.wipDeps=a.currentDeps,a.wipIsRefreshing=!1,a.isDirty=!1})),Jt(n,a),o},Xt=(e,t)=>Yt(()=>e,t);function Zt(e,t){vt(e,t,`insertion`)}function Qt(e){let t=at(),n=bt(e);return n.current!==e&&ft(t,()=>{n.current=e}),bt(((...e)=>{if(st&&ot())throw Error(`useEffectEvent cannot be called during render`);return n.current(...e)})).current}var $t=e=>typeof e==`object`&&!!e&&typeof e.then==`function`,en=()=>{},tn=e=>{let t=e;switch(typeof t.status==`string`?t.status!==`fulfilled`&&t.status!==`rejected`&&e.then(en,en):(t.status=`pending`,e.then(e=>{t.status===`pending`&&(t.status=`fulfilled`,t.value=e)},e=>{t.status===`pending`&&(t.status=`rejected`,t.reason=e)})),t.status){case`fulfilled`:return t.value;case`rejected`:throw t.reason;default:throw e}},nn=e=>$t(e)?tn(e):Pt(e),rn=!1,an=(e,t,n=t)=>{let r=at().isNeverMounted,i=r?n():t();!st||rn||r&&n!==t||Object.is(i,t())||(rn=!0,console.error(`The result of getSnapshot should be cached to avoid an infinite loop`));let[,a]=Ut(e=>e+1,0),o=bt(0),s=Qt(()=>{try{if(Object.is(i,t()))return o.current=0,!1}catch(e){}return!0});return yt(()=>e(()=>{s()&&a()}),[e]),yt(()=>{if(s()){if(++o.current>50)throw o.current=0,Error(`Maximum update depth exceeded. The result of getSnapshot should be cached to avoid an infinite loop.`);a()}},[e,i,t]),i},on=(e,t)=>{},sn=0,cn=()=>{let e=bt(null);return e.current!=null||(e.current=`:tap${sn++}:`),e.current},ln=(e,t,n)=>{let r=()=>{if(!e)return;let n=t();if(typeof e==`function`){let t=e(n);return typeof t==`function`?t:()=>e(null)}return e.current=n,()=>{e.current=null}};n==null?yt(r):yt(r,[...n,e])},un,dn=h.default;function fn(e){let t=(0,h.useRef)(e);return(0,h.useInsertionEffect)(()=>{t.current=e}),(0,h.useCallback)(((...e)=>t.current(...e)),[])}var pn=(un=dn.useEffectEvent)==null?fn:un,mn=d({Children:()=>In,Fragment:()=>jn,Suspense:()=>Ln,cloneElement:()=>Nn,createContext:()=>zn,createElement:()=>Mn,default:()=>h.default,forwardRef:()=>kn,isValidElement:()=>Pn,lazy:()=>Fn,memo:()=>An,use:()=>Bn,useCallback:()=>xn,useContext:()=>Vn,useDebugValue:()=>Tn,useDeferredValue:()=>Rn,useEffect:()=>G,useEffectEvent:()=>Cn,useId:()=>Dn,useImperativeHandle:()=>On,useInsertionEffect:()=>En,useLayoutEffect:()=>Sn,useMemo:()=>bn,useReducer:()=>vn,useRef:()=>yn,useState:()=>_n,useSyncExternalStore:()=>wn});p(mn,require("react"));var hn=()=>ot()!==null,gn=h.default,_n=e=>hn()?Kt(e):gn.useState(e),vn=(e,t,n)=>hn()?Ut(e,t,n):gn.useReducer(e,t,n),yn=e=>hn()?bt(e):gn.useRef(e),bn=(e,t)=>hn()?Yt(e,t):gn.useMemo(e,t),xn=(e,t)=>hn()?Xt(e,t):gn.useCallback(e,t),G=(e,t)=>hn()?yt(e,t):gn.useEffect(e,t),Sn=(e,t)=>hn()?yt(e,t):gn.useLayoutEffect(e,t),Cn=e=>hn()?Qt(e):pn(e),wn=(e,t,n)=>hn()?an(e,t,n):gn.useSyncExternalStore(e,t,n),Tn=(e,t)=>hn()?void 0:gn.useDebugValue(e,t),En=(e,t)=>hn()?Zt(e,t):gn.useInsertionEffect(e,t),Dn=()=>hn()?cn():gn.useId(),On=(e,t,n)=>hn()?ln(e,t,n):gn.useImperativeHandle(e,t,n),kn=e=>gn.forwardRef(e),An=(e,t)=>gn.memo(e,t),jn=gn.Fragment,Mn=(...e)=>gn.createElement(...e),Nn=(...e)=>gn.cloneElement(...e),Pn=e=>gn.isValidElement(e),Fn=e=>gn.lazy(e),In=gn.Children,Ln=gn.Suspense,Rn=(e,t)=>gn.useDeferredValue(e,t),zn=e=>{let t=gn.createContext(e);return Dt(t,e),t},Bn=e=>{if(hn()&&At(e))return nn(e);if(gn.use)return gn.use(e);if(At(e))return gn.useContext(e);throw Error(`React.use() requires React 19 outside a tap resource.`)},Vn=e=>hn()&&At(e)?nn(e):gn.useContext(e),Hn=Symbol.for(`react.memo_cache_sentinel`),Un=e=>Array(e).fill(Hn),Wn=(e,t)=>{var n;let r=e.memoCache,i=r.workInProgress;if(i===null){let t=r.current;i=t===null?[]:t.map(e=>e.slice()),r.workInProgress=i,pt(e.root,()=>{r.workInProgress=null,r.refreshedIndices=null})}let a=r.index++,o=i[a];if((n=r.refreshedIndices)!=null&&n.has(a)&&!e.isRefreshing){var s,c;r.refreshedIndices.delete(a),o=(s=(c=r.current)==null||(c=c[a])==null?void 0:c.slice())==null?Un(t):s,i[a]=o}if(o===void 0||e.isRefreshing){var l;o=Un(t),i[a]=o,e.isRefreshing&&((l=r.refreshedIndices)==null?r.refreshedIndices=new Set:l).add(a)}else st&&o.length!==t&&console.error(`Expected a constant size argument for each invocation of c(). The previous cache was allocated with size ${o.length} but size ${t} was requested.`);return o},Gn=e=>Wn(at(),e),Kn=(e,t)=>{if(e.length!==0){if(e.length===1)throw e[0];for(let t of e)console.error(t);throw AggregateError(e,t)}},qn=50,Jn={schedulers:new Set,tasks:[],notifies:[],isScheduled:!1},Yn=null,Xn,Zn=class{constructor(e,t){S(this,`_isDirty`,!1),S(this,`_task`,void 0),S(this,`onError`,void 0),this._task=e,this.onError=t}get isDirty(){return this._isDirty}markDirty(){var e;if(Yn&&((e=Yn.get(this))==null?0:e)>=qn)throw Error(`Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside useEffect.`);this._isDirty=!0,Jn.schedulers.add(this),tr()}runTask(){var e;Yn==null||Yn.set(this,((e=Yn.get(this))==null?0:e)+1),this._isDirty=!1,this._task()}settle(){this._isDirty=!1}},Qn=new Zn(()=>{let e=Jn.tasks.splice(0),t=[];for(let{run:n,onError:r}of e)try{n()}catch(e){if(Xn&&r)try{r(e)}catch(e){t.push(e)}else t.push(e)}Kn(t,`Errors occurred while running scheduled tasks`)}),$n=(e,t)=>{Qn.markDirty(),Jn.tasks.push({run:e,onError:t})},er=(e,t)=>{Yn===null?e():Jn.notifies.push({run:e,onError:t})},tr=()=>{Jn.isScheduled||(Jn.isScheduled=!0,rr())},nr=(e=!1)=>{let t=Yn,n=Xn,r=[];Yn=new Map,Xn=e?r:void 0;try{for(let t of Jn.schedulers)if(Jn.schedulers.delete(t),t.isDirty)try{t.runTask()}catch(n){if(e&&t.onError)try{t.onError(n)}catch(e){r.push(e)}else r.push(n)}}finally{if(Yn=t,Xn=n,Jn.schedulers.clear(),Jn.isScheduled=!1,Yn===null){let t=Jn.notifies;for(;t.length>0;){let{run:n,onError:i}=t.shift();try{n()}catch(t){if(e&&i)try{i(t)}catch(e){r.push(e)}else r.push(t)}}}}Kn(r,`Errors occurred during flushSync`)},rr=(()=>{if(typeof MessageChannel<`u`){let e=null,t;return()=>{var n;if(!e){let n=new MessageChannel;n.port1.onmessage=()=>{var t;e==null||(t=e.unref)==null||t.call(e),nr(!0)},e=n.port1,t=n.port2}(n=e.ref)==null||n.call(e),t.postMessage(null)}}return()=>setTimeout(()=>nr(!0),0)})(),ir=e=>{if(Yn!==null)return st&&console.warn(`flushTapSync was called from inside a render or commit. The flush is deferred until the current pass completes.`),e();let t=Jn;Jn={schedulers:new Set,tasks:[],notifies:[],isScheduled:!0};try{let t=e();return nr(),t}finally{let e=Jn;Jn=t;for(let t of e.tasks)Jn.tasks.push(t);if(Jn.tasks.length>0&&Qn.markDirty(),e.schedulers.size>0){for(let t of e.schedulers)Jn.schedulers.add(t);tr()}}};function ar(e){if(e.length===0)return;let t;for(let r=0;r<e.length;r++)try{e[r]()}catch(e){var n;((n=t)==null?t=[]:n).push(e)}t!==void 0&&Kn(t,`Errors during commit`)}function or(e){let t=e.setup,n=e.setupDeps,r=e.generation,i;try{let e=t();if(e!==void 0&&typeof e!=`function`)throw Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof e}`);i=e}finally{e.generation===r?(e.cleanup=i,e.deps=n):i==null||i()}}var sr=e=>e.setup===void 0?!1:e.deps===null||e.setupDeps===void 0||!qt(e.deps,e.setupDeps);function cr(e,t){var n;let r;for(let t of e)sr(t)&&((n=r)==null?r=[]:n).push(t);if(r===void 0)return t;for(let e of r)if(e.deps=null,e.cleanup!==void 0)try{e.cleanup()}catch(e){var i;((i=t)==null?t=[]:i).push(e)}finally{e.cleanup=void 0}for(let e of r)try{or(e)}catch(e){var a;((a=t)==null?t=[]:a).push(e)}return t}function lr(e,t=!0){let n;e.insertionCells!==null&&t&&(n=cr(e.insertionCells,n)),n=cr(e.effectCells,n),n!==void 0&&Kn(n,`Errors during commit`)}function ur(e){let t;for(let i of e)if(i.deps=null,i.cleanup)try{var n;(n=i.cleanup)==null||n.call(i)}catch(e){var r;((r=t)==null?t=[]:r).push(e)}finally{i.cleanup=void 0}t!==void 0&&Kn(t,`Errors during cleanup`)}var dr,fr={useState:Kt,useReducer:Ut,useRef:bt,useMemo:Yt,useCallback:Xt,useEffect:yt,useLayoutEffect:yt,useInsertionEffect:Zt,useEffectEvent:Qt,useContext:Pt,use:nn,useSyncExternalStore:an,useDebugValue:on,useId:cn,useImperativeHandle:ln,useMemoCache:Gn},pr=h.default,mr=(dr=pr.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE)==null?pr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:dr,hr=mr==null?null:`H`in mr?{get current(){return mr.H},set current(e){mr.H=e}}:`ReactCurrentDispatcher`in mr?{get current(){return mr.ReactCurrentDispatcher.current},set current(e){mr.ReactCurrentDispatcher.current=e}}:null;function gr(e){if(!hr)return e();let t=hr.current;hr.current=fr;try{return e()}finally{hr.current=t}}function _r(e,t,n=void 0,r){return{hook:e,root:t,markDirty:n,devStrictMode:r,cells:[],effectCells:[],insertionCells:null,hostCells:null,contextDeps:null,wipContextDeps:null,wipCommitCallbacks:null,memoCache:{current:null,workInProgress:null,refreshedIndices:null,index:0},renderPendingCells:null,currentIndex:0,isRefreshing:!1,isFirstRender:!0,isMounted:!1,isReleased:!1,isNeverMounted:!0}}function vr(e){e.wipCommitCallbacks=null,e.wipContextDeps=null,e.memoCache.workInProgress=null,e.memoCache.refreshedIndices=null}function yr(e,t,n){try{t?(e.isReleased=!0,e.insertionCells!==null&&ur(e.insertionCells)):e.isMounted&&(e.isMounted=!1,ur(e.effectCells))}catch(e){var r;((r=n)==null?n=[]:r).push(e)}if(e.hostCells!==null){for(let r of e.hostCells)if(r.fiber!==null&&(n=yr(r.fiber,t,n)),r.fibers!==null)for(let{fiber:e}of r.fibers.values())n=yr(e,t,n)}return n}function br(e,t=!0){let n;t&&(n=yr(e,!0,n)),n=yr(e,!1,n),n!==void 0&&Kn(n,`Errors during cleanup`)}function xr(e){let t;for(let n of e)n.isReleased&&(t=yr(n,!0,t));for(let n of e)t=yr(n,!1,t);t!==void 0&&Kn(t,`Errors during cleanup`)}function Sr(e,t){var n,r;if(e.renderPendingCells!==null){for(let t of e.renderPendingCells)t.renderQueue=null;e.renderPendingCells.clear()}let i=0,a,o=e.isRefreshing;e.isRefreshing=o||(n=(r=ot())==null?void 0:r.isRefreshing)!=null&&n;try{var s,c;do{if(++i>25)throw Error(`Too many re-renders. tap limits the number of renders to prevent an infinite loop.`);e.memoCache.index=0,it(e,()=>{a=gr(()=>e.hook(...t))})}while(((s=(c=e.renderPendingCells)==null?void 0:c.size)==null?0:s)>0)}catch(t){throw vr(e),t}finally{e.isRefreshing=o}return Lt(e),a}function Cr(e){let t=e.wipCommitCallbacks;e.wipCommitCallbacks=null;let n=st&&!e.isMounted&&e.devStrictMode===`root`;e.isMounted=!0,e.isNeverMounted=!1,t!==null&&(e.contextDeps=e.wipContextDeps,lt(e.root),e.memoCache.workInProgress!==null&&(e.memoCache.current=e.memoCache.workInProgress,e.memoCache.workInProgress=null,e.memoCache.refreshedIndices=null),ar(t)),n&&(lr(e,t!==null),br(e,!1),e.isMounted=!0),lr(e,!n&&t!==null)}var wr=()=>{let e=at();return e.devStrictMode?e.isFirstRender?`child`:`root`:null},Tr=()=>null,Er=()=>{if(!st)return Tr;let e=yn(0);_n(()=>e.current++);let t=e.current===2,n=yn(!1),r=yn(!0);return r.current=!0,G(()=>{var e;(e=h.default.version)!=null&&e.startsWith(`18.`)&&(r.current||(n.current=!0),r.current=!1)},[]),()=>t||n.current?`child`:null},Dr=()=>ot()?wr:Er(),Or=e=>{let t=at(),n=t.currentIndex++,r=t.cells[n],i;if(r===void 0){var a;t.isFirstRender||ht();let r=e instanceof Map;i={type:`host`,fiber:r?null:e,fibers:r?e:null},t.cells[n]=i,((a=t.hostCells)==null?t.hostCells=[]:a).push(i)}else r.type!==`host`&&gt(),i=r;return i.fibers===null&&i.fiber!==e&&ft(t,()=>{i.fiber=e}),i},kr=(e,t)=>{if(!(e instanceof Map))return t(e);for(let{fiber:n}of e.values())t(n)},Ar=e=>{e.isReleased=!1},jr=e=>{e.isReleased=!0,e.isMounted||queueMicrotask(()=>{e.isReleased&&br(e,!0)})},Mr=e=>{En(()=>(kr(e,Ar),()=>kr(e,jr)),[e]),G(()=>()=>{xr(e instanceof Map?Array.from(e.values(),({fiber:e})=>e):[e])},[e])},Nr=e=>ot()?Or(e):(Mr(e),null),Pr=()=>{let e=yn(0),t=e.current,n=at();return{version:t,markDirty:bn(()=>()=>{var t;e.current++,(t=n.markDirty)==null||t.call(n)},[n]),root:n.root}},Fr=()=>{let[e]=_n(()=>ct((e,t)=>{let i=!1;r(t=>(i=!e(),i?t:t+1)),i||n(()=>e()&&t())})),[t,n]=vn((t,n)=>(ut(e,t),t+ +!!n()),0),[,r]=_n(0);return ut(e,t),{root:e,version:t,markDirty:void 0}},Ir=()=>{let e=Dr(),t=ot()===null,n=t?e():null,{root:r,version:i,markDirty:a}=t?Fr():Pr();return{version:i,createFiber:xn((i,o,s)=>_r(i,r,s?()=>{s(),a==null||a()}:a,t?n:e()),[])}},Lr=e=>e(),Rr=e=>{let t=[];for(let n of e)try{n()}catch(e){t.push(e)}Kn(t,`Errors occurred while notifying Tap root subscribers`)},zr=(e,t,n,r)=>{let i=new Zn(()=>c.handleUpdate(),r),a=[],o=ct((e,t)=>{(a.length!==0||e())&&(a.push(t),i.markDirty())},r),s=_r(Lr,o,void 0,t),c={scheduler:i,queue:a,fiber:s,subscribers:new Set,pendingHostRender:!1,isMounted:!1,hasRendered:!1,committedRender:e,context:new Map,value:void 0,applyQueue:()=>{ut(o,o.committedVersion);for(let e of a)st&&s.devStrictMode&&e(),e();return ut(o,o.committedVersion+o.changelog.length),a.length},publish:(e,t)=>{i.isDirty||o.committedVersion!==t||c.value===e||(c.value=e,er(()=>Rr(c.subscribers),r))},finishFlush:(e,t,n)=>{lt(o),a.splice(0,n),c.pendingHostRender=!1,a.length===0&&i.settle(),c.isMounted&&Cr(s),c.publish(e,t)},handleUpdate:()=>{let e=c.applyQueue(),t;try{st&&s.devStrictMode&&Et(c.context,()=>Sr(s,[c.committedRender])),t=Et(c.context,()=>Sr(s,[c.committedRender]))}catch(e){if(ut(o,o.committedVersion),$t(e)){let t=()=>{c.isMounted&&i.markDirty()};e.then(t,t);return}if(c.isMounted){c.pendingHostRender=!0,n(e=>e+1);return}throw e}if(i.isDirty)throw Error(`Scheduler is dirty, this should never happen`);c.finishFlush(t,o.version,e)}};return c},Br=e=>{var t,n;let r=ot()===null,i=(t=ot())==null?void 0:t.root.onError,[,a]=_n(0),o=Dr(),s=yn(null),c=(n=s.current)==null?s.current=zr(e,o(),a,i):n,l=Tt(),u=c.scheduler.isDirty||c.pendingHostRender?c.applyQueue():0,d=Et(l,()=>Sr(c.fiber,[e])),f={render:e,context:l,value:d,drained:u,wip:c.fiber.wipCommitCallbacks,version:c.fiber.root.version,processed:!1};return c.hasRendered||(c.hasRendered=!0,c.committedRender=e,c.context=l,c.value=d),G(()=>(c.isMounted=!0,()=>{c.isMounted=!1}),[c]),Nr(c.fiber),G(()=>{var e;st&&r&&((e=c.fiber).devStrictMode!=null||(e.devStrictMode=o())),f.processed?c.fiber.isMounted||(Cr(c.fiber),c.queue.length&&!c.scheduler.isDirty&&c.scheduler.markDirty()):(f.processed=!0,c.committedRender=f.render,c.context=f.context,c.fiber.wipCommitCallbacks===f.wip?f.drained>0&&c.fiber.root.version===f.version?c.finishFlush(f.value,f.version,f.drained):(Cr(c.fiber),c.publish(f.value,f.version)):c.scheduler.isDirty||c.handleUpdate())}),bn(()=>({getValue:()=>c.value,subscribe:e=>(c.subscribers.add(e),()=>c.subscribers.delete(e))}),[c])},Vr=(e,t)=>{let n=!1,r=_r(Br,ct((i,a)=>{i()&&(a(),$n(()=>{!n&&r.isMounted&&(st&&r.devStrictMode&&Sr(r,[e]),Sr(r,[e]),Cr(r))},t==null?void 0:t.onError))},t==null?void 0:t.onError),void 0,st?`root`:null),i=()=>{try{return st&&r.devStrictMode&&Sr(r,[e]),Sr(r,[e])}catch(e){throw $t(e)?Error(`createTapRoot suspended during its initial render; resolve the data first or use useTapRoot under a Suspense boundary.`):e}},a=()=>ir(()=>$n(()=>{n||Cr(r)})),o=()=>{n||(n=!0,br(r))},s,c=()=>{var e;return(e=s)==null?s=i():e};if(!(t!=null&&t.mountOnSubscribe)){let e=c();return a(),E(E({},e),{},{unmount:o})}let l=0,u=()=>$n(()=>{l===0&&r.isMounted&&br(r,!1)},t==null?void 0:t.onError);return{getValue:()=>c().getValue(),subscribe:e=>{let t=c().subscribe(e);if(l++===0&&!r.isMounted&&!n)try{a()}catch(e){try{br(r,!1)}finally{l--,t()}throw e}let i=!0;return()=>{i&&(i=!1,t(),--l===0&&u())}},unmount:o}};function Hr(e){return(...t)=>({hook:e,args:t})}function Ur(e,t,n){return typeof t==`function`?(...n)=>Ur(e,t(...n)):n?E(E({},t),{},{key:e,deps:n}):E(E({},t),{},{key:e})}var Wr=(e,t)=>({fiber:e,key:t,currentDeps:null,current:null,wipDeps:null,wip:null});function Gr(e){var t,n;let{version:r,createFiber:i}=Ir(),a=yn(null),o=(t=a.current)==null?a.current=Wr(i(e.hook,e.key),e.key):t,s=bn(()=>o.fiber.hook===e.hook&&o.key===e.key&&!o.fiber.isReleased?o.fiber:i(e.hook,e.key),[o,e.hook,e.key,i]);o.wipDeps=o.currentDeps,o.wip=o.current;let c=[s,r,e.args];((n=ot())!=null&&n.isRefreshing||zt(s)||o.currentDeps===null||!qt(o.currentDeps,c))&&(o.wipDeps=c,o.wip={value:Sr(s,e.args)});let l=o.wip,u=Nr(s);return G(()=>{if(o.currentDeps=o.wipDeps,o.current=o.wip,o.fiber=s,o.key=e.key,Cr(s),u!==null)return()=>{u.fiber!==s&&br(s,!0)}},[o,u,s,e.key,l]),l.value}var Kr=(e,t,n)=>{var r;let i=yn(null),a=(r=i.current)==null?i.current={currentDeps:null,current:null}:r,o=!n&&a.currentDeps&&qt(a.currentDeps,t)?a.current:e();return G(()=>{a.currentDeps=t,a.current=o}),o},qr=(e,t)=>{let n=e.get(t);n&&(n.isDirty=!0)},Jr=(e,t)=>!e.isDirty&&!zt(e.fiber)&&(e.committedElement===t||t.deps!==void 0&&e.committedDeps!==void 0&&qt(e.committedDeps,t.deps)),Yr=e=>{if(!Rt())return!1;for(let{fiber:t}of e.values())if(zt(t))return!0;return!1};function Xr(e){var t,n;let[r]=_n(()=>new Map),{version:i,createFiber:a}=Ir(),o=(t=(n=ot())==null?void 0:n.isRefreshing)!=null&&t,s=Yr(r),c=!1,l=Kr(()=>{let t=new Set,n=[],i=0;for(let s=0;s<e.length;s++){let l=e[s],u=l.key;if(u===void 0)throw Error(`useResources did not provide a key for array at index ${s}`);if(t.has(u))throw Error(`Duplicate key ${u} in useResources`);t.add(u);let d=r.get(u);if(!d){let e=a(l.hook,l.key,()=>qr(r,u));d={fiber:e,next:{value:Sr(e,l.args),deps:l.deps,element:l},isDirty:!1,committedDeps:void 0,committedElement:void 0,committedValue:void 0},i++,r.set(u,d)}else if(d.fiber.hook!==l.hook){let e=a(l.hook,l.key,()=>qr(r,u)),t=Sr(e,l.args);d.next={value:t,deps:l.deps,element:l,remount:e},c=!0}else if(!o&&Jr(d,l))typeof d.next==`object`&&vr(d.fiber),d.fiber.contextDeps&&Lt(d.fiber,d.fiber.contextDeps),d.next=`skip`;else{let e=Sr(d.fiber,l.args);d.next={value:e,deps:l.deps,element:l}}n.push(typeof d.next==`object`?d.next.value:d.committedValue)}if(r.size>n.length-i)for(let e of r.keys())t.has(e)||(r.get(e).next=`delete`,c=!0);return n},[e,r,a,i],o||s);return Nr(r),G(()=>{if(c){let e=[];for(let[t,n]of r.entries()){let i=n.next;i===`delete`?(e.push(n.fiber),r.delete(t)):i!==`skip`&&i.remount&&(e.push(n.fiber),n.fiber=i.remount)}for(let t of e)t.isReleased=!0;xr(e)}for(let e of r.values()){let t=e.next;t===`skip`?!e.fiber.isNeverMounted&&!e.fiber.isMounted&&Cr(e.fiber):t!==`delete`&&(Cr(e.fiber),e.committedDeps=t.deps,e.committedElement=t.element,e.committedValue=t.value,e.isDirty=!1,e.next=`skip`)}},[l,r,c]),o?l.slice():l}var Zr=e=>e(),Qr=e=>{let{createFiber:t}=Ir(),[n]=_n(()=>t(Zr,void 0)),r=Sr(n,[e]);Nr(n);let i=!1,a=()=>{i&&n.isMounted||(i=!0,Cr(n))};return G(a),{value:r,effects:a}},$r,ei,ti,ni,ri=()=>()=>{},ii=`You are using a component or hook that requires an AuiProvider. Wrap your component in an <AuiProvider> component.`,ai=($r=new WeakMap,ei=new WeakMap,ti=new WeakMap,ni=new WeakMap,class extends Fe{constructor(e,t,n){super(),Xe(this,$r,void 0),Xe(this,ei,void 0),Xe(this,ti,void 0),Xe(this,ni,void 0),Qe($r,this,e),Qe(ei,this,t),Qe(ti,this,n)}get(e,t){var n;if(t===`subscribe`||t===`on`)return ri;if(t===`optional`)return(n=$e(ni,this))==null?Qe(ni,this,nt($e(ti,this).call(this))):n;let r=Pe(t,$e($r,this));return r===!1?Ve($e(ei,this).call(this,String(t)),String(t)):r}ownKeys(){return[`subscribe`,`on`,`optional`]}getOwnPropertyDescriptor(e,t){if(t!==`optional`)return super.getOwnPropertyDescriptor(e,t);let n=this.get(e,t);if(n!==void 0)return{value:n,writable:!1,enumerable:!1,configurable:!0}}has(e,t){return t===`subscribe`||t===`on`||t===`optional`}}),oi=((e,t)=>{let n=new Proxy({},new ai(e,t,()=>n));return n})(`DefaultAssistantClient`,()=>ii),si=()=>new Proxy({},{get(e,t){let n=Pe(t,`AssistantClient`);return n===!1?Ve(`The current scope does not have a "${String(t)}" property.`,String(t)):n}}),ci=zn(oi),li=()=>{},ui=new WeakMap,di=e=>{var t;return(t=ui.get(e))==null?li:t},fi=(e,t)=>{ui.set(e,t)},pi=()=>Vn(ci),mi=(e,t)=>Mt(ci,e,t),hi=Symbol(`assistant-ui.transform-scopes`);function gi(e,t){let n=e;if(n[hi])throw Error(`transformScopes is already attached to this resource`);n[hi]=t}function _i(e){return e[hi]}var vi=e=>typeof e==`string`?{scope:e.split(`.`)[0],event:e}:{scope:e.scope,event:e.event},yi,bi,xi=(yi=(bi=h.default.__COMPILER_RUNTIME)==null?void 0:bi.c)==null?e=>(0,h.useMemo)(()=>{let t=Un(e);return t[Hn]=!0,t},[]):yi,Si=()=>ot()!==null,K=e=>Si()?Gn(e):xi(e),Ci=Symbol(`assistant-ui.store.clientIndex`),wi=e=>e[Ci],Ti=zn([]),Ei=()=>Bn(Ti),Di=(e,t)=>{let n=K(3),r=Ei(),i;return n[0]!==e||n[1]!==r?(i=[...r,e],n[0]=e,n[1]=r,n[2]=i):i=n[2],Mt(Ti,i,t)},Oi=zn(null),ki=Symbol(`aui.scope-effect-unapplied`),Ai=(e,t)=>Mt(Oi,e,t),ji=()=>{let e=Bn(Oi);if(!e)throw Error(`AssistantTapContext is not available`);return e},Mi=()=>ji().clientRef,Ni=()=>{var e;return(e=Bn(Oi))==null?void 0:e.invalidate},Pi=()=>Bn(Oi)!==null,Fi=()=>{var e;let t=K(5),n=(e=Bn(Oi))==null?void 0:e.markChanged,r;t[0]===n?r=t[1]:(r=n?{readers:new Set,version:0}:void 0,t[0]=n,t[1]=r);let i=r,a;return t[2]!==n||t[3]!==i?(a={signal:i,markChanged:n},t[2]=n,t[3]=i,t[4]=a):a=t[4],a},Ii=(e,t,n,r)=>{let i=K(8),a;i[0]!==e||i[1]!==n||i[2]!==t?(a=()=>{if(e===void 0)return;let r=e.current;if(r===null)throw Error(`useAssistantScopeEffect ran before the client was committed. This is likely an internal bug in assistant-ui.`);let i=()=>{var n;let r=(n=e.current)==null?void 0:n[t];return r!==void 0&&Ue(r)?Ke(r):void 0},a=ki,o,s=e=>{if(o==null||o(),o=void 0,a=ki,e!==void 0){let e=n();o=typeof e==`function`?e:void 0}a=e};s(i());let c=r.subscribe(()=>{let e=i();e!==a&&s(e)});return()=>{c(),o==null||o()}},i[0]=e,i[1]=n,i[2]=t,i[3]=a):a=i[3];let o;i[4]!==e||i[5]!==r||i[6]!==t?(o=[e,t,...r],i[4]=e,i[5]=r,i[6]=t,i[7]=o):o=i[7],G(a,o)},Li=(e,t,n)=>{let{clientRef:r}=ji();Ii(r,e,t,n)},Ri=()=>{let e=K(3),{emit:t}=ji(),n=Ei(),r;return e[0]!==n||e[1]!==t?(r=(e,r)=>{t(e,r,n)},e[0]=n,e[1]=t,e[2]=r):r=e[2],Cn(r)},zi=[],Bi=-1,Vi=null,Hi=e=>{Vi&&(e?Vi.signals.includes(e)||(Vi.signals.push(e),Vi.versions.push(e.version)):Vi.untracked=!0)},Ui=e=>{var t,n;Bi++;let r=(n=zi[t=Bi])==null?zi[t]={signals:[],versions:[],untracked:!1}:n;r.signals.length=0,r.versions.length=0,r.untracked=!1;let i=Vi;Vi=r;try{return{value:e(),signals:[...r.signals],untracked:r.untracked}}finally{Vi=i,Bi--,i&&(i.untracked||(i.untracked=r.untracked),r.signals.forEach(Hi))}},Wi=(e,t)=>e.length===t.length&&e.every(e=>t.includes(e)),Gi=(e,t)=>{var n,r;Bi++;let i=(r=zi[n=Bi])==null?zi[n]={signals:[],versions:[],untracked:!1}:r;i.signals.length=0,i.versions.length=0,i.untracked=!1;let a=Vi;Vi=i;try{let n=e(),r=t.current;if(i.untracked||i.signals.length===0)t.current=null;else if(r&&Wi(r.signals,i.signals))for(let e=0;e<r.signals.length;e++)r.versions[e]=r.signals[e].version;else t.current={signals:[...i.signals],versions:[...i.versions]};return n}finally{Vi=a,Bi--,a&&(a.untracked||(a.untracked=i.untracked),i.signals.forEach(Hi))}},Ki=(e,t)=>{let n=yn(null),r=yn(null),i=Pi(),a=wn(bn(()=>t=>{let i,a,o=!1,s=()=>{var t;let r=n.current,o=(t=r==null?void 0:r.signals)==null?null:t;if(i!==void 0&&(i===null||o===null?i===o:Wi(i,o)))return!1;let s=!1;if(i)for(let e of i)o!=null&&o.includes(e)||e.readers.delete(c);return r===null?a!=null||(a=e(c)):(a==null||a(),a=void 0,r.signals.forEach((e,t)=>{i!=null&&i.includes(e)||(s||(s=e.version!==r.versions[t]),e.readers.add(c))})),i=o&&[...o],s};function c(){o||(t(),s())}s();let l=()=>{s()&&t()};return r.current=l,()=>{if(o=!0,a==null||a(),i)for(let e of i)e.readers.delete(c);r.current===l&&(r.current=null)}},[e]),i?t:()=>Gi(t,n),t);return G(()=>{var e;(e=r.current)==null||e.call(r)}),a},qi=Symbol(`assistant-ui.store.getValue`),Ji=Symbol(`assistant-ui.store.signal`),Yi=e=>e[Ji],Xi=e=>{let t=Ei().at(-1),n=t&&Yi(t),r=Ni();G(()=>{if(n&&r&&e)return e(()=>r(n))},[e,n,r])},Zi=e=>{var t;let n=e[qi];if(!n)throw Error(`Client scope contains a non-client resource. Ensure your Derived get() returns a client created with useClientResource(), not a plain resource.`);return Hi(Yi(e)),(t=n.getState)==null?void 0:t.call(n)},Qi=new Map;function $i(e){let t=Qi.get(e);return t||(t=function(...t){if(!this||typeof this!=`object`)throw Error(`Method "${String(e)}" called without proper context. This may indicate the function was called incorrectly.`);let n=this[qi];if(!n)throw Error(`Method "${String(e)}" called on invalid client proxy. Ensure you are calling this method on a valid client instance.`);let r=n[e];if(!r)throw Error(`Method "${String(e)}" is not implemented.`);if(typeof r!=`function`)throw Error(`"${String(e)}" is not a function.`);return Hi(this[Ji]),r(...t)},Qi.set(e,t)),t}var ea=class extends Fe{constructor(e,t,n,r){super(),S(this,`boundFns`,void 0),S(this,`cachedReceiver`,void 0),S(this,`outputRef`,void 0),S(this,`tagRef`,void 0),S(this,`index`,void 0),S(this,`signal`,void 0),S(this,`self`,void 0),this.outputRef=e,this.tagRef=t,this.index=n,this.signal=r}get(e,t,n){if(t===qi)return this.outputRef.current;if(t===Ji)return this.signal;if(t===Ci)return this.index;if(t===Ie)return this.self;if(t===Le)return this.tagRef.current;let r=Pe(t,`ClientProxy`);if(r!==!1)return r;let i=this.outputRef.current[t];if(typeof i==`function`){if(n===void 0)return i;this.boundFns&&this.cachedReceiver===n||(this.boundFns=new Map,this.cachedReceiver=n);let e=this.boundFns.get(t);return e||(e=$i(t).bind(n),this.boundFns.set(t,e)),e}return i}ownKeys(){return Object.keys(this.outputRef.current)}has(e,t){return t===qi||t===Ji||t===Ci||t===Ie||t===Le||t in this.outputRef.current}},ta=class extends Fe{constructor(e,t){super(),S(this,`targetRef`,void 0),S(this,`signal`,void 0),this.targetRef=e,this.signal=t}get(e,t){return t===Ji?this.signal:(Hi(this.signal),this.targetRef.current[t])}ownKeys(){return Hi(this.signal),Reflect.ownKeys(this.targetRef.current)}has(e,t){return Hi(this.signal),t in this.targetRef.current}getOwnPropertyDescriptor(e,t){var n;Hi(this.signal);let r=(n=Reflect.getOwnPropertyDescriptor(this.targetRef.current,t))==null?void 0:n.value;if(r!==void 0)return{value:r,writable:!1,enumerable:!0,configurable:!0}}},na=e=>{let t=yn(e),{signal:n,markChanged:r}=Fi(),i=bn(()=>{let e=new ta(t,n);return new Proxy({},e)},[n]);return G(()=>{t.current!==e&&(t.current=e,n&&r(n))},[r,n,e]),i},ra=e=>{var t;let n=yn(null),r=yn(null),i=bn(()=>({}),[e.hook,e.key]),a=Ei().length,{signal:o,markChanged:s}=Fi(),c=bn(()=>{let e=new ea(n,r,a,o),t=new Proxy({},e);return e.self=t,t},[a,o]),l=Di(c,function(){return Gr(e)});return n.current||(n.current=l,r.current=i),G(()=>{let e=n.current!==l||r.current!==i;n.current=l,r.current=i,e&&o&&s(o)}),{methods:c,state:(t=l.getState)==null?void 0:t.call(l),key:e.key}},ia=Hr(ra),aa=0,oa=0,sa=e=>{aa++,oa++;try{return e()}finally{oa--,aa++}},ca=e=>{let t,n=new Map,r=-1,i=t=>{if(oa===0)return Zi(e[t]());if(r!==aa)n.clear(),r=aa;else{let e=n.get(t);if(e)return e.signals.forEach(Hi),e.untracked&&Hi(void 0),e.state}let{value:i,signals:a,untracked:o}=Ui(()=>Zi(e[t]()));return n.set(t,{state:i,signals:a,untracked:o}),i};class a extends Fe{get(t,n){let r=Pe(n,`OptionalAssistantState`);if(r!==!1)return r;let a=n;if(!qe(a)&&Ue(e[a]))return i(a)}ownKeys(){return Je(e)}has(t,n){return!qe(n)&&n in e}}class o extends Fe{get(e,n){var r;let o=Pe(n,`AssistantState`);if(o!==!1)return o;if(n===`optional`)return(r=t)==null?t=new Proxy({},new a):r;let s=n;if(!qe(s))return i(s)}ownKeys(){return[...Je(e),`optional`]}has(t,n){return n===`optional`||!qe(n)&&n in e}}return new Proxy({},new o)},la=new WeakMap,ua=e=>{let t=la.get(e);return t||(t=ca(e),la.set(e,t)),t},da=zn(void 0),fa=(e,t)=>{let n=Bn(da);return Mt(da,e==null?n:e,t)},pa=()=>Bn(da),ma=(e,t)=>{if(Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.hasOwn(t,n)&&Object.is(e[n],t[n]))},ha=Symbol(`assistant-ui.derived-hook`),ga=e=>{e[ha]=!0},_a=e=>e[ha]===!0,va=e=>{try{e()}catch(e){console.error(`NotificationManager: subscriber callback error`,e)}},ya=e=>{console.error(`NotificationManager: event listener error`,e)},ba=(e,t,n)=>{try{let r=e(t,n);r!==null&&(typeof r==`object`||typeof r==`function`)&&typeof r.then==`function`&&Promise.resolve(r).catch(ya)}catch(e){ya(e)}},xa=()=>{let e=new Map,t=new Set,n=new Set,r=new Set;return{on(n,r){let i=r;if(n===`*`)return t.add(i),()=>t.delete(i);let a=e.get(n);return a||(a=new Set,e.set(n,a)),a.add(i),()=>{a.delete(i),a.size===0&&e.get(n)===a&&e.delete(n)}},emit(n,r,i){(e.has(n)||t.size!==0)&&queueMicrotask(()=>{let a=e.get(n);if(a)for(let e of a)ba(e,r,i);if(t.size>0){let e={event:n,payload:r};for(let n of t)ba(n,e,i)}})},subscribe(e){return n.add(e),()=>n.delete(e)},markChanged(e){e.version++,r.add(e)},invalidate(e){e.version++,sa(()=>{for(let t of[...e.readers])va(t)})},notifySubscribers(){sa(()=>{for(let e of n)va(e);if(r.size===0)return;let e=new Set;for(let t of r)for(let n of t.readers)e.add(n);r.clear();for(let t of e)va(t)})}}},Sa=()=>_n(xa)[0],Ca=()=>{let[e]=_n(()=>({controller:new AbortController,generation:0}));return En(()=>{let t=++e.generation;return()=>queueMicrotask(()=>{e.generation===t&&e.controller.abort()})},[e]),e.controller.signal},wa=e=>{let t=bn(()=>({}),[]);return t.v!==void 0&&ma(t.v,e)?t.v:(t.v=e,e)},Ta=e=>{let t=K(2),n=yn(void 0),r;return t[0]===e?r=t[1]:(r=t=>{let r=e(t);return n.current!==void 0&&ma(n.current,r)?n.current:(n.current=r,r)},t[0]=e,t[1]=r),r},Ea=(()=>{try{return process.env.NODE_ENV===`development`||process.env.NODE_ENV===`test`}catch(e){return!1}})(),Da=(e,t)=>{let n=E({},e),r=new Set,i=!0;for(;i;){i=!1;for(let e of Object.values(n)){if(r.has(e.hook))continue;r.add(e.hook);let a=_i(e.hook);if(a){a(n,t),i=!0;break}}}return n},Oa=e=>_a(e.hook),ka=e=>{var t;if(!Oa(e))return{source:`root`,query:{}};let n=e.args[0];return{source:n.source,query:(t=n.query)==null?{}:t}},Aa=Symbol.for(`aui.event-receiver-ref`),ja=(e,t)=>{let n=e===oi?si():e,r=Object.create(n);Object.assign(r,t);let i;return Object.defineProperty(r,"optional",{get:()=>{var e;return(e=i)==null?i=nt(r):e},enumerable:!1}),r},Ma=({notifications:e,clientRef:t})=>bn(()=>({subscribe:e.subscribe,on:function(n,r){if(!this)throw Error(`const { on } = useAui() is not supported. Use aui.on() instead.`);let{scope:i,event:a}=vi(n),o=n[Aa];if(i!==`*`&&!o&&We(this[i]))throw Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);let s=e.on(a,(e,n)=>{var a;if(i===`*`)return r(e);let s=((a=(o==null?t:o).current)==null?this:a)[i];if(!Ue(s))return;let c=Ge(s);if(c===n[wi(c)])return r(e)});if(i!==`*`){if(o){if(t.parent===oi)return s}else if(We(t.parent[i]))return s}let c=t.parent.on(n,r);return()=>{s(),c()}}}),[e,t]),Na=e=>{let t=K(5),n;t[0]===e?n=t[1]:(n=ka(e),t[0]=e,t[1]=n);let{source:r,query:i}=n,a=wa(i),o;return t[2]!==r||t[3]!==a?(o={source:r,query:a},t[2]=r,t[3]=a,t[4]=o):o=t[4],wa(o)},Pa=e=>He(e)?()=>(Hi(void 0),e):()=>e,Fa=(e,t)=>{let n=K(3),r;return n[0]!==t||n[1]!==e?(r=t?e:ia(e),n[0]=t,n[1]=e,n[2]=r):r=n[2],Gr(r)},Ia=Hr((e,t)=>{let n=pi(),r=Oa(t),i=Fa(t,r),a=r?i:i.methods,o=Na(t),s=bn(()=>Be(E({name:e},o),Pa(a)),[e,o,a]);return n[e]=s,s}),La=e=>{let t=K(2),n;return t[0]===e?n=t[1]:(n=e.map(Ja),t[0]=e,t[1]=n),Xr(n)},Ra=(e,t)=>{let n=wa(t),r=bn(()=>({}),[]);return r.deps!==n&&(r.deps=n,r.client=e),r.client},za=({parent:e,entries:t,clientRef:n,notifications:r})=>{let i=ja(e,Ma({notifications:r,clientRef:n}));return{client:Ra(i,[e,...Ai(bn(()=>({clientRef:n,emit:r.emit,markChanged:r.markChanged,invalidate:r.invalidate}),[n,r.emit,r.markChanged,r.invalidate]),function(){return mi(i,function(){return La(t)})})])}},Ba=({parent:e,entries:t,destroySignal:n})=>{let r=yn({parent:e,current:null}).current,{value:i,effects:a}=Qr(function(){let i=Sa(),{client:a}=fa(n,function(){return za({parent:e,entries:t,clientRef:r,notifications:i})});return G(()=>e.subscribe(i.notifySubscribers),[e,i]),G(()=>i.notifySubscribers()),a});return En(()=>{r.parent=e,r.current=i},[i,e,r]),{client:i,effects:a}},Va=({parent:e,entries:t,destroySignal:n})=>{let r=yn({parent:e,current:null}).current,{value:i,effects:a}=Qr(function(){let i=Sa(),a=Br(function(){return fa(n,function(){return za({parent:e,entries:t,clientRef:r,notifications:i})})}),o=wn(a.subscribe,()=>a.getValue().client,()=>a.getValue().client);return G(()=>{let t=()=>ir(()=>{r.current=a.getValue().client,i.notifySubscribers()}),n=a.subscribe(t),o=e.subscribe(t);return()=>{n(),o()}},[a,e,i]),o});return En(()=>{r.parent=e,r.current=i},[i,e,r]),{client:i,effects:a}},Ha=(e,t,n,r)=>{let{get:i}=r.args[0],a=Ki(e.subscribe,()=>i(e)),o=Na(r),s=bn(()=>Be(E({name:n},o),Pa(a)),[n,o,a]);return t[n]=s,s},Ua=(e,t)=>{if(Ea){let[e]=_n(()=>t.map(([e])=>e).join(`,`)),n=t.find(([,e])=>!Oa(e));if(n)throw Error(`Scope "${n[0]}" is a root scope but this useAui mounted derived-only; remount with a new key to change scope kinds.`);let r=t.map(([e])=>e).join(`,`);if(r!==e)throw Error(`A derived-only config mounted scopes [${e}] but now has [${r}]; remount with a new key to change the scope set.`)}let n=yn({parent:e,current:null}).current,r=ja(e,{subscribe:e.subscribe,on:function(t,r){if(!this)throw Error(`const { on } = useAui() is not supported. Use aui.on() instead.`);let{scope:i,event:a}=vi(t);if(i===`*`)return e.on(t,r);let o=t[Aa];if(!o&&We(this[i]))throw Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);return e.on({scope:i,event:a,[Aa]:o==null?n:o},r)}}),i=Ra(r,[e,...t.map(([t,n])=>Ha(e,r,t,n))]);return En(()=>{n.parent=e,n.current=i},[i,e,n]),i},Wa=(e,t)=>{let n=K(8),r;n[0]!==t||n[1]!==e?(r=Object.entries(Da(t,e)),n[0]=t,n[1]=e,n[2]=r):r=n[2];let i=r,a;n[3]===i?a=n[4]:(a=()=>i.length===0||i.some(Ya),n[3]=i,n[4]=a);let[o]=_n(a),s;return n[5]!==i||n[6]!==o?(s={entries:i,rooted:o},n[5]=i,n[6]=o,n[7]=s):s=n[7],s},Ga=(e,t,n,r)=>{let{entries:i,rooted:a}=Wa(e,t);return a?n({parent:e,entries:i,destroySignal:r}):{client:Ua(e,i)}},Ka=(e,t,n)=>Ga(e,t,Ba,n);function qa(e){let t=pi();if(e){let{client:n,effects:r}=Ga(t,e,Va,Ca());return r&&fi(n,r),n}return t}function Ja(e){let[t,n]=e;return Ur(t,Ia(t,n))}function Ya(e){let[,t]=e;return!Oa(t)}var q=e=>{let t=K(5),n=qa(),r;t[0]===n?r=t[1]:(r=ua(n),t[0]=n,t[1]=r);let i=r,a;t[2]!==i||t[3]!==e?(a=()=>e(i),t[2]=i,t[3]=e,t[4]=a):a=t[4];let o=Ki(n.subscribe,a);if(typeof o==`object`&&o&&(o===i||o===i.optional))throw Error(`You tried to return the entire AssistantState. This is not supported due to technical limitations.`);return Tn(o),o},Xa=e=>{let t=K(3),{get:n}=e,r=qa(),i;return t[0]!==r||t[1]!==n?(i=()=>n(r),t[0]=r,t[1]=n,t[2]=i):i=t[2],q(i)};ga(Xa);var Za=Hr(Xa),Qa=e=>typeof e.getConfig==`function`,$a=()=>()=>{},eo=e=>{if(!Qa(e))return{getConfig:()=>e,subscribe:$a};let t=null;return{getConfig:()=>{var n;return((n=t)==null?t={value:e.getConfig()}:n).value},subscribe:n=>(t=null,e.subscribe(()=>{t=null,n()}))}},to=e=>typeof e.getClient==`function`&&!(`on`in e),no=e=>to(e)?e:{getClient:()=>e,subscribe:e.subscribe},ro=new WeakMap,io=(e,t)=>{var n;let r=no((n=t==null?void 0:t.parent)==null?oi:n),i=eo(e),a={parent:r.getClient(),current:null},o=new AbortController,s=xa(),c=ro.get(r),l=()=>{var e;return(e=c==null?void 0:c())==null?r.getClient():e},u,d,f=null,p=()=>Vr(function(){let[,e]=vn(e=>e+1,0),t=l();En(()=>{f=e,u=t});let n=wn(r.subscribe,r.getClient,r.getClient),c=wn(i.subscribe,i.getConfig,i.getConfig),d=Object.entries(Da(c,n)),p=fa(o.signal,function(){return za({parent:n,entries:d,clientRef:a,notifications:s})});return a.current===null&&(a.current=p.client),p},{mountOnSubscribe:!0}),m=p(),h=()=>{a.parent=r.getClient(),a.current=m.getValue().client,d=l(),ir(s.notifySubscribers)},g=!1,_=!1,v=(e=!1)=>{if(!e&&Object.is(u,l()))return!1;if(!g)m.unmount(),a.current=null,m=p(),m.getValue(),u=l();else{_=!0;try{ir(()=>f==null?void 0:f())}finally{_=!1}}return!0},y=()=>{let e=g&&(t==null?void 0:t.parent)!==void 0&&!c&&!_;_=!1,v(e)||h()},b=()=>{v(!c)||c&&Object.is(d,l())||h()},x=0,S=null,C=!1,w=()=>{let e=r.subscribe(b),t;try{t=m.subscribe(y),g=!0}catch(t){throw e(),t}a.parent=r.getClient(),a.current=m.getValue().client,S=()=>{S=null,t(),e()}},T=()=>{S==null||S(),m.unmount()},E={getClient:()=>(m.getValue(),!g&&u===void 0&&(u=l()),v(),m.getValue().client),subscribe:e=>{if(C)return()=>{};let t=s.subscribe(e);if(x++===0){try{w()}catch(e){throw x--,t(),e}C&&T()}let n=!0;return()=>{n&&(n=!1,t(),--x===0&&(S==null||S()))}},destroy:()=>{C||(C=!0,o.abort(),x>0&&S===null||T())}};return ro.set(E,()=>m.getValue()),E},ao=e=>{if(e.key===void 0)throw Error(`useClientLookup: Element has no key`);return e.key};function oo(e){let t=K(12),n;t[0]===e?n=t[1]:(n=e.map(lo),t[0]=e,t[1]=n);let r=Xr(n),i;t[2]===e?i=t[3]:(i=e.reduce(co,Object.create(null)),t[2]=e,t[3]=i);let a=i,o;t[4]===r?o=t[5]:(o=r.map(so),t[4]=r,t[5]=o);let s=o,c;t[6]!==a||t[7]!==r?(c=e=>{if(`index`in e){if(e.index<0||e.index>=r.length)throw Error(`useClientLookup: index ${e.index} out of bounds (length: ${r.length}) (ignore if recovered)`);return r[e.index].methods}let t=a[e.key];if(t===void 0)throw Error(`useClientLookup: key "${e.key}" not found (ignore if recovered)`);return r[t].methods},t[6]=a,t[7]=r,t[8]=c):c=t[8];let l;return t[9]!==s||t[10]!==c?(l={state:s,get:c},t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function so(e){return e.state}function co(e,t,n){return e[ao(t)]=n,e}function lo(e){return Ur(ao(e),ia(e),e.deps)}var uo=e=>new Proxy({},{get:(t,n)=>Reflect.get(e.getClient(),n),has:(t,n)=>n in e.getClient(),ownKeys:()=>{let t=e.getClient(),n=new Set(Reflect.ownKeys(t));for(let e in t)n.add(e);return[...n]},getOwnPropertyDescriptor:(t,n)=>{let r=e.getClient();if(n in r)return{configurable:!0,enumerable:!0,value:Reflect.get(r,n)}}}),fo=(e,t=0)=>t===0?Math.abs(e.scrollHeight-e.scrollTop-e.clientHeight)<=1||e.scrollHeight<=e.clientHeight:e.scrollHeight-t-e.scrollTop-e.clientHeight<=1||e.scrollHeight-t<=e.clientHeight,po=(e,t=0)=>t===0?e.scrollHeight>e.clientHeight+1:e.scrollHeight-t>e.clientHeight+1,mo=e=>e.nodeType===Node.ELEMENT_NODE,ho=(e,t)=>{let n=[],r=typeof ResizeObserver<`u`?new ResizeObserver(()=>t()):null;if(r){r.observe(e);for(let t of e.children)r.observe(t);n.push(()=>r.disconnect())}if(typeof MutationObserver<`u`){let i=new MutationObserver(n=>{if(r){for(let t of n)if(t.target===e){for(let e of t.addedNodes)mo(e)&&r.observe(e);for(let e of t.removedNodes)mo(e)&&r.unobserve(e)}}n.some(e=>e.type!==`attributes`||e.attributeName!==`style`)&&t()});i.observe(e,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),n.push(()=>i.disconnect())}return()=>{for(let e of n)e()}},go=`[data-message-id]`,_o=`[aria-expanded], summary`,vo=`textarea, select, [contenteditable]:not([contenteditable='false']), input:not([type='checkbox']):not([type='radio']):not([type='button']):not([type='submit']):not([type='reset']):not([type='image']):not([type='range']):not([type='file']):not([type='color'])`,yo=new Set([` `,`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`]),bo=e=>{var t;let n=e.closest(_o);if(!n)return!1;if(n.tagName===`SUMMARY`)return((t=n.parentElement)==null?void 0:t.hasAttribute(`open`))===!1;let r=n.getAttribute(`aria-haspopup`);return n.getAttribute(`aria-expanded`)===`false`&&(r===null||r===`false`)&&n.getAttribute(`role`)!==`combobox`},xo=(e,t)=>e.getBoundingClientRect().top-t.getBoundingClientRect().top,So=e=>{let t=e.querySelector(go),n=t==null?void 0:t.dataset.messageId;return t&&n?{id:n,offset:xo(t,e)}:null},Co=e=>{let{top:t,bottom:n}=e.getBoundingClientRect(),r=null;for(let i of e.querySelectorAll(go)){let e=i.getBoundingClientRect();if(e.bottom<=t)continue;if(e.top>=n)break;let a=i.dataset.messageId;if(a){if(e.top>=t)return{id:a,offset:e.top-t};r!=null||(r={id:a,offset:e.top-t})}}return r},wo=(e,t)=>{for(let n of e.querySelectorAll(go))if(n.dataset.messageId===t)return n;return null},To=e=>{let t=null,n=null,r=null,i=!0,a=!0,o=!1,s=!1,c=0,l=0,u=new Map,d=!1,f=!1,p=0,m=0,h=0,g=0,_=null,v=null,y=null,b=0,x=e=>{if(!t)return!1;let n=wo(t,e.id);if(!n)return!1;let r=xo(n,t)-e.offset;return b=t.scrollTop+r,Math.abs(r)>=1&&t.scrollTo({top:b,behavior:`instant`}),b=t.scrollTop,!0},S=t=>{t!==i&&(i=t,e.onAtBottomChange(t))},C=()=>{_!==null&&(cancelAnimationFrame(_),_=null)},w=(e=`auto`)=>{var n;t&&(a=!0,o=!1,s=!1,r=e,y=null,(n=t.scrollTo)==null||n.call(t,{top:t.scrollHeight,behavior:e}),p=t.scrollTop,m=t.scrollHeight)},T=e=>{r=e,typeof requestAnimationFrame<`u`&&(C(),_=requestAnimationFrame(()=>{_=null,w(e)}))},E=({preserveFollow:n=!1,insetShrank:i=!1}={})=>{if(!t)return;y&&Math.abs(t.scrollTop-b)>=1&&(y=null);let{autoScroll:l,holdFollow:u}=e.getOptions(),d=fo(t,c),f=t.scrollTop<p&&t.scrollHeight>=m;u||d||l&&(n||r!==null||o||!f&&!i)||(a=!1),r!==null&&!d&&p<t.scrollTop||(d?(po(t,c)&&(r=null,o&&s&&(o=!1),s=!1),a=!0):f&&(r=null,C(),a=!1),(d||r===null)&&S(d)),p=t.scrollTop,m=t.scrollHeight,v=So(t)},D=()=>E(),O=()=>{if(_!==null)return;let{autoScroll:t,holdFollow:n}=e.getOptions();r&&n?r=null:r?w(r):!n&&t&&a&&!o?w(`instant`):y&&!x(y)&&(y=null)},k=()=>{if(!t)return;let{scrollHeight:e,clientHeight:n}=t;(e!==h||n!==g)&&(h=e,g=n,O(),E())},A=()=>{(r!==null||_!==null)&&(r=null,C(),E({preserveFollow:!0}))},j=e=>{var t,n;e.key!==`Enter`&&!yo.has(e.key)||(t=e.target)!=null&&(n=t.closest)!=null&&n.call(t,vo)||A()},M=e=>{var t;let n=e.target;n!=null&&(t=n.closest)!=null&&t.call(n,go)&&!n.closest(vo)&&bo(n)&&(o=!0,s=!1,r=null,C())},N=e=>{if(e.type===`keydown`){var n,r;let t=e;if(!yo.has(t.key)||(n=e.target)!=null&&(r=n.closest)!=null&&r.call(n,vo))return}else if(e.type===`pointerdown`&&e.target!==t)return;s=!0},P=()=>{y=null},F=()=>{d?e.getOptions().scrollToBottomOnInitialize&&!f&&(f=!0,r===null&&T(`instant`)):f=!1},I=()=>{var t;let n=l;for(let e of u.values())n+=e;if(c===n)return;let r=n>c;c=n,(t=e.onContentInsetChange)==null||t.call(e,n),r&&O(),E({insetShrank:!r})};return{attach:e=>{n==null||n(),t=e,r=null,p=e.scrollTop,m=e.scrollHeight,h=0,g=0,f=!1,a=!0,o=!1,s=!1,v=null,y=null,b=e.scrollTop,S(!0);let i=ho(e,k);e.addEventListener(`scroll`,D),e.addEventListener(`pointerdown`,A),e.addEventListener(`wheel`,A,{passive:!0}),e.addEventListener(`touchstart`,A,{passive:!0}),e.addEventListener(`keydown`,j),e.addEventListener(`click`,M,!0);for(let t of[`pointerdown`,`wheel`,`touchmove`,`keydown`])e.addEventListener(t,N,{passive:!0});for(let t of[`pointerdown`,`wheel`,`touchstart`,`keydown`])e.addEventListener(t,P,{passive:!0});F(),c>0&&O();let l=()=>{if(n===l){i(),e.removeEventListener(`scroll`,D),e.removeEventListener(`pointerdown`,A),e.removeEventListener(`wheel`,A),e.removeEventListener(`touchstart`,A),e.removeEventListener(`keydown`,j),e.removeEventListener(`click`,M,!0);for(let t of[`pointerdown`,`wheel`,`touchmove`,`keydown`])e.removeEventListener(t,N);for(let t of[`pointerdown`,`wheel`,`touchstart`,`keydown`])e.removeEventListener(t,P);C(),t===e&&(t=null),n=null}};return n=l,l},get isAtBottom(){return i},scrollToBottom:w,messagesPrepended:n=>{var i;if(!t||e.getOptions().autoScroll&&a&&!o||r!==null)return;let s=v;if((s==null?void 0:s.id)===n&&x(s))y=(i=Co(t))==null?s:i;else{let e=t.scrollHeight-(m-p);Math.abs(t.scrollTop-e)>=1&&t.scrollTo({top:e,behavior:`instant`})}p=t.scrollTop,m=t.scrollHeight},setContentInset:e=>{l!==e&&(l=e,I())},registerContentInset:()=>{let e=Symbol();return u.set(e,0),{setHeight:t=>{u.has(e)&&u.get(e)!==t&&(u.set(e,t),I())},unregister:()=>{u.delete(e)&&I()}}},setHasMessages:e=>{d=e,F()},runStarted:()=>{y=null,o=!1,s=!1,e.getOptions().scrollToBottomOnRunStart&&T(`auto`)},threadSwitched:()=>{y=null,o=!1,s=!1,e.getOptions().scrollToBottomOnThreadSwitch&&T(`instant`)},dispose:()=>{n==null||n(),C()}}},Eo=Symbol(`skip-update`),Do=(e,...t)=>{let n=[];for(let r of e)try{r(...t)}catch(e){n.push(e)}if(n.length===1)throw n[0];if(n.length>1){for(let e of n)console.error(e);throw AggregateError(n)}},Oo=e=>{Do(e)},ko=(e,t)=>{try{e()}catch(e){console.error(`[assistant-ui] Subscription rollback cleanup threw`,e)}throw t},Ao=(e,t)=>e===void 0||t===void 0?e===t:ma(e,t),jo=class{constructor(){S(this,`_subscribers`,new Set)}subscribe(e){return this._subscribers.add(e),()=>this._subscribers.delete(e)}waitForUpdate(){return new Promise(e=>{let t=this.subscribe(()=>{t(),e()})})}_notifySubscribers(){Do(this._subscribers)}},Mo=class extends jo{constructor(e){super(),S(this,`_state`,void 0),S(this,`getServerSnapshot`,void 0),this._state=e,this.subscribe=this.subscribe.bind(this),this.getState=this.getState.bind(this),this.getServerSnapshot=()=>e}getState(){return this._state}setState(e){Object.is(e,this._state)||(this._state=e,this._notifySubscribers())}},No=class{constructor(){S(this,`_subscriptions`,new Set),S(this,`_connection`,void 0)}get isConnected(){return!!this._connection}notifySubscribers(e,t){t?L(this._subscriptions,e,t):Do(this._subscriptions,e)}_updateConnection(){if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else{let e=this._connection;this._connection=void 0,e==null||e()}}subscribe(e){this._subscriptions.add(e);try{this._updateConnection()}catch(t){throw this._subscriptions.delete(e),t}return()=>{this._subscriptions.delete(e),this._updateConnection()}}},Po=class extends No{get path(){return this.binding.path}constructor(e){super(),S(this,`binding`,void 0),S(this,`_previousState`,void 0),S(this,`getState`,()=>(this.isConnected||this._syncState(),this._previousState)),this.binding=e;let t=e.getState();if(t===Eo)throw Error(`Entry not available in the store`);this._previousState=t}_syncState(){let e=this.binding.getState();return e===Eo||Ao(e,this._previousState)?!1:(this._previousState=e,!0)}_connect(){let e=this.binding.subscribe(()=>{this._syncState()&&this.notifySubscribers()});try{return this._syncState(),e}catch(t){throw ko(e,t)}}},Fo=class extends No{get path(){return this.binding.path}constructor(e){super(),S(this,`binding`,void 0),S(this,`_previousStateDirty`,!0),S(this,`_previousState`,void 0),S(this,`getState`,()=>{if(!this.isConnected||this._previousStateDirty){let e=this.binding.getState();e===Eo||this._previousState!==void 0&&Ao(e,this._previousState)||(this._previousState=e),this._previousStateDirty=!1}if(this._previousState===void 0)throw Error(`Entry not available in the store`);return this._previousState}),this.binding=e}_connect(){let e=this.binding.subscribe(()=>{this._previousStateDirty=!0,this.notifySubscribers()});return this._previousStateDirty=!0,e}},Io=class extends No{get path(){return this.binding.path}constructor(e){super(),S(this,`binding`,void 0),this.binding=e}getState(){return this.binding.getState()}outerSubscribe(e){return this.binding.subscribe(e)}_connect(){let e=()=>{this.notifySubscribers()},t=this.binding.getState(),n=t==null?void 0:t.subscribe(e),r=()=>{let r=this.binding.getState();if(r===t)return;t=r;let i=n;n=void 0;try{i==null||i()}finally{n=r==null?void 0:r.subscribe(e),e()}},i;try{i=this.outerSubscribe(r)}catch(e){throw ko(()=>n==null?void 0:n(),e)}return()=>Oo([()=>i(),()=>n==null?void 0:n()])}},Lo=class extends No{constructor(e){super(),S(this,`config`,void 0),this.config=e}getState(){return this.config.binding.getState()}outerSubscribe(e){return this.config.binding.subscribe(e)}_connect(){let e=`Runtime event "${this.config.event}"`,t=t=>{this.notifySubscribers(t,e)},n=this.config.binding.getState(),r=n==null?void 0:n.unstable_on(this.config.event,t),i=()=>{let e=this.config.binding.getState();if(e===n)return;n=e;let i=r;r=void 0;try{i==null||i()}finally{r=e==null?void 0:e.unstable_on(this.config.event,t),this.config.notifyOnRebind&&t({})}},a;try{a=this.outerSubscribe(i)}catch(e){throw ko(()=>r==null?void 0:r(),e)}return()=>Oo([()=>a(),()=>r==null?void 0:r()])}},Ro=class{constructor(e=()=>({})){S(this,`_providers`,new Map),S(this,`_providerUnsubscribes`,new Map),S(this,`_getMergeOptions`,void 0),S(this,`_subscribers`,new Set),this._getMergeOptions=e}getModelContext(){return ce(new Set(this._providers.values()),this._getMergeOptions())}registerModelContextProvider(e){let t=Symbol();this._providers.set(t,e);let n;try{var r;n=(r=e.subscribe)==null?void 0:r.call(e,()=>{this.notifySubscribers()})}catch(e){this._providers.delete(t);try{this.notifySubscribers()}catch(e){console.error(e)}throw e}this._providerUnsubscribes.set(t,n),this.notifySubscribers();let i=!1;return()=>{if(i)return;i=!0,this._providers.delete(t);let e=this._providerUnsubscribes.get(t);this._providerUnsubscribes.delete(t);let n=!1,r,a=e=>{try{e()}catch(e){n?console.error(e):(n=!0,r=e)}};if(e&&a(e),a(()=>this.notifySubscribers()),n)throw r}}notifySubscribers(){Do(this._subscribers)}subscribe(e){return this._subscribers.add(e),()=>{this._subscribers.delete(e)}}},zo=(e,t=`The operation was aborted`)=>{if(e.reason!==void 0)return e.reason;let n=Error(t);return n.name=`AbortError`,n},Bo=(e,t)=>{if(!e)try{return Promise.resolve(t())}catch(e){return Promise.reject(e)}return e.aborted?Promise.reject(zo(e)):new Promise((n,r)=>{let i=!1,a=()=>e.removeEventListener(`abort`,c),o=e=>{i||(i=!0,a(),n(e))},s=e=>{i||(i=!0,a(),r(e))},c=()=>s(zo(e));e.addEventListener(`abort`,c,{once:!0});let l;try{l=t()}catch(e){s(e);return}Promise.resolve(l).then(o,s)})},Vo=((e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i-->0;)r+=e[Math.random()*e.length|0];return r})(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7),Ho=new Set([`__proto__`,`constructor`,`prototype`]);function Uo(e){if(Ho.has(e))throw Error(`Unsafe gorp path segment: ${e}`)}var Wo=class{constructor(e=null,t={}){var n;S(this,`_state`,void 0),S(this,`_strict`,void 0),S(this,`_logged`,new Set),S(this,`_warnedClamp`,!1),this._state=e,this._strict=(n=t.strict)==null||n}get state(){return this._state}logOnce(e,t){this._logged.has(e)||this._logged.size>=20||(this._logged.add(e),t())}append(e){this._state=e.reduce((e,t)=>{if(this._strict)return this.apply(e,t);try{return this.apply(e,t)}catch(n){return this.logOnce(`skip:${String(n)}`,()=>console.error(`Skipped unappliable gorp operation: ${String(n)}`,t)),e}},this._state)}apply(e,t){let n=t.type;switch(n){case`set`:return this.updatePath(e,t.path,()=>t.value);case`append-text`:return this.updatePath(e,t.path,e=>{if(typeof e!=`string`)throw Error(`Expected string at path [${t.path.join(`, `)}]`);return e+t.value});default:throw Error(`Invalid operation type: ${n}`)}}updatePath(e,t,n){if(t.length===0)return n(e);let r=[],i=e;for(let e=0;e<t.length;e++){if(i!=null||(i={}),typeof i!=`object`)throw Error(`Invalid path: [${t.slice(e).join(`, `)}]`);let n=t[e];if(Uo(n),Array.isArray(i)){let a=Number(n);if(!Number.isInteger(a)||String(a)!==String(n))throw Error(`Expected array index at [${t.slice(e).join(`, `)}]`);if(a<0)throw Error(`Insert array index out of bounds`);if(a>i.length){if(this._strict)throw Error(`Insert array index out of bounds`);this._warnedClamp||(this._warnedClamp=!0,console.warn(`Clamped out-of-bounds gorp array index ${a} to ${i.length}`)),a=i.length}r.push({kind:`array`,state:i,key:a}),i=Object.hasOwn(i,a)?i[a]:void 0}else{let e=i;r.push({kind:`object`,state:e,key:n}),i=Object.hasOwn(e,n)?e[n]:void 0}}let a=n(i);for(let e=r.length-1;e>=0;e--){let t=r[e];if(t.kind===`array`){let e=[...t.state];e[t.key]=a,a=e}else{let e=E({},t.state);e[t.key]=a,a=e}}return a}},Go=/[0-9a-fA-F]/;function Ko(e){let t=[`ROOT`],n=-1,r=null,i=0,a=[],o;function s(){o!==void 0&&(a.push(JSON.parse(`"${o}"`)),o=void 0)}function c(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`),s();break;case`f`:case`t`:case`n`:n=i,r=i,t.pop(),t.push(a),t.push(`INSIDE_LITERAL`);break;case`-`:t.pop(),t.push(a),t.push(`INSIDE_NUMBER`),s();break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=i,t.pop(),t.push(a),t.push(`INSIDE_NUMBER`),s();break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`),s();break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`),s()}}function l(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop(),o=a.pop()}}function u(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),o=(Number(o)+1).toString();break;case`]`:n=r,t.pop(),o=a.pop()}}for(let s=0;s<e.length;s++){let d=e[s];switch(t[t.length-1]){case`ROOT`:c(d,s,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(d){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`),o=``;break;case`}`:n=s,t.pop(),o=a.pop()}break;case`INSIDE_OBJECT_AFTER_COMMA`:d===`"`&&(t.pop(),t.push(`INSIDE_OBJECT_KEY`),o=``);break;case`INSIDE_OBJECT_KEY`:switch(d){case`"`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`);break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`),o+=d;break;default:o+=d}break;case`INSIDE_OBJECT_AFTER_KEY`:d===`:`&&(t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`));break;case`INSIDE_OBJECT_BEFORE_VALUE`:c(d,s,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:l(d,s);break;case`INSIDE_STRING`:switch(d){case`"`:t.pop(),n=s,o=a.pop();break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=s}break;case`INSIDE_ARRAY_START`:switch(d){case`]`:n=s,t.pop(),o=a.pop();break;default:o=`0`,c(d,s,`INSIDE_ARRAY_AFTER_VALUE`)}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(d){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),o=(Number(o)+1).toString();break;case`]`:n=s,t.pop(),o=a.pop();break;default:n=s}break;case`INSIDE_ARRAY_AFTER_COMMA`:c(d,s,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:{t.pop();let e=t[t.length-1];d===`u`?(t.push(`INSIDE_STRING_UNICODE_ESCAPE`),i=0):e===`INSIDE_STRING`&&(n=s),e===`INSIDE_OBJECT_KEY`&&(o+=d);break}case`INSIDE_STRING_UNICODE_ESCAPE`:{let e=t[t.length-2];if(!Go.test(d)){t.pop(),s--;break}i++,i===4&&(t.pop(),e===`INSIDE_STRING`&&(n=s)),e===`INSIDE_OBJECT_KEY`&&(o+=d);break}case`INSIDE_NUMBER`:switch(d){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=s;break;case`e`:case`E`:case`-`:case`+`:case`.`:break;case`,`:t.pop(),o=a.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&u(d,s),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&l(d,s);break;case`}`:t.pop(),o=a.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&l(d,s);break;case`]`:t.pop(),o=a.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&u(d,s);break;default:t.pop(),o=a.pop()}break;case`INSIDE_LITERAL`:{let i=e.substring(r,s+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?l(d,s):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&u(d,s)):n=s;break}}}let d=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:d+=`"`;break;case`INSIDE_OBJECT_KEY`:case`INSIDE_OBJECT_AFTER_KEY`:case`INSIDE_OBJECT_AFTER_COMMA`:case`INSIDE_OBJECT_START`:case`INSIDE_OBJECT_BEFORE_VALUE`:case`INSIDE_OBJECT_AFTER_VALUE`:d+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:d+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?d+=`true`.slice(t.length):`false`.startsWith(t)?d+=`false`.slice(t.length):`null`.startsWith(t)&&(d+=`null`.slice(t.length))}}return[d,a]}var qo=m(u(((e,t)=>{var n=typeof Buffer<`u`,r=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,i=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function a(e,t,a){a==null&&typeof t==`object`&&t&&(a=t,t=void 0),n&&Buffer.isBuffer(e)&&(e=e.toString()),e&&e.charCodeAt(0)===65279&&(e=e.slice(1));let s=JSON.parse(e,t);if(typeof s!=`object`||!s)return s;let c=a&&a.protoAction||`error`,l=a&&a.constructorAction||`error`;if(c===`ignore`&&l===`ignore`)return s;if(c!==`ignore`&&l!==`ignore`){if(r.test(e)===!1&&i.test(e)===!1)return s}else if(c!==`ignore`&&l===`ignore`){if(r.test(e)===!1)return s}else if(i.test(e)===!1)return s;return o(s,{protoAction:c,constructorAction:l,safe:a&&a.safe})}function o(e,{protoAction:t=`error`,constructorAction:n=`error`,safe:r}={}){let i=[e];for(;i.length;){let e=i;i=[];for(let a of e){if(t!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`__proto__`)){if(r===!0)return null;if(t===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.__proto__}if(n!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`constructor`)&&a.constructor!==null&&typeof a.constructor==`object`&&Object.prototype.hasOwnProperty.call(a.constructor,`prototype`)){if(r===!0)return null;if(n===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.constructor}for(let e in a){let t=a[e];t&&typeof t==`object`&&i.push(t)}}}return e}function s(e,t,n){let{stackTraceLimit:r}=Error;Error.stackTraceLimit=0;try{return a(e,t,n)}finally{Error.stackTraceLimit=r}}function c(e,t){let{stackTraceLimit:n}=Error;Error.stackTraceLimit=0;let r;try{r=a(e,t,{safe:!0})}catch(e){r=void 0}finally{Error.stackTraceLimit=n}return r}t.exports=s,t.exports.default=s,t.exports.parse=s,t.exports.safeParse=c,t.exports.scan=o}))(),1),Jo=Symbol(`aui.parse-partial-json-object.meta`),Yo=e=>e==null?void 0:e[Jo],Xo=e=>{if(e.length===0)return{[Jo]:{state:`partial`,partialPath:[]}};try{let t=qo.default.parse(e);if(typeof t!=`object`||!t)throw Error(`argsText is expected to be an object`);return t[Jo]={state:`complete`,partialPath:[]},t}catch(t){try{let[t,n]=Ko(e),r=qo.default.parse(t);if(typeof r!=`object`||!r)throw Error(`argsText is expected to be an object`);return r[Jo]={state:`partial`,partialPath:n},r}catch(e){return}}},Zo=(e,t,n)=>{if(typeof e!=`object`||!e)return t.state;if(t.state===`complete`)return`complete`;if(n.length===0)return t.state;let[r,...i]=n;if(!Object.hasOwn(e,r))return`partial`;let[a,...o]=t.partialPath;if(r!==a)return`complete`;let s=e[r];return Zo(s,{state:`partial`,partialPath:o},i)},Qo=(e,t)=>{let n=Yo(e);if(!n)throw Error(`unable to determine object state`);return Zo(e,n,t.map(String))},$o=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/,es=/^-?$|^-?(?:0|[1-9]\d*)(?:\.\d*)?$|^-?(?:0|[1-9]\d*)(?:\.\d+)?[eE][+-]?\d*$/,ts=/^[\t\n\r ]$/,ns=/^[0-9a-fA-F]$/,rs={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
8
+ `,r:`\r`,t:` `},is=e=>typeof e==`object`&&!!e,as=(e,t,n)=>{e[t]=n},os=e=>{if(Array.isArray(e))return[...e];let t={};for(let n of Object.keys(e))t[n]=e[n];return t},ss=(e,t,n,r)=>{let i=(e,a)=>{let o=r.has(e)?e:os(e);r.add(o);let s=t[a];if(a===t.length-1)return as(o,s,n),is(n)&&r.add(n),o;let c=o[s];if(!is(c))throw Error(`Invalid incremental JSON path`);return as(o,s,i(c,a+1)),o};return i(e,0)},cs=(e,t,n)=>{let r=Xo(``);for(let t of Object.keys(e))as(r,t,e[t]);let i=Yo(r);return i.state=t,i.partialPath=n.map(String),r},ls=e=>{let t=[e];for(;t.length>0;){let e=t.pop();for(let n of Object.keys(e)){let r=e[n];if(!is(r))continue;let i=os(r);as(e,n,i),t.push(i)}}return e},us=class e{constructor(e){S(this,`text`,void 0),S(this,`mode`,`start`),S(this,`root`,{}),S(this,`frames`,[]),S(this,`token`,void 0),S(this,`args`,void 0),S(this,`publishedArgs`,void 0),S(this,`ownedContainers`,void 0),this.args=e,this.publishedArgs=e}static from(t=``,n=Xo(``)){var r;let i=new e(n);t.length!==0&&(i.text={length:t.length,previous:void 0,value:t});let a=t.trimEnd().endsWith(`}`)?Xo(t):void 0;return a&&((r=Yo(a))==null?void 0:r.state)===`complete`?(i.args=a,i.publishedArgs=a,i.mode=`complete`,i):(i.consumeDelta(t,!0),i.args=i.snapshot(n),i.args!==n&&(i.publishedArgs=i.mode===`fallback`?i.args:void 0),i)}get currentTextLength(){var e,t;return(e=(t=this.text)==null?void 0:t.length)==null?0:e}get currentArgs(){var e;return(e=this.publishedArgs)==null?this.publishedArgs=ls(this.args):e}append(t){var n,r;if(t.length===0)return this;if(this.currentTextLength===0)return e.from(t,this.args);if(this.mode===`complete`){let n=e.from(this.accumulatedText()+t,this.args);return n.args===this.args&&(n.publishedArgs=this.currentArgs),n}let i=this.clone(),a=this.args;return i.consumeDelta(t),i.text={length:((n=(r=this.text)==null?void 0:r.length)==null?0:n)+t.length,previous:this.text,value:t},i.args=i.snapshot(a),i.publishedArgs=i.args===a?this.currentArgs:i.mode===`fallback`?i.args:void 0,i}clone(){let t=new e(this.args);return t.text=this.text,t.mode=this.mode,t.root=this.root,t.frames=this.frames.map(e=>E(E({},e),{},{path:[...e.path]})),t.token=this.token?E(E({},this.token),`path`in this.token&&this.token.path?{path:[...this.token.path]}:void 0):void 0,t}snapshot(e){var t;return this.mode===`fallback`?(t=Xo(this.accumulatedText()))==null?e:t:this.mode===`start`?e:cs(this.root,this.mode===`complete`?`complete`:`partial`,this.partialPath())}accumulatedText(){let e=[];for(let t=this.text;t;t=t.previous)e.push(t.value);return e.reverse().join(``)}partialPath(){var e,t;return this.mode===`complete`?[]:this.token&&(this.token.kind===`number`||this.token.kind===`string`&&this.token.role===`value`)?this.token.path:(e=(t=this.frames.at(-1))==null?void 0:t.path)==null?[]:e}isFallback(){return this.mode===`fallback`}consumeDelta(e,t=!1){var n,r;if(!this.isFallback()){this.ownedContainers=t?new Set([this.root]):new Set;for(let t of e)if(this.consumeCharacter(t),this.isFallback())break;!this.isFallback()&&((n=this.token)==null?void 0:n.kind)===`string`&&this.token.role===`value`?this.writeValue(this.token.path,this.token.value):!this.isFallback()&&((r=this.token)==null?void 0:r.kind)===`number`&&$o.test(this.token.value)&&this.writeValue(this.token.path,Number(this.token.value)),this.ownedContainers=void 0}}consumeCharacter(e){let t=!0;for(;t&&this.mode!==`fallback`;){if(t=!1,this.token){t=this.consumeToken(e);continue}if(this.mode===`complete`){ts.test(e)||(this.mode=`fallback`);continue}if(this.mode===`start`){if(ts.test(e))continue;if(e!==`{`){this.mode=`fallback`;continue}this.mode=`parsing`,this.frames.push({kind:`object`,path:[],state:`first-key-or-end`});continue}let n=this.frames.at(-1);n?n.kind===`object`?this.consumeObjectCharacter(n,e):this.consumeArrayCharacter(n,e):this.mode=`fallback`}}consumeObjectCharacter(e,t){if(!ts.test(t))switch(e.state){case`first-key-or-end`:t===`}`?this.closeContainer():t===`"`?(e.state=`key`,this.startKeyString()):this.mode=`fallback`;break;case`key`:t===`"`?this.startKeyString():this.mode=`fallback`;break;case`colon`:t===`:`?e.state=`value`:this.mode=`fallback`;break;case`value`:this.startValue(t,[...e.path,e.key]);break;case`comma-or-end`:t===`,`?(e.state=`key`,e.key=void 0):t===`}`?this.closeContainer():this.mode=`fallback`}}consumeArrayCharacter(e,t){if(!ts.test(t))switch(e.state){case`first-value-or-end`:t===`]`?this.closeContainer():(e.state=`value`,this.startValue(t,[...e.path,e.index]));break;case`value`:this.startValue(t,[...e.path,e.index]);break;case`comma-or-end`:t===`,`?(e.index+=1,e.state=`value`):t===`]`?this.closeContainer():this.mode=`fallback`}}startValue(e,t){if(e===`{`)this.writeValue(t,{}),this.frames.push({kind:`object`,path:t,state:`first-key-or-end`});else if(e===`[`)this.writeValue(t,[]),this.frames.push({kind:`array`,path:t,state:`first-value-or-end`,index:0});else if(e===`"`)this.writeValue(t,``),this.startValueString(t);else if(e===`t`||e===`f`||e===`n`){let n=e===`t`?`true`:e===`f`?`false`:`null`;this.writeValue(t,n===`true`||n!==`false`&&null),this.token={kind:`literal`,value:n,offset:1}}else e===`-`||e>=`0`&&e<=`9`?(this.token={kind:`number`,path:t,value:e},$o.test(e)&&this.writeValue(t,Number(e))):this.mode=`fallback`}startKeyString(){this.token={kind:`string`,role:`key`,value:``,escape:`none`,unicode:``}}startValueString(e){this.token={kind:`string`,role:`value`,path:e,value:``,escape:`none`,unicode:``}}consumeToken(e){let t=this.token;return t.kind===`string`?this.consumeString(t,e):t.kind===`number`?this.consumeNumber(t,e):this.consumeLiteral(t,e)}consumeString(e,t){if(e.escape===`unicode`)return ns.test(t)?(e.unicode+=t,e.unicode.length===4&&(e.value+=String.fromCharCode(Number.parseInt(e.unicode,16)),e.escape=`none`,e.unicode=``),!1):(this.mode=`fallback`,!1);if(e.escape===`single`){if(t===`u`)return e.escape=`unicode`,!1;let n=rs[t];return n===void 0?this.mode=`fallback`:(e.value+=n,e.escape=`none`),!1}if(t===`\\`)return e.escape=`single`,!1;if(t.charCodeAt(0)<32)return this.mode=`fallback`,!1;if(t!==`"`)return e.value+=t,!1;if(this.token=void 0,e.role===`key`){let t=this.frames.at(-1);if(!t||t.kind!==`object`||e.value===`__proto__`||e.value===`prototype`&&t.path.at(-1)===`constructor`)return this.mode=`fallback`,!1;t.key=e.value,t.state=`colon`}else this.writeValue(e.path,e.value),this.finishValue();return!1}consumeNumber(e,t){if(t>=`0`&&t<=`9`||t===`e`||t===`E`||t===`+`||t===`-`||t===`.`){let n=e.value+t;return es.test(n)?(e.value=n,$o.test(e.value)&&this.writeValue(e.path,Number(e.value)),!1):(this.mode=`fallback`,!1)}return $o.test(e.value)?(this.token=void 0,this.finishValue(),!0):(this.mode=`fallback`,!1)}consumeLiteral(e,t){return t===e.value[e.offset]?(e.offset+=1,e.offset===e.value.length&&(this.token=void 0,this.finishValue()),!1):(this.mode=`fallback`,!1)}finishValue(){let e=this.frames.at(-1);!e||e.state!==`value`?this.mode=`fallback`:e.state=`comma-or-end`}closeContainer(){this.frames.pop(),this.frames.length===0?this.mode=`complete`:this.finishValue()}writeValue(e,t){try{var n;this.root=ss(this.root,e,t,(n=this.ownedContainers)==null?new Set:n)}catch(e){this.mode=`fallback`}}},ds=class{constructor(){S(this,`_streamStartTime`,void 0),S(this,`_firstTokenTime`,void 0),S(this,`_totalChunks`,0),S(this,`_toolCallIds`,new Set),this._streamStartTime=Date.now()}recordChunk(){this._totalChunks++}recordFirstToken(){this._firstTokenTime===void 0&&(this._firstTokenTime=Date.now())}recordToolCallStart(e){this._toolCallIds.add(e)}getTiming(e,t){let n=Date.now()-this._streamStartTime,r=e&&e>0?e:t?Math.ceil(t.length/4):void 0,i=r&&n>0?r/n*1e3:void 0;return E(E(E(E({streamStartTime:this._streamStartTime},this._firstTokenTime===void 0?void 0:{firstTokenTime:this._firstTokenTime-this._streamStartTime}),{},{totalStreamTime:n},r===void 0?void 0:{tokenCount:r}),i===void 0?void 0:{tokensPerSecond:i}),{},{totalChunks:this._totalChunks,toolCallCount:this._toolCallIds.size})}},fs=[`isPreliminary`,`modelContent`],ps=(e,t)=>E(E({},e),{},{parts:t,get content(){return this.parts}}),ms=(e,t)=>ps(e,[...e.parts,t]),hs=({unstable_state:e=null}={})=>({role:`assistant`,status:{type:`running`},parts:[],get content(){return this.parts},metadata:{unstable_state:e,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}),gs=16,_s=(e,t,n,r)=>{let i=t.path.length===1?e.parts[t.path[0]]:void 0;if(i===void 0)return n(`no-part:${t.type}`,`Dropped ${t.type} chunk: no part at path [${t.path.join(`, `)}]`),e;let a=t.path[0],o=r(i);return o===i?e:ps(e,[...e.parts.slice(0,a),o,...e.parts.slice(a+1)])},vs=(e,t,n)=>{let r=t.part;if(r.type===`text`||r.type===`reasoning`)return ms(e,E(E(E(E({type:r.type,text:``,status:{type:`running`}},r.providerMetadata!=null&&{providerMetadata:r.providerMetadata}),r.type===`reasoning`&&r.unstable_summary!==void 0?{unstable_summary:r.unstable_summary}:void 0),r.type===`reasoning`?{timing:{startedAt:Date.now()}}:void 0),r.parentId&&{parentId:r.parentId}));if(r.type===`tool-call`)return ms(e,E({type:`tool-call`,state:`partial-call`,status:{type:`running`,isArgsComplete:!1},toolCallId:r.toolCallId,toolName:r.toolName,argsText:``,args:{},timing:{startedAt:Date.now()}},r.parentId&&{parentId:r.parentId}));if(r.type===`source`)return ms(e,E(E({type:`source`,sourceType:r.sourceType,id:r.id,url:r.url},r.title?{title:r.title}:void 0),r.parentId&&{parentId:r.parentId}));if(r.type===`file`)return ms(e,E({type:`file`,mimeType:r.mimeType,data:r.data},r.parentId&&{parentId:r.parentId}));if(r.type===`data`)return ms(e,E({type:`data`,name:r.name,data:r.data},r.parentId&&{parentId:r.parentId}));{let t=String(r.type);return n(`unsupported-part-start:${t}`,`Unsupported part-start type ${t}: inserting an empty reasoning part to preserve part indices`),ms(e,{type:`reasoning`,text:``,status:{type:`running`}})}},ys=(e,t,n)=>_s(e,t,n,e=>e.type===`tool-call`?e.state===`partial-call`?E(E({},e),{},{state:`call`,status:e.status.type===`running`?{type:`running`,isArgsComplete:!0}:e.status}):e:(n(`wrong-part:tool-call-args-text-finish`,`Dropped tool-call-args-text-finish chunk: part is not a tool-call`),e)),bs=(e,t,n)=>_s(e,t,n,e=>{var n;if(e.type===`tool-call`&&e.isPreliminary)return e;let r=(e.type===`text`||e.type===`reasoning`)&&t.providerMetadata!=null?{providerMetadata:t.providerMetadata}:{};return e.type===`reasoning`&&e.timing!==void 0?E(E(E({},e),r),{},{status:{type:`complete`,reason:`unknown`},timing:E(E({},e.timing),{},{completedAt:(n=e.timing.completedAt)==null?Date.now():n})}):E(E(E({},e),r),{},{status:{type:`complete`,reason:`unknown`}})}),xs=(e,t,n,r)=>_s(e,t,n,e=>{if(e.type===`text`||e.type===`reasoning`)return E(E({},e),{},{text:e.text+t.textDelta},t.providerMetadata!=null&&{providerMetadata:t.providerMetadata});if(e.type===`tool-call`){let n=e.argsText+t.textDelta,i=r.get(e),a=i?i.append(t.textDelta):n.length===0?us.from(``):us.from(n,e.args),o=a.currentArgs,s=E(E({},e),{},{argsText:n,args:o});return r.set(s,a),s}return n(`wrong-part:text-delta`,`Dropped text-delta chunk: part is neither text nor tool-call`),e}),Ss=(e,t,n)=>_s(e,t,n,e=>{if(e.type===`tool-call`){var r,i,a;let n=t.isPreliminary===!0;if(n&&e.state===`result`)return e;let{isPreliminary:o,modelContent:s}=e,c=W(e,fs),l=e.status.type===`running`?e.status:{type:`running`,isArgsComplete:e.state!==`partial-call`};return n?E(E(E(E(E({},c),{},{state:e.state===`partial-call`?`partial-call`:`call`},t.artifact===void 0?{}:{artifact:t.artifact}),{},{result:t.result,isError:(r=t.isError)!=null&&r,isPreliminary:!0},t.modelContent===void 0?{}:{modelContent:t.modelContent}),t.messages===void 0?{}:{messages:t.messages}),{},{status:l}):E(E(E(E(E(E({},c),{},{state:`result`},e.timing===void 0?{}:{timing:E(E({},e.timing),{},{completedAt:(i=e.timing.completedAt)==null?Date.now():i})}),t.artifact===void 0?{}:{artifact:t.artifact}),{},{result:t.result,isError:(a=t.isError)!=null&&a},t.modelContent===void 0?{}:{modelContent:t.modelContent}),t.messages===void 0?{}:{messages:t.messages}),{},{status:{type:`complete`,reason:`stop`}})}return n(`wrong-part:result`,`Dropped result chunk: part is not a tool-call`),e}),Cs=(e,t)=>{var n,r;if(((n=e.status)==null?void 0:n.type)===`incomplete`&&((r=e.status)==null?void 0:r.reason)===`error`)return e;let i=ws(t);return E(E({},e),{},{status:i})},ws=e=>e.finishReason===`tool-calls`?{type:`requires-action`,reason:`tool-calls`}:e.finishReason===`stop`||e.finishReason===`unknown`?{type:`complete`,reason:e.finishReason}:{type:`incomplete`,reason:e.finishReason},Ts=(e,t)=>E(E({},e),{},{metadata:E(E({},e.metadata),{},{unstable_annotations:[...e.metadata.unstable_annotations,...t.annotations]})}),Es=(e,t)=>E(E({},e),{},{metadata:E(E({},e.metadata),{},{unstable_data:[...e.metadata.unstable_data,...t.data]})}),Ds=(e,t)=>E(E({},e),{},{metadata:E(E({},e.metadata),{},{steps:[...e.metadata.steps,{state:`started`,messageId:t.messageId}]})}),Os=(e,t)=>{var n;let r=e.metadata.steps.slice(),i=r.length-1;return r.length>0&&((n=r[i])==null?void 0:n.state)===`started`?r[i]=E(E({},r[i]),{},{state:`finished`,finishReason:t.finishReason,usage:t.usage,isContinued:t.isContinued}):r.push({state:`finished`,messageId:Vo(),finishReason:t.finishReason,usage:t.usage,isContinued:t.isContinued}),E(E({},e),{},{metadata:E(E({},e.metadata),{},{steps:r})})},ks=(e,t)=>{var n,r;let i=t.severity===`critical`||t.severity===`warning`||t.severity===`info`?t.severity:void 0;return E(E({},e),{},{status:{type:`incomplete`,reason:`error`,error:E({code:(n=t.code)==null?`unknown`:n,message:(r=t.error)==null?`unknown error`:r},i!==void 0&&{severity:i})}})},As=(e,t,n)=>(n.append(t.operations),E(E({},e),{},{metadata:E(E({},e.metadata),{},{unstable_state:n.state})})),js=e=>{let t=0;for(let n of e.metadata.steps)n.state===`finished`&&n.usage&&(t+=n.usage.outputTokens);return t},Ms=(e,t,n=0)=>{let r=n>0?n:js(t);if(r>0)return e.getTiming(r);let i=``;for(let e of t.parts)(e.type===`text`||e.type===`reasoning`)&&(i+=e.text);return e.getTiming(void 0,i||void 0)},Ns=e=>{let t=!1;return()=>{t||(t=!0,queueMicrotask(()=>{t=!1,e()}))}},Ps=class extends TransformStream{constructor({initialMessage:e,throttle:t,onError:n,strict:r=!0}={}){let i=e==null?hs():e,a,o,s=new ds,c=new WeakMap,l=new Set,u=(e,t)=>{l.has(e)||l.size>=gs||(l.add(e),console.warn(t))},d,f=t?Ns(()=>{d==null||d.enqueue(i)}):()=>{d==null||d.enqueue(i)};super({start(e){d=e},transform(e){s.recordChunk();let t=e.type;switch(t){case`part-start`:i=vs(i,e,u),e.part.type===`tool-call`&&s.recordToolCallStart(e.part.toolCallId);break;case`tool-call-args-text-finish`:i=ys(i,e,u);break;case`part-finish`:i=bs(i,e,u);break;case`text-delta`:{let t=xs(i,e,u,c);t!==i&&s.recordFirstToken(),i=t;break}case`result`:i=Ss(i,e,u);break;case`message-finish`:var l;o=(l=e.usage)==null?void 0:l.outputTokens,i=Cs(i,e);break;case`annotations`:i=Ts(i,e);break;case`data`:i=Es(i,e);break;case`step-start`:i=Ds(i,e);break;case`step-finish`:i=Os(i,e);break;case`error`:i=ks(i,e),n==null||n(e.error);break;case`update-state`:a!=null||(a=new Wo(i.metadata.unstable_state,{strict:r})),i=As(i,e,a);break;default:throw Error(`Unsupported chunk type: ${t}`)}i.status.type!==`running`&&(i=E(E({},i),{},{metadata:E(E({},i.metadata),{},{timing:Ms(s,i,o)})})),f()},flush(e){var t;if(((t=i.status)==null?void 0:t.type)===`running`){var n,r;let t=(n=(r=i.parts)==null?void 0:r.some(e=>e.type===`tool-call`&&(e.state===`call`||e.state===`partial-call`)&&(e.result===void 0||e.isPreliminary)))!=null&&n;i=Cs(i,{type:`message-finish`,path:[],finishReason:t?`tool-calls`:`unknown`,usage:{inputTokens:0,outputTokens:0}}),i=E(E({},i),{},{metadata:E(E({},i.metadata),{},{timing:Ms(s,i,o)})}),e.enqueue(i)}}})}};function Fs(){let e=this.getReader(),t=!1,n=Promise.resolve(),r=e=>{let t=n.then(e);return n=t.then(()=>void 0,()=>void 0),t},i=function(){var n=w(function*(n){if(!t){t=!0;try{return e.cancel(n)}finally{e.releaseLock()}}});return function(e){return n.apply(this,arguments)}}(),a={next:()=>r(w(function*(){if(t)return{done:!0,value:void 0};try{let n=yield e.read();return n.done&&(t=!0,e.releaseLock()),n}catch(n){throw t=!0,e.releaseLock(),n}})),return:e=>r(w(function*(){return yield i(e),{done:!0,value:e}})),throw:e=>r(w(function*(){throw yield i(void 0),e})),[Symbol.asyncIterator](){return this}},o=Symbol.asyncDispose;return o&&Object.defineProperty(a,o,{value:function(){var e=w(function*(){yield a.return()});return function(){return e.apply(this,arguments)}}(),writable:!0,configurable:!0}),a}function Is(e){var t;return e[t=Symbol.asyncIterator]!=null||(e[t]=Fs),e}var Ls=Symbol.asyncIterator,Rs=class e{constructor(e){S(this,`readable`,void 0),this.readable=e}static fromAssistantStream(t){return new e(t.pipeThrough(new Ps))}unstable_result(){var e=this;return w(function*(){let t;var n=!1,r=!1,i;try{for(var a=z(e),o;n=!(o=yield a.next()).done;n=!1)t=o.value}catch(e){r=!0,i=e}finally{try{n&&a.return!=null&&(yield a.return())}finally{if(r)throw i}}return t||{role:`assistant`,status:{type:`complete`,reason:`unknown`},parts:[],content:[],metadata:{unstable_state:null,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}})()}[Ls](){return Is(this.readable)[Symbol.asyncIterator]()}tee(){let[t,n]=this.readable.tee();return[new e(t),new e(n)]}},zs,Bs=Symbol.for(`aui.tool-response`),Vs=`<no result>`,Hs=(zs=Symbol.hasInstance,class e{get[Bs](){return!0}constructor(e){var t;S(this,`artifact`,void 0),S(this,`result`,void 0),S(this,`isError`,void 0),S(this,`isPreliminary`,void 0),S(this,`modelContent`,void 0),S(this,`messages`,void 0),e.artifact!==void 0&&(this.artifact=e.artifact);let n=e.result;this.result=n===void 0?Vs:n,this.isError=(t=e.isError)!=null&&t,e.isPreliminary&&(this.isPreliminary=!0),e.modelContent!==void 0&&(this.modelContent=e.modelContent),e.messages!==void 0&&(this.messages=e.messages)}static[zs](e){return typeof e==`object`&&!!e&&Bs in e}static toResponse(t){return t instanceof e?t:new e({result:t===void 0?Vs:t})}}),Us=class extends TransformStream{constructor(e){super();let t=e(super.readable);Object.defineProperty(this,"readable",{value:t,writable:!1})}},Ws=(e,t)=>new ReadableStream({start(n){var r;return(r=e.start)==null?void 0:r.call(e,t(n))},pull(n){var r;return(r=e.pull)==null?void 0:r.call(e,t(n))},cancel(t){var n;return(n=e.cancel)==null?void 0:n.call(e,t)}}),Gs=(e,t)=>{let n;return[Ws({start(e){n=e},cancel(e){return t==null?void 0:t(n,e)}},e),n]};function Ks(e,t,n){try{let r=e();if(typeof r==`object`&&r&&`then`in r)return r.then(t,n);t(r)}catch(e){n(e)}}var qs=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});if(!e||!t)throw Error(`Failed to create promise`);return{promise:n,resolve:e,reject:t}},Js=()=>{let e=[],t=!1,n=!1,r=!1,i,a,o,s=0,c,l,u=e=>{for(let t of e.holds)t.reached.resolve();e.holds=[]},d=()=>{if(a=void 0,!l){let n=e.splice(0);for(let e of n){var t;(t=e.orderedFinish)==null||t.delivered.resolve(),u(e)}l=Promise.all(n.map(function(){var e=w(function*(e){try{yield e.reader.cancel().catch(()=>void 0),yield e.pipeTask}finally{e.reader.releaseLock()}});return function(t){return e.apply(this,arguments)}}())).then(()=>void 0)}return l},f=e=>{n||r||(r=!0,console.error(e),d(),i.error(e),c==null||c.reject(e),c=void 0)},p=a=>{a.promise||(a.promise=a.reader.read().then(function(){var o=w(function*({done:o,value:l}){if(!(n||r)){if(o){var d;(d=a.orderedFinish)==null||d.delivered.resolve(),e.splice(e.indexOf(a),1),a.reader.releaseLock(),u(a),t&&e.length===0&&s===0&&i.close()}else{var f;if(a.gate&&(yield a.gate,a.gate=void 0,n||r))return;for(;a.holds[0]&&a.delivered>=a.holds[0].writtenBefore;)if(yield a.holds[0].flushed,a.holds.shift(),n||r)return;if(l.type===`part-finish`&&a.orderedFinish&&(yield a.orderedFinish.previous(),n||r))return;i.enqueue(l),a.delivered++;for(let e of a.holds)a.delivered>=e.writtenBefore&&e.reached.resolve();l.type===`part-finish`&&((f=a.orderedFinish)==null||f.delivered.resolve())}a.promise=void 0,c==null||c.resolve(),c=void 0}});return function(e){return o.apply(this,arguments)}}()).catch(e=>{a.promise=void 0,f(e)}))},m=new ReadableStream({start(e){i=e},pull(){return c=qs(),e.forEach(e=>{p(e)}),c.promise},cancel(){return w(function*(){n=!0;let e=d();c==null||c.resolve(),c=void 0,yield e})()}}),h=(e,t)=>{let n={writtenBefore:e.written(),reached:qs(),flushed:t};return e.delivered>=n.writtenBefore&&n.reached.resolve(),e.holds.push(n),n.reached.promise},g=l=>{let u=l.type===`step-finish`||l.type===`message-finish`||l.type===`error`;if((e.length>0||u)&&(a=void 0),!a){let l=[];a=l,s++;let d=o,p=u?e.filter(e=>e.written):[],m=d||p.length>0?qs():void 0,g=m?p.map(e=>h(e,m.promise)):[];m&&(o=m.promise),Promise.resolve().then(w(function*(){if(d&&(yield d),g.length>0&&(yield Promise.all(g)),s--,a===l&&(a=void 0),!(n||r)){for(let e of l)i.enqueue(e);t&&e.length===0&&s===0&&i.close(),c==null||c.resolve(),c=void 0}})).catch(f).finally(()=>{m&&(m.resolve(),o===m.promise&&(o=void 0))})}a.push(l),u&&(a=void 0)};return{readable:m,isSealed(){return t},isCancelled(){return n},isErrored(){return r},seal(){t||n||r||(t=!0,e.length===0&&s===0&&i.close())},addStream:(i,s,c)=>{let l=s==null?void 0:s.catch(()=>void 0);if(n||r){i.cancel().catch(()=>void 0);return}if(t)throw i.cancel().catch(()=>void 0),Error(`Cannot add streams after the run callback has settled.`);a=void 0;let u={reader:i.getReader(),pipeTask:l,orderedFinish:c==null?void 0:c.orderedFinish,written:c==null?void 0:c.written,delivered:0,gate:o,holds:[]};e.push(u),p(u)},enqueue(e){if(!(n||r)){if(t)throw Error(`Cannot add streams after the run callback has settled.`);g(e)}}}},Ys=e=>e instanceof TypeError,Xs=(e,t,n)=>{try{e.enqueue(t)}catch(e){if(!Ys(e))throw e;n==null||n(e)}},Zs=e=>{try{e.close()}catch(e){if(!Ys(e))throw e}},Qs=class{constructor(e,t={}){var n;S(this,`_controller`,void 0),S(this,`_strict`,void 0),S(this,`_isClosed`,!1),S(this,`_ignoreAppends`,!1),S(this,`_warnedDropped`,!1),S(this,`_warnDroppedAfterClose`,e=>{this._warnedDropped||(this._warnedDropped=!0,console.error(`Dropped text delta for closed stream: ${String(e)}`))}),this._controller=e,this._strict=(n=t.strict)==null||n}append(e,t){if(this._ignoreAppends)return this;let n=E({type:`text-delta`,path:[],textDelta:e},t!=null&&{providerMetadata:t});if(this._isClosed){if(this._strict)throw TypeError(`Cannot append to a closed TextStreamController`);return Xs(this._controller,n,this._warnDroppedAfterClose),this}return Xs(this._controller,n),this}close(e){this._isClosed||(this._isClosed=!0,Xs(this._controller,E({type:`part-finish`,path:[]},e!=null&&{providerMetadata:e})),Zs(this._controller))}__internal_close(){this._isClosed||(this._ignoreAppends=!0,this.close())}__internal_truncate(){this._isClosed||(this._ignoreAppends=!0,this._isClosed=!0,Zs(this._controller))}},$s=class{constructor(e,t={}){S(this,`_isClosed`,!1),S(this,`_hasArgsText`,!1),S(this,`_argsTextState`,`open`),S(this,`_controller`,void 0),S(this,`_argsTextController`,void 0),S(this,`_options`,void 0),this._controller=e,this._options=t,this._argsTextController=new Qs({enqueue:e=>{if(this._argsTextState!==`open`)throw TypeError(`Cannot append to finished tool-call args`);e.type===`text-delta`?(this._hasArgsText=!0,this._controller.enqueue(e)):(this._argsTextState=`finishing`,queueMicrotask(()=>this._finishArgsText()))},close:()=>{}},{strict:this._options.strict})}_finishArgsText(){this._argsTextState===`finishing`&&(this._argsTextState=`finished`,this._hasArgsText||Xs(this._controller,{type:`text-delta`,textDelta:`{}`,path:[]}),Xs(this._controller,{type:`tool-call-args-text-finish`,path:[]}))}get argsText(){return this._argsTextController}setResponse(e){var t=this;return w(function*(){var n;if(t._isClosed)return;let r=e.result;Xs(t._controller,E(E(E(E({type:`result`,path:[]},e.artifact===void 0?{}:{artifact:e.artifact}),{},{result:r===void 0?Vs:r,isError:(n=e.isError)!=null&&n},e.isPreliminary?{isPreliminary:!0}:{}),e.modelContent===void 0?{}:{modelContent:e.modelContent}),e.messages===void 0?{}:{messages:e.messages})),e.isPreliminary?(t._argsTextController.close(),t._finishArgsText()):yield t.close()})()}close(){var e=this;return w(function*(){var t,n;e._isClosed||(e._isClosed=!0,(t=(n=e._options).onClose)==null||t.call(n),e._argsTextController.close(),e._finishArgsText(),Xs(e._controller,{type:`part-finish`,path:[]}),Zs(e._controller))})()}__internal_truncate(){this._isClosed||(this._isClosed=!0,this._finishArgsText(),this._argsTextController.__internal_truncate(),this._argsTextState=`finished`,Zs(this._controller))}},ec=class{constructor(){S(this,`value`,-1)}up(){return++this.value}},tc=class extends TransformStream{constructor(e){super({transform(t,n){n.enqueue(E(E({},t),{},{path:[e,...t.path]}))}})}};TransformStream;var nc=class extends TransformStream{constructor(e){let t=new ec,n=new Map;super({transform(r,i){r.type===`part-start`&&r.path.length===0&&n.set(t.up(),e.up());let[a,...o]=r.path;if(a===void 0){i.enqueue(r);return}let s=n.get(a);if(s===void 0)throw Error(`Path not found`);i.enqueue(E(E({},r),{},{path:[s,...o]}))}})}},rc=e=>{let t=0,[n,r]=Gs(n=>e({get desiredSize(){return n.desiredSize},enqueue(e){n.enqueue(e),t++},close(){n.close()},error(e){n.error(e)}}));return[n,r,()=>t]},ic=class e{constructor(e,t={}){var n;S(this,`_state`,void 0),S(this,`_parentId`,void 0),this._state=e||{strict:(n=t.strict)==null||n,merger:Js(),contentCounter:new ec,openInputs:new Set,lastToolCallFinish:Promise.resolve()}}get __internal_isClosed(){return this._state.merger.isSealed()||this._state.merger.isCancelled()||this._state.merger.isErrored()}get __internal_isCancelled(){return this._state.merger.isCancelled()}__internal_getReadable(){return this._state.merger.readable}__internal_endOpenInputs(){this._state.append=void 0;for(let e of this._state.openInputs)e();this._state.openInputs.clear()}__internal_subscribeToClose(e){this._state.closeSubscriber=e}_addTransformedStream(e,t,n){if(e.locked)throw TypeError(`Cannot merge a stream that is already locked to a reader.`);let r=e.pipeTo(t.writable).catch(function(){var e=w(function*(e){throw yield t.writable.abort(e).catch(()=>void 0),e});return function(t){return e.apply(this,arguments)}}());return this._state.merger.addStream(t.readable,r,n),r}_trackOpenInput(e,t){let{openInputs:n}=this._state;n.add(t);let r=()=>n.delete(t);e.then(r,r)}_addPart(e,t,n,r,i){this._state.append&&(this._state.append.controller.close(),this._state.append=void 0),this.enqueue({type:`part-start`,part:e,path:[]});let a=this._addTransformedStream(t,new tc(this._state.contentCounter.value),{orderedFinish:i,written:n});r&&this._trackOpenInput(a,r)}merge(e){this._addTransformedStream(e,new nc(this._state.contentCounter))}appendText(e){var t;(((t=this._state.append)==null?void 0:t.kind)!==`text`||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:`text`,parentId:this._parentId,controller:this.addTextPart()}),this._state.append.controller.append(e)}appendReasoning(e,t){var n;(t!==void 0||((n=this._state.append)==null?void 0:n.kind)!==`reasoning`||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:`reasoning`,parentId:this._parentId,controller:this.addReasoningPart(t)}),(t===void 0||e.length!==0)&&this._state.append.controller.append(e)}addTextPart(e){let[t,n,r]=rc(e=>new Qs(e,{strict:this._state.strict}));return this._addPart(this._withParentIdOption(E({type:`text`},e)),t,r,()=>n.__internal_close()),n}addReasoningPart(e){let[t,n,r]=rc(e=>new Qs(e,{strict:this._state.strict}));return this._addPart(this._withParentIdOption(E({type:`reasoning`},e)),t,r,()=>n.__internal_close()),n}addToolCallPart(e){var t;let n=typeof e==`string`?{toolName:e}:e,r=n.toolName,i=(t=n.toolCallId)==null?Vo():t,a=qs(),o=Promise.resolve(),[s,c,l]=rc(e=>new $s(e,{strict:this._state.strict,onClose:()=>{o=this._state.lastToolCallFinish,this._state.lastToolCallFinish=a.promise}}));return this._addPart(E({type:`tool-call`,toolName:r,toolCallId:i},this._parentId&&{parentId:this._parentId}),s,l,()=>c.__internal_truncate(),{previous:()=>o,delivered:a}),n.argsText!==void 0&&(c.argsText.append(n.argsText),c.argsText.close()),n.args!==void 0&&(c.argsText.append(JSON.stringify(n.args)),c.argsText.close()),n.response!==void 0&&c.setResponse(n.response),c}_finishedPartStream(){return new ReadableStream({start(e){e.enqueue({type:`part-finish`,path:[]}),e.close()}})}_withParentIdOption(e){return this._parentId?E(E({},e),{},{parentId:this._parentId}):e}appendSource(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream(),()=>1)}appendFile(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream(),()=>1)}appendData(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream(),()=>1)}enqueue(e){this._state.merger.enqueue(e),e.type===`part-start`&&e.path.length===0&&this._state.contentCounter.up()}withParentId(t){let n=new e(this._state);return n._parentId=t,n}close(){var e,t,n;(e=this._state.append)==null||(e=e.controller)==null||e.close(),this._state.merger.seal(),(t=(n=this._state).closeSubscriber)==null||t.call(n)}};function ac(e,t={}){let n=new ic(void 0,t);return(function(){var t=w(function*(){try{yield e(n)}catch(e){n.__internal_isClosed?n.__internal_isCancelled||console.error(e):(n.enqueue({type:`error`,path:[],error:String(e)}),n.__internal_endOpenInputs())}finally{n.__internal_isClosed||n.close()}});return function(){return t.apply(this,arguments)}})()(),n.__internal_getReadable()}function oc(e={}){let{resolve:t,promise:n}=qs(),r;return[ac(e=>(r=e,r.__internal_subscribeToClose(t),n),e),r]}var sc=class extends TransformStream{constructor(){let e=[];super({transform(t,n){if(t.type===`part-start`){if(t.path.length!==0){n.error(Error(`Nested parts are not supported`));return}e.push(t.part),n.enqueue(t)}else if(t.type===`text-delta`||t.type===`result`||t.type===`part-finish`||t.type===`tool-call-args-text-finish`){if(t.path.length!==1){n.error(Error(`${t.type} chunks must have a path of length 1`));return}let r=t.path[0];if(r<0||r>=e.length){n.error(Error(`Invalid path index: ${r}`));return}let i=e[r];n.enqueue(E(E({},t),{},{meta:i}))}else n.enqueue(t)}})}};function cc(e,t){let n=e;for(let e of t){if(n==null||!Object.hasOwn(n,e))return;n=n[e]}return n}var lc=class{get isDisposed(){return this.disposed}constructor(e,t,n){S(this,`resolve`,void 0),S(this,`reject`,void 0),S(this,`disposed`,!1),S(this,`fieldPath`,void 0),this.resolve=e,this.reject=t,this.fieldPath=n}update(e){if(!this.disposed)try{if(Qo(e,this.fieldPath)===`complete`){let t=cc(e,this.fieldPath);t!==void 0&&(this.resolve(t),this.dispose())}}catch(e){this.reject(e),this.dispose()}}end(e){if(!this.disposed)try{let t=cc(e,this.fieldPath);this.resolve(t)}catch(e){this.reject(e)}finally{this.dispose()}}error(e){this.disposed||(this.reject(e),this.dispose())}dispose(){this.disposed=!0}},uc=class{get isDisposed(){return this.disposed}constructor(e,t){S(this,`controller`,void 0),S(this,`disposed`,!1),S(this,`fieldPath`,void 0),this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=cc(e,this.fieldPath);t!==void 0&&this.controller.enqueue(t),Qo(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}error(e){this.disposed||(this.controller.error(e),this.dispose())}dispose(){this.disposed=!0}},dc=class{get isDisposed(){return this.disposed}constructor(e,t){S(this,`controller`,void 0),S(this,`disposed`,!1),S(this,`fieldPath`,void 0),S(this,`lastValue`,void 0),this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let n=cc(e,this.fieldPath);if(n!==void 0&&typeof n==`string`){var t;let e=n.substring(((t=this.lastValue)==null?void 0:t.length)||0);this.lastValue=n,this.controller.enqueue(e)}Qo(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}error(e){this.disposed||(this.controller.error(e),this.dispose())}dispose(){this.disposed=!0}},fc=class{get isDisposed(){return this.disposed}constructor(e,t){S(this,`controller`,void 0),S(this,`disposed`,!1),S(this,`fieldPath`,void 0),S(this,`nextIndex`,0),this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=cc(e,this.fieldPath);if(!Array.isArray(t))return;for(;this.nextIndex<t.length&&Qo(e,[...this.fieldPath,this.nextIndex])===`complete`;this.nextIndex++)this.controller.enqueue(t[this.nextIndex]);Qo(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}error(e){this.disposed||(this.controller.error(e),this.dispose())}dispose(){this.disposed=!0}},pc=class{constructor(e){S(this,`argTextDeltas`,void 0),S(this,`handles`,new Set),S(this,`accumulatedText`,``),S(this,`parser`,void 0),S(this,`args`,void 0),S(this,`finished`,!1),S(this,`failure`,void 0),this.argTextDeltas=e,this.processStream()}processStream(){var e=this;return w(function*(){try{let t=e.argTextDeltas.getReader();for(;;){let{value:n,done:r}=yield t.read();if(r)break;e.accumulatedText+=n,e.handles.size!==0&&e.parseCurrentArgs(n)&&e.updateHandles()}}catch(t){e.failure={reason:t}}finally{e.finished=!0;for(let t of e.handles)e.settleHandle(t);e.handles.clear()}})()}settleHandle(e){this.failure?e.error(this.failure.reason):e.end(this.args)}parseCurrentArgs(e){var t;if(((t=this.parser)==null?void 0:t.currentTextLength)===this.accumulatedText.length)return!1;let n=this.args;return this.parser=this.parser&&e!==void 0&&this.parser.currentTextLength+e.length===this.accumulatedText.length?this.parser.append(e):us.from(this.accumulatedText,this.args),this.args=this.parser.currentArgs,this.args!==n}updateHandles(){for(let e of this.handles)e.update(this.args),e.isDisposed&&this.handles.delete(e)}activateHandle(e){this.parseCurrentArgs(),e.update(this.args),e.isDisposed||(this.finished?this.settleHandle(e):this.handles.add(e))}get(...e){return new Promise((t,n)=>{let r=new lc(t,n,e);this.activateHandle(r)})}streamValues(...e){let t=e,n;return Is(new ReadableStream({start:e=>{n=new uc(e,t),this.activateHandle(n)},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}streamText(...e){let t=e,n;return Is(new ReadableStream({start:e=>{n=new dc(e,t),this.activateHandle(n)},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}forEach(...e){let t=e,n;return Is(new ReadableStream({start:e=>{n=new fc(e,t),this.activateHandle(n)},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}},mc=class{constructor(e){S(this,`promise`,void 0),this.promise=e}get(){return this.promise}},hc=class{constructor(){var e=this;S(this,`args`,void 0),S(this,`response`,void 0),S(this,`writable`,void 0),S(this,`resolve`,void 0),S(this,`argsText`,``),S(this,`result`,{get:function(){var t=w(function*(){return(yield e.response.get()).result});return function(){return t.apply(this,arguments)}}()});let t=new TransformStream;this.writable=t.writable,this.args=new pc(t.readable);let{promise:n,resolve:r}=qs();this.resolve=r,this.response=new mc(n)}appendArgsTextDelta(e){var t=this;return w(function*(){let n=t.writable.getWriter();try{yield n.write(e)}catch(e){console.warn(e)}finally{n.releaseLock()}t.argsText+=e})()}finishArgsText(){var e=this;return w(function*(){let t=e.writable.getWriter();try{yield t.close()}catch(e){console.warn(e)}finally{t.releaseLock()}})()}setResponse(e){this.resolve(e)}},gc=Symbol.for(`assistant-stream.tool-execution-id`),_c=(e,t,n,r,i)=>{try{let a=t==null?void 0:t(n,r,i);Promise.resolve(a).catch(t=>{console.error(`[assistant-stream] ${e} callback threw an error`,t)})}catch(t){console.error(`[assistant-stream] ${e} callback threw an error`,t)}},vc=e=>e.join(`,`),yc=(e,t)=>{let n=E({},e);return Object.defineProperty(n,gc,{value:t,enumerable:!0}),n},bc=class extends Us{constructor(e){let t=e,n=new Map,r=new Map,i=new Set,a=new Map,o=0;super(e=>{let s=new TransformStream({transform(e,s){return w(function*(){let c=a.get(vc(e.path));switch((e.type!==`part-finish`||e.meta.type!==`tool-call`)&&s.enqueue(c?yc(e,c):e),e.type){case`part-start`:{let n=o;if(o+=1,e.part.type===`tool-call`){let i=new hc,o=Symbol();a.set(String(n),o),r.set(o,i);let s=t.streamCall({reader:i,toolCallId:e.part.toolCallId,toolName:e.part.toolName,executionId:o});s&&Promise.resolve(s).catch(e=>{console.error(`[assistant-stream] streamCall callback threw an error`,e)})}break}case`text-delta`:if(e.meta.type===`tool-call`){let t=a.get(vc(e.path)),n=t?r.get(t):void 0;if(!n)throw Error(`No controller found for tool call`);yield n.appendArgsTextDelta(e.textDelta)}break;case`result`:{if(e.meta.type!==`tool-call`)break;let t=a.get(vc(e.path)),n=t?r.get(t):void 0;if(!n)throw Error(`No controller found for tool call`);if(i.add(t),e.isPreliminary)break;n.setResponse(new Hs({result:e.result,artifact:e.artifact,isError:e.isError,modelContent:e.modelContent,messages:e.messages}));break}case`tool-call-args-text-finish`:{if(e.meta.type!==`tool-call`)break;let{toolCallId:o,toolName:c}=e.meta,l=a.get(vc(e.path)),u=l?r.get(l):void 0;if(!u)throw Error(`No controller found for tool call`);if(yield u.finishArgsText(),i.has(l))break;let d=!1,f=Ks(()=>{let e;try{e=qo.default.parse(u.argsText)}catch(e){throw Error(`Function parameter parsing failed. ${JSON.stringify(e.message)}`)}let n=t.execute({toolCallId:o,toolName:c,args:e,executionId:l});return n!==void 0&&(d=!0,_c(`onExecutionStart`,t.onExecutionStart,o,c,l)),n},n=>{if(d&&_c(`onExecutionEnd`,t.onExecutionEnd,o,c,l),n===void 0)return;let r=new Hs({artifact:n.artifact,result:n.result,isError:n.isError,messages:n.messages,modelContent:n.modelContent});u.setResponse(r),Xs(s,yc(E({type:`result`,path:e.path},r),l))},n=>{d&&_c(`onExecutionEnd`,t.onExecutionEnd,o,c,l);let r=new Hs({result:String(n),isError:!0});u.setResponse(r),Xs(s,yc(E({type:`result`,path:e.path},r),l))});f&&n.set(l,f);break}case`part-finish`:{if(e.meta.type!==`tool-call`)break;let t=a.get(vc(e.path)),o=t?n.get(t):void 0,c=()=>{t&&(n.delete(t),r.delete(t),i.delete(t),a.delete(vc(e.path)))};o?o.then(()=>{c(),Xs(s,e)}):(c(),s.enqueue(e))}}})()},flush(){return w(function*(){yield Promise.all(n.values())})()}});return e.pipeThrough(new sc).pipeThrough(s)})}},xc=[`reader`],Sc=Symbol.for(`assistant-stream.tool-execution-id`),Cc=Symbol(`assistant-stream.tool-aborted`),wc=e=>typeof e==`object`&&!!e&&`~standard`in e&&e[`~standard`].version===1,Tc=e=>typeof(e==null?void 0:e.then)==`function`,Ec=function(){var e=w(function*(e,t,n=!1){let r,i=new Promise(e=>{r=()=>{n?queueMicrotask(()=>queueMicrotask(()=>e(Cc))):e(Cc)},t.aborted?r():t.addEventListener(`abort`,r,{once:!0})});try{return yield Promise.race([e,i])}finally{t.removeEventListener(`abort`,r)}});return function(t,n){return e.apply(this,arguments)}}(),Dc=()=>new Hs({result:`Tool execution was cancelled.`,isError:!0});function Oc(e,t,n,r){let i=e==null?void 0:e[n.toolName];if(i!=null&&i.execute)return function(){var e=w(function*(e){if(t.aborted)return Dc();let a=e,o=n.args;if(wc(i.parameters)){var s;let e=i.parameters[`~standard`].validate(n.args),r=Tc(e)?yield Ec(e,t):e;if(r===Cc)return Dc();r.issues?a=(s=i.experimental_onSchemaValidationError)==null?(()=>{throw Error(`Function parameter validation failed. ${JSON.stringify(r.issues)}`)}):s:o=r.value}if(t.aborted)return Dc();let c=yield Ec(w(function*(){let e={toolCallId:n.toolCallId,abortSignal:t,human:e=>r(n.toolCallId,e,n.executionId),[Sc]:n.executionId},s=yield a(o,e),c=Hs.toResponse(s);if(i.toModelOutput&&!c.isError&&c.modelContent===void 0)try{let e=yield i.toModelOutput({toolCallId:n.toolCallId,input:o,output:c.result});return new Hs({result:c.result,artifact:c.artifact,isError:c.isError,messages:c.messages,modelContent:e})}catch(e){console.warn(`[assistant-stream] tool "${n.toolName}" toModelOutput threw; falling back to default projection.`,e)}return c})(),t,!0);return c===Cc?Dc():c});return function(t){return e.apply(this,arguments)}}()(i.execute)}function kc(e,t,n,r,i){var a,o;let s={toolCallId:r.toolCallId,abortSignal:t,human:e=>i(r.toolCallId,e,r.executionId),[Sc]:r.executionId};return e==null||(a=e[r.toolName])==null||(o=a.streamCall)==null?void 0:o.call(a,n,s)}function Ac(e,t,n,r){let i=typeof e==`function`?e:()=>e,a=typeof t==`function`?t:()=>t,o=r,s=n;return new bc({execute:e=>Oc(i(),a(),e,s),streamCall:e=>{let{reader:t}=e,n=W(e,xc);return kc(i(),a(),t,n,s)},onExecutionStart:o==null?void 0:o.onExecutionStart,onExecutionEnd:o==null?void 0:o.onExecutionEnd})}var jc=Symbol.for(`assistant-ui.message-not-sent`),Mc=class extends Error{constructor(e=`The message was not sent.`){super(e),S(this,jc,!0),this.name=`MessageNotSentError`}},Nc=e=>typeof e==`object`&&!!e&&jc in e,Pc=`application/octet-stream`;function Fc(e,t=Pc){let n=e.match(/^data:([^;,]*)(?:;[^;,]+)*;base64,(.*)$/i);return n?{mimeType:n[1]?n[1].toLowerCase():t,data:n[2].replace(/%([\da-f]{2})/gi,(e,t)=>String.fromCharCode(Number.parseInt(t,16)))}:null}var Ic={entries:32,payloadLength:16384,logLength:65536},Lc=64,Rc=e=>{let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},zc=(e,t,n)=>{if(e===null)return!0;switch(typeof e){case`string`:case`boolean`:return!0;case`number`:return Number.isFinite(e);case`object`:break;default:return!1}if(n>Lc||t.has(e))return!1;t.add(e);let r=Array.isArray(e)?e.every(e=>zc(e,t,n+1)):Rc(e)&&Object.values(e).every(e=>zc(e,t,n+1));return t.delete(e),r},Bc=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Vc=e=>e===`action`||e===`human-response`;function Hc(e,t=Date.now()){let{type:n,payload:r}=e;if(!Vc(n))throw Error(`Unknown tool interaction type: ${String(n)}`);if(!zc(r,new Set,0))throw Error(`A tool interaction payload must be plain JSON.`);if(n===`action`&&!Bc(r))throw Error(`An action interaction payload must be a JSON object.`);let i=JSON.stringify(r);if(i.length>Ic.payloadLength)throw Error(`A tool interaction payload is limited to ${Ic.payloadLength} characters of JSON.`);return{type:n,occurredAt:t,payload:JSON.parse(i)}}function Uc(e,t){var n,r;let i=[...(n=e==null?void 0:e.entries)==null?[]:n,t],a=(r=e==null?void 0:e.omitted)==null?0:r;for(;i.length>1&&(i.length>Ic.entries||JSON.stringify(i).length>Ic.logLength);)i.shift(),a+=1;return a>0?{entries:i,omitted:a}:{entries:i}}var Wc=e=>{if(!Bc(e))return;let{type:t,occurredAt:n,payload:r}=e;if(Vc(t)&&typeof n==`number`&&Number.isFinite(n)&&zc(r,new Set,0))return t===`action`?Bc(r)?{type:t,occurredAt:n,payload:r}:void 0:{type:t,occurredAt:n,payload:r}};function Gc(e){if(!Bc(e))return;let{entries:t,omitted:n}=e,r=Array.isArray(t)?t.flatMap(e=>{let t=Wc(e);return t?[t]:[]}):[],i=typeof n==`number`&&Number.isInteger(n)&&n>0?n:0;for(;r.length>1&&(r.length>Ic.entries||JSON.stringify(r).length>Ic.logLength);)r.shift(),i+=1;if(r.length!==0||i!==0)return i>0?{entries:r,omitted:i}:{entries:r}}var Kc=[`image`],qc=[`parentId`,`messages`,`unstable_interactions`],Jc=(e,t,n)=>{if(e!=null&&e.startsWith(`data-`))return E({type:`data`,name:e.substring(5),data:t},typeof n==`string`&&{id:n})},Yc=(e,t,n)=>{let{role:r,id:i,createdAt:a,attachments:o,status:s,metadata:c}=e,l={id:i==null?t:i,createdAt:a==null?new Date:a},u=typeof e.content==`string`?[{type:`text`,text:e.content}]:e.content,d=e=>{var t;let{image:n}=e,r=W(e,Kc);return typeof n==`string`?(t=Fc(n))!=null&&t.mimeType.startsWith(`image/`)||/^(https:\/\/|blob:)/i.test(n)?E(E({},r),{},{image:n}):(console.warn(`Invalid image data format detected`),null):null};if(r!==`user`&&o!=null&&o.length)throw Error(`attachments are only supported for user messages`);if(r!==`assistant`&&s)throw Error(`status is only supported for assistant messages`);if(r!==`assistant`&&c!=null&&c.steps)throw Error(`metadata.steps is only supported for assistant messages`);switch(r){case`assistant`:var f,p,m,h,_;return E(E({},l),{},{role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:var n;return(n=e.text)!=null&&n.trim()?e:null;case`reasoning`:var r,i;return!((r=e.text)!=null&&r.trim())&&!((i=e.unstable_summary)!=null&&i.trim())?null:e.text==null?E(E({},e),{},{text:``}):e;case`file`:case`source`:return e;case`image`:return d(e);case`data`:return e;case`generative-ui`:return e;case`tool-call`:{var a,o,s,c;let{parentId:t,messages:n,unstable_interactions:r}=e,i=W(e,qc),l=Gc(r),u=E(E(E(E({},i),{},{toolCallId:e.toolCallId||`tool-${g()}`},t!==void 0&&{parentId:t}),n!==void 0&&{messages:n}),l!==void 0&&{unstable_interactions:l});return e.args?E(E({},u),{},{args:e.args,argsText:(a=e.argsText)==null?JSON.stringify(e.args):a}):E(E({},u),{},{args:(o=Xo((s=e.argsText)==null?``:s))==null?{}:o,argsText:(c=e.argsText)==null?``:c})}case`audio`:throw Error(`Unsupported assistant message part type: ${t}`);default:{let n=t,r=Jc(n,e.data,e.id);if(r)return r;throw Error(`Unsupported assistant message part type: ${n}`)}}}).filter(e=>!!e),status:s==null?n:s,metadata:E(E(E(E(E({},(c==null?void 0:c.runId)!==void 0&&{runId:c.runId}),{},{unstable_state:(f=c==null?void 0:c.unstable_state)==null?null:f,unstable_annotations:(p=c==null?void 0:c.unstable_annotations)==null?[]:p,unstable_data:(m=c==null?void 0:c.unstable_data)==null?[]:m,custom:(h=c==null?void 0:c.custom)==null?{}:h,steps:(_=c==null?void 0:c.steps)==null?[]:_},(c==null?void 0:c.timing)&&{timing:c.timing}),(c==null?void 0:c.submittedFeedback)&&{submittedFeedback:c.submittedFeedback}),(c==null?void 0:c.isOptimistic)&&{isOptimistic:!0}),(c==null?void 0:c.modality)&&{modality:c.modality})});case`user`:var v;return E(E({},l),{},{role:r,content:u.filter(e=>e.type!==`text`||e.text!=null).map(e=>{let t=e.type;switch(t){case`text`:case`image`:case`audio`:case`file`:case`data`:return e;case`reasoning`:case`source`:case`generative-ui`:case`tool-call`:throw Error(`Unsupported user message part type: ${t}`);default:{let n=t,r=Jc(n,e.data,e.id);if(r)return r;throw Error(`Unsupported user message part type: ${n}`)}}}),attachments:(o==null?[]:o).map(e=>{var t;return E(E({},e),{},{content:((t=e.content)==null?[]:t).map(e=>{var t;return(t=Jc(e.type,e.data,`id`in e?e.id:void 0))==null?e:t})})}),metadata:E(E({custom:(v=c==null?void 0:c.custom)==null?{}:v},(c==null?void 0:c.isOptimistic)&&{isOptimistic:!0}),(c==null?void 0:c.modality)&&{modality:c.modality})});case`system`:var y;if(u.length!==1||u[0].type!==`text`)throw Error(`System messages must have exactly one text message part.`);return E(E({},l),{},{role:r,content:u,metadata:{custom:(y=c==null?void 0:c.custom)==null?{}:y}});default:throw Error(`Unknown message role: ${r}`)}},Xc=Symbol(`innerMessage`),Zc=Symbol(`innerMessages`),Qc=[],$c=(e,t)=>{Xc in e||(e[Xc]=t)},el=e=>{let t=`messages`in e&&!(`type`in e&&e.type===`tool-call`)?e.messages:e,n=t[Zc]||t[Xc];return n?Array.isArray(n)?n:(t[Zc]=[n],t[Zc]):Qc},tl=`__external_store_fallback_`,nl=(e,t)=>{let n=new Set,r=[];for(let i=e.length-1;i>=0;i--){let a=e[i];n.has(a.id)?t(a.id):(n.add(a.id),r.push(a))}return r.length===e.length?e:r.reverse()},rl=Object.freeze({type:`complete`}),il=Object.freeze({type:`running`}),al=Object.freeze({cancelled:Object.freeze({type:`incomplete`,reason:`cancelled`}),length:Object.freeze({type:`incomplete`,reason:`length`}),"content-filter":Object.freeze({type:`incomplete`,reason:`content-filter`}),other:Object.freeze({type:`incomplete`,reason:`other`}),error:Object.freeze({type:`incomplete`,reason:`error`})}),ol=e=>{let t=e.status;if(!t||typeof t!=`object`)return;let{type:n}=t;if(n===`running`)return il;if(n===`complete`)return rl;if(n!==`incomplete`)return;let{reason:r}=t;return al[r===`cancelled`||r===`length`||r===`content-filter`||r===`other`||r===`error`?r:`other`]},sl=e=>e.interrupt!=null||e.approval!=null&&e.approval.approved===void 0&&e.approval.resolution===void 0,cl=(e,t,n)=>{if(e.role!==`assistant`)return rl;if(n.type===`tool-call`)return n.result===void 0||n.isPreliminary||sl(n)?e.status:rl;if(e.status.type===`running`){let e=ol(n);if(e)return e}let r=t===Math.max(0,e.content.length-1);return e.status.type===`requires-action`?rl:r?e.status:rl},ll=e=>e.type===`tool-call`&&e.result===void 0,ul=e=>{var t;if(e.type!==`tool-call`||e.result!==void 0)return!1;let n=(t=e.messages)==null?void 0:t.at(-1);return(n==null?void 0:n.role)===`assistant`&&n.status.type===`running`},dl=e=>e.type===`tool-call`&&sl(e),fl=Symbol(`autoStatus`),pl=Object.freeze(Object.assign({type:`running`},{[fl]:!0})),ml=Object.freeze(Object.assign({type:`complete`,reason:`unknown`},{[fl]:!0})),hl=Object.freeze(Object.assign({type:`incomplete`,reason:`cancelled`},{[fl]:!0})),gl=Object.freeze(Object.assign({type:`requires-action`,reason:`tool-calls`},{[fl]:!0})),_l=Object.freeze(Object.assign({type:`requires-action`,reason:`interrupt`},{[fl]:!0})),vl=e=>e[fl]===!0,yl=(e,t,n,r,i,a,o)=>e&&i!=null?Object.assign({type:`incomplete`,reason:`error`,error:i},{[fl]:!0}):e&&t?pl:n?_l:o&&!a?pl:r?gl:a?hl:ml,bl=e=>yl(!1,!1,typeof e!=`string`&&e.some(dl),typeof e!=`string`&&e.some(ll)),xl=(e,t,n)=>yl(t,n,typeof e!=`string`&&e.some(dl),typeof e!=`string`&&e.some(ll),void 0,void 0,typeof e!=`string`&&e.some(ul)),Sl={fromArray:e=>{let t=e.map(e=>{var t;return Yc(e,(t=e.id)==null?g():t,bl(e.content))});return{messages:t.map((e,n)=>({parentId:n>0?t[n-1].id:null,message:e}))}},fromBranchableArray:(e,t)=>E(E({},(t==null?void 0:t.headId)===void 0?void 0:{headId:t.headId}),{},{messages:e.map(({message:e,parentId:t})=>{if(!e.id)throw Error(`ExportedMessageRepository.fromBranchableArray: Each message must have an 'id' field set.`);return{parentId:t,message:Yc(e,e.id,bl(e.content))}})})},Cl=e=>{let t=e;for(;t.next;)t=t.next;return`current`in t?t:null},wl=(e,t)=>{let n=new Set(e.map(e=>e.message.id)),r=new Set,i=new Map,a=[];for(let o of e){let{parentId:e}=o;if(e!==null&&n.has(e)&&!r.has(e)&&!t(e)){let t=i.get(e);t?t.push(o):i.set(e,[o])}else for(let e=a.push(o)-1;e<a.length;e++){let{id:t}=a[e].message;if(r.has(t))continue;r.add(t);let n=i.get(t);n&&(i.delete(t),a.push(...n))}}for(let e of i.values())a.push(...e);return a},Tl=class{constructor(e){S(this,`_value`,null),S(this,`func`,void 0),this.func=e}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},El=class{constructor(){S(this,`messages`,new Map),S(this,`head`,null),S(this,`root`,{children:[],next:null}),S(this,`_messages`,new Tl(()=>{var e,t;let n=Array(((e=(t=this.head)==null?void 0:t.level)==null?-1:e)+1);for(let e=this.head;e;e=e.prev)n[e.level]=e.current;return n}))}updateLevels(e,t){let n=[{message:e,level:t}];for(;n.length>0;){let e=n.pop();e.message.level=e.level;for(let t of e.message.children){let r=this.messages.get(t);r&&n.push({message:r,level:e.level+1})}}}selectPathTo(e){var t;for(let n=e;n;n=n.prev)((t=n.prev)==null?this.root:t).next=n}performOp(e,t,n){var r;let i=(r=t.prev)==null?this.root:r,a=e==null?this.root:e;if(n!==`relink`||i!==a){if(n===`relink`){for(let n=e;n;n=n.prev)if(n.current.id===t.current.id)throw Error(`MessageRepository(performOp/relink): A message with the same id already exists in the parent tree. This error occurs if the same message id is found multiple times. This is likely an internal bug in assistant-ui.`)}if(n!==`link`&&(i.children=i.children.filter(e=>e!==t.current.id),i.next===t)){let e=i.children.at(-1),t=e?this.messages.get(e):null;if(t===void 0)throw Error(`MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.`);i.next=t}if(n!==`cut`){a.children=[...a.children,t.current.id],t.prev=e,Cl(t)===this.head?this.selectPathTo(t):a.next===null&&(a.next=t,this.head===a&&(this.head=Cl(t)));let n=e?e.level+1:0;this.updateLevels(t,n)}}}get headId(){var e,t;return(e=(t=this.head)==null?void 0:t.current.id)==null?null:e}get canonicalHeadId(){var e,t;let n=this.head;for(;n!=null&&(e=n.current.metadata)!=null&&e.isOptimistic;)n=n.prev;return(t=n==null?void 0:n.current.id)==null?null:t}getMessages(e){var t;if(e===void 0||e===((t=this.head)==null?void 0:t.current.id))return this._messages.value;let n=this.messages.get(e);if(!n)throw Error(`MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.`);let r=Array(n.level+1);for(let e=n;e;e=e.prev)r[e.level]=e.current;return r}addOrUpdateMessage(e,t){let n=this.messages.get(t.id),r=e?this.messages.get(e):null;if(r===void 0)throw Error(`MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.`);if(n){this.performOp(r,n,`relink`),n.current=t,this._messages.dirty();return}let i={prev:r,current:t,next:null,children:[],level:r?r.level+1:0};this.messages.set(t.id,i),this.performOp(r,i,`link`),this.head===r&&(this.head=i,this.selectPathTo(i)),this._messages.dirty()}getMessage(e){var t,n;let r=this.messages.get(e);if(!r)throw Error(`MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.`);return{parentId:(t=(n=r.prev)==null?void 0:n.current.id)==null?null:t,message:r.current,index:r.level}}deleteMessage(e,t){let n=this.messages.get(e);if(!n)throw Error(`MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.`);let r=t===void 0?n.prev:t===null?null:this.messages.get(t);if(r===void 0)throw Error(`MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.`);for(let e=r;e;e=e.prev)if(e===n)throw Error(`MessageRepository(deleteMessage): Replacement is the deleted message or one of its descendants. This is likely an internal bug in assistant-ui.`);for(let e of n.children){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.`);this.performOp(r,t,`relink`)}this.performOp(null,n,`cut`),this.messages.delete(e),this.head===n&&(this.head=Cl(r==null?this.root:r)),this._messages.dirty()}hasChildren(e){var t,n;return((t=(n=this.messages.get(e))==null?void 0:n.children.length)==null?0:t)>0}getBranches(e){var t;let n=this.messages.get(e);if(!n)throw Error(`MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.`);let{children:r}=(t=n.prev)==null?this.root:t;return r}evictOffBranchOptimisticMessages(e,t){if(!e)return;let n=new Set;for(let e=t;e;e=e.prev)n.add(e.current.id);let r=[];for(let t=e;t;t=t.prev){var i;if(n.has(t.current.id))break;(i=t.current.metadata)!=null&&i.isOptimistic&&r.push(t.current.id)}for(let e of r)this.messages.has(e)&&this.deleteMessage(e)}switchToBranch(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.`);let n=this.head;this.selectPathTo(t),this.head=Cl(t),this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}setHead(e,t){if(e===null){this.clear();return}let n=this.messages.get(e);if(!n)throw Error(`MessageRepository(${t?`resetHead`:`import`}): Branch not found. This is likely an internal bug in assistant-ui.`);let r=this.head;if(t&&n.children.length>0){let e=[...n.children];for(;e.length>0;){let t=e.pop(),n=this.messages.get(t);if(n){for(let t of n.children)e.push(t);this.messages.delete(t)}}n.children=[],n.next=null}this.head=n,this.selectPathTo(n),this.evictOffBranchOptimisticMessages(r,this.head),this._messages.dirty()}resetHead(e){this.setHead(e,!0)}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){let e=[],t=[...this.root.children].reverse();for(;t.length>0;){var n,r,i;let a=this.messages.get(t.pop());if(!a)continue;for(let e=a.children.length-1;e>=0;e--)t.push(a.children[e]);if((n=a.current.metadata)!=null&&n.isOptimistic)continue;let o=a.prev;for(;o&&(r=o.current.metadata)!=null&&r.isOptimistic;)o=o.prev;e.push({message:a.current,parentId:(i=o==null?void 0:o.current.id)==null?null:i})}return{headId:this.exportedHeadId(),messages:e}}exportedHeadId(){var e,t;let n=this.head;for(;n!=null&&(e=n.current.metadata)!=null&&e.isOptimistic;)n=n.prev;if(n===this.head)return(t=n==null?void 0:n.current.id)==null?null:t;for(;;){var r,i;let e=this.exportedChild((r=n)==null?this.root:r);if(!e)return(i=n==null?void 0:n.current.id)==null?null:i;n=e}}exportedChild(e){let t=e.next;if(t){var n;if(!((n=t.current.metadata)!=null&&n.isOptimistic))return t;let e=this.exportedChild(t);if(e)return e}let r=t?e.children.indexOf(t.current.id):e.children.length,i=[...e.children.slice(0,r).reverse(),...e.children.slice(r+1).reverse()];for(let e of i){var a;let t=this.messages.get(e);if(!t)continue;if(!((a=t.current.metadata)!=null&&a.isOptimistic))return t;let n=this.exportedChild(t);if(n)return n}return null}import({headId:e,messages:t}){var n,r;let i=wl(t,e=>this.messages.has(e));for(let{message:e,parentId:t}of i)this.addOrUpdateMessage(t,e);let a=(n=e==null?(r=i.at(-1))==null?void 0:r.message.id:e)==null?null:n;this.setHead(a,!1)}},Dl=Object.freeze([]),Ol=new WeakMap,kl=e=>{var t;let n=e.__internal_setDispatchTransform;n&&((t=Ol.get(n))==null||t.bindNext())},Al=e=>{var t;let n=e.__internal_setDispatchTransform;return n?(t=Ol.get(n))==null?void 0:t.getCurrent():void 0},jl=Hr(()=>{let e=K(4),[t,n]=_n(Ml),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(e,t)=>(n(n=>{var r;let i=H(n.renderers);return i[e]=[...(r=i[e])==null?[]:r,t],E(E({},n),{},{renderers:i})}),()=>{n(n=>{var r,i;let a=H(n.renderers),o=(r=(i=a[e])==null?void 0:i.filter(e=>e!==t))==null?[]:r;return o.length>0?a[e]=o:delete a[e],E(E({},n),{},{renderers:a})})}),e[0]=r):r=e[0];let i=r,a;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>(n(t=>E(E({},t),{},{fallbacks:[...t.fallbacks,e]})),()=>{n(t=>E(E({},t),{},{fallbacks:t.fallbacks.filter(t=>t!==e)}))}),e[1]=a):a=e[1];let o=a,s;return e[2]===t?s=e[3]:(s={getState:()=>t,setDataUI:i,setFallbackDataUI:o},e[2]=t,e[3]=s),s});function Ml(){return{renderers:H(),fallbacks:[]}}var Nl=()=>()=>{},Pl=()=>wn(Nl,Il,Ll),Fl=(e,t)=>{(Pl()?G:Sn)(e,t)};function Il(){return!1}function Ll(){return typeof document>`u`}var Rl=(e,t)=>e.length===t.length&&e.every((e,n)=>Object.is(e,t[n])),zl=(e,t)=>{let[n]=_n(()=>({pending:void 0}));G(()=>{let r=n.pending;n.pending=void 0;let i;if(r!==void 0&&Rl(r.deps,t))i=r;else{var a;r==null||(a=r.cleanup)==null||a.call(r),i={deps:t,cleanup:e()}}return()=>{n.pending=i,queueMicrotask(()=>{var e;n.pending===i&&(n.pending=void 0,(e=i.cleanup)==null||e.call(i))})}},t)},Bl=[],Vl={modelName:void 0,toolNames:Bl},Hl=(e,t)=>e===t||ma(e,t),Ul=(e,t)=>{var n;let r=e.getModelContext(),i=(n=r.config)==null?void 0:n.modelName,a=r.tools?Object.keys(r.tools).sort():Bl,o=a.length?a:Bl;return i===t.modelName&&Hl(o,t.toolNames)?t:{modelName:i,toolNames:o}},Wl=Hr((e={})=>{let t=yn(e);En(()=>{t.current=e});let n=bn(()=>new Ro(()=>t.current),[]),{maxSystemLength:r,mergeSystem:i}=e,a=yn({maxSystemLength:r,mergeSystem:i});G(()=>{let e=a.current;(e.maxSystemLength!==r||e.mergeSystem!==i)&&(a.current={maxSystemLength:r,mergeSystem:i},n.notifySubscribers())},[n,r,i]);let[o,s]=_n(()=>Ul(n,Vl));return G(()=>(s(e=>Ul(n,e)),n.subscribe(()=>{s(e=>Ul(n,e))})),[n]),{getState:()=>Ul(n,o),getModelContext:()=>n.getModelContext(),subscribe:e=>n.subscribe(e),register:e=>n.registerModelContextProvider(e)}}),Gl=(e,t)=>{var n,r;if(((n=t.status)==null?void 0:n.type)!==`running`&&((r=t.status)==null?void 0:r.type)!==`requires-action`){let n=e.complete;return typeof n==`function`?n({args:t.args,result:t.result}):n==null?null:n}let i=e.running;return typeof i==`function`?i({args:t.args}):i==null?null:i},Kl=e=>e.display===void 0?e.type===`human`:e.display===`standalone`,ql=e=>function(t){return Gl(e,t)},Jl=[`display`,`render`,`renderText`],Yl=e=>{let t=K(16),{toolkit:n,mcpApp:r}=e,i;t[0]===r?i=t[1]:(i=r?[Ur(`mcpApp`,r)]:[],t[0]=r,t[1]=i);let a=Xr(i)[0],[o,s]=_n(Zl),c;t[2]!==a||t[3]!==o?(c={toolUIs:o,mcpApp:a},t[2]=a,t[3]=o,t[4]=c):c=t[4];let l=c,u=Mi(),d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(e,t,n)=>{var r;let i={render:t,renderText:n==null?void 0:n.renderText,standalone:(r=n==null?void 0:n.standalone)!=null&&r};return s(t=>{var n;let r=H(t);return r[e]=[...(n=r[e])==null?[]:n,i],r}),()=>{s(t=>{var n,r;let a=(n=(r=t[e])==null?void 0:r.filter(e=>e!==i))==null?[]:n,o=H(t);return a.length>0?(o[e]=a,o):(delete o[e],o)})}},t[5]=d):d=t[5];let f=d,p,m;t[6]===n?(p=t[7],m=t[8]):(p=()=>{if(!n)return;let e=[];for(let[t,r]of Object.entries(n)){let n=`render`in r?r.render:void 0,i=`renderText`in r?r.renderText:void 0,a=n==null?i?ql(i):void 0:n;a&&e.push(f(t,a,{standalone:Kl(r),renderText:i}))}return()=>Oo(e)},m=[n,f],t[6]=n,t[7]=p,t[8]=m),G(p,m);let h;t[9]!==u||t[10]!==n?(h=()=>{if(!n)return;let e=Object.entries(n).reduce(Ql,H());return u.current.modelContext().register({getModelContext:()=>({tools:e})})},t[9]=u,t[10]=n,t[11]=h):h=t[11];let g;t[12]===n?g=t[13]:(g=[n],t[12]=n,t[13]=g),Li(`modelContext`,h,g);let _;return t[14]===l?_=t[15]:(_={getState:()=>l,setToolUI:f},t[14]=l,t[15]=_),_},Xl=Hr(Yl);gi(Yl,(e,t)=>{!e.modelContext&&t.modelContext.source===null&&(e.modelContext=Wl())});function Zl(){return H()}function Ql(e,t){let[n,r]=t;if(r.type===`mcp`)return e;let{display:i,render:a,renderText:o}=r;return e[n]=W(r,Jl),e}var $l=(e,t)=>(Xi(t!=null&&t.live?e.subscribe:void 0),wn(e.subscribe,e.getState,e.getServerSnapshot)),eu=Symbol.for(`assistant-ui.silent-runtime-action`),tu=e=>typeof e==`object`&&!!e&&eu in e,nu=(e,t)=>{let n=t();return n.catch(t=>{tu(t)||console.error(`[assistant-ui] ${e} failed:`,t)}),n},ru=Hr(e=>{let t=K(9),{runtime:n}=e,r=$l(n),i;t[0]===r?i=t[1]:(i=()=>r,t[0]=r,t[1]=i);let a,o;t[2]===n?(a=t[3],o=t[4]):(a=()=>nu(`attachment remove`,n.remove),o=()=>n,t[2]=n,t[3]=a,t[4]=o);let s;return t[5]!==i||t[6]!==a||t[7]!==o?(s={getState:i,remove:a,__internal_getRuntime:o},t[5]=i,t[6]=a,t[7]=o,t[8]=s):s=t[8],s}),iu=Hr(({item:e,onMove:t,onRemove:n})=>({getState:()=>e,steer:()=>t({lane:`steer`,insertAfter:null}),move:t,remove:n})),au=Hr(e=>{let t=K(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getAttachmentByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=ru({runtime:a}),t[3]=a,t[4]=o),Gr(o)}),ou=(e,t,n)=>{var r;return{text:e.text,role:e.role,attachments:t,runConfig:e.runConfig,isEditing:e.isEditing,canCancel:e.canCancel,canSend:e.canSend,attachmentAccept:e.attachmentAccept,isEmpty:e.isEmpty,type:(r=e.type)==null?`thread`:r,dictation:e.dictation,quote:e.quote,queue:n,submission:e.submission,inTransit:e.inTransit}},su=(e,t,n)=>{let r,i;return()=>{let a=e.getState();return a===t?n:(a!==r&&(r=a,i=ou(a,n.attachments,n.queue)),i)}},cu=Hr(e=>{var t;let n=K(56),{threadIdRef:r,messageIdRef:i,runtime:a,isSuggestion:o}=e,s;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={live:!0},n[0]=s):s=n[0];let c=$l(a,s),l=Ri(),u=yn(!1),d,f;n[1]!==l||n[2]!==i||n[3]!==a||n[4]!==r?(d=()=>{let e=[],t=a.unstable_on(`send`,e=>{let t=u.current;u.current=!1,l(`composer.send`,E(E({threadId:r.current},i&&{messageId:i.current}),{},{chars:e.chars,attachments:e.attachments},t?{suggestion:!0}:void 0))});e.push(t);let n=a.unstable_on(`attachmentAdd`,e=>{l(`composer.attachmentAdd`,E(E({threadId:r.current},i&&{messageId:i.current}),e.contentType?{contentType:e.contentType}:void 0))});return e.push(n),e.push(a.unstable_on(`attachmentAddError`,e=>{l(`composer.attachmentAddError`,E(E(E({threadId:r.current},i&&{messageId:i.current}),e.attachmentId&&{attachmentId:e.attachmentId}),{},{reason:e.reason,message:e.message},e.contentType?{contentType:e.contentType}:void 0))})),e.push(a.unstable_on(`textChange`,e=>{l(`composer.textChange`,E(E({threadId:r.current},i&&{messageId:i.current}),{},{text:e.text,origin:e.origin}))})),()=>Oo(e)},f=[a,l,r,i],n[1]=l,n[2]=i,n[3]=a,n[4]=r,n[5]=d,n[6]=f):(d=n[5],f=n[6]),G(d,f);let p;if(n[7]!==a||n[8]!==c.attachments){let e;n[10]===a?e=n[11]:(e=(e,t)=>Ur(e.id,au({runtime:a,index:t}),[a,t]),n[10]=a,n[11]=e),p=c.attachments.map(e),n[7]=a,n[8]=c.attachments,n[9]=p}else p=n[9];let m=oo(p),h=c.queue,g;if(n[12]!==h||n[13]!==a){let e;n[15]===a?e=n[16]:(e=e=>Ur(e.id,iu({item:e,onMove:t=>a.moveQueueItem(e.id,t),onRemove:()=>a.removeQueueItem(e.id)})),n[15]=a,n[16]=e),g=h.map(e),n[12]=h,n[13]=a,n[14]=g}else g=n[14];let _=oo(g),v;n[17]!==m.state||n[18]!==h||n[19]!==c?(v=ou(c,m.state,h),n[17]=m.state,n[18]=h,n[19]=c,n[20]=v):v=n[20];let y=v,b;n[21]!==a||n[22]!==c||n[23]!==y?(b=su(a,c,y),n[21]=a,n[22]=c,n[23]=y,n[24]=b):b=n[24];let x=b,S;n[25]!==o||n[26]!==a?(S=e=>{var t;let n=a.getState();u.current=n.canSend&&(t=o==null?void 0:o(n.text))!=null&&t,a.send(e)},n[25]=o,n[26]=a,n[27]=S):S=n[27];let C;n[28]!==l||n[29]!==i||n[30]!==a||n[31]!==r?(C=()=>{!i&&a.getState().canCancel&&l(`composer.cancel`,{threadId:r.current}),a.cancel()},n[28]=l,n[29]=i,n[30]=a,n[31]=r,n[32]=C):C=n[32];let w=(t=a.beginEdit)==null?lu:t,T;n[33]===m?T=n[34]:(T=e=>`id`in e?m.get({key:e.id}):m.get(e),n[33]=m,n[34]=T);let D;n[35]===_?D=n[36]:(D=e=>`id`in e?_.get({key:e.id}):_.get(e),n[35]=_,n[36]=D);let O;n[37]===a?O=n[38]:(O=()=>a,n[37]=a,n[38]=O);let k;return n[39]!==x||n[40]!==a.addAttachment||n[41]!==a.clearAttachments||n[42]!==a.reset||n[43]!==a.setQuote||n[44]!==a.setRole||n[45]!==a.setRunConfig||n[46]!==a.setText||n[47]!==a.startDictation||n[48]!==a.stopDictation||n[49]!==w||n[50]!==T||n[51]!==D||n[52]!==O||n[53]!==S||n[54]!==C?(k={getState:x,setText:a.setText,setRole:a.setRole,setRunConfig:a.setRunConfig,addAttachment:a.addAttachment,reset:a.reset,clearAttachments:a.clearAttachments,send:S,cancel:C,beginEdit:w,startDictation:a.startDictation,stopDictation:a.stopDictation,setQuote:a.setQuote,attachment:T,queueItem:D,__internal_getRuntime:O},n[39]=x,n[40]=a.addAttachment,n[41]=a.clearAttachments,n[42]=a.reset,n[43]=a.setQuote,n[44]=a.setRole,n[45]=a.setRunConfig,n[46]=a.setText,n[47]=a.startDictation,n[48]=a.stopDictation,n[49]=w,n[50]=T,n[51]=D,n[52]=O,n[53]=S,n[54]=C,n[55]=k):k=n[55],k});function lu(){throw Error(`beginEdit is not supported in this runtime`)}var uu=e=>({get current(){return e()}}),du=new WeakMap,fu=e=>{let t=du.get(e);if(t)return t;let n=new Map,r=e.map(e=>{var t;let r=e.type===`tool-call`?e.toolCallId:`id`in e?e.id:void 0;if(!r)return;let i=`${e.type}:${r}`;return n.set(i,((t=n.get(i))==null?0:t)+1),i}),i=e.map((e,t)=>{let i=r[t];return i&&n.get(i)===1?i:`${e.type}@${t}`});return du.set(e,i),i},pu=Hr(e=>{let t=K(17),{runtime:n}=e,r=$l(n),i;t[0]===r?i=t[1]:(i=()=>r,t[0]=r,t[1]=i);let a,o,s;t[2]===n?(a=t[3],o=t[4],s=t[5]):(a=e=>n.addToolResult(e),o=e=>n.resumeToolCall(e),s=e=>n.respondToToolApproval(e),t[2]=n,t[3]=a,t[4]=o,t[5]=s);let c;t[6]===n.unstable_recordInteraction?c=t[7]:(c=n.unstable_recordInteraction&&{unstable_recordInteraction:e=>n.unstable_recordInteraction(e)},t[6]=n.unstable_recordInteraction,t[7]=c);let l;t[8]===n?l=t[9]:(l=()=>n,t[8]=n,t[9]=l);let u;return t[10]!==i||t[11]!==a||t[12]!==o||t[13]!==s||t[14]!==c||t[15]!==l?(u=E(E({getState:i,addToolResult:a,resumeToolCall:o,respondToToolApproval:s},c),{},{__internal_getRuntime:l}),t[10]=i,t[11]=a,t[12]=o,t[13]=s,t[14]=c,t[15]=l,t[16]=u):u=t[16],u}),mu=Hr(e=>{let t=K(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getAttachmentByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=ru({runtime:a}),t[3]=a,t[4]=o),Gr(o)}),hu=Hr(e=>{let t=K(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getMessagePartByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=pu({runtime:a}),t[3]=a,t[4]=o),Gr(o)}),gu=Hr(e=>{let t=K(78),{runtime:n,threadIdRef:r,threadId:i,isLast:a}=e,o=$l(n),s=Ri(),[c,l]=_n(!1),[u,d]=_n(!1),f;t[0]===n?f=t[1]:(f=uu(()=>n.getState().id),t[0]=n,t[1]=f);let p=f,m=yn(o.status),h;t[2]!==s||t[3]!==n||t[4]!==i?(h=e=>{s(e,{threadId:i,messageId:n.getState().id})},t[2]=s,t[3]=n,t[4]=i,t[5]=h):h=t[5];let g=h,_,v;t[6]!==s||t[7]!==o.id||t[8]!==o.status||t[9]!==i?(_=()=>{let e=o.status,t=m.current;m.current=e,(e==null?void 0:e.type)===`incomplete`&&e.reason===`error`&&((t==null?void 0:t.type)!==`incomplete`||t.reason!==`error`)&&s(`message.error`,{threadId:i,messageId:o.id,reason:`error`})},v=[o.status,o.id,s,i],t[6]=s,t[7]=o.id,t[8]=o.status,t[9]=i,t[10]=_,t[11]=v):(_=t[10],v=t[11]),G(_,v);let y;t[12]!==p||t[13]!==n.composer||t[14]!==r?(y=cu({runtime:n.composer,threadIdRef:r,messageIdRef:p}),t[12]=p,t[13]=n.composer,t[14]=r,t[15]=y):y=t[15];let b=ra(y),x;if(t[16]!==n||t[17]!==o.content){let e;t[19]===n?e=t[20]:(e=(e,t)=>Ur(e,hu({runtime:n,index:t}),[n,t]),t[19]=n,t[20]=e),x=fu(o.content).map(e),t[16]=n,t[17]=o.content,t[18]=x}else x=t[18];let S=oo(x),C;if(t[21]!==o.attachments){var w;C=(w=o.attachments)==null?[]:w,t[21]=o.attachments,t[22]=C}else C=t[22];let T;if(t[23]!==n||t[24]!==C){let e;t[26]===n?e=t[27]:(e=(e,t)=>Ur(e.id,mu({runtime:n,index:t}),[n,t]),t[26]=n,t[27]=e),T=C.map(e),t[23]=n,t[24]=C,t[25]=T}else T=t[25];let D=oo(T),O=o,k;t[28]===a?k=t[29]:(k=a===!1?{isLast:a}:{},t[28]=a,t[29]=k);let A;t[30]!==b.state||t[31]!==c||t[32]!==u||t[33]!==S.state||t[34]!==k||t[35]!==O?(A=E(E(E({},O),k),{},{parts:S.state,composer:b.state,isCopied:c,isHovering:u}),t[30]=b.state,t[31]=c,t[32]=u,t[33]=S.state,t[34]=k,t[35]=O,t[36]=A):A=t[36];let j=A,M;t[37]===j?M=t[38]:(M=()=>j,t[37]=j,t[38]=M);let N;t[39]===b.methods?N=t[40]:(N=()=>b.methods,t[39]=b.methods,t[40]=N);let P;t[41]===n?P=t[42]:(P=()=>n.delete(),t[41]=n,t[42]=P);let F,I;t[43]!==g||t[44]!==n?(F=e=>(g(`message.reload`),n.reload(e)),I=()=>(g(`message.speak`),n.speak()),t[43]=g,t[44]=n,t[45]=F,t[46]=I):(F=t[45],I=t[46]);let L,R;t[47]===n?(L=t[48],R=t[49]):(L=()=>n.stopSpeaking(),R=e=>n.submitFeedback(e),t[47]=n,t[48]=L,t[49]=R);let z;t[50]!==g||t[51]!==n?(z=e=>(g(`message.branchSwitched`),n.switchToBranch(e)),t[50]=g,t[51]=n,t[52]=z):z=t[52];let B;t[53]===n?B=t[54]:(B=()=>n.unstable_getCopyText(),t[53]=n,t[54]=B);let ee;t[55]!==S||t[56]!==o.content?(ee=e=>{if(`index`in e)return S.get({index:e.index});{let t=o.content.findIndex(t=>t.type===`tool-call`&&t.toolCallId===e.toolCallId);return S.get({index:t})}},t[55]=S,t[56]=o.content,t[57]=ee):ee=t[57];let V;t[58]===D?V=t[59]:(V=e=>`id`in e?D.get({key:e.id}):D.get(e),t[58]=D,t[59]=V);let te;t[60]===g?te=t[61]:(te=e=>{e&&g(`message.copied`),l(e)},t[60]=g,t[61]=te);let H;t[62]===n?H=t[63]:(H=()=>n,t[62]=n,t[63]=H);let U;return t[64]!==M||t[65]!==N||t[66]!==P||t[67]!==F||t[68]!==I||t[69]!==L||t[70]!==R||t[71]!==z||t[72]!==B||t[73]!==ee||t[74]!==V||t[75]!==te||t[76]!==H?(U={getState:M,composer:N,delete:P,reload:F,speak:I,stopSpeaking:L,submitFeedback:R,switchToBranch:z,getCopyText:B,part:ee,attachment:V,setIsCopied:te,setIsHovering:d,__internal_getRuntime:H},t[64]=M,t[65]=N,t[66]=P,t[67]=F,t[68]=I,t[69]=L,t[70]=R,t[71]=z,t[72]=B,t[73]=ee,t[74]=V,t[75]=te,t[76]=H,t[77]=U):U=t[77],U}),_u=Hr(e=>{let t=K(7),{type:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let i;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(i={},t[1]=i):i=t[1];let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=[],t[2]=a):a=t[2];let o;t[3]===n?o=t[4]:(o={isEditing:!1,isEmpty:!0,text:``,attachmentAccept:`*`,attachments:r,role:`user`,runConfig:i,canCancel:!1,canSend:!1,type:n,dictation:void 0,quote:void 0,queue:a,submission:void 0,inTransit:void 0},t[3]=n,t[4]=o);let s=o,c;return t[5]===s?c=t[6]:(c={getState:()=>s,setText:vu,setRole:yu,setRunConfig:bu,addAttachment:xu,clearAttachments:Su,attachment:Cu,reset:wu,send:Tu,cancel:Eu,startDictation:Du,stopDictation:Ou,beginEdit:ku,setQuote:Au,queueItem:ju},t[5]=s,t[6]=c),c});function vu(){throw Error(`Not supported`)}function yu(){throw Error(`Not supported`)}function bu(){throw Error(`Not supported`)}function xu(){throw Error(`Not supported`)}function Su(){throw Error(`Not supported`)}function Cu(){throw Error(`Not supported`)}function wu(){throw Error(`Not supported`)}function Tu(){throw Error(`Not supported`)}function Eu(){throw Error(`Not supported`)}function Du(){throw Error(`Not supported`)}function Ou(){throw Error(`Not supported`)}function ku(){throw Error(`Not supported`)}function Au(){throw Error(`Not supported`)}function ju(){throw Error(`Not supported`)}var Mu=Hr(e=>{let t=K(8),{part:n,isMessageRunning:r}=e,i;if(t[0]!==r||t[1]!==n){var a;i=r?(a=ol(n))==null?rl:a:rl,t[0]=r,t[1]=n,t[2]=i}else i=t[2];let o;t[3]!==n||t[4]!==i?(o=E(E({},n),{},{status:i}),t[3]=n,t[4]=i,t[5]=o):o=t[5];let s=o,c;return t[6]===s?c=t[7]:(c={getState:()=>s,addToolResult:Fu,resumeToolCall:Iu,respondToToolApproval:Lu,unstable_recordInteraction:Ru},t[6]=s,t[7]=c),c}),Nu=Hr(({attachment:e})=>({getState:()=>e,remove:()=>{throw Error(`Not supported`)}})),Pu=Hr(e=>{let t=K(38),{message:n,index:r,isLast:i,branchNumber:a,branchCount:o,submission:s}=e,c=i===void 0||i,l=a===void 0?1:a,u=o===void 0?1:o,[d,f]=_n(!1),[p,m]=_n(!1),h=n.role===`assistant`&&n.status.type===`running`,g,_;if(t[0]!==h||t[1]!==n.content){let e=fu(n.content);g=oo,_=n.content.map((t,n)=>Ur(e[n],Mu({part:t,isMessageRunning:h}),[t,h])),t[0]=h,t[1]=n.content,t[2]=g,t[3]=_}else g=t[2],_=t[3];let v=g(_),y;if(t[4]!==n.attachments||t[5]!==(s==null?void 0:s.attachments)){var b,x;y=(b=(x=s==null?void 0:s.attachments)==null?n.attachments:x)==null?[]:b,t[4]=n.attachments,t[5]=s==null?void 0:s.attachments,t[6]=y}else y=t[6];let S;t[7]===y?S=t[8]:(S=y.map(Bu),t[7]=y,t[8]=S);let C=oo(S),w;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(w=_u({type:`edit`}),t[9]=w):w=t[9];let T=ra(w),D=T.state,O;t[10]!==u||t[11]!==l||t[12]!==D||t[13]!==r||t[14]!==d||t[15]!==p||t[16]!==c||t[17]!==n||t[18]!==v.state||t[19]!==s?(O=E(E({},n),{},{parts:v.state,composer:D,parentId:null,index:r,isLast:c,branchNumber:l,branchCount:u,speech:void 0,isCopied:d,isHovering:p,submission:s}),t[10]=u,t[11]=l,t[12]=D,t[13]=r,t[14]=d,t[15]=p,t[16]=c,t[17]=n,t[18]=v.state,t[19]=s,t[20]=O):O=t[20];let k=O,A;t[21]===k?A=t[22]:(A=()=>k,t[21]=k,t[22]=A);let j;t[23]===T.methods?j=t[24]:(j=()=>T.methods,t[23]=T.methods,t[24]=j);let M;t[25]!==n.content||t[26]!==v?(M=e=>`index`in e?v.get({index:e.index}):v.get({index:n.content.findIndex(t=>t.type===`tool-call`&&t.toolCallId===e.toolCallId)}),t[25]=n.content,t[26]=v,t[27]=M):M=t[27];let N;t[28]===C?N=t[29]:(N=e=>`id`in e?C.get({key:e.id}):C.get(e),t[28]=C,t[29]=N);let P;t[30]===n?P=t[31]:(P=()=>R(n),t[30]=n,t[31]=P);let F;return t[32]!==A||t[33]!==j||t[34]!==M||t[35]!==N||t[36]!==P?(F={getState:A,composer:j,part:M,attachment:N,delete:Vu,reload:Hu,speak:Uu,stopSpeaking:Wu,submitFeedback:Gu,switchToBranch:Ku,getCopyText:P,setIsCopied:f,setIsHovering:m},t[32]=A,t[33]=j,t[34]=M,t[35]=N,t[36]=P,t[37]=F):F=t[37],F});function Fu(){throw Error(`Not supported`)}function Iu(){throw Error(`Not supported`)}function Lu(){throw Error(`Not supported`)}function Ru(){return zu.apply(this,arguments)}function zu(){return zu=w(function*(){}),zu.apply(this,arguments)}function Bu(e){return Ur(e.id,Nu({attachment:e}),[e])}function Vu(){throw Error(`Not supported in ThreadMessageProvider`)}function Hu(){throw Error(`Not supported in ThreadMessageProvider`)}function Uu(){throw Error(`Not supported in ThreadMessageProvider`)}function Wu(){throw Error(`Not supported in ThreadMessageProvider`)}function Gu(){throw Error(`Not supported in ThreadMessageProvider`)}function Ku(){throw Error(`Not supported in ThreadMessageProvider`)}var qu=e=>Yc({role:e.role,content:e.role===`system`||e.text?[{type:`text`,text:e.text}]:[],attachments:[],metadata:{custom:E({},e.quote?{quote:e.quote}:{})}},e.id,{type:`complete`,reason:`unknown`}),Ju=e=>{let t=bn(()=>({}),[]),n=t.state,r=[];e.suggestions.forEach(e=>{let t=n==null?void 0:n.suggestions[r.length];r.push(t&&ma(t,e)?t:e)});let i=n&&ma(r,n.suggestions)?n:{suggestions:r};return t.state=i,i},Yu=Hr(e=>({getState:()=>e})),Xu=e=>{let t=K(9),n=Ju(e),r;t[0]===n.suggestions?r=t[1]:(r=n.suggestions.map(Qu),t[0]=n.suggestions,t[1]=r);let i=oo(r),a;t[2]===n?a=t[3]:(a=()=>n,t[2]=n,t[3]=a);let o;t[4]===i?o=t[5]:(o=e=>{let{index:t}=e;return i.get({index:t})},t[4]=i,t[5]=o);let s;return t[6]!==a||t[7]!==o?(s={getState:a,suggestion:o},t[6]=a,t[7]=o,t[8]=s):s=t[8],s},Zu=Hr(e=>{let t=K(4),n;t[0]===e?n=t[1]:(n=e.map($u),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r={suggestions:n},t[2]=n,t[3]=r),Xu(r)});function Qu(e,t){return Ur(t,Yu(e),[e])}function $u(e){var t,n;return{title:(t=e.title)==null?e.prompt:t,label:(n=e.label)==null?``:n,prompt:e.prompt}}var ed=e=>`reason`in e?e.reason:void 0,td=e=>`error`in e?e.error:void 0,nd=32,rd=new WeakMap,id=e=>{var t;return(t=rd.get(e))==null?e.id:t},ad=(e,t,n)=>`status`in e&&e.status?cl(e,t,n):rl,od=()=>{let e=[],t=new Map;return n=>{let r=[],i=new Map,a=!0,o=(e,n,s,c)=>{if(!(s>nd))for(let[l,u]of e.entries())for(let[e,d]of u.content.entries()){if(d.type!==`tool-call`||d.messages===void 0)continue;let f=d.messages,p=ad(u,e,d),m=ed(p),h=td(p),g=`${c}${l}.${e}`,_=t.get(g),v=(_==null?void 0:_.part)===d&&_.statusType===p.type&&_.statusReason===m&&Object.is(_.statusError,h)&&_.messages===f&&_.task.messageId===u.id&&_.task.parentTaskId===n&&_.task.depth===s?_.task:E(E({id:d.toolCallId,toolName:d.toolName,args:d.args,result:d.result},d.isError===void 0?void 0:{isError:d.isError}),{},{status:p,timing:d.timing,messageId:u.id,parentTaskId:n,depth:s,messages:f});v!==(_==null?void 0:_.task)&&(a=!1,rd.set(v,g)),r.push(v),i.set(g,{task:v,part:d,statusType:p.type,statusReason:m,statusError:h,messages:f}),o(f,v.id,s+1,`${g}.`)}};o(n,null,0,``);let s=a&&r.length===e.length&&r.every((t,n)=>t===e[n])?e:r;return e=s,t=i,s}},sd=Hr(({task:e})=>({getState:()=>e})),cd=Hr(e=>{let t=K(8),{runtime:n,id:r,threadIdRef:i,threadId:a,isLast:o}=e,s;t[0]!==r||t[1]!==n?(s=n.getMessageById(r),t[0]=r,t[1]=n,t[2]=s):s=t[2];let c=s,l;return t[3]!==o||t[4]!==c||t[5]!==a||t[6]!==i?(l=gu({runtime:c,threadIdRef:i,threadId:a,isLast:o}),t[3]=o,t[4]=c,t[5]=a,t[6]=i,t[7]=l):l=t[7],Gr(l)}),ld=Hr(e=>{var t;let n=K(118),{runtime:r}=e,i=$l(r),a=Ri(),o,s;n[0]!==a||n[1]!==r?(o=()=>{let e=[];for(let t of[`runStart`,`runEnd`,`initialize`,`modelContextUpdate`]){let n=r.unstable_on(t,()=>{var e;let n=((e=r.getState())==null?void 0:e.threadId)||`unknown`;a(`thread.${t}`,{threadId:n})});e.push(n)}return e.push(r.unstable_on(`historyWriteError`,e=>{var t;let n=((t=r.getState())==null?void 0:t.threadId)||`unknown`;a(`thread.historyWriteError`,{threadId:n,operation:e.operation,messageIds:e.messageIds,message:e.message})}),r.unstable_on(`toolApprovalAnswered`,e=>{var t;let n=((t=r.getState())==null?void 0:t.threadId)||`unknown`;a(`thread.toolApprovalAnswered`,E({threadId:n},e))})),()=>Oo(e)},s=[r,a],n[0]=a,n[1]=r,n[2]=o,n[3]=s):(o=n[2],s=n[3]),G(o,s);let c;n[4]===r?c=n[5]:(c=uu(()=>r.getState().threadId),n[4]=r,n[5]=c);let l=c,u;n[6]!==a||n[7]!==r?(u=e=>{a(e,{threadId:r.getState().threadId})},n[6]=a,n[7]=r,n[8]=u):u=n[8];let d=u,f;n[9]===r?f=n[10]:(f=e=>r.getState().suggestions.some(t=>t.prompt===e),n[9]=r,n[10]=f);let p=f,m;n[11]!==p||n[12]!==r.composer||n[13]!==l?(m=cu({runtime:r.composer,threadIdRef:l,isSuggestion:p}),n[11]=p,n[12]=r.composer,n[13]=l,n[14]=m):m=n[14];let h=ra(m),g;n[15]===i.suggestions?g=n[16]:(g=Zu(i.suggestions),n[15]=i.suggestions,n[16]=g);let _=ra(g),v;n[17]===Symbol.for(`react.memo_cache_sentinel`)?(v=od(),n[17]=v):v=n[17];let y=v,b;n[18]===i.messages?b=n[19]:(b=y(i.messages),n[18]=i.messages,n[19]=b);let x=b,S;n[20]===x?S=n[21]:(S=x.map(ud),n[20]=x,n[21]=S);let C=oo(S),w=h.state.submission,T=h.state.inTransit,D;n[22]===T?D=n[23]:(D=T==null?[]:T,n[22]=T,n[23]=D);let O;n[24]===w?O=n[25]:(O=w?[w]:[],n[24]=w,n[25]=O);let k;n[26]!==D||n[27]!==O?(k=[...D,...O],n[26]=D,n[27]=O,n[28]=k):k=n[28];let A=k,j;n[29]===A?j=n[30]:(j=A.map(qu),n[29]=A,n[30]=j);let M=j,N=i.messages.length-1,P;if(n[31]!==N||n[32]!==A||n[33]!==M||n[34]!==r||n[35]!==i.messages||n[36]!==i.threadId||n[37]!==l){let e;n[39]!==N||n[40]!==A.length||n[41]!==r||n[42]!==i.threadId||n[43]!==l?(e=(e,t)=>{let n=t===N&&A.length>0?!1:void 0;return Ur(e.id,cd({runtime:r,id:e.id,threadIdRef:l,threadId:i.threadId,isLast:n}),[r,e.id,l,i.threadId,n])},n[39]=N,n[40]=A.length,n[41]=r,n[42]=i.threadId,n[43]=l,n[44]=e):e=n[44];let t=i.messages.map(e),a;n[45]!==A||n[46]!==M||n[47]!==i.messages.length?(a=A.map((e,t)=>Ur(e.id,Pu({message:M[t],submission:e,index:i.messages.length+t,isLast:t===A.length-1}),[M[t],e,i.messages.length,t,A.length])),n[45]=A,n[46]=M,n[47]=i.messages.length,n[48]=a):a=n[48],P=[...t,...a],n[31]=N,n[32]=A,n[33]=M,n[34]=r,n[35]=i.messages,n[36]=i.threadId,n[37]=l,n[38]=P}else P=n[38];let F=oo(P),I=F.state.length===0&&!i.isLoading,L=(t=i.canResume)!=null&&t,R;n[49]!==h.state||n[50]!==F.state||n[51]!==i.capabilities||n[52]!==i.extras||n[53]!==i.hasEarlier||n[54]!==i.isDisabled||n[55]!==i.isLoading||n[56]!==i.isLoadingEarlier||n[57]!==i.isRunning||n[58]!==i.isSendDisabled||n[59]!==i.speech||n[60]!==i.state||n[61]!==i.suggestions||n[62]!==i.voice||n[63]!==I||n[64]!==L||n[65]!==x?(R={isEmpty:I,isDisabled:i.isDisabled,isSendDisabled:i.isSendDisabled,isLoading:i.isLoading,hasEarlier:i.hasEarlier,isLoadingEarlier:i.isLoadingEarlier,isRunning:i.isRunning,canResume:L,capabilities:i.capabilities,state:i.state,suggestions:i.suggestions,extras:i.extras,speech:i.speech,voice:i.voice,composer:h.state,messages:F.state,tasks:x},n[49]=h.state,n[50]=F.state,n[51]=i.capabilities,n[52]=i.extras,n[53]=i.hasEarlier,n[54]=i.isDisabled,n[55]=i.isLoading,n[56]=i.isLoadingEarlier,n[57]=i.isRunning,n[58]=i.isSendDisabled,n[59]=i.speech,n[60]=i.state,n[61]=i.suggestions,n[62]=i.voice,n[63]=I,n[64]=L,n[65]=x,n[66]=R):R=n[66];let z=R,B;n[67]===z?B=n[68]:(B=()=>z,n[67]=z,n[68]=B);let ee;n[69]===h.methods?ee=n[70]:(ee=()=>h.methods,n[69]=h.methods,n[70]=ee);let V;n[71]===_?V=n[72]:(V=()=>_.methods,n[71]=_,n[72]=V);let te;n[73]!==C||n[74]!==x?(te=e=>{if(`id`in e){let t=x.find(t=>t.id===e.id);return C.get({key:t?id(t):e.id})}return C.get(e)},n[73]=C,n[74]=x,n[75]=te):te=n[75];let H;n[76]!==a||n[77]!==p||n[78]!==r?(H=e=>{var t;let n=typeof e==`string`?{content:[{type:`text`,text:e}]}:e;if(((t=n.role)==null?`user`:t)===`user`){var i,o;let e=n.content.map(dd).join(``);a(`composer.send`,E({threadId:r.getState().threadId,chars:e.length,attachments:(i=(o=n.attachments)==null?void 0:o.length)==null?0:i},p(e)?{suggestion:!0}:void 0))}r.append(e)},n[76]=a,n[77]=p,n[78]=r,n[79]=H):H=n[79];let U;n[80]!==d||n[81]!==r||n[82]!==i.isRunning?(U=()=>{i.isRunning&&d(`thread.cancelRun`),r.cancelRun()},n[80]=d,n[81]=r,n[82]=i.isRunning,n[83]=U):U=n[83];let W;n[84]===r?W=n[85]:(W=()=>r.loadEarlier(),n[84]=r,n[85]=W);let ne;n[86]!==d||n[87]!==r?(ne=()=>{r.connectVoice(),d(`thread.voiceStarted`)},n[86]=d,n[87]=r,n[88]=ne):ne=n[88];let re;n[89]===F?re=n[90]:(re=e=>`id`in e?F.get({key:e.id}):F.get(e),n[89]=F,n[90]=re);let ie;n[91]===r?ie=n[92]:(ie=()=>r,n[91]=r,n[92]=ie);let ae;return n[93]!==r.deleteMessage||n[94]!==r.disconnectVoice||n[95]!==r.export||n[96]!==r.getModelContext||n[97]!==r.getVoiceVolume||n[98]!==r.import||n[99]!==r.importExternalState||n[100]!==r.muteVoice||n[101]!==r.reset||n[102]!==r.resumeRun||n[103]!==r.startRun||n[104]!==r.stopSpeaking||n[105]!==r.subscribeVoiceVolume||n[106]!==r.unmuteVoice||n[107]!==B||n[108]!==ee||n[109]!==V||n[110]!==te||n[111]!==H||n[112]!==U||n[113]!==W||n[114]!==ne||n[115]!==re||n[116]!==ie?(ae={getState:B,composer:ee,suggestions:V,task:te,append:H,deleteMessage:r.deleteMessage,startRun:r.startRun,resumeRun:r.resumeRun,importExternalState:r.importExternalState,cancelRun:U,loadEarlier:W,getModelContext:r.getModelContext,export:r.export,import:r.import,reset:r.reset,stopSpeaking:r.stopSpeaking,connectVoice:ne,disconnectVoice:r.disconnectVoice,getVoiceVolume:r.getVoiceVolume,subscribeVoiceVolume:r.subscribeVoiceVolume,muteVoice:r.muteVoice,unmuteVoice:r.unmuteVoice,message:re,__internal_getRuntime:ie},n[93]=r.deleteMessage,n[94]=r.disconnectVoice,n[95]=r.export,n[96]=r.getModelContext,n[97]=r.getVoiceVolume,n[98]=r.import,n[99]=r.importExternalState,n[100]=r.muteVoice,n[101]=r.reset,n[102]=r.resumeRun,n[103]=r.startRun,n[104]=r.stopSpeaking,n[105]=r.subscribeVoiceVolume,n[106]=r.unmuteVoice,n[107]=B,n[108]=ee,n[109]=V,n[110]=te,n[111]=H,n[112]=U,n[113]=W,n[114]=ne,n[115]=re,n[116]=ie,n[117]=ae):ae=n[117],ae});function ud(e){return Ur(id(e),sd({task:e}),[e])}function dd(e){return e.type===`text`?e.text:``}var fd=e=>{let t=K(4),n=Ri(),r=yn(e),i,a;t[0]!==n||t[1]!==e?(i=()=>{let t=r.current;t!==e&&(r.current=e,n(`threads.selectionChanged`,{threadId:e,previousThreadId:t}))},a=[e,n],t[0]=n,t[1]=e,t[2]=i,t[3]=a):(i=t[2],a=t[3]),G(i,a)},pd=(e,t,n)=>{let r=K(8),i=n===void 0?t:n,a=Ri(),o=t&&i,s;r[0]!==o||r[1]!==e?(s={isMain:o,threadId:e},r[0]=o,r[1]=e,r[2]=s):s=r[2];let c=yn(s),l,u;r[3]!==a||r[4]!==t||r[5]!==e?(l=()=>{let n=c.current;(n.isMain!==t||n.threadId!==e)&&(c.current={isMain:t,threadId:e},a(t?`threadListItem.switchedTo`:`threadListItem.switchedAway`,{threadId:e}))},u=[t,e,a],r[3]=a,r[4]=t,r[5]=e,r[6]=l,r[7]=u):(l=r[6],u=r[7]),G(l,u)},md=(e,t)=>nu(`thread list ${e}`,t),hd=Hr(e=>{let t=K(27),{runtime:n,mainThreadIsRunning:r}=e,i=r!==void 0&&r,a=$l(n),o;bb0:{let e=a.isRunning||a.isMain&&i;if(e===a.isRunning){o=a;break bb0}let n;t[0]!==e||t[1]!==a?(n=E(E({},a),{},{isRunning:e}),t[0]=e,t[1]=a,t[2]=n):n=t[2],o=n}let s=o;pd(a.id,a.isMain);let c;t[3]===s?c=t[4]:(c=()=>s,t[3]=s,t[4]=c);let l,u,d,f,p,m,h;t[5]===n?(l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11],h=t[12]):(u=e=>md(`switch`,()=>n.switchTo(e)),d=e=>md(`rename`,()=>n.rename(e)),f=e=>md(`update custom metadata`,()=>n.updateCustom(e)),p=()=>md(`archive`,()=>n.archive()),m=()=>md(`unarchive`,()=>n.unarchive()),h=()=>md(`delete`,()=>n.delete()),l=e=>md(`generate title`,()=>n.generateTitle(e)),t[5]=n,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m,t[12]=h);let g;t[13]===n?g=t[14]:(g=()=>n,t[13]=n,t[14]=g);let _;return t[15]!==n.detach||t[16]!==n.initialize||t[17]!==l||t[18]!==g||t[19]!==c||t[20]!==u||t[21]!==d||t[22]!==f||t[23]!==p||t[24]!==m||t[25]!==h?(_={getState:c,switchTo:u,rename:d,updateCustom:f,archive:p,unarchive:m,delete:h,generateTitle:l,initialize:n.initialize,detach:n.detach,__internal_getRuntime:g},t[15]=n.detach,t[16]=n.initialize,t[17]=l,t[18]=g,t[19]=c,t[20]=u,t[21]=d,t[22]=f,t[23]=p,t[24]=m,t[25]=h,t[26]=_):_=t[26],_}),gd=(e,t)=>{let[n]=_n(()=>({committed:void 0,unmounted:!1,waiters:new Set,delayed:new WeakMap}));return G(()=>{if(n.committed={state:e},!Object.is(e,t()))return;let r=[...n.waiters];n.waiters.clear();for(let e of r)e()}),G(()=>(n.unmounted=!1,()=>{n.unmounted=!0,n.committed=void 0;let e=[...n.waiters];n.waiters.clear();for(let t of e)t()}),[n]),xn(e=>{let r=n.delayed.get(e);if(r)return r;let i=e.then(e=>new Promise(r=>{let i=n.committed;if(n.unmounted||i!==void 0&&Object.is(i.state,t())){r(e);return}let a=()=>{clearTimeout(o),n.waiters.delete(a),r(e)},o=setTimeout(a,100);n.waiters.add(a)}));return n.delayed.set(e,i),i},[n,t])},_d=Hr(e=>{let t=K(6),{runtime:n,id:r,mainThreadIsRunning:i}=e,a;t[0]!==r||t[1]!==n?(a=n.getItemById(r),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s;return t[3]!==i||t[4]!==o?(s=hd({runtime:o,mainThreadIsRunning:i}),t[3]=i,t[4]=o,t[5]=s):s=t[5],Gr(s)}),vd=Hr(e=>{var t;let n=K(55),{runtime:r,__internal_assistantRuntime:i}=e,a=$l(r),o=gd(a,r.getState);fd(a.mainThreadId);let s=Ri(),c,l;n[0]!==s||n[1]!==r?(c=()=>r.unstable_subscribeThreadEvents(e=>{let{threadId:t,type:n}=e;t!==r.getState().mainThreadId&&s(`thread.${n}`,{threadId:t})}),l=[r,s],n[0]=s,n[1]=r,n[2]=c,n[3]=l):(c=n[2],l=n[3]),G(c,l);let u;n[4]===r.main?u=n[5]:(u=ld({runtime:r.main}),n[4]=r.main,n[5]=u);let d=ra(u),f;n[6]!==d.state||n[7]!==r||n[8]!==a.threadItems?(f=Object.keys(a.threadItems).map(e=>Ur(e,_d({runtime:r,id:e,mainThreadIsRunning:d.state.isRunning}),[r,e,d.state.isRunning])),n[6]=d.state,n[7]=r,n[8]=a.threadItems,n[9]=f):f=n[9];let p=oo(f),m=(t=a.newThreadId)==null?null:t,h;n[10]!==d.state||n[11]!==a.archivedThreadIds||n[12]!==a.canUnarchive||n[13]!==a.hasMore||n[14]!==a.isLoading||n[15]!==a.isLoadingMore||n[16]!==a.loadError||n[17]!==a.mainThreadId||n[18]!==a.switchError||n[19]!==a.threadIds||n[20]!==m||n[21]!==p.state?(h={canUnarchive:a.canUnarchive,mainThreadId:a.mainThreadId,newThreadId:m,isLoading:a.isLoading,loadError:a.loadError,switchError:a.switchError,isLoadingMore:a.isLoadingMore,hasMore:a.hasMore,threadIds:a.threadIds,archivedThreadIds:a.archivedThreadIds,threadItems:p.state,main:d.state},n[10]=d.state,n[11]=a.archivedThreadIds,n[12]=a.canUnarchive,n[13]=a.hasMore,n[14]=a.isLoading,n[15]=a.isLoadingMore,n[16]=a.loadError,n[17]=a.mainThreadId,n[18]=a.switchError,n[19]=a.threadIds,n[20]=m,n[21]=p.state,n[22]=h):h=n[22];let g=h,_;n[23]===g?_=n[24]:(_=()=>g,n[23]=g,n[24]=_);let v;n[25]===d.methods?v=n[26]:(v=()=>d.methods,n[25]=d.methods,n[26]=v);let y;n[27]!==g||n[28]!==p?(y=e=>{if(e===`main`)return p.get({key:g.mainThreadId});if(`id`in e)return p.get({key:e.id});let{index:t,archived:n}=e,r=n!==void 0&&n?g.archivedThreadIds[t]:g.threadIds[t];return p.get({key:r})},n[27]=g,n[28]=p,n[29]=y):y=n[29];let b,x;n[30]===r?(b=n[31],x=n[32]):(b=(e,t)=>md(`switch`,()=>r.switchToThread(e,t)),x=()=>md(`create`,()=>r.switchToNewThread()),n[30]=r,n[31]=b,n[32]=x);let S,C;n[33]!==o||n[34]!==r?(S=()=>o(r.getLoadThreadsPromise()),C=()=>o(r.reload()),n[33]=o,n[34]=r,n[35]=S,n[36]=C):(S=n[35],C=n[36]);let w;n[37]===r?w=n[38]:(w=()=>r.reloadMainThread(),n[37]=r,n[38]=w);let T;n[39]!==o||n[40]!==r?(T=()=>o(r.loadMore()),n[39]=o,n[40]=r,n[41]=T):T=n[41];let E;n[42]===i?E=n[43]:(E=()=>i,n[42]=i,n[43]=E);let D;return n[44]!==b||n[45]!==x||n[46]!==S||n[47]!==C||n[48]!==w||n[49]!==T||n[50]!==E||n[51]!==_||n[52]!==v||n[53]!==y?(D={getState:_,thread:v,item:y,switchToThread:b,switchToNewThread:x,getLoadThreadsPromise:S,reload:C,reloadMainThread:w,loadMore:T,__internal_getAssistantRuntime:E},n[44]=b,n[45]=x,n[46]=S,n[47]=C,n[48]=w,n[49]=T,n[50]=E,n[51]=_,n[52]=v,n[53]=y,n[54]=D):D=n[54],D}),yd=(e,t)=>{e.thread!=null||(e.thread=Za({source:`threads`,query:{type:`main`},get:e=>e.threads.thread(`main`)})),e.threadListItem!=null||(e.threadListItem=Za({source:`threads`,query:{type:`main`},get:e=>e.threads.item(`main`)})),e.composer!=null||(e.composer=Za({source:`thread`,query:{},get:e=>e.threads.thread(`main`).composer()})),!e.modelContext&&t.modelContext.source===null&&(e.modelContext=Wl()),!e.suggestions&&t.suggestions.source===null&&(e.suggestions=Za({source:`thread`,query:{},get:e=>e.thread.suggestions()}))},bd=e=>{let t=K(7),n=Mi(),r;t[0]!==n||t[1]!==e?(r=()=>e.registerModelContextProvider(n.current.modelContext()),t[0]=n,t[1]=e,t[2]=r):r=t[2];let i;t[3]===e?i=t[4]:(i=[e],t[3]=e,t[4]=i),Li(`modelContext`,r,i);let a;return t[5]===e?a=t[6]:(a=vd({runtime:e.threads,__internal_assistantRuntime:e}),t[5]=e,t[6]=a),Gr(a)},xd=Hr(bd);gi(bd,(e,t)=>{yd(e,t),!e.tools&&t.tools.source===null&&(e.tools=Xl({})),!e.dataRenderers&&t.dataRenderers.source===null&&(e.dataRenderers=jl())});var Sd=e=>{let{children:t,condition:n}=e;return q(n)?t:null};Sd.displayName=`AuiIf`;var Cd=u((e=>{var t=require("react"),n=Symbol.for(`react.element`),r=Symbol.for(`react.fragment`),i=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var s,c={},l=null,u=null;for(s in r!==void 0&&(l=``+r),t.key!==void 0&&(l=``+t.key),t.ref!==void 0&&(u=t.ref),t)i.call(t,s)&&!o.hasOwnProperty(s)&&(c[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)c[s]===void 0&&(c[s]=t[s]);return{$$typeof:n,type:e,key:l,ref:u,props:c,_owner:a.current}}e.Fragment=r,e.jsx=s,e.jsxs=s})),wd=u((e=>{process.env.NODE_ENV!==`production`&&(function(){"use strict";var t=require("react"),n=Symbol.for(`react.element`),r=Symbol.for(`react.portal`),i=Symbol.for(`react.fragment`),a=Symbol.for(`react.strict_mode`),o=Symbol.for(`react.profiler`),s=Symbol.for(`react.provider`),c=Symbol.for(`react.context`),l=Symbol.for(`react.forward_ref`),u=Symbol.for(`react.suspense`),d=Symbol.for(`react.suspense_list`),f=Symbol.for(`react.memo`),p=Symbol.for(`react.lazy`),m=Symbol.for(`react.offscreen`),h=Symbol.iterator,g=`@@iterator`;function _(e){if(typeof e!=`object`||!e)return null;var t=h&&e[h]||e[g];return typeof t==`function`?t:null}var v=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y(e){b(`error`,e,[...arguments].slice(1))}function b(e,t,n){var r=v.ReactDebugCurrentFrame.getStackAddendum();r!==``&&(t+=`%s`,n=n.concat([r]));var i=n.map(function(e){return String(e)});i.unshift(`Warning: `+t),Function.prototype.apply.call(console[e],console,i)}var x=Symbol.for(`react.module.reference`);function S(e){return!!(typeof e==`string`||typeof e==`function`||e===i||e===o||e===a||e===u||e===d||e===m||typeof e==`object`&&e&&(e.$$typeof===p||e.$$typeof===f||e.$$typeof===s||e.$$typeof===c||e.$$typeof===l||e.$$typeof===x||e.getModuleId!==void 0))}function C(e,t,n){var r=e.displayName;if(r)return r;var i=t.displayName||t.name||``;return i===``?n:n+`(`+i+`)`}function w(e){return e.displayName||`Context`}function T(e){if(e==null)return null;if(typeof e.tag==`number`&&y(`Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.`),typeof e==`function`)return e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case i:return`Fragment`;case r:return`Portal`;case o:return`Profiler`;case a:return`StrictMode`;case u:return`Suspense`;case d:return`SuspenseList`}if(typeof e==`object`)switch(e.$$typeof){case c:return w(e)+`.Consumer`;case s:return w(e._context)+`.Provider`;case l:return C(e,e.render,`ForwardRef`);case f:var t=e.displayName||null;return t===null?T(e.type)||`Memo`:t;case p:var n=e,m=n._payload,h=n._init;try{return T(h(m))}catch(e){return null}}return null}var E=Object.assign,D=0,O,k,A,j,M,N,P;function F(){}F.__reactDisabledLog=!0;function I(){if(D===0){O=console.log,k=console.info,A=console.warn,j=console.error,M=console.group,N=console.groupCollapsed,P=console.groupEnd;var e={configurable:!0,enumerable:!0,value:F,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}D++}function L(){if(D--,D===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:E({},e,{value:O}),info:E({},e,{value:k}),warn:E({},e,{value:A}),error:E({},e,{value:j}),group:E({},e,{value:M}),groupCollapsed:E({},e,{value:N}),groupEnd:E({},e,{value:P})})}D<0&&y(`disabledDepth fell below zero. This is a bug in React. Please file an issue.`)}var R=v.ReactCurrentDispatcher,z;function B(e,t,n){if(z===void 0)try{throw Error()}catch(e){var r=e.stack.trim().match(/\n( *(at )?)/);z=r&&r[1]||``}return`
9
+ `+z+e}var ee=!1,V=new(typeof WeakMap==`function`?WeakMap:Map);function te(e,t){if(!e||ee)return``;var n=V.get(e);if(n!==void 0)return n;var r;ee=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var a=R.current;R.current=null,I();try{if(t){var o=function(){throw Error()};if(Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(o,[])}catch(e){r=e}Reflect.construct(e,[],o)}else{try{o.call()}catch(e){r=e}e.call(o.prototype)}}else{try{throw Error()}catch(e){r=e}e()}}catch(t){if(t&&r&&typeof t.stack==`string`){for(var s=t.stack.split(`
10
+ `),c=r.stack.split(`
11
+ `),l=s.length-1,u=c.length-1;l>=1&&u>=0&&s[l]!==c[u];)u--;for(;l>=1&&u>=0;l--,u--)if(s[l]!==c[u]){if(l!==1||u!==1)do if(l--,u--,u<0||s[l]!==c[u]){var d=`
12
+ `+s[l].replace(` at new `,` at `);return e.displayName&&d.includes(`<anonymous>`)&&(d=d.replace(`<anonymous>`,e.displayName)),typeof e==`function`&&V.set(e,d),d}while(l>=1&&u>=0);break}}}finally{ee=!1,R.current=a,L(),Error.prepareStackTrace=i}var f=e?e.displayName||e.name:``,p=f?B(f):``;return typeof e==`function`&&V.set(e,p),p}function H(e,t,n){return te(e,!1)}function U(e){var t=e.prototype;return!!(t&&t.isReactComponent)}function W(e,t,n){if(e==null)return``;if(typeof e==`function`)return te(e,U(e));if(typeof e==`string`)return B(e);switch(e){case u:return B(`Suspense`);case d:return B(`SuspenseList`)}if(typeof e==`object`)switch(e.$$typeof){case l:return H(e.render);case f:return W(e.type,t,n);case p:var r=e,i=r._payload,a=r._init;try{return W(a(i),t,n)}catch(e){}}return``}var ne=Object.prototype.hasOwnProperty,re={},ie=v.ReactDebugCurrentFrame;function ae(e){if(e){var t=e._owner,n=W(e.type,e._source,t?t.type:null);ie.setExtraStackFrame(n)}else ie.setExtraStackFrame(null)}function oe(e,t,n,r,i){var a=Function.call.bind(ne);for(var o in e)if(a(e,o)){var s=void 0;try{if(typeof e[o]!=`function`){var c=Error((r||`React class`)+`: `+n+" type `"+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[o]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw c.name=`Invariant Violation`,c}s=e[o](t,o,r,n,null,`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`)}catch(e){s=e}s&&!(s instanceof Error)&&(ae(i),y("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",r||`React class`,n,o,typeof s),ae(null)),s instanceof Error&&!(s.message in re)&&(re[s.message]=!0,ae(i),y(`Failed %s type: %s`,n,s.message),ae(null))}}var se=Array.isArray;function ce(e){return se(e)}function le(e){return typeof Symbol==`function`&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||`Object`}function ue(e){try{return de(e),!1}catch(e){return!0}}function de(e){return``+e}function fe(e){if(ue(e))return y(`The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.`,le(e)),de(e)}var pe=v.ReactCurrentOwner,me={key:!0,ref:!0,__self:!0,__source:!0},he,ge,_e={};function ve(e){if(ne.call(e,`ref`)){var t=Object.getOwnPropertyDescriptor(e,`ref`).get;if(t&&t.isReactWarning)return!1}return e.ref!==void 0}function ye(e){if(ne.call(e,`key`)){var t=Object.getOwnPropertyDescriptor(e,`key`).get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function be(e,t){if(typeof e.ref==`string`&&pe.current&&t&&pe.current.stateNode!==t){var n=T(pe.current.type);_e[n]||(y(`Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref`,T(pe.current.type),e.ref),_e[n]=!0)}}function xe(e,t){var n=function(){he||(he=!0,y("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}function Se(e,t){var n=function(){ge||(ge=!0,y("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};n.isReactWarning=!0,Object.defineProperty(e,"ref",{get:n,configurable:!0})}var Ce=function(e,t,r,i,a,o,s){var c={$$typeof:n,type:e,key:t,ref:r,props:s,_owner:o};return c._store={},Object.defineProperty(c._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(c,"_self",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.defineProperty(c,"_source",{configurable:!1,enumerable:!1,writable:!1,value:a}),Object.freeze&&(Object.freeze(c.props),Object.freeze(c)),c};function we(e,t,n,r,i){var a,o={},s=null,c=null;for(a in n!==void 0&&(fe(n),s=``+n),ye(t)&&(fe(t.key),s=``+t.key),ve(t)&&(c=t.ref,be(t,i)),t)ne.call(t,a)&&!me.hasOwnProperty(a)&&(o[a]=t[a]);if(e&&e.defaultProps){var l=e.defaultProps;for(a in l)o[a]===void 0&&(o[a]=l[a])}if(s||c){var u=typeof e==`function`?e.displayName||e.name||`Unknown`:e;s&&xe(o,u),c&&Se(o,u)}return Ce(e,s,c,i,r,pe.current,o)}var Te=v.ReactCurrentOwner,Ee=v.ReactDebugCurrentFrame;function De(e){if(e){var t=e._owner,n=W(e.type,e._source,t?t.type:null);Ee.setExtraStackFrame(n)}else Ee.setExtraStackFrame(null)}var Oe=!1;function ke(e){return typeof e==`object`&&!!e&&e.$$typeof===n}function Ae(){if(Te.current){var e=T(Te.current.type);if(e)return`
13
+
14
+ Check the render method of \``+e+"`."}return``}function je(e){if(e!==void 0){var t=e.fileName.replace(/^.*[\\\/]/,``),n=e.lineNumber;return`
15
+
16
+ Check your code at `+t+`:`+n+`.`}return``}var Me={};function Ne(e){var t=Ae();if(!t){var n=typeof e==`string`?e:e.displayName||e.name;n&&(t=`
17
+
18
+ Check the top-level render call using <`+n+`>.`)}return t}function Pe(e,t){if(e._store&&!e._store.validated&&e.key==null){e._store.validated=!0;var n=Ne(t);if(!Me[n]){Me[n]=!0;var r=``;e&&e._owner&&e._owner!==Te.current&&(r=` It was passed a child from `+T(e._owner.type)+`.`),De(e),y(`Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.`,n,r),De(null)}}}function Fe(e,t){if(typeof e==`object`){if(ce(e))for(var n=0;n<e.length;n++){var r=e[n];ke(r)&&Pe(r,t)}else if(ke(e))e._store&&(e._store.validated=!0);else if(e){var i=_(e);if(typeof i==`function`&&i!==e.entries)for(var a=i.call(e),o;!(o=a.next()).done;)ke(o.value)&&Pe(o.value,t)}}}function Ie(e){var t=e.type;if(t!=null&&typeof t!=`string`){var n;if(typeof t==`function`)n=t.propTypes;else if(typeof t==`object`&&(t.$$typeof===l||t.$$typeof===f))n=t.propTypes;else return;if(n){var r=T(t);oe(n,e.props,`prop`,r,e)}else t.PropTypes!==void 0&&!Oe&&(Oe=!0,y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",T(t)||`Unknown`));typeof t.getDefaultProps==`function`&&!t.getDefaultProps.isReactClassApproved&&y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Le(e){for(var t=Object.keys(e.props),n=0;n<t.length;n++){var r=t[n];if(r!==`children`&&r!==`key`){De(e),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",r),De(null);break}}e.ref!==null&&(De(e),y("Invalid attribute `ref` supplied to `React.Fragment`."),De(null))}function Re(e,t,r,a,o,s){var c=S(e);if(!c){var l=``;(e===void 0||typeof e==`object`&&e&&Object.keys(e).length===0)&&(l+=` You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.`);var u=je(o);l+=u||Ae();var d;e===null?d=`null`:ce(e)?d=`array`:e!==void 0&&e.$$typeof===n?(d=`<`+(T(e.type)||`Unknown`)+` />`,l=` Did you accidentally export a JSX literal instead of a component?`):d=typeof e,y(`React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s`,d,l)}var f=we(e,t,r,o,s);if(f==null)return f;if(c){var p=t.children;if(p!==void 0){if(a){if(ce(p)){for(var m=0;m<p.length;m++)Fe(p[m],e);Object.freeze&&Object.freeze(p)}else y(`React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.`)}else Fe(p,e)}}return e===i?Le(f):Ie(f),f}function ze(e,t,n){return Re(e,t,n,!0)}function Be(e,t,n){return Re(e,t,n,!1)}var Ve=Be,He=ze;e.Fragment=i,e.jsx=Ve,e.jsxs=He})()})),J=u(((e,t)=>{t.exports=process.env.NODE_ENV===`production`?Cd():wd()}))(),Td=Me({}),Ed=({effects:e})=>{"use no memo";return Fl(e),null},Dd=kn(function(e,t){"use no memo";var n,r;let{config:i,children:a}=e,o=`extends`in e,s=`value`in e,c=pi();if(Ea){if(o&&s)throw Error("AuiProvider: pass either `extends` or `value`, not both.");if(o&&e.extends===void 0)throw Error("AuiProvider: `extends` must be a client or null, not undefined.");if(o&&!i)throw Error("AuiProvider: `extends` requires a `config`.");if(s&&i)throw Error("AuiProvider: pass either `value` or `config`, not both.");if(!s&&!i)throw Error("AuiProvider: a `config` is required.");if(!o&&!s&&c!==oi)throw Error(`A parent AuiProvider exists — pass extends={aui} to inherit it or extends={null} to isolate.`)}let l=o?(n=e.extends)==null?oi:n:s?(r=e.value)==null?oi:r:c,u=Ca(),{client:d,effects:f}=Ka(l,i==null?Td:i,u);return On(t,()=>d,[d]),(0,J.jsx)(da.Provider,{value:u,children:(0,J.jsxs)(ci.Provider,{value:d,children:[(0,J.jsx)(Ed,{effects:di(l)}),f&&(0,J.jsx)(Ed,{effects:f}),a]})})}),Od=e=>{let t=qa(),n=yn(!1),r=n.current?null:e(t);return q(()=>n.current?e(t):r),()=>(n.current=!0,e(t))},kd=Object.freeze({});function Ad(e){let t=K(3),{getItemState:n,children:r}=e,i=Od(n),a;return t[0]!==r||t[1]!==i?(a=r(i),t[0]=r,t[1]=i,t[2]=a):a=t[2],jd(a)}var jd=e=>{var t;let n=typeof e==`object`&&e&&`type`in e?e:null;return(t=bn(()=>n,[n==null?void 0:n.type,n==null?void 0:n.key,typeof(n==null?void 0:n.props)==`object`&&n.props!=null&&Object.entries(n.props).length===0?kd:n==null?void 0:n.props]))==null?e:t},Md=(e,t)=>{let n=K(11),r=qa(),i=Cn(t),a;n[0]===e?a=n[1]:(a=vi(e),n[0]=e,n[1]=a);let{scope:o,event:s}=a,c;n[2]!==r||n[3]!==i||n[4]!==s||n[5]!==o?(c=()=>r.on({scope:o,event:s},i),n[2]=r,n[3]=i,n[4]=s,n[5]=o,n[6]=c):c=n[6];let l;n[7]!==r||n[8]!==s||n[9]!==o?(l=[r,o,s],n[7]=r,n[8]=s,n[9]=o,n[10]=l):l=n[10],G(c,l)},Nd=e=>{var t;return(t=e._core)==null?void 0:t.RenderComponent},Pd=({runtime:e,aui:t,config:n,children:r})=>{"use no memo";let i=Nd(e),a=Me(E(E({},n),{},{threads:xd(e)}));return(0,J.jsxs)(Dd,{extends:t,config:a,children:[i&&(0,J.jsx)(i,{}),r]})},Fd=An(e=>{let t=K(5),{runtime:n,aui:r,config:i,children:a}=e,o=r===void 0?null:r,s;return t[0]!==o||t[1]!==a||t[2]!==i||t[3]!==n?(s=(0,J.jsx)(Pd,{runtime:n,aui:o,config:i,children:a}),t[0]=o,t[1]=a,t[2]=i,t[3]=n,t[4]=s):s=t[4],s}),Id=zn(null),Ld=(e,t)=>Mt(Id,e,t),Rd=()=>Vn(Id),zd={},Bd=e=>{let t=wa(e==null?zd:e);return e==null?null:t},Vd=class{constructor(){S(this,`cache`,new WeakMap)}convertMessages(e,t){return e.map((e,n)=>{let r=t(this.cache.get(e),e,n);return this.cache.set(e,r),r})}},Hd=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0};Object.freeze({});var Ud=e=>{let t=K(6),{index:n,children:r}=e,i=qa(),a;t[0]===n?a=t[1]:(a=Me({attachment:Za({source:`message`,query:{type:`index`,index:n},get:e=>e.message.attachment({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,J.jsx)(Dd,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Wd=e=>{let t=K(6),{index:n,children:r}=e,i=qa(),a;t[0]===n?a=t[1]:(a=Me({attachment:Za({source:`composer`,query:{type:`index`,index:n},get:e=>e.composer.attachment({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,J.jsx)(Dd,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Gd=e=>{let t=K(6),{runtime:n,children:r}=e,i=qa(),a;t[0]===n?a=t[1]:(a=Me({threadListItem:hd({runtime:n})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,J.jsx)(Dd,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Kd=e=>{let t=K(6),{index:n,children:r}=e,i=qa(),a;t[0]===n?a=t[1]:(a=Me({message:Za({source:`thread`,query:{type:`index`,index:n},get:e=>e.thread.message({index:n})}),composer:Za({source:`message`,query:{},get:e=>e.thread.message({index:n}).composer()})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,J.jsx)(Dd,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},qd=e=>{let t=K(6),{index:n,children:r}=e,i=qa(),a;t[0]===n?a=t[1]:(a=Me({part:Za({source:`message`,query:{type:`index`,index:n},get:e=>e.message.part({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,J.jsx)(Dd,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Jd=Hr(e=>{let t=K(7),{text:n,isRunning:r}=e,i;t[0]===r?i=t[1]:(i=r?{type:`running`}:{type:`complete`},t[0]=r,t[1]=i);let a;t[2]!==i||t[3]!==n?(a={type:`text`,text:n,status:i},t[2]=i,t[3]=n,t[4]=a):a=t[4];let o=a,s;return t[5]===o?s=t[6]:(s={getState:()=>o,addToolResult:Xd,resumeToolCall:Zd,respondToToolApproval:Qd,unstable_recordInteraction:$d},t[5]=o,t[6]=s),s}),Yd=e=>{let t=K(7),{text:n,isRunning:r,children:i}=e,a=r!==void 0&&r,o=qa(),s;t[0]!==a||t[1]!==n?(s=Me({part:Jd({text:n,isRunning:a})}),t[0]=a,t[1]=n,t[2]=s):s=t[2];let c=s,l;return t[3]!==o||t[4]!==i||t[5]!==c?(l=(0,J.jsx)(Dd,{extends:o,config:c,children:i}),t[3]=o,t[4]=i,t[5]=c,t[6]=l):l=t[6],l};function Xd(){throw Error(`Not supported`)}function Zd(){throw Error(`Not supported`)}function Qd(){throw Error(`Not supported`)}function $d(){return ef.apply(this,arguments)}function ef(){return ef=w(function*(){throw Error(`Not supported`)}),ef.apply(this,arguments)}var tf=e=>{var t,n;for(let t of e)if((t==null?void 0:t.status.type)===`running`)return il;return(t=(n=e.at(-1))==null?void 0:n.status)==null?rl:t},nf=(e,t)=>{let n={running:0,complete:0,incomplete:0,requiresAction:0},r=rl,i=!1,a,o,s=!0;for(let p of t){var c,l,u;let t=(c=e[p])==null?void 0:c.timing;if(t){var d,f;a=Math.min((d=a)==null?t.startedAt:d,t.startedAt),t.completedAt===void 0?s=!1:o=Math.max((f=o)==null?t.completedAt:f,t.completedAt)}switch(r=(l=(u=e[p])==null?void 0:u.status)==null?rl:l,r.type){case`running`:n.running++,i=!0;break;case`complete`:n.complete++;break;case`incomplete`:n.incomplete++;break;case`requires-action`:n.requiresAction++}}let p=a===void 0?void 0:!i&&s&&o!==void 0?{startedAt:a,completedAt:o}:{startedAt:a};return E({status:i?il:r,counts:n},p&&{timing:p})},rf=Hr(e=>{let t=K(11),{parts:n,getMessagePart:r}=e,[i,a]=_n(!0),o;t[0]===n?o=t[1]:(o=tf(n),t[0]=n,t[1]=o);let s=o,c;t[2]!==i||t[3]!==n||t[4]!==s?(c={parts:n,collapsed:i,status:s},t[2]=i,t[3]=n,t[4]=s,t[5]=c):c=t[5];let l=c,u;t[6]===l?u=t[7]:(u=()=>l,t[6]=l,t[7]=u);let d;return t[8]!==r||t[9]!==u?(d={getState:u,setCollapsed:a,part:r},t[8]=r,t[9]=u,t[10]=d):d=t[10],d}),af=zn(null),of=e=>{let t=K(13),{startIndex:n,endIndex:r,children:i}=e,a=q(sf).slice(n,r+1),o;t[0]!==r||t[1]!==n?(o=e=>fu(e.message.parts).slice(n,r+1),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s=q(Ta(o)),c;t[3]!==s||t[4]!==n?(c={partKeys:s,startIndex:n},t[3]=s,t[4]=n,t[5]=c):c=t[5];let l=c,u=qa(),d=Me({chainOfThought:rf({parts:a,getMessagePart:e=>{let{index:t}=e;if(t<0||t>=a.length)throw Error(`ChainOfThought part index ${t} is out of bounds (0..${a.length-1})`);return u.message.part({index:n+t})}})}),f;t[6]!==i||t[7]!==d||t[8]!==u?(f=(0,J.jsx)(Dd,{extends:u,config:d,children:i}),t[6]=i,t[7]=d,t[8]=u,t[9]=f):f=t[9];let p;return t[10]!==l||t[11]!==f?(p=(0,J.jsx)(af.Provider,{value:l,children:f}),t[10]=l,t[11]=f,t[12]=p):p=t[12],p};function sf(e){return e.message.parts}var cf=e=>{let t=K(7),{index:n,archived:r,children:i}=e,a=qa(),o;t[0]!==r||t[1]!==n?(o=Me({threadListItem:Za({source:`threads`,query:{type:`index`,index:n,archived:r},get:e=>e.threads.item({index:n,archived:r})})}),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s=o,c;return t[3]!==a||t[4]!==i||t[5]!==s?(c=(0,J.jsx)(Dd,{extends:a,config:s,children:i}),t[3]=a,t[4]=i,t[5]=s,t[6]=c):c=t[6],c},lf=e=>{let t=K(6),{index:n,children:r}=e,i=qa(),a;t[0]===n?a=t[1]:(a=Me({suggestion:Za({source:`suggestions`,query:{index:n},get:e=>e.suggestions.suggestion({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,J.jsx)(Dd,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},uf=e=>{let t=K(6),{index:n,children:r}=e,i=qa(),a;t[0]===n?a=t[1]:(a=Me({queueItem:Za({source:`composer`,query:{type:`index`,index:n},get:e=>e.composer.queueItem({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,J.jsx)(Dd,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},df=(e,t)=>{Promise.resolve(t).catch(t=>{Nc(t)||console.error(`[assistant-ui] ${e} failed`,t)})},ff=class{get path(){return this._core.path}constructor(e){S(this,`_core`,void 0),this._core=e,this.__internal_bindMethods()}__internal_bindMethods(){this.getState=this.getState.bind(this),this.remove=this.remove.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this._core.getState()}subscribe(e){return this._core.subscribe(e)}},pf=class extends ff{constructor(e,t){super(e),S(this,`_composerApi`,void 0),this._composerApi=t}remove(){let e=this._composerApi.getState();if(!e)throw Error(`Composer is not available`);return e.removeAttachment(this.getState().id)}},mf=class extends pf{get source(){return`thread-composer`}},hf=class extends pf{get source(){return`edit-composer`}},gf=class extends ff{get source(){return`message`}remove(){throw Error(`Message attachments cannot be removed`)}},_f=Object.freeze([]),vf=Object.freeze({}),yf=e=>{var t,n,r,i,a,o,s,c,l,u,d,f;return Object.freeze({type:`thread`,isEditing:(t=e==null?void 0:e.isEditing)!=null&&t,canCancel:(n=e==null?void 0:e.canCancel)!=null&&n,canSend:(r=e==null?void 0:e.canSend)!=null&&r,isEmpty:(i=e==null?void 0:e.isEmpty)==null||i,attachments:(a=e==null?void 0:e.attachments)==null?_f:a,text:(o=e==null?void 0:e.text)==null?``:o,role:(s=e==null?void 0:e.role)==null?`user`:s,runConfig:(c=e==null?void 0:e.runConfig)==null?vf:c,attachmentAccept:(l=e==null?void 0:e.attachmentAccept)==null?``:l,dictation:e==null?void 0:e.dictation,quote:e==null?void 0:e.quote,queue:(u=e==null?void 0:e.queue)==null?_f:u,submission:e==null?void 0:e.submission,inTransit:(d=e==null?void 0:e.inTransit)==null?_f:d,value:(f=e==null?void 0:e.text)==null?``:f})},bf=e=>{var t,n,r,i,a,o,s,c,l,u,d,f,p,m;return Object.freeze({type:`edit`,isEditing:(t=e==null?void 0:e.isEditing)!=null&&t,canCancel:(n=e==null?void 0:e.canCancel)!=null&&n,canSend:(r=e==null?void 0:e.canSend)!=null&&r,isEmpty:(i=e==null?void 0:e.isEmpty)==null||i,text:(a=e==null?void 0:e.text)==null?``:a,role:(o=e==null?void 0:e.role)==null?`user`:o,attachments:(s=e==null?void 0:e.attachments)==null?_f:s,runConfig:(c=e==null?void 0:e.runConfig)==null?vf:c,attachmentAccept:(l=e==null?void 0:e.attachmentAccept)==null?``:l,dictation:e==null?void 0:e.dictation,quote:e==null?void 0:e.quote,queue:(u=e==null?void 0:e.queue)==null?_f:u,submission:e==null?void 0:e.submission,inTransit:(d=e==null?void 0:e.inTransit)==null?_f:d,parentId:(f=e==null?void 0:e.parentId)==null?null:f,sourceId:(p=e==null?void 0:e.sourceId)==null?null:p,value:(m=e==null?void 0:e.text)==null?``:m})},xf=class{get path(){return this._core.path}constructor(e){S(this,`_core`,void 0),S(this,`_eventSubscriptionSubjects`,new Map),this._core=e}__internal_bindMethods(){this.setText=this.setText.bind(this),this.setRunConfig=this.setRunConfig.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.addAttachment=this.addAttachment.bind(this),this.reset=this.reset.bind(this),this.clearAttachments=this.clearAttachments.bind(this),this.send=this.send.bind(this),this.cancel=this.cancel.bind(this),this.steerQueueItem=this.steerQueueItem.bind(this),this.moveQueueItem=this.moveQueueItem.bind(this),this.removeQueueItem=this.removeQueueItem.bind(this),this.setRole=this.setRole.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.startDictation=this.startDictation.bind(this),this.stopDictation=this.stopDictation.bind(this),this.setQuote=this.setQuote.bind(this),this.unstable_on=this.unstable_on.bind(this)}setText(e,t){let n=this._core.getState();if(!n)throw Error(`Composer is not available`);n.setText(e,t)}setRunConfig(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setRunConfig(e)}addAttachment(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);return t.addAttachment(e)}reset(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);return e.reset()}clearAttachments(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);return e.clearAttachments()}send(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.send(e)}cancel(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.cancel()}steerQueueItem(e){this.moveQueueItem(e,{lane:`steer`,insertAfter:null})}moveQueueItem(e,t){let n=this._core.getState();if(!n)throw Error(`Composer is not available`);n.moveQueueItem(e,t)}removeQueueItem(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.removeQueueItem(e)}setRole(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setRole(e)}startDictation(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.startDictation()}stopDictation(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.stopDictation()}setQuote(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setQuote(e)}subscribe(e){return this._core.subscribe(e)}unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new Lo({event:e,binding:this._core}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},Sf=class extends xf{get path(){return this._core.path}get type(){return`thread`}constructor(e){let t=new Fo({path:e.path,getState:()=>yf(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>t.subscribe(e)}),S(this,`_getState`,void 0),this._getState=t.getState.bind(t),this.__internal_bindMethods()}getState(){return this._getState()}getAttachmentByIndex(e){return new mf(new Po({path:E(E({},this.path),{},{attachmentSource:`thread-composer`,attachmentSelector:{type:`index`,index:e},ref:`${this.path.ref}.attachments[${e}]`}),getState:()=>{let t=this.getState().attachments[e];return t?E(E({},t),{},{source:`thread-composer`}):Eo},subscribe:e=>this._core.subscribe(e)}),this._core)}},Cf=class extends xf{get path(){return this._core.path}get type(){return`edit`}constructor(e,t){let n=new Fo({path:e.path,getState:()=>bf(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>n.subscribe(e)}),S(this,`_getState`,void 0),S(this,`_beginEdit`,void 0),this._beginEdit=t,this._getState=n.getState.bind(n),this.__internal_bindMethods()}__internal_bindMethods(){super.__internal_bindMethods(),this.beginEdit=this.beginEdit.bind(this)}getState(){return this._getState()}beginEdit(){this._beginEdit()}getAttachmentByIndex(e){return new hf(new Po({path:E(E({},this.path),{},{attachmentSource:`edit-composer`,attachmentSelector:{type:`index`,index:e},ref:`${this.path.ref}.attachments[${e}]`}),getState:()=>{let t=this.getState().attachments[e];return t?E(E({},t),{},{source:`edit-composer`}):Eo},subscribe:e=>this._core.subscribe(e)}),this._core)}},wf={"allow-once":!0,"allow-always":!0,"reject-once":!1,"reject-always":!1},Tf=(e,t)=>{var n;let r=(n=e.questions)==null?[]:n;if(r.length===0)throw Error(`Tool approval "${e.id}" has display "questions" but declares no questions`);let i=new Set;for(let t of r){if(i.has(t.id))throw Error(`Tool approval "${e.id}" declares question "${t.id}" more than once`);i.add(t.id)}for(let n of Object.keys(t))if(!i.has(n))throw Error(`Tool approval "${e.id}" has no question with id "${n}"`);for(let n of r){var a,o,s,c;let r=Object.hasOwn(t,n.id)?t[n.id]:void 0,i=(a=r==null?void 0:r.optionIds)==null?[]:a,l=r==null?void 0:r.text;if(!Array.isArray(i)||l!==void 0&&typeof l!=`string`)throw Error(`Question "${n.id}" takes optionIds as an array and text as a string`);if(i.length===0&&(l===void 0||l.trim()===``))throw Error(`Tool approval "${e.id}" is missing an answer to question "${n.id}"`);if(i.length>1&&!n.multiple)throw Error(`Question "${n.id}" takes one option, not ${i.length}`);if(new Set(i).size!==i.length)throw Error(`Question "${n.id}" lists an option more than once`);for(let e of i)if(!((o=n.options)!=null&&o.some(t=>t.id===e)))throw Error(`Question "${n.id}" has no option with id "${e}"`);if(l!==void 0&&((s=(c=n.options)==null?void 0:c.length)==null?0:s)>0&&!n.allowFreeform)throw Error(`Question "${n.id}" does not accept a typed answer; it must declare allowFreeform`)}},Ef=(e,t)=>{let n=t.reason;if(`answers`in t){if(`approved`in t||`optionId`in t||`text`in t)throw Error(`Tool approval "${e.id}" takes its answers alone, without approved, optionId or text`);return Tf(e,t.answers),E({approvalId:e.id,approved:!0,answers:t.answers},n!=null&&{reason:n})}if(`approved`in t&&t.approved===!1&&!(`optionId`in t)&&t.text===void 0)return E({approvalId:e.id,approved:!1},n!=null&&{reason:n});throw Error(`Tool approval "${e.id}" asks questions; respond with answers, or with approved: false to dismiss it`)},Df=(e,t)=>{if(e.display===`questions`)return Ef(e,t);if(`answers`in t)throw Error(`Tool approval "${e.id}" asks no questions; answers only resolve a display "questions" request`);let n=t.text;if(n!==void 0&&!te(e))throw Error(`Tool approval "${e.id}" does not accept a free-form answer; the request must declare display "text" or allowFreeform`);let r,i;if(`optionId`in t){var a;let n=(a=e.options)==null?void 0:a.find(e=>e.id===t.optionId);if(!n)throw Error(`Tool approval has no option with id "${t.optionId}"`);if(`approved`in t)r=t.approved;else{if(!Object.hasOwn(wf,n.kind))throw Error(`Tool approval option "${n.id}" has a custom kind "${n.kind}"; respond with an explicit approved value instead`);r=wf[n.kind]}i=n.id}else if(`approved`in t)r=t.approved;else{if(e.display!==`text`&&e.display!==`select`)throw Error(`Tool approval "${e.id}" is a decision, not a question; respond with an explicit approved value, optionally alongside the answer`);r=!0}return E(E(E({approvalId:e.id,approved:r},i!==void 0&&{optionId:i}),n!==void 0&&{text:n}),t.reason!=null&&{reason:t.reason})},Of=class{get path(){return this.contentBinding.path}constructor(e,t,n){var r,i;S(this,`contentBinding`,void 0),S(this,`messageApi`,void 0),S(this,`threadApi`,void 0),S(this,`interactionState`,void 0),S(this,`interactionMessageId`,void 0),S(this,`interactionThreadId`,void 0),S(this,`interactionCore`,void 0),this.contentBinding=e,this.messageApi=t,this.threadApi=n,this.interactionState=e.getState(),this.interactionMessageId=this.interactionState.type===`tool-call`?t==null?void 0:t.getState().id:void 0,this.interactionThreadId=this.interactionState.type===`tool-call`?(r=this.threadApi)==null||(i=r.getStateState)==null?void 0:i.call(r).threadId:void 0,this.interactionCore=this.interactionState.type===`tool-call`?n==null?void 0:n.getState():void 0,this.__internal_bindMethods()}__internal_bindMethods(){this.addToolResult=this.addToolResult.bind(this),this.resumeToolCall=this.resumeToolCall.bind(this),this.respondToToolApproval=this.respondToToolApproval.bind(this),this.unstable_recordInteraction=this.unstable_recordInteraction.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this.contentBinding.getState()}getInteractionCore(){var e,t;let n=this.interactionThreadId!==void 0&&((e=this.threadApi)==null||(t=e.getStateState)==null?void 0:t.call(e).threadId)===this.interactionThreadId?this.threadApi.getState():this.interactionCore;if(!n)throw Error(`Thread API is not available`);return n}addToolResult(e){let t=this.interactionState;if(t.type!==`tool-call`)throw Error(`Tried to add tool result to non-tool message part`);if(!this.messageApi)throw Error(`Message API is not available. This is likely a bug in assistant-ui.`);if(!this.threadApi)throw Error(`Thread API is not available`);let n=this.interactionMessageId;if(n===void 0)throw Error(`Message is not available`);let r=t.toolName,i=t.toolCallId,a=Hs.toResponse(e);this.getInteractionCore().addToolResult(E(E({messageId:n,toolName:r,toolCallId:i,result:a.result,isError:a.isError},a.artifact!==void 0&&{artifact:a.artifact}),a.modelContent!==void 0&&{modelContent:a.modelContent}))}resumeToolCall(e){let t=this.interactionState;if(t.type!==`tool-call`)throw Error(`Tried to resume tool call on non-tool message part`);if(!this.threadApi)throw Error(`Thread API is not available`);this.getInteractionCore().resumeToolCall({toolCallId:t.toolCallId,payload:e}),this.unstable_recordInteraction({type:`human-response`,payload:e}).catch(()=>{})}respondToToolApproval(e){var t;let n=this.interactionState;if(n.type!==`tool-call`)throw Error(`Tried to respond to tool approval on non-tool message part`);if(!this.threadApi)throw Error(`Thread API is not available`);let r=this.getInteractionCore(),i=this.interactionMessageId===void 0||(t=r.getMessageById(this.interactionMessageId))==null?void 0:t.message.content.find(e=>e.type===`tool-call`&&e.toolCallId===n.toolCallId),a=(i==null?void 0:i.type)===`tool-call`?i.approval:void 0;if(!a||a.approved!==void 0||a.resolution!==void 0)throw Error(`Tool call has no pending approval`);return r.respondToToolApproval(Df(a,e))}unstable_recordInteraction(e){var t=this;return w(function*(){let n=t.interactionState;if(n.type!==`tool-call`)throw Error(`Tried to record interaction on non-tool message part`);let r=t.interactionMessageId;if(r===void 0)throw Error(`Message is not available`);let i=t.getInteractionCore();if(!i.unstable_recordToolInteraction)throw Error(`Runtime does not support recording tool interactions.`);yield i.unstable_recordToolInteraction({messageId:r,toolCallId:n.toolCallId,interaction:Hc(e)})})()}subscribe(e){return this.contentBinding.subscribe(e)}},kf=(e,t)=>{let n=e.content[t];if(!n)return Eo;let r=cl(e,t,n);return Object.freeze(E(E({},n),{},{[Xc]:n[Xc],status:r}))},Af=class{get path(){return this._core.path}constructor(e,t){S(this,`_core`,void 0),S(this,`_threadBinding`,void 0),S(this,`composer`,void 0),S(this,`_getEditComposerRuntimeCore`,()=>this._threadBinding.getState().getEditComposer(this._core.getState().id)),this._core=e,this._threadBinding=t,this.composer=new Cf(new Io({path:E(E({},this.path),{},{ref:`${this.path.ref}.composer`,composerSource:`edit`}),getState:this._getEditComposerRuntimeCore,subscribe:e=>this._threadBinding.subscribe(e)}),()=>this._threadBinding.getState().beginEdit(this._core.getState().id)),this.__internal_bindMethods()}__internal_bindMethods(){this.reload=this.reload.bind(this),this.delete=this.delete.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getMessagePartByIndex=this.getMessagePartByIndex.bind(this),this.getMessagePartByToolCallId=this.getMessagePartByToolCallId.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.unstable_getCopyText=this.unstable_getCopyText.bind(this),this.speak=this.speak.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.submitFeedback=this.submitFeedback.bind(this),this.switchToBranch=this.switchToBranch.bind(this)}getState(){return this._core.getState()}delete(){let e=this._core.getState();return this._threadBinding.getState().deleteMessage(e.id)}reload(e={}){let t=this._getEditComposerRuntimeCore(),n=t==null?this._threadBinding.getState().composer:t,r=t==null?n:t,{runConfig:i=r.runConfig}=e,a=this._core.getState();if(a.role!==`assistant`)throw Error(`Can only reload assistant messages`);df(`Message reload`,this._threadBinding.getState().startRun({parentId:a.parentId,sourceId:a.id,runConfig:i}))}speak(){let e=this._core.getState();return this._threadBinding.getState().speak(e.id)}stopSpeaking(){var e;let t=this._core.getState();if(((e=this._threadBinding.getState().speech)==null?void 0:e.messageId)===t.id)this._threadBinding.getState().stopSpeaking();else throw Error(`Message is not being spoken`)}submitFeedback({type:e,comment:t}){let n=this._core.getState();this._threadBinding.getState().submitFeedback(E({messageId:n.id,type:e},t===void 0?void 0:{comment:t}))}switchToBranch({position:e,branchId:t}){let n=this._core.getState();if(t&&e)throw Error(`May not specify both branchId and position`);if(!t&&!e)throw Error(`Must specify either branchId or position`);let r=this._threadBinding.getState().getBranches(n.id),i=t;if(e===`previous`?i=r[n.branchNumber-2]:e===`next`&&(i=r[n.branchNumber]),!i)throw Error(`Branch not found`);this._threadBinding.getState().switchToBranch(i)}unstable_getCopyText(){return R(this.getState())}subscribe(e){return this._core.subscribe(e)}getMessagePartByIndex(e){if(e<0)throw Error(`Message part index must be >= 0`);return new Of(new Po({path:E(E({},this.path),{},{ref:`${this.path.ref}.content[${e}]`,messagePartSelector:{type:`index`,index:e}}),getState:()=>kf(this.getState(),e),subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getMessagePartByToolCallId(e){return new Of(new Po({path:E(E({},this.path),{},{ref:`${this.path.ref}.content[toolCallId=${JSON.stringify(e)}]`,messagePartSelector:{type:`toolCallId`,toolCallId:e}}),getState:()=>{let t=this._core.getState(),n=t.content.findIndex(t=>t.type===`tool-call`&&t.toolCallId===e);return n===-1?Eo:kf(t,n)},subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getAttachmentByIndex(e){return new gf(new Po({path:E(E({},this.path),{},{ref:`${this.path.ref}.attachments[${e}]`,attachmentSource:`message`,attachmentSelector:{type:`index`,index:e}}),getState:()=>{var t;let n=(t=this.getState().attachments)==null?void 0:t[e];return n?E(E({},n),{},{source:`message`}):Eo},subscribe:e=>this._core.subscribe(e)}))}},jf=(e,t)=>{var n,r,i,a,o,s,c,l,u,d;return typeof t==`string`?{createdAt:new Date,parentId:(n=(r=e.at(-1))==null?void 0:r.id)==null?null:n,sourceId:null,runConfig:{},role:`user`,content:[{type:`text`,text:t}],attachments:[],metadata:{custom:{}}}:{createdAt:(i=t.createdAt)==null?new Date:i,parentId:t.parentId===void 0?(a=(o=e.at(-1))==null?void 0:o.id)==null?null:a:t.parentId,sourceId:(s=t.sourceId)==null?null:s,role:(c=t.role)==null?`user`:c,content:t.content,attachments:(l=t.attachments)==null?[]:l,metadata:(u=t.metadata)==null?{custom:{}}:u,runConfig:(d=t.runConfig)==null?{}:d,startRun:t.startRun}},Mf=e=>{var t,n,r;return E({parentId:(t=e.parentId)==null?null:t,sourceId:(n=e.sourceId)==null?null:n,runConfig:(r=e.runConfig)==null?{}:r},e.stream?{stream:e.stream}:{})},Nf=e=>{var t,n,r;return{parentId:(t=e.parentId)==null?null:t,sourceId:(n=e.sourceId)==null?null:n,runConfig:(r=e.runConfig)==null?{}:r}},Pf=e=>{if(e.isRunning!==void 0)return e.isRunning;let t=e.messages.at(-1);return(t==null?void 0:t.role)===`assistant`&&t.status.type===`running`},Ff=(e,t)=>{var n,r,i;return Object.freeze({threadId:t.id,metadata:t,capabilities:e.capabilities,isDisabled:e.isDisabled,isSendDisabled:e.isSendDisabled,isLoading:e.isLoading,hasEarlier:(n=e.hasEarlier)!=null&&n,isLoadingEarlier:(r=e.isLoadingEarlier)!=null&&r,isRunning:Pf(e),canResume:(i=e.canResume)!=null&&i,messages:e.messages,state:e.state,suggestions:e.suggestions,extras:e.extras,speech:e.speech,voice:e.voice})},If=class{get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}constructor(e,t){S(this,`_threadBinding`,void 0),S(this,`_stateBinding`,void 0),S(this,`composer`,void 0),S(this,`_eventSubscriptionSubjects`,new Map);let n=new Po({path:e.path,getState:()=>Ff(e.getState(),t.getState()),subscribe:n=>{let r=e.subscribe(n),i=t.subscribe(n);return()=>Oo([r,i])}});this._stateBinding=n,this._threadBinding={path:e.path,getState:()=>e.getState(),getStateState:()=>n.getState(),outerSubscribe:t=>e.outerSubscribe(t),subscribe:t=>e.subscribe(t)},this.composer=new Sf(new Io({path:E(E({},this.path),{},{ref:`${this.path.ref}.composer`,composerSource:`thread`}),getState:()=>this._threadBinding.getState().composer,subscribe:e=>this._threadBinding.subscribe(e)})),this.__internal_bindMethods()}__internal_bindMethods(){this.append=this.append.bind(this),this.deleteMessage=this.deleteMessage.bind(this),this.resumeRun=this.resumeRun.bind(this),this.loadEarlier=this.loadEarlier.bind(this),this.importExternalState=this.importExternalState.bind(this),this.exportExternalState=this.exportExternalState.bind(this),this.startRun=this.startRun.bind(this),this.cancelRun=this.cancelRun.bind(this),this.unstable_notifySessionReset=this.unstable_notifySessionReset.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.connectVoice=this.connectVoice.bind(this),this.disconnectVoice=this.disconnectVoice.bind(this),this.muteVoice=this.muteVoice.bind(this),this.unmuteVoice=this.unmuteVoice.bind(this),this.getVoiceVolume=this.getVoiceVolume.bind(this),this.subscribeVoiceVolume=this.subscribeVoiceVolume.bind(this),this.export=this.export.bind(this),this.import=this.import.bind(this),this.reset=this.reset.bind(this),this.getMessageByIndex=this.getMessageByIndex.bind(this),this.getMessageById=this.getMessageById.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getModelContext=this.getModelContext.bind(this),this.getState=this.getState.bind(this)}getState(){return this._threadBinding.getStateState()}append(e){df(`Message append`,this._threadBinding.getState().append(jf(this._threadBinding.getState().messages,e)))}deleteMessage(e){return this._threadBinding.getState().deleteMessage(e)}subscribe(e){return this._stateBinding.subscribe(e)}getModelContext(){return this._threadBinding.getState().getModelContext()}startRun(e){return this._threadBinding.getState().startRun(Nf(e))}resumeRun(e){return this._threadBinding.getState().resumeRun(Mf(e))}exportExternalState(){return this._threadBinding.getState().exportExternalState()}importExternalState(e){this._threadBinding.getState().importExternalState(e)}cancelRun(){this._threadBinding.getState().cancelRun()}loadEarlier(){var e,t,n;return(e=(t=(n=this._threadBinding.getState()).loadEarlier)==null?void 0:t.call(n))==null?Promise.resolve():e}unstable_notifySessionReset(){this._threadBinding.getState().unstable_notifySessionReset()}stopSpeaking(){return this._threadBinding.getState().stopSpeaking()}connectVoice(){this._threadBinding.getState().connectVoice()}disconnectVoice(){this._threadBinding.getState().disconnectVoice()}getVoiceVolume(){return this._threadBinding.getState().getVoiceVolume()}subscribeVoiceVolume(e){return this._threadBinding.getState().subscribeVoiceVolume(e)}muteVoice(){this._threadBinding.getState().muteVoice()}unmuteVoice(){this._threadBinding.getState().unmuteVoice()}export(){return this._threadBinding.getState().export()}import(e){this._threadBinding.getState().import(e)}reset(e){this._threadBinding.getState().reset(e)}getMessageByIndex(e){if(e<0)throw Error(`Message index must be >= 0`);return this._getMessageRuntime(E(E({},this.path),{},{ref:`${this.path.ref}.messages[${e}]`,messageSelector:{type:`index`,index:e}}),()=>{var t,n;let r=this._threadBinding.getState().messages,i=r[e];if(i)return{message:i,parentId:(t=(n=r[e-1])==null?void 0:n.id)==null?null:t,index:e}})}getMessageById(e){return this._getMessageRuntime(E(E({},this.path),{},{ref:`${this.path.ref}.messages[messageId=${JSON.stringify(e)}]`,messageSelector:{type:`messageId`,messageId:e}}),()=>this._threadBinding.getState().getMessageById(e))}_getMessageRuntime(e,t){return new Af(new Po({path:e,getState:()=>{var e,n;let{message:r,parentId:i,index:a}=(e=t())==null?{}:e,{messages:o,speech:s}=this._threadBinding.getState();if(!r||i===void 0||a===void 0)return Eo;let c=this._threadBinding.getState().getBranches(r.id);return E(E({},r),{},{[Xc]:r[Xc],index:a,isLast:((n=o.at(-1))==null?void 0:n.id)===r.id,parentId:i,branchNumber:c.indexOf(r.id)+1,branchCount:c.length,speech:(s==null?void 0:s.messageId)===r.id?s:void 0})},subscribe:e=>this._threadBinding.subscribe(e)}),this._threadBinding)}unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new Lo({event:e,binding:this._threadBinding,notifyOnRebind:e===`modelContextUpdate`}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},Lf=(e,t)=>({attachments:[],attachmentAccept:`*`,addAttachment(){return w(function*(){throw e})()},removeAttachment(){return w(function*(){throw e})()},isEditing:t,canCancel:!1,canSend:!1,isEmpty:!0,text:``,setText(){throw e},role:`user`,setRole(){throw e},runConfig:{},setRunConfig(){throw e},reset(){return w(function*(){})()},clearAttachments(){return w(function*(){})()},send(){throw e},cancel(){},queue:[],moveQueueItem(){},removeQueueItem(){},dictation:void 0,startDictation(){throw e},stopDictation(){},quote:void 0,setQuote(){throw e},subscribe(){return()=>{}},unstable_on(){return()=>{}}}),Rf=class extends jo{constructor(...e){super(...e),S(this,`getVoiceVolume`,()=>0),S(this,`subscribeVoiceVolume`,()=>()=>{}),S(this,`speech`,void 0),S(this,`voice`,void 0),S(this,`capabilities`,{switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,delete:!1,reload:!1,refetchThread:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1,answerToolCall:!1}),S(this,`isDisabled`,!1),S(this,`isSendDisabled`,!1),S(this,`state`,null),S(this,`suggestions`,[]),S(this,`extras`,void 0)}switchToBranch(){throw this.error}append(){throw this.error}deleteMessage(){throw this.error}startRun(){throw this.error}resumeRun(){throw this.error}cancelRun(){throw this.error}unstable_notifySessionReset(){throw this.error}addToolResult(){throw this.error}resumeToolCall(){throw this.error}respondToToolApproval(){throw this.error}unstable_recordToolInteraction(e){var t=this;return w(function*(){throw t.error})()}speak(){throw this.error}stopSpeaking(){throw this.error}connectVoice(){throw this.error}disconnectVoice(){throw this.error}muteVoice(){throw this.error}unmuteVoice(){throw this.error}submitFeedback(){throw this.error}exportExternalState(){throw this.error}importExternalState(){throw this.error}beginEdit(){throw this.error}import(){throw this.error}reset(){throw this.error}getModelContext(){return{}}getEditComposer(){}unstable_on(){return()=>{}}},zf=e=>{let t=K(6),{adapters:n,children:r}=e,i=Vn(Id),a;t[0]!==n||t[1]!==i?(a=E(E({},i),n),t[0]=n,t[1]=i,t[2]=a):a=t[2];let o=a,s;return t[3]!==r||t[4]!==o?(s=(0,J.jsx)(Id.Provider,{value:o,children:r}),t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Bf=new WeakMap,Vf=e=>{let t=Bf.get(e);return t||(t=new AbortController,Bf.set(e,t)),t.signal},Hf=new WeakMap,Uf=e=>{let t=Hf.get(e);return t||(t=new AbortController,Hf.set(e,t)),t},Wf=e=>Uf(e).signal,Gf=e=>{let t=Bf.get(e);t!=null&&t.signal.aborted||(Bf.delete(e),t==null||t.abort())},Kf=(e,t)=>{try{e()}catch(e){console.error(`[assistant-ui] ${t} cleanup threw while discarding a thread runtime`,e)}},qf=e=>{var t,n;e.voice&&Kf(()=>e.disconnectVoice(),`Voice`),e.composer.dictation&&Kf(()=>e.composer.stopDictation(),`Dictation`);let r=(t=(n=e.__internal_getEditComposers)==null?void 0:n.call(e))==null?e.messages.map(t=>e.getEditComposer(t.id)):t;for(let e of r)e!=null&&e.dictation&&Kf(()=>e.stopDictation(),`Dictation`);e.speech&&Kf(()=>e.stopSpeaking(),`Speech`)},Jf=e=>{qf(e),Gf(e)},Yf=e=>{var t;let n=(t=Bf.get(e))==null?new AbortController:t;Bf.set(e,n),n.abort(),Uf(e).abort(),qf(e)},Xf=class{get path(){return this._core.path}constructor(e,t){S(this,`_core`,void 0),S(this,`_threadListBinding`,void 0),this._core=e,this._threadListBinding=t,this.__internal_bindMethods()}__internal_bindMethods(){this.switchTo=this.switchTo.bind(this),this.rename=this.rename.bind(this),this.updateCustom=this.updateCustom.bind(this),this.archive=this.archive.bind(this),this.unarchive=this.unarchive.bind(this),this.delete=this.delete.bind(this),this.initialize=this.initialize.bind(this),this.generateTitle=this.generateTitle.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getState=this.getState.bind(this),this.detach=this.detach.bind(this)}getState(){return this._core.getState()}switchTo(e){let t=this._core.getState();return this._threadListBinding.switchToThread(t.id,e)}rename(e){let t=this._core.getState();return this._threadListBinding.rename(t.id,e)}updateCustom(e){let t=this._core.getState();if(!this._threadListBinding.updateCustom)throw Error(`Thread list runtime does not support updating custom metadata`);return this._threadListBinding.updateCustom(t.id,e)}archive(){let e=this._core.getState();return this._threadListBinding.archive(e.id)}unarchive(){let e=this._core.getState();return this._threadListBinding.unarchive(e.id)}delete(){let e=this._core.getState();return this._threadListBinding.delete(e.id)}initialize(){let e=this._core.getState();return this._threadListBinding.initialize(e.id)}generateTitle(e){let t=this._core.getState();return this._threadListBinding.generateTitle(t.id,e)}unstable_on(e,t){let n=this._core.getState().isMain,r=this._core.getState().id;return this.subscribe(()=>{let i=this._core.getState(),a=i.isMain,o=i.id;(n!==a||r!==o)&&(n=a,r=o,e===`switchedTo`&&!a||e===`switchedAway`&&a||L([t],{},`Thread list item "${e}"`))})}subscribe(e){return this._core.subscribe(e)}detach(){let e=this._core.getState();this._threadListBinding.detach(e.id)}__internal_getRuntime(){return this}},Zf=Promise.resolve(),Qf=()=>{},$f=e=>{var t,n,r;return{canUnarchive:(t=e.canUnarchive)==null||t,mainThreadId:e.mainThreadId,newThreadId:e.newThreadId,threadIds:e.threadIds,archivedThreadIds:e.archivedThreadIds,isLoading:e.isLoading,loadError:e.loadError,switchError:e.switchError,isLoadingMore:(n=e.isLoadingMore)!=null&&n,hasMore:(r=e.hasMore)!=null&&r,threadItems:e.threadItems}},ep=(e,t)=>{var n,r;if(t===void 0)return Eo;let i=e.getItemById(t);return i?{id:i.id,remoteId:i.remoteId,externalId:i.externalId,title:i.title,status:i.status,lastMessageAt:i.lastMessageAt,custom:i.custom,isMain:i.id===e.mainThreadId,isRunning:(n=(r=e.unstable_isThreadRunning)==null?void 0:r.call(e,i.id))!=null&&n}:Eo},tp=class{constructor(e,t=If){S(this,`_getState`,void 0),S(this,`_stateBinding`,void 0),S(this,`_core`,void 0),S(this,`_runtimeFactory`,void 0),S(this,`_mainThreadListItemRuntime`,void 0),S(this,`main`,void 0),this._core=e,this._runtimeFactory=t;let n=new Fo({path:{},getState:()=>$f(e),subscribe:t=>e.subscribe(t)});this._getState=n.getState.bind(n),this._stateBinding=n,this._mainThreadListItemRuntime=new Xf(new Po({path:{ref:`threadItems[main]`,threadSelector:{type:`main`}},getState:()=>ep(this._core,this._core.mainThreadId),subscribe:e=>this._core.subscribe(e)}),this._core),this.main=new t(new Io({path:{ref:`threads.main`,threadSelector:{type:`main`}},getState:()=>e.getMainThreadRuntimeCore(),subscribe:t=>e.subscribe(t)}),this._mainThreadListItemRuntime),this.__internal_bindMethods()}__internal_bindMethods(){this.switchToThread=this.switchToThread.bind(this),this.switchToNewThread=this.switchToNewThread.bind(this),this.unstable_subscribeThreadEvents=this.unstable_subscribeThreadEvents.bind(this),this.getLoadThreadsPromise=this.getLoadThreadsPromise.bind(this),this.reload=this.reload.bind(this),this.reloadMainThread=this.reloadMainThread.bind(this),this.loadMore=this.loadMore.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getById=this.getById.bind(this),this.getItemById=this.getItemById.bind(this),this.getItemByIndex=this.getItemByIndex.bind(this),this.getArchivedItemByIndex=this.getArchivedItemByIndex.bind(this)}switchToThread(e,t){return this._core.switchToThread(e,t)}switchToNewThread(){return this._core.switchToNewThread()}unstable_subscribeThreadEvents(e){var t,n,r;return(t=(n=(r=this._core).unstable_subscribeThreadEvents)==null?void 0:n.call(r,e))==null?Qf:t}getLoadThreadsPromise(){return this._core.getLoadThreadsPromise()}reload(){var e,t,n;return(e=(t=(n=this._core).reload)==null?void 0:t.call(n))==null?Zf:e}reloadMainThread(){var e,t,n;return(e=(t=(n=this._core).reloadMainThread)==null?void 0:t.call(n))==null?Zf:e}loadMore(){var e,t,n;return(e=(t=(n=this._core).loadMore)==null?void 0:t.call(n))==null?Zf:e}getState(){return this._getState()}subscribe(e){return this._stateBinding.subscribe(e)}get mainItem(){return this._mainThreadListItemRuntime}_createItemStateBinding(e){return new Po({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>ep(this._core,e),subscribe:e=>this._core.subscribe(e)})}getById(e){return new this._runtimeFactory(new Io({path:{ref:`threads[threadId=${JSON.stringify(e)}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>this._core.getThreadRuntimeCore(e),subscribe:e=>this._core.subscribe(e)}),this._createItemStateBinding(e))}getItemByIndex(e){return new Xf(new Po({path:{ref:`threadItems[${e}]`,threadSelector:{type:`index`,index:e}},getState:()=>ep(this._core,this._core.threadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getArchivedItemByIndex(e){return new Xf(new Po({path:{ref:`archivedThreadItems[${e}]`,threadSelector:{type:`archiveIndex`,index:e}},getState:()=>ep(this._core,this._core.archivedThreadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getItemById(e){return new Xf(this._createItemStateBinding(e),this._core)}},np=class{constructor(e){S(this,`threads`,void 0),S(this,`_thread`,void 0),S(this,`_core`,void 0),this._core=e,this.threads=new tp(e.threads),this._thread=this.threads.main,this.__internal_bindMethods()}__internal_bindMethods(){this.registerModelContextProvider=this.registerModelContextProvider.bind(this)}get thread(){return this._thread}registerModelContextProvider(e){return this._core.registerModelContextProvider(e)}},rp=class{constructor(){S(this,`_contextProvider`,new Ro)}registerModelContextProvider(e){return this._contextProvider.registerModelContextProvider(e)}getModelContextProvider(){return this._contextProvider}},ip=Object.freeze([]),ap=`DEFAULT_THREAD_ID`,op=Object.freeze([ap]),sp=Object.freeze({id:ap,remoteId:void 0,externalId:void 0,status:`regular`}),cp=Promise.resolve(),lp=Object.freeze(H({[ap]:sp})),up=class extends jo{get isLoading(){var e;return(e=this.adapter.isLoading)!=null&&e}get canUnarchive(){return!!this.adapter.onUnarchive}get newThreadId(){}get threadIds(){return this._threads}get archivedThreadIds(){return this._archivedThreads}get threadItems(){return this._threadData}getLoadThreadsPromise(){return cp}get mainThreadId(){return this._mainThreadId}constructor(e={},t){super(),S(this,`_mainThreadId`,ap),S(this,`_threads`,op),S(this,`_archivedThreads`,ip),S(this,`_threadData`,lp),S(this,`adapter`,{}),S(this,`_mainThread`,void 0),S(this,`threadFactory`,void 0),this.threadFactory=t,this.__internal_setAdapter(e,!0)}getMainThreadRuntimeCore(){return this._mainThread}getThreadRuntimeCore(){throw Error(`Method not implemented.`)}getItemById(e){return Object.hasOwn(this._threadData,e)?this._threadData[e]:void 0}__internal_setAdapter(e,t=!1){var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_;let v=this.adapter;this.adapter=e;let y=(n=e.threadId)==null?ap:n,b=(r=e.threads)==null?ip:r,x=(i=e.archivedThreads)==null?ip:i,S=(a=v.threadId)==null?ap:a,C=(o=v.threads)==null?ip:o,w=(s=v.archivedThreads)==null?ip:s;(t||((c=v.isLoading)!=null&&c)!==((l=e.isLoading)!=null&&l)||!!v.onUnarchive!=!!e.onUnarchive||S!==y||C!==b||w!==x)&&((C!==b||w!==x||S!==y)&&(this._threadData=H(Object.fromEntries((u=(d=e.threads)==null?void 0:d.map(e=>[e.id,E(E({},e),{},{remoteId:e.remoteId,externalId:e.externalId,status:`regular`})]))==null?[]:u),Object.fromEntries((f=(p=e.archivedThreads)==null?void 0:p.map(e=>[e.id,E(E({},e),{},{remoteId:e.remoteId,externalId:e.externalId,status:`archived`})]))==null?[]:f))),(C!==b||this._threads===op&&S!==y)&&(this._threads=(m=(h=this.adapter.threads)==null?void 0:h.map(e=>e.id))==null?ip:m),w!==x&&(this._archivedThreads=(g=(_=this.adapter.archivedThreads)==null?void 0:_.map(e=>e.id))==null?ip:g),(t||S!==y)&&(t||Yf(this._mainThread),this._mainThreadId=y,this._mainThread=this.threadFactory()),Object.hasOwn(this._threadData,this._mainThreadId)||(this._threadData=H(this._threadData,{[this._mainThreadId]:{id:this._mainThreadId,remoteId:void 0,externalId:void 0,status:`regular`}})),this._notifySubscribers())}reloadMainThread(){var e=this;return w(function*(){e._mainThread.unstable_refetchThread&&(yield e._mainThread.unstable_refetchThread())})()}switchToThread(e,t){var n=this;return w(function*(){if(n._mainThreadId===e)return;let t=n.adapter.onSwitchToThread;if(!t)throw Error(`External store adapter does not support switching to thread`);yield t(e)})()}switchToNewThread(){var e=this;return w(function*(){let t=e.adapter.onSwitchToNewThread;if(!t)throw Error(`External store adapter does not support switching to new thread`);yield t()})()}rename(e,t){var n=this;return w(function*(){let r=n.adapter.onRename;if(!r)throw Error(`External store adapter does not support renaming`);yield r(e,t)})()}updateCustom(e,t){var n=this;return w(function*(){let r=n.adapter.onUpdateCustom;if(!r)throw Error(`External store adapter does not support updating custom metadata`);yield r(e,t)})()}detach(){return w(function*(){})()}archive(e){var t=this;return w(function*(){let n=t.adapter.onArchive;if(!n)throw Error(`External store adapter does not support archiving`);yield n(e)})()}unarchive(e){var t=this;return w(function*(){let n=t.adapter.onUnarchive;if(!n)throw Error(`External store adapter does not support unarchiving`);yield n(e)})()}delete(e){var t=this;return w(function*(){let n=t.adapter.onDelete;if(!n)throw Error(`External store adapter does not support deleting`);yield n(e)})()}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){throw Error(`Method not implemented.`)}},dp=class{constructor(){S(this,`_generation`,0)}begin(){return this._generation++,this.current()}current(){let e=this._generation;return{isCurrent:()=>e===this._generation}}invalidate(){this._generation++}};function*fp(e,t){let n=[{type:`messages`,values:e,index:0}],r,i=e=>{if(!r){r=new WeakSet;for(let e of n)e.type===`messages`&&r.add(e.values)}return!r.has(e.values)&&(r.add(e.values),n.push(e),!0)};for(;n.length>0;){var a,o;let e=n[n.length-1];if(e.index>=e.values.length){n.pop(),e.type===`messages`&&(r==null||r.delete(e.values));continue}if(e.type===`messages`){let t=e.values[e.index++];if((t==null?void 0:t.role)!==`assistant`||!Array.isArray(t.content))continue;n.push({type:`content`,values:t.content,messageId:t.id,index:0});continue}let s=e.values[e.index++];s&&s.type===`tool-call`&&(yield{part:s,messageId:e.messageId},(a=s.messages)!=null&&a.length&&(t==null||(o=t.shouldDescend)==null?void 0:o.call(t,s))!==!1&&i({type:`messages`,values:s.messages,index:0}))}}var pp=e=>`content`in e&&!(`lastModified`in e),mp=e=>e.status.type===`complete`,hp=class{constructor(){S(this,`operations`,new Set),S(this,`uploading`,new Map)}start(){let e={cancelled:!1,attachmentIds:new Set};return this.operations.add(e),e}accept(e,t){var n;if(e.cancelled)return!1;e.attachmentIds.add(t.id);let r=this.uploading.get(t.id);return(r==null?void 0:r.operation)!==e&&(r||t.status.type===`running`)&&this.uploading.set(t.id,{operation:e,waiters:(n=r==null?void 0:r.waiters)==null?new Set:n}),t.status.type!==`running`&&this.settle(t.id,e),!0}finish(e){this.operations.delete(e);for(let t of e.attachmentIds)this.settle(t,e)}isCancelled(e){return e.cancelled}cancel(e){for(let t of[...this.operations])t.attachmentIds.has(e)&&(t.cancelled=!0,this.operations.delete(t));this.settle(e)}cancelAll(e){for(let t of[...this.operations])e&&[...t.attachmentIds].some(t=>e.has(t))||(t.cancelled=!0,this.operations.delete(t));for(let t of[...this.uploading.keys()])e!=null&&e.has(t)||this.settle(t)}whenSendable(e){let t=this.uploading.get(e);if(t)return new Promise(e=>t.waiters.add(e))}settle(e,t){let n=this.uploading.get(e);if(n&&!(t&&n.operation!==t)){this.uploading.delete(e);for(let e of n.waiters)e()}}},gp=function(){var e=w(function*(e,t){if(Symbol.asyncIterator in e){let s,c=!1;var n=!1,r=!1,i;try{for(var a=z(e),o;n=!(o=yield a.next()).done;n=!1){let e=o.value;if(s===void 0&&(s=e.id),e.id!==s)c||(console.warn(`[assistant-ui] AttachmentAdapter.add() yielded multiple attachment ids; only the first id is accepted`),c=!0);else if(!t(e))break}}catch(e){r=!0,i=e}finally{try{n&&a.return!=null&&(yield a.return())}finally{if(r)throw i}}}else t(yield e)});return function(t,n){return e.apply(this,arguments)}}(),_p=class{constructor(){S(this,`entries`,new WeakMap),S(this,`removals`,new WeakMap)}beginRemoval(e){let t=this.removals.get(e);return(t==null?void 0:t.phase)!==`pending`&&(t?t.phase=`pending`:this.removals.set(e,{phase:`pending`,dispatched:!1,retried:!1,abandoned:!1}),!0)}abandonRemoval(e){let t=this.removals.get(e);t&&(t.abandoned=!0),this.removals.delete(e)}isRemoved(e){return this.removals.has(e)}shouldRemoveOnClear(e){let t=this.removals.get(e);return!t||t.dispatched&&t.retried&&t.phase===`failed`}isRemovalPending(e){var t;return((t=this.removals.get(e))==null?void 0:t.phase)===`pending`}remove(e,t,n){var r=this;return w(function*(){let i=r.removals.get(e);try{if(!mp(e)){if(!t)throw Error(`Attachments are not supported`);yield t.remove(e)}i.phase=`complete`}catch(e){throw i.phase=`failed`,n==null||n(e,e instanceof Error?e.message:String(e)),r.retryDispatched(i),e}})()}dispatchRemoval(e,t){let n=this.removals.get(e);n&&(n.dispatched=!0,n.retry=t,this.retryDispatched(n))}retryDispatched(e){!e.abandoned&&e.dispatched&&e.phase===`failed`&&!e.retried&&e.retry&&(e.retried=!0,e.retry())}restore(e){let t=this.removals.get(e);if(!t||t.dispatched||t.phase!==`failed`)return e;let n=E({},e),r=this.entries.get(e);return r&&this.entries.set(n,r),n}restoreUnsent(e){let t=this.removals.get(e);if(!(t!=null&&t.dispatched||(t==null?void 0:t.phase)===`complete`))return this.restore(e)}adoptFrom(e,t){let n=e.removals.get(t);n&&this.removals.set(t,n);let r=e.entries.get(t);r&&this.entries.set(t,r)}isSameRemoval(e,t){let n=this.removals.get(e);return n!==void 0&&n===this.removals.get(t)}reconcileFailures(e,t,n){let r=new Map;return n.forEach((e,n)=>{e.status===`rejected`&&r.set(t[n].id,e.reason)}),e.map(e=>{if(!r.has(e.id)||mp(e)||this.isRemoved(e))return e;let t=r.get(e.id);return this.transfer(e,E(E({},e),{},{status:{type:`incomplete`,reason:`error`,message:t instanceof Error?t.message:String(t)}}))})}send(e,t,n){var r=this;return w(function*(){var i;if(mp(e))return e;let a=(i=r.entries.get(e))==null?{}:i;if(a.result)return a.result;if(!t)throw Error(`Attachments are not supported`);r.entries.set(e,a);let o=yield t.send(e,n?{signal:n}:void 0);return a.result=o,o})()}transfer(e,t){let n=this.entries.get(e);n&&this.entries.set(t,n);let r=this.removals.get(e);return r&&this.removals.set(t,r),t}},vp=(e,t,n=()=>!0)=>{let r=new Set,i=new Set;for(let o of e){var a;let e=(a=t(o))==null?void 0:a.find(e=>!o.known.has(e)&&!r.has(e)&&n(o,e));e!==void 0&&(r.add(e),i.add(o))}return{landed:i,claimed:r}},yp=(e,t)=>e.filter(e=>!t.landed.has(e)).map(e=>E(E({},e),{},{known:new Set([...e.known,...t.claimed])})),bp=[`transcript`],xp=class{constructor(e){S(this,`_host`,void 0),S(this,`_dictation`,void 0),S(this,`_dictationSession`,void 0),S(this,`_stoppingDictationSession`,void 0),S(this,`_dictationUnsubscribes`,[]),S(this,`_dictationBaseText`,``),S(this,`_currentInterimText`,``),S(this,`_dictationSessionIdCounter`,0),S(this,`_activeDictationSessionId`,void 0),S(this,`_isCleaningDictation`,!1),this._host=e}rebase(e){if(!this._dictation)return;this._dictationBaseText=e,this._currentInterimText=``;let{status:t,inputDisabled:n}=this._dictation;this._dictation=n?{status:t,inputDisabled:n}:{status:t}}cancel(){if(!this._dictationSession)return;let e=this._activeDictationSessionId;try{this._dictationSession.cancel()}catch(e){console.error(`[assistant-ui] Dictation session cancel threw`,e)}finally{this._cleanupDictation({sessionId:e})}}get dictation(){return this._dictation}_isActiveSession(e,t){return this._activeDictationSessionId===e&&this._dictationSession===t}startDictation(){var e;let t=this._host.getAdapter();if(!t)throw Error(`Dictation adapter not configured`);let n=this._dictationSession!==void 0;if(this._dictationSession){let e=this._dictationSession;this._cleanupDictation({notify:!1}),this._stopDictationSession(e)}let r=(e=t.disableInputDuringDictation)!=null&&e;this._dictationBaseText=this._host.getText(),this._currentInterimText=``;let i;try{i=t.listen()}catch(e){if(n)try{this._host.notify()}catch(e){console.error(`[assistant-ui] Dictation replacement rollback notification threw`,e)}throw e}this._dictationSession=i;let a=++this._dictationSessionIdCounter;this._activeDictationSessionId=a,this._dictation={status:i.status,inputDisabled:r};try{this._host.notify()}catch(e){console.error(`[assistant-ui] Dictation start notification threw`,e)}if(!this._isActiveSession(a,i))return;let o=[],s=()=>{for(let e of o.splice(0))try{e()}catch(e){console.error(`[assistant-ui] Dictation cleanup threw`,e)}},c=e=>(o.push(e),this._isActiveSession(a,i)?!0:(s(),!1));try{if(!c(i.onSpeech(e=>{if(!this._isActiveSession(a,i))return;let t=e.isFinal!==!1,n=this._dictationBaseText&&!this._dictationBaseText.endsWith(` `)&&e.transcript?` `:``;if(t){if(this._dictationBaseText=this._dictationBaseText+n+e.transcript,this._currentInterimText=``,this._host.setText(this._dictationBaseText),this._dictation){let e=this._dictation,{transcript:t}=e,n=W(e,bp);this._dictation=n}this._host.notify()}else this._currentInterimText=n+e.transcript,this._host.setText(this._dictationBaseText+this._currentInterimText),this._dictation&&(this._dictation=E(E({},this._dictation),{},{transcript:e.transcript})),this._host.notify()}))||!c(i.onSpeechStart(()=>{var e;this._isActiveSession(a,i)&&(this._dictation=E({status:{type:`running`},inputDisabled:r},((e=this._dictation)==null?void 0:e.transcript)&&{transcript:this._dictation.transcript}),this._host.notify())}))||!c(i.onSpeechEnd(()=>{this._cleanupDictation({sessionId:a})})))return;let e=setInterval(()=>{this._isActiveSession(a,i)&&i.status.type===`ended`&&this._cleanupDictation({sessionId:a})},100);if(!c(()=>clearInterval(e)))return;this._dictationUnsubscribes.push(...o.splice(0))}catch(e){if(s(),this._isActiveSession(a,i))try{i.cancel()}catch(e){console.error(`[assistant-ui] Dictation session cancel threw`,e)}finally{this._cleanupDictation({sessionId:a})}throw e}}stopDictation(){if(!this._dictationSession)return;let e=this._dictationSession;if(this._stoppingDictationSession===e)return;this._stoppingDictationSession=e;let t=this._activeDictationSessionId;this._stopDictationSession(e,()=>this._cleanupDictation({sessionId:t}))}_stopDictationSession(e,t=()=>{}){let n;try{n=e.stop()}catch(e){console.error(`[assistant-ui] Dictation session stop threw`,e),t();return}n.then(t,e=>{console.error(`[assistant-ui] Dictation session stop rejected`,e),t()})}_cleanupDictation(e){if((e==null?void 0:e.sessionId)!==void 0&&e.sessionId!==this._activeDictationSessionId||this._isCleaningDictation)return;this._isCleaningDictation=!0;let t=e=>{try{e()}catch(e){console.error(`[assistant-ui] Dictation cleanup threw`,e)}};try{let n=this._dictationUnsubscribes;this._dictationUnsubscribes=[],this._dictationSession=void 0,this._stoppingDictationSession=void 0,this._activeDictationSessionId=void 0,this._dictation=void 0,this._dictationBaseText=``,this._currentInterimText=``;for(let e of n)t(e);(e==null?void 0:e.notify)!==!1&&t(()=>this._host.notify())}finally{this._isCleaningDictation=!1}}},Sp=class extends jo{constructor(...e){super(...e),S(this,`isEditing`,!0),S(this,`_attachments`,[]),S(this,`_text`,``),S(this,`_dictationSessionController`,new xp({getAdapter:()=>this.getDictationAdapter(),getText:()=>this._text,setText:e=>this._writeText(e,`user`),notify:()=>this._notifySubscribers()})),S(this,`_role`,`user`),S(this,`_runConfig`,{}),S(this,`_quote`,void 0),S(this,`_pendingTextChanges`,[]),S(this,`_isFlushingTextChanges`,!1),S(this,`_notifyDepth`,0),S(this,`_submission`,void 0),S(this,`_submissionSend`,void 0),S(this,`_inTransit`,[]),S(this,`_inTransitSubmissions`,[]),S(this,`_sendGeneration`,0),S(this,`_draftEpoch`,0),S(this,`_attachmentAddOperations`,new hp),S(this,`_attachmentSends`,new _p),S(this,`_eventSubscribers`,new Map)}enrichWithComposerMetadata(e,t){var n;return t?E(E({},e),{},{metadata:E(E({},e.metadata),{},{custom:E(E({},(n=e.metadata)==null?void 0:n.custom),t)})}):e}get attachmentAccept(){var e,t;return(e=(t=this.getAttachmentAdapter())==null?void 0:t.accept)==null?`*`:e}get attachments(){return this._attachments}setAttachments(e){this._attachments=e,this._notifySubscribers()}get isEmpty(){return!this.text.trim()&&!this.sendableAttachments.length}get sendableAttachments(){return this.attachments.filter(e=>!this._attachmentSends.isRemoved(e))}get text(){return this._text}get role(){return this._role}get runConfig(){return this._runConfig}get quote(){return this._quote}setQuote(e){this._quote!==e&&(this._quote=e,this._notifySubscribers())}setText(e,t){var n;this._text!==e&&(this._writeText(e,(n=t==null?void 0:t.origin)==null?`external`:n),this._rebaseDictation(e),this._notifySubscribers())}_writeText(e,t){this._text!==e&&(this._text=e,this._pendingTextChanges.push({text:e,origin:t}))}_notifySubscribers(){this._notifyDepth++;try{super._notifySubscribers()}finally{--this._notifyDepth===0&&this._flushTextChanges()}}_flushTextChanges(){if(!this._isFlushingTextChanges){this._isFlushingTextChanges=!0;for(let e=this._pendingTextChanges.shift();e;e=this._pendingTextChanges.shift())this._notifyEventSubscribers(`textChange`,e);this._isFlushingTextChanges=!1}}_rebaseDictation(e){this._dictationSessionController.rebase(e)}setRole(e){this._role!==e&&(this._role=e,this._notifySubscribers())}setRunConfig(e){this._runConfig!==e&&(this._runConfig=e,this._notifySubscribers())}get submission(){return this._submission}get inTransit(){return this._inTransitSubmissions}get isSubmitting(){return this._submission!==void 0}get detachesDraftOnSend(){return!0}threadMessageIds(e){}settleInTransit(){if(this._inTransit.length===0)return;let e=vp(this._inTransit,e=>this.threadMessageIds(e.submission.role));e.landed.size!==0&&(this._setInTransit(yp(this._inTransit,e)),this._notifySubscribers())}_setInTransit(e){this._inTransit=e,this._inTransitSubmissions=e.map(e=>e.submission)}_leaveTransit(e){let t=this._inTransit.filter(t=>t.submission!==e);return t.length!==this._inTransit.length&&(this._setInTransit(t),!0)}_cancelAttachmentAdd(e){this._attachmentAddOperations.cancel(e)}_cancelAllAttachmentAdds(){this._attachmentAddOperations.cancelAll()}_emptyTextAndAttachments(){this._attachments=[],this._writeText(``,`reset`),this._rebaseDictation(``),this._notifySubscribers()}_draftUploadsToRemove(){return this._attachments.filter(e=>!mp(e)&&this._attachmentSends.shouldRemoveOnClear(e))}_onClearAttachments(e){var t=this;return w(function*(){let n=t.getAttachmentAdapter();n&&(yield Promise.all(e.map(e=>(t._attachmentSends.beginRemoval(e),t._attachmentSends.remove(e,n)))))})()}reset(){var e=this;return w(function*(){e._cancelAllAttachmentAdds(),e._draftEpoch++,e._sendGeneration++;let t=e._discardSubmission();if(e._attachments.length===0&&e._text===``&&e._role===`user`&&Object.keys(e._runConfig).length===0&&e._quote===void 0){yield t;return}e._role=`user`,e._runConfig={},e._quote=void 0;let n=e._onClearAttachments(e._draftUploadsToRemove());e._emptyTextAndAttachments(),yield Promise.all([n,t])})()}clearAttachments(){var e=this;return w(function*(){var t;e._draftEpoch++,e._attachmentAddOperations.cancelAll(e.detachesDraftOnSend?new Set((t=e._submission)==null?void 0:t.attachments.map(e=>e.id)):void 0);let n=e._draftUploadsToRemove();if(e.isSubmitting)for(let t of e._attachments)e._attachmentSends.beginRemoval(t);let r=e._onClearAttachments(n);e.setAttachments([]),yield r})()}send(e){var t=this;return w(function*(){if(!t.canSend||t.isSubmitting)return;t._dictationSessionController.cancel();let n=t.sendableAttachments;if(!t.text.trim()&&n.length===0)return;let r={id:g(),role:t.role,text:t.text,quote:t._quote,attachments:n},i={options:e,runConfig:t.runConfig},a=n.filter(mp),o=a.length===n.length;if(o||(t._submission=r,t._submissionSend=E(E({},i),{},{controller:new AbortController})),t.detachesDraftOnSend){let e=new Set(n);t._attachments=t._attachments.filter(t=>!e.has(t)),t._writeText(``,`send`),t._rebaseDictation(``),t._quote=void 0}let s=++t._sendGeneration;t._notifySubscribers(),o?t._dispatch(s,r,a,i,!1):yield t._prepareSubmission(s)})()}_prepareSubmission(e){var t=this;return w(function*(){var n,r,i;let a=t.getAttachmentAdapter(),o=((n=(r=t._submission)==null?void 0:r.attachments)==null?[]:n).flatMap(e=>{let n=t._attachmentAddOperations.whenSendable(e.id);return n?[n]:[]});if(o.length>0&&(yield Promise.all(o),e!==t._sendGeneration))return;let s=t._submission,c=t._submissionSend;if(!s||!c)return;let l=s.attachments.filter(e=>!t._attachmentSends.isRemoved(e));for(let e of l)t._cancelAttachmentAdd(e.id);let u=yield Promise.allSettled(l.map(e=>t._attachmentSends.send(e,a,c.controller.signal)));if(e!==t._sendGeneration)return;let d=u.find(e=>e.status===`rejected`);if(d){t._returnSubmissionToDraft(l,u,d.reason);return}let f=u.flatMap((e,n)=>t._attachmentSends.isRemoved(l[n])||e.status===`rejected`?[]:[e.value]),p=(i=t._submission)==null?s:i;!p.text.trim()&&f.length===0?(t._endSubmission(),t._returnToDraft(p)):t._dispatch(e,p,f,c,!0)})()}_dispatch(e,t,n,r,i){let a={createdAt:new Date,role:t.role,content:t.text?[{type:`text`,text:t.text}]:[],attachments:n,runConfig:r.runConfig,metadata:{custom:E({},t.quote?{quote:t.quote}:{})}},o=E(E({},t),{},{attachments:n}),s=new Map(t.attachments.filter(e=>!this._attachmentSends.isRemoved(e)).map((e,t)=>[e,n[t]])),c=E(E({},t),{},{attachments:t.attachments.map(e=>{var t;return(t=s.get(e))==null?e:t})}),l=this.queue.length;if(i){if(this._submission=void 0,this._submissionSend=void 0,!this.detachesDraftOnSend){let e=new Map(t.attachments.map((e,t)=>[e.id,c.attachments[t]]));this._attachments=this._attachments.map(t=>{var n;return(n=e.get(t.id))==null?t:n})}let e=this.threadMessageIds(t.role);e&&this._setInTransit([...this._inTransit,{submission:o,known:new Set(e)}])}let u=this.cleanupOwner,d=u._draftEpoch,f;try{f=this.handleSend(a,r.options)}catch(t){console.error(`[assistant-ui] Failed to send the message`,t),this._leaveTransit(o),e===this._sendGeneration?this._returnToDraft(c):this._notifySubscribers();return}if(f&&f.catch(t=>{let n=this._leaveTransit(o);e===this._sendGeneration&&Nc(t)?this._returnToDraft(c):n&&this._notifySubscribers()}),i)for(let e of t.attachments)mp(e)||this._attachmentSends.dispatchRemoval(e,()=>void this._retrySubmittedRemoval(e,u,d));this._notifyEventSubscribers(`send`,{chars:t.text.length,attachments:n.length}),i&&(this.queue.length>l&&this._leaveTransit(o),this._notifySubscribers(),this.settleInTransit())}_returnSubmissionToDraft(e,t,n){let r=this._submission;if(!r)return;let i=this._attachmentSends.reconcileFailures(r.attachments,e,t);this._endSubmission(),this._returnToDraft(E(E({},r),{},{attachments:i})),console.error(`[assistant-ui] Failed to send attachments`,n)}_endSubmission(){this._sendGeneration++,this._submission=void 0,this._submissionSend=void 0}__internal_dispose(){var e;this._cancelAllAttachmentAdds(),this._submission&&((e=this._submissionSend)==null||e.controller.abort(),this._endSubmission(),this._notifySubscribers())}cancelSubmission(){var e;let t=this._submission;t&&((e=this._submissionSend)==null||e.controller.abort(),this._endSubmission(),this._returnToDraft(t))}_returnToDraft(e){if(this.detachesDraftOnSend){var t;let n=e.attachments.flatMap(e=>{let t=this._attachmentSends.restoreUnsent(e);return t?[t]:[]});this._attachments=[...n,...this._attachments];let r=[e.text,this._text].filter(Boolean).join(`
19
+ `);this._writeText(r,`return`),this._rebaseDictation(r),this._quote=(t=this._quote)==null?e.quote:t}else{let t=new Map(e.attachments.flatMap(e=>{let t=this._attachmentSends.restoreUnsent(e);return t?[[e.id,t]]:[]}));this._attachments=this._attachments.flatMap(e=>{var n;let r=this._attachmentSends.restoreUnsent(e);return r?[(n=t.get(e.id))==null?r:n]:[]})}this._notifySubscribers()}_discardSubmission(){var e=this;return w(function*(){var t;let n=e._submission;if(!n)return;(t=e._submissionSend)==null||t.controller.abort(),e._endSubmission(),e._notifySubscribers();let r=e.getAttachmentAdapter();if(!r)return;let i=new Set(e._attachments.map(e=>e.id));yield Promise.all(n.attachments.filter(t=>!mp(t)&&!i.has(t.id)&&!e._attachmentSends.isRemovalPending(t)).map(function(){var e=w(function*(e){return r.remove(e)});return function(t){return e.apply(this,arguments)}}()))})()}restoreDraft(e){var t;return this._text.trim()||this._quote!==void 0||this._attachments.length>0?!1:(this._writeText(e.text,`return`),this._rebaseDictation(e.text),this._quote=e.quote,this._attachments=(t=e.attachments)==null?[]:t,this._notifySubscribers(),!0)}retractDraft(e){let t=e.attachments===void 0?this._attachments.length===0:this._attachments===e.attachments;this._text===e.text&&this._quote===e.quote&&t&&(this._writeText(``,`send`),this._rebaseDictation(``),this._quote=void 0,this._attachments=[],this._notifySubscribers())}cancel(){if(!this.detachesDraftOnSend&&(this._dictationSessionController.cancel(),this.isSubmitting)){var e;(e=this._submissionSend)==null||e.controller.abort(),this._endSubmission(),this._notifySubscribers()}this.handleCancel()}get queue(){return Dl}moveQueueItem(e,t){}removeQueueItem(e){}addAttachment(e){var t=this;return w(function*(){var n;if(pp(e)){var r,i,a;let n=t.getAttachmentAdapter();if(n&&!j({name:e.name,type:(r=e.contentType)==null?``:r},n.accept)){let r=`File type ${e.contentType||`unknown`} is not accepted. Accepted types: ${n.accept}`,i=Error(r);throw t._safeEmitAttachmentAddError(`not-accepted`,r,void 0,i,e.contentType),i}let o={id:(i=e.id)==null?g():i,type:(a=e.type)==null?`document`:a,name:e.name,contentType:e.contentType,content:e.content,status:{type:`complete`}};t._attachments=[...t._attachments,o],t._notifySubscribers(),t._notifyEventSubscribers(`attachmentAdd`,E({},o.contentType?{contentType:o.contentType}:void 0));return}let o=t.getAttachmentAdapter();if(!o){let n=`Attachments are not supported`,r=Error(n);throw t._safeEmitAttachmentAddError(`no-adapter`,n,void 0,r,e.type),r}if(!j({name:e.name,type:e.type},o.accept)){let n=`File type ${e.type||`unknown`} is not accepted. Accepted types: ${o.accept}`,r=Error(n);throw t._safeEmitAttachmentAddError(`not-accepted`,n,void 0,r,e.type),r}let s=t._attachmentAddOperations.start(),c=e=>{var n;if(!t._attachmentAddOperations.accept(s,e))return!1;let r=t._submission,i=(n=r==null?void 0:r.attachments.some(t=>t.id===e.id))!=null&&n;r&&i&&(t._submission=E(E({},r),{},{attachments:r.attachments.map(n=>n.id===e.id?t._attachmentSends.transfer(n,e):n)}));let a=t._attachments.findIndex(t=>t.id===e.id);return a===-1?i||(t._attachments=[...t._attachments,e]):t._attachments=[...t._attachments.slice(0,a),e,...t._attachments.slice(a+1)],t._notifySubscribers(),!0},l;try{yield gp(o.add({file:e}),e=>(l=e,c(e)))}catch(n){if(t._attachmentAddOperations.isCancelled(s))return;throw l&&c(E(E({},l),{},{status:{type:`incomplete`,reason:`error`,message:n instanceof Error?n.message:String(n)}})),t._safeEmitAttachmentAddError(`adapter-error`,n instanceof Error?n.message:String(n),l==null?void 0:l.id,n instanceof Error?n:void 0,(l==null?void 0:l.contentType)||e.type),n}finally{t._attachmentAddOperations.finish(s)}t._attachmentAddOperations.isCancelled(s)||((l==null?void 0:l.status.type)===`incomplete`&&l.status.reason===`error`?t._safeEmitAttachmentAddError(`adapter-error`,(n=l.status.message)==null?`Attachment upload did not complete successfully.`:n,l.id,void 0,l.contentType||e.type):t._notifyEventSubscribers(`attachmentAdd`,E({},l!=null&&l.contentType?{contentType:l.contentType}:e.type?{contentType:e.type}:void 0)))})()}_safeEmitAttachmentAddError(e,t,n,r,i){try{this._notifyEventSubscribers(`attachmentAddError`,E(E(E({reason:e,message:t},n!==void 0&&{attachmentId:n}),r!==void 0&&{error:r}),i?{contentType:i}:void 0))}catch(e){console.error(`[assistant-ui] attachmentAddError subscriber threw:`,e)}}removeAttachment(e){var t=this;return w(function*(){var n,r;let i=(n=t._attachments.find(t=>t.id===e))==null?(r=t._submission)==null?void 0:r.attachments.find(t=>t.id===e):n;if(!i)throw Error(`Attachment not found`);let a=t.getAttachmentAdapter();if(!mp(i)&&!a)throw Error(`Attachments are not supported`);if(!t._attachmentSends.beginRemoval(i))return;t._cancelAttachmentAdd(e),t._notifySubscribers(),yield t._attachmentSends.remove(i,a,(e,n)=>{let r=e=>t._attachmentSends.transfer(e,E(E({},e),{},{status:{type:`incomplete`,reason:`error`,message:n}})),a=t._submission;a&&(t._submission=E(E({},a),{},{attachments:a.attachments.map(e=>!mp(e)&&t._attachmentSends.isSameRemoval(e,i)?r(e):e)})),t._attachments.some(e=>t._attachmentSends.isSameRemoval(e,i))&&(t._attachments=t._attachments.map(e=>!mp(e)&&t._attachmentSends.isSameRemoval(e,i)?r(e):e),t._submission||(t._attachments=t._attachments.map(e=>t._attachmentSends.isSameRemoval(e,i)?t._attachmentSends.restore(e):e))),t._notifySubscribers()});let o=t._submission;o&&(t._submission=E(E({},o),{},{attachments:o.attachments.filter(e=>!t._attachmentSends.isSameRemoval(e,i))})),t._attachments.some(e=>t._attachmentSends.isSameRemoval(e,i))&&(t._attachments=t._attachments.filter(e=>!t._attachmentSends.isSameRemoval(e,i))),t._notifySubscribers()})()}get cleanupOwner(){return this}_adoptCleanupFailure(e,t,n){this._draftEpoch===n&&(this._attachments.some(e=>e.id===t.id)||(this._attachmentSends.adoptFrom(e,t),this._attachments=[t,...this._attachments],this._notifySubscribers()))}_retrySubmittedRemoval(e,t,n){var r=this;return w(function*(){r._attachmentSends.beginRemoval(e),yield r._attachmentSends.remove(e,r.getAttachmentAdapter(),(i,a)=>{console.error(`[assistant-ui] Failed to remove sent attachment`,i);let o=r._attachmentSends.transfer(e,E(E({},e),{},{status:{type:`incomplete`,reason:`error`,message:a}}));t._adoptCleanupFailure(r._attachmentSends,o,n)}).catch(()=>{})})()}get dictation(){return this._dictationSessionController.dictation}startDictation(){this._dictationSessionController.startDictation()}stopDictation(){this._dictationSessionController.stopDictation()}_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);n&&L(n,t,`Composer runtime "${e}"`)}unstable_on(e,t){let n=t,r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),()=>{var t;(t=this._eventSubscribers.get(e))==null||t.delete(n)}}},Cp=e=>{var t;return(t=e.capabilities)!=null&&t.cancel?Pf(e):!1},wp=class extends Sp{get canCancel(){return this.isSubmitting||Cp(this.runtime)}get canSend(){if(this.runtime.isDisabled||this.isEmpty||this.runtime.isSendDisabled||this.isSubmitting)return!1;let e=this.runtime.voice;return!e||e.canSendText&&this.role===`user`&&this.sendableAttachments.length===0}addAttachment(e){return this.runtime.isDisabled?Promise.resolve():super.addAttachment(e)}startDictation(){this.runtime.isDisabled||super.startDictation()}cancel(){this.isSubmitting?(this.cancelSubmission(),Cp(this.runtime)&&super.cancel()):super.cancel()}threadMessageIds(e){return this.runtime.messages.filter(t=>t.role===e).map(e=>e.id)}get queue(){var e,t,n,r,i,a;let o=(e=(t=(n=this.runtime).getSteerQueueItems)==null?void 0:t.call(n))==null?Dl:e,s=(r=(i=(a=this.runtime).getQueueItems)==null?void 0:i.call(a))==null?Dl:r,c=this._queueCache;if(c&&c.steer===o&&c.queue===s)return c.flat;let l=o.length===0?s:s.length===0?o:[...o,...s];return this._queueCache={steer:o,queue:s,flat:l},l}moveQueueItem(e,t){var n,r;(n=(r=this.runtime).moveQueueItem)==null||n.call(r,e,t)}removeQueueItem(e){var t,n;(t=(n=this.runtime).removeQueueItem)==null||t.call(n,e)}getAttachmentAdapter(){var e;return(e=this.runtime.adapters)==null?void 0:e.attachments}getDictationAdapter(){var e;return(e=this.runtime.adapters)==null?void 0:e.dictation}constructor(e){super(),S(this,`_queueCache`,void 0),S(this,`runtime`,void 0),this.runtime=e,this.connect()}connect(){var e;let t=!1,n=this.runtime.isDisabled,r=this.runtime.isSendDisabled,i=(e=this.runtime.voice)==null?void 0:e.canSendText,a=this.queue;return this.runtime.subscribe(()=>{var e;this.settleInTransit();let o=!1,s=this.canCancel;t!==s&&(t=s,o=!0),n!==this.runtime.isDisabled&&(n=this.runtime.isDisabled,o=!0),r!==this.runtime.isSendDisabled&&(r=this.runtime.isSendDisabled,o=!0);let c=(e=this.runtime.voice)==null?void 0:e.canSendText;i!==c&&(i=c,o=!0),a!==this.queue&&(a=this.queue,o=!0),o&&this._notifySubscribers()})}handleSend(e,t){var n=this;return w(function*(){var r,i;return n.runtime.append(E(E({},e),{},{parentId:(r=(i=n.runtime.messages.at(-1))==null?void 0:i.id)==null?null:r,sourceId:null,startRun:t==null?void 0:t.startRun,steer:t==null?void 0:t.steer}))})()}handleCancel(){var e=this;return w(function*(){e.runtime.cancelRun()})()}},Tp=class extends Sp{get canCancel(){return!0}get detachesDraftOnSend(){return!1}get cleanupOwner(){return this.runtime.composer instanceof Sp?this.runtime.composer:this}get canSend(){return!this.runtime.isDisabled&&!this.isEmpty&&!this.runtime.voice&&!this.isSubmitting}addAttachment(e){return this.runtime.isDisabled?Promise.resolve():super.addAttachment(e)}startDictation(){this.runtime.isDisabled||super.startDictation()}getAttachmentAdapter(){var e;return(e=this.runtime.adapters)==null?void 0:e.attachments}getDictationAdapter(){var e;return(e=this.runtime.adapters)==null?void 0:e.dictation}constructor(e,t,{parentId:n,message:r,onMessageNotSent:i}){super(),S(this,`_nonTextPassthrough`,void 0),S(this,`_parentId`,void 0),S(this,`_sourceId`,void 0),S(this,`runtime`,void 0),S(this,`endEditCallback`,void 0),S(this,`onMessageNotSent`,void 0),S(this,`_ended`,!1),this.runtime=e,this.onMessageNotSent=i;let a=e.voice!==void 0,o=e.isDisabled,s=e.subscribe(()=>{let t=e.voice!==void 0,n=e.isDisabled;(t!==a||n!==o)&&(a=t,o=n,this._notifySubscribers())});this.endEditCallback=()=>{s(),t()},this._parentId=n,this._sourceId=r.id,this.setText(R(r)),this.setRole(r.role);let c;if(r.role===`user`){var l;c=[...(l=r.attachments)==null?[]:l,...N(r.content)],this._nonTextPassthrough=[]}else{var u;c=(u=r.attachments)==null?[]:u,this._nonTextPassthrough=r.content.filter(e=>e.type!==`text`)}this.setAttachments(c),this.setQuote(r.metadata.custom.quote),this.setRunConfig(E({},e.composer.runConfig))}get parentId(){return this._parentId}get sourceId(){return this._sourceId}handleSend(e,t){var n=this;return w(function*(){let r=n._nonTextPassthrough.length>0?[...e.content,...n._nonTextPassthrough]:e.content,i=E(E({},e),{},{content:r,parentId:n._parentId,sourceId:n._sourceId,startRun:t==null?void 0:t.startRun}),a=n.runtime.append(i);n.handleCancel();try{yield a}catch(e){var o;throw Nc(e)&&((o=n.onMessageNotSent)==null||o.call(n,i)),e}})()}handleCancel(){this._ended||(this._ended=!0,this.reset().catch(e=>{console.error(`[assistant-ui] Failed to clear cancelled edit`,e)}),this.endEditCallback(),this._notifySubscribers())}},Ep=class{constructor(e){S(this,`voiceMessages`,[]),S(this,`voiceGeneration`,0),S(this,`_cachedMergedMessages`,null),S(this,`_cachedVoiceGeneration`,-1),S(this,`_cachedMergedBase`,null),S(this,`host`,void 0),S(this,`_voiceSession`,void 0),S(this,`_voiceUnsubs`,[]),S(this,`voice`,void 0),S(this,`_voiceVolume`,0),S(this,`_voiceVolumeSubscribers`,new Set),S(this,`getVoiceVolume`,()=>this._voiceVolume),S(this,`subscribeVoiceVolume`,e=>(this._voiceVolumeSubscribers.add(e),()=>this._voiceVolumeSubscribers.delete(e))),S(this,`_currentAssistantMsg`,null),this.host=e}markMessagesDirty(){this.voiceGeneration++,this._cachedMergedMessages=null}dropMessage(e,t){let n=this.voiceMessages.findIndex(t=>t.id===e);n!==-1&&(this.voiceMessages.splice(n,1),this.host.markVoiceMessagesDirty(),t&&this.host.notify())}getMessages(){if(this.voiceMessages.length===0)return this.host.getBaseMessages();let e=this.host.getBaseMessages();if(this._cachedVoiceGeneration!==this.voiceGeneration||this._cachedMergedBase!==e){let t=new Set(e.map(e=>e.id));this._cachedMergedMessages=[...e,...this.voiceMessages.filter(e=>!t.has(e.id))],this._cachedVoiceGeneration=this.voiceGeneration,this._cachedMergedBase=e}return this._cachedMergedMessages}replaceAssistantMessage(e,t){this._currentAssistantMsg===e&&(this._currentAssistantMsg=t)}isVoiceMessage(e){return e!==null&&this.voiceMessages.some(t=>t.id===e)}_toVoiceSessionState(e,t,n){return{status:t,isMuted:e.isMuted,mode:n,canSendText:t.type===`running`&&e.sendText!==void 0}}isRunActive(){if(this.host.isRunning())return!0;let e=this.host.getBaseMessages().at(-1);return(e==null?void 0:e.role)===`assistant`&&(e.status.type===`running`||e.status.type===`requires-action`)}getVoiceCommitBarrier(){var e=this;if(!this.host.isLoading())return;let t=this.host.captureGeneration();return w(function*(){for(;e.host.isLoading()&&!t.aborted;)yield new Promise(n=>{let r=()=>{i(),t.removeEventListener(`abort`,r),n()},i=e.host.subscribe(r);t.addEventListener(`abort`,r)})})()}connectVoice(){let e=this.host.adapter();if(!e)throw Error(`Voice adapter not configured`);if(this.host.isRunActive())throw Error(`Cannot start a voice session while a run is in progress or paused on a pending tool action`);let t=this._voiceSession!==void 0;try{this._disconnectVoice(!1)}catch(e){console.error(`[assistant-ui] Voice cleanup threw before reconnect`,e)}if(this._voiceSession!==void 0)return;let n;try{n=e.connect({})}catch(e){throw t&&this._voiceSession===void 0&&this.host.onDisconnected(),e}if(n.status.type===`ended`){try{n.disconnect()}finally{t&&this._voiceSession===void 0&&this.host.onDisconnected()}return}this._voiceSession=n;let r=[];this._voiceUnsubs=r;let i=()=>{if(this._voiceSession===n&&this._voiceUnsubs===r)return!1;try{Do(r.splice(0))}catch(e){console.error(`[assistant-ui] Detached voice setup cleanup threw`,e)}return!0};try{let e=`listening`;if(this.voice=this._toVoiceSessionState(n,n.status,e),this._voiceVolume=0,this.host.notify(),i()||(r.push(n.onStatusChange(t=>{if(this._voiceSession===n){if(t.type===`ended`){this._voiceSession=void 0,this.voice=void 0,this._voiceVolume=0;try{Do([()=>this._finishVoiceAssistantMessage(!1),()=>{this._voiceSession===void 0&&this.host.onDisconnected()},()=>L(this._voiceVolumeSubscribers,void 0,`Voice volume`),()=>this.host.notify()])}finally{i()}}else this.voice=this._toVoiceSessionState(n,t,e),this.host.notify()}})),i())||(r.push(n.onModeChange(t=>{this._voiceSession===n&&(e=t,this.voice&&(this.voice=E(E({},this.voice),{},{mode:t}),this.host.notify()))})),i())||(r.push(n.onVolumeChange(e=>{this._voiceSession===n&&(this._voiceVolume=e,L(this._voiceVolumeSubscribers,void 0,`Voice volume`))})),i()))return;r.push(n.onTranscript(e=>{this._voiceSession===n&&this._handleVoiceTranscript(e)})),i()||this.host.onConnected()}catch(e){if(this._voiceSession===n&&this._voiceUnsubs===r){try{this._disconnectVoice(!1)}catch(e){console.error(`[assistant-ui] Voice rollback cleanup threw`,e)}t&&this._voiceSession===void 0&&this.host.onDisconnected()}else i();throw e}}_observeVoiceCommit(e){new Promise(t=>t(e())).catch(e=>{console.error(`[assistant-ui] Voice message commit failed`,e)})}_handleVoiceTranscript(e){let t=this._voiceSession;if(this.host.ensureInitialized(),this._voiceSession===t){if(e.role===`user`){if(this._finishVoiceAssistantMessage(),this._voiceSession!==t)return;this._currentAssistantMsg=null,e.isFinal&&this._observeVoiceCommit(()=>this._commitVoiceUserMessage({id:g(),role:`user`,content:[{type:`text`,text:e.text}],metadata:{modality:`voice`,custom:{}},createdAt:new Date,attachments:[]}))}else{let t=e.isFinal?{type:`complete`,reason:`stop`}:{type:`running`};if(!this._currentAssistantMsg)this._currentAssistantMsg={id:g(),role:`assistant`,content:[{type:`text`,text:e.text}],metadata:{unstable_state:this.host.state(),unstable_annotations:[],unstable_data:[],steps:[],modality:`voice`,custom:{}},status:t,createdAt:new Date},this.voiceMessages.push(this._currentAssistantMsg);else{let n=this.voiceMessages.indexOf(this._currentAssistantMsg);if(n===-1)return;let r=E(E({},this._currentAssistantMsg),{},{content:[{type:`text`,text:e.text}],status:t});this.voiceMessages[n]=r,this._currentAssistantMsg=r}if(e.isFinal){let e=this._currentAssistantMsg;this._observeVoiceCommit(()=>this.host.commitVoiceMessage(e)),this._currentAssistantMsg=null}this.host.markVoiceMessagesDirty(),this.host.notify()}}}_commitVoiceUserMessage(e){this.voiceMessages.push(e);try{return this.host.commitVoiceMessage(e)}finally{this.host.markVoiceMessagesDirty(),this.host.notify()}}appendToVoiceSession(e){var t=this;return w(function*(){var n,r,i,a,o;let s=t._voiceSession;if(!((n=t.voice)!=null&&n.canSendText)||!(s!=null&&s.sendText))throw Error(`Cannot send a text message while a voice session is connected`);let c=e.content.filter(e=>e.type===`text`);if(e.role!==`user`||e.sourceId!=null||e.parentId!==t.host.resolveAppendParent((r=(i=t.host.messages().at(-1))==null?void 0:i.id)==null?null:r)||(a=e.attachments)!=null&&a.length||c.length!==e.content.length||!c.some(e=>e.text.trim()))throw Error(`Only a plain text user message can be sent while a voice session is connected`);let l=t.host.enrichAppendMetadata(e);t.host.ensureInitialized();let u=t.host.captureGeneration();try{yield s.sendText(R(e))}catch(e){if(u.aborted)return;let t=new Mc;throw t.cause=e,t}if(!u.aborted){if(t._voiceSession!==s||(t._finishVoiceAssistantMessage(!1),t._voiceSession!==s))throw new Mc(`The voice session ended before the typed message was recorded`);t._currentAssistantMsg=null,yield t._commitVoiceUserMessage({id:g(),role:`user`,content:c,metadata:{custom:E({},(o=l.metadata)==null?void 0:o.custom)},createdAt:e.createdAt,attachments:[]})}})()}_finishVoiceAssistantMessage(e=!0){let t=this.voiceMessages.at(-1);if((t==null?void 0:t.role)===`assistant`&&t.status.type===`running`){let n=this.voiceMessages.length-1;this.voiceMessages[n]=E(E({},t),{},{status:{type:`complete`,reason:`stop`}}),this._observeVoiceCommit(()=>this.host.commitVoiceMessage(this.voiceMessages[n])),this._currentAssistantMsg=null,this.host.markVoiceMessagesDirty(),e&&this.host.notify()}}disconnectVoice(){this._disconnectVoice(!0)}_disconnectVoice(e){this._finishVoiceAssistantMessage(!1),this._currentAssistantMsg=null;let t=this._voiceUnsubs.splice(0);this._voiceUnsubs=[];let n=this._voiceSession;this._voiceSession=void 0,this.voice=void 0,this._voiceVolume=0;let r=this.host.stopSpeakingForVoiceMessage();this.voiceMessages=[],this.host.markVoiceMessagesDirty();try{Do([...t,...r?[r]:[],...n?[()=>n.disconnect()]:[],()=>L(this._voiceVolumeSubscribers,void 0,`Voice volume`),()=>this.host.notify()])}finally{e&&n&&this._voiceSession===void 0&&this.host.onDisconnected()}}muteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.mute(),this.voice=E(E({},this.voice),{},{isMuted:!0}),this.host.notify()}unmuteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.unmute(),this.voice=E(E({},this.voice),{},{isMuted:!1}),this.host.notify()}},Dp=class extends jo{get _voiceMessages(){return this._voiceController.voiceMessages}set _voiceMessages(e){this._voiceController.voiceMessages=e}get _voiceGeneration(){return this._voiceController.voiceGeneration}set _voiceGeneration(e){this._voiceController.voiceGeneration=e}_markVoiceMessagesDirty(){this._voiceController.markMessagesDirty()}_getBaseMessages(){return this.repository.getMessages()}_commitVoiceMessage(e){}_onMessageMetadataChanged(e,t){}_dropVoiceMessage(e,t){this._voiceController.dropMessage(e,t)}get messages(){return this._voiceController.getMessages()}get state(){var e;let t;for(let e of this.messages)e.role===`assistant`&&(t=e);return(e=t==null?void 0:t.metadata.unstable_state)==null?null:e}constructor(e){super(),S(this,`_isInitialized`,!1),S(this,`repository`,new El),S(this,`_voiceController`,new Ep({adapter:()=>{var e;return(e=this.adapters)==null?void 0:e.voice},isRunning:()=>this.isRunning===!0,isRunActive:()=>this._isRunActive(),isLoading:()=>this.isLoading,getBaseMessages:()=>this._getBaseMessages(),messages:()=>this.messages,state:()=>this.state,notify:()=>this._notifySubscribers(),subscribe:e=>this.subscribe(e),captureGeneration:()=>Vf(this),ensureInitialized:()=>this.ensureInitialized(),commitVoiceMessage:e=>this._commitVoiceMessage(e),markVoiceMessagesDirty:()=>this._markVoiceMessagesDirty(),onConnected:()=>this._onVoiceConnected(),onDisconnected:()=>this._onVoiceDisconnected(),enrichAppendMetadata:e=>this.enrichAppendMetadata(e),resolveAppendParent:e=>this._resolveAppendParent(e),stopSpeakingForVoiceMessage:()=>this.speech&&this._isVoiceMessage(this.speech.messageId)?this._stopSpeaking:void 0})),S(this,`composer`,new wp(this)),S(this,`_contextProvider`,void 0),S(this,`_editComposers`,new Map),S(this,`_editAttempts`,new WeakMap),S(this,`_stopSpeaking`,void 0),S(this,`_replacingSpeech`,!1),S(this,`speech`,void 0),S(this,`getVoiceVolume`,()=>this._voiceController.getVoiceVolume()),S(this,`subscribeVoiceVolume`,e=>this._voiceController.subscribeVoiceVolume(e)),S(this,`_eventSubscribers`,new Map),this._contextProvider=e,Wf(this).addEventListener(`abort`,()=>{this.composer.__internal_dispose();for(let e of this._editComposers.values())e.__internal_dispose()})}getModelContext(){return this._contextProvider.getModelContext()}enrichAppendMetadata(e,t=e.parentId){var n;if(e.role!==`user`)return e;let r=this.messages,i=t===null?-1:r.findIndex(e=>e.id===t),a=je(this.getModelContext().unstable_composerMetadata,r.slice(0,i+1));return a?E(E({},e),{},{metadata:E(E({},e.metadata),{},{custom:E(E({},(n=e.metadata)==null?void 0:n.custom),a)})}):e}getEditComposer(e){return this._editComposers.get(e)}__internal_getEditComposers(){return this._editComposers.values()}_isVoiceMessage(e){return this._voiceController.isVoiceMessage(e)}_resolveAppendParent(e){var t,n;return this._isVoiceMessage(e)?(t=(n=this._getBaseMessages().at(-1))==null?void 0:n.id)==null?null:t:e}beginEdit(e){if(this.voice)throw Error(`Cannot edit a message while a voice session is connected`);if(this._isVoiceMessage(e))throw Error(`Voice transcript messages cannot be edited`);if(this._editComposers.has(e))throw Error(`Edit already in progress`);let t=this.repository.getMessage(e),n=this.repository,r=Vf(this),i={};this._editAttempts.set(t.message,i);let a=(o,s)=>{let c=new Tp(this,()=>this._editComposers.delete(e),{parentId:t.parentId,message:o,onMessageNotSent:o=>{var s;let c=this.getMessageById(e);r.aborted||this.repository!==n||this._editAttempts.get(t.message)!==i||this._editComposers.has(e)||(c==null?void 0:c.message)!==t.message||c.parentId!==t.parentId||!this.messages.includes(t.message)||this.voice||a(Yc(o,e,{type:`complete`,reason:`unknown`}),(s=o.runConfig)==null?{}:s)}});c.setRunConfig(s),this._editComposers.set(e,c),this._notifySubscribers()};a(t.message,E({},this.composer.runConfig))}getMessageById(e){try{return this.repository.getMessage(e)}catch(r){var t,n;let i=this.repository.getMessages(),a=this._voiceMessages.findIndex(t=>t.id===e);return a===-1?void 0:{parentId:a>0?this._voiceMessages[a-1].id:(t=(n=i.at(-1))==null?void 0:n.id)==null?null:t,message:this._voiceMessages[a],index:i.length+a}}}getBranches(e){return this._voiceMessages.some(t=>t.id===e)?[]:this.repository.getBranches(e)}switchToBranch(e){this.repository.switchToBranch(e),this._notifySubscribers()}_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);n&&L(n,t,`Thread runtime "${e}"`)}_notifyToolApprovalAnswered(e,t,n,r){this._notifyEventSubscribers(`toolApprovalAnswered`,{messageId:e,toolCallId:t,toolName:n,approved:r})}submitFeedback({messageId:e,type:t,comment:n}){var r;let i=(r=this.adapters)==null?void 0:r.feedback,a=this.getMessageById(e);if(!a)throw Error(`Message not found: ${e}`);let{message:o,parentId:s}=a,c=n==null?void 0:n.trim(),l=E({type:t},c?{comment:c}:void 0);if(i==null||i.submit(E({message:o},l)),o.role===`assistant`){let t=E(E({},o),{},{metadata:E(E({},o.metadata),{},{submittedFeedback:l})}),n=this._voiceMessages.findIndex(t=>t.id===e);n===-1?(this.repository.addOrUpdateMessage(s,t),this._onMessageMetadataChanged(o,t)):(this._voiceMessages[n]=t,this._voiceController.replaceAssistantMessage(o,t),this._markVoiceMessagesDirty())}this._notifySubscribers()}speak(e){var t;let n=(t=this.adapters)==null?void 0:t.speech;if(!n)throw Error(`Speech adapter not configured`);let r=this.getMessageById(e);if(!r)throw Error(`Message not found: ${e}`);let{message:i}=r;if(this._replacingSpeech)return;let a=this._stopSpeaking,o;try{this._replacingSpeech=!0;try{a==null||a()}finally{this._replacingSpeech=!1}o=n.speak(R(i))}catch(e){if(a&&!this._stopSpeaking)try{this._notifySubscribers()}catch(e){console.error(`[assistant-ui] Speech rollback notification threw`,e)}throw e}let s,c=()=>{this._stopSpeaking=void 0,this.speech=void 0;let e=s;s=void 0,e==null||e()},l=()=>{if(this._stopSpeaking===l)try{c()}finally{o.cancel()}},u=()=>{this._stopSpeaking===l&&(o.status.type===`ended`?Do([c,()=>this._notifySubscribers()]):(this.speech={messageId:e,status:o.status},this._notifySubscribers()))};this._stopSpeaking=l;try{if(s=o.subscribe(u),this._stopSpeaking!==l){s();return}u()}catch(e){if(this._stopSpeaking===l)try{Do([l,()=>this._notifySubscribers()])}catch(e){console.error(`[assistant-ui] Speech rollback cleanup threw`,e)}throw e}}stopSpeaking(){if(!this._stopSpeaking)throw Error(`No message is being spoken`);Do([this._stopSpeaking,()=>this._notifySubscribers()])}get voice(){return this._voiceController.voice}set voice(e){this._voiceController.voice=e}_onVoiceConnected(){}_onVoiceDisconnected(){}_isRunActive(){return this._voiceController.isRunActive()}_getVoiceCommitBarrier(){return this._voiceController.getVoiceCommitBarrier()}connectVoice(){this._voiceController.connectVoice()}_appendToVoiceSession(e){var t=this;return w(function*(){return t._voiceController.appendToVoiceSession(e)})()}disconnectVoice(){this._voiceController.disconnectVoice()}muteVoice(){this._voiceController.muteVoice()}unmuteVoice(){this._voiceController.unmuteVoice()}ensureInitialized(){return!this._isInitialized&&(this._isInitialized=!0,this._notifyEventSubscribers(`initialize`,{}),!0)}export(){return this.repository.export()}import(e){this.ensureInitialized(),this.repository.clear(),this.repository.import(e),this._notifySubscribers()}reset(e){this.import(Sl.fromArray(e==null?[]:e))}unstable_on(e,t){var n,r,i;let a=t;if(e===`modelContextUpdate`)return(n=(r=(i=this._contextProvider).subscribe)==null?void 0:r.call(i,()=>L([a],{},`Thread runtime "${e}"`)))==null?(()=>{}):n;let o=this._eventSubscribers.get(e);return o||(o=new Set,this._eventSubscribers.set(e,o)),o.add(a),e===`initialize`&&this._isInitialized&&queueMicrotask(()=>{o.has(a)&&L([a],{},`Thread runtime "${e}"`)}),()=>{var t;(t=this._eventSubscribers.get(e))==null||t.delete(a)}}},Op=class{constructor(){S(this,`pending`,void 0)}get isLoading(){return this.pending!==void 0}load(e,t,n){if(this.pending)return this.pending;if(!e)return Promise.resolve();let r=Promise.resolve().then(()=>e()).catch(t).finally(()=>{this.pending=void 0,n(!1)});return this.pending=r,n(!0),r}},kp=Symbol.for(`assistant-stream.tool-execution-id`),Ap=Promise.resolve(),jp=e=>{try{return JSON.parse(e),!0}catch(e){return!1}},Mp=e=>{try{return JSON.parse(e)}catch(e){return}},Np=(e,t)=>{let n=Mp(e),r=Mp(t);return n===void 0||r===void 0?!1:pe(n,r)},Pp=e=>e.result!==void 0&&e.isPreliminary!==!0,Fp=e=>e[kp],Ip=class{constructor(e,t,n){S(this,`_getTools`,void 0),S(this,`_callbacks`,void 0),S(this,`_isClientToolCall`,void 0),S(this,`_entries`,new Map),S(this,`_humanInput`,new Map),S(this,`_executing`,new Set),S(this,`_discardedToolCallIds`,new Set),S(this,`_settledResolvers`,[]),S(this,`_statuses`,new Map),S(this,`_ac`,new AbortController),S(this,`_retiredAc`,void 0),S(this,`_pendingRestore`,!0),S(this,`_lastSnapshot`,null),S(this,`_isRunning`,!1),S(this,`_controller`,void 0),S(this,`_pipelineDead`,!1),S(this,`_pipelineRestartUsed`,!1),this._getTools=e,this._callbacks=t,this._isClientToolCall=n,this._initPipeline()}_initPipeline(){let[e,t]=oc();this._controller=t;let n=Ac(()=>this._getWrappedTools(),()=>this._ac.signal,(e,t,n)=>this._onHumanInput(e,t,n),{onExecutionStart:(e,t,n)=>this._onExecutionStart(e,n),onExecutionEnd:(e,t,n)=>this._onExecutionEnd(e,n)});e.pipeThrough(n).pipeThrough(new sc).pipeTo(new WritableStream({write:e=>{try{if(e.type!==`result`)return;this._handleResultChunk(e)}catch(e){console.error(`[ToolInvocationTracker] result chunk handling failed`,e)}}})).catch(e=>{console.error(`[ToolInvocationTracker] stream pipeline failed; will attempt single restart on next setState`,e),this._pipelineDead=!0})}setState(e){try{if(this._pipelineDead){if(this._pipelineRestartUsed)return;this._pipelineRestartUsed=!0,this._pipelineDead=!1;let e=new Set;for(let[t,n]of this._entries)n.executionId&&this._executing.has(n.executionId)&&e.add(t);this._demoteEntriesToRestored(),this._executing.clear(),this._humanInput.size===0?this._ac.abort():this._retiredAc=this._ac,this._ac=new AbortController;let t=new Map(this._statuses);for(let n of e)this._humanInput.has(n)||t.delete(n);t.size!==this._statuses.size&&(this._statuses=t,this._invokeOnStatusesChange()),this._resolveSettledResolvers(),this._initPipeline()}if(this._lastSnapshot&&this._lastSnapshot.messages===e.messages&&this._lastSnapshot.isRunning===e.isRunning&&this._lastSnapshot.isLoading===e.isLoading)return;e.isLoading===!0&&(this._pendingRestore=!0);let t=this._isRunning;this._isRunning=e.isRunning;try{this._processMessages(e.messages,e.discardedToolCallIds)}catch(e){throw this._isRunning=t,e}this._lastSnapshot=e,this._pendingRestore=!1}catch(e){console.error(`[ToolInvocationTracker] setState failed; snapshot dropped`,e)}}reset(){try{this._pendingRestore=!0,this._entries.clear(),this._discardedToolCallIds.clear(),this._lastSnapshot=null,this.abort(),this._statuses.size>0&&(this._statuses=new Map,this._invokeOnStatusesChange())}catch(e){console.error(`[ToolInvocationTracker] reset failed`,e)}}abort(e){try{var t;if(this._humanInput.forEach(({executionId:e,reject:t},n)=>{try{t(Error(`Tool execution aborted`))}catch(e){}this._endHumanRequest(n,e)}),this._humanInput.clear(),e!=null&&e.discardPending)for(let[e,t]of this._entries)t.controller&&(t.hasResult||t.executeStarted||(this._discardedToolCallIds.add(e),t.skipExecute=!0,t.discarded=!0));if((t=this._retiredAc)==null||t.abort(),this._retiredAc=void 0,this._ac.abort(),this._ac=new AbortController,this._executing.size===0)return Ap;let n=new Set(this._executing);return new Promise(e=>{this._settledResolvers.push({executionIds:n,resolve:e})})}catch(e){return console.error(`[ToolInvocationTracker] abort failed`,e),Ap}}_endHumanRequest(e,t){var n;if(this._executing.has(t)){this._setStatus(e,{type:`executing`});return}let r=(n=this._entries.get(e))==null?void 0:n.executionId;(r===void 0||r===t)&&this._deleteStatus(e)}resume(e,t){try{let n=this._humanInput.get(e);return n?(this._humanInput.delete(e),this._endHumanRequest(e,n.executionId),n.resolve(t),!0):!1}catch(e){return console.error(`[ToolInvocationTracker] resume failed`,e),!1}}getStatuses(){return this._statuses}_getWrappedTools(){let e=this._getTools();if(e)return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.execute,r=t.streamCall;return n===void 0&&r===void 0?[e,t]:[e,E(E(E({},t),n!==void 0&&{execute:(...[e,t])=>{let r=Fp(t),i=this._captureExecution(t.toolCallId,r);return!i||i.skipExecute?new Promise(()=>{}):(i.executeStarted=!0,n(e,t))}}),r!==void 0&&{streamCall:(...[e,t])=>{let n=Fp(t),i=this._captureExecution(t.toolCallId,n);if(i&&!i.discarded)return r(e,t)}})]}))}_captureExecution(e,t){if(t===void 0)return;let n=this._entries.get(e);if(n!=null&&n.controller)return n.executionId===void 0&&(n.executionId=t),n.executionId===t?n:void 0}_onHumanInput(e,t,n){return new Promise((r,i)=>{let a=this._entries.get(e);if(!(a!=null&&a.controller)||a.executionId!==n){i(Error(`Tool execution aborted`));return}let o=this._humanInput.get(e);if(o)try{o.reject(Error(`Human input request was superseded by a new request`))}catch(e){}this._humanInput.set(e,{executionId:n,resolve:r,reject:i}),this._setStatus(e,{type:`interrupt`,payload:{type:`human`,payload:t}})})}_onExecutionStart(e,t){var n;this._captureExecution(e,t)&&(this._entries.get(e).skipExecute||(this._executing.add(t),((n=this._humanInput.get(e))==null?void 0:n.executionId)!==t&&this._setStatus(e,{type:`executing`})))}_onExecutionEnd(e,t){var n;if(t===void 0||!this._executing.delete(t))return;((n=this._entries.get(e))==null?void 0:n.executionId)===t&&this._deleteStatus(e);let r=[];this._settledResolvers.forEach(({executionIds:e,resolve:t})=>{if([...e].some(e=>this._executing.has(e)))r.push({executionIds:e,resolve:t});else try{t()}catch(e){}}),this._settledResolvers.length=0,this._settledResolvers.push(...r)}_handleResultChunk(e){let t=e.meta.toolCallId,n=Fp(e),r=this._entries.get(t);r&&r.executionId===n&&(r!=null&&r.hasResult||r.skipExecute||this._invokeOnResult(E(E({type:`add-tool-result`,toolCallId:t,toolName:e.meta.toolName,result:e.result,isError:e.isError},e.artifact!==void 0&&{artifact:e.artifact}),e.modelContent!==void 0&&{modelContent:e.modelContent})))}_invokeOnResult(e){try{this._callbacks.onResult(e)}catch(e){console.error(`[ToolInvocationTracker] onResult callback threw; result dropped`,e)}}_invokeOnStatusesChange(){try{this._callbacks.onStatusesChange(this._statuses)}catch(e){console.error(`[ToolInvocationTracker] onStatusesChange callback threw; status change not propagated`,e)}}_setStatus(e,t){let n=new Map(this._statuses);n.set(e,t),this._statuses=n,this._invokeOnStatusesChange()}_deleteStatus(e){if(!this._statuses.has(e))return;let t=new Map(this._statuses);t.delete(e),this._statuses=t,this._invokeOnStatusesChange()}_resolveSettledResolvers(){let e=this._settledResolvers.splice(0);for(let{resolve:t}of e)try{t()}catch(e){}}_warnProviderOwnedSkip(e,t){var n;process.env.NODE_ENV!==`production`&&((n=this._getTools())==null||(n=n[e])==null?void 0:n.execute)!==void 0&&console.warn(`[ToolInvocationTracker] the runtime reports this tool call as provider-owned, so the registered execute is skipped; the provider has to hand the call to the client for it to run (see EDGE_CASES.md A.9)`,{toolCallId:t,toolName:e})}_shouldCloseArgsStream({argsText:e,hasResult:t,clientOwned:n}){return t?!0:jp(e)?n||!this._isRunning:!1}_startActiveEntry(e,t,n,r,i){let a={toolName:t,controller:this._controller.addToolCallPart({toolName:t,toolCallId:e}),argsText:``,hasResult:!1,skipExecute:n,discarded:r,argsComplete:!1,clientOwned:i};return this._entries.set(e,a),a}_demoteEntriesToRestored(){for(let[e,t]of this._entries)t.controller&&(!t.argsComplete&&!t.hasResult?this._entries.delete(e):this._entries.set(e,{toolName:t.toolName,argsText:t.argsText,hasResult:t.hasResult}))}_processArgsText(e,t){if(!e.controller)return;let n=t.result!==void 0;if(t.argsText!==e.argsText){let r=!0;if(e.argsComplete)Np(e.argsText,t.argsText)?(e.argsText=t.argsText,r=!1):(process.env.NODE_ENV!==`production`&&console.warn(`[ToolInvocationTracker] argsText changed after first completion; not re-firing streamCall (see EDGE_CASES.md A.4)`,{previous:e.argsText,next:t.argsText,toolCallId:t.toolCallId}),e.argsText=t.argsText,r=!1);else if(!t.argsText.startsWith(e.argsText)){if(jp(e.argsText)&&jp(t.argsText)&&Np(e.argsText,t.argsText)){let i=this._shouldCloseArgsStream({argsText:t.argsText,hasResult:n,clientOwned:e.clientOwned});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i,r=!1}else process.env.NODE_ENV!==`production`&&console.warn(`[ToolInvocationTracker] argsText regressed mid-stream; not restarting (see EDGE_CASES.md A.2)`,{previous:e.argsText,next:t.argsText,toolCallId:t.toolCallId}),r=!1}if(r&&e.controller){let r=t.argsText.slice(e.argsText.length);e.controller.argsText.append(r);let i=this._shouldCloseArgsStream({argsText:t.argsText,hasResult:n,clientOwned:e.clientOwned});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i}}!e.argsComplete&&e.controller&&this._shouldCloseArgsStream({argsText:e.argsText,hasResult:n,clientOwned:e.clientOwned})&&(e.controller.argsText.close(),e.argsComplete=!0)}_processMessages(e,t){let n=this._pendingRestore;for(let{part:i}of fp(e)){let e=this._entries.get(i.toolCallId);if(n){e!=null&&e.controller||this._entries.set(i.toolCallId,{toolName:i.toolName,argsText:i.argsText,hasResult:Pp(i)});continue}let a=e,o=this._discardedToolCallIds.has(i.toolCallId);if(Pp(i)&&this._discardedToolCallIds.delete(i.toolCallId),a&&!a.controller){if(a.hasResult||(i.argsText===a.argsText||jp(a.argsText)&&jp(i.argsText)&&Np(a.argsText,i.argsText))&&!Pp(i))continue;this._entries.delete(i.toolCallId),a=void 0}if(!a){var r;let e=o||(t==null?void 0:t.has(i.toolCallId))===!0;e&&!Pp(i)&&this._discardedToolCallIds.add(i.toolCallId);let n=(r=this._isClientToolCall)==null?void 0:r.call(this,i),s=i.result===void 0&&n===!1;s&&this._warnProviderOwnedSkip(i.toolName,i.toolCallId),a=this._startActiveEntry(i.toolCallId,i.toolName,i.result!==void 0||s||e,e,n===!0)}if(i.result!==void 0&&(a.skipExecute=!0),i.approval!==void 0&&(a.skipExecute=!0),this._processArgsText(a,i),i.result!==void 0&&!a.hasResult){let{controller:e}=a;if(!e)continue;a.argsComplete=!0,e.setResponse(new Hs(E({result:i.result,artifact:i.artifact,isError:i.isError,isPreliminary:i.isPreliminary},i.modelContent===void 0?{}:{modelContent:i.modelContent}))),Pp(i)&&(a.hasResult=!0,e.close())}}}},Lp=Object.freeze([]),Rp=new WeakMap,zp=(e,t)=>(e==null?void 0:e.type)===(t==null?void 0:t.type)&&(e==null?void 0:e.comment)===(t==null?void 0:t.comment),Bp=new WeakMap,Vp=(e,t)=>{Promise.resolve(t).catch(t=>{console.error(`[ExternalStoreThreadRuntimeCore] ${e} callback rejected`,t)})},Hp=(e,t)=>{var n;return e&&((n=t[t.length-1])==null?void 0:n.role)!==`assistant`},Up=class extends Dp{get capabilities(){return this._capabilities}get isLoading(){var e;return(e=this._store.isLoading)!=null&&e}_clearPendingResume(e){e&&this._pendingResume===e&&(this._pendingResume=void 0,this._notifySubscribers())}get canResume(){return!!this._store.canResume&&!!this._store.onResume&&!this._pendingResume&&!this.isDisabled&&!Pf(this)&&!this.isLoading&&!this.voice}get hasEarlier(){return this._store.hasEarlier===!0&&this._store.onLoadEarlier!==void 0}get isLoadingEarlier(){return this._loadEarlier.isLoading}loadEarlier(){let e=this._store.onLoadEarlier;return this._loadEarlier.load(this.hasEarlier?e:void 0,e=>{console.error(`[ExternalStoreThreadRuntimeCore] onLoadEarlier callback rejected`,e)},()=>this._notifySubscribers())}get isRunning(){return this._hasExecutingTools(this._store)?!0:this._store.isRunning}_getBaseMessages(){return this._messages}get state(){var e;return(e=this._store.state)==null?super.state:e}get adapters(){return this._store.adapters}get unstable_refetchThread(){if(this._store.onRefetchThread)return()=>this._store.onRefetchThread()}_openDeleteWindow(e){let t=this.repository.getMessages(),n=t.findIndex(t=>t.id===e)+1,r={prefix:new Set(t.slice(0,n).map(e=>e.id)),suffix:new Set(t.slice(n).map(e=>e.id))};if(r.suffix.size===0)return r;this._pendingDeleteWindows.add(r);for(let[e,t]of this._pendingDeleteEvictions)r.prefix.has(e)||(t.calls.size>0?t.reloaded=!0:this._pendingDeleteEvictions.delete(e));return r}_closeDeleteWindows(e){for(let t of this._pendingDeleteWindows)[...t.suffix].every(t=>!e.has(t))&&this._pendingDeleteWindows.delete(t)}__internal_setGetInitializePromise(e){this._getInitializePromise=e}_onMessageMetadataChanged(e,t){if(this._storeMessages=this._storeMessages.map(e=>e.id===t.id?t:e),t.id.startsWith(`__external_store_fallback_`))return;let n=this._submittedFeedback.get(t.id),r=n&&zp(e.metadata.submittedFeedback,n.feedback)?n.external:e.metadata.submittedFeedback,i=t.metadata.submittedFeedback;i&&this._submittedFeedback.set(t.id,{feedback:i,external:r,source:(n==null?void 0:n.message)===e?n.source:e,message:t})}_applySubmittedFeedback(e){if(this._submittedFeedback.size===0)return e;for(let e of this._submittedFeedback.keys())try{this.repository.getMessage(e)}catch(t){this._submittedFeedback.delete(e)}return e.map(e=>{let t=this._submittedFeedback.get(e.id);if(!t)return e;if(e.role!==`assistant`||!zp(e.metadata.submittedFeedback,t.external))return this._submittedFeedback.delete(e.id),e;if(t.source===e)return t.message;let n=E(E({},e),{},{metadata:E(E({},e.metadata),{},{submittedFeedback:t.feedback})});return t.source=e,t.message=n,n})}_runTrackerUpdate(e){this._inTrackerUpdate=!0;try{e()}finally{this._inTrackerUpdate=!1}this._pendingRunningRefresh&&(this._pendingRunningRefresh=!1,this._refreshEffectiveIsRunning())}_refreshEffectiveIsRunning(){this._effectiveIsRunning!==this._getEffectiveIsRunning(this._store)&&this._updateStoreSnapshot(this._store,!1)}_hasExecutingTools(e){if(e.unstable_enableToolInvocations!==!0||this._toolInvocations===null)return!1;for(let e of this._toolStatuses.values())if(e.type===`executing`)return!0;return!1}_getEffectiveIsRunning(e){var t;return(t=e.isRunning)!=null&&t||this._hasExecutingTools(e)}beginEdit(e){if(!this._store.onEdit)throw Error(`Runtime does not support editing.`);super.beginEdit(e)}constructor(e,t){super(e),S(this,`_capabilities`,{switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,delete:!1,reload:!1,refetchThread:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1,answerToolCall:!1}),S(this,`_messages`,void 0),S(this,`isDisabled`,void 0),S(this,`isSendDisabled`,void 0),S(this,`_pendingResume`,void 0),S(this,`_loadEarlier`,new Op),S(this,`suggestions`,[]),S(this,`extras`,void 0),S(this,`_converter`,new Vd),S(this,`_createdAtById`,new Map),S(this,`_submittedFeedback`,new Map),S(this,`_pendingDeleteEvictions`,new Map),S(this,`_pendingDeleteWindows`,new Set),S(this,`_optimistic`,null),S(this,`_storeMessages`,[]),S(this,`_importedMessageIds`,void 0),S(this,`_runStartLeases`,new dp),S(this,`_runCancellationLeases`,new dp),S(this,`_cancelRunResyncLeases`,new dp),S(this,`_cancelledToolTurn`,null),S(this,`_cancelledRunIds`,new Set),S(this,`_pendingCancelResyncs`,new Set),S(this,`_movedLeaf`,void 0),S(this,`_store`,void 0),S(this,`_getInitializePromise`,void 0),S(this,`_queueDispatchTransform`,e=>{var t,n;let r=this._transformedQueue&&Al(this._transformedQueue);if(r&&Wf(this).aborted&&r!==this._queueDispatchTransform)return r(e);let i=r?void 0:Rp.get(e),a=i&&!Wf(i).aborted?i:this;a._pendingDeleteWindows.clear(),a._settleCancelResyncs();let o=(t=(n=a.messages.at(-1))==null?void 0:n.id)==null?null:t;return a.enrichAppendMetadata(E(E({},e),{},{parentId:o}),o)}),S(this,`_transformedQueue`,void 0),S(this,`_toolInvocations`,null),S(this,`_toolStatuses`,new Map),S(this,`_effectiveIsRunning`,!1),S(this,`_inTrackerUpdate`,!1),S(this,`_pendingRunningRefresh`,!1),S(this,`_toolCallToMessageId`,new Map),S(this,`_messagesForToolCallIndex`,null),S(this,`updateMessages`,e=>{var t,n,r,i;this._storeMessages=e,this._store.convertMessage===void 0?(r=(i=this._store).setMessages)==null||r.call(i,e):(t=(n=this._store).setMessages)==null||t.call(n,e.flatMap(el))}),this.__internal_setAdapter(t)}__internal_setAdapter(e){this._store!==e&&this._updateStoreSnapshot(e)}_evictPlaceholder(){if(this._optimistic){try{this.repository.getMessage(this._optimistic.id)}catch(e){return}this.repository.deleteMessage(this._optimistic.id)}}_updateStoreSnapshot(e,t=!0,n=!1){var r,i,a,o,s,c,l,u,d,f,p,m;let h=this._effectiveIsRunning;this.isDisabled=(r=e.isDisabled)!=null&&r,this.isSendDisabled=(i=e.isSendDisabled)!=null&&i;let _=this._store;this._store=e;let v=this._getEffectiveIsRunning(e),y=e.unstable_messageRepositoryInstance,b=y!==void 0&&y!==this.repository;if(b){var x,S;this.repository=y,this._createdAtById.clear(),this._cancelledToolTurn=null,this._cancelledRunIds.clear(),this._pendingResume=void 0,this._pendingDeleteEvictions.clear(),this._pendingDeleteWindows.clear(),this._submittedFeedback.clear(),this._movedLeaf=void 0;let e=this.repository.getMessages(),t=e.at(-1);this._optimistic=t!=null&&t.metadata.isOptimistic?{id:t.id,parentId:(x=(S=e.at(-2))==null?void 0:S.id)==null?null:x}:null}if((_==null?void 0:_.queue)!==e.queue){var C,w,T;this._transformedQueue=void 0,(C=e.queue)==null||(w=C.__internal_setDispatchTransform)==null||w.call(C,this._queueDispatchTransform),(T=e.queue)!=null&&T.__internal_setDispatchTransform&&(this._transformedQueue=e.queue)}this.extras!==e.extras&&(this.extras=e.extras);let D=(a=e.suggestions)==null?Lp:a;ma(this.suggestions,D)||(this.suggestions=D);let O={switchToBranch:this._store.setMessages!==void 0,switchBranchDuringRun:!1,edit:this._store.onEdit!==void 0,delete:this._store.onDelete!==void 0||this._store.setMessages!==void 0,reload:this._store.onReload!==void 0,refetchThread:this._store.onRefetchThread!==void 0,cancel:this._store.onCancel!==void 0,speech:((o=this._store.adapters)==null?void 0:o.speech)!==void 0,dictation:((s=this._store.adapters)==null?void 0:s.dictation)!==void 0,voice:((c=this._store.adapters)==null?void 0:c.voice)!==void 0,unstable_copy:((l=this._store.unstable_capabilities)==null?void 0:l.copy)!==!1,attachments:!!((u=this._store.adapters)!=null&&u.attachments),feedback:!!((d=this._store.adapters)!=null&&d.feedback),queue:this._store.queue!==void 0,answerToolCall:this._store.onAddToolResult!==void 0||this._store.onResumeToolCall!==void 0||this._store.onRespondToToolApproval!==void 0||this._store.unstable_enableToolInvocations===!0};ma(this._capabilities,O)||(this._capabilities=O);let k,A=!1,j=!1;if(e.messageRepository){var M,N,P;if(this._importedMessageIds=void 0,!n&&_&&!b&&_.isRunning===e.isRunning&&_.messageRepository===e.messageRepository&&h===v){t&&this._pendingDeleteWindows.size>0&&this._closeDeleteWindows(new Set(e.messageRepository.messages.map(({message:e})=>e.id))),this._notifySubscribers();return}let r=e.messageRepository.messages;t&&this._pendingDeleteWindows.size>0&&this._closeDeleteWindows(new Set(r.map(({message:e})=>e.id)));let i=(M=(N=e.messageRepository.headId)==null?(P=r.at(-1))==null?void 0:P.message.id:N)==null?null:M;if(this._evictPlaceholder(),_&&!n&&!b&&_.messageRepository===e.messageRepository)this.repository.import({headId:i,messages:[]}),k=this.repository.getMessages();else{let e=new Set(r.map(({message:e})=>e.id)),t=this._applySubmittedFeedback(r.map(({message:e})=>e));for(let e=0;e<r.length;e++)this.repository.addOrUpdateMessage(r[e].parentId,t[e]);for(let{message:t}of this.repository.export().messages)e.has(t.id)||this.repository.deleteMessage(t.id);this._pendingDeleteEvictions.clear(),this.repository.import({headId:i,messages:[]}),k=this.repository.getMessages()}}else if(e.messages){if(_){if(_.convertMessage!==e.convertMessage)this._converter=new Vd;else if(!n&&!b&&_.isRunning===e.isRunning&&_.messages===e.messages&&h===v){t&&this._pendingDeleteWindows.size>0&&this._closeDeleteWindows(new Set(this._storeMessages.map(e=>e.id))),this._notifySubscribers();return}}k=e.convertMessage?this._converter.convertMessages(e.messages,(t,n,r)=>{var i,a;if(!e.convertMessage)return n;let o=r===((i=(a=e.messages)==null?void 0:a.length)==null?0:i)-1,s=`${tl}${r}`;if(t&&(t.role!==`assistant`||!vl(t.status)||t.status===xl(t.content,o,v))){if(t.id.startsWith(`__external_store_fallback_`)&&t.id!==s){let e=E(E({},t),{},{id:s});return $c(e,n),e}return t}let c=e.convertMessage(n,r);if(c.createdAt==null&&c.id!=null){var l;let e=(l=this._createdAtById.get(c.id))==null?new Date:l;this._createdAtById.set(c.id,e),c=E(E({},c),{},{createdAt:e})}let u=Yc(c,s,xl(c.content,o,v));return $c(u,n),u}):e.messages,k=nl(k,e=>{console.warn(`ExternalStoreThreadRuntimeCore: duplicate message id "${e}" in the provided messages array; keeping the last occurrence.`)}),k=this._applySubmittedFeedback(k);let r=this._importedMessageIds;A=r!==void 0&&Hd(r,k.map(e=>e.id)),A||(j=r!==void 0,this._importedMessageIds=void 0);let i=new Set(k.map(e=>e.id)),a=new Map;for(let e=1;e<k.length;e++){let t=k[e].id,n=k[e-1].id,r;try{r=this.repository.getMessage(t).parentId}catch(e){continue}if(r===n)continue;let o=this.repository.getMessages(t),s=o.findIndex(e=>e.id===n);if(s!==-1)for(let e=s+1;e<o.length-1;e++){let t=o[e];i.has(t.id)||a.set(t.id,t)}}for(let e=0;e<k.length;e++){var F;let t=k[e],n=k[e-1];this.repository.addOrUpdateMessage((F=n==null?void 0:n.id)==null?null:F,t)}for(let[e,t]of a)this._evictDeletedMessage(e,t,!1);if(this._pendingDeleteEvictions.size>0&&(_==null?void 0:_.messages)!==e.messages||t&&this._pendingDeleteWindows.size>0){let n=new Set(k.map(e=>e.id));if(t&&this._closeDeleteWindows(n),(_==null?void 0:_.messages)!==e.messages){for(let[e,t]of this._pendingDeleteEvictions)if(!t.reloaded){if(n.has(e))t.calls.size===0&&this._pendingDeleteEvictions.delete(e);else{this._pendingDeleteEvictions.delete(e);try{this.repository.getMessage(e)}catch(e){continue}this.repository.deleteMessage(e)}}}}}else throw Error(`ExternalStoreAdapter must provide either 'messages' or 'messageRepository'`);this._storeMessages=k,k.length>0&&this.ensureInitialized();let I=this._movedLeaf;if(I){if(I.generation.aborted||!I.resyncLease.isCurrent()||this.composer.text!==I.draft.text)this._movedLeaf=void 0;else{let e=k.findIndex(e=>e.id===I.id);e!==-1&&(R(k[e])===I.draft.text?e<k.length-1&&(this.composer.retractDraft(I.draft),this._movedLeaf=void 0):this._movedLeaf=void 0)}}if(this._effectiveIsRunning=v,h!==v){if(v){let e=this._cancelledToolTurn;if(e!=null&&e.lease.isCurrent()){var L,z,B;let t=k.at(-1);(t==null?void 0:t.role)===`assistant`&&e.messageIds.has(t.id)?this._cancelledToolTurn=null:((t==null?void 0:t.role)===`assistant`?(L=(z=k.at(-2))==null?void 0:z.id)==null?null:L:(B=t==null?void 0:t.id)==null?null:B)===e.parentId&&(e.parentOpen=!1)}this._notifyEventSubscribers(`runStart`,{})}else this._notifyEventSubscribers(`runEnd`,{})}let ee=null;if(Hp(v,k)){var V,te,H;let e=(V=(te=k.at(-1))==null?void 0:te.id)==null?null:V;j&&this.repository.resetHead(e),((H=this._optimistic)==null?void 0:H.parentId)!==e&&(this._optimistic={id:g(),parentId:e}),ee=this._optimistic.id,this.repository.addOrUpdateMessage(e,Yc({role:`assistant`,content:[],metadata:{isOptimistic:!0}},ee,{type:`running`}))}ee===null&&(this._optimistic=null);let U=(f=(p=ee)==null?(m=k.at(-1))==null?void 0:m.id:p)==null?null:f;e.messageRepository||A?this.repository.import({headId:U,messages:[]}):this.repository.resetHead(U);let W=this.repository.getMessages();if(this._messages&&Hd(this._messages,W)||(this._messages=W),this._voiceMessages.length>0){let e=new Set(this._messages.map(e=>e.id)),t=this._voiceMessages.filter(t=>!e.has(t.id));t.length!==this._voiceMessages.length&&(this._voiceMessages=t,this._markVoiceMessagesDirty())}t&&(b&&this._runTrackerUpdate(()=>{var e;return(e=this._toolInvocations)==null?void 0:e.reset()}),this._runTrackerUpdate(()=>this._driveToolInvocations())),this._notifySubscribers()}_driveToolInvocations(){if(!this._store.unstable_enableToolInvocations){if(this._toolInvocations){var e,t;this._toolInvocations.reset(),this._toolInvocations=null,this._toolStatuses=new Map,(e=(t=this._store).setToolStatuses)==null||e.call(t,{})}return}let n=Bp.get(this.repository);if(n||(n=this._createToolInvocations(),Bp.set(this.repository,n)),this._toolInvocations=n.tracker,n.host!==this){n.host._toolInvocations===n.tracker&&(n.host._toolInvocations=null),n.host=this;let e=n.tracker.getStatuses();(e.size>0||this._toolStatuses.size>0)&&this._applyToolStatuses(e)}let r=this._getDiscardedToolCallIds();this._toolInvocations.setState(E(E({messages:this._messages,isRunning:this._getEffectiveIsRunning(this._store)},r&&{discardedToolCallIds:r}),this._store.isLoading!==void 0&&{isLoading:this._store.isLoading}))}_getDiscardedToolCallIds(){let e=this._cancelledToolTurn;if(!e&&this._cancelledRunIds.size===0)return;let t=new Set;for(let i=0;i<this._messages.length;i++){let a=this._messages[i];if(a.role!==`assistant`||a.metadata.isOptimistic)continue;let o=a.metadata.runId;if(o===void 0||!this._cancelledRunIds.has(o)){if(!e)continue;if(!e.messageIds.has(a.id)){var n,r;if(!e.parentOpen||((n=(r=this._messages[i-1])==null?void 0:r.id)==null?null:n)!==e.parentId)continue;e.messageIds.add(a.id)}}for(let{part:e}of fp([a]))t.add(e.toolCallId)}return t}_createToolInvocations(){let e={host:this,tracker:new Ip(()=>e.host.getModelContext().tools,{onResult:t=>e.host._dispatchToolResult(t),onStatusesChange:t=>e.host._applyToolStatuses(t)},t=>{var n,r;return(n=(r=e.host._store).unstable_isClientToolCall)==null?void 0:n.call(r,t)})};return e}_dispatchToolResult(e){try{var t,n;let r=this._findMessageIdForToolCall(e.toolCallId);if(r===void 0)return;Vp(`onAddToolResult`,(t=(n=this._store).onAddToolResult)==null?void 0:t.call(n,E(E({messageId:r,toolCallId:e.toolCallId,toolName:e.toolName,result:e.result,isError:e.isError},e.artifact!==void 0&&{artifact:e.artifact}),e.modelContent!==void 0&&{modelContent:e.modelContent})))}catch(e){console.error(`[ExternalStoreThreadRuntimeCore] onAddToolResult dispatch failed`,e)}}_applyToolStatuses(e){let t=this._hasExecutingTools(this._store);this._toolStatuses=e;try{var n,r;(n=(r=this._store).setToolStatuses)==null||n.call(r,Object.fromEntries(e))}finally{t!==this._hasExecutingTools(this._store)&&(this._inTrackerUpdate?this._pendingRunningRefresh=!0:this._updateStoreSnapshot(this._store))}}_findMessageIdForToolCall(e){if(this._messagesForToolCallIndex!==this._messages){this._toolCallToMessageId.clear();for(let{part:e,messageId:t}of fp(this._messages))this._toolCallToMessageId.set(e.toolCallId,t);this._messagesForToolCallIndex=this._messages}return this._toolCallToMessageId.get(e)}switchToBranch(e){if(!this._store.setMessages)throw Error(`Runtime does not support switching branches.`);if(this._getEffectiveIsRunning(this._store))return;let t=this._store.unstable_onBranchChange,n=this._pendingResume,r=t||n?this.repository.canonicalHeadId:null;this.repository.switchToBranch(e),this._pendingDeleteWindows.clear();for(let[e,t]of this._pendingDeleteEvictions)t.calls.size>0?t.reloaded=!0:this._pendingDeleteEvictions.delete(e);this.updateMessages(this.repository.getMessages()),n&&this.repository.canonicalHeadId!==r&&this._clearPendingResume(n),t&&this._notifyBranchChange(r,t)}_notifyBranchChange(e,t){let n=this.repository.canonicalHeadId;n!==e&&t({headId:n,visibleMessageIds:this.repository.getMessages().map(e=>e.id)})}append(e){var t=this;return w(function*(){var n,r,i,a;let o=E(E({},e),{},{parentId:t._resolveAppendParent(e.parentId)});if(t.voice)return t._pendingDeleteWindows.clear(),t._appendToVoiceSession(o);if(t._isVoiceMessage(o.sourceId))throw Error(`Voice transcript messages cannot be edited`);let s=o.sourceId!=null||o.parentId!==((n=(r=t._getBaseMessages().at(-1))==null?void 0:r.id)==null?null:n),c=!s&&t._store.queue&&t._store.queue===t._transformedQueue?void 0:t.enrichAppendMetadata(o),l=Vf(t);t.ensureInitialized();let u=(i=t._getInitializePromise)==null?void 0:i.call(t);if(!s&&t._store.queue&&(u&&(yield u),l.aborted))return;let d=s?void 0:t._store.queue;if(d&&d===t._transformedQueue||(o=c==null?t.enrichAppendMetadata(o):c),d){var f;if(d===t._transformedQueue){var p;Al(d)||Rp.set(o,t),(p=d.__internal_setDispatchTransform)==null||p.call(d,t._queueDispatchTransform),kl(d)}((f=o.steer)==null?t._getEffectiveIsRunning(t._store):f)?d.steer(o):d.enqueue(o)}else{if(u==null||u.catch(()=>{}),(a=o.startRun)==null?o.role===`user`:a){var m;let e=(m=t._toolInvocations)==null?void 0:m.abort({discardPending:!0});e&&e!==Ap&&(yield e)}if(!l.aborted){if(s||t._pendingDeleteWindows.clear(),t._settleCancelResyncs(),s){if(!t._store.onEdit)throw Error(`Runtime does not support editing messages.`);let e=t._openDeleteWindow(o.parentId);try{yield t._store.onEdit(o)}catch(n){throw t._pendingDeleteWindows.delete(e),n}}else yield t._store.onNew(o)}}})()}_commitVoiceMessage(e){let t=Vf(this);if(t.aborted){this._dropVoiceMessage(e.id,!1);return}let n=this._getVoiceCommitBarrier();if(!n){var r,i;(r=(i=this._store).onVoiceTranscript)==null||r.call(i,e);return}let a=this.repository;return n.then(()=>{var n,r;t.aborted||this.repository!==a?this._dropVoiceMessage(e.id,!0):(n=(r=this._store).onVoiceTranscript)==null||n.call(r,e)})}deleteMessage(e){var t=this;return w(function*(){var n;if(t._store.onDelete){let n=t.repository.getMessages().find(t=>t.id===e),r=Symbol(),i=t._pendingDeleteEvictions.get(e);if(n){let a=!1;for(let n of t._pendingDeleteWindows)if(!n.prefix.has(e)){a=!0;break}(!i||e.startsWith(`__external_store_fallback_`)&&i.message!==n)&&(i={calls:new Set,reloaded:a,message:n}),a&&(i.reloaded=!0),i.calls.add(r),t._pendingDeleteEvictions.set(e,i)}let a=!1;try{yield t._store.onDelete(e),a=!0}finally{i&&t._pendingDeleteEvictions.get(e)===i&&i.calls.delete(r)&&(i.reloaded&&a?(i.reloaded=!1,t._storeMessages.some(t=>t.id===e)||(t._pendingDeleteEvictions.delete(e),t._evictDeletedMessage(e,i.message))):i.reloaded&&i.calls.size===0&&t._pendingDeleteEvictions.delete(e))}return}if(!t._store.setMessages)throw Error(`Runtime does not support deleting messages.`);t._getEffectiveIsRunning(t._store)&&(yield(n=t._toolInvocations)==null?void 0:n.abort());let r=t.repository.getMessages();if(r.findIndex(t=>t.id===e)===-1)throw Error(`Message not found.`);t._pendingDeleteEvictions.clear(),t.updateMessages(r.filter(t=>t.id!==e)),t._evictDeletedMessage(e)})()}_evictDeletedMessage(e,t,n=!0){if(!e.startsWith(`__external_store_fallback_`)||t){try{let n=this.repository.getMessage(e).message;if(e.startsWith(`__external_store_fallback_`)&&n!==t)return}catch(e){return}this.repository.deleteMessage(e),n&&this._publishRepositoryMessages()}}_publishRepositoryMessages(){let e=this.repository.getMessages();Hd(this._messages,e)||(this._messages=e),this._notifySubscribers()}getQueueItems(){var e,t;return(e=(t=this._store)==null||(t=t.queue)==null?void 0:t.items)==null?Dl:e}getSteerQueueItems(){var e,t;return(e=(t=this._store)==null||(t=t.queue)==null?void 0:t.steerItems)==null?Dl:e}moveQueueItem(e,t){var n;(n=this._store)==null||(n=n.queue)==null||n.move(e,t)}removeQueueItem(e){var t;(t=this._store)==null||(t=t.queue)==null||t.remove(e)}_restoreMovedLeafForRun(e){let t=this._movedLeaf;(t==null?void 0:t.id)===e&&t.resyncLease.isCurrent()&&!t.generation.aborted&&this._storeMessages.some(e=>e.id===t.id)&&(this._cancelRunResyncLeases.invalidate(),this._movedLeaf=void 0,this.composer.retractDraft(t.draft),this._updateStoreSnapshot(this._store,!1,!0))}startRun(e){var t=this;return w(function*(){var n;if(!t._store.onReload)throw Error(`Runtime does not support reloading messages.`);if(t.voice)throw Error(`Cannot start a run while a voice session is connected`);if(t._isVoiceMessage(e.sourceId))throw Error(`Voice transcript messages cannot be reloaded`);t._restoreMovedLeafForRun(e.parentId),t._runStartLeases.begin(),((n=t._cancelledToolTurn)==null?void 0:n.parentId)===e.parentId&&(t._cancelledToolTurn.parentOpen=!1);let r=t._openDeleteWindow(e.parentId),i=t._runCancellationLeases.current();try{var a;if(yield(a=t._toolInvocations)==null?void 0:a.abort({discardPending:!0}),!i.isCurrent()){t._pendingDeleteWindows.delete(r);return}yield t._store.onReload(e.parentId,e)}catch(e){throw t._pendingDeleteWindows.delete(r),e}})()}resumeRun(e){var t=this;return w(function*(){if(!t._store.onResume)throw Error(`Runtime does not support resuming runs.`);if(t.voice)throw Error(`Cannot start a run while a voice session is connected`);if(t._isVoiceMessage(e.sourceId))throw Error(`Voice transcript messages cannot be reloaded`);let n=t._store;if(t._pendingResume)return t._pendingResume;let r=function(){var r=w(function*(){t._pendingDeleteWindows.clear(),t._restoreMovedLeafForRun(e.parentId),t._runStartLeases.begin(),t._cancelledToolTurn=null,yield n.onResume(e)});return function(){return r.apply(this,arguments)}}();if(n.canResume!==!0)return r();let i,a=new Promise((e,t)=>{i=()=>{try{e(r())}catch(e){t(e)}}}).finally(()=>{t._clearPendingResume(a)});return t._pendingResume=a,t._notifySubscribers(),i(),a})()}exportExternalState(){if(!this._store.onExportExternalState)throw Error(`Runtime does not support exporting external states.`);return this._store.onExportExternalState()}importExternalState(e){if(!this._store.onLoadExternalState)throw Error(`Runtime does not support importing external states.`);this._pendingDeleteWindows.clear(),this._cancelRunResyncLeases.invalidate(),this._cancelledToolTurn=null,this._cancelledRunIds.clear();let t=this._pendingResume;this._runTrackerUpdate(()=>{var e;return(e=this._toolInvocations)==null?void 0:e.reset()}),this._store.onLoadExternalState(e),this._clearPendingResume(t)}unstable_notifySessionReset(){var e,t;this._cancelRunResyncLeases.invalidate(),this._cancelledToolTurn=null,this._cancelledRunIds.clear(),this._clearPendingResume(this._pendingResume),this._runTrackerUpdate(()=>{var e;return(e=this._toolInvocations)==null?void 0:e.reset()}),(e=this._store.queue)==null||(t=e.__internal_notifyCancelled)==null||t.call(e)}cancelRun(){var e,t,n,r,i;if(!this._store.onCancel)throw Error(`Runtime does not support cancelling runs.`);this._pendingDeleteWindows.clear();let a=this._getEffectiveIsRunning(this._store);this._runCancellationLeases.invalidate();let o=Vf(this),s=this._cancelRunResyncLeases.current();if(this._store.activeRunId!==void 0&&this._cancelledRunIds.add(this._store.activeRunId),a){var c,l,u;let e=this._storeMessages.filter(e=>!e.metadata.isOptimistic),t=e.at(-1);this._cancelledToolTurn={messageIds:new Set((t==null?void 0:t.role)===`assistant`?[t.id]:[]),parentId:(t==null?void 0:t.role)===`assistant`?(c=(l=e.at(-2))==null?void 0:l.id)==null?null:c:(u=t==null?void 0:t.id)==null?null:u,parentOpen:!0,lease:this._runStartLeases.current()}}(e=this._toolInvocations)==null||e.abort({discardPending:!0}),(t=this._store.queue)==null||(n=t.__internal_notifyCancelled)==null||n.call(t),Vp(`onCancel`,this._store.onCancel()),this.dropEmptyOptimisticHead();let d=this.repository.getMessages(),f=d[d.length-1],p=(r=f==null?void 0:f.id)==null?null:r,m=this._runStartLeases.current(),h=a&&this._store.setMessages!==void 0&&(f==null?void 0:f.role)===`user`&&f.id===((i=d.at(-1))==null?void 0:i.id)&&f.content.every(e=>e.type===`text`)?f:void 0,g;if(h){let e={text:R(h),attachments:h.attachments,quote:h.metadata.custom.quote};this.composer.restoreDraft(e)&&(this.repository.deleteMessage(h.id),g={id:h.id,draft:e,resyncLease:s,generation:o},this._movedLeaf=g)}this._publishRepositoryMessages();let _=()=>{var e,t;if(o.aborted||!s.isCurrent())return;if((!this._getEffectiveIsRunning(this._store)||m.isCurrent()&&((e=(t=this.repository.getMessages().at(-2))==null?void 0:t.id)==null?null:e)===p)&&this.dropEmptyOptimisticHead(),g){var n;let e=this.repository.getMessages();this._movedLeaf===g&&((n=e.at(-1))==null?void 0:n.id)===g.id&&this.composer.text===g.draft.text&&this.repository.deleteMessage(g.id)}this._publishRepositoryMessages();let r=this._messages.filter(e=>{var t;return e.id!==((t=this._optimistic)==null?void 0:t.id)});Hd(r,this._storeMessages)||this.updateMessages(r)};this._pendingCancelResyncs.add(_),setTimeout(()=>{this._pendingCancelResyncs.delete(_),_()},0)}_settleCancelResyncs(){for(let e of this._pendingCancelResyncs)e()}dropEmptyOptimisticHead(){let e=this.repository.getMessages().at(-1);e&&e.metadata.isOptimistic&&e.content.length===0&&this.repository.deleteMessage(e.id)}addToolResult(e){if(!this._store.onAddToolResult)throw Error(`Runtime does not support tool results.`);Vp(`onAddToolResult`,this._store.onAddToolResult(e))}resumeToolCall(e){var t,n;if(!((t=(n=this._toolInvocations)==null?void 0:n.resume(e.toolCallId,e.payload))!=null&&t)){if(this._store.onResumeToolCall)this._store.onResumeToolCall(e);else throw Error(`Tool call ${e.toolCallId} is not waiting for resume.`)}}respondToToolApproval(e){if(!this._store.onRespondToToolApproval)throw Error(`Runtime does not support tool approvals.`);let t=this.messages.findLast(t=>t.role===`assistant`&&t.content.some(t=>{var n;return t.type===`tool-call`&&((n=t.approval)==null?void 0:n.id)===e.approvalId})),n=t==null?void 0:t.content.find(t=>{var n;return t.type===`tool-call`&&((n=t.approval)==null?void 0:n.id)===e.approvalId});try{return Promise.resolve(this._store.onRespondToToolApproval(e)).then(()=>{t&&(n==null?void 0:n.type)===`tool-call`&&this._notifyToolApprovalAnswered(t.id,n.toolCallId,n.toolName,e.approved)})}catch(e){return Promise.reject(e)}}unstable_recordToolInteraction(e){var t=this;return w(function*(){if(!t._store.unstable_onRecordToolInteraction)throw Error(`Runtime does not support recording tool interactions.`);yield t._store.unstable_onRecordToolInteraction(e)})()}reset(e){let t=this._pendingResume;this._pendingDeleteWindows.clear(),this._cancelRunResyncLeases.invalidate(),this._cancelledToolTurn=null,this._cancelledRunIds.clear(),this._submittedFeedback.clear(),this._importedMessageIds=void 0;let n=new El;n.import(Sl.fromArray(e==null?[]:e)),this.updateMessages(n.getMessages()),this._clearPendingResume(t)}import(e){if(!this._store.onImport)throw Error(`Runtime does not support importing messages.`);let t=this._pendingResume;this._pendingDeleteWindows.clear(),this._cancelRunResyncLeases.invalidate(),this._cancelledToolTurn=null,this._cancelledRunIds.clear(),this._submittedFeedback.clear(),super.import(e),this._clearPendingResume(t);let n=this.repository.getMessages();this._importedMessageIds=n.map(e=>e.id),this._store.onImport(n)}},Wp=e=>{var t,n;return(t=(n=e.adapters)==null?void 0:n.threadList)==null?{}:t},Gp=class extends rp{constructor(e){super(),S(this,`threads`,void 0),S(this,`_adapter`,void 0),this._adapter=e,this.threads=new up(Wp(e),()=>new Up(this._contextProvider,this._adapter))}setAdapter(e){this._adapter=e,this.threads.__internal_setAdapter(Wp(e)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(e)}},Kp=class{constructor(){var e=this;S(this,`thread`,void 0),S(this,`history`,void 0),S(this,`lastHistory`,void 0),S(this,`session`,0),S(this,`copied`,new Map),S(this,`failedIds`,new Set),S(this,`interactions`,new Map),S(this,`overlaid`,new WeakMap),S(this,`pending`,!1),S(this,`inFlight`,new WeakSet),S(this,`timer`,void 0),S(this,`waiters`,[]),S(this,`warned`,!1),S(this,`recordInteraction`,function(){var t=w(function*(t){var n;let r=e.thread,i=r==null?void 0:r.messages.find(e=>e.id===t.messageId),a=i==null?void 0:i.content.find(e=>e.type===`tool-call`&&e.toolCallId===t.toolCallId);if(!r||!i||(a==null?void 0:a.type)!==`tool-call`)throw Error(`Tool call is not available.`);let o=Pf(r);o||e.seed();let s=e.interactions.get(i.id);s||(s=new Map,e.interactions.set(i.id,s)),s.set(t.toolCallId,Uc((n=s.get(t.toolCallId))==null?Gc(a.unstable_interactions):n,t.interaction)),o||(yield e.schedule(!0))});return function(e){return t.apply(this,arguments)}}())}signature(e){try{var t;return(t=JSON.stringify({role:e.role,content:e.content,attachments:e.role===`user`?e.attachments:void 0,status:e.role===`assistant`?e.status:void 0,metadata:e.metadata}))==null?e:t}catch(t){return e}}branch(){var e,t;return((e=(t=this.thread)==null?void 0:t.messages)==null?[]:e).filter(e=>!e.metadata.isOptimistic&&!e.id.startsWith(`__external_store_fallback_`)&&!v(e.id)&&(e.role!==`assistant`||e.status.type!==`running`)).map(e=>{let t=this.interactions.get(e.id);if(!t)return e;let n=this.overlaid.get(e);if(n&&n.logs.size===t.size&&[...t].every(([e,t])=>n.logs.get(e)===t))return n.message;let r=E(E({},e),{},{content:e.content.map(e=>{if(e.type!==`tool-call`)return e;let n=t.get(e.toolCallId);return n?E(E({},e),{},{unstable_interactions:n}):e})});return this.overlaid.set(e,{logs:new Map(t),message:r}),r})}seed(){for(let e of this.branch())!this.copied.has(e.id)&&!this.failedIds.has(e.id)&&this.copied.set(e.id,this.signature(e))}attach(e,t){t!==this.lastHistory&&(this.copied.clear(),this.failedIds.clear(),this.interactions.clear(),this.overlaid=new WeakMap,this.lastHistory=t,this.session+=1),this.thread=e,this.history=t,this.seed();let n=e.unstable_on(`runStart`,()=>this.seed()),r=e.unstable_on(`runEnd`,()=>this.schedule());return()=>{n(),r(),this.timer!==void 0&&clearTimeout(this.timer),this.timer=void 0,this.pending=!1;let e=Error(`History copy was detached.`);for(let t of this.waiters.splice(0))t.reject(e);this.thread=void 0,this.history=void 0}}schedule(e=!1){this.pending=!0;let t=e?new Promise((e,t)=>{this.waiters.push({resolve:e,reject:t})}):Promise.resolve();return this.history&&!this.inFlight.has(this.history)&&this.timer===void 0&&(this.timer=setTimeout(()=>{this.timer=void 0,this.flush()},0)),t}flush(){var e=this;return w(function*(){if(!e.pending||!e.history)return;let t=e.history,n=e.session;e.pending=!1,e.inFlight.add(t);let r=e.waiters.splice(0),i=e.branch(),a=i.map(t=>[t.id,e.signature(t)]).filter(([t,n])=>e.copied.get(t)!==n);try{if(a.length>0){var o;if(yield(o=t.unstable_copy)==null?void 0:o.call(t,i,a.map(([e])=>e)),n===e.session)for(let[t,n]of a)e.copied.set(t,n),e.failedIds.delete(t)}for(let e of r)e.resolve()}catch(t){if(n===e.session)for(let[t]of a)e.failedIds.add(t);e.warned||(e.warned=!0,console.warn(`[useExternalStoreRuntime] Failed to copy history.`,t));for(let e of r)e.reject(t)}finally{e.inFlight.delete(t),e.pending&&e.schedule()}})()}},qp=zn(!1),Jp=e=>Mt(qp,!0,e),Yp=()=>Vn(qp),Xp=e=>{var t,n;let{modelContext:r,feedback:i,history:a}=(t=Rd())==null?{}:t,[o]=_n(()=>new Kp),s=!!(a!=null&&a.unstable_copy)&&!e.unstable_persistsHistory&&!((n=e.adapters)!=null&&n.threadList),c=bn(()=>{var t;let n=i&&!((t=e.adapters)!=null&&t.feedback)?E(E({},e),{},{adapters:E(E({},e.adapters),{},{feedback:i})}):e;return!s||e.unstable_onRecordToolInteraction?n:E(E({},n),{},{unstable_onRecordToolInteraction:o.recordInteraction})},[s,i,o,e]),[l]=_n(()=>new Gp(c)),u=Yp(),[d]=_n(()=>({generation:0}));En(()=>{if(u)return;let e=++d.generation;return()=>queueMicrotask(()=>{d.generation===e&&Yf(l.threads.getMainThreadRuntimeCore())})},[u,d,l]),zl(()=>()=>{Gf(l.threads.getMainThreadRuntimeCore())},[l]),G(()=>{l.setAdapter(c)}),zl(()=>{if(s&&a)return o.attach(l.threads.getMainThreadRuntimeCore(),a)},[s,a,o,l]),G(()=>{if(r)return l.registerModelContextProvider(r)},[r,l]);let[f]=_n(()=>new np(l));return f},Zp=class extends Error{constructor(){super(`Thread list was destroyed while an operation was pending.`),S(this,eu,!0),this.name=`ThreadListDestroyedError`}},Qp=({threadId:e,generation:t,runtimeHook:n,publish:r,itemRuntime:i,publishInCommit:a})=>{var o;let s=Jp(n),c=s==null||(o=s.thread)==null?void 0:o.__internal_threadBinding,l=xn(()=>{c&&r(e,c.getState(),t)},[e,t,c,r]),u=yn(!1);!a&&!u.current&&l(),Fl(()=>{if(c)return u.current=!0,l(),c.outerSubscribe(l)},[c,l]);let d=yn(void 0),f=Cn(()=>{let e=d.current;if(e===void 0||!c)return;let t=c.getState(),n=t.__internal_setGetThreadId;typeof n==`function`&&n.call(t,()=>e)});G(()=>{f()},[c]);let p=yn(void 0),m=yn(!1),h=yn(i.getState().status===`new`),g=Cn(()=>{if(m.current||i.getState().status!==`new`&&!h.current)return;m.current=!0,h.current=!1;let e=i.initialize();p.current=e,e.then(({remoteId:e})=>{d.current=e,f()},()=>{}),e.catch(()=>{p.current===e&&(p.current=void 0,m.current=!1)})}),_=Cn(()=>(g(),p.current));return G(()=>{if(!c)return;let e=c.getState(),t=e.__internal_setGetInitializePromise;typeof t==`function`&&t.call(e,_)},[c]),G(()=>{var e;if(s!=null&&(e=s.threads)!=null&&e.main)return m.current=!1,s.threads.main.unstable_on(`initialize`,g)},[s]),s},$p=Hr(({threadId:e,generation:t,parentList:n,runtimeHook:r,parentClient:i,adapters:a,publish:o,destroySignal:s,publishInCommit:c=!1})=>{let l=bn(()=>new Xf(new Po({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>{var t,r;let i=n.getItemById(e);return i?{id:i.id,remoteId:i.remoteId,externalId:i.externalId,title:i.title,lastMessageAt:i.lastMessageAt,custom:i.custom,status:i.status,isMain:i.id===n.mainThreadId,isRunning:(t=(r=n.unstable_isThreadRunning)==null?void 0:r.call(n,i.id))!=null&&t}:Eo},subscribe:e=>n.subscribe(e)}),n),[n,e]),{client:u}=Ka(i,{threadListItem:hd({runtime:l})});return fa(s,function(){return mi(u,function(){return Ld(a,function(){return Qp({threadId:e,generation:t,runtimeHook:r,publish:o,itemRuntime:l,publishInCommit:c})})})})}),em=[`runStart`,`runEnd`,`initialize`,`modelContextUpdate`],tm=e=>(e==null?void 0:e.runtime)!==void 0&&e.mountError===void 0&&e.publishedGeneration===e.generation,nm=e=>{let t=K(3),{detectorRef:n}=e,r,i;return t[0]===n?(r=t[1],i=t[2]):(r=()=>{n.current=!0},i=[n],t[0]=n,t[1]=r,t[2]=i),Fl(r,i),null},rm=class extends jo{constructor(e,t,n=!1){super(),S(this,`runtimeHook`,void 0),S(this,`adapterStore`,new Mo({defaultAdapters:null,threadAdapters:new Map})),S(this,`hostStore`,new Mo({threads:[],hookEpoch:0})),S(this,`pendingThreadAdapters`,new Map),S(this,`instances`,new Map),S(this,`nextGeneration`,0),S(this,`disposed`,!1),S(this,`parent`,void 0),S(this,`publishInCommit`,void 0),S(this,`runningSubscribers`,new Set),S(this,`threadEventSubscribers`,new Set),S(this,`_publish`,(e,t,n)=>{this._publishThreadRuntime(e,t,n)}),S(this,`replacedSubscribers`,new Set),S(this,`__internal_RenderThreadRuntimes`,({provider:e})=>($l(this.hostStore),Array.from(this.instances.entries()).map(([t,{generation:n}])=>(0,J.jsx)(this._OuterActiveThreadProvider,{threadId:t,provider:e},`${t}:${n}`)))),S(this,`__internal_Host`,({parentClient:e})=>{var t;let n=$l(this.hostStore),r=$l(this.adapterStore),i=Rd(),a=this._threadElements(e,n,E(E({},r),{},{defaultAdapters:(t=r.defaultAdapters)==null?i:t})),{effects:o}=Qr(function(){return Xr(a)});return Fl(()=>{try{o();for(let{id:e,generation:t}of n.threads){let n=this.instances.get(e);(n==null?void 0:n.generation)===t&&(n.committedGeneration=t)}}catch(e){for(let{id:t,generation:r}of n.threads)this._failThreadRuntime(t,r,e);throw e}}),null}),S(this,`_OuterActiveThreadProvider`,An(({threadId:e,provider:t})=>{let n=bn(()=>new tp(this.parent).getItemById(e),[e]),r=yn(!1);return G(()=>{if(process.env.NODE_ENV!==`production`&&t!==jn){let e=setTimeout(()=>{r.current||console.warn("RemoteThreadListAdapter.unstable_Provider did not render its `children` synchronously. Render `children` on first commit; deferring them behind a loading state, Suspense boundary, or `useEffect` gate strands the runtime host and leaves the thread without context.")},100);return()=>clearTimeout(e)}},[t]),(0,J.jsx)(Gd,{runtime:n,children:(0,J.jsx)(t,{children:(0,J.jsx)(this._AdapterSink,{threadId:e,detectorRef:r})})})})),S(this,`_AdapterSink`,({threadId:e,detectorRef:t})=>{let n=Rd();return this.pendingThreadAdapters.set(e,n),Fl(()=>(this.__internal_setThreadAdapters(e,n),()=>{this.pendingThreadAdapters.get(e)===n&&this.pendingThreadAdapters.delete(e),this.__internal_setThreadAdapters(e,null)}),[e,n]),(0,J.jsx)(nm,{detectorRef:t})}),this.parent=t,this.publishInCommit=n,this.runtimeHook=e}_whenRuntimeAttached(e){return new Promise((t,n)=>{let r=()=>{let r=this.instances.get(e);r?r.mountError?(i(),n(r.mountError.error)):tm(r)&&(i(),t(r.runtime)):(i(),n(Error(`Thread was deleted before runtime was started`)))},i=this.subscribe(r);r()})}startThreadRuntime(e){if(this.disposed)return Promise.reject(new Zp);if(!this.instances.has(e)){let t=this.nextGeneration++;this.instances.set(e,{generation:t,isRunning:!1,destroy:new AbortController}),this._syncHostThreads()}return this._whenRuntimeAttached(e)}_retireThreadRuntime(e){try{var t;(t=e.unsubscribeRunning)==null||t.call(e)}finally{e.unsubscribeRunning=void 0,e.runtime&&Jf(e.runtime),e.destroy.abort(),e.destroy=new AbortController,e.generation=this.nextGeneration++,e.mountError=void 0}}__internal_restartThreadRuntime(e){let t=this.instances.get(e);if(!t)return this.startThreadRuntime(e);try{this._retireThreadRuntime(t)}finally{this._syncHostThreads(),this._notifySubscribers()}return this._whenRuntimeAttached(e)}getThreadRuntimeCore(e){let t=this.instances.get(e);if(t)return t.runtime}__internal_hasThreadRuntime(e){return this.instances.has(e)}__internal_isThreadRuntimeAttached(e){return tm(this.instances.get(e))}__internal_isThreadRunning(e){var t,n;return(t=(n=this.instances.get(e))==null?void 0:n.isRunning)!=null&&t}__internal_subscribeRunningChanged(e){return this.runningSubscribers.add(e),()=>this.runningSubscribers.delete(e)}__internal_subscribeThreadEvents(e){return this.threadEventSubscribers.add(e),()=>this.threadEventSubscribers.delete(e)}_failThreadRuntime(e,t,n){let r=this.instances.get(e);(r==null?void 0:r.generation)!==t||tm(r)&&r.committedGeneration===t||(r.mountError={error:n},queueMicrotask(()=>this._notifySubscribers()))}_publishThreadRuntime(e,t,n){let r=this.instances.get(e);if(!r||r.generation!==n)return;let i=r.runtime,a=r.publishedGeneration;r.mountError=void 0,r.runtime=t,r.publishedGeneration=n;try{i!==t&&this._trackRunning(e,r)}finally{try{this._notifySubscribers(),i!==void 0&&i!==t&&Do(this.replacedSubscribers)}finally{a===n&&i!==void 0&&i!==t&&Yf(i)}}}__internal_subscribeRuntimeReplaced(e){return this.replacedSubscribers.add(e),()=>this.replacedSubscribers.delete(e)}_trackRunning(e,t){let n=t.unsubscribeRunning;t.unsubscribeRunning=void 0;try{n==null||n()}finally{let n=t.runtime;if(!n)this._setRunning(t,!1);else{let r=Pf(n);t.isRunning!==r&&(t.isRunning=r,queueMicrotask(()=>Do(this.runningSubscribers)));let i=[n.subscribe(()=>{this._setRunning(t,Pf(n))}),...em.map(t=>n.unstable_on(t,()=>{L(this.threadEventSubscribers,{threadId:e,type:t},`Thread event "${t}"`)}))];t.unsubscribeRunning=()=>Oo(i)}}}_setRunning(e,t){e.isRunning!==t&&(e.isRunning=t,Do(this.runningSubscribers))}stopThreadRuntime(e){let t=this.instances.get(e);try{var n;t==null||(n=t.unsubscribeRunning)==null||n.call(t)}finally{t!=null&&t.runtime&&Yf(t.runtime),t==null||t.destroy.abort(),this.instances.delete(e),this.pendingThreadAdapters.delete(e),this._syncHostThreads(),this._notifySubscribers()}}setRuntimeHook(e){if(this.runtimeHook===e)return;this.runtimeHook=e;let t=this.hostStore.getState().hookEpoch+1;try{Oo(Array.from(this.instances.values(),e=>()=>this._retireThreadRuntime(e)))}finally{this._syncHostThreads(t)}}__internal_setDefaultAdapters(e){let t=this.adapterStore.getState();t.defaultAdapters!==e&&this.adapterStore.setState(E(E({},t),{},{defaultAdapters:e}))}__internal_setThreadAdapters(e,t){let n=this.adapterStore.getState(),r=new Map(n.threadAdapters);t===null?r.delete(e):r.set(e,t),this.adapterStore.setState(E(E({},n),{},{threadAdapters:r}))}__internal_dispose(){this.disposed=!0;for(let e of[...this.instances.keys()])try{this.stopThreadRuntime(e)}catch(e){console.error(`[assistant-ui] Thread runtime cleanup threw while stopping a thread`,e)}}_syncHostThreads(e){let t=this.hostStore.getState();this.hostStore.setState(E(E({},t),{},{hookEpoch:e==null?t.hookEpoch:e,threads:Array.from(this.instances.entries()).map(([e,{generation:t,destroy:n}])=>({id:e,generation:t,destroySignal:n.signal}))}))}_threadElements(e,{threads:t,hookEpoch:n},r){let i=this.runtimeHook;return t.map(({id:a,generation:o,destroySignal:s})=>{var c;let l=this.pendingThreadAdapters.has(a)?this.pendingThreadAdapters.get(a):(c=r.threadAdapters.get(a))==null?r.defaultAdapters:c;return Ur(`${a}:${o}:${n}`,$p({threadId:a,generation:o,parentList:this.parent,runtimeHook:()=>{try{return i()}catch(e){if(e!==null&&(typeof e==`object`||typeof e==`function`)&&`then`in e&&typeof e.then==`function`)throw e;for(let n of t)this._failThreadRuntime(n.id,n.generation,e);throw e}},parentClient:e,adapters:l,publish:this._publish,publishInCommit:this.publishInCommit,destroySignal:s}),[a,o,this.parent,i,e,l,this._publish,this.publishInCommit,s])})}__internal_useHost(e){let t=$l(this.hostStore),n=$l(this.adapterStore);return Xr(this._threadElements(e,t,n))}};function im(e,t,n,...r){if(!n)return;let i=n=>{try{console.error(`[${e}] ${t} callback threw an error`,n)}catch(e){}};try{let e=n(...r);if(e!==null&&(typeof e==`object`||typeof e==`function`)&&`then`in e&&typeof e.then==`function`)return Promise.resolve(e).then(()=>void 0,e=>i(e))}catch(e){i(e)}}var am=(e,t,n)=>n.reduce((e,n)=>{var r;return(r=n==null?void 0:n(e,t))==null?e:r},e),om=class extends jo{constructor(e){super(),S(this,`_pendingTransforms`,[]),S(this,`_completedOptimistics`,[]),S(this,`_nextTransformOrder`,0),S(this,`_epoch`,0),S(this,`_baseValue`,void 0),S(this,`_cachedValue`,void 0),this._baseValue=e,this._cachedValue=e}_updateState(){let e=[...this._pendingTransforms.map(e=>({order:e.order,apply:t=>am(t,e.task,[e.loading,e.optimistic])})),...this._completedOptimistics.map(({order:e,optimistic:t})=>({order:e,apply:t}))].sort((e,t)=>e.order-t.order);this._cachedValue=e.reduce((e,t)=>t.apply(e),this._baseValue),this._notifySubscribers()}get baseValue(){return this._baseValue}get value(){return this._cachedValue}update(e){this._baseValue=e,this._updateState()}reset(e){this._epoch++,this._pendingTransforms.length=0,this._completedOptimistics.length=0,this._baseValue=e,this._cachedValue=e,this._notifySubscribers()}optimisticUpdate(e){var t=this;return w(function*(){let n=t._epoch,r=t._nextTransformOrder++,i=e.execute(),a=E(E({},e),{},{order:r,task:i});try{t._pendingTransforms.push(a),t._updateState();let r=yield i;if(n!==t._epoch)return r;t._baseValue=am(t._baseValue,r,[e.optimistic,e.then]);for(let n of t._completedOptimistics)(e.then||n.order>a.order)&&(t._baseValue=n.optimistic(t._baseValue));return e.optimistic&&(t._completedOptimistics.push({order:a.order,optimistic:e.optimistic}),t._completedOptimistics.sort((e,t)=>e.order-t.order)),r}finally{let e=t._pendingTransforms.indexOf(a);e>-1&&t._pendingTransforms.splice(e,1);try{t._updateState()}finally{t._pendingTransforms.length===0&&(t._completedOptimistics.length=0)}}})()}},sm=Error("This is the empty thread, a placeholder for the main thread. You cannot perform any actions on this thread instance. This error is probably because you tried to call a thread method in your render function. Call the method inside a `useEffect` hook instead."),cm=new class extends Rf{constructor(...e){super(...e),S(this,`messages`,[]),S(this,`composer`,Lf(sm,!0)),S(this,`isLoading`,!0)}get error(){return sm}getMessageById(){}getBranches(){return[]}export(){return{messages:[]}}subscribe(){return()=>{}}waitForUpdate(){return Promise.reject(sm)}};function lm(e){return e}var um=`__LOCALID_`,dm=e=>e||void 0,fm=(e,t)=>{let n=[...t.threadIds],r=[...t.archivedThreadIds],i=H(t.threadIdMap),a=H(t.threadData),o=new Set([...n,...r]);for(let t of e){var s;switch(t.status){case`regular`:case`archived`:break;default:{let e=t.status;throw Error(`Unsupported state: ${e}`)}}let e=i[t.remoteId],c=e===void 0?void 0:a[e],l=(s=c==null?void 0:c.id)==null?t.remoteId:s,u=e==null?lm(l):e,d=c!==void 0&&c.status!==`new`?c.initializeTask:void 0;o.has(l)?c!==void 0&&c.status!==t.status&&(t.status===`regular`?(r=r.filter(e=>e!==l),n.push(l)):(n=n.filter(e=>e!==l),r.push(l))):(o.add(l),t.status===`regular`?n.push(l):r.push(l)),i[l]=u,i[t.remoteId]=u,a[u]=E(E({},(c==null?void 0:c.localOrigin)===!0?{localOrigin:!0}:{}),{},{id:l,remoteId:t.remoteId,externalId:t.externalId,status:t.status,title:t.title,lastMessageAt:t.lastMessageAt,custom:t.custom,initializeTask:d==null?Promise.resolve({remoteId:t.remoteId,externalId:t.externalId}):d})}return{threadIds:n,archivedThreadIds:r,threadIdMap:i,threadData:a}},pm=(e,t)=>E(E({},e),fm([t],{threadIds:[...e.threadIds],archivedThreadIds:[...e.archivedThreadIds],threadIdMap:e.threadIdMap,threadData:e.threadData})),mm=()=>({isLoading:!0,loadError:void 0,switchError:void 0,isLoadingMore:!1,cursor:void 0,newThreadId:void 0,threadIds:[],archivedThreadIds:[],threadIdMap:H(),threadData:H()}),hm=(e,t)=>{let n=lm(t.id);return E(E({},e),{},{newThreadId:t.id,threadIdMap:H(e.threadIdMap,{[t.id]:n}),threadData:H(e.threadData,{[n]:t})})},gm=(e,t)=>{let n=`${um}${t==null?g():t}`;for(;e.threadIdMap[n];)n=`${um}${g()}`;return{id:n,state:hm(e,{status:`new`,id:n,remoteId:void 0,externalId:void 0,title:void 0,custom:void 0,localOrigin:!0})}},_m=(e,t,n)=>{let r=new Set(e.threadIds),i=new Set(e.archivedThreadIds),a=[],o=[],s=(e,t)=>e.has(t.id)||t.remoteId!==void 0&&e.has(t.remoteId);for(let t of Object.values(e.threadData)){let e=n.get(t.id);e!==void 0&&e!==`new`||e===void 0&&t.localOrigin!==!0||(t.status===`regular`&&!s(r,t)?(a.push(t),r.add(t.id)):t.status===`archived`&&!s(i,t)&&(o.push(t),i.add(t.id)))}if(a.length===0&&o.length===0)return e;let c=(e,t)=>{let n=e.indexOf(t.id);if(n!==-1)return n;let r=t.remoteId===void 0?-1:e.indexOf(t.remoteId);return r===-1?9007199254740991:r};return a.sort((e,n)=>c(t.threadIds,e)-c(t.threadIds,n)),o.sort((e,n)=>c(t.archivedThreadIds,e)-c(t.archivedThreadIds,n)),E(E({},e),{},{threadIds:[...a.map(e=>e.id),...e.threadIds],archivedThreadIds:[...o.map(e=>e.id),...e.archivedThreadIds]})},vm=e=>new Map(Object.values(e.threadData).map(e=>[e.id,e.status])),ym=(e,t,n)=>{let r=fm(t.threads,{threadIds:[],archivedThreadIds:[],threadIdMap:E({},e.threadIdMap),threadData:E({},e.threadData)});return _m(E(E({},e),{},{isLoading:!1,loadError:void 0,cursor:dm(t.nextCursor),threadIds:r.threadIds,archivedThreadIds:r.archivedThreadIds,threadIdMap:r.threadIdMap,threadData:r.threadData}),e,n)},bm=(e,t)=>{let n=fm(t.threads,{threadIds:[...e.threadIds],archivedThreadIds:[...e.archivedThreadIds],threadIdMap:E({},e.threadIdMap),threadData:E({},e.threadData)});return E(E({},e),{},{isLoadingMore:!1,cursor:dm(t.nextCursor),threadIds:n.threadIds,archivedThreadIds:n.archivedThreadIds,threadIdMap:n.threadIdMap,threadData:n.threadData})},Y=(e,t)=>{let n=Object.hasOwn(e.threadIdMap,t)?e.threadIdMap[t]:void 0;if(n!==void 0)return Object.hasOwn(e.threadData,n)?e.threadData[n]:void 0},xm=(e,t,n,r,i)=>{var a,o,s;let c=lm(t),l=Object.hasOwn(e.threadData,c)?e.threadData[c]:void 0;if(!l)return{state:e,removedMappingId:void 0,survivorMappingId:c};let u=Object.hasOwn(e.threadIdMap,n)?e.threadIdMap[n]:void 0,d=u!==void 0&&u!==c&&Object.hasOwn(e.threadData,u)?e.threadData[u]:void 0,f=u!==void 0&&d!==void 0?{mappingId:u,data:d}:void 0,p=i!==void 0&&Object.hasOwn(e.threadIdMap,i)?e.threadIdMap[i]:void 0,m=f!==void 0&&p===f.mappingId?f.mappingId:c,h=f===void 0?void 0:m===c?f.mappingId:c,g=r==null?f==null?void 0:f.data.externalId:r,_=H(e.threadData);h!==void 0&&delete _[h];let v=E(E({},l),{},{id:m,initializeTask:Promise.resolve({remoteId:n,externalId:g}),remoteId:n,externalId:g});_[m]=E(E(E({},f==null?void 0:f.data),v),{},{title:(a=l.title)==null?f==null?void 0:f.data.title:a,lastMessageAt:(o=`lastMessageAt`in l?l.lastMessageAt:void 0)==null?f&&`lastMessageAt`in f.data?f.data.lastMessageAt:void 0:o,custom:(s=l.custom)==null?f==null?void 0:f.data.custom:s});let y=H(e.threadIdMap);if(h!==void 0)for(let[e,t]of Object.entries(y))t===h&&(y[e]=m);y[t]=m,y[n]=m;let b=e=>f===void 0?e:e.filter(e=>e!==f.data.id).map(e=>e===l.id?m:e);return{state:E(E({},e),{},{threadIds:b(e.threadIds),archivedThreadIds:b(e.archivedThreadIds),threadIdMap:y,threadData:_}),removedMappingId:h,survivorMappingId:m}},Sm=(e,t,n,r)=>{let i=Y(e,t);if(!i)return e;let{id:a,status:o}=i;if(o===n)return e;let s;if(n!==`deleted`){if(i.status===`new`){if(r===void 0)return e;s=E(E({},i),{},{initializeTask:r,status:n})}else s=E(E({},i),{},{status:n})}let c=E({},e);switch(o){case`new`:c.newThreadId=void 0;break;case`regular`:c.threadIds=c.threadIds.filter(e=>e!==a);break;case`archived`:c.archivedThreadIds=c.archivedThreadIds.filter(e=>e!==a);break;default:throw Error(`Unsupported state: ${o}`)}switch(n){case`regular`:c.threadIds=[a,...c.threadIds];break;case`archived`:c.archivedThreadIds=[a,...c.archivedThreadIds];break;case`deleted`:{let n=e.threadIdMap[t],r=H(c.threadData);delete r[n],c.threadData=r;let i=H(c.threadIdMap);for(let[e,t]of Object.entries(i))t===n&&delete i[e];c.threadIdMap=i;break}default:throw Error(`Unsupported state: ${n}`)}return s!==void 0&&(c.threadData=E(E({},c.threadData),{},{[a]:s})),c},Cm=(e,t,n)=>Sm(e,t,n,void 0),wm=(e,t,n)=>Sm(e,t,`regular`,n),Tm=(e,t,n)=>{let r=Cm(e,t,`deleted`);return n===void 0?r:Cm(r,n,`deleted`)},Em=class{constructor(){S(this,`pending`,new Map),S(this,`aliases`,new Map),S(this,`nextOrder`,0)}resolve(e){let t=this.aliases.get(e);for(;t!==void 0;)e=t,t=this.aliases.get(e);return e}merge(e,t){var n,r;let i=this.resolve(e),a=this.resolve(t);if(i===a)return;this.aliases.set(a,i);let o=[...(n=this.pending.get(i))==null?[]:n,...(r=this.pending.get(a))==null?[]:r].sort((e,t)=>Number(t.running)-Number(e.running)||e.order-t.order);if(this.pending.delete(a),o.length===0)return;let s;for(let e of o)e.previous=s,s=e.done;this.pending.set(i,o)}reserve(e,t){var n,r;let i=(t==null?void 0:t.remoteId)===void 0?t==null?void 0:t.initializeTask:void 0,a=this.resolve(e),o=(n=this.pending.get(a))==null?[]:n,s,c=new Promise(e=>{s=e}),l={order:this.nextOrder++,done:c,previous:(r=o.at(-1))==null?void 0:r.done,running:!1};o.push(l),this.pending.set(a,o);let u=!1,d=()=>{s();let t=this.resolve(e),n=this.pending.get(t);n.splice(n.indexOf(l),1),n.length===0&&this.pending.delete(t)},f=function(){var e=w(function*(e){let t;do t=l.previous,t&&(yield t);while(t!==l.previous);return e()});return function(t){return e.apply(this,arguments)}}();return{run:function(){var e=w(function*(e){u=!0;try{return i&&(yield i.catch(()=>{})),yield f(()=>(l.running=!0,e()))}finally{f(d)}});return function(t){return e.apply(this,arguments)}}(),cancel:()=>{u||(u=!0,f(d))}}}},Dm=class extends Error{constructor(){super(`Thread list adapter changed while an operation was pending.`),S(this,eu,!0),this.name=`ThreadListAdapterChangedError`}},Om=e=>{var t;return((t=e.status)==null?void 0:t.type)!==`running`},km=function(){var e=w(function*(e,t){let n=Rs.fromAssistantStream(e);var r=!1,i=!1,a;try{for(var o=z(n),s;r=!(s=yield o.next()).done;r=!1){let e=s.value;{var c;let n=(c=e.parts.filter(e=>e.type===`text`)[0])==null?void 0:c.text;n!=null&&n.trim()&&(yield t(n))}}}catch(e){i=!0,a=e}finally{try{r&&o.return!=null&&(yield o.return())}finally{if(i)throw a}}});return function(t,n){return e.apply(this,arguments)}}(),Am=new WeakMap,jm=new WeakMap;function Mm(e,t){let n=jm.get(e);n===void 0&&(n=new Map,jm.set(e,n));let r=n.get(t);return r===void 0&&(r={runEnded:!1,renamed:!1,messages:void 0},n.set(t,r)),r}var Nm=new WeakMap;function Pm(e,t){var n;for(let r of(n=Nm.get(e))==null?[]:n)r(t)}function Fm(e,t){let n=e.get(t);return n===void 0&&(n={generations:new Set,pendingClaim:null,inFlightClaims:new Set,manualClaim:null,latestGeneration:null,nextOrder:0},e.set(t,n)),n}function Im(e,t,n){n.generations.size===0&&!Am.has(n)&&n.pendingClaim===null&&n.inFlightClaims.size===0&&n.manualClaim===null&&e.get(t)===n&&e.delete(t)}function Lm(e,t){var n,r;return!t.superseded&&((n=(r=e.latestGeneration)==null?void 0:r.order)==null?0:n)<=t.order}function Rm(e){let t=e.latestGeneration;for(;t!==null&&t.automatic;)t=t.outranked;return t}function zm(e,t){var n,r;return((n=(r=Rm(e))==null?void 0:r.order)==null?0:n)<t.order}function Bm(e,t,n){let r=Fm(e,t),i,a=new Promise(e=>{i=e}),o={title:n,order:++r.nextOrder,settled:a,settle:i,renamed:void 0};r.pendingClaim=o,r.inFlightClaims.add(o),Pm(r,a);for(let e of r.generations)e.order<o.order&&(e.claim=o,e.claims.push(o));return o}function Vm(e,t,n,r){var i,a;n.renamed=r,n.settle(r);let o=e.get(t);o!==void 0&&(r&&(Mm(e,t).renamed=!0),o.inFlightClaims.delete(n),r&&zm(o,n)&&((i=(a=o.manualClaim)==null?void 0:a.order)==null?0:i)<n.order&&(o.manualClaim=n),o.pendingClaim===n&&(o.pendingClaim=r?null:Hm(o,o.inFlightClaims)),Im(e,t,o))}function Hm(e,t){let n=null;for(let r of t)r.renamed!==!1&&zm(e,r)&&(n===null||r.order>n.order)&&(n=r);return n}function Um(e,t,n){let r=n.manualClaim;if(r!==null)return n.manualClaim=null,Im(e,t,n),r.title}function Wm(e,t){var n,r,i,a;e.latestGeneration===t&&(e.latestGeneration=t.outranked);let o=[...t.hiddenManual===null?[]:[t.hiddenManual],...t.beforeGenerationClaims].reduce((e,t)=>{var n;return t.renamed===!0&&((n=e==null?void 0:e.order)==null?0:n)<t.order?t:e},null);for(let n=e.latestGeneration;n!==null;n=n.outranked)n.outranked===t&&(n.outranked=t.outranked);for(let i of e.generations)o!==null&&!i.automatic&&i.order>t.order&&((n=(r=i.hiddenManual)==null?void 0:r.order)==null?0:n)<o.order&&(i.hiddenManual=o);o!==null&&zm(e,o)&&((i=(a=e.manualClaim)==null?void 0:a.order)==null?0:i)<o.order&&(e.manualClaim=o);for(let n of e.generations)n!==t&&n.automatic&&n.claim===null&&(n.claim=Hm(e,[...n.claims,...e.inFlightClaims,...e.manualClaim===null?[]:[e.manualClaim]]))}function Gm(e,t){e.delete(t)}function Km(e,t,n){let r=Fm(e,t);if(n&&r.pendingClaim===null&&Um(e,t,r)!==void 0)return null;let i,a=new Promise(e=>{i=e}),o={automatic:n,order:++r.nextOrder,claim:n?r.pendingClaim:null,claims:n&&r.pendingClaim!==null?[r.pendingClaim]:[],beforeGenerationClaims:n?[]:[...r.inFlightClaims],outranked:r.latestGeneration,hiddenManual:n?null:r.manualClaim,superseded:!1,persisted:a,settlePersisted:i};return n||(r.pendingClaim=null,r.manualClaim=null),r.latestGeneration=o,r.generations.add(o),Nm.has(r)&&Pm(r,a.then(e=>e!==void 0)),o}function qm(e){return Jm.apply(this,arguments)}function Jm(){return Jm=w(function*(e){var t;let{states:n,threadId:r,automatic:i,afterRun:a}=e,o=Fm(n,r),s=Mm(n,r);if(a){var c,l;if(s.runEnded||s.renamed){Im(n,r,o);return}s.runEnded=!0;let t=s.messages!==void 0&&s.messages.some(e=>e.role===`assistant`)&&s.messages.length===((c=e.messages)==null?void 0:c.length)&&s.messages.every((t,n)=>t===e.messages[n]);if(s.messages=void 0,t){Im(n,r,o);return}Am.set(o,((l=Am.get(o))==null?0:l)+1);let i=!1;try{for(;o.generations.size>0||o.inFlightClaims.size>0;)if(yield Promise.all([...[...o.generations].map(e=>e.persisted),...[...o.inFlightClaims].map(e=>e.settled)]),n.get(r)!==o)return;if(s.renamed||a())return;i=!0}finally{let e=Am.get(o)-1;e===0?Am.delete(o):Am.set(o,e),i||Im(n,r,o)}}else i&&!s.runEnded&&(s.messages=e.messages);let u=i?[...o.generations].filter(e=>!e.automatic):[],d=u.length>0,f=o.nextOrder;d&&Am.set(o,((t=Am.get(o))==null?0:t)+1);let p;try{if(d){let e=new Set(u),t=()=>{let t=!1;for(let n of o.generations)n.automatic||e.has(n)||(e.add(n),t=!0);for(let n=o.latestGeneration;n!==null;n=n.outranked)n.automatic||n.order<=f||e.has(n)||(e.add(n),t=!0);return t};for(;;){t();let i=yield Promise.all([...e].map(e=>e.persisted));if(n.get(r)!==o)return;if(!(t()||[...o.generations].some(e=>!e.automatic))){if(i.some(e=>e!==void 0))return;break}}}p=Km(n,r,i)}finally{if(d){let e=Am.get(o)-1;e===0?Am.delete(o):Am.set(o,e),Im(n,r,o)}}if(p===null)return;let m=()=>n.get(r)===o,h=function(){var t=w(function*(t){m()&&(yield e.generate(t))});return function(e){return t.apply(this,arguments)}}(),g=function(){var t=w(function*(t){m()&&(yield e.rename(t))});return function(e){return t.apply(this,arguments)}}(),_,v=function(){var t=w(function*(t){m()&&(yield e.applyTitle(t),_=t)});return function(e){return t.apply(this,arguments)}}(),y,b=p.order,x=!1,S,C=function(){var t=w(function*(t,n){let r=o.nextOrder,i=[],a=e=>i.push(e),s=Nm.get(o);s===void 0&&(s=new Set,Nm.set(o,s)),s.add(a);try{yield g(t),y=t}catch(t){try{for(;m();){let t=i.length,a=yield Promise.all(i);if(i.length!==t)continue;if(a.some(Boolean)||t===0&&(o.nextOrder!==r||!n()))break;let s=o.nextOrder,c=yield e.readTitle();if(!m())break;if(o.nextOrder===s&&i.length===t){if(t===0&&!n())break;y=c,yield v(c);break}}}catch(e){}throw t}finally{s.delete(a),s.size===0&&Nm.delete(o)}});return function(e,n){return t.apply(this,arguments)}}(),T=function(){var e=w(function*(e){let t=yield e.settled;if(p.claim===e){if(!t){o.pendingClaim===e&&(o.pendingClaim=null);let t=Hm(o,i?[...p.claims,...o.inFlightClaims,...o.manualClaim===null?[]:[o.manualClaim]]:p.claims);if(p.claim=t,t!==null)return}return t}});return function(t){return e.apply(this,arguments)}}(),E=()=>i&&Um(n,r,o)!==void 0,D=function(){var e=w(function*(){for(;!p.superseded;){let e=o.latestGeneration;if(e===null||e.order<=p.order||(yield e.persisted,o.latestGeneration===e))return}});return function(){return e.apply(this,arguments)}}(),O=function(){var e=w(function*(){if(y!==void 0)for(;;){let e=p.claim;if(e!==null&&zm(o,e)&&(e.order>b||e.renamed===!0&&e.title!==y)){(yield T(e))===!0&&(yield C(e.title,()=>p.claim===e&&zm(o,e)),b=e.order);continue}let t=o.latestGeneration;if(t===null||t===p||t.order<=b)return;let n=yield t.persisted;if(o.latestGeneration===t){if(n===void 0||n===y)return;yield C(n,()=>{var e,n;return o.latestGeneration===t&&((e=(n=p.claim)==null?void 0:n.order)==null?0:e)<=t.order}),b=t.order}}});return function(){return e.apply(this,arguments)}}(),k=function(){var e=w(function*(){for(p.beforeGenerationClaims.length>0&&(yield Promise.all(p.beforeGenerationClaims.map(e=>e.settled)));;){for(;p.claim!==null;){let e=yield T(p.claim);if(e!==void 0){if(e){p.superseded=!0;return}if(E())return;break}}if(i&&!Lm(o,p)){if(yield D(),!Lm(o,p))return}else{if(!Lm(o,p))return;break}}for(yield h(function(){var e=w(function*(e){x=!0,S=e,e!==void 0&&(y=e);let t=p.claim;if(t!==null){if((yield T(t))!==!1)return;if(E()){p.superseded=!0;return}}y!==void 0&&Lm(o,p)&&(yield v(S))});return function(t){return e.apply(this,arguments)}}());;){let e=p.claim;if(e===null)return;let t=yield T(e);if(t!==void 0){if(t===!1){if(E())return;x&&y!==void 0&&Lm(o,p)&&(yield v(S));return}if(!zm(o,e)){if(yield D(),!zm(o,e))return;if(p.claim!==e)continue}if(yield C(e.title,()=>p.claim===e&&Lm(o,p)),b=e.order,p.claim===e){if(!Lm(o,p))return;yield v(e.title),p.superseded=!0;return}}}});return function(){return e.apply(this,arguments)}}();try{if(yield k(),y!==void 0&&(yield D()),yield O(),y!==void 0&&Lm(o,p)){let e=p.claim;e!==null&&e.renamed===!0&&zm(o,e)?_!==e.title&&(yield v(e.title)):e===null&&x&&_!==S&&(yield v(S))}}finally{y===void 0&&Wm(o,p),p.settlePersisted(y),o.generations.delete(p),Im(n,r,o)}}),Jm.apply(this,arguments)}var Ym=(e,t)=>Error(`Thread "${e}" not found while ${t}.`),Xm=(e,t,n)=>Error(`Thread "${e}" has status "${t}", so it cannot ${n}.`),Zm=mm(),Qm=class extends jo{resolveProvider(e){return e.unstable_Provider===void 0?e.unstable_useAdapters===void 0?jn:this._useAdaptersProvider:e.unstable_Provider}_getExposedItems(){let e=this._state.value,t=this._exposedItems;if((t==null?void 0:t.state)===e&&t.mainThreadId===this._mainThreadId)return t;let n=new Set;for(let t of[e.newThreadId,...e.threadIds,...e.archivedThreadIds,this._mainThreadId]){if(t===void 0)continue;let r=Y(e,t);r!==void 0&&n.add(r.id)}let r=Object.entries(e.threadData),i=r.every(([,e])=>n.has(e.id))?e.threadData:H(Object.fromEntries(r.filter(([,e])=>n.has(e.id))));return this._exposedItems={state:e,mainThreadId:this._mainThreadId,ids:n,items:i},this._exposedItems}get threadItems(){return this._getExposedItems().items}getLoadThreadsPromise(){var e=this;if(!this._loadThreadsPromise){let t=this._loadGeneration,n=this._switchGeneration,r=!1,i=!1,a=vm(this._state.baseValue),o=(e,t)=>{this._loadThreadsPromise=void 0,console.error(`[assistant-ui] thread list load failed:`,t);let n=E(E({},e),{},{isLoading:!1,loadError:t});return this._replaceListOnNextLoad?(this._replaceListOnNextLoad=!1,this._listedAdapterGeneration=this._adapterGeneration,r=!0,this._replaceWithThreads(n,[],void 0)):n};this._loadThreadsPromise=this._state.optimisticUpdate({execute:function(){var t=w(function*(){try{return{success:!0,response:yield e._options.adapter.list()}}catch(e){return{success:!1,error:e}}});return function(){return t.apply(this,arguments)}}(),loading:e=>t===this._loadGeneration?E(E({},e),{},{isLoading:!0,loadError:void 0}):e,then:(e,n)=>{if(t!==this._loadGeneration)return e;if(!n.success)return o(e,n.error);let s=n.response,c=!1;try{return c=this._replaceListOnNextLoad,i=!0,c?(this._replaceListOnNextLoad=!1,this._listedAdapterGeneration=this._adapterGeneration,r=!0,this._replaceWithThreads(E(E({},e),{},{loadError:void 0}),s.threads,dm(s.nextCursor))):ym(e,s,a)}catch(t){return c&&(this._replaceListOnNextLoad=!0),o(e,t)}}}).catch(e=>{t===this._loadGeneration&&this._state.update(o(this._state.baseValue,e))}).then(()=>{(i||r)&&this._reapplyControlledThread(r,n)})}return this._loadThreadsPromise}loadMore(){if(this._loadMorePromise)return this._loadMorePromise;let e=this._state.value;if(e.cursor===void 0||e.isLoading)return Promise.resolve();let t=this._loadGeneration,n=this._options.adapter,r=e.cursor,i=!1,a=this._state.optimisticUpdate({execute:()=>n.list({after:r}),loading:e=>t===this._loadGeneration?E(E({},e),{},{isLoadingMore:!0}):e,then:(e,r)=>t!==this._loadGeneration||n!==this._options.adapter?e:(i=!0,bm(e,r))}).catch(e=>{t===this._loadGeneration&&console.error(`[assistant-ui] thread list loadMore failed:`,e)}).then(()=>{this._loadMorePromise===a&&(this._loadMorePromise=void 0),i&&this._reapplyControlledThread(!1)});return this._loadMorePromise=a,a}_reapplyControlledThread(e,t=this._switchGeneration){let n=this._options.threadId;if(n===void 0)return;let r=this.getItemById(n);e&&t!==this._switchGeneration&&this._controlledSwitchGeneration!==this._switchGeneration||!e&&(r===void 0||this._controlledSwitchGeneration!==this._switchGeneration)||(r==null?void 0:r.id)!==this._mainThreadId&&this._switchToThreadFromProp(n).catch(()=>{})}constructor(e,t,n){var r;super(),r=this,S(this,`_options`,void 0),S(this,`_hookManager`,void 0),S(this,`_runtimeAdapters`,void 0),S(this,`_loadThreadsPromise`,void 0),S(this,`_loadMorePromise`,void 0),S(this,`_loadGeneration`,0),S(this,`_adapterGeneration`,0),S(this,`_listedAdapterGeneration`,0),S(this,`_replaceListOnNextLoad`,!1),S(this,`_staleThreadIdsOnReplace`,void 0),S(this,`_staleThreadsAdapter`,void 0),S(this,`_switchGeneration`,0),S(this,`_disposedSwitchGeneration`,void 0),S(this,`_switchTask`,void 0),S(this,`_supersedeAttachmentWait`,void 0),S(this,`_switchError`,void 0),S(this,`_titleStates`,new Map),S(this,`_mutations`,new Em),S(this,`_automaticTitles`,new Map),S(this,`_runningThreads`,new Set),S(this,`_destroyController`,new AbortController),S(this,`_mainThreadId`,void 0),S(this,`_state`,new om(Zm)),S(this,`_useAdaptersProvider`,({children:e})=>{let t=this._options.adapter.unstable_useAdapters;return t===void 0?e:(0,J.jsx)(this._SynthesizedAdapters,{useAdapters:t,children:e})}),S(this,`_SynthesizedAdapters`,({useAdapters:e,children:t})=>{let n=Bd(e());return n==null?t:(0,J.jsx)(zf,{adapters:n,children:t})}),S(this,`_exposedItems`,void 0),S(this,`_initialThreadLoaded`,!1),S(this,`providerStore`,void 0),S(this,`_lastNotifiedThreadId`,void 0),S(this,`_newThreadIntent`,void 0),S(this,`_controlledSwitchGeneration`,void 0),S(this,`_controlledSwitchTask`,void 0),S(this,`initialize`,function(){var e=w(function*(e){var t;let n=r._options.adapter,i=r._adapterGeneration;if(r._state.value.newThreadId!==e){r._requireAdapterSettled();let t=Y(r._state.value,e);if(!t)throw Ym(e,`initializing it`);if(t.status===`new`)throw Xm(e,t.status,`be initialized here`);let{remoteId:n,externalId:a}=yield t.initializeTask;return r._requireAdapterGeneration(i),{remoteId:n,externalId:a}}r._requireAdapterGeneration(i);let a=(t=Y(r._state.value,e))==null?void 0:t.custom,o=a===void 0?n.initialize(e):n.initialize(e,{custom:a}),s,c=r._state.optimisticUpdate({execute:()=>o,optimistic:t=>r._listedAdapterGeneration>i?t:wm(t,e,o),then:(t,{remoteId:n,externalId:a})=>{if(i!==r._adapterGeneration)return t;let o=xm(t,e,n,a,e);return s=o.removedMappingId,s!==void 0&&r._mutations.merge(o.survivorMappingId,s),s===r._mainThreadId&&r._setMainThreadId(o.survivorMappingId),o.state}});r._armAutomaticTitle(e,c);let{remoteId:l,externalId:u}=yield c.finally(()=>{r._leaveRemovedMainThread(e).catch(()=>{})});return r._requireAdapterGeneration(i),s!==void 0&&r._hookManager.stopThreadRuntime(s),{remoteId:l,externalId:u}});return function(t){return e.apply(this,arguments)}}()),S(this,`generateTitle`,function(){var e=w(function*(e,t){yield r._generateTitle(e,t)});return function(t,n){return e.apply(this,arguments)}}()),S(this,`_generateTitle`,function(){var e=w(function*(e,t,n,i=!1){r._requireAdapterSettled();let a=r._options.adapter,o=r._adapterGeneration,s=r.getItemById(e);if(!s)throw Ym(e,`generating its title`);if(s.status===`new`)throw Xm(e,s.status,`generate a title`);let{remoteId:c}=yield s.initializeTask;r._requireAdapterGeneration(o);let l=n==null?void 0:n();if(n&&!l)return!1;let u=r._hookManager.getThreadRuntimeCore(s.id);if(!u||n&&u.isLoading)return!1;let d=u.messages.filter(Om),f=i?l:d.length||l==null?d:l,p=()=>Y(r._state.baseValue,s.id)===void 0;return yield qm({states:r._titleStates,threadId:s.id,automatic:(t==null?void 0:t.automatic)===!0,messages:f,generate:function(){var e=w(function*(e){if(p())return;let t=yield a.generateTitle(c,f);r._requireAdapterGeneration(o),yield km(t,e)});return function(t){return e.apply(this,arguments)}}(),rename:function(){var e=w(function*(e){yield r._mutations.reserve(s.id,s).run(w(function*(){r._requireAdapterGeneration(o),p()||(yield a.rename(c,e))}))});return function(t){return e.apply(this,arguments)}}(),readTitle:function(){var e=w(function*(){if(r._requireAdapterGeneration(o),p())return;let{title:e}=yield a.fetch(c);return r._requireAdapterGeneration(o),e});return function(){return e.apply(this,arguments)}}(),applyTitle:function(){var e=w(function*(e){yield r._state.optimisticUpdate({execute:function(){var e=w(function*(){});return function(){return e.apply(this,arguments)}}(),optimistic:t=>{if(o!==r._adapterGeneration)return t;let n=Y(t,s.id);return n?E(E({},t),{},{threadData:E(E({},t.threadData),{},{[n.id]:E(E({},n),{},{title:e})})}):t}})});return function(t){return e.apply(this,arguments)}}(),afterRun:i?()=>{var e;if(r._requireAdapterGeneration(o),r._destroyController.signal.aborted)throw new Zp;return(e=r.getItemById(s.id))==null?void 0:e.title}:void 0}),!0});return function(t,n,r){return e.apply(this,arguments)}}()),S(this,`boundIdsStore`,new Mo([])),S(this,`__internal_RenderComponent`,()=>{let e=Dn();G(()=>(this.boundIdsStore.setState([...this.boundIdsStore.getState(),e]),()=>{this.boundIdsStore.setState(this.boundIdsStore.getState().filter(t=>t!==e))}),[e]);let t=$l(this.boundIdsStore),n=$l(this.providerStore),r=qa();return(t.length===0||t[0]===e)&&(0,J.jsxs)(zf,{adapters:this._runtimeAdapters,children:[(0,J.jsx)(this._hookManager.__internal_RenderThreadRuntimes,{provider:n}),(0,J.jsx)(this._hookManager.__internal_Host,{parentClient:r})]})}),this._state.subscribe(()=>{this._notifySubscribers(),this._notifyThreadIdChange()}),this._runtimeAdapters={modelContext:t},this._hookManager=new rm(e.runtimeHook,this),this._hookManager.__internal_setDefaultAdapters(this._runtimeAdapters),this._hookManager.__internal_subscribeRunningChanged(()=>{for(let t of Object.values(this._state.value.threadData))if(this._hookManager.__internal_isThreadRunning(t.id))this._runningThreads.add(t.id);else if(this._runningThreads.delete(t.id)){var e;let n=(e=this._hookManager.getThreadRuntimeCore(t.id))==null?void 0:e.messages.filter(Om);if(!n||t.status===`new`)continue;let r=this._adapterGeneration;queueMicrotask(()=>{!this._destroyController.signal.aborted&&r===this._adapterGeneration&&this.getItemById(t.id)&&this._generateTitle(t.id,{automatic:!0},()=>this._destroyController.signal.aborted?void 0:n,!0).catch(e=>{tu(e)||console.error(`[assistant-ui] Thread title generation failed`,e)})})}this._notifySubscribers()}),this._hookManager.__internal_subscribeRuntimeReplaced(()=>{queueMicrotask(()=>this._notifySubscribers())}),this.providerStore=new Mo(this.resolveProvider(e.adapter)),this.__internal_setOptions(e),this._startSwitchToNewThread(!0,n)}__internal_setOptions(e){if(this._options===e)return;let t=this._options!==void 0&&this._options.adapter!==e.adapter,n=this._initialThreadLoaded&&this._options!==void 0&&this._options.threadId!==e.threadId;t&&!this._replaceListOnNextLoad&&(this._staleThreadsAdapter=this._options.adapter),this._options=e,this.providerStore.setState(this.resolveProvider(e.adapter)),this._hookManager.setRuntimeHook(e.runtimeHook),t&&(this._loadGeneration++,this._adapterGeneration++,this._mutations=new Em,this._nextSwitchGeneration(),this._switchTask=void 0,this._loadThreadsPromise=void 0,this._loadMorePromise=void 0,this._replaceListOnNextLoad=!0,this._staleThreadIdsOnReplace=new Set([...Object.values(this._state.baseValue.threadData),...Object.values(this._state.value.threadData).filter(e=>{var t;return((t=Y(this._state.baseValue,e.id))==null?void 0:t.status)===`new`})].filter(e=>e.status!==`new`).map(e=>e.id)),this._titleStates.clear(),this._disarmAutomaticTitles(),this._runningThreads.clear(),this._state.update(E(E({},this._state.baseValue),{},{cursor:void 0,loadError:void 0}))),n&&this._switchToThreadFromProp(e.threadId).catch(()=>{})}_requireAdapterGeneration(e){if(e!==this._adapterGeneration)throw new Dm}_isOtherAdaptersThread(e,t,n){var r;let i=Y(e,n);return i!==void 0&&((r=this._staleThreadIdsOnReplace)!=null&&r.has(i.id)?this._staleThreadsAdapter:this._options.adapter)!==t}_updateStatusFromAdapter(e,t,n,r){return this._isOtherAdaptersThread(e,t,n)?e:Cm(e,n,r)}_requireAdapterSettled(){if(this._replaceListOnNextLoad)throw new Dm}_replaceWithThreads(e,t,n){let r=[];if(e.newThreadId){let t=Object.hasOwn(e.threadIdMap,e.newThreadId)?e.threadIdMap[e.newThreadId]:void 0,n=t&&Object.hasOwn(e.threadData,t)?e.threadData[t]:void 0;(n==null?void 0:n.status)===`new`&&r.push(n)}let i=this._staleThreadIdsOnReplace;if(i){let n=new Map(t.map(e=>[e.remoteId,e]));for(let t of Object.values(e.threadData)){if(!i.has(t.id)){if(t.status!==`new`&&t.remoteId===void 0)continue;r.push(t);continue}if(t.remoteId===void 0||t.localOrigin!==!0||Y(this._state.value,t.id)===void 0)continue;let e=n.get(t.remoteId);e!==void 0&&r.push(E(E({},t),{},{initializeTask:Promise.resolve({remoteId:e.remoteId,externalId:e.externalId})}))}}let a={threadIds:[],archivedThreadIds:[],threadIdMap:H(),threadData:H()};for(let e of r){let t=lm(e.id);Object.hasOwn(a.threadData,t)||(a.threadIdMap[e.id]=t,e.remoteId!==void 0&&(a.threadIdMap[e.remoteId]=t),a.threadData[t]=e)}let{threadIds:o,archivedThreadIds:s,threadIdMap:c,threadData:l}=fm(t,a);this._staleThreadIdsOnReplace=void 0,this._staleThreadsAdapter=void 0;for(let e of r){if(e.remoteId===void 0)continue;let t=lm(e.id),n=Object.hasOwn(l,t)?l[t]:void 0;n!==void 0&&(n.status===`regular`&&!o.includes(n.id)?o.push(n.id):n.status===`archived`&&!s.includes(n.id)&&s.push(n.id))}let u=E(E({},e),{},{isLoading:!1,cursor:n,threadIds:o,archivedThreadIds:s,threadIdMap:c,threadData:l,newThreadId:e.newThreadId!==void 0&&!Object.hasOwn(c,e.newThreadId)?void 0:e.newThreadId});if(Y(u,this._mainThreadId)===void 0){let e=u.newThreadId;if(e!==void 0)this._mainThreadId=e;else{let e=gm(u);this._mainThreadId=e.id,u=e.state}this._options.threadId===void 0?this._notifyThreadIdChange():this._lastNotifiedThreadId=void 0}let d=new Set(Object.values(u.threadData).map(e=>e.id));for(let t of Object.values(e.threadData))if(!d.has(t.id)){this._disarmAutomaticTitle(t.id),this._runningThreads.delete(t.id);try{this._hookManager.stopThreadRuntime(t.id)}catch(e){console.error(`[assistant-ui] Thread runtime cleanup threw while stopping a thread`,e)}}return this._hookManager.startThreadRuntime(this._mainThreadId).then(()=>this._notifySubscribers(),()=>void 0),u}__internal_load(){var e;if(this.getLoadThreadsPromise(),this._initialThreadLoaded)return;this._initialThreadLoaded=!0;let t=(e=this._options.threadId)==null?this._options.initialThreadId:e;t!==void 0&&(this._options.threadId===void 0?this.switchToThread(t):this._switchToThreadFromProp(t)).catch(()=>{})}reloadMainThread(){var e=this;return w(function*(){var t;let n=e._mainThreadId;if(n===void 0||((t=e.getItemById(n))==null?void 0:t.status)===`new`)return;let r=e._hookManager.getThreadRuntimeCore(n);try{r!=null&&r.unstable_refetchThread?yield r.unstable_refetchThread():yield e._hookManager.__internal_restartThreadRuntime(n)}catch(t){if(n!==e._mainThreadId)return;throw t}n===e._mainThreadId&&e._notifySubscribers()})()}reload(){return this._loadGeneration++,this._loadThreadsPromise=void 0,this._loadMorePromise=void 0,this._state.update(E(E({},this._state.baseValue),{},{cursor:void 0})),this.getLoadThreadsPromise()}get isLoading(){return this._state.value.isLoading}get canUnarchive(){return!!this._options.adapter.unarchive}get loadError(){return this._state.value.loadError}get switchError(){return this._switchError}_setSwitchError(e){this._switchError!==e&&(this._switchError=e,this._notifySubscribers())}get isLoadingMore(){return this._state.value.isLoadingMore}get hasMore(){return this._state.value.cursor!==void 0}get threadIds(){return this._state.value.threadIds}get archivedThreadIds(){return this._state.value.archivedThreadIds}get newThreadId(){return this._state.value.newThreadId}get mainThreadId(){return this._mainThreadId}_clearNewThreadIntent(){var e;(e=this._newThreadIntent)==null||e.unsubscribe(),this._newThreadIntent=void 0}_notifyThreadIdChange(e=!0){var t;let n=this._mainThreadId===void 0?void 0:Y(this._state.value,this._mainThreadId),r=n==null?void 0:n.remoteId;r!==void 0&&((t=this._newThreadIntent)==null?void 0:t.generation)===this._switchGeneration&&this._newThreadIntent.id===this._mainThreadId||r===void 0&&n&&n.status!==`new`||this._lastNotifiedThreadId!==r&&(this._lastNotifiedThreadId=r,e&&im(`assistant-ui`,`onThreadIdChange`,this._options.onThreadIdChange,r))}getMainThreadRuntimeCore(){return this._hookManager.getThreadRuntimeCore(this._mainThreadId)||cm}getThreadRuntimeCore(e){let t=this.getItemById(e);if(!t)throw Ym(e,`getting its runtime`);let n=this._hookManager.getThreadRuntimeCore(t.id);if(!n)throw Error(`Runtime for thread "${e}" not found while getting its runtime.`);return n}unstable_isThreadRunning(e){let t=this.getItemById(e);return t?this._hookManager.__internal_isThreadRunning(t.id):!1}unstable_subscribeThreadEvents(e){return this._hookManager.__internal_subscribeThreadEvents(e)}_getExposedItem(e){let t=Y(this._state.value,e);if(t!==void 0&&this._getExposedItems().ids.has(t.id))return t}getItemById(e){let t=Y(this._state.value,e);if(t!==void 0&&(this._getExposedItems().ids.has(t.id)||this._hookManager.__internal_hasThreadRuntime(t.id)))return t}switchToThread(e,t){var n;return this._controlledSwitchTask!==void 0&&this._controlledSwitchGeneration===this._switchGeneration&&this._supersedeAttachmentWait===void 0&&((n=Y(this._state.value,e))==null?void 0:n.id)===this._mainThreadId?Promise.resolve():this._startSwitchToThread(e,t,!0)}_nextSwitchGeneration(){var e;return(e=this._supersedeAttachmentWait)==null||e.call(this),this._supersedeAttachmentWait=void 0,++this._switchGeneration}_raceDispose(e,t){let n=this._destroyController.signal;return Bo(n,t).catch(t=>{if(!(t===n.reason&&this._disposedSwitchGeneration!==void 0&&e<this._disposedSwitchGeneration))throw t})}_startSwitchToThread(e,t,n){var r;if(this._supersedeAttachmentWait&&this._switchTask&&((r=Y(this._state.value,e))==null?void 0:r.id)===this._mainThreadId)return this._switchTask;this._clearNewThreadIntent();let i=this._nextSwitchGeneration();this._setSwitchError(void 0);let a=this._raceDispose(i,()=>this._switchToThread(e,t,i,n)).catch(t=>{var n;throw i===this._switchGeneration&&!tu(t)&&((n=Y(this._state.value,e))==null?void 0:n.id)!==this._mainThreadId&&this._setSwitchError({threadId:e,error:t}),t});return this._switchTask=a,a}_switchToThread(e,t,n,r){var i=this;return w(function*(){if(i._replaceListOnNextLoad&&e!==i._state.value.newThreadId)throw new Dm;let a=Y(i._state.value,e);if(!a){let t=i._options.adapter;if(yield i._state.optimisticUpdate({execute:()=>t.fetch(e),then:(e,t)=>n===i._switchGeneration?pm(e,t):e}),n!==i._switchGeneration)return;a=Y(i._state.value,e)}if(!a)throw Ym(e,`switching to it`);if(i._mainThreadId===a.id)return;let o=i.mainThreadId!==void 0,s=i._hookManager.startThreadRuntime(a.id);if(o?yield s:s.then(()=>i._notifySubscribers(),()=>void 0),n!==i._switchGeneration)return;let c=Y(i._state.value,a.id);if((c==null?void 0:c.id)===a.id&&!(c.status===`archived`&&(t==null?void 0:t.unarchive)!==!1&&i._options.adapter.unarchive&&(yield c.initializeTask,n!==i._switchGeneration||(c=Y(i._state.value,a.id),(c==null?void 0:c.id)!==a.id)||c.status===`archived`&&(yield i._unarchive(c.id,c),n!==i._switchGeneration||(c=Y(i._state.value,a.id),(c==null?void 0:c.id)!==a.id))))){for(i._setMainThreadId(c.id);o&&!i._hookManager.__internal_isThreadRuntimeAttached(c.id);)if(yield i._waitForReplacement(c.id),n!==i._switchGeneration)return;i._notifySubscribers(),i._notifyThreadIdChange(r)}})()}_setMainThreadId(e){if(this._mainThreadId=e,this._destroyController.signal.aborted||this._hookManager.getThreadRuntimeCore(e))return;let t=()=>this._notifySubscribers();this._hookManager.startThreadRuntime(e).then(t,t)}_waitForReplacement(e){var t=this;return w(function*(){let n,r=new Promise(e=>{n=e});t._supersedeAttachmentWait=n;try{yield Promise.race([t._hookManager.startThreadRuntime(e),r])}finally{t._supersedeAttachmentWait===n&&(t._supersedeAttachmentWait=void 0)}})()}switchToNewThread(){return this._startSwitchToNewThread(!0)}_switchToThreadFromProp(e){let t=e===void 0?md(`create`,()=>this._startSwitchToNewThread(!1)):md(`switch`,()=>this._startSwitchToThread(e,void 0,!1));this._controlledSwitchGeneration=this._switchGeneration,this._controlledSwitchTask=t;let n=()=>{if(this._controlledSwitchTask===t){var e;this._controlledSwitchTask=void 0,((e=this._newThreadIntent)==null?void 0:e.generation)===this._controlledSwitchGeneration&&this._clearNewThreadIntent()}};return t.then(n,n),t}__internal_retryControlledThread(){var e;let t=this._options.threadId;t!==void 0&&((e=this._switchError)==null?void 0:e.threadId)===t&&this._switchToThreadFromProp(t).catch(()=>{})}_startSwitchToNewThread(e,t){this._clearNewThreadIntent();let n=this._nextSwitchGeneration();!e&&this._state.baseValue.newThreadId===this._mainThreadId&&(this._newThreadIntent={id:this._mainThreadId,generation:n,unsubscribe:()=>{}}),this._setSwitchError(void 0);let r=this._raceDispose(n,()=>this._switchToNewThread(n,e,t));return this._switchTask=r,r}_switchToNewThread(e,t,n){var r=this;return w(function*(){for(;e===r._switchGeneration;){for(;r._state.baseValue.newThreadId!==void 0&&r._state.value.newThreadId===void 0;)if(yield r._state.waitForUpdate(),e!==r._switchGeneration)return;let i=r._state.value.newThreadId;if(i===void 0){let e=gm(r._state.baseValue,n);i=e.id,r._state.update(e.state)}let a=Y(r._state.value,i);if((a==null?void 0:a.status)!==`new`)continue;if(a.id===r._mainThreadId){if(!t){let t=r._state.subscribe(()=>{var n;e===r._switchGeneration?((n=Y(r._state.value,i))==null?void 0:n.status)!==`new`&&(t(),queueMicrotask(()=>{e===r._switchGeneration&&r._switchToThreadFromProp(void 0).catch(()=>{})})):t()});r._newThreadIntent={id:a.id,generation:e,unsubscribe:t}}return}let o=r._hookManager.startThreadRuntime(a.id);if(r.mainThreadId===void 0?o.then(()=>r._notifySubscribers(),()=>void 0):yield o,e!==r._switchGeneration)return;let s=Y(r._state.value,a.id);if((s==null?void 0:s.status)===`new`&&s.id===a.id){r._setMainThreadId(s.id),r._clearNewThreadIntent(),r._notifySubscribers(),r._notifyThreadIdChange(t);return}}})()}_armAutomaticTitle(e,t){var n;if(this._destroyController.signal.aborted)return;(n=this._automaticTitles.get(e))==null||n();let r,i,a=[],o=!1,s=!1,c=!0,l=()=>{if(!c)return;let t=this.getItemById(e);if(!t){this._disarmAutomaticTitle(e);return}let n=this._hookManager.getThreadRuntimeCore(t.id);n!==r&&(i==null||i(),r=n,i=n==null?void 0:n.subscribe(l));let u=r==null?void 0:r.messages.filter(Om);u!=null&&u.length&&(a=u),o&&!s&&r&&!r.isLoading&&a.length!==0&&(this._replaceListOnNextLoad?(s=!0,this._state.waitForUpdate().then(()=>{s=!1,l()})):(s=!0,this._generateTitle(e,{automatic:!0},()=>c?a:void 0).then(t=>{s=!1,c&&(t?this._disarmAutomaticTitle(e):l())},t=>{c&&(this._disarmAutomaticTitle(e),tu(t)||console.error(`[assistant-ui] Thread title generation failed`,t))})))},u=this._hookManager.subscribe(l);this._automaticTitles.set(e,()=>{c=!1,u(),i==null||i()}),t.then(()=>{o=!0,l()},()=>{c&&this._disarmAutomaticTitle(e)}),l()}_disarmAutomaticTitle(e){var t;(t=this._automaticTitles.get(e))==null||t(),this._automaticTitles.delete(e)}_disarmAutomaticTitles(){for(let e of[...this._automaticTitles.keys()])this._disarmAutomaticTitle(e)}rename(e,t){var n=this;return w(function*(){n._requireAdapterSettled();let r=n._options.adapter,i=n._adapterGeneration,a=n._getExposedItem(e);if(!a)throw Ym(e,`renaming it`);if(a.status===`new`)throw Xm(e,a.status,`be renamed`);let o=Bm(n._titleStates,a.id,t),s=n._mutations.reserve(a.id,a);try{let c=yield n._state.optimisticUpdate({execute:()=>s.run(w(function*(){let{remoteId:e}=yield a.initializeTask;return n._requireAdapterGeneration(i),r.rename(e,t)})),optimistic:i=>{if(n._isOtherAdaptersThread(i,r,e))return i;let a=Y(i,e);return a?E(E({},i),{},{threadData:E(E({},i.threadData),{},{[a.id]:E(E({},a),{},{title:t})})}):i}});return Vm(n._titleStates,a.id,o,!0),c}catch(e){throw Vm(n._titleStates,a.id,o,!1),e}})()}updateCustom(e,t){var n=this;return w(function*(){n._requireAdapterSettled();let r=n._options.adapter,i=n._adapterGeneration,a=n._getExposedItem(e);if(!a)throw Ym(e,`updating its custom metadata`);let o=i=>{if(n._isOtherAdaptersThread(i,r,e))return i;let a=Y(i,e);return a?E(E({},i),{},{threadData:E(E({},i.threadData),{},{[a.id]:E(E({},a),{},{custom:t})})}):i};if(a.status===`new`){n._state.update(o(n._state.baseValue));return}if(!r.updateCustom)throw Error(`Remote thread list adapter does not support updating custom metadata`);let s=n._mutations.reserve(a.id,a);return n._state.optimisticUpdate({execute:()=>s.run(w(function*(){let{remoteId:e}=yield a.initializeTask;if(n._requireAdapterGeneration(i),!r.updateCustom)throw Error(`Remote thread list adapter does not support updating custom metadata`);return r.updateCustom(e,t)})),optimistic:o})})()}_ensureThreadIsNotMain(e){var t=this;return w(function*(){if(e===t.newThreadId)throw Error(`Cannot ensure new thread is not main`);let n;for(;t._isMainThread(e);){if(e===t.newThreadId)throw Error(`Cannot ensure new thread is not main`);let r=t._switchTask,i=!r||r===n;i&&(r=t.switchToNewThread()),n=r;try{yield r}catch(e){if(i&&t._switchTask===r)throw e}}})()}_isMainThread(e){var t,n;return((t=(n=this.getItemById(e))==null?void 0:n.id)==null?e:t)===this._mainThreadId}_leaveRemovedMainThread(e){var t=this;return w(function*(){let n=t._mainThreadId,r=t.getItemById(n);if(r!==void 0&&(r.status!==`archived`||!t._isMainThread(e)))return;let i=t._state.baseValue.newThreadId!==void 0&&t._state.value.newThreadId===void 0;if(r===void 0&&!i){var a,o;let e=t._state.value.newThreadId;if(e===void 0){let n=gm(t._state.baseValue);e=n.id,t._state.update(n.state)}t._mainThreadId=(a=(o=Y(t._state.value,e))==null?void 0:o.id)==null?e:a,t._hookManager.stopThreadRuntime(n),t._hookManager.startThreadRuntime(t._mainThreadId).then(()=>t._notifySubscribers(),()=>void 0),t._notifySubscribers(),t._notifyThreadIdChange()}else yield t._ensureThreadIsNotMain(n),t.getItemById(n)===void 0&&t._hookManager.stopThreadRuntime(n)})()}archive(e){var t=this;return w(function*(){t._requireAdapterSettled();let n=t._options.adapter,r=t._adapterGeneration,i=t._getExposedItem(e);if(!i)throw Ym(e,`archiving it`);if(i.status!==`regular`)throw Xm(e,i.status,`be archived`);let a=t._mutations.reserve(i.id,i);try{do yield t._ensureThreadIsNotMain(i.id);while(i.id===t._mainThreadId);t._requireAdapterGeneration(r),yield t._state.optimisticUpdate({execute:()=>a.run(w(function*(){let{remoteId:e}=yield i.initializeTask;return t._requireAdapterGeneration(r),n.archive(e)})),optimistic:e=>t._updateStatusFromAdapter(e,n,i.id,`archived`)})}finally{a.cancel()}yield t._leaveRemovedMainThread(i.id)})()}unarchive(e){return this._unarchive(e,this._getExposedItem(e))}_unarchive(e,t){var n=this;return w(function*(){n._requireAdapterSettled();let r=n._options.adapter,i=n._adapterGeneration;if(!t)throw Ym(e,`unarchiving it`);if(t.status!==`archived`)throw Xm(e,t.status,`be unarchived`);if(!r.unarchive)throw Error(`Remote thread list adapter does not support unarchiving`);let a=n._mutations.reserve(t.id,t);return n._state.optimisticUpdate({execute:()=>a.run(w(function*(){try{let{remoteId:e}=yield t.initializeTask;if(n._requireAdapterGeneration(i),!r.unarchive)throw Error(`Remote thread list adapter does not support unarchiving`);return yield r.unarchive(e)}catch(e){throw i===n._adapterGeneration&&(yield n._ensureThreadIsNotMain(t.id)),e}})),optimistic:e=>n._updateStatusFromAdapter(e,r,t.id,`regular`)})})()}delete(e){var t=this;return w(function*(){t._requireAdapterSettled();let n=t._options.adapter,r=t._adapterGeneration,i=t._getExposedItem(e);if(!i)throw Ym(e,`deleting it`);if(i.status!==`regular`&&i.status!==`archived`)throw Xm(e,i.status,`be deleted`);let a=Y(t._state.baseValue,i.id),o=t._mutations.reserve(i.id,i),s;try{do yield t._ensureThreadIsNotMain(i.id);while(i.id===t._mainThreadId);t._requireAdapterGeneration(r),yield t._state.optimisticUpdate({execute:()=>o.run(w(function*(){return{remoteId:s}=yield i.initializeTask,t._requireAdapterGeneration(r),yield n.delete(s)})),optimistic:e=>t._isOtherAdaptersThread(e,n,i.id)?e:Tm(e,i.id,t._options.adapter===n?s:void 0)})}catch(e){var c,l;o.cancel();let s=()=>{if(r===t._adapterGeneration)return;let e=Y(t._state.baseValue,i.id);(e==null?void 0:e.status)===`new`&&e===a&&t._mainThreadId!==e.id?(t._state.update(Tm(t._state.baseValue,i.id,void 0)),t._hookManager.stopThreadRuntime(i.id),Gm(t._titleStates,i.id)):t._replaceListOnNextLoad&&e!==void 0&&e.status!==`new`&&e.remoteId===void 0&&t._mainThreadId!==e.id&&!t._isOtherAdaptersThread(t._state.baseValue,n,i.id)&&(t._state.update(Cm(t._state.baseValue,i.id,`deleted`)),t._hookManager.stopThreadRuntime(i.id),Gm(t._titleStates,i.id))};r!==t._adapterGeneration&&t._replaceListOnNextLoad&&((c=Y(t._state.baseValue,i.id))==null?void 0:c.status)===`new`?i.initializeTask.then(s,()=>{}):s();let u=t._options.threadId;throw t._switchGeneration===t._controlledSwitchGeneration&&u!==void 0&&t._mainThreadId!==i.id&&((l=t.getItemById(u))==null?void 0:l.id)===i.id&&t._switchToThreadFromProp(u).catch(()=>{}),e}t._isOtherAdaptersThread(t._state.value,n,i.id)||(t._hookManager.stopThreadRuntime(i.id),Gm(t._titleStates,i.id),yield t._leaveRemovedMainThread(i.id))})()}__internal_dispose(){this._clearNewThreadIntent(),this._disposedSwitchGeneration=this._switchGeneration,this._nextSwitchGeneration(),this._destroyController.abort(new Zp),this._disarmAutomaticTitles(),this._runningThreads.clear(),this._hookManager.__internal_dispose()}detach(e){var t=this;return w(function*(){let n=t._adapterGeneration,r=t.getItemById(e);if(!r)throw Ym(e,`detaching it`);if(r.status!==`regular`&&r.status!==`archived`)throw Xm(e,r.status,`be detached`);do yield t._ensureThreadIsNotMain(r.id);while(r.id===t._mainThreadId);t._requireAdapterGeneration(n),t._runningThreads.delete(r.id),t._hookManager.stopThreadRuntime(r.id)})()}},$m=(()=>{try{return process.env.NODE_ENV===`development`||process.env.NODE_ENV===`test`}catch(e){return!1}})(),eh=(e,t)=>function(){let n=Dn(),r=qa();G(()=>(t.setState([...t.getState(),n]),()=>t.setState(t.getState().filter(e=>e!==n))),[n]);let i=$l(t);return i.length===0||i[0]===n?Mn(e.__internal_Host,{parentClient:r}):null},th=class{get aui(){return this.handle.getClient()}constructor(e,t,n,r=!0){var i=this;S(this,`handle`,void 0),S(this,`hookManager`,void 0),S(this,`boundIdsStore`,new Mo([])),S(this,`cachedItems`,void 0),S(this,`cachedItemMap`,void 0),S(this,`pendingItems`,new Map),S(this,`mainReport`,void 0),S(this,`__internal_RenderComponent`,void 0),S(this,`__internal_ensureThread`,function(){var e=w(function*(e){let t={item:e,source:i.state.threadItems};i.pendingItems.set(e.id,t);try{yield i.hookManager.startThreadRuntime(e.id)}finally{i.pendingItems.get(e.id)===t&&i.pendingItems.delete(e.id)}});return function(t){return e.apply(this,arguments)}}()),S(this,`__internal_isThreadAttached`,e=>this.hookManager.__internal_isThreadRuntimeAttached(e)),S(this,`__internal_announceMainRemoteId`,e=>{let t=this.untilReported(()=>{var t;return((t=this.getItemById(this.mainThreadId))==null?void 0:t.remoteId)===e});this.mainReport=t,t.then(()=>{this.mainReport===t&&(this.mainReport=void 0)})}),this.handle=t,this.hookManager=new rm(n,this,!0),this.__internal_RenderComponent=eh(this.hookManager,this.boundIdsStore),r&&this.hookManager.startThreadRuntime(`${um}${e}`).catch(()=>{})}__internal_dispose(){this.hookManager.__internal_dispose()}get state(){return this.aui.threads.getState()}get actions(){var e,t;let n=(e=(t=this.aui.threads).__internal_getRawActions)==null?void 0:e.call(t);if(!n)throw Error(`Remote thread list is not mounted.`);return n}get isLoading(){return this.state.isLoading}get canUnarchive(){return this.state.canUnarchive}get loadError(){return this.state.loadError}get switchError(){return this.state.switchError}get isLoadingMore(){return this.state.isLoadingMore}get hasMore(){return this.state.hasMore}get mainThreadId(){return this.state.mainThreadId}get newThreadId(){var e;return(e=this.state.newThreadId)==null?void 0:e}get threadIds(){return this.state.threadIds}get archivedThreadIds(){return this.state.archivedThreadIds}get threadItems(){var e;let t=this.state.threadItems;return(((e=this.cachedItems)==null?void 0:e.length)!==t.length||t.some((e,t)=>{var n;return e!==((n=this.cachedItems)==null?void 0:n[t])}))&&(this.cachedItems=[...t],this.cachedItemMap=Object.fromEntries(t.map(e=>[e.id,e]))),this.cachedItemMap}getMainThreadRuntimeCore(){var e;return(e=this.hookManager.getThreadRuntimeCore(this.mainThreadId))==null?cm:e}getThreadRuntimeCore(e){var t;let n=this.getItemById(e);if(!n)throw Error(`Thread "${e}" not found while getting its runtime.`);return(t=this.hookManager.getThreadRuntimeCore(n.id))==null?cm:t}unstable_isThreadRunning(e){let t=this.getItemById(e);return t?this.hookManager.__internal_isThreadRunning(t.id):!1}unstable_subscribeThreadEvents(e){return this.hookManager.__internal_subscribeThreadEvents(e)}getItemById(e){var t,n,r,i,a;let o=this.state.threadItems,s=this.pendingItems.get(e);return(t=(n=o.find(t=>t.id===e||t.remoteId===e))==null?(r=(i=this.aui.threads).__internal_getThreadBody)==null||(r=r.call(i,e))==null||(a=r.__internal_getRuntime)==null?void 0:a.call(r).getState().metadata:n)==null?(s==null?void 0:s.source)===o?s.item:void 0:t}switchToThread(e,t){return this.actions.switchToThread(e,t)}switchToNewThread(){return this.actions.switchToNewThread()}getLoadThreadsPromise(){return this.aui.threads.getLoadThreadsPromise()}reload(){return this.aui.threads.reload()}loadMore(){return this.aui.threads.loadMore()}detach(e){return this.actions.detach(e)}rename(e,t){return this.actions.rename(e,t)}updateCustom(e,t){var n=this;return w(function*(){return n.aui.threads.item({id:e}).updateCustom(t)})()}archive(e){return this.actions.archive(e)}unarchive(e){return this.actions.unarchive(e)}delete(e){return this.actions.delete(e)}initialize(e){return this.actions.initialize(e)}generateTitle(e,t){var n,r,i;let a=(n=(r=this.getItemById(e))==null?void 0:r.id)==null?e:n,o=(i=this.hookManager.getThreadRuntimeCore(a))==null?void 0:i.messages.filter(Om);return this.actions.generateTitle(e,o,t)}reloadMainThread(){var e=this;return w(function*(){var t;e.mainReport&&(yield e.mainReport);let n=e.mainThreadId;if(((t=e.getItemById(n))==null?void 0:t.status)===`new`)return;let r=e.getMainThreadRuntimeCore();try{r.unstable_refetchThread?yield r.unstable_refetchThread():yield e.hookManager.__internal_restartThreadRuntime(n)}catch(t){if(n!==e.mainThreadId)return;throw t}})()}untilReported(e){return new Promise(t=>{let n=!1,r,i=()=>{n||(n=!0,clearTimeout(o),r==null||r(),t())},a=()=>{e()&&i()},o=setTimeout(i,100);r=this.handle.subscribe(a),n?r():a()})}subscribe(e){let t=this.handle.subscribe(e),n=this.hookManager.subscribe(e),r=this.hookManager.__internal_subscribeRunningChanged(e);return()=>{t(),n(),r()}}},nh=Promise.resolve(),rh=Hr(e=>{let t=K(19),{data:n,isMain:r,isInitialMain:i,isRunning:a,onSwitchTo:o,onRename:s,onUpdateCustom:c,onArchive:l,onUnarchive:u,onDelete:d}=e,f;t[0]!==n.custom||t[1]!==n.id||t[2]!==n.status||t[3]!==n.title||t[4]!==a?(f={id:n.id,remoteId:void 0,externalId:void 0,title:n.title,status:n.status,custom:n.custom,isRunning:a},t[0]=n.custom,t[1]=n.id,t[2]=n.status,t[3]=n.title,t[4]=a,t[5]=f):f=t[5];let p=f;pd(n.id,r,i);let m;t[6]===p?m=t[7]:(m=()=>p,t[6]=p,t[7]=m);let h;t[8]===n.id?h=t[9]:(h=w(function*(){return{remoteId:n.id,externalId:void 0}}),t[8]=n.id,t[9]=h);let g;return t[10]!==l||t[11]!==d||t[12]!==s||t[13]!==o||t[14]!==u||t[15]!==c||t[16]!==m||t[17]!==h?(g={getState:m,switchTo:o,rename:s,updateCustom:c,archive:l,unarchive:u,delete:d,generateTitle:lh,initialize:h,detach:uh},t[10]=l,t[11]=d,t[12]=s,t[13]=o,t[14]=u,t[15]=c,t[16]=m,t[17]=h,t[18]=g):g=t[18],g}),ih=()=>{let e=new Map,t,n,r=()=>{n==null||n(),n=void 0;for(let n of e.values())n.abort(t==null?void 0:t.reason)};return{signalFor(t,n){let r=e.get(t);return r||(r=new AbortController,n!=null&&n.aborted&&r.abort(n.reason),e.set(t,r)),r.signal},release(t){var n;(n=e.get(t))==null||n.abort(),e.delete(t)},releaseAll(){for(let t of e.values())t.abort();e.clear()},bindOwner(e){t!==e&&(n==null||n(),n=void 0,t=e,e&&(e.aborted?r():(e.addEventListener(`abort`,r),n=()=>e.removeEventListener(`abort`,r))))}}},ah=Hr(({destroySignal:e,thread:t})=>fa(e,function(){return ra(t).methods})),oh=`main`,sh=e=>{let t=K(78),{thread:n,onSwitchToThread:r,onSwitchToNewThread:i,onDelete:a}=e,o=pa(),[s]=_n(ih),[c]=_n(dh),l,u;t[0]!==s||t[1]!==o?(l=()=>{s.bindOwner(o)},u=[s,o],t[0]=s,t[1]=o,t[2]=l,t[3]=u):(l=t[2],u=t[3]),G(l,u);let[d,f]=_n(fh),{threads:p,mainThreadId:m}=d,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=e=>f(t=>E(E({},t),{},{threads:e(t.threads)})),t[4]=h):h=t[4];let _=h;fd(m);let v;t[5]!==c||t[6]!==r?(v=e=>{c.has(e)&&(f(t=>E(E({},t),{},{mainThreadId:e})),r==null||r(e))},t[5]=c,t[6]=r,t[7]=v):v=t[7];let y=v,b;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=(e,t)=>{_(n=>n.map(n=>n.id===e?E(E({},n),{},{title:t}):n))},t[8]=b):b=t[8];let x=b,S;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>{_(t=>t.map(t=>t.id===e?E(E({},t),{},{status:`archived`}):t))},t[9]=S):S=t[9];let C=S,w;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(w=e=>{_(t=>t.map(t=>t.id===e?E(E({},t),{},{status:`regular`}):t))},t[10]=w):w=t[10];let T=w,D;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(D=(e,t)=>{_(n=>n.map(n=>n.id===e?E(E({},n),{},{custom:t}):n))},t[11]=D):D=t[11];let O=D,k;t[12]!==c||t[13]!==s||t[14]!==a?(k=e=>{s.release(e);let t=`thread-${g()}`;c.delete(e),c.size===0&&c.add(t),f(n=>{var r;let i=n.threads.filter(t=>t.id!==e);return i.length===0?{threads:[{id:t,title:`New Thread`,status:`regular`}],mainThreadId:t}:{threads:i,mainThreadId:n.mainThreadId===e?((r=i.find(ph))==null?i[0]:r).id:n.mainThreadId}}),a==null||a(e)},t[12]=c,t[13]=s,t[14]=a,t[15]=k):k=t[15];let A=k,j;t[16]!==c||t[17]!==i?(j=()=>{let e=`thread-${g()}`;c.add(e),f(t=>({threads:[...t.threads,{id:e,title:`New Thread`,status:`regular`}],mainThreadId:e})),i==null||i()},t[16]=c,t[17]=i,t[18]=j):j=t[18];let M=j,N;t[19]!==s||t[20]!==m||t[21]!==o||t[22]!==n?(N=Ur(m,ah({destroySignal:s.signalFor(m,o),thread:n(m)})),t[19]=s,t[20]=m,t[21]=o,t[22]=n,t[23]=N):N=t[23];let P=ra(N),F;if(t[24]!==A||t[25]!==y||t[26]!==P.state||t[27]!==m||t[28]!==p){let e;t[30]!==A||t[31]!==y||t[32]!==P.state||t[33]!==m?(e=e=>Ur(e.id,rh({data:e,isMain:e.id===m,isInitialMain:e.id===oh,isRunning:e.id===m&&P.state.isRunning,onSwitchTo:()=>y(e.id),onRename:t=>x(e.id,t),onUpdateCustom:t=>O(e.id,t),onArchive:()=>C(e.id),onUnarchive:()=>T(e.id),onDelete:()=>A(e.id)})),t[30]=A,t[31]=y,t[32]=P.state,t[33]=m,t[34]=e):e=t[34],F=p.map(e),t[24]=A,t[25]=y,t[26]=P.state,t[27]=m,t[28]=p,t[29]=F}else F=t[29];let I=oo(F),L,R,z,B,ee,V,te,H,U,W;if(t[35]!==m||t[36]!==p){let e=p.filter(mh),n=p.filter(hh);L=m,R=null,z=!1,B=!0,ee=void 0,V=void 0,te=!1,H=!1,U=e.map(gh),W=n.map(_h),t[35]=m,t[36]=p,t[37]=L,t[38]=R,t[39]=z,t[40]=B,t[41]=ee,t[42]=V,t[43]=te,t[44]=H,t[45]=U,t[46]=W}else L=t[37],R=t[38],z=t[39],B=t[40],ee=t[41],V=t[42],te=t[43],H=t[44],U=t[45],W=t[46];let ne;t[47]!==P.state||t[48]!==L||t[49]!==R||t[50]!==z||t[51]!==B||t[52]!==ee||t[53]!==V||t[54]!==te||t[55]!==H||t[56]!==U||t[57]!==W||t[58]!==I.state?(ne={mainThreadId:L,newThreadId:R,isLoading:z,canUnarchive:B,loadError:ee,switchError:V,isLoadingMore:te,hasMore:H,threadIds:U,archivedThreadIds:W,threadItems:I.state,main:P.state},t[47]=P.state,t[48]=L,t[49]=R,t[50]=z,t[51]=B,t[52]=ee,t[53]=V,t[54]=te,t[55]=H,t[56]=U,t[57]=W,t[58]=I.state,t[59]=ne):ne=t[59];let re=ne,ie;t[60]===re?ie=t[61]:(ie=()=>re,t[60]=re,t[61]=ie);let ae;t[62]===P.methods?ae=t[63]:(ae=()=>{var e,t,n;return(e=(t=(n=P.methods).unstable_refetchThread)==null?void 0:t.call(n))==null?nh:e},t[62]=P.methods,t[63]=ae);let oe;t[64]!==m||t[65]!==re||t[66]!==I||t[67]!==p?(oe=e=>{if(e===`main`){let e=p.findIndex(e=>e.id===m);return I.get({index:e})}if(`id`in e){let t=p.findIndex(t=>t.id===e.id);return I.get({index:t})}let t=(e.archived?re.archivedThreadIds:re.threadIds)[e.index];if(t===void 0)return I.get({index:-1});let n=p.findIndex(e=>e.id===t);return I.get({index:n})},t[64]=m,t[65]=re,t[66]=I,t[67]=p,t[68]=oe):oe=t[68];let se;t[69]===P.methods?se=t[70]:(se=()=>P.methods,t[69]=P.methods,t[70]=se);let ce;return t[71]!==M||t[72]!==y||t[73]!==ie||t[74]!==ae||t[75]!==oe||t[76]!==se?(ce={getState:ie,switchToThread:y,switchToNewThread:M,getLoadThreadsPromise:vh,reload:yh,reloadMainThread:ae,loadMore:bh,item:oe,thread:se},t[71]=M,t[72]=y,t[73]=ie,t[74]=ae,t[75]=oe,t[76]=se,t[77]=ce):ce=t[77],ce},ch=(e,t)=>{e.thread!=null||(e.thread=Za({source:`threads`,query:{type:`main`},get:e=>e.threads.thread(`main`)})),e.threadListItem!=null||(e.threadListItem=Za({source:`threads`,query:{type:`main`},get:e=>e.threads.item(`main`)})),e.composer!=null||(e.composer=Za({source:`thread`,query:{},get:e=>e.threads.thread(`main`).composer()})),!e.modelContext&&t.modelContext.source===null&&(e.modelContext=Wl()),!e.tools&&t.tools.source===null&&(e.tools=Xl({})),!e.dataRenderers&&t.dataRenderers.source===null&&(e.dataRenderers=jl()),!e.suggestions&&t.suggestions.source===null&&(e.suggestions=Za({source:`thread`,query:{},get:e=>e.thread.suggestions()}))};gi(sh,ch);function lh(){}function uh(){}function dh(){return new Set([oh])}function fh(){return{threads:[{id:oh,title:`Main Thread`,status:`regular`}],mainThreadId:oh}}function ph(e){return e.status===`regular`}function mh(e){return e.status===`regular`}function hh(e){return e.status===`archived`}function gh(e){return e.id}function _h(e){return e.id}function vh(){return nh}function yh(){return nh}function bh(){return nh}var xh=Hr(({useAdapters:e,thread:t})=>{let n=Rd(),r=Bd(e()),i=(r==null?void 0:r.history)!=null&&t.key===void 0;return G(()=>{$m&&i&&console.warn(`[assistant-ui] RemoteThreadList received a history adapter, but the thread factory is unkeyed. Key the thread resource by thread id (withKey) so switching threads reloads history.`)},[i]),Ld(bn(()=>r==null?n:E(E({},n),r),[n,r]),function(){return ra(t).methods})}),Sh=Promise.resolve(),Ch=mm(),wh=(e,t)=>Error(`Thread "${e}" was not found while ${t}.`),Th=(e,t,n)=>Error(`Thread "${e}" has status "${t}", so it cannot ${n}.`),Eh=e=>({remoteId:e.remoteId,externalId:e.externalId}),Dh=Hr(e=>{let t=K(22),{data:n,isMain:r,isInitialMain:i,isRunning:a,onSwitchTo:o,onRename:s,onUpdateCustom:c,onArchive:l,onUnarchive:u,onDelete:d,onGenerateTitle:f,onInitialize:p,onDetach:m}=e,h=`lastMessageAt`in n?n.lastMessageAt:void 0,g;t[0]!==n.custom||t[1]!==n.externalId||t[2]!==n.id||t[3]!==n.remoteId||t[4]!==n.status||t[5]!==n.title||t[6]!==a||t[7]!==h?(g={id:n.id,remoteId:n.remoteId,externalId:n.externalId,title:n.title,lastMessageAt:h,status:n.status,custom:n.custom,isRunning:a},t[0]=n.custom,t[1]=n.externalId,t[2]=n.id,t[3]=n.remoteId,t[4]=n.status,t[5]=n.title,t[6]=a,t[7]=h,t[8]=g):g=t[8];let _=g;pd(n.id,r,i);let v;t[9]===_?v=t[10]:(v=()=>_,t[9]=_,t[10]=v);let y;return t[11]!==l||t[12]!==d||t[13]!==m||t[14]!==f||t[15]!==p||t[16]!==s||t[17]!==o||t[18]!==u||t[19]!==c||t[20]!==v?(y={getState:v,switchTo:o,rename:s,updateCustom:c,archive:l,unarchive:u,delete:d,generateTitle:f,initialize:p,detach:m},t[11]=l,t[12]=d,t[13]=m,t[14]=f,t[15]=p,t[16]=s,t[17]=o,t[18]=u,t[19]=c,t[20]=v,t[21]=y):y=t[21],y}),Oh=(e,t)=>{let n=[e.newThreadId,...e.threadIds,...e.archivedThreadIds,t].filter(e=>e!==void 0),r=new Set,i=new Set,a=[];for(let t of n){let n=Y(e,t);n&&!r.has(n.id)&&(n.remoteId!==void 0&&i.has(n.remoteId)||(r.add(n.id),n.remoteId!==void 0&&i.add(n.remoteId),a.push(n)))}return a},kh=(e,t,n)=>{let r=Y(e,n);if(r!==void 0)return[e.newThreadId,...e.threadIds,...e.archivedThreadIds,t].some(t=>{var n;return t!==void 0&&((n=Y(e,t))==null?void 0:n.id)===r.id})?r:void 0},Ah=(e,t,n)=>{let r=Y(t,n);return e.id===n||e.id===(r==null?void 0:r.id)||(r==null?void 0:r.remoteId)!==void 0&&(e.id===r.remoteId||e.remoteId===r.remoteId)},jh=(e,t,n)=>{if(t===n)return!0;let r=Y(e,t);return r!==void 0&&Ah(r,e,n)},Mh=Hr(({id:e,remoteId:t,item:n,thread:r,onAutomaticTitle:i})=>{let a=pi(),[o,s]=_n(!1),c=ra(n(o)),{client:l}=Ka(a,{threadListItem:Za({source:`threads`,query:{type:`id`,id:e},get:()=>c.methods})});return mi(l,function(){let n=ra(r),a=n.state.isRunning===!0,o=yn(!1);G(()=>{s(a)},[a]);let c=n.state.messages;return G(()=>{i(e,c,t!==void 0,n.state.isLoading,o.current&&!a),o.current=a}),n.methods})}),Nh=e=>na(e),Ph=e=>{let t=K(32),{listState:n,mainThreadId:r,initialMainId:i,startedIds:a,pendingAutomaticTitles:o,backgroundThreads:s,lifetimes:c,ownerDestroySignal:l,threadFactory:u,useAdapters:d,onSwitchTo:f,onRename:p,onUpdateCustom:m,onArchive:h,onUnarchive:g,onDelete:_,onGenerateTitle:v,onInitialize:y,onDetach:b}=e,x;bb0:{if(!s){let e;t[0]===r?e=t[1]:(e=[r],t[0]=r,t[1]=e),x=e;break bb0}let e;if(t[2]!==n||t[3]!==a){let r=new Set,i=new Set;e=[];for(let t of a){let a=Y(n,t);a&&!r.has(a.id)&&(a.remoteId!==void 0&&i.has(a.remoteId)||(r.add(a.id),a.remoteId!==void 0&&i.add(a.remoteId),e.push(a.id)))}t[2]=n,t[3]=a,t[4]=e}else e=t[4];x=e}let S=x,C;t[5]!==s||t[6]!==n||t[7]!==v||t[8]!==o?(C=(e,t,r,i,a)=>{let c=o.get(e);if(c===void 0&&!(s&&a))return;let l=t.filter(Om),u=(t,n)=>{v(e,t,{automatic:!0},n!==void 0&&n).catch(Lh)};if(c!==void 0){l.length>0&&o.set(e,l);let t=l.length>0?l:c;r&&!i&&t.length>0&&(o.delete(e),u(t))}let d=Y(n,e);s&&a&&d&&d.status!==`new`&&u(l,!0)},t[5]=s,t[6]=n,t[7]=v,t[8]=o,t[9]=C):C=t[9];let w=C,T=(e,t,a)=>Dh({data:e,isMain:a&&Ah(e,n,r),isInitialMain:e.id===i,isRunning:t,onSwitchTo:t=>md(`switch`,()=>f(e.id,t)),onRename:t=>md(`rename`,()=>p(e.id,t)),onUpdateCustom:t=>md(`update custom metadata`,()=>m(e.id,t)),onArchive:()=>md(`archive`,()=>h(e.id)),onUnarchive:()=>md(`unarchive`,()=>g(e.id)),onDelete:()=>md(`delete`,()=>_(e.id)),onGenerateTitle:t=>md(`generate title`,()=>{var n;return v(e.id,s?(n=k(e.id))==null?void 0:n.messages:F.state.messages,t)}),onInitialize:()=>y(e.id),onDetach:()=>md(`detach`,()=>b(e.id))}),E=oo(S.map(e=>{var t;let r=u(e),i=s&&r.key===void 0?Ur(e,r):r,a=d===void 0?i:xh({useAdapters:d,thread:i}),o=Y(n,e),f=s&&o!==void 0?Mh({id:e,remoteId:o.remoteId,item:e=>T(o,e,!1),thread:a,onAutomaticTitle:w}):a;return Ur(s?e:(t=r.key)==null?`main`:t,ah({destroySignal:c.signalFor(e,l),thread:f}))})),D;t[10]!==S||t[11]!==n?(D=e=>{let t=S.indexOf(e);return t===-1?S.findIndex(t=>jh(n,t,e)):t},t[10]=S,t[11]=n,t[12]=D):D=t[12];let O=D,k=e=>{let t=O(e);return t===-1?void 0:E.state[t]},A;t[13]!==s||t[14]!==E||t[15]!==O||t[16]!==r?(A=e=>{if(!s&&e!==r)return;let t=O(e);return t===-1?void 0:E.get({index:t})},t[13]=s,t[14]=E,t[15]=O,t[16]=r,t[17]=A):A=t[17];let j=A,M,N,P;if(t[18]!==E||t[19]!==O||t[20]!==r){let e=O(r);P=E.state[e],M=Nh,N=E.get({index:e}),t[18]=E,t[19]=O,t[20]=r,t[21]=M,t[22]=N,t[23]=P}else M=t[21],N=t[22],P=t[23];let F={state:P,methods:M(N)},I;t[24]!==n||t[25]!==r?(I=Oh(n,r),t[24]=n,t[25]=r,t[26]=I):I=t[26];let L=I,R=oo(L.map(e=>{var t,i;return Ur(e.id,T(e,s?(t=(i=k(e.id))==null?void 0:i.isRunning)!=null&&t:Ah(e,n,r)&&F.state.isRunning,!0))})),z;return t[27]!==j||t[28]!==L||t[29]!==F||t[30]!==R?(z={mainThreadClient:F,itemOrder:L,threadListItems:R,bodyMethodsOf:j},t[27]=j,t[28]=L,t[29]=F,t[30]=R,t[31]=z):z=t[31],z},Fh=e=>{var t;let{adapter:n,thread:r,threadId:i,onThreadIdChange:a,onSwitchToThread:o,onSwitchToNewThread:s,onDelete:c,__internal_ensureThread:l,__internal_isThreadAttached:u,__internal_preserveDraftOnAdapterChange:d,__internal_reopenControlledThreadOnAdapterChange:f}=e,p=pa(),m=Mi(),[h]=_n(ih);G(()=>{h.bindOwner(p)},[h,p]);let g=Dn(),_=Pl(),[{store:v,initialMainId:y,session:b}]=_n(()=>{var t;let r=gm(Ch,(t=e.__internal_initialThreadIdSeed)==null?_?g:void 0:t);return{store:new om(r.state),initialMainId:r.id,session:{adapter:n,adapterAtLoad:n,adapterGeneration:0,titleStates:new Map,mutations:new Em,pendingAutomaticTitles:new Map,loadGeneration:0,switchGeneration:0,startedIds:new Set([r.id]),pendingEnsures:new Map,loadPromise:void 0,loadMorePromise:void 0,lastNotifiedRemoteId:void 0,lastControlledThreadId:void 0,controlledSwitchGeneration:void 0,controlledSwitchAdapter:void 0,controlledReloadPending:!1,replaceListPending:!1,switchTask:void 0,pendingSwitchGeneration:void 0,settleSwitch:void 0,newThreadIntent:void 0,supersedeAttachmentWait:void 0,mainThreadId:r.id,isFirstThreadIdEffect:!0,onThreadIdChange:a,onSwitchToThread:o,onSwitchToNewThread:s}}}),x=wn(e=>v.subscribe(e),()=>v.value,()=>v.value),S=gd(x,xn(()=>v.value,[v])),[C,T]=_n(y),[D,O]=_n([y]),[k]=_n(e.backgroundThreads===!0),[A,j]=_n(0),M=xn(e=>{b.mainThreadId=e,b.startedIds.add(e);let t=b.pendingEnsures.get(e);t&&(t.wasStarted=!0),T(e),O(t=>t.includes(e)?t:[...t,e])},[b]);fd(C),G(()=>{b.adapter=n,b.mainThreadId=C,b.onThreadIdChange=a,b.onSwitchToThread=o,b.onSwitchToNewThread=s},[n,C,s,o,a,b]);let N=xn((e,t)=>{var n;if(e!==void 0&&((n=b.newThreadIntent)==null?void 0:n.generation)===b.switchGeneration&&b.newThreadIntent.id===b.mainThreadId)return;let r=Y(v.value,b.mainThreadId);e===void 0&&r&&r.status!==`new`||b.lastNotifiedRemoteId!==e&&(b.lastNotifiedRemoteId=e,t&&im(`assistant-ui`,`onThreadIdChange`,b.onThreadIdChange,e))},[b,v]);G(()=>v.subscribe(()=>{let e=Y(v.value,b.mainThreadId);e&&N(e.remoteId,!0)}),[N,b,v]);let P=xn(()=>{if(b.loadPromise)return b.loadPromise;let e=b.replaceListPending,t=b.loadGeneration,n=b.adapter,r=vm(v.baseValue),i=(t,n)=>{if(!e)return ym(t,n,r);let i=new Map(n.threads.map(e=>[e.remoteId,e])),a=t;for(let[e,t]of r){if(t===`new`)continue;let n=Y(a,e);if(!n||n.status===`new`)continue;let r=n.remoteId===void 0?void 0:i.get(n.remoteId);a=r?E(E({},a),{},{threadData:E(E({},a.threadData),{},{[n.id]:E(E({},n),{},{initializeTask:Promise.resolve({remoteId:r.remoteId,externalId:r.externalId})})})}):Tm(a,e,n.remoteId)}if(a=ym(a,n,r),!Y(a,b.mainThreadId)){let e=a.newThreadId;if(e===void 0){let t=gm(a);e=t.id,a=t.state}M(e),N(void 0,b.lastControlledThreadId===void 0&&b.controlledSwitchGeneration!==b.switchGeneration)}for(let e of b.startedIds)Y(a,e)||(b.startedIds.delete(e),h.release(e));return O([...b.startedIds]),a};return b.loadPromise=v.optimisticUpdate({execute:()=>n.list(),loading:e=>t===b.loadGeneration?E(E({},e),{},{isLoading:!0,loadError:void 0}):e,then:(e,r)=>t===b.loadGeneration?(b.adapterAtLoad=n,b.replaceListPending=!1,i(e,r)):e}).catch(n=>{t===b.loadGeneration&&(console.error(`[assistant-ui] thread list load failed:`,n),b.loadPromise=void 0,b.replaceListPending=!1,v.update(E(E({},e?i(v.baseValue,{threads:[]}):v.baseValue),{},{isLoading:!1,loadError:n})))}).then(()=>j(e=>e+1)),b.loadPromise},[M,h,N,b,v]),F=xn(()=>{let e=n!==b.adapterAtLoad;if(b.loadGeneration++,b.loadPromise=void 0,b.loadMorePromise=void 0,e){var t,r;let e=d?v.baseValue.newThreadId:void 0,i=e===void 0?void 0:Y(v.baseValue,e),a=(i==null?void 0:i.status)===`new`?i:void 0;b.adapterGeneration++,b.mutations=new Em,b.titleStates.clear(),b.pendingAutomaticTitles.clear();let o=b.lastControlledThreadId!==void 0&&(f||b.controlledSwitchAdapter===n)&&b.controlledSwitchGeneration===b.switchGeneration;if((t=b.supersedeAttachmentWait)==null||t.call(b),b.switchGeneration++,(r=b.settleSwitch)==null||r.call(b),b.controlledReloadPending=o,o&&(b.controlledSwitchGeneration=b.switchGeneration),b.switchTask=void 0,b.pendingSwitchGeneration=void 0,b.pendingEnsures.clear(),b.adapterAtLoad=n,l)return v.reset(E(E({},v.baseValue),{},{cursor:void 0,isLoading:!0,loadError:void 0})),b.replaceListPending=!0,P();if(a)for(let e of b.startedIds)e!==a.id&&h.release(e);else h.releaseAll();let s=a?{id:a.id,state:hm(Ch,a)}:gm(Ch);v.reset(E(E({},s.state),{},{isLoading:!0})),b.startedIds=new Set([s.id]),M(s.id),O([s.id]),N(void 0,!o)}else v.update(E(E({},v.baseValue),{},{cursor:void 0}));return P()},[n,M,l,P,h,N,d,f,b,v]);G(()=>{P()},[P]),G(()=>{l&&n!==b.adapterAtLoad&&F()},[n,l,F,b]);let I=n.unstable_useAdapters===void 0&&n.unstable_Provider!==void 0,L=yn(!1);G(()=>{I?$m&&!L.current&&(L.current=!0,console.warn(l?`[assistant-ui] useRemoteThreadListRuntime mounted with an adapter without unstable_Provider, so it ignores RemoteThreadListAdapter.unstable_Provider on this adapter. Expose unstable_useAdapters so per-thread history loads.`:`[assistant-ui] RemoteThreadList ignores RemoteThreadListAdapter.unstable_Provider. Expose unstable_useAdapters so per-thread history loads on this entry. useRemoteThreadListRuntime renders unstable_Provider only when the adapter it mounts with has one.`)):L.current=!1},[I,l]);let R=xn(()=>{if(b.loadMorePromise)return b.loadMorePromise;let e=v.value;if(e.cursor===void 0||e.isLoading)return Sh;let t=b.loadGeneration,n=e.cursor,r=b.adapter,i=v.optimisticUpdate({execute:()=>r.list({after:n}),loading:e=>t===b.loadGeneration?E(E({},e),{},{isLoadingMore:!0}):e,then:(e,n)=>t===b.loadGeneration?bm(e,n):e}).catch(e=>{t===b.loadGeneration&&console.error(`[assistant-ui] thread list loadMore failed:`,e)}).then(()=>{b.loadMorePromise===i&&(b.loadMorePromise=void 0),j(e=>e+1)});return b.loadMorePromise=i,i},[b,v]),z=xn((e,t)=>{var n,r,i;if(p!=null&&p.aborted)return Promise.reject(new Zp);if(b.supersedeAttachmentWait&&b.switchTask&&t!==void 0&&jh(v.value,t,b.mainThreadId))return b.switchTask;(n=b.supersedeAttachmentWait)==null||n.call(b),b.supersedeAttachmentWait=void 0,(r=b.newThreadIntent)==null||r.unsubscribe(),b.newThreadIntent=void 0;let a=++b.switchGeneration;(i=b.settleSwitch)==null||i.call(b),b.controlledReloadPending=!1,v.baseValue.switchError!==void 0&&v.update(E(E({},v.baseValue),{},{switchError:void 0}));let o,s,c=new Promise((e,t)=>{o=e,s=t});b.switchTask=c,b.pendingSwitchGeneration=a;let u,d=()=>{var e;u==null||u(),((e=b.newThreadIntent)==null?void 0:e.generation)===a&&(b.newThreadIntent.unsubscribe(),b.newThreadIntent=void 0),p==null||p.removeEventListener(`abort`,f),b.pendingSwitchGeneration===a&&(b.pendingSwitchGeneration=void 0,b.settleSwitch=void 0),o()},f=()=>{var e;a===b.switchGeneration?(u==null||u(),b.switchGeneration++,b.pendingSwitchGeneration=void 0,b.settleSwitch=void 0,(e=b.supersedeAttachmentWait)==null||e.call(b),b.supersedeAttachmentWait=void 0,s(new Zp)):d()};return p==null||p.addEventListener(`abort`,f,{once:!0}),l&&(b.settleSwitch=d),e(a).then(()=>{if(!l||a!==b.switchGeneration||p!=null&&p.aborted){d();return}let e=()=>{m.current.threads.getState().mainThreadId===b.mainThreadId&&d()};u=m.current.subscribe(e),e()},e=>{var n;((n=b.newThreadIntent)==null?void 0:n.generation)===a&&(b.newThreadIntent.unsubscribe(),b.newThreadIntent=void 0),p==null||p.removeEventListener(`abort`,f),b.pendingSwitchGeneration===a&&(b.pendingSwitchGeneration=void 0,b.settleSwitch=void 0),t!==void 0&&a===b.switchGeneration&&!tu(e)&&!jh(v.value,t,b.mainThreadId)&&v.update(E(E({},v.baseValue),{},{switchError:{threadId:t,error:e}})),s(e)}),c},[m,l,p,b,v]),B=xn(function(){var e=w(function*(e,t,n,r,i=!1){var a;let o=Y(v.value,e);if(!o){let t=b.adapter;if(yield v.optimisticUpdate({execute:()=>t.fetch(e),then:(e,t)=>r===b.switchGeneration?pm(e,t):e}),r!==b.switchGeneration)return;o=Y(v.value,e)}if(!o)throw wh(e,`switching to it`);if(jh(v.value,o.id,b.mainThreadId)){i&&(yield l==null?void 0:l(o));return}let s=o.id,c=l?(a=b.pendingEnsures.get(s))==null?{wasStarted:b.startedIds.has(s),count:0}:a:void 0;c&&(b.pendingEnsures.set(s,c),c.count++,b.startedIds.add(s),O(e=>e.includes(s)?e:[...e,s]));try{var d,f;if(l&&(yield l(o),r!==b.switchGeneration))return;let e=Y(v.value,s);if((e==null?void 0:e.id)!==s)return;if(e.status===`archived`&&(t==null?void 0:t.unarchive)!==!1&&b.adapter.unarchive){let{remoteId:t}=yield e.initializeTask;if(r!==b.switchGeneration||(e=Y(v.value,s),(e==null?void 0:e.id)!==s))return;if(e.status===`archived`){let n=b.mutations.reserve(s),i=b.adapter,a=b.adapterGeneration;if(yield v.optimisticUpdate({execute:()=>n.run(w(function*(){if(U(a),!i.unarchive)throw Error(`Remote thread list adapter does not support unarchiving`);return i.unarchive(t)})),optimistic:e=>Cm(e,s,`regular`)}),r!==b.switchGeneration||(e=Y(v.value,s),(e==null?void 0:e.id)!==s))return}}if(r!==b.switchGeneration||i&&e.status!==`new`)return;for(M(e.id);l&&(u==null?void 0:u(e.id))===!1;){let t,n=new Promise(e=>{t=e});b.supersedeAttachmentWait=t;try{yield Promise.race([l(e),n])}finally{b.supersedeAttachmentWait===t&&(b.supersedeAttachmentWait=void 0)}if(r!==b.switchGeneration)return}N(e.remoteId,n),i?(d=b.onSwitchToNewThread)==null||d.call(b):(f=b.onSwitchToThread)==null||f.call(b,e.id)}finally{c&&(c.count--,b.pendingEnsures.get(s)===c&&c.count===0&&(b.pendingEnsures.delete(s),!c.wasStarted&&!jh(v.value,s,b.mainThreadId)&&(b.startedIds.delete(s),O(e=>e.filter(e=>e!==s)),h.release(s))))}});return function(t,n,r,i){return e.apply(this,arguments)}}(),[M,l,u,h,N,b,v]),ee=xn((e,t,n=!0)=>n&&b.controlledSwitchGeneration===b.switchGeneration&&b.pendingSwitchGeneration===b.switchGeneration&&b.supersedeAttachmentWait===void 0&&jh(v.value,e,b.mainThreadId)?Sh:z(r=>B(e,t,n,r),e),[B,b,z,v]),V=xn((e=!0,t=!1)=>{let n=function(){var r=w(function*(r){for(t&&v.baseValue.newThreadId===b.mainThreadId&&(b.newThreadIntent={id:b.mainThreadId,generation:r,unsubscribe:()=>{}});r===b.switchGeneration;){for(var i,a,o;v.baseValue.newThreadId!==void 0&&v.value.newThreadId===void 0;)if(yield v.waitForUpdate(),r!==b.switchGeneration)return;let s=v.value.newThreadId;if(s===void 0){let e=gm(v.baseValue);v.update(e.state),s=e.id}let c=(i=(a=Y(v.value,s))==null?void 0:a.id)==null?s:i;if(jh(v.value,c,b.mainThreadId)){if(t){let e=v.subscribe(()=>{var t;r===b.switchGeneration?((t=Y(v.value,c))==null?void 0:t.status)!==`new`&&(e(),queueMicrotask(()=>{r===b.switchGeneration&&md(`create`,()=>{let e=z(n);return b.controlledSwitchGeneration=b.switchGeneration,b.controlledSwitchAdapter=b.adapter,e})})):e()});b.newThreadIntent={id:c,generation:r,unsubscribe:e}}return B(c,void 0,e,r,!0)}if(yield B(c,void 0,e,r,!0),r!==b.switchGeneration||((o=Y(v.value,c))==null?void 0:o.status)===`new`)return}});return function(e){return r.apply(this,arguments)}}();return z(n)},[B,b,z,v]);G(()=>{if(typeof window>`u`||typeof document>`u`)return;let e=()=>{v.value.loadError!==void 0&&P();let e=v.value.switchError;e!==void 0&&e.threadId===i&&md(`switch`,()=>{let e=ee(i,void 0,!1);return b.controlledSwitchGeneration=b.switchGeneration,b.controlledSwitchAdapter=b.adapter,e})},t=()=>{document.visibilityState===`visible`&&e()};return window.addEventListener(`online`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`online`,e),document.removeEventListener(`visibilitychange`,t)}},[P,b,v,ee,i]);let te=xn(function(){var e=w(function*(e){if(e===v.value.newThreadId)throw Error(`Cannot ensure new thread is not main`);let t;for(;jh(v.value,e,b.mainThreadId);){if(e===v.value.newThreadId)throw Error(`Cannot ensure new thread is not main`);let n=b.switchTask,r=!n||n===t;r&&(n=V()),t=n;try{yield n}catch(e){if(r&&b.switchTask===n)throw e}}});return function(t){return e.apply(this,arguments)}}(),[b,v,V]),H=xn(function(){var e=w(function*(e){let t=Y(v.value,b.mainThreadId);if(t!==void 0&&(t.status!==`archived`||!jh(v.value,e,b.mainThreadId)))return;let n=v.baseValue.newThreadId!==void 0&&v.value.newThreadId===void 0;if(t===void 0&&!n){var r,i,a;let e=v.value.newThreadId,t;if(e!==void 0)t=(r=(i=Y(v.value,e))==null?void 0:i.id)==null?e:r;else{let e=gm(v.baseValue);v.update(e.state),t=e.id}M(t),N(void 0,!0),(a=b.onSwitchToNewThread)==null||a.call(b)}else yield te(b.mainThreadId)});return function(t){return e.apply(this,arguments)}}(),[M,te,N,b,v]),U=xn(e=>{if(e!==b.adapterGeneration)throw new Dm},[b]),W=xn(function(){var e=w(function*(e){var t;let n=b.adapter,r=b.adapterGeneration;if(v.value.newThreadId!==e){let t=Y(v.value,e);if(!t)throw wh(e,`initializing it`);if(t.status===`new`)throw Th(e,t.status,`be initialized here`);let n=Eh(yield t.initializeTask);return U(r),n}U(r);let i=(t=Y(v.value,e))==null?void 0:t.custom,a=i===void 0?n.initialize(e):n.initialize(e,{custom:i});k&&b.pendingAutomaticTitles.set(e,[]);let o,s,c=v.optimisticUpdate({execute:()=>a,optimistic:t=>wm(t,e,a),then:(t,{remoteId:n,externalId:i})=>{if(r!==b.adapterGeneration)return t;let a=xm(t,e,n,i,k?e:b.mainThreadId);return o=a.removedMappingId,o!==void 0&&b.mutations.merge(a.survivorMappingId,o),o===b.mainThreadId&&(s=a.survivorMappingId),a.state}}),l;try{l=yield c}catch(t){throw b.pendingAutomaticTitles.delete(e),t}return U(r),o!==void 0&&(b.startedIds.delete(o),O(e=>e.filter(e=>e!==o))),s!==void 0&&b.mainThreadId===o&&M(s),e===b.mainThreadId&&N(l.remoteId,!0),H(e).catch(()=>{}),Eh(l)});return function(t){return e.apply(this,arguments)}}(),[M,k,H,N,U,b,v]),ne=xn(function(){var e=w(function*(e,t){let n=b.adapter,r=b.adapterGeneration,i=kh(v.value,b.mainThreadId,e);if(!i)throw wh(e,`renaming it`);if(i.status===`new`)throw Th(e,i.status,`be renamed`);let a=Bm(b.titleStates,i.id,t),o=b.mutations.reserve(i.id,i);return v.optimisticUpdate({execute:()=>o.run(w(function*(){let{remoteId:e}=yield i.initializeTask;return U(r),n.rename(e,t)})),optimistic:n=>{let r=Y(n,e);return r?E(E({},n),{},{threadData:E(E({},n.threadData),{},{[r.id]:E(E({},r),{},{title:t})})}):n}}).then(e=>(Vm(b.titleStates,i.id,a,!0),e),e=>{throw Vm(b.titleStates,i.id,a,!1),e})});return function(t,n){return e.apply(this,arguments)}}(),[U,b,v]),re=xn(function(){var e=w(function*(e,t){let n=b.adapter,r=b.adapterGeneration,i=kh(v.value,b.mainThreadId,e);if(!i)throw wh(e,`updating its custom metadata`);let a=n=>{let r=Y(n,e);return r?E(E({},n),{},{threadData:E(E({},n.threadData),{},{[r.id]:E(E({},r),{},{custom:t})})}):n};if(i.status===`new`){v.update(a(v.baseValue));return}if(!n.updateCustom)throw Error(`Remote thread list adapter does not support updating custom metadata`);let o=b.mutations.reserve(i.id,i);return v.optimisticUpdate({execute:()=>o.run(w(function*(){let{remoteId:e}=yield i.initializeTask;if(U(r),!n.updateCustom)throw Error(`Remote thread list adapter does not support updating custom metadata`);return n.updateCustom(e,t)})),optimistic:a})});return function(t,n){return e.apply(this,arguments)}}(),[U,b,v]),ie=xn(function(){var e=w(function*(e){let t=b.adapter,n=b.adapterGeneration,r=kh(v.value,b.mainThreadId,e);if(!r)throw wh(e,`archiving it`);if(r.status!==`regular`)throw Th(e,r.status,`be archived`);let i=b.mutations.reserve(r.id,r);try{do yield te(r.id);while(jh(v.value,r.id,b.mainThreadId));U(n),yield v.optimisticUpdate({execute:()=>i.run(w(function*(){let{remoteId:e}=yield r.initializeTask;return U(n),t.archive(e)})),optimistic:e=>Cm(e,r.id,`archived`)})}finally{i.cancel()}yield H(r.id)});return function(t){return e.apply(this,arguments)}}(),[te,H,U,b,v]),ae=xn(function(){var e=w(function*(e){let t=b.adapter,n=b.adapterGeneration,r=kh(v.value,b.mainThreadId,e);if(!r)throw wh(e,`unarchiving it`);if(r.status!==`archived`)throw Th(e,r.status,`be unarchived`);if(!t.unarchive)throw Error(`Remote thread list adapter does not support unarchiving`);let i=b.mutations.reserve(r.id,r);return v.optimisticUpdate({execute:()=>i.run(w(function*(){try{let{remoteId:e}=yield r.initializeTask;if(U(n),!t.unarchive)throw Error(`Remote thread list adapter does not support unarchiving`);return yield t.unarchive(e)}catch(e){throw n===b.adapterGeneration&&(yield te(r.id)),e}})),optimistic:e=>Cm(e,r.id,`regular`)})});return function(t){return e.apply(this,arguments)}}(),[te,U,b,v]),oe=xn(function(){var e=w(function*(e){let t=b.adapter,n=b.adapterGeneration,r=kh(v.value,b.mainThreadId,e);if(!r)throw wh(e,`deleting it`);if(r.status!==`regular`&&r.status!==`archived`)throw Th(e,r.status,`be deleted`);let i=b.mutations.reserve(r.id,r),a,o;try{do yield te(r.id);while(jh(v.value,r.id,b.mainThreadId));U(n),o=yield v.optimisticUpdate({execute:()=>i.run(w(function*(){return{remoteId:a}=yield r.initializeTask,U(n),t.delete(a)})),optimistic:e=>Tm(e,r.id,a)})}finally{i.cancel()}return yield H(r.id),Y(v.value,r.id)===void 0&&(h.release(r.id),Gm(b.titleStates,r.id),b.pendingAutomaticTitles.delete(r.id),c==null||c(r.id)),o});return function(t){return e.apply(this,arguments)}}(),[te,H,h,c,U,b,v]),se=xn(function(){var e=w(function*(e,t,n,r=!1){let i=b.adapter,a=b.adapterGeneration,o=Y(v.value,e);if(!o)throw wh(e,`generating its title`);if(o.status===`new`)throw Th(e,o.status,`generate a title`);let{remoteId:s}=yield o.initializeTask;if(U(a),!k&&!jh(v.value,o.id,b.mainThreadId)||!t)return;let c=()=>Y(v.baseValue,o.id)===void 0;yield qm({states:b.titleStates,threadId:o.id,automatic:(n==null?void 0:n.automatic)===!0,messages:t,generate:function(){var e=w(function*(e){if(c())return;let n=yield i.generateTitle(s,t);U(a),yield km(n,e)});return function(t){return e.apply(this,arguments)}}(),rename:function(){var e=w(function*(e){yield b.mutations.reserve(o.id,o).run(w(function*(){U(a),c()||(yield i.rename(s,e))}))});return function(t){return e.apply(this,arguments)}}(),readTitle:function(){var e=w(function*(){if(U(a),c())return;let{title:e}=yield i.fetch(s);return U(a),e});return function(){return e.apply(this,arguments)}}(),applyTitle:function(){var e=w(function*(e){yield v.optimisticUpdate({execute:function(){var e=w(function*(){});return function(){return e.apply(this,arguments)}}(),optimistic:t=>{if(a!==b.adapterGeneration)return t;let n=Y(t,o.id);return n?E(E({},t),{},{threadData:E(E({},t.threadData),{},{[n.id]:E(E({},n),{},{title:e})})}):t}})});return function(t){return e.apply(this,arguments)}}(),afterRun:r?()=>{var e;if(U(a),p!=null&&p.aborted)throw new Zp;return(e=Y(v.value,o.id))==null?void 0:e.title}:void 0})});return function(t,n,r){return e.apply(this,arguments)}}(),[k,p,U,b,v]),ce=xn(function(){var e=w(function*(e){do yield te(e);while(jh(v.value,e,b.mainThreadId));h.release(e),b.startedIds.delete(e),O(t=>t.filter(t=>t!==e))});return function(t){return e.apply(this,arguments)}}(),[te,h,b,v]),{mainThreadClient:le,itemOrder:ue,threadListItems:de,bodyMethodsOf:fe}=Ph({listState:x,mainThreadId:C,initialMainId:y,startedIds:D,pendingAutomaticTitles:b.pendingAutomaticTitles,backgroundThreads:k,lifetimes:h,ownerDestroySignal:p,threadFactory:r,useAdapters:l?void 0:n.unstable_useAdapters,onSwitchTo:(e,t)=>ee(e,t),onRename:(e,t)=>ne(e,t),onUpdateCustom:(e,t)=>S(re(e,t)),onArchive:e=>ie(e),onUnarchive:e=>ae(e),onDelete:e=>oe(e),onGenerateTitle:(e,t,n,r)=>se(e,t,n,r),onInitialize:function(){var e=w(function*(e){return Eh(yield W(e))});return function(t){return e.apply(this,arguments)}}(),onDetach:e=>ce(e)});G(()=>{let e=()=>{var e;(e=b.newThreadIntent)==null||e.unsubscribe(),b.newThreadIntent=void 0};return p==null||p.addEventListener(`abort`,e,{once:!0}),()=>{p==null||p.removeEventListener(`abort`,e),e()}},[p,b]);let pe=(t=Y(x,C))==null?void 0:t.remoteId;G(()=>{N(pe,!0)},[pe,N,a]),G(()=>{if(b.isFirstThreadIdEffect){if(b.isFirstThreadIdEffect=!1,b.lastControlledThreadId=i,i===void 0)return;md(`switch`,()=>{let e=ee(i,void 0,!1);return b.controlledSwitchGeneration=b.switchGeneration,b.controlledSwitchAdapter=b.adapter,e})}else Object.is(b.lastControlledThreadId,i)||(b.lastControlledThreadId=i,i===void 0?md(`create`,()=>{let e=V(!1,!0);return b.controlledSwitchGeneration=b.switchGeneration,b.controlledSwitchAdapter=b.adapter,e}):md(`switch`,()=>{let e=ee(i,void 0,!1);return b.controlledSwitchGeneration=b.switchGeneration,b.controlledSwitchAdapter=b.adapter,e}))},[b,V,ee,i]),G(()=>{let e=b.lastControlledThreadId;if(x.isLoading||x.isLoadingMore||e===void 0||b.controlledSwitchGeneration!==b.switchGeneration||!f&&b.controlledReloadPending&&x.loadError!==void 0||!b.controlledReloadPending&&Y(x,e)===void 0)return;let t=f&&b.controlledReloadPending;b.controlledReloadPending=!1,jh(x,e,b.mainThreadId)||md(`switch`,()=>{let n=ee(e,void 0,!1),r=b.switchGeneration,i=b.adapter;return b.controlledSwitchGeneration=r,b.controlledSwitchAdapter=i,t&&n.catch(()=>{b.switchGeneration===r&&b.controlledSwitchGeneration===r&&b.lastControlledThreadId===e&&b.adapter===i&&(b.controlledReloadPending=!0)}),n})},[A]);let me=bn(()=>{var e;return{mainThreadId:C,newThreadId:(e=x.newThreadId)==null?null:e,isLoading:x.isLoading,canUnarchive:!!n.unarchive,loadError:x.loadError,switchError:x.switchError,isLoadingMore:x.isLoadingMore,hasMore:x.cursor!==void 0,threadIds:x.threadIds,archivedThreadIds:x.archivedThreadIds,threadItems:de.state,main:le.state}},[x.archivedThreadIds,n.unarchive,x.cursor,x.isLoading,x.loadError,x.switchError,x.isLoadingMore,x.newThreadId,x.threadIds,le.state,C,de.state]),he=()=>{var e,t,n,r;return((e=Y(v.value,C))==null?void 0:e.status)===`new`||(t=(n=(r=le.methods).unstable_refetchThread)==null?void 0:n.call(r))==null?Sh:t};return{getState:()=>me,switchToThread:(e,t)=>{md(`switch`,()=>ee(e,t))},switchToNewThread:()=>{md(`create`,()=>V())},getLoadThreadsPromise:()=>S(P()),reload:()=>S(F()),reloadMainThread:he,loadMore:()=>S(R()),item:e=>{if(e===`main`){let e=ue.findIndex(e=>Ah(e,x,C));return de.get({index:e})}if(`id`in e){let t=ue.findIndex(t=>Ah(t,x,e.id));return de.get({index:t})}let t=(e.archived?x.archivedThreadIds:x.threadIds)[e.index];if(t===void 0)return de.get({index:-1});let n=ue.findIndex(e=>Ah(e,x,t));return de.get({index:n})},thread:()=>le.methods,__internal_getRawActions:()=>({switchToThread:ee,switchToNewThread:V,rename:ne,archive:ie,unarchive:ae,delete:oe,detach:ce,generateTitle:se,initialize:W,reload:F,reloadMainThread:he,getLoadThreadsPromise:P,loadMore:R}),__internal_getThreadBody:fe}},Ih=Hr(Fh);gi(Fh,ch);function Lh(e){tu(e)||console.error(`[assistant-ui] Thread title generation failed`,e)}var Rh=e=>{let t=K(18),{clientCore:n,threadId:r,startThread:i}=e,a=qa(),o=n.hookManager,s=r,c=pa(),l,u;t[0]!==c||t[1]!==s||t[2]!==o||t[3]!==i?(l=()=>{i&&o.startThreadRuntime(s).catch(Vh);let e=()=>o.stopThreadRuntime(s);return c==null||c.addEventListener(`abort`,e,{once:!0}),()=>c==null?void 0:c.removeEventListener(`abort`,e)},u=[o,s,c,i],t[0]=c,t[1]=s,t[2]=o,t[3]=i,t[4]=l,t[5]=u):(l=t[4],u=t[5]),G(l,u);let d;if(t[6]!==a.subscribe||t[7]!==a.threadListItem||t[8]!==s||t[9]!==o){let e;t[11]!==s||t[12]!==o?(e=()=>{var e;return(e=o.getThreadRuntimeCore(s))==null?cm:e},t[11]=s,t[12]=o,t[13]=e):e=t[13];let n;t[14]===o?n=t[15]:(n=e=>o.subscribe(e),t[14]=o,t[15]=n);let r;t[16]===a.threadListItem?r=t[17]:(r=()=>E(E({},a.threadListItem.getState()),{},{isMain:!1}),t[16]=a.threadListItem,t[17]=r),d=new If(new Io({path:{ref:`threads[${s}]`,threadSelector:{type:`threadId`,threadId:s}},getState:e,subscribe:n}),new Po({path:{ref:`threadItems[${s}]`,threadSelector:{type:`threadId`,threadId:s}},getState:r,subscribe:a.subscribe})),t[6]=a.subscribe,t[7]=a.threadListItem,t[8]=s,t[9]=o,t[10]=d}else d=t[10];return d},zh=e=>{let t=qa(),n=yn(t);return En(()=>{n.current=t},[t]),mi(bn(()=>uo({getClient:()=>n.current,subscribe:e=>n.current.subscribe(e)}),[]),function(){return Rh(e)})},Bh=Hr(e=>{let t=K(2),n=zh(e),r;return t[0]===n?r=t[1]:(r=ld({runtime:n}),t[0]=n,t[1]=r),Gr(r)});function Vh(){}var Hh={getState:()=>0,getServerSnapshot:()=>0,subscribe:()=>()=>{}},Uh=e=>{let t=K(35),{optionsStore:n,generationStore:r,assistantRuntime:i,initialThreadIdSeed:a,clientCore:o}=e,s=$l(n),c=$l(r==null?Hh:r),[l,u]=_n(s.threadId!==void 0||s.initialThreadId===void 0),d;t[0]!==o||t[1]!==l?(d={clientCore:o,startThread:l},t[0]=o,t[1]=l,t[2]=d):d=t[2];let f=d,p;t[3]!==c||t[4]!==f?(p=e=>Ur(`${e}:${c}`,Bh(E(E({},f),{},{threadId:e}))),t[3]=c,t[4]=f,t[5]=p):p=t[5];let m=p,h=Mi(),g;t[6]!==i||t[7]!==h?(g=()=>(typeof i==`function`?i():i).registerModelContextProvider(h.current.modelContext()),t[6]=i,t[7]=h,t[8]=g):g=t[8];let _;t[9]===i?_=t[10]:(_=[i],t[9]=i,t[10]=_),Li(`modelContext`,g,_);let v=yn(s.initialThreadId),y;t[11]!==h||t[12]!==s.threadId?(y=()=>{var e,t;s.threadId===void 0&&v.current!==void 0&&((e=(t=h.current.threads).__internal_getRawActions)==null||e.call(t).switchToThread(v.current).finally(()=>u(!0)).catch(Gh))},t[11]=h,t[12]=s.threadId,t[13]=y):y=t[13];let b;t[14]===h?b=t[15]:(b=[h],t[14]=h,t[15]=b),G(y,b);let x=s.onThreadIdChange,S;t[16]!==o||t[17]!==x?(S=e=>(o.__internal_announceMainRemoteId(e),x==null?void 0:x(e)),t[16]=o,t[17]=x,t[18]=S):S=t[18];let C=S,w;t[19]!==o.__internal_ensureThread||t[20]!==o.__internal_isThreadAttached||t[21]!==a||t[22]!==C||t[23]!==s.adapter||t[24]!==s.threadId||t[25]!==m?(w=Ih({adapter:s.adapter,thread:m,threadId:s.threadId,onThreadIdChange:C,backgroundThreads:!0,__internal_ensureThread:o.__internal_ensureThread,__internal_isThreadAttached:o.__internal_isThreadAttached,__internal_initialThreadIdSeed:a,__internal_preserveDraftOnAdapterChange:!0,__internal_reopenControlledThreadOnAdapterChange:!0}),t[19]=o.__internal_ensureThread,t[20]=o.__internal_isThreadAttached,t[21]=a,t[22]=C,t[23]=s.adapter,t[24]=s.threadId,t[25]=m,t[26]=w):w=t[26];let T=Gr(w),D;t[27]===o?D=t[28]:(D=()=>o.reloadMainThread(),t[27]=o,t[28]=D);let O;t[29]===i?O=t[30]:(O=()=>typeof i==`function`?i():i,t[29]=i,t[30]=O);let k;return t[31]!==O||t[32]!==D||t[33]!==T?(k=E(E({},T),{},{reloadMainThread:D,__internal_getAssistantRuntime:O}),t[31]=O,t[32]=D,t[33]=T,t[34]=k):k=t[34],k},Wh=Hr(Uh);gi(Uh,ch);function Gh(){}var Kh=class extends rp{constructor(e,t){super(),S(this,`threads`,void 0),this.threads=new Qm(e,this._contextProvider,t)}get RenderComponent(){return this.threads.__internal_RenderComponent}},qh=class extends rp{constructor(e,t,n){super(),S(this,`threads`,void 0),S(this,`optionsStore`,void 0),this.optionsStore=new Mo(e);let r=this.optionsStore,i=this._contextProvider;this.threads=new th(t,n,function(){let e=$l(r),t=Rd(),n=e.adapter.unstable_useAdapters,a=Bd(Gr(bn(()=>Hr(function(e){return n==null?void 0:n.call(e)}),[n])(e.adapter)));return Ld(bn(()=>E(E({modelContext:i},t),a),[t,a]),e.runtimeHook)},e.threadId!==void 0||e.initialThreadId===void 0)}get RenderComponent(){return this.threads.__internal_RenderComponent}},Jh=(e,t)=>{let[n]=_n(()=>new Kh(e,t)),[r]=_n(()=>({generation:0})),i=yn(!1);G(()=>{$m&&!i.current&&(i.current=!0,console.warn(`[assistant-ui] RemoteThreadListAdapter.unstable_Provider is deprecated and will be removed in a future minor release. Return the same adapters from unstable_useAdapters and drop unstable_Provider so useRemoteThreadListRuntime runs on the RemoteThreadList client.`))},[]),En(()=>{let e=++r.generation;return()=>queueMicrotask(()=>{r.generation===e&&n.threads.__internal_dispose()})},[n,r]),G(()=>{n.threads.__internal_setOptions(e)},[n,e]);let a=e.adapter;G(()=>{n.threads.__internal_load()},[n,a]),G(()=>{if(typeof window>`u`||typeof document>`u`)return;let e=()=>{n.threads.loadError!==void 0&&n.threads.reload(),n.threads.__internal_retryControlledThread()},t=()=>{document.visibilityState===`visible`&&e()};return window.addEventListener(`online`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`online`,e),document.removeEventListener(`visibilitychange`,t)}},[n]);let[o]=_n(()=>new np(n));return o},Yh=(e,t)=>{let[n]=_n(()=>{let n=io({getConfig:()=>Me({threads:Wh({optionsStore:r.optionsStore,assistantRuntime:()=>i,initialThreadIdSeed:t,clientCore:r.threads})}),subscribe:()=>()=>{}}),r=new qh(e,t,n),i=new np(r);return{assistantRuntime:i,core:r,handle:n,generation:0}});return Fl(()=>n.handle.subscribe(()=>{}),[n]),En(()=>{let e=++n.generation;return()=>queueMicrotask(()=>{n.generation===e&&(n.handle.destroy(),n.core.threads.__internal_dispose())})},[n]),Fl(()=>{n.core.optionsStore.setState(e)},[n,e]),n.assistantRuntime},Xh=e=>{let t=Dn(),n=Pl(),[r]=_n(()=>e.adapter.unstable_Provider===void 0?`client`:`legacy`),[i]=_n(()=>n?t:r===`client`?Math.random().toString(36).slice(2):``);return r===`legacy`?Jh(e,n?i:void 0):Yh(e,i)},Zh=e=>{let[t]=_n(()=>new Mo(e.runtimeHook));Fl(()=>{t.setState(e.runtimeHook)},[t,e.runtimeHook]);let n=yn(e.initialThreadId),[r]=_n(()=>function(){return $l({subscribe:t.subscribe,getState:t.getState,getServerSnapshot:t.getState})()}),i=Cn(t=>{var n;return(n=e.onThreadIdChange)==null?void 0:n.call(e,t)}),a=bn(()=>({adapter:e.adapter,allowNesting:e.allowNesting,threadId:e.threadId,initialThreadId:n.current,runtimeHook:r,onThreadIdChange:i}),[e.adapter,e.allowNesting,e.threadId,r]);if(qa().threadListItem.source!==null){if(!a.allowNesting)throw Error(`useRemoteThreadListRuntime cannot be nested inside another RemoteThreadListRuntime. Set allowNesting: true to allow nesting (the inner runtime will become a no-op).`);return e.runtimeHook()}return Xh(a)};function Qh(e,t){this.v=e,this.k=t}function $h(e){return new Qh(e,0)}function eg(e){return function(){return new tg(e.apply(this,arguments))}}function tg(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof Qh;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`?`return`:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(a.done?`return`:`normal`,n)},function(e){r(`throw`,e)})}catch(e){i(`throw`,e)}}function i(e,i){switch(e){case`return`:t.resolve({value:i,done:!0});break;case`throw`:t.reject(i);break;default:t.resolve({value:i,done:!1})}(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}tg.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},tg.prototype.next=function(e){return this._invoke(`next`,e)},tg.prototype.throw=function(e){return this._invoke(`throw`,e)},tg.prototype.return=function(e){return this._invoke(`return`,e)};var ng=e=>{let t=K(6),{id:n,children:r}=e,i=qa(),a;t[0]===n?a=t[1]:(a=Me({message:Za({source:`thread`,query:{type:`id`,id:n},get:e=>e.thread.message({id:n})}),composer:Za({source:`message`,query:{},get:e=>e.thread.message({id:n}).composer()})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,J.jsx)(Dd,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},rg=(e,t)=>e.Message===t.Message&&e.EditComposer===t.EditComposer&&e.UserEditComposer===t.UserEditComposer&&e.AssistantEditComposer===t.AssistantEditComposer&&e.SystemEditComposer===t.SystemEditComposer&&e.UserMessage===t.UserMessage&&e.AssistantMessage===t.AssistantMessage&&e.SystemMessage===t.SystemMessage,ig=()=>null,ag=new WeakMap,og=(e,t)=>{let n=ag.get(e);return n||(n=new Set(e.map(e=>e.id)),ag.set(e,n)),n.has(t)},sg=(e,t,n)=>{switch(t){case`user`:var r,i,a,o;return n?(r=(i=(a=e.UserEditComposer)==null?e.EditComposer:a)==null?e.UserMessage:i)==null?e.Message:r:(o=e.UserMessage)==null?e.Message:o;case`assistant`:var s,c,l,u;return n?(s=(c=(l=e.AssistantEditComposer)==null?e.EditComposer:l)==null?e.AssistantMessage:c)==null?e.Message:s:(u=e.AssistantMessage)==null?e.Message:u;case`system`:var d,f,p,m,h,g;return n?(d=(f=(p=(m=e.SystemEditComposer)==null?e.EditComposer:m)==null?e.SystemMessage:p)==null?e.Message:f)==null?ig:d:(h=(g=e.SystemMessage)==null?e.Message:g)==null?ig:h;default:throw Error(`Unknown message role: ${t}`)}},cg=e=>{let t=K(6),{components:n}=e,r=q(mg),i=q(hg),a;t[0]!==n||t[1]!==i||t[2]!==r?(a=sg(n,r,i),t[0]=n,t[1]=i,t[2]=r,t[3]=a):a=t[3];let o=a,s;return t[4]===o?s=t[5]:(s=(0,J.jsx)(o,{}),t[4]=o,t[5]=s),s},lg=An(e=>{let t=K(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,J.jsx)(cg,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,J.jsx)(Kd,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&rg(e.components,t.components));lg.displayName=`ThreadPrimitive.MessageByIndex`;var ug=An(e=>{let t=K(7),{messageId:n,components:r}=e,i;if(t[0]===n?i=t[1]:(i=e=>og(e.thread.messages,n),t[0]=n,t[1]=i),!q(i))return null;let a;t[2]===r?a=t[3]:(a=(0,J.jsx)(cg,{components:r}),t[2]=r,t[3]=a);let o;return t[4]!==n||t[5]!==a?(o=(0,J.jsx)(ng,{id:n,children:a}),t[4]=n,t[5]=a,t[6]=o):o=t[6],o},(e,t)=>e.messageId===t.messageId&&rg(e.components,t.components));ug.displayName=`ThreadPrimitive.Unstable_MessageById`;var dg=({children:e})=>{let t=q(Ta(e=>e.thread.messages.map(e=>e.id)));return bn(()=>t.length===0?null:t.map((t,n)=>(0,J.jsx)(Kd,{index:n,children:(0,J.jsx)(Ad,{getItemState:e=>e.thread.message({index:n}).getState(),children:t=>e({get message(){return t()}})})},t)),[t,e])},fg=e=>{let t=K(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,J.jsx)(dg,{children:()=>(0,J.jsx)(cg,{components:n})}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,J.jsx)(dg,{children:r}),t[2]=r,t[3]=i),i};fg.displayName=`ThreadPrimitive.Messages`;var pg=An(fg,(e,t)=>e.children||t.children?e.children===t.children:rg(e.components,t.components));function mg(e){return e.message.role}function hg(e){return e.message.composer.isEditing}var gg=e=>{var t;let n=e.message.metadata;if(n&&typeof n==`object`)return(t=n.custom)==null?void 0:t.quote},_g=class extends Error{constructor(e,t=`Component "${e}" is not in the generative-ui allowlist.`){super(t),S(this,`componentName`,void 0),this.name=`GenerativeUIRenderError`,this.componentName=e}},vg=e=>typeof e==`object`&&!!e&&!Array.isArray(e),yg=e=>e==null?[]:Array.isArray(e)?e:[e],bg=(e,...t)=>{typeof process<`u`&&process.env.NODE_ENV!==`production`&&console.warn(e,...t)},xg=64,Sg=(e,t,n,r,i=0)=>{if(i>xg)return bg(`[generative-ui] Skipping node nested past ${xg} levels at ${r}.`),null;if(e==null)return null;if(typeof e==`string`||typeof e==`number`)return e;if(Array.isArray(e))return e.map((e,a)=>Sg(e,t,n,`${r}/${a}`,i+1));if(!vg(e)||!(`component`in e)||typeof e.component!=`string`)return bg(`[generative-ui] Skipping malformed node at ${r}:`,e),null;let{component:a,props:o,children:s,key:c}=e,l=Object.hasOwn(t,a)?t[a]:void 0;if(!l){if(n)return(0,J.jsx)(n,{component:a,props:o},c==null?r:c);throw new _g(a)}return Mn(l,E(E({},o==null?{}:o),{},{key:c==null?r:c}),...yg(s).map((e,a)=>Sg(e,t,n,`${r}/${a}`,i+1)))},Cg=e=>{let t=K(11),{spec:n,components:r,Fallback:i}=e,a=n==null?void 0:n.root,o;t[0]===a?o=t[1]:(o=yg(a),t[0]=a,t[1]=o);let s=o,c;if(t[2]!==i||t[3]!==r||t[4]!==s){let e;t[6]!==i||t[7]!==r?(e=(e,t)=>Sg(e,r,i,`${t}`),t[6]=i,t[7]=r,t[8]=e):e=t[8],c=s.map(e),t[2]=i,t[3]=r,t[4]=s,t[5]=c}else c=t[5];let l;return t[9]===c?l=t[10]:(l=(0,J.jsx)(J.Fragment,{children:c}),t[9]=c,t[10]=l),l};Cg.displayName=`GenerativeUIRender`;var wg=e=>{let t=K(4),{components:n,spec:r,Fallback:i}=e,a=q(Tg),o=r==null?a:r;if(!o)return null;let s;return t[0]!==i||t[1]!==n||t[2]!==o?(s=(0,J.jsx)(Cg,{spec:o,components:n,Fallback:i}),t[0]=i,t[1]=n,t[2]=o,t[3]=s):s=t[3],s};wg.displayName=`MessagePrimitive.GenerativeUI`;function Tg(e){let t=e.part;return(t==null?void 0:t.type)===`generative-ui`?t.spec:void 0}var Eg=(e,t,n)=>{var r,i,a;return((r=(i=e.toolUIs[t.toolName])==null||(i=i[0])==null?void 0:i.render)==null?null:r)||n||(V((a=t.mcp)==null||(a=a.app)==null?void 0:a.resourceUri)&&e.mcpApp?e.mcpApp.render:null)},Dg=[`ByName`,`Fallback`],Og=[`Fallback`],kg=e=>{let t=-1;return{startGroup:e=>{t===-1&&(t=e)},endGroup:(n,r)=>{t!==-1&&(r.push({type:e,startIndex:t,endIndex:n}),t=-1)},finalize:(n,r)=>{t!==-1&&r.push({type:e,startIndex:t,endIndex:n})}}},Ag=(e,t,n)=>{let r=[];if(t){let t=kg(`chainOfThoughtGroup`);for(let n=0;n<e.length;n++){let i=e[n];i===`tool-call`||i===`reasoning`?t.startGroup(n):(t.endGroup(n-1,r),r.push({type:`single`,index:n}))}t.finalize(e.length-1,r)}else{let t=kg(`toolGroup`),n=kg(`reasoningGroup`);for(let i=0;i<e.length;i++){let a=e[i];a===`tool-call`?(n.endGroup(i-1,r),t.startGroup(i)):a===`reasoning`?(t.endGroup(i-1,r),n.startGroup(i)):(t.endGroup(i-1,r),n.endGroup(i-1,r),r.push({type:`single`,index:i}))}t.finalize(e.length-1,r),n.finalize(e.length-1,r)}if(n){let e=new Set;for(let t of r){if(t.type===`single`)continue;let r=n[t.startIndex];r!=null&&r.includes(`:`)&&!e.has(r)&&(e.add(r),t.idKey=`id:${r}`)}}return r},jg=e=>{let t=K(10),n=q(Ta(e_)),r=q(Ta(t_)),i;bb0:{if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0];let n;t[1]===r?n=t[2]:(n={ranges:e,partIds:r},t[1]=r,t[2]=n),i=n;break bb0}let a;t[3]!==n||t[4]!==r||t[5]!==e?(a=Ag(n,e,r),t[3]=n,t[4]=r,t[5]=e,t[6]=a):a=t[6];let o;t[7]!==r||t[8]!==a?(o={ranges:a,partIds:r},t[7]=r,t[8]=a,t[9]=o):o=t[9],i=o}return i},Mg=e=>{let t=K(11),n,r,i;if(t[0]!==e){var a=e;({ByName:n,Fallback:r}=a),i=W(a,Dg),t[0]=e,t[1]=n,t[2]=r,t[3]=i}else n=t[1],r=t[2],i=t[3];let o;t[4]!==n||t[5]!==r||t[6]!==i?(o=e=>{var t;return(t=Eg(e.tools,i,n))==null?r:t},t[4]=n,t[5]=r,t[6]=i,t[7]=o):o=t[7];let s=q(o);if(!s)return null;let c;return t[8]!==s||t[9]!==i?(c=(0,J.jsx)(s,E({},i)),t[8]=s,t[9]=i,t[10]=c):c=t[10],c},Ng=(e,t,n)=>{var r,i;return((r=e.renderers[t])==null?void 0:r[0])||((i=e.fallbacks[0])==null?n:i)},Pg=e=>{let t=K(9),n,r;if(t[0]!==e){var i=e;({Fallback:n}=i),r=W(i,Og),t[0]=e,t[1]=n,t[2]=r}else n=t[1],r=t[2];let a;t[3]!==n||t[4]!==r.name?(a=e=>Ng(e.dataRenderers,r.name,n),t[3]=n,t[4]=r.name,t[5]=a):a=t[5];let o=q(a);if(!o)return null;let s;return t[6]!==o||t[7]!==r?(s=(0,J.jsx)(o,E({},r)),t[6]=o,t[7]=r,t[8]=s):s=t[8],s},Fg={Text:()=>null,Reasoning:()=>null,Source:()=>null,Image:()=>null,File:()=>null,Unstable_Audio:()=>null,ToolGroup:({children:e})=>e,ReasoningGroup:({children:e})=>e},Ig=e=>{var t;let n=K(54),{components:r}=e,i;n[0]===r?i=n[1]:(i=r===void 0?{}:r,n[0]=r,n[1]=i);let{Text:a,Reasoning:o,Image:s,Source:c,File:l,Unstable_Audio:u,tools:d,data:f,generativeUI:p}=i,m=a===void 0?Fg.Text:a,h=o===void 0?Fg.Reasoning:o,g=s===void 0?Fg.Image:s,_=c===void 0?Fg.Source:c,v=l===void 0?Fg.File:l,y=u===void 0?Fg.Unstable_Audio:u,b;n[2]===d?b=n[3]:(b=d===void 0?{}:d,n[2]=d,n[3]=b);let x=b,S=qa(),C=q(n_),w=C.type;if(w===`tool-call`){let e=S.part.addToolResult,t=S.part.resumeToolCall,r=S.part.respondToToolApproval,i=S.part.unstable_recordInteraction;if(`Override`in x){let a;n[4]===i?a=n[5]:(a=i&&{unstable_recordInteraction:i},n[4]=i,n[5]=a);let o;return n[6]!==e||n[7]!==C||n[8]!==r||n[9]!==t||n[10]!==a||n[11]!==x.Override?(o=(0,J.jsx)(x.Override,E(E({},C),{},{addResult:e,resume:t,respondToApproval:r},a)),n[6]=e,n[7]=C,n[8]=r,n[9]=t,n[10]=a,n[11]=x.Override,n[12]=o):o=n[12],o}let a;n[13]!==C.toolName||n[14]!==x.by_name?(a=x.by_name&&Object.hasOwn(x.by_name,C.toolName)?x.by_name[C.toolName]:void 0,n[13]=C.toolName,n[14]=x.by_name,n[15]=a):a=n[15];let o=a,s;n[16]===i?s=n[17]:(s=i&&{unstable_recordInteraction:i},n[16]=i,n[17]=s);let c;return n[18]!==o||n[19]!==e||n[20]!==C||n[21]!==r||n[22]!==t||n[23]!==s||n[24]!==x.Fallback?(c=(0,J.jsx)(Mg,E(E({},C),{},{ByName:o,Fallback:x.Fallback,addResult:e,resume:t,respondToApproval:r},s)),n[18]=o,n[19]=e,n[20]=C,n[21]=r,n[22]=t,n[23]=s,n[24]=x.Fallback,n[25]=c):c=n[25],c}if(((t=C.status)==null?void 0:t.type)===`requires-action`)throw Error(`Encountered unexpected requires-action status`);switch(w){case`text`:{let e;return n[26]!==m||n[27]!==C?(e=(0,J.jsx)(m,E({},C)),n[26]=m,n[27]=C,n[28]=e):e=n[28],e}case`reasoning`:{let e;return n[29]!==h||n[30]!==C?(e=(0,J.jsx)(h,E({},C)),n[29]=h,n[30]=C,n[31]=e):e=n[31],e}case`source`:{let e;return n[32]!==_||n[33]!==C?(e=(0,J.jsx)(_,E({},C)),n[32]=_,n[33]=C,n[34]=e):e=n[34],e}case`image`:{let e;return n[35]!==g||n[36]!==C?(e=(0,J.jsx)(g,E({},C)),n[35]=g,n[36]=C,n[37]=e):e=n[37],e}case`file`:{let e;return n[38]!==v||n[39]!==C?(e=(0,J.jsx)(v,E({},C)),n[38]=v,n[39]=C,n[40]=e):e=n[40],e}case`audio`:{let e;return n[41]!==y||n[42]!==C?(e=(0,J.jsx)(y,E({},C)),n[41]=y,n[42]=C,n[43]=e):e=n[43],e}case`data`:{let e;if(n[44]!==f||n[45]!==C.name){var T;e=(T=f!=null&&f.by_name&&Object.hasOwn(f.by_name,C.name)?f.by_name[C.name]:void 0)==null?f==null?void 0:f.Fallback:T,n[44]=f,n[45]=C.name,n[46]=e}else e=n[46];let t=e,r;return n[47]!==t||n[48]!==C?(r=(0,J.jsx)(Pg,E(E({},C),{},{Fallback:t})),n[47]=t,n[48]=C,n[49]=r):r=n[49],r}case`generative-ui`:{if(!(p!=null&&p.components))return typeof process<`u`&&process.env.NODE_ENV!==`production`&&console.warn("MessagePrimitive.Parts received a generative-ui part but no `components.generativeUI.components` allowlist was provided. Pass an allowlist or render with <MessagePrimitive.GenerativeUI />."),null;let e=C,t;return n[50]!==p.Fallback||n[51]!==p.components||n[52]!==e.spec?(t=(0,J.jsx)(Cg,{spec:e.spec,components:p.components,Fallback:p.Fallback}),n[50]=p.Fallback,n[51]=p.components,n[52]=e.spec,n[53]=t):t=n[53],t}default:return console.warn(`Unknown message part type: ${w}`),null}},Lg=An(e=>{let t=K(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,J.jsx)(Ig,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,J.jsx)(qd,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>{var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C;return e.index===t.index&&((n=e.components)==null?void 0:n.Text)===((r=t.components)==null?void 0:r.Text)&&((i=e.components)==null?void 0:i.Reasoning)===((a=t.components)==null?void 0:a.Reasoning)&&((o=e.components)==null?void 0:o.Source)===((s=t.components)==null?void 0:s.Source)&&((c=e.components)==null?void 0:c.Image)===((l=t.components)==null?void 0:l.Image)&&((u=e.components)==null?void 0:u.File)===((d=t.components)==null?void 0:d.File)&&((f=e.components)==null?void 0:f.Unstable_Audio)===((p=t.components)==null?void 0:p.Unstable_Audio)&&((m=e.components)==null?void 0:m.tools)===((h=t.components)==null?void 0:h.tools)&&((g=e.components)==null?void 0:g.data)===((_=t.components)==null?void 0:_.data)&&((v=e.components)==null?void 0:v.generativeUI)===((y=t.components)==null?void 0:y.generativeUI)&&((b=e.components)==null?void 0:b.ToolGroup)===((x=t.components)==null?void 0:x.ToolGroup)&&((S=e.components)==null?void 0:S.ReasoningGroup)===((C=t.components)==null?void 0:C.ReasoningGroup)});Lg.displayName=`MessagePrimitive.PartByIndex`;var Rg=e=>{let t=K(6),{status:n,component:r}=e,i=n.type===`running`,a;t[0]!==r||t[1]!==n?(a=(0,J.jsx)(r,{type:`text`,text:``,status:n}),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o;return t[3]!==i||t[4]!==a?(o=(0,J.jsx)(Yd,{text:``,isRunning:i,children:a}),t[3]=i,t[4]=a,t[5]=o):o=t[5],o},zg=Object.freeze({type:`complete`}),Bg=Object.freeze({type:`running`}),Vg=An(e=>{var t;let n=K(6),{components:r}=e,i=q(r_);if(r!=null&&r.Empty){let e;return n[0]!==r.Empty||n[1]!==i?(e=(0,J.jsx)(r.Empty,{status:i}),n[0]=r.Empty,n[1]=i,n[2]=e):e=n[2],e}if(i.type!==`running`)return null;let a=(t=r==null?void 0:r.Text)==null?Fg.Text:t,o;return n[3]!==i||n[4]!==a?(o=(0,J.jsx)(Rg,{status:i,component:a}),n[3]=i,n[4]=a,n[5]=o):o=n[5],o},(e,t)=>{var n,r,i,a;return((n=e.components)==null?void 0:n.Empty)===((r=t.components)==null?void 0:r.Empty)&&((i=e.components)==null?void 0:i.Text)===((a=t.components)==null?void 0:a.Text)}),Hg=An(e=>{let t=K(4),{components:n,enabled:r}=e,i;if(t[0]===r?i=t[1]:(i=e=>{if(!r||e.message.parts.length===0)return!1;let t=e.message.parts[e.message.parts.length-1];return(t==null?void 0:t.type)!==`text`&&(t==null?void 0:t.type)!==`reasoning`},t[0]=r,t[1]=i),!q(i))return null;let a;return t[2]===n?a=t[3]:(a=(0,J.jsx)(Vg,{components:n}),t[2]=n,t[3]=a),a},(e,t)=>{var n,r,i,a;return e.enabled===t.enabled&&((n=e.components)==null?void 0:n.Empty)===((r=t.components)==null?void 0:r.Empty)&&((i=e.components)==null?void 0:i.Text)===((a=t.components)==null?void 0:a.Text)}),Ug=An(e=>{let t=K(4),{Quote:n}=e,r=q(gg);if(!r)return null;let i;return t[0]!==n||t[1]!==r.messageId||t[2]!==r.text?(i=(0,J.jsx)(n,{text:r.text,messageId:r.messageId}),t[0]=n,t[1]=r.messageId,t[2]=r.text,t[3]=i):i=t[3],i}),Wg=()=>{let e=K(9),t=qa(),n=q(i_),r=q(a_),i=t.part.unstable_recordInteraction;if(!r||n.type!==`tool-call`)return null;let a;e[0]===i?a=e[1]:(a=i&&{unstable_recordInteraction:i},e[0]=i,e[1]=a);let o;return e[2]!==r||e[3]!==t.part.addToolResult||e[4]!==t.part.respondToToolApproval||e[5]!==t.part.resumeToolCall||e[6]!==n||e[7]!==a?(o=(0,J.jsx)(r,E(E({},n),{},{addResult:t.part.addToolResult,resume:t.part.resumeToolCall,respondToApproval:t.part.respondToToolApproval},a)),e[2]=r,e[3]=t.part.addToolResult,e[4]=t.part.respondToToolApproval,e[5]=t.part.resumeToolCall,e[6]=n,e[7]=a,e[8]=o):o=e[8],o},Gg=()=>{let e=K(3),t=q(o_),n=q(s_);if(!n||t.type!==`data`)return null;let r=t,i;return e[0]!==n||e[1]!==r?(i=(0,J.jsx)(n,E({},r)),e[0]=n,e[1]=r,e[2]=i):i=e[2],i},Kg=()=>{let e=K(2),t=q(c_);if(t===`tool-call`){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,J.jsx)(Wg,{}),e[0]=t):t=e[0],t}if(t===`data`){let t;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,J.jsx)(Gg,{}),e[1]=t):t=e[1],t}return null},qg=Object.freeze({type:`text`,text:``,status:Bg}),Jg=({children:e})=>{let t=qa(),n=q(e=>e.dataRenderers);return(0,J.jsx)(Ad,{getItemState:e=>e.part.getState(),children:r=>e({get part(){let e=r();if(e.type===`tool-call`){let n=Eg(t.tools.getState(),e)!==null,r=t.part;return E(E({},e),{},{toolUI:n?(0,J.jsx)(Wg,{}):null,addResult:r.addToolResult,resume:r.resumeToolCall,respondToApproval:r.respondToToolApproval},r.unstable_recordInteraction&&{unstable_recordInteraction:r.unstable_recordInteraction})}if(e.type===`data`){let t=Ng(n,e.name,void 0)!==void 0;return E(E({},e),{},{dataRendererUI:t?(0,J.jsx)(Gg,{}):null})}return e}})})},Yg=e=>{let t=K(5),{index:n,children:r}=e,i;t[0]===r?i=t[1]:(i=(0,J.jsx)(Jg,{children:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,J.jsx)(qd,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},Xg=e=>{let t=K(11),{children:n}=e,r=q(Ta(l_)),i=r.length,a=q(u_),o=i===0&&a;if(i===0){if(!o)return null;let e;t[0]===n?e=t[1]:(e=n({part:qg}),t[0]=n,t[1]=e);let r;return t[2]===e?r=t[3]:(r=(0,J.jsx)(Yd,{text:``,isRunning:!0,children:e}),t[2]=e,t[3]=r),r}let s;if(t[4]!==n||t[5]!==r){let e;t[7]===n?e=t[8]:(e=(e,t)=>(0,J.jsx)(Yg,{index:t,children:e=>{var t;return(t=n(e))==null?(0,J.jsx)(Kg,{}):t}},e),t[7]=n,t[8]=e),s=r.map(e),t[4]=n,t[5]=r,t[6]=s}else s=t[6];let c;return t[9]===s?c=t[10]:(c=(0,J.jsx)(J.Fragment,{children:s}),t[9]=s,t[10]=c),c},Zg=e=>{let t=K(5),{components:n,unstable_showEmptyOnNonTextEnd:r,children:i}=e,a=r===void 0||r;if(i){let e;return t[0]===i?e=t[1]:(e=(0,J.jsx)(Xg,{children:i}),t[0]=i,t[1]=e),e}let o;return t[2]!==n||t[3]!==a?(o=(0,J.jsx)(Qg,{components:n,unstable_showEmptyOnNonTextEnd:a}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o};Zg.displayName=`MessagePrimitive.Parts`;var Qg=e=>{let t=K(18),{components:n,unstable_showEmptyOnNonTextEnd:r}=e,i=q(d_),{ranges:a,partIds:o}=jg(!!(n!=null&&n.ChainOfThought)),s;bb0:{if(i===0){let e;t[0]===n?e=t[1]:(e=(0,J.jsx)(Vg,{components:n}),t[0]=n,t[1]=e),s=e;break bb0}let e;if(t[2]!==n||t[3]!==a||t[4]!==o){let r;t[6]!==n||t[7]!==o?(r=e=>{var t;if(e.type===`single`)return(0,J.jsx)(Lg,{index:e.index,components:n},o[e.index]);let r=JSON.stringify([e.type,(t=e.idKey)==null?e.startIndex:t]);if(e.type===`chainOfThoughtGroup`){let t=n==null?void 0:n.ChainOfThought;return t?(0,J.jsx)(of,{startIndex:e.startIndex,endIndex:e.endIndex,children:(0,J.jsx)(t,{})},r):null}if(e.type===`toolGroup`){var i;let t=(i=n==null?void 0:n.ToolGroup)==null?Fg.ToolGroup:i;return(0,J.jsx)(t,{startIndex:e.startIndex,endIndex:e.endIndex,children:Array.from({length:e.endIndex-e.startIndex+1},(t,r)=>{let i=e.startIndex+r;return(0,J.jsx)(Lg,{index:i,components:n},o[i])})},r)}{var a;let t=(a=n==null?void 0:n.ReasoningGroup)==null?Fg.ReasoningGroup:a;return(0,J.jsx)(t,{startIndex:e.startIndex,endIndex:e.endIndex,children:Array.from({length:e.endIndex-e.startIndex+1},(t,r)=>{let i=e.startIndex+r;return(0,J.jsx)(Lg,{index:i,components:n},o[i])})},r)}},t[6]=n,t[7]=o,t[8]=r):r=t[8],e=a.map(r),t[2]=n,t[3]=a,t[4]=o,t[5]=e}else e=t[5];s=e}let c=s,l;t[9]===n?l=t[10]:(l=(n==null?void 0:n.Quote)&&(0,J.jsx)(Ug,{Quote:n.Quote}),t[9]=n,t[10]=l);let u;t[11]!==n||t[12]!==r?(u=(0,J.jsx)(Hg,{components:n,enabled:r}),t[11]=n,t[12]=r,t[13]=u):u=t[13];let d;return t[14]!==c||t[15]!==l||t[16]!==u?(d=(0,J.jsxs)(J.Fragment,{children:[l,c,u]}),t[14]=c,t[15]=l,t[16]=u,t[17]=d):d=t[17],d};function $g(e){return e.type}function e_(e){return e.message.parts.map($g)}function t_(e){return fu(e.message.parts)}function n_(e){return e.part}function r_(e){var t;return(t=e.message.status)==null?zg:t}function i_(e){return e.part}function a_(e){return e.part.type===`tool-call`?Eg(e.tools,e.part):null}function o_(e){return e.part}function s_(e){var t;return e.part.type===`data`?(t=Ng(e.dataRenderers,e.part.name,void 0))==null?null:t:null}function c_(e){return e.part.type}function l_(e){return fu(e.message.parts)}function u_(e){var t,n;return((t=(n=e.message.status)==null?void 0:n.type)==null?`complete`:t)===`running`}function d_(e){return e.message.parts.length}var f_=Symbol.for(`@assistant-ui/groupBy.memoKey`),p_=e=>{let t=e,n=((e,n)=>{var r;if(e.type===`tool-call`){var i,a,o,s;if((V((i=e.mcp)==null||(i=i.app)==null?void 0:i.resourceUri)||(a=n==null||(o=n.toolUIs)==null||(o=o[e.toolName])==null||(o=o[0])==null?void 0:o.standalone)!=null&&a)&&t[`standalone-tool-call`]!==void 0)return t[`standalone-tool-call`];let r=t[`tool-call:${e.toolName}`];return r===void 0?(s=t[`tool-call`])==null?[]:s:r}return(r=t[e.type])==null?[]:r}),r=Object.keys(e).sort().map(t=>[t,e[t]]);return n[f_]=`groupPartByType:${JSON.stringify(r)}`,n},m_=e=>{let t=e.nextChildIdx++;return e.nodeKey===``?String(t):`${e.nodeKey}.${t}`},h_=(e,t)=>{if(!(t===void 0||e.claimed.has(t)))return e.claimed.add(t),`id:${t}`},g_=(e,t)=>{let n={key:``,nodeKey:``,indices:[],children:[],nextChildIdx:0,claimed:new Set},r=[n],i=()=>{let e=r.pop(),n=r[r.length-1],i=t==null?void 0:t[e.indices[0]];n.children.push({type:`group`,key:e.key,nodeKey:e.nodeKey,idKey:h_(n,i!=null&&i.includes(`:`)?i:void 0),indices:e.indices,children:e.children})};for(let n=0;n<e.length;n++){let a=e[n],o=0;for(;o<r.length-1&&o<a.length&&r[o+1].key===a[o];)o++;for(;r.length-1>o;)i();for(;r.length-1<a.length;){let e=r[r.length-1];r.push({key:a[r.length-1],nodeKey:m_(e),indices:[],children:[],nextChildIdx:0,claimed:new Set})}let s=r[r.length-1];s.children.push({type:`part`,index:n,nodeKey:m_(s),idKey:h_(s,t==null?void 0:t[n])});for(let e=1;e<r.length;e++)r[e].indices.push(n)}for(;r.length>1;)i();return n.children},__=(e,t,n)=>{if(!n)return!1;switch(e){case`never`:return!1;case`always`:return!0;case`empty`:return t.length===0;case`no-text`:{let e=t[t.length-1];return e===void 0||e.type!==`text`&&e.type!==`reasoning`}}},v_=()=>{throw Error("MessagePrimitive.GroupedParts: rendered `children` under a leaf part. `children` is only meaningful for `group-…` cases — add a matching case for the part type or return `null` to use registered UIs.")},y_=(e,t,n)=>{var r;if(e.type===`part`)return(0,J.jsx)(Yg,{index:e.index,children:({part:e})=>{var t;return(t=n({part:e,children:(0,J.jsx)(v_,{})}))==null?(0,J.jsx)(Kg,{}):t}},e.idKey?`part-${e.idKey}`:`part-${e.index}`);let{status:i,counts:a,timing:o}=nf(t,e.indices),s=E({type:e.key,status:i,counts:a,indices:e.indices},o&&{timing:o});return(0,J.jsx)(jn,{children:n({part:s,children:(0,J.jsx)(J.Fragment,{children:e.children.map(e=>y_(e,t,n))})})},JSON.stringify([e.key,(r=e.idKey)==null?e.nodeKey:r]))},b_=({groupBy:e,indicator:t=`no-text`,children:n})=>{var r;let i=q(Ta(e=>e.message.parts)),a=q(e=>e.tools.toolUIs),o=q(e=>{var n;return t!==`never`&&((n=e.message.status)==null?void 0:n.type)===`running`}),s=bn(()=>{let t={toolUIs:a};return g_(i.map(n=>{var r;return(r=e(n,t))==null?[]:r}),fu(i))},[i,(r=e[f_])==null?e:r,a]);return(0,J.jsxs)(J.Fragment,{children:[s.map(e=>y_(e,i,n)),__(t,i,o)&&n({part:{type:`indicator`},children:(0,J.jsx)(v_,{})})]})};b_.displayName=`MessagePrimitive.GroupedParts`;var x_=new WeakMap,S_=e=>x_.get(e);Object.freeze([]);var C_=e=>e.length===1?{type:`part`,index:e[0],nodeKey:`0`,idKey:void 0}:{type:`group`,key:`group-row`,nodeKey:`0`,idKey:void 0,indices:e,children:e.map((e,t)=>({type:`part`,index:e,nodeKey:`0.${t}`,idKey:void 0}))},w_=e=>{let t=K(7),{row:n,children:r}=e,i=q(Ta(O_));if(n.indices.some(e=>e>=i.length))return null;let a;if(t[0]!==r||t[1]!==i||t[2]!==n){var o;let e=(o=S_(n))==null?C_(n.indices):o,s;t[4]!==r||t[5]!==n?(s=e=>r({type:`part`,row:n,part:e.part,children:e.children}),t[4]=r,t[5]=n,t[6]=s):s=t[6],a=y_(e,i,s),t[0]=r,t[1]=i,t[2]=n,t[3]=a}else a=t[3];return a},T_=({row:e,children:t})=>(0,J.jsx)(Ad,{getItemState:e=>e.message.getState(),children:n=>t({type:`message`,row:e,get message(){return n()}})}),E_=({row:e,children:t})=>(0,J.jsx)(Ad,{getItemState:e=>e.message.getState(),children:n=>t({type:`turn-end`,row:e,get message(){return n()}})}),D_=An(e=>{let t=K(8),{row:n,children:r}=e,i;if(t[0]===n.messageId?i=t[1]:(i=e=>og(e.thread.messages,n.messageId),t[0]=n.messageId,t[1]=i),!q(i))return null;let a;t[2]!==r||t[3]!==n?(a=n.type===`message`?(0,J.jsx)(T_,{row:n,children:r}):n.type===`part`?(0,J.jsx)(w_,{row:n,children:r}):(0,J.jsx)(E_,{row:n,children:r}),t[2]=r,t[3]=n,t[4]=a):a=t[4];let o;return t[5]!==n.messageId||t[6]!==a?(o=(0,J.jsx)(ng,{id:n.messageId,children:a}),t[5]=n.messageId,t[6]=a,t[7]=o):o=t[7],o},(e,t)=>e.row===t.row&&e.children===t.children);D_.displayName=`ThreadPrimitive.Row`;function O_(e){return e.message.parts}var k_=An(e=>{let t=K(5),{children:n}=e,r=q(gg);if(!r)return null;let i;t[0]!==n||t[1]!==r?(i=n(r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;return t[3]===i?a=t[4]:(a=(0,J.jsx)(J.Fragment,{children:i}),t[3]=i,t[4]=a),a});k_.displayName=`MessagePrimitive.Quote`;var A_=(e,t)=>{switch(t.type){case`image`:var n;return(n=e==null?void 0:e.Image)==null?e==null?void 0:e.Attachment:n;case`document`:var r;return(r=e==null?void 0:e.Document)==null?e==null?void 0:e.Attachment:r;case`file`:var i;return(i=e==null?void 0:e.File)==null?e==null?void 0:e.Attachment:i;default:return e==null?void 0:e.Attachment}},j_=e=>{let t=K(5),{components:n}=e,r=q(F_);if(!r)return null;let i;t[0]!==r||t[1]!==n?(i=A_(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i;if(!a)return null;let o;return t[3]===a?o=t[4]:(o=(0,J.jsx)(a,{}),t[3]=a,t[4]=o),o},M_=An(e=>{let t=K(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,J.jsx)(j_,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,J.jsx)(Ud,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>{var n,r,i,a,o,s,c,l;return e.index===t.index&&((n=e.components)==null?void 0:n.Image)===((r=t.components)==null?void 0:r.Image)&&((i=e.components)==null?void 0:i.Document)===((a=t.components)==null?void 0:a.Document)&&((o=e.components)==null?void 0:o.File)===((s=t.components)==null?void 0:s.File)&&((c=e.components)==null?void 0:c.Attachment)===((l=t.components)==null?void 0:l.Attachment)});M_.displayName=`MessagePrimitive.AttachmentByIndex`;var N_=({children:e})=>{let t=q(Ta(e=>{var t,n,r;return e.message.role===`user`?((t=(n=(r=e.message.submission)==null?void 0:r.attachments)==null?e.message.attachments:n)==null?[]:t).map(e=>e.id):[]}));return bn(()=>t.map((t,n)=>(0,J.jsx)(Ud,{index:n,children:(0,J.jsx)(Ad,{getItemState:e=>e.message.attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},t)),[t,e])},P_=e=>{let t=K(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,J.jsx)(N_,{children:e=>{let{attachment:t}=e,r=A_(n,t);return r?(0,J.jsx)(r,{}):null}}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,J.jsx)(N_,{children:r}),t[2]=r,t[3]=i),i};P_.displayName=`MessagePrimitive.Attachments`;function F_(e){return e.attachment}var I_=(e,t)=>{switch(t.type){case`image`:var n;return(n=e==null?void 0:e.Image)==null?e==null?void 0:e.Attachment:n;case`document`:var r;return(r=e==null?void 0:e.Document)==null?e==null?void 0:e.Attachment:r;case`file`:var i;return(i=e==null?void 0:e.File)==null?e==null?void 0:e.Attachment:i;default:return e==null?void 0:e.Attachment}},L_=e=>{let t=K(5),{components:n}=e,r=q(V_);if(!r)return null;let i;t[0]!==r||t[1]!==n?(i=I_(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i;if(!a)return null;let o;return t[3]===a?o=t[4]:(o=(0,J.jsx)(a,{}),t[3]=a,t[4]=o),o},R_=An(e=>{let t=K(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,J.jsx)(L_,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,J.jsx)(Wd,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>{var n,r,i,a,o,s,c,l;return e.index===t.index&&((n=e.components)==null?void 0:n.Image)===((r=t.components)==null?void 0:r.Image)&&((i=e.components)==null?void 0:i.Document)===((a=t.components)==null?void 0:a.Document)&&((o=e.components)==null?void 0:o.File)===((s=t.components)==null?void 0:s.File)&&((c=e.components)==null?void 0:c.Attachment)===((l=t.components)==null?void 0:l.Attachment)});R_.displayName=`ComposerPrimitive.AttachmentByIndex`;var z_=({children:e})=>{let t=q(Ta(e=>e.composer.attachments.map(e=>e.id)));return bn(()=>t.map((t,n)=>(0,J.jsx)(Wd,{index:n,children:(0,J.jsx)(Ad,{getItemState:e=>e.composer.attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},t)),[t,e])},B_=e=>{let t=K(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,J.jsx)(z_,{children:e=>{let{attachment:t}=e,r=I_(n,t);return r?(0,J.jsx)(r,{}):null}}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,J.jsx)(z_,{children:r}),t[2]=r,t[3]=i),i};B_.displayName=`ComposerPrimitive.Attachments`;function V_(e){return e.attachment}var H_=An(({children:e})=>{let t=q(Ta(e=>e.composer.queue.map(e=>e.id)));return bn(()=>t.map((t,n)=>(0,J.jsx)(uf,{index:n,children:(0,J.jsx)(Ad,{getItemState:e=>e.composer.queueItem({index:n}).getState(),children:t=>e({get queueItem(){return t()}})})},t)),[t,e])});H_.displayName=`ComposerPrimitive.Queue`;var U_=An(e=>{let t=K(6),{index:n,archived:r,components:i}=e,a=r!==void 0&&r,o=i.ThreadListItem,s;t[0]===o?s=t[1]:(s=(0,J.jsx)(o,{}),t[0]=o,t[1]=s);let c;return t[2]!==a||t[3]!==n||t[4]!==s?(c=(0,J.jsx)(cf,{index:n,archived:a,children:s}),t[2]=a,t[3]=n,t[4]=s,t[5]=c):c=t[5],c},(e,t)=>e.index===t.index&&e.archived===t.archived&&e.components.ThreadListItem===t.components.ThreadListItem);U_.displayName=`ThreadListPrimitive.ItemByIndex`;var W_=({archived:e,children:t})=>{let n=q(Ta(t=>e?t.threads.archivedThreadIds:t.threads.threadIds));return bn(()=>n.map((n,r)=>(0,J.jsx)(cf,{index:r,archived:e,children:(0,J.jsx)(Ad,{getItemState:t=>t.threads.item({index:r,archived:e}).getState(),children:e=>t({get threadListItem(){return e()}})})},n)),[n,e,t])},G_=e=>{let t=K(8),{archived:n,components:r,children:i}=e,a=n!==void 0&&n;if(r){let e=r.ThreadListItem,n;t[0]===e?n=t[1]:(n=()=>(0,J.jsx)(e,{}),t[0]=e,t[1]=n);let i;return t[2]!==a||t[3]!==n?(i=(0,J.jsx)(W_,{archived:a,children:n}),t[2]=a,t[3]=n,t[4]=i):i=t[4],i}let o;return t[5]!==a||t[6]!==i?(o=(0,J.jsx)(W_,{archived:a,children:i}),t[5]=a,t[6]=i,t[7]=o):o=t[7],o};G_.displayName=`ThreadListPrimitive.Items`;var K_=e=>{let{children:t}=e;return q(q_)?t:null};K_.displayName=`MessagePartPrimitive.InProgress`;function q_(e){return e.part.status.type===`running`}var J_=e=>{let t=K(2),{fallback:n}=e,r=q(Y_)||n,i;return t[0]===r?i=t[1]:(i=(0,J.jsx)(J.Fragment,{children:r}),t[0]=r,t[1]=i),i};J_.displayName=`ThreadListItemPrimitive.Title`;function Y_(e){return e.threadListItem.title}var X_=e=>{let t=new Map;return e.map(e=>{var n;let r=JSON.stringify([e.title,e.label,e.prompt]),i=(n=t.get(r))==null?0:n;return t.set(r,i+1),i===0?r:`${r}:${i}`})},Z_=e=>{let t=K(2),{components:n}=e,r=n.Suggestion,i;return t[0]===r?i=t[1]:(i=(0,J.jsx)(r,{}),t[0]=r,t[1]=i),i},Q_=An(e=>{let t=K(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,J.jsx)(Z_,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,J.jsx)(lf,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components.Suggestion===t.components.Suggestion);Q_.displayName=`ThreadPrimitive.SuggestionByIndex`;var $_=({children:e})=>{let t=q(Ta(e=>X_(e.suggestions.suggestions)));return bn(()=>t.length===0?null:t.map((t,n)=>(0,J.jsx)(lf,{index:n,children:(0,J.jsx)(Ad,{getItemState:e=>e.suggestions.suggestion({index:n}).getState(),children:t=>e({get suggestion(){return t()}})})},t)),[t,e])},ev=e=>{let t=K(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,J.jsx)($_,{children:()=>(0,J.jsx)(Z_,{components:n})}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,J.jsx)($_,{children:r}),t[2]=r,t[3]=i),i};ev.displayName=`ThreadPrimitive.Suggestions`;var tv=An(ev,(e,t)=>e.children||t.children?e.children===t.children:e.components.Suggestion===t.components.Suggestion),nv=[`children`],rv=e=>{let t=K(3),n;return t[0]!==e.dictation||t[1]!==e.editing?(n=t=>{if(e.editing===!0&&!t.composer.isEditing||e.editing===!1&&t.composer.isEditing)return!1;let n=t.composer.dictation!=null;return!(e.dictation===!0&&!n||e.dictation===!1&&n)},t[0]=e.dictation,t[1]=e.editing,t[2]=n):n=t[2],q(n)},iv=e=>{let t=K(3),n,r;if(t[0]!==e){var i=e;({children:n}=i),r=W(i,nv),t[0]=e,t[1]=n,t[2]=r}else n=t[1],r=t[2];return rv(r)?n:null};iv.displayName=`ComposerPrimitive.If`;var av=e=>e.thread.isDisabled||!e.composer.canSend||e.thread.isRunning&&!e.thread.capabilities.queue&&e.thread.voice===void 0,ov=e=>e.thread.isDisabled||e.thread.isRunning||e.thread.voice!==void 0||!e.thread.canResume||e.composer.type!==`thread`||!e.composer.isEmpty,sv=e=>!e.composer.canCancel,cv=e=>{var t,n,r,i;return e.composer.isEditing||((t=e.optional.message)==null?void 0:t.submission)!==void 0||((n=e.optional.thread)==null?void 0:n.isDisabled)===!0||((r=e.optional.thread)==null?void 0:r.voice)!==void 0||((i=e.optional.thread)==null?void 0:i.capabilities.edit)===!1},lv=e=>e.thread.isRunning||e.thread.isDisabled||e.thread.voice!==void 0||e.message.role!==`assistant`||!e.thread.capabilities.reload,uv=e=>{var t;return(e.message.role!==`assistant`||((t=e.message.status)==null?void 0:t.type)!==`running`)&&e.message.parts.some(e=>e.type===`text`&&e.text.length>0)},dv=e=>!uv(e),fv=e=>{var t;return((t=e.optional.thread)==null?void 0:t.capabilities.speech)!==!0||!uv(e)},pv=e=>e.message.branchNumber<=1||!e.thread.capabilities.switchToBranch||e.thread.isRunning&&!e.thread.capabilities.switchBranchDuringRun,mv=e=>e.message.branchNumber>=e.message.branchCount||!e.thread.capabilities.switchToBranch||e.thread.isRunning&&!e.thread.capabilities.switchBranchDuringRun,hv=e=>e.isSendDisabled?`blocked`:e.voice===void 0?e.isRunning?e.capabilities.queue?`queued`:`blocked`:`now`:e.voice.canSendText?`now`:`blocked`,gv=(e,t)=>e.thread.isDisabled||t&&hv(e.thread)===`blocked`,_v=e=>{var t;if(((t=e.message.status)==null?void 0:t.type)!==`incomplete`||e.message.status.reason!==`error`)return;let n=e.message.status.error;return typeof n==`string`?n:typeof n==`object`&&n&&`message`in n&&typeof n.message==`string`?n.message:n==null?`An error occurred`:n},vv=e=>!e.threads.hasMore||e.threads.isLoading||e.threads.isLoadingMore,yv=e=>!e.threads.canUnarchive,bv=()=>{let e=K(5),t=qa(),n=q(av),r;e[0]===t?r=e[1]:(r=e=>{t.composer.send(e)},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={send:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},xv=()=>{let e=K(5),t=qa(),n=q(ov),r;e[0]===t?r=e[1]:(r=()=>{var e,n;df(`Resume`,t.thread().resumeRun({parentId:(e=(n=t.thread().getState().messages.at(-1))==null?void 0:n.id)==null?null:e}))},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={resume:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},Sv=()=>{let e=K(5),t=qa(),n=q(sv),r;e[0]===t?r=e[1]:(r=()=>{t.composer.cancel()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==i||e[3]!==n?(a={cancel:i,disabled:n},e[2]=i,e[3]=n,e[4]=a):a=e[4],a},Cv=()=>{let e=K(5),t=qa(),n=q(wv),r;e[0]===t?r=e[1]:(r=()=>{t.composer.startDictation()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={startDictation:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function wv(e){return e.thread.isDisabled||e.composer.dictation!=null||!e.thread.capabilities.dictation||!e.composer.isEditing}var Tv=()=>{let e=K(5),t=qa(),n=q(Ev),r;e[0]===t?r=e[1]:(r=e=>t.composer.addAttachment(e),e[0]=t,e[1]=r);let i=r,a;return e[2]!==i||e[3]!==n?(a={addAttachment:i,disabled:n},e[2]=i,e[3]=n,e[4]=a):a=e[4],a};function Ev(e){return e.thread.isDisabled||!e.composer.isEditing}var Dv=e=>{let t=K(20),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{copiedDuration:r,copyToClipboard:i}=n,a=r===void 0?3e3:r,o=qa(),s=q(dv),c=q(Ov),l=q(kv),u=q(Av),d=q(jv),f=yn(void 0),p=yn(void 0),m=yn(0),h=yn(c),g,_;t[2]===c?(g=t[3],_=t[4]):(g=()=>{h.current=c},_=[c],t[2]=c,t[3]=g,t[4]=_),En(g,_);let v;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(v=()=>()=>{var e;m.current+=1,f.current!==void 0&&(clearTimeout(f.current),f.current=void 0,(e=p.current)==null||e.call(p,!1),p.current=void 0)},t[5]=v):v=t[5];let y;t[6]!==o.message||t[7]!==c?(y=[o.message,c],t[6]=o.message,t[7]=c,t[8]=y):y=t[8],G(v,y);let b;t[9]!==o.message||t[10]!==d||t[11]!==a||t[12]!==i||t[13]!==u||t[14]!==c?(b=()=>{if(!i)return;let e=u?d:o.message.getCopyText();if(!e)return;let t=m.current,n=c,r=o.message.setIsCopied,s;try{s=i(e)}catch(e){return}Promise.resolve(s).then(()=>{t===m.current&&n===h.current&&(f.current!==void 0&&clearTimeout(f.current),p.current=r,r(!0),f.current=setTimeout(()=>{f.current=void 0,h.current,r(!1),p.current=void 0},a))},Mv)},t[9]=o.message,t[10]=d,t[11]=a,t[12]=i,t[13]=u,t[14]=c,t[15]=b):b=t[15];let x=b,S=s||!i,C;return t[16]!==x||t[17]!==l||t[18]!==S?(C={copy:x,disabled:S,isCopied:l},t[16]=x,t[17]=l,t[18]=S,t[19]=C):C=t[19],C};function Ov(e){return e.message.id}function kv(e){return e.message.isCopied}function Av(e){return e.composer.isEditing}function jv(e){return e.composer.text}function Mv(){}var Nv=()=>{let e=K(5),t=qa(),n=q(cv),r;e[0]===t?r=e[1]:(r=()=>{t.composer.beginEdit()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={edit:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},Pv=()=>{let e=K(5),t=qa(),n=q(lv),r;e[0]===t?r=e[1]:(r=()=>{t.message.reload()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={reload:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},Fv=()=>{let e=K(5),t=qa(),n=q(Lv),r;e[0]===t?r=e[1]:(r=()=>{t.message.submitFeedback({type:`positive`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={submit:i,isSubmitted:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},Iv=()=>{let e=K(5),t=qa(),n=q(Rv),r;e[0]===t?r=e[1]:(r=()=>{t.message.submitFeedback({type:`negative`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={submit:i,isSubmitted:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function Lv(e){var t;return((t=e.message.metadata.submittedFeedback)==null?void 0:t.type)===`positive`}function Rv(e){var t;return((t=e.message.metadata.submittedFeedback)==null?void 0:t.type)===`negative`}var zv=()=>{let e=K(5),t=qa(),n=q(fv),r;e[0]===t?r=e[1]:(r=w(function*(){t.message.speak()}),e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={speak:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},Bv=()=>{let e=K(5),t=qa(),n=q(Vv),r;e[0]===t?r=e[1]:(r=()=>{t.message.stopSpeaking()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={stopSpeaking:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function Vv(e){return e.message.speech==null}var Hv=()=>{let e=K(5),t=qa(),n=q(mv),r;e[0]===t?r=e[1]:(r=()=>{t.message.switchToBranch({position:`next`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={next:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},Uv=()=>{let e=K(5),t=qa(),n=q(pv),r;e[0]===t?r=e[1]:(r=()=>{t.message.switchToBranch({position:`previous`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={previous:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},Wv=e=>{let t=K(10),{prompt:n,send:r,clearComposer:i}=e,a=i===void 0||i,o=qa(),s=r!=null&&r,c;t[0]===s?c=t[1]:(c=e=>gv(e,s),t[0]=s,t[1]=c);let l=q(c),u;t[2]!==o||t[3]!==a||t[4]!==n||t[5]!==s?(u=()=>{if(s){let e=hv(o.thread.getState());if(e===`blocked`)return;o.thread.append({content:[{type:`text`,text:n}],runConfig:o.composer.getState().runConfig}),a&&e===`now`&&o.composer.setText(``)}else if(a)o.composer.setText(n);else{let e=o.composer.getState().text;o.composer.setText([e,n].filter(Gv).join(` `))}},t[2]=o,t[3]=a,t[4]=n,t[5]=s,t[6]=u):u=t[6];let d=u,f;return t[7]!==l||t[8]!==d?(f={trigger:d,disabled:l},t[7]=l,t[8]=d,t[9]=f):f=t[9],f};function Gv(e){return e.trim()}var Kv=()=>{let e=K(4),t=qa(),n;e[0]===t?n=e[1]:(n=()=>{t.threadListItem.archive()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={archive:r},e[2]=r,e[3]=i),i},qv=()=>{let e=K(4),t=qa(),n;e[0]===t?n=e[1]:(n=()=>{t.threadListItem.delete()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={delete:r},e[2]=r,e[3]=i),i},Jv=()=>{let e=K(5),t=qa(),n=q(yv),r;e[0]===t?r=e[1]:(r=()=>{t.threadListItem.unarchive()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={unarchive:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},Yv=()=>{let e=K(4),t=qa(),n;e[0]===t?n=e[1]:(n=()=>{t.threadListItem.switchTo()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={switchTo:r},e[2]=r,e[3]=i),i},Xv=()=>{let e=K(4),t=qa(),n;e[0]===t?n=e[1]:(n=()=>{t.threads.switchToNewThread()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={switchToNewThread:r},e[2]=r,e[3]=i),i},Zv=()=>{let e=K(5),t=qa(),n=q(vv),r;e[0]===t?r=e[1]:(r=()=>{t.threads.loadMore()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={loadMore:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},Qv=()=>q(_v),$v=[`cloud`,`scopeId`,`initialMessages`,`maxSteps`,`adapters`,`unstable_humanToolNames`,`unstable_enableMessageQueue`,`unstable_queueClearOnRewind`,`unstable_queueClearOnCancel`],ey=e=>{let{cloud:t,scopeId:n,initialMessages:r,maxSteps:i,adapters:a,unstable_humanToolNames:o,unstable_enableMessageQueue:s,unstable_queueClearOnRewind:c,unstable_queueClearOnCancel:l}=e,u=W(e,$v);return{localRuntimeOptions:{cloud:t,scopeId:n,initialMessages:r,maxSteps:i,adapters:a,unstable_humanToolNames:o,unstable_enableMessageQueue:s,unstable_queueClearOnRewind:c,unstable_queueClearOnCancel:l},otherOptions:u}};function ty(e,t){function n(n){let r=Vn(e);if(!(n!=null&&n.optional)&&!r)throw Error(`This component must be used within ${t}.`);return r}return n}function ny(e,t){function n(n){let r=e(n);return r?r[t]:null}function r(e){let t=!1,r;typeof e==`function`?r=e:e&&typeof e==`object`&&(t=!!e.optional,r=e.selector);let i=n({optional:t});return i?r?i(r):i():null}return{[t]:r,[`${t}Store`]:n}}var ry=zn(null),{useThreadViewport:iy,useThreadViewportStore:ay}=ny(ty(ry,`ThreadPrimitive.Viewport`),`useThreadViewport`),oy,sy,cy=()=>{if(sy)return sy;let e=()=>({apis:new Map,nextId:0,listeners:new Set});if(typeof window>`u`)return sy=e(),sy;let t=window.__ASSISTANT_UI_DEVTOOLS_HOOK__;if(t)return sy=t,t;let n=e();return window.__ASSISTANT_UI_DEVTOOLS_HOOK__=n,sy=n,n},ly=e=>{L(cy().listeners,e,`DevTools`)},uy=(oy=class e{static register(t){var n,r;let i=cy();for(let e of i.apis.values())if(e.api===t)return()=>{};let a=i.nextId++,o={api:t,logs:[]},s=(n=t.on)==null?void 0:n.call(t,`*`,t=>{let n=i.apis.get(a);n&&(n.logs.push({time:new Date,event:t.event,data:t.payload}),n.logs.length>e.MAX_EVENT_LOGS_PER_API&&(n.logs=n.logs.slice(-e.MAX_EVENT_LOGS_PER_API)),ly(a))}),c=(r=t.subscribe)==null?void 0:r.call(t,()=>{ly(a)});return i.apis.set(a,o),ly(a),()=>{let e=cy();e.apis.get(a)&&(s==null||s(),c==null||c(),e.apis.delete(a),ly(a))}}},S(oy,`MAX_EVENT_LOGS_PER_API`,200),oy),dy=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=(r==null?typeof i!=`object`||!i:r)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},fy=(e=>e?dy(e):dy),py=e=>e;function my(e,t=py){let n=h.default.useSyncExternalStore(e.subscribe,h.default.useCallback(()=>t(e.getState()),[e,t]),()=>t(e.getInitialState()));return h.default.useDebugValue(n),n}var hy=e=>{let t=fy(e),n=e=>my(t,e);return Object.assign(n,t),n},gy=(e=>e?hy(e):hy),_y=e=>{let t=new Map,n=()=>{let n=0;for(let e of t.values())n+=e;e(n)};return{register:()=>{let e=Symbol();return t.set(e,0),{setHeight:r=>{t.get(e)!==r&&(t.set(e,r),n())},unregister:()=>{t.delete(e),n()}}}}},vy=new WeakMap,yy=e=>vy.get(e),by=(e={})=>{let t=new Set,n=_y(e=>{a.setState({height:E(E({},a.getState().height),{},{viewport:e})})}),r={getOptions:()=>({autoScroll:e.turnAnchor!==`top`,scrollToBottomOnInitialize:!0,scrollToBottomOnRunStart:e.turnAnchor!==`top`,scrollToBottomOnThreadSwitch:!0}),controller:To({getOptions:()=>r.getOptions(),onAtBottomChange:e=>a.setState({isAtBottom:e}),onContentInsetChange:e=>{a.setState({height:E(E({},a.getState().height),{},{inset:e})})}})},i=(e,t)=>(a.setState({element:E(E({},a.getState().element),{},{[e]:t})}),()=>{a.getState().element[e]===t&&a.setState({element:E(E({},a.getState().element),{},{[e]:null})})}),a=gy(()=>{var o,s,c,l,u;return{isAtBottom:!0,scrollToBottom:({behavior:e=`auto`}={})=>{L(t,()=>({behavior:e}),`Thread viewport`)},onScrollToBottom:e=>(t.add(e),()=>{t.delete(e)}),turnAnchor:(o=e.turnAnchor)==null?`bottom`:o,topAnchorMessageClamp:{tallerThan:(s=(c=e.topAnchorMessageClamp)==null?void 0:c.tallerThan)==null?`10em`:s,visibleHeight:(l=(u=e.topAnchorMessageClamp)==null?void 0:u.visibleHeight)==null?`6em`:l},height:{viewport:0,inset:0},element:{viewport:null,anchor:null,target:null},targetConfig:null,topAnchorTurn:null,registerViewport:n.register,registerContentInset:r.controller.registerContentInset,registerViewportElement:e=>i(`viewport`,e),registerAnchorElement:e=>i(`anchor`,e),registerAnchorTargetElement:(e,t)=>(a.setState({element:E(E({},a.getState().element),{},{target:e}),targetConfig:e&&t?t:null}),()=>{a.getState().element.target===e&&a.setState({element:E(E({},a.getState().element),{},{target:null}),targetConfig:null})}),setTopAnchorTurn:e=>{a.setState({topAnchorTurn:e})}}});return vy.set(a,r),a},xy=e=>e,Sy=e=>{let t=K(11),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={optional:!0},t[0]=n):n=t[0];let r=ay(n),i;t[1]===e?i=t[2]:(i=()=>by(e),t[1]=e,t[2]=i);let[a]=_n(i),o,s;t[3]!==r||t[4]!==a?(o=()=>r==null?void 0:r.getState().onScrollToBottom(e=>{a.getState().scrollToBottom(e)}),s=[r,a],t[3]=r,t[4]=a,t[5]=o,t[6]=s):(o=t[5],s=t[6]),G(o,s);let c,l;return t[7]!==r||t[8]!==a?(c=()=>{if(r)return a.subscribe(e=>{r.getState().isAtBottom!==e.isAtBottom&&xy(r).setState({isAtBottom:e.isAtBottom})})},l=[a,r],t[7]=r,t[8]=a,t[9]=c,t[10]=l):(c=t[9],l=t[10]),G(c,l),a},Cy=e=>{let t=K(7),{children:n,options:r}=e,i;t[0]===r?i=t[1]:(i=r===void 0?{}:r,t[0]=r,t[1]=i);let a=Sy(i),o;t[2]===a?o=t[3]:(o=()=>({useThreadViewport:a}),t[2]=a,t[3]=o);let[s]=_n(o),c;return t[4]!==n||t[5]!==s?(c=(0,J.jsx)(ry.Provider,{value:s,children:n}),t[4]=n,t[5]=s,t[6]=c):c=t[6],c},wy=()=>{let e=K(3),t=qa(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{if(typeof process<`u`&&process.env.NODE_ENV!==`production`)return uy.register(t)},r=[t],e[0]=t,e[1]=n,e[2]=r),G(n,r),null},Ty=An(e=>{let t=K(8),{children:n,aui:r,config:i,runtime:a}=e,o=r==null?null:r,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,J.jsx)(wy,{}),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,J.jsx)(Cy,{children:n}),t[1]=n,t[2]=c);let l;return t[3]!==i||t[4]!==a||t[5]!==o||t[6]!==c?(l=(0,J.jsxs)(Fd,{runtime:a,aui:o,config:i,children:[s,c]}),t[3]=i,t[4]=a,t[5]=o,t[6]=c,t[7]=l):l=t[7],l}),Ey=globalThis.window===void 0?G:Sn,Dy=()=>{let e=K(3),t=q(Oy),n=q(ky),r=t!==void 0&&t.completedAt===void 0&&n,[i,a]=_n(void 0),o,s;if(e[0]===r?(o=e[1],s=e[2]):(o=()=>{if(!r)return;a(Date.now());let e=setInterval(()=>a(Date.now()),1e3);return()=>clearInterval(e)},s=[r],e[0]=r,e[1]=o,e[2]=s),Ey(o,s),t!==void 0){if(t.completedAt!==void 0)return Math.max(0,t.completedAt-t.startedAt);if(r&&i!==void 0)return Math.max(0,i-t.startedAt)}};function Oy(e){let t=e.optional.part;return(t==null?void 0:t.type)===`tool-call`?t.timing:void 0}function ky(e){let t=e.optional.part;return(t==null?void 0:t.type)===`tool-call`&&t.status.type===`running`}var Ay=Object.defineProperty,jy=(e,t)=>Ay(e,`name`,{value:t,configurable:!0});function My(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}jy(My,`setRef`);function Ny(...e){return t=>{let n=!1,r=e.map(e=>{let r=My(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():My(e[t],null)}}}}jy(Ny,`composeRefs`);function Py(...e){return h.useCallback(Ny(...e),e)}jy(Py,`useComposedRefs`);var Fy=[`children`],Iy=Object.defineProperty,Ly=(e,t)=>Iy(e,`name`,{value:t,configurable:!0});function Ry(e){let t=h.forwardRef((t,n)=>{var r;let{children:i}=t,a=W(t,Fy),o=null,s=!1,c=[];i=Yy(i),h.Children.forEach(i,e=>{if(Gy(e)){var t;s=!0;let n=e,r=`child`in n.props?n.props.child:n.props.children;for(;qy(r)&&typeof $y==`function`;)r=$y(r._payload);o=Hy(n,r),c.push(o==null||(t=o.props)==null?void 0:t.children)}else c.push(e)}),o?o=h.cloneElement(o,void 0,c):!s&&h.Children.count(i)===1&&h.isValidElement(i)&&(o=i);let l=o?Wy(o):void 0,u=Py(n,l);if(!o){if(i||i===0)throw Error(s?Qy(e):Zy(e));return i}let d=Uy(a,(r=o.props)==null?{}:r);return o.type!==h.Fragment&&(d.ref=n?u:l),h.cloneElement(o,d)});return t.displayName=`${e}.Slot`,t}Ly(Ry,`createSlot`);var zy=Ry(`Slot`),By=Symbol.for(`radix.slottable`);function Vy(e){let t=Ly(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=By,t}Ly(Vy,`createSlottable`);var Hy=Ly((e,t)=>`child`in e.props?h.isValidElement(t)?h.cloneElement(t,void 0,e.props.children(t.props.children)):null:h.isValidElement(t)?t:null,`getSlottableElementFromSlottable`);function Uy(e,t){let n=E({},t);for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]=E(E({},i),a):r===`className`?n[r]=[i,a].filter(Boolean).join(` `):r===`aria-describedby`&&(n[r]=Xy(a,i))}return E(E({},e),n)}Ly(Uy,`mergeProps`);function Wy(e){var t,n;let r=(t=Object.getOwnPropertyDescriptor(e.props,`ref`))==null?void 0:t.get,i=r&&`isReactWarning`in r&&r.isReactWarning;return i?e.ref:(r=(n=Object.getOwnPropertyDescriptor(e,`ref`))==null?void 0:n.get,i=r&&`isReactWarning`in r&&r.isReactWarning,i?e.props.ref:e.props.ref||e.ref)}Ly(Wy,`getElementRef`);function Gy(e){return h.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===By}Ly(Gy,`isSlottable`);var Ky=Symbol.for(`react.lazy`);function qy(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Ky&&`_payload`in e&&Jy(e._payload)}Ly(qy,`isLazyComponent`);function Jy(e){return typeof e==`object`&&!!e&&`then`in e}Ly(Jy,`isPromiseLike`);function Yy(e){let t=e;for(;qy(t)&&typeof $y==`function`;)t=$y(t._payload);return t}Ly(Yy,`useUnwrappedLazy`);function Xy(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}Ly(Xy,`concatAriaDescribedby`);var Zy=Ly(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),Qy=Ly(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),$y=h.use,eb=[`asChild`],tb=Object.defineProperty,nb=(e,t)=>tb(e,`name`,{value:t,configurable:!0}),rb=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Ry(`Primitive.${t}`),r=h.forwardRef((e,r)=>{let{asChild:i}=e,a=W(e,eb),o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,J.jsx)(o,E(E({},a),{},{ref:r}))});return r.displayName=`Primitive.${t}`,E(E({},e),{},{[t]:r})},{});function ib(e,t){e&&n.flushSync(()=>e.dispatchEvent(t))}nb(ib,`dispatchDiscreteCustomEvent`);var ab=[`children`],ob=[`scope`,`children`],sb=Object.defineProperty,cb=(e,t)=>sb(e,`name`,{value:t,configurable:!0});function lb(e,t){let n=h.createContext(t);n.displayName=e+`Context`;let r=cb(e=>{let{children:t}=e,r=W(e,ab),i=h.useMemo(()=>r,Object.values(r));return(0,J.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=h.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return cb(i,`useContext`),[r,i]}cb(lb,`createContext`);function ub(e,t=[]){let n=[];function r(t,r){let i=h.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=cb(t=>{var n;let{scope:r,children:o}=t,s=W(t,ob),c=(r==null||(n=r[e])==null?void 0:n[a])||i,l=h.useMemo(()=>s,Object.values(s));return(0,J.jsx)(c.Provider,{value:l,children:o})},`Provider`);o.displayName=t+`Provider`;function s(n,o,s={}){var c;let{optional:l=!1}=s,u=(o==null||(c=o[e])==null?void 0:c[a])||i,d=h.useContext(u);if(d)return d;if(r!==void 0)return r;if(!l)throw Error(`\`${n}\` must be used within \`${t}\``)}return cb(s,`useContext`),[o,s]}cb(r,`createContext`);let i=cb(()=>{let t=n.map(e=>h.createContext(e));return cb(function(n){let r=(n==null?void 0:n[e])||t;return h.useMemo(()=>({[`__scope${e}`]:E(E({},n),{},{[e]:r})}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,db(i,...t)]}cb(ub,`createContextScope`);function db(...e){let t=e[0];if(e.length===1)return t;let n=cb(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return cb(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return E(E({},t),i)},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}cb(db,`composeContextScopes`);var fb,pb=(fb=globalThis)!=null&&fb.document?h.useLayoutEffect:()=>{},mb=[`scope`,`children`],hb=[`state`],gb=[`scope`,`children`],_b,vb,yb=Object.defineProperty,bb=(e,t)=>yb(e,`name`,{value:t,configurable:!0});function xb(e){let t=e+`CollectionProvider`,[n,r]=ub(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=bb(e=>{let{scope:t,children:n}=e,r=h.useRef(null),a=h.useRef(new Map).current;return(0,J.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let s=e+`CollectionSlot`,c=Ry(s),l=h.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=Py(t,a(s,n).collectionRef);return(0,J.jsx)(c,{ref:i,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=Ry(u),p=h.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=W(e,mb),o=h.useRef(null),s=Py(t,o),c=a(u,n);return h.useEffect(()=>(c.itemMap.set(o,E({ref:o},i)),()=>void c.itemMap.delete(o))),(0,J.jsx)(f,E(E({},{[d]:``}),{},{ref:s,children:r}))});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return h.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return bb(m,`useCollection`),[{Provider:o,Slot:l,ItemSlot:p},m,r]}bb(xb,`createCollection`);var Sb=new WeakMap,Cb=(_b=new WeakMap,vb=class e extends Map{constructor(e){super(e),Xe(this,_b,void 0),Qe(_b,this,[...super.keys()]),Sb.set(this,!0)}set(e,t){return Sb.get(this)&&!this.has(e)&&$e(_b,this).push(e),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=r?this.size:this.size+1,a=Eb(e),o=a>=0?Math.min(a,i-1):Math.max(i+a,0);if(r?$e(_b,this).indexOf(t)===o:o===this.size)return this.set(t,n),this;let s=$e(_b,this).filter(e=>e!==t);s.splice(o,0,t);let c=s.map(e=>[e,e===t?n:this.get(e)]);this.clear();for(let[e,t]of c)this.set(e,t);return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=$e(_b,this).indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=$e(_b,this).indexOf(e);if(r===-1)return this;let i=$e(_b,this).indexOf(t),a=i!==-1&&i<r?r-1:r;return this.insert(a,t,n)}after(e){let t=$e(_b,this).indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=$e(_b,this).indexOf(e);if(r===-1)return this;let i=$e(_b,this).indexOf(t),a=i!==-1&&i<=r?r:r+1;return this.insert(a,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return Qe(_b,this,[]),super.clear()}delete(e){let t=super.delete(e);return t&&$e(_b,this).splice($e(_b,this).indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=wb($e(_b,this),e);if(t!==void 0)return this.get(t)}entryAt(e){let t=wb($e(_b,this),e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return $e(_b,this).indexOf(e)}keyAt(e){return wb($e(_b,this),e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=e.length>1;if(!r&&this.size===0)throw TypeError(`Reduce of empty OrderedDict with no initial value`);let i=0,a=n;for(let e of this)a=i===0&&!r?e:Reflect.apply(t,this,[a,e,i,this]),i++;return a}reduceRight(...e){let[t,n]=e,r=e.length>1;if(!r&&this.size===0)throw TypeError(`Reduce of empty OrderedDict with no initial value`);let i=n;for(let e=this.size-1;e>=0;e--){let n=this.entryAt(e);i=e===this.size-1&&!r?n:Reflect.apply(t,this,[i,n,e,this])}return i}sort(e){if(typeof e!=`function`)throw TypeError(`OrderedDict.sort requires a compare function`);let t=[...this.entries()].sort(e);this.clear();for(let[e,n]of t)this.set(e,n);return this}toSorted(t){if(typeof t!=`function`)throw TypeError(`OrderedDict.toSorted requires a compare function`);let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e;for(let e of $e(_b,this).slice(t,n))r.set(e,this.get(e));return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}},bb(vb,`OrderedDict`),vb);function wb(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=Tb(e,t);return n===-1?void 0:e[n]}bb(wb,`at`);function Tb(e,t){let n=e.length,r=Eb(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}bb(Tb,`toSafeIndex`);function Eb(e){return e!==e||e===0?0:Math.trunc(e)}bb(Eb,`toSafeInteger`);function Db(e){let t=e+`CollectionProvider`,[n,r]=ub(t),[i,a]=n(t);i.displayName=e+`CollectionStableContextProvider`;let[o,s]=n(t);o.displayName=e+`CollectionStatefulContextProvider`;let c=bb(e=>{let{state:t}=e,n=W(e,hb);return t?(0,J.jsx)(u,E(E({},n),{},{state:t})):(0,J.jsx)(l,E({},n))},`CollectionProvider`);c.displayName=t;let l=bb(e=>{let t=v();return(0,J.jsx)(u,E(E({},e),{},{state:t}))},`CollectionInit`);l.displayName=e+`CollectionInit`;let u=bb(e=>{let{scope:t,children:n,state:r}=e,a=h.useRef(null),[s,c]=h.useState(null),l=Py(a,c),[u,d]=r,f=h.useRef(new Cb),p=h.useCallback(()=>{let e=f.current;return Ab(e)||e.sort(jb),e},[]);return h.useEffect(()=>{if(!s)return;let e=Mb(()=>{d(e=>{let t=e.toSorted(jb);return t.some(([t],n)=>e.keyAt(n)!==t)?t:e})});return e.observe(s,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[s,d]),(0,J.jsx)(i,{scope:t,collectionElementRef:l,collectionElementRefObject:a,getCollection:p,setCollection:d,registryRef:f,children:(0,J.jsx)(o,{scope:t,collectionElement:s,collection:u,children:n})})},`CollectionProviderImpl`);u.displayName=e+`CollectionProviderImpl`;let d=e+`CollectionSlot`,f=Ry(d),p=h.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=Py(t,a(d,n).collectionElementRef);return(0,J.jsx)(f,{ref:i,children:r})});p.displayName=d;let m=e+`CollectionItemSlot`,g=Ry(m),_=h.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=W(e,gb),o=h.useRef(null),{setCollection:s,registryRef:c}=a(m,n),l=h.useRef(i);Ob(l.current,i)||(l.current=i);let u=l.current,d=Py(t,h.useCallback(e=>{let t=c.current;e?t.set(e,E(E({},l.current),{},{element:e})):o.current&&t.delete(o.current)},[c]),o);pb(()=>{let e=o.current,t=c.current;e&&t.has(e)&&t.set(e,E(E({},u),{},{element:e}))},[u,c]);let f=h.useRef(null);return h.useEffect(()=>{var e;let t=o.current,n=f.current;(((e=n==null?void 0:n.element)==null?null:e)!==t||t&&(n==null?void 0:n.itemData)!==u)&&(f.current=t?{element:t,itemData:u}:null,s(e=>{let r=new Cb(e);return n&&n.element!==t&&r.delete(n.element),t&&r.set(t,E(E({},u),{},{element:t})),r.sort(jb)}))}),h.useEffect(()=>()=>{let e=f.current;f.current=null,e&&s(t=>{if(!t.has(e.element))return t;let n=new Cb(t);return n.delete(e.element),n})},[s]),(0,J.jsx)(g,E(E({},{"data-radix-collection-item":``}),{},{ref:d,children:r}))});_.displayName=m;function v(){return h.useState(new Cb)}bb(v,`useInitCollection`);function y(t){let{collection:n}=s(e+`CollectionConsumer`,t);return n}bb(y,`useCollection`);function b(t){let{getCollection:n}=a(e+`CollectionConsumer`,t);return n}return bb(b,`useGetCollection`),[{Provider:c,Slot:p,ItemSlot:_},{createCollectionScope:r,useCollection:y,useGetCollection:b,useInitCollection:v}]}bb(Db,`createCollection`);function Ob(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}bb(Ob,`shallowEqual`);function kb(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}bb(kb,`isElementPreceding`);function Ab(e){let t;for(let n of e.keys()){if(t){let e=t.compareDocumentPosition(n);if(!(e&Node.DOCUMENT_POSITION_DISCONNECTED)&&e&Node.DOCUMENT_POSITION_PRECEDING)return!1}t=n}return!0}bb(Ab,`isInDocumentOrder`);function jb(e,t){return!e[1].element||!t[1].element?0:kb(e[1].element,t[1].element)?-1:1}bb(jb,`sortByDocumentPosition`);function Mb(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}bb(Mb,`getChildListObserver`);var Nb=Object.defineProperty,Pb=(e,t)=>Nb(e,`name`,{value:t,configurable:!0}),Fb=!!(typeof window<`u`&&window.document&&window.document.createElement);function Ib(e,t,{checkForDefaultPrevented:n=!0}={}){return Pb(function(r){if(e==null||e(r),n===!1||!r||!r.defaultPrevented)return t==null?void 0:t(r)},`handleEvent`)}Pb(Ib,`composeEventHandlers`);function Lb(e){var t,n;if(!Fb)throw Error(`Cannot access window outside of the DOM`);return(t=e==null||(n=e.ownerDocument)==null?void 0:n.defaultView)==null?window:t}Pb(Lb,`getOwnerWindow`);function Rb(e){var t;if(!Fb)throw Error(`Cannot access document outside of the DOM`);return(t=e==null?void 0:e.ownerDocument)==null?document:t}Pb(Rb,`getOwnerDocument`);function zb(e,t=!1){let{activeElement:n}=Rb(e);if(!(n!=null&&n.nodeName))return null;if(Bb(n)&&n.contentDocument)return zb(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=Rb(n).getElementById(e);if(t)return t}}return n}Pb(zb,`getActiveElement`);function Bb(e){return e.tagName===`IFRAME`}Pb(Bb,`isFrame`);var Vb=Object.defineProperty,Hb=(e,t)=>Vb(e,`name`,{value:t,configurable:!0}),Ub=h.useInsertionEffect;function Wb(e){let t=h.useRef(e);return typeof Ub==`function`?Ub(()=>{t.current=e}):pb(()=>{t.current=e}),h.useMemo(()=>((...e)=>{var n;return(n=t.current)==null?void 0:n.call(t,...e)}),[])}Hb(Wb,`useCallbackRef`);var Gb=[`disableOutsidePointerEvents`,`deferPointerDownOutside`,`onEscapeKeyDown`,`onPointerDownOutside`,`onFocusOutside`,`onInteractOutside`,`onDismiss`],Kb=Object.defineProperty,qb=(e,t)=>Kb(e,`name`,{value:t,configurable:!0}),Jb=`dismissableLayer.update`,Yb=`dismissableLayer.pointerDownOutside`,Xb=`dismissableLayer.focusOutside`,Zb,Qb=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),$b=h.forwardRef(qb(function(e,t){var n,r;let{disableOutsidePointerEvents:i=!1,deferPointerDownOutside:a=!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:c,onInteractOutside:l,onDismiss:u}=e,d=W(e,Gb),f=h.useContext(Qb),[p,m]=h.useState(null),g=(n=p==null?void 0:p.ownerDocument)==null?(r=globalThis)==null?void 0:r.document:n,[,_]=h.useState({}),v=Py(t,m),y=Array.from(f.layers),[b]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),x=b?y.indexOf(b):-1,S=p?y.indexOf(p):-1,C=f.layersWithOutsidePointerEventsDisabled.size>0,w=S>=x,T=h.useRef(!1),D=nx(e=>{s==null||s(e),l==null||l(e),e.defaultPrevented||u==null||u()},{ownerDocument:g,deferPointerDownOutside:a,isDeferredPointerDownOutsideRef:T,dismissableSurfaces:f.dismissableSurfaces,shouldHandlePointerDownOutside:h.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...f.branches].some(t=>t.contains(e));return w&&!t},[f.branches,w])}),O=rx(e=>{if(a&&T.current)return;let t=e.target;[...f.branches].some(e=>e.contains(t))||(c==null||c(e),l==null||l(e),e.defaultPrevented||u==null||u())},g),k=p?S===y.length-1:!1,A=Wb(e=>{e.key===`Escape`&&(o==null||o(e),!e.defaultPrevented&&u&&(e.preventDefault(),u()))});return h.useEffect(()=>{if(k)return g.addEventListener(`keydown`,A,{capture:!0}),()=>g.removeEventListener(`keydown`,A,{capture:!0})},[g,k,A]),h.useEffect(()=>{if(p)return i&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(Zb=g.body.style.pointerEvents,g.body.style.pointerEvents=`none`),f.layersWithOutsidePointerEventsDisabled.add(p)),f.layers.add(p),ix(),()=>{i&&(f.layersWithOutsidePointerEventsDisabled.delete(p),f.layersWithOutsidePointerEventsDisabled.size===0&&(g.body.style.pointerEvents=Zb))}},[p,g,i,f]),h.useEffect(()=>()=>{p&&(f.layers.delete(p),f.layersWithOutsidePointerEventsDisabled.delete(p),ix())},[p,f]),h.useEffect(()=>{let e=qb(()=>_({}),`handleUpdate`);return document.addEventListener(Jb,e),()=>document.removeEventListener(Jb,e)},[]),(0,J.jsx)(rb.div,E(E({},d),{},{ref:v,style:E({pointerEvents:C?w?`auto`:`none`:void 0},e.style),onFocusCapture:Ib(e.onFocusCapture,O.onFocusCapture),onBlurCapture:Ib(e.onBlurCapture,O.onBlurCapture),onPointerDownCapture:Ib(e.onPointerDownCapture,D.onPointerDownCapture)}))},`DismissableLayer`));function ex(){let e=h.useContext(Qb),[t,n]=h.useState(null);return h.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}qb(ex,`useDismissableLayerSurface`);var tx=qb(()=>!0,`IS_TRUE`);function nx(e,t){var n;let{ownerDocument:r=(n=globalThis)==null?void 0:n.document,deferPointerDownOutside:i=!1,isDeferredPointerDownOutsideRef:a,dismissableSurfaces:o,shouldHandlePointerDownOutside:s=tx}=t,c=Wb(e),l=h.useRef(!1),u=h.useRef(!1),d=h.useRef(new Map),f=h.useRef(()=>{});return h.useEffect(()=>{function e(){u.current=!1,a.current=!1,d.current.clear()}qb(e,`resetOutsideInteraction`);function t(){return Array.from(d.current.values()).some(Boolean)}qb(t,`isOutsideInteractionIntercepted`);function n(e){if(!u.current)return;let t=e.target;t instanceof Node&&[...o].some(e=>e.contains(t))||d.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{u.current&&f.current()},0)}qb(n,`handleInteractionCapture`);function p(e){u.current&&d.current.set(e.type,!1)}qb(p,`handleInteractionBubble`);let m=qb(n=>{if(n.target&&!l.current){let o=function(){r.removeEventListener(`click`,f.current);let n=t();e(),n||ax(Yb,c,p,{discrete:!0})};if(qb(o,`handleAndDispatchPointerDownOutsideEvent`),!s(n.target)){r.removeEventListener(`click`,f.current),e(),l.current=!1;return}let p={originalEvent:n};u.current=!0,a.current=i&&n.button===0,d.current.clear(),!i||n.button!==0?o():(r.removeEventListener(`click`,f.current),f.current=o,r.addEventListener(`click`,f.current,{once:!0}))}else r.removeEventListener(`click`,f.current),e();l.current=!1},`handlePointerDown`),h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)r.addEventListener(e,n,!0),r.addEventListener(e,p);let g=window.setTimeout(()=>{r.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),r.removeEventListener(`pointerdown`,m),r.removeEventListener(`click`,f.current);for(let e of h)r.removeEventListener(e,n,!0),r.removeEventListener(e,p)}},[r,c,i,a,o,s]),{onPointerDownCapture:qb(()=>l.current=!0,`onPointerDownCapture`)}}qb(nx,`usePointerDownOutside`);function rx(e,t=(()=>{var e;return(e=globalThis)==null?void 0:e.document})()){let n=Wb(e),r=h.useRef(!1);return h.useEffect(()=>{let e=qb(e=>{e.target&&!r.current&&ax(Xb,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:qb(()=>r.current=!0,`onFocusCapture`),onBlurCapture:qb(()=>r.current=!1,`onBlurCapture`)}}qb(rx,`useFocusOutside`);function ix(){let e=new CustomEvent(Jb);document.dispatchEvent(e)}qb(ix,`dispatchUpdate`);function ax(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?ib(i,a):i.dispatchEvent(a)}qb(ax,`handleAndDispatchCustomEvent`);var ox=Object.defineProperty,sx=(e,t)=>ox(e,`name`,{value:t,configurable:!0}),cx=0,lx=null;function ux(e){return dx(),e.children}sx(ux,`FocusGuards`);function dx(){h.useEffect(()=>{lx||(lx={start:fx(),end:fx()});let{start:e,end:t}=lx;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),cx++,()=>{cx===1&&(lx==null||lx.start.remove(),lx==null||lx.end.remove(),lx=null),cx=Math.max(0,cx-1)}},[])}sx(dx,`useFocusGuards`);function fx(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}sx(fx,`createFocusGuard`);var px=[`loop`,`trapped`,`branches`,`onMountAutoFocus`,`onUnmountAutoFocus`],mx=Object.defineProperty,hx=(e,t)=>mx(e,`name`,{value:t,configurable:!0}),gx=`focusScope.autoFocusOnMount`,_x=`focusScope.autoFocusOnUnmount`,vx={bubbles:!1,cancelable:!0},yx=h.forwardRef(hx(function(e,t){let{loop:n=!1,trapped:r=!1,branches:i,onMountAutoFocus:a,onUnmountAutoFocus:o}=e,s=W(e,px),[c,l]=h.useState(null),u=Wb(a),d=Wb(o),f=h.useRef(null),p=Py(t,l),m=h.useRef(i);h.useEffect(()=>{m.current=i});let g=h.useCallback(e=>{var t;return e?c!=null&&c.contains(e)?!0:!!((t=m.current)!=null&&t.some(t=>t.contains(e))):!1},[c]),_=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let e=function(e){if(_.paused||!c)return;let t=e.target;g(t)?f.current=t:Ax(f.current,{select:!0})},t=function(e){if(_.paused||!c)return;let t=e.relatedTarget;t!==null&&(g(t)||Ax(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&Ax(c)};hx(e,`handleFocusIn`),hx(t,`handleFocusOut`),hx(n,`handleMutations`),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return c&&r.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,c,_.paused,g]),h.useEffect(()=>{if(c){jx.add(_);let e=document.activeElement;if(!c.contains(e)){let t=new CustomEvent(gx,vx);c.addEventListener(gx,u),c.dispatchEvent(t),t.defaultPrevented||(wx(Px(Ex(c)),{select:!0}),document.activeElement===e&&Ax(c))}return()=>{c.removeEventListener(gx,u);let t=c.ownerDocument,n=CustomEvent;setTimeout(()=>{let r=new n(_x,vx);c.addEventListener(_x,d),c.dispatchEvent(r),r.defaultPrevented||Ax(e==null?t.body:e,{select:!0}),c.removeEventListener(_x,d),jx.remove(_)},0)}}},[c,u,d,_]);let v=h.useCallback(e=>{if(!n&&!r||_.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=Tx(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&Ax(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&Ax(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,_.paused]);return(0,J.jsx)(rb.div,E(E({tabIndex:-1},s),{},{ref:p,onKeyDown:v}))},`FocusScope`)),bx=h.createContext(null);function xx({registry:e,children:t}){return e?(0,J.jsx)(bx.Provider,{value:e,children:t}):t}hx(xx,`FocusScopeBranchProvider`);function Sx(){let[e,t]=h.useState([]);return{nodes:e,registry:h.useMemo(()=>({add:hx(e=>t(t=>t.includes(e)?t:[...t,e]),`add`),remove:hx(e=>t(t=>t.filter(t=>t!==e)),`remove`)}),[])}}hx(Sx,`useFocusScopeBranchRegistry`);function Cx(e){let t=h.useContext(bx);h.useEffect(()=>{if(e&&t)return t.add(e),()=>t.remove(e)},[e,t])}hx(Cx,`useFocusScopeBranch`);function wx(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(Ax(r,{select:t}),document.activeElement!==n)return}hx(wx,`focusFirst`);function Tx(e){let t=Ex(e);return[Dx(t,e),Dx(t.reverse(),e)]}hx(Tx,`getTabbableEdges`);function Ex(e){let t=[],n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:hx(e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}hx(Ex,`getTabbableCandidates`);function Dx(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Ox(r,{upTo:t})))return r}hx(Dx,`findVisible`);function Ox(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}hx(Ox,`isHidden`);function kx(e){return e.tagName===`INPUT`&&typeof e.select==`function`}hx(kx,`isSelectableInput`);function Ax(e,{select:t=!1}={}){if(e&&e.focus){var n;let r=((n=e.ownerDocument)==null?document:n).activeElement;e.focus({preventScroll:!0}),e!==r&&kx(e)&&t&&e.select()}}hx(Ax,`focus`);var jx=Mx();function Mx(){let e=[];return{add(t){let n=e[0];t!==n&&(n==null||n.pause()),e=Nx(e,t),e.unshift(t)},remove(t){var n;e=Nx(e,t),(n=e[0])==null||n.resume()}}}hx(Mx,`createFocusScopesStack`);function Nx(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}hx(Nx,`arrayRemove`);function Px(e){return e.filter(e=>e.tagName!==`A`)}hx(Px,`removeLinks`);var Fx=Object.defineProperty,Ix=(e,t)=>Fx(e,`name`,{value:t,configurable:!0}),Lx={LTR:`ltr`,RTL:`rtl`},Rx=h.createContext(void 0);function zx(e){let t=h.useContext(Rx);return e||t||Lx.LTR}Ix(zx,`useDirection`);var Bx=Object.defineProperty,Vx=(e,t)=>Bx(e,`name`,{value:t,configurable:!0}),Hx=h.useId||(()=>void 0),Ux=0;function Wx(e){let[t,n]=h.useState(Hx());return pb(()=>{e||n(e=>e==null?String(Ux++):e)},[e]),e||(t?`radix-${t}`:``)}Vx(Wx,`useId`);var Gx=[`top`,`right`,`bottom`,`left`],Kx=Math.min,qx=Math.max,Jx=Math.round,Yx=Math.floor,Xx=e=>({x:e,y:e}),Zx={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Qx(e,t,n){return qx(e,Kx(t,n))}function $x(e,t){return typeof e==`function`?e(t):e}function eS(e){return e.split(`-`)[0]}function tS(e){return e.split(`-`)[1]}function nS(e){return e===`x`?`y`:`x`}function rS(e){return e===`y`?`height`:`width`}function iS(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function aS(e){return nS(iS(e))}function oS(e,t,n){n===void 0&&(n=!1);let r=tS(e),i=aS(e),a=rS(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=hS(o)),[o,hS(o)]}function sS(e){let t=hS(e);return[cS(e),t,cS(t)]}function cS(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var lS=[`left`,`right`],uS=[`right`,`left`],dS=[`top`,`bottom`],fS=[`bottom`,`top`];function pS(e,t,n){switch(e){case`top`:case`bottom`:return n?t?uS:lS:t?lS:uS;case`left`:case`right`:return t?dS:fS;default:return[]}}function mS(e,t,n,r){let i=tS(e),a=pS(eS(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(cS)))),a}function hS(e){let t=eS(e);return Zx[t]+e.slice(t.length)}function gS(e){var t,n,r,i;return{top:(t=e.top)==null?0:t,right:(n=e.right)==null?0:n,bottom:(r=e.bottom)==null?0:r,left:(i=e.left)==null?0:i}}function _S(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:gS(e)}function vS(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}var yS=[`mainAxis`,`crossAxis`,`fallbackPlacements`,`fallbackStrategy`,`fallbackAxisSideDirection`,`flipAlignment`],bS=[`strategy`],xS=[`mainAxis`,`crossAxis`,`limiter`],SS=[`apply`];function CS(e,t,n){let{reference:r,floating:i}=e,a=iS(t),o=aS(t),s=rS(o),c=eS(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=tS(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}function wS(e,t){return TS.apply(this,arguments)}function TS(){return TS=w(function*(e,t){var n;t===void 0&&(t={});let{x:r,y:i,platform:a,rects:o,elements:s,strategy:c}=e,{boundary:l=`clippingAncestors`,rootBoundary:u=`viewport`,elementContext:d=`floating`,altBoundary:f=!1,padding:p=0}=$x(t,e),m=_S(p),h=s[f?d===`floating`?`reference`:`floating`:d],g=vS(yield a.getClippingRect({element:(n=yield a.isElement==null?void 0:a.isElement(h))==null||n?h:h.contextElement||(yield a.getDocumentElement==null?void 0:a.getDocumentElement(s.floating)),boundary:l,rootBoundary:u,strategy:c})),_=d===`floating`?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,v=yield a.getOffsetParent==null?void 0:a.getOffsetParent(s.floating),y=(yield a.isElement==null?void 0:a.isElement(v))&&(yield a.getScale==null?void 0:a.getScale(v))||{x:1,y:1},b=vS(a.convertOffsetParentRelativeRectToViewportRelativeRect?yield a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:_,offsetParent:v,strategy:c}):_);return{top:(g.top-b.top+m.top)/y.y,bottom:(b.bottom-g.bottom+m.bottom)/y.y,left:(g.left-b.left+m.left)/y.x,right:(b.right-g.right+m.right)/y.x}}),TS.apply(this,arguments)}var ES=50,DS=function(){var e=w(function*(e,t,n){let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:E(E({},o),{},{detectOverflow:wS}),c=yield o.isRTL==null?void 0:o.isRTL(t),l=yield o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=CS(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=yield _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v==null?u:v,d=y==null?d:y,m[g]=E(E({},m[g]),b),x&&p<ES&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?yield o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=CS(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}});return function(t,n,r){return e.apply(this,arguments)}}(),OS=e=>({name:`arrow`,options:e,fn(t){return w(function*(){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=$x(e,t)||{};if(l==null)return{};let d=_S(u),f={x:n,y:r},p=aS(i),m=rS(p),h=yield o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=yield o.getOffsetParent==null?void 0:o.getOffsetParent(l),C=S?S[y]:0;C&&(yield o.isElement==null?void 0:o.isElement(S))||(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,D=Kx(d[_],T),O=Kx(d[v],T),k=C-h[m]-O,A=C/2-h[m]/2+w,j=Qx(D,A,k),M=!c.arrow&&tS(i)!=null&&A!==j&&a.reference[m]/2-(A<D?D:O)-h[m]/2<0,N=M?A<D?A-D:A-k:0;return{[p]:f[p]+N,data:E({[p]:j,centerOffset:A-j-N},M&&{alignmentOffset:N}),reset:M}})()}}),kS=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,fn(t){return w(function*(){var n,r;let{placement:i,middlewareData:a,rects:o,initialPlacement:s,platform:c,elements:l}=t,u=$x(e,t),{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:m=`bestFit`,fallbackAxisSideDirection:h=`none`,flipAlignment:g=!0}=u,_=W(u,yS);if((n=a.arrow)!=null&&n.alignmentOffset)return{};let v=eS(i),y=iS(s),b=eS(s)===s,x=yield c.isRTL==null?void 0:c.isRTL(l.floating),S=p||(b||!g?[hS(s)]:sS(s)),C=h!==`none`;!p&&C&&S.push(...mS(s,g,h,x));let w=[s,...S],T=yield c.detectOverflow(t,_),E=[],D=((r=a.flip)==null?void 0:r.overflows)||[];if(d&&E.push(T[v]),f){let e=oS(i,o,x);E.push(T[e[0]],T[e[1]])}if(D=[...D,{placement:i,overflows:E}],!E.every(e=>e<=0)){var O,k;let e=(((O=a.flip)==null?void 0:O.index)||0)+1,t=w[e];if(t&&(f!==`alignment`||y===iS(t)||D.every(e=>iS(e.placement)!==y||e.overflows[0]>0)))return{data:{index:e,overflows:D},reset:{placement:t}};let n=(k=D.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])==null?void 0:k.placement;if(!n)switch(m){case`bestFit`:{var A;let e=(A=D.filter(e=>{if(C){let t=iS(e.placement);return t===y||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])==null?void 0:A[0];e&&(n=e);break}case`initialPlacement`:n=s}if(i!==n)return{reset:{placement:n}}}return{}})()}}};function AS(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function jS(e){return Gx.some(t=>e[t]>=0)}var MS=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,fn(t){return w(function*(){let{rects:n,platform:r}=t,i=$x(e,t),{strategy:a=`referenceHidden`}=i,o=W(i,bS);switch(a){case`referenceHidden`:{let e=AS(yield r.detectOverflow(t,E(E({},o),{},{elementContext:`reference`})),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:jS(e)}}}case`escaped`:{let e=AS(yield r.detectOverflow(t,E(E({},o),{},{altBoundary:!0})),n.floating);return{data:{escapedOffsets:e,escaped:jS(e)}}}default:return{}}})()}}},NS=new Set([`left`,`top`]);function PS(e,t){return FS.apply(this,arguments)}function FS(){return FS=w(function*(e,t){let{placement:n,platform:r,elements:i}=e,a=yield r.isRTL==null?void 0:r.isRTL(i.floating),o=eS(n),s=tS(n),c=iS(n)===`y`,l=NS.has(o)?-1:1,u=a&&c?-1:1,d=$x(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}),FS.apply(this,arguments)}var IS=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,fn(t){return w(function*(){var n,r;let{x:i,y:a,placement:o,middlewareData:s}=t,c=yield PS(t,e);return o===((n=s.offset)==null?void 0:n.placement)&&(r=s.arrow)!=null&&r.alignmentOffset?{}:{x:i+c.x,y:a+c.y,data:E(E({},c),{},{placement:o})}})()}}},LS=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,fn(t){return w(function*(){let{x:n,y:r,placement:i,platform:a}=t,o=$x(e,t),{mainAxis:s=!0,crossAxis:c=!1,limiter:l={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}}}=o,u=W(o,xS),d={x:n,y:r},f=yield a.detectOverflow(t,u),p=iS(i),m=nS(p),h=d[m],g=d[p],_=(e,t)=>Qx(t+f[e===`y`?`top`:`left`],t,t-f[e===`y`?`bottom`:`right`]);s&&(h=_(m,h)),c&&(g=_(p,g));let v=l.fn(E(E({},t),{},{[m]:h,[p]:g}));return E(E({},v),{},{data:{x:v.x-n,y:v.y-r,enabled:{[m]:s,[p]:c}}})})()}}},RS=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,r;let{x:i,y:a,placement:o,rects:s,middlewareData:c}=t,{offset:l=0,mainAxis:u=!0,crossAxis:d=!0}=$x(e,t),f={x:i,y:a},p=iS(o),m=nS(p),h=f[m],g=f[p],_=$x(l,t),v=typeof _==`number`?{mainAxis:_,crossAxis:0}:{mainAxis:(n=_.mainAxis)==null?0:n,crossAxis:(r=_.crossAxis)==null?0:r};if(u){let e=m===`y`?`height`:`width`,t=s.reference[m]-s.floating[e]+v.mainAxis,n=s.reference[m]+s.reference[e]-v.mainAxis;h<t?h=t:h>n&&(h=n)}if(d){var y,b;let e=m===`y`?`width`:`height`,t=NS.has(eS(o)),n=s.reference[p]-s.floating[e]+(t&&((y=c.offset)==null?void 0:y[p])||0)+(t?0:v.crossAxis),r=s.reference[p]+s.reference[e]+(t?0:((b=c.offset)==null?void 0:b[p])||0)-(t?v.crossAxis:0);g<n?g=n:g>r&&(g=r)}return{[m]:h,[p]:g}}}},zS=function(e){return e===void 0&&(e={}),{name:`size`,options:e,fn(t){return w(function*(){let{placement:n,rects:r,platform:i,elements:a}=t,o=$x(e,t),{apply:s=()=>{}}=o,c=W(o,SS),l=yield i.detectOverflow(t,c),u=eS(n),d=tS(n),f=iS(n)===`y`,{width:p,height:m}=r.floating,h,g;u===`top`||u===`bottom`?(h=u,g=d===((yield i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(g=u,h=d===`end`?`top`:`bottom`);let _=m-l.top-l.bottom,v=p-l.left-l.right,y=Kx(m-l[h],_),b=Kx(p-l[g],v),x=t.middlewareData.shift,S=!x,C=y,w=b;x!=null&&x.enabled.x&&(w=v),x!=null&&x.enabled.y&&(C=_),S&&!d&&(f?w=p-2*qx(l.left,l.right):C=m-2*qx(l.top,l.bottom)),yield s(E(E({},t),{},{availableWidth:w,availableHeight:C}));let T=yield i.getDimensions(a.floating);return p!==T.width||m!==T.height?{reset:{rects:!0}}:{}})()}}};function BS(){return typeof window<`u`}function VS(e){return WS(e)?(e.nodeName||``).toLowerCase():`#document`}function HS(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function US(e){var t;return(t=(WS(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function WS(e){return BS()?e instanceof Node||e instanceof HS(e).Node:!1}function GS(e){return BS()?e instanceof Element||e instanceof HS(e).Element:!1}function KS(e){return BS()?e instanceof HTMLElement||e instanceof HS(e).HTMLElement:!1}function qS(e){return!BS()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof HS(e).ShadowRoot}function JS(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=aC(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function YS(e){return/^(table|td|th)$/.test(VS(e))}function XS(e){try{if(e.matches(`:popover-open`))return!0}catch(e){}try{return e.matches(`:modal`)}catch(e){return!1}}var ZS=/transform|translate|scale|rotate|perspective|filter/,QS=/paint|layout|strict|content/,$S=e=>!!e&&e!==`none`,eC;function tC(e){let t=GS(e)?aC(e):e;return $S(t.transform)||$S(t.translate)||$S(t.scale)||$S(t.rotate)||$S(t.perspective)||!rC()&&($S(t.backdropFilter)||$S(t.filter))||ZS.test(t.willChange||``)||QS.test(t.contain||``)}function nC(e){let t=sC(e);for(;KS(t)&&!iC(t);){if(tC(t))return t;if(XS(t))return null;t=sC(t)}return null}function rC(){return eC==null&&(eC=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`)),eC}function iC(e){return/^(html|body|#document)$/.test(VS(e))}function aC(e){return HS(e).getComputedStyle(e)}function oC(e){return GS(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function sC(e){if(VS(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||qS(e)&&e.host||US(e);return qS(t)?t.host:t}function cC(e){let t=sC(e);return iC(t)?(e.ownerDocument||e).body:KS(t)&&JS(t)?t:cC(t)}function lC(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);let i=cC(e),a=i===((r=e.ownerDocument)==null?void 0:r.body),o=HS(i);if(a){let e=uC(o);return t.concat(o,o.visualViewport||[],JS(i)?i:[],e&&n?lC(e):[])}return t.concat(i,lC(i,[],n))}function uC(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function dC(e){let t=aC(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=KS(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Jx(n)!==a||Jx(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function fC(e){return GS(e)?e:e.contextElement}function pC(e){let t=fC(e);if(!KS(t))return Xx(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=dC(t),o=(a?Jx(n.width):n.width)/r,s=(a?Jx(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var mC=Xx(0);function hC(e){let t=HS(e);return!rC()||!t.visualViewport?mC:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function gC(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===HS(e)}function _C(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=fC(e),o=Xx(1);t&&(r?GS(r)&&(o=pC(r)):o=pC(e));let s=gC(a,n,r)?hC(a):Xx(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=HS(a),t=GS(r)?HS(r):r,n=e,i=uC(n);for(;i&&t!==n;){let e=pC(i),t=i.getBoundingClientRect(),r=aC(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=HS(i),i=uC(n)}}return vS({width:u,height:d,x:c,y:l})}function vC(e,t){let n=oC(e).scrollLeft;return t?t.left+n:_C(US(e)).left+n}function yC(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-vC(e,n),y:n.top+t.scrollTop}}function bC(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=US(r),s=t?XS(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Xx(1),u=Xx(0),d=KS(r);if((d||!a)&&((VS(r)!==`body`||JS(o))&&(c=oC(r)),d)){let e=_C(r);l=pC(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?yC(o,c):Xx(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function xC(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function SC(e){let t=oC(e),n=e.ownerDocument.body,r=qx(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=qx(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+vC(e),o=-t.scrollTop;return aC(n).direction===`rtl`&&(a+=qx(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var CC=25;function wC(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=HS(e),a=US(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!rC()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(vC(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=CC&&(s-=o)}return{width:s,height:c,x:l,y:u}}function TC(e,t){let n=_C(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=pC(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function EC(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=wC(e,n,t);else if(t===`document`)r=SC(US(e));else if(GS(t))r=TC(t,n);else{let n=hC(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return vS(r)}function DC(e,t){let n=t.get(e);if(n)return n;let r=lC(e,[],!1).filter(e=>GS(e)&&VS(e)!==`body`),i=null,a=aC(e).position===`fixed`,o=a?sC(e):e;for(;GS(o)&&!iC(o);){let e=aC(o),t=tC(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=sC(o)}return t.set(e,r),r}function OC(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?XS(t)?[]:DC(t,this._c):[].concat(n),r],o=EC(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=EC(t,a[e],i);s=qx(n.top,s),c=Kx(n.right,c),l=Kx(n.bottom,l),u=qx(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function kC(e){let{width:t,height:n}=dC(e);return{width:t,height:n}}function AC(e,t,n){let r=KS(t),i=US(t),a=n===`fixed`,o=_C(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Xx(0);if((r||!a)&&((VS(t)!==`body`||JS(i))&&(s=oC(t)),r)){let e=_C(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=vC(i));let l=i&&!r&&!a?yC(i,s):Xx(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function jC(e){return aC(e).position===`static`}function MC(e,t){if(!KS(e)||aC(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return US(e)===n&&(n=n.ownerDocument.body),n}function NC(e,t){let n=HS(e);if(XS(e))return n;if(!KS(e)){let t=sC(e);for(;t&&!iC(t);){if(GS(t)&&!jC(t))return t;t=sC(t)}return n}let r=MC(e,t);for(;r&&YS(r)&&jC(r);)r=MC(r,t);return r&&iC(r)&&jC(r)&&!tC(r)?n:r||nC(e)||n}var PC=function(){var e=w(function*(e){let t=this.getOffsetParent||NC,n=this.getDimensions,r=yield n(e.floating);return{reference:AC(e.reference,yield t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}});return function(t){return e.apply(this,arguments)}}();function FC(e){return aC(e).direction===`rtl`}var IC={convertOffsetParentRelativeRectToViewportRelativeRect:bC,getDocumentElement:US,getClippingRect:OC,getOffsetParent:NC,getElementRects:PC,getClientRects:xC,getDimensions:kC,getScale:pC,isElement:GS,isRTL:FC};function LC(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function RC(e,t,n){let r=null,i,a=US(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=Yx(d),h=Yx(a.clientWidth-(u+f)),g=Yx(a.clientHeight-(d+p)),_=Yx(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:qx(0,Kx(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!LC(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,E(E({},v),{},{root:a.ownerDocument}))}catch(e){r=new IntersectionObserver(b,v)}r.observe(e)}let c=HS(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function zC(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=fC(e),u=i||a?[...l?lC(l):[],...t?lC(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?RC(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?_C(e):null;c&&g();function g(){let t=_C(e);h&&!LC(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d==null||d(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var BC=IS,VC=LS,HC=kS,UC=zS,WC=MS,GC=OS,KC=RS,qC=(e,t,n)=>{let r=new Map,i=n==null?{}:n,a=E(E(E({},IC),i.platform),{},{_c:r});return DS(e,t,E(E({},i),{},{platform:a}))},JC=typeof document<`u`?h.useLayoutEffect:function(){};function YC(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,i;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(!YC(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!YC(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function XC(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function ZC(e,t){let n=XC(e);return Math.round(t*n)/n}function QC(e){let t=h.useRef(e);return JC(()=>{t.current=e}),t}function $C(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:r=`absolute`,middleware:i=[],platform:a,elements:{reference:o,floating:s}={},transform:c=!0,whileElementsMounted:l,open:u}=e,[d,f]=h.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=h.useState(i);YC(p,i)||m(i);let[g,_]=h.useState(null),[v,y]=h.useState(null),b=h.useCallback(e=>{e!==w.current&&(w.current=e,_(e))},[]),x=h.useCallback(e=>{e!==T.current&&(T.current=e,y(e))},[]),S=o||g,C=s||v,w=h.useRef(null),T=h.useRef(null),D=h.useRef(d),O=l!=null,k=QC(l),A=QC(a),j=QC(u),M=h.useCallback(()=>{if(!w.current||!T.current)return;let e={placement:t,strategy:r,middleware:p};A.current&&(e.platform=A.current),qC(w.current,T.current,e).then(e=>{let t=E(E({},e),{},{isPositioned:j.current!==!1});N.current&&!YC(D.current,t)&&(D.current=t,n.flushSync(()=>{f(t)}))})},[p,t,r,A,j]);JC(()=>{u===!1&&D.current.isPositioned&&(D.current.isPositioned=!1,f(e=>E(E({},e),{},{isPositioned:!1})))},[u]);let N=h.useRef(!1);JC(()=>(N.current=!0,()=>{N.current=!1}),[]),JC(()=>{if(S&&(w.current=S),C&&(T.current=C),S&&C){if(k.current)return k.current(S,C,M);M()}},[S,C,M,k,O]);let P=h.useMemo(()=>({reference:w,floating:T,setReference:b,setFloating:x}),[b,x]),F=h.useMemo(()=>({reference:S,floating:C}),[S,C]),I=h.useMemo(()=>{let e={position:r,left:0,top:0};if(!F.floating)return e;let t=ZC(F.floating,d.x),n=ZC(F.floating,d.y);return c?E(E({},e),{},{transform:`translate(`+t+`px, `+n+`px)`},XC(F.floating)>=1.5&&{willChange:`transform`}):{position:r,left:t,top:n}},[r,c,F.floating,d.x,d.y]);return h.useMemo(()=>E(E({},d),{},{update:M,refs:P,elements:F,floatingStyles:I}),[d,M,P,F,I])}var ew=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:GC({element:r.current,padding:i}).fn(n):r?GC({element:r,padding:i}).fn(n):{}}}},tw=(e,t)=>{let n=BC(e);return{name:n.name,fn:n.fn,options:[e,t]}},nw=(e,t)=>{let n=VC(e);return{name:n.name,fn:n.fn,options:[e,t]}},rw=(e,t)=>({fn:KC(e).fn,options:[e,t]}),iw=(e,t)=>{let n=HC(e);return{name:n.name,fn:n.fn,options:[e,t]}},aw=(e,t)=>{let n=UC(e);return{name:n.name,fn:n.fn,options:[e,t]}},ow=(e,t)=>{let n=WC(e);return{name:n.name,fn:n.fn,options:[e,t]}},sw=(e,t)=>{let n=ew(e);return{name:n.name,fn:n.fn,options:[e,t]}},cw=Object.defineProperty,lw=(e,t)=>cw(e,`name`,{value:t,configurable:!0});function uw(e){let[t,n]=h.useState(void 0);return pb(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=0,r=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;let i=r[0];window.cancelAnimationFrame(t),t=window.requestAnimationFrame(()=>{let t,r;if(`borderBoxSize`in i){let e=i.borderBoxSize,n=Array.isArray(e)?e[0]:e;t=n.inlineSize,r=n.blockSize}else t=e.offsetWidth,r=e.offsetHeight;n({width:t,height:r})})});return r.observe(e,{box:`border-box`}),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}n(void 0)},[e]),t}lw(uw,`useSize`);var dw=[`__scopePopper`,`virtualRef`],fw=[`__scopePopper`,`side`,`sideOffset`,`align`,`alignOffset`,`arrowPadding`,`avoidCollisions`,`collisionBoundary`,`collisionPadding`,`sticky`,`hideWhenDetached`,`updatePositionStrategy`,`onPlaced`],pw=Object.defineProperty,mw=(e,t)=>pw(e,`name`,{value:t,configurable:!0}),hw={Partial:`partial`,Always:`always`},gw={Optimized:`optimized`,Always:`always`},_w=`Popper`,[vw,yw]=ub(_w),[bw,xw]=vw(_w),Sw=mw(e=>{let{__scopePopper:t,children:n}=e,[r,i]=h.useState(null),[a,o]=h.useState(void 0);return(0,J.jsx)(bw,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),Cw=`PopperAnchor`,ww=h.forwardRef(mw(function(e,t){let{__scopePopper:n,virtualRef:r}=e,i=W(e,dw),a=xw(Cw,n),o=h.useRef(null),s=a.onAnchorChange,c=Py(t,h.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=h.useRef(null);h.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&jw(a.placementState),d=u==null?void 0:u[0],f=u==null?void 0:u[1];return r?null:(0,J.jsx)(rb.div,E(E({"data-radix-popper-side":d,"data-radix-popper-align":f},i),{},{ref:c}))},`PopperAnchor`)),Tw=`PopperContent`,[Ew,Dw]=vw(Tw),Ow=h.forwardRef(mw(function(e,t){var n,r,i,a,o,s,c,l,u;let{__scopePopper:d,side:f=`bottom`,sideOffset:p=0,align:m=`center`,alignOffset:g=0,arrowPadding:_=0,avoidCollisions:v=!0,collisionBoundary:y=[],collisionPadding:b=0,sticky:x=hw.Partial,hideWhenDetached:S=!1,updatePositionStrategy:C=gw.Optimized,onPlaced:w}=e,T=W(e,fw),D=xw(Tw,d),[O,k]=h.useState(null),A=Py(t,k),[j,M]=h.useState(null),N=uw(j),P=(n=N==null?void 0:N.width)==null?0:n,F=(r=N==null?void 0:N.height)==null?0:r,I=f+(m===`center`?``:`-`+m),L=typeof b==`number`?b:E({top:0,right:0,bottom:0,left:0},b),R=Array.isArray(y)?y:[y],z=R.length>0,B={padding:L,boundary:R.filter(kw),altBoundary:z},{refs:ee,floatingStyles:V,placement:te,isPositioned:H,middlewareData:U}=$C({strategy:`fixed`,placement:I,whileElementsMounted:mw((...e)=>zC(...e,{animationFrame:C===gw.Always}),`whileElementsMounted`),elements:{reference:D.anchor},middleware:[tw({mainAxis:p+F,alignmentAxis:g}),v&&nw(E(E({mainAxis:!0,crossAxis:!1},x===hw.Partial?{limiter:rw()}:{}),B)),v&&iw(E({},B)),aw(E(E({},B),{},{apply:mw(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)})),j&&sw({element:j,padding:_}),Aw({arrowWidth:P,arrowHeight:F}),S&&ow(z?E({strategy:`referenceHidden`},B):{strategy:`referenceHidden`,padding:B.padding,altBoundary:B.altBoundary})]}),ne=D.setPlacementState;pb(()=>(ne(te),()=>{ne(void 0)}),[te,ne]);let[re,ie]=jw(te),ae=Wb(w);pb(()=>{H&&(ae==null||ae())},[H,ae]);let oe=(i=U.arrow)==null?void 0:i.x,se=(a=U.arrow)==null?void 0:a.y,ce=((o=U.arrow)==null?void 0:o.centerOffset)!==0,[le,ue]=h.useState();return pb(()=>{O&&ue(window.getComputedStyle(O).zIndex)},[O]),(0,J.jsx)(`div`,{ref:ee.setFloating,"data-radix-popper-content-wrapper":``,style:E(E({},V),{},{transform:H?V.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:le,"--radix-popper-transform-origin":[(s=U.transformOrigin)==null?void 0:s.x,(c=U.transformOrigin)==null?void 0:c.y].join(` `)},((l=U.hide)==null?void 0:l.referenceHidden)&&{visibility:`hidden`,pointerEvents:`none`}),dir:e.dir,children:(0,J.jsx)(Ew,{scope:d,placedSide:re,placedAlign:ie,onArrowChange:M,arrowX:oe,arrowY:se,shouldHideArrow:ce,children:(0,J.jsx)(rb.div,E(E({"data-side":re,"data-align":ie},T),{},{ref:A,style:E(E({},T.style),{},{animation:H?(u=T.style)==null?void 0:u.animation:`none`})}))})})},`PopperContent`));function kw(e){return e!==null}mw(kw,`isNotNull`);var Aw=mw(e=>({name:`transformOrigin`,options:e,fn(t){var n,r,i,a,o;let{placement:s,rects:c,middlewareData:l}=t,u=((n=l.arrow)==null?void 0:n.centerOffset)!==0,d=u?0:e.arrowWidth,f=u?0:e.arrowHeight,[p,m]=jw(s),h={start:`0%`,center:`50%`,end:`100%`}[m],g=((r=(i=l.arrow)==null?void 0:i.x)==null?0:r)+d/2,_=((a=(o=l.arrow)==null?void 0:o.y)==null?0:a)+f/2,v=``,y=``;return p===`bottom`?(v=u?h:`${g}px`,y=`${-f}px`):p===`top`?(v=u?h:`${g}px`,y=`${c.floating.height+f}px`):p===`right`?(v=`${-f}px`,y=u?h:`${_}px`):p===`left`&&(v=`${c.floating.width+f}px`,y=u?h:`${_}px`),{data:{x:v,y}}}}),`transformOrigin`);function jw(e){let[t,n=`center`]=e.split(`-`);return[t,n]}mw(jw,`getSideAndAlignFromPlacement`);var Mw=[`container`],Nw=Object.defineProperty,Pw=h.forwardRef(((e,t)=>Nw(e,`name`,{value:t,configurable:!0}))(function(e,t){var r;let{container:i}=e,a=W(e,Mw),[o,s]=h.useState(!1);pb(()=>s(!0),[]);let c=i||o&&((r=globalThis)==null||(r=r.document)==null?void 0:r.body);return c?n.createPortal((0,J.jsx)(rb.div,E(E({},a),{},{ref:t})),c):null},`Portal`)),Fw=Object.defineProperty,Iw=(e,t)=>Fw(e,`name`,{value:t,configurable:!0});function Lw(e,t){return h.useReducer((e,n)=>{let r=t[e][n];return r==null?e:r},e)}Iw(Lw,`useStateMachine`);var Rw=Iw(e=>{let{present:t,children:n}=e,r=zw(t),i=typeof n==`function`?n({present:r.isPresent}):h.Children.only(n),a=Vw(r.ref,Uw(i));return typeof n==`function`||r.isPresent?h.cloneElement(i,{ref:a}):null},`Presence`);function zw(e){let[t,n]=h.useState(),r=h.useRef(null),i=h.useRef(e),a=h.useRef(`none`),o=h.useRef(void 0),[s,c]=Lw(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return h.useEffect(()=>{if(s===`mounted`){var e;a.current=(e=o.current)==null?Hw(r.current):e,o.current=void 0}else a.current=`none`},[s]),pb(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=Hw(t);e?(o.current=s,c(`MOUNT`)):s===`none`||(t==null?void 0:t.display)===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),pb(()=>{if(t){var e;let n,o=(e=t.ownerDocument.defaultView)==null?window:e,s=Iw(e=>{let a=Hw(r.current).includes(CSS.escape(e.animationName));if(e.target===t&&a&&(c(`ANIMATION_END`),!i.current)){let e=t.style.animationFillMode;t.style.animationFillMode=`forwards`,n=o.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=e)})}},`handleAnimationEnd`),l=Iw(e=>{e.target===t&&(a.current=Hw(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,l),t.addEventListener(`animationcancel`,s),t.addEventListener(`animationend`,s),()=>{o.clearTimeout(n),t.removeEventListener(`animationstart`,l),t.removeEventListener(`animationcancel`,s),t.removeEventListener(`animationend`,s)}}c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:h.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=Hw(t)}else r.current=null;n(e)},[])}}Iw(zw,`usePresence`);function Bw(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}Iw(Bw,`setRef`);function Vw(...e){let t=h.useRef(e);return t.current=e,h.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=Bw(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():Bw(n[e],null)}}},[])}Iw(Vw,`useStableComposedRefs`);function Hw(e){return(e==null?void 0:e.animationName)||`none`}Iw(Hw,`getAnimationName`);function Uw(e){var t,n;let r=(t=Object.getOwnPropertyDescriptor(e.props,`ref`))==null?void 0:t.get,i=r&&`isReactWarning`in r&&r.isReactWarning;return i?e.ref:(r=(n=Object.getOwnPropertyDescriptor(e,`ref`))==null?void 0:n.get,i=r&&`isReactWarning`in r&&r.isReactWarning,i?e.props.ref:e.props.ref||e.ref)}Iw(Uw,`getElementRef`);var Ww=Object.defineProperty,Gw=(e,t)=>Ww(e,`name`,{value:t,configurable:!0}),Kw=h.useEffectEvent,qw=h.useInsertionEffect;function Jw(e){if(typeof Kw==`function`)return Kw(e);let t=h.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof qw==`function`?qw(()=>{t.current=e}):pb(()=>{t.current=e}),h.useMemo(()=>((...e)=>{var n;return(n=t.current)==null?void 0:n.call(t,...e)}),[])}Gw(Jw,`useEffectEvent`);var Yw=Object.defineProperty,Xw=(e,t)=>Yw(e,`name`,{value:t,configurable:!0}),Zw=h.useInsertionEffect||pb;function Qw({prop:e,defaultProp:t,onChange:n=Xw(()=>{},`onChange`),caller:r}){let[i,a,o]=$w({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,h.useCallback(t=>{if(s){let r=eT(t)?t(e):t;if(r!==e){var n;(n=o.current)==null||n.call(o,r)}}else a(t)},[s,e,a,o])]}Xw(Qw,`useControllableState`);function $w({defaultProp:e,onChange:t}){let[n,r]=h.useState(e),i=h.useRef(n),a=h.useRef(t);return Zw(()=>{a.current=t},[t]),h.useEffect(()=>{if(i.current!==n){var e;(e=a.current)==null||e.call(a,n),i.current=n}},[n,i]),[n,r,a]}Xw($w,`useUncontrolledState`);function eT(e){return typeof e==`function`}Xw(eT,`isFunction`);var tT=Symbol(`RADIX:SYNC_STATE`);function nT(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=Jw(o),u=[E(E({},n),{},{state:a})];r&&u.push(r);let[d,f]=h.useReducer((t,n)=>{if(n.type===tT)return E(E({},t),{},{state:n.state});let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),p=d.state,m=h.useRef(p);h.useEffect(()=>{m.current!==p&&(m.current=p,c||l(p))},[p,m,c]);let g=h.useMemo(()=>i===void 0?d:E(E({},d),{},{state:i}),[d,i]);return h.useEffect(()=>{c&&!Object.is(i,d.state)&&f({type:tT,state:i})},[i,d.state,c]),[g,f]}Xw(nT,`useControllableStateReducer`);var rT=Object.defineProperty,iT=(e,t)=>rT(e,`name`,{value:t,configurable:!0}),aT=!1;function oT(){let[e,t]=h.useState(aT);return h.useEffect(()=>{aT||(aT=!0,t(!0))},[]),e}iT(oT,`useIsHydrated`);var sT=h.useSyncExternalStore;function cT(){return()=>{}}iT(cT,`subscribe`);function lT(){return sT(cT,()=>!0,()=>!1)}iT(lT,`useIsHydratedModern`);var uT=typeof sT==`function`?lT:oT,dT=[`__scopeRovingFocusGroup`,`orientation`,`loop`,`dir`,`currentTabStopId`,`defaultCurrentTabStopId`,`onCurrentTabStopIdChange`,`onEntryFocus`,`preventScrollOnEntryFocus`],fT=[`__scopeRovingFocusGroup`,`focusable`,`active`,`tabStopId`,`children`],pT=Object.defineProperty,mT=(e,t)=>pT(e,`name`,{value:t,configurable:!0}),hT=`rovingFocusGroup.onEntryFocus`,gT={bubbles:!1,cancelable:!0},_T=`RovingFocusGroup`,[vT,yT,bT]=xb(_T),[xT,ST]=ub(_T,[bT]),CT={Vertical:`vertical`,Horizontal:`horizontal`},wT={LTR:`ltr`,RTL:`rtl`},[TT,ET]=xT(_T),DT=h.forwardRef(mT(function(e,t){return(0,J.jsx)(vT.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,J.jsx)(vT.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,J.jsx)(OT,E(E({},e),{},{ref:t}))})})},`RovingFocusGroup`)),OT=h.forwardRef(mT(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1}=e,d=W(e,dT),f=h.useRef(null),p=Py(t,f),m=zx(a),[g,_]=Qw({prop:o,defaultProp:s==null?null:s,onChange:c,caller:_T}),[v,y]=h.useState(!1),b=Wb(l),x=yT(n),S=h.useRef(!1),[C,w]=h.useState(0);return h.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(hT,b),()=>e.removeEventListener(hT,b)},[b]),(0,J.jsx)(TT,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:g,onItemFocus:h.useCallback(e=>_(e),[_]),onItemShiftTab:h.useCallback(()=>y(!0),[]),onFocusableItemAdd:h.useCallback(()=>w(e=>e+1),[]),onFocusableItemRemove:h.useCallback(()=>w(e=>e-1),[]),children:(0,J.jsx)(rb.div,E(E({tabIndex:v||C===0?-1:0,"data-orientation":r},d),{},{ref:p,style:E({outline:`none`},e.style),onMouseDown:Ib(e.onMouseDown,()=>{S.current=!0}),onFocus:Ib(e.onFocus,e=>{let t=!S.current;if(e.target===e.currentTarget&&t&&!v){let t=new CustomEvent(hT,gT);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=x().filter(e=>e.focusable);PT([e.find(e=>e.active),e.find(e=>e.id===g),...e].filter(Boolean).map(e=>e.ref.current),u)}}S.current=!1}),onBlur:Ib(e.onBlur,()=>y(!1))}))})},`RovingFocusGroupImpl`)),kT=`RovingFocusGroupItem`,AT=h.forwardRef(mT(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o}=e,s=W(e,fT),c=Wx(),l=a||c,u=ET(kT,n),d=u.currentTabStopId===l,f=yT(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:g}=u,_=uT();return pb(()=>{if(_&&r)return p(),()=>m()},[_,r,p,m]),h.useEffect(()=>{if(!_&&r)return p(),()=>m()},[_,r,p,m]),(0,J.jsx)(vT.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,J.jsx)(rb.span,E(E({tabIndex:d?0:-1,"data-orientation":u.orientation},s),{},{ref:t,onMouseDown:Ib(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:Ib(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:Ib(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=NT(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?FT(n,r+1):n.slice(r+1)}setTimeout(()=>PT(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:g!=null}):o}))})},`RovingFocusGroupItem`)),jT={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function MT(e,t){return t===wT.RTL?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}mT(MT,`getDirectionAwareKey`);function NT(e,t,n){let r=MT(e.key,n);if(!(t===CT.Vertical&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===CT.Horizontal&&[`ArrowUp`,`ArrowDown`].includes(r)))return jT[r]}mT(NT,`getFocusIntent`);function PT(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}mT(PT,`focusFirst`);function FT(e,t){return e.map((n,r)=>e[(t+r)%e.length])}mT(FT,`wrapArray`);var IT=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},LT=new WeakMap,RT=new WeakMap,zT={},BT=0,VT=function(e){return e&&(e.host||VT(e.parentNode))},HT=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=VT(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},UT=function(e,t,n,r){var i=HT(t,Array.isArray(e)?e:[e]);zT[n]||(zT[n]=new WeakMap);var a=zT[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(LT.get(e)||0)+1,l=(a.get(e)||0)+1;LT.set(e,c),a.set(e,l),o.push(e),c===1&&i&&RT.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),BT++,function(){o.forEach(function(e){var t=LT.get(e)-1,i=a.get(e)-1;LT.set(e,t),a.set(e,i),t||(RT.has(e)||e.removeAttribute(r),RT.delete(e)),i||e.removeAttribute(n)}),BT--,BT||(LT=new WeakMap,LT=new WeakMap,RT=new WeakMap,zT={})}},WT=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||IT(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),UT(r,i,n,`aria-hidden`)):function(){return null}},GT=function(){return GT=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},GT.apply(this,arguments)};function KT(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function qT(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var JT=`right-scroll-bar-position`,YT=`width-before-scroll-bar`,XT=`with-scroll-bars-hidden`,ZT=`--removed-body-scroll-bar-size`;function QT(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function $T(e,n){var r=(0,t.useState)(function(){return{value:e,callback:n,facade:{get current(){return r.value},set current(e){var t=r.value;t!==e&&(r.value=e,r.callback(e,t))}}}})[0];return r.callback=n,r.facade}var eE=typeof window<`u`?t.useLayoutEffect:t.useEffect,tE=new WeakMap;function nE(e,t){var n=$T(t||null,function(t){return e.forEach(function(e){return QT(e,t)})});return eE(function(){var t=tE.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||QT(e,null)}),i.forEach(function(e){r.has(e)||QT(e,a)})}tE.set(n,e)},[e]),n}function rE(e){return e}function iE(e,t){t===void 0&&(t=rE);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function aE(e){e===void 0&&(e={});var t=iE(null);return t.options=GT({async:!0,ssr:!1},e),t}var oE=function(e){var n=e.sideCar,r=KT(e,[`sideCar`]);if(!n)throw Error("Sidecar: please provide `sideCar` property to import the right car");var i=n.read();if(!i)throw Error(`Sidecar medium not found`);return t.createElement(i,GT({},r))};oE.isSideCarExport=!0;function sE(e,t){return e.useMedium(t),oE}var cE=aE(),lE=function(){},uE=t.forwardRef(function(e,n){var r=t.useRef(null),i=t.useState({onScrollCapture:lE,onWheelCapture:lE,onTouchMoveCapture:lE}),a=i[0],o=i[1],s=e.forwardProps,c=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,h=e.noIsolation,g=e.inert,_=e.allowPinchZoom,v=e.as,y=v===void 0?`div`:v,b=e.gapMode,x=KT(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=p,C=nE([r,n]),w=GT(GT({},x),a);return t.createElement(t.Fragment,null,d&&t.createElement(S,{sideCar:cE,removeScrollBar:u,shards:f,noRelative:m,noIsolation:h,inert:g,setCallbacks:o,allowPinchZoom:!!_,lockRef:r,gapMode:b}),s?t.cloneElement(t.Children.only(c),GT(GT({},w),{ref:C})):t.createElement(y,GT({},w,{className:l,ref:C}),c))});uE.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},uE.classNames={fullWidth:YT,zeroRight:JT};var dE,fE=function(){if(dE)return dE;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function pE(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=fE();return t&&e.setAttribute(`nonce`,t),e}function mE(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function hE(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var gE=function(){var e=0,t=null;return{add:function(n){e==0&&(t=pE())&&(mE(t,n),hE(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},_E=function(){var e=gE();return function(n,r){t.useEffect(function(){return e.add(n),function(){e.remove()}},[n&&r])}},vE=function(){var e=_E();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},yE={left:0,top:0,right:0,gap:0},bE=function(e){return parseInt(e||``,10)||0},xE=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[bE(n),bE(r),bE(i)]},SE=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return yE;var t=xE(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},CE=vE(),wE=`data-scroll-locked`,TE=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
20
+ .${XT} {
21
+ overflow: hidden ${r};
22
+ padding-right: ${s}px ${r};
23
+ }
24
+ body[${wE}] {
25
+ overflow: hidden ${r};
26
+ overscroll-behavior: contain;
27
+ ${[t&&`position: relative ${r};`,n===`margin`&&`
28
+ padding-left: ${i}px;
29
+ padding-top: ${a}px;
30
+ padding-right: ${o}px;
31
+ margin-left:0;
32
+ margin-top:0;
33
+ margin-right: ${s}px ${r};
34
+ `,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
35
+ }
36
+
37
+ .${JT} {
38
+ right: ${s}px ${r};
39
+ }
40
+
41
+ .${YT} {
42
+ margin-right: ${s}px ${r};
43
+ }
44
+
45
+ .${JT} .${JT} {
46
+ right: 0 ${r};
47
+ }
48
+
49
+ .${YT} .${YT} {
50
+ margin-right: 0 ${r};
51
+ }
52
+
53
+ body[${wE}] {
54
+ ${ZT}: ${s}px;
55
+ }
56
+ `},EE=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},DE=function(){t.useEffect(function(){return document.body.setAttribute(wE,(EE()+1).toString()),function(){var e=EE()-1;e<=0?document.body.removeAttribute(wE):document.body.setAttribute(wE,e.toString())}},[])},OE=function(e){var n=e.noRelative,r=e.noImportant,i=e.gapMode,a=i===void 0?`margin`:i;DE();var o=t.useMemo(function(){return SE(a)},[a]);return t.createElement(CE,{styles:TE(o,!n,a,r?``:`!important`)})},kE=!1;if(typeof window<`u`)try{var AE=Object.defineProperty({},"passive",{get:function(){return kE=!0,!0}});window.addEventListener(`test`,AE,AE),window.removeEventListener(`test`,AE,AE)}catch(e){kE=!1}var jE=kE?{passive:!1}:!1,ME=function(e){return e.tagName===`TEXTAREA`},NE=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!ME(e)&&n[t]===`visible`)},PE=function(e){return NE(e,`overflowY`)},FE=function(e){return NE(e,`overflowX`)},IE=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),zE(e,r)){var i=BE(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},LE=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},RE=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},zE=function(e,t){return e===`v`?PE(t):FE(t)},BE=function(e,t){return e===`v`?LE(t):RE(t)},VE=function(e,t){return e===`h`&&t===`rtl`?-1:1},HE=function(e,t,n,r,i){var a=VE(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=BE(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&zE(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},UE=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},WE=function(e){return[e.deltaX,e.deltaY]},GE=function(e){return e&&`current`in e?e.current:e},KE=function(e,t){return e[0]===t[0]&&e[1]===t[1]},qE=function(e){return`
57
+ .block-interactivity-${e} {pointer-events: none;}
58
+ .allow-interactivity-${e} {pointer-events: all;}
59
+ `},JE=0,YE=[];function XE(e){var n=t.useRef([]),r=t.useRef([0,0]),i=t.useRef(),a=t.useState(JE++)[0],o=t.useState(vE)[0],s=t.useRef(e);t.useEffect(function(){s.current=e},[e]),t.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${a}`);var t=qT([e.lockRef.current],(e.shards||[]).map(GE),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${a}`)}),function(){document.body.classList.remove(`block-interactivity-${a}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${a}`)})}}},[e.inert,e.lockRef.current,e.shards]);var c=t.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!s.current.allowPinchZoom;var n=UE(e),a=r.current,o=`deltaX`in e?e.deltaX:a[0]-n[0],c=`deltaY`in e?e.deltaY:a[1]-n[1],l,u=e.target,d=Math.abs(o)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=IE(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=IE(d,u)),!m)return!1;if(!i.current&&`changedTouches`in e&&(o||c)&&(i.current=l),!l)return!0;var h=i.current||l;return HE(h,t,e,h===`h`?o:c,!0)},[]),l=t.useCallback(function(e){var t=e;if(YE.length&&YE[YE.length-1]===o){var r=`deltaY`in t?WE(t):UE(t),i=n.current.filter(function(e){return e.name===t.type&&(e.target===t.target||t.target===e.shadowParent)&&KE(e.delta,r)})[0];if(i&&i.should)t.cancelable&&t.preventDefault();else if(!i){var a=(s.current.shards||[]).map(GE).filter(Boolean).filter(function(e){return e.contains(t.target)});(a.length>0?c(t,a[0]):!s.current.noIsolation)&&t.cancelable&&t.preventDefault()}}},[]),u=t.useCallback(function(e,t,r,i){var a={name:e,delta:t,target:r,should:i,shadowParent:ZE(r)};n.current.push(a),setTimeout(function(){n.current=n.current.filter(function(e){return e!==a})},1)},[]),d=t.useCallback(function(e){r.current=UE(e),i.current=void 0},[]),f=t.useCallback(function(t){u(t.type,WE(t),t.target,c(t,e.lockRef.current))},[]),p=t.useCallback(function(t){u(t.type,UE(t),t.target,c(t,e.lockRef.current))},[]);t.useEffect(function(){return YE.push(o),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener(`wheel`,l,jE),document.addEventListener(`touchmove`,l,jE),document.addEventListener(`touchstart`,d,jE),function(){YE=YE.filter(function(e){return e!==o}),document.removeEventListener(`wheel`,l,jE),document.removeEventListener(`touchmove`,l,jE),document.removeEventListener(`touchstart`,d,jE)}},[]);var m=e.removeScrollBar,h=e.inert;return t.createElement(t.Fragment,null,h?t.createElement(o,{styles:qE(a)}):null,m?t.createElement(OE,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ZE(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var QE=sE(cE,XE),$E=t.forwardRef(function(e,n){return t.createElement(uE,GT({},e,{ref:n,sideCar:QE}))});$E.classNames=uE.classNames;var eD=[`__scopeMenu`],tD=[`forceMount`],nD=[`__scopeMenu`,`loop`,`trapFocus`,`onOpenAutoFocus`,`onCloseAutoFocus`,`disableOutsidePointerEvents`,`onEntryFocus`,`onEscapeKeyDown`,`onPointerDownOutside`,`onFocusOutside`,`onInteractOutside`,`onDismiss`,`disableOutsideScroll`],rD=[`disabled`,`onSelect`],iD=[`__scopeMenu`,`disabled`,`textValue`],aD=[`__scopeMenu`],oD=Object.defineProperty,sD=(e,t)=>oD(e,`name`,{value:t,configurable:!0}),cD=[`Enter`,` `],lD=[`ArrowDown`,`PageUp`,`Home`],uD=[`ArrowUp`,`PageDown`,`End`],dD=[...lD,...uD];[...cD],[...cD];var fD=`Menu`,[pD,mD,hD]=xb(fD),[gD,_D]=ub(fD,[hD,yw,ST]),vD=yw(),yD=ST(),[bD,xD]=gD(fD),[SD,CD]=gD(fD),wD=sD(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=vD(t),[c,l]=h.useState(null),u=h.useRef(!1),d=Wb(a),f=zx(i);return h.useEffect(()=>{let e=sD(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=sD(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),h.useEffect(()=>{if(!n)return;let e=sD(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,J.jsx)(Sw,E(E({},s),{},{children:(0,J.jsx)(bD,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,J.jsx)(SD,{scope:t,onClose:h.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})}))},`Menu`),TD=h.forwardRef(sD(function(e,t){let{__scopeMenu:n}=e,r=W(e,eD),i=vD(n);return(0,J.jsx)(ww,E(E(E({},i),r),{},{ref:t}))},`MenuAnchor`)),ED=`MenuPortal`,[DD,OD]=gD(ED,{forceMount:void 0}),kD=sD(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=xD(ED,t);return(0,J.jsx)(DD,{scope:t,forceMount:n,children:(0,J.jsx)(Rw,{present:n||a.open,children:(0,J.jsx)(Pw,{asChild:!0,container:i,children:r})})})},`MenuPortal`),AD=`MenuContent`,[jD,MD]=gD(AD),ND=h.forwardRef(sD(function(e,t){let n=OD(AD,e.__scopeMenu),{forceMount:r=n.forceMount}=e,i=W(e,tD),a=xD(AD,e.__scopeMenu),o=CD(AD,e.__scopeMenu);return(0,J.jsx)(pD.Provider,{scope:e.__scopeMenu,children:(0,J.jsx)(Rw,{present:r||a.open,children:(0,J.jsx)(pD.Slot,{scope:e.__scopeMenu,children:o.modal?(0,J.jsx)(PD,E(E({},i),{},{ref:t})):(0,J.jsx)(FD,E(E({},i),{},{ref:t}))})})})},`MenuContent`)),PD=h.forwardRef(sD(function(e,t){let n=xD(AD,e.__scopeMenu),r=h.useRef(null),i=Py(t,r);return h.useEffect(()=>{let e=r.current;if(e)return WT(e)},[]),(0,J.jsx)(LD,E(E({},e),{},{ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ib(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)}))},`MenuRootContentModal`)),FD=h.forwardRef(sD(function(e,t){let n=xD(AD,e.__scopeMenu);return(0,J.jsx)(LD,E(E({},e),{},{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)}))},`MenuRootContentNonModal`)),ID=Ry(`MenuContent.ScrollLock`),LD=h.forwardRef(sD(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m}=e,g=W(e,nD),_=xD(AD,n),v=CD(AD,n),y=vD(n),b=yD(n),x=mD(n),[S,C]=h.useState(null),w=h.useRef(null),[T,D]=h.useState(null);Cx(T);let{nodes:O,registry:k}=Sx(),A=!!(i||m),j=Py(t,w,_.onContentChange,D),M=h.useRef(0),N=h.useRef(``),P=h.useRef(0),F=h.useRef(null),I=h.useRef(`right`),L=h.useRef(0),R=h.useMemo(()=>m?[w,...O.map(e=>({current:e}))]:[],[w,O,m]),z=m?$E:h.Fragment,B=m?{as:ID,allowPinchZoom:!0,shards:R}:void 0,ee=sD(e=>{var t,n;let r=N.current+e,i=x().filter(e=>!e.disabled),a=document.activeElement,o=(t=i.find(e=>e.ref.current===a))==null?void 0:t.textValue,s=eO(i.map(e=>e.textValue),r,o),c=(n=i.find(e=>e.textValue===s))==null?void 0:n.ref.current;function l(e){N.current=e,window.clearTimeout(M.current),e!==``&&(M.current=window.setTimeout(()=>l(``),1e3))}sD(l,`updateSearch`),l(r),c&&setTimeout(()=>c.focus())},`handleTypeaheadSearch`);h.useEffect(()=>()=>window.clearTimeout(M.current),[]),dx();let V=h.useCallback(e=>{var t,n;return I.current===((t=F.current)==null?void 0:t.side)&&nO(e,(n=F.current)==null?void 0:n.area)},[]);return(0,J.jsx)(jD,{scope:n,searchRef:N,onItemEnter:h.useCallback(e=>{V(e)&&e.preventDefault()},[V]),onItemLeave:h.useCallback(e=>{var t;V(e)||((t=w.current)==null||t.focus(),C(null))},[V]),onTriggerLeave:h.useCallback(e=>{V(e)&&e.preventDefault()},[V]),pointerGraceTimerRef:P,onPointerGraceIntentChange:h.useCallback(e=>{F.current=e},[]),children:(0,J.jsx)(xx,{registry:A?k:null,children:(0,J.jsx)(z,E(E({},B),{},{children:(0,J.jsx)(yx,{asChild:!0,trapped:i,branches:O,onMountAutoFocus:Ib(a,e=>{var t;e.preventDefault(),(t=w.current)==null||t.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,J.jsx)($b,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,J.jsx)(DT,E(E({asChild:!0},b),{},{dir:v.dir,orientation:`vertical`,loop:r,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:Ib(c,e=>{v.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,J.jsx)(Ow,E(E(E({role:`menu`,"aria-orientation":`vertical`,"data-state":YD(_.open),"data-radix-menu-content":``,dir:v.dir},y),g),{},{ref:j,style:E({outline:`none`},g.style),onKeyDown:Ib(g.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&ee(e.key));let i=w.current;if(e.target!==i||!dD.includes(e.key))return;e.preventDefault();let a=x().filter(e=>!e.disabled).map(e=>e.ref.current);uD.includes(e.key)&&a.reverse(),QD(a)}),onBlur:Ib(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(M.current),N.current=``)}),onPointerMove:Ib(e.onPointerMove,rO(e=>{let t=e.target,n=L.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>L.current?`right`:`left`;I.current=t,L.current=e.clientX}}))}))}))})})}))})})},`MenuContentImpl`)),RD=`MenuItem`,zD=`menu.itemSelect`,BD=h.forwardRef(sD(function(e,t){let{disabled:n=!1,onSelect:r}=e,i=W(e,rD),a=h.useRef(null),o=CD(RD,e.__scopeMenu),s=MD(RD,e.__scopeMenu),c=Py(t,a),l=h.useRef(!1),u=sD(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(zD,{bubbles:!0,cancelable:!0});e.addEventListener(zD,e=>r==null?void 0:r(e),{once:!0}),ib(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,J.jsx)(VD,E(E({},i),{},{ref:c,disabled:n,onClick:Ib(e.onClick,u),onPointerDown:t=>{var n;(n=e.onPointerDown)==null||n.call(e,t),l.current=!0},onPointerUp:Ib(e.onPointerUp,e=>{var t;l.current||(t=e.currentTarget)==null||t.click()}),onKeyDown:Ib(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(s.searchRef.current===``||e.key!==` `)&&cD.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})}))},`MenuItem`)),VD=h.forwardRef(sD(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i}=e,a=W(e,iD),o=MD(RD,n),s=yD(n),c=h.useRef(null),l=Py(t,c),[u,d]=h.useState(!1),[f,p]=h.useState(``);return h.useEffect(()=>{let e=c.current;if(e){var t;p(((t=e.textContent)==null?``:t).trim())}},[a.children]),(0,J.jsx)(pD.ItemSlot,{scope:n,disabled:r,textValue:i==null?f:i,children:(0,J.jsx)(AT,E(E({asChild:!0},s),{},{focusable:!r,children:(0,J.jsx)(rb.div,E(E({role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0},a),{},{ref:l,onPointerMove:Ib(e.onPointerMove,rO(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ib(e.onPointerLeave,rO(e=>o.onItemLeave(e))),onFocus:Ib(e.onFocus,()=>d(!0)),onBlur:Ib(e.onBlur,()=>d(!1))}))}))})},`MenuItemImpl`)),[HD,UD]=gD(`MenuRadioGroup`,{value:void 0,onValueChange:sD(()=>{},`onValueChange`)}),[WD,GD]=gD(`MenuItemIndicator`,{checked:!1}),KD=h.forwardRef(sD(function(e,t){let{__scopeMenu:n}=e,r=W(e,aD);return(0,J.jsx)(rb.div,E(E({role:`separator`,"aria-orientation":`horizontal`},r),{},{ref:t}))},`MenuSeparator`)),[qD,JD]=gD(`MenuSub`);function YD(e){return e?`open`:`closed`}sD(YD,`getOpenState`);function XD(e){return e===`indeterminate`}sD(XD,`isIndeterminate`);function ZD(e){return XD(e)?`indeterminate`:e?`checked`:`unchecked`}sD(ZD,`getCheckedState`);function QD(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}sD(QD,`focusFirst`);function $D(e,t){return e.map((n,r)=>e[(t+r)%e.length])}sD($D,`wrapArray`);function eO(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=$D(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}sD(eO,`getNextMatch`);function tO(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}sD(tO,`isPointInPolygon`);function nO(e,t){return t?tO({x:e.clientX,y:e.clientY},t):!1}sD(nO,`isPointerInGraceArea`);function rO(e){return t=>t.pointerType===`mouse`?e(t):void 0}sD(rO,`whenMouse`);var iO=Object.defineProperty,aO=(e,t)=>iO(e,`name`,{value:t,configurable:!0});function oO(e,t=(()=>{var e;return(e=globalThis)==null?void 0:e.document})()){let n=Wb(e);h.useEffect(()=>{let e=aO(e=>{e.key===`Escape`&&n(e)},`handleKeyDown`);return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}aO(oO,`useEscapeKeydown`);var sO=rb;sO.dispatchDiscreteCustomEvent=ib,sO.Root=rb;var cO=Object.defineProperty,lO=(e,t)=>{let n={};for(var r in e)cO(n,r,{get:e[r],enumerable:!0});return t||cO(n,Symbol.toStringTag,{value:`Module`}),n},uO=[`__scopeDropdownMenu`,`disabled`],dO=[`__scopeDropdownMenu`],fO=[`__scopeDropdownMenu`],pO=[`__scopeDropdownMenu`],mO=[`__scopeDropdownMenu`],hO=Object.defineProperty,gO=(e,t)=>hO(e,`name`,{value:t,configurable:!0}),_O=`DropdownMenu`,[vO,yO]=ub(_O,[_D]),bO=_D(),[xO,SO]=vO(_O),CO=gO(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=bO(t),l=h.useRef(null),[u,d]=Qw({prop:i,defaultProp:a!=null&&a,onChange:o,caller:_O});return(0,J.jsx)(xO,{scope:t,triggerId:Wx(),triggerRef:l,contentId:Wx(),open:u,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,J.jsx)(wD,E(E({},c),{},{open:u,onOpenChange:d,dir:r,modal:s,children:n}))})},`DropdownMenu`),wO=`DropdownMenuTrigger`,TO=h.forwardRef(gO(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1}=e,i=W(e,uO),a=SO(wO,n),o=bO(n),s=Py(t,a.triggerRef);return(0,J.jsx)(TD,E(E({asChild:!0},o),{},{children:(0,J.jsx)(rb.button,E(E({type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r},i),{},{ref:s,onPointerDown:Ib(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:Ib(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})}))}))},`DropdownMenuTrigger`)),EO=gO(e=>{let{__scopeDropdownMenu:t}=e,n=W(e,dO),r=bO(t);return(0,J.jsx)(kD,E(E({},r),n))},`DropdownMenuPortal`),DO=`DropdownMenuContent`,OO=h.forwardRef(gO(function(e,t){let{__scopeDropdownMenu:n}=e,r=W(e,fO),i=SO(DO,n),a=bO(n),o=h.useRef(!1);return(0,J.jsx)(ND,E(E(E({id:i.contentId,"aria-labelledby":i.triggerId},a),r),{},{ref:t,onCloseAutoFocus:Ib(e.onCloseAutoFocus,e=>{var t;o.current||(t=i.triggerRef.current)==null||t.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:Ib(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:E(E({},e.style),{"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`})}))},`DropdownMenuContent`)),kO=h.forwardRef(gO(function(e,t){let{__scopeDropdownMenu:n}=e,r=W(e,pO),i=bO(n);return(0,J.jsx)(BD,E(E(E({},i),r),{},{ref:t}))},`DropdownMenuItem`)),AO=h.forwardRef(gO(function(e,t){let{__scopeDropdownMenu:n}=e,r=W(e,mO),i=bO(n);return(0,J.jsx)(KD,E(E(E({},i),r),{},{ref:t}))},`DropdownMenuSeparator`)),jO=[`render`,`asChild`,`children`],MO=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`];function NO(e,t){return Nn(e,void 0,t===void 0?e.props.children:t)}function PO(e,t,n){return(0,J.jsx)(zy,E(E({},n),{},{children:NO(e,t)}))}function FO(e){var t,n;let r=kn((t,n)=>{let r=K(17),i,a,o,s;if(r[0]!==t){var c=t;({render:o,asChild:i,children:a}=c),s=W(c,jO),r[0]=t,r[1]=i,r[2]=a,r[3]=o,r[4]=s}else i=r[1],a=r[2],o=r[3],s=r[4];let l=e;if(o&&Pn(o)){let e=s,t;r[5]!==a||r[6]!==o?(t=NO(o,a),r[5]=a,r[6]=o,r[7]=t):t=r[7];let i;return r[8]!==n||r[9]!==e||r[10]!==t?(i=(0,J.jsx)(l,E(E({},e),{},{asChild:!0,ref:n,children:t})),r[8]=n,r[9]=e,r[10]=t,r[11]=i):i=r[11],i}let u=s,d;return r[12]!==i||r[13]!==a||r[14]!==n||r[15]!==u?(d=(0,J.jsx)(l,E(E({},u),{},{asChild:i,ref:n,children:a})),r[12]=i,r[13]=a,r[14]=n,r[15]=u,r[16]=d):d=r[16],d});return r.displayName=typeof e==`string`?e:(t=(n=e.displayName)==null?e.name:n)==null?`Component`:t,r}function IO(e){let t=sO[e],n=FO(t);return n.displayName=`Primitive.${e}`,n}var LO=MO.reduce((e,t)=>(e[t]=IO(t),e),{}),RO={Hidden:`hidden`,Floating:`floating`,Normal:`normal`},zO=e=>{let t=K(5),{hideWhenRunning:n,autohide:r,autohideFloat:i,forceVisible:a}=e,o;return t[0]!==r||t[1]!==i||t[2]!==a||t[3]!==n?(o=e=>{if(n&&e.thread.isRunning)return RO.Hidden;let t=r===`always`||r===`not-last`&&!e.message.isLast,o=a||e.message.isHovering;return t?o?i===`always`||i===`single-branch`&&e.message.branchCount<=1?RO.Floating:RO.Normal:RO.Hidden:RO.Normal},t[0]=r,t[1]=i,t[2]=a,t[3]=n,t[4]=o):o=t[4],q(o)},BO=zn(null),VO=()=>Vn(BO),HO=[`hideWhenRunning`,`autohide`,`autohideFloat`],UO=kn((e,t)=>{let n=K(18),r,i,a,o;if(n[0]!==e){var s=e;({hideWhenRunning:a,autohide:r,autohideFloat:i}=s),o=W(s,HO),n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o}else r=n[1],i=n[2],a=n[3],o=n[4];let[c,l]=_n(0),u;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{let e=!1;return l(WO),()=>{e||(e=!0,l(GO))}},n[5]=u):u=n[5];let d=u,f;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(f={acquireInteractionLock:d},n[6]=f):f=n[6];let p=f,m=c>0,h;n[7]!==r||n[8]!==i||n[9]!==a||n[10]!==m?(h={hideWhenRunning:a,autohide:r,autohideFloat:i,forceVisible:m},n[7]=r,n[8]=i,n[9]=a,n[10]=m,n[11]=h):h=n[11];let g=zO(h);if(g===RO.Hidden)return null;let _;n[12]===g?_=n[13]:(_=g===RO.Floating?{"data-floating":`true`}:null,n[12]=g,n[13]=_);let v;return n[14]!==t||n[15]!==o||n[16]!==_?(v=(0,J.jsx)(BO.Provider,{value:p,children:(0,J.jsx)(LO.div,E(E(E({},_),o),{},{ref:t}))}),n[14]=t,n[15]=o,n[16]=_,n[17]=v):v=n[17],v});UO.displayName=`ActionBarPrimitive.Root`;function WO(e){return e+1}function GO(e){return Math.max(0,e-1)}var KO=[`copiedDuration`,`onClick`,`disabled`],qO=e=>{let t=K(4),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{copiedDuration:r}=n,i=r===void 0?3e3:r,a;t[2]===i?a=t[3]:(a={copiedDuration:i,copyToClipboard:YO},t[2]=i,t[3]=a);let{copy:o,disabled:s}=Dv(a);return s?null:o},JO=kn((e,t)=>{let n=K(20),r,i,a,o;if(n[0]!==e){var s=e;({copiedDuration:r,onClick:a,disabled:i}=s),o=W(s,KO),n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o}else r=n[1],i=n[2],a=n[3],o=n[4];let c=q(XO),l;n[5]===r?l=n[6]:(l={copiedDuration:r},n[5]=r,n[6]=l);let u=qO(l),d;n[7]===c?d=n[8]:(d=c?{"data-copied":`true`}:{},n[7]=c,n[8]=d);let f=i||!u,p;n[9]===u?p=n[10]:(p=()=>{u==null||u()},n[9]=u,n[10]=p);let m;n[11]!==a||n[12]!==p?(m=Ib(a,p),n[11]=a,n[12]=p,n[13]=m):m=n[13];let h;return n[14]!==t||n[15]!==o||n[16]!==d||n[17]!==f||n[18]!==m?(h=(0,J.jsx)(LO.button,E(E(E({type:`button`},d),o),{},{ref:t,disabled:f,onClick:m})),n[14]=t,n[15]=o,n[16]=d,n[17]=f,n[18]=m,n[19]=h):h=n[19],h});JO.displayName=`ActionBarPrimitive.Copy`;function YO(e){return typeof navigator>`u`||!navigator.clipboard?Promise.reject(Error(`Clipboard API is unavailable`)):navigator.clipboard.writeText(e)}function XO(e){return e.message.isCopied}var ZO=(e,t,n=[])=>{let r=kn((e,r)=>{var i;let a=K(6),o={},s={};Object.keys(e).forEach(t=>{n.includes(t)?o[t]=e[t]:s[t]=e[t]});let c=(i=t(o))==null?void 0:i,l=LO,u=s.disabled||!c,d=Ib(s.onClick,c),f;return a[0]!==r||a[1]!==s||a[2]!==l.button||a[3]!==u||a[4]!==d?(f=(0,J.jsx)(l.button,E(E({type:`button`},s),{},{ref:r,disabled:u,onClick:d})),a[0]=r,a[1]=s,a[2]=l.button,a[3]=u,a[4]=d,a[5]=f):f=a[5],f});return r.displayName=e,r},QO=ZO(`ActionBarPrimitive.Reload`,()=>{let{disabled:e,reload:t}=Pv();return e?null:t}),$O=ZO(`ActionBarPrimitive.Edit`,()=>{let{disabled:e,edit:t}=Nv();return e?null:t}),ek=ZO(`ActionBarPrimitive.Speak`,()=>{let{disabled:e,speak:t}=zv();return e?null:t}),tk=()=>{let{disabled:e,stopSpeaking:t}=Bv();return e?null:t},nk=kn((e,t)=>{let n=K(10),r=tk(),i=!r,a;n[0]===r?a=n[1]:(a=()=>{r==null||r()},n[0]=r,n[1]=a);let o;n[2]!==e.onClick||n[3]!==a?(o=Ib(e.onClick,a),n[2]=e.onClick,n[3]=a,n[4]=o):o=n[4];let s;return n[5]!==e||n[6]!==t||n[7]!==i||n[8]!==o?(s=(0,J.jsx)(LO.button,E(E({type:`button`,disabled:i},e),{},{ref:t,onClick:o})),n[5]=e,n[6]=t,n[7]=i,n[8]=o,n[9]=s):s=n[9],s});nk.displayName=`ActionBarPrimitive.StopSpeaking`;var rk=[`onClick`,`disabled`],ik=()=>{let{submit:e}=Fv();return e},ak=kn((e,t)=>{let n=K(18),r,i,a;if(n[0]!==e){var o=e;({onClick:i,disabled:r}=o),a=W(o,rk),n[0]=e,n[1]=r,n[2]=i,n[3]=a}else r=n[1],i=n[2],a=n[3];let s=q(ok),c=ik(),l;n[4]===s?l=n[5]:(l=s?{"data-submitted":`true`}:{},n[4]=s,n[5]=l);let u=r||!c,d;n[6]===c?d=n[7]:(d=()=>{c==null||c()},n[6]=c,n[7]=d);let f;n[8]!==i||n[9]!==d?(f=Ib(i,d),n[8]=i,n[9]=d,n[10]=f):f=n[10];let p;return n[11]!==t||n[12]!==s||n[13]!==a||n[14]!==l||n[15]!==u||n[16]!==f?(p=(0,J.jsx)(LO.button,E(E(E({type:`button`,"aria-pressed":s},l),a),{},{ref:t,disabled:u,onClick:f})),n[11]=t,n[12]=s,n[13]=a,n[14]=l,n[15]=u,n[16]=f,n[17]=p):p=n[17],p});ak.displayName=`ActionBarPrimitive.FeedbackPositive`;function ok(e){var t;return((t=e.message.metadata.submittedFeedback)==null?void 0:t.type)===`positive`}var sk=[`onClick`,`disabled`],ck=()=>{let{submit:e}=Iv();return e},lk=kn((e,t)=>{let n=K(18),r,i,a;if(n[0]!==e){var o=e;({onClick:i,disabled:r}=o),a=W(o,sk),n[0]=e,n[1]=r,n[2]=i,n[3]=a}else r=n[1],i=n[2],a=n[3];let s=q(uk),c=ck(),l;n[4]===s?l=n[5]:(l=s?{"data-submitted":`true`}:{},n[4]=s,n[5]=l);let u=r||!c,d;n[6]===c?d=n[7]:(d=()=>{c==null||c()},n[6]=c,n[7]=d);let f;n[8]!==i||n[9]!==d?(f=Ib(i,d),n[8]=i,n[9]=d,n[10]=f):f=n[10];let p;return n[11]!==t||n[12]!==s||n[13]!==a||n[14]!==l||n[15]!==u||n[16]!==f?(p=(0,J.jsx)(LO.button,E(E(E({type:`button`,"aria-pressed":s},l),a),{},{ref:t,disabled:u,onClick:f})),n[11]=t,n[12]=s,n[13]=a,n[14]=l,n[15]=u,n[16]=f,n[17]=p):p=n[17],p});lk.displayName=`ActionBarPrimitive.FeedbackNegative`;function uk(e){var t;return((t=e.message.metadata.submittedFeedback)==null?void 0:t.type)===`negative`}var dk=[`filename`,`onExport`,`onClick`,`disabled`],fk=e=>{let t=K(6),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{filename:r,onExport:i}=n,a=qa(),o=q(hk),s;return t[2]!==a.message||t[3]!==r||t[4]!==i?(s=w(function*(){let e=a.message.getCopyText();if(!e)return;if(i){yield i(e);return}let t=new Blob([e],{type:`text/markdown`}),n=URL.createObjectURL(t),o=document.createElement(`a`);o.href=n,o.download=r==null?`message-${Date.now()}.md`:r,o.rel=`noopener`,document.body.appendChild(o),o.click(),document.body.removeChild(o),setTimeout(()=>URL.revokeObjectURL(n),4e4)}),t[2]=a.message,t[3]=r,t[4]=i,t[5]=s):s=t[5],o?s:null},pk=kn((e,t)=>{let n=K(19),r,i,a,o,s;if(n[0]!==e){var c=e;({filename:i,onExport:o,onClick:a,disabled:r}=c),s=W(c,dk),n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s}else r=n[1],i=n[2],a=n[3],o=n[4],s=n[5];let l;n[6]!==i||n[7]!==o?(l={filename:i,onExport:o},n[6]=i,n[7]=o,n[8]=l):l=n[8];let u=fk(l),d=r||!u,f;n[9]===u?f=n[10]:(f=()=>{u==null||u().catch(gk)},n[9]=u,n[10]=f);let p;n[11]!==a||n[12]!==f?(p=Ib(a,f),n[11]=a,n[12]=f,n[13]=p):p=n[13];let m;return n[14]!==t||n[15]!==s||n[16]!==d||n[17]!==p?(m=(0,J.jsx)(LO.button,E(E({type:`button`},s),{},{ref:t,disabled:d,onClick:p})),n[14]=t,n[15]=s,n[16]=d,n[17]=p,n[18]=m):m=n[18],m});pk.displayName=`ActionBarPrimitive.ExportMarkdown`;function mk(e){return e.type===`text`&&e.text.length>0}function hk(e){var t;return(e.message.role!==`assistant`||((t=e.message.status)==null?void 0:t.type)!==`running`)&&e.message.parts.some(mk)}function gk(e){console.error(`[assistant-ui] markdown export failed:`,e)}var _k=lO({Copy:()=>JO,Edit:()=>$O,ExportMarkdown:()=>pk,FeedbackNegative:()=>lk,FeedbackPositive:()=>ak,Reload:()=>QO,Root:()=>UO,Speak:()=>ek,StopSpeaking:()=>nk}),vk=yO(),yk=[`__scopeActionBarMore`,`open`,`onOpenChange`],bk=e=>{let t=K(25),n,r,i,a;if(t[0]!==e){var o=e;({__scopeActionBarMore:n,open:i,onOpenChange:r}=o),a=W(o,yk),t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a}else n=t[1],r=t[2],i=t[3],a=t[4];let s=vk(n),c=VO(),l=yn(null),u=i!==void 0,d;t[5]===c?d=t[6]:(d=e=>{var t;if(e){var n;if(l.current)return;l.current=(n=c==null?void 0:c.acquireInteractionLock())==null?null:n}else(t=l.current)==null||t.call(l),l.current=null},t[5]=c,t[6]=d);let f=d,p;t[7]!==u||t[8]!==r||t[9]!==f?(p=e=>{u||f(e),r==null||r(e)},t[7]=u,t[8]=r,t[9]=f,t[10]=p):p=t[10];let m=p,h,g;t[11]!==u||t[12]!==i||t[13]!==f?(h=()=>{u&&f(!!i)},g=[u,i,f],t[11]=u,t[12]=i,t[13]=f,t[14]=h,t[15]=g):(h=t[14],g=t[15]),G(h,g);let _,v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>()=>{var e;(e=l.current)==null||e.call(l),l.current=null},v=[],t[16]=_,t[17]=v):(_=t[16],v=t[17]),G(_,v);let y;t[18]===i?y=t[19]:(y=i===void 0?null:{open:i},t[18]=i,t[19]=y);let b;return t[20]!==m||t[21]!==a||t[22]!==s||t[23]!==y?(b=(0,J.jsx)(CO,E(E(E(E({},s),a),y),{},{onOpenChange:m})),t[20]=m,t[21]=a,t[22]=s,t[23]=y,t[24]=b):b=t[24],b};bk.displayName=`ActionBarMorePrimitive.Root`;var xk=FO(TO),Sk=FO(OO),Ck=FO(kO),wk=FO(AO),Tk=[`__scopeActionBarMore`],Ek=kn((e,t)=>{let n=K(7),r,i;if(n[0]!==e){var a=e;({__scopeActionBarMore:r}=a),i=W(a,Tk),n[0]=e,n[1]=r,n[2]=i}else r=n[1],i=n[2];let o=vk(r),s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,J.jsx)(xk,E(E(E({},o),i),{},{ref:t})),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});Ek.displayName=`ActionBarMorePrimitive.Trigger`;var Dk=[`__scopeActionBarMore`,`portalProps`,`sideOffset`],Ok=kn((e,t)=>{let n=K(14),r,i,a,o;if(n[0]!==e){var s=e;({__scopeActionBarMore:r,portalProps:i,sideOffset:o}=s),a=W(s,Dk),n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o}else r=n[1],i=n[2],a=n[3],o=n[4];let c=o===void 0?4:o,l=vk(r),u;n[5]!==t||n[6]!==a||n[7]!==l||n[8]!==c?(u=(0,J.jsx)(Sk,E(E(E({},l),a),{},{ref:t,sideOffset:c})),n[5]=t,n[6]=a,n[7]=l,n[8]=c,n[9]=u):u=n[9];let d;return n[10]!==i||n[11]!==l||n[12]!==u?(d=(0,J.jsx)(EO,E(E(E({},l),i),{},{children:u})),n[10]=i,n[11]=l,n[12]=u,n[13]=d):d=n[13],d});Ok.displayName=`ActionBarMorePrimitive.Content`;var kk=[`__scopeActionBarMore`],Ak=kn((e,t)=>{let n=K(7),r,i;if(n[0]!==e){var a=e;({__scopeActionBarMore:r}=a),i=W(a,kk),n[0]=e,n[1]=r,n[2]=i}else r=n[1],i=n[2];let o=vk(r),s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,J.jsx)(Ck,E(E(E({},o),i),{},{ref:t})),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});Ak.displayName=`ActionBarMorePrimitive.Item`;var jk=[`__scopeActionBarMore`],Mk=kn((e,t)=>{let n=K(7),r,i;if(n[0]!==e){var a=e;({__scopeActionBarMore:r}=a),i=W(a,jk),n[0]=e,n[1]=r,n[2]=i}else r=n[1],i=n[2];let o=vk(r),s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,J.jsx)(wk,E(E(E({},o),i),{},{ref:t})),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});Mk.displayName=`ActionBarMorePrimitive.Separator`;var Nk=lO({Content:()=>Ok,Item:()=>Ak,Root:()=>bk,Separator:()=>Mk,Trigger:()=>Ek}),Pk=kn((e,t)=>{let n=K(3),r;return n[0]!==e||n[1]!==t?(r=(0,J.jsx)(LO.div,E(E({},e),{},{ref:t})),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});Pk.displayName=`AttachmentPrimitive.Root`;var Fk=kn((e,t)=>{var n;let r=K(4),i=q(Ik),a=(n=e.children)==null?i:n,o;return r[0]!==e||r[1]!==t||r[2]!==a?(o=(0,J.jsx)(LO.div,E(E({},e),{},{ref:t,children:a})),r[0]=e,r[1]=t,r[2]=a,r[3]=o):o=r[3],o});Fk.displayName=`AttachmentPrimitive.unstable_Thumb`;function Ik(e){let t=e.attachment.name,n=t.lastIndexOf(`.`);return n>0&&n<t.length-1?`.${t.slice(n+1)}`:e.attachment.type}var Lk=()=>{let e=K(2),t=q(Rk),n;return e[0]===t?n=e[1]:(n=(0,J.jsx)(J.Fragment,{children:t}),e[0]=t,e[1]=n),n};Lk.displayName=`AttachmentPrimitive.Name`;function Rk(e){return e.attachment.name}var zk=ZO(`AttachmentPrimitive.Remove`,()=>{let e=K(2),t=qa(),n;return e[0]===t.attachment?n=e[1]:(n=()=>{t.attachment.remove()},e[0]=t.attachment,e[1]=n),n}),Bk=lO({Name:()=>Lk,Remove:()=>zk,Root:()=>Pk,unstable_Thumb:()=>Fk}),Vk=ZO(`BranchPickerPrimitive.Next`,()=>{let{disabled:e,next:t}=Hv();return e?null:t}),Hk=ZO(`BranchPickerPrimitive.Previous`,()=>{let{disabled:e,previous:t}=Uv();return e?null:t}),Uk=()=>q(Gk),Wk=()=>{let e=K(2),t=Uk(),n;return e[0]===t?n=e[1]:(n=(0,J.jsx)(J.Fragment,{children:t}),e[0]=t,e[1]=n),n};Wk.displayName=`BranchPickerPrimitive.Count`;function Gk(e){return e.message.branchCount}var Kk=()=>q(Jk),qk=()=>{let e=K(2),t=Kk(),n;return e[0]===t?n=e[1]:(n=(0,J.jsx)(J.Fragment,{children:t}),e[0]=t,e[1]=n),n};qk.displayName=`BranchPickerPrimitive.Number`;function Jk(e){return e.message.branchNumber}var Yk=[`hideWhenSingleBranch`],Xk=kn((e,t)=>{let n=K(11),r,i;if(n[0]!==e){var a=e;({hideWhenSingleBranch:r}=a),i=W(a,Yk),n[0]=e,n[1]=r,n[2]=i}else r=n[1],i=n[2];let o;n[3]===r?o=n[4]:(o=e=>!r||e.message.branchCount>=2,n[3]=r,n[4]=o);let s;n[5]!==t||n[6]!==i?(s=(0,J.jsx)(LO.div,E(E({},i),{},{ref:t})),n[5]=t,n[6]=i,n[7]=s):s=n[7];let c;return n[8]!==o||n[9]!==s?(c=(0,J.jsx)(Sd,{condition:o,children:s}),n[8]=o,n[9]=s,n[10]=c):c=n[10],c});Xk.displayName=`BranchPickerPrimitive.Root`;var Zk=lO({Count:()=>Wk,Next:()=>Vk,Number:()=>qk,Previous:()=>Hk,Root:()=>Xk}),Qk=zn(null),$k=()=>Vn(Qk),eA=e=>{let t=K(8),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=yn(r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=[],t[1]=a):a=t[1];let o=yn(a),s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=Array.from(i.current.entries());e.sort(tA),o.current=e.map(nA)},t[2]=s):s=t[2];let c=s,l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(e,t)=>{var n;let r=(n=t==null?void 0:t.priority)==null?0:n;return i.current.set(e,r),c(),()=>{i.current.delete(e),c()}},t[3]=l):l=t[3];let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>o.current,t[4]=d):d=t[4];let f=d,p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={register:u,getPlugins:f},t[5]=p):p=t[5];let m=p,h;return t[6]===n?h=t[7]:(h=(0,J.jsx)(Qk.Provider,{value:m,children:n}),t[6]=n,t[7]=h),h};function tA(e,t){return t[1]-e[1]}function nA(e){let[t]=e;return t}var rA=zn(null),iA=zn(null),aA=()=>{let e=Vn(rA);if(!e)throw Error(`useTriggerPopoverRootContext must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},oA=()=>Vn(rA),sA=()=>{let e=Vn(iA);if(!e)throw Error(`useTriggerPopoverAriaPublish must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},cA=()=>{let e=aA();return wn(e.subscribe,e.getTriggers,e.getTriggers)},lA=new Map,uA=()=>()=>{},dA=()=>lA,fA=()=>{let e=oA();return wn(e?e.subscribe:uA,e?e.getTriggers:dA,e?e.getTriggers:dA)},pA=()=>null,mA=()=>{let e=oA();return wn(e?e.subscribeAria:uA,e?e.getActiveAria:pA,e?e.getActiveAria:pA)};function hA(){let e=K(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new Set,e[0]=t):t=e[0];let n=yn(t),r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{for(let e of n.current)e()},e[1]=r):r=e[1];let i=r,a;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>(n.current.add(e),()=>{n.current.delete(e)}),e[2]=a):a=e[2];let o=a,s;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s={notify:i,subscribe:o},e[3]=s):s=e[3],s}var gA=e=>{let t=K(21),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=yn(r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=new Set,t[1]=a):a=t[1];let o=yn(a),{notify:s,subscribe:c}=hA(),l;t[2]===s?l=t[3]:(l=e=>{let{char:t}=e;if(i.current.has(t))return process.env.NODE_ENV!==`production`&&console.warn(`[assistant-ui] Duplicate TriggerPopover for char "${t}". Ignoring the second registration.`),vA;if(process.env.NODE_ENV!==`production`)for(let e of i.current.values())(t.startsWith(e.char)||e.char.startsWith(t))&&console.warn(`[assistant-ui] Trigger prefix collision between "${e.char}" and "${t}". One char is a prefix of the other; only one will match reliably.`);let n=new Map(i.current);n.set(t,e),i.current=n,s();for(let t of o.current)t.added(e);return()=>{let e=new Map(i.current);e.delete(t),i.current=e,s();for(let e of o.current)e.removed(t)}},t[2]=s,t[3]=l);let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>i.current,t[4]=d):d=t[4];let f=d,p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>(o.current.add(e),()=>{o.current.delete(e)}),t[5]=p):p=t[5];let m=p,h=yn(null),g=yn(null),{notify:_,subscribe:v}=hA(),y;t[6]===_?y=t[7]:(y=(e,t)=>{if(t===null){if(g.current!==e)return;h.current=null,g.current=null,_();return}let n=h.current;(g.current!==e||n===null||n.popoverId!==t.popoverId||n.highlightedItemId!==t.highlightedItemId)&&(h.current=t,g.current=e,_())},t[6]=_,t[7]=y);let b=y,x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>h.current,t[8]=x):x=t[8];let S=x,C;t[9]!==u||t[10]!==c||t[11]!==v?(C={register:u,getTriggers:f,subscribe:c,subscribeLifecycle:m,getActiveAria:S,subscribeAria:v},t[9]=u,t[10]=c,t[11]=v,t[12]=C):C=t[12];let w=C,T;t[13]===b?T=t[14]:(T={setActiveAria:b},t[13]=b,t[14]=T);let E=T,D;t[15]!==E||t[16]!==n?(D=(0,J.jsx)(iA.Provider,{value:E,children:n}),t[15]=E,t[16]=n,t[17]=D):D=t[17];let O;return t[18]!==D||t[19]!==w?(O=(0,J.jsx)(rA.Provider,{value:w,children:D}),t[18]=D,t[19]=w,t[20]=O):O=t[20],O},_A=e=>{let t=K(4),{children:n}=e;if($k()){let e;return t[0]===n?e=t[1]:(e=(0,J.jsx)(gA,{children:n}),t[0]=n,t[1]=e),e}let r;return t[2]===n?r=t[3]:(r=(0,J.jsx)(eA,{children:(0,J.jsx)(gA,{children:n})}),t[2]=n,t[3]=r),r};_A.displayName=`ComposerPrimitive.TriggerPopoverRoot`;function vA(){}var yA=/\s/u;function bA(e,t,n,r){if(r===null)return null;let{query:i,offset:a,endOffset:o}=r;return a<0||a+t.length>n||!e.startsWith(t,a)||o<a+t.length||o>e.length?null:{query:i,offset:a,endOffset:o}}function xA(e,t,n,r){if(r)return bA(e,t,n,r(e,t,n));let i=e.slice(0,n);for(let e=i.length-1;e>=0;e--){let r=i[e];if(yA.test(r))return null;if(i.startsWith(t,e)){if(e>0&&!yA.test(i[e-1]))continue;return{query:i.slice(e+t.length),offset:e,endOffset:n}}}return null}var SA=Hr(e=>{var t;let n=K(8),{text:r,triggerChar:i,matcher:a}=e,[o,s]=_n(r.length),c=Math.min(o,r.length),l;n[0]!==a||n[1]!==c||n[2]!==r||n[3]!==i?(l=xA(r,i,c,a),n[0]=a,n[1]=c,n[2]=r,n[3]=i,n[4]=l):l=n[4];let u=l,d=(t=u==null?void 0:u.query)==null?``:t,f;return n[5]!==d||n[6]!==u?(f={trigger:u,query:d,setCursorPosition:s},n[5]=d,n[6]=u,n[7]=f):f=n[7],f});function CA(e){return`type`in e}var wA=Hr(e=>{let t=K(22),{navigableList:n,isSearchMode:r,activeCategoryId:i,query:a,popoverId:o,open:s,selectItem:c,selectCategory:l,goBack:u,close:d}=e,[f,p]=_n(0),m;t[0]!==i||t[1]!==r||t[2]!==n?(m={navigableList:n,isSearchMode:r,activeCategoryId:i},t[0]=i,t[1]=r,t[2]=n,t[3]=m):m=t[3];let[h,g]=_n(m);(h.navigableList!==n||h.isSearchMode!==r||h.activeCategoryId!==i)&&(g({navigableList:n,isSearchMode:r,activeCategoryId:i}),p(0));let _;t[4]!==f||t[5]!==n.length?(_=e=>{e<0||e>=n.length||e!==f&&p(e)},t[4]=f,t[5]=n.length,t[6]=_):_=t[6];let v=Cn(_),y;t[7]!==i||t[8]!==d||t[9]!==u||t[10]!==f||t[11]!==n||t[12]!==s||t[13]!==a||t[14]!==l||t[15]!==c?(y=e=>{if(!s)return!1;switch(e.key){case`ArrowDown`:return e.preventDefault(),p(e=>{let t=n.length;return t===0?0:e<t-1?e+1:0}),!0;case`ArrowUp`:return e.preventDefault(),p(e=>{let t=n.length;return t===0?0:e>0?e-1:t-1}),!0;case`Enter`:case`Tab`:{if(e.shiftKey)return!1;e.preventDefault();let t=n[f];return t&&(CA(t)?c(t):l(t.id)),!0}case`Escape`:return e.preventDefault(),d(),!0;case`Backspace`:return i&&a===``?(e.preventDefault(),u(),!0):!1;default:return!1}},t[7]=i,t[8]=d,t[9]=u,t[10]=f,t[11]=n,t[12]=s,t[13]=a,t[14]=l,t[15]=c,t[16]=y):y=t[16];let b=Cn(y),x=n[f],S=s&&x?`${o}-option-${x.id}`:void 0,C;return t[17]!==b||t[18]!==v||t[19]!==f||t[20]!==S?(C={highlightedIndex:f,highlightedItemId:S,highlightIndex:v,handleKeyDown:b},t[17]=b,t[18]=v,t[19]=f,t[20]=S,t[21]=C):C=t[21],C});function TA(e,t){var n,r;return!t||e.id.toLowerCase().includes(t)||e.label.toLowerCase().includes(t)||(n=(r=e.description)==null?void 0:r.toLowerCase().includes(t))!=null&&n}var EA=Hr(e=>{let t=K(35),{adapter:n,query:r,open:i}=e,[a,o]=_n(null),[s,c]=_n(i);s!==i&&(c(i),i||o(null));let l;bb0:{if(!i||!n){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],l=e;break bb0}let e;t[1]===n?e=t[2]:(e=n.categories(),t[1]=n,t[2]=e),l=e}let u=l,d=i?a:null,f;bb1:{if(!d||!n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[3]=e):e=t[3],f=e;break bb1}let e;t[4]!==n||t[5]!==d?(e=n.categoryItems(d),t[4]=n,t[5]=d,t[6]=e):e=t[6],f=e}let p=f,m;bb2:{if(!i||!n||d||!r&&u.length>0){m=null;break bb2}if(n.search){let e;t[7]!==n||t[8]!==r?(e=n.search(r),t[7]=n,t[8]=r,t[9]=e):e=t[9],m=e;break bb2}let e;if(t[10]!==n||t[11]!==u||t[12]!==r){e=[];let i=r.toLowerCase();for(let t of u)for(let r of n.categoryItems(t.id))TA(r,i)&&e.push(r);t[10]=n,t[11]=u,t[12]=r,t[13]=e}else e=t[13];m=e}let h=m,g=h!==null,_;bb3:{if(g){let e;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[14]=e):e=t[14],_=e;break bb3}if(!r){_=u;break bb3}let e;if(t[15]!==u||t[16]!==r){let n=r.toLowerCase();e=u.filter(e=>e.label.toLowerCase().includes(n)),t[15]=u,t[16]=r,t[17]=e}else e=t[17];_=e}let v=_,y;bb4:{if(g){let e;t[18]===h?e=t[19]:(e=h==null?[]:h,t[18]=h,t[19]=e),y=e;break bb4}if(!r){y=p;break bb4}let e;if(t[20]!==p||t[21]!==r){let n=r.toLowerCase();e=p.filter(e=>TA(e,n)),t[20]=p,t[21]=r,t[22]=e}else e=t[22];y=e}let b=y,x;bb5:{if(g){let e;t[23]===h?e=t[24]:(e=h==null?[]:h,t[23]=h,t[24]=e),x=e;break bb5}if(d){x=b;break bb5}x=v}let S=x,C;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{o(e)},t[25]=C):C=t[25];let w=Cn(C),T;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>{o(null)},t[26]=T):T=t[26];let E=Cn(T),D;return t[27]!==d||t[28]!==v||t[29]!==b||t[30]!==E||t[31]!==g||t[32]!==S||t[33]!==w?(D={categories:v,items:b,isSearchMode:g,activeCategoryId:d,navigableList:S,selectCategory:w,goBack:E},t[27]=d,t[28]=v,t[29]=b,t[30]=E,t[31]=g,t[32]=S,t[33]=w,t[34]=D):D=t[34],D}),DA=Hr(e=>{let t=K(15),{behavior:n,trigger:r,aui:i,setCursorPosition:a,onSelected:o}=e,s=yn(null),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>(s.current=e,()=>{s.current===e&&(s.current=null)}),t[0]=c):c=t[0];let l=Cn(c),u;t[1]!==i||t[2]!==n||t[3]!==o||t[4]!==a||t[5]!==r?(u=e=>{var t;if(!r||!n)return;if((t=s.current)!=null&&t.call(s,e,()=>{var t;n.kind===`directive`&&((t=n.onInserted)==null||t.call(n,e))})){o();return}let c=i.composer.getState().text,l=c.slice(0,r.offset),u=c.slice(r.endOffset),d=()=>{let t=n.formatter.serialize(e);i.composer.setText(l+t+(u.startsWith(` `)?u:` ${u}`),{origin:`user`}),a(l.length+t.length+1)};if(n.kind===`directive`){var f;d(),(f=n.onInserted)==null||f.call(n,e)}else n.removeOnExecute?(i.composer.setText(l+(u.startsWith(` `)?u.slice(1):u),{origin:`user`}),a(l.length)):d(),n.onExecute(e);o()},t[1]=i,t[2]=n,t[3]=o,t[4]=a,t[5]=r,t[6]=u):u=t[6];let d=Cn(u),f;t[7]!==o||t[8]!==a||t[9]!==r?(f=()=>{o(),r&&a(r.offset)},t[7]=o,t[8]=a,t[9]=r,t[10]=f):f=t[10];let p=Cn(f),m;return t[11]!==p||t[12]!==l||t[13]!==d?(m={selectItem:d,close:p,registerSelectItemOverride:l},t[11]=p,t[12]=l,t[13]=d,t[14]=m):m=t[14],m}),OA=Hr(e=>{let t=K(47),{adapter:n,text:r,triggerChar:i,matcher:a,behavior:o,aui:s,popoverId:c,isLoading:l}=e,u;t[0]!==a||t[1]!==r||t[2]!==i?(u=SA({text:r,triggerChar:i,matcher:a}),t[0]=a,t[1]=r,t[2]=i,t[3]=u):u=t[3];let d=Gr(u),f=d.trigger!==null&&n!==void 0&&o!==void 0,p;t[4]!==n||t[5]!==d.query||t[6]!==f?(p=EA({adapter:n,query:d.query,open:f}),t[4]=n,t[5]=d.query,t[6]=f,t[7]=p):p=t[7];let m=Gr(p),h;t[8]===m?h=t[9]:(h=()=>{m.goBack()},t[8]=m,t[9]=h);let g=Cn(h),_;t[10]!==s||t[11]!==o||t[12]!==d.setCursorPosition||t[13]!==d.trigger||t[14]!==g||t[15]!==i?(_=DA({behavior:o,trigger:d.trigger,aui:s,triggerChar:i,setCursorPosition:d.setCursorPosition,onSelected:g}),t[10]=s,t[11]=o,t[12]=d.setCursorPosition,t[13]=d.trigger,t[14]=g,t[15]=i,t[16]=_):_=t[16];let v=Gr(_),y;t[17]!==d.query||t[18]!==m.activeCategoryId||t[19]!==m.goBack||t[20]!==m.isSearchMode||t[21]!==m.navigableList||t[22]!==m.selectCategory||t[23]!==f||t[24]!==c||t[25]!==v.close||t[26]!==v.selectItem?(y=wA({navigableList:m.navigableList,isSearchMode:m.isSearchMode,activeCategoryId:m.activeCategoryId,query:d.query,popoverId:c,open:f,selectItem:v.selectItem,selectCategory:m.selectCategory,goBack:m.goBack,close:v.close}),t[17]=d.query,t[18]=m.activeCategoryId,t[19]=m.goBack,t[20]=m.isSearchMode,t[21]=m.navigableList,t[22]=m.selectCategory,t[23]=f,t[24]=c,t[25]=v.close,t[26]=v.selectItem,t[27]=y):y=t[27];let b=Gr(y),x;return t[28]!==d.query||t[29]!==d.setCursorPosition||t[30]!==l||t[31]!==b.handleKeyDown||t[32]!==b.highlightIndex||t[33]!==b.highlightedIndex||t[34]!==b.highlightedItemId||t[35]!==m.activeCategoryId||t[36]!==m.categories||t[37]!==m.goBack||t[38]!==m.isSearchMode||t[39]!==m.items||t[40]!==m.selectCategory||t[41]!==f||t[42]!==c||t[43]!==v.close||t[44]!==v.registerSelectItemOverride||t[45]!==v.selectItem?(x={open:f,query:d.query,activeCategoryId:m.activeCategoryId,categories:m.categories,items:m.items,highlightedIndex:b.highlightedIndex,isSearchMode:m.isSearchMode,isLoading:l,popoverId:c,highlightedItemId:b.highlightedItemId,selectCategory:m.selectCategory,goBack:m.goBack,selectItem:v.selectItem,close:v.close,highlightIndex:b.highlightIndex,handleKeyDown:b.handleKeyDown,setCursorPosition:d.setCursorPosition,registerSelectItemOverride:v.registerSelectItemOverride},t[28]=d.query,t[29]=d.setCursorPosition,t[30]=l,t[31]=b.handleKeyDown,t[32]=b.highlightIndex,t[33]=b.highlightedIndex,t[34]=b.highlightedItemId,t[35]=m.activeCategoryId,t[36]=m.categories,t[37]=m.goBack,t[38]=m.isSearchMode,t[39]=m.items,t[40]=m.selectCategory,t[41]=f,t[42]=c,t[43]=v.close,t[44]=v.registerSelectItemOverride,t[45]=v.selectItem,t[46]=x):x=t[46],x}),kA=[`char`,`matcher`,`adapter`,`isLoading`,`aria-label`,`children`],AA=zn(null),jA=()=>{let e=Vn(AA);if(!e)throw Error(`useTriggerPopoverScopeContext must be used within ComposerPrimitive.TriggerPopover`);return e},MA=()=>Vn(AA),NA=zn(null),PA=()=>{let e=Vn(NA);if(!e)throw Error(`TriggerPopover.Directive / TriggerPopover.Action must be rendered inside ComposerPrimitive.TriggerPopover`);return e},FA=kn((e,t)=>{let n=K(70),r,i,a,o,s,c,l;if(n[0]!==e){var u=e;({char:a,matcher:s,adapter:r,isLoading:l,"aria-label":i,children:o}=u),c=W(u,kA),n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c,n[7]=l}else r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6],l=n[7];let d=l!==void 0&&l,f=qa(),p=q(IA),m=Dn(),h=yn(s),g;n[8]===s?g=n[9]:(g=()=>{h.current=s},n[8]=s,n[9]=g),G(g);let _;n[10]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>(e,t,n)=>h.current(e,t,n),n[10]=_):_=n[10];let[v]=_n(_),y=s!==void 0,b=yn(null),[x,S]=_n(null),C=yn(0),w;n[11]===a?w=n[12]:(w=e=>(C.current+=1,process.env.NODE_ENV!==`production`&&C.current>1&&console.warn(`[assistant-ui] TriggerPopover "${a}" received more than one behavior child. Exactly one <TriggerPopover.Directive> or <TriggerPopover.Action> is allowed per TriggerPopover; the last registration wins.`),b.current=e,S(e),()=>{C.current=Math.max(0,C.current-1),b.current===e&&(b.current=null,S(null))}),n[11]=a,n[12]=w);let T=w,D;n[13]===T?D=n[14]:(D={register:T},n[13]=T,n[14]=D);let O=D,k=x==null?void 0:x,A;n[15]!==r||n[16]!==f||n[17]!==a||n[18]!==d||n[19]!==s||n[20]!==m||n[21]!==k||n[22]!==p?(A=OA({adapter:r,text:p,triggerChar:a,matcher:s,behavior:k,aui:f,popoverId:m,isLoading:d}),n[15]=r,n[16]=f,n[17]=a,n[18]=d,n[19]=s,n[20]=m,n[21]=k,n[22]=p,n[23]=A):A=n[23];let j=Gr(A),M;n[24]===j?M=n[25]:(M=()=>j,n[24]=j,n[25]=M);let N=Cn(M),P=aA(),F;n[26]!==x||n[27]!==a||n[28]!==N||n[29]!==y||n[30]!==v||n[31]!==P?(F=()=>P.register(E(E(E({char:a},y?{matcher:v}:{}),x?{behavior:x}:{}),{},{resource:N()})),n[26]=x,n[27]=a,n[28]=N,n[29]=y,n[30]=v,n[31]=P,n[32]=F):F=n[32];let I;n[33]!==x||n[34]!==a||n[35]!==y||n[36]!==v||n[37]!==P?(I=[P,a,y,v,x],n[33]=x,n[34]=a,n[35]=y,n[36]=v,n[37]=P,n[38]=I):I=n[38],G(F,I);let L=$k(),R;n[39]!==N||n[40]!==L?(R=()=>{if(L)return L.register(N())},n[39]=N,n[40]=L,n[41]=R):R=n[41];let z;n[42]===L?z=n[43]:(z=[L],n[42]=L,n[43]=z),G(R,z);let B=x!==null&&j.open,ee=sA(),V,te;n[44]!==ee||n[45]!==a||n[46]!==B?(V=()=>{if(B)return()=>{ee.setActiveAria(a,null)}},te=[ee,a,B],n[44]=ee,n[45]=a,n[46]=B,n[47]=V,n[48]=te):(V=n[47],te=n[48]),G(V,te);let H,U;n[49]!==ee||n[50]!==a||n[51]!==B||n[52]!==m||n[53]!==j.highlightedItemId?(H=()=>{B&&ee.setActiveAria(a,{popoverId:m,highlightedItemId:j.highlightedItemId})},U=[ee,a,m,B,j.highlightedItemId],n[49]=ee,n[50]=a,n[51]=B,n[52]=m,n[53]=j.highlightedItemId,n[54]=H,n[55]=U):(H=n[54],U=n[55]),G(H,U);let ne;if(n[56]!==i||n[57]!==o||n[58]!==t||n[59]!==B||n[60]!==m||n[61]!==c||n[62]!==j.highlightedItemId){var re;ne=B?(0,J.jsx)(LO.div,E(E({role:`listbox`,id:m,"aria-label":(re=i)==null?`Suggestions`:re,"aria-activedescendant":j.highlightedItemId,"data-state":`open`},c),{},{ref:t,children:o})):o,n[56]=i,n[57]=o,n[58]=t,n[59]=B,n[60]=m,n[61]=c,n[62]=j.highlightedItemId,n[63]=ne}else ne=n[63];let ie;n[64]!==j||n[65]!==ne?(ie=(0,J.jsx)(AA.Provider,{value:j,children:ne}),n[64]=j,n[65]=ne,n[66]=ie):ie=n[66];let ae;return n[67]!==O||n[68]!==ie?(ae=(0,J.jsx)(NA.Provider,{value:O,children:ie}),n[67]=O,n[68]=ie,n[69]=ae):ae=n[69],ae});FA.displayName=`ComposerPrimitive.TriggerPopover`;function IA(e){return e.composer.text}var LA=()=>{let e=K(2),{disabled:t,send:n}=bv(),r;return e[0]===n?r=e[1]:(r=()=>n(),e[0]=n,e[1]=r),t?null:r},RA=ZO(`ComposerPrimitive.Send`,LA),zA=zn(null),BA=()=>Vn(zA),VA=`[contenteditable]:not([contenteditable='false'])`,HA=`textarea:not(:disabled), ${VA}`,UA=[`onSubmit`,`onMouseDown`,`compact`,`inert`],WA=[`a`,`audio[controls]`,`button`,`details`,`embed`,`iframe`,`input`,`label`,`select`,`summary`,`textarea`,`video[controls]`,VA,`[tabindex]`].join(`, `),GA=mn.version.startsWith(`18.`),KA=kn((e,t)=>{let n=K(27),r,i,a,o,s;if(n[0]!==e){var c=e;({onSubmit:o,onMouseDown:a,compact:r,inert:i}=c),s=W(c,UA),n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s}else r=n[1],i=n[2],a=n[3],o=n[4],s=n[5];let l=LA(),u=q(qA),[d,f]=_n(!1),p;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(p={setMultiline:f},n[6]=p):p=n[6];let m=p,h;n[7]===r?h=n[8]:(h=e=>r?e.composer.attachments.length===0&&e.composer.quote==null&&e.composer.queue.length===0&&e.composer.dictation==null&&!e.composer.text.includes(`
60
+ `):!1,n[7]=r,n[8]=h);let g=q(h)&&!d,_=GA&&typeof i==`boolean`?i?``:void 0:i,v;n[9]===l?v=n[10]:(v=e=>{e.preventDefault(),l&&l()},n[9]=l,n[10]=v);let y=v,b=JA,x=r?m:null,S=_,C=g?``:void 0,w;n[11]!==y||n[12]!==o?(w=Ib(o,y),n[11]=y,n[12]=o,n[13]=w):w=n[13];let T;n[14]===a?T=n[15]:(T=Ib(a,b),n[14]=a,n[15]=T);let D;n[16]!==u||n[17]!==t||n[18]!==s||n[19]!==S||n[20]!==C||n[21]!==w||n[22]!==T?(D=(0,J.jsx)(LO.form,E(E({},s),{},{inert:S,"data-aui-composer-type":u,"data-compact":C,ref:t,onSubmit:w,onMouseDown:T})),n[16]=u,n[17]=t,n[18]=s,n[19]=S,n[20]=C,n[21]=w,n[22]=T,n[23]=D):D=n[23];let O;return n[24]!==x||n[25]!==D?(O=(0,J.jsx)(zA.Provider,{value:x,children:D}),n[24]=x,n[25]=D,n[26]=O):O=n[26],O});KA.displayName=`ComposerPrimitive.Root`;function qA(e){return e.composer.type}function JA(e){if(e.button!==0)return;let t=e.target;if(!(t instanceof Element)||!e.currentTarget.contains(t))return;let n=t.closest(WA);if(n&&e.currentTarget.contains(n))return;let r=e.currentTarget.querySelector(HA);r&&(e.preventDefault(),r.focus())}var YA=e=>{let t=K(4),n=Wb(e),r=iy(XA),i,a;t[0]!==n||t[1]!==r?(i=()=>r(n),a=[r,n],t[0]=n,t[1]=r,t[2]=i,t[3]=a):(i=t[2],a=t[3]),G(i,a)};function XA(e){return e.onScrollToBottom}var ZA=()=>!1,QA=()=>{},$A=e=>{let t=K(4),n;t[0]===e?n=t[1]:(n=t=>{if(typeof window>`u`||e===null||!window.matchMedia)return QA;let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},t[0]=e,t[1]=n);let r=n,i;return t[2]===e?i=t[3]:(i=()=>typeof window>`u`||e===null||!window.matchMedia?!1:window.matchMedia(e).matches,t[2]=e,t[3]=i),wn(r,i,ZA)},ej=e=>e.isComposing||e.keyCode===229,tj=zn(void 0),nj=()=>Vn(tj),rj=`[data-aui-composer-type]`,ij=`[data-aui-thread-root]`,aj=e=>{let t=K(4),n=qa(),r=nj(),i;return t[0]!==n.composer||t[1]!==e||t[2]!==r?(i=t=>{let i=r==null?void 0:r.current,a=t==null?void 0:t.ownerDocument,o=a==null?void 0:a.activeElement,s=t==null?void 0:t.closest(rj),c=n.composer.getState().type===`edit`&&i&&o&&(s==null?void 0:s.getAttribute(`data-aui-composer-type`))===`edit`&&s.contains(o)&&s.closest(ij)===i,l=c?Array.from(i.querySelectorAll(HA)).filter(e=>{var t;return e.closest(ij)===i&&((t=e.closest(rj))==null?void 0:t.getAttribute(`data-aui-composer-type`))===`thread`}):[];if(e(),a&&o&&c&&(a.activeElement===o||a.activeElement===a.body)){for(let e of l)if(e.isConnected&&!e.closest(`[hidden], [inert]`)&&(e.focus({preventScroll:!0}),a.activeElement!==o&&a.activeElement!==a.body))break}},t[0]=n.composer,t[1]=e,t[2]=r,t[3]=i):i=t[3],i};function oj(){return q(sj)}function sj(e){return e.composer.isEditing?e.composer.text:``}function cj(e){return!!q(lj)||!!e}function lj(e){var t;return e.thread.isDisabled||((t=e.composer.dictation)==null?void 0:t.inputDisabled)}function uj(){let e=K(4),t=mA();if(!t){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={},e[0]=t):t=e[0],t}let n;return e[1]!==t.highlightedItemId||e[2]!==t.popoverId?(n={"aria-controls":t.popoverId,"aria-expanded":!0,"aria-haspopup":`listbox`,"aria-activedescendant":t.highlightedItemId},e[1]=t.highlightedItemId,e[2]=t.popoverId,e[3]=n):n=e[3],n}function dj(){return dj=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},dj.apply(null,arguments)}function fj(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var pj=t.useLayoutEffect,mj=function(e){var n=t.default.useRef(e);return pj(function(){n.current=e}),n},hj=function(e,t){typeof e==`function`?e(t):e.current=t},gj=function(e,n){var r=t.default.useRef();return t.default.useCallback(function(t){e.current=t,r.current&&hj(r.current,null),r.current=n,n&&hj(n,t)},[n])},_j={"min-height":`0`,"max-height":`none`,height:`0`,visibility:`hidden`,overflow:`hidden`,position:`absolute`,"z-index":`-1000`,top:`0`,right:`0`,display:`block`},vj=function(e){Object.keys(_j).forEach(function(t){e.style.setProperty(t,_j[t],`important`)})},yj=null,bj=function(e,t){var n=e.scrollHeight;return t.sizingStyle.boxSizing===`border-box`?n+t.borderSize:n-t.paddingSize};function xj(e,t,n,r){n===void 0&&(n=1),r===void 0&&(r=1/0),yj||(yj=document.createElement(`textarea`),yj.setAttribute(`tabindex`,`-1`),yj.setAttribute(`aria-hidden`,`true`),vj(yj)),yj.parentNode===null&&document.body.appendChild(yj);var i=e.paddingSize,a=e.borderSize,o=e.sizingStyle,s=o.boxSizing;Object.keys(o).forEach(function(e){var t=e;yj.style[t]=o[t]}),vj(yj),yj.value=t;var c=bj(yj,e);yj.value=t,c=bj(yj,e),yj.value=`x`;var l=yj.scrollHeight-i,u=l*n;s===`border-box`&&(u=u+i+a),c=Math.max(u,c);var d=l*r;return s===`border-box`&&(d=d+i+a),c=Math.min(d,c),[c,l]}var Sj=function(){},Cj=function(e,t){return e.reduce(function(e,n){return e[n]=t[n],e},{})},wj=[`borderBottomWidth`,`borderLeftWidth`,`borderRightWidth`,`borderTopWidth`,`boxSizing`,`fontFamily`,`fontSize`,`fontStyle`,`fontWeight`,`letterSpacing`,`lineHeight`,`paddingBottom`,`paddingLeft`,`paddingRight`,`paddingTop`,`tabSize`,`textIndent`,`textRendering`,`textTransform`,`width`,`wordBreak`,`wordSpacing`,`scrollbarGutter`],Tj=!!document.documentElement.currentStyle,Ej=function(e){var t=window.getComputedStyle(e);if(t===null)return null;var n=Cj(wj,t),r=n.boxSizing;return r===``?null:(Tj&&r===`border-box`&&(n.width=parseFloat(n.width)+parseFloat(n.borderRightWidth)+parseFloat(n.borderLeftWidth)+parseFloat(n.paddingRight)+parseFloat(n.paddingLeft)+`px`),{sizingStyle:n,paddingSize:parseFloat(n.paddingBottom)+parseFloat(n.paddingTop),borderSize:parseFloat(n.borderBottomWidth)+parseFloat(n.borderTopWidth)})};function Dj(e,n,r){var i=mj(r);t.useLayoutEffect(function(){var t=function(e){return i.current(e)};if(e)return e.addEventListener(n,t),function(){return e.removeEventListener(n,t)}},[])}var Oj=function(e,t){Dj(document.body,`reset`,function(n){e.current.form===n.target&&t(n)})},kj=function(e){Dj(window,`resize`,e)},Aj=function(e){Dj(document.fonts,`loadingdone`,e)},jj=[`cacheMeasurements`,`maxRows`,`minRows`,`onChange`,`onHeightChange`],Mj=t.forwardRef(function(e,n){var r=e.cacheMeasurements,i=e.maxRows,a=e.minRows,o=e.onChange,s=o===void 0?Sj:o,c=e.onHeightChange,l=c===void 0?Sj:c,u=fj(e,jj),d=u.value!==void 0,f=t.useRef(null),p=gj(f,n),m=t.useRef(0),h=t.useRef(),g=function(){var e=f.current,t=r&&h.current?h.current:Ej(e);if(t){h.current=t;var n=xj(t,e.value||e.placeholder||`x`,a,i),o=n[0],s=n[1];m.current!==o&&(m.current=o,e.style.setProperty(`height`,o+`px`,`important`),l(o,{rowHeight:s}))}};return t.useLayoutEffect(g),Oj(f,function(){if(!d){var e=f.current.value;requestAnimationFrame(function(){var t=f.current;t&&e!==t.value&&g()})}}),kj(g),Aj(g),t.createElement(`textarea`,dj({},u,{onChange:function(e){d||g(),s(e)},ref:p}))}),Nj=[`autoFocus`,`asChild`,`render`,`disabled`,`onChange`,`onKeyDown`,`onPaste`,`onSelect`,`submitOnEnter`,`submitMode`,`cancelOnEscape`,`unstable_focusOnRunStart`,`unstable_focusOnScrollToBottom`,`unstable_focusOnThreadSwitched`,`unstable_insertNewlineOnTouchEnter`,`addAttachmentOnPaste`,`onHeightChange`],Pj=`(pointer: coarse) and (not (any-pointer: fine))`,Fj=kn((e,t)=>{let{autoFocus:n=!1,asChild:r,render:i,disabled:a,onChange:o,onKeyDown:s,onPaste:c,onSelect:l,submitOnEnter:u,submitMode:d,cancelOnEscape:f=!0,unstable_focusOnRunStart:p=!0,unstable_focusOnScrollToBottom:m=!0,unstable_focusOnThreadSwitched:h=!0,unstable_insertNewlineOnTouchEnter:g=!1,addAttachmentOnPaste:_=!0,onHeightChange:v}=e,y=W(e,Nj),b=qa(),x=nj(),S=$k(),C=BA(),T=d==null?u===!1?`none`:`enter`:d,D=$A(g?Pj:null),O=g&&D&&T===`enter`?`none`:T,k=oj(),A=cj(a),j=yn(null),M=aj(xn(()=>b.composer.cancel(),[b])),N=Py(t,j),P=yn(!1);oO(e=>{var t;if((t=j.current)!=null&&t.contains(e.target)&&!ej(e)){if(S){for(let t of S.getPlugins())if(t.handleKeyDown(e))return}f&&b.composer.getState().canCancel&&(M(j.current),e.preventDefault())}});let F=e=>{if(!A&&!ej(e.nativeEvent)){if(S){for(let t of S.getPlugins())if(t.handleKeyDown(e))return}if(e.key===`Enter`){let n=b.thread.getState(),r=n.capabilities.queue;if(e.shiftKey&&(e.ctrlKey||e.metaKey)&&r&&T!==`none`&&b.composer.getState().canSend){e.preventDefault(),b.composer.send({steer:!0});return}if(e.shiftKey||n.isRunning&&!r&&n.voice===void 0)return;let i=!1;if(O===`ctrlEnter`?i=e.ctrlKey||e.metaKey:O===`enter`&&(i=!0),i){var t;e.preventDefault(),(t=j.current)==null||(t=t.closest(`form`))==null||t.requestSubmit()}}}},I=function(){var e=w(function*(e){var t;if(!_)return;let n=b.thread.getState().capabilities,r=Array.from(((t=e.clipboardData)==null?void 0:t.files)||[]);n.attachments&&r.length>0&&(e.preventDefault(),yield Promise.all(r.map(function(){var e=w(function*(e){try{yield b.composer.addAttachment(e)}catch(e){}});return function(t){return e.apply(this,arguments)}}())))});return function(t){return e.apply(this,arguments)}}(),L=(e,t)=>{if(v==null||v(e,t),!C)return;let n=j.current;if(!n||n.value===``)return;let r=getComputedStyle(n),i=r.boxSizing===`border-box`?e-parseFloat(r.paddingTop)-parseFloat(r.paddingBottom)-parseFloat(r.borderTopWidth)-parseFloat(r.borderBottomWidth):e;Math.round(i/t.rowHeight)>1&&C.setMultiline(!0)},R=n&&!A,z=xn(()=>{let e=j.current;e&&R&&(e.focus({preventScroll:!0}),e.setSelectionRange(e.value.length,e.value.length))},[R]),B=xn(()=>{let e=j.current;if(!e)return;let t=e.ownerDocument,n=t.activeElement;if(n===e)return;let r=x==null?void 0:x.current,i=e.closest(`[data-aui-composer-type]`);(!n||n===t.body||i!=null&&i.contains(n)||r!=null&&r.contains(n)&&n.closest(`[data-aui-thread-root]`)===r)&&z()},[z,x]);G(()=>z(),[z]),YA(()=>{b.composer.getState().type===`thread`&&m&&z()}),G(()=>{if(b.composer.getState().type===`thread`&&p)return b.on(`thread.runStart`,B)},[p,B,b]),G(()=>{if(b.composer.getState().type===`thread`&&h&&b.optional.threads)return b.on(`threads.selectionChanged`,z)},[h,z,b]),G(()=>{k===``&&(C==null||C.setMultiline(!1))},[k,C]);let ee=uj(),V=E(E(E({name:`input`,value:k},y),ee),{},{ref:N,disabled:A,onChange:Ib(o,e=>{var t;if(!b.composer.getState().isEditing)return;let n=e.nativeEvent.isComposing===!0;P.current&&!n&&(P.current=!1);let r=n||P.current;if(ir(()=>{b.composer.setText(e.target.value,{origin:`user`})}),r)return;let i=(t=e.target.selectionStart)==null?e.target.value.length:t;if(S)for(let e of S.getPlugins())e.setCursorPosition(i)}),onKeyDown:Ib(s,F),onCompositionStart:Ib(y.onCompositionStart,()=>{P.current=!0}),onCompositionEnd:Ib(y.onCompositionEnd,e=>{var t;if(P.current=!1,!b.composer.getState().isEditing)return;let n=e.target;ir(()=>{b.composer.setText(n.value,{origin:`user`})});let r=(t=n.selectionStart)==null?n.value.length:t;if(S)for(let e of S.getPlugins())e.setCursorPosition(r)}),onSelect:Ib(l,e=>{var t;if(P.current)return;let n=e.target,r=(t=n.selectionStart)==null?n.value.length:t;if(S)for(let e of S.getPlugins())e.setCursorPosition(r)}),onPaste:Ib(c,I)},C?{onHeightChange:L}:v===void 0?{}:{onHeightChange:v});if(i&&Pn(i))return PO(i,y.children,V);let te=r?zy:Mj;return(0,J.jsx)(te,E({},V))});Fj.displayName=`ComposerPrimitive.Input`;var Ij=ZO(`ComposerPrimitive.Resume`,()=>{let e=K(2),{disabled:t,resume:n}=xv(),r;return e[0]===n?r=e[1]:(r=()=>n(),e[0]=n,e[1]=r),t?null:r}),Lj=ZO(`ComposerPrimitive.Cancel`,()=>{let e=K(2),{disabled:t,cancel:n}=Sv(),r=aj(n);if(t)return null;let i;return e[0]===r?i=e[1]:(i=e=>r(e.detail===0?e.currentTarget:null),e[0]=r,e[1]=i),i}),Rj=ZO(`ComposerPrimitive.AddAttachment`,e=>{let t=K(10),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{multiple:r}=n,i=r===void 0||r,{disabled:a,addAttachment:o}=Tv(),s=qa(),c=yn(0),l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>()=>{c.current+=1},t[2]=l):l=t[2];let u;t[3]!==s.composer||t[4]!==s.optional.threadListItem?(u=[s.composer,s.optional.threadListItem],t[3]=s.composer,t[4]=s.optional.threadListItem,t[5]=u):u=t[5],En(l,u);let d;return t[6]!==o||t[7]!==s.composer||t[8]!==i?(d=()=>{let e=c.current,t=document.createElement(`input`);t.type=`file`,t.multiple=i,t.hidden=!0;let n=s.composer.getState().attachmentAccept;n!==`*`&&(t.accept=n),document.body.appendChild(t),t.onchange=function(){var n=w(function*(n){let r=n.target.files;if(!r)return;let i=Array.from(r,function(){var t=w(function*(t){try{if(c.current!==e)return;yield o(t)}catch(e){}});return function(e){return t.apply(this,arguments)}}());document.body.removeChild(t),yield Promise.all(i)});return function(e){return n.apply(this,arguments)}}(),t.oncancel=()=>{t.files&&t.files.length!==0||document.body.removeChild(t)},t.click()},t[6]=o,t[7]=s.composer,t[8]=i,t[9]=d):d=t[9],a?null:d},[`multiple`]),zj=[`disabled`,`asChild`,`render`,`children`],Bj=kn((e,t)=>{let{disabled:n,asChild:r=!1,render:i,children:a}=e,o=W(e,zj),[s,c]=_n(!1),l=qa(),u=q(e=>e.thread.isDisabled),d=n||u;G(()=>{d&&c(!1)},[d]);let f=xn(e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),d||!l.thread.getState().capabilities.attachments?e.dataTransfer.dropEffect=`none`:c(!0))},[d,l]),p=xn(e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),d||!l.thread.getState().capabilities.attachments?e.dataTransfer.dropEffect=`none`:s||c(!0))},[d,s,l]),m=xn(e=>{if(d)return;e.preventDefault();let t=e.relatedTarget;t&&e.currentTarget.contains(t)||c(!1)},[d]),h=xn(function(){var e=w(function*(e){if(c(!1),!e.dataTransfer.types.includes(`Files`)||(e.preventDefault(),d))return;let t=Array.from(e.dataTransfer.files);l.thread.getState().capabilities.attachments&&t.length!==0&&(yield Promise.all(t.map(function(){var e=w(function*(e){try{yield l.composer.addAttachment(e)}catch(e){}});return function(t){return e.apply(this,arguments)}}())))});return function(t){return e.apply(this,arguments)}}(),[d,l]),g=E(E(E({},s&&!d?{"data-dragging":`true`}:null),o),{},{onDragEnterCapture:Ib(o.onDragEnterCapture,f),onDragOverCapture:Ib(o.onDragOverCapture,p),onDragLeaveCapture:Ib(o.onDragLeaveCapture,m),onDropCapture:Ib(o.onDropCapture,h),ref:t});if(i&&Pn(i))return PO(i,a,g);let _=r?zy:`div`;return(0,J.jsx)(_,E(E({},g),{},{children:a}))});Bj.displayName=`ComposerPrimitive.AttachmentDropzone`;var Vj=ZO(`ComposerPrimitive.Dictate`,()=>{let{disabled:e,startDictation:t}=Cv();return e?null:t}),Hj=ZO(`ComposerPrimitive.StopDictation`,()=>{let e=K(2),t=qa(),n=q(Uj),r;return e[0]===t.composer?r=e[1]:(r=()=>{t.composer.stopDictation()},e[0]=t.composer,e[1]=r),n?r:null});function Uj(e){return e.composer.dictation!=null}var Wj=[`children`],Gj=kn((e,t)=>{var n;let r=K(7),i,a;if(r[0]!==e){var o=e;({children:i}=o),a=W(o,Wj),r[0]=e,r[1]=i,r[2]=a}else i=r[1],a=r[2];let s=q(Kj);if(!s)return null;let c=(n=i)==null?s:n,l;return r[3]!==t||r[4]!==a||r[5]!==c?(l=(0,J.jsx)(LO.span,E(E({},a),{},{ref:t,children:c})),r[3]=t,r[4]=a,r[5]=c,r[6]=l):l=r[6],l});Gj.displayName=`ComposerPrimitive.DictationTranscript`;function Kj(e){var t;return(t=e.composer.dictation)==null?void 0:t.transcript}var qj=[`children`],Jj=[`onClick`],Yj=kn((e,t)=>{let n=K(3);if(!q(Qj))return null;let r;return n[0]!==t||n[1]!==e?(r=(0,J.jsx)(LO.div,E(E({},e),{},{ref:t})),n[0]=t,n[1]=e,n[2]=r):r=n[2],r});Yj.displayName=`ComposerPrimitive.Quote`;var Xj=kn((e,t)=>{var n;let r=K(7),i,a;if(r[0]!==e){var o=e;({children:i}=o),a=W(o,qj),r[0]=e,r[1]=i,r[2]=a}else i=r[1],a=r[2];let s=q($j);if(!s)return null;let c=(n=i)==null?s:n,l;return r[3]!==t||r[4]!==a||r[5]!==c?(l=(0,J.jsx)(LO.span,E(E({},a),{},{ref:t,children:c})),r[3]=t,r[4]=a,r[5]=c,r[6]=l):l=r[6],l});Xj.displayName=`ComposerPrimitive.QuoteText`;var Zj=kn((e,t)=>{let n=K(12),r,i;if(n[0]!==e){var a=e;({onClick:r}=a),i=W(a,Jj),n[0]=e,n[1]=r,n[2]=i}else r=n[1],i=n[2];let o=qa(),s;n[3]===o?s=n[4]:(s=()=>{o.composer.setQuote(void 0)},n[3]=o,n[4]=s);let c=s,l;n[5]!==c||n[6]!==r?(l=Ib(r,c),n[5]=c,n[6]=r,n[7]=l):l=n[7];let u;return n[8]!==t||n[9]!==i||n[10]!==l?(u=(0,J.jsx)(LO.button,E(E({type:`button`},i),{},{ref:t,onClick:l})),n[8]=t,n[9]=i,n[10]=l,n[11]=u):u=n[11],u});Zj.displayName=`ComposerPrimitive.QuoteDismiss`;function Qj(e){return e.composer.quote}function $j(e){var t;return(t=e.composer.quote)==null?void 0:t.text}var eM=[`children`,`aria-label`],tM=[`categoryId`,`onClick`,`onMouseMove`],nM=kn((e,t)=>{var n;let r=K(12),i,a,o;if(r[0]!==e){var s=e;({children:a,"aria-label":i}=s),o=W(s,eM),r[0]=e,r[1]=i,r[2]=a,r[3]=o}else i=r[1],a=r[2],o=r[3];let{categories:c,activeCategoryId:l,isSearchMode:u,open:d}=jA();if(!d||l||u)return null;let f=(n=i)==null?`Categories`:n,p;r[4]!==c||r[5]!==a?(p=a(c),r[4]=c,r[5]=a,r[6]=p):p=r[6];let m;return r[7]!==t||r[8]!==o||r[9]!==f||r[10]!==p?(m=(0,J.jsx)(LO.div,E(E({role:`group`,"aria-label":f},o),{},{ref:t,children:p})),r[7]=t,r[8]=o,r[9]=f,r[10]=p,r[11]=m):m=r[11],m});nM.displayName=`ComposerPrimitive.TriggerPopoverCategories`;var rM=kn((e,t)=>{let n=K(30),r,i,a,o;if(n[0]!==e){var s=e;({categoryId:r,onClick:i,onMouseMove:a}=s),o=W(s,tM),n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o}else r=n[1],i=n[2],a=n[3],o=n[4];let{selectCategory:c,highlightIndex:l,categories:u,highlightedIndex:d,activeCategoryId:f,isSearchMode:p,popoverId:m}=jA(),h;n[5]!==r||n[6]!==c?(h=()=>{c(r)},n[5]=r,n[6]=c,n[7]=h):h=n[7];let g=h,_;if(n[8]!==u||n[9]!==r){let e;n[11]===r?e=n[12]:(e=e=>e.id===r,n[11]=r,n[12]=e),_=u.findIndex(e),n[8]=u,n[9]=r,n[10]=_}else _=n[10];let v=_,y=!f&&!p&&v===d,b;n[13]!==v||n[14]!==l?(b=()=>{l(v)},n[13]=v,n[14]=l,n[15]=b):b=n[15];let x=b,S=`${m}-option-${r}`,C=y?``:void 0,w;n[16]!==g||n[17]!==i?(w=Ib(i,g),n[16]=g,n[17]=i,n[18]=w):w=n[18];let T;n[19]!==x||n[20]!==a?(T=Ib(a,x),n[19]=x,n[20]=a,n[21]=T):T=n[21];let D;return n[22]!==t||n[23]!==y||n[24]!==o||n[25]!==S||n[26]!==C||n[27]!==w||n[28]!==T?(D=(0,J.jsx)(LO.button,E(E({type:`button`,role:`option`,id:S,"aria-selected":y,"data-highlighted":C},o),{},{ref:t,onClick:w,onMouseMove:T})),n[22]=t,n[23]=y,n[24]=o,n[25]=S,n[26]=C,n[27]=w,n[28]=T,n[29]=D):D=n[29],D});rM.displayName=`ComposerPrimitive.TriggerPopoverCategoryItem`;var iM=[`children`,`aria-label`],aM=[`item`,`index`,`onClick`,`onMouseMove`],oM=kn((e,t)=>{var n;let r=K(12),i,a,o;if(r[0]!==e){var s=e;({children:a,"aria-label":i}=s),o=W(s,iM),r[0]=e,r[1]=i,r[2]=a,r[3]=o}else i=r[1],a=r[2],o=r[3];let{items:c,activeCategoryId:l,isSearchMode:u,open:d}=jA();if(!d||!l&&!u)return null;let f=(n=i)==null?`Items`:n,p;r[4]!==a||r[5]!==c?(p=a(c),r[4]=a,r[5]=c,r[6]=p):p=r[6];let m;return r[7]!==t||r[8]!==o||r[9]!==f||r[10]!==p?(m=(0,J.jsx)(LO.div,E(E({role:`group`,"aria-label":f},o),{},{ref:t,children:p})),r[7]=t,r[8]=o,r[9]=f,r[10]=p,r[11]=m):m=r[11],m});oM.displayName=`ComposerPrimitive.TriggerPopoverItems`;var sM=kn((e,t)=>{let n=K(30),r,i,a,o,s;if(n[0]!==e){var c=e;({item:i,index:r,onClick:a,onMouseMove:o}=c),s=W(c,aM),n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s}else r=n[1],i=n[2],a=n[3],o=n[4],s=n[5];let{selectItem:l,highlightIndex:u,items:d,highlightedIndex:f,activeCategoryId:p,isSearchMode:m,popoverId:h}=jA(),g;n[6]!==i||n[7]!==l?(g=()=>{l(i)},n[6]=i,n[7]=l,n[8]=g):g=n[8];let _=g,v;if(n[9]!==r||n[10]!==i.id||n[11]!==d){var y;v=(y=r)==null?d.findIndex(e=>e.id===i.id):y,n[9]=r,n[10]=i.id,n[11]=d,n[12]=v}else v=n[12];let b=v,x=(m||p!==null)&&b===f,S;n[13]!==u||n[14]!==b?(S=()=>{u(b)},n[13]=u,n[14]=b,n[15]=S):S=n[15];let C=S,w=`${h}-option-${i.id}`,T=x?``:void 0,D;n[16]!==_||n[17]!==a?(D=Ib(a,_),n[16]=_,n[17]=a,n[18]=D):D=n[18];let O;n[19]!==C||n[20]!==o?(O=Ib(o,C),n[19]=C,n[20]=o,n[21]=O):O=n[21];let k;return n[22]!==t||n[23]!==x||n[24]!==s||n[25]!==w||n[26]!==T||n[27]!==D||n[28]!==O?(k=(0,J.jsx)(LO.button,E(E({type:`button`,role:`option`,id:w,"aria-selected":x,"data-highlighted":T},s),{},{ref:t,onClick:D,onMouseMove:O})),n[22]=t,n[23]=x,n[24]=s,n[25]=w,n[26]=T,n[27]=D,n[28]=O,n[29]=k):k=n[29],k});sM.displayName=`ComposerPrimitive.TriggerPopoverItem`;var cM=[`onClick`],lM=kn((e,t)=>{let n=K(10),r,i;if(n[0]!==e){var a=e;({onClick:r}=a),i=W(a,cM),n[0]=e,n[1]=r,n[2]=i}else r=n[1],i=n[2];let{activeCategoryId:o,isSearchMode:s,goBack:c,open:l}=jA();if(!l||!o||s)return null;let u;n[3]!==c||n[4]!==r?(u=Ib(r,c),n[3]=c,n[4]=r,n[5]=u):u=n[5];let d;return n[6]!==t||n[7]!==i||n[8]!==u?(d=(0,J.jsx)(LO.button,E(E({type:`button`},i),{},{ref:t,onClick:u})),n[6]=t,n[7]=i,n[8]=u,n[9]=d):d=n[9],d});lM.displayName=`ComposerPrimitive.TriggerPopoverBack`;var uM=e=>{let t=K(8),{formatter:n,onExecute:r,removeOnExecute:i}=e,{register:a}=PA(),o=yn(r),s,c;t[0]===r?(s=t[1],c=t[2]):(s=()=>{o.current=r},c=[r],t[0]=r,t[1]=s,t[2]=c),En(s,c);let l,u;return t[3]!==n||t[4]!==a||t[5]!==i?(l=()=>{let e=E({kind:`action`,formatter:n==null?I:n,onExecute:e=>o.current(e)},i===void 0?{}:{removeOnExecute:i});return a(e)},u=[a,n,i],t[3]=n,t[4]=a,t[5]=i,t[6]=l,t[7]=u):(l=t[6],u=t[7]),G(l,u),null};uM.displayName=`ComposerPrimitive.TriggerPopoverAction`;var dM=e=>{let t=K(7),{formatter:n,onInserted:r}=e,{register:i}=PA(),a=yn(r),o,s;t[0]===r?(o=t[1],s=t[2]):(o=()=>{a.current=r},s=[r],t[0]=r,t[1]=o,t[2]=s),En(o,s);let c,l;return t[3]!==n||t[4]!==i?(c=()=>i({kind:`directive`,formatter:n==null?I:n,onInserted:e=>{var t;return(t=a.current)==null?void 0:t.call(a,e)}}),l=[i,n],t[3]=n,t[4]=i,t[5]=c,t[6]=l):(c=t[5],l=t[6]),G(c,l),null};dM.displayName=`ComposerPrimitive.TriggerPopoverDirective`;var fM=Object.assign(FA,{Directive:dM,Action:uM}),pM=lO({AddAttachment:()=>Rj,AttachmentByIndex:()=>R_,AttachmentDropzone:()=>Bj,Attachments:()=>B_,Cancel:()=>Lj,Dictate:()=>Vj,DictationTranscript:()=>Gj,If:()=>iv,Input:()=>Fj,Queue:()=>H_,Quote:()=>Yj,QuoteDismiss:()=>Zj,QuoteText:()=>Xj,Resume:()=>Ij,Root:()=>KA,Send:()=>RA,StopDictation:()=>Hj,TriggerPopover:()=>fM,TriggerPopoverBack:()=>lM,TriggerPopoverCategories:()=>nM,TriggerPopoverCategoryItem:()=>rM,TriggerPopoverItem:()=>sM,TriggerPopoverItems:()=>oM,TriggerPopoverRoot:()=>_A,Unstable_TriggerPopover:()=>fM,Unstable_TriggerPopoverBack:()=>lM,Unstable_TriggerPopoverCategories:()=>nM,Unstable_TriggerPopoverCategoryItem:()=>rM,Unstable_TriggerPopoverItem:()=>sM,Unstable_TriggerPopoverItems:()=>oM,Unstable_TriggerPopoverRoot:()=>_A,unstable_useTriggerPopoverRootContext:()=>aA,unstable_useTriggerPopoverRootContextOptional:()=>oA,unstable_useTriggerPopoverScopeContext:()=>jA,unstable_useTriggerPopoverScopeContextOptional:()=>MA,unstable_useTriggerPopoverTriggers:()=>cA,unstable_useTriggerPopoverTriggersOptional:()=>fA}),mM=Object.freeze({type:`complete`}),hM=Object.freeze({type:`text`,text:``,status:mM}),gM=()=>q(_M);function _M(e){return e.part.type!==`text`&&e.part.type!==`reasoning`?hM:e.part}var vM=zn(null),yM=e=>({useSmoothStatus:gy(()=>e)}),bM=e=>{let t=K(6),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={optional:!0},t[0]=r):r=t[0];let i=SM(r),a=qa(),o;t[1]===a.part?o=t[2]:(o=()=>yM(a.part.getState().status),t[1]=a.part,t[2]=o);let[s]=_n(o);if(i)return n;let c;return t[3]!==n||t[4]!==s?(c=(0,J.jsx)(vM.Provider,{value:s,children:n}),t[3]=n,t[4]=s,t[5]=c):c=t[5],c},xM=e=>{let t=kn((t,n)=>{let r=K(3),i=t,a;return r[0]!==n||r[1]!==i?(a=(0,J.jsx)(bM,{children:(0,J.jsx)(e,E(E({},i),{},{ref:n}))}),r[0]=n,r[1]=i,r[2]=a):a=r[2],a});return t.displayName=e.displayName,t};function SM(e){let t=Vn(vM);if(!(e!=null&&e.optional)&&!t)throw Error(`This component must be used within a SmoothContextProvider.`);return t}var{useSmoothStatus:CM,useSmoothStatusStore:wM}=ny(SM,`useSmoothStatus`),TM=250,EM=5,DM=class{constructor(e,t){S(this,`animationFrameId`,null),S(this,`lastUpdateTime`,0),S(this,`lastCommitTime`,-1/0),S(this,`targetText`,``),S(this,`drainMs`,TM),S(this,`maxCharIntervalMs`,EM),S(this,`maxCharsPerFrame`,1/0),S(this,`minCommitMs`,0),S(this,`currentText`,void 0),S(this,`setText`,void 0),S(this,`animate`,()=>{let e=performance.now(),t=e-this.lastUpdateTime,n=this.targetText.length-this.currentText.length,r=Math.min(this.maxCharIntervalMs,this.drainMs/n),i=Math.min(n,this.maxCharsPerFrame),a=0;for(;t>=r&&a<i;)a++,t-=r;a===i&&i===this.maxCharsPerFrame&&(t=0),this.animationFrameId=a===n?null:requestAnimationFrame(this.animate),a!==0&&(this.currentText=this.targetText.slice(0,this.currentText.length+a),this.lastUpdateTime=e-t,(a===n||e-this.lastCommitTime>=this.minCommitMs)&&(this.lastCommitTime=e,this.setText(this.currentText)))}),this.currentText=e,this.setText=t}start(){this.animationFrameId===null&&(this.lastUpdateTime=performance.now(),this.animate())}stop(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}},OM=Object.freeze({type:`running`}),kM=(e,t)=>e!==void 0&&e>0?e:t,AM=(e,t=!1)=>{let{text:n}=e,r=$A(`(prefers-reduced-motion: reduce)`),i=typeof t==`object`&&t?t:void 0,a=t!==!1&&t!==null&&!r,o=kM(i==null?void 0:i.drainMs,TM),s=kM(i==null?void 0:i.maxCharIntervalMs,EM),c=kM(i==null?void 0:i.maxCharsPerFrame,1/0),l=kM(i==null?void 0:i.minCommitMs,0),[u,d]=_n(e.status.type===`running`?``:n),f=qa(),p=q(()=>f.part),[m,h]=_n(p);p===m&&n.startsWith(u)||(h(p),d(e.status.type===`running`?``:n));let g=wM({optional:!0}),_=Wb(t=>{if(d(t),g){let n=u!==t||e.status.type===`running`?OM:e.status;xy(g).setState(n,!0)}});G(()=>{if(g){let t=a&&(u!==n||e.status.type===`running`)?OM:e.status;xy(g).setState(t,!0)}},[g,a,n,u,e.status]);let[v]=_n(()=>new DM(u,_)),[y,b]=_n(a);a!==y&&(b(a),a&&p===m&&n.startsWith(v.currentText)&&d(v.currentText)),G(()=>{v.drainMs=o,v.maxCharIntervalMs=s,v.maxCharsPerFrame=c,v.minCommitMs=l},[v,o,s,c,l]);let x=yn(p);return G(()=>{let t=x.current!==p;if(x.current=p,!a)v.stop(),v.currentText=n,v.targetText=n,v.lastCommitTime=-1/0;else if(t||!n.startsWith(v.targetText))e.status.type===`running`?(v.currentText=``,v.targetText=n,v.lastCommitTime=-1/0,v.start()):(v.currentText=n,v.targetText=n,v.stop(),_(n));else if(v.targetText=n,e.status.type!==`running`){if(v.currentText===``){v.currentText=n,v.stop(),_(n);return}v.start()}else v.start()},[v,a,n,e.status.type,p,_]),G(()=>()=>{v.stop()},[v]),bn(()=>a?E(E({},e),{},{text:u,status:n===u?e.status:OM}):e,[a,u,e,n])},jM=Object.freeze({type:`complete`}),MM=Object.freeze({type:`image`,image:``,status:jM}),NM=()=>q(PM);function PM(e){return e.part.type===`image`?e.part:MM}var FM=[`smooth`,`component`,`render`],IM=kn((e,t)=>{let{smooth:n=!0,component:r=LO.span,render:i}=e,a=W(e,FM),{text:o,status:s}=AM(gM(),n),c=E(E({"data-status":s.type},a),{},{ref:t});return i&&Pn(i)?PO(i,o,c):(0,J.jsx)(r,E(E({},c),{},{children:o}))});IM.displayName=`MessagePartPrimitive.Text`;var LM=kn((e,t)=>{let n=K(4),{image:r}=NM(),i;return n[0]!==t||n[1]!==r||n[2]!==e?(i=(0,J.jsx)(LO.img,E(E({src:r},e),{},{ref:t})),n[0]=t,n[1]=r,n[2]=e,n[3]=i):i=n[3],i});LM.displayName=`MessagePartPrimitive.Image`;var RM=kn((e,t)=>{let n=K(3),r;return n[0]!==t||n[1]!==e?(r=(0,J.jsx)(LO.div,E(E({role:`alert`},e),{},{ref:t})),n[0]=t,n[1]=e,n[2]=r):r=n[2],r});RM.displayName=`ErrorPrimitive.Root`;var zM=[`children`],BM=kn((e,t)=>{var n;let r=K(7),i,a;if(r[0]!==e){var o=e;({children:i}=o),a=W(o,zM),r[0]=e,r[1]=i,r[2]=a}else i=r[1],a=r[2];let s=Qv();if(s===void 0)return null;let c=(n=i)==null?String(s):n,l;return r[3]!==t||r[4]!==a||r[5]!==c?(l=(0,J.jsx)(LO.span,E(E({},a),{},{ref:t,children:c})),r[3]=t,r[4]=a,r[5]=c,r[6]=l):l=r[6],l});BM.displayName=`ErrorPrimitive.Message`;var VM=lO({Message:()=>BM,Root:()=>RM}),HM=e=>{let t=K(2),n=yn(void 0),r;return t[0]===e?r=t[1]:(r=t=>{n.current&&(n.current(),n.current=void 0),t&&(n.current=e(t))},t[0]=e,t[1]=r),r},UM=(e,t)=>{let n=e.trim().match(/^(\d+(?:\.\d+)?|\.\d+)(em|px|rem)$/);if(!n)return 1/0;let r=Number(n[1]),i=n[2];return i===`px`?r:i===`em`?r*(parseFloat(getComputedStyle(t).fontSize)||16):i===`rem`?r*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16):1/0},WM=e=>e.dataset.messageId,GM=()=>{let e=document.createElement(`div`);return e.dataset.auiTopAnchorReserve=``,e.style.height=`0px`,e.style.flexShrink=`0`,e.style.pointerEvents=`none`,e.setAttribute(`aria-hidden`,`true`),e},KM=(e,t)=>{let n=`${t}px`;return e.style.height!==n&&(e.style.height=n,!0)},qM=e=>{let t=window.devicePixelRatio||1;return Math.round(e*t)/t},JM=[`forwardedRef`],YM=[`forwardedRef`,`threadViewportStore`],XM=()=>{let e=K(4),t=qa(),n;e[0]===t.message?n=e[1]:(n=()=>t.message,e[0]=t.message,e[1]=n);let r=q(n),i;return e[2]===r?i=e[3]:(i=e=>{let t=!0,n=()=>{r.setIsHovering(!0)},i=()=>{r.setIsHovering(!1)};return e.addEventListener(`mouseenter`,n),e.addEventListener(`mouseleave`,i),e.matches(`:hover`)&&queueMicrotask(()=>{t&&r.setIsHovering(!0)}),()=>{t=!1,e.removeEventListener(`mouseenter`,n),e.removeEventListener(`mouseleave`,i),r.setIsHovering(!1)}},e[2]=r,e[3]=i),HM(i)},ZM=()=>{let e=K(2),t=iy(iN),n;return e[0]===t?n=e[1]:(n=e=>{var n;return e.message.role===`user`&&e.message.index>0&&e.message.index===e.thread.messages.length-2&&((n=e.thread.messages.at(-1))==null?void 0:n.role)===`assistant`&&(e.message.id===t||e.thread.isRunning)},e[0]=t,e[1]=n),q(n)},QM=()=>{let e=K(2),t=iy(aN),n;return e[0]===t?n=e[1]:(n=e=>{var n;return e.message.isLast&&e.message.role===`assistant`&&e.message.index>=1&&((n=e.thread.messages.at(e.message.index-1))==null?void 0:n.role)===`user`&&(e.message.id===t||e.thread.isRunning)},e[0]=t,e[1]=n),q(n)},$M=(e,t)=>{let n=K(3),r;return n[0]!==e||n[1]!==t?(r=n=>{if(e)return t.getState().registerAnchorElement(n)},n[0]=e,n[1]=t,n[2]=r):r=n[2],HM(r)},eN=e=>{let t=K(3),{active:n,threadViewportStore:r}=e,i;return t[0]!==n||t[1]!==r?(i=e=>{if(!n)return;let t=r.getState(),i=t.topAnchorMessageClamp;return t.registerAnchorTargetElement(e,{tallerThan:UM(i.tallerThan,e),visibleHeight:UM(i.visibleHeight,e)})},t[0]=n,t[1]=r,t[2]=i):i=t[2],HM(i)},tN=e=>{let t=K(7),n,r;if(t[0]!==e){var i=e;({forwardedRef:n}=i),r=W(i,JM),t[0]=e,t[1]=n,t[2]=r}else n=t[1],r=t[2];let a=XM(),o=Py(n,a),s=q(oN),c;return t[3]!==s||t[4]!==r||t[5]!==o?(c=(0,J.jsx)(LO.div,E(E({},r),{},{ref:o,"data-message-id":s})),t[3]=s,t[4]=r,t[5]=o,t[6]=c):c=t[6],c},nN=e=>{let t=K(13),n,r,i;if(t[0]!==e){var a=e;({forwardedRef:n,threadViewportStore:i}=a),r=W(a,YM),t[0]=e,t[1]=n,t[2]=r,t[3]=i}else n=t[1],r=t[2],i=t[3];let o=XM(),s=ZM(),c=QM(),l=$M(s,i),u;t[4]!==c||t[5]!==i?(u={active:c,threadViewportStore:i},t[4]=c,t[5]=i,t[6]=u):u=t[6];let d=eN(u),f=Py(n,o,l,d),p=q(sN),m=s?``:void 0,h=c?``:void 0,g;return t[7]!==p||t[8]!==r||t[9]!==f||t[10]!==m||t[11]!==h?(g=(0,J.jsx)(LO.div,E(E({},r),{},{ref:f,"data-message-id":p,"data-aui-top-anchor-user":m,"data-aui-top-anchor-target":h})),t[7]=p,t[8]=r,t[9]=f,t[10]=m,t[11]=h,t[12]=g):g=t[12],g},rN=kn((e,t)=>{let n=K(7),r=ay();if(r.getState().turnAnchor===`top`){let i;return n[0]!==t||n[1]!==e||n[2]!==r?(i=(0,J.jsx)(nN,E(E({},e),{},{forwardedRef:t,threadViewportStore:r})),n[0]=t,n[1]=e,n[2]=r,n[3]=i):i=n[3],i}let i;return n[4]!==t||n[5]!==e?(i=(0,J.jsx)(tN,E(E({},e),{},{forwardedRef:t})),n[4]=t,n[5]=e,n[6]=i):i=n[6],i});rN.displayName=`MessagePrimitive.Root`;function iN(e){var t;return(t=e.topAnchorTurn)==null?void 0:t.anchorId}function aN(e){var t;return(t=e.topAnchorTurn)==null?void 0:t.targetId}function oN(e){return e.message.id}function sN(e){return e.message.id}var cN=[`components`],lN=E(E({},Fg),{},{Text:()=>(0,J.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,J.jsx)(IM,{}),(0,J.jsx)(K_,{children:(0,J.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Image:()=>(0,J.jsx)(LM,{})}),uN=e=>{let t=K(10);if(`children`in e){let n;return t[0]===e.children?n=t[1]:(n=(0,J.jsx)(Zg,{children:e.children}),t[0]=e.children,t[1]=n),n}let n,r;if(t[2]!==e){var i=e;({components:n}=i),r=W(i,cN),t[2]=e,t[3]=n,t[4]=r}else n=t[3],r=t[4];let a;if(t[5]!==n){var o,s;a=n?E(E({},n),{},{Text:(o=n.Text)==null?lN.Text:o,Image:(s=n.Image)==null?lN.Image:s}):lN,t[5]=n,t[6]=a}else a=t[6];let c=a,l;return t[7]!==r||t[8]!==c?(l=(0,J.jsx)(Zg,E({components:c},r)),t[7]=r,t[8]=c,t[9]=l):l=t[9],l};uN.displayName=`MessagePrimitive.Parts`;var dN=[`children`],fN=e=>{let t=K(12),n;return t[0]!==e.assistant||t[1]!==e.copied||t[2]!==e.hasAttachments||t[3]!==e.hasBranches||t[4]!==e.hasContent||t[5]!==e.last||t[6]!==e.lastOrHover||t[7]!==e.speaking||t[8]!==e.submittedFeedback||t[9]!==e.system||t[10]!==e.user?(n=t=>{var n,r;let{role:i,attachments:a,parts:o,branchCount:s,isLast:c,speech:l,isCopied:u,isHovering:d}=t.message;return!(e.hasBranches===!0&&s<2||e.user===!0&&i!==`user`||e.user===!1&&i===`user`||e.assistant===!0&&i!==`assistant`||e.assistant===!1&&i===`assistant`||e.system===!0&&i!==`system`||e.system===!1&&i===`system`||e.lastOrHover===!0&&!d&&!c||e.last!==void 0&&e.last!==c||e.copied===!0&&!u||e.copied===!1&&u||e.speaking===!0&&l==null||e.speaking===!1&&l!=null||e.hasAttachments===!0&&(i!==`user`||!(a!=null&&a.length))||e.hasAttachments===!1&&i===`user`&&a!=null&&a.length||e.hasContent===!0&&o.length===0||e.hasContent===!1&&o.length>0||e.submittedFeedback!==void 0&&((n=(r=t.message.metadata.submittedFeedback)==null?void 0:r.type)==null?null:n)!==e.submittedFeedback)},t[0]=e.assistant,t[1]=e.copied,t[2]=e.hasAttachments,t[3]=e.hasBranches,t[4]=e.hasContent,t[5]=e.last,t[6]=e.lastOrHover,t[7]=e.speaking,t[8]=e.submittedFeedback,t[9]=e.system,t[10]=e.user,t[11]=n):n=t[11],q(n)},pN=e=>{let t=K(3),n,r;if(t[0]!==e){var i=e;({children:n}=i),r=W(i,dN),t[0]=e,t[1]=n,t[2]=r}else n=t[1],r=t[2];return fN(r)?n:null};pN.displayName=`MessagePrimitive.If`;var mN=e=>{let{children:t}=e;return Qv()===void 0?null:t};mN.displayName=`MessagePrimitive.Error`;var hN=[`components`],gN=e=>{let t=new Map;for(let a=0;a<e.length;a++){var n,r,i;let o=(n=(r=e[a])==null?void 0:r.parentId)==null?a:n,s=(i=t.get(o))==null?[]:i;s.push(a),t.set(o,s)}let a=[];for(let[e,n]of t){let t=typeof e==`string`?e:void 0;a.push({groupKey:t,indices:n})}return a},_N=e=>{let t=K(9),n=q(TN),r;bb0:{if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],r=e;break bb0}let i;t[1]!==e||t[2]!==n?(i=e(n),t[1]=e,t[2]=n,t[3]=i):i=t[3],r=i}let i=r,a;t[4]===n?a=t[5]:(a=fu(n),t[4]=n,t[5]=a);let o;return t[6]!==i||t[7]!==a?(o={groups:i,partKeys:a},t[6]=i,t[7]=a,t[8]=o):o=t[8],o},vN={Text:()=>(0,J.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,J.jsx)(IM,{}),(0,J.jsx)(K_,{children:(0,J.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Reasoning:()=>null,Source:()=>null,Image:()=>(0,J.jsx)(LM,{}),File:()=>null,Unstable_Audio:()=>null,Group:({children:e})=>e},yN=An(e=>{let t=K(5),{partIndex:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,J.jsx)(Ig,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,J.jsx)(qd,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>{var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_;return e.partIndex===t.partIndex&&((n=e.components)==null?void 0:n.Text)===((r=t.components)==null?void 0:r.Text)&&((i=e.components)==null?void 0:i.Reasoning)===((a=t.components)==null?void 0:a.Reasoning)&&((o=e.components)==null?void 0:o.Source)===((s=t.components)==null?void 0:s.Source)&&((c=e.components)==null?void 0:c.Image)===((l=t.components)==null?void 0:l.Image)&&((u=e.components)==null?void 0:u.File)===((d=t.components)==null?void 0:d.File)&&((f=e.components)==null?void 0:f.Unstable_Audio)===((p=t.components)==null?void 0:p.Unstable_Audio)&&((m=e.components)==null?void 0:m.tools)===((h=t.components)==null?void 0:h.tools)&&((g=e.components)==null?void 0:g.data)===((_=t.components)==null?void 0:_.data)}),bN=e=>{let t=K(6),{status:n,component:r}=e,i=n.type===`running`,a;t[0]!==r||t[1]!==n?(a=(0,J.jsx)(r,{type:`text`,text:``,status:n}),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o;return t[3]!==i||t[4]!==a?(o=(0,J.jsx)(Yd,{text:``,isRunning:i,children:a}),t[3]=i,t[4]=a,t[5]=o):o=t[5],o},xN=Object.freeze({type:`complete`}),SN=An(e=>{var t;let n=K(6),{components:r}=e,i=q(EN);if(r!=null&&r.Empty){let e;return n[0]!==r.Empty||n[1]!==i?(e=(0,J.jsx)(r.Empty,{status:i}),n[0]=r.Empty,n[1]=i,n[2]=e):e=n[2],e}let a=(t=r==null?void 0:r.Text)==null?vN.Text:t,o;return n[3]!==i||n[4]!==a?(o=(0,J.jsx)(bN,{status:i,component:a}),n[3]=i,n[4]=a,n[5]=o):o=n[5],o},(e,t)=>{var n,r,i,a;return((n=e.components)==null?void 0:n.Empty)===((r=t.components)==null?void 0:r.Empty)&&((i=e.components)==null?void 0:i.Text)===((a=t.components)==null?void 0:a.Text)}),CN=e=>{let t=K(21),{groupingFunction:n,components:r}=e,i=q(DN),{groups:a,partKeys:o}=_N(n),s;bb0:{var c,l,u,d,f,p;if(i===0){let e;t[0]===r?e=t[1]:(e=(0,J.jsx)(SN,{components:r}),t[0]=r,t[1]=e),s=e;break bb0}let e=(c=r==null?void 0:r.Text)==null?vN.Text:c,n=(l=r==null?void 0:r.Reasoning)==null?vN.Reasoning:l,m=(u=r==null?void 0:r.Image)==null?vN.Image:u,h=(d=r==null?void 0:r.Source)==null?vN.Source:d,g=(f=r==null?void 0:r.File)==null?vN.File:f,_=(p=r==null?void 0:r.Unstable_Audio)==null?vN.Unstable_Audio:p,v;t[2]!==r||t[3]!==e||t[4]!==n||t[5]!==m||t[6]!==h||t[7]!==g||t[8]!==_?(v=E(E({},r),{},{Text:e,Reasoning:n,Image:m,Source:h,File:g,Unstable_Audio:_}),t[2]=r,t[3]=e,t[4]=n,t[5]=m,t[6]=h,t[7]=g,t[8]=_,t[9]=v):v=t[9];let y=v,b;if(t[10]!==(r==null?void 0:r.Group)||t[11]!==y||t[12]!==a||t[13]!==o){let e;t[15]!==(r==null?void 0:r.Group)||t[16]!==y||t[17]!==o?(e=(e,t)=>{var n,i;let a=(n=r==null?void 0:r.Group)==null?vN.Group:n,s=o[e.indices[0]];return(0,J.jsx)(a,{groupKey:e.groupKey,indices:e.indices,children:e.indices.map(e=>(0,J.jsx)(yN,{partIndex:e,components:y},o[e]))},JSON.stringify([`group`,(i=e.groupKey)==null?null:i,s!=null&&s.includes(`:`)?`id:${s}`:t]))},t[15]=r==null?void 0:r.Group,t[16]=y,t[17]=o,t[18]=e):e=t[18],b=a.map(e),t[10]=r==null?void 0:r.Group,t[11]=y,t[12]=a,t[13]=o,t[14]=b}else b=t[14];s=b}let m=s,h;return t[19]===m?h=t[20]:(h=(0,J.jsx)(J.Fragment,{children:m}),t[19]=m,t[20]=h),h};CN.displayName=`MessagePrimitive.Unstable_PartsGrouped`;var wN=e=>{let t=K(6),n,r;if(t[0]!==e){var i=e;({components:n}=i),r=W(i,hN),t[0]=e,t[1]=n,t[2]=r}else n=t[1],r=t[2];let a;return t[3]!==n||t[4]!==r?(a=(0,J.jsx)(CN,E(E({},r),{},{components:n,groupingFunction:gN})),t[3]=n,t[4]=r,t[5]=a):a=t[5],a};wN.displayName=`MessagePrimitive.Unstable_PartsGroupedByParentId`;function TN(e){return e.message.parts}function EN(e){var t;return(t=e.message.status)==null?xN:t}function DN(e){return e.message.parts.length}var ON=lO({AttachmentByIndex:()=>M_,Attachments:()=>P_,Content:()=>uN,Error:()=>mN,GenerativeUI:()=>wg,GroupedParts:()=>b_,If:()=>pN,PartByIndex:()=>Lg,Parts:()=>uN,Quote:()=>k_,Root:()=>rN,Unstable_PartsGrouped:()=>CN,Unstable_PartsGroupedByParentId:()=>wN}),kN=({autoScroll:e,scrollToBottomOnRunStart:t=!0,scrollToBottomOnInitialize:n=!0,scrollToBottomOnThreadSwitch:r=!0})=>{let i=qa(),a=yn(null),o=q(e=>e.thread.messages.length>0),s=q(e=>{var t;return(t=e.thread.messages[0])==null?void 0:t.id}),c=q(e=>{var t;return(t=e.optional.threadListItem)==null?void 0:t.id}),l=q(e=>e.thread.isRunning),u=ay(),d=yy(u),{controller:f}=d;En(()=>{d.getOptions=()=>{let i=u.getState();return{autoScroll:e==null?i.turnAnchor!==`top`:e,holdFollow:l&&i.turnAnchor===`top`&&i.element.viewport===a.current&&i.element.anchor!==null,scrollToBottomOnInitialize:n,scrollToBottomOnRunStart:t&&i.turnAnchor!==`top`,scrollToBottomOnThreadSwitch:r}}});let p=yn({threadId:c,firstMessageId:s});return Ey(()=>{let e=p.current;if(p.current={threadId:c,firstMessageId:s},e.threadId!==c)return;let t=e.firstMessageId;t!==void 0&&t!==s&&i.thread.getState().messages.some((e,n)=>n>0&&e.id===t)&&f.messagesPrepended(t)},[i,f,s,c]),Ey(()=>{f.setHasMessages(o)},[f,o,n]),YA(({behavior:e})=>f.scrollToBottom(e)),Md(`thread.runStart`,()=>f.runStarted()),G(()=>{if(i.optional.threads)return i.on(`threads.selectionChanged`,()=>f.threadSwitched())},[i,f]),HM(xn(e=>{a.current=e;let t=f.attach(e);return()=>{t(),a.current=null}},[f]))},AN=new WeakMap,jN=kn((e,t)=>{let n=K(9),r=qa(),i=yn(null),a=Py(t,i),o;n[0]===e?o=n[1]:(o=t=>{var n;t.key===`Escape`&&i.current&&AN.set(t.nativeEvent,i.current),(n=e.onKeyDown)==null||n.call(e,t)},n[0]=e,n[1]=o);let s=o,c,l;n[2]===r?(c=n[3],l=n[4]):(c=()=>{let e=e=>{var t;if(e.key!==`Escape`||ej(e)||e.defaultPrevented||r.thread.source===null)return;let n=(t=AN.get(e))==null?e.composedPath().find(MN):t;if(!(n&&n!==i.current)&&r.thread.getState().speech!=null){e.preventDefault();try{r.thread.stopSpeaking()}catch(e){let t=e;if(!(t instanceof Error)||t.message!==`No message is being spoken`)throw t}}};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},l=[r],n[2]=r,n[3]=c,n[4]=l),G(c,l);let u;return n[5]!==a||n[6]!==s||n[7]!==e?(u=(0,J.jsx)(tj.Provider,{value:i,children:(0,J.jsx)(LO.div,E(E({},e),{},{"data-aui-thread-root":``,ref:a,onKeyDown:s}))}),n[5]=a,n[6]=s,n[7]=e,n[8]=u):u=n[8],u});jN.displayName=`ThreadPrimitive.Root`;function MN(e){return e instanceof Element&&e.hasAttribute(`data-aui-thread-root`)}var NN=e=>{let{children:t}=e;return q(PN)?t:null};NN.displayName=`ThreadPrimitive.Empty`;function PN(e){return e.thread.isEmpty}var FN=[`children`],IN=e=>{let t=K(4),n;return t[0]!==e.disabled||t[1]!==e.empty||t[2]!==e.running?(n=t=>!(e.empty===!0&&!t.thread.isEmpty||e.empty===!1&&t.thread.isEmpty||e.running===!0&&!t.thread.isRunning||e.running===!1&&t.thread.isRunning||e.disabled===!0&&!t.thread.isDisabled||e.disabled===!1&&t.thread.isDisabled),t[0]=e.disabled,t[1]=e.empty,t[2]=e.running,t[3]=n):n=t[3],q(n)},LN=e=>{let t=K(3),n,r;if(t[0]!==e){var i=e;({children:n}=i),r=W(i,FN),t[0]=e,t[1]=n,t[2]=r}else n=t[1],r=t[2];return IN(r)?n:null};LN.displayName=`ThreadPrimitive.If`;var RN=(e,t)=>{let n=K(3),r;return n[0]!==t||n[1]!==e?(r=n=>{if(!e)return;let r=e(),i=()=>{let e=t?t(n):n.offsetHeight;r.setHeight(e)},a=new ResizeObserver(i);return a.observe(n),i(),()=>{a.disconnect(),r.unregister()}},n[0]=t,n[1]=e,n[2]=r):r=n[2],HM(r)},zN=[`scrollHeight`],BN=[`viewport`,`reserve`],VN=e=>{let t=0,n=e;for(;n;)t+=n.offsetTop,n=n.offsetParent;return t},HN=(e,t)=>{let n=0,r=e;for(;r&&r!==t;)n+=r.offsetTop,r=r.offsetParent;return r===t?n:VN(e)-VN(t)},UN=({viewport:e,anchor:t,tallerThan:n,visibleHeight:r})=>{let i=HN(t,e),a=t.offsetHeight;return i+Math.max(0,a-(a<=n?a:r))},WN=e=>{let{scrollHeight:t}=e,n=W(e,zN),{viewport:r}=n,i=UN(n)+r.clientHeight;return Math.max(0,i-t)},GN=e=>{let{viewport:t,reserve:n}=e,r=W(e,BN);return WN(E(E({viewport:t},r),{},{scrollHeight:t.scrollHeight-n.offsetHeight}))},KN=e=>{let t=new ResizeObserver(e),n=new MutationObserver(e),r=null,i=null,a=null,o=()=>{t.disconnect(),n.disconnect(),r=null,i=null,a=null};return{target:(e,s,c)=>{(r!==e||i!==s||a!==c)&&(o(),t.observe(e),t.observe(s),t.observe(c),n.observe(c,{childList:!0,subtree:!0,characterData:!0}),r=e,i=s,a=c)},disconnect:o}},qN=e=>{let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},cancel:()=>{t!==null&&(cancelAnimationFrame(t),t=null)}}},JN=e=>{let t=null,n,r=null,i=0,a=null,o=!1,s=null,c=()=>{a=null,s=null},l=()=>s!==null&&Math.abs(i-s)<=1,u=()=>{let e=r;if(!e)return;let t=e.scrollTop,n=Math.max(0,e.scrollHeight-e.clientHeight);t<i&&i>n+1&&Math.abs(t-n)<=1&&l()&&!o&&(a!=null||(a=i),p.schedule()),i=t},d=e=>{r!==e&&(r&&r.removeEventListener(`scroll`,u),r=e,o=!1,c(),e&&(e.addEventListener(`scroll`,u,{passive:!0}),i=e.scrollTop))};function f(){let r=e.getState(),{viewport:i,anchor:l,target:u}=r.element,f=r.targetConfig;if(d(r.turnAnchor===`top`?i:null),r.turnAnchor!==`top`||!i){m.disconnect(),c(),t&&(KM(t,0),t.remove());return}if(!l&&!u&&!f&&r.topAnchorTurn){m.disconnect(),c(),t!=null&&t.parentElement&&t.parentElement.lastElementChild!==t&&t.parentElement.append(t);return}if(!l||!u||!f){m.disconnect(),c(),t&&(KM(t,0),t.remove());return}if(t!=null||(t=GM()),(t.parentElement!==u.parentElement||t.previousElementSibling!==u)&&u.after(t),m.target(i,l,u),KM(t,GN(E({viewport:i,anchor:l,reserve:t},f)))){p.schedule();return}let h=WM(l),g=qM(UN(E({viewport:i,anchor:l},f)));if(h===void 0||h!==n)a=null,o=!1,Math.abs(i.scrollTop-g)>1&&i.scrollTo({top:g,behavior:`smooth`}),h!==void 0&&(n=h);else if(a!==null&&s!==null){let e=qM(a+(g-s));a=null,o=!0,Math.abs(i.scrollTop-e)>1&&i.scrollTo({top:e,behavior:`instant`})}s=g}let p=qN(f),m=KN(p.schedule);p.schedule();let h=e.subscribe(p.schedule);return()=>{p.cancel(),h(),m.disconnect(),d(null),t==null||t.remove()}},YN=e=>{let t=K(4),n=ay(),r,i;t[0]!==e||t[1]!==n?(r=()=>{if(e)return JN(n)},i=[e,n],t[0]=e,t[1]=n,t[2]=r,t[3]=i):(r=t[2],i=t[3]),Ey(r,i)},XN=(e,t)=>{var n;if(!e)return!1;let r=t.findIndex(t=>t.id===e.targetId);return r<1?!1:((n=t[r-1])==null?void 0:n.id)===e.anchorId&&t.slice(r+1).every(e=>e.role===`user`)},ZN=({isRunning:e,messages:t})=>{if(!e)return null;let n=t.at(-1),r=t.at(-2);return(r==null?void 0:r.role)!==`user`||(n==null?void 0:n.role)!==`assistant`?null:{anchorId:r.id,targetId:n.id}},QN=e=>{var t;return(t=ZN(e))==null?void 0:t.anchorId},$N=e=>{var t;return(t=ZN(e))==null?void 0:t.targetId},eP=[`autoScroll`,`scrollToBottomOnRunStart`,`scrollToBottomOnInitialize`,`scrollToBottomOnThreadSwitch`,`children`],tP=[`turnAnchor`,`topAnchorMessageClamp`],nP=()=>RN(iy(sP),cP),rP=()=>HM(iy(lP)),iP=e=>{let t=K(19),n=ay(),r;t[0]===e?r=t[1]:(r=t=>{if(e)return QN(t.thread)},t[0]=e,t[1]=r);let i=q(r),a;t[2]===e?a=t[3]:(a=t=>{if(e)return $N(t.thread)},t[2]=e,t[3]=a);let o=q(a),s=iy(uP),c;bb0:{if(!i||!o){c=null;break bb0}let e;t[4]!==i||t[5]!==o?(e={anchorId:i,targetId:o},t[4]=i,t[5]=o,t[6]=e):e=t[6],c=e}let l=c,u;t[7]!==e||t[8]!==s?(u=t=>e&&!!s&&XN(s,t.thread.messages),t[7]=e,t[8]=s,t[9]=u):u=t[9];let d=q(u),f,p;t[10]!==n||t[11]!==s||t[12]!==d?(f=()=>{s&&!d&&n.getState().setTopAnchorTurn(null)},p=[n,s,d],t[10]=n,t[11]=s,t[12]=d,t[13]=f,t[14]=p):(f=t[13],p=t[14]),Ey(f,p);let m,h;t[15]!==l||t[16]!==n?(m=()=>{if(!l)return;let e=n.getState(),t=e.topAnchorTurn;((t==null?void 0:t.anchorId)!==l.anchorId||t.targetId!==l.targetId)&&e.setTopAnchorTurn(l)},h=[l,n],t[15]=l,t[16]=n,t[17]=m,t[18]=h):(m=t[17],h=t[18]),Ey(m,h)},aP=kn((e,t)=>{let n=K(18),r,i,a,o,s,c;if(n[0]!==e){var l=e;({autoScroll:r,scrollToBottomOnRunStart:s,scrollToBottomOnInitialize:o,scrollToBottomOnThreadSwitch:c,children:i}=l),a=W(l,eP),n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c}else r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6];let u;n[7]!==r||n[8]!==o||n[9]!==s||n[10]!==c?(u={autoScroll:r,scrollToBottomOnRunStart:s,scrollToBottomOnInitialize:o,scrollToBottomOnThreadSwitch:c},n[7]=r,n[8]=o,n[9]=s,n[10]=c,n[11]=u):u=n[11];let d=kN(u),f=nP(),p=rP(),m=ay(),h;n[12]===m?h=n[13]:(h=m.getState(),n[12]=m,n[13]=h);let g=h.turnAnchor===`top`;iP(g),YN(g);let _=Py(t,d,f,p),v;return n[14]!==i||n[15]!==_||n[16]!==a?(v=(0,J.jsx)(LO.div,E(E({},a),{},{ref:_,children:i})),n[14]=i,n[15]=_,n[16]=a,n[17]=v):v=n[17],v});aP.displayName=`ThreadPrimitive.ViewportScrollable`;var oP=kn((e,t)=>{let n=K(13),r,i,a;if(n[0]!==e){var o=e;({turnAnchor:a,topAnchorMessageClamp:i}=o),r=W(o,tP),n[0]=e,n[1]=r,n[2]=i,n[3]=a}else r=n[1],i=n[2],a=n[3];let s;n[4]!==i||n[5]!==a?(s={turnAnchor:a,topAnchorMessageClamp:i},n[4]=i,n[5]=a,n[6]=s):s=n[6];let c;n[7]!==r||n[8]!==t?(c=(0,J.jsx)(aP,E(E({},r),{},{ref:t})),n[7]=r,n[8]=t,n[9]=c):c=n[9];let l;return n[10]!==s||n[11]!==c?(l=(0,J.jsx)(Cy,{options:s,children:c}),n[10]=s,n[11]=c,n[12]=l):l=n[12],l});oP.displayName=`ThreadPrimitive.Viewport`;function sP(e){return e.registerViewport}function cP(e){return e.clientHeight}function lP(e){return e.registerViewportElement}function uP(e){return e.topAnchorTurn}var dP=kn((e,t)=>{let n=K(3),r=Py(t,RN(iy(fP),pP)),i;return n[0]!==e||n[1]!==r?(i=(0,J.jsx)(LO.div,E(E({},e),{},{ref:r})),n[0]=e,n[1]=r,n[2]=i):i=n[2],i});dP.displayName=`ThreadPrimitive.ViewportFooter`;function fP(e){return e.registerContentInset}function pP(e){let t=parseFloat(getComputedStyle(e).marginTop)||0;return e.offsetHeight+t}var mP=ZO(`ThreadPrimitive.ScrollToBottom`,e=>{let t=K(5),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{behavior:r}=n,i=iy(hP),a=ay(),o;return t[2]!==r||t[3]!==a?(o=()=>{a.getState().scrollToBottom({behavior:r})},t[2]=r,t[3]=a,t[4]=o):o=t[4],i?null:o},[`behavior`]);function hP(e){return e.isAtBottom}var gP=ZO(`ThreadPrimitive.LoadEarlier`,()=>{let e=K(2),t=qa(),n=q(_P),r;return e[0]===t.thread?r=e[1]:(r=()=>{t.thread.loadEarlier()},e[0]=t.thread,e[1]=r),n?r:null});function _P(e){return e.thread.hasEarlier}var vP=ZO(`ThreadPrimitive.Suggestion`,e=>{var t;let n=K(4),{prompt:r,send:i,clearComposer:a,autoSend:o}=e,s=(t=i==null?o:i)!=null&&t,c;n[0]!==a||n[1]!==r||n[2]!==s?(c={prompt:r,send:s,clearComposer:a},n[0]=a,n[1]=r,n[2]=s,n[3]=c):c=n[3];let{disabled:l,trigger:u}=Wv(c);return l?null:u},[`prompt`,`send`,`clearComposer`,`autoSend`,`method`]),yP=lO({Empty:()=>NN,If:()=>LN,LoadEarlier:()=>gP,MessageByIndex:()=>lg,Messages:()=>pg,Root:()=>jN,Row:()=>D_,ScrollToBottom:()=>mP,Suggestion:()=>vP,SuggestionByIndex:()=>Q_,Suggestions:()=>tv,Unstable_MessageById:()=>ug,Viewport:()=>oP,ViewportFooter:()=>dP,ViewportProvider:()=>Cy}),bP=kn((e,t)=>{var n;let r=K(4),i=q(xP),a=(n=e.children)==null?i:n,o;return r[0]!==e||r[1]!==t||r[2]!==a?(o=(0,J.jsx)(LO.span,E(E({},e),{},{ref:t,children:a})),r[0]=e,r[1]=t,r[2]=a,r[3]=o):o=r[3],o});bP.displayName=`SuggestionPrimitive.Title`;function xP(e){return e.suggestion.title}var SP=kn((e,t)=>{var n;let r=K(4),i=q(CP),a=(n=e.children)==null?i:n,o;return r[0]!==e||r[1]!==t||r[2]!==a?(o=(0,J.jsx)(LO.span,E(E({},e),{},{ref:t,children:a})),r[0]=e,r[1]=t,r[2]=a,r[3]=o):o=r[3],o});SP.displayName=`SuggestionPrimitive.Description`;function CP(e){return e.suggestion.label}var wP=ZO(`SuggestionPrimitive.Trigger`,e=>{let t=K(4),{send:n,clearComposer:r}=e,i=q(TP),a;t[0]!==r||t[1]!==i||t[2]!==n?(a={prompt:i,send:n,clearComposer:r},t[0]=r,t[1]=i,t[2]=n,t[3]=a):a=t[3];let{trigger:o,disabled:s}=Wv(a);return s?null:o},[`send`,`clearComposer`]);function TP(e){return e.suggestion.prompt}var EP=lO({Description:()=>SP,Title:()=>bP,Trigger:()=>wP}),DP=[`onClick`,`disabled`],OP=kn((e,t)=>{let n=K(15),r,i,a;if(n[0]!==e){var o=e;({onClick:i,disabled:r}=o),a=W(o,DP),n[0]=e,n[1]=r,n[2]=i,n[3]=a}else r=n[1],i=n[2],a=n[3];let s=q(kP),{switchToNewThread:c}=Xv(),l;n[4]===s?l=n[5]:(l=s?{"data-active":`true`,"aria-current":`true`}:null,n[4]=s,n[5]=l);let u;n[6]!==i||n[7]!==c?(u=Ib(i,c),n[6]=i,n[7]=c,n[8]=u):u=n[8];let d;return n[9]!==r||n[10]!==t||n[11]!==a||n[12]!==l||n[13]!==u?(d=(0,J.jsx)(LO.button,E(E(E({type:`button`},l),a),{},{ref:t,disabled:r,onClick:u})),n[9]=r,n[10]=t,n[11]=a,n[12]=l,n[13]=u,n[14]=d):d=n[14],d});OP.displayName=`ThreadListPrimitive.New`;function kP(e){return e.threads.newThreadId===e.threads.mainThreadId}var AP=ZO(`ThreadListPrimitive.LoadMore`,()=>{let{loadMore:e,disabled:t}=Zv();return t?null:e}),[jP,MP]=xb(`ThreadList`),NP=jP,PP=zn(null),FP=PP.Provider,IP=()=>Vn(PP),LP=kn((e,t)=>{let n=K(3),r;return n[0]!==e||n[1]!==t?(r=(0,J.jsx)(NP.Provider,{scope:void 0,children:(0,J.jsx)(NP.Slot,{scope:void 0,children:(0,J.jsx)(LO.div,E(E({},e),{},{ref:t}))})}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});LP.displayName=`ThreadListPrimitive.Root`;var RP=lO({ItemByIndex:()=>U_,Items:()=>G_,LoadMore:()=>AP,New:()=>OP,Root:()=>LP}),zP=kn((e,t)=>{let n=q(e=>e.threads.mainThreadId===e.threadListItem.id),r=yn(null),i=yn(null),a=bn(()=>({triggerRef:r,moreRef:i}),[]),o=MP(void 0),s=zx();return(0,J.jsx)(FP,{value:a,children:(0,J.jsx)(LO.div,E(E(E({},n?{"data-active":`true`,"aria-current":`true`}:null),e),{},{onKeyDown:Ib(e.onKeyDown,e=>{if(e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return;let t=s===`rtl`?`ArrowLeft`:`ArrowRight`,n=s===`rtl`?`ArrowRight`:`ArrowLeft`,a=r.current,c=i.current;if(a&&e.target===a){if(e.key===`ArrowDown`||e.key===`ArrowUp`){let t=o().map(e=>e.ref.current).filter(e=>e!==null&&!e.disabled),n=t[t.indexOf(a)+(e.key===`ArrowDown`?1:-1)];n&&(n.focus(),e.preventDefault())}else e.key===t&&c&&(c.focus(),e.preventDefault())}else c&&e.target===c&&e.key===n&&(a==null||a.focus(),e.preventDefault())}),ref:t}))})});zP.displayName=`ThreadListItemPrimitive.Root`;var BP=ZO(`ThreadListItemPrimitive.Archive`,()=>{let{archive:e}=Kv();return e}),VP=ZO(`ThreadListItemPrimitive.Unarchive`,()=>{let{unarchive:e,disabled:t}=Jv();return t?null:e}),HP=ZO(`ThreadListItemPrimitive.Delete`,()=>{let{delete:e}=qv();return e}),UP=ZO(`ThreadListItemPrimitive.Trigger`,()=>{let{switchTo:e}=Yv();return e}),WP=kn((e,t)=>{let n=K(3),r=IP(),i=Py(t,r==null?void 0:r.triggerRef),a;return n[0]!==e||n[1]!==i?(a=(0,J.jsx)(NP.ItemSlot,{scope:void 0,children:(0,J.jsx)(UP,E(E({},e),{},{ref:i}))}),n[0]=e,n[1]=i,n[2]=a):a=n[2],a});WP.displayName=`ThreadListItemPrimitive.Trigger`;var GP=lO({Archive:()=>BP,Delete:()=>HP,Root:()=>zP,Title:()=>J_,Trigger:()=>WP,Unarchive:()=>VP}),KP=e=>{let t=e;for(;t;){let{overflowY:e}=getComputedStyle(t);if(e===`scroll`||e===`auto`)return t;t=t.parentElement}return null},qP=new WeakMap,JP=e=>{var t,n;let r=qP.get(e);if(r)return r.count++,r;let i=e.scrollTop,a=e.style.scrollbarWidth,o=getComputedStyle(e),s=o.direction===`rtl`?`paddingLeft`:`paddingRight`,c=e.style[s],l=e.offsetWidth-e.clientWidth-parseFloat(o.borderLeftWidth)-parseFloat(o.borderRightWidth),u=e.ownerDocument,d=(e===u.documentElement||e===u.body)&&l<=0?((t=(n=u.defaultView)==null?void 0:n.innerWidth)==null?0:t)-u.documentElement.clientWidth:l;e.style.scrollbarWidth=`none`,d>0&&(e.style[s]=`${parseFloat(o[s])+d}px`);let f=()=>{e.style.scrollbarWidth=a,e.style[s]=c},p=()=>e.scrollTop=i;e.addEventListener(`scroll`,p);let m={count:1,restore:()=>{e.removeEventListener(`scroll`,p),f()}};return qP.set(e,m),m},YP=(e,t)=>{let n=K(5),r=yn(null),i,a;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>()=>{var e;(e=r.current)==null||e.call(r)},a=[],n[0]=i,n[1]=a):(i=n[0],a=n[1]),G(i,a);let o;return n[2]!==e||n[3]!==t?(o=()=>{var n;(n=r.current)==null||n.call(r);let i=KP(e.current);if(!i){r.current=null;return}let a=JP(i),o=setTimeout(()=>{var e;return(e=r.current)==null?void 0:e.call(r)},t);r.current=()=>{clearTimeout(o),--a.count===0&&(a.restore(),qP.delete(i)),r.current=null}},n[2]=e,n[3]=t,n[4]=o):o=n[4],o},XP=lO({AssistantRuntimeImpl:()=>np,BaseAssistantRuntimeCore:()=>rp,CompositeContextProvider:()=>Ro,DefaultThreadComposerRuntimeCore:()=>wp,MessageRepository:()=>El,ThreadRuntimeImpl:()=>If,getAutoStatus:()=>yl,splitLocalRuntimeOptions:()=>ey,useComposerInputPluginRegistryOptional:()=>$k,useSmooth:()=>AM,useSmoothStatus:()=>CM,withSmoothContextProvider:()=>xM}),ZP=`http://localhost:3000/api/agent/chat`;function QP(e){let t=e.split(/\r?\n/);for(let e of t){if(!e.startsWith(`data:`))continue;let t=e.startsWith(`data: `)?e.slice(6):e.slice(5);if(t)try{return JSON.parse(t)}catch(e){return null}}return null}function $P(e){return eF.apply(this,arguments)}function eF(){return eF=eg(function*(e){let t=new TextDecoder,n=``;for(;;){let{done:r,value:i}=yield $h(e.read());if(r)break;n+=t.decode(i,{stream:!0});let a;for(;(a=n.search(/\r?\n\r?\n/))!==-1;){let e=n.match(/\r?\n\r?\n/);if(!e)break;let t=n.slice(0,a);n=n.slice(a+e[0].length);let r=QP(t);r&&(yield r)}}if(n+=t.decode(),n){let e=QP(n);e&&(yield e)}}),eF.apply(this,arguments)}function tF(e){return nF.apply(this,arguments)}function nF(){return nF=eg(function*({userMessage:e,abortSignal:t,token:n,getConversationId:r,onConversationCreated:i,onCustomEvent:a,onEvent:o}){let s={id:e.id,role:`user`,parts:e.content.filter(e=>e.type===`text`).map(e=>{var t;return{type:`text`,text:(t=e.text)==null?``:t}}),metadata:{files:[],sentAt:new Date().toISOString()}},c=r(),l=yield $h(fetch(ZP,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`text/event-stream`,Token:n},credentials:`include`,signal:t,body:JSON.stringify({message:s,conversationId:c||``})}));if(!l.ok){let e=yield $h(l.text());throw Error(`请求失败 (${l.status}): ${e}`)}if(!l.body)throw Error(`服务端没有返回数据流`);let u=l.body.getReader(),d=[],f=new Map,p=new Map,m=new Map,h=()=>[...d];try{var g=!1,_=!1,v;try{for(var y=z($P(u)),b;g=!(b=yield $h(y.next())).done;g=!1){let e=b.value;{if(t.aborted)return;let n=e.payload;switch(e.type){case`data-conversation-created`:{var x;let t=(x=e.data)==null?void 0:x.id;t&&i(t);break}case`text-delta`:{var S;let e=(S=n==null?void 0:n.id)==null?`default`:S,t=n==null?void 0:n.text;if(!t)break;let r=f.get(e);r===void 0&&(r=d.length,f.set(e,r),d.push({type:`text`,text:``}));let i=d[r];i.type===`text`&&(d[r]=E(E({},i),{},{text:i.text+t})),yield h();break}case`reasoning-start`:{var C;let e=(C=n==null?void 0:n.id)==null?`default`:C,t=Date.now(),r=d.length;p.set(e,r),m.set(e,t),d.push({type:`reasoning`,text:``,timing:{startedAt:t}}),yield h();break}case`reasoning-delta`:{var w;let e=(w=n==null?void 0:n.id)==null?`default`:w;if(!p.has(e)){let t=Date.now(),n=d.length;p.set(e,n),m.set(e,t),d.push({type:`reasoning`,text:``,timing:{startedAt:t}}),yield h()}break}case`reasoning-end`:{var T,D,O,k;let e=(T=n==null?void 0:n.id)==null?`default`:T,t=p.get(e);if(t===void 0)break;let r=d[t];if(r.type!==`reasoning`)break;let i=(D=(O=m.get(e))==null?(k=r.timing)==null?void 0:k.startedAt:O)==null?Date.now():D;d[t]=E(E({},r),{},{timing:{startedAt:i,completedAt:Date.now()}}),p.delete(e),m.delete(e),yield h();break}case`tool-call`:case`tool-result`:case`tool-error`:break;case`error`:var A;throw Error((A=n==null?void 0:n.error)==null?`AI 服务执行失败`:A);default:e.type.startsWith(`data-`)?a==null||a(e):o==null||o(e)}}}}catch(e){_=!0,v=e}finally{try{g&&y.return!=null&&(yield $h(y.return()))}finally{if(_)throw v}}}finally{try{yield $h(u.cancel())}catch(e){}finally{u.releaseLock()}}}),nF.apply(this,arguments)}var rF=`http://localhost:3000/api/conversations`,iF=new Map,aF=new Set,oF=`currentConversationId`;function sF(){return localStorage.getItem(oF)}function cF(e=``){localStorage.setItem(oF,e)}function lF(){localStorage.removeItem(oF)}function uF(e,t){iF.set(e,t)}var dF=``;function fF(e){dF=e}function pF(e){return mF.apply(this,arguments)}function mF(){return mF=w(function*(e,t={}){let n=yield fetch(`${rF}${e}`,E(E({},t),{},{credentials:`include`,headers:E({"Content-Type":`application/json`,Token:dF},t.headers)})),r=yield n.json();if(!n.ok||r.success===!1)throw Error(r.message||`请求失败`);return r}),mF.apply(this,arguments)}function hF(e){return{remoteId:e.id,status:`regular`,title:e.title||`新会话`}}function gF(e){let t={id:e.id,content:[{type:`text`,text:e.content}],createdAt:new Date(e.createdAt)};return e.role===`user`?E(E({},t),{},{role:`user`,attachments:[],metadata:{custom:{}}}):E(E({},t),{},{role:`assistant`,status:{type:`complete`,reason:`stop`},metadata:{unstable_state:{},unstable_annotations:[],unstable_data:[],steps:[],custom:{}}})}function _F(e){var t;let n=(t=e.custom)==null?void 0:t.conversationId;if(typeof n==`string`&&n)return n;let r=iF.get(e.id);if(r)return r;if(!aF.has(e.id))return e.remoteId||void 0}function vF(e){return aF.has(e)}function yF(e,t){return bF.apply(this,arguments)}function bF(){return bF=w(function*(e,t,n=20){return pF(`/${encodeURIComponent(e)}/messages?page=${t}&perPage=${n}`)}),bF.apply(this,arguments)}var xF={list(){return w(function*(){return{threads:(yield pF(`/`)).data.map(hF)}})()},initialize(e){return w(function*(){return aF.add(e),{remoteId:e}})()},fetch(e){return w(function*(){return hF((yield pF(`/${encodeURIComponent(e)}`)).data)})()},delete(e){return w(function*(){var t;let n=(t=iF.get(e))==null?aF.has(e)?void 0:e:t;n?(yield pF(`/${encodeURIComponent(n)}`,{method:`DELETE`}),iF.delete(e),aF.delete(e)):(aF.delete(e),iF.delete(e))})()},rename(){return w(function*(){})()},archive(){return w(function*(){})()},updateCustom(){return w(function*(){})()},generateTitle(e,t){return w(function*(){return ac(function(){var e=w(function*(e){let n=t.find(e=>e.role===`user`),r=(n==null?void 0:n.content.filter(e=>e.type===`text`).map(e=>e.text).join(``).slice(0,30))||`新会话`;e.appendText(r)});return function(t){return e.apply(this,arguments)}}())})()}},SF=`mineScript`,X={"color-white":`#ffffff`,"color-black":`#000000`,"color-transparent":`#00000000`,"color-cold-gray-50":`#F8F9FD`,"color-cold-gray-100":`#F0F3FA`,"color-cold-gray-150":`#E0E3EB`,"color-cold-gray-200":`#D1D4DC`,"color-cold-gray-250":`#C1C4CD`,"color-cold-gray-300":`#B2B5BE`,"color-cold-gray-350":`#A3A6AF`,"color-cold-gray-400":`#9598A1`,"color-cold-gray-450":`#868993`,"color-cold-gray-500":`#787B86`,"color-cold-gray-550":`#6A6D78`,"color-cold-gray-600":`#5D606B`,"color-cold-gray-650":`#50535E`,"color-cold-gray-700":`#434651`,"color-cold-gray-750":`#363A45`,"color-cold-gray-800":`#2A2E39`,"color-cold-gray-850":`#1E222D`,"color-cold-gray-900":`#131722`,"color-cold-gray-950":`#0C0E15`,"color-ripe-red-50":`#FFEBEC`,"color-ripe-red-100":`#FCCBCD`,"color-ripe-red-200":`#FAA1A4`,"color-ripe-red-300":`#F77C80`,"color-ripe-red-400":`#F7525F`,"color-ripe-red-500":`#F23645`,"color-ripe-red-600":`#CC2F3C`,"color-ripe-red-700":`#B22833`,"color-ripe-red-800":`#991F29`,"color-ripe-red-900":`#801922`,"color-ripe-red-a100":`#FF8080`,"color-ripe-red-a200":`#FF5252`,"color-ripe-red-a400":`#FF3333`,"color-ripe-red-a600":`#CC2929`,"color-ripe-red-a700":`#802028`,"color-ripe-red-a800":`#4D191D`,"color-ripe-red-a900":`#331F20`,"color-tan-orange-50":`#FFF3E0`,"color-tan-orange-100":`#FFE0B2`,"color-tan-orange-200":`#FFCC80`,"color-tan-orange-300":`#ffb74d`,"color-tan-orange-400":`#FFA726`,"color-tan-orange-500":`#FF9800`,"color-tan-orange-600":`#FB8C00`,"color-tan-orange-700":`#F57C00`,"color-tan-orange-800":`#EF6C00`,"color-tan-orange-900":`#e65100`,"color-tan-orange-a200":`#ffab40`,"color-tan-orange-a400":`#FF9100`,"color-tan-orange-a600":`#CC7014`,"color-tan-orange-a700":`#8C541C`,"color-tan-orange-a800":`#593A1B`,"color-tan-orange-a900":`#33261A`,"color-iguana-green-100":`#C8E6C9`,"color-iguana-green-200":`#A5D6A7`,"color-iguana-green-300":`#81c784`,"color-iguana-green-400":`#66BB6A`,"color-iguana-green-500":`#4caf50`,"color-iguana-green-600":`#43a047`,"color-iguana-green-700":`#388e3c`,"color-iguana-green-800":`#2E7D32`,"color-iguana-green-900":`#1B5E20`,"color-iguana-green-a700":`#00c853`,"color-banana-yellow-100":`#FFF9C4`,"color-banana-yellow-200":`#FFF59D`,"color-banana-yellow-300":`#FFF176`,"color-banana-yellow-400":`#ffee58`,"color-banana-yellow-500":`#ffeb3b`,"color-banana-yellow-600":`#fdd835`,"color-banana-yellow-700":`#fbc02d`,"color-banana-yellow-800":`#f9a825`,"color-banana-yellow-900":`#F57F17`,"color-banana-yellow-a400":`#ffea00`,"color-banana-yellow-a700":`#EEDA01`,"color-tv-blue-50":`#E3EFFD`,"color-tv-blue-100":`#BBD9FB`,"color-tv-blue-200":`#90BFF9`,"color-tv-blue-300":`#5B9CF6`,"color-tv-blue-400":`#3179F5`,"color-tv-blue-500":`#2962FF`,"color-tv-blue-600":`#1E53E5`,"color-tv-blue-700":`#1848CC`,"color-tv-blue-800":`#143EB3`,"color-tv-blue-900":`#0C3299`,"color-tv-blue-a100":`#82b1ff`,"color-tv-blue-a200":`#448aff`,"color-tv-blue-a400":`#2979ff`,"color-tv-blue-a600":`#2962FF`,"color-tv-blue-a700":`#143A87`,"color-tv-blue-a800":`#142E61`,"color-tv-blue-a900":`#132042`,"color-deep-blue-50":`#EDE7F6`,"color-deep-blue-100":`#D1C4E9`,"color-deep-blue-200":`#B39DDB`,"color-deep-blue-300":`#9575cd`,"color-deep-blue-400":`#7e57c2`,"color-deep-blue-500":`#673ab7`,"color-deep-blue-700":`#512da8`,"color-deep-blue-800":`#4527A0`,"color-deep-blue-900":`#311B92`,"color-deep-blue-a100":`#b388ff`,"color-deep-blue-a200":`#7C4DFF`,"color-deep-blue-a400":`#651FFF`,"color-deep-blue-a700":`#6200EA`,"color-minty-green-50":`#DAF2EE`,"color-minty-green-100":`#ACE5DC`,"color-minty-green-200":`#70CCBD`,"color-minty-green-300":`#42BDA8`,"color-minty-green-400":`#22AB94`,"color-minty-green-500":`#089981`,"color-minty-green-600":`#06806B`,"color-minty-green-700":`#056656`,"color-minty-green-800":`#004D40`,"color-minty-green-900":`#00332A`,"color-minty-green-a400":`#2BD9BC`,"color-minty-green-a600":`#24B29B`,"color-minty-green-a700":`#1B7667`,"color-minty-green-a800":`#10443B`,"color-minty-green-a900":`#082621`,"color-grapes-purple-50":`#F3E5F5`,"color-grapes-purple-100":`#E1BEE7`,"color-grapes-purple-200":`#CE93D8`,"color-grapes-purple-300":`#ba68c8`,"color-grapes-purple-400":`#ab47bc`,"color-grapes-purple-500":`#9c27b0`,"color-grapes-purple-600":`#8e24aa`,"color-grapes-purple-700":`#7b1fa2`,"color-grapes-purple-800":`#6A1B9A`,"color-grapes-purple-900":`#4A148C`,"color-grapes-purple-a100":`#EA80FC`,"color-grapes-purple-a200":`#E040FB`,"color-grapes-purple-a400":`#D500F9`,"color-grapes-purple-a700":`#aa00ff`,"color-berry-pink-100":`#F8BBD0`,"color-berry-pink-200":`#f48fb1`,"color-berry-pink-300":`#f06292`,"color-berry-pink-400":`#ec407a`,"color-berry-pink-500":`#e91e63`,"color-berry-pink-600":`#D81B60`,"color-berry-pink-700":`#C2185B`,"color-berry-pink-800":`#AD1457`,"color-berry-pink-900":`#880E4F`,"color-berry-pink-a100":`#ff80ab`,"color-berry-pink-a200":`#ff4081`,"color-berry-pink-a400":`#f50057`,"color-sky-blue-100":`#B2EBF2`,"color-sky-blue-200":`#80DEEA`,"color-sky-blue-300":`#4dd0e1`,"color-sky-blue-400":`#26c6da`,"color-sky-blue-500":`#00bcd4`,"color-sky-blue-600":`#00acc1`,"color-sky-blue-700":`#0097A7`,"color-sky-blue-800":`#00838F`,"color-sky-blue-900":`#006064`,"color-sky-blue-a400":`#00e5ff`,"color-sky-blue-a700":`#00B8D4`,"color-deep-blue-600":`#5E35B1`,"color-forest-green-50":`#DAF2E6`,"color-forest-green-100":`#ACE5C9`,"color-forest-green-200":`#70CC9E`,"color-forest-green-300":`#42BD7F`,"color-forest-green-400":`#22AB67`,"color-forest-green-500":`#089950`,"color-forest-green-600":`#068043`,"color-forest-green-700":`#056636`,"color-forest-green-800":`#004D27`,"color-forest-green-900":`#1A3326`,"color-facebook":`#1877F2`,"color-deep-facebook":`#1564CA`,"color-twitter":`#1DA1F2`,"color-deep-twitter":`#188CD3`,"color-youtube":`#FF0000`,"color-linkedin":`#007BB5`,"color-seeking-alpha-brand":`#ff7200`};function CF(e,t=1){return e+Math.round(255*Math.min(Math.max(t,0),1)).toString(16).toUpperCase().padStart(2,`0`)}var wF={base:`vs`,inherit:!0,rules:[{token:`comment`,foreground:X[`color-cold-gray-400`]},{token:`comment.annotation`,fontStyle:`bold`},{token:`text`,foreground:X[`color-cold-gray-900`]},{token:`string`,foreground:X[`color-iguana-green-700`]},{token:`constant.numeric`,foreground:X[`color-banana-yellow-900`]},{token:`constant.language`,foreground:X[`color-ripe-red-a600`]},{token:`constant.other.color`,foreground:X[`color-ripe-red-a600`]},{token:`constant.other`,foreground:X[`color-ripe-red-a600`]},{token:`support.variable`,foreground:X[`color-ripe-red-a600`]},{token:`support.function`,foreground:X[`color-tv-blue-a600`]},{token:`support.type`,foreground:X[`color-minty-green-400`],fontStyle:`bold`},{token:`entity.name.type`,foreground:X[`color-minty-green-400`],fontStyle:`bold`},{token:`support.method`,foreground:X[`color-tv-blue-a600`]},{token:`keyword.equals`,foreground:X[`color-minty-green-400`]},{token:`keyword.operator`,foreground:X[`color-minty-green-400`]},{token:`keyword.other`,foreground:X[`color-minty-green-400`]},{token:`keyword`,foreground:X[`color-minty-green-400`]},{token:`variable.other`,foreground:X[`color-cold-gray-800`]},{token:`variable.other.property`,foreground:X[`color-cold-gray-800`]},{token:`paren`,foreground:X[`color-black`]},{token:`entity.name.function`,foreground:X[`color-tv-blue-900`]},{token:`entity.name.method`,foreground:X[`color-tv-blue-900`]},{token:`meta.function-call`,foreground:X[`color-grapes-purple-600`]},{token:`entity.name.module.name`,foreground:X[`color-grapes-purple-600`]},{token:`entity.name.module`,foreground:X[`color-tv-blue-a600`]},{token:``,background:X[`color-white`]}],colors:{"editor.foreground":X[`color-cold-gray-900`],"editor.background":`#00000000`,"editorLineNumber.foreground":X[`color-cold-gray-400`],"editorLineNumber.activeForeground":X[`color-cold-gray-700`],"editorHoverWidget.background":X[`color-white`],"editorHoverWidget.statusBarBackground":X[`color-cold-gray-150`],"editorHoverWidget.foreground":X[`color-cold-gray-900`],"editorWidget.background":X[`color-white`],"editorWidget.foreground":X[`color-cold-gray-900`],"editorGutter.background":`#00000000`,"editor.foldBackground":CF(X[`color-cold-gray-200`],.5),"editor.lineHighlightBackground":X[`color-tv-blue-50`],"editor.lineHighlightBorder":X[`color-tv-blue-50`],"editor.rangeHighlightBackground":X[`color-tv-blue-100`],"editorBracketMatch.background":X[`color-cold-gray-150`],"editor.selectionBackground":X[`color-tv-blue-100`],"editor.selectionHighlightBackground":X[`color-tv-blue-50`],"editor.findMatchBackground":X[`color-tan-orange-100`],"editor.findMatchHighlightBackground":X[`color-tan-orange-100`],"editor.findMatchBorder":X[`color-tan-orange-500`],"list.foreground":X[`color-cold-gray-900`],"list.hoverForeground":X[`color-cold-gray-900`],"list.activeSelectionBackground":X[`color-tv-blue-500`],"list.hoverBackground":X[`color-tv-blue-50`],"list.focusHighlightForeground":X[`color-tv-blue-100`],"list.inactiveSelectionBackground":X[`color-tv-blue-500`],"keybindingLabel.background":X[`color-white`],"keybindingLabel.foreground":X[`color-cold-gray-900`],"keybindingLabel.border":X[`color-cold-gray-150`],"input.foreground":X[`color-cold-gray-900`],"textLink.foreground":X[`color-tv-blue-500`],"textLink.activeForeground":X[`color-tv-blue-600`],"peekViewEditor.matchHighlightBackground":X[`color-tan-orange-100`],"peekViewResult.lineForeground":X[`color-cold-gray-900`],"editorMarkerNavigationWarning.background":X[`color-banana-yellow-800`],"inputValidation.warningBackground":X[`color-banana-yellow-800`],"diffEditor.insertedTextBackground":CF(X[`color-forest-green-500`],.3),"diffEditor.insertedLineBackground":CF(X[`color-forest-green-500`],.15),"diffEditor.removedTextBackground":CF(X[`color-ripe-red-500`],.3),"diffEditor.removedLineBackground":CF(X[`color-ripe-red-500`],.15),"editorInlayHint.background":X[`color-cold-gray-150`],"editorInlayHint.foreground":X[`color-cold-gray-550`],"editorError.foreground":X[`color-ripe-red-500`],"editorWarning.foreground":X[`color-tan-orange-500`]}},TF={base:`vs-dark`,inherit:!0,rules:[{token:`comment`,foreground:X[`color-cold-gray-500`]},{token:`comment.annotation`,fontStyle:`bold`},{token:`text`,foreground:X[`color-white`]},{token:`string`,foreground:X[`color-iguana-green-700`]},{token:`constant.numeric`,foreground:X[`color-banana-yellow-900`]},{token:`constant.language`,foreground:X[`color-ripe-red-300`]},{token:`constant.other.color`,foreground:X[`color-ripe-red-300`]},{token:`constant.other`,foreground:X[`color-ripe-red-300`]},{token:`support.variable`,foreground:X[`color-ripe-red-300`]},{token:`support.function`,foreground:X[`color-tv-blue-300`]},{token:`support.method`,foreground:X[`color-tv-blue-300`]},{token:`support.type`,foreground:X[`color-minty-green-300`],fontStyle:`bold`},{token:`entity.name.type`,foreground:X[`color-minty-green-300`],fontStyle:`bold`},{token:`keyword.equals`,foreground:X[`color-minty-green-300`]},{token:`keyword.operator`,foreground:X[`color-minty-green-300`]},{token:`keyword.other`,foreground:X[`color-minty-green-300`]},{token:`keyword`,foreground:X[`color-minty-green-300`]},{token:`variable.other`,foreground:X[`color-cold-gray-200`]},{token:`variable.other.property`,foreground:X[`color-cold-gray-200`]},{token:`paren`,foreground:X[`color-white`]},{token:`entity.name.function`,foreground:X[`color-tv-blue-400`]},{token:`entity.name.method`,foreground:X[`color-tv-blue-400`]},{token:`meta.function-call`,foreground:X[`color-grapes-purple-300`]},{token:`entity.name.module.name`,foreground:X[`color-grapes-purple-300`]},{token:`entity.name.module`,foreground:X[`color-tv-blue-300`]},{token:``,background:X[`color-cold-gray-900`]}],colors:{"editor.foreground":X[`color-white`],"editor.background":X[`color-cold-gray-900`],"editorLineNumber.foreground":X[`color-cold-gray-500`],"editorLineNumber.activeForeground":X[`color-cold-gray-300`],"editorWidget.background":X[`color-cold-gray-850`],"editorHoverWidget.background":X[`color-cold-gray-850`],"editorHoverWidget.foreground":X[`color-cold-gray-300`],"editorHoverWidget.statusBarBackground":X[`color-cold-gray-900`],"editorWidget.foreground":X[`color-cold-gray-300`],"editorGutter.background":X[`color-cold-gray-900`],"editor.foldBackground":CF(X[`color-cold-gray-700`],.5),"editor.lineHighlightBackground":X[`color-tv-blue-a900`],"editor.lineHighlightBorder":X[`color-tv-blue-a900`],"editor.rangeHighlightBackground":X[`color-tv-blue-a800`],"editorBracketMatch.background":X[`color-cold-gray-750`],"editor.selectionBackground":X[`color-tv-blue-a800`],"editor.selectionHighlightBackground":X[`color-cold-gray-800`],"list.foreground":X[`color-cold-gray-350`],"list.hoverForeground":X[`color-cold-gray-350`],"list.activeSelectionBackground":X[`color-tv-blue-500`],"list.hoverBackground":X[`color-tv-blue-900`],"list.focusHighlightForeground":X[`color-tv-blue-300`],"list.inactiveSelectionBackground":X[`color-tv-blue-500`],"keybindingLabel.background":X[`color-cold-gray-800`],"keybindingLabel.foreground":X[`color-cold-gray-300`],"keybindingLabel.border":X[`color-cold-gray-700`],"input.foreground":X[`color-cold-gray-350`],"textLink.foreground":X[`color-tv-blue-500`],"textLink.activeForeground":X[`color-tv-blue-600`],"peekViewEditor.matchHighlightBackground":X[`color-tan-orange-a800`],"peekViewResult.lineForeground":X[`color-cold-gray-350`],"diffEditor.insertedTextBackground":CF(X[`color-iguana-green-a700`],.3),"diffEditor.insertedLineBackground":CF(X[`color-iguana-green-a700`],.15),"diffEditor.removedTextBackground":CF(X[`color-ripe-red-a400`],.3),"diffEditor.removedLineBackground":CF(X[`color-ripe-red-a400`],.15),"editorInlayHint.background":X[`color-cold-gray-800`],"editorInlayHint.foreground":X[`color-cold-gray-400`],"editorError.foreground":X[`color-ripe-red-500`],"editorWarning.foreground":X[`color-tan-orange-700`]}},EF={builtinFunctions:/strategy\.closedtrades\.max_drawdown_percent|strategy\.opentrades\.max_drawdown_percent|strategy\.risk\.max_intraday_filled_orders|strategy\.closedtrades\.max_runup_percent|array\.percentile_linear_interpolation|strategy\.closedtrades\.entry_bar_index|strategy\.opentrades\.max_runup_percent|strategy\.closedtrades\.exit_bar_index|strategy\.closedtrades\.profit_percent|strategy\.closedtrades\.entry_comment|strategy\.opentrades\.entry_bar_index|strategy\.closedtrades\.exit_comment|strategy\.closedtrades\.max_drawdown|strategy\.opentrades\.profit_percent|ta\.percentile_linear_interpolation|strategy\.closedtrades\.entry_price|strategy\.opentrades\.entry_comment|strategy\.closedtrades\.commission|strategy\.closedtrades\.entry_time|strategy\.closedtrades\.exit_price|strategy\.opentrades\.max_drawdown|strategy\.risk\.max_cons_loss_days|strategy\.closedtrades\.exit_time|strategy\.closedtrades\.max_runup|strategy\.opentrades\.entry_price|strategy\.risk\.max_intraday_loss|strategy\.risk\.max_position_size|table\.cell_set_text_font_family|strategy\.closedtrades\.entry_id|strategy\.opentrades\.commission|strategy\.opentrades\.entry_time|table\.cell_set_text_formatting|array\.binary_search_rightmost|array\.percentile_nearest_rank|strategy\.closedtrades\.exit_id|strategy\.opentrades\.direction|strategy\.opentrades\.max_runup|array\.binary_search_leftmost|strategy\.closedtrades\.profit|strategy\.opentrades\.entry_id|strategy\.risk\.allow_entry_in|strategy\.convert_to_account|box\.set_bottom_right_point|label\.set_text_font_family|strategy\.closedtrades\.size|strategy\.convert_to_symbol|strategy\.default_entry_qty|strategy\.opentrades\.profit|strategy\.risk\.max_drawdown|ta\.percentile_nearest_rank|table\.cell_set_text_halign|table\.cell_set_text_valign|label\.set_text_formatting|request\.security_lower_tf|table\.cell_set_text_color|box\.set_text_font_family|strategy\.close_all_short|strategy\.opentrades\.size|table\.cell_set_text_size|box\.set_text_formatting|matrix\.is_antisymmetric|strategy\.close_all_long|box\.set_top_left_point|chart\.point\.from_index|matrix\.is_antidiagonal|table\.cell_set_bgcolor|table\.cell_set_tooltip|table\.set_border_color|table\.set_border_width|timeframe\.from_seconds|chart\.point\.from_time|line\.set_second_point|math\.round_to_mintick|matrix\.elements_count|ta\.pivot_point_levels|table\.cell_set_height|table\.set_frame_color|table\.set_frame_width|box\.set_border_color|box\.set_border_style|box\.set_border_width|line\.set_first_point|matrix\.is_stochastic|matrix\.is_triangular|table\.cell_set_width|timeframe\.in_seconds|array\.binary_search|box\.set_rightbottom|box\.set_text_halign|box\.set_text_valign|color\.from_gradient|label\.set_textalign|label\.set_textcolor|matrix\.eigenvectors|matrix\.is_symmetric|matrix\.swap_columns|strategy\.cancel_all|table\.cell_set_text|array\.new_linefill|array\.sort_indices|box\.set_text_color|linefill\.get_line1|linefill\.get_line2|linefill\.set_color|map\.new|matrix\.eigenvalues|matrix\.is_diagonal|matrix\.is_identity|strategy\.close_all|table\.set_position|array\.lastindexof|array\.percentrank|array\.standardize|box\.set_text_size|box\.set_text_wrap|label\.set_tooltip|matrix\.remove_col|matrix\.remove_row|table\.merge_cells|table\.set_bgcolor|array\.covariance|array\.new_string|chart\.point\.copy|matrix\.is_binary|matrix\.is_square|matrix\.new|matrix\.submatrix|matrix\.swap_rows|matrix\.transpose|request\.security|timeframe\.change|array\.new|array\.new_color|array\.new_float|array\.new_label|array\.new_table|box\.set_bgcolor|box\.set_lefttop|chart\.point\.new|chart\.point\.now|input\.text_area|input\.timeframe|label\.set_color|label\.set_point|label\.set_style|line\.set_extend|linefill\.delete|polyline\.delete|str\.format_time|str\.replace_all|strategy\.cancel|alertcondition|array\.includes|array\.new_bool|array\.new_line|array\.variance|box\.get_bottom|box\.set_bottom|box\.set_extend|label\.get_text|label\.set_size|label\.set_text|label\.set_xloc|label\.set_yloc|line\.get_price|line\.set_color|line\.set_style|line\.set_width|math\.todegrees|math\.toradians|matrix\.add_col|matrix\.add_row|matrix\.columns|matrix\.is_zero|matrix\.reshape|matrix\.reverse|str\.startswith|strategy\.close|strategy\.entry|strategy\.order|syminfo\.prefix|syminfo\.ticker|ta\.correlation|ta\.highestbars|ta\.percentrank|array\.indexof|array\.new_box|array\.new_int|array\.reverse|array\.unshift|box\.get_right|box\.set_right|input\.session|line\.set_xloc|matrix\.concat|matrix\.median|max_bars_back|runtime\.error|str\.substring|strategy\.exit|ta\.crossunder|ta\.lowestbars|ta\.supertrend|array\.concat|array\.insert|array\.median|array\.remove|box\.get_left|box\.set_left|box\.set_text|box\.set_xloc|input\.source|input\.string|input\.symbol|label\.delete|label\.set_xy|line\.set_xy1|line\.set_xy2|linefill\.new|map\.contains|matrix\.trace|polyline\.new|str\.contains|str\.endswith|str\.tonumber|str\.tostring|ta\.barssince|ta\.crossover|ta\.pivothigh|ta\.valuewhen|table\.delete|array\.clear|array\.every|array\.first|array\.range|array\.shift|array\.slice|array\.stdev|box\.get_top|box\.set_top|input\.color|input\.float|input\.price|label\.get_x|label\.get_y|label\.set_x|label\.set_y|line\.delete|line\.get_x1|line\.get_x2|line\.get_y1|line\.get_y2|line\.set_x1|line\.set_x2|line\.set_y1|line\.set_y2|log\.warning|map\.put_all|math\.random|matrix\.copy|matrix\.diff|matrix\.fill|matrix\.kron|matrix\.mode|matrix\.mult|matrix\.pinv|matrix\.rank|matrix\.rows|matrix\.sort|str\.replace|ta\.pivotlow|ta\.variance|table\.clear|array\.copy|array\.fill|array\.from|array\.join|array\.last|array\.mode|array\.push|array\.size|array\.some|array\.sort|box\.delete|dayofmonth|input\.bool|input\.enum|input\.time|label\.copy|map\.remove|map\.values|math\.floor|math\.log10|math\.round|matrix\.avg|matrix\.col|matrix\.det|matrix\.get|matrix\.inv|matrix\.max|matrix\.min|matrix\.pow|matrix\.row|matrix\.set|matrix\.sum|plotcandle|str\.format|str\.length|str\.repeat|ta\.falling|ta\.highest|table\.cell|time_close|weekofyear|array\.abs|array\.avg|array\.get|array\.max|array\.min|array\.pop|array\.set|array\.sum|color\.new|color\.rgb|dayofweek|indicator|input\.int|label\.new|line\.copy|log\.error|map\.clear|math\.acos|math\.asin|math\.atan|math\.ceil|math\.sign|math\.sqrt|plotarrow|plotshape|str\.lower|str\.match|str\.split|str\.upper|ta\.change|ta\.linreg|ta\.lowest|ta\.median|ta\.rising|table\.new|timestamp|barcolor|box\.copy|line\.new|linefill|log\.info|map\.copy|map\.keys|map\.size|math\.abs|math\.avg|math\.cos|math\.exp|math\.log|math\.max|math\.min|math\.pow|math\.sin|math\.sum|math\.tan|plotchar|str\.trim|strategy|ta\.cross|ta\.range|ta\.stdev|ta\.stoch|bgcolor|box\.new|color\.b|color\.g|color\.r|color\.t|library|map\.get|map\.put|plotbar|str\.pos|ta\.alma|ta\.macd|ta\.mode|ta\.swma|ta\.vwap|ta\.vwma|fixnan|minute|second|string|ta\.atr|ta\.bbw|ta\.cci|ta\.cmo|ta\.cog|ta\.cum|ta\.dev|ta\.dmi|ta\.ema|ta\.hma|ta\.kcw|ta\.max|ta\.mfi|ta\.min|ta\.mom|ta\.rci|ta\.rma|ta\.roc|ta\.rsi|ta\.sar|ta\.sma|ta\.tsi|ta\.wma|ta\.wpr|alert|color|float|hline|input|label|month|ta\.bb|ta\.kc|ta\.tr|table|bool|fill|hour|line|plot|time|year|box|int|na|nz/,keywords:/continue|for\.\.\.in|export|import|method|switch|break|varip|while|else|enum|type|and|for|not|var|as|by|if|in|or|to/,tokenizer:{root:[[/\/\/\s*(?=@)/,`comment`,`@comments`],[/\/\/.*(?!@).*/,`comment`],[/\'([^\'\\]|\\.)*$/,`string.invalid`],[/'([^'\\]|\\.)*$/,`string.invalid`],[/\"/,{token:`string`,bracket:`@open`,next:`@stringDouble`}],[/(type|enum)\s+[a-zA-Z]\w*/,`entity.name.type`],[/'/,{token:`string`,bracket:`@open`,next:`@stringSingle`}],[/(@builtinFunctions)(?=\s*\(|\s*<.*>)/,{token:`support.function`,next:`@template`}],[/@punctuation/,{token:`punctuation.operator`,next:`@property`}],[/(varip|var)\b(\s+)((?!(?:chart\.point|linefill|polyline|matrix|series|simple|string|array|color|const|float|label|table|bool|line|box|int|map|continue|for\.\.\.in|export|import|method|switch|break|varip|while|else|type|enum|and|for|not|var|as|by|if|in|or|to)\b)[\w.\d_$]+)(\[\]|)(\s+)((?!(?:continue|for\.\.\.in|export|import|method|switch|break|varip|while|else|type|enum|and|for|not|var|as|by|if|in|or|to)\b)[\w\d_$]+)/,[{token:`keyword`},{token:`source`},{token:`entity.name.type`},{token:`paren`},{token:`source`},{token:`variable.other`}]],[/\b(?:@builtinTypes)(?=(\s*)[\[|<|(]|(?=\s+(?=[^.=][\w\(]*))|\s*$)/,{token:`support.type`,next:`@template`}],[/^(\s*)\b(?!(?:chart\.point|linefill|polyline|matrix|series|simple|string|array|color|const|float|label|table|bool|line|box|int|map|continue|for\.\.\.in|export|import|method|switch|break|varip|while|else|type|enum|and|for|not|var|as|by|if|in|or|to)\b)([\w.\d_$]+)(\[\]|)(\s+)((?!(?:continue|for\.\.\.in|export|import|method|switch|break|varip|while|else|type|enum|and|for|not|var|as|by|if|in|or|to)\b)[\w\d_$]+)(\s+)(\=)/,[{token:`source`},{token:`entity.name.type`},{token:`paren`},{token:`source`},{token:`variable.other`},{token:`source`},{token:`keyword.equals`}]],[/(\((?:\s+))?((?!(?:chart\.point|linefill|polyline|continue|for\.\.\.in|matrix|series|simple|string|export|import|method|switch|array|color|const|float|label|table|break|varip|while|bool|line|else|type|enum|box|int|map|and|for|not|var|as|by|if|in|or|to)\b)\b[\w.\d_$]+(?=[\[\]]*(?:\s+)(?:[\w\d_$]+\s*(?:\,|\))+\s*).+(?:\=\>|\→)))/,`entity.name.type`],[/import(?=\s+@importName)/,{token:`keyword`,next:`@import`}],[/import(?=\s+[a-zA-Z\d\$_\-\.\u00a1-\uffff\/]+)/,`keyword`],[/[+-]?\d+\.\d*([eE][\-+]?\d+)?(?!\w+)/,`constant.numeric.float`],[/[+-]?\.\d+([eE][\-+]?\d+)?(?!\w+)/,`constant.numeric.float`],[/([+-]?(\d+))(?!\w+)(?!\w+)/,`constant.numeric.integer`],[/(?:true|false)\b/,`constant.other.boolean`],[/#[0-9a-fA-F]{6,8}\b/,`constant.other.color`],[/\+=|\-=|\*=|\/=|%=|[\/%*+\-]|==|!=|<=|>=|=>|<|>|\?|\:=|\:|\,/,`keyword.operator`],[/\b(?:continue|for\.\.\.in|export|import|method|switch|break|varip|while|else|type|enum|and|for|not|var|as|by|if|in|or|to)\b/,`keyword`],[/^[a-zA-Z_][a-zA-Z_0-9]+(?=\s*\()/,`entity.name.function`],[/[0-9]+\b/,`constant.numeric.integer`],[/=/,`keyword.equals`],[/\b(?:@builtinVariables)\b(?!\s*=\s*\w+)/,`support.variable`],[/[(|)|\[|\]]/,`paren`],[/[a-zA-Z_][a-zA-Z_0-9]*(?=\s*\()/,{token:`entity.name.method`}],[/\w+\b/,`variable.other`]],comments:[[/@[A-Za-z]+(\s*=\s*)?$/,{token:`comment.annotation`,next:`@pop`}],[/@[A-Za-z]+(\s*=\s*)?/,{token:`comment.annotation`}],[/(?!\s*@[A-Za-z]+).+$/,{token:`comment`,next:`@pop`}]],stringDouble:[[/[^\\\"]+/,`string`],[/\\./,`string.invalid`],[/\"/,{token:`string.quote`,bracket:`@close`,next:`@pop`}]],stringSingle:[[/[^\\']+/,`string`],[/\\./,`string.invalid`],[/'/,{token:`string`,bracket:`@close`,next:`@pop`}]],template:[[/(@builtinTypes)/,{token:`support.type`}],[/(\((?:\s+))?((?!(?:chart\.point|linefill|polyline|continue|for\.\.\.in|matrix|series|simple|string|export|import|method|switch|array|color|const|float|label|table|break|varip|while|bool|line|else|type|enum|box|int|map|and|for|not|var|as|by|if|in|or|to)\b)\b[\w.\d_$]+(?=[\[\]]*(?:\s+)(?:[\w\d_$]+\s*(?:\,|\))+\s*).+(?:\=\>|\→)))/,`entity.name.type`],[/\(|\)|\[|\]|\=|\>/,{token:`paren`,next:`@pop`}],[/(\,)(\s+)/,[`keyword.operator`,`source`]],[/(\,)/,{token:`keyword.operator`}],[/([\w.\d$]+)/,{token:`entity.name.type`}],[/(<|>)/,{token:`paren`}],[/\s(?=\w)|$/,{token:`source`,next:`@pop`}]],property:[[/@punctuation/,{token:`punctuation.operator`}],[/(@builtinTypes)(?=\s*[(])/,{token:`support.method`,next:`@pop`}],[/[a-zA-Z_][a-zA-Z_0-9]+(?=\s*\()/,{token:`entity.name.method`,next:`@pop`}],[/[a-zA-Z0-9_]+/,{token:`variable.other.property`,next:`@pop`}],[/@empty/,{token:`source`,next:`@pop`}]],import:[[/\s+/,{token:`source`}],[/(@importName)(\s+)(as\b)(\s+)(@importAlias)/,[{token:`entity.name.module`},{token:`source`},{token:`keyword`},{token:`source`},{token:`entity.name.module.name`,next:`@pop`}]],[/@importName/,{token:`entity.name.module`,next:`@pop`}]]},builtinVariables:/strategy\.commission\.cash_per_contract|syminfo\.recommendations_sell_strong|strategy\.commission\.cash_per_order|strategy\.avg_winning_trade_percent|syminfo\.recommendations_buy_strong|strategy\.avg_losing_trade_percent|strategy\.closedtrades\.first_index|strategy\.margin_liquidation_price|strategy\.max_contracts_held_short|strategy\.max_contracts_held_long|strategy\.opentrades\.capital_held|syminfo\.shares_outstanding_float|syminfo\.shares_outstanding_total|barstate\.islastconfirmedhistory|earnings\.future_period_end_time|strategy\.max_contracts_held_all|syminfo\.target_price_estimates|alert\.freq_once_per_bar_close|label\.style_label_lower_right|label\.style_label_upper_right|strategy\.max_drawdown_percent|syminfo\.recommendations_total|label\.style_label_lower_left|label\.style_label_upper_left|chart\.right_visible_bar_time|strategy\.grossprofit_percent|strategy\.position_entry_name|strategy\.position_size_short|strategy\.position_size_total|strategy\.price_highest_short|syminfo\.recommendations_date|syminfo\.recommendations_hold|syminfo\.recommendations_sell|syminfo\.target_price_average|plot\.style_stepline_diamond|strategy\.commission\.percent|chart\.left_visible_bar_time|strategy\.openprofit_percent|strategy\.position_avg_price|strategy\.position_size_long|strategy\.price_highest_long|strategy\.price_lowest_short|syminfo\.recommendations_buy|syminfo\.target_price_median|strategy\.percent_of_equity|session\.isfirstbar_regular|strategy\.avg_trade_percent|strategy\.avg_winning_trade|strategy\.grossloss_percent|strategy\.max_runup_percent|strategy\.netprofit_percent|strategy\.price_first_short|strategy\.price_lowest_long|dividends\.future_pay_date|session\.islastbar_regular|strategy\.account_currency|strategy\.avg_losing_trade|strategy\.openprofit_short|strategy\.opentrades_short|strategy\.price_first_long|strategy\.price_last_short|syminfo\.target_price_date|syminfo\.target_price_high|label\.style_label_center|label\.style_text_outline|label\.style_triangledown|strategy\.direction\.short|dividends\.future_ex_date|strategy\.avg_price_short|strategy\.initial_capital|strategy\.openprofit_long|strategy\.opentrades_long|strategy\.price_last_long|syminfo\.current_contract|syminfo\.target_price_low|alert\.freq_once_per_bar|label\.style_label_right|strategy\.direction\.long|dividends\.future_amount|earnings\.future_revenue|strategy\.avg_price_long|syminfo\.expiration_date|barmerge\.lookahead_off|label\.style_label_down|label\.style_label_left|label\.style_triangleup|line\.style_arrow_right|position\.bottom_center|position\.middle_center|strategy\.direction\.all|strategy\.position_size|barmerge\.lookahead_on|earnings\.standardized|font\.family_monospace|label\.style_arrowdown|line\.style_arrow_both|line\.style_arrow_left|plot\.style_steplinebr|position\.bottom_right|position\.middle_right|strategy\.closedtrades|strategy\.max_drawdown|syminfo\.main_tickerid|timeframe\.main_period|label\.style_label_up|plot\.style_histogram|position\.bottom_left|position\.middle_left|barstate\.isconfirmed|earnings\.future_time|session\.ispostmarket|strategy\.grossprofit|syminfo\.basecurrency|syminfo\.shareholders|timeframe\.isintraday|timeframe\.multiplier|dayofweek\.wednesday|display\.data_window|display\.price_scale|display\.status_line|font\.family_default|label\.style_arrowup|label\.style_diamond|plot\.style_stepline|position\.top_center|strategy\.oca\.cancel|strategy\.oca\.reduce|barstate\.isrealtime|chart\.is_heikinashi|earnings\.future_eps|session\.ispremarket|strategy\.eventrades|strategy\.losstrades|strategy\.openprofit|strategy\.opentrades|syminfo\.description|syminfo\.mincontract|timeframe\.isminutes|timeframe\.ismonthly|timeframe\.isseconds|dayofweek\.saturday|dayofweek\.thursday|hline\.style_dashed|hline\.style_dotted|label\.style_circle|label\.style_square|label\.style_xcross|plot\.style_circles|plot\.style_columns|position\.top_right|shape\.triangledown|splits\.denominator|text\.format_italic|barstate\.ishistory|chart\.is_linebreak|session\.isfirstbar|strategy\.avg_trade|strategy\.grossloss|strategy\.max_runup|strategy\.netprofit|strategy\.wintrades|syminfo\.pointvalue|syminfo\.pricescale|syminfo\.volumetype|timeframe\.isweekly|barmerge\.gaps_off|dayofweek\.tuesday|earnings\.estimate|hline\.style_solid|label\.style_cross|line\.style_dashed|line\.style_dotted|location\.abovebar|location\.absolute|location\.belowbar|plot\.style_areabr|plot\.style_linebr|position\.top_left|strategy\.oca\.none|text\.align_bottom|text\.align_center|chart\.is_standard|session\.islastbar|syminfo\.employees|timeframe\.isdaily|barmerge\.gaps_on|dayofweek\.friday|dayofweek\.monday|dayofweek\.sunday|label\.style_flag|label\.style_none|line\.style_solid|order\.descending|plot\.style_cross|session\.extended|shape\.triangleup|splits\.numerator|text\.align_right|text\.format_bold|text\.format_none|barstate\.isfirst|session\.ismarket|syminfo\.currency|syminfo\.industry|syminfo\.tickerid|syminfo\.timezone|timeframe\.period|dividends\.gross|earnings\.actual|location\.bottom|order\.ascending|plot\.style_area|plot\.style_line|session\.regular|shape\.arrowdown|shape\.labeldown|text\.align_left|barstate\.islast|strategy\.equity|syminfo\.country|syminfo\.minmove|syminfo\.mintick|syminfo\.session|time_tradingday|timeframe\.isdwm|alert\.freq_all|format\.inherit|format\.mintick|format\.percent|strategy\.fixed|strategy\.short|text\.align_top|text\.wrap_auto|text\.wrap_none|xloc\.bar_index|barstate\.isnew|chart\.bg_color|chart\.fg_color|chart\.is_range|chart\.is_renko|last_bar_index|syminfo\.prefix|syminfo\.sector|syminfo\.ticker|color\.fuchsia|currency\.NONE|currency\.USDT|dividends\.net|format\.volume|shape\.arrowup|shape\.diamond|shape\.labelup|strategy\.cash|strategy\.long|xloc\.bar_time|yloc\.abovebar|yloc\.belowbar|chart\.is_kagi|last_bar_time|color\.maroon|color\.orange|color\.purple|color\.silver|color\.yellow|currency\.AUD|currency\.BTC|currency\.CAD|currency\.CHF|currency\.EGP|currency\.ETH|currency\.EUR|currency\.GBP|currency\.HKD|currency\.INR|currency\.JPY|currency\.KRW|currency\.MYR|currency\.NOK|currency\.NZD|currency\.PKR|currency\.PLN|currency\.RUB|currency\.SEK|currency\.SGD|currency\.TRY|currency\.USD|currency\.ZAR|display\.none|display\.pane|extend\.right|format\.price|location\.top|shape\.circle|shape\.square|shape\.xcross|chart\.is_pnf|linefill\.all|polyline\.all|syminfo\.root|syminfo\.type|color\.black|color\.green|color\.olive|color\.white|display\.all|extend\.both|extend\.left|extend\.none|scale\.right|shape\.cross|size\.normal|color\.aqua|color\.blue|color\.gray|color\.lime|color\.navy|color\.teal|scale\.left|scale\.none|shape\.flag|size\.large|size\.small|yloc\.price|dayofmonth|ta\.accdist|time_close|weekofyear|color\.red|math\.rphi|size\.auto|size\.huge|size\.tiny|bar_index|dayofweek|label\.all|table\.all|math\.phi|line\.all|math\.pi|box\.all|ta\.vwap|ta\.wvad|timenow|math\.e|minute|second|ta\.iii|ta\.nvi|ta\.obv|ta\.pvi|ta\.pvt|ta\.wad|volume|false|close|hlcc4|month|ohlc4|ta\.tr|true|high|hlc3|hour|open|time|year|ask|bid|hl2|low|na/,builtinTypes:/chart\.point|linefill|polyline|matrix|series|simple|string|array|color|const|float|label|table|bool|line|box|int|map/,punctuation:/[.](?![.])/,importName:/[a-zA-Z\d\$_\-\.\u00a1-\uffff\/]+/,importAlias:/[a-zA-Z\d\_\u00a1\uffff\/]+/,empty:/^$/},DF={None:0,Indent:1,IndentOutdent:2,Outdent:3},OF={wordPattern:/(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,comments:{lineComment:`//`,blockComment:[`/*`,`*/`]},brackets:[[`(`,`)`],[`[`,`]`]],folding:{markers:{start:/(\/\/#region)|(\/\/.*{($|\s))/,end:/(\/\/#endregion)|(\/\/.*}($|\s))/}},autoClosingPairs:[{open:`{`,close:`}`},{open:`[`,close:`]`},{open:`(`,close:`)`},{open:`"`,close:`"`},{open:`'`,close:`'`}],surroundingPairs:[{open:`{`,close:`}`},{open:`[`,close:`]`},{open:`(`,close:`)`},{open:`"`,close:`"`},{open:`'`,close:`'`},{open:`<`,close:`>`}],onEnterRules:[{beforeText:/\)\s*=>\s*$/,action:{indentAction:DF.Indent}},{beforeText:/if\s+.*\s*$/,action:{indentAction:DF.Indent}},{beforeText:/else/,action:{indentAction:DF.Indent}},{beforeText:/for\s+\S+\s*=\s*\S+\s+to\s+\S+(?:\s+by\s+\S+)?\s*$/,action:{indentAction:DF.Indent}},{beforeText:/for\s+(?:\[\S+\s+\S+]|\S+)\s+in\s+\S+\s*$/,action:{indentAction:DF.Indent}},{beforeText:/switch\s+.*\s*$/,action:{indentAction:DF.Indent}},{beforeText:/while\s+.*\s*$/,action:{indentAction:DF.Indent}},{beforeText:/type\s+\w+/,action:{indentAction:DF.Indent}},{beforeText:/enum\s+\w+/,action:{indentAction:DF.Indent}},{beforeText:/^\s*$/,action:{indentAction:DF.Outdent}}]},Z={"color-white":`#ffffff`,"color-black":`#000000`,"color-transparent":`#00000000`,"color-cold-gray-50":`#F8F9FD`,"color-cold-gray-100":`#F0F3FA`,"color-cold-gray-150":`#E0E3EB`,"color-cold-gray-200":`#D1D4DC`,"color-cold-gray-250":`#C1C4CD`,"color-cold-gray-300":`#B2B5BE`,"color-cold-gray-350":`#A3A6AF`,"color-cold-gray-400":`#9598A1`,"color-cold-gray-450":`#868993`,"color-cold-gray-500":`#787B86`,"color-cold-gray-550":`#6A6D78`,"color-cold-gray-600":`#5D606B`,"color-cold-gray-650":`#50535E`,"color-cold-gray-700":`#434651`,"color-cold-gray-750":`#363A45`,"color-cold-gray-800":`#2A2E39`,"color-cold-gray-850":`#1E222D`,"color-cold-gray-900":`#131722`,"color-cold-gray-950":`#0C0E15`,"color-ripe-red-50":`#FFEBEC`,"color-ripe-red-100":`#FCCBCD`,"color-ripe-red-200":`#FAA1A4`,"color-ripe-red-300":`#F77C80`,"color-ripe-red-400":`#F7525F`,"color-ripe-red-500":`#F23645`,"color-ripe-red-600":`#CC2F3C`,"color-ripe-red-700":`#B22833`,"color-ripe-red-800":`#991F29`,"color-ripe-red-900":`#801922`,"color-ripe-red-a100":`#FF8080`,"color-ripe-red-a200":`#FF5252`,"color-ripe-red-a400":`#FF3333`,"color-ripe-red-a600":`#CC2929`,"color-ripe-red-a700":`#802028`,"color-ripe-red-a800":`#4D191D`,"color-ripe-red-a900":`#331F20`,"color-tan-orange-50":`#FFF3E0`,"color-tan-orange-100":`#FFE0B2`,"color-tan-orange-200":`#FFCC80`,"color-tan-orange-300":`#ffb74d`,"color-tan-orange-400":`#FFA726`,"color-tan-orange-500":`#FF9800`,"color-tan-orange-600":`#FB8C00`,"color-tan-orange-700":`#F57C00`,"color-tan-orange-800":`#EF6C00`,"color-tan-orange-900":`#e65100`,"color-tan-orange-a200":`#ffab40`,"color-tan-orange-a400":`#FF9100`,"color-tan-orange-a600":`#CC7014`,"color-tan-orange-a700":`#8C541C`,"color-tan-orange-a800":`#593A1B`,"color-tan-orange-a900":`#33261A`,"color-iguana-green-100":`#C8E6C9`,"color-iguana-green-200":`#A5D6A7`,"color-iguana-green-300":`#81c784`,"color-iguana-green-400":`#66BB6A`,"color-iguana-green-500":`#4caf50`,"color-iguana-green-600":`#43a047`,"color-iguana-green-700":`#388e3c`,"color-iguana-green-800":`#2E7D32`,"color-iguana-green-900":`#1B5E20`,"color-iguana-green-a700":`#00c853`,"color-banana-yellow-100":`#FFF9C4`,"color-banana-yellow-200":`#FFF59D`,"color-banana-yellow-300":`#FFF176`,"color-banana-yellow-400":`#ffee58`,"color-banana-yellow-500":`#ffeb3b`,"color-banana-yellow-600":`#fdd835`,"color-banana-yellow-700":`#fbc02d`,"color-banana-yellow-800":`#f9a825`,"color-banana-yellow-900":`#F57F17`,"color-banana-yellow-a400":`#ffea00`,"color-banana-yellow-a700":`#EEDA01`,"color-tv-blue-50":`#E3EFFD`,"color-tv-blue-100":`#BBD9FB`,"color-tv-blue-200":`#90BFF9`,"color-tv-blue-300":`#5B9CF6`,"color-tv-blue-400":`#3179F5`,"color-tv-blue-500":`#2962FF`,"color-tv-blue-600":`#1E53E5`,"color-tv-blue-700":`#1848CC`,"color-tv-blue-800":`#143EB3`,"color-tv-blue-900":`#0C3299`,"color-tv-blue-a100":`#82b1ff`,"color-tv-blue-a200":`#448aff`,"color-tv-blue-a400":`#2979ff`,"color-tv-blue-a600":`#2962FF`,"color-tv-blue-a700":`#143A87`,"color-tv-blue-a800":`#142E61`,"color-tv-blue-a900":`#132042`,"color-deep-blue-50":`#EDE7F6`,"color-deep-blue-100":`#D1C4E9`,"color-deep-blue-200":`#B39DDB`,"color-deep-blue-300":`#9575cd`,"color-deep-blue-400":`#7e57c2`,"color-deep-blue-500":`#673ab7`,"color-deep-blue-700":`#512da8`,"color-deep-blue-800":`#4527A0`,"color-deep-blue-900":`#311B92`,"color-deep-blue-a100":`#b388ff`,"color-deep-blue-a200":`#7C4DFF`,"color-deep-blue-a400":`#651FFF`,"color-deep-blue-a700":`#6200EA`,"color-minty-green-50":`#DAF2EE`,"color-minty-green-100":`#ACE5DC`,"color-minty-green-200":`#70CCBD`,"color-minty-green-300":`#42BDA8`,"color-minty-green-400":`#22AB94`,"color-minty-green-500":`#089981`,"color-minty-green-600":`#06806B`,"color-minty-green-700":`#056656`,"color-minty-green-800":`#004D40`,"color-minty-green-900":`#00332A`,"color-minty-green-a400":`#2BD9BC`,"color-minty-green-a600":`#24B29B`,"color-minty-green-a700":`#1B7667`,"color-minty-green-a800":`#10443B`,"color-minty-green-a900":`#082621`,"color-grapes-purple-50":`#F3E5F5`,"color-grapes-purple-100":`#E1BEE7`,"color-grapes-purple-200":`#CE93D8`,"color-grapes-purple-300":`#ba68c8`,"color-grapes-purple-400":`#ab47bc`,"color-grapes-purple-500":`#9c27b0`,"color-grapes-purple-600":`#8e24aa`,"color-grapes-purple-700":`#7b1fa2`,"color-grapes-purple-800":`#6A1B9A`,"color-grapes-purple-900":`#4A148C`,"color-grapes-purple-a100":`#EA80FC`,"color-grapes-purple-a200":`#E040FB`,"color-grapes-purple-a400":`#D500F9`,"color-grapes-purple-a700":`#aa00ff`,"color-berry-pink-100":`#F8BBD0`,"color-berry-pink-200":`#f48fb1`,"color-berry-pink-300":`#f06292`,"color-berry-pink-400":`#ec407a`,"color-berry-pink-500":`#e91e63`,"color-berry-pink-600":`#D81B60`,"color-berry-pink-700":`#C2185B`,"color-berry-pink-800":`#AD1457`,"color-berry-pink-900":`#880E4F`,"color-berry-pink-a100":`#ff80ab`,"color-berry-pink-a200":`#ff4081`,"color-berry-pink-a400":`#f50057`,"color-sky-blue-100":`#B2EBF2`,"color-sky-blue-200":`#80DEEA`,"color-sky-blue-300":`#4dd0e1`,"color-sky-blue-400":`#26c6da`,"color-sky-blue-500":`#00bcd4`,"color-sky-blue-600":`#00acc1`,"color-sky-blue-700":`#0097A7`,"color-sky-blue-800":`#00838F`,"color-sky-blue-900":`#006064`,"color-sky-blue-a400":`#00e5ff`,"color-sky-blue-a700":`#00B8D4`,"color-deep-blue-600":`#5E35B1`,"color-forest-green-50":`#DAF2E6`,"color-forest-green-100":`#ACE5C9`,"color-forest-green-200":`#70CC9E`,"color-forest-green-300":`#42BD7F`,"color-forest-green-400":`#22AB67`,"color-forest-green-500":`#089950`,"color-forest-green-600":`#068043`,"color-forest-green-700":`#056636`,"color-forest-green-800":`#004D27`,"color-forest-green-900":`#1A3326`,"color-facebook":`#1877F2`,"color-deep-facebook":`#1564CA`,"color-twitter":`#1DA1F2`,"color-deep-twitter":`#188CD3`,"color-youtube":`#FF0000`,"color-linkedin":`#007BB5`,"color-seeking-alpha-brand":`#ff7200`};function kF(e,t=1){return e+Math.round(255*Math.min(Math.max(t,0),1)).toString(16).toUpperCase().padStart(2,`0`)}Z[`color-cold-gray-400`],Z[`color-cold-gray-900`],Z[`color-iguana-green-700`],Z[`color-banana-yellow-900`],Z[`color-ripe-red-a600`],Z[`color-ripe-red-a600`],Z[`color-ripe-red-a600`],Z[`color-ripe-red-a600`],Z[`color-tv-blue-a600`],Z[`color-minty-green-400`],Z[`color-minty-green-400`],Z[`color-tv-blue-a600`],Z[`color-minty-green-400`],Z[`color-minty-green-400`],Z[`color-minty-green-400`],Z[`color-minty-green-400`],Z[`color-cold-gray-800`],Z[`color-cold-gray-800`],Z[`color-black`],Z[`color-tv-blue-900`],Z[`color-tv-blue-900`],Z[`color-grapes-purple-600`],Z[`color-grapes-purple-600`],Z[`color-tv-blue-a600`],Z[`color-white`],Z[`color-cold-gray-900`],Z[`color-cold-gray-400`],Z[`color-cold-gray-700`],Z[`color-white`],Z[`color-cold-gray-150`],Z[`color-cold-gray-900`],Z[`color-white`],Z[`color-cold-gray-900`],kF(Z[`color-cold-gray-200`],.5),Z[`color-tv-blue-50`],Z[`color-tv-blue-50`],Z[`color-tv-blue-100`],Z[`color-cold-gray-150`],Z[`color-tv-blue-100`],Z[`color-tv-blue-50`],Z[`color-tan-orange-100`],Z[`color-tan-orange-100`],Z[`color-tan-orange-500`],Z[`color-cold-gray-900`],Z[`color-cold-gray-900`],Z[`color-tv-blue-500`],Z[`color-tv-blue-50`],Z[`color-tv-blue-100`],Z[`color-tv-blue-500`],Z[`color-white`],Z[`color-cold-gray-900`],Z[`color-cold-gray-150`],Z[`color-cold-gray-900`],Z[`color-tv-blue-500`],Z[`color-tv-blue-600`],Z[`color-tan-orange-100`],Z[`color-cold-gray-900`],Z[`color-banana-yellow-800`],Z[`color-banana-yellow-800`],kF(Z[`color-forest-green-500`],.3),kF(Z[`color-forest-green-500`],.15),kF(Z[`color-ripe-red-500`],.3),kF(Z[`color-ripe-red-500`],.15),Z[`color-cold-gray-150`],Z[`color-cold-gray-550`],Z[`color-ripe-red-500`],Z[`color-tan-orange-500`],Z[`color-cold-gray-500`],Z[`color-white`],Z[`color-iguana-green-700`],Z[`color-banana-yellow-900`],Z[`color-ripe-red-300`],Z[`color-ripe-red-300`],Z[`color-ripe-red-300`],Z[`color-ripe-red-300`],Z[`color-tv-blue-300`],Z[`color-tv-blue-300`],Z[`color-minty-green-300`],Z[`color-minty-green-300`],Z[`color-minty-green-300`],Z[`color-minty-green-300`],Z[`color-minty-green-300`],Z[`color-minty-green-300`],Z[`color-cold-gray-200`],Z[`color-cold-gray-200`],Z[`color-white`],Z[`color-tv-blue-400`],Z[`color-tv-blue-400`],Z[`color-grapes-purple-300`],Z[`color-grapes-purple-300`],Z[`color-tv-blue-300`],Z[`color-cold-gray-900`],Z[`color-white`],Z[`color-cold-gray-900`],Z[`color-cold-gray-500`],Z[`color-cold-gray-300`],Z[`color-cold-gray-850`],Z[`color-cold-gray-850`],Z[`color-cold-gray-300`],Z[`color-cold-gray-900`],Z[`color-cold-gray-300`],Z[`color-cold-gray-900`],kF(Z[`color-cold-gray-700`],.5),Z[`color-tv-blue-a900`],Z[`color-tv-blue-a900`],Z[`color-tv-blue-a800`],Z[`color-cold-gray-750`],Z[`color-tv-blue-a800`],Z[`color-cold-gray-800`],Z[`color-cold-gray-350`],Z[`color-cold-gray-350`],Z[`color-tv-blue-500`],Z[`color-tv-blue-900`],Z[`color-tv-blue-300`],Z[`color-tv-blue-500`],Z[`color-cold-gray-800`],Z[`color-cold-gray-300`],Z[`color-cold-gray-700`],Z[`color-cold-gray-350`],Z[`color-tv-blue-500`],Z[`color-tv-blue-600`],Z[`color-tan-orange-a800`],Z[`color-cold-gray-350`],kF(Z[`color-iguana-green-a700`],.3),kF(Z[`color-iguana-green-a700`],.15),kF(Z[`color-ripe-red-a400`],.3),kF(Z[`color-ripe-red-a400`],.15),Z[`color-cold-gray-800`],Z[`color-cold-gray-400`],Z[`color-ripe-red-500`],Z[`color-tan-orange-700`];function AF(){r.languages.register({id:SF}),r.editor.defineTheme(`vs-dark`,TF),r.editor.defineTheme(`vs`,wF),r.languages.setMonarchTokensProvider(SF,EF),r.languages.setLanguageConfiguration(SF,OF)}function jF(e,t){return MF.apply(this,arguments)}function MF(){return MF=w(function*(e,t){return t&&r.editor.setTheme(t.includes(`dark`)?`vs-dark`:`light`),yield r.editor.colorize(e,SF,{tabSize:4})}),MF.apply(this,arguments)}function NF(e=`light`){r.editor.setTheme(e.includes(`dark`)?`vs-dark`:`light`)}var PF=20;function FF(e,t,n){var r;let i=qa(),a=q(e=>e.threadListItem),[o,s]=(0,h.useState)([]),c=(0,h.useCallback)(e=>{s([...e])},[]),[l,u]=(0,h.useState)(!1),[d,f]=(0,h.useState)(!0),[p,m]=(0,h.useState)(!1),[g,_]=(0,h.useState)(0),v=(r=_F(a))==null?``:r,y=(0,h.useRef)(null),b=(0,h.useRef)(!1);(0,h.useEffect)(()=>{let e=!1;function t(){return n.apply(this,arguments)}function n(){return n=w(function*(){if(s([]),_(0),m(!1),f(!0),!v)f(!1);else try{let t=yield yF(v,0,PF);if(e)return;s([...t.messages].reverse().map(gF)),_(0),m(t.pagination.hasMore)}catch(t){e||console.error(`加载会话历史失败:`,t)}finally{e||f(!1)}}),n.apply(this,arguments)}return t(),()=>{e=!0}},[a.id]);let x=(0,h.useCallback)(function(){var r=w(function*(r,a=!1){var o;let c=crypto.randomUUID(),l=crypto.randomUUID(),d=new AbortController;y.current=d;let f=r.content.flatMap(e=>e.type===`text`?[{type:`text`,text:e.text}]:[]),p={id:c,role:`user`,content:f,attachments:(o=r.attachments)==null?[]:o,createdAt:new Date,metadata:{custom:{}}},h={id:l,role:`assistant`,content:[],createdAt:new Date,status:{type:`running`},metadata:{unstable_state:{},unstable_annotations:[],unstable_data:[],steps:[],custom:{}}};s(e=>{let t=e;if(a){let n=e.findIndex(e=>e.id===r.parentId);t=n===-1?[]:e.slice(0,n+1)}return[...t,p,h]}),u(!0);try{var g=!1,v=!1,b;try{for(var x=z(tF({token:e.current||``,userMessage:{id:c,content:f},abortSignal:d.signal,getConversationId:()=>{var e;return(e=_F(i.threadListItem.getState()))==null?``:e},onConversationCreated:e=>{var t;let r=i.threadListItem.getState();uF(r.id,e),i.threadListItem.updateCustom(E(E({},r.custom),{},{conversationId:e})),(t=n.current)==null||t.call(n,e),_(0),m(!1)},onCustomEvent:e=>{var n;(n=t.current)==null||n.call(t,e)}})),S;g=!(S=yield x.next()).done;g=!1){let e=S.value;s(t=>t.map(t=>t.id!==l||t.role!==`assistant`?t:E(E({},t),{},{content:e})))}}catch(e){v=!0,b=e}finally{try{g&&x.return!=null&&(yield x.return())}finally{if(v)throw b}}if(d.signal.aborted){s(e=>e.filter(e=>e.id!==l));return}s(e=>e.map(e=>e.id!==l||e.role!==`assistant`?e:E(E({},e),{},{status:{type:`complete`,reason:`stop`}})))}catch(e){if(s(e=>e.filter(e=>e.id!==l)),!d.signal.aborted)throw e}finally{y.current===d&&(y.current=null),u(!1)}});return function(e){return r.apply(this,arguments)}}(),[i]);return Xp({messages:o,setMessages:c,isRunning:l,isLoading:d,onNew:(0,h.useCallback)(e=>x(e),[x]),onEdit:(0,h.useCallback)(e=>x(e,!0),[x]),onCancel:(0,h.useCallback)(w(function*(){var e;(e=y.current)==null||e.abort()}),[]),hasEarlier:p,onLoadEarlier:(0,h.useCallback)(w(function*(){if(v&&p&&!b.current){b.current=!0;try{let e=g+1,t=yield yF(v,e,PF),n=[...t.messages].reverse().map(gF);s(e=>{let t=new Set(e.map(e=>e.id));return[...n.filter(e=>!t.has(e.id)),...e]}),_(e),m(t.pagination.hasMore)}finally{b.current=!1}}}),[v,g,p])})}AF();function IF({children:e,token:t,onCustomEvent:n}){let[r,i]=(0,h.useState)(),a=(0,h.useRef)(!1),o=(0,h.useRef)(t),s=(0,h.useRef)(n);(0,h.useEffect)(()=>{s.current=n},[n]),fF(t),(0,h.useEffect)(()=>{o.current=t},[t]);let c=(0,h.useRef)(()=>{}),l=(0,h.useCallback)(e=>{a.current&&(i(e),!e||vF(e)?lF():cF(e))},[]),u=(0,h.useCallback)(function(){return FF(o,s,c)},[]);(0,h.useEffect)(()=>{let e=!1;function t(){return n.apply(this,arguments)}function n(){return n=w(function*(){let t=sF();if(t)try{let n=yield xF.fetch(t);if(e)return;i(n.remoteId)}catch(t){if(e)return;lF(),i(void 0)}finally{e||(a.current=!0)}else{if(e)return;i(void 0),a.current=!0}}),n.apply(this,arguments)}return t(),c.current=e=>{cF(e)},()=>{e=!0}},[]);let d=Zh({runtimeHook:u,adapter:xF,threadId:r,onThreadIdChange:l});return(0,J.jsx)(Ty,{runtime:d,children:e})}var LF=e=>e==null?void 0:e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase();function RF(e,t,n=[]){if(t==null)throw Error(`[lucide]: iconNode is required when icon name is used`);return E({name:LF(e),size:24,node:t},n.length>0?{aliases:n}:{})}var zF=e=>{let t=``,n=!1;for(let r of e)r===`-`||r===`_`||r<=` `?n=t.length>0:(t.length===0?t+=r.toLowerCase():t+=n?r.toUpperCase():r,n=!1);return t},BF=e=>{let t=zF(e);return t.charAt(0).toUpperCase()+t.slice(1)},VF=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),HF={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`};function UF(e){return e!=null}function WF(e,t={}){var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g;let _=(n=t.attributeNames)==null?{}:n,v=e=>{var t;return(t=_[e])==null?e:t},y=(r=(i=e.size)==null?e.width:i)==null?HF.width:r,b=(a=(o=e.size)==null?e.height:o)==null?HF.height:a,x=(s=(c=e.aliases)==null?void 0:c.filter(e=>typeof e==`string`&&e.trim()!==``).map(e=>`lucide-${e}`))==null?[]:s,S=[...e.name?[`lucide-${e.name}`]:[],...x],C=(l=(u=t.className)==null?void 0:u.split(` `).filter(Boolean))==null?[]:l,w=t.includeDefaultClasses===!1?VF(...C):VF(`lucide`,...S,...C),T=t.absoluteStrokeWidth?Number((d=t.strokeWidth)==null?HF[`stroke-width`]:d)*Number((f=(p=e.size)==null?e.width:p)==null?HF.width:f)/Number((m=(h=t.size)==null?t.width:h)==null?HF.width:m):(g=t.strokeWidth)==null?HF[`stroke-width`]:g;return[`svg`,E(E(E(E(E(E(E(E({},Object.entries(HF).reduce((e,[t,n])=>(e[v(t)]=n,e),{})),`color`in t&&t.color&&{[v(`stroke`)]:t.color}),`size`in t&&UF(t.size)&&{[v(`width`)]:t.size,[v(`height`)]:t.size}),`width`in t&&UF(t.width)&&{[v(`width`)]:t.width}),`height`in t&&UF(t.height)&&{[v(`height`)]:t.height}),{},{[v(`stroke-width`)]:T},w&&{[v(`class`)]:w}),{},{[v(`viewBox`)]:`0 0 ${y} ${b}`},t.hasA11yProp===!1?{[v(`aria-hidden`)]:`true`}:{}),`attributes`in t&&t.attributes),e.node.map(e=>{let[n,r,i]=e,a=t.nonScalingStroke?E({[v(`vector-effect`)]:`non-scaling-stroke`},r):r;return i?[n,a,i]:[n,a]})]}function GF(e,t={}){return WF(e,E(E({},t),{},{attributeNames:E(E({},t.attributeNames),{},{class:`className`,"stroke-width":`strokeWidth`,"stroke-linecap":`strokeLinecap`,"stroke-linejoin":`strokeLinejoin`,"vector-effect":`vectorEffect`})}))}var KF=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},qF=(0,h.createContext)({}),JF=()=>(0,h.useContext)(qF),YF=[`color`,`size`,`width`,`height`,`strokeWidth`,`absoluteStrokeWidth`,`nonScalingStroke`,`className`,`children`,`iconNode`,`icon`],XF=(0,h.forwardRef)((e,t)=>{var n,r,i;let{color:a,size:o,width:s,height:c,strokeWidth:l,absoluteStrokeWidth:u,nonScalingStroke:d,className:f=``,children:p,iconNode:m=[],icon:g={node:m,aliases:[],size:24}}=e,_=W(e,YF),{size:v=24,strokeWidth:y=2,absoluteStrokeWidth:b=!1,nonScalingStroke:x=!1,color:S=`currentColor`,className:C=``}=(n=JF())==null?{}:n,w=!!p||KF(_),[T,D,O=[]]=GF(g,{color:a==null?S:a,width:(r=s==null?o:s)==null?v:r,height:(i=c==null?o:c)==null?v:i,strokeWidth:l==null?y:l,absoluteStrokeWidth:u==null?b:u,nonScalingStroke:d==null?x:d,className:VF(C,f),hasA11yProp:w,attributes:_});return(0,h.createElement)(T,E({ref:t},D),[...O.map(([e,t])=>(0,h.createElement)(e,t)),...Array.isArray(p)?p:[p]])}),ZF=[`className`];function QF(e,t=[],n=[]){let r=typeof e==`string`?RF(e,t,n):e,i=(0,h.forwardRef)((e,t)=>{let{className:n}=e,i=W(e,ZF);return(0,h.createElement)(XF,E({ref:t,icon:r,className:n},i))});return r.name&&(i.displayName=BF(r.name)),i}var $F={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};$F.node;var eI=QF($F),tI={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};tI.node;var nI=QF(tI),rI={name:`audio-lines`,size:24,node:[[`path`,{d:`M2 10v3`,key:`1fnikh`}],[`path`,{d:`M6 6v11`,key:`11sgs0`}],[`path`,{d:`M10 3v18`,key:`yhl04a`}],[`path`,{d:`M14 8v7`,key:`3a1oy3`}],[`path`,{d:`M18 5v13`,key:`123xd1`}],[`path`,{d:`M22 10v3`,key:`154ddg`}]]};rI.node;var iI=QF(rI),aI={name:`braces`,size:24,node:[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]],aliases:[`curly-braces`]};aI.node;var oI=QF(aI),sI={name:`brain`,size:24,node:[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 01-3-4 4.17 4.17 0 01-3 4`,key:`5nuw1p`}],[`path`,{d:`M17.707 6.294A3 3 0 1012 5a3 3 0 10-5.707 1.294`,key:`18ldcf`}],[`path`,{d:`M17.996 5.125a4 4 0 012.526 5.77`,key:`1sdu8q`}],[`path`,{d:`M18 18a4 4 0 002-7.465`,key:`7xqqvr`}],[`path`,{d:`M19.967 17.482a4 4 0 11-7.967.517 4 4 0 11-7.967-.517`,key:`t46ysz`}],[`path`,{d:`M6 18a4 4 0 01-2-7.465`,key:`1y2m15`}],[`path`,{d:`M6.004 5.125a4 4 0 00-2.526 5.77`,key:`3cw1ss`}]]};sI.node;var cI=QF(sI),lI={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};lI.node;var uI=QF(lI),dI={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};dI.node;var fI=QF(dI),pI={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};pI.node;var mI=QF(pI),hI={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};hI.node;var gI=QF(hI),_I={name:`circle-exclamation-point`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]],aliases:[`alert-circle`,`circle-alert`]};_I.node;var vI=QF(_I),yI={name:`circle-minus`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]],aliases:[`minus-circle`]};yI.node;var bI=QF(yI),xI={name:`circle-x`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-circle`]};xI.node;var SI=QF(xI),CI={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};CI.node;var wI=QF(CI),TI={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]};TI.node;var EI=QF(TI),DI={name:`eighth-notes`,size:24,node:[[`path`,{d:`M21 16V3a1 1 0 0 0-1.28-.96l-10 2.917a1 1 0 0 0-.72.96V19`,key:`uy6ho8`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}],[`circle`,{cx:`6`,cy:`19`,r:`3`,key:`1kj8tv`}]],aliases:[`music`]};DI.node;var OI=QF(DI),kI={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};kI.node;var AI=QF(kI),jI={name:`file-text`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]};jI.node;var MI=QF(jI),NI={name:`file`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]};NI.node;var PI=QF(NI),FI={name:`image-off`,size:24,node:[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]};FI.node;var II=QF(FI),LI={name:`image`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]};LI.node;var RI=QF(LI),zI={name:`loader-circle`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]],aliases:[`loader-2`]};zI.node;var BI=QF(zI),VI={name:`loader`,size:24,node:[[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m16.2 7.8 2.9-2.9`,key:`r700ao`}],[`path`,{d:`M18 12h4`,key:`wj9ykh`}],[`path`,{d:`m16.2 16.2 2.9 2.9`,key:`1bxg5t`}],[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`m4.9 19.1 2.9-2.9`,key:`bwix9q`}],[`path`,{d:`M2 12h4`,key:`j09sii`}],[`path`,{d:`m4.9 4.9 2.9 2.9`,key:`giyufr`}]]};VI.node;var HI=QF(VI),UI={name:`message-square`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]};UI.node;var WI=QF(UI),GI={name:`messages-square`,size:24,node:[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]};GI.node;var KI=QF(GI),qI={name:`mic`,size:24,node:[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]};qI.node;var JI=QF(qI),YI={name:`pause`,size:24,node:[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]};YI.node;var XI=QF(YI),ZI={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};ZI.node;var QI=QF(ZI),$I={name:`phone`,size:24,node:[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]};$I.node;var eL=QF($I),tL={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};tL.node;var nL=QF(tL),rL={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};rL.node;var iL=QF(rL),aL={name:`refresh-cw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]};aL.node;var oL=QF(aL),sL={name:`shield-exclamation-point`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]],aliases:[`shield-alert`]};sL.node;var cL=QF(sL),lL={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};lL.node;var uL=QF(lL),dL={name:`thumbs-up`,size:24,node:[[`path`,{d:`M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z`,key:`emmmcr`}],[`path`,{d:`M7 10v12`,key:`1qc93n`}]]};dL.node;var fL=QF(dL),pL={name:`thumbs-down`,size:24,node:[[`path`,{d:`M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z`,key:`m61m77`}],[`path`,{d:`M17 14V2`,key:`8ymqnk`}]]};pL.node;var mL=QF(pL),hL={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};hL.node;var gL=QF(hL),_L={name:`video`,size:24,node:[[`path`,{d:`m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5`,key:`ftymec`}],[`rect`,{x:`2`,y:`6`,width:`14`,height:`12`,rx:`2`,key:`158x01`}]]};_L.node;var vL=QF(_L),yL={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};yL.node;var bL=QF(yL),xL={};function SL(e,t){let n=h.useRef(xL);return n.current===xL&&(n.current=e(t)),n}var CL=[],wL=void 0;function TL(){return wL}function EL(e){CL.push(e)}function DL(e){let t=(t,n)=>{let r=SL(kL).current,i;try{wL=r;for(let e of CL)e.before(r);i=e(t,n);for(let e of CL)e.after(r);r.didInitialize=!0}finally{wL=void 0}return i};return t.displayName=e.displayName||e.name,t}function OL(e){return h.forwardRef(DL(e))}function kL(){return{didInitialize:!1}}function AL(){}var jL=Object.freeze([]),ML=Object.freeze({}),NL=typeof document<`u`?h.useLayoutEffect:()=>{};function PL(e,t){return function(n,...r){let i=new URL(e);return i.searchParams.set(`code`,n.toString()),r.forEach(e=>i.searchParams.append(`args[]`,e)),`${t} error #${n}; visit ${i} for the full message.`}}var FL=PL(`https://base-ui.com/production-error`,`Base UI`),IL=h.createContext(void 0);process.env.NODE_ENV!==`production`&&(IL.displayName=`TooltipRootContext`);function LL(e){let t=h.useContext(IL);if(t===void 0&&!e)throw Error(process.env.NODE_ENV===`production`?FL(72):`Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>.`);return t}function RL(e){h.useEffect(e,jL)}var zL=0,BL=class e{constructor(){S(this,`currentId`,zL),S(this,`clear`,()=>{this.currentId!==zL&&(clearTimeout(this.currentId),this.currentId=zL)}),S(this,`disposeEffect`,()=>this.clear)}static create(){return new e}start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=zL,t()},e)}isStarted(){return this.currentId!==zL}};function VL(){let e=SL(BL.create).current;return RL(e.disposeEffect),e}function HL(){var e,t;if(typeof navigator>`u`)return{userAgent:``,platform:``,maxTouchPoints:0};if(process.env.NODE_ENV!==`production`){let e=navigator.userAgentData;if(e&&Array.isArray(e.brands)){var n,r,i;return{userAgent:e.brands.map(({brand:e,version:t})=>`${e}/${t}`).join(` `),platform:(n=(r=e.platform)==null?navigator.platform:r)==null?``:n,maxTouchPoints:(i=navigator.maxTouchPoints)==null?0:i}}}return{userAgent:navigator.userAgent,platform:(e=navigator.platform)==null?``:e,maxTouchPoints:(t=navigator.maxTouchPoints)==null?0:t}}var{userAgent:UL,platform:WL,maxTouchPoints:GL}=HL(),KL=UL.toLowerCase(),qL=WL.toLowerCase(),JL=/^i(os$|p)/.test(qL)||qL===`macintel`&&GL>1,YL=`android`,XL=qL===YL||KL.includes(YL),ZL=!JL&&qL.startsWith(`mac`);qL.startsWith(`win`),!XL&&/^(linux|chrome os)/.test(qL);var QL=ZL||JL,$L,eR,tR=typeof CSS<`u`&&!!(($L=(eR=CSS).supports)!=null&&$L.call(eR,`-webkit-backdrop-filter:none`));!tR&&KL.includes(`firefox`),!tR&&KL.includes(`chrom`);var nR=QL,rR=/jsdom|happydom/.test(KL);function iR(e){e.preventDefault(),e.stopPropagation()}function aR(e){return`nativeEvent`in e}function oR(e){return e.pointerType===``&&e.isTrusted?!0:XL&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function sR(e){return rR?!1:!XL&&e.width===0&&e.height===0||e.type===`pointerdown`&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`&&(XL||e.buttons===0)||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType===`touch`}function cR(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function lR(e){let t=e.type;return t===`click`||t===`mousedown`||t===`keydown`||t===`keyup`}function uR(e){var t;let n=e.activeElement;for(;(n==null||(t=n.shadowRoot)==null?void 0:t.activeElement)!=null;)n=n.shadowRoot.activeElement;return n}function dR(e,t){var n;if(!e||!t)return!1;let r=(n=t.getRootNode)==null?void 0:n.call(t);if(e.contains(t))return!0;if(r&&qS(r)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function fR(e,t){let n=e;for(;n;){var r,i;if(GS(n)&&n.matches(t))return n;n=(r=(i=n.assignedSlot)==null?n.parentNode:i)==null?qS(n)?n.host:null:r}return null}function pR(e){if(`composedPath`in e){var t;return(t=e.composedPath()[0])==null?e.target:t}return e.target}var mR=`data-base-ui-focusable`,hR=`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`,gR=`data-starting-style`,_R=`data-ending-style`,vR={[gR]:``},yR={[_R]:``},bR={transitionStatus(e){return e===`starting`?vR:e===`ending`?yR:null}},xR=`data-open`,SR=`data-closed`,CR=`data-anchor-hidden`,wR={"data-popup-open":``},TR={[xR]:``},ER={[SR]:``},DR={[CR]:``},OR={open(e){return e?wR:null}},kR={open(e){return e?TR:ER},anchorHidden(e){return e?DR:null}},AR=E(E({},kR),bR),jR=`data-trigger-disabled`;function MR(e,t){if(!GS(e))return!1;let n=e;if(t.hasElement(n))return!n.hasAttribute(jR);for(let[,e]of t.entries())if(dR(e,n))return!e.hasAttribute(jR);return!1}function NR(e,t){if(t==null)return!1;if(`composedPath`in e)return e.composedPath().includes(t);let n=e;return n.target!=null&&t.contains(n.target)}function PR(e){return e.matches(`html,body`)}function FR(e){return KS(e)&&e.matches(`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`)}function IR(e){return fR(e,`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${hR}`)!=null}function LR(e){return e?e.getAttribute(`role`)===`combobox`&&FR(e):!1}function RR(e){if(!e||rR)return!0;try{return e.matches(`:focus-visible`)}catch(e){return!0}}function zR(e){return e?e.hasAttribute(`data-base-ui-focusable`)?e:e.querySelector(`[data-base-ui-focusable]`)||e:null}function BR(e,t){return t!=null&&!cR(t)?0:typeof e==`function`?e():e}function VR(e,t,n){let r=BR(e,n);return typeof r==`number`?r:r==null?void 0:r[t]}function HR(e){return typeof e==`function`?e():e}function UR(e,t){return t||e===`click`||e===`mousedown`}function WR(e){return(e==null?void 0:e.includes(`mouse`))&&e!==`mousedown`}function GR(e,t,n,r){let i=!1,a=!1,o=r==null?ML:r;return E({reason:e,event:t==null?new Event(`base-ui`):t,cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n},o)}var KR=`none`,qR=`trigger-press`,JR=`trigger-hover`,YR=`trigger-focus`,XR=`outside-press`,ZR=`close-press`,QR=`focus-out`,$R=`escape-key`,ez=`disabled`,tz=`imperative-action`,nz=h.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new BL,currentIdRef:{current:null},currentContextRef:{current:null}});process.env.NODE_ENV!==`production`&&(nz.displayName=`FloatingDelayGroupContext`);function rz(e,t){e.current=t.current}function iz(e){let{children:t,delay:n,timeoutMs:r=0}=e,i=h.useRef(n),a=h.useRef(n),o=h.useRef(null),s=h.useRef(null),c=VL();return NL(()=>{a.current=n,o.current?i.current={open:VR(i.current,`open`),close:VR(n,`close`)}:i.current=n},[n,o,i,a]),(0,J.jsx)(nz.Provider,{value:h.useMemo(()=>({hasProvider:!0,delayRef:i,initialDelayRef:a,currentIdRef:o,timeoutMs:r,currentContextRef:s,timeout:c}),[r,c]),children:t})}function az(e,t={open:!1}){let{open:n}=t,r=e.useState(`floatingId`),{currentIdRef:i,delayRef:a,timeoutMs:o,initialDelayRef:s,currentContextRef:c,hasProvider:l,timeout:u}=h.useContext(nz),[d,f]=h.useState(!1),p=h.useRef(n);return NL(()=>{p.current=n},[n]),NL(()=>{function t(){var e;(e=c.current)==null||e.setIsInstantPhase(!1),i.current=null,c.current=null,a.current=s.current,u.clear()}if(i.current&&!n&&i.current===r){if(f(!1),o){let n=r;return u.start(o,()=>{e.select(`open`)||i.current&&i.current!==n||t()}),()=>{(p.current||i.current!==n)&&u.clear()}}t()}},[n,r,i,a,o,s,c,u,e]),NL(()=>{if(!n)return;let t=c.current,o=i.current;u.clear(),c.current={onOpenChange:e.setOpen,setIsInstantPhase:f},i.current=r,a.current={open:0,close:VR(s.current,`close`)},o!==null&&o!==r?(f(!0),t==null||t.setIsInstantPhase(!0),t==null||t.onOpenChange(!1,GR(`none`))):(f(!1),t==null||t.setIsInstantPhase(!1))},[n,r,e,i,a,s,c,u]),NL(()=>()=>{if(i.current===r){if(c.current=null,!p.current)return;i.current=null,rz(a,s),u.clear()}},[c,i,a,r,s,u]),h.useMemo(()=>({activeIdRef:i,hasProvider:l,delayRef:a,isInstantPhase:d}),[i,l,a,d])}function oz(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function sz(...e){return()=>{for(let t=0;t<e.length;t+=1){let n=e[t];n&&n()}}}function cz(e,t,n,r){let i=SL(uz).current;return dz(i,e,t,n,r)&&pz(i,[e,t,n,r]),i.callback}function lz(e){let t=SL(uz).current;return fz(t,e)&&pz(t,e),t.callback}function uz(){return{callback:null,cleanup:null,refs:[]}}function dz(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function fz(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function pz(e,t){e.refs=t,e.callback=t.every(e=>e==null)?null:n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null}}}}}}function mz(e){let t=SL(hz,e).current;return t.next=e,NL(t.effect),t}function hz(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var gz=E({},h),_z=gz.useInsertionEffect,vz=_z&&_z!==gz.useLayoutEffect?_z:e=>e();function yz(e){let t=SL(bz).current;return t.next=e,vz(t.effect),t.trampoline}function bz(){let e={next:void 0,callback:xz,trampoline:(...t)=>{var n;return(n=e.callback)==null?void 0:n.call(e,...t)},effect:()=>{e.callback=e.next}};return e}function xz(){if(process.env.NODE_ENV!==`production`)throw Error(`Base UI: Cannot call an event handler while rendering.`)}var Sz=null,Cz=globalThis.requestAnimationFrame,wz=new class{constructor(){S(this,`callbacks`,[]),S(this,`callbacksCount`,0),S(this,`nextId`,1),S(this,`startId`,1),S(this,`isScheduled`,!1),S(this,`tick`,e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1){var r;(r=t[n])==null||r.call(t,e)}})}request(e){let t=this.nextId;this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1;let n=process.env.NODE_ENV!==`production`&&Cz!==requestAnimationFrame&&(Cz=requestAnimationFrame,!0);return(!this.isScheduled||n)&&(requestAnimationFrame(this.tick),this.isScheduled=!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||this.callbacks[t]!==null&&(this.callbacks[t]=null,--this.callbacksCount)}},Tz=class e{constructor(){S(this,`currentId`,Sz),S(this,`cancel`,()=>{this.currentId!==Sz&&(wz.cancel(this.currentId),this.currentId=Sz)}),S(this,`disposeEffect`,()=>this.cancel)}static create(){return new e}static request(e){return wz.request(e)}static cancel(e){return wz.cancel(e)}request(e){this.cancel(),this.currentId=wz.request(()=>{this.currentId=Sz,e()})}};function Ez(){let e=SL(Tz.create).current;return RL(e.disposeEffect),e}function Dz(e){return(e==null?void 0:e.ownerDocument)||document}var Oz={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},kz=E(E({},Oz),{},{position:`fixed`,margin:0,top:0,left:0});E(E({},Oz),{},{position:`absolute`});var Az=h.forwardRef(function(e,t){let[n,r]=h.useState();NL(()=>{nR&&tR&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,J.jsx)(`span`,E(E(E({},e),{},{ref:t,style:kz,"aria-hidden":!n||void 0},i),{},{"data-base-ui-focus-guard":``}))});process.env.NODE_ENV!==`production`&&(Az.displayName=`FocusGuard`);function jz(e){return e.visibility===`hidden`||e.visibility===`collapse`}function Mz(e,t=e?aC(e):null){return!e||!e.isConnected||!t||jz(t)?!1:typeof e.checkVisibility==`function`?e.checkVisibility():t.display!==`none`&&t.display!==`contents`}var Nz=`a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]`;function Pz(e){let t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;let n=e.getRootNode();return qS(n)?n.host:null}function Fz(e){for(let t of Array.from(e.children))if(VS(t)===`summary`)return t;return null}function Iz(e,t){let n=Fz(t);return!!n&&(e===n||dR(n,e))}function Lz(e){let t=e?VS(e):``;return e!=null&&e.matches(Nz)&&(t!==`summary`||e.parentElement!=null&&VS(e.parentElement)===`details`&&Fz(e.parentElement)===e)&&(t!==`details`||Fz(e)==null)&&(t!==`input`||e.type!==`hidden`)}function Rz(e){if(!Lz(e)||!e.isConnected||e.matches(`:disabled`))return!1;for(let t=e;t;t=Pz(t)){let n=t!==e,r=VS(t)===`slot`;if(t.hasAttribute(`inert`)||n&&VS(t)===`details`&&!t.open&&!Iz(e,t)||t.hasAttribute(`hidden`)||!r&&!zz(t,n))return!1}return!0}function zz(e,t){let n=aC(e);return t?n.display!==`none`:Mz(e,n)}function Bz(e){let t=e.tabIndex;if(t<0){let t=VS(e);if(t===`details`||t===`audio`||t===`video`||KS(e)&&e.isContentEditable)return 0}return t}function Vz(e){if(VS(e)!==`input`)return null;let t=e;return t.type===`radio`&&t.name!==``?t:null}function Hz(e,t){let n=Vz(e);if(!n)return!0;let r=t.find(e=>{let t=Vz(e);return(t==null?void 0:t.name)===n.name&&t.form===n.form&&t.checked});return r?r===n:t.find(e=>{let t=Vz(e);return(t==null?void 0:t.name)===n.name&&t.form===n.form})===n}function Uz(e){if(KS(e)&&VS(e)===`slot`){let t=e.assignedElements({flatten:!0});if(t.length>0)return t}return KS(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function Wz(e,t){Uz(e).forEach(e=>{Lz(e)&&t.push(e),Wz(e,t)})}function Gz(e,t,n){Uz(e).forEach(e=>{KS(e)&&e.matches(t)&&n.push(e),Gz(e,t,n)})}function Kz(e){return Rz(e)&&Bz(e)>=0}function qz(e){let t=[];return Wz(e,t),t.filter(Rz)}function Jz(e){let t=qz(e);return t.filter(e=>Bz(e)>=0&&Hz(e,t))}function Yz(e,t){let n=Jz(e),r=n.length;if(r===0)return;let i=uR(Dz(e)),a=n.indexOf(i);return n[a===-1?t===1?0:r-1:a+t]}function Xz(e){return Yz(Dz(e).body,1)||e}function Zz(e){return Yz(Dz(e).body,-1)||e}function Qz(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!r||!dR(n,r)}function $z(e){Jz(e).forEach(e=>{e.dataset.tabindex=e.getAttribute(`tabindex`)||``,e.setAttribute(`tabindex`,`-1`)})}function eB(e){let t=[];Gz(e,`[data-tabindex]`,t),t.forEach(e=>{let t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute(`tabindex`,t):e.removeAttribute(`tabindex`)})}function tB(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>{var r;return[...!n||(r=t.context)!=null&&r.open?[t]:[],...tB(e,t.id,n)]})}function nB(e,t){var n;let r=[],i=(n=e.find(e=>e.id===t))==null?void 0:n.parentId;for(;i;){let t=e.find(e=>e.id===i);i=t==null?void 0:t.parentId,t&&(r=r.concat(t))}return r}function rB(e){return`data-base-ui-${e}`}var iB=0;function aB(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(iB);function a(){i&&!i()||e==null||e.focus({preventScroll:n})}if(r)return a(),AL;let o=requestAnimationFrame(a);return iB=o,()=>{iB===o&&(cancelAnimationFrame(o),iB=0)}}var oB=`data-base-ui-inert`,sB=new WeakMap,cB=new WeakSet,lB=new WeakMap,uB=0;function dB(e){return e?qS(e)?e.host:dB(e.parentNode):null}var fB=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=dB(t);return e.contains(n)?n:null}).filter(e=>e!=null),pB=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},mB=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{VS(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function hB(e,t,n,{mark:r=!0}){let i=fB(t,e),a=r?mB(t,pB(i),new Set(i)):[],o=[],s=[];if(n){let e=fB(t,Array.from(t.querySelectorAll(`[aria-live]`))),n=i.concat(e);mB(t,pB(n),new Set(n)).forEach(e=>{let t=e.getAttribute(`aria-hidden`),n=t!==null&&t!==`false`,r=(sB.get(e)||0)+1;sB.set(e,r),o.push(e),r===1&&n&&cB.add(e),n||e.setAttribute(`aria-hidden`,`true`)})}return r&&a.forEach(e=>{let t=(lB.get(e)||0)+1;lB.set(e,t),s.push(e),t===1&&e.setAttribute(oB,``)}),uB+=1,()=>{o.forEach(e=>{let t=(sB.get(e)||0)-1;sB.set(e,t),t||(cB.has(e)||e.removeAttribute(`aria-hidden`),cB.delete(e))}),r&&s.forEach(e=>{let t=(lB.get(e)||0)-1;lB.set(e,t),t||e.removeAttribute(oB)}),--uB,uB||(sB=new WeakMap,cB=new WeakSet,lB=new WeakMap)}}function gB(e,t={}){let{ariaHidden:n=!1,mark:r=!0}=t,i=Dz(e[0]).body;return hB(e,i,n,{mark:r})}function _B(){let[,e]=h.useState({});return h.useCallback(()=>{e({})},[])}var vB=0;function yB(e,t=`mui`){let n=h.useRef(void 0),r=_B(),i=e==null?n.current:e;return h.useEffect(()=>{n.current==null&&(vB+=1,n.current=`${t}-${vB}`,e==null&&r())},[e,t,r]),i}var bB=gz.useId;function xB(e,t){if(bB!==void 0){let n=bB();return e==null?t?`${t}-${n}`:n:e}return yB(e,t)}var SB=parseInt(h.version,10);function CB(e){return SB>=e}function wB(e){var t;if(!h.isValidElement(e))return null;let n=e,r=n.props;return(t=CB(19)?r==null?void 0:r.ref:n.ref)==null?null:t}function TB(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return E(E({},e),t)}var EB;process.env.NODE_ENV!==`production`&&(EB=new Set);function DB(e,t){return function(...n){if(process.env.NODE_ENV!==`production`){let r=n.join(` `),i=t?`${t}: ${r}`:r,a=`${e}:${i}`;EB.has(a)||(EB.add(a),e===`warn`?console.warn(i):console.error(i))}}}var OB=DB(`warn`,`Base UI`);function kB(e,t){let n={};for(let r in e){let i=e[r];if(t!=null&&t.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e)}else i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function AB(e,t){return typeof e==`function`?e(t):e}function jB(e,t){return typeof e==`function`?e(t):e}var MB={};function NB(e,t,n,r,i){if(!n&&!r&&!i&&!e)return FB(t);let a=FB(e);return t&&(a=IB(a,t)),n&&(a=IB(a,n)),r&&(a=IB(a,r)),i&&(a=IB(a,i)),a}function PB(e){if(e.length===0)return MB;if(e.length===1)return FB(e[0]);let t=FB(e[0]);for(let n=1;n<e.length;n+=1)t=IB(t,e[n]);return t}function FB(e){return BB(e)?E({},e(MB)):LB(e)}function IB(e,t){return BB(t)?t(e):RB(e,t)}function LB(e){let t=E({},e);for(let e in t){let n=t[e];zB(e,n)&&(t[e]=HB(n))}return t}function RB(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=TB(e.style,r);break;case`className`:e[n]=WB(e.className,r);break;default:e[n]=zB(n,r)?VB(e[n],r):r}}return e}function zB(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function BB(e){return typeof e==`function`}function VB(e,t){return t?e?(...n)=>{let r=n[0];if(GB(r)){let i=r;UB(i);let a=t(...n);return i.baseUIHandlerPrevented||e==null||e(...n),a}let i=t(...n);return e==null||e(...n),i}:HB(t):e}function HB(e){return e&&((...t)=>{let n=t[0];return GB(n)&&UB(n),e(...t)})}function UB(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function WB(e,t){return t?e?t+` `+e:t:e}function GB(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function KB(e,t,n={}){var r;let i=t.render;n.enabled!==!1&&(i=QB(i));let a=qB(t,n,i);if(n.enabled===!1)return null;let o=(r=n.state)==null?ML:r;return $B(e,i,a,o)}function qB(e,t,n){var r;let{className:i,style:a}=e,{state:o=ML,ref:s,props:c,stateAttributesMapping:l,enabled:u=!0}=t,d=u?AB(i,o):void 0,f=u?jB(a,o):void 0,p=u?kB(o,l):ML,m=u&&c?JB(c):void 0,h=u?(r=TB(p,m))==null?{}:r:ML;return typeof document<`u`&&(u?h.ref=Array.isArray(s)?lz([h.ref,wB(n),...s]):cz(h.ref,wB(n),s):cz(null,null)),u?(d!==void 0&&(h.className=WB(h.className,d)),f!==void 0&&(h.style=TB(h.style,f)),h):ML}function JB(e){return Array.isArray(e)?PB(e):NB(void 0,e)}var YB=Symbol.for(`react.lazy`),XB=/^[A-Z][A-Za-z0-9$]*$/,ZB=/[a-z]/;function QB(e){if((e==null?void 0:e.$$typeof)!==YB)return e;let t=h.Children.toArray(e)[0];return h.isValidElement(t)?t:e}function $B(e,t,n,r){if(t){if(typeof t==`function`)return process.env.NODE_ENV!==`production`&&eV(t),t(n,r);let e=NB(n,t.props);if(e.ref=n.ref,process.env.NODE_ENV!==`production`&&!h.isValidElement(t))throw Error("Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.\nA valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.\nhttps://base-ui.com/r/invalid-render-prop");return h.cloneElement(t,e)}return tV(e,n)}function eV(e){let t=e.name;t.length!==0&&XB.test(t)&&ZB.test(t)&&OB(`The \`render\` prop received a function named \`${t}\` that starts with an uppercase letter.`,"This usually means a React component was passed directly as `render={Component}`.","Base UI calls `render` as a plain function, which can break the Rules of Hooks during reconciliation.",`If this is an intentional render callback, rename it to start with a lowercase letter.`,"Use `render={<Component />}` or `render={(props) => <Component {...props} />}` instead.",`https://base-ui.com/r/invalid-render-prop`)}function tV(e,t){return e===`button`?(0,h.createElement)(`button`,E(E({type:`button`},t),{},{key:t.key})):e===`img`?(0,h.createElement)(`img`,E(E({alt:``},t),{},{key:t.key})):h.createElement(e,t)}var nV={style:{transition:`none`}},rV=`data-base-ui-click-trigger`,iV={fallbackAxisSide:`end`},aV={clipPath:`inset(50%)`,position:`fixed`,top:0,left:0},oV=[`render`,`className`,`style`,`children`,`container`,`portalOwnerRole`],sV=h.createContext(null);process.env.NODE_ENV!==`production`&&(sV.displayName=`PortalContext`);var cV=()=>h.useContext(sV),lV=rB(`portal`);function uV(e={}){let{ref:t,container:r,componentProps:i=ML,elementProps:a}=e,o=xB(),s=cV(),c=s==null?void 0:s.portalNode,[l,u]=h.useState(null),[d,f]=h.useState(null),p=yz(e=>{e!==null&&f(e)}),m=h.useRef(null);NL(()=>{var e,t;if(r===null){m.current&&(m.current=null,f(null),u(null));return}let n=(e=(t=r&&(WS(r)?r:r.current))==null?c:t)==null?document.body:e;n==null?m.current&&(m.current=null,f(null),u(null)):m.current!==n&&(m.current=n,f(null),u(n))},[r,c]);let g=KB(`div`,i,{ref:[t,p],props:[{id:o,[lV]:``},a]}),_=l&&g?n.createPortal(g,l):null;return{node:d,nodeId:h.isValidElement(g)?g.props.id:void 0,subtree:_}}var dV=h.forwardRef(function(e,t){let{render:r,className:i,style:a,children:o,container:s,portalOwnerRole:c}=e,{node:l,nodeId:u,subtree:d}=uV({container:s,ref:t,componentProps:e,elementProps:W(e,oV)}),f=h.useRef(null),p=h.useRef(null),m=h.useRef(null),g=h.useRef(null),[_,v]=h.useState(null),y=h.useRef(!1),b=_==null?void 0:_.modal,x=_==null?void 0:_.open,S=!!_&&!_.modal&&_.open&&!!l;h.useEffect(()=>{if(!l||b)return;function e(e){l&&e.relatedTarget&&Qz(e)&&(e.type===`focusin`?y.current&&(eB(l),y.current=!1):($z(l),y.current=!0))}return sz(oz(l,`focusin`,e,!0),oz(l,`focusout`,e,!0))},[l,b]),NL(()=>{l&&x===!0&&y.current&&(eB(l),y.current=!1)},[x,l]);let C=h.useMemo(()=>({beforeOutsideRef:f,afterOutsideRef:p,beforeInsideRef:m,afterInsideRef:g,portalNode:l,setFocusManagerState:v}),[l]);return(0,J.jsxs)(h.Fragment,{children:[d,(0,J.jsxs)(sV.Provider,{value:C,children:[S&&l&&(0,J.jsx)(Az,{"data-type":`outside`,ref:f,onFocus:e=>{if(Qz(e,l)){var t;(t=m.current)==null||t.focus()}else{let e=Zz(_?_.domReference:null);e==null||e.focus()}}}),S&&l&&(0,J.jsx)(`span`,{role:c,"aria-owns":u,style:aV}),l&&n.createPortal(o,l),S&&l&&(0,J.jsx)(Az,{"data-type":`outside`,ref:p,onFocus:e=>{if(Qz(e,l)){var t;(t=g.current)==null||t.focus()}else{let t=Xz(_?_.domReference:null);t==null||t.focus(),_!=null&&_.closeOnFocusOut&&(_==null||_.onOpenChange(!1,GR(`focus-out`,e.nativeEvent)))}}})]})]})});process.env.NODE_ENV!==`production`&&(dV.displayName=`FloatingPortal`);function fV(){let e=new Map;return{emit(t,n){var r;(r=e.get(t))==null||r.forEach(e=>e(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)}}}var pV=h.createContext(null);process.env.NODE_ENV!==`production`&&(pV.displayName=`FloatingNodeContext`);var mV=h.createContext(null);process.env.NODE_ENV!==`production`&&(mV.displayName=`FloatingTreeContext`);var hV=()=>{var e;return((e=h.useContext(pV))==null?void 0:e.id)||null},gV=e=>{let t=h.useContext(mV);return e==null?t:e};function _V(e){return e==null?e:`current`in e?e.current:e}function vV(e,t){let n=HS(pR(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||(oR(e)?`keyboard`:t||`mouse`):`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var yV=20,bV=[];function xV(){bV=bV.filter(e=>{var t;return(t=e.deref())==null?void 0:t.isConnected})}function SV(e){xV(),e&&VS(e)!==`body`&&(bV.push(new WeakRef(e)),bV.length>yV&&(bV=bV.slice(-20)))}function CV(){var e;return xV(),(e=bV[bV.length-1])==null?void 0:e.deref()}function wV(e){return e?Kz(e)?e:Jz(e)[0]||e:null}function TV(e){var t;if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!((t=e.getAttribute(`role`))!=null&&t.includes(`dialog`)))return;let n=qz(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return Kz(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),r=e.getAttribute(`tabindex`);n.length===0?r!==`0`&&(e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-tabindex`,`0`)):(r!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function EV(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,explicitReturnFocus:o,restoreFocus:s=!1,modal:c=!0,closeOnFocusOut:l=!0,openInteractionType:u=``,nextFocusableElement:d,previousFocusableElement:f,beforeContentFocusGuardRef:p,externalTree:m,getInsideElements:g}=e,_=t.useState(`open`),v=t.useState(`domReferenceElement`),y=t.useState(`floatingElement`),{events:b,dataRef:x}=t.context,S=yz(()=>{var e;return(e=x.current.floatingContext)==null?void 0:e.nodeId}),C=i===!1,w=LR(v)&&C,T=mz(i),E=mz(a),D=mz(o),O=mz(u),k=mz(_),A=gV(m),j=cV(),M=h.useRef(!1),N=h.useRef(!1),P=h.useRef(!1),F=h.useRef(null),I=h.useRef(``),L=h.useRef(``),R=h.useRef(null),z=h.useRef(null),B=cz(R,p,j==null?void 0:j.beforeInsideRef),ee=cz(z,j==null?void 0:j.afterInsideRef),V=VL(),te=VL(),H=Ez(),U=j!=null,W=zR(y),ne=yz((e=W)=>e?Jz(e):[]),re=yz(()=>{var e;return(e=g==null?void 0:g().filter(e=>e!=null))==null?[]:e});h.useEffect(()=>{if(r||!c)return;function e(e){e.key===`Tab`&&dR(W,uR(Dz(W)))&&ne().length===0&&!w&&iR(e)}return oz(Dz(W),`keydown`,e)},[r,W,c,w,ne]),h.useEffect(()=>{if(r||!_)return;let e=Dz(W);function t(){P.current=!1}function n(e){let t=pR(e),n=re(),r=dR(y,t)||dR(v,t)||dR(j==null?void 0:j.portalNode,t)||n.some(e=>e===t||dR(e,t));P.current=!r,L.current=e.pointerType||`keyboard`,fR(t,`[data-base-ui-click-trigger]`)&&(N.current=!0,te.start(0,()=>{N.current=!1}))}function i(){L.current=`keyboard`}return sz(oz(e,`pointerdown`,n,!0),oz(e,`pointerup`,t,!0),oz(e,`pointercancel`,t,!0),oz(e,`keydown`,i,!0),t)},[r,y,v,W,_,j,te,re]),h.useEffect(()=>{if(r||!l)return;let e=Dz(W);function n(){N.current=!0,te.start(0,()=>{N.current=!1})}function i(e){let t=pR(e);Kz(t)&&(F.current=t)}function a(n){let r=n.relatedTarget,i=n.currentTarget,a=pR(n);c&&r==null&&a!=null&&dR(y,a)&&SV(a),queueMicrotask(()=>{let o=S(),l=t.context.triggerElements,u=re(),p=(r==null?void 0:r.hasAttribute(rB(`focus-guard`)))&&[R.current,z.current,j==null?void 0:j.beforeInsideRef.current,j==null?void 0:j.afterInsideRef.current,j==null?void 0:j.beforeOutsideRef.current,j==null?void 0:j.afterOutsideRef.current,_V(f),_V(d)].includes(r),m=!(dR(v,r)||dR(y,r)||dR(r,y)||dR(j==null?void 0:j.portalNode,r)||u.some(e=>e===r||dR(e,r))||l.hasMatchingElement(e=>dR(e,r))||p||A&&(tB(A.nodesRef.current,o).find(e=>{var t,n;return dR((t=e.context)==null?void 0:t.elements.floating,r)||dR((n=e.context)==null?void 0:n.elements.domReference,r)})||nB(A.nodesRef.current,o).find(e=>{var t,n,i;return[(t=e.context)==null?void 0:t.elements.floating,zR((n=e.context)==null?void 0:n.elements.floating)].includes(r)||((i=e.context)==null?void 0:i.elements.domReference)===r})));if(i===v&&W&&TV(W),s&&i!==v&&!Mz(a)&&uR(e)===e.body){if(KS(W)&&(W.focus(),s===`popup`)){H.request(()=>{W.focus()});return}let e=ne(),t=F.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||W;KS(n)&&n.focus()}x.current.insideReactTree?x.current.insideReactTree=!1:(w||!c)&&r&&m&&!N.current&&(w||r!==CV())&&(M.current=!0,t.setOpen(!1,GR(QR,n)))})}function o(){P.current||(x.current.insideReactTree=!0,V.start(0,()=>{x.current.insideReactTree=!1}))}let u=KS(v)?v:null;if(y||u)return sz(u&&oz(u,`focusout`,a),u&&oz(u,`pointerdown`,n),y&&oz(y,`focusin`,i),y&&oz(y,`focusout`,a),y&&j&&oz(y,`focusout`,o,!0))},[r,v,y,W,c,A,j,t,l,s,ne,w,S,x,V,te,H,d,f,re]),h.useEffect(()=>{var e,t;if(r||!y||!_)return;let n=Array.from((j==null||(e=j.portalNode)==null?void 0:e.querySelectorAll(`[${rB(`portal`)}]`))||[]),i=(t=(A?nB(A.nodesRef.current,S()):[]).find(e=>{var t;return LR(((t=e.context)==null?void 0:t.elements.domReference)||null)}))==null||(t=t.context)==null?void 0:t.elements.domReference,a=gB([y,...n,R.current,z.current,j==null?void 0:j.beforeOutsideRef.current,j==null?void 0:j.afterOutsideRef.current,...re(),i,_V(f),_V(d),w?v:null].filter(e=>e!=null),{ariaHidden:c||w,mark:!1}),o=gB([y,...n].filter(e=>e!=null));return()=>{o(),a()}},[_,r,v,y,c,j,w,A,S,d,f,re]),NL(()=>{if(!_||r||!KS(W))return;I.current=``,L.current=``;let e=Dz(W),t=uR(e);queueMicrotask(()=>{let n=T.current,r=typeof n==`function`?n(O.current||``):n;if(r===void 0||r===!1||dR(W,t))return;let i=null,a=()=>(i==null&&(i=ne(W)),i[0]||W),o;o=r===!0||r===null?a():_V(r),o=o||a();let s=dR(W,uR(e)),c=x.current.openEvent,l=(c==null?void 0:c.type)===`mousedown`&&oR(c);aB(o,{sync:l,preventScroll:o===W,shouldFocus(){if(!k.current)return!1;if(s)return!0;let t=uR(e);return!(t!==o&&dR(W,t))}})})},[r,_,W,ne,T,O,k,x]);let ie=h.useRef(null);NL(()=>{if(r||!W){ie.current=null;return}ie.current&&(ie.current.cancelled=!0,ie.current=null);let e=Dz(W),t=uR(e),n=O.current==null;SV(t);function i(e){var t;if(e.open||(I.current=vV(e.nativeEvent,L.current)),(e.reason===`focus-out`&&(t=e.triggerElement)!=null&&t.hasAttribute(rB(`focus-guard`))||e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`)&&(M.current=!0),e.reason===`outside-press`){if(e.nested)M.current=!1;else if(oR(e.nativeEvent)||sR(e.nativeEvent))M.current=!1;else{let e=!1;Dz(W).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?M.current=!1:M.current=!0}}}b.on(`openchange`,i);function a(e){let r=E.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=v!=null&&v.isConnected?v:null,o=t!=null&&t.isConnected&&VS(t)!==`body`?t:null,s=n?o||a:a||o;return s||(s=CV()||null),typeof i==`boolean`?s:_V(i)||s||null}return()=>{b.off(`openchange`,i);let t=uR(e),n=re(),r=dR(y,t)||n.some(e=>e===t||dR(e,t))||A&&tB(A.nodesRef.current,S(),!1).some(e=>{var n;return dR((n=e.context)==null?void 0:n.elements.floating,t)}),o=E.current,s=I.current,c=a(s),l={cancelled:!1};ie.current=l,queueMicrotask(()=>{var n;ie.current===l&&(ie.current=null);let i=wV(c),a=(n=D.current)==null?typeof o!=`boolean`:n;if(!l.cancelled&&o&&!M.current&&KS(i)&&(a||i===t||t===e.body||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),i.focus(e)}M.current=!1})}},[r,y,W,E,D,O,b,A,v,S,re]),NL(()=>{if(!tR||_||!y)return;let e=uR(Dz(y));KS(e)&&FR(e)&&dR(y,e)&&e.blur()},[_,y]),NL(()=>{if(!r&&j)return j.setFocusManagerState({modal:c,closeOnFocusOut:l,open:_,onOpenChange:t.setOpen,domReference:v}),()=>{j.setFocusManagerState(null)}},[r,j,c,_,t,l,v]),NL(()=>{if(!r&&W)return TV(W),()=>{queueMicrotask(xV)}},[r,W]);let ae=!r&&(!c||!w)&&(U||c);return(0,J.jsxs)(h.Fragment,{children:[ae&&(0,J.jsx)(Az,{"data-type":`inside`,ref:B,onFocus:e=>{if(c){let e=ne();aB(e[e.length-1])}else if(j!=null&&j.portalNode){if(M.current=!1,Qz(e,j.portalNode)){let e=Xz(v);e==null||e.focus()}else{var t;(t=_V(f==null?j.beforeOutsideRef:f))==null||t.focus()}}}}),n,ae&&(0,J.jsx)(Az,{"data-type":`inside`,ref:ee,onFocus:e=>{if(c)aB(ne()[0]);else if(j!=null&&j.portalNode){if(l&&(M.current=!0),Qz(e,j.portalNode)){let e=Zz(v);e==null||e.focus()}else{var t;(t=_V(d==null?j.afterOutsideRef:d))==null||t.focus()}}}})]})}function DV(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=qR}=t,l=e.context.dataRef,u=h.useRef(void 0),d=Ez(),f=VL(),p=h.useMemo(()=>{function t(t,n,r,i){let a=GR(c,n,r);t&&i===`touch`&&s>0?f.start(s,()=>{e.setOpen(!0,a)}):e.setOpen(t,a)}function n(t,n,r){let a=l.current.openEvent,s=e.select(`domReferenceElement`)!==n;return t&&s||!t||!i?!0:a&&(typeof o==`function`?o():o)?!r(a.type):!1}return{onPointerDown(e){u.current=cR(e.pointerType,!0)&&sR(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(i){let o=u.current,s=i.nativeEvent,c=e.select(`open`);if(i.button!==0||r===`click`||cR(o,!0)&&a)return;let l=n(c,i.currentTarget,e=>e===`click`||e===`mousedown`),f=pR(s),p=FR(f);if(p||o===`virtual`){t(l,s,p?f:i.currentTarget,o);return}let m=i.currentTarget;d.request(()=>{t(l,s,m,o)})},onClick(i){if(r===`mousedown-only`)return;let o=u.current;r===`mousedown`&&o?u.current=void 0:cR(o,!0)&&a||t(n(e.select(`open`),i.currentTarget,e=>e===`click`||e===`mousedown`||e===`keydown`||e===`keyup`),i.nativeEvent,i.currentTarget,o)},onKeyDown(){u.current=void 0}}},[l,r,a,c,e,o,i,d,f,s]);return h.useMemo(()=>n?{reference:p}:ML,[n,p])}function OV(e,t){let n=null,r=null,i=!1;return{contextElement:e||void 0,getBoundingClientRect(){var a;let o=(e==null?void 0:e.getBoundingClientRect())||{width:0,height:0,x:0,y:0},s=t.axis===`x`||t.axis===`both`,c=t.axis===`y`||t.axis===`both`,l=[`mouseenter`,`mousemove`].includes(((a=t.dataRef.current.openEvent)==null?void 0:a.type)||``)&&t.pointerType!==`touch`,u=t.axis===`y`?o.width:0,d=t.axis===`x`?o.height:0,f=o.x,p=o.y;return n==null&&t.x&&s&&(n=o.x-t.x),r==null&&t.y&&c&&(r=o.y-t.y),f-=n||0,p-=r||0,(!i||l)&&(f=s&&t.x!=null?t.x:f,p=c&&t.y!=null?t.y:p),i=!0,{width:u,height:d,x:f,y:p,top:p,right:f+u,bottom:p+d,left:f}}}}function kV(e){return e!=null&&e.clientX!=null}function AV(e,t={}){let{enabled:n=!0,axis:r=`both`}=t,i=e.useState(`open`),a=e.useState(`floatingElement`),o=e.useState(`domReferenceElement`),s=e.context.dataRef,c=h.useRef(!1),l=h.useRef(null),[u,d]=h.useState(),[f,p]=h.useState([]),m=yz(t=>{e.set(`positionReference`,t)}),g=yz((t,n,i)=>{c.current||(!s.current.openEvent||kV(s.current.openEvent))&&e.set(`positionReference`,OV(i==null?o:i,{x:t,y:n,axis:r,dataRef:s,pointerType:u}))}),_=yz(e=>{i?l.current||(g(e.clientX,e.clientY,e.currentTarget),p([])):g(e.clientX,e.clientY,e.currentTarget)}),v=cR(u)?a:i;h.useEffect(()=>{if(!n){m(o);return}if(!v)return;function e(){var e;(e=l.current)==null||e.call(l),l.current=null}let t=HS(a);function r(t){let n=pR(t);dR(a,n)?e():g(t.clientX,t.clientY)}return!s.current.openEvent||kV(s.current.openEvent)?l.current=oz(t,`mousemove`,r):m(o),e},[v,n,a,s,o,e,g,m,f]),h.useEffect(()=>()=>{e.set(`positionReference`,null)},[e]),h.useEffect(()=>{n&&!a&&(c.current=!1)},[n,a]),h.useEffect(()=>{!n&&i&&(c.current=!0)},[n,i]);let y=h.useMemo(()=>{function e(e){d(e.pointerType)}return{onPointerDown:e,onPointerEnter:e,onMouseMove:_,onMouseEnter:_}},[_]);return h.useMemo(()=>n?{reference:y,trigger:y}:{},[n,y])}function jV(){return!1}function MV(e){var t,n;return{escapeKey:typeof e==`boolean`?e:(t=e==null?void 0:e.escapeKey)!=null&&t,outsidePress:typeof e==`boolean`?e:(n=e==null?void 0:e.outsidePress)==null||n}}function NV(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=jV,bubbles:s,externalTree:c}=t,l=e.useState(`open`),u=e.useState(`floatingElement`),{dataRef:d,events:f}=e.context,p=gV(c),m=yz(typeof i==`function`?i:()=>!1),g=typeof i==`function`?m:i,_=g!==!1,v=yz(()=>a),{escapeKey:y,outsidePress:b}=MV(s),x=h.useRef(!1),S=h.useRef(!1),C=h.useRef(!1),w=h.useRef(!1),T=h.useRef(!1),E=h.useRef(``),D=h.useRef(null),O=VL(),k=VL(),A=VL(),j=yz(()=>{k.clear(),d.current.insideReactTree=!1}),M=yz(e=>{var t;let n=(t=d.current.floatingContext)==null?void 0:t.nodeId;return(p?tB(p.nodesRef.current,n):[]).some(t=>{var n;return((n=t.context)==null?void 0:n.open)&&!t.context.dataRef.current[e]})}),N=yz(t=>NR(t,e.select(`floatingElement`))||NR(t,e.select(`domReferenceElement`))),P=yz(t=>{o()&&e.setOpen(!1,GR(qR,t.nativeEvent))}),F=yz(t=>{if(!l||!n||!r||t.key!==`Escape`)return;let i=aR(t)?t.nativeEvent:t;if(T.current||i.isComposing||!y&&M(`__escapeKeyBubbles`))return;let a=GR($R,i);e.setOpen(!1,a),a.isCanceled||t.preventDefault(),!y&&!a.isPropagationAllowed&&t.stopPropagation()}),I=yz(()=>{d.current.insideReactTree=!0,k.start(0,j)}),L=yz(t=>{if(!l||!n||t.button!==0)return;let r=pR(t.nativeEvent);dR(e.select(`floatingElement`),r)&&(x.current||(x.current=!0,S.current=!1))}),R=yz(e=>{l&&n&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&x.current&&(S.current=!0)});h.useEffect(()=>{function e(e){e.open||(w.current=!1)}return f.on(`openchange`,e),()=>{f.off(`openchange`,e)}},[f]),h.useEffect(()=>j,[j]),h.useEffect(()=>{if(!l||!n)return l||(w.current=!1,T.current=!1,E.current=``,D.current=null),j;d.current.__escapeKeyBubbles=y,d.current.__outsidePressBubbles=b;let t=new BL,i=Dz(u);function a(){A.clear(),T.current=!0}function o(){T.current=!0,A.start(tR?5:0,()=>{T.current=!1})}function s(){C.current=!0,t.start(0,()=>{C.current=!1})}function c(){x.current=!1,S.current=!1}function f(){let e=E.current,t=e===`pen`||!e?`mouse`:e,n=v(),r=typeof n==`function`?n():n;return typeof r==`string`?r:r[t]}function m(e){let t=f();return t===`intentional`&&e.type!==`click`||t===`sloppy`&&e.type===`click`}function h(e){var t;let n=(t=d.current.floatingContext)==null?void 0:t.nodeId,r=p&&tB(p.nodesRef.current,n).some(t=>{var n;return NR(e,(n=t.context)==null?void 0:n.elements.floating)});return N(e)||r}function k(n){if(m(n)){n.type!==`click`&&!N(n)&&(t.clear(),C.current=!1),j();return}if(d.current.insideReactTree){j();return}let r=pR(n),i=`[${rB(`inert`)}]`,a=GS(r)?r.getRootNode():null,o=Array.from((qS(a)?a:Dz(e.select(`floatingElement`))).querySelectorAll(i)),s=e.context.triggerElements;if(r&&(s.hasElement(r)||s.hasMatchingElement(e=>dR(e,r))))return;let c=GS(r)?r:null;for(;c&&!iC(c);){let e=sC(c);if(iC(e)||!GS(e))break;c=e}if(!(o.length&&GS(r)&&!PR(r)&&!dR(r,e.select(`floatingElement`))&&o.every(e=>!dR(c,e)))){if(KS(r)&&!(`touches`in n)){let e=iC(r),t=aC(r),i=/auto|scroll/,a=e||i.test(t.overflowX),o=e||i.test(t.overflowY),s=a&&r.clientWidth>0&&r.scrollWidth>r.clientWidth,c=o&&r.clientHeight>0&&r.scrollHeight>r.clientHeight,l=t.direction===`rtl`,u=c&&(l?n.offsetX<=r.offsetWidth-r.clientWidth:n.offsetX>r.clientWidth),d=s&&n.offsetY>r.clientHeight;if(u||d)return}if(!h(n)){if(f()===`intentional`){if(n.detail!==0&&!oR(n)&&!w.current)return;if(C.current){t.clear(),C.current=!1;return}}typeof g==`function`&&!g(n)||M(`__outsidePressBubbles`)||(e.setOpen(!1,GR(XR,n)),j())}}}function P(t){f()===`sloppy`&&t.pointerType!==`touch`&&e.select(`open`)&&n&&!N(t)&&k(t)}function I(t){if(f()!==`sloppy`||!e.select(`open`)||!n||N(t))return;let r=t.touches[0];r&&(D.current={startTime:Date.now(),startX:r.clientX,startY:r.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},O.start(1e3,()=>{D.current&&(D.current.dismissOnTouchEnd=!1,D.current.dismissOnMouseDown=!1)}))}function L(e,t){let n=pR(e);if(!n)return;let r=oz(n,e.type,()=>{t(e),r()})}function R(e){E.current=`touch`,L(e,I)}function z(e){O.clear(),e.type===`pointerdown`&&(e.button===0&&(w.current=!0),E.current=e.pointerType),(e.type!==`mousedown`||!D.current||D.current.dismissOnMouseDown)&&L(e,e=>{e.type===`pointerdown`?P(e):k(e)})}function B(e){if(e.type===`pointercancel`&&(w.current=!1),!x.current)return;let n=S.current;c(),f()===`intentional`&&(e.type===`pointercancel`?n&&s():h(e)||(n?s():(typeof g!=`function`||g(e))&&(t.clear(),C.current=!0,j())))}function ee(e){if(f()!==`sloppy`||!D.current||N(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-D.current.startX),r=Math.abs(t.clientY-D.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(D.current.dismissOnTouchEnd=!0),i>10&&(k(e),O.clear(),D.current=null)}function V(e){L(e,ee)}function te(e){f()===`sloppy`&&D.current&&!N(e)&&(D.current.dismissOnTouchEnd&&k(e),O.clear(),D.current=null)}function H(e){L(e,te)}let U=sz(r&&sz(oz(i,`keydown`,F),oz(i,`compositionstart`,a),oz(i,`compositionend`,o)),_&&sz(oz(i,`click`,z,!0),oz(i,`pointerdown`,z,!0),oz(i,`pointerup`,B,!0),oz(i,`pointercancel`,B,!0),oz(i,`mousedown`,z,!0),oz(i,`mouseup`,B,!0),oz(i,`touchstart`,R,{capture:!0,passive:!0}),oz(i,`touchmove`,V,{capture:!0,passive:!0}),oz(i,`touchend`,H,{capture:!0,passive:!0})));return()=>{U(),t.clear(),c(),C.current=!1}},[d,u,r,_,g,l,n,y,b,F,j,v,M,N,p,e,O,A]);let z=h.useMemo(()=>({onKeyDown:F,onPointerDown:P,onClick:P}),[F,P]),B=h.useMemo(()=>({onKeyDown:F,onPointerDown:R,onMouseDown:R,onClickCapture:I,onMouseDownCapture(e){I(),L(e)},onPointerDownCapture(e){I(),L(e)},onMouseUpCapture:I,onTouchEndCapture:I,onTouchMoveCapture:I}),[F,I,L,R]);return h.useMemo(()=>n?{reference:z,floating:B,trigger:z}:{},[n,z,B])}function PV(e){let{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:i,nested:a,onOpenChange:o}=e,s=t.useState(`open`),c=t.useState(`activeTriggerElement`),l=t.useState(n?`popupElement`:`positionerElement`),u=o;return t.useSyncedValue(`floatingId`,i),NL(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:l};GS(c)&&(e.domReferenceElement=c),r.state.positionReference===r.state.referenceElement&&(e.positionReference=c),r.update(e)},[s,i,c,l,r]),r.context.onOpenChange=u,r.context.nested=a,r}function FV(e,t=!1,n=!1,r=!1){let[i,a]=h.useState(e&&t?`idle`:void 0),[o,s]=h.useState(e&&!r);return e&&!o&&(s(!0),a(`starting`)),!e&&o&&i!==`ending`&&!n&&a(`ending`),!e&&!o&&i===`ending`&&a(void 0),NL(()=>{if(!e&&o&&i!==`ending`&&n){let e=Tz.request(()=>{a(`ending`)});return()=>{Tz.cancel(e)}}},[e,o,i,n]),NL(()=>{if(!e||t||i===void 0)return;let n=Tz.request(()=>{a(void 0)});return()=>{Tz.cancel(n)}},[t,e,i]),NL(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=Tz.request(()=>{a(`idle`)});return()=>{Tz.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}function IV(e,t){return e.getAnimations(t).filter(e=>{var t;let n=(t=e.effect)==null?void 0:t.getTiming();return(n==null?void 0:n.duration)!==1/0&&(n==null?void 0:n.iterations)!==1/0})}var LV=null;function RV(e){if(!LV){let e=[];LV=e,queueMicrotask(()=>{LV=null,n.flushSync(()=>{for(let t of e)t()})})}LV.push(e)}function zV(e,t=!1,r=!1){let i=Ez();return yz((a,o=null)=>{i.cancel();let s=_V(e);if(s==null)return;let c=s,l=()=>{r?RV(()=>{o!=null&&o.aborted||a()}):n.flushSync(a)};if(typeof c.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED){a();return}function u(){Promise.all(IV(c).map(e=>e.finished.then(AL))).then(()=>{o!=null&&o.aborted||l()},()=>{o!=null&&o.aborted||(IV(c).some(e=>e.pending||e.playState!==`finished`)?u():l())})}if(t){let e=gR;if(!c.hasAttribute(e)){i.request(u);return}let t=new MutationObserver(()=>{c.hasAttribute(e)||(t.disconnect(),u())});t.observe(c,{attributes:!0,attributeFilter:[e]}),o==null||o.addEventListener(`abort`,()=>t.disconnect(),{once:!0})}else i.request(u)})}function BV(e){let{enabled:t=!0,open:n,ref:r,batch:i=!1,onComplete:a}=e,o=yz(a),s=zV(r,n,i);h.useEffect(()=>{if(!t)return;let e=new AbortController;return s(o,e.signal),()=>{e.abort()}},[t,n,o,s])}function VV(e){let{open:t,ref:n,preventUnmountOnClose:r,setPreventUnmountOnClose:i,onUnmount:a,animateInitialOpen:o}=e,s=yz(i),{mounted:c,setMounted:l,transitionStatus:u}=FV(t,!1,!1,o),d=!t&&r;NL(()=>{t&&s(!1)},[t,s]);let f=h.useRef(c),p=h.useRef(!1),m=_B(),g=()=>{f.current=!1,l(!1),a()};NL(()=>{f.current=c,p.current&&(p.current=!1,!t&&c&&g())});let _=yz(()=>{f.current&&(t?(p.current=!0,m()):g())});return BV({enabled:c&&!t&&!d,open:t,ref:n,onComplete(){t||_()}}),{mounted:c,transitionStatus:u,preventUnmountingOnClose:d,forceUnmount:_}}var HV={tabIndex:-1,[mR]:``};function UV(e){return t=>t!==`touch`||e.current}function WV(e,t=!1){let n=xB(),r=hV()!=null,i=SL(()=>e(n,r)).current;return PV({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:i.setOpen}),i}function GV({handle:e,store:t}){return NL(()=>e.attachStore(t),[e,t]),null}function KV(e){let t=e.context.triggerElements.size;e.select(`open`)&&e.state.triggerCount!==t&&e.set(`triggerCount`,t)}function qV(e,t){let n=h.useRef(null);return yz(r=>{let i=n.current;if(i!==null){if(i.element===r&&i.store===t&&i.id===e)return;n.current=null;let a=i.store;a.context.triggerElements.getById(i.id)===i.element&&(a.context.triggerElements.delete(i.id),KV(a))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),KV(t))})}function JV(e,t,n,r=!1){var i;let a=e.preventUnmountingOnClose;t?a=!1:r&&(a=!0);let o=(i=n==null?void 0:n.id)==null?null:i,s=e.activeTriggerId,c=e.activeTriggerElement;return(o||t)&&(s=o,c=n==null?null:n),{open:t,preventUnmountingOnClose:a,activeTriggerId:s,activeTriggerElement:c,openedWithoutTrigger:t?n==null:e.openedWithoutTrigger}}function YV(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function XV(e,t,r,i={}){var a,o,s;let c=r.reason,l=c===JR,u=t&&c===`trigger-focus`,d=!t&&(c===`trigger-press`||c===`escape-key`),f=YV(r);if((a=(o=e.context).onOpenChange)==null||a.call(o,t,r),r.isCanceled)return;(s=i.onBeforeDispatch)==null||s.call(i),e.state.floatingRootContext.dispatchOpenChange(t,r);let p=()=>{let n=JV(e.state,t,r.trigger,f()),a=E(E({},i.extraState),n);u?a.instantType=`focus`:d?a.instantType=`dismiss`:l&&(a.instantType=void 0),e.update(a)};l?n.flushSync(p):p()}function ZV(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=qV(e,n),o=yz(t=>{let i=n.select(`open`),a=n.select(`activeTriggerId`);if(a===e){let e=E({activeTriggerElement:t},i?r:null);n.update(e)}else if(a==null&&i&&!n.state.openedWithoutTrigger){let i=E({activeTriggerId:e==null?null:e,activeTriggerElement:t},r);n.update(i)}}),s=yz(e=>{a(e),e&&o(e)});return NL(()=>(s(t.current),()=>s(null)),[s,t,n,e]),NL(()=>{if(i){let e=E({activeTriggerElement:t.current},r);n.update(e)}},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function QV(e,t={}){let{closeOnActiveTriggerUnmount:n=!1}=t,r=h.useRef(null),i=e.useState(`open`);NL(()=>{if(!i){r.current=null,e.state.triggerCount!==0&&e.set(`triggerCount`,0),e.state.openedWithoutTrigger&&e.set(`openedWithoutTrigger`,!1);return}let t=e.context.triggerElements.size,a={};e.state.triggerCount!==t&&(a.triggerCount=t);let o=e.select(`activeTriggerId`),s=null;if(o){let t=e.context.triggerElements.getById(o);if(t)r.current=o,t!==e.state.activeTriggerElement&&(a.activeTriggerElement=t);else{for(let[t,n]of e.context.triggerElements.entries())if(n===e.state.activeTriggerElement){a.activeTriggerId=t,a.activeTriggerElement=n,r.current=t;break}a.activeTriggerId===void 0&&(r.current===o?s=o:r.current=null)}}else r.current=null;if(!s&&!o&&!e.state.openedWithoutTrigger&&t===1){let t=e.context.triggerElements.entries().next();if(!t.done){let[e,n]=t.value;a.activeTriggerId=e,a.activeTriggerElement=n,r.current=e}}(a.triggerCount!==void 0||a.activeTriggerId!==void 0||a.activeTriggerElement!==void 0)&&e.update(a),s&&n&&queueMicrotask(()=>{if(e.select(`open`)&&e.select(`activeTriggerId`)===s&&!e.context.triggerElements.getById(s)){let t=GR(KR);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,e.useState(`triggerCount`),e.useState(`activeTriggerId`),e.useState(`activeTriggerElement`),n])}function $V(e,t,n,r){let{mounted:i,transitionStatus:a,forceUnmount:o}=VV({open:e,ref:t.context.popupRef,preventUnmountOnClose:t.useState(`preventUnmountingOnClose`),setPreventUnmountOnClose:e=>t.set(`preventUnmountingOnClose`,e),animateInitialOpen:r,onUnmount(){var e,r;t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n==null||n(),(e=(r=t.context).onOpenChangeComplete)==null||e.call(r,!1)}});return SL(()=>(t.set(`mounted`,i),null)),t.useSyncedValues({mounted:i,transitionStatus:a}),{forceUnmount:o,transitionStatus:a}}function eH(e,t){e.useSyncedValues(t),NL(()=>()=>{e.update({activeTriggerProps:ML,inactiveTriggerProps:ML,popupProps:ML})},[e])}function tH(e,t){NL(()=>{!t&&e.state.openMethod!==null&&e.set(`openMethod`,null)},[t,e]),NL(()=>()=>{e.state.openMethod!==null&&e.set(`openMethod`,null)},[e])}var nH;function rH(e){nH!=null||(nH=new WeakMap);let t=nH.get(e);return t||(t=new WeakMap,nH.set(e,t)),t}var iH=class{constructor(){S(this,`idMap`,new Map)}add(e,t){if(process.env.NODE_ENV!==`production`){let n=rH(this),r=n.get(t);if(r!==void 0&&r!==e)throw Error(`Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.`);let i=this.idMap.get(e);i!==void 0&&i!==t&&n.delete(i),n.set(t,e)}this.idMap.set(e,t)}delete(e){if(process.env.NODE_ENV!==`production`){let n=this.idMap.get(e);if(n!==void 0){var t;nH==null||(t=nH.get(this))==null||t.delete(n)}}this.idMap.delete(e)}hasElement(e){for(let t of this.idMap.values())if(t===e)return!0;return!1}hasMatchingElement(e){for(let t of this.idMap.values())if(e(t))return!0;return!1}getById(e){return this.idMap.get(e)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}},aH=u((e=>{var t=require("react");function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch(e){return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),oH=u((e=>{process.env.NODE_ENV!==`production`&&(function(){function t(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}function n(e,t){d||a.startTransition===void 0||(d=!0,console.error(`You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release.`));var n=t();if(!f){var i=t();o(n,i)||(console.error(`The result of getSnapshot should be cached to avoid an infinite loop`),f=!0)}i=s({inst:{value:n,getSnapshot:t}});var p=i[0].inst,m=i[1];return l(function(){p.value=n,p.getSnapshot=t,r(p)&&m({inst:p})},[e,n,t]),c(function(){return r(p)&&m({inst:p}),e(function(){r(p)&&m({inst:p})})},[e]),u(n),n}function r(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!o(e,n)}catch(e){return!0}}function i(e,t){return t()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart==`function`&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var a=require("react"),o=typeof Object.is==`function`?Object.is:t,s=a.useState,c=a.useEffect,l=a.useLayoutEffect,u=a.useDebugValue,d=!1,f=!1,p=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?i:n;e.useSyncExternalStore=a.useSyncExternalStore===void 0?p:a.useSyncExternalStore,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop==`function`&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()})),sH=u(((e,t)=>{t.exports=process.env.NODE_ENV===`production`?aH():oH()})),cH=u((e=>{var t=require("react"),n=sH();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),lH=u((e=>{process.env.NODE_ENV!==`production`&&(function(){function t(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart==`function`&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var n=require("react"),r=sH(),i=typeof Object.is==`function`?Object.is:t,a=r.useSyncExternalStore,o=n.useRef,s=n.useEffect,c=n.useMemo,l=n.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop==`function`&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()})),uH=u(((e,t)=>{t.exports=process.env.NODE_ENV===`production`?cH():lH()})),dH=sH(),fH=uH(),pH=CB(19)?gH:_H;function mH(e,t,n,r,i){return pH(e,t,n,r,i)}function hH(e,t,n,r,i){let a=h.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,dH.useSyncExternalStore)(e.subscribe,a,a)}EL({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,i)||(t=!0,r.value=i)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,dH.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function gH(e,t,n,r,i){let a=TL();if(!a)return hH(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],s.store===e&&s.selector===t&&Object.is(s.a1,n)&&Object.is(s.a2,r)&&Object.is(s.a3,i)||(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.value=t(e.getSnapshot(),n,r,i))):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i)},a.syncHooks.push(s)),s.value}function _H(e,t,n,r,i){return(0,fH.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var vH=class{static create(e){return new this(e)}constructor(e){S(this,`subscribe`,e=>(this.listeners.add(e),()=>{this.listeners.delete(e)})),S(this,`getSnapshot`,()=>this.state),this.state=e,this.listeners=new Set,this.updateTick=0}setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState(E(E({},this.state),e));return}}set(e,t){Object.is(this.state[e],t)||this.setState(E(E({},this.state),{},{[e]:t}))}notifyAll(){let e=E({},this.state);this.setState(e)}use(e,t,n,r){return mH(this,e,t,n,r)}},yH=class extends vH{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){h.useDebugValue(e);let n=this;NL(()=>{n.state[e]!==t&&n.set(e,t)},[n,e,t])}useSyncedValueWithCleanup(e,t){let n=this;NL(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;if(process.env.NODE_ENV!==`production`){h.useDebugValue(e,e=>Object.keys(e));let t=h.useRef(Object.keys(e)).current,n=Object.keys(e);(t.length!==n.length||t.some((e,t)=>e!==n[t]))&&console.error(`ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.`)}NL(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){h.useDebugValue(e);let n=this,r=t!==void 0;if(NL(()=>{r&&!Object.is(n.state[e],t)&&n.setState(E(E({},n.state),{},{[e]:t}))},[n,e,t,r]),process.env.NODE_ENV!==`production`){var i;let t=(i=this.controlledValues)==null?this.controlledValues=new Map:i;t.has(e)||t.set(e,r);let n=t.get(e);n!==void 0&&n!==r&&console.error(`A component is changing the ${n?``:`un`}controlled state of ${e.toString()} to be ${n?`un`:``}controlled. Elements should not switch from uncontrolled to controlled (or vice versa).`)}}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return h.useDebugValue(e),mH(this,this.selectors[e],t,n,r)}useContextCallback(e,t){h.useDebugValue(e);let n=yz(t==null?AL:t);this.context[e]=n}useStateSetter(e){let t=h.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}},bH=[`syncOnly`,`nested`,`onOpenChange`,`triggerElements`],xH={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>{var t;return(t=e.positionReference)==null?e.referenceElement:t},floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId},SH=class extends yH{constructor(e){let{syncOnly:t,nested:n,onOpenChange:r,triggerElements:i}=e,a=W(e,bH);super(E(E({},a),{},{positionReference:a.referenceElement,domReferenceElement:a.referenceElement}),{onOpenChange:r,dataRef:{current:{}},events:fV(),nested:n,triggerElements:i},xH),S(this,`syncOpenEvent`,(e,t)=>{(!e||!this.state.open||t!=null&&lR(t))&&(this.context.dataRef.current.openEvent=e?t:void 0)}),S(this,`dispatchOpenChange`,(e,t)=>{this.syncOpenEvent(e,t.event);let n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit(`openchange`,n)}),S(this,`setOpen`,(e,t)=>{var n,r;if(this.syncOnly){var i,a;(i=(a=this.context).onOpenChange)==null||i.call(a,e,t)}else this.dispatchOpenChange(e,t),(n=(r=this.context).onOpenChange)==null||n.call(r,e,t)}),this.syncOnly=t}};function CH(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new SH({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,openedWithoutTrigger:!1,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:ML,inactiveTriggerProps:ML,popupProps:ML}}var wH=e=>{var t;return(t=e.triggerIdProp)==null?e.activeTriggerId:t},TH=e=>{var t;return(t=e.openProp)==null?e.open:t},EH=e=>{var t,n;return((t=(n=e.popupElement)==null?void 0:n.id)==null?e.floatingId:t)||void 0};function DH(e,t){return t!==void 0&&TH(e)&&wH(e)===t}function OH(e,t){return DH(e,t)?!0:t!==void 0&&TH(e)&&wH(e)==null&&!e.openedWithoutTrigger&&e.triggerCount===1}var kH={open:TH,mounted:e=>e.mounted,transitionStatus:e=>TH(e)&&!e.mounted?`starting`:e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:wH,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:EH,isTriggerActive:(e,t)=>t!==void 0&&wH(e)===t,isOpenedByTrigger:(e,t)=>DH(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&wH(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>OH(e,t)?EH(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function AH(e){let t=h.useCallback(t=>e===void 0?AL:e.subscribeStore(t),[e]),n=h.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,dH.useSyncExternalStore)(t,n,()=>e==null?void 0:e.serverStore)}var jH=ZL&&tR;function MH(e,t={}){let{enabled:n=!0,delay:r}=t,{events:i,dataRef:a}=e.context,o=h.useRef(!1),s=h.useRef(null),c=h.useRef(!0),l=VL();h.useEffect(()=>{let t=e.select(`domReferenceElement`);if(!n)return;let r=HS(t);function i(){let t=e.select(`domReferenceElement`);!e.select(`open`)&&KS(t)&&t===uR(Dz(t))&&(o.current=!0,s.current=t)}function a(){c.current=!0}function l(){c.current=!1}return sz(oz(r,`blur`,i),jH&&oz(r,`keydown`,a,!0),jH&&oz(r,`pointerdown`,l,!0))},[e,n]),h.useEffect(()=>{if(!n)return;function t(t){if(t.reason===`trigger-press`||t.reason===`escape-key`){let t=e.select(`domReferenceElement`);GS(t)&&(s.current=t,o.current=!0)}}return i.on(`openchange`,t),()=>{i.off(`openchange`,t)}},[i,n,e]);let u=h.useMemo(()=>{function t(){o.current=!1,s.current=null}return{onMouseLeave(){t()},onFocus(n){let i=n.currentTarget;if(o.current){if(s.current===i)return;t()}let a=pR(n.nativeEvent);if(GS(a)){if(jH&&!n.relatedTarget){if(!c.current&&!FR(a))return}else if(!RR(a))return}let u=MR(n.relatedTarget,e.context.triggerElements),{nativeEvent:d,currentTarget:f}=n;e.select(`open`)&&u||!r?e.setOpen(!0,GR(YR,d,f)):l.start(r,()=>{o.current||e.setOpen(!0,GR(YR,d,f))})},onBlur(n){t();let r=n.relatedTarget,i=n.nativeEvent,o=GS(r)&&r.hasAttribute(rB(`focus-guard`))&&r.getAttribute(`data-type`)===`outside`;l.start(0,()=>{var t;let n=e.select(`domReferenceElement`),s=uR(Dz(n));!r&&s===n||dR((t=a.current.floatingContext)==null?void 0:t.refs.floating.current,s)||dR(n,s)||o||MR(r==null?s:r,e.context.triggerElements)||e.setOpen(!1,GR(YR,i))})}}},[a,r,e,l]);return h.useMemo(()=>n?{reference:u,trigger:u}:{},[n,u])}var NH=class e{constructor(){S(this,`pointerType`,void 0),S(this,`interactedInside`,!1),S(this,`handler`,void 0),S(this,`blockMouseMove`,!0),S(this,`performedPointerEventsMutation`,!1),S(this,`pointerEventsScopeElement`,null),S(this,`pointerEventsReferenceElement`,null),S(this,`pointerEventsFloatingElement`,null),S(this,`restTimeoutPending`,!1),S(this,`openChangeTimeout`,new BL),S(this,`restTimeout`,new BL),S(this,`handleCloseOptions`,void 0),S(this,`dispose`,()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()}),S(this,`disposeEffect`,()=>this.dispose)}static create(){return new e}},PH=new WeakMap;function FH(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;if(t&&PH.get(t)===e){var n,r,i;(n=e.pointerEventsScopeElement)==null||n.style.removeProperty(`pointer-events`),(r=e.pointerEventsReferenceElement)==null||r.style.removeProperty(`pointer-events`),(i=e.pointerEventsFloatingElement)==null||i.style.removeProperty(`pointer-events`),PH.delete(t)}e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function IH(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=PH.get(n);a&&a!==e&&FH(a),FH(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,PH.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function LH(e){let t=e.context.dataRef.current,n=SL(()=>{var e;return(e=t.hoverInteractionState)==null?NH.create():e}).current;return t.hoverInteractionState||(t.hoverInteractionState=n),RL(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function RH(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=e.useState(`open`),o=e.useState(`floatingElement`),s=e.useState(`domReferenceElement`),{dataRef:c}=e.context,l=gV(),u=hV(),d=LH(e),f=VL(),p=yz(()=>{var e;return UR((e=c.current.openEvent)==null?void 0:e.type,d.interactedInside)}),m=yz(()=>{var e;return WR((e=c.current.openEvent)==null?void 0:e.type)}),g=yz(()=>{FH(d)});NL(()=>{a||(d.pointerType=void 0,d.restTimeoutPending=!1,d.interactedInside=!1,g())},[a,d,g]),h.useEffect(()=>g,[g]),NL(()=>{var e;if(n&&a&&(e=d.handleCloseOptions)!=null&&e.blockPointerEvents&&m()&&GS(s)&&o){var t,r,i,c,f,p,h;let e=s,n=o,a=Dz(o),m=l==null||(t=l.nodesRef.current.find(e=>e.id===u))==null||(t=t.context)==null?void 0:t.elements.floating;m&&(m.style.pointerEvents=``);let _=d.pointerEventsScopeElement===n?null:d.pointerEventsScopeElement,v=m===n?null:m,y=(r=(i=(c=(f=(p=d.handleCloseOptions)==null||(h=p.getScope)==null?void 0:h.call(p))==null?_:f)==null?v:c)==null?fR(e,`[data-rootownerid]`):i)==null?a.body:r;return IH(d,{scopeElement:y,referenceElement:e,floatingElement:n}),()=>{g()}}},[n,a,s,o,d,m,l,u,g]),h.useEffect(()=>{if(!n)return;function t(){return!!(l&&u&&tB(l.nodesRef.current,u).length>0)}function a(t){let n=VR(r,`close`,d.pointerType),i=()=>{e.setOpen(!1,GR(JR,t)),l==null||l.events.emit(`floating.closed`,t)};n?d.openChangeTimeout.start(n,i):(d.openChangeTimeout.clear(),i())}function s(e){let t=pR(e);IR(t)?d.interactedInside=fR(t,`[aria-haspopup]`)!=null:d.interactedInside=!1}function h(){d.openChangeTimeout.clear(),f.clear(),l==null||l.events.off(`floating.closed`,v),g()}function _(n){var r,o;if(t()&&l){l.events.on(`floating.closed`,v);return}if(MR(n.relatedTarget,e.context.triggerElements))return;let s=(r=(o=c.current.floatingContext)==null?void 0:o.nodeId)==null?i:r,u=n.relatedTarget;l&&s&&GS(u)&&tB(l.nodesRef.current,s,!1).some(e=>{var t;return dR((t=e.context)==null?void 0:t.elements.floating,u)})||(d.handler?d.handler(n):(g(),m()&&!p()&&a(n)))}function v(n){l&&u&&!t()&&f.start(0,()=>{l.events.off(`floating.closed`,v),e.setOpen(!1,GR(JR,n)),l.events.emit(`floating.closed`,n)})}let y=o;return sz(y&&oz(y,`mouseenter`,h),y&&oz(y,`mouseleave`,_),y&&oz(y,`pointerdown`,s,!0),()=>{l==null||l.events.off(`floating.closed`,v)})},[n,o,e,c,r,i,m,p,g,d,l,u,f])}var zH={current:null};function BH(e,t={}){let{enabled:r=!0,delay:i=0,handleClose:a=null,mouseOnly:o=!1,restMs:s=0,move:c=!0,triggerElementRef:l=zH,externalTree:u,isActiveTrigger:d=!0,getHandleCloseContext:f,isClosing:p,shouldOpen:m,guardStaleOpen:g=!1}=t,{dataRef:_,events:v}=e.context,y=gV(u),b=LH(e),x=h.useRef(!1),S=mz(a),C=mz(i),w=mz(s),T=mz(r),D=mz(m),O=mz(p),k=yz(()=>{var e;return UR((e=_.current.openEvent)==null?void 0:e.type,b.interactedInside)}),A=yz(()=>{var e;return((e=D.current)==null?void 0:e.call(D))!==!1}),j=yz((t,n,r)=>{let i=e.context.triggerElements;if(i.hasElement(n))return!t||!dR(t,n);if(!GS(r))return!1;let a=r;return i.hasMatchingElement(e=>dR(e,a))&&(!t||!dR(t,a))}),M=yz(()=>{b.handler&&(Dz(e.select(`domReferenceElement`)).removeEventListener(`mousemove`,b.handler),b.handler=void 0)}),N=yz(()=>{FH(b)});return d&&(b.handleCloseOptions=a==null?void 0:a.__options),h.useEffect(()=>M,[M]),h.useEffect(()=>{if(!r)return;function e(e){e.open?x.current=!1:(x.current=e.reason===JR,M(),b.openChangeTimeout.clear(),b.restTimeout.clear(),b.blockMouseMove=!0,b.restTimeoutPending=!1)}return v.on(`openchange`,e),()=>{v.off(`openchange`,e)}},[r,v,b,M]),h.useEffect(()=>{var t;if(!r)return;function n(t,n=!0){let r=VR(C.current,`close`,b.pointerType);r?b.openChangeTimeout.start(r,()=>{e.setOpen(!1,GR(JR,t)),y==null||y.events.emit(`floating.closed`,t)}):n&&(b.openChangeTimeout.clear(),e.setOpen(!1,GR(JR,t)),y==null||y.events.emit(`floating.closed`,t))}let i=(t=l.current)==null?d?e.select(`domReferenceElement`):null:t;if(!GS(i))return;function a(t){var n,r,i;if(b.openChangeTimeout.clear(),b.blockMouseMove=!1,o&&!cR(b.pointerType))return;let a=HR(w.current),s=VR(C.current,`open`,b.pointerType),c=pR(t),l=(n=t.currentTarget)==null?null:n,u=e.select(`domReferenceElement`),d=l;if(GS(c)&&!e.context.triggerElements.hasElement(c)){for(let t of e.context.triggerElements.elements())if(dR(t,c)){d=t;break}}GS(l)&&GS(u)&&!e.context.triggerElements.hasElement(l)&&dR(l,u)&&(d=u);let f=d!=null&&j(u,d,c),p=e.select(`open`),m=(r=(i=O.current)==null?void 0:i.call(O))==null?e.select(`transitionStatus`)===`ending`:r,h=!p&&m&&x.current,g=!f&&GS(d)&&GS(u)&&dR(u,d)&&h,_=a>0&&!s,v=f&&(p||h)||g,y=!p||f;v?A()&&e.setOpen(!0,GR(JR,t,d)):_||(s?b.openChangeTimeout.start(s,()=>{y&&A()&&e.setOpen(!0,GR(JR,t,d))}):y&&A()&&e.setOpen(!0,GR(JR,t,d)))}function s(t){var r;if(k()){N();return}M();let i=Dz(e.select(`domReferenceElement`));b.restTimeout.clear(),b.restTimeoutPending=!1;let a=(r=_.current.floatingContext)==null?f==null?void 0:f():r;if(!MR(t.relatedTarget,e.context.triggerElements)){if(S.current&&a){e.select(`open`)||b.openChangeTimeout.clear();let r=l.current;b.handler=S.current(E(E({},a),{},{tree:y,x:t.clientX,y:t.clientY,onClose(){N(),M(),T.current&&!k()&&r===e.select(`domReferenceElement`)&&n(t,!0)}})),i.addEventListener(`mousemove`,b.handler),b.handler(t)}else b.pointerType===`touch`&&dR(e.select(`floatingElement`),t.relatedTarget)||n(t)}}function u(e){dR(i,e.relatedTarget)||(b.openChangeTimeout.clear(),b.restTimeout.clear(),b.restTimeoutPending=!1)}let p=g?oz(i,`mouseout`,u):void 0;return c?sz(oz(i,`mousemove`,a,{once:!0}),oz(i,`mouseenter`,a),oz(i,`mouseleave`,s),p):sz(oz(i,`mouseenter`,a),oz(i,`mouseleave`,s),p)},[M,N,_,C,e,r,S,b,d,j,k,o,c,w,l,y,T,f,O,A,g]),h.useMemo(()=>{if(!r)return;function t(e){b.pointerType=e.pointerType}return{onPointerDown:t,onPointerEnter:t,onMouseMove(t){var r;let{nativeEvent:i}=t,a=t.currentTarget,s=e.select(`domReferenceElement`),c=e.select(`open`),l=j(s,a,t.target);if(o&&!cR(b.pointerType))return;if(c&&l&&(r=b.handleCloseOptions)!=null&&r.blockPointerEvents){let t=e.select(`floatingElement`);if(t){var u,d,f;let e=(u=(d=b.handleCloseOptions)==null||(f=d.getScope)==null?void 0:f.call(d))==null?a.ownerDocument.body:u;IH(b,{scopeElement:e,referenceElement:a,floatingElement:t})}}let p=HR(w.current);if(c&&!l||p===0||!l&&b.restTimeoutPending&&Math.pow(t.movementX,2)+Math.pow(t.movementY,2)<2)return;b.restTimeout.clear();function m(){if(b.restTimeoutPending=!1,k())return;let t=e.select(`open`);!b.blockMouseMove&&(!t||l)&&A()&&e.setOpen(!0,GR(JR,i,a))}b.pointerType===`touch`?n.flushSync(()=>{m()}):l&&c?m():(b.restTimeoutPending=!0,b.restTimeout.start(p,m))}}},[r,b,k,j,o,e,w,A])}var VH=.1,HH=VH*VH,UH=.5;function WH(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function GH(e,t,n,r,i,a,o,s,c,l){let u=!1;return WH(e,t,n,r,i,a)&&(u=!u),WH(e,t,i,a,o,s)&&(u=!u),WH(e,t,o,s,c,l)&&(u=!u),WH(e,t,c,l,n,r)&&(u=!u),u}function KH(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function qH(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function JH(e={}){let{blockPointerEvents:t=!1}=e,n=new BL,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r==null?void 0:r.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*HH;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=pR(r),g=r.type===`mouseleave`,_=dR(u,h),v=dR(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&GS(r.relatedTarget)&&dR(u,r.relatedTarget))return;function y(){return!!(s&&tB(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=qH(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=qH(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=qH(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=qH(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!KH(d,f,x)||!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?UH/2:UH*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+UH+1,o=C||T?S.bottom-UH:S.top,s=C?T?S.bottom-UH:S.top:S.bottom-UH;M=GH(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?UH/2:UH*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-UH,o=C||T?S.top+UH:S.bottom,s=C?T?S.top+UH:S.bottom:S.top+UH;M=GH(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?UH/2:UH*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+UH+1,o=w||E?S.right-UH:S.left,s=w?E?S.right-UH:S.left:S.right-UH;M=GH(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?UH/2:UH*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-UH,o=w||E?S.left+UH:S.right,s=w?E?S.left+UH:S.right:S.left+UH;M=GH(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options=E(E({},e),{},{blockPointerEvents:t}),r}var YH=E(E({},kH),{},{disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,appliedTriggerProps:(e,t)=>t?e.activeTriggerProps:void 0,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin}),XH=class extends yH{constructor(e,t,n){let r=new iH;super(ZH(e,r,t,n),QH(r),YH),S(this,`setOpen`,(e,t)=>{XV(this,e,t,{extraState:{openChangeReason:t.reason}})})}cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,GR(qR,e))}};function ZH(e,t,n,r=!1){return E(E({},CH(t,n,r)),{},{disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:`none`,disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0},e)}function QH(e){return{popupRef:h.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}var $H=DL(function(e){let{disabled:t=!1,defaultOpen:n=!1,open:r,disableHoverablePopup:i=!1,trackCursorAxis:a=`none`,actionsRef:o,onOpenChange:s,onOpenChangeComplete:c,handle:l,triggerId:u,defaultTriggerId:d=null,children:f}=e,p=WV((e,t)=>new XH({open:n,openProp:r,activeTriggerId:d,triggerIdProp:u},e,t));p.useControlledProp(`openProp`,r),p.useControlledProp(`triggerIdProp`,u),p.useContextCallback(`onOpenChange`,s),p.useContextCallback(`onOpenChangeComplete`,c);let m=p.useState(`open`),g=!t&&m,_=p.useState(`activeTriggerId`),v=p.useState(`mounted`),y=p.useState(`payload`);p.useSyncedValues({trackCursorAxis:a,disableHoverablePopup:i,disabled:t}),QV(p,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:b,transitionStatus:x}=$V(g,p),S=p.useState(`isInstantPhase`),C=p.useState(`instantType`),w=p.useState(`lastOpenChangeReason`),T=h.useRef(null);NL(()=>{m&&t&&p.setOpen(!1,GR(ez))},[m,t,p]),NL(()=>{x===`ending`&&w===`none`||x!==`ending`&&S?(C!==`delay`&&(T.current=C),p.set(`instantType`,`delay`)):T.current!==null&&(p.set(`instantType`,T.current),T.current=null)},[x,S,w,C,p]),NL(()=>{g&&_==null&&p.set(`payload`,void 0)},[p,_,g]),h.useImperativeHandle(o,()=>({unmount:b,close:()=>p.setOpen(!1,GR(tz))}),[b,p]);let E=g||v||!t&&a!==`none`;return(0,J.jsxs)(IL.Provider,{value:p,children:[l&&(0,J.jsx)(GV,{handle:l,store:p}),E&&(0,J.jsx)(eU,{store:p,disabled:t,trackCursorAxis:a}),typeof f==`function`?f({payload:y}):f]})});process.env.NODE_ENV!==`production`&&($H.displayName=`TooltipRoot`);function eU({store:e,disabled:t,trackCursorAxis:n}){var r;let i=e.useState(`floatingRootContext`),a=NV(i,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),o=AV(i,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),s=h.useMemo(()=>NB(o.reference,a.reference),[o.reference,a.reference]);return eH(e,{activeTriggerProps:s,inactiveTriggerProps:s,popupProps:(r=a.floating)==null?ML:r}),null}function tU(e){return xB(e,`base-ui`)}var nU=h.createContext(void 0);process.env.NODE_ENV!==`production`&&(nU.displayName=`TooltipProviderContext`);function rU(){return h.useContext(nU)}var iU=[`render`,`className`,`style`,`handle`,`payload`,`disabled`,`delay`,`closeOnClick`,`closeDelay`,`id`],aU=`data-base-ui-tooltip-trigger`;function oU(e){let t=pR(e);return GS(t)?t:null}var sU=OL(function(e,t){let{render:n,className:r,style:i,handle:a,payload:o,disabled:s,delay:c,closeOnClick:l=!0,closeDelay:u,id:d}=e,f=W(e,iU),p=LL(!0),m=AH(a),g=m==null?p:m;if(!g)throw Error(process.env.NODE_ENV===`production`?FL(82):`Base UI: <Tooltip.Trigger> must be either used within a <Tooltip.Root> component or provided with a handle.`);let _=tU(d),v=g.useState(`isTriggerActive`,_),y=g.useState(`isOpenedByTrigger`,_),b=g.useState(`floatingRootContext`),x=h.useRef(null),S=u==null?0:u,{registerTrigger:C,isMountedByThisTrigger:w}=ZV(_,x,g,{payload:o,closeOnClick:l,closeDelay:S}),T=rU(),{activeIdRef:E,delayRef:D,isInstantPhase:O,hasProvider:k}=az(b,{open:y}),A=LH(b);g.useSyncedValue(`isInstantPhase`,O);let j=g.useState(`disabled`),M=s==null?j:s,N=mz(M),P=g.useState(`trackCursorAxis`),F=g.useState(`disableHoverablePopup`),I=h.useRef(!1),L=VL(),R=h.useRef(void 0);function z(){var e;return k&&E.current!=null?0:(e=c==null?T:c)==null?600:e}function B(e){let t=x.current;if(!t||!e)return!1;let n=fR(e,`[${aU}]`);return n!==null&&n!==t&&dR(t,n)}function ee(e){let t=B(e);return I.current=t,t&&(A.openChangeTimeout.clear(),A.restTimeout.clear(),A.restTimeoutPending=!1,L.clear()),t}let V=BH(b,{enabled:!M,mouseOnly:!0,move:!1,handleClose:!F&&P!==`both`?JH():null,restMs:z,delay(){return u==null&&k?{close:VR(D.current,`close`)}:{close:S}},triggerElementRef:x,isActiveTrigger:v,isClosing:()=>g.select(`transitionStatus`)===`ending`,shouldOpen(){return!I.current}}),te=MH(b,{enabled:!M}).reference,H=e=>{let t=I.current,n=oU(e),r=ee(n),i=x.current,a=i&&n&&dR(i,n);if(r&&g.select(`open`)&&g.select(`lastOpenChangeReason`)===`trigger-hover`)g.setOpen(!1,GR(JR,e));else if(t&&!r&&a&&!N.current&&!g.select(`open`)&&i&&cR(R.current)){let t=()=>{I.current||N.current||g.select(`open`)||g.setOpen(!0,GR(JR,e,i))},n=z();n===0?(L.clear(),t()):L.start(n,t)}},U=g.useState(`appliedTriggerProps`,w||P!==`none`);return KB(`button`,e,{state:{open:y},ref:[t,C,x],props:[V,te,U,{onMouseOver(e){H(e.nativeEvent)},onFocus(e){B(oU(e.nativeEvent))&&e.preventBaseUIHandler()},onMouseLeave(){I.current=!1,L.clear(),R.current=void 0},onPointerEnter(e){R.current=e.pointerType},onPointerDown(e){R.current=e.pointerType,g.set(`closeOnClick`,l),l&&!g.select(`open`)&&g.cancelPendingOpen(e.nativeEvent)},onClick(e){l&&!g.select(`open`)&&g.cancelPendingOpen(e.nativeEvent)},id:_,[jR]:M?``:void 0,[aU]:M?void 0:``},f],stateAttributesMapping:OR})});process.env.NODE_ENV!==`production`&&(sU.displayName=`TooltipTrigger`);var cU=h.createContext(void 0);process.env.NODE_ENV!==`production`&&(cU.displayName=`TooltipPortalContext`);function lU(){let e=h.useContext(cU);if(e===void 0)throw Error(process.env.NODE_ENV===`production`?FL(70):`Base UI: <Tooltip.Portal> is missing.`);return e}var uU=[`children`,`container`,`className`,`render`,`style`],dU=h.forwardRef(function(e,t){let{children:r,container:i,className:a,render:o,style:s}=e,{node:c,subtree:l}=uV({container:i,ref:t,componentProps:e,elementProps:W(e,uU)});return!l&&!c?null:(0,J.jsxs)(h.Fragment,{children:[l,c&&n.createPortal(r,c)]})});process.env.NODE_ENV!==`production`&&(dU.displayName=`FloatingPortalLite`);var fU=[`keepMounted`],pU=h.forwardRef(function(e,t){let{keepMounted:n=!1}=e,r=W(e,fU);return LL().useState(`mounted`)||n?(0,J.jsx)(cU.Provider,{value:n,children:(0,J.jsx)(dU,E({ref:t},r))}):null});process.env.NODE_ENV!==`production`&&(pU.displayName=`TooltipPortal`);var mU=h.createContext(void 0);process.env.NODE_ENV!==`production`&&(mU.displayName=`TooltipPositionerContext`);function hU(){let e=h.useContext(mU);if(e===void 0)throw Error(process.env.NODE_ENV===`production`?FL(71):`Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>.`);return e}function gU(e){let{nodeId:t,externalTree:n,rootContext:r}=e,i=r.useState(`referenceElement`),a=r.useState(`floatingElement`),o=r.useState(`domReferenceElement`),s=r.useState(`open`),c=r.useState(`floatingId`),[l,u]=h.useState(null),d=h.useRef(null),f=gV(n),p=h.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),m=$C(E(E({},e),{},{elements:E(E({},p),l&&{reference:l})})),g=h.useCallback(e=>{let t=GS(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),m.refs.setReference(t)},[m.refs]),_=h.useMemo(()=>E(E({},m.refs),{},{setPositionReference:g,domReference:d}),[m.refs,g]),v=h.useMemo(()=>E(E({},m.elements),{},{domReference:o}),[m.elements,o]),y=h.useMemo(()=>E(E({},m),{},{dataRef:r.context.dataRef,open:s,onOpenChange:r.setOpen,events:r.context.events,floatingId:c,refs:_,elements:v,nodeId:t,rootStore:r}),[m,_,v,t,r,s,c]);return NL(()=>{o&&(d.current=o)},[o]),NL(()=>{r.context.dataRef.current.floatingContext=y;let e=f==null?void 0:f.nodesRef.current.find(e=>e.id===t);e&&(e.context=y)}),h.useMemo(()=>E(E({},m),{},{context:y,refs:_,elements:v,rootStore:r}),[m,_,v,y,r])}var _U=h.createContext(void 0);process.env.NODE_ENV!==`production`&&(_U.displayName=`DirectionContext`);function vU(){var e;let t=h.useContext(_U);return(e=t==null?void 0:t.direction)==null?`ltr`:e}var yU=e=>({name:`arrow`,options:e,fn(t){return w(function*(){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=$x(e,t)||{};if(l==null)return{};let d=_S(u),f={x:n,y:r},p=aS(i),m=rS(p),h=yield o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=s.floating[y]||a.floating[m],C=b/2-x/2,w=S/2-h[m]/2-1,T=Math.min(d[_],w),D=Math.min(d[v],w),O=T,k=S-h[m]-D,A=S/2-h[m]/2+C,j=Qx(O,A,k),M=!c.arrow&&tS(i)!=null&&A!==j&&a.reference[m]/2-(A<O?T:D)-h[m]/2<0,N=M?A<O?A-O:A-k:0;return{[p]:f[p]+N,data:E({[p]:j,centerOffset:A-j-N},M&&{alignmentOffset:N}),reset:M}})()}}),bU=(e,t)=>{let{name:n,fn:r}=yU(e);return{name:n,fn:r,options:[e,t]}},xU={name:`hide`,fn(e){return w(function*(){let{width:t,height:n,x:r,y:i}=e.rects.reference,a=t===0&&n===0&&r===0&&i===0,o=yield e.platform.detectOverflow(e,{elementContext:`reference`});return{data:{referenceHidden:o.top-n>=0||o.right-t>=0||o.bottom-n>=0||o.left-t>=0||a}}})()}},SU={sideX:`left`,sideY:`top`},CU=`--available-width`,wU=`--available-height`,TU=`--anchor-width`,EU=`--anchor-height`,DU=`--transform-origin`,OU=CU,kU=wU;function AU(e,t,n){let r=e===`inline-start`||e===`inline-end`;return{top:`top`,right:r?n?`inline-start`:`inline-end`:`right`,bottom:`bottom`,left:r?n?`inline-end`:`inline-start`:`left`}[t]}function jU(e,t,n){let{rects:r,placement:i}=e;return{side:AU(t,eS(i),n),align:tS(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function MU(e){return NU(e,gU)}function NU(e,t){var n,r,i;let{anchor:a,positionMethod:o=`absolute`,side:s=`bottom`,sideOffset:c=0,align:l=`center`,alignOffset:u=0,collisionBoundary:d,collisionPadding:f=5,sticky:p=!1,arrowPadding:m=5,disableAnchorTracking:g=!1,inline:_,keepMounted:v=!1,floatingRootContext:y,mounted:b,collisionAvoidance:x,shift:S,nodeId:C,adaptiveOrigin:w,lazyFlip:T=!1,externalTree:D}=e,O=x.side||`flip`,k=x.align||`flip`,A=x.fallbackAxisSide||`end`,j=(n=S==null?void 0:S.crossAxis)!=null&&n,M=S==null?void 0:S.rootBoundary,N=typeof a==`function`?a:void 0,P=yz(N),F=N?P:a,I=mz(a),L=mz(b),R=vU()===`rtl`,[z,B]=h.useState(null);!b&&z!==null&&B(null);let ee=T===`placement`,V=z?eS(z):null,te=z&&ee?tS(z)||`center`:null,H=V||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":R?`left`:`right`,"inline-start":R?`right`:`left`}[s],U=te||l,W=U===`center`?H:`${H}-${U}`,ne=f;typeof ne==`number`?ne={top:ne,right:ne,bottom:ne,left:ne}:ne&&(ne={top:ne.top||0,right:ne.right||0,bottom:ne.bottom||0,left:ne.left||0});let re=+(s===`bottom`),ie=+(s===`top`),ae=+(s===`right`),oe=+(s===`left`),se={boundary:d===`clipping-ancestors`?`clippingAncestors`:d,padding:ne},ce=h.useRef(null),le=mz(c),ue=mz(u),de=typeof c==`function`?0:c,fe=typeof u==`function`?0:u,pe=[];_&&pe.push(_),pe.push(tw(e=>{let t=jU(e,s,R),n=typeof le.current==`function`?le.current(t):le.current,r=typeof ue.current==`function`?ue.current(t):ue.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[de,fe,R,s]));let me=k===`none`&&O!==`shift`,he=!me&&(p||j||O===`shift`),ge=O===`none`?null:iw(E(E({},se),{},{padding:{top:ne.top+1+re,right:ne.right+1+oe,bottom:ne.bottom+1+ie,left:ne.left+1+ae},mainAxis:!j&&O===`flip`,crossAxis:k===`flip`&&`alignment`,fallbackAxisSideDirection:A})),_e=me?null:nw(E(E({},se),{},{rootBoundary:M,mainAxis:k!==`none`,crossAxis:he,limiter:p||j?void 0:rw(e=>{if(!ce.current)return{};let{width:t,height:n}=ce.current.getBoundingClientRect(),r=iS(eS(e.placement)),i=r===`y`?t:n,a=r===`y`?ne.left+ne.right:ne.top+ne.bottom;return{offset:i/2+a/2}})}),[se,p,j,M,ne,k]);O===`shift`||k===`shift`||U===`center`?pe.push(_e,ge):pe.push(ge,_e),pe.push(aw(E(E({},se),{},{apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!L.current)return;let i=e.style;i.setProperty(OU,`${t}px`),i.setProperty(kU,`${n}px`);let a=HS(e).devicePixelRatio||1,{x:o,y:s,width:c,height:l}=r.reference,u=(Math.round((o+c)*a)-Math.round(o*a))/a,d=(Math.round((s+l)*a)-Math.round(s*a))/a;i.setProperty(TU,`${u}px`),i.setProperty(EU,`${d}px`)}})),bU(e=>({element:ce.current||Dz(e.elements.floating).createElement(`div`),padding:ce.current?m:0}),[m]),{name:`transformOrigin`,fn(e){var t,n,r;let{elements:{floating:i},middlewareData:a,placement:o,platform:l,rects:u,y:d}=e,f=eS(o),p=tS(o),m=iS(f)===`y`,h=ce.current,g=typeof c==`function`?c(jU(e,s,R)):c,_;if(!h&&p&&Math.abs(m?((t=a.shift)==null?void 0:t.x)||0:((n=a.shift)==null?void 0:n.y)||0)<=1){var v;_=p===`start`===(m&&((v=l.isRTL)==null?void 0:v.call(l,i))===!0)?`100%`:`0%`}else{var y,b;_=`${(m?((y=a.arrow)==null?void 0:y.x)||0:((b=a.arrow)==null?void 0:b.y)||0)+(m?(h==null?void 0:h.clientWidth)||0:(h==null?void 0:h.clientHeight)||0)/2}px`}let x=f===`top`||f===`left`?`calc(100% + ${g}px)`:`${-g}px`;return he&&m&&Math.abs(((r=a.shift)==null?void 0:r.y)||0)>g&&(x=`${u.reference.y+u.reference.height/2-d}px`),i.style.setProperty(DU,m?`${_} ${x}`:`${x} ${_}`),{}}},xU,w),NL(()=>{!b&&y&&y.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[b,y]);let ve=h.useMemo(()=>({ancestorScroll:!g,elementResize:!g&&typeof ResizeObserver<`u`,layoutShift:!g&&typeof IntersectionObserver<`u`}),[g]),{refs:ye,elements:be,x:xe,y:Se,middlewareData:Ce,update:we,placement:Te,context:Ee,isPositioned:De,floatingStyles:Oe}=t({rootContext:y,open:v?b:void 0,placement:W,middleware:pe,strategy:o,whileElementsMounted:v?void 0:(...e)=>zC(...e,ve),nodeId:C,externalTree:D}),{sideX:ke,sideY:Ae}=Ce.adaptiveOrigin||SU,je=De?o:`fixed`,Me=h.useMemo(()=>{let e;return e=De?w?{position:je,[ke]:xe,[Ae]:Se}:E(E({},Oe),{},{position:je}):{position:je,top:0,left:0},e[OU]=`100vw`,e[kU]=`100vh`,De||(e.opacity=0),e},[w,je,ke,xe,Ae,Se,Oe,De]),Ne=h.useRef(null);NL(()=>{if(!b)return;let e=I.current,t=typeof e==`function`?e():e,n=(PU(t)?t.current:t)||null;n!==Ne.current&&(ye.setPositionReference(n),Ne.current=n)},[b,ye,F,I]),h.useEffect(()=>{if(!b)return;let e=I.current;typeof e!=`function`&&PU(e)&&e.current!==Ne.current&&(ye.setPositionReference(e.current),Ne.current=e.current)},[b,ye,F,I]),h.useEffect(()=>{if(v&&b&&be.reference&&be.floating)return zC(be.reference,be.floating,we,ve)},[v,b,be,we,ve]);let Pe=eS(Te),Fe=AU(s,Pe,R),Ie=tS(Te)||`center`,Le=!!((r=Ce.hide)!=null&&r.referenceHidden);NL(()=>{T&&b&&De&&(Pe!==H||ee&&Ie!==U)&&B(Te)},[T,ee,b,De,Te,Pe,Ie,H,U]);let Re=h.useMemo(()=>{var e,t;return{position:`absolute`,top:(e=Ce.arrow)==null?void 0:e.y,left:(t=Ce.arrow)==null?void 0:t.x}},[Ce.arrow]),ze=((i=Ce.arrow)==null?void 0:i.centerOffset)!==0;return h.useMemo(()=>({positionerStyles:Me,arrowStyles:Re,arrowRef:ce,arrowUncentered:ze,side:Fe,align:Ie,physicalSide:Pe,anchorHidden:Le,refs:ye,context:Ee,isPositioned:De,update:we}),[Me,Re,ce,ze,Fe,Ie,Pe,Le,ye,Ee,De,we])}function PU(e){return e!=null&&`current`in e}function FU(e){return e===`starting`?nV:ML}function IU(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c=E({},n);return s&&(c.pointerEvents=`none`),KB(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},FU(r),i],stateAttributesMapping:kR})}var LU=[`render`,`className`,`anchor`,`positionMethod`,`side`,`align`,`sideOffset`,`alignOffset`,`collisionBoundary`,`collisionPadding`,`arrowPadding`,`sticky`,`disableAnchorTracking`,`collisionAvoidance`,`style`],RU=h.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`top`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:g=iV,style:_}=e,v=W(e,LU),y=LL(),b=lU(),x=y.useState(`open`),S=y.useState(`mounted`),C=y.useState(`trackCursorAxis`),w=y.useState(`disableHoverablePopup`),T=y.useState(`floatingRootContext`),E=y.useState(`instantType`),D=y.useState(`transitionStatus`),O=MU({anchor:i,positionMethod:a,floatingRootContext:T,mounted:S,side:o,sideOffset:c,align:s,alignOffset:l,collisionBoundary:u,collisionPadding:d,sticky:p,arrowPadding:f,disableAnchorTracking:m,keepMounted:b,collisionAvoidance:g,adaptiveOrigin:y.useState(`adaptiveOrigin`)}),k=IU(e,h.useMemo(()=>({open:x,side:O.side,align:O.align,anchorHidden:O.anchorHidden,instant:C===`none`?E:`tracking-cursor`}),[x,O.side,O.align,O.anchorHidden,C,E]),{styles:O.positionerStyles,transitionStatus:D,props:v,refs:[t,y.useStateSetter(`positionerElement`)],hidden:!S,inert:!x||C===`both`||w});return(0,J.jsx)(mU.Provider,{value:O,children:k})});process.env.NODE_ENV!==`production`&&(RU.displayName=`TooltipPositioner`);var zU=[`render`,`className`,`style`],BU=h.forwardRef(function(e,t){let{render:n,className:r,style:i}=e,a=W(e,zU),o=LL(),{side:s,align:c}=hU(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`disabled`),h=o.useState(`closeDelay`);BV({open:l,ref:o.context.popupRef,onComplete(){if(l){var e,t;(e=(t=o.context).onOpenChangeComplete)==null||e.call(t,!0)}}}),RH(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return KB(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[HV,f,FU(d),a],stateAttributesMapping:AR})});process.env.NODE_ENV!==`production`&&(BU.displayName=`TooltipPopup`);var VU=[`render`,`className`,`style`],HU=h.forwardRef(function(e,t){let{render:n,className:r,style:i}=e,a=W(e,VU),o=LL(),{arrowRef:s,side:c,align:l,arrowUncentered:u,arrowStyles:d}=hU();return KB(`div`,e,{state:{open:o.useState(`open`),side:c,align:l,uncentered:u,instant:o.useState(`instantType`)},ref:[t,s],props:[{style:d,"aria-hidden":!0},a],stateAttributesMapping:kR})});process.env.NODE_ENV!==`production`&&(HU.displayName=`TooltipArrow`);var UU=function(e){let{delay:t,closeDelay:n,timeout:r=400}=e,i=h.useMemo(()=>({open:t,close:n}),[t,n]);return(0,J.jsx)(nU.Provider,{value:t,children:(0,J.jsx)(iz,{delay:i,timeoutMs:r,children:e.children})})};process.env.NODE_ENV!==`production`&&(UU.displayName=`TooltipProvider`);function WU(e){return CB(19)?e:e?`true`:void 0}var GU=48,KU=(e,t=0)=>{let n=new Int32Array(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r)-GU-t;return n},qU=e=>{let t=new Int32Array(e.length+1);for(let n=0;n<e.length;n++)t[n+1]=t[n]+e[n];return t},JU=e=>{let t=new Int32Array(e.length),n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r)-GU;n+=i>>>1^-(i&1),t[r]=n}return t},YU=384,XU=[],ZU=qU(KU(`E0500002005282000000002000150000020021820000011200000003022202000300004200120000200420001200021200301200010400162000010000220021010:2192001200220012000220012000200200200400010200040000000000400200108200110100000022010313000162002000020020012020080213000228200000000082000000000120002000120020020040101020300130001001010`)),QU=qU(KU(`:11111111211111119311546544411119731869:671397415686432441111111111161114151214313433415:78311132233313187211117221449443411141111151152226611131111112212518142224214215421421542142424242516171151615616347111111111197911327451111111111111111111113134714133513411111311111111111111111111112444411111342312715245411117:3`)),$U=`@containerabcdefghinlmoprstunderlineviawzccentlignnimatespectuto-colsrowsaglorightnessckdrop-sisbcontrastfiltergrayscalehue-rotateinvertopacityslurrightnessaturateepia-coniclinearpositionradialsizeockurrderttom-belrstxyespacing-xyaretoursorlnt-umnsendspantartainentrasteividerop-shadowurationcorationlay-xyasendillexontromlter-featuresstretchapr-xyayscaleidow-colsrowsue-rotatedentlinesetvert-beringsxyeshadoweiadingftnest-clamp-imageabein-lrstxyskx--b-coniclpositionrsizet-x-y-fromto-fromto-inearfromto-fromto-adialfromto-fromtofromtofromtofromtoblockhinlinew-screenesblockhinlinewbjectpacityrutlinederigin-offsetbelrstxyesrspective-originaceholderioghtng-offsettateundedw-xyz-belrstlreseslr-endspantartaturatecepiahizekewpace-taleroll-xyz-barmpbelrstxyesbelrstxyes-thumbrackadowrink-xyxyartrokeabextora-shadowpckingnsformitionlate-xyz-offsetill-changeoom`,eW=(()=>{let e=ZU.length-1,t=new Int32Array(e);for(let n=e-1;n>=0;n--){let e=1,r=n+1;for(let i=ZU[n];i<ZU[n+1];i++)e+=t[r],r+=t[r];t[n]=e}let n=new Int32Array(ZU[e]),r=0;for(let i=0;i<e;i++){let e=i+1;for(let a=ZU[i];a<ZU[i+1];a++)n[r++]=e,e+=t[e]}return n})(),tW=KU(`02000000000000900<=0?000B000F00F00ŏI0J0LNPRTVX0000]_a00000000000000000000000rst0000000zŏ00000000000…ŏ000ˆ0000ŏ0000000000—0000000000000000000000000000000000000000000000000000Ë000000000000000000000Þ000000000000000000ð0000000ø0ùúûüýþÿĀāĂ㥹Ć000000000000000000000000000000000000000000ħ0ĨĪ00000000000000000000ļĽ00000Ŭ000000`,1),nW=qU(KU(`123333359346463635126536711576`)),rW=KU(`93203242332583253248325D>E?F@03263243255B:032523853:0325B:8GA032542H<C=12727B:0328432553;D>E?3257D>032585:0325B:;0328B:032`),iW=KU(`012113445661666666789111:5;;;;;;;;444;;;:62999<1161=62>>?61:21@ABCD4446996:64E:::;:?::64:F114GHHIHHHHIHH1HH1HH1HHHHHH::EEJ4444::EE4444441691;644444114244444:;K6666555555555555555999666664444444444444444444444226?6:66644L9M?D:111::::6DE199`),aW=JU(`020200202020020020020020020020200200200200200200200002020202001003040106000200200200200200200200200200200200200200200200200200200200200200200200200200200200020020020020020020002020200202002002002002002002002002002020002002020020200220200200200200200200200200200200020020020000200020002000200200200020020020002000200200200020020202002020202000200200020022000200200020020002002000200220002002000200W0Z00020020002002020002002000200g0j0002002000200200020020002002000200200020020002000200002000002002002002002000200020000200002002002002002002002020020020200200200200200200200200202020020020020020020020020002002002020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020002002002002002002000200200200200200200200200200020202020002000200020002002002002000020200200`),oW=(()=>{let e=new Int32Array(319).fill(-1),t=JU(`02422242:222222242224222242442222222422222244442242226224222426222422442462222422622222222626222462242622422622422424242422222222422222222242422222222222222222622442224222222222222224424442262222222222222222222226224222424242422224422422422222`),n=JU(`02222222222222222222202222222222222222222222221422222222222222222222222222222222222Y\\222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222221422222222222222222222222222222222222222Ŀł222222222222222222`);for(let r=0;r<t.length;r++)e[t[r]]=n[r];return e})(),sW=`container |break-after- all auto avoid avoid-page column left page right|break-before- all auto avoid avoid-page column left page right|break-inside-a uto void void-column void-page|box-decoration- clone slice|box- border content| contents flow-root hidden table table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row table-row-group| not-sr-only sr-only|float- end left none right start|clear- both end left none right start|isolat e ion-auto|overflow- auto clip hidden scroll visible|overflow-x- auto clip hidden scroll visible|overflow-y- auto clip hidden scroll visible|overscroll- auto contain none|overscroll-x- auto contain none|overscroll-y- auto contain none| absolute fixed relative static sticky| collapse invisible visible|justify- around baseline between center center-safe end end-safe evenly normal start stretch|justify-items- center center-safe end end-safe normal start stretch|justify-self- auto center center-safe end end-safe start stretch|items- baseline baseline-last center center-safe end end-safe start stretch|self- auto baseline baseline-last center center-safe end end-safe start stretch|place-content- around baseline between center center-safe end end-safe evenly start stretch|place-items- baseline center center-safe end end-safe start stretch|place-self- auto center center-safe end end-safe start stretch| antialiased subpixel-antialiased| italic not-italic|normal-nums |ordinal |slashed-zero | lining-nums oldstyle-nums| proportional-nums tabular-nums| diagonal-fractions stacked-fractions| no-underline overline| capitalize lowercase normal-case uppercase|truncate |whitespace- break-spaces normal nowrap pre pre-line pre-wrap|break- all keep normal words|wrap- anywhere break-word normal|hyphens- auto manual none|mix-blend- color color-burn color-dodge darken difference exclusion hard-light hue lighten luminosity multiply normal overlay plus-darker plus-lighter saturation screen soft-light|table- auto fixed|caption- bottom top|backface- hidden visible|appearance- auto none|scheme- dark light light-dark normal only-dark only-light|field-sizing- content fixed|pointer-events- auto none|resize -none -x -y|snap- align-none center end start|snap- always normal|snap- both none x y|snap- mandatory proximity|touch- auto manipulation none|touch-pan- left right x|touch-pan- down up y|touch-pinch-zoom |select- all auto none text|forced-color-adjust- auto none| normal size| baseline bottom middle sub super text-bottom text-top top| bounce none ping pulse spin| auto square video| auto fr max min px|none | auto full px| fixed local scroll|clip- border content padding text|origin- border content padding| bottom bottom-left bottom-right center left left-bottom left-top right right-bottom right-top top top-left top-right| no-repeat repeat repeat-round repeat-space repeat-x repeat-y| auto contain cover|blend- color color-burn color-dodge darken difference exclusion hard-light hue lighten luminosity multiply normal overlay saturation screen soft-light|to- b bl br l r t tl tr| auto dvh fit full lh lvh max min px screen svh| dashed dotted double hidden none solid| collapse separate|px |auto |full | content none strict| inline-size size|layout |paint |style | around baseline between center center-safe end end-safe evenly normal start stretch| alias all-scroll auto cell col-resize context-menu copy crosshair default e-resize ew-resize grab grabbing help move n-resize ne-resize nesw-resize no-drop none not-allowed ns-resize nw-resize nwse-resize pointer progress row-resize s-resize se-resize sw-resize text vertical-text w-resize wait zoom-in zoom-out| dashed dotted double solid wavy| auto from-font|reverse |initial | in in-out initial linear out| col col-reverse row row-reverse| nowrap wrap wrap-reverse| auto initial none| black bold extrabold extralight light medium normal semibold thin| condensed expanded extra-condensed extra-expanded normal semi-condensed semi-expanded ultra-condensed ultra-expanded|flow- col col-dense dense row row-dense| none subgrid| auto dvh dvw fit full lh lvh lvw max min px screen svh svw| block flex grid table| auto dvw fit full lvw max min px screen svw| loose none normal px relaxed snug tight|through |item | inside outside| decimal disc none| auto px| clip-border clip-content clip-fill clip-padding clip-stroke clip-view no-clip| add exclude intersect subtract| alpha luminance match|origin- border content fill padding stroke view|type- alpha luminance| circle ellipse| closest-corner closest-side farthest-corner farthest-side|at- bottom bottom-left bottom-right center left left-bottom left-top right right-bottom right-top top top-left top-right| dvh fit full lh lvh max min none px screen svh| auto dvh dvw fit full lh lvh lvw max min none px screen svh svw| dvw fit full lvw max min none px screen svw| auto dvh dvw fit full lvh lvw max min none prose px svh svw| auto dvh dvw fit full lvh lvw max min none px screen svh svw| contain cover fill none scale-down| first last none| distant dramatic midrange near none normal|inset | full none|3d | auto smooth|gutter- auto both stable| auto none thin| inner none| auto dvh dvw fit full lvh lvw max min px svh svw|base | center end justify left right start| clip ellipsis| balance nowrap pretty wrap| normal tight tighter wide wider widest| cpu gpu none| 3d flat| all colors none opacity shadow transform| discrete normal| full px| auto dvh dvw fit full lvh lvw max min px screen svh svw| auto contents scroll transform`.split(`|`).map(e=>{let t=e.split(` `),n=t.shift();for(let e=0;e<t.length;e++)t[e]=n+t[e];return t}),cW=JU(`0000000000000000000000000000000000000000000000000000000000000262242:6@200000006:240B428:4422400002046044222426220026642642462026224222824220022400000000\\00N222422242222222224062242222222422226264222422222222222222442804222422222222222222222222220<4<0204260002444020204224422`),lW=JU(`ɠ222222222222222222222222222222222222222222222222222222222222˕4222226>6ʰ22ʷʺʷʺʷ42ʴ2ʓ22>621422ɶ222ɹɼɷɺɷɺ22ɱ42222ɨ2ɧ26622ɘɓ244ƸƵ222]d24242ǖǓƚÄȫ2263ȨȥȨ2222222ǣ222222222222222222ǂƽ2ƾƵ2222222422222ƜƑ22222222222222222222144Ŧţ22Ţş222222222222222222222ĸ2ı68ĦģĦɡŰ4Ġ«®ĝ822ĔđĔ2ē2222622`),uW=JU(`02222222222222222222222222222222222222222222222222222222222222222202021422222222CF2200GJ021042222WZ222IL0ad2c10h2222U00X202[^2w0000120zy|}€22ƒ†…:22z22222222222G000q†OVI00000{˜2™<40000Œ›@00000G¦§000ª00000000000000021K¬«00®“000000000000000000000–222›HGH_1¸222½2¾2222ÇÊ000­°2±`),dW=new Int32Array(987),fW=new Int32Array(987),pW=new Int32Array(987),mW=``,hW=new Int32Array(1022);{let e=new Map,t=0,n=0;for(let r=0;r<cW.length;r++)for(let i of sW[uW[r]]){let a=e.get(i);a===void 0&&(a=t++,e.set(i,a),hW[a*2]=mW.length,hW[a*2+1]=i.length,mW+=i),dW[n]=cW[r],fW[n]=lW[r],pW[n]=a,n++}}var gW=JU(`0b2N:222@R>F@286¦2@H2D266226FB22B2>BD\\6N22222Z222D222p`),_W=qU(KU(`1::24444432:442:44:44>222222:44:4421322511111311111114`)),vW=JU(`2Š4A;33N=C@H4A;33N=C@<27;83:;8393NQ:3NQʰ222ˉºŴŽ2R2=18cƴÅҜ=cĞÛC1ƈǝȈ:ħ25=11D3A@4=<1;1DEr25;11B3?<6;:371BCn9@7=<8192>2E121@9@EHE@9>2T25511<398454131<=V25511<398454131<=„ƧNž2Đå242L222290000f22500ɛ000ǘ222`),yW=KU(`ij`),bW=KU(`—`),xW=KU(`1`),SW={GROUP_COUNT:YU,customValidatorNames:XU,edgeStart:ZU,labelStart:QU,labelText:$U,edgeTarget:eW,nodeGroup:tW,nodeVlist:oW,vlistPat:nW,vlistOps:rW,vlistRef:iW,vlistGroup:aW,litAnchor:dW,litGroup:fW,litPool:pW,poolOffsets:hW,poolText:mW,adjGid:gW,adjStart:_W,adjTgt:vW,patGid:yW,patTgt:bW,postfixLookupGroups:xW,orderSensitiveModifiers:`* ** after backdrop before details-content file first-letter first-line marker placeholder selection`},CW=`line`in Error(),wW=-1,TW=-1,EW=(e,t,n)=>{let r=2166136261;for(let i=t;i<n;i++)r=Math.imul(r^e.charCodeAt(i),16777619);return r},DW=(e,t,n)=>{let r=n-t,i=Math.imul(r,2654435761)^e.charCodeAt(t);if(r>3){let a=r>>2,o=r>>1;i=Math.imul(i^e.charCodeAt(t+1)<<8^e.charCodeAt(t+2)<<16^e.charCodeAt(t+a),2246822507),i=Math.imul(i^e.charCodeAt(t+o)<<8^e.charCodeAt(t+o+a)<<16^e.charCodeAt(n-3),3266489909),i^=e.charCodeAt(n-2)<<8^e.charCodeAt(n-1)<<16;for(let r=t+3,a=n-4;r<t+8&&r<a;r++,a--)i=Math.imul(i^e.charCodeAt(r)^e.charCodeAt(a)<<8,16777619)}return i^i>>>15},OW=(e,t,n={})=>{var r,i,a;let{GROUP_COUNT:o,edgeStart:s,labelStart:c,labelText:l,edgeTarget:u,nodeGroup:d,nodeVlist:f,vlistPat:p,vlistOps:m,vlistRef:h,vlistGroup:g,litAnchor:_,litGroup:v,litPool:y,poolOffsets:b,poolText:x,adjGid:S,adjStart:C,adjTgt:w,patGid:T,patTgt:E,postfixLookupGroups:D,customValidatorNames:O,orderSensitiveModifiers:k}=e,A=new Int32Array(o).fill(-1);for(let e=0;e<S.length;e++)A[S[e]]=e;let j=0;for(let e=0;e+1<C.length;e++){let t=C[e+1]-C[e];t>j&&(j=t)}let M=32;for(;M<2*(1+j+T.length);)M<<=1;let N=new Int32Array(h.length+1);for(let e=0;e<h.length;e++)N[e+1]=N[e]+p[h[e]+1]-p[h[e]];let P=new Uint8Array(o);for(let e=0;e<D.length;e++)P[D[e]]=1;let F=s.length-1,I=new Uint8Array(F),L=0,R=!0;for(let e=0;e<_.length;e++){I[_[e]]=1;let t=b[y[e]*2+1];t>L&&(L=t);let n=x.charCodeAt(b[y[e]*2]);(n===91||n===40)&&(R=!1)}let z=1;for(;z<_.length*2;)z<<=1;let B=new Int32Array(z).fill(-1);for(let e=0;e<_.length;e++){let t=b[y[e]*2],n=(EW(x,t,t+b[y[e]*2+1])^Math.imul(_[e],2654435761)|0)&z-1;for(;B[n]!==-1;)n=n+1&z-1;B[n]=e}let ee=(e,t,n,r)=>{let i=(EW(t,n,r)^Math.imul(e,2654435761)|0)&z-1,a=r-n;for(;;){let r=B[i];if(r===-1)return-1;if(_[r]===e&&b[y[r]*2+1]===a){let e=b[y[r]*2],i=!0;for(let r=0;r<a;r++)if(x.charCodeAt(e+r)!==t.charCodeAt(n+r)){i=!1;break}if(i)return v[r]}i=i+1&z-1}},V=(r=n.cacheSize)==null?8192:r,te=(i=(a=n.prefix)==null?e.prefix:a)==null?``:i,H=te===``?``:te+`:`,U=H.length,W=(O==null?[]:O).map(e=>{let n=t&&t[e];if(!n)throw Error(`cn: missing validator `+e);return n}),ne=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,re=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,ie=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ae=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,oe=0,se=-1,ce=-1,le=-1,ue=-1,de=e=>e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||e===95,fe=e=>/\s/.test(String.fromCharCode(e)),pe=(e,t,n)=>{if(oe=0,se=-1,n-t<3)return;let r=e.charCodeAt(t),i=e.charCodeAt(n-1);if(r===91&&i===93)oe=1;else if(r===40&&i===41)oe=2;else return;le=t+1,ue=n-1;let a=t+1;if(de(e.charCodeAt(a))){for(a++;a<n-1;){let t=e.charCodeAt(a);if(!de(t)&&t!==45)break;a++}a<n-2&&e.charCodeAt(a)===58&&(se=t+1,ce=a,le=a+1)}},me=(e,t,n,r)=>{if(n-t!==r.length)return!1;for(let n=0;n<r.length;n++)if(e.charCodeAt(t+n)!==r.charCodeAt(n))return!1;return!0},he=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,ge=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,_e=e=>!!e&&!Number.isNaN(Number(e)),ve=(e,t,n)=>{if(n-t<11||!me(e,t,t+10,`@container`))return!1;if(e.charCodeAt(t+10)===47)return n-t>=12;let r=e.charCodeAt(t+11);return r===115&&n-t>=17&&me(e,t+10,t+16,`-size/`)||r===110&&n-t>=19&&me(e,t+10,t+18,`-normal/`)},ye=[1,1,1,1,1,1,1,1,2,2,2,2,2,2,2],be=`length|number|number weight|family-name|position percentage|length size bg-size|image url|shadow|length|family-name|position percentage|length size bg-size|image url|shadow|number weight`.split(`|`).map(e=>e.split(` `)),xe=[2,3,1,0,0,0,4,5,0,0,0,0,0,1,1],Se=(e,t,n,r)=>{if(e>=10){if(e>=25)return W[e-25](t.slice(n,r));let i=e-10;if(oe!==ye[i])return!1;if(se>=0){for(let e of be[i])if(me(t,se,ce,e))return!0;return!1}switch(xe[i]){case 0:return!1;case 1:return!0;case 2:{let e=t.slice(le,ue);return ne.test(e)&&!re.test(e)}case 3:return _e(t.slice(le,ue));case 4:return ae.test(t.slice(le,ue));default:return ie.test(t.slice(le,ue))}}switch(e){case 0:return!0;case 1:return oe===0;case 2:return oe===1;case 3:return oe===2;case 4:return he.test(t.slice(n,r));case 5:return _e(t.slice(n,r));case 6:{let e=t.slice(n,r);return!!e&&Number.isInteger(Number(e))}case 7:return r>n&&t.charCodeAt(r-1)===37&&_e(t.slice(n,r-1));case 8:return ge.test(t.slice(n,r));default:return ve(t,n,r)}},Ce=new Set(typeof k==`string`?k.split(` `):k),we=(e,t,n,r,i,a)=>{let o=EW(t,n,r)^(i?2654435769:0),s=e.get(o);if(s!==void 0)outer:for(let e=0;e<s.length;e++){let a=s[e];if(a.imp===i&&a.k.length===r-n){for(let e=0;e<a.k.length;e++)if(a.k.charCodeAt(e)!==t.charCodeAt(n+e))continue outer;return a.id}}else e.set(o,s=[]);let c=t.slice(n,r),l=a(c);return s.push({k:c,imp:i,id:l}),l},Te=new Map,Ee=new Map,De=2,Oe=4096,ke=(e,t)=>{let n=[],r=0,i=0,a=0;for(let t=0;t<e.length;t++){let o=e.charCodeAt(t);r===0&&i===0&&o===58?(n.push(e.slice(a,t)),a=t+1):o===91?r++:o===93?r--:o===40?i++:o===41&&i--}n.push(e.slice(a));let o=n[0];if(n.length>1){let e=[],t=[];for(let r of n)r.charCodeAt(0)===91||Ce.has(r)?(t.length&&(e.push(...t.sort()),t=[]),e.push(r)):t.push(r);t.length&&e.push(...t.sort()),o=e.join(`:`)}let s=t?o+` !`:o,c=Ee.get(s);return c===void 0&&Ee.set(s,c=De++),c},Ae=new Map,je=o,Me=o+4096,Ne=()=>je++,Pe=2097152,Fe=8192,Ie=new Int32Array(Fe),Le=Array(Fe).fill(null),Re=new Int32Array(Fe),ze=new Int32Array(Fe),Be=new Uint8Array(Fe),Ve=0,He=(e,t,n,r,i,a,o,s)=>{let c=e;if(Le[e]!==null){if(Le[e|1]===null)c=e|1;else if(!(Ve++&3))c=e|Ve>>2&1;else return}Le[c]=t.slice(n,r),Ie[c]=i,Re[c]=a,ze[c]=o,Be[c]=s},Ue=()=>Le.fill(null),We=256,Ge=[new Int32Array(We),new Int32Array(We),new Int32Array(We),new Int32Array(We)],[Ke,qe,Je,Ye]=Ge,Xe=new Uint8Array(We),Ze=new Uint8Array(We),Qe=()=>{We*=2,Ge=Ge.map(e=>{let t=new Int32Array(We);return t.set(e),t}),[Ke,qe,Je,Ye]=Ge;let e=new Uint8Array(We);e.set(Xe),Xe=e,Ze=new Uint8Array(We)},$e=64,et=new Int32Array($e),tt=new Int32Array($e),nt=new Int32Array(o),rt=2048,it=21,at=new Float64Array(rt),ot=new Int32Array(rt),st=0,ct=(e,t)=>{if(e===0&&t<o)return nt[t]===st?1:(nt[t]=st,0);let n=e*2097152+t+1,r=Math.imul(n,2654435761)>>>it;for(;ot[r]===st;){if(at[r]===n)return 1;r=r+1&rt-1}return at[r]=n,ot[r]=st,0},lt=(e,t,n,r,i)=>{if(n-t>=2&&e.charCodeAt(t)===91&&e.charCodeAt(n-1)===93){let r=-1;for(let i=t+1;i<n-1;i++)if(e.charCodeAt(i)===58){r=i;break}return r===-1||r===t+1?wW:we(Ae,e,t+1,r,0,Ne)}if(r>=0&&d[r]>=0)return d[r];for(let t=i-1;t>=0;t--){let r=tt[t];if(r>n)continue;let i=et[t],a=n-r;if(I[i]===1&&a>0&&a<=L){let t=e.charCodeAt(r);if(R===!1||t!==91&&t!==40){let t=ee(i,e,r,n);if(t>=0)return t}}let o=f[i];if(o<0)continue;let s=h[o],c=p[s],l=p[s+1];if(c===l)continue;pe(e,r,n);let u=N[o]-c;for(let t=c;t<l;t++)if(Se(m[t],e,r,n))return g[u+t]}return wW},ut=e=>{let t=e.length,n=0,r=0,i=!1;(De>Oe||Te.size>Oe)&&(Te=new Map,Ee=new Map,De=2,Ue()),je>Me&&(Ae=new Map,je=o,Ue());let a=0;for(;a<t;){let d=e.charCodeAt(a);if(d===32||d>=9&&d<=13||d>=160&&fe(d)){d!==32&&(i=!0),a++;continue}let p=a,m=0;for(;a<t;){if(d=e.charCodeAt(a),d<=32){if(d===32)break;if(d>=9&&d<=13){i=!0;break}}else if(d>=160&&fe(d)){i=!0;break}m=Math.imul(m^d,16777619),a++}let h=a,g=h-p;n===We&&Qe();let _=n++;Ke[_]=p,qe[_]=h,r+=g,m^=Math.imul(g,2654435761);let v=m^m>>>15,y=v&8190;{let t=-1;if(Ie[y]===v&&Le[y]!==null&&Le[y].length===g?t=y:Ie[y|1]===v&&Le[y|1]!==null&&Le[y|1].length===g&&(t=y|1),t>=0){let n=Le[t],r=!0;for(let t=0;t<g;t++)if(n.charCodeAt(t)!==e.charCodeAt(p+t)){r=!1;break}if(r){Je[_]=Re[t],Ye[_]=ze[t],Xe[_]=Be[t];continue}}}let b=p;if(U!==0){if(h-p<=U||!e.startsWith(H,p)){Je[_]=wW,He(y,e,p,h,v,wW,0,0);continue}b=p+U}let x=0,S=0,C=-1,w=-1;for(let t=b;t<h;t++){let n=e.charCodeAt(t);if(x===0&&S===0){if(n===58){C=t;continue}if(n===47){w=t;continue}}n===91?x++:n===93?x--:n===40?S++:n===41&&S--}let T=C>=b?C+1:b,E=T,D=h,O=!1,k=0;D>E&&e.charCodeAt(D-1)===33?(O=!0,D--):D>E&&e.charCodeAt(E)===33&&(O=!0,E++,k=1);let A=-1;w>T&&(A=w+k,A>=D&&(A=-1));let j=E;D-E>1&&e.charCodeAt(E)===45&&(j=E+1);let M=0,N=0,F=0,L=-1,R=0;(f[0]>=0||I[0]===1)&&(et[0]=0,tt[0]=j,R=1);let z=TW,B=0;for(let t=j;t<D;t++)if(t===A&&(z=N<F?TW:M,B=R),M!==TW){let n=e.charCodeAt(t),r=-1;if(N<F)l.charCodeAt(N)===n?(N++,N===F&&(r=M=L)):M=TW;else{let e=s[M],t=s[M+1],i=TW;for(let a=e;a<t;a++){let e=c[a];if(l.charCodeAt(e)===n){c[a+1]-e===1?r=i=u[a]:(N=e+1,F=c[a+1],L=u[a],i=M);break}}M=i}if(r>=0&&(f[r]>=0||I[r]===1)&&t+1<D&&e.charCodeAt(t+1)===45){if(R===$e){$e*=2;let e=new Int32Array($e);e.set(et),et=e;let t=new Int32Array($e);t.set(tt),tt=t}et[R]=r,tt[R]=t+2,R++}}A===D&&(z=N<F?TW:M,B=R);let ee=N<F?TW:M,V,te=!1;if(A>=0){if(te=!0,V=lt(e,E,A,z,B),V!==wW&&V<o&&P[V]){let t=lt(e,E,D,ee,R);t!==wW&&t!==V&&(V=t,te=!1)}else V===wW&&(V=lt(e,E,D,ee,R),te=!1)}else V=lt(e,E,D,ee,R);let W=0,ne=0;V===wW?Je[_]=wW:(ne=+!!te,W=b>=C?+!!O:we(Te,e,b,C,+!!O,e=>ke(e,O)),Je[_]=V,Xe[_]=ne,Ye[_]=W),He(y,e,p,h,v,V,W,ne)}if(n===0)return``;if(n===1)return Ke[0]===0&&qe[0]===t?e:e.slice(Ke[0],qe[0]);if(n*M>rt){for(;n*M>rt;)rt<<=1,it--;at=new Float64Array(rt),ot=new Int32Array(rt)}if(De>=Pe||je>=Pe)throw Error(`cn: too many distinct classes in one merge`);st=st+1|0,st===0&&(nt.fill(0),ot.fill(0),st=1);let d=!1;for(let e=n-1;e>=0;e--){let t=Je[e];if(t===wW){Ze[e]=1;continue}let n=Ye[e];if(ct(n,t)===1)Ze[e]=0,d=!0;else if(Ze[e]=1,t<o){let r=A[t];if(r>=0)for(let e=C[r];e<C[r+1];e++)ct(n,w[e]);if(Xe[e]&1)for(let e=0;e<T.length;e++)T[e]===t&&ct(n,E[e])}}if(!d&&!i&&t===r+n-1)return e;let p=``,m=0;for(;m<n;){if(!Ze[m]){m++;continue}let t=Ke[m],r=qe[m],i=m+1;for(;i<n&&Ze[i]&&Ke[i]===r+1&&e.charCodeAt(r)===32;)r=qe[i],i++;p.length>0&&(p+=` `),p+=e.slice(t,r),m=i}return p},dt=16384,ft=new Int32Array(dt*2),pt=0,mt=1,ht=Object.create(null),gt=Object.create(null),_t=new Map,vt=new Map,yt=0,bt=0,xt=()=>{pt^=dt,mt=mt+1|0,bt=0},St=e=>{let t=ht[e];if(t!==void 0)return t;let n=DW(e,0,e.length),r=(n&16383)+pt,i=ft[r]===(n^mt)||ft[r^dt]===(n^mt-1);return i&&(t=gt[e],t!==void 0)?(ht[e]=t,t):(t=ut(e),i?(ht[e]=t,++yt>V&&(yt=0,gt=ht,ht=Object.create(null),xt())):(ft[r]=n^mt,++bt>dt&&xt()),t)},Ct=e=>{let t=_t.get(e);if(t!==void 0)return t;let n=DW(e,0,e.length),r=(n&16383)+pt,i=ft[r]===(n^mt)||ft[r^dt]===(n^mt-1);return i&&(t=vt.get(e),t!==void 0)?(_t.set(e,t),t):(t=ut(e),i?(_t.set(e,t),++yt>V&&(yt=0,vt=_t,_t=new Map,xt())):(ft[r]=n^mt,++bt>dt&&xt()),t)},wt=e=>{let t=DW(e,0,e.length),n=(t&16383)+pt;return ft[n]===(t^mt)||ft[n^dt]===(t^mt-1)||(ft[n]=t^mt,++bt>dt&&xt(),!1)},Tt=V===0?ut:CW?e=>{let t=_t.get(e);return t===void 0?Ct(e):t}:St;return{merge:function(){return arguments.length===1&&typeof arguments[0]==`string`?Tt(arguments[0]):Tt(jW.apply(null,arguments))},mergeString:Tt,seenBefore:V===0?()=>!1:wt,mergeUncached:ut}},kW=(e,t)=>{if(!e)return``;if(typeof e==`string`)return e;let n=``;if(typeof e.length==`number`&&(!t||Array.isArray(e))){let r=e;for(let e=0;e<r.length;e++){let i=r[e];if(!i)continue;let a=typeof i==`string`?i:kW(i,t);a&&(n&&(n+=` `),n+=a)}return n}if(t){if(typeof e==`number`)return``+e;if(typeof e==`object`)for(let t in e)e[t]&&(n&&(n+=` `),n+=t)}return n},AW=(e,t)=>{let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(!i)continue;let a=typeof i==`string`?i:kW(i,t);a&&(n&&(n+=` `),n+=a)}return n},jW=function(){return AW(arguments,!1)},MW=256,NW=16,PW=1024,FW=4096,IW=(e,t)=>{let n=t===void 0?()=>!0:t.seenBefore,r=t===void 0?e:t.mergeUncached,i=new Map,a=new Map,o=0,s=null,c=null,l=[],u=[],d=0,f=(t,n,r)=>{c===null&&(c=Array(FW).fill(``),l=Array(FW).fill(``),u=Array(FW).fill(``));let i=DW(t,0,t.length)&4094;if(c[i]===t&&l[i]===n)return u[i];if(c[i|1]===t&&l[i|1]===n)return u[i|1];let a=e(r?n+` `+t:t),o=c[i]===``?i:i|(c[i|1]===``?1:d++&1);return c[o]=t,l[o]=n,u[o]=a,a},p=(e,t,n,r)=>{let i=0;if(t){if(t!==e.a0)return!1;i=1}if(n){if(n!==(i===0?e.a0:e.a1))return!1;i++}if(r){if(r!==(i===0?e.a0:i===1?e.a1:e.a2))return!1;i++}return i===e.t},m=(e,t)=>{let n=e.a,r=0;for(let e=0;e<t.length;e++){let i=t[e];if(i){if(i!==n[r])return!1;r++}}return r===e.t},h=(t,c)=>{let l=t.length,u=s===null?null:s.n;if(!c){if(u!==null&&m(u,t))return s=u,u.r;if(s!==null&&s!==u&&m(s,t))return s.r}let d=``,p=-1,h=0,g=!1;for(let e=0;e<l;e++){let n=t[e];if(n){if(typeof n!=`string`){if(n=t[e]=kW(n,!0),!n)continue;g=!0}p<0&&(d=n,p=e),h++}}if(h===0)return``;if(h===1)return e(d);if(g){if(u!==null&&m(u,t))return s=u,u.r;if(s!==null&&s!==u&&m(s,t))return s.r}let _=i.get(d);_===void 0&&(_=a.get(d),_!==void 0&&i.set(d,_));let v=null;if(_!==void 0){if(_.skip>0){_.skip--,s=null;let e=d;for(let n=p+1;n<l;n++){let r=t[n];r&&(e+=` `+r)}return f(e,``,!1)}let e=_.e;outer:for(let n=0;n<e.length;n++){let r=e[n];if(r.t!==h)continue;let i=r.a,a=1;for(let e=p+1;e<l;e++){let n=t[e];if(n&&n!==i[a++])continue outer}v=r;break}v!==null&&(_.miss=0)}if(v===null){var y;let s=d,c=[d];for(let e=p+1;e<l;e++){let n=t[e];n&&(s+=` `+n,c.push(n))}if(!n(s))return r(s);v={r:e(s),t:c.length,a0:c[0],a1:c[1],a2:(y=c[2])==null?``:y,a:c,n:null},_===void 0?i.set(d,_={e:[],miss:0,skip:0,at:0}):++_.miss>NW&&(_.miss=NW,_.skip=PW,_.e.length=0,_.at=0);let u=_.e;u.length<MW?u.push(v):(u[_.at]=v,_.at=_.at+1&255),++o>1e3&&(o=0,a=i,i=new Map)}return s!==null&&s!==v&&(s.n=v),s=v,v.r},g=t=>Array.isArray(t)?h(t.slice(),!1):e(kW(t,!0));return function(t,n,r){let a=arguments.length;if((a|1)==3){let e=s;if(e!==null){let i=e.n;if(i!==null&&p(i,t,n,r))return s=i,i.r;if(e!==i&&p(e,t,n,r))return e.r}if(a===2&&typeof n==`string`&&n!==``){let e=i.get(t);if(e!==void 0&&e.skip>0)return e.skip--,s=null,f(n,t,!0)}return h([t,n,r],!0)}if(a===1)return typeof t==`string`?e(t):g(t);let o=s;if(o!==null){let e=o.n;if(e!==null){let t=e.a,n=0,r=!0;for(let e=0;e<a;e++){let i=arguments[e];if(i){if(i!==t[n]){r=!1;break}n++}}if(r&&n===e.t)return s=e,e.r}if(o!==e){let e=o.a,t=0,n=!0;for(let r=0;r<a;r++){let i=arguments[r];if(i){if(i!==e[t]){n=!1;break}t++}}if(n&&t===o.t)return o.r}}let c=[];for(let e=0;e<a;e++)c.push(arguments[e]);return h(c,!0)}},LW=OW(SW),Q=IW(LW.mergeString,LW);LW.merge;function RW(e){if(e==null)throw TypeError(`Cannot destructure `+e)}function zW(){return zW=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},zW.apply(null,arguments)}var BW=[`delay`],VW=[`className`,`side`,`sideOffset`,`align`,`alignOffset`,`children`];function HW(e){let{delay:t=0}=e,n=W(e,BW);return(0,J.jsx)(UU,E({"data-slot":`tooltip-provider`,delay:t},n))}function UW(e){let t=zW({},(RW(e),e));return(0,J.jsx)($H,E({"data-slot":`tooltip`},t))}function WW(e){let t=zW({},(RW(e),e));return(0,J.jsx)(sU,E({"data-slot":`tooltip-trigger`},t))}function GW(e){let{className:t,side:n=`top`,sideOffset:r=4,align:i=`center`,alignOffset:a=0,children:o}=e,s=W(e,VW);return(0,J.jsx)(pU,{children:(0,J.jsx)(RU,{align:i,alignOffset:a,side:n,sideOffset:r,className:`isolate z-50`,children:(0,J.jsxs)(BU,E(E({"data-slot":`tooltip-content`,className:Q(`z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,t)},s),{},{children:[o,(0,J.jsx)(HU,{className:`z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5`})]}))})})}var KW=h.createContext(void 0);process.env.NODE_ENV!==`production`&&(KW.displayName=`DialogRootContext`);function qW(e){let t=h.useContext(KW);if(!e&&t===void 0)throw Error(process.env.NODE_ENV===`production`?FL(27):`Base UI: DialogRootContext is missing. Dialog parts must be placed within <Dialog.Root>.`);return t}var JW=[`render`,`className`,`style`,`forceRender`],YW=h.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1}=e,o=W(e,JW),s=qW(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return KB(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:AR,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})});process.env.NODE_ENV!==`production`&&(YW.displayName=`DialogBackdrop`);var XW=DB(`error`,`Base UI`),ZW=h.createContext(void 0);process.env.NODE_ENV!==`production`&&(ZW.displayName=`CompositeRootContext`);function QW(e=!1){let t=h.useContext(ZW);if(t===void 0&&!e)throw Error(process.env.NODE_ENV===`production`?FL(16):`Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>.`);return t}function $W(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:h.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function eG(e,t,{detail:n=0,pointerType:r=``}={}){e.dispatchEvent(new(HS(e)).PointerEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:n,pointerType:r,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}var tG=[`onClick`,`onMouseDown`,`onKeyUp`,`onKeyDown`,`onPointerDown`];function nG(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=h.useRef(null),s=QW(!0),c=a==null?s!==void 0:a,{props:l}=$W({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i});process.env.NODE_ENV!==`production`&&h.useEffect(()=>{if(!o.current)return;let e=rG(o.current);if(i){if(!e){var t;XW(`A component that acts as a button expected a native <button> because the \`nativeButton\` prop is true. Rendering a non-<button> removes native button semantics, which can impact forms and accessibility. Use a real <button> in the \`render\` prop, or set \`nativeButton\` to \`false\`.${((t=gz.captureOwnerStack)==null?void 0:t.call(gz))||``}`)}}else if(e){var n;XW(`A component that acts as a button expected a non-<button> because the \`nativeButton\` prop is false. Rendering a <button> keeps native behavior while Base UI applies non-native attributes and handlers, which can add unintended extra attributes (such as \`role\` or \`aria-disabled\`). Use a non-<button> in the \`render\` prop, or set \`nativeButton\` to \`true\`.${((n=gz.captureOwnerStack)==null?void 0:n.call(gz))||``}`)}},[i]);let u=h.useCallback(()=>{let e=o.current;rG(e)&&c&&t&&l.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,l.disabled,c]);return NL(u,[u]),{getButtonProps:h.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s}=e,u=W(e,tG);return NB({onClick(e){t?e.preventDefault():n==null||n(e)},onMouseDown(e){t||r==null||r(e)},onKeyDown(e){if(t||(UB(e),o==null||o(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,r=e.currentTarget,a=rG(r),s=!i&&iG(r),l=n&&(i?a:!s),u=e.key===`Enter`,d=e.key===` `,f=r.getAttribute(`role`),p=(f==null?void 0:f.startsWith(`menuitem`))||f===`option`||f===`gridcell`;if(n&&c&&d){if(e.defaultPrevented&&p)return;e.preventDefault(),(!i||a)&&(e.preventBaseUIHandler(),eG(r,e))}else!l||i||!d&&!u?n&&s&&d&&e.preventDefault():e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),eG(r,e)))},onKeyUp(e){t||(UB(e),a==null||a(e),e.target===e.currentTarget&&i&&c&&rG(e.currentTarget)&&e.key===` `?e.preventDefault():e.baseUIHandlerPrevented||e.target!==e.currentTarget||i||c||e.defaultPrevented||e.key!==` `||(e.preventBaseUIHandler(),eG(e.currentTarget,e)))},onPointerDown(e){t?e.preventDefault():s==null||s(e)}},i?{type:`button`}:{role:`button`},l,u)},[t,l,c,i]),buttonRef:yz(e=>{o.current=e,u()})}}function rG(e){return KS(e)&&e.tagName===`BUTTON`}function iG(e){return KS(e)&&e.tagName===`A`&&!!e.href}var aG=[`render`,`className`,`style`,`disabled`,`nativeButton`],oG=h.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0}=e,s=W(e,aG),c=qW(),l=c.useState(`open`),{getButtonProps:u,buttonRef:d}=nG({disabled:a,native:o}),f={disabled:a};function p(e){l&&c.setOpen(!1,GR(ZR,e.nativeEvent))}return KB(`button`,e,{state:f,ref:[t,d],props:[{onClick:p},s,u]})});process.env.NODE_ENV!==`production`&&(oG.displayName=`DialogClose`);var sG=h.createContext(void 0);process.env.NODE_ENV!==`production`&&(sG.displayName=`DialogPortalContext`);function cG(){let e=h.useContext(sG);if(e===void 0)throw Error(process.env.NODE_ENV===`production`?FL(26):`Base UI: <Dialog.Portal> is missing.`);return e}var lG=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`]),uG=`--nested-dialogs`,dG=`data-nested-dialog-open`,fG=E(E(E({},kR),bR),{},{nestedDialogOpen(e){return e?{[dG]:``}:null}}),pG=[`render`,`className`,`style`,`finalFocus`,`initialFocus`],mG=h.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o}=e,s=W(e,pG),c=qW(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`),S=d.useState(`floatingId`);cG(),BV({open:_,ref:c.context.popupRef,onComplete(){if(_){var e,t;(e=(t=c.context).onOpenChangeComplete)==null||e.call(t,!0)}}});let C=o===void 0?UV(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),D=KB(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,E(E({id:S,"aria-labelledby":y,"aria-describedby":l,role:x},HV),{},{hidden:!m,onKeyDown(e){lG.has(e.key)&&e.stopPropagation()},style:{[uG]:g}}),s],ref:[t,c.context.popupRef,T],stateAttributesMapping:fG});return(0,J.jsx)(EV,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:D})});process.env.NODE_ENV!==`production`&&(mG.displayName=`DialogPopup`);var hG=[`cutout`],gG=h.forwardRef(function(e,t){let{cutout:n}=e,r=W(e,hG),i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,J.jsx)(`div`,E(E({ref:t,role:`presentation`,"data-base-ui-inert":``},r),{},{style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}}))});process.env.NODE_ENV!==`production`&&(gG.displayName=`InternalBackdrop`);var _G=[`keepMounted`],vG=h.forwardRef(function(e,t){let{keepMounted:n=!1}=e,r=W(e,_G),i=qW(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,J.jsx)(sG.Provider,{value:n,children:(0,J.jsxs)(dV,E(E({ref:t},r),{},{children:[a&&o===!0&&(0,J.jsx)(gG,{ref:i.context.internalBackdropRef,inert:WU(!s)}),e.children]}))}):null});process.env.NODE_ENV!==`production`&&(vG.displayName=`DialogPortal`);var yG={},bG={},xG=``;function SG(e,t){return JS(e)?e:t}function CG(e,t,n){return/hidden|clip/.test(e.getComputedStyle(SG(t,n)).overflowY)}function wG(e){if(typeof document>`u`)return!1;let t=Dz(e);return HS(t).innerWidth-t.documentElement.clientWidth>0}function TG(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=Dz(e),n=t.documentElement,r=t.body,i=SG(n,r),a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function EG(e){let t=Dz(e),n=t.documentElement,r=t.body,i=SG(n,r),a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function DG(e){var t,n;let r=Dz(e),i=r.documentElement,a=r.body,o=HS(i),s=0,c=0,l=!1,u=Tz.create();if(tR&&((t=(n=o.visualViewport)==null?void 0:n.scale)==null?1:t)!==1)return()=>{};function d(){let t=o.getComputedStyle(i),n=o.getComputedStyle(a),r=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;s=i.scrollTop,c=i.scrollLeft,yG={scrollbarGutter:i.style.scrollbarGutter,overflowY:i.style.overflowY,overflowX:i.style.overflowX},xG=i.style.scrollBehavior,bG={position:a.style.position,height:a.style.height,width:a.style.width,boxSizing:a.style.boxSizing,overflowY:a.style.overflowY,overflowX:a.style.overflowX,scrollBehavior:a.style.scrollBehavior};let u=i.scrollHeight>i.clientHeight,d=i.scrollWidth>i.clientWidth,f=t.overflowY===`scroll`||n.overflowY===`scroll`,p=t.overflowX===`scroll`||n.overflowX===`scroll`,m=Math.max(0,o.innerWidth-a.clientWidth),h=Math.max(0,o.innerHeight-a.clientHeight),g=parseFloat(n.marginTop)+parseFloat(n.marginBottom),_=parseFloat(n.marginLeft)+parseFloat(n.marginRight),v=SG(i,a);l=TG(e),l?(i.style.scrollbarGutter=r,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`):(Object.assign(i.style,{scrollbarGutter:r,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(i.style.overflowY=`scroll`),(d||p)&&(i.style.overflowX=`scroll`),Object.assign(a.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflowY:`hidden`,overflowX:`hidden`,scrollBehavior:`unset`}),a.scrollTop=s,a.scrollLeft=c,i.setAttribute(`data-base-ui-scroll-locked`,``),i.style.scrollBehavior=`unset`)}function f(){Object.assign(i.style,yG),Object.assign(a.style,bG),l||(i.scrollTop=s,i.scrollLeft=c,i.removeAttribute(`data-base-ui-scroll-locked`),i.style.scrollBehavior=xG)}function p(){f(),u.request(d)}d();let m=oz(o,`resize`,p);return()=>{u.cancel(),f(),typeof o.removeEventListener==`function`&&m()}}var OG=new class{constructor(){S(this,`lockCount`,0),S(this,`restore`,null),S(this,`timeoutLock`,BL.create()),S(this,`timeoutUnlock`,BL.create()),S(this,`release`,()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)}),S(this,`unlock`,()=>{if(this.lockCount===0&&this.restore){var e;(e=this.restore)==null||e.call(this),this.restore=null}})}acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}lock(e){if(this.lockCount===0||this.restore!==null)return;let t=Dz(e),n=t.documentElement,r=t.body,i=HS(n);if(CG(i,n,r)){let t=new i.MutationObserver(()=>{CG(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=JL||!wG(e);this.restore=a?EG(e):DG(e)}};function kG(e=!0,t=null){NL(()=>{if(e)return OG.acquire(t)},[e,t])}function AG({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`mounted`),a=e.useState(`disablePointerDismissal`),o=e.useState(`modal`),s=e.useState(`popupElement`),c=e.useState(`floatingRootContext`),[l,u]=h.useState(0),[d,f]=h.useState(0),p=l===0,m=NV(c,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:o===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=pR(t);if(p&&!a){if(o){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||dR(n,s)&&!(n!=null&&n.hasAttribute(`data-base-ui-portal`)):!0}return!0}return!1},escapeKey:p});return kG(r&&o===!0,s),e.useContextCallback(`onNestedDialogOpen`,(t,n)=>{(e.select(`open`)||e.select(`mounted`))&&(u(t),f(n))}),NL(()=>{!r&&!i&&(u(0),f(0))},[r,i]),NL(()=>(t!=null&&t.onNestedDialogOpen&&r&&t.onNestedDialogOpen(l+1,d+ +!!n),()=>{t!=null&&t.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,l,d,t]),eH(e,{activeTriggerProps:m.reference,inactiveTriggerProps:m.trigger,popupProps:m.floating,nestedOpenDialogCount:l,nestedOpenDrawerCount:d}),null}var jG=E(E({},kH),{},{modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role}),MG=class extends yH{constructor(e,t,n){let r=new iH,i=NG(e,r,t,n);super(i,PG(r),jG),S(this,`setOpen`,(e,t)=>{var n,r;if(t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null){var i;t.trigger=(i=this.state.activeTriggerElement)==null?void 0:i}(n=(r=this.context).onOpenChange)==null||n.call(r,e,t),t.isCanceled||(this.state.floatingRootContext.dispatchOpenChange(e,t),this.update(JV(this.state,e,t.trigger)))})}};function NG(e,t,n,r=!1){return E(E({},CH(t,n,r)),{},{modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`},e)}function PG(e){return{popupRef:h.createRef(),backdropRef:h.createRef(),internalBackdropRef:h.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function FG(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:l,handle:u,triggerId:d,defaultTriggerId:f=null}=t,p=e===`drawer`,m=e===`alert-dialog`,g=m?!0:c,_=m||s,v=m?`alertdialog`:`dialog`,y=qW(!0),b={modal:g,disablePointerDismissal:_,nested:y!=null,role:v},x=WV((e,t)=>new MG(E({open:i,openProp:r,activeTriggerId:f,triggerIdProp:d},b),e,t),!0);x.useControlledProp(`openProp`,r),x.useControlledProp(`triggerIdProp`,d),x.useSyncedValues(b),x.useContextCallback(`onOpenChange`,a),x.useContextCallback(`onOpenChangeComplete`,o);let S=x.useState(`open`),C=x.useState(`mounted`),w=x.useState(`payload`);tH(x,S),QV(x);let{forceUnmount:T}=$V(S,x);h.useImperativeHandle(l,()=>({unmount:T,close:()=>x.setOpen(!1,GR(tz))}),[T,x]);let D=S||C||u!=null;return(0,J.jsxs)(KW.Provider,{value:x,children:[u&&(0,J.jsx)(GV,{handle:u,store:x}),D&&(0,J.jsx)(AG,{store:x,parentContext:y==null?void 0:y.context,isDrawer:p}),typeof n==`function`?n({payload:w}):n]})}var IG=DL(function(e){return FG(`dialog`,e)});process.env.NODE_ENV!==`production`&&(IG.displayName=`DialogRoot`);var LG=[`render`,`className`,`style`,`id`],RG=h.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a}=e,o=W(e,LG),s=qW(),c=tU(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),KB(`h2`,e,{ref:t,props:[{id:c},o]})});process.env.NODE_ENV!==`production`&&(RG.displayName=`DialogTitle`);function zG(e){let t=h.useRef(``),n=h.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:h.useCallback(n=>{n.detail===0?e(n,`keyboard`):(`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``)},[e]),onPointerDown:n}}function BG(e,t){let{onClick:n,onPointerDown:r}=zG(yz((n,r)=>{(typeof e==`function`?e():e)||t(r||(JL?`touch`:``))}));return h.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}var VG=[`render`,`className`,`style`,`disabled`,`nativeButton`,`id`,`payload`,`handle`],HG=OL(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,payload:c,handle:l}=e,u=W(e,VG),d=qW(!0),f=AH(l),p=f==null?d:f;if(!p)throw Error(process.env.NODE_ENV===`production`?FL(79):`Base UI: <Dialog.Trigger> must be used within <Dialog.Root> or provided with a handle.`);let m=tU(s),g=p.useState(`floatingRootContext`),_=p.useState(`isOpenedByTrigger`,m),v=p.useState(`triggerPopupId`,m),y=h.useRef(null),{registerTrigger:b,isMountedByThisTrigger:x}=ZV(m,y,p,{payload:c}),{getButtonProps:S,buttonRef:C}=nG({disabled:a,native:o}),w=DV(g),T=BG(()=>p.select(`open`),e=>{p.set(`openMethod`,e)}),E={disabled:a,open:_},D=p.useState(`triggerProps`,x);return KB(`button`,e,{state:E,ref:[C,t,b,y],props:[w.reference,D,T,{[rV]:``,id:m,"aria-haspopup":`dialog`,"aria-expanded":_,"aria-controls":v},u,S],stateAttributesMapping:OR})});process.env.NODE_ENV!==`production`&&(HG.displayName=`DialogTrigger`);var UG=[`render`,`className`,`disabled`,`focusableWhenDisabled`,`nativeButton`,`style`],WG=h.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,focusableWhenDisabled:a=!1,nativeButton:o=!0,style:s}=e,c=W(e,UG),{getButtonProps:l,buttonRef:u}=nG({disabled:i,focusableWhenDisabled:a,native:o});return KB(`button`,e,{state:{disabled:i},ref:[t,u],props:[c,l]})});process.env.NODE_ENV!==`production`&&(WG.displayName=`Button`);function GG(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=GG(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function KG(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=GG(e))&&(r&&(r+=` `),r+=t);return r}var qG=[`class`,`className`],JG=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,YG=KG,XG=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return YG(e,n==null?void 0:n.class,n==null?void 0:n.className);let{variants:i,defaultVariants:a}=t,o=Object.keys(i).map(e=>{let t=n==null?void 0:n[e],r=a==null?void 0:a[e];if(t===null)return null;let o=JG(t)||JG(r);return i[e][o]}),s=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return YG(e,o,t==null||(r=t.compoundVariants)==null?void 0:r.reduce((e,t)=>{let{class:n,className:r}=t,i=W(t,qG);return Object.entries(i).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes(E(E({},a),s)[t]):E(E({},a),s)[t]===n})?[...e,n,r]:e},[]),n==null?void 0:n.class,n==null?void 0:n.className)},ZG=[`className`,`variant`,`size`],QG=XG(`group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/80`,outline:`border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground`,ghost:`hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50`,destructive:`bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,xs:`h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,icon:`size-8`,"icon-xs":`size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg`,"icon-lg":`size-9`}},defaultVariants:{variant:`default`,size:`default`}}),$G=h.forwardRef((e,t)=>{let{className:n,variant:r=`default`,size:i=`default`}=e,a=W(e,ZG);return(0,J.jsx)(WG,E({ref:t,"data-slot":`button`,className:Q(QG({variant:r,size:i,className:n}))},a))});$G.displayName=`Button`;var eK=[`className`],tK=[`className`,`children`,`showCloseButton`],nK=[`className`];function rK(e){let t=zW({},(RW(e),e));return(0,J.jsx)(IG,E({"data-slot":`dialog`},t))}function iK(e){let t=zW({},(RW(e),e));return(0,J.jsx)(HG,E({"data-slot":`dialog-trigger`},t))}function aK(e){let t=zW({},(RW(e),e));return(0,J.jsx)(vG,E({"data-slot":`dialog-portal`},t))}function oK(e){let{className:t}=e,n=W(e,eK);return(0,J.jsx)(YW,E({"data-slot":`dialog-overlay`,className:Q(`fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,t)},n))}function sK(e){let{className:t,children:n,showCloseButton:r=!0}=e,i=W(e,tK);return(0,J.jsxs)(aK,{children:[(0,J.jsx)(oK,{}),(0,J.jsxs)(mG,E(E({"data-slot":`dialog-content`,className:Q(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,t)},i),{},{children:[n,r&&(0,J.jsxs)(oG,{"data-slot":`dialog-close`,render:(0,J.jsx)($G,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`}),children:[(0,J.jsx)(bL,{}),(0,J.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]}))]})}function cK(e){let{className:t}=e,n=W(e,nK);return(0,J.jsx)(RG,E({"data-slot":`dialog-title`,className:Q(`font-heading text-base leading-none font-medium`,t)},n))}var lK=h.createContext(void 0);process.env.NODE_ENV!==`production`&&(lK.displayName=`AvatarRootContext`);function uK(){let e=h.useContext(lK);if(e===void 0)throw Error(process.env.NODE_ENV===`production`?FL(13):`Base UI: AvatarRootContext is missing. Avatar parts must be placed within <Avatar.Root>.`);return e}var dK={imageLoadingStatus:()=>null},fK=[`className`,`render`,`style`],pK=h.forwardRef(function(e,t){let{className:n,render:r,style:i}=e,a=W(e,fK),[o,s]=h.useState(`idle`),c={imageLoadingStatus:o},l=h.useMemo(()=>({imageLoadingStatus:o,setImageLoadingStatus:s}),[o,s]),u=KB(`span`,e,{state:c,ref:t,props:a,stateAttributesMapping:dK});return(0,J.jsx)(lK.Provider,{value:l,children:u})});process.env.NODE_ENV!==`production`&&(pK.displayName=`AvatarRoot`);function mK(e,{referrerPolicy:t,crossOrigin:n,sizes:r,srcSet:i},a){let o=h.useState(`idle`),s=o[1];return NL(()=>{if(!a)return AL;if(!e&&!i)return s(`error`),AL;let o=!0,c=new window.Image,l=e=>()=>{o&&s(e)};return s(`loading`),c.onload=l(`loaded`),c.onerror=l(`error`),t&&(c.referrerPolicy=t),c.crossOrigin=n==null?null:n,r&&(c.sizes=r),i&&(c.srcset=i),e&&(c.src=e),c.complete&&s(c.naturalWidth>0?`loaded`:`error`),()=>{o=!1}},[a,e,i,r,n,t,s]),o}var hK=[`className`,`render`,`onLoadingStatusChange`,`keepMounted`,`style`,`sizes`,`srcSet`,`src`],gK=E(E({},dK),bR),_K=h.forwardRef(function(e,t){let{className:n,render:r,onLoadingStatusChange:i,keepMounted:a=!1,style:o,sizes:s,srcSet:c,src:l}=e,u=W(e,hK),{setImageLoadingStatus:d}=uK(),[f,p]=mK(l,e,!a),m=f===`loaded`,{mounted:g,transitionStatus:_,setMounted:v}=FV(m),y=h.useRef(null),b=h.useRef(!0);NL(()=>{if(!a)return;let e=b.current;b.current=!1;let t=y.current;if(!t)return;if(!t.complete){p(`loading`);return}let n=t.naturalWidth>0?`loaded`:`error`;p(n),n===`loaded`&&e&&v(!0)},[a,l,c,s,u.crossOrigin,u.referrerPolicy,r,p,v]);let x=a?{"data-loading":f===`loading`?``:void 0,"data-error":f===`error`?``:void 0,"aria-hidden":f!==`loaded`||void 0,onLoad(){p(`loaded`)},onError(){p(`error`)}}:void 0,S=yz(e=>{i==null||i(e),d(e)});NL(()=>{f!==`idle`&&S(f)},[f,S]),NL(()=>()=>d(`idle`),[d]),BV({enabled:!m,open:m,ref:y,onComplete(){m||v(!1)}});let C={imageLoadingStatus:f,transitionStatus:a&&_===`ending`?void 0:_},w=a||g,T={};s!==void 0&&(T.sizes=s),c!==void 0&&(T.srcSet=c),l!==void 0&&(T.src=l);let E=KB(`img`,e,{state:C,ref:[t,y],props:[x,u,T],stateAttributesMapping:gK,enabled:w});return w?E:null});process.env.NODE_ENV!==`production`&&(_K.displayName=`AvatarImage`);var vK=[`className`,`render`,`delay`,`style`],yK=h.forwardRef(function(e,t){let{className:n,render:r,delay:i=0,style:a}=e,o=W(e,vK),{imageLoadingStatus:s}=uK(),[c,l]=h.useState(i===0),u=VL();return h.useEffect(()=>(i>0?u.start(i,()=>l(!0)):l(!0),u.clear),[u,i]),KB(`span`,e,{state:{imageLoadingStatus:s},ref:t,props:o,stateAttributesMapping:dK,enabled:s!==`loaded`&&(i===0||c)})});process.env.NODE_ENV!==`production`&&(yK.displayName=`AvatarFallback`);var bK=[`className`,`size`],xK=[`className`],SK=[`className`];function CK(e){let{className:t,size:n=`default`}=e,r=W(e,bK);return(0,J.jsx)(pK,E({"data-slot":`avatar`,"data-size":n,className:Q(`group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten`,t)},r))}function wK(e){let{className:t}=e,n=W(e,xK);return(0,J.jsx)(_K,E({"data-slot":`avatar-image`,className:Q(`aspect-square size-full rounded-full object-cover`,t)},n))}function TK(e){let{className:t}=e,n=W(e,SK);return(0,J.jsx)(yK,E({"data-slot":`avatar-fallback`,className:Q(`flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs`,t)},n))}var EK=[`children`,`tooltip`,`side`,`className`],DK=(0,h.forwardRef)((e,t)=>{let{children:n,tooltip:r,side:i=`bottom`,className:a}=e,o=W(e,EK);return(0,J.jsx)(HW,{children:(0,J.jsxs)(UW,{children:[(0,J.jsxs)(WW,{render:(0,J.jsx)($G,E(E({variant:`ghost`,size:`icon`},o),{},{className:Q(`aui-button-icon size-6 p-1 active:scale-90`,a),ref:t})),children:[n,(0,J.jsx)(`span`,{className:`aui-sr-only sr-only`,children:r})]}),(0,J.jsx)(GW,{side:i,children:r})]})})});DK.displayName=`TooltipIconButton`;var OK=e=>Symbol.iterator in e,kK=e=>`entries`in e,AK=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},jK=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function MK(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:OK(e)&&OK(t)?kK(e)&&kK(t)?AK(e,t):jK(e,t):AK({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function NK(e){let t=h.default.useRef(void 0);return n=>{let r=e(n);return MK(t.current,r)?t.current:t.current=r}}var PK=e=>{let[t,n]=(0,h.useState)(void 0);return(0,h.useEffect)(()=>{if(!e){n(void 0);return}let t=URL.createObjectURL(e);return n({file:e,url:t}),()=>{URL.revokeObjectURL(t)}},[e]),t!==void 0&&t.file===e?t.url:void 0},FK=()=>{var e;let{file:t,src:n}=q(NK(e=>{var t;if(e.attachment.type!==`image`)return{};if(e.attachment.file)return{file:e.attachment.file};let n=(t=e.attachment.content)==null||(t=t.filter(e=>e.type===`image`)[0])==null?void 0:t.image;return n?{src:n}:{}}));return(e=PK(t))==null?n:e};function IK(){let e=qa().attachment.source!==`message`,t=FK(),n=q(e=>e.attachment.type===`image`),r=q(e=>e.attachment.name),i=q(e=>{let t=e.attachment.type;switch(t){case`image`:return`Image`;case`document`:return`Document`;case`file`:return`File`;default:return t}}),a=q(e=>{var t;return e.attachment.status.type===`incomplete`&&e.attachment.status.reason===`error`?`error`:e.attachment.status.type===`running`||((t=e.optional.message)==null?void 0:t.submission)!==void 0&&e.attachment.status.type!==`complete`?`uploading`:void 0});return{isComposer:e,src:t,isImage:n,name:r,typeLabel:i,isUploading:a===`uploading`,isError:a===`error`,errorMessage:q(e=>{var t;return e.attachment.status.type===`incomplete`&&e.attachment.status.reason===`error`?(t=e.attachment.status.message)==null?`Upload failed`:t:void 0})}}var LK=({src:e,name:t})=>{let[n,r]=(0,h.useState)(!1);return(0,J.jsx)(`img`,{src:e,alt:`Preview of ${t}`,className:Q(`block h-auto max-h-[80vh] w-auto max-w-full rounded-sm object-contain transition-opacity duration-300 motion-reduce:transition-none`,n?`aui-attachment-preview-image-loaded opacity-100`:`aui-attachment-preview-image-loading opacity-0`),onLoad:()=>r(!0)})},RK=({children:e,src:t,name:n})=>t?(0,J.jsxs)(rK,{children:[(0,J.jsx)(iK,{nativeButton:!1,className:`aui-attachment-preview-trigger cursor-zoom-in`,render:(0,h.isValidElement)(e)?e:(0,J.jsx)(`button`,{type:`button`,children:e})}),(0,J.jsxs)(sK,{className:`aui-attachment-preview-dialog-content [&>button]:bg-foreground/60 [&>button]:hover:bg-foreground/80 [&_svg]:text-background p-2 sm:max-w-3xl [&>button]:rounded-full [&>button]:p-1 [&>button]:opacity-100 [&>button]:ring-0!`,children:[(0,J.jsxs)(cK,{className:`aui-sr-only sr-only`,children:[`Preview `,n]}),(0,J.jsx)(`div`,{className:`aui-attachment-preview bg-background relative mx-auto flex max-h-[80dvh] w-full items-center justify-center overflow-hidden rounded-sm`,children:(0,J.jsx)(LK,{src:t,name:n})})]})]}):e,zK=({src:e})=>(0,J.jsxs)(CK,{className:`aui-attachment-tile-avatar h-full w-full rounded-none after:hidden`,children:[(0,J.jsx)(wK,{src:e,alt:``,className:`aui-attachment-tile-image rounded-none object-cover`}),(0,J.jsx)(TK,{children:(0,J.jsx)(MI,{className:`aui-attachment-tile-fallback-icon text-muted-foreground/80 size-6 stroke-[1.5]`})})]}),BK=()=>{let{isComposer:e,src:t,isImage:n,name:r,typeLabel:i,isUploading:a,isError:o,errorMessage:s}=IK();return(0,J.jsx)(HW,{children:(0,J.jsxs)(UW,{children:[(0,J.jsxs)(Bk.Root,{className:Q(`aui-attachment-root relative`,e&&`animate-in fade-in-0 zoom-in-95 duration-200 motion-reduce:animate-none`,n&&!e&&`aui-attachment-root-message only:*:first:size-24`),children:[(0,J.jsx)(RK,{src:t,name:r,children:(0,J.jsxs)(WW,{render:(0,J.jsx)(`div`,{className:Q(`aui-attachment-tile bg-muted hover:after:bg-foreground/10 focus-visible:ring-ring/50 relative size-14 overflow-hidden rounded-[calc(var(--composer-radius,1rem)-var(--composer-padding,8px))] transition-transform outline-none after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] after:ring-1 after:ring-black/10 after:transition-colors after:ring-inset focus-visible:ring-1 motion-reduce:transition-none dark:after:ring-white/10`,t?`cursor-zoom-in active:scale-[0.96]`:`cursor-default`,o&&`after:ring-destructive/60 dark:after:ring-destructive/60`),role:t?`button`:`group`,tabIndex:0,"aria-label":`${t?`Preview ${r}`:`${i} attachment ${r}`}${o?`, upload failed`:a?`, uploading`:``}`}),children:[(0,J.jsx)(zK,{src:t}),a&&(0,J.jsx)(`div`,{"aria-hidden":`true`,className:`aui-attachment-tile-uploading bg-background/60 animate-in fade-in-0 absolute inset-0 flex items-center justify-center backdrop-blur-[2px] motion-reduce:animate-none`,children:(0,J.jsx)(BI,{className:`text-muted-foreground size-4 animate-spin`})}),o&&(0,J.jsx)(`div`,{"aria-hidden":`true`,className:`aui-attachment-tile-error bg-background/70 animate-in fade-in-0 absolute inset-0 flex items-center justify-center backdrop-blur-[2px] motion-reduce:animate-none`,children:(0,J.jsx)(vI,{className:`text-destructive size-4`})})]})}),e&&(0,J.jsx)(VK,{name:r})]}),(0,J.jsxs)(GW,{side:`top`,children:[(0,J.jsx)(Bk.Name,{}),s&&(0,J.jsx)(`p`,{className:`aui-attachment-error-message`,children:s})]})]})})},VK=({name:e})=>(0,J.jsx)(Bk.Remove,{render:(0,J.jsx)(DK,{tooltip:`Remove ${e}`,className:`aui-attachment-tile-remove absolute end-1 top-1 size-5 rounded-full bg-black/50! text-white after:absolute after:-inset-1.5 hover:bg-black/70! hover:text-white! active:scale-[0.96] motion-reduce:transition-none`,side:`top`}),children:(0,J.jsx)(bL,{className:`aui-attachment-remove-icon size-3 stroke-[2.5]`})}),HK=()=>(0,J.jsx)(`div`,{className:`aui-user-message-attachments-end col-span-full col-start-1 row-start-1 flex w-full flex-row justify-end gap-2 empty:hidden`,children:(0,J.jsx)(ON.Attachments,{children:()=>(0,J.jsx)(BK,{})})}),UK=()=>(0,J.jsx)(`div`,{className:`aui-composer-attachments flex w-full flex-row items-center gap-2 overflow-x-auto empty:hidden`,children:(0,J.jsx)(pM.Attachments,{children:()=>(0,J.jsx)(BK,{})})}),WK=()=>(0,J.jsx)(pM.AddAttachment,{render:(0,J.jsx)(DK,{tooltip:`Add Attachment`,side:`bottom`,variant:`ghost`,size:`icon`,className:`aui-composer-add-attachment text-muted-foreground hover:text-foreground hover:bg-muted-foreground/15 dark:border-muted-foreground/15 dark:hover:bg-muted-foreground/30 size-7 rounded-full active:scale-[0.96] motion-reduce:transition-none`,"aria-label":`Add Attachment`}),children:(0,J.jsx)(iL,{className:`aui-attachment-add-icon size-4`})}),GK=globalThis.window===void 0?h.useEffect:h.useLayoutEffect,KK=`bg-background border border-border/60 dark:bg-popover`,qK=`bg-foreground/[0.04] forced-colors:border dark:bg-foreground/[0.06]`,JK=`bg-foreground text-background transition-[opacity,scale] duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] hover:opacity-90 active:scale-[0.96] motion-reduce:transition-none forced-colors:border`,YK=`font-mono text-[11px] tracking-tight`,XK=[`src`,`title`,`artwork`,`durationMs`,`className`],ZK=[`src`,`poster`,`title`,`ratio`,`durationMs`,`className`];function QK(e){let t=Math.max(0,Math.floor(e));return`${Math.floor(t/60)}:${(t%60).toString().padStart(2,`0`)}`}function $K(e,t,n){var r;let[i,a]=(0,h.useState)({src:t});(0,h.useEffect)(()=>{let n=e.current;!n||n.readyState<HTMLMediaElement.HAVE_METADATA||Number.isFinite(n.duration)&&n.duration>=0&&a({src:t,duration:n.duration})},[e,t]);let o=n!==void 0&&Number.isFinite(n)?Math.max(0,n/1e3):void 0;return{duration:i.src===t?(r=i.duration)==null?o:r:o,setDurationFromMetadata:e=>{Number.isFinite(e)&&e>=0&&a({src:t,duration:e})}}}function eq(e){let{src:t,title:n,artwork:r,durationMs:i,className:a}=e,o=W(e,XK),s=(0,h.useRef)(null),[c,l]=(0,h.useState)({src:t,currentTime:0,playing:!1,hasError:!1}),{duration:u,setDurationFromMetadata:d}=$K(s,t,i),{currentTime:f,playing:p,hasError:m}=c.src===t?c:{src:t,currentTime:0,playing:!1,hasError:!1},g=e=>l(n=>E(E({},n.src===t?n:{src:t,currentTime:0,playing:!1,hasError:!1}),e)),_=n==null?`Audio`:n,v=n?` ${n}`:` audio`,y=u===void 0?`--:--`:QK(u);return(0,h.useEffect)(()=>{var e;(e=s.current)!=null&&e.error&&l({src:t,currentTime:0,playing:!1,hasError:!0})},[t]),(0,J.jsxs)(`div`,E(E({"data-slot":`audio-player`,className:Q(KK,`flex w-full max-w-md items-center gap-3 rounded-2xl p-3`,a)},o),{},{children:[r?(0,J.jsx)(`img`,{src:r,alt:``,className:`size-10 shrink-0 rounded-lg object-cover`}):null,(0,J.jsx)(`button`,{type:`button`,"aria-label":`${p?`Pause`:`Play`}${v}`,disabled:m,onClick:()=>{let e=s.current;e&&!m&&(p?(e.pause(),g({playing:!1})):e.play().then(()=>g({playing:!0}),()=>g(e.error?{hasError:!0,playing:!1}:{playing:!1})))},className:Q(JK,`flex size-9 shrink-0 items-center justify-center rounded-full disabled:cursor-default disabled:opacity-40`),children:p?(0,J.jsx)(XI,{"aria-hidden":!0,className:`size-4`}):(0,J.jsx)(nL,{"aria-hidden":!0,className:`ml-0.5 size-4`})}),(0,J.jsxs)(`div`,{className:`flex min-w-0 grow basis-16 flex-col gap-1.5`,children:[(0,J.jsx)(`span`,{className:`truncate text-[13.5px] font-medium`,children:_}),(0,J.jsx)(`input`,{type:`range`,min:0,max:u==null?0:u,step:.1,value:Math.min(f,u==null?0:u),"aria-label":`Seek`,"aria-valuetext":`${QK(f)} of ${y}`,disabled:m,onChange:e=>{let t=Number(e.currentTarget.value);if(!Number.isFinite(t))return;let n=Math.min(t,u==null?t:u);s.current&&(s.current.currentTime=n),g({currentTime:n})},className:`accent-foreground w-full`})]}),(0,J.jsxs)(`span`,{className:Q(YK,`text-muted-foreground tabular-nums`),children:[QK(f),`\xA0/ `,y]}),(0,J.jsx)(`audio`,{ref:s,src:t,preload:`metadata`,className:`hidden`,onLoadedMetadata:e=>{d(e.currentTarget.duration)},onTimeUpdate:e=>g({currentTime:e.currentTarget.currentTime}),onPlay:()=>g({playing:!0}),onPause:()=>g({playing:!1}),onError:()=>g({hasError:!0,playing:!1})}),m?(0,J.jsx)(`span`,{role:`alert`,className:`text-muted-foreground text-xs`,children:`Can't play this audio`}):null]}))}function tq(e){let{src:t,poster:n,title:r,ratio:i=`16:9`,durationMs:a,className:o}=e,s=W(e,ZK),c=(0,h.useRef)(null),{duration:l,setDurationFromMetadata:u}=$K(c,t,a),d=i===`1:1`?`aspect-square`:i===`4:3`?`aspect-[4/3]`:i===`16:9`?`aspect-video`:i===`9:16`?`aspect-[9/16]`:void 0;return(0,J.jsxs)(`div`,E(E({"data-slot":`video-player`,className:Q(`flex w-full max-w-xl flex-col gap-2`,o)},s),{},{children:[(0,J.jsx)(`div`,{className:Q(qK,`overflow-hidden rounded-xl`,d),children:(0,J.jsx)(`video`,{ref:c,src:t,poster:n,controls:!0,playsInline:!0,preload:`metadata`,"aria-label":r==null?`Video`:r,className:Q(`block max-w-full`,i!==`auto`&&`h-full w-full object-contain`),onLoadedMetadata:e=>{u(e.currentTarget.duration)}})}),(r||l!==void 0)&&(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 px-1`,children:[r?(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13.5px] font-medium`,children:r}):null,l===void 0?null:(0,J.jsx)(`span`,{className:Q(`font-mono text-[11px] tracking-tight`,`text-muted-foreground shrink-0 tabular-nums`),children:QK(l)})]})]}))}var nq=[`className`,`variant`,`size`,`children`],rq=[`mimeType`,`className`,`children`],iq=[`className`,`children`],aq=[`bytes`,`className`],oq=[`data`,`mimeType`,`filename`,`sourceType`,`className`,`children`],sq=[`data`,`mimeType`,`filename`,`sourceType`,`className`],cq=XG(`aui-file-root inline-flex items-center gap-3 rounded-lg transition-colors`,{variants:{variant:{outline:`border-border hover:bg-muted/50 border`,ghost:`hover:bg-muted/50`,muted:`bg-muted/50 hover:bg-muted/70`},size:{sm:`px-2.5 py-1.5 text-xs`,default:`px-3 py-2 text-sm`,lg:`px-4 py-3 text-base`}},defaultVariants:{variant:`outline`,size:`default`}});function lq(e){let t=e.toLowerCase();return t.startsWith(`image/`)?RI:t===`application/pdf`?MI:t===`application/json`?oI:t.startsWith(`text/`)?MI:t.startsWith(`audio/`)?OI:t.startsWith(`video/`)?vL:PI}function uq(e,t){return t===`url`&&/^data:/i.test(e)?`data-uri`:t||(/^data:/i.test(e)?`data-uri`:/^(https?:\/\/|blob:)/i.test(e)?`url`:`base64`)}function dq(e){return/^[a-z][a-z\d+.-]*:/i.test(e)&&!/^(data:|https?:\/\/|blob:)/i.test(e)}function fq(e,t,n){if(dq(e))return null;let r=uq(e,n);return r===`id`?null:r===`data-uri`?/^data:[^,]*,/i.test(e)?e:null:r===`url`?/^(https?:\/\/|blob:)/i.test(e)?e:null:`data:${t};base64,${e}`}function pq(e){let t=e.endsWith(`==`)?2:+!!e.endsWith(`=`),n=e.search(/[^A-Za-z\d+/]/);return n!==-1&&n!==e.length-t||e.length%4==1||t>0&&e.length%4!=0?0:Math.floor(e.length*3/4)-t}function mq(e){return pq(/[\t\n\f\r ]/.test(e)?e.replace(/[\t\n\f\r ]/g,``):e)}function hq(e){let t=e.indexOf(`#`),n=t<0?e.length:t,r=e.indexOf(`,`);if(r<0||r>=n)return 0;let i=e.slice(r+1,n);return/;base64$/i.test(e.slice(0,r))?(/[%\t\n\f\r ]/.test(i)&&(i=i.replace(/%([\da-f]{2})/gi,(e,t)=>String.fromCharCode(Number.parseInt(t,16))).replace(/[\t\n\f\r ]/g,``)),pq(i)):new TextEncoder().encode(i.replace(/%[\da-f]{2}/gi,`_`)).byteLength}function gq(e){var t;let n=(t=/^[^/;]+\/(?:x-)?(?:[^;+]*\.)?([^;+.\s]+)/.exec(e.toLowerCase()))==null?void 0:t[1];return!n||n===`octet-stream`?`文件`:n===`plain`?`文本文件`:`${n.toUpperCase()} 文件`}function _q(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function vq(e){let{className:t,variant:n,size:r,children:i}=e,a=W(e,nq);return(0,J.jsx)(`div`,E(E({"data-slot":`file-root`,"data-variant":n,"data-size":r,className:Q(cq({variant:n,size:r,className:t}))},a),{},{children:i}))}function yq(e){let{mimeType:t,className:n,children:r}=e,i=W(e,rq),a=t?lq(t):PI;return(0,J.jsx)(`span`,E(E({"data-slot":`file-icon`,className:Q(`text-muted-foreground shrink-0`,n)},i),{},{children:r==null?(0,J.jsx)(a,{className:`size-5`}):r}))}function bq(e){let{className:t,children:n}=e,r=W(e,iq);return(0,J.jsx)(`span`,E(E({"data-slot":`file-name`,className:Q(`min-w-0 flex-1 truncate font-medium`,t)},r),{},{children:n||`未命名文件`}))}function xq(e){let{bytes:t,className:n}=e,r=W(e,aq);return(0,J.jsx)(`span`,E(E({"data-slot":`file-size`,className:Q(`text-muted-foreground shrink-0`,n)},r),{},{children:_q(t)}))}function Sq(e){let{data:t,mimeType:n,filename:r,sourceType:i,className:a,children:o}=e,s=W(e,oq);if(typeof t!=`string`)return null;let c=uq(t,i),l=fq(t,n,i);return l?(0,J.jsx)(`a`,E(E(E({"data-slot":`file-download`,href:l,download:r||`download`},c===`url`&&{target:`_blank`,rel:`noopener noreferrer`}),{},{className:Q(`text-muted-foreground hover:bg-accent hover:text-accent-foreground shrink-0 rounded-md p-1 transition-colors`,a),"aria-label":o?void 0:`下载 ${r||`文件`}`},s),{},{children:o||(0,J.jsx)(EI,{className:`size-4`})})):null}function Cq(e){let{data:t,mimeType:n,filename:r,sourceType:i,className:a}=e,o=W(e,sq),s=fq(t,n,i),c=n.toLowerCase();return!s||!c.startsWith(`audio/`)&&!c.startsWith(`video/`)?null:(0,J.jsx)(`div`,E(E({"data-slot":`file-player`,className:Q(`w-full`,a)},o),{},{children:c.startsWith(`audio/`)?(0,J.jsx)(eq,{src:s,title:r}):(0,J.jsx)(tq,{src:s,title:r})}))}var wq=(0,h.memo)(({filename:e,data:t,mimeType:n,sourceType:r})=>{let i=uq(t,r),a=typeof t==`string`&&(i===`base64`||i===`data-uri`),o=fq(t,n,r),s=n.toLowerCase().startsWith(`audio/`)||n.toLowerCase().startsWith(`video/`);return o&&s?(0,J.jsxs)(`div`,{className:`flex w-full max-w-xl flex-col gap-2`,children:[(0,J.jsx)(Cq,E(E({data:t,mimeType:n},e!==void 0&&{filename:e}),r!==void 0&&{sourceType:r})),(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center justify-end gap-2 px-1`,children:[a&&(0,J.jsx)(xq,{bytes:i===`data-uri`?hq(t):mq(t),className:`text-muted-foreground text-[11px]`}),(0,J.jsx)(Sq,E(E({data:t,mimeType:n},e!==void 0&&{filename:e}),r!==void 0&&{sourceType:r}))]})]}):(0,J.jsxs)(vq,{children:[(0,J.jsx)(yq,{mimeType:n}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,J.jsx)(bq,{children:e||gq(n)}),a&&(0,J.jsx)(xq,{bytes:i===`data-uri`?hq(t):mq(t),className:`text-xs`})]}),(0,J.jsx)(Sq,E(E({data:t,mimeType:n},e!==void 0&&{filename:e}),r!==void 0&&{sourceType:r}))]})});wq.displayName=`File`,wq.Root=vq,wq.Icon=yq,wq.Name=bq,wq.Size=xq,wq.Download=Sq,wq.Player=Cq;var Tq=()=>{let e=q(e=>e.thread.suggestions),t=(0,h.useRef)(null),n=(0,h.useRef)(null),[r,i]=(0,h.useState)({left:!1,right:!1}),a=(0,h.useCallback)(()=>{var e;let r=t.current;if(!r)return;let a=r.scrollWidth-r.clientWidth,o=Math.abs(r.scrollLeft),[s,c]=((e=n.current)==null?n.current=getComputedStyle(r).direction===`rtl`:e)?[a-o,o]:[o,a-o];i(e=>{let t={left:s>1,right:c>1};return e.left===t.left&&e.right===t.right?e:t})},[]);(0,h.useEffect)(()=>{a();let e=t.current;if(!(e!=null&&e.firstElementChild))return;let n=new ResizeObserver(a);return n.observe(e),n.observe(e.firstElementChild),()=>n.disconnect()},[a]);let o=`linear-gradient(to right, ${r.left?`transparent, black 2rem`:`black`}, ${r.right?`black calc(100% - 2rem), transparent`:`black`})`;return(0,J.jsx)(`div`,{ref:t,onScroll:a,role:`group`,"aria-label":`后续问题建议`,className:`aui-thread-followup-suggestions -my-1 w-full [scrollbar-width:none] overflow-x-auto py-1 [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden`,style:{maskImage:o,WebkitMaskImage:o},children:(0,J.jsx)(`div`,{className:`mx-auto flex min-h-8 w-max items-center gap-2 px-0.5`,children:e.map((e,t)=>{var n;return(0,J.jsxs)(yP.Suggestion,{className:`aui-thread-followup-suggestion border-foreground/10 hover:bg-foreground/[0.03] hover:border-foreground/25 rounded-md border px-2.5 py-1 text-sm whitespace-nowrap transition-colors ease-in motion-reduce:transition-none`,prompt:e.prompt,send:!0,children:[(n=e.title)==null?e.prompt:n,e.label&&(0,J.jsx)(`span`,{className:`aui-thread-followup-suggestion-label text-muted-foreground ms-1`,children:e.label})]},t)})})})},Eq=()=>(0,J.jsx)(Sd,{condition:e=>!e.thread.isEmpty&&!e.thread.isRunning&&e.thread.suggestions.length>0,children:(0,J.jsx)(Tq,{})}),Dq=/^(?:[/?#]|\.{1,2}\/)/,Oq=new Set([`http:`,`https:`,`mailto:`]),kq=e=>{try{return new URL(e)}catch(e){return}};function Aq(e){if(typeof e!=`string`)return;let t=e.trim();if(t===``)return;let n=kq(t);return n?Oq.has(n.protocol)?t:void 0:Dq.test(t)?t:void 0}function jq(e){var t,n;let r=Aq(e);return(r===void 0||(t=(n=kq(r))==null?void 0:n.hostname)==null?``:t).replace(/^www\./,``)||void 0}var Mq=[`className`,`variant`,`size`,`children`],Nq=[`className`,`containerClassName`,`ratio`,`fit`,`onLoad`,`onError`,`alt`,`src`],Pq=[`className`,`label`,`url`,`iconUrl`],Fq=[`className`,`children`],Iq=e=>{switch(e){case`image/png`:return`png`;case`image/jpeg`:case`image/jpg`:return`jpg`;case`image/webp`:return`webp`;case`image/gif`:return`gif`;case`image/svg+xml`:return`svg`;default:return`png`}},Lq=e=>{var t,n;let r=e.indexOf(`,`),i=r>=0?e.slice(0,r):e,a=r>=0?e.slice(r+1):``,o=(t=(n=i.match(/data:([^;]+)/i))==null||(n=n[1])==null?void 0:n.toLowerCase())==null?`application/octet-stream`:t;if(!/;base64/i.test(i)){let e=[],t=0;for(let n of a.matchAll(/(?:%[\da-f]{2})+/gi)){n.index>t&&e.push(a.slice(t,n.index));let r=n[0],i=new Uint8Array(r.length/3);for(let e=0;e<i.length;e++)i[e]=Number.parseInt(r.slice(e*3+1,e*3+3),16);e.push(i),t=n.index+r.length}return e.push(a.slice(t)),new Blob(e,{type:o})}let s;try{let e=a.replace(/%([\da-f]{2})/gi,(e,t)=>String.fromCharCode(Number.parseInt(t,16)));s=atob(e)}catch(e){return null}let c=new Uint8Array(s.length);for(let e=0;e<s.length;e++)c[e]=s.charCodeAt(e);return new Blob([c],{type:o})},Rq=e=>{var t;return(t=e.match(/^data:([^;,]+)/i))==null||(t=t[1])==null?void 0:t.toLowerCase()},zq=e=>{let t=Rq(e);if(t)return`image.${Iq(t)}`;try{var n;let t=(n=new URL(e,document.baseURI).pathname.split(`/`).pop())==null?``:n,r=t;try{r=decodeURIComponent(t)}catch(e){}if(/\.(png|jpe?g|webp|gif|svg)$/i.test(r))return r}catch(e){}return`image.png`},Bq=e=>{try{let t=new URL(e,document.baseURI);return t.protocol===`http:`||t.protocol===`https:`||t.protocol===`blob:`?e:null}catch(e){return null}},Vq=e=>{var t;if(typeof document>`u`)return;let n=(t=e.filename)==null?zq(e.image):t,r=/^data:/i.test(e.image),i=r?Lq(e.image):null;if(r&&!i)return;let a=i?URL.createObjectURL(i):null,o=a==null?Bq(e.image):a;if(!o)return;let s=document.createElement(`a`);s.href=o,s.download=n,s.rel=`noopener`,document.body.appendChild(s),s.click(),document.body.removeChild(s),a&&setTimeout(()=>URL.revokeObjectURL(a),4e4)},Hq=function(){var e=w(function*(e){var t,n;if(typeof navigator>`u`||!navigator.clipboard||typeof ClipboardItem>`u`)throw Error(`Clipboard API is not available in this environment.`);let r=/^data:/i.test(e.image)?Lq(e.image):yield fetch(e.image).then(e=>e.blob());if(!r)return;let i=(t=(n=Rq(e.image))==null?r.type:n)==null?`image/png`:t;yield navigator.clipboard.write([new ClipboardItem({[i]:r})])});return function(t){return e.apply(this,arguments)}}(),Uq=XG(`aui-image-root relative overflow-hidden rounded-lg`,{variants:{variant:{outline:`border-border border`,ghost:``,muted:`bg-muted/50`},size:{sm:`max-w-64`,default:`max-w-96`,lg:`max-w-[512px]`,full:`w-full`}},defaultVariants:{variant:`outline`,size:`default`}});function Wq(e){let{className:t,variant:n,size:r,children:i}=e,a=W(e,Mq);return(0,J.jsx)(`div`,E(E({"data-slot":`image-root`,"data-variant":n,"data-size":r,className:Q(Uq({variant:n,size:r,className:t}))},a),{},{children:i}))}function Gq(e){let{className:t,containerClassName:n,ratio:r=`auto`,fit:i=`contain`,onLoad:a,onError:o,alt:s=`Image content`,src:c}=e,l=W(e,Nq),u=(0,h.useRef)(null),[d,f]=(0,h.useState)(void 0),[p,m]=(0,h.useState)(void 0),g=d===c,_=p===c,v=r!==`auto`,y=r===`1:1`?`aspect-square`:r===`4:3`?`aspect-[4/3]`:r===`16:9`?`aspect-video`:r===`9:16`?`aspect-[9/16]`:void 0;return(0,h.useEffect)(()=>{let e=u.current;typeof c==`string`&&e!=null&&e.complete&&(e.naturalWidth>0?f(c):m(c))},[c]),(0,J.jsxs)(`div`,{"data-slot":`image-preview`,className:Q(`relative`,v?y:`min-h-32`,n),children:[!g&&!_&&(0,J.jsx)(`div`,{"data-slot":`image-preview-loading`,className:`bg-muted/50 absolute inset-0 flex items-center justify-center`,children:(0,J.jsx)(RI,{className:`text-muted-foreground size-8 animate-pulse`})}),_?(0,J.jsx)(`div`,{"data-slot":`image-preview-error`,className:Q(`bg-muted/50 flex min-h-32 items-center justify-center p-4`,v&&`absolute inset-0`),children:(0,J.jsx)(II,{className:`text-muted-foreground size-8`})}):(0,J.jsx)(`img`,E({ref:u,src:c,alt:s,className:Q(v?Q(`block h-full w-full`,{"object-cover":i===`cover`,"object-contain":i===`contain`}):`block h-auto w-full object-contain`,!g&&`invisible`,t),onLoad:e=>{typeof c==`string`&&f(c),a==null||a(e)},onError:e=>{typeof c==`string`&&m(c),o==null||o(e)}},l))]})}function Kq(e){let{className:t,label:n,url:r,iconUrl:i}=e,a=W(e,Pq),o=Aq(r),s=jq(r),c=n||s,[l,u]=(0,h.useState)();if(!c)return null;let d=i!==void 0&&l!==i;return(0,J.jsxs)(`div`,E(E({"data-slot":`image-source`,className:Q(`text-muted-foreground flex items-center gap-2 border-t px-2 py-1.5 text-xs`,t)},a),{},{children:[d?(0,J.jsx)(`img`,{"data-slot":`image-source-icon`,src:i,alt:``,className:`size-4 shrink-0 rounded-sm`,onError:()=>u(i)}):(0,J.jsx)(`span`,{"data-slot":`image-source-icon-fallback`,"aria-hidden":`true`,className:`bg-muted flex size-4 shrink-0 items-center justify-center rounded-sm text-[10px] font-medium`,children:c.charAt(0).toUpperCase()}),o?(0,J.jsxs)(`a`,{"data-slot":`image-source-label`,href:o,target:`_blank`,rel:`noopener noreferrer`,className:`hover:text-foreground truncate`,children:[c,(0,J.jsx)(`span`,{className:`sr-only`,children:` (opens in a new tab)`})]}):(0,J.jsx)(`span`,{"data-slot":`image-source-label`,className:`truncate`,children:c})]}))}function qq(e){let{className:t,children:n}=e,r=W(e,Fq);return n?(0,J.jsx)(`span`,E(E({"data-slot":`image-filename`,className:Q(`text-muted-foreground block truncate px-2 py-1.5 text-xs`,t)},r),{},{children:n})):null}function Jq({src:e,alt:t=`Image preview`,children:r}){let[i,a]=(0,h.useState)(!1),o=(0,h.useRef)(null),s=(0,h.useRef)(null),c=(0,h.useRef)(null),l=(0,h.useCallback)(()=>a(!0),[]),u=(0,h.useCallback)(()=>{var e;a(!1),(e=o.current)==null||e.focus()},[]);return(0,h.useEffect)(()=>{if(!i)return;let e=e=>{var t;if(e.key===`Escape`){u();return}if(e.key!==`Tab`)return;let n=(t=c.current)==null?void 0:t.querySelectorAll(`a[href], button:not([disabled]), [tabindex]:not([tabindex="-1"])`),r=n==null?void 0:n[0],i=n==null?void 0:n[n.length-1];r&&i&&(e.shiftKey&&document.activeElement===r?(e.preventDefault(),i.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),r.focus()))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,u]),(0,h.useEffect)(()=>{if(!i)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[i]),(0,h.useEffect)(()=>{var e;i&&((e=s.current)==null||e.focus())},[i]),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{ref:o,onClick:l,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.click()):e.key===` `&&e.preventDefault()},onKeyUp:e=>{e.key===` `&&e.currentTarget.click()},role:`button`,tabIndex:0,className:`aui-image-zoom-trigger cursor-zoom-in`,"aria-label":`Click to zoom image`,children:r}),i&&(0,n.createPortal)((0,J.jsxs)(`div`,{ref:c,"data-slot":`image-zoom-overlay`,role:`dialog`,"aria-modal":`true`,className:`aui-image-zoom-overlay fade-in animate-in fixed inset-0 z-50 flex items-center justify-center bg-black/80 duration-200`,onClick:u,"aria-label":`Zoomed image`,children:[(0,J.jsx)(`img`,{"data-slot":`image-zoom-content`,src:e,alt:t,className:`aui-image-zoom-content fade-in zoom-in-95 animate-in max-h-[90%] max-w-[90%] cursor-zoom-out object-contain duration-200`,onClick:e=>{e.stopPropagation(),u()}}),(0,J.jsx)(`button`,{ref:s,type:`button`,"aria-label":`Close zoomed image`,onClick:e=>{e.stopPropagation(),u()},className:`text-muted-foreground hover:text-foreground bg-background/80 absolute end-4 top-4 rounded-md p-2`,children:(0,J.jsx)(bL,{className:`size-5`})})]}),document.body)]})}function Yq({className:e}){return(0,J.jsxs)(`div`,{"data-slot":`image-generating`,className:Q(`bg-muted/50 flex min-h-32 items-center justify-center p-4`,e),children:[(0,J.jsx)(BI,{className:`text-muted-foreground size-8 animate-spin`}),(0,J.jsx)(`span`,{className:`sr-only`,children:`Generating image…`})]})}function Xq({className:e,reason:t}){return(0,J.jsxs)(`div`,{"data-slot":`image-content-filter-error`,className:Q(`bg-muted/50 flex min-h-32 flex-col items-center justify-center gap-2 p-4 text-center`,e),children:[(0,J.jsx)(cL,{className:`text-muted-foreground size-8`}),(0,J.jsx)(`p`,{className:`text-sm font-medium`,children:`Image could not be generated`}),t&&(0,J.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:t})]})}function Zq({onRegenerate:e}){let[t,n]=(0,h.useState)(!1);return(0,J.jsx)(`button`,{type:`button`,onClick:function(){var t=w(function*(){n(!0);try{yield e()}catch(e){}finally{n(!1)}});return function(){return t.apply(this,arguments)}}(),disabled:t,"data-slot":`image-regenerate`,"aria-label":`Regenerate image`,className:`hover:bg-muted inline-flex size-7 items-center justify-center rounded disabled:opacity-50`,children:(0,J.jsx)(oL,{className:Q(`size-4`,t&&`animate-spin`)})})}function Qq({part:e,onRegenerate:t,className:n}){return(0,J.jsxs)(`div`,{"data-slot":`image-actions`,className:Q(`flex items-center gap-1 p-1`,n),children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>Vq(e),"data-slot":`image-download`,"aria-label":`Download image`,className:`hover:bg-muted inline-flex size-7 items-center justify-center rounded`,children:(0,J.jsx)(EI,{className:`size-4`})}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>{Hq(e).catch(()=>{})},"data-slot":`image-copy`,"aria-label":`Copy image`,className:`hover:bg-muted inline-flex size-7 items-center justify-center rounded`,children:(0,J.jsx)(wI,{className:`size-4`})}),t&&(0,J.jsx)(Zq,{onRegenerate:t})]})}var $q=(0,h.memo)(e=>{let{image:t,filename:n,status:r}=e;return(r==null?void 0:r.type)===`running`?(0,J.jsxs)(Wq,{children:[(0,J.jsx)(Yq,{}),(0,J.jsx)(qq,{children:n})]}):(r==null?void 0:r.type)===`incomplete`&&r.reason===`content-filter`?(0,J.jsx)(Wq,{children:(0,J.jsx)(Xq,{reason:`The provider blocked this image.`})}):(0,J.jsxs)(Wq,{children:[(0,J.jsx)(Jq,{src:t,alt:n||`Image content`,children:(0,J.jsx)(Gq,{src:t,alt:n||`Image content`})}),(0,J.jsx)(qq,{children:n})]})});$q.displayName=`Image`,$q.Root=Wq,$q.Preview=Gq,$q.Source=Kq,$q.Filename=qq,$q.Zoom=Jq,$q.Actions=Qq,$q.Generating=Yq,$q.ContentFilterError=Xq;var eJ=[`node`],tJ=(e,t,n=0,r=!1)=>{if(Object.is(e,t))return!0;if(n>=100||typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!tJ(e[r],t[r],n+1))return!1;return!0}if(Array.isArray(t))return!1;let i=Object.getPrototypeOf(e),a=Object.getPrototypeOf(t);if(i!==Object.prototype&&i!==null||a!==Object.prototype&&a!==null)return!1;let o=e,s=t,c=0;for(let e in o)if(Object.hasOwn(o,e)&&(!r||e!==`position`&&e!==`data`)){if(!Object.prototype.propertyIsEnumerable.call(s,e)||!tJ(o[e],s[e],n+1))return!1;c++}let l=0;for(let e in s)Object.hasOwn(s,e)&&(!r||e!==`position`&&e!==`data`)&&l++;return c===l},nJ=(e,t)=>!e||!t?!1:e===t||tJ(e.properties,t.properties,0,!0)&&tJ(e.children,t.children),rJ=(e,t)=>nJ(e.node,t.node),iJ=(e={})=>Object.fromEntries(Object.entries(e==null?{}:e).map(([e,t])=>{if(!t)return[e,t];let n=t;return[e,(0,h.memo)(e=>{let{node:t}=e,r=W(e,eJ);return(0,J.jsx)(n,E({},r))},rJ)]})),aJ=[`children`,`fallbackPre`],oJ=(0,h.createContext)(null),sJ=()=>(0,h.useContext)(oJ)!==null,cJ=(0,h.memo)(e=>{var t,n;let{children:r,fallbackPre:i}=e,a=W(e,aJ);return(t=(n=a.node)==null?void 0:n.children.some(e=>e.type===`element`&&e.tagName===`code`))==null||t?(0,J.jsx)(oJ.Provider,{value:a,children:r}):(0,J.jsx)(i,E(E({},a),{},{children:r}))},(e,t)=>e.fallbackPre===t.fallbackPre&&rJ(e,t)),lJ=[`node`],uJ=[`node`],dJ=e=>{let{node:t}=e,n=W(e,lJ);return(0,J.jsx)(`pre`,E({},n))},fJ=e=>{let{node:t}=e,n=W(e,uJ);return(0,J.jsx)(`code`,E({},n))},pJ=({node:e,components:{Pre:t,Code:n},code:r})=>(0,J.jsx)(t,{children:(0,J.jsx)(n,{node:e,children:r})}),mJ=()=>null,hJ=e=>{var t,n;return(t=(n=/language-([^\s]+)/.exec(e==null?``:e))==null?void 0:n[1])==null?``:t},gJ=({node:e,components:{Pre:t,Code:n,SyntaxHighlighter:r,CodeHeader:i},language:a,code:o})=>{let s=(0,h.useMemo)(()=>({Pre:t,Code:n}),[t,n]);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(i,{node:e,language:a,code:o}),(0,J.jsx)(r,{node:e,components:s,language:a,code:o})]})},_J=m(u(((e,t)=>{(function(){"use strict";var e={}.hasOwnProperty;function n(){for(var e=``,t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=i(e,r(n)))}return e}function r(t){if(typeof t==`string`||typeof t==`number`)return t;if(typeof t!=`object`)return``;if(Array.isArray(t))return n.apply(null,t);if(t.toString!==Object.prototype.toString&&!t.toString.toString().includes(`[native code]`))return t.toString();var r=``;for(var a in t)e.call(t,a)&&t[a]&&(r=i(r,a));return r}function i(e,t){return t?e?e+` `+t:e+t:e}t!==void 0&&t.exports?(n.default=n,t.exports=n):typeof define==`function`&&typeof define.amd==`object`&&define.amd?define(`classnames`,[],function(){return n}):window.classNames=n})()}))(),1),vJ=[`className`],yJ=[`className`],bJ=e=>{let{className:t}=e,n=W(e,vJ);return e=>{let{className:r}=e,i=W(e,yJ);return E(E({className:(0,_J.default)(t,r)},n),i)}},xJ=[`node`,`components`,`componentsByLanguage`,`children`],SJ=[`node`,`components`,`componentsByLanguage`],CJ=(0,h.createContext)(null);function wJ(e){let{Pre:t,preProps:n}=(0,h.useContext)(CJ);return(0,J.jsx)(t,E({},bJ(n)(e)))}function TJ(e){let{Code:t,codeProps:n}=(0,h.useContext)(CJ);return(0,J.jsx)(t,E({},bJ(n)(e)))}function EJ(e){if(typeof e==`string`)return e;if(Array.isArray(e)){let t=``;for(let n of e)t+=EJ(n);return t}return(0,h.isValidElement)(e)?EJ(e.props.children):``}var DJ=e=>{var t,n,r,i;let{node:a,components:{Pre:o,Code:s,SyntaxHighlighter:c,CodeHeader:l},componentsByLanguage:u={},children:d}=e,f=W(e,xJ),p={Pre:o,Code:s,preProps:(0,h.useContext)(oJ),codeProps:f},m=hJ(f.className),g=(t=(n=u[m])==null?void 0:n.SyntaxHighlighter)==null?c:t,_=(r=(i=u[m])==null?void 0:i.CodeHeader)==null?l:r;return d!=null&&typeof d!=`string`?(0,J.jsxs)(CJ.Provider,{value:p,children:[(0,J.jsx)(_,{node:a,language:m,code:EJ(d)}),(0,J.jsx)(pJ,{node:a,components:{Pre:wJ,Code:TJ},code:d})]}):(0,J.jsx)(CJ.Provider,{value:p,children:(0,J.jsx)(gJ,{node:a,components:{Pre:wJ,Code:TJ,SyntaxHighlighter:g,CodeHeader:_},language:m,code:d==null?``:d})})},OJ=e=>{let{node:t,components:n,componentsByLanguage:r}=e,i=W(e,SJ);return sJ()?(0,J.jsx)(DJ,E({node:t,components:n,componentsByLanguage:r},i)):(0,J.jsx)(n.Code,E({},i))},kJ=(e,t)=>{if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n){if(!Object.hasOwn(t,r))return!1;let n=e[r],i=t[r];if(n!==i&&(!n||!i||n.SyntaxHighlighter!==i.SyntaxHighlighter||n.CodeHeader!==i.CodeHeader))return!1}return!0},AJ=(0,h.memo)(OJ,(e,t)=>e.components===t.components&&kJ(e.componentsByLanguage,t.componentsByLanguage)&&rJ(e,t));function jJ(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}RegExp(`[$_\\p{ID_Start}]`,`u`),RegExp(`[$_\\u{200C}\\u{200D}\\p{ID_Continue}]`,`u`),RegExp(`[-$_\\u{200C}\\u{200D}\\p{ID_Continue}]`,`u`);var MJ=RegExp(`^[$_\\p{ID_Start}][$_\\u{200C}\\u{200D}\\p{ID_Continue}]*$`,`u`),NJ=RegExp(`^[$_\\p{ID_Start}][-$_\\u{200C}\\u{200D}\\p{ID_Continue}]*$`,`u`),PJ={};function FJ(e,t){return((t||PJ).jsx?NJ:MJ).test(e)}var IJ=/[ \t\n\f\r]/g;function LJ(e){return typeof e==`object`?e.type===`text`&&RJ(e.value):RJ(e)}function RJ(e){return e.replace(IJ,``)===``}var zJ=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};zJ.prototype.normal={},zJ.prototype.property={},zJ.prototype.space=void 0;function BJ(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new zJ(n,r,t)}function VJ(e){return e.toLowerCase()}var HJ=class{constructor(e,t){this.attribute=t,this.property=e}};HJ.prototype.attribute=``,HJ.prototype.booleanish=!1,HJ.prototype.boolean=!1,HJ.prototype.commaOrSpaceSeparated=!1,HJ.prototype.commaSeparated=!1,HJ.prototype.defined=!1,HJ.prototype.mustUseProperty=!1,HJ.prototype.number=!1,HJ.prototype.overloadedBoolean=!1,HJ.prototype.property=``,HJ.prototype.spaceSeparated=!1,HJ.prototype.space=void 0;var UJ=d({boolean:()=>GJ,booleanish:()=>KJ,commaOrSpaceSeparated:()=>XJ,commaSeparated:()=>YJ,number:()=>$,overloadedBoolean:()=>qJ,spaceSeparated:()=>JJ}),WJ=0,GJ=ZJ(),KJ=ZJ(),qJ=ZJ(),$=ZJ(),JJ=ZJ(),YJ=ZJ(),XJ=ZJ();function ZJ(){return Math.pow(2,++WJ)}var QJ=Object.keys(UJ),$J=class extends HJ{constructor(e,t,n,r){let i=-1;if(super(e,t),eY(this,`space`,r),typeof n==`number`)for(;++i<QJ.length;){let e=QJ[i];eY(this,QJ[i],(n&UJ[e])===UJ[e])}}};$J.prototype.defined=!0;function eY(e,t,n){n&&(e[t]=n)}function tY(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new $J(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[VJ(r)]=r,n[VJ(a.attribute)]=r}return new zJ(t,n,e.space)}var nY=tY({properties:{ariaActiveDescendant:null,ariaAtomic:KJ,ariaAutoComplete:null,ariaBusy:KJ,ariaChecked:KJ,ariaColCount:$,ariaColIndex:$,ariaColSpan:$,ariaControls:JJ,ariaCurrent:null,ariaDescribedBy:JJ,ariaDetails:null,ariaDisabled:KJ,ariaDropEffect:JJ,ariaErrorMessage:null,ariaExpanded:KJ,ariaFlowTo:JJ,ariaGrabbed:KJ,ariaHasPopup:null,ariaHidden:KJ,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:JJ,ariaLevel:$,ariaLive:null,ariaModal:KJ,ariaMultiLine:KJ,ariaMultiSelectable:KJ,ariaOrientation:null,ariaOwns:JJ,ariaPlaceholder:null,ariaPosInSet:$,ariaPressed:KJ,ariaReadOnly:KJ,ariaRelevant:null,ariaRequired:KJ,ariaRoleDescription:JJ,ariaRowCount:$,ariaRowIndex:$,ariaRowSpan:$,ariaSelected:KJ,ariaSetSize:$,ariaSort:null,ariaValueMax:$,ariaValueMin:$,ariaValueNow:$,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function rY(e,t){return t in e?e[t]:t}function iY(e,t){return rY(e,t.toLowerCase())}var aY=tY({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:YJ,acceptCharset:JJ,accessKey:JJ,action:null,allow:null,allowFullScreen:GJ,allowPaymentRequest:GJ,allowUserMedia:GJ,alpha:GJ,alt:null,as:null,async:GJ,autoCapitalize:null,autoComplete:JJ,autoFocus:GJ,autoPlay:GJ,blocking:JJ,capture:null,charSet:null,checked:GJ,cite:null,className:JJ,closedBy:null,colorSpace:null,cols:$,colSpan:$,command:null,commandFor:null,content:null,contentEditable:KJ,controls:GJ,controlsList:JJ,coords:$|YJ,crossOrigin:null,data:null,dateTime:null,decoding:null,default:GJ,defer:GJ,dir:null,dirName:null,disabled:GJ,download:qJ,draggable:KJ,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:GJ,formTarget:null,headers:JJ,height:$,hidden:qJ,high:$,href:null,hrefLang:null,htmlFor:JJ,httpEquiv:JJ,id:null,imageSizes:null,imageSrcSet:null,inert:GJ,inputMode:null,integrity:null,is:null,isMap:GJ,itemId:null,itemProp:JJ,itemRef:JJ,itemScope:GJ,itemType:JJ,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:GJ,low:$,manifest:null,max:null,maxLength:$,media:null,method:null,min:null,minLength:$,multiple:GJ,muted:GJ,name:null,nonce:null,noModule:GJ,noValidate:GJ,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:GJ,optimum:$,pattern:null,ping:JJ,placeholder:null,playsInline:GJ,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:GJ,referrerPolicy:null,rel:JJ,required:GJ,reversed:GJ,rows:$,rowSpan:$,sandbox:JJ,scope:null,scoped:GJ,seamless:GJ,selected:GJ,shadowRootClonable:GJ,shadowRootCustomElementRegistry:GJ,shadowRootDelegatesFocus:GJ,shadowRootMode:null,shadowRootSerializable:GJ,shape:null,size:$,sizes:null,slot:null,span:$,spellCheck:KJ,src:null,srcDoc:null,srcLang:null,srcSet:null,start:$,step:null,style:null,tabIndex:$,target:null,title:null,translate:null,type:null,typeMustMatch:GJ,useMap:null,value:KJ,width:$,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:JJ,axis:null,background:null,bgColor:null,border:$,borderColor:null,bottomMargin:$,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:GJ,declare:GJ,event:null,face:null,frame:null,frameBorder:null,hSpace:$,leftMargin:$,link:null,longDesc:null,lowSrc:null,marginHeight:$,marginWidth:$,noResize:GJ,noHref:GJ,noShade:GJ,noWrap:GJ,object:null,profile:null,prompt:null,rev:null,rightMargin:$,rules:null,scheme:null,scrolling:KJ,standby:null,summary:null,text:null,topMargin:$,valueType:null,version:null,vAlign:null,vLink:null,vSpace:$,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:GJ,disablePictureInPicture:GJ,disableRemotePlayback:GJ,exportParts:YJ,part:JJ,prefix:null,property:null,results:$,security:null,unselectable:null},space:`html`,transform:iY}),oY=tY({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`,maskType:`mask-type`,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:XJ,accentHeight:$,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:$,amplitude:$,arabicForm:null,ascent:$,attributeName:null,attributeType:null,azimuth:$,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:$,by:null,calcMode:null,capHeight:$,className:JJ,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:$,diffuseConstant:$,direction:null,display:null,dur:null,divisor:$,dominantBaseline:null,download:GJ,dx:null,dy:null,edgeMode:null,editable:null,elevation:$,enableBackground:null,end:null,event:null,exponent:$,externalResourcesRequired:null,fill:null,fillOpacity:$,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:YJ,g2:YJ,glyphName:YJ,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:$,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:$,horizOriginX:$,horizOriginY:$,id:null,ideographic:$,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:$,k:$,k1:$,k2:$,k3:$,k4:$,kernelMatrix:XJ,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:$,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:$,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:$,overlineThickness:$,paintOrder:null,panose1:null,path:null,pathLength:$,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:JJ,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:$,pointsAtY:$,pointsAtZ:$,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:XJ,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:XJ,rev:XJ,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:XJ,requiredFeatures:XJ,requiredFonts:XJ,requiredFormats:XJ,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:$,specularExponent:$,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:$,strikethroughThickness:$,string:null,stroke:null,strokeDashArray:XJ,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:$,strokeOpacity:$,strokeWidth:null,style:null,surfaceScale:$,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:XJ,tabIndex:$,tableValues:null,target:null,targetX:$,targetY:$,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:XJ,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:$,underlineThickness:$,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:$,values:null,vAlphabetic:$,vMathematical:$,vectorEffect:null,vHanging:$,vIdeographic:$,version:null,vertAdvY:$,vertOriginX:$,vertOriginY:$,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:$,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:rY}),sY=tY({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()}}),cY=tY({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:iY}),lY=tY({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),uY={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`},dY=/[A-Z]/g,fY=/-[a-z]/g,pY=/^data[-\w.:]+$/i;function mY(e,t){let n=VJ(t),r=t,i=HJ;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&pY.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(fY,gY);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!fY.test(e)){let n=e.replace(dY,hY);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=$J}return new i(r,t)}function hY(e){return`-`+e.toLowerCase()}function gY(e){return e.charAt(1).toUpperCase()}var _Y=BJ([nY,aY,sY,cY,lY],`html`),vY=BJ([nY,oY,sY,cY,lY],`svg`);function yY(e){return e.join(` `).trim()}var bY=/\/\*(?:[^*]|\*(?!\/))*\*\//g,xY=/\n/g,SY=/^\s*/,CY=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,wY=/^:\s*/,TY=/^((?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|url\((?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|[^)]*)\)|[^};])+)/,EY=/^[;\s]*/,DY=`
61
+ `,OY=`/`,kY=`*`,AY=``,jY=`comment`,MY=`declaration`;function NY(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t=t||{};var n=1,r=1;function i(e){var t=e.match(xY);t&&(n+=t.length);var i=e.lastIndexOf(DY);r=~i?e.length-i:r+e.length}function a(){var e={line:n,column:r};return function(t){return t.position=new o(e),l(),t}}function o(e){this.start=e,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function s(i){var a=Error(t.source+`:`+n+`:`+r+`: `+i);if(a.reason=i,a.filename=t.source,a.line=n,a.column=r,a.source=e,!t.silent)throw a}function c(t){var n=t.exec(e);if(n){var r=n[0];return i(r),e=e.slice(r.length),n}}function l(){c(SY)}function u(e){for(var t;t=d();)e.push(t);return e}function d(){var t=a();if(OY==e.charAt(0)&&kY==e.charAt(1)){for(var n=2;AY!=e.charAt(n)&&(kY!=e.charAt(n)||OY!=e.charAt(n+1));)++n;if(n+=2,AY===e.charAt(n-1))return s(`End of comment missing`);var o=e.slice(2,n-2);return r+=2,i(o),e=e.slice(n),r+=2,t({type:jY,comment:o})}}function f(){var e=a(),t=c(CY);if(t){if(d(),!c(wY))return s(`property missing ':'`);var n=c(TY),r=e({type:MY,property:t[0].replace(bY,AY).trim(),value:n?n[0].replace(bY,AY).trim():AY});return c(EY),r}}function p(){var e=[];u(e);for(var t;t=f();)e.push(t),u(e);return e}return l(),p()}function PY(e,t){let n=null;if(!e||typeof e!=`string`)return n;let r=NY(e),i=typeof t==`function`;return r.forEach(e=>{if(e.type!==`declaration`)return;let{property:r,value:a}=e;if(i)t(r,a,e);else if(a){var o;n=(o=n)==null?{}:o,n[r]=a}}),n}var FY=LY(`end`),IY=LY(`start`);function LY(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function RY(e){let t=IY(e),n=FY(e);if(t&&n)return{start:t,end:n}}function zY(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?VY(e.position):`start`in e||`end`in e?VY(e):`line`in e||`column`in e?BY(e):``}function BY(e){return HY(e&&e.line)+`:`+HY(e&&e.column)}function VY(e){return BY(e&&e.start)+`-`+BY(e&&e.end)}function HY(e){return e&&typeof e==`number`?e:1}var UY=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:E({},t)),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=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=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=zY(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=a&&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}};UY.prototype.file=``,UY.prototype.name=``,UY.prototype.reason=``,UY.prototype.message=``,UY.prototype.stack=``,UY.prototype.column=void 0,UY.prototype.line=void 0,UY.prototype.ancestors=void 0,UY.prototype.cause=void 0,UY.prototype.fatal=void 0,UY.prototype.place=void 0,UY.prototype.ruleId=void 0,UY.prototype.source=void 0;var WY={}.hasOwnProperty,GY=new Map,KY=/[A-Z]/g,qY=/-([a-z])/g,JY=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),YY=new Set([`td`,`th`]),XY=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function ZY(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=cX(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=sX(n,t.jsx,t.jsxs)}let i={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`?vY:_Y,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=QY(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function QY(e,t,n){if(t.type===`element`)return $Y(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return eX(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return nX(e,t,n);if(t.type===`mdxjsEsm`)return tX(e,t);if(t.type===`root`)return rX(e,t,n);if(t.type===`text`)return iX(e,t)}function $Y(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=vY,e.schema=i),e.ancestors.push(t);let a=mX(e,t.tagName,!1),o=lX(e,t),s=dX(e,t);return JY.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!LJ(e)})),aX(e,o,a,t),oX(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function eX(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}hX(e,t.position)}function tX(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);hX(e,t.position)}function nX(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=vY,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:mX(e,t.name,!0),o=uX(e,t),s=dX(e,t);return aX(e,o,a,t),oX(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function rX(e,t,n){let r={};return oX(r,dX(e,t)),e.create(t,e.Fragment,r,n)}function iX(e,t){return t.value}function aX(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function oX(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function sX(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function cX(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=IY(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function lX(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&WY.call(t.properties,i)){let a=fX(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&YY.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||(n.style={});t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function uX(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else hX(e,t.position)}else{let{name:i}=r,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else hX(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function dX(e,t){let n=[],r=-1,i=e.passKeys?new Map:GY;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=QY(e,a,o);s!==void 0&&n.push(s)}return n}function fX(e,t,n){if(n==null||typeof n==`number`&&Number.isNaN(n))return;let r=mY(e.schema,t);return Array.isArray(n)&&(n=r.commaSeparated?jJ(n):yY(n)),r.property===`style`?[`style`,typeof n==`object`?e.stylePropertyNameCase===`dom`?n:gX(n):pX(e,String(n))]:[e.elementAttributeNameCase===`react`&&r.space?uY[r.property]||r.property:r.attribute,n]}function pX(e,t){let n={};try{PY(t,function(t,r){if(t&&r){let i=t;i.slice(0,2)!==`--`&&(i=i.toLowerCase(),e.stylePropertyNameCase===`dom`&&(i.slice(0,4)===`-ms-`&&(i=i.slice(1)),i=i.replace(qY,yX))),n[i]=r}})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new UY("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=XY+`#cannot-parse-style-attribute`,r}return n}function mX(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=FJ(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=FJ(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return WY.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);hX(e)}function hX(e,t){let n=new UY("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=XY+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function gX(e){let t={},n;for(n in e)WY.call(e,n)&&(t[_X(n)]=e[n]);return t}function _X(e){if(e.slice(0,2)===`--`)return e;let t=e.replace(KY,vX);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function vX(e){return`-`+e.toLowerCase()}function yX(e,t){return t.toUpperCase()}var bX={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`]},xX={};function SX(e,t){let n=t||xX;return CX(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function CX(e,t,n){if(TX(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 wX(e.children,t,n)}return Array.isArray(e)?wX(e,t,n):``}function wX(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=CX(e[i],t,n);return r.join(``)}function TX(e){return!!(e&&typeof e==`object`)}var EX=document.createElement(`i`);function DX(e){let t=`&`+e+`;`;EX.innerHTML=t;let n=EX.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function OX(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i: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);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function kX(e,t){return e.length>0?(OX(e,e.length,0,t),e):t}var AX={}.hasOwnProperty;function jX(e){let t={},n=-1;for(;++n<e.length;)MX(t,e[n]);return t}function MX(e,t){let n;for(n in t){let r=(AX.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){AX.call(r,a)||(r[a]=[]);let e=i[a];NX(r[a],Array.isArray(e)?e:e?[e]:[])}}}function NX(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);OX(e,0,0,r)}function PX(e,t){let 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 FX(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var IX=JX(/[A-Za-z]/),LX=JX(/[\dA-Za-z]/),RX=JX(/[#-'*+\--9=?A-Z^-~]/);function zX(e){return e!==null&&(e<32||e===127)}var BX=JX(/\d/),VX=JX(/[\dA-Fa-f]/),HX=JX(/[!-/:-@[-`{-~]/);function UX(e){return e!==null&&e<-2}function WX(e){return e!==null&&(e<0||e===32)}function GX(e){return e===-2||e===-1||e===32}var KX=JX(RegExp(`\\p{P}|\\p{S}`,`u`)),qX=JX(/\s/);function JX(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function YX(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&LX(e.charCodeAt(n+1))&&LX(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=``),i&&(n+=i,i=0)}return t.join(``)+e.slice(r)}function XX(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return GX(r)?(e.enter(n),s(r)):t(r)}function s(r){return GX(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}function ZX(e,t,n,r,i,a){let o=0;return s;function s(t){return a>0&&GX(t)?(e.enter(r),c(t)):l(t)}function c(t){return GX(t)&&o<a?(e.consume(t),o++,c):(e.exit(r),l(t))}function l(e){return o>=i?t(e):n(e)}}var QX={tokenize:$X};function $X(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null)e.consume(n);else return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),XX(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null)e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);else return UX(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var eZ=class{constructor(){this.index=new Map,this.map=[]}add(e,t,n){tZ(this,e,t,n,!1)}addBefore(e,t,n){tZ(this,e,t,n,!0)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function tZ(e,t,n,r,i){if(n===0&&r.length===0)return;let a=e.index.get(t);if(a){a[1]+=n,i?(r.push(...a[2]),a[2]=r):a[2].push(...r);return}let o=[t,n,r];e.map.push(o),e.index.set(t,o)}var nZ={tokenize:iZ},rZ={tokenize:aZ};function iZ(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end=E({},o),s++;let c=new eZ;return c.add(a+1,0,t.events.slice(n)),c.add(n,s-n,[]),c.consume(t.events),l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(rZ,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(rZ,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null)i&&v(),_(0),e.consume(n);else return i=i||t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null)g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);else return UX(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end=E({},c),e++;let l=new eZ;l.add(a+1,0,t.events.slice(n)),l.add(n,e-n,[]),l.consume(t.events)}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function aZ(e,t,n){return XX(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function oZ(e){if(e===null||WX(e)||qX(e))return 1;if(KX(e))return 2}function sZ(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var cZ={name:`attention`,resolveAll:lZ,tokenize:uZ};function lZ(e,t){let n=-1,r;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){let i=n;for(;i--;)if(e[i][0]===`exit`&&e[i][1].type===`attentionSequence`&&e[i][1]._open&&t.sliceSerialize(e[i][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[i][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;let a=e[i][1].end.offset-e[i][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1,o=E({},e[i][1].end),s=E({},e[n][1].start);dZ(o,-a),dZ(s,a);let c={type:a>1?`strongSequence`:`emphasisSequence`,start:o,end:E({},e[i][1].end)},l={type:a>1?`strongSequence`:`emphasisSequence`,start:E({},e[n][1].start),end:s},u={type:a>1?`strongText`:`emphasisText`,start:E({},e[i][1].end),end:E({},e[n][1].start)},d={type:a>1?`strong`:`emphasis`,start:E({},c.start),end:E({},l.end)};e[i][1].end=E({},c.start),e[n][1].start=E({},l.end),r=[],e[i][1].end.offset-e[i][1].start.offset&&(r=kX(r,[[`enter`,e[i][1],t],[`exit`,e[i][1],t]])),r=kX(r,[[`enter`,d,t],[`enter`,c,t],[`exit`,c,t],[`enter`,u,t]]),r=kX(r,sZ(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),r=kX(r,[[`exit`,u,t],[`enter`,l,t],[`exit`,l,t],[`exit`,d,t]]);let f=0;e[n][1].end.offset-e[n][1].start.offset&&(f=2,r=kX(r,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])),OX(e,i-1,n-i+3,r),n=i+r.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function uZ(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=oZ(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=oZ(o),u=!l||l===2&&i||n.includes(o)&&o!==42&&o!==95,d=!i||i===2&&l||n.includes(r)&&r!==42&&r!==95;return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function dZ(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var fZ={name:`autolink`,tokenize:pZ};function pZ(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return IX(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||LX(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||LX(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||zX(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):RX(t)?(e.consume(t),l):n(t)}function u(e){return LX(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||LX(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var mZ={partial:!0,tokenize:hZ};function hZ(e,t,n){return r;function r(t){return GX(t)?XX(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||UX(e)?t(e):n(e)}}var gZ={continuation:{tokenize:vZ},exit:yZ,name:`blockQuote`,tokenize:_Z};function _Z(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||(e.enter(`blockQuote`,{_container:!0}),n.open=!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return GX(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function vZ(e,t,n){let r=this;return i;function i(t){return GX(t)?XX(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(gZ,t,n)(r)}}function yZ(e){e.exit(`blockQuote`)}var bZ={name:`characterEscape`,tokenize:xZ};function xZ(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return HX(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var SZ={name:`characterReference`,tokenize:CZ};function CZ(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=LX,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=VX,u):(e.enter(`characterReferenceValue`),a=7,o=BX,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===LX&&!DX(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var wZ={partial:!0,tokenize:TZ};function TZ(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var EZ={concrete:!0,name:`codeFenced`,tokenize:DZ};function DZ(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),GX(t)?XX(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||UX(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(wZ,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||UX(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):GX(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),XX(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||UX(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||UX(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&GX(t)?XX(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||UX(t)?e.check(wZ,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||UX(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),GX(t)?XX(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),GX(t)?XX(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||UX(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}var OZ={name:`codeIndented`,tokenize:AZ},kZ={partial:!0,tokenize:jZ};function AZ(e,t,n){return r;function r(t){return e.enter(`codeIndented`),ZX(e,i,n,`linePrefix`,4,4)(t)}function i(t){return t===null?o(t):UX(t)?e.attempt(kZ,i,o)(t):(e.enter(`codeFlowValue`),a(t))}function a(t){return t===null||UX(t)?(e.exit(`codeFlowValue`),i(t)):(e.consume(t),a)}function o(n){return e.exit(`codeIndented`),t(n)}}function jZ(e,t,n){let r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):UX(o)?(e.enter(`lineEnding`),e.consume(o),e.exit(`lineEnding`),i):ZX(e,t,a,`linePrefix`,4,4)(o)}function a(e){return UX(e)?i(e):n(e)}}var MZ={name:`codeText`,previous:PZ,resolve:NZ,tokenize:FZ};function NZ(e){let t=e.length-4,n=3,r,i;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;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function PZ(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function FZ(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):UX(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||UX(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var IZ=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t==null?1/0:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&LZ(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),LZ(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),LZ(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);LZ(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);LZ(this.left,t.reverse())}}}};function LZ(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 RZ(e){let t={},n=-1,r,i,a,o,s,c,l,u=new IZ(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,zZ(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end=E({},u.get(i)[1].start),s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return OX(e,0,1/0,u.slice(0)),!l}function zZ(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var BZ={resolve:HZ,tokenize:UZ},VZ={partial:!0,tokenize:WZ};function HZ(e){return RZ(e),e}function UZ(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):UX(t)?e.check(VZ,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function WZ(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),XX(e,a,`linePrefix`)}function a(i){if(i===null||UX(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function GZ(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||zX(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||UX(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||WX(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||zX(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function KZ(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):UX(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||UX(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||(c=!GX(t)),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function qZ(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):UX(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),XX(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||UX(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function JZ(e,t){let n;return r;function r(i){return UX(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):GX(i)?XX(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var YZ={name:`definition`,tokenize:ZZ},XZ={partial:!0,tokenize:QZ};function ZZ(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return KZ.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=FX(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return WX(t)?JZ(e,l)(t):l(t)}function l(t){return GZ(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(XZ,d,d)(t)}function d(t){return GX(t)?XX(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||UX(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function QZ(e,t,n){return r;function r(t){return WX(t)?JZ(e,i)(t):n(t)}function i(t){return qZ(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return GX(t)?XX(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||UX(e)?t(e):n(e)}}var $Z={name:`hardBreakEscape`,tokenize:eQ};function eQ(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return UX(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var tQ={name:`headingAtx`,resolve:nQ,tokenize:rQ};function nQ(e,t){let n=e.length-2,r=3;if(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){let i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`};OX(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])}return e}function rQ(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||WX(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||UX(n)?(e.exit(`atxHeading`),t(n)):GX(n)?XX(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||WX(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var iQ=`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`.split(`.`),aQ=[`pre`,`script`,`style`,`textarea`],oQ={concrete:!0,name:`htmlFlow`,resolveTo:cQ,tokenize:lQ},sQ={partial:!0,tokenize:uQ};function cQ(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 lQ(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:I):IX(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):IX(a)?(e.consume(a),i=4,r.interrupt?t:I):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:I):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return IX(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||WX(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&aQ.includes(l)?(i=1,r.interrupt?t(s):O(s)):iQ.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||LX(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return GX(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||IX(t)?(e.consume(t),b):GX(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||LX(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):GX(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):GX(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||UX(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||WX(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||GX(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||UX(t)?O(t):GX(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),L):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):UX(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(sQ,R,k)(t)):t===null||UX(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(wZ,A,R)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||UX(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),I):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return aQ.includes(n)?(e.consume(t),L):O(t)}return IX(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),I):O(t)}function I(t){return t===62?(e.consume(t),L):t===45&&i===2?(e.consume(t),I):O(t)}function L(t){return t===null||UX(t)?(e.exit(`htmlFlowData`),R(t)):(e.consume(t),L)}function R(n){return e.exit(`htmlFlow`),t(n)}}function uQ(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(mZ,t,n)}}var dQ={name:`htmlText`,tokenize:fQ};function fQ(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):IX(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):IX(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):UX(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):UX(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):UX(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):UX(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return IX(t)?(e.consume(t),S):n(t)}function S(t){return t===45||LX(t)?(e.consume(t),S):C(t)}function C(t){return UX(t)?(o=C,N(t)):GX(t)?(e.consume(t),C):M(t)}function w(t){return t===45||LX(t)?(e.consume(t),w):t===47||t===62||WX(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||IX(t)?(e.consume(t),E):UX(t)?(o=T,N(t)):GX(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||LX(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):UX(t)?(o=D,N(t)):GX(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):UX(t)?(o=O,N(t)):GX(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):UX(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||WX(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||WX(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return GX(t)?XX(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}var pQ={name:`labelEnd`,resolveAll:_Q,resolveTo:vQ,tokenize:yQ},mQ={tokenize:bQ},hQ={tokenize:xQ},gQ={tokenize:SQ};function _Q(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&OX(e,0,e.length,n),e}function vQ(e,t){let n=e.length,r=0,i,a,o;for(;n--;){let t=e[n][1];if(i){if(t.type===`link`||t.type===`labelLink`&&t._inactive)break;e[n][0]===`enter`&&t.type===`labelLink`&&(t._inactive=!0)}else if(a){if(e[n][0]===`enter`&&(t.type===`labelImage`||t.type===`labelLink`)&&!t._balanced&&(i=n,t.type!==`labelLink`)){r=2;break}}else t.type===`labelEnd`&&(a=n)}let s={type:e[i][1].type===`labelLink`?`link`:`image`,start:E({},e[i][1].start),end:E({},e[e.length-1][1].end)},c={type:`label`,start:E({},e[i][1].start),end:E({},e[a][1].end)},l={type:`labelText`,start:E({},e[i+r+2][1].end),end:E({},e[a-2][1].start)};return o=[[`enter`,s,t],[`enter`,c,t]],o=kX(o,e.slice(i+1,i+r+3)),o=kX(o,[[`enter`,l,t]]),o=kX(o,sZ(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),o=kX(o,[[`exit`,l,t],e[a-2],e[a-1],[`exit`,c,t]]),o=kX(o,e.slice(a+1)),o=kX(o,[[`exit`,s,t]]),OX(e,i,e.length,o),e}function yQ(e,t,n){let r=this,i=r._labelStarts,a,o;if(i){for(;i.length>0&&i[i.length-1]._balanced;)i.pop();a=i[i.length-1]}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(FX(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(mQ,u,o?u:d)(t):t===91?e.attempt(hQ,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(gQ,u,d)(t)}function u(e){return i.pop(),t(e)}function d(e){return a._balanced=!0,n(e)}}function bQ(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return WX(t)?JZ(e,a)(t):a(t)}function a(t){return t===41?u(t):GZ(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return WX(t)?JZ(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?qZ(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return WX(t)?JZ(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function xQ(e,t,n){let r=this;return i;function i(t){return KZ.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(FX(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function SQ(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var CQ={name:`labelStartImage`,resolveAll:pQ.resolveAll,tokenize:wQ};function wQ(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),o}function o(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelImage`),s):n(t)}function s(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var TQ={name:`labelStartLink`,resolveAll:pQ.resolveAll,tokenize:EQ};function EQ(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelLink`),o}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var DQ={name:`lineEnding`,tokenize:OQ};function OQ(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),XX(e,t,`linePrefix`)}}var kQ={name:`thematicBreak`,tokenize:AQ};function AQ(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||UX(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),GX(t)?XX(e,s,`whitespace`)(t):s(t))}}var jQ={continuation:{tokenize:FQ},exit:LQ,name:`list`,tokenize:PQ},MQ={partial:!0,tokenize:RQ},NQ={partial:!0,tokenize:IQ};function PQ(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:BX(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(kQ,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return BX(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(mZ,r.interrupt?n:u,e.attempt(MQ,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return GX(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function FQ(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(mZ,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,XX(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!GX(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(NQ,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,XX(e,e.attempt(jQ,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function IQ(e,t,n){let r=this;return XX(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function LQ(e){e.exit(this.containerState.type)}function RQ(e,t,n){let r=this;return XX(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!GX(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var zQ={name:`setextUnderline`,resolveTo:BQ,tokenize:VQ};function BQ(e,t){let n=new eZ,r=e.length,i,a,o;for(;r--;)if(e[r][0]===`enter`){if(e[r][1].type===`content`){i=r;break}e[r][1].type===`paragraph`&&(a=r)}else e[r][1].type===`content`&&n.add(r,1,[]),!o&&e[r][1].type===`definition`&&(o=r);let s={type:`setextHeading`,start:E({},e[i][1].start),end:E({},e[e.length-1][1].end)};return e[a][1].type=`setextHeadingText`,o?(n.add(a,0,[[`enter`,s,t]]),n.add(o+1,0,[[`exit`,e[i][1],t]]),e[i][1].end=E({},e[o][1].end)):e[i][1]=s,n.add(e.length,0,[[`exit`,s,t]]),n.consume(e),e}function VQ(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),GX(t)?XX(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||UX(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var HQ={tokenize:UQ};function UQ(e){let t=this,n=e.attempt(mZ,r,e.attempt(this.parser.constructs.flowInitial,i,XX(e,e.attempt(this.parser.constructs.flow,i,e.attempt(BZ,i)),`linePrefix`)));return n;function r(r){if(r===null)e.consume(r);else return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null)e.consume(r);else return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var WQ={resolveAll:JQ()},GQ=qQ(`string`),KQ=qQ(`text`);function qQ(e){return{resolveAll:JQ(e===`text`?YQ:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null)t.consume(e);else return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function JQ(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):t[r]&&t[r][1].type===`data`||(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function YQ(e,t){let n=new eZ,r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type===`lineEnding`)&&e[r-1][1].type===`data`){let i=e[r-1][1],a=t.sliceStream(i),o=a.length,s=-1,c=0,l;for(;o--;){let e=a[o];if(typeof e==`string`){for(s=e.length;e.charCodeAt(s-1)===32;)c++,s--;if(s)break;s=-1}else if(e===-2)l=!0,c++;else if(e!==-1){o++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(c=0),c){let a={type:r===e.length||l||c<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:o?s:i.start._bufferIndex+s,_index:i.start._index+o,line:i.end.line,column:i.end.column-c,offset:i.end.offset-c},end:E({},i.end)};i.end=E({},a.start),i.start.offset===i.end.offset?Object.assign(i,a):n.add(r,0,[[`enter`,a,t],[`exit`,a,t]])}r++}return n.consume(e),e}var XQ=d({attentionMarkers:()=>i$,contentInitial:()=>QQ,disable:()=>a$,document:()=>ZQ,flow:()=>e$,flowInitial:()=>$Q,insideSpan:()=>r$,string:()=>t$,text:()=>n$}),ZQ={42:jQ,43:jQ,45:jQ,48:jQ,49:jQ,50:jQ,51:jQ,52:jQ,53:jQ,54:jQ,55:jQ,56:jQ,57:jQ,62:gZ},QQ={91:YZ},$Q={[-2]:OZ,[-1]:OZ,32:OZ},e$={35:tQ,42:kQ,45:[zQ,kQ],60:oQ,61:zQ,95:kQ,96:EZ,126:EZ},t$={38:SZ,92:bZ},n$={[-5]:DQ,[-4]:DQ,[-3]:DQ,33:CQ,38:SZ,42:cZ,60:[fZ,dQ],91:TQ,92:[$Z,bZ],93:pQ,95:cZ,96:MZ},r$={null:[cZ,WQ]},i$={null:[42,95]},a$={null:[]};function o$(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=kX(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=sZ(a,l.events,l),l.events):[]}function f(e,t){return c$(p(e),t)}function p(e){return s$(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){for(;r._index<o.length;){let e=o[r._index];if(typeof e==`string`){let t=r._index;for(r._bufferIndex<0&&(r._bufferIndex=0);r._index===t&&r._bufferIndex<e.length;)_(e.charCodeAt(r._bufferIndex))}else _(e)}}function _(e){u=u(e)}function v(e){UX(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&OX(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function s$(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function c$(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
62
+ `;break;case-3:o=`\r
63
+ `;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function l$(e){let t={constructs:jX([XQ,...(e||{}).extensions||[]]),content:n(QX),defined:[],document:n(nZ),flow:n(HQ),lazy:{},string:n(GQ),text:n(KQ)};return t;function n(e){return n;function n(n){return o$(t,e,n)}}}function u$(e){for(;!RZ(e););return e}var d$=/[\0\t\n\r]/g;function f$(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i));let s=[],c=0;for(t=``,n&&(i.charCodeAt(0)===65279&&c++,n=void 0);c<i.length;){d$.lastIndex=c;let n=d$.exec(i),a=n&&n.index!==void 0?n.index:i.length,o=i.charCodeAt(a);if(!n){t=i.slice(c);break}if(o===10&&c===a&&r)s.push(-3),r=void 0;else switch(r&&(s.push(-5),r=void 0),c<a&&(s.push(i.slice(c,a)),e+=a-c),o){case 0:s.push(65533),e++;break;case 9:{let t=Math.ceil(e/4)*4;for(s.push(-2);e++<t;)s.push(-1);break}case 10:s.push(-4),e=1;break;default:r=!0,e=1}c=a+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var p$=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function m$(e){return e.replace(p$,h$)}function h$(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return PX(n.slice(t?2:1),t?16:10)}return DX(n)||e}var g$={}.hasOwnProperty;function _$(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),v$(n)(u$(l$(n).document().write(f$()(e,t,!0))))}function v$(e){let t={afterExit:[],beforeEnter:[],transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:o(fe),autolinkProtocol:D,autolinkEmail:D,atxHeading:o(ce),blockQuote:o(re),characterEscape:D,characterReference:D,codeFenced:o(ie),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:o(ie,s),codeText:o(ae,s),codeTextData:D,data:D,codeFlowValue:D,definition:o(oe),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:o(se),hardBreakEscape:o(le),hardBreakTrailing:o(le),htmlFlow:o(ue,s),htmlFlowData:D,htmlText:o(ue,s),htmlTextData:D,image:o(de),label:s,link:o(fe),listItem:o(me),listItemValue:p,listOrdered:o(pe,f),listUnordered:o(pe),paragraph:o(he),reference:ee,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(ce),strong:o(ge),thematicBreak:o(ve)},exit:{atxHeading:l(),atxHeadingSequence:S,autolink:l(),autolinkEmail:ne,autolinkProtocol:W,blockQuote:l(),characterEscapeValue:O,characterReferenceMarkerHexadecimal:te,characterReferenceMarkerNumeric:te,characterReferenceValue:H,characterReference:U,codeFenced:l(_),codeFencedFence:g,codeFencedFenceInfo:m,codeFencedFenceMeta:h,codeFlowValue:O,codeIndented:l(v),codeText:l(N),codeTextData:O,data:O,definition:l(),definitionDestinationString:x,definitionLabelString:y,definitionTitleString:b,emphasis:l(),hardBreakEscape:l(A),hardBreakTrailing:l(A),htmlFlow:l(j),htmlFlowData:O,htmlText:l(M),htmlTextData:O,image:l(F),label:L,labelText:I,lineEnding:k,link:l(P),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:V,resourceDestinationString:R,resourceTitleString:z,resource:B,setextHeading:l(T),setextHeadingLineSequence:w,setextHeadingText:C,strong:l(),thematicBreak:l()}};b$(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[],position:void 0},o={stack:[r],tokenStack:[],config:t,enter:c,exit:u,buffer:s,resume:d,data:n},l=[],f=[],p=-1;for(;++p<e.length;)f.push(e[p]),(e[p][1].type===`listOrdered`||e[p][1].type===`listUnordered`)&&(e[p][0]===`enter`?l.push(f.length-1):a(f,l.pop()));for(e=f,p=-1;++p<e.length;){let n=t[e[p][0]];e[p][0]===`enter`&&t.beforeEnter.length>0&&i(t.beforeEnter,E(E({},o),{},{sliceSerialize:e[p][2].sliceSerialize}),e[p][1]),g$.call(n,e[p][1].type)&&n[e[p][1].type].call(E(E({},o),{},{sliceSerialize:e[p][2].sliceSerialize}),e[p][1]),e[p][0]===`exit`&&t.afterExit.length>0&&i(t.afterExit,E(E({},o),{},{sliceSerialize:e[p][2].sliceSerialize}),e[p][1])}if(o.tokenStack.length>0){let e=o.tokenStack[o.tokenStack.length-1];(e[1]||S$).call(o,void 0,e[0])}for(r.position={start:y$(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:y$(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},p=-1;++p<t.transforms.length;)r=t.transforms[p](r)||r;return r}function i(e,t,n){let r=-1;for(;++r<e.length;)e[r].call(t,n)}function a(e,t){let n=e.length-1,r=t-1,i=-1,a=!1,o,s,c,l,u=[];for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let n=r;for(s=void 0;n--;){let t=e[n];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=n}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),u.push({at:s||r,event:[`exit`,o,t[2]]})}if(t[1].type===`listItemPrefix`){let e={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=e,u.push({at:r,event:[`enter`,e,t[2]]}),c=void 0,l=!0}}}let d=e.splice(t),f=0;for(r=-1;++r<d.length;){for(;f<u.length&&u[f].at===t+r;)e.push(u[f++].event);e.push(d[r])}e[t][1]._spread=a}function o(e,t){return n;function n(n){c.call(this,e(n),n),t&&t.call(this,n)}}function s(){this.stack.push({type:`fragment`,children:[]})}function c(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:y$(t.start),end:void 0}}function l(e){return t;function t(t){e&&e.call(this,t),u.call(this,t)}}function u(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(!r)throw Error("Cannot close `"+e.type+"` ("+zY({start:e.start,end:e.end})+`): it’s not open`);r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||S$).call(this,e,r[0])),n.position.end=y$(e.end)}function d(){return SX(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function h(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function v(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function y(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=FX(this.sliceSerialize(e)).toLowerCase()}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function x(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function S(e){let t=this.stack[this.stack.length-1];t.depth||(t.depth=this.sliceSerialize(e).length)}function C(){this.data.setextHeadingSlurpLineEnding=!0}function w(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function D(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];n&&n.type===`text`||(n=_e(),n.position={start:y$(e.start),end:void 0},t.push(n)),this.stack.push(n)}function O(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=y$(e.end)}function k(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=y$(e.end),this.data.atHardBreak=void 0}else!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(D.call(this,e),O.call(this,e))}function A(){this.data.atHardBreak=!0}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function N(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function P(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function F(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function I(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=m$(t),n.identifier=FX(t).toLowerCase()}function L(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function R(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function z(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function B(){this.data.inReference=void 0}function ee(){this.data.referenceType=`collapsed`}function V(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=FX(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function te(e){this.data.characterReferenceType=e.type}function H(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=PX(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=DX(t);let i=this.stack[this.stack.length-1];i.value+=r}function U(e){let t=this.stack.pop();t.position.end=y$(e.end)}function W(e){O.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function ne(e){O.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function re(){return{type:`blockquote`,children:[],position:void 0}}function ie(){return{type:`code`,lang:null,meta:null,value:``,position:void 0}}function ae(){return{type:`inlineCode`,value:``,position:void 0}}function oe(){return{type:`definition`,identifier:``,label:null,title:null,url:``,position:void 0}}function se(){return{type:`emphasis`,children:[],position:void 0}}function ce(){return{type:`heading`,depth:0,children:[],position:void 0}}function le(){return{type:`break`,position:void 0}}function ue(){return{type:`html`,value:``,position:void 0}}function de(){return{type:`image`,title:null,url:``,alt:null,position:void 0}}function fe(){return{type:`link`,title:null,url:``,children:[],position:void 0}}function pe(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[],position:void 0}}function me(e){return{type:`listItem`,spread:e._spread,checked:null,children:[],position:void 0}}function he(){return{type:`paragraph`,children:[],position:void 0}}function ge(){return{type:`strong`,children:[],position:void 0}}function _e(){return{type:`text`,value:``,position:void 0}}function ve(){return{type:`thematicBreak`,position:void 0}}}function y$(e){return{line:e.line,column:e.column,offset:e.offset}}function b$(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?b$(e,r):x$(e,r)}}function x$(e,t){let n;for(n in t)if(g$.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`afterExit`:case`beforeEnter`:{let r=t[n];r&&e[n].push(r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function S$(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+zY({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+zY({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+zY({start:t.start,end:t.end})+`) is still open`)}function C$(e){let t=this;t.parser=n;function n(n){return _$(n,E(E(E({},t.data(`settings`)),e),{},{extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]}))}}function w$(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function T$(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
64
+ `}]}function E$(e,t){let n=t.value?t.value+`
65
+ `:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function D$(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function O$(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function k$(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=YX(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function A$(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function j$(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function M$(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function N$(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return M$(e,t);let i={src:YX(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function P$(e,t){let n={src:YX(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function F$(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function I$(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return M$(e,t);let i={href:YX(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function L$(e,t){let n={href:YX(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function R$(e,t,n){let r=e.all(t),i=n?z$(n):B$(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
66
+ `}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
67
+ `});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function z$(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=B$(n[r])}return t}function B$(e){let t=e.spread;return t==null?e.children.length>1:t}function V$(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function H$(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function U$(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function W$(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function G$(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=IY(t.children[1]),o=FY(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function K$(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function q$(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var J$=9,Y$=32;function X$(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(Z$(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(Z$(t.slice(i),i>0,!1)),a.join(``)}function Z$(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===J$||t===Y$;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===J$||t===Y$;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function Q$(e,t){let n={type:`text`,value:X$(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function $$(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var e1={blockquote:w$,break:T$,code:E$,delete:D$,emphasis:O$,footnoteReference:k$,heading:A$,html:j$,imageReference:N$,image:P$,inlineCode:F$,linkReference:I$,link:L$,listItem:R$,list:V$,paragraph:H$,root:U$,strong:W$,table:G$,tableCell:q$,tableRow:K$,text:Q$,thematicBreak:$$,toml:t1,yaml:t1,definition:t1,footnoteDefinition:t1};function t1(){}var{defineProperty:n1}=Object,r1=typeof self==`object`?self:globalThis,i1=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new r1[e](t)},a1=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o){let i=r(t),a=r(n);i===`__proto__`?n1(e,i,{value:a,configurable:!0,enumerable:!0,writable:!0}):e[i]=a}return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(typeof r1[e]==`function`?i1(e,t):Error(t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}case`-0`:return-0}return n(i1(a,o),i)};return r},o1=e=>a1(new Map,e)(0),s1=``,{toString:c1}={},{keys:l1,is:u1}=Object,d1=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=c1.call(e).slice(8,-1);switch(n){case`Array`:return[1,s1];case`Object`:return[2,s1];case`Date`:return[3,s1];case`RegExp`:return[4,s1];case`Map`:return[5,s1];case`Set`:return[6,s1];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:e instanceof Error?[7,e.name||`Error`]:[2,n]},f1=([e,t])=>e===0&&(t===`function`||t===`symbol`),p1=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=o=>{if(n.has(o))return n.get(o);let[s,c]=d1(o);switch(s){case 0:{let t=o;switch(c){case`bigint`:s=8,t=o.toString();break;case`number`:if(!o&&u1(o,-0))return r.push([`-0`])-1;break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+c);t=null;break;case`undefined`:return i([-1],o)}return i([s,t],o)}case 1:{if(c){let e=o;return c===`DataView`?e=new Uint8Array(o.buffer):c===`ArrayBuffer`&&(e=new Uint8Array(o)),i([c,[...e]],o)}let e=[],t=i([s,e],o);for(let t of o)e.push(a(t));return t}case 2:{if(c)switch(c){case`BigInt`:return i([c,o.toString()],o);case`Boolean`:case`Number`:case`String`:return i([c,o.valueOf()],o)}if(t&&`toJSON`in o)return a(o.toJSON());let n=[],r=i([s,n],o);for(let t of l1(o))(e||!f1(d1(o[t])))&&n.push([a(t),a(o[t])]);return r}case 3:return i([s,isNaN(o.getTime())?s1:o.toISOString()],o);case 4:{let{source:e,flags:t}=o;return i([s,{source:e,flags:t}],o)}case 5:{let t=[],n=i([s,t],o);for(let[n,r]of o)(e||!(f1(d1(n))||f1(d1(r))))&&t.push([a(n),a(r)]);return n}case 6:{let t=[],n=i([s,t],o);for(let n of o)(e||!f1(d1(n)))&&t.push(a(n));return n}}let{message:l}=o;return i([s,{name:c,message:l}],o)};return a},m1=(e,{json:t,lossy:n}={})=>{let r=[];return p1(!(t||n),!!t,new Map,r)(e),r},h1=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?o1(m1(e,t)):structuredClone(e):(e,t)=>o1(m1(e,t));function g1(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function _1(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function v1(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||g1,r=e.options.footnoteBackLabel||_1,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=YX(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:E(E({},h1(o)),{},{id:`footnote-label`}),children:[{type:`text`,value:i}]},{type:`text`,value:`
68
+ `},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
69
+ `}]}}var y1=(function(e){if(e==null)return w1;if(typeof e==`function`)return C1(e);if(typeof e==`object`)return Array.isArray(e)?b1(e):x1(e);if(typeof e==`string`)return S1(e);throw Error(`Expected function, string, or object as test`)});function b1(e){let t=[],n=-1;for(;++n<e.length;)t[n]=y1(e[n]);return C1(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function x1(e){let t=e;return C1(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function S1(e){return C1(t);function t(t){return t&&t.type===e}}function C1(e){return t;function t(t,n,r){return!!(T1(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function w1(){return!0}function T1(e){return typeof e==`object`&&!!e&&`type`in e}function E1(e){return e}var D1=[],O1=`skip`;function k1(e,t,n,r){if(!e||typeof e!=`object`)throw Error("Unexpected value `"+e+"` for `tree`, expected node");let i=!0,a,o,s,c;if(typeof n==`function`||n&&typeof n==`object`?(a=t,o=n,r&&(i=!1)):(o=t,n&&(i=!1)),typeof o==`function`)s=o;else if(o&&typeof o==`object`){if(o.enter!==null&&o.enter!==void 0){if(typeof o.enter==`function`)s=o.enter;else throw Error("Unexpected value `"+o.enter+"` for `visitors.enter`, expected optional visitor")}if(typeof o.exit==`function`)c=o.exit;else throw Error("Unexpected value `"+o.exit+"` for `visitors.exit`, expected visitor (pass a visitor directly if you only want an enter visitor)")}else throw Error("Unexpected value `"+o+"` for `enter` or `visitors`, expected visitor or object with visitors");let l=y1(a),u=i?1:-1;d(e,void 0,[])();function d(e,t,n){let r=e&&typeof e==`object`?e:{};if(typeof r.type==`string`){let t=typeof r.tagName==`string`?r.tagName:typeof r.name==`string`?r.name:void 0;Object.defineProperty(o,"name",{value:`node (`+E1(e.type+(t?`<`+t+`>`:``))+`)`})}return o;function o(){let r=!a||l(e,t,n[n.length-1]||void 0),o=D1;if(s&&r&&(o=A1(s(e,n,t)),o[0]===!1))return o;if(`children`in e&&e.children){let t=e;if(t.children&&o[0]!==`skip`){let e=(i?-1:t.children.length)+u,r=[...n,t];for(;e>-1&&e<t.children.length;){let n=t.children[e],i=d(n,e,r)();if(i[0]===!1)return i;e=typeof i[1]==`number`?i[1]:e+u}}}if(c&&r){let r=A1(c(e,n,t));if(r[0]===`skip`)throw Error("Unexpected value `"+r[0]+"` from `exit`, expected `CONTINUE`, `EXIT`, index, or nothing");if(r[0]===!1||typeof r[1]==`number`)return r}return o}}}function A1(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?D1:[e]}function j1(e,t,n,r){let i,a,o;typeof n==`function`||n&&typeof n==`object`?(i=t,a=n,o=r):(a=t,o=n),typeof a==`function`?k1(e,i,N1(a),o):k1(e,i,M1(a),o)}function M1(e){return!e||typeof e!=`object`?e:{enter:typeof e.enter==`function`?N1(e.enter):e.enter,exit:typeof e.exit==`function`?N1(e.exit):e.exit}}function N1(e){return t;function t(t,n,r){return e(t,r,n[n.length-1])}}var P1=[`children`],F1={}.hasOwnProperty,I1={};function L1(e,t){let n=t||I1,r=new Map,i=new Map,a={all:s,applyData:z1,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:E(E({},e1),n.handlers),one:o,options:n,patch:R1,wrap:V1};return j1(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(F1.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t}=e,n=h1(W(e,P1));return n.children=a.all(e),n}return h1(e)}return(a.options.unknownHandler||B1)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=H1(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=H1(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function R1(e,t){e.position&&(t.position=RY(e))}function z1(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,h1(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function B1(e,t){let n=t.data||{},r=`value`in t&&!(F1.call(n,`hProperties`)||F1.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function V1(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
70
+ `});++r<e.length;)r&&n.push({type:`text`,value:`
71
+ `}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
72
+ `}),n}function H1(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function U1(e,t){let n=L1(e,t),r=n.one(e,void 0),i=v1(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
73
+ `},i)),a}function W1(e,t){return e&&`run`in e?function(){var n=w(function*(n,r){let i=U1(n,E({file:r},t));yield e.run(i,r)});return function(e,t){return n.apply(this,arguments)}}():function(n,r){return U1(n,E({file:r},e||t))}}function G1(e){if(e)throw e}var K1=u(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function q1(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function J1(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a)r(a);else{for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?Y1(s,i)(...o):r(null,...o)}}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function Y1(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var X1={basename:Z1,dirname:Q1,extname:$1,join:e0,sep:`/`};function Z1(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);r0(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function Q1(e){if(r0(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function $1(e){r0(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}}else n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function e0(...e){let t=-1,n;for(;++t<e.length;)r0(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:t0(n)}function t0(e){r0(e);let t=e.codePointAt(0)===47,n=n0(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function n0(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(i!==o-1&&a!==1){if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1}i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function r0(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var i0={cwd:a0};function a0(){return`/`}function o0(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function s0(e){if(typeof e==`string`)e=new URL(e);else if(!o0(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return c0(e)}function c0(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var l0=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],u0=class{constructor(e){let t;t=e?o0(e)?{path:e}:typeof e==`string`||m0(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:i0.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<l0.length;){let e=l0[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)l0.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?X1.basename(this.path):void 0}set basename(e){f0(e,`basename`),d0(e,`basename`),this.path=X1.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?X1.dirname(this.path):void 0}set dirname(e){p0(this.basename,`dirname`),this.path=X1.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?X1.extname(this.path):void 0}set extname(e){if(d0(e,`extname`),p0(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=X1.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){o0(e)&&(e=s0(e)),f0(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?X1.basename(this.path,this.extname):void 0}set stem(e){f0(e,`stem`),d0(e,`stem`),this.path=X1.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new UY(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function d0(e,t){if(e&&e.includes(X1.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+X1.sep+"`")}function f0(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function p0(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function m0(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var h0=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),g0=m(K1(),1),_0={}.hasOwnProperty,v0=new class e extends h0{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=J1()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,g0.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(x0(`data`,this.frozen),this.namespace[e]=t,this):_0.call(this.namespace,e)&&this.namespace[e]||void 0:e?(x0(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=w0(e),n=this.parser||this.Parser;return y0(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),y0(`process`,this.parser||this.Parser),b0(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=w0(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);E0(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),y0(`processSync`,this.parser||this.Parser),b0(`processSync`,this.compiler||this.Compiler),this.process(e,r),C0(`processSync`,`process`,t),n;function r(e,r){t=!0,G1(e),n=r}}run(e,t,n){S0(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=w0(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),C0(`runSync`,`run`,n),r;function i(e,t){G1(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=w0(t),r=this.compiler||this.Compiler;return b0(`stringify`,r),S0(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(x0(`use`,this.frozen),e!=null){if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`")}return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`){if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e)}else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,g0.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null){if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];q1(o)&&q1(r)&&(r=(0,g0.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function y0(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function b0(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function x0(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function S0(e){if(!q1(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function C0(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function w0(e){return T0(e)?e:new u0(e)}function T0(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function E0(e){return typeof e==`string`||D0(e)}function D0(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var O0=[],k0={allowDangerousHtml:!0},A0=/^(https?|ircs?|mailto|xmpp)$/i,j0=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function M0(e){let t=N0(e),n=P0(e);return F0(t.runSync(t.parse(n),n),e)}function N0(e){let t=e.rehypePlugins||O0,n=e.remarkPlugins||O0,r=e.remarkRehypeOptions?E(E({},e.remarkRehypeOptions),k0):k0;return v0().use(C$).use(n).use(W1,r).use(t)}function P0(e){let t=e.children||``,n=new u0;return typeof t==`string`?n.value=t:``+t,n}function F0(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||I0;for(let e of j0)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return j1(e,l),ZY(e,{Fragment:J.Fragment,components:i,ignoreInvalidStyle:!0,jsx:J.jsx,jsxs:J.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in bX)if(Object.hasOwn(bX,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=bX[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function I0(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||A0.test(e.slice(0,t))?e:``}var L0=[`text`],R0=[`text`],z0=[`components`,`componentsByLanguage`,`smooth`,`defer`,`preprocess`],B0=[`pre`,`code`,`SyntaxHighlighter`,`CodeHeader`],V0=[`className`,`containerProps`,`containerComponent`],{useSmooth:H0,useSmoothStatus:U0,withSmoothContextProvider:W0}=XP,G0=(0,h.createContext)(null),K0=e=>{let t=(0,h.useContext)(G0);return(0,J.jsx)(AJ,E(E({},t),e))},q0=e=>{let{components:t}=(0,h.useContext)(G0);return(0,J.jsx)(cJ,E(E({},e),{},{fallbackPre:t.Pre}))},J0=(0,h.memo)(e=>{let{text:t}=e,n=W(e,L0);return(0,J.jsx)(M0,E(E({},n),{},{children:t}))});J0.displayName=`MarkdownRenderer`;var Y0=e=>{let{text:t}=e,n=W(e,R0),r=(0,h.useDeferredValue)(t);return(0,J.jsx)(J0,E({text:r},n))},X0=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Z0=(e,t,n=1)=>{if(Object.is(e,t))return!0;if(n<=0)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Z0(e[r],t[r],n-1))return!1;return!0}if(X0(e)&&X0(t)){let r=Object.keys(e);return r.length===Object.keys(t).length&&r.every(r=>Object.hasOwn(t,r)&&Z0(e[r],t[r],n-1))}return!1};function Q0(e,t){let n=(0,h.useRef)(e);return Z0(e,n.current,t)||(n.current=e),n.current}function $0(e){let t=(0,h.useRef)(e),n=(e,t)=>e[t],r=Object.keys(e),i=Object.keys(t.current);return r.length===i.length&&r.every(r=>Object.hasOwn(t.current,r)&&Z0(n(e,r),n(t.current,r)))||(t.current=e),t.current}var e2=e=>{let{components:t,componentsByLanguage:n,smooth:r=!0,defer:i=!1,preprocess:a}=e,o=W(e,z0),{text:s}=H0(gM(),r),c=(0,h.useMemo)(()=>a?a(s):s,[a,s]),{pre:l=dJ,code:u=fJ,SyntaxHighlighter:d=pJ,CodeHeader:f=mJ}=t==null?{}:t,p=(0,h.useMemo)(()=>({Pre:l,Code:u,SyntaxHighlighter:d,CodeHeader:f}),[l,u,d,f]),m=Q0((0,h.useMemo)(()=>({components:p,componentsByLanguage:n}),[p,n]),3),g=$0((0,h.useMemo)(()=>{let e=t==null?{}:t,{pre:n,code:r,SyntaxHighlighter:i,CodeHeader:a}=e;return E(E({},W(e,B0)),{},{pre:q0,code:K0})},[t])),_=i?Y0:J0,v=$0(o);return(0,J.jsx)(G0.Provider,{value:m,children:(0,J.jsx)(_,E({text:c,components:g},v))})},t2=(0,h.forwardRef)((e,t)=>{let{className:n,containerProps:r,containerComponent:i=`div`}=e,a=W(e,V0),o=U0();return(0,J.jsx)(i,E(E({"data-status":o.type},r),{},{className:(0,_J.default)(n,r==null?void 0:r.className),ref:t,children:(0,J.jsx)(e2,E({},a))}))});t2.displayName=`MarkdownTextPrimitive`;var n2=W0(t2);function r2(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function i2(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function a2(e,t,n){let r=y1((n||{}).ignore||[]),i=o2(t),a=-1;for(;++a<i.length;)k1(e,o);function o(e,t,n){if(e.type===`text`&&typeof n==`number`)return s(e,t,n);if(r(e,n,t[t.length-1]))return O1}function s(e,t,n){let r=t[t.length-1],o=i[a][0],s=i[a][1],c=0,l=!1,u=[];o.lastIndex=0;let d=o.exec(e.value);for(;d;){let n=d.index,r={index:d.index,input:d.input,stack:[...t,e]},i=s(...d,r);if(typeof i==`string`&&(i=i.length>0?{type:`text`,value:i}:void 0),i===!1)o.lastIndex=n+1;else{if(c!==n&&f({type:`text`,value:e.value.slice(c,n)}),Array.isArray(i))for(let e of i)f(e);else i&&f(i);c=n+d[0].length,l=!0}if(!o.global)break;d=o.exec(e.value)}return l?(c<e.value.length&&f({type:`text`,value:e.value.slice(c)}),r.children.splice(n,1,...u)):u=[e],n+u.length;function f(e){let t=u[u.length-1];t&&t.type===`text`&&e.type===`text`?t.value+=e.value:u.push(e)}}}function o2(e){if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let t=[],n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([s2(e[0]),c2(e[1])])}return t}function s2(e){return typeof e==`string`?new RegExp(i2(e),`g`):e}function c2(e){return typeof e==`function`?e:function(){return e}}var l2=`phrasing`,u2=[`autolink`,`link`,`image`,`label`];function d2(){return{transforms:[y2],enter:{literalAutolink:p2,literalAutolinkEmail:m2,literalAutolinkHttp:m2,literalAutolinkWww:m2},exit:{literalAutolink:v2,literalAutolinkEmail:_2,literalAutolinkHttp:h2,literalAutolinkWww:g2}}}function f2(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:l2,notInConstruct:u2},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:l2,notInConstruct:u2},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:l2,notInConstruct:u2}]}}function p2(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function m2(e){this.config.enter.autolinkProtocol.call(this,e)}function h2(e){this.config.exit.autolinkProtocol.call(this,e)}function g2(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function _2(e){this.config.exit.autolinkEmail.call(this,e)}function v2(e){this.exit(e)}function y2(e){a2(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,b2],[RegExp(`(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)`,`gu`),x2]],{ignore:[`link`,`linkReference`]})}function b2(e,t,n,r,i){let a=``;if(!w2(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!S2(n)))return!1;let o=C2(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function x2(e,t,n,r){return!w2(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function S2(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function C2(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=r2(e,`(`),a=r2(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function w2(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||qX(n)||KX(n))&&(!t||n!==47)}P2.peek=N2;function T2(){this.buffer()}function E2(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function D2(){this.buffer()}function O2(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function k2(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=FX(this.sliceSerialize(e)).toLowerCase(),n.label=t}function A2(e){this.exit(e)}function j2(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=FX(this.sliceSerialize(e)).toLowerCase(),n.label=t}function M2(e){this.exit(e)}function N2(){return`[`}function P2(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function F2(){return{enter:{gfmFootnoteCallString:T2,gfmFootnoteCall:E2,gfmFootnoteDefinitionLabelString:D2,gfmFootnoteDefinition:O2},exit:{gfmFootnoteCallString:k2,gfmFootnoteCall:A2,gfmFootnoteDefinitionLabelString:j2,gfmFootnoteDefinition:M2}}}function I2(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:P2},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
74
+ `:` `)+r.indentLines(r.containerFlow(e,a.current()),t?R2:L2))),s(),o}}function L2(e,t,n){return t===0?e:R2(e,t,n)}function R2(e,t,n){return(n?``:` `)+e}var z2=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];W2.attention=G2,W2.peek=K2;function B2(){return{canContainEols:[`delete`],enter:{strikethrough:H2},exit:{strikethrough:U2}}}function V2(){return{handlers:{delete:W2},unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:z2}]}}function H2(e){this.enter({type:`delete`,children:[],position:void 0},e)}function U2(e){this.exit(e)}function W2(e,t,n,r){let i=n.createTracker(r),a=n.stack.includes(`strikethrough`)?`~`:`~~`,o=n.enter(`strikethrough`),s=i.move(a);return s+=n.containerPhrasing(e,E(E({},i.current()),{},{before:s,after:`~`})),s+=i.move(a),o(),s}function G2(){return{construct:`strikethrough`,markers:[`~`],sizes:[2,1]}}function K2(){return`~`}function q2(e){return e.length}function J2(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||q2,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=Y2(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=X2(r[d]);else{let e=X2(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u],r=n.fillRows===!1?Math.max(1,o[u===1?0:u].length):l;d=-1;let i=[];for(;++d<r;){let o=e[d]||``,s=``,l=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];if(n===114)s=` `.repeat(e);else if(n===99){let t=e/2;e%2?(s=` `.repeat(t+.5),l=` `.repeat(t-.5)):(s=` `.repeat(t),l=s)}else l=` `.repeat(e)}n.delimiterStart!==!1&&!d&&i.push(`|`),n.padding===!1||n.alignDelimiters===!1&&o===``||n.delimiterStart===!1&&!d||i.push(` `),n.alignDelimiters!==!1&&i.push(s),i.push(o),n.alignDelimiters!==!1&&i.push(l),n.padding!==!1&&i.push(` `),(n.delimiterEnd!==!1||d!==r-1)&&i.push(`|`)}m.push(n.delimiterEnd===!1?i.join(``).replace(/ +$/,``):i.join(``))}return m.join(`
75
+ `)}function Y2(e){return e==null?``:String(e)}function X2(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}var Z2=y1([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function Q2(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),$2);return i(),o}function $2(e,t,n){return`>`+(n?``:` `)+e}function e4(e,t){return t4(e,t.inConstruct,!0)&&!t4(e,t.notInConstruct,!1)}function t4(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function n4(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;){let e=n.unsafe[i];if(e.character===`
76
+ `&&!e.before&&!e.after&&e4(n.stack,e))return/[\t ]/.test(r.before)?``:` `}return`\\
77
+ `}function r4(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function i4(e,t){return!(t.options.fences!==!1||!e.value||e.lang||!/[^\n\r ]/.test(e.value)||/^[\t ]*(?:[\n\r]|$)|(?:^|[\n\r])[\t ]*$/.test(e.value))}function a4(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function o4(e,t,n,r){let i=a4(n),a=e.value||``;if(i4(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,s4);return e(),t}let o=n.createTracker(r),s=i.repeat(Math.max(r4(a,i)+1,3)),c=n.enter(`codeFenced`),l=i==="`"?`GraveAccent`:`Tilde`,u=o.move(s);if(e.lang){let t=n.enter(`codeFencedLang${l}`);u+=o.move(n.safe(e.lang,E({before:u,after:` `,encode:["`"]},o.current()))),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${l}`);u+=o.move(` `),u+=o.move(n.safe(e.meta,E({before:u,after:`
78
+ `,encode:["`"]},o.current()))),t()}return u+=o.move(`
79
+ `),a&&(u+=o.move(a+`
80
+ `)),u+=o.move(s),c(),u}function s4(e,t,n){return(n?``:` `)+e}function c4(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function l4(e,t,n,r){let i=c4(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),E({before:l,after:`]`},c.current()))),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,E({before:l,after:`>`},c.current()))),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,E({before:l,after:e.title?` `:`
81
+ `},c.current())))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,E({before:l,after:i},c.current()))),l+=c.move(i),s()),o(),l}function u4(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function d4(e){let t=e.codePointAt(0);return t===void 0?``:String.fromCodePoint(t)}function f4(e){let t=e.codePointAt(e.length-2);return t!==void 0&&t>65535?e.slice(-2):e.slice(-1)}function p4(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function m4(e,t,n){let r=oZ(e),i=oZ(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function h4(e){if(e.charCodeAt(0)!==60)return;let t=e.charCodeAt(1);if(t===33){let t=e.charCodeAt(2);return t===45?2:t===91?5:IX(t)?4:void 0}if(t===63)return 3;let n=t===47,r=n?2:1,i=r,a=e.charCodeAt(i);if(!IX(a))return;for(;a===45||LX(a);)a=e.charCodeAt(++i);let o=e.slice(r,i).toLowerCase();return!n&&a!==47&&aQ.includes(o)?1:iQ.includes(o)?6:7}var g4=new Map([[`*`,!1],[`_`,!0]]);function _4(e,t,n){let r=new Set;for(let i of e){let e=n.get(i);if(e&&i.attention&&t.some(e=>e.attention===i.attention))for(let t of e.tokens)r.add(t.attention)}let i=[];for(let t of e)t.attention&&r.delete(t.attention)&&i.push(t.attention);return i.reverse(),i}function v4(e,t,n){let r=[],i=new Map,a=new Map,o=0;for(;o<e.length;){if(!e[o].attention){o++;continue}let s=e[o].value.charAt(0),c=g4.get(s),l=o+1;for(;l<e.length&&e[l].attention&&e[l].value.charAt(0)===s;)l++;let u=o?e[o-1].value:t,d=oZ(u.charCodeAt(u.length-1)),f=oZ((l<e.length?e[l].value:n).charCodeAt(0)),p=!f||f===2&&!!d,m=!d||d===2&&!!f,h={tokens:e.slice(o,l),markers:[],start:0,end:0,open:c?p&&(!!d||!m):p,close:c?m&&(!!f||!p):m,split:c!==void 0};for(let e of h.tokens){i.set(e,[...h.tokens]),a.set(e,h);let t=e.value.length;for(;t--;)h.markers.push(e)}h.end=h.markers.length,r.push(h),o=l}for(x4(r,i),o=-1;++o<e.length;){let t=i.get(e[o]);if(t)return{attention:_4(e,t,a),index:o}}}function y4(e,t){let n=e[t?0:e.length-1];if(!n||n.attention)return;let r=t?d4(n.value):f4(n.value),i=p4(r.codePointAt(0));if(t)n.value=i+n.value.slice(r.length);else{let e=n.value.slice(0,n.value.length-r.length),t=0;for(;e.charCodeAt(e.length-1-t)===92;)t++;t%2&&(e+=`\\`),n.value=e+i}}function b4(e,t,n,r,i){for(let a of n.attention){let o=t.get(a)||a.sequences[0];for(let s of a.sequences){if(s===o)continue;let c=new Map(t);c.set(a,s);let l=T4(e,c,r,i),u=v4(l,r,i);if(!u||u.index>n.index)return{chosen:c,mistake:u,tokens:l}}}}function x4(e,t){let n=new Map;for(let r of e){let e=r.tokens[0].value.charAt(0),i=n.get(e);i||(i=[],n.set(e,i));let a=r.close?i.length:0;for(;a--&&r.start<r.end;){let e=i[a],n=e.end-e.start,o=r.end-r.start;if(r.split?(e.close||r.open)&&o%3&&!((n+o)%3):n!==e.markers.length||n!==o)continue;let s=r.split?n>1&&o>1?2:1:o,c=e.markers.slice(e.end-s,e.end),l=r.markers.slice(r.start,r.start+s),u=c[0],d=l[0];if(u===c[s-1]&&u.value.length===s&&d===l[s-1]&&d.value.length===s&&u.attention===d.attention)t.delete(u),t.delete(d);else{let e=[...new Set([...c,...l])];for(let n of e){let r=t.get(n);r&&r.push(...e)}}e.end-=s,r.start+=s,e.start===e.end&&i.splice(a,1),a=i.length}r.open&&r.start<r.end&&i.push(r)}}function S4(e,t,n){if(t.length===0)throw Error("Cannot serialize `"+e+"` as attention without markers, expected one or more markers");if(n.length===0)throw Error("Cannot serialize `"+e+"` as attention without sizes, expected one or more sizes");for(let t of n)if(!Number.isSafeInteger(t)||t<1)throw Error("Cannot serialize `"+e+"` as attention with `"+t+"` as size, expected positive integer");let r=[];for(let i of t){if(i.length!==1)throw Error("Cannot serialize `"+e+"` as attention with `"+i+"` as marker, expected a single ascii character");if(!HX(i.charCodeAt(0)))throw Error("Cannot serialize `"+e+"` as attention with `"+i+"` as marker, expected ascii punctuation");for(let e of n)r.push(i.repeat(e))}return r}function C4(e,t,n){let r=t.indexStack,i=e.children||[],a=[],o=-1,s=n.before;r.push(-1);let c=t.createTracker(n);for(;++o<i.length;){let l=i[o],u;if(r[r.length-1]=o,o+1<i.length){let n=t.handle.handlers[i[o+1].type];n&&n.peek&&(n=n.peek),u=n?d4(n(i[o+1],e,t,E({before:``,after:``},c.current()))):``}else u=n.after;let d=a[a.length-1];typeof d==`string`&&(s===`\r`||s===`
82
+ `)&&l.type===`html`&&h4(l.value)!==7&&(a[a.length-1]=d.replace(/(\r?\n|\r)$/,` `),s=` `,c=t.createTracker(n),c.move(E4(a,n.before,n.after)));let f=t.handle.handlers[l.type];if(f&&f.attention){let e=w4(l,f.attention,t,c);a.push(e),s=f4(e.sequences[0])}else{let n=t.handle(l,e,t,E(E({},c.current()),{},{after:u,before:s}));if(!n)continue;c.move(n),a.push(n),s=f4(n)}}return r.pop(),a}function w4(e,t,n,r){let{construct:i,markers:a,sizes:o}=t(e,n),s=S4(e.type,a,o),c=s[0],l=n.enter(i);r.move(c);let u=C4(e,n,E(E({},r.current()),{},{before:c,after:c}));return r.move(E4(u,c,c)),r.move(c),l(),{children:u,sequences:s}}function T4(e,t,n,r){let i=[],a,o=f4(n),s=-1;for(;++s<e.length;){let n=e[s];if(typeof n==`string`){let e={value:n,attention:void 0};a&&a===d4(n)&&y4([e],!0),a=void 0,i.push(e),e.value&&(o=f4(e.value));continue}let c=t.get(n)||n.sequences[0],l=c.charAt(0),u=e[s+1],d=o,f=d4(u===void 0?r:typeof u==`string`?u:t.get(u)||u.sequences[0]),p=T4(n.children,t,c,c),m=p.length>0?p[0].value:``,h=m4(d.charCodeAt(d.length-1),m.charCodeAt(0),l);h.inside&&y4(p,!0);let g=p.length>0?f4(p[p.length-1].value):``,_=m4(f.charCodeAt(0),g.charCodeAt(g.length-1),l);_.inside&&y4(p,!1),h.outside&&d!==`
83
+ `&&d!==`\r`&&y4(i,!1),_.outside&&(a=f),i.push({value:c,attention:n},...p,{value:c,attention:n}),o=c.charAt(c.length-1)}return i}function E4(e,t,n){let r=new Map,i=T4(e,r,t,n),a=i,o=v4(a,t,n);for(;o;){let s=b4(e,r,o,t,n);if(!s){a=i;break}r=s.chosen,a=s.tokens,o=s.mistake}let s=``;for(let e of a)s+=e.value;return s}D4.attention=O4,D4.peek=k4;function D4(e,t,n,r){let i=n.enter(`phrasing`),a=E4([w4(e,O4,n,n.createTracker(r))],r.before,r.after);return i(),a}function O4(e,t){return{construct:`emphasis`,markers:u4(t)===`*`?[`*`,`_`]:[`_`,`*`],sizes:[1]}}function k4(e,t,n){return n.options.emphasis||`*`}function A4(e,t){let n=!1;return j1(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&SX(e)&&(t.options.setext||n))}function j4(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(A4(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,E(E({},a.current()),{},{before:`
84
+ `,after:`
85
+ `}));return r(),t(),o+`
86
+ `+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
87
+ `))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,E({before:`# `,after:`
88
+ `},a.current())),u=l.charCodeAt(0);return(u===9||u===32)&&(l=p4(u)+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}M4.peek=N4;function M4(e){return e.value||``}function N4(){return`<`}P4.peek=F4;function P4(e,t,n,r){let i=c4(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,E({before:l,after:`]`},c.current()))),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,E({before:l,after:`>`},c.current()))),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,E({before:l,after:e.title?` `:`)`},c.current())))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,E({before:l,after:i},c.current()))),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function F4(){return`!`}I4.peek=L4;function I4(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,E({before:c,after:`]`},s.current()));c+=s.move(l+`][`),o();let u=n.stack;n.stack=u.filter(function(e){return e!==`phrasing`}),o=n.enter(`reference`);let d=n.safe(n.associationId(e),E({before:c,after:`]`},s.current()));return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function L4(){return`!`}R4.peek=z4;function R4(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^\n\r ]/.test(r)&&(/^[\n\r ]/.test(r)&&/[\n\r ]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e);if(!e.atBreak)continue;let i;for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function z4(){return"`"}function B4(e,t){let n=SX(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][+\-.a-z]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}V4.peek=H4;function V4(e,t,n,r){let i=c4(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r);if(B4(e,n)){let t=n.stack;n.stack=t.filter(function(e){return e!==`phrasing`});let r=n.enter(`autolink`),i=o.move(`<`);return i+=o.move(n.containerPhrasing(e,E({before:i,after:`>`},o.current()))),i+=o.move(`>`),r(),n.stack=t,i}let s=n.enter(`link`),c=n.enter(`label`),l=o.move(`[`),u=n.containerPhrasing(e,E({before:l,after:`](`},o.current()));l+=o.move(u),c(),l+=o.move(`](`);let d=/[\0- \u007F]/.test(e.url),f=r.before.charAt(r.before.length-1),p=e.title||void 0;if(!p&&!d&&(f===`
89
+ `||f===`\r`)){let e=0;for(;e<u.length&&u.charCodeAt(e)!==93;)e+=u.charCodeAt(e)===92?2:1;u.charCodeAt(e+1)===58&&(p=``)}return!e.url&&typeof p==`string`||d?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,E({before:l,after:`>`},o.current()))),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,E({before:l,after:typeof p==`string`?` `:`)`},o.current())))),c(),typeof p==`string`&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(p,E({before:l,after:i},o.current()))),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function H4(e,t,n){return B4(e,n)?`<`:`[`}U4.peek=W4;function U4(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,E({before:c,after:`]`},s.current()));c+=s.move(l+`][`),o();let u=n.stack;n.stack=u.filter(function(e){return e!==`phrasing`}),o=n.enter(`reference`);let d=n.safe(n.associationId(e),E({before:c,after:`]`},s.current()));return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function W4(){return`[`}function G4(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function K4(e){let t=G4(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function q4(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function J4(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Y4(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?q4(n):G4(n),s=e.ordered?o===`.`?`)`:`.`:K4(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if(o!==`*`&&o!==`-`||!t||t.children&&t.children[0]||n.stack[n.stack.length-1]!==`list`||n.stack[n.stack.length-2]!==`listItem`||n.stack[n.stack.length-3]!==`list`||n.stack[n.stack.length-4]!==`listItem`||n.indexStack[n.indexStack.length-1]!==0||n.indexStack[n.indexStack.length-2]!==0||n.indexStack[n.indexStack.length-3]!==0||(c=!0),J4(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function X4(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Z4(e,t,n,r){let i=X4(n),a=n.bulletCurrent||G4(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function Q4(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}function $4(e,t,n,r){if(!e.children.some(function(e){return Z2(e)}))return n.containerFlow(e,r);let i=n.enter(`phrasing`),a=n.containerPhrasing(e,r);return i(),a}function e3(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}t3.attention=n3,t3.peek=r3;function t3(e,t,n,r){let i=n.enter(`phrasing`),a=E4([w4(e,n3,n,n.createTracker(r))],r.before,r.after);return i(),a}function n3(e,t){return{construct:`strong`,markers:e3(t)===`*`?[`*`,`_`]:[`_`,`*`],sizes:[2]}}function r3(e,t,n){return n.options.strong||`*`}function i3(e,t,n,r){let i=t?t.children:[],a=n.indexStack[n.indexStack.length-1];return n.safe(e.value,E(E({},r),{},{afterNode:i[a+1],beforeNode:i[a-1]}))}function a3(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function o3(e,t,n){let r=(J4(n)+(n.options.ruleSpaces?` `:``)).repeat(a3(n));return n.options.ruleSpaces?r.slice(0,-1):r}var s3={blockquote:Q2,break:n4,code:o4,definition:l4,emphasis:D4,hardBreak:n4,heading:j4,html:M4,image:P4,imageReference:I4,inlineCode:R4,link:V4,linkReference:U4,list:Y4,listItem:Z4,paragraph:Q4,root:$4,strong:t3,text:i3,thematicBreak:o3};function c3(){return{enter:{table:l3,tableData:p3,tableHeader:p3,tableRow:d3},exit:{codeText:m3,table:u3,tableData:f3,tableHeader:f3,tableRow:f3}}}function l3(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[],position:void 0},e),this.data.inTable=!0}function u3(e){this.exit(e),this.data.inTable=void 0}function d3(e){this.enter({type:`tableRow`,children:[],position:void 0},e)}function f3(e){this.exit(e)}function p3(e){this.enter({type:`tableCell`,children:[],position:void 0},e)}function m3(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,h3));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function h3(e,t){return t===`|`?t:e}function g3(e){let{tableCellPadding:t,tablePipeAlign:n,stringLength:r}=e||{},i=t?` `:`|`;return{handlers:{inlineCode:d,table:a,tableCell:s,tableRow:o},join:[_3],unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
90
+ `,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}]};function a(e,t,n,r){let i=l(e,n,r),a=i[0];if(a){let t=e.align?e.align.length:0,n=-1;if(!t)for(;++n<i.length;)i[n].length>t&&(t=i[n].length);for(;a.length<t;)a.push(``)}return c(i,e.align)}function o(e,t,n,r){let i=c([u(e,n,r)]);return i.slice(0,i.indexOf(`
91
+ `))}function s(e,t,n,r){let a=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,E(E({},r),{},{before:i,after:i}));return o(),a(),s}function c(e,i){return J2(e,{align:i,alignDelimiters:n,fillRows:!1,padding:t,stringLength:r})}function l(e,t,n){let{children:r}=e,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=u(r[i],t,n);return o(),a}function u(e,t,n){let{children:r}=e,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=s(r[i],e,t,n);return o(),a}function d(e,t,n){let r=s3.inlineCode(e,t,n);if(!n.stack.includes(`tableCell`))return r;let i=[],a=0,o=r.indexOf(`|`);for(;o!==-1;){let e=o;for(;e>a&&r.charCodeAt(e-1)===92;)e--;i.push(r.slice(a,o)),(o-e)%2==0&&i.push(`\\`),a=o,o=r.indexOf(`|`,o+1)}return i.push(r.slice(a)),i.join(``)}}function _3(e,t,n,r){if(e.type===`table`&&n.type===`listItem`&&n.spread===!1&&(t.type===`definition`||t.type===`heading`&&v3(t,r)||t.type===`paragraph`||t.type===`table`))return 1}function v3(e,t){let n=!1;return j1(e,function(e){if(e.type===`break`||`value`in e&&/\r?\n|\r/.test(e.value))return n=!0,!1}),!!((!e.depth||e.depth<3)&&SX(e)&&(t.options.setext||n))}function y3(){return{exit:{taskListCheckValueChecked:x3,taskListCheckValueUnchecked:x3,paragraph:S3}}}function b3(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:C3}}}function x3(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function S3(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function C3(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=s3.listItem(e,t,n,E(E({},r),s.current()));return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function w3(){return[d2(),F2(),B2(),c3(),y3()]}function T3(e){return{extensions:[f2(),I2(e),V2(),g3(e),b3()]}}var E3={tokenize:B3,partial:!0},D3={tokenize:V3,partial:!0},O3={tokenize:H3,partial:!0},k3={tokenize:U3,partial:!0},A3={tokenize:W3,partial:!0},j3={name:`wwwAutolink`,tokenize:R3,previous:G3},M3={name:`protocolAutolink`,tokenize:z3,previous:K3},N3={name:`emailAutolink`,tokenize:L3,previous:q3},P3={};function F3(){return{text:P3}}for(var I3=48;I3<123;)P3[I3]=N3,I3++,I3===58?I3=65:I3===91&&(I3=97);P3[43]=N3,P3[45]=N3,P3[46]=N3,P3[95]=N3,P3[72]=[N3,M3],P3[104]=[N3,M3],P3[87]=[N3,j3],P3[119]=[N3,j3];function L3(e,t,n){let r=this,i,a;return o;function o(t){return!J3(t)||!q3.call(r,r.previous)||Y3(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return J3(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(A3,u,l)(t):t===45||t===95||LX(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&IX(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function R3(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!G3.call(r,r.previous)||Y3(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(E3,e.attempt(D3,e.attempt(O3,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function z3(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&K3.call(r,r.previous)&&!Y3(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(IX(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||zX(t)||WX(t)||qX(t)||KX(t)?n(t):e.attempt(D3,e.attempt(O3,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function B3(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function V3(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(k3,c,s)(t):t===null||WX(t)||qX(t)||t!==45&&KX(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function H3(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(k3,t,a)(o):o===null||WX(o)||qX(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function U3(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||WX(o)||qX(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||WX(e)||qX(e)?t(e):r(e)}function a(e){return IX(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):IX(t)?(e.consume(t),o):n(t)}}function W3(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return LX(e)?n(e):t(e)}}function G3(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||WX(e)}function K3(e){return!IX(e)}function q3(e){return!(e===47||J3(e))}function J3(e){return e===43||e===45||e===46||e===95||LX(e)}function Y3(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var X3={tokenize:i6,partial:!0};function Z3(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:t6,continuation:{tokenize:n6},exit:r6}},text:{91:{name:`gfmFootnoteCall`,tokenize:e6},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Q3,resolveTo:$3}}}}function Q3(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=FX(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function $3(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function e6(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||WX(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(FX(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return WX(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function t6(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||WX(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=FX(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return WX(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),XX(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function n6(e,t,n){return e.check(mZ,t,e.attempt(X3,t,n))}function r6(e){e.exit(`gfmFootnoteDefinition`)}function i6(e,t,n){let r=this;return XX(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function a6(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t==null&&(t=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&OX(o,o.length,0,sZ(s,e.slice(r+1,n),t)),OX(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),OX(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=oZ(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=oZ(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var o6=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){s6(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function s6(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function c6(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function l6(){return{flow:{null:{name:`table`,tokenize:u6,resolveAll:d6}}}}function u6(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124||(o=!0,a+=1),u(e)}function u(t){return t===null?n(t):UX(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):GX(t)?XX(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||WX(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,GX(t)?XX(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return GX(t)?XX(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||UX(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return GX(t)?XX(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||UX(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||UX(n)?(e.exit(`tableRow`),t(n)):GX(n)?XX(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||WX(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function d6(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new o6;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(p6(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=f6(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=f6(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=f6(f,t,o,i,n,d)):(o[0]=o[1],d=f6(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&p6(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=c6(t.events,n))}return e}function f6(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},m6(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=m6(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=m6(t.events,n[2]),a=m6(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},m6(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function p6(e,t,n,r,i){let a=[],o=m6(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function m6(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var h6={name:`tasklistCheck`,tokenize:_6};function g6(){return{text:{91:h6}}}function _6(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return WX(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return UX(r)?t(r):GX(r)?e.check({tokenize:v6},t,n)(r):n(r)}}function v6(e,t,n){return XX(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function y6(e){return jX([F3(),Z3(),a6(e),l6(),g6()])}var b6={};function x6(e){let t=this,n=e||b6,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),a=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(y6(n)),a.push(w3()),o.push(T3(n))}var S6=({copiedDuration:e=3e3}={})=>{let[t,n]=(0,h.useState)(!1),r=(0,h.useRef)(void 0),i=(0,h.useRef)(0);return(0,h.useEffect)(()=>()=>{i.current+=1,r.current!==void 0&&(clearTimeout(r.current),r.current=void 0,n(!1))},[]),{isCopied:t,copyToClipboard:t=>{if(!t||typeof navigator>`u`||!navigator.clipboard)return;let a=i.current;navigator.clipboard.writeText(t).then(()=>{a===i.current&&(r.current!==void 0&&clearTimeout(r.current),n(!0),r.current=setTimeout(()=>{r.current=void 0,n(!1)},e))},()=>{})}}},C6=[`className`,`children`],w6=[`className`],T6=[`className`],E6=[`className`],D6=[`className`],O6=[`className`],k6=[`className`],A6=[`className`],j6=[`className`],M6=[`className`],N6=[`className`],P6=[`className`],F6=[`className`],I6=[`className`],L6=[`className`],R6=[`className`],z6=[`className`],B6=[`className`],V6=[`className`],H6=[`className`],U6=[`className`],W6=e=>{let t=(0,h.useRef)(e);if(e!==t.current){let n=t.current;e!==void 0&&n!==void 0&&Object.keys(n).length===Object.keys(e).length&&Object.keys(e).every(t=>n[t]===e[t])||(t.current=e)}return t.current},G6=e=>{let{className:t,children:n}=e,r=W(e,C6),i=sJ(),a=/\blanguage-mine\b/.test(t==null?``:t)||!t,o=String(n==null?``:n).replace(/\n$/,``),[s,c]=(0,h.useState)(null);(0,h.useEffect)(()=>{if(!i||!a)return;let e=!1;return jF(o).then(t=>{e||c({code:o,html:t})}).catch(e=>{console.error(`[Markdown] Monaco 高亮失败:`,e)}),()=>{e=!0}},[o,i,a]);let l=Q(`font-mono`,i?`text-inherit`:Q(`aui-md-inline-code`,`rounded-md border border-border/60`,`bg-muted px-1.5 py-0.5`,`text-[0.85em] text-foreground`),t);if(!i||!a)return(0,J.jsx)(`code`,E(E({className:l},r),{},{children:n}));let u=(s==null?void 0:s.code)===o?s.html:null;return u===null?(0,J.jsx)(`code`,E(E({className:l},r),{},{children:n})):(0,J.jsx)(`code`,E(E({className:l},r),{},{dangerouslySetInnerHTML:{__html:u}}))},K6=(0,h.memo)(({components:e,componentsByLanguage:t})=>{let n=W6(e),r=W6(t),i=(0,h.useMemo)(()=>n?E(E({},q6),iJ(n)):q6,[n]);return(0,J.jsx)(n2,{remarkPlugins:[x6],className:Q(`aui-md`,`min-w-0 break-words`,`text-[15px] leading-[1.75] text-foreground`,`[&_img]:max-w-full`,`[&_svg]:max-w-full`),components:i,componentsByLanguage:r,defer:!0})}),q6=iJ({h1:e=>{let{className:t}=e,n=W(e,w6);return(0,J.jsx)(`h1`,E({className:Q(`aui-md-h1`,`mt-7 mb-3 scroll-m-20`,`text-2xl font-semibold tracking-tight`,`leading-tight text-foreground`,`first:mt-0 last:mb-0`,t)},n))},h2:e=>{let{className:t}=e,n=W(e,T6);return(0,J.jsx)(`h2`,E({className:Q(`aui-md-h2`,`mt-6 mb-3 scroll-m-20`,`text-xl font-semibold tracking-tight`,`leading-snug text-foreground`,`first:mt-0 last:mb-0`,t)},n))},h3:e=>{let{className:t}=e,n=W(e,E6);return(0,J.jsx)(`h3`,E({className:Q(`aui-md-h3`,`mt-5 mb-2 scroll-m-20`,`text-lg font-semibold`,`leading-snug text-foreground`,`first:mt-0 last:mb-0`,t)},n))},h4:e=>{let{className:t}=e,n=W(e,D6);return(0,J.jsx)(`h4`,E({className:Q(`aui-md-h4`,`mt-4 mb-2 scroll-m-20`,`text-base font-semibold text-foreground`,`first:mt-0 last:mb-0`,t)},n))},h5:e=>{let{className:t}=e,n=W(e,O6);return(0,J.jsx)(`h5`,E({className:Q(`aui-md-h5`,`mt-3 mb-1`,`text-sm font-semibold text-foreground`,`first:mt-0 last:mb-0`,t)},n))},h6:e=>{let{className:t}=e,n=W(e,k6);return(0,J.jsx)(`h6`,E({className:Q(`aui-md-h6`,`mt-3 mb-1`,`text-sm font-medium text-muted-foreground`,`first:mt-0 last:mb-0`,t)},n))},p:e=>{let{className:t}=e,n=W(e,A6);return(0,J.jsx)(`p`,E({className:Q(`aui-md-p`,`my-3`,`text-[15px] leading-[1.75] text-foreground`,`first:mt-0 last:mb-0`,t)},n))},a:e=>{let{className:t}=e,n=W(e,j6);return(0,J.jsx)(`a`,E({className:Q(`aui-md-a`,`text-primary underline decoration-primary/40`,`underline-offset-4 transition-colors`,`hover:decoration-primary`,t)},n))},blockquote:e=>{let{className:t}=e,n=W(e,M6);return(0,J.jsx)(`blockquote`,E({className:Q(`aui-md-blockquote`,`my-4 border-s-2 border-border ps-4`,`text-muted-foreground`,`[&>p]:my-1`,t)},n))},ul:e=>{let{className:t}=e,n=W(e,N6);return(0,J.jsx)(`ul`,E({className:Q(`aui-md-ul`,`my-3 ms-6 list-disc`,`space-y-1`,`marker:text-muted-foreground`,`[&_ul]:my-1`,t)},n))},ol:e=>{let{className:t}=e,n=W(e,P6);return(0,J.jsx)(`ol`,E({className:Q(`aui-md-ol`,`my-3 ms-6 list-decimal`,`space-y-1`,`marker:text-muted-foreground`,`[&_ol]:my-1`,t)},n))},hr:e=>{let{className:t}=e,n=W(e,F6);return(0,J.jsx)(`hr`,E({className:Q(`aui-md-hr`,`my-6 border-0 border-t border-border`,t)},n))},table:e=>{let{className:t}=e,n=W(e,I6);return(0,J.jsx)(`div`,{className:`aui-md-table-wrapper my-4 w-full overflow-x-auto rounded-lg border border-border`,children:(0,J.jsx)(`table`,E({className:Q(`aui-md-table`,`w-full border-collapse text-sm`,t)},n))})},th:e=>{let{className:t}=e,n=W(e,L6);return(0,J.jsx)(`th`,E({className:Q(`aui-md-th`,`border-b border-border`,`bg-muted/60 px-3 py-2.5`,`text-start text-sm font-semibold text-foreground`,`[[align=center]]:text-center`,`[[align=right]]:text-right`,t)},n))},td:e=>{let{className:t}=e,n=W(e,R6);return(0,J.jsx)(`td`,E({className:Q(`aui-md-td`,`border-b border-border/70`,`px-3 py-2.5`,`text-start text-foreground`,`[[align=center]]:text-center`,`[[align=right]]:text-right`,t)},n))},tr:e=>{let{className:t}=e,n=W(e,z6);return(0,J.jsx)(`tr`,E({className:Q(`aui-md-tr`,`transition-colors`,`last:[&>td]:border-b-0`,`hover:bg-muted/30`,t)},n))},li:e=>{let{className:t}=e,n=W(e,B6);return(0,J.jsx)(`li`,E({className:Q(`aui-md-li`,`ps-0 leading-[1.75] text-foreground`,`[&>p]:my-1`,t)},n))},strong:e=>{let{className:t}=e,n=W(e,V6);return(0,J.jsx)(`strong`,E({className:Q(`aui-md-strong`,`font-semibold text-foreground`,t)},n))},sup:e=>{let{className:t}=e,n=W(e,H6);return(0,J.jsx)(`sup`,E({className:Q(`aui-md-sup`,`text-muted-foreground`,`[&>a]:text-xs [&>a]:no-underline`,t)},n))},pre:e=>{let{className:t}=e,n=W(e,U6);return(0,J.jsx)(`pre`,E({className:Q(`aui-md-pre`,`my-0 overflow-x-auto`,`rounded-b-xl border border-border`,`bg-[#f4f4f4] px-4 py-4`,`font-mono text-[13px] leading-6`,`text-[#242424]`,`dark:bg-[#2f2f2f] dark:text-[#ededed]`,`[&>code]:bg-transparent`,`[&>code]:p-0`,`[&>code]:text-inherit`,`[&>code]:border-0`,t)},n))},code:G6,CodeHeader:({language:e,code:t})=>{let{isCopied:n,copyToClipboard:r}=S6();return(0,J.jsxs)(`div`,{className:Q(`aui-code-header-root`,`mt-4 flex items-center justify-between`,`rounded-t-xl border border-b-0 border-border`,`bg-[#f4f4f4] px-4 py-2`,`dark:bg-[#2f2f2f]`,`text-xs`),children:[(0,J.jsx)(`span`,{className:`aui-code-header-language font-medium text-muted-foreground`,children:e||`code`}),(0,J.jsx)(DK,{tooltip:n?`已复制`:`复制代码`,onClick:()=>{t&&!n&&r(t)},className:Q(`size-7 rounded-md`,`text-muted-foreground`,`hover:bg-black/5 hover:text-foreground`,`dark:hover:bg-white/10`),children:n?(0,J.jsx)(uI,{className:`size-4`}):(0,J.jsx)(wI,{className:`size-4`})})]})}});function J6({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=h.useRef(e!==void 0),[a,o]=h.useState(()=>t),s=i&&e!==void 0?e:a;if(process.env.NODE_ENV!==`production`){h.useEffect(()=>{i!==(e!==void 0)&&XW([`A component is changing the ${i?``:`un`}controlled ${r} state of ${n} to be ${i?`un`:``}controlled.`,`Elements should not switch from uncontrolled to controlled (or vice versa).`,`Decide between using a controlled or uncontrolled ${n} element for the lifetime of the component.`,"The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.",`More info: https://fb.me/react-controlled-components`].join(`
92
+ `))},[r,n,e]);let{current:a}=h.useRef(t);h.useEffect(()=>{!i&&Y6(a)!==Y6(t)&&XW([`A component is changing the default ${r} state of an uncontrolled ${n} after being initialized. To suppress this warning opt to use a controlled ${n}.`].join(`
93
+ `))},[t])}return[s,h.useCallback(e=>{i||o(e)},[])]}function Y6(e){let t=0,n=new WeakMap;try{let r=JSON.stringify(e,function(e,r){if(!(e===`_owner`&&this!=null&&typeof this==`object`&&`$$typeof`in this)){if(typeof r==`bigint`)return`__bigint__:${r}`;if(typeof r==`object`&&r){let e=n.get(r);if(e!==void 0)return`__object__:${e}`;n.set(r,t),t+=1}return r}});return r==null?`__top__:${typeof e}`:r}catch(e){return`__unserializable__`}}function X6(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,disabled:i}=e,[a,o]=J6({controlled:t,default:n,name:`Collapsible`,state:`open`}),{mounted:s,setMounted:c,transitionStatus:l}=FV(a,!0,!0),u=tU(),[d,f]=h.useState(),p=d===null?void 0:d==null?u:d,m=yz(e=>{let t=!a,n=GR(qR,e.nativeEvent);r(t,n),n.isCanceled||o(t)});return h.useMemo(()=>({defaultPanelId:u,disabled:i,handleTrigger:m,mounted:s,open:a,panelId:p,setMounted:c,setOpen:o,setPanelIdState:f,transitionStatus:l}),[u,i,m,s,a,p,c,o,f,l])}var Z6=h.createContext(void 0);process.env.NODE_ENV!==`production`&&(Z6.displayName=`CollapsibleRootContext`);function Q6(){let e=h.useContext(Z6);if(e===void 0)throw Error(process.env.NODE_ENV===`production`?FL(15):`Base UI: CollapsibleRootContext is missing. Collapsible parts must be placed within <Collapsible.Root>.`);return e}var $6=`data-open`,e8=`data-closed`,t8=gR,n8=`data-panel-open`,r8={[$6]:``},i8={[e8]:``},a8={open(e){return e?{[n8]:``}:null}},o8=E(E({},{open(e){return e?r8:i8}}),bR),s8=[`render`,`className`,`defaultOpen`,`disabled`,`onOpenChange`,`open`,`style`],c8=h.forwardRef(function(e,t){let{render:n,className:r,defaultOpen:i=!1,disabled:a=!1,onOpenChange:o,open:s,style:c}=e,l=W(e,s8),u=yz(o),d=X6({open:s,defaultOpen:i,onOpenChange:u,disabled:a}),f=h.useMemo(()=>({open:d.open,disabled:d.disabled,transitionStatus:d.transitionStatus}),[d.open,d.disabled,d.transitionStatus]),p=h.useMemo(()=>E(E({},d),{},{onOpenChange:u,state:f}),[d,u,f]),m=KB(`div`,e,{state:f,ref:t,props:l,stateAttributesMapping:o8});return(0,J.jsx)(Z6.Provider,{value:p,children:m})});process.env.NODE_ENV!==`production`&&(c8.displayName=`CollapsibleRoot`);var l8=[`className`,`disabled`,`render`,`nativeButton`,`style`],u8=E(E({},a8),bR),d8=h.forwardRef(function(e,t){let{panelId:n,open:r,handleTrigger:i,state:a,disabled:o}=Q6(),{className:s,disabled:c=o,render:l,nativeButton:u=!0,style:d}=e,f=W(e,l8),{getButtonProps:p,buttonRef:m}=nG({disabled:c,native:u});return KB(`button`,e,{state:a,ref:[t,m],props:[{"aria-controls":r?n:void 0,"aria-expanded":r,onClick:i},f,p],stateAttributesMapping:u8})});process.env.NODE_ENV!==`production`&&(d8.displayName=`CollapsibleTrigger`);var f8={height:void 0,width:void 0};function p8(e){let{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:a,onOpenChange:o,open:s,setMounted:c,setOpen:l,transitionStatus:u}=e,d=h.useRef(null),f=h.useRef(null),[p,m]=h.useState(f8),g=h.useRef(f8),_=h.useRef(!1),v=h.useRef(s),y=h.useRef(!1),[b,x]=h.useState(!1),S=h.useRef(null),C=cz(t,d),w=mz(s),T=zV(d),D=!s&&!a,O=b?`idle`:u,k=s&&(v.current||y.current),A=!s&&a&&f.current===`css-animation`&&p.height===void 0&&p.width===void 0?g.current:p,j=n&&D&&f.current!==`css-animation`,M=yz((e,t=!0)=>{t&&(g.current=e),m(e)}),N=yz(()=>{var e;(e=S.current)==null||e.call(S),S.current=null}),P=yz(e=>{N(),S.current=()=>{S.current=null,e()}}),F=yz(()=>{s&&a&&f.current===`css-animation`&&(y.current=!0)});NL(()=>{b&&u!==`starting`&&x(!1)},[b,u]),h.useEffect(()=>()=>{F(),N()},[F,N]),NL(()=>{s||(v.current=!1,y.current=!1);let e=d.current;if(!e)return;!s&&S.current&&N();let t=h8(e,k);if(f.current=t,s&&u===`idle`&&v.current&&t===`css-animation`){g.current=m8(e);return}if(s&&u===`starting`){let n=_.current;if(_.current=!1,t===`none`){M(m8(e)),x(!0);return}if(t===`css-transition`){let t=v8(e);if(M(m8(e)),!n)return t;let r=_8(e,`transition-duration`,`0s`);return P(r),x(!0),t}M(m8(e));let r=_8(e,`animation-name`,`none`);if(!n){r();return}let i=_8(e,`animation-duration`,`0s`);r(),P(i),x(!0);return}if(!s&&a&&(u===`idle`||u===`starting`)){if(t===`none`){M(f8,!1),c(!1);return}M(m8(e));return}if(u!==`ending`)return;if(t===`none`){c(!1);return}let n=m8(e);n.height>0||n.width>0?(M(n),t===`css-animation`&&_8(e,`animation-name`,`none`)()):c(!1)},[a,s,N,M,c,P,k,u]),BV({enabled:s&&a&&O===`idle`,open:!0,ref:d,onComplete(){s&&M(f8,!1)}}),h.useEffect(()=>{if(s||!a||O!==`ending`)return;if(!d.current){c(!1),M(f8,!1);return}let e=new AbortController,t=-1;function n(){w.current||(c(!1),M(f8,!1))}return t=Tz.request(()=>{T(n,e.signal)}),()=>{Tz.cancel(t),e.abort()}},[w,a,s,O,T,M,c]),NL(()=>{let e=d.current;e&&n&&D&&e.setAttribute(`hidden`,`until-found`)},[D,n]),h.useEffect(function(){let e=d.current;if(!e)return;let t=BL.create(),n=-1,r=(r,i)=>{t.start(0,()=>{w.current||(n=Tz.request(()=>{w.current||(r&&(_.current=!1),i&&e.setAttribute(t8,``),e.setAttribute(`hidden`,`until-found`))}))})},i=oz(e,`beforematch`,t=>{let n=GR(KR,t);if(o(!0,n),n.isCanceled){r(!1,!1);return}_.current=!0;let i=e.hasAttribute(t8);e.removeAttribute(t8),l(!0),r(!0,i)});return()=>{t.clear(),Tz.cancel(n),i()}},[w,o,l]);let I=i||n||a||s;return{height:A.height,props:E(E({},j?{[t8]:``}:void 0),{},{hidden:D,id:r}),ref:C,shouldPreventOpenAnimation:k,shouldRender:I,transitionStatus:O,width:A.width}}function m8(e){return{height:e.scrollHeight,width:e.scrollWidth}}function h8(e,t){let n=HS(e).getComputedStyle(e),r=(n.animationName.split(`,`).map(e=>e.trim()).some(e=>e!==``&&e!==`none`)||t)&&g8(n.animationDuration),i=g8(n.transitionDuration);return r&&i?(process.env.NODE_ENV!==`production`&&OB(`CSS transitions and CSS animations both detected on Collapsible or Accordion panel.`,`Only one of either animation type should be used.`),`css-transition`):i?`css-transition`:r?`css-animation`:`none`}function g8(e){return e.split(`,`).map(e=>e.trim()).some(e=>e!==``&&Number.parseFloat(e)>0)}function _8(e,t,n){let r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{r===``?e.style.removeProperty(t):e.style.setProperty(t,r,i)}}function v8(e){let t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(t=>{e.style.setProperty(t,`initial`,`important`)});function n(){Object.entries(t).forEach(([t,n])=>{n===``?e.style.removeProperty(t):e.style.setProperty(t,n)})}let r=Tz.request(n);return()=>{Tz.cancel(r),n()}}var y8=`--collapsible-panel-height`,b8=`--collapsible-panel-width`,x8=[`className`,`hiddenUntilFound`,`keepMounted`,`render`,`id`,`style`],S8=h.forwardRef(function(e,t){let{className:n,hiddenUntilFound:r,keepMounted:i,render:a,id:o,style:s}=e,c=W(e,x8);process.env.NODE_ENV!==`production`&&h.useEffect(()=>{r&&i===!1&&OB("The `keepMounted={false}` prop on `Collapsible.Panel` is ignored when `hiddenUntilFound` is enabled, since the panel must remain mounted while closed.")},[r,i]);let{defaultPanelId:l,mounted:u,onOpenChange:d,open:f,setMounted:p,setPanelIdState:m,setOpen:g,state:_,transitionStatus:v}=Q6(),y=r!=null&&r,b=i!=null&&i,x=o||void 0,S=x==null?l:x;NL(()=>(m(e=>x==null?e===null?void 0:e:x),()=>{m(e=>e===x?null:e)}),[x,m]);let{height:C,props:w,ref:T,shouldPreventOpenAnimation:D,shouldRender:O,transitionStatus:k,width:A}=p8({externalRef:t,hiddenUntilFound:y,id:S,keepMounted:b,mounted:u,onOpenChange:d,open:f,setMounted:p,setOpen:g,transitionStatus:v}),j=E(E({},_),{},{transitionStatus:k}),M=jB(s,j),N=KB(`div`,E(E({},e),{},{style:void 0}),{state:j,ref:T,props:[w,{style:{[y8]:C===void 0?`auto`:`${C}px`,[b8]:A===void 0?`auto`:`${A}px`}},c,M?{style:M}:void 0,D?{style:{animationName:`none`}}:void 0],stateAttributesMapping:o8});return O?N:null});process.env.NODE_ENV!==`production`&&(S8.displayName=`CollapsiblePanel`);var C8=(0,h.forwardRef)(function(e,t){return(0,J.jsx)(c8,E({ref:t,"data-slot":`collapsible`},e))});function w8(e){let t=zW({},(RW(e),e));return(0,J.jsx)(d8,E({"data-slot":`collapsible-trigger`},t))}function T8(e){let t=zW({},(RW(e),e));return(0,J.jsx)(S8,E({"data-slot":`collapsible-content`},t))}var E8=[`className`,`variant`,`open`,`onOpenChange`,`defaultOpen`,`streaming`,`showContent`,`onAnimationStart`,`style`,`children`],D8=[`side`,`className`],O8=[`active`,`duration`,`className`],k8=[`className`,`children`],A8=[`className`,`children`],j8=(0,h.createContext)({isPreview:!1,showContent:!0}),M8=XG(`aui-reasoning-root mb-0 w-full`,{variants:{variant:{outline:`rounded-lg px-0 py-2`,ghost:``,muted:`bg-muted/50 rounded-lg px-3 py-2`}},defaultVariants:{variant:`outline`}}),N8=(0,h.forwardRef)(function(e,t){let{className:n,variant:r,open:i,onOpenChange:a,defaultOpen:o=!1,streaming:s,showContent:c=!0,onAnimationStart:l,style:u,children:d}=e,f=W(e,E8),[p]=(0,h.useState)(o),[m,g]=(0,h.useState)(null),_=i!==void 0,v=_?i:m==null?s||p:m,y=s===!0&&v,b=(0,h.useRef)(s);GK(()=>{b.current!==s&&(b.current=s,_||m!==null||p||l==null||l())},[s,_,m,p,l]);let x=(0,h.useCallback)(e=>{l==null||l(),_||g(e),a==null||a(e)},[l,_,a]),S={isPreview:c&&y,showContent:c};return c?(0,J.jsx)(C8,E(E({ref:t,"data-slot":`reasoning-root`,"data-variant":r,open:v,onOpenChange:x,className:Q(`group/reasoning-root`,M8({variant:r,className:n})),style:E({"--animation-duration":`200ms`},typeof u==`object`&&u||{})},f),{},{children:(0,J.jsx)(j8.Provider,{value:S,children:d})})):(0,J.jsx)(`div`,E(E({ref:t,"data-slot":`reasoning-root`,"data-variant":r,className:Q(`group/reasoning-root`,M8({variant:r,className:n})),style:typeof u==`function`?void 0:u},f),{},{children:(0,J.jsx)(j8.Provider,{value:S,children:d})}))});function P8(e){let{side:t=`bottom`,className:n}=e,r=W(e,D8);return t===`top`?(0,J.jsx)(`div`,E({"data-slot":`reasoning-fade`,className:Q(`aui-reasoning-fade pointer-events-none absolute inset-x-0 top-0 z-10 h-8`,`bg-[linear-gradient(to_bottom,var(--color-background),transparent)]`,`group-data-[variant=muted]/reasoning-root:bg-[linear-gradient(to_bottom,color-mix(in_oklab,var(--color-muted)_50%,var(--color-background)),transparent)]`,`fade-in-0 animate-in`,`animation-duration-(--animation-duration)`,n)},r)):(0,J.jsx)(`div`,E({"data-slot":`reasoning-fade`,className:Q(`aui-reasoning-fade pointer-events-none absolute inset-x-0 bottom-0 z-10 h-8`,`bg-[linear-gradient(to_top,var(--color-background),transparent)]`,`group-data-[variant=muted]/reasoning-root:bg-[linear-gradient(to_top,color-mix(in_oklab,var(--color-muted)_50%,var(--color-background)),transparent)]`,`fade-in-0 animate-in`,`animation-duration-(--animation-duration)`,n)},r))}function F8(e){let{active:t,duration:n,className:r}=e,i=W(e,O8),{showContent:a}=(0,h.useContext)(j8),o=t?`正在思考...`:n===void 0?`思考过程`:`思考了 ${n} 秒`,s=Q(`aui-reasoning-trigger flex max-w-[75%] origin-left items-center gap-2 py-1.5 text-sm text-muted-foreground`,t&&a&&`hover:text-foreground transition-colors active:scale-[0.98]`,r),c=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(cI,{"data-slot":`reasoning-trigger-icon`,className:`aui-reasoning-trigger-icon size-4 shrink-0`}),(0,J.jsx)(`span`,{"data-slot":`reasoning-trigger-label`,className:Q(`aui-reasoning-trigger-label-wrapper inline-block leading-none tabular-nums`,t&&`shimmer motion-reduce:animate-none`),children:o})]});return!a||!t?(0,J.jsx)(`div`,{"data-slot":`reasoning-trigger`,className:s,children:c}):(0,J.jsx)(w8,E(E({"data-slot":`reasoning-trigger`,className:s},i),{},{children:c}))}function I8(e){let{className:t,children:n}=e,r=W(e,k8),{showContent:i}=(0,h.useContext)(j8);return i?(0,J.jsx)(T8,E(E({"data-slot":`reasoning-content`,className:Q(`aui-reasoning-content relative overflow-hidden text-sm text-muted-foreground outline-none`,`group/collapsible-content ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none`,`data-closed:animate-collapsible-up`,`data-open:animate-collapsible-down`,`data-closed:fill-mode-forwards`,`data-closed:pointer-events-none`,`[--tw-duration:var(--animation-duration)]`,t)},r),{},{children:n})):null}function L8(e){let{className:t,children:n}=e,r=W(e,A8),{showContent:i}=(0,h.useContext)(j8);return i?(0,J.jsx)(`div`,E(E({"data-slot":`reasoning-text`,className:Q(`aui-reasoning-text relative z-0 max-h-64 overflow-y-auto ps-6 pt-2 pb-2 leading-relaxed text-pretty`,`motion-reduce:animate-none`,t)},r),{},{children:(0,J.jsx)(`div`,{className:`aui-reasoning-text-content space-y-4`,children:n})})):null}var R8=[`onAnimationStart`],z8=(0,h.forwardRef)(function(e,t){let{onAnimationStart:n}=e,r=W(e,R8),i=(0,h.useRef)(null),a=YP(i,200),o=(0,h.useCallback)(()=>{a(),n==null||n()},[a,n]),s=(0,h.useCallback)(e=>{if(i.current=e,typeof t==`function`){let n=t(e);if(typeof n==`function`)return()=>{i.current=null,n()}}else t&&(t.current=e)},[t]);return(0,J.jsx)(N8,E({ref:s,onAnimationStart:o},r))}),B8=()=>(0,J.jsx)(K6,{}),V8=({children:e,startIndex:t,endIndex:n})=>{let r=q(e=>{var r;if(((r=e.message.status)==null?void 0:r.type)!==`running`)return!1;for(let r=t;r<=n;r++){var i;if(((i=e.message.parts[r])==null?void 0:i.status.type)===`running`)return!0}return!1});return(0,J.jsxs)(z8,{streaming:r,showContent:!1,children:[(0,J.jsx)(F8,{active:r}),(0,J.jsx)(I8,{"aria-busy":r,"aria-label":`AI 思考过程`,children:(0,J.jsx)(L8,{children:e})})]})},H8=(0,h.memo)(B8);H8.displayName=`Reasoning`,H8.Root=z8,H8.Trigger=F8,H8.Content=I8,H8.Text=L8,H8.Fade=P8;var U8=(0,h.memo)(V8);U8.displayName=`ReasoningGroup`;var W8=[`className`];function G8(e){let{className:t}=e,n=W(e,W8);return(0,J.jsx)(`textarea`,E({"data-slot":`textarea`,className:Q(`flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,t)},n))}var K8=[`className`,`open`,`onOpenChange`,`defaultOpen`,`children`],q8=[`className`],J8=[`toolName`,`status`,`responseDeliveryStatus`,`className`],Y8=[`className`,`children`],X8=[`argsText`,`className`],Z8=[`result`,`className`],Q8=[`status`,`className`],$8=[`approval`,`className`,`focusReceiptRef`,`receiptRef`],e5=[`className`,`forwardedRef`,`carryFocusRef`,`addResult`,`resume`,`interrupt`,`approval`,`respondToApproval`,`status`],t5=200,n5=`active:scale-[0.98]`;function r5(e){let{className:t,open:n,onOpenChange:r,defaultOpen:i=!1,children:a}=e,o=W(e,K8),s=(0,h.useRef)(null),[c,l]=(0,h.useState)(i),u=YP(s,t5),d=n!==void 0,f=d?n:c,p=(0,h.useCallback)(e=>{u(),d||l(e),r==null||r(e)},[u,d,r]);return(0,J.jsx)(C8,E(E({ref:s,"data-slot":`tool-fallback-root`,open:f,onOpenChange:p,className:Q(`aui-tool-fallback-root group/tool-fallback-root w-full`,t),style:{"--animation-duration":`${t5}ms`}},o),{},{children:a}))}var i5={running:HI,complete:uI,incomplete:SI,"requires-action":vI},a5=e=>{if(e<1e3)return`<1秒`;let t=e/1e3;return t<10?`${(Math.floor(t*10)/10).toFixed(1)}秒`:t<60?`${Math.floor(t)}秒`:`${Math.floor(t/60)}分 ${Math.floor(t%60)}秒`};function o5(e){let{className:t}=e,n=W(e,q8),r=Dy();return r===void 0?null:(0,J.jsx)(`span`,E(E({"data-slot":`tool-fallback-duration`,className:Q(`aui-tool-fallback-duration text-muted-foreground text-xs tabular-nums`,t)},n),{},{children:a5(r)}))}function s5(e){var t;let{toolName:n,status:r,responseDeliveryStatus:i,className:a}=e,o=W(e,J8),s=(t=r==null?void 0:r.type)==null?`complete`:t,c=s===`running`,l=(r==null?void 0:r.type)===`incomplete`&&r.reason===`cancelled`,u=i5[s],d=i===`queued`?`回复已排队,尚未发送`:s===`running`?`正在执行工具`:s===`requires-action`?`等待工具操作`:s===`incomplete`?l?`已取消工具调用`:`工具执行失败`:`已调用工具`;return(0,J.jsxs)(w8,E(E({"data-slot":`tool-fallback-trigger`,className:Q(`aui-tool-fallback-trigger group/trigger text-muted-foreground hover:text-foreground flex w-fit max-w-full origin-left items-center gap-2 py-1.5 text-sm transition-[color,scale] active:scale-[0.98]`,a)},o),{},{children:[(0,J.jsx)(u,{"data-slot":`tool-fallback-trigger-icon`,className:Q(`aui-tool-fallback-trigger-icon size-4 shrink-0`,l&&`text-muted-foreground`,c&&`animate-spin [animation-duration:0.6s]`)}),(0,J.jsxs)(`span`,{"data-slot":`tool-fallback-trigger-label`,className:Q(`aui-tool-fallback-trigger-label-wrapper inline-block min-w-0 text-start leading-none wrap-anywhere`,l&&`text-muted-foreground line-through`,c&&`shimmer motion-reduce:animate-none`),children:[d,`:`,(0,J.jsx)(`b`,{children:n})]}),(0,J.jsx)(o5,{}),(0,J.jsx)(fI,{"data-slot":`tool-fallback-trigger-chevron`,className:Q(`aui-tool-fallback-trigger-chevron size-4 shrink-0`,`transition-transform duration-(--animation-duration) ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:transition-none`,`-rotate-90`,`group-data-open/trigger:rotate-0`,`group-data-panel-open/trigger:rotate-0`)})]}))}function c5(e){let{className:t,children:n}=e,r=W(e,Y8);return(0,J.jsx)(T8,E(E({"data-slot":`tool-fallback-content`,className:Q(`aui-tool-fallback-content relative overflow-hidden text-sm outline-none`,`group/collapsible-content ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none`,`data-closed:animate-collapsible-up`,`data-open:animate-collapsible-down`,`data-closed:fill-mode-forwards`,`data-closed:pointer-events-none`,`[--tw-duration:var(--animation-duration)]`,t)},r),{},{children:(0,J.jsx)(`div`,{className:Q(`flex flex-col gap-2 ps-6 pt-1 pb-2 ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none`,`group-data-open/collapsible-content:animate-in group-data-open/collapsible-content:fade-in-0 group-data-open/collapsible-content:blur-in-[2px] group-data-open/collapsible-content:slide-in-from-top-1`,`group-data-closed/collapsible-content:animate-out group-data-closed/collapsible-content:fade-out-0 group-data-closed/collapsible-content:blur-out-[2px] group-data-closed/collapsible-content:slide-out-to-top-1`,`group-data-closed/collapsible-content:animation-duration-(--animation-duration) group-data-open/collapsible-content:animation-duration-(--animation-duration)`),children:n})}))}function l5(e){let{argsText:t,className:n}=e,r=W(e,X8);return t?(0,J.jsx)(`div`,E(E({"data-slot":`tool-fallback-args`,className:Q(`aui-tool-fallback-args`,n)},r),{},{children:(0,J.jsx)(`pre`,{className:`aui-tool-fallback-args-value bg-muted/50 text-foreground/90 rounded-md p-2.5 text-xs break-words whitespace-pre-wrap`,children:t})})):null}var u5=(e,t)=>{if(typeof e==`string`)return e;try{if(e instanceof Error)return String(e);let n=JSON.stringify(e,null,t);if(n!==void 0)return n}catch(e){}try{return String(e)}catch(e){return`[无法序列化的数据]`}};function d5(e){let{result:t,className:n}=e,r=W(e,Z8);return t===void 0?null:(0,J.jsxs)(`div`,E(E({"data-slot":`tool-fallback-result`,className:Q(`aui-tool-fallback-result`,n)},r),{},{children:[(0,J.jsx)(`p`,{className:`aui-tool-fallback-result-header text-muted-foreground text-xs font-medium`,children:`执行结果:`}),(0,J.jsx)(`pre`,{className:`aui-tool-fallback-result-content bg-muted/50 text-foreground/90 mt-1 rounded-md p-2.5 text-xs break-words whitespace-pre-wrap`,children:u5(t,2)})]}))}function f5(e){let{status:t,className:n}=e,r=W(e,Q8);if((t==null?void 0:t.type)!==`incomplete`)return null;let i=t.error,a=i==null?null:u5(i);if(!a)return null;let o=t.reason===`cancelled`?`取消原因:`:`错误信息:`;return(0,J.jsxs)(`div`,E(E({"data-slot":`tool-fallback-error`,className:Q(`aui-tool-fallback-error`,n)},r),{},{children:[(0,J.jsx)(`p`,{className:`aui-tool-fallback-error-header text-muted-foreground font-semibold`,children:o}),(0,J.jsx)(`p`,{className:`aui-tool-fallback-error-reason text-muted-foreground break-words whitespace-pre-line`,children:a})]}))}var p5=`Approved by user`,m5=`User denied tool execution`,h5={"allow-once":`允许一次`,"allow-always":`始终允许`,"reject-once":`拒绝一次`,"reject-always":`始终拒绝`},g5=e=>Object.hasOwn(h5,e),_5=e=>e===`allow-once`||e===`allow-always`,v5=e=>{var t,n;return(t=(n=e.label)==null?g5(e.kind)?h5[e.kind]:void 0:n)==null?e.id:t},y5=e=>(e==null?void 0:e.display)===`select`||(e==null?void 0:e.display)===`text`||(e==null?void 0:e.display)===`questions`,b5=e=>{var t;return!((t=e.options)!=null&&t.length)||e.allowFreeform===!0},x5=(e,t)=>{var n,r;return[...((n=t==null?void 0:t.optionIds)==null?[]:n).map(t=>{var n,r;return(n=(r=e.options)==null||(r=r.find(e=>e.id===t))==null?void 0:r.label)==null?t:n}),...t!=null&&(r=t.text)!=null&&r.trim()?[t.text]:[]]},S5=e=>e!=null&&(e.approved!==void 0||e.resolution!==void 0),C5=e=>{var t;if(e.resolution!==void 0)return{outcome:`closed`,label:e.resolution===`cancelled`?`已取消,未作出决定`:`已过期,未作出决定`};let n=e.optionId===void 0||(t=e.options)==null?void 0:t.find(t=>t.id===e.optionId),r=n===void 0?e.optionId===void 0?void 0:e.optionId:v5(n),i=y5(e)||n!==void 0&&!g5(n.kind),a=e.isAutomatic?`(自动处理)`:``;return e.approved?{outcome:`allowed`,label:`${i?`已回答`:`已允许`}${a}`,option:r}:{outcome:`refused`,label:`${i?`已关闭`:`已拒绝`}${a}`,option:r}},w5={allowed:uI,refused:SI,closed:bI};function T5(e){var t;let{approval:n,className:r,focusReceiptRef:i,receiptRef:a}=e,o=W(e,$8);(0,h.useLayoutEffect)(()=>{var e;let t=i.current===n.id;i.current=null,t&&((e=a.current)==null||e.focus({preventScroll:!0}))},[n.id,i,a]);let s=C5(n),c=w5[s.outcome],l=[...new Set([n.text,n.reason].filter(e=>typeof e==`string`&&e!==``))];return(0,J.jsxs)(`div`,E(E({ref:a,"data-slot":`tool-fallback-approval-receipt`,"data-outcome":s.outcome,tabIndex:-1,className:Q(`aui-tool-fallback-approval-receipt flex flex-col gap-1.5 pt-1`,r)},o),{},{children:[n.prompt?(0,J.jsx)(`p`,{className:`aui-tool-fallback-approval-prompt text-muted-foreground whitespace-pre-line`,children:n.prompt}):null,(0,J.jsxs)(`p`,{className:`aui-tool-fallback-approval-receipt-label flex items-center gap-1.5`,children:[(0,J.jsx)(c,{"aria-hidden":!0,className:`text-muted-foreground size-3.5 shrink-0`}),(0,J.jsx)(`span`,{className:`font-medium`,children:s.label}),s.option===void 0?null:(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,s.option]})]}),n.answers&&((t=n.questions)==null?void 0:t.map(e=>{var t;let r=x5(e,n.answers&&Object.hasOwn(n.answers,e.id)?n.answers[e.id]:void 0);return r.length===0?null:(0,J.jsxs)(`p`,{className:`aui-tool-fallback-approval-receipt-answer whitespace-pre-line`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:(t=e.header)==null?e.prompt:t}),` `,`· `,r.join(`、`)]},e.id)})),l.map(e=>(0,J.jsx)(`p`,{className:`aui-tool-fallback-approval-receipt-note text-muted-foreground whitespace-pre-line`,children:e},e))]}))}function E5({questions:e,dismissible:t,locked:n,onSend:r,onDismiss:i}){let[a,o]=(0,h.useState)(()=>new Map),[s,c]=(0,h.useState)(()=>new Map),l=(e,t)=>o(n=>{var r;let i=(r=n.get(e.id))==null?[]:r,a=i.includes(t)?i.filter(e=>e!==t):e.multiple?[...i,t]:[t];return new Map(n).set(e.id,a)}),u=e=>{var t;let n=(t=a.get(e.id))==null?[]:t,r=s.get(e.id),i=r!=null&&r.trim()?r:void 0;return E(E({},n.length>0&&{optionIds:n}),i!==void 0&&{text:i})},d=e.length>0&&e.every(e=>{let t=u(e);return t.optionIds!==void 0||t.text!==void 0});return(0,J.jsxs)(J.Fragment,{children:[e.map(e=>{var t,r,i,o,u;let d=(t=a.get(e.id))==null?[]:t,f=(r=(i=e.options)==null?void 0:i.some(e=>e.description))!=null&&r;return(0,J.jsxs)(`div`,{role:`group`,"aria-label":e.prompt,"data-slot":`tool-fallback-approval-question`,className:`aui-tool-fallback-approval-question flex flex-col gap-2`,children:[(0,J.jsxs)(`p`,{className:`aui-tool-fallback-approval-question-prompt text-foreground whitespace-pre-line`,children:[e.header?(0,J.jsx)(`span`,{className:`text-muted-foreground me-1.5 text-xs font-medium uppercase`,children:e.header}):null,e.prompt]}),e.options&&e.options.length>0?(0,J.jsx)(`div`,{className:Q(`flex gap-2`,f?`flex-col items-stretch`:`flex-wrap items-center`),children:e.options.map(t=>{let r=d.includes(t.id);return(0,J.jsxs)($G,{size:`sm`,variant:r?`default`:`outline`,className:Q(n5,f&&`h-auto flex-col items-start gap-0.5 py-2 text-start whitespace-normal`),"aria-pressed":r,onClick:()=>l(e,t.id),disabled:n,children:[(0,J.jsx)(`span`,{children:t.label}),t.description?(0,J.jsx)(`span`,{className:`text-xs font-normal opacity-80`,children:t.description}):null]},t.id)})}):null,b5(e)?(0,J.jsx)(G8,{value:(o=s.get(e.id))==null?``:o,onChange:t=>c(n=>new Map(n).set(e.id,t.target.value)),disabled:n,"aria-label":e.prompt,placeholder:(u=e.options)!=null&&u.length?`或者输入其他答案`:`请输入你的答案`}):null]},e.id)}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)($G,{size:`sm`,className:n5,onClick:()=>{!n&&d&&r(Object.fromEntries(e.map(e=>[e.id,u(e)])))},disabled:n||!d,children:`发送`}),t?(0,J.jsx)($G,{size:`sm`,variant:`outline`,className:n5,onClick:i,disabled:n,children:`关闭`}):null]})]})}var D5=(e,t,n)=>(e==null?void 0:e.type)!==`requires-action`||e.reason!==`interrupt`||t!=null||n!=null,O5=(0,h.forwardRef)(function(e,t){var n;let r=(0,h.useRef)(!1);return(0,J.jsx)(k5,E({carryFocusRef:r,forwardedRef:t},e),(n=e.approval)==null?void 0:n.id)});function k5(e){var t;let{className:n,forwardedRef:r,carryFocusRef:i,addResult:a,resume:o,interrupt:s,approval:c,respondToApproval:l,status:u}=e,d=W(e,e5),[f,p]=(0,h.useState)(!1),m=q(e=>e.thread.voice!==void 0),g=q(e=>e.thread.capabilities.answerToolCall),_=f||m,[v,y]=(0,h.useState)(null),[b,x]=(0,h.useState)(``),[S,C]=(0,h.useState)(null),T=(u==null?void 0:u.type)===`requires-action`,[D,O]=(0,h.useState)(T),[k,A]=(0,h.useState)(0),j=(0,h.useRef)(k);(0,h.useLayoutEffect)(()=>{j.current=k},[k]),T!==D&&(O(T),T&&(p(!1),y(null),x(``),C(null),A(k+1)));let M=(0,h.useRef)(null),N=(0,h.useRef)(null),P=(0,h.useRef)(null);(0,h.useLayoutEffect)(()=>{if(i.current){var e;i.current=!1,(e=M.current)==null||e.focus({preventScroll:!0})}return()=>{var e,t;let n=(e=M.current)==null?N.current:e;i.current=(t=n==null?void 0:n.contains(n.ownerDocument.activeElement))!=null&&t}},[i]),(0,h.useImperativeHandle)(r,()=>{var e;return(e=M.current)==null?N.current:e});let F=(0,h.useCallback)(e=>{let t=M.current;P.current=!e&&t!=null&&t.contains(t.ownerDocument.activeElement)?c==null?void 0:c.id:null,M.current=e},[c==null?void 0:c.id]),I=c!=null&&!S5(c)&&u!==void 0&&u.type!==`requires-action`&&!(f&&u.type===`running`);(0,h.useLayoutEffect)(()=>{I&&(P.current=null)},[I]);let L=()=>{let e=M.current;e!=null&&e.contains(e.ownerDocument.activeElement)&&e.focus({preventScroll:!0})};if(c!=null&&S5(c))return(0,J.jsx)(T5,E({approval:c,receiptRef:N,focusReceiptRef:P,className:n},d));if(I||!D5(u,c,s))return null;let R=c!=null&&c.prompt?(0,J.jsx)(`p`,{className:`aui-tool-fallback-approval-prompt text-foreground whitespace-pre-line`,children:c.prompt}):null;if(!g)return R&&(0,J.jsx)(`div`,E(E({"data-slot":`tool-fallback-approval`,tabIndex:-1,className:Q(`aui-tool-fallback-approval flex flex-col gap-2 pt-1`,n)},d),{},{ref:F,children:R}));let z=l?c==null?void 0:c.options:void 0,B=c!=null&&l!=null&&te(c),ee=e=>{L(),p(!0),y(null),C(null),w(function*(){try{yield e()}catch(e){if(j.current!==k)return;p(!1),C(e instanceof Error?e.message:String(e))}})()},V=e=>{if(!_){if(c!=null&&c.approved===void 0&&l)ee(()=>l(E({approved:e},U())));else if(s)ee(()=>o==null?void 0:o({approved:e}));else if((u==null?void 0:u.type)===`requires-action`&&u.reason===`interrupt`)return;else ee(()=>a==null?void 0:a(e?p5:m5))}},H=e=>{_||ee(()=>l==null?void 0:l(g5(e.kind)?E({optionId:e.id},U()):E({optionId:e.id,approved:!0},U())))},U=()=>b.trim()?{text:b}:{},ne=()=>{_||ee(()=>l==null?void 0:l({text:b}))},re=()=>{_||ee(()=>l==null?void 0:l({approved:!1}))},ie=e=>{e.confirm?(L(),y(e.id)):H(e)},ae=v==null||z==null?void 0:z.find(e=>e.id===v),oe=y5(c),se=oe&&l!=null&&(c==null?void 0:c.dismissible)===!0?(0,J.jsx)($G,{size:`sm`,variant:`outline`,className:n5,onClick:re,disabled:_,children:`关闭`}):null,ce=S?(0,J.jsx)(`p`,{role:`alert`,className:`aui-tool-fallback-approval-error text-destructive text-xs whitespace-pre-line`,children:S}):null,le=B?(0,J.jsxs)(`div`,{className:`aui-tool-fallback-approval-answer flex flex-col items-start gap-2`,children:[(0,J.jsx)(G8,{value:b,onChange:e=>x(e.target.value),disabled:_,"aria-label":oe?(t=c==null?void 0:c.prompt)==null?`答案`:t:`备注`,placeholder:oe?`请输入你的答案`:`填写决策备注`}),oe&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)($G,{size:`sm`,className:n5,onClick:ne,disabled:_,children:`发送`}),se]})]}):null;if((c==null?void 0:c.display)===`questions`&&l){var ue;return(0,J.jsxs)(`div`,E(E({"data-slot":`tool-fallback-approval`,tabIndex:-1,className:Q(`aui-tool-fallback-approval flex flex-col gap-3 pt-1`,n)},d),{},{ref:F,children:[R,(0,J.jsx)(E5,{questions:(ue=c.questions)==null?[]:ue,dismissible:c.dismissible===!0,locked:_,onSend:e=>ee(()=>l({answers:e})),onDismiss:re}),ce]}))}if(ae){var de,fe;let e=typeof ae.confirm==`object`?ae.confirm:void 0,t=(de=e==null?void 0:e.description)==null?ae.description:de;return(0,J.jsxs)(`div`,E(E({"data-slot":`tool-fallback-approval-confirm`,tabIndex:-1,className:Q(`aui-tool-fallback-approval-confirm flex flex-col gap-2 pt-1`,n)},d),{},{ref:F,children:[(0,J.jsx)(`p`,{className:`aui-tool-fallback-approval-confirm-title font-semibold`,children:(fe=e==null?void 0:e.title)==null?`${v5(ae)}?`:fe}),t&&(0,J.jsx)(`p`,{className:`aui-tool-fallback-approval-confirm-description text-muted-foreground whitespace-pre-line`,children:t}),ae.grants&&ae.grants.length>0&&(0,J.jsx)(`ul`,{className:`aui-tool-fallback-approval-confirm-grants flex flex-col gap-1`,children:ae.grants.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(`code`,{className:`aui-tool-fallback-approval-confirm-grant bg-muted rounded px-1.5 py-0.5 text-xs`,children:e})},e))}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)($G,{size:`sm`,className:n5,onClick:()=>H(ae),disabled:_,children:`确认`}),(0,J.jsx)($G,{size:`sm`,variant:`outline`,className:n5,onClick:()=>{L(),y(null)},disabled:_,children:`返回`})]})]}))}if(z&&z.length>0){let e=z.filter(e=>_5(e.kind)),t=z.filter(e=>!g5(e.kind)),r=z.filter(e=>g5(e.kind)&&!_5(e.kind));return(0,J.jsxs)(`div`,E(E({"data-slot":`tool-fallback-approval`,tabIndex:-1,className:Q(`aui-tool-fallback-approval flex flex-col gap-2 pt-1`,n)},d),{},{ref:F,children:[R,(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[[...e,...t,...r].map(t=>(0,J.jsx)($G,{size:`sm`,variant:t===e[0]?`default`:`outline`,className:n5,onClick:()=>ie(t),disabled:_,children:v5(t)},t.id)),r.length===0&&!oe&&(0,J.jsx)($G,{size:`sm`,variant:`outline`,className:n5,onClick:()=>V(!1),disabled:_,children:`拒绝`}),!B&&se]}),le,ce]}))}return oe?(0,J.jsxs)(`div`,E(E({"data-slot":`tool-fallback-approval`,tabIndex:-1,className:Q(`aui-tool-fallback-approval flex flex-col gap-2 pt-1`,n)},d),{},{ref:F,children:[R,le,!B&&se&&(0,J.jsx)(`div`,{className:`flex items-center gap-2`,children:se}),ce]})):(0,J.jsxs)(`div`,E(E({"data-slot":`tool-fallback-approval`,tabIndex:-1,className:Q(`aui-tool-fallback-approval flex flex-col gap-2 pt-1`,n)},d),{},{ref:F,children:[R,(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)($G,{size:`sm`,className:n5,onClick:()=>V(!0),disabled:_,children:`允许`}),(0,J.jsx)($G,{size:`sm`,variant:`outline`,className:n5,onClick:()=>V(!1),disabled:_,children:`拒绝`})]}),le,ce]}))}var A5=(0,h.memo)(({toolName:e,argsText:t,result:n,status:r,responseDeliveryStatus:i,addResult:a,resume:o,interrupt:s,approval:c,respondToApproval:l})=>{let u=(r==null?void 0:r.type)===`incomplete`&&r.reason===`cancelled`,d=(r==null?void 0:r.type)===`requires-action`,f=c!=null||d&&D5(r,c,s),[p,m]=(0,h.useState)(d),[g,_]=(0,h.useState)(d);d!==g&&(_(d),d&&m(!0));let v=(0,h.useRef)(!1),y=(0,h.useRef)(null),b=(0,h.useRef)(null);return(0,h.useLayoutEffect)(()=>{let e=y.current;if(!e||e.isConnected||d||!v.current)return;let t=c==null||!S5(c);v.current=!1;let{activeElement:n,body:r}=e.ownerDocument;if(t&&(n==null||n===r)){var i;(i=b.current)==null||i.focus({preventScroll:!0})}},[c,d,r==null?void 0:r.type]),(0,J.jsxs)(r5,{open:p,onOpenChange:m,children:[(0,J.jsx)(s5,{toolName:e,status:r,responseDeliveryStatus:i}),(0,J.jsxs)(c5,{children:[(0,J.jsx)(f5,{status:r}),(0,J.jsx)(l5,{argsText:t,className:Q(u&&`opacity-60`)}),f&&(0,J.jsx)(O5,{addResult:a,resume:o,interrupt:s,approval:c,respondToApproval:l,status:r,onFocusCapture:e=>{var t;let n=e.currentTarget.closest(`[data-slot="tool-fallback-root"]`);b.current=(t=n==null?void 0:n.querySelector(`[data-slot="tool-fallback-trigger"]`))==null?null:t,y.current=e.currentTarget,v.current=!0},onBlurCapture:e=>{let t=e.relatedTarget;(t?e.currentTarget.contains(t):e.currentTarget.contains(e.currentTarget.ownerDocument.activeElement))||(v.current=!1)}}),(0,J.jsx)(d5,{result:n})]})]})});A5.displayName=`ToolFallback`,A5.Root=r5,A5.Trigger=s5,A5.Content=c5,A5.Args=l5,A5.Result=d5,A5.Error=f5,A5.Approval=O5;var j5=[`className`,`variant`,`open`,`onOpenChange`,`defaultOpen`,`children`],M5=[`count`,`active`,`className`],N5=[`className`,`children`],P5=200,F5=XG(`aui-tool-group-root group/tool-group w-full`,{variants:{variant:{outline:`rounded-lg border py-3`,ghost:``,muted:`border-muted-foreground/30 bg-muted/30 rounded-lg border py-3`}},defaultVariants:{variant:`outline`}});function I5(e){let{className:t,variant:n,open:r,onOpenChange:i,defaultOpen:a=!1,children:o}=e,s=W(e,j5),c=(0,h.useRef)(null),[l,u]=(0,h.useState)(a),d=YP(c,P5),f=r!==void 0,p=f?r:l,m=(0,h.useCallback)(e=>{d(),f||u(e),i==null||i(e)},[d,f,i]);return(0,J.jsx)(C8,E(E({ref:c,"data-slot":`tool-group-root`,"data-variant":n==null?`outline`:n,open:p,onOpenChange:m,className:Q(F5({variant:n}),`group/tool-group-root`,t),style:{"--animation-duration":`${P5}ms`}},s),{},{children:o}))}function L5(e){let{count:t,active:n=!1,className:r}=e,i=W(e,M5),a=`${t} 次工具调用`;return(0,J.jsxs)(w8,E(E({"data-slot":`tool-group-trigger`,className:Q(`aui-tool-group-trigger group/trigger flex origin-left items-center gap-2 text-sm transition-[color,scale] active:scale-[0.98]`,`group-data-[variant=ghost]/tool-group-root:text-muted-foreground group-data-[variant=ghost]/tool-group-root:hover:text-foreground group-data-[variant=ghost]/tool-group-root:py-1.5`,`group-data-[variant=outline]/tool-group-root:w-full group-data-[variant=outline]/tool-group-root:px-4`,`group-data-[variant=muted]/tool-group-root:w-full group-data-[variant=muted]/tool-group-root:px-4`,r)},i),{},{children:[n&&(0,J.jsx)(HI,{"data-slot":`tool-group-trigger-loader`,className:`aui-tool-group-trigger-loader size-3 shrink-0 animate-spin [animation-duration:0.6s]`}),(0,J.jsx)(`span`,{"data-slot":`tool-group-trigger-label`,className:Q(`aui-tool-group-trigger-label-wrapper inline-block text-start text-xs leading-none font-medium`,`group-data-[variant=ghost]/tool-group-root:font-normal`,`group-data-[variant=outline]/tool-group-root:grow`,`group-data-[variant=muted]/tool-group-root:grow`,n&&`shimmer motion-reduce:animate-none`),children:a}),(0,J.jsx)(fI,{"data-slot":`tool-group-trigger-chevron`,className:Q(`aui-tool-group-trigger-chevron size-3 shrink-0`,`transition-transform duration-(--animation-duration) ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:transition-none`,`-rotate-90`,`group-data-open/trigger:rotate-0`,`group-data-panel-open/trigger:rotate-0`)})]}))}function R5(e){let{className:t,children:n}=e,r=W(e,N5);return(0,J.jsx)(T8,E(E({"data-slot":`tool-group-content`,className:Q(`aui-tool-group-content relative overflow-hidden text-sm outline-none`,`group/collapsible-content ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none`,`data-closed:animate-collapsible-up`,`data-open:animate-collapsible-down`,`data-closed:fill-mode-forwards`,`data-closed:pointer-events-none`,`[--tw-duration:var(--animation-duration)]`,t)},r),{},{children:(0,J.jsx)(`div`,{className:Q(`mt-2 flex flex-col gap-2`,`group-data-[variant=ghost]/tool-group-root:mt-1 group-data-[variant=ghost]/tool-group-root:gap-1`,`group-data-[variant=outline]/tool-group-root:mt-3 group-data-[variant=outline]/tool-group-root:border-t group-data-[variant=outline]/tool-group-root:px-4 group-data-[variant=outline]/tool-group-root:pt-3`,`group-data-[variant=muted]/tool-group-root:mt-3 group-data-[variant=muted]/tool-group-root:border-t group-data-[variant=muted]/tool-group-root:px-4 group-data-[variant=muted]/tool-group-root:pt-3`,`[&>*]:animate-in [&>*]:fade-in-0 [&>*]:blur-in-[2px] [&>*]:slide-in-from-top-1 [&>*]:animation-duration-(--animation-duration) [&>*]:ease-[cubic-bezier(0.32,0.72,0,1)]`,`[&>*]:motion-reduce:animate-none`,`[&>*:nth-child(2)]:[animation-delay:40ms]`,`[&>*:nth-child(3)]:[animation-delay:80ms]`,`[&>*:nth-child(4)]:[animation-delay:120ms]`,`[&>*:nth-child(n+5)]:[animation-delay:160ms]`),children:n})}))}var z5=(0,h.memo)(({children:e,startIndex:t,endIndex:n})=>{let r=n-t+1;return(0,J.jsxs)(I5,{children:[(0,J.jsx)(L5,{count:r}),(0,J.jsx)(R5,{children:e})]})});z5.displayName=`ToolGroup`,z5.Root=I5,z5.Trigger=L5,z5.Content=R5;var B5=[`className`];function V5(e){let{className:t}=e,n=W(e,B5);return(0,J.jsx)(`div`,E({"data-slot":`skeleton`,className:Q(`animate-pulse rounded-md bg-muted`,t)},n))}var H5=[`className`],U5=({group:e,children:t})=>{let[n,r]=(0,h.useState)(!1);return(0,J.jsxs)(I5,{variant:`ghost`,open:n||e.counts.requiresAction>0,onOpenChange:r,children:[(0,J.jsx)(L5,{count:e.indices.length,active:e.status.type===`running`}),(0,J.jsx)(R5,{children:t})]})},W5=e=>!!e.thread.canResume&&e.composer.type===`thread`&&e.composer.isEmpty,G5=e=>(e==null?void 0:e.completedAt)===void 0?void 0:Number(((e.completedAt-e.startedAt)/1e3).toFixed(1)),K5=p_({reasoning:[`group-chainOfThought`,`group-reasoning`],"tool-call":[`group-chainOfThought`,`group-reasoning`],"standalone-tool-call":[]}),q5=[`group-chainOfThought`,`group-task`],J5=(e,t)=>{var n;let r=K5(e,t);return e.type===`tool-call`&&e.messages!==void 0&&r.length>0&&!(t!=null&&(n=t.toolUIs)!=null&&(n=n[e.toolName])!=null&&n.length)?q5:r},Y5={},X5=(0,h.createContext)(Y5),Z5=e=>e.thread.messages.length===0&&(!e.thread.isLoading||e.threads.isLoading),Q5=e=>e.thread.messages.length===0&&e.thread.isLoading&&!e.thread.isDisabled&&!e.threads.isLoading,$5=()=>(0,J.jsxs)(`div`,{"data-slot":`aui_thread-history-skeleton`,role:`status`,className:`animate-in fade-in fill-mode-both flex flex-col gap-y-6 [animation-delay:150ms] [animation-duration:200ms]`,children:[(0,J.jsx)(`span`,{className:`sr-only`,children:`正在加载对话`}),(0,J.jsx)(V5,{className:`ml-auto h-9 w-2/5 rounded-xl motion-reduce:animate-none`}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-y-2`,children:[(0,J.jsx)(V5,{className:`h-4 w-11/12 motion-reduce:animate-none`}),(0,J.jsx)(V5,{className:`h-4 w-4/5 motion-reduce:animate-none`}),(0,J.jsx)(V5,{className:`h-4 w-3/5 motion-reduce:animate-none`})]}),(0,J.jsx)(V5,{className:`ml-auto h-9 w-1/3 rounded-xl motion-reduce:animate-none`}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-y-2`,children:[(0,J.jsx)(V5,{className:`h-4 w-10/12 motion-reduce:animate-none`}),(0,J.jsx)(V5,{className:`h-4 w-2/3 motion-reduce:animate-none`})]})]}),e7=({components:e=Y5,autoFocus:t=!0})=>{let n=q(Z5);return(0,J.jsx)(X5.Provider,{value:e,children:(0,J.jsx)(t7,{isEmpty:n,autoFocus:t})})},t7=({isEmpty:e,autoFocus:t})=>{let{Welcome:n=d7}=(0,h.useContext)(X5);return(0,J.jsx)(yP.Root,{className:`aui-root aui-thread-root bg-background @container flex h-full flex-col`,style:{"--thread-max-width":`44rem`,"--composer-bg":`color-mix(in oklab, var(--color-muted) 30%, transparent)`,"--composer-radius":`1rem`,"--composer-padding":`8px`},children:(0,J.jsx)(yP.Viewport,{turnAnchor:`top`,"data-slot":`aui_thread-viewport`,className:`relative flex flex-1 flex-col overflow-x-auto overflow-y-scroll scroll-smooth`,children:(0,J.jsxs)(`div`,{className:Q(`mx-auto flex w-full max-w-(--thread-max-width) flex-1 flex-col px-4 pt-4`,e&&`justify-center`),children:[(0,J.jsx)(Sd,{condition:Z5,children:(0,J.jsx)(n,{})}),(0,J.jsx)(Sd,{condition:Q5,children:(0,J.jsx)($5,{})}),(0,J.jsx)(l7,{}),(0,J.jsx)(`div`,{"data-slot":`aui_message-group`,className:`mb-14 flex flex-col gap-y-6 empty:hidden`,children:(0,J.jsx)(yP.Messages,{children:()=>(0,J.jsx)(n7,{})})}),(0,J.jsxs)(yP.ViewportFooter,{className:Q(`aui-thread-viewport-footer bg-background flex flex-col gap-2 overflow-visible pb-4 md:pb-6`,!e&&`sticky bottom-0 mt-auto rounded-t-(--composer-radius)`),children:[(0,J.jsx)(u7,{}),(0,J.jsx)(Eq,{}),!e&&(0,J.jsx)(`div`,{className:`mx-auto flex w-full max-w-(--thread-max-width) justify-start`,children:(0,J.jsxs)(RP.New,{render:(0,J.jsx)(`button`,{type:`button`,className:`inline-flex h-6 items-center gap-1 rounded text-xs text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`}),children:[(0,J.jsx)(iL,{className:`size-3`}),`新建对话`]})}),(0,J.jsx)(m7,{autoFocus:t}),(0,J.jsx)(Sd,{condition:e=>Z5(e)&&e.composer.isEmpty,children:(0,J.jsx)(f7,{})})]})]})})})},n7=()=>{let{AssistantMessage:e=_7}=(0,h.useContext)(X5),t=q(e=>e.message.role),n=q(e=>e.message.composer.isEditing),r=q(e=>e.message.metadata.modality===`voice`);return n?(0,J.jsx)(w7,{}):r?(0,J.jsx)(a7,{}):t===`user`?(0,J.jsx)(S7,{}):(0,J.jsx)(e,{})},r7=()=>q(e=>{var t,n;let r=((t=e.thread.messages[e.message.index-1])==null?void 0:t.metadata.modality)===`voice`,i=((n=e.thread.messages[e.message.index+1])==null?void 0:n.metadata.modality)===`voice`;return r?i?`middle`:`end`:i?`start`:`single`}),i7=({text:e})=>(0,J.jsx)(`p`,{className:`aui-spoken-message-text m-0`,children:e}),a7=()=>{let e=q(e=>e.message.role),t=r7(),n=q(e=>{var t;return e.message.role===`assistant`&&((t=e.message.status)==null?void 0:t.type)===`running`}),r=t===`start`||t===`single`;return(0,J.jsxs)(ON.Root,{"data-slot":`aui_spoken-message-root`,"data-role":e,"data-voice-run":t,className:Q(`aui-spoken-message bg-muted/40 mx-2 px-3 py-1.5 [contain-intrinsic-size:auto_48px] [content-visibility:auto]`,t===`single`&&`rounded-xl py-2`,t===`start`&&`rounded-t-xl pt-2`,t===`middle`&&`-mt-6`,t===`end`&&`-mt-6 rounded-b-xl pb-2`),children:[r&&(0,J.jsxs)(`div`,{"data-slot":`aui_spoken-exchange-header`,className:`text-muted-foreground mb-1.5 flex items-center gap-1.5 text-xs`,children:[(0,J.jsx)(eL,{className:`size-3`,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:`语音对话`})]}),(0,J.jsxs)(`div`,{"data-slot":`aui_spoken-message-content`,className:`text-foreground flex items-start gap-2 text-sm leading-relaxed`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground mt-1 shrink-0`,"aria-hidden":!0,children:e===`user`?(0,J.jsx)(JI,{className:`size-3.5`}):(0,J.jsx)(iI,{className:`size-3.5`})}),(0,J.jsx)(`span`,{className:`sr-only`,children:e===`user`?`你说`:`助手说`}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 wrap-break-word`,children:[(0,J.jsx)(ON.Parts,{components:{Text:i7}}),n&&(0,J.jsx)(`span`,{"data-slot":`aui_spoken-message-indicator`,role:`status`,className:`text-muted-foreground ms-1 animate-pulse font-sans`,"aria-label":`助手正在说话`,children:`●`})]}),(0,J.jsx)(o7,{})]})]})},o7=()=>(0,J.jsx)(_k.Root,{hideWhenRunning:!0,autohide:`always`,className:`aui-spoken-action-bar text-muted-foreground flex shrink-0 gap-1`,children:(0,J.jsxs)(_k.Copy,{render:(0,J.jsx)(DK,{tooltip:`复制`,className:`size-6`}),children:[(0,J.jsx)(Sd,{condition:e=>e.message.isCopied,children:(0,J.jsx)(uI,{className:`animate-in zoom-in-50 fade-in duration-200 ease-out`})}),(0,J.jsx)(Sd,{condition:e=>!e.message.isCopied,children:(0,J.jsx)(wI,{className:`animate-in zoom-in-75 fade-in duration-150`})})]})}),s7=`a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex='-1']):not([disabled])`,c7=e=>{for(let t=e.nextElementSibling;t;t=t.nextElementSibling){let e=t.matches(s7)?t:t.querySelector(s7);if(e instanceof HTMLElement)return e}return null},l7=()=>{let e=qa(),t=q(e=>e.thread.hasEarlier),n=q(e=>e.thread.isLoadingEarlier),r=t||n,i=(0,h.useRef)(null),a=(0,h.useRef)(null),o=(0,h.useRef)(null),s=(0,h.useRef)(!1);return(0,h.useEffect)(()=>{if(!t||n){n||(s.current=!1);return}let r=a.current;if(!r)return;let i=r.closest(`[data-slot="aui_thread-viewport"]`);if(!i)return;let o=new IntersectionObserver(t=>{let n=t[0];n!=null&&n.isIntersecting&&!s.current&&(s.current=!0,e.thread.loadEarlier().catch(e=>{console.error(`加载更早的消息失败:`,e),s.current=!1}))},{root:i,rootMargin:`120px 0px 0px 0px`,threshold:0});return o.observe(r),()=>{o.disconnect()}},[e,t,n]),(0,h.useLayoutEffect)(()=>{var e;let t=o.current,n=i.current;if(r||!t||t.isConnected||!n)return;o.current=null;let a=document.activeElement;a&&a!==document.body||(e=c7(n))==null||e.focus()},[r]),(0,J.jsxs)(`div`,{ref:i,className:`contents`,onFocus:e=>{o.current=e.target},children:[(0,J.jsx)(`div`,{ref:a,"aria-hidden":`true`,className:`h-px w-full shrink-0`}),(0,J.jsx)(`span`,{role:`status`,className:`sr-only`,children:n?`正在加载更早的消息`:``}),r&&(0,J.jsx)(yP.LoadEarlier,{render:(0,J.jsx)($G,{variant:`ghost`,size:`sm`,"data-slot":`aui_thread-load-earlier`,className:`aui-thread-load-earlier text-muted-foreground mb-6 self-center rounded-full`}),children:(0,J.jsx)(`span`,{className:Q(n&&`shimmer motion-reduce:animate-none`),children:n?`正在加载更早的消息...`:`加载更早的消息`})})]})},u7=()=>(0,J.jsx)(yP.ScrollToBottom,{render:(0,J.jsx)(DK,{tooltip:`滚动到底部`,variant:`outline`,className:`aui-thread-scroll-to-bottom dark:border-border dark:bg-background dark:hover:bg-accent absolute -top-12 z-10 self-center rounded-full p-4 disabled:invisible`}),children:(0,J.jsx)(eI,{})}),d7=()=>(0,J.jsx)(`div`,{className:`aui-thread-welcome-root mb-6 flex flex-col px-2`,children:(0,J.jsx)(`p`,{className:`aui-thread-welcome-message-inner fade-in slide-in-from-bottom-1 animate-in fill-mode-both text-2xl font-medium tracking-tight text-foreground duration-200 text-center`,children:`今天有什么可以帮你?`})}),f7=()=>(0,J.jsx)(`div`,{className:`aui-thread-welcome-suggestions flex w-full flex-col`,children:(0,J.jsx)(yP.Suggestions,{children:()=>(0,J.jsx)(p7,{})})}),p7=()=>(0,J.jsx)(`div`,{className:`aui-thread-welcome-suggestion-display fade-in slide-in-from-bottom-2 animate-in fill-mode-both duration-200`,children:(0,J.jsxs)(EP.Trigger,{send:!0,render:(0,J.jsx)(`button`,{type:`button`,className:`aui-thread-welcome-suggestion group hover:bg-foreground/[0.03] focus-visible:ring-ring/50 flex w-full items-baseline gap-2.5 rounded-md px-2 py-2 text-start text-sm transition-colors outline-none focus-visible:ring-1 motion-reduce:transition-none`}),children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/60 group-hover:text-foreground font-mono text-xs transition-colors motion-reduce:transition-none`,children:`>`}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[(0,J.jsx)(EP.Title,{className:`aui-thread-welcome-suggestion-text-1 text-foreground`}),` `,(0,J.jsx)(EP.Description,{className:`aui-thread-welcome-suggestion-text-2 text-muted-foreground empty:hidden`})]})]})}),m7=({autoFocus:e})=>(0,J.jsx)(pM.Root,{className:`aui-composer-root relative flex w-full flex-col`,children:(0,J.jsxs)(pM.AttachmentDropzone,{render:(0,J.jsx)(`div`,{"data-slot":`aui_composer-shell`,className:`border-foreground/10 focus-within:border-foreground/25 data-[dragging=true]:border-ring flex w-full cursor-text flex-col gap-2 rounded-(--composer-radius) border bg-(--composer-bg) p-(--composer-padding) transition-[border-color] data-[dragging=true]:border-dashed data-[dragging=true]:bg-[color-mix(in_oklab,var(--color-accent)_50%,var(--color-background))]`}),children:[(0,J.jsx)(UK,{}),(0,J.jsx)(pM.Input,{placeholder:`请输入你的问题...`,className:`aui-composer-input text-foreground caret-primary placeholder:text-muted-foreground/60 max-h-48 min-h-10 w-full resize-none bg-transparent px-2.5 py-1 text-base leading-6 outline-none`,rows:1,autoFocus:e,enterKeyHint:`send`,"aria-label":`消息输入框`}),(0,J.jsx)(h7,{})]})}),h7=()=>{let{ComposerExtra:e}=(0,h.useContext)(X5),t=q(e=>e.composer.submission!==void 0&&!(e.thread.isRunning&&e.thread.capabilities.cancel));return(0,J.jsxs)(`div`,{className:`aui-composer-action-wrapper relative flex items-center justify-between`,children:[e?(0,J.jsxs)(`div`,{className:`aui-composer-action-start flex items-center gap-1.5`,children:[(0,J.jsx)(WK,{}),(0,J.jsx)(e,{})]}):(0,J.jsx)(WK,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsxs)(Sd,{condition:e=>e.thread.capabilities.dictation,children:[(0,J.jsx)(Sd,{condition:e=>e.composer.dictation==null,children:(0,J.jsx)(pM.Dictate,{render:(0,J.jsx)(DK,{tooltip:`语音输入`,side:`bottom`,type:`button`,variant:`ghost`,size:`icon`,className:`aui-composer-dictate text-muted-foreground hover:text-foreground size-7 rounded-full`,"aria-label":`开始语音输入`}),children:(0,J.jsx)(JI,{className:`aui-composer-dictate-icon size-4`})})}),(0,J.jsx)(Sd,{condition:e=>e.composer.dictation!=null,children:(0,J.jsx)(pM.StopDictation,{render:(0,J.jsx)(DK,{tooltip:`停止语音输入`,side:`bottom`,type:`button`,variant:`ghost`,size:`icon`,className:`aui-composer-stop-dictation text-destructive size-7 rounded-full`,"aria-label":`停止语音输入`}),children:(0,J.jsx)(uL,{className:`aui-composer-stop-dictation-icon size-3.5 animate-pulse fill-current`})})})]}),(0,J.jsx)(Sd,{condition:e=>(!e.composer.canCancel||e.thread.voice!==void 0&&e.composer.submission===void 0)&&!W5(e),children:(0,J.jsx)(pM.Send,{render:(0,J.jsx)(DK,{tooltip:`发送消息`,side:`bottom`,type:`button`,variant:`default`,size:`icon`,className:`aui-composer-send size-7 rounded-full`,"aria-label":`发送消息`}),children:(0,J.jsx)(nI,{className:`aui-composer-send-icon size-4`})})}),(0,J.jsx)(Sd,{condition:W5,children:(0,J.jsx)(pM.Resume,{render:(0,J.jsx)(DK,{tooltip:`继续生成`,side:`bottom`,type:`button`,variant:`default`,size:`icon`,className:`aui-composer-resume size-7 rounded-full`,"aria-label":`继续生成`}),children:(0,J.jsx)(nL,{className:`aui-composer-resume-icon size-4`})})}),(0,J.jsx)(Sd,{condition:e=>e.composer.canCancel&&(e.thread.voice===void 0||e.composer.submission!==void 0),children:(0,J.jsx)(pM.Cancel,{render:(0,J.jsx)($G,{type:`button`,variant:`default`,size:`icon`,className:`aui-composer-cancel size-7 rounded-full`,"aria-label":t?`取消发送`:`停止生成`}),children:(0,J.jsx)(uL,{className:`aui-composer-cancel-icon size-3.5 fill-current`})})})]})]})},g7=()=>(0,J.jsx)(ON.Error,{children:(0,J.jsx)(VM.Root,{className:`aui-message-error-root border-destructive bg-destructive/10 text-destructive dark:bg-destructive/5 mt-2 rounded-md border p-3 text-sm dark:text-red-200`,children:(0,J.jsx)(VM.Message,{className:`aui-message-error-message line-clamp-2`})})}),_7=()=>{let{ToolFallback:e=A5,ToolGroup:t,ReasoningGroup:n,TaskGroup:r}=(0,h.useContext)(X5),i=r?J5:K5;return(0,J.jsxs)(ON.Root,{"data-slot":`aui_assistant-message-root`,"data-role":`assistant`,className:`fade-in slide-in-from-bottom-1 animate-in relative -mb-7.5 pb-7.5 duration-150 [contain-intrinsic-size:auto_200px] [content-visibility:auto]`,children:[(0,J.jsxs)(`div`,{"data-slot":`aui_assistant-message-content`,className:`text-foreground px-2 text-left leading-relaxed wrap-break-word`,children:[(0,J.jsx)(ON.GroupedParts,{groupBy:i,children:({part:i,children:a})=>{switch(i.type){case`group-chainOfThought`:return(0,J.jsx)(`div`,{"data-slot":`aui_chain-of-thought`,children:a});case`group-task`:return r?(0,J.jsx)(r,{group:i}):null;case`group-tool`:return t?(0,J.jsx)(t,{group:i,children:a}):(0,J.jsx)(U5,{group:i,children:a});case`group-reasoning`:{if(n)return(0,J.jsx)(n,{group:i,children:a});let e=i.status.type===`running`;return(0,J.jsxs)(z8,{streaming:e,children:[(0,J.jsx)(F8,{active:e,duration:G5(i.timing)}),(0,J.jsx)(I8,{"aria-busy":e,children:(0,J.jsx)(L8,{children:a})})]})}case`text`:return(0,J.jsx)(K6,{});case`reasoning`:return(0,J.jsx)(H8,E({},i));case`tool-call`:var o;return(o=i.toolUI)==null?(0,J.jsx)(e,E({},i)):o;case`data`:return i.dataRendererUI;case`file`:return(0,J.jsx)(`div`,{"data-slot":`aui_assistant-message-file`,className:`py-1`,children:(0,J.jsx)(y7,E({},i))});case`image`:return(0,J.jsx)(`div`,{"data-slot":`aui_assistant-message-image`,className:`py-1`,children:(0,J.jsx)($q,E({},i))});case`indicator`:return(0,J.jsx)(`span`,{"data-slot":`aui_assistant-message-indicator`,className:`animate-pulse font-sans`,"aria-label":`助手正在处理`,children:`●`});default:return null}}}),(0,J.jsx)(g7,{})]}),(0,J.jsxs)(`div`,{"data-slot":`aui_assistant-message-footer`,className:Q(`ms-2 flex items-center`,`min-h-7.5 pt-1.5`),children:[(0,J.jsx)(T7,{}),(0,J.jsx)(v7,{})]})]})},v7=()=>(0,J.jsxs)(_k.Root,{hideWhenRunning:!0,autohide:`not-last`,className:`aui-assistant-action-bar-root text-muted-foreground animate-in fade-in col-start-3 row-start-2 -ms-1 flex gap-1 duration-200`,children:[(0,J.jsxs)(_k.Copy,{render:(0,J.jsx)(DK,{tooltip:`复制`}),children:[(0,J.jsx)(Sd,{condition:e=>e.message.isCopied,children:(0,J.jsx)(uI,{className:`animate-in zoom-in-50 fade-in duration-200 ease-out`})}),(0,J.jsx)(Sd,{condition:e=>!e.message.isCopied,children:(0,J.jsx)(wI,{className:`animate-in zoom-in-75 fade-in duration-150`})})]}),(0,J.jsxs)(Sd,{condition:e=>e.thread.capabilities.feedback,children:[(0,J.jsx)(_k.FeedbackPositive,{render:(0,J.jsx)(DK,{tooltip:`有帮助`,className:`data-[submitted=true]:bg-accent data-[submitted=true]:text-accent-foreground`}),children:(0,J.jsx)(fL,{})}),(0,J.jsx)(_k.FeedbackNegative,{render:(0,J.jsx)(DK,{tooltip:`没有帮助`,className:`data-[submitted=true]:bg-accent data-[submitted=true]:text-accent-foreground`}),children:(0,J.jsx)(mL,{})})]}),(0,J.jsx)(_k.Reload,{render:(0,J.jsx)(DK,{tooltip:`重新生成`}),children:(0,J.jsx)(oL,{})}),(0,J.jsxs)(Nk.Root,{children:[(0,J.jsx)(Nk.Trigger,{render:(0,J.jsx)(DK,{tooltip:`更多`,className:`data-[state=open]:bg-accent`}),children:(0,J.jsx)(AI,{})}),(0,J.jsx)(Nk.Content,{side:`bottom`,align:`start`,sideOffset:6,className:`aui-action-bar-more-content bg-popover text-popover-foreground data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-xl border p-1.5`,children:(0,J.jsxs)(_k.ExportMarkdown,{render:(0,J.jsx)(Nk.Item,{className:`aui-action-bar-more-item hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground flex items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`}),children:[(0,J.jsx)(EI,{className:`size-4`}),`导出为 Markdown`]})})]})]}),y7=e=>{let t=e.mimeType.toLowerCase().startsWith(`image/`)?fq(e.data,e.mimeType,e.sourceType):null;return t?(0,J.jsx)($q,E({type:`image`,image:t,status:e.status},e.filename!==void 0&&{filename:e.filename})):(0,J.jsx)(wq,E({},e))},b7=e=>(0,J.jsx)(`div`,{"data-slot":`aui_user-message-file`,className:`py-1`,children:(0,J.jsx)(y7,E({},e))}),x7=e=>(0,J.jsx)(`div`,{"data-slot":`aui_user-message-image`,className:`py-1`,children:(0,J.jsx)($q,E({},e))}),S7=()=>(0,J.jsxs)(ON.Root,{"data-slot":`aui_user-message-root`,className:`fade-in slide-in-from-bottom-1 animate-in grid auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] content-start gap-y-2 px-2 duration-150 [contain-intrinsic-size:auto_200px] [content-visibility:auto] [&:where(>*)]:col-start-2`,"data-role":`user`,children:[(0,J.jsx)(HK,{}),(0,J.jsx)(`div`,{className:`aui-user-message-content-wrapper relative col-start-2 min-w-0`,children:(0,J.jsx)(`div`,{className:`aui-user-message-content peer rounded-(--composer-radius) bg-muted px-4 py-2 text-foreground wrap-break-word empty:hidden`,children:(0,J.jsx)(ON.Parts,{components:{File:b7,Image:x7}})})}),(0,J.jsx)(`div`,{className:`col-start-2 -mt-1 flex justify-end min-h-8`,children:(0,J.jsx)(C7,{})}),(0,J.jsx)(T7,{"data-slot":`aui_user-branch-picker`,className:`col-span-full col-start-1 -me-1 justify-end`})]}),C7=()=>(0,J.jsxs)(_k.Root,{hideWhenRunning:!0,autohide:`not-last`,className:`aui-user-action-bar-root flex flex-row items-center gap-1`,children:[(0,J.jsxs)(_k.Copy,{render:(0,J.jsx)(DK,{tooltip:`复制`,className:`aui-user-action-copy size-8 rounded-md text-muted-foreground hover:bg-accent hover:text-foreground`}),children:[(0,J.jsx)(Sd,{condition:e=>e.message.isCopied,children:(0,J.jsx)(uI,{className:`animate-in zoom-in-50 fade-in duration-200 ease-out`})}),(0,J.jsx)(Sd,{condition:e=>!e.message.isCopied,children:(0,J.jsx)(wI,{className:`animate-in zoom-in-75 fade-in duration-150`})})]}),(0,J.jsx)(_k.Edit,{render:(0,J.jsx)(DK,{tooltip:`编辑`,className:`aui-user-action-edit size-8 rounded-md text-muted-foreground hover:bg-accent hover:text-foreground`}),children:(0,J.jsx)(QI,{className:`size-4`})})]}),w7=()=>(0,J.jsx)(ON.Root,{"data-slot":`aui_edit-composer-wrapper`,className:`flex flex-col px-2 [contain-intrinsic-size:auto_200px] [content-visibility:auto]`,children:(0,J.jsxs)(pM.Root,{className:`aui-edit-composer-root border-foreground/10 focus-within:border-foreground/25 ms-auto flex w-full max-w-[85%] cursor-text flex-col rounded-(--composer-radius) border bg-(--composer-bg) transition-[border-color]`,children:[(0,J.jsx)(pM.Input,{className:`aui-edit-composer-input text-foreground min-h-14 w-full resize-none bg-transparent px-4 pt-3 pb-1 text-base outline-none`,autoFocus:!0}),(0,J.jsxs)(`div`,{className:`aui-edit-composer-footer mx-2.5 mb-2.5 flex items-center gap-1.5 self-end`,children:[(0,J.jsx)(pM.Cancel,{render:(0,J.jsx)($G,{variant:`ghost`,size:`sm`,className:`h-8 px-3`}),children:`取消`}),(0,J.jsx)(pM.Send,{render:(0,J.jsx)($G,{size:`sm`,className:`h-8 px-3`}),children:`更新`})]})]})}),T7=e=>{let{className:t}=e,n=W(e,H5);return(0,J.jsxs)(Zk.Root,E(E({hideWhenSingleBranch:!0,className:Q(`aui-branch-picker-root text-muted-foreground -ms-2 me-2 inline-flex items-center text-xs`,t)},n),{},{children:[(0,J.jsx)(Zk.Previous,{render:(0,J.jsx)(DK,{tooltip:`上一条回复`}),children:(0,J.jsx)(mI,{})}),(0,J.jsxs)(`span`,{className:`aui-branch-picker-state font-medium`,children:[(0,J.jsx)(Zk.Number,{}),` /`,` `,(0,J.jsx)(Zk.Count,{})]}),(0,J.jsx)(Zk.Next,{render:(0,J.jsx)(DK,{tooltip:`下一条回复`}),children:(0,J.jsx)(gI,{})})]}))};function E7({onSelect:e}){return(0,J.jsxs)(`div`,{className:`flex h-full flex-col bg-background text-foreground`,children:[(0,J.jsx)(`div`,{className:`p-4`,children:(0,J.jsxs)(RP.New,{render:(0,J.jsx)(`button`,{type:`button`,onClick:e,className:`\r
94
+ flex w-full items-center justify-center gap-2\r
95
+ rounded-lg border border-border\r
96
+ bg-background px-4 py-3\r
97
+ text-sm font-medium text-foreground\r
98
+ transition-colors\r
99
+ hover:bg-accent hover:text-accent-foreground\r
100
+ `}),children:[(0,J.jsx)(iL,{className:`size-4`}),`新建对话`]})}),(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 pb-4`,children:[(0,J.jsx)(`div`,{className:`mb-3 px-2 text-xs font-medium text-muted-foreground`,children:`历史对话`}),(0,J.jsx)(RP.Items,{children:({threadListItem:t})=>(0,J.jsxs)(GP.Root,{className:`\r
101
+ group mb-1 flex items-center rounded-lg\r
102
+ text-foreground transition-colors\r
103
+ hover:bg-accent hover:text-accent-foreground\r
104
+ data-active:bg-accent\r
105
+ data-active:text-accent-foreground\r
106
+ `,children:[(0,J.jsxs)(GP.Trigger,{render:(0,J.jsx)(`button`,{type:`button`,onClick:e,className:`\r
107
+ flex min-w-0 flex-1 items-center gap-3\r
108
+ px-3 py-3 text-left text-sm\r
109
+ `}),children:[(0,J.jsx)(WI,{className:`size-4 shrink-0 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:(0,J.jsx)(GP.Title,{fallback:`新对话`})})]}),(0,J.jsx)(GP.Delete,{render:(0,J.jsx)(`button`,{type:`button`,className:`\r
110
+ mr-2 rounded-md p-2\r
111
+ text-muted-foreground\r
112
+ opacity-0 transition-colors\r
113
+ hover:bg-destructive/10\r
114
+ hover:text-destructive\r
115
+ group-hover:opacity-100\r
116
+ focus-visible:opacity-100\r
117
+ `,title:`删除对话`}),children:(0,J.jsx)(gL,{className:`size-4`})})]},t.id)})]})]})}function D7(e){let{theme:t}=e,[n,r]=(0,h.useState)(`chat`),i=()=>{r(`chat`)};return(0,h.useEffect)(()=>{NF(t)},[t]),(0,J.jsxs)(RP.Root,{className:`flex h-full min-h-0 w-full flex-col overflow-hidden`,children:[(0,J.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center border-b bg-background px-2`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:i,className:`flex h-9 flex-1 items-center justify-center gap-2 rounded-md text-sm transition-colors ${n===`chat`?`bg-accent font-medium text-foreground`:`text-muted-foreground hover:bg-accent/50`}`,children:[(0,J.jsx)(WI,{className:`size-4`}),`对话`]}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>r(`conversations`),className:`flex h-9 flex-1 items-center justify-center gap-2 rounded-md text-sm transition-colors ${n===`conversations`?`bg-accent font-medium text-foreground`:`text-muted-foreground hover:bg-accent/50`}`,children:[(0,J.jsx)(KI,{className:`size-4`}),`所有对话`]})]}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 flex-col overflow-hidden ${n===`chat`?`flex`:`hidden`}`,children:(0,J.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,J.jsx)(e7,{})})}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden ${n===`conversations`?`block`:`hidden`}`,children:(0,J.jsx)(E7,{onSelect:i})})]})}e.ChatApp=D7,e.ChatRuntimeProvider=IF});