@idl3/claude-control 0.1.22 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,85 +0,0 @@
1
- var zS=Object.defineProperty;var FS=(e,t,n)=>t in e?zS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var T=(e,t,n)=>FS(e,typeof t!="symbol"?t+"":t,n);function BS(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in e)){const i=Object.getOwnPropertyDescriptor(r,s);i&&Object.defineProperty(e,s,i.get?i:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();var Eo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ki(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var bm={exports:{}},ga={},km={exports:{}},se={};/**
2
- * @license React
3
- * react.production.min.js
4
- *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var Ci=Symbol.for("react.element"),$S=Symbol.for("react.portal"),US=Symbol.for("react.fragment"),VS=Symbol.for("react.strict_mode"),HS=Symbol.for("react.profiler"),WS=Symbol.for("react.provider"),qS=Symbol.for("react.context"),KS=Symbol.for("react.forward_ref"),GS=Symbol.for("react.suspense"),QS=Symbol.for("react.memo"),YS=Symbol.for("react.lazy"),ef=Symbol.iterator;function JS(e){return e===null||typeof e!="object"?null:(e=ef&&e[ef]||e["@@iterator"],typeof e=="function"?e:null)}var Cm={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_m=Object.assign,Em={};function as(e,t,n){this.props=e,this.context=t,this.refs=Em,this.updater=n||Cm}as.prototype.isReactComponent={};as.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};as.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Tm(){}Tm.prototype=as.prototype;function fc(e,t,n){this.props=e,this.context=t,this.refs=Em,this.updater=n||Cm}var hc=fc.prototype=new Tm;hc.constructor=fc;_m(hc,as.prototype);hc.isPureReactComponent=!0;var tf=Array.isArray,Im=Object.prototype.hasOwnProperty,pc={current:null},Rm={key:!0,ref:!0,__self:!0,__source:!0};function Pm(e,t,n){var r,s={},i=null,o=null;if(t!=null)for(r in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(i=""+t.key),t)Im.call(t,r)&&!Rm.hasOwnProperty(r)&&(s[r]=t[r]);var a=arguments.length-2;if(a===1)s.children=n;else if(1<a){for(var l=Array(a),u=0;u<a;u++)l[u]=arguments[u+2];s.children=l}if(e&&e.defaultProps)for(r in a=e.defaultProps,a)s[r]===void 0&&(s[r]=a[r]);return{$$typeof:Ci,type:e,key:i,ref:o,props:s,_owner:pc.current}}function XS(e,t){return{$$typeof:Ci,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function mc(e){return typeof e=="object"&&e!==null&&e.$$typeof===Ci}function ZS(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var nf=/\/+/g;function Ya(e,t){return typeof e=="object"&&e!==null&&e.key!=null?ZS(""+e.key):t.toString(36)}function lo(e,t,n,r,s){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var o=!1;if(e===null)o=!0;else switch(i){case"string":case"number":o=!0;break;case"object":switch(e.$$typeof){case Ci:case $S:o=!0}}if(o)return o=e,s=s(o),e=r===""?"."+Ya(o,0):r,tf(s)?(n="",e!=null&&(n=e.replace(nf,"$&/")+"/"),lo(s,t,n,"",function(u){return u})):s!=null&&(mc(s)&&(s=XS(s,n+(!s.key||o&&o.key===s.key?"":(""+s.key).replace(nf,"$&/")+"/")+e)),t.push(s)),1;if(o=0,r=r===""?".":r+":",tf(e))for(var a=0;a<e.length;a++){i=e[a];var l=r+Ya(i,a);o+=lo(i,t,n,l,s)}else if(l=JS(e),typeof l=="function")for(e=l.call(e),a=0;!(i=e.next()).done;)i=i.value,l=r+Ya(i,a++),o+=lo(i,t,n,l,s);else if(i==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return o}function Mi(e,t,n){if(e==null)return e;var r=[],s=0;return lo(e,r,"","",function(i){return t.call(n,i,s++)}),r}function eb(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var tt={current:null},uo={transition:null},tb={ReactCurrentDispatcher:tt,ReactCurrentBatchConfig:uo,ReactCurrentOwner:pc};function Am(){throw Error("act(...) is not supported in production builds of React.")}se.Children={map:Mi,forEach:function(e,t,n){Mi(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Mi(e,function(){t++}),t},toArray:function(e){return Mi(e,function(t){return t})||[]},only:function(e){if(!mc(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};se.Component=as;se.Fragment=US;se.Profiler=HS;se.PureComponent=fc;se.StrictMode=VS;se.Suspense=GS;se.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=tb;se.act=Am;se.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=_m({},e.props),s=e.key,i=e.ref,o=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,o=pc.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var a=e.type.defaultProps;for(l in t)Im.call(t,l)&&!Rm.hasOwnProperty(l)&&(r[l]=t[l]===void 0&&a!==void 0?a[l]:t[l])}var l=arguments.length-2;if(l===1)r.children=n;else if(1<l){a=Array(l);for(var u=0;u<l;u++)a[u]=arguments[u+2];r.children=a}return{$$typeof:Ci,type:e.type,key:s,ref:i,props:r,_owner:o}};se.createContext=function(e){return e={$$typeof:qS,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:WS,_context:e},e.Consumer=e};se.createElement=Pm;se.createFactory=function(e){var t=Pm.bind(null,e);return t.type=e,t};se.createRef=function(){return{current:null}};se.forwardRef=function(e){return{$$typeof:KS,render:e}};se.isValidElement=mc;se.lazy=function(e){return{$$typeof:YS,_payload:{_status:-1,_result:e},_init:eb}};se.memo=function(e,t){return{$$typeof:QS,type:e,compare:t===void 0?null:t}};se.startTransition=function(e){var t=uo.transition;uo.transition={};try{e()}finally{uo.transition=t}};se.unstable_act=Am;se.useCallback=function(e,t){return tt.current.useCallback(e,t)};se.useContext=function(e){return tt.current.useContext(e)};se.useDebugValue=function(){};se.useDeferredValue=function(e){return tt.current.useDeferredValue(e)};se.useEffect=function(e,t){return tt.current.useEffect(e,t)};se.useId=function(){return tt.current.useId()};se.useImperativeHandle=function(e,t,n){return tt.current.useImperativeHandle(e,t,n)};se.useInsertionEffect=function(e,t){return tt.current.useInsertionEffect(e,t)};se.useLayoutEffect=function(e,t){return tt.current.useLayoutEffect(e,t)};se.useMemo=function(e,t){return tt.current.useMemo(e,t)};se.useReducer=function(e,t,n){return tt.current.useReducer(e,t,n)};se.useRef=function(e){return tt.current.useRef(e)};se.useState=function(e){return tt.current.useState(e)};se.useSyncExternalStore=function(e,t,n){return tt.current.useSyncExternalStore(e,t,n)};se.useTransition=function(){return tt.current.useTransition()};se.version="18.3.1";km.exports=se;var m=km.exports;const lt=ki(m),nb=BS({__proto__:null,default:lt},[m]);/**
10
- * @license React
11
- * react-jsx-runtime.production.min.js
12
- *
13
- * Copyright (c) Facebook, Inc. and its affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var rb=m,sb=Symbol.for("react.element"),ib=Symbol.for("react.fragment"),ob=Object.prototype.hasOwnProperty,ab=rb.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,lb={key:!0,ref:!0,__self:!0,__source:!0};function jm(e,t,n){var r,s={},i=null,o=null;n!==void 0&&(i=""+n),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(o=t.ref);for(r in t)ob.call(t,r)&&!lb.hasOwnProperty(r)&&(s[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)s[r]===void 0&&(s[r]=t[r]);return{$$typeof:sb,type:e,key:i,ref:o,props:s,_owner:ab.current}}ga.Fragment=ib;ga.jsx=jm;ga.jsxs=jm;bm.exports=ga;var c=bm.exports,Nm={exports:{}},kt={},Mm={exports:{}},Lm={};/**
18
- * @license React
19
- * scheduler.production.min.js
20
- *
21
- * Copyright (c) Facebook, Inc. and its affiliates.
22
- *
23
- * This source code is licensed under the MIT license found in the
24
- * LICENSE file in the root directory of this source tree.
25
- */(function(e){function t(A,N){var S=A.length;A.push(N);e:for(;0<S;){var G=S-1>>>1,Y=A[G];if(0<s(Y,N))A[G]=N,A[S]=Y,S=G;else break e}}function n(A){return A.length===0?null:A[0]}function r(A){if(A.length===0)return null;var N=A[0],S=A.pop();if(S!==N){A[0]=S;e:for(var G=0,Y=A.length,C=Y>>>1;G<C;){var ve=2*(G+1)-1,Re=A[ve],ue=ve+1,De=A[ue];if(0>s(Re,S))ue<Y&&0>s(De,Re)?(A[G]=De,A[ue]=S,G=ue):(A[G]=Re,A[ve]=S,G=ve);else if(ue<Y&&0>s(De,S))A[G]=De,A[ue]=S,G=ue;else break e}}return N}function s(A,N){var S=A.sortIndex-N.sortIndex;return S!==0?S:A.id-N.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var o=Date,a=o.now();e.unstable_now=function(){return o.now()-a}}var l=[],u=[],f=1,d=null,h=3,p=!1,g=!1,x=!1,k=typeof setTimeout=="function"?setTimeout:null,y=typeof clearTimeout=="function"?clearTimeout:null,v=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(A){for(var N=n(u);N!==null;){if(N.callback===null)r(u);else if(N.startTime<=A)r(u),N.sortIndex=N.expirationTime,t(l,N);else break;N=n(u)}}function E(A){if(x=!1,w(A),!g)if(n(l)!==null)g=!0,B(I);else{var N=n(u);N!==null&&K(E,N.startTime-A)}}function I(A,N){g=!1,x&&(x=!1,y(D),D=-1),p=!0;var S=h;try{for(w(N),d=n(l);d!==null&&(!(d.expirationTime>N)||A&&!z());){var G=d.callback;if(typeof G=="function"){d.callback=null,h=d.priorityLevel;var Y=G(d.expirationTime<=N);N=e.unstable_now(),typeof Y=="function"?d.callback=Y:d===n(l)&&r(l),w(N)}else r(l);d=n(l)}if(d!==null)var C=!0;else{var ve=n(u);ve!==null&&K(E,ve.startTime-N),C=!1}return C}finally{d=null,h=S,p=!1}}var b=!1,P=null,D=-1,O=5,_=-1;function z(){return!(e.unstable_now()-_<O)}function L(){if(P!==null){var A=e.unstable_now();_=A;var N=!0;try{N=P(!0,A)}finally{N?W():(b=!1,P=null)}}else b=!1}var W;if(typeof v=="function")W=function(){v(L)};else if(typeof MessageChannel<"u"){var j=new MessageChannel,R=j.port2;j.port1.onmessage=L,W=function(){R.postMessage(null)}}else W=function(){k(L,0)};function B(A){P=A,b||(b=!0,W())}function K(A,N){D=k(function(){A(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(A){A.callback=null},e.unstable_continueExecution=function(){g||p||(g=!0,B(I))},e.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<A?Math.floor(1e3/A):5},e.unstable_getCurrentPriorityLevel=function(){return h},e.unstable_getFirstCallbackNode=function(){return n(l)},e.unstable_next=function(A){switch(h){case 1:case 2:case 3:var N=3;break;default:N=h}var S=h;h=N;try{return A()}finally{h=S}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(A,N){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var S=h;h=A;try{return N()}finally{h=S}},e.unstable_scheduleCallback=function(A,N,S){var G=e.unstable_now();switch(typeof S=="object"&&S!==null?(S=S.delay,S=typeof S=="number"&&0<S?G+S:G):S=G,A){case 1:var Y=-1;break;case 2:Y=250;break;case 5:Y=1073741823;break;case 4:Y=1e4;break;default:Y=5e3}return Y=S+Y,A={id:f++,callback:N,priorityLevel:A,startTime:S,expirationTime:Y,sortIndex:-1},S>G?(A.sortIndex=S,t(u,A),n(l)===null&&A===n(u)&&(x?(y(D),D=-1):x=!0,K(E,S-G))):(A.sortIndex=Y,t(l,A),g||p||(g=!0,B(I))),A},e.unstable_shouldYield=z,e.unstable_wrapCallback=function(A){var N=h;return function(){var S=h;h=N;try{return A.apply(this,arguments)}finally{h=S}}}})(Lm);Mm.exports=Lm;var ub=Mm.exports;/**
26
- * @license React
27
- * react-dom.production.min.js
28
- *
29
- * Copyright (c) Facebook, Inc. and its affiliates.
30
- *
31
- * This source code is licensed under the MIT license found in the
32
- * LICENSE file in the root directory of this source tree.
33
- */var cb=m,St=ub;function F(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;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."}var Dm=new Set,ei={};function mr(e,t){Qr(e,t),Qr(e+"Capture",t)}function Qr(e,t){for(ei[e]=t,e=0;e<t.length;e++)Dm.add(t[e])}var pn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Kl=Object.prototype.hasOwnProperty,db=/^[: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]*$/,rf={},sf={};function fb(e){return Kl.call(sf,e)?!0:Kl.call(rf,e)?!1:db.test(e)?sf[e]=!0:(rf[e]=!0,!1)}function hb(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function pb(e,t,n,r){if(t===null||typeof t>"u"||hb(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function nt(e,t,n,r,s,i,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=o}var Ue={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Ue[e]=new nt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Ue[t]=new nt(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Ue[e]=new nt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Ue[e]=new nt(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Ue[e]=new nt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Ue[e]=new nt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Ue[e]=new nt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Ue[e]=new nt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Ue[e]=new nt(e,5,!1,e.toLowerCase(),null,!1,!1)});var gc=/[\-:]([a-z])/g;function yc(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(gc,yc);Ue[t]=new nt(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(gc,yc);Ue[t]=new nt(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(gc,yc);Ue[t]=new nt(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Ue[e]=new nt(e,1,!1,e.toLowerCase(),null,!1,!1)});Ue.xlinkHref=new nt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Ue[e]=new nt(e,1,!1,e.toLowerCase(),null,!0,!0)});function vc(e,t,n,r){var s=Ue.hasOwnProperty(t)?Ue[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(pb(t,n,s,r)&&(n=null),r||s===null?fb(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):s.mustUseProperty?e[s.propertyName]=n===null?s.type===3?!1:"":n:(t=s.attributeName,r=s.attributeNamespace,n===null?e.removeAttribute(t):(s=s.type,n=s===3||s===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var vn=cb.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Li=Symbol.for("react.element"),Rr=Symbol.for("react.portal"),Pr=Symbol.for("react.fragment"),xc=Symbol.for("react.strict_mode"),Gl=Symbol.for("react.profiler"),Om=Symbol.for("react.provider"),zm=Symbol.for("react.context"),wc=Symbol.for("react.forward_ref"),Ql=Symbol.for("react.suspense"),Yl=Symbol.for("react.suspense_list"),Sc=Symbol.for("react.memo"),kn=Symbol.for("react.lazy"),Fm=Symbol.for("react.offscreen"),of=Symbol.iterator;function xs(e){return e===null||typeof e!="object"?null:(e=of&&e[of]||e["@@iterator"],typeof e=="function"?e:null)}var ke=Object.assign,Ja;function As(e){if(Ja===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Ja=t&&t[1]||""}return`
34
- `+Ja+e}var Xa=!1;function Za(e,t){if(!e||Xa)return"";Xa=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(u){var r=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){r=u}e.call(t.prototype)}else{try{throw Error()}catch(u){r=u}e()}}catch(u){if(u&&r&&typeof u.stack=="string"){for(var s=u.stack.split(`
35
- `),i=r.stack.split(`
36
- `),o=s.length-1,a=i.length-1;1<=o&&0<=a&&s[o]!==i[a];)a--;for(;1<=o&&0<=a;o--,a--)if(s[o]!==i[a]){if(o!==1||a!==1)do if(o--,a--,0>a||s[o]!==i[a]){var l=`
37
- `+s[o].replace(" at new "," at ");return e.displayName&&l.includes("<anonymous>")&&(l=l.replace("<anonymous>",e.displayName)),l}while(1<=o&&0<=a);break}}}finally{Xa=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?As(e):""}function mb(e){switch(e.tag){case 5:return As(e.type);case 16:return As("Lazy");case 13:return As("Suspense");case 19:return As("SuspenseList");case 0:case 2:case 15:return e=Za(e.type,!1),e;case 11:return e=Za(e.type.render,!1),e;case 1:return e=Za(e.type,!0),e;default:return""}}function Jl(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Pr:return"Fragment";case Rr:return"Portal";case Gl:return"Profiler";case xc:return"StrictMode";case Ql:return"Suspense";case Yl:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case zm:return(e.displayName||"Context")+".Consumer";case Om:return(e._context.displayName||"Context")+".Provider";case wc:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Sc:return t=e.displayName||null,t!==null?t:Jl(e.type)||"Memo";case kn:t=e._payload,e=e._init;try{return Jl(e(t))}catch{}}return null}function gb(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Jl(t);case 8:return t===xc?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Fn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Bm(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function yb(e){var t=Bm(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(o){r=""+o,i.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Di(e){e._valueTracker||(e._valueTracker=yb(e))}function $m(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Bm(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function To(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Xl(e,t){var n=t.checked;return ke({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function af(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Fn(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Um(e,t){t=t.checked,t!=null&&vc(e,"checked",t,!1)}function Zl(e,t){Um(e,t);var n=Fn(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?eu(e,t.type,n):t.hasOwnProperty("defaultValue")&&eu(e,t.type,Fn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function lf(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function eu(e,t,n){(t!=="number"||To(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var js=Array.isArray;function $r(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s<n.length;s++)t["$"+n[s]]=!0;for(n=0;n<e.length;n++)s=t.hasOwnProperty("$"+e[n].value),e[n].selected!==s&&(e[n].selected=s),s&&r&&(e[n].defaultSelected=!0)}else{for(n=""+Fn(n),t=null,s=0;s<e.length;s++){if(e[s].value===n){e[s].selected=!0,r&&(e[s].defaultSelected=!0);return}t!==null||e[s].disabled||(t=e[s])}t!==null&&(t.selected=!0)}}function tu(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(F(91));return ke({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function uf(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(F(92));if(js(n)){if(1<n.length)throw Error(F(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:Fn(n)}}function Vm(e,t){var n=Fn(t.value),r=Fn(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function cf(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function Hm(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function nu(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?Hm(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Oi,Wm=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,s){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,s)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Oi=Oi||document.createElement("div"),Oi.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Oi.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function ti(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Ls={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},vb=["Webkit","ms","Moz","O"];Object.keys(Ls).forEach(function(e){vb.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ls[t]=Ls[e]})});function qm(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Ls.hasOwnProperty(e)&&Ls[e]?(""+t).trim():t+"px"}function Km(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=qm(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var xb=ke({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ru(e,t){if(t){if(xb[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(F(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(F(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(F(61))}if(t.style!=null&&typeof t.style!="object")throw Error(F(62))}}function su(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";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 iu=null;function bc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ou=null,Ur=null,Vr=null;function df(e){if(e=Ti(e)){if(typeof ou!="function")throw Error(F(280));var t=e.stateNode;t&&(t=Sa(t),ou(e.stateNode,e.type,t))}}function Gm(e){Ur?Vr?Vr.push(e):Vr=[e]:Ur=e}function Qm(){if(Ur){var e=Ur,t=Vr;if(Vr=Ur=null,df(e),t)for(e=0;e<t.length;e++)df(t[e])}}function Ym(e,t){return e(t)}function Jm(){}var el=!1;function Xm(e,t,n){if(el)return e(t,n);el=!0;try{return Ym(e,t,n)}finally{el=!1,(Ur!==null||Vr!==null)&&(Jm(),Qm())}}function ni(e,t){var n=e.stateNode;if(n===null)return null;var r=Sa(n);if(r===null)return null;n=r[t];e: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 e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(F(231,t,typeof n));return n}var au=!1;if(pn)try{var ws={};Object.defineProperty(ws,"passive",{get:function(){au=!0}}),window.addEventListener("test",ws,ws),window.removeEventListener("test",ws,ws)}catch{au=!1}function wb(e,t,n,r,s,i,o,a,l){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(f){this.onError(f)}}var Ds=!1,Io=null,Ro=!1,lu=null,Sb={onError:function(e){Ds=!0,Io=e}};function bb(e,t,n,r,s,i,o,a,l){Ds=!1,Io=null,wb.apply(Sb,arguments)}function kb(e,t,n,r,s,i,o,a,l){if(bb.apply(this,arguments),Ds){if(Ds){var u=Io;Ds=!1,Io=null}else throw Error(F(198));Ro||(Ro=!0,lu=u)}}function gr(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 Zm(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 ff(e){if(gr(e)!==e)throw Error(F(188))}function Cb(e){var t=e.alternate;if(!t){if(t=gr(e),t===null)throw Error(F(188));return t!==e?null:e}for(var n=e,r=t;;){var s=n.return;if(s===null)break;var i=s.alternate;if(i===null){if(r=s.return,r!==null){n=r;continue}break}if(s.child===i.child){for(i=s.child;i;){if(i===n)return ff(s),e;if(i===r)return ff(s),t;i=i.sibling}throw Error(F(188))}if(n.return!==r.return)n=s,r=i;else{for(var o=!1,a=s.child;a;){if(a===n){o=!0,n=s,r=i;break}if(a===r){o=!0,r=s,n=i;break}a=a.sibling}if(!o){for(a=i.child;a;){if(a===n){o=!0,n=i,r=s;break}if(a===r){o=!0,r=i,n=s;break}a=a.sibling}if(!o)throw Error(F(189))}}if(n.alternate!==r)throw Error(F(190))}if(n.tag!==3)throw Error(F(188));return n.stateNode.current===n?e:t}function eg(e){return e=Cb(e),e!==null?tg(e):null}function tg(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=tg(e);if(t!==null)return t;e=e.sibling}return null}var ng=St.unstable_scheduleCallback,hf=St.unstable_cancelCallback,_b=St.unstable_shouldYield,Eb=St.unstable_requestPaint,Te=St.unstable_now,Tb=St.unstable_getCurrentPriorityLevel,kc=St.unstable_ImmediatePriority,rg=St.unstable_UserBlockingPriority,Po=St.unstable_NormalPriority,Ib=St.unstable_LowPriority,sg=St.unstable_IdlePriority,ya=null,Xt=null;function Rb(e){if(Xt&&typeof Xt.onCommitFiberRoot=="function")try{Xt.onCommitFiberRoot(ya,e,void 0,(e.current.flags&128)===128)}catch{}}var Ft=Math.clz32?Math.clz32:jb,Pb=Math.log,Ab=Math.LN2;function jb(e){return e>>>=0,e===0?32:31-(Pb(e)/Ab|0)|0}var zi=64,Fi=4194304;function Ns(e){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: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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Ao(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,i=e.pingedLanes,o=n&268435455;if(o!==0){var a=o&~s;a!==0?r=Ns(a):(i&=o,i!==0&&(r=Ns(i)))}else o=n&~s,o!==0?r=Ns(o):i!==0&&(r=Ns(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,i=t&-t,s>=i||s===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-Ft(t),s=1<<n,r|=e[n],t&=~s;return r}function Nb(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64: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:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Mb(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,i=e.pendingLanes;0<i;){var o=31-Ft(i),a=1<<o,l=s[o];l===-1?(!(a&n)||a&r)&&(s[o]=Nb(a,t)):l<=t&&(e.expiredLanes|=a),i&=~a}}function uu(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function ig(){var e=zi;return zi<<=1,!(zi&4194240)&&(zi=64),e}function tl(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function _i(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ft(t),e[t]=n}function Lb(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var s=31-Ft(n),i=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~i}}function Cc(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Ft(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var ce=0;function og(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var ag,_c,lg,ug,cg,cu=!1,Bi=[],Pn=null,An=null,jn=null,ri=new Map,si=new Map,En=[],Db="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 submit".split(" ");function pf(e,t){switch(e){case"focusin":case"focusout":Pn=null;break;case"dragenter":case"dragleave":An=null;break;case"mouseover":case"mouseout":jn=null;break;case"pointerover":case"pointerout":ri.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":si.delete(t.pointerId)}}function Ss(e,t,n,r,s,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:i,targetContainers:[s]},t!==null&&(t=Ti(t),t!==null&&_c(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function Ob(e,t,n,r,s){switch(t){case"focusin":return Pn=Ss(Pn,e,t,n,r,s),!0;case"dragenter":return An=Ss(An,e,t,n,r,s),!0;case"mouseover":return jn=Ss(jn,e,t,n,r,s),!0;case"pointerover":var i=s.pointerId;return ri.set(i,Ss(ri.get(i)||null,e,t,n,r,s)),!0;case"gotpointercapture":return i=s.pointerId,si.set(i,Ss(si.get(i)||null,e,t,n,r,s)),!0}return!1}function dg(e){var t=er(e.target);if(t!==null){var n=gr(t);if(n!==null){if(t=n.tag,t===13){if(t=Zm(n),t!==null){e.blockedOn=t,cg(e.priority,function(){lg(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 co(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=du(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);iu=r,n.target.dispatchEvent(r),iu=null}else return t=Ti(n),t!==null&&_c(t),e.blockedOn=n,!1;t.shift()}return!0}function mf(e,t,n){co(e)&&n.delete(t)}function zb(){cu=!1,Pn!==null&&co(Pn)&&(Pn=null),An!==null&&co(An)&&(An=null),jn!==null&&co(jn)&&(jn=null),ri.forEach(mf),si.forEach(mf)}function bs(e,t){e.blockedOn===t&&(e.blockedOn=null,cu||(cu=!0,St.unstable_scheduleCallback(St.unstable_NormalPriority,zb)))}function ii(e){function t(s){return bs(s,e)}if(0<Bi.length){bs(Bi[0],e);for(var n=1;n<Bi.length;n++){var r=Bi[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Pn!==null&&bs(Pn,e),An!==null&&bs(An,e),jn!==null&&bs(jn,e),ri.forEach(t),si.forEach(t),n=0;n<En.length;n++)r=En[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<En.length&&(n=En[0],n.blockedOn===null);)dg(n),n.blockedOn===null&&En.shift()}var Hr=vn.ReactCurrentBatchConfig,jo=!0;function Fb(e,t,n,r){var s=ce,i=Hr.transition;Hr.transition=null;try{ce=1,Ec(e,t,n,r)}finally{ce=s,Hr.transition=i}}function Bb(e,t,n,r){var s=ce,i=Hr.transition;Hr.transition=null;try{ce=4,Ec(e,t,n,r)}finally{ce=s,Hr.transition=i}}function Ec(e,t,n,r){if(jo){var s=du(e,t,n,r);if(s===null)dl(e,t,r,No,n),pf(e,r);else if(Ob(s,e,t,n,r))r.stopPropagation();else if(pf(e,r),t&4&&-1<Db.indexOf(e)){for(;s!==null;){var i=Ti(s);if(i!==null&&ag(i),i=du(e,t,n,r),i===null&&dl(e,t,r,No,n),i===s)break;s=i}s!==null&&r.stopPropagation()}else dl(e,t,r,null,n)}}var No=null;function du(e,t,n,r){if(No=null,e=bc(r),e=er(e),e!==null)if(t=gr(e),t===null)e=null;else if(n=t.tag,n===13){if(e=Zm(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 No=e,null}function fg(e){switch(e){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"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 1;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"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Tb()){case kc:return 1;case rg:return 4;case Po:case Ib:return 16;case sg:return 536870912;default:return 16}default:return 16}}var In=null,Tc=null,fo=null;function hg(){if(fo)return fo;var e,t=Tc,n=t.length,r,s="value"in In?In.value:In.textContent,i=s.length;for(e=0;e<n&&t[e]===s[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===s[i-r];r++);return fo=s.slice(e,1<r?1-r:void 0)}function ho(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 $i(){return!0}function gf(){return!1}function Ct(e){function t(n,r,s,i,o){this._reactName=n,this._targetInst=s,this.type=r,this.nativeEvent=i,this.target=o,this.currentTarget=null;for(var a in e)e.hasOwnProperty(a)&&(n=e[a],this[a]=n?n(i):i[a]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?$i:gf,this.isPropagationStopped=gf,this}return ke(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=$i)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=$i)},persist:function(){},isPersistent:$i}),t}var ls={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ic=Ct(ls),Ei=ke({},ls,{view:0,detail:0}),$b=Ct(Ei),nl,rl,ks,va=ke({},Ei,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Rc,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!==ks&&(ks&&e.type==="mousemove"?(nl=e.screenX-ks.screenX,rl=e.screenY-ks.screenY):rl=nl=0,ks=e),nl)},movementY:function(e){return"movementY"in e?e.movementY:rl}}),yf=Ct(va),Ub=ke({},va,{dataTransfer:0}),Vb=Ct(Ub),Hb=ke({},Ei,{relatedTarget:0}),sl=Ct(Hb),Wb=ke({},ls,{animationName:0,elapsedTime:0,pseudoElement:0}),qb=Ct(Wb),Kb=ke({},ls,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Gb=Ct(Kb),Qb=ke({},ls,{data:0}),vf=Ct(Qb),Yb={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Jb={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"},Xb={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Zb(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Xb[e])?!!t[e]:!1}function Rc(){return Zb}var ek=ke({},Ei,{key:function(e){if(e.key){var t=Yb[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=ho(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Jb[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Rc,charCode:function(e){return e.type==="keypress"?ho(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ho(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),tk=Ct(ek),nk=ke({},va,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),xf=Ct(nk),rk=ke({},Ei,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Rc}),sk=Ct(rk),ik=ke({},ls,{propertyName:0,elapsedTime:0,pseudoElement:0}),ok=Ct(ik),ak=ke({},va,{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}),lk=Ct(ak),uk=[9,13,27,32],Pc=pn&&"CompositionEvent"in window,Os=null;pn&&"documentMode"in document&&(Os=document.documentMode);var ck=pn&&"TextEvent"in window&&!Os,pg=pn&&(!Pc||Os&&8<Os&&11>=Os),wf=" ",Sf=!1;function mg(e,t){switch(e){case"keyup":return uk.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function gg(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ar=!1;function dk(e,t){switch(e){case"compositionend":return gg(t);case"keypress":return t.which!==32?null:(Sf=!0,wf);case"textInput":return e=t.data,e===wf&&Sf?null:e;default:return null}}function fk(e,t){if(Ar)return e==="compositionend"||!Pc&&mg(e,t)?(e=hg(),fo=Tc=In=null,Ar=!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 pg&&t.locale!=="ko"?null:t.data;default:return null}}var hk={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 bf(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!hk[e.type]:t==="textarea"}function yg(e,t,n,r){Gm(r),t=Mo(t,"onChange"),0<t.length&&(n=new Ic("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var zs=null,oi=null;function pk(e){Ig(e,0)}function xa(e){var t=Mr(e);if($m(t))return e}function mk(e,t){if(e==="change")return t}var vg=!1;if(pn){var il;if(pn){var ol="oninput"in document;if(!ol){var kf=document.createElement("div");kf.setAttribute("oninput","return;"),ol=typeof kf.oninput=="function"}il=ol}else il=!1;vg=il&&(!document.documentMode||9<document.documentMode)}function Cf(){zs&&(zs.detachEvent("onpropertychange",xg),oi=zs=null)}function xg(e){if(e.propertyName==="value"&&xa(oi)){var t=[];yg(t,oi,e,bc(e)),Xm(pk,t)}}function gk(e,t,n){e==="focusin"?(Cf(),zs=t,oi=n,zs.attachEvent("onpropertychange",xg)):e==="focusout"&&Cf()}function yk(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return xa(oi)}function vk(e,t){if(e==="click")return xa(t)}function xk(e,t){if(e==="input"||e==="change")return xa(t)}function wk(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Ut=typeof Object.is=="function"?Object.is:wk;function ai(e,t){if(Ut(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)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 s=n[r];if(!Kl.call(t,s)||!Ut(e[s],t[s]))return!1}return!0}function _f(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Ef(e,t){var n=_f(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}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=_f(n)}}function wg(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?wg(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Sg(){for(var e=window,t=To();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=To(e.document)}return t}function Ac(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")}function Sk(e){var t=Sg(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&wg(n.ownerDocument.documentElement,n)){if(r!==null&&Ac(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!e.extend&&i>r&&(s=r,r=i,i=s),s=Ef(n,i);var o=Ef(n,r);s&&o&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var bk=pn&&"documentMode"in document&&11>=document.documentMode,jr=null,fu=null,Fs=null,hu=!1;function Tf(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;hu||jr==null||jr!==To(r)||(r=jr,"selectionStart"in r&&Ac(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}),Fs&&ai(Fs,r)||(Fs=r,r=Mo(fu,"onSelect"),0<r.length&&(t=new Ic("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=jr)))}function Ui(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Nr={animationend:Ui("Animation","AnimationEnd"),animationiteration:Ui("Animation","AnimationIteration"),animationstart:Ui("Animation","AnimationStart"),transitionend:Ui("Transition","TransitionEnd")},al={},bg={};pn&&(bg=document.createElement("div").style,"AnimationEvent"in window||(delete Nr.animationend.animation,delete Nr.animationiteration.animation,delete Nr.animationstart.animation),"TransitionEvent"in window||delete Nr.transitionend.transition);function wa(e){if(al[e])return al[e];if(!Nr[e])return e;var t=Nr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in bg)return al[e]=t[n];return e}var kg=wa("animationend"),Cg=wa("animationiteration"),_g=wa("animationstart"),Eg=wa("transitionend"),Tg=new Map,If="abort auxClick 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(" ");function Hn(e,t){Tg.set(e,t),mr(t,[e])}for(var ll=0;ll<If.length;ll++){var ul=If[ll],kk=ul.toLowerCase(),Ck=ul[0].toUpperCase()+ul.slice(1);Hn(kk,"on"+Ck)}Hn(kg,"onAnimationEnd");Hn(Cg,"onAnimationIteration");Hn(_g,"onAnimationStart");Hn("dblclick","onDoubleClick");Hn("focusin","onFocus");Hn("focusout","onBlur");Hn(Eg,"onTransitionEnd");Qr("onMouseEnter",["mouseout","mouseover"]);Qr("onMouseLeave",["mouseout","mouseover"]);Qr("onPointerEnter",["pointerout","pointerover"]);Qr("onPointerLeave",["pointerout","pointerover"]);mr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));mr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));mr("onBeforeInput",["compositionend","keypress","textInput","paste"]);mr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));mr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));mr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ms="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(" "),_k=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ms));function Rf(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,kb(r,t,void 0,e),e.currentTarget=null}function Ig(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],s=r.event;r=r.listeners;e:{var i=void 0;if(t)for(var o=r.length-1;0<=o;o--){var a=r[o],l=a.instance,u=a.currentTarget;if(a=a.listener,l!==i&&s.isPropagationStopped())break e;Rf(s,a,u),i=l}else for(o=0;o<r.length;o++){if(a=r[o],l=a.instance,u=a.currentTarget,a=a.listener,l!==i&&s.isPropagationStopped())break e;Rf(s,a,u),i=l}}}if(Ro)throw e=lu,Ro=!1,lu=null,e}function ge(e,t){var n=t[vu];n===void 0&&(n=t[vu]=new Set);var r=e+"__bubble";n.has(r)||(Rg(t,e,2,!1),n.add(r))}function cl(e,t,n){var r=0;t&&(r|=4),Rg(n,e,r,t)}var Vi="_reactListening"+Math.random().toString(36).slice(2);function li(e){if(!e[Vi]){e[Vi]=!0,Dm.forEach(function(n){n!=="selectionchange"&&(_k.has(n)||cl(n,!1,e),cl(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Vi]||(t[Vi]=!0,cl("selectionchange",!1,t))}}function Rg(e,t,n,r){switch(fg(t)){case 1:var s=Fb;break;case 4:s=Bb;break;default:s=Ec}n=s.bind(null,t,n,e),s=void 0,!au||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(s=!0),r?s!==void 0?e.addEventListener(t,n,{capture:!0,passive:s}):e.addEventListener(t,n,!0):s!==void 0?e.addEventListener(t,n,{passive:s}):e.addEventListener(t,n,!1)}function dl(e,t,n,r,s){var i=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var a=r.stateNode.containerInfo;if(a===s||a.nodeType===8&&a.parentNode===s)break;if(o===4)for(o=r.return;o!==null;){var l=o.tag;if((l===3||l===4)&&(l=o.stateNode.containerInfo,l===s||l.nodeType===8&&l.parentNode===s))return;o=o.return}for(;a!==null;){if(o=er(a),o===null)return;if(l=o.tag,l===5||l===6){r=i=o;continue e}a=a.parentNode}}r=r.return}Xm(function(){var u=i,f=bc(n),d=[];e:{var h=Tg.get(e);if(h!==void 0){var p=Ic,g=e;switch(e){case"keypress":if(ho(n)===0)break e;case"keydown":case"keyup":p=tk;break;case"focusin":g="focus",p=sl;break;case"focusout":g="blur",p=sl;break;case"beforeblur":case"afterblur":p=sl;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":p=yf;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":p=Vb;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":p=sk;break;case kg:case Cg:case _g:p=qb;break;case Eg:p=ok;break;case"scroll":p=$b;break;case"wheel":p=lk;break;case"copy":case"cut":case"paste":p=Gb;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":p=xf}var x=(t&4)!==0,k=!x&&e==="scroll",y=x?h!==null?h+"Capture":null:h;x=[];for(var v=u,w;v!==null;){w=v;var E=w.stateNode;if(w.tag===5&&E!==null&&(w=E,y!==null&&(E=ni(v,y),E!=null&&x.push(ui(v,E,w)))),k)break;v=v.return}0<x.length&&(h=new p(h,g,null,n,f),d.push({event:h,listeners:x}))}}if(!(t&7)){e:{if(h=e==="mouseover"||e==="pointerover",p=e==="mouseout"||e==="pointerout",h&&n!==iu&&(g=n.relatedTarget||n.fromElement)&&(er(g)||g[mn]))break e;if((p||h)&&(h=f.window===f?f:(h=f.ownerDocument)?h.defaultView||h.parentWindow:window,p?(g=n.relatedTarget||n.toElement,p=u,g=g?er(g):null,g!==null&&(k=gr(g),g!==k||g.tag!==5&&g.tag!==6)&&(g=null)):(p=null,g=u),p!==g)){if(x=yf,E="onMouseLeave",y="onMouseEnter",v="mouse",(e==="pointerout"||e==="pointerover")&&(x=xf,E="onPointerLeave",y="onPointerEnter",v="pointer"),k=p==null?h:Mr(p),w=g==null?h:Mr(g),h=new x(E,v+"leave",p,n,f),h.target=k,h.relatedTarget=w,E=null,er(f)===u&&(x=new x(y,v+"enter",g,n,f),x.target=w,x.relatedTarget=k,E=x),k=E,p&&g)t:{for(x=p,y=g,v=0,w=x;w;w=Er(w))v++;for(w=0,E=y;E;E=Er(E))w++;for(;0<v-w;)x=Er(x),v--;for(;0<w-v;)y=Er(y),w--;for(;v--;){if(x===y||y!==null&&x===y.alternate)break t;x=Er(x),y=Er(y)}x=null}else x=null;p!==null&&Pf(d,h,p,x,!1),g!==null&&k!==null&&Pf(d,k,g,x,!0)}}e:{if(h=u?Mr(u):window,p=h.nodeName&&h.nodeName.toLowerCase(),p==="select"||p==="input"&&h.type==="file")var I=mk;else if(bf(h))if(vg)I=xk;else{I=yk;var b=gk}else(p=h.nodeName)&&p.toLowerCase()==="input"&&(h.type==="checkbox"||h.type==="radio")&&(I=vk);if(I&&(I=I(e,u))){yg(d,I,n,f);break e}b&&b(e,h,u),e==="focusout"&&(b=h._wrapperState)&&b.controlled&&h.type==="number"&&eu(h,"number",h.value)}switch(b=u?Mr(u):window,e){case"focusin":(bf(b)||b.contentEditable==="true")&&(jr=b,fu=u,Fs=null);break;case"focusout":Fs=fu=jr=null;break;case"mousedown":hu=!0;break;case"contextmenu":case"mouseup":case"dragend":hu=!1,Tf(d,n,f);break;case"selectionchange":if(bk)break;case"keydown":case"keyup":Tf(d,n,f)}var P;if(Pc)e:{switch(e){case"compositionstart":var D="onCompositionStart";break e;case"compositionend":D="onCompositionEnd";break e;case"compositionupdate":D="onCompositionUpdate";break e}D=void 0}else Ar?mg(e,n)&&(D="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(D="onCompositionStart");D&&(pg&&n.locale!=="ko"&&(Ar||D!=="onCompositionStart"?D==="onCompositionEnd"&&Ar&&(P=hg()):(In=f,Tc="value"in In?In.value:In.textContent,Ar=!0)),b=Mo(u,D),0<b.length&&(D=new vf(D,e,null,n,f),d.push({event:D,listeners:b}),P?D.data=P:(P=gg(n),P!==null&&(D.data=P)))),(P=ck?dk(e,n):fk(e,n))&&(u=Mo(u,"onBeforeInput"),0<u.length&&(f=new vf("onBeforeInput","beforeinput",null,n,f),d.push({event:f,listeners:u}),f.data=P))}Ig(d,t)})}function ui(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Mo(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,i=s.stateNode;s.tag===5&&i!==null&&(s=i,i=ni(e,n),i!=null&&r.unshift(ui(e,i,s)),i=ni(e,t),i!=null&&r.push(ui(e,i,s))),e=e.return}return r}function Er(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Pf(e,t,n,r,s){for(var i=t._reactName,o=[];n!==null&&n!==r;){var a=n,l=a.alternate,u=a.stateNode;if(l!==null&&l===r)break;a.tag===5&&u!==null&&(a=u,s?(l=ni(n,i),l!=null&&o.unshift(ui(n,l,a))):s||(l=ni(n,i),l!=null&&o.push(ui(n,l,a)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Ek=/\r\n?/g,Tk=/\u0000|\uFFFD/g;function Af(e){return(typeof e=="string"?e:""+e).replace(Ek,`
38
- `).replace(Tk,"")}function Hi(e,t,n){if(t=Af(t),Af(e)!==t&&n)throw Error(F(425))}function Lo(){}var pu=null,mu=null;function gu(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var yu=typeof setTimeout=="function"?setTimeout:void 0,Ik=typeof clearTimeout=="function"?clearTimeout:void 0,jf=typeof Promise=="function"?Promise:void 0,Rk=typeof queueMicrotask=="function"?queueMicrotask:typeof jf<"u"?function(e){return jf.resolve(null).then(e).catch(Pk)}:yu;function Pk(e){setTimeout(function(){throw e})}function fl(e,t){var n=t,r=0;do{var s=n.nextSibling;if(e.removeChild(n),s&&s.nodeType===8)if(n=s.data,n==="/$"){if(r===0){e.removeChild(s),ii(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);ii(t)}function Nn(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==="$?")break;if(t==="/$")return null}}return e}function Nf(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var us=Math.random().toString(36).slice(2),Yt="__reactFiber$"+us,ci="__reactProps$"+us,mn="__reactContainer$"+us,vu="__reactEvents$"+us,Ak="__reactListeners$"+us,jk="__reactHandles$"+us;function er(e){var t=e[Yt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[mn]||n[Yt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Nf(e);e!==null;){if(n=e[Yt])return n;e=Nf(e)}return t}e=n,n=e.parentNode}return null}function Ti(e){return e=e[Yt]||e[mn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Mr(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(F(33))}function Sa(e){return e[ci]||null}var xu=[],Lr=-1;function Wn(e){return{current:e}}function ye(e){0>Lr||(e.current=xu[Lr],xu[Lr]=null,Lr--)}function pe(e,t){Lr++,xu[Lr]=e.current,e.current=t}var Bn={},Ge=Wn(Bn),dt=Wn(!1),ar=Bn;function Yr(e,t){var n=e.type.contextTypes;if(!n)return Bn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function ft(e){return e=e.childContextTypes,e!=null}function Do(){ye(dt),ye(Ge)}function Mf(e,t,n){if(Ge.current!==Bn)throw Error(F(168));pe(Ge,t),pe(dt,n)}function Pg(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(F(108,gb(e)||"Unknown",s));return ke({},n,r)}function Oo(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Bn,ar=Ge.current,pe(Ge,e),pe(dt,dt.current),!0}function Lf(e,t,n){var r=e.stateNode;if(!r)throw Error(F(169));n?(e=Pg(e,t,ar),r.__reactInternalMemoizedMergedChildContext=e,ye(dt),ye(Ge),pe(Ge,e)):ye(dt),pe(dt,n)}var un=null,ba=!1,hl=!1;function Ag(e){un===null?un=[e]:un.push(e)}function Nk(e){ba=!0,Ag(e)}function qn(){if(!hl&&un!==null){hl=!0;var e=0,t=ce;try{var n=un;for(ce=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}un=null,ba=!1}catch(s){throw un!==null&&(un=un.slice(e+1)),ng(kc,qn),s}finally{ce=t,hl=!1}}return null}var Dr=[],Or=0,zo=null,Fo=0,_t=[],Et=0,lr=null,cn=1,dn="";function Jn(e,t){Dr[Or++]=Fo,Dr[Or++]=zo,zo=e,Fo=t}function jg(e,t,n){_t[Et++]=cn,_t[Et++]=dn,_t[Et++]=lr,lr=e;var r=cn;e=dn;var s=32-Ft(r)-1;r&=~(1<<s),n+=1;var i=32-Ft(t)+s;if(30<i){var o=s-s%5;i=(r&(1<<o)-1).toString(32),r>>=o,s-=o,cn=1<<32-Ft(t)+s|n<<s|r,dn=i+e}else cn=1<<i|n<<s|r,dn=e}function jc(e){e.return!==null&&(Jn(e,1),jg(e,1,0))}function Nc(e){for(;e===zo;)zo=Dr[--Or],Dr[Or]=null,Fo=Dr[--Or],Dr[Or]=null;for(;e===lr;)lr=_t[--Et],_t[Et]=null,dn=_t[--Et],_t[Et]=null,cn=_t[--Et],_t[Et]=null}var xt=null,vt=null,xe=!1,Ot=null;function Ng(e,t){var n=It(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function Df(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,xt=e,vt=Nn(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,xt=e,vt=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=lr!==null?{id:cn,overflow:dn}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=It(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,xt=e,vt=null,!0):!1;default:return!1}}function wu(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Su(e){if(xe){var t=vt;if(t){var n=t;if(!Df(e,t)){if(wu(e))throw Error(F(418));t=Nn(n.nextSibling);var r=xt;t&&Df(e,t)?Ng(r,n):(e.flags=e.flags&-4097|2,xe=!1,xt=e)}}else{if(wu(e))throw Error(F(418));e.flags=e.flags&-4097|2,xe=!1,xt=e}}}function Of(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;xt=e}function Wi(e){if(e!==xt)return!1;if(!xe)return Of(e),xe=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!gu(e.type,e.memoizedProps)),t&&(t=vt)){if(wu(e))throw Mg(),Error(F(418));for(;t;)Ng(e,t),t=Nn(t.nextSibling)}if(Of(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(F(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){vt=Nn(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}vt=null}}else vt=xt?Nn(e.stateNode.nextSibling):null;return!0}function Mg(){for(var e=vt;e;)e=Nn(e.nextSibling)}function Jr(){vt=xt=null,xe=!1}function Mc(e){Ot===null?Ot=[e]:Ot.push(e)}var Mk=vn.ReactCurrentBatchConfig;function Cs(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(F(309));var r=n.stateNode}if(!r)throw Error(F(147,e));var s=r,i=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===i?t.ref:(t=function(o){var a=s.refs;o===null?delete a[i]:a[i]=o},t._stringRef=i,t)}if(typeof e!="string")throw Error(F(284));if(!n._owner)throw Error(F(290,e))}return e}function qi(e,t){throw e=Object.prototype.toString.call(t),Error(F(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function zf(e){var t=e._init;return t(e._payload)}function Lg(e){function t(y,v){if(e){var w=y.deletions;w===null?(y.deletions=[v],y.flags|=16):w.push(v)}}function n(y,v){if(!e)return null;for(;v!==null;)t(y,v),v=v.sibling;return null}function r(y,v){for(y=new Map;v!==null;)v.key!==null?y.set(v.key,v):y.set(v.index,v),v=v.sibling;return y}function s(y,v){return y=On(y,v),y.index=0,y.sibling=null,y}function i(y,v,w){return y.index=w,e?(w=y.alternate,w!==null?(w=w.index,w<v?(y.flags|=2,v):w):(y.flags|=2,v)):(y.flags|=1048576,v)}function o(y){return e&&y.alternate===null&&(y.flags|=2),y}function a(y,v,w,E){return v===null||v.tag!==6?(v=wl(w,y.mode,E),v.return=y,v):(v=s(v,w),v.return=y,v)}function l(y,v,w,E){var I=w.type;return I===Pr?f(y,v,w.props.children,E,w.key):v!==null&&(v.elementType===I||typeof I=="object"&&I!==null&&I.$$typeof===kn&&zf(I)===v.type)?(E=s(v,w.props),E.ref=Cs(y,v,w),E.return=y,E):(E=wo(w.type,w.key,w.props,null,y.mode,E),E.ref=Cs(y,v,w),E.return=y,E)}function u(y,v,w,E){return v===null||v.tag!==4||v.stateNode.containerInfo!==w.containerInfo||v.stateNode.implementation!==w.implementation?(v=Sl(w,y.mode,E),v.return=y,v):(v=s(v,w.children||[]),v.return=y,v)}function f(y,v,w,E,I){return v===null||v.tag!==7?(v=sr(w,y.mode,E,I),v.return=y,v):(v=s(v,w),v.return=y,v)}function d(y,v,w){if(typeof v=="string"&&v!==""||typeof v=="number")return v=wl(""+v,y.mode,w),v.return=y,v;if(typeof v=="object"&&v!==null){switch(v.$$typeof){case Li:return w=wo(v.type,v.key,v.props,null,y.mode,w),w.ref=Cs(y,null,v),w.return=y,w;case Rr:return v=Sl(v,y.mode,w),v.return=y,v;case kn:var E=v._init;return d(y,E(v._payload),w)}if(js(v)||xs(v))return v=sr(v,y.mode,w,null),v.return=y,v;qi(y,v)}return null}function h(y,v,w,E){var I=v!==null?v.key:null;if(typeof w=="string"&&w!==""||typeof w=="number")return I!==null?null:a(y,v,""+w,E);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case Li:return w.key===I?l(y,v,w,E):null;case Rr:return w.key===I?u(y,v,w,E):null;case kn:return I=w._init,h(y,v,I(w._payload),E)}if(js(w)||xs(w))return I!==null?null:f(y,v,w,E,null);qi(y,w)}return null}function p(y,v,w,E,I){if(typeof E=="string"&&E!==""||typeof E=="number")return y=y.get(w)||null,a(v,y,""+E,I);if(typeof E=="object"&&E!==null){switch(E.$$typeof){case Li:return y=y.get(E.key===null?w:E.key)||null,l(v,y,E,I);case Rr:return y=y.get(E.key===null?w:E.key)||null,u(v,y,E,I);case kn:var b=E._init;return p(y,v,w,b(E._payload),I)}if(js(E)||xs(E))return y=y.get(w)||null,f(v,y,E,I,null);qi(v,E)}return null}function g(y,v,w,E){for(var I=null,b=null,P=v,D=v=0,O=null;P!==null&&D<w.length;D++){P.index>D?(O=P,P=null):O=P.sibling;var _=h(y,P,w[D],E);if(_===null){P===null&&(P=O);break}e&&P&&_.alternate===null&&t(y,P),v=i(_,v,D),b===null?I=_:b.sibling=_,b=_,P=O}if(D===w.length)return n(y,P),xe&&Jn(y,D),I;if(P===null){for(;D<w.length;D++)P=d(y,w[D],E),P!==null&&(v=i(P,v,D),b===null?I=P:b.sibling=P,b=P);return xe&&Jn(y,D),I}for(P=r(y,P);D<w.length;D++)O=p(P,y,D,w[D],E),O!==null&&(e&&O.alternate!==null&&P.delete(O.key===null?D:O.key),v=i(O,v,D),b===null?I=O:b.sibling=O,b=O);return e&&P.forEach(function(z){return t(y,z)}),xe&&Jn(y,D),I}function x(y,v,w,E){var I=xs(w);if(typeof I!="function")throw Error(F(150));if(w=I.call(w),w==null)throw Error(F(151));for(var b=I=null,P=v,D=v=0,O=null,_=w.next();P!==null&&!_.done;D++,_=w.next()){P.index>D?(O=P,P=null):O=P.sibling;var z=h(y,P,_.value,E);if(z===null){P===null&&(P=O);break}e&&P&&z.alternate===null&&t(y,P),v=i(z,v,D),b===null?I=z:b.sibling=z,b=z,P=O}if(_.done)return n(y,P),xe&&Jn(y,D),I;if(P===null){for(;!_.done;D++,_=w.next())_=d(y,_.value,E),_!==null&&(v=i(_,v,D),b===null?I=_:b.sibling=_,b=_);return xe&&Jn(y,D),I}for(P=r(y,P);!_.done;D++,_=w.next())_=p(P,y,D,_.value,E),_!==null&&(e&&_.alternate!==null&&P.delete(_.key===null?D:_.key),v=i(_,v,D),b===null?I=_:b.sibling=_,b=_);return e&&P.forEach(function(L){return t(y,L)}),xe&&Jn(y,D),I}function k(y,v,w,E){if(typeof w=="object"&&w!==null&&w.type===Pr&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case Li:e:{for(var I=w.key,b=v;b!==null;){if(b.key===I){if(I=w.type,I===Pr){if(b.tag===7){n(y,b.sibling),v=s(b,w.props.children),v.return=y,y=v;break e}}else if(b.elementType===I||typeof I=="object"&&I!==null&&I.$$typeof===kn&&zf(I)===b.type){n(y,b.sibling),v=s(b,w.props),v.ref=Cs(y,b,w),v.return=y,y=v;break e}n(y,b);break}else t(y,b);b=b.sibling}w.type===Pr?(v=sr(w.props.children,y.mode,E,w.key),v.return=y,y=v):(E=wo(w.type,w.key,w.props,null,y.mode,E),E.ref=Cs(y,v,w),E.return=y,y=E)}return o(y);case Rr:e:{for(b=w.key;v!==null;){if(v.key===b)if(v.tag===4&&v.stateNode.containerInfo===w.containerInfo&&v.stateNode.implementation===w.implementation){n(y,v.sibling),v=s(v,w.children||[]),v.return=y,y=v;break e}else{n(y,v);break}else t(y,v);v=v.sibling}v=Sl(w,y.mode,E),v.return=y,y=v}return o(y);case kn:return b=w._init,k(y,v,b(w._payload),E)}if(js(w))return g(y,v,w,E);if(xs(w))return x(y,v,w,E);qi(y,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,v!==null&&v.tag===6?(n(y,v.sibling),v=s(v,w),v.return=y,y=v):(n(y,v),v=wl(w,y.mode,E),v.return=y,y=v),o(y)):n(y,v)}return k}var Xr=Lg(!0),Dg=Lg(!1),Bo=Wn(null),$o=null,zr=null,Lc=null;function Dc(){Lc=zr=$o=null}function Oc(e){var t=Bo.current;ye(Bo),e._currentValue=t}function bu(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Wr(e,t){$o=e,Lc=zr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ut=!0),e.firstContext=null)}function At(e){var t=e._currentValue;if(Lc!==e)if(e={context:e,memoizedValue:t,next:null},zr===null){if($o===null)throw Error(F(308));zr=e,$o.dependencies={lanes:0,firstContext:e}}else zr=zr.next=e;return t}var tr=null;function zc(e){tr===null?tr=[e]:tr.push(e)}function Og(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,zc(t)):(n.next=s.next,s.next=n),t.interleaved=n,gn(e,r)}function gn(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Cn=!1;function Fc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function zg(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function hn(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Mn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,le&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,gn(e,n)}return s=r.interleaved,s===null?(t.next=t,zc(r)):(t.next=s.next,s.next=t),r.interleaved=t,gn(e,n)}function po(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Cc(e,n)}}function Ff(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?s=i=o:i=i.next=o,n=n.next}while(n!==null);i===null?s=i=t:i=i.next=t}else s=i=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Uo(e,t,n,r){var s=e.updateQueue;Cn=!1;var i=s.firstBaseUpdate,o=s.lastBaseUpdate,a=s.shared.pending;if(a!==null){s.shared.pending=null;var l=a,u=l.next;l.next=null,o===null?i=u:o.next=u,o=l;var f=e.alternate;f!==null&&(f=f.updateQueue,a=f.lastBaseUpdate,a!==o&&(a===null?f.firstBaseUpdate=u:a.next=u,f.lastBaseUpdate=l))}if(i!==null){var d=s.baseState;o=0,f=u=l=null,a=i;do{var h=a.lane,p=a.eventTime;if((r&h)===h){f!==null&&(f=f.next={eventTime:p,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var g=e,x=a;switch(h=t,p=n,x.tag){case 1:if(g=x.payload,typeof g=="function"){d=g.call(p,d,h);break e}d=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=x.payload,h=typeof g=="function"?g.call(p,d,h):g,h==null)break e;d=ke({},d,h);break e;case 2:Cn=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,h=s.effects,h===null?s.effects=[a]:h.push(a))}else p={eventTime:p,lane:h,tag:a.tag,payload:a.payload,callback:a.callback,next:null},f===null?(u=f=p,l=d):f=f.next=p,o|=h;if(a=a.next,a===null){if(a=s.shared.pending,a===null)break;h=a,a=h.next,h.next=null,s.lastBaseUpdate=h,s.shared.pending=null}}while(!0);if(f===null&&(l=d),s.baseState=l,s.firstBaseUpdate=u,s.lastBaseUpdate=f,t=s.shared.interleaved,t!==null){s=t;do o|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);cr|=o,e.lanes=o,e.memoizedState=d}}function Bf(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],s=r.callback;if(s!==null){if(r.callback=null,r=n,typeof s!="function")throw Error(F(191,s));s.call(r)}}}var Ii={},Zt=Wn(Ii),di=Wn(Ii),fi=Wn(Ii);function nr(e){if(e===Ii)throw Error(F(174));return e}function Bc(e,t){switch(pe(fi,t),pe(di,e),pe(Zt,Ii),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:nu(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=nu(t,e)}ye(Zt),pe(Zt,t)}function Zr(){ye(Zt),ye(di),ye(fi)}function Fg(e){nr(fi.current);var t=nr(Zt.current),n=nu(t,e.type);t!==n&&(pe(di,e),pe(Zt,n))}function $c(e){di.current===e&&(ye(Zt),ye(di))}var we=Wn(0);function Vo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){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 pl=[];function Uc(){for(var e=0;e<pl.length;e++)pl[e]._workInProgressVersionPrimary=null;pl.length=0}var mo=vn.ReactCurrentDispatcher,ml=vn.ReactCurrentBatchConfig,ur=0,be=null,Me=null,Oe=null,Ho=!1,Bs=!1,hi=0,Lk=0;function Ve(){throw Error(F(321))}function Vc(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Ut(e[n],t[n]))return!1;return!0}function Hc(e,t,n,r,s,i){if(ur=i,be=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,mo.current=e===null||e.memoizedState===null?Fk:Bk,e=n(r,s),Bs){i=0;do{if(Bs=!1,hi=0,25<=i)throw Error(F(301));i+=1,Oe=Me=null,t.updateQueue=null,mo.current=$k,e=n(r,s)}while(Bs)}if(mo.current=Wo,t=Me!==null&&Me.next!==null,ur=0,Oe=Me=be=null,Ho=!1,t)throw Error(F(300));return e}function Wc(){var e=hi!==0;return hi=0,e}function Gt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Oe===null?be.memoizedState=Oe=e:Oe=Oe.next=e,Oe}function jt(){if(Me===null){var e=be.alternate;e=e!==null?e.memoizedState:null}else e=Me.next;var t=Oe===null?be.memoizedState:Oe.next;if(t!==null)Oe=t,Me=e;else{if(e===null)throw Error(F(310));Me=e,e={memoizedState:Me.memoizedState,baseState:Me.baseState,baseQueue:Me.baseQueue,queue:Me.queue,next:null},Oe===null?be.memoizedState=Oe=e:Oe=Oe.next=e}return Oe}function pi(e,t){return typeof t=="function"?t(e):t}function gl(e){var t=jt(),n=t.queue;if(n===null)throw Error(F(311));n.lastRenderedReducer=e;var r=Me,s=r.baseQueue,i=n.pending;if(i!==null){if(s!==null){var o=s.next;s.next=i.next,i.next=o}r.baseQueue=s=i,n.pending=null}if(s!==null){i=s.next,r=r.baseState;var a=o=null,l=null,u=i;do{var f=u.lane;if((ur&f)===f)l!==null&&(l=l.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),r=u.hasEagerState?u.eagerState:e(r,u.action);else{var d={lane:f,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};l===null?(a=l=d,o=r):l=l.next=d,be.lanes|=f,cr|=f}u=u.next}while(u!==null&&u!==i);l===null?o=r:l.next=a,Ut(r,t.memoizedState)||(ut=!0),t.memoizedState=r,t.baseState=o,t.baseQueue=l,n.lastRenderedState=r}if(e=n.interleaved,e!==null){s=e;do i=s.lane,be.lanes|=i,cr|=i,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function yl(e){var t=jt(),n=t.queue;if(n===null)throw Error(F(311));n.lastRenderedReducer=e;var r=n.dispatch,s=n.pending,i=t.memoizedState;if(s!==null){n.pending=null;var o=s=s.next;do i=e(i,o.action),o=o.next;while(o!==s);Ut(i,t.memoizedState)||(ut=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),n.lastRenderedState=i}return[i,r]}function Bg(){}function $g(e,t){var n=be,r=jt(),s=t(),i=!Ut(r.memoizedState,s);if(i&&(r.memoizedState=s,ut=!0),r=r.queue,qc(Hg.bind(null,n,r,e),[e]),r.getSnapshot!==t||i||Oe!==null&&Oe.memoizedState.tag&1){if(n.flags|=2048,mi(9,Vg.bind(null,n,r,s,t),void 0,null),ze===null)throw Error(F(349));ur&30||Ug(n,t,s)}return s}function Ug(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=be.updateQueue,t===null?(t={lastEffect:null,stores:null},be.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Vg(e,t,n,r){t.value=n,t.getSnapshot=r,Wg(t)&&qg(e)}function Hg(e,t,n){return n(function(){Wg(t)&&qg(e)})}function Wg(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Ut(e,n)}catch{return!0}}function qg(e){var t=gn(e,1);t!==null&&Bt(t,e,1,-1)}function $f(e){var t=Gt();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:pi,lastRenderedState:e},t.queue=e,e=e.dispatch=zk.bind(null,be,e),[t.memoizedState,e]}function mi(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=be.updateQueue,t===null?(t={lastEffect:null,stores:null},be.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function Kg(){return jt().memoizedState}function go(e,t,n,r){var s=Gt();be.flags|=e,s.memoizedState=mi(1|t,n,void 0,r===void 0?null:r)}function ka(e,t,n,r){var s=jt();r=r===void 0?null:r;var i=void 0;if(Me!==null){var o=Me.memoizedState;if(i=o.destroy,r!==null&&Vc(r,o.deps)){s.memoizedState=mi(t,n,i,r);return}}be.flags|=e,s.memoizedState=mi(1|t,n,i,r)}function Uf(e,t){return go(8390656,8,e,t)}function qc(e,t){return ka(2048,8,e,t)}function Gg(e,t){return ka(4,2,e,t)}function Qg(e,t){return ka(4,4,e,t)}function Yg(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Jg(e,t,n){return n=n!=null?n.concat([e]):null,ka(4,4,Yg.bind(null,t,e),n)}function Kc(){}function Xg(e,t){var n=jt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Vc(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Zg(e,t){var n=jt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Vc(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function ey(e,t,n){return ur&21?(Ut(n,t)||(n=ig(),be.lanes|=n,cr|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,ut=!0),e.memoizedState=n)}function Dk(e,t){var n=ce;ce=n!==0&&4>n?n:4,e(!0);var r=ml.transition;ml.transition={};try{e(!1),t()}finally{ce=n,ml.transition=r}}function ty(){return jt().memoizedState}function Ok(e,t,n){var r=Dn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},ny(e))ry(t,n);else if(n=Og(e,t,n,r),n!==null){var s=et();Bt(n,e,r,s),sy(n,t,r)}}function zk(e,t,n){var r=Dn(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(ny(e))ry(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var o=t.lastRenderedState,a=i(o,n);if(s.hasEagerState=!0,s.eagerState=a,Ut(a,o)){var l=t.interleaved;l===null?(s.next=s,zc(t)):(s.next=l.next,l.next=s),t.interleaved=s;return}}catch{}finally{}n=Og(e,t,s,r),n!==null&&(s=et(),Bt(n,e,r,s),sy(n,t,r))}}function ny(e){var t=e.alternate;return e===be||t!==null&&t===be}function ry(e,t){Bs=Ho=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function sy(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Cc(e,n)}}var Wo={readContext:At,useCallback:Ve,useContext:Ve,useEffect:Ve,useImperativeHandle:Ve,useInsertionEffect:Ve,useLayoutEffect:Ve,useMemo:Ve,useReducer:Ve,useRef:Ve,useState:Ve,useDebugValue:Ve,useDeferredValue:Ve,useTransition:Ve,useMutableSource:Ve,useSyncExternalStore:Ve,useId:Ve,unstable_isNewReconciler:!1},Fk={readContext:At,useCallback:function(e,t){return Gt().memoizedState=[e,t===void 0?null:t],e},useContext:At,useEffect:Uf,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,go(4194308,4,Yg.bind(null,t,e),n)},useLayoutEffect:function(e,t){return go(4194308,4,e,t)},useInsertionEffect:function(e,t){return go(4,2,e,t)},useMemo:function(e,t){var n=Gt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Gt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Ok.bind(null,be,e),[r.memoizedState,e]},useRef:function(e){var t=Gt();return e={current:e},t.memoizedState=e},useState:$f,useDebugValue:Kc,useDeferredValue:function(e){return Gt().memoizedState=e},useTransition:function(){var e=$f(!1),t=e[0];return e=Dk.bind(null,e[1]),Gt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=be,s=Gt();if(xe){if(n===void 0)throw Error(F(407));n=n()}else{if(n=t(),ze===null)throw Error(F(349));ur&30||Ug(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,Uf(Hg.bind(null,r,i,e),[e]),r.flags|=2048,mi(9,Vg.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Gt(),t=ze.identifierPrefix;if(xe){var n=dn,r=cn;n=(r&~(1<<32-Ft(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=hi++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=Lk++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},Bk={readContext:At,useCallback:Xg,useContext:At,useEffect:qc,useImperativeHandle:Jg,useInsertionEffect:Gg,useLayoutEffect:Qg,useMemo:Zg,useReducer:gl,useRef:Kg,useState:function(){return gl(pi)},useDebugValue:Kc,useDeferredValue:function(e){var t=jt();return ey(t,Me.memoizedState,e)},useTransition:function(){var e=gl(pi)[0],t=jt().memoizedState;return[e,t]},useMutableSource:Bg,useSyncExternalStore:$g,useId:ty,unstable_isNewReconciler:!1},$k={readContext:At,useCallback:Xg,useContext:At,useEffect:qc,useImperativeHandle:Jg,useInsertionEffect:Gg,useLayoutEffect:Qg,useMemo:Zg,useReducer:yl,useRef:Kg,useState:function(){return yl(pi)},useDebugValue:Kc,useDeferredValue:function(e){var t=jt();return Me===null?t.memoizedState=e:ey(t,Me.memoizedState,e)},useTransition:function(){var e=yl(pi)[0],t=jt().memoizedState;return[e,t]},useMutableSource:Bg,useSyncExternalStore:$g,useId:ty,unstable_isNewReconciler:!1};function Lt(e,t){if(e&&e.defaultProps){t=ke({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function ku(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:ke({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Ca={isMounted:function(e){return(e=e._reactInternals)?gr(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=et(),s=Dn(e),i=hn(r,s);i.payload=t,n!=null&&(i.callback=n),t=Mn(e,i,s),t!==null&&(Bt(t,e,s,r),po(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=et(),s=Dn(e),i=hn(r,s);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Mn(e,i,s),t!==null&&(Bt(t,e,s,r),po(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=et(),r=Dn(e),s=hn(n,r);s.tag=2,t!=null&&(s.callback=t),t=Mn(e,s,r),t!==null&&(Bt(t,e,r,n),po(t,e,r))}};function Vf(e,t,n,r,s,i,o){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,i,o):t.prototype&&t.prototype.isPureReactComponent?!ai(n,r)||!ai(s,i):!0}function iy(e,t,n){var r=!1,s=Bn,i=t.contextType;return typeof i=="object"&&i!==null?i=At(i):(s=ft(t)?ar:Ge.current,r=t.contextTypes,i=(r=r!=null)?Yr(e,s):Bn),t=new t(n,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Ca,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=i),t}function Hf(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&&Ca.enqueueReplaceState(t,t.state,null)}function Cu(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},Fc(e);var i=t.contextType;typeof i=="object"&&i!==null?s.context=At(i):(i=ft(t)?ar:Ge.current,s.context=Yr(e,i)),s.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(ku(e,t,i,n),s.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof s.getSnapshotBeforeUpdate=="function"||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(t=s.state,typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount(),t!==s.state&&Ca.enqueueReplaceState(s,s.state,null),Uo(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function es(e,t){try{var n="",r=t;do n+=mb(r),r=r.return;while(r);var s=n}catch(i){s=`
39
- Error generating stack: `+i.message+`
40
- `+i.stack}return{value:e,source:t,stack:s,digest:null}}function vl(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function _u(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var Uk=typeof WeakMap=="function"?WeakMap:Map;function oy(e,t,n){n=hn(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Ko||(Ko=!0,Lu=r),_u(e,t)},n}function ay(e,t,n){n=hn(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var s=t.value;n.payload=function(){return r(s)},n.callback=function(){_u(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){_u(e,t),typeof r!="function"&&(Ln===null?Ln=new Set([this]):Ln.add(this));var o=t.stack;this.componentDidCatch(t.value,{componentStack:o!==null?o:""})}),n}function Wf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Uk;var s=new Set;r.set(t,s)}else s=r.get(t),s===void 0&&(s=new Set,r.set(t,s));s.has(n)||(s.add(n),e=nC.bind(null,e,t,n),t.then(e,e))}function qf(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function Kf(e,t,n,r,s){return e.mode&1?(e.flags|=65536,e.lanes=s,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=hn(-1,1),t.tag=2,Mn(n,t,1))),n.lanes|=1),e)}var Vk=vn.ReactCurrentOwner,ut=!1;function Xe(e,t,n,r){t.child=e===null?Dg(t,null,n,r):Xr(t,e.child,n,r)}function Gf(e,t,n,r,s){n=n.render;var i=t.ref;return Wr(t,s),r=Hc(e,t,n,r,i,s),n=Wc(),e!==null&&!ut?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,yn(e,t,s)):(xe&&n&&jc(t),t.flags|=1,Xe(e,t,r,s),t.child)}function Qf(e,t,n,r,s){if(e===null){var i=n.type;return typeof i=="function"&&!td(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,ly(e,t,i,r,s)):(e=wo(n.type,null,r,t,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&s)){var o=i.memoizedProps;if(n=n.compare,n=n!==null?n:ai,n(o,r)&&e.ref===t.ref)return yn(e,t,s)}return t.flags|=1,e=On(i,r),e.ref=t.ref,e.return=t,t.child=e}function ly(e,t,n,r,s){if(e!==null){var i=e.memoizedProps;if(ai(i,r)&&e.ref===t.ref)if(ut=!1,t.pendingProps=r=i,(e.lanes&s)!==0)e.flags&131072&&(ut=!0);else return t.lanes=e.lanes,yn(e,t,s)}return Eu(e,t,n,r,s)}function uy(e,t,n){var r=t.pendingProps,s=r.children,i=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},pe(Br,yt),yt|=n;else{if(!(n&1073741824))return e=i!==null?i.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,pe(Br,yt),yt|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,pe(Br,yt),yt|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,pe(Br,yt),yt|=r;return Xe(e,t,s,n),t.child}function cy(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Eu(e,t,n,r,s){var i=ft(n)?ar:Ge.current;return i=Yr(t,i),Wr(t,s),n=Hc(e,t,n,r,i,s),r=Wc(),e!==null&&!ut?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,yn(e,t,s)):(xe&&r&&jc(t),t.flags|=1,Xe(e,t,n,s),t.child)}function Yf(e,t,n,r,s){if(ft(n)){var i=!0;Oo(t)}else i=!1;if(Wr(t,s),t.stateNode===null)yo(e,t),iy(t,n,r),Cu(t,n,r,s),r=!0;else if(e===null){var o=t.stateNode,a=t.memoizedProps;o.props=a;var l=o.context,u=n.contextType;typeof u=="object"&&u!==null?u=At(u):(u=ft(n)?ar:Ge.current,u=Yr(t,u));var f=n.getDerivedStateFromProps,d=typeof f=="function"||typeof o.getSnapshotBeforeUpdate=="function";d||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==r||l!==u)&&Hf(t,o,r,u),Cn=!1;var h=t.memoizedState;o.state=h,Uo(t,r,o,s),l=t.memoizedState,a!==r||h!==l||dt.current||Cn?(typeof f=="function"&&(ku(t,n,f,r),l=t.memoizedState),(a=Cn||Vf(t,n,a,r,h,l,u))?(d||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),o.props=r,o.state=l,o.context=u,r=a):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,zg(e,t),a=t.memoizedProps,u=t.type===t.elementType?a:Lt(t.type,a),o.props=u,d=t.pendingProps,h=o.context,l=n.contextType,typeof l=="object"&&l!==null?l=At(l):(l=ft(n)?ar:Ge.current,l=Yr(t,l));var p=n.getDerivedStateFromProps;(f=typeof p=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==d||h!==l)&&Hf(t,o,r,l),Cn=!1,h=t.memoizedState,o.state=h,Uo(t,r,o,s);var g=t.memoizedState;a!==d||h!==g||dt.current||Cn?(typeof p=="function"&&(ku(t,n,p,r),g=t.memoizedState),(u=Cn||Vf(t,n,u,r,h,g,l)||!1)?(f||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,g,l),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,g,l)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=g),o.props=r,o.state=g,o.context=l,r=u):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),r=!1)}return Tu(e,t,n,r,i,s)}function Tu(e,t,n,r,s,i){cy(e,t);var o=(t.flags&128)!==0;if(!r&&!o)return s&&Lf(t,n,!1),yn(e,t,i);r=t.stateNode,Vk.current=t;var a=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&o?(t.child=Xr(t,e.child,null,i),t.child=Xr(t,null,a,i)):Xe(e,t,a,i),t.memoizedState=r.state,s&&Lf(t,n,!0),t.child}function dy(e){var t=e.stateNode;t.pendingContext?Mf(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Mf(e,t.context,!1),Bc(e,t.containerInfo)}function Jf(e,t,n,r,s){return Jr(),Mc(s),t.flags|=256,Xe(e,t,n,r),t.child}var Iu={dehydrated:null,treeContext:null,retryLane:0};function Ru(e){return{baseLanes:e,cachePool:null,transitions:null}}function fy(e,t,n){var r=t.pendingProps,s=we.current,i=!1,o=(t.flags&128)!==0,a;if((a=o)||(a=e!==null&&e.memoizedState===null?!1:(s&2)!==0),a?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(s|=1),pe(we,s&1),e===null)return Su(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(o=r.children,e=r.fallback,i?(r=t.mode,i=t.child,o={mode:"hidden",children:o},!(r&1)&&i!==null?(i.childLanes=0,i.pendingProps=o):i=Ta(o,r,0,null),e=sr(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=Ru(n),t.memoizedState=Iu,e):Gc(t,o));if(s=e.memoizedState,s!==null&&(a=s.dehydrated,a!==null))return Hk(e,t,o,r,a,s,n);if(i){i=r.fallback,o=t.mode,s=e.child,a=s.sibling;var l={mode:"hidden",children:r.children};return!(o&1)&&t.child!==s?(r=t.child,r.childLanes=0,r.pendingProps=l,t.deletions=null):(r=On(s,l),r.subtreeFlags=s.subtreeFlags&14680064),a!==null?i=On(a,i):(i=sr(i,o,n,null),i.flags|=2),i.return=t,r.return=t,r.sibling=i,t.child=r,r=i,i=t.child,o=e.child.memoizedState,o=o===null?Ru(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},i.memoizedState=o,i.childLanes=e.childLanes&~n,t.memoizedState=Iu,r}return i=e.child,e=i.sibling,r=On(i,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function Gc(e,t){return t=Ta({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Ki(e,t,n,r){return r!==null&&Mc(r),Xr(t,e.child,null,n),e=Gc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Hk(e,t,n,r,s,i,o){if(n)return t.flags&256?(t.flags&=-257,r=vl(Error(F(422))),Ki(e,t,o,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,s=t.mode,r=Ta({mode:"visible",children:r.children},s,0,null),i=sr(i,s,o,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&Xr(t,e.child,null,o),t.child.memoizedState=Ru(o),t.memoizedState=Iu,i);if(!(t.mode&1))return Ki(e,t,o,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var a=r.dgst;return r=a,i=Error(F(419)),r=vl(i,r,void 0),Ki(e,t,o,r)}if(a=(o&e.childLanes)!==0,ut||a){if(r=ze,r!==null){switch(o&-o){case 4:s=2;break;case 16:s=8;break;case 64: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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:s=32;break;case 536870912:s=268435456;break;default:s=0}s=s&(r.suspendedLanes|o)?0:s,s!==0&&s!==i.retryLane&&(i.retryLane=s,gn(e,s),Bt(r,e,s,-1))}return ed(),r=vl(Error(F(421))),Ki(e,t,o,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=rC.bind(null,e),s._reactRetry=t,null):(e=i.treeContext,vt=Nn(s.nextSibling),xt=t,xe=!0,Ot=null,e!==null&&(_t[Et++]=cn,_t[Et++]=dn,_t[Et++]=lr,cn=e.id,dn=e.overflow,lr=t),t=Gc(t,r.children),t.flags|=4096,t)}function Xf(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),bu(e.return,t,n)}function xl(e,t,n,r,s){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:s}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=s)}function hy(e,t,n){var r=t.pendingProps,s=r.revealOrder,i=r.tail;if(Xe(e,t,r.children,n),r=we.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Xf(e,n,t);else if(e.tag===19)Xf(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(pe(we,r),!(t.mode&1))t.memoizedState=null;else switch(s){case"forwards":for(n=t.child,s=null;n!==null;)e=n.alternate,e!==null&&Vo(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),xl(t,!1,s,n,i);break;case"backwards":for(n=null,s=t.child,t.child=null;s!==null;){if(e=s.alternate,e!==null&&Vo(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}xl(t,!0,n,null,i);break;case"together":xl(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function yo(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function yn(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),cr|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(F(153));if(t.child!==null){for(e=t.child,n=On(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=On(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Wk(e,t,n){switch(t.tag){case 3:dy(t),Jr();break;case 5:Fg(t);break;case 1:ft(t.type)&&Oo(t);break;case 4:Bc(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;pe(Bo,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(pe(we,we.current&1),t.flags|=128,null):n&t.child.childLanes?fy(e,t,n):(pe(we,we.current&1),e=yn(e,t,n),e!==null?e.sibling:null);pe(we,we.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return hy(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),pe(we,we.current),r)break;return null;case 22:case 23:return t.lanes=0,uy(e,t,n)}return yn(e,t,n)}var py,Pu,my,gy;py=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Pu=function(){};my=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,nr(Zt.current);var i=null;switch(n){case"input":s=Xl(e,s),r=Xl(e,r),i=[];break;case"select":s=ke({},s,{value:void 0}),r=ke({},r,{value:void 0}),i=[];break;case"textarea":s=tu(e,s),r=tu(e,r),i=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Lo)}ru(n,r);var o;n=null;for(u in s)if(!r.hasOwnProperty(u)&&s.hasOwnProperty(u)&&s[u]!=null)if(u==="style"){var a=s[u];for(o in a)a.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(ei.hasOwnProperty(u)?i||(i=[]):(i=i||[]).push(u,null));for(u in r){var l=r[u];if(a=s?.[u],r.hasOwnProperty(u)&&l!==a&&(l!=null||a!=null))if(u==="style")if(a){for(o in a)!a.hasOwnProperty(o)||l&&l.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in l)l.hasOwnProperty(o)&&a[o]!==l[o]&&(n||(n={}),n[o]=l[o])}else n||(i||(i=[]),i.push(u,n)),n=l;else u==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,a=a?a.__html:void 0,l!=null&&a!==l&&(i=i||[]).push(u,l)):u==="children"?typeof l!="string"&&typeof l!="number"||(i=i||[]).push(u,""+l):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(ei.hasOwnProperty(u)?(l!=null&&u==="onScroll"&&ge("scroll",e),i||a===l||(i=[])):(i=i||[]).push(u,l))}n&&(i=i||[]).push("style",n);var u=i;(t.updateQueue=u)&&(t.flags|=4)}};gy=function(e,t,n,r){n!==r&&(t.flags|=4)};function _s(e,t){if(!xe)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 He(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var s=e.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags&14680064,r|=s.flags&14680064,s.return=e,s=s.sibling;else for(s=e.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags,r|=s.flags,s.return=e,s=s.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function qk(e,t,n){var r=t.pendingProps;switch(Nc(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return He(t),null;case 1:return ft(t.type)&&Do(),He(t),null;case 3:return r=t.stateNode,Zr(),ye(dt),ye(Ge),Uc(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Wi(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ot!==null&&(zu(Ot),Ot=null))),Pu(e,t),He(t),null;case 5:$c(t);var s=nr(fi.current);if(n=t.type,e!==null&&t.stateNode!=null)my(e,t,n,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(F(166));return He(t),null}if(e=nr(Zt.current),Wi(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[Yt]=t,r[ci]=i,e=(t.mode&1)!==0,n){case"dialog":ge("cancel",r),ge("close",r);break;case"iframe":case"object":case"embed":ge("load",r);break;case"video":case"audio":for(s=0;s<Ms.length;s++)ge(Ms[s],r);break;case"source":ge("error",r);break;case"img":case"image":case"link":ge("error",r),ge("load",r);break;case"details":ge("toggle",r);break;case"input":af(r,i),ge("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},ge("invalid",r);break;case"textarea":uf(r,i),ge("invalid",r)}ru(n,i),s=null;for(var o in i)if(i.hasOwnProperty(o)){var a=i[o];o==="children"?typeof a=="string"?r.textContent!==a&&(i.suppressHydrationWarning!==!0&&Hi(r.textContent,a,e),s=["children",a]):typeof a=="number"&&r.textContent!==""+a&&(i.suppressHydrationWarning!==!0&&Hi(r.textContent,a,e),s=["children",""+a]):ei.hasOwnProperty(o)&&a!=null&&o==="onScroll"&&ge("scroll",r)}switch(n){case"input":Di(r),lf(r,i,!0);break;case"textarea":Di(r),cf(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=Lo)}r=s,t.updateQueue=r,r!==null&&(t.flags|=4)}else{o=s.nodeType===9?s:s.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=Hm(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=o.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[Yt]=t,e[ci]=r,py(e,t,!1,!1),t.stateNode=e;e:{switch(o=su(n,r),n){case"dialog":ge("cancel",e),ge("close",e),s=r;break;case"iframe":case"object":case"embed":ge("load",e),s=r;break;case"video":case"audio":for(s=0;s<Ms.length;s++)ge(Ms[s],e);s=r;break;case"source":ge("error",e),s=r;break;case"img":case"image":case"link":ge("error",e),ge("load",e),s=r;break;case"details":ge("toggle",e),s=r;break;case"input":af(e,r),s=Xl(e,r),ge("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=ke({},r,{value:void 0}),ge("invalid",e);break;case"textarea":uf(e,r),s=tu(e,r),ge("invalid",e);break;default:s=r}ru(n,s),a=s;for(i in a)if(a.hasOwnProperty(i)){var l=a[i];i==="style"?Km(e,l):i==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,l!=null&&Wm(e,l)):i==="children"?typeof l=="string"?(n!=="textarea"||l!=="")&&ti(e,l):typeof l=="number"&&ti(e,""+l):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(ei.hasOwnProperty(i)?l!=null&&i==="onScroll"&&ge("scroll",e):l!=null&&vc(e,i,l,o))}switch(n){case"input":Di(e),lf(e,r,!1);break;case"textarea":Di(e),cf(e);break;case"option":r.value!=null&&e.setAttribute("value",""+Fn(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?$r(e,!!r.multiple,i,!1):r.defaultValue!=null&&$r(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=Lo)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return He(t),null;case 6:if(e&&t.stateNode!=null)gy(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(F(166));if(n=nr(fi.current),nr(Zt.current),Wi(t)){if(r=t.stateNode,n=t.memoizedProps,r[Yt]=t,(i=r.nodeValue!==n)&&(e=xt,e!==null))switch(e.tag){case 3:Hi(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Hi(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Yt]=t,t.stateNode=r}return He(t),null;case 13:if(ye(we),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(xe&&vt!==null&&t.mode&1&&!(t.flags&128))Mg(),Jr(),t.flags|=98560,i=!1;else if(i=Wi(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(F(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(F(317));i[Yt]=t}else Jr(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;He(t),i=!1}else Ot!==null&&(zu(Ot),Ot=null),i=!0;if(!i)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||we.current&1?Le===0&&(Le=3):ed())),t.updateQueue!==null&&(t.flags|=4),He(t),null);case 4:return Zr(),Pu(e,t),e===null&&li(t.stateNode.containerInfo),He(t),null;case 10:return Oc(t.type._context),He(t),null;case 17:return ft(t.type)&&Do(),He(t),null;case 19:if(ye(we),i=t.memoizedState,i===null)return He(t),null;if(r=(t.flags&128)!==0,o=i.rendering,o===null)if(r)_s(i,!1);else{if(Le!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Vo(e),o!==null){for(t.flags|=128,_s(i,!1),r=o.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)i=n,e=r,i.flags&=14680066,o=i.alternate,o===null?(i.childLanes=0,i.lanes=e,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=o.childLanes,i.lanes=o.lanes,i.child=o.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=o.memoizedProps,i.memoizedState=o.memoizedState,i.updateQueue=o.updateQueue,i.type=o.type,e=o.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return pe(we,we.current&1|2),t.child}e=e.sibling}i.tail!==null&&Te()>ts&&(t.flags|=128,r=!0,_s(i,!1),t.lanes=4194304)}else{if(!r)if(e=Vo(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),_s(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!xe)return He(t),null}else 2*Te()-i.renderingStartTime>ts&&n!==1073741824&&(t.flags|=128,r=!0,_s(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(n=i.last,n!==null?n.sibling=o:t.child=o,i.last=o)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=Te(),t.sibling=null,n=we.current,pe(we,r?n&1|2:n&1),t):(He(t),null);case 22:case 23:return Zc(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?yt&1073741824&&(He(t),t.subtreeFlags&6&&(t.flags|=8192)):He(t),null;case 24:return null;case 25:return null}throw Error(F(156,t.tag))}function Kk(e,t){switch(Nc(t),t.tag){case 1:return ft(t.type)&&Do(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Zr(),ye(dt),ye(Ge),Uc(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return $c(t),null;case 13:if(ye(we),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(F(340));Jr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ye(we),null;case 4:return Zr(),null;case 10:return Oc(t.type._context),null;case 22:case 23:return Zc(),null;case 24:return null;default:return null}}var Gi=!1,We=!1,Gk=typeof WeakSet=="function"?WeakSet:Set,q=null;function Fr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){_e(e,t,r)}else n.current=null}function Au(e,t,n){try{n()}catch(r){_e(e,t,r)}}var Zf=!1;function Qk(e,t){if(pu=jo,e=Sg(),Ac(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var o=0,a=-1,l=-1,u=0,f=0,d=e,h=null;t:for(;;){for(var p;d!==n||s!==0&&d.nodeType!==3||(a=o+s),d!==i||r!==0&&d.nodeType!==3||(l=o+r),d.nodeType===3&&(o+=d.nodeValue.length),(p=d.firstChild)!==null;)h=d,d=p;for(;;){if(d===e)break t;if(h===n&&++u===s&&(a=o),h===i&&++f===r&&(l=o),(p=d.nextSibling)!==null)break;d=h,h=d.parentNode}d=p}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(mu={focusedElem:e,selectionRange:n},jo=!1,q=t;q!==null;)if(t=q,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,q=e;else for(;q!==null;){t=q;try{var g=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(g!==null){var x=g.memoizedProps,k=g.memoizedState,y=t.stateNode,v=y.getSnapshotBeforeUpdate(t.elementType===t.type?x:Lt(t.type,x),k);y.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var w=t.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(F(163))}}catch(E){_e(t,t.return,E)}if(e=t.sibling,e!==null){e.return=t.return,q=e;break}q=t.return}return g=Zf,Zf=!1,g}function $s(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var i=s.destroy;s.destroy=void 0,i!==void 0&&Au(t,n,i)}s=s.next}while(s!==r)}}function _a(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function ju(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function yy(e){var t=e.alternate;t!==null&&(e.alternate=null,yy(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Yt],delete t[ci],delete t[vu],delete t[Ak],delete t[jk])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function vy(e){return e.tag===5||e.tag===3||e.tag===4}function eh(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||vy(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.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Nu(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Lo));else if(r!==4&&(e=e.child,e!==null))for(Nu(e,t,n),e=e.sibling;e!==null;)Nu(e,t,n),e=e.sibling}function Mu(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&&(e=e.child,e!==null))for(Mu(e,t,n),e=e.sibling;e!==null;)Mu(e,t,n),e=e.sibling}var Fe=null,Dt=!1;function Sn(e,t,n){for(n=n.child;n!==null;)xy(e,t,n),n=n.sibling}function xy(e,t,n){if(Xt&&typeof Xt.onCommitFiberUnmount=="function")try{Xt.onCommitFiberUnmount(ya,n)}catch{}switch(n.tag){case 5:We||Fr(n,t);case 6:var r=Fe,s=Dt;Fe=null,Sn(e,t,n),Fe=r,Dt=s,Fe!==null&&(Dt?(e=Fe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Fe.removeChild(n.stateNode));break;case 18:Fe!==null&&(Dt?(e=Fe,n=n.stateNode,e.nodeType===8?fl(e.parentNode,n):e.nodeType===1&&fl(e,n),ii(e)):fl(Fe,n.stateNode));break;case 4:r=Fe,s=Dt,Fe=n.stateNode.containerInfo,Dt=!0,Sn(e,t,n),Fe=r,Dt=s;break;case 0:case 11:case 14:case 15:if(!We&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var i=s,o=i.destroy;i=i.tag,o!==void 0&&(i&2||i&4)&&Au(n,t,o),s=s.next}while(s!==r)}Sn(e,t,n);break;case 1:if(!We&&(Fr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){_e(n,t,a)}Sn(e,t,n);break;case 21:Sn(e,t,n);break;case 22:n.mode&1?(We=(r=We)||n.memoizedState!==null,Sn(e,t,n),We=r):Sn(e,t,n);break;default:Sn(e,t,n)}}function th(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Gk),t.forEach(function(r){var s=sC.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function Mt(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var s=n[r];try{var i=e,o=t,a=o;e:for(;a!==null;){switch(a.tag){case 5:Fe=a.stateNode,Dt=!1;break e;case 3:Fe=a.stateNode.containerInfo,Dt=!0;break e;case 4:Fe=a.stateNode.containerInfo,Dt=!0;break e}a=a.return}if(Fe===null)throw Error(F(160));xy(i,o,s),Fe=null,Dt=!1;var l=s.alternate;l!==null&&(l.return=null),s.return=null}catch(u){_e(s,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)wy(t,e),t=t.sibling}function wy(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Mt(t,e),qt(e),r&4){try{$s(3,e,e.return),_a(3,e)}catch(x){_e(e,e.return,x)}try{$s(5,e,e.return)}catch(x){_e(e,e.return,x)}}break;case 1:Mt(t,e),qt(e),r&512&&n!==null&&Fr(n,n.return);break;case 5:if(Mt(t,e),qt(e),r&512&&n!==null&&Fr(n,n.return),e.flags&32){var s=e.stateNode;try{ti(s,"")}catch(x){_e(e,e.return,x)}}if(r&4&&(s=e.stateNode,s!=null)){var i=e.memoizedProps,o=n!==null?n.memoizedProps:i,a=e.type,l=e.updateQueue;if(e.updateQueue=null,l!==null)try{a==="input"&&i.type==="radio"&&i.name!=null&&Um(s,i),su(a,o);var u=su(a,i);for(o=0;o<l.length;o+=2){var f=l[o],d=l[o+1];f==="style"?Km(s,d):f==="dangerouslySetInnerHTML"?Wm(s,d):f==="children"?ti(s,d):vc(s,f,d,u)}switch(a){case"input":Zl(s,i);break;case"textarea":Vm(s,i);break;case"select":var h=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!i.multiple;var p=i.value;p!=null?$r(s,!!i.multiple,p,!1):h!==!!i.multiple&&(i.defaultValue!=null?$r(s,!!i.multiple,i.defaultValue,!0):$r(s,!!i.multiple,i.multiple?[]:"",!1))}s[ci]=i}catch(x){_e(e,e.return,x)}}break;case 6:if(Mt(t,e),qt(e),r&4){if(e.stateNode===null)throw Error(F(162));s=e.stateNode,i=e.memoizedProps;try{s.nodeValue=i}catch(x){_e(e,e.return,x)}}break;case 3:if(Mt(t,e),qt(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{ii(t.containerInfo)}catch(x){_e(e,e.return,x)}break;case 4:Mt(t,e),qt(e);break;case 13:Mt(t,e),qt(e),s=e.child,s.flags&8192&&(i=s.memoizedState!==null,s.stateNode.isHidden=i,!i||s.alternate!==null&&s.alternate.memoizedState!==null||(Jc=Te())),r&4&&th(e);break;case 22:if(f=n!==null&&n.memoizedState!==null,e.mode&1?(We=(u=We)||f,Mt(t,e),We=u):Mt(t,e),qt(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!f&&e.mode&1)for(q=e,f=e.child;f!==null;){for(d=q=f;q!==null;){switch(h=q,p=h.child,h.tag){case 0:case 11:case 14:case 15:$s(4,h,h.return);break;case 1:Fr(h,h.return);var g=h.stateNode;if(typeof g.componentWillUnmount=="function"){r=h,n=h.return;try{t=r,g.props=t.memoizedProps,g.state=t.memoizedState,g.componentWillUnmount()}catch(x){_e(r,n,x)}}break;case 5:Fr(h,h.return);break;case 22:if(h.memoizedState!==null){rh(d);continue}}p!==null?(p.return=h,q=p):rh(d)}f=f.sibling}e:for(f=null,d=e;;){if(d.tag===5){if(f===null){f=d;try{s=d.stateNode,u?(i=s.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(a=d.stateNode,l=d.memoizedProps.style,o=l!=null&&l.hasOwnProperty("display")?l.display:null,a.style.display=qm("display",o))}catch(x){_e(e,e.return,x)}}}else if(d.tag===6){if(f===null)try{d.stateNode.nodeValue=u?"":d.memoizedProps}catch(x){_e(e,e.return,x)}}else if((d.tag!==22&&d.tag!==23||d.memoizedState===null||d===e)&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===e)break e;for(;d.sibling===null;){if(d.return===null||d.return===e)break e;f===d&&(f=null),d=d.return}f===d&&(f=null),d.sibling.return=d.return,d=d.sibling}}break;case 19:Mt(t,e),qt(e),r&4&&th(e);break;case 21:break;default:Mt(t,e),qt(e)}}function qt(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(vy(n)){var r=n;break e}n=n.return}throw Error(F(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(ti(s,""),r.flags&=-33);var i=eh(e);Mu(e,i,s);break;case 3:case 4:var o=r.stateNode.containerInfo,a=eh(e);Nu(e,a,o);break;default:throw Error(F(161))}}catch(l){_e(e,e.return,l)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Yk(e,t,n){q=e,Sy(e)}function Sy(e,t,n){for(var r=(e.mode&1)!==0;q!==null;){var s=q,i=s.child;if(s.tag===22&&r){var o=s.memoizedState!==null||Gi;if(!o){var a=s.alternate,l=a!==null&&a.memoizedState!==null||We;a=Gi;var u=We;if(Gi=o,(We=l)&&!u)for(q=s;q!==null;)o=q,l=o.child,o.tag===22&&o.memoizedState!==null?sh(s):l!==null?(l.return=o,q=l):sh(s);for(;i!==null;)q=i,Sy(i),i=i.sibling;q=s,Gi=a,We=u}nh(e)}else s.subtreeFlags&8772&&i!==null?(i.return=s,q=i):nh(e)}}function nh(e){for(;q!==null;){var t=q;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:We||_a(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!We)if(n===null)r.componentDidMount();else{var s=t.elementType===t.type?n.memoizedProps:Lt(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&Bf(t,i,r);break;case 3:var o=t.updateQueue;if(o!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}Bf(t,o,n)}break;case 5:var a=t.stateNode;if(n===null&&t.flags&4){n=a;var l=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":l.autoFocus&&n.focus();break;case"img":l.src&&(n.src=l.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var f=u.memoizedState;if(f!==null){var d=f.dehydrated;d!==null&&ii(d)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(F(163))}We||t.flags&512&&ju(t)}catch(h){_e(t,t.return,h)}}if(t===e){q=null;break}if(n=t.sibling,n!==null){n.return=t.return,q=n;break}q=t.return}}function rh(e){for(;q!==null;){var t=q;if(t===e){q=null;break}var n=t.sibling;if(n!==null){n.return=t.return,q=n;break}q=t.return}}function sh(e){for(;q!==null;){var t=q;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{_a(4,t)}catch(l){_e(t,n,l)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(l){_e(t,s,l)}}var i=t.return;try{ju(t)}catch(l){_e(t,i,l)}break;case 5:var o=t.return;try{ju(t)}catch(l){_e(t,o,l)}}}catch(l){_e(t,t.return,l)}if(t===e){q=null;break}var a=t.sibling;if(a!==null){a.return=t.return,q=a;break}q=t.return}}var Jk=Math.ceil,qo=vn.ReactCurrentDispatcher,Qc=vn.ReactCurrentOwner,Rt=vn.ReactCurrentBatchConfig,le=0,ze=null,Ae=null,$e=0,yt=0,Br=Wn(0),Le=0,gi=null,cr=0,Ea=0,Yc=0,Us=null,at=null,Jc=0,ts=1/0,ln=null,Ko=!1,Lu=null,Ln=null,Qi=!1,Rn=null,Go=0,Vs=0,Du=null,vo=-1,xo=0;function et(){return le&6?Te():vo!==-1?vo:vo=Te()}function Dn(e){return e.mode&1?le&2&&$e!==0?$e&-$e:Mk.transition!==null?(xo===0&&(xo=ig()),xo):(e=ce,e!==0||(e=window.event,e=e===void 0?16:fg(e.type)),e):1}function Bt(e,t,n,r){if(50<Vs)throw Vs=0,Du=null,Error(F(185));_i(e,n,r),(!(le&2)||e!==ze)&&(e===ze&&(!(le&2)&&(Ea|=n),Le===4&&Tn(e,$e)),ht(e,r),n===1&&le===0&&!(t.mode&1)&&(ts=Te()+500,ba&&qn()))}function ht(e,t){var n=e.callbackNode;Mb(e,t);var r=Ao(e,e===ze?$e:0);if(r===0)n!==null&&hf(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&hf(n),t===1)e.tag===0?Nk(ih.bind(null,e)):Ag(ih.bind(null,e)),Rk(function(){!(le&6)&&qn()}),n=null;else{switch(og(r)){case 1:n=kc;break;case 4:n=rg;break;case 16:n=Po;break;case 536870912:n=sg;break;default:n=Po}n=Ry(n,by.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function by(e,t){if(vo=-1,xo=0,le&6)throw Error(F(327));var n=e.callbackNode;if(qr()&&e.callbackNode!==n)return null;var r=Ao(e,e===ze?$e:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Qo(e,r);else{t=r;var s=le;le|=2;var i=Cy();(ze!==e||$e!==t)&&(ln=null,ts=Te()+500,rr(e,t));do try{eC();break}catch(a){ky(e,a)}while(!0);Dc(),qo.current=i,le=s,Ae!==null?t=0:(ze=null,$e=0,t=Le)}if(t!==0){if(t===2&&(s=uu(e),s!==0&&(r=s,t=Ou(e,s))),t===1)throw n=gi,rr(e,0),Tn(e,r),ht(e,Te()),n;if(t===6)Tn(e,r);else{if(s=e.current.alternate,!(r&30)&&!Xk(s)&&(t=Qo(e,r),t===2&&(i=uu(e),i!==0&&(r=i,t=Ou(e,i))),t===1))throw n=gi,rr(e,0),Tn(e,r),ht(e,Te()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(F(345));case 2:Xn(e,at,ln);break;case 3:if(Tn(e,r),(r&130023424)===r&&(t=Jc+500-Te(),10<t)){if(Ao(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){et(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=yu(Xn.bind(null,e,at,ln),t);break}Xn(e,at,ln);break;case 4:if(Tn(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var o=31-Ft(r);i=1<<o,o=t[o],o>s&&(s=o),r&=~i}if(r=s,r=Te()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Jk(r/1960))-r,10<r){e.timeoutHandle=yu(Xn.bind(null,e,at,ln),r);break}Xn(e,at,ln);break;case 5:Xn(e,at,ln);break;default:throw Error(F(329))}}}return ht(e,Te()),e.callbackNode===n?by.bind(null,e):null}function Ou(e,t){var n=Us;return e.current.memoizedState.isDehydrated&&(rr(e,t).flags|=256),e=Qo(e,t),e!==2&&(t=at,at=n,t!==null&&zu(t)),e}function zu(e){at===null?at=e:at.push.apply(at,e)}function Xk(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var s=n[r],i=s.getSnapshot;s=s.value;try{if(!Ut(i(),s))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 Tn(e,t){for(t&=~Yc,t&=~Ea,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Ft(t),r=1<<n;e[n]=-1,t&=~r}}function ih(e){if(le&6)throw Error(F(327));qr();var t=Ao(e,0);if(!(t&1))return ht(e,Te()),null;var n=Qo(e,t);if(e.tag!==0&&n===2){var r=uu(e);r!==0&&(t=r,n=Ou(e,r))}if(n===1)throw n=gi,rr(e,0),Tn(e,t),ht(e,Te()),n;if(n===6)throw Error(F(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Xn(e,at,ln),ht(e,Te()),null}function Xc(e,t){var n=le;le|=1;try{return e(t)}finally{le=n,le===0&&(ts=Te()+500,ba&&qn())}}function dr(e){Rn!==null&&Rn.tag===0&&!(le&6)&&qr();var t=le;le|=1;var n=Rt.transition,r=ce;try{if(Rt.transition=null,ce=1,e)return e()}finally{ce=r,Rt.transition=n,le=t,!(le&6)&&qn()}}function Zc(){yt=Br.current,ye(Br)}function rr(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,Ik(n)),Ae!==null)for(n=Ae.return;n!==null;){var r=n;switch(Nc(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Do();break;case 3:Zr(),ye(dt),ye(Ge),Uc();break;case 5:$c(r);break;case 4:Zr();break;case 13:ye(we);break;case 19:ye(we);break;case 10:Oc(r.type._context);break;case 22:case 23:Zc()}n=n.return}if(ze=e,Ae=e=On(e.current,null),$e=yt=t,Le=0,gi=null,Yc=Ea=cr=0,at=Us=null,tr!==null){for(t=0;t<tr.length;t++)if(n=tr[t],r=n.interleaved,r!==null){n.interleaved=null;var s=r.next,i=n.pending;if(i!==null){var o=i.next;i.next=s,r.next=o}n.pending=r}tr=null}return e}function ky(e,t){do{var n=Ae;try{if(Dc(),mo.current=Wo,Ho){for(var r=be.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}Ho=!1}if(ur=0,Oe=Me=be=null,Bs=!1,hi=0,Qc.current=null,n===null||n.return===null){Le=1,gi=t,Ae=null;break}e:{var i=e,o=n.return,a=n,l=t;if(t=$e,a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){var u=l,f=a,d=f.tag;if(!(f.mode&1)&&(d===0||d===11||d===15)){var h=f.alternate;h?(f.updateQueue=h.updateQueue,f.memoizedState=h.memoizedState,f.lanes=h.lanes):(f.updateQueue=null,f.memoizedState=null)}var p=qf(o);if(p!==null){p.flags&=-257,Kf(p,o,a,i,t),p.mode&1&&Wf(i,u,t),t=p,l=u;var g=t.updateQueue;if(g===null){var x=new Set;x.add(l),t.updateQueue=x}else g.add(l);break e}else{if(!(t&1)){Wf(i,u,t),ed();break e}l=Error(F(426))}}else if(xe&&a.mode&1){var k=qf(o);if(k!==null){!(k.flags&65536)&&(k.flags|=256),Kf(k,o,a,i,t),Mc(es(l,a));break e}}i=l=es(l,a),Le!==4&&(Le=2),Us===null?Us=[i]:Us.push(i),i=o;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var y=oy(i,l,t);Ff(i,y);break e;case 1:a=l;var v=i.type,w=i.stateNode;if(!(i.flags&128)&&(typeof v.getDerivedStateFromError=="function"||w!==null&&typeof w.componentDidCatch=="function"&&(Ln===null||!Ln.has(w)))){i.flags|=65536,t&=-t,i.lanes|=t;var E=ay(i,a,t);Ff(i,E);break e}}i=i.return}while(i!==null)}Ey(n)}catch(I){t=I,Ae===n&&n!==null&&(Ae=n=n.return);continue}break}while(!0)}function Cy(){var e=qo.current;return qo.current=Wo,e===null?Wo:e}function ed(){(Le===0||Le===3||Le===2)&&(Le=4),ze===null||!(cr&268435455)&&!(Ea&268435455)||Tn(ze,$e)}function Qo(e,t){var n=le;le|=2;var r=Cy();(ze!==e||$e!==t)&&(ln=null,rr(e,t));do try{Zk();break}catch(s){ky(e,s)}while(!0);if(Dc(),le=n,qo.current=r,Ae!==null)throw Error(F(261));return ze=null,$e=0,Le}function Zk(){for(;Ae!==null;)_y(Ae)}function eC(){for(;Ae!==null&&!_b();)_y(Ae)}function _y(e){var t=Iy(e.alternate,e,yt);e.memoizedProps=e.pendingProps,t===null?Ey(e):Ae=t,Qc.current=null}function Ey(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=Kk(n,t),n!==null){n.flags&=32767,Ae=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Le=6,Ae=null;return}}else if(n=qk(n,t,yt),n!==null){Ae=n;return}if(t=t.sibling,t!==null){Ae=t;return}Ae=t=e}while(t!==null);Le===0&&(Le=5)}function Xn(e,t,n){var r=ce,s=Rt.transition;try{Rt.transition=null,ce=1,tC(e,t,n,r)}finally{Rt.transition=s,ce=r}return null}function tC(e,t,n,r){do qr();while(Rn!==null);if(le&6)throw Error(F(327));n=e.finishedWork;var s=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(F(177));e.callbackNode=null,e.callbackPriority=0;var i=n.lanes|n.childLanes;if(Lb(e,i),e===ze&&(Ae=ze=null,$e=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Qi||(Qi=!0,Ry(Po,function(){return qr(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=Rt.transition,Rt.transition=null;var o=ce;ce=1;var a=le;le|=4,Qc.current=null,Qk(e,n),wy(n,e),Sk(mu),jo=!!pu,mu=pu=null,e.current=n,Yk(n),Eb(),le=a,ce=o,Rt.transition=i}else e.current=n;if(Qi&&(Qi=!1,Rn=e,Go=s),i=e.pendingLanes,i===0&&(Ln=null),Rb(n.stateNode),ht(e,Te()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)s=t[n],r(s.value,{componentStack:s.stack,digest:s.digest});if(Ko)throw Ko=!1,e=Lu,Lu=null,e;return Go&1&&e.tag!==0&&qr(),i=e.pendingLanes,i&1?e===Du?Vs++:(Vs=0,Du=e):Vs=0,qn(),null}function qr(){if(Rn!==null){var e=og(Go),t=Rt.transition,n=ce;try{if(Rt.transition=null,ce=16>e?16:e,Rn===null)var r=!1;else{if(e=Rn,Rn=null,Go=0,le&6)throw Error(F(331));var s=le;for(le|=4,q=e.current;q!==null;){var i=q,o=i.child;if(q.flags&16){var a=i.deletions;if(a!==null){for(var l=0;l<a.length;l++){var u=a[l];for(q=u;q!==null;){var f=q;switch(f.tag){case 0:case 11:case 15:$s(8,f,i)}var d=f.child;if(d!==null)d.return=f,q=d;else for(;q!==null;){f=q;var h=f.sibling,p=f.return;if(yy(f),f===u){q=null;break}if(h!==null){h.return=p,q=h;break}q=p}}}var g=i.alternate;if(g!==null){var x=g.child;if(x!==null){g.child=null;do{var k=x.sibling;x.sibling=null,x=k}while(x!==null)}}q=i}}if(i.subtreeFlags&2064&&o!==null)o.return=i,q=o;else e:for(;q!==null;){if(i=q,i.flags&2048)switch(i.tag){case 0:case 11:case 15:$s(9,i,i.return)}var y=i.sibling;if(y!==null){y.return=i.return,q=y;break e}q=i.return}}var v=e.current;for(q=v;q!==null;){o=q;var w=o.child;if(o.subtreeFlags&2064&&w!==null)w.return=o,q=w;else e:for(o=v;q!==null;){if(a=q,a.flags&2048)try{switch(a.tag){case 0:case 11:case 15:_a(9,a)}}catch(I){_e(a,a.return,I)}if(a===o){q=null;break e}var E=a.sibling;if(E!==null){E.return=a.return,q=E;break e}q=a.return}}if(le=s,qn(),Xt&&typeof Xt.onPostCommitFiberRoot=="function")try{Xt.onPostCommitFiberRoot(ya,e)}catch{}r=!0}return r}finally{ce=n,Rt.transition=t}}return!1}function oh(e,t,n){t=es(n,t),t=oy(e,t,1),e=Mn(e,t,1),t=et(),e!==null&&(_i(e,1,t),ht(e,t))}function _e(e,t,n){if(e.tag===3)oh(e,e,n);else for(;t!==null;){if(t.tag===3){oh(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Ln===null||!Ln.has(r))){e=es(n,e),e=ay(t,e,1),t=Mn(t,e,1),e=et(),t!==null&&(_i(t,1,e),ht(t,e));break}}t=t.return}}function nC(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=et(),e.pingedLanes|=e.suspendedLanes&n,ze===e&&($e&n)===n&&(Le===4||Le===3&&($e&130023424)===$e&&500>Te()-Jc?rr(e,0):Yc|=n),ht(e,t)}function Ty(e,t){t===0&&(e.mode&1?(t=Fi,Fi<<=1,!(Fi&130023424)&&(Fi=4194304)):t=1);var n=et();e=gn(e,t),e!==null&&(_i(e,t,n),ht(e,n))}function rC(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ty(e,n)}function sC(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(F(314))}r!==null&&r.delete(t),Ty(e,n)}var Iy;Iy=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||dt.current)ut=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ut=!1,Wk(e,t,n);ut=!!(e.flags&131072)}else ut=!1,xe&&t.flags&1048576&&jg(t,Fo,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;yo(e,t),e=t.pendingProps;var s=Yr(t,Ge.current);Wr(t,n),s=Hc(null,t,r,e,s,n);var i=Wc();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,ft(r)?(i=!0,Oo(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,Fc(t),s.updater=Ca,t.stateNode=s,s._reactInternals=t,Cu(t,r,e,n),t=Tu(null,t,r,!0,i,n)):(t.tag=0,xe&&i&&jc(t),Xe(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(yo(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=oC(r),e=Lt(r,e),s){case 0:t=Eu(null,t,r,e,n);break e;case 1:t=Yf(null,t,r,e,n);break e;case 11:t=Gf(null,t,r,e,n);break e;case 14:t=Qf(null,t,r,Lt(r.type,e),n);break e}throw Error(F(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Lt(r,s),Eu(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Lt(r,s),Yf(e,t,r,s,n);case 3:e:{if(dy(t),e===null)throw Error(F(387));r=t.pendingProps,i=t.memoizedState,s=i.element,zg(e,t),Uo(t,r,null,n);var o=t.memoizedState;if(r=o.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){s=es(Error(F(423)),t),t=Jf(e,t,r,n,s);break e}else if(r!==s){s=es(Error(F(424)),t),t=Jf(e,t,r,n,s);break e}else for(vt=Nn(t.stateNode.containerInfo.firstChild),xt=t,xe=!0,Ot=null,n=Dg(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Jr(),r===s){t=yn(e,t,n);break e}Xe(e,t,r,n)}t=t.child}return t;case 5:return Fg(t),e===null&&Su(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,o=s.children,gu(r,s)?o=null:i!==null&&gu(r,i)&&(t.flags|=32),cy(e,t),Xe(e,t,o,n),t.child;case 6:return e===null&&Su(t),null;case 13:return fy(e,t,n);case 4:return Bc(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Xr(t,null,r,n):Xe(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Lt(r,s),Gf(e,t,r,s,n);case 7:return Xe(e,t,t.pendingProps,n),t.child;case 8:return Xe(e,t,t.pendingProps.children,n),t.child;case 12:return Xe(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,i=t.memoizedProps,o=s.value,pe(Bo,r._currentValue),r._currentValue=o,i!==null)if(Ut(i.value,o)){if(i.children===s.children&&!dt.current){t=yn(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var a=i.dependencies;if(a!==null){o=i.child;for(var l=a.firstContext;l!==null;){if(l.context===r){if(i.tag===1){l=hn(-1,n&-n),l.tag=2;var u=i.updateQueue;if(u!==null){u=u.shared;var f=u.pending;f===null?l.next=l:(l.next=f.next,f.next=l),u.pending=l}}i.lanes|=n,l=i.alternate,l!==null&&(l.lanes|=n),bu(i.return,n,t),a.lanes|=n;break}l=l.next}}else if(i.tag===10)o=i.type===t.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error(F(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),bu(o,n,t),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===t){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}Xe(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Wr(t,n),s=At(s),r=r(s),t.flags|=1,Xe(e,t,r,n),t.child;case 14:return r=t.type,s=Lt(r,t.pendingProps),s=Lt(r.type,s),Qf(e,t,r,s,n);case 15:return ly(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Lt(r,s),yo(e,t),t.tag=1,ft(r)?(e=!0,Oo(t)):e=!1,Wr(t,n),iy(t,r,s),Cu(t,r,s,n),Tu(null,t,r,!0,e,n);case 19:return hy(e,t,n);case 22:return uy(e,t,n)}throw Error(F(156,t.tag))};function Ry(e,t){return ng(e,t)}function iC(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.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 It(e,t,n,r){return new iC(e,t,n,r)}function td(e){return e=e.prototype,!(!e||!e.isReactComponent)}function oC(e){if(typeof e=="function")return td(e)?1:0;if(e!=null){if(e=e.$$typeof,e===wc)return 11;if(e===Sc)return 14}return 2}function On(e,t){var n=e.alternate;return n===null?(n=It(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&14680064,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}function wo(e,t,n,r,s,i){var o=2;if(r=e,typeof e=="function")td(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case Pr:return sr(n.children,s,i,t);case xc:o=8,s|=8;break;case Gl:return e=It(12,n,t,s|2),e.elementType=Gl,e.lanes=i,e;case Ql:return e=It(13,n,t,s),e.elementType=Ql,e.lanes=i,e;case Yl:return e=It(19,n,t,s),e.elementType=Yl,e.lanes=i,e;case Fm:return Ta(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Om:o=10;break e;case zm:o=9;break e;case wc:o=11;break e;case Sc:o=14;break e;case kn:o=16,r=null;break e}throw Error(F(130,e==null?e:typeof e,""))}return t=It(o,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function sr(e,t,n,r){return e=It(7,e,r,t),e.lanes=n,e}function Ta(e,t,n,r){return e=It(22,e,r,t),e.elementType=Fm,e.lanes=n,e.stateNode={isHidden:!1},e}function wl(e,t,n){return e=It(6,e,null,t),e.lanes=n,e}function Sl(e,t,n){return t=It(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function aC(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=tl(0),this.expirationTimes=tl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=tl(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function nd(e,t,n,r,s,i,o,a,l){return e=new aC(e,t,n,a,l),t===1?(t=1,i===!0&&(t|=8)):t=0,i=It(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Fc(i),e}function lC(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Rr,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function Py(e){if(!e)return Bn;e=e._reactInternals;e:{if(gr(e)!==e||e.tag!==1)throw Error(F(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(ft(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(F(171))}if(e.tag===1){var n=e.type;if(ft(n))return Pg(e,n,t)}return t}function Ay(e,t,n,r,s,i,o,a,l){return e=nd(n,r,!0,e,s,i,o,a,l),e.context=Py(null),n=e.current,r=et(),s=Dn(n),i=hn(r,s),i.callback=t??null,Mn(n,i,s),e.current.lanes=s,_i(e,s,r),ht(e,r),e}function Ia(e,t,n,r){var s=t.current,i=et(),o=Dn(s);return n=Py(n),t.context===null?t.context=n:t.pendingContext=n,t=hn(i,o),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=Mn(s,t,o),e!==null&&(Bt(e,s,o,i),po(e,s,o)),o}function Yo(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function ah(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function rd(e,t){ah(e,t),(e=e.alternate)&&ah(e,t)}function uC(){return null}var jy=typeof reportError=="function"?reportError:function(e){console.error(e)};function sd(e){this._internalRoot=e}Ra.prototype.render=sd.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(F(409));Ia(e,t,null,null)};Ra.prototype.unmount=sd.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;dr(function(){Ia(null,e,null,null)}),t[mn]=null}};function Ra(e){this._internalRoot=e}Ra.prototype.unstable_scheduleHydration=function(e){if(e){var t=ug();e={blockedOn:null,target:e,priority:t};for(var n=0;n<En.length&&t!==0&&t<En[n].priority;n++);En.splice(n,0,e),n===0&&dg(e)}};function id(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Pa(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function lh(){}function cC(e,t,n,r,s){if(s){if(typeof r=="function"){var i=r;r=function(){var u=Yo(o);i.call(u)}}var o=Ay(t,r,e,0,null,!1,!1,"",lh);return e._reactRootContainer=o,e[mn]=o.current,li(e.nodeType===8?e.parentNode:e),dr(),o}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var a=r;r=function(){var u=Yo(l);a.call(u)}}var l=nd(e,0,!1,null,null,!1,!1,"",lh);return e._reactRootContainer=l,e[mn]=l.current,li(e.nodeType===8?e.parentNode:e),dr(function(){Ia(t,l,n,r)}),l}function Aa(e,t,n,r,s){var i=n._reactRootContainer;if(i){var o=i;if(typeof s=="function"){var a=s;s=function(){var l=Yo(o);a.call(l)}}Ia(t,o,e,s)}else o=cC(n,t,e,s,r);return Yo(o)}ag=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Ns(t.pendingLanes);n!==0&&(Cc(t,n|1),ht(t,Te()),!(le&6)&&(ts=Te()+500,qn()))}break;case 13:dr(function(){var r=gn(e,1);if(r!==null){var s=et();Bt(r,e,1,s)}}),rd(e,1)}};_c=function(e){if(e.tag===13){var t=gn(e,134217728);if(t!==null){var n=et();Bt(t,e,134217728,n)}rd(e,134217728)}};lg=function(e){if(e.tag===13){var t=Dn(e),n=gn(e,t);if(n!==null){var r=et();Bt(n,e,t,r)}rd(e,t)}};ug=function(){return ce};cg=function(e,t){var n=ce;try{return ce=e,t()}finally{ce=n}};ou=function(e,t,n){switch(t){case"input":if(Zl(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var s=Sa(r);if(!s)throw Error(F(90));$m(r),Zl(r,s)}}}break;case"textarea":Vm(e,n);break;case"select":t=n.value,t!=null&&$r(e,!!n.multiple,t,!1)}};Ym=Xc;Jm=dr;var dC={usingClientEntryPoint:!1,Events:[Ti,Mr,Sa,Gm,Qm,Xc]},Es={findFiberByHostInstance:er,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},fC={bundleType:Es.bundleType,version:Es.version,rendererPackageName:Es.rendererPackageName,rendererConfig:Es.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:vn.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=eg(e),e===null?null:e.stateNode},findFiberByHostInstance:Es.findFiberByHostInstance||uC,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Yi=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Yi.isDisabled&&Yi.supportsFiber)try{ya=Yi.inject(fC),Xt=Yi}catch{}}kt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=dC;kt.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!id(t))throw Error(F(200));return lC(e,t,null,n)};kt.createRoot=function(e,t){if(!id(e))throw Error(F(299));var n=!1,r="",s=jy;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=nd(e,1,!1,null,null,n,!1,r,s),e[mn]=t.current,li(e.nodeType===8?e.parentNode:e),new sd(t)};kt.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(F(188)):(e=Object.keys(e).join(","),Error(F(268,e)));return e=eg(t),e=e===null?null:e.stateNode,e};kt.flushSync=function(e){return dr(e)};kt.hydrate=function(e,t,n){if(!Pa(t))throw Error(F(200));return Aa(null,e,t,!0,n)};kt.hydrateRoot=function(e,t,n){if(!id(e))throw Error(F(405));var r=n!=null&&n.hydratedSources||null,s=!1,i="",o=jy;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(o=n.onRecoverableError)),t=Ay(t,null,e,1,n??null,s,!1,i,o),e[mn]=t.current,li(e),r)for(e=0;e<r.length;e++)n=r[e],s=n._getVersion,s=s(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,s]:t.mutableSourceEagerHydrationData.push(n,s);return new Ra(t)};kt.render=function(e,t,n){if(!Pa(t))throw Error(F(200));return Aa(null,e,t,!1,n)};kt.unmountComponentAtNode=function(e){if(!Pa(e))throw Error(F(40));return e._reactRootContainer?(dr(function(){Aa(null,null,e,!1,function(){e._reactRootContainer=null,e[mn]=null})}),!0):!1};kt.unstable_batchedUpdates=Xc;kt.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Pa(n))throw Error(F(200));if(e==null||e._reactInternals===void 0)throw Error(F(38));return Aa(e,t,n,!1,r)};kt.version="18.3.1-next-f1338f8080-20240426";function Ny(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Ny)}catch(e){console.error(e)}}Ny(),Nm.exports=kt;var hC=Nm.exports,My,uh=hC;My=uh.createRoot,uh.hydrateRoot;function pC(e,t){const n=e[Ly];if(!n)throw new Error("ResourceElement.type is not a valid Resource");return n(t)}const Ly=Symbol("fnSymbol");function ie(e){const t=n=>({type:t,props:n});return t[Ly]=e,t}function nn(e,t){return{...t,key:e}}let Hs=null;function mC(e,t){e.currentIndex=0;const n=Hs;Hs=e;try{if(t(),e.isFirstRender=!1,e.cells.length!==e.currentIndex)throw new Error(`Rendered ${e.currentIndex} hooks but expected ${e.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{Hs=n}}function $n(){if(!Hs)throw new Error("No resource fiber available");return Hs}function gC(e){return null}const Dy=e=>({version:0,committedVersion:0,dispatchUpdate:e,changelog:[],dirtyCells:[]}),Jo=e=>{for(const 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},Ws=(e,t)=>{const n=e.version>t;if(e.version=t,n){for(const r of e.dirtyCells)r.dirty=!1,r.queue.clear(),r.workInProgress=r.current;if(e.dirtyCells.length=0,t===e.committedVersion)e.changelog.length=0;else{if(e.committedVersion>t)throw new Error("Version is less than committed version");for(;e.committedVersion+e.changelog.length>t;)e.changelog.pop();e.changelog.forEach(r=>r()),Jo(e)}}},ch=(e,t)=>{t.dirty||(t.dirty=!0,e.markDirty?.(),e.root.dirtyCells.push(t))},Oy=(e,t)=>{const n=$n(),r=n.currentIndex++;if(!n.isFirstRender&&r>=n.cells.length)throw new Error("Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.");let s=n.cells[r];if(s||(s=t(),n.cells[r]=s),s.type!==e)throw new Error("Hook order changed between renders");return s},yC=e=>{$n().renderContext.effectTasks.push(e)},vC=(e,t)=>{if(e.renderContext)throw new Error("Resource updated during render");if(e.isNeverMounted)throw new Error("Resource updated before mount");e.root.dispatchUpdate(()=>{const n=t();return n?(n(),e.root.changelog.push(n),!0):!1})};function zy(e,t,n,r){const s=Oy("reducer",()=>{const a=$n(),l=r?r(n):n;return{type:"reducer",queue:new Set,dirty:!1,workInProgress:l,current:l,reducer:e,dispatch:u=>{const f={action:u,hasEagerState:!1,eagerState:void 0};vC(a,()=>a.root.dirtyCells.length===0&&!f.hasEagerState&&(f.eagerState=e(s.workInProgress,u),f.hasEagerState=!0,Object.is(s.current,f.eagerState))?null:()=>{ch(a,s),s.queue.add(f)})}}}),i=$n(),o=e===s.reducer;s.reducer=e;for(const a of s.queue)(!a.hasEagerState||!o)&&(a.eagerState=e(s.workInProgress,a.action),a.hasEagerState=!0),s.workInProgress=a.eagerState;if(s.queue.clear(),t){const a=t(s.workInProgress);Object.is(a,s.workInProgress)||(ch(i,s),s.workInProgress=a)}return[s.workInProgress,s.dispatch]}function xC(e,t,n){return zy(e,void 0,t,n)}function wC(e,t,n,r){return zy(e,t,n,r)}const SC=(e,t)=>typeof t=="function"?t(e):t,bC=e=>typeof e=="function"?e():e;function bt(e){return xC(SC,e,bC)}const Fy=(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},kC=()=>({type:"effect",cleanup:void 0,deps:null});function Ie(e,t){const n=Oy("effect",kC);if(!(t&&n.deps&&Fy(n.deps,t))){if(n.deps!==null&&!!t!=!!n.deps)throw new Error("tapEffect called with and without dependencies across re-renders");yC(()=>{const r=[];try{n.cleanup?.()}catch(s){r.push(s)}finally{n.cleanup=void 0}try{const s=e();if(s!==void 0&&typeof s!="function")throw new Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof s}`);n.cleanup=s}catch(s){r.push(s)}if(n.deps=t,r.length>0){if(r.length===1)throw r[0];for(const s of r)console.error(s);throw new AggregateError(r,"Errors during commit")}})}}function en(e){const[t]=bt(()=>({current:e}));return t}function ir(e,t){const[n]=bt(e);return n}const CC=()=>{throw new Error("Memo reducer should not be called")},te=(e,t)=>{$n();const[n]=wC(CC,r=>r&&Fy(r.deps,t)?r:{value:e(),deps:t},null);return n.value},yi=(e,t)=>te(()=>e,t);function tn(e){const t=en(e);Ie(()=>{t.current=e});const n=$n();return yi((...r)=>t.current(...r),[n])}function _C(e){const t=[];for(const n of e.effectTasks)try{n()}catch(r){t.push(r)}if(t.length>0){if(t.length===1)throw t[0];for(const n of t)console.error(n);throw new AggregateError(t,"Errors during commit")}}function EC(e){const t=[];for(const n of e.cells)if(n?.type==="effect"&&(n.deps=null,n.cleanup))try{n.cleanup?.()}catch(r){t.push(r)}finally{n.cleanup=void 0}if(t.length>0){if(t.length===1)throw t[0];for(const n of t)console.error(n);throw new AggregateError(t,"Errors during cleanup")}}function vi(e,t,n=void 0,r=gC()){return{type:e,root:t,markDirty:n,devStrictMode:r,cells:[],currentIndex:0,renderContext:void 0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function Kr(e){if(!e.isMounted)throw new Error("Tried to unmount a fiber that is already unmounted");e.isMounted=!1,EC(e)}function zn(e,t){const n={effectTasks:[],props:t,output:void 0};return mC(e,()=>{e.renderContext=n;try{n.output=pC(e.type,t)}finally{e.renderContext=void 0}}),n}function ns(e,t){e.isMounted=!0,e.isNeverMounted=!1,_C(t)}function Be(e,t){const n=$n(),r=en(0),s=te(()=>(e.key,vi(e.type,n.root,()=>{r.current++,n.markDirty?.()})),[e.type,e.key,n]),i=t?te(()=>zn(s,e.props),[s,...t,r.current]):zn(s,e.props);return Ie(()=>()=>Kr(s),[s]),Ie(()=>{ns(s,i)},[s,i]),i.output}function ja(e,t){const n=en(0),r=n.current,s=ir($n),i=ir(()=>()=>{n.current++,s.markDirty?.()}),o=ir(()=>new Map),a=t?yi(e,t):e,l=te(()=>{const u=a(),f=new Set,d=[];let h=0;for(let p=0;p<u.length;p++){const g=u[p],x=g.key;if(x===void 0)throw new Error(`tapResources did not provide a key for array at index ${p}`);if(f.has(x))throw new Error(`Duplicate key ${x} in tapResources`);f.add(x);let k=o.get(x);if(k)if(k.fiber.type!==g.type){const y=vi(g.type,s.root,i),v=zn(y,g.props);k.next=[y,v],d.push(v.output)}else k.next=zn(k.fiber,g.props),d.push(k.next.output);else{const y=vi(g.type,s.root,i),v=zn(y,g.props);k={fiber:y,next:v},h++,o.set(x,k),d.push(v.output)}}if(o.size>d.length-h)for(const p of o.keys())f.has(p)||(o.get(p).next="delete");return d},[a,r]);return Ie(()=>()=>{for(const u of o.keys()){const f=o.get(u).fiber;Kr(f)}},[]),Ie(()=>{for(const[u,f]of o.entries())f.next==="delete"?(f.fiber.isMounted&&Kr(f.fiber),o.delete(u)):Array.isArray(f.next)?(Kr(f.fiber),f.fiber=f.next[0],ns(f.fiber,f.next[1])):ns(f.fiber,f.next)},[l]),l}const TC=50;let Jt={schedulers:new Set([]),isScheduled:!1};var IC=class{constructor(e){T(this,"_task");T(this,"_isDirty",!1);this._task=e}get isDirty(){return this._isDirty}markDirty(){this._isDirty=!0,Jt.schedulers.add(this),RC()}runTask(){this._isDirty=!1,this._task()}};const RC=()=>{Jt.isScheduled||(Jt.isScheduled=!0,PC())},Fu=()=>{try{const e=[];let t=0;for(const n of Jt.schedulers)if(Jt.schedulers.delete(n),!!n.isDirty){if(t++,t>TC)throw new Error("Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside tapEffect.");try{n.runTask()}catch(r){e.push(r)}}if(e.length>0){if(e.length===1)throw e[0];for(const n of e)console.error(n);throw new AggregateError(e,"Errors occurred during flushSync")}}finally{Jt.schedulers.clear(),Jt.isScheduled=!1}},PC=(()=>{if(typeof MessageChannel<"u"){const e=new MessageChannel;return e.port1.onmessage=Fu,()=>e.port2.postMessage(null)}return()=>setTimeout(Fu,0)})(),dh=e=>{const t=Jt;Jt={schedulers:new Set([]),isScheduled:!0};try{const n=e();return Fu(),n}finally{Jt=t}},AC=e=>{const t=ir(()=>new IC(()=>u(null))),n=ir(()=>[]),r=te(()=>(e.key,vi(e.type,Dy(f=>{!t.isDirty&&!f()||(n.push(f),t.markDirty())}))),[e.type,e.key]);Ws(r.root,r.root.committedVersion);const s=zn(r,e.props),i=en(!1),o=en(e.props),a=en(s.output),l=ir(()=>new Set),u=tn(f=>{if(f===null&&(Ws(r.root,2),Ws(r.root,1),n.forEach(d=>{d()}),f=zn(r,o.current)),t.isDirty)throw new Error("Scheduler is dirty, this should never happen");Jo(r.root),n.length=0,i.current&&ns(r,f),!(t.isDirty||a.current===f.output)&&(a.current=f.output,l.forEach(d=>d()))});return Ie(()=>(i.current=!0,()=>{i.current=!1,Kr(r)}),[r]),Ie(()=>{o.current=s.props,Jo(r.root),ns(r,s),!(t.isDirty||a.current===s.output)&&(a.current=s.output,l.forEach(f=>f()))}),te(()=>({getValue:()=>a.current,subscribe:f=>(l.add(f),()=>l.delete(f))}),[])},qs=Symbol("tap.Context"),By=e=>({[qs]:e}),$y=(e,t,n)=>{const r=e[qs];e[qs]=t;try{return n()}finally{e[qs]=r}},Uy=e=>e[qs],jC=ie(()=>{const[e,t]=bt(()=>({renderers:{},fallbacks:[]}));return{getState:()=>e,setDataUI:yi((n,r)=>(t(s=>({...s,renderers:{...s.renderers,[n]:[...s.renderers[n]??[],r]}})),()=>{t(s=>({...s,renderers:{...s.renderers,[n]:s.renderers[n]?.filter(i=>i!==r)??[]}}))}),[]),setFallbackDataUI:yi(n=>(t(r=>({...r,fallbacks:[...r.fallbacks,n]})),()=>{t(r=>({...r,fallbacks:r.fallbacks.filter(s=>s!==n)}))}),[])}}),NC=e=>{const t=Array.from(e).map(r=>r.getModelContext()).sort((r,s)=>(s.priority??0)-(r.priority??0)),n={};return t.reduce((r,s)=>{const i=s.priority??0;if(s.system&&(r.system?r.system+=`
41
-
42
- ${s.system}`:r.system=s.system),s.tools)for(const[o,a]of Object.entries(s.tools)){const l=r.tools?.[o];if(l&&l!==a){const u=n[o];if(u===i)throw new Error(`You tried to define a tool with the name ${o}, but it already exists.`);const f=u>i?l:a,d=u>i?a:l;r.tools[o]={...d,...f},n[o]=Math.max(u,i);continue}r.tools||(r.tools={}),r.tools[o]=a,n[o]??(n[o]=i)}return s.config&&(r.config={...r.config,...s.config}),s.callSettings&&(r.callSettings={...r.callSettings,...s.callSettings}),r},{})};var od=class{constructor(){T(this,"_providers",new Set);T(this,"_subscribers",new Set)}getModelContext(){return NC(this._providers)}registerModelContextProvider(e){this._providers.add(e);const t=e.subscribe?.(()=>{this.notifySubscribers()});return this.notifySubscribers(),()=>{this._providers.delete(e),t?.(),this.notifySubscribers()}}notifySubscribers(){for(const e of this._subscribers)e()}subscribe(e){return this._subscribers.add(e),()=>this._subscribers.delete(e)}};const Bu=[],MC={modelName:void 0,toolNames:Bu},LC=(e,t)=>e===t||e.length===t.length&&e.every((n,r)=>n===t[r]),Ji=(e,t)=>{const n=e.getModelContext(),r=n.config?.modelName,s=n.tools?Object.keys(n.tools).sort():Bu,i=s.length?s:Bu;return r===t.modelName&&LC(i,t.toolNames)?t:{modelName:r,toolNames:i}},Vy=ie(()=>{const e=te(()=>new od,[]),[t,n]=bt(()=>Ji(e,MC));return Ie(()=>(n(r=>Ji(e,r)),e.subscribe(()=>{n(r=>Ji(e,r))})),[e]),{getState:()=>Ji(e,t),getModelContext:()=>e.getModelContext(),subscribe:r=>e.subscribe(r),register:r=>e.registerModelContextProvider(r)}}),DC=e=>e.display!==void 0?e.display==="standalone":e.type==="human",OC=(e,t)=>{if(!(t.status?.type==="running"||t.status?.type==="requires-action")){const r=e.complete;return typeof r!="function"?r??null:r({args:t.args,result:t.result})}const n=e.running;return typeof n!="function"?n??null:n({args:t.args})},zC=e=>function(n){return OC(e,n)},$u=Symbol("assistant-ui.store.clientIndex"),FC=e=>e[$u],Hy=By([]),ad=()=>Uy(Hy),BC=(e,t)=>{const n=ad();return $y(Hy,te(()=>[...n,e],[n,e]),t)},$C=new Set(["$$typeof","nodeType","then"]),Na=(e,t)=>{if(e===Symbol.toStringTag)return t;if(typeof e!="symbol"){if(e==="toJSON")return()=>t;if(!$C.has(e))return!1}};var ld=class{getOwnPropertyDescriptor(e,t){const 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}};const Wy=e=>{const t=ie(e);return n=>{const r=t(n);return n.key===void 0?r:nn(n.key,r)}},Xo=Symbol("assistant-ui.store.getValue"),UC=e=>{const t=e[Xo];if(!t)throw new 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?.()},fh=new Map;function VC(e){let t=fh.get(e);return t||(t=function(...n){if(!this||typeof this!="object")throw new Error(`Method "${String(e)}" called without proper context. This may indicate the function was called incorrectly.`);const r=this[Xo];if(!r)throw new Error(`Method "${String(e)}" called on invalid client proxy. Ensure you are calling this method on a valid client instance.`);const s=r[e];if(!s)throw new Error(`Method "${String(e)}" is not implemented.`);if(typeof s!="function")throw new Error(`"${String(e)}" is not a function.`);return s(...n)},fh.set(e,t)),t}var HC=class extends ld{constructor(t,n){super();T(this,"outputRef");T(this,"index");T(this,"boundFns");T(this,"cachedReceiver");this.outputRef=t,this.index=n}get(t,n,r){if(n===Xo)return this.outputRef.current;if(n===$u)return this.index;const s=Na(n,"ClientProxy");if(s!==!1)return s;const i=this.outputRef.current[n];if(typeof i=="function"){this.cachedReceiver!==r&&(this.boundFns=new Map,this.cachedReceiver=r);let o=this.boundFns.get(n);return o||(o=VC(n).bind(r),this.boundFns.set(n,o)),o}return i}ownKeys(){return Object.keys(this.outputRef.current)}has(t,n){return n===Xo||n===$u?!0:n in this.outputRef.current}};const qy=Wy(e=>{const t=en(null),n=ad().length,r=te(()=>new Proxy({},new HC(t,n)),[n]),s=BC(r,()=>Be(e));return t.current||(t.current=s),Ie(()=>{t.current=s}),{methods:r,state:s.getState?.(),key:e.key}}),Ma=e=>Be(qy(e)),Ks=Symbol("assistant-ui.store.proxiedAssistantState"),bl=e=>e==="on"||e==="subscribe"||typeof e=="symbol",Ky=e=>{class t extends ld{get(r,s){const i=Na(s,"AssistantState");if(i!==!1)return i;const o=s;if(!bl(o))return UC(e[o]())}ownKeys(){return Object.keys(e).filter(r=>!bl(r))}has(r,s){return!bl(s)&&s in e}}return new Proxy({},new t)},WC=e=>e[Ks],hh=()=>()=>{},Gy=e=>{const t=()=>{throw new Error(e)};return t.source=null,t.query=null,t};var qC=class extends ld{get(e,t){if(t==="subscribe"||t==="on")return hh;if(t===Ks)return KC;const n=Na(t,"DefaultAssistantClient");return n!==!1?n:Gy("You are using a component or hook that requires an AuiProvider. Wrap your component in an <AuiProvider> component.")}ownKeys(){return["subscribe","on",Ks]}has(e,t){return t==="subscribe"||t==="on"||t===Ks}};const La=new Proxy({},new qC),KC=Ky(La),GC=()=>new Proxy({},{get(e,t){const n=Na(t,"AssistantClient");return n!==!1?n:Gy(`The current scope does not have a "${String(t)}" property.`)}}),Qy=m.createContext(La),QC=()=>m.useContext(Qy),xn=({value:e,children:t})=>c.jsx(Qy.Provider,{value:e,children:t}),Pt=ie(e=>null),Uu=Symbol("assistant-ui.transform-scopes");function Yy(e,t){const n=e;if(n[Uu])throw new Error("transformScopes is already attached to this resource");n[Uu]=t}function YC(e){return e[Uu]}const Jy=e=>typeof e=="string"?{scope:e.split(".")[0],event:e}:{scope:e.scope,event:e.event},Xy=By(null),JC=(e,t)=>$y(Xy,e,t),Zy=()=>{const e=Uy(Xy);if(!e)throw new Error("AssistantTapContext is not available");return e},ev=()=>Zy().clientRef,ud=()=>{const{emit:e}=Zy(),t=ad();return tn((n,r)=>{e(n,r,t)})};function XC(e,t){const n={...e},r=new Set;let s=!0;for(;s;){s=!1;for(const a of Object.values(n)){if(a.type===Pt||r.has(a.type))continue;r.add(a.type);const l=YC(a.type);if(l){l(n,t),s=!0;break}}}const i={},o={};for(const[a,l]of Object.entries(n))l.type===Pt?o[a]=l:i[a]=l;return{rootClients:i,derivedClients:o}}const ph=e=>te(()=>e,[...Object.entries(e).flat()]),ZC=(e,t)=>{const{rootClients:n,derivedClients:r}=XC(e,t);return{rootClients:ph(n),derivedClients:ph(r)}},e_=ie(()=>ir(()=>{const e=new Map,t=new Set,n=new Set;return{on(r,s){const i=s;if(r==="*")return t.add(i),()=>t.delete(i);let o=e.get(r);return o||(o=new Set,e.set(r,o)),o.add(i),()=>{o.delete(i),o.size===0&&e.delete(r)}},emit(r,s,i){const o=e.get(r);!o&&t.size===0||queueMicrotask(()=>{const a=[];if(o)for(const l of o)try{l(s,i)}catch(u){a.push(u)}if(t.size>0){const l={event:r,payload:s};for(const u of t)try{u(l,i)}catch(f){a.push(f)}}if(a.length>0){if(a.length===1)throw a[0];for(const l of a)console.error(l);throw new AggregateError(a,"Errors occurred during event emission")}})},subscribe(r){return n.add(r),()=>n.delete(r)},notifySubscribers(){for(const r of n)try{r()}catch(s){console.error("NotificationManager: subscriber callback error",s)}}}})),t_=()=>null;function tv(e){const t=m.useMemo(()=>Dy(a=>r(a)),[]),[n,r]=m.useReducer((a,l)=>(Ws(t,a),a+(l()?1:0)),0);Ws(t,n);const s=t_(),i=m.useMemo(()=>(e.key,vi(e.type,t,void 0,s)),[e.type,e.key,t,s]),o=zn(i,e.props);return m.useLayoutEffect(()=>()=>Kr(i),[i]),m.useLayoutEffect(()=>{Jo(t),ns(i,o)}),o.output}const nv=e=>te(()=>e,e),n_=ie(({element:e,emit:t,clientRef:n})=>{const{methods:r,state:s}=JC({clientRef:n,emit:t},()=>Ma(e));return te(()=>({state:s,methods:r}),[r,s])}),r_=ie(({element:e,notifications:t,clientRef:n,name:r})=>{const s=AC(n_({element:e,emit:t.emit,clientRef:n}));return Ie(()=>s.subscribe(t.notifySubscribers),[s,t]),te(()=>{const i=()=>s.getValue().methods;return Object.defineProperties(i,{source:{value:"root",writable:!1},query:{value:{},writable:!1},name:{value:r,configurable:!0}}),i},[s,r])}),s_=ie(()=>te(()=>({clients:[],subscribe:void 0,on:void 0}),[])),i_=ie(({clients:e,clientRef:t})=>{const n=Be(e_());Ie(()=>t.parent.subscribe(n.notifySubscribers),[t,n]);const r=nv(ja(()=>Object.keys(e).map(s=>nn(s,r_({element:e[s],notifications:n,clientRef:t,name:s}))),[e,n,t]));return te(()=>({clients:r,subscribe:n.subscribe,on:function(s,i){if(!this)throw new Error("const { on } = useAui() is not supported. Use aui.on() instead.");const{scope:o,event:a}=Jy(s);if(o!=="*"&&this[o].source===null)throw new Error(`Scope "${o}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);const l=n.on(a,(f,d)=>{if(o==="*"){i(f);return}const h=this[o]();h===d[FC(h)]&&i(f)});if(o!=="*"&&t.parent[o].source===null)return l;const u=t.parent.on(s,i);return()=>{l(),u()}}}),[r,n,t])}),o_=ie(({element:e,clientRef:t,name:n})=>{const r=en(e.props);return r.current=e.props,te(()=>{const s=()=>r.current.get(t.current);return Object.defineProperties(s,{source:{value:r.current.source},query:{value:r.current.query},name:{value:n,configurable:!0}}),s},[t,n])}),a_=(e,t)=>{let n;try{const r={};for(const s of Object.keys(t.query).sort())r[s]=t.query[s];n=JSON.stringify(r)}catch{n=String(t.query)}return`${e}::${t.source}::${n}`},l_=ie(({clients:e,clientRef:t})=>nv(ja(()=>Object.keys(e).map(n=>{const r=n,s=e[r];return nn(a_(r,s.props),o_({element:s,clientRef:t,name:r}))}),[e,t]))),u_=ie(({parent:e,clients:t})=>{const{rootClients:n,derivedClients:r}=ZC(t,e),s=en({parent:e,current:null}).current;Ie(()=>{s.current=a});const i=Be(Object.keys(n).length>0?i_({clients:n,clientRef:s}):s_()),o=Be(l_({clients:r,clientRef:s})),a=te(()=>{const l=e===La?GC():e,u=Object.create(l);Object.assign(u,{subscribe:i.subscribe??e.subscribe,on:i.on??e.on,[Ks]:Ky(u)});for(const f of i.clients)u[f.name]=f;for(const f of o)u[f.name]=f;return u},[e,i,o]);return s.current===null&&(s.current=a),a});function Z(e,{parent:t}={parent:QC()}){if(e)return tv(u_({parent:t??La,clients:e}));if(t===null)throw new Error("received null parent, this usage is not allowed");return t}const U=e=>{const t=Z(),n=WC(t),r=m.useSyncExternalStore(t.subscribe,()=>e(n),()=>e(n));if(r===n)throw new Error("You tried to return the entire AssistantState. This is not supported due to technical limitations.");return m.useDebugValue(r),r},c_=e=>{const t=Z(),n=m.useRef(!1),r=n.current?null:e(t);return U(()=>n.current?e(t):r),()=>(n.current=!0,e(t))},d_=Object.freeze({});function cs({getItemState:e,children:t}){return f_(t(c_(e)))}const f_=e=>{const t=typeof e=="object"&&e!=null&&"type"in e?e:null,n=t?.type,r=t?.key;return m.useMemo(()=>t,[n,r,typeof t?.props=="object"&&t.props!=null&&Object.entries(t.props).length===0?d_:t?.props])??e},h_=lt.createContext(!0);function mh(){throw new Error("A function wrapped in useEffectEvent can't be called during rendering.")}const p_="use"in lt?()=>{try{return lt.use(h_)}catch{return!1}}:()=>!1;function m_(e){const t=lt.useRef(mh);return lt.useInsertionEffect(()=>{t.current=e},[e]),(...n)=>{p_()&&mh();const r=t.current;return r(...n)}}const Zo=(e,t)=>{const n=Z(),r=m_(t),{scope:s,event:i}=Jy(e);m.useEffect(()=>n.on({scope:s,event:i},r),[n,s,i])},g_=Wy(e=>{if(e.key===void 0)throw new Error("tapClientResource: Element has no key");return Be(qy(e))});function rs(e,t){const n=ja(()=>e().map(i=>g_(i)),t),r=te(()=>Object.keys(n),[n]),s=te(()=>n.reduce((i,o,a)=>(i[o.key]=a,i),{}),[n]);return{state:te(()=>n.map(i=>i.state),[n]),get:i=>{if("index"in i){if(i.index<0||i.index>=r.length)throw new Error(`tapClientLookup: Index ${i.index} out of bounds (length: ${r.length})`);return n[i.index].methods}const o=s[i.key];if(o===void 0)throw new Error(`tapClientLookup: Key "${i.key}" not found`);return n[o].methods}}}const rv=ie(({toolkit:e,mcpApp:t})=>{const n=ja(()=>t?[nn("mcpApp",t)]:[],[t])[0],[r,s]=bt(()=>({})),i=te(()=>({toolUIs:r,mcpApp:n,tools:Object.fromEntries(Object.entries(r).map(([l,u])=>[l,u.map(f=>f.render)]))}),[r,n]),o=ev(),a=yi((l,u,f)=>{const d={render:u,standalone:f?.standalone??!1};return s(h=>({...h,[l]:[...h[l]??[],d]})),()=>{s(h=>{const p=h[l]?.filter(k=>k!==d)??[];if(p.length>0)return{...h,[l]:p};const{[l]:g,...x}=h;return x})}},[]);return Ie(()=>{if(!e)return;const l=[];for(const[f,d]of Object.entries(e)){const h="render"in d?d.render:void 0,p="renderText"in d?d.renderText:void 0,g=h??(p?zC(p):void 0);g&&l.push(a(f,g,{standalone:DC(d)}))}const u=Object.entries(e).reduce((f,[d,h])=>{if(h.type==="mcp")return f;const{display:p,render:g,renderText:x,...k}=h;return f[d]=k,f},{});return l.push(o.current.modelContext().register({getModelContext:()=>({tools:u})})),()=>{l.forEach(f=>f())}},[e,a,o]),{getState:()=>i,setToolUI:a}});Yy(rv,(e,t)=>{!e.modelContext&&t.modelContext.source===null&&(e.modelContext=Vy())});const yr=e=>{const[,t]=bt(e.getState);return Ie(()=>(t(e.getState()),e.subscribe(()=>{t(e.getState())})),[e]),e.getState()},sv=ie(({runtime:e})=>{const t=yr(e);return{getState:()=>t,remove:e.remove,__internal_getRuntime:()=>e}}),y_=ie(({runtime:e,index:t})=>Be(sv({runtime:te(()=>e.getAttachmentByIndex(t),[e,t])}))),iv=ie(({threadIdRef:e,messageIdRef:t,runtime:n})=>{const r=yr(n),s=ud();Ie(()=>{const a=[];for(const l of["send","attachmentAdd"]){const u=n.unstable_on(l,()=>{s(`composer.${l}`,{threadId:e.current,...t&&{messageId:t.current}})});a.push(u)}return a.push(n.unstable_on("attachmentAddError",l=>{s("composer.attachmentAddError",{threadId:e.current,...t&&{messageId:t.current},...l.attachmentId&&{attachmentId:l.attachmentId},reason:l.reason,message:l.message})})),()=>{for(const l of a)l()}},[n,s,e,t]);const i=rs(()=>r.attachments.map((a,l)=>nn(a.id,y_({runtime:n,index:l}))),[r.attachments,n]),o=te(()=>({text:r.text,role:r.role,attachments:i.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,i.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 new Error("beginEdit is not supported in this runtime")}),startDictation:n.startDictation,stopDictation:n.stopDictation,setQuote:n.setQuote,attachment:a=>"id"in a?i.get({key:a.id}):i.get(a),queueItem:()=>{throw new Error("Queue is not supported in this runtime")},__internal_getRuntime:()=>n}}),v_=ie(({runtime:e})=>{const t=yr(e);return{getState:()=>t,addToolResult:n=>e.addToolResult(n),resumeToolCall:n=>e.resumeToolCall(n),respondToToolApproval:n=>e.respondToToolApproval(n),__internal_getRuntime:()=>e}}),x_=ie(({runtime:e,index:t})=>Be(sv({runtime:te(()=>e.getAttachmentByIndex(t),[e,t])}))),w_=ie(({runtime:e,index:t})=>Be(v_({runtime:te(()=>e.getMessagePartByIndex(t),[e,t])}))),S_=ie(({runtime:e,threadIdRef:t})=>{const n=yr(e),[r,s]=bt(!1),[i,o]=bt(!1),a=te(()=>({get current(){return e.getState().id}}),[e]),l=Ma(iv({runtime:e.composer,threadIdRef:t,messageIdRef:a})),u=rs(()=>n.content.map((h,p)=>nn("toolCallId"in h&&h.toolCallId!=null?`toolCallId-${h.toolCallId}`:`index-${p}`,w_({runtime:e,index:p}))),[n.content,e]),f=rs(()=>(n.attachments??[]).map((h,p)=>nn(h.id,x_({runtime:e,index:p}))),[n.attachments,e]),d=te(()=>({...n,parts:u.state,composer:l.state,isCopied:r,isHovering:i}),[n,u.state,l.state,r,i]);return{getState:()=>d,composer:()=>l.methods,reload:h=>e.reload(h),speak:()=>e.speak(),stopSpeaking:()=>e.stopSpeaking(),submitFeedback:h=>e.submitFeedback(h),switchToBranch:h=>e.switchToBranch(h),getCopyText:()=>e.unstable_getCopyText(),part:h=>"index"in h?u.get({index:h.index}):u.get({key:`toolCallId-${h.toolCallId}`}),attachment:h=>"id"in h?f.get({key:h.id}):f.get(h),setIsCopied:s,setIsHovering:o,__internal_getRuntime:()=>e}}),b_=ie(({runtime:e,id:t,threadIdRef:n})=>Be(S_({runtime:te(()=>e.getMessageById(t),[e,t]),threadIdRef:n}))),k_=ie(({runtime:e})=>{const t=yr(e),n=ud();Ie(()=>{const a=[];for(const l of["runStart","runEnd","initialize","modelContextUpdate"]){const u=e.unstable_on(l,()=>{const f=e.getState()?.threadId||"unknown";n(`thread.${l}`,{threadId:f})});a.push(u)}return()=>{for(const l of a)l()}},[e,n]);const r=te(()=>({get current(){return e.getState().threadId}}),[e]),s=Ma(iv({runtime:e.composer,threadIdRef:r})),i=rs(()=>t.messages.map(a=>nn(a.id,b_({runtime:e,id:a.id,threadIdRef:r}))),[t.messages,e,r]),o=te(()=>({isEmpty:i.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:s.state,messages:i.state}),[t,i,s.state]);return{getState:()=>o,composer:()=>s.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:a=>"id"in a?i.get({key:a.id}):i.get(a),__internal_getRuntime:()=>e}}),C_=ie(({runtime:e})=>{const t=yr(e),n=ud();return Ie(()=>{const r=[];for(const s of["switchedTo","switchedAway"]){const i=e.unstable_on(s,()=>{n(`threadListItem.${s}`,{threadId:e.getState().id})});r.push(i)}return()=>{for(const s of r)s()}},[e,n]),{getState:()=>t,switchTo:e.switchTo,rename:e.rename,updateCustom:e.updateCustom,archive:e.archive,unarchive:e.unarchive,delete:e.delete,generateTitle:e.generateTitle,initialize:e.initialize,detach:e.detach,__internal_getRuntime:()=>e}}),__=ie(({runtime:e,id:t})=>Be(C_({runtime:te(()=>e.getItemById(t),[e,t])}))),E_=ie(({runtime:e,__internal_assistantRuntime:t})=>{const n=yr(e),r=Ma(k_({runtime:e.main})),s=rs(()=>Object.keys(n.threadItems).map(o=>nn(o,__({runtime:e,id:o}))),[n.threadItems,e]),i=te(()=>({mainThreadId:n.mainThreadId,newThreadId:n.newThreadId??null,isLoading:n.isLoading,isLoadingMore:n.isLoadingMore,hasMore:n.hasMore,threadIds:n.threadIds,archivedThreadIds:n.archivedThreadIds,threadItems:s.state,main:r.state}),[n,s.state,r.state]);return{getState:()=>i,thread:()=>r.methods,item:o=>{if(o==="main")return s.get({key:i.mainThreadId});if("id"in o)return s.get({key:o.id});const{index:a,archived:l=!1}=o,u=l?i.archivedThreadIds[a]:i.threadIds[a];return s.get({key:u})},switchToThread:async(o,a)=>{await e.switchToThread(o,a)},switchToNewThread:async()=>{await e.switchToNewThread()},getLoadThreadsPromise:()=>e.getLoadThreadsPromise(),reload:()=>e.reload(),loadMore:()=>e.loadMore(),__internal_getAssistantRuntime:()=>t}}),T_=ie(e=>({getState:()=>e})),I_=ie(e=>{const[t]=bt(()=>({suggestions:(e??[]).map(r=>typeof r=="string"?{title:r,label:"",prompt:r}:{title:r.title,label:r.label,prompt:r.prompt})})),n=rs(()=>t.suggestions.map((r,s)=>nn(s,T_(r))),[t.suggestions]);return{getState:()=>t,suggestion:({index:r})=>n.get({index:r})}}),R_=ie(e=>{const t=ev();return Ie(()=>e.registerModelContextProvider(t.current.modelContext()),[e,t]),Be(E_({runtime:e.threads,__internal_assistantRuntime:e}))}),P_=(e,t)=>{e.thread??(e.thread=Pt({source:"threads",query:{type:"main"},get:n=>n.threads().thread("main")})),e.threadListItem??(e.threadListItem=Pt({source:"threads",query:{type:"main"},get:n=>n.threads().item("main")})),e.composer??(e.composer=Pt({source:"thread",query:{},get:n=>n.threads().thread("main").composer()})),!e.modelContext&&t.modelContext.source===null&&(e.modelContext=Vy()),!e.suggestions&&t.suggestions.source===null&&(e.suggestions=I_())},ov=ie(e=>Be(R_(e)));Yy(ov,(e,t)=>{P_(e,t),!e.tools&&t.tools.source===null&&(e.tools=rv({})),!e.dataRenderers&&t.dataRenderers.source===null&&(e.dataRenderers=jC())});const A_=e=>e._core?.RenderComponent,j_=m.memo(({runtime:e,aui:t=null,children:n})=>{const r=Z({threads:ov(e)},{parent:t}),s=A_(e);return c.jsxs(xn,{value:r,children:[s&&c.jsx(s,{}),n]})}),gh=e=>{let t;const n=new Set,r=(u,f)=>{const d=typeof u=="function"?u(t):u;if(!Object.is(d,t)){const h=t;t=f??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(p=>p(t,h))}},s=()=>t,a={setState:r,getState:s,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u))},l=t=e(r,s,a);return a},N_=e=>e?gh(e):gh,M_=e=>e;function L_(e,t=M_){const n=lt.useSyncExternalStore(e.subscribe,lt.useCallback(()=>t(e.getState()),[e,t]),lt.useCallback(()=>t(e.getInitialState()),[e,t]));return lt.useDebugValue(n),n}const yh=e=>{const t=N_(e),n=r=>L_(t,r);return Object.assign(n,t),n},av=e=>e?yh(e):yh,cd=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});if(!e||!t)throw new Error("Failed to create promise");return{promise:n,resolve:e,reject:t}},D_=()=>{const e=[];let t=!1,n,r;const s=i=>{i.promise||(i.promise=i.reader.read().then(({done:o,value:a})=>{i.promise=void 0,o?(e.splice(e.indexOf(i),1),t&&e.length===0&&n.close()):n.enqueue(a),r?.resolve(),r=void 0}).catch(o=>{console.error(o),e.forEach(a=>{a.reader.cancel()}),e.length=0,n.error(o),r?.reject(o),r=void 0}))};return{readable:new ReadableStream({start(i){n=i},pull(){return r=cd(),e.forEach(i=>{s(i)}),r.promise},cancel(){e.forEach(i=>{i.reader.cancel()}),e.length=0}}),isSealed(){return t},seal(){t=!0,e.length===0&&n.close()},addStream(i){if(t)throw new Error("Cannot add streams after the run callback has settled.");const o={reader:i.getReader()};e.push(o),s(o)},enqueue(i){this.addStream(new ReadableStream({start(o){o.enqueue(i),o.close()}}))}}};var vh=class{constructor(e){T(this,"_controller");T(this,"_isClosed",!1);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())}};const lv=e=>new ReadableStream({start(t){return e.start?.(new vh(t))},pull(t){return e.pull?.(new vh(t))},cancel(t){return e.cancel?.(t)}}),xh=()=>{let e;return[lv({start(t){e=t}}),e]};var wh=class{constructor(e){T(this,"_controller");T(this,"_isClosed",!1);T(this,"_mergeTask");T(this,"_argsTextController");this._controller=e;const t=lv({start:r=>{this._argsTextController=r}});let n=!1;this._mergeTask=t.pipeTo(new WritableStream({write:r=>{switch(r.type){case"text-delta":n=!0,this._controller.enqueue(r);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 new Error(`Unexpected chunk type: ${r.type}`)}}}))}get argsText(){return this._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())}};const O_=e=>new ReadableStream({start(t){return e.start?.(new wh(t))},pull(t){return e.pull?.(new wh(t))},cancel(t){return e.cancel?.(t)}}),z_=()=>{let e;return[O_({start(t){e=t}}),e]};var uv=class{constructor(){T(this,"value",-1)}up(){return++this.value}},F_=class extends TransformStream{constructor(e){super({transform(t,n){n.enqueue({...t,path:[e,...t.path]})}})}};(class extends TransformStream{constructor(e){super({transform(t,n){const{path:[r,...s]}=t;if(e!==r)throw new Error(`Path mismatch: expected ${e}, got ${r}`);n.enqueue({...t,path:s})}})}});var B_=class extends TransformStream{constructor(e){const t=new uv,n=new Map;super({transform(r,s){r.type==="part-start"&&r.path.length===0&&n.set(t.up(),e.up());const[i,...o]=r.path;if(i===void 0){s.enqueue(r);return}const a=n.get(i);if(a===void 0)throw new Error("Path not found");s.enqueue({...r,path:[a,...o]})}})}},$_=class extends TransformStream{constructor(e){super();const t=e(super.readable);Object.defineProperty(this,"readable",{value:t,writable:!1})}},cv=class extends TransformStream{constructor(){const e=[];super({transform(t,n){if(t.type==="part-start"){if(t.path.length!==0){n.error(new 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(new Error(`${t.type} chunks must have a path of length 1`));return}const r=t.path[0];if(r<0||r>=e.length){n.error(new Error(`Invalid path index: ${r}`));return}const s=e[r];n.enqueue({...t,meta:s});return}n.enqueue(t)}})}};let dv=(e,t=21)=>(n=t)=>{let r="",s=n|0;for(;s--;)r+=e[Math.random()*e.length|0];return r};const U_=dv("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7);var V_=class fv{constructor(t){T(this,"_state");T(this,"_parentId");this._state=t||{merger:D_(),contentCounter:new uv}}get __internal_isClosed(){return this._state.merger.isSealed()}__internal_getReadable(){return this._state.merger.readable}__internal_subscribeToClose(t){this._state.closeSubscriber=t}_addPart(t,n){this._state.append&&(this._state.append.controller.close(),this._state.append=void 0),this.enqueue({type:"part-start",part:t,path:[]}),this._state.merger.addStream(n.pipeThrough(new F_(this._state.contentCounter.value)))}merge(t){this._state.merger.addStream(t.pipeThrough(new B_(this._state.contentCounter)))}appendText(t){(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(t)}appendReasoning(t){(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(t)}addTextPart(){const[t,n]=xh();return this._addPart(this._withParentIdOption({type:"text"}),t),n}addReasoningPart(){const[t,n]=xh();return this._addPart(this._withParentIdOption({type:"reasoning"}),t),n}addToolCallPart(t){const n=typeof t=="string"?{toolName:t}:t,r=n.toolName,s=n.toolCallId??U_(),[i,o]=z_();return this._addPart({type:"tool-call",toolName:r,toolCallId:s,...this._parentId&&{parentId:this._parentId}},i),n.argsText!==void 0&&(o.argsText.append(n.argsText),o.argsText.close()),n.args!==void 0&&(o.argsText.append(JSON.stringify(n.args)),o.argsText.close()),n.response!==void 0&&o.setResponse(n.response),o}_finishedPartStream(){return new ReadableStream({start(t){t.enqueue({type:"part-finish",path:[]}),t.close()}})}_withParentIdOption(t){return this._parentId?{...t,parentId:this._parentId}:t}appendSource(t){this._addPart(this._withParentIdOption(t),this._finishedPartStream())}appendFile(t){this._addPart(this._withParentIdOption(t),this._finishedPartStream())}appendData(t){this._addPart(this._withParentIdOption(t),this._finishedPartStream())}enqueue(t){this._state.merger.enqueue(t),t.type==="part-start"&&t.path.length===0&&this._state.contentCounter.up()}withParentId(t){const n=new fv(this._state);return n._parentId=t,n}close(){this._state.append?.controller?.close(),this._state.merger.seal(),this._state.closeSubscriber?.()}};function H_(e){const t=new V_;return(async()=>{try{await e(t)}catch(r){throw t.__internal_isClosed||t.enqueue({type:"error",path:[],error:String(r)}),r}finally{t.__internal_isClosed||t.close()}})(),t.__internal_getReadable()}function W_(){const{resolve:e,promise:t}=cd();let n;return[H_(r=>(n=r,n.__internal_subscribeToClose(e),t)),n]}function q_(e){const t=["ROOT"];let n=-1,r=null;const s=[];let i;function o(){i!==void 0&&(s.push(JSON.parse(`"${i}"`)),i=void 0)}function a(d,h,p){switch(d){case'"':n=h,t.pop(),t.push(p),t.push("INSIDE_STRING"),o();break;case"f":case"t":case"n":n=h,r=h,t.pop(),t.push(p),t.push("INSIDE_LITERAL");break;case"-":t.pop(),t.push(p),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=h,t.pop(),t.push(p),t.push("INSIDE_NUMBER"),o();break;case"{":n=h,t.pop(),t.push(p),t.push("INSIDE_OBJECT_START"),o();break;case"[":n=h,t.pop(),t.push(p),t.push("INSIDE_ARRAY_START"),o();break}}function l(d,h){switch(d){case",":t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break;case"}":n=h,t.pop(),i=s.pop();break}}function u(d,h){switch(d){case",":t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA"),i=(Number(i)+1).toString();break;case"]":n=h,t.pop(),i=s.pop();break}}for(let d=0;d<e.length;d++){const h=e[d];switch(t[t.length-1]){case"ROOT":a(h,d,"FINISH");break;case"INSIDE_OBJECT_START":switch(h){case'"':t.pop(),t.push("INSIDE_OBJECT_KEY"),i="";break;case"}":n=d,t.pop(),i=s.pop();break}break;case"INSIDE_OBJECT_AFTER_COMMA":switch(h){case'"':t.pop(),t.push("INSIDE_OBJECT_KEY"),i="";break}break;case"INSIDE_OBJECT_KEY":switch(h){case'"':t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break;case"\\":t.push("INSIDE_STRING_ESCAPE"),i+=h;break;default:i+=h;break}break;case"INSIDE_OBJECT_AFTER_KEY":switch(h){case":":t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}break;case"INSIDE_OBJECT_BEFORE_VALUE":a(h,d,"INSIDE_OBJECT_AFTER_VALUE");break;case"INSIDE_OBJECT_AFTER_VALUE":l(h,d);break;case"INSIDE_STRING":switch(h){case'"':t.pop(),n=d,i=s.pop();break;case"\\":t.push("INSIDE_STRING_ESCAPE");break;default:n=d}break;case"INSIDE_ARRAY_START":switch(h){case"]":n=d,t.pop(),i=s.pop();break;default:n=d,i="0",a(h,d,"INSIDE_ARRAY_AFTER_VALUE");break}break;case"INSIDE_ARRAY_AFTER_VALUE":switch(h){case",":t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA"),i=(Number(i)+1).toString();break;case"]":n=d,t.pop(),i=s.pop();break;default:n=d;break}break;case"INSIDE_ARRAY_AFTER_COMMA":a(h,d,"INSIDE_ARRAY_AFTER_VALUE");break;case"INSIDE_STRING_ESCAPE":t.pop(),t[t.length-1]==="INSIDE_STRING"?n=d:t[t.length-1]==="INSIDE_OBJECT_KEY"&&(i+=h);break;case"INSIDE_NUMBER":switch(h){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n=d;break;case"e":case"E":case"-":case".":break;case",":t.pop(),i=s.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(h,d),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&l(h,d);break;case"}":t.pop(),i=s.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&l(h,d);break;case"]":t.pop(),i=s.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(h,d);break;default:t.pop(),i=s.pop();break}break;case"INSIDE_LITERAL":{const p=e.substring(r,d+1);!"false".startsWith(p)&&!"true".startsWith(p)&&!"null".startsWith(p)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?l(h,d):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(h,d)):n=d;break}}}let f=e.slice(0,n+1);for(let d=t.length-1;d>=0;d--)switch(t[d]){case"INSIDE_STRING":f+='"';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":f+="}";break;case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":f+="]";break;case"INSIDE_LITERAL":{const h=e.substring(r,e.length);"true".startsWith(h)?f+="true".slice(h.length):"false".startsWith(h)?f+="false".slice(h.length):"null".startsWith(h)&&(f+="null".slice(h.length))}}return[f,s]}var ds={exports:{}};const K_=typeof Buffer<"u",Sh=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,bh=/"(?: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 hv(e,t,n){n==null&&t!==null&&typeof t=="object"&&(n=t,t=void 0),K_&&Buffer.isBuffer(e)&&(e=e.toString()),e&&e.charCodeAt(0)===65279&&(e=e.slice(1));const r=JSON.parse(e,t);if(r===null||typeof r!="object")return r;const s=n&&n.protoAction||"error",i=n&&n.constructorAction||"error";if(s==="ignore"&&i==="ignore")return r;if(s!=="ignore"&&i!=="ignore"){if(Sh.test(e)===!1&&bh.test(e)===!1)return r}else if(s!=="ignore"&&i==="ignore"){if(Sh.test(e)===!1)return r}else if(bh.test(e)===!1)return r;return pv(r,{protoAction:s,constructorAction:i,safe:n&&n.safe})}function pv(e,{protoAction:t="error",constructorAction:n="error",safe:r}={}){let s=[e];for(;s.length;){const i=s;s=[];for(const o of i){if(t!=="ignore"&&Object.prototype.hasOwnProperty.call(o,"__proto__")){if(r===!0)return null;if(t==="error")throw new SyntaxError("Object contains forbidden prototype property");delete o.__proto__}if(n!=="ignore"&&Object.prototype.hasOwnProperty.call(o,"constructor")&&o.constructor!==null&&typeof o.constructor=="object"&&Object.prototype.hasOwnProperty.call(o.constructor,"prototype")){if(r===!0)return null;if(n==="error")throw new SyntaxError("Object contains forbidden prototype property");delete o.constructor}for(const a in o){const l=o[a];l&&typeof l=="object"&&s.push(l)}}}return e}function dd(e,t,n){const{stackTraceLimit:r}=Error;Error.stackTraceLimit=0;try{return hv(e,t,n)}finally{Error.stackTraceLimit=r}}function G_(e,t){const{stackTraceLimit:n}=Error;Error.stackTraceLimit=0;try{return hv(e,t,{safe:!0})}catch{return}finally{Error.stackTraceLimit=n}}ds.exports=dd;ds.exports.default=dd;ds.exports.parse=dd;ds.exports.safeParse=G_;ds.exports.scan=pv;var Q_=ds.exports;const Vu=ki(Q_),So=Symbol("aui.parse-partial-json-object.meta"),Y_=e=>e?.[So],Hu=e=>{if(e.length===0)return{[So]:{state:"partial",partialPath:[]}};try{const t=Vu.parse(e);if(typeof t!="object"||t===null)throw new Error("argsText is expected to be an object");return t[So]={state:"complete",partialPath:[]},t}catch{try{const[t,n]=q_(e),r=Vu.parse(t);if(typeof r!="object"||r===null)throw new Error("argsText is expected to be an object");return r[So]={state:"partial",partialPath:n},r}catch{return}}},mv=(e,t,n)=>{if(typeof e!="object"||e===null)return t.state;if(t.state==="complete")return"complete";if(n.length===0)return t.state;const[r,...s]=n;if(!Object.hasOwn(e,r))return"partial";const[i,...o]=t.partialPath;if(r!==i)return"complete";const a=e[r];return mv(a,{state:"partial",partialPath:o},s)},ss=(e,t)=>{const n=Y_(e);if(!n)throw new Error("unable to determine object state");return mv(e,n,t.map(String))};async function*J_(){const e=this.getReader();try{for(;;){const{done:t,value:n}=await e.read();if(t)break;yield n}}finally{e.releaseLock()}}function kl(e){var t;return e[t=Symbol.asyncIterator]??(e[t]=J_),e}const kh=Symbol.for("aui.tool-response");var fn=class Wu{constructor(t){T(this,"artifact");T(this,"result");T(this,"isError");T(this,"modelContent");T(this,"messages");t.artifact!==void 0&&(this.artifact=t.artifact),this.result=t.result,this.isError=t.isError??!1,t.modelContent!==void 0&&(this.modelContent=t.modelContent),t.messages!==void 0&&(this.messages=t.messages)}get[kh](){return!0}static[Symbol.hasInstance](t){return typeof t=="object"&&t!==null&&kh in t}static toResponse(t){return t instanceof Wu?t:new Wu({result:t===void 0?"<no result>":t})}};function X_(e,t,n){try{const r=e();if(typeof r=="object"&&r!==null&&"then"in r)return r.then(t,n);t(r)}catch(r){n(r)}}function is(e,t){let n=e;for(const r of t){if(n==null)return;n=n[r]}return n}var Z_=class{constructor(e,t,n){T(this,"resolve");T(this,"reject");T(this,"disposed",!1);T(this,"fieldPath");this.resolve=e,this.reject=t,this.fieldPath=n}update(e){if(!this.disposed)try{if(ss(e,this.fieldPath)==="complete"){const t=is(e,this.fieldPath);t!==void 0&&(this.resolve(t),this.dispose())}}catch(t){this.reject(t),this.dispose()}}end(e){if(!this.disposed)try{const t=is(e,this.fieldPath);this.resolve(t)}catch(t){this.reject(t)}finally{this.dispose()}}dispose(){this.disposed=!0}},e0=class{constructor(e,t){T(this,"controller");T(this,"disposed",!1);T(this,"fieldPath");this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{const t=is(e,this.fieldPath);t!==void 0&&this.controller.enqueue(t),ss(e,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(t){this.controller.error(t),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},t0=class{constructor(e,t){T(this,"controller");T(this,"disposed",!1);T(this,"fieldPath");T(this,"lastValue");this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{const t=is(e,this.fieldPath);if(t!==void 0&&typeof t=="string"){const n=t.substring(this.lastValue?.length||0);this.lastValue=t,this.controller.enqueue(n)}ss(e,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(t){this.controller.error(t),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},n0=class{constructor(e,t){T(this,"controller");T(this,"disposed",!1);T(this,"fieldPath");T(this,"processedIndexes",new Set);this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{const t=is(e,this.fieldPath);if(!Array.isArray(t))return;for(let n=0;n<t.length;n++)this.processedIndexes.has(n)||ss(e,[...this.fieldPath,n])==="complete"&&(this.controller.enqueue(t[n]),this.processedIndexes.add(n));ss(e,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(t){this.controller.error(t),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},r0=class{constructor(e){T(this,"argTextDeltas");T(this,"handles",new Set);T(this,"args",Hu(""));T(this,"finished",!1);this.argTextDeltas=e,this.processStream()}async processStream(){try{let e="";const t=this.argTextDeltas.getReader();for(;;){const{value:n,done:r}=await t.read();if(r)break;e+=n;const s=Hu(e);if(s!==void 0){this.args=s;for(const i of this.handles)i.update(s)}}}catch(e){console.error("Error processing argument stream:",e)}finally{this.finished=!0;for(const e of this.handles)e.end(this.args);this.handles.clear()}}get(...e){return new Promise((t,n)=>{const r=new Z_(t,n,e);if(this.args&&ss(this.args,e)==="complete"){const s=is(this.args,e);if(s!==void 0){t(s);return}}if(this.finished){r.end(this.args);return}this.handles.add(r),r.update(this.args)})}streamValues(...e){const t=e;let n;return kl(new ReadableStream({start:r=>{n=new e0(r,t),this.finished||this.handles.add(n),n.update(this.args),this.finished&&n.end()},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}streamText(...e){const t=e;let n;return kl(new ReadableStream({start:r=>{n=new t0(r,t),this.finished||this.handles.add(n),n.update(this.args),this.finished&&n.end()},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}forEach(...e){const t=e;let n;return kl(new ReadableStream({start:r=>{n=new n0(r,t),this.finished||this.handles.add(n),n.update(this.args),this.finished&&n.end()},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}},s0=class{constructor(e){T(this,"promise");this.promise=e}get(){return this.promise}},i0=class{constructor(){T(this,"args");T(this,"response");T(this,"writable");T(this,"resolve");T(this,"argsText","");T(this,"result",{get:async()=>(await this.response.get()).result});const e=new TransformStream;this.writable=e.writable,this.args=new r0(e.readable);const{promise:t,resolve:n}=cd();this.resolve=n,this.response=new s0(t)}async appendArgsTextDelta(e){const t=this.writable.getWriter();try{await t.write(e)}catch(n){console.warn(n)}finally{t.releaseLock()}this.argsText+=e}async finishArgsText(){const e=this.writable.getWriter();try{await e.close()}catch(t){console.warn(t)}finally{e.releaseLock()}}setResponse(e){this.resolve(e)}},o0=class extends $_{constructor(e){const t=new Map,n=new Map;super(r=>{const s=new TransformStream({async transform(i,o){switch((i.type!=="part-finish"||i.meta.type!=="tool-call")&&o.enqueue(i),i.type){case"part-start":if(i.part.type==="tool-call"){const a=new i0;n.set(i.part.toolCallId,a),e.streamCall({reader:a,toolCallId:i.part.toolCallId,toolName:i.part.toolName})}break;case"text-delta":if(i.meta.type==="tool-call"){const a=i.meta.toolCallId,l=n.get(a);if(!l)throw new Error("No controller found for tool call");await l.appendArgsTextDelta(i.textDelta)}break;case"result":{if(i.meta.type!=="tool-call")break;const{toolCallId:a}=i.meta,l=n.get(a);if(!l)throw new Error("No controller found for tool call");l.setResponse(new fn({result:i.result,artifact:i.artifact,isError:i.isError,modelContent:i.modelContent}));break}case"tool-call-args-text-finish":{if(i.meta.type!=="tool-call")break;const{toolCallId:a,toolName:l}=i.meta,u=n.get(a);if(!u)throw new Error("No controller found for tool call");await u.finishArgsText();let f=!1;const d=X_(()=>{let h;try{h=Vu.parse(u.argsText)}catch(g){throw new Error(`Function parameter parsing failed. ${JSON.stringify(g.message)}`)}const p=e.execute({toolCallId:a,toolName:l,args:h});return p!==void 0&&(f=!0,e.onExecutionStart?.(a,l)),p},h=>{if(f&&e.onExecutionEnd?.(a,l),h===void 0)return;const p=new fn({artifact:h.artifact,result:h.result,isError:h.isError,messages:h.messages,modelContent:h.modelContent});u.setResponse(p),o.enqueue({type:"result",path:i.path,...p})},h=>{f&&e.onExecutionEnd?.(a,l);const p=new fn({result:String(h),isError:!0});u.setResponse(p),o.enqueue({type:"result",path:i.path,...p})});d&&t.set(a,d);break}case"part-finish":{if(i.meta.type!=="tool-call")break;const{toolCallId:a}=i.meta,l=t.get(a);l?l.then(()=>{t.delete(a),n.delete(a),o.enqueue(i)}):o.enqueue(i)}}},async flush(){await Promise.all(t.values())}});return r.pipeThrough(new cv).pipeThrough(s)})}};const a0=e=>typeof e=="object"&&e!==null&&"~standard"in e&&e["~standard"].version===1;function l0(e,t,n,r){const s=e?.[n.toolName];return s?.execute?(async o=>{if(t.aborted)return new fn({result:"Tool execution was cancelled.",isError:!0});let a=o;if(a0(s.parameters)){let f=s.parameters["~standard"].validate(n.args);f instanceof Promise&&(f=await f),f.issues&&(a=s.experimental_onSchemaValidationError??(()=>{throw new Error(`Function parameter validation failed. ${JSON.stringify(f.issues)}`)}))}const l=new Promise(f=>{const d=()=>{queueMicrotask(()=>{queueMicrotask(()=>{f(new fn({result:"Tool execution was cancelled.",isError:!0}))})})};t.aborted?d():t.addEventListener("abort",d,{once:!0})}),u=(async()=>{const f=await a(n.args,{toolCallId:n.toolCallId,abortSignal:t,human:h=>r(n.toolCallId,h)}),d=fn.toResponse(f);if(s.toModelOutput&&!d.isError&&d.modelContent===void 0)try{const h=await s.toModelOutput({toolCallId:n.toolCallId,input:n.args,output:d.result});return new fn({result:d.result,artifact:d.artifact,isError:d.isError,messages:d.messages,modelContent:h})}catch(h){console.warn(`[assistant-stream] tool "${n.toolName}" toModelOutput threw; falling back to default projection.`,h)}return d})();return Promise.race([u,l])})(s.execute):void 0}function u0(e,t,n,r,s){e?.[r.toolName]?.streamCall?.(n,{toolCallId:r.toolCallId,abortSignal:t,human:i=>s(r.toolCallId,i)})}function c0(e,t,n,r){const s=typeof e=="function"?e:()=>e,i=typeof t=="function"?t:()=>t;return new o0({execute:o=>l0(s(),i(),o,n),streamCall:({reader:o,...a})=>u0(s(),i(),o,a,n),onExecutionStart:r?.onExecutionStart,onExecutionEnd:r?.onExecutionEnd})}const gv=({index:e,children:t})=>c.jsx(xn,{value:Z({attachment:Pt({source:"message",query:{type:"index",index:e},get:n=>n.message().attachment({index:e})})}),children:t}),yv=({index:e,children:t})=>c.jsx(xn,{value:Z({attachment:Pt({source:"composer",query:{type:"index",index:e},get:n=>n.composer().attachment({index:e})})}),children:t}),vv=({index:e,children:t})=>c.jsx(xn,{value:Z({message:Pt({source:"thread",query:{type:"index",index:e},get:n=>n.thread().message({index:e})}),composer:Pt({source:"message",query:{},get:n=>n.thread().message({index:e}).composer()})}),children:t}),fd=({index:e,children:t})=>c.jsx(xn,{value:Z({part:Pt({source:"message",query:{type:"index",index:e},get:n=>n.message().part({index:e})})}),children:t}),d0=ie(({text:e,isRunning:t})=>{const n=te(()=>({type:"text",text:e,status:t?{type:"running"}:{type:"complete"}}),[e,t]);return{getState:()=>n,addToolResult:()=>{throw new Error("Not supported")},resumeToolCall:()=>{throw new Error("Not supported")},respondToToolApproval:()=>{throw new Error("Not supported")}}}),hd=({text:e,isRunning:t=!1,children:n})=>c.jsx(xn,{value:Z({part:d0({text:e,isRunning:t})}),children:n}),f0=Object.freeze({type:"complete"}),h0=ie(({parts:e,getMessagePart:t})=>{const[n,r]=bt(!0),s=te(()=>e[e.length-1]?.status??f0,[e]),i=te(()=>({parts:e,collapsed:n,status:s}),[e,n,s]);return{getState:()=>i,setCollapsed:r,part:t}}),p0=({startIndex:e,endIndex:t,children:n})=>{const r=U(i=>i.message.parts).slice(e,t+1),s=Z();return c.jsx(xn,{value:Z({chainOfThought:h0({parts:r,getMessagePart:({index:i})=>{if(i<0||i>=r.length)throw new Error(`ChainOfThought part index ${i} is out of bounds (0..${r.length-1})`);return s.message().part({index:e+i})}})}),children:n})},xv=({index:e,children:t})=>c.jsx(xn,{value:Z({suggestion:Pt({source:"suggestions",query:{index:e},get:n=>n.suggestions().suggestion({index:e})})}),children:t}),m0=({index:e,children:t})=>c.jsx(xn,{value:Z({queueItem:Pt({source:"composer",query:{index:e},get:n=>n.composer().queueItem({index:e})})}),children:t}),fr=Symbol("innerMessage"),Cl=Symbol("innerMessages"),g0=[],y0=(e,t)=>{fr in e||(e[fr]=t)},v0=e=>{const t="messages"in e?e.messages:e,n=t[Cl]||t[fr];return n?Array.isArray(n)?n:(t[Cl]=[n],t[Cl]):g0},Vt=Symbol("skip-update");function x0(e,t){if(e===void 0&&t===void 0)return!0;if(e===void 0||t===void 0)return!1;for(const n of Object.keys(e)){const r=e[n],s=t[n];if(!Object.is(r,s))return!1}return!0}var w0=class{constructor(){T(this,"_subscribers",new Set)}subscribe(e){return this._subscribers.add(e),()=>this._subscribers.delete(e)}waitForUpdate(){return new Promise(e=>{const t=this.subscribe(()=>{t(),e()})})}_notifySubscribers(){const e=[];for(const t of this._subscribers)try{t()}catch(n){e.push(n)}if(e.length>0){if(e.length===1)throw e[0];for(const t of e)console.error(t);throw new AggregateError(e)}}},Da=class{constructor(){T(this,"_subscriptions",new Set);T(this,"_connection")}get isConnected(){return!!this._connection}notifySubscribers(e){for(const 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()}}},zt=class extends Da{constructor(t){super();T(this,"binding");T(this,"_previousState");T(this,"getState",()=>(this.isConnected||this._syncState(),this._previousState));this.binding=t;const n=t.getState();if(n===Vt)throw new Error("Entry not available in the store");this._previousState=n}get path(){return this.binding.path}_syncState(){const t=this.binding.getState();return t===Vt||x0(t,this._previousState)?!1:(this._previousState=t,!0)}_connect(){const t=()=>{this._syncState()&&this.notifySubscribers()};return this.binding.subscribe(t)}},pd=class extends Da{constructor(t){super();T(this,"binding");T(this,"_previousStateDirty",!0);T(this,"_previousState");T(this,"getState",()=>{if(!this.isConnected||this._previousStateDirty){const t=this.binding.getState();t!==Vt&&(this._previousState=t),this._previousStateDirty=!1}if(this._previousState===void 0)throw new Error("Entry not available in the store");return this._previousState});this.binding=t}get path(){return this.binding.path}_connect(){const t=()=>{this._previousStateDirty=!0,this.notifySubscribers()};return this.binding.subscribe(t)}},ea=class extends Da{constructor(t){super();T(this,"binding");this.binding=t}get path(){return this.binding.path}getState(){return this.binding.getState()}outerSubscribe(t){return this.binding.subscribe(t)}_connect(){const t=()=>{this.notifySubscribers()};let n=this.binding.getState(),r=n?.subscribe(t);const s=()=>{const o=this.binding.getState();o!==n&&(n=o,r?.(),r=o?.subscribe(t),t())},i=this.outerSubscribe(s);return()=>{i?.(),r?.()}}},wv=class extends Da{constructor(t){super();T(this,"config");this.config=t}getState(){return this.config.binding.getState()}outerSubscribe(t){return this.config.binding.subscribe(t)}_connect(){const t=o=>{this.notifySubscribers(o)};let n=this.config.binding.getState(),r=n?.unstable_on(this.config.event,t);const s=()=>{const o=this.config.binding.getState();o!==n&&(n=o,r?.(),r=o?.unstable_on(this.config.event,t))},i=this.outerSubscribe(s);return()=>{i?.(),r?.()}}},Sv=class{constructor(e){T(this,"_core");this._core=e,this.__internal_bindMethods()}get path(){return this._core.path}__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)}},bv=class extends Sv{constructor(t,n){super(t);T(this,"_composerApi");this._composerApi=n}remove(){const t=this._composerApi.getState();if(!t)throw new Error("Composer is not available");return t.removeAttachment(this.getState().id)}},S0=class extends bv{get source(){return"thread-composer"}},b0=class extends bv{get source(){return"edit-composer"}},k0=class extends Sv{get source(){return"message"}remove(){throw new Error("Message attachments cannot be removed")}};const kv=Object.freeze([]),Cv=Object.freeze({}),C0=e=>Object.freeze({type:"thread",isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,attachments:e?.attachments??kv,text:e?.text??"",role:e?.role??"user",runConfig:e?.runConfig??Cv,attachmentAccept:e?.attachmentAccept??"",dictation:e?.dictation,quote:e?.quote,value:e?.text??""}),_0=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??kv,runConfig:e?.runConfig??Cv,attachmentAccept:e?.attachmentAccept??"",dictation:e?.dictation,quote:e?.quote,parentId:e?.parentId??null,sourceId:e?.sourceId??null,value:e?.text??""});var _v=class{constructor(e){T(this,"_core");T(this,"_eventSubscriptionSubjects",new Map);this._core=e}get path(){return this._core.path}__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){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.setText(e)}setRunConfig(e){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.setRunConfig(e)}addAttachment(e){const t=this._core.getState();if(!t)throw new Error("Composer is not available");return t.addAttachment(e)}reset(){const e=this._core.getState();if(!e)throw new Error("Composer is not available");return e.reset()}clearAttachments(){const e=this._core.getState();if(!e)throw new Error("Composer is not available");return e.clearAttachments()}send(e){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.send(e)}cancel(){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.cancel()}setRole(e){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.setRole(e)}startDictation(){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.startDictation()}stopDictation(){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.stopDictation()}setQuote(e){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.setQuote(e)}subscribe(e){return this._core.subscribe(e)}unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new wv({event:e,binding:this._core}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},E0=class extends _v{constructor(t){const n=new pd({path:t.path,getState:()=>C0(t.getState()),subscribe:r=>t.subscribe(r)});super({path:t.path,getState:()=>t.getState(),subscribe:r=>n.subscribe(r)});T(this,"_getState");this._getState=n.getState.bind(n),this.__internal_bindMethods()}get path(){return this._core.path}get type(){return"thread"}getState(){return this._getState()}getAttachmentByIndex(t){return new S0(new zt({path:{...this.path,attachmentSource:"thread-composer",attachmentSelector:{type:"index",index:t},ref:`${this.path.ref}.attachments[${t}]`},getState:()=>{const n=this.getState().attachments[t];return n?{...n,source:"thread-composer"}:Vt},subscribe:n=>this._core.subscribe(n)}),this._core)}},T0=class extends _v{constructor(t,n){const r=new pd({path:t.path,getState:()=>_0(t.getState()),subscribe:s=>t.subscribe(s)});super({path:t.path,getState:()=>t.getState(),subscribe:s=>r.subscribe(s)});T(this,"_beginEdit");T(this,"_getState");this._beginEdit=n,this._getState=r.getState.bind(r),this.__internal_bindMethods()}get path(){return this._core.path}get type(){return"edit"}__internal_bindMethods(){super.__internal_bindMethods(),this.beginEdit=this.beginEdit.bind(this)}getState(){return this._getState()}beginEdit(){this._beginEdit()}getAttachmentByIndex(t){return new b0(new zt({path:{...this.path,attachmentSource:"edit-composer",attachmentSelector:{type:"index",index:t},ref:`${this.path.ref}.attachments[${t}]`},getState:()=>{const n=this.getState().attachments[t];return n?{...n,source:"edit-composer"}:Vt},subscribe:n=>this._core.subscribe(n)}),this._core)}};const xi=e=>e.content.filter(t=>t.type==="text").map(t=>t.text).join(`
43
-
44
- `);var Ch=class{constructor(e,t,n){T(this,"contentBinding");T(this,"messageApi");T(this,"threadApi");this.contentBinding=e,this.messageApi=t,this.threadApi=n,this.__internal_bindMethods()}get path(){return this.contentBinding.path}__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){const t=this.contentBinding.getState();if(!t)throw new Error("Message part is not available");if(t.type!=="tool-call")throw new Error("Tried to add tool result to non-tool message part");if(!this.messageApi)throw new Error("Message API is not available. This is likely a bug in assistant-ui.");if(!this.threadApi)throw new Error("Thread API is not available");const n=this.messageApi.getState();if(!n)throw new Error("Message is not available");const r=t.toolName,s=t.toolCallId,i=fn.toResponse(e);this.threadApi.getState().addToolResult({messageId:n.id,toolName:r,toolCallId:s,result:i.result,artifact:i.artifact,isError:i.isError})}resumeToolCall(e){const t=this.contentBinding.getState();if(!t)throw new Error("Message part is not available");if(t.type!=="tool-call")throw new Error("Tried to resume tool call on non-tool message part");if(!this.threadApi)throw new Error("Thread API is not available");const n=t.toolCallId;this.threadApi.getState().resumeToolCall({toolCallId:n,payload:e})}respondToToolApproval(e){const t=this.contentBinding.getState();if(!t)throw new Error("Message part is not available");if(t.type!=="tool-call")throw new Error("Tried to respond to tool approval on non-tool message part");if(!t.approval||t.approval.approved!==void 0)throw new Error("Tool call has no pending approval");if(!this.threadApi)throw new 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)}};const Xi=Object.freeze({type:"complete"}),I0=(e,t,n)=>{if(e.role!=="assistant")return Xi;if(n.type==="tool-call")return n.result?Xi:e.status;const r=t===Math.max(0,e.content.length-1);return e.status.type==="requires-action"?Xi:r?e.status:Xi},_h=(e,t)=>{const n=e.content[t];if(!n)return Vt;const r=I0(e,t,n);return Object.freeze({...n,[fr]:n[fr],status:r})};var R0=class{constructor(e,t){T(this,"_core");T(this,"_threadBinding");T(this,"composer");T(this,"_getEditComposerRuntimeCore",()=>this._threadBinding.getState().getEditComposer(this._core.getState().id));this._core=e,this._threadBinding=t,this.composer=new T0(new ea({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.composer`,composerSource:"edit"},getState:this._getEditComposerRuntimeCore,subscribe:n=>this._threadBinding.subscribe(n)}),()=>this._threadBinding.getState().beginEdit(this._core.getState().id)),this.__internal_bindMethods()}get path(){return this._core.path}__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)}getState(){return this._core.getState()}reload(e={}){const t=this._getEditComposerRuntimeCore(),n=t??this._threadBinding.getState().composer,r=t??n,{runConfig:s=r.runConfig}=e,i=this._core.getState();if(i.role!=="assistant")throw new Error("Can only reload assistant messages");this._threadBinding.getState().startRun({parentId:i.parentId,sourceId:i.id,runConfig:s})}speak(){const e=this._core.getState();return this._threadBinding.getState().speak(e.id)}stopSpeaking(){const e=this._core.getState();if(this._threadBinding.getState().speech?.messageId===e.id)this._threadBinding.getState().stopSpeaking();else throw new Error("Message is not being spoken")}submitFeedback({type:e}){const t=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:t.id,type:e})}switchToBranch({position:e,branchId:t}){const n=this._core.getState();if(t&&e)throw new Error("May not specify both branchId and position");if(!t&&!e)throw new Error("Must specify either branchId or position");const r=this._threadBinding.getState().getBranches(n.id);let s=t;if(e==="previous"?s=r[n.branchNumber-2]:e==="next"&&(s=r[n.branchNumber]),!s)throw new Error("Branch not found");this._threadBinding.getState().switchToBranch(s)}unstable_getCopyText(){return xi(this.getState())}subscribe(e){return this._core.subscribe(e)}getMessagePartByIndex(e){if(e<0)throw new Error("Message part index must be >= 0");return new Ch(new zt({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.content[${e}]`,messagePartSelector:{type:"index",index:e}},getState:()=>_h(this.getState(),e),subscribe:t=>this._core.subscribe(t)}),this._core,this._threadBinding)}getMessagePartByToolCallId(e){return new Ch(new zt({path:{...this.path,ref:this.path.ref+`${this.path.ref}.content[toolCallId=${JSON.stringify(e)}]`,messagePartSelector:{type:"toolCallId",toolCallId:e}},getState:()=>{const t=this._core.getState(),n=t.content.findIndex(r=>r.type==="tool-call"&&r.toolCallId===e);return n===-1?Vt:_h(t,n)},subscribe:t=>this._core.subscribe(t)}),this._core,this._threadBinding)}getAttachmentByIndex(e){return new k0(new zt({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.attachments[${e}]`,attachmentSource:"message",attachmentSelector:{type:"index",index:e}},getState:()=>{const t=this.getState().attachments?.[e];return t?{...t,source:"message"}:Vt},subscribe:t=>this._core.subscribe(t)}))}};const P0=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{},...e.stream?{stream:e.stream}:{}}),A0=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{}}),j0=(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},N0=(e,t)=>{const 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"?!1:n.status.type==="running"),messages:e.messages,state:e.state,suggestions:e.suggestions,extras:e.extras,speech:e.speech,voice:e.voice})};var Ev=class{constructor(e,t){T(this,"_threadBinding");T(this,"composer");T(this,"_eventSubscriptionSubjects",new Map);const n=new zt({path:e.path,getState:()=>N0(e.getState(),t.getState()),subscribe:r=>{const s=e.subscribe(r),i=t.subscribe(r);return()=>{s(),i()}}});this._threadBinding={path:e.path,getState:()=>e.getState(),getStateState:()=>n.getState(),outerSubscribe:r=>e.outerSubscribe(r),subscribe:r=>e.subscribe(r)},this.composer=new E0(new ea({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:"thread"},getState:()=>this._threadBinding.getState().composer,subscribe:r=>this._threadBinding.subscribe(r)})),this.__internal_bindMethods()}get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}__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)}getState(){return this._threadBinding.getStateState()}append(e){this._threadBinding.getState().append(j0(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(A0(e))}resumeRun(e){return this._threadBinding.getState().resumeRun(P0(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 new Error("Message index must be >= 0");return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[${e}]`,messageSelector:{type:"index",index:e}},()=>{const 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 R0(new zt({path:e,getState:()=>{const{message:n,parentId:r,index:s}=t()??{},{messages:i,speech:o}=this._threadBinding.getState();if(!n||r===void 0||s===void 0)return Vt;const a=this._threadBinding.getState().getBranches(n.id);return{...n,[fr]:n[fr],index:s,isLast:i.at(-1)?.id===n.id,parentId:r,branchNumber:a.indexOf(n.id)+1,branchCount:a.length,speech:o?.messageId===n.id?o:void 0}},subscribe:n=>this._threadBinding.subscribe(n)}),this._threadBinding)}unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new wv({event:e,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}};const M0=m.createContext(null),L0=()=>m.useContext(M0);var Zi=class{constructor(e,t){T(this,"_core");T(this,"_threadListBinding");this._core=e,this._threadListBinding=t,this.__internal_bindMethods()}get path(){return this._core.path}__internal_bindMethods(){this.switchTo=this.switchTo.bind(this),this.rename=this.rename.bind(this),this.updateCustom=this.updateCustom.bind(this),this.archive=this.archive.bind(this),this.unarchive=this.unarchive.bind(this),this.delete=this.delete.bind(this),this.initialize=this.initialize.bind(this),this.generateTitle=this.generateTitle.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getState=this.getState.bind(this),this.detach=this.detach.bind(this)}getState(){return this._core.getState()}switchTo(e){const t=this._core.getState();return this._threadListBinding.switchToThread(t.id,e)}rename(e){const t=this._core.getState();return this._threadListBinding.rename(t.id,e)}updateCustom(e){const t=this._core.getState();if(!this._threadListBinding.updateCustom)throw new Error("Thread list runtime does not support updating custom metadata");return this._threadListBinding.updateCustom(t.id,e)}archive(){const e=this._core.getState();return this._threadListBinding.archive(e.id)}unarchive(){const e=this._core.getState();return this._threadListBinding.unarchive(e.id)}delete(){const e=this._core.getState();return this._threadListBinding.delete(e.id)}initialize(){const e=this._core.getState();return this._threadListBinding.initialize(e.id)}generateTitle(){const 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(()=>{const s=this._core.getState(),i=s.isMain,o=s.id;n===i&&r===o||(n=i,r=o,!(e==="switchedTo"&&!i)&&(e==="switchedAway"&&i||t({})))})}subscribe(e){return this._core.subscribe(e)}detach(){const e=this._core.getState();this._threadListBinding.detach(e.id)}__internal_getRuntime(){return this}};const Eh=Promise.resolve(),D0=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}),eo=(e,t)=>{if(t===void 0)return Vt;const 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}:Vt};var O0=class{constructor(e,t=Ev){T(this,"_core");T(this,"_runtimeFactory");T(this,"_getState");T(this,"_mainThreadListItemRuntime");T(this,"main");this._core=e,this._runtimeFactory=t;const n=new pd({path:{},getState:()=>D0(e),subscribe:r=>e.subscribe(r)});this._getState=n.getState.bind(n),this._mainThreadListItemRuntime=new Zi(new zt({path:{ref:"threadItems[main]",threadSelector:{type:"main"}},getState:()=>eo(this._core,this._core.mainThreadId),subscribe:r=>this._core.subscribe(r)}),this._core),this.main=new t(new ea({path:{ref:"threads.main",threadSelector:{type:"main"}},getState:()=>e.getMainThreadRuntimeCore(),subscribe:r=>e.subscribe(r)}),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?.()??Eh}loadMore(){return this._core.loadMore?.()??Eh}getState(){return this._getState()}subscribe(e){return this._core.subscribe(e)}get mainItem(){return this._mainThreadListItemRuntime}getById(e){return new this._runtimeFactory(new ea({path:{ref:`threads[threadId=${JSON.stringify(e)}]`,threadSelector:{type:"threadId",threadId:e}},getState:()=>this._core.getThreadRuntimeCore(e),subscribe:t=>this._core.subscribe(t)}),this.mainItem)}getItemByIndex(e){return new Zi(new zt({path:{ref:`threadItems[${e}]`,threadSelector:{type:"index",index:e}},getState:()=>eo(this._core,this._core.threadIds[e]),subscribe:t=>this._core.subscribe(t)}),this._core)}getArchivedItemByIndex(e){return new Zi(new zt({path:{ref:`archivedThreadItems[${e}]`,threadSelector:{type:"archiveIndex",index:e}},getState:()=>eo(this._core,this._core.archivedThreadIds[e]),subscribe:t=>this._core.subscribe(t)}),this._core)}getItemById(e){return new Zi(new zt({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:"threadId",threadId:e}},getState:()=>eo(this._core,e),subscribe:t=>this._core.subscribe(t)}),this._core)}},Tv=class{constructor(e){T(this,"_core");T(this,"threads");T(this,"_thread");this._core=e,this.threads=new O0(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)}},Iv=class{constructor(){T(this,"_contextProvider",new od)}registerModelContextProvider(e){return this._contextProvider.registerModelContextProvider(e)}getModelContextProvider(){return this._contextProvider}};const Qn=Object.freeze([]),Gr="DEFAULT_THREAD_ID",z0=Object.freeze([Gr]),F0=Object.freeze({id:Gr,remoteId:void 0,externalId:void 0,status:"regular"}),B0=Promise.resolve(),Th=Object.freeze({[Gr]:F0});var $0=class{constructor(e={},t){T(this,"threadFactory");T(this,"_mainThreadId",Gr);T(this,"_threads",z0);T(this,"_archivedThreads",Qn);T(this,"_threadData",Th);T(this,"adapter",{});T(this,"_mainThread");T(this,"_subscriptions",new Set);this.threadFactory=t,this.__internal_setAdapter(e,!0)}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 B0}get mainThreadId(){return this._mainThreadId}getMainThreadRuntimeCore(){return this._mainThread}getThreadRuntimeCore(){throw new Error("Method not implemented.")}getItemById(e){return this._threadData[e]}__internal_setAdapter(e,t=!1){const n=this.adapter;this.adapter=e;const r=e.threadId??Gr,s=e.threads??Qn,i=e.archivedThreads??Qn,o=n.threadId??Gr,a=n.threads??Qn,l=n.archivedThreads??Qn;!t&&o===r&&a===s&&l===i||((a!==s||l!==i||o!==r)&&(this._threadData={...Th,...Object.fromEntries(e.threads?.map(u=>[u.id,{...u,remoteId:u.remoteId,externalId:u.externalId,status:"regular"}])??[]),...Object.fromEntries(e.archivedThreads?.map(u=>[u.id,{...u,remoteId:u.remoteId,externalId:u.externalId,status:"archived"}])??[])}),a!==s&&(this._threads=this.adapter.threads?.map(u=>u.id)??Qn),l!==i&&(this._archivedThreads=this.adapter.archivedThreads?.map(u=>u.id)??Qn),(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;const n=this.adapter.onSwitchToThread;if(!n)throw new Error("External store adapter does not support switching to thread");await n(e)}async switchToNewThread(){const e=this.adapter.onSwitchToNewThread;if(!e)throw new Error("External store adapter does not support switching to new thread");await e()}async rename(e,t){const n=this.adapter.onRename;if(!n)throw new Error("External store adapter does not support renaming");await n(e,t)}async updateCustom(e,t){const n=this.adapter.onUpdateCustom;if(!n)throw new Error("External store adapter does not support updating custom metadata");await n(e,t)}async detach(){}async archive(e){const t=this.adapter.onArchive;if(!t)throw new Error("External store adapter does not support archiving");await t(e)}async unarchive(e){const t=this.adapter.onUnarchive;if(!t)throw new Error("External store adapter does not support unarchiving");await t(e)}async delete(e){const t=this.adapter.onDelete;if(!t)throw new Error("External store adapter does not support deleting");await t(e)}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){throw new Error("Method not implemented.")}subscribe(e){return this._subscriptions.add(e),()=>this._subscriptions.delete(e)}_notifySubscribers(){for(const e of this._subscriptions)e()}};const Un=dv("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7),fs=Symbol("autoStatus"),U0=Object.freeze(Object.assign({type:"running"},{[fs]:!0})),V0=Object.freeze(Object.assign({type:"complete",reason:"unknown"},{[fs]:!0})),H0=Object.freeze(Object.assign({type:"requires-action",reason:"tool-calls"},{[fs]:!0})),W0=Object.freeze(Object.assign({type:"requires-action",reason:"interrupt"},{[fs]:!0})),q0=e=>e[fs]===!0,ta=(e,t,n,r,s)=>e&&s?Object.assign({type:"incomplete",reason:"error",error:s},{[fs]:!0}):e&&t?U0:n?W0:r?H0:V0,_l=(e,t)=>{if(e.startsWith("data-"))return{type:"data",name:e.substring(5),data:t}},wi=(e,t,n)=>{const{role:r,id:s,createdAt:i,attachments:o,status:a,metadata:l}=e,u={id:s??t,createdAt:i??new Date},f=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content,d=({image:h,...p})=>h.match(/^data:image\/(png|jpeg|jpg|gif|webp|svg\+xml);base64,(.*)$/)?{...p,image:h}:/^(https:\/\/|blob:)/.test(h)?{...p,image:h}:(console.warn("Invalid image data format detected"),null);if(r!=="user"&&o?.length)throw new Error("attachments are only supported for user messages");if(r!=="assistant"&&a)throw new Error("status is only supported for assistant messages");if(r!=="assistant"&&l?.steps)throw new Error("metadata.steps is only supported for assistant messages");switch(r){case"assistant":return{...u,role:r,content:f.map(h=>{const p=h.type;switch(p){case"text":case"reasoning":return h.text.trim().length===0?null:h;case"file":case"source":return h;case"image":return d(h);case"data":return h;case"generative-ui":return h;case"tool-call":{const{parentId:g,messages:x,...k}=h,y={...k,toolCallId:h.toolCallId??`tool-${Un()}`,...g!==void 0&&{parentId:g},...x!==void 0&&{messages:x}};return h.args?{...y,args:h.args,argsText:h.argsText??JSON.stringify(h.args)}:{...y,args:Hu(h.argsText??"")??{},argsText:h.argsText??""}}default:{const g=_l(p,h.data);if(g)return g;throw new Error(`Unsupported assistant message part type: ${p}`)}}}).filter(h=>!!h),status:a??n,metadata:{unstable_state:l?.unstable_state??null,unstable_annotations:l?.unstable_annotations??[],unstable_data:l?.unstable_data??[],custom:l?.custom??{},steps:l?.steps??[],...l?.timing&&{timing:l.timing},...l?.submittedFeedback&&{submittedFeedback:l.submittedFeedback},...l?.isOptimistic&&{isOptimistic:!0}}};case"user":return{...u,role:r,content:f.map(h=>{const p=h.type;switch(p){case"text":case"image":case"audio":case"file":case"data":return h;default:{const g=_l(p,h.data);if(g)return g;throw new Error(`Unsupported user message part type: ${p}`)}}}),attachments:(o??[]).map(h=>({...h,content:h.content.map(p=>_l(p.type,p.data)??p)})),metadata:{custom:l?.custom??{}}};case"system":if(f.length!==1||f[0].type!=="text")throw new Error("System messages must have exactly one text message part.");return{...u,role:r,content:f,metadata:{custom:l?.custom??{}}};default:throw new Error(`Unknown message role: ${r}`)}},Rv={fromArray:e=>{const t=e.map(n=>wi(n,Un(),ta(!1,!1,!1,!1,void 0)));return{messages:t.map((n,r)=>({parentId:r>0?t[r-1].id:null,message:n}))}},fromBranchableArray:(e,t)=>{const n=ta(!1,!1,!1,!1,void 0);return{...t?.headId!==void 0?{headId:t.headId}:void 0,messages:e.map(({message:r,parentId:s})=>{if(!r.id)throw new Error("ExportedMessageRepository.fromBranchableArray: Each message must have an 'id' field set.");return{parentId:s,message:wi(r,r.id,n)}})}}},bo=e=>e.next?bo(e.next):"current"in e?e:null;var K0=class{constructor(e){T(this,"func");T(this,"_value",null);this.func=e}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},md=class{constructor(){T(this,"messages",new Map);T(this,"head",null);T(this,"root",{children:[],next:null});T(this,"_messages",new K0(()=>{const e=new Array((this.head?.level??-1)+1);for(let t=this.head;t;t=t.prev)e[t.level]=t.current;return e}))}updateLevels(e,t){e.level=t;for(const n of e.children){const r=this.messages.get(n);r&&this.updateLevels(r,t+1)}}performOp(e,t,n){const r=t.prev??this.root,s=e??this.root;if(!(n==="relink"&&r===s)){if(n!=="link"&&(r.children=r.children.filter(i=>i!==t.current.id),r.next===t)){const i=r.children.at(-1),o=i?this.messages.get(i):null;if(o===void 0)throw new Error("MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.");r.next=o}if(n!=="cut"){for(let o=e;o;o=o.prev)if(o.current.id===t.current.id)throw new 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.");s.children=[...s.children,t.current.id],(bo(t)===this.head||s.next===null)&&(s.next=t),t.prev=e;const i=e?e.level+1:0;this.updateLevels(t,i)}}}get headId(){return this.head?.current.id??null}getMessages(e){if(e===void 0||e===this.head?.current.id)return this._messages.value;const t=this.messages.get(e);if(!t)throw new Error("MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.");const n=new Array(t.level+1);for(let r=t;r;r=r.prev)n[r.level]=r.current;return n}addOrUpdateMessage(e,t){const n=this.messages.get(t.id),r=e?this.messages.get(e):null;if(r===void 0)throw new 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}const s={prev:r,current:t,next:null,children:[],level:r?r.level+1:0};this.messages.set(t.id,s),this.performOp(r,s,"link"),this.head===r&&(this.head=s),this._messages.dirty()}getMessage(e){const t=this.messages.get(e);if(!t)throw new 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){const n=this.messages.get(e);if(!n)throw new Error("MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.");const r=t===void 0?n.prev:t===null?null:this.messages.get(t);if(r===void 0)throw new Error("MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.");for(const s of n.children){const i=this.messages.get(s);if(!i)throw new Error("MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.");this.performOp(r,i,"relink")}this.performOp(null,n,"cut"),this.messages.delete(e),this.head===n&&(this.head=bo(r??this.root)),this._messages.dirty()}getBranches(e){const t=this.messages.get(e);if(!t)throw new Error("MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.");const{children:n}=t.prev??this.root;return n}evictOffBranchOptimisticMessages(e,t){if(!e)return;const n=new Set;for(let s=t;s;s=s.prev)n.add(s.current.id);const r=[];for(let s=e;s&&!n.has(s.current.id);s=s.prev)s.current.metadata?.isOptimistic&&r.push(s.current.id);for(const s of r)this.messages.has(s)&&this.deleteMessage(s)}switchToBranch(e){const t=this.messages.get(e);if(!t)throw new Error("MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.");const n=this.head,r=t.prev??this.root;r.next=t,this.head=bo(t),this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}resetHead(e){if(e===null){this.clear();return}const t=this.messages.get(e);if(!t)throw new Error("MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.");const n=this.head;if(t.children.length>0){const r=s=>{for(const i of s.children){const o=this.messages.get(i);o&&(r(o),this.messages.delete(i))}};r(t),t.children=[],t.next=null}this.head=t;for(let r=t;r;r=r.prev)r.prev?r.prev.next=r:this.root.next=r;this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){const e=[];for(const[,n]of this.messages)n.current.metadata?.isOptimistic||e.push({message:n.current,parentId:n.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(const{message:n,parentId:r}of t)this.addOrUpdateMessage(r,n);this.resetHead(e??t.at(-1)?.message.id??null)}};function Ih(e,t){if(t==="*")return!0;const n=t.split(",").map(i=>i.trim().toLowerCase()),r=`.${e.name.split(".").pop().toLowerCase()}`,s=e.type.toLowerCase();for(const i of n){if(i.startsWith(".")&&i===r||i.includes("/")&&i===s)return!0;if(i.endsWith("/*")){const o=i.split("/")[0];if(s.startsWith(`${o}/`))return!0}}return!1}function G0(e,t){return e.length!==t.length?!1:e.every((n,r)=>n.id===t[r].id)}function Q0(e){const t=Un();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 Y0(e){const t=[];for(const n of e)n.type!=="text"&&t.push(Q0(n));return t}const El=e=>e.status.type==="complete";var Pv=class extends w0{constructor(){super(...arguments);T(this,"isEditing",!0);T(this,"_attachments",[]);T(this,"_text","");T(this,"_role","user");T(this,"_runConfig",{});T(this,"_quote");T(this,"_dictation");T(this,"_dictationSession");T(this,"_dictationUnsubscribes",[]);T(this,"_dictationBaseText","");T(this,"_currentInterimText","");T(this,"_dictationSessionIdCounter",0);T(this,"_activeDictationSessionId");T(this,"_isCleaningDictation",!1);T(this,"_eventSubscribers",new Map)}get attachmentAccept(){return this.getAttachmentAdapter()?.accept??"*"}get attachments(){return this._attachments}setAttachments(t){this._attachments=t,this._notifySubscribers()}get isEmpty(){return!this.text.trim()&&!this.attachments.length}get text(){return this._text}get role(){return this._role}get runConfig(){return this._runConfig}get quote(){return this._quote}setQuote(t){this._quote!==t&&(this._quote=t,this._notifySubscribers())}setText(t){if(this._text!==t){if(this._text=t,this._dictation){this._dictationBaseText=t,this._currentInterimText="";const{status:n,inputDisabled:r}=this._dictation;this._dictation=r?{status:n,inputDisabled:r}:{status:n}}this._notifySubscribers()}}setRole(t){this._role!==t&&(this._role=t,this._notifySubscribers())}setRunConfig(t){this._runConfig!==t&&(this._runConfig=t,this._notifySubscribers())}_emptyTextAndAttachments(){this._attachments=[],this._text="",this._notifySubscribers()}async _onClearAttachments(){const t=this.getAttachmentAdapter();if(t){const n=this._attachments.filter(r=>!El(r));await Promise.all(n.map(r=>t.remove(r)))}}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;const t=this._onClearAttachments();this._emptyTextAndAttachments(),await t}async clearAttachments(){const t=this._onClearAttachments();this.setAttachments([]),await t}async send(t){if(!this.canSend)return;this._dictationSession&&(this._dictationSession.cancel(),this._cleanupDictation());const n=this.getAttachmentAdapter(),r=this.attachments.length>0?Promise.all(this.attachments.map(async a=>{if(El(a))return a;if(!n)throw new Error("Attachments are not supported");return await n.send(a)})):[],s=this.text,i=this._quote;this._quote=void 0,this._emptyTextAndAttachments();const o={createdAt:new Date,role:this.role,content:s?[{type:"text",text:s}]:[],attachments:await r,runConfig:this.runConfig,metadata:{custom:{...i?{quote:i}:{}}}};this.handleSend(o,t),this._notifyEventSubscribers("send",{})}cancel(){this.handleCancel()}async addAttachment(t){if(!(t instanceof File)){const i=this.getAttachmentAdapter();if(i&&!Ih({name:t.name,type:t.contentType??""},i.accept)){const a=`File type ${t.contentType||"unknown"} is not accepted. Accepted types: ${i.accept}`,l=new Error(a);throw this._safeEmitAttachmentAddError("not-accepted",a,void 0,l),l}const o={id:t.id??Un(),type:t.type??"document",name:t.name,contentType:t.contentType,content:t.content,status:{type:"complete"}};this._attachments=[...this._attachments,o],this._notifySubscribers(),this._notifyEventSubscribers("attachmentAdd",{});return}const n=i=>{const o=this._attachments.findIndex(a=>a.id===i.id);o!==-1?this._attachments=[...this._attachments.slice(0,o),i,...this._attachments.slice(o+1)]:this._attachments=[...this._attachments,i],this._notifySubscribers()},r=this.getAttachmentAdapter();if(!r){const i="Attachments are not supported",o=new Error(i);throw this._safeEmitAttachmentAddError("no-adapter",i,void 0,o),o}if(!Ih({name:t.name,type:t.type},r.accept)){const i=`File type ${t.type||"unknown"} is not accepted. Accepted types: ${r.accept}`,o=new Error(i);throw this._safeEmitAttachmentAddError("not-accepted",i,void 0,o),o}let s;try{const i=r.add({file:t});if(Symbol.asyncIterator in i)for await(const o of i)s=o,n(o);else s=await i,n(s)}catch(i){throw s&&n({...s,status:{type:"incomplete",reason:"error"}}),this._safeEmitAttachmentAddError("adapter-error",i instanceof Error?i.message:String(i),s?.id,i instanceof Error?i:void 0),i}s?.status.type==="incomplete"&&s.status.reason==="error"?this._safeEmitAttachmentAddError("adapter-error","Attachment upload did not complete successfully.",s?.id):this._notifyEventSubscribers("attachmentAdd",{})}_safeEmitAttachmentAddError(t,n,r,s){try{this._notifyEventSubscribers("attachmentAddError",{reason:t,message:n,...r!==void 0&&{attachmentId:r},...s!==void 0&&{error:s}})}catch(i){console.error("[assistant-ui] attachmentAddError subscriber threw:",i)}}async removeAttachment(t){const n=this._attachments.findIndex(s=>s.id===t);if(n===-1)throw new Error("Attachment not found");const r=this._attachments[n];if(!El(r)){const s=this.getAttachmentAdapter();if(!s)throw new Error("Attachments are not supported");await s.remove(r)}this._attachments=this._attachments.filter(s=>s.id!==t),this._notifySubscribers()}get dictation(){return this._dictation}_isActiveSession(t,n){return this._activeDictationSessionId===t&&this._dictationSession===n}startDictation(){const t=this.getDictationAdapter();if(!t)throw new Error("Dictation adapter not configured");if(this._dictationSession){for(const u of this._dictationUnsubscribes)u();this._dictationUnsubscribes=[],this._dictationSession.stop().catch(()=>{}),this._dictationSession=void 0}const n=t.disableInputDuringDictation??!1;this._dictationBaseText=this._text,this._currentInterimText="";const r=t.listen();this._dictationSession=r;const s=++this._dictationSessionIdCounter;this._activeDictationSessionId=s,this._dictation={status:r.status,inputDisabled:n},this._notifySubscribers();const i=r.onSpeech(u=>{if(!this._isActiveSession(s,r))return;const f=u.isFinal!==!1,d=this._dictationBaseText&&!this._dictationBaseText.endsWith(" ")&&u.transcript?" ":"";if(f){if(this._dictationBaseText=this._dictationBaseText+d+u.transcript,this._currentInterimText="",this._text=this._dictationBaseText,this._dictation){const{transcript:h,...p}=this._dictation;this._dictation=p}this._notifySubscribers()}else this._currentInterimText=d+u.transcript,this._text=this._dictationBaseText+this._currentInterimText,this._dictation&&(this._dictation={...this._dictation,transcript:u.transcript}),this._notifySubscribers()});this._dictationUnsubscribes.push(i);const o=r.onSpeechStart(()=>{this._isActiveSession(s,r)&&(this._dictation={status:{type:"running"},inputDisabled:n,...this._dictation?.transcript&&{transcript:this._dictation.transcript}},this._notifySubscribers())});this._dictationUnsubscribes.push(o);const a=r.onSpeechEnd(()=>{this._cleanupDictation({sessionId:s})});this._dictationUnsubscribes.push(a);const l=setInterval(()=>{this._isActiveSession(s,r)&&r.status.type==="ended"&&this._cleanupDictation({sessionId:s})},100);this._dictationUnsubscribes.push(()=>clearInterval(l))}stopDictation(){if(!this._dictationSession)return;const t=this._dictationSession,n=this._activeDictationSessionId;t.stop().finally(()=>{this._cleanupDictation({sessionId:n})})}_cleanupDictation(t){if(!(t?.sessionId!==void 0&&t.sessionId!==this._activeDictationSessionId||this._isCleaningDictation)){this._isCleaningDictation=!0;try{for(const n of this._dictationUnsubscribes)n();this._dictationUnsubscribes=[],this._dictationSession=void 0,this._activeDictationSessionId=void 0,this._dictation=void 0,this._dictationBaseText="",this._currentInterimText="",this._notifySubscribers()}finally{this._isCleaningDictation=!1}}}_notifyEventSubscribers(t,n){const r=this._eventSubscribers.get(t);if(r)for(const s of r)s(n)}unstable_on(t,n){const r=n;let s=this._eventSubscribers.get(t);return s||(s=new Set,this._eventSubscribers.set(t,s)),s.add(r),()=>{this._eventSubscribers.get(t)?.delete(r)}}},Av=class extends Pv{constructor(t){super();T(this,"runtime");T(this,"_canCancel",!1);this.runtime=t,this.connect()}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}connect(){let t=this.runtime.isSendDisabled;return this.runtime.subscribe(()=>{let n=!1;this.canCancel!==this.runtime.capabilities.cancel&&(this._canCancel=this.runtime.capabilities.cancel,n=!0),t!==this.runtime.isSendDisabled&&(t=this.runtime.isSendDisabled,n=!0),n&&this._notifySubscribers()})}async handleSend(t,n){this.runtime.append({...t,parentId:this.runtime.messages.at(-1)?.id??null,sourceId:null,startRun:n?.startRun})}async handleCancel(){this.runtime.cancelRun()}},J0=class extends Pv{constructor(t,n,{parentId:r,message:s}){super();T(this,"runtime");T(this,"endEditCallback");T(this,"_previousText");T(this,"_previousAttachments");T(this,"_nonTextPassthrough");T(this,"_parentId");T(this,"_sourceId");this.runtime=t,this.endEditCallback=n,this._parentId=r,this._sourceId=s.id,this._previousText=xi(s),this.setText(this._previousText),this.setRole(s.role),s.role==="user"?(this._previousAttachments=[...s.attachments??[],...Y0(s.content)],this._nonTextPassthrough=[]):(this._previousAttachments=s.attachments??[],this._nonTextPassthrough=s.content.filter(i=>i.type!=="text")),this.setAttachments(this._previousAttachments),this.setRunConfig({...t.composer.runConfig})}get canCancel(){return!0}get canSend(){return!this.isEmpty}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}get parentId(){return this._parentId}get sourceId(){return this._sourceId}async handleSend(t,n){const r=xi(t),s=!G0(t.attachments??[],this._previousAttachments);if(r!==this._previousText||s||n?.startRun){const i=this._nonTextPassthrough.length>0?[...t.content,...this._nonTextPassthrough]:t.content;this.runtime.append({...t,content:i,parentId:this._parentId,sourceId:this._sourceId,startRun:n?.startRun})}this.handleCancel()}handleCancel(){this.endEditCallback(),this._notifySubscribers()}},X0=class{constructor(e){T(this,"_contextProvider");T(this,"_subscriptions",new Set);T(this,"_isInitialized",!1);T(this,"repository",new md);T(this,"_voiceMessages",[]);T(this,"_voiceGeneration",0);T(this,"_cachedMergedMessages",null);T(this,"_cachedVoiceGeneration",-1);T(this,"_cachedMergedBase",null);T(this,"composer",new Av(this));T(this,"_editComposers",new Map);T(this,"_stopSpeaking");T(this,"speech");T(this,"_voiceSession");T(this,"_voiceUnsubs",[]);T(this,"voice");T(this,"_voiceVolume",0);T(this,"_voiceVolumeSubscribers",new Set);T(this,"getVoiceVolume",()=>this._voiceVolume);T(this,"subscribeVoiceVolume",e=>(this._voiceVolumeSubscribers.add(e),()=>this._voiceVolumeSubscribers.delete(e)));T(this,"_currentAssistantMsg",null);T(this,"_eventSubscribers",new Map);this._contextProvider=e}_markVoiceMessagesDirty(){this._voiceGeneration++,this._cachedMergedMessages=null}_getBaseMessages(){return this.repository.getMessages()}get messages(){if(this._voiceMessages.length===0)return this._getBaseMessages();const 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(const t of this.messages)t.role==="assistant"&&(e=t);return e?.metadata.unstable_state??null}getModelContext(){return this._contextProvider.getModelContext()}getEditComposer(e){return this._editComposers.get(e)}beginEdit(e){if(this._editComposers.has(e))throw new Error("Edit already in progress");this._editComposers.set(e,new J0(this,()=>this._editComposers.delete(e),this.repository.getMessage(e))),this._notifySubscribers()}getMessageById(e){try{return this.repository.getMessage(e)}catch{const t=this.repository.getMessages(),n=this._voiceMessages.findIndex(r=>r.id===e);return n!==-1?{parentId:n>0?this._voiceMessages[n-1].id:t.at(-1)?.id??null,message:this._voiceMessages[n],index:t.length+n}:void 0}}getBranches(e){return this._voiceMessages.some(t=>t.id===e)?[]:this.repository.getBranches(e)}switchToBranch(e){this.repository.switchToBranch(e),this._notifySubscribers()}_notifySubscribers(){for(const e of this._subscriptions)e()}_notifyEventSubscribers(e,t){const n=this._eventSubscribers.get(e);if(n)for(const r of n)r(t)}subscribe(e){return this._subscriptions.add(e),()=>this._subscriptions.delete(e)}submitFeedback({messageId:e,type:t}){const n=this.adapters?.feedback;if(!n)throw new Error("Feedback adapter not configured");const{message:r,parentId:s}=this.repository.getMessage(e);if(n.submit({message:r,type:t}),r.role==="assistant"){const i={...r,metadata:{...r.metadata,submittedFeedback:{type:t}}};this.repository.addOrUpdateMessage(s,i)}this._notifySubscribers()}speak(e){const t=this.adapters?.speech;if(!t)throw new Error("Speech adapter not configured");const{message:n}=this.repository.getMessage(e);this._stopSpeaking?.();const r=t.speak(xi(n)),s=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(),s(),this.speech=void 0,this._stopSpeaking=void 0}}stopSpeaking(){if(!this._stopSpeaking)throw new Error("No message is being spoken");this._stopSpeaking(),this._notifySubscribers()}connectVoice(){const e=this.adapters?.voice;if(!e)throw new Error("Voice adapter not configured");this.disconnectVoice();const t=e.connect({});this._voiceSession=t;const n=[];let r="listening";this.voice={status:t.status,isMuted:t.isMuted,mode:r},this._voiceVolume=0,this._notifySubscribers(),n.push(t.onStatusChange(s=>{s.type==="ended"?(this._finishVoiceAssistantMessage(),this._voiceSession=void 0,this.voice=void 0):this.voice={status:s,isMuted:t.isMuted,mode:r},this._notifySubscribers()})),n.push(t.onModeChange(s=>{r=s,this.voice&&(this.voice={...this.voice,mode:s},this._notifySubscribers())})),n.push(t.onVolumeChange(s=>{this._voiceVolume=s;for(const i of this._voiceVolumeSubscribers)i()})),n.push(t.onTranscript(s=>{this._handleVoiceTranscript(s)})),this._voiceUnsubs=n}_handleVoiceTranscript(e){if(this.ensureInitialized(),e.role==="user")this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null,e.isFinal&&(this._voiceMessages.push({id:Un(),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:Un(),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{const t=this._voiceMessages.indexOf(this._currentAssistantMsg);if(t===-1)return;const 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(){const e=this._voiceMessages.at(-1);if(e?.role==="assistant"&&e.status.type==="running"){const 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(const e of this._voiceUnsubs)e();this._voiceUnsubs=[],this._voiceSession?.disconnect(),this._voiceSession=void 0,this.voice=void 0,this._voiceVolume=0;for(const e of this._voiceVolumeSubscribers)e();this._voiceMessages=[],this._markVoiceMessagesDirty(),this._notifySubscribers()}muteVoice(){if(!this._voiceSession)throw new Error("No active voice session");this._voiceSession.mute(),this.voice={...this.voice,isMuted:!0},this._notifySubscribers()}unmuteVoice(){if(!this._voiceSession)throw new 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(Rv.fromArray(e??[]))}unstable_on(e,t){const 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)}}},Rh=class{constructor(){T(this,"cache",new WeakMap)}convertMessages(e,t){return e.map((n,r)=>{const s=t(this.cache.get(n),n,r);return this.cache.set(n,s),s})}};function qu(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function na(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(n=>na(n,t+1)):qu(e)?Object.entries(e).every(([n,r])=>typeof n=="string"&&na(r,t+1)):!1}const Z0=100,Ku=(e,t,n)=>{if(e===t)return!0;if(n>Z0||e==null||t==null)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.every((i,o)=>Ku(i,t[o],n+1));if(Array.isArray(t)||!qu(e)||!qu(t))return!1;const r=Object.keys(e),s=Object.keys(t);return r.length!==s.length?!1:r.every(i=>Object.hasOwn(t,i)&&Ku(e[i],t[i],n+1))},e1=(e,t)=>!na(e)||!na(t)?!1:Ku(e,t,0),to=e=>{try{return JSON.parse(e),!0}catch{return!1}},Ph=e=>{try{return JSON.parse(e)}catch{return}},Ah=(e,t)=>{const n=Ph(e),r=Ph(t);return n===void 0||r===void 0?!1:e1(n,r)};var t1=class{constructor(e,t){T(this,"_getTools");T(this,"_callbacks");T(this,"_entries",new Map);T(this,"_skipExecuteStreamIds",new Set);T(this,"_humanInput",new Map);T(this,"_executing",new Set);T(this,"_settledResolvers",[]);T(this,"_statuses",new Map);T(this,"_ac",new AbortController);T(this,"_pendingRestore",!0);T(this,"_lastSnapshot",null);T(this,"_isRunning",!1);T(this,"_controller");T(this,"_pipelineDead",!1);T(this,"_pipelineRestartUsed",!1);this._getTools=e,this._callbacks=t,this._initPipeline()}_initPipeline(){const[e,t]=W_();this._controller=t;const n=c0(()=>this._getWrappedTools(),()=>this._ac.signal,(r,s)=>this._onHumanInput(r,s),{onExecutionStart:r=>this._onExecutionStart(r),onExecutionEnd:r=>this._onExecutionEnd(r)});e.pipeThrough(n).pipeThrough(new cv).pipeTo(new WritableStream({write:r=>{try{if(r.type!=="result")return;this._handleResultChunk(r)}catch(s){console.error("[ToolInvocationTracker] result chunk handling failed",s)}}})).catch(r=>{console.error("[ToolInvocationTracker] stream pipeline failed; will attempt single restart on next setState",r),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);const t=this._isRunning;this._isRunning=e.isRunning;try{this._processMessages(e.messages)}catch(n){throw this._isRunning=t,n}this._lastSnapshot=e,this._pendingRestore=!1}catch(t){console.error("[ToolInvocationTracker] setState failed; snapshot dropped",t)}}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(new 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{const n=this._humanInput.get(e);return n?(this._humanInput.delete(e),this._setStatus(e,{type:"executing"}),n.resolve(t),!0):!1}catch(n){return console.error("[ToolInvocationTracker] resume failed",n),!1}}getStatuses(){return this._statuses}_getWrappedTools(){const e=this._getTools();if(e)return Object.fromEntries(Object.entries(e).map(([t,n])=>{const r=n.execute;return r===void 0?[t,n]:[t,{...n,execute:(...[s,i])=>this._skipExecuteStreamIds.has(i.toolCallId)?new Promise(()=>{}):r(s,i)}]}))}_onHumanInput(e,t){return new Promise((n,r)=>{const s=this._humanInput.get(e);if(s)try{s.reject(new 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(t=>{try{t()}catch{}}))}_handleResultChunk(e){const 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(t){console.error("[ToolInvocationTracker] onResult callback threw; result dropped",t)}}_invokeOnStatusesChange(){try{this._callbacks.onStatusesChange(this._statuses)}catch(e){console.error("[ToolInvocationTracker] onStatusesChange callback threw; status change not propagated",e)}}_setStatus(e,t){const n=new Map(this._statuses);n.set(e,t),this._statuses=n,this._invokeOnStatusesChange()}_deleteStatus(e){if(!this._statuses.has(e))return;const t=new Map(this._statuses);t.delete(e),this._statuses=t,this._invokeOnStatusesChange()}_hasExecutableTool(e){const 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)&&to(t)}_startActiveEntry(e,t,n){const r=this._controller.addToolCallPart({toolName:t,toolCallId:e});n&&this._skipExecuteStreamIds.add(e);const s={toolName:t,controller:r,argsText:"",hasResult:!1,argsComplete:!1};return this._entries.set(e,s),s}_demoteEntriesToRestored(){for(const[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;const n=t.result!==void 0;if(t.argsText!==e.argsText){let r=!0;if(e.argsComplete)Ah(e.argsText,t.argsText)&&(e.argsText=t.argsText),r=!1;else if(!t.argsText.startsWith(e.argsText))if(to(e.argsText)&&to(t.argsText)&&Ah(e.argsText,t.argsText)){const s=this._shouldCloseArgsStream({toolName:t.toolName,argsText:t.argsText,hasResult:n});s&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=s,r=!1}else r=!1;if(r&&e.controller){const s=t.argsText.slice(e.argsText.length);e.controller.argsText.append(s);const 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){const t=this._pendingRestore;for(const n of e)if(!(!n||!Array.isArray(n.content)))for(const r of n.content){if(!r||r.type!=="tool-call")continue;const s=this._entries.get(r.toolCallId);if(t){s?.controller||this._entries.set(r.toolCallId,{toolName:r.toolName,argsText:r.argsText,hasResult:r.result!==void 0}),r.messages&&this._processMessages(r.messages);continue}let i=s;if(i&&!i.controller){if(!(r.argsText!==i.argsText||r.result!==void 0!==i.hasResult)){r.messages&&this._processMessages(r.messages);continue}this._entries.delete(r.toolCallId),i=void 0}if(i||(i=this._startActiveEntry(r.toolCallId,r.toolName,r.result!==void 0)),this._processArgsText(i,r),r.result!==void 0&&!i.hasResult){const{controller:o}=i;if(!o)continue;i.hasResult=!0,i.argsComplete=!0,o.setResponse(new fn({result:r.result,artifact:r.artifact,isError:r.isError,...r.modelContent!==void 0?{modelContent:r.modelContent}:{}})),o.close()}r.messages&&this._processMessages(r.messages)}}};const n1=Object.freeze([]),jh=(e,t)=>{const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(e[r]!==t[r])return!1;return!0},r1=(e,t)=>e&&t[t.length-1]?.role!=="assistant";var s1=class extends X0{constructor(t,n){super(t);T(this,"_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});T(this,"_messages");T(this,"isDisabled");T(this,"isSendDisabled");T(this,"suggestions",[]);T(this,"extras");T(this,"_converter",new Rh);T(this,"_store");T(this,"_toolInvocations",null);T(this,"_toolCallToMessageId",new Map);T(this,"_messagesForToolCallIndex",null);T(this,"updateMessages",t=>{this._store.convertMessage!==void 0?this._store.setMessages?.(t.flatMap(v0)):this._store.setMessages?.(t)});this.__internal_setAdapter(n)}get capabilities(){return this._capabilities}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}beginEdit(t){if(!this._store.onEdit)throw new Error("Runtime does not support editing.");super.beginEdit(t)}__internal_setAdapter(t){if(this._store===t)return;const n=t.isRunning??!1;this.isDisabled=t.isDisabled??!1,this.isSendDisabled=t.isSendDisabled??!1;const r=this._store;this._store=t,this.extras!==t.extras&&(this.extras=t.extras);const s=t.suggestions??n1;jh(this.suggestions,s)||(this.suggestions=s);const 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};jh(this._capabilities,i)||(this._capabilities=i);let o;if(t.messageRepository){if(r&&r.isRunning===t.isRunning&&r.messageRepository===t.messageRepository){this._notifySubscribers();return}this.repository.clear(),this.repository.import(t.messageRepository),o=this.repository.getMessages()}else if(t.messages){if(r){if(r.convertMessage!==t.convertMessage)this._converter=new Rh;else if(r.isRunning===t.isRunning&&r.messages===t.messages){this._notifySubscribers();return}}o=t.convertMessage?this._converter.convertMessages(t.messages,(l,u,f)=>{if(!t.convertMessage)return u;const d=ta(f===(t.messages?.length??0)-1,n,!1,!1,void 0);if(l&&(l.role!=="assistant"||!q0(l.status)||l.status===d))return l;const h=wi(t.convertMessage(u,f),f.toString(),d);return y0(h,u),h}):t.messages;for(let l=0;l<o.length;l++){const u=o[l],f=o[l-1];this.repository.addOrUpdateMessage(f?.id??null,u)}}else throw new Error("ExternalStoreAdapter must provide either 'messages' or 'messageRepository'");o.length>0&&this.ensureInitialized(),(r?.isRunning??!1)!==(t.isRunning??!1)&&(t.isRunning?this._notifyEventSubscribers("runStart",{}):this._notifyEventSubscribers("runEnd",{}));let a=null;r1(n,o)&&(a=Un(),this.repository.addOrUpdateMessage(o.at(-1)?.id??null,wi({role:"assistant",content:[],metadata:{isOptimistic:!0}},a,{type:"running"}))),this.repository.resetHead(a??o.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||(this._toolInvocations=new t1(()=>this.getModelContext().tools,{onResult:t=>{try{const n=this._findMessageIdForToolCall(t.toolCallId);if(n===void 0)return;this._store.onAddToolResult?.({messageId:n,toolCallId:t.toolCallId,toolName:t.toolName,result:t.result,isError:t.isError,...t.artifact!==void 0&&{artifact:t.artifact},...t.modelContent!==void 0&&{modelContent:t.modelContent}})}catch(n){console.error("[ExternalStoreThreadRuntimeCore] onAddToolResult dispatch failed",n)}},onStatusesChange:t=>{this._store.setToolStatuses?.(Object.fromEntries(t))}})),this._toolInvocations.setState({messages:this._messages,isRunning:this._store.isRunning??!1,...this._store.isLoading!==void 0&&{isLoading:this._store.isLoading}})}_findMessageIdForToolCall(t){if(this._messagesForToolCallIndex!==this._messages){this._toolCallToMessageId.clear();const n=r=>{for(const s of r)if(Array.isArray(s.content))for(const i of s.content)!i||i.type!=="tool-call"||(this._toolCallToMessageId.set(i.toolCallId,s.id),i.messages&&n(i.messages))};n(this._messages),this._messagesForToolCallIndex=this._messages}return this._toolCallToMessageId.get(t)}switchToBranch(t){if(!this._store.setMessages)throw new Error("Runtime does not support switching branches.");this._store.isRunning||(this.repository.switchToBranch(t),this.updateMessages(this.repository.getMessages()))}async append(t){if((t.startRun??t.role==="user")&&await this._toolInvocations?.abort(),t.parentId!==(this.messages.at(-1)?.id??null)){if(!this._store.onEdit)throw new Error("Runtime does not support editing messages.");await this._store.onEdit(t)}else await this._store.onNew(t)}async startRun(t){if(!this._store.onReload)throw new Error("Runtime does not support reloading messages.");await this._toolInvocations?.abort(),await this._store.onReload(t.parentId,t)}async resumeRun(t){if(!this._store.onResume)throw new Error("Runtime does not support resuming runs.");await this._store.onResume(t)}exportExternalState(){if(!this._store.onExportExternalState)throw new Error("Runtime does not support exporting external states.");return this._store.onExportExternalState()}importExternalState(t){if(!this._store.onLoadExternalState)throw new Error("Runtime does not support importing external states.");this._toolInvocations&&(this._toolInvocations.reset(),this._store.setToolStatuses?.({})),this._store.onLoadExternalState(t)}cancelRun(){if(!this._store.onCancel)throw new Error("Runtime does not support cancelling runs.");this._toolInvocations?.abort(),this._store.onCancel();const t=this.repository.getMessages().at(-1);t&&t.metadata.isOptimistic&&t.content.length===0&&this.repository.deleteMessage(t.id);let n=this.repository.getMessages();const r=n[n.length-1];r?.role==="user"&&r.id===n.at(-1)?.id?(this.repository.deleteMessage(r.id),this.composer.text.trim()||this.composer.setText(xi(r)),n=this.repository.getMessages()):this._notifySubscribers(),setTimeout(()=>{this.updateMessages(n)},0)}addToolResult(t){if(!this._store.onAddToolResult)throw new Error("Runtime does not support tool results.");this._store.onAddToolResult?.(t)}resumeToolCall(t){if(!(this._toolInvocations?.resume(t.toolCallId,t.payload)??!1)){if(this._store.onResumeToolCall){this._store.onResumeToolCall(t);return}throw new Error(`Tool call ${t.toolCallId} is not waiting for resume.`)}}respondToToolApproval(t){if(!this._store.onRespondToToolApproval)throw new Error("Runtime does not support tool approvals.");this._store.onRespondToToolApproval(t)}reset(t){const n=new md;n.import(Rv.fromArray(t??[])),this.updateMessages(n.getMessages())}import(t){super.import(t),this._store.onImport&&this._store.onImport(this.repository.getMessages())}};const Nh=e=>e.adapters?.threadList??{};var i1=class extends Iv{constructor(t){super();T(this,"threads");this.threads=new $0(Nh(t),()=>new s1(this._contextProvider,t))}setAdapter(t){this.threads.__internal_setAdapter(Nh(t)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(t)}};const Oa=e=>{const[t]=m.useState(()=>new i1(e));m.useEffect(()=>{t.setAdapter(e)});const{modelContext:n}=L0()??{};return m.useEffect(()=>{if(n)return t.registerModelContextProvider(n)},[n,t]),m.useMemo(()=>new Tv(t),[t])},jv=(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,o1=()=>null,a1=(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??o1;default:throw new Error(`Unknown message role: ${t}`)}},Nv=({components:e})=>c.jsx(a1(e,U(t=>t.message.role),U(t=>t.message.composer.isEditing)),{}),Mv=m.memo(({index:e,components:t})=>c.jsx(vv,{index:e,children:c.jsx(Nv,{components:t})}),(e,t)=>e.index===t.index&&jv(e.components,t.components));Mv.displayName="ThreadPrimitive.MessageByIndex";const Mh=({children:e})=>{const t=U(n=>n.thread.messages.length);return m.useMemo(()=>t===0?null:Array.from({length:t},(n,r)=>c.jsx(vv,{index:r,children:c.jsx(cs,{getItemState:s=>s.thread().message({index:r}).getState(),children:s=>e({get message(){return s()}})})},r)),[t,e])},Lv=({components:e,children:t})=>e?c.jsx(Mh,{children:()=>c.jsx(Nv,{components:e})}):c.jsx(Mh,{children:t});Lv.displayName="ThreadPrimitive.Messages";const l1=m.memo(Lv,(e,t)=>e.children||t.children?e.children===t.children:jv(e.components,t.components)),Dv=e=>{const t=e.message.metadata;if(!(!t||typeof t!="object"))return t.custom?.quote};var u1=class extends Error{constructor(t,n=`Component "${t}" is not in the generative-ui allowlist.`){super(n);T(this,"componentName");this.name="GenerativeUIRenderError",this.componentName=t}};const c1=e=>typeof e=="object"&&e!==null,Ov=(e,t,n,r)=>{if(e==null)return null;if(typeof e=="string")return e;if(!c1(e)||!("component"in e))return null;const{component:s,props:i,children:o,key:a}=e,l=t[s];if(!l){if(n)return c.jsx(n,{component:s,props:i},a??r);throw new u1(s)}const u=o?.length?o.map((f,d)=>Ov(f,t,n,`${r}/${d}`)):void 0;return m.createElement(l,{...i??{},key:a??r},...u??[])},d1=e=>{if(!e||e.root===void 0||e.root===null)return[];const t=e.root;return Array.isArray(t)?t:[t]},gd=({spec:e,components:t,Fallback:n})=>c.jsx(c.Fragment,{children:m.useMemo(()=>d1(e),[e]).map((r,s)=>Ov(r,t,n,`${s}`))});gd.displayName="GenerativeUIRender";const zv=({components:e,spec:t,Fallback:n})=>{const r=U(i=>{const o=i.part;return o?.type==="generative-ui"?o.spec:void 0}),s=t??r;return s?c.jsx(gd,{spec:s,components:e,Fallback:n}):null};zv.displayName="MessagePrimitive.GenerativeUI";const f1="ui://",h1=e=>!!e?.startsWith(f1),Lh=e=>Symbol.iterator in e,Dh=e=>"entries"in e,Oh=(e,t)=>{const 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(const[s,i]of n)if(!r.has(s)||!Object.is(i,r.get(s)))return!1;return!0},p1=(e,t)=>{const n=e[Symbol.iterator](),r=t[Symbol.iterator]();let s=n.next(),i=r.next();for(;!s.done&&!i.done;){if(!Object.is(s.value,i.value))return!1;s=n.next(),i=r.next()}return!!s.done&&!!i.done};function m1(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:Lh(e)&&Lh(t)?Dh(e)&&Dh(t)?Oh(e,t):p1(e,t):Oh({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function Fv(e){const t=lt.useRef(void 0);return n=>{const r=e(n);return m1(t.current,r)?t.current:t.current=r}}const Tl=e=>{let t=-1;return{startGroup:n=>{t===-1&&(t=n)},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})}}},g1=(e,t)=>{const n=[];if(t){const r=Tl("chainOfThoughtGroup");for(let s=0;s<e.length;s++){const i=e[s];i==="tool-call"||i==="reasoning"?r.startGroup(s):(r.endGroup(s-1,n),n.push({type:"single",index:s}))}r.finalize(e.length-1,n)}else{const r=Tl("toolGroup"),s=Tl("reasoningGroup");for(let i=0;i<e.length;i++){const o=e[i];o==="tool-call"?(s.endGroup(i-1,n),r.startGroup(i)):o==="reasoning"?(r.endGroup(i-1,n),s.startGroup(i)):(r.endGroup(i-1,n),s.endGroup(i-1,n),n.push({type:"single",index:i}))}r.finalize(e.length-1,n),s.finalize(e.length-1,n)}return n},y1=e=>{const t=U(Fv(n=>n.message.parts.map(r=>r.type)));return m.useMemo(()=>t.length===0?[]:g1(t,e),[t,e])},v1=({Fallback:e,...t})=>{const n=U(r=>r.tools.toolUIs[t.toolName]?.[0]?.render??e);return n?c.jsx(n,{...t}):null},yd=(e,t,n)=>{const r=e.renderers[t]?.[0];return r||(e.fallbacks[0]??n)},x1=({Fallback:e,...t})=>{const n=U(r=>yd(r.dataRenderers,t.name,e));return n?c.jsx(n,{...t}):null},qe={Text:()=>null,Reasoning:()=>null,Source:()=>null,Image:()=>null,File:()=>null,Unstable_Audio:()=>null,ToolGroup:({children:e})=>e,ReasoningGroup:({children:e})=>e},w1=({components:{Text:e=qe.Text,Reasoning:t=qe.Reasoning,Image:n=qe.Image,Source:r=qe.Source,File:s=qe.File,Unstable_Audio:i=qe.Unstable_Audio,tools:o={},data:a,generativeUI:l}={}})=>{const u=Z(),f=U(h=>h.part),d=f.type;if(d==="tool-call"){const h=u.part().addToolResult,p=u.part().resumeToolCall,g=u.part().respondToToolApproval;if("Override"in o)return c.jsx(o.Override,{...f,addResult:h,resume:p,respondToApproval:g});const x=o.by_name?.[f.toolName]??o.Fallback;return c.jsx(v1,{...f,Fallback:x,addResult:h,resume:p,respondToApproval:g})}if(f.status?.type==="requires-action")throw new Error("Encountered unexpected requires-action status");switch(d){case"text":return c.jsx(e,{...f});case"reasoning":return c.jsx(t,{...f});case"source":return c.jsx(r,{...f});case"image":return c.jsx(n,{...f});case"file":return c.jsx(s,{...f});case"audio":return c.jsx(i,{...f});case"data":{const h=a?.by_name?.[f.name]??a?.Fallback;return c.jsx(x1,{...f,Fallback:h})}case"generative-ui":return l?.components?c.jsx(gd,{spec:f.spec,components:l.components,Fallback:l.Fallback}):null;default:return console.warn(`Unknown message part type: ${d}`),null}},Gs=m.memo(({index:e,components:t})=>c.jsx(fd,{index:e,children:c.jsx(w1,{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);Gs.displayName="MessagePrimitive.PartByIndex";const S1=({status:e,component:t})=>c.jsx(hd,{text:"",isRunning:e.type==="running",children:c.jsx(t,{type:"text",text:"",status:e})}),b1=Object.freeze({type:"complete"}),k1=Object.freeze({type:"running"}),C1=({components:e})=>{const t=U(n=>n.message.status??b1);return e?.Empty?c.jsx(e.Empty,{status:t}):t.type!=="running"?null:c.jsx(S1,{status:t,component:e?.Text??qe.Text})},Bv=m.memo(C1,(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),_1=({components:e,enabled:t})=>U(n=>{if(!t||n.message.parts.length===0)return!1;const r=n.message.parts[n.message.parts.length-1];return r?.type!=="text"&&r?.type!=="reasoning"})?c.jsx(Bv,{components:e}):null,E1=m.memo(_1,(e,t)=>e.enabled===t.enabled&&e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),T1=({Quote:e})=>{const t=U(Dv);return t?c.jsx(e,{text:t.text,messageId:t.messageId}):null},I1=m.memo(T1);function $v(e,t){const n=e.toolUIs[t.toolName]?.[0]?.render??null;return n||(h1(t.mcp?.app?.resourceUri)&&e.mcpApp?e.mcpApp.render:null)}const Uv=()=>{const e=Z(),t=U(r=>r.part),n=U(r=>r.part.type==="tool-call"?$v(r.tools,r.part):null);return!n||t.type!=="tool-call"?null:c.jsx(n,{...t,addResult:e.part().addToolResult,resume:e.part().resumeToolCall,respondToApproval:e.part().respondToToolApproval})},Vv=()=>{const e=U(n=>n.part),t=U(n=>n.part.type==="data"?yd(n.dataRenderers,n.part.name,void 0)??null:null);return!t||e.type!=="data"?null:c.jsx(t,{...e})},R1=()=>{const e=U(t=>t.part.type);return e==="tool-call"?c.jsx(Uv,{}):e==="data"?c.jsx(Vv,{}):null},P1=Object.freeze({type:"text",text:"",status:k1}),Hv=({index:e,children:t})=>{const n=Z(),r=U(s=>s.dataRenderers);return c.jsx(fd,{index:e,children:c.jsx(cs,{getItemState:s=>s.message().part({index:e}).getState(),children:s=>t({get part(){const i=s();if(i.type==="tool-call"){const o=$v(n.tools().getState(),i)!==null,a=n.message().part({index:e});return{...i,toolUI:o?c.jsx(Uv,{}):null,addResult:a.addToolResult,resume:a.resumeToolCall,respondToApproval:a.respondToToolApproval}}if(i.type==="data"){const o=yd(r,i.name,void 0)!==void 0;return{...i,dataRendererUI:o?c.jsx(Vv,{}):null}}return i}})})})},A1=({children:e})=>{const t=U(s=>s.message.parts.length),n=U(s=>(s.message.status?.type??"complete")==="running"),r=t===0&&n;return t===0?r?c.jsx(hd,{text:"",isRunning:!0,children:e({part:P1})}):null:c.jsx(c.Fragment,{children:Array.from({length:t},(s,i)=>c.jsx(Hv,{index:i,children:o=>e(o)??c.jsx(R1,{})},i))})},Gu=({components:e,unstable_showEmptyOnNonTextEnd:t=!0,children:n})=>n?c.jsx(A1,{children:n}):c.jsx(j1,{components:e,unstable_showEmptyOnNonTextEnd:t});Gu.displayName="MessagePrimitive.Parts";const j1=({components:e,unstable_showEmptyOnNonTextEnd:t})=>{const n=U(i=>i.message.parts.length),r=y1(!!e?.ChainOfThought),s=m.useMemo(()=>n===0?c.jsx(Bv,{components:e}):r.map(i=>{if(i.type==="single")return c.jsx(Gs,{index:i.index,components:e},i.index);if(i.type==="chainOfThoughtGroup"){const o=e?.ChainOfThought;return o?c.jsx(p0,{startIndex:i.startIndex,endIndex:i.endIndex,children:c.jsx(o,{})},`chainOfThought-${i.startIndex}`):null}else return i.type==="toolGroup"?c.jsx(e?.ToolGroup??qe.ToolGroup,{startIndex:i.startIndex,endIndex:i.endIndex,children:Array.from({length:i.endIndex-i.startIndex+1},(o,a)=>{const l=i.startIndex+a;return c.jsx(Gs,{index:l,components:e},`part-${l}`)})},`tool-${i.startIndex}`):c.jsx(e?.ReasoningGroup??qe.ReasoningGroup,{startIndex:i.startIndex,endIndex:i.endIndex,children:Array.from({length:i.endIndex-i.startIndex+1},(o,a)=>{const l=i.startIndex+a;return c.jsx(Gs,{index:l,components:e},`part-${l}`)})},`reasoning-${i.startIndex}`)}),[r,e,n]);return c.jsxs(c.Fragment,{children:[e?.Quote&&c.jsx(I1,{Quote:e.Quote}),s,c.jsx(E1,{components:e,enabled:t})]})},N1=Symbol.for("@assistant-ui/groupBy.memoKey"),zh=e=>{const t=e.nextChildIdx++;return e.nodeKey===""?String(t):`${e.nodeKey}.${t}`},M1=e=>{const t={key:"",nodeKey:"",indices:[],children:[],nextChildIdx:0},n=[t],r=()=>{const s=n.pop();n[n.length-1].children.push({type:"group",key:s.key,nodeKey:s.nodeKey,indices:s.indices,children:s.children})};for(let s=0;s<e.length;s++){const i=e[s];let o=0;for(;o<n.length-1&&o<i.length&&n[o+1].key===i[o];)o++;for(;n.length-1>o;)r();for(;n.length-1<i.length;){const l=n[n.length-1];n.push({key:i[n.length-1],nodeKey:zh(l),indices:[],children:[],nextChildIdx:0})}const a=n[n.length-1];a.children.push({type:"part",index:s,nodeKey:zh(a)});for(let l=1;l<n.length;l++)n[l].indices.push(s)}for(;n.length>1;)r();return t.children},L1=Object.freeze({type:"complete"}),D1=(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":{const r=t[t.length-1];return r!==void 0&&r.type!=="text"&&r.type!=="reasoning"}}},Wv=()=>{throw new 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.")},qv=(e,t,n)=>{if(e.type==="part")return c.jsx(Hv,{index:e.index,children:({part:s})=>n({part:s,children:c.jsx(Wv,{})})},`part-${e.index}`);const r=t[e.indices.at(-1)]?.status??L1;return c.jsx(m.Fragment,{children:n({part:{type:e.key,status:r,indices:e.indices},children:c.jsx(c.Fragment,{children:e.children.map(s=>qv(s,t,n))})})},e.nodeKey)},Kv=({groupBy:e,indicator:t="no-text",children:n})=>{const r=U(Fv(o=>o.message.parts)),s=U(o=>o.tools.toolUIs),i=U(o=>t==="never"?!1:o.message.status?.type==="running");return c.jsxs(c.Fragment,{children:[m.useMemo(()=>{const o={toolUIs:s};return M1(r.map(a=>e(a,o)??[]))},[r,e[N1]??e,s]).map(o=>qv(o,r,n)),D1(t,r,i)&&n({part:{type:"indicator"},children:c.jsx(Wv,{})})]})};Kv.displayName="MessagePrimitive.GroupedParts";const O1=({children:e})=>{const t=U(Dv);return t?c.jsx(c.Fragment,{children:e(t)}):null},Gv=m.memo(O1);Gv.displayName="MessagePrimitive.Quote";const Qv=(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}},z1=({components:e})=>{const t=U(r=>r.attachment);if(!t)return null;const n=Qv(e,t);return n?c.jsx(n,{}):null},Yv=m.memo(({index:e,components:t})=>c.jsx(gv,{index:e,children:c.jsx(z1,{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);Yv.displayName="MessagePrimitive.AttachmentByIndex";const Fh=({children:e})=>{const t=U(n=>n.message.role!=="user"?0:(n.message.attachments??[]).length);return m.useMemo(()=>Array.from({length:t},(n,r)=>c.jsx(gv,{index:r,children:c.jsx(cs,{getItemState:s=>s.message().attachment({index:r}).getState(),children:s=>e({get attachment(){return s()}})})},r)),[t,e])},Jv=({components:e,children:t})=>e?c.jsx(Fh,{children:({attachment:n})=>{const r=Qv(e,n);return r?c.jsx(r,{}):null}}):c.jsx(Fh,{children:t});Jv.displayName="MessagePrimitive.Attachments";const Xv=(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}},F1=({components:e})=>{const t=U(r=>r.attachment);if(!t)return null;const n=Xv(e,t);return n?c.jsx(n,{}):null},Zv=m.memo(({index:e,components:t})=>c.jsx(yv,{index:e,children:c.jsx(F1,{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);Zv.displayName="ComposerPrimitive.AttachmentByIndex";const Bh=({children:e})=>{const t=U(n=>n.composer.attachments.length);return m.useMemo(()=>Array.from({length:t},(n,r)=>c.jsx(yv,{index:r,children:c.jsx(cs,{getItemState:s=>s.composer().attachment({index:r}).getState(),children:s=>e({get attachment(){return s()}})})},r)),[t,e])},ex=({components:e,children:t})=>e?c.jsx(Bh,{children:({attachment:n})=>{const r=Xv(e,n);return r?c.jsx(r,{}):null}}):c.jsx(Bh,{children:t});ex.displayName="ComposerPrimitive.Attachments";const B1=({children:e})=>{const t=U(n=>n.composer.queue.length);return m.useMemo(()=>Array.from({length:t},(n,r)=>c.jsx(m0,{index:r,children:c.jsx(cs,{getItemState:s=>s.composer().queueItem({index:r}).getState(),children:s=>e({get queueItem(){return s()}})})},r)),[t,e])},tx=m.memo(B1);tx.displayName="ComposerPrimitive.Queue";const vd=({children:e})=>U(t=>t.part.status.type==="running")?e:null;vd.displayName="MessagePartPrimitive.InProgress";const nx=({components:e})=>{const t=e.Suggestion;return c.jsx(t,{})},rx=m.memo(({index:e,components:t})=>c.jsx(xv,{index:e,children:c.jsx(nx,{components:t})}),(e,t)=>e.index===t.index&&e.components.Suggestion===t.components.Suggestion);rx.displayName="ThreadPrimitive.SuggestionByIndex";const $h=({children:e})=>{const t=U(n=>n.suggestions.suggestions.length);return m.useMemo(()=>t===0?null:Array.from({length:t},(n,r)=>c.jsx(xv,{index:r,children:c.jsx(cs,{getItemState:s=>s.suggestions().suggestion({index:r}).getState(),children:s=>e({get suggestion(){return s()}})})},r)),[t,e])},sx=({components:e,children:t})=>e?c.jsx($h,{children:()=>c.jsx(nx,{components:e})}):c.jsx($h,{children:t});sx.displayName="ThreadPrimitive.Suggestions";const $1=m.memo(sx,(e,t)=>e.children||t.children?e.children===t.children:e.components.Suggestion===t.components.Suggestion),U1=e=>U(t=>{if(e.editing===!0&&!t.composer.isEditing||e.editing===!1&&t.composer.isEditing)return!1;const n=t.composer.dictation!=null;return!(e.dictation===!0&&!n||e.dictation===!1&&n)}),ix=({children:e,...t})=>U1(t)?e:null;ix.displayName="ComposerPrimitive.If";const V1=()=>{const e=Z(),t=U(n=>!n.composer.canSend||n.thread.isRunning&&!n.thread.capabilities.queue);return{send:m.useCallback(n=>{e.composer().send(n)},[e]),disabled:t}},H1=()=>{const e=Z(),t=U(n=>!n.composer.canCancel);return{cancel:m.useCallback(()=>{e.composer().cancel()},[e]),disabled:t}},W1=()=>{const e=Z(),t=U(n=>n.composer.dictation!=null||!n.thread.capabilities.dictation||!n.composer.isEditing);return{startDictation:m.useCallback(()=>{e.composer().startDictation()},[e]),disabled:t}},q1=()=>{const e=Z(),t=U(n=>!n.composer.isEditing);return{addAttachment:m.useCallback(n=>e.composer().addAttachment(n),[e]),disabled:t}},K1=({copiedDuration:e=3e3,copyToClipboard:t}={})=>{const n=Z(),r=U(a=>!((a.message.role!=="assistant"||a.message.status?.type!=="running")&&a.message.parts.some(l=>l.type==="text"&&l.text.length>0))),s=U(a=>a.message.isCopied),i=U(a=>a.composer.isEditing),o=U(a=>a.composer.text);return{copy:m.useCallback(()=>{const a=i?o:n.message().getCopyText();if(!a)return;const l=t??(()=>{});Promise.resolve(l(a)).then(()=>{n.message().setIsCopied(!0),setTimeout(()=>n.message().setIsCopied(!1),e)},()=>{})},[n,i,o,e,t]),disabled:r,isCopied:s}},G1=()=>{const e=Z(),t=U(n=>n.composer.isEditing);return{edit:m.useCallback(()=>{e.composer().beginEdit()},[e]),disabled:t}},Q1=()=>{const e=Z(),t=U(n=>n.thread.isRunning||n.thread.isDisabled||n.message.role!=="assistant");return{reload:m.useCallback(()=>{e.message().reload()},[e]),disabled:t}},Y1=()=>{const e=Z(),t=U(n=>n.message.metadata.submittedFeedback?.type==="positive");return{submit:m.useCallback(()=>{e.message().submitFeedback({type:"positive"})},[e]),isSubmitted:t}},J1=()=>{const e=Z(),t=U(n=>n.message.metadata.submittedFeedback?.type==="negative");return{submit:m.useCallback(()=>{e.message().submitFeedback({type:"negative"})},[e]),isSubmitted:t}},X1=()=>{const e=Z(),t=U(n=>!((n.message.role!=="assistant"||n.message.status?.type!=="running")&&n.message.parts.some(r=>r.type==="text"&&r.text.length>0)));return{speak:m.useCallback(async()=>{e.message().speak()},[e]),disabled:t}},Z1=()=>{const e=Z(),t=U(n=>n.message.speech==null);return{stopSpeaking:m.useCallback(()=>{e.message().stopSpeaking()},[e]),disabled:t}},eE=({prompt:e,send:t,clearComposer:n=!0})=>{const r=Z(),s=U(o=>o.thread.isDisabled),i=t??!1;return{trigger:m.useCallback(()=>{const o=r.thread().getState().isRunning;if(i&&!o)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{const a=r.composer().getState().text;r.composer().setText(a.trim()?`${a} ${e}`:e)}},[r,i,n,e]),disabled:s}},tE=()=>U(e=>e.message.status?.type==="incomplete"&&e.message.status.reason==="error"?e.message.status.error??"An error occurred":void 0),nE=e=>{const{cloud:t,initialMessages:n,maxSteps:r,adapters:s,unstable_humanToolNames:i,...o}=e;return{localRuntimeOptions:{cloud:t,initialMessages:n,maxSteps:r,adapters:s,unstable_humanToolNames:i},otherOptions:o}},rE=/:([\w-]{1,64})\[([^\]\n]{1,1024})\](?:\{name=([^}\n]{1,1024})\})?/gu,ox={serialize(e){const t=e.id!==e.label?`{name=${e.id}}`:"";return`:${e.type}[${e.label}]${t}`},parse(e){const t=[];let n=0;for(const r of e.matchAll(rE)){r.index>n&&t.push({kind:"text",text:e.slice(n,r.index)});const s=r[2];t.push({kind:"mention",type:r[1],label:s,id:r[3]??s}),n=r.index+r[0].length}return n<e.length&&t.push({kind:"text",text:e.slice(n)}),t}};function sE(e,t){function n(r){const s=m.useContext(e);if(!r?.optional&&!s)throw new Error(`This component must be used within ${t}.`);return s}return n}function ax(e,t){function n(s){const i=e(s);return i?i[t]:null}function r(s){let i=!1,o;typeof s=="function"?o=s:s&&typeof s=="object"&&(i=!!s.optional,o=s.selector);const a=n({optional:i});return a?o?a(o):a():null}return{[t]:r,[`${t}Store`]:n}}const lx=m.createContext(null),{useThreadViewport:vr,useThreadViewportStore:xr}=ax(sE(lx,"ThreadPrimitive.Viewport"),"useThreadViewport"),Uh=e=>{const t=new Map,n=()=>{let r=0;for(const s of t.values())r+=s;e(r)};return{register:()=>{const r=Symbol();return t.set(r,0),{setHeight:s=>{t.get(r)!==s&&(t.set(r,s),n())},unregister:()=>{t.delete(r),n()}}}}},iE=(e={})=>{const t=new Set,n=Uh(o=>{i.setState({height:{...i.getState().height,viewport:o}})}),r=Uh(o=>{i.setState({height:{...i.getState().height,inset:o}})}),s=(o,a)=>(i.setState({element:{...i.getState().element,[o]:a}}),()=>{i.getState().element[o]===a&&i.setState({element:{...i.getState().element,[o]:null}})}),i=av(()=>({isAtBottom:!0,scrollToBottom:({behavior:o="auto"}={})=>{for(const a of t)a({behavior:o})},onScrollToBottom:o=>(t.add(o),()=>{t.delete(o)}),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:o=>s("viewport",o),registerAnchorElement:o=>s("anchor",o),registerAnchorTargetElement:(o,a)=>(i.setState({element:{...i.getState().element,target:o},targetConfig:o&&a?a:null}),()=>{i.getState().element.target===o&&i.setState({element:{...i.getState().element,target:null},targetConfig:null})}),setTopAnchorTurn:o=>{i.setState({topAnchorTurn:o})}}));return i},ra=e=>e,oE=e=>{const t=xr({optional:!0}),[n]=m.useState(()=>iE(e));return m.useEffect(()=>t?.getState().onScrollToBottom(()=>{n.getState().scrollToBottom()}),[t,n]),m.useEffect(()=>{if(t)return n.subscribe(r=>{t.getState().isAtBottom!==r.isAtBottom&&ra(t).setState({isAtBottom:r.isAtBottom})})},[n,t]),n},xd=({children:e,options:t={}})=>{const n=oE(t),[r]=m.useState(()=>({useThreadViewport:n}));return c.jsx(lx.Provider,{value:r,children:e})},aE=()=>{const e=Z();return m.useEffect(()=>{},[e]),null},lE=({children:e,aui:t,runtime:n})=>c.jsxs(j_,{runtime:n,aui:t??null,children:[c.jsx(aE,{}),c.jsx(xd,{children:e})]}),za=m.memo(lE),uE=e=>{const t=e;t.__isBound||(t.__internal_bindMethods?.(),t.__isBound=!0)};function cE(e,t=dE){uE(e);const n=m.useSyncExternalStore(e.subscribe,()=>t(e.getState()),()=>t(e.getState()));return m.useDebugValue(n),n}const dE=e=>e;function fE(e){function t(n){let r=!1,s;typeof n=="function"?s=n:n&&(r=!!n.optional,s=n.selector);const i=e({optional:r});return i?cE(i,s):null}return t}function hE(e){const t=Z(),n=U(()=>t.composer.source?t.composer().__internal_getRuntime?.()??null:null);if(!n&&!e?.optional)throw new Error("ComposerRuntime is not available");return n}function pE(e){const t=Z(),n=U(()=>t.message.source?t.message().__internal_getRuntime?.()??null:null);if(!n&&!e?.optional)throw new Error("MessageRuntime is not available");return n}const sa=fE(pE);function Vh(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function mE(...e){return t=>{let n=!1;const r=e.map(s=>{const i=Vh(s,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let s=0;s<r.length;s++){const i=r[s];typeof i=="function"?i():Vh(e[s],null)}}}}function wr(...e){return m.useCallback(mE(...e),e)}var Hh=Object.defineProperty,hs=(e,t)=>{let n={};for(var r in e)Hh(n,r,{get:e[r],enumerable:!0});return Hh(n,Symbol.toStringTag,{value:"Module"}),n};function ux(e){const t=m.forwardRef((n,r)=>{let{children:s,...i}=n,o=null,a=!1;const l=[];Wh(s)&&typeof no=="function"&&(s=no(s._payload)),m.Children.forEach(s,h=>{if(wE(h)){a=!0;const p=h;let g="child"in p.props?p.props.child:p.props.children;Wh(g)&&typeof no=="function"&&(g=no(g._payload)),o=yE(p,g),l.push(o?.props?.children)}else l.push(h)}),o?o=m.cloneElement(o,void 0,l):!a&&m.Children.count(s)===1&&m.isValidElement(s)&&(o=s);const u=o?xE(o):void 0,f=wr(r,u);if(!o){if(s||s===0)throw new Error(a?CE(e):kE(e));return s}const d=vE(i,o.props??{});return o.type!==m.Fragment&&(d.ref=r?f:u),m.cloneElement(o,d)});return t.displayName=`${e}.Slot`,t}var ia=ux("Slot"),gE=Symbol.for("radix.slottable"),yE=(e,t)=>{if("child"in e.props){const n=e.props.child;return m.isValidElement(n)?m.cloneElement(n,void 0,e.props.children(n.props.children)):null}return m.isValidElement(t)?t:null};function vE(e,t){const n={...t};for(const r in t){const s=e[r],i=t[r];/^on[A-Z]/.test(r)?s&&i?n[r]=(...a)=>{const l=i(...a);return s(...a),l}:s&&(n[r]=s):r==="style"?n[r]={...s,...i}:r==="className"&&(n[r]=[s,i].filter(Boolean).join(" "))}return{...e,...n}}function xE(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)}function wE(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===gE}var SE=Symbol.for("react.lazy");function Wh(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===SE&&"_payload"in e&&bE(e._payload)}function bE(e){return typeof e=="object"&&e!==null&&"then"in e}var kE=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,CE=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,no=nb[" use ".trim().toString()],_E=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],EE=_E.reduce((e,t)=>{const n=ux(`Primitive.${t}`),r=m.forwardRef((s,i)=>{const{asChild:o,...a}=s,l=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(l,{...a,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});const TE=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"];function IE(e){const t=m.forwardRef(({render:n,asChild:r,children:s,...i},o)=>{const a=e;if(n&&m.isValidElement(n)){const l=s!==void 0?s:n.props.children;return c.jsx(a,{...i,asChild:!0,ref:o,children:m.cloneElement(n,void 0,l)})}return c.jsx(a,{...i,asChild:r,ref:o,children:s})});return t.displayName=typeof e=="string"?e:e.displayName??e.name??"Component",t}function RE(e){const t=EE[e],n=IE(t);return n.displayName=`Primitive.${e}`,n}const me=TE.reduce((e,t)=>(e[t]=RE(t),e),{}),PE=({hideWhenRunning:e,autohide:t,autohideFloat:n,forceVisible:r})=>U(s=>{if(e&&s.thread.isRunning)return"hidden";const i=t==="always"||t==="not-last"&&!s.message.isLast,o=r||s.message.isHovering;return i?o?n==="always"||n==="single-branch"&&s.message.branchCount<=1?"floating":"normal":"hidden":"normal"}),AE=m.createContext(null),cx=m.forwardRef(({hideWhenRunning:e,autohide:t,autohideFloat:n,...r},s)=>{const[i,o]=m.useState(0),a=m.useCallback(()=>{let f=!1;return o(d=>d+1),()=>{f||(f=!0,o(d=>Math.max(0,d-1)))}},[]),l=m.useMemo(()=>({acquireInteractionLock:a}),[a]),u=PE({hideWhenRunning:e,autohide:t,autohideFloat:n,forceVisible:i>0});return u==="hidden"?null:c.jsx(AE.Provider,{value:l,children:c.jsx(me.div,{...u==="floating"?{"data-floating":"true"}:null,...r,ref:s})})});cx.displayName="ActionBarPrimitive.Root";function Se(e,t,{checkForDefaultPrevented:n=!0}={}){return function(s){if(e?.(s),n===!1||!s.defaultPrevented)return t?.(s)}}const jE=({copiedDuration:e=3e3}={})=>{const{copy:t,disabled:n}=K1({copiedDuration:e,copyToClipboard:r=>typeof navigator>"u"||!navigator.clipboard?Promise.reject(new Error("Clipboard API is unavailable")):navigator.clipboard.writeText(r)});return n?null:t},dx=m.forwardRef(({copiedDuration:e,onClick:t,disabled:n,...r},s)=>{const i=U(a=>a.message.isCopied),o=jE({copiedDuration:e});return c.jsx(me.button,{type:"button",...i?{"data-copied":"true"}:{},...r,ref:s,disabled:n||!o,onClick:Se(t,()=>{o?.()})})});dx.displayName="ActionBarPrimitive.Copy";const Ht=(e,t,n=[])=>{const r=m.forwardRef((s,i)=>{const o={},a={};Object.keys(s).forEach(u=>{n.includes(u)?o[u]=s[u]:a[u]=s[u]});const l=t(o)??void 0;return c.jsx(me.button,{...a,type:"button",ref:i,disabled:a.disabled||!l,onClick:Se(a.onClick,l)})});return r.displayName=e,r},NE=()=>{const{disabled:e,reload:t}=Q1();return e?null:t},ME=Ht("ActionBarPrimitive.Reload",NE),LE=()=>{const{disabled:e,edit:t}=G1();return e?null:t},DE=Ht("ActionBarPrimitive.Edit",LE),OE=()=>{const{disabled:e,speak:t}=X1();return e?null:t},zE=Ht("ActionBarPrimitive.Speak",OE);function hr(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>t.current?.(...n),[])}function fx(e,t=globalThis?.document){const n=hr(e);m.useEffect(()=>{const r=s=>{s.key==="Escape"&&n(s)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}const FE=()=>{const{disabled:e,stopSpeaking:t}=Z1();return e?null:t},hx=m.forwardRef((e,t)=>{const n=FE();return fx(r=>{n&&(r.preventDefault(),n())}),c.jsx(me.button,{type:"button",disabled:!n,...e,ref:t,onClick:Se(e.onClick,()=>{n?.()})})});hx.displayName="ActionBarPrimitive.StopSpeaking";const BE=()=>{const{submit:e}=Y1();return e},px=m.forwardRef(({onClick:e,disabled:t,...n},r)=>{const s=U(o=>o.message.metadata.submittedFeedback?.type==="positive"),i=BE();return c.jsx(me.button,{type:"button",...s?{"data-submitted":"true"}:{},...n,ref:r,disabled:t||!i,onClick:Se(e,()=>{i?.()})})});px.displayName="ActionBarPrimitive.FeedbackPositive";const $E=()=>{const{submit:e}=J1();return e},mx=m.forwardRef(({onClick:e,disabled:t,...n},r)=>{const s=U(o=>o.message.metadata.submittedFeedback?.type==="negative"),i=$E();return c.jsx(me.button,{type:"button",...s?{"data-submitted":"true"}:{},...n,ref:r,disabled:t||!i,onClick:Se(e,()=>{i?.()})})});mx.displayName="ActionBarPrimitive.FeedbackNegative";const UE=({filename:e,onExport:t}={})=>{const n=Z(),r=U(i=>(i.message.role!=="assistant"||i.message.status?.type!=="running")&&i.message.parts.some(o=>o.type==="text"&&o.text.length>0)),s=m.useCallback(async()=>{const i=n.message().getCopyText();if(!i)return;if(t){await t(i);return}const o=new Blob([i],{type:"text/markdown"}),a=URL.createObjectURL(o),l=document.createElement("a");l.href=a,l.download=e??`message-${Date.now()}.md`,l.click(),URL.revokeObjectURL(a)},[n,e,t]);return r?s:null},gx=m.forwardRef(({filename:e,onExport:t,onClick:n,disabled:r,...s},i)=>{const o=UE({filename:e,onExport:t});return c.jsx(me.button,{type:"button",...s,ref:i,disabled:r||!o,onClick:Se(n,()=>{o?.()})})});gx.displayName="ActionBarPrimitive.ExportMarkdown";var qh=hs({Copy:()=>dx,Edit:()=>DE,ExportMarkdown:()=>gx,FeedbackNegative:()=>mx,FeedbackPositive:()=>px,Reload:()=>ME,Root:()=>cx,Speak:()=>zE,StopSpeaking:()=>hx});const yx=m.forwardRef((e,t)=>c.jsx(me.div,{...e,ref:t}));yx.displayName="AttachmentPrimitive.Root";const vx=m.forwardRef((e,t)=>{const n=U(r=>{const s=r.attachment.name.split(".");return s.length>1?s.pop():""});return c.jsxs(me.div,{...e,ref:t,children:[".",n]})});vx.displayName="AttachmentPrimitive.unstable_Thumb";const xx=()=>c.jsx(c.Fragment,{children:U(e=>e.attachment.name)});xx.displayName="AttachmentPrimitive.Name";const VE=()=>{const e=Z();return m.useCallback(()=>{e.attachment().remove()},[e])},HE=Ht("AttachmentPrimitive.Remove",VE);var Kh=hs({Name:()=>xx,Remove:()=>HE,Root:()=>yx,unstable_Thumb:()=>vx});const WE=e=>U(t=>{const{role:n,attachments:r,parts:s,branchCount:i,isLast:o,speech:a,isCopied:l,isHovering:u}=t.message;return!(e.hasBranches===!0&&i<2||e.user&&n!=="user"||e.assistant&&n!=="assistant"||e.system&&n!=="system"||e.lastOrHover===!0&&!u&&!o||e.last!==void 0&&e.last!==o||e.copied===!0&&!l||e.copied===!1&&l||e.speaking===!0&&a==null||e.speaking===!1&&a!=null||e.hasAttachments===!0&&(n!=="user"||!r?.length)||e.hasAttachments===!1&&n==="user"&&r?.length||e.hasContent===!0&&s.length===0||e.hasContent===!1&&s.length>0||e.submittedFeedback!==void 0&&(t.message.metadata.submittedFeedback?.type??null)!==e.submittedFeedback)}),wx=({children:e,...t})=>WE(t)?e:null;wx.displayName="MessagePrimitive.If";const Sx=m.createContext(null),Fa=()=>m.useContext(Sx),qE=({children:e})=>{const t=m.useRef(new Map),n=m.useRef([]),r=m.useCallback(()=>{const a=Array.from(t.current.entries());a.sort((l,u)=>u[1]-l[1]),n.current=a.map(([l])=>l)},[]),s=m.useCallback((a,l)=>{const u=l?.priority??0;return t.current.set(a,u),r(),()=>{t.current.delete(a),r()}},[r]),i=m.useCallback(()=>n.current,[]),o=m.useMemo(()=>({register:s,getPlugins:i}),[s,i]);return c.jsx(Sx.Provider,{value:o,children:e})},wd=m.createContext(null),bx=m.createContext(null),Sd=()=>{const e=m.useContext(wd);if(!e)throw new Error("useTriggerPopoverRootContext must be used within ComposerPrimitive.TriggerPopoverRoot");return e},bd=()=>m.useContext(wd),KE=()=>{const e=m.useContext(bx);if(!e)throw new Error("useTriggerPopoverAriaPublish must be used within ComposerPrimitive.TriggerPopoverRoot");return e},GE=()=>{const e=Sd();return m.useSyncExternalStore(e.subscribe,e.getTriggers,e.getTriggers)},QE=new Map,kx=()=>()=>{},Gh=()=>QE,YE=()=>{const e=bd();return m.useSyncExternalStore(e?e.subscribe:kx,e?e.getTriggers:Gh,e?e.getTriggers:Gh)},Qh=()=>null,JE=()=>{const e=bd();return m.useSyncExternalStore(e?e.subscribeAria:kx,e?e.getActiveAria:Qh,e?e.getActiveAria:Qh)};function Yh(){const e=m.useRef(new Set);return{notify:m.useCallback(()=>{for(const t of e.current)t()},[]),subscribe:m.useCallback(t=>(e.current.add(t),()=>{e.current.delete(t)}),[])}}const Jh=({children:e})=>{const t=m.useRef(new Map),n=m.useRef(new Set),{notify:r,subscribe:s}=Yh(),i=m.useCallback(k=>{const{char:y}=k;if(t.current.has(y))return()=>{};const v=new Map(t.current);v.set(y,k),t.current=v,r();for(const w of n.current)w.added(k);return()=>{const w=new Map(t.current);w.delete(y),t.current=w,r();for(const E of n.current)E.removed(y)}},[r]),o=m.useCallback(()=>t.current,[]),a=m.useCallback(k=>(n.current.add(k),()=>{n.current.delete(k)}),[]),l=m.useRef(null),u=m.useRef(null),{notify:f,subscribe:d}=Yh(),h=m.useCallback((k,y)=>{if(y===null){if(u.current!==k)return;l.current=null,u.current=null,f();return}const v=l.current;u.current===k&&v!==null&&v.popoverId===y.popoverId&&v.highlightedItemId===y.highlightedItemId||(l.current=y,u.current=k,f())},[f]),p=m.useCallback(()=>l.current,[]),g=m.useMemo(()=>({register:i,getTriggers:o,subscribe:s,subscribeLifecycle:a,getActiveAria:p,subscribeAria:d}),[i,o,s,a,p,d]),x=m.useMemo(()=>({setActiveAria:h}),[h]);return c.jsx(wd.Provider,{value:g,children:c.jsx(bx.Provider,{value:x,children:e})})},Cx=({children:e})=>Fa()?c.jsx(Jh,{children:e}):c.jsx(qE,{children:c.jsx(Jh,{children:e})});Cx.displayName="ComposerPrimitive.TriggerPopoverRoot";const Xh=/\s/u;function XE(e,t,n){const r=e.slice(0,n);for(let s=r.length-1;s>=0;s--){const i=r[s];if(Xh.test(i))return null;if(r.startsWith(t,s)){if(s>0&&!Xh.test(r[s-1]))continue;return{query:r.slice(s+t.length),offset:s}}}return null}const ZE=ie(({text:e,triggerChar:t})=>{const[n,r]=bt(e.length),s=te(()=>XE(e,t,Math.min(n,e.length)),[n,e,t]);return{trigger:s,query:s?.query??"",setCursorPosition:r}});function eT(e){return"type"in e}const tT=ie(({navigableList:e,isSearchMode:t,activeCategoryId:n,query:r,popoverId:s,open:i,selectItem:o,selectCategory:a,goBack:l,close:u})=>{const[f,d]=bt(0);Ie(()=>{d(0)},[e]),Ie(()=>{d(0)},[t,n]);const h=tn(x=>{x<0||x>=e.length||x!==f&&d(x)}),p=tn(x=>{if(!i)return!1;switch(x.key){case"ArrowDown":return x.preventDefault(),d(k=>{const y=e.length;return y===0?0:k<y-1?k+1:0}),!0;case"ArrowUp":return x.preventDefault(),d(k=>{const y=e.length;return y===0?0:k>0?k-1:y-1}),!0;case"Enter":case"Tab":{if(x.shiftKey)return!1;x.preventDefault();const k=e[f];return k&&(eT(k)?o(k):a(k.id)),!0}case"Escape":return x.preventDefault(),u(),!0;case"Backspace":return n&&r===""?(x.preventDefault(),l(),!0):!1;default:return!1}}),g=e[f];return{highlightedIndex:f,highlightedItemId:i&&g?`${s}-option-${g.id}`:void 0,highlightIndex:h,handleKeyDown:p}});function Zh(e,t){return e.id.toLowerCase().includes(t)||e.label.toLowerCase().includes(t)||(e.description?.toLowerCase().includes(t)??!1)}const nT=ie(({adapter:e,query:t,open:n})=>{const[r,s]=bt(null);Ie(()=>{n||s(null)},[n]);const i=te(()=>!n||!e?[]:e.categories(),[n,e]),o=n?r:null,a=te(()=>!o||!e?[]:e.categoryItems(o),[o,e]),l=te(()=>{if(!n||!e||o||!t&&i.length>0)return null;if(e.search)return e.search(t);const h=[],p=t.toLowerCase();for(const g of i)for(const x of e.categoryItems(g.id))Zh(x,p)&&h.push(x);return h},[n,e,t,o,i]),u=l!==null,f=te(()=>{if(u)return[];if(!t)return i;const h=t.toLowerCase();return i.filter(p=>p.label.toLowerCase().includes(h))},[i,t,u]),d=te(()=>{if(u)return l??[];if(!t)return a;const h=t.toLowerCase();return a.filter(p=>Zh(p,h))},[a,t,u,l]);return{categories:f,items:d,isSearchMode:u,activeCategoryId:o,navigableList:te(()=>u?l??[]:o?d:f,[u,l,o,d,f]),selectCategory:tn(h=>{s(h)}),goBack:tn(()=>{s(null)})}}),rT=ie(({behavior:e,trigger:t,aui:n,triggerChar:r,setCursorPosition:s,onSelected:i})=>{const o=en(null),a=tn(l=>(o.current=l,()=>{o.current===l&&(o.current=null)}));return{selectItem:tn(l=>{if(!t||!e)return;if(o.current?.(l)){i();return}const u=n.composer().getState().text,f=u.slice(0,t.offset),d=u.slice(t.offset+r.length+t.query.length),h=()=>{const p=e.formatter.serialize(l);n.composer().setText(f+p+(d.startsWith(" ")?d:` ${d}`))};e.kind==="directive"?(h(),e.onInserted?.(l)):(e.removeOnExecute?n.composer().setText(f+(d.startsWith(" ")?d.slice(1):d)):h(),e.onExecute(l)),i()}),close:tn(()=>{i(),t&&s(t.offset)}),registerSelectItemOverride:a}}),sT=ie(({adapter:e,text:t,triggerChar:n,behavior:r,aui:s,popoverId:i})=>{const o=Be(ZE({text:t,triggerChar:n})),a=o.trigger!==null&&e!==void 0&&r!==void 0,l=Be(nT({adapter:e,query:o.query,open:a})),u=tn(()=>{l.goBack()}),f=Be(rT({behavior:r,trigger:o.trigger,aui:s,triggerChar:n,setCursorPosition:o.setCursorPosition,onSelected:u})),d=Be(tT({navigableList:l.navigableList,isSearchMode:l.isSearchMode,activeCategoryId:l.activeCategoryId,query:o.query,popoverId:i,open:a,selectItem:f.selectItem,selectCategory:l.selectCategory,goBack:l.goBack,close:f.close}));return{open:a,query:o.query,activeCategoryId:l.activeCategoryId,categories:l.categories,items:l.items,highlightedIndex:d.highlightedIndex,isSearchMode:l.isSearchMode,popoverId:i,highlightedItemId:d.highlightedItemId,selectCategory:l.selectCategory,goBack:l.goBack,selectItem:f.selectItem,close:f.close,highlightIndex:d.highlightIndex,handleKeyDown:d.handleKeyDown,setCursorPosition:o.setCursorPosition,registerSelectItemOverride:f.registerSelectItemOverride}}),kd=m.createContext(null),ps=()=>{const e=m.useContext(kd);if(!e)throw new Error("useTriggerPopoverScopeContext must be used within ComposerPrimitive.TriggerPopover");return e},iT=()=>m.useContext(kd),_x=m.createContext(null),Ex=()=>{const e=m.useContext(_x);if(!e)throw new Error("TriggerPopover.Directive / TriggerPopover.Action must be rendered inside ComposerPrimitive.TriggerPopover");return e},Tx=m.forwardRef(({char:e,adapter:t,"aria-label":n,children:r,...s},i)=>{const o=Z(),a=U(I=>I.composer.text),l=m.useId(),u=m.useRef(null),[f,d]=m.useState(null),h=m.useRef(0),p=m.useCallback(I=>(h.current+=1,u.current=I,d(I),()=>{h.current=Math.max(0,h.current-1),u.current===I&&(u.current=null,d(null))}),[e]),g=m.useMemo(()=>({register:p}),[p]),x=tv(sT({adapter:t,text:a,triggerChar:e,behavior:f??void 0,aui:o,popoverId:l})),k=m.useRef(x);k.current=x;const y=Sd();m.useEffect(()=>y.register({char:e,...f?{behavior:f}:{},resource:k.current}),[y,e,f]);const v=Fa();m.useEffect(()=>{if(v)return v.register(k.current)},[v]);const w=f!==null&&x.open,E=KE();return m.useEffect(()=>{if(w)return()=>{E.setActiveAria(e,null)}},[E,e,w]),m.useEffect(()=>{w&&E.setActiveAria(e,{popoverId:l,highlightedItemId:x.highlightedItemId})},[E,e,l,w,x.highlightedItemId]),c.jsx(_x.Provider,{value:g,children:c.jsx(kd.Provider,{value:x,children:w?c.jsx(me.div,{role:"listbox",id:l,"aria-label":n??"Suggestions","aria-activedescendant":x.highlightedItemId,"data-state":"open",...s,ref:i,children:r}):r})})});Tx.displayName="ComposerPrimitive.TriggerPopover";const Ix=()=>{const{disabled:e,send:t}=V1(),n=m.useCallback(()=>t(),[t]);return e?null:n},oT=Ht("ComposerPrimitive.Send",Ix),Rx=m.forwardRef(({onSubmit:e,...t},n)=>{const r=Ix(),s=i=>{i.preventDefault(),r&&r()};return c.jsx(me.form,{...t,ref:n,onSubmit:Se(e,s)})});Rx.displayName="ComposerPrimitive.Root";const Px=e=>{const t=hr(e),n=vr(r=>r.onScrollToBottom);m.useEffect(()=>n(t),[n,t])},aT=()=>!1,lT=()=>{},uT=e=>m.useSyncExternalStore(m.useCallback(t=>{if(typeof window>"u"||e===null)return lT;const n=window.matchMedia(e);return n.addEventListener("change",t),()=>n.removeEventListener("change",t)},[e]),m.useCallback(()=>typeof window>"u"||e===null?!1:window.matchMedia(e).matches,[e]),aT);function Qu(){return Qu=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},Qu.apply(null,arguments)}function cT(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 dT=m.useLayoutEffect,fT=function(t){var n=lt.useRef(t);return dT(function(){n.current=t}),n},ep=function(t,n){if(typeof t=="function"){t(n);return}t.current=n},hT=function(t,n){var r=lt.useRef();return lt.useCallback(function(s){t.current=s,r.current&&ep(r.current,null),r.current=n,n&&ep(n,s)},[n])},tp={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0",display:"block"},pT=function(t){Object.keys(tp).forEach(function(n){t.style.setProperty(n,tp[n],"important")})},np=pT,Je=null,rp=function(t,n){var r=t.scrollHeight;return n.sizingStyle.boxSizing==="border-box"?r+n.borderSize:r-n.paddingSize};function mT(e,t,n,r){n===void 0&&(n=1),r===void 0&&(r=1/0),Je||(Je=document.createElement("textarea"),Je.setAttribute("tabindex","-1"),Je.setAttribute("aria-hidden","true"),np(Je)),Je.parentNode===null&&document.body.appendChild(Je);var s=e.paddingSize,i=e.borderSize,o=e.sizingStyle,a=o.boxSizing;Object.keys(o).forEach(function(h){var p=h;Je.style[p]=o[p]}),np(Je),Je.value=t;var l=rp(Je,e);Je.value=t,l=rp(Je,e),Je.value="x";var u=Je.scrollHeight-s,f=u*n;a==="border-box"&&(f=f+s+i),l=Math.max(f,l);var d=u*r;return a==="border-box"&&(d=d+s+i),l=Math.min(d,l),[l,u]}var sp=function(){},gT=function(t,n){return t.reduce(function(r,s){return r[s]=n[s],r},{})},yT=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","boxSizing","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textRendering","textTransform","width","wordBreak","wordSpacing","scrollbarGutter"],vT=!!document.documentElement.currentStyle,xT=function(t){var n=window.getComputedStyle(t);if(n===null)return null;var r=gT(yT,n),s=r.boxSizing;if(s==="")return null;vT&&s==="border-box"&&(r.width=parseFloat(r.width)+parseFloat(r.borderRightWidth)+parseFloat(r.borderLeftWidth)+parseFloat(r.paddingRight)+parseFloat(r.paddingLeft)+"px");var i=parseFloat(r.paddingBottom)+parseFloat(r.paddingTop),o=parseFloat(r.borderBottomWidth)+parseFloat(r.borderTopWidth);return{sizingStyle:r,paddingSize:i,borderSize:o}},wT=xT;function Cd(e,t,n){var r=fT(n);m.useLayoutEffect(function(){var s=function(o){return r.current(o)};if(e)return e.addEventListener(t,s),function(){return e.removeEventListener(t,s)}},[])}var ST=function(t,n){Cd(document.body,"reset",function(r){t.current.form===r.target&&n(r)})},bT=function(t){Cd(window,"resize",t)},kT=function(t){Cd(document.fonts,"loadingdone",t)},CT=["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"],_T=function(t,n){var r=t.cacheMeasurements,s=t.maxRows,i=t.minRows,o=t.onChange,a=o===void 0?sp:o,l=t.onHeightChange,u=l===void 0?sp:l,f=cT(t,CT),d=f.value!==void 0,h=m.useRef(null),p=hT(h,n),g=m.useRef(0),x=m.useRef(),k=function(){var w=h.current,E=r&&x.current?x.current:wT(w);if(E){x.current=E;var I=mT(E,w.value||w.placeholder||"x",i,s),b=I[0],P=I[1];g.current!==b&&(g.current=b,w.style.setProperty("height",b+"px","important"),u(b,{rowHeight:P}))}},y=function(w){d||k(),a(w)};return m.useLayoutEffect(k),ST(h,function(){if(!d){var v=h.current.value;requestAnimationFrame(function(){var w=h.current;w&&v!==w.value&&k()})}}),bT(k),kT(k),m.createElement("textarea",Qu({},f,{onChange:y,ref:p}))},ET=m.forwardRef(_T);const TT="(pointer: coarse) and (not (any-pointer: fine))",Ax=m.forwardRef(({autoFocus:e=!1,asChild:t,render:n,disabled:r,onChange:s,onKeyDown:i,onPaste:o,onSelect:a,submitOnEnter:l,submitMode:u,cancelOnEscape:f=!0,unstable_focusOnRunStart:d=!0,unstable_focusOnScrollToBottom:h=!0,unstable_focusOnThreadSwitched:p=!0,unstable_insertNewlineOnTouchEnter:g=!1,addAttachmentOnPaste:x=!0,...k},y)=>{const v=Z(),w=Fa(),E=JE(),I=u??(l===!1?"none":"enter"),b=uT(g?TT:null),P=g&&b&&I==="enter"?"none":I,D=U(N=>N.composer.isEditing?N.composer.text:""),O=U(N=>N.thread.isDisabled||N.composer.dictation?.inputDisabled)||r,_=m.useRef(null),z=wr(y,_),L=m.useRef(!1);fx(N=>{if(!_.current?.contains(N.target))return;if(w){for(const G of w.getPlugins())if(G.handleKeyDown(N))return}if(!f)return;const S=v.composer();S.getState().canCancel&&(S.cancel(),N.preventDefault())});const W=N=>{if(!O&&!N.nativeEvent.isComposing){if(w){for(const S of w.getPlugins())if(S.handleKeyDown(N))return}if(N.key==="Enter"){const S=v.thread().getState(),G=S.capabilities.queue;if(N.shiftKey&&(N.ctrlKey||N.metaKey)&&G&&I!=="none"&&v.composer().getState().canSend){N.preventDefault(),v.composer().send({steer:!0});return}if(N.shiftKey||S.isRunning&&!G)return;let Y=!1;P==="ctrlEnter"?Y=N.ctrlKey||N.metaKey:P==="enter"&&(Y=!0),Y&&(N.preventDefault(),_.current?.closest("form")?.requestSubmit())}}},j=async N=>{if(!x)return;const S=v.thread().getState().capabilities,G=Array.from(N.clipboardData?.files||[]);if(S.attachments&&G.length>0)try{N.preventDefault(),await Promise.all(G.map(Y=>v.composer().addAttachment(Y)))}catch(Y){console.error("Error adding attachment:",Y)}},R=e&&!O,B=m.useCallback(()=>{const N=_.current;!N||!R||(N.focus({preventScroll:!0}),N.setSelectionRange(N.value.length,N.value.length))},[R]);m.useEffect(()=>B(),[B]),Px(()=>{v.composer().getState().type==="thread"&&h&&B()}),m.useEffect(()=>{if(!(v.composer().getState().type!=="thread"||!d))return v.on("thread.runStart",B)},[d,B,v]),m.useEffect(()=>{if(!(v.composer().getState().type!=="thread"||!p))return v.on("threadListItem.switchedTo",B)},[p,B,v]);const K=E?{"aria-controls":E.popoverId,"aria-expanded":!0,"aria-haspopup":"listbox","aria-activedescendant":E.highlightedItemId}:{},A={name:"input",value:D,...k,...K,ref:z,disabled:O,onChange:Se(s,N=>{if(!v.composer().getState().isEditing)return;const S=N.nativeEvent.isComposing===!0;L.current&&!S&&(L.current=!1);const G=S||L.current;if(dh(()=>{v.composer().setText(N.target.value)}),G)return;const Y=N.target.selectionStart??N.target.value.length;if(w)for(const C of w.getPlugins())C.setCursorPosition(Y)}),onKeyDown:Se(i,W),onCompositionStart:Se(k.onCompositionStart,()=>{L.current=!0}),onCompositionEnd:Se(k.onCompositionEnd,N=>{if(L.current=!1,!v.composer().getState().isEditing)return;const S=N.target;dh(()=>{v.composer().setText(S.value)});const G=S.selectionStart??S.value.length;if(w)for(const Y of w.getPlugins())Y.setCursorPosition(G)}),onSelect:Se(a,N=>{if(L.current)return;const S=N.target,G=S.selectionStart??S.value.length;if(w)for(const Y of w.getPlugins())Y.setCursorPosition(G)}),onPaste:Se(o,j)};if(n&&m.isValidElement(n)){const N=k.children!==void 0?k.children:n.props.children;return c.jsx(ia,{...A,children:m.cloneElement(n,void 0,N)})}return c.jsx(t?ia:ET,{...A})});Ax.displayName="ComposerPrimitive.Input";const IT=()=>{const{disabled:e,cancel:t}=H1();return e?null:t},RT=Ht("ComposerPrimitive.Cancel",IT),PT=({multiple:e=!0}={})=>{const{disabled:t,addAttachment:n}=q1(),r=Z(),s=m.useCallback(()=>{const i=document.createElement("input");i.type="file",i.multiple=e,i.hidden=!0;const o=r.composer().getState().attachmentAccept;o!=="*"&&(i.accept=o),document.body.appendChild(i),i.onchange=a=>{const l=a.target.files;if(l){for(const u of l)n(u);document.body.removeChild(i)}},i.oncancel=()=>{(!i.files||i.files.length===0)&&document.body.removeChild(i)},i.click()},[r,e,n]);return t?null:s},AT=Ht("ComposerPrimitive.AddAttachment",PT,["multiple"]),jx=m.forwardRef(({disabled:e,asChild:t=!1,render:n,children:r,...s},i)=>{const[o,a]=m.useState(!1),l=Z(),u=m.useCallback(g=>{e||(g.preventDefault(),a(!0))},[e]),f=m.useCallback(g=>{e||(g.preventDefault(),o||a(!0))},[e,o]),d=m.useCallback(g=>{if(e)return;g.preventDefault();const x=g.relatedTarget;x&&g.currentTarget.contains(x)||a(!1)},[e]),h=m.useCallback(async g=>{if(e)return;g.preventDefault(),a(!1);const x=Array.from(g.dataTransfer.files);await Promise.all(x.map(async k=>{try{await l.composer().addAttachment(k)}catch(y){console.error("Failed to add attachment:",y)}}))},[e,l]),p={...o?{"data-dragging":"true"}:null,...s,onDragEnterCapture:Se(s.onDragEnterCapture,u),onDragOverCapture:Se(s.onDragOverCapture,f),onDragLeaveCapture:Se(s.onDragLeaveCapture,d),onDropCapture:Se(s.onDropCapture,h),ref:i};if(n&&m.isValidElement(n)){const g=r!==void 0?r:n.props.children;return c.jsx(ia,{...p,children:m.cloneElement(n,void 0,g)})}return c.jsx(t?ia:"div",{...p,children:r})});jx.displayName="ComposerPrimitive.AttachmentDropzone";const jT=()=>{const{disabled:e,startDictation:t}=W1();return e?null:t},NT=Ht("ComposerPrimitive.Dictate",jT),MT=()=>{const e=Z(),t=U(r=>r.composer.dictation!=null),n=m.useCallback(()=>{e.composer().stopDictation()},[e]);return t?n:null},LT=Ht("ComposerPrimitive.StopDictation",MT),Nx=m.forwardRef(({children:e,...t},n)=>{const r=U(s=>s.composer.dictation?.transcript);return r?c.jsx(me.span,{...t,ref:n,children:e??r}):null});Nx.displayName="ComposerPrimitive.DictationTranscript";const Mx=m.forwardRef((e,t)=>U(n=>n.composer.quote)?c.jsx(me.div,{...e,ref:t}):null);Mx.displayName="ComposerPrimitive.Quote";const Lx=m.forwardRef(({children:e,...t},n)=>{const r=U(s=>s.composer.quote?.text);return r?c.jsx(me.span,{...t,ref:n,children:e??r}):null});Lx.displayName="ComposerPrimitive.QuoteText";const Dx=m.forwardRef(({onClick:e,...t},n)=>{const r=Z(),s=m.useCallback(()=>{r.composer().setQuote(void 0)},[r]);return c.jsx(me.button,{type:"button",...t,ref:n,onClick:Se(e,s)})});Dx.displayName="ComposerPrimitive.QuoteDismiss";const Ox=m.forwardRef(({children:e,"aria-label":t,...n},r)=>{const{categories:s,activeCategoryId:i,isSearchMode:o,open:a}=ps();return!a||i||o?null:c.jsx(me.div,{role:"group","aria-label":t??"Categories",...n,ref:r,children:e(s)})});Ox.displayName="ComposerPrimitive.TriggerPopoverCategories";const zx=m.forwardRef(({categoryId:e,onClick:t,onMouseMove:n,...r},s)=>{const{selectCategory:i,highlightIndex:o,categories:a,highlightedIndex:l,activeCategoryId:u,isSearchMode:f,popoverId:d}=ps(),h=m.useCallback(()=>{i(e)},[i,e]),p=a.findIndex(k=>k.id===e),g=!u&&!f&&p===l,x=m.useCallback(()=>{o(p)},[o,p]);return c.jsx(me.button,{type:"button",role:"option",id:`${d}-option-${e}`,"aria-selected":g,"data-highlighted":g?"":void 0,...r,ref:s,onClick:Se(t,h),onMouseMove:Se(n,x)})});zx.displayName="ComposerPrimitive.TriggerPopoverCategoryItem";const Fx=m.forwardRef(({children:e,"aria-label":t,...n},r)=>{const{items:s,activeCategoryId:i,isSearchMode:o,open:a}=ps();return!a||!i&&!o?null:c.jsx(me.div,{role:"group","aria-label":t??"Items",...n,ref:r,children:e(s)})});Fx.displayName="ComposerPrimitive.TriggerPopoverItems";const Bx=m.forwardRef(({item:e,index:t,onClick:n,onMouseMove:r,...s},i)=>{const{selectItem:o,highlightIndex:a,items:l,highlightedIndex:u,activeCategoryId:f,isSearchMode:d,popoverId:h}=ps(),p=m.useCallback(()=>{o(e)},[o,e]),g=t??l.findIndex(y=>y.id===e.id),x=(d||f!==null)&&g===u,k=m.useCallback(()=>{a(g)},[a,g]);return c.jsx(me.button,{type:"button",role:"option",id:`${h}-option-${e.id}`,"aria-selected":x,"data-highlighted":x?"":void 0,...s,ref:i,onClick:Se(n,p),onMouseMove:Se(r,k)})});Bx.displayName="ComposerPrimitive.TriggerPopoverItem";const $x=m.forwardRef(({onClick:e,...t},n)=>{const{activeCategoryId:r,isSearchMode:s,goBack:i,open:o}=ps();return!o||!r||s?null:c.jsx(me.button,{type:"button",...t,ref:n,onClick:Se(e,i)})});$x.displayName="ComposerPrimitive.TriggerPopoverBack";const Ux=({formatter:e,onExecute:t,removeOnExecute:n})=>{const{register:r}=Ex(),s=m.useRef(t);return s.current=t,m.useEffect(()=>r({kind:"action",formatter:e??ox,onExecute:i=>s.current(i),...n!==void 0?{removeOnExecute:n}:{}}),[r,e,n]),null};Ux.displayName="ComposerPrimitive.TriggerPopoverAction";const Vx=({formatter:e,onInserted:t})=>{const{register:n}=Ex(),r=m.useRef(t);return r.current=t,m.useEffect(()=>n({kind:"directive",formatter:e??ox,onInserted:s=>r.current?.(s)}),[n,e]),null};Vx.displayName="ComposerPrimitive.TriggerPopoverDirective";const DT=Object.assign(Tx,{Directive:Vx,Action:Ux});var Ts=hs({AddAttachment:()=>AT,AttachmentByIndex:()=>Zv,AttachmentDropzone:()=>jx,Attachments:()=>ex,Cancel:()=>RT,Dictate:()=>NT,DictationTranscript:()=>Nx,If:()=>ix,Input:()=>Ax,Queue:()=>tx,Quote:()=>Mx,QuoteDismiss:()=>Dx,QuoteText:()=>Lx,Root:()=>Rx,Send:()=>oT,StopDictation:()=>LT,Unstable_TriggerPopover:()=>DT,Unstable_TriggerPopoverBack:()=>$x,Unstable_TriggerPopoverCategories:()=>Ox,Unstable_TriggerPopoverCategoryItem:()=>zx,Unstable_TriggerPopoverItem:()=>Bx,Unstable_TriggerPopoverItems:()=>Fx,Unstable_TriggerPopoverRoot:()=>Cx,unstable_useTriggerPopoverRootContext:()=>Sd,unstable_useTriggerPopoverRootContextOptional:()=>bd,unstable_useTriggerPopoverScopeContext:()=>ps,unstable_useTriggerPopoverScopeContextOptional:()=>iT,unstable_useTriggerPopoverTriggers:()=>GE,unstable_useTriggerPopoverTriggersOptional:()=>YE});const Hx=()=>U(e=>{if(e.part.type!=="text"&&e.part.type!=="reasoning")throw new Error("MessagePartText can only be used inside text or reasoning message parts.");return e.part}),OT=()=>U(e=>{if(e.part.type!=="image")throw new Error("MessagePartImage can only be used inside image message parts.");return e.part}),Wx=m.createContext(null),zT=e=>({useSmoothStatus:av(()=>e)}),FT=({children:e})=>{const t=qx({optional:!0}),n=Z(),[r]=m.useState(()=>zT(n.part().getState().status));return t?e:c.jsx(Wx.Provider,{value:r,children:e})},BT=e=>{const t=m.forwardRef((n,r)=>c.jsx(FT,{children:c.jsx(e,{...n,ref:r})}));return t.displayName=e.displayName,t};function qx(e){const t=m.useContext(Wx);if(!e?.optional&&!t)throw new Error("This component must be used within a SmoothContextProvider.");return t}const{useSmoothStatus:$T,useSmoothStatusStore:UT}=ax(qx,"useSmoothStatus");var VT=class{constructor(e,t){T(this,"currentText");T(this,"setText");T(this,"animationFrameId",null);T(this,"lastUpdateTime",Date.now());T(this,"targetText","");T(this,"animate",()=>{const e=Date.now();let t=e-this.lastUpdateTime;const n=this.targetText.length-this.currentText.length,r=Math.min(5,250/n);let s=0;for(;t>=r&&s<n;)s++,t-=r;s!==n?this.animationFrameId=requestAnimationFrame(this.animate):this.animationFrameId=null,s!==0&&(this.currentText=this.targetText.slice(0,this.currentText.length+s),this.lastUpdateTime=e-t,this.setText(this.currentText))});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)}};const Il=Object.freeze({type:"running"}),Kx=(e,t=!1)=>{const{text:n}=e,[r,s]=m.useState(e.status.type==="running"?"":n),i=Z(),o=U(()=>i.part()),[a,l]=m.useState(o);(o!==a||!n.startsWith(r))&&(l(o),s(e.status.type==="running"?"":n));const u=UT({optional:!0}),f=hr(p=>{if(s(p),u){const g=r!==p||e.status.type==="running"?Il:e.status;ra(u).setState(g,!0)}});m.useEffect(()=>{if(u){const p=t&&(r!==n||e.status.type==="running")?Il:e.status;ra(u).setState(p,!0)}},[u,t,n,r,e.status]);const[d]=m.useState(new VT(r,f)),h=m.useRef(o);return m.useEffect(()=>{if(!t){d.stop();return}const p=h.current!==o;if(h.current=o,p||!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]),m.useEffect(()=>()=>{d.stop()},[d]),m.useMemo(()=>t?{type:"text",text:r,status:n===r?e.status:Il}:e,[t,r,e,n])},_d=m.forwardRef(({smooth:e=!0,component:t="span",...n},r)=>{const{text:s,status:i}=Kx(Hx(),e);return c.jsx(t,{"data-status":i.type,...n,ref:r,children:s})});_d.displayName="MessagePartPrimitive.Text";const Ed=m.forwardRef((e,t)=>{const{image:n}=OT();return c.jsx(me.img,{src:n,...e,ref:t})});Ed.displayName="MessagePartPrimitive.Image";const Sr=e=>{const t=m.useRef(void 0);return m.useCallback(n=>{t.current&&(t.current(),t.current=void 0),n&&(t.current=e(n))},[e])},ip=(e,t)=>{const n=e.trim().match(/^(\d+(?:\.\d+)?|\.\d+)(em|px|rem)$/);if(!n)return Number.POSITIVE_INFINITY;const r=Number(n[1]),s=n[2];return s==="px"?r:s==="em"?r*(parseFloat(getComputedStyle(t).fontSize)||16):s==="rem"?r*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16):Number.POSITIVE_INFINITY},HT=e=>e.dataset.messageId,WT=()=>{const 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},op=(e,t)=>{const n=`${t}px`;return e.style.height!==n?(e.style.height=n,!0):!1},qT=e=>{const t=window.devicePixelRatio||1;return Math.round(e*t)/t},Gx=()=>{const e=Z(),t=U(()=>e.message());return Sr(m.useCallback(n=>{const r=()=>{t.setIsHovering(!0)},s=()=>{t.setIsHovering(!1)};return n.addEventListener("mouseenter",r),n.addEventListener("mouseleave",s),n.matches(":hover")&&queueMicrotask(()=>t.setIsHovering(!0)),()=>{n.removeEventListener("mouseenter",r),n.removeEventListener("mouseleave",s),t.setIsHovering(!1)}},[t]))},KT=()=>{const e=vr(t=>t.topAnchorTurn?.anchorId);return U(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))},GT=()=>{const e=vr(t=>t.topAnchorTurn?.targetId);return U(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))},QT=(e,t)=>Sr(m.useCallback(n=>{if(e)return t.getState().registerAnchorElement(n)},[e,t])),YT=({active:e,threadViewportStore:t})=>Sr(m.useCallback(n=>{if(!e)return;const r=t.getState(),s=r.topAnchorMessageClamp;return r.registerAnchorTargetElement(n,{tallerThan:ip(s.tallerThan,n),visibleHeight:ip(s.visibleHeight,n)})},[e,t])),JT=({forwardedRef:e,...t})=>{const n=wr(e,Gx()),r=U(s=>s.message.id);return c.jsx(me.div,{...t,ref:n,"data-message-id":r})},XT=({forwardedRef:e,threadViewportStore:t,...n})=>{const r=Gx(),s=KT(),i=GT(),o=wr(e,r,QT(s,t),YT({active:i,threadViewportStore:t})),a=U(l=>l.message.id);return c.jsx(me.div,{...n,ref:o,"data-message-id":a,"data-aui-top-anchor-user":s?"":void 0,"data-aui-top-anchor-target":i?"":void 0})},Qx=m.forwardRef((e,t)=>{const n=xr();return n.getState().turnAnchor==="top"?c.jsx(XT,{...e,forwardedRef:t,threadViewportStore:n}):c.jsx(JT,{...e,forwardedRef:t})});Qx.displayName="MessagePrimitive.Root";const Rl={...qe,Text:()=>c.jsxs("p",{style:{whiteSpace:"pre-line"},children:[c.jsx(_d,{}),c.jsx(vd,{children:c.jsx("span",{style:{fontFamily:"revert"},children:" ●"})})]}),Image:()=>c.jsx(Ed,{})},Yu=e=>{if("children"in e)return c.jsx(Gu,{children:e.children});const{components:t,...n}=e;return c.jsx(Gu,{components:t?{Text:t.Text??Rl.Text,Image:t.Image??Rl.Image,Reasoning:t.Reasoning??qe.Reasoning,Source:t.Source??qe.Source,File:t.File??qe.File,Unstable_Audio:t.Unstable_Audio??qe.Unstable_Audio,..."ChainOfThought"in t?{ChainOfThought:t.ChainOfThought}:{tools:t.tools,data:t.data,ToolGroup:t.ToolGroup??qe.ToolGroup,ReasoningGroup:t.ReasoningGroup??qe.ReasoningGroup},Empty:t.Empty,Quote:t.Quote,generativeUI:t.generativeUI}:Rl,...n})};Yu.displayName="MessagePrimitive.Parts";const Yx=({children:e})=>tE()!==void 0?e:null;Yx.displayName="MessagePrimitive.Error";const ZT=e=>{const t=new Map;for(let r=0;r<e.length;r++){const s=e[r]?.parentId??`__ungrouped_${r}`,i=t.get(s)??[];i.push(r),t.set(s,i)}const n=[];for(const[r,s]of t){const i=r.startsWith("__ungrouped_")?void 0:r;n.push({groupKey:i,indices:s})}return n},eI=e=>{const t=U(n=>n.message.parts);return m.useMemo(()=>t.length===0?[]:e(t),[t,e])},tI=({Fallback:e,...t})=>{const n=U(r=>{const s=r.tools.tools[t.toolName]??e;return Array.isArray(s)?s[0]??e:s});return n?c.jsx(n,{...t}):null},nI=({Fallback:e,...t})=>{const n=U(r=>{const s=r.dataRenderers.renderers[t.name]??e;return Array.isArray(s)?s[0]??e:s});return n?c.jsx(n,{...t}):null},_n={Text:()=>c.jsxs("p",{style:{whiteSpace:"pre-line"},children:[c.jsx(_d,{}),c.jsx(vd,{children:c.jsx("span",{style:{fontFamily:"revert"},children:" ●"})})]}),Reasoning:()=>null,Source:()=>null,Image:()=>c.jsx(Ed,{}),File:()=>null,Unstable_Audio:()=>null,Group:({children:e})=>e},rI=({components:{Text:e=_n.Text,Reasoning:t=_n.Reasoning,Image:n=_n.Image,Source:r=_n.Source,File:s=_n.File,Unstable_Audio:i=_n.Unstable_Audio,tools:o={},data:a}={}})=>{const l=Z(),u=U(d=>d.part),f=u.type;if(f==="tool-call"){const d=l.part().addToolResult,h=l.part().resumeToolCall,p=l.part().respondToToolApproval;if("Override"in o)return c.jsx(o.Override,{...u,addResult:d,resume:h,respondToApproval:p});const g=o.by_name?.[u.toolName]??o.Fallback;return c.jsx(tI,{...u,Fallback:g,addResult:d,resume:h,respondToApproval:p})}if(u.status?.type==="requires-action")throw new Error("Encountered unexpected requires-action status");switch(f){case"text":return c.jsx(e,{...u});case"reasoning":return c.jsx(t,{...u});case"source":return c.jsx(r,{...u});case"image":return c.jsx(n,{...u});case"file":return c.jsx(s,{...u});case"audio":return c.jsx(i,{...u});case"data":{const d=a?.by_name?.[u.name]??a?.Fallback;return c.jsx(nI,{...u,Fallback:d})}default:return console.warn(`Unknown message part type: ${f}`),null}},sI=({partIndex:e,components:t})=>c.jsx(fd,{index:e,children:c.jsx(rI,{components:t})}),iI=m.memo(sI,(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),oI=({status:e,component:t})=>c.jsx(hd,{text:"",isRunning:e.type==="running",children:c.jsx(t,{type:"text",text:"",status:e})}),aI=Object.freeze({type:"complete"}),lI=({components:e})=>{const t=U(n=>n.message.status??aI);return e?.Empty?c.jsx(e.Empty,{status:t}):c.jsx(oI,{status:t,component:e?.Text??_n.Text})},uI=m.memo(lI,(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),Td=({groupingFunction:e,components:t})=>{const n=U(s=>s.message.parts.length),r=eI(e);return c.jsx(c.Fragment,{children:m.useMemo(()=>n===0?c.jsx(uI,{components:t}):r.map((s,i)=>c.jsx(t?.Group??_n.Group,{groupKey:s.groupKey,indices:s.indices,children:s.indices.map(o=>c.jsx(iI,{partIndex:o,components:t},o))},`group-${i}-${s.groupKey??"ungrouped"}`)),[r,t,n])})};Td.displayName="MessagePrimitive.Unstable_PartsGrouped";const Jx=({components:e,...t})=>c.jsx(Td,{...t,components:e,groupingFunction:ZT});Jx.displayName="MessagePrimitive.Unstable_PartsGroupedByParentId";var oa=hs({AttachmentByIndex:()=>Yv,Attachments:()=>Jv,Content:()=>Yu,Error:()=>Yx,GenerativeUI:()=>zv,GroupedParts:()=>Kv,If:()=>wx,PartByIndex:()=>Gs,Parts:()=>Yu,Quote:()=>Gv,Root:()=>Qx,Unstable_PartsGrouped:()=>Td,Unstable_PartsGroupedByParentId:()=>Jx});const cI=e=>{const t=hr(e);return Sr(m.useCallback(n=>{const r=new ResizeObserver(()=>{t()}),s=new MutationObserver(i=>{i.some(o=>o.type!=="attributes"||o.attributeName!=="style")&&t()});return r.observe(n),s.observe(n,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),()=>{r.disconnect(),s.disconnect()}},[t]))},dI=({autoScroll:e,scrollToBottomOnRunStart:t=!0,scrollToBottomOnInitialize:n=!0,scrollToBottomOnThreadSwitch:r=!0})=>{const s=m.useRef(null),i=U(E=>E.thread.messages.length>0),o=m.useRef(!1),a=m.useRef(null),l=xr();e===void 0&&(e=l.getState().turnAnchor!=="top");const u=m.useRef(0),f=m.useRef(0),d=m.useRef(0),h=m.useRef(0),p=m.useRef(null),g=m.useCallback(E=>{const I=s.current;I&&(p.current=E,I.scrollTo({top:I.scrollHeight,behavior:E}))},[]),x=m.useCallback(E=>{p.current=E,a.current!==null&&cancelAnimationFrame(a.current),a.current=requestAnimationFrame(()=>{a.current=null,g(E)})},[g]);m.useLayoutEffect(()=>()=>{a.current!==null&&cancelAnimationFrame(a.current)},[]);const k=m.useCallback(()=>{const E=l.getState();return E.turnAnchor==="top"&&E.element.viewport===s.current&&E.element.anchor!==null},[l]),y=()=>{const E=s.current;if(!E)return;const I=l.getState().isAtBottom,b=Math.abs(E.scrollHeight-E.scrollTop-E.clientHeight)<=1||E.scrollHeight<=E.clientHeight;!b&&u.current<E.scrollTop||(b?E.scrollHeight>E.clientHeight+1&&(p.current=null):u.current>E.scrollTop&&f.current===E.scrollHeight&&(p.current=null),(b||p.current===null)&&b!==I&&ra(l).setState({isAtBottom:b})),u.current=E.scrollTop,f.current=E.scrollHeight},v=cI(()=>{const E=s.current;if(!E)return;const{scrollHeight:I,clientHeight:b}=E;if(I===d.current&&b===h.current)return;d.current=I,h.current=b;const P=p.current;P&&k()?p.current=null:P?g(P):e&&l.getState().isAtBottom&&g("instant"),y()}),w=Sr(E=>(E.addEventListener("scroll",y),()=>{E.removeEventListener("scroll",y)}));return m.useLayoutEffect(()=>{if(n){if(!i){o.current=!1;return}o.current||(o.current=!0,p.current===null&&x("instant"))}},[i,x,n]),Px(({behavior:E})=>{g(E)}),Zo("thread.runStart",()=>{t&&l.getState().turnAnchor!=="top"&&x("auto")}),Zo("threadListItem.switchedTo",()=>{r&&x("instant")}),wr(v,w,s)},Xx=m.forwardRef((e,t)=>c.jsx(me.div,{...e,ref:t}));Xx.displayName="ThreadPrimitive.Root";const Zx=({children:e})=>U(t=>t.thread.isEmpty)?e:null;Zx.displayName="ThreadPrimitive.Empty";const fI=e=>U(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)),ew=({children:e,...t})=>fI(t)?e:null;ew.displayName="ThreadPrimitive.If";const tw=(e,t)=>Sr(m.useCallback(n=>{if(!e)return;const r=e(),s=()=>{const o=t?t(n):n.offsetHeight;r.setHeight(o)},i=new ResizeObserver(s);return i.observe(n),s(),()=>{i.disconnect(),r.unregister()}},[e,t])),ap=e=>{let t=0,n=e;for(;n;)t+=n.offsetTop,n=n.offsetParent;return t},hI=(e,t)=>{let n=0,r=e;for(;r&&r!==t;)n+=r.offsetTop,r=r.offsetParent;return r===t?n:ap(e)-ap(t)},nw=({viewport:e,anchor:t,tallerThan:n,visibleHeight:r})=>{const s=hI(t,e),i=t.offsetHeight;return s+Math.max(0,i-(i<=n?i:r))},pI=({scrollHeight:e,...t})=>{const{viewport:n}=t,r=nw(t)+n.clientHeight;return Math.max(0,r-e)},mI=({viewport:e,reserve:t,...n})=>pI({viewport:e,...n,scrollHeight:e.scrollHeight-t.offsetHeight}),gI=e=>{const t=new ResizeObserver(e),n=new MutationObserver(e);let r=null,s=null,i=null;const o=()=>{t.disconnect(),n.disconnect(),r=null,s=null,i=null};return{target:(a,l,u)=>{r===a&&s===l&&i===u||(o(),t.observe(a),t.observe(l),t.observe(u),n.observe(u,{childList:!0,subtree:!0,characterData:!0}),r=a,s=l,i=u)},disconnect:o}},yI=e=>{let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},cancel:()=>{t!==null&&(cancelAnimationFrame(t),t=null)}}},vI=e=>{let t=null,n;function r(){const a=e.getState(),{viewport:l,anchor:u,target:f}=a.element,d=a.targetConfig;if(a.turnAnchor!=="top"||!l||!u||!f||!d){i.disconnect(),t&&(op(t,0),t.remove());return}if(t??(t=WT()),(t.parentElement!==f.parentElement||t.previousElementSibling!==f)&&f.after(t),i.target(l,u,f),op(t,mI({viewport:l,anchor:u,reserve:t,...d}))){s.schedule();return}const h=HT(u);if(h!==void 0&&n===h)return;const p=qT(nw({viewport:l,anchor:u,...d}));Math.abs(l.scrollTop-p)>1&&l.scrollTo({top:p,behavior:"smooth"}),h!==void 0&&(n=h)}const s=yI(r),i=gI(s.schedule);s.schedule();const o=e.subscribe(s.schedule);return()=>{s.cancel(),o(),i.disconnect(),t?.remove()}},xI=e=>{const t=xr();m.useLayoutEffect(()=>{if(e)return vI(t)},[e,t])},rw=({isRunning:e,messages:t})=>{if(!e)return null;const n=t.at(-1),r=t.at(-2);return r?.role!=="user"||n?.role!=="assistant"?null:{anchorId:r.id,targetId:n.id}},wI=e=>rw(e)?.anchorId,SI=e=>rw(e)?.targetId,bI=()=>tw(vr(e=>e.registerViewport),m.useCallback(e=>e.clientHeight,[])),kI=()=>Sr(vr(e=>e.registerViewportElement)),CI=e=>{const t=xr(),n=U(o=>{if(e)return wI(o.thread)}),r=U(o=>{if(e)return SI(o.thread)}),s=m.useMemo(()=>!n||!r?null:{anchorId:n,targetId:r},[n,r]);m.useLayoutEffect(()=>{if(!s)return;const o=t.getState(),a=o.topAnchorTurn;a?.anchorId===s.anchorId&&a.targetId===s.targetId||o.setTopAnchorTurn(s)},[s,t]);const i=m.useCallback(()=>{t.getState().setTopAnchorTurn(null)},[t]);Zo("thread.initialize",i),Zo("threadListItem.switchedTo",i)},sw=m.forwardRef(({autoScroll:e,scrollToBottomOnRunStart:t,scrollToBottomOnInitialize:n,scrollToBottomOnThreadSwitch:r,children:s,...i},o)=>{const a=dI({autoScroll:e,scrollToBottomOnRunStart:t,scrollToBottomOnInitialize:n,scrollToBottomOnThreadSwitch:r}),l=bI(),u=kI(),f=xr().getState().turnAnchor==="top";CI(f),xI(f);const d=wr(o,a,l,u);return c.jsx(me.div,{...i,ref:d,children:s})});sw.displayName="ThreadPrimitive.ViewportScrollable";const iw=m.forwardRef(({turnAnchor:e,topAnchorMessageClamp:t,...n},r)=>c.jsx(xd,{options:{turnAnchor:e,topAnchorMessageClamp:t},children:c.jsx(sw,{...n,ref:r})}));iw.displayName="ThreadPrimitive.Viewport";const ow=m.forwardRef((e,t)=>{const n=wr(t,tw(vr(r=>r.registerContentInset),m.useCallback(r=>{const s=parseFloat(getComputedStyle(r).marginTop)||0;return r.offsetHeight+s},[])));return c.jsx(me.div,{...e,ref:n})});ow.displayName="ThreadPrimitive.ViewportFooter";const _I=({behavior:e}={})=>{const t=vr(s=>s.isAtBottom),n=xr(),r=m.useCallback(()=>{n.getState().scrollToBottom({behavior:e})},[n,e]);return t?null:r},EI=Ht("ThreadPrimitive.ScrollToBottom",_I,["behavior"]),TI=({prompt:e,send:t,clearComposer:n,autoSend:r,method:s})=>{const{disabled:i,trigger:o}=eE({prompt:e,send:t??r??!1,clearComposer:n});return i?null:o},II=Ht("ThreadPrimitive.Suggestion",TI,["prompt","send","clearComposer","autoSend","method"]);var ct=hs({Empty:()=>Zx,If:()=>ew,MessageByIndex:()=>Mv,Messages:()=>l1,Root:()=>Xx,ScrollToBottom:()=>EI,Suggestion:()=>II,SuggestionByIndex:()=>rx,Suggestions:()=>$1,Viewport:()=>iw,ViewportFooter:()=>ow,ViewportProvider:()=>xd}),RI=hs({AssistantRuntimeImpl:()=>Tv,BaseAssistantRuntimeCore:()=>Iv,CompositeContextProvider:()=>od,DefaultThreadComposerRuntimeCore:()=>Av,MessageRepository:()=>md,ThreadRuntimeImpl:()=>Ev,fromThreadMessageLike:()=>wi,generateId:()=>Un,getAutoStatus:()=>ta,splitLocalRuntimeOptions:()=>nE,useComposerInputPluginRegistryOptional:()=>Fa,useSmooth:()=>Kx,useSmoothStatus:()=>$T,withSmoothContextProvider:()=>BT});const Id="claude-control.token";let aa=null,la=!1;function PI(){try{return window.localStorage.getItem(Id)}catch{return null}}const AI="claude-control";function Ba(){return la||(aa=PI(),la=!0),aa}function aw(e){aa=e,la=!0;try{window.localStorage.setItem(Id,e)}catch{}}function lw(){aa=null,la=!0;try{window.localStorage.removeItem(Id)}catch{}}function jI(){if(typeof window>"u"||!window.location)return;let e;try{e=new URLSearchParams(window.location.search)}catch{return}const t=e.get("token");if(!t)return;aw(t),e.delete("token");const n=e.toString(),r=window.location.pathname+(n?`?${n}`:"")+window.location.hash;try{window.history.replaceState(null,"",r)}catch{}}jI();const Ju=new Set;function NI(e){return Ju.add(e),()=>Ju.delete(e)}function uw(){lw();for(const e of Ju)e()}function MI(e){const t=Ba(),n={...e??{}};return t&&(n.Authorization=`Bearer ${t}`),n}async function je(e,t){const n=await fetch(e,{...t,headers:MI(t?.headers)});return n.status===401&&uw(),n}function LI(e){const t=`/term/${encodeURIComponent(e)}/`,n=Ba();return n?`${t}?token=${encodeURIComponent(n)}`:t}function DI(){const e=window.location;return`${e.protocol==="https:"?"wss:":"ws:"}//${e.host}/`}async function OI(e,t){const n=await je("/api/pins",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({id:e,transcriptPath:t})}),r=await n.json().catch(()=>({}));if(!n.ok||!r.ok)throw new Error(r.error||`HTTP ${n.status}`);return r.pins??{}}async function zI(){const e=await je("/api/transcripts");if(!e.ok)throw new Error(`HTTP ${e.status}`);return(await e.json()).transcripts??[]}async function cw(){try{const e=await je("/api/version");return e.ok?await e.json():null}catch{return null}}async function FI(){try{const e=await je("/api/update",{method:"POST"}),t=await e.json().catch(()=>({}));return e.ok&&!!t.ok}catch{return!0}}async function BI(){try{const e=await je("/api/push/vapid");return e.ok?(await e.json()).publicKey??null:null}catch{return null}}async function $I(e){try{return(await je("/api/push/subscribe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)})).ok}catch{return!1}}async function UI(e){try{return(await je("/api/push/unsubscribe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:e})})).ok}catch{return!1}}async function VI(e){const t=await je("/api/icon",{method:"POST",body:e}),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok)throw new Error(n.error||`HTTP ${t.status}`)}async function HI(){const e=await je("/api/icon",{method:"DELETE"}),t=await e.json().catch(()=>({}));if(!e.ok||!t.ok)throw new Error(t.error||`HTTP ${e.status}`)}async function WI(){const e=await je("/api/models");if(!e.ok)throw new Error(`HTTP ${e.status}`);return await e.json()}async function qI(e,t){const n=await je("/api/optimize",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:e})}),r=await n.json().catch(()=>({}));if(!n.ok||typeof r.optimized!="string")throw new Error(r.error||`HTTP ${n.status}`);return{optimized:r.optimized,rationale:r.rationale??[],changes:r.changes??[],mode:r.mode==="rules"?"rules":"llm"}}async function KI(e,t="webm"){const n=await je(`/api/transcribe?ext=${encodeURIComponent(t)}`,{method:"POST",body:e}),r=await n.json().catch(()=>({}));if(!n.ok||!r.ok)throw new Error(r.error||`HTTP ${n.status}`);return r.text??""}async function GI(){const e=await je("/api/config");if(!e.ok)throw new Error(`HTTP ${e.status}`);return await e.json()}async function QI(e){const t=await je("/api/config",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}),n=await t.json().catch(()=>({}));if(!t.ok)throw new Error("error"in n&&n.error||`HTTP ${t.status}`);return n}async function YI(e){const t=await je("/api/session/new",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e??{})}),n=await t.json().catch(()=>({}));if(!t.ok||!("ok"in n)||!n.ok){const r="error"in n&&n.error||`HTTP ${t.status}`;throw new Error(r)}return n}async function JI(e,t){const n=await je("/api/session/rename",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({id:e,name:t})}),r=await n.json().catch(()=>({}));if(!n.ok||!("ok"in r)||!r.ok){const s="error"in r&&r.error||`HTTP ${n.status}`;throw new Error(s)}}function XI(e){return`/api/uploads/${encodeURIComponent(e)}`}async function dw(){const e=await je("/api/skills");if(!e.ok)throw new Error(`HTTP ${e.status}`);return(await e.json()).skills??[]}async function ZI(e){const t=`/api/upload?name=${encodeURIComponent(e.name)}`,n=await je(t,{method:"POST",body:e});let r=null;try{r=await n.json()}catch{}const s=r??{};if(!n.ok||!s.ok||!s.path)throw new Error(s.error||`HTTP ${n.status}`);return{ok:!0,path:s.path,name:s.name??e.name}}const eR=1008,lp=1e3,tR=3e4;class nR{constructor(){T(this,"ws",null);T(this,"reconnectTimer",null);T(this,"reconnectDelay",lp);T(this,"selectedId",null);T(this,"closed",!1);T(this,"msgHandlers",new Set);T(this,"stateHandlers",new Set)}connect(){if(this.ws&&(this.ws.readyState===WebSocket.OPEN||this.ws.readyState===WebSocket.CONNECTING))return;this.emitState("connecting");const t=Ba(),n=t?[AI,t]:void 0,r=new WebSocket(DI(),n);this.ws=r,r.addEventListener("open",()=>{this.reconnectDelay=lp,this.emitState("connected"),this.selectedId&&this.send({type:"subscribe",id:this.selectedId})}),r.addEventListener("message",s=>{let i;try{i=JSON.parse(s.data)}catch{return}for(const o of this.msgHandlers)o(i)}),r.addEventListener("close",s=>{if(this.ws=null,this.emitState("disconnected"),s.code===eR){uw();return}this.closed||this.scheduleReconnect()}),r.addEventListener("error",()=>{})}scheduleReconnect(){this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>this.connect(),this.reconnectDelay),this.reconnectDelay=Math.min(this.reconnectDelay*2,tR)}send(t){return this.ws&&this.ws.readyState===WebSocket.OPEN?(this.ws.send(JSON.stringify(t)),!0):!1}isOpen(){return this.ws?.readyState===WebSocket.OPEN}select(t){this.selectedId!==t&&(this.selectedId&&this.send({type:"unsubscribe",id:this.selectedId}),this.selectedId=t,t&&this.send({type:"subscribe",id:t}))}resubscribe(){const t=this.selectedId;t&&(this.send({type:"unsubscribe",id:t}),this.send({type:"subscribe",id:t}))}onMessage(t){return this.msgHandlers.add(t),()=>this.msgHandlers.delete(t)}onState(t){return this.stateHandlers.add(t),()=>this.stateHandlers.delete(t)}emitState(t){for(const n of this.stateHandlers)n(t)}close(){this.closed=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.ws?.close(),this.ws=null}}const up=2e3;function rR(e,t){if(!e||e.length===0)return cp(t);if(t.length===0)return e;const n=new Set;for(const s of e)n.add(s.uuid);const r=t.filter(s=>!n.has(s.uuid));return r.length===0?e:cp([...e,...r])}function cp(e){return e.length>up?e.slice(e.length-up):e}function sR(){const e=m.useRef(null);e.current||(e.current=new nR);const t=e.current,[n,r]=m.useState([]),[s,i]=m.useState(null),[o,a]=m.useState("connecting"),[l,u]=m.useState({snapshot:null,warning:null}),[f,d]=m.useState(null),[h,p]=m.useState({}),[g,x]=m.useState({}),[k,y]=m.useState({}),[v,w]=m.useState({}),E=m.useRef(null);E.current=s,m.useEffect(()=>{const B=t.onState(a),K=t.onMessage(A=>{switch(A.type){case"sessions":r(A.sessions??[]);break;case"messages":p(N=>({...N,[A.id]:rR(N[A.id],A.messages??[])})),x(N=>({...N,[A.id]:A.pending??null}));break;case"append":p(N=>({...N,[A.id]:[...N[A.id]??[],...A.messages??[]]}));break;case"pending":x(N=>({...N,[A.id]:A.pending})),r(N=>N.map(S=>S.id===A.id?{...S,pending:!!A.pending}:S));break;case"resources":u({snapshot:A.snapshot??null,warning:A.warning??null});break;case"capture":A.id===E.current&&d(A.text??"");break;case"prompt":w(N=>({...N,[A.id]:A.prompt}));break;case"subagents":y(N=>({...N,[A.id]:Object.fromEntries((A.subagents??[]).map(S=>[S.agentId,S]))}));break;case"subagent":y(N=>({...N,[A.id]:{...N[A.id]??{},[A.subagent.agentId]:A.subagent}}));break;case"ack":window.dispatchEvent(new CustomEvent("cockpit:ack",{detail:A}));break}});return t.connect(),()=>{B(),K()}},[t]),m.useEffect(()=>()=>t.close(),[t]);const I=m.useCallback(B=>{B!==E.current&&(i(B),d(null),t.select(B))},[t]),b=m.useCallback(B=>{const K=E.current;return!K||!B.trim()?!1:t.send({type:"reply",id:K,text:B})},[t]),P=m.useCallback((B,K)=>{const A=E.current;return A?t.send({type:"answer",id:A,toolUseId:B,selections:K}):!1},[t]),D=m.useCallback(B=>{const K=E.current;return K?t.send({type:"capture",id:K,lines:B}):!1},[t]),O=m.useCallback(()=>d(null),[]),_=m.useCallback(()=>t.resubscribe(),[t]),z=m.useCallback(B=>{const K=E.current;return K?t.send({type:"promptkey",id:K,key:B}):!1},[t]),L=m.useMemo(()=>s?h[s]??[]:[],[s,h]),W=m.useMemo(()=>s?g[s]??null:null,[s,g]),j=m.useMemo(()=>s?v[s]??null:null,[s,v]),R=m.useMemo(()=>{const B=s?k[s]:null;return B?Object.values(B).sort((K,A)=>(A.createdAt??-1/0)-(K.createdAt??-1/0)):[]},[s,k]);return{sessions:n,selectedId:s,messages:L,pending:W,prompt:j,subagents:R,conn:o,resources:l,capture:f,select:I,resubscribe:_,sendReply:b,sendPromptKey:z,sendAnswer:P,requestCapture:D,clearCapture:O}}const Pl="cc:push:intent";function iR(){return typeof window>"u"||!("serviceWorker"in navigator)||!("PushManager"in window)||!("Notification"in window)?!1:window.isSecureContext===!0}function oR(){if(typeof navigator>"u")return!1;const e=navigator.userAgent||"",t=/iPad|iPhone|iPod/.test(e),n=navigator.platform==="MacIntel"&&typeof navigator.maxTouchPoints=="number"&&navigator.maxTouchPoints>1;return t||n}function dp(e){const t="=".repeat((4-e.length%4)%4),n=(e+t).replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(n),s=new ArrayBuffer(r.length),i=new Uint8Array(s);for(let o=0;o<r.length;o+=1)i[o]=r.charCodeAt(o);return s}function aR(){const e=iR(),t=oR(),[n,r]=m.useState(e?"off":"unsupported"),s=m.useCallback(async()=>{const a=await navigator.serviceWorker.register("/sw.js");if(await navigator.serviceWorker.ready,await Notification.requestPermission()!=="granted")return r("denied"),!1;const u=await BI();if(!u)return r("off"),!1;let f=await a.pushManager.getSubscription();if(f)try{const h=dp(u),p=f.options?.applicationServerKey;let g=!1;if(p instanceof ArrayBuffer){const x=new Uint8Array(p),k=new Uint8Array(h);if(x.length!==k.length)g=!0;else for(let y=0;y<x.length;y++)if(x[y]!==k[y]){g=!0;break}}g&&(await f.unsubscribe(),f=null)}catch{}return f||(f=await a.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:dp(u)})),await $I(f.toJSON())},[]),i=m.useCallback(async()=>{if(e){r("working");try{await s()?(localStorage.setItem(Pl,"1"),r("on")):r(l=>l==="denied"?"denied":"off")}catch{r("off")}}},[e,s]),o=m.useCallback(async()=>{r("working"),localStorage.removeItem(Pl);try{const l=await(await navigator.serviceWorker.getRegistration())?.pushManager.getSubscription();l&&(await UI(l.endpoint),await l.unsubscribe())}catch{}r("off")},[]);return m.useEffect(()=>{if(!e||localStorage.getItem(Pl)!=="1")return;if(Notification.permission!=="granted"){r(Notification.permission==="denied"?"denied":"off");return}let a=!1;return(async()=>{try{const l=await s();a||r(l?"on":"off")}catch{a||r("off")}})(),()=>{a=!0}},[e,s]),{status:n,supported:e,iosHint:t,enable:i,disable:o}}const Xu=70,lR=110,uR=.5,cR=".thread-viewport, .rail, .live-pane-body";function dR(e,t=()=>window.location.reload()){const[n,r]=m.useState(0),[s,i]=m.useState(!1),o=m.useRef(0),a=m.useRef(!1),l=m.useRef(0),u=m.useRef(null),f=d=>{o.current=d,r(d)};return m.useEffect(()=>{const d=e.current;if(!d)return;const h=x=>{if(x.touches.length!==1){a.current=!1;return}const y=x.target?.closest(cR)??null;y&&y.scrollTop<=0?(u.current=y,l.current=x.touches[0].clientY,a.current=!0):a.current=!1},p=x=>{if(!a.current)return;const k=x.touches[0].clientY-l.current,y=u.current;if(k<=0||y&&y.scrollTop>0){o.current!==0&&f(0),y&&y.scrollTop>0&&(a.current=!1);return}const v=Math.min(lR,k*uR);f(v),x.cancelable&&x.preventDefault()},g=()=>{a.current&&(a.current=!1,o.current>=Xu?(f(Xu),i(!0),setTimeout(t,150)):f(0))};return d.addEventListener("touchstart",h,{passive:!0}),d.addEventListener("touchmove",p,{passive:!1}),d.addEventListener("touchend",g,{passive:!0}),d.addEventListener("touchcancel",g,{passive:!0}),()=>{d.removeEventListener("touchstart",h),d.removeEventListener("touchmove",p),d.removeEventListener("touchend",g),d.removeEventListener("touchcancel",g)}},[e,t]),{pull:n,refreshing:s}}const fR=Xu,ua="__cockpitSummary";function hR(e){if(e&&typeof e=="object"&&ua in e){const t=e[ua];return typeof t=="string"?t:""}return""}function fw(e){if(!e||typeof e!="object")return e;const t={};for(const[n,r]of Object.entries(e))n!==ua&&(t[n]=r);return t}function pR(e){if(e&&typeof e=="object"&&"text"in e){const t=e;return{text:String(t.text??""),isError:!!t.isError}}return null}function hw(e){const t=new Map;for(const r of e)for(const s of r.blocks??[])s.kind==="tool_result"&&t.set(s.forId,{text:s.text??"",isError:!!s.isError});const n=[];return e.forEach((r,s)=>{const i=yR(r.blocks??[],t,r.role==="user");if(i.length===0)return;const o=r.role==="user"?"user":"assistant";n.push({role:o,id:r.uuid||`m-${s}`,createdAt:r.ts?new Date(r.ts):void 0,content:i,metadata:{custom:{cockpitRole:r.role}}})}),mR(n)}function mR(e){const t=r=>r.role==="assistant"&&(r.metadata?.custom?.cockpitRole??"assistant")==="assistant",n=[];for(const r of e){const s=n[n.length-1];s&&t(s)&&t(r)?n[n.length-1]={...s,content:[...s.content,...r.content]}:n.push(r)}return n}function gR(e){const t=e.trimStart();if(!t.startsWith("<"))return null;const n=/<summary>([\s\S]*?)<\/summary>/.exec(t)?.[1]?.trim();return t.startsWith("<task-notification")?`⚙ background task ${n?`— ${n}`:"update"}`:t.startsWith("<system-reminder")?"⚙ system reminder":t.startsWith("<command-name")||t.startsWith("<command-message")?"⌘ slash command":t.startsWith("<local-command-stdout")?"⌘ command output":t.startsWith("<user-prompt-submit-hook")||t.startsWith("<session-")?"⚙ session hook":null}function yR(e,t,n=!1){const r=[];for(const s of e)switch(s.kind){case"text":{if(s.text&&s.text.length>0){const i=n?gR(s.text):null;r.push({type:"text",text:i??s.text})}break}case"thinking":{s.text&&s.text.trim().length>0&&r.push({type:"reasoning",text:s.text});break}case"tool_use":{const i=t.get(s.id),o=s.input&&typeof s.input=="object"?s.input:s.input!=null?{value:s.input}:{};r.push({type:"tool-call",toolCallId:s.id,toolName:s.name||"tool",args:{...o,[ua]:s.inputSummary??""},argsText:s.inputSummary??"",result:i??void 0,isError:i?.isError});break}}return r}const vR="image/*,application/pdf,text/*,.md,.json,.csv,.log",Zu=" cockpit-path:";function xR(e){return Zu+e}const ko=new Map;function wR(e){return ko.get(e)??null}function SR(e){for(const t of e.content??[])if(t.type==="text"&&t.text.startsWith(Zu))return t.text.slice(Zu.length);return wR(e.id)}function bR(e){return`${e.name}-${e.size}-${e.lastModified}`}function kR(e){return{accept:vR,async add({file:t}){const n=bR(t),r=t.type.startsWith("image/"),s=t.type==="application/pdf",i={id:n,type:r?"image":s?"document":"file",name:t.name,contentType:t.type||"application/octet-stream",file:t};e(`Uploading ${t.name}…`);try{const o=await ZI(t);return ko.set(n,o.path),e(`Attached ${o.name}`,"ok"),{...i,status:{type:"requires-action",reason:"composer-send"}}}catch(o){const a=o instanceof Error?o.message:String(o);return e(`Attach failed: ${a}`,"error"),{...i,status:{type:"incomplete",reason:"error"}}}},async send(t){const n=ko.get(t.id);if(!n)throw new Error(`attachment ${t.name} was not uploaded`);return{...t,status:{type:"complete"},content:[{type:"text",text:xR(n)}]}},async remove(t){ko.delete(t.id)}}}function CR(e){const t=e.windowIndex!=null&&e.sessionName!=null?`${e.sessionName}:${e.windowIndex}`:e.id,n=e.paneIndex!=null?` · p${e.paneIndex}`:"";return`${t}${n}`}function _R(e,t){return!!e.active!=!!t.active?e.active?-1:1:(t.lastActivity??0)-(e.lastActivity??0)}function ER({sessions:e,selectedId:t,onSelect:n}){const r=[...e].sort(_R);return c.jsxs("ul",{className:"session-list",role:"listbox","aria-label":"Sessions",children:[r.map(s=>{const i=s.id===t;return c.jsxs("li",{role:"option","aria-selected":i,tabIndex:0,className:"session-item","data-active":s.active?"true":"false","data-selected":i?"true":"false",onClick:()=>n(s.id),onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),n(s.id))},children:[c.jsxs("div",{className:"session-top",children:[c.jsx("span",{className:"active-dot","data-on":s.active?"true":"false","aria-hidden":"true"}),c.jsx("span",{className:"session-name",children:s.name||s.id}),s.pending?c.jsx("span",{className:"ask-badge","aria-label":"pending question",children:"ASK"}):null]}),c.jsxs("div",{className:"session-meta",children:[c.jsx("span",{className:"meta-prov",children:CR(s)}),s.model?c.jsx("span",{className:"meta-model",children:s.model}):null,s.ctxPct!=null?c.jsxs("span",{className:"meta-ctx",children:["ctx:",Math.round(s.ctxPct),"%"]}):null]})]},s.id)}),r.length===0?c.jsx("li",{className:"session-empty",children:"no Claude sessions"}):null]})}const TR={on:"Notifications on",off:"Enable notifications",denied:"Notifications blocked",unsupported:"Notifications unsupported",working:"Working…"};function IR({push:e}){const{status:t,supported:n,enable:r,disable:s}=e,i=t==="on",o=!n||t==="unsupported"||t==="working"||t==="denied",a=TR[t]??"Notifications",l=()=>{o||(i?s():r())};return c.jsx("button",{type:"button",className:"notify-bell","data-state":t,"aria-pressed":i,"aria-label":a,title:a,disabled:o,onClick:l,children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24","aria-hidden":"true",children:[c.jsx("path",{d:"M12 22a2.5 2.5 0 0 0 2.45-2h-4.9A2.5 2.5 0 0 0 12 22Zm7-5-1.6-1.6V10a5.4 5.4 0 0 0-4-5.2V4a1.4 1.4 0 0 0-2.8 0v.8A5.4 5.4 0 0 0 6.6 10v5.4L5 17v1h14Z",fill:i?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"}),t==="denied"||t==="unsupported"?c.jsx("line",{x1:"4",y1:"4",x2:"20",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}):null]})})}function RR({size:e=18}){return c.jsxs("svg",{width:e,height:Math.round(e*1.2),viewBox:"0 0 10 12","aria-hidden":"true",focusable:"false",style:{display:"block",flexShrink:0},children:[c.jsx("rect",{x:"1",y:"2",width:"8",height:"7",fill:"#c97c5a"}),c.jsx("rect",{x:"0",y:"3",width:"1",height:"2",fill:"#c97c5a"}),c.jsx("rect",{x:"9",y:"3",width:"1",height:"2",fill:"#c97c5a"}),c.jsx("rect",{x:"2",y:"4",width:"2",height:"2",fill:"var(--bg)"}),c.jsx("rect",{x:"6",y:"4",width:"2",height:"2",fill:"var(--bg)"}),c.jsx("rect",{x:"2",y:"9",width:"2",height:"2",fill:"#c97c5a"}),c.jsx("rect",{x:"6",y:"9",width:"2",height:"2",fill:"#c97c5a"})]})}function fp(e,t=""){return e!=null?`${Math.round(e)}${t}`:"—"}function PR({resources:e,conn:t,push:n}){const r=e.snapshot,s=r?.self??{},i=r?.system??{},o=!!r?.overLimit||!!e.warning,a=i.loadavg?.[0];return c.jsxs("div",{className:"hud","data-warn":o?"true":"false",role:"status",children:[c.jsxs("span",{className:"hud-brand",children:[c.jsx(RR,{size:18}),"claude control"]}),c.jsx("span",{className:`conn-dot conn-${t}`,title:t,"aria-label":t}),c.jsxs("span",{className:"hud-group",children:[c.jsx("span",{className:"hud-k",children:"cpu"}),c.jsx("span",{className:"hud-v",children:s.cpuPct!=null?`${s.cpuPct.toFixed(0)}%`:"—"})]}),c.jsxs("span",{className:"hud-group",children:[c.jsx("span",{className:"hud-k",children:"rss"}),c.jsx("span",{className:"hud-v",children:fp(s.rssMB,"m")})]}),c.jsxs("span",{className:"hud-group",children:[c.jsx("span",{className:"hud-k",children:"load"}),c.jsx("span",{className:"hud-v",children:a!=null?a.toFixed(2):"—"})]}),c.jsxs("span",{className:"hud-group",children:[c.jsx("span",{className:"hud-k",children:"mem"}),c.jsx("span",{className:"hud-v",children:fp(i.memUsedPct,"%")})]}),o?c.jsx("span",{className:"hud-warn-text",children:e.warning||"over limit"}):null,c.jsx("span",{className:"hud-spacer"}),c.jsx(IR,{push:n})]})}const AR={direction:"down",stagger:45,duration:300,exitOffset:50,easing:"cubic-bezier(0.34, 1.56, 0.64, 1)",bounce:.6,colorFade:280,skipUnchanged:!0,interrupt:!0},jR=" ",Rd=e=>e===" "?jR:e,Qs=new WeakMap;function pw(e){const t=Qs.get(e);t&&(t.timers.forEach(n=>window.clearTimeout(n)),Qs.delete(e),ca(e,t.target))}function mw(e){const t=document.createElement("span");return t.className="char-face",t.textContent=Rd(e),t}function gw(e){const t=document.createElement("span");t.className="char-slot",t.dataset.char=e;const n=document.createElement("span");return n.className="char-sizer",n.textContent=Rd(e),t.append(n,mw(e)),t}function ca(e,t){e.classList.add("slot-text"),e.replaceChildren(...Array.from(t,gw))}function yw(e,t,n={}){const{direction:r,stagger:s,duration:i,exitOffset:o,easing:a,bounce:l,color:u,colorFade:f,skipUnchanged:d,interrupt:h}={...AR,...n},p=Qs.get(e);if(p&&!h){t!==p.target&&(p.pending={text:t,options:n});return}if(pw(e),!e.querySelector(".char-slot")){ca(e,t);return}const g=Array.from(e.querySelectorAll(".char-slot")),x=g.map(L=>L.dataset.char??"").join("");if(!h&&x===t)return;const k=Math.max(x.length,t.length),y=g.find(L=>(L.dataset.char??"")!=="")??g[0],v=getComputedStyle(e),w=Math.ceil(y?.getBoundingClientRect().height||y?.offsetHeight||e.getBoundingClientRect().height||parseFloat(v.lineHeight)||0)||Math.ceil(parseFloat(v.fontSize)*1.3)||18,E=u?v.color:"";for(let L=g.length;L<k;L++){const W=gw("");e.appendChild(W),g.push(W)}const I=[],b={timers:I,target:t};Qs.set(e,b);const P=r==="down"?w:-w,D=r==="down"?-w:w,O=(L,W)=>{const j=Math.sin((L+1)*12.9898+W*78.233)*43758.5453;return(j-Math.floor(j))*2-1};let _=0;for(let L=0;L<k;L++){const W=x[L]||"",j=t[L]||"";if(W===j&&(d||W===""))continue;const R=g[L],B=R.querySelector(".char-sizer"),K=R.querySelector(".char-face"),A=R.getBoundingClientRect().width;B.textContent=Rd(j);const N=B.getBoundingClientRect().width,S=Math.abs(N-A)>.5;S&&(R.style.width=`${A}px`),(W===""||j==="")&&R.classList.add("is-resizing");const G=typeof u=="function"?u(L,k):u,Y=j==="",C=Math.round(i*(Y?.75:1)*(1+l*.45*O(L,1))),ve=Y?t.length*.5+(L-t.length)*.25:L,Re=Math.round(ve*s*(1+l*.25*O(L,2))),ue=(l*5*O(L,3)).toFixed(2),De=`transform ${C}ms ${a}`,rt=u?`${De}, color ${f}ms linear ${C}ms`:De,Ne=mw(j);if(Ne.style.transformOrigin="50% 50%",Ne.style.transform=`translateY(${D}px) rotate(${ue}deg)`,G&&(Ne.style.color=G),R.appendChild(Ne),R.offsetWidth,S){let Ye=Re,st=C;Y?(Ye=Re+Math.round(C*.55),st=Math.max(140,Math.round(C*.6))):W===""&&(st=Math.max(140,Math.round(C*.45))),I.push(window.setTimeout(()=>{R.style.transition=`width ${st}ms cubic-bezier(0.2, 0, 0, 1)`,R.style.width=`${N}px`},Ye)),_=Math.max(_,Ye+st)}_=Math.max(_,Re+o+C+(u?f:0)),K&&I.push(window.setTimeout(()=>{K.style.transition=De,K.style.transform=`translateY(${P}px) rotate(${-Number(ue)}deg)`},Re)),I.push(window.setTimeout(()=>{Ne.style.transition=rt,Ne.style.transform="translateY(0) rotate(0deg)",u&&(Ne.style.color=E);const Ye=st=>{st.propertyName==="transform"&&(Ne.removeEventListener("transitionend",Ye),R.dataset.char=j,R.style.removeProperty("transition"),R.style.removeProperty("width"),R.classList.remove("is-resizing"),R.querySelectorAll(".char-face").forEach(Ce=>{Ce!==Ne&&Ce.remove()}))};Ne.addEventListener("transitionend",Ye)},Re+o))}const z=_+80;I.push(window.setTimeout(()=>{const L=b.pending;Qs.delete(e),ca(e,t),L&&yw(e,L.text,L.options)},z))}function NR(e,t=""){pw(e),e.classList.remove("slot-text"),e.textContent=t}const vw=m.forwardRef(({text:e,options:t,"aria-label":n,...r},s)=>{const i=m.useRef(null),o=m.useRef(!1),a=m.useRef(!0),l=m.useRef(t);return m.useImperativeHandle(s,()=>i.current,[]),m.useEffect(()=>{l.current=t},[t]),m.useEffect(()=>{const u=i.current;if(u)return ca(u,e),o.current=!0,()=>{NR(u),o.current=!1,a.current=!0}},[]),m.useEffect(()=>{const u=i.current;if(!(!u||!o.current)){if(a.current){a.current=!1;return}yw(u,e,l.current)}},[e]),m.createElement("span",{...r,"aria-label":n??e,ref:i})});vw.displayName="SlotText";const MR=(e,t)=>typeof e=="string"?e===t:JSON.stringify(e)===JSON.stringify(t),LR=(e,t)=>{if(!e||!t)return!1;const n=r=>{const{position:s,data:i,...o}=r||{};return o};return JSON.stringify(n(e.properties))===JSON.stringify(n(t.properties))&&MR(e.children,t.children)},xw=(e,t)=>LR(e.node,t.node),Pd=m.createContext(null),DR=()=>m.useContext(Pd)!==null,OR=({children:e,...t})=>c.jsx(Pd.Provider,{value:t,children:e}),zR=m.memo(OR,xw),FR=({node:e,...t})=>c.jsx("pre",{...t}),BR=({node:e,...t})=>c.jsx("code",{...t}),Ad=({node:e,components:{Pre:t,Code:n},code:r})=>c.jsx(t,{children:c.jsx(n,{node:e,children:r})}),$R=()=>null,UR=({node:e,components:{Pre:t,Code:n,SyntaxHighlighter:r,CodeHeader:s},language:i,code:o})=>{const a=m.useMemo(()=>({Pre:t,Code:n}),[t,n]);return c.jsxs(c.Fragment,{children:[c.jsx(s,{node:e,language:i,code:o}),c.jsx(i?r:Ad,{node:e,components:a,language:i??"unknown",code:o})]})};var ww={exports:{}};/*!
45
- Copyright (c) 2018 Jed Watson.
46
- Licensed under the MIT License (MIT), see
47
- http://jedwatson.github.io/classnames
48
- */(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var i="",o=0;o<arguments.length;o++){var a=arguments[o];a&&(i=s(i,r(a)))}return i}function r(i){if(typeof i=="string"||typeof i=="number")return i;if(typeof i!="object")return"";if(Array.isArray(i))return n.apply(null,i);if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]"))return i.toString();var o="";for(var a in i)t.call(i,a)&&i[a]&&(o=s(o,a));return o}function s(i,o){return o?i?i+" "+o:i+o:i}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(ww);var VR=ww.exports;const Sw=ki(VR),hp=({className:e,...t})=>({className:n,...r})=>({className:Sw(e,n),...t,...r}),HR=({node:e,components:{Pre:t,Code:n,SyntaxHighlighter:r,CodeHeader:s},componentsByLanguage:i={},children:o,...a})=>{const l=hp(m.useContext(Pd)),u=hr(p=>c.jsx(t,{...l(p)})),f=hp(a),d=hr(p=>c.jsx(n,{...f(p)})),h=/language-(\w+)/.exec(a.className||"")?.[1]??"";return typeof o!="string"?c.jsx(Ad,{node:e,components:{Pre:u,Code:d},code:o}):c.jsx(UR,{node:e,components:{Pre:u,Code:d,SyntaxHighlighter:i[h]?.SyntaxHighlighter??r,CodeHeader:i[h]?.CodeHeader??s},language:h||"unknown",code:o})},WR=({node:e,components:t,componentsByLanguage:n,...r})=>DR()?c.jsx(HR,{node:e,components:t,componentsByLanguage:n,...r}):c.jsx(t.Code,{...r}),qR=m.memo(WR,(e,t)=>e.components===t.components&&e.componentsByLanguage===t.componentsByLanguage&&xw(e,t));function KR(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const GR=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,QR=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,YR={};function pp(e,t){return(YR.jsx?QR:GR).test(e)}const JR=/[ \t\n\f\r]/g;function XR(e){return typeof e=="object"?e.type==="text"?mp(e.value):!1:mp(e)}function mp(e){return e.replace(JR,"")===""}class Ri{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Ri.prototype.normal={};Ri.prototype.property={};Ri.prototype.space=void 0;function bw(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new Ri(n,r,t)}function ec(e){return e.toLowerCase()}class pt{constructor(t,n){this.attribute=n,this.property=t}}pt.prototype.attribute="";pt.prototype.booleanish=!1;pt.prototype.boolean=!1;pt.prototype.commaOrSpaceSeparated=!1;pt.prototype.commaSeparated=!1;pt.prototype.defined=!1;pt.prototype.mustUseProperty=!1;pt.prototype.number=!1;pt.prototype.overloadedBoolean=!1;pt.prototype.property="";pt.prototype.spaceSeparated=!1;pt.prototype.space=void 0;let ZR=0;const J=br(),Pe=br(),tc=br(),$=br(),fe=br(),or=br(),gt=br();function br(){return 2**++ZR}const nc=Object.freeze(Object.defineProperty({__proto__:null,boolean:J,booleanish:Pe,commaOrSpaceSeparated:gt,commaSeparated:or,number:$,overloadedBoolean:tc,spaceSeparated:fe},Symbol.toStringTag,{value:"Module"})),Al=Object.keys(nc);class jd extends pt{constructor(t,n,r,s){let i=-1;if(super(t,n),gp(this,"space",s),typeof r=="number")for(;++i<Al.length;){const o=Al[i];gp(this,Al[i],(r&nc[o])===nc[o])}}}jd.prototype.defined=!0;function gp(e,t,n){n&&(e[t]=n)}function ms(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const i=new jd(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[ec(r)]=r,n[ec(i.attribute)]=r}return new Ri(t,n,e.space)}const kw=ms({properties:{ariaActiveDescendant:null,ariaAtomic:Pe,ariaAutoComplete:null,ariaBusy:Pe,ariaChecked:Pe,ariaColCount:$,ariaColIndex:$,ariaColSpan:$,ariaControls:fe,ariaCurrent:null,ariaDescribedBy:fe,ariaDetails:null,ariaDisabled:Pe,ariaDropEffect:fe,ariaErrorMessage:null,ariaExpanded:Pe,ariaFlowTo:fe,ariaGrabbed:Pe,ariaHasPopup:null,ariaHidden:Pe,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:fe,ariaLevel:$,ariaLive:null,ariaModal:Pe,ariaMultiLine:Pe,ariaMultiSelectable:Pe,ariaOrientation:null,ariaOwns:fe,ariaPlaceholder:null,ariaPosInSet:$,ariaPressed:Pe,ariaReadOnly:Pe,ariaRelevant:null,ariaRequired:Pe,ariaRoleDescription:fe,ariaRowCount:$,ariaRowIndex:$,ariaRowSpan:$,ariaSelected:Pe,ariaSetSize:$,ariaSort:null,ariaValueMax:$,ariaValueMin:$,ariaValueNow:$,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Cw(e,t){return t in e?e[t]:t}function _w(e,t){return Cw(e,t.toLowerCase())}const eP=ms({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:or,acceptCharset:fe,accessKey:fe,action:null,allow:null,allowFullScreen:J,allowPaymentRequest:J,allowUserMedia:J,alpha:J,alt:null,as:null,async:J,autoCapitalize:null,autoComplete:fe,autoFocus:J,autoPlay:J,blocking:fe,capture:null,charSet:null,checked:J,cite:null,className:fe,closedBy:null,colorSpace:null,cols:$,colSpan:$,command:null,commandFor:null,content:null,contentEditable:Pe,controls:J,controlsList:fe,coords:$|or,crossOrigin:null,data:null,dateTime:null,decoding:null,default:J,defer:J,dir:null,dirName:null,disabled:J,download:tc,draggable:Pe,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:J,formTarget:null,headers:fe,height:$,hidden:tc,high:$,href:null,hrefLang:null,htmlFor:fe,httpEquiv:fe,id:null,imageSizes:null,imageSrcSet:null,inert:J,inputMode:null,integrity:null,is:null,isMap:J,itemId:null,itemProp:fe,itemRef:fe,itemScope:J,itemType:fe,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:J,low:$,manifest:null,max:null,maxLength:$,media:null,method:null,min:null,minLength:$,multiple:J,muted:J,name:null,nonce:null,noModule:J,noValidate:J,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:J,optimum:$,pattern:null,ping:fe,placeholder:null,playsInline:J,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:J,referrerPolicy:null,rel:fe,required:J,reversed:J,rows:$,rowSpan:$,sandbox:fe,scope:null,scoped:J,seamless:J,selected:J,shadowRootClonable:J,shadowRootCustomElementRegistry:J,shadowRootDelegatesFocus:J,shadowRootMode:null,shadowRootSerializable:J,shape:null,size:$,sizes:null,slot:null,span:$,spellCheck:Pe,src:null,srcDoc:null,srcLang:null,srcSet:null,start:$,step:null,style:null,tabIndex:$,target:null,title:null,translate:null,type:null,typeMustMatch:J,useMap:null,value:Pe,width:$,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:fe,axis:null,background:null,bgColor:null,border:$,borderColor:null,bottomMargin:$,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:J,declare:J,event:null,face:null,frame:null,frameBorder:null,hSpace:$,leftMargin:$,link:null,longDesc:null,lowSrc:null,marginHeight:$,marginWidth:$,noResize:J,noHref:J,noShade:J,noWrap:J,object:null,profile:null,prompt:null,rev:null,rightMargin:$,rules:null,scheme:null,scrolling:Pe,standby:null,summary:null,text:null,topMargin:$,valueType:null,version:null,vAlign:null,vLink:null,vSpace:$,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:J,disablePictureInPicture:J,disableRemotePlayback:J,exportParts:or,part:fe,prefix:null,property:null,results:$,security:null,unselectable:null},space:"html",transform:_w}),tP=ms({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:gt,accentHeight:$,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:$,amplitude:$,arabicForm:null,ascent:$,attributeName:null,attributeType:null,azimuth:$,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:$,by:null,calcMode:null,capHeight:$,className:fe,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:$,diffuseConstant:$,direction:null,display:null,dur:null,divisor:$,dominantBaseline:null,download:J,dx:null,dy:null,edgeMode:null,editable:null,elevation:$,enableBackground:null,end:null,event:null,exponent:$,externalResourcesRequired:null,fill:null,fillOpacity:$,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:or,g2:or,glyphName:or,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:$,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:$,horizOriginX:$,horizOriginY:$,id:null,ideographic:$,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:$,k:$,k1:$,k2:$,k3:$,k4:$,kernelMatrix:gt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:$,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:$,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:$,overlineThickness:$,paintOrder:null,panose1:null,path:null,pathLength:$,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:fe,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:$,pointsAtY:$,pointsAtZ:$,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:gt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:gt,rev:gt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:gt,requiredFeatures:gt,requiredFonts:gt,requiredFormats:gt,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:$,specularExponent:$,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:$,strikethroughThickness:$,string:null,stroke:null,strokeDashArray:gt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:$,strokeOpacity:$,strokeWidth:null,style:null,surfaceScale:$,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:gt,tabIndex:$,tableValues:null,target:null,targetX:$,targetY:$,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:gt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:$,underlineThickness:$,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:$,values:null,vAlphabetic:$,vMathematical:$,vectorEffect:null,vHanging:$,vIdeographic:$,version:null,vertAdvY:$,vertOriginX:$,vertOriginY:$,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:$,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Cw}),Ew=ms({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()}}),Tw=ms({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:_w}),Iw=ms({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),nP={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"},rP=/[A-Z]/g,yp=/-[a-z]/g,sP=/^data[-\w.:]+$/i;function iP(e,t){const n=ec(t);let r=t,s=pt;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&sP.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(yp,aP);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!yp.test(i)){let o=i.replace(rP,oP);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}s=jd}return new s(r,t)}function oP(e){return"-"+e.toLowerCase()}function aP(e){return e.charAt(1).toUpperCase()}const lP=bw([kw,eP,Ew,Tw,Iw],"html"),Nd=bw([kw,tP,Ew,Tw,Iw],"svg");function uP(e){return e.join(" ").trim()}var Md={},vp=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,cP=/\n/g,dP=/^\s*/,fP=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,hP=/^:\s*/,pP=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,mP=/^[;\s]*/,gP=/^\s+|\s+$/g,yP=`
49
- `,xp="/",wp="*",Zn="",vP="comment",xP="declaration";function wP(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function s(g){var x=g.match(cP);x&&(n+=x.length);var k=g.lastIndexOf(yP);r=~k?g.length-k:r+g.length}function i(){var g={line:n,column:r};return function(x){return x.position=new o(g),u(),x}}function o(g){this.start=g,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function a(g){var x=new Error(t.source+":"+n+":"+r+": "+g);if(x.reason=g,x.filename=t.source,x.line=n,x.column=r,x.source=e,!t.silent)throw x}function l(g){var x=g.exec(e);if(x){var k=x[0];return s(k),e=e.slice(k.length),x}}function u(){l(dP)}function f(g){var x;for(g=g||[];x=d();)x!==!1&&g.push(x);return g}function d(){var g=i();if(!(xp!=e.charAt(0)||wp!=e.charAt(1))){for(var x=2;Zn!=e.charAt(x)&&(wp!=e.charAt(x)||xp!=e.charAt(x+1));)++x;if(x+=2,Zn===e.charAt(x-1))return a("End of comment missing");var k=e.slice(2,x-2);return r+=2,s(k),e=e.slice(x),r+=2,g({type:vP,comment:k})}}function h(){var g=i(),x=l(fP);if(x){if(d(),!l(hP))return a("property missing ':'");var k=l(pP),y=g({type:xP,property:Sp(x[0].replace(vp,Zn)),value:k?Sp(k[0].replace(vp,Zn)):Zn});return l(mP),y}}function p(){var g=[];f(g);for(var x;x=h();)x!==!1&&(g.push(x),f(g));return g}return u(),p()}function Sp(e){return e?e.replace(gP,Zn):Zn}var SP=wP,bP=Eo&&Eo.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Md,"__esModule",{value:!0});Md.default=CP;const kP=bP(SP);function CP(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,kP.default)(e),s=typeof t=="function";return r.forEach(i=>{if(i.type!=="declaration")return;const{property:o,value:a}=i;s?t(o,a,i):a&&(n=n||{},n[o]=a)}),n}var $a={};Object.defineProperty($a,"__esModule",{value:!0});$a.camelCase=void 0;var _P=/^--[a-zA-Z0-9_-]+$/,EP=/-([a-z])/g,TP=/^[^-]+$/,IP=/^-(webkit|moz|ms|o|khtml)-/,RP=/^-(ms)-/,PP=function(e){return!e||TP.test(e)||_P.test(e)},AP=function(e,t){return t.toUpperCase()},bp=function(e,t){return"".concat(t,"-")},jP=function(e,t){return t===void 0&&(t={}),PP(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(RP,bp):e=e.replace(IP,bp),e.replace(EP,AP))};$a.camelCase=jP;var NP=Eo&&Eo.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},MP=NP(Md),LP=$a;function rc(e,t){var n={};return!e||typeof e!="string"||(0,MP.default)(e,function(r,s){r&&s&&(n[(0,LP.camelCase)(r,t)]=s)}),n}rc.default=rc;var DP=rc;const OP=ki(DP),Rw=Pw("end"),Ld=Pw("start");function Pw(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function zP(e){const t=Ld(e),n=Rw(e);if(t&&n)return{start:t,end:n}}function Ys(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?kp(e.position):"start"in e||"end"in e?kp(e):"line"in e||"column"in e?sc(e):""}function sc(e){return Cp(e&&e.line)+":"+Cp(e&&e.column)}function kp(e){return sc(e&&e.start)+"-"+sc(e&&e.end)}function Cp(e){return e&&typeof e=="number"?e:1}class Qe extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let s="",i={},o=!1;if(n&&("line"in n&&"column"in n?i={place:n}:"start"in n&&"end"in n?i={place:n}:"type"in n?i={ancestors:[n],place:n.position}:i={...n}),typeof t=="string"?s=t:!i.cause&&t&&(o=!0,s=t.message,i.cause=t),!i.ruleId&&!i.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?i.ruleId=r:(i.source=r.slice(0,l),i.ruleId=r.slice(l+1))}if(!i.place&&i.ancestors&&i.ancestors){const l=i.ancestors[i.ancestors.length-1];l&&(i.place=l.position)}const a=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=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=a?a.line:void 0,this.name=Ys(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=o&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Qe.prototype.file="";Qe.prototype.name="";Qe.prototype.reason="";Qe.prototype.message="";Qe.prototype.stack="";Qe.prototype.column=void 0;Qe.prototype.line=void 0;Qe.prototype.ancestors=void 0;Qe.prototype.cause=void 0;Qe.prototype.fatal=void 0;Qe.prototype.place=void 0;Qe.prototype.ruleId=void 0;Qe.prototype.source=void 0;const Dd={}.hasOwnProperty,FP=new Map,BP=/[A-Z]/g,$P=new Set(["table","tbody","thead","tfoot","tr"]),UP=new Set(["td","th"]),Aw="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function VP(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=JP(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=YP(n,t.jsx,t.jsxs)}const s={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"?Nd:lP,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=jw(s,e,void 0);return i&&typeof i!="string"?i:s.create(e,s.Fragment,{children:i||void 0},void 0)}function jw(e,t,n){if(t.type==="element")return HP(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return WP(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return KP(e,t,n);if(t.type==="mdxjsEsm")return qP(e,t);if(t.type==="root")return GP(e,t,n);if(t.type==="text")return QP(e,t)}function HP(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=Nd,e.schema=s),e.ancestors.push(t);const i=Mw(e,t.tagName,!1),o=XP(e,t);let a=zd(e,t);return $P.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!XR(l):!0})),Nw(e,o,i,t),Od(o,a),e.ancestors.pop(),e.schema=r,e.create(t,i,o,n)}function WP(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Si(e,t.position)}function qP(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Si(e,t.position)}function KP(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=Nd,e.schema=s),e.ancestors.push(t);const i=t.name===null?e.Fragment:Mw(e,t.name,!0),o=ZP(e,t),a=zd(e,t);return Nw(e,o,i,t),Od(o,a),e.ancestors.pop(),e.schema=r,e.create(t,i,o,n)}function GP(e,t,n){const r={};return Od(r,zd(e,t)),e.create(t,e.Fragment,r,n)}function QP(e,t){return t.value}function Nw(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Od(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function YP(e,t,n){return r;function r(s,i,o,a){const u=Array.isArray(o.children)?n:t;return a?u(i,o,a):u(i,o)}}function JP(e,t){return n;function n(r,s,i,o){const a=Array.isArray(i.children),l=Ld(r);return t(s,i,o,a,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function XP(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&Dd.call(t.properties,s)){const i=eA(e,s,t.properties[s]);if(i){const[o,a]=i;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&UP.has(t.tagName)?r=a:n[o]=a}}if(r){const i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function ZP(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const i=r.data.estree.body[0];i.type;const o=i.expression;o.type;const a=o.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else Si(e,t.position);else{const s=r.name;let i;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,i=e.evaluater.evaluateExpression(a.expression)}else Si(e,t.position);else i=r.value===null?!0:r.value;n[s]=i}return n}function zd(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:FP;for(;++r<t.children.length;){const i=t.children[r];let o;if(e.passKeys){const l=i.type==="element"?i.tagName:i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement"?i.name:void 0;if(l){const u=s.get(l)||0;o=l+"-"+u,s.set(l,u+1)}}const a=jw(e,i,o);a!==void 0&&n.push(a)}return n}function eA(e,t,n){const r=iP(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?KR(n):uP(n)),r.property==="style"){let s=typeof n=="object"?n:tA(e,String(n));return e.stylePropertyNameCase==="css"&&(s=nA(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?nP[r.property]||r.property:r.attribute,n]}}function tA(e,t){try{return OP(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new Qe("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=Aw+"#cannot-parse-style-attribute",s}}function Mw(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let i=-1,o;for(;++i<s.length;){const a=pp(s[i])?{type:"Identifier",name:s[i]}:{type:"Literal",value:s[i]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(i&&a.type==="Literal"),optional:!1}:a}r=o}else r=pp(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return Dd.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);Si(e)}function Si(e,t){const n=new Qe("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=Aw+"#cannot-handle-mdx-estrees-without-createevaluater",n}function nA(e){const t={};let n;for(n in e)Dd.call(e,n)&&(t[rA(n)]=e[n]);return t}function rA(e){let t=e.replace(BP,sA);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function sA(e){return"-"+e.toLowerCase()}const jl={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"]},iA={};function Fd(e,t){const n=iA,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Lw(e,r,s)}function Lw(e,t,n){if(oA(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 _p(e.children,t,n)}return Array.isArray(e)?_p(e,t,n):""}function _p(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=Lw(e[s],t,n);return r.join("")}function oA(e){return!!(e&&typeof e=="object")}const Ep=document.createElement("i");function Bd(e){const t="&"+e+";";Ep.innerHTML=t;const n=Ep.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function wt(e,t,n,r){const s=e.length;let i=0,o;if(t<0?t=-t>s?0:s+t:t=t>s?s:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);i<r.length;)o=r.slice(i,i+1e4),o.unshift(t,0),e.splice(...o),i+=1e4,t+=1e4}function Tt(e,t){return e.length>0?(wt(e,e.length,0,t),e):t}const Tp={}.hasOwnProperty;function Dw(e){const t={};let n=-1;for(;++n<e.length;)aA(t,e[n]);return t}function aA(e,t){let n;for(n in t){const s=(Tp.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let o;if(i)for(o in i){Tp.call(s,o)||(s[o]=[]);const a=i[o];lA(s[o],Array.isArray(a)?a:a?[a]:[])}}}function lA(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);wt(e,0,0,r)}function Ow(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function $t(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ze=Kn(/[A-Za-z]/),Ke=Kn(/[\dA-Za-z]/),uA=Kn(/[#-'*+\--9=?A-Z^-~]/);function da(e){return e!==null&&(e<32||e===127)}const ic=Kn(/\d/),cA=Kn(/[\dA-Fa-f]/),dA=Kn(/[!-/:-@[-`{-~]/);function Q(e){return e!==null&&e<-2}function he(e){return e!==null&&(e<0||e===32)}function re(e){return e===-2||e===-1||e===32}const Ua=Kn(/\p{P}|\p{S}/u),pr=Kn(/\s/);function Kn(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function gs(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const i=e.charCodeAt(n);let o="";if(i===37&&Ke(e.charCodeAt(n+1))&&Ke(e.charCodeAt(n+2)))s=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(o=String.fromCharCode(i));else if(i>55295&&i<57344){const a=e.charCodeAt(n+1);i<56320&&a>56319&&a<57344?(o=String.fromCharCode(i,a),s=1):o="�"}else o=String.fromCharCode(i);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+s+1,o=""),s&&(n+=s,s=0)}return t.join("")+e.slice(r)}function ae(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let i=0;return o;function o(l){return re(l)?(e.enter(n),a(l)):t(l)}function a(l){return re(l)&&i++<s?(e.consume(l),a):(e.exit(n),t(l))}}const fA={tokenize:hA};function hA(e){const t=e.attempt(this.parser.constructs.contentInitial,r,s);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),ae(e,t,"linePrefix")}function s(a){return e.enter("paragraph"),i(a)}function i(a){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return Q(a)?(e.consume(a),e.exit("chunkText"),i):(e.consume(a),o)}}const pA={tokenize:mA},Ip={tokenize:gA};function mA(e){const t=this,n=[];let r=0,s,i,o;return a;function a(w){if(r<n.length){const E=n[r];return t.containerState=E[1],e.attempt(E[0].continuation,l,u)(w)}return u(w)}function l(w){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&v();const E=t.events.length;let I=E,b;for(;I--;)if(t.events[I][0]==="exit"&&t.events[I][1].type==="chunkFlow"){b=t.events[I][1].end;break}y(r);let P=E;for(;P<t.events.length;)t.events[P][1].end={...b},P++;return wt(t.events,I+1,0,t.events.slice(E)),t.events.length=P,u(w)}return a(w)}function u(w){if(r===n.length){if(!s)return h(w);if(s.currentConstruct&&s.currentConstruct.concrete)return g(w);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Ip,f,d)(w)}function f(w){return s&&v(),y(r),h(w)}function d(w){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,g(w)}function h(w){return t.containerState={},e.attempt(Ip,p,g)(w)}function p(w){return r++,n.push([t.currentConstruct,t.containerState]),h(w)}function g(w){if(w===null){s&&v(),y(0),e.consume(w);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:i}),x(w)}function x(w){if(w===null){k(e.exit("chunkFlow"),!0),y(0),e.consume(w);return}return Q(w)?(e.consume(w),k(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(w),x)}function k(w,E){const I=t.sliceStream(w);if(E&&I.push(null),w.previous=i,i&&(i.next=w),i=w,s.defineSkip(w.start),s.write(I),t.parser.lazy[w.start.line]){let b=s.events.length;for(;b--;)if(s.events[b][1].start.offset<o&&(!s.events[b][1].end||s.events[b][1].end.offset>o))return;const P=t.events.length;let D=P,O,_;for(;D--;)if(t.events[D][0]==="exit"&&t.events[D][1].type==="chunkFlow"){if(O){_=t.events[D][1].end;break}O=!0}for(y(r),b=P;b<t.events.length;)t.events[b][1].end={..._},b++;wt(t.events,D+1,0,t.events.slice(P)),t.events.length=b}}function y(w){let E=n.length;for(;E-- >w;){const I=n[E];t.containerState=I[1],I[0].exit.call(t,e)}n.length=w}function v(){s.write([null]),i=void 0,s=void 0,t.containerState._closeFlow=void 0}}function gA(e,t,n){return ae(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function os(e){if(e===null||he(e)||pr(e))return 1;if(Ua(e))return 2}function Va(e,t,n){const r=[];let s=-1;for(;++s<e.length;){const i=e[s].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}const oc={name:"attention",resolveAll:yA,tokenize:vA};function yA(e,t){let n=-1,r,s,i,o,a,l,u,f;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const d={...e[r][1].end},h={...e[n][1].start};Rp(d,-l),Rp(h,l),o={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:h},i={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},s={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[n][1].start={...a.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Tt(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Tt(u,[["enter",s,t],["enter",o,t],["exit",o,t],["enter",i,t]]),u=Tt(u,Va(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Tt(u,[["exit",i,t],["enter",a,t],["exit",a,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,u=Tt(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):f=0,wt(e,r-1,n-r+3,u),n=r+u.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function vA(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=os(r);let i;return o;function o(l){return i=l,e.enter("attentionSequence"),a(l)}function a(l){if(l===i)return e.consume(l),a;const u=e.exit("attentionSequence"),f=os(l),d=!f||f===2&&s||n.includes(l),h=!s||s===2&&f||n.includes(r);return u._open=!!(i===42?d:d&&(s||!h)),u._close=!!(i===42?h:h&&(f||!d)),t(l)}}function Rp(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const xA={name:"autolink",tokenize:wA};function wA(e,t,n){let r=0;return s;function s(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(p){return Ze(p)?(e.consume(p),o):p===64?n(p):u(p)}function o(p){return p===43||p===45||p===46||Ke(p)?(r=1,a(p)):u(p)}function a(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||Ke(p))&&r++<32?(e.consume(p),a):(r=0,u(p))}function l(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||da(p)?n(p):(e.consume(p),l)}function u(p){return p===64?(e.consume(p),f):uA(p)?(e.consume(p),u):n(p)}function f(p){return Ke(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,f):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):h(p)}function h(p){if((p===45||Ke(p))&&r++<63){const g=p===45?h:d;return e.consume(p),g}return n(p)}}const Pi={partial:!0,tokenize:SA};function SA(e,t,n){return r;function r(i){return re(i)?ae(e,s,"linePrefix")(i):s(i)}function s(i){return i===null||Q(i)?t(i):n(i)}}const zw={continuation:{tokenize:kA},exit:CA,name:"blockQuote",tokenize:bA};function bA(e,t,n){const r=this;return s;function s(o){if(o===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),i}return n(o)}function i(o){return re(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function kA(e,t,n){const r=this;return s;function s(o){return re(o)?ae(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):i(o)}function i(o){return e.attempt(zw,t,n)(o)}}function CA(e){e.exit("blockQuote")}const Fw={name:"characterEscape",tokenize:_A};function _A(e,t,n){return r;function r(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),s}function s(i){return dA(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const Bw={name:"characterReference",tokenize:EA};function EA(e,t,n){const r=this;let s=0,i,o;return a;function a(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),l}function l(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),i=31,o=Ke,f(d))}function u(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,o=cA,f):(e.enter("characterReferenceValue"),i=7,o=ic,f(d))}function f(d){if(d===59&&s){const h=e.exit("characterReferenceValue");return o===Ke&&!Bd(r.sliceSerialize(h))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(d)&&s++<i?(e.consume(d),f):n(d)}}const Pp={partial:!0,tokenize:IA},Ap={concrete:!0,name:"codeFenced",tokenize:TA};function TA(e,t,n){const r=this,s={partial:!0,tokenize:I};let i=0,o=0,a;return l;function l(b){return u(b)}function u(b){const P=r.events[r.events.length-1];return i=P&&P[1].type==="linePrefix"?P[2].sliceSerialize(P[1],!0).length:0,a=b,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(b)}function f(b){return b===a?(o++,e.consume(b),f):o<3?n(b):(e.exit("codeFencedFenceSequence"),re(b)?ae(e,d,"whitespace")(b):d(b))}function d(b){return b===null||Q(b)?(e.exit("codeFencedFence"),r.interrupt?t(b):e.check(Pp,x,E)(b)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),h(b))}function h(b){return b===null||Q(b)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(b)):re(b)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ae(e,p,"whitespace")(b)):b===96&&b===a?n(b):(e.consume(b),h)}function p(b){return b===null||Q(b)?d(b):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(b))}function g(b){return b===null||Q(b)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(b)):b===96&&b===a?n(b):(e.consume(b),g)}function x(b){return e.attempt(s,E,k)(b)}function k(b){return e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),y}function y(b){return i>0&&re(b)?ae(e,v,"linePrefix",i+1)(b):v(b)}function v(b){return b===null||Q(b)?e.check(Pp,x,E)(b):(e.enter("codeFlowValue"),w(b))}function w(b){return b===null||Q(b)?(e.exit("codeFlowValue"),v(b)):(e.consume(b),w)}function E(b){return e.exit("codeFenced"),t(b)}function I(b,P,D){let O=0;return _;function _(R){return b.enter("lineEnding"),b.consume(R),b.exit("lineEnding"),z}function z(R){return b.enter("codeFencedFence"),re(R)?ae(b,L,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):L(R)}function L(R){return R===a?(b.enter("codeFencedFenceSequence"),W(R)):D(R)}function W(R){return R===a?(O++,b.consume(R),W):O>=o?(b.exit("codeFencedFenceSequence"),re(R)?ae(b,j,"whitespace")(R):j(R)):D(R)}function j(R){return R===null||Q(R)?(b.exit("codeFencedFence"),P(R)):D(R)}}}function IA(e,t,n){const r=this;return s;function s(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i)}function i(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const Nl={name:"codeIndented",tokenize:PA},RA={partial:!0,tokenize:AA};function PA(e,t,n){const r=this;return s;function s(u){return e.enter("codeIndented"),ae(e,i,"linePrefix",5)(u)}function i(u){const f=r.events[r.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?o(u):n(u)}function o(u){return u===null?l(u):Q(u)?e.attempt(RA,o,l)(u):(e.enter("codeFlowValue"),a(u))}function a(u){return u===null||Q(u)?(e.exit("codeFlowValue"),o(u)):(e.consume(u),a)}function l(u){return e.exit("codeIndented"),t(u)}}function AA(e,t,n){const r=this;return s;function s(o){return r.parser.lazy[r.now().line]?n(o):Q(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):ae(e,i,"linePrefix",5)(o)}function i(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):Q(o)?s(o):n(o)}}const jA={name:"codeText",previous:MA,resolve:NA,tokenize:LA};function NA(e){let t=e.length-4,n=3,r,s;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;)s===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(s=r):(r===t||e[r][1].type==="lineEnding")&&(e[s][1].type="codeTextData",r!==s+2&&(e[s][1].end=e[r-1][1].end,e.splice(s+2,r-s-2),t-=r-s-2,r=s+2),s=void 0);return e}function MA(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function LA(e,t,n){let r=0,s,i;return o;function o(d){return e.enter("codeText"),e.enter("codeTextSequence"),a(d)}function a(d){return d===96?(e.consume(d),r++,a):(e.exit("codeTextSequence"),l(d))}function l(d){return d===null?n(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),l):d===96?(i=e.enter("codeTextSequence"),s=0,f(d)):Q(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),l):(e.enter("codeTextData"),u(d))}function u(d){return d===null||d===32||d===96||Q(d)?(e.exit("codeTextData"),l(d)):(e.consume(d),u)}function f(d){return d===96?(e.consume(d),s++,f):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(d)):(i.type="codeTextData",u(d))}}class DA{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const s=n||0;this.setCursor(Math.trunc(t));const i=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return r&&Is(this.left,r),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Is(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Is(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Is(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Is(this.left,n.reverse())}}}function Is(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 $w(e){const t={};let n=-1,r,s,i,o,a,l,u;const f=new DA(e);for(;++n<f.length;){for(;n in t;)n=t[n];if(r=f.get(n),n&&r[1].type==="chunkFlow"&&f.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,i=0,i<l.length&&l[i][1].type==="lineEndingBlank"&&(i+=2),i<l.length&&l[i][1].type==="content"))for(;++i<l.length&&l[i][1].type!=="content";)l[i][1].type==="chunkText"&&(l[i][1]._isInFirstContentOfListItem=!0,i++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,OA(f,n)),n=t[n],u=!0);else if(r[1]._container){for(i=n,s=void 0;i--;)if(o=f.get(i),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(s&&(f.get(s)[1].type="lineEndingBlank"),o[1].type="lineEnding",s=i);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;s&&(r[1].end={...f.get(s)[1].start},a=f.slice(s,n),a.unshift(r),f.splice(s,n-s+1,a))}}return wt(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!u}function OA(e,t){const n=e.get(t)[1],r=e.get(t)[2];let s=t-1;const i=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],u={};let f,d,h=-1,p=n,g=0,x=0;const k=[x];for(;p;){for(;e.get(++s)[1]!==p;);i.push(s),p._tokenizer||(f=r.sliceStream(p),p.next||f.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(f),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++h<a.length;)a[h][0]==="exit"&&a[h-1][0]==="enter"&&a[h][1].type===a[h-1][1].type&&a[h][1].start.line!==a[h][1].end.line&&(x=h+1,k.push(x),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):k.pop(),h=k.length;h--;){const y=a.slice(k[h],k[h+1]),v=i.pop();l.push([v,v+y.length-1]),e.splice(v,2,y)}for(l.reverse(),h=-1;++h<l.length;)u[g+l[h][0]]=g+l[h][1],g+=l[h][1]-l[h][0]-1;return u}const zA={resolve:BA,tokenize:$A},FA={partial:!0,tokenize:UA};function BA(e){return $w(e),e}function $A(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),s(a)}function s(a){return a===null?i(a):Q(a)?e.check(FA,o,i)(a):(e.consume(a),s)}function i(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function o(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,s}}function UA(e,t,n){const r=this;return s;function s(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),ae(e,i,"linePrefix")}function i(o){if(o===null||Q(o))return n(o);const 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(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function Uw(e,t,n,r,s,i,o,a,l){const u=l||Number.POSITIVE_INFINITY;let f=0;return d;function d(y){return y===60?(e.enter(r),e.enter(s),e.enter(i),e.consume(y),e.exit(i),h):y===null||y===32||y===41||da(y)?n(y):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),x(y))}function h(y){return y===62?(e.enter(i),e.consume(y),e.exit(i),e.exit(s),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(y))}function p(y){return y===62?(e.exit("chunkString"),e.exit(a),h(y)):y===null||y===60||Q(y)?n(y):(e.consume(y),y===92?g:p)}function g(y){return y===60||y===62||y===92?(e.consume(y),p):p(y)}function x(y){return!f&&(y===null||y===41||he(y))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(y)):f<u&&y===40?(e.consume(y),f++,x):y===41?(e.consume(y),f--,x):y===null||y===32||y===40||da(y)?n(y):(e.consume(y),y===92?k:x)}function k(y){return y===40||y===41||y===92?(e.consume(y),x):x(y)}}function Vw(e,t,n,r,s,i){const o=this;let a=0,l;return u;function u(p){return e.enter(r),e.enter(s),e.consume(p),e.exit(s),e.enter(i),f}function f(p){return a>999||p===null||p===91||p===93&&!l||p===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(p):p===93?(e.exit(i),e.enter(s),e.consume(p),e.exit(s),e.exit(r),t):Q(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),f):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||Q(p)||a++>999?(e.exit("chunkString"),f(p)):(e.consume(p),l||(l=!re(p)),p===92?h:d)}function h(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function Hw(e,t,n,r,s,i){let o;return a;function a(h){return h===34||h===39||h===40?(e.enter(r),e.enter(s),e.consume(h),e.exit(s),o=h===40?41:h,l):n(h)}function l(h){return h===o?(e.enter(s),e.consume(h),e.exit(s),e.exit(r),t):(e.enter(i),u(h))}function u(h){return h===o?(e.exit(i),l(o)):h===null?n(h):Q(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),ae(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===o||h===null||Q(h)?(e.exit("chunkString"),u(h)):(e.consume(h),h===92?d:f)}function d(h){return h===o||h===92?(e.consume(h),f):f(h)}}function Js(e,t){let n;return r;function r(s){return Q(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):re(s)?ae(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const VA={name:"definition",tokenize:WA},HA={partial:!0,tokenize:qA};function WA(e,t,n){const r=this;let s;return i;function i(p){return e.enter("definition"),o(p)}function o(p){return Vw.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return s=$t(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):n(p)}function l(p){return he(p)?Js(e,u)(p):u(p)}function u(p){return Uw(e,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function f(p){return e.attempt(HA,d,d)(p)}function d(p){return re(p)?ae(e,h,"whitespace")(p):h(p)}function h(p){return p===null||Q(p)?(e.exit("definition"),r.parser.defined.push(s),t(p)):n(p)}}function qA(e,t,n){return r;function r(a){return he(a)?Js(e,s)(a):n(a)}function s(a){return Hw(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function i(a){return re(a)?ae(e,o,"whitespace")(a):o(a)}function o(a){return a===null||Q(a)?t(a):n(a)}}const KA={name:"hardBreakEscape",tokenize:GA};function GA(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),s}function s(i){return Q(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const QA={name:"headingAtx",resolve:YA,tokenize:JA};function YA(e,t){let n=e.length-2,r=3,s,i;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(s={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},i={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},wt(e,r,n-r+1,[["enter",s,t],["enter",i,t],["exit",i,t],["exit",s,t]])),e}function JA(e,t,n){let r=0;return s;function s(f){return e.enter("atxHeading"),i(f)}function i(f){return e.enter("atxHeadingSequence"),o(f)}function o(f){return f===35&&r++<6?(e.consume(f),o):f===null||he(f)?(e.exit("atxHeadingSequence"),a(f)):n(f)}function a(f){return f===35?(e.enter("atxHeadingSequence"),l(f)):f===null||Q(f)?(e.exit("atxHeading"),t(f)):re(f)?ae(e,a,"whitespace")(f):(e.enter("atxHeadingText"),u(f))}function l(f){return f===35?(e.consume(f),l):(e.exit("atxHeadingSequence"),a(f))}function u(f){return f===null||f===35||he(f)?(e.exit("atxHeadingText"),a(f)):(e.consume(f),u)}}const XA=["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"],jp=["pre","script","style","textarea"],ZA={concrete:!0,name:"htmlFlow",resolveTo:nj,tokenize:rj},ej={partial:!0,tokenize:ij},tj={partial:!0,tokenize:sj};function nj(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 rj(e,t,n){const r=this;let s,i,o,a,l;return u;function u(C){return f(C)}function f(C){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(C),d}function d(C){return C===33?(e.consume(C),h):C===47?(e.consume(C),i=!0,x):C===63?(e.consume(C),s=3,r.interrupt?t:S):Ze(C)?(e.consume(C),o=String.fromCharCode(C),k):n(C)}function h(C){return C===45?(e.consume(C),s=2,p):C===91?(e.consume(C),s=5,a=0,g):Ze(C)?(e.consume(C),s=4,r.interrupt?t:S):n(C)}function p(C){return C===45?(e.consume(C),r.interrupt?t:S):n(C)}function g(C){const ve="CDATA[";return C===ve.charCodeAt(a++)?(e.consume(C),a===ve.length?r.interrupt?t:L:g):n(C)}function x(C){return Ze(C)?(e.consume(C),o=String.fromCharCode(C),k):n(C)}function k(C){if(C===null||C===47||C===62||he(C)){const ve=C===47,Re=o.toLowerCase();return!ve&&!i&&jp.includes(Re)?(s=1,r.interrupt?t(C):L(C)):XA.includes(o.toLowerCase())?(s=6,ve?(e.consume(C),y):r.interrupt?t(C):L(C)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(C):i?v(C):w(C))}return C===45||Ke(C)?(e.consume(C),o+=String.fromCharCode(C),k):n(C)}function y(C){return C===62?(e.consume(C),r.interrupt?t:L):n(C)}function v(C){return re(C)?(e.consume(C),v):_(C)}function w(C){return C===47?(e.consume(C),_):C===58||C===95||Ze(C)?(e.consume(C),E):re(C)?(e.consume(C),w):_(C)}function E(C){return C===45||C===46||C===58||C===95||Ke(C)?(e.consume(C),E):I(C)}function I(C){return C===61?(e.consume(C),b):re(C)?(e.consume(C),I):w(C)}function b(C){return C===null||C===60||C===61||C===62||C===96?n(C):C===34||C===39?(e.consume(C),l=C,P):re(C)?(e.consume(C),b):D(C)}function P(C){return C===l?(e.consume(C),l=null,O):C===null||Q(C)?n(C):(e.consume(C),P)}function D(C){return C===null||C===34||C===39||C===47||C===60||C===61||C===62||C===96||he(C)?I(C):(e.consume(C),D)}function O(C){return C===47||C===62||re(C)?w(C):n(C)}function _(C){return C===62?(e.consume(C),z):n(C)}function z(C){return C===null||Q(C)?L(C):re(C)?(e.consume(C),z):n(C)}function L(C){return C===45&&s===2?(e.consume(C),B):C===60&&s===1?(e.consume(C),K):C===62&&s===4?(e.consume(C),G):C===63&&s===3?(e.consume(C),S):C===93&&s===5?(e.consume(C),N):Q(C)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(ej,Y,W)(C)):C===null||Q(C)?(e.exit("htmlFlowData"),W(C)):(e.consume(C),L)}function W(C){return e.check(tj,j,Y)(C)}function j(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),R}function R(C){return C===null||Q(C)?W(C):(e.enter("htmlFlowData"),L(C))}function B(C){return C===45?(e.consume(C),S):L(C)}function K(C){return C===47?(e.consume(C),o="",A):L(C)}function A(C){if(C===62){const ve=o.toLowerCase();return jp.includes(ve)?(e.consume(C),G):L(C)}return Ze(C)&&o.length<8?(e.consume(C),o+=String.fromCharCode(C),A):L(C)}function N(C){return C===93?(e.consume(C),S):L(C)}function S(C){return C===62?(e.consume(C),G):C===45&&s===2?(e.consume(C),S):L(C)}function G(C){return C===null||Q(C)?(e.exit("htmlFlowData"),Y(C)):(e.consume(C),G)}function Y(C){return e.exit("htmlFlow"),t(C)}}function sj(e,t,n){const r=this;return s;function s(o){return Q(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):n(o)}function i(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function ij(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(Pi,t,n)}}const oj={name:"htmlText",tokenize:aj};function aj(e,t,n){const r=this;let s,i,o;return a;function a(S){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(S),l}function l(S){return S===33?(e.consume(S),u):S===47?(e.consume(S),I):S===63?(e.consume(S),w):Ze(S)?(e.consume(S),D):n(S)}function u(S){return S===45?(e.consume(S),f):S===91?(e.consume(S),i=0,g):Ze(S)?(e.consume(S),v):n(S)}function f(S){return S===45?(e.consume(S),p):n(S)}function d(S){return S===null?n(S):S===45?(e.consume(S),h):Q(S)?(o=d,K(S)):(e.consume(S),d)}function h(S){return S===45?(e.consume(S),p):d(S)}function p(S){return S===62?B(S):S===45?h(S):d(S)}function g(S){const G="CDATA[";return S===G.charCodeAt(i++)?(e.consume(S),i===G.length?x:g):n(S)}function x(S){return S===null?n(S):S===93?(e.consume(S),k):Q(S)?(o=x,K(S)):(e.consume(S),x)}function k(S){return S===93?(e.consume(S),y):x(S)}function y(S){return S===62?B(S):S===93?(e.consume(S),y):x(S)}function v(S){return S===null||S===62?B(S):Q(S)?(o=v,K(S)):(e.consume(S),v)}function w(S){return S===null?n(S):S===63?(e.consume(S),E):Q(S)?(o=w,K(S)):(e.consume(S),w)}function E(S){return S===62?B(S):w(S)}function I(S){return Ze(S)?(e.consume(S),b):n(S)}function b(S){return S===45||Ke(S)?(e.consume(S),b):P(S)}function P(S){return Q(S)?(o=P,K(S)):re(S)?(e.consume(S),P):B(S)}function D(S){return S===45||Ke(S)?(e.consume(S),D):S===47||S===62||he(S)?O(S):n(S)}function O(S){return S===47?(e.consume(S),B):S===58||S===95||Ze(S)?(e.consume(S),_):Q(S)?(o=O,K(S)):re(S)?(e.consume(S),O):B(S)}function _(S){return S===45||S===46||S===58||S===95||Ke(S)?(e.consume(S),_):z(S)}function z(S){return S===61?(e.consume(S),L):Q(S)?(o=z,K(S)):re(S)?(e.consume(S),z):O(S)}function L(S){return S===null||S===60||S===61||S===62||S===96?n(S):S===34||S===39?(e.consume(S),s=S,W):Q(S)?(o=L,K(S)):re(S)?(e.consume(S),L):(e.consume(S),j)}function W(S){return S===s?(e.consume(S),s=void 0,R):S===null?n(S):Q(S)?(o=W,K(S)):(e.consume(S),W)}function j(S){return S===null||S===34||S===39||S===60||S===61||S===96?n(S):S===47||S===62||he(S)?O(S):(e.consume(S),j)}function R(S){return S===47||S===62||he(S)?O(S):n(S)}function B(S){return S===62?(e.consume(S),e.exit("htmlTextData"),e.exit("htmlText"),t):n(S)}function K(S){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(S),e.exit("lineEnding"),A}function A(S){return re(S)?ae(e,N,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(S):N(S)}function N(S){return e.enter("htmlTextData"),o(S)}}const $d={name:"labelEnd",resolveAll:dj,resolveTo:fj,tokenize:hj},lj={tokenize:pj},uj={tokenize:mj},cj={tokenize:gj};function dj(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const s=r.type==="labelImage"?4:2;r.type="data",t+=s}}return e.length!==n.length&&wt(e,0,e.length,n),e}function fj(e,t){let n=e.length,r=0,s,i,o,a;for(;n--;)if(s=e[n][1],i){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;e[n][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(i=n,s.type!=="labelLink")){r=2;break}}else s.type==="labelEnd"&&(o=n);const l={type:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[i][1].start},end:{...e[o][1].end}},f={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[o-2][1].start}};return a=[["enter",l,t],["enter",u,t]],a=Tt(a,e.slice(i+1,i+r+3)),a=Tt(a,[["enter",f,t]]),a=Tt(a,Va(t.parser.constructs.insideSpan.null,e.slice(i+r+4,o-3),t)),a=Tt(a,[["exit",f,t],e[o-2],e[o-1],["exit",u,t]]),a=Tt(a,e.slice(o+1)),a=Tt(a,[["exit",l,t]]),wt(e,i,e.length,a),e}function hj(e,t,n){const r=this;let s=r.events.length,i,o;for(;s--;)if((r.events[s][1].type==="labelImage"||r.events[s][1].type==="labelLink")&&!r.events[s][1]._balanced){i=r.events[s][1];break}return a;function a(h){return i?i._inactive?d(h):(o=r.parser.defined.includes($t(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelEnd"),l):n(h)}function l(h){return h===40?e.attempt(lj,f,o?f:d)(h):h===91?e.attempt(uj,f,o?u:d)(h):o?f(h):d(h)}function u(h){return e.attempt(cj,f,d)(h)}function f(h){return t(h)}function d(h){return i._balanced=!0,n(h)}}function pj(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),s}function s(d){return he(d)?Js(e,i)(d):i(d)}function i(d){return d===41?f(d):Uw(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function o(d){return he(d)?Js(e,l)(d):f(d)}function a(d){return n(d)}function l(d){return d===34||d===39||d===40?Hw(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):f(d)}function u(d){return he(d)?Js(e,f)(d):f(d)}function f(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function mj(e,t,n){const r=this;return s;function s(a){return Vw.call(r,e,i,o,"reference","referenceMarker","referenceString")(a)}function i(a){return r.parser.defined.includes($t(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function gj(e,t,n){return r;function r(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),s}function s(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):n(i)}}const yj={name:"labelStartImage",resolveAll:$d.resolveAll,tokenize:vj};function vj(e,t,n){const r=this;return s;function s(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),i}function i(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const xj={name:"labelStartLink",resolveAll:$d.resolveAll,tokenize:wj};function wj(e,t,n){const r=this;return s;function s(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),i}function i(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const Ml={name:"lineEnding",tokenize:Sj};function Sj(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),ae(e,t,"linePrefix")}}const Co={name:"thematicBreak",tokenize:bj};function bj(e,t,n){let r=0,s;return i;function i(u){return e.enter("thematicBreak"),o(u)}function o(u){return s=u,a(u)}function a(u){return u===s?(e.enter("thematicBreakSequence"),l(u)):r>=3&&(u===null||Q(u))?(e.exit("thematicBreak"),t(u)):n(u)}function l(u){return u===s?(e.consume(u),r++,l):(e.exit("thematicBreakSequence"),re(u)?ae(e,a,"whitespace")(u):a(u))}}const ot={continuation:{tokenize:Ej},exit:Ij,name:"list",tokenize:_j},kj={partial:!0,tokenize:Rj},Cj={partial:!0,tokenize:Tj};function _j(e,t,n){const r=this,s=r.events[r.events.length-1];let i=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,o=0;return a;function a(p){const g=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:ic(p)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(Co,n,u)(p):u(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(p)}return n(p)}function l(p){return ic(p)&&++o<10?(e.consume(p),l):(!r.interrupt||o<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),u(p)):n(p)}function u(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(Pi,r.interrupt?n:f,e.attempt(kj,h,d))}function f(p){return r.containerState.initialBlankLine=!0,i++,h(p)}function d(p){return re(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),h):n(p)}function h(p){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function Ej(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Pi,s,i);function s(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ae(e,t,"listItemIndent",r.containerState.size+1)(a)}function i(a){return r.containerState.furtherBlankLines||!re(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Cj,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,ae(e,e.attempt(ot,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function Tj(e,t,n){const r=this;return ae(e,s,"listItemIndent",r.containerState.size+1);function s(i){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(i):n(i)}}function Ij(e){e.exit(this.containerState.type)}function Rj(e,t,n){const r=this;return ae(e,s,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(i){const o=r.events[r.events.length-1];return!re(i)&&o&&o[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const Np={name:"setextUnderline",resolveTo:Pj,tokenize:Aj};function Pj(e,t){let n=e.length,r,s,i;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(s=n)}else e[n][1].type==="content"&&e.splice(n,1),!i&&e[n][1].type==="definition"&&(i=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",i?(e.splice(s,0,["enter",o,t]),e.splice(i+1,0,["exit",e[r][1],t]),e[r][1].end={...e[i][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function Aj(e,t,n){const r=this;let s;return i;function i(u){let f=r.events.length,d;for(;f--;)if(r.events[f][1].type!=="lineEnding"&&r.events[f][1].type!=="linePrefix"&&r.events[f][1].type!=="content"){d=r.events[f][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),s=u,o(u)):n(u)}function o(u){return e.enter("setextHeadingLineSequence"),a(u)}function a(u){return u===s?(e.consume(u),a):(e.exit("setextHeadingLineSequence"),re(u)?ae(e,l,"lineSuffix")(u):l(u))}function l(u){return u===null||Q(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const jj={tokenize:Nj};function Nj(e){const t=this,n=e.attempt(Pi,r,e.attempt(this.parser.constructs.flowInitial,s,ae(e,e.attempt(this.parser.constructs.flow,s,e.attempt(zA,s)),"linePrefix")));return n;function r(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function s(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Mj={resolveAll:qw()},Lj=Ww("string"),Dj=Ww("text");function Ww(e){return{resolveAll:qw(e==="text"?Oj:void 0),tokenize:t};function t(n){const r=this,s=this.parser.constructs[e],i=n.attempt(s,o,a);return o;function o(f){return u(f)?i(f):a(f)}function a(f){if(f===null){n.consume(f);return}return n.enter("data"),n.consume(f),l}function l(f){return u(f)?(n.exit("data"),i(f)):(n.consume(f),l)}function u(f){if(f===null)return!0;const d=s[f];let h=-1;if(d)for(;++h<d.length;){const p=d[h];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function qw(e){return t;function t(n,r){let s=-1,i;for(;++s<=n.length;)i===void 0?n[s]&&n[s][1].type==="data"&&(i=s,s++):(!n[s]||n[s][1].type!=="data")&&(s!==i+2&&(n[i][1].end=n[s-1][1].end,n.splice(i+2,s-i-2),s=i+2),i=void 0);return e?e(n,r):n}}function Oj(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],s=t.sliceStream(r);let i=s.length,o=-1,a=0,l;for(;i--;){const u=s[i];if(typeof u=="string"){for(o=u.length;u.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(u===-2)l=!0,a++;else if(u!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const u={type:n===e.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?o:r.start._bufferIndex+o,_index:r.start._index+i,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const zj={42:ot,43:ot,45:ot,48:ot,49:ot,50:ot,51:ot,52:ot,53:ot,54:ot,55:ot,56:ot,57:ot,62:zw},Fj={91:VA},Bj={[-2]:Nl,[-1]:Nl,32:Nl},$j={35:QA,42:Co,45:[Np,Co],60:ZA,61:Np,95:Co,96:Ap,126:Ap},Uj={38:Bw,92:Fw},Vj={[-5]:Ml,[-4]:Ml,[-3]:Ml,33:yj,38:Bw,42:oc,60:[xA,oj],91:xj,92:[KA,Fw],93:$d,95:oc,96:jA},Hj={null:[oc,Mj]},Wj={null:[42,95]},qj={null:[]},Kj=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Wj,contentInitial:Fj,disable:qj,document:zj,flow:$j,flowInitial:Bj,insideSpan:Hj,string:Uj,text:Vj},Symbol.toStringTag,{value:"Module"}));function Gj(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const s={},i=[];let o=[],a=[];const l={attempt:P(I),check:P(b),consume:v,enter:w,exit:E,interrupt:P(b,{interrupt:!0})},u={code:null,containerState:{},defineSkip:x,events:[],now:g,parser:e,previous:null,sliceSerialize:h,sliceStream:p,write:d};let f=t.tokenize.call(u,l);return t.resolveAll&&i.push(t),u;function d(z){return o=Tt(o,z),k(),o[o.length-1]!==null?[]:(D(t,0),u.events=Va(i,u.events,u),u.events)}function h(z,L){return Yj(p(z),L)}function p(z){return Qj(o,z)}function g(){const{_bufferIndex:z,_index:L,line:W,column:j,offset:R}=r;return{_bufferIndex:z,_index:L,line:W,column:j,offset:R}}function x(z){s[z.line]=z.column,_()}function k(){let z;for(;r._index<o.length;){const L=o[r._index];if(typeof L=="string")for(z=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===z&&r._bufferIndex<L.length;)y(L.charCodeAt(r._bufferIndex));else y(L)}}function y(z){f=f(z)}function v(z){Q(z)?(r.line++,r.column=1,r.offset+=z===-3?2:1,_()):z!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=z}function w(z,L){const W=L||{};return W.type=z,W.start=g(),u.events.push(["enter",W,u]),a.push(W),W}function E(z){const L=a.pop();return L.end=g(),u.events.push(["exit",L,u]),L}function I(z,L){D(z,L.from)}function b(z,L){L.restore()}function P(z,L){return W;function W(j,R,B){let K,A,N,S;return Array.isArray(j)?Y(j):"tokenize"in j?Y([j]):G(j);function G(ue){return De;function De(rt){const Ne=rt!==null&&ue[rt],Ye=rt!==null&&ue.null,st=[...Array.isArray(Ne)?Ne:Ne?[Ne]:[],...Array.isArray(Ye)?Ye:Ye?[Ye]:[]];return Y(st)(rt)}}function Y(ue){return K=ue,A=0,ue.length===0?B:C(ue[A])}function C(ue){return De;function De(rt){return S=O(),N=ue,ue.partial||(u.currentConstruct=ue),ue.name&&u.parser.constructs.disable.null.includes(ue.name)?Re():ue.tokenize.call(L?Object.assign(Object.create(u),L):u,l,ve,Re)(rt)}}function ve(ue){return z(N,S),R}function Re(ue){return S.restore(),++A<K.length?C(K[A]):B}}}function D(z,L){z.resolveAll&&!i.includes(z)&&i.push(z),z.resolve&&wt(u.events,L,u.events.length-L,z.resolve(u.events.slice(L),u)),z.resolveTo&&(u.events=z.resolveTo(u.events,u))}function O(){const z=g(),L=u.previous,W=u.currentConstruct,j=u.events.length,R=Array.from(a);return{from:j,restore:B};function B(){r=z,u.previous=L,u.currentConstruct=W,u.events.length=j,a=R,_()}}function _(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function Qj(e,t){const n=t.start._index,r=t.start._bufferIndex,s=t.end._index,i=t.end._bufferIndex;let o;if(n===s)o=[e[n].slice(r,i)];else{if(o=e.slice(n,s),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}i>0&&o.push(e[s].slice(0,i))}return o}function Yj(e,t){let n=-1;const r=[];let s;for(;++n<e.length;){const i=e[n];let o;if(typeof i=="string")o=i;else switch(i){case-5:{o="\r";break}case-4:{o=`
50
- `;break}case-3:{o=`\r
51
- `;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&s)continue;o=" ";break}default:o=String.fromCharCode(i)}s=i===-2,r.push(o)}return r.join("")}function Jj(e){const r={constructs:Dw([Kj,...(e||{}).extensions||[]]),content:s(fA),defined:[],document:s(pA),flow:s(jj),lazy:{},string:s(Lj),text:s(Dj)};return r;function s(i){return o;function o(a){return Gj(r,i,a)}}}function Xj(e){for(;!$w(e););return e}const Mp=/[\0\t\n\r]/g;function Zj(){let e=1,t="",n=!0,r;return s;function s(i,o,a){const l=[];let u,f,d,h,p;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(o||void 0).decode(i)),d=0,t="",n&&(i.charCodeAt(0)===65279&&d++,n=void 0);d<i.length;){if(Mp.lastIndex=d,u=Mp.exec(i),h=u&&u.index!==void 0?u.index:i.length,p=i.charCodeAt(h),!u){t=i.slice(d);break}if(p===10&&d===h&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),d<h&&(l.push(i.slice(d,h)),e+=h-d),p){case 0:{l.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,l.push(-2);e++<f;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}d=h+1}return a&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const eN=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function tN(e){return e.replace(eN,nN)}function nN(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),i=s===120||s===88;return Ow(n.slice(i?2:1),i?16:10)}return Bd(n)||e}const Kw={}.hasOwnProperty;function rN(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),sN(n)(Xj(Jj(n).document().write(Zj()(e,t,!0))))}function sN(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(ne),autolinkProtocol:O,autolinkEmail:O,atxHeading:i(kr),blockQuote:i(Ye),characterEscape:O,characterReference:O,codeFenced:i(st),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:i(st,o),codeText:i(Ce,o),codeTextData:O,data:O,codeFlowValue:O,definition:i(Ga),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:i(ji),hardBreakEscape:i(Cr),hardBreakTrailing:i(Cr),htmlFlow:i(H,o),htmlFlowData:O,htmlText:i(H,o),htmlTextData:O,image:i(ee),label:o,link:i(ne),listItem:i(sn),listItemValue:h,listOrdered:i(Ee,d),listUnordered:i(Ee),paragraph:i(it),reference:C,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:i(kr),strong:i(Wt),thematicBreak:i(Ni)},exit:{atxHeading:l(),atxHeadingSequence:I,autolink:l(),autolinkEmail:Ne,autolinkProtocol:rt,blockQuote:l(),characterEscapeValue:_,characterReferenceMarkerHexadecimal:Re,characterReferenceMarkerNumeric:Re,characterReferenceValue:ue,characterReference:De,codeFenced:l(k),codeFencedFence:x,codeFencedFenceInfo:p,codeFencedFenceMeta:g,codeFlowValue:_,codeIndented:l(y),codeText:l(R),codeTextData:_,data:_,definition:l(),definitionDestinationString:E,definitionLabelString:v,definitionTitleString:w,emphasis:l(),hardBreakEscape:l(L),hardBreakTrailing:l(L),htmlFlow:l(W),htmlFlowData:_,htmlText:l(j),htmlTextData:_,image:l(K),label:N,labelText:A,lineEnding:z,link:l(B),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ve,resourceDestinationString:S,resourceTitleString:G,resource:Y,setextHeading:l(D),setextHeadingLineSequence:P,setextHeadingText:b,strong:l(),thematicBreak:l()}};Gw(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(M){let V={type:"root",children:[]};const X={stack:[V],tokenStack:[],config:t,enter:a,exit:u,buffer:o,resume:f,data:n},oe=[];let de=-1;for(;++de<M.length;)if(M[de][1].type==="listOrdered"||M[de][1].type==="listUnordered")if(M[de][0]==="enter")oe.push(de);else{const Nt=oe.pop();de=s(M,Nt,de)}for(de=-1;++de<M.length;){const Nt=t[M[de][0]];Kw.call(Nt,M[de][1].type)&&Nt[M[de][1].type].call(Object.assign({sliceSerialize:M[de][2].sliceSerialize},X),M[de][1])}if(X.tokenStack.length>0){const Nt=X.tokenStack[X.tokenStack.length-1];(Nt[1]||Lp).call(X,void 0,Nt[0])}for(V.position={start:bn(M.length>0?M[0][1].start:{line:1,column:1,offset:0}),end:bn(M.length>0?M[M.length-2][1].end:{line:1,column:1,offset:0})},de=-1;++de<t.transforms.length;)V=t.transforms[de](V)||V;return V}function s(M,V,X){let oe=V-1,de=-1,Nt=!1,Gn,on,ys,vs;for(;++oe<=X;){const mt=M[oe];switch(mt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{mt[0]==="enter"?de++:de--,vs=void 0;break}case"lineEndingBlank":{mt[0]==="enter"&&(Gn&&!vs&&!de&&!ys&&(ys=oe),vs=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:vs=void 0}if(!de&&mt[0]==="enter"&&mt[1].type==="listItemPrefix"||de===-1&&mt[0]==="exit"&&(mt[1].type==="listUnordered"||mt[1].type==="listOrdered")){if(Gn){let _r=oe;for(on=void 0;_r--;){const an=M[_r];if(an[1].type==="lineEnding"||an[1].type==="lineEndingBlank"){if(an[0]==="exit")continue;on&&(M[on][1].type="lineEndingBlank",Nt=!0),an[1].type="lineEnding",on=_r}else if(!(an[1].type==="linePrefix"||an[1].type==="blockQuotePrefix"||an[1].type==="blockQuotePrefixWhitespace"||an[1].type==="blockQuoteMarker"||an[1].type==="listItemIndent"))break}ys&&(!on||ys<on)&&(Gn._spread=!0),Gn.end=Object.assign({},on?M[on][1].start:mt[1].end),M.splice(on||oe,0,["exit",Gn,mt[2]]),oe++,X++}if(mt[1].type==="listItemPrefix"){const _r={type:"listItem",_spread:!1,start:Object.assign({},mt[1].start),end:void 0};Gn=_r,M.splice(oe,0,["enter",_r,mt[2]]),oe++,X++,ys=void 0,vs=!0}}}return M[V][1]._spread=Nt,X}function i(M,V){return X;function X(oe){a.call(this,M(oe),oe),V&&V.call(this,oe)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(M,V,X){this.stack[this.stack.length-1].children.push(M),this.stack.push(M),this.tokenStack.push([V,X||void 0]),M.position={start:bn(V.start),end:void 0}}function l(M){return V;function V(X){M&&M.call(this,X),u.call(this,X)}}function u(M,V){const X=this.stack.pop(),oe=this.tokenStack.pop();if(oe)oe[0].type!==M.type&&(V?V.call(this,M,oe[0]):(oe[1]||Lp).call(this,M,oe[0]));else throw new Error("Cannot close `"+M.type+"` ("+Ys({start:M.start,end:M.end})+"): it’s not open");X.position.end=bn(M.end)}function f(){return Fd(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function h(M){if(this.data.expectingFirstListItemValue){const V=this.stack[this.stack.length-2];V.start=Number.parseInt(this.sliceSerialize(M),10),this.data.expectingFirstListItemValue=void 0}}function p(){const M=this.resume(),V=this.stack[this.stack.length-1];V.lang=M}function g(){const M=this.resume(),V=this.stack[this.stack.length-1];V.meta=M}function x(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function k(){const M=this.resume(),V=this.stack[this.stack.length-1];V.value=M.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const M=this.resume(),V=this.stack[this.stack.length-1];V.value=M.replace(/(\r?\n|\r)$/g,"")}function v(M){const V=this.resume(),X=this.stack[this.stack.length-1];X.label=V,X.identifier=$t(this.sliceSerialize(M)).toLowerCase()}function w(){const M=this.resume(),V=this.stack[this.stack.length-1];V.title=M}function E(){const M=this.resume(),V=this.stack[this.stack.length-1];V.url=M}function I(M){const V=this.stack[this.stack.length-1];if(!V.depth){const X=this.sliceSerialize(M).length;V.depth=X}}function b(){this.data.setextHeadingSlurpLineEnding=!0}function P(M){const V=this.stack[this.stack.length-1];V.depth=this.sliceSerialize(M).codePointAt(0)===61?1:2}function D(){this.data.setextHeadingSlurpLineEnding=void 0}function O(M){const X=this.stack[this.stack.length-1].children;let oe=X[X.length-1];(!oe||oe.type!=="text")&&(oe=Qa(),oe.position={start:bn(M.start),end:void 0},X.push(oe)),this.stack.push(oe)}function _(M){const V=this.stack.pop();V.value+=this.sliceSerialize(M),V.position.end=bn(M.end)}function z(M){const V=this.stack[this.stack.length-1];if(this.data.atHardBreak){const X=V.children[V.children.length-1];X.position.end=bn(M.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(V.type)&&(O.call(this,M),_.call(this,M))}function L(){this.data.atHardBreak=!0}function W(){const M=this.resume(),V=this.stack[this.stack.length-1];V.value=M}function j(){const M=this.resume(),V=this.stack[this.stack.length-1];V.value=M}function R(){const M=this.resume(),V=this.stack[this.stack.length-1];V.value=M}function B(){const M=this.stack[this.stack.length-1];if(this.data.inReference){const V=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=V,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function K(){const M=this.stack[this.stack.length-1];if(this.data.inReference){const V=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=V,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function A(M){const V=this.sliceSerialize(M),X=this.stack[this.stack.length-2];X.label=tN(V),X.identifier=$t(V).toLowerCase()}function N(){const M=this.stack[this.stack.length-1],V=this.resume(),X=this.stack[this.stack.length-1];if(this.data.inReference=!0,X.type==="link"){const oe=M.children;X.children=oe}else X.alt=V}function S(){const M=this.resume(),V=this.stack[this.stack.length-1];V.url=M}function G(){const M=this.resume(),V=this.stack[this.stack.length-1];V.title=M}function Y(){this.data.inReference=void 0}function C(){this.data.referenceType="collapsed"}function ve(M){const V=this.resume(),X=this.stack[this.stack.length-1];X.label=V,X.identifier=$t(this.sliceSerialize(M)).toLowerCase(),this.data.referenceType="full"}function Re(M){this.data.characterReferenceType=M.type}function ue(M){const V=this.sliceSerialize(M),X=this.data.characterReferenceType;let oe;X?(oe=Ow(V,X==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):oe=Bd(V);const de=this.stack[this.stack.length-1];de.value+=oe}function De(M){const V=this.stack.pop();V.position.end=bn(M.end)}function rt(M){_.call(this,M);const V=this.stack[this.stack.length-1];V.url=this.sliceSerialize(M)}function Ne(M){_.call(this,M);const V=this.stack[this.stack.length-1];V.url="mailto:"+this.sliceSerialize(M)}function Ye(){return{type:"blockquote",children:[]}}function st(){return{type:"code",lang:null,meta:null,value:""}}function Ce(){return{type:"inlineCode",value:""}}function Ga(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ji(){return{type:"emphasis",children:[]}}function kr(){return{type:"heading",depth:0,children:[]}}function Cr(){return{type:"break"}}function H(){return{type:"html",value:""}}function ee(){return{type:"image",title:null,url:"",alt:null}}function ne(){return{type:"link",title:null,url:"",children:[]}}function Ee(M){return{type:"list",ordered:M.type==="listOrdered",start:null,spread:M._spread,children:[]}}function sn(M){return{type:"listItem",spread:M._spread,checked:null,children:[]}}function it(){return{type:"paragraph",children:[]}}function Wt(){return{type:"strong",children:[]}}function Qa(){return{type:"text",value:""}}function Ni(){return{type:"thematicBreak"}}}function bn(e){return{line:e.line,column:e.column,offset:e.offset}}function Gw(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Gw(e,r):iN(e,r)}}function iN(e,t){let n;for(n in t)if(Kw.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function Lp(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Ys({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Ys({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Ys({start:t.start,end:t.end})+") is still open")}function oN(e){const t=this;t.parser=n;function n(r){return rN(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function aN(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function lN(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
52
- `}]}function uN(e,t){const n=t.value?t.value+`
53
- `:"",r={},s=t.lang?t.lang.split(/\s+/):[];s.length>0&&(r.className=["language-"+s[0]]);let i={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(i.data={meta:t.meta}),e.patch(t,i),i=e.applyData(t,i),i={type:"element",tagName:"pre",properties:{},children:[i]},e.patch(t,i),i}function cN(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function dN(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function fN(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),s=gs(r.toLowerCase()),i=e.footnoteOrder.indexOf(r);let o,a=e.footnoteCounts.get(r);a===void 0?(a=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=i+1,a+=1,e.footnoteCounts.set(r,a);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+s,id:n+"fnref-"+s+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};e.patch(t,l);const u={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,u),e.applyData(t,u)}function hN(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function pN(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Qw(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const s=e.all(t),i=s[0];i&&i.type==="text"?i.value="["+i.value:s.unshift({type:"text",value:"["});const o=s[s.length-1];return o&&o.type==="text"?o.value+=r:s.push({type:"text",value:r}),s}function mN(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Qw(e,t);const s={src:gs(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(s.title=r.title);const i={type:"element",tagName:"img",properties:s,children:[]};return e.patch(t,i),e.applyData(t,i)}function gN(e,t){const n={src:gs(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function yN(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function vN(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Qw(e,t);const s={href:gs(r.url||"")};r.title!==null&&r.title!==void 0&&(s.title=r.title);const i={type:"element",tagName:"a",properties:s,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function xN(e,t){const n={href:gs(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function wN(e,t,n){const r=e.all(t),s=n?SN(n):Yw(t),i={},o=[];if(typeof t.checked=="boolean"){const f=r[0];let d;f&&f.type==="element"&&f.tagName==="p"?d=f:(d={type:"element",tagName:"p",properties:{},children:[]},r.unshift(d)),d.children.length>0&&d.children.unshift({type:"text",value:" "}),d.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),i.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const f=r[a];(s||a!==0||f.type!=="element"||f.tagName!=="p")&&o.push({type:"text",value:`
54
- `}),f.type==="element"&&f.tagName==="p"&&!s?o.push(...f.children):o.push(f)}const l=r[r.length-1];l&&(s||l.type!=="element"||l.tagName!=="p")&&o.push({type:"text",value:`
55
- `});const u={type:"element",tagName:"li",properties:i,children:o};return e.patch(t,u),e.applyData(t,u)}function SN(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=Yw(n[r])}return t}function Yw(e){const t=e.spread;return t??e.children.length>1}function bN(e,t){const n={},r=e.all(t);let s=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++s<r.length;){const o=r[s];if(o.type==="element"&&o.tagName==="li"&&o.properties&&Array.isArray(o.properties.className)&&o.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const i={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,i),e.applyData(t,i)}function kN(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function CN(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function _N(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function EN(e,t){const n=e.all(t),r=n.shift(),s=[];if(r){const o={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],o),s.push(o)}if(n.length>0){const o={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=Ld(t.children[1]),l=Rw(t.children[t.children.length-1]);a&&l&&(o.position={start:a,end:l}),s.push(o)}const i={type:"element",tagName:"table",properties:{},children:e.wrap(s,!0)};return e.patch(t,i),e.applyData(t,i)}function TN(e,t,n){const r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?"th":"td",o=n&&n.type==="table"?n.align:void 0,a=o?o.length:t.children.length;let l=-1;const u=[];for(;++l<a;){const d=t.children[l],h={},p=o?o[l]:void 0;p&&(h.align=p);let g={type:"element",tagName:i,properties:h,children:[]};d&&(g.children=e.all(d),e.patch(d,g),g=e.applyData(d,g)),u.push(g)}const f={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,f),e.applyData(t,f)}function IN(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const Dp=9,Op=32;function RN(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),s=0;const i=[];for(;r;)i.push(zp(t.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(t);return i.push(zp(t.slice(s),s>0,!1)),i.join("")}function zp(e,t,n){let r=0,s=e.length;if(t){let i=e.codePointAt(r);for(;i===Dp||i===Op;)r++,i=e.codePointAt(r)}if(n){let i=e.codePointAt(s-1);for(;i===Dp||i===Op;)s--,i=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}function PN(e,t){const n={type:"text",value:RN(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function AN(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const jN={blockquote:aN,break:lN,code:uN,delete:cN,emphasis:dN,footnoteReference:fN,heading:hN,html:pN,imageReference:mN,image:gN,inlineCode:yN,linkReference:vN,link:xN,listItem:wN,list:bN,paragraph:kN,root:CN,strong:_N,table:EN,tableCell:IN,tableRow:TN,text:PN,thematicBreak:AN,toml:ro,yaml:ro,definition:ro,footnoteDefinition:ro};function ro(){}const Jw=-1,Ha=0,Xs=1,fa=2,Ud=3,Vd=4,Hd=5,Wd=6,Xw=7,Zw=8,NN=typeof self=="object"?self:globalThis,Fp=(e,t)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+e)}return new NN[e](t)},MN=(e,t)=>{const n=(s,i)=>(e.set(i,s),s),r=s=>{if(e.has(s))return e.get(s);const[i,o]=t[s];switch(i){case Ha:case Jw:return n(o,s);case Xs:{const a=n([],s);for(const l of o)a.push(r(l));return a}case fa:{const a=n({},s);for(const[l,u]of o)a[r(l)]=r(u);return a}case Ud:return n(new Date(o),s);case Vd:{const{source:a,flags:l}=o;return n(new RegExp(a,l),s)}case Hd:{const a=n(new Map,s);for(const[l,u]of o)a.set(r(l),r(u));return a}case Wd:{const a=n(new Set,s);for(const l of o)a.add(r(l));return a}case Xw:{const{name:a,message:l}=o;return n(Fp(a,l),s)}case Zw:return n(BigInt(o),s);case"BigInt":return n(Object(BigInt(o)),s);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{const{buffer:a}=new Uint8Array(o);return n(new DataView(a),o)}}return n(Fp(i,o),s)};return r},Bp=e=>MN(new Map,e)(0),Tr="",{toString:LN}={},{keys:DN}=Object,Rs=e=>{const t=typeof e;if(t!=="object"||!e)return[Ha,t];const n=LN.call(e).slice(8,-1);switch(n){case"Array":return[Xs,Tr];case"Object":return[fa,Tr];case"Date":return[Ud,Tr];case"RegExp":return[Vd,Tr];case"Map":return[Hd,Tr];case"Set":return[Wd,Tr];case"DataView":return[Xs,n]}return n.includes("Array")?[Xs,n]:n.includes("Error")?[Xw,n]:[fa,n]},so=([e,t])=>e===Ha&&(t==="function"||t==="symbol"),ON=(e,t,n,r)=>{const s=(o,a)=>{const l=r.push(o)-1;return n.set(a,l),l},i=o=>{if(n.has(o))return n.get(o);let[a,l]=Rs(o);switch(a){case Ha:{let f=o;switch(l){case"bigint":a=Zw,f=o.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);f=null;break;case"undefined":return s([Jw],o)}return s([a,f],o)}case Xs:{if(l){let h=o;return l==="DataView"?h=new Uint8Array(o.buffer):l==="ArrayBuffer"&&(h=new Uint8Array(o)),s([l,[...h]],o)}const f=[],d=s([a,f],o);for(const h of o)f.push(i(h));return d}case fa:{if(l)switch(l){case"BigInt":return s([l,o.toString()],o);case"Boolean":case"Number":case"String":return s([l,o.valueOf()],o)}if(t&&"toJSON"in o)return i(o.toJSON());const f=[],d=s([a,f],o);for(const h of DN(o))(e||!so(Rs(o[h])))&&f.push([i(h),i(o[h])]);return d}case Ud:return s([a,o.toISOString()],o);case Vd:{const{source:f,flags:d}=o;return s([a,{source:f,flags:d}],o)}case Hd:{const f=[],d=s([a,f],o);for(const[h,p]of o)(e||!(so(Rs(h))||so(Rs(p))))&&f.push([i(h),i(p)]);return d}case Wd:{const f=[],d=s([a,f],o);for(const h of o)(e||!so(Rs(h)))&&f.push(i(h));return d}}const{message:u}=o;return s([a,{name:l,message:u}],o)};return i},$p=(e,{json:t,lossy:n}={})=>{const r=[];return ON(!(t||n),!!t,new Map,r)(e),r},ha=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Bp($p(e,t)):structuredClone(e):(e,t)=>Bp($p(e,t));function zN(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function FN(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function BN(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||zN,r=e.options.footnoteBackLabel||FN,s=e.options.footnoteLabel||"Footnotes",i=e.options.footnoteLabelTagName||"h2",o=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[];let l=-1;for(;++l<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[l]);if(!u)continue;const f=e.all(u),d=String(u.identifier).toUpperCase(),h=gs(d.toLowerCase());let p=0;const g=[],x=e.footnoteCounts.get(d);for(;x!==void 0&&++p<=x;){g.length>0&&g.push({type:"text",value:" "});let v=typeof n=="string"?n:n(l,p);typeof v=="string"&&(v={type:"text",value:v}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+h+(p>1?"-"+p:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(l,p),className:["data-footnote-backref"]},children:Array.isArray(v)?v:[v]})}const k=f[f.length-1];if(k&&k.type==="element"&&k.tagName==="p"){const v=k.children[k.children.length-1];v&&v.type==="text"?v.value+=" ":k.children.push({type:"text",value:" "}),k.children.push(...g)}else f.push(...g);const y={type:"element",tagName:"li",properties:{id:t+"fn-"+h},children:e.wrap(f,!0)};e.patch(u,y),a.push(y)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...ha(o),id:"footnote-label"},children:[{type:"text",value:s}]},{type:"text",value:`
56
- `},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:`
57
- `}]}}const Wa=function(e){if(e==null)return HN;if(typeof e=="function")return qa(e);if(typeof e=="object")return Array.isArray(e)?$N(e):UN(e);if(typeof e=="string")return VN(e);throw new Error("Expected function, string, or object as test")};function $N(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Wa(e[n]);return qa(r);function r(...s){let i=-1;for(;++i<t.length;)if(t[i].apply(this,s))return!0;return!1}}function UN(e){const t=e;return qa(n);function n(r){const s=r;let i;for(i in e)if(s[i]!==t[i])return!1;return!0}}function VN(e){return qa(t);function t(n){return n&&n.type===e}}function qa(e){return t;function t(n,r,s){return!!(WN(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function HN(){return!0}function WN(e){return e!==null&&typeof e=="object"&&"type"in e}const eS=[],qN=!0,ac=!1,KN="skip";function tS(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const i=Wa(s),o=r?-1:1;a(e,void 0,[])();function a(l,u,f){const d=l&&typeof l=="object"?l:{};if(typeof d.type=="string"){const p=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(h,"name",{value:"node ("+(l.type+(p?"<"+p+">":""))+")"})}return h;function h(){let p=eS,g,x,k;if((!t||i(l,u,f[f.length-1]||void 0))&&(p=GN(n(l,f)),p[0]===ac))return p;if("children"in l&&l.children){const y=l;if(y.children&&p[0]!==KN)for(x=(r?y.children.length:-1)+o,k=f.concat(y);x>-1&&x<y.children.length;){const v=y.children[x];if(g=a(v,x,k)(),g[0]===ac)return g;x=typeof g[1]=="number"?g[1]:x+o}}return p}}}function GN(e){return Array.isArray(e)?e:typeof e=="number"?[qN,e]:e==null?eS:[e]}function qd(e,t,n,r){let s,i,o;typeof t=="function"&&typeof n!="function"?(i=void 0,o=t,s=n):(i=t,o=n,s=r),tS(e,i,a,s);function a(l,u){const f=u[u.length-1],d=f?f.children.indexOf(l):void 0;return o(l,d,f)}}const lc={}.hasOwnProperty,QN={};function YN(e,t){const n=t||QN,r=new Map,s=new Map,i=new Map,o={...jN,...n.handlers},a={all:u,applyData:XN,definitionById:r,footnoteById:s,footnoteCounts:i,footnoteOrder:[],handlers:o,one:l,options:n,patch:JN,wrap:eM};return qd(e,function(f){if(f.type==="definition"||f.type==="footnoteDefinition"){const d=f.type==="definition"?r:s,h=String(f.identifier).toUpperCase();d.has(h)||d.set(h,f)}}),a;function l(f,d){const h=f.type,p=a.handlers[h];if(lc.call(a.handlers,h)&&p)return p(a,f,d);if(a.options.passThrough&&a.options.passThrough.includes(h)){if("children"in f){const{children:x,...k}=f,y=ha(k);return y.children=a.all(f),y}return ha(f)}return(a.options.unknownHandler||ZN)(a,f,d)}function u(f){const d=[];if("children"in f){const h=f.children;let p=-1;for(;++p<h.length;){const g=a.one(h[p],f);if(g){if(p&&h[p-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=Up(g.value)),!Array.isArray(g)&&g.type==="element")){const x=g.children[0];x&&x.type==="text"&&(x.value=Up(x.value))}Array.isArray(g)?d.push(...g):d.push(g)}}}return d}}function JN(e,t){e.position&&(t.position=zP(e))}function XN(e,t){let n=t;if(e&&e.data){const r=e.data.hName,s=e.data.hChildren,i=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const o="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:o}}n.type==="element"&&i&&Object.assign(n.properties,ha(i)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function ZN(e,t){const n=t.data||{},r="value"in t&&!(lc.call(n,"hProperties")||lc.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function eM(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
58
- `});++r<e.length;)r&&n.push({type:"text",value:`
59
- `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
60
- `}),n}function Up(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Vp(e,t){const n=YN(e,t),r=n.one(e,void 0),s=BN(n),i=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return s&&i.children.push({type:"text",value:`
61
- `},s),i}function tM(e,t){return e&&"run"in e?async function(n,r){const s=Vp(n,{file:r,...t});await e.run(s,r)}:function(n,r){return Vp(n,{file:r,...e||t})}}function Hp(e){if(e)throw e}var _o=Object.prototype.hasOwnProperty,nS=Object.prototype.toString,Wp=Object.defineProperty,qp=Object.getOwnPropertyDescriptor,Kp=function(t){return typeof Array.isArray=="function"?Array.isArray(t):nS.call(t)==="[object Array]"},Gp=function(t){if(!t||nS.call(t)!=="[object Object]")return!1;var n=_o.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&_o.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var s;for(s in t);return typeof s>"u"||_o.call(t,s)},Qp=function(t,n){Wp&&n.name==="__proto__"?Wp(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},Yp=function(t,n){if(n==="__proto__")if(_o.call(t,n)){if(qp)return qp(t,n).value}else return;return t[n]},nM=function e(){var t,n,r,s,i,o,a=arguments[0],l=1,u=arguments.length,f=!1;for(typeof a=="boolean"&&(f=a,a=arguments[1]||{},l=2),(a==null||typeof a!="object"&&typeof a!="function")&&(a={});l<u;++l)if(t=arguments[l],t!=null)for(n in t)r=Yp(a,n),s=Yp(t,n),a!==s&&(f&&s&&(Gp(s)||(i=Kp(s)))?(i?(i=!1,o=r&&Kp(r)?r:[]):o=r&&Gp(r)?r:{},Qp(a,{name:n,newValue:e(f,o,s)})):typeof s<"u"&&Qp(a,{name:n,newValue:s}));return a};const Ll=ki(nM);function uc(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function rM(){const e=[],t={run:n,use:r};return t;function n(...s){let i=-1;const o=s.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);a(null,...s);function a(l,...u){const f=e[++i];let d=-1;if(l){o(l);return}for(;++d<s.length;)(u[d]===null||u[d]===void 0)&&(u[d]=s[d]);s=u,f?sM(f,a)(...u):o(null,...u)}}function r(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),t}}function sM(e,t){let n;return r;function r(...o){const a=e.length>o.length;let l;a&&o.push(s);try{l=e.apply(this,o)}catch(u){const f=u;if(a&&n)throw f;return s(f)}a||(l&&l.then&&typeof l.then=="function"?l.then(i,s):l instanceof Error?s(l):i(l))}function s(o,...a){n||(n=!0,t(o,...a))}function i(o){s(null,o)}}const Qt={basename:iM,dirname:oM,extname:aM,join:lM,sep:"/"};function iM(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Ai(e);let n=0,r=-1,s=e.length,i;if(t===void 0||t.length===0||t.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(i){n=s+1;break}}else r<0&&(i=!0,r=s+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let o=-1,a=t.length-1;for(;s--;)if(e.codePointAt(s)===47){if(i){n=s+1;break}}else o<0&&(i=!0,o=s+1),a>-1&&(e.codePointAt(s)===t.codePointAt(a--)?a<0&&(r=s):(a=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function oM(e){if(Ai(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function aM(e){Ai(e);let t=e.length,n=-1,r=0,s=-1,i=0,o;for(;t--;){const a=e.codePointAt(t);if(a===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),a===46?s<0?s=t:i!==1&&(i=1):s>-1&&(i=-1)}return s<0||n<0||i===0||i===1&&s===n-1&&s===r+1?"":e.slice(s,n)}function lM(...e){let t=-1,n;for(;++t<e.length;)Ai(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":uM(n)}function uM(e){Ai(e);const t=e.codePointAt(0)===47;let n=cM(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function cM(e,t){let n="",r=0,s=-1,i=0,o=-1,a,l;for(;++o<=e.length;){if(o<e.length)a=e.codePointAt(o);else{if(a===47)break;a=47}if(a===47){if(!(s===o-1||i===1))if(s!==o-1&&i===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",r=0):(n=n.slice(0,l),r=n.length-1-n.lastIndexOf("/")),s=o,i=0;continue}}else if(n.length>0){n="",r=0,s=o,i=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(s+1,o):n=e.slice(s+1,o),r=o-s-1;s=o,i=0}else a===46&&i>-1?i++:i=-1}return n}function Ai(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const dM={cwd:fM};function fM(){return"/"}function cc(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function hM(e){if(typeof e=="string")e=new URL(e);else if(!cc(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return pM(e)}function pM(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const s=new TypeError("File URL path must not include encoded / characters");throw s.code="ERR_INVALID_FILE_URL_PATH",s}}return decodeURIComponent(t)}const Dl=["history","path","basename","stem","extname","dirname"];class rS{constructor(t){let n;t?cc(t)?n={path:t}:typeof t=="string"||mM(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":dM.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Dl.length;){const i=Dl[r];i in n&&n[i]!==void 0&&n[i]!==null&&(this[i]=i==="history"?[...n[i]]:n[i])}let s;for(s in n)Dl.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?Qt.basename(this.path):void 0}set basename(t){zl(t,"basename"),Ol(t,"basename"),this.path=Qt.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Qt.dirname(this.path):void 0}set dirname(t){Jp(this.basename,"dirname"),this.path=Qt.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Qt.extname(this.path):void 0}set extname(t){if(Ol(t,"extname"),Jp(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Qt.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){cc(t)&&(t=hM(t)),zl(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Qt.basename(this.path,this.extname):void 0}set stem(t){zl(t,"stem"),Ol(t,"stem"),this.path=Qt.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const s=this.message(t,n,r);throw s.fatal=!0,s}info(t,n,r){const s=this.message(t,n,r);return s.fatal=void 0,s}message(t,n,r){const s=new Qe(t,n,r);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Ol(e,t){if(e&&e.includes(Qt.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Qt.sep+"`")}function zl(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Jp(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function mM(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const gM=function(e){const r=this.constructor.prototype,s=r[e],i=function(){return s.apply(i,arguments)};return Object.setPrototypeOf(i,r),i},yM={}.hasOwnProperty;class Kd extends gM{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=rM()}copy(){const t=new Kd;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Ll(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?($l("data",this.frozen),this.namespace[t]=n,this):yM.call(this.namespace,t)&&this.namespace[t]||void 0:t?($l("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const s=n.call(t,...r);typeof s=="function"&&this.transformers.use(s)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=io(t),r=this.parser||this.Parser;return Fl("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Fl("process",this.parser||this.Parser),Bl("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(i,o){const a=io(t),l=r.parse(a);r.run(l,a,function(f,d,h){if(f||!d||!h)return u(f);const p=d,g=r.stringify(p,h);wM(g)?h.value=g:h.result=g,u(f,h)});function u(f,d){f||!d?o(f):i?i(d):n(void 0,d)}}}processSync(t){let n=!1,r;return this.freeze(),Fl("processSync",this.parser||this.Parser),Bl("processSync",this.compiler||this.Compiler),this.process(t,s),Zp("processSync","process",n),r;function s(i,o){n=!0,Hp(i),r=o}}run(t,n,r){Xp(t),this.freeze();const s=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?i(void 0,r):new Promise(i);function i(o,a){const l=io(n);s.run(t,l,u);function u(f,d,h){const p=d||t;f?a(f):o?o(p):r(void 0,p,h)}}}runSync(t,n){let r=!1,s;return this.run(t,n,i),Zp("runSync","run",r),s;function i(o,a){Hp(o),s=a,r=!0}}stringify(t,n){this.freeze();const r=io(n),s=this.compiler||this.Compiler;return Bl("stringify",s),Xp(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if($l("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?a(t):o(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function i(u){if(typeof u=="function")l(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[f,...d]=u;l(f,d)}else o(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function o(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(u.plugins),u.settings&&(s.settings=Ll(!0,s.settings,u.settings))}function a(u){let f=-1;if(u!=null)if(Array.isArray(u))for(;++f<u.length;){const d=u[f];i(d)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function l(u,f){let d=-1,h=-1;for(;++d<r.length;)if(r[d][0]===u){h=d;break}if(h===-1)r.push([u,...f]);else if(f.length>0){let[p,...g]=f;const x=r[h][1];uc(x)&&uc(p)&&(p=Ll(!0,x,p)),r[h]=[u,p,...g]}}}}const vM=new Kd().freeze();function Fl(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Bl(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function $l(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Xp(e){if(!uc(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Zp(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function io(e){return xM(e)?e:new rS(e)}function xM(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function wM(e){return typeof e=="string"||SM(e)}function SM(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const bM="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",em=[],tm={allowDangerousHtml:!0},kM=/^(https?|ircs?|mailto|xmpp)$/i,CM=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function _M(e){const t=EM(e),n=TM(e);return IM(t.runSync(t.parse(n),n),e)}function EM(e){const t=e.rehypePlugins||em,n=e.remarkPlugins||em,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...tm}:tm;return vM().use(oN).use(n).use(tM,r).use(t)}function TM(e){const t=e.children||"",n=new rS;return typeof t=="string"&&(n.value=t),n}function IM(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,i=t.disallowedElements,o=t.skipHtml,a=t.unwrapDisallowed,l=t.urlTransform||RM;for(const f of CM)Object.hasOwn(t,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+bM+f.id,void 0);return qd(e,u),VP(e,{Fragment:c.Fragment,components:s,ignoreInvalidStyle:!0,jsx:c.jsx,jsxs:c.jsxs,passKeys:!0,passNode:!0});function u(f,d,h){if(f.type==="raw"&&h&&typeof d=="number")return o?h.children.splice(d,1):h.children[d]={type:"text",value:f.value},d;if(f.type==="element"){let p;for(p in jl)if(Object.hasOwn(jl,p)&&Object.hasOwn(f.properties,p)){const g=f.properties[p],x=jl[p];(x===null||x.includes(f.tagName))&&(f.properties[p]=l(String(g||""),p,f))}}if(f.type==="element"){let p=n?!n.includes(f.tagName):i?i.includes(f.tagName):!1;if(!p&&r&&typeof d=="number"&&(p=!r(f,d,h)),p&&h&&typeof d=="number")return a&&f.children?h.children.splice(d,1,...f.children):h.children.splice(d,1),d}}}function RM(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),s=e.indexOf("/");return t===-1||s!==-1&&t>s||n!==-1&&t>n||r!==-1&&t>r||kM.test(e.slice(0,t))?e:""}const{useSmooth:PM,useSmoothStatus:AM,withSmoothContextProvider:jM}=RI,NM=({components:e,componentsByLanguage:t,smooth:n=!0,preprocess:r,...s})=>{const i=Hx(),{text:o}=PM(m.useMemo(()=>r?{...i,text:r(i.text)}:i,[i,r]),n),{pre:a=FR,code:l=BR,SyntaxHighlighter:u=Ad,CodeHeader:f=$R}=e??{},d=m.useMemo(()=>({Pre:a,Code:l,SyntaxHighlighter:u,CodeHeader:f}),[a,l,u,f]),h=hr(p=>c.jsx(qR,{components:d,componentsByLanguage:t,...p}));return c.jsx(_M,{components:m.useMemo(()=>{const{pre:p,code:g,SyntaxHighlighter:x,CodeHeader:k,...y}=e??{};return{...y,pre:zR,code:h}},[h,e]),...s,children:o})},sS=m.forwardRef(({className:e,containerProps:t,containerComponent:n="div",...r},s)=>c.jsx(n,{"data-status":AM().type,...t,className:Sw(e,t?.className),ref:s,children:c.jsx(NM,{...r})}));sS.displayName="MarkdownTextPrimitive";const MM=jM(sS);function nm(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,s=n.indexOf(t);for(;s!==-1;)r++,s=n.indexOf(t,s+t.length);return r}function LM(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function DM(e,t,n){const s=Wa((n||{}).ignore||[]),i=OM(t);let o=-1;for(;++o<i.length;)tS(e,"text",a);function a(u,f){let d=-1,h;for(;++d<f.length;){const p=f[d],g=h?h.children:void 0;if(s(p,g?g.indexOf(p):void 0,h))return;h=p}if(h)return l(u,f)}function l(u,f){const d=f[f.length-1],h=i[o][0],p=i[o][1];let g=0;const k=d.children.indexOf(u);let y=!1,v=[];h.lastIndex=0;let w=h.exec(u.value);for(;w;){const E=w.index,I={index:w.index,input:w.input,stack:[...f,u]};let b=p(...w,I);if(typeof b=="string"&&(b=b.length>0?{type:"text",value:b}:void 0),b===!1?h.lastIndex=E+1:(g!==E&&v.push({type:"text",value:u.value.slice(g,E)}),Array.isArray(b)?v.push(...b):b&&v.push(b),g=E+w[0].length,y=!0),!h.global)break;w=h.exec(u.value)}return y?(g<u.value.length&&v.push({type:"text",value:u.value.slice(g)}),d.children.splice(k,1,...v)):v=[u],k+v.length}}function OM(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const s=n[r];t.push([zM(s[0]),FM(s[1])])}return t}function zM(e){return typeof e=="string"?new RegExp(LM(e),"g"):e}function FM(e){return typeof e=="function"?e:function(){return e}}const Ul="phrasing",Vl=["autolink","link","image","label"];function BM(){return{transforms:[KM],enter:{literalAutolink:UM,literalAutolinkEmail:Hl,literalAutolinkHttp:Hl,literalAutolinkWww:Hl},exit:{literalAutolink:qM,literalAutolinkEmail:WM,literalAutolinkHttp:VM,literalAutolinkWww:HM}}}function $M(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Ul,notInConstruct:Vl},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Ul,notInConstruct:Vl},{character:":",before:"[ps]",after:"\\/",inConstruct:Ul,notInConstruct:Vl}]}}function UM(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Hl(e){this.config.enter.autolinkProtocol.call(this,e)}function VM(e){this.config.exit.autolinkProtocol.call(this,e)}function HM(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function WM(e){this.config.exit.autolinkEmail.call(this,e)}function qM(e){this.exit(e)}function KM(e){DM(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,GM],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,QM]],{ignore:["link","linkReference"]})}function GM(e,t,n,r,s){let i="";if(!iS(s)||(/^w/i.test(t)&&(n=t+n,t="",i="http://"),!YM(n)))return!1;const o=JM(n+r);if(!o[0])return!1;const a={type:"link",title:null,url:i+t+o[0],children:[{type:"text",value:t+o[0]}]};return o[1]?[a,{type:"text",value:o[1]}]:a}function QM(e,t,n,r){return!iS(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function YM(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function JM(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const s=nm(e,"(");let i=nm(e,")");for(;r!==-1&&s>i;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),i++;return[e,n]}function iS(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||pr(n)||Ua(n))&&(!t||n!==47)}oS.peek=oL;function XM(){this.buffer()}function ZM(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function eL(){this.buffer()}function tL(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function nL(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=$t(this.sliceSerialize(e)).toLowerCase(),n.label=t}function rL(e){this.exit(e)}function sL(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=$t(this.sliceSerialize(e)).toLowerCase(),n.label=t}function iL(e){this.exit(e)}function oL(){return"["}function oS(e,t,n,r){const s=n.createTracker(r);let i=s.move("[^");const o=n.enter("footnoteReference"),a=n.enter("reference");return i+=s.move(n.safe(n.associationId(e),{after:"]",before:i})),a(),o(),i+=s.move("]"),i}function aL(){return{enter:{gfmFootnoteCallString:XM,gfmFootnoteCall:ZM,gfmFootnoteDefinitionLabelString:eL,gfmFootnoteDefinition:tL},exit:{gfmFootnoteCallString:nL,gfmFootnoteCall:rL,gfmFootnoteDefinitionLabelString:sL,gfmFootnoteDefinition:iL}}}function lL(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:oS},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,s,i,o){const a=i.createTracker(o);let l=a.move("[^");const u=i.enter("footnoteDefinition"),f=i.enter("label");return l+=a.move(i.safe(i.associationId(r),{before:l,after:"]"})),f(),l+=a.move("]:"),r.children&&r.children.length>0&&(a.shift(4),l+=a.move((t?`
62
- `:" ")+i.indentLines(i.containerFlow(r,a.current()),t?aS:uL))),u(),l}}function uL(e,t,n){return t===0?e:aS(e,t,n)}function aS(e,t,n){return(n?"":" ")+e}const cL=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];lS.peek=mL;function dL(){return{canContainEols:["delete"],enter:{strikethrough:hL},exit:{strikethrough:pL}}}function fL(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:cL}],handlers:{delete:lS}}}function hL(e){this.enter({type:"delete",children:[]},e)}function pL(e){this.exit(e)}function lS(e,t,n,r){const s=n.createTracker(r),i=n.enter("strikethrough");let o=s.move("~~");return o+=n.containerPhrasing(e,{...s.current(),before:o,after:"~"}),o+=s.move("~~"),i(),o}function mL(){return"~"}function gL(e){return e.length}function yL(e,t){const n=t||{},r=(n.align||[]).concat(),s=n.stringLength||gL,i=[],o=[],a=[],l=[];let u=0,f=-1;for(;++f<e.length;){const x=[],k=[];let y=-1;for(e[f].length>u&&(u=e[f].length);++y<e[f].length;){const v=vL(e[f][y]);if(n.alignDelimiters!==!1){const w=s(v);k[y]=w,(l[y]===void 0||w>l[y])&&(l[y]=w)}x.push(v)}o[f]=x,a[f]=k}let d=-1;if(typeof r=="object"&&"length"in r)for(;++d<u;)i[d]=rm(r[d]);else{const x=rm(r);for(;++d<u;)i[d]=x}d=-1;const h=[],p=[];for(;++d<u;){const x=i[d];let k="",y="";x===99?(k=":",y=":"):x===108?k=":":x===114&&(y=":");let v=n.alignDelimiters===!1?1:Math.max(1,l[d]-k.length-y.length);const w=k+"-".repeat(v)+y;n.alignDelimiters!==!1&&(v=k.length+v+y.length,v>l[d]&&(l[d]=v),p[d]=v),h[d]=w}o.splice(1,0,h),a.splice(1,0,p),f=-1;const g=[];for(;++f<o.length;){const x=o[f],k=a[f];d=-1;const y=[];for(;++d<u;){const v=x[d]||"";let w="",E="";if(n.alignDelimiters!==!1){const I=l[d]-(k[d]||0),b=i[d];b===114?w=" ".repeat(I):b===99?I%2?(w=" ".repeat(I/2+.5),E=" ".repeat(I/2-.5)):(w=" ".repeat(I/2),E=w):E=" ".repeat(I)}n.delimiterStart!==!1&&!d&&y.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&v==="")&&(n.delimiterStart!==!1||d)&&y.push(" "),n.alignDelimiters!==!1&&y.push(w),y.push(v),n.alignDelimiters!==!1&&y.push(E),n.padding!==!1&&y.push(" "),(n.delimiterEnd!==!1||d!==u-1)&&y.push("|")}g.push(n.delimiterEnd===!1?y.join("").replace(/ +$/,""):y.join(""))}return g.join(`
63
- `)}function vL(e){return e==null?"":String(e)}function rm(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function xL(e,t,n,r){const s=n.enter("blockquote"),i=n.createTracker(r);i.move("> "),i.shift(2);const o=n.indentLines(n.containerFlow(e,i.current()),wL);return s(),o}function wL(e,t,n){return">"+(n?"":" ")+e}function SL(e,t){return sm(e,t.inConstruct,!0)&&!sm(e,t.notInConstruct,!1)}function sm(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function im(e,t,n,r){let s=-1;for(;++s<n.unsafe.length;)if(n.unsafe[s].character===`
64
- `&&SL(n.stack,n.unsafe[s]))return/[ \t]/.test(r.before)?"":" ";return`\\
65
- `}function bL(e,t){const n=String(e);let r=n.indexOf(t),s=r,i=0,o=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===s?++i>o&&(o=i):i=1,s=r+t.length,r=n.indexOf(t,s);return o}function kL(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function CL(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function _L(e,t,n,r){const s=CL(n),i=e.value||"",o=s==="`"?"GraveAccent":"Tilde";if(kL(e,n)){const d=n.enter("codeIndented"),h=n.indentLines(i,EL);return d(),h}const a=n.createTracker(r),l=s.repeat(Math.max(bL(i,s)+1,3)),u=n.enter("codeFenced");let f=a.move(l);if(e.lang){const d=n.enter(`codeFencedLang${o}`);f+=a.move(n.safe(e.lang,{before:f,after:" ",encode:["`"],...a.current()})),d()}if(e.lang&&e.meta){const d=n.enter(`codeFencedMeta${o}`);f+=a.move(" "),f+=a.move(n.safe(e.meta,{before:f,after:`
66
- `,encode:["`"],...a.current()})),d()}return f+=a.move(`
67
- `),i&&(f+=a.move(i+`
68
- `)),f+=a.move(l),u(),f}function EL(e,t,n){return(n?"":" ")+e}function Gd(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function TL(e,t,n,r){const s=Gd(n),i=s==='"'?"Quote":"Apostrophe",o=n.enter("definition");let a=n.enter("label");const l=n.createTracker(r);let u=l.move("[");return u+=l.move(n.safe(n.associationId(e),{before:u,after:"]",...l.current()})),u+=l.move("]: "),a(),!e.url||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),u+=l.move("<"),u+=l.move(n.safe(e.url,{before:u,after:">",...l.current()})),u+=l.move(">")):(a=n.enter("destinationRaw"),u+=l.move(n.safe(e.url,{before:u,after:e.title?" ":`
69
- `,...l.current()}))),a(),e.title&&(a=n.enter(`title${i}`),u+=l.move(" "+s),u+=l.move(n.safe(e.title,{before:u,after:s,...l.current()})),u+=l.move(s),a()),o(),u}function IL(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function bi(e){return"&#x"+e.toString(16).toUpperCase()+";"}function pa(e,t,n){const r=os(e),s=os(t);return r===void 0?s===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:s===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?s===void 0?{inside:!1,outside:!1}:s===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:s===void 0?{inside:!1,outside:!1}:s===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}uS.peek=RL;function uS(e,t,n,r){const s=IL(n),i=n.enter("emphasis"),o=n.createTracker(r),a=o.move(s);let l=o.move(n.containerPhrasing(e,{after:s,before:a,...o.current()}));const u=l.charCodeAt(0),f=pa(r.before.charCodeAt(r.before.length-1),u,s);f.inside&&(l=bi(u)+l.slice(1));const d=l.charCodeAt(l.length-1),h=pa(r.after.charCodeAt(0),d,s);h.inside&&(l=l.slice(0,-1)+bi(d));const p=o.move(s);return i(),n.attentionEncodeSurroundingInfo={after:h.outside,before:f.outside},a+l+p}function RL(e,t,n){return n.options.emphasis||"*"}function PL(e,t){let n=!1;return qd(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,ac}),!!((!e.depth||e.depth<3)&&Fd(e)&&(t.options.setext||n))}function AL(e,t,n,r){const s=Math.max(Math.min(6,e.depth||1),1),i=n.createTracker(r);if(PL(e,n)){const f=n.enter("headingSetext"),d=n.enter("phrasing"),h=n.containerPhrasing(e,{...i.current(),before:`
70
- `,after:`
71
- `});return d(),f(),h+`
72
- `+(s===1?"=":"-").repeat(h.length-(Math.max(h.lastIndexOf("\r"),h.lastIndexOf(`
73
- `))+1))}const o="#".repeat(s),a=n.enter("headingAtx"),l=n.enter("phrasing");i.move(o+" ");let u=n.containerPhrasing(e,{before:"# ",after:`
74
- `,...i.current()});return/^[\t ]/.test(u)&&(u=bi(u.charCodeAt(0))+u.slice(1)),u=u?o+" "+u:o,n.options.closeAtx&&(u+=" "+o),l(),a(),u}cS.peek=jL;function cS(e){return e.value||""}function jL(){return"<"}dS.peek=NL;function dS(e,t,n,r){const s=Gd(n),i=s==='"'?"Quote":"Apostrophe",o=n.enter("image");let a=n.enter("label");const l=n.createTracker(r);let u=l.move("![");return u+=l.move(n.safe(e.alt,{before:u,after:"]",...l.current()})),u+=l.move("]("),a(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),u+=l.move("<"),u+=l.move(n.safe(e.url,{before:u,after:">",...l.current()})),u+=l.move(">")):(a=n.enter("destinationRaw"),u+=l.move(n.safe(e.url,{before:u,after:e.title?" ":")",...l.current()}))),a(),e.title&&(a=n.enter(`title${i}`),u+=l.move(" "+s),u+=l.move(n.safe(e.title,{before:u,after:s,...l.current()})),u+=l.move(s),a()),u+=l.move(")"),o(),u}function NL(){return"!"}fS.peek=ML;function fS(e,t,n,r){const s=e.referenceType,i=n.enter("imageReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("![");const u=n.safe(e.alt,{before:l,after:"]",...a.current()});l+=a.move(u+"]["),o();const f=n.stack;n.stack=[],o=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return o(),n.stack=f,i(),s==="full"||!u||u!==d?l+=a.move(d+"]"):s==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function ML(){return"!"}hS.peek=LL;function hS(e,t,n){let r=e.value||"",s="`",i=-1;for(;new RegExp("(^|[^`])"+s+"([^`]|$)").test(r);)s+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++i<n.unsafe.length;){const o=n.unsafe[i],a=n.compilePattern(o);let l;if(o.atBreak)for(;l=a.exec(r);){let u=l.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(l.index+1)}}return s+r+s}function LL(){return"`"}function pS(e,t){const n=Fd(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}mS.peek=DL;function mS(e,t,n,r){const s=Gd(n),i=s==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let a,l;if(pS(e,n)){const f=n.stack;n.stack=[],a=n.enter("autolink");let d=o.move("<");return d+=o.move(n.containerPhrasing(e,{before:d,after:">",...o.current()})),d+=o.move(">"),a(),n.stack=f,d}a=n.enter("link"),l=n.enter("label");let u=o.move("[");return u+=o.move(n.containerPhrasing(e,{before:u,after:"](",...o.current()})),u+=o.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),u+=o.move("<"),u+=o.move(n.safe(e.url,{before:u,after:">",...o.current()})),u+=o.move(">")):(l=n.enter("destinationRaw"),u+=o.move(n.safe(e.url,{before:u,after:e.title?" ":")",...o.current()}))),l(),e.title&&(l=n.enter(`title${i}`),u+=o.move(" "+s),u+=o.move(n.safe(e.title,{before:u,after:s,...o.current()})),u+=o.move(s),l()),u+=o.move(")"),a(),u}function DL(e,t,n){return pS(e,n)?"<":"["}gS.peek=OL;function gS(e,t,n,r){const s=e.referenceType,i=n.enter("linkReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("[");const u=n.containerPhrasing(e,{before:l,after:"]",...a.current()});l+=a.move(u+"]["),o();const f=n.stack;n.stack=[],o=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return o(),n.stack=f,i(),s==="full"||!u||u!==d?l+=a.move(d+"]"):s==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function OL(){return"["}function Qd(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function zL(e){const t=Qd(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function FL(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function yS(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function BL(e,t,n,r){const s=n.enter("list"),i=n.bulletCurrent;let o=e.ordered?FL(n):Qd(n);const a=e.ordered?o==="."?")":".":zL(n);let l=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){const f=e.children?e.children[0]:void 0;if((o==="*"||o==="-")&&f&&(!f.children||!f.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(l=!0),yS(n)===o&&f){let d=-1;for(;++d<e.children.length;){const h=e.children[d];if(h&&h.type==="listItem"&&h.children&&h.children[0]&&h.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(o=a),n.bulletCurrent=o;const u=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=i,s(),u}function $L(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function UL(e,t,n,r){const s=$L(n);let i=n.bulletCurrent||Qd(n);t&&t.type==="list"&&t.ordered&&(i=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+i);let o=i.length+1;(s==="tab"||s==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);const a=n.createTracker(r);a.move(i+" ".repeat(o-i.length)),a.shift(o);const l=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,a.current()),f);return l(),u;function f(d,h,p){return h?(p?"":" ".repeat(o))+d:(p?i:i+" ".repeat(o-i.length))+d}}function VL(e,t,n,r){const s=n.enter("paragraph"),i=n.enter("phrasing"),o=n.containerPhrasing(e,r);return i(),s(),o}const HL=Wa(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function WL(e,t,n,r){return(e.children.some(function(o){return HL(o)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function qL(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}vS.peek=KL;function vS(e,t,n,r){const s=qL(n),i=n.enter("strong"),o=n.createTracker(r),a=o.move(s+s);let l=o.move(n.containerPhrasing(e,{after:s,before:a,...o.current()}));const u=l.charCodeAt(0),f=pa(r.before.charCodeAt(r.before.length-1),u,s);f.inside&&(l=bi(u)+l.slice(1));const d=l.charCodeAt(l.length-1),h=pa(r.after.charCodeAt(0),d,s);h.inside&&(l=l.slice(0,-1)+bi(d));const p=o.move(s+s);return i(),n.attentionEncodeSurroundingInfo={after:h.outside,before:f.outside},a+l+p}function KL(e,t,n){return n.options.strong||"*"}function GL(e,t,n,r){return n.safe(e.value,r)}function QL(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function YL(e,t,n){const r=(yS(n)+(n.options.ruleSpaces?" ":"")).repeat(QL(n));return n.options.ruleSpaces?r.slice(0,-1):r}const xS={blockquote:xL,break:im,code:_L,definition:TL,emphasis:uS,hardBreak:im,heading:AL,html:cS,image:dS,imageReference:fS,inlineCode:hS,link:mS,linkReference:gS,list:BL,listItem:UL,paragraph:VL,root:WL,strong:vS,text:GL,thematicBreak:YL};function JL(){return{enter:{table:XL,tableData:om,tableHeader:om,tableRow:eD},exit:{codeText:tD,table:ZL,tableData:Wl,tableHeader:Wl,tableRow:Wl}}}function XL(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function ZL(e){this.exit(e),this.data.inTable=void 0}function eD(e){this.enter({type:"tableRow",children:[]},e)}function Wl(e){this.exit(e)}function om(e){this.enter({type:"tableCell",children:[]},e)}function tD(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,nD));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function nD(e,t){return t==="|"?t:e}function rD(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,s=t.stringLength,i=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
75
- `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:h,table:o,tableCell:l,tableRow:a}};function o(p,g,x,k){return u(f(p,x,k),p.align)}function a(p,g,x,k){const y=d(p,x,k),v=u([y]);return v.slice(0,v.indexOf(`
76
- `))}function l(p,g,x,k){const y=x.enter("tableCell"),v=x.enter("phrasing"),w=x.containerPhrasing(p,{...k,before:i,after:i});return v(),y(),w}function u(p,g){return yL(p,{align:g,alignDelimiters:r,padding:n,stringLength:s})}function f(p,g,x){const k=p.children;let y=-1;const v=[],w=g.enter("table");for(;++y<k.length;)v[y]=d(k[y],g,x);return w(),v}function d(p,g,x){const k=p.children;let y=-1;const v=[],w=g.enter("tableRow");for(;++y<k.length;)v[y]=l(k[y],p,g,x);return w(),v}function h(p,g,x){let k=xS.inlineCode(p,g,x);return x.stack.includes("tableCell")&&(k=k.replace(/\|/g,"\\$&")),k}}function sD(){return{exit:{taskListCheckValueChecked:am,taskListCheckValueUnchecked:am,paragraph:oD}}}function iD(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:aD}}}function am(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function oD(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const s=t.children;let i=-1,o;for(;++i<s.length;){const a=s[i];if(a.type==="paragraph"){o=a;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function aD(e,t,n,r){const s=e.children[0],i=typeof e.checked=="boolean"&&s&&s.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);i&&a.move(o);let l=xS.listItem(e,t,n,{...r,...a.current()});return i&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),l;function u(f){return f+o}}function lD(){return[BM(),aL(),dL(),JL(),sD()]}function uD(e){return{extensions:[$M(),lL(e),fL(),rD(e),iD()]}}const cD={tokenize:gD,partial:!0},wS={tokenize:yD,partial:!0},SS={tokenize:vD,partial:!0},bS={tokenize:xD,partial:!0},dD={tokenize:wD,partial:!0},kS={name:"wwwAutolink",tokenize:pD,previous:_S},CS={name:"protocolAutolink",tokenize:mD,previous:ES},wn={name:"emailAutolink",tokenize:hD,previous:TS},rn={};function fD(){return{text:rn}}let Yn=48;for(;Yn<123;)rn[Yn]=wn,Yn++,Yn===58?Yn=65:Yn===91&&(Yn=97);rn[43]=wn;rn[45]=wn;rn[46]=wn;rn[95]=wn;rn[72]=[wn,CS];rn[104]=[wn,CS];rn[87]=[wn,kS];rn[119]=[wn,kS];function hD(e,t,n){const r=this;let s,i;return o;function o(d){return!dc(d)||!TS.call(r,r.previous)||Yd(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(d))}function a(d){return dc(d)?(e.consume(d),a):d===64?(e.consume(d),l):n(d)}function l(d){return d===46?e.check(dD,f,u)(d):d===45||d===95||Ke(d)?(i=!0,e.consume(d),l):f(d)}function u(d){return e.consume(d),s=!0,l}function f(d){return i&&s&&Ze(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function pD(e,t,n){const r=this;return s;function s(o){return o!==87&&o!==119||!_S.call(r,r.previous)||Yd(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(cD,e.attempt(wS,e.attempt(SS,i),n),n)(o))}function i(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function mD(e,t,n){const r=this;let s="",i=!1;return o;function o(d){return(d===72||d===104)&&ES.call(r,r.previous)&&!Yd(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),s+=String.fromCodePoint(d),e.consume(d),a):n(d)}function a(d){if(Ze(d)&&s.length<5)return s+=String.fromCodePoint(d),e.consume(d),a;if(d===58){const h=s.toLowerCase();if(h==="http"||h==="https")return e.consume(d),l}return n(d)}function l(d){return d===47?(e.consume(d),i?u:(i=!0,l)):n(d)}function u(d){return d===null||da(d)||he(d)||pr(d)||Ua(d)?n(d):e.attempt(wS,e.attempt(SS,f),n)(d)}function f(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function gD(e,t,n){let r=0;return s;function s(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),s):o===46&&r===3?(e.consume(o),i):n(o)}function i(o){return o===null?n(o):t(o)}}function yD(e,t,n){let r,s,i;return o;function o(u){return u===46||u===95?e.check(bS,l,a)(u):u===null||he(u)||pr(u)||u!==45&&Ua(u)?l(u):(i=!0,e.consume(u),o)}function a(u){return u===95?r=!0:(s=r,r=void 0),e.consume(u),o}function l(u){return s||r||!i?n(u):t(u)}}function vD(e,t){let n=0,r=0;return s;function s(o){return o===40?(n++,e.consume(o),s):o===41&&r<n?i(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(bS,t,i)(o):o===null||he(o)||pr(o)?t(o):(e.consume(o),s)}function i(o){return o===41&&r++,e.consume(o),s}}function xD(e,t,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(e.consume(a),r):a===38?(e.consume(a),i):a===93?(e.consume(a),s):a===60||a===null||he(a)||pr(a)?t(a):n(a)}function s(a){return a===null||a===40||a===91||he(a)||pr(a)?t(a):r(a)}function i(a){return Ze(a)?o(a):n(a)}function o(a){return a===59?(e.consume(a),r):Ze(a)?(e.consume(a),o):n(a)}}function wD(e,t,n){return r;function r(i){return e.consume(i),s}function s(i){return Ke(i)?n(i):t(i)}}function _S(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||he(e)}function ES(e){return!Ze(e)}function TS(e){return!(e===47||dc(e))}function dc(e){return e===43||e===45||e===46||e===95||Ke(e)}function Yd(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const SD={tokenize:RD,partial:!0};function bD(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:ED,continuation:{tokenize:TD},exit:ID}},text:{91:{name:"gfmFootnoteCall",tokenize:_D},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:kD,resolveTo:CD}}}}function kD(e,t,n){const r=this;let s=r.events.length;const i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;s--;){const l=r.events[s][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!o||!o._balanced)return n(l);const u=$t(r.sliceSerialize({start:o.end,end:r.now()}));return u.codePointAt(0)!==94||!i.includes(u.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function CD(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;const i={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},i.start),end:Object.assign({},i.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",s,t],["exit",s,t],["enter",i,t],["enter",o,t],["exit",o,t],["exit",i,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function _D(e,t,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i=0,o;return a;function a(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(d){if(i>999||d===93&&!o||d===null||d===91||he(d))return n(d);if(d===93){e.exit("chunkString");const h=e.exit("gfmFootnoteCallString");return s.includes($t(r.sliceSerialize(h)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return he(d)||(o=!0),i++,e.consume(d),d===92?f:u}function f(d){return d===91||d===92||d===93?(e.consume(d),i++,u):u(d)}}function ED(e,t,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i,o=0,a;return l;function l(g){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(g){return g===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",f):n(g)}function f(g){if(o>999||g===93&&!a||g===null||g===91||he(g))return n(g);if(g===93){e.exit("chunkString");const x=e.exit("gfmFootnoteDefinitionLabelString");return i=$t(r.sliceSerialize(x)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),h}return he(g)||(a=!0),o++,e.consume(g),g===92?d:f}function d(g){return g===91||g===92||g===93?(e.consume(g),o++,f):f(g)}function h(g){return g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),s.includes(i)||s.push(i),ae(e,p,"gfmFootnoteDefinitionWhitespace")):n(g)}function p(g){return t(g)}}function TD(e,t,n){return e.check(Pi,t,e.attempt(SD,t,n))}function ID(e){e.exit("gfmFootnoteDefinition")}function RD(e,t,n){const r=this;return ae(e,s,"gfmFootnoteDefinitionIndent",5);function s(i){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(i):n(i)}}function PD(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:i,resolveAll:s};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function s(o,a){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let u=l;for(;u--;)if(o[u][0]==="exit"&&o[u][1].type==="strikethroughSequenceTemporary"&&o[u][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[u][1].end.offset-o[u][1].start.offset){o[l][1].type="strikethroughSequence",o[u][1].type="strikethroughSequence";const f={type:"strikethrough",start:Object.assign({},o[u][1].start),end:Object.assign({},o[l][1].end)},d={type:"strikethroughText",start:Object.assign({},o[u][1].end),end:Object.assign({},o[l][1].start)},h=[["enter",f,a],["enter",o[u][1],a],["exit",o[u][1],a],["enter",d,a]],p=a.parser.constructs.insideSpan.null;p&&wt(h,h.length,0,Va(p,o.slice(u+1,l),a)),wt(h,h.length,0,[["exit",d,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",f,a]]),wt(o,u-1,l-u+3,h),l=u+h.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function i(o,a,l){const u=this.previous,f=this.events;let d=0;return h;function h(g){return u===126&&f[f.length-1][1].type!=="characterEscape"?l(g):(o.enter("strikethroughSequenceTemporary"),p(g))}function p(g){const x=os(u);if(g===126)return d>1?l(g):(o.consume(g),d++,p);if(d<2&&!n)return l(g);const k=o.exit("strikethroughSequenceTemporary"),y=os(g);return k._open=!y||y===2&&!!x,k._close=!x||x===2&&!!y,a(g)}}}class AD{constructor(){this.map=[]}add(t,n,r){jD(this,t,n,r)}consume(t){if(this.map.sort(function(i,o){return i[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let s=r.pop();for(;s;){for(const i of s)t.push(i);s=r.pop()}this.map.length=0}}function jD(e,t,n,r){let s=0;if(!(n===0&&r.length===0)){for(;s<e.map.length;){if(e.map[s][0]===t){e.map[s][1]+=n,e.map[s][2].push(...r);return}s+=1}e.map.push([t,n,r])}}function ND(e,t){let n=!1;const r=[];for(;t<e.length;){const s=e[t];if(n){if(s[0]==="enter")s[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(s[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const i=r.length-1;r[i]=r[i]==="left"?"center":"right"}}else if(s[1].type==="tableDelimiterRow")break}else s[0]==="enter"&&s[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function MD(){return{flow:{null:{name:"table",tokenize:LD,resolveAll:DD}}}}function LD(e,t,n){const r=this;let s=0,i=0,o;return a;function a(_){let z=r.events.length-1;for(;z>-1;){const j=r.events[z][1].type;if(j==="lineEnding"||j==="linePrefix")z--;else break}const L=z>-1?r.events[z][1].type:null,W=L==="tableHead"||L==="tableRow"?b:l;return W===b&&r.parser.lazy[r.now().line]?n(_):W(_)}function l(_){return e.enter("tableHead"),e.enter("tableRow"),u(_)}function u(_){return _===124||(o=!0,i+=1),f(_)}function f(_){return _===null?n(_):Q(_)?i>1?(i=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),p):n(_):re(_)?ae(e,f,"whitespace")(_):(i+=1,o&&(o=!1,s+=1),_===124?(e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),o=!0,f):(e.enter("data"),d(_)))}function d(_){return _===null||_===124||he(_)?(e.exit("data"),f(_)):(e.consume(_),_===92?h:d)}function h(_){return _===92||_===124?(e.consume(_),d):d(_)}function p(_){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(_):(e.enter("tableDelimiterRow"),o=!1,re(_)?ae(e,g,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(_):g(_))}function g(_){return _===45||_===58?k(_):_===124?(o=!0,e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),x):I(_)}function x(_){return re(_)?ae(e,k,"whitespace")(_):k(_)}function k(_){return _===58?(i+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(_),e.exit("tableDelimiterMarker"),y):_===45?(i+=1,y(_)):_===null||Q(_)?E(_):I(_)}function y(_){return _===45?(e.enter("tableDelimiterFiller"),v(_)):I(_)}function v(_){return _===45?(e.consume(_),v):_===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(_),e.exit("tableDelimiterMarker"),w):(e.exit("tableDelimiterFiller"),w(_))}function w(_){return re(_)?ae(e,E,"whitespace")(_):E(_)}function E(_){return _===124?g(_):_===null||Q(_)?!o||s!==i?I(_):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(_)):I(_)}function I(_){return n(_)}function b(_){return e.enter("tableRow"),P(_)}function P(_){return _===124?(e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),P):_===null||Q(_)?(e.exit("tableRow"),t(_)):re(_)?ae(e,P,"whitespace")(_):(e.enter("data"),D(_))}function D(_){return _===null||_===124||he(_)?(e.exit("data"),P(_)):(e.consume(_),_===92?O:D)}function O(_){return _===92||_===124?(e.consume(_),D):D(_)}}function DD(e,t){let n=-1,r=!0,s=0,i=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,u,f,d;const h=new AD;for(;++n<e.length;){const p=e[n],g=p[1];p[0]==="enter"?g.type==="tableHead"?(a=!1,l!==0&&(lm(h,t,l,u,f),f=void 0,l=0),u={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},h.add(n,0,[["enter",u,t]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(r=!0,d=void 0,i=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,f={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},h.add(n,0,[["enter",f,t]])),s=g.type==="tableDelimiterRow"?2:f?3:1):s&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(i[1]!==0&&(o[0]=o[1],d=oo(h,t,i,s,void 0,d),i=[0,0,0,0]),o[2]=n)):g.type==="tableCellDivider"&&(r?r=!1:(i[1]!==0&&(o[0]=o[1],d=oo(h,t,i,s,void 0,d)),i=o,o=[i[1],n,0,0])):g.type==="tableHead"?(a=!0,l=n):g.type==="tableRow"||g.type==="tableDelimiterRow"?(l=n,i[1]!==0?(o[0]=o[1],d=oo(h,t,i,s,n,d)):o[1]!==0&&(d=oo(h,t,o,s,n,d)),s=0):s&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&lm(h,t,l,u,f),h.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=ND(t.events,n))}return e}function oo(e,t,n,r,s,i){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(i.end=Object.assign({},Ir(t.events,n[0])),e.add(n[0],0,[["exit",i,t]]));const l=Ir(t.events,n[1]);if(i={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",i,t]]),n[2]!==0){const u=Ir(t.events,n[2]),f=Ir(t.events,n[3]),d={type:a,start:Object.assign({},u),end:Object.assign({},f)};if(e.add(n[2],0,[["enter",d,t]]),r!==2){const h=t.events[n[2]],p=t.events[n[3]];if(h[1].end=Object.assign({},p[1].end),h[1].type="chunkText",h[1].contentType="text",n[3]>n[2]+1){const g=n[2]+1,x=n[3]-n[2]-1;e.add(g,x,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return s!==void 0&&(i.end=Object.assign({},Ir(t.events,s)),e.add(s,0,[["exit",i,t]]),i=void 0),i}function lm(e,t,n,r,s){const i=[],o=Ir(t.events,n);s&&(s.end=Object.assign({},o),i.push(["exit",s,t])),r.end=Object.assign({},o),i.push(["exit",r,t]),e.add(n+1,0,i)}function Ir(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const OD={name:"tasklistCheck",tokenize:FD};function zD(){return{text:{91:OD}}}function FD(e,t,n){const r=this;return s;function s(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),i)}function i(l){return he(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(l)}function a(l){return Q(l)?t(l):re(l)?e.check({tokenize:BD},t,n)(l):n(l)}}function BD(e,t,n){return ae(e,r,"whitespace");function r(s){return s===null?n(s):t(s)}}function $D(e){return Dw([fD(),bD(),PD(e),MD(),zD()])}const UD={};function VD(e){const t=this,n=e||UD,r=t.data(),s=r.micromarkExtensions||(r.micromarkExtensions=[]),i=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);s.push($D(n)),i.push(lD()),o.push(uD(n))}const HD="modulepreload",WD=function(e,t){return new URL(e,t).href},um={},Kt=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){const o=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),l=a?.nonce||a?.getAttribute("nonce");s=Promise.allSettled(n.map(u=>{if(u=WD(u,r),u in um)return;um[u]=!0;const f=u.endsWith(".css"),d=f?'[rel="stylesheet"]':"";if(!!r)for(let g=o.length-1;g>=0;g--){const x=o[g];if(x.href===u&&(!f||x.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${u}"]${d}`))return;const p=document.createElement("link");if(p.rel=f?"stylesheet":HD,f||(p.as="script"),p.crossOrigin="",p.href=u,l&&p.setAttribute("nonce",l),document.head.appendChild(p),f)return new Promise((g,x)=>{p.addEventListener("load",g),p.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${u}`)))})}))}function i(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return s.then(o=>{for(const a of o||[])a.status==="rejected"&&i(a.reason);return t().catch(i)})},qD={ts:"typescript",typescript:"typescript",tsx:"typescript",js:"javascript",javascript:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",json:"json",jsonc:"json",sh:"bash",bash:"bash",shell:"bash",zsh:"bash",py:"python",python:"python",diff:"diff",patch:"diff",md:"markdown",markdown:"markdown",html:"xml",xml:"xml",css:"css"};function Jd(e){return e?qD[e.trim().toLowerCase()]??null:null}let ql=null;async function KD(){return ql||(ql=(async()=>{const{default:e}=await Kt(async()=>{const{default:f}=await import("./core-CZTz1vMx.js");return{default:f}},[],import.meta.url),[t,n,r,s,i,o,a,l,u]=await Promise.all([Kt(()=>import("./typescript-C2FFdlUC.js"),[],import.meta.url),Kt(()=>import("./javascript-BKRaQes9.js"),[],import.meta.url),Kt(()=>import("./json-DIYVocXf.js"),[],import.meta.url),Kt(()=>import("./bash-I8pq0VWm.js"),[],import.meta.url),Kt(()=>import("./python-sE43i1Pi.js"),[],import.meta.url),Kt(()=>import("./diff-DiTmLxSS.js"),[],import.meta.url),Kt(()=>import("./markdown-BrP960CR.js"),[],import.meta.url),Kt(()=>import("./xml-BXBhIUeX.js"),[],import.meta.url),Kt(()=>import("./css-DazXZka4.js"),[],import.meta.url)]);return e.registerLanguage("typescript",t.default),e.registerLanguage("javascript",n.default),e.registerLanguage("json",r.default),e.registerLanguage("bash",s.default),e.registerLanguage("python",i.default),e.registerLanguage("diff",o.default),e.registerLanguage("markdown",a.default),e.registerLanguage("xml",l.default),e.registerLanguage("css",u.default),e})()),ql}async function IS(e,t){const n=Jd(e);if(!n)return null;try{const r=await KD(),{value:s}=r.highlight(t,{language:n,ignoreIllegals:!0});return s}catch{return null}}function GD(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n),t=t>>>0;return t.toString(36)}function QD(e,t){return"code-"+GD((e??"")+`
77
- `+t)}const cm=8,RS=m.createContext(null);function Xd(){const e=m.useContext(RS);if(!e)throw new Error("useArtifactPanel must be used inside <ArtifactPanelProvider>");return e}function YD(e,t){const n=e.artifacts.findIndex(s=>s.id===t.id);if(n>=0)return{artifacts:[e.artifacts[n],...e.artifacts.filter((i,o)=>o!==n)],activeId:t.id};const r=[t,...e.artifacts];return{artifacts:r.length>cm?r.slice(0,cm):r,activeId:t.id}}function JD(e,t){const n=e.artifacts.findIndex(i=>i.id===t);if(n<0)return e;const r=e.artifacts.filter((i,o)=>o!==n);let s=e.activeId;if(e.activeId===t)if(r.length===0)s=null;else{const i=Math.min(n,r.length-1);s=r[i].id}return{artifacts:r,activeId:s}}function XD({children:e}){const[t,n]=m.useState({artifacts:[],activeId:null}),r=m.useCallback(a=>{n(l=>YD(l,a))},[]),s=m.useCallback(a=>{n(l=>({...l,activeId:a}))},[]),i=m.useCallback(a=>{n(l=>JD(l,a))},[]),o=m.useMemo(()=>({artifacts:t.artifacts,activeId:t.activeId,open:r,setActive:s,close:i}),[t,r,s,i]);return c.jsx(RS.Provider,{value:o,children:e})}const ZD=({language:e,code:t})=>{const{open:n}=Xd();if(!e)return null;const r=typeof t=="string"&&t.length>0,s=()=>{if(!r||typeof t!="string")return;const i=e||"code";n({id:QD(e,t),kind:"code",title:i,language:e,content:t})};return c.jsxs("div",{className:"aui-md-code-lang",children:[c.jsx("span",{className:"aui-md-code-lang-name",children:e}),r?c.jsx("button",{type:"button",className:"aui-md-code-open-btn",onClick:s,title:"Open in side panel","aria-label":`Open ${e} code in side panel`,children:"↗"}):null]})},eO=({components:e,language:t,code:n})=>{const{Pre:r,Code:s}=e,i=Jd(t)!==null,[o,a]=m.useState(null);return m.useEffect(()=>{if(!i){a(null);return}let l=!0;return a(null),IS(t,n).then(u=>{l&&a(u)}).catch(()=>{l&&a(null)}),()=>{l=!1}},[i,t,n]),i&&o!=null?c.jsx(r,{children:c.jsx(s,{className:"hljs",dangerouslySetInnerHTML:{__html:o}})}):c.jsx(r,{children:c.jsx(s,{className:i?"hljs":void 0,children:n})})},tO=({node:e,...t})=>c.jsx("div",{className:"md-table-wrap",children:c.jsx("table",{...t})}),nO=()=>c.jsx(MM,{className:"aui-md",remarkPlugins:[VD],components:{CodeHeader:ZD,SyntaxHighlighter:eO,table:tO}}),rO=m.memo(nO);function sO(e){const[t,n]=m.useState(null);return m.useEffect(()=>{let r=!1,s=null;return je(XI(e)).then(i=>i.ok?i.blob():null).then(i=>{!i||r||(s=URL.createObjectURL(i),n(s))}).catch(()=>{}),()=>{r=!0,s&&URL.revokeObjectURL(s),n(null)}},[e]),t}const iO=new Set([".jpg",".jpeg",".png",".gif",".webp",".avif",".heic",".heif",".svg"]),dm=/(?:^|\s)(\/[^\s]*\/\.claude-control\/uploads\/([^\s]+))/g;function oO(e){const t=[],n=new Set;let r;for(dm.lastIndex=0;(r=dm.exec(e))!==null;){const s=r[1].trim();if(n.has(s))continue;n.add(s);const i=r[2],o=i.slice(i.lastIndexOf(".")).toLowerCase();t.push({fullPath:s,basename:i,isImage:iO.has(o)})}return t}function aO({src:e,alt:t,onClose:n}){const r=m.useRef(null);m.useEffect(()=>{r.current?.focus()},[]);const s=m.useCallback(i=>{i.key==="Escape"&&(i.preventDefault(),n())},[n]);return c.jsx("div",{className:"lightbox-backdrop",role:"dialog","aria-modal":"true","aria-label":`Preview: ${t}`,ref:r,tabIndex:-1,onClick:n,onKeyDown:s,children:c.jsx("img",{className:"lightbox-img",src:e,alt:t,onClick:i=>i.stopPropagation()})})}function lO({ref_:e}){const[t,n]=m.useState(!1),r=sO(e.basename);return e.isImage?c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",className:"transcript-thumb-btn","aria-label":`Preview ${e.basename}`,title:e.basename,onClick:()=>n(!0),children:r?c.jsx("img",{className:"transcript-thumb",src:r,alt:e.basename,loading:"lazy"}):c.jsx("span",{className:"transcript-thumb transcript-thumb-loading","aria-hidden":"true"})}),t&&r?c.jsx(aO,{src:r,alt:e.basename,onClose:()=>n(!1)}):null]}):c.jsxs("a",{className:"transcript-file-chip",href:r??void 0,download:e.basename,"aria-label":`Download ${e.basename}`,title:e.basename,"aria-disabled":r?void 0:!0,children:[c.jsx("span",{className:"chip-icon","aria-hidden":"true",children:"📎"}),c.jsx("span",{className:"chip-name",children:e.basename})]})}function uO({text:e}){const t=oO(e);return t.length===0?null:c.jsx("div",{className:"transcript-attachments","aria-label":"Attachments",children:t.map(n=>c.jsx(lO,{ref_:n},n.fullPath))})}function cO(e){return e.trimStart().startsWith("Base directory for this skill:")}function dO(e){const n=e.trim().replace(/\/SKILL\.md$/i,"").split("/").filter(Boolean);return n[n.length-1]??"skill"}function fO(e){const t=e.split(`
78
- `);if(t[0]?.trim()!=="---")return{entries:[],rest:e};const n=[];let r=-1;for(let i=1;i<t.length;i++){if(t[i].trim()==="---"){r=i;break}const o=t[i].indexOf(":");if(o!==-1){const a=t[i].slice(0,o).trim(),l=t[i].slice(o+1).trim();a&&n.push({key:a,value:l})}}if(r===-1)return{entries:[],rest:e};const s=t.slice(r+1).join(`
79
- `);return{entries:n,rest:s}}function hO(e){const t=e.trimStart().split(`
80
- `),s=(t[0]??"").match(/Base directory for this skill:\s*(.+)/)?.[1]??"",i=dO(s),o=t.slice(1).join(`
81
- `).trimStart(),{entries:a,rest:l}=fO(o),u=a.find(d=>d.key==="name")?.value??null,f=a.find(d=>d.key==="description")?.value??null;return{name:u??i,description:f,frontmatter:a,body:l.trimStart()}}const pO={UserMessage:Ka,AssistantMessage:Vn,SystemMessage:Vn};function mO({markdown:e}){const t=m.useMemo(()=>[{role:"assistant",id:"skill-body",content:[{type:"text",text:e}],metadata:{custom:{cockpitRole:"assistant"}}}],[e]),n=Oa({messages:t,isDisabled:!0,convertMessage:r=>r,onNew:async()=>{}});return c.jsx(za,{runtime:n,children:c.jsx(ct.Root,{className:"skill-body-thread",children:c.jsx(ct.Viewport,{className:"skill-body-viewport",children:c.jsx(ct.Messages,{components:pO})})})})}function gO({parsed:e,onClose:t}){return m.useEffect(()=>{const n=r=>{r.key==="Escape"&&(r.preventDefault(),t())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t]),c.jsx("div",{className:"modal-backdrop",onClick:n=>{n.target===n.currentTarget&&t()},children:c.jsxs("div",{className:"modal modal-skill",role:"dialog","aria-modal":"true","aria-label":`Skill: ${e.name}`,children:[c.jsxs("div",{className:"modal-head",children:[c.jsxs("span",{className:"modal-title modal-title-skill",children:["🧩 Skill: ",e.name]}),c.jsx("button",{type:"button",className:"modal-close","aria-label":"Close skill detail",onClick:t,children:"✕"})]}),c.jsxs("div",{className:"modal-body skill-modal-body",children:[e.frontmatter.length>0&&c.jsx("dl",{className:"skill-fm",children:e.frontmatter.map(({key:n,value:r})=>c.jsxs("div",{className:"skill-fm-row",children:[c.jsx("dt",{className:"skill-fm-key",children:n}),c.jsx("dd",{className:"skill-fm-val",children:r})]},n))}),e.body.length>0&&c.jsx("div",{className:"skill-body-wrap",children:c.jsx(mO,{markdown:e.body})})]})]})})}function yO({text:e}){const[t,n]=m.useState(!1),r=m.useMemo(()=>hO(e),[e]);return c.jsxs(c.Fragment,{children:[c.jsxs("button",{type:"button",className:"skill-chip",onClick:()=>n(!0),onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),n(!0))},title:r.description??`Skill: ${r.name}`,children:[c.jsx("span",{className:"skill-chip-icon","aria-hidden":"true",children:"🧩"}),c.jsx("span",{className:"skill-chip-name",children:r.name}),c.jsx("span",{className:"skill-chip-tag",children:"skill"})]}),t&&c.jsx(gO,{parsed:r,onClose:()=>n(!1)})]})}const vO=/^\s*working…?\s*$/i,xO=e=>typeof e.text=="string"&&vO.test(e.text)?c.jsxs("span",{className:"working-indicator",role:"status","aria-live":"polite",children:[c.jsx("span",{className:"working-spinner","aria-hidden":"true"}),c.jsx("span",{className:"shimmer-text",children:"Working…"})]}):typeof e.text=="string"&&cO(e.text)?c.jsx(yO,{text:e.text}):c.jsxs(c.Fragment,{children:[c.jsx(rO,{...e}),typeof e.text=="string"?c.jsx(uO,{text:e.text}):null]}),fm=90;function wO(e){const t=e.split(`
82
- `);for(let n=t.length-1;n>=0;n--){const r=t[n].trim();if(r)return r.length>fm?r.slice(0,fm-1)+"…":r}return""}function SO(e){const t=fw(e);if(t==null||typeof t=="object"&&Object.keys(t).length===0)return"";try{return JSON.stringify(t,null,2)}catch{return String(t)}}const bO=({toolCallId:e,toolName:t,args:n,result:r})=>{const{open:s}=Xd(),[i,o]=m.useState(!1),a=hR(n),l=SO(n),u=pR(r),f=l.length>0||u!=null,d=fw(n),h=d&&typeof d=="object"&&"file_path"in d?String(d.file_path):void 0,p=h&&h.includes(".")?h.split(".").pop():void 0,g=u?.text??l,x=g.length>0,k=()=>{x&&s({id:e,kind:"tool",title:t+(a?` — ${a}`:""),language:p,content:g,filePath:h})},y=x?c.jsx("button",{type:"button",className:"tool-name tool-name-btn",onClick:k,title:"Open in side panel",children:t}):c.jsx("span",{className:"tool-name",children:t}),v=c.jsxs("span",{className:"tool-head",children:[f?c.jsx("button",{type:"button",className:"tool-arrow-btn","aria-expanded":i,"aria-label":i?"Collapse":"Expand",onClick:()=>o(w=>!w),children:c.jsx("span",{className:"tool-arrow","data-peek":i?"true":"false","aria-hidden":"true",children:"▸"})}):c.jsx("span",{className:"tool-arrow","aria-hidden":"true",children:"▸"}),y,a?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"tool-sep",children:"—"}),c.jsx("span",{className:"tool-input",children:a})]}):null]});return c.jsxs("div",{className:"block-tool",children:[c.jsx("div",{className:"block-tool-use",children:v}),f&&i?c.jsxs("div",{className:"block-tool-body",children:[l?c.jsx("pre",{className:"block-tool-args",children:l}):null,u!=null?c.jsx("div",{className:"block-tool-result","data-error":u.isError?"true":"false",children:u.text}):null]}):null]})},PS=m.createContext(null);function kO(){return m.useContext(PS)}function CO(){return c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[c.jsx("rect",{x:"9",y:"9",width:"11",height:"11",rx:"2",stroke:"currentColor",strokeWidth:"2"}),c.jsx("path",{d:"M5 15V5a2 2 0 0 1 2-2h10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function _O(){return c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:c.jsx("path",{d:"M5 12l5 5L19 6",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function AS(){return c.jsx(qh.Root,{className:"msg-actions",children:c.jsxs(qh.Copy,{className:"act-btn","aria-label":"Copy message",children:[c.jsxs("span",{className:"act-copy-idle",children:[c.jsx(CO,{})," copy"]}),c.jsxs("span",{className:"act-copy-done",children:[c.jsx(_O,{})," copied"]})]})})}const EO=new Set(["AskUserQuestion","ExitPlanMode"]);function TO(e){const t=[],n=[];function r(){if(n.length===0)return;if(n.filter(i=>e[i].type==="reasoning"||e[i].type==="tool-call").length>=2)t.push({groupKey:"group-thought",indices:[...n]});else for(const i of n)t.push({groupKey:void 0,indices:[i]});n.length=0}for(let s=0;s<e.length;s+=1){const i=e[s];i.type==="text"||i.type==="tool-call"&&i.toolName!==void 0&&EO.has(i.toolName)?(r(),t.push({groupKey:void 0,indices:[s]})):n.push(s)}return r(),t}function IO({text:e}){return!e||!e.trim()?null:c.jsx("div",{className:"cot-reasoning thinking-text",children:e})}const jS={Text:xO,Reasoning:IO,tools:{Fallback:bO}};function RO({indices:e,children:t}){const n=sa(x=>x.id),r=kO(),s=!!r&&n===r,[i,o]=m.useState(!1),a=s||i,l=sa(x=>x.content);let u=0,f=0,d="";for(const x of e){const k=l[x];k&&(k.type==="reasoning"?(u+=1,k.text?.trim()&&(d=k.text)):k.type==="tool-call"&&(f+=1))}const h=u+f,p=u>0?"chain of thought":`${f} tool call${f===1?"":"s"}`,g=wO(d);return c.jsxs("details",{className:"block-cot","data-thinking":s?"true":void 0,open:a,onToggle:x=>o(x.currentTarget.open),children:[c.jsxs("summary",{children:[c.jsx("span",{className:"cot-label",children:s?"thinking":p}),u>0?c.jsxs("span",{className:"cot-steps",children:["· ",h," step",h===1?"":"s"]}):null,g?c.jsx("span",{className:"cot-last",children:s?c.jsx(vw,{text:g}):g}):null]}),a?c.jsx("div",{className:"cot-body",children:t}):null]})}function PO(){return c.jsx(oa.Unstable_PartsGrouped,{groupingFunction:TO,components:{...jS,Group:({groupKey:e,indices:t,children:n})=>e?c.jsx(RO,{indices:t,children:n}):c.jsx(c.Fragment,{children:n})}})}function Ka(){return c.jsxs(oa.Root,{className:"msg-row","data-role":"user",children:[c.jsx("div",{className:"msg-body",children:c.jsx(oa.Parts,{components:jS})}),c.jsx(AS,{})]})}function Vn(){const e=sa(n=>n.metadata?.custom?.cockpitRole)??"assistant",t=sa(n=>n.metadata?.custom?.working);return c.jsxs(oa.Root,{className:"msg-row","data-role":e,children:[c.jsx("div",{className:"msg-body",children:c.jsx(PO,{})}),!t&&c.jsx(AS,{})]})}function ma({children:e}){return c.jsx("kbd",{className:"kbd",children:e})}function AO(e){if(e.backend==="mlx"){const t=(e.model||"").replace(/^mlx-community\//,"").replace(/-Instruct-4bit$/i,"").replace(/-4bit$/i,"");return t?`MLX · ${t}`:"MLX"}return e.backend==="claude"?"claude -p":e.backend==="rules"?"rules":e.mode==="llm"?"llm":"rules"}function jO(e,t){const n=e.split(`
83
- `),r=t.split(`
84
- `),s=new Set(n),i=new Set(r),o=[];let a=0,l=0;for(;a<n.length||l<r.length;){const u=n[a],f=r[l];a>=n.length?(o.push({kind:"add",text:f}),l++):l>=r.length?(o.push({kind:"del",text:u}),a++):u===f?(o.push({kind:"same",text:u}),a++,l++):!i.has(u)&&s.has(f)?(o.push({kind:"del",text:u}),o.push({kind:"add",text:f}),a++,l++):i.has(u)?s.has(f)?(o.push({kind:"same",text:u}),a++,l++):(o.push({kind:"add",text:f}),l++):(o.push({kind:"del",text:u}),a++)}return o}function NO({original:e,result:t,onAccept:n,onClose:r}){const[s,i]=m.useState(t.optimized),o=m.useRef(null);m.useEffect(()=>{o.current?.focus()},[]),m.useEffect(()=>{const u=f=>{f.key==="Escape"&&(f.preventDefault(),r())};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[r]);const a=jO(e,t.optimized),l=a.some(u=>u.kind!=="same");return c.jsx("div",{className:"modal-backdrop",onClick:u=>{u.target===u.currentTarget&&r()},children:c.jsxs("div",{className:"modal modal-optimize",role:"dialog","aria-modal":!0,"aria-label":"Review enhanced prompt",children:[c.jsxs("div",{className:"modal-head",children:[c.jsxs("div",{className:"modal-head-group",children:[c.jsx("span",{className:"modal-title modal-title-optimize",children:"Enhanced prompt"}),c.jsx("span",{className:"optimize-mode-badge","data-mode":t.mode,children:AO(t)})]}),c.jsx("button",{type:"button",className:"modal-close","aria-label":"Close",onClick:r,children:"✕"})]}),c.jsxs("div",{className:"modal-body",children:[c.jsxs("div",{className:"optimize-section",children:[c.jsx("span",{className:"optimize-section-label",children:"Suggestion"}),c.jsx("textarea",{ref:o,className:"optimize-suggestion",value:s,onChange:u=>i(u.target.value),rows:6,spellCheck:!1,autoComplete:"off"})]}),l?c.jsxs("div",{className:"optimize-section",children:[c.jsx("span",{className:"optimize-section-label",children:"Changes vs original"}),c.jsx("div",{className:"optimize-diff",children:a.map((u,f)=>c.jsxs("div",{className:u.kind==="add"?"diff-add":u.kind==="del"?"diff-del":"diff-same",children:[u.kind==="add"?"+ ":u.kind==="del"?"- ":" ",u.text||" "]},f))})]}):null,t.rationale.length>0?c.jsxs("div",{className:"optimize-section",children:[c.jsx("span",{className:"optimize-section-label",children:"Rationale"}),c.jsx("ul",{className:"optimize-list",children:t.rationale.map((u,f)=>c.jsx("li",{children:u},f))})]}):null,t.changes.length>0?c.jsxs("div",{className:"optimize-section",children:[c.jsx("span",{className:"optimize-section-label",children:"What changed"}),c.jsx("ul",{className:"optimize-list",children:t.changes.map((u,f)=>c.jsx("li",{children:u},f))})]}):null]}),c.jsxs("div",{className:"modal-foot",children:[c.jsx("button",{type:"button",className:"btn-secondary",onClick:r,children:"Discard"}),c.jsx("span",{className:"modal-foot-spacer"}),c.jsx("button",{type:"button",className:"btn-primary",onClick:()=>n(s),children:"Accept"})]})]})})}const hm="(max-width:760px)";function NS(){const[e,t]=m.useState(()=>typeof window>"u"?!1:window.matchMedia(hm).matches);return m.useEffect(()=>{if(typeof window>"u")return;const n=window.matchMedia(hm),r=s=>t(s.matches);return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}function MO({onPick:e,onClose:t}){const n=NS(),[r,s]=m.useState([]),[i,o]=m.useState(!0),[a,l]=m.useState(""),u=m.useRef(null);m.useEffect(()=>{let p=!0;return o(!0),dw().then(g=>{p&&(s(g),o(!1))}).catch(()=>{p&&o(!1)}),()=>{p=!1}},[]),m.useEffect(()=>{requestAnimationFrame(()=>u.current?.focus())},[]),m.useEffect(()=>{const p=g=>{g.key==="Escape"&&(g.preventDefault(),t())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[t]);const f=a.trim().toLowerCase(),d=f?r.filter(p=>p.name.toLowerCase().includes(f)||p.description.toLowerCase().includes(f)):r,h=c.jsxs("div",{className:"skill-browser","data-mode":n?"sheet":"modal",role:"dialog","aria-modal":"true","aria-label":"Skill browser",children:[c.jsxs("div",{className:"skill-browser-head",children:[c.jsx("span",{className:"skill-browser-title",children:"Skills"}),c.jsx("button",{type:"button",className:"modal-close","aria-label":"Close skill browser",onClick:t,children:"✕"})]}),c.jsx("div",{className:"skill-browser-search",children:c.jsx("input",{ref:u,type:"search",className:"skill-search-input",placeholder:"Search skills…",value:a,onChange:p=>l(p.currentTarget.value),"aria-label":"Search skills",autoComplete:"off",spellCheck:!1})}),c.jsx("div",{className:"skill-browser-list",role:"list",children:i?c.jsx("div",{className:"skill-browser-empty",children:"Loading…"}):d.length===0?c.jsx("div",{className:"skill-browser-empty",children:f?"No skills match your search.":"No skills found."}):d.map(p=>c.jsxs("button",{type:"button",className:"skill-card",role:"listitem",onClick:()=>e(p.name),title:`Prefill /${p.name}`,children:[c.jsxs("span",{className:"tool-head",children:[c.jsx("span",{className:"tool-arrow","aria-hidden":"true",children:"▸"}),c.jsx("span",{className:"tool-name skill-card-name",children:p.name}),p.description?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"tool-sep",children:"—"}),c.jsx("span",{className:"tool-input skill-card-desc",children:p.description})]}):null]}),p.source==="plugin"?c.jsx("span",{className:"skill-source-tag",children:"plugin"}):null]},p.name))})]});return n?c.jsx("div",{className:"skill-browser-sheet-wrap",children:h}):c.jsx("div",{className:"modal-backdrop",onClick:p=>{p.target===p.currentTarget&&t()},children:h})}function LO(){if(typeof window>"u")return null;const e=window;return e.AudioContext??e.webkitAudioContext??null}function DO(){const e=typeof window<"u"?window.MediaRecorder:void 0,t=[{mime:"audio/webm;codecs=opus",ext:"webm"},{mime:"audio/webm",ext:"webm"},{mime:"audio/mp4",ext:"mp4"},{mime:"audio/aac",ext:"aac"},{mime:"audio/ogg;codecs=opus",ext:"ogg"}];if(e&&typeof e.isTypeSupported=="function"){for(const n of t)if(e.isTypeSupported(n.mime))return n}return{mime:"",ext:"webm"}}function OO({onCommit:e,onClose:t}){const[n,r]=m.useState("starting"),[s,i]=m.useState(null),o=typeof window<"u"&&"MediaRecorder"in window,a=m.useRef(null),l=m.useRef(null),u=m.useRef(null),f=m.useRef(null),d=m.useRef([]),h=m.useRef({mime:"",ext:"webm"}),p=m.useRef(null),g=m.useRef(null),x=m.useRef(!1),k=m.useRef(!1),y=m.useCallback(()=>{x.current=!1,g.current!=null&&cancelAnimationFrame(g.current),g.current=null},[]),v=m.useCallback(()=>{const O=p.current,_=u.current;if(!O||!_)return;const z=O.getContext("2d");if(!z)return;const L=new Uint8Array(_.fftSize),W=getComputedStyle(O).getPropertyValue("--accent").trim()||"#7aa2f7";x.current=!0;const j=()=>{if(!x.current)return;O.width!==O.clientWidth&&(O.width=O.clientWidth),_.getByteTimeDomainData(L);const R=O.width,B=O.height;z.clearRect(0,0,R,B),z.lineWidth=2,z.strokeStyle=W,z.beginPath();const K=R/L.length;for(let A=0;A<L.length;A+=1){const S=L[A]/128*B/2,G=A*K;A===0?z.moveTo(G,S):z.lineTo(G,S)}z.stroke(),g.current=requestAnimationFrame(j)};g.current=requestAnimationFrame(j)},[]),w=m.useCallback(()=>{y(),a.current?.getTracks().forEach(O=>O.stop()),a.current=null,l.current?.close().catch(()=>{}),l.current=null,u.current=null},[y]);m.useEffect(()=>{let O=!1;return(async()=>{try{if(!navigator.mediaDevices?.getUserMedia)throw new Error("no-getusermedia");const _=await navigator.mediaDevices.getUserMedia({audio:!0});if(O){_.getTracks().forEach(j=>j.stop());return}a.current=_;const z=LO();if(z){const j=new z;l.current=j,j.state==="suspended"&&await j.resume();const R=j.createMediaStreamSource(_),B=j.createAnalyser();B.fftSize=512,R.connect(B),u.current=B}if(!("MediaRecorder"in window))throw new Error("no-mediarecorder");const L=DO();h.current=L;const W=L.mime?new MediaRecorder(_,{mimeType:L.mime}):new MediaRecorder(_);W.ondataavailable=j=>{j.data&&j.data.size>0&&d.current.push(j.data)},f.current=W,W.start(),r("recording"),v()}catch(_){const z=_ instanceof Error?_.message:"";i(z==="no-mediarecorder"?"Audio recording isn’t supported in this browser.":"Microphone permission denied or unavailable."),r("error")}})(),()=>{O=!0,y();try{f.current?.stop()}catch{}f.current=null,a.current?.getTracks().forEach(_=>_.stop()),a.current=null,l.current?.close().catch(()=>{}),l.current=null,u.current=null}},[]);const E=m.useCallback(()=>{try{f.current?.pause()}catch{}y(),r("paused")},[y]),I=m.useCallback(()=>{try{f.current?.resume()}catch{}r("recording"),v()},[v]),b=m.useCallback(()=>{if(k.current)return;k.current=!0;const O=f.current;if(!O){w(),e("");return}r("transcribing"),O.onstop=async()=>{const{mime:_,ext:z}=h.current,L=new Blob(d.current,{type:_||"audio/webm"});if(w(),L.size===0){e("");return}try{const W=await KI(L,z);e(W)}catch(W){i(W instanceof Error?W.message:"Transcription failed."),r("error")}};try{O.stop()}catch{w(),e("")}},[w,e]),P=m.useCallback(()=>{k.current=!0;try{f.current?.stop()}catch{}f.current=null,w(),t()},[w,t]);m.useEffect(()=>{const O=_=>{_.key==="Escape"&&n!=="transcribing"&&(_.preventDefault(),P())};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[P,n]);const D=n==="error"?"Microphone unavailable":n==="transcribing"?"Transcribing…":n==="paused"?"Paused":n==="starting"?"Starting…":"Listening…";return c.jsx("div",{className:"modal-backdrop",onClick:O=>{O.target===O.currentTarget&&n!=="transcribing"&&P()},children:c.jsxs("div",{className:"modal voice-dialog",role:"dialog","aria-modal":"true","aria-label":"Voice input",children:[c.jsxs("div",{className:"voice-status",children:[c.jsx("span",{className:"voice-dot","data-on":n==="recording"?"true":void 0}),D]}),c.jsx("canvas",{ref:p,className:"voice-wave",height:72,"data-paused":n!=="recording"?"true":void 0}),c.jsx("div",{className:"voice-transcript",children:n==="transcribing"?c.jsx("span",{className:"voice-placeholder",children:"Converting speech to text…"}):c.jsx("span",{className:"voice-placeholder",children:"Speak, then tap “Stop & insert” to transcribe."})}),n==="error"?c.jsx("div",{className:"voice-error",children:s||"Could not start recording."}):o?null:c.jsx("div",{className:"voice-note",children:"Audio recording isn’t supported in this browser."}),c.jsxs("div",{className:"voice-actions",children:[c.jsx("button",{type:"button",className:"btn-secondary",onClick:P,disabled:n==="transcribing",children:"Cancel"}),c.jsx("span",{className:"voice-actions-spacer"}),n==="recording"?c.jsx("button",{type:"button",className:"btn-secondary",onClick:E,children:"Pause"}):n==="paused"?c.jsx("button",{type:"button",className:"btn-secondary",onClick:I,children:"Resume"}):null,c.jsx("button",{type:"button",className:"btn-primary",onClick:b,disabled:n==="error"||n==="transcribing"||n==="starting",children:n==="transcribing"?"Transcribing…":"Stop & insert"})]})]})})}let Zs=null,ao=null;function zO(){return Zs?Promise.resolve(Zs):(ao||(ao=dw().then(e=>(Zs=e,e)).catch(()=>(ao=null,[]))),ao)}const FO=/^\/([A-Za-z0-9:_-]*)$/,BO=/^\/([A-Za-z0-9:_-]+)(?:\s|$)/,$O=4;function UO({file:e}){const[t,n]=m.useState(null);return m.useEffect(()=>{const r=URL.createObjectURL(e);return n(r),()=>URL.revokeObjectURL(r)},[e]),t?c.jsx("img",{className:"chip-thumb",src:t,alt:"",role:"button",tabIndex:0,title:"Open preview",onClick:()=>window.open(t,"_blank","noopener"),onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),window.open(t,"_blank","noopener"))}}):c.jsx("div",{className:"chip-thumb chip-thumb-empty"})}function VO({attachment:e}){const t=e.type==="image",n=e.status.type==="running";return c.jsxs(Kh.Root,{className:"attach-chip","data-pending":n,children:[t&&e.file?c.jsx(UO,{file:e.file}):c.jsx("span",{className:"chip-icon","aria-hidden":"true",children:e.type==="document"?"📄":"📎"}),c.jsx("span",{className:"chip-name",title:e.name,children:e.name}),n?c.jsx("span",{className:"chip-spinner","aria-hidden":"true"}):null,c.jsx(Kh.Remove,{className:"chip-remove","aria-label":`Remove ${e.name}`,children:"×"})]})}const pm={optimizing:!1,review:null};function MS({disabled:e,sessionId:t}){const n=hE(),[r,s]=m.useState(!0),[i,o]=m.useState(!1),[a,l]=m.useState({}),u=t??"",{optimizing:f,review:d}=a[u]??pm,h=m.useCallback((R,B)=>{l(K=>({...K,[R]:{...K[R]??pm,...B}}))},[]),[p,g]=m.useState(()=>Zs??[]),[x,k]=m.useState(""),[y,v]=m.useState(0),[w,E]=m.useState(!1);m.useEffect(()=>{Zs||zO().then(g)},[]),m.useEffect(()=>{const R=()=>{const B=n.getState().text??"";k(B),s(!B.trim())};return R(),n.subscribe(R)},[n]);const I=m.useMemo(()=>{const R=FO.exec(x);return R?R[1]:null},[x]);m.useEffect(()=>{v(0),E(!1)},[I]);const b=m.useMemo(()=>{if(I==null||w)return[];const R=I.toLowerCase();return p.filter(B=>B.name.toLowerCase().includes(R)).sort((B,K)=>{const A=B.name.toLowerCase().startsWith(R)?0:1,N=K.name.toLowerCase().startsWith(R)?0:1;return A!==N?A-N:B.name.localeCompare(K.name)}).slice(0,$O)},[I,w,p]),P=b.length>0,D=m.useMemo(()=>{const R=BO.exec(x);return R&&p.some(B=>B.name===R[1])?R[1]:null},[x,p]),O=m.useCallback(R=>{n.setText(`/${R} `),E(!0),requestAnimationFrame(()=>{document.querySelector(".composer-input")?.focus()})},[n]),[_,z]=m.useState(!1),L=m.useCallback(R=>{z(!1);const B=R.trim();if(!B)return;const K=n.getState().text??"",A=K&&!/\s$/.test(K)?" ":"";n.setText(K+A+B+" ")},[n]);m.useEffect(()=>{o(!1),z(!1)},[t]);const W=m.useCallback(R=>{n.setText(`/${R} `),o(!1),requestAnimationFrame(()=>{document.querySelector(".composer-input")?.focus()})},[n]),j=m.useCallback(async()=>{if(e||f)return;const R=n.getState().text??"";if(!R.trim())return;const B=u;h(B,{optimizing:!0});try{const K=await qI(R);h(B,{optimizing:!1,review:{...K,original:R}})}catch{h(B,{optimizing:!1})}},[n,e,f,u,h]);return c.jsxs(Ts.Root,{className:"composer",children:[P?c.jsx("div",{className:"skill-ac",role:"listbox","aria-label":"Skill suggestions",children:b.map((R,B)=>c.jsx("button",{type:"button",role:"option","aria-selected":B===y,"data-on":B===y?"true":void 0,className:"skill-ac-item",onMouseDown:K=>{K.preventDefault(),O(R.name)},onMouseEnter:()=>v(B),children:c.jsxs("span",{className:"tool-head",children:[c.jsx("span",{className:"tool-arrow","aria-hidden":"true",children:"▸"}),c.jsx("span",{className:"tool-name skill-card-name",children:R.name}),R.description?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"tool-sep",children:"—"}),c.jsx("span",{className:"tool-input skill-card-desc",children:R.description})]}):null]})},R.name))}):null,c.jsxs("div",{className:"composer-card",children:[D?c.jsx("div",{className:"composer-skill-chip-row",children:c.jsxs("span",{className:"skill-chip composer-skill-chip",title:`Invoking /${D}`,children:[c.jsx("span",{className:"skill-chip-icon","aria-hidden":"true",children:"⌁"}),c.jsxs("span",{className:"skill-chip-name",children:["/",D]})]})}):null,c.jsxs("div",{className:"composer-input-wrap",children:[c.jsx(Ts.Input,{className:"composer-input",placeholder:e?"Select a session…":" ",submitOnEnter:!1,onKeyDown:R=>{if(P){if(R.key==="ArrowDown"){R.preventDefault(),v(B=>(B+1)%b.length);return}if(R.key==="ArrowUp"){R.preventDefault(),v(B=>(B-1+b.length)%b.length);return}if(R.key==="Enter"&&!R.metaKey&&!R.ctrlKey){R.preventDefault(),O(b[y].name);return}if(R.key==="Tab"){R.preventDefault(),O(b[y].name);return}if(R.key==="Escape"){R.preventDefault(),E(!0);return}}R.key==="Enter"&&(R.metaKey||R.ctrlKey)&&(R.preventDefault(),!e&&!f&&n.send()),R.key.toLowerCase()==="o"&&(R.metaKey||R.ctrlKey)&&(R.preventDefault(),j())},rows:1,disabled:e,autoComplete:"off"}),e?null:c.jsxs("div",{className:"composer-hint","aria-hidden":"true",children:[c.jsx("span",{className:"composer-hint-lead",children:"Reply…"}),c.jsxs("span",{className:"composer-hint-keys",children:[c.jsx(ma,{children:"⌘/Ctrl+↵"})," to send",c.jsx("span",{className:"composer-hint-dot",children:"·"}),c.jsx(ma,{children:"↵"})," newline"]})]})]}),c.jsx("div",{className:"composer-attachments",children:c.jsx(Ts.Attachments,{children:({attachment:R})=>c.jsx(VO,{attachment:R})})}),c.jsxs("div",{className:"composer-toolbar",children:[c.jsx(Ts.AddAttachment,{className:"composer-attach","aria-label":"Attach a file",title:"Attach a file",multiple:!0,disabled:e,children:c.jsx(HO,{})}),c.jsx("button",{type:"button",className:"composer-skills-btn","aria-label":"Browse skills",title:"Browse skills",disabled:e,onClick:()=>o(R=>!R),children:c.jsx(qO,{})}),c.jsx("button",{type:"button",className:"composer-mic","aria-label":"Voice input",title:"Voice input",disabled:e,onClick:()=>z(!0),children:c.jsx(KO,{})}),c.jsx("span",{className:"composer-toolbar-spacer"}),c.jsx("button",{type:"button",className:"composer-enhance","aria-label":"Enhance prompt",title:"Enhance prompt (⌘/Ctrl+O)",disabled:e||f||r,onClick:()=>void j(),children:f?c.jsx("span",{className:"composer-enhance-spinner","aria-hidden":"true"}):c.jsx(GO,{})}),c.jsx(Ts.Send,{className:"composer-send","aria-label":"Send reply",disabled:e||f,children:c.jsx(WO,{})})]})]}),d?c.jsx(NO,{original:d.original,result:d,onAccept:R=>{n.setText(R),h(u,{review:null})},onClose:()=>h(u,{review:null})}):null,i?c.jsx(MO,{onPick:W,onClose:()=>o(!1)}):null,_?c.jsx(OO,{onCommit:L,onClose:()=>z(!1)}):null]})}function HO(){return c.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:c.jsx("path",{d:"M12 5v14M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})}function WO(){return c.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:c.jsx("path",{d:"M12 19V5M6 11l6-6 6 6",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function qO(){return c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:c.jsx("path",{d:"M7 20L17 4",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round"})})}function KO(){return c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[c.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3",fill:"currentColor"}),c.jsx("path",{d:"M6 11a6 6 0 0 0 12 0M12 17v3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function GO(){return c.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[c.jsx("path",{d:"M12 2 L13.5 9.5 L21 11 L13.5 12.5 L12 20 L10.5 12.5 L3 11 L10.5 9.5 Z",fill:"currentColor",opacity:"0.9"}),c.jsx("path",{d:"M19 2 L19.8 4.2 L22 5 L19.8 5.8 L19 8 L18.2 5.8 L16 5 L18.2 4.2 Z",fill:"currentColor",opacity:"0.6"})]})}const QO={UserMessage:Ka,AssistantMessage:Vn,SystemMessage:Vn};function YO({hasSelection:e,sessionId:t,hiddenCount:n,onLoadEarlier:r}){return c.jsxs(ct.Root,{className:"thread-root",children:[c.jsx("div",{className:"thread-fade","aria-hidden":"true"}),c.jsxs(ct.Viewport,{className:"thread-viewport",autoScroll:!0,children:[e?c.jsx(ct.Empty,{children:c.jsx("div",{className:"thread-empty",children:"no messages yet"})}):c.jsx("div",{className:"thread-empty",children:"select a session"}),e&&n>0?c.jsxs("button",{type:"button",className:"load-earlier",onClick:r,children:["Load earlier messages (",n," hidden)"]}):null,c.jsx(ct.Messages,{components:QO})]}),c.jsx(MS,{disabled:!e,sessionId:t})]})}const JO=256*1024,Ps=40,mm=90,XO=25,ZO=15,e2=95;function t2(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function gm({language:e,content:t,artifactId:n}){const[r,s]=m.useState(null),i=t.length>JO,o=Jd(e),a=!i&&o!==null;return m.useEffect(()=>{if(!a){s(null);return}let l=!0;return s(null),IS(e,t).then(u=>{l&&s(u)}).catch(()=>{l&&s(null)}),()=>{l=!1}},[n,t,a,e]),i?c.jsxs("div",{className:"artifact-body-wrap",children:[c.jsx("p",{className:"artifact-large-note",children:"(large file — shown as plain text)"}),c.jsx("pre",{className:"artifact-pre",children:c.jsx("code",{children:t})})]}):a&&r!==null?c.jsx("div",{className:"artifact-body-wrap",children:c.jsx("pre",{className:"artifact-pre",children:c.jsx("code",{className:"hljs",dangerouslySetInnerHTML:{__html:r}})})}):c.jsx("div",{className:"artifact-body-wrap",children:c.jsx("pre",{className:"artifact-pre",children:c.jsx("code",{className:a?"hljs":void 0,dangerouslySetInnerHTML:{__html:t2(t)}})})})}function n2(){const{artifacts:e,activeId:t,setActive:n,close:r}=Xd(),s=NS(),i=m.useRef(null),o=m.useRef(null),a=m.useId(),[l,u]=m.useState(Ps),f=m.useRef(null),[d,h]=m.useState(!1),p=e.find(I=>I.id===t)??null,g=p!==null;m.useEffect(()=>{g&&u(Ps)},[g]);const x=m.useRef(!1);m.useEffect(()=>{const I=x.current;if(x.current=g,!I&&g&&requestAnimationFrame(()=>{const b=o.current?.querySelector('[role="tab"][aria-selected="true"]');b?b.focus():i.current?.focus()}),I&&!g){const b=document.querySelector(".thread-root");b&&(b.hasAttribute("tabindex")||b.setAttribute("tabindex","-1"),b.focus())}},[g]);const k=m.useCallback(I=>{I.key==="Escape"&&t&&(I.preventDefault(),r(t))},[t,r]),y=m.useCallback(I=>{if(I.key!=="ArrowLeft"&&I.key!=="ArrowRight")return;const b=Array.from(o.current?.querySelectorAll('[role="tab"]')??[]),P=document.activeElement,D=b.indexOf(P);if(D<0)return;const O=I.key==="ArrowRight"?b[(D+1)%b.length]:b[(D-1+b.length)%b.length];O?.focus();const _=O?.dataset.artifactId;_&&n(_)},[n]),v=m.useCallback(I=>{f.current={startY:I.clientY,startH:l},I.currentTarget.setPointerCapture(I.pointerId),h(!0)},[l]),w=m.useCallback(I=>{if(!f.current)return;const{startY:b,startH:P}=f.current,D=(b-I.clientY)/window.innerHeight*100,O=Math.min(e2,Math.max(ZO,P+D));u(O)},[]),E=m.useCallback(I=>{f.current&&(I.currentTarget.releasePointerCapture(I.pointerId),f.current=null,h(!1),u(b=>{if(b<XO)return t&&r(t),Ps;const P=Math.abs(b-Ps),D=Math.abs(b-mm);return P<=D?Ps:mm}))},[t,r]);return g?s?c.jsxs("div",{className:"artifact-panel","data-mode":"sheet",style:{height:`${l}dvh`},"data-dragging":d?"true":"false",role:"region","aria-label":"Artifact panel",ref:i,tabIndex:-1,onKeyDown:k,children:[c.jsx("div",{className:"artifact-drag-handle",role:"separator","aria-label":"Resize panel",onPointerDown:v,onPointerMove:w,onPointerUp:E,children:c.jsx("div",{className:"artifact-drag-pip","aria-hidden":"true"})}),c.jsxs("div",{className:"artifact-panel-head",children:[c.jsx("div",{role:"tablist","aria-label":"Open artifacts",ref:o,className:"artifact-tablist",onKeyDown:y,children:e.map(I=>{const b=I.id===t,P=`artifact-tab-${I.id}`;return c.jsxs("div",{role:"presentation",className:"artifact-tab-wrap",children:[c.jsx("button",{role:"tab",id:P,className:"artifact-tab","aria-selected":b,tabIndex:b?0:-1,"data-artifact-id":I.id,onClick:()=>n(I.id),children:I.title}),c.jsx("button",{className:"artifact-tab-close","aria-label":`Close ${I.title}`,tabIndex:-1,onClick:D=>{D.stopPropagation(),r(I.id)},children:"✕"})]},I.id)})}),c.jsx("button",{className:"artifact-close-all","aria-label":"Close artifact panel",onClick:()=>t&&r(t),children:"×"})]}),p&&c.jsx("div",{role:"tabpanel",id:`${a}-body`,"aria-labelledby":`artifact-tab-${p.id}`,className:"artifact-panel-body",children:c.jsx(gm,{language:p.language,content:p.content,artifactId:p.id})})]}):c.jsxs("div",{className:"artifact-panel",role:"region","aria-label":"Artifact panel",ref:i,tabIndex:-1,onKeyDown:k,children:[c.jsxs("div",{className:"artifact-panel-head",children:[c.jsx("div",{role:"tablist","aria-label":"Open artifacts",ref:o,className:"artifact-tablist",onKeyDown:y,children:e.map(I=>{const b=I.id===t,P=`artifact-tab-${I.id}`;return c.jsxs("div",{role:"presentation",className:"artifact-tab-wrap",children:[c.jsx("button",{role:"tab",id:P,className:"artifact-tab","aria-selected":b,tabIndex:b?0:-1,"data-artifact-id":I.id,onClick:()=>n(I.id),children:I.title}),c.jsx("button",{className:"artifact-tab-close","aria-label":`Close ${I.title}`,tabIndex:-1,onClick:D=>{D.stopPropagation(),r(I.id)},children:"✕"})]},I.id)})}),c.jsx("button",{className:"artifact-close-all","aria-label":"Close artifact panel",onClick:()=>t&&r(t),children:"×"})]}),p&&c.jsx("div",{role:"tabpanel",id:`${a}-body`,"aria-labelledby":`artifact-tab-${p.id}`,className:"artifact-panel-body",children:c.jsx(gm,{language:p.language,content:p.content,artifactId:p.id})})]}):null}const ym=200,r2=2e3;function s2({sessionId:e,capture:t,requestCapture:n,clearCapture:r}){const s=m.useRef(null),i=m.useRef(!0);m.useEffect(()=>{n(ym);const a=setInterval(()=>n(ym),r2);return()=>{clearInterval(a),r()}},[e,n,r]),m.useLayoutEffect(()=>{const a=s.current;a&&i.current&&(a.scrollTop=a.scrollHeight)},[t]);const o=()=>{const a=s.current;a&&(i.current=a.scrollHeight-a.scrollTop-a.clientHeight<24)};return c.jsxs("div",{className:"live-pane",children:[c.jsx("div",{className:"live-pane-head",children:"live pane (no transcript)"}),c.jsx("pre",{className:"live-pane-body",ref:s,onScroll:o,children:t??"capturing live pane…"})]})}function vm(e){return e.questions.map(()=>new Set)}function i2({pending:e,capture:t,onAnswer:n,onCapture:r,onClose:s}){const[i,o]=m.useState(()=>vm(e)),a=m.useRef(null),l=m.useRef(null);m.useEffect(()=>{o(vm(e))},[e]),m.useEffect(()=>(l.current=document.activeElement,(a.current?.querySelector("button:not([disabled]), [tabindex]")??a.current)?.focus(),()=>{l.current?.focus?.()}),[]);const u=m.useMemo(()=>i.length>0&&i.every(p=>p.size>0),[i]),f=(p,g,x)=>{o(k=>{const y=k.map(w=>new Set(w)),v=y[p];return x?v.has(g)?v.delete(g):v.add(g):y[p]=new Set([g]),y})},d=p=>{if(p.key==="Escape"){p.preventDefault(),s();return}if(p.key!=="Tab")return;const g=a.current?.querySelectorAll('button:not([disabled]), [tabindex="0"]');if(!g||g.length===0)return;const x=g[0],k=g[g.length-1];p.shiftKey&&document.activeElement===x?(p.preventDefault(),k.focus()):!p.shiftKey&&document.activeElement===k&&(p.preventDefault(),x.focus())},h=()=>{u&&n(e.toolUseId,i.map(p=>[...p]))};return c.jsx("div",{className:"modal-backdrop",onClick:p=>{p.target===p.currentTarget&&s()},children:c.jsxs("div",{ref:a,className:"modal",role:"dialog","aria-modal":"true","aria-label":"Question from Claude",tabIndex:-1,onKeyDown:d,children:[c.jsxs("div",{className:"modal-head",children:[c.jsx("span",{className:"modal-title",children:"Claude is asking"}),c.jsx("button",{type:"button",className:"modal-close","aria-label":"Close",onClick:s,children:"✕"})]}),c.jsxs("div",{className:"modal-body",children:[e.questions.map((p,g)=>c.jsxs("div",{className:"question",children:[p.header?c.jsx("div",{className:"q-header",children:p.header}):null,c.jsx("div",{className:"q-text",children:p.question}),p.multiSelect?c.jsx("div",{className:"q-hint",children:"select one or more"}):null,c.jsx("div",{className:"q-options",children:p.options.map(x=>{const k=i[g]?.has(x.label);return c.jsxs("button",{type:"button",className:"option-btn","data-on":k?"true":"false","aria-pressed":k,onClick:()=>f(g,x.label,!!p.multiSelect),children:[c.jsx("span",{className:"option-label",children:x.label}),x.description?c.jsx("span",{className:"option-desc",children:x.description}):null]},x.label)})})]},g)),t!=null?c.jsx("pre",{className:"capture-output",children:t}):null]}),c.jsxs("div",{className:"modal-foot",children:[c.jsx("button",{type:"button",className:"btn-secondary",onClick:r,children:"show terminal"}),c.jsx("span",{className:"modal-foot-spacer"}),c.jsx("button",{type:"button",className:"btn-secondary",onClick:s,children:"Cancel"}),c.jsx("button",{type:"button",className:"btn-primary",disabled:!u,onClick:h,children:"send answer"})]})]})})}function o2({toast:e}){const[t,n]=m.useState(!1);return m.useEffect(()=>{if(!e)return;n(!0);const r=setTimeout(()=>n(!1),2200);return()=>clearTimeout(r)},[e]),e?c.jsx("div",{className:`toast ${t?"show":""} ${e.kind?`toast-${e.kind}`:""}`,role:"status","aria-live":"polite",children:e.text}):null}const xm="claude-control-update-dismissed";function a2(e){if(e.latest&&e.latest!==e.current)return`Update available — v${e.latest} (you’re on v${e.current}).`;const t=e.behind||1;return`Update available — ${t} new commit${t===1?"":"s"} (v${e.current}).`}function l2(){const[e,t]=m.useState(null),[n,r]=m.useState(!1);return m.useEffect(()=>{let s=!0;return cw().then(i=>{if(!s||!i?.updateAvailable)return;const o=i.latest??`behind-${i.behind??0}`;localStorage.getItem(xm)!==o&&t({current:i.current,latest:i.latest,behind:i.behind??0})}),()=>{s=!1}},[]),e?n?c.jsx("div",{className:"update-banner",role:"status",children:c.jsx("span",{children:"Updating… the page will reconnect shortly."})}):c.jsxs("div",{className:"update-banner",role:"status",children:[c.jsx("span",{children:a2(e)}),c.jsxs("span",{className:"update-actions",children:[c.jsx("button",{type:"button",className:"update-now",onClick:()=>{r(!0),FI()},children:"Update now"}),c.jsx("button",{type:"button",className:"update-dismiss","aria-label":"Dismiss update notice",onClick:()=>{localStorage.setItem(xm,e.latest??`behind-${e.behind}`),t(null)},children:"×"})]})]}):null}function u2({onClose:e,onToast:t}){const[n,r]=m.useState(""),[s,i]=m.useState(""),[o,a]=m.useState(""),[l,u]=m.useState(""),[f,d]=m.useState("mlx"),[h,p]=m.useState(""),[g,x]=m.useState(null),[k,y]=m.useState(!0),[v,w]=m.useState(!1),[E,I]=m.useState(null),[b,P]=m.useState(()=>Date.now()),[D,O]=m.useState(!1),_=m.useRef(null);m.useEffect(()=>{let j=!0;return cw().then(R=>j&&R&&I(R)).catch(()=>{}),WI().then(R=>j&&x(R)).catch(()=>{}),()=>{j=!1}},[]),m.useEffect(()=>{let j=!0;return GI().then(R=>{j&&(r(R.launchCommand),i(R.defaultCwd),a(R.optimizeModel??""),u(R.claudeBin??""),d(R.optimizeBackend??"mlx"),p(R.mlxModel??""))}).catch(R=>t(`Load config failed: ${R.message}`,"error")).finally(()=>{j&&y(!1)}),()=>{j=!1}},[t]),m.useEffect(()=>{const j=R=>{R.key==="Escape"&&e()};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[e]);const z=async j=>{const R=j.target.files?.[0];if(j.target.value="",!!R){if(R.type!=="image/png"){t("Icon must be a PNG image","error");return}O(!0);try{await VI(R),P(Date.now()),t("App icon updated — re-add to Home Screen to see it","ok")}catch(B){t(`Icon upload failed: ${B.message}`,"error")}finally{O(!1)}}},L=async()=>{O(!0);try{await HI(),P(Date.now()),t("App icon reset to default","ok")}catch(j){t(`Icon reset failed: ${j.message}`,"error")}finally{O(!1)}},W=async()=>{w(!0);try{const j=await QI({launchCommand:n,defaultCwd:s,optimizeModel:o,claudeBin:l,optimizeBackend:f,mlxModel:h});r(j.launchCommand),i(j.defaultCwd),a(j.optimizeModel??""),u(j.claudeBin??""),d(j.optimizeBackend??"mlx"),p(j.mlxModel??"");const R=g?.mlxModels.find(B=>B.id===j.mlxModel);j.optimizeBackend==="mlx"&&R&&R.installed===!1?t(`Downloading ${R.label} (${R.sizeGB} GB)… enhancer uses claude until ready`,"ok"):t("Config saved","ok"),e()}catch(j){t(`Save failed: ${j.message}`,"error")}finally{w(!1)}};return c.jsx("div",{className:"config-overlay",role:"presentation",onClick:j=>{j.target===j.currentTarget&&e()},children:c.jsxs("div",{className:"config-modal",role:"dialog","aria-modal":"true","aria-label":"Settings",children:[c.jsxs("div",{className:"config-head",children:[c.jsx("span",{className:"config-title",children:"Settings"}),c.jsx("button",{type:"button",className:"config-close","aria-label":"Close settings",onClick:e,children:"×"})]}),c.jsxs("div",{className:"config-body",children:[c.jsxs("label",{className:"config-field",children:[c.jsx("span",{className:"config-label",children:"Launch command"}),c.jsx("input",{className:"config-input",type:"text",placeholder:"claude",value:n,disabled:k,onChange:j=>r(j.target.value),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),c.jsx("span",{className:"config-hint",children:"Run in each new session's pane."})]}),c.jsxs("label",{className:"config-field",children:[c.jsx("span",{className:"config-label",children:"Default cwd"}),c.jsx("input",{className:"config-input",type:"text",value:s,disabled:k,onChange:j=>i(j.target.value),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),c.jsx("span",{className:"config-hint",children:"Existing dir new sessions start in."})]}),c.jsxs("label",{className:"config-field",children:[c.jsx("span",{className:"config-label",children:"Enhancer backend"}),c.jsxs("select",{className:"config-input",value:f,disabled:k,onChange:j=>d(j.target.value),children:[c.jsx("option",{value:"mlx",children:"Local MLX (→ claude → rules)"}),c.jsx("option",{value:"claude",children:"claude -p (→ rules)"}),c.jsx("option",{value:"rules",children:"Rules only (offline)"})]}),c.jsxs("span",{className:"config-hint",children:["Powers ✨. ",c.jsx("code",{children:"mlx"})," = on-device, no key."]})]}),c.jsxs("label",{className:"config-field",children:[c.jsx("span",{className:"config-label",children:"Claude model"}),c.jsxs("select",{className:"config-input",value:o,disabled:k,onChange:j=>a(j.target.value),children:[o&&!g?.claudeModels.some(j=>j.id===o)?c.jsxs("option",{value:o,children:[o,g?" (custom)":""]}):null,(g?.claudeModels??[]).map(j=>c.jsxs("option",{value:j.id,children:[j.label,j.id===g?.recommendedClaudeModel?" · recommended":""]},j.id))]}),c.jsxs("span",{className:"config-hint",children:["For the ",c.jsx("code",{children:"claude -p"})," backend/fallback."]})]}),c.jsxs("label",{className:"config-field config-field--wide",children:[c.jsx("span",{className:"config-label",children:"MLX model"}),c.jsxs("select",{className:"config-input",value:h,disabled:k||f!=="mlx",onChange:j=>p(j.target.value),children:[h&&!g?.mlxModels.some(j=>j.id===h)?c.jsxs("option",{value:h,children:[h,g?" (custom)":""]}):null,(g?.mlxModels??[]).map(j=>c.jsxs("option",{value:j.id,children:[j.label," · ",j.sizeGB," GB",j.installed?" · downloaded":" · ⬇ download",j.id===g?.recommendedMlxModel?" · recommended":"",g&&j.minRamGB>g.machine.ramGB?` (needs ≥${j.minRamGB} GB)`:""]},j.id))]}),c.jsx("span",{className:"config-hint",children:g?`Your ${g.machine.appleSilicon?"Apple Silicon ":""}Mac has ${g.machine.ramGB} GB — recommended: ${g.mlxModels.find(j=>j.id===g.recommendedMlxModel)?.label??g.recommendedMlxModel}. Auto-downloads on first use.`:"On-device model for the ✨ enhancer. Auto-downloads on first use."})]}),c.jsxs("label",{className:"config-field config-field--wide",children:[c.jsx("span",{className:"config-label",children:"Claude CLI path (optional)"}),c.jsx("input",{className:"config-input",type:"text",placeholder:"auto-detected",value:l,disabled:k,onChange:j=>u(j.target.value),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),c.jsxs("span",{className:"config-hint",children:["Path to the ",c.jsx("code",{children:"claude"})," binary. Blank = auto-detect."]})]}),c.jsxs("div",{className:"config-field config-field--wide",children:[c.jsx("span",{className:"config-label",children:"App icon"}),c.jsxs("div",{className:"config-icon-row",children:[c.jsx("img",{className:"config-icon-preview",src:`/api/icon?size=192&t=${b}`,alt:"Current home-screen icon",width:44,height:44}),c.jsxs("div",{className:"config-icon-actions",children:[c.jsx("button",{type:"button",className:"config-cancel",disabled:D,onClick:()=>_.current?.click(),children:D?"Working…":"Upload PNG"}),c.jsx("button",{type:"button",className:"config-cancel",disabled:D,onClick:L,children:"Reset"})]}),c.jsx("input",{ref:_,type:"file",accept:"image/png",hidden:!0,onChange:z})]}),c.jsx("span",{className:"config-hint",children:"Defaults to the Claude Control logo. Re-add to Home Screen after changing."})]})]}),c.jsxs("div",{className:"config-foot",children:[c.jsx("div",{className:"config-version",children:E?c.jsxs(c.Fragment,{children:[c.jsxs("span",{children:["claude-control v",E.current]}),E.updateAvailable&&E.latest?c.jsxs("span",{className:"config-version-update",children:["· update available: v",E.latest]}):null]}):null}),c.jsxs("div",{className:"config-actions",children:[c.jsx("button",{type:"button",className:"config-cancel",onClick:e,disabled:v,children:"Cancel"}),c.jsx("button",{type:"button",className:"config-save",onClick:W,disabled:k||v,children:v?"Saving…":"Save"})]})]})]})})}function wm(e=Date.now()){return`session-${e.toString(36).slice(-6)}`}function c2({onToast:e,onOpenSettings:t}){const[n,r]=m.useState(!1),[s,i]=m.useState(""),[o,a]=m.useState(!1),[l,u]=m.useState(wm),f=m.useRef(null);m.useEffect(()=>{n&&(u(wm()),f.current?.focus())},[n]);const d=m.useCallback(()=>{r(!1),i("")},[]),h=m.useCallback(async()=>{if(o)return;a(!0);const p=s.trim()||l;e("Creating session…");try{const g=await YI({name:p});e(`Session created → ${g.name}`,"ok"),d()}catch(g){e(`New session failed: ${g.message}`,"error")}finally{a(!1)}},[o,s,l,e,d]);return n?c.jsxs("form",{className:"rail-new-form","aria-label":"Create session",onSubmit:p=>{p.preventDefault(),h()},children:[c.jsx("input",{ref:f,className:"rail-new-name",type:"text",value:s,placeholder:l,disabled:o,onChange:p=>i(p.target.value),onKeyDown:p=>{p.key==="Escape"&&(p.preventDefault(),d())},"aria-label":"Session name",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),c.jsxs("div",{className:"rail-new-actions",children:[c.jsx("button",{type:"button",className:"rail-new-cancel",onClick:d,disabled:o,children:"Cancel"}),c.jsx("button",{type:"submit",className:"rail-new-create",disabled:o,children:o?"Creating…":"Create"})]})]}):c.jsxs("div",{className:"rail-head",children:[c.jsx("button",{type:"button",className:"rail-new",onClick:()=>r(!0),children:"+ New session"}),c.jsx("button",{type:"button",className:"rail-gear","aria-label":"Settings",title:"Settings",onClick:t,children:"⚙"})]})}function d2(e){return e==="Escape"}function f2({sessionId:e,label:t,onClose:n}){const r=LI(e),s=m.useRef(null);m.useEffect(()=>{const o=a=>{d2(a.key)&&n()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[n]);const i=()=>{s.current?.focus()};return m.useEffect(()=>{i()},[]),c.jsxs("div",{className:"term-overlay",role:"dialog","aria-modal":"true","aria-label":`Raw terminal — ${t}`,children:[c.jsxs("header",{className:"term-head",children:[c.jsxs("span",{className:"term-title",children:[c.jsx("span",{"aria-hidden":"true",children:"⛶"})," ",t]}),c.jsxs("span",{className:"term-actions",children:[c.jsx("a",{className:"term-newtab",href:r,target:"_blank",rel:"noopener noreferrer",title:"Open in a new tab",children:"↗ New tab"}),c.jsx("button",{type:"button",className:"term-close","aria-label":"Close terminal",onClick:n,children:"✕"})]})]}),c.jsx("iframe",{ref:s,className:"term-frame",src:r,title:`Raw terminal for ${t}`,onLoad:i})]})}function h2({children:e}){const[t,n]=m.useState("probing"),[r,s]=m.useState(null),[i,o]=m.useState(""),a=m.useCallback(async()=>{try{return(await je("/api/health")).ok?(n("authed"),s(null),!0):!1}catch{return s("Cannot reach the server. Check the connection and retry."),!1}},[]);m.useEffect(()=>{let u=!1;return(async()=>{const f=await a();u||f||n("needs-token")})(),()=>{u=!0}},[a]),m.useEffect(()=>NI(()=>{n("needs-token"),o(""),s("Session expired — enter your access token again.")}),[]);const l=m.useCallback(async u=>{u.preventDefault();const f=i.trim();if(!f){s("Enter an access token.");return}n("submitting"),s(null),aw(f),await a()||(lw(),n("needs-token"),s("Invalid token."))},[i,a]);return t==="authed"?c.jsx(c.Fragment,{children:e}):t==="probing"?c.jsx("div",{className:"gate-root",role:"status","aria-live":"polite",children:c.jsxs("div",{className:"gate-card gate-card--probing",children:[c.jsx("span",{className:"gate-spinner","aria-hidden":"true"}),c.jsx("span",{className:"gate-probing-text",children:"Connecting…"})]})}):(Ba(),c.jsx("div",{className:"gate-root",children:c.jsxs("form",{className:"gate-card",onSubmit:l,"aria-label":"Sign in",children:[c.jsxs("div",{className:"gate-brand",children:[c.jsx("span",{className:"gate-glyph","aria-hidden":"true",children:"◧"}),c.jsx("span",{className:"gate-title",children:"claude control"})]}),c.jsx("label",{className:"gate-label",htmlFor:"gate-token",children:"Access token"}),c.jsx("input",{id:"gate-token",className:"gate-input",type:"password",autoComplete:"current-password",autoFocus:!0,spellCheck:!1,value:i,onChange:u=>{o(u.target.value),r&&s(null)},"aria-invalid":r?!0:void 0,"aria-describedby":r?"gate-error":void 0,placeholder:"••••••••••••"}),r?c.jsx("p",{id:"gate-error",className:"gate-error",role:"alert",children:r}):null,c.jsx("button",{type:"submit",className:"gate-submit",disabled:t==="submitting",children:t==="submitting"?"Connecting…":"Connect"})]})}))}function p2(e){if(!e)return"";const t=Date.parse(e);return Number.isNaN(t)?"":new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function m2({session:e,onClose:t,onToast:n,onPinned:r}){const[s,i]=m.useState(null),[o,a]=m.useState(""),[l,u]=m.useState(!1);m.useEffect(()=>{let h=!0;return zI().then(p=>h&&i(p)).catch(p=>{h&&(i([]),n(`Couldn't load transcripts: ${p.message}`,"error"))}),()=>{h=!1}},[n]);const f=m.useMemo(()=>{if(!s)return[];const h=o.trim().toLowerCase();return h?s.filter(p=>[p.title,p.cwd,p.sessionId].some(g=>g?.toLowerCase().includes(h))):s},[s,o]),d=async h=>{if(!l){u(!0);try{await OI(e.id,h),n(h?"Pinned →":"Unpinned","ok"),r(),t()}catch(p){n(`Pin failed: ${p.message}`,"error")}finally{u(!1)}}};return c.jsx("div",{className:"modal-backdrop",role:"dialog","aria-modal":"true",onClick:t,children:c.jsxs("div",{className:"modal pin-modal",onClick:h=>h.stopPropagation(),children:[c.jsxs("header",{className:"modal-head",children:[c.jsxs("span",{className:"modal-title",children:["Pin transcript — ",e.name||e.id]}),c.jsx("button",{type:"button",className:"modal-close","aria-label":"Close",onClick:t,children:"×"})]}),e.pinned?c.jsx("button",{type:"button",className:"pin-unpin",disabled:l,onClick:()=>d(null),children:"Unpin (return to auto-match)"}):null,c.jsx("input",{className:"pin-search",type:"text",placeholder:"filter by title, cwd, or session id…",value:o,onChange:h=>a(h.target.value),autoFocus:!0}),c.jsx("div",{className:"pin-list",children:s===null?c.jsx("div",{className:"pin-empty",children:"loading…"}):f.length===0?c.jsx("div",{className:"pin-empty",children:"no transcripts match"}):f.map(h=>{const p=h.transcriptPath===e.transcriptPath;return c.jsxs("button",{type:"button",className:"pin-row","data-current":p?"true":void 0,disabled:l,onClick:()=>d(h.transcriptPath),children:[c.jsxs("span",{className:"pin-row-title",children:[h.title||h.sessionId||h.transcriptPath,p?c.jsx("span",{className:"pin-row-cur",children:" · current"}):null]}),c.jsxs("span",{className:"pin-row-meta",children:[h.cwd?c.jsx("span",{className:"pin-row-cwd",children:h.cwd}):null,c.jsx("span",{className:"pin-row-when",children:p2(h.lastActivity)})]})]},h.transcriptPath)})})]})})}const g2={UserMessage:Ka,AssistantMessage:Vn,SystemMessage:Vn};function y2({markdown:e}){const t=m.useMemo(()=>[{role:"assistant",id:"plan",content:[{type:"text",text:e}],metadata:{custom:{cockpitRole:"assistant"}}}],[e]),n=Oa({messages:t,isDisabled:!0,convertMessage:r=>r,onNew:async()=>{}});return c.jsx(za,{runtime:n,children:c.jsx(ct.Root,{className:"plan-review",children:c.jsx(ct.Viewport,{className:"plan-review-viewport",children:c.jsx(ct.Messages,{components:g2})})})})}function v2({prompt:e,onKey:t,onClose:n,planMarkdown:r}){const s=m.useMemo(()=>e.options.find(x=>x.selected)?.key??e.options[0]?.key??null,[e]),[i,o]=m.useState(s),[a,l]=m.useState(null),u=JSON.stringify(e);m.useEffect(()=>{o(s),l(null)},[u,s]);const f=g=>{a||(l(g),t(g))},d=()=>{i&&f(i)};m.useEffect(()=>{const g=x=>{if(!a){if(x.key==="Escape"){x.preventDefault(),n();return}if(x.key==="Enter"){x.preventDefault(),i&&f(i);return}e.options.some(k=>k.key===x.key)&&(x.preventDefault(),o(x.key))}};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[n,a,i,u]);const h=a!==null,p=!!r;return c.jsx("div",{className:"modal-backdrop",onClick:g=>{g.target===g.currentTarget&&!h&&n()},children:c.jsxs("div",{className:p?"modal modal-plan":"modal",role:"dialog","aria-modal":"true","aria-label":p?"Review plan":"Terminal prompt",children:[c.jsxs("div",{className:"modal-head",children:[c.jsx("span",{className:"modal-title",children:p?"Review plan":"Claude needs a choice"}),c.jsx("button",{type:"button",className:"modal-close","aria-label":"Hide",onClick:n,children:"✕"})]}),c.jsxs("div",{className:"modal-body",children:[p?c.jsx(y2,{markdown:r}):null,c.jsxs("div",{className:"question",children:[p?null:c.jsx("div",{className:"q-text",children:e.question}),c.jsx("div",{className:"q-options",role:"radiogroup","aria-label":"Options",children:e.options.map(g=>c.jsxs("button",{type:"button",className:"option-btn",role:"radio","aria-checked":i===g.key,"data-on":i===g.key?"true":"false","data-sending":a===g.key?"true":void 0,disabled:h,onClick:()=>o(g.key),children:[c.jsxs("span",{className:"option-label",children:[g.key,". ",g.label]}),a===g.key?c.jsxs("span",{className:"option-sending","aria-live":"polite",children:[c.jsx("span",{className:"working-spinner","aria-hidden":"true"})," sending…"]}):null]},g.key))})]})]}),c.jsxs("div",{className:"modal-foot",children:[c.jsxs("button",{type:"button",className:"btn-secondary",disabled:h,onClick:()=>f("Escape"),children:["Cancel ",c.jsx(ma,{children:"Esc"})]}),c.jsx("span",{className:"modal-foot-spacer"}),h?c.jsx("span",{className:"prompt-status",children:"submitting your answer…"}):null,c.jsxs("button",{type:"button",className:"btn-primary",disabled:h||!i,onClick:d,children:["Confirm ",c.jsx(ma,{children:"↵"})]})]})]})})}const x2={UserMessage:Ka,AssistantMessage:Vn,SystemMessage:Vn};function w2({messages:e}){const t=m.useMemo(()=>hw(e),[e]),n=Oa({messages:t,isDisabled:!0,convertMessage:r=>r,onNew:async()=>{}});return c.jsx(za,{runtime:n,children:c.jsx(ct.Root,{className:"sa-thread-root",children:c.jsxs(ct.Viewport,{className:"sa-thread-viewport",autoScroll:!0,children:[c.jsx(ct.Empty,{children:c.jsx("div",{className:"thread-empty",children:"no output yet…"})}),c.jsx(ct.Messages,{components:x2})]})})})}const S2={active:"Active",completed:"Completed",all:"All"};function LS(e){return e.model?e.model:e.def?.model?e.def.model:null}function Zd({agentType:e,model:t}){return c.jsxs("span",{className:"agent-chip",children:[c.jsx("span",{className:"agent-chip-name",children:e||"sub-agent"}),t?c.jsx("span",{className:"agent-chip-model",children:t}):null]})}function b2({def:e,agentType:t}){if(!e)return c.jsx("div",{className:"agent-def",children:c.jsx("span",{className:"agent-def-no-def",children:t||"sub-agent"})});const n=new Set(["name","description","tools","model"]),r=Object.keys(e).filter(s=>!n.has(s));return c.jsxs("div",{className:"agent-def",children:[e.description?c.jsx("div",{className:"agent-def-row agent-def-desc",children:e.description}):null,e.tools?c.jsxs("div",{className:"agent-def-row",children:[c.jsx("span",{className:"agent-def-label",children:"tools"}),c.jsx("span",{className:"agent-def-val agent-def-tools",children:e.tools})]}):null,e.model?c.jsxs("div",{className:"agent-def-row",children:[c.jsx("span",{className:"agent-def-label",children:"model"}),c.jsx("span",{className:"agent-def-val",children:e.model})]}):null,r.map(s=>c.jsxs("div",{className:"agent-def-row",children:[c.jsx("span",{className:"agent-def-label",children:s}),c.jsx("span",{className:"agent-def-val",children:e[s]})]},s))]})}function k2({nested:e}){return!e||e.length===0?null:c.jsxs("div",{className:"agent-nested",children:[c.jsxs("span",{className:"agent-nested-label",children:["nested (",e.length,")"]}),c.jsx("div",{className:"agent-nested-list",children:e.map(t=>c.jsx(Zd,{agentType:t.agentType,model:t.model},t.agentId))})]})}function C2({agent:e}){const t=LS(e);return c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"sa-dot","data-status":e.status,"aria-hidden":"true"}),c.jsx(Zd,{agentType:e.agentType,model:t}),e.description?c.jsx("span",{className:"sa-desc",children:e.description}):null,c.jsx("span",{className:"sa-status",children:e.status==="running"?"· running":"· done"})]})}function _2({subagents:e,open:t,onClose:n}){const[r,s]=m.useState("active"),[i,o]=m.useState(null),a=e.filter(d=>d.status==="running").length,l={active:a,completed:e.length-a,all:e.length},u=i?e.find(d=>d.agentId===i)??null:null,f=m.useMemo(()=>e.filter(d=>r==="all"?!0:r==="active"?d.status==="running":d.status==="done"),[e,r]);if(!t)return null;if(u){const d=LS(u);return c.jsxs("div",{className:"sa-panel",role:"complementary","aria-label":"Sub-agent transcript",children:[c.jsxs("header",{className:"sa-panel-head",children:[c.jsx("button",{type:"button",className:"sa-back","aria-label":"Back to list",onClick:()=>o(null),children:"‹"}),c.jsxs("span",{className:"sa-panel-title sa-detail-title",children:[c.jsx("span",{className:"sa-dot","data-status":u.status,"aria-hidden":"true"}),c.jsx(Zd,{agentType:u.agentType,model:d}),c.jsx("span",{className:"sa-status",children:u.status==="running"?"· running":"· done"})]}),c.jsx("button",{type:"button",className:"sa-panel-close","aria-label":"Close",onClick:n,children:"×"})]}),c.jsx(b2,{def:u.def,agentType:u.agentType}),c.jsx(k2,{nested:u.nested}),c.jsx(w2,{messages:u.messages})]})}return c.jsxs("div",{className:"sa-panel",role:"complementary","aria-label":"Sub-agents",children:[c.jsxs("header",{className:"sa-panel-head",children:[c.jsxs("span",{className:"sa-panel-title",children:["Sub-agents ",c.jsx("span",{className:"sa-count",children:e.length}),a?c.jsxs("span",{className:"sa-count-running",children:[a," running"]}):null]}),c.jsx("button",{type:"button",className:"sa-panel-close","aria-label":"Close sub-agents panel",onClick:n,children:"×"})]}),c.jsx("div",{className:"sa-tabs",role:"tablist",children:["active","completed","all"].map(d=>c.jsxs("button",{type:"button",role:"tab","aria-selected":r===d,className:"sa-tab","data-on":r===d?"true":void 0,onClick:()=>s(d),children:[S2[d],c.jsx("span",{className:"sa-tab-count",children:l[d]})]},d))}),c.jsx("div",{className:"sa-panel-body",children:f.length===0?c.jsxs("div",{className:"sa-empty",children:["No ",r==="all"?"":`${r} `,"sub-agents."]}):f.map(d=>c.jsxs("button",{type:"button",className:"sa-item-row",onClick:()=>o(d.agentId),children:[c.jsx(C2,{agent:d}),c.jsx("span",{className:"sa-chevron","aria-hidden":"true",children:"›"})]},d.agentId))})]})}function E2(e){return(e.blocks??[]).filter(t=>t.kind==="text").map(t=>t.text).join(" ")}const T2=18e5,DS="cc_drafts";function I2(){try{return JSON.parse(localStorage.getItem(DS)||"{}")||{}}catch{return{}}}function R2(e){try{localStorage.setItem(DS,JSON.stringify(e))}catch{}}const Sm=150,P2=150;function A2(e){return typeof e.content=="string"?e.content:e.content.filter(t=>t.type==="text").map(t=>t.text).join(`
85
- `)}function j2(){const e=sR(),t=aR(),[n,r]=m.useState(null),s=m.useRef(0),i=m.useCallback((H,ee="")=>{r({id:++s.current,text:H,kind:ee})},[]);m.useEffect(()=>{const H=ee=>{const ne=ee.detail;ne.ok?ne.op==="answer"&&i("Answer sent →","ok"):i(`${ne.op} failed: ${ne.error??"error"}`,"error")};return window.addEventListener("cockpit:ack",H),()=>window.removeEventListener("cockpit:ack",H)},[i]);const o=m.useMemo(()=>kR(i),[i]),[a,l]=m.useState([]),u=m.useRef(0),[f,d]=m.useState(null),h=m.useCallback(async H=>{const ee=A2(H).trim(),ne=(H.attachments??[]).map(it=>SR(it)).filter(it=>!!it),Ee=[ee,...ne].filter(Boolean).join(" ");if(!Ee)return;const sn=e.sendReply(Ee);if(i(sn?"Sent →":"Not connected — reconnecting…",sn?"ok":"error"),sn&&e.selectedId){const it=ee||(ne.length?`📎 ${ne.length} attachment(s)`:Ee);l(Wt=>[...Wt,{key:++u.current,sessionId:e.selectedId,text:Ee,label:it,at:Date.now()}])}},[e,i]),p=m.useRef({});m.useEffect(()=>{const H=e.selectedId;if(!H)return;const ee=e.messages,ne=p.current[H],Ee=ne==null?ee.length:Math.min(ne,ee.length);if(ee.length>Ee){const sn=[];for(let it=Ee;it<ee.length;it++){if(ee[it].role!=="user")continue;const Wt=E2(ee[it]).trim();Wt&&sn.push(Wt)}sn.length&&l(it=>{const Wt=[...it];for(const Qa of sn){const Ni=Wt.findIndex(M=>M.sessionId===H&&M.text.trim()===Qa);Ni>=0&&Wt.splice(Ni,1)}return Wt})}p.current[H]=ee.length},[e.selectedId,e.messages]),m.useEffect(()=>{if(a.length===0)return;const H=setInterval(()=>{const ee=Date.now()-T2;l(ne=>ne.some(Ee=>Ee.at<ee)?ne.filter(Ee=>Ee.at>=ee):ne)},5e3);return()=>clearInterval(H)},[a.length]),m.useEffect(()=>{if(!f)return;if(e.selectedId!==f.sessionId||e.messages.length>f.baseCount){d(null);return}const H=setTimeout(()=>d(null),9e4);return()=>clearTimeout(H)},[f,e.selectedId,e.messages.length]);const[g,x]=m.useState(Sm);m.useEffect(()=>{x(Sm)},[e.selectedId]);const k=m.useMemo(()=>hw(e.messages),[e.messages]),y=Math.max(0,k.length-g),v=m.useMemo(()=>a.filter(H=>H.sessionId===e.selectedId),[a,e.selectedId]),w=m.useMemo(()=>{if(!e.prompt)return null;const H=e.messages;for(let ee=H.length-1;ee>=0;ee--)for(const ne of H[ee].blocks??[])if(ne.kind==="tool_use"&&ne.name==="ExitPlanMode"){const Ee=ne.input?.plan;if(typeof Ee=="string"&&Ee.trim())return Ee}return null},[e.prompt,e.messages]),E=m.useMemo(()=>{const H=y>0?k.slice(y):k.slice();for(const ne of v)H.push({role:"user",id:`queued-${ne.key}`,content:[{type:"text",text:ne.label}],metadata:{custom:{cockpitRole:"user",optimistic:!0}}});return(v.length>0||f!==null&&f.sessionId===e.selectedId)&&H.push({role:"assistant",id:"optimistic-working",content:[{type:"text",text:"Working…"}],metadata:{custom:{cockpitRole:"assistant",working:!0}}}),H},[k,y,e.selectedId,v,f]),I=m.useCallback(()=>{x(H=>H+P2)},[]),b=Oa({messages:E,isDisabled:!e.selectedId,convertMessage:H=>H,onNew:h,adapters:{attachments:o}}),P=m.useRef(I2()),D=m.useRef(e.selectedId);m.useEffect(()=>{const H=b.thread.composer,ee=()=>{const ne=D.current;if(!ne)return;const Ee=H.getState().text??"";Ee?P.current[ne]=Ee:delete P.current[ne],R2(P.current)};return H.subscribe(ee)},[b]),m.useEffect(()=>{const H=b.thread.composer,ee=e.selectedId,ne=ee?P.current[ee]??"":"";D.current=ee;try{H.reset(),ne&&H.setText(ne)}catch{}},[e.selectedId,b]);const[O,_]=m.useState(null),[z,L]=m.useState(!1),[W,j]=m.useState(null),[R,B]=m.useState(!1),[K,A]=m.useState(!1),[N,S]=m.useState(null);m.useEffect(()=>{B(!1),A(!1)},[e.selectedId]);const[G,Y]=m.useState(null),C=m.useRef(null),ve=G!==null;m.useEffect(()=>{ve&&C.current?.select()},[ve]);const Re=m.useCallback(async()=>{const H=e.selectedId,ee=(G??"").trim();if(Y(null),!(!H||!ee))try{await JI(H,ee),i("Renamed →","ok")}catch(ne){i(`rename failed: ${ne instanceof Error?ne.message:"error"}`,"error")}},[e.selectedId,G,i]),[ue,De]=m.useState(!0),rt=m.useCallback(H=>{e.select(H),De(!1),window.location.hash=encodeURIComponent(H)},[e]);m.useEffect(()=>{if(!("serviceWorker"in navigator))return;const H=ee=>{const ne=ee.data;ne?.type==="open-session"&&ne.id&&rt(ne.id)};return navigator.serviceWorker.addEventListener("message",H),()=>navigator.serviceWorker.removeEventListener("message",H)},[rt]);const Ne=typeof window<"u"&&(window.matchMedia?.("(display-mode: standalone)").matches||navigator.standalone===!0),Ye=t.iosHint&&!Ne&&t.status!=="on",st=m.useRef(!1);m.useEffect(()=>{const H=()=>{const ee=decodeURIComponent(window.location.hash.replace(/^#/,""));ee&&ee!==e.selectedId&&e.sessions.some(ne=>ne.id===ee)&&(e.select(ee),De(!1))};return!st.current&&e.sessions.length>0&&(st.current=!0,H()),window.addEventListener("hashchange",H),()=>window.removeEventListener("hashchange",H)},[e,e.sessions,e.selectedId]);const Ce=e.sessions.find(H=>H.id===e.selectedId),Ga=Ce?.thinking&&k.length>0?k[k.length-1].id??null:null,ji=m.useRef(null),{pull:kr,refreshing:Cr}=dR(ji);return c.jsx(za,{runtime:b,children:c.jsx(XD,{children:c.jsxs("div",{ref:ji,className:"app","data-detail":e.selectedId&&!ue?"open":"closed",children:[kr>0||Cr?c.jsx("div",{className:"ptr-indicator",style:{transform:`translate(-50%, ${Math.round(kr)}px)`},"data-ready":!Cr&&kr>=fR?"true":void 0,"data-refreshing":Cr?"true":void 0,"aria-hidden":"true",children:c.jsx("span",{className:"ptr-spinner"})}):null,c.jsx("div",{className:"app-top-fade","aria-hidden":"true"}),c.jsx(PR,{resources:e.resources,conn:e.conn,push:t}),c.jsx(l2,{}),Ye?c.jsx("div",{className:"ios-push-hint",role:"note",children:"On iPhone/iPad, add this site to your Home Screen to receive push notifications."}):null,c.jsxs("div",{className:"app-body",children:[c.jsxs("aside",{className:"rail",children:[c.jsx(c2,{onToast:i,onOpenSettings:()=>L(!0)}),c.jsx(ER,{sessions:e.sessions,selectedId:e.selectedId,onSelect:rt})]}),c.jsxs("main",{className:"detail",children:[c.jsxs("header",{className:"detail-head",children:[c.jsx("button",{type:"button",className:"back-btn","aria-label":"Back to sessions",onClick:()=>De(!0),children:"‹"}),c.jsxs("div",{className:"detail-title",children:[G!==null?c.jsx("input",{ref:C,className:"detail-rename-input",type:"text",value:G,"aria-label":"Session name",onChange:H=>Y(H.target.value),onKeyDown:H=>{H.key==="Enter"?(H.preventDefault(),Re()):H.key==="Escape"&&(H.preventDefault(),Y(null))},onBlur:()=>void Re()}):c.jsxs("span",{className:"detail-name-row",children:[c.jsx("span",{className:"detail-name",children:Ce?.name||e.selectedId||"claude control"}),Ce?c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",className:"rename-btn","aria-label":"Rename session",title:"Rename session",onClick:()=>Y(Ce.name??Ce.id),children:"✎"}),c.jsx("button",{type:"button",className:"rename-btn term-btn","aria-label":"Open raw terminal",title:"Raw terminal",onClick:()=>j(Ce.id),children:"⛶"}),c.jsx("button",{type:"button",className:"rename-btn pin-btn","aria-pressed":!!Ce.pinned,"aria-label":Ce.pinned?"Transcript pinned":"Pin a transcript",title:Ce.pinned?"Transcript pinned":"Pin a transcript",onClick:()=>B(!0),children:Ce.pinned?"📌":"📍"}),e.subagents.length>0?c.jsxs("button",{type:"button",className:"rename-btn agents-btn","aria-pressed":K,title:"Sub-agents",onClick:()=>A(H=>!H),children:["🤖 ",e.subagents.length]}):null]}):null]}),Ce?.cwd?c.jsx("span",{className:"detail-cwd",children:Ce.cwd}):null]})]}),Ce&&!Ce.transcriptPath?c.jsxs("div",{className:"thread-root",children:[c.jsx("div",{className:"thread-fade","aria-hidden":"true"}),c.jsx(s2,{sessionId:Ce.id,capture:e.capture,requestCapture:e.requestCapture,clearCapture:e.clearCapture}),c.jsx(MS,{disabled:!1,sessionId:e.selectedId})]}):c.jsxs("div",{className:"detail-split",children:[c.jsx(PS.Provider,{value:Ga,children:c.jsx(YO,{hasSelection:!!e.selectedId,sessionId:e.selectedId,hiddenCount:y,onLoadEarlier:I})}),c.jsx(n2,{})]})]})]}),e.pending&&e.pending.toolUseId!==O?c.jsx(i2,{pending:e.pending,capture:e.capture,onAnswer:(H,ee)=>{e.sendAnswer(H,ee),_(H),e.clearCapture(),e.selectedId&&d({sessionId:e.selectedId,baseCount:e.messages.length})},onCapture:e.requestCapture,onClose:()=>{_(e.pending?.toolUseId??null),e.clearCapture()}},e.pending.toolUseId):null,z?c.jsx(u2,{onClose:()=>L(!1),onToast:i}):null,W?c.jsx(f2,{sessionId:W,label:e.sessions.find(H=>H.id===W)?.name??W,onClose:()=>j(null)},W):null,c.jsx(_2,{subagents:e.subagents,open:K&&e.subagents.length>0,onClose:()=>A(!1)}),R&&Ce?c.jsx(m2,{session:Ce,onClose:()=>B(!1),onToast:i,onPinned:()=>e.resubscribe()}):null,e.prompt&&!e.pending&&JSON.stringify(e.prompt)!==N?c.jsx(v2,{prompt:e.prompt,planMarkdown:w,onKey:H=>e.sendPromptKey(H),onClose:()=>S(JSON.stringify(e.prompt))}):null,c.jsx(o2,{toast:n})]})})})}function N2(){return c.jsx(h2,{children:c.jsx(j2,{})})}const OS=document.getElementById("root");if(!OS)throw new Error("#root not found");My(OS).render(c.jsx(m.StrictMode,{children:c.jsx(N2,{})}));export{ki as g};