loopat 0.1.22 → 0.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server/src/index.ts +43 -22
- package/server/src/podman.ts +4 -3
- package/server/templates/sandbox/Containerfile +10 -2
- package/web/dist/assets/{CodeEditor-CCmzcfl4.js → CodeEditor-DtHZtsPs.js} +1 -1
- package/web/dist/assets/{Editor-DjEYNpQa.js → Editor-BctC10Up.js} +1 -1
- package/web/dist/assets/{Markdown-DL99Gl_M.js → Markdown-BaQm5IQ5.js} +1 -1
- package/web/dist/assets/{MilkdownEditor-CDYnLn81.js → MilkdownEditor-UrDfL7Gb.js} +1 -1
- package/web/dist/assets/{Terminal-DTMXO4Pg.js → Terminal-trnCVajY.js} +1 -1
- package/web/dist/assets/{index-Bpe3D3u2.js → index-DFfPNaJU.js} +6 -6
- package/web/dist/assets/{jsx-runtime-29NaZBia.js → jsx-runtime-Bt-cYkS5.js} +1 -1
- package/web/dist/index.html +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Editor-
|
|
2
|
-
import{i as e,n as t,o as n,r,t as i}from"./jsx-runtime-29NaZBia.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var a=r((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),o=r(((e,t)=>{t.exports=a()})),s=r((e=>{var n=t();function r(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(r(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`);function s(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var c=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(r(299));return s(e,t,null,n)},e.flushSync=function(e){var t=c.T,n=a.p;try{if(c.T=null,a.p=2,e)return e()}finally{c.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=l(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??a.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=l(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else a.d.m(e)},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return c.H.useFormState(e,t,n)},e.useFormStatus=function(){return c.H.useHostTransitionStatus()},e.version=`19.2.6`})),c=r(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=s()})),l=r((e=>{var n=o(),r=t(),i=c();function a(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function l(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function u(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function f(e){if(l(e)!==e)throw Error(a(188))}function p(e){var t=e.alternate;if(!t){if(t=l(e),t===null)throw Error(a(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return f(i),e;if(o===r)return f(i),t;o=o.sibling}throw Error(a(188))}if(n.return!==r.return)n=i,r=o;else{for(var s=!1,c=i.child;c;){if(c===n){s=!0,n=i,r=o;break}if(c===r){s=!0,r=i,n=o;break}c=c.sibling}if(!s){for(c=o.child;c;){if(c===n){s=!0,n=o,r=i;break}if(c===r){s=!0,r=o,n=i;break}c=c.sibling}if(!s)throw Error(a(189))}}if(n.alternate!==r)throw Error(a(190))}if(n.tag!==3)throw Error(a(188));return n.stateNode.current===n?e:t}function m(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=m(e),t!==null)return t;e=e.sibling}return null}var h=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),D=Symbol.for(`react.memo`),O=Symbol.for(`react.lazy`),k=Symbol.for(`react.activity`),A=Symbol.for(`react.memo_cache_sentinel`),j=Symbol.iterator;function M(e){return typeof e!=`object`||!e?null:(e=j&&e[j]||e[`@@iterator`],typeof e==`function`?e:null)}var N=Symbol.for(`react.client.reference`);function P(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===N?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case T:return`Suspense`;case E:return`SuspenseList`;case k:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case D:return t=e.displayName||null,t===null?P(e.type)||`Memo`:t;case O:t=e._payload,e=e._init;try{return P(e(t))}catch{}}return null}var F=Array.isArray,I=r.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R={pending:!1,data:null,method:null,action:null},z=[],B=-1;function V(e){return{current:e}}function H(e){0>B||(e.current=z[B],z[B]=null,B--)}function U(e,t){B++,z[B]=e.current,e.current=t}var ee=V(null),W=V(null),te=V(null),ne=V(null);function re(e,t){switch(U(te,t),U(W,e),U(ee,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Jd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Jd(t),e=Yd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}H(ee),U(ee,e)}function ie(){H(ee),H(W),H(te)}function ae(e){e.memoizedState!==null&&U(ne,e);var t=ee.current,n=Yd(t,e.type);t!==n&&(U(W,e),U(ee,n))}function oe(e){W.current===e&&(H(ee),H(W)),ne.current===e&&(H(ne),ap._currentValue=R)}var se,ce;function le(e){if(se===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);se=t&&t[1]||``,ce=-1<e.stack.indexOf(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Editor-BctC10Up.js","assets/jsx-runtime-Bt-cYkS5.js","assets/CodeEditor-DtHZtsPs.js","assets/w3c-keyname-BOAvb0qz.js","assets/Terminal-trnCVajY.js","assets/Terminal-BrP-ENHg.css","assets/Markdown-BaQm5IQ5.js","assets/MilkdownEditor-UrDfL7Gb.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e,n as t,o as n,r,t as i}from"./jsx-runtime-Bt-cYkS5.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var a=r((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),o=r(((e,t)=>{t.exports=a()})),s=r((e=>{var n=t();function r(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(r(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`);function s(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var c=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(r(299));return s(e,t,null,n)},e.flushSync=function(e){var t=c.T,n=a.p;try{if(c.T=null,a.p=2,e)return e()}finally{c.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=l(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??a.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=l(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else a.d.m(e)},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return c.H.useFormState(e,t,n)},e.useFormStatus=function(){return c.H.useHostTransitionStatus()},e.version=`19.2.7`})),c=r(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=s()})),l=r((e=>{var n=o(),r=t(),i=c();function a(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function l(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function u(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function f(e){if(l(e)!==e)throw Error(a(188))}function p(e){var t=e.alternate;if(!t){if(t=l(e),t===null)throw Error(a(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return f(i),e;if(o===r)return f(i),t;o=o.sibling}throw Error(a(188))}if(n.return!==r.return)n=i,r=o;else{for(var s=!1,c=i.child;c;){if(c===n){s=!0,n=i,r=o;break}if(c===r){s=!0,r=i,n=o;break}c=c.sibling}if(!s){for(c=o.child;c;){if(c===n){s=!0,n=o,r=i;break}if(c===r){s=!0,r=o,n=i;break}c=c.sibling}if(!s)throw Error(a(189))}}if(n.alternate!==r)throw Error(a(190))}if(n.tag!==3)throw Error(a(188));return n.stateNode.current===n?e:t}function m(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=m(e),t!==null)return t;e=e.sibling}return null}var h=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),D=Symbol.for(`react.memo`),O=Symbol.for(`react.lazy`),k=Symbol.for(`react.activity`),A=Symbol.for(`react.memo_cache_sentinel`),j=Symbol.iterator;function M(e){return typeof e!=`object`||!e?null:(e=j&&e[j]||e[`@@iterator`],typeof e==`function`?e:null)}var N=Symbol.for(`react.client.reference`);function P(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===N?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case T:return`Suspense`;case E:return`SuspenseList`;case k:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case D:return t=e.displayName||null,t===null?P(e.type)||`Memo`:t;case O:t=e._payload,e=e._init;try{return P(e(t))}catch{}}return null}var F=Array.isArray,I=r.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R={pending:!1,data:null,method:null,action:null},z=[],B=-1;function V(e){return{current:e}}function H(e){0>B||(e.current=z[B],z[B]=null,B--)}function U(e,t){B++,z[B]=e.current,e.current=t}var ee=V(null),W=V(null),te=V(null),ne=V(null);function re(e,t){switch(U(te,t),U(W,e),U(ee,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Jd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Jd(t),e=Yd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}H(ee),U(ee,e)}function ie(){H(ee),H(W),H(te)}function ae(e){e.memoizedState!==null&&U(ne,e);var t=ee.current,n=Yd(t,e.type);t!==n&&(U(W,e),U(ee,n))}function oe(e){W.current===e&&(H(ee),H(W)),ne.current===e&&(H(ne),ap._currentValue=R)}var se,ce;function le(e){if(se===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);se=t&&t[1]||``,ce=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+se+e+ce}var ue=!1;function de(e,t){if(!e||ue)return``;ue=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
5
5
|
`),l=s.split(`
|
|
@@ -7,7 +7,7 @@ import{i as e,n as t,o as n,r,t as i}from"./jsx-runtime-29NaZBia.js";(function()
|
|
|
7
7
|
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{ue=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?le(n):``}function fe(e,t){switch(e.tag){case 26:case 27:case 5:return le(e.type);case 16:return le(`Lazy`);case 13:return e.child!==t&&t!==null?le(`Suspense Fallback`):le(`Suspense`);case 19:return le(`SuspenseList`);case 0:case 15:return de(e.type,!1);case 11:return de(e.type.render,!1);case 1:return de(e.type,!0);case 31:return le(`Activity`);default:return``}}function pe(e){try{var t=``,n=null;do t+=fe(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
|
8
8
|
Error generating stack: `+e.message+`
|
|
9
9
|
`+e.stack}}var me=Object.prototype.hasOwnProperty,he=n.unstable_scheduleCallback,ge=n.unstable_cancelCallback,_e=n.unstable_shouldYield,ve=n.unstable_requestPaint,ye=n.unstable_now,be=n.unstable_getCurrentPriorityLevel,xe=n.unstable_ImmediatePriority,Se=n.unstable_UserBlockingPriority,Ce=n.unstable_NormalPriority,we=n.unstable_LowPriority,Te=n.unstable_IdlePriority,Ee=n.log,De=n.unstable_setDisableYieldValue,Oe=null,ke=null;function Ae(e){if(typeof Ee==`function`&&De(e),ke&&typeof ke.setStrictMode==`function`)try{ke.setStrictMode(Oe,e)}catch{}}var je=Math.clz32?Math.clz32:Pe,Me=Math.log,Ne=Math.LN2;function Pe(e){return e>>>=0,e===0?32:31-(Me(e)/Ne|0)|0}var Fe=256,Ie=262144,Le=4194304;function Re(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function ze(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Re(n))):i=Re(o):i=Re(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Re(n))):i=Re(o)):i=Re(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function Be(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Ve(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function He(){var e=Le;return Le<<=1,!(Le&62914560)&&(Le=4194304),e}function Ue(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function We(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ge(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-je(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&Ke(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function Ke(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-je(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function qe(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-je(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function Je(e,t){var n=t&-t;return n=n&42?1:Ye(n),(n&(e.suspendedLanes|t))===0?n:0}function Ye(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Xe(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function Ze(){var e=L.p;return e===0?(e=window.event,e===void 0?32:bp(e.type)):e}function Qe(e,t){var n=L.p;try{return L.p=e,t()}finally{L.p=n}}var $e=Math.random().toString(36).slice(2),et=`__reactFiber$`+$e,tt=`__reactProps$`+$e,nt=`__reactContainer$`+$e,rt=`__reactEvents$`+$e,it=`__reactListeners$`+$e,at=`__reactHandles$`+$e,ot=`__reactResources$`+$e,st=`__reactMarker$`+$e;function ct(e){delete e[et],delete e[tt],delete e[rt],delete e[it],delete e[at]}function lt(e){var t=e[et];if(t)return t;for(var n=e.parentNode;n;){if(t=n[nt]||n[et]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=vf(e);e!==null;){if(n=e[et])return n;e=vf(e)}return t}e=n,n=e.parentNode}return null}function ut(e){if(e=e[et]||e[nt]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function dt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(a(33))}function ft(e){var t=e[ot];return t||=e[ot]={hoistableStyles:new Map,hoistableScripts:new Map},t}function pt(e){e[st]=!0}var mt=new Set,ht={};function gt(e,t){_t(e,t),_t(e+`Capture`,t)}function _t(e,t){for(ht[e]=t,e=0;e<t.length;e++)mt.add(t[e])}var vt=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),yt={},bt={};function xt(e){return me.call(bt,e)?!0:me.call(yt,e)?!1:vt.test(e)?bt[e]=!0:(yt[e]=!0,!1)}function St(e,t,n){if(xt(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}function Ct(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function wt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function Tt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Et(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function Dt(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Ot(e){if(!e._valueTracker){var t=Et(e)?`checked`:`value`;e._valueTracker=Dt(e,t,``+e[t])}}function kt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Et(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function At(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var jt=/[\n"\\]/g;function Mt(e){return e.replace(jt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Nt(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+Tt(t)):e.value!==``+Tt(t)&&(e.value=``+Tt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):Ft(e,o,Tt(n)):Ft(e,o,Tt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+Tt(s):e.removeAttribute(`name`)}function Pt(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){Ot(e);return}n=n==null?``:``+Tt(n),t=t==null?n:``+Tt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),Ot(e)}function Ft(e,t,n){t===`number`&&At(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function It(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+Tt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Lt(e,t,n){if(t!=null&&(t=``+Tt(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+Tt(n)}function Rt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(a(92));if(F(r)){if(1<r.length)throw Error(a(93));r=r[0]}n=r}n??=``,t=n}n=Tt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),Ot(e)}function zt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Bt=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function Vt(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||Bt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function Ht(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(a(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var i in t)r=t[i],t.hasOwnProperty(i)&&n[i]!==r&&Vt(e,i,r)}else for(var o in t)t.hasOwnProperty(o)&&Vt(e,o,t[o])}function Ut(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Wt=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`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`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`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`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`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`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),Gt=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Kt(e){return Gt.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function qt(){}var Jt=null;function Yt(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Xt=null,Zt=null;function Qt(e){var t=ut(e);if(t&&(e=t.stateNode)){var n=e[tt]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Nt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Mt(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var i=r[tt]||null;if(!i)throw Error(a(90));Nt(r,i.value,i.defaultValue,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&kt(r)}break a;case`textarea`:Lt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&It(e,!!n.multiple,t,!1)}}}var $t=!1;function en(e,t,n){if($t)return e(t,n);$t=!0;try{return e(t)}finally{if($t=!1,(Xt!==null||Zt!==null)&&(wu(),Xt&&(t=Xt,e=Zt,Zt=Xt=null,Qt(t),e)))for(t=0;t<e.length;t++)Qt(e[t])}}function tn(e,t){var n=e.stateNode;if(n===null)return null;var r=n[tt]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=!(e===`button`||e===`input`||e===`select`||e===`textarea`)),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(a(231,t,typeof n));return n}var nn=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),rn=!1;if(nn)try{var an={};Object.defineProperty(an,"passive",{get:function(){rn=!0}}),window.addEventListener(`test`,an,an),window.removeEventListener(`test`,an,an)}catch{rn=!1}var on=null,sn=null,cn=null;function ln(){if(cn)return cn;var e,t=sn,n=t.length,r,i=`value`in on?on.value:on.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return cn=i.slice(e,1<r?1-r:void 0)}function un(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function dn(){return!0}function fn(){return!1}function pn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?dn:fn,this.isPropagationStopped=fn,this}return h(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=dn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=dn)},persist:function(){},isPersistent:dn}),t}var mn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},hn=pn(mn),gn=h({},mn,{view:0,detail:0}),_n=pn(gn),vn,yn,bn,xn=h({},gn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Mn,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==bn&&(bn&&e.type===`mousemove`?(vn=e.screenX-bn.screenX,yn=e.screenY-bn.screenY):yn=vn=0,bn=e),vn)},movementY:function(e){return`movementY`in e?e.movementY:yn}}),Sn=pn(xn),Cn=pn(h({},xn,{dataTransfer:0})),wn=pn(h({},gn,{relatedTarget:0})),Tn=pn(h({},mn,{animationName:0,elapsedTime:0,pseudoElement:0})),En=pn(h({},mn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Dn=pn(h({},mn,{data:0})),On={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},kn={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},An={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function jn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=An[e])?!!t[e]:!1}function Mn(){return jn}var Nn=pn(h({},gn,{key:function(e){if(e.key){var t=On[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=un(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?kn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Mn,charCode:function(e){return e.type===`keypress`?un(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?un(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Pn=pn(h({},xn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Fn=pn(h({},gn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Mn})),In=pn(h({},mn,{propertyName:0,elapsedTime:0,pseudoElement:0})),Ln=pn(h({},xn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),Rn=pn(h({},mn,{newState:0,oldState:0})),zn=[9,13,27,32],Bn=nn&&`CompositionEvent`in window,Vn=null;nn&&`documentMode`in document&&(Vn=document.documentMode);var Hn=nn&&`TextEvent`in window&&!Vn,Un=nn&&(!Bn||Vn&&8<Vn&&11>=Vn),Wn=` `,Gn=!1;function Kn(e,t){switch(e){case`keyup`:return zn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function qn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Jn=!1;function Yn(e,t){switch(e){case`compositionend`:return qn(t);case`keypress`:return t.which===32?(Gn=!0,Wn):null;case`textInput`:return e=t.data,e===Wn&&Gn?null:e;default:return null}}function Xn(e,t){if(Jn)return e===`compositionend`||!Bn&&Kn(e,t)?(e=ln(),cn=sn=on=null,Jn=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return Un&&t.locale!==`ko`?null:t.data;default:return null}}var Zn={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Qn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!Zn[e.type]:t===`textarea`}function $n(e,t,n,r){Xt?Zt?Zt.push(r):Zt=[r]:Xt=r,t=Md(t,`onChange`),0<t.length&&(n=new hn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var er=null,tr=null;function nr(e){wd(e,0)}function rr(e){if(kt(dt(e)))return e}function ir(e,t){if(e===`change`)return t}var ar=!1;if(nn){var or;if(nn){var sr=`oninput`in document;if(!sr){var cr=document.createElement(`div`);cr.setAttribute(`oninput`,`return;`),sr=typeof cr.oninput==`function`}or=sr}else or=!1;ar=or&&(!document.documentMode||9<document.documentMode)}function lr(){er&&(er.detachEvent(`onpropertychange`,ur),tr=er=null)}function ur(e){if(e.propertyName===`value`&&rr(tr)){var t=[];$n(t,tr,e,Yt(e)),en(nr,t)}}function dr(e,t,n){e===`focusin`?(lr(),er=t,tr=n,er.attachEvent(`onpropertychange`,ur)):e===`focusout`&&lr()}function fr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return rr(tr)}function pr(e,t){if(e===`click`)return rr(t)}function mr(e,t){if(e===`input`||e===`change`)return rr(t)}function hr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var gr=typeof Object.is==`function`?Object.is:hr;function _r(e,t){if(gr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!me.call(t,i)||!gr(e[i],t[i]))return!1}return!0}function vr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function yr(e,t){var n=vr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=vr(n)}}function br(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?br(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function xr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=At(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=At(e.document)}return t}function Sr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Cr=nn&&`documentMode`in document&&11>=document.documentMode,wr=null,Tr=null,Er=null,Dr=!1;function Or(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Dr||wr==null||wr!==At(r)||(r=wr,`selectionStart`in r&&Sr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Er&&_r(Er,r)||(Er=r,r=Md(Tr,`onSelect`),0<r.length&&(t=new hn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=wr)))}function kr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Ar={animationend:kr(`Animation`,`AnimationEnd`),animationiteration:kr(`Animation`,`AnimationIteration`),animationstart:kr(`Animation`,`AnimationStart`),transitionrun:kr(`Transition`,`TransitionRun`),transitionstart:kr(`Transition`,`TransitionStart`),transitioncancel:kr(`Transition`,`TransitionCancel`),transitionend:kr(`Transition`,`TransitionEnd`)},jr={},Mr={};nn&&(Mr=document.createElement(`div`).style,`AnimationEvent`in window||(delete Ar.animationend.animation,delete Ar.animationiteration.animation,delete Ar.animationstart.animation),`TransitionEvent`in window||delete Ar.transitionend.transition);function Nr(e){if(jr[e])return jr[e];if(!Ar[e])return e;var t=Ar[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Mr)return jr[e]=t[n];return e}var Pr=Nr(`animationend`),Fr=Nr(`animationiteration`),Ir=Nr(`animationstart`),Lr=Nr(`transitionrun`),Rr=Nr(`transitionstart`),zr=Nr(`transitioncancel`),Br=Nr(`transitionend`),Vr=new Map,Hr=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);Hr.push(`scrollEnd`);function Ur(e,t){Vr.set(e,t),gt(t,[e])}var Wr=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},Gr=[],Kr=0,qr=0;function Jr(){for(var e=Kr,t=qr=Kr=0;t<e;){var n=Gr[t];Gr[t++]=null;var r=Gr[t];Gr[t++]=null;var i=Gr[t];Gr[t++]=null;var a=Gr[t];if(Gr[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&Qr(n,i,a)}}function Yr(e,t,n,r){Gr[Kr++]=e,Gr[Kr++]=t,Gr[Kr++]=n,Gr[Kr++]=r,qr|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Xr(e,t,n,r){return Yr(e,t,n,r),$r(e)}function Zr(e,t){return Yr(e,null,null,t),$r(e)}function Qr(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-je(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function $r(e){if(50<hu)throw hu=0,gu=null,Error(a(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var ei={};function ti(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ni(e,t,n,r){return new ti(e,t,n,r)}function ri(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ii(e,t){var n=e.alternate;return n===null?(n=ni(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function ai(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function oi(e,t,n,r,i,o){var s=0;if(r=e,typeof e==`function`)ri(e)&&(s=1);else if(typeof e==`string`)s=Xf(e,n,ee.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case k:return e=ni(31,n,t,i),e.elementType=k,e.lanes=o,e;case y:return si(n.children,i,o,t);case b:s=8,i|=24;break;case x:return e=ni(12,n,t,i|2),e.elementType=x,e.lanes=o,e;case T:return e=ni(13,n,t,i),e.elementType=T,e.lanes=o,e;case E:return e=ni(19,n,t,i),e.elementType=E,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case C:s=10;break a;case S:s=9;break a;case w:s=11;break a;case D:s=14;break a;case O:s=16,r=null;break a}s=29,n=Error(a(130,e===null?`null`:typeof e,``)),r=null}return t=ni(s,n,t,i),t.elementType=e,t.type=r,t.lanes=o,t}function si(e,t,n,r){return e=ni(7,e,r,t),e.lanes=n,e}function ci(e,t,n){return e=ni(6,e,null,t),e.lanes=n,e}function li(e){var t=ni(18,null,null,0);return t.stateNode=e,t}function ui(e,t,n){return t=ni(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var di=new WeakMap;function fi(e,t){if(typeof e==`object`&&e){var n=di.get(e);return n===void 0?(t={value:e,source:t,stack:pe(t)},di.set(e,t),t):n}return{value:e,source:t,stack:pe(t)}}var pi=[],mi=0,hi=null,gi=0,_i=[],vi=0,yi=null,bi=1,xi=``;function Si(e,t){pi[mi++]=gi,pi[mi++]=hi,hi=e,gi=t}function Ci(e,t,n){_i[vi++]=bi,_i[vi++]=xi,_i[vi++]=yi,yi=e;var r=bi;e=xi;var i=32-je(r)-1;r&=~(1<<i),n+=1;var a=32-je(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,bi=1<<32-je(t)+i|n<<i|r,xi=a+e}else bi=1<<a|n<<i|r,xi=e}function wi(e){e.return!==null&&(Si(e,1),Ci(e,1,0))}function Ti(e){for(;e===hi;)hi=pi[--mi],pi[mi]=null,gi=pi[--mi],pi[mi]=null;for(;e===yi;)yi=_i[--vi],_i[vi]=null,xi=_i[--vi],_i[vi]=null,bi=_i[--vi],_i[vi]=null}function Ei(e,t){_i[vi++]=bi,_i[vi++]=xi,_i[vi++]=yi,bi=t.id,xi=t.overflow,yi=e}var Di=null,Oi=null,ki=!1,Ai=null,ji=!1,G=Error(a(519));function Mi(e){throw Ri(fi(Error(a(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),G}function Ni(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[et]=e,t[tt]=r,n){case`dialog`:Td(`cancel`,t),Td(`close`,t);break;case`iframe`:case`object`:case`embed`:Td(`load`,t);break;case`video`:case`audio`:for(n=0;n<Sd.length;n++)Td(Sd[n],t);break;case`source`:Td(`error`,t);break;case`img`:case`image`:case`link`:Td(`error`,t),Td(`load`,t);break;case`details`:Td(`toggle`,t);break;case`input`:Td(`invalid`,t),Pt(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:Td(`invalid`,t);break;case`textarea`:Td(`invalid`,t),Rt(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||Rd(t.textContent,n)?(r.popover!=null&&(Td(`beforetoggle`,t),Td(`toggle`,t)),r.onScroll!=null&&Td(`scroll`,t),r.onScrollEnd!=null&&Td(`scrollend`,t),r.onClick!=null&&(t.onclick=qt),t=!0):t=!1,t||Mi(e,!0)}function Pi(e){for(Di=e.return;Di;)switch(Di.tag){case 5:case 31:case 13:ji=!1;return;case 27:case 3:ji=!0;return;default:Di=Di.return}}function Fi(e){if(e!==Di)return!1;if(!ki)return Pi(e),ki=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!==`form`&&n!==`button`)||Xd(e.type,e.memoizedProps)),n=!n),n&&Oi&&Mi(e),Pi(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(a(317));Oi=_f(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(a(317));Oi=_f(e)}else t===27?(t=Oi,af(e.type)?(e=gf,gf=null,Oi=e):Oi=t):Oi=Di?hf(e.stateNode.nextSibling):null;return!0}function Ii(){Oi=Di=null,ki=!1}function Li(){var e=Ai;return e!==null&&(tu===null?tu=e:tu.push.apply(tu,e),Ai=null),e}function Ri(e){Ai===null?Ai=[e]:Ai.push(e)}var zi=V(null),Bi=null,Vi=null;function Hi(e,t,n){U(zi,t._currentValue),t._currentValue=n}function Ui(e){e._currentValue=zi.current,H(zi)}function Wi(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Gi(e,t,n,r){var i=e.child;for(i!==null&&(i.return=e);i!==null;){var o=i.dependencies;if(o!==null){var s=i.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=i;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),Wi(o.return,n,e),r||(s=null);break a}o=c.next}}else if(i.tag===18){if(s=i.return,s===null)throw Error(a(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),Wi(s,n,e),s=null}else s=i.child;if(s!==null)s.return=i;else for(s=i;s!==null;){if(s===e){s=null;break}if(i=s.sibling,i!==null){i.return=s.return,s=i;break}s=s.return}i=s}}function Ki(e,t,n,r){e=null;for(var i=t,o=!1;i!==null;){if(!o){if(i.flags&524288)o=!0;else if(i.flags&262144)break}if(i.tag===10){var s=i.alternate;if(s===null)throw Error(a(387));if(s=s.memoizedProps,s!==null){var c=i.type;gr(i.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(i===ne.current){if(s=i.alternate,s===null)throw Error(a(387));s.memoizedState.memoizedState!==i.memoizedState.memoizedState&&(e===null?e=[ap]:e.push(ap))}i=i.return}e!==null&&Gi(t,e,n,r),t.flags|=262144}function qi(e){for(e=e.firstContext;e!==null;){if(!gr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Ji(e){Bi=e,Vi=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function K(e){return Xi(Bi,e)}function Yi(e,t){return Bi===null&&Ji(e),Xi(e,t)}function Xi(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Vi===null){if(e===null)throw Error(a(308));Vi=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Vi=Vi.next=t;return n}var Zi=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Qi=n.unstable_scheduleCallback,$i=n.unstable_NormalPriority,ea={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ta(){return{controller:new Zi,data:new Map,refCount:0}}function na(e){e.refCount--,e.refCount===0&&Qi($i,function(){e.controller.abort()})}var ra=null,ia=0,aa=0,oa=null;function sa(e,t){if(ra===null){var n=ra=[];ia=0,aa=gd(),oa={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return ia++,t.then(ca,ca),t}function ca(){if(--ia===0&&ra!==null){oa!==null&&(oa.status=`fulfilled`);var e=ra;ra=null,aa=0,oa=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function la(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var ua=I.S;I.S=function(e,t){iu=ye(),typeof t==`object`&&t&&typeof t.then==`function`&&sa(e,t),ua!==null&&ua(e,t)};var da=V(null);function fa(){var e=da.current;return e===null?zl.pooledCache:e}function pa(e,t){t===null?U(da,da.current):U(da,t.pool)}function ma(){var e=fa();return e===null?null:{parent:ea._currentValue,pool:e}}var ha=Error(a(460)),ga=Error(a(474)),_a=Error(a(542)),va={then:function(){}};function ya(e){return e=e.status,e===`fulfilled`||e===`rejected`}function ba(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(qt,qt),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,wa(e),e;default:if(typeof t.status==`string`)t.then(qt,qt);else{if(e=zl,e!==null&&100<e.shellSuspendCounter)throw Error(a(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,wa(e),e}throw Sa=t,ha}}function xa(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(Sa=e,ha):e}}var Sa=null;function Ca(){if(Sa===null)throw Error(a(459));var e=Sa;return Sa=null,e}function wa(e){if(e===ha||e===_a)throw Error(a(483))}var Ta=null,Ea=0;function Da(e){var t=Ea;return Ea+=1,Ta===null&&(Ta=[]),ba(Ta,e,t)}function Oa(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function ka(e,t){throw t.$$typeof===g?Error(a(525)):(e=Object.prototype.toString.call(t),Error(a(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Aa(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function i(e,t){return e=ii(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=ci(n,e.mode,r),t.return=e,t):(t=i(t,n),t.return=e,t)}function l(e,t,n,r){var a=n.type;return a===y?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===a||typeof a==`object`&&a&&a.$$typeof===O&&xa(a)===t.type)?(t=i(t,n.props),Oa(t,n),t.return=e,t):(t=oi(n.type,n.key,n.props,null,e.mode,r),Oa(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=ui(n,e.mode,r),t.return=e,t):(t=i(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,a){return t===null||t.tag!==7?(t=si(n,e.mode,r,a),t.return=e,t):(t=i(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=ci(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case _:return n=oi(t.type,t.key,t.props,null,e.mode,n),Oa(n,t),n.return=e,n;case v:return t=ui(t,e.mode,n),t.return=e,t;case O:return t=xa(t),f(e,t,n)}if(F(t)||M(t))return t=si(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,Da(t),n);if(t.$$typeof===C)return f(e,Yi(e,t),n);ka(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case _:return n.key===i?l(e,t,n,r):null;case v:return n.key===i?u(e,t,n,r):null;case O:return n=xa(n),p(e,t,n,r)}if(F(n)||M(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,Da(n),r);if(n.$$typeof===C)return p(e,t,Yi(e,n),r);ka(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case _:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case v:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case O:return r=xa(r),m(e,t,n,r,i)}if(F(r)||M(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,Da(r),i);if(r.$$typeof===C)return m(e,t,n,Yi(t,r),i);ka(t,r)}return null}function h(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),ki&&Si(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return ki&&Si(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),ki&&Si(i,h),l}function g(i,s,c,l){if(c==null)throw Error(a(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(i,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(i,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(i,h),ki&&Si(i,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(i,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return ki&&Si(i,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,i,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(i,e)}),ki&&Si(i,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===y&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case _:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===y){if(r.tag===7){n(e,r.sibling),c=i(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===O&&xa(l)===r.type){n(e,r.sibling),c=i(r,o.props),Oa(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===y?(c=si(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=oi(o.type,o.key,o.props,null,e.mode,c),Oa(c,o),c.return=e,e=c)}return s(e);case v:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=i(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=ui(o,e.mode,c),c.return=e,e=c}return s(e);case O:return o=xa(o),b(e,r,o,c)}if(F(o))return h(e,r,o,c);if(M(o)){if(l=M(o),typeof l!=`function`)throw Error(a(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,Da(o),c);if(o.$$typeof===C)return b(e,r,Yi(e,o),c);ka(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=i(r,o),c.return=e,e=c):(n(e,r),c=ci(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Ea=0;var i=b(e,t,n,r);return Ta=null,i}catch(t){if(t===ha||t===_a)throw t;var a=ni(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var ja=Aa(!0),Ma=Aa(!1),Na=!1;function Pa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Fa(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Ia(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function La(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Rl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=$r(e),Qr(e,null,n),t}return Yr(e,r,t,n),$r(e)}function Ra(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,qe(e,n)}}function za(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Ba=!1;function Va(){if(Ba){var e=oa;if(e!==null)throw e}}function Ha(e,t,n,r){Ba=!1;var i=e.updateQueue;Na=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Vl&f)===f:(r&f)===f){f!==0&&f===aa&&(Ba=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(m=g.payload,typeof m==`function`){d=m.call(_,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=g.payload,f=typeof m==`function`?m.call(_,d,f):m,f==null)break a;d=h({},d,f);break a;case 2:Na=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Yl|=o,e.lanes=o,e.memoizedState=d}}function Ua(e,t){if(typeof e!=`function`)throw Error(a(191,e));e.call(t)}function Wa(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Ua(n[e],t)}var Ga=V(null),Ka=V(0);function qa(e,t){e=ql,U(Ka,e),U(Ga,t),ql=e|t.baseLanes}function Ja(){U(Ka,ql),U(Ga,Ga.current)}function Ya(){ql=Ka.current,H(Ga),H(Ka)}var Xa=V(null),Za=null;function Qa(e){var t=e.alternate;U(ro,ro.current&1),U(Xa,e),Za===null&&(t===null||Ga.current!==null||t.memoizedState!==null)&&(Za=e)}function $a(e){U(ro,ro.current),U(Xa,e),Za===null&&(Za=e)}function eo(e){e.tag===22?(U(ro,ro.current),U(Xa,e),Za===null&&(Za=e)):to(e)}function to(){U(ro,ro.current),U(Xa,Xa.current)}function no(e){H(Xa),Za===e&&(Za=null),H(ro)}var ro=V(0);function io(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||ff(n)||pf(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var ao=0,oo=null,so=null,co=null,lo=!1,uo=!1,fo=!1,po=0,mo=0,ho=null,go=0;function _o(){throw Error(a(321))}function vo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!gr(e[n],t[n]))return!1;return!0}function yo(e,t,n,r,i,a){return ao=a,oo=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,I.H=e===null||e.memoizedState===null?Is:Ls,fo=!1,a=n(r,i),fo=!1,uo&&(a=xo(t,n,r,i)),bo(e),a}function bo(e){I.H=Fs;var t=so!==null&&so.next!==null;if(ao=0,co=so=oo=null,lo=!1,mo=0,ho=null,t)throw Error(a(300));e===null||ec||(e=e.dependencies,e!==null&&qi(e)&&(ec=!0))}function xo(e,t,n,r){oo=e;var i=0;do{if(uo&&(ho=null),mo=0,uo=!1,25<=i)throw Error(a(301));if(i+=1,co=so=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}I.H=Rs,o=t(n,r)}while(uo);return o}function So(){var e=I.H,t=e.useState()[0];return t=typeof t.then==`function`?ko(t):t,e=e.useState()[0],(so===null?null:so.memoizedState)!==e&&(oo.flags|=1024),t}function Co(){var e=po!==0;return po=0,e}function wo(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function To(e){if(lo){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}lo=!1}ao=0,co=so=oo=null,uo=!1,mo=po=0,ho=null}function Eo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return co===null?oo.memoizedState=co=e:co=co.next=e,co}function Do(){if(so===null){var e=oo.alternate;e=e===null?null:e.memoizedState}else e=so.next;var t=co===null?oo.memoizedState:co.next;if(t!==null)co=t,so=e;else{if(e===null)throw oo.alternate===null?Error(a(467)):Error(a(310));so=e,e={memoizedState:so.memoizedState,baseState:so.baseState,baseQueue:so.baseQueue,queue:so.queue,next:null},co===null?oo.memoizedState=co=e:co=co.next=e}return co}function Oo(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ko(e){var t=mo;return mo+=1,ho===null&&(ho=[]),e=ba(ho,e,t),t=oo,(co===null?t.memoizedState:co.next)===null&&(t=t.alternate,I.H=t===null||t.memoizedState===null?Is:Ls),e}function Ao(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return ko(e);if(e.$$typeof===C)return K(e)}throw Error(a(438,String(e)))}function jo(e){var t=null,n=oo.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=oo.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=Oo(),oo.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=A;return t.index++,n}function Mo(e,t){return typeof t==`function`?t(e):t}function No(e){return Po(Do(),so,e)}function Po(e,t,n){var r=e.queue;if(r===null)throw Error(a(311));r.lastRenderedReducer=n;var i=e.baseQueue,o=r.pending;if(o!==null){if(i!==null){var s=i.next;i.next=o.next,o.next=s}t.baseQueue=i=o,r.pending=null}if(o=e.baseState,i===null)e.memoizedState=o;else{t=i.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(ao&f)===f:(Vl&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===aa&&(d=!0);else if((ao&p)===p){u=u.next,p===aa&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,oo.lanes|=p,Yl|=p;f=u.action,fo&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,oo.lanes|=f,Yl|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!gr(o,e.memoizedState)&&(ec=!0,d&&(n=oa,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return i===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Fo(e){var t=Do(),n=t.queue;if(n===null)throw Error(a(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,o=t.memoizedState;if(i!==null){n.pending=null;var s=i=i.next;do o=e(o,s.action),s=s.next;while(s!==i);gr(o,t.memoizedState)||(ec=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function Io(e,t,n){var r=oo,i=Do(),o=ki;if(o){if(n===void 0)throw Error(a(407));n=n()}else n=t();var s=!gr((so||i).memoizedState,n);if(s&&(i.memoizedState=n,ec=!0),i=i.queue,ss(zo.bind(null,r,i,e),[e]),i.getSnapshot!==t||s||co!==null&&co.memoizedState.tag&1){if(r.flags|=2048,ns(9,{destroy:void 0},Ro.bind(null,r,i,n,t),null),zl===null)throw Error(a(349));o||ao&127||Lo(r,t,n)}return n}function Lo(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=oo.updateQueue,t===null?(t=Oo(),oo.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Ro(e,t,n,r){t.value=n,t.getSnapshot=r,Bo(t)&&Vo(e)}function zo(e,t,n){return n(function(){Bo(t)&&Vo(e)})}function Bo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!gr(e,n)}catch{return!0}}function Vo(e){var t=Zr(e,2);t!==null&&yu(t,e,2)}function Ho(e){var t=Eo();if(typeof e==`function`){var n=e;if(e=n(),fo){Ae(!0);try{n()}finally{Ae(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Mo,lastRenderedState:e},t}function Uo(e,t,n,r){return e.baseState=n,Po(e,so,typeof r==`function`?r:Mo)}function Wo(e,t,n,r,i){if(Ms(e))throw Error(a(485));if(e=t.action,e!==null){var o={payload:i,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};I.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,Go(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Go(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=I.T,o={};I.T=o;try{var s=n(i,r),c=I.S;c!==null&&c(o,s),Ko(e,t,s)}catch(n){Jo(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),I.T=a}}else try{a=n(i,r),Ko(e,t,a)}catch(n){Jo(e,t,n)}}function Ko(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){qo(e,t,n)},function(n){return Jo(e,t,n)}):qo(e,t,n)}function qo(e,t,n){t.status=`fulfilled`,t.value=n,Yo(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Go(e,n)))}function Jo(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Yo(t),t=t.next;while(t!==r)}e.action=null}function Yo(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Xo(e,t){return t}function Zo(e,t){if(ki){var n=zl.formState;if(n!==null){a:{var r=oo;if(ki){if(Oi){b:{for(var i=Oi,a=ji;i.nodeType!==8;){if(!a){i=null;break b}if(i=hf(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Oi=hf(i.nextSibling),r=i.data===`F!`;break a}}Mi(r)}r=!1}r&&(t=n[0])}}return n=Eo(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Xo,lastRenderedState:t},n.queue=r,n=ks.bind(null,oo,r),r.dispatch=n,r=Ho(!1),a=js.bind(null,oo,!1,r.queue),r=Eo(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=Wo.bind(null,oo,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function Qo(e){return $o(Do(),so,e)}function $o(e,t,n){if(t=Po(e,t,Xo)[0],e=No(Mo)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=ko(t)}catch(e){throw e===ha?_a:e}else r=t;t=Do();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(oo.flags|=2048,ns(9,{destroy:void 0},es.bind(null,i,n),null)),[r,a,e]}function es(e,t){e.action=t}function ts(e){var t=Do(),n=so;if(n!==null)return $o(t,n,e);Do(),t=t.memoizedState,n=Do();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function ns(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=oo.updateQueue,t===null&&(t=Oo(),oo.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function rs(){return Do().memoizedState}function is(e,t,n,r){var i=Eo();oo.flags|=e,i.memoizedState=ns(1|t,{destroy:void 0},n,r===void 0?null:r)}function as(e,t,n,r){var i=Do();r=r===void 0?null:r;var a=i.memoizedState.inst;so!==null&&r!==null&&vo(r,so.memoizedState.deps)?i.memoizedState=ns(t,a,n,r):(oo.flags|=e,i.memoizedState=ns(1|t,a,n,r))}function os(e,t){is(8390656,8,e,t)}function ss(e,t){as(2048,8,e,t)}function cs(e){oo.flags|=4;var t=oo.updateQueue;if(t===null)t=Oo(),oo.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function ls(e){var t=Do().memoizedState;return cs({ref:t,nextImpl:e}),function(){if(Rl&2)throw Error(a(440));return t.impl.apply(void 0,arguments)}}function us(e,t){return as(4,2,e,t)}function ds(e,t){return as(4,4,e,t)}function fs(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function ps(e,t,n){n=n==null?null:n.concat([e]),as(4,4,fs.bind(null,t,e),n)}function ms(){}function hs(e,t){var n=Do();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&vo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function gs(e,t){var n=Do();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&vo(t,r[1]))return r[0];if(r=e(),fo){Ae(!0);try{e()}finally{Ae(!1)}}return n.memoizedState=[r,t],r}function _s(e,t,n){return n===void 0||ao&1073741824&&!(Vl&261930)?e.memoizedState=t:(e.memoizedState=n,e=vu(),oo.lanes|=e,Yl|=e,n)}function vs(e,t,n,r){return gr(n,t)?n:Ga.current===null?!(ao&42)||ao&1073741824&&!(Vl&261930)?(ec=!0,e.memoizedState=n):(e=vu(),oo.lanes|=e,Yl|=e,t):(e=_s(e,n,r),gr(e,t)||(ec=!0),e)}function ys(e,t,n,r,i){var a=L.p;L.p=a!==0&&8>a?a:8;var o=I.T,s={};I.T=s,js(e,!1,t,n);try{var c=i(),l=I.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?As(e,t,la(c,r),_u(e)):As(e,t,r,_u(e))}catch(n){As(e,t,{then:function(){},status:`rejected`,reason:n},_u())}finally{L.p=a,o!==null&&s.types!==null&&(o.types=s.types),I.T=o}}function bs(){}function xs(e,t,n,r){if(e.tag!==5)throw Error(a(476));var i=Ss(e).queue;ys(e,i,t,R,n===null?bs:function(){return Cs(e),n(r)})}function Ss(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:R,baseState:R,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Mo,lastRenderedState:R},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Mo,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Cs(e){var t=Ss(e);t.next===null&&(t=e.alternate.memoizedState),As(e,t.next.queue,{},_u())}function ws(){return K(ap)}function Ts(){return Do().memoizedState}function Es(){return Do().memoizedState}function Ds(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=_u();e=Ia(n);var r=La(t,e,n);r!==null&&(yu(r,t,n),Ra(r,t,n)),t={cache:ta()},e.payload=t;return}t=t.return}}function Os(e,t,n){var r=_u();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ms(e)?Ns(t,n):(n=Xr(e,t,n,r),n!==null&&(yu(n,e,r),Ps(n,t,r)))}function ks(e,t,n){As(e,t,n,_u())}function As(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ms(e))Ns(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,gr(s,o))return Yr(e,t,i,0),zl===null&&Jr(),!1}catch{}if(n=Xr(e,t,i,r),n!==null)return yu(n,e,r),Ps(n,t,r),!0}return!1}function js(e,t,n,r){if(r={lane:2,revertLane:gd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ms(e)){if(t)throw Error(a(479))}else t=Xr(e,n,r,2),t!==null&&yu(t,e,2)}function Ms(e){var t=e.alternate;return e===oo||t!==null&&t===oo}function Ns(e,t){uo=lo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Ps(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,qe(e,n)}}var Fs={readContext:K,use:Ao,useCallback:_o,useContext:_o,useEffect:_o,useImperativeHandle:_o,useLayoutEffect:_o,useInsertionEffect:_o,useMemo:_o,useReducer:_o,useRef:_o,useState:_o,useDebugValue:_o,useDeferredValue:_o,useTransition:_o,useSyncExternalStore:_o,useId:_o,useHostTransitionStatus:_o,useFormState:_o,useActionState:_o,useOptimistic:_o,useMemoCache:_o,useCacheRefresh:_o};Fs.useEffectEvent=_o;var Is={readContext:K,use:Ao,useCallback:function(e,t){return Eo().memoizedState=[e,t===void 0?null:t],e},useContext:K,useEffect:os,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),is(4194308,4,fs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return is(4194308,4,e,t)},useInsertionEffect:function(e,t){is(4,2,e,t)},useMemo:function(e,t){var n=Eo();t=t===void 0?null:t;var r=e();if(fo){Ae(!0);try{e()}finally{Ae(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Eo();if(n!==void 0){var i=n(t);if(fo){Ae(!0);try{n(t)}finally{Ae(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Os.bind(null,oo,e),[r.memoizedState,e]},useRef:function(e){var t=Eo();return e={current:e},t.memoizedState=e},useState:function(e){e=Ho(e);var t=e.queue,n=ks.bind(null,oo,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ms,useDeferredValue:function(e,t){return _s(Eo(),e,t)},useTransition:function(){var e=Ho(!1);return e=ys.bind(null,oo,e.queue,!0,!1),Eo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=oo,i=Eo();if(ki){if(n===void 0)throw Error(a(407));n=n()}else{if(n=t(),zl===null)throw Error(a(349));Vl&127||Lo(r,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,os(zo.bind(null,r,o,e),[e]),r.flags|=2048,ns(9,{destroy:void 0},Ro.bind(null,r,o,n,t),null),n},useId:function(){var e=Eo(),t=zl.identifierPrefix;if(ki){var n=xi,r=bi;n=(r&~(1<<32-je(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=po++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=go++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:ws,useFormState:Zo,useActionState:Zo,useOptimistic:function(e){var t=Eo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=js.bind(null,oo,!0,n),n.dispatch=t,[e,t]},useMemoCache:jo,useCacheRefresh:function(){return Eo().memoizedState=Ds.bind(null,oo)},useEffectEvent:function(e){var t=Eo(),n={impl:e};return t.memoizedState=n,function(){if(Rl&2)throw Error(a(440));return n.impl.apply(void 0,arguments)}}},Ls={readContext:K,use:Ao,useCallback:hs,useContext:K,useEffect:ss,useImperativeHandle:ps,useInsertionEffect:us,useLayoutEffect:ds,useMemo:gs,useReducer:No,useRef:rs,useState:function(){return No(Mo)},useDebugValue:ms,useDeferredValue:function(e,t){return vs(Do(),so.memoizedState,e,t)},useTransition:function(){var e=No(Mo)[0],t=Do().memoizedState;return[typeof e==`boolean`?e:ko(e),t]},useSyncExternalStore:Io,useId:Ts,useHostTransitionStatus:ws,useFormState:Qo,useActionState:Qo,useOptimistic:function(e,t){return Uo(Do(),so,e,t)},useMemoCache:jo,useCacheRefresh:Es};Ls.useEffectEvent=ls;var Rs={readContext:K,use:Ao,useCallback:hs,useContext:K,useEffect:ss,useImperativeHandle:ps,useInsertionEffect:us,useLayoutEffect:ds,useMemo:gs,useReducer:Fo,useRef:rs,useState:function(){return Fo(Mo)},useDebugValue:ms,useDeferredValue:function(e,t){var n=Do();return so===null?_s(n,e,t):vs(n,so.memoizedState,e,t)},useTransition:function(){var e=Fo(Mo)[0],t=Do().memoizedState;return[typeof e==`boolean`?e:ko(e),t]},useSyncExternalStore:Io,useId:Ts,useHostTransitionStatus:ws,useFormState:ts,useActionState:ts,useOptimistic:function(e,t){var n=Do();return so===null?(n.baseState=e,[e,n.queue.dispatch]):Uo(n,so,e,t)},useMemoCache:jo,useCacheRefresh:Es};Rs.useEffectEvent=ls;function zs(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:h({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Bs={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=_u(),i=Ia(r);i.payload=t,n!=null&&(i.callback=n),t=La(e,i,r),t!==null&&(yu(t,e,r),Ra(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=_u(),i=Ia(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=La(e,i,r),t!==null&&(yu(t,e,r),Ra(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=_u(),r=Ia(n);r.tag=2,t!=null&&(r.callback=t),t=La(e,r,n),t!==null&&(yu(t,e,n),Ra(t,e,n))}};function Vs(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!_r(n,r)||!_r(i,a):!0}function Hs(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Bs.enqueueReplaceState(t,t.state,null)}function Us(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=h({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Ws(e){Wr(e)}function Gs(e){console.error(e)}function Ks(e){Wr(e)}function qs(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Js(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Ys(e,t,n){return n=Ia(n),n.tag=3,n.payload={element:null},n.callback=function(){qs(e,t)},n}function Xs(e){return e=Ia(e),e.tag=3,e}function Zs(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Js(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Js(t,n,r),typeof i!=`function`&&(su===null?su=new Set([this]):su.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function Qs(e,t,n,r,i){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Ki(t,n,i,!0),n=Xa.current,n!==null){switch(n.tag){case 31:case 13:return Za===null?ju():n.alternate===null&&Jl===0&&(Jl=3),n.flags&=-257,n.flags|=65536,n.lanes=i,r===va?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Xu(e,r,i)),!1;case 22:return n.flags|=65536,r===va?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),Xu(e,r,i)),!1}throw Error(a(435,n.tag))}return Xu(e,r,i),ju(),!1}if(ki)return t=Xa.current,t===null?(r!==G&&(t=Error(a(423),{cause:r}),Ri(fi(t,n))),e=e.current.alternate,e.flags|=65536,i&=-i,e.lanes|=i,r=fi(r,n),i=Ys(e.stateNode,r,i),za(e,i),Jl!==4&&(Jl=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=i,r!==G&&(e=Error(a(422),{cause:r}),Ri(fi(e,n)))),!1;var o=Error(a(520),{cause:r});if(o=fi(o,n),eu===null?eu=[o]:eu.push(o),Jl!==4&&(Jl=2),t===null)return!0;r=fi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=i&-i,n.lanes|=e,e=Ys(n.stateNode,r,e),za(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(su===null||!su.has(o))))return n.flags|=65536,i&=-i,n.lanes|=i,i=Xs(i),Zs(i,e,n,r),za(n,i),!1}n=n.return}while(n!==null);return!1}var $s=Error(a(461)),ec=!1;function tc(e,t,n,r){t.child=e===null?Ma(t,null,n,r):ja(t,e.child,n,r)}function nc(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Ji(t),r=yo(e,t,n,o,a,i),s=Co(),e!==null&&!ec?(wo(e,t,i),Ec(e,t,i)):(ki&&s&&wi(t),t.flags|=1,tc(e,t,r,i),t.child)}function rc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!ri(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,ic(e,t,a,r,i)):(e=oi(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Dc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?_r:n,n(o,r)&&e.ref===t.ref)return Ec(e,t,i)}return t.flags|=1,e=ii(a,r),e.ref=t.ref,e.return=t,t.child=e}function ic(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(_r(a,r)&&e.ref===t.ref)if(ec=!1,t.pendingProps=r=a,Dc(e,i))e.flags&131072&&(ec=!0);else return t.lanes=e.lanes,Ec(e,t,i)}return fc(e,t,n,r,i)}function ac(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return sc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&pa(t,a===null?null:a.cachePool),a===null?Ja():qa(t,a),eo(t);else return r=t.lanes=536870912,sc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&pa(t,null),Ja(),to(t)):(pa(t,a.cachePool),qa(t,a),to(t),t.memoizedState=null);return tc(e,t,i,n),t.child}function oc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function sc(e,t,n,r,i){var a=fa();return a=a===null?null:{parent:ea._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&pa(t,null),Ja(),eo(t),e!==null&&Ki(e,t,r,!0),t.childLanes=i,null}function cc(e,t){return t=xc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function lc(e,t,n){return ja(t,e.child,null,n),e=cc(t,t.pendingProps),e.flags|=2,no(t),t.memoizedState=null,e}function uc(e,t,n){var r=t.pendingProps,i=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(ki){if(r.mode===`hidden`)return e=cc(t,r),t.lanes=536870912,oc(null,e);if($a(t),(e=Oi)?(e=df(e,ji),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:yi===null?null:{id:bi,overflow:xi},retryLane:536870912,hydrationErrors:null},n=li(e),n.return=t,t.child=n,Di=t,Oi=null)):e=null,e===null)throw Mi(t);return t.lanes=536870912,null}return cc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if($a(t),i)if(t.flags&256)t.flags&=-257,t=lc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(a(558));else if(ec||Ki(e,t,n,!1),i=(n&e.childLanes)!==0,ec||i){if(r=zl,r!==null&&(s=Je(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Zr(e,s),yu(r,e,s),$s;ju(),t=lc(e,t,n)}else e=o.treeContext,Oi=hf(s.nextSibling),Di=t,ki=!0,Ai=null,ji=!1,e!==null&&Ei(t,e),t=cc(t,r),t.flags|=4096;return t}return e=ii(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function dc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(a(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function fc(e,t,n,r,i){return Ji(t),n=yo(e,t,n,r,void 0,i),r=Co(),e!==null&&!ec?(wo(e,t,i),Ec(e,t,i)):(ki&&r&&wi(t),t.flags|=1,tc(e,t,n,i),t.child)}function pc(e,t,n,r,i,a){return Ji(t),t.updateQueue=null,n=xo(t,r,n,i),bo(e),r=Co(),e!==null&&!ec?(wo(e,t,a),Ec(e,t,a)):(ki&&r&&wi(t),t.flags|=1,tc(e,t,n,a),t.child)}function mc(e,t,n,r,i){if(Ji(t),t.stateNode===null){var a=ei,o=n.contextType;typeof o==`object`&&o&&(a=K(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Bs,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},Pa(t),o=n.contextType,a.context=typeof o==`object`&&o?K(o):ei,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(zs(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Bs.enqueueReplaceState(a,a.state,null),Ha(t,r,a,i),Va(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Us(n,s);a.props=c;var l=a.context,u=n.contextType;o=ei,typeof u==`object`&&u&&(o=K(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Hs(t,a,r,o),Na=!1;var f=t.memoizedState;a.state=f,Ha(t,r,a,i),Va(),l=t.memoizedState,s||f!==l||Na?(typeof d==`function`&&(zs(t,n,d,r),l=t.memoizedState),(c=Na||Vs(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,Fa(e,t),o=t.memoizedProps,u=Us(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=ei,typeof l==`object`&&l&&(c=K(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Hs(t,a,r,c),Na=!1,f=t.memoizedState,a.state=f,Ha(t,r,a,i),Va();var p=t.memoizedState;o!==d||f!==p||Na||e!==null&&e.dependencies!==null&&qi(e.dependencies)?(typeof s==`function`&&(zs(t,n,s,r),p=t.memoizedState),(u=Na||Vs(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&qi(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,dc(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=ja(t,e.child,null,i),t.child=ja(t,null,n,i)):tc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=Ec(e,t,i),e}function hc(e,t,n,r){return Ii(),t.flags|=256,tc(e,t,n,r),t.child}var gc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function _c(e){return{baseLanes:e,cachePool:ma()}}function vc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=Ql),e}function yc(e,t,n){var r=t.pendingProps,i=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(ro.current&2)!=0),s&&(i=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(ki){if(i?Qa(t):to(t),(e=Oi)?(e=df(e,ji),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:yi===null?null:{id:bi,overflow:xi},retryLane:536870912,hydrationErrors:null},n=li(e),n.return=t,t.child=n,Di=t,Oi=null)):e=null,e===null)throw Mi(t);return pf(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,i?(to(t),i=t.mode,c=xc({mode:`hidden`,children:c},i),r=si(r,i,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=_c(n),r.childLanes=vc(e,s,n),t.memoizedState=gc,oc(null,r)):(Qa(t),bc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(Qa(t),t.flags&=-257,t=Sc(e,t,n)):t.memoizedState===null?(to(t),c=r.fallback,i=t.mode,r=xc({mode:`visible`,children:r.children},i),c=si(c,i,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,ja(t,e.child,null,n),r=t.child,r.memoizedState=_c(n),r.childLanes=vc(e,s,n),t.memoizedState=gc,t=oc(null,r)):(to(t),t.child=e.child,t.flags|=128,t=null);else if(Qa(t),pf(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(a(419)),r.stack=``,r.digest=s,Ri({value:r,source:null,stack:null}),t=Sc(e,t,n)}else if(ec||Ki(e,t,n,!1),s=(n&e.childLanes)!==0,ec||s){if(s=zl,s!==null&&(r=Je(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,Zr(e,r),yu(s,e,r),$s;ff(c)||ju(),t=Sc(e,t,n)}else ff(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Oi=hf(c.nextSibling),Di=t,ki=!0,Ai=null,ji=!1,e!==null&&Ei(t,e),t=bc(t,r.children),t.flags|=4096);return t}return i?(to(t),c=r.fallback,i=t.mode,l=e.child,u=l.sibling,r=ii(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=si(c,i,n,null),c.flags|=2):c=ii(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,oc(null,r),r=t.child,c=e.child.memoizedState,c===null?c=_c(n):(i=c.cachePool,i===null?i=ma():(l=ea._currentValue,i=i.parent===l?i:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:i}),r.memoizedState=c,r.childLanes=vc(e,s,n),t.memoizedState=gc,oc(e.child,r)):(Qa(t),n=e.child,e=n.sibling,n=ii(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function bc(e,t){return t=xc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function xc(e,t){return e=ni(22,e,null,t),e.lanes=0,e}function Sc(e,t,n){return ja(t,e.child,null,n),e=bc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Cc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Wi(e.return,t,n)}function wc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function Tc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=ro.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,U(ro,o),tc(e,t,r,n),r=ki?gi:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Cc(e,n,t);else if(e.tag===19)Cc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&io(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),wc(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&io(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}wc(t,!0,n,null,a,r);break;case`together`:wc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function Ec(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Yl|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Ki(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(a(153));if(t.child!==null){for(e=t.child,n=ii(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=ii(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Dc(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&qi(e))):!0}function Oc(e,t,n){switch(t.tag){case 3:re(t,t.stateNode.containerInfo),Hi(t,ea,e.memoizedState.cache),Ii();break;case 27:case 5:ae(t);break;case 4:re(t,t.stateNode.containerInfo);break;case 10:Hi(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,$a(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(Qa(t),e=Ec(e,t,n),e===null?null:e.sibling):yc(e,t,n):(Qa(t),t.flags|=128,null);Qa(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(Ki(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return Tc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),U(ro,ro.current),r)break;return null;case 22:return t.lanes=0,ac(e,t,n,t.pendingProps);case 24:Hi(t,ea,e.memoizedState.cache)}return Ec(e,t,n)}function kc(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)ec=!0;else{if(!Dc(e,n)&&!(t.flags&128))return ec=!1,Oc(e,t,n);ec=!!(e.flags&131072)}else ec=!1,ki&&t.flags&1048576&&Ci(t,gi,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=xa(t.elementType),t.type=e,typeof e==`function`)ri(e)?(r=Us(e,r),t.tag=1,t=mc(null,t,e,r,n)):(t.tag=0,t=fc(null,t,e,r,n));else{if(e!=null){var i=e.$$typeof;if(i===w){t.tag=11,t=nc(null,t,e,r,n);break a}else if(i===D){t.tag=14,t=rc(null,t,e,r,n);break a}}throw t=P(e)||e,Error(a(306,t,``))}}return t;case 0:return fc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,i=Us(r,t.pendingProps),mc(e,t,r,i,n);case 3:a:{if(re(t,t.stateNode.containerInfo),e===null)throw Error(a(387));r=t.pendingProps;var o=t.memoizedState;i=o.element,Fa(e,t),Ha(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Hi(t,ea,r),r!==o.cache&&Gi(t,[ea],n,!0),Va(),r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=hc(e,t,r,n);break a}else if(r!==i){i=fi(Error(a(424)),t),Ri(i),t=hc(e,t,r,n);break a}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(Oi=hf(e.firstChild),Di=t,ki=!0,Ai=null,ji=!0,n=Ma(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Ii(),r===i){t=Ec(e,t,n);break a}tc(e,t,r,n)}t=t.child}return t;case 26:return dc(e,t),e===null?(n=If(t.type,null,t.pendingProps,null))?t.memoizedState=n:ki||(n=t.type,e=t.pendingProps,r=qd(te.current).createElement(n),r[et]=t,r[tt]=e,Vd(r,n,e),pt(r),t.stateNode=r):t.memoizedState=If(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return ae(t),e===null&&ki&&(r=t.stateNode=yf(t.type,t.pendingProps,te.current),Di=t,ji=!0,i=Oi,af(t.type)?(gf=i,Oi=hf(r.firstChild)):Oi=i),tc(e,t,t.pendingProps.children,n),dc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&ki&&((i=r=Oi)&&(r=lf(r,t.type,t.pendingProps,ji),r===null?i=!1:(t.stateNode=r,Di=t,Oi=hf(r.firstChild),ji=!1,i=!0)),i||Mi(t)),ae(t),i=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,Xd(i,o)?r=null:s!==null&&Xd(i,s)&&(t.flags|=32),t.memoizedState!==null&&(i=yo(e,t,So,null,null,n),ap._currentValue=i),dc(e,t),tc(e,t,r,n),t.child;case 6:return e===null&&ki&&((e=n=Oi)&&(n=uf(n,t.pendingProps,ji),n===null?e=!1:(t.stateNode=n,Di=t,Oi=null,e=!0)),e||Mi(t)),null;case 13:return yc(e,t,n);case 4:return re(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=ja(t,null,r,n):tc(e,t,r,n),t.child;case 11:return nc(e,t,t.type,t.pendingProps,n);case 7:return tc(e,t,t.pendingProps,n),t.child;case 8:return tc(e,t,t.pendingProps.children,n),t.child;case 12:return tc(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Hi(t,t.type,r.value),tc(e,t,r.children,n),t.child;case 9:return i=t.type._context,r=t.pendingProps.children,Ji(t),i=K(i),r=r(i),t.flags|=1,tc(e,t,r,n),t.child;case 14:return rc(e,t,t.type,t.pendingProps,n);case 15:return ic(e,t,t.type,t.pendingProps,n);case 19:return Tc(e,t,n);case 31:return uc(e,t,n);case 22:return ac(e,t,n,t.pendingProps);case 24:return Ji(t),r=K(ea),e===null?(i=fa(),i===null&&(i=zl,o=ta(),i.pooledCache=o,o.refCount++,o!==null&&(i.pooledCacheLanes|=n),i=o),t.memoizedState={parent:r,cache:i},Pa(t),Hi(t,ea,i)):((e.lanes&n)!==0&&(Fa(e,t),Ha(t,null,null,n),Va()),i=e.memoizedState,o=t.memoizedState,i.parent===r?(r=o.cache,Hi(t,ea,r),r!==i.cache&&Gi(t,[ea],n,!0)):(i={parent:r,cache:r},t.memoizedState=i,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=i),Hi(t,ea,r))),tc(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(a(156,t.tag))}function Ac(e){e.flags|=4}function jc(e,t,n,r,i){if((t=(e.mode&32)!=0)&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i)if(e.stateNode.complete)e.flags|=8192;else if(Ou())e.flags|=8192;else throw Sa=va,ga}else e.flags&=-16777217}function Mc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Zf(t))if(Ou())e.flags|=8192;else throw Sa=va,ga}function Nc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:He(),e.lanes|=t,$l|=t)}function Pc(e,t){if(!ki)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Fc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Ic(e,t,n){var r=t.pendingProps;switch(Ti(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Fc(t),null;case 1:return Fc(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Ui(ea),ie(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Fi(t)?Ac(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Li())),Fc(t),null;case 26:var i=t.type,o=t.memoizedState;return e===null?(Ac(t),o===null?(Fc(t),jc(t,i,null,r,n)):(Fc(t),Mc(t,o))):o?o===e.memoizedState?(Fc(t),t.flags&=-16777217):(Ac(t),Fc(t),Mc(t,o)):(e=e.memoizedProps,e!==r&&Ac(t),Fc(t),jc(t,i,e,r,n)),null;case 27:if(oe(t),n=te.current,i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Ac(t);else{if(!r){if(t.stateNode===null)throw Error(a(166));return Fc(t),null}e=ee.current,Fi(t)?Ni(t,e):(e=yf(i,r,n),t.stateNode=e,Ac(t))}return Fc(t),null;case 5:if(oe(t),i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Ac(t);else{if(!r){if(t.stateNode===null)throw Error(a(166));return Fc(t),null}if(o=ee.current,Fi(t))Ni(t,o);else{var s=qd(te.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,i);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,i);break;default:switch(i){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,i);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,i);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(i,{is:r.is}):s.createElement(i)}}o[et]=t,o[tt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Vd(o,i,r),i){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Ac(t)}}return Fc(t),jc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Ac(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(a(166));if(e=te.current,Fi(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=Di,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[et]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Rd(e.nodeValue,n)),e||Mi(t,!0)}else e=qd(e).createTextNode(r),e[et]=t,t.stateNode=e}return Fc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Fi(t),n!==null){if(e===null){if(!r)throw Error(a(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(a(557));e[et]=t}else Ii(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Fc(t),e=!1}else n=Li(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(no(t),t):(no(t),null);if(t.flags&128)throw Error(a(558))}return Fc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=Fi(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(a(318));if(i=t.memoizedState,i=i===null?null:i.dehydrated,!i)throw Error(a(317));i[et]=t}else Ii(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Fc(t),i=!1}else i=Li(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(no(t),t):(no(t),null)}return no(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,i=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(i=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==i&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Nc(t,t.updateQueue),Fc(t),null);case 4:return ie(),e===null&&Od(t.stateNode.containerInfo),Fc(t),null;case 10:return Ui(t.type),Fc(t),null;case 19:if(H(ro),r=t.memoizedState,r===null)return Fc(t),null;if(i=(t.flags&128)!=0,o=r.rendering,o===null)if(i)Pc(r,!1);else{if(Jl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=io(e),o!==null){for(t.flags|=128,Pc(r,!1),e=o.updateQueue,t.updateQueue=e,Nc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)ai(n,e),n=n.sibling;return U(ro,ro.current&1|2),ki&&Si(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&ye()>au&&(t.flags|=128,i=!0,Pc(r,!1),t.lanes=4194304)}else{if(!i)if(e=io(o),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,Nc(t,e),Pc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!ki)return Fc(t),null}else 2*ye()-r.renderingStartTime>au&&n!==536870912&&(t.flags|=128,i=!0,Pc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Fc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=ye(),e.sibling=null,n=ro.current,U(ro,i?n&1|2:n&1),ki&&Si(t,r.treeForkCount),e);case 22:case 23:return no(t),Ya(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Fc(t),t.subtreeFlags&6&&(t.flags|=8192)):Fc(t),n=t.updateQueue,n!==null&&Nc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&H(da),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Ui(ea),Fc(t),null;case 25:return null;case 30:return null}throw Error(a(156,t.tag))}function Lc(e,t){switch(Ti(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ui(ea),ie(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return oe(t),null;case 31:if(t.memoizedState!==null){if(no(t),t.alternate===null)throw Error(a(340));Ii()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(no(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(a(340));Ii()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return H(ro),null;case 4:return ie(),null;case 10:return Ui(t.type),null;case 22:case 23:return no(t),Ya(),e!==null&&H(da),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ui(ea),null;case 25:return null;default:return null}}function Rc(e,t){switch(Ti(t),t.tag){case 3:Ui(ea),ie();break;case 26:case 27:case 5:oe(t);break;case 4:ie();break;case 31:t.memoizedState!==null&&no(t);break;case 13:no(t);break;case 19:H(ro);break;case 10:Ui(t.type);break;case 22:case 23:no(t),Ya(),e!==null&&H(da);break;case 24:Ui(ea)}}function zc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Yu(t,t.return,e)}}function Bc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Yu(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Yu(t,t.return,e)}}function Vc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Wa(t,n)}catch(t){Yu(e,e.return,t)}}}function Hc(e,t,n){n.props=Us(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Yu(e,t,n)}}function Uc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Yu(e,t,n)}}function Wc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Yu(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Yu(e,t,n)}else n.current=null}function Gc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Yu(e,e.return,t)}}function Kc(e,t,n){try{var r=e.stateNode;Hd(r,e.type,n,t),r[tt]=t}catch(t){Yu(e,e.return,t)}}function qc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&af(e.type)||e.tag===4}function Jc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||qc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&af(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Yc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=qt));else if(r!==4&&(r===27&&af(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Yc(e,t,n),e=e.sibling;e!==null;)Yc(e,t,n),e=e.sibling}function Xc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&af(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Xc(e,t,n),e=e.sibling;e!==null;)Xc(e,t,n),e=e.sibling}function Zc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Vd(t,r,n),t[et]=e,t[tt]=n}catch(t){Yu(e,e.return,t)}}var Qc=!1,$c=!1,el=!1,tl=typeof WeakSet==`function`?WeakSet:Set,nl=null;function rl(e,t){if(e=e.containerInfo,Gd=q,e=xr(e),Sr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||i!==0&&f.nodeType!==3||(c=s+i),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===i&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Kd={focusedElem:e,selectionRange:n},q=!1,nl=t;nl!==null;)if(t=nl,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,nl=e;else for(;nl!==null;){switch(t=nl,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)i=e[n],i.ref.impl=i.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,i=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=Us(n.type,i);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){Yu(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)cf(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:cf(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(a(163))}if(e=t.sibling,e!==null){e.return=t.return,nl=e;break}nl=t.return}}function il(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:yl(e,n),r&4&&zc(5,n);break;case 1:if(yl(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Yu(n,n.return,e)}else{var i=Us(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Yu(n,n.return,e)}}r&64&&Vc(n),r&512&&Uc(n,n.return);break;case 3:if(yl(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{Wa(e,t)}catch(e){Yu(n,n.return,e)}}break;case 27:t===null&&r&4&&Zc(n);case 26:case 5:yl(e,n),t===null&&r&4&&Gc(n),r&512&&Uc(n,n.return);break;case 12:yl(e,n);break;case 31:yl(e,n),r&4&&ul(e,n);break;case 13:yl(e,n),r&4&&dl(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=$u.bind(null,n),mf(e,n))));break;case 22:if(r=n.memoizedState!==null||Qc,!r){t=t!==null&&t.memoizedState!==null||$c,i=Qc;var a=$c;Qc=r,($c=t)&&!a?xl(e,n,(n.subtreeFlags&8772)!=0):yl(e,n),Qc=i,$c=a}break;case 30:break;default:yl(e,n)}}function al(e){var t=e.alternate;t!==null&&(e.alternate=null,al(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&ct(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var ol=null,sl=!1;function cl(e,t,n){for(n=n.child;n!==null;)ll(e,t,n),n=n.sibling}function ll(e,t,n){if(ke&&typeof ke.onCommitFiberUnmount==`function`)try{ke.onCommitFiberUnmount(Oe,n)}catch{}switch(n.tag){case 26:$c||Wc(n,t),cl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:$c||Wc(n,t);var r=ol,i=sl;af(n.type)&&(ol=n.stateNode,sl=!1),cl(e,t,n),bf(n.stateNode),ol=r,sl=i;break;case 5:$c||Wc(n,t);case 6:if(r=ol,i=sl,ol=null,cl(e,t,n),ol=r,sl=i,ol!==null)if(sl)try{(ol.nodeType===9?ol.body:ol.nodeName===`HTML`?ol.ownerDocument.body:ol).removeChild(n.stateNode)}catch(e){Yu(n,t,e)}else try{ol.removeChild(n.stateNode)}catch(e){Yu(n,t,e)}break;case 18:ol!==null&&(sl?(e=ol,of(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Rp(e)):of(ol,n.stateNode));break;case 4:r=ol,i=sl,ol=n.stateNode.containerInfo,sl=!0,cl(e,t,n),ol=r,sl=i;break;case 0:case 11:case 14:case 15:Bc(2,n,t),$c||Bc(4,n,t),cl(e,t,n);break;case 1:$c||(Wc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Hc(n,t,r)),cl(e,t,n);break;case 21:cl(e,t,n);break;case 22:$c=(r=$c)||n.memoizedState!==null,cl(e,t,n),$c=r;break;default:cl(e,t,n)}}function ul(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Rp(e)}catch(e){Yu(t,t.return,e)}}}function dl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Rp(e)}catch(e){Yu(t,t.return,e)}}function fl(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new tl),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new tl),t;default:throw Error(a(435,e.tag))}}function pl(e,t){var n=fl(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=ed.bind(null,e,t);t.then(r,r)}})}function ml(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(af(c.type)){ol=c.stateNode,sl=!1;break a}break;case 5:ol=c.stateNode,sl=!1;break a;case 3:case 4:ol=c.stateNode.containerInfo,sl=!0;break a}c=c.return}if(ol===null)throw Error(a(160));ll(o,s,i),ol=null,sl=!1,o=i.alternate,o!==null&&(o.return=null),i.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)gl(t,e),t=t.sibling}var hl=null;function gl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:ml(t,e),_l(e),r&4&&(Bc(3,e,e.return),zc(3,e),Bc(5,e,e.return));break;case 1:ml(t,e),_l(e),r&512&&($c||n===null||Wc(n,n.return)),r&64&&Qc&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var i=hl;if(ml(t,e),_l(e),r&512&&($c||n===null||Wc(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,i=i.ownerDocument||i;b:switch(r){case`title`:o=i.getElementsByTagName(`title`)[0],(!o||o[st]||o[et]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=i.createElement(r),i.head.insertBefore(o,i.querySelector(`head > title`))),Vd(o,r,n),o[et]=e,pt(o),r=o;break a;case`link`:var s=Jf(`link`,`href`,i).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=i.createElement(r),Vd(o,r,n),i.head.appendChild(o);break;case`meta`:if(s=Jf(`meta`,`content`,i).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=i.createElement(r),Vd(o,r,n),i.head.appendChild(o);break;default:throw Error(a(468,r))}o[et]=e,pt(o),r=o}e.stateNode=r}else Yf(i,e.type,e.stateNode);else e.stateNode=Uf(i,r,e.memoizedProps);else o===r?r===null&&e.stateNode!==null&&Kc(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?Yf(i,e.type,e.stateNode):Uf(i,r,e.memoizedProps))}break;case 27:ml(t,e),_l(e),r&512&&($c||n===null||Wc(n,n.return)),n!==null&&r&4&&Kc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(ml(t,e),_l(e),r&512&&($c||n===null||Wc(n,n.return)),e.flags&32){i=e.stateNode;try{zt(i,``)}catch(t){Yu(e,e.return,t)}}r&4&&e.stateNode!=null&&(i=e.memoizedProps,Kc(e,i,n===null?i:n.memoizedProps)),r&1024&&(el=!0);break;case 6:if(ml(t,e),_l(e),r&4){if(e.stateNode===null)throw Error(a(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){Yu(e,e.return,t)}}break;case 3:if(qf=null,i=hl,hl=Cf(t.containerInfo),ml(t,e),hl=i,_l(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Rp(t.containerInfo)}catch(t){Yu(e,e.return,t)}el&&(el=!1,vl(e));break;case 4:r=hl,hl=Cf(e.stateNode.containerInfo),ml(t,e),_l(e),hl=r;break;case 12:ml(t,e),_l(e);break;case 31:ml(t,e),_l(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,pl(e,r)));break;case 13:ml(t,e),_l(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(ru=ye()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,pl(e,r)));break;case 22:i=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=Qc,d=$c;if(Qc=u||i,$c=d||l,ml(t,e),$c=d,Qc=u,_l(e),r&8192)a:for(t=e.stateNode,t._visibility=i?t._visibility&-2:t._visibility|1,i&&(n===null||l||Qc||$c||bl(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,i)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){Yu(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=i?``:l.memoizedProps}catch(e){Yu(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;i?sf(m,!0):sf(l.stateNode,!1)}catch(e){Yu(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,pl(e,n))));break;case 19:ml(t,e),_l(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,pl(e,r)));break;case 30:break;case 21:break;default:ml(t,e),_l(e)}}function _l(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(qc(r)){n=r;break}r=r.return}if(n==null)throw Error(a(160));switch(n.tag){case 27:var i=n.stateNode;Xc(e,Jc(e),i);break;case 5:var o=n.stateNode;n.flags&32&&(zt(o,``),n.flags&=-33),Xc(e,Jc(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;Yc(e,Jc(e),s);break;default:throw Error(a(161))}}catch(t){Yu(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function vl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;vl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function yl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)il(e,t.alternate,t),t=t.sibling}function bl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Bc(4,t,t.return),bl(t);break;case 1:Wc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Hc(t,t.return,n),bl(t);break;case 27:bf(t.stateNode);case 26:case 5:Wc(t,t.return),bl(t);break;case 22:t.memoizedState===null&&bl(t);break;case 30:bl(t);break;default:bl(t)}e=e.sibling}}function xl(e,t,n){for(n&&=(t.subtreeFlags&8772)!=0,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:xl(i,a,n),zc(4,a);break;case 1:if(xl(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Yu(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)Ua(c[i],s)}catch(e){Yu(r,r.return,e)}}n&&o&64&&Vc(a),Uc(a,a.return);break;case 27:Zc(a);case 26:case 5:xl(i,a,n),n&&r===null&&o&4&&Gc(a),Uc(a,a.return);break;case 12:xl(i,a,n);break;case 31:xl(i,a,n),n&&o&4&&ul(i,a);break;case 13:xl(i,a,n),n&&o&4&&dl(i,a);break;case 22:a.memoizedState===null&&xl(i,a,n),Uc(a,a.return);break;case 30:break;default:xl(i,a,n)}t=t.sibling}}function Sl(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&na(n))}function Cl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&na(e))}function wl(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Tl(e,t,n,r),t=t.sibling}function Tl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:wl(e,t,n,r),i&2048&&zc(9,t);break;case 1:wl(e,t,n,r);break;case 3:wl(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&na(e)));break;case 12:if(i&2048){wl(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){Yu(t,t.return,e)}}else wl(e,t,n,r);break;case 31:wl(e,t,n,r);break;case 13:wl(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?wl(e,t,n,r):(a._visibility|=2,El(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?wl(e,t,n,r):Dl(e,t),i&2048&&Sl(o,t);break;case 24:wl(e,t,n,r),i&2048&&Cl(t.alternate,t);break;default:wl(e,t,n,r)}}function El(e,t,n,r,i){for(i&&=(t.subtreeFlags&10256)!=0||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:El(a,o,s,c,i),zc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,El(a,o,s,c,i)):u._visibility&2?El(a,o,s,c,i):Dl(a,o),i&&l&2048&&Sl(o.alternate,o);break;case 24:El(a,o,s,c,i),i&&l&2048&&Cl(o.alternate,o);break;default:El(a,o,s,c,i)}t=t.sibling}}function Dl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Dl(n,r),i&2048&&Sl(r.alternate,r);break;case 24:Dl(n,r),i&2048&&Cl(r.alternate,r);break;default:Dl(n,r)}t=t.sibling}}var Ol=8192;function kl(e,t,n){if(e.subtreeFlags&Ol)for(e=e.child;e!==null;)Al(e,t,n),e=e.sibling}function Al(e,t,n){switch(e.tag){case 26:kl(e,t,n),e.flags&Ol&&e.memoizedState!==null&&Qf(n,hl,e.memoizedState,e.memoizedProps);break;case 5:kl(e,t,n);break;case 3:case 4:var r=hl;hl=Cf(e.stateNode.containerInfo),kl(e,t,n),hl=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Ol,Ol=16777216,kl(e,t,n),Ol=r):kl(e,t,n));break;default:kl(e,t,n)}}function jl(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Ml(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];nl=r,Fl(r,e)}jl(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Nl(e),e=e.sibling}function Nl(e){switch(e.tag){case 0:case 11:case 15:Ml(e),e.flags&2048&&Bc(9,e,e.return);break;case 3:Ml(e);break;case 12:Ml(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Pl(e)):Ml(e);break;default:Ml(e)}}function Pl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];nl=r,Fl(r,e)}jl(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Bc(8,t,t.return),Pl(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Pl(t));break;default:Pl(t)}e=e.sibling}}function Fl(e,t){for(;nl!==null;){var n=nl;switch(n.tag){case 0:case 11:case 15:Bc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:na(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,nl=r;else a:for(n=e;nl!==null;){r=nl;var i=r.sibling,a=r.return;if(al(r),r===n){nl=null;break a}if(i!==null){i.return=a,nl=i;break a}nl=a}}}var Il={getCacheForType:function(e){var t=K(ea),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return K(ea).controller.signal}},Ll=typeof WeakMap==`function`?WeakMap:Map,Rl=0,zl=null,Bl=null,Vl=0,Hl=0,Ul=null,Wl=!1,Gl=!1,Kl=!1,ql=0,Jl=0,Yl=0,Xl=0,Zl=0,Ql=0,$l=0,eu=null,tu=null,nu=!1,ru=0,iu=0,au=1/0,ou=null,su=null,cu=0,lu=null,uu=null,du=0,fu=0,pu=null,mu=null,hu=0,gu=null;function _u(){return Rl&2&&Vl!==0?Vl&-Vl:I.T===null?Ze():gd()}function vu(){if(Ql===0)if(!(Vl&536870912)||ki){var e=Ie;Ie<<=1,!(Ie&3932160)&&(Ie=262144),Ql=e}else Ql=536870912;return e=Xa.current,e!==null&&(e.flags|=32),Ql}function yu(e,t,n){(e===zl&&(Hl===2||Hl===9)||e.cancelPendingCommit!==null)&&(Eu(e,0),Cu(e,Vl,Ql,!1)),We(e,n),(!(Rl&2)||e!==zl)&&(e===zl&&(!(Rl&2)&&(Xl|=n),Jl===4&&Cu(e,Vl,Ql,!1)),cd(e))}function bu(e,t,n){if(Rl&6)throw Error(a(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||Be(e,t),i=r?Pu(e,t):Mu(e,t,!0),o=r;do{if(i===0){Gl&&!r&&Cu(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!Su(n)){i=Mu(e,t,!1),o=!1;continue}if(i===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;i=eu;var l=c.current.memoizedState.isDehydrated;if(l&&(Eu(c,s).flags|=256),s=Mu(c,s,!1),s!==2){if(Kl&&!l){c.errorRecoveryDisabledLanes|=o,Xl|=o,i=4;break a}o=tu,tu=i,o!==null&&(tu===null?tu=o:tu.push.apply(tu,o))}i=s}if(o=!1,i!==2)continue}}if(i===1){Eu(e,0),Cu(e,t,0,!0);break}a:{switch(r=e,o=i,o){case 0:case 1:throw Error(a(345));case 4:if((t&4194048)!==t)break;case 6:Cu(r,t,Ql,!Wl);break a;case 2:tu=null;break;case 3:case 5:break;default:throw Error(a(329))}if((t&62914560)===t&&(i=ru+300-ye(),10<i)){if(Cu(r,t,Ql,!Wl),ze(r,0,!0)!==0)break a;du=t,r.timeoutHandle=$d(xu.bind(null,r,n,tu,ou,nu,t,Ql,Xl,$l,Wl,o,`Throttled`,-0,0),i);break a}xu(r,n,tu,ou,nu,t,Ql,Xl,$l,Wl,o,null,-0,0)}}break}while(1);cd(e)}function xu(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:qt},Al(t,a,d);var m=(a&62914560)===a?ru-ye():(a&4194048)===a?iu-ye():0;if(m=ep(d,m),m!==null){du=a,e.cancelPendingCommit=m(Vu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),Cu(e,a,o,!l);return}}Vu(e,t,a,n,r,i,o,s,c)}function Su(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!gr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Cu(e,t,n,r){t&=~Zl,t&=~Xl,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-je(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&Ke(e,n,t)}function wu(){return Rl&6?!0:(ld(0,!1),!1)}function Tu(){if(Bl!==null){if(Hl===0)var e=Bl.return;else e=Bl,Vi=Bi=null,To(e),Ta=null,Ea=0,e=Bl;for(;e!==null;)Rc(e.alternate,e),e=e.return;Bl=null}}function Eu(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,ef(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),du=0,Tu(),zl=e,Bl=n=ii(e.current,null),Vl=t,Hl=0,Ul=null,Wl=!1,Gl=Be(e,t),Kl=!1,$l=Ql=Zl=Xl=Yl=Jl=0,tu=eu=null,nu=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-je(r),a=1<<i;t|=e[i],r&=~a}return ql=t,Jr(),n}function Du(e,t){oo=null,I.H=Fs,t===ha||t===_a?(t=Ca(),Hl=3):t===ga?(t=Ca(),Hl=4):Hl=t===$s?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Ul=t,Bl===null&&(Jl=1,qs(e,fi(t,e.current)))}function Ou(){var e=Xa.current;return e===null?!0:(Vl&4194048)===Vl?Za===null:(Vl&62914560)===Vl||Vl&536870912?e===Za:!1}function ku(){var e=I.H;return I.H=Fs,e===null?Fs:e}function Au(){var e=I.A;return I.A=Il,e}function ju(){Jl=4,Wl||(Vl&4194048)!==Vl&&Xa.current!==null||(Gl=!0),!(Yl&134217727)&&!(Xl&134217727)||zl===null||Cu(zl,Vl,Ql,!1)}function Mu(e,t,n){var r=Rl;Rl|=2;var i=ku(),a=Au();(zl!==e||Vl!==t)&&(ou=null,Eu(e,t)),t=!1;var o=Jl;a:do try{if(Hl!==0&&Bl!==null){var s=Bl,c=Ul;switch(Hl){case 8:Tu(),o=6;break a;case 3:case 2:case 9:case 6:Xa.current===null&&(t=!0);var l=Hl;if(Hl=0,Ul=null,Ru(e,s,c,l),n&&Gl){o=0;break a}break;default:l=Hl,Hl=0,Ul=null,Ru(e,s,c,l)}}Nu(),o=Jl;break}catch(t){Du(e,t)}while(1);return t&&e.shellSuspendCounter++,Vi=Bi=null,Rl=r,I.H=i,I.A=a,Bl===null&&(zl=null,Vl=0,Jr()),o}function Nu(){for(;Bl!==null;)Iu(Bl)}function Pu(e,t){var n=Rl;Rl|=2;var r=ku(),i=Au();zl!==e||Vl!==t?(ou=null,au=ye()+500,Eu(e,t)):Gl=Be(e,t);a:do try{if(Hl!==0&&Bl!==null){t=Bl;var o=Ul;b:switch(Hl){case 1:Hl=0,Ul=null,Ru(e,t,o,1);break;case 2:case 9:if(ya(o)){Hl=0,Ul=null,Lu(t);break}t=function(){Hl!==2&&Hl!==9||zl!==e||(Hl=7),cd(e)},o.then(t,t);break a;case 3:Hl=7;break a;case 4:Hl=5;break a;case 7:ya(o)?(Hl=0,Ul=null,Lu(t)):(Hl=0,Ul=null,Ru(e,t,o,7));break;case 5:var s=null;switch(Bl.tag){case 26:s=Bl.memoizedState;case 5:case 27:var c=Bl;if(s?Zf(s):c.stateNode.complete){Hl=0,Ul=null;var l=c.sibling;if(l!==null)Bl=l;else{var u=c.return;u===null?Bl=null:(Bl=u,zu(u))}break b}}Hl=0,Ul=null,Ru(e,t,o,5);break;case 6:Hl=0,Ul=null,Ru(e,t,o,6);break;case 8:Tu(),Jl=6;break a;default:throw Error(a(462))}}Fu();break}catch(t){Du(e,t)}while(1);return Vi=Bi=null,I.H=r,I.A=i,Rl=n,Bl===null?(zl=null,Vl=0,Jr(),Jl):0}function Fu(){for(;Bl!==null&&!_e();)Iu(Bl)}function Iu(e){var t=kc(e.alternate,e,ql);e.memoizedProps=e.pendingProps,t===null?zu(e):Bl=t}function Lu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=pc(n,t,t.pendingProps,t.type,void 0,Vl);break;case 11:t=pc(n,t,t.pendingProps,t.type.render,t.ref,Vl);break;case 5:To(t);default:Rc(n,t),t=Bl=ai(t,ql),t=kc(n,t,ql)}e.memoizedProps=e.pendingProps,t===null?zu(e):Bl=t}function Ru(e,t,n,r){Vi=Bi=null,To(t),Ta=null,Ea=0;var i=t.return;try{if(Qs(e,i,t,n,Vl)){Jl=1,qs(e,fi(n,e.current)),Bl=null;return}}catch(t){if(i!==null)throw Bl=i,t;Jl=1,qs(e,fi(n,e.current)),Bl=null;return}t.flags&32768?(ki||r===1?e=!0:Gl||Vl&536870912?e=!1:(Wl=e=!0,(r===2||r===9||r===3||r===6)&&(r=Xa.current,r!==null&&r.tag===13&&(r.flags|=16384))),Bu(t,e)):zu(t)}function zu(e){var t=e;do{if(t.flags&32768){Bu(t,Wl);return}e=t.return;var n=Ic(t.alternate,t,ql);if(n!==null){Bl=n;return}if(t=t.sibling,t!==null){Bl=t;return}Bl=t=e}while(t!==null);Jl===0&&(Jl=5)}function Bu(e,t){do{var n=Lc(e.alternate,e);if(n!==null){n.flags&=32767,Bl=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Bl=e;return}Bl=e=n}while(e!==null);Jl=6,Bl=null}function Vu(e,t,n,r,i,o,s,c,l){e.cancelPendingCommit=null;do Ku();while(cu!==0);if(Rl&6)throw Error(a(327));if(t!==null){if(t===e.current)throw Error(a(177));if(o=t.lanes|t.childLanes,o|=qr,Ge(e,n,o,s,c,l),e===zl&&(Bl=zl=null,Vl=0),uu=t,lu=e,du=n,fu=o,pu=i,mu=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,td(Ce,function(){return qu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=I.T,I.T=null,i=L.p,L.p=2,s=Rl,Rl|=4;try{rl(e,t,n)}finally{Rl=s,L.p=i,I.T=r}}cu=1,Hu(),Uu(),Wu()}}function Hu(){if(cu===1){cu=0;var e=lu,t=uu,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=I.T,I.T=null;var r=L.p;L.p=2;var i=Rl;Rl|=4;try{gl(t,e);var a=Kd,o=xr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&br(s.ownerDocument.documentElement,s)){if(c!==null&&Sr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=yr(s,h),v=yr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}q=!!Gd,Kd=Gd=null}finally{Rl=i,L.p=r,I.T=n}}e.current=t,cu=2}}function Uu(){if(cu===2){cu=0;var e=lu,t=uu,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=I.T,I.T=null;var r=L.p;L.p=2;var i=Rl;Rl|=4;try{il(e,t.alternate,t)}finally{Rl=i,L.p=r,I.T=n}}cu=3}}function Wu(){if(cu===4||cu===3){cu=0,ve();var e=lu,t=uu,n=du,r=mu;t.subtreeFlags&10256||t.flags&10256?cu=5:(cu=0,uu=lu=null,Gu(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(su=null),Xe(n),t=t.stateNode,ke&&typeof ke.onCommitFiberRoot==`function`)try{ke.onCommitFiberRoot(Oe,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=I.T,i=L.p,L.p=2,I.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{I.T=t,L.p=i}}du&3&&Ku(),cd(e),i=e.pendingLanes,n&261930&&i&42?e===gu?hu++:(hu=0,gu=e):hu=0,ld(0,!1)}}function Gu(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,na(t)))}function Ku(){return Hu(),Uu(),Wu(),qu()}function qu(){if(cu!==5)return!1;var e=lu,t=fu;fu=0;var n=Xe(du),r=I.T,i=L.p;try{L.p=32>n?32:n,I.T=null,n=pu,pu=null;var o=lu,s=du;if(cu=0,uu=lu=null,du=0,Rl&6)throw Error(a(331));var c=Rl;if(Rl|=4,Nl(o.current),Tl(o,o.current,s,n),Rl=c,ld(0,!1),ke&&typeof ke.onPostCommitFiberRoot==`function`)try{ke.onPostCommitFiberRoot(Oe,o)}catch{}return!0}finally{L.p=i,I.T=r,Gu(e,t)}}function Ju(e,t,n){t=fi(n,t),t=Ys(e.stateNode,t,2),e=La(e,t,2),e!==null&&(We(e,2),cd(e))}function Yu(e,t,n){if(e.tag===3)Ju(e,e,n);else for(;t!==null;){if(t.tag===3){Ju(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(su===null||!su.has(r))){e=fi(n,e),n=Xs(2),r=La(t,n,2),r!==null&&(Zs(n,r,t,e),We(r,2),cd(r));break}}t=t.return}}function Xu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Ll;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Kl=!0,i.add(n),e=Zu.bind(null,e,t,n),t.then(e,e))}function Zu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,zl===e&&(Vl&n)===n&&(Jl===4||Jl===3&&(Vl&62914560)===Vl&&300>ye()-ru?!(Rl&2)&&Eu(e,0):Zl|=n,$l===Vl&&($l=0)),cd(e)}function Qu(e,t){t===0&&(t=He()),e=Zr(e,t),e!==null&&(We(e,t),cd(e))}function $u(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Qu(e,n)}function ed(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(a(314))}r!==null&&r.delete(t),Qu(e,n)}function td(e,t){return he(e,t)}var nd=null,rd=null,id=!1,ad=!1,od=!1,sd=0;function cd(e){e!==rd&&e.next===null&&(rd===null?nd=rd=e:rd=rd.next=e),ad=!0,id||(id=!0,hd())}function ld(e,t){if(!od&&ad){od=!0;do for(var n=!1,r=nd;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-je(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,md(r,a))}else a=Vl,a=ze(r,r===zl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||Be(r,a)||(n=!0,md(r,a));r=r.next}while(n);od=!1}}function ud(){dd()}function dd(){ad=id=!1;var e=0;sd!==0&&Qd()&&(e=sd);for(var t=ye(),n=null,r=nd;r!==null;){var i=r.next,a=fd(r,t);a===0?(r.next=null,n===null?nd=i:n.next=i,i===null&&(rd=n)):(n=r,(e!==0||a&3)&&(ad=!0)),r=i}cu!==0&&cu!==5||ld(e,!1),sd!==0&&(sd=0)}function fd(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-je(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=Ve(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=zl,n=Vl,n=ze(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Hl===2||Hl===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&ge(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||Be(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&ge(r),Xe(n)){case 2:case 8:n=Se;break;case 32:n=Ce;break;case 268435456:n=Te;break;default:n=Ce}return r=pd.bind(null,e),n=he(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&ge(r),e.callbackPriority=2,e.callbackNode=null,2}function pd(e,t){if(cu!==0&&cu!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Ku()&&e.callbackNode!==n)return null;var r=Vl;return r=ze(e,e===zl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(bu(e,r,t),fd(e,ye()),e.callbackNode!=null&&e.callbackNode===n?pd.bind(null,e):null)}function md(e,t){if(Ku())return null;bu(e,t,!0)}function hd(){nf(function(){Rl&6?he(xe,ud):dd()})}function gd(){if(sd===0){var e=aa;e===0&&(e=Fe,Fe<<=1,!(Fe&261888)&&(Fe=256)),sd=e}return sd}function _d(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:Kt(``+e)}function vd(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function yd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=_d((i[tt]||null).action),o=r.submitter;o&&(t=(t=o[tt]||null)?_d(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new hn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(sd!==0){var e=o?vd(i,o):new FormData(i);xs(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?vd(i,o):new FormData(i),xs(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var bd=0;bd<Hr.length;bd++){var xd=Hr[bd];Ur(xd.toLowerCase(),`on`+(xd[0].toUpperCase()+xd.slice(1)))}Ur(Pr,`onAnimationEnd`),Ur(Fr,`onAnimationIteration`),Ur(Ir,`onAnimationStart`),Ur(`dblclick`,`onDoubleClick`),Ur(`focusin`,`onFocus`),Ur(`focusout`,`onBlur`),Ur(Lr,`onTransitionRun`),Ur(Rr,`onTransitionStart`),Ur(zr,`onTransitionCancel`),Ur(Br,`onTransitionEnd`),_t(`onMouseEnter`,[`mouseout`,`mouseover`]),_t(`onMouseLeave`,[`mouseout`,`mouseover`]),_t(`onPointerEnter`,[`pointerout`,`pointerover`]),_t(`onPointerLeave`,[`pointerout`,`pointerover`]),gt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),gt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),gt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),gt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),gt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),gt(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var Sd=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),Cd=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(Sd));function wd(e,t){t=(t&4)!=0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Wr(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Wr(e)}i.currentTarget=null,a=c}}}}function Td(e,t){var n=t[rt];n===void 0&&(n=t[rt]=new Set);var r=e+`__bubble`;n.has(r)||(kd(t,e,2,!1),n.add(r))}function Ed(e,t,n){var r=0;t&&(r|=4),kd(n,e,r,t)}var Dd=`_reactListening`+Math.random().toString(36).slice(2);function Od(e){if(!e[Dd]){e[Dd]=!0,mt.forEach(function(t){t!==`selectionchange`&&(Cd.has(t)||Ed(t,!1,e),Ed(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Dd]||(t[Dd]=!0,Ed(`selectionchange`,!1,t))}}function kd(e,t,n,r){switch(bp(t)){case 2:var i=mp;break;case 8:i=hp;break;default:i=gp}n=i.bind(null,t,n,e),i=void 0,!rn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Ad(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var s=r.stateNode.containerInfo;if(s===i)break;if(o===4)for(o=r.return;o!==null;){var c=o.tag;if((c===3||c===4)&&o.stateNode.containerInfo===i)return;o=o.return}for(;s!==null;){if(o=lt(s),o===null)return;if(c=o.tag,c===5||c===6||c===26||c===27){r=a=o;continue a}s=s.parentNode}}r=r.return}en(function(){var r=a,i=Yt(n),o=[];a:{var s=Vr.get(e);if(s!==void 0){var c=hn,u=e;switch(e){case`keypress`:if(un(n)===0)break a;case`keydown`:case`keyup`:c=Nn;break;case`focusin`:u=`focus`,c=wn;break;case`focusout`:u=`blur`,c=wn;break;case`beforeblur`:case`afterblur`:c=wn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:c=Sn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:c=Cn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:c=Fn;break;case Pr:case Fr:case Ir:c=Tn;break;case Br:c=In;break;case`scroll`:case`scrollend`:c=_n;break;case`wheel`:c=Ln;break;case`copy`:case`cut`:case`paste`:c=En;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:c=Pn;break;case`toggle`:case`beforetoggle`:c=Rn}var d=(t&4)!=0,f=!d&&(e===`scroll`||e===`scrollend`),p=d?s===null?null:s+`Capture`:s;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=tn(m,p),g!=null&&d.push(jd(m,g,h))),f)break;m=m.return}0<d.length&&(s=new c(s,u,null,n,i),o.push({event:s,listeners:d}))}}if(!(t&7)){a:{if(s=e===`mouseover`||e===`pointerover`,c=e===`mouseout`||e===`pointerout`,s&&n!==Jt&&(u=n.relatedTarget||n.fromElement)&&(lt(u)||u[nt]))break a;if((c||s)&&(s=i.window===i?i:(s=i.ownerDocument)?s.defaultView||s.parentWindow:window,c?(u=n.relatedTarget||n.toElement,c=r,u=u?lt(u):null,u!==null&&(f=l(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(c=null,u=r),c!==u)){if(d=Sn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Pn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=c==null?s:dt(c),h=u==null?s:dt(u),s=new d(g,m+`leave`,c,n,i),s.target=f,s.relatedTarget=h,g=null,lt(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,c&&u)b:{for(d=Nd,p=c,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;c!==null&&Pd(o,s,c,d,!1),u!==null&&f!==null&&Pd(o,f,u,d,!0)}}a:{if(s=r?dt(r):window,c=s.nodeName&&s.nodeName.toLowerCase(),c===`select`||c===`input`&&s.type===`file`)var v=ir;else if(Qn(s))if(ar)v=mr;else{v=fr;var y=dr}else c=s.nodeName,!c||c.toLowerCase()!==`input`||s.type!==`checkbox`&&s.type!==`radio`?r&&Ut(r.elementType)&&(v=ir):v=pr;if(v&&=v(e,r)){$n(o,v,n,i);break a}y&&y(e,s,r),e===`focusout`&&r&&s.type===`number`&&r.memoizedProps.value!=null&&Ft(s,`number`,s.value)}switch(y=r?dt(r):window,e){case`focusin`:(Qn(y)||y.contentEditable===`true`)&&(wr=y,Tr=r,Er=null);break;case`focusout`:Er=Tr=wr=null;break;case`mousedown`:Dr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Dr=!1,Or(o,n,i);break;case`selectionchange`:if(Cr)break;case`keydown`:case`keyup`:Or(o,n,i)}var b;if(Bn)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else Jn?Kn(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(Un&&n.locale!==`ko`&&(Jn||x!==`onCompositionStart`?x===`onCompositionEnd`&&Jn&&(b=ln()):(on=i,sn=`value`in on?on.value:on.textContent,Jn=!0)),y=Md(r,x),0<y.length&&(x=new Dn(x,e,null,n,i),o.push({event:x,listeners:y}),b?x.data=b:(b=qn(n),b!==null&&(x.data=b)))),(b=Hn?Yn(e,n):Xn(e,n))&&(x=Md(r,`onBeforeInput`),0<x.length&&(y=new Dn(`onBeforeInput`,`beforeinput`,null,n,i),o.push({event:y,listeners:x}),y.data=b)),yd(o,e,r,n,i)}wd(o,t)})}function jd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Md(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=tn(e,n),i!=null&&r.unshift(jd(e,i,a)),i=tn(e,t),i!=null&&r.push(jd(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Nd(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Pd(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=tn(n,a),l!=null&&o.unshift(jd(n,l,c))):i||(l=tn(n,a),l!=null&&o.push(jd(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Fd=/\r\n?/g,Id=/\u0000|\uFFFD/g;function Ld(e){return(typeof e==`string`?e:``+e).replace(Fd,`
|
|
10
|
-
`).replace(Id,``)}function Rd(e,t){return t=Ld(t),Ld(e)===t}function zd(e,t,n,r,i,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||zt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&zt(e,``+r);break;case`className`:Ct(e,`class`,r);break;case`tabIndex`:Ct(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Ct(e,n,r);break;case`style`:Ht(e,r,o);break;case`data`:if(t!==`object`){Ct(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Kt(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&zd(e,t,`name`,i.name,i,null),zd(e,t,`formEncType`,i.formEncType,i,null),zd(e,t,`formMethod`,i.formMethod,i,null),zd(e,t,`formTarget`,i.formTarget,i,null)):(zd(e,t,`encType`,i.encType,i,null),zd(e,t,`method`,i.method,i,null),zd(e,t,`target`,i.target,i,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Kt(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=qt);break;case`onScroll`:r!=null&&Td(`scroll`,e);break;case`onScrollEnd`:r!=null&&Td(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(a(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(a(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=Kt(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Td(`beforetoggle`,e),Td(`toggle`,e),St(e,`popover`,r);break;case`xlinkActuate`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:wt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:wt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:wt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:St(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=Wt.get(n)||n,St(e,n,r))}}function Bd(e,t,n,r,i,o){switch(n){case`style`:Ht(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(a(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(a(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?zt(e,r):(typeof r==`number`||typeof r==`bigint`)&&zt(e,``+r);break;case`onScroll`:r!=null&&Td(`scroll`,e);break;case`onScrollEnd`:r!=null&&Td(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=qt);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!ht.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(i=n.endsWith(`Capture`),t=n.slice(2,i?n.length-7:void 0),o=e[tt]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,i),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,i);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):St(e,n,r)}}}function Vd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Td(`error`,e),Td(`load`,e);var r=!1,i=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:i=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(a(137,t));default:zd(e,t,o,s,n,null)}}i&&zd(e,t,`srcSet`,n.srcSet,n,null),r&&zd(e,t,`src`,n.src,n,null);return;case`input`:Td(`invalid`,e);var c=o=s=i=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:i=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(a(137,t));break;default:zd(e,t,r,d,n,null)}}Pt(e,o,c,l,u,s,i,!1);return;case`select`:for(i in Td(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(i)&&(c=n[i],c!=null))switch(i){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:zd(e,t,i,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&It(e,!!r,n,!0):It(e,!!r,t,!1);return;case`textarea`:for(s in Td(`invalid`,e),o=i=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:i=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(a(91));break;default:zd(e,t,s,c,n,null)}Rt(e,r,i,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:zd(e,t,l,r,n,null)}return;case`dialog`:Td(`beforetoggle`,e),Td(`toggle`,e),Td(`cancel`,e),Td(`close`,e);break;case`iframe`:case`object`:Td(`load`,e);break;case`video`:case`audio`:for(r=0;r<Sd.length;r++)Td(Sd[r],e);break;case`image`:Td(`error`,e),Td(`load`,e);break;case`details`:Td(`toggle`,e);break;case`embed`:case`source`:case`link`:Td(`error`,e),Td(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(a(137,t));default:zd(e,t,u,r,n,null)}return;default:if(Ut(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Bd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&zd(e,t,c,r,n,null))}function Hd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var i=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||zd(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:i=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(a(137,t));break;default:m!==f&&zd(e,t,p,m,r,f)}}Nt(e,s,c,l,u,d,o,i);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||zd(e,t,o,null,r,l)}for(i in r)if(o=r[i],l=n[i],r.hasOwnProperty(i)&&(o!=null||l!=null))switch(i){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&zd(e,t,i,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?It(e,!!n,n?[]:``,!1):It(e,!!n,t,!0)):It(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(i=n[c],n.hasOwnProperty(c)&&i!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:zd(e,t,c,null,r,i)}for(s in r)if(i=r[s],o=n[s],r.hasOwnProperty(s)&&(i!=null||o!=null))switch(s){case`value`:p=i;break;case`defaultValue`:m=i;break;case`children`:break;case`dangerouslySetInnerHTML`:if(i!=null)throw Error(a(91));break;default:i!==o&&zd(e,t,s,i,r,o)}Lt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:zd(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:zd(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&zd(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(a(137,t));break;default:zd(e,t,u,p,r,m)}return;default:if(Ut(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Bd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Bd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&zd(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||zd(e,t,f,p,r,m)}function Ud(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Wd(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Ud(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Ud(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Gd=null,Kd=null;function qd(e){return e.nodeType===9?e:e.ownerDocument}function Jd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Yd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Xd(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Zd=null;function Qd(){var e=window.event;return e&&e.type===`popstate`?e===Zd?!1:(Zd=e,!0):(Zd=null,!1)}var $d=typeof setTimeout==`function`?setTimeout:void 0,ef=typeof clearTimeout==`function`?clearTimeout:void 0,tf=typeof Promise==`function`?Promise:void 0,nf=typeof queueMicrotask==`function`?queueMicrotask:tf===void 0?$d:function(e){return tf.resolve(null).then(e).catch(rf)};function rf(e){setTimeout(function(){throw e})}function af(e){return e===`head`}function of(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Rp(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)bf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,bf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[st]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&bf(e.ownerDocument.body);n=i}while(n);Rp(t)}function sf(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function cf(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:cf(n),ct(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function lf(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[st])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=hf(e.nextSibling),e===null)break}return null}function uf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=hf(e.nextSibling),e===null))return null;return e}function df(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=hf(e.nextSibling),e===null))return null;return e}function ff(e){return e.data===`$?`||e.data===`$~`}function pf(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function mf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function hf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var gf=null;function _f(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return hf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function vf(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function yf(e,t,n){switch(t=qd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(a(452));return e;case`head`:if(e=t.head,!e)throw Error(a(453));return e;case`body`:if(e=t.body,!e)throw Error(a(454));return e;default:throw Error(a(451))}}function bf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);ct(e)}var xf=new Map,Sf=new Set;function Cf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var wf=L.d;L.d={f:Tf,r:Ef,D:kf,C:Af,L:jf,m:Mf,X:Pf,S:Nf,M:Ff};function Tf(){var e=wf.f(),t=wu();return e||t}function Ef(e){var t=ut(e);t!==null&&t.tag===5&&t.type===`form`?Cs(t):wf.r(e)}var Df=typeof document>`u`?null:document;function Of(e,t,n){var r=Df;if(r&&typeof t==`string`&&t){var i=Mt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),Sf.has(i)||(Sf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Vd(t,`link`,e),pt(t),r.head.appendChild(t)))}}function kf(e){wf.D(e),Of(`dns-prefetch`,e,null)}function Af(e,t){wf.C(e,t),Of(`preconnect`,e,t)}function jf(e,t,n){wf.L(e,t,n);var r=Df;if(r&&e&&t){var i=`link[rel="preload"][as="`+Mt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Mt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Mt(n.imageSizes)+`"]`)):i+=`[href="`+Mt(e)+`"]`;var a=i;switch(t){case`style`:a=Lf(e);break;case`script`:a=Vf(e)}xf.has(a)||(e=h({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),xf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Rf(a))||t===`script`&&r.querySelector(Hf(a))||(t=r.createElement(`link`),Vd(t,`link`,e),pt(t),r.head.appendChild(t)))}}function Mf(e,t){wf.m(e,t);var n=Df;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Mt(r)+`"][href="`+Mt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Vf(e)}if(!xf.has(a)&&(e=h({rel:`modulepreload`,href:e},t),xf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Hf(a)))return}r=n.createElement(`link`),Vd(r,`link`,e),pt(r),n.head.appendChild(r)}}}function Nf(e,t,n){wf.S(e,t,n);var r=Df;if(r&&e){var i=ft(r).hoistableStyles,a=Lf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Rf(a)))s.loading=5;else{e=h({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=xf.get(a))&&Gf(e,n);var c=o=r.createElement(`link`);pt(c),Vd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Wf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Pf(e,t){wf.X(e,t);var n=Df;if(n&&e){var r=ft(n).hoistableScripts,i=Vf(e),a=r.get(i);a||(a=n.querySelector(Hf(i)),a||(e=h({src:e,async:!0},t),(t=xf.get(i))&&Kf(e,t),a=n.createElement(`script`),pt(a),Vd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Ff(e,t){wf.M(e,t);var n=Df;if(n&&e){var r=ft(n).hoistableScripts,i=Vf(e),a=r.get(i);a||(a=n.querySelector(Hf(i)),a||(e=h({src:e,async:!0,type:`module`},t),(t=xf.get(i))&&Kf(e,t),a=n.createElement(`script`),pt(a),Vd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function If(e,t,n,r){var i=(i=te.current)?Cf(i):null;if(!i)throw Error(a(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Lf(n.href),n=ft(i).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Lf(n.href);var o=ft(i).hoistableStyles,s=o.get(e);if(s||(i=i.ownerDocument||i,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=i.querySelector(Rf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),xf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},xf.set(e,n),o||Bf(i,e,n,s.state))),t&&r===null)throw Error(a(528,``));return s}if(t&&r!==null)throw Error(a(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Vf(n),n=ft(i).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(a(444,e))}}function Lf(e){return`href="`+Mt(e)+`"`}function Rf(e){return`link[rel="stylesheet"][`+e+`]`}function zf(e){return h({},e,{"data-precedence":e.precedence,precedence:null})}function Bf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Vd(t,`link`,n),pt(t),e.head.appendChild(t))}function Vf(e){return`[src="`+Mt(e)+`"]`}function Hf(e){return`script[async]`+e}function Uf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Mt(n.href)+`"]`);if(r)return t.instance=r,pt(r),r;var i=h({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),pt(r),Vd(r,`style`,i),Wf(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Lf(n.href);var o=e.querySelector(Rf(i));if(o)return t.state.loading|=4,t.instance=o,pt(o),o;r=zf(n),(i=xf.get(i))&&Gf(r,i),o=(e.ownerDocument||e).createElement(`link`),pt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Vd(o,`link`,r),t.state.loading|=4,Wf(o,n.precedence,e),t.instance=o;case`script`:return o=Vf(n.src),(i=e.querySelector(Hf(o)))?(t.instance=i,pt(i),i):(r=n,(i=xf.get(o))&&(r=h({},n),Kf(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),pt(i),Vd(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(a(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Wf(r,n.precedence,e));return t.instance}function Wf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Gf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Kf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var qf=null;function Jf(e,t,n){if(qf===null){var r=new Map,i=qf=new Map;i.set(n,r)}else i=qf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[st]||a[et]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Yf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Xf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Zf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Qf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Lf(r.href),a=t.querySelector(Rf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=tp.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,pt(a);return}a=t.ownerDocument||t,r=zf(r),(i=xf.get(i))&&Gf(r,i),a=a.createElement(`link`),pt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Vd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=tp.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var $f=0;function ep(e,t){return e.stylesheets&&e.count===0&&rp(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&rp(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&$f===0&&($f=62500*Wd());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&rp(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>$f?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function tp(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)rp(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var np=null;function rp(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,np=new Map,t.forEach(ip,e),np=null,tp.call(e))}function ip(e,t){if(!(t.state.loading&4)){var n=np.get(e);if(n)var r=n.get(null);else{n=new Map,np.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=tp.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var ap={$$typeof:C,Provider:null,Consumer:null,_currentValue:R,_currentValue2:R,_threadCount:0};function op(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ue(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ue(0),this.hiddenUpdates=Ue(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function sp(e,t,n,r,i,a,o,s,c,l,u,d){return e=new op(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=ni(3,null,null,t),e.current=a,a.stateNode=e,t=ta(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Pa(a),e}function cp(e){return e?(e=ei,e):ei}function lp(e,t,n,r,i,a){i=cp(i),r.context===null?r.context=i:r.pendingContext=i,r=Ia(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=La(e,r,t),n!==null&&(yu(n,e,t),Ra(n,e,t))}function up(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function dp(e,t){up(e,t),(e=e.alternate)&&up(e,t)}function fp(e){if(e.tag===13||e.tag===31){var t=Zr(e,67108864);t!==null&&yu(t,e,67108864),dp(e,67108864)}}function pp(e){if(e.tag===13||e.tag===31){var t=_u();t=Ye(t);var n=Zr(e,t);n!==null&&yu(n,e,t),dp(e,t)}}var q=!0;function mp(e,t,n,r){var i=I.T;I.T=null;var a=L.p;try{L.p=2,gp(e,t,n,r)}finally{L.p=a,I.T=i}}function hp(e,t,n,r){var i=I.T;I.T=null;var a=L.p;try{L.p=8,gp(e,t,n,r)}finally{L.p=a,I.T=i}}function gp(e,t,n,r){if(q){var i=_p(r);if(i===null)Ad(e,t,r,vp,n),Op(e,r);else if(Ap(i,e,t,n,r))r.stopPropagation();else if(Op(e,r),t&4&&-1<Dp.indexOf(e)){for(;i!==null;){var a=ut(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Re(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-je(o);s.entanglements[1]|=c,o&=~c}cd(a),!(Rl&6)&&(au=ye()+500,ld(0,!1))}}break;case 31:case 13:s=Zr(a,2),s!==null&&yu(s,a,2),wu(),dp(a,2)}if(a=_p(r),a===null&&Ad(e,t,r,vp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Ad(e,t,r,null,n)}}function _p(e){return e=Yt(e),yp(e)}var vp=null;function yp(e){if(vp=null,e=lt(e),e!==null){var t=l(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=u(t),e!==null)return e;e=null}else if(n===31){if(e=d(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return vp=e,null}function bp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(be()){case xe:return 2;case Se:return 8;case Ce:case we:return 32;case Te:return 268435456;default:return 32}default:return 32}}var J=!1,xp=null,Sp=null,Cp=null,wp=new Map,Tp=new Map,Ep=[],Dp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Op(e,t){switch(e){case`focusin`:case`focusout`:xp=null;break;case`dragenter`:case`dragleave`:Sp=null;break;case`mouseover`:case`mouseout`:Cp=null;break;case`pointerover`:case`pointerout`:wp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:Tp.delete(t.pointerId)}}function kp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=ut(t),t!==null&&fp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Ap(e,t,n,r,i){switch(t){case`focusin`:return xp=kp(xp,e,t,n,r,i),!0;case`dragenter`:return Sp=kp(Sp,e,t,n,r,i),!0;case`mouseover`:return Cp=kp(Cp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return wp.set(a,kp(wp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,Tp.set(a,kp(Tp.get(a)||null,e,t,n,r,i)),!0}return!1}function jp(e){var t=lt(e.target);if(t!==null){var n=l(t);if(n!==null){if(t=n.tag,t===13){if(t=u(n),t!==null){e.blockedOn=t,Qe(e.priority,function(){pp(n)});return}}else if(t===31){if(t=d(n),t!==null){e.blockedOn=t,Qe(e.priority,function(){pp(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Mp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=_p(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Jt=r,n.target.dispatchEvent(r),Jt=null}else return t=ut(n),t!==null&&fp(t),e.blockedOn=n,!1;t.shift()}return!0}function Np(e,t,n){Mp(e)&&n.delete(t)}function Pp(){J=!1,xp!==null&&Mp(xp)&&(xp=null),Sp!==null&&Mp(Sp)&&(Sp=null),Cp!==null&&Mp(Cp)&&(Cp=null),wp.forEach(Np),Tp.forEach(Np)}function Fp(e,t){e.blockedOn===t&&(e.blockedOn=null,J||(J=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,Pp)))}var Ip=null;function Lp(e){Ip!==e&&(Ip=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){Ip===e&&(Ip=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(yp(r||n)===null)continue;break}var a=ut(n);a!==null&&(e.splice(t,3),t-=3,xs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Rp(e){function t(t){return Fp(t,e)}xp!==null&&Fp(xp,e),Sp!==null&&Fp(Sp,e),Cp!==null&&Fp(Cp,e),wp.forEach(t),Tp.forEach(t);for(var n=0;n<Ep.length;n++){var r=Ep[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Ep.length&&(n=Ep[0],n.blockedOn===null);)jp(n),n.blockedOn===null&&Ep.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[tt]||null;if(typeof a==`function`)o||Lp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[tt]||null)s=o.formAction;else if(yp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Lp(n)}}}function Y(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function zp(e){this._internalRoot=e}Bp.prototype.render=zp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(a(409));var n=t.current;lp(n,_u(),e,t,null,null)},Bp.prototype.unmount=zp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;lp(e.current,2,null,e,null,null),wu(),t[nt]=null}};function Bp(e){this._internalRoot=e}Bp.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ze();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ep.length&&t!==0&&t<Ep[n].priority;n++);Ep.splice(n,0,e),n===0&&jp(e)}};var Vp=r.version;if(Vp!==`19.2.6`)throw Error(a(527,Vp,`19.2.6`));L.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(a(188)):(e=Object.keys(e).join(`,`),Error(a(268,e)));return e=p(t),e=e===null?null:m(e),e=e===null?null:e.stateNode,e};var Hp={bundleType:0,version:`19.2.6`,rendererPackageName:`react-dom`,currentDispatcherRef:I,reconcilerVersion:`19.2.6`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var X=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!X.isDisabled&&X.supportsFiber)try{Oe=X.inject(Hp),ke=X}catch{}}e.createRoot=function(e,t){if(!s(e))throw Error(a(299));var n=!1,r=``,i=Ws,o=Gs,c=Ks;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(i=t.onUncaughtError),t.onCaughtError!==void 0&&(o=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=sp(e,1,!1,null,null,n,r,null,i,o,c,Y),e[nt]=t.current,Od(e),new zp(t)}})),u=r(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=l()})),d=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),f=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),p=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),m=e=>{let t=p(e);return t.charAt(0).toUpperCase()+t.slice(1)},h={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},g=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},_=n(t(),1),v=(0,_.createContext)({}),y=()=>(0,_.useContext)(v),b=(0,_.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:f=!1,color:p=`currentColor`,className:m=``}=y()??{},v=r??f?Number(n??u)*24/Number(t??l):n??u;return(0,_.createElement)(`svg`,{ref:c,...h,width:t??l??h.width,height:t??l??h.height,stroke:e??p,strokeWidth:v,className:d(`lucide`,m,i),...!a&&!g(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,_.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),x=(e,t)=>{let n=(0,_.forwardRef)(({className:n,...r},i)=>(0,_.createElement)(b,{ref:i,iconNode:t,className:d(`lucide-${f(m(e))}`,`lucide-${e}`,n),...r}));return n.displayName=m(e),n},S=x(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),C=x(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),w=x(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),T=x(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),E=x(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),D=x(`arrow-up-down`,[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]),O=x(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),k=x(`blocks`,[[`path`,{d:`M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2`,key:`1ah6g2`}],[`rect`,{x:`14`,y:`2`,width:`8`,height:`8`,rx:`1`,key:`88lufb`}]]),A=x(`bookmark`,[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]),j=x(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),M=x(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),N=x(`chart-column`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),P=x(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),F=x(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),I=x(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),L=x(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),R=x(`circle-alert`,[[`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`}]]),z=x(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),B=x(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),V=x(`circle-x`,[[`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`}]]),H=x(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),U=x(`clipboard-list`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`M12 11h4`,key:`1jrz19`}],[`path`,{d:`M12 16h4`,key:`n85exb`}],[`path`,{d:`M8 11h.01`,key:`1dfujw`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),ee=x(`copy`,[[`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`}]]),W=x(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),te=x(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),ne=x(`download`,[[`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`}]]),re=x(`eraser`,[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]),ie=x(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),ae=x(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),oe=x(`fast-forward`,[[`path`,{d:`M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z`,key:`b19h5q`}],[`path`,{d:`M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z`,key:`h7h5ge`}]]),se=x(`file-code-corner`,[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]]),ce=x(`file-plus`,[[`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:`M9 15h6`,key:`cctwl0`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}]]),le=x(`file-text`,[[`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`}]]),ue=x(`file`,[[`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`}]]),de=x(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),fe=x(`folder-git-2`,[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),pe=x(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),me=x(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),he=x(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),ge=x(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),_e=x(`git-commit-horizontal`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]]),ve=x(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),ye=x(`hand`,[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]),be=x(`hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),xe=x(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Se=x(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),Ce=x(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),we=x(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),Te=x(`loader`,[[`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`}]]),Ee=x(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),De=x(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),Oe=x(`message-circle`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}]]),ke=x(`message-square`,[[`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`}]]),Ae=x(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),je=x(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),Me=x(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),Ne=x(`network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),Pe=x(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),Fe=x(`panel-left-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]]),Ie=x(`panel-left-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),Le=x(`pen-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`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`}]]),Re=x(`pencil`,[[`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`}]]),ze=x(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Be=x(`puzzle`,[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]),Ve=x(`refresh-cw`,[[`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`}]]),He=x(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),Ue=x(`route`,[[`circle`,{cx:`6`,cy:`19`,r:`3`,key:`1kj8tv`}],[`path`,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,key:`1d8sl`}],[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}]]),We=x(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Ge=x(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),Ke=x(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),qe=x(`share-2`,[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]),Je=x(`shield`,[[`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`}]]),Ye=x(`shuffle`,[[`path`,{d:`m18 14 4 4-4 4`,key:`10pe0f`}],[`path`,{d:`m18 2 4 4-4 4`,key:`pucp1d`}],[`path`,{d:`M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22`,key:`1ailkh`}],[`path`,{d:`M2 6h1.972a4 4 0 0 1 3.6 2.2`,key:`km57vx`}],[`path`,{d:`M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45`,key:`os18l9`}]]),Xe=x(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),Ze=x(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Qe=x(`store`,[[`path`,{d:`M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5`,key:`slp6dd`}],[`path`,{d:`M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244`,key:`o0xfot`}],[`path`,{d:`M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05`,key:`wn3emo`}]]),$e=x(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),et=x(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),tt=x(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),nt=x(`trash-2`,[[`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`}]]),rt=x(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),it=x(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),at=x(`unlink`,[[`path`,{d:`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,key:`yqzxt4`}],[`path`,{d:`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,key:`4qinb0`}],[`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`5`,key:`1041cp`}],[`line`,{x1:`2`,x2:`5`,y1:`8`,y2:`8`,key:`14m1p5`}],[`line`,{x1:`16`,x2:`16`,y1:`19`,y2:`22`,key:`rzdirn`}],[`line`,{x1:`19`,x2:`22`,y1:`16`,y2:`16`,key:`ox905f`}]]),ot=x(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),st=x(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),ct=x(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),lt=x(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),ut=x(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),dt=x(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),ft=n(c(),1),pt=u(),mt=`modulepreload`,ht=function(e){return`/`+e},gt={},_t=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=ht(t,n),t in gt)return;gt[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:mt,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},vt=`popstate`;function yt(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function bt(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return Tt(``,{pathname:r,search:i,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||`default`,n?{pathname:e.location.pathname,search:e.location.search,hash:e.location.hash}:void 0)}function n(e,t){return typeof t==`string`?t:Et(t)}return Ot(t,n,null,e)}function xt(e,t){if(e===!1||e==null)throw Error(t)}function St(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function Ct(){return Math.random().toString(36).substring(2,10)}function wt(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function Tt(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?Dt(t):t,state:n,key:t&&t.key||r||Ct(),mask:i}}function Et({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function Dt(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function Ot(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=yt(e)?e:Tt(h.location,e,t);n&&n(r,e),l=u()+1;let d=wt(r,l),f=h.createHref(r.mask||r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=yt(e)?e:Tt(h.location,e,t);n&&n(r,e),l=u();let i=wt(r,l),d=h.createHref(r.mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return kt(i,e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(vt,d),c=e,()=>{i.removeEventListener(vt,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function kt(e,t,n=!1){let r=`http://localhost`;e&&(r=e.location.origin===`null`?e.location.href:e.location.origin),xt(r,`No window.location.(origin|href) available to create URL`);let i=typeof t==`string`?t:Et(t);return i=i.replace(/ $/,`%20`),!n&&i.startsWith(`//`)&&(i=r+i),new URL(i,r)}function At(e,t,n=`/`){return jt(e,t,n,!1)}function jt(e,t,n,r,i){let a=Xt((typeof t==`string`?Dt(t):t).pathname||`/`,n);if(a==null)return null;let o=i??Nt(e),s=null,c=Yt(a);for(let e=0;s==null&&e<o.length;++e)s=Kt(o[e],c,r);return s}function Mt(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function Nt(e){let t=Pt(e);return It(t),t}function Pt(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;xt(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=on([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(xt(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),Pt(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:Wt(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of Ft(e.path))a(e,t,!0,n)}),t}function Ft(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=Ft(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function It(e){e.sort((e,t)=>e.score===t.score?Gt(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var Lt=/^:[\w-]+$/,Rt=3,zt=2,Bt=1,Vt=10,Ht=-2,Ut=e=>e===`*`;function Wt(e,t){let n=e.split(`/`),r=n.length;return n.some(Ut)&&(r+=Ht),t&&(r+=zt),n.filter(e=>!Ut(e)).reduce((e,t)=>e+(Lt.test(t)?Rt:t===``?Bt:Vt),r)}function Gt(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function Kt(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=qt({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=qt({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:on([a,u.pathname]),pathnameBase:cn(on([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=on([a,u.pathnameBase]))}return o}function qt(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Jt(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function Jt(e,t=!1,n=!0){St(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function Yt(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return St(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Xt(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}var Zt=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Qt(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?Dt(e):e,a;return n?(n=an(n),a=n.startsWith(`/`)?$t(n.substring(1),`/`):$t(n,t)):a=t,{pathname:a,search:ln(r),hash:un(i)}}function $t(e,t){let n=sn(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function en(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function tn(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function nn(e){let t=tn(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function rn(e,t,n,r=!1){let i;typeof e==`string`?i=Dt(e):(i={...e},xt(!i.pathname||!i.pathname.includes(`?`),en(`?`,`pathname`,`search`,i)),xt(!i.pathname||!i.pathname.includes(`#`),en(`#`,`pathname`,`hash`,i)),xt(!i.search||!i.search.includes(`#`),en(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=Qt(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var an=e=>e.replace(/\/\/+/g,`/`),on=e=>an(e.join(`/`)),sn=e=>e.replace(/\/+$/,``),cn=e=>sn(e).replace(/^\/*/,`/`),ln=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,un=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,dn=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function fn(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function pn(e){return on(e.map(e=>e.route.path).filter(Boolean))||`/`}var mn=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function hn(e,t){let n=e;if(typeof n!=`string`||!Zt.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(mn)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=Xt(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{St(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var gn=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(gn);var _n=[`GET`,...gn];new Set(_n);var vn=_.createContext(null);vn.displayName=`DataRouter`;var yn=_.createContext(null);yn.displayName=`DataRouterState`;var bn=_.createContext(!1);function xn(){return _.useContext(bn)}var Sn=_.createContext({isTransitioning:!1});Sn.displayName=`ViewTransition`;var Cn=_.createContext(new Map);Cn.displayName=`Fetchers`;var wn=_.createContext(null);wn.displayName=`Await`;var Tn=_.createContext(null);Tn.displayName=`Navigation`;var En=_.createContext(null);En.displayName=`Location`;var Dn=_.createContext({outlet:null,matches:[],isDataRoute:!1});Dn.displayName=`Route`;var On=_.createContext(null);On.displayName=`RouteError`;var kn=`REACT_ROUTER_ERROR`,An=`REDIRECT`,jn=`ROUTE_ERROR_RESPONSE`;function Mn(e){if(e.startsWith(`${kn}:${An}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function Nn(e){if(e.startsWith(`${kn}:${jn}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new dn(t.status,t.statusText,t.data)}catch{}}function Pn(e,{relative:t}={}){xt(Fn(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=_.useContext(Tn),{hash:i,pathname:a,search:o}=Gn(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:on([n,a])),r.createHref({pathname:s,search:o,hash:i})}function Fn(){return _.useContext(En)!=null}function In(){return xt(Fn(),`useLocation() may be used only in the context of a <Router> component.`),_.useContext(En).location}function Ln(e){xt(Fn(),`useMatch() may be used only in the context of a <Router> component.`);let{pathname:t}=In();return _.useMemo(()=>qt(e,Yt(t)),[t,e])}var Rn=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function zn(e){_.useContext(Tn).static||_.useLayoutEffect(e)}function Bn(){let{isDataRoute:e}=_.useContext(Dn);return e?ur():Vn()}function Vn(){xt(Fn(),`useNavigate() may be used only in the context of a <Router> component.`);let e=_.useContext(vn),{basename:t,navigator:n}=_.useContext(Tn),{matches:r}=_.useContext(Dn),{pathname:i}=In(),a=JSON.stringify(nn(r)),o=_.useRef(!1);return zn(()=>{o.current=!0}),_.useCallback((r,s={})=>{if(St(o.current,Rn),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=rn(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:on([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}var Hn=_.createContext(null);function Un(e){let t=_.useContext(Dn).outlet;return _.useMemo(()=>t&&_.createElement(Hn.Provider,{value:e},t),[t,e])}function Wn(){let{matches:e}=_.useContext(Dn);return e[e.length-1]?.params??{}}function Gn(e,{relative:t}={}){let{matches:n}=_.useContext(Dn),{pathname:r}=In(),i=JSON.stringify(nn(n));return _.useMemo(()=>rn(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function Kn(e,t){return qn(e,t)}function qn(e,t,n){xt(Fn(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:r}=_.useContext(Tn),{matches:i}=_.useContext(Dn),a=i[i.length-1],o=a?a.params:{},s=a?a.pathname:`/`,c=a?a.pathnameBase:`/`,l=a&&a.route;{let e=l&&l.path||``;fr(s,!l||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${s}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
10
|
+
`).replace(Id,``)}function Rd(e,t){return t=Ld(t),Ld(e)===t}function zd(e,t,n,r,i,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||zt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&zt(e,``+r);break;case`className`:Ct(e,`class`,r);break;case`tabIndex`:Ct(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Ct(e,n,r);break;case`style`:Ht(e,r,o);break;case`data`:if(t!==`object`){Ct(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Kt(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&zd(e,t,`name`,i.name,i,null),zd(e,t,`formEncType`,i.formEncType,i,null),zd(e,t,`formMethod`,i.formMethod,i,null),zd(e,t,`formTarget`,i.formTarget,i,null)):(zd(e,t,`encType`,i.encType,i,null),zd(e,t,`method`,i.method,i,null),zd(e,t,`target`,i.target,i,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Kt(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=qt);break;case`onScroll`:r!=null&&Td(`scroll`,e);break;case`onScrollEnd`:r!=null&&Td(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(a(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(a(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=Kt(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Td(`beforetoggle`,e),Td(`toggle`,e),St(e,`popover`,r);break;case`xlinkActuate`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:wt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:wt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:wt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:St(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=Wt.get(n)||n,St(e,n,r))}}function Bd(e,t,n,r,i,o){switch(n){case`style`:Ht(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(a(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(a(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?zt(e,r):(typeof r==`number`||typeof r==`bigint`)&&zt(e,``+r);break;case`onScroll`:r!=null&&Td(`scroll`,e);break;case`onScrollEnd`:r!=null&&Td(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=qt);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!ht.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(i=n.endsWith(`Capture`),t=n.slice(2,i?n.length-7:void 0),o=e[tt]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,i),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,i);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):St(e,n,r)}}}function Vd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Td(`error`,e),Td(`load`,e);var r=!1,i=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:i=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(a(137,t));default:zd(e,t,o,s,n,null)}}i&&zd(e,t,`srcSet`,n.srcSet,n,null),r&&zd(e,t,`src`,n.src,n,null);return;case`input`:Td(`invalid`,e);var c=o=s=i=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:i=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(a(137,t));break;default:zd(e,t,r,d,n,null)}}Pt(e,o,c,l,u,s,i,!1);return;case`select`:for(i in Td(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(i)&&(c=n[i],c!=null))switch(i){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:zd(e,t,i,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&It(e,!!r,n,!0):It(e,!!r,t,!1);return;case`textarea`:for(s in Td(`invalid`,e),o=i=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:i=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(a(91));break;default:zd(e,t,s,c,n,null)}Rt(e,r,i,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:zd(e,t,l,r,n,null)}return;case`dialog`:Td(`beforetoggle`,e),Td(`toggle`,e),Td(`cancel`,e),Td(`close`,e);break;case`iframe`:case`object`:Td(`load`,e);break;case`video`:case`audio`:for(r=0;r<Sd.length;r++)Td(Sd[r],e);break;case`image`:Td(`error`,e),Td(`load`,e);break;case`details`:Td(`toggle`,e);break;case`embed`:case`source`:case`link`:Td(`error`,e),Td(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(a(137,t));default:zd(e,t,u,r,n,null)}return;default:if(Ut(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Bd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&zd(e,t,c,r,n,null))}function Hd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var i=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||zd(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:i=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(a(137,t));break;default:m!==f&&zd(e,t,p,m,r,f)}}Nt(e,s,c,l,u,d,o,i);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||zd(e,t,o,null,r,l)}for(i in r)if(o=r[i],l=n[i],r.hasOwnProperty(i)&&(o!=null||l!=null))switch(i){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&zd(e,t,i,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?It(e,!!n,n?[]:``,!1):It(e,!!n,t,!0)):It(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(i=n[c],n.hasOwnProperty(c)&&i!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:zd(e,t,c,null,r,i)}for(s in r)if(i=r[s],o=n[s],r.hasOwnProperty(s)&&(i!=null||o!=null))switch(s){case`value`:p=i;break;case`defaultValue`:m=i;break;case`children`:break;case`dangerouslySetInnerHTML`:if(i!=null)throw Error(a(91));break;default:i!==o&&zd(e,t,s,i,r,o)}Lt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:zd(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:zd(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&zd(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(a(137,t));break;default:zd(e,t,u,p,r,m)}return;default:if(Ut(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Bd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Bd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&zd(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||zd(e,t,f,p,r,m)}function Ud(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Wd(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Ud(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Ud(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Gd=null,Kd=null;function qd(e){return e.nodeType===9?e:e.ownerDocument}function Jd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Yd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Xd(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Zd=null;function Qd(){var e=window.event;return e&&e.type===`popstate`?e===Zd?!1:(Zd=e,!0):(Zd=null,!1)}var $d=typeof setTimeout==`function`?setTimeout:void 0,ef=typeof clearTimeout==`function`?clearTimeout:void 0,tf=typeof Promise==`function`?Promise:void 0,nf=typeof queueMicrotask==`function`?queueMicrotask:tf===void 0?$d:function(e){return tf.resolve(null).then(e).catch(rf)};function rf(e){setTimeout(function(){throw e})}function af(e){return e===`head`}function of(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Rp(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)bf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,bf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[st]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&bf(e.ownerDocument.body);n=i}while(n);Rp(t)}function sf(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function cf(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:cf(n),ct(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function lf(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[st])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=hf(e.nextSibling),e===null)break}return null}function uf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=hf(e.nextSibling),e===null))return null;return e}function df(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=hf(e.nextSibling),e===null))return null;return e}function ff(e){return e.data===`$?`||e.data===`$~`}function pf(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function mf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function hf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var gf=null;function _f(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return hf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function vf(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function yf(e,t,n){switch(t=qd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(a(452));return e;case`head`:if(e=t.head,!e)throw Error(a(453));return e;case`body`:if(e=t.body,!e)throw Error(a(454));return e;default:throw Error(a(451))}}function bf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);ct(e)}var xf=new Map,Sf=new Set;function Cf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var wf=L.d;L.d={f:Tf,r:Ef,D:kf,C:Af,L:jf,m:Mf,X:Pf,S:Nf,M:Ff};function Tf(){var e=wf.f(),t=wu();return e||t}function Ef(e){var t=ut(e);t!==null&&t.tag===5&&t.type===`form`?Cs(t):wf.r(e)}var Df=typeof document>`u`?null:document;function Of(e,t,n){var r=Df;if(r&&typeof t==`string`&&t){var i=Mt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),Sf.has(i)||(Sf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Vd(t,`link`,e),pt(t),r.head.appendChild(t)))}}function kf(e){wf.D(e),Of(`dns-prefetch`,e,null)}function Af(e,t){wf.C(e,t),Of(`preconnect`,e,t)}function jf(e,t,n){wf.L(e,t,n);var r=Df;if(r&&e&&t){var i=`link[rel="preload"][as="`+Mt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Mt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Mt(n.imageSizes)+`"]`)):i+=`[href="`+Mt(e)+`"]`;var a=i;switch(t){case`style`:a=Lf(e);break;case`script`:a=Vf(e)}xf.has(a)||(e=h({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),xf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Rf(a))||t===`script`&&r.querySelector(Hf(a))||(t=r.createElement(`link`),Vd(t,`link`,e),pt(t),r.head.appendChild(t)))}}function Mf(e,t){wf.m(e,t);var n=Df;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Mt(r)+`"][href="`+Mt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Vf(e)}if(!xf.has(a)&&(e=h({rel:`modulepreload`,href:e},t),xf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Hf(a)))return}r=n.createElement(`link`),Vd(r,`link`,e),pt(r),n.head.appendChild(r)}}}function Nf(e,t,n){wf.S(e,t,n);var r=Df;if(r&&e){var i=ft(r).hoistableStyles,a=Lf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Rf(a)))s.loading=5;else{e=h({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=xf.get(a))&&Gf(e,n);var c=o=r.createElement(`link`);pt(c),Vd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Wf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Pf(e,t){wf.X(e,t);var n=Df;if(n&&e){var r=ft(n).hoistableScripts,i=Vf(e),a=r.get(i);a||(a=n.querySelector(Hf(i)),a||(e=h({src:e,async:!0},t),(t=xf.get(i))&&Kf(e,t),a=n.createElement(`script`),pt(a),Vd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Ff(e,t){wf.M(e,t);var n=Df;if(n&&e){var r=ft(n).hoistableScripts,i=Vf(e),a=r.get(i);a||(a=n.querySelector(Hf(i)),a||(e=h({src:e,async:!0,type:`module`},t),(t=xf.get(i))&&Kf(e,t),a=n.createElement(`script`),pt(a),Vd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function If(e,t,n,r){var i=(i=te.current)?Cf(i):null;if(!i)throw Error(a(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Lf(n.href),n=ft(i).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Lf(n.href);var o=ft(i).hoistableStyles,s=o.get(e);if(s||(i=i.ownerDocument||i,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=i.querySelector(Rf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),xf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},xf.set(e,n),o||Bf(i,e,n,s.state))),t&&r===null)throw Error(a(528,``));return s}if(t&&r!==null)throw Error(a(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Vf(n),n=ft(i).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(a(444,e))}}function Lf(e){return`href="`+Mt(e)+`"`}function Rf(e){return`link[rel="stylesheet"][`+e+`]`}function zf(e){return h({},e,{"data-precedence":e.precedence,precedence:null})}function Bf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Vd(t,`link`,n),pt(t),e.head.appendChild(t))}function Vf(e){return`[src="`+Mt(e)+`"]`}function Hf(e){return`script[async]`+e}function Uf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Mt(n.href)+`"]`);if(r)return t.instance=r,pt(r),r;var i=h({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),pt(r),Vd(r,`style`,i),Wf(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Lf(n.href);var o=e.querySelector(Rf(i));if(o)return t.state.loading|=4,t.instance=o,pt(o),o;r=zf(n),(i=xf.get(i))&&Gf(r,i),o=(e.ownerDocument||e).createElement(`link`),pt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Vd(o,`link`,r),t.state.loading|=4,Wf(o,n.precedence,e),t.instance=o;case`script`:return o=Vf(n.src),(i=e.querySelector(Hf(o)))?(t.instance=i,pt(i),i):(r=n,(i=xf.get(o))&&(r=h({},n),Kf(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),pt(i),Vd(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(a(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Wf(r,n.precedence,e));return t.instance}function Wf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Gf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Kf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var qf=null;function Jf(e,t,n){if(qf===null){var r=new Map,i=qf=new Map;i.set(n,r)}else i=qf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[st]||a[et]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Yf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Xf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Zf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Qf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Lf(r.href),a=t.querySelector(Rf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=tp.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,pt(a);return}a=t.ownerDocument||t,r=zf(r),(i=xf.get(i))&&Gf(r,i),a=a.createElement(`link`),pt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Vd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=tp.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var $f=0;function ep(e,t){return e.stylesheets&&e.count===0&&rp(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&rp(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&$f===0&&($f=62500*Wd());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&rp(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>$f?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function tp(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)rp(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var np=null;function rp(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,np=new Map,t.forEach(ip,e),np=null,tp.call(e))}function ip(e,t){if(!(t.state.loading&4)){var n=np.get(e);if(n)var r=n.get(null);else{n=new Map,np.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=tp.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var ap={$$typeof:C,Provider:null,Consumer:null,_currentValue:R,_currentValue2:R,_threadCount:0};function op(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ue(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ue(0),this.hiddenUpdates=Ue(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function sp(e,t,n,r,i,a,o,s,c,l,u,d){return e=new op(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=ni(3,null,null,t),e.current=a,a.stateNode=e,t=ta(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Pa(a),e}function cp(e){return e?(e=ei,e):ei}function lp(e,t,n,r,i,a){i=cp(i),r.context===null?r.context=i:r.pendingContext=i,r=Ia(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=La(e,r,t),n!==null&&(yu(n,e,t),Ra(n,e,t))}function up(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function dp(e,t){up(e,t),(e=e.alternate)&&up(e,t)}function fp(e){if(e.tag===13||e.tag===31){var t=Zr(e,67108864);t!==null&&yu(t,e,67108864),dp(e,67108864)}}function pp(e){if(e.tag===13||e.tag===31){var t=_u();t=Ye(t);var n=Zr(e,t);n!==null&&yu(n,e,t),dp(e,t)}}var q=!0;function mp(e,t,n,r){var i=I.T;I.T=null;var a=L.p;try{L.p=2,gp(e,t,n,r)}finally{L.p=a,I.T=i}}function hp(e,t,n,r){var i=I.T;I.T=null;var a=L.p;try{L.p=8,gp(e,t,n,r)}finally{L.p=a,I.T=i}}function gp(e,t,n,r){if(q){var i=_p(r);if(i===null)Ad(e,t,r,vp,n),Op(e,r);else if(Ap(i,e,t,n,r))r.stopPropagation();else if(Op(e,r),t&4&&-1<Dp.indexOf(e)){for(;i!==null;){var a=ut(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Re(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-je(o);s.entanglements[1]|=c,o&=~c}cd(a),!(Rl&6)&&(au=ye()+500,ld(0,!1))}}break;case 31:case 13:s=Zr(a,2),s!==null&&yu(s,a,2),wu(),dp(a,2)}if(a=_p(r),a===null&&Ad(e,t,r,vp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Ad(e,t,r,null,n)}}function _p(e){return e=Yt(e),yp(e)}var vp=null;function yp(e){if(vp=null,e=lt(e),e!==null){var t=l(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=u(t),e!==null)return e;e=null}else if(n===31){if(e=d(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return vp=e,null}function bp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(be()){case xe:return 2;case Se:return 8;case Ce:case we:return 32;case Te:return 268435456;default:return 32}default:return 32}}var J=!1,xp=null,Sp=null,Cp=null,wp=new Map,Tp=new Map,Ep=[],Dp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Op(e,t){switch(e){case`focusin`:case`focusout`:xp=null;break;case`dragenter`:case`dragleave`:Sp=null;break;case`mouseover`:case`mouseout`:Cp=null;break;case`pointerover`:case`pointerout`:wp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:Tp.delete(t.pointerId)}}function kp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=ut(t),t!==null&&fp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Ap(e,t,n,r,i){switch(t){case`focusin`:return xp=kp(xp,e,t,n,r,i),!0;case`dragenter`:return Sp=kp(Sp,e,t,n,r,i),!0;case`mouseover`:return Cp=kp(Cp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return wp.set(a,kp(wp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,Tp.set(a,kp(Tp.get(a)||null,e,t,n,r,i)),!0}return!1}function jp(e){var t=lt(e.target);if(t!==null){var n=l(t);if(n!==null){if(t=n.tag,t===13){if(t=u(n),t!==null){e.blockedOn=t,Qe(e.priority,function(){pp(n)});return}}else if(t===31){if(t=d(n),t!==null){e.blockedOn=t,Qe(e.priority,function(){pp(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Mp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=_p(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Jt=r,n.target.dispatchEvent(r),Jt=null}else return t=ut(n),t!==null&&fp(t),e.blockedOn=n,!1;t.shift()}return!0}function Np(e,t,n){Mp(e)&&n.delete(t)}function Pp(){J=!1,xp!==null&&Mp(xp)&&(xp=null),Sp!==null&&Mp(Sp)&&(Sp=null),Cp!==null&&Mp(Cp)&&(Cp=null),wp.forEach(Np),Tp.forEach(Np)}function Fp(e,t){e.blockedOn===t&&(e.blockedOn=null,J||(J=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,Pp)))}var Ip=null;function Lp(e){Ip!==e&&(Ip=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){Ip===e&&(Ip=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(yp(r||n)===null)continue;break}var a=ut(n);a!==null&&(e.splice(t,3),t-=3,xs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Rp(e){function t(t){return Fp(t,e)}xp!==null&&Fp(xp,e),Sp!==null&&Fp(Sp,e),Cp!==null&&Fp(Cp,e),wp.forEach(t),Tp.forEach(t);for(var n=0;n<Ep.length;n++){var r=Ep[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Ep.length&&(n=Ep[0],n.blockedOn===null);)jp(n),n.blockedOn===null&&Ep.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[tt]||null;if(typeof a==`function`)o||Lp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[tt]||null)s=o.formAction;else if(yp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Lp(n)}}}function Y(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function zp(e){this._internalRoot=e}Bp.prototype.render=zp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(a(409));var n=t.current;lp(n,_u(),e,t,null,null)},Bp.prototype.unmount=zp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;lp(e.current,2,null,e,null,null),wu(),t[nt]=null}};function Bp(e){this._internalRoot=e}Bp.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ze();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ep.length&&t!==0&&t<Ep[n].priority;n++);Ep.splice(n,0,e),n===0&&jp(e)}};var Vp=r.version;if(Vp!==`19.2.7`)throw Error(a(527,Vp,`19.2.7`));L.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(a(188)):(e=Object.keys(e).join(`,`),Error(a(268,e)));return e=p(t),e=e===null?null:m(e),e=e===null?null:e.stateNode,e};var Hp={bundleType:0,version:`19.2.7`,rendererPackageName:`react-dom`,currentDispatcherRef:I,reconcilerVersion:`19.2.7`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var X=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!X.isDisabled&&X.supportsFiber)try{Oe=X.inject(Hp),ke=X}catch{}}e.createRoot=function(e,t){if(!s(e))throw Error(a(299));var n=!1,r=``,i=Ws,o=Gs,c=Ks;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(i=t.onUncaughtError),t.onCaughtError!==void 0&&(o=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=sp(e,1,!1,null,null,n,r,null,i,o,c,Y),e[nt]=t.current,Od(e),new zp(t)}})),u=r(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=l()})),d=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),f=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),p=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),m=e=>{let t=p(e);return t.charAt(0).toUpperCase()+t.slice(1)},h={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},g=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},_=n(t(),1),v=(0,_.createContext)({}),y=()=>(0,_.useContext)(v),b=(0,_.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:f=!1,color:p=`currentColor`,className:m=``}=y()??{},v=r??f?Number(n??u)*24/Number(t??l):n??u;return(0,_.createElement)(`svg`,{ref:c,...h,width:t??l??h.width,height:t??l??h.height,stroke:e??p,strokeWidth:v,className:d(`lucide`,m,i),...!a&&!g(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,_.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),x=(e,t)=>{let n=(0,_.forwardRef)(({className:n,...r},i)=>(0,_.createElement)(b,{ref:i,iconNode:t,className:d(`lucide-${f(m(e))}`,`lucide-${e}`,n),...r}));return n.displayName=m(e),n},S=x(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),C=x(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),w=x(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),T=x(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),E=x(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),D=x(`arrow-up-down`,[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]),O=x(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),k=x(`blocks`,[[`path`,{d:`M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2`,key:`1ah6g2`}],[`rect`,{x:`14`,y:`2`,width:`8`,height:`8`,rx:`1`,key:`88lufb`}]]),A=x(`bookmark`,[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]),j=x(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),M=x(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),N=x(`chart-column`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),P=x(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),F=x(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),I=x(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),L=x(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),R=x(`circle-alert`,[[`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`}]]),z=x(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),B=x(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),V=x(`circle-x`,[[`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`}]]),H=x(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),U=x(`clipboard-list`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`M12 11h4`,key:`1jrz19`}],[`path`,{d:`M12 16h4`,key:`n85exb`}],[`path`,{d:`M8 11h.01`,key:`1dfujw`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),ee=x(`copy`,[[`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`}]]),W=x(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),te=x(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),ne=x(`download`,[[`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`}]]),re=x(`eraser`,[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]),ie=x(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),ae=x(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),oe=x(`fast-forward`,[[`path`,{d:`M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z`,key:`b19h5q`}],[`path`,{d:`M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z`,key:`h7h5ge`}]]),se=x(`file-code-corner`,[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]]),ce=x(`file-plus`,[[`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:`M9 15h6`,key:`cctwl0`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}]]),le=x(`file-text`,[[`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`}]]),ue=x(`file`,[[`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`}]]),de=x(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),fe=x(`folder-git-2`,[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),pe=x(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),me=x(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),he=x(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),ge=x(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),_e=x(`git-commit-horizontal`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]]),ve=x(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),ye=x(`hand`,[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]),be=x(`hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),xe=x(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Se=x(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),Ce=x(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),we=x(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),Te=x(`loader`,[[`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`}]]),Ee=x(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),De=x(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),Oe=x(`message-circle`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}]]),ke=x(`message-square`,[[`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`}]]),Ae=x(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),je=x(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),Me=x(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),Ne=x(`network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),Pe=x(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),Fe=x(`panel-left-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]]),Ie=x(`panel-left-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),Le=x(`pen-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`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`}]]),Re=x(`pencil`,[[`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`}]]),ze=x(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Be=x(`puzzle`,[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]),Ve=x(`refresh-cw`,[[`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`}]]),He=x(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),Ue=x(`route`,[[`circle`,{cx:`6`,cy:`19`,r:`3`,key:`1kj8tv`}],[`path`,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,key:`1d8sl`}],[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}]]),We=x(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Ge=x(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),Ke=x(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),qe=x(`share-2`,[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]),Je=x(`shield`,[[`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`}]]),Ye=x(`shuffle`,[[`path`,{d:`m18 14 4 4-4 4`,key:`10pe0f`}],[`path`,{d:`m18 2 4 4-4 4`,key:`pucp1d`}],[`path`,{d:`M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22`,key:`1ailkh`}],[`path`,{d:`M2 6h1.972a4 4 0 0 1 3.6 2.2`,key:`km57vx`}],[`path`,{d:`M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45`,key:`os18l9`}]]),Xe=x(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),Ze=x(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Qe=x(`store`,[[`path`,{d:`M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5`,key:`slp6dd`}],[`path`,{d:`M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244`,key:`o0xfot`}],[`path`,{d:`M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05`,key:`wn3emo`}]]),$e=x(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),et=x(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),tt=x(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),nt=x(`trash-2`,[[`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`}]]),rt=x(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),it=x(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),at=x(`unlink`,[[`path`,{d:`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,key:`yqzxt4`}],[`path`,{d:`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,key:`4qinb0`}],[`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`5`,key:`1041cp`}],[`line`,{x1:`2`,x2:`5`,y1:`8`,y2:`8`,key:`14m1p5`}],[`line`,{x1:`16`,x2:`16`,y1:`19`,y2:`22`,key:`rzdirn`}],[`line`,{x1:`19`,x2:`22`,y1:`16`,y2:`16`,key:`ox905f`}]]),ot=x(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),st=x(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),ct=x(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),lt=x(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),ut=x(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),dt=x(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),ft=n(c(),1),pt=u(),mt=`modulepreload`,ht=function(e){return`/`+e},gt={},_t=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=ht(t,n),t in gt)return;gt[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:mt,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},vt=`popstate`;function yt(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function bt(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return Tt(``,{pathname:r,search:i,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||`default`,n?{pathname:e.location.pathname,search:e.location.search,hash:e.location.hash}:void 0)}function n(e,t){return typeof t==`string`?t:Et(t)}return Ot(t,n,null,e)}function xt(e,t){if(e===!1||e==null)throw Error(t)}function St(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function Ct(){return Math.random().toString(36).substring(2,10)}function wt(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function Tt(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?Dt(t):t,state:n,key:t&&t.key||r||Ct(),mask:i}}function Et({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function Dt(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function Ot(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=yt(e)?e:Tt(h.location,e,t);n&&n(r,e),l=u()+1;let d=wt(r,l),f=h.createHref(r.mask||r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=yt(e)?e:Tt(h.location,e,t);n&&n(r,e),l=u();let i=wt(r,l),d=h.createHref(r.mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return kt(i,e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(vt,d),c=e,()=>{i.removeEventListener(vt,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function kt(e,t,n=!1){let r=`http://localhost`;e&&(r=e.location.origin===`null`?e.location.href:e.location.origin),xt(r,`No window.location.(origin|href) available to create URL`);let i=typeof t==`string`?t:Et(t);return i=i.replace(/ $/,`%20`),!n&&i.startsWith(`//`)&&(i=r+i),new URL(i,r)}function At(e,t,n=`/`){return jt(e,t,n,!1)}function jt(e,t,n,r,i){let a=Xt((typeof t==`string`?Dt(t):t).pathname||`/`,n);if(a==null)return null;let o=i??Nt(e),s=null,c=Yt(a);for(let e=0;s==null&&e<o.length;++e)s=Kt(o[e],c,r);return s}function Mt(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function Nt(e){let t=Pt(e);return It(t),t}function Pt(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;xt(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=on([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(xt(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),Pt(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:Wt(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of Ft(e.path))a(e,t,!0,n)}),t}function Ft(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=Ft(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function It(e){e.sort((e,t)=>e.score===t.score?Gt(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var Lt=/^:[\w-]+$/,Rt=3,zt=2,Bt=1,Vt=10,Ht=-2,Ut=e=>e===`*`;function Wt(e,t){let n=e.split(`/`),r=n.length;return n.some(Ut)&&(r+=Ht),t&&(r+=zt),n.filter(e=>!Ut(e)).reduce((e,t)=>e+(Lt.test(t)?Rt:t===``?Bt:Vt),r)}function Gt(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function Kt(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=qt({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=qt({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:on([a,u.pathname]),pathnameBase:cn(on([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=on([a,u.pathnameBase]))}return o}function qt(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Jt(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function Jt(e,t=!1,n=!0){St(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function Yt(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return St(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Xt(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}var Zt=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Qt(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?Dt(e):e,a;return n?(n=an(n),a=n.startsWith(`/`)?$t(n.substring(1),`/`):$t(n,t)):a=t,{pathname:a,search:ln(r),hash:un(i)}}function $t(e,t){let n=sn(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function en(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function tn(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function nn(e){let t=tn(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function rn(e,t,n,r=!1){let i;typeof e==`string`?i=Dt(e):(i={...e},xt(!i.pathname||!i.pathname.includes(`?`),en(`?`,`pathname`,`search`,i)),xt(!i.pathname||!i.pathname.includes(`#`),en(`#`,`pathname`,`hash`,i)),xt(!i.search||!i.search.includes(`#`),en(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=Qt(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var an=e=>e.replace(/\/\/+/g,`/`),on=e=>an(e.join(`/`)),sn=e=>e.replace(/\/+$/,``),cn=e=>sn(e).replace(/^\/*/,`/`),ln=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,un=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,dn=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function fn(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function pn(e){return on(e.map(e=>e.route.path).filter(Boolean))||`/`}var mn=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function hn(e,t){let n=e;if(typeof n!=`string`||!Zt.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(mn)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=Xt(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{St(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var gn=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(gn);var _n=[`GET`,...gn];new Set(_n);var vn=_.createContext(null);vn.displayName=`DataRouter`;var yn=_.createContext(null);yn.displayName=`DataRouterState`;var bn=_.createContext(!1);function xn(){return _.useContext(bn)}var Sn=_.createContext({isTransitioning:!1});Sn.displayName=`ViewTransition`;var Cn=_.createContext(new Map);Cn.displayName=`Fetchers`;var wn=_.createContext(null);wn.displayName=`Await`;var Tn=_.createContext(null);Tn.displayName=`Navigation`;var En=_.createContext(null);En.displayName=`Location`;var Dn=_.createContext({outlet:null,matches:[],isDataRoute:!1});Dn.displayName=`Route`;var On=_.createContext(null);On.displayName=`RouteError`;var kn=`REACT_ROUTER_ERROR`,An=`REDIRECT`,jn=`ROUTE_ERROR_RESPONSE`;function Mn(e){if(e.startsWith(`${kn}:${An}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function Nn(e){if(e.startsWith(`${kn}:${jn}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new dn(t.status,t.statusText,t.data)}catch{}}function Pn(e,{relative:t}={}){xt(Fn(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=_.useContext(Tn),{hash:i,pathname:a,search:o}=Gn(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:on([n,a])),r.createHref({pathname:s,search:o,hash:i})}function Fn(){return _.useContext(En)!=null}function In(){return xt(Fn(),`useLocation() may be used only in the context of a <Router> component.`),_.useContext(En).location}function Ln(e){xt(Fn(),`useMatch() may be used only in the context of a <Router> component.`);let{pathname:t}=In();return _.useMemo(()=>qt(e,Yt(t)),[t,e])}var Rn=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function zn(e){_.useContext(Tn).static||_.useLayoutEffect(e)}function Bn(){let{isDataRoute:e}=_.useContext(Dn);return e?ur():Vn()}function Vn(){xt(Fn(),`useNavigate() may be used only in the context of a <Router> component.`);let e=_.useContext(vn),{basename:t,navigator:n}=_.useContext(Tn),{matches:r}=_.useContext(Dn),{pathname:i}=In(),a=JSON.stringify(nn(r)),o=_.useRef(!1);return zn(()=>{o.current=!0}),_.useCallback((r,s={})=>{if(St(o.current,Rn),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=rn(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:on([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}var Hn=_.createContext(null);function Un(e){let t=_.useContext(Dn).outlet;return _.useMemo(()=>t&&_.createElement(Hn.Provider,{value:e},t),[t,e])}function Wn(){let{matches:e}=_.useContext(Dn);return e[e.length-1]?.params??{}}function Gn(e,{relative:t}={}){let{matches:n}=_.useContext(Dn),{pathname:r}=In(),i=JSON.stringify(nn(n));return _.useMemo(()=>rn(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function Kn(e,t){return qn(e,t)}function qn(e,t,n){xt(Fn(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:r}=_.useContext(Tn),{matches:i}=_.useContext(Dn),a=i[i.length-1],o=a?a.params:{},s=a?a.pathname:`/`,c=a?a.pathnameBase:`/`,l=a&&a.route;{let e=l&&l.path||``;fr(s,!l||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${s}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
11
11
|
|
|
12
12
|
Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let u=In(),d;if(t){let e=typeof t==`string`?Dt(t):t;xt(c===`/`||e.pathname?.startsWith(c),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${e.pathname}" was given in the \`location\` prop.`),d=e}else d=u;let f=d.pathname||`/`,p=f;if(c!==`/`){let e=c.replace(/^\//,``).split(`/`);p=`/`+f.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let m=n&&n.state.matches.length?n.state.matches.map(e=>Object.assign(e,{route:n.manifest[e.route.id]||e.route})):At(e,{pathname:p});St(l||m!=null,`No routes matched location "${d.pathname}${d.search}${d.hash}" `),St(m==null||m[m.length-1].route.element!==void 0||m[m.length-1].route.Component!==void 0||m[m.length-1].route.lazy!==void 0,`Matched leaf route at location "${d.pathname}${d.search}${d.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let h=er(m&&m.map(e=>Object.assign({},e,{params:Object.assign({},o,e.params),pathname:on([c,r.encodeLocation?r.encodeLocation(e.pathname.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?c:on([c,r.encodeLocation?r.encodeLocation(e.pathnameBase.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),i,n);return t&&h?_.createElement(En.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,mask:void 0,...d},navigationType:`POP`}},h):h}function Jn(){let e=lr(),t=fn(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},o=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),o=_.createElement(_.Fragment,null,_.createElement(`p`,null,`💿 Hey developer 👋`),_.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,_.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,_.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),_.createElement(_.Fragment,null,_.createElement(`h2`,null,`Unexpected Application Error!`),_.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?_.createElement(`pre`,{style:i},n):null,o)}var Yn=_.createElement(Jn,null),Xn=class extends _.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=Nn(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:_.createElement(Dn.Provider,{value:this.props.routeContext},_.createElement(On.Provider,{value:e,children:this.props.component}));return this.context?_.createElement(Qn,{error:e},t):t}};Xn.contextType=bn;var Zn=new WeakMap;function Qn({children:e,error:t}){let{basename:n}=_.useContext(Tn);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=Mn(t.digest);if(e){let r=Zn.get(t);if(r)throw r;let i=hn(e.location,n);if(mn&&!Zn.get(t))if(i.isExternal||e.reloadDocument)window.location.href=i.absoluteURL||i.to;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw Zn.set(t,n),n}return _.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${i.absoluteURL||i.to}`})}}return e}function $n({routeContext:e,match:t,children:n}){let r=_.useContext(vn);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),_.createElement(Dn.Provider,{value:e},n)}function er(e,t=[],n){let r=n?.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let i=e,a=r?.errors;if(a!=null){let e=i.findIndex(e=>e.route.id&&a?.[e.route.id]!==void 0);xt(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(`,`)}`),i=i.slice(0,Math.min(i.length,e+1))}let o=!1,s=-1;if(n&&r){o=r.renderFallback;for(let e=0;e<i.length;e++){let t=i[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(s=e),t.route.id){let{loaderData:e,errors:a}=r,c=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!a||a[t.route.id]===void 0);if(t.route.lazy||c){n.isStatic&&(o=!0),i=s>=0?i.slice(0,s+1):[i[0]];break}}}}let c=n?.onError,l=r&&c?(e,t)=>{c(e,{location:r.location,params:r.matches?.[0]?.params??{},pattern:pn(r.matches),errorInfo:t})}:void 0;return i.reduceRight((e,n,c)=>{let u,d=!1,f=null,p=null;r&&(u=a&&n.route.id?a[n.route.id]:void 0,f=n.route.errorElement||Yn,o&&(s<0&&c===0?(fr(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,p=null):s===c&&(d=!0,p=n.route.hydrateFallbackElement||null)));let m=t.concat(i.slice(0,c+1)),h=()=>{let t;return t=u?f:d?p:n.route.Component?_.createElement(n.route.Component,null):n.route.element?n.route.element:e,_.createElement($n,{match:n,routeContext:{outlet:e,matches:m,isDataRoute:r!=null},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||c===0)?_.createElement(Xn,{location:r.location,revalidation:r.revalidation,component:f,error:u,children:h(),routeContext:{outlet:null,matches:m,isDataRoute:!0},onError:l}):h()},null)}function tr(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function nr(e){let t=_.useContext(vn);return xt(t,tr(e)),t}function rr(e){let t=_.useContext(yn);return xt(t,tr(e)),t}function ir(e){let t=_.useContext(Dn);return xt(t,tr(e)),t}function ar(e){let t=ir(e),n=t.matches[t.matches.length-1];return xt(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function or(){return ar(`useRouteId`)}function sr(){let e=rr(`useNavigation`);return _.useMemo(()=>{let{matches:t,historyAction:n,...r}=e.navigation;return r},[e.navigation])}function cr(){let{matches:e,loaderData:t}=rr(`useMatches`);return _.useMemo(()=>e.map(e=>Mt(e,t)),[e,t])}function lr(){let e=_.useContext(On),t=rr(`useRouteError`),n=ar(`useRouteError`);return e===void 0?t.errors?.[n]:e}function ur(){let{router:e}=nr(`useNavigate`),t=ar(`useNavigate`),n=_.useRef(!1);return zn(()=>{n.current=!0}),_.useCallback(async(r,i={})=>{St(n.current,Rn),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var dr={};function fr(e,t,n){!t&&!dr[e]&&(dr[e]=!0,St(!1,n))}_.memo(pr);function pr({routes:e,manifest:t,future:n,state:r,isStatic:i,onError:a}){return qn(e,void 0,{manifest:t,state:r,isStatic:i,onError:a,future:n})}function mr({to:e,replace:t,state:n,relative:r}){xt(Fn(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=_.useContext(Tn);St(!i,`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`);let{matches:a}=_.useContext(Dn),{pathname:o}=In(),s=Bn(),c=rn(e,nn(a),o,r===`path`),l=JSON.stringify(c);return _.useEffect(()=>{s(JSON.parse(l),{replace:t,state:n,relative:r})},[s,l,r,t,n]),null}function hr(e){return Un(e.context)}function gr(e){xt(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function _r({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,useTransitions:o}){xt(!Fn(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let s=e.replace(/^\/*/,`/`),c=_.useMemo(()=>({basename:s,navigator:i,static:a,useTransitions:o,future:{}}),[s,i,a,o]);typeof n==`string`&&(n=Dt(n));let{pathname:l=`/`,search:u=``,hash:d=``,state:f=null,key:p=`default`,mask:m}=n,h=_.useMemo(()=>{let e=Xt(l,s);return e==null?null:{location:{pathname:e,search:u,hash:d,state:f,key:p,mask:m},navigationType:r}},[s,l,u,d,f,p,r,m]);return St(h!=null,`<Router basename="${s}"> is not able to match the URL "${l}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),h==null?null:_.createElement(Tn.Provider,{value:c},_.createElement(En.Provider,{children:t,value:h}))}function vr({children:e,location:t}){return Kn(yr(e),t)}_.Component;function yr(e,t=[]){let n=[];return _.Children.forEach(e,(e,r)=>{if(!_.isValidElement(e))return;let i=[...t,r];if(e.type===_.Fragment){n.push.apply(n,yr(e.props.children,i));return}xt(e.type===gr,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),xt(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=yr(e.props.children,i)),n.push(a)}),n}var br=`get`,xr=`application/x-www-form-urlencoded`;function Sr(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function Cr(e){return Sr(e)&&e.tagName.toLowerCase()===`button`}function wr(e){return Sr(e)&&e.tagName.toLowerCase()===`form`}function Tr(e){return Sr(e)&&e.tagName.toLowerCase()===`input`}function Er(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Dr(e,t){return e.button===0&&(!t||t===`_self`)&&!Er(e)}function Or(e=``){return new URLSearchParams(typeof e==`string`||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(e=>[n,e]):[[n,r]])},[]))}function kr(e,t){let n=Or(e);return t&&t.forEach((e,r)=>{n.has(r)||t.getAll(r).forEach(e=>{n.append(r,e)})}),n}var Ar=null;function jr(){if(Ar===null)try{new FormData(document.createElement(`form`),0),Ar=!1}catch{Ar=!0}return Ar}var Mr=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function Nr(e){return e!=null&&!Mr.has(e)?(St(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${xr}"`),null):e}function Pr(e,t){let n,r,i,a,o;if(wr(e)){let o=e.getAttribute(`action`);r=o?Xt(o,t):null,n=e.getAttribute(`method`)||br,i=Nr(e.getAttribute(`enctype`))||xr,a=new FormData(e)}else if(Cr(e)||Tr(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?Xt(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||br,i=Nr(e.getAttribute(`formenctype`))||Nr(o.getAttribute(`enctype`))||xr,a=new FormData(o,e),!jr()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(Sr(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=br,r=null,i=xr,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Fr={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},Ir=/[&><\u2028\u2029]/g;function Lr(e){return e.replace(Ir,e=>Fr[e])}function Rr(e,t){if(e===!1||e==null)throw Error(t)}function zr(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return n?i.pathname.endsWith(`/`)?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname===`/`?i.pathname=`_root.${r}`:t&&Xt(i.pathname,t)===`/`?i.pathname=`${sn(t)}/_root.${r}`:i.pathname=`${sn(i.pathname)}.${r}`,i}async function Br(e,t){if(e.id in t)return t[e.id];try{let n=await _t(()=>import(e.module),[]);return t[e.id]=n,n}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Vr(e){return e!=null&&typeof e.page==`string`}function Hr(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function Ur(e,t,n){return Jr((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await Br(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(Hr).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function Wr(e,t,n,r,i,a){let o=(e,t)=>n[t]?e.route.id!==n[t].route.id:!0,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function Gr(e,t,{includeHydrateFallback:n}={}){return Kr(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function Kr(e){return[...new Set(e)]}function qr(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function Jr(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!Vr(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(qr(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function Yr(){let e=_.useContext(vn);return Rr(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function Xr(){let e=_.useContext(yn);return Rr(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var Zr=_.createContext(void 0);Zr.displayName=`FrameworkContext`;function Qr(){let e=_.useContext(Zr);return Rr(e,`You must render this element inside a <HydratedRouter> element`),e}function $r(e,t){let n=_.useContext(Zr),[r,i]=_.useState(!1),[a,o]=_.useState(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:u,onTouchStart:d}=t,f=_.useRef(null);_.useEffect(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return f.current&&e.observe(f.current),()=>{e.disconnect()}}},[e]),_.useEffect(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let p=()=>{i(!0)},m=()=>{i(!1),o(!1)};return n?e===`intent`?[a,f,{onFocus:ei(s,p),onBlur:ei(c,m),onMouseEnter:ei(l,p),onMouseLeave:ei(u,m),onTouchStart:ei(d,p)}]:[a,f,{}]:[!1,f,{}]}function ei(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function ti({page:e,...t}){let n=xn(),{router:r}=Yr(),i=_.useMemo(()=>At(r.routes,e,r.basename),[r.routes,e,r.basename]);return i?n?_.createElement(ri,{page:e,matches:i,...t}):_.createElement(ii,{page:e,matches:i,...t}):null}function ni(e){let{manifest:t,routeModules:n}=Qr(),[r,i]=_.useState([]);return _.useEffect(()=>{let r=!1;return Ur(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function ri({page:e,matches:t,...n}){let r=In(),{future:i}=Qr(),{basename:a}=Yr(),o=_.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=zr(e,a,i.v8_trailingSlashAwareDataRequests,`rsc`),o=!1,s=[];for(let e of t)typeof e.route.shouldRevalidate==`function`?o=!0:s.push(e.route.id);return o&&s.length>0&&n.searchParams.set(`_routes`,s.join(`,`)),[n.pathname+n.search]},[a,i.v8_trailingSlashAwareDataRequests,e,r,t]);return _.createElement(_.Fragment,null,o.map(e=>_.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})))}function ii({page:e,matches:t,...n}){let r=In(),{future:i,manifest:a,routeModules:o}=Qr(),{basename:s}=Yr(),{loaderData:c,matches:l}=Xr(),u=_.useMemo(()=>Wr(e,t,l,a,r,`data`),[e,t,l,a,r]),d=_.useMemo(()=>Wr(e,t,l,a,r,`assets`),[e,t,l,a,r]),f=_.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,l=!1;if(t.forEach(e=>{let t=a.routes[e.route.id];!t||!t.hasLoader||(!u.some(t=>t.route.id===e.route.id)&&e.route.id in c&&o[e.route.id]?.shouldRevalidate||t.hasClientLoader?l=!0:n.add(e.route.id))}),n.size===0)return[];let d=zr(e,s,i.v8_trailingSlashAwareDataRequests,`data`);return l&&n.size>0&&d.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[d.pathname+d.search]},[s,i.v8_trailingSlashAwareDataRequests,c,r,a,u,t,e,o]),p=_.useMemo(()=>Gr(d,a),[d,a]),m=ni(d);return _.createElement(_.Fragment,null,f.map(e=>_.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),p.map(e=>_.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),m.map(({key:e,link:t})=>_.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function ai(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}_.Component;var oi=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{oi&&(window.__reactRouterVersion=`7.16.0`)}catch{}function si({basename:e,children:t,useTransitions:n,window:r}){let i=_.useRef();i.current??=bt({window:r,v5Compat:!0});let a=i.current,[o,s]=_.useState({action:a.action,location:a.location}),c=_.useCallback(e=>{n===!1?s(e):_.startTransition(()=>s(e))},[n]);return _.useLayoutEffect(()=>a.listen(c),[a,c]),_.createElement(_r,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:a,useTransitions:n})}function ci({basename:e,children:t,history:n,useTransitions:r}){let[i,a]=_.useState({action:n.action,location:n.location}),o=_.useCallback(e=>{r===!1?a(e):_.startTransition(()=>a(e))},[r]);return _.useLayoutEffect(()=>n.listen(o),[n,o]),_.createElement(_r,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,useTransitions:r})}ci.displayName=`unstable_HistoryRouter`;var li=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ui=_.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,mask:o,state:s,target:c,to:l,preventScrollReset:u,viewTransition:d,defaultShouldRevalidate:f,...p},m){let{basename:h,navigator:g,useTransitions:v}=_.useContext(Tn),y=typeof l==`string`&&li.test(l),b=hn(l,h);l=b.to;let x=Pn(l,{relative:r}),S=In(),C=null;if(o){let e=rn(o,[],S.mask?S.mask.pathname:`/`,!0);h!==`/`&&(e.pathname=e.pathname===`/`?h:on([h,e.pathname])),C=g.createHref(e)}let[w,T,E]=$r(n,p),D=_i(l,{replace:a,mask:o,state:s,target:c,preventScrollReset:u,relative:r,viewTransition:d,defaultShouldRevalidate:f,useTransitions:v});function O(t){e&&e(t),t.defaultPrevented||D(t)}let k=!(b.isExternal||i),A=_.createElement(`a`,{...p,...E,href:(k?C:void 0)||b.absoluteURL||x,onClick:k?O:e,ref:ai(m,T),target:c,"data-discover":!y&&t===`render`?`true`:void 0});return w&&!y?_.createElement(_.Fragment,null,A,_.createElement(ti,{page:x})):A});ui.displayName=`Link`;var di=_.forwardRef(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:a,viewTransition:o,children:s,...c},l){let u=Gn(a,{relative:c.relative}),d=In(),f=_.useContext(yn),{navigator:p,basename:m}=_.useContext(Tn),h=f!=null&&Oi(u)&&o===!0,g=p.encodeLocation?p.encodeLocation(u).pathname:u.pathname,v=d.pathname,y=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(v=v.toLowerCase(),y=y?y.toLowerCase():null,g=g.toLowerCase()),y&&m&&(y=Xt(y,m)||y);let b=g!==`/`&&g.endsWith(`/`)?g.length-1:g.length,x=v===g||!r&&v.startsWith(g)&&v.charAt(b)===`/`,S=y!=null&&(y===g||!r&&y.startsWith(g)&&y.charAt(g.length)===`/`),C={isActive:x,isPending:S,isTransitioning:h},w=x?e:void 0,T;T=typeof n==`function`?n(C):[n,x?`active`:null,S?`pending`:null,h?`transitioning`:null].filter(Boolean).join(` `);let E=typeof i==`function`?i(C):i;return _.createElement(ui,{...c,"aria-current":w,className:T,ref:l,style:E,to:a,viewTransition:o},typeof s==`function`?s(C):s)});di.displayName=`NavLink`;var fi=_.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:o=br,action:s,onSubmit:c,relative:l,preventScrollReset:u,viewTransition:d,defaultShouldRevalidate:f,...p},m)=>{let{useTransitions:h}=_.useContext(Tn),g=xi(),v=Si(s,{relative:l}),y=o.toLowerCase()===`get`?`get`:`post`,b=typeof s==`string`&&li.test(s);return _.createElement(`form`,{ref:m,method:y,action:v,onSubmit:r?c:e=>{if(c&&c(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,s=r?.getAttribute(`formmethod`)||o,p=()=>g(r||e.currentTarget,{fetcherKey:t,method:s,navigate:n,replace:i,state:a,relative:l,preventScrollReset:u,viewTransition:d,defaultShouldRevalidate:f});h&&n!==!1?_.startTransition(()=>p()):p()},...p,"data-discover":!b&&e===`render`?`true`:void 0})});fi.displayName=`Form`;function pi({getKey:e,storageKey:t,...n}){let r=_.useContext(Zr),{basename:i}=_.useContext(Tn),a=In(),o=cr();Ei({getKey:e,storageKey:t});let s=_.useMemo(()=>{if(!r||!e)return null;let t=Ti(a,o,i,e);return t===a.key?null:t},[]);if(!r||r.isSpaMode)return null;let c=((e,t)=>{if(!window.history.state||!window.history.state.key){let e=Math.random().toString(32).slice(2);window.history.replaceState({key:e},``)}try{let n=JSON.parse(sessionStorage.getItem(e)||`{}`)[t||window.history.state.key];typeof n==`number`&&window.scrollTo(0,n)}catch(t){console.error(t),sessionStorage.removeItem(e)}}).toString();return _.createElement(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${c})(${Lr(JSON.stringify(t||Ci))}, ${Lr(JSON.stringify(s))})`}})}pi.displayName=`ScrollRestoration`;function mi(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function hi(e){let t=_.useContext(vn);return xt(t,mi(e)),t}function gi(e){let t=_.useContext(yn);return xt(t,mi(e)),t}function _i(e,{target:t,replace:n,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c,useTransitions:l}={}){let u=Bn(),d=In(),f=Gn(e,{relative:o});return _.useCallback(p=>{if(Dr(p,t)){p.preventDefault();let t=n===void 0?Et(d)===Et(f):n,m=()=>u(e,{replace:t,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c});l?_.startTransition(()=>m()):m()}},[d,u,f,n,r,i,t,e,a,o,s,c,l])}function vi(e){St(typeof URLSearchParams<`u`,"You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=_.useRef(Or(e)),n=_.useRef(!1),r=In(),i=_.useMemo(()=>kr(r.search,n.current?null:t.current),[r.search]),a=Bn();return[i,_.useCallback((e,t)=>{let r=Or(typeof e==`function`?e(new URLSearchParams(i)):e);n.current=!0,a(`?`+r,t)},[a,i])]}var yi=0,bi=()=>`__${String(++yi)}__`;function xi(){let{router:e}=hi(`useSubmit`),{basename:t}=_.useContext(Tn),n=or(),r=e.fetch,i=e.navigate;return _.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=Pr(e,t);a.navigate===!1?await r(a.fetcherKey||bi(),n,a.action||o,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,flushSync:a.flushSync}):await i(a.action||o,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,t,n])}function Si(e,{relative:t}={}){let{basename:n}=_.useContext(Tn),r=_.useContext(Dn);xt(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...Gn(e||`.`,{relative:t})},o=In();if(e==null){a.search=o.search;let e=new URLSearchParams(a.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();a.search=n?`?${n}`:``}}return(!e||e===`.`)&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(a.pathname=a.pathname===`/`?n:on([n,a.pathname])),Et(a)}var Ci=`react-router-scroll-positions`,wi={};function Ti(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:Xt(e.pathname,n)||e.pathname},t)),i??=e.key,i}function Ei({getKey:e,storageKey:t}={}){let{router:n}=hi(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=gi(`useScrollRestoration`),{basename:a}=_.useContext(Tn),o=In(),s=cr(),c=sr();_.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),Di(_.useCallback(()=>{if(c.state===`idle`){let t=Ti(o,s,a,e);wi[t]=window.scrollY}try{sessionStorage.setItem(t||Ci,JSON.stringify(wi))}catch(e){St(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[c.state,e,a,o,s,t])),typeof document<`u`&&(_.useLayoutEffect(()=>{try{let e=sessionStorage.getItem(t||Ci);e&&(wi=JSON.parse(e))}catch{}},[t]),_.useLayoutEffect(()=>{let t=n?.enableScrollRestoration(wi,()=>window.scrollY,e?(t,n)=>Ti(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),_.useLayoutEffect(()=>{if(r!==!1){if(typeof r==`number`){window.scrollTo(0,r);return}try{if(o.hash){let e=document.getElementById(decodeURIComponent(o.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{St(!1,`"${o.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}i!==!0&&window.scrollTo(0,0)}},[o,r,i]))}function Di(e,t){let{capture:n}=t||{};_.useEffect(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function Oi(e,{relative:t}={}){let n=_.useContext(Sn);xt(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=hi(`useViewTransitionState`),i=Gn(e,{relative:t});if(!n.isTransitioning)return!1;let a=Xt(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Xt(n.nextLocation.pathname,r)||n.nextLocation.pathname;return qt(i.pathname,o)!=null||qt(i.pathname,a)!=null}function ki(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Ai(...e){return t=>{let n=!1,r=e.map(e=>{let r=ki(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():ki(e[t],null)}}}}function ji(...e){return _.useCallback(Ai(...e),e)}var G=i();function Mi(e){let t=Pi(e),n=_.forwardRef((e,n)=>{let{children:r,...i}=e,a=_.Children.toArray(r),o=a.find(Li);if(o){let e=o.props.children,r=a.map(t=>t===o?_.Children.count(e)>1?_.Children.only(null):_.isValidElement(e)?e.props.children:null:t);return(0,G.jsx)(t,{...i,ref:n,children:_.isValidElement(e)?_.cloneElement(e,void 0,r):null})}return(0,G.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}var Ni=Mi(`Slot`);function Pi(e){let t=_.forwardRef((e,t)=>{let{children:n,...r}=e;if(_.isValidElement(n)){let e=zi(n),i=Ri(r,n.props);return n.type!==_.Fragment&&(i.ref=t?Ai(t,e):e),_.cloneElement(n,i)}return _.Children.count(n)>1?_.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Fi=Symbol(`radix.slottable`);function Ii(e){let t=({children:e})=>(0,G.jsx)(G.Fragment,{children:e});return t.displayName=`${e}.Slottable`,t.__radixId=Fi,t}function Li(e){return _.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Fi}function Ri(e,t){let n={...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]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function zi(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Bi=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Mi(`Primitive.${t}`),r=_.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,G.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Vi(e,t){e&&ft.flushSync(()=>e.dispatchEvent(t))}var Hi=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),Ui=`VisuallyHidden`,Wi=_.forwardRef((e,t)=>(0,G.jsx)(Bi.span,{...e,ref:t,style:{...Hi,...e.style}}));Wi.displayName=Ui;var Gi=Wi;function Ki(e,t){let n=_.createContext(t),r=e=>{let{children:t,...r}=e,i=_.useMemo(()=>r,Object.values(r));return(0,G.jsx)(n.Provider,{value:i,children:t})};r.displayName=e+`Provider`;function i(r){let i=_.useContext(n);if(i)return i;if(t!==void 0)return t;throw Error(`\`${r}\` must be used within \`${e}\``)}return[r,i]}function qi(e,t=[]){let n=[];function r(t,r){let i=_.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=_.useMemo(()=>o,Object.values(o));return(0,G.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=_.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>_.createContext(e));return function(n){let r=n?.[e]||t;return _.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,Ji(i,...t)]}function Ji(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return _.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}typeof window<`u`&&window.document&&window.document.createElement;function K(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}var Yi=globalThis?.document?_.useLayoutEffect:()=>{},Xi=_.useInsertionEffect||Yi;function Zi({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=Qi({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=_.useRef(e!==void 0);_.useEffect(()=>{let e=t.current;e!==s&&console.warn(`${r} is changing from ${e?`controlled`:`uncontrolled`} to ${s?`controlled`:`uncontrolled`}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),t.current=s},[s,r])}return[c,_.useCallback(t=>{if(s){let n=$i(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function Qi({defaultProp:e,onChange:t}){let[n,r]=_.useState(e),i=_.useRef(n),a=_.useRef(t);return Xi(()=>{a.current=t},[t]),_.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function $i(e){return typeof e==`function`}function ea(e,t){return _.useReducer((e,n)=>t[e][n]??e,e)}var ta=e=>{let{present:t,children:n}=e,r=na(t),i=typeof n==`function`?n({present:r.isPresent}):_.Children.only(n),a=ji(r.ref,ia(i));return typeof n==`function`||r.isPresent?_.cloneElement(i,{ref:a}):null};ta.displayName=`Presence`;function na(e){let[t,n]=_.useState(),r=_.useRef(null),i=_.useRef(e),a=_.useRef(`none`),[o,s]=ea(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return _.useEffect(()=>{let e=ra(r.current);a.current=o===`mounted`?e:`none`},[o]),Yi(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=ra(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),Yi(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=ra(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=ra(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:_.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function ra(e){return e?.animationName||`none`}function ia(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var aa=_.useId||(()=>void 0),oa=0;function sa(e){let[t,n]=_.useState(aa());return Yi(()=>{e||n(e=>e??String(oa++))},[e]),e||(t?`radix-${t}`:``)}var ca=`Collapsible`,[la,ua]=qi(ca),[da,fa]=la(ca),pa=_.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=Zi({prop:r,defaultProp:i??!1,onChange:o,caller:ca});return(0,G.jsx)(da,{scope:n,disabled:a,contentId:sa(),open:c,onOpenToggle:_.useCallback(()=>l(e=>!e),[l]),children:(0,G.jsx)(Bi.div,{"data-state":ya(c),"data-disabled":a?``:void 0,...s,ref:t})})});pa.displayName=ca;var ma=`CollapsibleTrigger`,ha=_.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,i=fa(ma,n);return(0,G.jsx)(Bi.button,{type:`button`,"aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":ya(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:K(e.onClick,i.onOpenToggle)})});ha.displayName=ma;var ga=`CollapsibleContent`,_a=_.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=fa(ga,e.__scopeCollapsible);return(0,G.jsx)(ta,{present:n||i.open,children:({present:e})=>(0,G.jsx)(va,{...r,ref:t,present:e})})});_a.displayName=ga;var va=_.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=fa(ga,n),[s,c]=_.useState(r),l=_.useRef(null),u=ji(t,l),d=_.useRef(0),f=d.current,p=_.useRef(0),m=p.current,h=o.open||s,g=_.useRef(h),v=_.useRef(void 0);return _.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),Yi(()=>{let e=l.current;if(e){v.current=v.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();d.current=t.height,p.current=t.width,g.current||(e.style.transitionDuration=v.current.transitionDuration,e.style.animationName=v.current.animationName),c(r)}},[o.open,r]),(0,G.jsx)(Bi.div,{"data-state":ya(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!h,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:h&&i})});function ya(e){return e?`open`:`closed`}var ba=pa;function xa(e){let t=_.useRef(e);return _.useEffect(()=>{t.current=e}),_.useMemo(()=>(...e)=>t.current?.(...e),[])}function Sa(e,t=globalThis?.document){let n=xa(e);_.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var Ca=`DismissableLayer`,wa=`dismissableLayer.update`,Ta=`dismissableLayer.pointerDownOutside`,Ea=`dismissableLayer.focusOutside`,Da,Oa=_.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ka=_.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:s,...c}=e,l=_.useContext(Oa),[u,d]=_.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=_.useState({}),m=ji(t,e=>d(e)),h=Array.from(l.layers),[g]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),v=h.indexOf(g),y=u?h.indexOf(u):-1,b=l.layersWithOutsidePointerEventsDisabled.size>0,x=y>=v,S=Ma(e=>{let t=e.target,n=[...l.branches].some(e=>e.contains(t));!x||n||(i?.(e),o?.(e),e.defaultPrevented||s?.())},f),C=Na(e=>{let t=e.target;[...l.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||s?.())},f);return Sa(e=>{y===l.layers.size-1&&(r?.(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},f),_.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(Da=f.body.style.pointerEvents,f.body.style.pointerEvents=`none`),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),Pa(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=Da)}},[u,f,n,l]),_.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),Pa())},[u,l]),_.useEffect(()=>{let e=()=>p({});return document.addEventListener(wa,e),()=>document.removeEventListener(wa,e)},[]),(0,G.jsx)(Bi.div,{...c,ref:m,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:K(e.onFocusCapture,C.onFocusCapture),onBlurCapture:K(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:K(e.onPointerDownCapture,S.onPointerDownCapture)})});ka.displayName=Ca;var Aa=`DismissableLayerBranch`,ja=_.forwardRef((e,t)=>{let n=_.useContext(Oa),r=_.useRef(null),i=ji(t,r);return _.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,G.jsx)(Bi.div,{...e,ref:i})});ja.displayName=Aa;function Ma(e,t=globalThis?.document){let n=xa(e),r=_.useRef(!1),i=_.useRef(()=>{});return _.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){Fa(Ta,n,a,{discrete:!0})},a={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,i.current),i.current=r,t.addEventListener(`click`,i.current,{once:!0})):r()}else t.removeEventListener(`click`,i.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(a),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Na(e,t=globalThis?.document){let n=xa(e),r=_.useRef(!1);return _.useEffect(()=>{let e=e=>{e.target&&!r.current&&Fa(Ea,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Pa(){let e=new CustomEvent(wa);document.dispatchEvent(e)}function Fa(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?Vi(i,a):i.dispatchEvent(a)}var Ia=`focusScope.autoFocusOnMount`,La=`focusScope.autoFocusOnUnmount`,Ra={bubbles:!1,cancelable:!0},za=`FocusScope`,Ba=_.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=_.useState(null),l=xa(i),u=xa(a),d=_.useRef(null),f=ji(t,e=>c(e)),p=_.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;_.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:qa(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||qa(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&qa(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),_.useEffect(()=>{if(s){Ja.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(Ia,Ra);s.addEventListener(Ia,l),s.dispatchEvent(t),t.defaultPrevented||(Va(Za(Ua(s)),{select:!0}),document.activeElement===e&&qa(s))}return()=>{s.removeEventListener(Ia,l),setTimeout(()=>{let t=new CustomEvent(La,Ra);s.addEventListener(La,u),s.dispatchEvent(t),t.defaultPrevented||qa(e??document.body,{select:!0}),s.removeEventListener(La,u),Ja.remove(p)},0)}}},[s,l,u,p]);let m=_.useCallback(e=>{if(!n&&!r||p.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]=Ha(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&qa(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&qa(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,G.jsx)(Bi.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});Ba.displayName=za;function Va(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(qa(r,{select:t}),document.activeElement!==n)return}function Ha(e){let t=Ua(e);return[Wa(t,e),Wa(t.reverse(),e)]}function Ua(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode: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}});for(;n.nextNode();)t.push(n.currentNode);return t}function Wa(e,t){for(let n of e)if(!Ga(n,{upTo:t}))return n}function Ga(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}function Ka(e){return e instanceof HTMLInputElement&&`select`in e}function qa(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Ka(e)&&t&&e.select()}}var Ja=Ya();function Ya(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Xa(e,t),e.unshift(t)},remove(t){e=Xa(e,t),e[0]?.resume()}}}function Xa(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Za(e){return e.filter(e=>e.tagName!==`A`)}var Qa=`Portal`,$a=_.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=_.useState(!1);Yi(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?ft.createPortal((0,G.jsx)(Bi.div,{...r,ref:t}),o):null});$a.displayName=Qa;var eo=0;function to(){_.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??no()),document.body.insertAdjacentElement(`beforeend`,e[1]??no()),eo++,()=>{eo===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),eo--}},[])}function no(){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}var ro=function(){return ro=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},ro.apply(this,arguments)};function io(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 ao(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var oo=`right-scroll-bar-position`,so=`width-before-scroll-bar`,co=`with-scroll-bars-hidden`,lo=`--removed-body-scroll-bar-size`;function uo(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function fo(e,t){var n=(0,_.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var po=typeof window<`u`?_.useLayoutEffect:_.useEffect,mo=new WeakMap;function ho(e,t){var n=fo(t||null,function(t){return e.forEach(function(e){return uo(e,t)})});return po(function(){var t=mo.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||uo(e,null)}),i.forEach(function(e){r.has(e)||uo(e,a)})}mo.set(n,e)},[e]),n}function go(e){return e}function _o(e,t){t===void 0&&(t=go);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 vo(e){e===void 0&&(e={});var t=_o(null);return t.options=ro({async:!0,ssr:!1},e),t}var yo=function(e){var t=e.sideCar,n=io(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return _.createElement(r,ro({},n))};yo.isSideCarExport=!0;function bo(e,t){return e.useMedium(t),yo}var xo=vo(),So=function(){},Co=_.forwardRef(function(e,t){var n=_.useRef(null),r=_.useState({onScrollCapture:So,onWheelCapture:So,onTouchMoveCapture:So}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,v=e.as,y=v===void 0?`div`:v,b=e.gapMode,x=io(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=f,C=ho([n,t]),w=ro(ro({},x),i);return _.createElement(_.Fragment,null,u&&_.createElement(S,{sideCar:xo,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:b}),o?_.cloneElement(_.Children.only(s),ro(ro({},w),{ref:C})):_.createElement(y,ro({},w,{className:c,ref:C}),s))});Co.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Co.classNames={fullWidth:so,zeroRight:oo};var wo,To=function(){if(wo)return wo;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function Eo(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=To();return t&&e.setAttribute(`nonce`,t),e}function Do(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Oo(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var ko=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Eo())&&(Do(t,n),Oo(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Ao=function(){var e=ko();return function(t,n){_.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},jo=function(){var e=Ao();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},Mo={left:0,top:0,right:0,gap:0},No=function(e){return parseInt(e||``,10)||0},Po=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[No(n),No(r),No(i)]},Fo=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return Mo;var t=Po(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])}},Io=jo(),Lo=`data-scroll-locked`,Ro=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
13
13
|
.${co} {
|
|
@@ -53,9 +53,9 @@ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}
|
|
|
53
53
|
|
|
54
54
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
55
55
|
|
|
56
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return _.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},ec=`DialogDescriptionWarning`,tc=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Qs(ec).contentName}}.`;return _.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},nc=Ds,rc=Ns,ic=Fs,ac=zs,oc=Ws,sc=Ks,cc=Js;function lc(e){let[t,n]=_.useState(void 0);return Yi(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var uc=[`top`,`right`,`bottom`,`left`],dc=Math.min,fc=Math.max,pc=Math.round,mc=Math.floor,hc=e=>({x:e,y:e}),gc={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function _c(e,t,n){return fc(e,dc(t,n))}function vc(e,t){return typeof e==`function`?e(t):e}function yc(e){return e.split(`-`)[0]}function bc(e){return e.split(`-`)[1]}function xc(e){return e===`x`?`y`:`x`}function Sc(e){return e===`y`?`height`:`width`}function Cc(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function wc(e){return xc(Cc(e))}function Tc(e,t,n){n===void 0&&(n=!1);let r=bc(e),i=wc(e),a=Sc(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Pc(o)),[o,Pc(o)]}function Ec(e){let t=Pc(e);return[Dc(e),t,Dc(t)]}function Dc(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var Oc=[`left`,`right`],kc=[`right`,`left`],Ac=[`top`,`bottom`],jc=[`bottom`,`top`];function Mc(e,t,n){switch(e){case`top`:case`bottom`:return n?t?kc:Oc:t?Oc:kc;case`left`:case`right`:return t?Ac:jc;default:return[]}}function Nc(e,t,n,r){let i=bc(e),a=Mc(yc(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Dc)))),a}function Pc(e){let t=yc(e);return gc[t]+e.slice(t.length)}function Fc(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ic(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Fc(e)}function Lc(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}}function Rc(e,t,n){let{reference:r,floating:i}=e,a=Cc(t),o=wc(t),s=Sc(o),c=yc(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}}switch(bc(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function zc(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=vc(t,e),p=Ic(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Lc(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=Lc(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Bc=50,Vc=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:zc},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Rc(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}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<Bc&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=Rc(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Hc=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=vc(e,t)||{};if(l==null)return{};let d=Ic(u),f={x:n,y:r},p=wc(i),m=Sc(p),h=await 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=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(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,E=dc(d[_],T),D=dc(d[v],T),O=E,k=C-h[m]-D,A=C/2-h[m]/2+w,j=_c(O,A,k),M=!c.arrow&&bc(i)!=null&&A!==j&&a.reference[m]/2-(A<O?E:D)-h[m]/2<0,N=M?A<O?A-O:A-k:0;return{[p]:f[p]+N,data:{[p]:j,centerOffset:A-j-N,...M&&{alignmentOffset:N}},reset:M}}}),Uc=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=vc(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=yc(r),_=Cc(o),v=yc(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Pc(o)]:Ec(o)),x=p!==`none`;!d&&x&&b.push(...Nc(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Tc(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==Cc(t))||T.every(e=>Cc(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=Cc(e.placement);return t===_||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]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function Wc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Gc(e){return uc.some(t=>e[t]>=0)}var Kc=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=vc(e,t);switch(i){case`referenceHidden`:{let e=Wc(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Gc(e)}}}case`escaped`:{let e=Wc(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Gc(e)}}}default:return{}}}}},qc=new Set([`left`,`top`]);async function Jc(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=yc(n),s=bc(n),c=Cc(n)===`y`,l=qc.has(o)?-1:1,u=a&&c?-1:1,d=vc(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}}var Yc=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Jc(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Xc=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=vc(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Cc(yc(i)),p=xc(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=_c(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=_c(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},Zc=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=vc(e,t),u={x:n,y:r},d=Cc(i),f=xc(d),p=u[f],m=u[d],h=vc(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=qc.has(yc(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},Qc=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=vc(e,t),u=await o.detectOverflow(t,l),d=yc(i),f=bc(i),p=Cc(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,y=m-u.left-u.right,b=dc(h-u[g],v),x=dc(m-u[_],y),S=!t.middlewareData.shift,C=b,w=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(w=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),S&&!f){let e=fc(u.left,0),t=fc(u.right,0),n=fc(u.top,0),r=fc(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:fc(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:fc(u.top,u.bottom))}await c({...t,availableWidth:w,availableHeight:C});let T=await o.getDimensions(s.floating);return m!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function $c(){return typeof window<`u`}function el(e){return rl(e)?(e.nodeName||``).toLowerCase():`#document`}function tl(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function nl(e){return((rl(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function rl(e){return $c()?e instanceof Node||e instanceof tl(e).Node:!1}function il(e){return $c()?e instanceof Element||e instanceof tl(e).Element:!1}function al(e){return $c()?e instanceof HTMLElement||e instanceof tl(e).HTMLElement:!1}function ol(e){return!$c()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof tl(e).ShadowRoot}function sl(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=vl(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function cl(e){return/^(table|td|th)$/.test(el(e))}function ll(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var ul=/transform|translate|scale|rotate|perspective|filter/,dl=/paint|layout|strict|content/,fl=e=>!!e&&e!==`none`,pl;function ml(e){let t=il(e)?vl(e):e;return fl(t.transform)||fl(t.translate)||fl(t.scale)||fl(t.rotate)||fl(t.perspective)||!gl()&&(fl(t.backdropFilter)||fl(t.filter))||ul.test(t.willChange||``)||dl.test(t.contain||``)}function hl(e){let t=bl(e);for(;al(t)&&!_l(t);){if(ml(t))return t;if(ll(t))return null;t=bl(t)}return null}function gl(){return pl??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),pl}function _l(e){return/^(html|body|#document)$/.test(el(e))}function vl(e){return tl(e).getComputedStyle(e)}function yl(e){return il(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function bl(e){if(el(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||ol(e)&&e.host||nl(e);return ol(t)?t.host:t}function xl(e){let t=bl(e);return _l(t)?e.ownerDocument?e.ownerDocument.body:e.body:al(t)&&sl(t)?t:xl(t)}function Sl(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=xl(e),i=r===e.ownerDocument?.body,a=tl(r);if(i){let e=Cl(a);return t.concat(a,a.visualViewport||[],sl(r)?r:[],e&&n?Sl(e):[])}else return t.concat(r,Sl(r,[],n))}function Cl(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function wl(e){let t=vl(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=al(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=pc(n)!==a||pc(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Tl(e){return il(e)?e:e.contextElement}function El(e){let t=Tl(e);if(!al(t))return hc(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=wl(t),o=(a?pc(n.width):n.width)/r,s=(a?pc(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Dl=hc(0);function Ol(e){let t=tl(e);return!gl()||!t.visualViewport?Dl:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function kl(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==tl(e)?!1:t}function Al(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Tl(e),o=hc(1);t&&(r?il(r)&&(o=El(r)):o=El(e));let s=kl(a,n,r)?Ol(a):hc(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){let e=tl(a),t=r&&il(r)?tl(r):r,n=e,i=Cl(n);for(;i&&r&&t!==n;){let e=El(i),t=i.getBoundingClientRect(),r=vl(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=tl(i),i=Cl(n)}}return Lc({width:u,height:d,x:c,y:l})}function jl(e,t){let n=yl(e).scrollLeft;return t?t.left+n:Al(nl(e)).left+n}function Ml(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-jl(e,n),y:n.top+t.scrollTop}}function Nl(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=nl(r),s=t?ll(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=hc(1),u=hc(0),d=al(r);if((d||!d&&!a)&&((el(r)!==`body`||sl(o))&&(c=yl(r)),d)){let e=Al(r);l=El(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Ml(o,c):hc(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 Pl(e){return Array.from(e.getClientRects())}function Fl(e){let t=nl(e),n=yl(e),r=e.ownerDocument.body,i=fc(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=fc(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+jl(e),s=-n.scrollTop;return vl(r).direction===`rtl`&&(o+=fc(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var Il=25;function Ll(e,t){let n=tl(e),r=nl(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=gl();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=jl(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=Il&&(a-=o)}else l<=Il&&(a+=l);return{width:a,height:o,x:s,y:c}}function Rl(e,t){let n=Al(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=al(e)?El(e):hc(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function zl(e,t,n){let r;if(t===`viewport`)r=Ll(e,n);else if(t===`document`)r=Fl(nl(e));else if(il(t))r=Rl(t,n);else{let n=Ol(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Lc(r)}function Bl(e,t){let n=bl(e);return n===t||!il(n)||_l(n)?!1:vl(n).position===`fixed`||Bl(n,t)}function Vl(e,t){let n=t.get(e);if(n)return n;let r=Sl(e,[],!1).filter(e=>il(e)&&el(e)!==`body`),i=null,a=vl(e).position===`fixed`,o=a?bl(e):e;for(;il(o)&&!_l(o);){let t=vl(o),n=ml(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||sl(o)&&!n&&Bl(e,o))?r=r.filter(e=>e!==o):i=t,o=bl(o)}return t.set(e,r),r}function Hl(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?ll(t)?[]:Vl(t,this._c):[].concat(n),r],o=zl(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=zl(t,a[e],i);s=fc(n.top,s),c=dc(n.right,c),l=dc(n.bottom,l),u=fc(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Ul(e){let{width:t,height:n}=wl(e);return{width:t,height:n}}function Wl(e,t,n){let r=al(t),i=nl(t),a=n===`fixed`,o=Al(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=hc(0);function l(){c.x=jl(i)}if(r||!r&&!a)if((el(t)!==`body`||sl(i))&&(s=yl(t)),r){let e=Al(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?Ml(i,s):hc(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function Gl(e){return vl(e).position===`static`}function Kl(e,t){if(!al(e)||vl(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return nl(e)===n&&(n=n.ownerDocument.body),n}function ql(e,t){let n=tl(e);if(ll(e))return n;if(!al(e)){let t=bl(e);for(;t&&!_l(t);){if(il(t)&&!Gl(t))return t;t=bl(t)}return n}let r=Kl(e,t);for(;r&&cl(r)&&Gl(r);)r=Kl(r,t);return r&&_l(r)&&Gl(r)&&!ml(r)?n:r||hl(e)||n}var Jl=async function(e){let t=this.getOffsetParent||ql,n=this.getDimensions,r=await n(e.floating);return{reference:Wl(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Yl(e){return vl(e).direction===`rtl`}var Xl={convertOffsetParentRelativeRectToViewportRelativeRect:Nl,getDocumentElement:nl,getClippingRect:Hl,getOffsetParent:ql,getElementRects:Jl,getClientRects:Pl,getDimensions:Ul,getScale:El,isElement:il,isRTL:Yl};function Zl(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Ql(e,t){let n=null,r,i=nl(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=mc(d),h=mc(i.clientWidth-(u+f)),g=mc(i.clientHeight-(d+p)),_=mc(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:fc(0,dc(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!Zl(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function $l(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=Tl(e),u=i||a?[...l?Sl(l):[],...t?Sl(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?Ql(l,n):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?Al(e):null;c&&g();function g(){let t=Al(e);h&&!Zl(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?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var eu=Yc,tu=Xc,nu=Uc,ru=Qc,iu=Kc,au=Hc,ou=Zc,su=(e,t,n)=>{let r=new Map,i={platform:Xl,...n},a={...i.platform,_c:r};return Vc(e,t,{...i,platform:a})},cu=typeof document<`u`?_.useLayoutEffect:function(){};function lu(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(!lu(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)&&!lu(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function uu(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function du(e,t){let n=uu(e);return Math.round(t*n)/n}function fu(e){let t=_.useRef(e);return cu(()=>{t.current=e}),t}function pu(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=_.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=_.useState(r);lu(f,r)||p(r);let[m,h]=_.useState(null),[g,v]=_.useState(null),y=_.useCallback(e=>{e!==C.current&&(C.current=e,h(e))},[]),b=_.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||m,S=o||g,C=_.useRef(null),w=_.useRef(null),T=_.useRef(u),E=c!=null,D=fu(c),O=fu(i),k=fu(l),A=_.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),su(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!lu(T.current,t)&&(T.current=t,ft.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);cu(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=_.useRef(!1);cu(()=>(j.current=!0,()=>{j.current=!1}),[]),cu(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=_.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=_.useMemo(()=>({reference:x,floating:S}),[x,S]),P=_.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=du(N.floating,u.x),r=du(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...uu(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return _.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:P}),[u,A,M,N,P])}var mu=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?{}:au({element:r.current,padding:i}).fn(n):r?au({element:r,padding:i}).fn(n):{}}}},hu=(e,t)=>{let n=eu(e);return{name:n.name,fn:n.fn,options:[e,t]}},gu=(e,t)=>{let n=tu(e);return{name:n.name,fn:n.fn,options:[e,t]}},_u=(e,t)=>({fn:ou(e).fn,options:[e,t]}),vu=(e,t)=>{let n=nu(e);return{name:n.name,fn:n.fn,options:[e,t]}},yu=(e,t)=>{let n=ru(e);return{name:n.name,fn:n.fn,options:[e,t]}},bu=(e,t)=>{let n=iu(e);return{name:n.name,fn:n.fn,options:[e,t]}},xu=(e,t)=>{let n=mu(e);return{name:n.name,fn:n.fn,options:[e,t]}},Su=`Arrow`,Cu=_.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,G.jsx)(Bi.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,G.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});Cu.displayName=Su;var wu=Cu,Tu=`Popper`,[Eu,Du]=qi(Tu),[Ou,ku]=Eu(Tu),Au=e=>{let{__scopePopper:t,children:n}=e,[r,i]=_.useState(null);return(0,G.jsx)(Ou,{scope:t,anchor:r,onAnchorChange:i,children:n})};Au.displayName=Tu;var ju=`PopperAnchor`,Mu=_.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=ku(ju,n),o=_.useRef(null),s=ji(t,o),c=_.useRef(null);return _.useEffect(()=>{let e=c.current;c.current=r?.current||o.current,e!==c.current&&a.onAnchorChange(c.current)}),r?null:(0,G.jsx)(Bi.div,{...i,ref:s})});Mu.displayName=ju;var Nu=`PopperContent`,[Pu,Fu]=Eu(Nu),Iu=_.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=ku(Nu,n),[v,y]=_.useState(null),b=ji(t,e=>y(e)),[x,S]=_.useState(null),C=lc(x),w=C?.width??0,T=C?.height??0,E=r+(a===`center`?``:`-`+a),D=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},O=Array.isArray(l)?l:[l],k=O.length>0,A={padding:D,boundary:O.filter(Bu),altBoundary:k},{refs:j,floatingStyles:M,placement:N,isPositioned:P,middlewareData:F}=pu({strategy:`fixed`,placement:E,whileElementsMounted:(...e)=>$l(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[hu({mainAxis:i+T,alignmentAxis:o}),c&&gu({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?_u():void 0,...A}),c&&vu({...A}),yu({...A,apply:({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`)}}),x&&xu({element:x,padding:s}),Vu({arrowWidth:w,arrowHeight:T}),f&&bu({strategy:`referenceHidden`,...A})]}),[I,L]=Hu(N),R=xa(m);Yi(()=>{P&&R?.()},[P,R]);let z=F.arrow?.x,B=F.arrow?.y,V=F.arrow?.centerOffset!==0,[H,U]=_.useState();return Yi(()=>{v&&U(window.getComputedStyle(v).zIndex)},[v]),(0,G.jsx)(`div`,{ref:j.setFloating,"data-radix-popper-content-wrapper":``,style:{...M,transform:P?M.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:H,"--radix-popper-transform-origin":[F.transformOrigin?.x,F.transformOrigin?.y].join(` `),...F.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,G.jsx)(Pu,{scope:n,placedSide:I,onArrowChange:S,arrowX:z,arrowY:B,shouldHideArrow:V,children:(0,G.jsx)(Bi.div,{"data-side":I,"data-align":L,...h,ref:b,style:{...h.style,animation:P?void 0:`none`}})})})});Iu.displayName=Nu;var Lu=`PopperArrow`,Ru={top:`bottom`,right:`left`,bottom:`top`,left:`right`},zu=_.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Fu(Lu,n),a=Ru[i.placedSide];return(0,G.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,G.jsx)(wu,{...r,ref:t,style:{...r.style,display:`block`}})})});zu.displayName=Lu;function Bu(e){return e!==null}var Vu=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Hu(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function Hu(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var Uu=Au,Wu=Mu,Gu=Iu,Ku=zu,qu=`Popover`,[Ju,Yu]=qi(qu,[Du]),Xu=Du(),[Zu,Qu]=Ju(qu),$u=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=Xu(t),c=_.useRef(null),[l,u]=_.useState(!1),[d,f]=Zi({prop:r,defaultProp:i??!1,onChange:a,caller:qu});return(0,G.jsx)(Uu,{...s,children:(0,G.jsx)(Zu,{scope:t,contentId:sa(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:_.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:_.useCallback(()=>u(!0),[]),onCustomAnchorRemove:_.useCallback(()=>u(!1),[]),modal:o,children:n})})};$u.displayName=qu;var ed=`PopoverAnchor`,td=_.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Qu(ed,n),a=Xu(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return _.useEffect(()=>(o(),()=>s()),[o,s]),(0,G.jsx)(Wu,{...a,...r,ref:t})});td.displayName=ed;var nd=`PopoverTrigger`,rd=_.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Qu(nd,n),a=Xu(n),o=ji(t,i.triggerRef),s=(0,G.jsx)(Bi.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":vd(i.open),...r,ref:o,onClick:K(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,G.jsx)(Wu,{asChild:!0,...a,children:s})});rd.displayName=nd;var id=`PopoverPortal`,[ad,od]=Ju(id,{forceMount:void 0}),sd=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=Qu(id,t);return(0,G.jsx)(ad,{scope:t,forceMount:n,children:(0,G.jsx)(ta,{present:n||a.open,children:(0,G.jsx)($a,{asChild:!0,container:i,children:r})})})};sd.displayName=id;var cd=`PopoverContent`,ld=_.forwardRef((e,t)=>{let n=od(cd,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=Qu(cd,e.__scopePopover);return(0,G.jsx)(ta,{present:r||a.open,children:a.modal?(0,G.jsx)(dd,{...i,ref:t}):(0,G.jsx)(fd,{...i,ref:t})})});ld.displayName=cd;var ud=Mi(`PopoverContent.RemoveScroll`),dd=_.forwardRef((e,t)=>{let n=Qu(cd,e.__scopePopover),r=_.useRef(null),i=ji(t,r),a=_.useRef(!1);return _.useEffect(()=>{let e=r.current;if(e)return xs(e)},[]),(0,G.jsx)(fs,{as:ud,allowPinchZoom:!0,children:(0,G.jsx)(pd,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:K(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:K(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;a.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:K(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),fd=_.forwardRef((e,t)=>{let n=Qu(cd,e.__scopePopover),r=_.useRef(!1),i=_.useRef(!1);return(0,G.jsx)(pd,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),pd=_.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=Qu(cd,n),p=Xu(n);return to(),(0,G.jsx)(Ba,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,G.jsx)(ka,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,G.jsx)(Gu,{"data-state":vd(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),md=`PopoverClose`,hd=_.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Qu(md,n);return(0,G.jsx)(Bi.button,{type:`button`,...r,ref:t,onClick:K(e.onClick,()=>i.onOpenChange(!1))})});hd.displayName=md;var gd=`PopoverArrow`,_d=_.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Xu(n);return(0,G.jsx)(Ku,{...i,...r,ref:t})});_d.displayName=gd;function vd(e){return e?`open`:`closed`}var yd=$u,bd=rd,xd=sd,Sd=ld,Cd=hd,[wd,Td]=qi(`Tooltip`,[Du]),Ed=Du(),Dd=`TooltipProvider`,Od=700,kd=`tooltip.open`,[Ad,jd]=wd(Dd),Md=e=>{let{__scopeTooltip:t,delayDuration:n=Od,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=_.useRef(!0),s=_.useRef(!1),c=_.useRef(0);return _.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,G.jsx)(Ad,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:_.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:_.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:_.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};Md.displayName=Dd;var Nd=`Tooltip`,[Pd,Fd]=wd(Nd),Id=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=jd(Nd,e.__scopeTooltip),l=Ed(t),[u,d]=_.useState(null),f=sa(),p=_.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=_.useRef(!1),[v,y]=Zi({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(kd))):c.onClose(),a?.(e)},caller:Nd}),b=_.useMemo(()=>v?g.current?`delayed-open`:`instant-open`:`closed`,[v]),x=_.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,y(!0)},[y]),S=_.useCallback(()=>{window.clearTimeout(p.current),p.current=0,y(!1)},[y]),C=_.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,y(!0),p.current=0},h)},[h,y]);return _.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,G.jsx)(Uu,{...l,children:(0,G.jsx)(Pd,{scope:t,contentId:f,open:v,stateAttribute:b,trigger:u,onTriggerChange:d,onTriggerEnter:_.useCallback(()=>{c.isOpenDelayedRef.current?C():x()},[c.isOpenDelayedRef,C,x]),onTriggerLeave:_.useCallback(()=>{m?S():(window.clearTimeout(p.current),p.current=0)},[S,m]),onOpen:x,onClose:S,disableHoverableContent:m,children:n})})};Id.displayName=Nd;var Ld=`TooltipTrigger`,Rd=_.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Fd(Ld,n),a=jd(Ld,n),o=Ed(n),s=ji(t,_.useRef(null),i.onTriggerChange),c=_.useRef(!1),l=_.useRef(!1),u=_.useCallback(()=>c.current=!1,[]);return _.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,G.jsx)(Wu,{asChild:!0,...o,children:(0,G.jsx)(Bi.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:K(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:K(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:K(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:K(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:K(e.onBlur,i.onClose),onClick:K(e.onClick,i.onClose)})})});Rd.displayName=Ld;var zd=`TooltipPortal`,[Bd,Vd]=wd(zd,{forceMount:void 0}),Hd=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=Fd(zd,t);return(0,G.jsx)(Bd,{scope:t,forceMount:n,children:(0,G.jsx)(ta,{present:n||a.open,children:(0,G.jsx)($a,{asChild:!0,container:i,children:r})})})};Hd.displayName=zd;var Ud=`TooltipContent`,Wd=_.forwardRef((e,t)=>{let n=Vd(Ud,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=Fd(Ud,e.__scopeTooltip);return(0,G.jsx)(ta,{present:r||o.open,children:o.disableHoverableContent?(0,G.jsx)(Yd,{side:i,...a,ref:t}):(0,G.jsx)(Gd,{side:i,...a,ref:t})})}),Gd=_.forwardRef((e,t)=>{let n=Fd(Ud,e.__scopeTooltip),r=jd(Ud,e.__scopeTooltip),i=_.useRef(null),a=ji(t,i),[o,s]=_.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=_.useCallback(()=>{s(null),d(!1)},[d]),p=_.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=$d(r,Qd(r,n.getBoundingClientRect())),a=ef(t.getBoundingClientRect());s(nf([...i,...a])),d(!0)},[d]);return _.useEffect(()=>()=>f(),[f]),_.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),_.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!tf(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,G.jsx)(Yd,{...e,ref:a})}),[Kd,qd]=wd(Nd,{isInside:!1}),Jd=Ii(`TooltipContent`),Yd=_.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=Fd(Ud,n),l=Ed(n),{onClose:u}=c;return _.useEffect(()=>(document.addEventListener(kd,u),()=>document.removeEventListener(kd,u)),[u]),_.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,G.jsx)(ka,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,G.jsxs)(Gu,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,G.jsx)(Jd,{children:r}),(0,G.jsx)(Kd,{scope:n,isInside:!0,children:(0,G.jsx)(Gi,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});Wd.displayName=Ud;var Xd=`TooltipArrow`,Zd=_.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Ed(n);return qd(Xd,n).isInside?null:(0,G.jsx)(Ku,{...i,...r,ref:t})});Zd.displayName=Xd;function Qd(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function $d(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function ef(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function tf(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}function nf(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),rf(t)}function rf(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var af=Md,of=Id,sf=Rd,cf=Hd,lf=Wd,uf=Zd;function df(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=df(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function ff(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=df(e))&&(r&&(r+=` `),r+=t);return r}var pf=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},mf=(e,t)=>({classGroupId:e,validator:t}),hf=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),gf=`-`,_f=[],vf=`arbitrary..`,yf=e=>{let t=Sf(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return xf(e);let n=e.split(gf);return bf(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?pf(i,t):t:i||_f}return n[e]||_f}}},bf=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=bf(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(gf):e.slice(t).join(gf),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},xf=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?vf+r:void 0})(),Sf=e=>{let{theme:t,classGroups:n}=e;return Cf(n,t)},Cf=(e,t)=>{let n=hf();for(let r in e){let i=e[r];wf(i,n,r,t)}return n},wf=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];Tf(i,t,n,r)}},Tf=(e,t,n,r)=>{if(typeof e==`string`){Ef(e,t,n);return}if(typeof e==`function`){Df(e,t,n,r);return}Of(e,t,n,r)},Ef=(e,t,n)=>{let r=e===``?t:kf(t,e);r.classGroupId=n},Df=(e,t,n,r)=>{if(Af(e)){wf(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(mf(n,e))},Of=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];wf(o,kf(t,a),n,r)}},kf=(e,t)=>{let n=e,r=t.split(gf),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=hf(),n.nextPart.set(t,i)),n=i}return n},Af=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,jf=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},Mf=`!`,Nf=`:`,Pf=[],Ff=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),If=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===Nf){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(Mf)?(c=s.slice(0,-1),l=!0):s.startsWith(Mf)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return Ff(t,l,c,u)};if(t){let e=t+Nf,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):Ff(Pf,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},Lf=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},Rf=e=>({cache:jf(e.cacheSize),parseClassName:If(e),sortModifiers:Lf(e),postfixLookupClassGroupIds:zf(e),...yf(e)}),zf=e=>{let t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let e=0;e<n.length;e++)t[n[e]]=!0;return t},Bf=/\s+/,Vf=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(Bf),l=``;for(let e=c.length-1;e>=0;--e){let t=c[e],{isExternal:u,modifiers:d,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}=n(t);if(u){l=t+(l.length>0?` `+l:l);continue}let h=!!m,g;if(h){g=r(p.substring(0,m));let e=g&&o[g]?r(p):void 0;e&&e!==g&&(g=e,h=!1)}else g=r(p);if(!g){if(!h){l=t+(l.length>0?` `+l:l);continue}if(g=r(p),!g){l=t+(l.length>0?` `+l:l);continue}h=!1}let _=d.length===0?``:d.length===1?d[0]:a(d).join(`:`),v=f?_+Mf:_,y=v+g;if(s.indexOf(y)>-1)continue;s.push(y);let b=i(g,h);for(let e=0;e<b.length;++e){let t=b[e];s.push(v+t)}l=t+(l.length>0?` `+l:l)}return l},Hf=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=Uf(n))&&(i&&(i+=` `),i+=r);return i},Uf=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=Uf(e[r]))&&(n&&(n+=` `),n+=t);return n},Wf=(e,...t)=>{let n,r,i,a,o=o=>(n=Rf(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=Vf(e,n);return i(e,a),a};return a=o,(...e)=>a(Hf(...e))},Gf=[],Kf=e=>{let t=t=>t[e]||Gf;return t.isThemeGetter=!0,t},qf=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Jf=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Yf=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Xf=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Zf=/\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$/,Qf=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,$f=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ep=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,tp=e=>Yf.test(e),np=e=>!!e&&!Number.isNaN(Number(e)),rp=e=>!!e&&Number.isInteger(Number(e)),ip=e=>e.endsWith(`%`)&&np(e.slice(0,-1)),ap=e=>Xf.test(e),op=()=>!0,sp=e=>Zf.test(e)&&!Qf.test(e),cp=()=>!1,lp=e=>$f.test(e),up=e=>ep.test(e),dp=e=>!q(e)&&!J(e),fp=e=>e.startsWith(`@container`)&&(e[10]===`/`&&e[11]!==void 0||e[11]===`s`&&e[16]!==void 0&&e.startsWith(`-size/`,10)||e[11]===`n`&&e[18]!==void 0&&e.startsWith(`-normal/`,10)),pp=e=>Op(e,Mp,cp),q=e=>qf.test(e),mp=e=>Op(e,Np,sp),hp=e=>Op(e,Pp,np),gp=e=>Op(e,Ip,op),_p=e=>Op(e,Fp,cp),vp=e=>Op(e,Ap,cp),yp=e=>Op(e,jp,up),bp=e=>Op(e,Lp,lp),J=e=>Jf.test(e),xp=e=>kp(e,Np),Sp=e=>kp(e,Fp),Cp=e=>kp(e,Ap),wp=e=>kp(e,Mp),Tp=e=>kp(e,jp),Ep=e=>kp(e,Lp,!0),Dp=e=>kp(e,Ip,!0),Op=(e,t,n)=>{let r=qf.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},kp=(e,t,n=!1)=>{let r=Jf.exec(e);return r?r[1]?t(r[1]):n:!1},Ap=e=>e===`position`||e===`percentage`,jp=e=>e===`image`||e===`url`,Mp=e=>e===`length`||e===`size`||e===`bg-size`,Np=e=>e===`length`,Pp=e=>e===`number`,Fp=e=>e===`family-name`,Ip=e=>e===`number`||e===`weight`,Lp=e=>e===`shadow`,Rp=Wf(()=>{let e=Kf(`color`),t=Kf(`font`),n=Kf(`text`),r=Kf(`font-weight`),i=Kf(`tracking`),a=Kf(`leading`),o=Kf(`breakpoint`),s=Kf(`container`),c=Kf(`spacing`),l=Kf(`radius`),u=Kf(`shadow`),d=Kf(`inset-shadow`),f=Kf(`text-shadow`),p=Kf(`drop-shadow`),m=Kf(`blur`),h=Kf(`perspective`),g=Kf(`aspect`),_=Kf(`ease`),v=Kf(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),J,q],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[J,q,c],T=()=>[tp,`full`,`auto`,...w()],E=()=>[rp,`none`,`subgrid`,J,q],D=()=>[`auto`,{span:[`full`,rp,J,q]},rp,J,q],O=()=>[rp,`auto`,J,q],k=()=>[`auto`,`min`,`max`,`fr`,J,q],A=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],j=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],M=()=>[`auto`,...w()],N=()=>[tp,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],P=()=>[tp,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],F=()=>[tp,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],I=()=>[e,J,q],L=()=>[...b(),Cp,vp,{position:[J,q]}],R=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],z=()=>[`auto`,`cover`,`contain`,wp,pp,{size:[J,q]}],B=()=>[ip,xp,mp],V=()=>[``,`none`,`full`,l,J,q],H=()=>[``,np,xp,mp],U=()=>[`solid`,`dashed`,`dotted`,`double`],ee=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],W=()=>[np,ip,Cp,vp],te=()=>[``,`none`,m,J,q],ne=()=>[`none`,np,J,q],re=()=>[`none`,np,J,q],ie=()=>[np,J,q],ae=()=>[tp,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[ap],breakpoint:[ap],color:[op],container:[ap],"drop-shadow":[ap],ease:[`in`,`out`,`in-out`],font:[dp],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[ap],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[ap],shadow:[ap],spacing:[`px`,np],text:[ap],"text-shadow":[ap],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,tp,q,J,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,J,q]}],"container-named":[fp],columns:[{columns:[np,q,J,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[rp,`auto`,J,q]}],basis:[{basis:[tp,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[np,tp,`auto`,`initial`,`none`,q]}],grow:[{grow:[``,np,J,q]}],shrink:[{shrink:[``,np,J,q]}],order:[{order:[rp,`first`,`last`,`none`,J,q]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":k()}],"auto-rows":[{"auto-rows":k()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...A(),`normal`]}],"justify-items":[{"justify-items":[...j(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...j()]}],"align-content":[{content:[`normal`,...A()]}],"align-items":[{items:[...j(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...j(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":A()}],"place-items":[{"place-items":[...j(),`baseline`]}],"place-self":[{"place-self":[`auto`,...j()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:M()}],mx:[{mx:M()}],my:[{my:M()}],ms:[{ms:M()}],me:[{me:M()}],mbs:[{mbs:M()}],mbe:[{mbe:M()}],mt:[{mt:M()}],mr:[{mr:M()}],mb:[{mb:M()}],ml:[{ml:M()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:N()}],"inline-size":[{inline:[`auto`,...P()]}],"min-inline-size":[{"min-inline":[`auto`,...P()]}],"max-inline-size":[{"max-inline":[`none`,...P()]}],"block-size":[{block:[`auto`,...F()]}],"min-block-size":[{"min-block":[`auto`,...F()]}],"max-block-size":[{"max-block":[`none`,...F()]}],w:[{w:[s,`screen`,...N()]}],"min-w":[{"min-w":[s,`screen`,`none`,...N()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...N()]}],h:[{h:[`screen`,`lh`,...N()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...N()]}],"max-h":[{"max-h":[`screen`,`lh`,...N()]}],"font-size":[{text:[`base`,n,xp,mp]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,Dp,gp]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,ip,q]}],"font-family":[{font:[Sp,_p,t]}],"font-features":[{"font-features":[q]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,J,q]}],"line-clamp":[{"line-clamp":[np,`none`,J,hp]}],leading:[{leading:[a,...w()]}],"list-image":[{"list-image":[`none`,J,q]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,J,q]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:I()}],"text-color":[{text:I()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...U(),`wavy`]}],"text-decoration-thickness":[{decoration:[np,`from-font`,`auto`,J,mp]}],"text-decoration-color":[{decoration:I()}],"underline-offset":[{"underline-offset":[np,`auto`,J,q]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"tab-size":[{tab:[rp,J,q]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,J,q]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,J,q]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:L()}],"bg-repeat":[{bg:R()}],"bg-size":[{bg:z()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},rp,J,q],radial:[``,J,q],conic:[rp,J,q]},Tp,yp]}],"bg-color":[{bg:I()}],"gradient-from-pos":[{from:B()}],"gradient-via-pos":[{via:B()}],"gradient-to-pos":[{to:B()}],"gradient-from":[{from:I()}],"gradient-via":[{via:I()}],"gradient-to":[{to:I()}],rounded:[{rounded:V()}],"rounded-s":[{"rounded-s":V()}],"rounded-e":[{"rounded-e":V()}],"rounded-t":[{"rounded-t":V()}],"rounded-r":[{"rounded-r":V()}],"rounded-b":[{"rounded-b":V()}],"rounded-l":[{"rounded-l":V()}],"rounded-ss":[{"rounded-ss":V()}],"rounded-se":[{"rounded-se":V()}],"rounded-ee":[{"rounded-ee":V()}],"rounded-es":[{"rounded-es":V()}],"rounded-tl":[{"rounded-tl":V()}],"rounded-tr":[{"rounded-tr":V()}],"rounded-br":[{"rounded-br":V()}],"rounded-bl":[{"rounded-bl":V()}],"border-w":[{border:H()}],"border-w-x":[{"border-x":H()}],"border-w-y":[{"border-y":H()}],"border-w-s":[{"border-s":H()}],"border-w-e":[{"border-e":H()}],"border-w-bs":[{"border-bs":H()}],"border-w-be":[{"border-be":H()}],"border-w-t":[{"border-t":H()}],"border-w-r":[{"border-r":H()}],"border-w-b":[{"border-b":H()}],"border-w-l":[{"border-l":H()}],"divide-x":[{"divide-x":H()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":H()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...U(),`hidden`,`none`]}],"divide-style":[{divide:[...U(),`hidden`,`none`]}],"border-color":[{border:I()}],"border-color-x":[{"border-x":I()}],"border-color-y":[{"border-y":I()}],"border-color-s":[{"border-s":I()}],"border-color-e":[{"border-e":I()}],"border-color-bs":[{"border-bs":I()}],"border-color-be":[{"border-be":I()}],"border-color-t":[{"border-t":I()}],"border-color-r":[{"border-r":I()}],"border-color-b":[{"border-b":I()}],"border-color-l":[{"border-l":I()}],"divide-color":[{divide:I()}],"outline-style":[{outline:[...U(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[np,J,q]}],"outline-w":[{outline:[``,np,xp,mp]}],"outline-color":[{outline:I()}],shadow:[{shadow:[``,`none`,u,Ep,bp]}],"shadow-color":[{shadow:I()}],"inset-shadow":[{"inset-shadow":[`none`,d,Ep,bp]}],"inset-shadow-color":[{"inset-shadow":I()}],"ring-w":[{ring:H()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:I()}],"ring-offset-w":[{"ring-offset":[np,mp]}],"ring-offset-color":[{"ring-offset":I()}],"inset-ring-w":[{"inset-ring":H()}],"inset-ring-color":[{"inset-ring":I()}],"text-shadow":[{"text-shadow":[`none`,f,Ep,bp]}],"text-shadow-color":[{"text-shadow":I()}],opacity:[{opacity:[np,J,q]}],"mix-blend":[{"mix-blend":[...ee(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":ee()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[np]}],"mask-image-linear-from-pos":[{"mask-linear-from":W()}],"mask-image-linear-to-pos":[{"mask-linear-to":W()}],"mask-image-linear-from-color":[{"mask-linear-from":I()}],"mask-image-linear-to-color":[{"mask-linear-to":I()}],"mask-image-t-from-pos":[{"mask-t-from":W()}],"mask-image-t-to-pos":[{"mask-t-to":W()}],"mask-image-t-from-color":[{"mask-t-from":I()}],"mask-image-t-to-color":[{"mask-t-to":I()}],"mask-image-r-from-pos":[{"mask-r-from":W()}],"mask-image-r-to-pos":[{"mask-r-to":W()}],"mask-image-r-from-color":[{"mask-r-from":I()}],"mask-image-r-to-color":[{"mask-r-to":I()}],"mask-image-b-from-pos":[{"mask-b-from":W()}],"mask-image-b-to-pos":[{"mask-b-to":W()}],"mask-image-b-from-color":[{"mask-b-from":I()}],"mask-image-b-to-color":[{"mask-b-to":I()}],"mask-image-l-from-pos":[{"mask-l-from":W()}],"mask-image-l-to-pos":[{"mask-l-to":W()}],"mask-image-l-from-color":[{"mask-l-from":I()}],"mask-image-l-to-color":[{"mask-l-to":I()}],"mask-image-x-from-pos":[{"mask-x-from":W()}],"mask-image-x-to-pos":[{"mask-x-to":W()}],"mask-image-x-from-color":[{"mask-x-from":I()}],"mask-image-x-to-color":[{"mask-x-to":I()}],"mask-image-y-from-pos":[{"mask-y-from":W()}],"mask-image-y-to-pos":[{"mask-y-to":W()}],"mask-image-y-from-color":[{"mask-y-from":I()}],"mask-image-y-to-color":[{"mask-y-to":I()}],"mask-image-radial":[{"mask-radial":[J,q]}],"mask-image-radial-from-pos":[{"mask-radial-from":W()}],"mask-image-radial-to-pos":[{"mask-radial-to":W()}],"mask-image-radial-from-color":[{"mask-radial-from":I()}],"mask-image-radial-to-color":[{"mask-radial-to":I()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[np]}],"mask-image-conic-from-pos":[{"mask-conic-from":W()}],"mask-image-conic-to-pos":[{"mask-conic-to":W()}],"mask-image-conic-from-color":[{"mask-conic-from":I()}],"mask-image-conic-to-color":[{"mask-conic-to":I()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:L()}],"mask-repeat":[{mask:R()}],"mask-size":[{mask:z()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,J,q]}],filter:[{filter:[``,`none`,J,q]}],blur:[{blur:te()}],brightness:[{brightness:[np,J,q]}],contrast:[{contrast:[np,J,q]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,Ep,bp]}],"drop-shadow-color":[{"drop-shadow":I()}],grayscale:[{grayscale:[``,np,J,q]}],"hue-rotate":[{"hue-rotate":[np,J,q]}],invert:[{invert:[``,np,J,q]}],saturate:[{saturate:[np,J,q]}],sepia:[{sepia:[``,np,J,q]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,J,q]}],"backdrop-blur":[{"backdrop-blur":te()}],"backdrop-brightness":[{"backdrop-brightness":[np,J,q]}],"backdrop-contrast":[{"backdrop-contrast":[np,J,q]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,np,J,q]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[np,J,q]}],"backdrop-invert":[{"backdrop-invert":[``,np,J,q]}],"backdrop-opacity":[{"backdrop-opacity":[np,J,q]}],"backdrop-saturate":[{"backdrop-saturate":[np,J,q]}],"backdrop-sepia":[{"backdrop-sepia":[``,np,J,q]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,J,q]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[np,`initial`,J,q]}],ease:[{ease:[`linear`,`initial`,_,J,q]}],delay:[{delay:[np,J,q]}],animate:[{animate:[`none`,v,J,q]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,J,q]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:ne()}],"rotate-x":[{"rotate-x":ne()}],"rotate-y":[{"rotate-y":ne()}],"rotate-z":[{"rotate-z":ne()}],scale:[{scale:re()}],"scale-x":[{"scale-x":re()}],"scale-y":[{"scale-y":re()}],"scale-z":[{"scale-z":re()}],"scale-3d":[`scale-3d`],skew:[{skew:ie()}],"skew-x":[{"skew-x":ie()}],"skew-y":[{"skew-y":ie()}],transform:[{transform:[J,q,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:ae()}],"translate-x":[{"translate-x":ae()}],"translate-y":[{"translate-y":ae()}],"translate-z":[{"translate-z":ae()}],"translate-none":[`translate-none`],zoom:[{zoom:[rp,J,q]}],accent:[{accent:I()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:I()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,J,q]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scrollbar-thumb-color":[{"scrollbar-thumb":I()}],"scrollbar-track-color":[{"scrollbar-track":I()}],"scrollbar-gutter":[{"scrollbar-gutter":[`auto`,`stable`,`both`]}],"scrollbar-w":[{scrollbar:[`auto`,`thin`,`none`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,J,q]}],fill:[{fill:[`none`,...I()]}],"stroke-w":[{stroke:[np,xp,mp,hp]}],stroke:[{stroke:[`none`,...I()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{"container-named":[`container-type`],overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},postfixLookupClassGroups:[`container-type`],orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function Y(...e){return Rp(ff(e))}function zp({delayDuration:e=0,...t}){return(0,G.jsx)(af,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Bp({...e}){return(0,G.jsx)(of,{"data-slot":`tooltip`,...e})}function Vp({...e}){return(0,G.jsx)(sf,{"data-slot":`tooltip-trigger`,...e})}function Hp({className:e,sideOffset:t=4,children:n,...r}){return(0,G.jsx)(cf,{children:(0,G.jsxs)(lf,{"data-slot":`tooltip-content`,sideOffset:t,className:Y(`z-50 overflow-hidden rounded-md bg-gray-900 px-3 py-1.5 text-xs text-gray-100 shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 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`,e),...r,children:[n,(0,G.jsx)(uf,{className:`fill-gray-900`})]})})}var X=(e,t)=>fetch(e,{credentials:`include`,...t}),Up=null;function Wp(){return Up||=X(`/api/health`).then(e=>e.json()).then(e=>typeof e?.workspace==`string`?e.workspace:`loopat`).catch(()=>`loopat`),Up}async function Gp(){let e=await X(`/api/auth/me`);return e.ok?(await e.json()).user??null:null}async function Kp(e,t){let n=await X(`/api/auth/login`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({username:e,password:t})}),r=await n.json().catch(()=>({}));return n.ok?{user:r.user}:{error:r.error??`login failed (${n.status})`}}async function qp(e){let t=await X(`/api/auth/register`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),n=await t.json().catch(()=>({}));return t.ok?{user:n.user,publicKey:n.publicKey,personalRepo:n.personalRepo??null,needsImport:!!n.needsImport}:{error:n.error??`register failed (${t.status})`}}async function Jp(e){let t=await X(`/api/personal/repos`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({token:e})}),n=await t.json().catch(()=>({}));return t.ok?{ok:n.ok!==!1,repos:Array.isArray(n.repos)?n.repos:[],login:n.login,error:n.error}:{ok:!1,repos:[],error:n?.error??`request failed`}}async function Yp(){let e=await X(`/api/personal/status`);return e.ok?await e.json():null}async function Xp(e){let t=await X(`/api/personal/crypt-key`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({password:e})}),n=await t.json().catch(()=>({}));return t.ok?typeof n.cryptKey==`string`?{ok:!0,cryptKey:n.cryptKey}:{ok:!1,error:`missing cryptKey in response`}:{ok:!1,error:n.error??`request failed (${t.status})`,wrongPassword:t.status===403}}async function Zp(e,t=!1){let n=await X(`/api/personal/delete`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({password:e,force:t})}),r=await n.json().catch(()=>({}));return n.ok?{ok:!0,synced:r.synced,dataLost:r.dataLost}:{ok:!1,error:r.error??`delete failed (${n.status})`,wrongPassword:n.status===403,syncFailed:r.syncFailed,uncommitted:r.uncommitted,unpushed:r.unpushed,hasRemote:r.hasRemote}}async function Qp(e){let t=await X(`/api/personal/pull`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({force:e?.force??!1})}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0,message:n.message}:{ok:!1,error:n.error??`pull failed (${t.status})`,conflict:n.conflict,files:n.files,needsStash:n.needsStash}}async function $p(){let e=await X(`/api/personal/push`,{method:`POST`}),t=await e.json().catch(()=>({}));return e.ok?{ok:!0,message:t.message}:{ok:!1,error:t.error??`push failed (${e.status})`,conflict:t.conflict,files:t.files,needsPull:t.needsPull}}async function em(e,t){let n={};e&&(n.repoUrl=e),t&&(n.cryptKey=t);let r=await X(`/api/personal/import`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}),i=await r.json().catch(()=>({}));return r.ok?{ok:!0,autoInitialized:!!i.autoInitialized,cryptKey:typeof i.cryptKey==`string`?i.cryptKey:null}:{ok:!1,error:i.error??`import failed (${r.status})`,needsCryptKey:!!i.needsCryptKey,notClean:!!i.notClean,secretsExposed:!!i.secretsExposed,exposedFiles:Array.isArray(i.exposedFiles)?i.exposedFiles:[]}}async function tm(e,t,n,r){let i={token:e};t&&(i.repoName=t),n&&(i.cryptKey=n),r&&(i.baseUrl=r);let a=await X(`/api/personal/github`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(i)}),o=await a.json().catch(()=>({}));return a.ok?{ok:!0,repo:typeof o.repo==`string`?o.repo:void 0,created:!!o.created,autoInitialized:!!o.autoInitialized,cryptKey:typeof o.cryptKey==`string`?o.cryptKey:null}:{ok:!1,error:o.error??`github setup failed (${a.status})`,needsCryptKey:!!o.needsCryptKey}}async function nm(){await X(`/api/auth/logout`,{method:`POST`}).catch(()=>{})}async function rm(e=`active`){let t=await X(`/api/loops`+(e===`all`?`?archived=all`:e===`archived`?`?archived=true`:``));return t.ok?(await t.json()).loops:[]}async function im(e){if(e.knowledgeRw||e.mountAllLoops){let t={title:e.title,repo:e.repo,profiles:e.profiles,vault:e.vault};return e.knowledgeRw&&(t.knowledge_rw=!0),e.mountAllLoops&&(t.mount_all_loops=!0),await(await X(`/api/loops`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)})).json()}let t=await X(`/api/v1/loops`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({title:e.title,profiles:e.profiles,vault:e.vault,repo:e.repo})});if(!t.ok)throw Error(`createLoop failed (${t.status})`);let n=await t.json();return{id:n.id.startsWith(`loop_`)?n.id.slice(5):n.id,title:n.title,createdAt:n.created_at,createdBy:n.created_by,archived:n.archived,repo:n.repo??void 0,config:{profiles:n.profiles,vault:n.vault}}}async function am(){let e=await X(`/api/profiles`);return e.ok?(await e.json()).profiles??[]:[]}async function om(){let e=await X(`/api/personal/default-profiles`);if(!e.ok)return[];let t=await e.json();return Array.isArray(t.default_profiles)?t.default_profiles:[]}async function sm(e){let t=await X(`/api/loop-stats?profiles=${encodeURIComponent(e.join(`,`))}`);return t.ok?await t.json():null}async function cm(){let e=await X(`/api/vaults`);if(!e.ok)return[];let t=await e.json();return Array.isArray(t.vaults)?t.vaults:[]}async function lm(e){return(await X(`/api/loops/${e}/viewed`,{method:`POST`})).ok}async function um(e,t){let n=await X(`/api/loops/${e}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({archived:t})});return n.ok?await n.json():null}async function dm(e,t){let n=await X(`/api/loops/${e}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({public:t})});return n.ok?await n.json():null}async function fm(e,t){let n=await X(`/api/loops/${e}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({title:t})});return n.ok?await n.json():null}async function pm(e){let t=await X(`/api/loops/${e}/request-drive`,{method:`POST`});return t.ok?await t.json():null}async function mm(e){let t=await X(`/api/loops/${e}/drive`,{method:`POST`});return t.ok?await t.json():null}async function hm(e){let t=await X(`/api/loops/${e}/distill`,{method:`POST`});return t.ok?await t.json():null}async function gm(e){let t=await X(`/api/loops/${e}`);return t.ok?await t.json():null}async function _m(e){let t=await X(`/api/loops/${e}/strip-thinking`,{method:`POST`});return t.ok?await t.json():{stripped:0,sessionsTouched:0}}async function vm(e,t=``){return(await(await X(`/api/loops/${e}/files?path=${encodeURIComponent(t)}`)).json()).entries??[]}async function ym(e,t=``){return(await(await X(`/api/loops/${e}/files/tree?path=${encodeURIComponent(t)}`)).json()).entries??[]}async function bm(e,t){let n=await X(`/api/loops/${e}/file?path=${encodeURIComponent(t)}`);return n.ok?await n.json():null}async function xm(e,t,n){return(await X(`/api/loops/${e}/file?path=${encodeURIComponent(t)}`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({content:n})})).ok}async function Sm(e,t){return(await X(`/api/loops/${e}/file?path=${encodeURIComponent(t)}`,{method:`DELETE`})).ok}async function Cm(e,t){return(await X(`/api/loops/${e}/folder`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:t})})).ok}async function wm(e,t){let n=new FormData;n.append(`file`,t);let r=await X(`/api/loops/${e}/upload`,{method:`POST`,body:n}),i=await r.json().catch(()=>({}));return r.ok?{ok:!0,path:i.path}:{ok:!1,error:i.error??`upload failed`}}async function Tm(e){let t=await X(`/api/loops/${e}/context`);return t.ok?(await t.json()).mounts??[]:[]}async function Em(e,t=``){let n=await X(`/api/workspace/files?vault=${e}&path=${encodeURIComponent(t)}`);return n.ok?(await n.json()).entries??[]:[]}async function Dm(e){let t=await X(`/api/workspace/files?vault=${e}&flat=1`);return t.ok?(await t.json()).entries??[]:[]}async function Om(e,t){let n=await X(`/api/workspace/file?vault=${e}&path=${encodeURIComponent(t)}`);return n.ok?await n.json():null}async function km(e,t,n){return await(await X(`/api/workspace/file?vault=${e}&path=${encodeURIComponent(t)}`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({content:n})})).json()}async function Am(){let e=await X(`/api/notes/save`,{method:`POST`}),t=await e.json().catch(()=>({}));return e.ok?{ok:!0,message:t.message}:{ok:!1,conflict:t.conflict,files:t.files,needsPull:t.needsPull,error:t.error??`save failed (${e.status})`}}async function jm(){let e=await(await X(`/api/notes/behind`)).json().catch(()=>({}));return typeof e.behind==`number`?e.behind:0}async function Mm(){let e=await(await X(`/api/notes/refresh`,{method:`POST`})).json().catch(()=>({}));return{ok:!!e.ok,diverged:e.diverged,error:e.error}}async function Nm(e,t){return await(await X(`/api/workspace/file?vault=${e}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:t})})).json()}async function Pm(e,t){return await(await X(`/api/workspace/folder?vault=${e}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:t})})).json()}async function Fm(e,t){return await(await X(`/api/workspace/file?vault=${e}&path=${encodeURIComponent(t)}`,{method:`DELETE`})).json()}async function Im(e,t){let n=await X(`/api/workspace/backlinks?vault=${e}&path=${encodeURIComponent(t)}`);return n.ok?(await n.json()).backlinks??[]:[]}async function Lm(){let e=await X(`/api/context/repos`);if(!e.ok)return{notes:null,repos:[]};let t=await e.json();return{notes:t.notes??null,repos:t.repos??[]}}async function Rm(e){let t=await X(`/api/context/repos`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0}:{ok:!1,error:n.error??`http ${t.status}`,savedLocally:n.savedLocally}}async function zm(e){let t=await X(`/api/loops/${e}/chat-history`);return t.ok?(await t.json()).map(e=>e.text):[]}async function Bm(e,t){await X(`/api/loops/${e}/chat-history`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({text:t})})}function Vm(e){return typeof e==`string`?`/api/sync/${e}`:`/api/sync/repos/${encodeURIComponent(e.repo)}`}async function Hm(e){let t=await X(`${Vm(e)}/status`);return t.ok?await t.json():null}async function Um(e){let t=await X(`${Vm(e)}/pull`,{method:`POST`}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0,message:n.message}:{ok:!1,error:n.error??`http ${t.status}`}}async function Wm(e){let t=await X(`${Vm(e)}/push`,{method:`POST`}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0,message:n.message}:{ok:!1,error:n.error??`http ${t.status}`}}async function Gm(e=`default`){let t=await X(`/api/kanban/${encodeURIComponent(e)}`);return t.ok?(await t.json()).columns:[]}async function Km(e,t,n){let r=await X(`/api/kanban/columns/${encodeURIComponent(e)}/${encodeURIComponent(t)}/cards`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}),i=await r.json().catch(()=>({}));return r.ok?{cid:i.cid}:{error:i.error??`add failed`}}async function qm(e,t,n){return(await X(`/api/kanban/columns/${encodeURIComponent(e)}/${encodeURIComponent(t)}/cards/${encodeURIComponent(n)}/toggle`,{method:`PATCH`})).ok}async function Jm(e,t,n,r){return(await X(`/api/kanban/columns/${encodeURIComponent(e)}/${encodeURIComponent(t)}/cards/${encodeURIComponent(n)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(r)})).ok}async function Ym(e,t,n,r){return(await X(`/api/kanban/columns/${encodeURIComponent(e)}/${encodeURIComponent(t)}/cards/${encodeURIComponent(n)}/block`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({block:r})})).ok}async function Xm(e,t,n){return(await X(`/api/kanban/columns/${encodeURIComponent(e)}/${encodeURIComponent(t)}/cards/${encodeURIComponent(n)}`,{method:`DELETE`})).ok}async function Zm(e,t,n,r,i){return(await X(`/api/kanban/columns/${encodeURIComponent(e)}/${encodeURIComponent(t)}/cards/${encodeURIComponent(n)}/move`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({toFile:r,toIndex:i})})).ok}async function Qm(e,t,n){return(await X(`/api/kanban/columns/${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({filename:t,title:n})})).ok}async function $m(){let e=await X(`/api/kanban/boards`);return e.ok?(await e.json()).boards:[`default`]}async function eh(e){return(await X(`/api/kanban/boards`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:e})})).ok}async function th(e,t){return(await X(`/api/kanban/boards/${encodeURIComponent(e)}/rename`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({name:t})})).ok}async function nh(e=`default`){let t=await X(`/api/kanban/config/${encodeURIComponent(e)}`);return t.ok?(await t.json()).columns:[]}async function rh(e,t){return(await X(`/api/kanban/config/${encodeURIComponent(e)}`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({columns:t})})).ok}async function ih(e,t,n){return(await X(`/api/kanban/columns/${encodeURIComponent(e)}/${encodeURIComponent(t)}/rename`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({toFile:n})})).ok}async function ah(e,t){return(await X(`/api/kanban/columns/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`DELETE`})).ok}async function oh(e,t,n){return(await X(`/api/kanban/columns/${encodeURIComponent(e)}/${encodeURIComponent(t)}/color`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({color:n})})).ok}async function sh(e,t,n){return(await X(`/api/kanban/columns/${encodeURIComponent(e)}/${encodeURIComponent(t)}/reorder`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({cids:n})})).ok}async function ch(e,t,n){let r=await X(`/api/kanban/columns/${encodeURIComponent(e)}/${encodeURIComponent(t)}/cards/${encodeURIComponent(n)}/assign-driver`,{method:`POST`});return r.ok?await r.json():{ok:!1}}async function lh(e,t,n,r){return(await X(`/api/kanban/columns/${encodeURIComponent(e)}/${encodeURIComponent(t)}/cards/${encodeURIComponent(n)}/link-loop`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({loopId:r})})).ok}async function uh(){let e=await X(`/api/topics`);return e.ok?(await e.json()).topics:[]}async function dh(){let e=await X(`/api/providers`);return e.ok?await e.json():{providers:{},default:``}}async function fh(e,t,n,r,i){let a={baseUrl:e,model:n};t?a.apiKey=t:r&&i&&(a.provider=r,a.source=i);let o=await X(`/api/providers/test`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(a)}),s=await o.json().catch(()=>({}));return o.ok?s:{ok:!1,error:s.error??`test failed (${o.status})`}}async function ph(){let e=await X(`/api/version`);return e.ok?await e.json():{branch:`unknown`,commit:`unknown`}}async function mh(){let e=await X(`/api/admin/system`);return e.ok?await e.json():null}async function hh(){return await(await X(`/api/admin/system/check`,{method:`POST`})).json()}async function gh(){return await(await X(`/api/admin/system/pull`,{method:`POST`})).json()}function _h(){return{commit:`1d6260dd9aef84f5426843e2a222913becbc2e9b`,time:`2026-06-01T06:13:23.043Z`}}async function vh(e){let t=await X(`/api/loops/${e}/git-status`);return t.ok?await t.json():{unstaged:[],staged:[]}}async function yh(e,t,n){let r=await X(`/api/loops/${e}/git-diff?path=${encodeURIComponent(t)}&staged=${n?`1`:`0`}`);return r.ok?(await r.json()).diff??null:null}async function bh(e,t,n=!1){return(await X(`/api/loops/${e}/git-stage`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({files:t,unstage:n})})).ok}async function xh(e,t){return(await X(`/api/loops/${e}/git-discard`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({file:t})})).ok}async function Sh(e,t){let n=await X(`/api/loops/${e}/git-commit`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:t})}),r=await n.json().catch(()=>({}));return n.ok?{ok:!0}:{ok:!1,error:r.error??`commit failed`}}async function Ch(e,t=50){let n=await X(`/api/loops/${e}/git-log?limit=${t}`);return n.ok?(await n.json()).commits??[]:[]}async function wh(){let e=await X(`/api/settings/personal/disk`);return e.ok?await e.json():null}async function Th(e){let t=await X(`/api/settings/personal/disk`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0}:{ok:!1,error:n.error??`save failed (${t.status})`}}async function Eh(e,t,n=`default`){let r=await X(`/api/settings/personal/value`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:e,value:t,vault:n})}),i=await r.json().catch(()=>({}));return r.ok?{ok:!0}:{ok:!1,error:i.error??`write failed (${r.status})`}}async function Dh(){return await(await X(`/api/settings/workspace`)).json()}async function Oh(e){return(await X(`/api/settings/workspace`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(e)})).ok}async function kh(){let e=await X(`/api/settings/token-usage/daily`);return e.ok?await e.json():{}}async function Ah(){let e=await X(`/api/settings/token-usage/loops`);return e.ok?await e.json():[]}async function jh(){let e=await X(`/api/admin/presets`);return e.ok?await e.json():{providerPresets:[],miseToolPresets:[]}}async function Mh(e){return(await X(`/api/admin/presets`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(e)})).ok}async function Nh(){let e=await X(`/api/admin/users`);return e.ok?(await e.json()).users??[]:[]}async function Ph(e){let t=await X(`/api/admin/users/${encodeURIComponent(e)}/activate`,{method:`POST`}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0}:{ok:!1,error:n.error??`activate failed (${t.status})`}}async function Fh(e,t){let n=await X(`/api/admin/users/${encodeURIComponent(e)}/role`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({role:t})}),r=await n.json().catch(()=>({}));return n.ok?{ok:!0}:{ok:!1,error:r.error??`role change failed (${n.status})`}}async function Ih(e){let t=await X(`/api/admin/users/${encodeURIComponent(e)}`,{method:`DELETE`}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0}:{ok:!1,error:n.error??`delete failed (${t.status})`}}async function Lh(){let e=await X(`/api/serve/config`);return e.ok?await e.json():{serveEnabled:!0,domain:`nip.io`,ip:`127.0.0.1`,baseUrl:`.127.0.0.1.nip.io`,withPort:!1,https:!1,displayPort:7788,serveDynamicEnabled:!1,serveDynamicDomain:``,serveDynamicPortRange:`10000-20000`,serveDynamicUdpEnabled:!1,serveDynamicStaticEnabled:!1,serveEphemeralEnabled:!1,serveEphemeralDomain:``}}async function Rh(e){let t=await X(`/api/loops/${e}/share/current-port`);return t.ok?await t.json():{port:null}}async function zh(e){return(await X(`/api/serve/config`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(e)})).ok}async function Bh(){let e=await X(`/api/serve/available-port`);return e.ok?await e.json():{port:null,error:`request failed`}}async function Vh(e,t){let n=await X(`/api/serve/check-port?port=${e}&loopId=${t||``}`);return n.ok?await n.json():{available:!1,reason:`request failed`}}async function Hh(e,t){let n=new URLSearchParams({alias:e});t&&n.set(`loopId`,t);let r=await X(`/api/serve/alias-check?${n}`);return r.ok?await r.json():{available:!1,reason:`check failed`}}async function Uh(){let e=await X(`/api/chat/conversations`);return e.ok?(await e.json()).conversations??[]:[]}async function Wh(){let e=await X(`/api/chat/users`);return e.ok?(await e.json()).users??[]:[]}async function Gh(e,t){let n=await X(`/api/chat/channels`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:e,topic:t})}),r=await n.json().catch(()=>({}));return n.ok?{conv:r.conv}:{error:r.error??`create failed (${n.status})`}}async function Kh(e){let t=await X(`/api/chat/channels/${encodeURIComponent(e)}`,{method:`DELETE`}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0}:{ok:!1,error:n.error??`delete failed (${t.status})`}}async function qh(e){let t=await X(`/api/chat/dm/${encodeURIComponent(e)}`,{method:`POST`}),n=await t.json().catch(()=>({}));return t.ok?{conv:n.conv}:{error:n.error??`open DM failed (${t.status})`}}async function Jh(e,t={}){let n=new URLSearchParams;t.before&&n.set(`before`,String(t.before)),t.limit&&n.set(`limit`,String(t.limit));let r=await X(`/api/chat/conversations/${encodeURIComponent(e)}/messages?${n.toString()}`);return r.ok?(await r.json()).messages??[]:[]}async function Yh(e){let t=await X(`/api/chat/threads/${e}`);return t.ok?await t.json():null}async function Xh(e,t,n=null){let r=await X(`/api/chat/conversations/${encodeURIComponent(e)}/messages`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n==null?{text:t}:{text:t,parentId:n})}),i=await r.json().catch(()=>({}));return r.ok?{message:i.message}:{error:i.error??`send failed (${r.status})`}}async function Zh(e,t){return(await X(`/api/chat/conversations/${encodeURIComponent(e)}/read`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({lastReadId:t})})).ok}async function Qh(e,t){let n=await X(`/api/chat/threads/${e}/spawn-loop`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t?{title:t}:{})}),r=await n.json().catch(()=>({}));return n.ok?{loopId:r.loopId,seedPrompt:r.seedPrompt,messageCount:r.messageCount}:{error:r.error??`spawn failed (${n.status})`}}async function $h(e){let t=await X(`/api/mcp-servers${e?`?loopId=${encodeURIComponent(e)}`:``}`);return t.ok?await t.json():{servers:[]}}async function eg(e,t){let n=await X(`/api/mcp-auth/start`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({serverName:e,loopId:t})}),r=await n.json().catch(()=>({}));return n.ok?{authorizationUrl:r.authorizationUrl}:{error:r.error??`start failed`}}async function tg(e){return(await X(`/api/envs/${encodeURIComponent(e)}`,{method:`DELETE`})).ok}async function ng(e){let t=await X(`/api/loops/${encodeURIComponent(e)}/restart-session`,{method:`POST`}),n=await t.json().catch(()=>({}));return t.ok?{restarted:!!n.restarted}:{restarted:!1,error:n.error??`restart failed (${t.status})`}}async function rg(){let e=await X(`/api/tiers`);return e.ok?await e.json():null}async function ig(e,t){let n=await X(`/api/tiers/${encodeURIComponent(e)}/settings`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),r=await n.json().catch(()=>({}));return n.ok?{ok:!0}:{ok:!1,error:r.error??`save failed (${n.status})`}}async function ag(e){let t=await X(`/api/tiers/${encodeURIComponent(e)}/mise-config`);return t.ok?await t.json():{content:``,exists:!1,error:`fetch failed (${t.status})`}}async function og(e,t){let n=await X(`/api/tiers/${encodeURIComponent(e)}/mise-config`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({content:t})}),r=await n.json().catch(()=>({}));return n.ok?{ok:!0}:{ok:!1,error:r.error??`save failed (${n.status})`}}async function sg(){let e=await X(`/api/plugins/available`);return e.ok?(await e.json()).plugins??[]:[]}async function cg(){let e=await X(`/api/plugins/browse`);return e.ok?(await e.json()).plugins??[]:[]}async function lg(){let e=await X(`/api/marketplaces`);return e.ok?(await e.json()).marketplaces??[]:[]}async function ug(){let e=await X(`/api/plugins/refresh`,{method:`POST`}),t=await e.json().catch(()=>({}));return e.ok?{ok:!0,added:t.added}:{ok:!1,error:t.error??`refresh failed (${e.status})`}}async function dg(e){let t=await X(`/api/admin/profiles`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:e})}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0}:{ok:!1,error:n.error??`create failed (${t.status})`}}async function fg(e){let t=await X(`/api/admin/profiles/${encodeURIComponent(e)}`,{method:`DELETE`}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0}:{ok:!1,error:n.error??`delete failed (${t.status})`}}async function pg(){let e=await X(`/api/v1/me/tokens`);return e.ok?(await e.json().catch(()=>({tokens:[]}))).tokens??[]:[]}async function mg(e){let t=await X(`/api/v1/me/tokens`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({label:e})});return t.ok?await t.json().catch(()=>null):null}async function hg(e){return(await X(`/api/v1/me/tokens/${encodeURIComponent(e)}`,{method:`DELETE`})).ok}function gg(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)(!0),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(!0),g=(0,_.useCallback)(async()=>{r(!0),t(await rm(i?`all`:`active`)),r(!1)},[i]);(0,_.useEffect)(()=>{let e=!1;return Gp().then(t=>{e||(p(t),h(!1))}),()=>{e=!0}},[]),(0,_.useEffect)(()=>{g()},[i,f]);let v=(0,_.useCallback)(async e=>{let n=await im(e);return t(e=>[n,...e]),n},[]),y=(0,_.useCallback)(async(e,n)=>{let r=await um(e,n);r&&t(t=>!i&&r.archived?t.filter(t=>t.id!==e):t.map(t=>t.id===e?r:t))},[i]),b=(0,_.useCallback)(async(e,n)=>{let r=await dm(e,n);r&&t(t=>t.map(t=>t.id===e?r:t))},[]),x=(0,_.useCallback)(async(e,n)=>{let r=await fm(e,n);return r?(t(t=>t.map(t=>t.id===e?r:t)),r):null},[]),S=(0,_.useCallback)(async e=>{let n=await pm(e);n&&t(t=>t.map(t=>t.id===e?n:t))},[]),C=(0,_.useCallback)(async e=>{let n=await mm(e);n&&t(t=>t.map(t=>t.id===e?n:t))},[]),w=(0,_.useCallback)(async(e,t)=>{let n=await Kp(e,t);return n.user&&p(n.user),{error:n.error}},[]),T=(0,_.useCallback)(async e=>{let t=await qp(e);return t.user&&t.user.status===`active`&&p(t.user),{error:t.error,user:t.user,publicKey:t.publicKey,personalRepo:t.personalRepo,needsImport:t.needsImport}},[]),E=(0,_.useCallback)(async()=>{await nm(),p(null)},[]);return{loops:e,loopsLoading:n,showArchived:i,setShowArchived:a,refresh:g,createLoop:v,setLoopArchived:y,setLoopPublic:b,setLoopTitle:x,requestDrive:S,takeDrive:C,newLoopDialogOpen:o,newLoopDialogTitle:c,kanbanCreateCtx:u,setNewLoopDialogOpen:(0,_.useCallback)((e,t,n)=>{s(e),l(t??``),d(n??null)},[]),currentUser:f,authLoading:m,login:w,register:T,logout:E}}var _g=(0,_.createContext)(null);function vg(){let e=(0,_.useContext)(_g);if(!e)throw Error(`useWorkspace outside provider`);return e}function yg({onClose:e,onCreate:t,initialTitle:n}){let[r,i]=(0,_.useState)(n??``),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(new Set),[l,u]=(0,_.useState)([]),[d,f]=(0,_.useState)(`default`),[p,m]=(0,_.useState)([]),[h,g]=(0,_.useState)([]),[v,y]=(0,_.useState)([]),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(!1),[w,T]=(0,_.useState)(!1),E=(0,_.useRef)(null);(0,_.useEffect)(()=>{Lm().then(e=>m(e.repos)),Promise.all([am(),om()]).then(([e,t])=>{g(e),u(t);let n=new Set(e.map(e=>e.name));c(new Set(t.filter(e=>n.has(e)&&e!==`base`)))}),cm().then(e=>{y(e),e.includes(`default`)?f(`default`):e.length>0&&f(e[0])}),E.current?.focus()},[]);function D(){let e=new Set(h.map(e=>e.name));c(new Set(l.filter(t=>e.has(t)&&t!==`base`)))}(0,_.useEffect)(()=>{C(!0);let e=setTimeout(()=>{sm([...s]).then(x).finally(()=>C(!1))},120);return()=>clearTimeout(e)},[s]);let O=(()=>{let e=new Set(l.filter(e=>e!==`base`));if(e.size!==s.size)return!0;for(let t of e)if(!s.has(t))return!0;return!1})(),k=h.find(e=>e.name===`base`),A=h.filter(e=>e.name!==`base`);function j(e){c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/30 flex items-center justify-center`,onClick:e,children:(0,G.jsxs)(`div`,{className:`w-full max-w-[480px] mx-4 bg-white rounded-md shadow-xl border border-gray-200 p-4 md:p-5 max-h-[85vh] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(`div`,{className:`text-base font-semibold text-gray-900 mb-4`,children:`New loop`}),(0,G.jsxs)(`form`,{onSubmit:async e=>{if(e.preventDefault(),!w){T(!0);try{await t({title:r.trim()||`untitled`,repo:a||void 0,profiles:s.size>0?[...s]:void 0,vault:d||void 0})}finally{T(!1)}}},className:`flex flex-col gap-4`,children:[(0,G.jsxs)(bg,{label:`Repo`,hint:`Sets the workdir. Optional — leave (none) for an empty workdir.`,children:[(0,G.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value),className:`w-full px-2 py-1.5 text-sm border border-gray-300 rounded outline-none focus:border-gray-500 bg-white`,children:[(0,G.jsx)(`option`,{value:``,children:`(none — empty workdir)`}),p.map(e=>(0,G.jsxs)(`option`,{value:e.name,children:[e.name,e.git?` · ${e.git}`:``]},e.name))]}),p.length===0&&(0,G.jsx)(`div`,{className:`text-[11px] text-gray-400 mt-1`,children:`No repos in the roster. Add them on the Context → Repos page.`})]}),(0,G.jsxs)(bg,{label:`Profiles`,hint:`Each profile contributes plugins + a CLAUDE.md fragment. Empty = base + personal only.`,children:[(0,G.jsxs)(`div`,{className:`border border-gray-300 rounded p-2 max-h-44 overflow-y-auto bg-white flex flex-col gap-1`,children:[k&&(0,G.jsxs)(`label`,{className:`flex items-start gap-2 px-1.5 py-1 rounded text-sm text-gray-500 cursor-not-allowed bg-gray-50`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!0,disabled:!0,className:`mt-0.5`}),(0,G.jsxs)(`span`,{className:`flex-1`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:`base`}),(0,G.jsx)(`span`,{className:`ml-1 text-[11px] text-gray-400`,children:`(always on)`}),k.description&&(0,G.jsx)(`span`,{className:`block text-[11px] text-gray-400 mt-0.5`,children:k.description})]})]}),A.map(e=>{let t=s.has(e.name),n=l.includes(e.name);return(0,G.jsxs)(`label`,{className:`flex items-start gap-2 px-1.5 py-1 rounded text-sm cursor-pointer hover:bg-gray-50 ${t?`bg-blue-50`:``}`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:t,onChange:()=>j(e.name),className:`mt-0.5`}),(0,G.jsxs)(`span`,{className:`flex-1`,children:[(0,G.jsx)(`span`,{className:`font-medium text-gray-900`,children:e.name}),n&&(0,G.jsx)(`span`,{className:`ml-1.5 px-1 py-px text-[10px] rounded bg-gray-200 text-gray-600`,title:`In your default_profiles (personal config)`,children:`default`}),e.description&&(0,G.jsx)(`span`,{className:`block text-[11px] text-gray-500 mt-0.5`,children:e.description})]})]},e.name)}),A.length===0&&!k&&(0,G.jsxs)(`div`,{className:`text-[11px] text-gray-400 p-1.5`,children:[`No profiles in workspace. Create directories under`,` `,(0,G.jsx)(`code`,{className:`bg-gray-100 px-1 rounded`,children:`context/profiles/<name>/`}),` with a profile.json.`]})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between mt-1`,children:[(0,G.jsx)(`span`,{className:`text-[11px] text-gray-500`,children:s.size>0?`Selected: ${[...s].join(`, `)}`:`No profiles selected (base + personal only)`}),O&&l.length>0&&(0,G.jsx)(`button`,{type:`button`,onClick:D,className:`text-[11px] text-gray-500 hover:text-gray-900 underline`,title:`Restore default_profiles from your personal config`,children:`reset to defaults`})]}),(0,G.jsx)(`div`,{className:`mt-1.5 px-1.5 py-1 text-[11px] text-gray-600 bg-gray-50 border border-gray-200 rounded`,children:S&&!b?(0,G.jsx)(`span`,{className:`text-gray-400`,children:`computing…`}):b?(0,G.jsxs)(`span`,{title:`Totals across team + selected profiles + their plugins (deduped by name)`,children:[(0,G.jsxs)(`span`,{className:b.plugins>0?``:`text-gray-400`,children:[b.plugins,` plugins`]}),(0,G.jsx)(`span`,{className:`mx-1 text-gray-300`,children:`·`}),(0,G.jsxs)(`span`,{className:b.skills>0?``:`text-gray-400`,children:[b.skills,` skills`]}),(0,G.jsx)(`span`,{className:`mx-1 text-gray-300`,children:`·`}),(0,G.jsxs)(`span`,{className:b.agents>0?``:`text-gray-400`,children:[b.agents,` agents`]}),(0,G.jsx)(`span`,{className:`mx-1 text-gray-300`,children:`·`}),(0,G.jsxs)(`span`,{className:b.hooks>0?``:`text-gray-400`,children:[b.hooks,` hooks`]}),(0,G.jsx)(`span`,{className:`mx-1 text-gray-300`,children:`·`}),(0,G.jsxs)(`span`,{className:b.mcpServers>0?``:`text-gray-400`,children:[b.mcpServers,` MCP servers`]}),(0,G.jsx)(`span`,{className:`mx-1 text-gray-300`,children:`·`}),(0,G.jsxs)(`span`,{className:b.toolchain>0?``:`text-gray-400`,title:`mise.toml [tools] entries, deduped across team + selected profiles`,children:[b.toolchain,` toolchain`]}),S&&(0,G.jsx)(`span`,{className:`ml-1.5 text-gray-400`,children:`·`}),S&&(0,G.jsx)(`span`,{className:`ml-1 text-gray-400`,children:`updating…`})]}):(0,G.jsx)(`span`,{className:`text-gray-400`,children:`—`})})]}),(0,G.jsxs)(bg,{label:`Vault`,hint:`Which credential set to inject. Only this vault is visible inside the loop.`,children:[(0,G.jsxs)(`select`,{value:d,onChange:e=>f(e.target.value),className:`w-full px-2 py-1.5 text-sm border border-gray-300 rounded outline-none focus:border-gray-500 bg-white`,children:[v.length===0&&(0,G.jsx)(`option`,{value:`default`,children:`default`}),v.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))]}),v.length===0&&(0,G.jsxs)(`div`,{className:`text-[11px] text-gray-400 mt-1`,children:[`No vaults yet — using default. Create more under`,` `,(0,G.jsx)(`code`,{className:`bg-gray-100 px-1 rounded`,children:`personal/.loopat/vaults/<name>/`}),` `,`to isolate prod / test credentials.`]})]}),(0,G.jsx)(bg,{label:`Name`,hint:`Optional — defaults to 'untitled'.`,children:(0,G.jsx)(`input`,{ref:E,type:`text`,value:r,onChange:e=>i(e.target.value),placeholder:`refactor-gateway`,className:`w-full px-2 py-1.5 text-sm border border-gray-300 rounded outline-none focus:border-gray-500`})}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2 mt-2 pt-3 border-t border-gray-100`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:e,className:`px-3 h-8 text-sm rounded text-gray-700 hover:bg-gray-100`,children:`cancel`}),(0,G.jsx)(`button`,{type:`submit`,disabled:w,className:`px-3 h-8 text-sm rounded bg-gray-900 text-white hover:bg-gray-700 disabled:opacity-50`,children:w?`creating…`:`create`})]})]})]})})}function bg({label:e,hint:t,children:n}){return(0,G.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`text-xs text-gray-700 font-medium`,children:e}),n,t&&(0,G.jsx)(`span`,{className:`text-[11px] text-gray-400`,children:t})]})}var xg=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,Sg=ff,Cg=((e,t)=>n=>{if(t?.variants==null)return Sg(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=xg(t)||xg(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return Sg(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)})(`inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 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/90`,destructive:`bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40`,outline:`border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3`,xs:`h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5`,lg:`h-10 rounded-md px-6 has-[>svg]:px-4`,icon:`size-9`,"icon-xs":`size-6 rounded-md [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-8`,"icon-lg":`size-10`}},defaultVariants:{variant:`default`,size:`default`}});function wg({className:e,variant:t=`default`,size:n=`default`,asChild:r=!1,...i}){return(0,G.jsx)(r?Ni:`button`,{"data-slot":`button`,"data-variant":t,"data-size":n,className:Y(Cg({variant:t,size:n,className:e})),...i})}function Tg({...e}){return(0,G.jsx)(nc,{"data-slot":`dialog`,...e})}function Eg({...e}){return(0,G.jsx)(rc,{"data-slot":`dialog-portal`,...e})}function Dg({className:e,...t}){return(0,G.jsx)(ic,{"data-slot":`dialog-overlay`,className:Y(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function Og({className:e,children:t,showCloseButton:n=!0,...r}){return(0,G.jsxs)(Eg,{"data-slot":`dialog-portal`,children:[(0,G.jsx)(Dg,{}),(0,G.jsxs)(ac,{"data-slot":`dialog-content`,className:Y(`fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-white p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg`,e),...r,children:[t,n&&(0,G.jsxs)(cc,{"data-slot":`dialog-close`,className:`absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,G.jsx)(ut,{}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function kg({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`dialog-header`,className:Y(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function Ag({className:e,...t}){return(0,G.jsx)(oc,{"data-slot":`dialog-title`,className:Y(`text-lg leading-none font-semibold`,e),...t})}function jg({className:e,...t}){return(0,G.jsx)(sc,{"data-slot":`dialog-description`,className:Y(`text-sm text-muted-foreground`,e),...t})}function Mg({open:e,onClose:t}){let[n,r]=(0,_.useState)({branch:`…`,commit:`…`}),i=_h();return(0,_.useEffect)(()=>{e&&ph().then(e=>r(e))},[e]),(0,G.jsx)(Tg,{open:e,onOpenChange:e=>!e&&t(),children:(0,G.jsxs)(Og,{className:`sm:max-w-sm bg-white`,children:[(0,G.jsx)(kg,{children:(0,G.jsxs)(Ag,{className:`text-center`,children:[(0,G.jsx)(`img`,{src:`/logo.png`,alt:`loopat`,className:`w-full max-w-[240px] mx-auto mb-2`}),`loopat`]})}),(0,G.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,G.jsxs)(`div`,{className:`bg-gray-50 rounded-lg p-3`,children:[(0,G.jsx)(`div`,{className:`text-gray-400 text-xs mb-1`,children:`Server`}),(0,G.jsxs)(`div`,{className:`font-mono text-gray-700`,children:[n.branch,`@`,n.commit.slice(0,7)]})]}),(0,G.jsxs)(`div`,{className:`bg-gray-50 rounded-lg p-3`,children:[(0,G.jsx)(`div`,{className:`text-gray-400 text-xs mb-1`,children:`Build`}),(0,G.jsx)(`div`,{className:`font-mono text-gray-700`,children:i.commit.slice(0,7)}),(0,G.jsx)(`div`,{className:`font-mono text-gray-400 text-xs mt-0.5`,children:new Date(i.time).toLocaleString()})]})]})]})})}function Ng(e,t){let n=e[Pg];if(!n)throw Error(`ResourceElement.type is not a valid Resource`);return n(t)}var Pg=Symbol(`fnSymbol`);function Fg(e){let t=e=>({type:t,props:e});return t[Pg]=e,t}function Ig(e,t){return{...t,key:e}}var Lg=typeof process<`u`&&!1,Rg=null;function zg(e,t){e.currentIndex=0;let n=Rg;Rg=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{Rg=n}}function Bg(){if(!Rg)throw Error(`No resource fiber available`);return Rg}function Vg(e){return Lg?Rg?.devStrictMode?Rg.isFirstRender?`child`:`root`:e?`root`:null:null}var Hg=e=>({version:0,committedVersion:0,dispatchUpdate:e,changelog:[],dirtyCells:[]}),Ug=e=>{for(let t of e.dirtyCells)t.dirty=!1,t.queue.clear(),t.current=t.workInProgress;e.committedVersion=e.version,e.changelog.length=0,e.dirtyCells.length=0},Wg=(e,t)=>{let n=e.version>t;if(e.version=t,n){for(let t of e.dirtyCells)t.dirty=!1,t.queue.clear(),t.workInProgress=t.current;if(e.dirtyCells.length=0,t===e.committedVersion)e.changelog.length=0;else{if(e.committedVersion>t)throw Error(`Version is less than committed version`);for(;e.committedVersion+e.changelog.length>t;)e.changelog.pop();e.changelog.forEach(e=>e()),Ug(e)}}},Gg=(e,t)=>{t.dirty||(t.dirty=!0,e.markDirty?.(),e.root.dirtyCells.push(t))},Kg=(e,t)=>{let n=Bg(),r=n.currentIndex++;if(!n.isFirstRender&&r>=n.cells.length)throw Error(`Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.`);let i=n.cells[r];if(i||(i=t(),n.cells[r]=i),i.type!==e)throw Error(`Hook order changed between renders`);return i},qg=e=>{Bg().renderContext.effectTasks.push(e)},Jg=(e,t)=>{if(e.renderContext)throw Error(`Resource updated during render`);if(e.isNeverMounted)throw Error(`Resource updated before mount`);e.root.dispatchUpdate(()=>{let n=t();return n?(n(),e.root.changelog.push(n),!0):!1})};function Yg(e,t,n,r){let i=Kg(`reducer`,()=>{let t=Bg(),a=r?r(n):n;return Lg&&t.devStrictMode&&r&&r(n),{type:`reducer`,queue:new Set,dirty:!1,workInProgress:a,current:a,reducer:e,dispatch:n=>{let r={action:n,hasEagerState:!1,eagerState:void 0};Jg(t,()=>t.root.dirtyCells.length===0&&!r.hasEagerState&&(r.eagerState=e(i.workInProgress,n),r.hasEagerState=!0,Object.is(i.current,r.eagerState))?null:()=>{Gg(t,i),i.queue.add(r)})}}}),a=Bg(),o=e===i.reducer;i.reducer=e;for(let t of i.queue)(!t.hasEagerState||!o)&&(t.eagerState=e(i.workInProgress,t.action),t.hasEagerState=!0),Lg&&a.devStrictMode&&e(i.workInProgress,t.action),i.workInProgress=t.eagerState;if(i.queue.clear(),t){let e=t(i.workInProgress);Object.is(e,i.workInProgress)||(Gg(a,i),i.workInProgress=e)}return[i.workInProgress,i.dispatch]}function Xg(e,t,n){return Yg(e,void 0,t,n)}function Zg(e,t,n,r){return Yg(e,t,n,r)}var Qg=(e,t)=>typeof t==`function`?t(e):t,$g=e=>typeof e==`function`?e():e;function e_(e){return Xg(Qg,e,$g)}var t_=(e,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},n_=()=>({type:`effect`,cleanup:void 0,deps:null});function r_(e,t){let n=Kg(`effect`,n_);if(!(t&&n.deps&&t_(n.deps,t))){if(n.deps!==null&&!!t!=!!n.deps)throw Error(`tapEffect called with and without dependencies across re-renders`);qg(()=>{let r=[];try{n.cleanup?.()}catch(e){r.push(e)}finally{n.cleanup=void 0}try{let t=e();if(t!==void 0&&typeof t!=`function`)throw Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof t}`);n.cleanup=t}catch(e){r.push(e)}if(n.deps=t,r.length>0){if(r.length===1)throw r[0];for(let e of r)console.error(e);throw AggregateError(r,`Errors during commit`)}})}}function i_(e){let[t]=e_(()=>({current:e}));return t}function a_(e,t){let[n]=e_(e);return n}var o_=()=>{throw Error(`Memo reducer should not be called`)},s_=(e,t)=>{let n=Bg(),[r]=Zg(o_,r=>{if(r&&t_(r.deps,t))return r;let i=e();return Lg&&n.devStrictMode&&e(),{value:i,deps:t}},null);return r.value},c_=(e,t)=>s_(()=>e,t);function l_(e){let t=i_(e);r_(()=>{t.current=e});let n=Bg();return c_(((...e)=>{if(Lg&&n.renderContext)throw Error(`tapEffectEvent cannot be called during render`);return t.current(...e)}),[n])}function u_(e){let t=[];for(let n of e.effectTasks)try{n()}catch(e){t.push(e)}if(t.length>0){if(t.length===1)throw t[0];for(let e of t)console.error(e);throw AggregateError(t,`Errors during commit`)}}function d_(e){let t=[];for(let n of e.cells)if(n?.type===`effect`&&(n.deps=null,n.cleanup))try{n.cleanup?.()}catch(e){t.push(e)}finally{n.cleanup=void 0}if(t.length>0){if(t.length===1)throw t[0];for(let e of t)console.error(e);throw AggregateError(t,`Errors during cleanup`)}}function f_(e,t,n=void 0,r=Vg(!1)){return{type:e,root:t,markDirty:n,devStrictMode:r,cells:[],currentIndex:0,renderContext:void 0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function p_(e){if(!e.isMounted)throw Error(`Tried to unmount a fiber that is already unmounted`);e.isMounted=!1,d_(e)}function m_(e,t){let n={effectTasks:[],props:t,output:void 0};return zg(e,()=>{e.renderContext=n;try{n.output=Ng(e.type,t)}finally{e.renderContext=void 0}}),n}function h_(e,t){e.isMounted=!0,Lg&&e.isNeverMounted&&e.devStrictMode===`root`&&(e.isNeverMounted=!1,u_(t),d_(e)),e.isNeverMounted=!1,u_(t)}function g_(e,t){let n=Bg(),r=i_(0),i=s_(()=>(e.key,f_(e.type,n.root,()=>{r.current++,n.markDirty?.()})),[e.type,e.key,n]),a=t?s_(()=>m_(i,e.props),[i,...t,r.current]):m_(i,e.props);return r_(()=>()=>p_(i),[i]),r_(()=>{h_(i,a)},[i,a]),a.output}function __(e,t){let n=i_(0),r=n.current,i=a_(Bg,[]),a=a_(()=>()=>{n.current++,i.markDirty?.()},[]),o=a_(()=>new Map,[]),s=t?c_(e,t):e,c=s_(()=>{let e=s(),t=new Set,n=[],r=0;for(let s=0;s<e.length;s++){let c=e[s],l=c.key;if(l===void 0)throw Error(`tapResources did not provide a key for array at index ${s}`);if(t.has(l))throw Error(`Duplicate key ${l} in tapResources`);t.add(l);let u=o.get(l);if(!u){let e=f_(c.type,i.root,a),t=m_(e,c.props);u={fiber:e,next:t},r++,o.set(l,u),n.push(t.output)}else if(u.fiber.type!==c.type){let e=f_(c.type,i.root,a),t=m_(e,c.props);u.next=[e,t],n.push(t.output)}else u.next=m_(u.fiber,c.props),n.push(u.next.output)}if(o.size>n.length-r)for(let e of o.keys())t.has(e)||(o.get(e).next=`delete`);return n},[s,r]);return r_(()=>()=>{for(let e of o.keys()){let t=o.get(e).fiber;p_(t)}},[]),r_(()=>{for(let[e,t]of o.entries())t.next===`delete`?(t.fiber.isMounted&&p_(t.fiber),o.delete(e)):Array.isArray(t.next)?(p_(t.fiber),t.fiber=t.next[0],h_(t.fiber,t.next[1])):h_(t.fiber,t.next)},[c]),c}var v_=50,y_={schedulers:new Set([]),isScheduled:!1},b_=class{_task;_isDirty=!1;constructor(e){this._task=e}get isDirty(){return this._isDirty}markDirty(){this._isDirty=!0,y_.schedulers.add(this),x_()}runTask(){this._isDirty=!1,this._task()}},x_=()=>{y_.isScheduled||(y_.isScheduled=!0,C_())},S_=()=>{try{let e=[],t=0;for(let n of y_.schedulers)if(y_.schedulers.delete(n),n.isDirty){if(t++,t>v_)throw Error(`Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside tapEffect.`);try{n.runTask()}catch(t){e.push(t)}}if(e.length>0){if(e.length===1)throw e[0];for(let t of e)console.error(t);throw AggregateError(e,`Errors occurred during flushSync`)}}finally{y_.schedulers.clear(),y_.isScheduled=!1}},C_=(()=>{if(typeof MessageChannel<`u`){let e=new MessageChannel;return e.port1.onmessage=S_,()=>e.port2.postMessage(null)}return()=>setTimeout(S_,0)})(),w_=e=>{let t=y_;y_={schedulers:new Set([]),isScheduled:!0};try{let t=e();return S_(),t}finally{y_=t}},T_=e=>{let t=a_(()=>new b_(()=>l(null)),[]),n=a_(()=>[],[]),r=s_(()=>(e.key,f_(e.type,Hg(e=>{!t.isDirty&&!e()||(n.push(e),t.markDirty())}))),[e.type,e.key]);Wg(r.root,r.root.committedVersion);let i=m_(r,e.props),a=i_(!1),o=i_(e.props),s=i_(i.output),c=a_(()=>new Set,[]),l=l_(e=>{if(e===null&&(Wg(r.root,2),Wg(r.root,1),n.forEach(e=>{Lg&&r.devStrictMode&&e(),e()}),Lg&&r.devStrictMode&&m_(r,o.current),e=m_(r,o.current)),t.isDirty)throw Error(`Scheduler is dirty, this should never happen`);Ug(r.root),n.length=0,a.current&&h_(r,e),!(t.isDirty||s.current===e.output)&&(s.current=e.output,c.forEach(e=>e()))});return r_(()=>(a.current=!0,()=>{a.current=!1,p_(r)}),[r]),r_(()=>{o.current=i.props,Ug(r.root),h_(r,i),!(t.isDirty||s.current===i.output)&&(s.current=i.output,c.forEach(e=>e()))}),s_(()=>({getValue:()=>s.current,subscribe:e=>(c.add(e),()=>c.delete(e))}),[])},E_=Symbol(`tap.Context`),D_=e=>({[E_]:e}),O_=(e,t,n)=>{let r=e[E_];e[E_]=t;try{return n()}finally{e[E_]=r}},k_=e=>e[E_],A_=Fg(()=>{let[e,t]=e_(()=>({renderers:{},fallbacks:[]}));return{getState:()=>e,setDataUI:c_((e,n)=>(t(t=>({...t,renderers:{...t.renderers,[e]:[...t.renderers[e]??[],n]}})),()=>{t(t=>({...t,renderers:{...t.renderers,[e]:t.renderers[e]?.filter(e=>e!==n)??[]}}))}),[]),setFallbackDataUI:c_(e=>(t(t=>({...t,fallbacks:[...t.fallbacks,e]})),()=>{t(t=>({...t,fallbacks:t.fallbacks.filter(t=>t!==e)}))}),[])}}),j_=e=>Array.from(e).map(e=>e.getModelContext()).sort((e,t)=>(t.priority??0)-(e.priority??0)).reduce((e,t)=>{if(t.system&&(e.system?e.system+=`\n\n${t.system}`:e.system=t.system),t.tools)for(let[n,r]of Object.entries(t.tools)){let t=e.tools?.[n];if(t&&t!==r)throw Error(`You tried to define a tool with the name ${n}, but it already exists.`);e.tools||={},e.tools[n]=r}return t.config&&(e.config={...e.config,...t.config}),t.callSettings&&(e.callSettings={...e.callSettings,...t.callSettings}),e},{}),M_=class{_providers=new Set;getModelContext(){return j_(this._providers)}registerModelContextProvider(e){this._providers.add(e);let t=e.subscribe?.(()=>{this.notifySubscribers()});return this.notifySubscribers(),()=>{this._providers.delete(e),t?.(),this.notifySubscribers()}}_subscribers=new Set;notifySubscribers(){for(let e of this._subscribers)e()}subscribe(e){return this._subscribers.add(e),()=>this._subscribers.delete(e)}},N_=[],P_={modelName:void 0,toolNames:N_},F_=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>e===t[n]),I_=(e,t)=>{let n=e.getModelContext(),r=n.config?.modelName,i=n.tools?Object.keys(n.tools).sort():N_,a=i.length?i:N_;return r===t.modelName&&F_(a,t.toolNames)?t:{modelName:r,toolNames:a}},L_=Fg(()=>{let e=s_(()=>new M_,[]),[t,n]=e_(()=>I_(e,P_));return r_(()=>(n(t=>I_(e,t)),e.subscribe(()=>{n(t=>I_(e,t))})),[e]),{getState:()=>I_(e,t),getModelContext:()=>e.getModelContext(),subscribe:t=>e.subscribe(t),register:t=>e.registerModelContextProvider(t)}}),R_=e=>e.display===void 0?e.type===`human`:e.display===`standalone`,z_=Symbol(`assistant-ui.store.clientIndex`),B_=e=>e[z_],V_=D_([]),H_=()=>k_(V_),U_=(e,t)=>{let n=H_();return O_(V_,s_(()=>[...n,e],[n,e]),t)},W_=new Set([`$$typeof`,`nodeType`,`then`]),G_=(e,t)=>{if(e===Symbol.toStringTag)return t;if(typeof e!=`symbol`){if(e===`toJSON`)return()=>t;if(!W_.has(e))return!1}},K_=class{getOwnPropertyDescriptor(e,t){let n=this.get(e,t);if(n!==void 0)return{value:n,writable:!1,enumerable:!0,configurable:!1}}set(){return!1}setPrototypeOf(){return!1}defineProperty(){return!1}deleteProperty(){return!1}preventExtensions(){return!1}},q_=e=>{let t=Fg(e);return e=>{let n=t(e);return e.key===void 0?n:Ig(e.key,n)}},J_=Symbol(`assistant-ui.store.getValue`),Y_=e=>{let t=e[J_];if(!t)throw Error(`Client scope contains a non-client resource. Ensure your Derived get() returns a client created with tapClientResource(), not a plain resource.`);return t.getState?.()},X_=new Map;function Z_(e){let t=X_.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[J_];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 r(...t)},X_.set(e,t)),t}var Q_=class extends K_{outputRef;index;boundFns;cachedReceiver;constructor(e,t){super(),this.outputRef=e,this.index=t}get(e,t,n){if(t===J_)return this.outputRef.current;if(t===z_)return this.index;let r=G_(t,`ClientProxy`);if(r!==!1)return r;let i=this.outputRef.current[t];if(typeof i==`function`){this.cachedReceiver!==n&&(this.boundFns=new Map,this.cachedReceiver=n);let e=this.boundFns.get(t);return e||(e=Z_(t).bind(n),this.boundFns.set(t,e)),e}return i}ownKeys(){return Object.keys(this.outputRef.current)}has(e,t){return t===J_||t===z_?!0:t in this.outputRef.current}},$_=q_(e=>{let t=i_(null),n=H_().length,r=s_(()=>new Proxy({},new Q_(t,n)),[n]),i=U_(r,()=>g_(e));return t.current||=i,r_(()=>{t.current=i}),{methods:r,state:i.getState?.(),key:e.key}}),ev=e=>g_($_(e)),tv=Symbol(`assistant-ui.store.proxiedAssistantState`),nv=e=>e===`on`||e===`subscribe`||typeof e==`symbol`,rv=e=>{class t extends K_{get(t,n){let r=G_(n,`AssistantState`);if(r!==!1)return r;let i=n;if(!nv(i))return Y_(e[i]())}ownKeys(){return Object.keys(e).filter(e=>!nv(e))}has(t,n){return!nv(n)&&n in e}}return new Proxy({},new t)},iv=e=>e[tv],av=()=>()=>{},ov=e=>{let t=(()=>{throw Error(e)});return t.source=null,t.query=null,t},sv=new Proxy({},new class extends K_{get(e,t){if(t===`subscribe`||t===`on`)return av;if(t===tv)return cv;let n=G_(t,`DefaultAssistantClient`);return n===!1?ov(`You are using a component or hook that requires an AuiProvider. Wrap your component in an <AuiProvider> component.`):n}ownKeys(){return[`subscribe`,`on`,tv]}has(e,t){return t===`subscribe`||t===`on`||t===tv}}),cv=rv(sv),lv=()=>new Proxy({},{get(e,t){let n=G_(t,`AssistantClient`);return n===!1?ov(`The current scope does not have a "${String(t)}" property.`):n}}),uv=(0,_.createContext)(sv),dv=()=>(0,_.useContext)(uv),fv=({value:e,children:t})=>(0,G.jsx)(uv.Provider,{value:e,children:t}),pv=Fg(e=>null),mv=Symbol(`assistant-ui.transform-scopes`);function hv(e,t){let n=e;if(n[mv])throw Error(`transformScopes is already attached to this resource`);n[mv]=t}function gv(e){return e[mv]}var _v=e=>typeof e==`string`?{scope:e.split(`.`)[0],event:e}:{scope:e.scope,event:e.event},vv=D_(null),yv=(e,t)=>O_(vv,e,t),bv=()=>{let e=k_(vv);if(!e)throw Error(`AssistantTapContext is not available`);return e},xv=()=>bv().clientRef,Sv=()=>{let{emit:e}=bv(),t=H_();return l_((n,r)=>{e(n,r,t)})};function Cv(e,t){let n={...e},r=new Set,i=!0;for(;i;){i=!1;for(let e of Object.values(n)){if(e.type===pv||r.has(e.type))continue;r.add(e.type);let a=gv(e.type);if(a){a(n,t),i=!0;break}}}let a={},o={};for(let[e,t]of Object.entries(n))t.type===pv?o[e]=t:a[e]=t;return{rootClients:a,derivedClients:o}}var wv=e=>s_(()=>e,[...Object.entries(e).flat()]),Tv=(e,t)=>{let{rootClients:n,derivedClients:r}=Cv(e,t);return{rootClients:wv(n),derivedClients:wv(r)}},Ev=Fg(()=>a_(()=>{let e=new Map,t=new Set,n=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.delete(n)}},emit(n,r,i){let a=e.get(n);!a&&t.size===0||queueMicrotask(()=>{let e=[];if(a)for(let t of a)try{t(r,i)}catch(t){e.push(t)}if(t.size>0){let a={event:n,payload:r};for(let n of t)try{n(a,i)}catch(t){e.push(t)}}if(e.length>0){if(e.length===1)throw e[0];for(let t of e)console.error(t);throw AggregateError(e,`Errors occurred during event emission`)}})},subscribe(e){return n.add(e),()=>n.delete(e)},notifySubscribers(){for(let e of n)try{e()}catch(e){console.error(`NotificationManager: subscriber callback error`,e)}}}},[])),Dv=()=>{if(!Lg)return null;let e=(0,_.useRef)(0),t=e.current===0;return(0,_.useState)(()=>e.current++),e.current===2?t?`child`:`root`:null};function Ov(e){let t=(0,_.useMemo)(()=>Hg(e=>r(e)),[]),[n,r]=(0,_.useReducer)((e,n)=>(Wg(t,e),e+ +!!n()),0);Wg(t,n);let i=Dv(),a=(0,_.useMemo)(()=>(e.key,f_(e.type,t,void 0,i)),[e.type,e.key,t,i]),o=m_(a,e.props);return(0,_.useLayoutEffect)(()=>()=>p_(a),[a]),(0,_.useLayoutEffect)(()=>{Ug(t),h_(a,o)}),o.output}var kv=e=>s_(()=>e,e),Av=Fg(({element:e,emit:t,clientRef:n})=>{let{methods:r,state:i}=yv({clientRef:n,emit:t},()=>ev(e));return s_(()=>({state:i,methods:r}),[r,i])}),jv=Fg(({element:e,notifications:t,clientRef:n,name:r})=>{let i=T_(Av({element:e,emit:t.emit,clientRef:n}));return r_(()=>i.subscribe(t.notifySubscribers),[i,t]),s_(()=>{let e=()=>i.getValue().methods;return Object.defineProperties(e,{source:{value:`root`,writable:!1},query:{value:{},writable:!1},name:{value:r,configurable:!0}}),e},[i,r])}),Mv=Fg(()=>s_(()=>({clients:[],subscribe:void 0,on:void 0}),[])),Nv=Fg(({clients:e,clientRef:t})=>{let n=g_(Ev());r_(()=>t.parent.subscribe(n.notifySubscribers),[t,n]);let r=kv(__(()=>Object.keys(e).map(r=>Ig(r,jv({element:e[r],notifications:n,clientRef:t,name:r}))),[e,n,t]));return s_(()=>({clients:r,subscribe:n.subscribe,on:function(e,r){if(!this)throw Error(`const { on } = useAui() is not supported. Use aui.on() instead.`);let{scope:i,event:a}=_v(e);if(i!==`*`&&this[i].source===null)throw Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);let o=n.on(a,(e,t)=>{if(i===`*`){r(e);return}let n=this[i]();n===t[B_(n)]&&r(e)});if(i!==`*`&&t.parent[i].source===null)return o;let s=t.parent.on(e,r);return()=>{o(),s()}}}),[r,n,t])}),Pv=Fg(({element:e,clientRef:t,name:n})=>{let r=i_(e.props);return r.current=e.props,s_(()=>{let e=()=>r.current.get(t.current);return Object.defineProperties(e,{source:{value:r.current.source},query:{value:r.current.query},name:{value:n,configurable:!0}}),e},[t,n])}),Fv=(e,t)=>{let n;try{let e={};for(let n of Object.keys(t.query).sort())e[n]=t.query[n];n=JSON.stringify(e)}catch{n=String(t.query)}return`${e}::${t.source}::${n}`},Iv=Fg(({clients:e,clientRef:t})=>kv(__(()=>Object.keys(e).map(n=>{let r=n,i=e[r];return Ig(Fv(r,i.props),Pv({element:i,clientRef:t,name:r}))}),[e,t]))),Lv=Fg(({parent:e,clients:t})=>{let{rootClients:n,derivedClients:r}=Tv(t,e),i=i_({parent:e,current:null}).current;r_(()=>{i.current=s});let a=g_(Object.keys(n).length>0?Nv({clients:n,clientRef:i}):Mv()),o=g_(Iv({clients:r,clientRef:i})),s=s_(()=>{let t=e===sv?lv():e,n=Object.create(t);Object.assign(n,{subscribe:a.subscribe??e.subscribe,on:a.on??e.on,[tv]:rv(n)});for(let e of a.clients)n[e.name]=e;for(let e of o)n[e.name]=e;return n},[e,a,o]);return i.current===null&&(i.current=s),s});function Rv(e,{parent:t}={parent:dv()}){if(e)return Ov(Lv({parent:t??sv,clients:e}));if(t===null)throw Error(`received null parent, this usage is not allowed`);return t}var Z=e=>{let t=Rv(),n=iv(t),r=(0,_.useSyncExternalStore)(t.subscribe,()=>e(n),()=>e(n));if(r===n)throw Error(`You tried to return the entire AssistantState. This is not supported due to technical limitations.`);return(0,_.useDebugValue)(r),r},zv=({children:e,condition:t})=>Z(t)?e:null;zv.displayName=`AuiIf`;var Bv=e=>{let t=Rv(),n=(0,_.useRef)(!1),r=n.current?null:e(t);return Z(()=>n.current?e(t):r),()=>(n.current=!0,e(t))},Vv=Object.freeze({});function Hv({getItemState:e,children:t}){return Uv(t(Bv(e)))}var Uv=e=>{let t=typeof e==`object`&&e&&`type`in e?e:null,n=t?.type,r=t?.key;return(0,_.useMemo)(()=>t,[n,r,typeof t?.props==`object`&&t.props!=null&&Object.entries(t.props).length===0?Vv:t?.props])??e},Wv=_.createContext(!0);function Gv(){throw Error(`A function wrapped in useEffectEvent can't be called during rendering.`)}var Kv=`use`in _.default?()=>{try{return _.use(Wv)}catch{return!1}}:()=>!1;function qv(e){let t=_.useRef(Gv);return _.useInsertionEffect(()=>{t.current=e},[e]),(...e)=>{Kv()&&Gv();let n=t.current;return n(...e)}}var Jv=(e,t)=>{let n=Rv(),r=qv(t),{scope:i,event:a}=_v(e);(0,_.useEffect)(()=>n.on({scope:i,event:a},r),[n,i,a])},Yv=q_(e=>{if(e.key===void 0)throw Error(`tapClientResource: Element has no key`);return g_($_(e))});function Xv(e,t){let n=__(()=>e().map(e=>Yv(e)),t),r=s_(()=>Object.keys(n),[n]),i=s_(()=>n.reduce((e,t,n)=>(e[t.key]=n,e),{}),[n]);return{state:s_(()=>n.map(e=>e.state),[n]),get:e=>{if(`index`in e){if(e.index<0||e.index>=r.length)throw Error(`tapClientLookup: Index ${e.index} out of bounds (length: ${r.length})`);return n[e.index].methods}let t=i[e.key];if(t===void 0)throw Error(`tapClientLookup: Key "${e.key}" not found`);return n[t].methods}}}var Zv=Fg(({toolkit:e,mcpApp:t})=>{let n=__(()=>t?[Ig(`mcpApp`,t)]:[],[t])[0],[r,i]=e_(()=>({})),a=s_(()=>({toolUIs:r,mcpApp:n,tools:Object.fromEntries(Object.entries(r).map(([e,t])=>[e,t.map(e=>e.render)]))}),[r,n]),o=xv(),s=c_((e,t,n)=>{let r={render:t,standalone:n?.standalone??!1};return i(t=>({...t,[e]:[...t[e]??[],r]})),()=>{i(t=>{let n=t[e]?.filter(e=>e!==r)??[];if(n.length>0)return{...t,[e]:n};let{[e]:i,...a}=t;return a})}},[]);return r_(()=>{if(!e)return;let t=[];for(let[n,r]of Object.entries(e))r.render&&t.push(s(n,r.render,{standalone:R_(r)}));let n=Object.entries(e).reduce((e,[t,n])=>{let{render:r,display:i,...a}=n;return e[t]=a,e},{});return t.push(o.current.modelContext().register({getModelContext:()=>({tools:n})})),()=>{t.forEach(e=>e())}},[e,s,o]),{getState:()=>a,setToolUI:s}});hv(Zv,(e,t)=>{!e.modelContext&&t.modelContext.source===null&&(e.modelContext=L_())});var Qv=e=>{let[,t]=e_(e.getState);return r_(()=>(t(e.getState()),e.subscribe(()=>{t(e.getState())})),[e]),e.getState()},$v=Fg(({runtime:e})=>{let t=Qv(e);return{getState:()=>t,remove:e.remove,__internal_getRuntime:()=>e}}),ey=Fg(({runtime:e,index:t})=>g_($v({runtime:s_(()=>e.getAttachmentByIndex(t),[e,t])}))),ty=Fg(({threadIdRef:e,messageIdRef:t,runtime:n})=>{let r=Qv(n),i=Sv();r_(()=>{let r=[];for(let a of[`send`,`attachmentAdd`]){let o=n.unstable_on(a,()=>{i(`composer.${a}`,{threadId:e.current,...t&&{messageId:t.current}})});r.push(o)}return r.push(n.unstable_on(`attachmentAddError`,n=>{i(`composer.attachmentAddError`,{threadId:e.current,...t&&{messageId:t.current},...n.attachmentId&&{attachmentId:n.attachmentId},reason:n.reason,message:n.message})})),()=>{for(let e of r)e()}},[n,i,e,t]);let a=Xv(()=>r.attachments.map((e,t)=>Ig(e.id,ey({runtime:n,index:t}))),[r.attachments,n]),o=s_(()=>({text:r.text,role:r.role,attachments:a.state,runConfig:r.runConfig,isEditing:r.isEditing,canCancel:r.canCancel,canSend:r.canSend,attachmentAccept:r.attachmentAccept,isEmpty:r.isEmpty,type:r.type??`thread`,dictation:r.dictation,quote:r.quote,queue:[]}),[r,a.state]);return{getState:()=>o,setText:n.setText,setRole:n.setRole,setRunConfig:n.setRunConfig,addAttachment:n.addAttachment,reset:n.reset,clearAttachments:n.clearAttachments,send:n.send,cancel:n.cancel,beginEdit:n.beginEdit??(()=>{throw Error(`beginEdit is not supported in this runtime`)}),startDictation:n.startDictation,stopDictation:n.stopDictation,setQuote:n.setQuote,attachment:e=>`id`in e?a.get({key:e.id}):a.get(e),queueItem:()=>{throw Error(`Queue is not supported in this runtime`)},__internal_getRuntime:()=>n}}),ny=Fg(({runtime:e})=>{let t=Qv(e);return{getState:()=>t,addToolResult:t=>e.addToolResult(t),resumeToolCall:t=>e.resumeToolCall(t),respondToToolApproval:t=>e.respondToToolApproval(t),__internal_getRuntime:()=>e}}),ry=Fg(({runtime:e,index:t})=>g_($v({runtime:s_(()=>e.getAttachmentByIndex(t),[e,t])}))),iy=Fg(({runtime:e,index:t})=>g_(ny({runtime:s_(()=>e.getMessagePartByIndex(t),[e,t])}))),ay=Fg(({runtime:e,threadIdRef:t})=>{let n=Qv(e),[r,i]=e_(!1),[a,o]=e_(!1),s=s_(()=>({get current(){return e.getState().id}}),[e]),c=ev(ty({runtime:e.composer,threadIdRef:t,messageIdRef:s})),l=Xv(()=>n.content.map((t,n)=>Ig(`toolCallId`in t&&t.toolCallId!=null?`toolCallId-${t.toolCallId}`:`index-${n}`,iy({runtime:e,index:n}))),[n.content,e]),u=Xv(()=>(n.attachments??[]).map((t,n)=>Ig(t.id,ry({runtime:e,index:n}))),[n.attachments,e]),d=s_(()=>({...n,parts:l.state,composer:c.state,isCopied:r,isHovering:a}),[n,l.state,c.state,r,a]);return{getState:()=>d,composer:()=>c.methods,reload:t=>e.reload(t),speak:()=>e.speak(),stopSpeaking:()=>e.stopSpeaking(),submitFeedback:t=>e.submitFeedback(t),switchToBranch:t=>e.switchToBranch(t),getCopyText:()=>e.unstable_getCopyText(),part:e=>`index`in e?l.get({index:e.index}):l.get({key:`toolCallId-${e.toolCallId}`}),attachment:e=>`id`in e?u.get({key:e.id}):u.get(e),setIsCopied:i,setIsHovering:o,__internal_getRuntime:()=>e}}),oy=Fg(({runtime:e,id:t,threadIdRef:n})=>g_(ay({runtime:s_(()=>e.getMessageById(t),[e,t]),threadIdRef:n}))),sy=Fg(({runtime:e})=>{let t=Qv(e),n=Sv();r_(()=>{let t=[];for(let r of[`runStart`,`runEnd`,`initialize`,`modelContextUpdate`]){let i=e.unstable_on(r,()=>{let t=e.getState()?.threadId||`unknown`;n(`thread.${r}`,{threadId:t})});t.push(i)}return()=>{for(let e of t)e()}},[e,n]);let r=s_(()=>({get current(){return e.getState().threadId}}),[e]),i=ev(ty({runtime:e.composer,threadIdRef:r})),a=Xv(()=>t.messages.map(t=>Ig(t.id,oy({runtime:e,id:t.id,threadIdRef:r}))),[t.messages,e,r]),o=s_(()=>({isEmpty:a.state.length===0&&!t.isLoading,isDisabled:t.isDisabled,isLoading:t.isLoading,isRunning:t.isRunning,capabilities:t.capabilities,state:t.state,suggestions:t.suggestions,extras:t.extras,speech:t.speech,voice:t.voice,composer:i.state,messages:a.state}),[t,a,i.state]);return{getState:()=>o,composer:()=>i.methods,append:e.append,startRun:e.startRun,resumeRun:e.resumeRun,cancelRun:e.cancelRun,getModelContext:e.getModelContext,export:e.export,import:e.import,reset:e.reset,stopSpeaking:e.stopSpeaking,connectVoice:e.connectVoice,disconnectVoice:e.disconnectVoice,getVoiceVolume:e.getVoiceVolume,subscribeVoiceVolume:e.subscribeVoiceVolume,muteVoice:e.muteVoice,unmuteVoice:e.unmuteVoice,message:e=>`id`in e?a.get({key:e.id}):a.get(e),__internal_getRuntime:()=>e}}),cy=Fg(({runtime:e})=>{let t=Qv(e),n=Sv();return r_(()=>{let t=[];for(let r of[`switchedTo`,`switchedAway`]){let i=e.unstable_on(r,()=>{n(`threadListItem.${r}`,{threadId:e.getState().id})});t.push(i)}return()=>{for(let e of t)e()}},[e,n]),{getState:()=>t,switchTo:e.switchTo,rename:e.rename,archive:e.archive,unarchive:e.unarchive,delete:e.delete,generateTitle:e.generateTitle,initialize:e.initialize,detach:e.detach,__internal_getRuntime:()=>e}}),ly=Fg(({runtime:e,id:t})=>g_(cy({runtime:s_(()=>e.getItemById(t),[e,t])}))),uy=Fg(({runtime:e,__internal_assistantRuntime:t})=>{let n=Qv(e),r=ev(sy({runtime:e.main})),i=Xv(()=>Object.keys(n.threadItems).map(t=>Ig(t,ly({runtime:e,id:t}))),[n.threadItems,e]),a=s_(()=>({mainThreadId:n.mainThreadId,newThreadId:n.newThreadId??null,isLoading:n.isLoading,isLoadingMore:n.isLoadingMore,hasMore:n.hasMore,threadIds:n.threadIds,archivedThreadIds:n.archivedThreadIds,threadItems:i.state,main:r.state}),[n,i.state,r.state]);return{getState:()=>a,thread:()=>r.methods,item:e=>{if(e===`main`)return i.get({key:a.mainThreadId});if(`id`in e)return i.get({key:e.id});let{index:t,archived:n=!1}=e,r=n?a.archivedThreadIds[t]:a.threadIds[t];return i.get({key:r})},switchToThread:async(t,n)=>{await e.switchToThread(t,n)},switchToNewThread:async()=>{await e.switchToNewThread()},getLoadThreadsPromise:()=>e.getLoadThreadsPromise(),reload:()=>e.reload(),loadMore:()=>e.loadMore(),__internal_getAssistantRuntime:()=>t}}),dy=Fg(e=>({getState:()=>e})),fy=Fg(e=>{let[t]=e_(()=>({suggestions:(e??[]).map(e=>typeof e==`string`?{title:e,label:``,prompt:e}:{title:e.title,label:e.label,prompt:e.prompt})})),n=Xv(()=>t.suggestions.map((e,t)=>Ig(t,dy(e))),[t.suggestions]);return{getState:()=>t,suggestion:({index:e})=>n.get({index:e})}}),py=Fg(e=>{let t=xv();return r_(()=>e.registerModelContextProvider(t.current.modelContext()),[e,t]),g_(uy({runtime:e.threads,__internal_assistantRuntime:e}))}),my=(e,t)=>{e.thread??=pv({source:`threads`,query:{type:`main`},get:e=>e.threads().thread(`main`)}),e.threadListItem??=pv({source:`threads`,query:{type:`main`},get:e=>e.threads().item(`main`)}),e.composer??=pv({source:`thread`,query:{},get:e=>e.threads().thread(`main`).composer()}),!e.modelContext&&t.modelContext.source===null&&(e.modelContext=L_()),!e.suggestions&&t.suggestions.source===null&&(e.suggestions=fy())},hy=Fg(e=>g_(py(e)));hv(hy,(e,t)=>{my(e,t),!e.tools&&t.tools.source===null&&(e.tools=Zv({})),!e.dataRenderers&&t.dataRenderers.source===null&&(e.dataRenderers=A_())});var gy=e=>e._core?.RenderComponent,_y=(0,_.memo)(({runtime:e,aui:t=null,children:n})=>{let r=Rv({threads:hy(e)},{parent:t}),i=gy(e);return(0,G.jsxs)(fv,{value:r,children:[i&&(0,G.jsx)(i,{}),n]})}),vy=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??(typeof i!=`object`||!i)?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},yy=(e=>e?vy(e):vy),by=e=>e;function xy(e,t=by){let n=_.useSyncExternalStore(e.subscribe,_.useCallback(()=>t(e.getState()),[e,t]),_.useCallback(()=>t(e.getInitialState()),[e,t]));return _.useDebugValue(n),n}var Sy=e=>{let t=yy(e),n=e=>xy(t,e);return Object.assign(n,t),n},Cy=(e=>e?Sy(e):Sy),wy=()=>{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}},Ty=()=>{let e=[],t=!1,n,r,i=i=>{i.promise||=i.reader.read().then(({done:a,value:o})=>{i.promise=void 0,a?(e.splice(e.indexOf(i),1),t&&e.length===0&&n.close()):n.enqueue(o),r?.resolve(),r=void 0}).catch(t=>{console.error(t),e.forEach(e=>{e.reader.cancel()}),e.length=0,n.error(t),r?.reject(t),r=void 0})};return{readable:new ReadableStream({start(e){n=e},pull(){return r=wy(),e.forEach(e=>{i(e)}),r.promise},cancel(){e.forEach(e=>{e.reader.cancel()}),e.length=0}}),isSealed(){return t},seal(){t=!0,e.length===0&&n.close()},addStream(n){if(t)throw Error(`Cannot add streams after the run callback has settled.`);let r={reader:n.getReader()};e.push(r),i(r)},enqueue(e){this.addStream(new ReadableStream({start(t){t.enqueue(e),t.close()}}))}}},Ey=class{_controller;_isClosed=!1;constructor(e){this._controller=e}append(e){return this._controller.enqueue({type:`text-delta`,path:[],textDelta:e}),this}close(){this._isClosed||(this._isClosed=!0,this._controller.enqueue({type:`part-finish`,path:[]}),this._controller.close())}},Dy=e=>new ReadableStream({start(t){return e.start?.(new Ey(t))},pull(t){return e.pull?.(new Ey(t))},cancel(t){return e.cancel?.(t)}}),Oy=()=>{let e;return[Dy({start(t){e=t}}),e]},ky=class{_controller;_isClosed=!1;_mergeTask;constructor(e){this._controller=e;let t=Dy({start:e=>{this._argsTextController=e}}),n=!1;this._mergeTask=t.pipeTo(new WritableStream({write:e=>{switch(e.type){case`text-delta`:n=!0,this._controller.enqueue(e);break;case`part-finish`:n||this._controller.enqueue({type:`text-delta`,textDelta:`{}`,path:[]}),this._controller.enqueue({type:`tool-call-args-text-finish`,path:[]});break;default:throw Error(`Unexpected chunk type: ${e.type}`)}}}))}get argsText(){return this._argsTextController}_argsTextController;async setResponse(e){this._argsTextController.close(),await Promise.resolve(),this._controller.enqueue({type:`result`,path:[],...e.artifact===void 0?{}:{artifact:e.artifact},result:e.result,isError:e.isError??!1,...e.modelContent===void 0?{}:{modelContent:e.modelContent},...e.messages===void 0?{}:{messages:e.messages}})}async close(){this._isClosed||(this._isClosed=!0,this._argsTextController.close(),await this._mergeTask,this._controller.enqueue({type:`part-finish`,path:[]}),this._controller.close())}},Ay=e=>new ReadableStream({start(t){return e.start?.(new ky(t))},pull(t){return e.pull?.(new ky(t))},cancel(t){return e.cancel?.(t)}}),jy=()=>{let e;return[Ay({start(t){e=t}}),e]},My=class{value=-1;up(){return++this.value}},Ny=class extends TransformStream{constructor(e){super({transform(t,n){n.enqueue({...t,path:[e,...t.path]})}})}};TransformStream;var Py=class extends TransformStream{constructor(e){let t=new My,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({...r,path:[s,...o]})}})}},Fy=class extends TransformStream{constructor(e){super();let t=e(super.readable);Object.defineProperty(this,"readable",{value:t,writable:!1})}},Iy=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);return}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({...t,meta:i});return}n.enqueue(t)}})}},Ly=(e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i--;)r+=e[Math.random()*e.length|0];return r},Ry=Ly(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7),zy=class e{_state;_parentId;constructor(e){this._state=e||{merger:Ty(),contentCounter:new My}}get __internal_isClosed(){return this._state.merger.isSealed()}__internal_getReadable(){return this._state.merger.readable}__internal_subscribeToClose(e){this._state.closeSubscriber=e}_addPart(e,t){this._state.append&&(this._state.append.controller.close(),this._state.append=void 0),this.enqueue({type:`part-start`,part:e,path:[]}),this._state.merger.addStream(t.pipeThrough(new Ny(this._state.contentCounter.value)))}merge(e){this._state.merger.addStream(e.pipeThrough(new Py(this._state.contentCounter)))}appendText(e){(this._state.append?.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){(this._state.append?.kind!==`reasoning`||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:`reasoning`,parentId:this._parentId,controller:this.addReasoningPart()}),this._state.append.controller.append(e)}addTextPart(){let[e,t]=Oy();return this._addPart(this._withParentIdOption({type:`text`}),e),t}addReasoningPart(){let[e,t]=Oy();return this._addPart(this._withParentIdOption({type:`reasoning`}),e),t}addToolCallPart(e){let t=typeof e==`string`?{toolName:e}:e,n=t.toolName,r=t.toolCallId??Ry(),[i,a]=jy();return this._addPart({type:`tool-call`,toolName:n,toolCallId:r,...this._parentId&&{parentId:this._parentId}},i),t.argsText!==void 0&&(a.argsText.append(t.argsText),a.argsText.close()),t.args!==void 0&&(a.argsText.append(JSON.stringify(t.args)),a.argsText.close()),t.response!==void 0&&a.setResponse(t.response),a}_finishedPartStream(){return new ReadableStream({start(e){e.enqueue({type:`part-finish`,path:[]}),e.close()}})}_withParentIdOption(e){return this._parentId?{...e,parentId:this._parentId}:e}appendSource(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendFile(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendData(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}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(){this._state.append?.controller?.close(),this._state.merger.seal(),this._state.closeSubscriber?.()}};function By(e){let t=new zy;return(async()=>{try{await e(t)}catch(e){throw t.__internal_isClosed||t.enqueue({type:`error`,path:[],error:String(e)}),e}finally{t.__internal_isClosed||t.close()}})(),t.__internal_getReadable()}function Vy(){let{resolve:e,promise:t}=wy(),n;return[By(r=>(n=r,n.__internal_subscribeToClose(e),t)),n]}function Hy(e){let t=[`ROOT`],n=-1,r=null,i=[],a;function o(){a!==void 0&&(i.push(JSON.parse(`"${a}"`)),a=void 0)}function s(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`),o();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`),o();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`),o();break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`),o();break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`),o();break}}function c(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop(),a=i.pop();break}}function l(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),a=(Number(a)+1).toString();break;case`]`:n=r,t.pop(),a=i.pop();break}}for(let o=0;o<e.length;o++){let u=e[o];switch(t[t.length-1]){case`ROOT`:s(u,o,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`),a=``;break;case`}`:n=o,t.pop(),a=i.pop();break}break;case`INSIDE_OBJECT_AFTER_COMMA`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`),a=``;break}break;case`INSIDE_OBJECT_KEY`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`);break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`),a+=u;break;default:a+=u;break}break;case`INSIDE_OBJECT_AFTER_KEY`:switch(u){case`:`:t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`);break}break;case`INSIDE_OBJECT_BEFORE_VALUE`:s(u,o,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:c(u,o);break;case`INSIDE_STRING`:switch(u){case`"`:t.pop(),n=o,a=i.pop();break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=o}break;case`INSIDE_ARRAY_START`:switch(u){case`]`:n=o,t.pop(),a=i.pop();break;default:n=o,a=`0`,s(u,o,`INSIDE_ARRAY_AFTER_VALUE`);break}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(u){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),a=(Number(a)+1).toString();break;case`]`:n=o,t.pop(),a=i.pop();break;default:n=o;break}break;case`INSIDE_ARRAY_AFTER_COMMA`:s(u,o,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:t.pop(),t[t.length-1]===`INSIDE_STRING`?n=o:t[t.length-1]===`INSIDE_OBJECT_KEY`&&(a+=u);break;case`INSIDE_NUMBER`:switch(u){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=o;break;case`e`:case`E`:case`-`:case`.`:break;case`,`:t.pop(),a=i.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&l(u,o),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&c(u,o);break;case`}`:t.pop(),a=i.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&c(u,o);break;case`]`:t.pop(),a=i.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&l(u,o);break;default:t.pop(),a=i.pop();break}break;case`INSIDE_LITERAL`:{let i=e.substring(r,o+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?c(u,o):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&l(u,o)):n=o;break}}}let u=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:u+=`"`;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`:u+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:u+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?u+=`true`.slice(t.length):`false`.startsWith(t)?u+=`false`.slice(t.length):`null`.startsWith(t)&&(u+=`null`.slice(t.length))}}return[u,i]}var Uy=n(r(((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;try{return a(e,t,{safe:!0})}catch{return}finally{Error.stackTraceLimit=n}}t.exports=s,t.exports.default=s,t.exports.parse=s,t.exports.safeParse=c,t.exports.scan=o}))(),1),Wy=Symbol(`aui.parse-partial-json-object.meta`),Gy=e=>e?.[Wy],Ky=e=>{if(e.length===0)return{[Wy]:{state:`partial`,partialPath:[]}};try{let t=Uy.default.parse(e);if(typeof t!=`object`||!t)throw Error(`argsText is expected to be an object`);return t[Wy]={state:`complete`,partialPath:[]},t}catch{try{let[t,n]=Hy(e),r=Uy.default.parse(t);if(typeof r!=`object`||!r)throw Error(`argsText is expected to be an object`);return r[Wy]={state:`partial`,partialPath:n},r}catch{return}}},qy=(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 qy(s,{state:`partial`,partialPath:o},i)},Jy=(e,t)=>{let n=Gy(e);if(!n)throw Error(`unable to determine object state`);return qy(e,n,t.map(String))};async function*Yy(){let e=this.getReader();try{for(;;){let{done:t,value:n}=await e.read();if(t)break;yield n}}finally{e.releaseLock()}}function Xy(e){return e[Symbol.asyncIterator]??=Yy,e}var Zy=Symbol.for(`aui.tool-response`),Qy=class e{get[Zy](){return!0}artifact;result;isError;modelContent;messages;constructor(e){e.artifact!==void 0&&(this.artifact=e.artifact),this.result=e.result,this.isError=e.isError??!1,e.modelContent!==void 0&&(this.modelContent=e.modelContent),e.messages!==void 0&&(this.messages=e.messages)}static[Symbol.hasInstance](e){return typeof e==`object`&&!!e&&Zy in e}static toResponse(t){return t instanceof e?t:new e({result:t===void 0?`<no result>`:t})}};function $y(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)}}function eb(e,t){let n=e;for(let e of t){if(n==null)return;n=n[e]}return n}var tb=class{resolve;reject;disposed=!1;fieldPath;constructor(e,t,n){this.resolve=e,this.reject=t,this.fieldPath=n}update(e){if(!this.disposed)try{if(Jy(e,this.fieldPath)===`complete`){let t=eb(e,this.fieldPath);t!==void 0&&(this.resolve(t),this.dispose())}}catch(e){this.reject(e),this.dispose()}}dispose(){this.disposed=!0}},nb=class{controller;disposed=!1;fieldPath;constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=eb(e,this.fieldPath);t!==void 0&&this.controller.enqueue(t),Jy(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}dispose(){this.disposed=!0}},rb=class{controller;disposed=!1;fieldPath;lastValue=void 0;constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=eb(e,this.fieldPath);if(t!==void 0&&typeof t==`string`){let e=t.substring(this.lastValue?.length||0);this.lastValue=t,this.controller.enqueue(e)}Jy(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}dispose(){this.disposed=!0}},ib=class{controller;disposed=!1;fieldPath;processedIndexes=new Set;constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=eb(e,this.fieldPath);if(!Array.isArray(t))return;for(let n=0;n<t.length;n++)this.processedIndexes.has(n)||Jy(e,[...this.fieldPath,n])===`complete`&&(this.controller.enqueue(t[n]),this.processedIndexes.add(n));Jy(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}dispose(){this.disposed=!0}},ab=class{argTextDeltas;handles=new Set;args=Ky(``);constructor(e){this.argTextDeltas=e,this.processStream()}async processStream(){try{let e=``,t=this.argTextDeltas.getReader();for(;;){let{value:n,done:r}=await t.read();if(r)break;e+=n;let i=Ky(e);if(i!==void 0){this.args=i;for(let e of this.handles)e.update(i)}}}catch(e){console.error(`Error processing argument stream:`,e);for(let e of this.handles)e.dispose()}}get(...e){return new Promise((t,n)=>{let r=new tb(t,n,e);if(this.args&&Jy(this.args,e)===`complete`){let n=eb(this.args,e);if(n!==void 0){t(n);return}}this.handles.add(r),r.update(this.args)})}streamValues(...e){let t=e;return Xy(new ReadableStream({start:e=>{let n=new nb(e,t);this.handles.add(n),n.update(this.args)},cancel:()=>{for(let e of this.handles)if(e instanceof nb){e.dispose(),this.handles.delete(e);break}}}))}streamText(...e){let t=e;return Xy(new ReadableStream({start:e=>{let n=new rb(e,t);this.handles.add(n),n.update(this.args)},cancel:()=>{for(let e of this.handles)if(e instanceof rb){e.dispose(),this.handles.delete(e);break}}}))}forEach(...e){let t=e;return Xy(new ReadableStream({start:e=>{let n=new ib(e,t);this.handles.add(n),n.update(this.args)},cancel:()=>{for(let e of this.handles)if(e instanceof ib){e.dispose(),this.handles.delete(e);break}}}))}},ob=class{promise;constructor(e){this.promise=e}get(){return this.promise}},sb=class{args;response;writable;resolve;argsText=``;constructor(){let e=new TransformStream;this.writable=e.writable,this.args=new ab(e.readable);let{promise:t,resolve:n}=wy();this.resolve=n,this.response=new ob(t)}async appendArgsTextDelta(e){let t=this.writable.getWriter();try{await t.write(e)}catch(e){console.warn(e)}finally{t.releaseLock()}this.argsText+=e}setResponse(e){this.resolve(e)}result={get:async()=>(await this.response.get()).result}},cb=class extends Fy{constructor(e){let t=new Map,n=new Map;super(r=>{let i=new TransformStream({transform(r,i){switch((r.type!==`part-finish`||r.meta.type!==`tool-call`)&&i.enqueue(r),r.type){case`part-start`:if(r.part.type===`tool-call`){let t=new sb;n.set(r.part.toolCallId,t),e.streamCall({reader:t,toolCallId:r.part.toolCallId,toolName:r.part.toolName})}break;case`text-delta`:if(r.meta.type===`tool-call`){let e=r.meta.toolCallId,t=n.get(e);if(!t)throw Error(`No controller found for tool call`);t.appendArgsTextDelta(r.textDelta)}break;case`result`:{if(r.meta.type!==`tool-call`)break;let{toolCallId:e}=r.meta,t=n.get(e);if(!t)throw Error(`No controller found for tool call`);t.setResponse(new Qy({result:r.result,artifact:r.artifact,isError:r.isError,modelContent:r.modelContent}));break}case`tool-call-args-text-finish`:{if(r.meta.type!==`tool-call`)break;let{toolCallId:a,toolName:o}=r.meta,s=n.get(a);if(!s)throw Error(`No controller found for tool call`);let c=!1,l=$y(()=>{let t;try{t=Uy.default.parse(s.argsText)}catch(e){throw Error(`Function parameter parsing failed. ${JSON.stringify(e.message)}`)}let n=e.execute({toolCallId:a,toolName:o,args:t});return n!==void 0&&(c=!0,e.onExecutionStart?.(a,o)),n},t=>{if(c&&e.onExecutionEnd?.(a,o),t===void 0)return;let n=new Qy({artifact:t.artifact,result:t.result,isError:t.isError,messages:t.messages,modelContent:t.modelContent});s.setResponse(n),i.enqueue({type:`result`,path:r.path,...n})},t=>{c&&e.onExecutionEnd?.(a,o);let n=new Qy({result:String(t),isError:!0});s.setResponse(n),i.enqueue({type:`result`,path:r.path,...n})});l&&t.set(a,l);break}case`part-finish`:{if(r.meta.type!==`tool-call`)break;let{toolCallId:e}=r.meta,a=t.get(e);a?a.then(()=>{t.delete(e),n.delete(e),i.enqueue(r)}):i.enqueue(r)}}},async flush(){await Promise.all(t.values())}});return r.pipeThrough(new Iy).pipeThrough(i)})}},lb=e=>typeof e==`object`&&!!e&&`~standard`in e&&e[`~standard`].version===1;function ub(e,t,n,r){let i=e?.[n.toolName];return i?.execute?(async e=>{if(t.aborted)return new Qy({result:`Tool execution was cancelled.`,isError:!0});let a=e;if(lb(i.parameters)){let e=i.parameters[`~standard`].validate(n.args);e instanceof Promise&&(e=await e),e.issues&&(a=i.experimental_onSchemaValidationError??(()=>{throw Error(`Function parameter validation failed. ${JSON.stringify(e.issues)}`)}))}let o=new Promise(e=>{let n=()=>{queueMicrotask(()=>{queueMicrotask(()=>{e(new Qy({result:`Tool execution was cancelled.`,isError:!0}))})})};t.aborted?n():t.addEventListener(`abort`,n,{once:!0})}),s=(async()=>{let e=await a(n.args,{toolCallId:n.toolCallId,abortSignal:t,human:e=>r(n.toolCallId,e)}),o=Qy.toResponse(e);if(i.toModelOutput&&!o.isError&&o.modelContent===void 0)try{let e=await i.toModelOutput({toolCallId:n.toolCallId,input:n.args,output:o.result});return new Qy({result:o.result,artifact:o.artifact,isError:o.isError,messages:o.messages,modelContent:e})}catch(e){console.warn(`[assistant-stream] tool "${n.toolName}" toModelOutput threw; falling back to default projection.`,e)}return o})();return Promise.race([s,o])})(i.execute):void 0}function db(e,t,n,r,i){e?.[r.toolName]?.streamCall?.(n,{toolCallId:r.toolCallId,abortSignal:t,human:e=>i(r.toolCallId,e)})}function fb(e,t,n,r){let i=typeof e==`function`?e:()=>e,a=typeof t==`function`?t:()=>t;return new cb({execute:e=>ub(i(),a(),e,n),streamCall:({reader:e,...t})=>db(i(),a(),e,t,n),onExecutionStart:r?.onExecutionStart,onExecutionEnd:r?.onExecutionEnd})}var pb=({index:e,children:t})=>(0,G.jsx)(fv,{value:Rv({attachment:pv({source:`message`,query:{type:`index`,index:e},get:t=>t.message().attachment({index:e})})}),children:t}),mb=({index:e,children:t})=>(0,G.jsx)(fv,{value:Rv({attachment:pv({source:`composer`,query:{type:`index`,index:e},get:t=>t.composer().attachment({index:e})})}),children:t}),hb=({index:e,children:t})=>(0,G.jsx)(fv,{value:Rv({message:pv({source:`thread`,query:{type:`index`,index:e},get:t=>t.thread().message({index:e})}),composer:pv({source:`message`,query:{},get:t=>t.thread().message({index:e}).composer()})}),children:t}),gb=({index:e,children:t})=>(0,G.jsx)(fv,{value:Rv({part:pv({source:`message`,query:{type:`index`,index:e},get:t=>t.message().part({index:e})})}),children:t}),_b=Fg(({text:e,isRunning:t})=>{let n=s_(()=>({type:`text`,text:e,status:t?{type:`running`}:{type:`complete`}}),[e,t]);return{getState:()=>n,addToolResult:()=>{throw Error(`Not supported`)},resumeToolCall:()=>{throw Error(`Not supported`)},respondToToolApproval:()=>{throw Error(`Not supported`)}}}),vb=({text:e,isRunning:t=!1,children:n})=>(0,G.jsx)(fv,{value:Rv({part:_b({text:e,isRunning:t})}),children:n}),yb=Object.freeze({type:`complete`}),bb=Fg(({parts:e,getMessagePart:t})=>{let[n,r]=e_(!0),i=s_(()=>e[e.length-1]?.status??yb,[e]),a=s_(()=>({parts:e,collapsed:n,status:i}),[e,n,i]);return{getState:()=>a,setCollapsed:r,part:t}}),xb=({startIndex:e,endIndex:t,children:n})=>{let r=Z(e=>e.message.parts).slice(e,t+1),i=Rv();return(0,G.jsx)(fv,{value:Rv({chainOfThought:bb({parts:r,getMessagePart:({index:t})=>{if(t<0||t>=r.length)throw Error(`ChainOfThought part index ${t} is out of bounds (0..${r.length-1})`);return i.message().part({index:e+t})}})}),children:n})},Sb=({index:e,children:t})=>(0,G.jsx)(fv,{value:Rv({suggestion:pv({source:`suggestions`,query:{index:e},get:t=>t.suggestions().suggestion({index:e})})}),children:t}),Cb=({index:e,children:t})=>(0,G.jsx)(fv,{value:Rv({queueItem:pv({source:`composer`,query:{index:e},get:t=>t.composer().queueItem({index:e})})}),children:t}),wb=Symbol(`innerMessage`),Tb=Symbol(`innerMessages`),Eb=[],Db=(e,t)=>{wb in e||(e[wb]=t)},Ob=e=>{let t=`messages`in e?e.messages:e,n=t[Tb]||t[wb];return n?Array.isArray(n)?n:(t[Tb]=[n],t[Tb]):Eb},kb=Symbol(`skip-update`);function Ab(e,t){if(e===void 0&&t===void 0)return!0;if(e===void 0||t===void 0)return!1;for(let n of Object.keys(e)){let r=e[n],i=t[n];if(!Object.is(r,i))return!1}return!0}var jb=class{_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(){let e=[];for(let t of this._subscribers)try{t()}catch(t){e.push(t)}if(e.length>0){if(e.length===1)throw e[0];for(let t of e)console.error(t);throw AggregateError(e)}}},Mb=class{_subscriptions=new Set;_connection;get isConnected(){return!!this._connection}notifySubscribers(e){for(let t of this._subscriptions)t(e)}_updateConnection(){if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else this._connection?.(),this._connection=void 0}subscribe(e){return this._subscriptions.add(e),this._updateConnection(),()=>{this._subscriptions.delete(e),this._updateConnection()}}},Nb=class extends Mb{binding;get path(){return this.binding.path}constructor(e){super(),this.binding=e;let t=e.getState();if(t===kb)throw Error(`Entry not available in the store`);this._previousState=t}_previousState;getState=()=>(this.isConnected||this._syncState(),this._previousState);_syncState(){let e=this.binding.getState();return e===kb||Ab(e,this._previousState)?!1:(this._previousState=e,!0)}_connect(){return this.binding.subscribe(()=>{this._syncState()&&this.notifySubscribers()})}},Pb=class extends Mb{binding;get path(){return this.binding.path}constructor(e){super(),this.binding=e}_previousStateDirty=!0;_previousState;getState=()=>{if(!this.isConnected||this._previousStateDirty){let e=this.binding.getState();e!==kb&&(this._previousState=e),this._previousStateDirty=!1}if(this._previousState===void 0)throw Error(`Entry not available in the store`);return this._previousState};_connect(){return this.binding.subscribe(()=>{this._previousStateDirty=!0,this.notifySubscribers()})}},Fb=class extends Mb{binding;get path(){return this.binding.path}constructor(e){super(),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?.subscribe(e),r=this.outerSubscribe(()=>{let r=this.binding.getState();r!==t&&(t=r,n?.(),n=r?.subscribe(e),e())});return()=>{r?.(),n?.()}}},Ib=class extends Mb{config;constructor(e){super(),this.config=e}getState(){return this.config.binding.getState()}outerSubscribe(e){return this.config.binding.subscribe(e)}_connect(){let e=e=>{this.notifySubscribers(e)},t=this.config.binding.getState(),n=t?.unstable_on(this.config.event,e),r=this.outerSubscribe(()=>{let r=this.config.binding.getState();r!==t&&(t=r,n?.(),n=r?.unstable_on(this.config.event,e))});return()=>{r?.(),n?.()}}},Lb=class{_core;get path(){return this._core.path}constructor(e){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)}},Rb=class extends Lb{_composerApi;constructor(e,t){super(e),this._composerApi=t}remove(){let e=this._composerApi.getState();if(!e)throw Error(`Composer is not available`);return e.removeAttachment(this.getState().id)}},zb=class extends Rb{get source(){return`thread-composer`}},Bb=class extends Rb{get source(){return`edit-composer`}},Vb=class extends Lb{get source(){return`message`}remove(){throw Error(`Message attachments cannot be removed`)}},Hb=Object.freeze([]),Ub=Object.freeze({}),Wb=e=>Object.freeze({type:`thread`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,attachments:e?.attachments??Hb,text:e?.text??``,role:e?.role??`user`,runConfig:e?.runConfig??Ub,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,value:e?.text??``}),Gb=e=>Object.freeze({type:`edit`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,text:e?.text??``,role:e?.role??`user`,attachments:e?.attachments??Hb,runConfig:e?.runConfig??Ub,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,parentId:e?.parentId??null,sourceId:e?.sourceId??null,value:e?.text??``}),Kb=class{_core;get path(){return this._core.path}constructor(e){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.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){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setText(e)}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()}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)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new Ib({event:e,binding:this._core}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},qb=class extends Kb{get path(){return this._core.path}get type(){return`thread`}_getState;constructor(e){let t=new Pb({path:e.path,getState:()=>Wb(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>t.subscribe(e)}),this._getState=t.getState.bind(t),this.__internal_bindMethods()}getState(){return this._getState()}getAttachmentByIndex(e){return new zb(new Nb({path:{...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?{...t,source:`thread-composer`}:kb},subscribe:e=>this._core.subscribe(e)}),this._core)}},Jb=class extends Kb{_beginEdit;get path(){return this._core.path}get type(){return`edit`}_getState;constructor(e,t){let n=new Pb({path:e.path,getState:()=>Gb(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>n.subscribe(e)}),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 Bb(new Nb({path:{...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?{...t,source:`edit-composer`}:kb},subscribe:e=>this._core.subscribe(e)}),this._core)}},Yb=e=>e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
56
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return _.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},ec=`DialogDescriptionWarning`,tc=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Qs(ec).contentName}}.`;return _.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},nc=Ds,rc=Ns,ic=Fs,ac=zs,oc=Ws,sc=Ks,cc=Js;function lc(e){let[t,n]=_.useState(void 0);return Yi(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var uc=[`top`,`right`,`bottom`,`left`],dc=Math.min,fc=Math.max,pc=Math.round,mc=Math.floor,hc=e=>({x:e,y:e}),gc={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function _c(e,t,n){return fc(e,dc(t,n))}function vc(e,t){return typeof e==`function`?e(t):e}function yc(e){return e.split(`-`)[0]}function bc(e){return e.split(`-`)[1]}function xc(e){return e===`x`?`y`:`x`}function Sc(e){return e===`y`?`height`:`width`}function Cc(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function wc(e){return xc(Cc(e))}function Tc(e,t,n){n===void 0&&(n=!1);let r=bc(e),i=wc(e),a=Sc(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Pc(o)),[o,Pc(o)]}function Ec(e){let t=Pc(e);return[Dc(e),t,Dc(t)]}function Dc(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var Oc=[`left`,`right`],kc=[`right`,`left`],Ac=[`top`,`bottom`],jc=[`bottom`,`top`];function Mc(e,t,n){switch(e){case`top`:case`bottom`:return n?t?kc:Oc:t?Oc:kc;case`left`:case`right`:return t?Ac:jc;default:return[]}}function Nc(e,t,n,r){let i=bc(e),a=Mc(yc(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Dc)))),a}function Pc(e){let t=yc(e);return gc[t]+e.slice(t.length)}function Fc(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ic(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Fc(e)}function Lc(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}}function Rc(e,t,n){let{reference:r,floating:i}=e,a=Cc(t),o=wc(t),s=Sc(o),c=yc(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}}switch(bc(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function zc(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=vc(t,e),p=Ic(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Lc(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=Lc(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Bc=50,Vc=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:zc},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Rc(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}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<Bc&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=Rc(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Hc=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=vc(e,t)||{};if(l==null)return{};let d=Ic(u),f={x:n,y:r},p=wc(i),m=Sc(p),h=await 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=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(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,E=dc(d[_],T),D=dc(d[v],T),O=E,k=C-h[m]-D,A=C/2-h[m]/2+w,j=_c(O,A,k),M=!c.arrow&&bc(i)!=null&&A!==j&&a.reference[m]/2-(A<O?E:D)-h[m]/2<0,N=M?A<O?A-O:A-k:0;return{[p]:f[p]+N,data:{[p]:j,centerOffset:A-j-N,...M&&{alignmentOffset:N}},reset:M}}}),Uc=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=vc(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=yc(r),_=Cc(o),v=yc(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Pc(o)]:Ec(o)),x=p!==`none`;!d&&x&&b.push(...Nc(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Tc(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==Cc(t))||T.every(e=>Cc(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=Cc(e.placement);return t===_||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]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function Wc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Gc(e){return uc.some(t=>e[t]>=0)}var Kc=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=vc(e,t);switch(i){case`referenceHidden`:{let e=Wc(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Gc(e)}}}case`escaped`:{let e=Wc(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Gc(e)}}}default:return{}}}}},qc=new Set([`left`,`top`]);async function Jc(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=yc(n),s=bc(n),c=Cc(n)===`y`,l=qc.has(o)?-1:1,u=a&&c?-1:1,d=vc(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}}var Yc=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Jc(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Xc=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=vc(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Cc(yc(i)),p=xc(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=_c(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=_c(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},Zc=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=vc(e,t),u={x:n,y:r},d=Cc(i),f=xc(d),p=u[f],m=u[d],h=vc(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=qc.has(yc(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},Qc=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=vc(e,t),u=await o.detectOverflow(t,l),d=yc(i),f=bc(i),p=Cc(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,y=m-u.left-u.right,b=dc(h-u[g],v),x=dc(m-u[_],y),S=!t.middlewareData.shift,C=b,w=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(w=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),S&&!f){let e=fc(u.left,0),t=fc(u.right,0),n=fc(u.top,0),r=fc(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:fc(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:fc(u.top,u.bottom))}await c({...t,availableWidth:w,availableHeight:C});let T=await o.getDimensions(s.floating);return m!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function $c(){return typeof window<`u`}function el(e){return rl(e)?(e.nodeName||``).toLowerCase():`#document`}function tl(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function nl(e){return((rl(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function rl(e){return $c()?e instanceof Node||e instanceof tl(e).Node:!1}function il(e){return $c()?e instanceof Element||e instanceof tl(e).Element:!1}function al(e){return $c()?e instanceof HTMLElement||e instanceof tl(e).HTMLElement:!1}function ol(e){return!$c()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof tl(e).ShadowRoot}function sl(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=vl(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function cl(e){return/^(table|td|th)$/.test(el(e))}function ll(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var ul=/transform|translate|scale|rotate|perspective|filter/,dl=/paint|layout|strict|content/,fl=e=>!!e&&e!==`none`,pl;function ml(e){let t=il(e)?vl(e):e;return fl(t.transform)||fl(t.translate)||fl(t.scale)||fl(t.rotate)||fl(t.perspective)||!gl()&&(fl(t.backdropFilter)||fl(t.filter))||ul.test(t.willChange||``)||dl.test(t.contain||``)}function hl(e){let t=bl(e);for(;al(t)&&!_l(t);){if(ml(t))return t;if(ll(t))return null;t=bl(t)}return null}function gl(){return pl??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),pl}function _l(e){return/^(html|body|#document)$/.test(el(e))}function vl(e){return tl(e).getComputedStyle(e)}function yl(e){return il(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function bl(e){if(el(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||ol(e)&&e.host||nl(e);return ol(t)?t.host:t}function xl(e){let t=bl(e);return _l(t)?e.ownerDocument?e.ownerDocument.body:e.body:al(t)&&sl(t)?t:xl(t)}function Sl(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=xl(e),i=r===e.ownerDocument?.body,a=tl(r);if(i){let e=Cl(a);return t.concat(a,a.visualViewport||[],sl(r)?r:[],e&&n?Sl(e):[])}else return t.concat(r,Sl(r,[],n))}function Cl(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function wl(e){let t=vl(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=al(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=pc(n)!==a||pc(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Tl(e){return il(e)?e:e.contextElement}function El(e){let t=Tl(e);if(!al(t))return hc(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=wl(t),o=(a?pc(n.width):n.width)/r,s=(a?pc(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Dl=hc(0);function Ol(e){let t=tl(e);return!gl()||!t.visualViewport?Dl:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function kl(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==tl(e)?!1:t}function Al(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Tl(e),o=hc(1);t&&(r?il(r)&&(o=El(r)):o=El(e));let s=kl(a,n,r)?Ol(a):hc(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){let e=tl(a),t=r&&il(r)?tl(r):r,n=e,i=Cl(n);for(;i&&r&&t!==n;){let e=El(i),t=i.getBoundingClientRect(),r=vl(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=tl(i),i=Cl(n)}}return Lc({width:u,height:d,x:c,y:l})}function jl(e,t){let n=yl(e).scrollLeft;return t?t.left+n:Al(nl(e)).left+n}function Ml(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-jl(e,n),y:n.top+t.scrollTop}}function Nl(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=nl(r),s=t?ll(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=hc(1),u=hc(0),d=al(r);if((d||!d&&!a)&&((el(r)!==`body`||sl(o))&&(c=yl(r)),d)){let e=Al(r);l=El(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Ml(o,c):hc(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 Pl(e){return Array.from(e.getClientRects())}function Fl(e){let t=nl(e),n=yl(e),r=e.ownerDocument.body,i=fc(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=fc(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+jl(e),s=-n.scrollTop;return vl(r).direction===`rtl`&&(o+=fc(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var Il=25;function Ll(e,t){let n=tl(e),r=nl(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=gl();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=jl(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=Il&&(a-=o)}else l<=Il&&(a+=l);return{width:a,height:o,x:s,y:c}}function Rl(e,t){let n=Al(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=al(e)?El(e):hc(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function zl(e,t,n){let r;if(t===`viewport`)r=Ll(e,n);else if(t===`document`)r=Fl(nl(e));else if(il(t))r=Rl(t,n);else{let n=Ol(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Lc(r)}function Bl(e,t){let n=bl(e);return n===t||!il(n)||_l(n)?!1:vl(n).position===`fixed`||Bl(n,t)}function Vl(e,t){let n=t.get(e);if(n)return n;let r=Sl(e,[],!1).filter(e=>il(e)&&el(e)!==`body`),i=null,a=vl(e).position===`fixed`,o=a?bl(e):e;for(;il(o)&&!_l(o);){let t=vl(o),n=ml(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||sl(o)&&!n&&Bl(e,o))?r=r.filter(e=>e!==o):i=t,o=bl(o)}return t.set(e,r),r}function Hl(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?ll(t)?[]:Vl(t,this._c):[].concat(n),r],o=zl(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=zl(t,a[e],i);s=fc(n.top,s),c=dc(n.right,c),l=dc(n.bottom,l),u=fc(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Ul(e){let{width:t,height:n}=wl(e);return{width:t,height:n}}function Wl(e,t,n){let r=al(t),i=nl(t),a=n===`fixed`,o=Al(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=hc(0);function l(){c.x=jl(i)}if(r||!r&&!a)if((el(t)!==`body`||sl(i))&&(s=yl(t)),r){let e=Al(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?Ml(i,s):hc(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function Gl(e){return vl(e).position===`static`}function Kl(e,t){if(!al(e)||vl(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return nl(e)===n&&(n=n.ownerDocument.body),n}function ql(e,t){let n=tl(e);if(ll(e))return n;if(!al(e)){let t=bl(e);for(;t&&!_l(t);){if(il(t)&&!Gl(t))return t;t=bl(t)}return n}let r=Kl(e,t);for(;r&&cl(r)&&Gl(r);)r=Kl(r,t);return r&&_l(r)&&Gl(r)&&!ml(r)?n:r||hl(e)||n}var Jl=async function(e){let t=this.getOffsetParent||ql,n=this.getDimensions,r=await n(e.floating);return{reference:Wl(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Yl(e){return vl(e).direction===`rtl`}var Xl={convertOffsetParentRelativeRectToViewportRelativeRect:Nl,getDocumentElement:nl,getClippingRect:Hl,getOffsetParent:ql,getElementRects:Jl,getClientRects:Pl,getDimensions:Ul,getScale:El,isElement:il,isRTL:Yl};function Zl(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Ql(e,t){let n=null,r,i=nl(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=mc(d),h=mc(i.clientWidth-(u+f)),g=mc(i.clientHeight-(d+p)),_=mc(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:fc(0,dc(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!Zl(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function $l(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=Tl(e),u=i||a?[...l?Sl(l):[],...t?Sl(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?Ql(l,n):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?Al(e):null;c&&g();function g(){let t=Al(e);h&&!Zl(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?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var eu=Yc,tu=Xc,nu=Uc,ru=Qc,iu=Kc,au=Hc,ou=Zc,su=(e,t,n)=>{let r=new Map,i={platform:Xl,...n},a={...i.platform,_c:r};return Vc(e,t,{...i,platform:a})},cu=typeof document<`u`?_.useLayoutEffect:function(){};function lu(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(!lu(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)&&!lu(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function uu(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function du(e,t){let n=uu(e);return Math.round(t*n)/n}function fu(e){let t=_.useRef(e);return cu(()=>{t.current=e}),t}function pu(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=_.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=_.useState(r);lu(f,r)||p(r);let[m,h]=_.useState(null),[g,v]=_.useState(null),y=_.useCallback(e=>{e!==C.current&&(C.current=e,h(e))},[]),b=_.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||m,S=o||g,C=_.useRef(null),w=_.useRef(null),T=_.useRef(u),E=c!=null,D=fu(c),O=fu(i),k=fu(l),A=_.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),su(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!lu(T.current,t)&&(T.current=t,ft.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);cu(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=_.useRef(!1);cu(()=>(j.current=!0,()=>{j.current=!1}),[]),cu(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=_.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=_.useMemo(()=>({reference:x,floating:S}),[x,S]),P=_.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=du(N.floating,u.x),r=du(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...uu(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return _.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:P}),[u,A,M,N,P])}var mu=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?{}:au({element:r.current,padding:i}).fn(n):r?au({element:r,padding:i}).fn(n):{}}}},hu=(e,t)=>{let n=eu(e);return{name:n.name,fn:n.fn,options:[e,t]}},gu=(e,t)=>{let n=tu(e);return{name:n.name,fn:n.fn,options:[e,t]}},_u=(e,t)=>({fn:ou(e).fn,options:[e,t]}),vu=(e,t)=>{let n=nu(e);return{name:n.name,fn:n.fn,options:[e,t]}},yu=(e,t)=>{let n=ru(e);return{name:n.name,fn:n.fn,options:[e,t]}},bu=(e,t)=>{let n=iu(e);return{name:n.name,fn:n.fn,options:[e,t]}},xu=(e,t)=>{let n=mu(e);return{name:n.name,fn:n.fn,options:[e,t]}},Su=`Arrow`,Cu=_.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,G.jsx)(Bi.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,G.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});Cu.displayName=Su;var wu=Cu,Tu=`Popper`,[Eu,Du]=qi(Tu),[Ou,ku]=Eu(Tu),Au=e=>{let{__scopePopper:t,children:n}=e,[r,i]=_.useState(null);return(0,G.jsx)(Ou,{scope:t,anchor:r,onAnchorChange:i,children:n})};Au.displayName=Tu;var ju=`PopperAnchor`,Mu=_.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=ku(ju,n),o=_.useRef(null),s=ji(t,o),c=_.useRef(null);return _.useEffect(()=>{let e=c.current;c.current=r?.current||o.current,e!==c.current&&a.onAnchorChange(c.current)}),r?null:(0,G.jsx)(Bi.div,{...i,ref:s})});Mu.displayName=ju;var Nu=`PopperContent`,[Pu,Fu]=Eu(Nu),Iu=_.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=ku(Nu,n),[v,y]=_.useState(null),b=ji(t,e=>y(e)),[x,S]=_.useState(null),C=lc(x),w=C?.width??0,T=C?.height??0,E=r+(a===`center`?``:`-`+a),D=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},O=Array.isArray(l)?l:[l],k=O.length>0,A={padding:D,boundary:O.filter(Bu),altBoundary:k},{refs:j,floatingStyles:M,placement:N,isPositioned:P,middlewareData:F}=pu({strategy:`fixed`,placement:E,whileElementsMounted:(...e)=>$l(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[hu({mainAxis:i+T,alignmentAxis:o}),c&&gu({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?_u():void 0,...A}),c&&vu({...A}),yu({...A,apply:({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`)}}),x&&xu({element:x,padding:s}),Vu({arrowWidth:w,arrowHeight:T}),f&&bu({strategy:`referenceHidden`,...A})]}),[I,L]=Hu(N),R=xa(m);Yi(()=>{P&&R?.()},[P,R]);let z=F.arrow?.x,B=F.arrow?.y,V=F.arrow?.centerOffset!==0,[H,U]=_.useState();return Yi(()=>{v&&U(window.getComputedStyle(v).zIndex)},[v]),(0,G.jsx)(`div`,{ref:j.setFloating,"data-radix-popper-content-wrapper":``,style:{...M,transform:P?M.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:H,"--radix-popper-transform-origin":[F.transformOrigin?.x,F.transformOrigin?.y].join(` `),...F.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,G.jsx)(Pu,{scope:n,placedSide:I,onArrowChange:S,arrowX:z,arrowY:B,shouldHideArrow:V,children:(0,G.jsx)(Bi.div,{"data-side":I,"data-align":L,...h,ref:b,style:{...h.style,animation:P?void 0:`none`}})})})});Iu.displayName=Nu;var Lu=`PopperArrow`,Ru={top:`bottom`,right:`left`,bottom:`top`,left:`right`},zu=_.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Fu(Lu,n),a=Ru[i.placedSide];return(0,G.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,G.jsx)(wu,{...r,ref:t,style:{...r.style,display:`block`}})})});zu.displayName=Lu;function Bu(e){return e!==null}var Vu=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Hu(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function Hu(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var Uu=Au,Wu=Mu,Gu=Iu,Ku=zu,qu=`Popover`,[Ju,Yu]=qi(qu,[Du]),Xu=Du(),[Zu,Qu]=Ju(qu),$u=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=Xu(t),c=_.useRef(null),[l,u]=_.useState(!1),[d,f]=Zi({prop:r,defaultProp:i??!1,onChange:a,caller:qu});return(0,G.jsx)(Uu,{...s,children:(0,G.jsx)(Zu,{scope:t,contentId:sa(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:_.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:_.useCallback(()=>u(!0),[]),onCustomAnchorRemove:_.useCallback(()=>u(!1),[]),modal:o,children:n})})};$u.displayName=qu;var ed=`PopoverAnchor`,td=_.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Qu(ed,n),a=Xu(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return _.useEffect(()=>(o(),()=>s()),[o,s]),(0,G.jsx)(Wu,{...a,...r,ref:t})});td.displayName=ed;var nd=`PopoverTrigger`,rd=_.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Qu(nd,n),a=Xu(n),o=ji(t,i.triggerRef),s=(0,G.jsx)(Bi.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":vd(i.open),...r,ref:o,onClick:K(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,G.jsx)(Wu,{asChild:!0,...a,children:s})});rd.displayName=nd;var id=`PopoverPortal`,[ad,od]=Ju(id,{forceMount:void 0}),sd=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=Qu(id,t);return(0,G.jsx)(ad,{scope:t,forceMount:n,children:(0,G.jsx)(ta,{present:n||a.open,children:(0,G.jsx)($a,{asChild:!0,container:i,children:r})})})};sd.displayName=id;var cd=`PopoverContent`,ld=_.forwardRef((e,t)=>{let n=od(cd,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=Qu(cd,e.__scopePopover);return(0,G.jsx)(ta,{present:r||a.open,children:a.modal?(0,G.jsx)(dd,{...i,ref:t}):(0,G.jsx)(fd,{...i,ref:t})})});ld.displayName=cd;var ud=Mi(`PopoverContent.RemoveScroll`),dd=_.forwardRef((e,t)=>{let n=Qu(cd,e.__scopePopover),r=_.useRef(null),i=ji(t,r),a=_.useRef(!1);return _.useEffect(()=>{let e=r.current;if(e)return xs(e)},[]),(0,G.jsx)(fs,{as:ud,allowPinchZoom:!0,children:(0,G.jsx)(pd,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:K(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:K(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;a.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:K(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),fd=_.forwardRef((e,t)=>{let n=Qu(cd,e.__scopePopover),r=_.useRef(!1),i=_.useRef(!1);return(0,G.jsx)(pd,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),pd=_.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=Qu(cd,n),p=Xu(n);return to(),(0,G.jsx)(Ba,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,G.jsx)(ka,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,G.jsx)(Gu,{"data-state":vd(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),md=`PopoverClose`,hd=_.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Qu(md,n);return(0,G.jsx)(Bi.button,{type:`button`,...r,ref:t,onClick:K(e.onClick,()=>i.onOpenChange(!1))})});hd.displayName=md;var gd=`PopoverArrow`,_d=_.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Xu(n);return(0,G.jsx)(Ku,{...i,...r,ref:t})});_d.displayName=gd;function vd(e){return e?`open`:`closed`}var yd=$u,bd=rd,xd=sd,Sd=ld,Cd=hd,[wd,Td]=qi(`Tooltip`,[Du]),Ed=Du(),Dd=`TooltipProvider`,Od=700,kd=`tooltip.open`,[Ad,jd]=wd(Dd),Md=e=>{let{__scopeTooltip:t,delayDuration:n=Od,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=_.useRef(!0),s=_.useRef(!1),c=_.useRef(0);return _.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,G.jsx)(Ad,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:_.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:_.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:_.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};Md.displayName=Dd;var Nd=`Tooltip`,[Pd,Fd]=wd(Nd),Id=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=jd(Nd,e.__scopeTooltip),l=Ed(t),[u,d]=_.useState(null),f=sa(),p=_.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=_.useRef(!1),[v,y]=Zi({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(kd))):c.onClose(),a?.(e)},caller:Nd}),b=_.useMemo(()=>v?g.current?`delayed-open`:`instant-open`:`closed`,[v]),x=_.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,y(!0)},[y]),S=_.useCallback(()=>{window.clearTimeout(p.current),p.current=0,y(!1)},[y]),C=_.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,y(!0),p.current=0},h)},[h,y]);return _.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,G.jsx)(Uu,{...l,children:(0,G.jsx)(Pd,{scope:t,contentId:f,open:v,stateAttribute:b,trigger:u,onTriggerChange:d,onTriggerEnter:_.useCallback(()=>{c.isOpenDelayedRef.current?C():x()},[c.isOpenDelayedRef,C,x]),onTriggerLeave:_.useCallback(()=>{m?S():(window.clearTimeout(p.current),p.current=0)},[S,m]),onOpen:x,onClose:S,disableHoverableContent:m,children:n})})};Id.displayName=Nd;var Ld=`TooltipTrigger`,Rd=_.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Fd(Ld,n),a=jd(Ld,n),o=Ed(n),s=ji(t,_.useRef(null),i.onTriggerChange),c=_.useRef(!1),l=_.useRef(!1),u=_.useCallback(()=>c.current=!1,[]);return _.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,G.jsx)(Wu,{asChild:!0,...o,children:(0,G.jsx)(Bi.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:K(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:K(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:K(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:K(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:K(e.onBlur,i.onClose),onClick:K(e.onClick,i.onClose)})})});Rd.displayName=Ld;var zd=`TooltipPortal`,[Bd,Vd]=wd(zd,{forceMount:void 0}),Hd=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=Fd(zd,t);return(0,G.jsx)(Bd,{scope:t,forceMount:n,children:(0,G.jsx)(ta,{present:n||a.open,children:(0,G.jsx)($a,{asChild:!0,container:i,children:r})})})};Hd.displayName=zd;var Ud=`TooltipContent`,Wd=_.forwardRef((e,t)=>{let n=Vd(Ud,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=Fd(Ud,e.__scopeTooltip);return(0,G.jsx)(ta,{present:r||o.open,children:o.disableHoverableContent?(0,G.jsx)(Yd,{side:i,...a,ref:t}):(0,G.jsx)(Gd,{side:i,...a,ref:t})})}),Gd=_.forwardRef((e,t)=>{let n=Fd(Ud,e.__scopeTooltip),r=jd(Ud,e.__scopeTooltip),i=_.useRef(null),a=ji(t,i),[o,s]=_.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=_.useCallback(()=>{s(null),d(!1)},[d]),p=_.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=$d(r,Qd(r,n.getBoundingClientRect())),a=ef(t.getBoundingClientRect());s(nf([...i,...a])),d(!0)},[d]);return _.useEffect(()=>()=>f(),[f]),_.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),_.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!tf(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,G.jsx)(Yd,{...e,ref:a})}),[Kd,qd]=wd(Nd,{isInside:!1}),Jd=Ii(`TooltipContent`),Yd=_.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=Fd(Ud,n),l=Ed(n),{onClose:u}=c;return _.useEffect(()=>(document.addEventListener(kd,u),()=>document.removeEventListener(kd,u)),[u]),_.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,G.jsx)(ka,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,G.jsxs)(Gu,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,G.jsx)(Jd,{children:r}),(0,G.jsx)(Kd,{scope:n,isInside:!0,children:(0,G.jsx)(Gi,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});Wd.displayName=Ud;var Xd=`TooltipArrow`,Zd=_.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Ed(n);return qd(Xd,n).isInside?null:(0,G.jsx)(Ku,{...i,...r,ref:t})});Zd.displayName=Xd;function Qd(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function $d(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function ef(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function tf(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}function nf(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),rf(t)}function rf(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var af=Md,of=Id,sf=Rd,cf=Hd,lf=Wd,uf=Zd;function df(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=df(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function ff(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=df(e))&&(r&&(r+=` `),r+=t);return r}var pf=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},mf=(e,t)=>({classGroupId:e,validator:t}),hf=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),gf=`-`,_f=[],vf=`arbitrary..`,yf=e=>{let t=Sf(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return xf(e);let n=e.split(gf);return bf(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?pf(i,t):t:i||_f}return n[e]||_f}}},bf=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=bf(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(gf):e.slice(t).join(gf),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},xf=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?vf+r:void 0})(),Sf=e=>{let{theme:t,classGroups:n}=e;return Cf(n,t)},Cf=(e,t)=>{let n=hf();for(let r in e){let i=e[r];wf(i,n,r,t)}return n},wf=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];Tf(i,t,n,r)}},Tf=(e,t,n,r)=>{if(typeof e==`string`){Ef(e,t,n);return}if(typeof e==`function`){Df(e,t,n,r);return}Of(e,t,n,r)},Ef=(e,t,n)=>{let r=e===``?t:kf(t,e);r.classGroupId=n},Df=(e,t,n,r)=>{if(Af(e)){wf(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(mf(n,e))},Of=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];wf(o,kf(t,a),n,r)}},kf=(e,t)=>{let n=e,r=t.split(gf),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=hf(),n.nextPart.set(t,i)),n=i}return n},Af=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,jf=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},Mf=`!`,Nf=`:`,Pf=[],Ff=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),If=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===Nf){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(Mf)?(c=s.slice(0,-1),l=!0):s.startsWith(Mf)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return Ff(t,l,c,u)};if(t){let e=t+Nf,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):Ff(Pf,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},Lf=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},Rf=e=>({cache:jf(e.cacheSize),parseClassName:If(e),sortModifiers:Lf(e),postfixLookupClassGroupIds:zf(e),...yf(e)}),zf=e=>{let t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let e=0;e<n.length;e++)t[n[e]]=!0;return t},Bf=/\s+/,Vf=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(Bf),l=``;for(let e=c.length-1;e>=0;--e){let t=c[e],{isExternal:u,modifiers:d,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}=n(t);if(u){l=t+(l.length>0?` `+l:l);continue}let h=!!m,g;if(h){g=r(p.substring(0,m));let e=g&&o[g]?r(p):void 0;e&&e!==g&&(g=e,h=!1)}else g=r(p);if(!g){if(!h){l=t+(l.length>0?` `+l:l);continue}if(g=r(p),!g){l=t+(l.length>0?` `+l:l);continue}h=!1}let _=d.length===0?``:d.length===1?d[0]:a(d).join(`:`),v=f?_+Mf:_,y=v+g;if(s.indexOf(y)>-1)continue;s.push(y);let b=i(g,h);for(let e=0;e<b.length;++e){let t=b[e];s.push(v+t)}l=t+(l.length>0?` `+l:l)}return l},Hf=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=Uf(n))&&(i&&(i+=` `),i+=r);return i},Uf=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=Uf(e[r]))&&(n&&(n+=` `),n+=t);return n},Wf=(e,...t)=>{let n,r,i,a,o=o=>(n=Rf(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=Vf(e,n);return i(e,a),a};return a=o,(...e)=>a(Hf(...e))},Gf=[],Kf=e=>{let t=t=>t[e]||Gf;return t.isThemeGetter=!0,t},qf=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Jf=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Yf=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Xf=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Zf=/\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$/,Qf=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,$f=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ep=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,tp=e=>Yf.test(e),np=e=>!!e&&!Number.isNaN(Number(e)),rp=e=>!!e&&Number.isInteger(Number(e)),ip=e=>e.endsWith(`%`)&&np(e.slice(0,-1)),ap=e=>Xf.test(e),op=()=>!0,sp=e=>Zf.test(e)&&!Qf.test(e),cp=()=>!1,lp=e=>$f.test(e),up=e=>ep.test(e),dp=e=>!q(e)&&!J(e),fp=e=>e.startsWith(`@container`)&&(e[10]===`/`&&e[11]!==void 0||e[11]===`s`&&e[16]!==void 0&&e.startsWith(`-size/`,10)||e[11]===`n`&&e[18]!==void 0&&e.startsWith(`-normal/`,10)),pp=e=>Op(e,Mp,cp),q=e=>qf.test(e),mp=e=>Op(e,Np,sp),hp=e=>Op(e,Pp,np),gp=e=>Op(e,Ip,op),_p=e=>Op(e,Fp,cp),vp=e=>Op(e,Ap,cp),yp=e=>Op(e,jp,up),bp=e=>Op(e,Lp,lp),J=e=>Jf.test(e),xp=e=>kp(e,Np),Sp=e=>kp(e,Fp),Cp=e=>kp(e,Ap),wp=e=>kp(e,Mp),Tp=e=>kp(e,jp),Ep=e=>kp(e,Lp,!0),Dp=e=>kp(e,Ip,!0),Op=(e,t,n)=>{let r=qf.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},kp=(e,t,n=!1)=>{let r=Jf.exec(e);return r?r[1]?t(r[1]):n:!1},Ap=e=>e===`position`||e===`percentage`,jp=e=>e===`image`||e===`url`,Mp=e=>e===`length`||e===`size`||e===`bg-size`,Np=e=>e===`length`,Pp=e=>e===`number`,Fp=e=>e===`family-name`,Ip=e=>e===`number`||e===`weight`,Lp=e=>e===`shadow`,Rp=Wf(()=>{let e=Kf(`color`),t=Kf(`font`),n=Kf(`text`),r=Kf(`font-weight`),i=Kf(`tracking`),a=Kf(`leading`),o=Kf(`breakpoint`),s=Kf(`container`),c=Kf(`spacing`),l=Kf(`radius`),u=Kf(`shadow`),d=Kf(`inset-shadow`),f=Kf(`text-shadow`),p=Kf(`drop-shadow`),m=Kf(`blur`),h=Kf(`perspective`),g=Kf(`aspect`),_=Kf(`ease`),v=Kf(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),J,q],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[J,q,c],T=()=>[tp,`full`,`auto`,...w()],E=()=>[rp,`none`,`subgrid`,J,q],D=()=>[`auto`,{span:[`full`,rp,J,q]},rp,J,q],O=()=>[rp,`auto`,J,q],k=()=>[`auto`,`min`,`max`,`fr`,J,q],A=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],j=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],M=()=>[`auto`,...w()],N=()=>[tp,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],P=()=>[tp,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],F=()=>[tp,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],I=()=>[e,J,q],L=()=>[...b(),Cp,vp,{position:[J,q]}],R=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],z=()=>[`auto`,`cover`,`contain`,wp,pp,{size:[J,q]}],B=()=>[ip,xp,mp],V=()=>[``,`none`,`full`,l,J,q],H=()=>[``,np,xp,mp],U=()=>[`solid`,`dashed`,`dotted`,`double`],ee=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],W=()=>[np,ip,Cp,vp],te=()=>[``,`none`,m,J,q],ne=()=>[`none`,np,J,q],re=()=>[`none`,np,J,q],ie=()=>[np,J,q],ae=()=>[tp,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[ap],breakpoint:[ap],color:[op],container:[ap],"drop-shadow":[ap],ease:[`in`,`out`,`in-out`],font:[dp],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[ap],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[ap],shadow:[ap],spacing:[`px`,np],text:[ap],"text-shadow":[ap],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,tp,q,J,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,J,q]}],"container-named":[fp],columns:[{columns:[np,q,J,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[rp,`auto`,J,q]}],basis:[{basis:[tp,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[np,tp,`auto`,`initial`,`none`,q]}],grow:[{grow:[``,np,J,q]}],shrink:[{shrink:[``,np,J,q]}],order:[{order:[rp,`first`,`last`,`none`,J,q]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":k()}],"auto-rows":[{"auto-rows":k()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...A(),`normal`]}],"justify-items":[{"justify-items":[...j(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...j()]}],"align-content":[{content:[`normal`,...A()]}],"align-items":[{items:[...j(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...j(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":A()}],"place-items":[{"place-items":[...j(),`baseline`]}],"place-self":[{"place-self":[`auto`,...j()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:M()}],mx:[{mx:M()}],my:[{my:M()}],ms:[{ms:M()}],me:[{me:M()}],mbs:[{mbs:M()}],mbe:[{mbe:M()}],mt:[{mt:M()}],mr:[{mr:M()}],mb:[{mb:M()}],ml:[{ml:M()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:N()}],"inline-size":[{inline:[`auto`,...P()]}],"min-inline-size":[{"min-inline":[`auto`,...P()]}],"max-inline-size":[{"max-inline":[`none`,...P()]}],"block-size":[{block:[`auto`,...F()]}],"min-block-size":[{"min-block":[`auto`,...F()]}],"max-block-size":[{"max-block":[`none`,...F()]}],w:[{w:[s,`screen`,...N()]}],"min-w":[{"min-w":[s,`screen`,`none`,...N()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...N()]}],h:[{h:[`screen`,`lh`,...N()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...N()]}],"max-h":[{"max-h":[`screen`,`lh`,...N()]}],"font-size":[{text:[`base`,n,xp,mp]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,Dp,gp]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,ip,q]}],"font-family":[{font:[Sp,_p,t]}],"font-features":[{"font-features":[q]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,J,q]}],"line-clamp":[{"line-clamp":[np,`none`,J,hp]}],leading:[{leading:[a,...w()]}],"list-image":[{"list-image":[`none`,J,q]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,J,q]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:I()}],"text-color":[{text:I()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...U(),`wavy`]}],"text-decoration-thickness":[{decoration:[np,`from-font`,`auto`,J,mp]}],"text-decoration-color":[{decoration:I()}],"underline-offset":[{"underline-offset":[np,`auto`,J,q]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"tab-size":[{tab:[rp,J,q]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,J,q]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,J,q]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:L()}],"bg-repeat":[{bg:R()}],"bg-size":[{bg:z()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},rp,J,q],radial:[``,J,q],conic:[rp,J,q]},Tp,yp]}],"bg-color":[{bg:I()}],"gradient-from-pos":[{from:B()}],"gradient-via-pos":[{via:B()}],"gradient-to-pos":[{to:B()}],"gradient-from":[{from:I()}],"gradient-via":[{via:I()}],"gradient-to":[{to:I()}],rounded:[{rounded:V()}],"rounded-s":[{"rounded-s":V()}],"rounded-e":[{"rounded-e":V()}],"rounded-t":[{"rounded-t":V()}],"rounded-r":[{"rounded-r":V()}],"rounded-b":[{"rounded-b":V()}],"rounded-l":[{"rounded-l":V()}],"rounded-ss":[{"rounded-ss":V()}],"rounded-se":[{"rounded-se":V()}],"rounded-ee":[{"rounded-ee":V()}],"rounded-es":[{"rounded-es":V()}],"rounded-tl":[{"rounded-tl":V()}],"rounded-tr":[{"rounded-tr":V()}],"rounded-br":[{"rounded-br":V()}],"rounded-bl":[{"rounded-bl":V()}],"border-w":[{border:H()}],"border-w-x":[{"border-x":H()}],"border-w-y":[{"border-y":H()}],"border-w-s":[{"border-s":H()}],"border-w-e":[{"border-e":H()}],"border-w-bs":[{"border-bs":H()}],"border-w-be":[{"border-be":H()}],"border-w-t":[{"border-t":H()}],"border-w-r":[{"border-r":H()}],"border-w-b":[{"border-b":H()}],"border-w-l":[{"border-l":H()}],"divide-x":[{"divide-x":H()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":H()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...U(),`hidden`,`none`]}],"divide-style":[{divide:[...U(),`hidden`,`none`]}],"border-color":[{border:I()}],"border-color-x":[{"border-x":I()}],"border-color-y":[{"border-y":I()}],"border-color-s":[{"border-s":I()}],"border-color-e":[{"border-e":I()}],"border-color-bs":[{"border-bs":I()}],"border-color-be":[{"border-be":I()}],"border-color-t":[{"border-t":I()}],"border-color-r":[{"border-r":I()}],"border-color-b":[{"border-b":I()}],"border-color-l":[{"border-l":I()}],"divide-color":[{divide:I()}],"outline-style":[{outline:[...U(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[np,J,q]}],"outline-w":[{outline:[``,np,xp,mp]}],"outline-color":[{outline:I()}],shadow:[{shadow:[``,`none`,u,Ep,bp]}],"shadow-color":[{shadow:I()}],"inset-shadow":[{"inset-shadow":[`none`,d,Ep,bp]}],"inset-shadow-color":[{"inset-shadow":I()}],"ring-w":[{ring:H()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:I()}],"ring-offset-w":[{"ring-offset":[np,mp]}],"ring-offset-color":[{"ring-offset":I()}],"inset-ring-w":[{"inset-ring":H()}],"inset-ring-color":[{"inset-ring":I()}],"text-shadow":[{"text-shadow":[`none`,f,Ep,bp]}],"text-shadow-color":[{"text-shadow":I()}],opacity:[{opacity:[np,J,q]}],"mix-blend":[{"mix-blend":[...ee(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":ee()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[np]}],"mask-image-linear-from-pos":[{"mask-linear-from":W()}],"mask-image-linear-to-pos":[{"mask-linear-to":W()}],"mask-image-linear-from-color":[{"mask-linear-from":I()}],"mask-image-linear-to-color":[{"mask-linear-to":I()}],"mask-image-t-from-pos":[{"mask-t-from":W()}],"mask-image-t-to-pos":[{"mask-t-to":W()}],"mask-image-t-from-color":[{"mask-t-from":I()}],"mask-image-t-to-color":[{"mask-t-to":I()}],"mask-image-r-from-pos":[{"mask-r-from":W()}],"mask-image-r-to-pos":[{"mask-r-to":W()}],"mask-image-r-from-color":[{"mask-r-from":I()}],"mask-image-r-to-color":[{"mask-r-to":I()}],"mask-image-b-from-pos":[{"mask-b-from":W()}],"mask-image-b-to-pos":[{"mask-b-to":W()}],"mask-image-b-from-color":[{"mask-b-from":I()}],"mask-image-b-to-color":[{"mask-b-to":I()}],"mask-image-l-from-pos":[{"mask-l-from":W()}],"mask-image-l-to-pos":[{"mask-l-to":W()}],"mask-image-l-from-color":[{"mask-l-from":I()}],"mask-image-l-to-color":[{"mask-l-to":I()}],"mask-image-x-from-pos":[{"mask-x-from":W()}],"mask-image-x-to-pos":[{"mask-x-to":W()}],"mask-image-x-from-color":[{"mask-x-from":I()}],"mask-image-x-to-color":[{"mask-x-to":I()}],"mask-image-y-from-pos":[{"mask-y-from":W()}],"mask-image-y-to-pos":[{"mask-y-to":W()}],"mask-image-y-from-color":[{"mask-y-from":I()}],"mask-image-y-to-color":[{"mask-y-to":I()}],"mask-image-radial":[{"mask-radial":[J,q]}],"mask-image-radial-from-pos":[{"mask-radial-from":W()}],"mask-image-radial-to-pos":[{"mask-radial-to":W()}],"mask-image-radial-from-color":[{"mask-radial-from":I()}],"mask-image-radial-to-color":[{"mask-radial-to":I()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[np]}],"mask-image-conic-from-pos":[{"mask-conic-from":W()}],"mask-image-conic-to-pos":[{"mask-conic-to":W()}],"mask-image-conic-from-color":[{"mask-conic-from":I()}],"mask-image-conic-to-color":[{"mask-conic-to":I()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:L()}],"mask-repeat":[{mask:R()}],"mask-size":[{mask:z()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,J,q]}],filter:[{filter:[``,`none`,J,q]}],blur:[{blur:te()}],brightness:[{brightness:[np,J,q]}],contrast:[{contrast:[np,J,q]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,Ep,bp]}],"drop-shadow-color":[{"drop-shadow":I()}],grayscale:[{grayscale:[``,np,J,q]}],"hue-rotate":[{"hue-rotate":[np,J,q]}],invert:[{invert:[``,np,J,q]}],saturate:[{saturate:[np,J,q]}],sepia:[{sepia:[``,np,J,q]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,J,q]}],"backdrop-blur":[{"backdrop-blur":te()}],"backdrop-brightness":[{"backdrop-brightness":[np,J,q]}],"backdrop-contrast":[{"backdrop-contrast":[np,J,q]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,np,J,q]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[np,J,q]}],"backdrop-invert":[{"backdrop-invert":[``,np,J,q]}],"backdrop-opacity":[{"backdrop-opacity":[np,J,q]}],"backdrop-saturate":[{"backdrop-saturate":[np,J,q]}],"backdrop-sepia":[{"backdrop-sepia":[``,np,J,q]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,J,q]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[np,`initial`,J,q]}],ease:[{ease:[`linear`,`initial`,_,J,q]}],delay:[{delay:[np,J,q]}],animate:[{animate:[`none`,v,J,q]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,J,q]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:ne()}],"rotate-x":[{"rotate-x":ne()}],"rotate-y":[{"rotate-y":ne()}],"rotate-z":[{"rotate-z":ne()}],scale:[{scale:re()}],"scale-x":[{"scale-x":re()}],"scale-y":[{"scale-y":re()}],"scale-z":[{"scale-z":re()}],"scale-3d":[`scale-3d`],skew:[{skew:ie()}],"skew-x":[{"skew-x":ie()}],"skew-y":[{"skew-y":ie()}],transform:[{transform:[J,q,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:ae()}],"translate-x":[{"translate-x":ae()}],"translate-y":[{"translate-y":ae()}],"translate-z":[{"translate-z":ae()}],"translate-none":[`translate-none`],zoom:[{zoom:[rp,J,q]}],accent:[{accent:I()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:I()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,J,q]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scrollbar-thumb-color":[{"scrollbar-thumb":I()}],"scrollbar-track-color":[{"scrollbar-track":I()}],"scrollbar-gutter":[{"scrollbar-gutter":[`auto`,`stable`,`both`]}],"scrollbar-w":[{scrollbar:[`auto`,`thin`,`none`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,J,q]}],fill:[{fill:[`none`,...I()]}],"stroke-w":[{stroke:[np,xp,mp,hp]}],stroke:[{stroke:[`none`,...I()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{"container-named":[`container-type`],overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},postfixLookupClassGroups:[`container-type`],orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function Y(...e){return Rp(ff(e))}function zp({delayDuration:e=0,...t}){return(0,G.jsx)(af,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Bp({...e}){return(0,G.jsx)(of,{"data-slot":`tooltip`,...e})}function Vp({...e}){return(0,G.jsx)(sf,{"data-slot":`tooltip-trigger`,...e})}function Hp({className:e,sideOffset:t=4,children:n,...r}){return(0,G.jsx)(cf,{children:(0,G.jsxs)(lf,{"data-slot":`tooltip-content`,sideOffset:t,className:Y(`z-50 overflow-hidden rounded-md bg-gray-900 px-3 py-1.5 text-xs text-gray-100 shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 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`,e),...r,children:[n,(0,G.jsx)(uf,{className:`fill-gray-900`})]})})}var X=(e,t)=>fetch(e,{credentials:`include`,...t}),Up=null;function Wp(){return Up||=X(`/api/health`).then(e=>e.json()).then(e=>typeof e?.workspace==`string`?e.workspace:`loopat`).catch(()=>`loopat`),Up}async function Gp(){let e=await X(`/api/auth/me`);return e.ok?(await e.json()).user??null:null}async function Kp(e,t){let n=await X(`/api/auth/login`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({username:e,password:t})}),r=await n.json().catch(()=>({}));return n.ok?{user:r.user}:{error:r.error??`login failed (${n.status})`}}async function qp(e){let t=await X(`/api/auth/register`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),n=await t.json().catch(()=>({}));return t.ok?{user:n.user,publicKey:n.publicKey,personalRepo:n.personalRepo??null,needsImport:!!n.needsImport}:{error:n.error??`register failed (${t.status})`}}async function Jp(e){let t=await X(`/api/personal/repos`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({token:e})}),n=await t.json().catch(()=>({}));return t.ok?{ok:n.ok!==!1,repos:Array.isArray(n.repos)?n.repos:[],login:n.login,error:n.error}:{ok:!1,repos:[],error:n?.error??`request failed`}}async function Yp(){let e=await X(`/api/personal/status`);return e.ok?await e.json():null}async function Xp(e){let t=await X(`/api/personal/crypt-key`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({password:e})}),n=await t.json().catch(()=>({}));return t.ok?typeof n.cryptKey==`string`?{ok:!0,cryptKey:n.cryptKey}:{ok:!1,error:`missing cryptKey in response`}:{ok:!1,error:n.error??`request failed (${t.status})`,wrongPassword:t.status===403}}async function Zp(e,t=!1){let n=await X(`/api/personal/delete`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({password:e,force:t})}),r=await n.json().catch(()=>({}));return n.ok?{ok:!0,synced:r.synced,dataLost:r.dataLost}:{ok:!1,error:r.error??`delete failed (${n.status})`,wrongPassword:n.status===403,syncFailed:r.syncFailed,uncommitted:r.uncommitted,unpushed:r.unpushed,hasRemote:r.hasRemote}}async function Qp(e){let t=await X(`/api/personal/pull`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({force:e?.force??!1})}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0,message:n.message}:{ok:!1,error:n.error??`pull failed (${t.status})`,conflict:n.conflict,files:n.files,needsStash:n.needsStash}}async function $p(){let e=await X(`/api/personal/push`,{method:`POST`}),t=await e.json().catch(()=>({}));return e.ok?{ok:!0,message:t.message}:{ok:!1,error:t.error??`push failed (${e.status})`,conflict:t.conflict,files:t.files,needsPull:t.needsPull}}async function em(e,t){let n={};e&&(n.repoUrl=e),t&&(n.cryptKey=t);let r=await X(`/api/personal/import`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}),i=await r.json().catch(()=>({}));return r.ok?{ok:!0,autoInitialized:!!i.autoInitialized,cryptKey:typeof i.cryptKey==`string`?i.cryptKey:null}:{ok:!1,error:i.error??`import failed (${r.status})`,needsCryptKey:!!i.needsCryptKey,notClean:!!i.notClean,secretsExposed:!!i.secretsExposed,exposedFiles:Array.isArray(i.exposedFiles)?i.exposedFiles:[]}}async function tm(e,t,n,r){let i={token:e};t&&(i.repoName=t),n&&(i.cryptKey=n),r&&(i.baseUrl=r);let a=await X(`/api/personal/github`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(i)}),o=await a.json().catch(()=>({}));return a.ok?{ok:!0,repo:typeof o.repo==`string`?o.repo:void 0,created:!!o.created,autoInitialized:!!o.autoInitialized,cryptKey:typeof o.cryptKey==`string`?o.cryptKey:null}:{ok:!1,error:o.error??`github setup failed (${a.status})`,needsCryptKey:!!o.needsCryptKey}}async function nm(){await X(`/api/auth/logout`,{method:`POST`}).catch(()=>{})}async function rm(e=`active`){let t=await X(`/api/loops`+(e===`all`?`?archived=all`:e===`archived`?`?archived=true`:``));return t.ok?(await t.json()).loops:[]}async function im(e){if(e.knowledgeRw||e.mountAllLoops){let t={title:e.title,repo:e.repo,profiles:e.profiles,vault:e.vault};return e.knowledgeRw&&(t.knowledge_rw=!0),e.mountAllLoops&&(t.mount_all_loops=!0),await(await X(`/api/loops`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)})).json()}let t=await X(`/api/v1/loops`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({title:e.title,profiles:e.profiles,vault:e.vault,repo:e.repo})});if(!t.ok)throw Error(`createLoop failed (${t.status})`);let n=await t.json();return{id:n.id.startsWith(`loop_`)?n.id.slice(5):n.id,title:n.title,createdAt:n.created_at,createdBy:n.created_by,archived:n.archived,repo:n.repo??void 0,config:{profiles:n.profiles,vault:n.vault}}}async function am(){let e=await X(`/api/profiles`);return e.ok?(await e.json()).profiles??[]:[]}async function om(){let e=await X(`/api/personal/default-profiles`);if(!e.ok)return[];let t=await e.json();return Array.isArray(t.default_profiles)?t.default_profiles:[]}async function sm(e){let t=await X(`/api/loop-stats?profiles=${encodeURIComponent(e.join(`,`))}`);return t.ok?await t.json():null}async function cm(){let e=await X(`/api/vaults`);if(!e.ok)return[];let t=await e.json();return Array.isArray(t.vaults)?t.vaults:[]}async function lm(e){return(await X(`/api/loops/${e}/viewed`,{method:`POST`})).ok}async function um(e,t){let n=await X(`/api/loops/${e}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({archived:t})});return n.ok?await n.json():null}async function dm(e,t){let n=await X(`/api/loops/${e}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({public:t})});return n.ok?await n.json():null}async function fm(e,t){let n=await X(`/api/loops/${e}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({title:t})});return n.ok?await n.json():null}async function pm(e){let t=await X(`/api/loops/${e}/request-drive`,{method:`POST`});return t.ok?await t.json():null}async function mm(e){let t=await X(`/api/loops/${e}/drive`,{method:`POST`});return t.ok?await t.json():null}async function hm(e){let t=await X(`/api/loops/${e}/distill`,{method:`POST`});return t.ok?await t.json():null}async function gm(e){let t=await X(`/api/loops/${e}`);return t.ok?await t.json():null}async function _m(e){let t=await X(`/api/loops/${e}/strip-thinking`,{method:`POST`});return t.ok?await t.json():{stripped:0,sessionsTouched:0}}async function vm(e,t=``){return(await(await X(`/api/loops/${e}/files?path=${encodeURIComponent(t)}`)).json()).entries??[]}async function ym(e,t=``){return(await(await X(`/api/loops/${e}/files/tree?path=${encodeURIComponent(t)}`)).json()).entries??[]}async function bm(e,t){let n=await X(`/api/loops/${e}/file?path=${encodeURIComponent(t)}`);return n.ok?await n.json():null}async function xm(e,t,n){return(await X(`/api/loops/${e}/file?path=${encodeURIComponent(t)}`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({content:n})})).ok}async function Sm(e,t){return(await X(`/api/loops/${e}/file?path=${encodeURIComponent(t)}`,{method:`DELETE`})).ok}async function Cm(e,t){return(await X(`/api/loops/${e}/folder`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:t})})).ok}async function wm(e,t){let n=new FormData;n.append(`file`,t);let r=await X(`/api/loops/${e}/upload`,{method:`POST`,body:n}),i=await r.json().catch(()=>({}));return r.ok?{ok:!0,path:i.path}:{ok:!1,error:i.error??`upload failed`}}async function Tm(e){let t=await X(`/api/loops/${e}/context`);return t.ok?(await t.json()).mounts??[]:[]}async function Em(e,t=``){let n=await X(`/api/workspace/files?vault=${e}&path=${encodeURIComponent(t)}`);return n.ok?(await n.json()).entries??[]:[]}async function Dm(e){let t=await X(`/api/workspace/files?vault=${e}&flat=1`);return t.ok?(await t.json()).entries??[]:[]}async function Om(e,t){let n=await X(`/api/workspace/file?vault=${e}&path=${encodeURIComponent(t)}`);return n.ok?await n.json():null}async function km(e,t,n){return await(await X(`/api/workspace/file?vault=${e}&path=${encodeURIComponent(t)}`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({content:n})})).json()}async function Am(){let e=await X(`/api/notes/save`,{method:`POST`}),t=await e.json().catch(()=>({}));return e.ok?{ok:!0,message:t.message}:{ok:!1,conflict:t.conflict,files:t.files,needsPull:t.needsPull,error:t.error??`save failed (${e.status})`}}async function jm(){let e=await(await X(`/api/notes/behind`)).json().catch(()=>({}));return typeof e.behind==`number`?e.behind:0}async function Mm(){let e=await(await X(`/api/notes/refresh`,{method:`POST`})).json().catch(()=>({}));return{ok:!!e.ok,diverged:e.diverged,error:e.error}}async function Nm(e,t){return await(await X(`/api/workspace/file?vault=${e}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:t})})).json()}async function Pm(e,t){return await(await X(`/api/workspace/folder?vault=${e}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:t})})).json()}async function Fm(e,t){return await(await X(`/api/workspace/file?vault=${e}&path=${encodeURIComponent(t)}`,{method:`DELETE`})).json()}async function Im(e,t){let n=await X(`/api/workspace/backlinks?vault=${e}&path=${encodeURIComponent(t)}`);return n.ok?(await n.json()).backlinks??[]:[]}async function Lm(){let e=await X(`/api/context/repos`);if(!e.ok)return{notes:null,repos:[]};let t=await e.json();return{notes:t.notes??null,repos:t.repos??[]}}async function Rm(e){let t=await X(`/api/context/repos`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0}:{ok:!1,error:n.error??`http ${t.status}`,savedLocally:n.savedLocally}}async function zm(e){let t=await X(`/api/loops/${e}/chat-history`);return t.ok?(await t.json()).map(e=>e.text):[]}async function Bm(e,t){await X(`/api/loops/${e}/chat-history`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({text:t})})}function Vm(e){return typeof e==`string`?`/api/sync/${e}`:`/api/sync/repos/${encodeURIComponent(e.repo)}`}async function Hm(e){let t=await X(`${Vm(e)}/status`);return t.ok?await t.json():null}async function Um(e){let t=await X(`${Vm(e)}/pull`,{method:`POST`}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0,message:n.message}:{ok:!1,error:n.error??`http ${t.status}`}}async function Wm(e){let t=await X(`${Vm(e)}/push`,{method:`POST`}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0,message:n.message}:{ok:!1,error:n.error??`http ${t.status}`}}async function Gm(e=`default`){let t=await X(`/api/kanban/${encodeURIComponent(e)}`);return t.ok?(await t.json()).columns:[]}async function Km(e,t,n){let r=await X(`/api/kanban/columns/${encodeURIComponent(e)}/${encodeURIComponent(t)}/cards`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}),i=await r.json().catch(()=>({}));return r.ok?{cid:i.cid}:{error:i.error??`add failed`}}async function qm(e,t,n){return(await X(`/api/kanban/columns/${encodeURIComponent(e)}/${encodeURIComponent(t)}/cards/${encodeURIComponent(n)}/toggle`,{method:`PATCH`})).ok}async function Jm(e,t,n,r){return(await X(`/api/kanban/columns/${encodeURIComponent(e)}/${encodeURIComponent(t)}/cards/${encodeURIComponent(n)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(r)})).ok}async function Ym(e,t,n,r){return(await X(`/api/kanban/columns/${encodeURIComponent(e)}/${encodeURIComponent(t)}/cards/${encodeURIComponent(n)}/block`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({block:r})})).ok}async function Xm(e,t,n){return(await X(`/api/kanban/columns/${encodeURIComponent(e)}/${encodeURIComponent(t)}/cards/${encodeURIComponent(n)}`,{method:`DELETE`})).ok}async function Zm(e,t,n,r,i){return(await X(`/api/kanban/columns/${encodeURIComponent(e)}/${encodeURIComponent(t)}/cards/${encodeURIComponent(n)}/move`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({toFile:r,toIndex:i})})).ok}async function Qm(e,t,n){return(await X(`/api/kanban/columns/${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({filename:t,title:n})})).ok}async function $m(){let e=await X(`/api/kanban/boards`);return e.ok?(await e.json()).boards:[`default`]}async function eh(e){return(await X(`/api/kanban/boards`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:e})})).ok}async function th(e,t){return(await X(`/api/kanban/boards/${encodeURIComponent(e)}/rename`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({name:t})})).ok}async function nh(e=`default`){let t=await X(`/api/kanban/config/${encodeURIComponent(e)}`);return t.ok?(await t.json()).columns:[]}async function rh(e,t){return(await X(`/api/kanban/config/${encodeURIComponent(e)}`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({columns:t})})).ok}async function ih(e,t,n){return(await X(`/api/kanban/columns/${encodeURIComponent(e)}/${encodeURIComponent(t)}/rename`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({toFile:n})})).ok}async function ah(e,t){return(await X(`/api/kanban/columns/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`DELETE`})).ok}async function oh(e,t,n){return(await X(`/api/kanban/columns/${encodeURIComponent(e)}/${encodeURIComponent(t)}/color`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({color:n})})).ok}async function sh(e,t,n){return(await X(`/api/kanban/columns/${encodeURIComponent(e)}/${encodeURIComponent(t)}/reorder`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({cids:n})})).ok}async function ch(e,t,n){let r=await X(`/api/kanban/columns/${encodeURIComponent(e)}/${encodeURIComponent(t)}/cards/${encodeURIComponent(n)}/assign-driver`,{method:`POST`});return r.ok?await r.json():{ok:!1}}async function lh(e,t,n,r){return(await X(`/api/kanban/columns/${encodeURIComponent(e)}/${encodeURIComponent(t)}/cards/${encodeURIComponent(n)}/link-loop`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({loopId:r})})).ok}async function uh(){let e=await X(`/api/topics`);return e.ok?(await e.json()).topics:[]}async function dh(){let e=await X(`/api/providers`);return e.ok?await e.json():{providers:{},default:``}}async function fh(e,t,n,r,i){let a={baseUrl:e,model:n};t?a.apiKey=t:r&&i&&(a.provider=r,a.source=i);let o=await X(`/api/providers/test`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(a)}),s=await o.json().catch(()=>({}));return o.ok?s:{ok:!1,error:s.error??`test failed (${o.status})`}}async function ph(){let e=await X(`/api/version`);return e.ok?await e.json():{branch:`unknown`,commit:`unknown`}}async function mh(){let e=await X(`/api/admin/system`);return e.ok?await e.json():null}async function hh(){return await(await X(`/api/admin/system/check`,{method:`POST`})).json()}async function gh(){return await(await X(`/api/admin/system/pull`,{method:`POST`})).json()}function _h(){return{commit:`5026dd989b59e2338d980e677e8efde8facb561d`,time:`2026-06-02T01:41:08.109Z`}}async function vh(e){let t=await X(`/api/loops/${e}/git-status`);return t.ok?await t.json():{unstaged:[],staged:[]}}async function yh(e,t,n){let r=await X(`/api/loops/${e}/git-diff?path=${encodeURIComponent(t)}&staged=${n?`1`:`0`}`);return r.ok?(await r.json()).diff??null:null}async function bh(e,t,n=!1){return(await X(`/api/loops/${e}/git-stage`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({files:t,unstage:n})})).ok}async function xh(e,t){return(await X(`/api/loops/${e}/git-discard`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({file:t})})).ok}async function Sh(e,t){let n=await X(`/api/loops/${e}/git-commit`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:t})}),r=await n.json().catch(()=>({}));return n.ok?{ok:!0}:{ok:!1,error:r.error??`commit failed`}}async function Ch(e,t=50){let n=await X(`/api/loops/${e}/git-log?limit=${t}`);return n.ok?(await n.json()).commits??[]:[]}async function wh(){let e=await X(`/api/settings/personal/disk`);return e.ok?await e.json():null}async function Th(e){let t=await X(`/api/settings/personal/disk`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0}:{ok:!1,error:n.error??`save failed (${t.status})`}}async function Eh(e,t,n=`default`){let r=await X(`/api/settings/personal/value`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:e,value:t,vault:n})}),i=await r.json().catch(()=>({}));return r.ok?{ok:!0}:{ok:!1,error:i.error??`write failed (${r.status})`}}async function Dh(){return await(await X(`/api/settings/workspace`)).json()}async function Oh(e){return(await X(`/api/settings/workspace`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(e)})).ok}async function kh(){let e=await X(`/api/settings/token-usage/daily`);return e.ok?await e.json():{}}async function Ah(){let e=await X(`/api/settings/token-usage/loops`);return e.ok?await e.json():[]}async function jh(){let e=await X(`/api/admin/presets`);return e.ok?await e.json():{providerPresets:[],miseToolPresets:[]}}async function Mh(e){return(await X(`/api/admin/presets`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(e)})).ok}async function Nh(){let e=await X(`/api/admin/users`);return e.ok?(await e.json()).users??[]:[]}async function Ph(e){let t=await X(`/api/admin/users/${encodeURIComponent(e)}/activate`,{method:`POST`}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0}:{ok:!1,error:n.error??`activate failed (${t.status})`}}async function Fh(e,t){let n=await X(`/api/admin/users/${encodeURIComponent(e)}/role`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({role:t})}),r=await n.json().catch(()=>({}));return n.ok?{ok:!0}:{ok:!1,error:r.error??`role change failed (${n.status})`}}async function Ih(e){let t=await X(`/api/admin/users/${encodeURIComponent(e)}`,{method:`DELETE`}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0}:{ok:!1,error:n.error??`delete failed (${t.status})`}}async function Lh(){let e=await X(`/api/serve/config`);return e.ok?await e.json():{serveEnabled:!0,domain:`nip.io`,ip:`127.0.0.1`,baseUrl:`.127.0.0.1.nip.io`,withPort:!1,https:!1,displayPort:7788,serveDynamicEnabled:!1,serveDynamicDomain:``,serveDynamicPortRange:`10000-20000`,serveDynamicUdpEnabled:!1,serveDynamicStaticEnabled:!1,serveEphemeralEnabled:!1,serveEphemeralDomain:``}}async function Rh(e){let t=await X(`/api/loops/${e}/share/current-port`);return t.ok?await t.json():{port:null}}async function zh(e){return(await X(`/api/serve/config`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(e)})).ok}async function Bh(){let e=await X(`/api/serve/available-port`);return e.ok?await e.json():{port:null,error:`request failed`}}async function Vh(e,t){let n=await X(`/api/serve/check-port?port=${e}&loopId=${t||``}`);return n.ok?await n.json():{available:!1,reason:`request failed`}}async function Hh(e,t){let n=new URLSearchParams({alias:e});t&&n.set(`loopId`,t);let r=await X(`/api/serve/alias-check?${n}`);return r.ok?await r.json():{available:!1,reason:`check failed`}}async function Uh(){let e=await X(`/api/chat/conversations`);return e.ok?(await e.json()).conversations??[]:[]}async function Wh(){let e=await X(`/api/chat/users`);return e.ok?(await e.json()).users??[]:[]}async function Gh(e,t){let n=await X(`/api/chat/channels`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:e,topic:t})}),r=await n.json().catch(()=>({}));return n.ok?{conv:r.conv}:{error:r.error??`create failed (${n.status})`}}async function Kh(e){let t=await X(`/api/chat/channels/${encodeURIComponent(e)}`,{method:`DELETE`}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0}:{ok:!1,error:n.error??`delete failed (${t.status})`}}async function qh(e){let t=await X(`/api/chat/dm/${encodeURIComponent(e)}`,{method:`POST`}),n=await t.json().catch(()=>({}));return t.ok?{conv:n.conv}:{error:n.error??`open DM failed (${t.status})`}}async function Jh(e,t={}){let n=new URLSearchParams;t.before&&n.set(`before`,String(t.before)),t.limit&&n.set(`limit`,String(t.limit));let r=await X(`/api/chat/conversations/${encodeURIComponent(e)}/messages?${n.toString()}`);return r.ok?(await r.json()).messages??[]:[]}async function Yh(e){let t=await X(`/api/chat/threads/${e}`);return t.ok?await t.json():null}async function Xh(e,t,n=null){let r=await X(`/api/chat/conversations/${encodeURIComponent(e)}/messages`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n==null?{text:t}:{text:t,parentId:n})}),i=await r.json().catch(()=>({}));return r.ok?{message:i.message}:{error:i.error??`send failed (${r.status})`}}async function Zh(e,t){return(await X(`/api/chat/conversations/${encodeURIComponent(e)}/read`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({lastReadId:t})})).ok}async function Qh(e,t){let n=await X(`/api/chat/threads/${e}/spawn-loop`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t?{title:t}:{})}),r=await n.json().catch(()=>({}));return n.ok?{loopId:r.loopId,seedPrompt:r.seedPrompt,messageCount:r.messageCount}:{error:r.error??`spawn failed (${n.status})`}}async function $h(e){let t=await X(`/api/mcp-servers${e?`?loopId=${encodeURIComponent(e)}`:``}`);return t.ok?await t.json():{servers:[]}}async function eg(e,t){let n=await X(`/api/mcp-auth/start`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({serverName:e,loopId:t})}),r=await n.json().catch(()=>({}));return n.ok?{authorizationUrl:r.authorizationUrl}:{error:r.error??`start failed`}}async function tg(e){return(await X(`/api/envs/${encodeURIComponent(e)}`,{method:`DELETE`})).ok}async function ng(e){let t=await X(`/api/loops/${encodeURIComponent(e)}/restart-session`,{method:`POST`}),n=await t.json().catch(()=>({}));return t.ok?{restarted:!!n.restarted}:{restarted:!1,error:n.error??`restart failed (${t.status})`}}async function rg(){let e=await X(`/api/tiers`);return e.ok?await e.json():null}async function ig(e,t){let n=await X(`/api/tiers/${encodeURIComponent(e)}/settings`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),r=await n.json().catch(()=>({}));return n.ok?{ok:!0}:{ok:!1,error:r.error??`save failed (${n.status})`}}async function ag(e){let t=await X(`/api/tiers/${encodeURIComponent(e)}/mise-config`);return t.ok?await t.json():{content:``,exists:!1,error:`fetch failed (${t.status})`}}async function og(e,t){let n=await X(`/api/tiers/${encodeURIComponent(e)}/mise-config`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({content:t})}),r=await n.json().catch(()=>({}));return n.ok?{ok:!0}:{ok:!1,error:r.error??`save failed (${n.status})`}}async function sg(){let e=await X(`/api/plugins/available`);return e.ok?(await e.json()).plugins??[]:[]}async function cg(){let e=await X(`/api/plugins/browse`);return e.ok?(await e.json()).plugins??[]:[]}async function lg(){let e=await X(`/api/marketplaces`);return e.ok?(await e.json()).marketplaces??[]:[]}async function ug(){let e=await X(`/api/plugins/refresh`,{method:`POST`}),t=await e.json().catch(()=>({}));return e.ok?{ok:!0,added:t.added}:{ok:!1,error:t.error??`refresh failed (${e.status})`}}async function dg(e){let t=await X(`/api/admin/profiles`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:e})}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0}:{ok:!1,error:n.error??`create failed (${t.status})`}}async function fg(e){let t=await X(`/api/admin/profiles/${encodeURIComponent(e)}`,{method:`DELETE`}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0}:{ok:!1,error:n.error??`delete failed (${t.status})`}}async function pg(){let e=await X(`/api/v1/me/tokens`);return e.ok?(await e.json().catch(()=>({tokens:[]}))).tokens??[]:[]}async function mg(e){let t=await X(`/api/v1/me/tokens`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({label:e})});return t.ok?await t.json().catch(()=>null):null}async function hg(e){return(await X(`/api/v1/me/tokens/${encodeURIComponent(e)}`,{method:`DELETE`})).ok}function gg(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)(!0),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(!0),g=(0,_.useCallback)(async()=>{r(!0),t(await rm(i?`all`:`active`)),r(!1)},[i]);(0,_.useEffect)(()=>{let e=!1;return Gp().then(t=>{e||(p(t),h(!1))}),()=>{e=!0}},[]),(0,_.useEffect)(()=>{g()},[i,f]);let v=(0,_.useCallback)(async e=>{let n=await im(e);return t(e=>[n,...e]),n},[]),y=(0,_.useCallback)(async(e,n)=>{let r=await um(e,n);r&&t(t=>!i&&r.archived?t.filter(t=>t.id!==e):t.map(t=>t.id===e?r:t))},[i]),b=(0,_.useCallback)(async(e,n)=>{let r=await dm(e,n);r&&t(t=>t.map(t=>t.id===e?r:t))},[]),x=(0,_.useCallback)(async(e,n)=>{let r=await fm(e,n);return r?(t(t=>t.map(t=>t.id===e?r:t)),r):null},[]),S=(0,_.useCallback)(async e=>{let n=await pm(e);n&&t(t=>t.map(t=>t.id===e?n:t))},[]),C=(0,_.useCallback)(async e=>{let n=await mm(e);n&&t(t=>t.map(t=>t.id===e?n:t))},[]),w=(0,_.useCallback)(async(e,t)=>{let n=await Kp(e,t);return n.user&&p(n.user),{error:n.error}},[]),T=(0,_.useCallback)(async e=>{let t=await qp(e);return t.user&&t.user.status===`active`&&p(t.user),{error:t.error,user:t.user,publicKey:t.publicKey,personalRepo:t.personalRepo,needsImport:t.needsImport}},[]),E=(0,_.useCallback)(async()=>{await nm(),p(null)},[]);return{loops:e,loopsLoading:n,showArchived:i,setShowArchived:a,refresh:g,createLoop:v,setLoopArchived:y,setLoopPublic:b,setLoopTitle:x,requestDrive:S,takeDrive:C,newLoopDialogOpen:o,newLoopDialogTitle:c,kanbanCreateCtx:u,setNewLoopDialogOpen:(0,_.useCallback)((e,t,n)=>{s(e),l(t??``),d(n??null)},[]),currentUser:f,authLoading:m,login:w,register:T,logout:E}}var _g=(0,_.createContext)(null);function vg(){let e=(0,_.useContext)(_g);if(!e)throw Error(`useWorkspace outside provider`);return e}function yg({onClose:e,onCreate:t,initialTitle:n}){let[r,i]=(0,_.useState)(n??``),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(new Set),[l,u]=(0,_.useState)([]),[d,f]=(0,_.useState)(`default`),[p,m]=(0,_.useState)([]),[h,g]=(0,_.useState)([]),[v,y]=(0,_.useState)([]),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(!1),[w,T]=(0,_.useState)(!1),E=(0,_.useRef)(null);(0,_.useEffect)(()=>{Lm().then(e=>m(e.repos)),Promise.all([am(),om()]).then(([e,t])=>{g(e),u(t);let n=new Set(e.map(e=>e.name));c(new Set(t.filter(e=>n.has(e)&&e!==`base`)))}),cm().then(e=>{y(e),e.includes(`default`)?f(`default`):e.length>0&&f(e[0])}),E.current?.focus()},[]);function D(){let e=new Set(h.map(e=>e.name));c(new Set(l.filter(t=>e.has(t)&&t!==`base`)))}(0,_.useEffect)(()=>{C(!0);let e=setTimeout(()=>{sm([...s]).then(x).finally(()=>C(!1))},120);return()=>clearTimeout(e)},[s]);let O=(()=>{let e=new Set(l.filter(e=>e!==`base`));if(e.size!==s.size)return!0;for(let t of e)if(!s.has(t))return!0;return!1})(),k=h.find(e=>e.name===`base`),A=h.filter(e=>e.name!==`base`);function j(e){c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/30 flex items-center justify-center`,onClick:e,children:(0,G.jsxs)(`div`,{className:`w-full max-w-[480px] mx-4 bg-white rounded-md shadow-xl border border-gray-200 p-4 md:p-5 max-h-[85vh] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(`div`,{className:`text-base font-semibold text-gray-900 mb-4`,children:`New loop`}),(0,G.jsxs)(`form`,{onSubmit:async e=>{if(e.preventDefault(),!w){T(!0);try{await t({title:r.trim()||`untitled`,repo:a||void 0,profiles:s.size>0?[...s]:void 0,vault:d||void 0})}finally{T(!1)}}},className:`flex flex-col gap-4`,children:[(0,G.jsxs)(bg,{label:`Repo`,hint:`Sets the workdir. Optional — leave (none) for an empty workdir.`,children:[(0,G.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value),className:`w-full px-2 py-1.5 text-sm border border-gray-300 rounded outline-none focus:border-gray-500 bg-white`,children:[(0,G.jsx)(`option`,{value:``,children:`(none — empty workdir)`}),p.map(e=>(0,G.jsxs)(`option`,{value:e.name,children:[e.name,e.git?` · ${e.git}`:``]},e.name))]}),p.length===0&&(0,G.jsx)(`div`,{className:`text-[11px] text-gray-400 mt-1`,children:`No repos in the roster. Add them on the Context → Repos page.`})]}),(0,G.jsxs)(bg,{label:`Profiles`,hint:`Each profile contributes plugins + a CLAUDE.md fragment. Empty = base + personal only.`,children:[(0,G.jsxs)(`div`,{className:`border border-gray-300 rounded p-2 max-h-44 overflow-y-auto bg-white flex flex-col gap-1`,children:[k&&(0,G.jsxs)(`label`,{className:`flex items-start gap-2 px-1.5 py-1 rounded text-sm text-gray-500 cursor-not-allowed bg-gray-50`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!0,disabled:!0,className:`mt-0.5`}),(0,G.jsxs)(`span`,{className:`flex-1`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:`base`}),(0,G.jsx)(`span`,{className:`ml-1 text-[11px] text-gray-400`,children:`(always on)`}),k.description&&(0,G.jsx)(`span`,{className:`block text-[11px] text-gray-400 mt-0.5`,children:k.description})]})]}),A.map(e=>{let t=s.has(e.name),n=l.includes(e.name);return(0,G.jsxs)(`label`,{className:`flex items-start gap-2 px-1.5 py-1 rounded text-sm cursor-pointer hover:bg-gray-50 ${t?`bg-blue-50`:``}`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:t,onChange:()=>j(e.name),className:`mt-0.5`}),(0,G.jsxs)(`span`,{className:`flex-1`,children:[(0,G.jsx)(`span`,{className:`font-medium text-gray-900`,children:e.name}),n&&(0,G.jsx)(`span`,{className:`ml-1.5 px-1 py-px text-[10px] rounded bg-gray-200 text-gray-600`,title:`In your default_profiles (personal config)`,children:`default`}),e.description&&(0,G.jsx)(`span`,{className:`block text-[11px] text-gray-500 mt-0.5`,children:e.description})]})]},e.name)}),A.length===0&&!k&&(0,G.jsxs)(`div`,{className:`text-[11px] text-gray-400 p-1.5`,children:[`No profiles in workspace. Create directories under`,` `,(0,G.jsx)(`code`,{className:`bg-gray-100 px-1 rounded`,children:`context/profiles/<name>/`}),` with a profile.json.`]})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between mt-1`,children:[(0,G.jsx)(`span`,{className:`text-[11px] text-gray-500`,children:s.size>0?`Selected: ${[...s].join(`, `)}`:`No profiles selected (base + personal only)`}),O&&l.length>0&&(0,G.jsx)(`button`,{type:`button`,onClick:D,className:`text-[11px] text-gray-500 hover:text-gray-900 underline`,title:`Restore default_profiles from your personal config`,children:`reset to defaults`})]}),(0,G.jsx)(`div`,{className:`mt-1.5 px-1.5 py-1 text-[11px] text-gray-600 bg-gray-50 border border-gray-200 rounded`,children:S&&!b?(0,G.jsx)(`span`,{className:`text-gray-400`,children:`computing…`}):b?(0,G.jsxs)(`span`,{title:`Totals across team + selected profiles + their plugins (deduped by name)`,children:[(0,G.jsxs)(`span`,{className:b.plugins>0?``:`text-gray-400`,children:[b.plugins,` plugins`]}),(0,G.jsx)(`span`,{className:`mx-1 text-gray-300`,children:`·`}),(0,G.jsxs)(`span`,{className:b.skills>0?``:`text-gray-400`,children:[b.skills,` skills`]}),(0,G.jsx)(`span`,{className:`mx-1 text-gray-300`,children:`·`}),(0,G.jsxs)(`span`,{className:b.agents>0?``:`text-gray-400`,children:[b.agents,` agents`]}),(0,G.jsx)(`span`,{className:`mx-1 text-gray-300`,children:`·`}),(0,G.jsxs)(`span`,{className:b.hooks>0?``:`text-gray-400`,children:[b.hooks,` hooks`]}),(0,G.jsx)(`span`,{className:`mx-1 text-gray-300`,children:`·`}),(0,G.jsxs)(`span`,{className:b.mcpServers>0?``:`text-gray-400`,children:[b.mcpServers,` MCP servers`]}),(0,G.jsx)(`span`,{className:`mx-1 text-gray-300`,children:`·`}),(0,G.jsxs)(`span`,{className:b.toolchain>0?``:`text-gray-400`,title:`mise.toml [tools] entries, deduped across team + selected profiles`,children:[b.toolchain,` toolchain`]}),S&&(0,G.jsx)(`span`,{className:`ml-1.5 text-gray-400`,children:`·`}),S&&(0,G.jsx)(`span`,{className:`ml-1 text-gray-400`,children:`updating…`})]}):(0,G.jsx)(`span`,{className:`text-gray-400`,children:`—`})})]}),(0,G.jsxs)(bg,{label:`Vault`,hint:`Which credential set to inject. Only this vault is visible inside the loop.`,children:[(0,G.jsxs)(`select`,{value:d,onChange:e=>f(e.target.value),className:`w-full px-2 py-1.5 text-sm border border-gray-300 rounded outline-none focus:border-gray-500 bg-white`,children:[v.length===0&&(0,G.jsx)(`option`,{value:`default`,children:`default`}),v.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))]}),v.length===0&&(0,G.jsxs)(`div`,{className:`text-[11px] text-gray-400 mt-1`,children:[`No vaults yet — using default. Create more under`,` `,(0,G.jsx)(`code`,{className:`bg-gray-100 px-1 rounded`,children:`personal/.loopat/vaults/<name>/`}),` `,`to isolate prod / test credentials.`]})]}),(0,G.jsx)(bg,{label:`Name`,hint:`Optional — defaults to 'untitled'.`,children:(0,G.jsx)(`input`,{ref:E,type:`text`,value:r,onChange:e=>i(e.target.value),placeholder:`refactor-gateway`,className:`w-full px-2 py-1.5 text-sm border border-gray-300 rounded outline-none focus:border-gray-500`})}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2 mt-2 pt-3 border-t border-gray-100`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:e,className:`px-3 h-8 text-sm rounded text-gray-700 hover:bg-gray-100`,children:`cancel`}),(0,G.jsx)(`button`,{type:`submit`,disabled:w,className:`px-3 h-8 text-sm rounded bg-gray-900 text-white hover:bg-gray-700 disabled:opacity-50`,children:w?`creating…`:`create`})]})]})]})})}function bg({label:e,hint:t,children:n}){return(0,G.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`text-xs text-gray-700 font-medium`,children:e}),n,t&&(0,G.jsx)(`span`,{className:`text-[11px] text-gray-400`,children:t})]})}var xg=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,Sg=ff,Cg=((e,t)=>n=>{if(t?.variants==null)return Sg(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=xg(t)||xg(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return Sg(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)})(`inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 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/90`,destructive:`bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40`,outline:`border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3`,xs:`h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5`,lg:`h-10 rounded-md px-6 has-[>svg]:px-4`,icon:`size-9`,"icon-xs":`size-6 rounded-md [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-8`,"icon-lg":`size-10`}},defaultVariants:{variant:`default`,size:`default`}});function wg({className:e,variant:t=`default`,size:n=`default`,asChild:r=!1,...i}){return(0,G.jsx)(r?Ni:`button`,{"data-slot":`button`,"data-variant":t,"data-size":n,className:Y(Cg({variant:t,size:n,className:e})),...i})}function Tg({...e}){return(0,G.jsx)(nc,{"data-slot":`dialog`,...e})}function Eg({...e}){return(0,G.jsx)(rc,{"data-slot":`dialog-portal`,...e})}function Dg({className:e,...t}){return(0,G.jsx)(ic,{"data-slot":`dialog-overlay`,className:Y(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function Og({className:e,children:t,showCloseButton:n=!0,...r}){return(0,G.jsxs)(Eg,{"data-slot":`dialog-portal`,children:[(0,G.jsx)(Dg,{}),(0,G.jsxs)(ac,{"data-slot":`dialog-content`,className:Y(`fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-white p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg`,e),...r,children:[t,n&&(0,G.jsxs)(cc,{"data-slot":`dialog-close`,className:`absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,G.jsx)(ut,{}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function kg({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`dialog-header`,className:Y(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function Ag({className:e,...t}){return(0,G.jsx)(oc,{"data-slot":`dialog-title`,className:Y(`text-lg leading-none font-semibold`,e),...t})}function jg({className:e,...t}){return(0,G.jsx)(sc,{"data-slot":`dialog-description`,className:Y(`text-sm text-muted-foreground`,e),...t})}function Mg({open:e,onClose:t}){let[n,r]=(0,_.useState)({branch:`…`,commit:`…`}),i=_h();return(0,_.useEffect)(()=>{e&&ph().then(e=>r(e))},[e]),(0,G.jsx)(Tg,{open:e,onOpenChange:e=>!e&&t(),children:(0,G.jsxs)(Og,{className:`sm:max-w-sm bg-white`,children:[(0,G.jsx)(kg,{children:(0,G.jsxs)(Ag,{className:`text-center`,children:[(0,G.jsx)(`img`,{src:`/logo.png`,alt:`loopat`,className:`w-full max-w-[240px] mx-auto mb-2`}),`loopat`]})}),(0,G.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,G.jsxs)(`div`,{className:`bg-gray-50 rounded-lg p-3`,children:[(0,G.jsx)(`div`,{className:`text-gray-400 text-xs mb-1`,children:`Server`}),(0,G.jsxs)(`div`,{className:`font-mono text-gray-700`,children:[n.branch,`@`,n.commit.slice(0,7)]})]}),(0,G.jsxs)(`div`,{className:`bg-gray-50 rounded-lg p-3`,children:[(0,G.jsx)(`div`,{className:`text-gray-400 text-xs mb-1`,children:`Build`}),(0,G.jsx)(`div`,{className:`font-mono text-gray-700`,children:i.commit.slice(0,7)}),(0,G.jsx)(`div`,{className:`font-mono text-gray-400 text-xs mt-0.5`,children:new Date(i.time).toLocaleString()})]})]})]})})}function Ng(e,t){let n=e[Pg];if(!n)throw Error(`ResourceElement.type is not a valid Resource`);return n(t)}var Pg=Symbol(`fnSymbol`);function Fg(e){let t=e=>({type:t,props:e});return t[Pg]=e,t}function Ig(e,t){return{...t,key:e}}var Lg=typeof process<`u`&&!1,Rg=null;function zg(e,t){e.currentIndex=0;let n=Rg;Rg=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{Rg=n}}function Bg(){if(!Rg)throw Error(`No resource fiber available`);return Rg}function Vg(e){return Lg?Rg?.devStrictMode?Rg.isFirstRender?`child`:`root`:e?`root`:null:null}var Hg=e=>({version:0,committedVersion:0,dispatchUpdate:e,changelog:[],dirtyCells:[]}),Ug=e=>{for(let t of e.dirtyCells)t.dirty=!1,t.queue.clear(),t.current=t.workInProgress;e.committedVersion=e.version,e.changelog.length=0,e.dirtyCells.length=0},Wg=(e,t)=>{let n=e.version>t;if(e.version=t,n){for(let t of e.dirtyCells)t.dirty=!1,t.queue.clear(),t.workInProgress=t.current;if(e.dirtyCells.length=0,t===e.committedVersion)e.changelog.length=0;else{if(e.committedVersion>t)throw Error(`Version is less than committed version`);for(;e.committedVersion+e.changelog.length>t;)e.changelog.pop();e.changelog.forEach(e=>e()),Ug(e)}}},Gg=(e,t)=>{t.dirty||(t.dirty=!0,e.markDirty?.(),e.root.dirtyCells.push(t))},Kg=(e,t)=>{let n=Bg(),r=n.currentIndex++;if(!n.isFirstRender&&r>=n.cells.length)throw Error(`Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.`);let i=n.cells[r];if(i||(i=t(),n.cells[r]=i),i.type!==e)throw Error(`Hook order changed between renders`);return i},qg=e=>{Bg().renderContext.effectTasks.push(e)},Jg=(e,t)=>{if(e.renderContext)throw Error(`Resource updated during render`);if(e.isNeverMounted)throw Error(`Resource updated before mount`);e.root.dispatchUpdate(()=>{let n=t();return n?(n(),e.root.changelog.push(n),!0):!1})};function Yg(e,t,n,r){let i=Kg(`reducer`,()=>{let t=Bg(),a=r?r(n):n;return Lg&&t.devStrictMode&&r&&r(n),{type:`reducer`,queue:new Set,dirty:!1,workInProgress:a,current:a,reducer:e,dispatch:n=>{let r={action:n,hasEagerState:!1,eagerState:void 0};Jg(t,()=>t.root.dirtyCells.length===0&&!r.hasEagerState&&(r.eagerState=e(i.workInProgress,n),r.hasEagerState=!0,Object.is(i.current,r.eagerState))?null:()=>{Gg(t,i),i.queue.add(r)})}}}),a=Bg(),o=e===i.reducer;i.reducer=e;for(let t of i.queue)(!t.hasEagerState||!o)&&(t.eagerState=e(i.workInProgress,t.action),t.hasEagerState=!0),Lg&&a.devStrictMode&&e(i.workInProgress,t.action),i.workInProgress=t.eagerState;if(i.queue.clear(),t){let e=t(i.workInProgress);Object.is(e,i.workInProgress)||(Gg(a,i),i.workInProgress=e)}return[i.workInProgress,i.dispatch]}function Xg(e,t,n){return Yg(e,void 0,t,n)}function Zg(e,t,n,r){return Yg(e,t,n,r)}var Qg=(e,t)=>typeof t==`function`?t(e):t,$g=e=>typeof e==`function`?e():e;function e_(e){return Xg(Qg,e,$g)}var t_=(e,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},n_=()=>({type:`effect`,cleanup:void 0,deps:null});function r_(e,t){let n=Kg(`effect`,n_);if(!(t&&n.deps&&t_(n.deps,t))){if(n.deps!==null&&!!t!=!!n.deps)throw Error(`tapEffect called with and without dependencies across re-renders`);qg(()=>{let r=[];try{n.cleanup?.()}catch(e){r.push(e)}finally{n.cleanup=void 0}try{let t=e();if(t!==void 0&&typeof t!=`function`)throw Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof t}`);n.cleanup=t}catch(e){r.push(e)}if(n.deps=t,r.length>0){if(r.length===1)throw r[0];for(let e of r)console.error(e);throw AggregateError(r,`Errors during commit`)}})}}function i_(e){let[t]=e_(()=>({current:e}));return t}function a_(e,t){let[n]=e_(e);return n}var o_=()=>{throw Error(`Memo reducer should not be called`)},s_=(e,t)=>{let n=Bg(),[r]=Zg(o_,r=>{if(r&&t_(r.deps,t))return r;let i=e();return Lg&&n.devStrictMode&&e(),{value:i,deps:t}},null);return r.value},c_=(e,t)=>s_(()=>e,t);function l_(e){let t=i_(e);r_(()=>{t.current=e});let n=Bg();return c_(((...e)=>{if(Lg&&n.renderContext)throw Error(`tapEffectEvent cannot be called during render`);return t.current(...e)}),[n])}function u_(e){let t=[];for(let n of e.effectTasks)try{n()}catch(e){t.push(e)}if(t.length>0){if(t.length===1)throw t[0];for(let e of t)console.error(e);throw AggregateError(t,`Errors during commit`)}}function d_(e){let t=[];for(let n of e.cells)if(n?.type===`effect`&&(n.deps=null,n.cleanup))try{n.cleanup?.()}catch(e){t.push(e)}finally{n.cleanup=void 0}if(t.length>0){if(t.length===1)throw t[0];for(let e of t)console.error(e);throw AggregateError(t,`Errors during cleanup`)}}function f_(e,t,n=void 0,r=Vg(!1)){return{type:e,root:t,markDirty:n,devStrictMode:r,cells:[],currentIndex:0,renderContext:void 0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function p_(e){if(!e.isMounted)throw Error(`Tried to unmount a fiber that is already unmounted`);e.isMounted=!1,d_(e)}function m_(e,t){let n={effectTasks:[],props:t,output:void 0};return zg(e,()=>{e.renderContext=n;try{n.output=Ng(e.type,t)}finally{e.renderContext=void 0}}),n}function h_(e,t){e.isMounted=!0,Lg&&e.isNeverMounted&&e.devStrictMode===`root`&&(e.isNeverMounted=!1,u_(t),d_(e)),e.isNeverMounted=!1,u_(t)}function g_(e,t){let n=Bg(),r=i_(0),i=s_(()=>(e.key,f_(e.type,n.root,()=>{r.current++,n.markDirty?.()})),[e.type,e.key,n]),a=t?s_(()=>m_(i,e.props),[i,...t,r.current]):m_(i,e.props);return r_(()=>()=>p_(i),[i]),r_(()=>{h_(i,a)},[i,a]),a.output}function __(e,t){let n=i_(0),r=n.current,i=a_(Bg,[]),a=a_(()=>()=>{n.current++,i.markDirty?.()},[]),o=a_(()=>new Map,[]),s=t?c_(e,t):e,c=s_(()=>{let e=s(),t=new Set,n=[],r=0;for(let s=0;s<e.length;s++){let c=e[s],l=c.key;if(l===void 0)throw Error(`tapResources did not provide a key for array at index ${s}`);if(t.has(l))throw Error(`Duplicate key ${l} in tapResources`);t.add(l);let u=o.get(l);if(!u){let e=f_(c.type,i.root,a),t=m_(e,c.props);u={fiber:e,next:t},r++,o.set(l,u),n.push(t.output)}else if(u.fiber.type!==c.type){let e=f_(c.type,i.root,a),t=m_(e,c.props);u.next=[e,t],n.push(t.output)}else u.next=m_(u.fiber,c.props),n.push(u.next.output)}if(o.size>n.length-r)for(let e of o.keys())t.has(e)||(o.get(e).next=`delete`);return n},[s,r]);return r_(()=>()=>{for(let e of o.keys()){let t=o.get(e).fiber;p_(t)}},[]),r_(()=>{for(let[e,t]of o.entries())t.next===`delete`?(t.fiber.isMounted&&p_(t.fiber),o.delete(e)):Array.isArray(t.next)?(p_(t.fiber),t.fiber=t.next[0],h_(t.fiber,t.next[1])):h_(t.fiber,t.next)},[c]),c}var v_=50,y_={schedulers:new Set([]),isScheduled:!1},b_=class{_task;_isDirty=!1;constructor(e){this._task=e}get isDirty(){return this._isDirty}markDirty(){this._isDirty=!0,y_.schedulers.add(this),x_()}runTask(){this._isDirty=!1,this._task()}},x_=()=>{y_.isScheduled||(y_.isScheduled=!0,C_())},S_=()=>{try{let e=[],t=0;for(let n of y_.schedulers)if(y_.schedulers.delete(n),n.isDirty){if(t++,t>v_)throw Error(`Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside tapEffect.`);try{n.runTask()}catch(t){e.push(t)}}if(e.length>0){if(e.length===1)throw e[0];for(let t of e)console.error(t);throw AggregateError(e,`Errors occurred during flushSync`)}}finally{y_.schedulers.clear(),y_.isScheduled=!1}},C_=(()=>{if(typeof MessageChannel<`u`){let e=new MessageChannel;return e.port1.onmessage=S_,()=>e.port2.postMessage(null)}return()=>setTimeout(S_,0)})(),w_=e=>{let t=y_;y_={schedulers:new Set([]),isScheduled:!0};try{let t=e();return S_(),t}finally{y_=t}},T_=e=>{let t=a_(()=>new b_(()=>l(null)),[]),n=a_(()=>[],[]),r=s_(()=>(e.key,f_(e.type,Hg(e=>{!t.isDirty&&!e()||(n.push(e),t.markDirty())}))),[e.type,e.key]);Wg(r.root,r.root.committedVersion);let i=m_(r,e.props),a=i_(!1),o=i_(e.props),s=i_(i.output),c=a_(()=>new Set,[]),l=l_(e=>{if(e===null&&(Wg(r.root,2),Wg(r.root,1),n.forEach(e=>{Lg&&r.devStrictMode&&e(),e()}),Lg&&r.devStrictMode&&m_(r,o.current),e=m_(r,o.current)),t.isDirty)throw Error(`Scheduler is dirty, this should never happen`);Ug(r.root),n.length=0,a.current&&h_(r,e),!(t.isDirty||s.current===e.output)&&(s.current=e.output,c.forEach(e=>e()))});return r_(()=>(a.current=!0,()=>{a.current=!1,p_(r)}),[r]),r_(()=>{o.current=i.props,Ug(r.root),h_(r,i),!(t.isDirty||s.current===i.output)&&(s.current=i.output,c.forEach(e=>e()))}),s_(()=>({getValue:()=>s.current,subscribe:e=>(c.add(e),()=>c.delete(e))}),[])},E_=Symbol(`tap.Context`),D_=e=>({[E_]:e}),O_=(e,t,n)=>{let r=e[E_];e[E_]=t;try{return n()}finally{e[E_]=r}},k_=e=>e[E_],A_=Fg(()=>{let[e,t]=e_(()=>({renderers:{},fallbacks:[]}));return{getState:()=>e,setDataUI:c_((e,n)=>(t(t=>({...t,renderers:{...t.renderers,[e]:[...t.renderers[e]??[],n]}})),()=>{t(t=>({...t,renderers:{...t.renderers,[e]:t.renderers[e]?.filter(e=>e!==n)??[]}}))}),[]),setFallbackDataUI:c_(e=>(t(t=>({...t,fallbacks:[...t.fallbacks,e]})),()=>{t(t=>({...t,fallbacks:t.fallbacks.filter(t=>t!==e)}))}),[])}}),j_=e=>Array.from(e).map(e=>e.getModelContext()).sort((e,t)=>(t.priority??0)-(e.priority??0)).reduce((e,t)=>{if(t.system&&(e.system?e.system+=`\n\n${t.system}`:e.system=t.system),t.tools)for(let[n,r]of Object.entries(t.tools)){let t=e.tools?.[n];if(t&&t!==r)throw Error(`You tried to define a tool with the name ${n}, but it already exists.`);e.tools||={},e.tools[n]=r}return t.config&&(e.config={...e.config,...t.config}),t.callSettings&&(e.callSettings={...e.callSettings,...t.callSettings}),e},{}),M_=class{_providers=new Set;getModelContext(){return j_(this._providers)}registerModelContextProvider(e){this._providers.add(e);let t=e.subscribe?.(()=>{this.notifySubscribers()});return this.notifySubscribers(),()=>{this._providers.delete(e),t?.(),this.notifySubscribers()}}_subscribers=new Set;notifySubscribers(){for(let e of this._subscribers)e()}subscribe(e){return this._subscribers.add(e),()=>this._subscribers.delete(e)}},N_=[],P_={modelName:void 0,toolNames:N_},F_=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>e===t[n]),I_=(e,t)=>{let n=e.getModelContext(),r=n.config?.modelName,i=n.tools?Object.keys(n.tools).sort():N_,a=i.length?i:N_;return r===t.modelName&&F_(a,t.toolNames)?t:{modelName:r,toolNames:a}},L_=Fg(()=>{let e=s_(()=>new M_,[]),[t,n]=e_(()=>I_(e,P_));return r_(()=>(n(t=>I_(e,t)),e.subscribe(()=>{n(t=>I_(e,t))})),[e]),{getState:()=>I_(e,t),getModelContext:()=>e.getModelContext(),subscribe:t=>e.subscribe(t),register:t=>e.registerModelContextProvider(t)}}),R_=e=>e.display===void 0?e.type===`human`:e.display===`standalone`,z_=Symbol(`assistant-ui.store.clientIndex`),B_=e=>e[z_],V_=D_([]),H_=()=>k_(V_),U_=(e,t)=>{let n=H_();return O_(V_,s_(()=>[...n,e],[n,e]),t)},W_=new Set([`$$typeof`,`nodeType`,`then`]),G_=(e,t)=>{if(e===Symbol.toStringTag)return t;if(typeof e!=`symbol`){if(e===`toJSON`)return()=>t;if(!W_.has(e))return!1}},K_=class{getOwnPropertyDescriptor(e,t){let n=this.get(e,t);if(n!==void 0)return{value:n,writable:!1,enumerable:!0,configurable:!1}}set(){return!1}setPrototypeOf(){return!1}defineProperty(){return!1}deleteProperty(){return!1}preventExtensions(){return!1}},q_=e=>{let t=Fg(e);return e=>{let n=t(e);return e.key===void 0?n:Ig(e.key,n)}},J_=Symbol(`assistant-ui.store.getValue`),Y_=e=>{let t=e[J_];if(!t)throw Error(`Client scope contains a non-client resource. Ensure your Derived get() returns a client created with tapClientResource(), not a plain resource.`);return t.getState?.()},X_=new Map;function Z_(e){let t=X_.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[J_];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 r(...t)},X_.set(e,t)),t}var Q_=class extends K_{outputRef;index;boundFns;cachedReceiver;constructor(e,t){super(),this.outputRef=e,this.index=t}get(e,t,n){if(t===J_)return this.outputRef.current;if(t===z_)return this.index;let r=G_(t,`ClientProxy`);if(r!==!1)return r;let i=this.outputRef.current[t];if(typeof i==`function`){this.cachedReceiver!==n&&(this.boundFns=new Map,this.cachedReceiver=n);let e=this.boundFns.get(t);return e||(e=Z_(t).bind(n),this.boundFns.set(t,e)),e}return i}ownKeys(){return Object.keys(this.outputRef.current)}has(e,t){return t===J_||t===z_?!0:t in this.outputRef.current}},$_=q_(e=>{let t=i_(null),n=H_().length,r=s_(()=>new Proxy({},new Q_(t,n)),[n]),i=U_(r,()=>g_(e));return t.current||=i,r_(()=>{t.current=i}),{methods:r,state:i.getState?.(),key:e.key}}),ev=e=>g_($_(e)),tv=Symbol(`assistant-ui.store.proxiedAssistantState`),nv=e=>e===`on`||e===`subscribe`||typeof e==`symbol`,rv=e=>{class t extends K_{get(t,n){let r=G_(n,`AssistantState`);if(r!==!1)return r;let i=n;if(!nv(i))return Y_(e[i]())}ownKeys(){return Object.keys(e).filter(e=>!nv(e))}has(t,n){return!nv(n)&&n in e}}return new Proxy({},new t)},iv=e=>e[tv],av=()=>()=>{},ov=e=>{let t=(()=>{throw Error(e)});return t.source=null,t.query=null,t},sv=new Proxy({},new class extends K_{get(e,t){if(t===`subscribe`||t===`on`)return av;if(t===tv)return cv;let n=G_(t,`DefaultAssistantClient`);return n===!1?ov(`You are using a component or hook that requires an AuiProvider. Wrap your component in an <AuiProvider> component.`):n}ownKeys(){return[`subscribe`,`on`,tv]}has(e,t){return t===`subscribe`||t===`on`||t===tv}}),cv=rv(sv),lv=()=>new Proxy({},{get(e,t){let n=G_(t,`AssistantClient`);return n===!1?ov(`The current scope does not have a "${String(t)}" property.`):n}}),uv=(0,_.createContext)(sv),dv=()=>(0,_.useContext)(uv),fv=({value:e,children:t})=>(0,G.jsx)(uv.Provider,{value:e,children:t}),pv=Fg(e=>null),mv=Symbol(`assistant-ui.transform-scopes`);function hv(e,t){let n=e;if(n[mv])throw Error(`transformScopes is already attached to this resource`);n[mv]=t}function gv(e){return e[mv]}var _v=e=>typeof e==`string`?{scope:e.split(`.`)[0],event:e}:{scope:e.scope,event:e.event},vv=D_(null),yv=(e,t)=>O_(vv,e,t),bv=()=>{let e=k_(vv);if(!e)throw Error(`AssistantTapContext is not available`);return e},xv=()=>bv().clientRef,Sv=()=>{let{emit:e}=bv(),t=H_();return l_((n,r)=>{e(n,r,t)})};function Cv(e,t){let n={...e},r=new Set,i=!0;for(;i;){i=!1;for(let e of Object.values(n)){if(e.type===pv||r.has(e.type))continue;r.add(e.type);let a=gv(e.type);if(a){a(n,t),i=!0;break}}}let a={},o={};for(let[e,t]of Object.entries(n))t.type===pv?o[e]=t:a[e]=t;return{rootClients:a,derivedClients:o}}var wv=e=>s_(()=>e,[...Object.entries(e).flat()]),Tv=(e,t)=>{let{rootClients:n,derivedClients:r}=Cv(e,t);return{rootClients:wv(n),derivedClients:wv(r)}},Ev=Fg(()=>a_(()=>{let e=new Map,t=new Set,n=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.delete(n)}},emit(n,r,i){let a=e.get(n);!a&&t.size===0||queueMicrotask(()=>{let e=[];if(a)for(let t of a)try{t(r,i)}catch(t){e.push(t)}if(t.size>0){let a={event:n,payload:r};for(let n of t)try{n(a,i)}catch(t){e.push(t)}}if(e.length>0){if(e.length===1)throw e[0];for(let t of e)console.error(t);throw AggregateError(e,`Errors occurred during event emission`)}})},subscribe(e){return n.add(e),()=>n.delete(e)},notifySubscribers(){for(let e of n)try{e()}catch(e){console.error(`NotificationManager: subscriber callback error`,e)}}}},[])),Dv=()=>{if(!Lg)return null;let e=(0,_.useRef)(0),t=e.current===0;return(0,_.useState)(()=>e.current++),e.current===2?t?`child`:`root`:null};function Ov(e){let t=(0,_.useMemo)(()=>Hg(e=>r(e)),[]),[n,r]=(0,_.useReducer)((e,n)=>(Wg(t,e),e+ +!!n()),0);Wg(t,n);let i=Dv(),a=(0,_.useMemo)(()=>(e.key,f_(e.type,t,void 0,i)),[e.type,e.key,t,i]),o=m_(a,e.props);return(0,_.useLayoutEffect)(()=>()=>p_(a),[a]),(0,_.useLayoutEffect)(()=>{Ug(t),h_(a,o)}),o.output}var kv=e=>s_(()=>e,e),Av=Fg(({element:e,emit:t,clientRef:n})=>{let{methods:r,state:i}=yv({clientRef:n,emit:t},()=>ev(e));return s_(()=>({state:i,methods:r}),[r,i])}),jv=Fg(({element:e,notifications:t,clientRef:n,name:r})=>{let i=T_(Av({element:e,emit:t.emit,clientRef:n}));return r_(()=>i.subscribe(t.notifySubscribers),[i,t]),s_(()=>{let e=()=>i.getValue().methods;return Object.defineProperties(e,{source:{value:`root`,writable:!1},query:{value:{},writable:!1},name:{value:r,configurable:!0}}),e},[i,r])}),Mv=Fg(()=>s_(()=>({clients:[],subscribe:void 0,on:void 0}),[])),Nv=Fg(({clients:e,clientRef:t})=>{let n=g_(Ev());r_(()=>t.parent.subscribe(n.notifySubscribers),[t,n]);let r=kv(__(()=>Object.keys(e).map(r=>Ig(r,jv({element:e[r],notifications:n,clientRef:t,name:r}))),[e,n,t]));return s_(()=>({clients:r,subscribe:n.subscribe,on:function(e,r){if(!this)throw Error(`const { on } = useAui() is not supported. Use aui.on() instead.`);let{scope:i,event:a}=_v(e);if(i!==`*`&&this[i].source===null)throw Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);let o=n.on(a,(e,t)=>{if(i===`*`){r(e);return}let n=this[i]();n===t[B_(n)]&&r(e)});if(i!==`*`&&t.parent[i].source===null)return o;let s=t.parent.on(e,r);return()=>{o(),s()}}}),[r,n,t])}),Pv=Fg(({element:e,clientRef:t,name:n})=>{let r=i_(e.props);return r.current=e.props,s_(()=>{let e=()=>r.current.get(t.current);return Object.defineProperties(e,{source:{value:r.current.source},query:{value:r.current.query},name:{value:n,configurable:!0}}),e},[t,n])}),Fv=(e,t)=>{let n;try{let e={};for(let n of Object.keys(t.query).sort())e[n]=t.query[n];n=JSON.stringify(e)}catch{n=String(t.query)}return`${e}::${t.source}::${n}`},Iv=Fg(({clients:e,clientRef:t})=>kv(__(()=>Object.keys(e).map(n=>{let r=n,i=e[r];return Ig(Fv(r,i.props),Pv({element:i,clientRef:t,name:r}))}),[e,t]))),Lv=Fg(({parent:e,clients:t})=>{let{rootClients:n,derivedClients:r}=Tv(t,e),i=i_({parent:e,current:null}).current;r_(()=>{i.current=s});let a=g_(Object.keys(n).length>0?Nv({clients:n,clientRef:i}):Mv()),o=g_(Iv({clients:r,clientRef:i})),s=s_(()=>{let t=e===sv?lv():e,n=Object.create(t);Object.assign(n,{subscribe:a.subscribe??e.subscribe,on:a.on??e.on,[tv]:rv(n)});for(let e of a.clients)n[e.name]=e;for(let e of o)n[e.name]=e;return n},[e,a,o]);return i.current===null&&(i.current=s),s});function Rv(e,{parent:t}={parent:dv()}){if(e)return Ov(Lv({parent:t??sv,clients:e}));if(t===null)throw Error(`received null parent, this usage is not allowed`);return t}var Z=e=>{let t=Rv(),n=iv(t),r=(0,_.useSyncExternalStore)(t.subscribe,()=>e(n),()=>e(n));if(r===n)throw Error(`You tried to return the entire AssistantState. This is not supported due to technical limitations.`);return(0,_.useDebugValue)(r),r},zv=({children:e,condition:t})=>Z(t)?e:null;zv.displayName=`AuiIf`;var Bv=e=>{let t=Rv(),n=(0,_.useRef)(!1),r=n.current?null:e(t);return Z(()=>n.current?e(t):r),()=>(n.current=!0,e(t))},Vv=Object.freeze({});function Hv({getItemState:e,children:t}){return Uv(t(Bv(e)))}var Uv=e=>{let t=typeof e==`object`&&e&&`type`in e?e:null,n=t?.type,r=t?.key;return(0,_.useMemo)(()=>t,[n,r,typeof t?.props==`object`&&t.props!=null&&Object.entries(t.props).length===0?Vv:t?.props])??e},Wv=_.createContext(!0);function Gv(){throw Error(`A function wrapped in useEffectEvent can't be called during rendering.`)}var Kv=`use`in _.default?()=>{try{return _.use(Wv)}catch{return!1}}:()=>!1;function qv(e){let t=_.useRef(Gv);return _.useInsertionEffect(()=>{t.current=e},[e]),(...e)=>{Kv()&&Gv();let n=t.current;return n(...e)}}var Jv=(e,t)=>{let n=Rv(),r=qv(t),{scope:i,event:a}=_v(e);(0,_.useEffect)(()=>n.on({scope:i,event:a},r),[n,i,a])},Yv=q_(e=>{if(e.key===void 0)throw Error(`tapClientResource: Element has no key`);return g_($_(e))});function Xv(e,t){let n=__(()=>e().map(e=>Yv(e)),t),r=s_(()=>Object.keys(n),[n]),i=s_(()=>n.reduce((e,t,n)=>(e[t.key]=n,e),{}),[n]);return{state:s_(()=>n.map(e=>e.state),[n]),get:e=>{if(`index`in e){if(e.index<0||e.index>=r.length)throw Error(`tapClientLookup: Index ${e.index} out of bounds (length: ${r.length})`);return n[e.index].methods}let t=i[e.key];if(t===void 0)throw Error(`tapClientLookup: Key "${e.key}" not found`);return n[t].methods}}}var Zv=Fg(({toolkit:e,mcpApp:t})=>{let n=__(()=>t?[Ig(`mcpApp`,t)]:[],[t])[0],[r,i]=e_(()=>({})),a=s_(()=>({toolUIs:r,mcpApp:n,tools:Object.fromEntries(Object.entries(r).map(([e,t])=>[e,t.map(e=>e.render)]))}),[r,n]),o=xv(),s=c_((e,t,n)=>{let r={render:t,standalone:n?.standalone??!1};return i(t=>({...t,[e]:[...t[e]??[],r]})),()=>{i(t=>{let n=t[e]?.filter(e=>e!==r)??[];if(n.length>0)return{...t,[e]:n};let{[e]:i,...a}=t;return a})}},[]);return r_(()=>{if(!e)return;let t=[];for(let[n,r]of Object.entries(e))r.render&&t.push(s(n,r.render,{standalone:R_(r)}));let n=Object.entries(e).reduce((e,[t,n])=>{let{render:r,display:i,...a}=n;return e[t]=a,e},{});return t.push(o.current.modelContext().register({getModelContext:()=>({tools:n})})),()=>{t.forEach(e=>e())}},[e,s,o]),{getState:()=>a,setToolUI:s}});hv(Zv,(e,t)=>{!e.modelContext&&t.modelContext.source===null&&(e.modelContext=L_())});var Qv=e=>{let[,t]=e_(e.getState);return r_(()=>(t(e.getState()),e.subscribe(()=>{t(e.getState())})),[e]),e.getState()},$v=Fg(({runtime:e})=>{let t=Qv(e);return{getState:()=>t,remove:e.remove,__internal_getRuntime:()=>e}}),ey=Fg(({runtime:e,index:t})=>g_($v({runtime:s_(()=>e.getAttachmentByIndex(t),[e,t])}))),ty=Fg(({threadIdRef:e,messageIdRef:t,runtime:n})=>{let r=Qv(n),i=Sv();r_(()=>{let r=[];for(let a of[`send`,`attachmentAdd`]){let o=n.unstable_on(a,()=>{i(`composer.${a}`,{threadId:e.current,...t&&{messageId:t.current}})});r.push(o)}return r.push(n.unstable_on(`attachmentAddError`,n=>{i(`composer.attachmentAddError`,{threadId:e.current,...t&&{messageId:t.current},...n.attachmentId&&{attachmentId:n.attachmentId},reason:n.reason,message:n.message})})),()=>{for(let e of r)e()}},[n,i,e,t]);let a=Xv(()=>r.attachments.map((e,t)=>Ig(e.id,ey({runtime:n,index:t}))),[r.attachments,n]),o=s_(()=>({text:r.text,role:r.role,attachments:a.state,runConfig:r.runConfig,isEditing:r.isEditing,canCancel:r.canCancel,canSend:r.canSend,attachmentAccept:r.attachmentAccept,isEmpty:r.isEmpty,type:r.type??`thread`,dictation:r.dictation,quote:r.quote,queue:[]}),[r,a.state]);return{getState:()=>o,setText:n.setText,setRole:n.setRole,setRunConfig:n.setRunConfig,addAttachment:n.addAttachment,reset:n.reset,clearAttachments:n.clearAttachments,send:n.send,cancel:n.cancel,beginEdit:n.beginEdit??(()=>{throw Error(`beginEdit is not supported in this runtime`)}),startDictation:n.startDictation,stopDictation:n.stopDictation,setQuote:n.setQuote,attachment:e=>`id`in e?a.get({key:e.id}):a.get(e),queueItem:()=>{throw Error(`Queue is not supported in this runtime`)},__internal_getRuntime:()=>n}}),ny=Fg(({runtime:e})=>{let t=Qv(e);return{getState:()=>t,addToolResult:t=>e.addToolResult(t),resumeToolCall:t=>e.resumeToolCall(t),respondToToolApproval:t=>e.respondToToolApproval(t),__internal_getRuntime:()=>e}}),ry=Fg(({runtime:e,index:t})=>g_($v({runtime:s_(()=>e.getAttachmentByIndex(t),[e,t])}))),iy=Fg(({runtime:e,index:t})=>g_(ny({runtime:s_(()=>e.getMessagePartByIndex(t),[e,t])}))),ay=Fg(({runtime:e,threadIdRef:t})=>{let n=Qv(e),[r,i]=e_(!1),[a,o]=e_(!1),s=s_(()=>({get current(){return e.getState().id}}),[e]),c=ev(ty({runtime:e.composer,threadIdRef:t,messageIdRef:s})),l=Xv(()=>n.content.map((t,n)=>Ig(`toolCallId`in t&&t.toolCallId!=null?`toolCallId-${t.toolCallId}`:`index-${n}`,iy({runtime:e,index:n}))),[n.content,e]),u=Xv(()=>(n.attachments??[]).map((t,n)=>Ig(t.id,ry({runtime:e,index:n}))),[n.attachments,e]),d=s_(()=>({...n,parts:l.state,composer:c.state,isCopied:r,isHovering:a}),[n,l.state,c.state,r,a]);return{getState:()=>d,composer:()=>c.methods,reload:t=>e.reload(t),speak:()=>e.speak(),stopSpeaking:()=>e.stopSpeaking(),submitFeedback:t=>e.submitFeedback(t),switchToBranch:t=>e.switchToBranch(t),getCopyText:()=>e.unstable_getCopyText(),part:e=>`index`in e?l.get({index:e.index}):l.get({key:`toolCallId-${e.toolCallId}`}),attachment:e=>`id`in e?u.get({key:e.id}):u.get(e),setIsCopied:i,setIsHovering:o,__internal_getRuntime:()=>e}}),oy=Fg(({runtime:e,id:t,threadIdRef:n})=>g_(ay({runtime:s_(()=>e.getMessageById(t),[e,t]),threadIdRef:n}))),sy=Fg(({runtime:e})=>{let t=Qv(e),n=Sv();r_(()=>{let t=[];for(let r of[`runStart`,`runEnd`,`initialize`,`modelContextUpdate`]){let i=e.unstable_on(r,()=>{let t=e.getState()?.threadId||`unknown`;n(`thread.${r}`,{threadId:t})});t.push(i)}return()=>{for(let e of t)e()}},[e,n]);let r=s_(()=>({get current(){return e.getState().threadId}}),[e]),i=ev(ty({runtime:e.composer,threadIdRef:r})),a=Xv(()=>t.messages.map(t=>Ig(t.id,oy({runtime:e,id:t.id,threadIdRef:r}))),[t.messages,e,r]),o=s_(()=>({isEmpty:a.state.length===0&&!t.isLoading,isDisabled:t.isDisabled,isLoading:t.isLoading,isRunning:t.isRunning,capabilities:t.capabilities,state:t.state,suggestions:t.suggestions,extras:t.extras,speech:t.speech,voice:t.voice,composer:i.state,messages:a.state}),[t,a,i.state]);return{getState:()=>o,composer:()=>i.methods,append:e.append,startRun:e.startRun,resumeRun:e.resumeRun,cancelRun:e.cancelRun,getModelContext:e.getModelContext,export:e.export,import:e.import,reset:e.reset,stopSpeaking:e.stopSpeaking,connectVoice:e.connectVoice,disconnectVoice:e.disconnectVoice,getVoiceVolume:e.getVoiceVolume,subscribeVoiceVolume:e.subscribeVoiceVolume,muteVoice:e.muteVoice,unmuteVoice:e.unmuteVoice,message:e=>`id`in e?a.get({key:e.id}):a.get(e),__internal_getRuntime:()=>e}}),cy=Fg(({runtime:e})=>{let t=Qv(e),n=Sv();return r_(()=>{let t=[];for(let r of[`switchedTo`,`switchedAway`]){let i=e.unstable_on(r,()=>{n(`threadListItem.${r}`,{threadId:e.getState().id})});t.push(i)}return()=>{for(let e of t)e()}},[e,n]),{getState:()=>t,switchTo:e.switchTo,rename:e.rename,archive:e.archive,unarchive:e.unarchive,delete:e.delete,generateTitle:e.generateTitle,initialize:e.initialize,detach:e.detach,__internal_getRuntime:()=>e}}),ly=Fg(({runtime:e,id:t})=>g_(cy({runtime:s_(()=>e.getItemById(t),[e,t])}))),uy=Fg(({runtime:e,__internal_assistantRuntime:t})=>{let n=Qv(e),r=ev(sy({runtime:e.main})),i=Xv(()=>Object.keys(n.threadItems).map(t=>Ig(t,ly({runtime:e,id:t}))),[n.threadItems,e]),a=s_(()=>({mainThreadId:n.mainThreadId,newThreadId:n.newThreadId??null,isLoading:n.isLoading,isLoadingMore:n.isLoadingMore,hasMore:n.hasMore,threadIds:n.threadIds,archivedThreadIds:n.archivedThreadIds,threadItems:i.state,main:r.state}),[n,i.state,r.state]);return{getState:()=>a,thread:()=>r.methods,item:e=>{if(e===`main`)return i.get({key:a.mainThreadId});if(`id`in e)return i.get({key:e.id});let{index:t,archived:n=!1}=e,r=n?a.archivedThreadIds[t]:a.threadIds[t];return i.get({key:r})},switchToThread:async(t,n)=>{await e.switchToThread(t,n)},switchToNewThread:async()=>{await e.switchToNewThread()},getLoadThreadsPromise:()=>e.getLoadThreadsPromise(),reload:()=>e.reload(),loadMore:()=>e.loadMore(),__internal_getAssistantRuntime:()=>t}}),dy=Fg(e=>({getState:()=>e})),fy=Fg(e=>{let[t]=e_(()=>({suggestions:(e??[]).map(e=>typeof e==`string`?{title:e,label:``,prompt:e}:{title:e.title,label:e.label,prompt:e.prompt})})),n=Xv(()=>t.suggestions.map((e,t)=>Ig(t,dy(e))),[t.suggestions]);return{getState:()=>t,suggestion:({index:e})=>n.get({index:e})}}),py=Fg(e=>{let t=xv();return r_(()=>e.registerModelContextProvider(t.current.modelContext()),[e,t]),g_(uy({runtime:e.threads,__internal_assistantRuntime:e}))}),my=(e,t)=>{e.thread??=pv({source:`threads`,query:{type:`main`},get:e=>e.threads().thread(`main`)}),e.threadListItem??=pv({source:`threads`,query:{type:`main`},get:e=>e.threads().item(`main`)}),e.composer??=pv({source:`thread`,query:{},get:e=>e.threads().thread(`main`).composer()}),!e.modelContext&&t.modelContext.source===null&&(e.modelContext=L_()),!e.suggestions&&t.suggestions.source===null&&(e.suggestions=fy())},hy=Fg(e=>g_(py(e)));hv(hy,(e,t)=>{my(e,t),!e.tools&&t.tools.source===null&&(e.tools=Zv({})),!e.dataRenderers&&t.dataRenderers.source===null&&(e.dataRenderers=A_())});var gy=e=>e._core?.RenderComponent,_y=(0,_.memo)(({runtime:e,aui:t=null,children:n})=>{let r=Rv({threads:hy(e)},{parent:t}),i=gy(e);return(0,G.jsxs)(fv,{value:r,children:[i&&(0,G.jsx)(i,{}),n]})}),vy=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??(typeof i!=`object`||!i)?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},yy=(e=>e?vy(e):vy),by=e=>e;function xy(e,t=by){let n=_.useSyncExternalStore(e.subscribe,_.useCallback(()=>t(e.getState()),[e,t]),_.useCallback(()=>t(e.getInitialState()),[e,t]));return _.useDebugValue(n),n}var Sy=e=>{let t=yy(e),n=e=>xy(t,e);return Object.assign(n,t),n},Cy=(e=>e?Sy(e):Sy),wy=()=>{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}},Ty=()=>{let e=[],t=!1,n,r,i=i=>{i.promise||=i.reader.read().then(({done:a,value:o})=>{i.promise=void 0,a?(e.splice(e.indexOf(i),1),t&&e.length===0&&n.close()):n.enqueue(o),r?.resolve(),r=void 0}).catch(t=>{console.error(t),e.forEach(e=>{e.reader.cancel()}),e.length=0,n.error(t),r?.reject(t),r=void 0})};return{readable:new ReadableStream({start(e){n=e},pull(){return r=wy(),e.forEach(e=>{i(e)}),r.promise},cancel(){e.forEach(e=>{e.reader.cancel()}),e.length=0}}),isSealed(){return t},seal(){t=!0,e.length===0&&n.close()},addStream(n){if(t)throw Error(`Cannot add streams after the run callback has settled.`);let r={reader:n.getReader()};e.push(r),i(r)},enqueue(e){this.addStream(new ReadableStream({start(t){t.enqueue(e),t.close()}}))}}},Ey=class{_controller;_isClosed=!1;constructor(e){this._controller=e}append(e){return this._controller.enqueue({type:`text-delta`,path:[],textDelta:e}),this}close(){this._isClosed||(this._isClosed=!0,this._controller.enqueue({type:`part-finish`,path:[]}),this._controller.close())}},Dy=e=>new ReadableStream({start(t){return e.start?.(new Ey(t))},pull(t){return e.pull?.(new Ey(t))},cancel(t){return e.cancel?.(t)}}),Oy=()=>{let e;return[Dy({start(t){e=t}}),e]},ky=class{_controller;_isClosed=!1;_mergeTask;constructor(e){this._controller=e;let t=Dy({start:e=>{this._argsTextController=e}}),n=!1;this._mergeTask=t.pipeTo(new WritableStream({write:e=>{switch(e.type){case`text-delta`:n=!0,this._controller.enqueue(e);break;case`part-finish`:n||this._controller.enqueue({type:`text-delta`,textDelta:`{}`,path:[]}),this._controller.enqueue({type:`tool-call-args-text-finish`,path:[]});break;default:throw Error(`Unexpected chunk type: ${e.type}`)}}}))}get argsText(){return this._argsTextController}_argsTextController;async setResponse(e){this._argsTextController.close(),await Promise.resolve(),this._controller.enqueue({type:`result`,path:[],...e.artifact===void 0?{}:{artifact:e.artifact},result:e.result,isError:e.isError??!1,...e.modelContent===void 0?{}:{modelContent:e.modelContent},...e.messages===void 0?{}:{messages:e.messages}})}async close(){this._isClosed||(this._isClosed=!0,this._argsTextController.close(),await this._mergeTask,this._controller.enqueue({type:`part-finish`,path:[]}),this._controller.close())}},Ay=e=>new ReadableStream({start(t){return e.start?.(new ky(t))},pull(t){return e.pull?.(new ky(t))},cancel(t){return e.cancel?.(t)}}),jy=()=>{let e;return[Ay({start(t){e=t}}),e]},My=class{value=-1;up(){return++this.value}},Ny=class extends TransformStream{constructor(e){super({transform(t,n){n.enqueue({...t,path:[e,...t.path]})}})}};TransformStream;var Py=class extends TransformStream{constructor(e){let t=new My,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({...r,path:[s,...o]})}})}},Fy=class extends TransformStream{constructor(e){super();let t=e(super.readable);Object.defineProperty(this,"readable",{value:t,writable:!1})}},Iy=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);return}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({...t,meta:i});return}n.enqueue(t)}})}},Ly=(e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i--;)r+=e[Math.random()*e.length|0];return r},Ry=Ly(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7),zy=class e{_state;_parentId;constructor(e){this._state=e||{merger:Ty(),contentCounter:new My}}get __internal_isClosed(){return this._state.merger.isSealed()}__internal_getReadable(){return this._state.merger.readable}__internal_subscribeToClose(e){this._state.closeSubscriber=e}_addPart(e,t){this._state.append&&(this._state.append.controller.close(),this._state.append=void 0),this.enqueue({type:`part-start`,part:e,path:[]}),this._state.merger.addStream(t.pipeThrough(new Ny(this._state.contentCounter.value)))}merge(e){this._state.merger.addStream(e.pipeThrough(new Py(this._state.contentCounter)))}appendText(e){(this._state.append?.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){(this._state.append?.kind!==`reasoning`||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:`reasoning`,parentId:this._parentId,controller:this.addReasoningPart()}),this._state.append.controller.append(e)}addTextPart(){let[e,t]=Oy();return this._addPart(this._withParentIdOption({type:`text`}),e),t}addReasoningPart(){let[e,t]=Oy();return this._addPart(this._withParentIdOption({type:`reasoning`}),e),t}addToolCallPart(e){let t=typeof e==`string`?{toolName:e}:e,n=t.toolName,r=t.toolCallId??Ry(),[i,a]=jy();return this._addPart({type:`tool-call`,toolName:n,toolCallId:r,...this._parentId&&{parentId:this._parentId}},i),t.argsText!==void 0&&(a.argsText.append(t.argsText),a.argsText.close()),t.args!==void 0&&(a.argsText.append(JSON.stringify(t.args)),a.argsText.close()),t.response!==void 0&&a.setResponse(t.response),a}_finishedPartStream(){return new ReadableStream({start(e){e.enqueue({type:`part-finish`,path:[]}),e.close()}})}_withParentIdOption(e){return this._parentId?{...e,parentId:this._parentId}:e}appendSource(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendFile(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendData(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}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(){this._state.append?.controller?.close(),this._state.merger.seal(),this._state.closeSubscriber?.()}};function By(e){let t=new zy;return(async()=>{try{await e(t)}catch(e){throw t.__internal_isClosed||t.enqueue({type:`error`,path:[],error:String(e)}),e}finally{t.__internal_isClosed||t.close()}})(),t.__internal_getReadable()}function Vy(){let{resolve:e,promise:t}=wy(),n;return[By(r=>(n=r,n.__internal_subscribeToClose(e),t)),n]}function Hy(e){let t=[`ROOT`],n=-1,r=null,i=[],a;function o(){a!==void 0&&(i.push(JSON.parse(`"${a}"`)),a=void 0)}function s(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`),o();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`),o();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`),o();break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`),o();break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`),o();break}}function c(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop(),a=i.pop();break}}function l(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),a=(Number(a)+1).toString();break;case`]`:n=r,t.pop(),a=i.pop();break}}for(let o=0;o<e.length;o++){let u=e[o];switch(t[t.length-1]){case`ROOT`:s(u,o,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`),a=``;break;case`}`:n=o,t.pop(),a=i.pop();break}break;case`INSIDE_OBJECT_AFTER_COMMA`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`),a=``;break}break;case`INSIDE_OBJECT_KEY`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`);break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`),a+=u;break;default:a+=u;break}break;case`INSIDE_OBJECT_AFTER_KEY`:switch(u){case`:`:t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`);break}break;case`INSIDE_OBJECT_BEFORE_VALUE`:s(u,o,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:c(u,o);break;case`INSIDE_STRING`:switch(u){case`"`:t.pop(),n=o,a=i.pop();break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=o}break;case`INSIDE_ARRAY_START`:switch(u){case`]`:n=o,t.pop(),a=i.pop();break;default:n=o,a=`0`,s(u,o,`INSIDE_ARRAY_AFTER_VALUE`);break}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(u){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),a=(Number(a)+1).toString();break;case`]`:n=o,t.pop(),a=i.pop();break;default:n=o;break}break;case`INSIDE_ARRAY_AFTER_COMMA`:s(u,o,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:t.pop(),t[t.length-1]===`INSIDE_STRING`?n=o:t[t.length-1]===`INSIDE_OBJECT_KEY`&&(a+=u);break;case`INSIDE_NUMBER`:switch(u){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=o;break;case`e`:case`E`:case`-`:case`.`:break;case`,`:t.pop(),a=i.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&l(u,o),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&c(u,o);break;case`}`:t.pop(),a=i.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&c(u,o);break;case`]`:t.pop(),a=i.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&l(u,o);break;default:t.pop(),a=i.pop();break}break;case`INSIDE_LITERAL`:{let i=e.substring(r,o+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?c(u,o):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&l(u,o)):n=o;break}}}let u=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:u+=`"`;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`:u+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:u+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?u+=`true`.slice(t.length):`false`.startsWith(t)?u+=`false`.slice(t.length):`null`.startsWith(t)&&(u+=`null`.slice(t.length))}}return[u,i]}var Uy=n(r(((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;try{return a(e,t,{safe:!0})}catch{return}finally{Error.stackTraceLimit=n}}t.exports=s,t.exports.default=s,t.exports.parse=s,t.exports.safeParse=c,t.exports.scan=o}))(),1),Wy=Symbol(`aui.parse-partial-json-object.meta`),Gy=e=>e?.[Wy],Ky=e=>{if(e.length===0)return{[Wy]:{state:`partial`,partialPath:[]}};try{let t=Uy.default.parse(e);if(typeof t!=`object`||!t)throw Error(`argsText is expected to be an object`);return t[Wy]={state:`complete`,partialPath:[]},t}catch{try{let[t,n]=Hy(e),r=Uy.default.parse(t);if(typeof r!=`object`||!r)throw Error(`argsText is expected to be an object`);return r[Wy]={state:`partial`,partialPath:n},r}catch{return}}},qy=(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 qy(s,{state:`partial`,partialPath:o},i)},Jy=(e,t)=>{let n=Gy(e);if(!n)throw Error(`unable to determine object state`);return qy(e,n,t.map(String))};async function*Yy(){let e=this.getReader();try{for(;;){let{done:t,value:n}=await e.read();if(t)break;yield n}}finally{e.releaseLock()}}function Xy(e){return e[Symbol.asyncIterator]??=Yy,e}var Zy=Symbol.for(`aui.tool-response`),Qy=class e{get[Zy](){return!0}artifact;result;isError;modelContent;messages;constructor(e){e.artifact!==void 0&&(this.artifact=e.artifact),this.result=e.result,this.isError=e.isError??!1,e.modelContent!==void 0&&(this.modelContent=e.modelContent),e.messages!==void 0&&(this.messages=e.messages)}static[Symbol.hasInstance](e){return typeof e==`object`&&!!e&&Zy in e}static toResponse(t){return t instanceof e?t:new e({result:t===void 0?`<no result>`:t})}};function $y(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)}}function eb(e,t){let n=e;for(let e of t){if(n==null)return;n=n[e]}return n}var tb=class{resolve;reject;disposed=!1;fieldPath;constructor(e,t,n){this.resolve=e,this.reject=t,this.fieldPath=n}update(e){if(!this.disposed)try{if(Jy(e,this.fieldPath)===`complete`){let t=eb(e,this.fieldPath);t!==void 0&&(this.resolve(t),this.dispose())}}catch(e){this.reject(e),this.dispose()}}dispose(){this.disposed=!0}},nb=class{controller;disposed=!1;fieldPath;constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=eb(e,this.fieldPath);t!==void 0&&this.controller.enqueue(t),Jy(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}dispose(){this.disposed=!0}},rb=class{controller;disposed=!1;fieldPath;lastValue=void 0;constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=eb(e,this.fieldPath);if(t!==void 0&&typeof t==`string`){let e=t.substring(this.lastValue?.length||0);this.lastValue=t,this.controller.enqueue(e)}Jy(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}dispose(){this.disposed=!0}},ib=class{controller;disposed=!1;fieldPath;processedIndexes=new Set;constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=eb(e,this.fieldPath);if(!Array.isArray(t))return;for(let n=0;n<t.length;n++)this.processedIndexes.has(n)||Jy(e,[...this.fieldPath,n])===`complete`&&(this.controller.enqueue(t[n]),this.processedIndexes.add(n));Jy(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}dispose(){this.disposed=!0}},ab=class{argTextDeltas;handles=new Set;args=Ky(``);constructor(e){this.argTextDeltas=e,this.processStream()}async processStream(){try{let e=``,t=this.argTextDeltas.getReader();for(;;){let{value:n,done:r}=await t.read();if(r)break;e+=n;let i=Ky(e);if(i!==void 0){this.args=i;for(let e of this.handles)e.update(i)}}}catch(e){console.error(`Error processing argument stream:`,e);for(let e of this.handles)e.dispose()}}get(...e){return new Promise((t,n)=>{let r=new tb(t,n,e);if(this.args&&Jy(this.args,e)===`complete`){let n=eb(this.args,e);if(n!==void 0){t(n);return}}this.handles.add(r),r.update(this.args)})}streamValues(...e){let t=e;return Xy(new ReadableStream({start:e=>{let n=new nb(e,t);this.handles.add(n),n.update(this.args)},cancel:()=>{for(let e of this.handles)if(e instanceof nb){e.dispose(),this.handles.delete(e);break}}}))}streamText(...e){let t=e;return Xy(new ReadableStream({start:e=>{let n=new rb(e,t);this.handles.add(n),n.update(this.args)},cancel:()=>{for(let e of this.handles)if(e instanceof rb){e.dispose(),this.handles.delete(e);break}}}))}forEach(...e){let t=e;return Xy(new ReadableStream({start:e=>{let n=new ib(e,t);this.handles.add(n),n.update(this.args)},cancel:()=>{for(let e of this.handles)if(e instanceof ib){e.dispose(),this.handles.delete(e);break}}}))}},ob=class{promise;constructor(e){this.promise=e}get(){return this.promise}},sb=class{args;response;writable;resolve;argsText=``;constructor(){let e=new TransformStream;this.writable=e.writable,this.args=new ab(e.readable);let{promise:t,resolve:n}=wy();this.resolve=n,this.response=new ob(t)}async appendArgsTextDelta(e){let t=this.writable.getWriter();try{await t.write(e)}catch(e){console.warn(e)}finally{t.releaseLock()}this.argsText+=e}setResponse(e){this.resolve(e)}result={get:async()=>(await this.response.get()).result}},cb=class extends Fy{constructor(e){let t=new Map,n=new Map;super(r=>{let i=new TransformStream({transform(r,i){switch((r.type!==`part-finish`||r.meta.type!==`tool-call`)&&i.enqueue(r),r.type){case`part-start`:if(r.part.type===`tool-call`){let t=new sb;n.set(r.part.toolCallId,t),e.streamCall({reader:t,toolCallId:r.part.toolCallId,toolName:r.part.toolName})}break;case`text-delta`:if(r.meta.type===`tool-call`){let e=r.meta.toolCallId,t=n.get(e);if(!t)throw Error(`No controller found for tool call`);t.appendArgsTextDelta(r.textDelta)}break;case`result`:{if(r.meta.type!==`tool-call`)break;let{toolCallId:e}=r.meta,t=n.get(e);if(!t)throw Error(`No controller found for tool call`);t.setResponse(new Qy({result:r.result,artifact:r.artifact,isError:r.isError,modelContent:r.modelContent}));break}case`tool-call-args-text-finish`:{if(r.meta.type!==`tool-call`)break;let{toolCallId:a,toolName:o}=r.meta,s=n.get(a);if(!s)throw Error(`No controller found for tool call`);let c=!1,l=$y(()=>{let t;try{t=Uy.default.parse(s.argsText)}catch(e){throw Error(`Function parameter parsing failed. ${JSON.stringify(e.message)}`)}let n=e.execute({toolCallId:a,toolName:o,args:t});return n!==void 0&&(c=!0,e.onExecutionStart?.(a,o)),n},t=>{if(c&&e.onExecutionEnd?.(a,o),t===void 0)return;let n=new Qy({artifact:t.artifact,result:t.result,isError:t.isError,messages:t.messages,modelContent:t.modelContent});s.setResponse(n),i.enqueue({type:`result`,path:r.path,...n})},t=>{c&&e.onExecutionEnd?.(a,o);let n=new Qy({result:String(t),isError:!0});s.setResponse(n),i.enqueue({type:`result`,path:r.path,...n})});l&&t.set(a,l);break}case`part-finish`:{if(r.meta.type!==`tool-call`)break;let{toolCallId:e}=r.meta,a=t.get(e);a?a.then(()=>{t.delete(e),n.delete(e),i.enqueue(r)}):i.enqueue(r)}}},async flush(){await Promise.all(t.values())}});return r.pipeThrough(new Iy).pipeThrough(i)})}},lb=e=>typeof e==`object`&&!!e&&`~standard`in e&&e[`~standard`].version===1;function ub(e,t,n,r){let i=e?.[n.toolName];return i?.execute?(async e=>{if(t.aborted)return new Qy({result:`Tool execution was cancelled.`,isError:!0});let a=e;if(lb(i.parameters)){let e=i.parameters[`~standard`].validate(n.args);e instanceof Promise&&(e=await e),e.issues&&(a=i.experimental_onSchemaValidationError??(()=>{throw Error(`Function parameter validation failed. ${JSON.stringify(e.issues)}`)}))}let o=new Promise(e=>{let n=()=>{queueMicrotask(()=>{queueMicrotask(()=>{e(new Qy({result:`Tool execution was cancelled.`,isError:!0}))})})};t.aborted?n():t.addEventListener(`abort`,n,{once:!0})}),s=(async()=>{let e=await a(n.args,{toolCallId:n.toolCallId,abortSignal:t,human:e=>r(n.toolCallId,e)}),o=Qy.toResponse(e);if(i.toModelOutput&&!o.isError&&o.modelContent===void 0)try{let e=await i.toModelOutput({toolCallId:n.toolCallId,input:n.args,output:o.result});return new Qy({result:o.result,artifact:o.artifact,isError:o.isError,messages:o.messages,modelContent:e})}catch(e){console.warn(`[assistant-stream] tool "${n.toolName}" toModelOutput threw; falling back to default projection.`,e)}return o})();return Promise.race([s,o])})(i.execute):void 0}function db(e,t,n,r,i){e?.[r.toolName]?.streamCall?.(n,{toolCallId:r.toolCallId,abortSignal:t,human:e=>i(r.toolCallId,e)})}function fb(e,t,n,r){let i=typeof e==`function`?e:()=>e,a=typeof t==`function`?t:()=>t;return new cb({execute:e=>ub(i(),a(),e,n),streamCall:({reader:e,...t})=>db(i(),a(),e,t,n),onExecutionStart:r?.onExecutionStart,onExecutionEnd:r?.onExecutionEnd})}var pb=({index:e,children:t})=>(0,G.jsx)(fv,{value:Rv({attachment:pv({source:`message`,query:{type:`index`,index:e},get:t=>t.message().attachment({index:e})})}),children:t}),mb=({index:e,children:t})=>(0,G.jsx)(fv,{value:Rv({attachment:pv({source:`composer`,query:{type:`index`,index:e},get:t=>t.composer().attachment({index:e})})}),children:t}),hb=({index:e,children:t})=>(0,G.jsx)(fv,{value:Rv({message:pv({source:`thread`,query:{type:`index`,index:e},get:t=>t.thread().message({index:e})}),composer:pv({source:`message`,query:{},get:t=>t.thread().message({index:e}).composer()})}),children:t}),gb=({index:e,children:t})=>(0,G.jsx)(fv,{value:Rv({part:pv({source:`message`,query:{type:`index`,index:e},get:t=>t.message().part({index:e})})}),children:t}),_b=Fg(({text:e,isRunning:t})=>{let n=s_(()=>({type:`text`,text:e,status:t?{type:`running`}:{type:`complete`}}),[e,t]);return{getState:()=>n,addToolResult:()=>{throw Error(`Not supported`)},resumeToolCall:()=>{throw Error(`Not supported`)},respondToToolApproval:()=>{throw Error(`Not supported`)}}}),vb=({text:e,isRunning:t=!1,children:n})=>(0,G.jsx)(fv,{value:Rv({part:_b({text:e,isRunning:t})}),children:n}),yb=Object.freeze({type:`complete`}),bb=Fg(({parts:e,getMessagePart:t})=>{let[n,r]=e_(!0),i=s_(()=>e[e.length-1]?.status??yb,[e]),a=s_(()=>({parts:e,collapsed:n,status:i}),[e,n,i]);return{getState:()=>a,setCollapsed:r,part:t}}),xb=({startIndex:e,endIndex:t,children:n})=>{let r=Z(e=>e.message.parts).slice(e,t+1),i=Rv();return(0,G.jsx)(fv,{value:Rv({chainOfThought:bb({parts:r,getMessagePart:({index:t})=>{if(t<0||t>=r.length)throw Error(`ChainOfThought part index ${t} is out of bounds (0..${r.length-1})`);return i.message().part({index:e+t})}})}),children:n})},Sb=({index:e,children:t})=>(0,G.jsx)(fv,{value:Rv({suggestion:pv({source:`suggestions`,query:{index:e},get:t=>t.suggestions().suggestion({index:e})})}),children:t}),Cb=({index:e,children:t})=>(0,G.jsx)(fv,{value:Rv({queueItem:pv({source:`composer`,query:{index:e},get:t=>t.composer().queueItem({index:e})})}),children:t}),wb=Symbol(`innerMessage`),Tb=Symbol(`innerMessages`),Eb=[],Db=(e,t)=>{wb in e||(e[wb]=t)},Ob=e=>{let t=`messages`in e?e.messages:e,n=t[Tb]||t[wb];return n?Array.isArray(n)?n:(t[Tb]=[n],t[Tb]):Eb},kb=Symbol(`skip-update`);function Ab(e,t){if(e===void 0&&t===void 0)return!0;if(e===void 0||t===void 0)return!1;for(let n of Object.keys(e)){let r=e[n],i=t[n];if(!Object.is(r,i))return!1}return!0}var jb=class{_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(){let e=[];for(let t of this._subscribers)try{t()}catch(t){e.push(t)}if(e.length>0){if(e.length===1)throw e[0];for(let t of e)console.error(t);throw AggregateError(e)}}},Mb=class{_subscriptions=new Set;_connection;get isConnected(){return!!this._connection}notifySubscribers(e){for(let t of this._subscriptions)t(e)}_updateConnection(){if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else this._connection?.(),this._connection=void 0}subscribe(e){return this._subscriptions.add(e),this._updateConnection(),()=>{this._subscriptions.delete(e),this._updateConnection()}}},Nb=class extends Mb{binding;get path(){return this.binding.path}constructor(e){super(),this.binding=e;let t=e.getState();if(t===kb)throw Error(`Entry not available in the store`);this._previousState=t}_previousState;getState=()=>(this.isConnected||this._syncState(),this._previousState);_syncState(){let e=this.binding.getState();return e===kb||Ab(e,this._previousState)?!1:(this._previousState=e,!0)}_connect(){return this.binding.subscribe(()=>{this._syncState()&&this.notifySubscribers()})}},Pb=class extends Mb{binding;get path(){return this.binding.path}constructor(e){super(),this.binding=e}_previousStateDirty=!0;_previousState;getState=()=>{if(!this.isConnected||this._previousStateDirty){let e=this.binding.getState();e!==kb&&(this._previousState=e),this._previousStateDirty=!1}if(this._previousState===void 0)throw Error(`Entry not available in the store`);return this._previousState};_connect(){return this.binding.subscribe(()=>{this._previousStateDirty=!0,this.notifySubscribers()})}},Fb=class extends Mb{binding;get path(){return this.binding.path}constructor(e){super(),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?.subscribe(e),r=this.outerSubscribe(()=>{let r=this.binding.getState();r!==t&&(t=r,n?.(),n=r?.subscribe(e),e())});return()=>{r?.(),n?.()}}},Ib=class extends Mb{config;constructor(e){super(),this.config=e}getState(){return this.config.binding.getState()}outerSubscribe(e){return this.config.binding.subscribe(e)}_connect(){let e=e=>{this.notifySubscribers(e)},t=this.config.binding.getState(),n=t?.unstable_on(this.config.event,e),r=this.outerSubscribe(()=>{let r=this.config.binding.getState();r!==t&&(t=r,n?.(),n=r?.unstable_on(this.config.event,e))});return()=>{r?.(),n?.()}}},Lb=class{_core;get path(){return this._core.path}constructor(e){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)}},Rb=class extends Lb{_composerApi;constructor(e,t){super(e),this._composerApi=t}remove(){let e=this._composerApi.getState();if(!e)throw Error(`Composer is not available`);return e.removeAttachment(this.getState().id)}},zb=class extends Rb{get source(){return`thread-composer`}},Bb=class extends Rb{get source(){return`edit-composer`}},Vb=class extends Lb{get source(){return`message`}remove(){throw Error(`Message attachments cannot be removed`)}},Hb=Object.freeze([]),Ub=Object.freeze({}),Wb=e=>Object.freeze({type:`thread`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,attachments:e?.attachments??Hb,text:e?.text??``,role:e?.role??`user`,runConfig:e?.runConfig??Ub,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,value:e?.text??``}),Gb=e=>Object.freeze({type:`edit`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,text:e?.text??``,role:e?.role??`user`,attachments:e?.attachments??Hb,runConfig:e?.runConfig??Ub,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,parentId:e?.parentId??null,sourceId:e?.sourceId??null,value:e?.text??``}),Kb=class{_core;get path(){return this._core.path}constructor(e){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.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){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setText(e)}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()}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)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new Ib({event:e,binding:this._core}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},qb=class extends Kb{get path(){return this._core.path}get type(){return`thread`}_getState;constructor(e){let t=new Pb({path:e.path,getState:()=>Wb(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>t.subscribe(e)}),this._getState=t.getState.bind(t),this.__internal_bindMethods()}getState(){return this._getState()}getAttachmentByIndex(e){return new zb(new Nb({path:{...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?{...t,source:`thread-composer`}:kb},subscribe:e=>this._core.subscribe(e)}),this._core)}},Jb=class extends Kb{_beginEdit;get path(){return this._core.path}get type(){return`edit`}_getState;constructor(e,t){let n=new Pb({path:e.path,getState:()=>Gb(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>n.subscribe(e)}),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 Bb(new Nb({path:{...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?{...t,source:`edit-composer`}:kb},subscribe:e=>this._core.subscribe(e)}),this._core)}},Yb=e=>e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
57
57
|
|
|
58
|
-
`),Xb=class{contentBinding;messageApi;threadApi;get path(){return this.contentBinding.path}constructor(e,t,n){this.contentBinding=e,this.messageApi=t,this.threadApi=n,this.__internal_bindMethods()}__internal_bindMethods(){this.addToolResult=this.addToolResult.bind(this),this.resumeToolCall=this.resumeToolCall.bind(this),this.respondToToolApproval=this.respondToToolApproval.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this.contentBinding.getState()}addToolResult(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);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.messageApi.getState();if(!n)throw Error(`Message is not available`);let r=t.toolName,i=t.toolCallId,a=Qy.toResponse(e);this.threadApi.getState().addToolResult({messageId:n.id,toolName:r,toolCallId:i,result:a.result,artifact:a.artifact,isError:a.isError})}resumeToolCall(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);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`);let n=t.toolCallId;this.threadApi.getState().resumeToolCall({toolCallId:n,payload:e})}respondToToolApproval(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to respond to tool approval on non-tool message part`);if(!t.approval||t.approval.approved!==void 0)throw Error(`Tool call has no pending approval`);if(!this.threadApi)throw Error(`Thread API is not available`);this.threadApi.getState().respondToToolApproval({approvalId:t.approval.id,approved:e.approved,...e.reason!=null&&{reason:e.reason}})}subscribe(e){return this.contentBinding.subscribe(e)}},Zb=Object.freeze({type:`complete`}),Qb=(e,t,n)=>{if(e.role!==`assistant`)return Zb;if(n.type===`tool-call`)return n.result?Zb:e.status;let r=t===Math.max(0,e.content.length-1);return e.status.type===`requires-action`?Zb:r?e.status:Zb},$b=(e,t)=>{let n=e.content[t];if(!n)return kb;let r=Qb(e,t,n);return Object.freeze({...n,[wb]:n[wb],status:r})},ex=class{_core;_threadBinding;get path(){return this._core.path}constructor(e,t){this._core=e,this._threadBinding=t,this.composer=new Jb(new Fb({path:{...this.path,ref:`${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.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)}composer;_getEditComposerRuntimeCore=()=>this._threadBinding.getState().getEditComposer(this._core.getState().id);getState(){return this._core.getState()}reload(e={}){let t=this._getEditComposerRuntimeCore(),n=t??this._threadBinding.getState().composer,r=t??n,{runConfig:i=r.runConfig}=e,a=this._core.getState();if(a.role!==`assistant`)throw Error(`Can only reload assistant messages`);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(){let e=this._core.getState();if(this._threadBinding.getState().speech?.messageId===e.id)this._threadBinding.getState().stopSpeaking();else throw Error(`Message is not being spoken`)}submitFeedback({type:e}){let t=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:t.id,type:e})}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 Yb(this.getState())}subscribe(e){return this._core.subscribe(e)}getMessagePartByIndex(e){if(e<0)throw Error(`Message part index must be >= 0`);return new Xb(new Nb({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.content[${e}]`,messagePartSelector:{type:`index`,index:e}},getState:()=>$b(this.getState(),e),subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getMessagePartByToolCallId(e){return new Xb(new Nb({path:{...this.path,ref: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?kb:$b(t,n)},subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getAttachmentByIndex(e){return new Vb(new Nb({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.attachments[${e}]`,attachmentSource:`message`,attachmentSelector:{type:`index`,index:e}},getState:()=>{let t=this.getState().attachments?.[e];return t?{...t,source:`message`}:kb},subscribe:e=>this._core.subscribe(e)}))}},tx=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{},...e.stream?{stream:e.stream}:{}}),nx=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{}}),rx=(e,t)=>typeof t==`string`?{createdAt:new Date,parentId:e.at(-1)?.id??null,sourceId:null,runConfig:{},role:`user`,content:[{type:`text`,text:t}],attachments:[],metadata:{custom:{}}}:{createdAt:t.createdAt??new Date,parentId:t.parentId??e.at(-1)?.id??null,sourceId:t.sourceId??null,role:t.role??`user`,content:t.content,attachments:t.attachments??[],metadata:t.metadata??{custom:{}},runConfig:t.runConfig??{},startRun:t.startRun},ix=(e,t)=>{let n=e.messages.at(-1);return Object.freeze({threadId:t.id,metadata:t,capabilities:e.capabilities,isDisabled:e.isDisabled,isLoading:e.isLoading,isRunning:e.isRunning??(n?.role===`assistant`?n.status.type===`running`:!1),messages:e.messages,state:e.state,suggestions:e.suggestions,extras:e.extras,speech:e.speech,voice:e.voice})},ax=class{get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}_threadBinding;constructor(e,t){let n=new Nb({path:e.path,getState:()=>ix(e.getState(),t.getState()),subscribe:n=>{let r=e.subscribe(n),i=t.subscribe(n);return()=>{r(),i()}}});this._threadBinding={path:e.path,getState:()=>e.getState(),getStateState:()=>n.getState(),outerSubscribe:t=>e.outerSubscribe(t),subscribe:t=>e.subscribe(t)},this.composer=new qb(new Fb({path:{...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.resumeRun=this.resumeRun.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.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)}composer;getState(){return this._threadBinding.getStateState()}append(e){this._threadBinding.getState().append(rx(this._threadBinding.getState().messages,e))}subscribe(e){return this._threadBinding.subscribe(e)}getModelContext(){return this._threadBinding.getState().getModelContext()}startRun(e){return this._threadBinding.getState().startRun(nx(e))}resumeRun(e){return this._threadBinding.getState().resumeRun(tx(e))}exportExternalState(){return this._threadBinding.getState().exportExternalState()}importExternalState(e){this._threadBinding.getState().importExternalState(e)}cancelRun(){this._threadBinding.getState().cancelRun()}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({...this.path,ref:`${this.path.ref}.messages[${e}]`,messageSelector:{type:`index`,index:e}},()=>{let t=this._threadBinding.getState().messages,n=t[e];if(n)return{message:n,parentId:t[e-1]?.id??null,index:e}})}getMessageById(e){return this._getMessageRuntime({...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 ex(new Nb({path:e,getState:()=>{let{message:e,parentId:n,index:r}=t()??{},{messages:i,speech:a}=this._threadBinding.getState();if(!e||n===void 0||r===void 0)return kb;let o=this._threadBinding.getState().getBranches(e.id);return{...e,[wb]:e[wb],index:r,isLast:i.at(-1)?.id===e.id,parentId:n,branchNumber:o.indexOf(e.id)+1,branchCount:o.length,speech:a?.messageId===e.id?a:void 0}},subscribe:e=>this._threadBinding.subscribe(e)}),this._threadBinding)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new Ib({event:e,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},ox=(0,_.createContext)(null),sx=()=>(0,_.useContext)(ox),cx=class{_core;_threadListBinding;get path(){return this._core.path}constructor(e,t){this._core=e,this._threadListBinding=t,this.__internal_bindMethods()}__internal_bindMethods(){this.switchTo=this.switchTo.bind(this),this.rename=this.rename.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)}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(){let e=this._core.getState();return this._threadListBinding.generateTitle(e.id)}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||t({})))})}subscribe(e){return this._core.subscribe(e)}detach(){let e=this._core.getState();this._threadListBinding.detach(e.id)}__internal_getRuntime(){return this}},lx=Promise.resolve(),ux=e=>({mainThreadId:e.mainThreadId,newThreadId:e.newThreadId,threadIds:e.threadIds,archivedThreadIds:e.archivedThreadIds,isLoading:e.isLoading,isLoadingMore:e.isLoadingMore??!1,hasMore:e.hasMore??!1,threadItems:e.threadItems}),dx=(e,t)=>{if(t===void 0)return kb;let n=e.getItemById(t);return n?{id:n.id,remoteId:n.remoteId,externalId:n.externalId,title:n.title,status:n.status,custom:n.custom,isMain:n.id===e.mainThreadId}:kb},fx=class{_core;_runtimeFactory;_getState;constructor(e,t=ax){this._core=e,this._runtimeFactory=t;let n=new Pb({path:{},getState:()=>ux(e),subscribe:t=>e.subscribe(t)});this._getState=n.getState.bind(n),this._mainThreadListItemRuntime=new cx(new Nb({path:{ref:`threadItems[main]`,threadSelector:{type:`main`}},getState:()=>dx(this._core,this._core.mainThreadId),subscribe:e=>this._core.subscribe(e)}),this._core),this.main=new t(new Fb({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.getLoadThreadsPromise=this.getLoadThreadsPromise.bind(this),this.reload=this.reload.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()}getLoadThreadsPromise(){return this._core.getLoadThreadsPromise()}reload(){return this._core.reload?.()??lx}loadMore(){return this._core.loadMore?.()??lx}getState(){return this._getState()}subscribe(e){return this._core.subscribe(e)}_mainThreadListItemRuntime;main;get mainItem(){return this._mainThreadListItemRuntime}getById(e){return new this._runtimeFactory(new Fb({path:{ref:`threads[threadId=${JSON.stringify(e)}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>this._core.getThreadRuntimeCore(e),subscribe:e=>this._core.subscribe(e)}),this.mainItem)}getItemByIndex(e){return new cx(new Nb({path:{ref:`threadItems[${e}]`,threadSelector:{type:`index`,index:e}},getState:()=>dx(this._core,this._core.threadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getArchivedItemByIndex(e){return new cx(new Nb({path:{ref:`archivedThreadItems[${e}]`,threadSelector:{type:`archiveIndex`,index:e}},getState:()=>dx(this._core,this._core.archivedThreadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getItemById(e){return new cx(new Nb({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>dx(this._core,e),subscribe:e=>this._core.subscribe(e)}),this._core)}},px=class{_core;threads;_thread;constructor(e){this._core=e,this.threads=new fx(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)}},mx=class{_contextProvider=new M_;registerModelContextProvider(e){return this._contextProvider.registerModelContextProvider(e)}getModelContextProvider(){return this._contextProvider}},hx=Object.freeze([]),gx=`DEFAULT_THREAD_ID`,_x=Object.freeze([gx]),vx=Object.freeze({id:gx,remoteId:void 0,externalId:void 0,status:`regular`}),yx=Promise.resolve(),bx=Object.freeze({[gx]:vx}),xx=class{threadFactory;_mainThreadId=gx;_threads=_x;_archivedThreads=hx;_threadData=bx;adapter={};get isLoading(){return this.adapter.isLoading??!1}get newThreadId(){}get threadIds(){return this._threads}get archivedThreadIds(){return this._archivedThreads}get threadItems(){return this._threadData}getLoadThreadsPromise(){return yx}_mainThread;get mainThreadId(){return this._mainThreadId}constructor(e={},t){this.threadFactory=t,this.__internal_setAdapter(e,!0)}getMainThreadRuntimeCore(){return this._mainThread}getThreadRuntimeCore(){throw Error(`Method not implemented.`)}getItemById(e){return this._threadData[e]}__internal_setAdapter(e,t=!1){let n=this.adapter;this.adapter=e;let r=e.threadId??gx,i=e.threads??hx,a=e.archivedThreads??hx,o=n.threadId??gx,s=n.threads??hx,c=n.archivedThreads??hx;!t&&o===r&&s===i&&c===a||((s!==i||c!==a||o!==r)&&(this._threadData={...bx,...Object.fromEntries(e.threads?.map(e=>[e.id,{...e,remoteId:e.remoteId,externalId:e.externalId,status:`regular`}])??[]),...Object.fromEntries(e.archivedThreads?.map(e=>[e.id,{...e,remoteId:e.remoteId,externalId:e.externalId,status:`archived`}])??[])}),s!==i&&(this._threads=this.adapter.threads?.map(e=>e.id)??hx),c!==a&&(this._archivedThreads=this.adapter.archivedThreads?.map(e=>e.id)??hx),(t||o!==r)&&(this._mainThreadId=r,this._mainThread=this.threadFactory()),this._threadData[this._mainThreadId]||(this._threadData={...this._threadData,[this._mainThreadId]:{id:this._mainThreadId,remoteId:void 0,externalId:void 0,status:`regular`}}),this._notifySubscribers())}async switchToThread(e,t){if(this._mainThreadId===e)return;let n=this.adapter.onSwitchToThread;if(!n)throw Error(`External store adapter does not support switching to thread`);await n(e)}async switchToNewThread(){let e=this.adapter.onSwitchToNewThread;if(!e)throw Error(`External store adapter does not support switching to new thread`);await e()}async rename(e,t){let n=this.adapter.onRename;if(!n)throw Error(`External store adapter does not support renaming`);await n(e,t)}async detach(){}async archive(e){let t=this.adapter.onArchive;if(!t)throw Error(`External store adapter does not support archiving`);await t(e)}async unarchive(e){let t=this.adapter.onUnarchive;if(!t)throw Error(`External store adapter does not support unarchiving`);await t(e)}async delete(e){let t=this.adapter.onDelete;if(!t)throw Error(`External store adapter does not support deleting`);await t(e)}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){throw Error(`Method not implemented.`)}_subscriptions=new Set;subscribe(e){return this._subscriptions.add(e),()=>this._subscriptions.delete(e)}_notifySubscribers(){for(let e of this._subscriptions)e()}},Sx=Ly(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7),Cx=Symbol(`autoStatus`),wx=Object.freeze(Object.assign({type:`running`},{[Cx]:!0})),Tx=Object.freeze(Object.assign({type:`complete`,reason:`unknown`},{[Cx]:!0})),Ex=Object.freeze(Object.assign({type:`requires-action`,reason:`tool-calls`},{[Cx]:!0})),Dx=Object.freeze(Object.assign({type:`requires-action`,reason:`interrupt`},{[Cx]:!0})),Ox=e=>e[Cx]===!0,kx=(e,t,n,r,i)=>e&&i?Object.assign({type:`incomplete`,reason:`error`,error:i},{[Cx]:!0}):e&&t?wx:n?Dx:r?Ex:Tx,Ax=(e,t)=>{if(e.startsWith(`data-`))return{type:`data`,name:e.substring(5),data:t}},jx=(e,t,n)=>{let{role:r,id:i,createdAt:a,attachments:o,status:s,metadata:c}=e,l={id:i??t,createdAt:a??new Date},u=typeof e.content==`string`?[{type:`text`,text:e.content}]:e.content,d=({image:e,...t})=>e.match(/^data:image\/(png|jpeg|jpg|gif|webp|svg\+xml);base64,(.*)$/)||/^(https:\/\/|blob:)/.test(e)?{...t,image:e}:(console.warn(`Invalid image data format detected`),null);if(r!==`user`&&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?.steps)throw Error(`metadata.steps is only supported for assistant messages`);switch(r){case`assistant`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:case`reasoning`:return e.text.trim().length===0?null:e;case`file`:case`source`:return e;case`image`:return d(e);case`data`:return e;case`generative-ui`:return e;case`tool-call`:{let{parentId:t,messages:n,...r}=e,i={...r,toolCallId:e.toolCallId??`tool-${Sx()}`,...t!==void 0&&{parentId:t},...n!==void 0&&{messages:n}};return e.args?{...i,args:e.args,argsText:e.argsText??JSON.stringify(e.args)}:{...i,args:Ky(e.argsText??``)??{},argsText:e.argsText??``}}default:{let n=Ax(t,e.data);if(n)return n;throw Error(`Unsupported assistant message part type: ${t}`)}}}).filter(e=>!!e),status:s??n,metadata:{unstable_state:c?.unstable_state??null,unstable_annotations:c?.unstable_annotations??[],unstable_data:c?.unstable_data??[],custom:c?.custom??{},steps:c?.steps??[],...c?.timing&&{timing:c.timing},...c?.submittedFeedback&&{submittedFeedback:c.submittedFeedback},...c?.isOptimistic&&{isOptimistic:!0}}};case`user`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:case`image`:case`audio`:case`file`:case`data`:return e;default:{let n=Ax(t,e.data);if(n)return n;throw Error(`Unsupported user message part type: ${t}`)}}}),attachments:(o??[]).map(e=>({...e,content:e.content.map(e=>Ax(e.type,e.data)??e)})),metadata:{custom:c?.custom??{}}};case`system`:if(u.length!==1||u[0].type!==`text`)throw Error(`System messages must have exactly one text message part.`);return{...l,role:r,content:u,metadata:{custom:c?.custom??{}}};default:throw Error(`Unknown message role: ${r}`)}},Mx={fromArray:e=>{let t=e.map(e=>jx(e,Sx(),kx(!1,!1,!1,!1,void 0)));return{messages:t.map((e,n)=>({parentId:n>0?t[n-1].id:null,message:e}))}},fromBranchableArray:(e,t)=>{let n=kx(!1,!1,!1,!1,void 0);return{...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:jx(e,e.id,n)}})}}},Nx=e=>e.next?Nx(e.next):`current`in e?e:null,Px=class{func;_value=null;constructor(e){this.func=e}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},Fx=class{messages=new Map;head=null;root={children:[],next:null};updateLevels(e,t){e.level=t;for(let n of e.children){let e=this.messages.get(n);e&&this.updateLevels(e,t+1)}}performOp(e,t,n){let r=t.prev??this.root,i=e??this.root;if(!(n===`relink`&&r===i)){if(n!==`link`&&(r.children=r.children.filter(e=>e!==t.current.id),r.next===t)){let e=r.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.`);r.next=t}if(n!==`cut`){for(let n=e;n;n=n.prev)if(n.current.id===t.current.id)throw Error(`MessageRepository(performOp/link): 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.`);i.children=[...i.children,t.current.id],(Nx(t)===this.head||i.next===null)&&(i.next=t),t.prev=e;let n=e?e.level+1:0;this.updateLevels(t,n)}}}_messages=new Px(()=>{let e=Array((this.head?.level??-1)+1);for(let t=this.head;t;t=t.prev)e[t.level]=t.current;return e});get headId(){return this.head?.current.id??null}getMessages(e){if(e===void 0||e===this.head?.current.id)return this._messages.value;let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.`);let n=Array(t.level+1);for(let e=t;e;e=e.prev)n[e.level]=e.current;return n}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){n.current=t,this.performOp(r,n,`relink`),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._messages.dirty()}getMessage(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.`);return{parentId:t.prev?.current.id??null,message:t.current,index:t.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 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=Nx(r??this.root)),this._messages.dirty()}getBranches(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.`);let{children:n}=t.prev??this.root;return n}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&&!n.has(t.current.id);t=t.prev)t.current.metadata?.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,r=t.prev??this.root;r.next=t,this.head=Nx(t),this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}resetHead(e){if(e===null){this.clear();return}let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.`);let n=this.head;if(t.children.length>0){let e=t=>{for(let n of t.children){let t=this.messages.get(n);t&&(e(t),this.messages.delete(n))}};e(t),t.children=[],t.next=null}this.head=t;for(let e=t;e;e=e.prev)e.prev?e.prev.next=e:this.root.next=e;this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){let e=[];for(let[,t]of this.messages)t.current.metadata?.isOptimistic||e.push({message:t.current,parentId:t.prev?.current.id??null});let t=this.head;for(;t?.current.metadata?.isOptimistic;)t=t.prev;return{headId:t?.current.id??null,messages:e}}import({headId:e,messages:t}){for(let{message:e,parentId:n}of t)this.addOrUpdateMessage(n,e);this.resetHead(e??t.at(-1)?.message.id??null)}};function Ix(e,t){if(t===`*`)return!0;let n=t.split(`,`).map(e=>e.trim().toLowerCase()),r=`.${e.name.split(`.`).pop().toLowerCase()}`,i=e.type.toLowerCase();for(let e of n){if(e.startsWith(`.`)&&e===r||e.includes(`/`)&&e===i)return!0;if(e.endsWith(`/*`)){let t=e.split(`/`)[0];if(i.startsWith(`${t}/`))return!0}}return!1}function Lx(e,t){return e.length===t.length?e.every((e,n)=>e.id===t[n].id):!1}function Rx(e){let t=Sx();return e.type===`image`?{id:t,type:`image`,name:e.filename??`image`,content:[e],status:{type:`complete`}}:e.type===`file`?{id:t,type:`document`,name:e.filename??`document`,contentType:e.mimeType,content:[e],status:{type:`complete`}}:e.type===`audio`?{id:t,type:`audio`,name:`audio.${e.audio.format}`,contentType:`audio/${e.audio.format}`,content:[e],status:{type:`complete`}}:{id:t,type:`data`,name:e.name,content:[e],status:{type:`complete`}}}function zx(e){let t=[];for(let n of e)n.type!==`text`&&t.push(Rx(n));return t}var Bx=e=>e.status.type===`complete`,Vx=class extends jb{isEditing=!0;get attachmentAccept(){return this.getAttachmentAdapter()?.accept??`*`}_attachments=[];get attachments(){return this._attachments}setAttachments(e){this._attachments=e,this._notifySubscribers()}get isEmpty(){return!this.text.trim()&&!this.attachments.length}_text=``;get text(){return this._text}_role=`user`;get role(){return this._role}_runConfig={};get runConfig(){return this._runConfig}_quote=void 0;get quote(){return this._quote}setQuote(e){this._quote!==e&&(this._quote=e,this._notifySubscribers())}setText(e){if(this._text!==e){if(this._text=e,this._dictation){this._dictationBaseText=e,this._currentInterimText=``;let{status:t,inputDisabled:n}=this._dictation;this._dictation=n?{status:t,inputDisabled:n}:{status:t}}this._notifySubscribers()}}setRole(e){this._role!==e&&(this._role=e,this._notifySubscribers())}setRunConfig(e){this._runConfig!==e&&(this._runConfig=e,this._notifySubscribers())}_emptyTextAndAttachments(){this._attachments=[],this._text=``,this._notifySubscribers()}async _onClearAttachments(){let e=this.getAttachmentAdapter();if(e){let t=this._attachments.filter(e=>!Bx(e));await Promise.all(t.map(t=>e.remove(t)))}}async reset(){if(this._attachments.length===0&&this._text===``&&this._role===`user`&&Object.keys(this._runConfig).length===0&&this._quote===void 0)return;this._role=`user`,this._runConfig={},this._quote=void 0;let e=this._onClearAttachments();this._emptyTextAndAttachments(),await e}async clearAttachments(){let e=this._onClearAttachments();this.setAttachments([]),await e}async send(e){if(!this.canSend)return;this._dictationSession&&(this._dictationSession.cancel(),this._cleanupDictation());let t=this.getAttachmentAdapter(),n=this.attachments.length>0?Promise.all(this.attachments.map(async e=>{if(Bx(e))return e;if(!t)throw Error(`Attachments are not supported`);return await t.send(e)})):[],r=this.text,i=this._quote;this._quote=void 0,this._emptyTextAndAttachments();let a={createdAt:new Date,role:this.role,content:r?[{type:`text`,text:r}]:[],attachments:await n,runConfig:this.runConfig,metadata:{custom:{...i?{quote:i}:{}}}};this.handleSend(a,e),this._notifyEventSubscribers(`send`,{})}cancel(){this.handleCancel()}async addAttachment(e){if(!(e instanceof File)){let t=this.getAttachmentAdapter();if(t&&!Ix({name:e.name,type:e.contentType??``},t.accept)){let n=`File type ${e.contentType||`unknown`} is not accepted. Accepted types: ${t.accept}`,r=Error(n);throw this._safeEmitAttachmentAddError(`not-accepted`,n,void 0,r),r}let n={id:e.id??Sx(),type:e.type??`document`,name:e.name,contentType:e.contentType,content:e.content,status:{type:`complete`}};this._attachments=[...this._attachments,n],this._notifySubscribers(),this._notifyEventSubscribers(`attachmentAdd`,{});return}let t=e=>{let t=this._attachments.findIndex(t=>t.id===e.id);t===-1?this._attachments=[...this._attachments,e]:this._attachments=[...this._attachments.slice(0,t),e,...this._attachments.slice(t+1)],this._notifySubscribers()},n=this.getAttachmentAdapter();if(!n){let e=`Attachments are not supported`,t=Error(e);throw this._safeEmitAttachmentAddError(`no-adapter`,e,void 0,t),t}if(!Ix({name:e.name,type:e.type},n.accept)){let t=`File type ${e.type||`unknown`} is not accepted. Accepted types: ${n.accept}`,r=Error(t);throw this._safeEmitAttachmentAddError(`not-accepted`,t,void 0,r),r}let r;try{let i=n.add({file:e});if(Symbol.asyncIterator in i)for await(let e of i)r=e,t(e);else r=await i,t(r)}catch(e){throw r&&t({...r,status:{type:`incomplete`,reason:`error`}}),this._safeEmitAttachmentAddError(`adapter-error`,e instanceof Error?e.message:String(e),r?.id,e instanceof Error?e:void 0),e}r?.status.type===`incomplete`&&r.status.reason===`error`?this._safeEmitAttachmentAddError(`adapter-error`,`Attachment upload did not complete successfully.`,r?.id):this._notifyEventSubscribers(`attachmentAdd`,{})}_safeEmitAttachmentAddError(e,t,n,r){try{this._notifyEventSubscribers(`attachmentAddError`,{reason:e,message:t,...n!==void 0&&{attachmentId:n},...r!==void 0&&{error:r}})}catch(e){console.error(`[assistant-ui] attachmentAddError subscriber threw:`,e)}}async removeAttachment(e){let t=this._attachments.findIndex(t=>t.id===e);if(t===-1)throw Error(`Attachment not found`);let n=this._attachments[t];if(!Bx(n)){let e=this.getAttachmentAdapter();if(!e)throw Error(`Attachments are not supported`);await e.remove(n)}this._attachments=this._attachments.filter(t=>t.id!==e),this._notifySubscribers()}_dictation;_dictationSession;_dictationUnsubscribes=[];_dictationBaseText=``;_currentInterimText=``;_dictationSessionIdCounter=0;_activeDictationSessionId;_isCleaningDictation=!1;get dictation(){return this._dictation}_isActiveSession(e,t){return this._activeDictationSessionId===e&&this._dictationSession===t}startDictation(){let e=this.getDictationAdapter();if(!e)throw Error(`Dictation adapter not configured`);if(this._dictationSession){for(let e of this._dictationUnsubscribes)e();this._dictationUnsubscribes=[],this._dictationSession.stop().catch(()=>{}),this._dictationSession=void 0}let t=e.disableInputDuringDictation??!1;this._dictationBaseText=this._text,this._currentInterimText=``;let n=e.listen();this._dictationSession=n;let r=++this._dictationSessionIdCounter;this._activeDictationSessionId=r,this._dictation={status:n.status,inputDisabled:t},this._notifySubscribers();let i=n.onSpeech(e=>{if(!this._isActiveSession(r,n))return;let t=e.isFinal!==!1,i=this._dictationBaseText&&!this._dictationBaseText.endsWith(` `)&&e.transcript?` `:``;if(t){if(this._dictationBaseText=this._dictationBaseText+i+e.transcript,this._currentInterimText=``,this._text=this._dictationBaseText,this._dictation){let{transcript:e,...t}=this._dictation;this._dictation=t}this._notifySubscribers()}else this._currentInterimText=i+e.transcript,this._text=this._dictationBaseText+this._currentInterimText,this._dictation&&={...this._dictation,transcript:e.transcript},this._notifySubscribers()});this._dictationUnsubscribes.push(i);let a=n.onSpeechStart(()=>{this._isActiveSession(r,n)&&(this._dictation={status:{type:`running`},inputDisabled:t,...this._dictation?.transcript&&{transcript:this._dictation.transcript}},this._notifySubscribers())});this._dictationUnsubscribes.push(a);let o=n.onSpeechEnd(()=>{this._cleanupDictation({sessionId:r})});this._dictationUnsubscribes.push(o);let s=setInterval(()=>{this._isActiveSession(r,n)&&n.status.type===`ended`&&this._cleanupDictation({sessionId:r})},100);this._dictationUnsubscribes.push(()=>clearInterval(s))}stopDictation(){if(!this._dictationSession)return;let e=this._dictationSession,t=this._activeDictationSessionId;e.stop().finally(()=>{this._cleanupDictation({sessionId:t})})}_cleanupDictation(e){if(!(e?.sessionId!==void 0&&e.sessionId!==this._activeDictationSessionId||this._isCleaningDictation)){this._isCleaningDictation=!0;try{for(let e of this._dictationUnsubscribes)e();this._dictationUnsubscribes=[],this._dictationSession=void 0,this._activeDictationSessionId=void 0,this._dictation=void 0,this._dictationBaseText=``,this._currentInterimText=``,this._notifySubscribers()}finally{this._isCleaningDictation=!1}}}_eventSubscribers=new Map;_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);if(n)for(let e of n)e(t)}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),()=>{this._eventSubscribers.get(e)?.delete(n)}}},Hx=class extends Vx{runtime;_canCancel=!1;get canCancel(){return this._canCancel}get canSend(){return!this.isEmpty&&!this.runtime.isSendDisabled}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}constructor(e){super(),this.runtime=e,this.connect()}connect(){let e=this.runtime.isSendDisabled;return this.runtime.subscribe(()=>{let t=!1;this.canCancel!==this.runtime.capabilities.cancel&&(this._canCancel=this.runtime.capabilities.cancel,t=!0),e!==this.runtime.isSendDisabled&&(e=this.runtime.isSendDisabled,t=!0),t&&this._notifySubscribers()})}async handleSend(e,t){this.runtime.append({...e,parentId:this.runtime.messages.at(-1)?.id??null,sourceId:null,startRun:t?.startRun})}async handleCancel(){this.runtime.cancelRun()}},Ux=class extends Vx{runtime;endEditCallback;get canCancel(){return!0}get canSend(){return!this.isEmpty}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}_previousText;_previousAttachments;_nonTextPassthrough;_parentId;_sourceId;constructor(e,t,{parentId:n,message:r}){super(),this.runtime=e,this.endEditCallback=t,this._parentId=n,this._sourceId=r.id,this._previousText=Yb(r),this.setText(this._previousText),this.setRole(r.role),r.role===`user`?(this._previousAttachments=[...r.attachments??[],...zx(r.content)],this._nonTextPassthrough=[]):(this._previousAttachments=r.attachments??[],this._nonTextPassthrough=r.content.filter(e=>e.type!==`text`)),this.setAttachments(this._previousAttachments),this.setRunConfig({...e.composer.runConfig})}get parentId(){return this._parentId}get sourceId(){return this._sourceId}async handleSend(e,t){let n=Yb(e),r=!Lx(e.attachments??[],this._previousAttachments);if(n!==this._previousText||r||t?.startRun){let n=this._nonTextPassthrough.length>0?[...e.content,...this._nonTextPassthrough]:e.content;this.runtime.append({...e,content:n,parentId:this._parentId,sourceId:this._sourceId,startRun:t?.startRun})}this.handleCancel()}handleCancel(){this.endEditCallback(),this._notifySubscribers()}},Wx=class{_contextProvider;_subscriptions=new Set;_isInitialized=!1;repository=new Fx;_voiceMessages=[];_voiceGeneration=0;_cachedMergedMessages=null;_cachedVoiceGeneration=-1;_cachedMergedBase=null;_markVoiceMessagesDirty(){this._voiceGeneration++,this._cachedMergedMessages=null}_getBaseMessages(){return this.repository.getMessages()}get messages(){if(this._voiceMessages.length===0)return this._getBaseMessages();let e=this._getBaseMessages();return(this._cachedVoiceGeneration!==this._voiceGeneration||this._cachedMergedBase!==e)&&(this._cachedMergedMessages=[...e,...this._voiceMessages],this._cachedVoiceGeneration=this._voiceGeneration,this._cachedMergedBase=e),this._cachedMergedMessages}get state(){let e;for(let t of this.messages)t.role===`assistant`&&(e=t);return e?.metadata.unstable_state??null}composer=new Hx(this);constructor(e){this._contextProvider=e}getModelContext(){return this._contextProvider.getModelContext()}_editComposers=new Map;getEditComposer(e){return this._editComposers.get(e)}beginEdit(e){if(this._editComposers.has(e))throw Error(`Edit already in progress`);this._editComposers.set(e,new Ux(this,()=>this._editComposers.delete(e),this.repository.getMessage(e))),this._notifySubscribers()}getMessageById(e){try{return this.repository.getMessage(e)}catch{let t=this.repository.getMessages(),n=this._voiceMessages.findIndex(t=>t.id===e);return n===-1?void 0:{parentId:n>0?this._voiceMessages[n-1].id:t.at(-1)?.id??null,message:this._voiceMessages[n],index:t.length+n}}}getBranches(e){return this._voiceMessages.some(t=>t.id===e)?[]:this.repository.getBranches(e)}switchToBranch(e){this.repository.switchToBranch(e),this._notifySubscribers()}_notifySubscribers(){for(let e of this._subscriptions)e()}_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);if(n)for(let e of n)e(t)}subscribe(e){return this._subscriptions.add(e),()=>this._subscriptions.delete(e)}submitFeedback({messageId:e,type:t}){let n=this.adapters?.feedback;if(!n)throw Error(`Feedback adapter not configured`);let{message:r,parentId:i}=this.repository.getMessage(e);if(n.submit({message:r,type:t}),r.role===`assistant`){let e={...r,metadata:{...r.metadata,submittedFeedback:{type:t}}};this.repository.addOrUpdateMessage(i,e)}this._notifySubscribers()}_stopSpeaking;speech;speak(e){let t=this.adapters?.speech;if(!t)throw Error(`Speech adapter not configured`);let{message:n}=this.repository.getMessage(e);this._stopSpeaking?.();let r=t.speak(Yb(n)),i=r.subscribe(()=>{r.status.type===`ended`?(this._stopSpeaking=void 0,this.speech=void 0):this.speech={messageId:e,status:r.status},this._notifySubscribers()});this.speech={messageId:e,status:r.status},this._notifySubscribers(),this._stopSpeaking=()=>{r.cancel(),i(),this.speech=void 0,this._stopSpeaking=void 0}}stopSpeaking(){if(!this._stopSpeaking)throw Error(`No message is being spoken`);this._stopSpeaking(),this._notifySubscribers()}_voiceSession;_voiceUnsubs=[];voice;_voiceVolume=0;_voiceVolumeSubscribers=new Set;getVoiceVolume=()=>this._voiceVolume;subscribeVoiceVolume=e=>(this._voiceVolumeSubscribers.add(e),()=>this._voiceVolumeSubscribers.delete(e));connectVoice(){let e=this.adapters?.voice;if(!e)throw Error(`Voice adapter not configured`);this.disconnectVoice();let t=e.connect({});this._voiceSession=t;let n=[],r=`listening`;this.voice={status:t.status,isMuted:t.isMuted,mode:r},this._voiceVolume=0,this._notifySubscribers(),n.push(t.onStatusChange(e=>{e.type===`ended`?(this._finishVoiceAssistantMessage(),this._voiceSession=void 0,this.voice=void 0):this.voice={status:e,isMuted:t.isMuted,mode:r},this._notifySubscribers()})),n.push(t.onModeChange(e=>{r=e,this.voice&&(this.voice={...this.voice,mode:e},this._notifySubscribers())})),n.push(t.onVolumeChange(e=>{this._voiceVolume=e;for(let e of this._voiceVolumeSubscribers)e()})),n.push(t.onTranscript(e=>{this._handleVoiceTranscript(e)})),this._voiceUnsubs=n}_currentAssistantMsg=null;_handleVoiceTranscript(e){if(this.ensureInitialized(),e.role===`user`)this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null,e.isFinal&&(this._voiceMessages.push({id:Sx(),role:`user`,content:[{type:`text`,text:e.text}],metadata:{custom:{}},createdAt:new Date,status:{type:`complete`,reason:`unknown`},attachments:[]}),this._markVoiceMessagesDirty(),this._notifySubscribers());else{if(!this._currentAssistantMsg)this._currentAssistantMsg={id:Sx(),role:`assistant`,content:[{type:`text`,text:e.text}],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],custom:{}},status:{type:`running`},createdAt:new Date},this._voiceMessages.push(this._currentAssistantMsg);else{let t=this._voiceMessages.indexOf(this._currentAssistantMsg);if(t===-1)return;let n={...this._currentAssistantMsg,content:[{type:`text`,text:e.text}],...e.isFinal?{status:{type:`complete`,reason:`stop`}}:{}};this._voiceMessages[t]=n,this._currentAssistantMsg=n}e.isFinal&&(this._currentAssistantMsg=null),this._markVoiceMessagesDirty(),this._notifySubscribers()}}_finishVoiceAssistantMessage(){let e=this._voiceMessages.at(-1);if(e?.role===`assistant`&&e.status.type===`running`){let t=this._voiceMessages.length-1;this._voiceMessages[t]={...e,status:{type:`complete`,reason:`stop`}},this._markVoiceMessagesDirty(),this._notifySubscribers()}}disconnectVoice(){this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null;for(let e of this._voiceUnsubs)e();this._voiceUnsubs=[],this._voiceSession?.disconnect(),this._voiceSession=void 0,this.voice=void 0,this._voiceVolume=0;for(let e of this._voiceVolumeSubscribers)e();this._voiceMessages=[],this._markVoiceMessagesDirty(),this._notifySubscribers()}muteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.mute(),this.voice={...this.voice,isMuted:!0},this._notifySubscribers()}unmuteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.unmute(),this.voice={...this.voice,isMuted:!1},this._notifySubscribers()}ensureInitialized(){this._isInitialized||(this._isInitialized=!0,this._notifyEventSubscribers(`initialize`,{}))}export(){return this.repository.export()}import(e){this.ensureInitialized(),this.repository.clear(),this.repository.import(e),this._notifySubscribers()}reset(e){this.import(Mx.fromArray(e??[]))}_eventSubscribers=new Map;unstable_on(e,t){let n=t;if(e===`modelContextUpdate`)return this._contextProvider.subscribe?.(()=>n({}))??(()=>{});let r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),e===`initialize`&&this._isInitialized&&queueMicrotask(()=>{r.has(n)&&n({})}),()=>{this._eventSubscribers.get(e)?.delete(n)}}},Gx=class{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})}};function Kx(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function qx(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=>qx(e,t+1)):Kx(e)?Object.entries(e).every(([e,n])=>typeof e==`string`&&qx(n,t+1)):!1}var Jx=100,Yx=(e,t,n)=>{if(e===t)return!0;if(n>Jx||e==null||t==null)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.every((e,r)=>Yx(e,t[r],n+1));if(Array.isArray(t)||!Kx(e)||!Kx(t))return!1;let r=Object.keys(e),i=Object.keys(t);return r.length===i.length?r.every(r=>Object.hasOwn(t,r)&&Yx(e[r],t[r],n+1)):!1},Xx=(e,t)=>!qx(e)||!qx(t)?!1:Yx(e,t,0),Zx=e=>{try{return JSON.parse(e),!0}catch{return!1}},Qx=e=>{try{return JSON.parse(e)}catch{return}},$x=(e,t)=>{let n=Qx(e),r=Qx(t);return n===void 0||r===void 0?!1:Xx(n,r)},eS=class{_getTools;_callbacks;_entries=new Map;_skipExecuteStreamIds=new Set;_humanInput=new Map;_executing=new Set;_settledResolvers=[];_statuses=new Map;_ac=new AbortController;_pendingRestore=!0;_lastSnapshot=null;_isRunning=!1;_controller;_pipelineDead=!1;_pipelineRestartUsed=!1;constructor(e,t){this._getTools=e,this._callbacks=t,this._initPipeline()}_initPipeline(){let[e,t]=Vy();this._controller=t;let n=fb(()=>this._getWrappedTools(),()=>this._ac.signal,(e,t)=>this._onHumanInput(e,t),{onExecutionStart:e=>this._onExecutionStart(e),onExecutionEnd:e=>this._onExecutionEnd(e)});e.pipeThrough(n).pipeThrough(new Iy).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,this._demoteEntriesToRestored(),this._executing.clear(),this._ac=new AbortController,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)}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._lastSnapshot=null,this.abort().finally(()=>{this._executing.clear()})}catch(e){console.error(`[ToolInvocationTracker] reset failed`,e)}}abort(){try{return this._humanInput.forEach(({reject:e})=>{try{e(Error(`Tool execution aborted`))}catch{}}),this._humanInput.clear(),this._ac.abort(),this._ac=new AbortController,this._executing.size===0?Promise.resolve():new Promise(e=>{this._settledResolvers.push(e)})}catch(e){return console.error(`[ToolInvocationTracker] abort failed`,e),Promise.resolve()}}resume(e,t){try{let n=this._humanInput.get(e);return n?(this._humanInput.delete(e),this._setStatus(e,{type:`executing`}),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;return n===void 0?[e,t]:[e,{...t,execute:(...[e,t])=>this._skipExecuteStreamIds.has(t.toolCallId)?new Promise(()=>{}):n(e,t)}]}))}_onHumanInput(e,t){return new Promise((n,r)=>{let i=this._humanInput.get(e);if(i)try{i.reject(Error(`Human input request was superseded by a new request`))}catch{}this._humanInput.set(e,{resolve:n,reject:r}),this._setStatus(e,{type:`interrupt`,payload:{type:`human`,payload:t}})})}_onExecutionStart(e){this._skipExecuteStreamIds.has(e)||(this._executing.add(e),this._setStatus(e,{type:`executing`}))}_onExecutionEnd(e){this._executing.delete(e)&&(this._deleteStatus(e),this._executing.size===0&&this._settledResolvers.splice(0).forEach(e=>{try{e()}catch{}}))}_handleResultChunk(e){let t=e.meta.toolCallId,n=this._entries.get(t);!n&&this._skipExecuteStreamIds.has(t)||n?.hasResult||this._invokeOnResult({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()}_hasExecutableTool(e){let t=this._getTools()?.[e];return t?.execute!==void 0||t?.streamCall!==void 0}_shouldCloseArgsStream({toolName:e,argsText:t,hasResult:n}){return n?!0:(this._hasExecutableTool(e)||!this._isRunning)&&Zx(t)}_startActiveEntry(e,t,n){let r=this._controller.addToolCallPart({toolName:t,toolCallId:e});n&&this._skipExecuteStreamIds.add(e);let i={toolName:t,controller:r,argsText:``,hasResult:!1,argsComplete:!1};return this._entries.set(e,i),i}_demoteEntriesToRestored(){for(let[e,t]of this._entries)t.controller&&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)$x(e.argsText,t.argsText)&&(e.argsText=t.argsText),r=!1;else if(!t.argsText.startsWith(e.argsText))if(Zx(e.argsText)&&Zx(t.argsText)&&$x(e.argsText,t.argsText)){let i=this._shouldCloseArgsStream({toolName:t.toolName,argsText:t.argsText,hasResult:n});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i,r=!1}else r=!1;if(r&&e.controller){let r=t.argsText.slice(e.argsText.length);e.controller.argsText.append(r);let i=this._shouldCloseArgsStream({toolName:t.toolName,argsText:t.argsText,hasResult:n});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i}}!e.argsComplete&&e.controller&&this._shouldCloseArgsStream({toolName:t.toolName,argsText:t.argsText,hasResult:n})&&(e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=!0)}_processMessages(e){let t=this._pendingRestore;for(let n of e)if(!(!n||!Array.isArray(n.content)))for(let e of n.content){if(!e||e.type!==`tool-call`)continue;let n=this._entries.get(e.toolCallId);if(t){n?.controller||this._entries.set(e.toolCallId,{toolName:e.toolName,argsText:e.argsText,hasResult:e.result!==void 0}),e.messages&&this._processMessages(e.messages);continue}let r=n;if(r&&!r.controller){if(!(e.argsText!==r.argsText||e.result!==void 0!==r.hasResult)){e.messages&&this._processMessages(e.messages);continue}this._entries.delete(e.toolCallId),r=void 0}if(r||=this._startActiveEntry(e.toolCallId,e.toolName,e.result!==void 0),this._processArgsText(r,e),e.result!==void 0&&!r.hasResult){let{controller:t}=r;if(!t)continue;r.hasResult=!0,r.argsComplete=!0,t.setResponse(new Qy({result:e.result,artifact:e.artifact,isError:e.isError,...e.modelContent===void 0?{}:{modelContent:e.modelContent}})),t.close()}e.messages&&this._processMessages(e.messages)}}},tS=Object.freeze([]),nS=(e,t)=>{let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0},rS=(e,t)=>e&&t[t.length-1]?.role!==`assistant`,iS=class extends Wx{_capabilities={switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,reload:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1};get capabilities(){return this._capabilities}_messages;isDisabled;isSendDisabled;get isLoading(){return this._store.isLoading??!1}get isRunning(){return this._store.isRunning}_getBaseMessages(){return this._messages}get state(){return this._store.state??super.state}get adapters(){return this._store.adapters}suggestions=[];extras=void 0;_converter=new Gx;_store;_toolInvocations=null;beginEdit(e){if(!this._store.onEdit)throw Error(`Runtime does not support editing.`);super.beginEdit(e)}constructor(e,t){super(e),this.__internal_setAdapter(t)}__internal_setAdapter(e){if(this._store===e)return;let t=e.isRunning??!1;this.isDisabled=e.isDisabled??!1,this.isSendDisabled=e.isSendDisabled??!1;let n=this._store;this._store=e,this.extras!==e.extras&&(this.extras=e.extras);let r=e.suggestions??tS;nS(this.suggestions,r)||(this.suggestions=r);let i={switchToBranch:this._store.setMessages!==void 0,switchBranchDuringRun:!1,edit:this._store.onEdit!==void 0,reload:this._store.onReload!==void 0,cancel:this._store.onCancel!==void 0,speech:this._store.adapters?.speech!==void 0,dictation:this._store.adapters?.dictation!==void 0,voice:this._store.adapters?.voice!==void 0,unstable_copy:this._store.unstable_capabilities?.copy!==!1,attachments:!!this._store.adapters?.attachments,feedback:!!this._store.adapters?.feedback,queue:!1};nS(this._capabilities,i)||(this._capabilities=i);let a;if(e.messageRepository){if(n&&n.isRunning===e.isRunning&&n.messageRepository===e.messageRepository){this._notifySubscribers();return}this.repository.clear(),this.repository.import(e.messageRepository),a=this.repository.getMessages()}else if(e.messages){if(n){if(n.convertMessage!==e.convertMessage)this._converter=new Gx;else if(n.isRunning===e.isRunning&&n.messages===e.messages){this._notifySubscribers();return}}a=e.convertMessage?this._converter.convertMessages(e.messages,(n,r,i)=>{if(!e.convertMessage)return r;let a=kx(i===(e.messages?.length??0)-1,t,!1,!1,void 0);if(n&&(n.role!==`assistant`||!Ox(n.status)||n.status===a))return n;let o=jx(e.convertMessage(r,i),i.toString(),a);return Db(o,r),o}):e.messages;for(let e=0;e<a.length;e++){let t=a[e],n=a[e-1];this.repository.addOrUpdateMessage(n?.id??null,t)}}else throw Error(`ExternalStoreAdapter must provide either 'messages' or 'messageRepository'`);a.length>0&&this.ensureInitialized(),(n?.isRunning??!1)!==(e.isRunning??!1)&&(e.isRunning?this._notifyEventSubscribers(`runStart`,{}):this._notifyEventSubscribers(`runEnd`,{}));let o=null;rS(t,a)&&(o=Sx(),this.repository.addOrUpdateMessage(a.at(-1)?.id??null,jx({role:`assistant`,content:[],metadata:{isOptimistic:!0}},o,{type:`running`}))),this.repository.resetHead(o??a.at(-1)?.id??null),this._messages=this.repository.getMessages(),this._driveToolInvocations(),this._notifySubscribers()}_driveToolInvocations(){if(!this._store.unstable_enableToolInvocations){this._toolInvocations&&(this._toolInvocations.reset(),this._toolInvocations=null,this._store.setToolStatuses?.({}));return}this._toolInvocations||=new eS(()=>this.getModelContext().tools,{onResult:e=>{try{let t=this._findMessageIdForToolCall(e.toolCallId);if(t===void 0)return;this._store.onAddToolResult?.({messageId:t,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)}},onStatusesChange:e=>{this._store.setToolStatuses?.(Object.fromEntries(e))}}),this._toolInvocations.setState({messages:this._messages,isRunning:this._store.isRunning??!1,...this._store.isLoading!==void 0&&{isLoading:this._store.isLoading}})}_toolCallToMessageId=new Map;_messagesForToolCallIndex=null;_findMessageIdForToolCall(e){if(this._messagesForToolCallIndex!==this._messages){this._toolCallToMessageId.clear();let e=t=>{for(let n of t)if(Array.isArray(n.content))for(let t of n.content)!t||t.type!==`tool-call`||(this._toolCallToMessageId.set(t.toolCallId,n.id),t.messages&&e(t.messages))};e(this._messages),this._messagesForToolCallIndex=this._messages}return this._toolCallToMessageId.get(e)}switchToBranch(e){if(!this._store.setMessages)throw Error(`Runtime does not support switching branches.`);this._store.isRunning||(this.repository.switchToBranch(e),this.updateMessages(this.repository.getMessages()))}async append(e){if((e.startRun??e.role===`user`)&&await this._toolInvocations?.abort(),e.parentId!==(this.messages.at(-1)?.id??null)){if(!this._store.onEdit)throw Error(`Runtime does not support editing messages.`);await this._store.onEdit(e)}else await this._store.onNew(e)}async startRun(e){if(!this._store.onReload)throw Error(`Runtime does not support reloading messages.`);await this._toolInvocations?.abort(),await this._store.onReload(e.parentId,e)}async resumeRun(e){if(!this._store.onResume)throw Error(`Runtime does not support resuming runs.`);await this._store.onResume(e)}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._toolInvocations&&(this._toolInvocations.reset(),this._store.setToolStatuses?.({})),this._store.onLoadExternalState(e)}cancelRun(){if(!this._store.onCancel)throw Error(`Runtime does not support cancelling runs.`);this._toolInvocations?.abort(),this._store.onCancel();let e=this.repository.getMessages().at(-1);e&&e.metadata.isOptimistic&&e.content.length===0&&this.repository.deleteMessage(e.id);let t=this.repository.getMessages(),n=t[t.length-1];n?.role===`user`&&n.id===t.at(-1)?.id?(this.repository.deleteMessage(n.id),this.composer.text.trim()||this.composer.setText(Yb(n)),t=this.repository.getMessages()):this._notifySubscribers(),setTimeout(()=>{this.updateMessages(t)},0)}addToolResult(e){if(!this._store.onAddToolResult)throw Error(`Runtime does not support tool results.`);this._store.onAddToolResult?.(e)}resumeToolCall(e){if(!(this._toolInvocations?.resume(e.toolCallId,e.payload)??!1)){if(this._store.onResumeToolCall){this._store.onResumeToolCall(e);return}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.`);this._store.onRespondToToolApproval(e)}reset(e){let t=new Fx;t.import(Mx.fromArray(e??[])),this.updateMessages(t.getMessages())}import(e){super.import(e),this._store.onImport&&this._store.onImport(this.repository.getMessages())}updateMessages=e=>{this._store.convertMessage===void 0?this._store.setMessages?.(e):this._store.setMessages?.(e.flatMap(Ob))}},aS=e=>e.adapters?.threadList??{},oS=class extends mx{threads;constructor(e){super(),this.threads=new xx(aS(e),()=>new iS(this._contextProvider,e))}setAdapter(e){this.threads.__internal_setAdapter(aS(e)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(e)}},sS=e=>{let[t]=(0,_.useState)(()=>new oS(e));(0,_.useEffect)(()=>{t.setAdapter(e)});let{modelContext:n}=sx()??{};return(0,_.useEffect)(()=>{if(n)return t.registerModelContextProvider(n)},[n,t]),(0,_.useMemo)(()=>new px(t),[t])},cS=(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,lS=()=>null,uS=(e,t,n)=>{switch(t){case`user`:return n?e.UserEditComposer??e.EditComposer??e.UserMessage??e.Message:e.UserMessage??e.Message;case`assistant`:return n?e.AssistantEditComposer??e.EditComposer??e.AssistantMessage??e.Message:e.AssistantMessage??e.Message;case`system`:return n?e.SystemEditComposer??e.EditComposer??e.SystemMessage??e.Message:e.SystemMessage??e.Message??lS;default:throw Error(`Unknown message role: ${t}`)}},dS=({components:e})=>(0,G.jsx)(uS(e,Z(e=>e.message.role),Z(e=>e.message.composer.isEditing)),{}),fS=(0,_.memo)(({index:e,components:t})=>(0,G.jsx)(hb,{index:e,children:(0,G.jsx)(dS,{components:t})}),(e,t)=>e.index===t.index&&cS(e.components,t.components));fS.displayName=`ThreadPrimitive.MessageByIndex`;var pS=({children:e})=>{let t=Z(e=>e.thread.messages.length);return(0,_.useMemo)(()=>t===0?null:Array.from({length:t},(t,n)=>(0,G.jsx)(hb,{index:n,children:(0,G.jsx)(Hv,{getItemState:e=>e.thread().message({index:n}).getState(),children:t=>e({get message(){return t()}})})},n)),[t,e])},mS=({components:e,children:t})=>e?(0,G.jsx)(pS,{children:()=>(0,G.jsx)(dS,{components:e})}):(0,G.jsx)(pS,{children:t});mS.displayName=`ThreadPrimitive.Messages`;var hS=(0,_.memo)(mS,(e,t)=>e.children||t.children?e.children===t.children:cS(e.components,t.components)),gS=e=>{let t=e.message.metadata;if(!(!t||typeof t!=`object`))return t.custom?.quote},_S=class extends Error{componentName;constructor(e,t=`Component "${e}" is not in the generative-ui allowlist.`){super(t),this.name=`GenerativeUIRenderError`,this.componentName=e}},vS=e=>typeof e==`object`&&!!e,yS=(e,t,n,r)=>{if(e==null)return null;if(typeof e==`string`)return e;if(!vS(e)||!(`component`in e))return null;let{component:i,props:a,children:o,key:s}=e,c=t[i];if(!c){if(n)return(0,G.jsx)(n,{component:i,props:a},s??r);throw new _S(i)}let l=o?.length?o.map((e,i)=>yS(e,t,n,`${r}/${i}`)):void 0;return(0,_.createElement)(c,{...a??{},key:s??r},...l??[])},bS=e=>{if(!e||e.root===void 0||e.root===null)return[];let t=e.root;return Array.isArray(t)?t:[t]},xS=({spec:e,components:t,Fallback:n})=>(0,G.jsx)(G.Fragment,{children:(0,_.useMemo)(()=>bS(e),[e]).map((e,r)=>yS(e,t,n,`${r}`))});xS.displayName=`GenerativeUIRender`;var SS=({components:e,spec:t,Fallback:n})=>{let r=Z(e=>{let t=e.part;return t?.type===`generative-ui`?t.spec:void 0}),i=t??r;return i?(0,G.jsx)(xS,{spec:i,components:e,Fallback:n}):null};SS.displayName=`MessagePrimitive.GenerativeUI`;var CS=`ui://`,wS=e=>!!e?.startsWith(CS),TS=e=>Symbol.iterator in e,ES=e=>`entries`in e,DS=(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},OS=(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 kS(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:TS(e)&&TS(t)?ES(e)&&ES(t)?DS(e,t):OS(e,t):DS({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function AS(e){let t=_.useRef(void 0);return n=>{let r=e(n);return kS(t.current,r)?t.current:t.current=r}}var jS=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})}}},MS=(e,t)=>{let n=[];if(t){let t=jS(`chainOfThoughtGroup`);for(let r=0;r<e.length;r++){let i=e[r];i===`tool-call`||i===`reasoning`?t.startGroup(r):(t.endGroup(r-1,n),n.push({type:`single`,index:r}))}t.finalize(e.length-1,n)}else{let t=jS(`toolGroup`),r=jS(`reasoningGroup`);for(let i=0;i<e.length;i++){let a=e[i];a===`tool-call`?(r.endGroup(i-1,n),t.startGroup(i)):a===`reasoning`?(t.endGroup(i-1,n),r.startGroup(i)):(t.endGroup(i-1,n),r.endGroup(i-1,n),n.push({type:`single`,index:i}))}t.finalize(e.length-1,n),r.finalize(e.length-1,n)}return n},NS=e=>{let t=Z(AS(e=>e.message.parts.map(e=>e.type)));return(0,_.useMemo)(()=>t.length===0?[]:MS(t,e),[t,e])},PS=({Fallback:e,...t})=>{let n=Z(n=>n.tools.toolUIs[t.toolName]?.[0]?.render??e);return n?(0,G.jsx)(n,{...t}):null},FS=(e,t,n)=>e.renderers[t]?.[0]||(e.fallbacks[0]??n),IS=({Fallback:e,...t})=>{let n=Z(n=>FS(n.dataRenderers,t.name,e));return n?(0,G.jsx)(n,{...t}):null},LS={Text:()=>null,Reasoning:()=>null,Source:()=>null,Image:()=>null,File:()=>null,Unstable_Audio:()=>null,ToolGroup:({children:e})=>e,ReasoningGroup:({children:e})=>e},RS=({components:{Text:e=LS.Text,Reasoning:t=LS.Reasoning,Image:n=LS.Image,Source:r=LS.Source,File:i=LS.File,Unstable_Audio:a=LS.Unstable_Audio,tools:o={},data:s,generativeUI:c}={}})=>{let l=Rv(),u=Z(e=>e.part),d=u.type;if(d===`tool-call`){let e=l.part().addToolResult,t=l.part().resumeToolCall,n=l.part().respondToToolApproval;if(`Override`in o)return(0,G.jsx)(o.Override,{...u,addResult:e,resume:t,respondToApproval:n});let r=o.by_name?.[u.toolName]??o.Fallback;return(0,G.jsx)(PS,{...u,Fallback:r,addResult:e,resume:t,respondToApproval:n})}if(u.status?.type===`requires-action`)throw Error(`Encountered unexpected requires-action status`);switch(d){case`text`:return(0,G.jsx)(e,{...u});case`reasoning`:return(0,G.jsx)(t,{...u});case`source`:return(0,G.jsx)(r,{...u});case`image`:return(0,G.jsx)(n,{...u});case`file`:return(0,G.jsx)(i,{...u});case`audio`:return(0,G.jsx)(a,{...u});case`data`:{let e=s?.by_name?.[u.name]??s?.Fallback;return(0,G.jsx)(IS,{...u,Fallback:e})}case`generative-ui`:return c?.components?(0,G.jsx)(xS,{spec:u.spec,components:c.components,Fallback:c.Fallback}):null;default:return console.warn(`Unknown message part type: ${d}`),null}},zS=(0,_.memo)(({index:e,components:t})=>(0,G.jsx)(gb,{index:e,children:(0,G.jsx)(RS,{components:t})}),(e,t)=>e.index===t.index&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.generativeUI===t.components?.generativeUI&&e.components?.ToolGroup===t.components?.ToolGroup&&e.components?.ReasoningGroup===t.components?.ReasoningGroup);zS.displayName=`MessagePrimitive.PartByIndex`;var BS=({status:e,component:t})=>(0,G.jsx)(vb,{text:``,isRunning:e.type===`running`,children:(0,G.jsx)(t,{type:`text`,text:``,status:e})}),VS=Object.freeze({type:`complete`}),HS=Object.freeze({type:`running`}),US=(0,_.memo)(({components:e})=>{let t=Z(e=>e.message.status??VS);return e?.Empty?(0,G.jsx)(e.Empty,{status:t}):t.type===`running`?(0,G.jsx)(BS,{status:t,component:e?.Text??LS.Text}):null},(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),WS=(0,_.memo)(({components:e,enabled:t})=>Z(e=>{if(!t||e.message.parts.length===0)return!1;let n=e.message.parts[e.message.parts.length-1];return n?.type!==`text`&&n?.type!==`reasoning`})?(0,G.jsx)(US,{components:e}):null,(e,t)=>e.enabled===t.enabled&&e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),GS=(0,_.memo)(({Quote:e})=>{let t=Z(gS);return t?(0,G.jsx)(e,{text:t.text,messageId:t.messageId}):null});function KS(e,t){return(e.toolUIs[t.toolName]?.[0]?.render??null)||(wS(t.mcp?.app?.resourceUri)&&e.mcpApp?e.mcpApp.render:null)}var qS=()=>{let e=Rv(),t=Z(e=>e.part),n=Z(e=>e.part.type===`tool-call`?KS(e.tools,e.part):null);return!n||t.type!==`tool-call`?null:(0,G.jsx)(n,{...t,addResult:e.part().addToolResult,resume:e.part().resumeToolCall,respondToApproval:e.part().respondToToolApproval})},JS=()=>{let e=Z(e=>e.part),t=Z(e=>e.part.type===`data`?FS(e.dataRenderers,e.part.name,void 0)??null:null);return!t||e.type!==`data`?null:(0,G.jsx)(t,{...e})},YS=()=>{let e=Z(e=>e.part.type);return e===`tool-call`?(0,G.jsx)(qS,{}):e===`data`?(0,G.jsx)(JS,{}):null},XS=Object.freeze({type:`text`,text:``,status:HS}),ZS=({index:e,children:t})=>{let n=Rv(),r=Z(e=>e.dataRenderers);return(0,G.jsx)(gb,{index:e,children:(0,G.jsx)(Hv,{getItemState:t=>t.message().part({index:e}).getState(),children:i=>t({get part(){let t=i();if(t.type===`tool-call`){let r=KS(n.tools().getState(),t)!==null,i=n.message().part({index:e});return{...t,toolUI:r?(0,G.jsx)(qS,{}):null,addResult:i.addToolResult,resume:i.resumeToolCall,respondToApproval:i.respondToToolApproval}}if(t.type===`data`){let e=FS(r,t.name,void 0)!==void 0;return{...t,dataRendererUI:e?(0,G.jsx)(JS,{}):null}}return t}})})})},QS=({children:e})=>{let t=Z(e=>e.message.parts.length),n=Z(e=>(e.message.status?.type??`complete`)===`running`);return t===0?t===0&&n?(0,G.jsx)(vb,{text:``,isRunning:!0,children:e({part:XS})}):null:(0,G.jsx)(G.Fragment,{children:Array.from({length:t},(t,n)=>(0,G.jsx)(ZS,{index:n,children:t=>e(t)??(0,G.jsx)(YS,{})},n))})},$S=({components:e,unstable_showEmptyOnNonTextEnd:t=!0,children:n})=>n?(0,G.jsx)(QS,{children:n}):(0,G.jsx)(eC,{components:e,unstable_showEmptyOnNonTextEnd:t});$S.displayName=`MessagePrimitive.Parts`;var eC=({components:e,unstable_showEmptyOnNonTextEnd:t})=>{let n=Z(e=>e.message.parts.length),r=NS(!!e?.ChainOfThought),i=(0,_.useMemo)(()=>n===0?(0,G.jsx)(US,{components:e}):r.map(t=>{if(t.type===`single`)return(0,G.jsx)(zS,{index:t.index,components:e},t.index);if(t.type===`chainOfThoughtGroup`){let n=e?.ChainOfThought;return n?(0,G.jsx)(xb,{startIndex:t.startIndex,endIndex:t.endIndex,children:(0,G.jsx)(n,{})},`chainOfThought-${t.startIndex}`):null}else if(t.type===`toolGroup`)return(0,G.jsx)(e?.ToolGroup??LS.ToolGroup,{startIndex:t.startIndex,endIndex:t.endIndex,children:Array.from({length:t.endIndex-t.startIndex+1},(n,r)=>{let i=t.startIndex+r;return(0,G.jsx)(zS,{index:i,components:e},`part-${i}`)})},`tool-${t.startIndex}`);else return(0,G.jsx)(e?.ReasoningGroup??LS.ReasoningGroup,{startIndex:t.startIndex,endIndex:t.endIndex,children:Array.from({length:t.endIndex-t.startIndex+1},(n,r)=>{let i=t.startIndex+r;return(0,G.jsx)(zS,{index:i,components:e},`part-${i}`)})},`reasoning-${t.startIndex}`)}),[r,e,n]);return(0,G.jsxs)(G.Fragment,{children:[e?.Quote&&(0,G.jsx)(GS,{Quote:e.Quote}),i,(0,G.jsx)(WS,{components:e,enabled:t})]})},tC=Symbol.for(`@assistant-ui/groupBy.memoKey`),nC=e=>{let t=e.nextChildIdx++;return e.nodeKey===``?String(t):`${e.nodeKey}.${t}`},rC=e=>{let t={key:``,nodeKey:``,indices:[],children:[],nextChildIdx:0},n=[t],r=()=>{let e=n.pop();n[n.length-1].children.push({type:`group`,key:e.key,nodeKey:e.nodeKey,indices:e.indices,children:e.children})};for(let t=0;t<e.length;t++){let i=e[t],a=0;for(;a<n.length-1&&a<i.length&&n[a+1].key===i[a];)a++;for(;n.length-1>a;)r();for(;n.length-1<i.length;){let e=n[n.length-1];n.push({key:i[n.length-1],nodeKey:nC(e),indices:[],children:[],nextChildIdx:0})}let o=n[n.length-1];o.children.push({type:`part`,index:t,nodeKey:nC(o)});for(let e=1;e<n.length;e++)n[e].indices.push(t)}for(;n.length>1;)r();return t.children},iC=Object.freeze({type:`complete`}),aC=(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`}}},oC=()=>{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 skip it.")},sC=(e,t,n)=>{if(e.type===`part`)return(0,G.jsx)(ZS,{index:e.index,children:({part:e})=>n({part:e,children:(0,G.jsx)(oC,{})})},`part-${e.index}`);let r=t[e.indices.at(-1)]?.status??iC;return(0,G.jsx)(_.Fragment,{children:n({part:{type:e.key,status:r,indices:e.indices},children:(0,G.jsx)(G.Fragment,{children:e.children.map(e=>sC(e,t,n))})})},e.nodeKey)},cC=({groupBy:e,indicator:t=`no-text`,children:n})=>{let r=Z(AS(e=>e.message.parts)),i=Z(e=>e.tools.toolUIs),a=Z(e=>t===`never`?!1:e.message.status?.type===`running`);return(0,G.jsxs)(G.Fragment,{children:[(0,_.useMemo)(()=>{let t={toolUIs:i};return rC(r.map(n=>e(n,t)??[]))},[r,e[tC]??e,i]).map(e=>sC(e,r,n)),aC(t,r,a)&&n({part:{type:`indicator`},children:(0,G.jsx)(oC,{})})]})};cC.displayName=`MessagePrimitive.GroupedParts`;var lC=(0,_.memo)(({children:e})=>{let t=Z(gS);return t?(0,G.jsx)(G.Fragment,{children:e(t)}):null});lC.displayName=`MessagePrimitive.Quote`;var uC=(e,t)=>{switch(t.type){case`image`:return e?.Image??e?.Attachment;case`document`:return e?.Document??e?.Attachment;case`file`:return e?.File??e?.Attachment;default:return e?.Attachment}},dC=({components:e})=>{let t=Z(e=>e.attachment);if(!t)return null;let n=uC(e,t);return n?(0,G.jsx)(n,{}):null},fC=(0,_.memo)(({index:e,components:t})=>(0,G.jsx)(pb,{index:e,children:(0,G.jsx)(dC,{components:t})}),(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);fC.displayName=`MessagePrimitive.AttachmentByIndex`;var pC=({children:e})=>{let t=Z(e=>e.message.role===`user`?(e.message.attachments??[]).length:0);return(0,_.useMemo)(()=>Array.from({length:t},(t,n)=>(0,G.jsx)(pb,{index:n,children:(0,G.jsx)(Hv,{getItemState:e=>e.message().attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},n)),[t,e])},mC=({components:e,children:t})=>e?(0,G.jsx)(pC,{children:({attachment:t})=>{let n=uC(e,t);return n?(0,G.jsx)(n,{}):null}}):(0,G.jsx)(pC,{children:t});mC.displayName=`MessagePrimitive.Attachments`;var hC=(e,t)=>{switch(t.type){case`image`:return e?.Image??e?.Attachment;case`document`:return e?.Document??e?.Attachment;case`file`:return e?.File??e?.Attachment;default:return e?.Attachment}},gC=({components:e})=>{let t=Z(e=>e.attachment);if(!t)return null;let n=hC(e,t);return n?(0,G.jsx)(n,{}):null},_C=(0,_.memo)(({index:e,components:t})=>(0,G.jsx)(mb,{index:e,children:(0,G.jsx)(gC,{components:t})}),(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);_C.displayName=`ComposerPrimitive.AttachmentByIndex`;var vC=({children:e})=>{let t=Z(e=>e.composer.attachments.length);return(0,_.useMemo)(()=>Array.from({length:t},(t,n)=>(0,G.jsx)(mb,{index:n,children:(0,G.jsx)(Hv,{getItemState:e=>e.composer().attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},n)),[t,e])},yC=({components:e,children:t})=>e?(0,G.jsx)(vC,{children:({attachment:t})=>{let n=hC(e,t);return n?(0,G.jsx)(n,{}):null}}):(0,G.jsx)(vC,{children:t});yC.displayName=`ComposerPrimitive.Attachments`;var bC=(0,_.memo)(({children:e})=>{let t=Z(e=>e.composer.queue.length);return(0,_.useMemo)(()=>Array.from({length:t},(t,n)=>(0,G.jsx)(Cb,{index:n,children:(0,G.jsx)(Hv,{getItemState:e=>e.composer().queueItem({index:n}).getState(),children:t=>e({get queueItem(){return t()}})})},n)),[t,e])});bC.displayName=`ComposerPrimitive.Queue`;var xC=({children:e})=>Z(e=>e.part.status.type===`running`)?e:null;xC.displayName=`MessagePartPrimitive.InProgress`;var SC=({components:e})=>{let t=e.Suggestion;return(0,G.jsx)(t,{})},CC=(0,_.memo)(({index:e,components:t})=>(0,G.jsx)(Sb,{index:e,children:(0,G.jsx)(SC,{components:t})}),(e,t)=>e.index===t.index&&e.components.Suggestion===t.components.Suggestion);CC.displayName=`ThreadPrimitive.SuggestionByIndex`;var wC=({children:e})=>{let t=Z(e=>e.suggestions.suggestions.length);return(0,_.useMemo)(()=>t===0?null:Array.from({length:t},(t,n)=>(0,G.jsx)(Sb,{index:n,children:(0,G.jsx)(Hv,{getItemState:e=>e.suggestions().suggestion({index:n}).getState(),children:t=>e({get suggestion(){return t()}})})},n)),[t,e])},TC=({components:e,children:t})=>e?(0,G.jsx)(wC,{children:()=>(0,G.jsx)(SC,{components:e})}):(0,G.jsx)(wC,{children:t});TC.displayName=`ThreadPrimitive.Suggestions`;var EC=(0,_.memo)(TC,(e,t)=>e.children||t.children?e.children===t.children:e.components.Suggestion===t.components.Suggestion),DC=e=>Z(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)}),OC=({children:e,...t})=>DC(t)?e:null;OC.displayName=`ComposerPrimitive.If`;var kC=()=>{let e=Rv(),t=Z(e=>!e.composer.canSend||e.thread.isRunning&&!e.thread.capabilities.queue);return{send:(0,_.useCallback)(t=>{e.composer().send(t)},[e]),disabled:t}},AC=()=>{let e=Rv(),t=Z(e=>!e.composer.canCancel);return{cancel:(0,_.useCallback)(()=>{e.composer().cancel()},[e]),disabled:t}},jC=()=>{let e=Rv(),t=Z(e=>e.composer.dictation!=null||!e.thread.capabilities.dictation||!e.composer.isEditing);return{startDictation:(0,_.useCallback)(()=>{e.composer().startDictation()},[e]),disabled:t}},MC=()=>{let e=Rv(),t=Z(e=>!e.composer.isEditing);return{addAttachment:(0,_.useCallback)(t=>e.composer().addAttachment(t),[e]),disabled:t}},NC=({prompt:e,send:t,clearComposer:n=!0})=>{let r=Rv(),i=Z(e=>e.thread.isDisabled),a=t??!1;return{trigger:(0,_.useCallback)(()=>{let t=r.thread().getState().isRunning;if(a&&!t)r.thread().append({content:[{type:`text`,text:e}],runConfig:r.composer().getState().runConfig}),n&&r.composer().setText(``);else if(n)r.composer().setText(e);else{let t=r.composer().getState().text;r.composer().setText(t.trim()?`${t} ${e}`:e)}},[r,a,n,e]),disabled:i}},PC=()=>Z(e=>e.message.status?.type===`incomplete`&&e.message.status.reason===`error`?e.message.status.error??`An error occurred`:void 0),FC=e=>{let{cloud:t,initialMessages:n,maxSteps:r,adapters:i,unstable_humanToolNames:a,...o}=e;return{localRuntimeOptions:{cloud:t,initialMessages:n,maxSteps:r,adapters:i,unstable_humanToolNames:a},otherOptions:o}},IC=/:([\w-]{1,64})\[([^\]\n]{1,1024})\](?:\{name=([^}\n]{1,1024})\})?/gu,LC={serialize(e){let t=e.id===e.label?``:`{name=${e.id}}`;return`:${e.type}[${e.label}]${t}`},parse(e){let t=[],n=0;for(let r of e.matchAll(IC)){r.index>n&&t.push({kind:`text`,text:e.slice(n,r.index)});let i=r[2];t.push({kind:`mention`,type:r[1],label:i,id:r[3]??i}),n=r.index+r[0].length}return n<e.length&&t.push({kind:`text`,text:e.slice(n)}),t}};function RC(e,t){function n(n){let r=(0,_.useContext)(e);if(!n?.optional&&!r)throw Error(`This component must be used within ${t}.`);return r}return n}function zC(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 BC=(0,_.createContext)(null),{useThreadViewport:VC,useThreadViewportStore:HC}=zC(RC(BC,`ThreadPrimitive.Viewport`),`useThreadViewport`),UC=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()}}}}},WC=(e={})=>{let t=new Set,n=UC(e=>{a.setState({height:{...a.getState().height,viewport:e}})}),r=UC(e=>{a.setState({height:{...a.getState().height,inset:e}})}),i=(e,t)=>(a.setState({element:{...a.getState().element,[e]:t}}),()=>{a.getState().element[e]===t&&a.setState({element:{...a.getState().element,[e]:null}})}),a=Cy(()=>({isAtBottom:!0,scrollToBottom:({behavior:e=`auto`}={})=>{for(let n of t)n({behavior:e})},onScrollToBottom:e=>(t.add(e),()=>{t.delete(e)}),turnAnchor:e.turnAnchor??`bottom`,topAnchorMessageClamp:{tallerThan:e.topAnchorMessageClamp?.tallerThan??`10em`,visibleHeight:e.topAnchorMessageClamp?.visibleHeight??`6em`},height:{viewport:0,inset:0},element:{viewport:null,anchor:null,target:null},targetConfig:null,topAnchorTurn:null,registerViewport:n.register,registerContentInset:r.register,registerViewportElement:e=>i(`viewport`,e),registerAnchorElement:e=>i(`anchor`,e),registerAnchorTargetElement:(e,t)=>(a.setState({element:{...a.getState().element,target:e},targetConfig:e&&t?t:null}),()=>{a.getState().element.target===e&&a.setState({element:{...a.getState().element,target:null},targetConfig:null})}),setTopAnchorTurn:e=>{a.setState({topAnchorTurn:e})}}));return a},GC=e=>e,KC=e=>{let t=HC({optional:!0}),[n]=(0,_.useState)(()=>WC(e));return(0,_.useEffect)(()=>t?.getState().onScrollToBottom(()=>{n.getState().scrollToBottom()}),[t,n]),(0,_.useEffect)(()=>{if(t)return n.subscribe(e=>{t.getState().isAtBottom!==e.isAtBottom&&GC(t).setState({isAtBottom:e.isAtBottom})})},[n,t]),n},qC=({children:e,options:t={}})=>{let n=KC(t),[r]=(0,_.useState)(()=>({useThreadViewport:n}));return(0,G.jsx)(BC.Provider,{value:r,children:e})},JC=()=>((0,_.useEffect)(()=>{},[Rv()]),null),YC=(0,_.memo)(({children:e,aui:t,runtime:n})=>(0,G.jsxs)(_y,{runtime:n,aui:t??null,children:[(0,G.jsx)(JC,{}),(0,G.jsx)(qC,{children:e})]}));function XC(e){let t=Rv(),n=Z(()=>t.composer.source?t.composer().__internal_getRuntime?.()??null:null);if(!n&&!e?.optional)throw Error(`ComposerRuntime is not available`);return n}var ZC=Object.defineProperty,QC=(e,t)=>{let n={};for(var r in e)ZC(n,r,{get:e[r],enumerable:!0});return t||ZC(n,Symbol.toStringTag,{value:`Module`}),n},$C=Symbol.for(`react.lazy`),ew=_.use;function tw(e){return typeof e==`object`&&!!e&&`then`in e}function nw(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===$C&&`_payload`in e&&tw(e._payload)}function rw(e){let t=iw(e),n=_.forwardRef((e,n)=>{let{children:r,...i}=e;nw(r)&&typeof ew==`function`&&(r=ew(r._payload));let a=_.Children.toArray(r),o=a.find(ow);if(o){let e=o.props.children,r=a.map(t=>t===o?_.Children.count(e)>1?_.Children.only(null):_.isValidElement(e)?e.props.children:null:t);return(0,G.jsx)(t,{...i,ref:n,children:_.isValidElement(e)?_.cloneElement(e,void 0,r):null})}return(0,G.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function iw(e){let t=_.forwardRef((e,t)=>{let{children:n,...r}=e;if(nw(n)&&typeof ew==`function`&&(n=ew(n._payload)),_.isValidElement(n)){let e=cw(n),i=sw(r,n.props);return n.type!==_.Fragment&&(i.ref=t?Ai(t,e):e),_.cloneElement(n,i)}return _.Children.count(n)>1?_.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var aw=Symbol(`radix.slottable`);function ow(e){return _.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===aw}function sw(e,t){let n={...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]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function cw(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var lw=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=rw(`Primitive.${t}`),r=_.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,G.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),uw=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`];function dw(e){let t=(0,_.forwardRef)(({render:t,asChild:n,children:r,...i},a)=>{let o=e;if(t&&(0,_.isValidElement)(t)){let e=r===void 0?t.props.children:r;return(0,G.jsx)(o,{...i,asChild:!0,ref:a,children:(0,_.cloneElement)(t,void 0,e)})}return(0,G.jsx)(o,{...i,asChild:n,ref:a,children:r})});return t.displayName=typeof e==`string`?e:e.displayName??e.name??`Component`,t}function fw(e){let t=lw[e],n=dw(t);return n.displayName=`Primitive.${e}`,n}var pw=uw.reduce((e,t)=>(e[t]=fw(t),e),{}),mw=(e,t,n=[])=>{let r=(0,_.forwardRef)((e,r)=>{let i={},a={};Object.keys(e).forEach(t=>{n.includes(t)?i[t]=e[t]:a[t]=e[t]});let o=t(i)??void 0;return(0,G.jsx)(pw.button,{...a,type:`button`,ref:r,disabled:a.disabled||!o,onClick:K(a.onClick,o)})});return r.displayName=e,r},hw=e=>Z(t=>{let{role:n,attachments:r,parts:i,branchCount:a,isLast:o,speech:s,isCopied:c,isHovering:l}=t.message;return!(e.hasBranches===!0&&a<2||e.user&&n!==`user`||e.assistant&&n!==`assistant`||e.system&&n!==`system`||e.lastOrHover===!0&&!l&&!o||e.last!==void 0&&e.last!==o||e.copied===!0&&!c||e.copied===!1&&c||e.speaking===!0&&s==null||e.speaking===!1&&s!=null||e.hasAttachments===!0&&(n!==`user`||!r?.length)||e.hasAttachments===!1&&n===`user`&&r?.length||e.hasContent===!0&&i.length===0||e.hasContent===!1&&i.length>0||e.submittedFeedback!==void 0&&(t.message.metadata.submittedFeedback?.type??null)!==e.submittedFeedback)}),gw=({children:e,...t})=>hw(t)?e:null;gw.displayName=`MessagePrimitive.If`;var _w=(0,_.createContext)(null),vw=()=>(0,_.useContext)(_w),yw=({children:e})=>{let t=(0,_.useRef)(new Map),n=(0,_.useRef)([]),r=(0,_.useCallback)(()=>{let e=Array.from(t.current.entries());e.sort((e,t)=>t[1]-e[1]),n.current=e.map(([e])=>e)},[]),i=(0,_.useCallback)((e,n)=>{let i=n?.priority??0;return t.current.set(e,i),r(),()=>{t.current.delete(e),r()}},[r]),a=(0,_.useCallback)(()=>n.current,[]),o=(0,_.useMemo)(()=>({register:i,getPlugins:a}),[i,a]);return(0,G.jsx)(_w.Provider,{value:o,children:e})},bw=(0,_.createContext)(null),xw=(0,_.createContext)(null),Sw=()=>{let e=(0,_.useContext)(bw);if(!e)throw Error(`useTriggerPopoverRootContext must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},Cw=()=>(0,_.useContext)(bw),ww=()=>{let e=(0,_.useContext)(xw);if(!e)throw Error(`useTriggerPopoverAriaPublish must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},Tw=()=>{let e=Sw();return(0,_.useSyncExternalStore)(e.subscribe,e.getTriggers,e.getTriggers)},Ew=new Map,Dw=()=>()=>{},Ow=()=>Ew,kw=()=>{let e=Cw();return(0,_.useSyncExternalStore)(e?e.subscribe:Dw,e?e.getTriggers:Ow,e?e.getTriggers:Ow)},Aw=()=>null,jw=()=>{let e=Cw();return(0,_.useSyncExternalStore)(e?e.subscribeAria:Dw,e?e.getActiveAria:Aw,e?e.getActiveAria:Aw)};function Mw(){let e=(0,_.useRef)(new Set);return{notify:(0,_.useCallback)(()=>{for(let t of e.current)t()},[]),subscribe:(0,_.useCallback)(t=>(e.current.add(t),()=>{e.current.delete(t)}),[])}}var Nw=({children:e})=>{let t=(0,_.useRef)(new Map),n=(0,_.useRef)(new Set),{notify:r,subscribe:i}=Mw(),a=(0,_.useCallback)(e=>{let{char:i}=e;if(t.current.has(i))return()=>{};let a=new Map(t.current);a.set(i,e),t.current=a,r();for(let t of n.current)t.added(e);return()=>{let e=new Map(t.current);e.delete(i),t.current=e,r();for(let e of n.current)e.removed(i)}},[r]),o=(0,_.useCallback)(()=>t.current,[]),s=(0,_.useCallback)(e=>(n.current.add(e),()=>{n.current.delete(e)}),[]),c=(0,_.useRef)(null),l=(0,_.useRef)(null),{notify:u,subscribe:d}=Mw(),f=(0,_.useCallback)((e,t)=>{if(t===null){if(l.current!==e)return;c.current=null,l.current=null,u();return}let n=c.current;l.current===e&&n!==null&&n.popoverId===t.popoverId&&n.highlightedItemId===t.highlightedItemId||(c.current=t,l.current=e,u())},[u]),p=(0,_.useCallback)(()=>c.current,[]),m=(0,_.useMemo)(()=>({register:a,getTriggers:o,subscribe:i,subscribeLifecycle:s,getActiveAria:p,subscribeAria:d}),[a,o,i,s,p,d]),h=(0,_.useMemo)(()=>({setActiveAria:f}),[f]);return(0,G.jsx)(bw.Provider,{value:m,children:(0,G.jsx)(xw.Provider,{value:h,children:e})})},Pw=({children:e})=>vw()?(0,G.jsx)(Nw,{children:e}):(0,G.jsx)(yw,{children:(0,G.jsx)(Nw,{children:e})});Pw.displayName=`ComposerPrimitive.TriggerPopoverRoot`;var Fw=/\s/u;function Iw(e,t,n){let r=e.slice(0,n);for(let e=r.length-1;e>=0;e--){let n=r[e];if(Fw.test(n))return null;if(r.startsWith(t,e)){if(e>0&&!Fw.test(r[e-1]))continue;return{query:r.slice(e+t.length),offset:e}}}return null}var Lw=Fg(({text:e,triggerChar:t})=>{let[n,r]=e_(e.length),i=s_(()=>Iw(e,t,Math.min(n,e.length)),[n,e,t]);return{trigger:i,query:i?.query??``,setCursorPosition:r}});function Rw(e){return`type`in e}var zw=Fg(({navigableList:e,isSearchMode:t,activeCategoryId:n,query:r,popoverId:i,open:a,selectItem:o,selectCategory:s,goBack:c,close:l})=>{let[u,d]=e_(0);r_(()=>{d(0)},[e]),r_(()=>{d(0)},[t,n]);let f=l_(t=>{t<0||t>=e.length||t!==u&&d(t)}),p=l_(t=>{if(!a)return!1;switch(t.key){case`ArrowDown`:return t.preventDefault(),d(t=>{let n=e.length;return n===0?0:t<n-1?t+1:0}),!0;case`ArrowUp`:return t.preventDefault(),d(t=>{let n=e.length;return n===0?0:t>0?t-1:n-1}),!0;case`Enter`:case`Tab`:{if(t.shiftKey)return!1;t.preventDefault();let n=e[u];return n&&(Rw(n)?o(n):s(n.id)),!0}case`Escape`:return t.preventDefault(),l(),!0;case`Backspace`:return n&&r===``?(t.preventDefault(),c(),!0):!1;default:return!1}}),m=e[u];return{highlightedIndex:u,highlightedItemId:a&&m?`${i}-option-${m.id}`:void 0,highlightIndex:f,handleKeyDown:p}});function Bw(e,t){return e.id.toLowerCase().includes(t)||e.label.toLowerCase().includes(t)||(e.description?.toLowerCase().includes(t)??!1)}var Vw=Fg(({adapter:e,query:t,open:n})=>{let[r,i]=e_(null);r_(()=>{n||i(null)},[n]);let a=s_(()=>!n||!e?[]:e.categories(),[n,e]),o=n?r:null,s=s_(()=>!o||!e?[]:e.categoryItems(o),[o,e]),c=s_(()=>{if(!n||!e||o||!t&&a.length>0)return null;if(e.search)return e.search(t);let r=[],i=t.toLowerCase();for(let t of a)for(let n of e.categoryItems(t.id))Bw(n,i)&&r.push(n);return r},[n,e,t,o,a]),l=c!==null,u=s_(()=>{if(l)return[];if(!t)return a;let e=t.toLowerCase();return a.filter(t=>t.label.toLowerCase().includes(e))},[a,t,l]),d=s_(()=>{if(l)return c??[];if(!t)return s;let e=t.toLowerCase();return s.filter(t=>Bw(t,e))},[s,t,l,c]);return{categories:u,items:d,isSearchMode:l,activeCategoryId:o,navigableList:s_(()=>l?c??[]:o?d:u,[l,c,o,d,u]),selectCategory:l_(e=>{i(e)}),goBack:l_(()=>{i(null)})}}),Hw=Fg(({behavior:e,trigger:t,aui:n,triggerChar:r,setCursorPosition:i,onSelected:a})=>{let o=i_(null),s=l_(e=>(o.current=e,()=>{o.current===e&&(o.current=null)}));return{selectItem:l_(i=>{if(!t||!e)return;if(o.current?.(i)){a();return}let s=n.composer().getState().text,c=s.slice(0,t.offset),l=s.slice(t.offset+r.length+t.query.length),u=()=>{let t=e.formatter.serialize(i);n.composer().setText(c+t+(l.startsWith(` `)?l:` ${l}`))};e.kind===`directive`?(u(),e.onInserted?.(i)):(e.removeOnExecute?n.composer().setText(c+(l.startsWith(` `)?l.slice(1):l)):u(),e.onExecute(i)),a()}),close:l_(()=>{a(),t&&i(t.offset)}),registerSelectItemOverride:s}}),Uw=Fg(({adapter:e,text:t,triggerChar:n,behavior:r,aui:i,popoverId:a})=>{let o=g_(Lw({text:t,triggerChar:n})),s=o.trigger!==null&&e!==void 0&&r!==void 0,c=g_(Vw({adapter:e,query:o.query,open:s})),l=l_(()=>{c.goBack()}),u=g_(Hw({behavior:r,trigger:o.trigger,aui:i,triggerChar:n,setCursorPosition:o.setCursorPosition,onSelected:l})),d=g_(zw({navigableList:c.navigableList,isSearchMode:c.isSearchMode,activeCategoryId:c.activeCategoryId,query:o.query,popoverId:a,open:s,selectItem:u.selectItem,selectCategory:c.selectCategory,goBack:c.goBack,close:u.close}));return{open:s,query:o.query,activeCategoryId:c.activeCategoryId,categories:c.categories,items:c.items,highlightedIndex:d.highlightedIndex,isSearchMode:c.isSearchMode,popoverId:a,highlightedItemId:d.highlightedItemId,selectCategory:c.selectCategory,goBack:c.goBack,selectItem:u.selectItem,close:u.close,highlightIndex:d.highlightIndex,handleKeyDown:d.handleKeyDown,setCursorPosition:o.setCursorPosition,registerSelectItemOverride:u.registerSelectItemOverride}}),Ww=(0,_.createContext)(null),Gw=()=>{let e=(0,_.useContext)(Ww);if(!e)throw Error(`useTriggerPopoverScopeContext must be used within ComposerPrimitive.TriggerPopover`);return e},Kw=()=>(0,_.useContext)(Ww),qw=(0,_.createContext)(null),Jw=()=>{let e=(0,_.useContext)(qw);if(!e)throw Error(`TriggerPopover.Directive / TriggerPopover.Action must be rendered inside ComposerPrimitive.TriggerPopover`);return e},Yw=(0,_.forwardRef)(({char:e,adapter:t,"aria-label":n,children:r,...i},a)=>{let o=Rv(),s=Z(e=>e.composer.text),c=(0,_.useId)(),l=(0,_.useRef)(null),[u,d]=(0,_.useState)(null),f=(0,_.useRef)(0),p=(0,_.useCallback)(e=>(f.current+=1,l.current=e,d(e),()=>{f.current=Math.max(0,f.current-1),l.current===e&&(l.current=null,d(null))}),[e]),m=(0,_.useMemo)(()=>({register:p}),[p]),h=Ov(Uw({adapter:t,text:s,triggerChar:e,behavior:u??void 0,aui:o,popoverId:c})),g=(0,_.useRef)(h);g.current=h;let v=Sw();(0,_.useEffect)(()=>v.register({char:e,...u?{behavior:u}:{},resource:g.current}),[v,e,u]);let y=vw();(0,_.useEffect)(()=>{if(y)return y.register(g.current)},[y]);let b=u!==null&&h.open,x=ww();return(0,_.useEffect)(()=>{if(b)return()=>{x.setActiveAria(e,null)}},[x,e,b]),(0,_.useEffect)(()=>{b&&x.setActiveAria(e,{popoverId:c,highlightedItemId:h.highlightedItemId})},[x,e,c,b,h.highlightedItemId]),(0,G.jsx)(qw.Provider,{value:m,children:(0,G.jsx)(Ww.Provider,{value:h,children:b?(0,G.jsx)(pw.div,{role:`listbox`,id:c,"aria-label":n??`Suggestions`,"aria-activedescendant":h.highlightedItemId,"data-state":`open`,...i,ref:a,children:r}):r})})});Yw.displayName=`ComposerPrimitive.TriggerPopover`;var Xw=()=>{let{disabled:e,send:t}=kC(),n=(0,_.useCallback)(()=>t(),[t]);return e?null:n},Zw=mw(`ComposerPrimitive.Send`,Xw),Qw=(0,_.forwardRef)(({onSubmit:e,...t},n)=>{let r=Xw(),i=e=>{e.preventDefault(),r&&r()};return(0,G.jsx)(pw.form,{...t,ref:n,onSubmit:K(e,i)})});Qw.displayName=`ComposerPrimitive.Root`;var $w=e=>{let t=xa(e),n=VC(e=>e.onScrollToBottom);(0,_.useEffect)(()=>n(t),[n,t])},eT=()=>!1,tT=()=>{},nT=e=>(0,_.useSyncExternalStore)((0,_.useCallback)(t=>{if(typeof window>`u`||e===null)return tT;let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},[e]),(0,_.useCallback)(()=>typeof window>`u`||e===null?!1:window.matchMedia(e).matches,[e]),eT);function rT(){return rT=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},rT.apply(null,arguments)}function iT(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 aT=_.useLayoutEffect,oT=function(e){var t=_.useRef(e);return aT(function(){t.current=e}),t},sT=function(e,t){if(typeof e==`function`){e(t);return}e.current=t},cT=function(e,t){var n=_.useRef();return _.useCallback(function(r){e.current=r,n.current&&sT(n.current,null),n.current=t,t&&sT(t,r)},[t])},lT={"min-height":`0`,"max-height":`none`,height:`0`,visibility:`hidden`,overflow:`hidden`,position:`absolute`,"z-index":`-1000`,top:`0`,right:`0`,display:`block`},uT=function(e){Object.keys(lT).forEach(function(t){e.style.setProperty(t,lT[t],`important`)})},dT=null,fT=function(e,t){var n=e.scrollHeight;return t.sizingStyle.boxSizing===`border-box`?n+t.borderSize:n-t.paddingSize};function pT(e,t,n,r){n===void 0&&(n=1),r===void 0&&(r=1/0),dT||(dT=document.createElement(`textarea`),dT.setAttribute(`tabindex`,`-1`),dT.setAttribute(`aria-hidden`,`true`),uT(dT)),dT.parentNode===null&&document.body.appendChild(dT);var i=e.paddingSize,a=e.borderSize,o=e.sizingStyle,s=o.boxSizing;Object.keys(o).forEach(function(e){var t=e;dT.style[t]=o[t]}),uT(dT),dT.value=t;var c=fT(dT,e);dT.value=t,c=fT(dT,e),dT.value=`x`;var l=dT.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 mT=function(){},hT=function(e,t){return e.reduce(function(e,n){return e[n]=t[n],e},{})},gT=[`borderBottomWidth`,`borderLeftWidth`,`borderRightWidth`,`borderTopWidth`,`boxSizing`,`fontFamily`,`fontSize`,`fontStyle`,`fontWeight`,`letterSpacing`,`lineHeight`,`paddingBottom`,`paddingLeft`,`paddingRight`,`paddingTop`,`tabSize`,`textIndent`,`textRendering`,`textTransform`,`width`,`wordBreak`,`wordSpacing`,`scrollbarGutter`],_T=!!document.documentElement.currentStyle,vT=function(e){var t=window.getComputedStyle(e);if(t===null)return null;var n=hT(gT,t),r=n.boxSizing;return r===``?null:(_T&&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 yT(e,t,n){var r=oT(n);_.useLayoutEffect(function(){var n=function(e){return r.current(e)};if(e)return e.addEventListener(t,n),function(){return e.removeEventListener(t,n)}},[])}var bT=function(e,t){yT(document.body,`reset`,function(n){e.current.form===n.target&&t(n)})},xT=function(e){yT(window,`resize`,e)},ST=function(e){yT(document.fonts,`loadingdone`,e)},CT=[`cacheMeasurements`,`maxRows`,`minRows`,`onChange`,`onHeightChange`],wT=_.forwardRef(function(e,t){var n=e.cacheMeasurements,r=e.maxRows,i=e.minRows,a=e.onChange,o=a===void 0?mT:a,s=e.onHeightChange,c=s===void 0?mT:s,l=iT(e,CT),u=l.value!==void 0,d=_.useRef(null),f=cT(d,t),p=_.useRef(0),m=_.useRef(),h=function(){var e=d.current,t=n&&m.current?m.current:vT(e);if(t){m.current=t;var a=pT(t,e.value||e.placeholder||`x`,i,r),o=a[0],s=a[1];p.current!==o&&(p.current=o,e.style.setProperty(`height`,o+`px`,`important`),c(o,{rowHeight:s}))}};return _.useLayoutEffect(h),bT(d,function(){if(!u){var e=d.current.value;requestAnimationFrame(function(){var t=d.current;t&&e!==t.value&&h()})}}),xT(h),ST(h),_.createElement(`textarea`,rT({},l,{onChange:function(e){u||h(),o(e)},ref:f}))}),TT=`(pointer: coarse) and (not (any-pointer: fine))`,ET=(0,_.forwardRef)(({autoFocus:e=!1,asChild:t,render:n,disabled:r,onChange:i,onKeyDown:a,onPaste:o,onSelect:s,submitOnEnter:c,submitMode:l,cancelOnEscape:u=!0,unstable_focusOnRunStart:d=!0,unstable_focusOnScrollToBottom:f=!0,unstable_focusOnThreadSwitched:p=!0,unstable_insertNewlineOnTouchEnter:m=!1,addAttachmentOnPaste:h=!0,...g},v)=>{let y=Rv(),b=vw(),x=jw(),S=l??(c===!1?`none`:`enter`),C=nT(m?TT:null),w=m&&C&&S===`enter`?`none`:S,T=Z(e=>e.composer.isEditing?e.composer.text:``),E=Z(e=>e.thread.isDisabled||e.composer.dictation?.inputDisabled)||r,D=(0,_.useRef)(null),O=ji(v,D),k=(0,_.useRef)(!1);Sa(e=>{if(!D.current?.contains(e.target))return;if(b){for(let t of b.getPlugins())if(t.handleKeyDown(e))return}if(!u)return;let t=y.composer();t.getState().canCancel&&(t.cancel(),e.preventDefault())});let A=e=>{if(!E&&!e.nativeEvent.isComposing){if(b){for(let t of b.getPlugins())if(t.handleKeyDown(e))return}if(e.key===`Enter`){let t=y.thread().getState(),n=t.capabilities.queue;if(e.shiftKey&&(e.ctrlKey||e.metaKey)&&n&&S!==`none`&&y.composer().getState().canSend){e.preventDefault(),y.composer().send({steer:!0});return}if(e.shiftKey||t.isRunning&&!n)return;let r=!1;w===`ctrlEnter`?r=e.ctrlKey||e.metaKey:w===`enter`&&(r=!0),r&&(e.preventDefault(),D.current?.closest(`form`)?.requestSubmit())}}},j=async e=>{if(!h)return;let t=y.thread().getState().capabilities,n=Array.from(e.clipboardData?.files||[]);if(t.attachments&&n.length>0)try{e.preventDefault(),await Promise.all(n.map(e=>y.composer().addAttachment(e)))}catch(e){console.error(`Error adding attachment:`,e)}},M=e&&!E,N=(0,_.useCallback)(()=>{let e=D.current;!e||!M||(e.focus({preventScroll:!0}),e.setSelectionRange(e.value.length,e.value.length))},[M]);(0,_.useEffect)(()=>N(),[N]),$w(()=>{y.composer().getState().type===`thread`&&f&&N()}),(0,_.useEffect)(()=>{if(!(y.composer().getState().type!==`thread`||!d))return y.on(`thread.runStart`,N)},[d,N,y]),(0,_.useEffect)(()=>{if(!(y.composer().getState().type!==`thread`||!p))return y.on(`threadListItem.switchedTo`,N)},[p,N,y]);let P=x?{"aria-controls":x.popoverId,"aria-expanded":!0,"aria-haspopup":`listbox`,"aria-activedescendant":x.highlightedItemId}:{},F={name:`input`,value:T,...g,...P,ref:O,disabled:E,onChange:K(i,e=>{if(!y.composer().getState().isEditing)return;let t=e.nativeEvent.isComposing===!0;k.current&&!t&&(k.current=!1);let n=t||k.current;if(w_(()=>{y.composer().setText(e.target.value)}),n)return;let r=e.target.selectionStart??e.target.value.length;if(b)for(let e of b.getPlugins())e.setCursorPosition(r)}),onKeyDown:K(a,A),onCompositionStart:K(g.onCompositionStart,()=>{k.current=!0}),onCompositionEnd:K(g.onCompositionEnd,e=>{if(k.current=!1,!y.composer().getState().isEditing)return;let t=e.target;w_(()=>{y.composer().setText(t.value)});let n=t.selectionStart??t.value.length;if(b)for(let e of b.getPlugins())e.setCursorPosition(n)}),onSelect:K(s,e=>{if(k.current)return;let t=e.target,n=t.selectionStart??t.value.length;if(b)for(let e of b.getPlugins())e.setCursorPosition(n)}),onPaste:K(o,j)};if(n&&(0,_.isValidElement)(n)){let e=g.children===void 0?n.props.children:g.children;return(0,G.jsx)(Ni,{...F,children:(0,_.cloneElement)(n,void 0,e)})}return(0,G.jsx)(t?Ni:wT,{...F})});ET.displayName=`ComposerPrimitive.Input`;var DT=mw(`ComposerPrimitive.Cancel`,()=>{let{disabled:e,cancel:t}=AC();return e?null:t}),OT=mw(`ComposerPrimitive.AddAttachment`,({multiple:e=!0}={})=>{let{disabled:t,addAttachment:n}=MC(),r=Rv(),i=(0,_.useCallback)(()=>{let t=document.createElement(`input`);t.type=`file`,t.multiple=e,t.hidden=!0;let i=r.composer().getState().attachmentAccept;i!==`*`&&(t.accept=i),document.body.appendChild(t),t.onchange=e=>{let r=e.target.files;if(r){for(let e of r)n(e);document.body.removeChild(t)}},t.oncancel=()=>{(!t.files||t.files.length===0)&&document.body.removeChild(t)},t.click()},[r,e,n]);return t?null:i},[`multiple`]),kT=(0,_.forwardRef)(({disabled:e,asChild:t=!1,render:n,children:r,...i},a)=>{let[o,s]=(0,_.useState)(!1),c=Rv(),l=(0,_.useCallback)(t=>{e||(t.preventDefault(),s(!0))},[e]),u=(0,_.useCallback)(t=>{e||(t.preventDefault(),o||s(!0))},[e,o]),d=(0,_.useCallback)(t=>{if(e)return;t.preventDefault();let n=t.relatedTarget;n&&t.currentTarget.contains(n)||s(!1)},[e]),f=(0,_.useCallback)(async t=>{if(e)return;t.preventDefault(),s(!1);let n=Array.from(t.dataTransfer.files);await Promise.all(n.map(async e=>{try{await c.composer().addAttachment(e)}catch(e){console.error(`Failed to add attachment:`,e)}}))},[e,c]),p={...o?{"data-dragging":`true`}:null,...i,onDragEnterCapture:K(i.onDragEnterCapture,l),onDragOverCapture:K(i.onDragOverCapture,u),onDragLeaveCapture:K(i.onDragLeaveCapture,d),onDropCapture:K(i.onDropCapture,f),ref:a};if(n&&(0,_.isValidElement)(n)){let e=r===void 0?n.props.children:r;return(0,G.jsx)(Ni,{...p,children:(0,_.cloneElement)(n,void 0,e)})}return(0,G.jsx)(t?Ni:`div`,{...p,children:r})});kT.displayName=`ComposerPrimitive.AttachmentDropzone`;var AT=mw(`ComposerPrimitive.Dictate`,()=>{let{disabled:e,startDictation:t}=jC();return e?null:t}),jT=mw(`ComposerPrimitive.StopDictation`,()=>{let e=Rv(),t=Z(e=>e.composer.dictation!=null),n=(0,_.useCallback)(()=>{e.composer().stopDictation()},[e]);return t?n:null}),MT=(0,_.forwardRef)(({children:e,...t},n)=>{let r=Z(e=>e.composer.dictation?.transcript);return r?(0,G.jsx)(pw.span,{...t,ref:n,children:e??r}):null});MT.displayName=`ComposerPrimitive.DictationTranscript`;var NT=(0,_.forwardRef)((e,t)=>Z(e=>e.composer.quote)?(0,G.jsx)(pw.div,{...e,ref:t}):null);NT.displayName=`ComposerPrimitive.Quote`;var PT=(0,_.forwardRef)(({children:e,...t},n)=>{let r=Z(e=>e.composer.quote?.text);return r?(0,G.jsx)(pw.span,{...t,ref:n,children:e??r}):null});PT.displayName=`ComposerPrimitive.QuoteText`;var FT=(0,_.forwardRef)(({onClick:e,...t},n)=>{let r=Rv(),i=(0,_.useCallback)(()=>{r.composer().setQuote(void 0)},[r]);return(0,G.jsx)(pw.button,{type:`button`,...t,ref:n,onClick:K(e,i)})});FT.displayName=`ComposerPrimitive.QuoteDismiss`;var IT=(0,_.forwardRef)(({children:e,"aria-label":t,...n},r)=>{let{categories:i,activeCategoryId:a,isSearchMode:o,open:s}=Gw();return!s||a||o?null:(0,G.jsx)(pw.div,{role:`group`,"aria-label":t??`Categories`,...n,ref:r,children:e(i)})});IT.displayName=`ComposerPrimitive.TriggerPopoverCategories`;var LT=(0,_.forwardRef)(({categoryId:e,onClick:t,onMouseMove:n,...r},i)=>{let{selectCategory:a,highlightIndex:o,categories:s,highlightedIndex:c,activeCategoryId:l,isSearchMode:u,popoverId:d}=Gw(),f=(0,_.useCallback)(()=>{a(e)},[a,e]),p=s.findIndex(t=>t.id===e),m=!l&&!u&&p===c,h=(0,_.useCallback)(()=>{o(p)},[o,p]);return(0,G.jsx)(pw.button,{type:`button`,role:`option`,id:`${d}-option-${e}`,"aria-selected":m,"data-highlighted":m?``:void 0,...r,ref:i,onClick:K(t,f),onMouseMove:K(n,h)})});LT.displayName=`ComposerPrimitive.TriggerPopoverCategoryItem`;var RT=(0,_.forwardRef)(({children:e,"aria-label":t,...n},r)=>{let{items:i,activeCategoryId:a,isSearchMode:o,open:s}=Gw();return!s||!a&&!o?null:(0,G.jsx)(pw.div,{role:`group`,"aria-label":t??`Items`,...n,ref:r,children:e(i)})});RT.displayName=`ComposerPrimitive.TriggerPopoverItems`;var zT=(0,_.forwardRef)(({item:e,index:t,onClick:n,onMouseMove:r,...i},a)=>{let{selectItem:o,highlightIndex:s,items:c,highlightedIndex:l,activeCategoryId:u,isSearchMode:d,popoverId:f}=Gw(),p=(0,_.useCallback)(()=>{o(e)},[o,e]),m=t??c.findIndex(t=>t.id===e.id),h=(d||u!==null)&&m===l,g=(0,_.useCallback)(()=>{s(m)},[s,m]);return(0,G.jsx)(pw.button,{type:`button`,role:`option`,id:`${f}-option-${e.id}`,"aria-selected":h,"data-highlighted":h?``:void 0,...i,ref:a,onClick:K(n,p),onMouseMove:K(r,g)})});zT.displayName=`ComposerPrimitive.TriggerPopoverItem`;var BT=(0,_.forwardRef)(({onClick:e,...t},n)=>{let{activeCategoryId:r,isSearchMode:i,goBack:a,open:o}=Gw();return!o||!r||i?null:(0,G.jsx)(pw.button,{type:`button`,...t,ref:n,onClick:K(e,a)})});BT.displayName=`ComposerPrimitive.TriggerPopoverBack`;var VT=({formatter:e,onExecute:t,removeOnExecute:n})=>{let{register:r}=Jw(),i=(0,_.useRef)(t);return i.current=t,(0,_.useEffect)(()=>r({kind:`action`,formatter:e??LC,onExecute:e=>i.current(e),...n===void 0?{}:{removeOnExecute:n}}),[r,e,n]),null};VT.displayName=`ComposerPrimitive.TriggerPopoverAction`;var HT=({formatter:e,onInserted:t})=>{let{register:n}=Jw(),r=(0,_.useRef)(t);return r.current=t,(0,_.useEffect)(()=>n({kind:`directive`,formatter:e??LC,onInserted:e=>r.current?.(e)}),[n,e]),null};HT.displayName=`ComposerPrimitive.TriggerPopoverDirective`;var UT=Object.assign(Yw,{Directive:HT,Action:VT}),WT=QC({AddAttachment:()=>OT,AttachmentByIndex:()=>_C,AttachmentDropzone:()=>kT,Attachments:()=>yC,Cancel:()=>DT,Dictate:()=>AT,DictationTranscript:()=>MT,If:()=>OC,Input:()=>ET,Queue:()=>bC,Quote:()=>NT,QuoteDismiss:()=>FT,QuoteText:()=>PT,Root:()=>Qw,Send:()=>Zw,StopDictation:()=>jT,Unstable_TriggerPopover:()=>UT,Unstable_TriggerPopoverBack:()=>BT,Unstable_TriggerPopoverCategories:()=>IT,Unstable_TriggerPopoverCategoryItem:()=>LT,Unstable_TriggerPopoverItem:()=>zT,Unstable_TriggerPopoverItems:()=>RT,Unstable_TriggerPopoverRoot:()=>Pw,unstable_useTriggerPopoverRootContext:()=>Sw,unstable_useTriggerPopoverRootContextOptional:()=>Cw,unstable_useTriggerPopoverScopeContext:()=>Gw,unstable_useTriggerPopoverScopeContextOptional:()=>Kw,unstable_useTriggerPopoverTriggers:()=>Tw,unstable_useTriggerPopoverTriggersOptional:()=>kw}),GT=()=>Z(e=>{if(e.part.type!==`text`&&e.part.type!==`reasoning`)throw Error(`MessagePartText can only be used inside text or reasoning message parts.`);return e.part}),KT=()=>Z(e=>{if(e.part.type!==`image`)throw Error(`MessagePartImage can only be used inside image message parts.`);return e.part}),qT=(0,_.createContext)(null),JT=e=>({useSmoothStatus:Cy(()=>e)}),YT=({children:e})=>{let t=ZT({optional:!0}),n=Rv(),[r]=(0,_.useState)(()=>JT(n.part().getState().status));return t?e:(0,G.jsx)(qT.Provider,{value:r,children:e})},XT=e=>{let t=(0,_.forwardRef)((t,n)=>(0,G.jsx)(YT,{children:(0,G.jsx)(e,{...t,ref:n})}));return t.displayName=e.displayName,t};function ZT(e){let t=(0,_.useContext)(qT);if(!e?.optional&&!t)throw Error(`This component must be used within a SmoothContextProvider.`);return t}var{useSmoothStatus:QT,useSmoothStatusStore:$T}=zC(ZT,`useSmoothStatus`),eE=class{currentText;setText;animationFrameId=null;lastUpdateTime=Date.now();targetText=``;constructor(e,t){this.currentText=e,this.setText=t}start(){this.animationFrameId===null&&(this.lastUpdateTime=Date.now(),this.animate())}stop(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}animate=()=>{let e=Date.now(),t=e-this.lastUpdateTime,n=this.targetText.length-this.currentText.length,r=Math.min(5,250/n),i=0;for(;t>=r&&i<n;)i++,t-=r;i===n?this.animationFrameId=null:this.animationFrameId=requestAnimationFrame(this.animate),i!==0&&(this.currentText=this.targetText.slice(0,this.currentText.length+i),this.lastUpdateTime=e-t,this.setText(this.currentText))}},tE=Object.freeze({type:`running`}),nE=(e,t=!1)=>{let{text:n}=e,[r,i]=(0,_.useState)(e.status.type===`running`?``:n),a=Rv(),o=Z(()=>a.part()),[s,c]=(0,_.useState)(o);(o!==s||!n.startsWith(r))&&(c(o),i(e.status.type===`running`?``:n));let l=$T({optional:!0}),u=xa(t=>{if(i(t),l){let n=r!==t||e.status.type===`running`?tE:e.status;GC(l).setState(n,!0)}});(0,_.useEffect)(()=>{if(l){let i=t&&(r!==n||e.status.type===`running`)?tE:e.status;GC(l).setState(i,!0)}},[l,t,n,r,e.status]);let[d]=(0,_.useState)(new eE(r,u)),f=(0,_.useRef)(o);return(0,_.useEffect)(()=>{if(!t){d.stop();return}let r=f.current!==o;if(f.current=o,r||!n.startsWith(d.targetText)){e.status.type===`running`?(d.currentText=``,d.targetText=n,d.start()):(d.currentText=n,d.targetText=n,d.stop());return}d.targetText=n,d.start()},[d,t,n,e.status.type,o]),(0,_.useEffect)(()=>()=>{d.stop()},[d]),(0,_.useMemo)(()=>t?{type:`text`,text:r,status:n===r?e.status:tE}:e,[t,r,e,n])},rE=(0,_.forwardRef)(({smooth:e=!0,component:t=`span`,...n},r)=>{let{text:i,status:a}=nE(GT(),e);return(0,G.jsx)(t,{"data-status":a.type,...n,ref:r,children:i})});rE.displayName=`MessagePartPrimitive.Text`;var iE=(0,_.forwardRef)((e,t)=>{let{image:n}=KT();return(0,G.jsx)(pw.img,{src:n,...e,ref:t})});iE.displayName=`MessagePartPrimitive.Image`;var aE=e=>{let t=(0,_.useRef)(void 0);return(0,_.useCallback)(n=>{t.current&&=(t.current(),void 0),n&&(t.current=e(n))},[e])},oE=(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},sE=e=>e.dataset.messageId,cE=()=>{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},lE=(e,t)=>{let n=`${t}px`;return e.style.height===n?!1:(e.style.height=n,!0)},uE=e=>{let t=window.devicePixelRatio||1;return Math.round(e*t)/t},dE=()=>{let e=Rv(),t=Z(()=>e.message());return aE((0,_.useCallback)(e=>{let n=()=>{t.setIsHovering(!0)},r=()=>{t.setIsHovering(!1)};return e.addEventListener(`mouseenter`,n),e.addEventListener(`mouseleave`,r),e.matches(`:hover`)&&queueMicrotask(()=>t.setIsHovering(!0)),()=>{e.removeEventListener(`mouseenter`,n),e.removeEventListener(`mouseleave`,r),t.setIsHovering(!1)}},[t]))},fE=()=>{let e=VC(e=>e.topAnchorTurn?.anchorId);return Z(t=>t.message.role===`user`&&t.message.index>0&&t.message.index===t.thread.messages.length-2&&t.thread.messages.at(-1)?.role===`assistant`&&(t.message.id===e||t.thread.isRunning))},pE=()=>{let e=VC(e=>e.topAnchorTurn?.targetId);return Z(t=>t.message.isLast&&t.message.role===`assistant`&&t.message.index>=1&&t.thread.messages.at(t.message.index-1)?.role===`user`&&(t.message.id===e||t.thread.isRunning))},mE=(e,t)=>aE((0,_.useCallback)(n=>{if(e)return t.getState().registerAnchorElement(n)},[e,t])),hE=({active:e,threadViewportStore:t})=>aE((0,_.useCallback)(n=>{if(!e)return;let r=t.getState(),i=r.topAnchorMessageClamp;return r.registerAnchorTargetElement(n,{tallerThan:oE(i.tallerThan,n),visibleHeight:oE(i.visibleHeight,n)})},[e,t])),gE=({forwardedRef:e,...t})=>{let n=ji(e,dE()),r=Z(e=>e.message.id);return(0,G.jsx)(pw.div,{...t,ref:n,"data-message-id":r})},_E=({forwardedRef:e,threadViewportStore:t,...n})=>{let r=dE(),i=fE(),a=pE(),o=ji(e,r,mE(i,t),hE({active:a,threadViewportStore:t})),s=Z(e=>e.message.id);return(0,G.jsx)(pw.div,{...n,ref:o,"data-message-id":s,"data-aui-top-anchor-user":i?``:void 0,"data-aui-top-anchor-target":a?``:void 0})},vE=(0,_.forwardRef)((e,t)=>{let n=HC();return n.getState().turnAnchor===`top`?(0,G.jsx)(_E,{...e,forwardedRef:t,threadViewportStore:n}):(0,G.jsx)(gE,{...e,forwardedRef:t})});vE.displayName=`MessagePrimitive.Root`;var yE={...LS,Text:()=>(0,G.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,G.jsx)(rE,{}),(0,G.jsx)(xC,{children:(0,G.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Image:()=>(0,G.jsx)(iE,{})},bE=e=>{if(`children`in e)return(0,G.jsx)($S,{children:e.children});let{components:t,...n}=e;return(0,G.jsx)($S,{components:t?{Text:t.Text??yE.Text,Image:t.Image??yE.Image,Reasoning:t.Reasoning??LS.Reasoning,Source:t.Source??LS.Source,File:t.File??LS.File,Unstable_Audio:t.Unstable_Audio??LS.Unstable_Audio,...`ChainOfThought`in t?{ChainOfThought:t.ChainOfThought}:{tools:t.tools,data:t.data,ToolGroup:t.ToolGroup??LS.ToolGroup,ReasoningGroup:t.ReasoningGroup??LS.ReasoningGroup},Empty:t.Empty,Quote:t.Quote,generativeUI:t.generativeUI}:yE,...n})};bE.displayName=`MessagePrimitive.Parts`;var xE=({children:e})=>PC()===void 0?null:e;xE.displayName=`MessagePrimitive.Error`;var SE=e=>{let t=new Map;for(let n=0;n<e.length;n++){let r=e[n]?.parentId??`__ungrouped_${n}`,i=t.get(r)??[];i.push(n),t.set(r,i)}let n=[];for(let[e,r]of t){let t=e.startsWith(`__ungrouped_`)?void 0:e;n.push({groupKey:t,indices:r})}return n},CE=e=>{let t=Z(e=>e.message.parts);return(0,_.useMemo)(()=>t.length===0?[]:e(t),[t,e])},wE=({Fallback:e,...t})=>{let n=Z(n=>{let r=n.tools.tools[t.toolName]??e;return Array.isArray(r)?r[0]??e:r});return n?(0,G.jsx)(n,{...t}):null},TE=({Fallback:e,...t})=>{let n=Z(n=>{let r=n.dataRenderers.renderers[t.name]??e;return Array.isArray(r)?r[0]??e:r});return n?(0,G.jsx)(n,{...t}):null},EE={Text:()=>(0,G.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,G.jsx)(rE,{}),(0,G.jsx)(xC,{children:(0,G.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Reasoning:()=>null,Source:()=>null,Image:()=>(0,G.jsx)(iE,{}),File:()=>null,Unstable_Audio:()=>null,Group:({children:e})=>e},DE=({components:{Text:e=EE.Text,Reasoning:t=EE.Reasoning,Image:n=EE.Image,Source:r=EE.Source,File:i=EE.File,Unstable_Audio:a=EE.Unstable_Audio,tools:o={},data:s}={}})=>{let c=Rv(),l=Z(e=>e.part),u=l.type;if(u===`tool-call`){let e=c.part().addToolResult,t=c.part().resumeToolCall,n=c.part().respondToToolApproval;if(`Override`in o)return(0,G.jsx)(o.Override,{...l,addResult:e,resume:t,respondToApproval:n});let r=o.by_name?.[l.toolName]??o.Fallback;return(0,G.jsx)(wE,{...l,Fallback:r,addResult:e,resume:t,respondToApproval:n})}if(l.status?.type===`requires-action`)throw Error(`Encountered unexpected requires-action status`);switch(u){case`text`:return(0,G.jsx)(e,{...l});case`reasoning`:return(0,G.jsx)(t,{...l});case`source`:return(0,G.jsx)(r,{...l});case`image`:return(0,G.jsx)(n,{...l});case`file`:return(0,G.jsx)(i,{...l});case`audio`:return(0,G.jsx)(a,{...l});case`data`:{let e=s?.by_name?.[l.name]??s?.Fallback;return(0,G.jsx)(TE,{...l,Fallback:e})}default:return console.warn(`Unknown message part type: ${u}`),null}},OE=(0,_.memo)(({partIndex:e,components:t})=>(0,G.jsx)(gb,{index:e,children:(0,G.jsx)(DE,{components:t})}),(e,t)=>e.partIndex===t.partIndex&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.Group===t.components?.Group),kE=({status:e,component:t})=>(0,G.jsx)(vb,{text:``,isRunning:e.type===`running`,children:(0,G.jsx)(t,{type:`text`,text:``,status:e})}),AE=Object.freeze({type:`complete`}),jE=(0,_.memo)(({components:e})=>{let t=Z(e=>e.message.status??AE);return e?.Empty?(0,G.jsx)(e.Empty,{status:t}):(0,G.jsx)(kE,{status:t,component:e?.Text??EE.Text})},(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),ME=({groupingFunction:e,components:t})=>{let n=Z(e=>e.message.parts.length),r=CE(e);return(0,G.jsx)(G.Fragment,{children:(0,_.useMemo)(()=>n===0?(0,G.jsx)(jE,{components:t}):r.map((e,n)=>(0,G.jsx)(t?.Group??EE.Group,{groupKey:e.groupKey,indices:e.indices,children:e.indices.map(e=>(0,G.jsx)(OE,{partIndex:e,components:t},e))},`group-${n}-${e.groupKey??`ungrouped`}`)),[r,t,n])})};ME.displayName=`MessagePrimitive.Unstable_PartsGrouped`;var NE=({components:e,...t})=>(0,G.jsx)(ME,{...t,components:e,groupingFunction:SE});NE.displayName=`MessagePrimitive.Unstable_PartsGroupedByParentId`;var PE=QC({AttachmentByIndex:()=>fC,Attachments:()=>mC,Content:()=>bE,Error:()=>xE,GenerativeUI:()=>SS,GroupedParts:()=>cC,If:()=>gw,PartByIndex:()=>zS,Parts:()=>bE,Quote:()=>lC,Root:()=>vE,Unstable_PartsGrouped:()=>ME,Unstable_PartsGroupedByParentId:()=>NE}),FE=e=>{let t=xa(e);return aE((0,_.useCallback)(e=>{let n=new ResizeObserver(()=>{t()}),r=new MutationObserver(e=>{e.some(e=>e.type!==`attributes`||e.attributeName!==`style`)&&t()});return n.observe(e),r.observe(e,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),()=>{n.disconnect(),r.disconnect()}},[t]))},IE=({autoScroll:e,scrollToBottomOnRunStart:t=!0,scrollToBottomOnInitialize:n=!0,scrollToBottomOnThreadSwitch:r=!0})=>{let i=(0,_.useRef)(null),a=Z(e=>e.thread.messages.length>0),o=(0,_.useRef)(!1),s=(0,_.useRef)(null),c=HC();e===void 0&&(e=c.getState().turnAnchor!==`top`);let l=(0,_.useRef)(0),u=(0,_.useRef)(0),d=(0,_.useRef)(0),f=(0,_.useRef)(0),p=(0,_.useRef)(null),m=(0,_.useCallback)(e=>{let t=i.current;t&&(p.current=e,t.scrollTo({top:t.scrollHeight,behavior:e}))},[]),h=(0,_.useCallback)(e=>{p.current=e,s.current!==null&&cancelAnimationFrame(s.current),s.current=requestAnimationFrame(()=>{s.current=null,m(e)})},[m]);(0,_.useLayoutEffect)(()=>()=>{s.current!==null&&cancelAnimationFrame(s.current)},[]);let g=(0,_.useCallback)(()=>{let e=c.getState();return e.turnAnchor===`top`&&e.element.viewport===i.current&&e.element.anchor!==null},[c]),v=()=>{let e=i.current;if(!e)return;let t=c.getState().isAtBottom,n=Math.abs(e.scrollHeight-e.scrollTop-e.clientHeight)<=1||e.scrollHeight<=e.clientHeight;!n&&l.current<e.scrollTop||(n?e.scrollHeight>e.clientHeight+1&&(p.current=null):l.current>e.scrollTop&&u.current===e.scrollHeight&&(p.current=null),(n||p.current===null)&&n!==t&&GC(c).setState({isAtBottom:n})),l.current=e.scrollTop,u.current=e.scrollHeight},y=FE(()=>{let t=i.current;if(!t)return;let{scrollHeight:n,clientHeight:r}=t;if(n===d.current&&r===f.current)return;d.current=n,f.current=r;let a=p.current;a&&g()?p.current=null:a?m(a):e&&c.getState().isAtBottom&&m(`instant`),v()}),b=aE(e=>(e.addEventListener(`scroll`,v),()=>{e.removeEventListener(`scroll`,v)}));return(0,_.useLayoutEffect)(()=>{if(n){if(!a){o.current=!1;return}o.current||(o.current=!0,p.current===null&&h(`instant`))}},[a,h,n]),$w(({behavior:e})=>{m(e)}),Jv(`thread.runStart`,()=>{t&&c.getState().turnAnchor!==`top`&&h(`auto`)}),Jv(`threadListItem.switchedTo`,()=>{r&&h(`instant`)}),ji(y,b,i)},LE=(0,_.forwardRef)((e,t)=>(0,G.jsx)(pw.div,{...e,ref:t}));LE.displayName=`ThreadPrimitive.Root`;var RE=({children:e})=>Z(e=>e.thread.isEmpty)?e:null;RE.displayName=`ThreadPrimitive.Empty`;var zE=e=>Z(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)),BE=({children:e,...t})=>zE(t)?e:null;BE.displayName=`ThreadPrimitive.If`;var VE=(e,t)=>aE((0,_.useCallback)(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()}},[e,t])),HE=e=>{let t=0,n=e;for(;n;)t+=n.offsetTop,n=n.offsetParent;return t},UE=(e,t)=>{let n=0,r=e;for(;r&&r!==t;)n+=r.offsetTop,r=r.offsetParent;return r===t?n:HE(e)-HE(t)},WE=({viewport:e,anchor:t,tallerThan:n,visibleHeight:r})=>{let i=UE(t,e),a=t.offsetHeight;return i+Math.max(0,a-(a<=n?a:r))},GE=({scrollHeight:e,...t})=>{let{viewport:n}=t,r=WE(t)+n.clientHeight;return Math.max(0,r-e)},KE=({viewport:e,reserve:t,...n})=>GE({viewport:e,...n,scrollHeight:e.scrollHeight-t.offsetHeight}),qE=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}},JE=e=>{let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},cancel:()=>{t!==null&&(cancelAnimationFrame(t),t=null)}}},YE=e=>{let t=null,n;function r(){let r=e.getState(),{viewport:o,anchor:s,target:c}=r.element,l=r.targetConfig;if(r.turnAnchor!==`top`||!o||!s||!c||!l){a.disconnect(),t&&(lE(t,0),t.remove());return}if(t??=cE(),(t.parentElement!==c.parentElement||t.previousElementSibling!==c)&&c.after(t),a.target(o,s,c),lE(t,KE({viewport:o,anchor:s,reserve:t,...l}))){i.schedule();return}let u=sE(s);if(u!==void 0&&n===u)return;let d=uE(WE({viewport:o,anchor:s,...l}));Math.abs(o.scrollTop-d)>1&&o.scrollTo({top:d,behavior:`smooth`}),u!==void 0&&(n=u)}let i=JE(r),a=qE(i.schedule);i.schedule();let o=e.subscribe(i.schedule);return()=>{i.cancel(),o(),a.disconnect(),t?.remove()}},XE=e=>{let t=HC();(0,_.useLayoutEffect)(()=>{if(e)return YE(t)},[e,t])},ZE=({isRunning:e,messages:t})=>{if(!e)return null;let n=t.at(-1),r=t.at(-2);return r?.role!==`user`||n?.role!==`assistant`?null:{anchorId:r.id,targetId:n.id}},QE=e=>ZE(e)?.anchorId,$E=e=>ZE(e)?.targetId,eD=()=>VE(VC(e=>e.registerViewport),(0,_.useCallback)(e=>e.clientHeight,[])),tD=()=>aE(VC(e=>e.registerViewportElement)),nD=e=>{let t=HC(),n=Z(t=>{if(e)return QE(t.thread)}),r=Z(t=>{if(e)return $E(t.thread)}),i=(0,_.useMemo)(()=>!n||!r?null:{anchorId:n,targetId:r},[n,r]);(0,_.useLayoutEffect)(()=>{if(!i)return;let e=t.getState(),n=e.topAnchorTurn;n?.anchorId===i.anchorId&&n.targetId===i.targetId||e.setTopAnchorTurn(i)},[i,t]);let a=(0,_.useCallback)(()=>{t.getState().setTopAnchorTurn(null)},[t]);Jv(`thread.initialize`,a),Jv(`threadListItem.switchedTo`,a)},rD=(0,_.forwardRef)(({autoScroll:e,scrollToBottomOnRunStart:t,scrollToBottomOnInitialize:n,scrollToBottomOnThreadSwitch:r,children:i,...a},o)=>{let s=IE({autoScroll:e,scrollToBottomOnRunStart:t,scrollToBottomOnInitialize:n,scrollToBottomOnThreadSwitch:r}),c=eD(),l=tD(),u=HC().getState().turnAnchor===`top`;nD(u),XE(u);let d=ji(o,s,c,l);return(0,G.jsx)(pw.div,{...a,ref:d,children:i})});rD.displayName=`ThreadPrimitive.ViewportScrollable`;var iD=(0,_.forwardRef)(({turnAnchor:e,topAnchorMessageClamp:t,...n},r)=>(0,G.jsx)(qC,{options:{turnAnchor:e,topAnchorMessageClamp:t},children:(0,G.jsx)(rD,{...n,ref:r})}));iD.displayName=`ThreadPrimitive.Viewport`;var aD=(0,_.forwardRef)((e,t)=>{let n=ji(t,VE(VC(e=>e.registerContentInset),(0,_.useCallback)(e=>{let t=parseFloat(getComputedStyle(e).marginTop)||0;return e.offsetHeight+t},[])));return(0,G.jsx)(pw.div,{...e,ref:n})});aD.displayName=`ThreadPrimitive.ViewportFooter`;var oD=mw(`ThreadPrimitive.ScrollToBottom`,({behavior:e}={})=>{let t=VC(e=>e.isAtBottom),n=HC(),r=(0,_.useCallback)(()=>{n.getState().scrollToBottom({behavior:e})},[n,e]);return t?null:r},[`behavior`]),sD=mw(`ThreadPrimitive.Suggestion`,({prompt:e,send:t,clearComposer:n,autoSend:r,method:i})=>{let{disabled:a,trigger:o}=NC({prompt:e,send:t??r??!1,clearComposer:n});return a?null:o},[`prompt`,`send`,`clearComposer`,`autoSend`,`method`]),cD=QC({Empty:()=>RE,If:()=>BE,MessageByIndex:()=>fS,Messages:()=>hS,Root:()=>LE,ScrollToBottom:()=>oD,Suggestion:()=>sD,SuggestionByIndex:()=>CC,Suggestions:()=>EC,Viewport:()=>iD,ViewportFooter:()=>aD,ViewportProvider:()=>qC}),lD=QC({AssistantRuntimeImpl:()=>px,BaseAssistantRuntimeCore:()=>mx,CompositeContextProvider:()=>M_,DefaultThreadComposerRuntimeCore:()=>Hx,MessageRepository:()=>Fx,ThreadRuntimeImpl:()=>ax,fromThreadMessageLike:()=>jx,generateId:()=>Sx,getAutoStatus:()=>kx,splitLocalRuntimeOptions:()=>FC,useComposerInputPluginRegistryOptional:()=>vw,useSmooth:()=>nE,useSmoothStatus:()=>QT,withSmoothContextProvider:()=>XT});function uD(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function dD(e,t){let n=getComputedStyle(e.ownerDocument.documentElement);return t*parseFloat(n.fontSize)}function fD(e){return e/100*window.innerHeight}function pD(e){return e/100*window.innerWidth}function mD(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}function hD({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=mD(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=dD(t,i);break;case`em`:r=uD(t,i);break;case`vh`:r=fD(i);break;case`vw`:r=pD(i);break}return r}function gD(e){return parseFloat(e.toFixed(3))}function _D({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>(e+=t===`horizontal`?n.element.offsetWidth:n.element.offsetHeight,e),0)}function vD(e){let{panels:t}=e,n=_D({group:e});return n===0?t.map(e=>({groupResizeBehavior:e.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:e.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let{element:t,panelConstraints:r}=e,i=0;r.collapsedSize!==void 0&&(i=gD(hD({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=gD(hD({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=gD(hD({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=gD(hD({groupSize:n,panelElement:t,styleProp:r.maxSize})/n*100)),{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsible:r.collapsible===!0,defaultSize:a,disabled:r.disabled,minSize:o,maxSize:s,panelId:e.id}})}function yD(e,t=`Assertion error`){if(!e)throw Error(t)}function bD(e,t){return Array.from(t).sort(e===`horizontal`?xD:SD)}function xD(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function SD(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function CD(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function wD(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function TD({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=wD(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return yD(i,`No rect found`),i}var ED;function DD(){return ED===void 0&&(ED=typeof matchMedia==`function`?!!matchMedia(`(pointer:coarse)`).matches:!1),ED}function OD(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=bD(n,Array.from(t.children).filter(CD).map(e=>({element:e}))).map(({element:e})=>e),o=[],s=!1,c=!1,l=-1,u=-1,d=0,f,p=[];{let e=-1;for(let t of a)t.hasAttribute(`data-panel`)&&(e++,t.hasAttribute(`data-disabled`)||(d++,l===-1&&(l=e),u=e))}if(d>1){let t=-1;for(let d of a)if(d.hasAttribute(`data-panel`)){t++;let i=r.find(e=>e.element===d);if(i){if(f){let r=f.element.getBoundingClientRect(),a=d.getBoundingClientRect(),m;if(c){let e=n===`horizontal`?new DOMRect(r.right,r.top,0,r.height):new DOMRect(r.left,r.bottom,r.width,0),t=n===`horizontal`?new DOMRect(a.left,a.top,0,a.height):new DOMRect(a.left,a.top,a.width,0);switch(p.length){case 0:m=[e,t];break;case 1:{let i=p[0];m=[i,TD({orientation:n,rects:[r,a],targetRect:i.element.getBoundingClientRect()})===r?t:e];break}default:m=p;break}}else m=p.length?p:[n===`horizontal`?new DOMRect(r.right,a.top,a.left-r.right,a.height):new DOMRect(a.left,r.bottom,a.width,a.top-r.bottom)];for(let n of m){let r=`width`in n?n:n.element.getBoundingClientRect(),a=DD()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<a){let e=a-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<a){let e=a-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}!s&&!(t<=l||t>u)&&o.push({group:e,groupSize:_D({group:e}),panels:[f,i],separator:`width`in n?void 0:n,rect:r}),s=!1}}c=!1,f=i,p=[]}}else if(d.hasAttribute(`data-separator`)){d.ariaDisabled!==null&&(s=!0);let e=i.find(e=>e.element===d);e?p.push(e):(f=void 0,p=[])}else c=!0}return o}var kD=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0)if(n.length===1)n[0].call(null,t);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}},AD=new Map,jD=new kD;function MD(e){AD=new Map(AD),AD.delete(e)}function ND(e,t){for(let[t]of AD)if(t.id===e)return t}function PD(e,t){for(let[t,n]of AD)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function FD(){return AD}function ID(e,t){return jD.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function LD(e,t){let n=AD.get(e);AD=new Map(AD),AD.set(e,t),jD.emit(`groupChange`,{group:e,prev:n,next:t})}function RD(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=wD(n,a.rect);switch(e){case`horizontal`:t.x<=i.x&&(r=a,i=t);break;case`vertical`:t.y<=i.y&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function zD(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function BD(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:KD(e),b:KD(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();yD(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:GD(WD(n.a)),b:GD(WD(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var VD=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function HD(e){let t=getComputedStyle(qD(e)??e).display;return t===`flex`||t===`inline-flex`}function UD(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||HD(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||VD.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function WD(e){let t=e.length;for(;t--;){let n=e[t];if(yD(n,`Missing node`),UD(n))return n}return null}function GD(e){return e&&Number(getComputedStyle(e).zIndex)||0}function KD(e){let t=[];for(;e;)t.push(e),e=qD(e);return t}function qD(e){let{parentNode:t}=e;return zD(t)?t.host:t}function JD(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function YD({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!CD(n)||n.contains(e)||e.contains(n))return!0;if(BD(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(JD(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function XD(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=OD(r),a=RD(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&YD({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function ZD(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}function QD(e,t,n=0){return Math.abs(gD(e)-gD(t))<=n}function $D(e,t){return QD(e,t)?0:e>t?1:-1}function eO({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsible:a,disabled:o,maxSize:s=100,minSize:c=0}=t;if(o&&!e)return n;if($D(r,c)<0)if(a){let e=(i+c)/2;r=$D(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=gD(r),r}function tO({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(QD(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;yD(u!=null,`Invalid first pivot index`),yD(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];yD(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(yD(n!=null,`Previous layout not found for panel index ${t}`),QD(n,i)){let t=o-n;$D(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];yD(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(yD(n!=null,`Previous layout not found for panel index ${t}`),QD(n,o)){let t=n-i;$D(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];yD(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&$D(i,c)<0)if(e>0){let t=c-o,n=t/2;$D(i+e,c)<0&&(e=$D(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;$D(i-e,c)<0&&(e=$D(100+e,n)>0?0:-t)}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];yD(e!=null,`Previous layout not found for panel index ${r}`);let a=eO({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];yD(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=eO({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!QD(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(ZD(c,l))return i;{let t=e<0?d:u,r=s[t];yD(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=eO({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!QD(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];yD(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=eO({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(QD(i,s)||(t-=s-i,l[r]=s),QD(t,0))break;e>0?r--:r++}}}if(!QD(Object.values(l).reduce((e,t)=>t+e,0),100,.1))return i;let p=Object.keys(i);return l.reduce((e,t,n)=>(e[p[n]]=t,e),{})}function nO(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||$D(e[n],t[n])!==0)return!1;return!0}function rO({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],i=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(`, `)}`);if(!QD(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];yD(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];yD(i!=null,`No layout data found for index ${e}`);let o=r[e];yD(o!=null,`No layout data found for index ${e}`);let s=eO({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!QD(a,0))for(let e=0;e<t.length;e++){let n=r[e];yD(n!=null,`No layout data found for index ${e}`);let i=n+a,o=eO({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,QD(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function iO({groupId:e,panelId:t}){let n=()=>{let t=FD();for(let[n,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:a,groupSize:o,separatorToPanels:s}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:n,groupSize:o,layout:a,separatorToPanels:s};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().group.panels.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=({nextSize:e,panels:n,prevLayout:r,derivedPanelConstraints:i})=>{let o=a(),s=n.findIndex(e=>e.id===t),c=s===0,l=s===n.length-1;if(l&&e<o&&(c||n.slice(0,s).every((e,t)=>{let n=i[t];return n?.collapsible&&QD(n.collapsedSize,r[n.panelId])}))){let e=n.slice(0,s).reduce((e,t)=>e+r[t.id],0);return{...r,[t]:gD(100-e)}}return tO({delta:l?o-e:e-o,initialLayout:r,panelConstraints:i,pivotIndices:l?[s-1,s]:[s,s+1],prevLayout:r,trigger:`imperative-api`})},s=e=>{if(e===a())return;let{defaultLayoutDeferred:t,derivedPanelConstraints:r,group:i,groupSize:s,layout:c,separatorToPanels:l}=n(),u=rO({layout:o({nextSize:e,panels:i.panels,prevLayout:c,derivedPanelConstraints:r}),panelConstraints:r});nO(c,u)||LD(i,{defaultLayoutDeferred:t,derivedPanelConstraints:r,groupSize:s,layout:u,separatorToPanels:l})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),o=a();e&&o!==t&&(n.expandToSize=o,s(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:o}=i(),c=a();if(e&&c===t){let e=o.expandToSize??n;e===0&&(e=1),s(e)}},getSize:()=>{let{group:e}=n(),t=a(),{element:r}=i();return{asPercentage:t,inPixels:e.orientation===`horizontal`?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&QD(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=_D({group:t});s(gD(hD({groupSize:a,panelElement:r,styleProp:e})/a*100))}}}function aO(e){e.defaultPrevented||XD(e,FD()).forEach(t=>{if(t.separator&&!t.separator.disableDoubleClick){let n=t.panels.find(e=>e.panelConstraints.defaultSize!==void 0);if(n){let r=n.panelConstraints.defaultSize,i=iO({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function oO(e){let t=FD();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function sO({groupId:e}){let t=()=>{let t=FD();for(let[n,r]of t)if(n.id===e)return{group:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:i,groupSize:a,layout:o,separatorToPanels:s}=t(),c=rO({layout:e,panelConstraints:r});return n?o:(nO(o,c)||LD(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function cO(e,t){let n=oO(e),r=PD(n.id,!0),i=n.separators.find(t=>t.element===e);yD(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);yD(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=sO({groupId:n.id}).getLayout(),c=rO({layout:tO({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});nO(s,c)||LD(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels})}function lO(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=oO(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&cO(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&cO(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&cO(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&cO(t,-5);break;case`End`:e.preventDefault(),cO(t,100);break;case`Enter`:{e.preventDefault();let n=oO(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=PD(n.id,!0),o=n.separators.find(e=>e.element===t);yD(o,`Matching separator not found`);let s=a.get(o);yD(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(yD(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];cO(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=oO(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);yD(r!==null,`Index not found`),n[e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0].focus({preventScroll:!0});break}case`Home`:e.preventDefault(),cO(t,-100);break}}var uO={cursorFlags:0,state:`inactive`},dO=new kD;function fO(){return uO}function pO(e){return dO.addListener(`change`,e)}function mO(e){let t=uO,n={...uO};n.cursorFlags=e,uO=n,dO.emit(`change`,{prev:t,next:n})}function hO(e){let t=uO;uO=e,dO.emit(`change`,{prev:t,next:e})}function gO(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=FD(),n=XD(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus({focusVisible:!1,preventScroll:!0})));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),hO({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}var _O=e=>e,vO=()=>{},yO=1,bO=2,xO=4,SO=8,CO=3,wO=12,TO;function EO(){return TO===void 0&&(TO=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(TO=!0)),TO}function DO({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&EO()){let t=(e&yO)!==0,n=(e&bO)!==0,r=(e&xO)!==0,i=(e&SO)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return EO()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var OO=new WeakMap;function kO(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=OO.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));let r=fO();switch(r.state){case`active`:case`hover`:{let e=DO({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(e=>e.group),state:r.state}),i=`*, *:hover {cursor: ${e} !important; }`;if(t===i)return;t=i,e?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}OO.set(e,{prevStyle:t,styleSheet:n})}function AO({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0;n.forEach(e=>{let{group:n,groupSize:o}=e,{orientation:c,panels:l}=n,{disableCursor:u}=n.mutableState,d=0;d=a?c===`horizontal`?(t.clientX-a.x)/o*100:(t.clientY-a.y)/o*100:c===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let f=r.get(n),p=i.get(n);if(!f||!p)return;let{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:_,separatorToPanels:v}=p;if(h&&_&&v){let t=tO({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(nO(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?yO:bO;break;case`vertical`:s|=d<0?xO:SO;break}}else LD(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&CO:c|=s&CO,t.movementY===0?c|=o&wO:c|=s&wO,mO(c),kO(e)}function jO(e){let t=FD(),n=fO();switch(n.state){case`active`:AO({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function MO(e){if(e.defaultPrevented)return;let t=fO(),n=FD();switch(t.state){case`active`:if(e.buttons===0){hO({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=PD(e.group.id,!0);LD(e.group,t)});return}for(let n of t.hitRegions)if(n.separator){let{element:t}=n.separator;t.hasPointerCapture?.(e.pointerId)||t.setPointerCapture?.(e.pointerId)}AO({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=XD(e,n);r.length===0?t.state!==`inactive`&&hO({cursorFlags:0,state:`inactive`}):hO({cursorFlags:0,hitRegions:r,state:`hover`}),kO(e.currentTarget);break}}}function NO(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(fO().state){case`hover`:hO({cursorFlags:0,state:`inactive`})}}function PO(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=fO();switch(t.state){case`active`:hO({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(kO(e.currentTarget),t.hitRegions.forEach(e=>{let t=PD(e.group.id,!0);LD(e.group,t)}),e.preventDefault())}}function FO(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=gD(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=gD((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function IO(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=_D({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:gD(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function LO(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function RO({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,a=0,o=!1,s=new Map,c=[];for(let l of e.panels){let e=r[l.id]??0;switch(l.panelConstraints.groupResizeBehavior){case`preserve-pixel-size`:{o=!0;let r=gD(e/100*n/t*100);s.set(l.id,r),i+=r;break}default:c.push(l.id),a+=e;break}}if(!o||c.length===0)return r;let l=100-i,u={...r};if(s.forEach((e,t)=>{u[t]=e}),a>0)for(let e of c)u[e]=gD((r[e]??0)/a*l);else{let e=gD(l/c.length);for(let t of c)u[t]=e}return u}function zO(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}var BO=new Map;function VO(e){let t=!0;yD(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){let t=_D({group:e});if(t===0)return;let n=PD(e.id);if(!n)return;let r=vD(e),i=n.defaultLayoutDeferred?FO(r):n.layout,a=rO({layout:RO({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&nO(n.layout,a)&&LO(n.derivedPanelConstraints,r)&&n.groupSize===t)return;LD(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else IO(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{yD(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=_D({group:e}),s=vD(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(zO(e.panels,l)||(l=void 0));let u=rO({layout:e.mutableState.layouts[c]??l??FO(s),panelConstraints:s}),d=e.element.ownerDocument;BO.set(d,(BO.get(d)??0)+1);let f=new Map;return OD(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),LD(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,groupSize:o,layout:u,separatorToPanels:f}),e.separators.forEach(e=>{yD(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,lO)}),BO.get(d)===1&&(d.addEventListener(`dblclick`,aO,!0),d.addEventListener(`pointerdown`,gO,!0),d.addEventListener(`pointerleave`,jO),d.addEventListener(`pointermove`,MO),d.addEventListener(`pointerout`,NO),d.addEventListener(`pointerup`,PO,!0)),function(){t=!1,BO.set(d,Math.max(0,(BO.get(d)??0)-1)),MD(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,lO)}),BO.get(d)||(d.removeEventListener(`dblclick`,aO,!0),d.removeEventListener(`pointerdown`,gO,!0),d.removeEventListener(`pointerleave`,jO),d.removeEventListener(`pointermove`,MO),d.removeEventListener(`pointerout`,NO),d.removeEventListener(`pointerup`,PO,!0)),a.disconnect()}}function HO(){let[e,t]=(0,_.useState)({});return[e,(0,_.useCallback)(()=>t({}),[])]}function UO(e){let t=(0,_.useId)();return`${e??t}`}var WO=typeof window<`u`?_.useLayoutEffect:_.useEffect;function GO(e){let t=(0,_.useRef)(e);return WO(()=>{t.current=e},[e]),(0,_.useCallback)((...e)=>t.current?.(...e),[t])}function KO(...e){return GO(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function qO(e){let t=(0,_.useRef)({...e});return WO(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var JO=(0,_.createContext)(null);function YO(e,t){let n=(0,_.useRef)({getLayout:()=>({}),setLayout:_O});(0,_.useImperativeHandle)(t,()=>n.current,[]),WO(()=>{Object.assign(n.current,sO({groupId:e}))})}function XO({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){let m=(0,_.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=GO(e=>{nO(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=GO(e=>{nO(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e))}),v=UO(s),y=(0,_.useRef)(null),[b,x]=HO(),S=(0,_.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),C=KO(y,a);YO(v,o);let w=GO((e,t)=>{let r=fO(),i=ND(e),a=PD(e);if(a){let e=!1;switch(r.state){case`active`:e=r.hitRegions.some(e=>e.group===i);break}return{flexGrow:a.layout[t]??1,pointerEvents:e?`none`:void 0}}if(n?.[t])return{flexGrow:n?.[t]}}),T=qO({defaultLayout:n,disableCursor:r}),E=(0,_.useMemo)(()=>({get disableCursor(){return!!T.disableCursor},getPanelStyles:w,id:v,orientation:u,registerPanel:e=>{let t=S.current;return t.panels=bD(u,[...t.panels,e]),x(),()=>{t.panels=t.panels.filter(t=>t!==e),x()}},registerSeparator:e=>{let t=S.current;return t.separators=bD(u,[...t.separators,e]),x(),()=>{t.separators=t.separators.filter(t=>t!==e),x()}},updatePanelProps:(e,{disabled:t})=>{let n=S.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let r=ND(v),i=PD(v);r&&i&&LD(r,{...i,derivedPanelConstraints:vD(r)})},updateSeparatorProps:(e,{disabled:t,disableDoubleClick:n})=>{let r=S.current.separators.find(t=>t.id===e);r&&(r.disabled=t,r.disableDoubleClick=n)}}),[w,v,x,u,T]),D=(0,_.useRef)(null);return WO(()=>{let e=y.current;if(e===null)return;let t=S.current,n;if(T.defaultLayout!==void 0&&Object.keys(T.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=T.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={disabled:!!i,element:e,id:v,mutableState:{defaultLayout:n,disableCursor:!!T.disableCursor,expandedPanelSizes:S.current.lastExpandedPanelSizes,layouts:S.current.layouts},orientation:u,panels:t.panels,resizeTargetMinimumSize:t.resizeTargetMinimumSize,separators:t.separators};D.current=r;let a=VO(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=PD(r.id,!0);!o&&s.length>0&&(h(c),g(c));let l=ID(v,e=>{let{defaultLayoutDeferred:t,derivedPanelConstraints:n,layout:i}=e.next;if(t||n.length===0)return;let a=r.panels.map(({id:e})=>e).join(`,`);r.mutableState.layouts[a]=i,n.forEach(t=>{if(t.collapsible){let{layout:n}=e.prev??{};if(n){let e=QD(t.collapsedSize,i[t.panelId]),a=QD(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=fO().state!==`active`;h(i),o&&g(i)});return()=>{D.current=null,a(),l()}},[i,v,g,h,u,b,T]),(0,_.useEffect)(()=>{let e=D.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,G.jsx)(JO.Provider,{value:E,children:(0,G.jsx)(`div`,{...p,className:t,"data-group":!0,"data-testid":v,id:v,ref:C,style:{height:`100%`,width:`100%`,overflow:`hidden`,...f,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:e})})}XO.displayName=`Group`;function ZO(){let e=(0,_.useContext)(JO);return yD(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function QO(e,t){let{id:n}=ZO(),r=(0,_.useRef)({collapse:vO,expand:vO,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:vO});(0,_.useImperativeHandle)(t,()=>r.current,[]),WO(()=>{Object.assign(r.current,iO({groupId:n,panelId:e}))})}function $O({children:e,className:t,collapsedSize:n=`0%`,collapsible:r=!1,defaultSize:i,disabled:a,elementRef:o,groupResizeBehavior:s=`preserve-relative-size`,id:c,maxSize:l=`100%`,minSize:u=`0%`,onResize:d,panelRef:f,style:p,...m}){let h=!!c,g=UO(c),v=qO({disabled:a}),y=(0,_.useRef)(null),b=KO(y,o),{getPanelStyles:x,id:S,orientation:C,registerPanel:w,updatePanelProps:T}=ZO(),E=d!==null,D=GO((e,t,n)=>{d?.(e,c,n)});WO(()=>{let e=y.current;if(e!==null)return w({element:e,id:g,idIsStable:h,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:E?D:void 0,panelConstraints:{groupResizeBehavior:s,collapsedSize:n,collapsible:r,defaultSize:i,disabled:v.disabled,maxSize:l,minSize:u}})},[s,n,r,i,E,g,h,l,u,D,w,v]),(0,_.useEffect)(()=>{T(g,{disabled:a})},[a,g,T]),QO(g,f);let O=()=>{let e=x(S,g);if(e)return JSON.stringify(e)},k=(0,_.useSyncExternalStore)(e=>ID(S,e),O,O),A;return A=k?JSON.parse(k):i===void 0?{flexGrow:1}:{flexGrow:void 0,flexShrink:void 0,flexBasis:i},(0,G.jsx)(`div`,{...m,"data-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:b,style:{...ek,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...A},children:(0,G.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:C===`horizontal`?`pan-y`:`pan-x`},children:e})})}$O.displayName=`Panel`;var ek={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function tk({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a,o=e[n],s=t.find(e=>e.panelId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=rO({layout:tO({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=rO({layout:tO({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function nk({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=UO(a),l=qO({disabled:n,disableDoubleClick:r}),[u,d]=(0,_.useState)({}),[f,p]=(0,_.useState)(`inactive`),[m,h]=(0,_.useState)(!1),g=(0,_.useRef)(null),v=KO(g,i),{disableCursor:y,id:b,orientation:x,registerSeparator:S,updateSeparatorProps:C}=ZO(),w=x===`horizontal`?`vertical`:`horizontal`;WO(()=>{let e=g.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=S(t),r=pO(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=ID(b,e=>{let{derivedPanelConstraints:n,layout:r,separatorToPanels:i}=e.next,a=i.get(t);if(a){let e=a[0],t=a.indexOf(e);d(tk({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[b,c,S,l]),(0,_.useEffect)(()=>{C(c,{disabled:n,disableDoubleClick:r})},[n,r,c,C]);let T;n&&!y&&(T=`not-allowed`);let E;if(n)E=`disabled`;else switch(f){case`active`:E=`active`;break;default:E=m?`focus`:f}return(0,G.jsx)(`div`,{...s,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":w,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":E,"data-testid":c,id:c,onBlur:()=>h(!1),onFocus:()=>h(!0),ref:v,role:`separator`,style:{flexBasis:`auto`,cursor:T,...o,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}nk.displayName=`Separator`;var rk=(e,t)=>typeof e==`string`?e===t:JSON.stringify(e)===JSON.stringify(t),ik=(e,t)=>{if(!e||!t)return!1;let n=e=>{let{position:t,data:n,...r}=e||{};return r};return JSON.stringify(n(e.properties))===JSON.stringify(n(t.properties))&&rk(e.children,t.children)},ak=(e,t)=>ik(e.node,t.node),ok=(e={})=>Object.fromEntries(Object.entries(e??{}).map(([e,t])=>{if(!t)return[e,t];let n=t;return[e,(0,_.memo)(({node:e,...t})=>(0,G.jsx)(n,{...t}),ak)]})),sk=(0,_.createContext)(null),ck=()=>(0,_.useContext)(sk)!==null,lk=(0,_.memo)(({children:e,...t})=>(0,G.jsx)(sk.Provider,{value:t,children:e}),ak),uk=({node:e,...t})=>(0,G.jsx)(`pre`,{...t}),dk=({node:e,...t})=>(0,G.jsx)(`code`,{...t}),fk=({node:e,components:{Pre:t,Code:n},code:r})=>(0,G.jsx)(t,{children:(0,G.jsx)(n,{node:e,children:r})}),pk=()=>null,mk=({node:e,components:{Pre:t,Code:n,SyntaxHighlighter:r,CodeHeader:i},language:a,code:o})=>{let s=(0,_.useMemo)(()=>({Pre:t,Code:n}),[t,n]);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(i,{node:e,language:a,code:o}),(0,G.jsx)(a?r:fk,{node:e,components:s,language:a??`unknown`,code:o})]})},hk=n(r(((e,t)=>{(function(){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),gk=({className:e,...t})=>({className:n,...r})=>({className:(0,hk.default)(e,n),...t,...r}),_k=({node:e,components:{Pre:t,Code:n,SyntaxHighlighter:r,CodeHeader:i},componentsByLanguage:a={},children:o,...s})=>{let c=gk((0,_.useContext)(sk)),l=xa(e=>(0,G.jsx)(t,{...c(e)})),u=gk(s),d=xa(e=>(0,G.jsx)(n,{...u(e)})),f=/language-(\w+)/.exec(s.className||``)?.[1]??``;return typeof o==`string`?(0,G.jsx)(mk,{node:e,components:{Pre:l,Code:d,SyntaxHighlighter:a[f]?.SyntaxHighlighter??r,CodeHeader:a[f]?.CodeHeader??i},language:f||`unknown`,code:o}):(0,G.jsx)(fk,{node:e,components:{Pre:l,Code:d},code:o})},vk=(0,_.memo)(({node:e,components:t,componentsByLanguage:n,...r})=>ck()?(0,G.jsx)(_k,{node:e,components:t,componentsByLanguage:n,...r}):(0,G.jsx)(t.Code,{...r}),(e,t)=>e.components===t.components&&e.componentsByLanguage===t.componentsByLanguage&&ak(e,t));function yk(){}function bk(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var xk=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Sk=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ck={};function wk(e,t){return((t||Ck).jsx?Sk:xk).test(e)}var Tk=/[ \t\n\f\r]/g;function Ek(e){return typeof e==`object`?e.type===`text`?Dk(e.value):!1:Dk(e)}function Dk(e){return e.replace(Tk,``)===``}var Ok=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};Ok.prototype.normal={},Ok.prototype.property={},Ok.prototype.space=void 0;function kk(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new Ok(n,r,t)}function Ak(e){return e.toLowerCase()}var jk=class{constructor(e,t){this.attribute=t,this.property=e}};jk.prototype.attribute=``,jk.prototype.booleanish=!1,jk.prototype.boolean=!1,jk.prototype.commaOrSpaceSeparated=!1,jk.prototype.commaSeparated=!1,jk.prototype.defined=!1,jk.prototype.mustUseProperty=!1,jk.prototype.number=!1,jk.prototype.overloadedBoolean=!1,jk.prototype.property=``,jk.prototype.spaceSeparated=!1,jk.prototype.space=void 0;var Mk=e({boolean:()=>Pk,booleanish:()=>Fk,commaOrSpaceSeparated:()=>zk,commaSeparated:()=>Rk,number:()=>Q,overloadedBoolean:()=>Ik,spaceSeparated:()=>Lk}),Nk=0,Pk=Bk(),Fk=Bk(),Ik=Bk(),Q=Bk(),Lk=Bk(),Rk=Bk(),zk=Bk();function Bk(){return 2**++Nk}var Vk=Object.keys(Mk),Hk=class extends jk{constructor(e,t,n,r){let i=-1;if(super(e,t),Uk(this,`space`,r),typeof n==`number`)for(;++i<Vk.length;){let e=Vk[i];Uk(this,Vk[i],(n&Mk[e])===Mk[e])}}};Hk.prototype.defined=!0;function Uk(e,t,n){n&&(e[t]=n)}function Wk(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new Hk(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[Ak(r)]=r,n[Ak(a.attribute)]=r}return new Ok(t,n,e.space)}var Gk=Wk({properties:{ariaActiveDescendant:null,ariaAtomic:Fk,ariaAutoComplete:null,ariaBusy:Fk,ariaChecked:Fk,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:Lk,ariaCurrent:null,ariaDescribedBy:Lk,ariaDetails:null,ariaDisabled:Fk,ariaDropEffect:Lk,ariaErrorMessage:null,ariaExpanded:Fk,ariaFlowTo:Lk,ariaGrabbed:Fk,ariaHasPopup:null,ariaHidden:Fk,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Lk,ariaLevel:Q,ariaLive:null,ariaModal:Fk,ariaMultiLine:Fk,ariaMultiSelectable:Fk,ariaOrientation:null,ariaOwns:Lk,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:Fk,ariaReadOnly:Fk,ariaRelevant:null,ariaRequired:Fk,ariaRoleDescription:Lk,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:Fk,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function Kk(e,t){return t in e?e[t]:t}function qk(e,t){return Kk(e,t.toLowerCase())}var Jk=Wk({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:Rk,acceptCharset:Lk,accessKey:Lk,action:null,allow:null,allowFullScreen:Pk,allowPaymentRequest:Pk,allowUserMedia:Pk,alt:null,as:null,async:Pk,autoCapitalize:null,autoComplete:Lk,autoFocus:Pk,autoPlay:Pk,blocking:Lk,capture:null,charSet:null,checked:Pk,cite:null,className:Lk,cols:Q,colSpan:null,content:null,contentEditable:Fk,controls:Pk,controlsList:Lk,coords:Q|Rk,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Pk,defer:Pk,dir:null,dirName:null,disabled:Pk,download:Ik,draggable:Fk,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Pk,formTarget:null,headers:Lk,height:Q,hidden:Ik,high:Q,href:null,hrefLang:null,htmlFor:Lk,httpEquiv:Lk,id:null,imageSizes:null,imageSrcSet:null,inert:Pk,inputMode:null,integrity:null,is:null,isMap:Pk,itemId:null,itemProp:Lk,itemRef:Lk,itemScope:Pk,itemType:Lk,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Pk,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:Pk,muted:Pk,name:null,nonce:null,noModule:Pk,noValidate:Pk,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:Pk,optimum:Q,pattern:null,ping:Lk,placeholder:null,playsInline:Pk,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Pk,referrerPolicy:null,rel:Lk,required:Pk,reversed:Pk,rows:Q,rowSpan:Q,sandbox:Lk,scope:null,scoped:Pk,seamless:Pk,selected:Pk,shadowRootClonable:Pk,shadowRootDelegatesFocus:Pk,shadowRootMode:null,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:Fk,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:Pk,useMap:null,value:Fk,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Lk,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Pk,declare:Pk,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:Pk,noHref:Pk,noShade:Pk,noWrap:Pk,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:Fk,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Pk,disableRemotePlayback:Pk,prefix:null,property:null,results:Q,security:null,unselectable:null},space:`html`,transform:qk}),Yk=Wk({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:zk,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:Lk,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:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:Pk,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,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:Rk,g2:Rk,glyphName:Rk,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:zk,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Q,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:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Lk,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:zk,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:zk,rev:zk,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:zk,requiredFeatures:zk,requiredFonts:zk,requiredFormats:zk,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:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:zk,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:zk,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:zk,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:Kk}),Xk=Wk({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()}}),Zk=Wk({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:qk}),Qk=Wk({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),$k={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`},eA=/[A-Z]/g,tA=/-[a-z]/g,nA=/^data[-\w.:]+$/i;function rA(e,t){let n=Ak(t),r=t,i=jk;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&nA.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(tA,aA);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!tA.test(e)){let n=e.replace(eA,iA);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=Hk}return new i(r,t)}function iA(e){return`-`+e.toLowerCase()}function aA(e){return e.charAt(1).toUpperCase()}var oA=kk([Gk,Jk,Xk,Zk,Qk],`html`),sA=kk([Gk,Yk,Xk,Zk,Qk],`svg`);function cA(e){return e.join(` `).trim()}var lA=r(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
|
|
58
|
+
`),Xb=class{contentBinding;messageApi;threadApi;get path(){return this.contentBinding.path}constructor(e,t,n){this.contentBinding=e,this.messageApi=t,this.threadApi=n,this.__internal_bindMethods()}__internal_bindMethods(){this.addToolResult=this.addToolResult.bind(this),this.resumeToolCall=this.resumeToolCall.bind(this),this.respondToToolApproval=this.respondToToolApproval.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this.contentBinding.getState()}addToolResult(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);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.messageApi.getState();if(!n)throw Error(`Message is not available`);let r=t.toolName,i=t.toolCallId,a=Qy.toResponse(e);this.threadApi.getState().addToolResult({messageId:n.id,toolName:r,toolCallId:i,result:a.result,artifact:a.artifact,isError:a.isError})}resumeToolCall(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);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`);let n=t.toolCallId;this.threadApi.getState().resumeToolCall({toolCallId:n,payload:e})}respondToToolApproval(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to respond to tool approval on non-tool message part`);if(!t.approval||t.approval.approved!==void 0)throw Error(`Tool call has no pending approval`);if(!this.threadApi)throw Error(`Thread API is not available`);this.threadApi.getState().respondToToolApproval({approvalId:t.approval.id,approved:e.approved,...e.reason!=null&&{reason:e.reason}})}subscribe(e){return this.contentBinding.subscribe(e)}},Zb=Object.freeze({type:`complete`}),Qb=(e,t,n)=>{if(e.role!==`assistant`)return Zb;if(n.type===`tool-call`)return n.result?Zb:e.status;let r=t===Math.max(0,e.content.length-1);return e.status.type===`requires-action`?Zb:r?e.status:Zb},$b=(e,t)=>{let n=e.content[t];if(!n)return kb;let r=Qb(e,t,n);return Object.freeze({...n,[wb]:n[wb],status:r})},ex=class{_core;_threadBinding;get path(){return this._core.path}constructor(e,t){this._core=e,this._threadBinding=t,this.composer=new Jb(new Fb({path:{...this.path,ref:`${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.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)}composer;_getEditComposerRuntimeCore=()=>this._threadBinding.getState().getEditComposer(this._core.getState().id);getState(){return this._core.getState()}reload(e={}){let t=this._getEditComposerRuntimeCore(),n=t??this._threadBinding.getState().composer,r=t??n,{runConfig:i=r.runConfig}=e,a=this._core.getState();if(a.role!==`assistant`)throw Error(`Can only reload assistant messages`);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(){let e=this._core.getState();if(this._threadBinding.getState().speech?.messageId===e.id)this._threadBinding.getState().stopSpeaking();else throw Error(`Message is not being spoken`)}submitFeedback({type:e}){let t=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:t.id,type:e})}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 Yb(this.getState())}subscribe(e){return this._core.subscribe(e)}getMessagePartByIndex(e){if(e<0)throw Error(`Message part index must be >= 0`);return new Xb(new Nb({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.content[${e}]`,messagePartSelector:{type:`index`,index:e}},getState:()=>$b(this.getState(),e),subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getMessagePartByToolCallId(e){return new Xb(new Nb({path:{...this.path,ref: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?kb:$b(t,n)},subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getAttachmentByIndex(e){return new Vb(new Nb({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.attachments[${e}]`,attachmentSource:`message`,attachmentSelector:{type:`index`,index:e}},getState:()=>{let t=this.getState().attachments?.[e];return t?{...t,source:`message`}:kb},subscribe:e=>this._core.subscribe(e)}))}},tx=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{},...e.stream?{stream:e.stream}:{}}),nx=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{}}),rx=(e,t)=>typeof t==`string`?{createdAt:new Date,parentId:e.at(-1)?.id??null,sourceId:null,runConfig:{},role:`user`,content:[{type:`text`,text:t}],attachments:[],metadata:{custom:{}}}:{createdAt:t.createdAt??new Date,parentId:t.parentId??e.at(-1)?.id??null,sourceId:t.sourceId??null,role:t.role??`user`,content:t.content,attachments:t.attachments??[],metadata:t.metadata??{custom:{}},runConfig:t.runConfig??{},startRun:t.startRun},ix=(e,t)=>{let n=e.messages.at(-1);return Object.freeze({threadId:t.id,metadata:t,capabilities:e.capabilities,isDisabled:e.isDisabled,isLoading:e.isLoading,isRunning:e.isRunning??(n?.role===`assistant`?n.status.type===`running`:!1),messages:e.messages,state:e.state,suggestions:e.suggestions,extras:e.extras,speech:e.speech,voice:e.voice})},ax=class{get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}_threadBinding;constructor(e,t){let n=new Nb({path:e.path,getState:()=>ix(e.getState(),t.getState()),subscribe:n=>{let r=e.subscribe(n),i=t.subscribe(n);return()=>{r(),i()}}});this._threadBinding={path:e.path,getState:()=>e.getState(),getStateState:()=>n.getState(),outerSubscribe:t=>e.outerSubscribe(t),subscribe:t=>e.subscribe(t)},this.composer=new qb(new Fb({path:{...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.resumeRun=this.resumeRun.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.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)}composer;getState(){return this._threadBinding.getStateState()}append(e){this._threadBinding.getState().append(rx(this._threadBinding.getState().messages,e))}subscribe(e){return this._threadBinding.subscribe(e)}getModelContext(){return this._threadBinding.getState().getModelContext()}startRun(e){return this._threadBinding.getState().startRun(nx(e))}resumeRun(e){return this._threadBinding.getState().resumeRun(tx(e))}exportExternalState(){return this._threadBinding.getState().exportExternalState()}importExternalState(e){this._threadBinding.getState().importExternalState(e)}cancelRun(){this._threadBinding.getState().cancelRun()}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({...this.path,ref:`${this.path.ref}.messages[${e}]`,messageSelector:{type:`index`,index:e}},()=>{let t=this._threadBinding.getState().messages,n=t[e];if(n)return{message:n,parentId:t[e-1]?.id??null,index:e}})}getMessageById(e){return this._getMessageRuntime({...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 ex(new Nb({path:e,getState:()=>{let{message:e,parentId:n,index:r}=t()??{},{messages:i,speech:a}=this._threadBinding.getState();if(!e||n===void 0||r===void 0)return kb;let o=this._threadBinding.getState().getBranches(e.id);return{...e,[wb]:e[wb],index:r,isLast:i.at(-1)?.id===e.id,parentId:n,branchNumber:o.indexOf(e.id)+1,branchCount:o.length,speech:a?.messageId===e.id?a:void 0}},subscribe:e=>this._threadBinding.subscribe(e)}),this._threadBinding)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new Ib({event:e,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},ox=(0,_.createContext)(null),sx=()=>(0,_.useContext)(ox),cx=class{_core;_threadListBinding;get path(){return this._core.path}constructor(e,t){this._core=e,this._threadListBinding=t,this.__internal_bindMethods()}__internal_bindMethods(){this.switchTo=this.switchTo.bind(this),this.rename=this.rename.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)}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(){let e=this._core.getState();return this._threadListBinding.generateTitle(e.id)}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||t({})))})}subscribe(e){return this._core.subscribe(e)}detach(){let e=this._core.getState();this._threadListBinding.detach(e.id)}__internal_getRuntime(){return this}},lx=Promise.resolve(),ux=e=>({mainThreadId:e.mainThreadId,newThreadId:e.newThreadId,threadIds:e.threadIds,archivedThreadIds:e.archivedThreadIds,isLoading:e.isLoading,isLoadingMore:e.isLoadingMore??!1,hasMore:e.hasMore??!1,threadItems:e.threadItems}),dx=(e,t)=>{if(t===void 0)return kb;let n=e.getItemById(t);return n?{id:n.id,remoteId:n.remoteId,externalId:n.externalId,title:n.title,status:n.status,custom:n.custom,isMain:n.id===e.mainThreadId}:kb},fx=class{_core;_runtimeFactory;_getState;constructor(e,t=ax){this._core=e,this._runtimeFactory=t;let n=new Pb({path:{},getState:()=>ux(e),subscribe:t=>e.subscribe(t)});this._getState=n.getState.bind(n),this._mainThreadListItemRuntime=new cx(new Nb({path:{ref:`threadItems[main]`,threadSelector:{type:`main`}},getState:()=>dx(this._core,this._core.mainThreadId),subscribe:e=>this._core.subscribe(e)}),this._core),this.main=new t(new Fb({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.getLoadThreadsPromise=this.getLoadThreadsPromise.bind(this),this.reload=this.reload.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()}getLoadThreadsPromise(){return this._core.getLoadThreadsPromise()}reload(){return this._core.reload?.()??lx}loadMore(){return this._core.loadMore?.()??lx}getState(){return this._getState()}subscribe(e){return this._core.subscribe(e)}_mainThreadListItemRuntime;main;get mainItem(){return this._mainThreadListItemRuntime}getById(e){return new this._runtimeFactory(new Fb({path:{ref:`threads[threadId=${JSON.stringify(e)}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>this._core.getThreadRuntimeCore(e),subscribe:e=>this._core.subscribe(e)}),this.mainItem)}getItemByIndex(e){return new cx(new Nb({path:{ref:`threadItems[${e}]`,threadSelector:{type:`index`,index:e}},getState:()=>dx(this._core,this._core.threadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getArchivedItemByIndex(e){return new cx(new Nb({path:{ref:`archivedThreadItems[${e}]`,threadSelector:{type:`archiveIndex`,index:e}},getState:()=>dx(this._core,this._core.archivedThreadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getItemById(e){return new cx(new Nb({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>dx(this._core,e),subscribe:e=>this._core.subscribe(e)}),this._core)}},px=class{_core;threads;_thread;constructor(e){this._core=e,this.threads=new fx(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)}},mx=class{_contextProvider=new M_;registerModelContextProvider(e){return this._contextProvider.registerModelContextProvider(e)}getModelContextProvider(){return this._contextProvider}},hx=Object.freeze([]),gx=`DEFAULT_THREAD_ID`,_x=Object.freeze([gx]),vx=Object.freeze({id:gx,remoteId:void 0,externalId:void 0,status:`regular`}),yx=Promise.resolve(),bx=Object.freeze({[gx]:vx}),xx=class{threadFactory;_mainThreadId=gx;_threads=_x;_archivedThreads=hx;_threadData=bx;adapter={};get isLoading(){return this.adapter.isLoading??!1}get newThreadId(){}get threadIds(){return this._threads}get archivedThreadIds(){return this._archivedThreads}get threadItems(){return this._threadData}getLoadThreadsPromise(){return yx}_mainThread;get mainThreadId(){return this._mainThreadId}constructor(e={},t){this.threadFactory=t,this.__internal_setAdapter(e,!0)}getMainThreadRuntimeCore(){return this._mainThread}getThreadRuntimeCore(){throw Error(`Method not implemented.`)}getItemById(e){return this._threadData[e]}__internal_setAdapter(e,t=!1){let n=this.adapter;this.adapter=e;let r=e.threadId??gx,i=e.threads??hx,a=e.archivedThreads??hx,o=n.threadId??gx,s=n.threads??hx,c=n.archivedThreads??hx;!t&&o===r&&s===i&&c===a||((s!==i||c!==a||o!==r)&&(this._threadData={...bx,...Object.fromEntries(e.threads?.map(e=>[e.id,{...e,remoteId:e.remoteId,externalId:e.externalId,status:`regular`}])??[]),...Object.fromEntries(e.archivedThreads?.map(e=>[e.id,{...e,remoteId:e.remoteId,externalId:e.externalId,status:`archived`}])??[])}),s!==i&&(this._threads=this.adapter.threads?.map(e=>e.id)??hx),c!==a&&(this._archivedThreads=this.adapter.archivedThreads?.map(e=>e.id)??hx),(t||o!==r)&&(this._mainThreadId=r,this._mainThread=this.threadFactory()),this._threadData[this._mainThreadId]||(this._threadData={...this._threadData,[this._mainThreadId]:{id:this._mainThreadId,remoteId:void 0,externalId:void 0,status:`regular`}}),this._notifySubscribers())}async switchToThread(e,t){if(this._mainThreadId===e)return;let n=this.adapter.onSwitchToThread;if(!n)throw Error(`External store adapter does not support switching to thread`);await n(e)}async switchToNewThread(){let e=this.adapter.onSwitchToNewThread;if(!e)throw Error(`External store adapter does not support switching to new thread`);await e()}async rename(e,t){let n=this.adapter.onRename;if(!n)throw Error(`External store adapter does not support renaming`);await n(e,t)}async detach(){}async archive(e){let t=this.adapter.onArchive;if(!t)throw Error(`External store adapter does not support archiving`);await t(e)}async unarchive(e){let t=this.adapter.onUnarchive;if(!t)throw Error(`External store adapter does not support unarchiving`);await t(e)}async delete(e){let t=this.adapter.onDelete;if(!t)throw Error(`External store adapter does not support deleting`);await t(e)}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){throw Error(`Method not implemented.`)}_subscriptions=new Set;subscribe(e){return this._subscriptions.add(e),()=>this._subscriptions.delete(e)}_notifySubscribers(){for(let e of this._subscriptions)e()}},Sx=Ly(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7),Cx=Symbol(`autoStatus`),wx=Object.freeze(Object.assign({type:`running`},{[Cx]:!0})),Tx=Object.freeze(Object.assign({type:`complete`,reason:`unknown`},{[Cx]:!0})),Ex=Object.freeze(Object.assign({type:`requires-action`,reason:`tool-calls`},{[Cx]:!0})),Dx=Object.freeze(Object.assign({type:`requires-action`,reason:`interrupt`},{[Cx]:!0})),Ox=e=>e[Cx]===!0,kx=(e,t,n,r,i)=>e&&i?Object.assign({type:`incomplete`,reason:`error`,error:i},{[Cx]:!0}):e&&t?wx:n?Dx:r?Ex:Tx,Ax=(e,t)=>{if(e.startsWith(`data-`))return{type:`data`,name:e.substring(5),data:t}},jx=(e,t,n)=>{let{role:r,id:i,createdAt:a,attachments:o,status:s,metadata:c}=e,l={id:i??t,createdAt:a??new Date},u=typeof e.content==`string`?[{type:`text`,text:e.content}]:e.content,d=({image:e,...t})=>e.match(/^data:image\/(png|jpeg|jpg|gif|webp|svg\+xml);base64,(.*)$/)||/^(https:\/\/|blob:)/.test(e)?{...t,image:e}:(console.warn(`Invalid image data format detected`),null);if(r!==`user`&&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?.steps)throw Error(`metadata.steps is only supported for assistant messages`);switch(r){case`assistant`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:case`reasoning`:return e.text.trim().length===0?null:e;case`file`:case`source`:return e;case`image`:return d(e);case`data`:return e;case`generative-ui`:return e;case`tool-call`:{let{parentId:t,messages:n,...r}=e,i={...r,toolCallId:e.toolCallId??`tool-${Sx()}`,...t!==void 0&&{parentId:t},...n!==void 0&&{messages:n}};return e.args?{...i,args:e.args,argsText:e.argsText??JSON.stringify(e.args)}:{...i,args:Ky(e.argsText??``)??{},argsText:e.argsText??``}}default:{let n=Ax(t,e.data);if(n)return n;throw Error(`Unsupported assistant message part type: ${t}`)}}}).filter(e=>!!e),status:s??n,metadata:{unstable_state:c?.unstable_state??null,unstable_annotations:c?.unstable_annotations??[],unstable_data:c?.unstable_data??[],custom:c?.custom??{},steps:c?.steps??[],...c?.timing&&{timing:c.timing},...c?.submittedFeedback&&{submittedFeedback:c.submittedFeedback},...c?.isOptimistic&&{isOptimistic:!0}}};case`user`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:case`image`:case`audio`:case`file`:case`data`:return e;default:{let n=Ax(t,e.data);if(n)return n;throw Error(`Unsupported user message part type: ${t}`)}}}),attachments:(o??[]).map(e=>({...e,content:e.content.map(e=>Ax(e.type,e.data)??e)})),metadata:{custom:c?.custom??{}}};case`system`:if(u.length!==1||u[0].type!==`text`)throw Error(`System messages must have exactly one text message part.`);return{...l,role:r,content:u,metadata:{custom:c?.custom??{}}};default:throw Error(`Unknown message role: ${r}`)}},Mx={fromArray:e=>{let t=e.map(e=>jx(e,Sx(),kx(!1,!1,!1,!1,void 0)));return{messages:t.map((e,n)=>({parentId:n>0?t[n-1].id:null,message:e}))}},fromBranchableArray:(e,t)=>{let n=kx(!1,!1,!1,!1,void 0);return{...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:jx(e,e.id,n)}})}}},Nx=e=>e.next?Nx(e.next):`current`in e?e:null,Px=class{func;_value=null;constructor(e){this.func=e}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},Fx=class{messages=new Map;head=null;root={children:[],next:null};updateLevels(e,t){e.level=t;for(let n of e.children){let e=this.messages.get(n);e&&this.updateLevels(e,t+1)}}performOp(e,t,n){let r=t.prev??this.root,i=e??this.root;if(!(n===`relink`&&r===i)){if(n!==`link`&&(r.children=r.children.filter(e=>e!==t.current.id),r.next===t)){let e=r.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.`);r.next=t}if(n!==`cut`){for(let n=e;n;n=n.prev)if(n.current.id===t.current.id)throw Error(`MessageRepository(performOp/link): 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.`);i.children=[...i.children,t.current.id],(Nx(t)===this.head||i.next===null)&&(i.next=t),t.prev=e;let n=e?e.level+1:0;this.updateLevels(t,n)}}}_messages=new Px(()=>{let e=Array((this.head?.level??-1)+1);for(let t=this.head;t;t=t.prev)e[t.level]=t.current;return e});get headId(){return this.head?.current.id??null}getMessages(e){if(e===void 0||e===this.head?.current.id)return this._messages.value;let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.`);let n=Array(t.level+1);for(let e=t;e;e=e.prev)n[e.level]=e.current;return n}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){n.current=t,this.performOp(r,n,`relink`),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._messages.dirty()}getMessage(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.`);return{parentId:t.prev?.current.id??null,message:t.current,index:t.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 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=Nx(r??this.root)),this._messages.dirty()}getBranches(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.`);let{children:n}=t.prev??this.root;return n}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&&!n.has(t.current.id);t=t.prev)t.current.metadata?.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,r=t.prev??this.root;r.next=t,this.head=Nx(t),this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}resetHead(e){if(e===null){this.clear();return}let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.`);let n=this.head;if(t.children.length>0){let e=t=>{for(let n of t.children){let t=this.messages.get(n);t&&(e(t),this.messages.delete(n))}};e(t),t.children=[],t.next=null}this.head=t;for(let e=t;e;e=e.prev)e.prev?e.prev.next=e:this.root.next=e;this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){let e=[];for(let[,t]of this.messages)t.current.metadata?.isOptimistic||e.push({message:t.current,parentId:t.prev?.current.id??null});let t=this.head;for(;t?.current.metadata?.isOptimistic;)t=t.prev;return{headId:t?.current.id??null,messages:e}}import({headId:e,messages:t}){for(let{message:e,parentId:n}of t)this.addOrUpdateMessage(n,e);this.resetHead(e??t.at(-1)?.message.id??null)}};function Ix(e,t){if(t===`*`)return!0;let n=t.split(`,`).map(e=>e.trim().toLowerCase()),r=`.${e.name.split(`.`).pop().toLowerCase()}`,i=e.type.toLowerCase();for(let e of n){if(e.startsWith(`.`)&&e===r||e.includes(`/`)&&e===i)return!0;if(e.endsWith(`/*`)){let t=e.split(`/`)[0];if(i.startsWith(`${t}/`))return!0}}return!1}function Lx(e,t){return e.length===t.length?e.every((e,n)=>e.id===t[n].id):!1}function Rx(e){let t=Sx();return e.type===`image`?{id:t,type:`image`,name:e.filename??`image`,content:[e],status:{type:`complete`}}:e.type===`file`?{id:t,type:`document`,name:e.filename??`document`,contentType:e.mimeType,content:[e],status:{type:`complete`}}:e.type===`audio`?{id:t,type:`audio`,name:`audio.${e.audio.format}`,contentType:`audio/${e.audio.format}`,content:[e],status:{type:`complete`}}:{id:t,type:`data`,name:e.name,content:[e],status:{type:`complete`}}}function zx(e){let t=[];for(let n of e)n.type!==`text`&&t.push(Rx(n));return t}var Bx=e=>e.status.type===`complete`,Vx=class extends jb{isEditing=!0;get attachmentAccept(){return this.getAttachmentAdapter()?.accept??`*`}_attachments=[];get attachments(){return this._attachments}setAttachments(e){this._attachments=e,this._notifySubscribers()}get isEmpty(){return!this.text.trim()&&!this.attachments.length}_text=``;get text(){return this._text}_role=`user`;get role(){return this._role}_runConfig={};get runConfig(){return this._runConfig}_quote=void 0;get quote(){return this._quote}setQuote(e){this._quote!==e&&(this._quote=e,this._notifySubscribers())}setText(e){if(this._text!==e){if(this._text=e,this._dictation){this._dictationBaseText=e,this._currentInterimText=``;let{status:t,inputDisabled:n}=this._dictation;this._dictation=n?{status:t,inputDisabled:n}:{status:t}}this._notifySubscribers()}}setRole(e){this._role!==e&&(this._role=e,this._notifySubscribers())}setRunConfig(e){this._runConfig!==e&&(this._runConfig=e,this._notifySubscribers())}_emptyTextAndAttachments(){this._attachments=[],this._text=``,this._notifySubscribers()}async _onClearAttachments(){let e=this.getAttachmentAdapter();if(e){let t=this._attachments.filter(e=>!Bx(e));await Promise.all(t.map(t=>e.remove(t)))}}async reset(){if(this._attachments.length===0&&this._text===``&&this._role===`user`&&Object.keys(this._runConfig).length===0&&this._quote===void 0)return;this._role=`user`,this._runConfig={},this._quote=void 0;let e=this._onClearAttachments();this._emptyTextAndAttachments(),await e}async clearAttachments(){let e=this._onClearAttachments();this.setAttachments([]),await e}async send(e){if(!this.canSend)return;this._dictationSession&&(this._dictationSession.cancel(),this._cleanupDictation());let t=this.getAttachmentAdapter(),n=this.attachments.length>0?Promise.all(this.attachments.map(async e=>{if(Bx(e))return e;if(!t)throw Error(`Attachments are not supported`);return await t.send(e)})):[],r=this.text,i=this._quote;this._quote=void 0,this._emptyTextAndAttachments();let a={createdAt:new Date,role:this.role,content:r?[{type:`text`,text:r}]:[],attachments:await n,runConfig:this.runConfig,metadata:{custom:{...i?{quote:i}:{}}}};this.handleSend(a,e),this._notifyEventSubscribers(`send`,{})}cancel(){this.handleCancel()}async addAttachment(e){if(!(e instanceof File)){let t=this.getAttachmentAdapter();if(t&&!Ix({name:e.name,type:e.contentType??``},t.accept)){let n=`File type ${e.contentType||`unknown`} is not accepted. Accepted types: ${t.accept}`,r=Error(n);throw this._safeEmitAttachmentAddError(`not-accepted`,n,void 0,r),r}let n={id:e.id??Sx(),type:e.type??`document`,name:e.name,contentType:e.contentType,content:e.content,status:{type:`complete`}};this._attachments=[...this._attachments,n],this._notifySubscribers(),this._notifyEventSubscribers(`attachmentAdd`,{});return}let t=e=>{let t=this._attachments.findIndex(t=>t.id===e.id);t===-1?this._attachments=[...this._attachments,e]:this._attachments=[...this._attachments.slice(0,t),e,...this._attachments.slice(t+1)],this._notifySubscribers()},n=this.getAttachmentAdapter();if(!n){let e=`Attachments are not supported`,t=Error(e);throw this._safeEmitAttachmentAddError(`no-adapter`,e,void 0,t),t}if(!Ix({name:e.name,type:e.type},n.accept)){let t=`File type ${e.type||`unknown`} is not accepted. Accepted types: ${n.accept}`,r=Error(t);throw this._safeEmitAttachmentAddError(`not-accepted`,t,void 0,r),r}let r;try{let i=n.add({file:e});if(Symbol.asyncIterator in i)for await(let e of i)r=e,t(e);else r=await i,t(r)}catch(e){throw r&&t({...r,status:{type:`incomplete`,reason:`error`}}),this._safeEmitAttachmentAddError(`adapter-error`,e instanceof Error?e.message:String(e),r?.id,e instanceof Error?e:void 0),e}r?.status.type===`incomplete`&&r.status.reason===`error`?this._safeEmitAttachmentAddError(`adapter-error`,`Attachment upload did not complete successfully.`,r?.id):this._notifyEventSubscribers(`attachmentAdd`,{})}_safeEmitAttachmentAddError(e,t,n,r){try{this._notifyEventSubscribers(`attachmentAddError`,{reason:e,message:t,...n!==void 0&&{attachmentId:n},...r!==void 0&&{error:r}})}catch(e){console.error(`[assistant-ui] attachmentAddError subscriber threw:`,e)}}async removeAttachment(e){let t=this._attachments.findIndex(t=>t.id===e);if(t===-1)throw Error(`Attachment not found`);let n=this._attachments[t];if(!Bx(n)){let e=this.getAttachmentAdapter();if(!e)throw Error(`Attachments are not supported`);await e.remove(n)}this._attachments=this._attachments.filter(t=>t.id!==e),this._notifySubscribers()}_dictation;_dictationSession;_dictationUnsubscribes=[];_dictationBaseText=``;_currentInterimText=``;_dictationSessionIdCounter=0;_activeDictationSessionId;_isCleaningDictation=!1;get dictation(){return this._dictation}_isActiveSession(e,t){return this._activeDictationSessionId===e&&this._dictationSession===t}startDictation(){let e=this.getDictationAdapter();if(!e)throw Error(`Dictation adapter not configured`);if(this._dictationSession){for(let e of this._dictationUnsubscribes)e();this._dictationUnsubscribes=[],this._dictationSession.stop().catch(()=>{}),this._dictationSession=void 0}let t=e.disableInputDuringDictation??!1;this._dictationBaseText=this._text,this._currentInterimText=``;let n=e.listen();this._dictationSession=n;let r=++this._dictationSessionIdCounter;this._activeDictationSessionId=r,this._dictation={status:n.status,inputDisabled:t},this._notifySubscribers();let i=n.onSpeech(e=>{if(!this._isActiveSession(r,n))return;let t=e.isFinal!==!1,i=this._dictationBaseText&&!this._dictationBaseText.endsWith(` `)&&e.transcript?` `:``;if(t){if(this._dictationBaseText=this._dictationBaseText+i+e.transcript,this._currentInterimText=``,this._text=this._dictationBaseText,this._dictation){let{transcript:e,...t}=this._dictation;this._dictation=t}this._notifySubscribers()}else this._currentInterimText=i+e.transcript,this._text=this._dictationBaseText+this._currentInterimText,this._dictation&&={...this._dictation,transcript:e.transcript},this._notifySubscribers()});this._dictationUnsubscribes.push(i);let a=n.onSpeechStart(()=>{this._isActiveSession(r,n)&&(this._dictation={status:{type:`running`},inputDisabled:t,...this._dictation?.transcript&&{transcript:this._dictation.transcript}},this._notifySubscribers())});this._dictationUnsubscribes.push(a);let o=n.onSpeechEnd(()=>{this._cleanupDictation({sessionId:r})});this._dictationUnsubscribes.push(o);let s=setInterval(()=>{this._isActiveSession(r,n)&&n.status.type===`ended`&&this._cleanupDictation({sessionId:r})},100);this._dictationUnsubscribes.push(()=>clearInterval(s))}stopDictation(){if(!this._dictationSession)return;let e=this._dictationSession,t=this._activeDictationSessionId;e.stop().finally(()=>{this._cleanupDictation({sessionId:t})})}_cleanupDictation(e){if(!(e?.sessionId!==void 0&&e.sessionId!==this._activeDictationSessionId||this._isCleaningDictation)){this._isCleaningDictation=!0;try{for(let e of this._dictationUnsubscribes)e();this._dictationUnsubscribes=[],this._dictationSession=void 0,this._activeDictationSessionId=void 0,this._dictation=void 0,this._dictationBaseText=``,this._currentInterimText=``,this._notifySubscribers()}finally{this._isCleaningDictation=!1}}}_eventSubscribers=new Map;_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);if(n)for(let e of n)e(t)}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),()=>{this._eventSubscribers.get(e)?.delete(n)}}},Hx=class extends Vx{runtime;_canCancel=!1;get canCancel(){return this._canCancel}get canSend(){return!this.isEmpty&&!this.runtime.isSendDisabled}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}constructor(e){super(),this.runtime=e,this.connect()}connect(){let e=this.runtime.isSendDisabled;return this.runtime.subscribe(()=>{let t=!1;this.canCancel!==this.runtime.capabilities.cancel&&(this._canCancel=this.runtime.capabilities.cancel,t=!0),e!==this.runtime.isSendDisabled&&(e=this.runtime.isSendDisabled,t=!0),t&&this._notifySubscribers()})}async handleSend(e,t){this.runtime.append({...e,parentId:this.runtime.messages.at(-1)?.id??null,sourceId:null,startRun:t?.startRun})}async handleCancel(){this.runtime.cancelRun()}},Ux=class extends Vx{runtime;endEditCallback;get canCancel(){return!0}get canSend(){return!this.isEmpty}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}_previousText;_previousAttachments;_nonTextPassthrough;_parentId;_sourceId;constructor(e,t,{parentId:n,message:r}){super(),this.runtime=e,this.endEditCallback=t,this._parentId=n,this._sourceId=r.id,this._previousText=Yb(r),this.setText(this._previousText),this.setRole(r.role),r.role===`user`?(this._previousAttachments=[...r.attachments??[],...zx(r.content)],this._nonTextPassthrough=[]):(this._previousAttachments=r.attachments??[],this._nonTextPassthrough=r.content.filter(e=>e.type!==`text`)),this.setAttachments(this._previousAttachments),this.setRunConfig({...e.composer.runConfig})}get parentId(){return this._parentId}get sourceId(){return this._sourceId}async handleSend(e,t){let n=Yb(e),r=!Lx(e.attachments??[],this._previousAttachments);if(n!==this._previousText||r||t?.startRun){let n=this._nonTextPassthrough.length>0?[...e.content,...this._nonTextPassthrough]:e.content;this.runtime.append({...e,content:n,parentId:this._parentId,sourceId:this._sourceId,startRun:t?.startRun})}this.handleCancel()}handleCancel(){this.endEditCallback(),this._notifySubscribers()}},Wx=class{_contextProvider;_subscriptions=new Set;_isInitialized=!1;repository=new Fx;_voiceMessages=[];_voiceGeneration=0;_cachedMergedMessages=null;_cachedVoiceGeneration=-1;_cachedMergedBase=null;_markVoiceMessagesDirty(){this._voiceGeneration++,this._cachedMergedMessages=null}_getBaseMessages(){return this.repository.getMessages()}get messages(){if(this._voiceMessages.length===0)return this._getBaseMessages();let e=this._getBaseMessages();return(this._cachedVoiceGeneration!==this._voiceGeneration||this._cachedMergedBase!==e)&&(this._cachedMergedMessages=[...e,...this._voiceMessages],this._cachedVoiceGeneration=this._voiceGeneration,this._cachedMergedBase=e),this._cachedMergedMessages}get state(){let e;for(let t of this.messages)t.role===`assistant`&&(e=t);return e?.metadata.unstable_state??null}composer=new Hx(this);constructor(e){this._contextProvider=e}getModelContext(){return this._contextProvider.getModelContext()}_editComposers=new Map;getEditComposer(e){return this._editComposers.get(e)}beginEdit(e){if(this._editComposers.has(e))throw Error(`Edit already in progress`);this._editComposers.set(e,new Ux(this,()=>this._editComposers.delete(e),this.repository.getMessage(e))),this._notifySubscribers()}getMessageById(e){try{return this.repository.getMessage(e)}catch{let t=this.repository.getMessages(),n=this._voiceMessages.findIndex(t=>t.id===e);return n===-1?void 0:{parentId:n>0?this._voiceMessages[n-1].id:t.at(-1)?.id??null,message:this._voiceMessages[n],index:t.length+n}}}getBranches(e){return this._voiceMessages.some(t=>t.id===e)?[]:this.repository.getBranches(e)}switchToBranch(e){this.repository.switchToBranch(e),this._notifySubscribers()}_notifySubscribers(){for(let e of this._subscriptions)e()}_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);if(n)for(let e of n)e(t)}subscribe(e){return this._subscriptions.add(e),()=>this._subscriptions.delete(e)}submitFeedback({messageId:e,type:t}){let n=this.adapters?.feedback;if(!n)throw Error(`Feedback adapter not configured`);let{message:r,parentId:i}=this.repository.getMessage(e);if(n.submit({message:r,type:t}),r.role===`assistant`){let e={...r,metadata:{...r.metadata,submittedFeedback:{type:t}}};this.repository.addOrUpdateMessage(i,e)}this._notifySubscribers()}_stopSpeaking;speech;speak(e){let t=this.adapters?.speech;if(!t)throw Error(`Speech adapter not configured`);let{message:n}=this.repository.getMessage(e);this._stopSpeaking?.();let r=t.speak(Yb(n)),i=r.subscribe(()=>{r.status.type===`ended`?(this._stopSpeaking=void 0,this.speech=void 0):this.speech={messageId:e,status:r.status},this._notifySubscribers()});this.speech={messageId:e,status:r.status},this._notifySubscribers(),this._stopSpeaking=()=>{r.cancel(),i(),this.speech=void 0,this._stopSpeaking=void 0}}stopSpeaking(){if(!this._stopSpeaking)throw Error(`No message is being spoken`);this._stopSpeaking(),this._notifySubscribers()}_voiceSession;_voiceUnsubs=[];voice;_voiceVolume=0;_voiceVolumeSubscribers=new Set;getVoiceVolume=()=>this._voiceVolume;subscribeVoiceVolume=e=>(this._voiceVolumeSubscribers.add(e),()=>this._voiceVolumeSubscribers.delete(e));connectVoice(){let e=this.adapters?.voice;if(!e)throw Error(`Voice adapter not configured`);this.disconnectVoice();let t=e.connect({});this._voiceSession=t;let n=[],r=`listening`;this.voice={status:t.status,isMuted:t.isMuted,mode:r},this._voiceVolume=0,this._notifySubscribers(),n.push(t.onStatusChange(e=>{e.type===`ended`?(this._finishVoiceAssistantMessage(),this._voiceSession=void 0,this.voice=void 0):this.voice={status:e,isMuted:t.isMuted,mode:r},this._notifySubscribers()})),n.push(t.onModeChange(e=>{r=e,this.voice&&(this.voice={...this.voice,mode:e},this._notifySubscribers())})),n.push(t.onVolumeChange(e=>{this._voiceVolume=e;for(let e of this._voiceVolumeSubscribers)e()})),n.push(t.onTranscript(e=>{this._handleVoiceTranscript(e)})),this._voiceUnsubs=n}_currentAssistantMsg=null;_handleVoiceTranscript(e){if(this.ensureInitialized(),e.role===`user`)this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null,e.isFinal&&(this._voiceMessages.push({id:Sx(),role:`user`,content:[{type:`text`,text:e.text}],metadata:{custom:{}},createdAt:new Date,status:{type:`complete`,reason:`unknown`},attachments:[]}),this._markVoiceMessagesDirty(),this._notifySubscribers());else{if(!this._currentAssistantMsg)this._currentAssistantMsg={id:Sx(),role:`assistant`,content:[{type:`text`,text:e.text}],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],custom:{}},status:{type:`running`},createdAt:new Date},this._voiceMessages.push(this._currentAssistantMsg);else{let t=this._voiceMessages.indexOf(this._currentAssistantMsg);if(t===-1)return;let n={...this._currentAssistantMsg,content:[{type:`text`,text:e.text}],...e.isFinal?{status:{type:`complete`,reason:`stop`}}:{}};this._voiceMessages[t]=n,this._currentAssistantMsg=n}e.isFinal&&(this._currentAssistantMsg=null),this._markVoiceMessagesDirty(),this._notifySubscribers()}}_finishVoiceAssistantMessage(){let e=this._voiceMessages.at(-1);if(e?.role===`assistant`&&e.status.type===`running`){let t=this._voiceMessages.length-1;this._voiceMessages[t]={...e,status:{type:`complete`,reason:`stop`}},this._markVoiceMessagesDirty(),this._notifySubscribers()}}disconnectVoice(){this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null;for(let e of this._voiceUnsubs)e();this._voiceUnsubs=[],this._voiceSession?.disconnect(),this._voiceSession=void 0,this.voice=void 0,this._voiceVolume=0;for(let e of this._voiceVolumeSubscribers)e();this._voiceMessages=[],this._markVoiceMessagesDirty(),this._notifySubscribers()}muteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.mute(),this.voice={...this.voice,isMuted:!0},this._notifySubscribers()}unmuteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.unmute(),this.voice={...this.voice,isMuted:!1},this._notifySubscribers()}ensureInitialized(){this._isInitialized||(this._isInitialized=!0,this._notifyEventSubscribers(`initialize`,{}))}export(){return this.repository.export()}import(e){this.ensureInitialized(),this.repository.clear(),this.repository.import(e),this._notifySubscribers()}reset(e){this.import(Mx.fromArray(e??[]))}_eventSubscribers=new Map;unstable_on(e,t){let n=t;if(e===`modelContextUpdate`)return this._contextProvider.subscribe?.(()=>n({}))??(()=>{});let r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),e===`initialize`&&this._isInitialized&&queueMicrotask(()=>{r.has(n)&&n({})}),()=>{this._eventSubscribers.get(e)?.delete(n)}}},Gx=class{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})}};function Kx(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function qx(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=>qx(e,t+1)):Kx(e)?Object.entries(e).every(([e,n])=>typeof e==`string`&&qx(n,t+1)):!1}var Jx=100,Yx=(e,t,n)=>{if(e===t)return!0;if(n>Jx||e==null||t==null)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.every((e,r)=>Yx(e,t[r],n+1));if(Array.isArray(t)||!Kx(e)||!Kx(t))return!1;let r=Object.keys(e),i=Object.keys(t);return r.length===i.length?r.every(r=>Object.hasOwn(t,r)&&Yx(e[r],t[r],n+1)):!1},Xx=(e,t)=>!qx(e)||!qx(t)?!1:Yx(e,t,0),Zx=e=>{try{return JSON.parse(e),!0}catch{return!1}},Qx=e=>{try{return JSON.parse(e)}catch{return}},$x=(e,t)=>{let n=Qx(e),r=Qx(t);return n===void 0||r===void 0?!1:Xx(n,r)},eS=class{_getTools;_callbacks;_entries=new Map;_skipExecuteStreamIds=new Set;_humanInput=new Map;_executing=new Set;_settledResolvers=[];_statuses=new Map;_ac=new AbortController;_pendingRestore=!0;_lastSnapshot=null;_isRunning=!1;_controller;_pipelineDead=!1;_pipelineRestartUsed=!1;constructor(e,t){this._getTools=e,this._callbacks=t,this._initPipeline()}_initPipeline(){let[e,t]=Vy();this._controller=t;let n=fb(()=>this._getWrappedTools(),()=>this._ac.signal,(e,t)=>this._onHumanInput(e,t),{onExecutionStart:e=>this._onExecutionStart(e),onExecutionEnd:e=>this._onExecutionEnd(e)});e.pipeThrough(n).pipeThrough(new Iy).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,this._demoteEntriesToRestored(),this._executing.clear(),this._ac=new AbortController,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)}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._lastSnapshot=null,this.abort().finally(()=>{this._executing.clear()})}catch(e){console.error(`[ToolInvocationTracker] reset failed`,e)}}abort(){try{return this._humanInput.forEach(({reject:e})=>{try{e(Error(`Tool execution aborted`))}catch{}}),this._humanInput.clear(),this._ac.abort(),this._ac=new AbortController,this._executing.size===0?Promise.resolve():new Promise(e=>{this._settledResolvers.push(e)})}catch(e){return console.error(`[ToolInvocationTracker] abort failed`,e),Promise.resolve()}}resume(e,t){try{let n=this._humanInput.get(e);return n?(this._humanInput.delete(e),this._setStatus(e,{type:`executing`}),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;return n===void 0?[e,t]:[e,{...t,execute:(...[e,t])=>this._skipExecuteStreamIds.has(t.toolCallId)?new Promise(()=>{}):n(e,t)}]}))}_onHumanInput(e,t){return new Promise((n,r)=>{let i=this._humanInput.get(e);if(i)try{i.reject(Error(`Human input request was superseded by a new request`))}catch{}this._humanInput.set(e,{resolve:n,reject:r}),this._setStatus(e,{type:`interrupt`,payload:{type:`human`,payload:t}})})}_onExecutionStart(e){this._skipExecuteStreamIds.has(e)||(this._executing.add(e),this._setStatus(e,{type:`executing`}))}_onExecutionEnd(e){this._executing.delete(e)&&(this._deleteStatus(e),this._executing.size===0&&this._settledResolvers.splice(0).forEach(e=>{try{e()}catch{}}))}_handleResultChunk(e){let t=e.meta.toolCallId,n=this._entries.get(t);!n&&this._skipExecuteStreamIds.has(t)||n?.hasResult||this._invokeOnResult({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()}_hasExecutableTool(e){let t=this._getTools()?.[e];return t?.execute!==void 0||t?.streamCall!==void 0}_shouldCloseArgsStream({toolName:e,argsText:t,hasResult:n}){return n?!0:(this._hasExecutableTool(e)||!this._isRunning)&&Zx(t)}_startActiveEntry(e,t,n){let r=this._controller.addToolCallPart({toolName:t,toolCallId:e});n&&this._skipExecuteStreamIds.add(e);let i={toolName:t,controller:r,argsText:``,hasResult:!1,argsComplete:!1};return this._entries.set(e,i),i}_demoteEntriesToRestored(){for(let[e,t]of this._entries)t.controller&&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)$x(e.argsText,t.argsText)&&(e.argsText=t.argsText),r=!1;else if(!t.argsText.startsWith(e.argsText))if(Zx(e.argsText)&&Zx(t.argsText)&&$x(e.argsText,t.argsText)){let i=this._shouldCloseArgsStream({toolName:t.toolName,argsText:t.argsText,hasResult:n});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i,r=!1}else r=!1;if(r&&e.controller){let r=t.argsText.slice(e.argsText.length);e.controller.argsText.append(r);let i=this._shouldCloseArgsStream({toolName:t.toolName,argsText:t.argsText,hasResult:n});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i}}!e.argsComplete&&e.controller&&this._shouldCloseArgsStream({toolName:t.toolName,argsText:t.argsText,hasResult:n})&&(e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=!0)}_processMessages(e){let t=this._pendingRestore;for(let n of e)if(!(!n||!Array.isArray(n.content)))for(let e of n.content){if(!e||e.type!==`tool-call`)continue;let n=this._entries.get(e.toolCallId);if(t){n?.controller||this._entries.set(e.toolCallId,{toolName:e.toolName,argsText:e.argsText,hasResult:e.result!==void 0}),e.messages&&this._processMessages(e.messages);continue}let r=n;if(r&&!r.controller){if(!(e.argsText!==r.argsText||e.result!==void 0!==r.hasResult)){e.messages&&this._processMessages(e.messages);continue}this._entries.delete(e.toolCallId),r=void 0}if(r||=this._startActiveEntry(e.toolCallId,e.toolName,e.result!==void 0),this._processArgsText(r,e),e.result!==void 0&&!r.hasResult){let{controller:t}=r;if(!t)continue;r.hasResult=!0,r.argsComplete=!0,t.setResponse(new Qy({result:e.result,artifact:e.artifact,isError:e.isError,...e.modelContent===void 0?{}:{modelContent:e.modelContent}})),t.close()}e.messages&&this._processMessages(e.messages)}}},tS=Object.freeze([]),nS=(e,t)=>{let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0},rS=(e,t)=>e&&t[t.length-1]?.role!==`assistant`,iS=class extends Wx{_capabilities={switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,reload:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1};get capabilities(){return this._capabilities}_messages;isDisabled;isSendDisabled;get isLoading(){return this._store.isLoading??!1}get isRunning(){return this._store.isRunning}_getBaseMessages(){return this._messages}get state(){return this._store.state??super.state}get adapters(){return this._store.adapters}suggestions=[];extras=void 0;_converter=new Gx;_store;_toolInvocations=null;beginEdit(e){if(!this._store.onEdit)throw Error(`Runtime does not support editing.`);super.beginEdit(e)}constructor(e,t){super(e),this.__internal_setAdapter(t)}__internal_setAdapter(e){if(this._store===e)return;let t=e.isRunning??!1;this.isDisabled=e.isDisabled??!1,this.isSendDisabled=e.isSendDisabled??!1;let n=this._store;this._store=e,this.extras!==e.extras&&(this.extras=e.extras);let r=e.suggestions??tS;nS(this.suggestions,r)||(this.suggestions=r);let i={switchToBranch:this._store.setMessages!==void 0,switchBranchDuringRun:!1,edit:this._store.onEdit!==void 0,reload:this._store.onReload!==void 0,cancel:this._store.onCancel!==void 0,speech:this._store.adapters?.speech!==void 0,dictation:this._store.adapters?.dictation!==void 0,voice:this._store.adapters?.voice!==void 0,unstable_copy:this._store.unstable_capabilities?.copy!==!1,attachments:!!this._store.adapters?.attachments,feedback:!!this._store.adapters?.feedback,queue:!1};nS(this._capabilities,i)||(this._capabilities=i);let a;if(e.messageRepository){if(n&&n.isRunning===e.isRunning&&n.messageRepository===e.messageRepository){this._notifySubscribers();return}this.repository.clear(),this.repository.import(e.messageRepository),a=this.repository.getMessages()}else if(e.messages){if(n){if(n.convertMessage!==e.convertMessage)this._converter=new Gx;else if(n.isRunning===e.isRunning&&n.messages===e.messages){this._notifySubscribers();return}}a=e.convertMessage?this._converter.convertMessages(e.messages,(n,r,i)=>{if(!e.convertMessage)return r;let a=kx(i===(e.messages?.length??0)-1,t,!1,!1,void 0);if(n&&(n.role!==`assistant`||!Ox(n.status)||n.status===a))return n;let o=jx(e.convertMessage(r,i),i.toString(),a);return Db(o,r),o}):e.messages;for(let e=0;e<a.length;e++){let t=a[e],n=a[e-1];this.repository.addOrUpdateMessage(n?.id??null,t)}}else throw Error(`ExternalStoreAdapter must provide either 'messages' or 'messageRepository'`);a.length>0&&this.ensureInitialized(),(n?.isRunning??!1)!==(e.isRunning??!1)&&(e.isRunning?this._notifyEventSubscribers(`runStart`,{}):this._notifyEventSubscribers(`runEnd`,{}));let o=null;rS(t,a)&&(o=Sx(),this.repository.addOrUpdateMessage(a.at(-1)?.id??null,jx({role:`assistant`,content:[],metadata:{isOptimistic:!0}},o,{type:`running`}))),this.repository.resetHead(o??a.at(-1)?.id??null),this._messages=this.repository.getMessages(),this._driveToolInvocations(),this._notifySubscribers()}_driveToolInvocations(){if(!this._store.unstable_enableToolInvocations){this._toolInvocations&&(this._toolInvocations.reset(),this._toolInvocations=null,this._store.setToolStatuses?.({}));return}this._toolInvocations||=new eS(()=>this.getModelContext().tools,{onResult:e=>{try{let t=this._findMessageIdForToolCall(e.toolCallId);if(t===void 0)return;this._store.onAddToolResult?.({messageId:t,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)}},onStatusesChange:e=>{this._store.setToolStatuses?.(Object.fromEntries(e))}}),this._toolInvocations.setState({messages:this._messages,isRunning:this._store.isRunning??!1,...this._store.isLoading!==void 0&&{isLoading:this._store.isLoading}})}_toolCallToMessageId=new Map;_messagesForToolCallIndex=null;_findMessageIdForToolCall(e){if(this._messagesForToolCallIndex!==this._messages){this._toolCallToMessageId.clear();let e=t=>{for(let n of t)if(Array.isArray(n.content))for(let t of n.content)!t||t.type!==`tool-call`||(this._toolCallToMessageId.set(t.toolCallId,n.id),t.messages&&e(t.messages))};e(this._messages),this._messagesForToolCallIndex=this._messages}return this._toolCallToMessageId.get(e)}switchToBranch(e){if(!this._store.setMessages)throw Error(`Runtime does not support switching branches.`);this._store.isRunning||(this.repository.switchToBranch(e),this.updateMessages(this.repository.getMessages()))}async append(e){if((e.startRun??e.role===`user`)&&await this._toolInvocations?.abort(),e.parentId!==(this.messages.at(-1)?.id??null)){if(!this._store.onEdit)throw Error(`Runtime does not support editing messages.`);await this._store.onEdit(e)}else await this._store.onNew(e)}async startRun(e){if(!this._store.onReload)throw Error(`Runtime does not support reloading messages.`);await this._toolInvocations?.abort(),await this._store.onReload(e.parentId,e)}async resumeRun(e){if(!this._store.onResume)throw Error(`Runtime does not support resuming runs.`);await this._store.onResume(e)}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._toolInvocations&&(this._toolInvocations.reset(),this._store.setToolStatuses?.({})),this._store.onLoadExternalState(e)}cancelRun(){if(!this._store.onCancel)throw Error(`Runtime does not support cancelling runs.`);this._toolInvocations?.abort(),this._store.onCancel();let e=this.repository.getMessages().at(-1);e&&e.metadata.isOptimistic&&e.content.length===0&&this.repository.deleteMessage(e.id);let t=this.repository.getMessages(),n=t[t.length-1];n?.role===`user`&&n.id===t.at(-1)?.id?(this.repository.deleteMessage(n.id),this.composer.text.trim()||this.composer.setText(Yb(n)),t=this.repository.getMessages()):this._notifySubscribers(),setTimeout(()=>{this.updateMessages(t)},0)}addToolResult(e){if(!this._store.onAddToolResult)throw Error(`Runtime does not support tool results.`);this._store.onAddToolResult?.(e)}resumeToolCall(e){if(!(this._toolInvocations?.resume(e.toolCallId,e.payload)??!1)){if(this._store.onResumeToolCall){this._store.onResumeToolCall(e);return}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.`);this._store.onRespondToToolApproval(e)}reset(e){let t=new Fx;t.import(Mx.fromArray(e??[])),this.updateMessages(t.getMessages())}import(e){super.import(e),this._store.onImport&&this._store.onImport(this.repository.getMessages())}updateMessages=e=>{this._store.convertMessage===void 0?this._store.setMessages?.(e):this._store.setMessages?.(e.flatMap(Ob))}},aS=e=>e.adapters?.threadList??{},oS=class extends mx{threads;constructor(e){super(),this.threads=new xx(aS(e),()=>new iS(this._contextProvider,e))}setAdapter(e){this.threads.__internal_setAdapter(aS(e)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(e)}},sS=e=>{let[t]=(0,_.useState)(()=>new oS(e));(0,_.useEffect)(()=>{t.setAdapter(e)});let{modelContext:n}=sx()??{};return(0,_.useEffect)(()=>{if(n)return t.registerModelContextProvider(n)},[n,t]),(0,_.useMemo)(()=>new px(t),[t])},cS=(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,lS=()=>null,uS=(e,t,n)=>{switch(t){case`user`:return n?e.UserEditComposer??e.EditComposer??e.UserMessage??e.Message:e.UserMessage??e.Message;case`assistant`:return n?e.AssistantEditComposer??e.EditComposer??e.AssistantMessage??e.Message:e.AssistantMessage??e.Message;case`system`:return n?e.SystemEditComposer??e.EditComposer??e.SystemMessage??e.Message:e.SystemMessage??e.Message??lS;default:throw Error(`Unknown message role: ${t}`)}},dS=({components:e})=>(0,G.jsx)(uS(e,Z(e=>e.message.role),Z(e=>e.message.composer.isEditing)),{}),fS=(0,_.memo)(({index:e,components:t})=>(0,G.jsx)(hb,{index:e,children:(0,G.jsx)(dS,{components:t})}),(e,t)=>e.index===t.index&&cS(e.components,t.components));fS.displayName=`ThreadPrimitive.MessageByIndex`;var pS=({children:e})=>{let t=Z(e=>e.thread.messages.length);return(0,_.useMemo)(()=>t===0?null:Array.from({length:t},(t,n)=>(0,G.jsx)(hb,{index:n,children:(0,G.jsx)(Hv,{getItemState:e=>e.thread().message({index:n}).getState(),children:t=>e({get message(){return t()}})})},n)),[t,e])},mS=({components:e,children:t})=>e?(0,G.jsx)(pS,{children:()=>(0,G.jsx)(dS,{components:e})}):(0,G.jsx)(pS,{children:t});mS.displayName=`ThreadPrimitive.Messages`;var hS=(0,_.memo)(mS,(e,t)=>e.children||t.children?e.children===t.children:cS(e.components,t.components)),gS=e=>{let t=e.message.metadata;if(!(!t||typeof t!=`object`))return t.custom?.quote},_S=class extends Error{componentName;constructor(e,t=`Component "${e}" is not in the generative-ui allowlist.`){super(t),this.name=`GenerativeUIRenderError`,this.componentName=e}},vS=e=>typeof e==`object`&&!!e,yS=(e,t,n,r)=>{if(e==null)return null;if(typeof e==`string`)return e;if(!vS(e)||!(`component`in e))return null;let{component:i,props:a,children:o,key:s}=e,c=t[i];if(!c){if(n)return(0,G.jsx)(n,{component:i,props:a},s??r);throw new _S(i)}let l=o?.length?o.map((e,i)=>yS(e,t,n,`${r}/${i}`)):void 0;return(0,_.createElement)(c,{...a??{},key:s??r},...l??[])},bS=e=>{if(!e||e.root===void 0||e.root===null)return[];let t=e.root;return Array.isArray(t)?t:[t]},xS=({spec:e,components:t,Fallback:n})=>(0,G.jsx)(G.Fragment,{children:(0,_.useMemo)(()=>bS(e),[e]).map((e,r)=>yS(e,t,n,`${r}`))});xS.displayName=`GenerativeUIRender`;var SS=({components:e,spec:t,Fallback:n})=>{let r=Z(e=>{let t=e.part;return t?.type===`generative-ui`?t.spec:void 0}),i=t??r;return i?(0,G.jsx)(xS,{spec:i,components:e,Fallback:n}):null};SS.displayName=`MessagePrimitive.GenerativeUI`;var CS=`ui://`,wS=e=>!!e?.startsWith(CS),TS=e=>Symbol.iterator in e,ES=e=>`entries`in e,DS=(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},OS=(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 kS(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:TS(e)&&TS(t)?ES(e)&&ES(t)?DS(e,t):OS(e,t):DS({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function AS(e){let t=_.useRef(void 0);return n=>{let r=e(n);return kS(t.current,r)?t.current:t.current=r}}var jS=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})}}},MS=(e,t)=>{let n=[];if(t){let t=jS(`chainOfThoughtGroup`);for(let r=0;r<e.length;r++){let i=e[r];i===`tool-call`||i===`reasoning`?t.startGroup(r):(t.endGroup(r-1,n),n.push({type:`single`,index:r}))}t.finalize(e.length-1,n)}else{let t=jS(`toolGroup`),r=jS(`reasoningGroup`);for(let i=0;i<e.length;i++){let a=e[i];a===`tool-call`?(r.endGroup(i-1,n),t.startGroup(i)):a===`reasoning`?(t.endGroup(i-1,n),r.startGroup(i)):(t.endGroup(i-1,n),r.endGroup(i-1,n),n.push({type:`single`,index:i}))}t.finalize(e.length-1,n),r.finalize(e.length-1,n)}return n},NS=e=>{let t=Z(AS(e=>e.message.parts.map(e=>e.type)));return(0,_.useMemo)(()=>t.length===0?[]:MS(t,e),[t,e])},PS=({Fallback:e,...t})=>{let n=Z(n=>n.tools.toolUIs[t.toolName]?.[0]?.render??e);return n?(0,G.jsx)(n,{...t}):null},FS=(e,t,n)=>e.renderers[t]?.[0]||(e.fallbacks[0]??n),IS=({Fallback:e,...t})=>{let n=Z(n=>FS(n.dataRenderers,t.name,e));return n?(0,G.jsx)(n,{...t}):null},LS={Text:()=>null,Reasoning:()=>null,Source:()=>null,Image:()=>null,File:()=>null,Unstable_Audio:()=>null,ToolGroup:({children:e})=>e,ReasoningGroup:({children:e})=>e},RS=({components:{Text:e=LS.Text,Reasoning:t=LS.Reasoning,Image:n=LS.Image,Source:r=LS.Source,File:i=LS.File,Unstable_Audio:a=LS.Unstable_Audio,tools:o={},data:s,generativeUI:c}={}})=>{let l=Rv(),u=Z(e=>e.part),d=u.type;if(d===`tool-call`){let e=l.part().addToolResult,t=l.part().resumeToolCall,n=l.part().respondToToolApproval;if(`Override`in o)return(0,G.jsx)(o.Override,{...u,addResult:e,resume:t,respondToApproval:n});let r=o.by_name?.[u.toolName]??o.Fallback;return(0,G.jsx)(PS,{...u,Fallback:r,addResult:e,resume:t,respondToApproval:n})}if(u.status?.type===`requires-action`)throw Error(`Encountered unexpected requires-action status`);switch(d){case`text`:return(0,G.jsx)(e,{...u});case`reasoning`:return(0,G.jsx)(t,{...u});case`source`:return(0,G.jsx)(r,{...u});case`image`:return(0,G.jsx)(n,{...u});case`file`:return(0,G.jsx)(i,{...u});case`audio`:return(0,G.jsx)(a,{...u});case`data`:{let e=s?.by_name?.[u.name]??s?.Fallback;return(0,G.jsx)(IS,{...u,Fallback:e})}case`generative-ui`:return c?.components?(0,G.jsx)(xS,{spec:u.spec,components:c.components,Fallback:c.Fallback}):null;default:return console.warn(`Unknown message part type: ${d}`),null}},zS=(0,_.memo)(({index:e,components:t})=>(0,G.jsx)(gb,{index:e,children:(0,G.jsx)(RS,{components:t})}),(e,t)=>e.index===t.index&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.generativeUI===t.components?.generativeUI&&e.components?.ToolGroup===t.components?.ToolGroup&&e.components?.ReasoningGroup===t.components?.ReasoningGroup);zS.displayName=`MessagePrimitive.PartByIndex`;var BS=({status:e,component:t})=>(0,G.jsx)(vb,{text:``,isRunning:e.type===`running`,children:(0,G.jsx)(t,{type:`text`,text:``,status:e})}),VS=Object.freeze({type:`complete`}),HS=Object.freeze({type:`running`}),US=(0,_.memo)(({components:e})=>{let t=Z(e=>e.message.status??VS);return e?.Empty?(0,G.jsx)(e.Empty,{status:t}):t.type===`running`?(0,G.jsx)(BS,{status:t,component:e?.Text??LS.Text}):null},(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),WS=(0,_.memo)(({components:e,enabled:t})=>Z(e=>{if(!t||e.message.parts.length===0)return!1;let n=e.message.parts[e.message.parts.length-1];return n?.type!==`text`&&n?.type!==`reasoning`})?(0,G.jsx)(US,{components:e}):null,(e,t)=>e.enabled===t.enabled&&e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),GS=(0,_.memo)(({Quote:e})=>{let t=Z(gS);return t?(0,G.jsx)(e,{text:t.text,messageId:t.messageId}):null});function KS(e,t){return(e.toolUIs[t.toolName]?.[0]?.render??null)||(wS(t.mcp?.app?.resourceUri)&&e.mcpApp?e.mcpApp.render:null)}var qS=()=>{let e=Rv(),t=Z(e=>e.part),n=Z(e=>e.part.type===`tool-call`?KS(e.tools,e.part):null);return!n||t.type!==`tool-call`?null:(0,G.jsx)(n,{...t,addResult:e.part().addToolResult,resume:e.part().resumeToolCall,respondToApproval:e.part().respondToToolApproval})},JS=()=>{let e=Z(e=>e.part),t=Z(e=>e.part.type===`data`?FS(e.dataRenderers,e.part.name,void 0)??null:null);return!t||e.type!==`data`?null:(0,G.jsx)(t,{...e})},YS=()=>{let e=Z(e=>e.part.type);return e===`tool-call`?(0,G.jsx)(qS,{}):e===`data`?(0,G.jsx)(JS,{}):null},XS=Object.freeze({type:`text`,text:``,status:HS}),ZS=({index:e,children:t})=>{let n=Rv(),r=Z(e=>e.dataRenderers);return(0,G.jsx)(gb,{index:e,children:(0,G.jsx)(Hv,{getItemState:t=>t.message().part({index:e}).getState(),children:i=>t({get part(){let t=i();if(t.type===`tool-call`){let r=KS(n.tools().getState(),t)!==null,i=n.message().part({index:e});return{...t,toolUI:r?(0,G.jsx)(qS,{}):null,addResult:i.addToolResult,resume:i.resumeToolCall,respondToApproval:i.respondToToolApproval}}if(t.type===`data`){let e=FS(r,t.name,void 0)!==void 0;return{...t,dataRendererUI:e?(0,G.jsx)(JS,{}):null}}return t}})})})},QS=({children:e})=>{let t=Z(e=>e.message.parts.length),n=Z(e=>(e.message.status?.type??`complete`)===`running`);return t===0?t===0&&n?(0,G.jsx)(vb,{text:``,isRunning:!0,children:e({part:XS})}):null:(0,G.jsx)(G.Fragment,{children:Array.from({length:t},(t,n)=>(0,G.jsx)(ZS,{index:n,children:t=>e(t)??(0,G.jsx)(YS,{})},n))})},$S=({components:e,unstable_showEmptyOnNonTextEnd:t=!0,children:n})=>n?(0,G.jsx)(QS,{children:n}):(0,G.jsx)(eC,{components:e,unstable_showEmptyOnNonTextEnd:t});$S.displayName=`MessagePrimitive.Parts`;var eC=({components:e,unstable_showEmptyOnNonTextEnd:t})=>{let n=Z(e=>e.message.parts.length),r=NS(!!e?.ChainOfThought),i=(0,_.useMemo)(()=>n===0?(0,G.jsx)(US,{components:e}):r.map(t=>{if(t.type===`single`)return(0,G.jsx)(zS,{index:t.index,components:e},t.index);if(t.type===`chainOfThoughtGroup`){let n=e?.ChainOfThought;return n?(0,G.jsx)(xb,{startIndex:t.startIndex,endIndex:t.endIndex,children:(0,G.jsx)(n,{})},`chainOfThought-${t.startIndex}`):null}else if(t.type===`toolGroup`)return(0,G.jsx)(e?.ToolGroup??LS.ToolGroup,{startIndex:t.startIndex,endIndex:t.endIndex,children:Array.from({length:t.endIndex-t.startIndex+1},(n,r)=>{let i=t.startIndex+r;return(0,G.jsx)(zS,{index:i,components:e},`part-${i}`)})},`tool-${t.startIndex}`);else return(0,G.jsx)(e?.ReasoningGroup??LS.ReasoningGroup,{startIndex:t.startIndex,endIndex:t.endIndex,children:Array.from({length:t.endIndex-t.startIndex+1},(n,r)=>{let i=t.startIndex+r;return(0,G.jsx)(zS,{index:i,components:e},`part-${i}`)})},`reasoning-${t.startIndex}`)}),[r,e,n]);return(0,G.jsxs)(G.Fragment,{children:[e?.Quote&&(0,G.jsx)(GS,{Quote:e.Quote}),i,(0,G.jsx)(WS,{components:e,enabled:t})]})},tC=Symbol.for(`@assistant-ui/groupBy.memoKey`),nC=e=>{let t=e.nextChildIdx++;return e.nodeKey===``?String(t):`${e.nodeKey}.${t}`},rC=e=>{let t={key:``,nodeKey:``,indices:[],children:[],nextChildIdx:0},n=[t],r=()=>{let e=n.pop();n[n.length-1].children.push({type:`group`,key:e.key,nodeKey:e.nodeKey,indices:e.indices,children:e.children})};for(let t=0;t<e.length;t++){let i=e[t],a=0;for(;a<n.length-1&&a<i.length&&n[a+1].key===i[a];)a++;for(;n.length-1>a;)r();for(;n.length-1<i.length;){let e=n[n.length-1];n.push({key:i[n.length-1],nodeKey:nC(e),indices:[],children:[],nextChildIdx:0})}let o=n[n.length-1];o.children.push({type:`part`,index:t,nodeKey:nC(o)});for(let e=1;e<n.length;e++)n[e].indices.push(t)}for(;n.length>1;)r();return t.children},iC=Object.freeze({type:`complete`}),aC=(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`}}},oC=()=>{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 skip it.")},sC=(e,t,n)=>{if(e.type===`part`)return(0,G.jsx)(ZS,{index:e.index,children:({part:e})=>n({part:e,children:(0,G.jsx)(oC,{})})},`part-${e.index}`);let r=t[e.indices.at(-1)]?.status??iC;return(0,G.jsx)(_.Fragment,{children:n({part:{type:e.key,status:r,indices:e.indices},children:(0,G.jsx)(G.Fragment,{children:e.children.map(e=>sC(e,t,n))})})},e.nodeKey)},cC=({groupBy:e,indicator:t=`no-text`,children:n})=>{let r=Z(AS(e=>e.message.parts)),i=Z(e=>e.tools.toolUIs),a=Z(e=>t===`never`?!1:e.message.status?.type===`running`);return(0,G.jsxs)(G.Fragment,{children:[(0,_.useMemo)(()=>{let t={toolUIs:i};return rC(r.map(n=>e(n,t)??[]))},[r,e[tC]??e,i]).map(e=>sC(e,r,n)),aC(t,r,a)&&n({part:{type:`indicator`},children:(0,G.jsx)(oC,{})})]})};cC.displayName=`MessagePrimitive.GroupedParts`;var lC=(0,_.memo)(({children:e})=>{let t=Z(gS);return t?(0,G.jsx)(G.Fragment,{children:e(t)}):null});lC.displayName=`MessagePrimitive.Quote`;var uC=(e,t)=>{switch(t.type){case`image`:return e?.Image??e?.Attachment;case`document`:return e?.Document??e?.Attachment;case`file`:return e?.File??e?.Attachment;default:return e?.Attachment}},dC=({components:e})=>{let t=Z(e=>e.attachment);if(!t)return null;let n=uC(e,t);return n?(0,G.jsx)(n,{}):null},fC=(0,_.memo)(({index:e,components:t})=>(0,G.jsx)(pb,{index:e,children:(0,G.jsx)(dC,{components:t})}),(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);fC.displayName=`MessagePrimitive.AttachmentByIndex`;var pC=({children:e})=>{let t=Z(e=>e.message.role===`user`?(e.message.attachments??[]).length:0);return(0,_.useMemo)(()=>Array.from({length:t},(t,n)=>(0,G.jsx)(pb,{index:n,children:(0,G.jsx)(Hv,{getItemState:e=>e.message().attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},n)),[t,e])},mC=({components:e,children:t})=>e?(0,G.jsx)(pC,{children:({attachment:t})=>{let n=uC(e,t);return n?(0,G.jsx)(n,{}):null}}):(0,G.jsx)(pC,{children:t});mC.displayName=`MessagePrimitive.Attachments`;var hC=(e,t)=>{switch(t.type){case`image`:return e?.Image??e?.Attachment;case`document`:return e?.Document??e?.Attachment;case`file`:return e?.File??e?.Attachment;default:return e?.Attachment}},gC=({components:e})=>{let t=Z(e=>e.attachment);if(!t)return null;let n=hC(e,t);return n?(0,G.jsx)(n,{}):null},_C=(0,_.memo)(({index:e,components:t})=>(0,G.jsx)(mb,{index:e,children:(0,G.jsx)(gC,{components:t})}),(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);_C.displayName=`ComposerPrimitive.AttachmentByIndex`;var vC=({children:e})=>{let t=Z(e=>e.composer.attachments.length);return(0,_.useMemo)(()=>Array.from({length:t},(t,n)=>(0,G.jsx)(mb,{index:n,children:(0,G.jsx)(Hv,{getItemState:e=>e.composer().attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},n)),[t,e])},yC=({components:e,children:t})=>e?(0,G.jsx)(vC,{children:({attachment:t})=>{let n=hC(e,t);return n?(0,G.jsx)(n,{}):null}}):(0,G.jsx)(vC,{children:t});yC.displayName=`ComposerPrimitive.Attachments`;var bC=(0,_.memo)(({children:e})=>{let t=Z(e=>e.composer.queue.length);return(0,_.useMemo)(()=>Array.from({length:t},(t,n)=>(0,G.jsx)(Cb,{index:n,children:(0,G.jsx)(Hv,{getItemState:e=>e.composer().queueItem({index:n}).getState(),children:t=>e({get queueItem(){return t()}})})},n)),[t,e])});bC.displayName=`ComposerPrimitive.Queue`;var xC=({children:e})=>Z(e=>e.part.status.type===`running`)?e:null;xC.displayName=`MessagePartPrimitive.InProgress`;var SC=({components:e})=>{let t=e.Suggestion;return(0,G.jsx)(t,{})},CC=(0,_.memo)(({index:e,components:t})=>(0,G.jsx)(Sb,{index:e,children:(0,G.jsx)(SC,{components:t})}),(e,t)=>e.index===t.index&&e.components.Suggestion===t.components.Suggestion);CC.displayName=`ThreadPrimitive.SuggestionByIndex`;var wC=({children:e})=>{let t=Z(e=>e.suggestions.suggestions.length);return(0,_.useMemo)(()=>t===0?null:Array.from({length:t},(t,n)=>(0,G.jsx)(Sb,{index:n,children:(0,G.jsx)(Hv,{getItemState:e=>e.suggestions().suggestion({index:n}).getState(),children:t=>e({get suggestion(){return t()}})})},n)),[t,e])},TC=({components:e,children:t})=>e?(0,G.jsx)(wC,{children:()=>(0,G.jsx)(SC,{components:e})}):(0,G.jsx)(wC,{children:t});TC.displayName=`ThreadPrimitive.Suggestions`;var EC=(0,_.memo)(TC,(e,t)=>e.children||t.children?e.children===t.children:e.components.Suggestion===t.components.Suggestion),DC=e=>Z(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)}),OC=({children:e,...t})=>DC(t)?e:null;OC.displayName=`ComposerPrimitive.If`;var kC=()=>{let e=Rv(),t=Z(e=>!e.composer.canSend||e.thread.isRunning&&!e.thread.capabilities.queue);return{send:(0,_.useCallback)(t=>{e.composer().send(t)},[e]),disabled:t}},AC=()=>{let e=Rv(),t=Z(e=>!e.composer.canCancel);return{cancel:(0,_.useCallback)(()=>{e.composer().cancel()},[e]),disabled:t}},jC=()=>{let e=Rv(),t=Z(e=>e.composer.dictation!=null||!e.thread.capabilities.dictation||!e.composer.isEditing);return{startDictation:(0,_.useCallback)(()=>{e.composer().startDictation()},[e]),disabled:t}},MC=()=>{let e=Rv(),t=Z(e=>!e.composer.isEditing);return{addAttachment:(0,_.useCallback)(t=>e.composer().addAttachment(t),[e]),disabled:t}},NC=({prompt:e,send:t,clearComposer:n=!0})=>{let r=Rv(),i=Z(e=>e.thread.isDisabled),a=t??!1;return{trigger:(0,_.useCallback)(()=>{let t=r.thread().getState().isRunning;if(a&&!t)r.thread().append({content:[{type:`text`,text:e}],runConfig:r.composer().getState().runConfig}),n&&r.composer().setText(``);else if(n)r.composer().setText(e);else{let t=r.composer().getState().text;r.composer().setText(t.trim()?`${t} ${e}`:e)}},[r,a,n,e]),disabled:i}},PC=()=>Z(e=>e.message.status?.type===`incomplete`&&e.message.status.reason===`error`?e.message.status.error??`An error occurred`:void 0),FC=e=>{let{cloud:t,initialMessages:n,maxSteps:r,adapters:i,unstable_humanToolNames:a,...o}=e;return{localRuntimeOptions:{cloud:t,initialMessages:n,maxSteps:r,adapters:i,unstable_humanToolNames:a},otherOptions:o}},IC=/:([\w-]{1,64})\[([^\]\n]{1,1024})\](?:\{name=([^}\n]{1,1024})\})?/gu,LC={serialize(e){let t=e.id===e.label?``:`{name=${e.id}}`;return`:${e.type}[${e.label}]${t}`},parse(e){let t=[],n=0;for(let r of e.matchAll(IC)){r.index>n&&t.push({kind:`text`,text:e.slice(n,r.index)});let i=r[2];t.push({kind:`mention`,type:r[1],label:i,id:r[3]??i}),n=r.index+r[0].length}return n<e.length&&t.push({kind:`text`,text:e.slice(n)}),t}};function RC(e,t){function n(n){let r=(0,_.useContext)(e);if(!n?.optional&&!r)throw Error(`This component must be used within ${t}.`);return r}return n}function zC(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 BC=(0,_.createContext)(null),{useThreadViewport:VC,useThreadViewportStore:HC}=zC(RC(BC,`ThreadPrimitive.Viewport`),`useThreadViewport`),UC=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()}}}}},WC=(e={})=>{let t=new Set,n=UC(e=>{a.setState({height:{...a.getState().height,viewport:e}})}),r=UC(e=>{a.setState({height:{...a.getState().height,inset:e}})}),i=(e,t)=>(a.setState({element:{...a.getState().element,[e]:t}}),()=>{a.getState().element[e]===t&&a.setState({element:{...a.getState().element,[e]:null}})}),a=Cy(()=>({isAtBottom:!0,scrollToBottom:({behavior:e=`auto`}={})=>{for(let n of t)n({behavior:e})},onScrollToBottom:e=>(t.add(e),()=>{t.delete(e)}),turnAnchor:e.turnAnchor??`bottom`,topAnchorMessageClamp:{tallerThan:e.topAnchorMessageClamp?.tallerThan??`10em`,visibleHeight:e.topAnchorMessageClamp?.visibleHeight??`6em`},height:{viewport:0,inset:0},element:{viewport:null,anchor:null,target:null},targetConfig:null,topAnchorTurn:null,registerViewport:n.register,registerContentInset:r.register,registerViewportElement:e=>i(`viewport`,e),registerAnchorElement:e=>i(`anchor`,e),registerAnchorTargetElement:(e,t)=>(a.setState({element:{...a.getState().element,target:e},targetConfig:e&&t?t:null}),()=>{a.getState().element.target===e&&a.setState({element:{...a.getState().element,target:null},targetConfig:null})}),setTopAnchorTurn:e=>{a.setState({topAnchorTurn:e})}}));return a},GC=e=>e,KC=e=>{let t=HC({optional:!0}),[n]=(0,_.useState)(()=>WC(e));return(0,_.useEffect)(()=>t?.getState().onScrollToBottom(()=>{n.getState().scrollToBottom()}),[t,n]),(0,_.useEffect)(()=>{if(t)return n.subscribe(e=>{t.getState().isAtBottom!==e.isAtBottom&&GC(t).setState({isAtBottom:e.isAtBottom})})},[n,t]),n},qC=({children:e,options:t={}})=>{let n=KC(t),[r]=(0,_.useState)(()=>({useThreadViewport:n}));return(0,G.jsx)(BC.Provider,{value:r,children:e})},JC=()=>((0,_.useEffect)(()=>{},[Rv()]),null),YC=(0,_.memo)(({children:e,aui:t,runtime:n})=>(0,G.jsxs)(_y,{runtime:n,aui:t??null,children:[(0,G.jsx)(JC,{}),(0,G.jsx)(qC,{children:e})]}));function XC(e){let t=Rv(),n=Z(()=>t.composer.source?t.composer().__internal_getRuntime?.()??null:null);if(!n&&!e?.optional)throw Error(`ComposerRuntime is not available`);return n}var ZC=Object.defineProperty,QC=(e,t)=>{let n={};for(var r in e)ZC(n,r,{get:e[r],enumerable:!0});return t||ZC(n,Symbol.toStringTag,{value:`Module`}),n},$C=Symbol.for(`react.lazy`),ew=_.use;function tw(e){return typeof e==`object`&&!!e&&`then`in e}function nw(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===$C&&`_payload`in e&&tw(e._payload)}function rw(e){let t=iw(e),n=_.forwardRef((e,n)=>{let{children:r,...i}=e;nw(r)&&typeof ew==`function`&&(r=ew(r._payload));let a=_.Children.toArray(r),o=a.find(ow);if(o){let e=o.props.children,r=a.map(t=>t===o?_.Children.count(e)>1?_.Children.only(null):_.isValidElement(e)?e.props.children:null:t);return(0,G.jsx)(t,{...i,ref:n,children:_.isValidElement(e)?_.cloneElement(e,void 0,r):null})}return(0,G.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function iw(e){let t=_.forwardRef((e,t)=>{let{children:n,...r}=e;if(nw(n)&&typeof ew==`function`&&(n=ew(n._payload)),_.isValidElement(n)){let e=cw(n),i=sw(r,n.props);return n.type!==_.Fragment&&(i.ref=t?Ai(t,e):e),_.cloneElement(n,i)}return _.Children.count(n)>1?_.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var aw=Symbol(`radix.slottable`);function ow(e){return _.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===aw}function sw(e,t){let n={...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]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function cw(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var lw=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=rw(`Primitive.${t}`),r=_.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,G.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),uw=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`];function dw(e){let t=(0,_.forwardRef)(({render:t,asChild:n,children:r,...i},a)=>{let o=e;if(t&&(0,_.isValidElement)(t)){let e=r===void 0?t.props.children:r;return(0,G.jsx)(o,{...i,asChild:!0,ref:a,children:(0,_.cloneElement)(t,void 0,e)})}return(0,G.jsx)(o,{...i,asChild:n,ref:a,children:r})});return t.displayName=typeof e==`string`?e:e.displayName??e.name??`Component`,t}function fw(e){let t=lw[e],n=dw(t);return n.displayName=`Primitive.${e}`,n}var pw=uw.reduce((e,t)=>(e[t]=fw(t),e),{}),mw=(e,t,n=[])=>{let r=(0,_.forwardRef)((e,r)=>{let i={},a={};Object.keys(e).forEach(t=>{n.includes(t)?i[t]=e[t]:a[t]=e[t]});let o=t(i)??void 0;return(0,G.jsx)(pw.button,{...a,type:`button`,ref:r,disabled:a.disabled||!o,onClick:K(a.onClick,o)})});return r.displayName=e,r},hw=e=>Z(t=>{let{role:n,attachments:r,parts:i,branchCount:a,isLast:o,speech:s,isCopied:c,isHovering:l}=t.message;return!(e.hasBranches===!0&&a<2||e.user&&n!==`user`||e.assistant&&n!==`assistant`||e.system&&n!==`system`||e.lastOrHover===!0&&!l&&!o||e.last!==void 0&&e.last!==o||e.copied===!0&&!c||e.copied===!1&&c||e.speaking===!0&&s==null||e.speaking===!1&&s!=null||e.hasAttachments===!0&&(n!==`user`||!r?.length)||e.hasAttachments===!1&&n===`user`&&r?.length||e.hasContent===!0&&i.length===0||e.hasContent===!1&&i.length>0||e.submittedFeedback!==void 0&&(t.message.metadata.submittedFeedback?.type??null)!==e.submittedFeedback)}),gw=({children:e,...t})=>hw(t)?e:null;gw.displayName=`MessagePrimitive.If`;var _w=(0,_.createContext)(null),vw=()=>(0,_.useContext)(_w),yw=({children:e})=>{let t=(0,_.useRef)(new Map),n=(0,_.useRef)([]),r=(0,_.useCallback)(()=>{let e=Array.from(t.current.entries());e.sort((e,t)=>t[1]-e[1]),n.current=e.map(([e])=>e)},[]),i=(0,_.useCallback)((e,n)=>{let i=n?.priority??0;return t.current.set(e,i),r(),()=>{t.current.delete(e),r()}},[r]),a=(0,_.useCallback)(()=>n.current,[]),o=(0,_.useMemo)(()=>({register:i,getPlugins:a}),[i,a]);return(0,G.jsx)(_w.Provider,{value:o,children:e})},bw=(0,_.createContext)(null),xw=(0,_.createContext)(null),Sw=()=>{let e=(0,_.useContext)(bw);if(!e)throw Error(`useTriggerPopoverRootContext must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},Cw=()=>(0,_.useContext)(bw),ww=()=>{let e=(0,_.useContext)(xw);if(!e)throw Error(`useTriggerPopoverAriaPublish must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},Tw=()=>{let e=Sw();return(0,_.useSyncExternalStore)(e.subscribe,e.getTriggers,e.getTriggers)},Ew=new Map,Dw=()=>()=>{},Ow=()=>Ew,kw=()=>{let e=Cw();return(0,_.useSyncExternalStore)(e?e.subscribe:Dw,e?e.getTriggers:Ow,e?e.getTriggers:Ow)},Aw=()=>null,jw=()=>{let e=Cw();return(0,_.useSyncExternalStore)(e?e.subscribeAria:Dw,e?e.getActiveAria:Aw,e?e.getActiveAria:Aw)};function Mw(){let e=(0,_.useRef)(new Set);return{notify:(0,_.useCallback)(()=>{for(let t of e.current)t()},[]),subscribe:(0,_.useCallback)(t=>(e.current.add(t),()=>{e.current.delete(t)}),[])}}var Nw=({children:e})=>{let t=(0,_.useRef)(new Map),n=(0,_.useRef)(new Set),{notify:r,subscribe:i}=Mw(),a=(0,_.useCallback)(e=>{let{char:i}=e;if(t.current.has(i))return()=>{};let a=new Map(t.current);a.set(i,e),t.current=a,r();for(let t of n.current)t.added(e);return()=>{let e=new Map(t.current);e.delete(i),t.current=e,r();for(let e of n.current)e.removed(i)}},[r]),o=(0,_.useCallback)(()=>t.current,[]),s=(0,_.useCallback)(e=>(n.current.add(e),()=>{n.current.delete(e)}),[]),c=(0,_.useRef)(null),l=(0,_.useRef)(null),{notify:u,subscribe:d}=Mw(),f=(0,_.useCallback)((e,t)=>{if(t===null){if(l.current!==e)return;c.current=null,l.current=null,u();return}let n=c.current;l.current===e&&n!==null&&n.popoverId===t.popoverId&&n.highlightedItemId===t.highlightedItemId||(c.current=t,l.current=e,u())},[u]),p=(0,_.useCallback)(()=>c.current,[]),m=(0,_.useMemo)(()=>({register:a,getTriggers:o,subscribe:i,subscribeLifecycle:s,getActiveAria:p,subscribeAria:d}),[a,o,i,s,p,d]),h=(0,_.useMemo)(()=>({setActiveAria:f}),[f]);return(0,G.jsx)(bw.Provider,{value:m,children:(0,G.jsx)(xw.Provider,{value:h,children:e})})},Pw=({children:e})=>vw()?(0,G.jsx)(Nw,{children:e}):(0,G.jsx)(yw,{children:(0,G.jsx)(Nw,{children:e})});Pw.displayName=`ComposerPrimitive.TriggerPopoverRoot`;var Fw=/\s/u;function Iw(e,t,n){let r=e.slice(0,n);for(let e=r.length-1;e>=0;e--){let n=r[e];if(Fw.test(n))return null;if(r.startsWith(t,e)){if(e>0&&!Fw.test(r[e-1]))continue;return{query:r.slice(e+t.length),offset:e}}}return null}var Lw=Fg(({text:e,triggerChar:t})=>{let[n,r]=e_(e.length),i=s_(()=>Iw(e,t,Math.min(n,e.length)),[n,e,t]);return{trigger:i,query:i?.query??``,setCursorPosition:r}});function Rw(e){return`type`in e}var zw=Fg(({navigableList:e,isSearchMode:t,activeCategoryId:n,query:r,popoverId:i,open:a,selectItem:o,selectCategory:s,goBack:c,close:l})=>{let[u,d]=e_(0);r_(()=>{d(0)},[e]),r_(()=>{d(0)},[t,n]);let f=l_(t=>{t<0||t>=e.length||t!==u&&d(t)}),p=l_(t=>{if(!a)return!1;switch(t.key){case`ArrowDown`:return t.preventDefault(),d(t=>{let n=e.length;return n===0?0:t<n-1?t+1:0}),!0;case`ArrowUp`:return t.preventDefault(),d(t=>{let n=e.length;return n===0?0:t>0?t-1:n-1}),!0;case`Enter`:case`Tab`:{if(t.shiftKey)return!1;t.preventDefault();let n=e[u];return n&&(Rw(n)?o(n):s(n.id)),!0}case`Escape`:return t.preventDefault(),l(),!0;case`Backspace`:return n&&r===``?(t.preventDefault(),c(),!0):!1;default:return!1}}),m=e[u];return{highlightedIndex:u,highlightedItemId:a&&m?`${i}-option-${m.id}`:void 0,highlightIndex:f,handleKeyDown:p}});function Bw(e,t){return e.id.toLowerCase().includes(t)||e.label.toLowerCase().includes(t)||(e.description?.toLowerCase().includes(t)??!1)}var Vw=Fg(({adapter:e,query:t,open:n})=>{let[r,i]=e_(null);r_(()=>{n||i(null)},[n]);let a=s_(()=>!n||!e?[]:e.categories(),[n,e]),o=n?r:null,s=s_(()=>!o||!e?[]:e.categoryItems(o),[o,e]),c=s_(()=>{if(!n||!e||o||!t&&a.length>0)return null;if(e.search)return e.search(t);let r=[],i=t.toLowerCase();for(let t of a)for(let n of e.categoryItems(t.id))Bw(n,i)&&r.push(n);return r},[n,e,t,o,a]),l=c!==null,u=s_(()=>{if(l)return[];if(!t)return a;let e=t.toLowerCase();return a.filter(t=>t.label.toLowerCase().includes(e))},[a,t,l]),d=s_(()=>{if(l)return c??[];if(!t)return s;let e=t.toLowerCase();return s.filter(t=>Bw(t,e))},[s,t,l,c]);return{categories:u,items:d,isSearchMode:l,activeCategoryId:o,navigableList:s_(()=>l?c??[]:o?d:u,[l,c,o,d,u]),selectCategory:l_(e=>{i(e)}),goBack:l_(()=>{i(null)})}}),Hw=Fg(({behavior:e,trigger:t,aui:n,triggerChar:r,setCursorPosition:i,onSelected:a})=>{let o=i_(null),s=l_(e=>(o.current=e,()=>{o.current===e&&(o.current=null)}));return{selectItem:l_(i=>{if(!t||!e)return;if(o.current?.(i)){a();return}let s=n.composer().getState().text,c=s.slice(0,t.offset),l=s.slice(t.offset+r.length+t.query.length),u=()=>{let t=e.formatter.serialize(i);n.composer().setText(c+t+(l.startsWith(` `)?l:` ${l}`))};e.kind===`directive`?(u(),e.onInserted?.(i)):(e.removeOnExecute?n.composer().setText(c+(l.startsWith(` `)?l.slice(1):l)):u(),e.onExecute(i)),a()}),close:l_(()=>{a(),t&&i(t.offset)}),registerSelectItemOverride:s}}),Uw=Fg(({adapter:e,text:t,triggerChar:n,behavior:r,aui:i,popoverId:a})=>{let o=g_(Lw({text:t,triggerChar:n})),s=o.trigger!==null&&e!==void 0&&r!==void 0,c=g_(Vw({adapter:e,query:o.query,open:s})),l=l_(()=>{c.goBack()}),u=g_(Hw({behavior:r,trigger:o.trigger,aui:i,triggerChar:n,setCursorPosition:o.setCursorPosition,onSelected:l})),d=g_(zw({navigableList:c.navigableList,isSearchMode:c.isSearchMode,activeCategoryId:c.activeCategoryId,query:o.query,popoverId:a,open:s,selectItem:u.selectItem,selectCategory:c.selectCategory,goBack:c.goBack,close:u.close}));return{open:s,query:o.query,activeCategoryId:c.activeCategoryId,categories:c.categories,items:c.items,highlightedIndex:d.highlightedIndex,isSearchMode:c.isSearchMode,popoverId:a,highlightedItemId:d.highlightedItemId,selectCategory:c.selectCategory,goBack:c.goBack,selectItem:u.selectItem,close:u.close,highlightIndex:d.highlightIndex,handleKeyDown:d.handleKeyDown,setCursorPosition:o.setCursorPosition,registerSelectItemOverride:u.registerSelectItemOverride}}),Ww=(0,_.createContext)(null),Gw=()=>{let e=(0,_.useContext)(Ww);if(!e)throw Error(`useTriggerPopoverScopeContext must be used within ComposerPrimitive.TriggerPopover`);return e},Kw=()=>(0,_.useContext)(Ww),qw=(0,_.createContext)(null),Jw=()=>{let e=(0,_.useContext)(qw);if(!e)throw Error(`TriggerPopover.Directive / TriggerPopover.Action must be rendered inside ComposerPrimitive.TriggerPopover`);return e},Yw=(0,_.forwardRef)(({char:e,adapter:t,"aria-label":n,children:r,...i},a)=>{let o=Rv(),s=Z(e=>e.composer.text),c=(0,_.useId)(),l=(0,_.useRef)(null),[u,d]=(0,_.useState)(null),f=(0,_.useRef)(0),p=(0,_.useCallback)(e=>(f.current+=1,l.current=e,d(e),()=>{f.current=Math.max(0,f.current-1),l.current===e&&(l.current=null,d(null))}),[e]),m=(0,_.useMemo)(()=>({register:p}),[p]),h=Ov(Uw({adapter:t,text:s,triggerChar:e,behavior:u??void 0,aui:o,popoverId:c})),g=(0,_.useRef)(h);g.current=h;let v=Sw();(0,_.useEffect)(()=>v.register({char:e,...u?{behavior:u}:{},resource:g.current}),[v,e,u]);let y=vw();(0,_.useEffect)(()=>{if(y)return y.register(g.current)},[y]);let b=u!==null&&h.open,x=ww();return(0,_.useEffect)(()=>{if(b)return()=>{x.setActiveAria(e,null)}},[x,e,b]),(0,_.useEffect)(()=>{b&&x.setActiveAria(e,{popoverId:c,highlightedItemId:h.highlightedItemId})},[x,e,c,b,h.highlightedItemId]),(0,G.jsx)(qw.Provider,{value:m,children:(0,G.jsx)(Ww.Provider,{value:h,children:b?(0,G.jsx)(pw.div,{role:`listbox`,id:c,"aria-label":n??`Suggestions`,"aria-activedescendant":h.highlightedItemId,"data-state":`open`,...i,ref:a,children:r}):r})})});Yw.displayName=`ComposerPrimitive.TriggerPopover`;var Xw=()=>{let{disabled:e,send:t}=kC(),n=(0,_.useCallback)(()=>t(),[t]);return e?null:n},Zw=mw(`ComposerPrimitive.Send`,Xw),Qw=(0,_.forwardRef)(({onSubmit:e,...t},n)=>{let r=Xw(),i=e=>{e.preventDefault(),r&&r()};return(0,G.jsx)(pw.form,{...t,ref:n,onSubmit:K(e,i)})});Qw.displayName=`ComposerPrimitive.Root`;var $w=e=>{let t=xa(e),n=VC(e=>e.onScrollToBottom);(0,_.useEffect)(()=>n(t),[n,t])},eT=()=>!1,tT=()=>{},nT=e=>(0,_.useSyncExternalStore)((0,_.useCallback)(t=>{if(typeof window>`u`||e===null)return tT;let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},[e]),(0,_.useCallback)(()=>typeof window>`u`||e===null?!1:window.matchMedia(e).matches,[e]),eT);function rT(){return rT=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},rT.apply(null,arguments)}function iT(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 aT=_.useLayoutEffect,oT=function(e){var t=_.useRef(e);return aT(function(){t.current=e}),t},sT=function(e,t){if(typeof e==`function`){e(t);return}e.current=t},cT=function(e,t){var n=_.useRef();return _.useCallback(function(r){e.current=r,n.current&&sT(n.current,null),n.current=t,t&&sT(t,r)},[t])},lT={"min-height":`0`,"max-height":`none`,height:`0`,visibility:`hidden`,overflow:`hidden`,position:`absolute`,"z-index":`-1000`,top:`0`,right:`0`,display:`block`},uT=function(e){Object.keys(lT).forEach(function(t){e.style.setProperty(t,lT[t],`important`)})},dT=null,fT=function(e,t){var n=e.scrollHeight;return t.sizingStyle.boxSizing===`border-box`?n+t.borderSize:n-t.paddingSize};function pT(e,t,n,r){n===void 0&&(n=1),r===void 0&&(r=1/0),dT||(dT=document.createElement(`textarea`),dT.setAttribute(`tabindex`,`-1`),dT.setAttribute(`aria-hidden`,`true`),uT(dT)),dT.parentNode===null&&document.body.appendChild(dT);var i=e.paddingSize,a=e.borderSize,o=e.sizingStyle,s=o.boxSizing;Object.keys(o).forEach(function(e){var t=e;dT.style[t]=o[t]}),uT(dT),dT.value=t;var c=fT(dT,e);dT.value=t,c=fT(dT,e),dT.value=`x`;var l=dT.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 mT=function(){},hT=function(e,t){return e.reduce(function(e,n){return e[n]=t[n],e},{})},gT=[`borderBottomWidth`,`borderLeftWidth`,`borderRightWidth`,`borderTopWidth`,`boxSizing`,`fontFamily`,`fontSize`,`fontStyle`,`fontWeight`,`letterSpacing`,`lineHeight`,`paddingBottom`,`paddingLeft`,`paddingRight`,`paddingTop`,`tabSize`,`textIndent`,`textRendering`,`textTransform`,`width`,`wordBreak`,`wordSpacing`,`scrollbarGutter`],_T=!!document.documentElement.currentStyle,vT=function(e){var t=window.getComputedStyle(e);if(t===null)return null;var n=hT(gT,t),r=n.boxSizing;return r===``?null:(_T&&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 yT(e,t,n){var r=oT(n);_.useLayoutEffect(function(){var n=function(e){return r.current(e)};if(e)return e.addEventListener(t,n),function(){return e.removeEventListener(t,n)}},[])}var bT=function(e,t){yT(document.body,`reset`,function(n){e.current.form===n.target&&t(n)})},xT=function(e){yT(window,`resize`,e)},ST=function(e){yT(document.fonts,`loadingdone`,e)},CT=[`cacheMeasurements`,`maxRows`,`minRows`,`onChange`,`onHeightChange`],wT=_.forwardRef(function(e,t){var n=e.cacheMeasurements,r=e.maxRows,i=e.minRows,a=e.onChange,o=a===void 0?mT:a,s=e.onHeightChange,c=s===void 0?mT:s,l=iT(e,CT),u=l.value!==void 0,d=_.useRef(null),f=cT(d,t),p=_.useRef(0),m=_.useRef(),h=function(){var e=d.current,t=n&&m.current?m.current:vT(e);if(t){m.current=t;var a=pT(t,e.value||e.placeholder||`x`,i,r),o=a[0],s=a[1];p.current!==o&&(p.current=o,e.style.setProperty(`height`,o+`px`,`important`),c(o,{rowHeight:s}))}};return _.useLayoutEffect(h),bT(d,function(){if(!u){var e=d.current.value;requestAnimationFrame(function(){var t=d.current;t&&e!==t.value&&h()})}}),xT(h),ST(h),_.createElement(`textarea`,rT({},l,{onChange:function(e){u||h(),o(e)},ref:f}))}),TT=`(pointer: coarse) and (not (any-pointer: fine))`,ET=(0,_.forwardRef)(({autoFocus:e=!1,asChild:t,render:n,disabled:r,onChange:i,onKeyDown:a,onPaste:o,onSelect:s,submitOnEnter:c,submitMode:l,cancelOnEscape:u=!0,unstable_focusOnRunStart:d=!0,unstable_focusOnScrollToBottom:f=!0,unstable_focusOnThreadSwitched:p=!0,unstable_insertNewlineOnTouchEnter:m=!1,addAttachmentOnPaste:h=!0,...g},v)=>{let y=Rv(),b=vw(),x=jw(),S=l??(c===!1?`none`:`enter`),C=nT(m?TT:null),w=m&&C&&S===`enter`?`none`:S,T=Z(e=>e.composer.isEditing?e.composer.text:``),E=Z(e=>e.thread.isDisabled||e.composer.dictation?.inputDisabled)||r,D=(0,_.useRef)(null),O=ji(v,D),k=(0,_.useRef)(!1);Sa(e=>{if(!D.current?.contains(e.target))return;if(b){for(let t of b.getPlugins())if(t.handleKeyDown(e))return}if(!u)return;let t=y.composer();t.getState().canCancel&&(t.cancel(),e.preventDefault())});let A=e=>{if(!E&&!e.nativeEvent.isComposing){if(b){for(let t of b.getPlugins())if(t.handleKeyDown(e))return}if(e.key===`Enter`){let t=y.thread().getState(),n=t.capabilities.queue;if(e.shiftKey&&(e.ctrlKey||e.metaKey)&&n&&S!==`none`&&y.composer().getState().canSend){e.preventDefault(),y.composer().send({steer:!0});return}if(e.shiftKey||t.isRunning&&!n)return;let r=!1;w===`ctrlEnter`?r=e.ctrlKey||e.metaKey:w===`enter`&&(r=!0),r&&(e.preventDefault(),D.current?.closest(`form`)?.requestSubmit())}}},j=async e=>{if(!h)return;let t=y.thread().getState().capabilities,n=Array.from(e.clipboardData?.files||[]);if(t.attachments&&n.length>0)try{e.preventDefault(),await Promise.all(n.map(e=>y.composer().addAttachment(e)))}catch(e){console.error(`Error adding attachment:`,e)}},M=e&&!E,N=(0,_.useCallback)(()=>{let e=D.current;!e||!M||(e.focus({preventScroll:!0}),e.setSelectionRange(e.value.length,e.value.length))},[M]);(0,_.useEffect)(()=>N(),[N]),$w(()=>{y.composer().getState().type===`thread`&&f&&N()}),(0,_.useEffect)(()=>{if(!(y.composer().getState().type!==`thread`||!d))return y.on(`thread.runStart`,N)},[d,N,y]),(0,_.useEffect)(()=>{if(!(y.composer().getState().type!==`thread`||!p))return y.on(`threadListItem.switchedTo`,N)},[p,N,y]);let P=x?{"aria-controls":x.popoverId,"aria-expanded":!0,"aria-haspopup":`listbox`,"aria-activedescendant":x.highlightedItemId}:{},F={name:`input`,value:T,...g,...P,ref:O,disabled:E,onChange:K(i,e=>{if(!y.composer().getState().isEditing)return;let t=e.nativeEvent.isComposing===!0;k.current&&!t&&(k.current=!1);let n=t||k.current;if(w_(()=>{y.composer().setText(e.target.value)}),n)return;let r=e.target.selectionStart??e.target.value.length;if(b)for(let e of b.getPlugins())e.setCursorPosition(r)}),onKeyDown:K(a,A),onCompositionStart:K(g.onCompositionStart,()=>{k.current=!0}),onCompositionEnd:K(g.onCompositionEnd,e=>{if(k.current=!1,!y.composer().getState().isEditing)return;let t=e.target;w_(()=>{y.composer().setText(t.value)});let n=t.selectionStart??t.value.length;if(b)for(let e of b.getPlugins())e.setCursorPosition(n)}),onSelect:K(s,e=>{if(k.current)return;let t=e.target,n=t.selectionStart??t.value.length;if(b)for(let e of b.getPlugins())e.setCursorPosition(n)}),onPaste:K(o,j)};if(n&&(0,_.isValidElement)(n)){let e=g.children===void 0?n.props.children:g.children;return(0,G.jsx)(Ni,{...F,children:(0,_.cloneElement)(n,void 0,e)})}return(0,G.jsx)(t?Ni:wT,{...F})});ET.displayName=`ComposerPrimitive.Input`;var DT=mw(`ComposerPrimitive.Cancel`,()=>{let{disabled:e,cancel:t}=AC();return e?null:t}),OT=mw(`ComposerPrimitive.AddAttachment`,({multiple:e=!0}={})=>{let{disabled:t,addAttachment:n}=MC(),r=Rv(),i=(0,_.useCallback)(()=>{let t=document.createElement(`input`);t.type=`file`,t.multiple=e,t.hidden=!0;let i=r.composer().getState().attachmentAccept;i!==`*`&&(t.accept=i),document.body.appendChild(t),t.onchange=e=>{let r=e.target.files;if(r){for(let e of r)n(e);document.body.removeChild(t)}},t.oncancel=()=>{(!t.files||t.files.length===0)&&document.body.removeChild(t)},t.click()},[r,e,n]);return t?null:i},[`multiple`]),kT=(0,_.forwardRef)(({disabled:e,asChild:t=!1,render:n,children:r,...i},a)=>{let[o,s]=(0,_.useState)(!1),c=Rv(),l=(0,_.useCallback)(t=>{e||(t.preventDefault(),s(!0))},[e]),u=(0,_.useCallback)(t=>{e||(t.preventDefault(),o||s(!0))},[e,o]),d=(0,_.useCallback)(t=>{if(e)return;t.preventDefault();let n=t.relatedTarget;n&&t.currentTarget.contains(n)||s(!1)},[e]),f=(0,_.useCallback)(async t=>{if(e)return;t.preventDefault(),s(!1);let n=Array.from(t.dataTransfer.files);await Promise.all(n.map(async e=>{try{await c.composer().addAttachment(e)}catch(e){console.error(`Failed to add attachment:`,e)}}))},[e,c]),p={...o?{"data-dragging":`true`}:null,...i,onDragEnterCapture:K(i.onDragEnterCapture,l),onDragOverCapture:K(i.onDragOverCapture,u),onDragLeaveCapture:K(i.onDragLeaveCapture,d),onDropCapture:K(i.onDropCapture,f),ref:a};if(n&&(0,_.isValidElement)(n)){let e=r===void 0?n.props.children:r;return(0,G.jsx)(Ni,{...p,children:(0,_.cloneElement)(n,void 0,e)})}return(0,G.jsx)(t?Ni:`div`,{...p,children:r})});kT.displayName=`ComposerPrimitive.AttachmentDropzone`;var AT=mw(`ComposerPrimitive.Dictate`,()=>{let{disabled:e,startDictation:t}=jC();return e?null:t}),jT=mw(`ComposerPrimitive.StopDictation`,()=>{let e=Rv(),t=Z(e=>e.composer.dictation!=null),n=(0,_.useCallback)(()=>{e.composer().stopDictation()},[e]);return t?n:null}),MT=(0,_.forwardRef)(({children:e,...t},n)=>{let r=Z(e=>e.composer.dictation?.transcript);return r?(0,G.jsx)(pw.span,{...t,ref:n,children:e??r}):null});MT.displayName=`ComposerPrimitive.DictationTranscript`;var NT=(0,_.forwardRef)((e,t)=>Z(e=>e.composer.quote)?(0,G.jsx)(pw.div,{...e,ref:t}):null);NT.displayName=`ComposerPrimitive.Quote`;var PT=(0,_.forwardRef)(({children:e,...t},n)=>{let r=Z(e=>e.composer.quote?.text);return r?(0,G.jsx)(pw.span,{...t,ref:n,children:e??r}):null});PT.displayName=`ComposerPrimitive.QuoteText`;var FT=(0,_.forwardRef)(({onClick:e,...t},n)=>{let r=Rv(),i=(0,_.useCallback)(()=>{r.composer().setQuote(void 0)},[r]);return(0,G.jsx)(pw.button,{type:`button`,...t,ref:n,onClick:K(e,i)})});FT.displayName=`ComposerPrimitive.QuoteDismiss`;var IT=(0,_.forwardRef)(({children:e,"aria-label":t,...n},r)=>{let{categories:i,activeCategoryId:a,isSearchMode:o,open:s}=Gw();return!s||a||o?null:(0,G.jsx)(pw.div,{role:`group`,"aria-label":t??`Categories`,...n,ref:r,children:e(i)})});IT.displayName=`ComposerPrimitive.TriggerPopoverCategories`;var LT=(0,_.forwardRef)(({categoryId:e,onClick:t,onMouseMove:n,...r},i)=>{let{selectCategory:a,highlightIndex:o,categories:s,highlightedIndex:c,activeCategoryId:l,isSearchMode:u,popoverId:d}=Gw(),f=(0,_.useCallback)(()=>{a(e)},[a,e]),p=s.findIndex(t=>t.id===e),m=!l&&!u&&p===c,h=(0,_.useCallback)(()=>{o(p)},[o,p]);return(0,G.jsx)(pw.button,{type:`button`,role:`option`,id:`${d}-option-${e}`,"aria-selected":m,"data-highlighted":m?``:void 0,...r,ref:i,onClick:K(t,f),onMouseMove:K(n,h)})});LT.displayName=`ComposerPrimitive.TriggerPopoverCategoryItem`;var RT=(0,_.forwardRef)(({children:e,"aria-label":t,...n},r)=>{let{items:i,activeCategoryId:a,isSearchMode:o,open:s}=Gw();return!s||!a&&!o?null:(0,G.jsx)(pw.div,{role:`group`,"aria-label":t??`Items`,...n,ref:r,children:e(i)})});RT.displayName=`ComposerPrimitive.TriggerPopoverItems`;var zT=(0,_.forwardRef)(({item:e,index:t,onClick:n,onMouseMove:r,...i},a)=>{let{selectItem:o,highlightIndex:s,items:c,highlightedIndex:l,activeCategoryId:u,isSearchMode:d,popoverId:f}=Gw(),p=(0,_.useCallback)(()=>{o(e)},[o,e]),m=t??c.findIndex(t=>t.id===e.id),h=(d||u!==null)&&m===l,g=(0,_.useCallback)(()=>{s(m)},[s,m]);return(0,G.jsx)(pw.button,{type:`button`,role:`option`,id:`${f}-option-${e.id}`,"aria-selected":h,"data-highlighted":h?``:void 0,...i,ref:a,onClick:K(n,p),onMouseMove:K(r,g)})});zT.displayName=`ComposerPrimitive.TriggerPopoverItem`;var BT=(0,_.forwardRef)(({onClick:e,...t},n)=>{let{activeCategoryId:r,isSearchMode:i,goBack:a,open:o}=Gw();return!o||!r||i?null:(0,G.jsx)(pw.button,{type:`button`,...t,ref:n,onClick:K(e,a)})});BT.displayName=`ComposerPrimitive.TriggerPopoverBack`;var VT=({formatter:e,onExecute:t,removeOnExecute:n})=>{let{register:r}=Jw(),i=(0,_.useRef)(t);return i.current=t,(0,_.useEffect)(()=>r({kind:`action`,formatter:e??LC,onExecute:e=>i.current(e),...n===void 0?{}:{removeOnExecute:n}}),[r,e,n]),null};VT.displayName=`ComposerPrimitive.TriggerPopoverAction`;var HT=({formatter:e,onInserted:t})=>{let{register:n}=Jw(),r=(0,_.useRef)(t);return r.current=t,(0,_.useEffect)(()=>n({kind:`directive`,formatter:e??LC,onInserted:e=>r.current?.(e)}),[n,e]),null};HT.displayName=`ComposerPrimitive.TriggerPopoverDirective`;var UT=Object.assign(Yw,{Directive:HT,Action:VT}),WT=QC({AddAttachment:()=>OT,AttachmentByIndex:()=>_C,AttachmentDropzone:()=>kT,Attachments:()=>yC,Cancel:()=>DT,Dictate:()=>AT,DictationTranscript:()=>MT,If:()=>OC,Input:()=>ET,Queue:()=>bC,Quote:()=>NT,QuoteDismiss:()=>FT,QuoteText:()=>PT,Root:()=>Qw,Send:()=>Zw,StopDictation:()=>jT,Unstable_TriggerPopover:()=>UT,Unstable_TriggerPopoverBack:()=>BT,Unstable_TriggerPopoverCategories:()=>IT,Unstable_TriggerPopoverCategoryItem:()=>LT,Unstable_TriggerPopoverItem:()=>zT,Unstable_TriggerPopoverItems:()=>RT,Unstable_TriggerPopoverRoot:()=>Pw,unstable_useTriggerPopoverRootContext:()=>Sw,unstable_useTriggerPopoverRootContextOptional:()=>Cw,unstable_useTriggerPopoverScopeContext:()=>Gw,unstable_useTriggerPopoverScopeContextOptional:()=>Kw,unstable_useTriggerPopoverTriggers:()=>Tw,unstable_useTriggerPopoverTriggersOptional:()=>kw}),GT=()=>Z(e=>{if(e.part.type!==`text`&&e.part.type!==`reasoning`)throw Error(`MessagePartText can only be used inside text or reasoning message parts.`);return e.part}),KT=()=>Z(e=>{if(e.part.type!==`image`)throw Error(`MessagePartImage can only be used inside image message parts.`);return e.part}),qT=(0,_.createContext)(null),JT=e=>({useSmoothStatus:Cy(()=>e)}),YT=({children:e})=>{let t=ZT({optional:!0}),n=Rv(),[r]=(0,_.useState)(()=>JT(n.part().getState().status));return t?e:(0,G.jsx)(qT.Provider,{value:r,children:e})},XT=e=>{let t=(0,_.forwardRef)((t,n)=>(0,G.jsx)(YT,{children:(0,G.jsx)(e,{...t,ref:n})}));return t.displayName=e.displayName,t};function ZT(e){let t=(0,_.useContext)(qT);if(!e?.optional&&!t)throw Error(`This component must be used within a SmoothContextProvider.`);return t}var{useSmoothStatus:QT,useSmoothStatusStore:$T}=zC(ZT,`useSmoothStatus`),eE=class{currentText;setText;animationFrameId=null;lastUpdateTime=Date.now();targetText=``;constructor(e,t){this.currentText=e,this.setText=t}start(){this.animationFrameId===null&&(this.lastUpdateTime=Date.now(),this.animate())}stop(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}animate=()=>{let e=Date.now(),t=e-this.lastUpdateTime,n=this.targetText.length-this.currentText.length,r=Math.min(5,250/n),i=0;for(;t>=r&&i<n;)i++,t-=r;i===n?this.animationFrameId=null:this.animationFrameId=requestAnimationFrame(this.animate),i!==0&&(this.currentText=this.targetText.slice(0,this.currentText.length+i),this.lastUpdateTime=e-t,this.setText(this.currentText))}},tE=Object.freeze({type:`running`}),nE=(e,t=!1)=>{let{text:n}=e,[r,i]=(0,_.useState)(e.status.type===`running`?``:n),a=Rv(),o=Z(()=>a.part()),[s,c]=(0,_.useState)(o);(o!==s||!n.startsWith(r))&&(c(o),i(e.status.type===`running`?``:n));let l=$T({optional:!0}),u=xa(t=>{if(i(t),l){let n=r!==t||e.status.type===`running`?tE:e.status;GC(l).setState(n,!0)}});(0,_.useEffect)(()=>{if(l){let i=t&&(r!==n||e.status.type===`running`)?tE:e.status;GC(l).setState(i,!0)}},[l,t,n,r,e.status]);let[d]=(0,_.useState)(new eE(r,u)),f=(0,_.useRef)(o);return(0,_.useEffect)(()=>{if(!t){d.stop();return}let r=f.current!==o;if(f.current=o,r||!n.startsWith(d.targetText)){e.status.type===`running`?(d.currentText=``,d.targetText=n,d.start()):(d.currentText=n,d.targetText=n,d.stop());return}d.targetText=n,d.start()},[d,t,n,e.status.type,o]),(0,_.useEffect)(()=>()=>{d.stop()},[d]),(0,_.useMemo)(()=>t?{type:`text`,text:r,status:n===r?e.status:tE}:e,[t,r,e,n])},rE=(0,_.forwardRef)(({smooth:e=!0,component:t=`span`,...n},r)=>{let{text:i,status:a}=nE(GT(),e);return(0,G.jsx)(t,{"data-status":a.type,...n,ref:r,children:i})});rE.displayName=`MessagePartPrimitive.Text`;var iE=(0,_.forwardRef)((e,t)=>{let{image:n}=KT();return(0,G.jsx)(pw.img,{src:n,...e,ref:t})});iE.displayName=`MessagePartPrimitive.Image`;var aE=e=>{let t=(0,_.useRef)(void 0);return(0,_.useCallback)(n=>{t.current&&=(t.current(),void 0),n&&(t.current=e(n))},[e])},oE=(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},sE=e=>e.dataset.messageId,cE=()=>{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},lE=(e,t)=>{let n=`${t}px`;return e.style.height===n?!1:(e.style.height=n,!0)},uE=e=>{let t=window.devicePixelRatio||1;return Math.round(e*t)/t},dE=()=>{let e=Rv(),t=Z(()=>e.message());return aE((0,_.useCallback)(e=>{let n=()=>{t.setIsHovering(!0)},r=()=>{t.setIsHovering(!1)};return e.addEventListener(`mouseenter`,n),e.addEventListener(`mouseleave`,r),e.matches(`:hover`)&&queueMicrotask(()=>t.setIsHovering(!0)),()=>{e.removeEventListener(`mouseenter`,n),e.removeEventListener(`mouseleave`,r),t.setIsHovering(!1)}},[t]))},fE=()=>{let e=VC(e=>e.topAnchorTurn?.anchorId);return Z(t=>t.message.role===`user`&&t.message.index>0&&t.message.index===t.thread.messages.length-2&&t.thread.messages.at(-1)?.role===`assistant`&&(t.message.id===e||t.thread.isRunning))},pE=()=>{let e=VC(e=>e.topAnchorTurn?.targetId);return Z(t=>t.message.isLast&&t.message.role===`assistant`&&t.message.index>=1&&t.thread.messages.at(t.message.index-1)?.role===`user`&&(t.message.id===e||t.thread.isRunning))},mE=(e,t)=>aE((0,_.useCallback)(n=>{if(e)return t.getState().registerAnchorElement(n)},[e,t])),hE=({active:e,threadViewportStore:t})=>aE((0,_.useCallback)(n=>{if(!e)return;let r=t.getState(),i=r.topAnchorMessageClamp;return r.registerAnchorTargetElement(n,{tallerThan:oE(i.tallerThan,n),visibleHeight:oE(i.visibleHeight,n)})},[e,t])),gE=({forwardedRef:e,...t})=>{let n=ji(e,dE()),r=Z(e=>e.message.id);return(0,G.jsx)(pw.div,{...t,ref:n,"data-message-id":r})},_E=({forwardedRef:e,threadViewportStore:t,...n})=>{let r=dE(),i=fE(),a=pE(),o=ji(e,r,mE(i,t),hE({active:a,threadViewportStore:t})),s=Z(e=>e.message.id);return(0,G.jsx)(pw.div,{...n,ref:o,"data-message-id":s,"data-aui-top-anchor-user":i?``:void 0,"data-aui-top-anchor-target":a?``:void 0})},vE=(0,_.forwardRef)((e,t)=>{let n=HC();return n.getState().turnAnchor===`top`?(0,G.jsx)(_E,{...e,forwardedRef:t,threadViewportStore:n}):(0,G.jsx)(gE,{...e,forwardedRef:t})});vE.displayName=`MessagePrimitive.Root`;var yE={...LS,Text:()=>(0,G.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,G.jsx)(rE,{}),(0,G.jsx)(xC,{children:(0,G.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Image:()=>(0,G.jsx)(iE,{})},bE=e=>{if(`children`in e)return(0,G.jsx)($S,{children:e.children});let{components:t,...n}=e;return(0,G.jsx)($S,{components:t?{Text:t.Text??yE.Text,Image:t.Image??yE.Image,Reasoning:t.Reasoning??LS.Reasoning,Source:t.Source??LS.Source,File:t.File??LS.File,Unstable_Audio:t.Unstable_Audio??LS.Unstable_Audio,...`ChainOfThought`in t?{ChainOfThought:t.ChainOfThought}:{tools:t.tools,data:t.data,ToolGroup:t.ToolGroup??LS.ToolGroup,ReasoningGroup:t.ReasoningGroup??LS.ReasoningGroup},Empty:t.Empty,Quote:t.Quote,generativeUI:t.generativeUI}:yE,...n})};bE.displayName=`MessagePrimitive.Parts`;var xE=({children:e})=>PC()===void 0?null:e;xE.displayName=`MessagePrimitive.Error`;var SE=e=>{let t=new Map;for(let n=0;n<e.length;n++){let r=e[n]?.parentId??`__ungrouped_${n}`,i=t.get(r)??[];i.push(n),t.set(r,i)}let n=[];for(let[e,r]of t){let t=e.startsWith(`__ungrouped_`)?void 0:e;n.push({groupKey:t,indices:r})}return n},CE=e=>{let t=Z(e=>e.message.parts);return(0,_.useMemo)(()=>t.length===0?[]:e(t),[t,e])},wE=({Fallback:e,...t})=>{let n=Z(n=>{let r=n.tools.tools[t.toolName]??e;return Array.isArray(r)?r[0]??e:r});return n?(0,G.jsx)(n,{...t}):null},TE=({Fallback:e,...t})=>{let n=Z(n=>{let r=n.dataRenderers.renderers[t.name]??e;return Array.isArray(r)?r[0]??e:r});return n?(0,G.jsx)(n,{...t}):null},EE={Text:()=>(0,G.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,G.jsx)(rE,{}),(0,G.jsx)(xC,{children:(0,G.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Reasoning:()=>null,Source:()=>null,Image:()=>(0,G.jsx)(iE,{}),File:()=>null,Unstable_Audio:()=>null,Group:({children:e})=>e},DE=({components:{Text:e=EE.Text,Reasoning:t=EE.Reasoning,Image:n=EE.Image,Source:r=EE.Source,File:i=EE.File,Unstable_Audio:a=EE.Unstable_Audio,tools:o={},data:s}={}})=>{let c=Rv(),l=Z(e=>e.part),u=l.type;if(u===`tool-call`){let e=c.part().addToolResult,t=c.part().resumeToolCall,n=c.part().respondToToolApproval;if(`Override`in o)return(0,G.jsx)(o.Override,{...l,addResult:e,resume:t,respondToApproval:n});let r=o.by_name?.[l.toolName]??o.Fallback;return(0,G.jsx)(wE,{...l,Fallback:r,addResult:e,resume:t,respondToApproval:n})}if(l.status?.type===`requires-action`)throw Error(`Encountered unexpected requires-action status`);switch(u){case`text`:return(0,G.jsx)(e,{...l});case`reasoning`:return(0,G.jsx)(t,{...l});case`source`:return(0,G.jsx)(r,{...l});case`image`:return(0,G.jsx)(n,{...l});case`file`:return(0,G.jsx)(i,{...l});case`audio`:return(0,G.jsx)(a,{...l});case`data`:{let e=s?.by_name?.[l.name]??s?.Fallback;return(0,G.jsx)(TE,{...l,Fallback:e})}default:return console.warn(`Unknown message part type: ${u}`),null}},OE=(0,_.memo)(({partIndex:e,components:t})=>(0,G.jsx)(gb,{index:e,children:(0,G.jsx)(DE,{components:t})}),(e,t)=>e.partIndex===t.partIndex&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.Group===t.components?.Group),kE=({status:e,component:t})=>(0,G.jsx)(vb,{text:``,isRunning:e.type===`running`,children:(0,G.jsx)(t,{type:`text`,text:``,status:e})}),AE=Object.freeze({type:`complete`}),jE=(0,_.memo)(({components:e})=>{let t=Z(e=>e.message.status??AE);return e?.Empty?(0,G.jsx)(e.Empty,{status:t}):(0,G.jsx)(kE,{status:t,component:e?.Text??EE.Text})},(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),ME=({groupingFunction:e,components:t})=>{let n=Z(e=>e.message.parts.length),r=CE(e);return(0,G.jsx)(G.Fragment,{children:(0,_.useMemo)(()=>n===0?(0,G.jsx)(jE,{components:t}):r.map((e,n)=>(0,G.jsx)(t?.Group??EE.Group,{groupKey:e.groupKey,indices:e.indices,children:e.indices.map(e=>(0,G.jsx)(OE,{partIndex:e,components:t},e))},`group-${n}-${e.groupKey??`ungrouped`}`)),[r,t,n])})};ME.displayName=`MessagePrimitive.Unstable_PartsGrouped`;var NE=({components:e,...t})=>(0,G.jsx)(ME,{...t,components:e,groupingFunction:SE});NE.displayName=`MessagePrimitive.Unstable_PartsGroupedByParentId`;var PE=QC({AttachmentByIndex:()=>fC,Attachments:()=>mC,Content:()=>bE,Error:()=>xE,GenerativeUI:()=>SS,GroupedParts:()=>cC,If:()=>gw,PartByIndex:()=>zS,Parts:()=>bE,Quote:()=>lC,Root:()=>vE,Unstable_PartsGrouped:()=>ME,Unstable_PartsGroupedByParentId:()=>NE}),FE=e=>{let t=xa(e);return aE((0,_.useCallback)(e=>{let n=new ResizeObserver(()=>{t()}),r=new MutationObserver(e=>{e.some(e=>e.type!==`attributes`||e.attributeName!==`style`)&&t()});return n.observe(e),r.observe(e,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),()=>{n.disconnect(),r.disconnect()}},[t]))},IE=({autoScroll:e,scrollToBottomOnRunStart:t=!0,scrollToBottomOnInitialize:n=!0,scrollToBottomOnThreadSwitch:r=!0})=>{let i=(0,_.useRef)(null),a=Z(e=>e.thread.messages.length>0),o=(0,_.useRef)(!1),s=(0,_.useRef)(null),c=HC();e===void 0&&(e=c.getState().turnAnchor!==`top`);let l=(0,_.useRef)(0),u=(0,_.useRef)(0),d=(0,_.useRef)(0),f=(0,_.useRef)(0),p=(0,_.useRef)(null),m=(0,_.useCallback)(e=>{let t=i.current;t&&(p.current=e,t.scrollTo({top:t.scrollHeight,behavior:e}))},[]),h=(0,_.useCallback)(e=>{p.current=e,s.current!==null&&cancelAnimationFrame(s.current),s.current=requestAnimationFrame(()=>{s.current=null,m(e)})},[m]);(0,_.useLayoutEffect)(()=>()=>{s.current!==null&&cancelAnimationFrame(s.current)},[]);let g=(0,_.useCallback)(()=>{let e=c.getState();return e.turnAnchor===`top`&&e.element.viewport===i.current&&e.element.anchor!==null},[c]),v=()=>{let e=i.current;if(!e)return;let t=c.getState().isAtBottom,n=Math.abs(e.scrollHeight-e.scrollTop-e.clientHeight)<=1||e.scrollHeight<=e.clientHeight;!n&&l.current<e.scrollTop||(n?e.scrollHeight>e.clientHeight+1&&(p.current=null):l.current>e.scrollTop&&u.current===e.scrollHeight&&(p.current=null),(n||p.current===null)&&n!==t&&GC(c).setState({isAtBottom:n})),l.current=e.scrollTop,u.current=e.scrollHeight},y=FE(()=>{let t=i.current;if(!t)return;let{scrollHeight:n,clientHeight:r}=t;if(n===d.current&&r===f.current)return;d.current=n,f.current=r;let a=p.current;a&&g()?p.current=null:a?m(a):e&&c.getState().isAtBottom&&m(`instant`),v()}),b=aE(e=>(e.addEventListener(`scroll`,v),()=>{e.removeEventListener(`scroll`,v)}));return(0,_.useLayoutEffect)(()=>{if(n){if(!a){o.current=!1;return}o.current||(o.current=!0,p.current===null&&h(`instant`))}},[a,h,n]),$w(({behavior:e})=>{m(e)}),Jv(`thread.runStart`,()=>{t&&c.getState().turnAnchor!==`top`&&h(`auto`)}),Jv(`threadListItem.switchedTo`,()=>{r&&h(`instant`)}),ji(y,b,i)},LE=(0,_.forwardRef)((e,t)=>(0,G.jsx)(pw.div,{...e,ref:t}));LE.displayName=`ThreadPrimitive.Root`;var RE=({children:e})=>Z(e=>e.thread.isEmpty)?e:null;RE.displayName=`ThreadPrimitive.Empty`;var zE=e=>Z(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)),BE=({children:e,...t})=>zE(t)?e:null;BE.displayName=`ThreadPrimitive.If`;var VE=(e,t)=>aE((0,_.useCallback)(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()}},[e,t])),HE=e=>{let t=0,n=e;for(;n;)t+=n.offsetTop,n=n.offsetParent;return t},UE=(e,t)=>{let n=0,r=e;for(;r&&r!==t;)n+=r.offsetTop,r=r.offsetParent;return r===t?n:HE(e)-HE(t)},WE=({viewport:e,anchor:t,tallerThan:n,visibleHeight:r})=>{let i=UE(t,e),a=t.offsetHeight;return i+Math.max(0,a-(a<=n?a:r))},GE=({scrollHeight:e,...t})=>{let{viewport:n}=t,r=WE(t)+n.clientHeight;return Math.max(0,r-e)},KE=({viewport:e,reserve:t,...n})=>GE({viewport:e,...n,scrollHeight:e.scrollHeight-t.offsetHeight}),qE=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}},JE=e=>{let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},cancel:()=>{t!==null&&(cancelAnimationFrame(t),t=null)}}},YE=e=>{let t=null,n;function r(){let r=e.getState(),{viewport:o,anchor:s,target:c}=r.element,l=r.targetConfig;if(r.turnAnchor!==`top`||!o||!s||!c||!l){a.disconnect(),t&&(lE(t,0),t.remove());return}if(t??=cE(),(t.parentElement!==c.parentElement||t.previousElementSibling!==c)&&c.after(t),a.target(o,s,c),lE(t,KE({viewport:o,anchor:s,reserve:t,...l}))){i.schedule();return}let u=sE(s);if(u!==void 0&&n===u)return;let d=uE(WE({viewport:o,anchor:s,...l}));Math.abs(o.scrollTop-d)>1&&o.scrollTo({top:d,behavior:`smooth`}),u!==void 0&&(n=u)}let i=JE(r),a=qE(i.schedule);i.schedule();let o=e.subscribe(i.schedule);return()=>{i.cancel(),o(),a.disconnect(),t?.remove()}},XE=e=>{let t=HC();(0,_.useLayoutEffect)(()=>{if(e)return YE(t)},[e,t])},ZE=({isRunning:e,messages:t})=>{if(!e)return null;let n=t.at(-1),r=t.at(-2);return r?.role!==`user`||n?.role!==`assistant`?null:{anchorId:r.id,targetId:n.id}},QE=e=>ZE(e)?.anchorId,$E=e=>ZE(e)?.targetId,eD=()=>VE(VC(e=>e.registerViewport),(0,_.useCallback)(e=>e.clientHeight,[])),tD=()=>aE(VC(e=>e.registerViewportElement)),nD=e=>{let t=HC(),n=Z(t=>{if(e)return QE(t.thread)}),r=Z(t=>{if(e)return $E(t.thread)}),i=(0,_.useMemo)(()=>!n||!r?null:{anchorId:n,targetId:r},[n,r]);(0,_.useLayoutEffect)(()=>{if(!i)return;let e=t.getState(),n=e.topAnchorTurn;n?.anchorId===i.anchorId&&n.targetId===i.targetId||e.setTopAnchorTurn(i)},[i,t]);let a=(0,_.useCallback)(()=>{t.getState().setTopAnchorTurn(null)},[t]);Jv(`thread.initialize`,a),Jv(`threadListItem.switchedTo`,a)},rD=(0,_.forwardRef)(({autoScroll:e,scrollToBottomOnRunStart:t,scrollToBottomOnInitialize:n,scrollToBottomOnThreadSwitch:r,children:i,...a},o)=>{let s=IE({autoScroll:e,scrollToBottomOnRunStart:t,scrollToBottomOnInitialize:n,scrollToBottomOnThreadSwitch:r}),c=eD(),l=tD(),u=HC().getState().turnAnchor===`top`;nD(u),XE(u);let d=ji(o,s,c,l);return(0,G.jsx)(pw.div,{...a,ref:d,children:i})});rD.displayName=`ThreadPrimitive.ViewportScrollable`;var iD=(0,_.forwardRef)(({turnAnchor:e,topAnchorMessageClamp:t,...n},r)=>(0,G.jsx)(qC,{options:{turnAnchor:e,topAnchorMessageClamp:t},children:(0,G.jsx)(rD,{...n,ref:r})}));iD.displayName=`ThreadPrimitive.Viewport`;var aD=(0,_.forwardRef)((e,t)=>{let n=ji(t,VE(VC(e=>e.registerContentInset),(0,_.useCallback)(e=>{let t=parseFloat(getComputedStyle(e).marginTop)||0;return e.offsetHeight+t},[])));return(0,G.jsx)(pw.div,{...e,ref:n})});aD.displayName=`ThreadPrimitive.ViewportFooter`;var oD=mw(`ThreadPrimitive.ScrollToBottom`,({behavior:e}={})=>{let t=VC(e=>e.isAtBottom),n=HC(),r=(0,_.useCallback)(()=>{n.getState().scrollToBottom({behavior:e})},[n,e]);return t?null:r},[`behavior`]),sD=mw(`ThreadPrimitive.Suggestion`,({prompt:e,send:t,clearComposer:n,autoSend:r,method:i})=>{let{disabled:a,trigger:o}=NC({prompt:e,send:t??r??!1,clearComposer:n});return a?null:o},[`prompt`,`send`,`clearComposer`,`autoSend`,`method`]),cD=QC({Empty:()=>RE,If:()=>BE,MessageByIndex:()=>fS,Messages:()=>hS,Root:()=>LE,ScrollToBottom:()=>oD,Suggestion:()=>sD,SuggestionByIndex:()=>CC,Suggestions:()=>EC,Viewport:()=>iD,ViewportFooter:()=>aD,ViewportProvider:()=>qC}),lD=QC({AssistantRuntimeImpl:()=>px,BaseAssistantRuntimeCore:()=>mx,CompositeContextProvider:()=>M_,DefaultThreadComposerRuntimeCore:()=>Hx,MessageRepository:()=>Fx,ThreadRuntimeImpl:()=>ax,fromThreadMessageLike:()=>jx,generateId:()=>Sx,getAutoStatus:()=>kx,splitLocalRuntimeOptions:()=>FC,useComposerInputPluginRegistryOptional:()=>vw,useSmooth:()=>nE,useSmoothStatus:()=>QT,withSmoothContextProvider:()=>XT});function uD(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function dD(e,t){let n=getComputedStyle(e.ownerDocument.documentElement);return t*parseFloat(n.fontSize)}function fD(e){return e/100*window.innerHeight}function pD(e){return e/100*window.innerWidth}function mD(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}function hD({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=mD(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=dD(t,i);break;case`em`:r=uD(t,i);break;case`vh`:r=fD(i);break;case`vw`:r=pD(i);break}return r}function gD(e){return parseFloat(e.toFixed(3))}function _D({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>(e+=t===`horizontal`?n.element.offsetWidth:n.element.offsetHeight,e),0)}function vD(e){let{panels:t}=e,n=_D({group:e});return n===0?t.map(e=>({groupResizeBehavior:e.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:e.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let{element:t,panelConstraints:r}=e,i=0;r.collapsedSize!==void 0&&(i=gD(hD({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=gD(hD({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=gD(hD({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=gD(hD({groupSize:n,panelElement:t,styleProp:r.maxSize})/n*100)),{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsible:r.collapsible===!0,defaultSize:a,disabled:r.disabled,minSize:o,maxSize:s,panelId:e.id}})}function yD(e,t=`Assertion error`){if(!e)throw Error(t)}function bD(e,t){return Array.from(t).sort(e===`horizontal`?xD:SD)}function xD(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function SD(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function CD(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function wD(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function TD({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=wD(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return yD(i,`No rect found`),i}var ED;function DD(){return ED===void 0&&(ED=typeof matchMedia==`function`?!!matchMedia(`(pointer:coarse)`).matches:!1),ED}function OD(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=bD(n,Array.from(t.children).filter(CD).map(e=>({element:e}))).map(({element:e})=>e),o=[],s=!1,c=!1,l=-1,u=-1,d=0,f,p=[];{let e=-1;for(let t of a)t.hasAttribute(`data-panel`)&&(e++,t.hasAttribute(`data-disabled`)||(d++,l===-1&&(l=e),u=e))}if(d>1){let t=-1;for(let d of a)if(d.hasAttribute(`data-panel`)){t++;let i=r.find(e=>e.element===d);if(i){if(f){let r=f.element.getBoundingClientRect(),a=d.getBoundingClientRect(),m;if(c){let e=n===`horizontal`?new DOMRect(r.right,r.top,0,r.height):new DOMRect(r.left,r.bottom,r.width,0),t=n===`horizontal`?new DOMRect(a.left,a.top,0,a.height):new DOMRect(a.left,a.top,a.width,0);switch(p.length){case 0:m=[e,t];break;case 1:{let i=p[0];m=[i,TD({orientation:n,rects:[r,a],targetRect:i.element.getBoundingClientRect()})===r?t:e];break}default:m=p;break}}else m=p.length?p:[n===`horizontal`?new DOMRect(r.right,a.top,a.left-r.right,a.height):new DOMRect(a.left,r.bottom,a.width,a.top-r.bottom)];for(let n of m){let r=`width`in n?n:n.element.getBoundingClientRect(),a=DD()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<a){let e=a-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<a){let e=a-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}!s&&!(t<=l||t>u)&&o.push({group:e,groupSize:_D({group:e}),panels:[f,i],separator:`width`in n?void 0:n,rect:r}),s=!1}}c=!1,f=i,p=[]}}else if(d.hasAttribute(`data-separator`)){d.ariaDisabled!==null&&(s=!0);let e=i.find(e=>e.element===d);e?p.push(e):(f=void 0,p=[])}else c=!0}return o}var kD=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0)if(n.length===1)n[0].call(null,t);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}},AD=new Map,jD=new kD;function MD(e){AD=new Map(AD),AD.delete(e)}function ND(e,t){for(let[t]of AD)if(t.id===e)return t}function PD(e,t){for(let[t,n]of AD)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function FD(){return AD}function ID(e,t){return jD.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function LD(e,t){let n=AD.get(e);AD=new Map(AD),AD.set(e,t),jD.emit(`groupChange`,{group:e,prev:n,next:t})}function RD(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=wD(n,a.rect);switch(e){case`horizontal`:t.x<=i.x&&(r=a,i=t);break;case`vertical`:t.y<=i.y&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function zD(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function BD(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:KD(e),b:KD(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();yD(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:GD(WD(n.a)),b:GD(WD(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var VD=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function HD(e){let t=getComputedStyle(qD(e)??e).display;return t===`flex`||t===`inline-flex`}function UD(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||HD(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||VD.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function WD(e){let t=e.length;for(;t--;){let n=e[t];if(yD(n,`Missing node`),UD(n))return n}return null}function GD(e){return e&&Number(getComputedStyle(e).zIndex)||0}function KD(e){let t=[];for(;e;)t.push(e),e=qD(e);return t}function qD(e){let{parentNode:t}=e;return zD(t)?t.host:t}function JD(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function YD({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!CD(n)||n.contains(e)||e.contains(n))return!0;if(BD(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(JD(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function XD(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=OD(r),a=RD(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&YD({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function ZD(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}function QD(e,t,n=0){return Math.abs(gD(e)-gD(t))<=n}function $D(e,t){return QD(e,t)?0:e>t?1:-1}function eO({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsible:a,disabled:o,maxSize:s=100,minSize:c=0}=t;if(o&&!e)return n;if($D(r,c)<0)if(a){let e=(i+c)/2;r=$D(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=gD(r),r}function tO({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(QD(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;yD(u!=null,`Invalid first pivot index`),yD(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];yD(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(yD(n!=null,`Previous layout not found for panel index ${t}`),QD(n,i)){let t=o-n;$D(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];yD(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(yD(n!=null,`Previous layout not found for panel index ${t}`),QD(n,o)){let t=n-i;$D(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];yD(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&$D(i,c)<0)if(e>0){let t=c-o,n=t/2;$D(i+e,c)<0&&(e=$D(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;$D(i-e,c)<0&&(e=$D(100+e,n)>0?0:-t)}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];yD(e!=null,`Previous layout not found for panel index ${r}`);let a=eO({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];yD(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=eO({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!QD(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(ZD(c,l))return i;{let t=e<0?d:u,r=s[t];yD(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=eO({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!QD(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];yD(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=eO({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(QD(i,s)||(t-=s-i,l[r]=s),QD(t,0))break;e>0?r--:r++}}}if(!QD(Object.values(l).reduce((e,t)=>t+e,0),100,.1))return i;let p=Object.keys(i);return l.reduce((e,t,n)=>(e[p[n]]=t,e),{})}function nO(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||$D(e[n],t[n])!==0)return!1;return!0}function rO({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],i=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(`, `)}`);if(!QD(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];yD(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];yD(i!=null,`No layout data found for index ${e}`);let o=r[e];yD(o!=null,`No layout data found for index ${e}`);let s=eO({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!QD(a,0))for(let e=0;e<t.length;e++){let n=r[e];yD(n!=null,`No layout data found for index ${e}`);let i=n+a,o=eO({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,QD(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function iO({groupId:e,panelId:t}){let n=()=>{let t=FD();for(let[n,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:a,groupSize:o,separatorToPanels:s}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:n,groupSize:o,layout:a,separatorToPanels:s};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().group.panels.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=({nextSize:e,panels:n,prevLayout:r,derivedPanelConstraints:i})=>{let o=a(),s=n.findIndex(e=>e.id===t),c=s===0,l=s===n.length-1;if(l&&e<o&&(c||n.slice(0,s).every((e,t)=>{let n=i[t];return n?.collapsible&&QD(n.collapsedSize,r[n.panelId])}))){let e=n.slice(0,s).reduce((e,t)=>e+r[t.id],0);return{...r,[t]:gD(100-e)}}return tO({delta:l?o-e:e-o,initialLayout:r,panelConstraints:i,pivotIndices:l?[s-1,s]:[s,s+1],prevLayout:r,trigger:`imperative-api`})},s=e=>{if(e===a())return;let{defaultLayoutDeferred:t,derivedPanelConstraints:r,group:i,groupSize:s,layout:c,separatorToPanels:l}=n(),u=rO({layout:o({nextSize:e,panels:i.panels,prevLayout:c,derivedPanelConstraints:r}),panelConstraints:r});nO(c,u)||LD(i,{defaultLayoutDeferred:t,derivedPanelConstraints:r,groupSize:s,layout:u,separatorToPanels:l})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),o=a();e&&o!==t&&(n.expandToSize=o,s(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:o}=i(),c=a();if(e&&c===t){let e=o.expandToSize??n;e===0&&(e=1),s(e)}},getSize:()=>{let{group:e}=n(),t=a(),{element:r}=i();return{asPercentage:t,inPixels:e.orientation===`horizontal`?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&QD(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=_D({group:t});s(gD(hD({groupSize:a,panelElement:r,styleProp:e})/a*100))}}}function aO(e){e.defaultPrevented||XD(e,FD()).forEach(t=>{if(t.separator&&!t.separator.disableDoubleClick){let n=t.panels.find(e=>e.panelConstraints.defaultSize!==void 0);if(n){let r=n.panelConstraints.defaultSize,i=iO({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function oO(e){let t=FD();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function sO({groupId:e}){let t=()=>{let t=FD();for(let[n,r]of t)if(n.id===e)return{group:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:i,groupSize:a,layout:o,separatorToPanels:s}=t(),c=rO({layout:e,panelConstraints:r});return n?o:(nO(o,c)||LD(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function cO(e,t){let n=oO(e),r=PD(n.id,!0),i=n.separators.find(t=>t.element===e);yD(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);yD(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=sO({groupId:n.id}).getLayout(),c=rO({layout:tO({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});nO(s,c)||LD(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels})}function lO(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=oO(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&cO(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&cO(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&cO(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&cO(t,-5);break;case`End`:e.preventDefault(),cO(t,100);break;case`Enter`:{e.preventDefault();let n=oO(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=PD(n.id,!0),o=n.separators.find(e=>e.element===t);yD(o,`Matching separator not found`);let s=a.get(o);yD(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(yD(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];cO(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=oO(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);yD(r!==null,`Index not found`),n[e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0].focus({preventScroll:!0});break}case`Home`:e.preventDefault(),cO(t,-100);break}}var uO={cursorFlags:0,state:`inactive`},dO=new kD;function fO(){return uO}function pO(e){return dO.addListener(`change`,e)}function mO(e){let t=uO,n={...uO};n.cursorFlags=e,uO=n,dO.emit(`change`,{prev:t,next:n})}function hO(e){let t=uO;uO=e,dO.emit(`change`,{prev:t,next:e})}function gO(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=FD(),n=XD(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus({focusVisible:!1,preventScroll:!0})));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),hO({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}var _O=e=>e,vO=()=>{},yO=1,bO=2,xO=4,SO=8,CO=3,wO=12,TO;function EO(){return TO===void 0&&(TO=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(TO=!0)),TO}function DO({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&EO()){let t=(e&yO)!==0,n=(e&bO)!==0,r=(e&xO)!==0,i=(e&SO)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return EO()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var OO=new WeakMap;function kO(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=OO.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));let r=fO();switch(r.state){case`active`:case`hover`:{let e=DO({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(e=>e.group),state:r.state}),i=`*, *:hover {cursor: ${e} !important; }`;if(t===i)return;t=i,e?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}OO.set(e,{prevStyle:t,styleSheet:n})}function AO({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0;n.forEach(e=>{let{group:n,groupSize:o}=e,{orientation:c,panels:l}=n,{disableCursor:u}=n.mutableState,d=0;d=a?c===`horizontal`?(t.clientX-a.x)/o*100:(t.clientY-a.y)/o*100:c===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let f=r.get(n),p=i.get(n);if(!f||!p)return;let{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:_,separatorToPanels:v}=p;if(h&&_&&v){let t=tO({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(nO(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?yO:bO;break;case`vertical`:s|=d<0?xO:SO;break}}else LD(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&CO:c|=s&CO,t.movementY===0?c|=o&wO:c|=s&wO,mO(c),kO(e)}function jO(e){let t=FD(),n=fO();switch(n.state){case`active`:AO({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function MO(e){if(e.defaultPrevented)return;let t=fO(),n=FD();switch(t.state){case`active`:if(e.buttons===0){hO({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=PD(e.group.id,!0);LD(e.group,t)});return}for(let n of t.hitRegions)if(n.separator){let{element:t}=n.separator;t.hasPointerCapture?.(e.pointerId)||t.setPointerCapture?.(e.pointerId)}AO({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=XD(e,n);r.length===0?t.state!==`inactive`&&hO({cursorFlags:0,state:`inactive`}):hO({cursorFlags:0,hitRegions:r,state:`hover`}),kO(e.currentTarget);break}}}function NO(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(fO().state){case`hover`:hO({cursorFlags:0,state:`inactive`})}}function PO(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=fO();switch(t.state){case`active`:hO({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(kO(e.currentTarget),t.hitRegions.forEach(e=>{let t=PD(e.group.id,!0);LD(e.group,t)}),e.preventDefault())}}function FO(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=gD(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=gD((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function IO(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=_D({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:gD(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function LO(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function RO({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,a=0,o=!1,s=new Map,c=[];for(let l of e.panels){let e=r[l.id]??0;switch(l.panelConstraints.groupResizeBehavior){case`preserve-pixel-size`:{o=!0;let r=gD(e/100*n/t*100);s.set(l.id,r),i+=r;break}default:c.push(l.id),a+=e;break}}if(!o||c.length===0)return r;let l=100-i,u={...r};if(s.forEach((e,t)=>{u[t]=e}),a>0)for(let e of c)u[e]=gD((r[e]??0)/a*l);else{let e=gD(l/c.length);for(let t of c)u[t]=e}return u}function zO(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}var BO=new Map;function VO(e){let t=!0;yD(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){let t=_D({group:e});if(t===0)return;let n=PD(e.id);if(!n)return;let r=vD(e),i=n.defaultLayoutDeferred?FO(r):n.layout,a=rO({layout:RO({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&nO(n.layout,a)&&LO(n.derivedPanelConstraints,r)&&n.groupSize===t)return;LD(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else IO(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{yD(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=_D({group:e}),s=vD(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(zO(e.panels,l)||(l=void 0));let u=rO({layout:e.mutableState.layouts[c]??l??FO(s),panelConstraints:s}),d=e.element.ownerDocument;BO.set(d,(BO.get(d)??0)+1);let f=new Map;return OD(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),LD(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,groupSize:o,layout:u,separatorToPanels:f}),e.separators.forEach(e=>{yD(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,lO)}),BO.get(d)===1&&(d.addEventListener(`dblclick`,aO,!0),d.addEventListener(`pointerdown`,gO,!0),d.addEventListener(`pointerleave`,jO),d.addEventListener(`pointermove`,MO),d.addEventListener(`pointerout`,NO),d.addEventListener(`pointerup`,PO,!0)),function(){t=!1,BO.set(d,Math.max(0,(BO.get(d)??0)-1)),MD(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,lO)}),BO.get(d)||(d.removeEventListener(`dblclick`,aO,!0),d.removeEventListener(`pointerdown`,gO,!0),d.removeEventListener(`pointerleave`,jO),d.removeEventListener(`pointermove`,MO),d.removeEventListener(`pointerout`,NO),d.removeEventListener(`pointerup`,PO,!0)),a.disconnect()}}function HO(){let[e,t]=(0,_.useState)({});return[e,(0,_.useCallback)(()=>t({}),[])]}function UO(e){let t=(0,_.useId)();return`${e??t}`}var WO=typeof window<`u`?_.useLayoutEffect:_.useEffect;function GO(e){let t=(0,_.useRef)(e);return WO(()=>{t.current=e},[e]),(0,_.useCallback)((...e)=>t.current?.(...e),[t])}function KO(...e){return GO(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function qO(e){let t=(0,_.useRef)({...e});return WO(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var JO=(0,_.createContext)(null);function YO(e,t){let n=(0,_.useRef)({getLayout:()=>({}),setLayout:_O});(0,_.useImperativeHandle)(t,()=>n.current,[]),WO(()=>{Object.assign(n.current,sO({groupId:e}))})}function XO({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){let m=(0,_.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=GO(e=>{nO(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=GO(e=>{nO(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e))}),v=UO(s),y=(0,_.useRef)(null),[b,x]=HO(),S=(0,_.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),C=KO(y,a);YO(v,o);let w=GO((e,t)=>{let r=fO(),i=ND(e),a=PD(e);if(a){let e=!1;switch(r.state){case`active`:e=r.hitRegions.some(e=>e.group===i);break}return{flexGrow:a.layout[t]??1,pointerEvents:e?`none`:void 0}}if(n?.[t])return{flexGrow:n?.[t]}}),T=qO({defaultLayout:n,disableCursor:r}),E=(0,_.useMemo)(()=>({get disableCursor(){return!!T.disableCursor},getPanelStyles:w,id:v,orientation:u,registerPanel:e=>{let t=S.current;return t.panels=bD(u,[...t.panels,e]),x(),()=>{t.panels=t.panels.filter(t=>t!==e),x()}},registerSeparator:e=>{let t=S.current;return t.separators=bD(u,[...t.separators,e]),x(),()=>{t.separators=t.separators.filter(t=>t!==e),x()}},updatePanelProps:(e,{disabled:t})=>{let n=S.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let r=ND(v),i=PD(v);r&&i&&LD(r,{...i,derivedPanelConstraints:vD(r)})},updateSeparatorProps:(e,{disabled:t,disableDoubleClick:n})=>{let r=S.current.separators.find(t=>t.id===e);r&&(r.disabled=t,r.disableDoubleClick=n)}}),[w,v,x,u,T]),D=(0,_.useRef)(null);return WO(()=>{let e=y.current;if(e===null)return;let t=S.current,n;if(T.defaultLayout!==void 0&&Object.keys(T.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=T.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={disabled:!!i,element:e,id:v,mutableState:{defaultLayout:n,disableCursor:!!T.disableCursor,expandedPanelSizes:S.current.lastExpandedPanelSizes,layouts:S.current.layouts},orientation:u,panels:t.panels,resizeTargetMinimumSize:t.resizeTargetMinimumSize,separators:t.separators};D.current=r;let a=VO(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=PD(r.id,!0);!o&&s.length>0&&(h(c),g(c));let l=ID(v,e=>{let{defaultLayoutDeferred:t,derivedPanelConstraints:n,layout:i}=e.next;if(t||n.length===0)return;let a=r.panels.map(({id:e})=>e).join(`,`);r.mutableState.layouts[a]=i,n.forEach(t=>{if(t.collapsible){let{layout:n}=e.prev??{};if(n){let e=QD(t.collapsedSize,i[t.panelId]),a=QD(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=fO().state!==`active`;h(i),o&&g(i)});return()=>{D.current=null,a(),l()}},[i,v,g,h,u,b,T]),(0,_.useEffect)(()=>{let e=D.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,G.jsx)(JO.Provider,{value:E,children:(0,G.jsx)(`div`,{...p,className:t,"data-group":!0,"data-testid":v,id:v,ref:C,style:{height:`100%`,width:`100%`,overflow:`hidden`,...f,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:e})})}XO.displayName=`Group`;function ZO(){let e=(0,_.useContext)(JO);return yD(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function QO(e,t){let{id:n}=ZO(),r=(0,_.useRef)({collapse:vO,expand:vO,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:vO});(0,_.useImperativeHandle)(t,()=>r.current,[]),WO(()=>{Object.assign(r.current,iO({groupId:n,panelId:e}))})}function $O({children:e,className:t,collapsedSize:n=`0%`,collapsible:r=!1,defaultSize:i,disabled:a,elementRef:o,groupResizeBehavior:s=`preserve-relative-size`,id:c,maxSize:l=`100%`,minSize:u=`0%`,onResize:d,panelRef:f,style:p,...m}){let h=!!c,g=UO(c),v=qO({disabled:a}),y=(0,_.useRef)(null),b=KO(y,o),{getPanelStyles:x,id:S,orientation:C,registerPanel:w,updatePanelProps:T}=ZO(),E=d!==null,D=GO((e,t,n)=>{d?.(e,c,n)});WO(()=>{let e=y.current;if(e!==null)return w({element:e,id:g,idIsStable:h,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:E?D:void 0,panelConstraints:{groupResizeBehavior:s,collapsedSize:n,collapsible:r,defaultSize:i,disabled:v.disabled,maxSize:l,minSize:u}})},[s,n,r,i,E,g,h,l,u,D,w,v]),(0,_.useEffect)(()=>{T(g,{disabled:a})},[a,g,T]),QO(g,f);let O=()=>{let e=x(S,g);if(e)return JSON.stringify(e)},k=(0,_.useSyncExternalStore)(e=>ID(S,e),O,O),A;return A=k?JSON.parse(k):i===void 0?{flexGrow:1}:{flexGrow:void 0,flexShrink:void 0,flexBasis:i},(0,G.jsx)(`div`,{...m,"data-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:b,style:{...ek,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...A},children:(0,G.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:C===`horizontal`?`pan-y`:`pan-x`},children:e})})}$O.displayName=`Panel`;var ek={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function tk({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a,o=e[n],s=t.find(e=>e.panelId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=rO({layout:tO({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=rO({layout:tO({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function nk({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=UO(a),l=qO({disabled:n,disableDoubleClick:r}),[u,d]=(0,_.useState)({}),[f,p]=(0,_.useState)(`inactive`),[m,h]=(0,_.useState)(!1),g=(0,_.useRef)(null),v=KO(g,i),{disableCursor:y,id:b,orientation:x,registerSeparator:S,updateSeparatorProps:C}=ZO(),w=x===`horizontal`?`vertical`:`horizontal`;WO(()=>{let e=g.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=S(t),r=pO(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=ID(b,e=>{let{derivedPanelConstraints:n,layout:r,separatorToPanels:i}=e.next,a=i.get(t);if(a){let e=a[0],t=a.indexOf(e);d(tk({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[b,c,S,l]),(0,_.useEffect)(()=>{C(c,{disabled:n,disableDoubleClick:r})},[n,r,c,C]);let T;n&&!y&&(T=`not-allowed`);let E;if(n)E=`disabled`;else switch(f){case`active`:E=`active`;break;default:E=m?`focus`:f}return(0,G.jsx)(`div`,{...s,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":w,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":E,"data-testid":c,id:c,onBlur:()=>h(!1),onFocus:()=>h(!0),ref:v,role:`separator`,style:{flexBasis:`auto`,cursor:T,...o,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}nk.displayName=`Separator`;var rk=(e,t)=>typeof e==`string`?e===t:JSON.stringify(e)===JSON.stringify(t),ik=(e,t)=>{if(!e||!t)return!1;let n=e=>{let{position:t,data:n,...r}=e||{};return r};return JSON.stringify(n(e.properties))===JSON.stringify(n(t.properties))&&rk(e.children,t.children)},ak=(e,t)=>ik(e.node,t.node),ok=(e={})=>Object.fromEntries(Object.entries(e??{}).map(([e,t])=>{if(!t)return[e,t];let n=t;return[e,(0,_.memo)(({node:e,...t})=>(0,G.jsx)(n,{...t}),ak)]})),sk=(0,_.createContext)(null),ck=()=>(0,_.useContext)(sk)!==null,lk=(0,_.memo)(({children:e,...t})=>(0,G.jsx)(sk.Provider,{value:t,children:e}),ak),uk=({node:e,...t})=>(0,G.jsx)(`pre`,{...t}),dk=({node:e,...t})=>(0,G.jsx)(`code`,{...t}),fk=({node:e,components:{Pre:t,Code:n},code:r})=>(0,G.jsx)(t,{children:(0,G.jsx)(n,{node:e,children:r})}),pk=()=>null,mk=({node:e,components:{Pre:t,Code:n,SyntaxHighlighter:r,CodeHeader:i},language:a,code:o})=>{let s=(0,_.useMemo)(()=>({Pre:t,Code:n}),[t,n]);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(i,{node:e,language:a,code:o}),(0,G.jsx)(a?r:fk,{node:e,components:s,language:a??`unknown`,code:o})]})},hk=n(r(((e,t)=>{(function(){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),gk=({className:e,...t})=>({className:n,...r})=>({className:(0,hk.default)(e,n),...t,...r}),_k=({node:e,components:{Pre:t,Code:n,SyntaxHighlighter:r,CodeHeader:i},componentsByLanguage:a={},children:o,...s})=>{let c=gk((0,_.useContext)(sk)),l=xa(e=>(0,G.jsx)(t,{...c(e)})),u=gk(s),d=xa(e=>(0,G.jsx)(n,{...u(e)})),f=/language-(\w+)/.exec(s.className||``)?.[1]??``;return typeof o==`string`?(0,G.jsx)(mk,{node:e,components:{Pre:l,Code:d,SyntaxHighlighter:a[f]?.SyntaxHighlighter??r,CodeHeader:a[f]?.CodeHeader??i},language:f||`unknown`,code:o}):(0,G.jsx)(fk,{node:e,components:{Pre:l,Code:d},code:o})},vk=(0,_.memo)(({node:e,components:t,componentsByLanguage:n,...r})=>ck()?(0,G.jsx)(_k,{node:e,components:t,componentsByLanguage:n,...r}):(0,G.jsx)(t.Code,{...r}),(e,t)=>e.components===t.components&&e.componentsByLanguage===t.componentsByLanguage&&ak(e,t));function yk(){}function bk(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var xk=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Sk=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ck={};function wk(e,t){return((t||Ck).jsx?Sk:xk).test(e)}var Tk=/[ \t\n\f\r]/g;function Ek(e){return typeof e==`object`?e.type===`text`?Dk(e.value):!1:Dk(e)}function Dk(e){return e.replace(Tk,``)===``}var Ok=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};Ok.prototype.normal={},Ok.prototype.property={},Ok.prototype.space=void 0;function kk(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new Ok(n,r,t)}function Ak(e){return e.toLowerCase()}var jk=class{constructor(e,t){this.attribute=t,this.property=e}};jk.prototype.attribute=``,jk.prototype.booleanish=!1,jk.prototype.boolean=!1,jk.prototype.commaOrSpaceSeparated=!1,jk.prototype.commaSeparated=!1,jk.prototype.defined=!1,jk.prototype.mustUseProperty=!1,jk.prototype.number=!1,jk.prototype.overloadedBoolean=!1,jk.prototype.property=``,jk.prototype.spaceSeparated=!1,jk.prototype.space=void 0;var Mk=e({boolean:()=>Pk,booleanish:()=>Fk,commaOrSpaceSeparated:()=>zk,commaSeparated:()=>Rk,number:()=>Q,overloadedBoolean:()=>Ik,spaceSeparated:()=>Lk}),Nk=0,Pk=Bk(),Fk=Bk(),Ik=Bk(),Q=Bk(),Lk=Bk(),Rk=Bk(),zk=Bk();function Bk(){return 2**++Nk}var Vk=Object.keys(Mk),Hk=class extends jk{constructor(e,t,n,r){let i=-1;if(super(e,t),Uk(this,`space`,r),typeof n==`number`)for(;++i<Vk.length;){let e=Vk[i];Uk(this,Vk[i],(n&Mk[e])===Mk[e])}}};Hk.prototype.defined=!0;function Uk(e,t,n){n&&(e[t]=n)}function Wk(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new Hk(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[Ak(r)]=r,n[Ak(a.attribute)]=r}return new Ok(t,n,e.space)}var Gk=Wk({properties:{ariaActiveDescendant:null,ariaAtomic:Fk,ariaAutoComplete:null,ariaBusy:Fk,ariaChecked:Fk,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:Lk,ariaCurrent:null,ariaDescribedBy:Lk,ariaDetails:null,ariaDisabled:Fk,ariaDropEffect:Lk,ariaErrorMessage:null,ariaExpanded:Fk,ariaFlowTo:Lk,ariaGrabbed:Fk,ariaHasPopup:null,ariaHidden:Fk,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Lk,ariaLevel:Q,ariaLive:null,ariaModal:Fk,ariaMultiLine:Fk,ariaMultiSelectable:Fk,ariaOrientation:null,ariaOwns:Lk,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:Fk,ariaReadOnly:Fk,ariaRelevant:null,ariaRequired:Fk,ariaRoleDescription:Lk,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:Fk,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function Kk(e,t){return t in e?e[t]:t}function qk(e,t){return Kk(e,t.toLowerCase())}var Jk=Wk({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:Rk,acceptCharset:Lk,accessKey:Lk,action:null,allow:null,allowFullScreen:Pk,allowPaymentRequest:Pk,allowUserMedia:Pk,alpha:Pk,alt:null,as:null,async:Pk,autoCapitalize:null,autoComplete:Lk,autoFocus:Pk,autoPlay:Pk,blocking:Lk,capture:null,charSet:null,checked:Pk,cite:null,className:Lk,closedBy:null,colorSpace:null,cols:Q,colSpan:Q,command:null,commandFor:null,content:null,contentEditable:Fk,controls:Pk,controlsList:Lk,coords:Q|Rk,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Pk,defer:Pk,dir:null,dirName:null,disabled:Pk,download:Ik,draggable:Fk,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Pk,formTarget:null,headers:Lk,height:Q,hidden:Ik,high:Q,href:null,hrefLang:null,htmlFor:Lk,httpEquiv:Lk,id:null,imageSizes:null,imageSrcSet:null,inert:Pk,inputMode:null,integrity:null,is:null,isMap:Pk,itemId:null,itemProp:Lk,itemRef:Lk,itemScope:Pk,itemType:Lk,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Pk,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:Pk,muted:Pk,name:null,nonce:null,noModule:Pk,noValidate:Pk,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:Pk,optimum:Q,pattern:null,ping:Lk,placeholder:null,playsInline:Pk,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Pk,referrerPolicy:null,rel:Lk,required:Pk,reversed:Pk,rows:Q,rowSpan:Q,sandbox:Lk,scope:null,scoped:Pk,seamless:Pk,selected:Pk,shadowRootClonable:Pk,shadowRootCustomElementRegistry:Pk,shadowRootDelegatesFocus:Pk,shadowRootMode:null,shadowRootSerializable:Pk,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:Fk,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:Pk,useMap:null,value:Fk,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Lk,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Pk,declare:Pk,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:Pk,noHref:Pk,noShade:Pk,noWrap:Pk,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:Fk,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Pk,disablePictureInPicture:Pk,disableRemotePlayback:Pk,exportParts:Rk,part:Lk,prefix:null,property:null,results:Q,security:null,unselectable:null},space:`html`,transform:qk}),Yk=Wk({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:zk,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:Lk,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:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:Pk,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,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:Rk,g2:Rk,glyphName:Rk,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:zk,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,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:Q,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:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Lk,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:zk,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:zk,rev:zk,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:zk,requiredFeatures:zk,requiredFonts:zk,requiredFormats:zk,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:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:zk,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:zk,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:zk,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:Kk}),Xk=Wk({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()}}),Zk=Wk({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:qk}),Qk=Wk({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),$k={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`},eA=/[A-Z]/g,tA=/-[a-z]/g,nA=/^data[-\w.:]+$/i;function rA(e,t){let n=Ak(t),r=t,i=jk;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&nA.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(tA,aA);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!tA.test(e)){let n=e.replace(eA,iA);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=Hk}return new i(r,t)}function iA(e){return`-`+e.toLowerCase()}function aA(e){return e.charAt(1).toUpperCase()}var oA=kk([Gk,Jk,Xk,Zk,Qk],`html`),sA=kk([Gk,Yk,Xk,Zk,Qk],`svg`);function cA(e){return e.join(` `).trim()}var lA=r(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
|
|
59
59
|
`,d=`/`,f=`*`,p=``,m=`comment`,h=`declaration`;function g(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,g=1;function v(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(u);g=~n?e.length-n:g+e.length}function y(){var e={line:l,column:g};return function(t){return t.position=new b(e),C(),t}}function b(e){this.start=e,this.end={line:l,column:g},this.source=t.source}b.prototype.content=e;function x(n){var r=Error(t.source+`:`+l+`:`+g+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=g,r.source=e,!t.silent)throw r}function S(t){var n=t.exec(e);if(n){var r=n[0];return v(r),e=e.slice(r.length),n}}function C(){S(i)}function w(e){var t;for(e||=[];t=T();)t!==!1&&e.push(t);return e}function T(){var t=y();if(!(d!=e.charAt(0)||f!=e.charAt(1))){for(var n=2;p!=e.charAt(n)&&(f!=e.charAt(n)||d!=e.charAt(n+1));)++n;if(n+=2,p===e.charAt(n-1))return x(`End of comment missing`);var r=e.slice(2,n-2);return g+=2,v(r),e=e.slice(n),g+=2,t({type:m,comment:r})}}function E(){var e=y(),t=S(a);if(t){if(T(),!S(o))return x(`property missing ':'`);var r=S(s),i=e({type:h,property:_(t[0].replace(n,p)),value:r?_(r[0].replace(n,p)):p});return S(c),i}}function D(){var e=[];w(e);for(var t;t=E();)t!==!1&&(e.push(t),w(e));return e}return C(),D()}function _(e){return e?e.replace(l,p):p}t.exports=g})),uA=r((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(lA());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),dA=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),fA=r(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(uA()),r=dA();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),pA=hA(`end`),mA=hA(`start`);function hA(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 gA(e){let t=mA(e),n=pA(e);if(t&&n)return{start:t,end:n}}function _A(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?yA(e.position):`start`in e||`end`in e?yA(e):`line`in e||`column`in e?vA(e):``}function vA(e){return bA(e&&e.line)+`:`+bA(e&&e.column)}function yA(e){return vA(e&&e.start)+`-`+vA(e&&e.end)}function bA(e){return e&&typeof e==`number`?e:1}var xA=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}:{...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=_A(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}};xA.prototype.file=``,xA.prototype.name=``,xA.prototype.reason=``,xA.prototype.message=``,xA.prototype.stack=``,xA.prototype.column=void 0,xA.prototype.line=void 0,xA.prototype.ancestors=void 0,xA.prototype.cause=void 0,xA.prototype.fatal=void 0,xA.prototype.place=void 0,xA.prototype.ruleId=void 0,xA.prototype.source=void 0;var SA=n(fA(),1),CA={}.hasOwnProperty,wA=new Map,TA=/[A-Z]/g,EA=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),DA=new Set([`td`,`th`]);function OA(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=zA(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=RA(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`?sA:oA,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=kA(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function kA(e,t,n){if(t.type===`element`)return AA(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return jA(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return NA(e,t,n);if(t.type===`mdxjsEsm`)return MA(e,t);if(t.type===`root`)return PA(e,t,n);if(t.type===`text`)return FA(e,t)}function AA(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=sA,e.schema=i),e.ancestors.push(t);let a=GA(e,t.tagName,!1),o=BA(e,t),s=HA(e,t);return EA.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!Ek(e):!0})),IA(e,o,a,t),LA(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function jA(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)}KA(e,t.position)}function MA(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);KA(e,t.position)}function NA(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=sA,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:GA(e,t.name,!0),o=VA(e,t),s=HA(e,t);return IA(e,o,a,t),LA(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function PA(e,t,n){let r={};return LA(r,HA(e,t)),e.create(t,e.Fragment,r,n)}function FA(e,t){return t.value}function IA(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function LA(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function RA(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 zA(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=mA(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 BA(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&CA.call(t.properties,i)){let a=UA(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&DA.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function VA(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 KA(e,t.position);else{let i=r.name,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 KA(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function HA(e,t){let n=[],r=-1,i=e.passKeys?new Map:wA;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=kA(e,a,o);s!==void 0&&n.push(s)}return n}function UA(e,t,n){let r=rA(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?bk(n):cA(n)),r.property===`style`){let t=typeof n==`object`?n:WA(e,String(n));return e.stylePropertyNameCase===`css`&&(t=qA(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?$k[r.property]||r.property:r.attribute,n]}}function WA(e,t){try{return(0,SA.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new xA("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=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-parse-style-attribute`,r}}function GA(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=wk(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=wk(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return CA.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);KA(e)}function KA(e,t){let n=new xA("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=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-handle-mdx-estrees-without-createevaluater`,n}function qA(e){let t={},n;for(n in e)CA.call(e,n)&&(t[JA(n)]=e[n]);return t}function JA(e){let t=e.replace(TA,YA);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function YA(e){return`-`+e.toLowerCase()}var XA={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`]},ZA={};function QA(e,t){let n=t||ZA;return $A(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function $A(e,t,n){if(tj(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 ej(e.children,t,n)}return Array.isArray(e)?ej(e,t,n):``}function ej(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=$A(e[i],t,n);return r.join(``)}function tj(e){return!!(e&&typeof e==`object`)}var nj=document.createElement(`i`);function rj(e){let t=`&`+e+`;`;nj.innerHTML=t;let n=nj.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function ij(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 aj(e,t){return e.length>0?(ij(e,e.length,0,t),e):t}var oj={}.hasOwnProperty;function sj(e){let t={},n=-1;for(;++n<e.length;)cj(t,e[n]);return t}function cj(e,t){let n;for(n in t){let r=(oj.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){oj.call(r,a)||(r[a]=[]);let e=i[a];lj(r[a],Array.isArray(e)?e:e?[e]:[])}}}function lj(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);ij(e,0,0,r)}function uj(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 dj(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var fj=Cj(/[A-Za-z]/),pj=Cj(/[\dA-Za-z]/),mj=Cj(/[#-'*+\--9=?A-Z^-~]/);function hj(e){return e!==null&&(e<32||e===127)}var gj=Cj(/\d/),_j=Cj(/[\dA-Fa-f]/),vj=Cj(/[!-/:-@[-`{-~]/);function $(e){return e!==null&&e<-2}function yj(e){return e!==null&&(e<0||e===32)}function bj(e){return e===-2||e===-1||e===32}var xj=Cj(/\p{P}|\p{S}/u),Sj=Cj(/\s/);function Cj(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function wj(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&pj(e.charCodeAt(n+1))&&pj(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,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function Tj(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return bj(r)?(e.enter(n),s(r)):t(r)}function s(r){return bj(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var Ej={tokenize:Dj};function Dj(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Tj(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);return}return $(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var Oj={tokenize:Aj},kj={tokenize:jj};function Aj(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={...o},s++;return ij(t.events,a+1,0,t.events.slice(n)),t.events.length=s,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(kj,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(kj,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);return}return 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);return}return $(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={...c},e++;ij(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}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 jj(e,t,n){return Tj(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function Mj(e){if(e===null||yj(e)||Sj(e))return 1;if(xj(e))return 2}function Nj(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 Pj={name:`attention`,resolveAll:Fj,tokenize:Ij};function Fj(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};Lj(d,-c),Lj(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=aj(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=aj(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=aj(l,Nj(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=aj(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=aj(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,ij(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function Ij(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Mj(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=Mj(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function Lj(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Rj={name:`autolink`,tokenize:zj};function zj(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 fj(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||pj(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||pj(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||hj(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):mj(t)?(e.consume(t),l):n(t)}function u(e){return pj(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||pj(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var Bj={partial:!0,tokenize:Vj};function Vj(e,t,n){return r;function r(t){return bj(t)?Tj(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||$(e)?t(e):n(e)}}var Hj={continuation:{tokenize:Wj},exit:Gj,name:`blockQuote`,tokenize:Uj};function Uj(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}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return bj(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function Wj(e,t,n){let r=this;return i;function i(t){return bj(t)?Tj(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(Hj,t,n)(r)}}function Gj(e){e.exit(`blockQuote`)}var Kj={name:`characterEscape`,tokenize:qj};function qj(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 vj(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var Jj={name:`characterReference`,tokenize:Yj};function Yj(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=pj,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=_j,u):(e.enter(`characterReferenceValue`),a=7,o=gj,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===pj&&!rj(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 Xj={partial:!0,tokenize:$j},Zj={concrete:!0,name:`codeFenced`,tokenize:Qj};function Qj(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`),bj(t)?Tj(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||$(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(Xj,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||$(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):bj(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),Tj(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||$(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||$(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&&bj(t)?Tj(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||$(t)?e.check(Xj,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||$(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`),bj(t)?Tj(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`),bj(t)?Tj(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||$(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function $j(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 eM={name:`codeIndented`,tokenize:nM},tM={partial:!0,tokenize:rM};function nM(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),Tj(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):$(t)?e.attempt(tM,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||$(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function rM(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):$(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):Tj(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):$(e)?i(e):n(e)}}var iM={name:`codeText`,previous:oM,resolve:aM,tokenize:sM};function aM(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 oM(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function sM(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)):$(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||$(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 cM=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??1/0;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&&lM(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),lM(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),lM(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);lM(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);lM(this.left,t.reverse())}}};function lM(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 uM(e){let t={},n=-1,r,i,a,o,s,c,l,u=new cM(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,dM(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={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return ij(e,0,1/0,u.slice(0)),!l}function dM(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 fM={resolve:mM,tokenize:hM},pM={partial:!0,tokenize:gM};function mM(e){return uM(e),e}function hM(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):$(t)?e.check(pM,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 gM(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Tj(e,a,`linePrefix`)}function a(i){if(i===null||$(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 _M(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||hj(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||$(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||yj(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||hj(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 vM(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):$(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||$(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!bj(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function yM(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):$(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Tj(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||$(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 bM(e,t){let n;return r;function r(i){return $(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):bj(i)?Tj(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var xM={name:`definition`,tokenize:CM},SM={partial:!0,tokenize:wM};function CM(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return vM.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=dj(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 yj(t)?bM(e,l)(t):l(t)}function l(t){return _M(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(SM,d,d)(t)}function d(t){return bj(t)?Tj(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||$(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function wM(e,t,n){return r;function r(t){return yj(t)?bM(e,i)(t):n(t)}function i(t){return yM(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return bj(t)?Tj(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||$(e)?t(e):n(e)}}var TM={name:`hardBreakEscape`,tokenize:EM};function EM(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return $(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var DM={name:`headingAtx`,resolve:OM,tokenize:kM};function OM(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(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`},ij(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function kM(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||yj(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||$(n)?(e.exit(`atxHeading`),t(n)):bj(n)?Tj(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||yj(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var AM=`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(`.`),jM=[`pre`,`script`,`style`,`textarea`],MM={concrete:!0,name:`htmlFlow`,resolveTo:FM,tokenize:IM},NM={partial:!0,tokenize:RM},PM={partial:!0,tokenize:LM};function FM(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 IM(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):fj(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):fj(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 fj(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||yj(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&jM.includes(l)?(i=1,r.interrupt?t(s):O(s)):AM.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||pj(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 bj(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||fj(t)?(e.consume(t),b):bj(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||pj(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):bj(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):bj(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||$(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||yj(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||bj(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||$(t)?O(t):bj(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):$(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(NM,R,k)(t)):t===null||$(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(PM,A,R)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||$(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 jM.includes(n)?(e.consume(t),L):O(t)}return fj(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||$(t)?(e.exit(`htmlFlowData`),R(t)):(e.consume(t),L)}function R(n){return e.exit(`htmlFlow`),t(n)}}function LM(e,t,n){let r=this;return i;function i(t){return $(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function RM(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(Bj,t,n)}}var zM={name:`htmlText`,tokenize:BM};function BM(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):fj(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):fj(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):$(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):$(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):$(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):$(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return fj(t)?(e.consume(t),S):n(t)}function S(t){return t===45||pj(t)?(e.consume(t),S):C(t)}function C(t){return $(t)?(o=C,N(t)):bj(t)?(e.consume(t),C):M(t)}function w(t){return t===45||pj(t)?(e.consume(t),w):t===47||t===62||yj(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||fj(t)?(e.consume(t),E):$(t)?(o=T,N(t)):bj(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||pj(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):$(t)?(o=D,N(t)):bj(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):$(t)?(o=O,N(t)):bj(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):$(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||yj(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||yj(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 bj(t)?Tj(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 VM={name:`labelEnd`,resolveAll:GM,resolveTo:KM,tokenize:qM},HM={tokenize:JM},UM={tokenize:YM},WM={tokenize:XM};function GM(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&&ij(e,0,e.length,n),e}function KM(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=aj(s,e.slice(a+1,a+r+3)),s=aj(s,[[`enter`,u,t]]),s=aj(s,Nj(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=aj(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=aj(s,e.slice(o+1)),s=aj(s,[[`exit`,c,t]]),ij(e,a,e.length,s),e}function qM(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(dj(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(HM,u,o?u:d)(t):t===91?e.attempt(UM,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(WM,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function JM(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 yj(t)?bM(e,a)(t):a(t)}function a(t){return t===41?u(t):_M(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return yj(t)?bM(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?yM(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return yj(t)?bM(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 YM(e,t,n){let r=this;return i;function i(t){return vM.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(dj(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function XM(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 ZM={name:`labelStartImage`,resolveAll:VM.resolveAll,tokenize:QM};function QM(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var $M={name:`labelStartLink`,resolveAll:VM.resolveAll,tokenize:eN};function eN(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var tN={name:`lineEnding`,tokenize:nN};function nN(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Tj(e,t,`linePrefix`)}}var rN={name:`thematicBreak`,tokenize:iN};function iN(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||$(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),bj(t)?Tj(e,s,`whitespace`)(t):s(t))}}var aN={continuation:{tokenize:lN},exit:dN,name:`list`,tokenize:cN},oN={partial:!0,tokenize:fN},sN={partial:!0,tokenize:uN};function cN(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:gj(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(rN,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 gj(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(Bj,r.interrupt?n:u,e.attempt(oN,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return bj(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 lN(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Bj,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Tj(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!bj(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(sN,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,Tj(e,e.attempt(aN,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function uN(e,t,n){let r=this;return Tj(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 dN(e){e.exit(this.containerState.type)}function fN(e,t,n){let r=this;return Tj(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!bj(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var pN={name:`setextUnderline`,resolveTo:mN,tokenize:hN};function mN(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function hN(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`),bj(t)?Tj(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||$(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var gN={tokenize:_N};function _N(e){let t=this,n=e.attempt(Bj,r,e.attempt(this.parser.constructs.flowInitial,i,Tj(e,e.attempt(this.parser.constructs.flow,i,e.attempt(fM,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var vN={resolveAll:SN()},yN=xN(`string`),bN=xN(`text`);function xN(e){return{resolveAll:SN(e===`text`?CN: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);return}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 SN(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 CN(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var wN=e({attentionMarkers:()=>MN,contentInitial:()=>EN,disable:()=>NN,document:()=>TN,flow:()=>ON,flowInitial:()=>DN,insideSpan:()=>jN,string:()=>kN,text:()=>AN}),TN={42:aN,43:aN,45:aN,48:aN,49:aN,50:aN,51:aN,52:aN,53:aN,54:aN,55:aN,56:aN,57:aN,62:Hj},EN={91:xM},DN={[-2]:eM,[-1]:eM,32:eM},ON={35:DM,42:rN,45:[pN,rN],60:MM,61:pN,95:rN,96:Zj,126:Zj},kN={38:Jj,92:Kj},AN={[-5]:tN,[-4]:tN,[-3]:tN,33:ZM,38:Jj,42:Pj,60:[Rj,zM],91:$M,92:[TM,Kj],93:VM,95:Pj,96:iM},jN={null:[Pj,vN]},MN={null:[42,95]},NN={null:[]};function PN(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=aj(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=Nj(a,l.events,l),l.events):[]}function f(e,t){return IN(p(e),t)}function p(e){return FN(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(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){$(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&&ij(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 FN(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 IN(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=`
|
|
60
60
|
`;break;case-3:o=`\r
|
|
61
61
|
`;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 LN(e){let t={constructs:sj([wN,...(e||{}).extensions||[]]),content:n(Ej),defined:[],document:n(Oj),flow:n(gN),lazy:{},string:n(yN),text:n(bN)};return t;function n(e){return n;function n(n){return PN(t,e,n)}}}function RN(e){for(;!uM(e););return e}var zN=/[\0\t\n\r]/g;function BN(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(zN.lastIndex=u,c=zN.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var VN=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function HN(e){return e.replace(VN,UN)}function UN(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return uj(n.slice(t?2:1),t?16:10)}return rj(n)||e}var WN={}.hasOwnProperty;function GN(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),KN(n)(RN(LN(n).document().write(BN()(e,t,!0))))}function KN(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(ue),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(oe),blockQuote:a(te),characterEscape:T,characterReference:T,codeFenced:a(ne),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(ne,o),codeText:a(re,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(ie),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(ae),hardBreakEscape:a(se),hardBreakTrailing:a(se),htmlFlow:a(ce,o),htmlFlowData:T,htmlText:a(ce,o),htmlTextData:T,image:a(le),label:o,link:a(ue),listItem:a(fe),listItemValue:f,listOrdered:a(de,d),listUnordered:a(de),paragraph:a(pe),reference:z,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(oe),strong:a(me),thematicBreak:a(ge)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:W,autolinkProtocol:ee,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:V,characterReferenceMarkerNumeric:V,characterReferenceValue:H,characterReference:U,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(N),label:F,labelText:P,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:B,resourceDestinationString:I,resourceTitleString:L,resource:R,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};JN(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];WN.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||XN).call(a,void 0,e[0])}for(r.position={start:qN(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:qN(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;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 i=r;for(s=void 0;i--;){let t=e[i];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=i}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),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(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:qN(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||XN).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+_A({start:e.start,end:e.end})+`): it’s not open`);n.position.end=qN(e.end)}function u(){return QA(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(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 p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){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 _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=dj(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=he(),n.position={start:qN(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=qN(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=qN(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){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 N(){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 P(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=HN(t),n.identifier=dj(t).toLowerCase()}function F(){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 I(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function L(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function R(){this.data.inReference=void 0}function z(){this.data.referenceType=`collapsed`}function B(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=dj(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function V(e){this.data.characterReferenceType=e.type}function H(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=uj(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=rj(t);let i=this.stack[this.stack.length-1];i.value+=r}function U(e){let t=this.stack.pop();t.position.end=qN(e.end)}function ee(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function W(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function te(){return{type:`blockquote`,children:[]}}function ne(){return{type:`code`,lang:null,meta:null,value:``}}function re(){return{type:`inlineCode`,value:``}}function ie(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function ae(){return{type:`emphasis`,children:[]}}function oe(){return{type:`heading`,depth:0,children:[]}}function se(){return{type:`break`}}function ce(){return{type:`html`,value:``}}function le(){return{type:`image`,title:null,url:``,alt:null}}function ue(){return{type:`link`,title:null,url:``,children:[]}}function de(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function fe(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function pe(){return{type:`paragraph`,children:[]}}function me(){return{type:`strong`,children:[]}}function he(){return{type:`text`,value:``}}function ge(){return{type:`thematicBreak`}}}function qN(e){return{line:e.line,column:e.column,offset:e.offset}}function JN(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?JN(e,r):YN(e,r)}}function YN(e,t){let n;for(n in t)if(WN.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`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function XN(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+_A({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+_A({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+_A({start:t.start,end:t.end})+`) is still open`)}function ZN(e){let t=this;t.parser=n;function n(n){return GN(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function QN(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 $N(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
@@ -104,7 +104,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(
|
|
|
104
104
|
`),r=(0,_.useMemo)(()=>{try{if(t)return tU.highlight(e,{language:t,ignoreIllegals:!0}).value;{let t=tU.highlightAuto(e);if(t.language)return t.value}}catch{}return null},[e,t]);return(0,G.jsx)(`div`,{className:`overflow-hidden rounded-md font-mono text-xs leading-5`,style:{border:`1px solid var(--cm-code-border)`,backgroundColor:`var(--cm-code-bg)`},children:(0,G.jsx)(`div`,{className:`max-h-80 overflow-auto`,children:r?(0,G.jsxs)(`div`,{className:`flex`,children:[(0,G.jsx)(`div`,{className:`shrink-0 text-right text-[9px] select-none`,style:{color:`var(--cm-gutter)`,borderRight:`1px solid var(--cm-border)`,minWidth:`3rem`},children:n.map((e,t)=>(0,G.jsx)(`div`,{className:`pr-3 py-px`,children:t+1},t))}),(0,G.jsx)(`pre`,{className:`flex-1 pl-2 py-px whitespace-pre-wrap break-all`,dangerouslySetInnerHTML:{__html:r}})]}):n.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex`,children:[(0,G.jsx)(`span`,{className:`w-12 shrink-0 text-right pr-3 py-px text-[9px] select-none border-r`,style:{color:`var(--cm-gutter)`,borderColor:`var(--cm-border)`},children:t+1}),(0,G.jsx)(`span`,{className:`pl-2 py-px whitespace-pre-wrap break-all`,style:{color:`var(--cm-text)`},children:e})]},t))})})}function BU({command:e,output:t}){return(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-md bg-[#0d1117] border border-gray-700 text-xs`,children:[e&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-gray-700/50 px-3 py-1.5 text-green-400 font-mono`,children:[(0,G.jsx)(`span`,{className:`select-none text-gray-500 text-[10px]`,children:`$`}),(0,G.jsx)(`span`,{className:`whitespace-pre-wrap break-all font-medium`,children:e})]}),t!==void 0&&(0,G.jsx)(`pre`,{className:`max-h-64 overflow-auto px-3 py-2 text-gray-300 whitespace-pre-wrap font-mono leading-relaxed`,children:t||(0,G.jsx)(`span`,{className:`text-gray-500 italic`,children:`(no output)`})})]})}function VU({toolName:e,args:t,result:n,status:r=`complete`,elapsedSeconds:i,taskState:a,toolCallId:o}){let s=OU(e),c=s.icon,l=AU(e,t),[u,d]=(0,_.useState)(!1),f=r===`complete`,p=r===`running`,m=r===`requires-action`,h=DU[r],g=rU(),{permissionPrompt:v,answerPermission:y,openFile:b}=_U(),x=m||v?.toolUseId===o,S=u||x,C=EU(p,i),w=f&&n?jU(n):null,T=w!==null,E=e===`Bash`,D=e===`TodoWrite`,O=e===`Agent`||e===`Task`,k=e===`Write`,A=e===`Edit`||e===`ApplyPatch`,j=Object.keys(t).length>0,M=t.content??``,N=t.old_string??``,P=t.new_string??``,I=A&&N&&P,L=kU(t.file_path||t.filePath||``),R=!!(b&&L&&f),z=(0,_.useMemo)(()=>{let e=L.includes(`.`)?L.split(`.`).pop()?.toLowerCase()??``:``;return{js:`javascript`,jsx:`javascript`,ts:`typescript`,tsx:`typescript`,py:`python`,rs:`rust`,go:`go`,rb:`ruby`,swift:`swift`,java:`java`,c:`c`,cpp:`cpp`,cs:`csharp`,kt:`kotlin`,json:`json`,yaml:`yaml`,yml:`yaml`,toml:`ini`,xml:`xml`,html:`xml`,htm:`xml`,svg:`xml`,css:`css`,scss:`scss`,less:`less`,sql:`sql`,sh:`bash`,bash:`bash`,zsh:`bash`,fish:`bash`,md:`markdown`,dockerfile:`dockerfile`,proto:`protobuf`,php:`php`,lua:`lua`,r:`r`,scala:`scala`}[e]||(e&&e.length<=5?e:``)},[L]),B=D?Array.isArray(t.todos)?t.todos:[]:null,H=S?null:k&&M?IU(M,200):A&&(T||I)?{type:`edit`,oldStr:N,newStr:P,diff:w}:null;return(0,G.jsxs)(xz,{open:S,onOpenChange:d,className:Y(`group/tool my-1.5 overflow-hidden rounded-lg border border-gray-100 bg-gray-50/60 border-l-[3px]`,s.borderClass,p&&`animate-pulse`),children:[(0,G.jsxs)(Sz,{className:`flex w-full flex-col text-left text-sm transition-colors hover:bg-gray-50`,children:[(0,G.jsxs)(`div`,{className:`flex w-full items-center gap-1.5 md:gap-2 px-2 md:px-3 py-1.5`,children:[(0,G.jsx)(c,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}),(0,G.jsx)(`span`,{className:`font-medium text-gray-700 text-xs`,children:e}),l&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-gray-300`,children:`·`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] text-gray-500`,children:l})]}),x?(0,G.jsx)(`span`,{className:`ml-auto shrink-0 rounded px-1.5 py-px text-[10px] font-medium bg-amber-100 text-amber-700`,children:`Action needed`}):p?(0,G.jsx)(`span`,{className:`ml-auto shrink-0 rounded px-1.5 py-px text-[10px] font-medium tabular-nums bg-sky-100 text-sky-700`,children:TU(C)}):(0,G.jsx)(`span`,{className:Y(`ml-auto shrink-0 rounded px-1.5 py-px text-[10px] font-medium`,h.className),children:h.label}),(0,G.jsx)(F,{className:Y(`h-3.5 w-3.5 shrink-0 text-gray-300 transition-transform`,u&&`rotate-180`)})]}),H&&(0,G.jsx)(`div`,{className:`border-t border-gray-100 px-2 md:px-3 py-1.5`,children:typeof H==`string`?(0,G.jsx)(`pre`,{className:`font-mono text-[10px] leading-relaxed text-gray-500 whitespace-pre-wrap break-all line-clamp-3`,children:H}):H.type===`edit`?H.diff&&n?(0,G.jsx)(PU,{text:n,lang:z,maxLines:8}):(0,G.jsx)(`div`,{className:`opacity-70`,children:(0,G.jsx)(RU,{oldStr:H.oldStr,newStr:H.newStr,maxLen:20,lang:z})}):null})]}),(0,G.jsx)(Cz,{className:Y(`overflow-hidden`,`data-[state=open]:animate-collapsible-down`,`data-[state=closed]:animate-collapsible-up`),children:(0,G.jsxs)(`div`,{className:Y(`border-t border-gray-100 px-2 md:px-3 py-2`,g&&`max-h-[60vh] overflow-y-auto`),children:[x&&v&&(0,G.jsx)(wU,{toolName:v.toolName,title:v.title,displayName:v.displayName,onAllow:()=>y(v.toolUseId,!0),onDeny:()=>y(v.toolUseId,!1)}),R&&(0,G.jsxs)(`button`,{type:`button`,onClick:()=>b(L),className:`inline-flex items-center gap-1 mb-2 px-2 py-1 rounded text-[11px] border border-gray-200 bg-white hover:bg-gray-50 text-gray-600 hover:text-gray-900 transition-colors`,children:[(0,G.jsx)(ie,{className:`h-3 w-3`}),`Open in Editor`]}),k&&f&&M&&(0,G.jsx)(FU,{content:M,lang:z}),A&&f&&T&&n&&(0,G.jsx)(PU,{text:n,lang:z}),A&&f&&!T&&I&&(0,G.jsx)(RU,{oldStr:N,newStr:P,lang:z}),E&&(l||n!==void 0)&&(0,G.jsx)(BU,{command:l,output:n}),D&&B&&B.length>0&&(0,G.jsx)(aU,{todos:B}),O&&(0,G.jsx)(SU,{args:t,result:n,status:r,taskState:a,elapsedSeconds:C,toolCallId:o}),!k&&!E&&!D&&!O&&!(A&&(T||I))&&n!==void 0&&(0,G.jsx)(zU,{text:typeof n==`string`?n:JSON.stringify(n,null,2),lang:z}),p&&!x&&!n&&!j&&!O&&!(D&&B&&B.length>0)&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-1 text-xs text-gray-400`,children:[(0,G.jsx)(Te,{className:`h-3 w-3 animate-spin`}),`Working...`]}),r===`incomplete`&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-red-500`,children:[(0,G.jsx)(V,{className:`h-3.5 w-3.5`}),`Tool call failed`]})]})})]})}var HU=class extends _.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[ErrorBoundary:`+this.props.name+`]`,e.message,e.stack,t)}render(){return this.state.error?(0,G.jsxs)(`div`,{className:`rounded border border-red-200 bg-red-50 p-3 text-xs text-red-700`,children:[(0,G.jsxs)(`b`,{children:[`Error in `,this.props.name,`:`]}),` `,this.state.error.message]}):this.props.children}};function UU(e){if(!e)return``;let t=e.match(/(\d{13})/);return t?new Date(parseInt(t[1],10)).toLocaleTimeString():``}function WU({content:e}){let t=e.trim();if(!(t.startsWith(`{`)||t.startsWith(`[`))||!(t.endsWith(`}`)||t.endsWith(`]`)))return null;try{let e=JSON.parse(t),n=JSON.stringify(e,null,2);return(0,G.jsxs)(`div`,{className:`my-2`,children:[(0,G.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm text-gray-500`,children:[(0,G.jsx)(`svg`,{className:`h-4 w-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,G.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z`})}),(0,G.jsx)(`span`,{className:`font-medium`,children:`JSON`})]}),(0,G.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-gray-600/30 bg-gray-900`,children:(0,G.jsx)(`pre`,{className:`overflow-x-auto p-4`,children:(0,G.jsx)(`code`,{className:`block whitespace-pre font-mono text-sm text-gray-200`,children:n})})})]})}catch{return null}}function GU(e){let t=!1,n=!1;for(let r of e)r?.type===`tool-call`&&(n=!0,r?.status?.type===`running`&&(t=!0));return t?`blink-green`:n?`green`:`gray`}function KU(){let e=Z(e=>e.message.id),{toolProgressMap:t,taskMap:n,thinkingOpen:r,setThinkingOpen:i}=_U(),a=Z(e=>e.message.content),o=Z(e=>{let t=e.message.content;return Array.isArray(t)?t.filter(e=>e.type===`text`).map(e=>e.text??``).join(``):``}),s=UU(e);if(!(Array.isArray(a)&&a.some(e=>e?.type===`text`&&(e.text??``).length>0||e?.type===`tool-call`||e?.type===`reasoning`||e?.type===`image`||e?.type===`file`)))return null;let c=Array.isArray(a)?GU(a):`gray`,l=(Array.isArray(a)?a.find(e=>e?.type===`text`||e?.type===`tool-call`):null)?.type===`text`?`top-[6px]`:`top-[17px]`,u=(0,G.jsx)(PE.GroupedParts,{groupBy:e=>e.type===`reasoning`?[`group-chainOfThought`,`group-reasoning`]:null,children:({part:e,children:s})=>{switch(e.type){case`group-chainOfThought`:return(0,G.jsx)(`div`,{"data-slot":`chain-of-thought`,children:s});case`group-reasoning`:{let t=e.status.type===`running`,n=e.indices?.reduce((e,t)=>e+(a[t]?.text?.length??0),0)??0,o=n>0?`Thinking · ${n.toLocaleString()} chars`:`Thinking`;return(0,G.jsxs)(xz,{open:t?!0:r,onOpenChange:i,className:`group/think my-1 overflow-hidden rounded-md border border-gray-100 bg-gray-50/50`,children:[(0,G.jsxs)(Sz,{className:`flex w-full items-center gap-1.5 px-2 py-1 text-left text-xs transition-colors hover:bg-gray-100/50`,children:[(0,G.jsx)(M,{className:`h-3 w-3 shrink-0 text-gray-400`}),(0,G.jsx)(`span`,{className:`text-gray-400`,children:o}),t&&(0,G.jsx)(`span`,{className:`shrink-0 rounded px-1 py-px text-[10px] font-medium text-gray-400`,children:`thinking`}),(0,G.jsx)(F,{className:Y(`ml-auto h-3 w-3 shrink-0 text-gray-300 transition-transform`,(t||r)&&`rotate-180`)})]}),(0,G.jsx)(Cz,{className:Y(`overflow-hidden`,`data-[state=open]:animate-collapsible-down`,`data-[state=closed]:animate-collapsible-up`),children:(0,G.jsx)(`div`,{className:`border-t border-gray-100 px-3 py-2`,children:(0,G.jsx)(`div`,{className:`max-h-64 overflow-y-auto text-[12px] text-gray-500 leading-relaxed`,children:s})})})]})}case`text`:{let e=WU({content:o});return e?(0,G.jsx)(`div`,{children:e}):(0,G.jsx)(fz,{})}case`reasoning`:return(0,G.jsx)(fz,{});case`tool-call`:{let r=e.args??{},i=e.result,a=e.status?.type??`complete`,o=e.toolCallId,s=e.toolName??`Unknown`,c=o?t.get(o):void 0,l=o?Array.from(n.values()).find(e=>e.tool_use_id===o):void 0;return(0,G.jsx)(HU,{name:`ToolRenderer:`+s,children:(0,G.jsx)(VU,{toolName:s,args:r,result:i,status:a,elapsedSeconds:c?.elapsed_time_seconds,taskState:l,toolCallId:o})})}default:return null}}});return(0,G.jsxs)(PE.Root,{"data-role":`assistant`,className:`relative pl-6 md:pl-8`,children:[(0,G.jsx)(`div`,{className:`absolute left-[5px] -top-2 -bottom-2 w-[2px] bg-gray-200`}),(0,G.jsx)(`div`,{className:Y(`absolute left-[3px] z-10 h-[6px] w-[6px] rounded-full`,l,c===`gray`&&`bg-gray-300`,c===`green`&&`bg-green-500`,c===`blink-green`&&`animate-[blink-green_2s_ease-in-out_infinite]`)}),(0,G.jsx)(`div`,{className:`w-full text-[13px] md:text-sm text-gray-700`,children:u}),s&&(0,G.jsx)(`div`,{className:`mt-1 flex items-center gap-2 text-[11px] text-gray-400`,children:(0,G.jsx)(`span`,{children:s})})]})}var qU=[`Thinking`,`Processing`,`Analyzing`,`Working`,`Computing`,`Reasoning`];function JU(e){let t=Math.floor(e/60),n=e%60;return t<1?`${n}s`:`${t}m ${n}s`}function YU(e){return e<0&&(e=0),e<1e3?String(Math.round(e)):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(1)}M`}function XU({isLoading:e,getTokenCount:t,getWaitingForResponse:n}){let{thinkingBudget:r,turnGeneration:i,turnStartedAt:a}=_U(),[o,s]=(0,_.useState)(0),[c,l]=(0,_.useState)(0),[u,d]=(0,_.useState)(``);if((0,_.useEffect)(()=>{if(!e){s(0),l(0),d(``);return}let t=a??Date.now(),n=setInterval(()=>{s(Math.floor((Date.now()-t)/1e3))},250),r=setInterval(()=>{d(e=>e.length>=3?``:e+`.`)},400);return()=>{clearInterval(n),clearInterval(r)}},[e,i,a]),(0,_.useEffect)(()=>{if(!e)return;let n,r=()=>{let e=t();l(t=>{if(Math.abs(e-t)<.5)return e;let n=e-t,r=Math.max(1,Math.ceil(Math.abs(n)/8));return t+Math.sign(n)*Math.min(r,Math.abs(n))}),n=requestAnimationFrame(r)};return n=requestAnimationFrame(r),()=>cancelAnimationFrame(n)},[e,t]),!e)return null;let f=qU[Math.floor(o/3)%qU.length],p=n()?`↑`:`↓`,m=r===null?null:r>=32e3?`think-hard`:r>=16e3?`think`:null;return(0,G.jsxs)(`div`,{className:`relative mb-1.5 pl-6 md:pl-8`,children:[(0,G.jsx)(`div`,{className:`absolute left-[3px] top-1/2 -translate-y-1/2 z-10 h-[6px] w-[6px] animate-[morph_2s_ease-in-out_infinite] bg-blue-500 shadow-[0_0_6px_rgba(59,130,246,0.4)]`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 md:gap-3 text-xs text-gray-500 py-1`,children:[(0,G.jsxs)(`span`,{className:`font-medium text-gray-600`,children:[f,(0,G.jsx)(`span`,{className:`inline-block w-4 tabular-nums`,children:u})]}),m&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-gray-300`,children:`·`}),(0,G.jsx)(`span`,{className:`rounded bg-blue-50 px-1.5 py-0.5 text-[10px] font-medium text-blue-600`,children:m})]}),(0,G.jsx)(`span`,{className:`tabular-nums text-gray-500 ml-auto mr-1`,children:JU(o)}),(0,G.jsxs)(`span`,{className:`tabular-nums text-gray-600 font-medium`,children:[p,YU(c),` tk`]})]})]})}function ZU({...e}){return(0,G.jsx)(yd,{"data-slot":`popover`,...e})}function QU({...e}){return(0,G.jsx)(bd,{"data-slot":`popover-trigger`,...e})}function $U({className:e,align:t=`center`,sideOffset:n=8,children:r,...i}){return(0,G.jsx)(xd,{children:(0,G.jsx)(Sd,{"data-slot":`popover-content`,align:t,sideOffset:n,className:Y(`z-50 w-72 rounded-xl border border-gray-200 bg-white p-0 shadow-xl outline-none`,`data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,`data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,`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`,e),...i,children:r})})}function eW({...e}){return(0,G.jsx)(Cd,{"data-slot":`popover-close`,...e})}var tW=[{id:`bypassPermissions`,label:`YOLO`,description:`Sandboxed — safe to proceed freely`,icon:dt,color:`text-green-600`,activeBg:`bg-green-50`,activeBorder:`border-green-200`,activeHover:`hover:bg-green-100`},{id:`auto`,label:`Auto`,description:`Fully automatic, minimal prompts`,icon:Xe,color:`text-amber-600`,activeBg:`bg-amber-50`,activeBorder:`border-amber-200`,activeHover:`hover:bg-amber-100`},{id:`dontAsk`,label:`Don't Ask`,description:`Skip most confirmations`,icon:oe,color:`text-blue-600`,activeBg:`bg-blue-50`,activeBorder:`border-blue-200`,activeHover:`hover:bg-blue-100`},{id:`acceptEdits`,label:`Accept Edits`,description:`Auto-approve file edits, ask for rest`,icon:Le,color:`text-yellow-600`,activeBg:`bg-yellow-50`,activeBorder:`border-yellow-200`,activeHover:`hover:bg-yellow-100`},{id:`plan`,label:`Plan`,description:`Plan first, then implement step by step`,icon:U,color:`text-purple-600`,activeBg:`bg-purple-50`,activeBorder:`border-purple-200`,activeHover:`hover:bg-purple-100`},{id:`default`,label:`Default`,description:`Ask before each edit (safest)`,icon:Je,color:`text-gray-600`,activeBg:`bg-gray-50`,activeBorder:`border-gray-200`,activeHover:`hover:bg-gray-100`}];function nW({mode:e,onChange:t,className:n=``}){let[r,i]=(0,_.useState)(!1),a=tW.find(t=>t.id===e)??tW[0],o=a.icon;return(0,G.jsxs)(ZU,{open:r,onOpenChange:i,children:[(0,G.jsx)(QU,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,className:Y(`flex h-8 items-center gap-1 rounded-lg border px-1.5 text-[10px] transition-all`,e===`bypassPermissions`?`border-gray-200 bg-gray-50 text-gray-500 hover:bg-gray-100`:`${a.activeBorder} ${a.activeBg} ${a.color} ${a.activeHover}`,n),title:`Mode: ${a.label}`,"aria-label":`Select permission mode`,children:[(0,G.jsx)(o,{className:Y(`h-3 w-3`,a.color)}),(0,G.jsx)(`span`,{className:`hidden font-medium sm:inline`,children:a.label})]})}),(0,G.jsxs)($U,{className:`w-56`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-gray-200 p-3`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-gray-900`,children:`Permission Mode`}),(0,G.jsx)(eW,{asChild:!0,children:(0,G.jsx)(`button`,{type:`button`,className:`rounded p-1 hover:bg-gray-100`,"aria-label":`Close`,children:(0,G.jsx)(ut,{className:`h-4 w-4 text-gray-500`})})})]}),(0,G.jsx)(`div`,{className:`py-1`,children:tW.map(n=>{let r=n.icon,a=n.id===e;return(0,G.jsx)(`button`,{type:`button`,onClick:()=>{t(n.id),i(!1)},className:Y(`w-full px-4 py-2.5 text-left transition-colors hover:bg-gray-50`,a&&`bg-gray-50`),children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,G.jsx)(r,{className:Y(`h-4 w-4`,n.color)}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:Y(`text-sm font-medium`,a?`text-gray-900`:`text-gray-700`),children:n.label}),a&&(0,G.jsx)(`span`,{className:`rounded bg-blue-100 px-1.5 py-0.5 text-[9px] text-blue-700`,children:`Active`})]}),(0,G.jsx)(`p`,{className:`text-xs text-gray-500`,children:n.description})]})]})},n.id)})})]})]})}function rW(){let{provider:e,selectProvider:t,thinkingBlockCount:n,loopId:r}=_U(),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(0),f=(0,_.useRef)(null),p=(0,_.useRef)(null);(0,_.useEffect)(()=>{dh().then(a)},[]);let m=e?.name||`default`,h=e?.model||``,g=(0,_.useMemo)(()=>{if(!i)return[];let e=[];for(let[t,n]of Object.entries(i.providers))if(!(n.enabled===!1||!n.hasKey))for(let r of n.models??[]){if(r.enabled===!1)continue;let i=c.toLowerCase().trim();i&&!r.id.toLowerCase().includes(i)&&!t.toLowerCase().includes(i)||e.push({provName:t,modelId:r.id,source:n.source})}return e},[i,c]);(0,_.useEffect)(()=>{d(0)},[c,o]),(0,_.useEffect)(()=>{p.current&&p.current.children[u]?.scrollIntoView({block:`nearest`})},[u]),(0,_.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&(e.preventDefault(),s(e=>!e)),e.key===`Escape`&&o&&s(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o]);let v=(0,_.useMemo)(()=>{let e=new Map;return g.forEach((t,n)=>{let r=e.get(t.provName)??{source:t.source,models:[]};r.models.push({modelId:t.modelId,idx:n}),e.set(t.provName,r)}),e},[g]),y=e=>e.toLowerCase().startsWith(`claude`),b=(0,_.useCallback)(async e=>{if(s(!1),!(e.provName===m&&e.modelId===h)){if(y(h)!==y(e.modelId)&&n>0&&r){let e=`Switching between Claude and non-Claude models makes the ${n} existing thinking block${n===1?``:`s`} in this conversation fail signature validation.\n\nClick OK to remove them from the AI's context (chat history stays). Cancel to keep the current provider.`;if(!window.confirm(e))return;await _m(r)}t(e.provName,e.source,e.modelId)}},[m,h,n,r,t]);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),className:`flex items-center gap-1 rounded-md border border-gray-200 bg-gray-50 px-1.5 py-0.5 text-[10px] text-gray-500 hover:bg-gray-100 transition-colors`,title:`Select model (Ctrl+K)`,"aria-label":`Select model`,children:[(0,G.jsx)(te,{className:`h-3 w-3`}),(0,G.jsx)(`span`,{className:`font-medium text-gray-700 truncate max-w-16 md:max-w-24`,children:m}),h&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`hidden md:inline text-gray-400`,children:`/`}),(0,G.jsx)(`span`,{className:`hidden md:inline font-mono truncate max-w-20`,children:h})]}),(0,G.jsx)(F,{className:`h-2.5 w-2.5 text-gray-400`})]}),o&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/20`,onClick:()=>s(!1)}),(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center pt-[15vh]`,onClick:()=>s(!1),children:(0,G.jsxs)(`div`,{className:`w-[480px] max-h-[60vh] bg-white rounded-xl shadow-2xl border border-gray-200 flex flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),d(e=>Math.min(e+1,g.length-1))):e.key===`ArrowUp`?(e.preventDefault(),d(e=>Math.max(e-1,0))):e.key===`Enter`?(e.preventDefault(),g[u]&&b(g[u])):e.key===`Escape`&&s(!1)},children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 border-b border-gray-200 shrink-0`,children:[(0,G.jsx)(We,{className:`h-4 w-4 text-gray-400 shrink-0`}),(0,G.jsx)(`input`,{ref:f,autoFocus:!0,type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:`Search models...`,className:`flex-1 text-sm outline-none text-gray-900 placeholder:text-gray-400`}),(0,G.jsx)(`kbd`,{className:`hidden sm:inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] bg-gray-100 text-gray-400 font-mono`,children:`esc`})]}),(0,G.jsxs)(`div`,{ref:p,className:`flex-1 overflow-y-auto py-2`,role:`listbox`,children:[Array.from(v.entries()).map(([e,t])=>(0,G.jsxs)(`div`,{className:`mb-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 px-4 py-1`,children:[(0,G.jsx)(`span`,{className:`text-[11px] font-medium text-gray-500`,children:e}),(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded px-1 py-0 text-[8px] font-medium ${t.source===`personal`?`bg-violet-100 text-violet-600`:`bg-gray-100 text-gray-400`}`,children:[t.source===`personal`?(0,G.jsx)(st,{className:`h-2 w-2`}):(0,G.jsx)(ve,{className:`h-2 w-2`}),t.source]})]}),t.models.map(t=>{let n=t.idx===u,r=e===m&&t.modelId===h;return(0,G.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,onClick:()=>b(g[t.idx]),onMouseEnter:()=>d(t.idx),className:`w-full px-6 py-1.5 text-left flex items-center gap-2 transition-colors ${n?`bg-blue-50`:``}`,children:[(0,G.jsx)(`span`,{className:`font-mono text-[12px] flex-1 truncate ${r?`text-blue-700 font-medium`:n?`text-gray-900`:`text-gray-600`}`,children:t.modelId}),r&&(0,G.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-blue-500 shrink-0`})]},t.modelId)})]},e)),g.length===0&&(0,G.jsx)(`div`,{className:`px-4 py-8 text-center text-sm text-gray-400`,children:c?`No models match your search`:`No models available`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-4 px-4 py-2 border-t border-gray-100 text-[10px] text-gray-400 shrink-0`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(O,{className:`h-3 w-3`}),(0,G.jsx)(T,{className:`h-3 w-3`}),`navigate`]}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(W,{className:`h-3 w-3`}),`select`]}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`kbd`,{className:`px-1 py-0.5 rounded bg-gray-100 font-mono text-[9px]`,children:`esc`}),`close`]})]})]})})]})]})}function iW({onPick:e}){let{availableSlashCommands:t}=_U(),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(0),c=(0,_.useMemo)(()=>{let e=new Map;for(let n of t){let t=n.name.indexOf(`:`);if(t<0)continue;let r=n.name.slice(0,t),i=n.name.slice(t+1),a=e.get(r)??{plugin:r,skills:[]};a.skills.push({name:i,description:n.description}),e.set(r,a)}return[...e.values()].sort((e,t)=>e.plugin.localeCompare(t.plugin))},[t]),l=(0,_.useMemo)(()=>c.reduce((e,t)=>e+t.skills.length,0),[c]),u=(0,_.useMemo)(()=>{let e=i.toLowerCase().trim(),t=[];for(let n of c)for(let r of n.skills)e&&!`${n.plugin}:${r.name}`.toLowerCase().includes(e)&&!r.description.toLowerCase().includes(e)||t.push({plugin:n.plugin,skill:r.name,description:r.description});return t},[c,i]);if((0,_.useEffect)(()=>{s(0)},[i,n]),(0,_.useEffect)(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),l===0)return null;let d=(t,n)=>{r(!1),e(`/${t}:${n} `)};return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>r(!0),className:`flex items-center gap-1 rounded-md border border-gray-200 bg-gray-50 px-1.5 py-0.5 text-[10px] text-gray-500 hover:bg-gray-100 transition-colors`,title:`${l} plugin skill${l===1?``:`s`} available`,"aria-label":`Show plugins`,children:[(0,G.jsx)(`span`,{className:`text-sm leading-none`,"aria-hidden":`true`,children:`🧩`}),(0,G.jsx)(`span`,{className:`font-medium text-gray-700`,children:l})]}),n&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/20`,onClick:()=>r(!1)}),(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center pt-[15vh]`,onClick:()=>r(!1),children:(0,G.jsxs)(`div`,{className:`w-[560px] max-h-[60vh] bg-white rounded-xl shadow-2xl border border-gray-200 flex flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),onKeyDown:e=>{if(e.key===`ArrowDown`)e.preventDefault(),s(e=>Math.min(e+1,u.length-1));else if(e.key===`ArrowUp`)e.preventDefault(),s(e=>Math.max(e-1,0));else if(e.key===`Enter`){e.preventDefault();let t=u[o];t&&d(t.plugin,t.skill)}},children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 border-b border-gray-200 shrink-0`,children:[(0,G.jsx)(We,{className:`h-4 w-4 text-gray-400 shrink-0`}),(0,G.jsx)(`input`,{autoFocus:!0,type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`Search plugins...`,className:`flex-1 text-sm outline-none text-gray-900 placeholder:text-gray-400`}),(0,G.jsxs)(`span`,{className:`text-[10px] text-gray-400`,children:[u.length,` / `,l]}),(0,G.jsx)(`kbd`,{className:`hidden sm:inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] bg-gray-100 text-gray-400 font-mono`,children:`esc`})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2`,role:`listbox`,children:[(()=>{let e=new Map;return u.forEach((t,n)=>{let r=e.get(t.plugin)??[];r.push({skill:t.skill,description:t.description,idx:n}),e.set(t.plugin,r)}),Array.from(e.entries()).map(([e,t])=>(0,G.jsxs)(`div`,{className:`mb-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 px-4 py-1`,children:[(0,G.jsx)(`span`,{className:`text-xs leading-none`,"aria-hidden":`true`,children:`🧩`}),(0,G.jsx)(`span`,{className:`text-[11px] font-medium text-gray-500`,children:e})]}),t.map(({skill:t,description:n,idx:r})=>{let i=r===o;return(0,G.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":i,onClick:()=>d(e,t),onMouseEnter:()=>s(r),className:`w-full px-6 py-1.5 text-left flex flex-col gap-0.5 transition-colors ${i?`bg-blue-50`:``}`,children:[(0,G.jsxs)(`span`,{className:`font-mono text-[12px] text-gray-900`,children:[`/`,e,`:`,t]}),n&&(0,G.jsx)(`span`,{className:`text-[11px] text-gray-500 line-clamp-2`,children:n})]},t)})]},e))})(),u.length===0&&(0,G.jsx)(`div`,{className:`px-4 py-8 text-center text-sm text-gray-400`,children:i?`No skills match your search`:`No plugins available`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-4 px-4 py-2 border-t border-gray-100 text-[10px] text-gray-400 shrink-0`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(O,{className:`h-3 w-3`}),(0,G.jsx)(T,{className:`h-3 w-3`}),`navigate`]}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(W,{className:`h-3 w-3`}),`insert`]}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`kbd`,{className:`px-1 py-0.5 rounded bg-gray-100 font-mono text-[9px]`,children:`esc`}),`close`]})]})]})})]})]})}function aW({onClose:e,loopId:t}){let[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(null),f=(0,_.useCallback)(async()=>{a(!0),r((await $h(t)).servers),a(!1)},[t]);(0,_.useEffect)(()=>{f()},[f]);let p=async e=>{if(o)return;s(e),l(null);let n=await eg(e,t);if(s(null),n.error||!n.authorizationUrl){l(n.error??`start failed`);return}window.location.href=n.authorizationUrl},m=async e=>{o||(s(e),await tg(e),s(null),f())};return(0,G.jsxs)(`div`,{className:`text-sm`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-gray-200`,children:[(0,G.jsx)(`div`,{className:`text-[13px] font-medium text-gray-700`,children:`MCP servers`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`button`,{onClick:f,className:`p-1 text-gray-400 hover:text-gray-700 rounded`,title:`reload`,children:(0,G.jsx)(Ve,{size:12,className:i?`animate-spin`:``})}),(0,G.jsx)(`button`,{onClick:e,className:`p-1 text-gray-400 hover:text-gray-700 rounded`,title:`close`,children:(0,G.jsx)(ut,{size:14})})]})]}),c&&(0,G.jsx)(`div`,{className:`mx-3 mt-3 rounded px-3 py-2 text-[12px] bg-red-50 text-red-800 border border-red-200`,children:c}),u&&(0,G.jsx)(`div`,{className:`mx-3 mt-3 rounded px-3 py-2 text-[12px] bg-blue-50 text-blue-800 border border-blue-200`,children:u}),(0,G.jsx)(`div`,{className:`max-h-[60vh] overflow-y-auto`,children:i&&n.length===0?(0,G.jsx)(`div`,{className:`px-3 py-4 text-[12px] text-gray-400`,children:`loading…`}):n.length===0?(0,G.jsxs)(`div`,{className:`px-3 py-4 text-[12px] text-gray-400 italic`,children:[`No MCP servers in this loop's merged settings.json. Add servers to team/personal/profile `,(0,G.jsx)(`code`,{className:`bg-gray-100 px-1 rounded font-mono text-[11px]`,children:`settings.json`}),`'s`,(0,G.jsx)(`code`,{className:`bg-gray-100 px-1 rounded font-mono text-[11px]`,children:`mcpServers`}),`.`]}):n.map(e=>(0,G.jsx)(oW,{server:e,busy:o===e.name||e.authTokenEnv!==null&&o===e.authTokenEnv,onConnect:()=>p(e.name),onForget:e.authTokenEnv?()=>m(e.authTokenEnv):void 0},e.name))}),(0,G.jsx)(`div`,{className:`border-t border-gray-200 px-3 py-2 flex items-center justify-end text-[11px]`,children:(0,G.jsxs)(`button`,{onClick:async()=>{d(null);let e=await ng(t);e.error?l(e.error):d(e.restarted?`Loop SDK session restarted. Send a message to re-spawn with new MCP tokens.`:`No active SDK session — next message will spawn fresh.`)},className:`text-gray-600 hover:text-gray-900 flex items-center gap-1`,title:`Restart the SDK session so newly-connected MCPs take effect. Conversation history is preserved.`,children:[(0,G.jsx)(He,{size:10}),` Reload session`]})})]})}function oW({server:e,busy:t,onConnect:n,onForget:r}){let i=e.type===`http`||e.type===`sse`,a=i&&e.oauthSupport===`dcr`&&!!e.authTokenEnv;return(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 hover:bg-gray-50`,children:[(0,G.jsx)(`span`,{className:`text-[14px] text-gray-300 leading-none`,children:e.authed?`●`:a?`○`:`·`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,G.jsx)(`span`,{className:`font-medium text-gray-700 text-[13px]`,children:e.name}),(0,G.jsx)(`span`,{className:`text-[10px] text-gray-400 uppercase`,children:e.type})]}),e.url&&(0,G.jsx)(`div`,{className:`text-[11px] text-gray-400 font-mono truncate`,children:e.url})]}),(0,G.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1`,children:[e.authed&&(0,G.jsxs)(`span`,{className:`text-[11px] text-green-700 inline-flex items-center gap-1`,children:[(0,G.jsx)(P,{size:11}),` authed`]}),a&&(0,G.jsxs)(`button`,{onClick:n,disabled:t,className:`inline-flex items-center gap-1 text-[11px] px-2 h-6 rounded ${e.authed?`text-gray-600 hover:bg-gray-100 border border-gray-200`:`text-amber-700 bg-amber-50 hover:bg-amber-100 border border-amber-200`} disabled:opacity-50`,title:e.authed?`Re-run OAuth and overwrite the existing token`:`Run OAuth to obtain a token`,children:[e.authed?(0,G.jsx)(Ce,{size:10}):(0,G.jsx)(rt,{size:10}),t?`…`:e.authed?`re-auth`:`auth`]}),e.authed&&r&&(0,G.jsxs)(`button`,{onClick:r,disabled:t,className:`inline-flex items-center gap-1 text-[11px] px-1.5 h-6 rounded text-gray-500 hover:text-gray-900 hover:bg-gray-100 disabled:opacity-50`,title:`Delete the env file backing this server's token`,children:[(0,G.jsx)(at,{size:10}),` forget`]}),!a&&!e.authed&&i&&(e.oauthSupport===`manual`?(0,G.jsx)(`span`,{className:`text-[11px] text-gray-500 italic`,title:`This provider requires admin to register an OAuth app (no DCR). Loopat doesn't support manual client_id setup.`,children:`manual setup`}):e.oauthSupport===`none`?(0,G.jsx)(`span`,{className:`text-[11px] text-gray-400`,title:`No OAuth metadata — server is public or uses non-OAuth auth (e.g. API key).`,children:`no oauth`}):e.oauthSupport===`unreachable`?(0,G.jsx)(`span`,{className:`text-[11px] text-red-500`,title:`Probe failed — server unreachable or returned malformed metadata.`,children:`unreachable`}):e.authTokenEnv===null?(0,G.jsx)(`span`,{className:`text-[11px] text-gray-400 italic`,title:"No Bearer ${VAR} template in Authorization header — loopat can't determine which env to write.",children:`no bearer template`}):null),!i&&(0,G.jsx)(`span`,{className:`text-[11px] text-gray-400`,children:`stdio`})]})]})}var sW=[{id:`think`,name:`Think`,description:`Extended thinking (16k token budget)`,icon:M,group:`quick`,action:`command`,prefix:``,commandKey:`setMaxThinkingTokens`,tokens:16e3},{id:`think-hard`,name:`Think Hard`,description:`Deep thinking (32k token budget)`,icon:dt,group:`quick`,action:`command`,prefix:``,commandKey:`setMaxThinkingTokens`,tokens:32e3},{id:`ultrathink`,name:`Ultrathink`,description:`Maximum thinking (no budget limit)`,icon:Xe,group:`quick`,action:`command`,prefix:``,commandKey:`setMaxThinkingTokens`,tokens:null},{id:`plan`,name:`Permission`,description:`Cycle permission mode`,icon:Ue,group:`quick`,action:`toggle`,prefix:``,toggleKey:`permissionMode`},{id:`goal`,name:`Goal`,description:`Set goal (/goal <text>), mark done (/goal done), clear (/goal clear)`,icon:et,group:`quick`,action:`agent`,prefix:``},{id:`usage`,name:`Context Usage`,description:`Show context window token usage`,icon:N,group:`quick`,action:`command`,prefix:``,commandKey:`getContextUsage`},{id:`clear`,name:`Clear Context`,description:`Reset AI conversation (history kept)`,icon:re,group:`quick`,action:`command`,prefix:``,commandKey:`clearContext`},{id:`mcp`,name:`MCP Servers`,description:`Show MCP servers + tools available to this loop`,icon:Ne,group:`quick`,action:`command`,prefix:``,commandKey:`openMcpPanel`}],cW=[{id:`quick`,label:`Quick actions`},{id:`plugin`,label:`Plugin commands`},{id:`skill`,label:`Skills`}],lW=new Set(sW.map(e=>e.id));function uW(){let e=Z(e=>e.composer.text),t=XC(),{permissionMode:n,setPermissionMode:r,clearContext:i,setMaxThinkingTokens:a,getContextUsage:o,availableSlashCommands:s,suppressSlashRef:c,loopId:l}=_U(),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(0),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(!1),y=(0,_.useRef)(null),b=(0,_.useMemo)(()=>{let e=s.filter(e=>!lW.has(e.name)).map(e=>{let t=e.name.includes(`:`),n=t?e.name.split(`:`,1)[0]:void 0;return{id:e.name,name:e.name,description:e.description||(t?`from ${n} plugin`:`skill`),icon:t?Be:tt,group:t?`plugin`:`skill`,action:`agent`,prefix:``,pluginName:n}});return[...sW,...e]},[s]),x=typeof e==`string`?e.trimStart():e,S=typeof x==`string`&&x.startsWith(`/`)&&!x.includes(` `);S&&c.current&&(S=!1);let C=S?x.slice(1).toLowerCase():``,w=(0,_.useMemo)(()=>b.filter(e=>!C||e.id.toLowerCase().includes(C)||e.name.toLowerCase().includes(C)),[b,C]),T=(0,_.useMemo)(()=>{let e={quick:0,plugin:1,skill:2};return[...w].sort((t,n)=>t.group===n.group?t.group===`plugin`&&t.pluginName!==n.pluginName?(t.pluginName??``).localeCompare(n.pluginName??``):t.id.localeCompare(n.id):e[t.group]-e[n.group])},[w]),E=(0,_.useMemo)(()=>{let e=new Map;for(let t of T){let n=e.get(t.group)??[];n.push(t),e.set(t.group,n)}return e},[T]);(0,_.useEffect)(()=>{S?(d(!0),h(C),p(0)):d(!1)},[S,C]);let D=(0,_.useCallback)(e=>{if(e.action===`toggle`&&e.toggleKey===`permissionMode`){let e=[`bypassPermissions`,`auto`,`dontAsk`,`acceptEdits`,`plan`,`default`],i=e[(e.indexOf(n)+1)%e.length];r(i),t.setText(``)}else e.action===`command`?e.commandKey===`clearContext`?(i(),t.setText(``)):e.commandKey===`setMaxThinkingTokens`?(a(e.tokens??null),t.setText(``)):e.commandKey===`getContextUsage`?(o(),t.setText(``)):e.commandKey===`openMcpPanel`&&(v(!0),t.setText(``)):e.action===`agent`&&t.setText(`/${e.id} `);d(!1)},[t,n,r,i,a,o]);(0,_.useEffect)(()=>{if(!u)return;let e=e=>{e.key===`ArrowDown`?(e.preventDefault(),e.stopImmediatePropagation(),p(e=>Math.min(e+1,T.length-1))):e.key===`ArrowUp`?(e.preventDefault(),e.stopImmediatePropagation(),p(e=>Math.max(e-1,0))):e.key===`Enter`&&T.length>0?(e.preventDefault(),e.stopImmediatePropagation(),D(T[f])):e.key===`Escape`&&(e.preventDefault(),e.stopImmediatePropagation(),t.setText(``))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[u,T,f,t,D]),(0,_.useEffect)(()=>{if(!y.current)return;let e=y.current.querySelector(`[data-slash-idx="${f}"]`);e&&e.scrollIntoView({block:`nearest`})},[f]);let O=-1;return g&&(!u||T.length===0)?(0,G.jsx)(`div`,{className:`relative`,children:(0,G.jsx)(`div`,{className:`absolute bottom-0 left-0 mb-1 w-[28rem] rounded-lg border border-gray-200 bg-white shadow-lg z-20`,children:(0,G.jsx)(aW,{onClose:()=>v(!1),loopId:l})})}):!u||T.length===0?null:(0,G.jsxs)(`div`,{className:`relative`,children:[g&&(0,G.jsx)(`div`,{className:`absolute bottom-0 left-0 mb-1 w-[28rem] rounded-lg border border-gray-200 bg-white shadow-lg z-30`,children:(0,G.jsx)(aW,{onClose:()=>v(!1),loopId:l})}),(0,G.jsx)(`div`,{className:`absolute bottom-0 left-0 mb-1 w-72 rounded-lg border border-gray-200 bg-white shadow-lg z-20`,children:(0,G.jsx)(`div`,{ref:y,className:`max-h-72 overflow-y-auto py-1`,children:cW.map(e=>{let t=E.get(e.id);return!t||t.length===0?null:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`px-3 pt-2 pb-1`,children:(0,G.jsx)(`p`,{className:`text-[10px] font-medium text-gray-400 uppercase tracking-wider`,children:e.label})}),t.map(e=>{O+=1;let t=O,r=e.icon,i=t===f,a=e.toggleKey===`permissionMode`&&n!==`bypassPermissions`||e.isActive;return(0,G.jsxs)(`button`,{type:`button`,"data-slash-idx":t,onMouseEnter:()=>p(t),onMouseDown:t=>{t.preventDefault(),D(e)},className:`w-full flex items-center gap-2.5 px-3 py-1.5 text-left transition-colors ${i?`bg-blue-50`:`hover:bg-gray-50`}`,children:[(0,G.jsx)(r,{className:`h-4 w-4 flex-shrink-0 ${a?`text-blue-600`:`text-gray-400`}`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsxs)(`span`,{className:`text-sm font-medium text-gray-700`,children:[`/`,e.id]}),e.action===`toggle`&&a&&(0,G.jsx)(`span`,{className:`rounded bg-blue-100 px-1 py-0.5 text-[9px] text-blue-600`,children:`ON`})]}),(0,G.jsx)(`p`,{className:`text-xs text-gray-500 truncate`,children:e.description})]})]},e.id)})]},e.id)})})})]})}function dW({used:e,total:t}){if(!t||t<=0)return null;let n=Math.min(100,e/t*100),r=2*Math.PI*10,i=r-n/100*r;return(0,G.jsxs)(Bp,{children:[(0,G.jsx)(Vp,{asChild:!0,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-gray-500`,children:[(0,G.jsxs)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,className:`-rotate-90 transform`,children:[(0,G.jsx)(`circle`,{cx:`12`,cy:`12`,r:10,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,className:`text-gray-300`}),(0,G.jsx)(`circle`,{cx:`12`,cy:`12`,r:10,fill:`none`,stroke:n<50?`var(--color-blue-500)`:n<75?`var(--color-amber-500)`:`var(--color-red-500)`,strokeWidth:`2`,strokeDasharray:r,strokeDashoffset:i,strokeLinecap:`round`})]}),(0,G.jsxs)(`span`,{children:[n.toFixed(0),`%`]})]})}),(0,G.jsx)(Hp,{children:(0,G.jsx)(`div`,{className:`text-xs`,children:(0,G.jsxs)(`p`,{children:[e.toLocaleString(),` / `,t.toLocaleString(),` tokens`]})})})]})}function fW({loopId:e,onPick:t,onClose:n}){let[r,i]=(0,_.useState)([]),[a,o]=(0,_.useState)([]),[s,c]=(0,_.useState)(!0),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(0),[p,m]=(0,_.useState)(new Set),[h,g]=(0,_.useState)({}),v=(0,_.useRef)(null),y=(0,_.useRef)(null);(0,_.useEffect)(()=>{c(!0),Promise.all([vm(e,`workdir`).catch(()=>[]),ym(e,`workdir`).catch(()=>[])]).then(([e,t])=>{i(e),o(t),c(!1)})},[e]);let b=l.trim().length>0,x=(0,_.useMemo)(()=>{let e=l.trim().toLowerCase();return e?a.filter(t=>t.type===`file`&&(t.path.toLowerCase().includes(e)||t.name.toLowerCase().includes(e))):[]},[a,l]),S=(0,_.useMemo)(()=>{if(b)return[];let e=[];function t(n,r){for(let i of n)e.push({entry:i,depth:r}),i.type===`dir`&&p.has(i.path)&&h[i.path]&&t(h[i.path],r+1)}return t(r,0),e},[r,b,p,h]);(0,_.useEffect)(()=>{f(0)},[l]),(0,_.useEffect)(()=>{y.current&&y.current.children[d]?.scrollIntoView({block:`nearest`})},[d]);let C=(0,_.useCallback)(async t=>{if(p.has(t.path))m(e=>{let n=new Set(e);return n.delete(t.path),n});else{if(!h[t.path]){let n=await vm(e,t.path).catch(()=>[]);g(e=>({...e,[t.path]:n}))}m(e=>new Set(e).add(t.path))}},[p,h,e]),w=(0,_.useCallback)(e=>{if(e.type===`dir`){C(e);return}t(e.path)},[C,t]);return(0,ft.createPortal)((0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/20`,onClick:n}),(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center pt-[15vh]`,onClick:n,children:(0,G.jsxs)(`div`,{className:`w-[420px] max-w-[calc(100vw-2rem)] max-h-[60vh] bg-white rounded-xl shadow-2xl border border-gray-200 flex flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),n();return}if(b)e.key===`ArrowDown`?(e.preventDefault(),f(e=>Math.min(e+1,x.length-1))):e.key===`ArrowUp`?(e.preventDefault(),f(e=>Math.max(e-1,0))):e.key===`Enter`&&(e.preventDefault(),x[d]&&t(x[d].path));else if(e.key===`ArrowDown`)e.preventDefault(),f(e=>Math.min(e+1,S.length-1));else if(e.key===`ArrowUp`)e.preventDefault(),f(e=>Math.max(e-1,0));else if(e.key===`ArrowRight`||e.key===`ArrowLeft`){e.preventDefault();let t=S[d];if(!t||t.entry.type!==`dir`)return;let n=p.has(t.entry.path);(e.key===`ArrowRight`&&!n||e.key===`ArrowLeft`&&n)&&C(t.entry)}else e.key===`Enter`&&(e.preventDefault(),S[d]&&w(S[d].entry))},children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 border-b border-gray-200 shrink-0`,children:[(0,G.jsx)(We,{className:`h-4 w-4 text-gray-400 shrink-0`}),(0,G.jsx)(`input`,{ref:v,autoFocus:!0,type:`text`,value:l,onChange:e=>u(e.target.value),placeholder:`Search files...`,className:`flex-1 text-sm outline-none text-gray-900 placeholder:text-gray-400`})]}),(0,G.jsx)(`div`,{ref:y,className:`flex-1 overflow-y-auto py-2`,role:`listbox`,children:s?(0,G.jsx)(`div`,{className:`px-4 py-8 text-center text-sm text-gray-400`,children:`Loading...`}):b?x.length===0?(0,G.jsx)(`div`,{className:`px-4 py-8 text-center text-sm text-gray-400`,children:`No files match your search`}):x.map((e,n)=>(0,G.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n===d,onClick:()=>t(e.path),onMouseEnter:()=>f(n),className:Y(`w-full px-6 py-1.5 text-left flex items-center gap-2 transition-colors text-[12px]`,n===d&&`bg-blue-50`),children:[(0,G.jsx)(le,{size:12,className:`text-blue-400 shrink-0`}),(0,G.jsx)(`span`,{className:`truncate font-mono text-gray-700`,children:e.path})]},e.path)):r.length===0?(0,G.jsx)(`div`,{className:`px-4 py-8 text-center text-sm text-gray-400`,children:`No files found`}):S.map(({entry:e,depth:t},n)=>{let r=e.type===`dir`,i=p.has(e.path);return(0,G.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n===d,onClick:()=>w(e),onMouseEnter:()=>f(n),className:Y(`w-full text-left flex items-center gap-1.5 px-2 py-1 text-[12px] transition-colors`,n===d&&`bg-blue-50`),style:{paddingLeft:12+t*16},children:[r?(0,G.jsxs)(G.Fragment,{children:[i?(0,G.jsx)(F,{size:11,className:`text-gray-300 shrink-0`}):(0,G.jsx)(I,{size:11,className:`text-gray-300 shrink-0`}),(0,G.jsx)(pe,{size:13,className:`text-amber-500 shrink-0`})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`w-[11px] shrink-0`}),(0,G.jsx)(le,{size:13,className:`text-blue-400 shrink-0`})]}),(0,G.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-4 px-4 py-2 border-t border-gray-100 text-[10px] text-gray-400 shrink-0`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(O,{className:`h-3 w-3`}),(0,G.jsx)(T,{className:`h-3 w-3`}),`navigate`]}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(W,{className:`h-3 w-3`}),`select`]}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`kbd`,{className:`px-1 py-0.5 rounded bg-gray-100 font-mono text-[9px]`,children:`esc`}),`close`]})]})]})})]}),document.body)}var pW=2e5,mW=500;function hW({pickedFile:e,editorSelection:t}){let n=Z(e=>e.thread.isRunning),r=Z(e=>typeof e.composer.text==`string`&&e.composer.text.trim().length>0),i=Z(e=>e.composer.text),{provider:a,permissionMode:o,setPermissionMode:s,enqueueMessage:c,queue:l,clearQueue:u,removeFromQueue:d,loopId:f,contextTokens:p,cumulativeTokens:m,getStreamingTokenCount:h,getWaitingForResponse:g,suppressSlashRef:v,goal:y,setGoal:b,goalStatus:x,completeGoal:S}=_U(),C=a?.contextWindow??pW,w=Rv(),[T,E]=(0,_.useState)(!1),[D,k]=(0,_.useState)([]),[A,j]=(0,_.useState)(!1),M=[...T&&e?[e]:[],...D],N=()=>E(e=>!e),P=e=>{k(t=>t.includes(e)?t:[...t,e]),j(!1)},F=e=>{k(t=>t.filter(t=>t!==e))},I=e=>{let t=e.lastIndexOf(`/`);return t>=0?e.slice(t+1):e},L=(0,_.useRef)(``),R=(0,_.useRef)([]),[B,V]=(0,_.useState)(!1);(0,_.useEffect)(()=>{let n=!1;async function r(){if(M.length===0){L.current=``,R.current=[];return}V(!0);let r=[],i=[];for(let a of M){if(n)return;try{let n=await bm(f,a);if(n&&n.content){let o=a.includes(`.`)?a.split(`.`).pop()??``:``,s=a===e?t:null,c=n.content,l=a;if(s){let e=n.content.split(`
|
|
105
105
|
`),t=Math.max(0,s.from-1),r=Math.min(e.length,s.to);c=e.slice(t,r).join(`
|
|
106
106
|
`),l=`${a} (${s.from}-${s.to})`}let u=c.replace(/```/g,"```");r.push(`\n# File: ${l}\n\`\`\`${o}\n${u}\n\`\`\`\n`),i.push({path:l,content:c})}}catch{}}n||(L.current=r.join(``),R.current=i,V(!1))}return r(),()=>{n=!0}},[M.join(`,`),f,e,t?.from,t?.to]);let H=e=>{let t=L.current;return t?`${t}\n${e}`:e},[U,ee]=(0,_.useState)([]),[W,te]=(0,_.useState)(-1),ne=(0,_.useRef)(``),re=(0,_.useRef)(``);re.current=typeof i==`string`?i:``,(0,_.useEffect)(()=>{f&&zm(f).then(e=>{ee(e),te(-1)})},[f]);let ie=e=>{if(!e.trim()||!f)return;let t=e.trim();ee(e=>{if(e[e.length-1]===t)return e;let n=[...e,t];return n.length>mW&&n.splice(0,n.length-mW),n}),te(-1),Bm(f,t).catch(()=>{})},ae=()=>{let e=typeof i==`string`?i.trim():``;if(e){if(ie(e),L.current)try{sessionStorage.setItem(`loopat:pendingFileContext`,L.current)}catch{}c(H(e)),w.composer().setText(``)}};return(0,G.jsxs)(WT.Root,{className:`relative flex w-full flex-col`,onSubmit:()=>{let e=re.current.trim();if(e&&(ie(e),L.current))try{sessionStorage.setItem(`loopat:pendingFileContext`,L.current)}catch{}},children:[(0,G.jsx)(XU,{isLoading:n,getTokenCount:h,getWaitingForResponse:g}),l.length>0&&(0,G.jsx)(`div`,{className:`mb-1.5 space-y-1 px-2`,children:l.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2 bg-gray-50 border border-gray-200 rounded-md px-2.5 py-1.5`,children:[(0,G.jsxs)(`span`,{className:`text-xs text-gray-600 line-clamp-3 break-words whitespace-pre-wrap min-w-0`,children:[(0,G.jsxs)(`span`,{className:`text-gray-400 mr-1.5 shrink-0`,children:[t+1,`.`]}),e]}),(0,G.jsx)(`button`,{onClick:()=>d(t),className:`text-gray-400 hover:text-gray-600 shrink-0 p-0.5 rounded hover:bg-gray-100 transition-colors`,title:`Remove from queue`,children:(0,G.jsx)(ut,{className:`h-3.5 w-3.5`})})]},t))}),M.length>0&&(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 px-1 mb-1 flex-wrap`,children:[M.map(n=>(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-blue-200 bg-blue-50 px-2 py-0.5 text-[11px] text-blue-700`,children:[(0,G.jsx)(le,{size:11,className:`shrink-0`}),(0,G.jsx)(`span`,{className:`truncate max-w-[160px]`,children:I(n)}),n!==e&&(0,G.jsx)(`button`,{onClick:()=>F(n),className:`ml-0.5 hover:text-blue-900`,children:(0,G.jsx)(ut,{size:11})}),n===e&&T&&(0,G.jsx)(`span`,{className:`text-[9px] text-blue-400 ml-0.5`,children:t?`(${t.from}-${t.to})`:`editor`})]},n)),B&&(0,G.jsx)(`span`,{className:`text-[10px] text-gray-400`,children:`loading...`})]}),y&&(0,G.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 px-2 py-1.5 rounded-lg border group ${x===`completed`?`border-green-200 bg-green-50`:`border-amber-200 bg-amber-50`}`,children:[x===`completed`?(0,G.jsx)(z,{className:`h-3.5 w-3.5 text-green-600 shrink-0`}):(0,G.jsx)(et,{className:`h-3.5 w-3.5 text-amber-600 shrink-0`}),(0,G.jsx)(`span`,{className:`text-xs font-medium truncate flex-1 min-w-0 ${x===`completed`?`text-green-800 line-through`:`text-amber-800`}`,children:y}),x===`active`&&(0,G.jsx)(`button`,{onClick:()=>S?.(),className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-medium text-amber-700 hover:bg-amber-200 opacity-0 group-hover:opacity-100 transition-opacity`,title:`Mark goal as complete`,children:`Done`}),(0,G.jsx)(`button`,{onClick:()=>b?.(null),className:`shrink-0 p-0.5 rounded hover:bg-amber-200/50 opacity-0 group-hover:opacity-100 transition-opacity`,title:`Clear goal`,children:(0,G.jsx)(ut,{className:`h-3 w-3 ${x===`completed`?`text-green-500`:`text-amber-600`}`})})]}),(0,G.jsxs)(`div`,{"data-slot":`composer-shell`,className:`flex w-full flex-col gap-2 rounded-2xl border border-gray-200 bg-white p-2.5 shadow-sm`,children:[(0,G.jsx)(uW,{}),(0,G.jsx)(WT.Input,{placeholder:`Send a message...`,className:`max-h-32 min-h-10 w-full resize-none bg-transparent px-1.5 py-1 text-sm text-gray-900 outline-none placeholder:text-gray-400`,rows:1,autoFocus:!0,"aria-label":`Message input`,onKeyDown:e=>{if(!(e.nativeEvent.isComposing||e.keyCode===229)){if(e.key===`c`&&e.ctrlKey&&!e.altKey&&!e.metaKey&&!e.shiftKey&&!/windows/i.test(navigator.userAgent)){let t=e.target;if(t.selectionStart===t.selectionEnd&&re.current.trim().length>0){e.preventDefault(),w.composer().setText(``);return}}if(e.key!==`ArrowUp`&&e.key!==`ArrowDown`&&(v.current=!1),e.key===`Enter`&&!e.nativeEvent.isComposing&&!e.shiftKey&&n){e.preventDefault(),ae();return}if(e.key===`ArrowUp`&&!e.shiftKey&&!e.altKey&&!e.metaKey&&!e.ctrlKey){if(U.length===0)return;if(e.preventDefault(),v.current=!0,W===-1)ne.current=re.current,te(U.length-1),w.composer().setText(U[U.length-1]);else if(W>0){let e=W-1;te(e),w.composer().setText(U[e])}return}if(e.key===`ArrowDown`&&!e.shiftKey&&!e.altKey&&!e.metaKey&&!e.ctrlKey){if(W===-1)return;if(e.preventDefault(),v.current=!0,W<U.length-1){let e=W+1;te(e),w.composer().setText(U[e])}else te(-1),w.composer().setText(ne.current);return}}}}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-0.5 border-t border-gray-100 pt-2 overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-0.5 min-w-0`,children:[(0,G.jsx)(dW,{used:Math.min(p,C),total:C}),(0,G.jsx)(rW,{}),(0,G.jsx)(iW,{onPick:e=>{let t=re.current,n=t.length===0||t.endsWith(` `)?`${t}${e}`:`${t} ${e}`;w.composer().setText(n)}}),e&&(0,G.jsxs)(`button`,{type:`button`,onClick:N,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] transition-colors ${T?`bg-blue-50 text-blue-600 border border-blue-200`:`text-gray-400 hover:text-gray-600 hover:bg-gray-100`}`,title:T?`Remove editor file from context`:`Include editor file in context`,children:[(0,G.jsx)(le,{size:12}),I(e)]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>j(e=>!e),className:`inline-flex items-center justify-center rounded-md border border-gray-200 bg-gray-50 w-[21px] h-[21px] mt-px text-gray-500 hover:bg-gray-100 transition-colors`,title:`Add file to context`,children:(0,G.jsx)(ce,{size:12})}),A&&(0,G.jsx)(fW,{loopId:f,onPick:P,onClose:()=>j(!1)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 sm:gap-2 shrink-0`,children:[(0,G.jsx)(nW,{mode:o,onChange:s}),r&&(n?(0,G.jsx)(wg,{type:`button`,variant:`default`,size:`icon`,onClick:ae,className:`h-8 w-8 rounded-lg bg-amber-500 hover:bg-amber-600 text-white`,"aria-label":`Enqueue message`,title:`Enqueue message`,children:(0,G.jsx)(we,{className:`h-4 w-4`})}):(0,G.jsx)(WT.Send,{asChild:!0,children:(0,G.jsx)(wg,{type:`button`,variant:`default`,size:`icon`,className:`h-8 w-8 rounded-lg bg-gray-800 hover:bg-gray-900 text-white`,"aria-label":`Send message`,children:(0,G.jsx)(O,{className:`h-4 w-4`})})})),(0,G.jsx)(zv,{condition:e=>e.thread.isRunning,children:(0,G.jsx)(WT.Cancel,{asChild:!0,children:(0,G.jsx)(wg,{type:`button`,variant:`default`,size:`icon`,className:`h-8 w-8 rounded-lg bg-red-500 hover:bg-red-600 text-white`,"aria-label":`Stop generating`,children:(0,G.jsx)(Ze,{className:`h-3 w-3 fill-current`})})})})]})]})]})]})}function gW({questions:e,toolUseId:t,onAnswers:n,onDismiss:r,disabled:i=!1}){let[a,o]=(0,_.useState)({}),[s,c]=(0,_.useState)({}),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(0),p=Array.isArray(e)?e.filter(e=>e!=null&&typeof e.question==`string`&&e.question.length>0&&Array.isArray(e.options)):[];if(p.length===0)return null;let m=(e,t)=>{i||l||(c(t=>{if(!t[e])return t;let n={...t};return delete n[e],n}),o(n=>({...n,[e]:t})))},h=(e,t)=>{i||l||(c(t=>{if(!t[e])return t;let n={...t};return delete n[e],n}),o(n=>{let r=(n[e]??``).split(`,`).filter(Boolean),i=r.indexOf(t);return i>=0?r.splice(i,1):r.push(t),{...n,[e]:r.join(`,`)}}))},g=(e,t)=>{i||l||(c(n=>({...n,[e]:t})),o(t=>{if(!t[e])return t;let n={...t};return delete n[e],n}))},v=e=>s[e.question]?.trim()||a[e.question]||``,y=p.every(e=>{let t=v(e);return t!==void 0&&t!==``}),b=e=>{let t=v(e);return t!==void 0&&t!==``},x=()=>{if(!y||!t||!n||l)return;u(!0);let e={};for(let t of p)e[t.question]=v(t);n(t,e)},S=()=>{i||l||(u(!0),r?.(t||``))},C=()=>{f(e=>Math.min(e+1,p.length-1))},w=(e,t)=>e.header?e.header:`Question ${t+1}`,T=p[d],E=a[T.question]??``,D=new Set(E.split(`,`).filter(Boolean)),O=Array.isArray(T.options)?T.options:[],k=s[T.question]??``;return(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-violet-600 font-medium`,children:[(0,G.jsx)(B,{className:`h-3.5 w-3.5`}),(0,G.jsx)(`span`,{children:p.length>1?`Question ${d+1} of ${p.length}`:`Question`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:S,disabled:i||l,className:`flex items-center justify-center h-5 w-5 rounded text-gray-400 hover:text-gray-600 hover:bg-gray-100 transition-colors`,children:(0,G.jsx)(ut,{className:`h-3.5 w-3.5`})})]}),p.length>1&&(0,G.jsx)(`div`,{className:`flex gap-1 border-b border-gray-200`,children:p.map((e,t)=>{let n=b(e);return(0,G.jsxs)(`button`,{type:`button`,disabled:i||l,onClick:()=>f(t),className:Y(`flex items-center gap-1 px-2.5 py-1.5 text-[11px] font-medium transition-colors border-b-2 -mb-[1px] whitespace-nowrap`,t===d?`border-violet-500 text-violet-700`:`border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300`,(i||l)&&`cursor-default opacity-70`),children:[n&&(0,G.jsx)(P,{className:`h-3 w-3 text-emerald-500`}),w(e,t)]},t)})}),(0,G.jsxs)(`div`,{className:`overflow-y-auto max-h-[260px] space-y-1.5`,children:[T.header&&(0,G.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-gray-400`,children:T.header}),(0,G.jsx)(`p`,{className:`text-[12px] text-gray-800 font-medium`,children:T.question}),(0,G.jsx)(`div`,{className:`space-y-1`,children:O.map((e,t)=>{let n=typeof e?.label==`string`?e.label:``,r=typeof e?.description==`string`?e.description:``;if(!n)return null;let a=T.multiSelect?D.has(n):E===n;return(0,G.jsx)(`button`,{type:`button`,disabled:i||l,onClick:()=>T.multiSelect?h(T.question,n):m(T.question,n),className:Y(`w-full text-left px-3 py-2 rounded-md border text-[12px] transition-colors`,a?`border-violet-400 bg-violet-50 text-violet-900`:`border-gray-200 bg-white text-gray-700 hover:border-gray-300 hover:bg-gray-50`,(i||l)&&`cursor-default opacity-70`),children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[T.multiSelect?(0,G.jsx)(`span`,{className:Y(`h-3.5 w-3.5 rounded border flex-shrink-0 flex items-center justify-center`,a?`border-violet-500 bg-violet-500`:`border-gray-300`),children:a&&(0,G.jsx)(`svg`,{className:`h-2.5 w-2.5 text-white`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,G.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:3,d:`M5 13l4 4L19 7`})})}):(0,G.jsx)(`span`,{className:Y(`h-3.5 w-3.5 rounded-full border flex-shrink-0`,a?`border-violet-500 bg-violet-500`:`border-gray-300`),children:a&&(0,G.jsx)(`span`,{className:`block h-1.5 w-1.5 rounded-full bg-white m-0.5`})}),(0,G.jsx)(`span`,{children:n}),r&&(0,G.jsxs)(`span`,{className:`text-[10px] text-gray-400`,children:[`— `,r]})]})},t)})}),(0,G.jsx)(`input`,{type:`text`,value:k,onChange:e=>g(T.question,e.target.value),placeholder:`Or type your own answer...`,disabled:i||l,className:Y(`w-full px-3 py-1.5 rounded-md border text-[12px] outline-none transition-colors`,k?`border-violet-300 bg-violet-50/50 text-violet-900 placeholder:text-violet-300`:`border-gray-200 bg-white text-gray-700 placeholder:text-gray-300 hover:border-gray-300 focus:border-violet-300`,(i||l)&&`cursor-default opacity-70`)})]}),!l&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between pt-1`,children:[p.length>1&&d<p.length-1?(0,G.jsxs)(`button`,{type:`button`,disabled:i,onClick:C,className:`inline-flex items-center gap-1 rounded-lg px-3 py-1.5 text-[11px] font-medium text-gray-500 hover:text-gray-700 hover:bg-gray-100 transition-colors`,children:[`Next`,(0,G.jsx)(I,{className:`h-3 w-3`})]}):(0,G.jsx)(`div`,{}),(0,G.jsxs)(`button`,{type:`button`,disabled:!y||i,onClick:x,className:Y(`inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,y?`bg-gray-900 text-white hover:bg-gray-800`:`bg-gray-100 text-gray-400 cursor-not-allowed`),children:[(0,G.jsx)(Ge,{className:`h-3 w-3`}),`Submit`]})]}),l&&(0,G.jsx)(`p`,{className:`text-[11px] text-emerald-600 font-medium text-right`,children:`Submitted`})]})}var _W=()=>(0,G.jsxs)(`div`,{className:`my-auto flex grow flex-col items-center justify-center gap-3`,children:[(0,G.jsx)(`div`,{className:`h-5 w-5 animate-spin rounded-full border-2 border-gray-300 border-t-gray-600`}),(0,G.jsx)(`p`,{className:`text-sm text-gray-400`,children:`Loading history…`})]}),vW=`loopat:composer:drafts`;function yW(e){try{let t=localStorage.getItem(vW);return t?JSON.parse(t)[e]??null:null}catch{return null}}function bW(e,t){try{let n=localStorage.getItem(vW),r=n?JSON.parse(n):{};t.trim()?r[e]=t:delete r[e],localStorage.setItem(vW,JSON.stringify(r))}catch{}}function xW({archived:e=!1,onUnarchive:t,readOnly:n=!1,repo:r,branch:i,title:a,driver:o,driverHistory:s,rfdRequestedAt:c,rfdRequestedBy:l,onTakeDrive:u,pickedFile:d,editorSelection:f}={}){let{questions:p,sendAnswers:m,loadingHistory:h,loopId:g,hasHistory:v,showHistory:y,toggleShowHistory:b,hasOlderMessages:x,loadMoreMessages:S,thinkingBudget:C,setMaxThinkingTokens:w}=_U(),[E,D]=(0,_.useState)(`normal`),O=Z(e=>e.thread.isEmpty&&!e.thread.isRunning)&&!h,k=(0,_.useRef)(null),A=(0,_.useRef)(null),[j,M]=(0,_.useState)(!1),N=(0,_.useCallback)(()=>{let e=A.current;e&&e.scrollTo({top:e.scrollHeight,behavior:`smooth`})},[]),P=(0,_.useRef)(v);P.current=v;let F=(0,_.useRef)(y);F.current=y;let I=(0,_.useRef)(x);I.current=x;let[L,R]=(0,_.useState)(!1),z=(0,_.useRef)({oldScrollTop:0,oldScrollHeight:0,active:!1}),B=(0,_.useCallback)(()=>{let e=A.current;e&&(z.current={oldScrollTop:e.scrollTop,oldScrollHeight:e.scrollHeight,active:!0}),b()},[b]),V=(0,_.useRef)({oldScrollTop:0,oldScrollHeight:0,active:!1}),H=(0,_.useCallback)(()=>{let e=A.current;e&&(V.current={oldScrollTop:e.scrollTop,oldScrollHeight:e.scrollHeight,active:!0}),ee(!0),S()},[S]),[U,ee]=(0,_.useState)(!1),W=(0,_.useRef)(!1);W.current=U;let te=XC(),ne=Z(e=>e.composer.text),re=(0,_.useRef)(ne);re.current=ne,(0,_.useEffect)(()=>{let e=yW(g);e&&te.setText(e)},[]),(0,_.useEffect)(()=>()=>{bW(g,re.current)},[g]),(0,_.useEffect)(()=>{if(!ne)return;let e=setTimeout(()=>{bW(g,ne)},300);return()=>clearTimeout(e)},[ne,g]);let[ie,ae]=(0,_.useState)(ne);(0,_.useEffect)(()=>{ie&&!ne&&bW(g,``),ae(ne)},[ne,g]);let oe=(0,_.useRef)(null),se=(0,_.useRef)(!1),ce=(0,_.useRef)(h);ce.current=h;let le=(0,_.useRef)(h);(0,_.useEffect)(()=>{let e=k.current,t=e?.parentElement;if(!e||!t)return;A.current=t;let n=()=>t.scrollTop+t.clientHeight>=t.scrollHeight-120,r=!1,i=null,a=e=>{e.deltaY<0&&(r=!0,i&&clearTimeout(i),i=setTimeout(()=>{i=null,n()&&(r=!1)},200))},o=()=>{!i&&n()?r=!1:n()||(r=!0),M(t.scrollTop+t.clientHeight<t.scrollHeight-200),R(t.scrollTop<20&&P.current),t.scrollTop<40&&I.current&&!W.current&&H()};t.addEventListener(`scroll`,o,{passive:!0}),t.addEventListener(`wheel`,a,{passive:!0});let s=null,c=!1,l=()=>{if(se.current&&r||c||!se.current&&t.scrollHeight<=t.clientHeight+10)return;let e=t.style.scrollBehavior;t.style.scrollBehavior=`auto`,t.scrollTop=t.scrollHeight,t.style.scrollBehavior=e,se.current||(ce.current||(se.current=!0),r=!1),c=!0,requestAnimationFrame(()=>{setTimeout(()=>{c=!1},120)})};l();let u=new ResizeObserver(()=>{s||ce.current||c||(s=setTimeout(()=>{s=null,l()},80))});return u.observe(e),()=>{u.disconnect(),s&&clearTimeout(s),i&&clearTimeout(i),t.removeEventListener(`scroll`,o),t.removeEventListener(`wheel`,a)}},[]),(0,_.useEffect)(()=>{if(le.current&&!h){let e=A.current;if(e){let t=e.style.scrollBehavior;e.style.scrollBehavior=`auto`,e.scrollTop=e.scrollHeight,e.style.scrollBehavior=t,se.current=!0}}le.current=h},[h]),(0,_.useEffect)(()=>{if(!z.current.active)return;let e=A.current;if(!e)return;let{oldScrollTop:t,oldScrollHeight:n}=z.current;z.current.active=!1,requestAnimationFrame(()=>{e.scrollTop=t+(e.scrollHeight-n)})},[y]),(0,_.useEffect)(()=>{if(!V.current.active)return;let e=A.current;if(!e)return;let{oldScrollTop:t,oldScrollHeight:n}=V.current;V.current.active=!1,requestAnimationFrame(()=>{e.scrollTop=t+(e.scrollHeight-n)})},[x]),(0,_.useEffect)(()=>{if(!U)return;let e=setTimeout(()=>ee(!1),200);return()=>clearTimeout(e)},[U,x]);let ue=p.size>0?Array.from(p.entries()):[];return(0,G.jsxs)(cD.Root,{className:`flex h-full flex-col bg-white relative`,style:{"--thread-max-width":`44rem`},children:[(0,G.jsx)(cD.Viewport,{turnAnchor:`top`,className:O?`hidden`:`relative flex-1 overflow-x-auto overflow-y-scroll scroll-smooth`,children:(0,G.jsxs)(`div`,{ref:k,className:`mx-auto flex w-full min-h-full flex-col px-2 md:px-3 pt-3 md:pt-4`,children:[h&&(0,G.jsx)(_W,{}),L&&(0,G.jsx)(`div`,{className:`flex justify-center pb-2`,children:(0,G.jsx)(`button`,{type:`button`,onClick:B,className:`rounded-full border border-gray-200 bg-white px-4 py-1.5 text-xs text-gray-500 hover:text-gray-700 hover:border-gray-300 shadow-sm transition-colors`,children:y?`Collapse earlier messages`:`View earlier messages`})}),U&&(0,G.jsx)(`div`,{className:`flex justify-center py-2`,children:(0,G.jsx)(`span`,{className:`inline-block h-4 w-4 animate-spin rounded-full border-2 border-gray-300 border-t-gray-500`})}),(s??[]).length>1&&(0,G.jsx)(`div`,{className:`flex flex-col gap-1 pb-2`,children:(s??[]).slice(1).map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-gray-500`,children:[(0,G.jsx)(`div`,{className:`flex-1 h-px bg-gray-200`}),(0,G.jsxs)(`span`,{className:`text-gray-600`,children:[(0,G.jsx)(`span`,{className:`text-amber-600`,children:`▸`}),` `,`driving by `,(0,G.jsx)(`span`,{className:`text-gray-900 font-medium`,children:e.driver}),` since `,new Date(e.since).toLocaleString()]}),(0,G.jsx)(`div`,{className:`flex-1 h-px bg-gray-200`})]},e.since))}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 pb-1`,children:[(0,G.jsx)(cD.Messages,{children:({message:e})=>e.role===`user`?(0,G.jsx)(bz,{}):(0,G.jsx)(KU,{})}),(0,G.jsx)(`div`,{ref:oe}),ue.length>0&&(0,G.jsx)(HU,{name:`QuestionsPanel`,children:(0,G.jsx)(`div`,{className:`space-y-3 w-full pt-2`,children:ue.map(([e,t])=>Array.isArray(t)&&t.length>0?(0,G.jsx)(`div`,{className:`rounded-lg border border-violet-100 bg-violet-50/30 p-4 shadow-sm`,children:(0,G.jsx)(gW,{questions:t,toolUseId:e,onAnswers:m,onDismiss:e=>m(e,{})})},e):null)})})]})]})}),(0,G.jsx)(`div`,{className:O?`flex-1 flex items-center justify-center px-2 md:px-3 pb-3 md:pb-6`:`shrink-0 z-10 bg-gradient-to-t from-white via-white to-transparent px-2 md:px-3 pt-1 md:pt-2 pb-3 md:pb-6`,children:(0,G.jsxs)(`div`,{className:O?`w-full max-w-[36rem]`:``,children:[O&&(0,G.jsxs)(`div`,{className:`mb-4 space-y-2 px-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[a&&(0,G.jsx)(`h1`,{className:`text-xl font-semibold text-gray-800`,children:a}),o&&(0,G.jsxs)(`span`,{className:`text-xs text-gray-400`,children:[`driver: `,o]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-gray-400`,children:[r&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,G.jsx)(ge,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}),(0,G.jsxs)(`span`,{className:`font-mono truncate`,children:[r,i?(0,G.jsxs)(`span`,{className:`text-gray-300`,children:[` · `,i]}):``]})]}),(0,G.jsx)(`span`,{className:`ml-auto flex gap-0.5`,children:[{label:`Normal`,tokens:null,mode:`normal`},{label:`Think`,tokens:16e3,mode:`think`},{label:`Hard`,tokens:32e3,mode:`hard`},{label:`Ultrathink`,tokens:null,mode:`ultra`}].map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>{D(e.mode===`normal`?`normal`:e.mode===`ultra`?`ultra`:`normal`),w(e.tokens)},className:`px-1.5 py-0.5 text-[11px] rounded transition-colors `+((e.mode===`normal`?C===null&&E===`normal`:e.mode===`ultra`?C===null&&E===`ultra`:C===e.tokens)?`bg-gray-200 text-gray-700 font-medium`:`text-gray-400 hover:text-gray-600 hover:bg-gray-100`),children:e.label},e.label))})]})]}),e?(0,G.jsxs)(`div`,{className:`mx-3 md:mx-5 mb-3 rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 flex items-center gap-2 text-[12px] text-amber-800`,children:[(0,G.jsx)(`span`,{children:`📦`}),(0,G.jsx)(`span`,{className:`flex-1`,children:`This loop is archived (read-only).`}),t&&(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`rounded border border-amber-300 bg-white px-2 py-0.5 text-[11px] font-medium text-amber-900 hover:bg-amber-100`,children:`Unarchive`})]}):c?(0,G.jsxs)(`div`,{className:`mx-3 md:mx-5 mb-3 rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 flex items-center gap-2 text-[12px] text-amber-800`,children:[(0,G.jsx)(`span`,{children:`✋`}),(0,G.jsxs)(`span`,{className:`flex-1`,children:[`Released for drive`,l?` by ${l}`:``,` — no one can write until someone takes over.`]}),u&&(0,G.jsx)(`button`,{type:`button`,onClick:u,className:`rounded bg-amber-500 px-2 py-0.5 text-[11px] font-medium text-white hover:bg-amber-600`,children:`Drive`})]}):n?null:(0,G.jsx)(hW,{pickedFile:d,editorSelection:f})]})}),j&&(0,G.jsx)(`button`,{type:`button`,onClick:N,className:`absolute bottom-40 right-4 z-20 flex h-7 w-7 items-center justify-center rounded-full bg-white border border-gray-200 shadow-sm text-gray-400 hover:text-gray-600 hover:border-gray-300 transition-all`,"aria-label":`Scroll to bottom`,children:(0,G.jsx)(T,{className:`h-3.5 w-3.5`})})]})}function SW(){let{id:e}=Wn(),[t,n]=(0,_.useState)(null);return(0,_.useEffect)(()=>{if(!e)return;let t=!1;return(async()=>{let r=await gm(e);t||n(r??`unauthorized`)})(),()=>{t=!0}},[e]),(0,_.useEffect)(()=>{t&&typeof t==`object`&&(document.title=`${t.title} · shared`)},[t]),e?t===null?(0,G.jsx)(wW,{}):t===`unauthorized`?(0,G.jsx)(TW,{reason:`this loop is private or does not exist`}):(0,G.jsx)(CW,{meta:t}):(0,G.jsx)(TW,{reason:`missing loop id`})}function CW({meta:e}){let{runtime:t,connected:n,reconnecting:r,extra:i}=yU(e.id,``);return(0,G.jsxs)(`div`,{className:`h-full w-full flex flex-col bg-white text-gray-900`,children:[(0,G.jsxs)(`header`,{className:`h-12 shrink-0 border-b border-gray-200 bg-white flex items-center px-3 md:px-5 gap-2`,children:[(0,G.jsx)(`span`,{className:`text-lg leading-none`,children:`🧶`}),(0,G.jsx)(`span`,{className:`text-[14px] font-medium text-gray-900 truncate`,children:e.title}),(0,G.jsx)(`span`,{className:`text-[11px] px-1.5 py-0.5 rounded bg-emerald-50 text-emerald-800 border border-emerald-200`,children:`view only`}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)(`span`,{className:`text-[11px] `+(n?`text-emerald-600`:r?`text-amber-500`:`text-red-500`),title:n?`connected`:r?`reconnecting…`:`disconnected`,children:`●`})]}),(0,G.jsx)(`main`,{className:`flex-1 min-h-0`,children:(0,G.jsx)(vU,{extra:i,children:(0,G.jsx)(YC,{runtime:t,children:(0,G.jsx)(xW,{readOnly:!0})})})})]})}function wW(){return(0,G.jsx)(`div`,{className:`h-full w-full flex items-center justify-center text-gray-400 text-sm`,children:`loading…`})}function TW({reason:e}){return(0,G.jsxs)(`div`,{className:`h-full w-full flex flex-col items-center justify-center text-gray-500 gap-2 px-4 text-center`,children:[(0,G.jsx)(`span`,{className:`text-lg`,children:`🧶`}),(0,G.jsx)(`div`,{className:`text-sm`,children:`Loop unavailable`}),(0,G.jsx)(`div`,{className:`text-xs text-gray-400`,children:e})]})}function EW(e){let[t,n]=(0,_.useState)({}),r=(0,_.useRef)(null);return(0,_.useEffect)(()=>{if(e.length===0)return;let t=location.protocol===`https:`?`wss:`:`ws:`,i=new WebSocket(`${t}//${location.host}/ws/loop-status`);return r.current=i,i.onopen=()=>{i.send(JSON.stringify({type:`subscribe`,ids:e}))},i.onmessage=e=>{try{let t=JSON.parse(e.data);(t.type===`init`||t.type===`update`)&&n(e=>({...e,...t.data}))}catch{}},()=>{i&&(i.readyState===WebSocket.CONNECTING?(i.onopen=()=>i.close(),i.onmessage=null,i.onclose=null,i.onerror=null):(i.onclose=null,i.onerror=null,i.close())),r.current=null}},[e.join(`,`)]),t}var DW=`loopat:tree:expanded:`;function OW(e){try{let t=localStorage.getItem(DW+e);return t?new Set(JSON.parse(t)):new Set}catch{return new Set}}function kW(e,t){try{localStorage.setItem(DW+e,JSON.stringify([...t]))}catch{}}function AW({treeId:e,entries:t,onPick:n,picked:r,onLoadChildren:i,getContextActions:a,onAction:o,depthOffset:s=0,renderNode:c,nodeClassName:l,reloadKey:u}){return(0,G.jsx)(G.Fragment,{children:t.map(t=>(0,G.jsx)(jW,{treeId:e,entry:t,depth:s,onPick:n,picked:r,onLoadChildren:i,getContextActions:a,onAction:o,renderNode:c,nodeClassName:l,reloadKey:u},t.path))})}function jW({treeId:e,entry:t,depth:n,onPick:r,picked:i,onLoadChildren:a,getContextActions:o,onAction:s,renderNode:c,nodeClassName:l,reloadKey:u}){let[d,f]=(0,_.useState)(()=>OW(e).has(t.path)),[p,m]=(0,_.useState)(null),[h,g]=(0,_.useState)(!1),[v,y]=(0,_.useState)(null),b=(0,_.useCallback)(()=>{let n=OW(e);n.has(t.path)?n.delete(t.path):n.add(t.path),kW(e,n),f(e=>!e)},[e,t.path]),x=(0,_.useRef)(u);(0,_.useEffect)(()=>{x.current!==u&&(m(null),x.current=u)},[u]),(0,_.useEffect)(()=>{!d||p!==null||t.type===`dir`&&(g(!0),a(t.path).then(m).finally(()=>g(!1)))},[d,t.path,a,p]);let S=e=>{e.preventDefault(),e.stopPropagation(),y({x:e.clientX,y:e.clientY})},C=8+n*12;if(t.type===`dir`)return c?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{onContextMenu:S,children:c(t,n,d,b)}),d&&p&&(0,G.jsx)(G.Fragment,{children:p.map(t=>(0,G.jsx)(jW,{treeId:e,entry:t,depth:n+1,onPick:r,picked:i,onLoadChildren:a,getContextActions:o,onAction:s,renderNode:c,nodeClassName:l,reloadKey:u},t.path))}),v&&(0,G.jsx)(MW,{x:v.x,y:v.y,items:o(t).filter(e=>!e.hidden),onAction:e=>s(e,t),onClose:()=>y(null)})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{onContextMenu:S,children:(0,G.jsxs)(`button`,{type:`button`,onClick:b,className:l?l(t,n,d,!1):`w-full py-1 flex items-center gap-1.5 hover:bg-gray-50 text-left group`,style:{paddingLeft:C,paddingRight:8},children:[(0,G.jsx)(`span`,{className:`text-gray-500 w-3`,children:d?`▾`:`▸`}),(0,G.jsx)(`span`,{className:`text-gray-500`,children:d?(0,G.jsx)(pe,{size:13}):(0,G.jsx)(he,{size:13})}),(0,G.jsx)(`span`,{className:`text-[13px] text-gray-900 truncate`,children:t.name})]})}),h&&(0,G.jsx)(`div`,{className:`text-[12px] text-gray-400 italic`,style:{paddingLeft:C+12},children:`...`}),d&&p&&(0,G.jsxs)(G.Fragment,{children:[p.map(t=>(0,G.jsx)(jW,{treeId:e,entry:t,depth:n+1,onPick:r,picked:i,onLoadChildren:a,getContextActions:o,onAction:s,renderNode:c,nodeClassName:l,reloadKey:u},t.path)),p.length===0&&(0,G.jsx)(`div`,{className:`text-[12px] text-gray-400 italic py-1`,style:{paddingLeft:C+12},children:`(empty)`})]}),v&&(0,G.jsx)(MW,{x:v.x,y:v.y,items:o(t).filter(e=>!e.hidden),onAction:e=>s(e,t),onClose:()=>y(null)})]});let w=i===t.path;return c?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{onContextMenu:S,onClick:()=>r(t.path),children:c(t,n,!1,()=>{})}),v&&(0,G.jsx)(MW,{x:v.x,y:v.y,items:o(t).filter(e=>!e.hidden),onAction:e=>s(e,t),onClose:()=>y(null)})]}):(0,G.jsx)(G.Fragment,{children:(0,G.jsxs)(`div`,{className:`relative`,onContextMenu:S,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>r(t.path),className:l?l(t,n,!1,w):`w-full py-1 flex items-center gap-2 text-left `+(w?`bg-gray-100`:`hover:bg-gray-50`),style:{paddingLeft:C,paddingRight:8},children:[(0,G.jsx)(`span`,{className:`w-3 text-gray-400`,children:(0,G.jsx)(ue,{size:13})}),(0,G.jsx)(`span`,{className:`text-[13px] text-gray-900 flex-1 min-w-0 truncate`,children:t.name})]}),v&&(0,G.jsx)(MW,{x:v.x,y:v.y,items:o(t).filter(e=>!e.hidden),onAction:e=>s(e,t),onClose:()=>y(null)})]})})}function MW({x:e,y:t,items:n,onAction:r,onClose:i}){return(0,_.useEffect)(()=>{let e=e=>{e.target?.closest(`[data-context-menu]`)||i()},t=e=>{e.key===`Escape`&&i()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]),(0,ft.createPortal)((0,G.jsx)(`div`,{"data-context-menu":!0,className:`fixed z-[9999] bg-white border border-gray-200 rounded-lg shadow-lg py-1 text-[12px] min-w-[140px]`,style:{left:e,top:t},onContextMenu:e=>e.preventDefault(),children:n.map(e=>(0,G.jsxs)(`button`,{onClick:()=>{r(e.action),i()},className:`w-full px-3 py-1.5 flex items-center gap-2 text-left hover:bg-gray-50 `+(e.danger?`text-red-600 hover:bg-red-50`:`text-gray-700`),children:[e.icon,e.label]},e.action))}),document.body)}var NW=[{name:`context`,section:`context`,emoji:`🧷`,hint:`knowledge / notes / personal`},{name:`workdir`,section:`workdir`,emoji:`▣`}];function PW({loopId:e,onPick:t,picked:n}){let[r,i]=(0,_.useState)(0),a=(0,_.useRef)(null),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(``),f=(0,_.useCallback)(e=>{s(e??`workdir`),a.current?.click()},[]),p=async t=>{let n=t.target.files?.[0];if(!n)return;let r=await wm(e,n);r.ok||alert(`upload failed: ${r.error}`),i(e=>e+1),a.current&&(a.current.value=``),s(``)},m=async()=>{if(!c||!u.trim()){l(null);return}let t=c.path+`/`+u.trim(),n=!1;if(n=c.type===`file`?await xm(e,t,``):await Cm(e,t),!n){alert(`create failed`),l(null);return}l(null),d(``),i(e=>e+1)},h=(0,_.useCallback)((t,n)=>{if(t===`upload`)f(n.path);else if(t===`new-file`||t===`new-folder`)l({type:t===`new-file`?`file`:`folder`,path:n.path}),d(``);else if(t===`delete`){if(!confirm(`Delete "${n.name}"?`))return;Sm(e,n.path).then(e=>{if(!e){alert(`delete failed`);return}i(e=>e+1)})}},[f,e]),g=(0,_.useCallback)(e=>e.type===`dir`?[{label:`Upload here`,icon:(0,G.jsx)(ot,{size:12}),action:`upload`},{label:`New file`,icon:(0,G.jsx)(ce,{size:12}),action:`new-file`},{label:`New folder`,icon:(0,G.jsx)(me,{size:12}),action:`new-folder`},{label:`Delete`,icon:(0,G.jsx)(nt,{size:12}),action:`delete`,danger:!0}]:[{label:`View`,icon:(0,G.jsx)(ae,{size:12}),action:`view`},{label:`Delete`,icon:(0,G.jsx)(nt,{size:12}),action:`delete`,danger:!0}],[]);return(0,_.useCallback)(t=>vm(e,t).then(e=>e),[e]),(0,G.jsxs)(`aside`,{className:`flex-1 min-h-0 overflow-auto py-2 text-[13px]`,children:[(0,G.jsx)(`input`,{ref:a,type:`file`,className:`hidden`,onChange:p}),NW.map(a=>(0,G.jsx)(FW,{loopId:e,name:a.name,section:a.section,emoji:a.emoji,hint:a.hint,onPick:t,picked:n,onUpload:()=>f(a.name),onReload:()=>i(e=>e+1),reloadKey:r,getContextActions:g,onAction:h,treeId:`loop-${e}`},a.name+r)),c&&(0,G.jsx)(IW,{depth:1,type:c.type,value:u,onChange:d,onSubmit:m,onCancel:()=>l(null)})]})}function FW({loopId:e,name:t,section:n,emoji:r,hint:i,onPick:a,picked:o,onUpload:s,onReload:c,reloadKey:l,getContextActions:u,onAction:d,treeId:f}){let[p,m]=(0,_.useState)(!0),h=n===`context`?`w-full py-1.5 flex items-center gap-1.5 bg-cyan-50/50 hover:bg-cyan-50 text-left border-y border-cyan-100/70`:`w-full py-1.5 flex items-center gap-1.5 bg-emerald-50/40 hover:bg-emerald-50 text-left border-y border-emerald-100/70`,g=(0,_.useCallback)(t=>vm(e,t).then(e=>e),[e]);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>m(e=>!e),className:h,style:{paddingLeft:`0.5rem`,paddingRight:`0.5rem`},children:[(0,G.jsx)(`span`,{className:`text-gray-500`,children:p?`▾`:`▸`}),(0,G.jsx)(`span`,{className:`text-[12px]`,children:r}),(0,G.jsx)(`span`,{className:`text-[11px] uppercase tracking-wider font-semibold text-gray-700`,children:t}),i&&(0,G.jsx)(`span`,{className:`text-[10px] text-gray-500 italic ml-1`,children:i}),n===`workdir`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)(`span`,{onClick:e=>{e.stopPropagation(),s()},className:`text-gray-400 hover:text-gray-700 px-1 rounded hover:bg-emerald-100/50 flex items-center gap-0.5`,title:`upload file`,children:(0,G.jsx)(ot,{size:12})})]})]}),p&&(0,G.jsx)(AW,{treeId:`${f}-${t}`,entries:[{name:t,path:t,type:`dir`}],onPick:a,picked:o,onLoadChildren:g,getContextActions:u,onAction:d,depthOffset:1,reloadKey:l})]})}function IW({depth:e,type:t,value:n,onChange:r,onSubmit:i,onCancel:a}){let o=(0,_.useRef)(null);return(0,_.useEffect)(()=>{o.current?.focus()},[]),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 py-0.5`,style:{paddingLeft:8+e*12},children:[(0,G.jsx)(`span`,{className:`text-gray-400`,children:t===`file`?`📄`:`📁`}),(0,G.jsx)(`input`,{ref:o,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&i(),e.key===`Escape`&&a()},placeholder:t===`file`?`filename.txt`:`folder-name`,className:`flex-1 px-1.5 py-0.5 text-[12px] border border-gray-300 rounded outline-none focus:border-gray-900`}),(0,G.jsx)(`button`,{onClick:i,className:`text-[10px] text-emerald-600 hover:text-emerald-800 px-1`,children:`✓`}),(0,G.jsx)(`button`,{onClick:a,className:`text-[10px] text-gray-400 hover:text-gray-600 px-1`,children:`✕`})]})}function LW(e){let t=e.split(`
|
|
107
|
-
`),n=``,r=[],i=null,a=0,o=0;for(let e of t){if(e.startsWith(`diff `)){n=e;continue}if(e.startsWith(`+++ `)||e.startsWith(`--- `))continue;let t=e.match(/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(.*)$/);if(t){i&&r.push(i),a=parseInt(t[1],10),o=parseInt(t[3],10),i={header:e,lines:[]};continue}i&&(e.startsWith(`+`)?(i.lines.push({type:`add`,oldNum:null,newNum:o,text:e.slice(1)}),o++):e.startsWith(`-`)?(i.lines.push({type:`del`,oldNum:a,newNum:null,text:e.slice(1)}),a++):(i.lines.push({type:`ctx`,oldNum:a,newNum:o,text:e.startsWith(` `)?e.slice(1):e}),a++,o++))}return i&&r.push(i),{fileHeader:n,hunks:r}}function RW({filePath:e,diff:t,loading:n,onClose:r}){let i=null;if(t)try{i=LW(t)}catch{}return(0,G.jsx)(Tg,{open:!0,onOpenChange:e=>{e||r()},children:(0,G.jsxs)(Og,{className:`sm:max-w-4xl max-h-[85vh] flex flex-col bg-white p-0 gap-0`,showCloseButton:!1,children:[(0,G.jsxs)(`div`,{className:`px-4 py-2.5 border-b border-gray-200 shrink-0 flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-sm font-mono text-gray-900 truncate flex-1`,children:e}),(0,G.jsx)(`button`,{onClick:r,className:`text-gray-400 hover:text-gray-700 text-sm leading-none`,children:`✕`})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:n?(0,G.jsxs)(`div`,{className:`flex items-center justify-center py-16 text-gray-400 gap-2`,children:[(0,G.jsx)(Te,{className:`animate-spin`,size:16}),(0,G.jsx)(`span`,{className:`text-sm`,children:`loading diff...`})]}):i?(0,G.jsx)(`div`,{className:`text-xs font-mono leading-5`,children:i.hunks.map((e,t)=>(0,G.jsxs)(`div`,{className:`border-b border-gray-100 last:border-b-0`,children:[(0,G.jsx)(`div`,{className:`px-4 py-1 bg-blue-50/60 text-blue-700 border-b border-blue-100 sticky top-0`,children:e.header}),e.lines.map((e,t)=>{let n=e.type===`add`,r=e.type===`del`;return(0,G.jsxs)(`div`,{className:`flex `+(n?`bg-emerald-50`:r?`bg-red-50`:``),children:[(0,G.jsx)(`span`,{className:`w-14 shrink-0 text-right pr-3 py-px text-gray-300 select-none border-r border-gray-200 bg-gray-50`,children:e.oldNum??``}),(0,G.jsx)(`span`,{className:`w-14 shrink-0 text-right pr-3 py-px select-none border-r border-gray-200 `+(n?`bg-emerald-100/70 text-emerald-700`:r?`bg-red-100/70 text-red-500`:`text-gray-300 bg-gray-50`),children:e.newNum??``}),(0,G.jsxs)(`span`,{className:`pl-3 py-px whitespace-pre-wrap break-all flex-1 `+(n?`text-emerald-800`:r?`text-red-700`:`text-gray-700`),children:[(0,G.jsx)(`span`,{className:`select-none`,children:n?`+`:r?`−`:` `}),e.text]})]},t)})]},t))}):(0,G.jsx)(`div`,{className:`py-16 text-center text-sm text-gray-400`,children:`empty diff`})})]})})}var zW={A:{label:`A`,color:`text-emerald-600`},M:{label:`M`,color:`text-amber-600`},D:{label:`D`,color:`text-red-600`},R:{label:`R`,color:`text-purple-600`},"?":{label:`?`,color:`text-gray-400`}};function BW({loopId:e,onClose:t,onPickFile:n}){let[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!0),[l,u]=(0,_.useState)(!0),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)(``),[h,g]=(0,_.useState)(``),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)([]),[w,T]=(0,_.useState)(!1),[E,D]=(0,_.useState)(!0),O=(0,_.useCallback)(async()=>{o(!0),f(null);try{i(await vh(e))}catch{f(`Failed to load git status`)}finally{o(!1)}},[e]),k=(0,_.useCallback)(async()=>{T(!0);try{C(await Ch(e,50))}catch{}finally{T(!1)}},[e]);(0,_.useEffect)(()=>{O(),k()},[O,k]);let A=async()=>{r?.unstaged.length&&await bh(e,r.unstaged.map(e=>e.path))&&O()},j=async()=>{r?.staged.length&&await bh(e,r.staged.map(e=>e.path),!0)&&O()},M=async t=>{await bh(e,[t])&&O()},N=async t=>{await bh(e,[t],!0)&&O()},P=async t=>{await xh(e,t)&&O()},F=async()=>{if(!h.trim())return;y(!0),x(null);let t=await Sh(e,h.trim());y(!1),t.ok?(g(``),O(),k()):x(t.error??`Commit failed`)},I=p.trim().toLowerCase(),L=r?r.unstaged.filter(e=>!I||e.path.toLowerCase().includes(I)):[],R=r?r.staged.filter(e=>!I||e.path.toLowerCase().includes(I)):[],z=!r||r.unstaged.length===0&&r.staged.length===0;return(0,G.jsxs)(`aside`,{className:`w-full h-full min-w-0 bg-white flex flex-col`,children:[(0,G.jsxs)(`header`,{className:`px-3 h-8 shrink-0 border-b border-gray-200 flex items-center gap-1 text-[11px] text-gray-500`,children:[(0,G.jsx)(`span`,{className:`tracking-wide`,children:`Git Changes`}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)(`button`,{onClick:()=>{O(),k()},className:`text-gray-500 hover:text-gray-900 px-1 rounded hover:bg-gray-100`,title:`refresh`,children:(0,G.jsx)(He,{size:13,className:a||w?`animate-spin`:``})}),(0,G.jsx)(`button`,{className:`text-gray-500 hover:text-gray-900 px-1 rounded hover:bg-gray-100`,onClick:t,title:`close`,children:`✕`})]}),(0,G.jsxs)(`div`,{className:`px-3 py-2 border-b border-gray-100`,children:[(0,G.jsx)(`textarea`,{placeholder:`Commit message...`,value:h,onChange:e=>{g(e.target.value),x(null)},rows:2,className:`w-full px-2 py-1.5 text-[12px] border border-gray-200 rounded outline-none focus:border-gray-300 placeholder:text-gray-300 resize-none mb-1.5`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`button`,{onClick:F,disabled:v||!h.trim(),className:`flex-1 flex items-center justify-center gap-1 px-2 py-1 text-[11px] rounded bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-40 disabled:cursor-not-allowed`,children:[(0,G.jsx)(_e,{size:12}),v?`Committing...`:`Commit`]}),r&&r.staged.length>0&&(0,G.jsxs)(`span`,{className:`text-[10px] text-gray-400`,children:[r.staged.length,` staged`]})]}),b&&(0,G.jsx)(`div`,{className:`mt-1 text-[10px] text-red-500`,children:b})]}),(0,G.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-100`,children:(0,G.jsx)(`input`,{type:`text`,placeholder:`Filter files...`,value:p,onChange:e=>m(e.target.value),className:`w-full px-2 py-1 text-[12px] border border-gray-200 rounded outline-none focus:border-gray-300 placeholder:text-gray-300`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-auto text-[13px]`,children:[(0,G.jsxs)(`div`,{className:`overflow-auto py-2`,children:[a&&!r&&(0,G.jsx)(`div`,{className:`px-5 py-4 text-[12px] text-gray-400 italic`,children:`loading git status...`}),d&&(0,G.jsx)(`div`,{className:`px-5 py-4 text-[12px] text-red-500`,children:d}),z&&!a&&(0,G.jsx)(`div`,{className:`px-5 py-4 text-[12px] text-gray-400 italic`,children:`no changes`}),L.length>0&&(0,G.jsx)(HW,{title:`Unstaged Changes`,count:L.length,open:s,onToggle:()=>c(e=>!e),bulkAction:{label:`Stage all`,icon:(0,G.jsx)(ze,{size:12}),onClick:A},children:L.map(t=>(0,G.jsx)(UW,{file:t,loopId:e,staged:!1,onStage:()=>M(t.path),onUnstage:()=>N(t.path),onDiscard:()=>P(t.path),onEdit:e=>n(e),onRefresh:O},t.path))}),R.length>0&&(0,G.jsx)(HW,{title:`Staged Changes`,count:R.length,open:l,onToggle:()=>u(e=>!e),bulkAction:{label:`Unstage all`,icon:(0,G.jsx)(je,{size:12}),onClick:j},children:R.map(t=>(0,G.jsx)(UW,{file:t,loopId:e,staged:!0,onStage:()=>M(t.path),onUnstage:()=>N(t.path),onDiscard:()=>P(t.path),onEdit:e=>n(e),onRefresh:O},t.path))})]}),(0,G.jsxs)(`div`,{className:`border-t border-gray-200`,children:[(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:()=>D(e=>!e),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&D(e=>!e)},className:`w-full px-3 py-1.5 flex items-center gap-1.5 hover:bg-gray-50 text-left cursor-pointer select-none`,children:[(0,G.jsx)(`span`,{className:`text-gray-500`,children:E?`▾`:`▸`}),(0,G.jsx)(ge,{size:12,className:`text-gray-500`}),(0,G.jsx)(`span`,{className:`text-[11px] uppercase tracking-wide text-gray-500`,children:`History`}),(0,G.jsxs)(`span`,{className:`text-[11px] text-gray-400`,children:[`(`,S.length,`)`]})]}),E&&(0,G.jsx)(`div`,{className:`px-2 pb-2 max-h-64 overflow-auto`,children:w?(0,G.jsx)(`div`,{className:`px-3 py-3 text-[11px] text-gray-400 italic`,children:`loading history...`}):S.length===0?(0,G.jsx)(`div`,{className:`px-3 py-3 text-[11px] text-gray-400 italic`,children:`no commits`}):(0,G.jsx)(VW,{commits:S})})]})]})]})}function VW({commits:e}){let t=[`bg-blue-500`,`bg-emerald-500`,`bg-purple-500`,`bg-amber-500`,`bg-pink-500`,`bg-cyan-500`],n=new Map,r=0,i=e=>(n.has(e)||(n.set(e,t[r%t.length]),r++),n.get(e));return(0,G.jsx)(`div`,{className:`space-y-0`,children:e.map((t,n)=>{let r=t.branch??t.branches[0]??null,a=r?i(r):`bg-gray-400`,o=n===0,s=new Date(t.date).toLocaleDateString(void 0,{month:`short`,day:`numeric`}),c=new Date(t.date).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});return(0,G.jsxs)(`div`,{className:`group/graph-row flex items-start gap-2 py-0.5 px-1.5 rounded hover:bg-gray-100 cursor-default text-[11px]`,title:`${t.subject}\n${t.author} · ${s} ${c}`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col items-center shrink-0`,children:[(0,G.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-full ${a} ring-2 ring-white ${o?`ring-blue-300`:``}`}),n<e.length-1&&(0,G.jsx)(`div`,{className:`w-0.5 h-10 ${a} opacity-10`})]}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-gray-400 truncate`,children:t.shortHash}),o&&(0,G.jsx)(`span`,{className:`text-[9px] px-1 py-0 rounded bg-blue-100 text-blue-700 font-medium`,children:`HEAD`}),t.branches.slice(0,2).map(e=>(0,G.jsx)(`span`,{className:`text-[9px] px-1 py-0 rounded bg-emerald-100 text-emerald-700 font-medium truncate max-w-[60px]`,children:e},e)),t.tags.map(e=>(0,G.jsx)(`span`,{className:`text-[9px] px-1 py-0 rounded bg-purple-100 text-purple-700 font-medium`,children:e},e))]}),(0,G.jsx)(`div`,{className:`text-gray-700 truncate`,children:t.subject}),(0,G.jsxs)(`div`,{className:`text-gray-400 text-[10px]`,children:[t.author,` · `,s]})]})]},t.hash)})})}function HW({title:e,count:t,open:n,onToggle:r,bulkAction:i,children:a}){return(0,G.jsxs)(`div`,{className:`mb-2`,children:[(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:r,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&r()},className:`w-full px-3 py-1.5 flex items-center gap-1.5 hover:bg-gray-50 text-left group/section cursor-pointer select-none`,children:[(0,G.jsx)(`span`,{className:`text-gray-500`,children:n?`▾`:`▸`}),(0,G.jsx)(`span`,{className:`text-[11px] uppercase tracking-wide text-gray-500`,children:e}),(0,G.jsxs)(`span`,{className:`text-[11px] text-gray-400`,children:[`(`,t,`)`]}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),i.onClick()},className:`opacity-100 sm:opacity-0 sm:group-hover/section:opacity-100 transition-opacity px-1 py-0.5 rounded hover:bg-gray-200 text-gray-500 hover:text-gray-900 flex items-center gap-0.5`,title:i.label,children:i.icon})]}),n&&(0,G.jsx)(`div`,{children:a})]})}function UW({file:e,loopId:t,staged:n,onStage:r,onUnstage:i,onDiscard:a,onEdit:o,onRefresh:s}){let[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)(null),y=(0,_.useRef)(null);(0,_.useEffect)(()=>{let e=e=>{y.current&&!y.current.contains(e.target)&&v(null)};if(g)return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[g]);let b=async()=>{e.isBinary||(l(!0),u===null&&(p(!0),d(await yh(t,e.path,n)??``),p(!1)))},x=e=>{e.preventDefault(),v({x:e.clientX,y:e.clientY})},S=`workdir/${e.path}`,C=[{label:`Open in Editor`,icon:(0,G.jsx)(Re,{size:12}),onClick:()=>{o(S),v(null)}},{label:`View Diff`,icon:(0,G.jsx)(We,{size:12}),onClick:()=>{b(),v(null)}},{separator:!0,label:``,onClick:()=>{}},n?{label:`Unstage`,icon:(0,G.jsx)(je,{size:12}),onClick:()=>{i(),v(null)}}:{label:`Stage`,icon:(0,G.jsx)(ze,{size:12}),onClick:()=>{r(),v(null)}},!n&&{label:`Discard Changes`,icon:(0,G.jsx)(it,{size:12}),onClick:()=>{h(!0),v(null)},danger:!0}].filter(Boolean),w=zW[e.status]??{label:e.status,color:`text-gray-500`},T=e.path.lastIndexOf(`/`),E=T>=0?e.path.slice(T+1):e.path,D=T>=0?e.path.slice(0,T+1):null;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`group/row relative flex items-center gap-2 px-3 py-1.5 hover:bg-gray-50`,onContextMenu:x,children:[(0,G.jsx)(`span`,{className:`w-5 text-center text-[11px] font-mono font-semibold ${w.color}`,children:w.label}),(0,G.jsxs)(`span`,{className:`flex-1 min-w-0 truncate text-[13px] font-mono`,children:[(0,G.jsx)(`span`,{className:`text-gray-900`,children:E}),D&&(0,G.jsx)(`span`,{className:`text-gray-400 ml-0.5`,children:D})]}),!e.isBinary&&(e.additions>0||e.deletions>0)&&(0,G.jsxs)(`span`,{className:`text-[11px] font-mono flex items-center gap-0.5 shrink-0`,children:[(0,G.jsxs)(`span`,{className:`text-emerald-600`,children:[`+`,e.additions]}),(0,G.jsxs)(`span`,{className:`text-red-500`,children:[`-`,e.deletions]})]}),(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 opacity-100 sm:opacity-0 sm:group-hover/row:opacity-100 transition-opacity shrink-0`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>o(S),className:`w-5 h-5 flex items-center justify-center text-gray-400 hover:text-blue-600 rounded`,title:`edit file`,children:(0,G.jsx)(Re,{size:13})}),n&&(0,G.jsx)(`button`,{type:`button`,onClick:b,className:`w-5 h-5 flex items-center justify-center text-gray-400 hover:text-gray-700 rounded`,title:`view diff`,disabled:e.isBinary,children:(0,G.jsx)(We,{size:13})}),n?(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`w-5 h-5 flex items-center justify-center text-gray-400 hover:text-amber-600 rounded`,title:`unstage`,children:(0,G.jsx)(je,{size:13})}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>h(!0),className:`w-5 h-5 flex items-center justify-center text-gray-400 hover:text-red-500 rounded`,title:`discard changes`,children:(0,G.jsx)(it,{size:13})}),(0,G.jsx)(`button`,{type:`button`,onClick:r,className:`w-5 h-5 flex items-center justify-center text-gray-400 hover:text-emerald-600 rounded`,title:`stage`,children:(0,G.jsx)(ze,{size:13})})]})]})]}),g&&(0,G.jsx)(`div`,{ref:y,className:`fixed z-50 min-w-[160px] py-1 bg-white border border-gray-200 rounded-md shadow-lg text-[12px]`,style:{left:g.x,top:g.y},children:C.map((e,t)=>e.separator?(0,G.jsx)(`div`,{className:`my-1 border-t border-gray-100`},t):(0,G.jsxs)(`button`,{onClick:e.onClick,className:`w-full flex items-center gap-2 px-3 py-1.5 text-left hover:bg-gray-100 ${e.danger?`text-red-600`:`text-gray-700`}`,children:[e.icon,(0,G.jsx)(`span`,{children:e.label})]},t))}),c&&(0,G.jsx)(RW,{filePath:e.path,diff:u,loading:f,onClose:()=>l(!1)}),m&&(0,G.jsx)(Tg,{open:!0,onOpenChange:e=>{e||h(!1)},children:(0,G.jsxs)(Og,{className:`sm:max-w-sm bg-white p-5 gap-4`,showCloseButton:!1,children:[(0,G.jsx)(kg,{children:(0,G.jsx)(Ag,{className:`text-sm`,children:`Discard changes`})}),(0,G.jsx)(`p`,{className:`text-[13px] text-gray-600 break-all font-mono`,children:e.path}),(0,G.jsx)(`p`,{className:`text-[12px] text-gray-500`,children:e.status===`?`?`This file is untracked and will be deleted.`:`This will permanently discard all changes to this file. This action cannot be undone.`}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,G.jsx)(`button`,{onClick:()=>h(!1),className:`px-3 py-1.5 text-xs rounded bg-gray-100 text-gray-700 hover:bg-gray-200`,children:`Cancel`}),(0,G.jsx)(`button`,{onClick:()=>{h(!1),a()},className:`px-3 py-1.5 text-xs rounded bg-red-600 text-white hover:bg-red-700`,children:`Discard`})]})]})})]})}function WW(e){return e.shareMode===`ephemeral`?`ephemeral`:e.shareExternalPort?`direct`:`standard`}function GW({loop:e,open:t,onClose:n,onSaved:r}){let[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(e.shareEnabled??!1),[c,l]=(0,_.useState)(e.shareMode===`ephemeral`?`ephemeral`:e.shareExternalPort?`direct`:e.shareMode??`static`),[u,d]=(0,_.useState)(e.shareAlias??``),[f,p]=(0,_.useState)(e.sharePort??3e3),[m,h]=(0,_.useState)(e.shareExternalPort??1e4),[g,v]=(0,_.useState)(e.shareProtocol??`tcp`),[y,b]=(0,_.useState)(null),[x,S]=(0,_.useState)(``),[C,w]=(0,_.useState)(!1),[T,E]=(0,_.useState)(!1),[D,O]=(0,_.useState)(!1),[k,A]=(0,_.useState)(``),[j,M]=(0,_.useState)(!1),[N,F]=(0,_.useState)(``),[I,L]=(0,_.useState)(``),[z,B]=(0,_.useState)(WW(e)),[V,H]=(0,_.useState)(null),U=e.id.slice(0,8),W=!!(i&&i.serveEnabled),te=!!(i&&i.serveDynamicEnabled),ne=!!(i&&i.serveEphemeralEnabled),re=[W,te,ne].filter(Boolean).length>1,ie=W&&!te&&!ne,ae=!W&&te&&!ne,oe=!W&&!te&≠(0,_.useEffect)(()=>{t&&(Lh().then(a),s(e.shareEnabled??!1),l(e.shareMode===`ephemeral`?`ephemeral`:e.shareExternalPort?`direct`:e.shareMode??`static`),d(e.shareAlias??``),p(e.sharePort??3e3),h(e.shareExternalPort??1e4),v(e.shareProtocol??`tcp`),B(WW(e)),b(null),S(``),A(``),H(null))},[t,e]),(0,_.useEffect)(()=>{if(!t||!(oe||re&&z===`ephemeral`)||!e.shareEnabled||e.shareMode!==`ephemeral`)return;let n=!1,r=async()=>{let t=await Rh(e.id);n||H(t.port)};r();let i=setInterval(r,3e3);return()=>{n=!0,clearInterval(i)}},[t,z,oe,re,e.id,e.shareEnabled,e.shareMode]),(0,_.useEffect)(()=>{!t||!i||i.serveDynamicEnabled&&(e.shareEnabled&&e.shareExternalPort||!e.shareEnabled&&!e.shareExternalPort&&Bh().then(e=>{e.port&&h(e.port)}))},[t,i,e.shareEnabled,e.shareExternalPort]),(0,_.useEffect)(()=>{t&&Hh(U,e.id).then(e=>{e.available?O(!1):(O(!0),S(`ID "${U}" is already in use. Please set an alias.`))})},[t,U,e.id]),(0,_.useEffect)(()=>{if(!u||!t){b(null),S(``);return}let n=setTimeout(async()=>{let t=await Hh(u,e.id);b(t.available),S(t.reason??``)},300);return()=>clearTimeout(n)},[u,t,e.id]);let se=u||U,ce=i?.https?`https`:`http`,le=i?.withPort?`:${i.displayPort}`:``,ue=i?`${ce}://${se}${i.baseUrl}${le}`:``,de=i?.serveDynamicDomain||i?.ip||`<host-ip>`,fe=g===`static`?`http://${de}:${m}`:`tcp://${de}:${m}`,pe=i?.serveEphemeralDomain||i?.ip||`<host-ip>`,me=V?`${g===`udp`?`udp`:`tcp`}://${pe}:${V}`:`(no active port — save & wait for container restart)`,he=ae||re&&z===`direct`&&te&&!oe,ge=oe||re&&z===`ephemeral`,_e=ge?me:he?fe:ue;(0,_.useEffect)(()=>{if(!t||!he)return;let n=setTimeout(async()=>{M(!0);let t=await Vh(m,e.id);M(!1),t.available?A(``):A(t.reason??`Port unavailable`)},400);return()=>clearTimeout(n)},[m,t,c,e.id]);let ye=async()=>{if(E(!0),he){let t=await Vh(m,e.id);if(!t.available){A(t.reason??`Port unavailable`),E(!1);return}}let t={shareEnabled:o};o?ge?(t.shareMode=`ephemeral`,t.sharePort=f,t.shareProtocol=g===`static`?`tcp`:g,t.shareAlias=void 0,t.shareExternalPort=void 0):he?(t.shareMode=`port`,t.sharePort=f,t.shareExternalPort=m,t.shareProtocol=g,t.shareAlias=void 0):(t.shareMode=c,t.shareAlias=u.trim()||void 0,c===`port`&&(t.sharePort=f),t.shareExternalPort=void 0,t.shareProtocol=void 0):(t.shareMode=void 0,t.shareAlias=void 0,t.sharePort=void 0);let i=await fetch(`/api/loops/${e.id}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(E(!1),i.ok)F(`Saved`),await r?.(),setTimeout(()=>{F(``),n()},800);else try{L((await i.json()).error??`Save failed (${i.status})`)}catch{L(`Save failed (${i.status})`)}},be=async()=>{try{await navigator.clipboard.writeText(_e),w(!0),setTimeout(()=>w(!1),1500)}catch{window.prompt(`Copy this URL:`,_e)}},xe=!T&&!k&&!j&&(ge?f>=1&&f<=65535:(!he||m>=1024)&&(!he||f>=1||g===`static`)&&(he||c!==`port`||!D||u.trim().length>0)&&(he||c!==`port`||f>=1024));return i?(0,G.jsx)(Tg,{open:t,onOpenChange:e=>{e||n()},children:(0,G.jsxs)(Og,{className:`sm:max-w-md bg-white max-h-[85vh] overflow-y-auto`,children:[(0,G.jsxs)(kg,{children:[(0,G.jsxs)(Ag,{className:`flex items-center gap-2 text-sm`,children:[(0,G.jsx)(ve,{size:16}),`Share Artifact`]}),(0,G.jsx)(jg,{className:`sr-only`,children:`Share this artifact via a public URL.`})]}),(0,G.jsxs)(`div`,{className:`space-y-4 text-[13px]`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-sm text-gray-700`,children:`Enable sharing`}),(0,G.jsx)(`button`,{onClick:()=>s(!o),className:`w-10 h-5 rounded-full transition-colors ${o?`bg-blue-600`:`bg-gray-300`}`,children:(0,G.jsx)(`div`,{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${o?`translate-x-5`:`translate-x-0.5`}`})})]}),o&&(0,G.jsxs)(G.Fragment,{children:[re&&(0,G.jsxs)(`div`,{className:`flex gap-1.5 border-b border-gray-200 pb-2`,children:[W&&(0,G.jsx)(`button`,{onClick:()=>{B(`standard`),l(`static`)},className:`px-3 py-1 text-xs rounded-t ${z===`standard`?`bg-blue-50 text-blue-700 font-medium`:`text-gray-500 hover:text-gray-700`}`,children:`Subdomain`}),te&&(0,G.jsx)(`button`,{onClick:()=>{B(`direct`),l(`direct`)},className:`px-3 py-1 text-xs rounded-t ${z===`direct`?`bg-blue-50 text-blue-700 font-medium`:`text-gray-500 hover:text-gray-700`}`,children:`Direct Port`}),ne&&(0,G.jsx)(`button`,{onClick:()=>{B(`ephemeral`),l(`ephemeral`)},className:`px-3 py-1 text-xs rounded-t ${z===`ephemeral`?`bg-blue-50 text-blue-700 font-medium`:`text-gray-500 hover:text-gray-700`}`,children:`Ephemeral`})]}),(ie||re&&z===`standard`)&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[11px] text-gray-500 uppercase tracking-wider`,children:`Share mode`}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5 mt-1`,children:[(0,G.jsx)(`button`,{onClick:()=>l(`static`),className:`px-2 py-1.5 text-xs rounded border ${c===`static`?`bg-blue-50 border-blue-300 text-blue-700`:`border-gray-200 text-gray-600`}`,children:`Static files`}),(0,G.jsx)(`button`,{onClick:()=>l(`port`),className:`px-2 py-1.5 text-xs rounded border ${c===`port`?`bg-blue-50 border-blue-300 text-blue-700`:`border-gray-200 text-gray-600`}`,children:`Port proxy`})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`text-[11px] text-gray-500 uppercase tracking-wider`,children:[`Alias `,D?(0,G.jsx)(`span`,{className:`text-red-500`,children:`(required)`}):`(optional)`]}),(0,G.jsx)(`input`,{value:u,onChange:e=>d(e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,``)),className:`w-full mt-1 px-2 py-1.5 text-sm border rounded outline-none focus:border-gray-300 ${D?`border-red-300 bg-red-50`:`border-gray-200`}`,placeholder:D?`Set an alias to resolve conflict`:`my-project`}),D&&(0,G.jsxs)(`span`,{className:`text-[11px] text-red-500 mt-0.5 flex items-center gap-1`,children:[(0,G.jsx)(R,{size:11}),` `,x||`ID "${U}" is already in use`]}),!D&&y===!0&&(0,G.jsx)(`span`,{className:`text-[11px] text-emerald-600 mt-0.5`,children:`Available`}),!D&&y===!1&&(0,G.jsxs)(`span`,{className:`text-[11px] text-red-500 mt-0.5 flex items-center gap-1`,children:[(0,G.jsx)(R,{size:11}),` `,x||`Already in use`]})]}),c===`port`&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[11px] text-gray-500 uppercase tracking-wider`,children:`Port (1024-65535)`}),(0,G.jsx)(`input`,{type:`number`,min:1024,max:65535,value:f,onChange:e=>p(parseInt(e.target.value,10)||3e3),className:`w-full mt-1 px-2 py-1.5 text-sm border border-gray-200 rounded outline-none focus:border-gray-300`})]})]}),ge&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[11px] text-gray-500 uppercase tracking-wider`,children:`Container port`}),(0,G.jsx)(`input`,{type:`number`,min:1,max:65535,value:f,onChange:e=>p(parseInt(e.target.value,10)||3e3),className:`w-full mt-1 px-2 py-1.5 text-sm border border-gray-200 rounded outline-none focus:border-gray-300`}),(0,G.jsx)(`p`,{className:`text-[10px] text-gray-400 mt-0.5`,children:`The port your app listens on inside the sandbox`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[11px] text-gray-500 uppercase tracking-wider`,children:`Protocol`}),(0,G.jsxs)(`div`,{className:`flex gap-1.5 mt-1`,children:[(0,G.jsx)(`button`,{onClick:()=>v(`tcp`),className:`flex-1 px-2 py-1.5 text-xs rounded border ${g===`tcp`?`bg-blue-50 border-blue-300 text-blue-700`:`border-gray-200 text-gray-600`}`,children:`TCP`}),(0,G.jsx)(`button`,{onClick:()=>v(`udp`),className:`flex-1 px-2 py-1.5 text-xs rounded border ${g===`udp`?`bg-blue-50 border-blue-300 text-blue-700`:`border-gray-200 text-gray-600`}`,children:`UDP`})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`text-[11px] text-gray-500 uppercase tracking-wider flex items-center gap-1.5`,children:[`Current host port`,(0,G.jsx)(Ve,{size:10,className:`text-gray-300`})]}),(0,G.jsx)(`div`,{className:`mt-1 px-2 py-1.5 text-sm bg-gray-50 rounded text-gray-700`,children:V==null?(0,G.jsx)(`span`,{className:`text-gray-400 text-xs`,children:e.shareEnabled&&e.shareMode===`ephemeral`?`(container starting / not running)`:`(save to start — port assigned by kernel on restart)`}):(0,G.jsx)(`span`,{className:`font-mono`,children:V})}),(0,G.jsxs)(`p`,{className:`text-[10px] text-amber-600 mt-1 flex items-center gap-1`,children:[(0,G.jsx)(R,{size:10}),` Changes on every loop restart. Saving also restarts the container.`]})]})]}),(ae||re&&z===`direct`&&!ge)&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[11px] text-gray-500 uppercase tracking-wider`,children:`External port`}),(0,G.jsxs)(`div`,{className:`flex gap-1.5 mt-1`,children:[(0,G.jsx)(`input`,{type:`number`,min:1024,max:65535,value:m,onChange:e=>h(parseInt(e.target.value,10)||1e4),className:`flex-1 px-2 py-1.5 text-sm border border-gray-200 rounded outline-none focus:border-gray-300`,placeholder:`10000`}),(0,G.jsx)(`button`,{onClick:async()=>{let e=await Bh();e.port&&h(e.port)},className:`px-2 py-1.5 rounded border border-gray-200 hover:bg-gray-100 text-gray-500`,title:`Pick a random available port`,children:(0,G.jsx)(Ye,{size:14})})]}),(0,G.jsx)(`p`,{className:`text-[10px] text-gray-400 mt-0.5`,children:`The public port clients connect to`}),j&&(0,G.jsx)(`span`,{className:`text-[11px] text-gray-400 mt-0.5`,children:`Checking availability…`}),k&&(0,G.jsxs)(`span`,{className:`text-[11px] text-red-500 mt-0.5 flex items-center gap-1`,children:[(0,G.jsx)(R,{size:11}),` `,k]}),!j&&!k&&(0,G.jsx)(`span`,{className:`text-[11px] text-emerald-600 mt-0.5`,children:`Available`})]}),g!==`static`&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[11px] text-gray-500 uppercase tracking-wider`,children:`Container port`}),(0,G.jsx)(`input`,{type:`number`,min:1,max:65535,value:f,onChange:e=>p(parseInt(e.target.value,10)||3e3),className:`w-full mt-1 px-2 py-1.5 text-sm border border-gray-200 rounded outline-none focus:border-gray-300`}),(0,G.jsx)(`p`,{className:`text-[10px] text-gray-400 mt-0.5`,children:`The port your app listens on inside the sandbox`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[11px] text-gray-500 uppercase tracking-wider`,children:`Protocol`}),(0,G.jsxs)(`div`,{className:`flex gap-1.5 mt-1`,children:[(0,G.jsx)(`button`,{onClick:()=>v(`tcp`),className:`flex-1 px-2 py-1.5 text-xs rounded border ${g===`tcp`?`bg-blue-50 border-blue-300 text-blue-700`:`border-gray-200 text-gray-600`}`,children:`TCP`}),i.serveDynamicUdpEnabled&&(0,G.jsx)(`button`,{onClick:()=>v(`udp`),className:`flex-1 px-2 py-1.5 text-xs rounded border ${g===`udp`?`bg-blue-50 border-blue-300 text-blue-700`:`border-gray-200 text-gray-600`}`,children:`UDP`}),i.serveDynamicStaticEnabled&&(0,G.jsx)(`button`,{onClick:()=>v(`static`),className:`flex-1 px-2 py-1.5 text-xs rounded border ${g===`static`?`bg-blue-50 border-blue-300 text-blue-700`:`border-gray-200 text-gray-600`}`,children:`Static`})]})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[11px] text-gray-500 uppercase tracking-wider`,children:`Access URL`}),(0,G.jsxs)(`div`,{className:`flex gap-2 mt-1`,children:[(0,G.jsx)(`code`,{className:`flex-1 px-2 py-1.5 text-xs bg-gray-50 rounded text-gray-700 truncate`,children:_e}),(0,G.jsx)(`button`,{onClick:be,className:`px-2 py-1.5 rounded hover:bg-gray-100 text-gray-500`,title:`Copy URL`,children:C?(0,G.jsx)(P,{size:14,className:`text-emerald-600`}):(0,G.jsx)(ee,{size:14})})]}),(0,G.jsx)(`p`,{className:`text-[10px] text-gray-400 mt-1`,children:he?`Direct TCP/UDP access — no domain needed`:`Domain suffix configured in Settings → Workspace → Workspace Serve`})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-2 pt-2`,children:[I&&(0,G.jsx)(`span`,{className:`text-xs text-red-500`,children:I}),N&&(0,G.jsxs)(`span`,{className:`text-xs text-emerald-600 flex items-center gap-1`,children:[(0,G.jsx)(P,{size:12}),` `,N]}),(0,G.jsx)(`button`,{onClick:n,className:`px-3 py-1.5 text-xs rounded bg-gray-100 text-gray-700 hover:bg-gray-200`,children:`Cancel`}),(0,G.jsx)(`button`,{onClick:ye,disabled:!xe,className:`px-3 py-1.5 text-xs rounded bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-40`,children:T?`Saving...`:`Save`})]})]})]})}):null}var KW=(0,_.lazy)(()=>_t(()=>import(`./Editor-DjEYNpQa.js`).then(e=>({default:e.Editor})),__vite__mapDeps([0,1,2,3]))),qW=(0,_.lazy)(()=>_t(()=>import(`./Terminal-DTMXO4Pg.js`).then(e=>({default:e.Terminal})),__vite__mapDeps([4,1,5])));function JW(){let{id:e}=Wn(),t=vg();if(!e)return(0,G.jsx)(mr,{to:`/loop`,replace:!0});if(!t.currentUser)return(0,G.jsx)(SW,{});let n=t.loops.find(t=>t.id===e);return t.loopsLoading?null:n?(0,G.jsxs)(`div`,{className:`h-full w-full flex min-h-0`,children:[(0,G.jsx)(YW,{currentId:e}),(0,G.jsx)(XW,{meta:n},e)]}):(0,G.jsx)(mr,{to:`/loop`,replace:!0})}function YW({currentId:e}){let t=vg(),n=Bn(),[r,i]=(0,_.useState)(`mine`),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(()=>localStorage.getItem(`loopat:loopsList:collapsed`)===`1`),l=rU(),u=EW((0,_.useMemo)(()=>t.loops.map(e=>e.id),[t.loops]));(0,_.useEffect)(()=>{let t=u[e];t?.status===`Done`&&t?.viewed===!1&&lm(e)},[u,e]);let d=t.currentUser?.id,f=(0,_.useMemo)(()=>{let e=a.toLowerCase().trim();return t.loops.filter(t=>{let n=t.driver??t.createdBy;return!(r===`mine`&&t.createdBy!==d&&n!==d||r===`rfd`&&!t.rfdRequestedAt||e&&!t.title.toLowerCase().includes(e)&&!t.id.toLowerCase().includes(e))})},[t.loops,r,d,a]),p=e=>{c(e),localStorage.setItem(`loopat:loopsList:collapsed`,e?`1`:`0`)},m=(0,G.jsxs)(`aside`,{className:`w-60 shrink-0 border-r border-gray-200 bg-white flex flex-col h-full`,children:[(0,G.jsxs)(`div`,{className:`px-2 pt-1.5 pb-1 space-y-1 border-b border-gray-200`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[[`mine`,`all`,`rfd`].map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:r===e?e===`rfd`?`px-2 h-6 rounded text-[11px] flex items-center gap-1 bg-amber-600 text-white`:`px-2 h-6 rounded text-[11px] bg-gray-900 text-white`:e===`rfd`?`px-2 h-6 rounded text-[11px] flex items-center gap-1 text-amber-700 hover:bg-amber-50`:`px-2 h-6 rounded text-[11px] text-gray-500 hover:bg-gray-100`,children:e===`mine`?`mine`:e===`all`?`all`:`RFD`},e)),(0,G.jsx)(`span`,{className:`text-[11px] text-gray-400 ml-auto pr-1`,children:f.length}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t.setShowArchived(!t.showArchived),className:t.showArchived?`w-6 h-6 flex items-center justify-center text-gray-700 bg-gray-100 rounded`:`w-6 h-6 flex items-center justify-center text-gray-400 hover:text-gray-700 hover:bg-gray-100 rounded`,title:t.showArchived?`hide archived`:`show archived`,children:(0,G.jsx)(w,{size:13})}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>p(!0),className:`w-6 h-6 flex items-center justify-center text-gray-400 hover:text-gray-700 hover:bg-gray-100 rounded`,title:`collapse sidebar`,children:(0,G.jsx)(Fe,{size:14})})]}),(0,G.jsx)(`input`,{type:`text`,name:`loop-search`,value:a,onChange:e=>o(e.target.value),placeholder:`search loops…`,className:`w-full h-6 rounded px-1.5 text-[11px] bg-gray-100 border border-transparent focus:border-gray-300 focus:bg-white focus:outline-none text-gray-600 placeholder-gray-400`})]}),(0,G.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-auto py-2`,children:[f.map(r=>{let i=e===r.id,a=r.archived===!0,o=t.currentUser?.id===r.createdBy,s=u[r.id],c=s?.status===`Done`||s?.status===`Ready`,d=s!==void 0&&!c;return(0,G.jsxs)(`div`,{className:`group/row relative flex items-stretch `+(i?`bg-gray-100`:`hover:bg-gray-50`),children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{lm(r.id),n(`/loop/${r.id}`),l&&p(!0)},className:`flex-1 min-w-0 px-3 py-1.5 flex items-center gap-2 text-left `+(a?`opacity-60`:``),children:[(0,G.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 mt-0.5 `+(a?`bg-gray-400`:d?`bg-blue-500 animate-pulse`:c&&!s?.viewed?`bg-yellow-500`:c?`bg-emerald-500`:`bg-gray-300`)}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`text-[13px] text-gray-900 truncate flex items-center gap-1.5`,children:[a&&(0,G.jsx)(w,{size:10,className:`text-gray-400 shrink-0`}),r.rfdRequestedAt&&(0,G.jsx)(`span`,{className:`shrink-0 text-[9px] px-1 rounded bg-amber-100 text-amber-800 font-medium tracking-wide`,children:`RFD`}),(0,G.jsx)(`span`,{className:`truncate`,children:r.title}),s&&(0,G.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium `+(d?`text-blue-500`:c?`text-emerald-500`:`text-gray-400`),children:s.status})]}),(0,G.jsxs)(`div`,{className:`text-[11px] text-gray-500 truncate flex items-center gap-1 mt-0.5`,children:[(0,G.jsx)(`span`,{children:r.driver??r.createdBy}),(0,G.jsx)(`span`,{className:`text-gray-300`,children:`·`}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-gray-400`,children:r.id.slice(0,6)})]})]})]}),(0,G.jsx)(`button`,{type:`button`,disabled:!o,onClick:e=>{e.stopPropagation(),o&&t.setLoopArchived(r.id,!a)},className:(l?`opacity-100`:`opacity-0 group-hover/row:opacity-100`)+` transition-opacity w-7 flex items-center justify-center `+(o?`text-gray-400 hover:text-gray-700`:`text-gray-300 cursor-not-allowed`),title:o?a?`unarchive`:`archive (hide + read-only)`:`only ${r.createdBy} can ${a?`unarchive`:`archive`} this loop`,children:a?(0,G.jsx)(C,{size:13}):(0,G.jsx)(w,{size:13})})]},r.id)}),f.length===0&&(0,G.jsx)(`div`,{className:`px-3 py-4 text-[12px] text-gray-400 italic`,children:`no loops · click "+ New Loop"`})]})]});return s?(0,G.jsx)(`aside`,{className:`w-9 shrink-0 border-r border-gray-200 bg-white flex flex-col items-center pt-2`,children:(0,G.jsx)(`button`,{type:`button`,onClick:()=>p(!1),className:`w-7 h-7 flex items-center justify-center text-gray-500 hover:text-gray-900 hover:bg-gray-100 rounded`,title:`expand sidebar`,children:(0,G.jsx)(Ie,{size:16})})}):l?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`aside`,{className:`w-9 shrink-0 border-r border-gray-200 bg-white flex flex-col items-center pt-2`,children:(0,G.jsx)(`button`,{type:`button`,onClick:()=>p(!0),className:`w-7 h-7 flex items-center justify-center text-gray-500 hover:text-gray-900 hover:bg-gray-100 rounded`,title:`collapse sidebar`,children:(0,G.jsx)(Fe,{size:16})})}),(0,G.jsxs)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>p(!0),children:[(0,G.jsx)(`div`,{className:`absolute inset-0 bg-black/30`}),(0,G.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 w-64 max-w-[80vw] shadow-xl`,onClick:e=>e.stopPropagation(),children:m})]})]}):m}function XW({meta:e}){let t=vg(),n=rU(),[r,i]=(0,_.useState)([]),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)([]),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(null);(0,_.useEffect)(()=>{Lh().then(m)},[]);let[h,g]=(0,_.useState)(null),v=e=>{c(e),g(null),i(e=>e.includes(`editor`)?e:[...e,`editor`])},{runtime:y,connected:b,reconnecting:x,running:S,viewers:C,extra:w,queue:T,onClearQueue:E}=yU(e.id,t.currentUser?.id??``,v);(0,_.useEffect)(()=>{Tm(e.id).then(u),lm(e.id),t.currentUser?.id&&localStorage.setItem(`loopat:lastLoop:${t.currentUser.id}`,e.id)},[e.id]);let D=In(),O=Bn(),k=D.state?.kickoff;(0,_.useEffect)(()=>{!k||!b||(w.enqueueMessage(k),O(D.pathname,{replace:!0,state:null}))},[k,b]);let A=e=>{i(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},j=e=>{i(t=>t.includes(e)?t.filter(t=>t!==e):[e])},M=e=>{i(t=>t.filter(t=>t!==e)),o(t=>t===e?null:t)},N=r.length>0,P=r.filter(e=>e===`editor`||e===`terminal`),F=r.filter(e=>e!==`editor`&&e!==`terminal`),I=P.length>0,L=F.length>0,[R,z]=(0,_.useState)(()=>{let e=parseInt(localStorage.getItem(`loopat:chatPct`)||``,10);return!isNaN(e)&&e>=10&&e<=90?e:55}),[B,V]=(0,_.useState)(()=>{let e=parseInt(localStorage.getItem(`loopat:otherPct`)||``,10);return!isNaN(e)&&e>=5&&e<=50?e:18});(0,_.useEffect)(()=>{if(!L){let e=parseInt(localStorage.getItem(`loopat:otherPct`)||``,10);!isNaN(e)&&e>=5&&e<=50&&V(e)}if(!I&&!L){let e=parseInt(localStorage.getItem(`loopat:chatPct`)||``,10);!isNaN(e)&&e>=10&&e<=90&&z(e)}},[I,L]);let H=e=>{!isNaN(e.chat)&&e.chat>0&&localStorage.setItem(`loopat:chatPct`,String(Math.round(e.chat))),!isNaN(e.otherCol)&&e.otherCol>0&&localStorage.setItem(`loopat:otherPct`,String(Math.round(e.otherCol)))},U=n=>{let r=a===n;return(0,G.jsx)(nG,{loopId:e.id,meta:e,mode:n,onClose:()=>M(n),pickedFile:s,onPickFile:v,currentUserId:t.currentUser?.id??``,isFullscreen:r,onToggleFullscreen:()=>o(r?null:n),onEditorSelection:g},n)};return(0,G.jsxs)(`div`,{className:`flex-1 min-w-0 min-h-0 flex flex-col`,children:[(0,G.jsx)(ZW,{meta:e,mounts:l,connected:b,reconnecting:x,running:S,viewers:C,queue:T,onClearQueue:E,openPanels:r,toggleMode:A,onShareWork:()=>f(!0),showShareButton:!p||p.serveEnabled||p.serveDynamicEnabled||p.serveEphemeralEnabled}),e.contextWarnings&&e.contextWarnings.length>0&&(0,G.jsxs)(`div`,{className:`shrink-0 border-b border-amber-200 bg-amber-50 px-4 py-2 text-[12px] text-amber-800 leading-relaxed`,children:[(0,G.jsx)(`span`,{className:`font-semibold`,children:`⚠ Context not fully loaded.`}),` `,`This loop's knowledge/notes couldn't be cloned — it runs with an empty context until the access is fixed (check the key has access to the repo):`,(0,G.jsx)(`ul`,{className:`mt-1 ml-4 list-disc`,children:e.contextWarnings.map((e,t)=>(0,G.jsx)(`li`,{className:`font-mono text-[11px] break-all`,children:e},t))})]}),n?(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,G.jsx)(vU,{extra:w,children:(0,G.jsx)(YC,{runtime:y,children:(0,G.jsx)(xW,{archived:e.archived===!0,onUnarchive:()=>t.setLoopArchived(e.id,!1),repo:e.repo,branch:e.branch,title:e.title,driver:e.driver??e.createdBy,driverHistory:e.driverHistory,rfdRequestedAt:e.rfdRequestedAt,rfdRequestedBy:e.rfdRequestedBy,onTakeDrive:()=>t.takeDrive(e.id),pickedFile:s,editorSelection:h})})})}):N?(0,G.jsxs)(XO,{orientation:`horizontal`,className:`flex-1 min-w-0 min-h-0`,onLayoutChange:H,children:[(0,G.jsx)($O,{id:`chat`,minSize:20,defaultSize:R,className:`flex flex-col min-h-0 min-w-0`,children:(0,G.jsx)(vU,{extra:w,children:(0,G.jsx)(YC,{runtime:y,children:(0,G.jsx)(xW,{archived:e.archived===!0,onUnarchive:()=>t.setLoopArchived(e.id,!1),repo:e.repo,branch:e.branch,title:e.title,driver:e.driver??e.createdBy,driverHistory:e.driverHistory,rfdRequestedAt:e.rfdRequestedAt,rfdRequestedBy:e.rfdRequestedBy,onTakeDrive:()=>t.takeDrive(e.id),pickedFile:s,editorSelection:h})})})}),(I||L)&&(0,G.jsx)(nk,{className:`relative w-4 -mx-1.5 cursor-col-resize group flex items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-px after:-translate-x-1/2 after:bg-gray-200 after:transition-colors hover:after:bg-blue-400`,children:(0,G.jsx)(`div`,{className:`absolute top-1/2 -translate-y-1/2 h-8 w-1.5 rounded-full bg-gray-300 group-hover:bg-blue-400 transition-colors`})}),I&&(0,G.jsx)($O,{id:`editorCol`,minSize:15,defaultSize:30,className:`flex flex-col min-h-0 min-w-0`,children:P.length>1?(0,G.jsx)(XO,{orientation:`vertical`,className:`flex-1 min-h-0`,children:P.map((e,t)=>(0,G.jsxs)(_.Fragment,{children:[t>0&&(0,G.jsx)(nk,{className:`relative h-4 -my-1.5 cursor-row-resize group flex items-center justify-center after:absolute after:left-0 after:right-0 after:top-1/2 after:h-px after:-translate-y-1/2 after:bg-gray-200 after:transition-colors hover:after:bg-blue-400`,children:(0,G.jsx)(`div`,{className:`absolute left-1/2 -translate-x-1/2 w-8 h-1.5 rounded-full bg-gray-300 group-hover:bg-blue-400 transition-colors`})}),(0,G.jsx)($O,{id:e,minSize:10,defaultSize:100/P.length,className:`flex flex-col min-h-0 min-w-0`,children:U(e)})]},e))}):U(P[0])}),I&&L&&(0,G.jsx)(nk,{className:`relative w-4 -mx-1.5 cursor-col-resize group flex items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-px after:-translate-x-1/2 after:bg-gray-200 after:transition-colors hover:after:bg-blue-400`,children:(0,G.jsx)(`div`,{className:`absolute top-1/2 -translate-y-1/2 h-8 w-1.5 rounded-full bg-gray-300 group-hover:bg-blue-400 transition-colors`})}),L&&(0,G.jsx)($O,{id:`otherCol`,minSize:15,defaultSize:B,className:`flex flex-col min-h-0 min-w-0`,children:F.length>1?(0,G.jsx)(XO,{orientation:`vertical`,className:`flex-1 min-h-0`,children:F.map((e,t)=>(0,G.jsxs)(_.Fragment,{children:[t>0&&(0,G.jsx)(nk,{className:`relative h-4 -my-1.5 cursor-row-resize group flex items-center justify-center after:absolute after:left-0 after:right-0 after:top-1/2 after:h-px after:-translate-y-1/2 after:bg-gray-200 after:transition-colors hover:after:bg-blue-400`,children:(0,G.jsx)(`div`,{className:`absolute left-1/2 -translate-x-1/2 w-8 h-1.5 rounded-full bg-gray-300 group-hover:bg-blue-400 transition-colors`})}),(0,G.jsx)($O,{id:e,minSize:10,defaultSize:100/F.length,className:`flex flex-col min-h-0 min-w-0`,children:U(e)})]},e))}):U(F[0])})]}):(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,G.jsx)(vU,{extra:w,children:(0,G.jsx)(YC,{runtime:y,children:(0,G.jsx)(xW,{archived:e.archived===!0,onUnarchive:()=>t.setLoopArchived(e.id,!1),repo:e.repo,branch:e.branch,title:e.title,driver:e.driver??e.createdBy,driverHistory:e.driverHistory,rfdRequestedAt:e.rfdRequestedAt,rfdRequestedBy:e.rfdRequestedBy,onTakeDrive:()=>t.takeDrive(e.id),pickedFile:s,editorSelection:h})})})}),N&&n&&r.map(e=>(0,G.jsx)(_.Fragment,{children:U(e)},e)),n&&(0,G.jsx)(`div`,{className:`fixed bottom-0 left-0 z-30 w-9 flex flex-col items-center gap-0.5 pb-2`,children:[`terminal`,`editor`,`workdir`,`git`].map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>j(e),className:`w-7 h-7 flex items-center justify-center rounded text-xs ${r.includes(e)?`bg-gray-200 text-gray-900`:`text-gray-400 hover:text-gray-700 hover:bg-gray-100`}`,title:e,children:e===`terminal`?`▷`:e===`editor`?`✎`:e===`workdir`?`▤`:`⑂`},e))}),(0,G.jsx)(GW,{loop:e,open:d,onClose:()=>f(!1),onSaved:async()=>{await t.refresh()}})]})}function ZW({meta:e,mounts:t,connected:n,reconnecting:r,running:i,viewers:a,queue:o,onClearQueue:s,openPanels:c,toggleMode:l,onShareWork:u,showShareButton:d}){let f=rU(),p=Bn(),m=vg(),[h,g]=(0,_.useState)(f),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(e.title),w=m.currentUser?.id===e.createdBy,T=async()=>{if(!v){y(!0);try{let t=await hm(e.id);t&&p(`/loop/${t.id}`)}finally{y(!1)}}},E=async()=>{let t=S.trim();if(!t||t===e.title){x(!1),C(e.title);return}x(!1),await m.setLoopTitle(e.id,t)||C(e.title)},D=(e,t)=>(0,G.jsx)(`button`,{className:c.includes(t)?`px-2 py-0.5 rounded bg-gray-100 text-gray-900`:`px-2 py-0.5 rounded text-gray-500 hover:text-gray-900 hover:bg-gray-50`,onClick:()=>l(t),children:e},t);return(0,G.jsxs)(`header`,{className:`group/header px-3 md:px-5 shrink-0 border-b border-gray-200 `+(h?`py-1.5`:`pt-3 pb-2`),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>g(e=>!e),className:`text-gray-400 hover:text-gray-700 -ml-1 p-0.5 rounded hover:bg-gray-100`,title:h?`expand header`:`collapse header`,children:(0,G.jsx)(F,{size:14,className:`transition-transform `+(h?`-rotate-90`:``)})}),b?(0,G.jsx)(`input`,{type:`text`,value:S,autoFocus:!0,onChange:e=>C(e.target.value),onKeyDown:t=>{t.key===`Enter`&&!t.nativeEvent.isComposing?(t.preventDefault(),E()):t.key===`Escape`&&(t.preventDefault(),x(!1),C(e.title))},onBlur:E,maxLength:200,className:`text-[14px] md:text-[15px] font-medium text-gray-900 bg-white border border-blue-400 rounded px-1 py-0 outline-none min-w-[120px]`}):(0,G.jsx)(`span`,{className:`text-[14px] md:text-[15px] font-medium text-gray-900 `+(w?`cursor-pointer hover:bg-gray-100 rounded px-1 -mx-1`:``),onClick:()=>{w&&(C(e.title),x(!0))},title:w?`click to rename`:void 0,children:e.title}),(0,G.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[`driver: `,(0,G.jsx)(`span`,{className:`text-gray-900`,children:e.driver??e.createdBy})]}),e.rfdRequestedAt&&(0,G.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-800 border border-amber-200 font-medium tracking-wide`,title:`released for drive by ${e.rfdRequestedBy??`?`} at ${e.rfdRequestedAt}`,children:`RFD`}),!n&&r&&(0,G.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:`reconnecting…`}),i&&(0,G.jsx)(`span`,{className:`text-[11px] text-blue-600`,children:`running`}),a>1&&(0,G.jsxs)(`span`,{title:`people watching`,className:`text-[11px] px-1.5 py-0.5 rounded bg-emerald-50 text-emerald-800 border border-emerald-200`,children:[`👥 `,a]}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsxs)(`button`,{type:`button`,onClick:T,disabled:v,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] border bg-white text-violet-700 border-violet-300 hover:bg-violet-50 disabled:opacity-50`,title:`Spawn a child loop seeded with this loop's conversation, for sedimenting reusable insights into knowledge/`,children:[(0,G.jsx)(de,{size:11}),v?`Distilling…`:`Distill`]}),d!==!1&&(0,G.jsxs)(`button`,{onClick:u,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] border ${e.shareEnabled?`bg-blue-50 text-blue-700 border-blue-200 hover:bg-blue-100`:`bg-white text-gray-700 border-gray-300 hover:bg-gray-100`}`,title:`Share workspace artifact (static files or port forward)`,children:[(0,G.jsx)(ve,{size:11}),`Share Artifact`]}),(0,G.jsx)($W,{meta:e}),(0,G.jsx)(QW,{meta:e})]}),!h&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`text-xs text-gray-500 mt-1.5 flex items-center gap-2 flex-wrap`,children:[(0,G.jsxs)(`span`,{className:`font-mono`,children:[`~/.loopat/loops/`,e.id.slice(0,8),`/workdir`]}),(0,G.jsx)(`span`,{children:`·`}),(0,G.jsx)(`span`,{children:`main`}),a>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{children:`·`}),(0,G.jsxs)(`span`,{children:[a,` viewing`]})]}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px]`,children:[D(`ℹ info`,`info`),D(`▤ workdir`,`workdir`),D(`✎ editor`,`editor`),D(`▷ terminal`,`terminal`),(0,G.jsx)(`button`,{className:c.includes(`git`)?`px-2 py-0.5 rounded bg-gray-100 text-gray-900`:`px-2 py-0.5 rounded text-gray-500 hover:text-gray-900 hover:bg-gray-50`,onClick:()=>l(`git`),title:`git changes`,children:(0,G.jsx)(ge,{size:14})})]})]}),(0,G.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5 flex-wrap text-[11px]`,children:[(0,G.jsx)(`span`,{className:`text-gray-400`,children:`context:`}),t.map(e=>(0,G.jsx)(eG,{label:e.name,value:e.name===`knowledge`?`ro`:`rw`},e.path))]}),e.config?.profiles&&e.config.profiles.length>0&&(0,G.jsx)(tG,{profiles:e.config.profiles}),(0,G.jsxs)(`div`,{className:`mt-1 flex items-center gap-1.5 flex-wrap text-[11px]`,children:[(0,G.jsx)(`span`,{className:`text-gray-400`,children:`vault:`}),(0,G.jsx)(eG,{label:e.config?.vault??`default`,value:`loaded`})]})]})]})}function QW({meta:e}){let t=vg(),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(!1),o=t.currentUser?.id===e.createdBy,s=e.public===!0;if(!t.currentUser)return null;let c=`${location.origin}/loop/${e.id}`;return o?(0,G.jsxs)(`div`,{className:`inline-flex items-center gap-1`,children:[s&&(0,G.jsxs)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(c),r(!0),setTimeout(()=>r(!1),1500)}catch{}},title:c,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] text-gray-600 hover:bg-gray-100`,children:[n?(0,G.jsx)(P,{size:11}):(0,G.jsx)(ee,{size:11}),(0,G.jsx)(`span`,{className:`hidden md:inline`,children:n?`copied`:`copy link`})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:async()=>{if(!(!o||i)){a(!0);try{await t.setLoopPublic(e.id,!s)}finally{a(!1)}}},disabled:i,title:s?`stop sharing`:`share publicly (anyone with the link can view)`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] border disabled:opacity-50 `+(s?`bg-emerald-50 text-emerald-800 border-emerald-200 hover:bg-emerald-100`:`bg-white text-gray-700 border-gray-300 hover:bg-gray-100`),children:[s?(0,G.jsx)(ve,{size:11}):(0,G.jsx)(Ee,{size:11}),s?`shared`:`share`]})]}):(0,G.jsxs)(`span`,{title:s?`this loop is shared publicly`:`this loop is private`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] `+(s?`bg-emerald-50 text-emerald-800 border border-emerald-200`:`bg-gray-100 text-gray-600`),children:[s?(0,G.jsx)(ve,{size:11}):(0,G.jsx)(Ee,{size:11}),s?`public`:`private`]})}function $W({meta:e}){let t=vg(),[n,r]=(0,_.useState)(!1);if(!t.currentUser)return null;let i=e.driver??e.createdBy,a=t.currentUser.id===i;return e.rfdRequestedAt?(0,G.jsxs)(`button`,{type:`button`,disabled:n,onClick:async()=>{r(!0);try{await t.takeDrive(e.id)}finally{r(!1)}},title:`released for drive by ${e.rfdRequestedBy??`?`} — click to take over`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] border bg-amber-500 text-white border-amber-600 hover:bg-amber-600 disabled:opacity-50`,children:[(0,G.jsx)(ye,{size:11}),`Drive`]}):a?(0,G.jsxs)(`button`,{type:`button`,disabled:n,onClick:async()=>{if(window.confirm(`Request For Drive: this will tear down the sandbox and release the loop so anyone else can take over. Continue?`)){r(!0);try{await t.requestDrive(e.id)}finally{r(!1)}}},title:`Release this loop so someone else can drive it`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] border bg-white text-amber-700 border-amber-300 hover:bg-amber-50 disabled:opacity-50`,children:[(0,G.jsx)(ye,{size:11}),`Request For Drive`]}):null}function eG({label:e,value:t,title:n}){return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-gray-100 text-[11px]`,title:n,children:[(0,G.jsxs)(`span`,{className:`text-gray-500`,children:[e,`:`]}),(0,G.jsx)(`span`,{className:`text-gray-900 font-medium`,children:t})]})}function tG({profiles:e}){let[t,n]=(0,_.useState)({});return(0,_.useEffect)(()=>{let e=!1;return am().then(t=>{if(e)return;let r={};for(let e of t)e.description&&(r[e.name]=e.description);n(r)}).catch(()=>{}),()=>{e=!0}},[]),(0,G.jsxs)(`div`,{className:`mt-1 flex items-center gap-1.5 flex-wrap text-[11px]`,children:[(0,G.jsx)(`span`,{className:`text-gray-400`,children:`profiles:`}),e.map(e=>(0,G.jsx)(eG,{label:e,value:`active`,title:t[e]},e))]})}function nG({loopId:e,meta:t,mode:n,onClose:r,pickedFile:i,onPickFile:a,currentUserId:o,isFullscreen:s,onToggleFullscreen:c,onEditorSelection:l}){let u=rU(),[d,f]=(0,_.useState)(()=>{let e=localStorage.getItem(`loopat:mobilePanelPct`);return e?Math.max(20,Math.min(95,parseInt(e)||55)):55}),p=(0,_.useRef)(null),m=e=>{localStorage.setItem(`loopat:mobilePanelPct`,String(e))},h=e=>{if(p.current={startY:e,startPct:d},s){let t=Math.round(e/window.innerHeight*100),n=Math.max(20,Math.min(95,t));f(n),m(n),c?.()}},g=e=>{if(!p.current)return;let t=e-p.current.startY,n=Math.round(t/window.innerHeight*100),r=Math.max(20,Math.min(95,p.current.startPct+n));f(r),m(r)},v=()=>{p.current=null},y=e=>{e.preventDefault(),e.stopPropagation(),h(e.touches[0].clientY)},b=e=>{e.preventDefault(),g(e.touches[0].clientY)},x=e=>{e.preventDefault(),v()},S=e=>{e.pointerType!==`touch`&&(e.preventDefault(),e.target.setPointerCapture(e.pointerId),h(e.clientY))},C=e=>{e.pointerType===`touch`||!p.current||g(e.clientY)},w=e=>{e.pointerType!==`touch`&&v()},T=(0,G.jsxs)(`aside`,{className:`flex-1 min-w-0 bg-white flex flex-col`,children:[(0,G.jsxs)(`header`,{className:`px-3 h-8 shrink-0 border-b border-gray-200 flex items-center gap-1 text-[11px] text-gray-500`,children:[(0,G.jsx)(`span`,{className:`capitalize`,children:n}),n===`editor`&&(0,G.jsx)(`span`,{className:`ml-2 truncate text-gray-700`,children:i||`(no file)`}),(0,G.jsx)(`div`,{className:`flex-1`}),(n===`editor`||n===`terminal`)&&(0,G.jsx)(`button`,{className:`text-gray-400 hover:text-gray-700 px-1 rounded hover:bg-gray-100`,onClick:c,title:s?`restore`:`maximize`,children:s?(0,G.jsx)(Ae,{size:13}):(0,G.jsx)(De,{size:13})}),(0,G.jsx)(`button`,{className:`text-gray-500 hover:text-gray-900 px-1 rounded hover:bg-gray-100`,onClick:r,title:`close panel`,children:`✕`})]}),n===`info`&&(0,G.jsx)(rG,{meta:t}),n===`workdir`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(PW,{loopId:e,onPick:a,picked:i}),(0,G.jsxs)(`div`,{className:`border-t border-gray-200 px-3 py-2 text-[11px] text-gray-500`,children:[`⑂ `,(0,G.jsx)(`span`,{className:`text-gray-900`,children:`main`})]})]}),(0,G.jsxs)(_.Suspense,{fallback:(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-gray-400 text-sm`,children:`Loading...`}),children:[n===`editor`&&(0,G.jsx)(KW,{loopId:e,path:i,onSelectionChange:l}),n===`terminal`&&(0,G.jsx)(`div`,{className:`flex-1 min-h-0 bg-[#1a1c20] overflow-hidden`,children:(0,G.jsx)(qW,{loopId:e,currentUserId:o})}),n===`git`&&(0,G.jsx)(BW,{loopId:e,onClose:r,onPickFile:a})]})]});return u?(0,G.jsxs)(`div`,{className:`fixed inset-x-0 top-0 z-40 bg-white rounded-b-xl shadow-xl pointer-events-auto overflow-hidden`,style:{height:s?`100vh`:`${d}vh`},children:[(0,G.jsx)(`div`,{className:`absolute inset-0 bottom-7 overflow-y-auto flex flex-col`,children:T}),(0,G.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 h-7 z-10 flex items-center justify-center cursor-row-resize active:bg-gray-50 rounded-b-xl`,style:{touchAction:`none`},onTouchStart:y,onTouchMove:b,onTouchEnd:x,onPointerDown:S,onPointerMove:C,onPointerUp:w,children:(0,G.jsx)(`div`,{className:`w-8 h-1 rounded-full bg-gray-300`})})]}):s?(0,ft.createPortal)((0,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex flex-col`,children:T}),document.body):T}function rG({meta:e}){let t=vg().currentUser?.id===e.createdBy;return(0,G.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-auto px-5 py-4 text-[13px] text-gray-900`,children:[(0,G.jsxs)(iG,{label:`basics`,children:[(0,G.jsx)(aG,{label:`title`,value:e.title}),(0,G.jsx)(aG,{label:`created`,value:new Date(e.createdAt).toLocaleString()}),(0,G.jsx)(aG,{label:`status`,value:`active`}),(0,G.jsx)(aG,{label:`driver`,value:t?`${e.createdBy} (you)`:e.createdBy}),(0,G.jsx)(aG,{label:`sharing`,value:e.public?`public — /loop/${e.id.slice(0,8)}…`:`private`})]}),(0,G.jsxs)(iG,{label:`workdir`,children:[(0,G.jsx)(aG,{label:`id`,value:e.id,mono:!0}),(0,G.jsx)(aG,{label:`path`,value:`~/.loopat/loops/${e.id.slice(0,8)}/workdir`,mono:!0}),(0,G.jsx)(aG,{label:`branch`,value:`main`,mono:!0})]}),(0,G.jsxs)(iG,{label:`context`,children:[(0,G.jsx)(aG,{label:`knowledge`,value:`all (ro)`}),(0,G.jsx)(aG,{label:`notes`,value:`all (rw)`}),(0,G.jsx)(aG,{label:`personal`,value:`${e.createdBy} (rw)`})]})]})}function iG({label:e,children:t}){return(0,G.jsxs)(`section`,{className:`mb-5`,children:[(0,G.jsx)(`h3`,{className:`text-[11px] uppercase tracking-wide text-gray-400 mb-2`,children:e}),(0,G.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:t})]})}function aG({label:e,value:t,mono:n=!1}){return(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,G.jsx)(`span`,{className:`text-[11px] text-gray-500 w-24 shrink-0`,children:e}),(0,G.jsx)(`span`,{className:n?`font-mono text-[12px] text-gray-800 truncate`:`text-[13px] text-gray-900 truncate`,children:t})]})}function oG({name:e,onClick:t,onEdit:n,size:r=`sm`}){return(0,G.jsxs)(`span`,{className:`relative inline-flex items-center group/chip`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:t,className:`inline-flex items-center rounded-full bg-sky-50 text-sky-700 border border-sky-200 hover:bg-sky-100 transition-colors font-mono `+(r===`md`?`px-2 py-0.5 text-[12px]`:`px-1.5 py-0.5 text-[10px]`),title:`#${e}`,children:[`#`,e]}),n&&(0,G.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),n()},className:`absolute -top-1 -right-1 z-10 w-4 h-4 rounded-full bg-white border border-gray-300 hover:border-red-400 hover:text-red-500 text-[9px] text-gray-400 opacity-0 group-hover/chip:opacity-100 transition-opacity flex items-center justify-center shadow-sm`,title:`Remove tag`,children:`×`})]})}function sG(){let{name:e}=Wn(),t=decodeURIComponent(e??``),n=Bn(),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(!0);return(0,_.useEffect)(()=>{let e=!1;return uh().then(n=>{e||(i(n.find(e=>e.name===t.toLowerCase())??null),o(!1))}),()=>{e=!0}},[t]),(0,G.jsxs)(`div`,{className:`flex flex-col h-full w-full bg-white`,children:[(0,G.jsxs)(`header`,{className:`h-10 shrink-0 flex items-center gap-3 px-6 border-b border-gray-200`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>n(-1),className:`text-[11px] text-gray-500 hover:text-gray-900`,children:`← back`}),(0,G.jsx)(oG,{name:t,size:`md`}),(0,G.jsx)(`div`,{className:`flex-1`})]}),(0,G.jsx)(`main`,{className:`flex-1 min-w-0 flex flex-col overflow-auto`,children:(0,G.jsx)(`div`,{className:`px-4 md:px-8 py-4 md:py-8 mx-auto w-full max-w-[760px] flex flex-col gap-5`,children:a?(0,G.jsx)(`div`,{className:`text-[12px] text-gray-400 italic`,children:`loading…`}):!r||r.loops.length===0?(0,G.jsxs)(`div`,{className:`text-[12px] text-gray-400 italic`,children:[`no entities tagged with `,(0,G.jsxs)(`code`,{children:[`#`,t]})]}):(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`div`,{className:`text-[12px] uppercase tracking-wider text-gray-500 mb-2 px-1`,children:[`Loops (`,r.loops.length,`)`]}),(0,G.jsx)(`div`,{className:`flex flex-col gap-1`,children:r.loops.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(`/loop/${e.id}`),className:`w-full text-left px-3 py-2 rounded border border-gray-200 hover:border-gray-400 hover:bg-gray-50 text-[13px] text-gray-900`,children:[e.title,(0,G.jsx)(`span`,{className:`ml-2 text-[10px] font-mono text-gray-400`,children:e.id.slice(0,6)})]},e.id))})]})})})]})}var cG=(0,_.lazy)(()=>_t(()=>import(`./CodeEditor-CCmzcfl4.js`).then(e=>({default:e.CodeEditor})),__vite__mapDeps([2,1,3]))),lG=(0,_.lazy)(()=>_t(()=>import(`./Markdown-DL99Gl_M.js`).then(e=>({default:e.Markdown})),__vite__mapDeps([6,1]))),uG=(0,_.lazy)(()=>_t(()=>import(`./MilkdownEditor-CDYnLn81.js`).then(e=>({default:e.MilkdownEditor})),__vite__mapDeps([7,1,3]))),dG=[{id:`knowledge`,label:`Knowledge`},{id:`notes`,label:`Notes`},{id:`personal`,label:`Personal`},{id:`repos`,label:`Repos`}],fG=new Set([`knowledge`,`notes`,`personal`,`repos`]);function pG(){let{sub:e}=Wn(),[t]=vi(),n=fG.has(e)?e:`knowledge`,r=t.get(`file`)||void 0,i=t.get(`edit`)===`1`;return(0,G.jsxs)(`div`,{className:`flex flex-col h-full w-full`,children:[(0,G.jsx)(`nav`,{className:`flex items-center gap-1 px-3 h-9 shrink-0 border-b border-gray-200 bg-white`,children:dG.map(e=>(0,G.jsx)(di,{to:`/context/${e.id}`,className:({isActive:e})=>e?`h-7 px-2.5 rounded flex items-center gap-1.5 text-xs bg-gray-100 text-gray-900`:`h-7 px-2.5 rounded flex items-center gap-1.5 text-xs text-gray-500 hover:bg-gray-50 hover:text-gray-900`,children:(0,G.jsx)(`span`,{children:e.label})},e.id))}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0`,children:n===`repos`?(0,G.jsx)(TG,{}):(0,G.jsx)(_G,{vault:n,initialFile:r,initialEditing:i},n)})]})}var mG={knowledge:`workspace's distilled materials`,notes:`workspace · public`,personal:`yours · private`,repos:`registered code repos`};function hG({resource:e,canPush:t=!0}){let[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(null),c=(0,_.useCallback)(async()=>{a(`status`),r(await Hm(e)),a(null)},[e]);(0,_.useEffect)(()=>{c()},[c]);let l=async()=>{a(`pull`),s(null);let t=await Um(e);a(null),s(t.ok?{ok:!0,text:t.message??`pulled`}:{ok:!1,text:t.error??`pull failed`}),t.ok&&c()},u=async()=>{a(`push`),s(null);let t=await Wm(e);a(null),s(t.ok?{ok:!0,text:t.message??`pushed`}:{ok:!1,text:t.error??`push failed`}),t.ok&&c()},d=n?.ahead??0,f=n?.behind??0,p=n&&!n.hasRemote;return(0,G.jsxs)(`div`,{className:`px-3 py-1.5 border-t border-gray-200 flex flex-col gap-1 text-[11px]`,children:[(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:p?(0,G.jsx)(`span`,{className:`text-gray-400`,children:`no remote`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`span`,{className:d>0?`text-emerald-700`:`text-gray-400`,title:`unpushed commits`,children:[`↑`,d]}),(0,G.jsxs)(`span`,{className:f>0?`text-amber-700`:`text-gray-400`,title:`unpulled commits`,children:[`↓`,f]}),n&&n.uncommitted>0&&(0,G.jsxs)(`span`,{className:`text-red-600`,title:`uncommitted changes in primary`,children:[`! `,n.uncommitted]}),(0,G.jsx)(`button`,{onClick:()=>void c(),disabled:i!==null,className:`ml-auto text-gray-400 hover:text-gray-700 disabled:opacity-50`,title:`refresh status`,children:`↻`})]})}),!p&&(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`button`,{onClick:l,disabled:i!==null||f===0,className:`px-1.5 h-5 rounded border border-gray-200 hover:bg-gray-100 text-gray-700 disabled:opacity-40 disabled:cursor-not-allowed`,children:i===`pull`?`pulling…`:`pull`}),t&&(0,G.jsx)(`button`,{onClick:u,disabled:i!==null||d===0,className:`px-1.5 h-5 rounded border border-gray-200 hover:bg-gray-100 text-gray-700 disabled:opacity-40 disabled:cursor-not-allowed`,children:i===`push`?`pushing…`:`push`}),o&&(0,G.jsx)(`span`,{className:`truncate flex-1 min-w-0 `+(o.ok?`text-emerald-700`:`text-red-600`),title:o.text,children:o.text})]})]})}function gG({onRefreshed:e}){let[t,n]=(0,_.useState)(0),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(null),s=(0,_.useRef)(e);s.current=e;let c=(0,_.useCallback)(async()=>{i(!0),o(null);let e=await Mm();i(!1),e.ok?(n(0),s.current()):e.diverged?o(`你有未保存的编辑,先保存再刷新`):o(e.error??`refresh failed`)},[]);return(0,_.useEffect)(()=>{c()},[c]),(0,_.useEffect)(()=>{let e=()=>jm().then(n).catch(()=>{});e();let t=setInterval(e,5e3);return()=>clearInterval(t)},[]),(0,G.jsxs)(`div`,{className:`px-3 py-2 border-t border-gray-200 flex flex-col gap-1.5 text-[11px]`,children:[t>0?(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2 bg-amber-50 border border-amber-200 rounded px-2 py-1 text-amber-800`,children:[(0,G.jsxs)(`span`,{children:[`远端已更新 `,t,` 个改动`]}),(0,G.jsx)(`button`,{type:`button`,onClick:c,disabled:r,className:`px-2 py-0.5 rounded bg-amber-600 text-white hover:bg-amber-700 disabled:opacity-50`,children:r?`刷新中…`:`刷新`})]}):(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-gray-400`,children:[(0,G.jsx)(`span`,{children:`已是最新`}),(0,G.jsx)(`button`,{type:`button`,onClick:c,disabled:r,className:`text-gray-500 hover:text-gray-900 underline disabled:opacity-50`,children:r?`刷新中…`:`刷新`})]}),a&&(0,G.jsx)(`div`,{className:`text-amber-700`,children:a})]})}function _G({vault:e,initialFile:t,initialEditing:n}){let[r,i]=(0,_.useState)([]),[a,o]=(0,_.useState)([]),[s,c]=(0,_.useState)(t??null),[l,u]=vi();(0,_.useEffect)(()=>{(l.get(`file`)??null)!==s&&u(s?{file:s}:{},{replace:!0})},[s,l,u]);let[d,f]=(0,_.useState)(0),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(``),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(``),w=rU(),T=(0,_.useRef)(!1);if(!T.current&&t){T.current=!0;let n=`vault-${e}`,r=t.includes(`/`)?t.substring(0,t.lastIndexOf(`/`)):``;if(r)try{let e=`loopat:tree:expanded:`+n,t=localStorage.getItem(e),i=t?JSON.parse(t):[];for(let e=r;e;e=e.includes(`/`)?e.substring(0,e.lastIndexOf(`/`)):``)i.includes(e)||i.push(e);localStorage.setItem(e,JSON.stringify(i))}catch{}}(0,_.useEffect)(()=>{Em(e).then(e=>{i(e),c(t=>{if(t)return t;let n=e.find(e=>e.type===`file`&&e.path.endsWith(`.md`));return n?n.path:null})}),Dm(e).then(o),g(``)},[e,d]),(0,_.useEffect)(()=>{let t=!1,n=()=>{t||f(e=>e+1)};return e===`knowledge`?Um(`knowledge`).then(e=>{e.ok&&(e.message??``).toLowerCase()!==`already up to date`&&n()}):e===`notes`?jm().then(e=>{e>0&&Mm().then(e=>{e.ok&&n()})}):e===`personal`&&Qp().then(e=>{e.ok&&(e.files?.length??0)>0&&n()}),()=>{t=!0}},[e]);let E=async t=>{let n=await Nm(e,t);n.ok?(m(!1),f(e=>e+1),c(t)):alert(`failed: ${n.error}`)},D=async()=>{if(!b||!S.trim()){x(null);return}let t=b.path+`/`+S.trim();if(b.type===`file`){let n=await Nm(e,t);if(!n.ok){alert(`create failed: ${n.error}`);return}}else{let n=await Pm(e,t);if(!n.ok){alert(`create failed: ${n.error}`);return}}x(null),C(``),f(e=>e+1)},O=(0,_.useCallback)((t,n)=>{if(t===`view`)c(n.path);else if(t===`new-file`||t===`new-folder`)x({type:t===`new-file`?`file`:`folder`,path:n.path}),C(``);else if(t===`delete`){if(!confirm(`Delete "${n.name}"?`))return;Fm(e,n.path).then(e=>{e.ok?(c(e=>e===n.path?null:e),f(e=>e+1)):alert(`delete failed: ${e.error}`)})}},[e]),k=(0,_.useCallback)(t=>yG(e,t.path)?[]:t.type===`dir`?[{label:`New file`,icon:(0,G.jsx)(ce,{size:12}),action:`new-file`},{label:`New folder`,icon:(0,G.jsx)(me,{size:12}),action:`new-folder`},{label:`Delete`,icon:(0,G.jsx)(nt,{size:12}),action:`delete`,danger:!0}]:bG(e,t.path)?[]:[{label:`View`,icon:(0,G.jsx)(ae,{size:12}),action:`view`},{label:`Delete`,icon:(0,G.jsx)(nt,{size:12}),action:`delete`,danger:!0}],[e]),A=(0,_.useCallback)(t=>Em(e,t).then(e=>e),[e]),j=(0,_.useCallback)((t,n,r,i)=>{if(t.type===`dir`)return yG(e,t.path)?`w-full py-1.5 flex items-center gap-1.5 bg-amber-50/40 hover:bg-amber-50 text-left border-y border-amber-200/60 mt-1`:`w-full py-1 flex items-center gap-1 hover:bg-gray-50 text-left`;let a=bG(e,t.path);return`w-full py-1 flex items-center gap-2 text-left `+(i?`bg-gray-100`:a?`hover:bg-amber-50/50`:`hover:bg-gray-50`)},[e]),M=h.trim().toLowerCase(),N=M.length>0,P=N?a.filter(e=>e.path.toLowerCase().includes(M)).slice(0,60):[],F=(0,G.jsxs)(`aside`,{className:`w-64 shrink-0 border-r border-gray-200 bg-white flex flex-col h-full`,children:[(0,G.jsxs)(`div`,{className:`px-3 h-9 flex items-center gap-1 border-b border-gray-200`,children:[w&&(0,G.jsx)(`button`,{onClick:()=>y(!1),className:`text-gray-500 hover:text-gray-900 px-1 rounded hover:bg-gray-100 mr-1`,title:`close sidebar`,children:(0,G.jsx)(Fe,{size:14})}),(0,G.jsx)(vG,{}),(0,G.jsx)(`input`,{type:`text`,value:h,onChange:e=>g(e.target.value),placeholder:`search files…`,className:`flex-1 min-w-0 bg-transparent outline-none text-[12px] text-gray-700 placeholder:text-gray-400`}),(0,G.jsx)(`button`,{onClick:()=>m(!0),className:`text-gray-500 hover:text-gray-900 px-1.5 rounded hover:bg-gray-100 text-xs`,title:`new file`,children:`+`}),(0,G.jsx)(`button`,{onClick:()=>f(e=>e+1),className:`text-gray-500 hover:text-gray-900 px-1.5 rounded hover:bg-gray-100 text-xs`,title:`refresh`,children:`↻`})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto py-2`,children:N?P.length===0?(0,G.jsx)(`div`,{className:`px-3 py-4 text-[12px] text-gray-400 italic`,children:`no matches`}):P.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{c(e.path),w&&y(!1)},className:`w-full px-3 py-1.5 flex items-center gap-2 text-left `+(s===e.path?`bg-gray-100`:`hover:bg-gray-50`),title:e.path,children:[(0,G.jsx)(`span`,{className:`text-gray-500`,children:`📄`}),(0,G.jsx)(`span`,{className:`flex-1 min-w-0 truncate text-[13px] text-gray-900`,children:e.path})]},e.path)):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(AW,{treeId:`vault-${e}`,entries:r,onPick:e=>{c(e),w&&y(!1)},picked:s,onLoadChildren:A,getContextActions:k,onAction:O,nodeClassName:j,reloadKey:d}),r.length===0&&(0,G.jsx)(`div`,{className:`px-3 py-4 text-[12px] text-gray-400 italic`,children:`empty · click + 创建第一个文件`})]})}),(0,G.jsx)(`div`,{className:`px-3 h-9 border-t border-gray-200 flex items-center text-[11px] text-gray-500`,children:mG[e]}),e===`knowledge`&&(0,G.jsx)(hG,{resource:e}),e===`notes`&&(0,G.jsx)(gG,{onRefreshed:()=>f(e=>e+1)})]});return(0,G.jsxs)(`div`,{className:`flex h-full w-full`,children:[w?(0,G.jsx)(G.Fragment,{children:v?(0,G.jsxs)(`div`,{className:`fixed inset-0 z-30`,onClick:()=>y(!1),children:[(0,G.jsx)(`div`,{className:`absolute inset-0 bg-black/30`}),(0,G.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 w-64 max-w-[80vw] shadow-xl`,onClick:e=>e.stopPropagation(),children:F})]}):(0,G.jsx)(`aside`,{className:`w-9 shrink-0 border-r border-gray-200 bg-white flex flex-col items-center pt-2`,children:(0,G.jsx)(`button`,{type:`button`,onClick:()=>y(!0),className:`w-7 h-7 flex items-center justify-center text-gray-500 hover:text-gray-900 hover:bg-gray-100 rounded`,title:`open file tree`,children:(0,G.jsx)(Ie,{size:16})})})}):F,(0,G.jsx)(`main`,{className:`flex-1 min-w-0 flex flex-col bg-white min-h-0`,children:s?(0,G.jsx)(CG,{vault:e,path:s,onSelect:c,onSaved:()=>f(e=>e+1),initialEditing:n}):(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-[13px] text-gray-400 italic`,children:`选一个文件,或点 + 新建`})}),p&&(0,G.jsx)(wG,{vault:e,onClose:()=>m(!1),onCreate:E}),b&&(0,G.jsx)(xG,{type:b.type,parentPath:b.path,value:S,onChange:C,onSubmit:D,onCancel:()=>x(null)})]})}function vG(){return(0,G.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,className:`text-gray-400 shrink-0`,children:(0,G.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,d:`M11 11l3 3M7 12.5a5.5 5.5 0 1 1 0-11 5.5 5.5 0 0 1 0 11z`})})}function yG(e,t){return e!==`personal`||!t.startsWith(`.loopat/vaults/`)?!1:t.slice(15).length>0}function bG(e,t){return e!==`personal`||!t.startsWith(`.loopat/vaults/`)?!1:t.slice(15).includes(`/`)}function xG({type:e,parentPath:t,value:n,onChange:r,onSubmit:i,onCancel:a}){return(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/30 flex items-center justify-center`,onClick:a,children:(0,G.jsxs)(`div`,{className:`w-full max-w-[420px] mx-4 bg-white rounded-md shadow-xl border border-gray-200 p-4 md:p-5`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`text-base font-semibold text-gray-900 mb-3`,children:[e===`file`?`New file`:`New folder`,` in `,(0,G.jsx)(`span`,{className:`font-mono text-[13px]`,children:t||`root`})]}),(0,G.jsx)(`input`,{autoFocus:!0,type:`text`,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&i(),e.key===`Escape`&&a()},placeholder:e===`file`?`filename.md`:`folder-name`,className:`w-full px-3 py-2 text-sm border border-gray-300 rounded outline-none focus:border-gray-500 font-mono`}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2 mt-4`,children:[(0,G.jsx)(`button`,{onClick:a,className:`px-3 h-8 text-sm rounded text-gray-700 hover:bg-gray-100`,children:`cancel`}),(0,G.jsx)(`button`,{onClick:()=>n.trim()&&i(),disabled:!n.trim(),className:`px-3 h-8 text-sm rounded bg-gray-900 text-white hover:bg-gray-700 disabled:opacity-50`,children:`create`})]})]})})}function SG(e){return/(^|\/)secrets\//.test(e)||e===`secrets`}function CG({vault:e,path:t,onSelect:n,onSaved:r,initialEditing:i}){let a=vg(),o=Bn(),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(i??!1),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)([]),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(!1),[w,T]=(0,_.useState)(!1),[E,D]=(0,_.useState)(!1),O=rU(),k=(0,_.useRef)(i);(0,_.useEffect)(()=>{k.current?k.current=!1:f(!1),C(!1),y(null),T(!1),D(!1),Om(e,t).then(e=>{let t=e?.content??``;c(t),u(t),D(!!e?.secret)}),Im(e,t).then(g)},[e,t]);let A=SG(t)||E,j=t.endsWith(`.md`),M=e!==`knowledge`,N=!A,P=e===`notes`&&!A,F=A?l.length>0:l!==s,I=(0,_.useCallback)(async()=>{if(!(!F||p)){m(!0);try{let n=await km(e,t,l);if(n.ok){if(A?(c(``),u(``)):c(l),y(n.commit??null),f(!1),r(),Im(e,t).then(g),e===`notes`){let e=await Am();e.ok||(e.conflict?alert(`Saved locally, but it conflicts with the remote (${(e.files??[]).join(`, `)}). Your edit is kept — resolve by taking the remote, or in a loop.`):alert(`Saved locally, but push to remote failed: ${e.error??`unknown`}`))}else if(e===`personal`){let e=await $p();e.ok||(e.conflict?alert(`Saved locally, but it conflicts with the remote (${(e.files??[]).join(`, `)}). Your edit is kept — pull first (re-open Personal) or resolve in a loop.`):alert(`Saved locally, but push to remote failed: ${e.error??`unknown`}`))}}else alert(`save failed: ${n.error}`)}finally{m(!1)}}},[e,t,l,F,p,r,A]),L=()=>{f(!0),j&&C(!0)},R=()=>{u(s),f(!1)},z=async()=>{o(`/loop/${(await a.createLoop({title:`edit ${e}/${t}`})).id}`)},B=async()=>{o(`/loop/${(await a.createLoop({title:`distill ${t} → knowledge`,knowledgeRw:!0})).id}`)},V=e=>{n([t.replace(/[^/]+$/,``)+e+`.md`,e+`.md`,e][0].replace(/^\//,``))};return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`header`,{className:`px-3 md:px-5 h-10 shrink-0 border-b border-gray-200 flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] min-w-0`,children:[(0,G.jsx)(`span`,{className:`text-gray-500 shrink-0`,children:A?`🔒`:`📄`}),(0,G.jsx)(`span`,{className:`font-mono text-[12px] text-gray-500 truncate`,children:t}),v&&!F&&!d&&(0,G.jsxs)(`span`,{className:`hidden md:inline text-[10px] text-emerald-700 font-mono`,children:[`commit `,v]})]}),(0,G.jsx)(`div`,{className:`flex items-center gap-1 md:gap-2 text-xs text-gray-500`,children:d?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{onClick:R,className:`px-2.5 h-7 rounded text-xs text-gray-600 hover:bg-gray-100`,children:`cancel`}),(0,G.jsx)(`button`,{onClick:I,disabled:!F||p,className:`px-2.5 h-7 rounded text-xs bg-gray-900 text-white hover:bg-gray-700 disabled:opacity-50`,children:p?`saving…`:`save`})]}):(0,G.jsxs)(G.Fragment,{children:[P&&(0,G.jsxs)(`button`,{onClick:B,className:`px-2.5 h-7 rounded text-xs bg-amber-100 text-amber-900 hover:bg-amber-200 flex items-center gap-1`,title:`open a loop to distill this notes file into knowledge`,children:[(0,G.jsx)(`span`,{children:`↑`}),(0,G.jsx)(`span`,{children:`distill`})]}),N&&(0,G.jsxs)(`button`,{onClick:z,className:P?`px-2.5 h-7 rounded text-xs border border-gray-200 hover:bg-gray-100 text-gray-900 flex items-center gap-1`:`px-2.5 h-7 rounded text-xs bg-gray-900 text-white hover:bg-gray-700 flex items-center gap-1`,title:`open a new loop with AI assist for this file`,children:[(0,G.jsx)(`span`,{children:`↻`}),(0,G.jsx)(`span`,{children:`edit by loop`})]}),M&&(0,G.jsx)(`button`,{onClick:L,className:`px-2.5 h-7 rounded text-xs border border-gray-200 hover:bg-gray-100 text-gray-900`,title:`direct edit (fastpath)`,children:`edit`}),O&&j&&(0,G.jsxs)(`button`,{onClick:()=>x(e=>!e),className:`px-2.5 h-7 rounded text-xs border ${b?`bg-gray-900 text-white`:`border-gray-200 hover:bg-gray-100 text-gray-900`}`,title:`toggle backlinks`,children:[`⇄ `,h.length]})]})})]}),d?A?(0,G.jsxs)(`div`,{className:w?`fixed inset-0 z-50 bg-white flex flex-col`:`flex-1 min-h-0 min-w-0 flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`px-3 h-7 shrink-0 border-b border-gray-200 flex items-center gap-2 text-[11px] text-gray-500`,children:[(0,G.jsx)(`span`,{className:`text-amber-700`,children:`🔒`}),(0,G.jsx)(`span`,{children:`new value · saved encrypted`}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)(`button`,{onClick:()=>T(!w),className:`text-gray-400 hover:text-gray-700 px-1 rounded hover:bg-gray-100`,title:w?`restore`:`maximize`,children:w?(0,G.jsx)(Ae,{size:13}):(0,G.jsx)(De,{size:13})})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0 relative`,children:(0,G.jsx)(_.Suspense,{fallback:(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-gray-400 text-sm`,children:`Loading editor...`}),children:(0,G.jsx)(cG,{path:t,value:l,onChange:u})})})]}):j&&!S?(0,G.jsxs)(`div`,{className:w?`fixed inset-0 z-50 bg-white flex flex-col md:flex-row`:`flex-1 min-h-0 min-w-0 flex flex-col md:flex-row`,children:[(0,G.jsxs)(`div`,{className:`flex-1 min-w-0 min-h-0 border-r border-gray-200 flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`px-3 h-7 shrink-0 border-b border-gray-200 flex items-center gap-2 text-[11px] text-gray-500`,children:[(0,G.jsx)(`span`,{children:`source · markdown`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>C(!0),className:`px-2 h-5 rounded text-[10px] bg-gray-100 hover:bg-gray-200 text-gray-600`,title:`Switch to WYSIWYG editor`,children:`wysiwyg`}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)(`button`,{onClick:()=>T(!w),className:`text-gray-400 hover:text-gray-700 px-1 rounded hover:bg-gray-100`,title:w?`restore`:`maximize`,children:w?(0,G.jsx)(Ae,{size:13}):(0,G.jsx)(De,{size:13})})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0 relative`,children:(0,G.jsx)(_.Suspense,{fallback:(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-gray-400 text-sm`,children:`Loading editor...`}),children:(0,G.jsx)(cG,{path:t,value:l,onChange:u})})})]}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0 min-h-0 flex flex-col`,children:[(0,G.jsx)(`div`,{className:`px-3 h-7 shrink-0 border-b border-gray-200 flex items-center text-[11px] text-gray-500`,children:`preview`}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto px-6 py-4`,children:(0,G.jsx)(`div`,{className:`max-w-[760px]`,children:(0,G.jsx)(_.Suspense,{fallback:(0,G.jsx)(`div`,{className:`text-gray-400 text-sm`,children:`Loading preview...`}),children:(0,G.jsx)(lG,{text:l,onWikilink:V})})})})]})]}):j?(0,G.jsxs)(`div`,{className:w?`fixed inset-0 z-50 bg-white flex flex-col`:`flex-1 min-h-0 min-w-0 flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`px-3 h-7 shrink-0 border-b border-gray-200 flex items-center gap-2 text-[11px] text-gray-500`,children:[(0,G.jsx)(`span`,{children:`wysiwyg · milkdown`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>C(!1),className:`px-2 h-5 rounded text-[10px] bg-gray-100 hover:bg-gray-200 text-gray-600`,title:`Switch to source editor`,children:`source`}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)(`button`,{onClick:()=>T(!w),className:`text-gray-400 hover:text-gray-700 px-1 rounded hover:bg-gray-100`,title:w?`restore`:`maximize`,children:w?(0,G.jsx)(Ae,{size:13}):(0,G.jsx)(De,{size:13})})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0 relative`,children:(0,G.jsx)(_.Suspense,{fallback:(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-gray-400 text-sm`,children:`Loading editor...`}),children:(0,G.jsx)(uG,{value:l,onChange:u})})})]}):(0,G.jsxs)(`div`,{className:w?`fixed inset-0 z-50 bg-white flex flex-col`:`flex-1 min-h-0 min-w-0 flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`px-3 h-7 shrink-0 border-b border-gray-200 flex items-center gap-2 text-[11px] text-gray-500`,children:[(0,G.jsxs)(`span`,{children:[`source · `,t.includes(`.`)?t.split(`.`).pop():`text`]}),t.endsWith(`.json`)&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>{try{u(JSON.stringify(JSON.parse(l),null,2))}catch(e){alert(`Invalid JSON: `+(e?.message??`parse error`))}},className:`px-2 h-5 rounded text-[10px] bg-gray-100 hover:bg-gray-200 text-gray-600`,title:`Format JSON`,children:`format`}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)(`button`,{onClick:()=>T(!w),className:`text-gray-400 hover:text-gray-700 px-1 rounded hover:bg-gray-100`,title:w?`restore`:`maximize`,children:w?(0,G.jsx)(Ae,{size:13}):(0,G.jsx)(De,{size:13})})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0 relative`,children:(0,G.jsx)(_.Suspense,{fallback:(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-gray-400 text-sm`,children:`Loading editor...`}),children:(0,G.jsx)(cG,{path:t,value:l,onChange:u})})})]}):(0,G.jsxs)(`div`,{className:`flex flex-1 min-h-0 min-w-0 overflow-hidden`,children:[(0,G.jsx)(`article`,{className:`flex-1 min-h-0 overflow-auto px-4 md:px-8 py-4 md:py-6`,children:(0,G.jsx)(`div`,{className:`max-w-[760px]`,children:A?(0,G.jsxs)(`div`,{className:`font-sans text-[13px] text-gray-600 leading-relaxed`,children:[(0,G.jsx)(`div`,{className:`inline-flex items-center gap-1.5 px-2 py-1 rounded bg-amber-50 border border-amber-200 text-amber-800 text-[12px] font-medium`,children:`encrypted · value hidden by design`}),(0,G.jsxs)(`div`,{className:`mt-3 text-[12px] text-gray-500`,children:[`Click `,(0,G.jsx)(`b`,{children:`edit`}),` to overwrite. The current value is never returned by the server, so editing means typing a new replacement — there is no decrypt-and-view.`]})]}):j?(0,G.jsx)(_.Suspense,{fallback:(0,G.jsx)(`div`,{className:`text-gray-400 text-sm`,children:`Loading...`}),children:(0,G.jsx)(lG,{text:s,onWikilink:V})}):(0,G.jsx)(`pre`,{className:`font-mono text-[12.5px] leading-relaxed whitespace-pre-wrap text-gray-900`,children:s||(0,G.jsx)(`span`,{className:`text-gray-400 italic`,children:`(empty)`})})})}),j&&!O&&(0,G.jsxs)(`aside`,{className:`w-64 shrink-0 border-l border-gray-200 bg-gray-50 overflow-auto`,children:[(0,G.jsxs)(`div`,{className:`px-3 h-9 flex items-center border-b border-gray-200`,children:[(0,G.jsx)(`span`,{className:`text-[11px] text-gray-500`,children:`Backlinks`}),(0,G.jsx)(`span`,{className:`ml-auto text-[11px] text-gray-500`,children:h.length})]}),h.length===0?(0,G.jsx)(`div`,{className:`px-3 py-4 text-xs text-gray-500`,children:`No documents link here yet.`}):(0,G.jsx)(`ul`,{className:`py-2`,children:h.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(e.path),className:`w-full px-3 py-2 text-left hover:bg-gray-100`,children:[(0,G.jsx)(`div`,{className:`text-xs font-medium text-gray-900 truncate`,children:e.path}),(0,G.jsx)(`div`,{className:`text-[11px] text-gray-500 mt-0.5 leading-snug line-clamp-2`,children:e.preview})]})},e.path))})]}),O&&j&&b&&(0,G.jsxs)(`div`,{className:`fixed inset-0 z-30`,onClick:()=>x(!1),children:[(0,G.jsx)(`div`,{className:`absolute inset-0 bg-black/30`}),(0,G.jsxs)(`div`,{className:`absolute right-0 top-0 bottom-0 w-64 max-w-[80vw] bg-gray-50 border-l border-gray-200 shadow-xl overflow-auto`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`px-3 h-9 flex items-center border-b border-gray-200`,children:[(0,G.jsx)(`span`,{className:`text-[11px] text-gray-500`,children:`Backlinks`}),(0,G.jsx)(`span`,{className:`ml-auto text-[11px] text-gray-500`,children:h.length}),(0,G.jsx)(`button`,{onClick:()=>x(!1),className:`ml-2 text-gray-400 hover:text-gray-700 px-1`,title:`close backlinks`,children:`✕`})]}),h.length===0?(0,G.jsx)(`div`,{className:`px-3 py-4 text-xs text-gray-500`,children:`No documents link here yet.`}):(0,G.jsx)(`ul`,{className:`py-2`,children:h.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{n(e.path),x(!1)},className:`w-full px-3 py-2 text-left hover:bg-gray-100`,children:[(0,G.jsx)(`div`,{className:`text-xs font-medium text-gray-900 truncate`,children:e.path}),(0,G.jsx)(`div`,{className:`text-[11px] text-gray-500 mt-0.5 leading-snug line-clamp-2`,children:e.preview})]})},e.path))})]})]})]})]})}function wG({vault:e,onClose:t,onCreate:n}){let[r,i]=(0,_.useState)(``);return(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/30 flex items-center justify-center`,onClick:t,children:(0,G.jsxs)(`div`,{className:`w-full max-w-[420px] mx-4 bg-white rounded-md shadow-xl border border-gray-200 p-4 md:p-5`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`text-base font-semibold text-gray-900 mb-3`,children:[`new file in `,e,`/`]}),(0,G.jsx)(`input`,{autoFocus:!0,type:`text`,value:r,onChange:e=>i(e.target.value),placeholder:`loopat/new-doc.md`,className:`w-full px-3 py-2 text-sm border border-gray-300 rounded outline-none focus:border-gray-500 font-mono`}),(0,G.jsx)(`div`,{className:`text-[11px] text-gray-400 mt-1`,children:`relative path. directories created as needed.`}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2 mt-4`,children:[(0,G.jsx)(`button`,{onClick:t,className:`px-3 h-8 text-sm rounded text-gray-700 hover:bg-gray-100`,children:`cancel`}),(0,G.jsx)(`button`,{onClick:()=>r.trim()&&n(r.trim()),disabled:!r.trim(),className:`px-3 h-8 text-sm rounded bg-gray-900 text-white hover:bg-gray-700 disabled:opacity-50`,children:`create`})]})]})})}function TG(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(null),u=(0,_.useCallback)(async()=>{let e=await Lm();t(e),r(e.notes?.git??``),a(e.repos)},[]);(0,_.useEffect)(()=>{u()},[u]);let d=e!==null&&(n.trim()!==(e.notes?.git??``)||JSON.stringify(i)!==JSON.stringify(e.repos)),f=()=>a(e=>[...e,{name:``,git:``}]),p=(e,t,n)=>a(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r)),m=e=>a(t=>t.filter((t,n)=>n!==e));return e?(0,G.jsx)(`article`,{className:`flex-1 min-w-0 overflow-auto p-5`,children:(0,G.jsxs)(`div`,{className:`max-w-2xl flex flex-col gap-5`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-gray-900`,children:`Repo roster`}),(0,G.jsxs)(`p`,{className:`text-[12px] text-gray-500 leading-relaxed mt-1`,children:[`Declared in the knowledge repo's`,` `,(0,G.jsx)(`code`,{className:`bg-gray-100 px-1 rounded text-[11px]`,children:`.loopat/config.json`}),`. Repos are cloned on demand when a loop selects one. Saving commits + pushes back to the knowledge repo (needs your key to have write access).`]})]}),(0,G.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`text-[12px] font-medium text-gray-700`,children:`notes remote`}),(0,G.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`git@…/notes.git`,className:`px-2 py-1.5 text-sm font-mono border border-gray-300 rounded outline-none focus:border-gray-500`})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(`span`,{className:`text-[12px] font-medium text-gray-700`,children:`repos`}),i.length===0&&(0,G.jsx)(`div`,{className:`text-[12px] text-gray-400`,children:`No repos yet.`}),i.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{value:e.name,onChange:e=>p(t,`name`,e.target.value),placeholder:`name`,className:`w-40 px-2 py-1.5 text-sm border border-gray-300 rounded outline-none focus:border-gray-500`}),(0,G.jsx)(`input`,{value:e.git,onChange:e=>p(t,`git`,e.target.value),placeholder:`git@…/repo.git`,className:`flex-1 px-2 py-1.5 text-sm font-mono border border-gray-300 rounded outline-none focus:border-gray-500`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>m(t),className:`px-2 py-1.5 text-gray-400 hover:text-red-600`,title:`remove`,children:`✕`})]},t)),(0,G.jsx)(`button`,{type:`button`,onClick:f,className:`self-start text-[12px] text-gray-600 hover:text-gray-900 border border-gray-200 rounded px-2 py-1`,children:`+ add repo`})]}),c&&(0,G.jsx)(`div`,{className:`text-[12px] rounded px-2 py-1.5 border ${c.ok?`text-emerald-700 bg-emerald-50 border-emerald-200`:`text-red-700 bg-red-50 border-red-200`}`,children:c.text}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:async()=>{s(!0),l(null);let e=i.map(e=>({name:e.name.trim(),git:e.git.trim()})).filter(e=>e.name&&e.git),t=await Rm({notes:n.trim()?{git:n.trim()}:null,repos:e});s(!1),t.ok?(l({ok:!0,text:`Saved + promoted to the knowledge repo.`}),await u()):l({ok:!1,text:(t.savedLocally?`Saved locally but promote failed: `:`Save failed: `)+(t.error??``)})},disabled:!d||o,className:`px-3 h-9 text-sm rounded bg-gray-900 text-white hover:bg-gray-700 disabled:opacity-40`,children:o?`Saving…`:`Save + promote`}),d&&(0,G.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:`unsaved changes`})]})]})}):(0,G.jsx)(`div`,{className:`p-6 text-sm text-gray-400`,children:`loading…`})}function EG(){var e=[...arguments];return(0,_.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var DG=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function OG(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function kG(e){return`nodeType`in e}function AG(e){return e?OG(e)?e:kG(e)?e.ownerDocument?.defaultView??window:window:window}function jG(e){let{Document:t}=AG(e);return e instanceof t}function MG(e){return OG(e)?!1:e instanceof AG(e).HTMLElement}function NG(e){return e instanceof AG(e).SVGElement}function PG(e){return e?OG(e)?e.document:kG(e)?jG(e)?e:MG(e)||NG(e)?e.ownerDocument:document:document:document}var FG=DG?_.useLayoutEffect:_.useEffect;function IG(e){let t=(0,_.useRef)(e);return FG(()=>{t.current=e}),(0,_.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function LG(){let e=(0,_.useRef)(null);return[(0,_.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,_.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function RG(e,t){t===void 0&&(t=[e]);let n=(0,_.useRef)(e);return FG(()=>{n.current!==e&&(n.current=e)},t),n}function zG(e,t){let n=(0,_.useRef)();return(0,_.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function BG(e){let t=IG(e),n=(0,_.useRef)(null);return[n,(0,_.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function VG(e){let t=(0,_.useRef)();return(0,_.useEffect)(()=>{t.current=e},[e]),t.current}var HG={};function UG(e,t){return(0,_.useMemo)(()=>{if(t)return t;let n=HG[e]==null?0:HG[e]+1;return HG[e]=n,e+`-`+n},[e,t])}function WG(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var GG=WG(1),KG=WG(-1);function qG(e){return`clientX`in e&&`clientY`in e}function JG(e){if(!e)return!1;let{KeyboardEvent:t}=AG(e.target);return t&&e instanceof t}function YG(e){if(!e)return!1;let{TouchEvent:t}=AG(e.target);return t&&e instanceof t}function XG(e){if(YG(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return qG(e)?{x:e.clientX,y:e.clientY}:null}var ZG=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[ZG.Translate.toString(e),ZG.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),QG=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function $G(e){return e.matches(QG)?e:e.querySelector(QG)}var eK={display:`none`};function tK(e){let{id:t,value:n}=e;return _.createElement(`div`,{id:t,style:eK},n)}function nK(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return _.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function rK(){let[e,t]=(0,_.useState)(``);return{announce:(0,_.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var iK=(0,_.createContext)(null);function aK(e){let t=(0,_.useContext)(iK);(0,_.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function oK(){let[e]=(0,_.useState)(()=>new Set),t=(0,_.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,_.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var sK={draggable:`
|
|
107
|
+
`),n=``,r=[],i=null,a=0,o=0;for(let e of t){if(e.startsWith(`diff `)){n=e;continue}if(e.startsWith(`+++ `)||e.startsWith(`--- `))continue;let t=e.match(/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(.*)$/);if(t){i&&r.push(i),a=parseInt(t[1],10),o=parseInt(t[3],10),i={header:e,lines:[]};continue}i&&(e.startsWith(`+`)?(i.lines.push({type:`add`,oldNum:null,newNum:o,text:e.slice(1)}),o++):e.startsWith(`-`)?(i.lines.push({type:`del`,oldNum:a,newNum:null,text:e.slice(1)}),a++):(i.lines.push({type:`ctx`,oldNum:a,newNum:o,text:e.startsWith(` `)?e.slice(1):e}),a++,o++))}return i&&r.push(i),{fileHeader:n,hunks:r}}function RW({filePath:e,diff:t,loading:n,onClose:r}){let i=null;if(t)try{i=LW(t)}catch{}return(0,G.jsx)(Tg,{open:!0,onOpenChange:e=>{e||r()},children:(0,G.jsxs)(Og,{className:`sm:max-w-4xl max-h-[85vh] flex flex-col bg-white p-0 gap-0`,showCloseButton:!1,children:[(0,G.jsxs)(`div`,{className:`px-4 py-2.5 border-b border-gray-200 shrink-0 flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-sm font-mono text-gray-900 truncate flex-1`,children:e}),(0,G.jsx)(`button`,{onClick:r,className:`text-gray-400 hover:text-gray-700 text-sm leading-none`,children:`✕`})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:n?(0,G.jsxs)(`div`,{className:`flex items-center justify-center py-16 text-gray-400 gap-2`,children:[(0,G.jsx)(Te,{className:`animate-spin`,size:16}),(0,G.jsx)(`span`,{className:`text-sm`,children:`loading diff...`})]}):i?(0,G.jsx)(`div`,{className:`text-xs font-mono leading-5`,children:i.hunks.map((e,t)=>(0,G.jsxs)(`div`,{className:`border-b border-gray-100 last:border-b-0`,children:[(0,G.jsx)(`div`,{className:`px-4 py-1 bg-blue-50/60 text-blue-700 border-b border-blue-100 sticky top-0`,children:e.header}),e.lines.map((e,t)=>{let n=e.type===`add`,r=e.type===`del`;return(0,G.jsxs)(`div`,{className:`flex `+(n?`bg-emerald-50`:r?`bg-red-50`:``),children:[(0,G.jsx)(`span`,{className:`w-14 shrink-0 text-right pr-3 py-px text-gray-300 select-none border-r border-gray-200 bg-gray-50`,children:e.oldNum??``}),(0,G.jsx)(`span`,{className:`w-14 shrink-0 text-right pr-3 py-px select-none border-r border-gray-200 `+(n?`bg-emerald-100/70 text-emerald-700`:r?`bg-red-100/70 text-red-500`:`text-gray-300 bg-gray-50`),children:e.newNum??``}),(0,G.jsxs)(`span`,{className:`pl-3 py-px whitespace-pre-wrap break-all flex-1 `+(n?`text-emerald-800`:r?`text-red-700`:`text-gray-700`),children:[(0,G.jsx)(`span`,{className:`select-none`,children:n?`+`:r?`−`:` `}),e.text]})]},t)})]},t))}):(0,G.jsx)(`div`,{className:`py-16 text-center text-sm text-gray-400`,children:`empty diff`})})]})})}var zW={A:{label:`A`,color:`text-emerald-600`},M:{label:`M`,color:`text-amber-600`},D:{label:`D`,color:`text-red-600`},R:{label:`R`,color:`text-purple-600`},"?":{label:`?`,color:`text-gray-400`}};function BW({loopId:e,onClose:t,onPickFile:n}){let[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!0),[l,u]=(0,_.useState)(!0),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)(``),[h,g]=(0,_.useState)(``),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)([]),[w,T]=(0,_.useState)(!1),[E,D]=(0,_.useState)(!0),O=(0,_.useCallback)(async()=>{o(!0),f(null);try{i(await vh(e))}catch{f(`Failed to load git status`)}finally{o(!1)}},[e]),k=(0,_.useCallback)(async()=>{T(!0);try{C(await Ch(e,50))}catch{}finally{T(!1)}},[e]);(0,_.useEffect)(()=>{O(),k()},[O,k]);let A=async()=>{r?.unstaged.length&&await bh(e,r.unstaged.map(e=>e.path))&&O()},j=async()=>{r?.staged.length&&await bh(e,r.staged.map(e=>e.path),!0)&&O()},M=async t=>{await bh(e,[t])&&O()},N=async t=>{await bh(e,[t],!0)&&O()},P=async t=>{await xh(e,t)&&O()},F=async()=>{if(!h.trim())return;y(!0),x(null);let t=await Sh(e,h.trim());y(!1),t.ok?(g(``),O(),k()):x(t.error??`Commit failed`)},I=p.trim().toLowerCase(),L=r?r.unstaged.filter(e=>!I||e.path.toLowerCase().includes(I)):[],R=r?r.staged.filter(e=>!I||e.path.toLowerCase().includes(I)):[],z=!r||r.unstaged.length===0&&r.staged.length===0;return(0,G.jsxs)(`aside`,{className:`w-full h-full min-w-0 bg-white flex flex-col`,children:[(0,G.jsxs)(`header`,{className:`px-3 h-8 shrink-0 border-b border-gray-200 flex items-center gap-1 text-[11px] text-gray-500`,children:[(0,G.jsx)(`span`,{className:`tracking-wide`,children:`Git Changes`}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)(`button`,{onClick:()=>{O(),k()},className:`text-gray-500 hover:text-gray-900 px-1 rounded hover:bg-gray-100`,title:`refresh`,children:(0,G.jsx)(He,{size:13,className:a||w?`animate-spin`:``})}),(0,G.jsx)(`button`,{className:`text-gray-500 hover:text-gray-900 px-1 rounded hover:bg-gray-100`,onClick:t,title:`close`,children:`✕`})]}),(0,G.jsxs)(`div`,{className:`px-3 py-2 border-b border-gray-100`,children:[(0,G.jsx)(`textarea`,{placeholder:`Commit message...`,value:h,onChange:e=>{g(e.target.value),x(null)},rows:2,className:`w-full px-2 py-1.5 text-[12px] border border-gray-200 rounded outline-none focus:border-gray-300 placeholder:text-gray-300 resize-none mb-1.5`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`button`,{onClick:F,disabled:v||!h.trim(),className:`flex-1 flex items-center justify-center gap-1 px-2 py-1 text-[11px] rounded bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-40 disabled:cursor-not-allowed`,children:[(0,G.jsx)(_e,{size:12}),v?`Committing...`:`Commit`]}),r&&r.staged.length>0&&(0,G.jsxs)(`span`,{className:`text-[10px] text-gray-400`,children:[r.staged.length,` staged`]})]}),b&&(0,G.jsx)(`div`,{className:`mt-1 text-[10px] text-red-500`,children:b})]}),(0,G.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-100`,children:(0,G.jsx)(`input`,{type:`text`,placeholder:`Filter files...`,value:p,onChange:e=>m(e.target.value),className:`w-full px-2 py-1 text-[12px] border border-gray-200 rounded outline-none focus:border-gray-300 placeholder:text-gray-300`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-auto text-[13px]`,children:[(0,G.jsxs)(`div`,{className:`overflow-auto py-2`,children:[a&&!r&&(0,G.jsx)(`div`,{className:`px-5 py-4 text-[12px] text-gray-400 italic`,children:`loading git status...`}),d&&(0,G.jsx)(`div`,{className:`px-5 py-4 text-[12px] text-red-500`,children:d}),z&&!a&&(0,G.jsx)(`div`,{className:`px-5 py-4 text-[12px] text-gray-400 italic`,children:`no changes`}),L.length>0&&(0,G.jsx)(HW,{title:`Unstaged Changes`,count:L.length,open:s,onToggle:()=>c(e=>!e),bulkAction:{label:`Stage all`,icon:(0,G.jsx)(ze,{size:12}),onClick:A},children:L.map(t=>(0,G.jsx)(UW,{file:t,loopId:e,staged:!1,onStage:()=>M(t.path),onUnstage:()=>N(t.path),onDiscard:()=>P(t.path),onEdit:e=>n(e),onRefresh:O},t.path))}),R.length>0&&(0,G.jsx)(HW,{title:`Staged Changes`,count:R.length,open:l,onToggle:()=>u(e=>!e),bulkAction:{label:`Unstage all`,icon:(0,G.jsx)(je,{size:12}),onClick:j},children:R.map(t=>(0,G.jsx)(UW,{file:t,loopId:e,staged:!0,onStage:()=>M(t.path),onUnstage:()=>N(t.path),onDiscard:()=>P(t.path),onEdit:e=>n(e),onRefresh:O},t.path))})]}),(0,G.jsxs)(`div`,{className:`border-t border-gray-200`,children:[(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:()=>D(e=>!e),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&D(e=>!e)},className:`w-full px-3 py-1.5 flex items-center gap-1.5 hover:bg-gray-50 text-left cursor-pointer select-none`,children:[(0,G.jsx)(`span`,{className:`text-gray-500`,children:E?`▾`:`▸`}),(0,G.jsx)(ge,{size:12,className:`text-gray-500`}),(0,G.jsx)(`span`,{className:`text-[11px] uppercase tracking-wide text-gray-500`,children:`History`}),(0,G.jsxs)(`span`,{className:`text-[11px] text-gray-400`,children:[`(`,S.length,`)`]})]}),E&&(0,G.jsx)(`div`,{className:`px-2 pb-2 max-h-64 overflow-auto`,children:w?(0,G.jsx)(`div`,{className:`px-3 py-3 text-[11px] text-gray-400 italic`,children:`loading history...`}):S.length===0?(0,G.jsx)(`div`,{className:`px-3 py-3 text-[11px] text-gray-400 italic`,children:`no commits`}):(0,G.jsx)(VW,{commits:S})})]})]})]})}function VW({commits:e}){let t=[`bg-blue-500`,`bg-emerald-500`,`bg-purple-500`,`bg-amber-500`,`bg-pink-500`,`bg-cyan-500`],n=new Map,r=0,i=e=>(n.has(e)||(n.set(e,t[r%t.length]),r++),n.get(e));return(0,G.jsx)(`div`,{className:`space-y-0`,children:e.map((t,n)=>{let r=t.branch??t.branches[0]??null,a=r?i(r):`bg-gray-400`,o=n===0,s=new Date(t.date).toLocaleDateString(void 0,{month:`short`,day:`numeric`}),c=new Date(t.date).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});return(0,G.jsxs)(`div`,{className:`group/graph-row flex items-start gap-2 py-0.5 px-1.5 rounded hover:bg-gray-100 cursor-default text-[11px]`,title:`${t.subject}\n${t.author} · ${s} ${c}`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col items-center shrink-0`,children:[(0,G.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-full ${a} ring-2 ring-white ${o?`ring-blue-300`:``}`}),n<e.length-1&&(0,G.jsx)(`div`,{className:`w-0.5 h-10 ${a} opacity-10`})]}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-gray-400 truncate`,children:t.shortHash}),o&&(0,G.jsx)(`span`,{className:`text-[9px] px-1 py-0 rounded bg-blue-100 text-blue-700 font-medium`,children:`HEAD`}),t.branches.slice(0,2).map(e=>(0,G.jsx)(`span`,{className:`text-[9px] px-1 py-0 rounded bg-emerald-100 text-emerald-700 font-medium truncate max-w-[60px]`,children:e},e)),t.tags.map(e=>(0,G.jsx)(`span`,{className:`text-[9px] px-1 py-0 rounded bg-purple-100 text-purple-700 font-medium`,children:e},e))]}),(0,G.jsx)(`div`,{className:`text-gray-700 truncate`,children:t.subject}),(0,G.jsxs)(`div`,{className:`text-gray-400 text-[10px]`,children:[t.author,` · `,s]})]})]},t.hash)})})}function HW({title:e,count:t,open:n,onToggle:r,bulkAction:i,children:a}){return(0,G.jsxs)(`div`,{className:`mb-2`,children:[(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:r,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&r()},className:`w-full px-3 py-1.5 flex items-center gap-1.5 hover:bg-gray-50 text-left group/section cursor-pointer select-none`,children:[(0,G.jsx)(`span`,{className:`text-gray-500`,children:n?`▾`:`▸`}),(0,G.jsx)(`span`,{className:`text-[11px] uppercase tracking-wide text-gray-500`,children:e}),(0,G.jsxs)(`span`,{className:`text-[11px] text-gray-400`,children:[`(`,t,`)`]}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),i.onClick()},className:`opacity-100 sm:opacity-0 sm:group-hover/section:opacity-100 transition-opacity px-1 py-0.5 rounded hover:bg-gray-200 text-gray-500 hover:text-gray-900 flex items-center gap-0.5`,title:i.label,children:i.icon})]}),n&&(0,G.jsx)(`div`,{children:a})]})}function UW({file:e,loopId:t,staged:n,onStage:r,onUnstage:i,onDiscard:a,onEdit:o,onRefresh:s}){let[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)(null),y=(0,_.useRef)(null);(0,_.useEffect)(()=>{let e=e=>{y.current&&!y.current.contains(e.target)&&v(null)};if(g)return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[g]);let b=async()=>{e.isBinary||(l(!0),u===null&&(p(!0),d(await yh(t,e.path,n)??``),p(!1)))},x=e=>{e.preventDefault(),v({x:e.clientX,y:e.clientY})},S=`workdir/${e.path}`,C=[{label:`Open in Editor`,icon:(0,G.jsx)(Re,{size:12}),onClick:()=>{o(S),v(null)}},{label:`View Diff`,icon:(0,G.jsx)(We,{size:12}),onClick:()=>{b(),v(null)}},{separator:!0,label:``,onClick:()=>{}},n?{label:`Unstage`,icon:(0,G.jsx)(je,{size:12}),onClick:()=>{i(),v(null)}}:{label:`Stage`,icon:(0,G.jsx)(ze,{size:12}),onClick:()=>{r(),v(null)}},!n&&{label:`Discard Changes`,icon:(0,G.jsx)(it,{size:12}),onClick:()=>{h(!0),v(null)},danger:!0}].filter(Boolean),w=zW[e.status]??{label:e.status,color:`text-gray-500`},T=e.path.lastIndexOf(`/`),E=T>=0?e.path.slice(T+1):e.path,D=T>=0?e.path.slice(0,T+1):null;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`group/row relative flex items-center gap-2 px-3 py-1.5 hover:bg-gray-50`,onContextMenu:x,children:[(0,G.jsx)(`span`,{className:`w-5 text-center text-[11px] font-mono font-semibold ${w.color}`,children:w.label}),(0,G.jsxs)(`span`,{className:`flex-1 min-w-0 truncate text-[13px] font-mono`,children:[(0,G.jsx)(`span`,{className:`text-gray-900`,children:E}),D&&(0,G.jsx)(`span`,{className:`text-gray-400 ml-0.5`,children:D})]}),!e.isBinary&&(e.additions>0||e.deletions>0)&&(0,G.jsxs)(`span`,{className:`text-[11px] font-mono flex items-center gap-0.5 shrink-0`,children:[(0,G.jsxs)(`span`,{className:`text-emerald-600`,children:[`+`,e.additions]}),(0,G.jsxs)(`span`,{className:`text-red-500`,children:[`-`,e.deletions]})]}),(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 opacity-100 sm:opacity-0 sm:group-hover/row:opacity-100 transition-opacity shrink-0`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>o(S),className:`w-5 h-5 flex items-center justify-center text-gray-400 hover:text-blue-600 rounded`,title:`edit file`,children:(0,G.jsx)(Re,{size:13})}),n&&(0,G.jsx)(`button`,{type:`button`,onClick:b,className:`w-5 h-5 flex items-center justify-center text-gray-400 hover:text-gray-700 rounded`,title:`view diff`,disabled:e.isBinary,children:(0,G.jsx)(We,{size:13})}),n?(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`w-5 h-5 flex items-center justify-center text-gray-400 hover:text-amber-600 rounded`,title:`unstage`,children:(0,G.jsx)(je,{size:13})}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>h(!0),className:`w-5 h-5 flex items-center justify-center text-gray-400 hover:text-red-500 rounded`,title:`discard changes`,children:(0,G.jsx)(it,{size:13})}),(0,G.jsx)(`button`,{type:`button`,onClick:r,className:`w-5 h-5 flex items-center justify-center text-gray-400 hover:text-emerald-600 rounded`,title:`stage`,children:(0,G.jsx)(ze,{size:13})})]})]})]}),g&&(0,G.jsx)(`div`,{ref:y,className:`fixed z-50 min-w-[160px] py-1 bg-white border border-gray-200 rounded-md shadow-lg text-[12px]`,style:{left:g.x,top:g.y},children:C.map((e,t)=>e.separator?(0,G.jsx)(`div`,{className:`my-1 border-t border-gray-100`},t):(0,G.jsxs)(`button`,{onClick:e.onClick,className:`w-full flex items-center gap-2 px-3 py-1.5 text-left hover:bg-gray-100 ${e.danger?`text-red-600`:`text-gray-700`}`,children:[e.icon,(0,G.jsx)(`span`,{children:e.label})]},t))}),c&&(0,G.jsx)(RW,{filePath:e.path,diff:u,loading:f,onClose:()=>l(!1)}),m&&(0,G.jsx)(Tg,{open:!0,onOpenChange:e=>{e||h(!1)},children:(0,G.jsxs)(Og,{className:`sm:max-w-sm bg-white p-5 gap-4`,showCloseButton:!1,children:[(0,G.jsx)(kg,{children:(0,G.jsx)(Ag,{className:`text-sm`,children:`Discard changes`})}),(0,G.jsx)(`p`,{className:`text-[13px] text-gray-600 break-all font-mono`,children:e.path}),(0,G.jsx)(`p`,{className:`text-[12px] text-gray-500`,children:e.status===`?`?`This file is untracked and will be deleted.`:`This will permanently discard all changes to this file. This action cannot be undone.`}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,G.jsx)(`button`,{onClick:()=>h(!1),className:`px-3 py-1.5 text-xs rounded bg-gray-100 text-gray-700 hover:bg-gray-200`,children:`Cancel`}),(0,G.jsx)(`button`,{onClick:()=>{h(!1),a()},className:`px-3 py-1.5 text-xs rounded bg-red-600 text-white hover:bg-red-700`,children:`Discard`})]})]})})]})}function WW(e){return e.shareMode===`ephemeral`?`ephemeral`:e.shareExternalPort?`direct`:`standard`}function GW({loop:e,open:t,onClose:n,onSaved:r}){let[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(e.shareEnabled??!1),[c,l]=(0,_.useState)(e.shareMode===`ephemeral`?`ephemeral`:e.shareExternalPort?`direct`:e.shareMode??`static`),[u,d]=(0,_.useState)(e.shareAlias??``),[f,p]=(0,_.useState)(e.sharePort??3e3),[m,h]=(0,_.useState)(e.shareExternalPort??1e4),[g,v]=(0,_.useState)(e.shareProtocol??`tcp`),[y,b]=(0,_.useState)(null),[x,S]=(0,_.useState)(``),[C,w]=(0,_.useState)(!1),[T,E]=(0,_.useState)(!1),[D,O]=(0,_.useState)(!1),[k,A]=(0,_.useState)(``),[j,M]=(0,_.useState)(!1),[N,F]=(0,_.useState)(``),[I,L]=(0,_.useState)(``),[z,B]=(0,_.useState)(WW(e)),[V,H]=(0,_.useState)(null),U=e.id.slice(0,8),W=!!(i&&i.serveEnabled),te=!!(i&&i.serveDynamicEnabled),ne=!!(i&&i.serveEphemeralEnabled),re=[W,te,ne].filter(Boolean).length>1,ie=W&&!te&&!ne,ae=!W&&te&&!ne,oe=!W&&!te&≠(0,_.useEffect)(()=>{t&&(Lh().then(a),s(e.shareEnabled??!1),l(e.shareMode===`ephemeral`?`ephemeral`:e.shareExternalPort?`direct`:e.shareMode??`static`),d(e.shareAlias??``),p(e.sharePort??3e3),h(e.shareExternalPort??1e4),v(e.shareProtocol??`tcp`),B(WW(e)),b(null),S(``),A(``),H(null))},[t,e]),(0,_.useEffect)(()=>{if(!t||!(oe||re&&z===`ephemeral`)||!e.shareEnabled||e.shareMode!==`ephemeral`)return;let n=!1,r=async()=>{let t=await Rh(e.id);n||H(t.port)};r();let i=setInterval(r,3e3);return()=>{n=!0,clearInterval(i)}},[t,z,oe,re,e.id,e.shareEnabled,e.shareMode]),(0,_.useEffect)(()=>{!t||!i||i.serveDynamicEnabled&&(e.shareEnabled&&e.shareExternalPort||!e.shareEnabled&&!e.shareExternalPort&&Bh().then(e=>{e.port&&h(e.port)}))},[t,i,e.shareEnabled,e.shareExternalPort]),(0,_.useEffect)(()=>{t&&Hh(U,e.id).then(e=>{e.available?O(!1):(O(!0),S(`ID "${U}" is already in use. Please set an alias.`))})},[t,U,e.id]),(0,_.useEffect)(()=>{if(!u||!t){b(null),S(``);return}let n=setTimeout(async()=>{let t=await Hh(u,e.id);b(t.available),S(t.reason??``)},300);return()=>clearTimeout(n)},[u,t,e.id]);let se=u||U,ce=i?.https?`https`:`http`,le=i?.withPort?`:${i.displayPort}`:``,ue=i?`${ce}://${se}${i.baseUrl}${le}`:``,de=i?.serveDynamicDomain||i?.ip||`<host-ip>`,fe=g===`static`?`http://${de}:${m}`:`tcp://${de}:${m}`,pe=i?.serveEphemeralDomain||i?.ip||`<host-ip>`,me=V?`${g===`udp`?`udp`:`tcp`}://${pe}:${V}`:`(no active port — save & wait for container restart)`,he=ae||re&&z===`direct`&&te&&!oe,ge=oe||re&&z===`ephemeral`,_e=ge?me:he?fe:ue;(0,_.useEffect)(()=>{if(!t||!he)return;let n=setTimeout(async()=>{M(!0);let t=await Vh(m,e.id);M(!1),t.available?A(``):A(t.reason??`Port unavailable`)},400);return()=>clearTimeout(n)},[m,t,c,e.id]);let ye=async()=>{if(E(!0),he){let t=await Vh(m,e.id);if(!t.available){A(t.reason??`Port unavailable`),E(!1);return}}let t={shareEnabled:o};o?ge?(t.shareMode=`ephemeral`,t.sharePort=f,t.shareProtocol=g===`static`?`tcp`:g,t.shareAlias=void 0,t.shareExternalPort=void 0):he?(t.shareMode=`port`,t.sharePort=f,t.shareExternalPort=m,t.shareProtocol=g,t.shareAlias=void 0):(t.shareMode=c,t.shareAlias=u.trim()||void 0,c===`port`&&(t.sharePort=f),t.shareExternalPort=void 0,t.shareProtocol=void 0):(t.shareMode=void 0,t.shareAlias=void 0,t.sharePort=void 0);let i=await fetch(`/api/loops/${e.id}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(E(!1),i.ok)F(`Saved`),await r?.(),setTimeout(()=>{F(``),n()},800);else try{L((await i.json()).error??`Save failed (${i.status})`)}catch{L(`Save failed (${i.status})`)}},be=async()=>{try{await navigator.clipboard.writeText(_e),w(!0),setTimeout(()=>w(!1),1500)}catch{window.prompt(`Copy this URL:`,_e)}},xe=!T&&!k&&!j&&(ge?f>=1&&f<=65535:(!he||m>=1024)&&(!he||f>=1||g===`static`)&&(he||c!==`port`||!D||u.trim().length>0)&&(he||c!==`port`||f>=1024));return i?(0,G.jsx)(Tg,{open:t,onOpenChange:e=>{e||n()},children:(0,G.jsxs)(Og,{className:`sm:max-w-md bg-white max-h-[85vh] overflow-y-auto`,children:[(0,G.jsxs)(kg,{children:[(0,G.jsxs)(Ag,{className:`flex items-center gap-2 text-sm`,children:[(0,G.jsx)(ve,{size:16}),`Share Artifact`]}),(0,G.jsx)(jg,{className:`sr-only`,children:`Share this artifact via a public URL.`})]}),(0,G.jsxs)(`div`,{className:`space-y-4 text-[13px]`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-sm text-gray-700`,children:`Enable sharing`}),(0,G.jsx)(`button`,{onClick:()=>s(!o),className:`w-10 h-5 rounded-full transition-colors ${o?`bg-blue-600`:`bg-gray-300`}`,children:(0,G.jsx)(`div`,{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${o?`translate-x-5`:`translate-x-0.5`}`})})]}),o&&(0,G.jsxs)(G.Fragment,{children:[re&&(0,G.jsxs)(`div`,{className:`flex gap-1.5 border-b border-gray-200 pb-2`,children:[W&&(0,G.jsx)(`button`,{onClick:()=>{B(`standard`),l(`static`)},className:`px-3 py-1 text-xs rounded-t ${z===`standard`?`bg-blue-50 text-blue-700 font-medium`:`text-gray-500 hover:text-gray-700`}`,children:`Subdomain`}),te&&(0,G.jsx)(`button`,{onClick:()=>{B(`direct`),l(`direct`)},className:`px-3 py-1 text-xs rounded-t ${z===`direct`?`bg-blue-50 text-blue-700 font-medium`:`text-gray-500 hover:text-gray-700`}`,children:`Direct Port`}),ne&&(0,G.jsx)(`button`,{onClick:()=>{B(`ephemeral`),l(`ephemeral`)},className:`px-3 py-1 text-xs rounded-t ${z===`ephemeral`?`bg-blue-50 text-blue-700 font-medium`:`text-gray-500 hover:text-gray-700`}`,children:`Ephemeral`})]}),(ie||re&&z===`standard`)&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[11px] text-gray-500 uppercase tracking-wider`,children:`Share mode`}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5 mt-1`,children:[(0,G.jsx)(`button`,{onClick:()=>l(`static`),className:`px-2 py-1.5 text-xs rounded border ${c===`static`?`bg-blue-50 border-blue-300 text-blue-700`:`border-gray-200 text-gray-600`}`,children:`Static files`}),(0,G.jsx)(`button`,{onClick:()=>l(`port`),className:`px-2 py-1.5 text-xs rounded border ${c===`port`?`bg-blue-50 border-blue-300 text-blue-700`:`border-gray-200 text-gray-600`}`,children:`Port proxy`})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`text-[11px] text-gray-500 uppercase tracking-wider`,children:[`Alias `,D?(0,G.jsx)(`span`,{className:`text-red-500`,children:`(required)`}):`(optional)`]}),(0,G.jsx)(`input`,{value:u,onChange:e=>d(e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,``)),className:`w-full mt-1 px-2 py-1.5 text-sm border rounded outline-none focus:border-gray-300 ${D?`border-red-300 bg-red-50`:`border-gray-200`}`,placeholder:D?`Set an alias to resolve conflict`:`my-project`}),D&&(0,G.jsxs)(`span`,{className:`text-[11px] text-red-500 mt-0.5 flex items-center gap-1`,children:[(0,G.jsx)(R,{size:11}),` `,x||`ID "${U}" is already in use`]}),!D&&y===!0&&(0,G.jsx)(`span`,{className:`text-[11px] text-emerald-600 mt-0.5`,children:`Available`}),!D&&y===!1&&(0,G.jsxs)(`span`,{className:`text-[11px] text-red-500 mt-0.5 flex items-center gap-1`,children:[(0,G.jsx)(R,{size:11}),` `,x||`Already in use`]})]}),c===`port`&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[11px] text-gray-500 uppercase tracking-wider`,children:`Port (1024-65535)`}),(0,G.jsx)(`input`,{type:`number`,min:1024,max:65535,value:f,onChange:e=>p(parseInt(e.target.value,10)||3e3),className:`w-full mt-1 px-2 py-1.5 text-sm border border-gray-200 rounded outline-none focus:border-gray-300`})]})]}),ge&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[11px] text-gray-500 uppercase tracking-wider`,children:`Container port`}),(0,G.jsx)(`input`,{type:`number`,min:1,max:65535,value:f,onChange:e=>p(parseInt(e.target.value,10)||3e3),className:`w-full mt-1 px-2 py-1.5 text-sm border border-gray-200 rounded outline-none focus:border-gray-300`}),(0,G.jsx)(`p`,{className:`text-[10px] text-gray-400 mt-0.5`,children:`The port your app listens on inside the sandbox`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[11px] text-gray-500 uppercase tracking-wider`,children:`Protocol`}),(0,G.jsxs)(`div`,{className:`flex gap-1.5 mt-1`,children:[(0,G.jsx)(`button`,{onClick:()=>v(`tcp`),className:`flex-1 px-2 py-1.5 text-xs rounded border ${g===`tcp`?`bg-blue-50 border-blue-300 text-blue-700`:`border-gray-200 text-gray-600`}`,children:`TCP`}),(0,G.jsx)(`button`,{onClick:()=>v(`udp`),className:`flex-1 px-2 py-1.5 text-xs rounded border ${g===`udp`?`bg-blue-50 border-blue-300 text-blue-700`:`border-gray-200 text-gray-600`}`,children:`UDP`})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`text-[11px] text-gray-500 uppercase tracking-wider flex items-center gap-1.5`,children:[`Current host port`,(0,G.jsx)(Ve,{size:10,className:`text-gray-300`})]}),(0,G.jsx)(`div`,{className:`mt-1 px-2 py-1.5 text-sm bg-gray-50 rounded text-gray-700`,children:V==null?(0,G.jsx)(`span`,{className:`text-gray-400 text-xs`,children:e.shareEnabled&&e.shareMode===`ephemeral`?`(container starting / not running)`:`(save to start — port assigned by kernel on restart)`}):(0,G.jsx)(`span`,{className:`font-mono`,children:V})}),(0,G.jsxs)(`p`,{className:`text-[10px] text-amber-600 mt-1 flex items-center gap-1`,children:[(0,G.jsx)(R,{size:10}),` Changes on every loop restart. Saving also restarts the container.`]})]})]}),(ae||re&&z===`direct`&&!ge)&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[11px] text-gray-500 uppercase tracking-wider`,children:`External port`}),(0,G.jsxs)(`div`,{className:`flex gap-1.5 mt-1`,children:[(0,G.jsx)(`input`,{type:`number`,min:1024,max:65535,value:m,onChange:e=>h(parseInt(e.target.value,10)||1e4),className:`flex-1 px-2 py-1.5 text-sm border border-gray-200 rounded outline-none focus:border-gray-300`,placeholder:`10000`}),(0,G.jsx)(`button`,{onClick:async()=>{let e=await Bh();e.port&&h(e.port)},className:`px-2 py-1.5 rounded border border-gray-200 hover:bg-gray-100 text-gray-500`,title:`Pick a random available port`,children:(0,G.jsx)(Ye,{size:14})})]}),(0,G.jsx)(`p`,{className:`text-[10px] text-gray-400 mt-0.5`,children:`The public port clients connect to`}),j&&(0,G.jsx)(`span`,{className:`text-[11px] text-gray-400 mt-0.5`,children:`Checking availability…`}),k&&(0,G.jsxs)(`span`,{className:`text-[11px] text-red-500 mt-0.5 flex items-center gap-1`,children:[(0,G.jsx)(R,{size:11}),` `,k]}),!j&&!k&&(0,G.jsx)(`span`,{className:`text-[11px] text-emerald-600 mt-0.5`,children:`Available`})]}),g!==`static`&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[11px] text-gray-500 uppercase tracking-wider`,children:`Container port`}),(0,G.jsx)(`input`,{type:`number`,min:1,max:65535,value:f,onChange:e=>p(parseInt(e.target.value,10)||3e3),className:`w-full mt-1 px-2 py-1.5 text-sm border border-gray-200 rounded outline-none focus:border-gray-300`}),(0,G.jsx)(`p`,{className:`text-[10px] text-gray-400 mt-0.5`,children:`The port your app listens on inside the sandbox`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[11px] text-gray-500 uppercase tracking-wider`,children:`Protocol`}),(0,G.jsxs)(`div`,{className:`flex gap-1.5 mt-1`,children:[(0,G.jsx)(`button`,{onClick:()=>v(`tcp`),className:`flex-1 px-2 py-1.5 text-xs rounded border ${g===`tcp`?`bg-blue-50 border-blue-300 text-blue-700`:`border-gray-200 text-gray-600`}`,children:`TCP`}),i.serveDynamicUdpEnabled&&(0,G.jsx)(`button`,{onClick:()=>v(`udp`),className:`flex-1 px-2 py-1.5 text-xs rounded border ${g===`udp`?`bg-blue-50 border-blue-300 text-blue-700`:`border-gray-200 text-gray-600`}`,children:`UDP`}),i.serveDynamicStaticEnabled&&(0,G.jsx)(`button`,{onClick:()=>v(`static`),className:`flex-1 px-2 py-1.5 text-xs rounded border ${g===`static`?`bg-blue-50 border-blue-300 text-blue-700`:`border-gray-200 text-gray-600`}`,children:`Static`})]})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`text-[11px] text-gray-500 uppercase tracking-wider`,children:`Access URL`}),(0,G.jsxs)(`div`,{className:`flex gap-2 mt-1`,children:[(0,G.jsx)(`code`,{className:`flex-1 px-2 py-1.5 text-xs bg-gray-50 rounded text-gray-700 truncate`,children:_e}),(0,G.jsx)(`button`,{onClick:be,className:`px-2 py-1.5 rounded hover:bg-gray-100 text-gray-500`,title:`Copy URL`,children:C?(0,G.jsx)(P,{size:14,className:`text-emerald-600`}):(0,G.jsx)(ee,{size:14})})]}),(0,G.jsx)(`p`,{className:`text-[10px] text-gray-400 mt-1`,children:he?`Direct TCP/UDP access — no domain needed`:`Domain suffix configured in Settings → Workspace → Workspace Serve`})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-2 pt-2`,children:[I&&(0,G.jsx)(`span`,{className:`text-xs text-red-500`,children:I}),N&&(0,G.jsxs)(`span`,{className:`text-xs text-emerald-600 flex items-center gap-1`,children:[(0,G.jsx)(P,{size:12}),` `,N]}),(0,G.jsx)(`button`,{onClick:n,className:`px-3 py-1.5 text-xs rounded bg-gray-100 text-gray-700 hover:bg-gray-200`,children:`Cancel`}),(0,G.jsx)(`button`,{onClick:ye,disabled:!xe,className:`px-3 py-1.5 text-xs rounded bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-40`,children:T?`Saving...`:`Save`})]})]})]})}):null}var KW=(0,_.lazy)(()=>_t(()=>import(`./Editor-BctC10Up.js`).then(e=>({default:e.Editor})),__vite__mapDeps([0,1,2,3]))),qW=(0,_.lazy)(()=>_t(()=>import(`./Terminal-trnCVajY.js`).then(e=>({default:e.Terminal})),__vite__mapDeps([4,1,5])));function JW(){let{id:e}=Wn(),t=vg();if(!e)return(0,G.jsx)(mr,{to:`/loop`,replace:!0});if(!t.currentUser)return(0,G.jsx)(SW,{});let n=t.loops.find(t=>t.id===e);return t.loopsLoading?null:n?(0,G.jsxs)(`div`,{className:`h-full w-full flex min-h-0`,children:[(0,G.jsx)(YW,{currentId:e}),(0,G.jsx)(XW,{meta:n},e)]}):(0,G.jsx)(mr,{to:`/loop`,replace:!0})}function YW({currentId:e}){let t=vg(),n=Bn(),[r,i]=(0,_.useState)(`mine`),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(()=>localStorage.getItem(`loopat:loopsList:collapsed`)===`1`),l=rU(),u=EW((0,_.useMemo)(()=>t.loops.map(e=>e.id),[t.loops]));(0,_.useEffect)(()=>{let t=u[e];t?.status===`Done`&&t?.viewed===!1&&lm(e)},[u,e]);let d=t.currentUser?.id,f=(0,_.useMemo)(()=>{let e=a.toLowerCase().trim();return t.loops.filter(t=>{let n=t.driver??t.createdBy;return!(r===`mine`&&t.createdBy!==d&&n!==d||r===`rfd`&&!t.rfdRequestedAt||e&&!t.title.toLowerCase().includes(e)&&!t.id.toLowerCase().includes(e))})},[t.loops,r,d,a]),p=e=>{c(e),localStorage.setItem(`loopat:loopsList:collapsed`,e?`1`:`0`)},m=(0,G.jsxs)(`aside`,{className:`w-60 shrink-0 border-r border-gray-200 bg-white flex flex-col h-full`,children:[(0,G.jsxs)(`div`,{className:`px-2 pt-1.5 pb-1 space-y-1 border-b border-gray-200`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[[`mine`,`all`,`rfd`].map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:r===e?e===`rfd`?`px-2 h-6 rounded text-[11px] flex items-center gap-1 bg-amber-600 text-white`:`px-2 h-6 rounded text-[11px] bg-gray-900 text-white`:e===`rfd`?`px-2 h-6 rounded text-[11px] flex items-center gap-1 text-amber-700 hover:bg-amber-50`:`px-2 h-6 rounded text-[11px] text-gray-500 hover:bg-gray-100`,children:e===`mine`?`mine`:e===`all`?`all`:`RFD`},e)),(0,G.jsx)(`span`,{className:`text-[11px] text-gray-400 ml-auto pr-1`,children:f.length}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t.setShowArchived(!t.showArchived),className:t.showArchived?`w-6 h-6 flex items-center justify-center text-gray-700 bg-gray-100 rounded`:`w-6 h-6 flex items-center justify-center text-gray-400 hover:text-gray-700 hover:bg-gray-100 rounded`,title:t.showArchived?`hide archived`:`show archived`,children:(0,G.jsx)(w,{size:13})}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>p(!0),className:`w-6 h-6 flex items-center justify-center text-gray-400 hover:text-gray-700 hover:bg-gray-100 rounded`,title:`collapse sidebar`,children:(0,G.jsx)(Fe,{size:14})})]}),(0,G.jsx)(`input`,{type:`text`,name:`loop-search`,value:a,onChange:e=>o(e.target.value),placeholder:`search loops…`,className:`w-full h-6 rounded px-1.5 text-[11px] bg-gray-100 border border-transparent focus:border-gray-300 focus:bg-white focus:outline-none text-gray-600 placeholder-gray-400`})]}),(0,G.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-auto py-2`,children:[f.map(r=>{let i=e===r.id,a=r.archived===!0,o=t.currentUser?.id===r.createdBy,s=u[r.id],c=s?.status===`Done`||s?.status===`Ready`,d=s!==void 0&&!c;return(0,G.jsxs)(`div`,{className:`group/row relative flex items-stretch `+(i?`bg-gray-100`:`hover:bg-gray-50`),children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{lm(r.id),n(`/loop/${r.id}`),l&&p(!0)},className:`flex-1 min-w-0 px-3 py-1.5 flex items-center gap-2 text-left `+(a?`opacity-60`:``),children:[(0,G.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 mt-0.5 `+(a?`bg-gray-400`:d?`bg-blue-500 animate-pulse`:c&&!s?.viewed?`bg-yellow-500`:c?`bg-emerald-500`:`bg-gray-300`)}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`text-[13px] text-gray-900 truncate flex items-center gap-1.5`,children:[a&&(0,G.jsx)(w,{size:10,className:`text-gray-400 shrink-0`}),r.rfdRequestedAt&&(0,G.jsx)(`span`,{className:`shrink-0 text-[9px] px-1 rounded bg-amber-100 text-amber-800 font-medium tracking-wide`,children:`RFD`}),(0,G.jsx)(`span`,{className:`truncate`,children:r.title}),s&&(0,G.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium `+(d?`text-blue-500`:c?`text-emerald-500`:`text-gray-400`),children:s.status})]}),(0,G.jsxs)(`div`,{className:`text-[11px] text-gray-500 truncate flex items-center gap-1 mt-0.5`,children:[(0,G.jsx)(`span`,{children:r.driver??r.createdBy}),(0,G.jsx)(`span`,{className:`text-gray-300`,children:`·`}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-gray-400`,children:r.id.slice(0,6)})]})]})]}),(0,G.jsx)(`button`,{type:`button`,disabled:!o,onClick:e=>{e.stopPropagation(),o&&t.setLoopArchived(r.id,!a)},className:(l?`opacity-100`:`opacity-0 group-hover/row:opacity-100`)+` transition-opacity w-7 flex items-center justify-center `+(o?`text-gray-400 hover:text-gray-700`:`text-gray-300 cursor-not-allowed`),title:o?a?`unarchive`:`archive (hide + read-only)`:`only ${r.createdBy} can ${a?`unarchive`:`archive`} this loop`,children:a?(0,G.jsx)(C,{size:13}):(0,G.jsx)(w,{size:13})})]},r.id)}),f.length===0&&(0,G.jsx)(`div`,{className:`px-3 py-4 text-[12px] text-gray-400 italic`,children:`no loops · click "+ New Loop"`})]})]});return s?(0,G.jsx)(`aside`,{className:`w-9 shrink-0 border-r border-gray-200 bg-white flex flex-col items-center pt-2`,children:(0,G.jsx)(`button`,{type:`button`,onClick:()=>p(!1),className:`w-7 h-7 flex items-center justify-center text-gray-500 hover:text-gray-900 hover:bg-gray-100 rounded`,title:`expand sidebar`,children:(0,G.jsx)(Ie,{size:16})})}):l?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`aside`,{className:`w-9 shrink-0 border-r border-gray-200 bg-white flex flex-col items-center pt-2`,children:(0,G.jsx)(`button`,{type:`button`,onClick:()=>p(!0),className:`w-7 h-7 flex items-center justify-center text-gray-500 hover:text-gray-900 hover:bg-gray-100 rounded`,title:`collapse sidebar`,children:(0,G.jsx)(Fe,{size:16})})}),(0,G.jsxs)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>p(!0),children:[(0,G.jsx)(`div`,{className:`absolute inset-0 bg-black/30`}),(0,G.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 w-64 max-w-[80vw] shadow-xl`,onClick:e=>e.stopPropagation(),children:m})]})]}):m}function XW({meta:e}){let t=vg(),n=rU(),[r,i]=(0,_.useState)([]),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)([]),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(null);(0,_.useEffect)(()=>{Lh().then(m)},[]);let[h,g]=(0,_.useState)(null),v=e=>{c(e),g(null),i(e=>e.includes(`editor`)?e:[...e,`editor`])},{runtime:y,connected:b,reconnecting:x,running:S,viewers:C,extra:w,queue:T,onClearQueue:E}=yU(e.id,t.currentUser?.id??``,v);(0,_.useEffect)(()=>{Tm(e.id).then(u),lm(e.id),t.currentUser?.id&&localStorage.setItem(`loopat:lastLoop:${t.currentUser.id}`,e.id)},[e.id]);let D=In(),O=Bn(),k=D.state?.kickoff;(0,_.useEffect)(()=>{!k||!b||(w.enqueueMessage(k),O(D.pathname,{replace:!0,state:null}))},[k,b]);let A=e=>{i(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},j=e=>{i(t=>t.includes(e)?t.filter(t=>t!==e):[e])},M=e=>{i(t=>t.filter(t=>t!==e)),o(t=>t===e?null:t)},N=r.length>0,P=r.filter(e=>e===`editor`||e===`terminal`),F=r.filter(e=>e!==`editor`&&e!==`terminal`),I=P.length>0,L=F.length>0,[R,z]=(0,_.useState)(()=>{let e=parseInt(localStorage.getItem(`loopat:chatPct`)||``,10);return!isNaN(e)&&e>=10&&e<=90?e:55}),[B,V]=(0,_.useState)(()=>{let e=parseInt(localStorage.getItem(`loopat:otherPct`)||``,10);return!isNaN(e)&&e>=5&&e<=50?e:18});(0,_.useEffect)(()=>{if(!L){let e=parseInt(localStorage.getItem(`loopat:otherPct`)||``,10);!isNaN(e)&&e>=5&&e<=50&&V(e)}if(!I&&!L){let e=parseInt(localStorage.getItem(`loopat:chatPct`)||``,10);!isNaN(e)&&e>=10&&e<=90&&z(e)}},[I,L]);let H=e=>{!isNaN(e.chat)&&e.chat>0&&localStorage.setItem(`loopat:chatPct`,String(Math.round(e.chat))),!isNaN(e.otherCol)&&e.otherCol>0&&localStorage.setItem(`loopat:otherPct`,String(Math.round(e.otherCol)))},U=n=>{let r=a===n;return(0,G.jsx)(nG,{loopId:e.id,meta:e,mode:n,onClose:()=>M(n),pickedFile:s,onPickFile:v,currentUserId:t.currentUser?.id??``,isFullscreen:r,onToggleFullscreen:()=>o(r?null:n),onEditorSelection:g},n)};return(0,G.jsxs)(`div`,{className:`flex-1 min-w-0 min-h-0 flex flex-col`,children:[(0,G.jsx)(ZW,{meta:e,mounts:l,connected:b,reconnecting:x,running:S,viewers:C,queue:T,onClearQueue:E,openPanels:r,toggleMode:A,onShareWork:()=>f(!0),showShareButton:!p||p.serveEnabled||p.serveDynamicEnabled||p.serveEphemeralEnabled}),e.contextWarnings&&e.contextWarnings.length>0&&(0,G.jsxs)(`div`,{className:`shrink-0 border-b border-amber-200 bg-amber-50 px-4 py-2 text-[12px] text-amber-800 leading-relaxed`,children:[(0,G.jsx)(`span`,{className:`font-semibold`,children:`⚠ Context not fully loaded.`}),` `,`This loop's knowledge/notes couldn't be cloned — it runs with an empty context until the access is fixed (check the key has access to the repo):`,(0,G.jsx)(`ul`,{className:`mt-1 ml-4 list-disc`,children:e.contextWarnings.map((e,t)=>(0,G.jsx)(`li`,{className:`font-mono text-[11px] break-all`,children:e},t))})]}),n?(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,G.jsx)(vU,{extra:w,children:(0,G.jsx)(YC,{runtime:y,children:(0,G.jsx)(xW,{archived:e.archived===!0,onUnarchive:()=>t.setLoopArchived(e.id,!1),repo:e.repo,branch:e.branch,title:e.title,driver:e.driver??e.createdBy,driverHistory:e.driverHistory,rfdRequestedAt:e.rfdRequestedAt,rfdRequestedBy:e.rfdRequestedBy,onTakeDrive:()=>t.takeDrive(e.id),pickedFile:s,editorSelection:h})})})}):N?(0,G.jsxs)(XO,{orientation:`horizontal`,className:`flex-1 min-w-0 min-h-0`,onLayoutChange:H,children:[(0,G.jsx)($O,{id:`chat`,minSize:20,defaultSize:R,className:`flex flex-col min-h-0 min-w-0`,children:(0,G.jsx)(vU,{extra:w,children:(0,G.jsx)(YC,{runtime:y,children:(0,G.jsx)(xW,{archived:e.archived===!0,onUnarchive:()=>t.setLoopArchived(e.id,!1),repo:e.repo,branch:e.branch,title:e.title,driver:e.driver??e.createdBy,driverHistory:e.driverHistory,rfdRequestedAt:e.rfdRequestedAt,rfdRequestedBy:e.rfdRequestedBy,onTakeDrive:()=>t.takeDrive(e.id),pickedFile:s,editorSelection:h})})})}),(I||L)&&(0,G.jsx)(nk,{className:`relative w-4 -mx-1.5 cursor-col-resize group flex items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-px after:-translate-x-1/2 after:bg-gray-200 after:transition-colors hover:after:bg-blue-400`,children:(0,G.jsx)(`div`,{className:`absolute top-1/2 -translate-y-1/2 h-8 w-1.5 rounded-full bg-gray-300 group-hover:bg-blue-400 transition-colors`})}),I&&(0,G.jsx)($O,{id:`editorCol`,minSize:15,defaultSize:30,className:`flex flex-col min-h-0 min-w-0`,children:P.length>1?(0,G.jsx)(XO,{orientation:`vertical`,className:`flex-1 min-h-0`,children:P.map((e,t)=>(0,G.jsxs)(_.Fragment,{children:[t>0&&(0,G.jsx)(nk,{className:`relative h-4 -my-1.5 cursor-row-resize group flex items-center justify-center after:absolute after:left-0 after:right-0 after:top-1/2 after:h-px after:-translate-y-1/2 after:bg-gray-200 after:transition-colors hover:after:bg-blue-400`,children:(0,G.jsx)(`div`,{className:`absolute left-1/2 -translate-x-1/2 w-8 h-1.5 rounded-full bg-gray-300 group-hover:bg-blue-400 transition-colors`})}),(0,G.jsx)($O,{id:e,minSize:10,defaultSize:100/P.length,className:`flex flex-col min-h-0 min-w-0`,children:U(e)})]},e))}):U(P[0])}),I&&L&&(0,G.jsx)(nk,{className:`relative w-4 -mx-1.5 cursor-col-resize group flex items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-px after:-translate-x-1/2 after:bg-gray-200 after:transition-colors hover:after:bg-blue-400`,children:(0,G.jsx)(`div`,{className:`absolute top-1/2 -translate-y-1/2 h-8 w-1.5 rounded-full bg-gray-300 group-hover:bg-blue-400 transition-colors`})}),L&&(0,G.jsx)($O,{id:`otherCol`,minSize:15,defaultSize:B,className:`flex flex-col min-h-0 min-w-0`,children:F.length>1?(0,G.jsx)(XO,{orientation:`vertical`,className:`flex-1 min-h-0`,children:F.map((e,t)=>(0,G.jsxs)(_.Fragment,{children:[t>0&&(0,G.jsx)(nk,{className:`relative h-4 -my-1.5 cursor-row-resize group flex items-center justify-center after:absolute after:left-0 after:right-0 after:top-1/2 after:h-px after:-translate-y-1/2 after:bg-gray-200 after:transition-colors hover:after:bg-blue-400`,children:(0,G.jsx)(`div`,{className:`absolute left-1/2 -translate-x-1/2 w-8 h-1.5 rounded-full bg-gray-300 group-hover:bg-blue-400 transition-colors`})}),(0,G.jsx)($O,{id:e,minSize:10,defaultSize:100/F.length,className:`flex flex-col min-h-0 min-w-0`,children:U(e)})]},e))}):U(F[0])})]}):(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,G.jsx)(vU,{extra:w,children:(0,G.jsx)(YC,{runtime:y,children:(0,G.jsx)(xW,{archived:e.archived===!0,onUnarchive:()=>t.setLoopArchived(e.id,!1),repo:e.repo,branch:e.branch,title:e.title,driver:e.driver??e.createdBy,driverHistory:e.driverHistory,rfdRequestedAt:e.rfdRequestedAt,rfdRequestedBy:e.rfdRequestedBy,onTakeDrive:()=>t.takeDrive(e.id),pickedFile:s,editorSelection:h})})})}),N&&n&&r.map(e=>(0,G.jsx)(_.Fragment,{children:U(e)},e)),n&&(0,G.jsx)(`div`,{className:`fixed bottom-0 left-0 z-30 w-9 flex flex-col items-center gap-0.5 pb-2`,children:[`terminal`,`editor`,`workdir`,`git`].map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>j(e),className:`w-7 h-7 flex items-center justify-center rounded text-xs ${r.includes(e)?`bg-gray-200 text-gray-900`:`text-gray-400 hover:text-gray-700 hover:bg-gray-100`}`,title:e,children:e===`terminal`?`▷`:e===`editor`?`✎`:e===`workdir`?`▤`:`⑂`},e))}),(0,G.jsx)(GW,{loop:e,open:d,onClose:()=>f(!1),onSaved:async()=>{await t.refresh()}})]})}function ZW({meta:e,mounts:t,connected:n,reconnecting:r,running:i,viewers:a,queue:o,onClearQueue:s,openPanels:c,toggleMode:l,onShareWork:u,showShareButton:d}){let f=rU(),p=Bn(),m=vg(),[h,g]=(0,_.useState)(f),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(e.title),w=m.currentUser?.id===e.createdBy,T=async()=>{if(!v){y(!0);try{let t=await hm(e.id);t&&p(`/loop/${t.id}`)}finally{y(!1)}}},E=async()=>{let t=S.trim();if(!t||t===e.title){x(!1),C(e.title);return}x(!1),await m.setLoopTitle(e.id,t)||C(e.title)},D=(e,t)=>(0,G.jsx)(`button`,{className:c.includes(t)?`px-2 py-0.5 rounded bg-gray-100 text-gray-900`:`px-2 py-0.5 rounded text-gray-500 hover:text-gray-900 hover:bg-gray-50`,onClick:()=>l(t),children:e},t);return(0,G.jsxs)(`header`,{className:`group/header px-3 md:px-5 shrink-0 border-b border-gray-200 `+(h?`py-1.5`:`pt-3 pb-2`),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>g(e=>!e),className:`text-gray-400 hover:text-gray-700 -ml-1 p-0.5 rounded hover:bg-gray-100`,title:h?`expand header`:`collapse header`,children:(0,G.jsx)(F,{size:14,className:`transition-transform `+(h?`-rotate-90`:``)})}),b?(0,G.jsx)(`input`,{type:`text`,value:S,autoFocus:!0,onChange:e=>C(e.target.value),onKeyDown:t=>{t.key===`Enter`&&!t.nativeEvent.isComposing?(t.preventDefault(),E()):t.key===`Escape`&&(t.preventDefault(),x(!1),C(e.title))},onBlur:E,maxLength:200,className:`text-[14px] md:text-[15px] font-medium text-gray-900 bg-white border border-blue-400 rounded px-1 py-0 outline-none min-w-[120px]`}):(0,G.jsx)(`span`,{className:`text-[14px] md:text-[15px] font-medium text-gray-900 `+(w?`cursor-pointer hover:bg-gray-100 rounded px-1 -mx-1`:``),onClick:()=>{w&&(C(e.title),x(!0))},title:w?`click to rename`:void 0,children:e.title}),(0,G.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[`driver: `,(0,G.jsx)(`span`,{className:`text-gray-900`,children:e.driver??e.createdBy})]}),e.rfdRequestedAt&&(0,G.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-800 border border-amber-200 font-medium tracking-wide`,title:`released for drive by ${e.rfdRequestedBy??`?`} at ${e.rfdRequestedAt}`,children:`RFD`}),!n&&r&&(0,G.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:`reconnecting…`}),i&&(0,G.jsx)(`span`,{className:`text-[11px] text-blue-600`,children:`running`}),a>1&&(0,G.jsxs)(`span`,{title:`people watching`,className:`text-[11px] px-1.5 py-0.5 rounded bg-emerald-50 text-emerald-800 border border-emerald-200`,children:[`👥 `,a]}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsxs)(`button`,{type:`button`,onClick:T,disabled:v,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] border bg-white text-violet-700 border-violet-300 hover:bg-violet-50 disabled:opacity-50`,title:`Spawn a child loop seeded with this loop's conversation, for sedimenting reusable insights into knowledge/`,children:[(0,G.jsx)(de,{size:11}),v?`Distilling…`:`Distill`]}),d!==!1&&(0,G.jsxs)(`button`,{onClick:u,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] border ${e.shareEnabled?`bg-blue-50 text-blue-700 border-blue-200 hover:bg-blue-100`:`bg-white text-gray-700 border-gray-300 hover:bg-gray-100`}`,title:`Share workspace artifact (static files or port forward)`,children:[(0,G.jsx)(ve,{size:11}),`Share Artifact`]}),(0,G.jsx)($W,{meta:e}),(0,G.jsx)(QW,{meta:e})]}),!h&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`text-xs text-gray-500 mt-1.5 flex items-center gap-2 flex-wrap`,children:[(0,G.jsxs)(`span`,{className:`font-mono`,children:[`~/.loopat/loops/`,e.id.slice(0,8),`/workdir`]}),(0,G.jsx)(`span`,{children:`·`}),(0,G.jsx)(`span`,{children:`main`}),a>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{children:`·`}),(0,G.jsxs)(`span`,{children:[a,` viewing`]})]}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px]`,children:[D(`ℹ info`,`info`),D(`▤ workdir`,`workdir`),D(`✎ editor`,`editor`),D(`▷ terminal`,`terminal`),(0,G.jsx)(`button`,{className:c.includes(`git`)?`px-2 py-0.5 rounded bg-gray-100 text-gray-900`:`px-2 py-0.5 rounded text-gray-500 hover:text-gray-900 hover:bg-gray-50`,onClick:()=>l(`git`),title:`git changes`,children:(0,G.jsx)(ge,{size:14})})]})]}),(0,G.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5 flex-wrap text-[11px]`,children:[(0,G.jsx)(`span`,{className:`text-gray-400`,children:`context:`}),t.map(e=>(0,G.jsx)(eG,{label:e.name,value:e.name===`knowledge`?`ro`:`rw`},e.path))]}),e.config?.profiles&&e.config.profiles.length>0&&(0,G.jsx)(tG,{profiles:e.config.profiles}),(0,G.jsxs)(`div`,{className:`mt-1 flex items-center gap-1.5 flex-wrap text-[11px]`,children:[(0,G.jsx)(`span`,{className:`text-gray-400`,children:`vault:`}),(0,G.jsx)(eG,{label:e.config?.vault??`default`,value:`loaded`})]})]})]})}function QW({meta:e}){let t=vg(),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(!1),o=t.currentUser?.id===e.createdBy,s=e.public===!0;if(!t.currentUser)return null;let c=`${location.origin}/loop/${e.id}`;return o?(0,G.jsxs)(`div`,{className:`inline-flex items-center gap-1`,children:[s&&(0,G.jsxs)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(c),r(!0),setTimeout(()=>r(!1),1500)}catch{}},title:c,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] text-gray-600 hover:bg-gray-100`,children:[n?(0,G.jsx)(P,{size:11}):(0,G.jsx)(ee,{size:11}),(0,G.jsx)(`span`,{className:`hidden md:inline`,children:n?`copied`:`copy link`})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:async()=>{if(!(!o||i)){a(!0);try{await t.setLoopPublic(e.id,!s)}finally{a(!1)}}},disabled:i,title:s?`stop sharing`:`share publicly (anyone with the link can view)`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] border disabled:opacity-50 `+(s?`bg-emerald-50 text-emerald-800 border-emerald-200 hover:bg-emerald-100`:`bg-white text-gray-700 border-gray-300 hover:bg-gray-100`),children:[s?(0,G.jsx)(ve,{size:11}):(0,G.jsx)(Ee,{size:11}),s?`shared`:`share`]})]}):(0,G.jsxs)(`span`,{title:s?`this loop is shared publicly`:`this loop is private`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] `+(s?`bg-emerald-50 text-emerald-800 border border-emerald-200`:`bg-gray-100 text-gray-600`),children:[s?(0,G.jsx)(ve,{size:11}):(0,G.jsx)(Ee,{size:11}),s?`public`:`private`]})}function $W({meta:e}){let t=vg(),[n,r]=(0,_.useState)(!1);if(!t.currentUser)return null;let i=e.driver??e.createdBy,a=t.currentUser.id===i;return e.rfdRequestedAt?(0,G.jsxs)(`button`,{type:`button`,disabled:n,onClick:async()=>{r(!0);try{await t.takeDrive(e.id)}finally{r(!1)}},title:`released for drive by ${e.rfdRequestedBy??`?`} — click to take over`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] border bg-amber-500 text-white border-amber-600 hover:bg-amber-600 disabled:opacity-50`,children:[(0,G.jsx)(ye,{size:11}),`Drive`]}):a?(0,G.jsxs)(`button`,{type:`button`,disabled:n,onClick:async()=>{if(window.confirm(`Request For Drive: this will tear down the sandbox and release the loop so anyone else can take over. Continue?`)){r(!0);try{await t.requestDrive(e.id)}finally{r(!1)}}},title:`Release this loop so someone else can drive it`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] border bg-white text-amber-700 border-amber-300 hover:bg-amber-50 disabled:opacity-50`,children:[(0,G.jsx)(ye,{size:11}),`Request For Drive`]}):null}function eG({label:e,value:t,title:n}){return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-gray-100 text-[11px]`,title:n,children:[(0,G.jsxs)(`span`,{className:`text-gray-500`,children:[e,`:`]}),(0,G.jsx)(`span`,{className:`text-gray-900 font-medium`,children:t})]})}function tG({profiles:e}){let[t,n]=(0,_.useState)({});return(0,_.useEffect)(()=>{let e=!1;return am().then(t=>{if(e)return;let r={};for(let e of t)e.description&&(r[e.name]=e.description);n(r)}).catch(()=>{}),()=>{e=!0}},[]),(0,G.jsxs)(`div`,{className:`mt-1 flex items-center gap-1.5 flex-wrap text-[11px]`,children:[(0,G.jsx)(`span`,{className:`text-gray-400`,children:`profiles:`}),e.map(e=>(0,G.jsx)(eG,{label:e,value:`active`,title:t[e]},e))]})}function nG({loopId:e,meta:t,mode:n,onClose:r,pickedFile:i,onPickFile:a,currentUserId:o,isFullscreen:s,onToggleFullscreen:c,onEditorSelection:l}){let u=rU(),[d,f]=(0,_.useState)(()=>{let e=localStorage.getItem(`loopat:mobilePanelPct`);return e?Math.max(20,Math.min(95,parseInt(e)||55)):55}),p=(0,_.useRef)(null),m=e=>{localStorage.setItem(`loopat:mobilePanelPct`,String(e))},h=e=>{if(p.current={startY:e,startPct:d},s){let t=Math.round(e/window.innerHeight*100),n=Math.max(20,Math.min(95,t));f(n),m(n),c?.()}},g=e=>{if(!p.current)return;let t=e-p.current.startY,n=Math.round(t/window.innerHeight*100),r=Math.max(20,Math.min(95,p.current.startPct+n));f(r),m(r)},v=()=>{p.current=null},y=e=>{e.preventDefault(),e.stopPropagation(),h(e.touches[0].clientY)},b=e=>{e.preventDefault(),g(e.touches[0].clientY)},x=e=>{e.preventDefault(),v()},S=e=>{e.pointerType!==`touch`&&(e.preventDefault(),e.target.setPointerCapture(e.pointerId),h(e.clientY))},C=e=>{e.pointerType===`touch`||!p.current||g(e.clientY)},w=e=>{e.pointerType!==`touch`&&v()},T=(0,G.jsxs)(`aside`,{className:`flex-1 min-w-0 bg-white flex flex-col`,children:[(0,G.jsxs)(`header`,{className:`px-3 h-8 shrink-0 border-b border-gray-200 flex items-center gap-1 text-[11px] text-gray-500`,children:[(0,G.jsx)(`span`,{className:`capitalize`,children:n}),n===`editor`&&(0,G.jsx)(`span`,{className:`ml-2 truncate text-gray-700`,children:i||`(no file)`}),(0,G.jsx)(`div`,{className:`flex-1`}),(n===`editor`||n===`terminal`)&&(0,G.jsx)(`button`,{className:`text-gray-400 hover:text-gray-700 px-1 rounded hover:bg-gray-100`,onClick:c,title:s?`restore`:`maximize`,children:s?(0,G.jsx)(Ae,{size:13}):(0,G.jsx)(De,{size:13})}),(0,G.jsx)(`button`,{className:`text-gray-500 hover:text-gray-900 px-1 rounded hover:bg-gray-100`,onClick:r,title:`close panel`,children:`✕`})]}),n===`info`&&(0,G.jsx)(rG,{meta:t}),n===`workdir`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(PW,{loopId:e,onPick:a,picked:i}),(0,G.jsxs)(`div`,{className:`border-t border-gray-200 px-3 py-2 text-[11px] text-gray-500`,children:[`⑂ `,(0,G.jsx)(`span`,{className:`text-gray-900`,children:`main`})]})]}),(0,G.jsxs)(_.Suspense,{fallback:(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-gray-400 text-sm`,children:`Loading...`}),children:[n===`editor`&&(0,G.jsx)(KW,{loopId:e,path:i,onSelectionChange:l}),n===`terminal`&&(0,G.jsx)(`div`,{className:`flex-1 min-h-0 bg-[#1a1c20] overflow-hidden`,children:(0,G.jsx)(qW,{loopId:e,currentUserId:o})}),n===`git`&&(0,G.jsx)(BW,{loopId:e,onClose:r,onPickFile:a})]})]});return u?(0,G.jsxs)(`div`,{className:`fixed inset-x-0 top-0 z-40 bg-white rounded-b-xl shadow-xl pointer-events-auto overflow-hidden`,style:{height:s?`100vh`:`${d}vh`},children:[(0,G.jsx)(`div`,{className:`absolute inset-0 bottom-7 overflow-y-auto flex flex-col`,children:T}),(0,G.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 h-7 z-10 flex items-center justify-center cursor-row-resize active:bg-gray-50 rounded-b-xl`,style:{touchAction:`none`},onTouchStart:y,onTouchMove:b,onTouchEnd:x,onPointerDown:S,onPointerMove:C,onPointerUp:w,children:(0,G.jsx)(`div`,{className:`w-8 h-1 rounded-full bg-gray-300`})})]}):s?(0,ft.createPortal)((0,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex flex-col`,children:T}),document.body):T}function rG({meta:e}){let t=vg().currentUser?.id===e.createdBy;return(0,G.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-auto px-5 py-4 text-[13px] text-gray-900`,children:[(0,G.jsxs)(iG,{label:`basics`,children:[(0,G.jsx)(aG,{label:`title`,value:e.title}),(0,G.jsx)(aG,{label:`created`,value:new Date(e.createdAt).toLocaleString()}),(0,G.jsx)(aG,{label:`status`,value:`active`}),(0,G.jsx)(aG,{label:`driver`,value:t?`${e.createdBy} (you)`:e.createdBy}),(0,G.jsx)(aG,{label:`sharing`,value:e.public?`public — /loop/${e.id.slice(0,8)}…`:`private`})]}),(0,G.jsxs)(iG,{label:`workdir`,children:[(0,G.jsx)(aG,{label:`id`,value:e.id,mono:!0}),(0,G.jsx)(aG,{label:`path`,value:`~/.loopat/loops/${e.id.slice(0,8)}/workdir`,mono:!0}),(0,G.jsx)(aG,{label:`branch`,value:`main`,mono:!0})]}),(0,G.jsxs)(iG,{label:`context`,children:[(0,G.jsx)(aG,{label:`knowledge`,value:`all (ro)`}),(0,G.jsx)(aG,{label:`notes`,value:`all (rw)`}),(0,G.jsx)(aG,{label:`personal`,value:`${e.createdBy} (rw)`})]})]})}function iG({label:e,children:t}){return(0,G.jsxs)(`section`,{className:`mb-5`,children:[(0,G.jsx)(`h3`,{className:`text-[11px] uppercase tracking-wide text-gray-400 mb-2`,children:e}),(0,G.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:t})]})}function aG({label:e,value:t,mono:n=!1}){return(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,G.jsx)(`span`,{className:`text-[11px] text-gray-500 w-24 shrink-0`,children:e}),(0,G.jsx)(`span`,{className:n?`font-mono text-[12px] text-gray-800 truncate`:`text-[13px] text-gray-900 truncate`,children:t})]})}function oG({name:e,onClick:t,onEdit:n,size:r=`sm`}){return(0,G.jsxs)(`span`,{className:`relative inline-flex items-center group/chip`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:t,className:`inline-flex items-center rounded-full bg-sky-50 text-sky-700 border border-sky-200 hover:bg-sky-100 transition-colors font-mono `+(r===`md`?`px-2 py-0.5 text-[12px]`:`px-1.5 py-0.5 text-[10px]`),title:`#${e}`,children:[`#`,e]}),n&&(0,G.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),n()},className:`absolute -top-1 -right-1 z-10 w-4 h-4 rounded-full bg-white border border-gray-300 hover:border-red-400 hover:text-red-500 text-[9px] text-gray-400 opacity-0 group-hover/chip:opacity-100 transition-opacity flex items-center justify-center shadow-sm`,title:`Remove tag`,children:`×`})]})}function sG(){let{name:e}=Wn(),t=decodeURIComponent(e??``),n=Bn(),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(!0);return(0,_.useEffect)(()=>{let e=!1;return uh().then(n=>{e||(i(n.find(e=>e.name===t.toLowerCase())??null),o(!1))}),()=>{e=!0}},[t]),(0,G.jsxs)(`div`,{className:`flex flex-col h-full w-full bg-white`,children:[(0,G.jsxs)(`header`,{className:`h-10 shrink-0 flex items-center gap-3 px-6 border-b border-gray-200`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>n(-1),className:`text-[11px] text-gray-500 hover:text-gray-900`,children:`← back`}),(0,G.jsx)(oG,{name:t,size:`md`}),(0,G.jsx)(`div`,{className:`flex-1`})]}),(0,G.jsx)(`main`,{className:`flex-1 min-w-0 flex flex-col overflow-auto`,children:(0,G.jsx)(`div`,{className:`px-4 md:px-8 py-4 md:py-8 mx-auto w-full max-w-[760px] flex flex-col gap-5`,children:a?(0,G.jsx)(`div`,{className:`text-[12px] text-gray-400 italic`,children:`loading…`}):!r||r.loops.length===0?(0,G.jsxs)(`div`,{className:`text-[12px] text-gray-400 italic`,children:[`no entities tagged with `,(0,G.jsxs)(`code`,{children:[`#`,t]})]}):(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`div`,{className:`text-[12px] uppercase tracking-wider text-gray-500 mb-2 px-1`,children:[`Loops (`,r.loops.length,`)`]}),(0,G.jsx)(`div`,{className:`flex flex-col gap-1`,children:r.loops.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(`/loop/${e.id}`),className:`w-full text-left px-3 py-2 rounded border border-gray-200 hover:border-gray-400 hover:bg-gray-50 text-[13px] text-gray-900`,children:[e.title,(0,G.jsx)(`span`,{className:`ml-2 text-[10px] font-mono text-gray-400`,children:e.id.slice(0,6)})]},e.id))})]})})})]})}var cG=(0,_.lazy)(()=>_t(()=>import(`./CodeEditor-DtHZtsPs.js`).then(e=>({default:e.CodeEditor})),__vite__mapDeps([2,1,3]))),lG=(0,_.lazy)(()=>_t(()=>import(`./Markdown-BaQm5IQ5.js`).then(e=>({default:e.Markdown})),__vite__mapDeps([6,1]))),uG=(0,_.lazy)(()=>_t(()=>import(`./MilkdownEditor-UrDfL7Gb.js`).then(e=>({default:e.MilkdownEditor})),__vite__mapDeps([7,1,3]))),dG=[{id:`knowledge`,label:`Knowledge`},{id:`notes`,label:`Notes`},{id:`personal`,label:`Personal`},{id:`repos`,label:`Repos`}],fG=new Set([`knowledge`,`notes`,`personal`,`repos`]);function pG(){let{sub:e}=Wn(),[t]=vi(),n=fG.has(e)?e:`knowledge`,r=t.get(`file`)||void 0,i=t.get(`edit`)===`1`;return(0,G.jsxs)(`div`,{className:`flex flex-col h-full w-full`,children:[(0,G.jsx)(`nav`,{className:`flex items-center gap-1 px-3 h-9 shrink-0 border-b border-gray-200 bg-white`,children:dG.map(e=>(0,G.jsx)(di,{to:`/context/${e.id}`,className:({isActive:e})=>e?`h-7 px-2.5 rounded flex items-center gap-1.5 text-xs bg-gray-100 text-gray-900`:`h-7 px-2.5 rounded flex items-center gap-1.5 text-xs text-gray-500 hover:bg-gray-50 hover:text-gray-900`,children:(0,G.jsx)(`span`,{children:e.label})},e.id))}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0`,children:n===`repos`?(0,G.jsx)(TG,{}):(0,G.jsx)(_G,{vault:n,initialFile:r,initialEditing:i},n)})]})}var mG={knowledge:`workspace's distilled materials`,notes:`workspace · public`,personal:`yours · private`,repos:`registered code repos`};function hG({resource:e,canPush:t=!0}){let[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(null),c=(0,_.useCallback)(async()=>{a(`status`),r(await Hm(e)),a(null)},[e]);(0,_.useEffect)(()=>{c()},[c]);let l=async()=>{a(`pull`),s(null);let t=await Um(e);a(null),s(t.ok?{ok:!0,text:t.message??`pulled`}:{ok:!1,text:t.error??`pull failed`}),t.ok&&c()},u=async()=>{a(`push`),s(null);let t=await Wm(e);a(null),s(t.ok?{ok:!0,text:t.message??`pushed`}:{ok:!1,text:t.error??`push failed`}),t.ok&&c()},d=n?.ahead??0,f=n?.behind??0,p=n&&!n.hasRemote;return(0,G.jsxs)(`div`,{className:`px-3 py-1.5 border-t border-gray-200 flex flex-col gap-1 text-[11px]`,children:[(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:p?(0,G.jsx)(`span`,{className:`text-gray-400`,children:`no remote`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`span`,{className:d>0?`text-emerald-700`:`text-gray-400`,title:`unpushed commits`,children:[`↑`,d]}),(0,G.jsxs)(`span`,{className:f>0?`text-amber-700`:`text-gray-400`,title:`unpulled commits`,children:[`↓`,f]}),n&&n.uncommitted>0&&(0,G.jsxs)(`span`,{className:`text-red-600`,title:`uncommitted changes in primary`,children:[`! `,n.uncommitted]}),(0,G.jsx)(`button`,{onClick:()=>void c(),disabled:i!==null,className:`ml-auto text-gray-400 hover:text-gray-700 disabled:opacity-50`,title:`refresh status`,children:`↻`})]})}),!p&&(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`button`,{onClick:l,disabled:i!==null||f===0,className:`px-1.5 h-5 rounded border border-gray-200 hover:bg-gray-100 text-gray-700 disabled:opacity-40 disabled:cursor-not-allowed`,children:i===`pull`?`pulling…`:`pull`}),t&&(0,G.jsx)(`button`,{onClick:u,disabled:i!==null||d===0,className:`px-1.5 h-5 rounded border border-gray-200 hover:bg-gray-100 text-gray-700 disabled:opacity-40 disabled:cursor-not-allowed`,children:i===`push`?`pushing…`:`push`}),o&&(0,G.jsx)(`span`,{className:`truncate flex-1 min-w-0 `+(o.ok?`text-emerald-700`:`text-red-600`),title:o.text,children:o.text})]})]})}function gG({onRefreshed:e}){let[t,n]=(0,_.useState)(0),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(null),s=(0,_.useRef)(e);s.current=e;let c=(0,_.useCallback)(async()=>{i(!0),o(null);let e=await Mm();i(!1),e.ok?(n(0),s.current()):e.diverged?o(`你有未保存的编辑,先保存再刷新`):o(e.error??`refresh failed`)},[]);return(0,_.useEffect)(()=>{c()},[c]),(0,_.useEffect)(()=>{let e=()=>jm().then(n).catch(()=>{});e();let t=setInterval(e,5e3);return()=>clearInterval(t)},[]),(0,G.jsxs)(`div`,{className:`px-3 py-2 border-t border-gray-200 flex flex-col gap-1.5 text-[11px]`,children:[t>0?(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2 bg-amber-50 border border-amber-200 rounded px-2 py-1 text-amber-800`,children:[(0,G.jsxs)(`span`,{children:[`远端已更新 `,t,` 个改动`]}),(0,G.jsx)(`button`,{type:`button`,onClick:c,disabled:r,className:`px-2 py-0.5 rounded bg-amber-600 text-white hover:bg-amber-700 disabled:opacity-50`,children:r?`刷新中…`:`刷新`})]}):(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-gray-400`,children:[(0,G.jsx)(`span`,{children:`已是最新`}),(0,G.jsx)(`button`,{type:`button`,onClick:c,disabled:r,className:`text-gray-500 hover:text-gray-900 underline disabled:opacity-50`,children:r?`刷新中…`:`刷新`})]}),a&&(0,G.jsx)(`div`,{className:`text-amber-700`,children:a})]})}function _G({vault:e,initialFile:t,initialEditing:n}){let[r,i]=(0,_.useState)([]),[a,o]=(0,_.useState)([]),[s,c]=(0,_.useState)(t??null),[l,u]=vi();(0,_.useEffect)(()=>{(l.get(`file`)??null)!==s&&u(s?{file:s}:{},{replace:!0})},[s,l,u]);let[d,f]=(0,_.useState)(0),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(``),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(``),w=rU(),T=(0,_.useRef)(!1);if(!T.current&&t){T.current=!0;let n=`vault-${e}`,r=t.includes(`/`)?t.substring(0,t.lastIndexOf(`/`)):``;if(r)try{let e=`loopat:tree:expanded:`+n,t=localStorage.getItem(e),i=t?JSON.parse(t):[];for(let e=r;e;e=e.includes(`/`)?e.substring(0,e.lastIndexOf(`/`)):``)i.includes(e)||i.push(e);localStorage.setItem(e,JSON.stringify(i))}catch{}}(0,_.useEffect)(()=>{Em(e).then(e=>{i(e),c(t=>{if(t)return t;let n=e.find(e=>e.type===`file`&&e.path.endsWith(`.md`));return n?n.path:null})}),Dm(e).then(o),g(``)},[e,d]),(0,_.useEffect)(()=>{let t=!1,n=()=>{t||f(e=>e+1)};return e===`knowledge`?Um(`knowledge`).then(e=>{e.ok&&(e.message??``).toLowerCase()!==`already up to date`&&n()}):e===`notes`?jm().then(e=>{e>0&&Mm().then(e=>{e.ok&&n()})}):e===`personal`&&Qp().then(e=>{e.ok&&(e.files?.length??0)>0&&n()}),()=>{t=!0}},[e]);let E=async t=>{let n=await Nm(e,t);n.ok?(m(!1),f(e=>e+1),c(t)):alert(`failed: ${n.error}`)},D=async()=>{if(!b||!S.trim()){x(null);return}let t=b.path+`/`+S.trim();if(b.type===`file`){let n=await Nm(e,t);if(!n.ok){alert(`create failed: ${n.error}`);return}}else{let n=await Pm(e,t);if(!n.ok){alert(`create failed: ${n.error}`);return}}x(null),C(``),f(e=>e+1)},O=(0,_.useCallback)((t,n)=>{if(t===`view`)c(n.path);else if(t===`new-file`||t===`new-folder`)x({type:t===`new-file`?`file`:`folder`,path:n.path}),C(``);else if(t===`delete`){if(!confirm(`Delete "${n.name}"?`))return;Fm(e,n.path).then(e=>{e.ok?(c(e=>e===n.path?null:e),f(e=>e+1)):alert(`delete failed: ${e.error}`)})}},[e]),k=(0,_.useCallback)(t=>yG(e,t.path)?[]:t.type===`dir`?[{label:`New file`,icon:(0,G.jsx)(ce,{size:12}),action:`new-file`},{label:`New folder`,icon:(0,G.jsx)(me,{size:12}),action:`new-folder`},{label:`Delete`,icon:(0,G.jsx)(nt,{size:12}),action:`delete`,danger:!0}]:bG(e,t.path)?[]:[{label:`View`,icon:(0,G.jsx)(ae,{size:12}),action:`view`},{label:`Delete`,icon:(0,G.jsx)(nt,{size:12}),action:`delete`,danger:!0}],[e]),A=(0,_.useCallback)(t=>Em(e,t).then(e=>e),[e]),j=(0,_.useCallback)((t,n,r,i)=>{if(t.type===`dir`)return yG(e,t.path)?`w-full py-1.5 flex items-center gap-1.5 bg-amber-50/40 hover:bg-amber-50 text-left border-y border-amber-200/60 mt-1`:`w-full py-1 flex items-center gap-1 hover:bg-gray-50 text-left`;let a=bG(e,t.path);return`w-full py-1 flex items-center gap-2 text-left `+(i?`bg-gray-100`:a?`hover:bg-amber-50/50`:`hover:bg-gray-50`)},[e]),M=h.trim().toLowerCase(),N=M.length>0,P=N?a.filter(e=>e.path.toLowerCase().includes(M)).slice(0,60):[],F=(0,G.jsxs)(`aside`,{className:`w-64 shrink-0 border-r border-gray-200 bg-white flex flex-col h-full`,children:[(0,G.jsxs)(`div`,{className:`px-3 h-9 flex items-center gap-1 border-b border-gray-200`,children:[w&&(0,G.jsx)(`button`,{onClick:()=>y(!1),className:`text-gray-500 hover:text-gray-900 px-1 rounded hover:bg-gray-100 mr-1`,title:`close sidebar`,children:(0,G.jsx)(Fe,{size:14})}),(0,G.jsx)(vG,{}),(0,G.jsx)(`input`,{type:`text`,value:h,onChange:e=>g(e.target.value),placeholder:`search files…`,className:`flex-1 min-w-0 bg-transparent outline-none text-[12px] text-gray-700 placeholder:text-gray-400`}),(0,G.jsx)(`button`,{onClick:()=>m(!0),className:`text-gray-500 hover:text-gray-900 px-1.5 rounded hover:bg-gray-100 text-xs`,title:`new file`,children:`+`}),(0,G.jsx)(`button`,{onClick:()=>f(e=>e+1),className:`text-gray-500 hover:text-gray-900 px-1.5 rounded hover:bg-gray-100 text-xs`,title:`refresh`,children:`↻`})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto py-2`,children:N?P.length===0?(0,G.jsx)(`div`,{className:`px-3 py-4 text-[12px] text-gray-400 italic`,children:`no matches`}):P.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{c(e.path),w&&y(!1)},className:`w-full px-3 py-1.5 flex items-center gap-2 text-left `+(s===e.path?`bg-gray-100`:`hover:bg-gray-50`),title:e.path,children:[(0,G.jsx)(`span`,{className:`text-gray-500`,children:`📄`}),(0,G.jsx)(`span`,{className:`flex-1 min-w-0 truncate text-[13px] text-gray-900`,children:e.path})]},e.path)):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(AW,{treeId:`vault-${e}`,entries:r,onPick:e=>{c(e),w&&y(!1)},picked:s,onLoadChildren:A,getContextActions:k,onAction:O,nodeClassName:j,reloadKey:d}),r.length===0&&(0,G.jsx)(`div`,{className:`px-3 py-4 text-[12px] text-gray-400 italic`,children:`empty · click + 创建第一个文件`})]})}),(0,G.jsx)(`div`,{className:`px-3 h-9 border-t border-gray-200 flex items-center text-[11px] text-gray-500`,children:mG[e]}),e===`knowledge`&&(0,G.jsx)(hG,{resource:e}),e===`notes`&&(0,G.jsx)(gG,{onRefreshed:()=>f(e=>e+1)})]});return(0,G.jsxs)(`div`,{className:`flex h-full w-full`,children:[w?(0,G.jsx)(G.Fragment,{children:v?(0,G.jsxs)(`div`,{className:`fixed inset-0 z-30`,onClick:()=>y(!1),children:[(0,G.jsx)(`div`,{className:`absolute inset-0 bg-black/30`}),(0,G.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 w-64 max-w-[80vw] shadow-xl`,onClick:e=>e.stopPropagation(),children:F})]}):(0,G.jsx)(`aside`,{className:`w-9 shrink-0 border-r border-gray-200 bg-white flex flex-col items-center pt-2`,children:(0,G.jsx)(`button`,{type:`button`,onClick:()=>y(!0),className:`w-7 h-7 flex items-center justify-center text-gray-500 hover:text-gray-900 hover:bg-gray-100 rounded`,title:`open file tree`,children:(0,G.jsx)(Ie,{size:16})})})}):F,(0,G.jsx)(`main`,{className:`flex-1 min-w-0 flex flex-col bg-white min-h-0`,children:s?(0,G.jsx)(CG,{vault:e,path:s,onSelect:c,onSaved:()=>f(e=>e+1),initialEditing:n}):(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-[13px] text-gray-400 italic`,children:`选一个文件,或点 + 新建`})}),p&&(0,G.jsx)(wG,{vault:e,onClose:()=>m(!1),onCreate:E}),b&&(0,G.jsx)(xG,{type:b.type,parentPath:b.path,value:S,onChange:C,onSubmit:D,onCancel:()=>x(null)})]})}function vG(){return(0,G.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,className:`text-gray-400 shrink-0`,children:(0,G.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,d:`M11 11l3 3M7 12.5a5.5 5.5 0 1 1 0-11 5.5 5.5 0 0 1 0 11z`})})}function yG(e,t){return e!==`personal`||!t.startsWith(`.loopat/vaults/`)?!1:t.slice(15).length>0}function bG(e,t){return e!==`personal`||!t.startsWith(`.loopat/vaults/`)?!1:t.slice(15).includes(`/`)}function xG({type:e,parentPath:t,value:n,onChange:r,onSubmit:i,onCancel:a}){return(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/30 flex items-center justify-center`,onClick:a,children:(0,G.jsxs)(`div`,{className:`w-full max-w-[420px] mx-4 bg-white rounded-md shadow-xl border border-gray-200 p-4 md:p-5`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`text-base font-semibold text-gray-900 mb-3`,children:[e===`file`?`New file`:`New folder`,` in `,(0,G.jsx)(`span`,{className:`font-mono text-[13px]`,children:t||`root`})]}),(0,G.jsx)(`input`,{autoFocus:!0,type:`text`,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&i(),e.key===`Escape`&&a()},placeholder:e===`file`?`filename.md`:`folder-name`,className:`w-full px-3 py-2 text-sm border border-gray-300 rounded outline-none focus:border-gray-500 font-mono`}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2 mt-4`,children:[(0,G.jsx)(`button`,{onClick:a,className:`px-3 h-8 text-sm rounded text-gray-700 hover:bg-gray-100`,children:`cancel`}),(0,G.jsx)(`button`,{onClick:()=>n.trim()&&i(),disabled:!n.trim(),className:`px-3 h-8 text-sm rounded bg-gray-900 text-white hover:bg-gray-700 disabled:opacity-50`,children:`create`})]})]})})}function SG(e){return/(^|\/)secrets\//.test(e)||e===`secrets`}function CG({vault:e,path:t,onSelect:n,onSaved:r,initialEditing:i}){let a=vg(),o=Bn(),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(i??!1),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)([]),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(!1),[w,T]=(0,_.useState)(!1),[E,D]=(0,_.useState)(!1),O=rU(),k=(0,_.useRef)(i);(0,_.useEffect)(()=>{k.current?k.current=!1:f(!1),C(!1),y(null),T(!1),D(!1),Om(e,t).then(e=>{let t=e?.content??``;c(t),u(t),D(!!e?.secret)}),Im(e,t).then(g)},[e,t]);let A=SG(t)||E,j=t.endsWith(`.md`),M=e!==`knowledge`,N=!A,P=e===`notes`&&!A,F=A?l.length>0:l!==s,I=(0,_.useCallback)(async()=>{if(!(!F||p)){m(!0);try{let n=await km(e,t,l);if(n.ok){if(A?(c(``),u(``)):c(l),y(n.commit??null),f(!1),r(),Im(e,t).then(g),e===`notes`){let e=await Am();e.ok||(e.conflict?alert(`Saved locally, but it conflicts with the remote (${(e.files??[]).join(`, `)}). Your edit is kept — resolve by taking the remote, or in a loop.`):alert(`Saved locally, but push to remote failed: ${e.error??`unknown`}`))}else if(e===`personal`){let e=await $p();e.ok||(e.conflict?alert(`Saved locally, but it conflicts with the remote (${(e.files??[]).join(`, `)}). Your edit is kept — pull first (re-open Personal) or resolve in a loop.`):alert(`Saved locally, but push to remote failed: ${e.error??`unknown`}`))}}else alert(`save failed: ${n.error}`)}finally{m(!1)}}},[e,t,l,F,p,r,A]),L=()=>{f(!0),j&&C(!0)},R=()=>{u(s),f(!1)},z=async()=>{o(`/loop/${(await a.createLoop({title:`edit ${e}/${t}`})).id}`)},B=async()=>{o(`/loop/${(await a.createLoop({title:`distill ${t} → knowledge`,knowledgeRw:!0})).id}`)},V=e=>{n([t.replace(/[^/]+$/,``)+e+`.md`,e+`.md`,e][0].replace(/^\//,``))};return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`header`,{className:`px-3 md:px-5 h-10 shrink-0 border-b border-gray-200 flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] min-w-0`,children:[(0,G.jsx)(`span`,{className:`text-gray-500 shrink-0`,children:A?`🔒`:`📄`}),(0,G.jsx)(`span`,{className:`font-mono text-[12px] text-gray-500 truncate`,children:t}),v&&!F&&!d&&(0,G.jsxs)(`span`,{className:`hidden md:inline text-[10px] text-emerald-700 font-mono`,children:[`commit `,v]})]}),(0,G.jsx)(`div`,{className:`flex items-center gap-1 md:gap-2 text-xs text-gray-500`,children:d?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{onClick:R,className:`px-2.5 h-7 rounded text-xs text-gray-600 hover:bg-gray-100`,children:`cancel`}),(0,G.jsx)(`button`,{onClick:I,disabled:!F||p,className:`px-2.5 h-7 rounded text-xs bg-gray-900 text-white hover:bg-gray-700 disabled:opacity-50`,children:p?`saving…`:`save`})]}):(0,G.jsxs)(G.Fragment,{children:[P&&(0,G.jsxs)(`button`,{onClick:B,className:`px-2.5 h-7 rounded text-xs bg-amber-100 text-amber-900 hover:bg-amber-200 flex items-center gap-1`,title:`open a loop to distill this notes file into knowledge`,children:[(0,G.jsx)(`span`,{children:`↑`}),(0,G.jsx)(`span`,{children:`distill`})]}),N&&(0,G.jsxs)(`button`,{onClick:z,className:P?`px-2.5 h-7 rounded text-xs border border-gray-200 hover:bg-gray-100 text-gray-900 flex items-center gap-1`:`px-2.5 h-7 rounded text-xs bg-gray-900 text-white hover:bg-gray-700 flex items-center gap-1`,title:`open a new loop with AI assist for this file`,children:[(0,G.jsx)(`span`,{children:`↻`}),(0,G.jsx)(`span`,{children:`edit by loop`})]}),M&&(0,G.jsx)(`button`,{onClick:L,className:`px-2.5 h-7 rounded text-xs border border-gray-200 hover:bg-gray-100 text-gray-900`,title:`direct edit (fastpath)`,children:`edit`}),O&&j&&(0,G.jsxs)(`button`,{onClick:()=>x(e=>!e),className:`px-2.5 h-7 rounded text-xs border ${b?`bg-gray-900 text-white`:`border-gray-200 hover:bg-gray-100 text-gray-900`}`,title:`toggle backlinks`,children:[`⇄ `,h.length]})]})})]}),d?A?(0,G.jsxs)(`div`,{className:w?`fixed inset-0 z-50 bg-white flex flex-col`:`flex-1 min-h-0 min-w-0 flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`px-3 h-7 shrink-0 border-b border-gray-200 flex items-center gap-2 text-[11px] text-gray-500`,children:[(0,G.jsx)(`span`,{className:`text-amber-700`,children:`🔒`}),(0,G.jsx)(`span`,{children:`new value · saved encrypted`}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)(`button`,{onClick:()=>T(!w),className:`text-gray-400 hover:text-gray-700 px-1 rounded hover:bg-gray-100`,title:w?`restore`:`maximize`,children:w?(0,G.jsx)(Ae,{size:13}):(0,G.jsx)(De,{size:13})})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0 relative`,children:(0,G.jsx)(_.Suspense,{fallback:(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-gray-400 text-sm`,children:`Loading editor...`}),children:(0,G.jsx)(cG,{path:t,value:l,onChange:u})})})]}):j&&!S?(0,G.jsxs)(`div`,{className:w?`fixed inset-0 z-50 bg-white flex flex-col md:flex-row`:`flex-1 min-h-0 min-w-0 flex flex-col md:flex-row`,children:[(0,G.jsxs)(`div`,{className:`flex-1 min-w-0 min-h-0 border-r border-gray-200 flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`px-3 h-7 shrink-0 border-b border-gray-200 flex items-center gap-2 text-[11px] text-gray-500`,children:[(0,G.jsx)(`span`,{children:`source · markdown`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>C(!0),className:`px-2 h-5 rounded text-[10px] bg-gray-100 hover:bg-gray-200 text-gray-600`,title:`Switch to WYSIWYG editor`,children:`wysiwyg`}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)(`button`,{onClick:()=>T(!w),className:`text-gray-400 hover:text-gray-700 px-1 rounded hover:bg-gray-100`,title:w?`restore`:`maximize`,children:w?(0,G.jsx)(Ae,{size:13}):(0,G.jsx)(De,{size:13})})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0 relative`,children:(0,G.jsx)(_.Suspense,{fallback:(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-gray-400 text-sm`,children:`Loading editor...`}),children:(0,G.jsx)(cG,{path:t,value:l,onChange:u})})})]}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0 min-h-0 flex flex-col`,children:[(0,G.jsx)(`div`,{className:`px-3 h-7 shrink-0 border-b border-gray-200 flex items-center text-[11px] text-gray-500`,children:`preview`}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto px-6 py-4`,children:(0,G.jsx)(`div`,{className:`max-w-[760px]`,children:(0,G.jsx)(_.Suspense,{fallback:(0,G.jsx)(`div`,{className:`text-gray-400 text-sm`,children:`Loading preview...`}),children:(0,G.jsx)(lG,{text:l,onWikilink:V})})})})]})]}):j?(0,G.jsxs)(`div`,{className:w?`fixed inset-0 z-50 bg-white flex flex-col`:`flex-1 min-h-0 min-w-0 flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`px-3 h-7 shrink-0 border-b border-gray-200 flex items-center gap-2 text-[11px] text-gray-500`,children:[(0,G.jsx)(`span`,{children:`wysiwyg · milkdown`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>C(!1),className:`px-2 h-5 rounded text-[10px] bg-gray-100 hover:bg-gray-200 text-gray-600`,title:`Switch to source editor`,children:`source`}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)(`button`,{onClick:()=>T(!w),className:`text-gray-400 hover:text-gray-700 px-1 rounded hover:bg-gray-100`,title:w?`restore`:`maximize`,children:w?(0,G.jsx)(Ae,{size:13}):(0,G.jsx)(De,{size:13})})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0 relative`,children:(0,G.jsx)(_.Suspense,{fallback:(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-gray-400 text-sm`,children:`Loading editor...`}),children:(0,G.jsx)(uG,{value:l,onChange:u})})})]}):(0,G.jsxs)(`div`,{className:w?`fixed inset-0 z-50 bg-white flex flex-col`:`flex-1 min-h-0 min-w-0 flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`px-3 h-7 shrink-0 border-b border-gray-200 flex items-center gap-2 text-[11px] text-gray-500`,children:[(0,G.jsxs)(`span`,{children:[`source · `,t.includes(`.`)?t.split(`.`).pop():`text`]}),t.endsWith(`.json`)&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>{try{u(JSON.stringify(JSON.parse(l),null,2))}catch(e){alert(`Invalid JSON: `+(e?.message??`parse error`))}},className:`px-2 h-5 rounded text-[10px] bg-gray-100 hover:bg-gray-200 text-gray-600`,title:`Format JSON`,children:`format`}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)(`button`,{onClick:()=>T(!w),className:`text-gray-400 hover:text-gray-700 px-1 rounded hover:bg-gray-100`,title:w?`restore`:`maximize`,children:w?(0,G.jsx)(Ae,{size:13}):(0,G.jsx)(De,{size:13})})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0 relative`,children:(0,G.jsx)(_.Suspense,{fallback:(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-gray-400 text-sm`,children:`Loading editor...`}),children:(0,G.jsx)(cG,{path:t,value:l,onChange:u})})})]}):(0,G.jsxs)(`div`,{className:`flex flex-1 min-h-0 min-w-0 overflow-hidden`,children:[(0,G.jsx)(`article`,{className:`flex-1 min-h-0 overflow-auto px-4 md:px-8 py-4 md:py-6`,children:(0,G.jsx)(`div`,{className:`max-w-[760px]`,children:A?(0,G.jsxs)(`div`,{className:`font-sans text-[13px] text-gray-600 leading-relaxed`,children:[(0,G.jsx)(`div`,{className:`inline-flex items-center gap-1.5 px-2 py-1 rounded bg-amber-50 border border-amber-200 text-amber-800 text-[12px] font-medium`,children:`encrypted · value hidden by design`}),(0,G.jsxs)(`div`,{className:`mt-3 text-[12px] text-gray-500`,children:[`Click `,(0,G.jsx)(`b`,{children:`edit`}),` to overwrite. The current value is never returned by the server, so editing means typing a new replacement — there is no decrypt-and-view.`]})]}):j?(0,G.jsx)(_.Suspense,{fallback:(0,G.jsx)(`div`,{className:`text-gray-400 text-sm`,children:`Loading...`}),children:(0,G.jsx)(lG,{text:s,onWikilink:V})}):(0,G.jsx)(`pre`,{className:`font-mono text-[12.5px] leading-relaxed whitespace-pre-wrap text-gray-900`,children:s||(0,G.jsx)(`span`,{className:`text-gray-400 italic`,children:`(empty)`})})})}),j&&!O&&(0,G.jsxs)(`aside`,{className:`w-64 shrink-0 border-l border-gray-200 bg-gray-50 overflow-auto`,children:[(0,G.jsxs)(`div`,{className:`px-3 h-9 flex items-center border-b border-gray-200`,children:[(0,G.jsx)(`span`,{className:`text-[11px] text-gray-500`,children:`Backlinks`}),(0,G.jsx)(`span`,{className:`ml-auto text-[11px] text-gray-500`,children:h.length})]}),h.length===0?(0,G.jsx)(`div`,{className:`px-3 py-4 text-xs text-gray-500`,children:`No documents link here yet.`}):(0,G.jsx)(`ul`,{className:`py-2`,children:h.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(e.path),className:`w-full px-3 py-2 text-left hover:bg-gray-100`,children:[(0,G.jsx)(`div`,{className:`text-xs font-medium text-gray-900 truncate`,children:e.path}),(0,G.jsx)(`div`,{className:`text-[11px] text-gray-500 mt-0.5 leading-snug line-clamp-2`,children:e.preview})]})},e.path))})]}),O&&j&&b&&(0,G.jsxs)(`div`,{className:`fixed inset-0 z-30`,onClick:()=>x(!1),children:[(0,G.jsx)(`div`,{className:`absolute inset-0 bg-black/30`}),(0,G.jsxs)(`div`,{className:`absolute right-0 top-0 bottom-0 w-64 max-w-[80vw] bg-gray-50 border-l border-gray-200 shadow-xl overflow-auto`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`px-3 h-9 flex items-center border-b border-gray-200`,children:[(0,G.jsx)(`span`,{className:`text-[11px] text-gray-500`,children:`Backlinks`}),(0,G.jsx)(`span`,{className:`ml-auto text-[11px] text-gray-500`,children:h.length}),(0,G.jsx)(`button`,{onClick:()=>x(!1),className:`ml-2 text-gray-400 hover:text-gray-700 px-1`,title:`close backlinks`,children:`✕`})]}),h.length===0?(0,G.jsx)(`div`,{className:`px-3 py-4 text-xs text-gray-500`,children:`No documents link here yet.`}):(0,G.jsx)(`ul`,{className:`py-2`,children:h.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{n(e.path),x(!1)},className:`w-full px-3 py-2 text-left hover:bg-gray-100`,children:[(0,G.jsx)(`div`,{className:`text-xs font-medium text-gray-900 truncate`,children:e.path}),(0,G.jsx)(`div`,{className:`text-[11px] text-gray-500 mt-0.5 leading-snug line-clamp-2`,children:e.preview})]})},e.path))})]})]})]})]})}function wG({vault:e,onClose:t,onCreate:n}){let[r,i]=(0,_.useState)(``);return(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/30 flex items-center justify-center`,onClick:t,children:(0,G.jsxs)(`div`,{className:`w-full max-w-[420px] mx-4 bg-white rounded-md shadow-xl border border-gray-200 p-4 md:p-5`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`text-base font-semibold text-gray-900 mb-3`,children:[`new file in `,e,`/`]}),(0,G.jsx)(`input`,{autoFocus:!0,type:`text`,value:r,onChange:e=>i(e.target.value),placeholder:`loopat/new-doc.md`,className:`w-full px-3 py-2 text-sm border border-gray-300 rounded outline-none focus:border-gray-500 font-mono`}),(0,G.jsx)(`div`,{className:`text-[11px] text-gray-400 mt-1`,children:`relative path. directories created as needed.`}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2 mt-4`,children:[(0,G.jsx)(`button`,{onClick:t,className:`px-3 h-8 text-sm rounded text-gray-700 hover:bg-gray-100`,children:`cancel`}),(0,G.jsx)(`button`,{onClick:()=>r.trim()&&n(r.trim()),disabled:!r.trim(),className:`px-3 h-8 text-sm rounded bg-gray-900 text-white hover:bg-gray-700 disabled:opacity-50`,children:`create`})]})]})})}function TG(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(null),u=(0,_.useCallback)(async()=>{let e=await Lm();t(e),r(e.notes?.git??``),a(e.repos)},[]);(0,_.useEffect)(()=>{u()},[u]);let d=e!==null&&(n.trim()!==(e.notes?.git??``)||JSON.stringify(i)!==JSON.stringify(e.repos)),f=()=>a(e=>[...e,{name:``,git:``}]),p=(e,t,n)=>a(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r)),m=e=>a(t=>t.filter((t,n)=>n!==e));return e?(0,G.jsx)(`article`,{className:`flex-1 min-w-0 overflow-auto p-5`,children:(0,G.jsxs)(`div`,{className:`max-w-2xl flex flex-col gap-5`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-gray-900`,children:`Repo roster`}),(0,G.jsxs)(`p`,{className:`text-[12px] text-gray-500 leading-relaxed mt-1`,children:[`Declared in the knowledge repo's`,` `,(0,G.jsx)(`code`,{className:`bg-gray-100 px-1 rounded text-[11px]`,children:`.loopat/config.json`}),`. Repos are cloned on demand when a loop selects one. Saving commits + pushes back to the knowledge repo (needs your key to have write access).`]})]}),(0,G.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`text-[12px] font-medium text-gray-700`,children:`notes remote`}),(0,G.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`git@…/notes.git`,className:`px-2 py-1.5 text-sm font-mono border border-gray-300 rounded outline-none focus:border-gray-500`})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(`span`,{className:`text-[12px] font-medium text-gray-700`,children:`repos`}),i.length===0&&(0,G.jsx)(`div`,{className:`text-[12px] text-gray-400`,children:`No repos yet.`}),i.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{value:e.name,onChange:e=>p(t,`name`,e.target.value),placeholder:`name`,className:`w-40 px-2 py-1.5 text-sm border border-gray-300 rounded outline-none focus:border-gray-500`}),(0,G.jsx)(`input`,{value:e.git,onChange:e=>p(t,`git`,e.target.value),placeholder:`git@…/repo.git`,className:`flex-1 px-2 py-1.5 text-sm font-mono border border-gray-300 rounded outline-none focus:border-gray-500`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>m(t),className:`px-2 py-1.5 text-gray-400 hover:text-red-600`,title:`remove`,children:`✕`})]},t)),(0,G.jsx)(`button`,{type:`button`,onClick:f,className:`self-start text-[12px] text-gray-600 hover:text-gray-900 border border-gray-200 rounded px-2 py-1`,children:`+ add repo`})]}),c&&(0,G.jsx)(`div`,{className:`text-[12px] rounded px-2 py-1.5 border ${c.ok?`text-emerald-700 bg-emerald-50 border-emerald-200`:`text-red-700 bg-red-50 border-red-200`}`,children:c.text}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:async()=>{s(!0),l(null);let e=i.map(e=>({name:e.name.trim(),git:e.git.trim()})).filter(e=>e.name&&e.git),t=await Rm({notes:n.trim()?{git:n.trim()}:null,repos:e});s(!1),t.ok?(l({ok:!0,text:`Saved + promoted to the knowledge repo.`}),await u()):l({ok:!1,text:(t.savedLocally?`Saved locally but promote failed: `:`Save failed: `)+(t.error??``)})},disabled:!d||o,className:`px-3 h-9 text-sm rounded bg-gray-900 text-white hover:bg-gray-700 disabled:opacity-40`,children:o?`Saving…`:`Save + promote`}),d&&(0,G.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:`unsaved changes`})]})]})}):(0,G.jsx)(`div`,{className:`p-6 text-sm text-gray-400`,children:`loading…`})}function EG(){var e=[...arguments];return(0,_.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var DG=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function OG(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function kG(e){return`nodeType`in e}function AG(e){return e?OG(e)?e:kG(e)?e.ownerDocument?.defaultView??window:window:window}function jG(e){let{Document:t}=AG(e);return e instanceof t}function MG(e){return OG(e)?!1:e instanceof AG(e).HTMLElement}function NG(e){return e instanceof AG(e).SVGElement}function PG(e){return e?OG(e)?e.document:kG(e)?jG(e)?e:MG(e)||NG(e)?e.ownerDocument:document:document:document}var FG=DG?_.useLayoutEffect:_.useEffect;function IG(e){let t=(0,_.useRef)(e);return FG(()=>{t.current=e}),(0,_.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function LG(){let e=(0,_.useRef)(null);return[(0,_.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,_.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function RG(e,t){t===void 0&&(t=[e]);let n=(0,_.useRef)(e);return FG(()=>{n.current!==e&&(n.current=e)},t),n}function zG(e,t){let n=(0,_.useRef)();return(0,_.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function BG(e){let t=IG(e),n=(0,_.useRef)(null);return[n,(0,_.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function VG(e){let t=(0,_.useRef)();return(0,_.useEffect)(()=>{t.current=e},[e]),t.current}var HG={};function UG(e,t){return(0,_.useMemo)(()=>{if(t)return t;let n=HG[e]==null?0:HG[e]+1;return HG[e]=n,e+`-`+n},[e,t])}function WG(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var GG=WG(1),KG=WG(-1);function qG(e){return`clientX`in e&&`clientY`in e}function JG(e){if(!e)return!1;let{KeyboardEvent:t}=AG(e.target);return t&&e instanceof t}function YG(e){if(!e)return!1;let{TouchEvent:t}=AG(e.target);return t&&e instanceof t}function XG(e){if(YG(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return qG(e)?{x:e.clientX,y:e.clientY}:null}var ZG=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[ZG.Translate.toString(e),ZG.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),QG=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function $G(e){return e.matches(QG)?e:e.querySelector(QG)}var eK={display:`none`};function tK(e){let{id:t,value:n}=e;return _.createElement(`div`,{id:t,style:eK},n)}function nK(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return _.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function rK(){let[e,t]=(0,_.useState)(``);return{announce:(0,_.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var iK=(0,_.createContext)(null);function aK(e){let t=(0,_.useContext)(iK);(0,_.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function oK(){let[e]=(0,_.useState)(()=>new Set),t=(0,_.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,_.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var sK={draggable:`
|
|
108
108
|
To pick up a draggable item, press the space bar.
|
|
109
109
|
While dragging, use the arrow keys to move the item.
|
|
110
110
|
Press space again to drop the item in its new position, or press escape to cancel.
|