@cjhyy/code-shell-web 0.9.44 → 0.9.47

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,57 +0,0 @@
1
- (function(){const i=document.createElement("link").relList;if(i&&i.supports&&i.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))a(u);new MutationObserver(u=>{for(const d of u)if(d.type==="childList")for(const c of d.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&a(c)}).observe(document,{childList:!0,subtree:!0});function r(u){const d={};return u.integrity&&(d.integrity=u.integrity),u.referrerPolicy&&(d.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?d.credentials="include":u.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function a(u){if(u.ep)return;u.ep=!0;const d=r(u);fetch(u.href,d)}})();function ko(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Gc={exports:{}},pa={};var Lg;function E1(){if(Lg)return pa;Lg=1;var t=Symbol.for("react.transitional.element"),i=Symbol.for("react.fragment");function r(a,u,d){var c=null;if(d!==void 0&&(c=""+d),u.key!==void 0&&(c=""+u.key),"key"in u){d={};for(var h in u)h!=="key"&&(d[h]=u[h])}else d=u;return u=d.ref,{$$typeof:t,type:a,key:c,ref:u!==void 0?u:null,props:d}}return pa.Fragment=i,pa.jsx=r,pa.jsxs=r,pa}var Bg;function N1(){return Bg||(Bg=1,Gc.exports=E1()),Gc.exports}var s=N1(),Vc={exports:{}},$e={};var Ug;function T1(){if(Ug)return $e;Ug=1;var t=Symbol.for("react.transitional.element"),i=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function x(O){return O===null||typeof O!="object"?null:(O=v&&O[v]||O["@@iterator"],typeof O=="function"?O:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},R=Object.assign,C={};function A(O,re,E){this.props=O,this.context=re,this.refs=C,this.updater=E||j}A.prototype.isReactComponent={},A.prototype.setState=function(O,re){if(typeof O!="object"&&typeof O!="function"&&O!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,O,re,"setState")},A.prototype.forceUpdate=function(O){this.updater.enqueueForceUpdate(this,O,"forceUpdate")};function _(){}_.prototype=A.prototype;function D(O,re,E){this.props=O,this.context=re,this.refs=C,this.updater=E||j}var q=D.prototype=new _;q.constructor=D,R(q,A.prototype),q.isPureReactComponent=!0;var ae=Array.isArray;function N(){}var U={H:null,A:null,T:null,S:null},X=Object.prototype.hasOwnProperty;function H(O,re,E){var J=E.ref;return{$$typeof:t,type:O,key:re,ref:J!==void 0?J:null,props:E}}function T(O,re){return H(O.type,re,O.props)}function I(O){return typeof O=="object"&&O!==null&&O.$$typeof===t}function L(O){var re={"=":"=0",":":"=2"};return"$"+O.replace(/[=:]/g,function(E){return re[E]})}var F=/\/+/g;function W(O,re){return typeof O=="object"&&O!==null&&O.key!=null?L(""+O.key):re.toString(36)}function ee(O){switch(O.status){case"fulfilled":return O.value;case"rejected":throw O.reason;default:switch(typeof O.status=="string"?O.then(N,N):(O.status="pending",O.then(function(re){O.status==="pending"&&(O.status="fulfilled",O.value=re)},function(re){O.status==="pending"&&(O.status="rejected",O.reason=re)})),O.status){case"fulfilled":return O.value;case"rejected":throw O.reason}}throw O}function V(O,re,E,J,be){var Z=typeof O;(Z==="undefined"||Z==="boolean")&&(O=null);var ne=!1;if(O===null)ne=!0;else switch(Z){case"bigint":case"string":case"number":ne=!0;break;case"object":switch(O.$$typeof){case t:case i:ne=!0;break;case y:return ne=O._init,V(ne(O._payload),re,E,J,be)}}if(ne)return be=be(O),ne=J===""?"."+W(O,0):J,ae(be)?(E="",ne!=null&&(E=ne.replace(F,"$&/")+"/"),V(be,re,E,"",function(ve){return ve})):be!=null&&(I(be)&&(be=T(be,E+(be.key==null||O&&O.key===be.key?"":(""+be.key).replace(F,"$&/")+"/")+ne)),re.push(be)),1;ne=0;var ge=J===""?".":J+":";if(ae(O))for(var P=0;P<O.length;P++)J=O[P],Z=ge+W(J,P),ne+=V(J,re,E,Z,be);else if(P=x(O),typeof P=="function")for(O=P.call(O),P=0;!(J=O.next()).done;)J=J.value,Z=ge+W(J,P++),ne+=V(J,re,E,Z,be);else if(Z==="object"){if(typeof O.then=="function")return V(ee(O),re,E,J,be);throw re=String(O),Error("Objects are not valid as a React child (found: "+(re==="[object Object]"?"object with keys {"+Object.keys(O).join(", ")+"}":re)+"). If you meant to render a collection of children, use an array instead.")}return ne}function B(O,re,E){if(O==null)return O;var J=[],be=0;return V(O,J,"","",function(Z){return re.call(E,Z,be++)}),J}function Q(O){if(O._status===-1){var re=O._result;re=re(),re.then(function(E){(O._status===0||O._status===-1)&&(O._status=1,O._result=E)},function(E){(O._status===0||O._status===-1)&&(O._status=2,O._result=E)}),O._status===-1&&(O._status=0,O._result=re)}if(O._status===1)return O._result.default;throw O._result}var fe=typeof reportError=="function"?reportError:function(O){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var re=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof O=="object"&&O!==null&&typeof O.message=="string"?String(O.message):String(O),error:O});if(!window.dispatchEvent(re))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",O);return}console.error(O)},k={map:B,forEach:function(O,re,E){B(O,function(){re.apply(this,arguments)},E)},count:function(O){var re=0;return B(O,function(){re++}),re},toArray:function(O){return B(O,function(re){return re})||[]},only:function(O){if(!I(O))throw Error("React.Children.only expected to receive a single React element child.");return O}};return $e.Activity=b,$e.Children=k,$e.Component=A,$e.Fragment=r,$e.Profiler=u,$e.PureComponent=D,$e.StrictMode=a,$e.Suspense=p,$e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=U,$e.__COMPILER_RUNTIME={__proto__:null,c:function(O){return U.H.useMemoCache(O)}},$e.cache=function(O){return function(){return O.apply(null,arguments)}},$e.cacheSignal=function(){return null},$e.cloneElement=function(O,re,E){if(O==null)throw Error("The argument must be a React element, but you passed "+O+".");var J=R({},O.props),be=O.key;if(re!=null)for(Z in re.key!==void 0&&(be=""+re.key),re)!X.call(re,Z)||Z==="key"||Z==="__self"||Z==="__source"||Z==="ref"&&re.ref===void 0||(J[Z]=re[Z]);var Z=arguments.length-2;if(Z===1)J.children=E;else if(1<Z){for(var ne=Array(Z),ge=0;ge<Z;ge++)ne[ge]=arguments[ge+2];J.children=ne}return H(O.type,be,J)},$e.createContext=function(O){return O={$$typeof:c,_currentValue:O,_currentValue2:O,_threadCount:0,Provider:null,Consumer:null},O.Provider=O,O.Consumer={$$typeof:d,_context:O},O},$e.createElement=function(O,re,E){var J,be={},Z=null;if(re!=null)for(J in re.key!==void 0&&(Z=""+re.key),re)X.call(re,J)&&J!=="key"&&J!=="__self"&&J!=="__source"&&(be[J]=re[J]);var ne=arguments.length-2;if(ne===1)be.children=E;else if(1<ne){for(var ge=Array(ne),P=0;P<ne;P++)ge[P]=arguments[P+2];be.children=ge}if(O&&O.defaultProps)for(J in ne=O.defaultProps,ne)be[J]===void 0&&(be[J]=ne[J]);return H(O,Z,be)},$e.createRef=function(){return{current:null}},$e.forwardRef=function(O){return{$$typeof:h,render:O}},$e.isValidElement=I,$e.lazy=function(O){return{$$typeof:y,_payload:{_status:-1,_result:O},_init:Q}},$e.memo=function(O,re){return{$$typeof:m,type:O,compare:re===void 0?null:re}},$e.startTransition=function(O){var re=U.T,E={};U.T=E;try{var J=O(),be=U.S;be!==null&&be(E,J),typeof J=="object"&&J!==null&&typeof J.then=="function"&&J.then(N,fe)}catch(Z){fe(Z)}finally{re!==null&&E.types!==null&&(re.types=E.types),U.T=re}},$e.unstable_useCacheRefresh=function(){return U.H.useCacheRefresh()},$e.use=function(O){return U.H.use(O)},$e.useActionState=function(O,re,E){return U.H.useActionState(O,re,E)},$e.useCallback=function(O,re){return U.H.useCallback(O,re)},$e.useContext=function(O){return U.H.useContext(O)},$e.useDebugValue=function(){},$e.useDeferredValue=function(O,re){return U.H.useDeferredValue(O,re)},$e.useEffect=function(O,re){return U.H.useEffect(O,re)},$e.useEffectEvent=function(O){return U.H.useEffectEvent(O)},$e.useId=function(){return U.H.useId()},$e.useImperativeHandle=function(O,re,E){return U.H.useImperativeHandle(O,re,E)},$e.useInsertionEffect=function(O,re){return U.H.useInsertionEffect(O,re)},$e.useLayoutEffect=function(O,re){return U.H.useLayoutEffect(O,re)},$e.useMemo=function(O,re){return U.H.useMemo(O,re)},$e.useOptimistic=function(O,re){return U.H.useOptimistic(O,re)},$e.useReducer=function(O,re,E){return U.H.useReducer(O,re,E)},$e.useRef=function(O){return U.H.useRef(O)},$e.useState=function(O){return U.H.useState(O)},$e.useSyncExternalStore=function(O,re,E){return U.H.useSyncExternalStore(O,re,E)},$e.useTransition=function(){return U.H.useTransition()},$e.version="19.2.6",$e}var Ig;function mf(){return Ig||(Ig=1,Vc.exports=T1()),Vc.exports}var A1=mf();const S=ko(A1);let _a,Co=null;const R1=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,Lb=/^\/p\/([0-9a-f-]{36})(\/.*)$/;function xl(t){return typeof t=="string"&&R1.test(t)}function Ks(t){if(t!==null&&!xl(t))throw new Error("项目标识无效。");Co=t}function Ta(){return Co}function mo(){return{workspace:_a??"",projectId:Co}}function Zs(t){_a=void 0}function go(){return _a}function qg(t=_a){return t?{"X-CodeShell-Workspace":encodeURIComponent(t)}:{}}function Bb(t){return/^\/api\/v1\/(?:auth|projects|environment)(?:\/|\?|$)/.test(t)||/^\/api\/v1\/cloud-browser\/environment(?:\?|$)/.test(t)||/^\/api\/v1\/desktop\/session(?:\?|$)/.test(t)}function z1(t){const i=Lb.exec(t);return!!i&&xl(i[1])}function kt(t,i=_a,r=Co){const a=Lb.exec(t),u=a?a[2]:t;if(a&&!xl(a[1])||!u.startsWith("/api/v1/")&&u!=="/ws"||/[\\\r\n]/.test(t))throw new Error("Workspace URLs must use the local API");const d=new URL(u,"http://codeshell.invalid");if(d.pathname!==u.split(/[?#]/,1)[0])throw new Error("Workspace URLs must use the local API");if(Bb(u))return u;if(a)return t;if(r!==null&&!xl(r))throw new Error("项目标识无效。");return i&&u.startsWith("/api/v1/")&&d.searchParams.set("workspace",i),`${r?`/p/${r}`:""}${d.pathname}${d.search}${d.hash}`}class Ze extends Error{constructor(i,r,a,u){super(i),this.status=r,this.code=a,this.retryAfterMs=u}status;code;retryAfterMs}class Ub extends Error{constructor(){super("服务端返回了无效的登录状态,请稍后重试。")}}async function Ue(t,i={},r){const a=r?qg(r.workspace):qg(),u={...i};if(Object.keys(a).length&&!Bb(t)&&!z1(t)&&!t.includes("workspace=")){const h=new Headers(i.headers);for(const[p,m]of Object.entries(a))h.has(p)||h.set(p,m);u.headers=h}const d=await fetch(r?kt(t,r.workspace,r.projectId):kt(t,""),{...u,credentials:"same-origin",cache:"no-store"}),c=await d.json().catch(()=>({}));if(!d.ok){const h=typeof c.error=="string"?c.error:c.error?.message;throw new Ze(h??c.message??`请求失败(${d.status})`,d.status,typeof c.code=="string"?c.code:void 0,typeof c.retryAfterMs=="number"?c.retryAfterMs:void 0)}return c}function Pd(t,i={}){return Ue(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}async function _1(){try{const t=await Ue("/api/v1/auth/status"),i=()=>new Ub;if(!t||typeof t.initialized!="boolean"||typeof t.authenticated!="boolean"||t.mode!==void 0&&t.mode!=="cloud-account")throw i();if(t.mode==="cloud-account"){if(!t.initialized||!t.authenticated&&t.session!==void 0)throw i();let r;if(t.authenticated){const a=t.session,u=/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/,d=c=>{if(typeof c!="string")return!1;try{const h=new URL(c);return h.origin===c&&!h.username&&!h.password&&(h.protocol==="https:"||h.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(h.hostname))}catch{return!1}};if(!a||Array.isArray(a)||a.kind!=="cloud-management"||![a.id,a.installationId,a.accountId,a.managementEpoch].every(c=>typeof c=="string"&&u.test(c))||!d(a.audience)||!d(a.accountOrigin)||typeof window<"u"&&a.audience!==window.location.origin||!Number.isSafeInteger(a.expiresAt)||a.expiresAt<=Date.now())throw i();r={id:a.id,kind:"cloud-management",audience:a.audience,installationId:a.installationId,accountOrigin:a.accountOrigin,accountId:a.accountId,managementEpoch:a.managementEpoch,expiresAt:a.expiresAt}}return{initialized:!0,authenticated:t.authenticated,mode:"cloud-account",...r?{cloudSession:r}:{}}}return{initialized:t.initialized,authenticated:t.authenticated,...t.host==="hub"||t.host==="desktop"?{host:t.host}:{},...t.session?{session:t.session}:{}}}catch(t){if(t instanceof Ze&&t.status===404)return null;throw t}}function D1(t,i){const r=new URLSearchParams(t.hash.replace(/^#/,"")),a=r.get("setup")??"";if(r.has("setup")){r.delete("setup");const u=r.toString();i.replaceState(i.state,"",`${t.pathname}${t.search}${u?`#${u}`:""}`)}return a}function Da(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const t=crypto.getRandomValues(new Uint8Array(16));t[6]=t[6]&15|64,t[8]=t[8]&63|128;const i=Array.from(t,r=>r.toString(16).padStart(2,"0")).join("");return`${i.slice(0,8)}-${i.slice(8,12)}-${i.slice(12,16)}-${i.slice(16,20)}-${i.slice(20)}`}async function M1(t,i={}){const r=i.scope??mo();return Ue(kt(`/api/v1/uploads/${Da()}`,r.workspace,r.projectId),{method:"PUT",headers:{"Content-Type":t.type||"application/octet-stream","X-File-Name":encodeURIComponent(t.name)},body:t,signal:i.signal})}function O1(t){try{const i=new URL(t??"");return(i.protocol==="https:"||i.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(i.hostname))&&!i.username&&!i.password?i.href:void 0}catch{return}}function $c(t,i){const r=t.authModes?.filter(a=>a.available&&(!i||a.methodId===i));return r?.find(a=>a.preferred)??r?.[0]}function Ni(t){if(t.state==="pending"){if(t.step)return t.step;if(t.redirect)return{id:t.id,kind:"redirect",...t.redirect};if(t.prompt)return{id:t.id,kind:"device-code",...t.prompt}}}const L1=new Set(["redirect","device-code","qr-code","credential-input","local-session","consent","processing"]);function B1(t,i){if(typeof t.id!="string"||!t.id||i&&t.id!==i)throw new Error("授权响应与当前连接不匹配。");if(!["pending","connected","failed","cancelled"].includes(t.state))throw new Error("无法识别授权状态,请更新客户端。");if(t.state==="connected"&&!t.connection)throw new Error("服务尚未确认连接已保存,请刷新后重试。");if(t.state==="connected"&&(t.connection?.providerId!==t.providerId||t.methodId&&t.connection.methodId!==t.methodId))throw new Error("保存的连接与当前授权不匹配。");const r=Ni(t);if(t.state==="pending"&&(!r||!L1.has(r.kind)))throw new Error("当前客户端不支持这个授权步骤,请更新客户端。");if(r&&(!r.id||!Number.isFinite(Date.parse(r.expiresAt))))throw new Error("授权步骤缺少有效期限,请重新连接。");if(t.expiresAt&&(!Number.isFinite(Date.parse(t.expiresAt))||r&&Date.parse(r.expiresAt)>Date.parse(t.expiresAt)))throw new Error("授权任务的有效期限无效,请重新连接。")}class U1{constructor(i,r={}){this.transport=i,this.options=r}transport;options;value={busy:!1};listeners=new Set;timer;generation=0;disposed=!1;binding;getSnapshot=()=>this.value;subscribe=i=>(this.listeners.add(i),()=>this.listeners.delete(i));publish(i){if(!this.disposed){this.value=i;for(const r of this.listeners)r()}}stop(){return clearTimeout(this.timer),++this.generation}current(i){return!this.disposed&&i===this.generation}deadline(i){const r=Ni(i);return Math.min(i.expiresAt?Date.parse(i.expiresAt):1/0,r?Date.parse(r.expiresAt):1/0)}accept(i,r,a){if(this.current(r)){if(B1(i,a),this.binding&&(i.providerId!==this.binding.providerId||i.methodId&&i.methodId!==this.binding.methodId))throw new Error("授权响应与当前服务不匹配。");this.publish({authorization:i,busy:!1}),i.state==="pending"&&this.schedule(r)}}schedule(i,r=this.options.pollIntervalMs??2e3){const a=this.value.authorization;if(!this.current(i)||a?.state!=="pending")return;const u=this.deadline(a)-Date.now();if(u<=0){this.stop(),this.publish({busy:!1,authorization:{...a,state:"failed",step:void 0,prompt:void 0,redirect:void 0,errorCode:"authorization_expired"}}),this.transport.cancel(a.id).catch(()=>{});return}const d=Ni(a),c=d&&["credential-input","local-session","consent"].includes(d.kind);this.timer=setTimeout(()=>{c?this.schedule(i):this.poll(i)},Math.min(r,u))}async poll(i){const r=this.value.authorization;if(!(!this.current(i)||r?.state!=="pending")){if(this.deadline(r)<=Date.now()){this.schedule(i);return}try{const a=await this.transport.status(r.id);this.accept(a,i,r.id)}catch(a){if(!this.current(i))return;this.publish({...this.value,busy:!1,error:Js(a)});const u=a?.status;u!==401&&u!==404&&this.schedule(i,this.options.retryIntervalMs??4e3)}}}async begin(i,r){if(this.disposed||this.value.busy||this.value.authorization?.state==="pending")return;const a=this.stop();this.binding=i,this.publish({busy:!0});try{const u=await this.transport.begin(i,r);if(!this.current(a)){u.state==="pending"&&this.transport.cancel(u.id).catch(()=>{});return}try{this.accept(u,a)}catch(d){throw u.state==="pending"&&this.transport.cancel(u.id).catch(()=>{}),d}return u}catch(u){this.current(a)&&this.publish({busy:!1,error:Js(u)})}}async respond(i){const r=this.value.authorization,a=r&&Ni(r);if(this.disposed||this.value.busy||r?.state!=="pending"||!a||a.id!==i.stepId)return;if(this.deadline(r)<=Date.now()){this.schedule(this.generation);return}const u=this.stop();this.publish({authorization:r,busy:!0});try{const d=await this.transport.respond(r.id,i);return this.accept(d,u,r.id),this.current(u)?d:void 0}catch(d){this.current(u)&&(this.publish({authorization:r,busy:!1,error:Js(d)}),this.timer=setTimeout(()=>{this.poll(u)},this.options.retryIntervalMs??4e3))}}async cancel(){const i=this.value.authorization,r=this.stop();if(i?.state!=="pending"){this.publish({busy:!1});return}this.publish({authorization:i,busy:!0});try{const a=await this.transport.cancel(i.id);if(!this.current(r))return;this.publish({busy:!1,authorization:a??{...i,state:"cancelled",step:void 0,prompt:void 0,redirect:void 0}})}catch(a){this.current(r)&&(this.publish({authorization:i,busy:!1,error:Js(a)}),this.schedule(r,this.options.retryIntervalMs??4e3))}}clearError(){this.publish({...this.value,error:void 0})}reset(){this.value.busy||this.value.authorization?.state==="pending"||(this.stop(),this.publish({busy:!1}))}dispose(){const i=this.value.authorization;this.stop(),this.disposed=!0,this.listeners.clear(),i?.state==="pending"&&this.transport.cancel(i.id).catch(()=>{})}}function Js(t){return t instanceof Error?t:new Error("连接操作失败,请重试。")}const Yd="codeshell.remote-link.authorization.v1",gf="/api/v1/links/authorizations/",Fd="[a-f0-9-]{36}",I1=new RegExp(`^(?:/p/${Fd})?${gf}${Fd}$`);function yf(t){return t==="/link/callback"?"/":t==="/mobile/link/callback"?"/mobile/":void 0}function q1(t,i){const r=new URL(t),a=new URL(i);if(r.origin!==a.origin||r.pathname!=="/oauth/authorize"||r.username||r.password||r.hash||r.protocol!=="https:"&&!(r.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(r.hostname)))throw new Error("授权地址无效,请检查 Link 服务配置。");return r}function H1(t,i,r,a=window.location.origin,u=window.sessionStorage){const d=Ni(t);if(d?.kind!=="redirect"||!new RegExp(`^${Fd}$`).test(t.id))throw new Error("授权请求无效。");const c=q1(d.authorizationUrl,i),h=c.searchParams.get("state"),p=c.searchParams.get("redirect_uri"),m=Date.parse(d.expiresAt),y=p?yf(new URL(p,a).pathname):void 0;if(!h||!p||!y||p!==`${a}${y}link/callback`||y==="/mobile/"&&r.projectId!==null||c.searchParams.getAll("state").length!==1||c.searchParams.getAll("redirect_uri").length!==1||!Number.isFinite(m)||m<=Date.now())throw new Error("授权回调地址或有效期无效,请检查服务配置。");const b=kt(gf+t.id,r.workspace,r.projectId),v=new URLSearchParams({view:"links",...r.projectId?{project:r.projectId}:{},...y==="/mobile/"?{workspace:r.workspace}:{}});return u.setItem(Yd,JSON.stringify({target:b,state:h,redirectUri:p,returnUrl:`${y}?${v}`,expiresAt:m,providerId:t.providerId})),c.href}function G1(t,i,r){const a=yf(t.pathname);if(!a)return;const u=t.href;i.replaceState(i.state,"",t.pathname);try{const d=r.getItem(Yd);r.removeItem(Yd);const c=JSON.parse(d??"null");if(!c||!Number.isFinite(c.expiresAt)||c.expiresAt<=Date.now())throw new Error;const h=new URL(u),p=new URL(c.target,t.origin),m=new URL(c.returnUrl,t.origin);if(c.redirectUri!==`${t.origin}${t.pathname}`||h.origin!==t.origin||h.hash||h.searchParams.getAll("state").length!==1||h.searchParams.get("state")!==c.state||p.origin!==t.origin||!I1.test(p.pathname)||p.hash||p.username||p.password||[...p.searchParams.keys()].some(y=>y!=="workspace")||p.searchParams.getAll("workspace").length>1||m.origin!==t.origin||m.pathname!==a||m.username||m.password||m.hash||[...m.searchParams.keys()].some(y=>!(a==="/mobile/"?["workspace","view"]:["project","view"]).includes(y))||m.searchParams.getAll("view").length!==1||m.searchParams.get("view")!=="links"||a==="/mobile/"&&(!p.pathname.startsWith(gf)||m.searchParams.getAll("workspace").length!==1||m.searchParams.get("workspace")!==(p.searchParams.get("workspace")??"")))throw new Error;return{callbackUrl:u,pending:c,denied:h.searchParams.has("error")}}catch{return{error:"找不到匹配的授权,或授权已过期。请返回原项目重新连接。",home:a}}}async function V1(t){const i=new URL(t.pending.target,window.location.origin),r=Ib(i);return t.denied?(await Ue(t.pending.target,{method:"DELETE"},r),{id:"",providerId:t.pending.providerId??"",state:"cancelled"}):(i.pathname+="/complete",Ue(i.pathname+i.search,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callbackUrl:t.callbackUrl})},r))}function Ib(t){return{workspace:t.searchParams.get("workspace")??"",projectId:/^\/p\/([a-f0-9-]{36})\//.exec(t.pathname)?.[1]??null}}function $1(t){const i=new URL(t.pending.target,window.location.origin);return Ue(t.pending.target,{},Ib(i))}function P1(){const t=yf(window.location.pathname);if(t)try{return G1(window.location,window.history,window.sessionStorage)}catch{return window.history.replaceState(window.history.state,"",window.location.pathname),{error:"浏览器无法读取原授权记录。请允许此站点保存临时数据后重新连接。",home:t}}}function Y1({callback:t}){const i=S.useRef(void 0),[r,a]=S.useState(),[u,d]=S.useState("error"in t?t.error:""),[c,h]=S.useState(!1),p=b=>d(b instanceof Ze&&b.status===401?"原登录已失效。请返回工作台登录,并重新发起授权。":b instanceof Error?b.message:"无法确认授权结果,请检查结果或返回项目重新连接。"),m=b=>{if(b.state==="connected"&&!b.connection){p(new Error("服务尚未确认连接已保存,请检查授权结果。"));return}a(b),d("")};S.useEffect(()=>{if("error"in t)return;let b=!0;return i.current??=V1(t),i.current.then(v=>{b&&m(v)},v=>{b&&p(v)}),()=>{b=!1}},[t]);const y=!r&&!u;return s.jsx("main",{className:"auth-page",children:s.jsxs("section",{className:"auth-card",children:[s.jsx("h1",{children:"Link 授权"}),y&&s.jsx("p",{role:"status",children:"正在确认授权并保存到原项目…"}),r?.state==="connected"&&s.jsxs("p",{role:"status",children:["已连接 ",r.connection?.account?.label??r.connection?.providerId,",授权已保存到原项目。"]}),r?.previousGrantRevocationPending&&s.jsx("p",{role:"alert",children:"新连接已保存。有遗留授权等待撤销,项目所在环境将自动重试,重启后仍会继续;也可在 Link 服务中撤销。"}),r?.state==="cancelled"&&s.jsx("p",{role:"status",children:"授权已取消,没有新增连接。"}),r?.state==="failed"&&s.jsx("p",{role:"alert",children:"授权未完成。请返回原项目重新连接。"}),r?.state==="pending"&&s.jsx("p",{role:"status",children:"服务端尚未确认完成。可以稍后检查结果,或返回项目重新发起授权。"}),u&&s.jsx("p",{className:"form-error",role:"alert",children:u}),!("error"in t)&&(u||r?.state==="pending")&&s.jsx("button",{disabled:c,onClick:()=>{c||(h(!0),$1(t).then(m,p).finally(()=>h(!1)))},children:c?"正在查询…":"检查授权结果"}),!y&&s.jsx("a",{href:"error"in t?t.home??"/":t.pending.returnUrl,children:"返回原项目"})]})})}var Pc={exports:{}},ma={},Yc={exports:{}},Fc={};var Hg;function F1(){return Hg||(Hg=1,(function(t){function i(V,B){var Q=V.length;V.push(B);e:for(;0<Q;){var fe=Q-1>>>1,k=V[fe];if(0<u(k,B))V[fe]=B,V[Q]=k,Q=fe;else break e}}function r(V){return V.length===0?null:V[0]}function a(V){if(V.length===0)return null;var B=V[0],Q=V.pop();if(Q!==B){V[0]=Q;e:for(var fe=0,k=V.length,O=k>>>1;fe<O;){var re=2*(fe+1)-1,E=V[re],J=re+1,be=V[J];if(0>u(E,Q))J<k&&0>u(be,E)?(V[fe]=be,V[J]=Q,fe=J):(V[fe]=E,V[re]=Q,fe=re);else if(J<k&&0>u(be,Q))V[fe]=be,V[J]=Q,fe=J;else break e}}return B}function u(V,B){var Q=V.sortIndex-B.sortIndex;return Q!==0?Q:V.id-B.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var d=performance;t.unstable_now=function(){return d.now()}}else{var c=Date,h=c.now();t.unstable_now=function(){return c.now()-h}}var p=[],m=[],y=1,b=null,v=3,x=!1,j=!1,R=!1,C=!1,A=typeof setTimeout=="function"?setTimeout:null,_=typeof clearTimeout=="function"?clearTimeout:null,D=typeof setImmediate<"u"?setImmediate:null;function q(V){for(var B=r(m);B!==null;){if(B.callback===null)a(m);else if(B.startTime<=V)a(m),B.sortIndex=B.expirationTime,i(p,B);else break;B=r(m)}}function ae(V){if(R=!1,q(V),!j)if(r(p)!==null)j=!0,N||(N=!0,L());else{var B=r(m);B!==null&&ee(ae,B.startTime-V)}}var N=!1,U=-1,X=5,H=-1;function T(){return C?!0:!(t.unstable_now()-H<X)}function I(){if(C=!1,N){var V=t.unstable_now();H=V;var B=!0;try{e:{j=!1,R&&(R=!1,_(U),U=-1),x=!0;var Q=v;try{t:{for(q(V),b=r(p);b!==null&&!(b.expirationTime>V&&T());){var fe=b.callback;if(typeof fe=="function"){b.callback=null,v=b.priorityLevel;var k=fe(b.expirationTime<=V);if(V=t.unstable_now(),typeof k=="function"){b.callback=k,q(V),B=!0;break t}b===r(p)&&a(p),q(V)}else a(p);b=r(p)}if(b!==null)B=!0;else{var O=r(m);O!==null&&ee(ae,O.startTime-V),B=!1}}break e}finally{b=null,v=Q,x=!1}B=void 0}}finally{B?L():N=!1}}}var L;if(typeof D=="function")L=function(){D(I)};else if(typeof MessageChannel<"u"){var F=new MessageChannel,W=F.port2;F.port1.onmessage=I,L=function(){W.postMessage(null)}}else L=function(){A(I,0)};function ee(V,B){U=A(function(){V(t.unstable_now())},B)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(V){V.callback=null},t.unstable_forceFrameRate=function(V){0>V||125<V?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):X=0<V?Math.floor(1e3/V):5},t.unstable_getCurrentPriorityLevel=function(){return v},t.unstable_next=function(V){switch(v){case 1:case 2:case 3:var B=3;break;default:B=v}var Q=v;v=B;try{return V()}finally{v=Q}},t.unstable_requestPaint=function(){C=!0},t.unstable_runWithPriority=function(V,B){switch(V){case 1:case 2:case 3:case 4:case 5:break;default:V=3}var Q=v;v=V;try{return B()}finally{v=Q}},t.unstable_scheduleCallback=function(V,B,Q){var fe=t.unstable_now();switch(typeof Q=="object"&&Q!==null?(Q=Q.delay,Q=typeof Q=="number"&&0<Q?fe+Q:fe):Q=fe,V){case 1:var k=-1;break;case 2:k=250;break;case 5:k=1073741823;break;case 4:k=1e4;break;default:k=5e3}return k=Q+k,V={id:y++,callback:B,priorityLevel:V,startTime:Q,expirationTime:k,sortIndex:-1},Q>fe?(V.sortIndex=Q,i(m,V),r(p)===null&&V===r(m)&&(R?(_(U),U=-1):R=!0,ee(ae,Q-fe))):(V.sortIndex=k,i(p,V),j||x||(j=!0,N||(N=!0,L()))),V},t.unstable_shouldYield=T,t.unstable_wrapCallback=function(V){var B=v;return function(){var Q=v;v=B;try{return V.apply(this,arguments)}finally{v=Q}}}})(Fc)),Fc}var Gg;function Q1(){return Gg||(Gg=1,Yc.exports=F1()),Yc.exports}var Qc={exports:{}},on={};var Vg;function X1(){if(Vg)return on;Vg=1;var t=mf();function i(p){var m="https://react.dev/errors/"+p;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)m+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+p+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(){}var a={d:{f:r,r:function(){throw Error(i(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},u=Symbol.for("react.portal");function d(p,m,y){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:u,key:b==null?null:""+b,children:p,containerInfo:m,implementation:y}}var c=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(p,m){if(p==="font")return"";if(typeof m=="string")return m==="use-credentials"?m:""}return on.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,on.createPortal=function(p,m){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!m||m.nodeType!==1&&m.nodeType!==9&&m.nodeType!==11)throw Error(i(299));return d(p,m,null,y)},on.flushSync=function(p){var m=c.T,y=a.p;try{if(c.T=null,a.p=2,p)return p()}finally{c.T=m,a.p=y,a.d.f()}},on.preconnect=function(p,m){typeof p=="string"&&(m?(m=m.crossOrigin,m=typeof m=="string"?m==="use-credentials"?m:"":void 0):m=null,a.d.C(p,m))},on.prefetchDNS=function(p){typeof p=="string"&&a.d.D(p)},on.preinit=function(p,m){if(typeof p=="string"&&m&&typeof m.as=="string"){var y=m.as,b=h(y,m.crossOrigin),v=typeof m.integrity=="string"?m.integrity:void 0,x=typeof m.fetchPriority=="string"?m.fetchPriority:void 0;y==="style"?a.d.S(p,typeof m.precedence=="string"?m.precedence:void 0,{crossOrigin:b,integrity:v,fetchPriority:x}):y==="script"&&a.d.X(p,{crossOrigin:b,integrity:v,fetchPriority:x,nonce:typeof m.nonce=="string"?m.nonce:void 0})}},on.preinitModule=function(p,m){if(typeof p=="string")if(typeof m=="object"&&m!==null){if(m.as==null||m.as==="script"){var y=h(m.as,m.crossOrigin);a.d.M(p,{crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0})}}else m==null&&a.d.M(p)},on.preload=function(p,m){if(typeof p=="string"&&typeof m=="object"&&m!==null&&typeof m.as=="string"){var y=m.as,b=h(y,m.crossOrigin);a.d.L(p,y,{crossOrigin:b,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0,type:typeof m.type=="string"?m.type:void 0,fetchPriority:typeof m.fetchPriority=="string"?m.fetchPriority:void 0,referrerPolicy:typeof m.referrerPolicy=="string"?m.referrerPolicy:void 0,imageSrcSet:typeof m.imageSrcSet=="string"?m.imageSrcSet:void 0,imageSizes:typeof m.imageSizes=="string"?m.imageSizes:void 0,media:typeof m.media=="string"?m.media:void 0})}},on.preloadModule=function(p,m){if(typeof p=="string")if(m){var y=h(m.as,m.crossOrigin);a.d.m(p,{as:typeof m.as=="string"&&m.as!=="script"?m.as:void 0,crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0})}else a.d.m(p)},on.requestFormReset=function(p){a.d.r(p)},on.unstable_batchedUpdates=function(p,m){return p(m)},on.useFormState=function(p,m,y){return c.H.useFormState(p,m,y)},on.useFormStatus=function(){return c.H.useHostTransitionStatus()},on.version="19.2.6",on}var $g;function qb(){if($g)return Qc.exports;$g=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(i){console.error(i)}}return t(),Qc.exports=X1(),Qc.exports}var Pg;function K1(){if(Pg)return ma;Pg=1;var t=Q1(),i=mf(),r=qb();function a(e){var n="https://react.dev/errors/"+e;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)n+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+e+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function u(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function d(e){var n=e,l=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(l=n.return),e=n.return;while(e)}return n.tag===3?l:null}function c(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function h(e){if(e.tag===31){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function p(e){if(d(e)!==e)throw Error(a(188))}function m(e){var n=e.alternate;if(!n){if(n=d(e),n===null)throw Error(a(188));return n!==e?null:e}for(var l=e,o=n;;){var f=l.return;if(f===null)break;var g=f.alternate;if(g===null){if(o=f.return,o!==null){l=o;continue}break}if(f.child===g.child){for(g=f.child;g;){if(g===l)return p(f),e;if(g===o)return p(f),n;g=g.sibling}throw Error(a(188))}if(l.return!==o.return)l=f,o=g;else{for(var w=!1,z=f.child;z;){if(z===l){w=!0,l=f,o=g;break}if(z===o){w=!0,o=f,l=g;break}z=z.sibling}if(!w){for(z=g.child;z;){if(z===l){w=!0,l=g,o=f;break}if(z===o){w=!0,o=g,l=f;break}z=z.sibling}if(!w)throw Error(a(189))}}if(l.alternate!==o)throw Error(a(190))}if(l.tag!==3)throw Error(a(188));return l.stateNode.current===l?e:n}function y(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e;for(e=e.child;e!==null;){if(n=y(e),n!==null)return n;e=e.sibling}return null}var b=Object.assign,v=Symbol.for("react.element"),x=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),D=Symbol.for("react.context"),q=Symbol.for("react.forward_ref"),ae=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),U=Symbol.for("react.memo"),X=Symbol.for("react.lazy"),H=Symbol.for("react.activity"),T=Symbol.for("react.memo_cache_sentinel"),I=Symbol.iterator;function L(e){return e===null||typeof e!="object"?null:(e=I&&e[I]||e["@@iterator"],typeof e=="function"?e:null)}var F=Symbol.for("react.client.reference");function W(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===F?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case R:return"Fragment";case A:return"Profiler";case C:return"StrictMode";case ae:return"Suspense";case N:return"SuspenseList";case H:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case j:return"Portal";case D:return e.displayName||"Context";case _:return(e._context.displayName||"Context")+".Consumer";case q:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case U:return n=e.displayName||null,n!==null?n:W(e.type)||"Memo";case X:n=e._payload,e=e._init;try{return W(e(n))}catch{}}return null}var ee=Array.isArray,V=i.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q={pending:!1,data:null,method:null,action:null},fe=[],k=-1;function O(e){return{current:e}}function re(e){0>k||(e.current=fe[k],fe[k]=null,k--)}function E(e,n){k++,fe[k]=e.current,e.current=n}var J=O(null),be=O(null),Z=O(null),ne=O(null);function ge(e,n){switch(E(Z,n),E(be,e),E(J,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?lg(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=lg(n),e=ag(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}re(J),E(J,e)}function P(){re(J),re(be),re(Z)}function ve(e){e.memoizedState!==null&&E(ne,e);var n=J.current,l=ag(n,e.type);n!==l&&(E(be,e),E(J,l))}function De(e){be.current===e&&(re(J),re(be)),ne.current===e&&(re(ne),ca._currentValue=Q)}var ze,_e;function Ge(e){if(ze===void 0)try{throw Error()}catch(l){var n=l.stack.trim().match(/\n( *(at )?)/);ze=n&&n[1]||"",_e=-1<l.stack.indexOf(`
2
- at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
3
- `+ze+e+_e}var ft=!1;function xt(e,n){if(!e||ft)return"";ft=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var o={DetermineComponentFrameRoot:function(){try{if(n){var me=function(){throw Error()};if(Object.defineProperty(me.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(me,[])}catch(de){var oe=de}Reflect.construct(e,[],me)}else{try{me.call()}catch(de){oe=de}e.call(me.prototype)}}else{try{throw Error()}catch(de){oe=de}(me=e())&&typeof me.catch=="function"&&me.catch(function(){})}}catch(de){if(de&&oe&&typeof de.stack=="string")return[de.stack,oe.stack]}return[null,null]}};o.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var f=Object.getOwnPropertyDescriptor(o.DetermineComponentFrameRoot,"name");f&&f.configurable&&Object.defineProperty(o.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var g=o.DetermineComponentFrameRoot(),w=g[0],z=g[1];if(w&&z){var $=w.split(`
4
- `),se=z.split(`
5
- `);for(f=o=0;o<$.length&&!$[o].includes("DetermineComponentFrameRoot");)o++;for(;f<se.length&&!se[f].includes("DetermineComponentFrameRoot");)f++;if(o===$.length||f===se.length)for(o=$.length-1,f=se.length-1;1<=o&&0<=f&&$[o]!==se[f];)f--;for(;1<=o&&0<=f;o--,f--)if($[o]!==se[f]){if(o!==1||f!==1)do if(o--,f--,0>f||$[o]!==se[f]){var he=`
6
- `+$[o].replace(" at new "," at ");return e.displayName&&he.includes("<anonymous>")&&(he=he.replace("<anonymous>",e.displayName)),he}while(1<=o&&0<=f);break}}}finally{ft=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?Ge(l):""}function Ke(e,n){switch(e.tag){case 26:case 27:case 5:return Ge(e.type);case 16:return Ge("Lazy");case 13:return e.child!==n&&n!==null?Ge("Suspense Fallback"):Ge("Suspense");case 19:return Ge("SuspenseList");case 0:case 15:return xt(e.type,!1);case 11:return xt(e.type.render,!1);case 1:return xt(e.type,!0);case 31:return Ge("Activity");default:return""}}function Tt(e){try{var n="",l=null;do n+=Ke(e,l),l=e,e=e.return;while(e);return n}catch(o){return`
7
- Error generating stack: `+o.message+`
8
- `+o.stack}}var Be=Object.prototype.hasOwnProperty,At=t.unstable_scheduleCallback,Je=t.unstable_cancelCallback,Fe=t.unstable_shouldYield,Lt=t.unstable_requestPaint,Ie=t.unstable_now,pt=t.unstable_getCurrentPriorityLevel,M=t.unstable_ImmediatePriority,ie=t.unstable_UserBlockingPriority,ye=t.unstable_NormalPriority,xe=t.unstable_LowPriority,Ce=t.unstable_IdlePriority,Ae=t.log,Pe=t.unstable_setDisableYieldValue,wt=null,ct=null;function mt(e){if(typeof Ae=="function"&&Pe(e),ct&&typeof ct.setStrictMode=="function")try{ct.setStrictMode(wt,e)}catch{}}var lt=Math.clz32?Math.clz32:K,Pt=Math.log,bt=Math.LN2;function K(e){return e>>>=0,e===0?32:31-(Pt(e)/bt|0)|0}var Se=256,je=262144,Ne=4194304;function ue(e){var n=e&42;if(n!==0)return n;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function ke(e,n,l){var o=e.pendingLanes;if(o===0)return 0;var f=0,g=e.suspendedLanes,w=e.pingedLanes;e=e.warmLanes;var z=o&134217727;return z!==0?(o=z&~g,o!==0?f=ue(o):(w&=z,w!==0?f=ue(w):l||(l=z&~e,l!==0&&(f=ue(l))))):(z=o&~g,z!==0?f=ue(z):w!==0?f=ue(w):l||(l=o&~e,l!==0&&(f=ue(l)))),f===0?0:n!==0&&n!==f&&(n&g)===0&&(g=f&-f,l=n&-n,g>=l||g===32&&(l&4194048)!==0)?n:f}function Te(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)===0}function G(e,n){switch(e){case 1:case 2:case 4:case 8:case 64:return n+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ce(){var e=Ne;return Ne<<=1,(Ne&62914560)===0&&(Ne=4194304),e}function qe(e){for(var n=[],l=0;31>l;l++)n.push(e);return n}function He(e,n){e.pendingLanes|=n,n!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Yt(e,n,l,o,f,g){var w=e.pendingLanes;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=l,e.entangledLanes&=l,e.errorRecoveryDisabledLanes&=l,e.shellSuspendCounter=0;var z=e.entanglements,$=e.expirationTimes,se=e.hiddenUpdates;for(l=w&~l;0<l;){var he=31-lt(l),me=1<<he;z[he]=0,$[he]=-1;var oe=se[he];if(oe!==null)for(se[he]=null,he=0;he<oe.length;he++){var de=oe[he];de!==null&&(de.lane&=-536870913)}l&=~me}o!==0&&Qe(e,o,0),g!==0&&f===0&&e.tag!==0&&(e.suspendedLanes|=g&~(w&~n))}function Qe(e,n,l){e.pendingLanes|=n,e.suspendedLanes&=~n;var o=31-lt(n);e.entangledLanes|=n,e.entanglements[o]=e.entanglements[o]|1073741824|l&261930}function ot(e,n){var l=e.entangledLanes|=n;for(e=e.entanglements;l;){var o=31-lt(l),f=1<<o;f&n|e[o]&n&&(e[o]|=n),l&=~f}}function tt(e,n){var l=n&-n;return l=(l&42)!==0?1:ht(l),(l&(e.suspendedLanes|n))!==0?0:l}function ht(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function We(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function ai(){var e=B.p;return e!==0?e:(e=window.event,e===void 0?32:Ag(e.type))}function Gt(e,n){var l=B.p;try{return B.p=e,n()}finally{B.p=l}}var hn=Math.random().toString(36).slice(2),Dt="__reactFiber$"+hn,nn="__reactProps$"+hn,Qn="__reactContainer$"+hn,Xn="__reactEvents$"+hn,mx="__reactListeners$"+hn,gx="__reactHandles$"+hn,Yf="__reactResources$"+hn,Cl="__reactMarker$"+hn;function Mo(e){delete e[Dt],delete e[nn],delete e[Xn],delete e[mx],delete e[gx]}function Ar(e){var n=e[Dt];if(n)return n;for(var l=e.parentNode;l;){if(n=l[Qn]||l[Dt]){if(l=n.alternate,n.child!==null||l!==null&&l.child!==null)for(e=hg(e);e!==null;){if(l=e[Dt])return l;e=hg(e)}return n}e=l,l=e.parentNode}return null}function Rr(e){if(e=e[Dt]||e[Qn]){var n=e.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return e}return null}function El(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e.stateNode;throw Error(a(33))}function zr(e){var n=e[Yf];return n||(n=e[Yf]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function Wt(e){e[Cl]=!0}var Ff=new Set,Qf={};function nr(e,n){_r(e,n),_r(e+"Capture",n)}function _r(e,n){for(Qf[e]=n,e=0;e<n.length;e++)Ff.add(n[e])}var yx=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Xf={},Kf={};function bx(e){return Be.call(Kf,e)?!0:Be.call(Xf,e)?!1:yx.test(e)?Kf[e]=!0:(Xf[e]=!0,!1)}function Ua(e,n,l){if(bx(n))if(l===null)e.removeAttribute(n);else{switch(typeof l){case"undefined":case"function":case"symbol":e.removeAttribute(n);return;case"boolean":var o=n.toLowerCase().slice(0,5);if(o!=="data-"&&o!=="aria-"){e.removeAttribute(n);return}}e.setAttribute(n,""+l)}}function Ia(e,n,l){if(l===null)e.removeAttribute(n);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttribute(n,""+l)}}function si(e,n,l,o){if(o===null)e.removeAttribute(l);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(l);return}e.setAttributeNS(n,l,""+o)}}function zn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Zf(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function vx(e,n,l){var o=Object.getOwnPropertyDescriptor(e.constructor.prototype,n);if(!e.hasOwnProperty(n)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var f=o.get,g=o.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(w){l=""+w,g.call(this,w)}}),Object.defineProperty(e,n,{enumerable:o.enumerable}),{getValue:function(){return l},setValue:function(w){l=""+w},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function Oo(e){if(!e._valueTracker){var n=Zf(e)?"checked":"value";e._valueTracker=vx(e,n,""+e[n])}}function Jf(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var l=n.getValue(),o="";return e&&(o=Zf(e)?e.checked?"true":"false":e.value),e=o,e!==l?(n.setValue(e),!0):!1}function qa(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}}var xx=/[\n"\\]/g;function _n(e){return e.replace(xx,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function Lo(e,n,l,o,f,g,w,z){e.name="",w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"?e.type=w:e.removeAttribute("type"),n!=null?w==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+zn(n)):e.value!==""+zn(n)&&(e.value=""+zn(n)):w!=="submit"&&w!=="reset"||e.removeAttribute("value"),n!=null?Bo(e,w,zn(n)):l!=null?Bo(e,w,zn(l)):o!=null&&e.removeAttribute("value"),f==null&&g!=null&&(e.defaultChecked=!!g),f!=null&&(e.checked=f&&typeof f!="function"&&typeof f!="symbol"),z!=null&&typeof z!="function"&&typeof z!="symbol"&&typeof z!="boolean"?e.name=""+zn(z):e.removeAttribute("name")}function Wf(e,n,l,o,f,g,w,z){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(e.type=g),n!=null||l!=null){if(!(g!=="submit"&&g!=="reset"||n!=null)){Oo(e);return}l=l!=null?""+zn(l):"",n=n!=null?""+zn(n):l,z||n===e.value||(e.value=n),e.defaultValue=n}o=o??f,o=typeof o!="function"&&typeof o!="symbol"&&!!o,e.checked=z?e.checked:!!o,e.defaultChecked=!!o,w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"&&(e.name=w),Oo(e)}function Bo(e,n,l){n==="number"&&qa(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function Dr(e,n,l,o){if(e=e.options,n){n={};for(var f=0;f<l.length;f++)n["$"+l[f]]=!0;for(l=0;l<e.length;l++)f=n.hasOwnProperty("$"+e[l].value),e[l].selected!==f&&(e[l].selected=f),f&&o&&(e[l].defaultSelected=!0)}else{for(l=""+zn(l),n=null,f=0;f<e.length;f++){if(e[f].value===l){e[f].selected=!0,o&&(e[f].defaultSelected=!0);return}n!==null||e[f].disabled||(n=e[f])}n!==null&&(n.selected=!0)}}function eh(e,n,l){if(n!=null&&(n=""+zn(n),n!==e.value&&(e.value=n),l==null)){e.defaultValue!==n&&(e.defaultValue=n);return}e.defaultValue=l!=null?""+zn(l):""}function th(e,n,l,o){if(n==null){if(o!=null){if(l!=null)throw Error(a(92));if(ee(o)){if(1<o.length)throw Error(a(93));o=o[0]}l=o}l==null&&(l=""),n=l}l=zn(n),e.defaultValue=l,o=e.textContent,o===l&&o!==""&&o!==null&&(e.value=o),Oo(e)}function Mr(e,n){if(n){var l=e.firstChild;if(l&&l===e.lastChild&&l.nodeType===3){l.nodeValue=n;return}}e.textContent=n}var wx=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function nh(e,n,l){var o=n.indexOf("--")===0;l==null||typeof l=="boolean"||l===""?o?e.setProperty(n,""):n==="float"?e.cssFloat="":e[n]="":o?e.setProperty(n,l):typeof l!="number"||l===0||wx.has(n)?n==="float"?e.cssFloat=l:e[n]=(""+l).trim():e[n]=l+"px"}function ih(e,n,l){if(n!=null&&typeof n!="object")throw Error(a(62));if(e=e.style,l!=null){for(var o in l)!l.hasOwnProperty(o)||n!=null&&n.hasOwnProperty(o)||(o.indexOf("--")===0?e.setProperty(o,""):o==="float"?e.cssFloat="":e[o]="");for(var f in n)o=n[f],n.hasOwnProperty(f)&&l[f]!==o&&nh(e,f,o)}else for(var g in n)n.hasOwnProperty(g)&&nh(e,g,n[g])}function Uo(e){if(e.indexOf("-")===-1)return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Sx=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),jx=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Ha(e){return jx.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function oi(){}var Io=null;function qo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Or=null,Lr=null;function rh(e){var n=Rr(e);if(n&&(e=n.stateNode)){var l=e[nn]||null;e:switch(e=n.stateNode,n.type){case"input":if(Lo(e,l.value,l.defaultValue,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name),n=l.name,l.type==="radio"&&n!=null){for(l=e;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll('input[name="'+_n(""+n)+'"][type="radio"]'),n=0;n<l.length;n++){var o=l[n];if(o!==e&&o.form===e.form){var f=o[nn]||null;if(!f)throw Error(a(90));Lo(o,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name)}}for(n=0;n<l.length;n++)o=l[n],o.form===e.form&&Jf(o)}break e;case"textarea":eh(e,l.value,l.defaultValue);break e;case"select":n=l.value,n!=null&&Dr(e,!!l.multiple,n,!1)}}}var Ho=!1;function lh(e,n,l){if(Ho)return e(n,l);Ho=!0;try{var o=e(n);return o}finally{if(Ho=!1,(Or!==null||Lr!==null)&&(Ts(),Or&&(n=Or,e=Lr,Lr=Or=null,rh(n),e)))for(n=0;n<e.length;n++)rh(e[n])}}function Nl(e,n){var l=e.stateNode;if(l===null)return null;var o=l[nn]||null;if(o===null)return null;l=o[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(o=!o.disabled)||(e=e.type,o=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!o;break e;default:e=!1}if(e)return null;if(l&&typeof l!="function")throw Error(a(231,n,typeof l));return l}var ui=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Go=!1;if(ui)try{var Tl={};Object.defineProperty(Tl,"passive",{get:function(){Go=!0}}),window.addEventListener("test",Tl,Tl),window.removeEventListener("test",Tl,Tl)}catch{Go=!1}var Ai=null,Vo=null,Ga=null;function ah(){if(Ga)return Ga;var e,n=Vo,l=n.length,o,f="value"in Ai?Ai.value:Ai.textContent,g=f.length;for(e=0;e<l&&n[e]===f[e];e++);var w=l-e;for(o=1;o<=w&&n[l-o]===f[g-o];o++);return Ga=f.slice(e,1<o?1-o:void 0)}function Va(e){var n=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&n===13&&(e=13)):e=n,e===10&&(e=13),32<=e||e===13?e:0}function $a(){return!0}function sh(){return!1}function pn(e){function n(l,o,f,g,w){this._reactName=l,this._targetInst=f,this.type=o,this.nativeEvent=g,this.target=w,this.currentTarget=null;for(var z in e)e.hasOwnProperty(z)&&(l=e[z],this[z]=l?l(g):g[z]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?$a:sh,this.isPropagationStopped=sh,this}return b(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=$a)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=$a)},persist:function(){},isPersistent:$a}),n}var ir={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Pa=pn(ir),Al=b({},ir,{view:0,detail:0}),kx=pn(Al),$o,Po,Rl,Ya=b({},Al,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Fo,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!==Rl&&(Rl&&e.type==="mousemove"?($o=e.screenX-Rl.screenX,Po=e.screenY-Rl.screenY):Po=$o=0,Rl=e),$o)},movementY:function(e){return"movementY"in e?e.movementY:Po}}),oh=pn(Ya),Cx=b({},Ya,{dataTransfer:0}),Ex=pn(Cx),Nx=b({},Al,{relatedTarget:0}),Yo=pn(Nx),Tx=b({},ir,{animationName:0,elapsedTime:0,pseudoElement:0}),Ax=pn(Tx),Rx=b({},ir,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),zx=pn(Rx),_x=b({},ir,{data:0}),uh=pn(_x),Dx={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Mx={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"},Ox={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Lx(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=Ox[e])?!!n[e]:!1}function Fo(){return Lx}var Bx=b({},Al,{key:function(e){if(e.key){var n=Dx[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=Va(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Mx[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Fo,charCode:function(e){return e.type==="keypress"?Va(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Va(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Ux=pn(Bx),Ix=b({},Ya,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ch=pn(Ix),qx=b({},Al,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Fo}),Hx=pn(qx),Gx=b({},ir,{propertyName:0,elapsedTime:0,pseudoElement:0}),Vx=pn(Gx),$x=b({},Ya,{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}),Px=pn($x),Yx=b({},ir,{newState:0,oldState:0}),Fx=pn(Yx),Qx=[9,13,27,32],Qo=ui&&"CompositionEvent"in window,zl=null;ui&&"documentMode"in document&&(zl=document.documentMode);var Xx=ui&&"TextEvent"in window&&!zl,dh=ui&&(!Qo||zl&&8<zl&&11>=zl),fh=" ",hh=!1;function ph(e,n){switch(e){case"keyup":return Qx.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function mh(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Br=!1;function Kx(e,n){switch(e){case"compositionend":return mh(n);case"keypress":return n.which!==32?null:(hh=!0,fh);case"textInput":return e=n.data,e===fh&&hh?null:e;default:return null}}function Zx(e,n){if(Br)return e==="compositionend"||!Qo&&ph(e,n)?(e=ah(),Ga=Vo=Ai=null,Br=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return dh&&n.locale!=="ko"?null:n.data;default:return null}}var Jx={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 gh(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!Jx[e.type]:n==="textarea"}function yh(e,n,l,o){Or?Lr?Lr.push(o):Lr=[o]:Or=o,n=Os(n,"onChange"),0<n.length&&(l=new Pa("onChange","change",null,l,o),e.push({event:l,listeners:n}))}var _l=null,Dl=null;function Wx(e){Wm(e,0)}function Fa(e){var n=El(e);if(Jf(n))return e}function bh(e,n){if(e==="change")return n}var vh=!1;if(ui){var Xo;if(ui){var Ko="oninput"in document;if(!Ko){var xh=document.createElement("div");xh.setAttribute("oninput","return;"),Ko=typeof xh.oninput=="function"}Xo=Ko}else Xo=!1;vh=Xo&&(!document.documentMode||9<document.documentMode)}function wh(){_l&&(_l.detachEvent("onpropertychange",Sh),Dl=_l=null)}function Sh(e){if(e.propertyName==="value"&&Fa(Dl)){var n=[];yh(n,Dl,e,qo(e)),lh(Wx,n)}}function e0(e,n,l){e==="focusin"?(wh(),_l=n,Dl=l,_l.attachEvent("onpropertychange",Sh)):e==="focusout"&&wh()}function t0(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Fa(Dl)}function n0(e,n){if(e==="click")return Fa(n)}function i0(e,n){if(e==="input"||e==="change")return Fa(n)}function r0(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var Sn=typeof Object.is=="function"?Object.is:r0;function Ml(e,n){if(Sn(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var l=Object.keys(e),o=Object.keys(n);if(l.length!==o.length)return!1;for(o=0;o<l.length;o++){var f=l[o];if(!Be.call(n,f)||!Sn(e[f],n[f]))return!1}return!0}function jh(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function kh(e,n){var l=jh(e);e=0;for(var o;l;){if(l.nodeType===3){if(o=e+l.textContent.length,e<=n&&o>=n)return{node:l,offset:n-e};e=o}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=jh(l)}}function Ch(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Ch(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Eh(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var n=qa(e.document);n instanceof e.HTMLIFrameElement;){try{var l=typeof n.contentWindow.location.href=="string"}catch{l=!1}if(l)e=n.contentWindow;else break;n=qa(e.document)}return n}function Zo(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}var l0=ui&&"documentMode"in document&&11>=document.documentMode,Ur=null,Jo=null,Ol=null,Wo=!1;function Nh(e,n,l){var o=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Wo||Ur==null||Ur!==qa(o)||(o=Ur,"selectionStart"in o&&Zo(o)?o={start:o.selectionStart,end:o.selectionEnd}:(o=(o.ownerDocument&&o.ownerDocument.defaultView||window).getSelection(),o={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset}),Ol&&Ml(Ol,o)||(Ol=o,o=Os(Jo,"onSelect"),0<o.length&&(n=new Pa("onSelect","select",null,n,l),e.push({event:n,listeners:o}),n.target=Ur)))}function rr(e,n){var l={};return l[e.toLowerCase()]=n.toLowerCase(),l["Webkit"+e]="webkit"+n,l["Moz"+e]="moz"+n,l}var Ir={animationend:rr("Animation","AnimationEnd"),animationiteration:rr("Animation","AnimationIteration"),animationstart:rr("Animation","AnimationStart"),transitionrun:rr("Transition","TransitionRun"),transitionstart:rr("Transition","TransitionStart"),transitioncancel:rr("Transition","TransitionCancel"),transitionend:rr("Transition","TransitionEnd")},eu={},Th={};ui&&(Th=document.createElement("div").style,"AnimationEvent"in window||(delete Ir.animationend.animation,delete Ir.animationiteration.animation,delete Ir.animationstart.animation),"TransitionEvent"in window||delete Ir.transitionend.transition);function lr(e){if(eu[e])return eu[e];if(!Ir[e])return e;var n=Ir[e],l;for(l in n)if(n.hasOwnProperty(l)&&l in Th)return eu[e]=n[l];return e}var Ah=lr("animationend"),Rh=lr("animationiteration"),zh=lr("animationstart"),a0=lr("transitionrun"),s0=lr("transitionstart"),o0=lr("transitioncancel"),_h=lr("transitionend"),Dh=new Map,tu="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");tu.push("scrollEnd");function Gn(e,n){Dh.set(e,n),nr(n,[e])}var Qa=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Dn=[],qr=0,nu=0;function Xa(){for(var e=qr,n=nu=qr=0;n<e;){var l=Dn[n];Dn[n++]=null;var o=Dn[n];Dn[n++]=null;var f=Dn[n];Dn[n++]=null;var g=Dn[n];if(Dn[n++]=null,o!==null&&f!==null){var w=o.pending;w===null?f.next=f:(f.next=w.next,w.next=f),o.pending=f}g!==0&&Mh(l,f,g)}}function Ka(e,n,l,o){Dn[qr++]=e,Dn[qr++]=n,Dn[qr++]=l,Dn[qr++]=o,nu|=o,e.lanes|=o,e=e.alternate,e!==null&&(e.lanes|=o)}function iu(e,n,l,o){return Ka(e,n,l,o),Za(e)}function ar(e,n){return Ka(e,null,null,n),Za(e)}function Mh(e,n,l){e.lanes|=l;var o=e.alternate;o!==null&&(o.lanes|=l);for(var f=!1,g=e.return;g!==null;)g.childLanes|=l,o=g.alternate,o!==null&&(o.childLanes|=l),g.tag===22&&(e=g.stateNode,e===null||e._visibility&1||(f=!0)),e=g,g=g.return;return e.tag===3?(g=e.stateNode,f&&n!==null&&(f=31-lt(l),e=g.hiddenUpdates,o=e[f],o===null?e[f]=[n]:o.push(n),n.lane=l|536870912),g):null}function Za(e){if(50<ia)throw ia=0,fc=null,Error(a(185));for(var n=e.return;n!==null;)e=n,n=e.return;return e.tag===3?e.stateNode:null}var Hr={};function u0(e,n,l,o){this.tag=e,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=o,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function jn(e,n,l,o){return new u0(e,n,l,o)}function ru(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ci(e,n){var l=e.alternate;return l===null?(l=jn(e.tag,n,e.key,e.mode),l.elementType=e.elementType,l.type=e.type,l.stateNode=e.stateNode,l.alternate=e,e.alternate=l):(l.pendingProps=n,l.type=e.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=e.flags&65011712,l.childLanes=e.childLanes,l.lanes=e.lanes,l.child=e.child,l.memoizedProps=e.memoizedProps,l.memoizedState=e.memoizedState,l.updateQueue=e.updateQueue,n=e.dependencies,l.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},l.sibling=e.sibling,l.index=e.index,l.ref=e.ref,l.refCleanup=e.refCleanup,l}function Oh(e,n){e.flags&=65011714;var l=e.alternate;return l===null?(e.childLanes=0,e.lanes=n,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=l.childLanes,e.lanes=l.lanes,e.child=l.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=l.memoizedProps,e.memoizedState=l.memoizedState,e.updateQueue=l.updateQueue,e.type=l.type,n=l.dependencies,e.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),e}function Ja(e,n,l,o,f,g){var w=0;if(o=e,typeof e=="function")ru(e)&&(w=1);else if(typeof e=="string")w=p1(e,l,J.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case H:return e=jn(31,l,n,f),e.elementType=H,e.lanes=g,e;case R:return sr(l.children,f,g,n);case C:w=8,f|=24;break;case A:return e=jn(12,l,n,f|2),e.elementType=A,e.lanes=g,e;case ae:return e=jn(13,l,n,f),e.elementType=ae,e.lanes=g,e;case N:return e=jn(19,l,n,f),e.elementType=N,e.lanes=g,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case D:w=10;break e;case _:w=9;break e;case q:w=11;break e;case U:w=14;break e;case X:w=16,o=null;break e}w=29,l=Error(a(130,e===null?"null":typeof e,"")),o=null}return n=jn(w,l,n,f),n.elementType=e,n.type=o,n.lanes=g,n}function sr(e,n,l,o){return e=jn(7,e,o,n),e.lanes=l,e}function lu(e,n,l){return e=jn(6,e,null,n),e.lanes=l,e}function Lh(e){var n=jn(18,null,null,0);return n.stateNode=e,n}function au(e,n,l){return n=jn(4,e.children!==null?e.children:[],e.key,n),n.lanes=l,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}var Bh=new WeakMap;function Mn(e,n){if(typeof e=="object"&&e!==null){var l=Bh.get(e);return l!==void 0?l:(n={value:e,source:n,stack:Tt(n)},Bh.set(e,n),n)}return{value:e,source:n,stack:Tt(n)}}var Gr=[],Vr=0,Wa=null,Ll=0,On=[],Ln=0,Ri=null,Kn=1,Zn="";function di(e,n){Gr[Vr++]=Ll,Gr[Vr++]=Wa,Wa=e,Ll=n}function Uh(e,n,l){On[Ln++]=Kn,On[Ln++]=Zn,On[Ln++]=Ri,Ri=e;var o=Kn;e=Zn;var f=32-lt(o)-1;o&=~(1<<f),l+=1;var g=32-lt(n)+f;if(30<g){var w=f-f%5;g=(o&(1<<w)-1).toString(32),o>>=w,f-=w,Kn=1<<32-lt(n)+f|l<<f|o,Zn=g+e}else Kn=1<<g|l<<f|o,Zn=e}function su(e){e.return!==null&&(di(e,1),Uh(e,1,0))}function ou(e){for(;e===Wa;)Wa=Gr[--Vr],Gr[Vr]=null,Ll=Gr[--Vr],Gr[Vr]=null;for(;e===Ri;)Ri=On[--Ln],On[Ln]=null,Zn=On[--Ln],On[Ln]=null,Kn=On[--Ln],On[Ln]=null}function Ih(e,n){On[Ln++]=Kn,On[Ln++]=Zn,On[Ln++]=Ri,Kn=n.id,Zn=n.overflow,Ri=e}var rn=null,Mt=null,ut=!1,zi=null,Bn=!1,uu=Error(a(519));function _i(e){var n=Error(a(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Bl(Mn(n,e)),uu}function qh(e){var n=e.stateNode,l=e.type,o=e.memoizedProps;switch(n[Dt]=e,n[nn]=o,l){case"dialog":it("cancel",n),it("close",n);break;case"iframe":case"object":case"embed":it("load",n);break;case"video":case"audio":for(l=0;l<la.length;l++)it(la[l],n);break;case"source":it("error",n);break;case"img":case"image":case"link":it("error",n),it("load",n);break;case"details":it("toggle",n);break;case"input":it("invalid",n),Wf(n,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":it("invalid",n);break;case"textarea":it("invalid",n),th(n,o.value,o.defaultValue,o.children)}l=o.children,typeof l!="string"&&typeof l!="number"&&typeof l!="bigint"||n.textContent===""+l||o.suppressHydrationWarning===!0||ig(n.textContent,l)?(o.popover!=null&&(it("beforetoggle",n),it("toggle",n)),o.onScroll!=null&&it("scroll",n),o.onScrollEnd!=null&&it("scrollend",n),o.onClick!=null&&(n.onclick=oi),n=!0):n=!1,n||_i(e,!0)}function Hh(e){for(rn=e.return;rn;)switch(rn.tag){case 5:case 31:case 13:Bn=!1;return;case 27:case 3:Bn=!0;return;default:rn=rn.return}}function $r(e){if(e!==rn)return!1;if(!ut)return Hh(e),ut=!0,!1;var n=e.tag,l;if((l=n!==3&&n!==27)&&((l=n===5)&&(l=e.type,l=!(l!=="form"&&l!=="button")||Nc(e.type,e.memoizedProps)),l=!l),l&&Mt&&_i(e),Hh(e),n===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(317));Mt=fg(e)}else if(n===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(317));Mt=fg(e)}else n===27?(n=Mt,Yi(e.type)?(e=_c,_c=null,Mt=e):Mt=n):Mt=rn?In(e.stateNode.nextSibling):null;return!0}function or(){Mt=rn=null,ut=!1}function cu(){var e=zi;return e!==null&&(bn===null?bn=e:bn.push.apply(bn,e),zi=null),e}function Bl(e){zi===null?zi=[e]:zi.push(e)}var du=O(null),ur=null,fi=null;function Di(e,n,l){E(du,n._currentValue),n._currentValue=l}function hi(e){e._currentValue=du.current,re(du)}function fu(e,n,l){for(;e!==null;){var o=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,o!==null&&(o.childLanes|=n)):o!==null&&(o.childLanes&n)!==n&&(o.childLanes|=n),e===l)break;e=e.return}}function hu(e,n,l,o){var f=e.child;for(f!==null&&(f.return=e);f!==null;){var g=f.dependencies;if(g!==null){var w=f.child;g=g.firstContext;e:for(;g!==null;){var z=g;g=f;for(var $=0;$<n.length;$++)if(z.context===n[$]){g.lanes|=l,z=g.alternate,z!==null&&(z.lanes|=l),fu(g.return,l,e),o||(w=null);break e}g=z.next}}else if(f.tag===18){if(w=f.return,w===null)throw Error(a(341));w.lanes|=l,g=w.alternate,g!==null&&(g.lanes|=l),fu(w,l,e),w=null}else w=f.child;if(w!==null)w.return=f;else for(w=f;w!==null;){if(w===e){w=null;break}if(f=w.sibling,f!==null){f.return=w.return,w=f;break}w=w.return}f=w}}function Pr(e,n,l,o){e=null;for(var f=n,g=!1;f!==null;){if(!g){if((f.flags&524288)!==0)g=!0;else if((f.flags&262144)!==0)break}if(f.tag===10){var w=f.alternate;if(w===null)throw Error(a(387));if(w=w.memoizedProps,w!==null){var z=f.type;Sn(f.pendingProps.value,w.value)||(e!==null?e.push(z):e=[z])}}else if(f===ne.current){if(w=f.alternate,w===null)throw Error(a(387));w.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(e!==null?e.push(ca):e=[ca])}f=f.return}e!==null&&hu(n,e,l,o),n.flags|=262144}function es(e){for(e=e.firstContext;e!==null;){if(!Sn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function cr(e){ur=e,fi=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function ln(e){return Gh(ur,e)}function ts(e,n){return ur===null&&cr(e),Gh(e,n)}function Gh(e,n){var l=n._currentValue;if(n={context:n,memoizedValue:l,next:null},fi===null){if(e===null)throw Error(a(308));fi=n,e.dependencies={lanes:0,firstContext:n},e.flags|=524288}else fi=fi.next=n;return l}var c0=typeof AbortController<"u"?AbortController:function(){var e=[],n=this.signal={aborted:!1,addEventListener:function(l,o){e.push(o)}};this.abort=function(){n.aborted=!0,e.forEach(function(l){return l()})}},d0=t.unstable_scheduleCallback,f0=t.unstable_NormalPriority,Ft={$$typeof:D,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function pu(){return{controller:new c0,data:new Map,refCount:0}}function Ul(e){e.refCount--,e.refCount===0&&d0(f0,function(){e.controller.abort()})}var Il=null,mu=0,Yr=0,Fr=null;function h0(e,n){if(Il===null){var l=Il=[];mu=0,Yr=bc(),Fr={status:"pending",value:void 0,then:function(o){l.push(o)}}}return mu++,n.then(Vh,Vh),n}function Vh(){if(--mu===0&&Il!==null){Fr!==null&&(Fr.status="fulfilled");var e=Il;Il=null,Yr=0,Fr=null;for(var n=0;n<e.length;n++)(0,e[n])()}}function p0(e,n){var l=[],o={status:"pending",value:null,reason:null,then:function(f){l.push(f)}};return e.then(function(){o.status="fulfilled",o.value=n;for(var f=0;f<l.length;f++)(0,l[f])(n)},function(f){for(o.status="rejected",o.reason=f,f=0;f<l.length;f++)(0,l[f])(void 0)}),o}var $h=V.S;V.S=function(e,n){Nm=Ie(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&h0(e,n),$h!==null&&$h(e,n)};var dr=O(null);function gu(){var e=dr.current;return e!==null?e:Rt.pooledCache}function ns(e,n){n===null?E(dr,dr.current):E(dr,n.pool)}function Ph(){var e=gu();return e===null?null:{parent:Ft._currentValue,pool:e}}var Qr=Error(a(460)),yu=Error(a(474)),is=Error(a(542)),rs={then:function(){}};function Yh(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Fh(e,n,l){switch(l=e[l],l===void 0?e.push(n):l!==n&&(n.then(oi,oi),n=l),n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Xh(e),e;default:if(typeof n.status=="string")n.then(oi,oi);else{if(e=Rt,e!==null&&100<e.shellSuspendCounter)throw Error(a(482));e=n,e.status="pending",e.then(function(o){if(n.status==="pending"){var f=n;f.status="fulfilled",f.value=o}},function(o){if(n.status==="pending"){var f=n;f.status="rejected",f.reason=o}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Xh(e),e}throw hr=n,Qr}}function fr(e){try{var n=e._init;return n(e._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(hr=l,Qr):l}}var hr=null;function Qh(){if(hr===null)throw Error(a(459));var e=hr;return hr=null,e}function Xh(e){if(e===Qr||e===is)throw Error(a(483))}var Xr=null,ql=0;function ls(e){var n=ql;return ql+=1,Xr===null&&(Xr=[]),Fh(Xr,e,n)}function Hl(e,n){n=n.props.ref,e.ref=n!==void 0?n:null}function as(e,n){throw n.$$typeof===v?Error(a(525)):(e=Object.prototype.toString.call(n),Error(a(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e)))}function Kh(e){function n(te,Y){if(e){var le=te.deletions;le===null?(te.deletions=[Y],te.flags|=16):le.push(Y)}}function l(te,Y){if(!e)return null;for(;Y!==null;)n(te,Y),Y=Y.sibling;return null}function o(te){for(var Y=new Map;te!==null;)te.key!==null?Y.set(te.key,te):Y.set(te.index,te),te=te.sibling;return Y}function f(te,Y){return te=ci(te,Y),te.index=0,te.sibling=null,te}function g(te,Y,le){return te.index=le,e?(le=te.alternate,le!==null?(le=le.index,le<Y?(te.flags|=67108866,Y):le):(te.flags|=67108866,Y)):(te.flags|=1048576,Y)}function w(te){return e&&te.alternate===null&&(te.flags|=67108866),te}function z(te,Y,le,pe){return Y===null||Y.tag!==6?(Y=lu(le,te.mode,pe),Y.return=te,Y):(Y=f(Y,le),Y.return=te,Y)}function $(te,Y,le,pe){var Me=le.type;return Me===R?he(te,Y,le.props.children,pe,le.key):Y!==null&&(Y.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===X&&fr(Me)===Y.type)?(Y=f(Y,le.props),Hl(Y,le),Y.return=te,Y):(Y=Ja(le.type,le.key,le.props,null,te.mode,pe),Hl(Y,le),Y.return=te,Y)}function se(te,Y,le,pe){return Y===null||Y.tag!==4||Y.stateNode.containerInfo!==le.containerInfo||Y.stateNode.implementation!==le.implementation?(Y=au(le,te.mode,pe),Y.return=te,Y):(Y=f(Y,le.children||[]),Y.return=te,Y)}function he(te,Y,le,pe,Me){return Y===null||Y.tag!==7?(Y=sr(le,te.mode,pe,Me),Y.return=te,Y):(Y=f(Y,le),Y.return=te,Y)}function me(te,Y,le){if(typeof Y=="string"&&Y!==""||typeof Y=="number"||typeof Y=="bigint")return Y=lu(""+Y,te.mode,le),Y.return=te,Y;if(typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case x:return le=Ja(Y.type,Y.key,Y.props,null,te.mode,le),Hl(le,Y),le.return=te,le;case j:return Y=au(Y,te.mode,le),Y.return=te,Y;case X:return Y=fr(Y),me(te,Y,le)}if(ee(Y)||L(Y))return Y=sr(Y,te.mode,le,null),Y.return=te,Y;if(typeof Y.then=="function")return me(te,ls(Y),le);if(Y.$$typeof===D)return me(te,ts(te,Y),le);as(te,Y)}return null}function oe(te,Y,le,pe){var Me=Y!==null?Y.key:null;if(typeof le=="string"&&le!==""||typeof le=="number"||typeof le=="bigint")return Me!==null?null:z(te,Y,""+le,pe);if(typeof le=="object"&&le!==null){switch(le.$$typeof){case x:return le.key===Me?$(te,Y,le,pe):null;case j:return le.key===Me?se(te,Y,le,pe):null;case X:return le=fr(le),oe(te,Y,le,pe)}if(ee(le)||L(le))return Me!==null?null:he(te,Y,le,pe,null);if(typeof le.then=="function")return oe(te,Y,ls(le),pe);if(le.$$typeof===D)return oe(te,Y,ts(te,le),pe);as(te,le)}return null}function de(te,Y,le,pe,Me){if(typeof pe=="string"&&pe!==""||typeof pe=="number"||typeof pe=="bigint")return te=te.get(le)||null,z(Y,te,""+pe,Me);if(typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case x:return te=te.get(pe.key===null?le:pe.key)||null,$(Y,te,pe,Me);case j:return te=te.get(pe.key===null?le:pe.key)||null,se(Y,te,pe,Me);case X:return pe=fr(pe),de(te,Y,le,pe,Me)}if(ee(pe)||L(pe))return te=te.get(le)||null,he(Y,te,pe,Me,null);if(typeof pe.then=="function")return de(te,Y,le,ls(pe),Me);if(pe.$$typeof===D)return de(te,Y,le,ts(Y,pe),Me);as(Y,pe)}return null}function Ee(te,Y,le,pe){for(var Me=null,gt=null,Re=Y,Xe=Y=0,st=null;Re!==null&&Xe<le.length;Xe++){Re.index>Xe?(st=Re,Re=null):st=Re.sibling;var yt=oe(te,Re,le[Xe],pe);if(yt===null){Re===null&&(Re=st);break}e&&Re&&yt.alternate===null&&n(te,Re),Y=g(yt,Y,Xe),gt===null?Me=yt:gt.sibling=yt,gt=yt,Re=st}if(Xe===le.length)return l(te,Re),ut&&di(te,Xe),Me;if(Re===null){for(;Xe<le.length;Xe++)Re=me(te,le[Xe],pe),Re!==null&&(Y=g(Re,Y,Xe),gt===null?Me=Re:gt.sibling=Re,gt=Re);return ut&&di(te,Xe),Me}for(Re=o(Re);Xe<le.length;Xe++)st=de(Re,te,Xe,le[Xe],pe),st!==null&&(e&&st.alternate!==null&&Re.delete(st.key===null?Xe:st.key),Y=g(st,Y,Xe),gt===null?Me=st:gt.sibling=st,gt=st);return e&&Re.forEach(function(Zi){return n(te,Zi)}),ut&&di(te,Xe),Me}function Le(te,Y,le,pe){if(le==null)throw Error(a(151));for(var Me=null,gt=null,Re=Y,Xe=Y=0,st=null,yt=le.next();Re!==null&&!yt.done;Xe++,yt=le.next()){Re.index>Xe?(st=Re,Re=null):st=Re.sibling;var Zi=oe(te,Re,yt.value,pe);if(Zi===null){Re===null&&(Re=st);break}e&&Re&&Zi.alternate===null&&n(te,Re),Y=g(Zi,Y,Xe),gt===null?Me=Zi:gt.sibling=Zi,gt=Zi,Re=st}if(yt.done)return l(te,Re),ut&&di(te,Xe),Me;if(Re===null){for(;!yt.done;Xe++,yt=le.next())yt=me(te,yt.value,pe),yt!==null&&(Y=g(yt,Y,Xe),gt===null?Me=yt:gt.sibling=yt,gt=yt);return ut&&di(te,Xe),Me}for(Re=o(Re);!yt.done;Xe++,yt=le.next())yt=de(Re,te,Xe,yt.value,pe),yt!==null&&(e&&yt.alternate!==null&&Re.delete(yt.key===null?Xe:yt.key),Y=g(yt,Y,Xe),gt===null?Me=yt:gt.sibling=yt,gt=yt);return e&&Re.forEach(function(C1){return n(te,C1)}),ut&&di(te,Xe),Me}function Nt(te,Y,le,pe){if(typeof le=="object"&&le!==null&&le.type===R&&le.key===null&&(le=le.props.children),typeof le=="object"&&le!==null){switch(le.$$typeof){case x:e:{for(var Me=le.key;Y!==null;){if(Y.key===Me){if(Me=le.type,Me===R){if(Y.tag===7){l(te,Y.sibling),pe=f(Y,le.props.children),pe.return=te,te=pe;break e}}else if(Y.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===X&&fr(Me)===Y.type){l(te,Y.sibling),pe=f(Y,le.props),Hl(pe,le),pe.return=te,te=pe;break e}l(te,Y);break}else n(te,Y);Y=Y.sibling}le.type===R?(pe=sr(le.props.children,te.mode,pe,le.key),pe.return=te,te=pe):(pe=Ja(le.type,le.key,le.props,null,te.mode,pe),Hl(pe,le),pe.return=te,te=pe)}return w(te);case j:e:{for(Me=le.key;Y!==null;){if(Y.key===Me)if(Y.tag===4&&Y.stateNode.containerInfo===le.containerInfo&&Y.stateNode.implementation===le.implementation){l(te,Y.sibling),pe=f(Y,le.children||[]),pe.return=te,te=pe;break e}else{l(te,Y);break}else n(te,Y);Y=Y.sibling}pe=au(le,te.mode,pe),pe.return=te,te=pe}return w(te);case X:return le=fr(le),Nt(te,Y,le,pe)}if(ee(le))return Ee(te,Y,le,pe);if(L(le)){if(Me=L(le),typeof Me!="function")throw Error(a(150));return le=Me.call(le),Le(te,Y,le,pe)}if(typeof le.then=="function")return Nt(te,Y,ls(le),pe);if(le.$$typeof===D)return Nt(te,Y,ts(te,le),pe);as(te,le)}return typeof le=="string"&&le!==""||typeof le=="number"||typeof le=="bigint"?(le=""+le,Y!==null&&Y.tag===6?(l(te,Y.sibling),pe=f(Y,le),pe.return=te,te=pe):(l(te,Y),pe=lu(le,te.mode,pe),pe.return=te,te=pe),w(te)):l(te,Y)}return function(te,Y,le,pe){try{ql=0;var Me=Nt(te,Y,le,pe);return Xr=null,Me}catch(Re){if(Re===Qr||Re===is)throw Re;var gt=jn(29,Re,null,te.mode);return gt.lanes=pe,gt.return=te,gt}}}var pr=Kh(!0),Zh=Kh(!1),Mi=!1;function bu(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function vu(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Oi(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Li(e,n,l){var o=e.updateQueue;if(o===null)return null;if(o=o.shared,(vt&2)!==0){var f=o.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),o.pending=n,n=Za(e),Mh(e,null,l),n}return Ka(e,o,n,l),Za(e)}function Gl(e,n,l){if(n=n.updateQueue,n!==null&&(n=n.shared,(l&4194048)!==0)){var o=n.lanes;o&=e.pendingLanes,l|=o,n.lanes=l,ot(e,l)}}function xu(e,n){var l=e.updateQueue,o=e.alternate;if(o!==null&&(o=o.updateQueue,l===o)){var f=null,g=null;if(l=l.firstBaseUpdate,l!==null){do{var w={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};g===null?f=g=w:g=g.next=w,l=l.next}while(l!==null);g===null?f=g=n:g=g.next=n}else f=g=n;l={baseState:o.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:o.shared,callbacks:o.callbacks},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=n:e.next=n,l.lastBaseUpdate=n}var wu=!1;function Vl(){if(wu){var e=Fr;if(e!==null)throw e}}function $l(e,n,l,o){wu=!1;var f=e.updateQueue;Mi=!1;var g=f.firstBaseUpdate,w=f.lastBaseUpdate,z=f.shared.pending;if(z!==null){f.shared.pending=null;var $=z,se=$.next;$.next=null,w===null?g=se:w.next=se,w=$;var he=e.alternate;he!==null&&(he=he.updateQueue,z=he.lastBaseUpdate,z!==w&&(z===null?he.firstBaseUpdate=se:z.next=se,he.lastBaseUpdate=$))}if(g!==null){var me=f.baseState;w=0,he=se=$=null,z=g;do{var oe=z.lane&-536870913,de=oe!==z.lane;if(de?(at&oe)===oe:(o&oe)===oe){oe!==0&&oe===Yr&&(wu=!0),he!==null&&(he=he.next={lane:0,tag:z.tag,payload:z.payload,callback:null,next:null});e:{var Ee=e,Le=z;oe=n;var Nt=l;switch(Le.tag){case 1:if(Ee=Le.payload,typeof Ee=="function"){me=Ee.call(Nt,me,oe);break e}me=Ee;break e;case 3:Ee.flags=Ee.flags&-65537|128;case 0:if(Ee=Le.payload,oe=typeof Ee=="function"?Ee.call(Nt,me,oe):Ee,oe==null)break e;me=b({},me,oe);break e;case 2:Mi=!0}}oe=z.callback,oe!==null&&(e.flags|=64,de&&(e.flags|=8192),de=f.callbacks,de===null?f.callbacks=[oe]:de.push(oe))}else de={lane:oe,tag:z.tag,payload:z.payload,callback:z.callback,next:null},he===null?(se=he=de,$=me):he=he.next=de,w|=oe;if(z=z.next,z===null){if(z=f.shared.pending,z===null)break;de=z,z=de.next,de.next=null,f.lastBaseUpdate=de,f.shared.pending=null}}while(!0);he===null&&($=me),f.baseState=$,f.firstBaseUpdate=se,f.lastBaseUpdate=he,g===null&&(f.shared.lanes=0),Hi|=w,e.lanes=w,e.memoizedState=me}}function Jh(e,n){if(typeof e!="function")throw Error(a(191,e));e.call(n)}function Wh(e,n){var l=e.callbacks;if(l!==null)for(e.callbacks=null,e=0;e<l.length;e++)Jh(l[e],n)}var Kr=O(null),ss=O(0);function ep(e,n){e=Si,E(ss,e),E(Kr,n),Si=e|n.baseLanes}function Su(){E(ss,Si),E(Kr,Kr.current)}function ju(){Si=ss.current,re(Kr),re(ss)}var kn=O(null),Un=null;function Bi(e){var n=e.alternate;E(Vt,Vt.current&1),E(kn,e),Un===null&&(n===null||Kr.current!==null||n.memoizedState!==null)&&(Un=e)}function ku(e){E(Vt,Vt.current),E(kn,e),Un===null&&(Un=e)}function tp(e){e.tag===22?(E(Vt,Vt.current),E(kn,e),Un===null&&(Un=e)):Ui()}function Ui(){E(Vt,Vt.current),E(kn,kn.current)}function Cn(e){re(kn),Un===e&&(Un=null),re(Vt)}var Vt=O(0);function os(e){for(var n=e;n!==null;){if(n.tag===13){var l=n.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||Rc(l)||zc(l)))return n}else if(n.tag===19&&(n.memoizedProps.revealOrder==="forwards"||n.memoizedProps.revealOrder==="backwards"||n.memoizedProps.revealOrder==="unstable_legacy-backwards"||n.memoizedProps.revealOrder==="together")){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var pi=0,Ye=null,Ct=null,Qt=null,us=!1,Zr=!1,mr=!1,cs=0,Pl=0,Jr=null,m0=0;function qt(){throw Error(a(321))}function Cu(e,n){if(n===null)return!1;for(var l=0;l<n.length&&l<e.length;l++)if(!Sn(e[l],n[l]))return!1;return!0}function Eu(e,n,l,o,f,g){return pi=g,Ye=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,V.H=e===null||e.memoizedState===null?Up:Hu,mr=!1,g=l(o,f),mr=!1,Zr&&(g=ip(n,l,o,f)),np(e),g}function np(e){V.H=Ql;var n=Ct!==null&&Ct.next!==null;if(pi=0,Qt=Ct=Ye=null,us=!1,Pl=0,Jr=null,n)throw Error(a(300));e===null||Xt||(e=e.dependencies,e!==null&&es(e)&&(Xt=!0))}function ip(e,n,l,o){Ye=e;var f=0;do{if(Zr&&(Jr=null),Pl=0,Zr=!1,25<=f)throw Error(a(301));if(f+=1,Qt=Ct=null,e.updateQueue!=null){var g=e.updateQueue;g.lastEffect=null,g.events=null,g.stores=null,g.memoCache!=null&&(g.memoCache.index=0)}V.H=Ip,g=n(l,o)}while(Zr);return g}function g0(){var e=V.H,n=e.useState()[0];return n=typeof n.then=="function"?Yl(n):n,e=e.useState()[0],(Ct!==null?Ct.memoizedState:null)!==e&&(Ye.flags|=1024),n}function Nu(){var e=cs!==0;return cs=0,e}function Tu(e,n,l){n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~l}function Au(e){if(us){for(e=e.memoizedState;e!==null;){var n=e.queue;n!==null&&(n.pending=null),e=e.next}us=!1}pi=0,Qt=Ct=Ye=null,Zr=!1,Pl=cs=0,Jr=null}function dn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Qt===null?Ye.memoizedState=Qt=e:Qt=Qt.next=e,Qt}function $t(){if(Ct===null){var e=Ye.alternate;e=e!==null?e.memoizedState:null}else e=Ct.next;var n=Qt===null?Ye.memoizedState:Qt.next;if(n!==null)Qt=n,Ct=e;else{if(e===null)throw Ye.alternate===null?Error(a(467)):Error(a(310));Ct=e,e={memoizedState:Ct.memoizedState,baseState:Ct.baseState,baseQueue:Ct.baseQueue,queue:Ct.queue,next:null},Qt===null?Ye.memoizedState=Qt=e:Qt=Qt.next=e}return Qt}function ds(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Yl(e){var n=Pl;return Pl+=1,Jr===null&&(Jr=[]),e=Fh(Jr,e,n),n=Ye,(Qt===null?n.memoizedState:Qt.next)===null&&(n=n.alternate,V.H=n===null||n.memoizedState===null?Up:Hu),e}function fs(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Yl(e);if(e.$$typeof===D)return ln(e)}throw Error(a(438,String(e)))}function Ru(e){var n=null,l=Ye.updateQueue;if(l!==null&&(n=l.memoCache),n==null){var o=Ye.alternate;o!==null&&(o=o.updateQueue,o!==null&&(o=o.memoCache,o!=null&&(n={data:o.data.map(function(f){return f.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),l===null&&(l=ds(),Ye.updateQueue=l),l.memoCache=n,l=n.data[n.index],l===void 0)for(l=n.data[n.index]=Array(e),o=0;o<e;o++)l[o]=T;return n.index++,l}function mi(e,n){return typeof n=="function"?n(e):n}function hs(e){var n=$t();return zu(n,Ct,e)}function zu(e,n,l){var o=e.queue;if(o===null)throw Error(a(311));o.lastRenderedReducer=l;var f=e.baseQueue,g=o.pending;if(g!==null){if(f!==null){var w=f.next;f.next=g.next,g.next=w}n.baseQueue=f=g,o.pending=null}if(g=e.baseState,f===null)e.memoizedState=g;else{n=f.next;var z=w=null,$=null,se=n,he=!1;do{var me=se.lane&-536870913;if(me!==se.lane?(at&me)===me:(pi&me)===me){var oe=se.revertLane;if(oe===0)$!==null&&($=$.next={lane:0,revertLane:0,gesture:null,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null}),me===Yr&&(he=!0);else if((pi&oe)===oe){se=se.next,oe===Yr&&(he=!0);continue}else me={lane:0,revertLane:se.revertLane,gesture:null,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null},$===null?(z=$=me,w=g):$=$.next=me,Ye.lanes|=oe,Hi|=oe;me=se.action,mr&&l(g,me),g=se.hasEagerState?se.eagerState:l(g,me)}else oe={lane:me,revertLane:se.revertLane,gesture:se.gesture,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null},$===null?(z=$=oe,w=g):$=$.next=oe,Ye.lanes|=me,Hi|=me;se=se.next}while(se!==null&&se!==n);if($===null?w=g:$.next=z,!Sn(g,e.memoizedState)&&(Xt=!0,he&&(l=Fr,l!==null)))throw l;e.memoizedState=g,e.baseState=w,e.baseQueue=$,o.lastRenderedState=g}return f===null&&(o.lanes=0),[e.memoizedState,o.dispatch]}function _u(e){var n=$t(),l=n.queue;if(l===null)throw Error(a(311));l.lastRenderedReducer=e;var o=l.dispatch,f=l.pending,g=n.memoizedState;if(f!==null){l.pending=null;var w=f=f.next;do g=e(g,w.action),w=w.next;while(w!==f);Sn(g,n.memoizedState)||(Xt=!0),n.memoizedState=g,n.baseQueue===null&&(n.baseState=g),l.lastRenderedState=g}return[g,o]}function rp(e,n,l){var o=Ye,f=$t(),g=ut;if(g){if(l===void 0)throw Error(a(407));l=l()}else l=n();var w=!Sn((Ct||f).memoizedState,l);if(w&&(f.memoizedState=l,Xt=!0),f=f.queue,Ou(sp.bind(null,o,f,e),[e]),f.getSnapshot!==n||w||Qt!==null&&Qt.memoizedState.tag&1){if(o.flags|=2048,Wr(9,{destroy:void 0},ap.bind(null,o,f,l,n),null),Rt===null)throw Error(a(349));g||(pi&127)!==0||lp(o,n,l)}return l}function lp(e,n,l){e.flags|=16384,e={getSnapshot:n,value:l},n=Ye.updateQueue,n===null?(n=ds(),Ye.updateQueue=n,n.stores=[e]):(l=n.stores,l===null?n.stores=[e]:l.push(e))}function ap(e,n,l,o){n.value=l,n.getSnapshot=o,op(n)&&up(e)}function sp(e,n,l){return l(function(){op(n)&&up(e)})}function op(e){var n=e.getSnapshot;e=e.value;try{var l=n();return!Sn(e,l)}catch{return!0}}function up(e){var n=ar(e,2);n!==null&&vn(n,e,2)}function Du(e){var n=dn();if(typeof e=="function"){var l=e;if(e=l(),mr){mt(!0);try{l()}finally{mt(!1)}}}return n.memoizedState=n.baseState=e,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:mi,lastRenderedState:e},n}function cp(e,n,l,o){return e.baseState=l,zu(e,Ct,typeof o=="function"?o:mi)}function y0(e,n,l,o,f){if(gs(e))throw Error(a(485));if(e=n.action,e!==null){var g={payload:f,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(w){g.listeners.push(w)}};V.T!==null?l(!0):g.isTransition=!1,o(g),l=n.pending,l===null?(g.next=n.pending=g,dp(n,g)):(g.next=l.next,n.pending=l.next=g)}}function dp(e,n){var l=n.action,o=n.payload,f=e.state;if(n.isTransition){var g=V.T,w={};V.T=w;try{var z=l(f,o),$=V.S;$!==null&&$(w,z),fp(e,n,z)}catch(se){Mu(e,n,se)}finally{g!==null&&w.types!==null&&(g.types=w.types),V.T=g}}else try{g=l(f,o),fp(e,n,g)}catch(se){Mu(e,n,se)}}function fp(e,n,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(o){hp(e,n,o)},function(o){return Mu(e,n,o)}):hp(e,n,l)}function hp(e,n,l){n.status="fulfilled",n.value=l,pp(n),e.state=l,n=e.pending,n!==null&&(l=n.next,l===n?e.pending=null:(l=l.next,n.next=l,dp(e,l)))}function Mu(e,n,l){var o=e.pending;if(e.pending=null,o!==null){o=o.next;do n.status="rejected",n.reason=l,pp(n),n=n.next;while(n!==o)}e.action=null}function pp(e){e=e.listeners;for(var n=0;n<e.length;n++)(0,e[n])()}function mp(e,n){return n}function gp(e,n){if(ut){var l=Rt.formState;if(l!==null){e:{var o=Ye;if(ut){if(Mt){t:{for(var f=Mt,g=Bn;f.nodeType!==8;){if(!g){f=null;break t}if(f=In(f.nextSibling),f===null){f=null;break t}}g=f.data,f=g==="F!"||g==="F"?f:null}if(f){Mt=In(f.nextSibling),o=f.data==="F!";break e}}_i(o)}o=!1}o&&(n=l[0])}}return l=dn(),l.memoizedState=l.baseState=n,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:mp,lastRenderedState:n},l.queue=o,l=Op.bind(null,Ye,o),o.dispatch=l,o=Du(!1),g=qu.bind(null,Ye,!1,o.queue),o=dn(),f={state:n,dispatch:null,action:e,pending:null},o.queue=f,l=y0.bind(null,Ye,f,g,l),f.dispatch=l,o.memoizedState=e,[n,l,!1]}function yp(e){var n=$t();return bp(n,Ct,e)}function bp(e,n,l){if(n=zu(e,n,mp)[0],e=hs(mi)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var o=Yl(n)}catch(w){throw w===Qr?is:w}else o=n;n=$t();var f=n.queue,g=f.dispatch;return l!==n.memoizedState&&(Ye.flags|=2048,Wr(9,{destroy:void 0},b0.bind(null,f,l),null)),[o,g,e]}function b0(e,n){e.action=n}function vp(e){var n=$t(),l=Ct;if(l!==null)return bp(n,l,e);$t(),n=n.memoizedState,l=$t();var o=l.queue.dispatch;return l.memoizedState=e,[n,o,!1]}function Wr(e,n,l,o){return e={tag:e,create:l,deps:o,inst:n,next:null},n=Ye.updateQueue,n===null&&(n=ds(),Ye.updateQueue=n),l=n.lastEffect,l===null?n.lastEffect=e.next=e:(o=l.next,l.next=e,e.next=o,n.lastEffect=e),e}function xp(){return $t().memoizedState}function ps(e,n,l,o){var f=dn();Ye.flags|=e,f.memoizedState=Wr(1|n,{destroy:void 0},l,o===void 0?null:o)}function ms(e,n,l,o){var f=$t();o=o===void 0?null:o;var g=f.memoizedState.inst;Ct!==null&&o!==null&&Cu(o,Ct.memoizedState.deps)?f.memoizedState=Wr(n,g,l,o):(Ye.flags|=e,f.memoizedState=Wr(1|n,g,l,o))}function wp(e,n){ps(8390656,8,e,n)}function Ou(e,n){ms(2048,8,e,n)}function v0(e){Ye.flags|=4;var n=Ye.updateQueue;if(n===null)n=ds(),Ye.updateQueue=n,n.events=[e];else{var l=n.events;l===null?n.events=[e]:l.push(e)}}function Sp(e){var n=$t().memoizedState;return v0({ref:n,nextImpl:e}),function(){if((vt&2)!==0)throw Error(a(440));return n.impl.apply(void 0,arguments)}}function jp(e,n){return ms(4,2,e,n)}function kp(e,n){return ms(4,4,e,n)}function Cp(e,n){if(typeof n=="function"){e=e();var l=n(e);return function(){typeof l=="function"?l():n(null)}}if(n!=null)return e=e(),n.current=e,function(){n.current=null}}function Ep(e,n,l){l=l!=null?l.concat([e]):null,ms(4,4,Cp.bind(null,n,e),l)}function Lu(){}function Np(e,n){var l=$t();n=n===void 0?null:n;var o=l.memoizedState;return n!==null&&Cu(n,o[1])?o[0]:(l.memoizedState=[e,n],e)}function Tp(e,n){var l=$t();n=n===void 0?null:n;var o=l.memoizedState;if(n!==null&&Cu(n,o[1]))return o[0];if(o=e(),mr){mt(!0);try{e()}finally{mt(!1)}}return l.memoizedState=[o,n],o}function Bu(e,n,l){return l===void 0||(pi&1073741824)!==0&&(at&261930)===0?e.memoizedState=n:(e.memoizedState=l,e=Am(),Ye.lanes|=e,Hi|=e,l)}function Ap(e,n,l,o){return Sn(l,n)?l:Kr.current!==null?(e=Bu(e,l,o),Sn(e,n)||(Xt=!0),e):(pi&42)===0||(pi&1073741824)!==0&&(at&261930)===0?(Xt=!0,e.memoizedState=l):(e=Am(),Ye.lanes|=e,Hi|=e,n)}function Rp(e,n,l,o,f){var g=B.p;B.p=g!==0&&8>g?g:8;var w=V.T,z={};V.T=z,qu(e,!1,n,l);try{var $=f(),se=V.S;if(se!==null&&se(z,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var he=p0($,o);Fl(e,n,he,Tn(e))}else Fl(e,n,o,Tn(e))}catch(me){Fl(e,n,{then:function(){},status:"rejected",reason:me},Tn())}finally{B.p=g,w!==null&&z.types!==null&&(w.types=z.types),V.T=w}}function x0(){}function Uu(e,n,l,o){if(e.tag!==5)throw Error(a(476));var f=zp(e).queue;Rp(e,f,n,Q,l===null?x0:function(){return _p(e),l(o)})}function zp(e){var n=e.memoizedState;if(n!==null)return n;n={memoizedState:Q,baseState:Q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:mi,lastRenderedState:Q},next:null};var l={};return n.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:mi,lastRenderedState:l},next:null},e.memoizedState=n,e=e.alternate,e!==null&&(e.memoizedState=n),n}function _p(e){var n=zp(e);n.next===null&&(n=e.alternate.memoizedState),Fl(e,n.next.queue,{},Tn())}function Iu(){return ln(ca)}function Dp(){return $t().memoizedState}function Mp(){return $t().memoizedState}function w0(e){for(var n=e.return;n!==null;){switch(n.tag){case 24:case 3:var l=Tn();e=Oi(l);var o=Li(n,e,l);o!==null&&(vn(o,n,l),Gl(o,n,l)),n={cache:pu()},e.payload=n;return}n=n.return}}function S0(e,n,l){var o=Tn();l={lane:o,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},gs(e)?Lp(n,l):(l=iu(e,n,l,o),l!==null&&(vn(l,e,o),Bp(l,n,o)))}function Op(e,n,l){var o=Tn();Fl(e,n,l,o)}function Fl(e,n,l,o){var f={lane:o,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(gs(e))Lp(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var w=n.lastRenderedState,z=g(w,l);if(f.hasEagerState=!0,f.eagerState=z,Sn(z,w))return Ka(e,n,f,0),Rt===null&&Xa(),!1}catch{}if(l=iu(e,n,f,o),l!==null)return vn(l,e,o),Bp(l,n,o),!0}return!1}function qu(e,n,l,o){if(o={lane:2,revertLane:bc(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},gs(e)){if(n)throw Error(a(479))}else n=iu(e,l,o,2),n!==null&&vn(n,e,2)}function gs(e){var n=e.alternate;return e===Ye||n!==null&&n===Ye}function Lp(e,n){Zr=us=!0;var l=e.pending;l===null?n.next=n:(n.next=l.next,l.next=n),e.pending=n}function Bp(e,n,l){if((l&4194048)!==0){var o=n.lanes;o&=e.pendingLanes,l|=o,n.lanes=l,ot(e,l)}}var Ql={readContext:ln,use:fs,useCallback:qt,useContext:qt,useEffect:qt,useImperativeHandle:qt,useLayoutEffect:qt,useInsertionEffect:qt,useMemo:qt,useReducer:qt,useRef:qt,useState:qt,useDebugValue:qt,useDeferredValue:qt,useTransition:qt,useSyncExternalStore:qt,useId:qt,useHostTransitionStatus:qt,useFormState:qt,useActionState:qt,useOptimistic:qt,useMemoCache:qt,useCacheRefresh:qt};Ql.useEffectEvent=qt;var Up={readContext:ln,use:fs,useCallback:function(e,n){return dn().memoizedState=[e,n===void 0?null:n],e},useContext:ln,useEffect:wp,useImperativeHandle:function(e,n,l){l=l!=null?l.concat([e]):null,ps(4194308,4,Cp.bind(null,n,e),l)},useLayoutEffect:function(e,n){return ps(4194308,4,e,n)},useInsertionEffect:function(e,n){ps(4,2,e,n)},useMemo:function(e,n){var l=dn();n=n===void 0?null:n;var o=e();if(mr){mt(!0);try{e()}finally{mt(!1)}}return l.memoizedState=[o,n],o},useReducer:function(e,n,l){var o=dn();if(l!==void 0){var f=l(n);if(mr){mt(!0);try{l(n)}finally{mt(!1)}}}else f=n;return o.memoizedState=o.baseState=f,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:f},o.queue=e,e=e.dispatch=S0.bind(null,Ye,e),[o.memoizedState,e]},useRef:function(e){var n=dn();return e={current:e},n.memoizedState=e},useState:function(e){e=Du(e);var n=e.queue,l=Op.bind(null,Ye,n);return n.dispatch=l,[e.memoizedState,l]},useDebugValue:Lu,useDeferredValue:function(e,n){var l=dn();return Bu(l,e,n)},useTransition:function(){var e=Du(!1);return e=Rp.bind(null,Ye,e.queue,!0,!1),dn().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,l){var o=Ye,f=dn();if(ut){if(l===void 0)throw Error(a(407));l=l()}else{if(l=n(),Rt===null)throw Error(a(349));(at&127)!==0||lp(o,n,l)}f.memoizedState=l;var g={value:l,getSnapshot:n};return f.queue=g,wp(sp.bind(null,o,g,e),[e]),o.flags|=2048,Wr(9,{destroy:void 0},ap.bind(null,o,g,l,n),null),l},useId:function(){var e=dn(),n=Rt.identifierPrefix;if(ut){var l=Zn,o=Kn;l=(o&~(1<<32-lt(o)-1)).toString(32)+l,n="_"+n+"R_"+l,l=cs++,0<l&&(n+="H"+l.toString(32)),n+="_"}else l=m0++,n="_"+n+"r_"+l.toString(32)+"_";return e.memoizedState=n},useHostTransitionStatus:Iu,useFormState:gp,useActionState:gp,useOptimistic:function(e){var n=dn();n.memoizedState=n.baseState=e;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=l,n=qu.bind(null,Ye,!0,l),l.dispatch=n,[e,n]},useMemoCache:Ru,useCacheRefresh:function(){return dn().memoizedState=w0.bind(null,Ye)},useEffectEvent:function(e){var n=dn(),l={impl:e};return n.memoizedState=l,function(){if((vt&2)!==0)throw Error(a(440));return l.impl.apply(void 0,arguments)}}},Hu={readContext:ln,use:fs,useCallback:Np,useContext:ln,useEffect:Ou,useImperativeHandle:Ep,useInsertionEffect:jp,useLayoutEffect:kp,useMemo:Tp,useReducer:hs,useRef:xp,useState:function(){return hs(mi)},useDebugValue:Lu,useDeferredValue:function(e,n){var l=$t();return Ap(l,Ct.memoizedState,e,n)},useTransition:function(){var e=hs(mi)[0],n=$t().memoizedState;return[typeof e=="boolean"?e:Yl(e),n]},useSyncExternalStore:rp,useId:Dp,useHostTransitionStatus:Iu,useFormState:yp,useActionState:yp,useOptimistic:function(e,n){var l=$t();return cp(l,Ct,e,n)},useMemoCache:Ru,useCacheRefresh:Mp};Hu.useEffectEvent=Sp;var Ip={readContext:ln,use:fs,useCallback:Np,useContext:ln,useEffect:Ou,useImperativeHandle:Ep,useInsertionEffect:jp,useLayoutEffect:kp,useMemo:Tp,useReducer:_u,useRef:xp,useState:function(){return _u(mi)},useDebugValue:Lu,useDeferredValue:function(e,n){var l=$t();return Ct===null?Bu(l,e,n):Ap(l,Ct.memoizedState,e,n)},useTransition:function(){var e=_u(mi)[0],n=$t().memoizedState;return[typeof e=="boolean"?e:Yl(e),n]},useSyncExternalStore:rp,useId:Dp,useHostTransitionStatus:Iu,useFormState:vp,useActionState:vp,useOptimistic:function(e,n){var l=$t();return Ct!==null?cp(l,Ct,e,n):(l.baseState=e,[e,l.queue.dispatch])},useMemoCache:Ru,useCacheRefresh:Mp};Ip.useEffectEvent=Sp;function Gu(e,n,l,o){n=e.memoizedState,l=l(o,n),l=l==null?n:b({},n,l),e.memoizedState=l,e.lanes===0&&(e.updateQueue.baseState=l)}var Vu={enqueueSetState:function(e,n,l){e=e._reactInternals;var o=Tn(),f=Oi(o);f.payload=n,l!=null&&(f.callback=l),n=Li(e,f,o),n!==null&&(vn(n,e,o),Gl(n,e,o))},enqueueReplaceState:function(e,n,l){e=e._reactInternals;var o=Tn(),f=Oi(o);f.tag=1,f.payload=n,l!=null&&(f.callback=l),n=Li(e,f,o),n!==null&&(vn(n,e,o),Gl(n,e,o))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var l=Tn(),o=Oi(l);o.tag=2,n!=null&&(o.callback=n),n=Li(e,o,l),n!==null&&(vn(n,e,l),Gl(n,e,l))}};function qp(e,n,l,o,f,g,w){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(o,g,w):n.prototype&&n.prototype.isPureReactComponent?!Ml(l,o)||!Ml(f,g):!0}function Hp(e,n,l,o){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(l,o),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(l,o),n.state!==e&&Vu.enqueueReplaceState(n,n.state,null)}function gr(e,n){var l=n;if("ref"in n){l={};for(var o in n)o!=="ref"&&(l[o]=n[o])}if(e=e.defaultProps){l===n&&(l=b({},l));for(var f in e)l[f]===void 0&&(l[f]=e[f])}return l}function Gp(e){Qa(e)}function Vp(e){console.error(e)}function $p(e){Qa(e)}function ys(e,n){try{var l=e.onUncaughtError;l(n.value,{componentStack:n.stack})}catch(o){setTimeout(function(){throw o})}}function Pp(e,n,l){try{var o=e.onCaughtError;o(l.value,{componentStack:l.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(f){setTimeout(function(){throw f})}}function $u(e,n,l){return l=Oi(l),l.tag=3,l.payload={element:null},l.callback=function(){ys(e,n)},l}function Yp(e){return e=Oi(e),e.tag=3,e}function Fp(e,n,l,o){var f=l.type.getDerivedStateFromError;if(typeof f=="function"){var g=o.value;e.payload=function(){return f(g)},e.callback=function(){Pp(n,l,o)}}var w=l.stateNode;w!==null&&typeof w.componentDidCatch=="function"&&(e.callback=function(){Pp(n,l,o),typeof f!="function"&&(Gi===null?Gi=new Set([this]):Gi.add(this));var z=o.stack;this.componentDidCatch(o.value,{componentStack:z!==null?z:""})})}function j0(e,n,l,o,f){if(l.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(n=l.alternate,n!==null&&Pr(n,l,f,!0),l=kn.current,l!==null){switch(l.tag){case 31:case 13:return Un===null?As():l.alternate===null&&Ht===0&&(Ht=3),l.flags&=-257,l.flags|=65536,l.lanes=f,o===rs?l.flags|=16384:(n=l.updateQueue,n===null?l.updateQueue=new Set([o]):n.add(o),mc(e,o,f)),!1;case 22:return l.flags|=65536,o===rs?l.flags|=16384:(n=l.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([o])},l.updateQueue=n):(l=n.retryQueue,l===null?n.retryQueue=new Set([o]):l.add(o)),mc(e,o,f)),!1}throw Error(a(435,l.tag))}return mc(e,o,f),As(),!1}if(ut)return n=kn.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=f,o!==uu&&(e=Error(a(422),{cause:o}),Bl(Mn(e,l)))):(o!==uu&&(n=Error(a(423),{cause:o}),Bl(Mn(n,l))),e=e.current.alternate,e.flags|=65536,f&=-f,e.lanes|=f,o=Mn(o,l),f=$u(e.stateNode,o,f),xu(e,f),Ht!==4&&(Ht=2)),!1;var g=Error(a(520),{cause:o});if(g=Mn(g,l),na===null?na=[g]:na.push(g),Ht!==4&&(Ht=2),n===null)return!0;o=Mn(o,l),l=n;do{switch(l.tag){case 3:return l.flags|=65536,e=f&-f,l.lanes|=e,e=$u(l.stateNode,o,e),xu(l,e),!1;case 1:if(n=l.type,g=l.stateNode,(l.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(Gi===null||!Gi.has(g))))return l.flags|=65536,f&=-f,l.lanes|=f,f=Yp(f),Fp(f,e,l,o),xu(l,f),!1}l=l.return}while(l!==null);return!1}var Pu=Error(a(461)),Xt=!1;function an(e,n,l,o){n.child=e===null?Zh(n,null,l,o):pr(n,e.child,l,o)}function Qp(e,n,l,o,f){l=l.render;var g=n.ref;if("ref"in o){var w={};for(var z in o)z!=="ref"&&(w[z]=o[z])}else w=o;return cr(n),o=Eu(e,n,l,w,g,f),z=Nu(),e!==null&&!Xt?(Tu(e,n,f),gi(e,n,f)):(ut&&z&&su(n),n.flags|=1,an(e,n,o,f),n.child)}function Xp(e,n,l,o,f){if(e===null){var g=l.type;return typeof g=="function"&&!ru(g)&&g.defaultProps===void 0&&l.compare===null?(n.tag=15,n.type=g,Kp(e,n,g,o,f)):(e=Ja(l.type,null,o,n,n.mode,f),e.ref=n.ref,e.return=n,n.child=e)}if(g=e.child,!Wu(e,f)){var w=g.memoizedProps;if(l=l.compare,l=l!==null?l:Ml,l(w,o)&&e.ref===n.ref)return gi(e,n,f)}return n.flags|=1,e=ci(g,o),e.ref=n.ref,e.return=n,n.child=e}function Kp(e,n,l,o,f){if(e!==null){var g=e.memoizedProps;if(Ml(g,o)&&e.ref===n.ref)if(Xt=!1,n.pendingProps=o=g,Wu(e,f))(e.flags&131072)!==0&&(Xt=!0);else return n.lanes=e.lanes,gi(e,n,f)}return Yu(e,n,l,o,f)}function Zp(e,n,l,o){var f=o.children,g=e!==null?e.memoizedState:null;if(e===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.mode==="hidden"){if((n.flags&128)!==0){if(g=g!==null?g.baseLanes|l:l,e!==null){for(o=n.child=e.child,f=0;o!==null;)f=f|o.lanes|o.childLanes,o=o.sibling;o=f&~g}else o=0,n.child=null;return Jp(e,n,g,l,o)}if((l&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},e!==null&&ns(n,g!==null?g.cachePool:null),g!==null?ep(n,g):Su(),tp(n);else return o=n.lanes=536870912,Jp(e,n,g!==null?g.baseLanes|l:l,l,o)}else g!==null?(ns(n,g.cachePool),ep(n,g),Ui(),n.memoizedState=null):(e!==null&&ns(n,null),Su(),Ui());return an(e,n,f,l),n.child}function Xl(e,n){return e!==null&&e.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function Jp(e,n,l,o,f){var g=gu();return g=g===null?null:{parent:Ft._currentValue,pool:g},n.memoizedState={baseLanes:l,cachePool:g},e!==null&&ns(n,null),Su(),tp(n),e!==null&&Pr(e,n,o,!0),n.childLanes=f,null}function bs(e,n){return n=xs({mode:n.mode,children:n.children},e.mode),n.ref=e.ref,e.child=n,n.return=e,n}function Wp(e,n,l){return pr(n,e.child,null,l),e=bs(n,n.pendingProps),e.flags|=2,Cn(n),n.memoizedState=null,e}function k0(e,n,l){var o=n.pendingProps,f=(n.flags&128)!==0;if(n.flags&=-129,e===null){if(ut){if(o.mode==="hidden")return e=bs(n,o),n.lanes=536870912,Xl(null,e);if(ku(n),(e=Mt)?(e=dg(e,Bn),e=e!==null&&e.data==="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:Ri!==null?{id:Kn,overflow:Zn}:null,retryLane:536870912,hydrationErrors:null},l=Lh(e),l.return=n,n.child=l,rn=n,Mt=null)):e=null,e===null)throw _i(n);return n.lanes=536870912,null}return bs(n,o)}var g=e.memoizedState;if(g!==null){var w=g.dehydrated;if(ku(n),f)if(n.flags&256)n.flags&=-257,n=Wp(e,n,l);else if(n.memoizedState!==null)n.child=e.child,n.flags|=128,n=null;else throw Error(a(558));else if(Xt||Pr(e,n,l,!1),f=(l&e.childLanes)!==0,Xt||f){if(o=Rt,o!==null&&(w=tt(o,l),w!==0&&w!==g.retryLane))throw g.retryLane=w,ar(e,w),vn(o,e,w),Pu;As(),n=Wp(e,n,l)}else e=g.treeContext,Mt=In(w.nextSibling),rn=n,ut=!0,zi=null,Bn=!1,e!==null&&Ih(n,e),n=bs(n,o),n.flags|=4096;return n}return e=ci(e.child,{mode:o.mode,children:o.children}),e.ref=n.ref,n.child=e,e.return=n,e}function vs(e,n){var l=n.ref;if(l===null)e!==null&&e.ref!==null&&(n.flags|=4194816);else{if(typeof l!="function"&&typeof l!="object")throw Error(a(284));(e===null||e.ref!==l)&&(n.flags|=4194816)}}function Yu(e,n,l,o,f){return cr(n),l=Eu(e,n,l,o,void 0,f),o=Nu(),e!==null&&!Xt?(Tu(e,n,f),gi(e,n,f)):(ut&&o&&su(n),n.flags|=1,an(e,n,l,f),n.child)}function em(e,n,l,o,f,g){return cr(n),n.updateQueue=null,l=ip(n,o,l,f),np(e),o=Nu(),e!==null&&!Xt?(Tu(e,n,g),gi(e,n,g)):(ut&&o&&su(n),n.flags|=1,an(e,n,l,g),n.child)}function tm(e,n,l,o,f){if(cr(n),n.stateNode===null){var g=Hr,w=l.contextType;typeof w=="object"&&w!==null&&(g=ln(w)),g=new l(o,g),n.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=Vu,n.stateNode=g,g._reactInternals=n,g=n.stateNode,g.props=o,g.state=n.memoizedState,g.refs={},bu(n),w=l.contextType,g.context=typeof w=="object"&&w!==null?ln(w):Hr,g.state=n.memoizedState,w=l.getDerivedStateFromProps,typeof w=="function"&&(Gu(n,l,w,o),g.state=n.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(w=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),w!==g.state&&Vu.enqueueReplaceState(g,g.state,null),$l(n,o,g,f),Vl(),g.state=n.memoizedState),typeof g.componentDidMount=="function"&&(n.flags|=4194308),o=!0}else if(e===null){g=n.stateNode;var z=n.memoizedProps,$=gr(l,z);g.props=$;var se=g.context,he=l.contextType;w=Hr,typeof he=="object"&&he!==null&&(w=ln(he));var me=l.getDerivedStateFromProps;he=typeof me=="function"||typeof g.getSnapshotBeforeUpdate=="function",z=n.pendingProps!==z,he||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(z||se!==w)&&Hp(n,g,o,w),Mi=!1;var oe=n.memoizedState;g.state=oe,$l(n,o,g,f),Vl(),se=n.memoizedState,z||oe!==se||Mi?(typeof me=="function"&&(Gu(n,l,me,o),se=n.memoizedState),($=Mi||qp(n,l,$,o,oe,se,w))?(he||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount()),typeof g.componentDidMount=="function"&&(n.flags|=4194308)):(typeof g.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=o,n.memoizedState=se),g.props=o,g.state=se,g.context=w,o=$):(typeof g.componentDidMount=="function"&&(n.flags|=4194308),o=!1)}else{g=n.stateNode,vu(e,n),w=n.memoizedProps,he=gr(l,w),g.props=he,me=n.pendingProps,oe=g.context,se=l.contextType,$=Hr,typeof se=="object"&&se!==null&&($=ln(se)),z=l.getDerivedStateFromProps,(se=typeof z=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(w!==me||oe!==$)&&Hp(n,g,o,$),Mi=!1,oe=n.memoizedState,g.state=oe,$l(n,o,g,f),Vl();var de=n.memoizedState;w!==me||oe!==de||Mi||e!==null&&e.dependencies!==null&&es(e.dependencies)?(typeof z=="function"&&(Gu(n,l,z,o),de=n.memoizedState),(he=Mi||qp(n,l,he,o,oe,de,$)||e!==null&&e.dependencies!==null&&es(e.dependencies))?(se||typeof g.UNSAFE_componentWillUpdate!="function"&&typeof g.componentWillUpdate!="function"||(typeof g.componentWillUpdate=="function"&&g.componentWillUpdate(o,de,$),typeof g.UNSAFE_componentWillUpdate=="function"&&g.UNSAFE_componentWillUpdate(o,de,$)),typeof g.componentDidUpdate=="function"&&(n.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof g.componentDidUpdate!="function"||w===e.memoizedProps&&oe===e.memoizedState||(n.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||w===e.memoizedProps&&oe===e.memoizedState||(n.flags|=1024),n.memoizedProps=o,n.memoizedState=de),g.props=o,g.state=de,g.context=$,o=he):(typeof g.componentDidUpdate!="function"||w===e.memoizedProps&&oe===e.memoizedState||(n.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||w===e.memoizedProps&&oe===e.memoizedState||(n.flags|=1024),o=!1)}return g=o,vs(e,n),o=(n.flags&128)!==0,g||o?(g=n.stateNode,l=o&&typeof l.getDerivedStateFromError!="function"?null:g.render(),n.flags|=1,e!==null&&o?(n.child=pr(n,e.child,null,f),n.child=pr(n,null,l,f)):an(e,n,l,f),n.memoizedState=g.state,e=n.child):e=gi(e,n,f),e}function nm(e,n,l,o){return or(),n.flags|=256,an(e,n,l,o),n.child}var Fu={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Qu(e){return{baseLanes:e,cachePool:Ph()}}function Xu(e,n,l){return e=e!==null?e.childLanes&~l:0,n&&(e|=Nn),e}function im(e,n,l){var o=n.pendingProps,f=!1,g=(n.flags&128)!==0,w;if((w=g)||(w=e!==null&&e.memoizedState===null?!1:(Vt.current&2)!==0),w&&(f=!0,n.flags&=-129),w=(n.flags&32)!==0,n.flags&=-33,e===null){if(ut){if(f?Bi(n):Ui(),(e=Mt)?(e=dg(e,Bn),e=e!==null&&e.data!=="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:Ri!==null?{id:Kn,overflow:Zn}:null,retryLane:536870912,hydrationErrors:null},l=Lh(e),l.return=n,n.child=l,rn=n,Mt=null)):e=null,e===null)throw _i(n);return zc(e)?n.lanes=32:n.lanes=536870912,null}var z=o.children;return o=o.fallback,f?(Ui(),f=n.mode,z=xs({mode:"hidden",children:z},f),o=sr(o,f,l,null),z.return=n,o.return=n,z.sibling=o,n.child=z,o=n.child,o.memoizedState=Qu(l),o.childLanes=Xu(e,w,l),n.memoizedState=Fu,Xl(null,o)):(Bi(n),Ku(n,z))}var $=e.memoizedState;if($!==null&&(z=$.dehydrated,z!==null)){if(g)n.flags&256?(Bi(n),n.flags&=-257,n=Zu(e,n,l)):n.memoizedState!==null?(Ui(),n.child=e.child,n.flags|=128,n=null):(Ui(),z=o.fallback,f=n.mode,o=xs({mode:"visible",children:o.children},f),z=sr(z,f,l,null),z.flags|=2,o.return=n,z.return=n,o.sibling=z,n.child=o,pr(n,e.child,null,l),o=n.child,o.memoizedState=Qu(l),o.childLanes=Xu(e,w,l),n.memoizedState=Fu,n=Xl(null,o));else if(Bi(n),zc(z)){if(w=z.nextSibling&&z.nextSibling.dataset,w)var se=w.dgst;w=se,o=Error(a(419)),o.stack="",o.digest=w,Bl({value:o,source:null,stack:null}),n=Zu(e,n,l)}else if(Xt||Pr(e,n,l,!1),w=(l&e.childLanes)!==0,Xt||w){if(w=Rt,w!==null&&(o=tt(w,l),o!==0&&o!==$.retryLane))throw $.retryLane=o,ar(e,o),vn(w,e,o),Pu;Rc(z)||As(),n=Zu(e,n,l)}else Rc(z)?(n.flags|=192,n.child=e.child,n=null):(e=$.treeContext,Mt=In(z.nextSibling),rn=n,ut=!0,zi=null,Bn=!1,e!==null&&Ih(n,e),n=Ku(n,o.children),n.flags|=4096);return n}return f?(Ui(),z=o.fallback,f=n.mode,$=e.child,se=$.sibling,o=ci($,{mode:"hidden",children:o.children}),o.subtreeFlags=$.subtreeFlags&65011712,se!==null?z=ci(se,z):(z=sr(z,f,l,null),z.flags|=2),z.return=n,o.return=n,o.sibling=z,n.child=o,Xl(null,o),o=n.child,z=e.child.memoizedState,z===null?z=Qu(l):(f=z.cachePool,f!==null?($=Ft._currentValue,f=f.parent!==$?{parent:$,pool:$}:f):f=Ph(),z={baseLanes:z.baseLanes|l,cachePool:f}),o.memoizedState=z,o.childLanes=Xu(e,w,l),n.memoizedState=Fu,Xl(e.child,o)):(Bi(n),l=e.child,e=l.sibling,l=ci(l,{mode:"visible",children:o.children}),l.return=n,l.sibling=null,e!==null&&(w=n.deletions,w===null?(n.deletions=[e],n.flags|=16):w.push(e)),n.child=l,n.memoizedState=null,l)}function Ku(e,n){return n=xs({mode:"visible",children:n},e.mode),n.return=e,e.child=n}function xs(e,n){return e=jn(22,e,null,n),e.lanes=0,e}function Zu(e,n,l){return pr(n,e.child,null,l),e=Ku(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function rm(e,n,l){e.lanes|=n;var o=e.alternate;o!==null&&(o.lanes|=n),fu(e.return,n,l)}function Ju(e,n,l,o,f,g){var w=e.memoizedState;w===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:o,tail:l,tailMode:f,treeForkCount:g}:(w.isBackwards=n,w.rendering=null,w.renderingStartTime=0,w.last=o,w.tail=l,w.tailMode=f,w.treeForkCount=g)}function lm(e,n,l){var o=n.pendingProps,f=o.revealOrder,g=o.tail;o=o.children;var w=Vt.current,z=(w&2)!==0;if(z?(w=w&1|2,n.flags|=128):w&=1,E(Vt,w),an(e,n,o,l),o=ut?Ll:0,!z&&e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&rm(e,l,n);else if(e.tag===19)rm(e,l,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(f){case"forwards":for(l=n.child,f=null;l!==null;)e=l.alternate,e!==null&&os(e)===null&&(f=l),l=l.sibling;l=f,l===null?(f=n.child,n.child=null):(f=l.sibling,l.sibling=null),Ju(n,!1,f,l,g,o);break;case"backwards":case"unstable_legacy-backwards":for(l=null,f=n.child,n.child=null;f!==null;){if(e=f.alternate,e!==null&&os(e)===null){n.child=f;break}e=f.sibling,f.sibling=l,l=f,f=e}Ju(n,!0,l,null,g,o);break;case"together":Ju(n,!1,null,null,void 0,o);break;default:n.memoizedState=null}return n.child}function gi(e,n,l){if(e!==null&&(n.dependencies=e.dependencies),Hi|=n.lanes,(l&n.childLanes)===0)if(e!==null){if(Pr(e,n,l,!1),(l&n.childLanes)===0)return null}else return null;if(e!==null&&n.child!==e.child)throw Error(a(153));if(n.child!==null){for(e=n.child,l=ci(e,e.pendingProps),n.child=l,l.return=n;e.sibling!==null;)e=e.sibling,l=l.sibling=ci(e,e.pendingProps),l.return=n;l.sibling=null}return n.child}function Wu(e,n){return(e.lanes&n)!==0?!0:(e=e.dependencies,!!(e!==null&&es(e)))}function C0(e,n,l){switch(n.tag){case 3:ge(n,n.stateNode.containerInfo),Di(n,Ft,e.memoizedState.cache),or();break;case 27:case 5:ve(n);break;case 4:ge(n,n.stateNode.containerInfo);break;case 10:Di(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,ku(n),null;break;case 13:var o=n.memoizedState;if(o!==null)return o.dehydrated!==null?(Bi(n),n.flags|=128,null):(l&n.child.childLanes)!==0?im(e,n,l):(Bi(n),e=gi(e,n,l),e!==null?e.sibling:null);Bi(n);break;case 19:var f=(e.flags&128)!==0;if(o=(l&n.childLanes)!==0,o||(Pr(e,n,l,!1),o=(l&n.childLanes)!==0),f){if(o)return lm(e,n,l);n.flags|=128}if(f=n.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),E(Vt,Vt.current),o)break;return null;case 22:return n.lanes=0,Zp(e,n,l,n.pendingProps);case 24:Di(n,Ft,e.memoizedState.cache)}return gi(e,n,l)}function am(e,n,l){if(e!==null)if(e.memoizedProps!==n.pendingProps)Xt=!0;else{if(!Wu(e,l)&&(n.flags&128)===0)return Xt=!1,C0(e,n,l);Xt=(e.flags&131072)!==0}else Xt=!1,ut&&(n.flags&1048576)!==0&&Uh(n,Ll,n.index);switch(n.lanes=0,n.tag){case 16:e:{var o=n.pendingProps;if(e=fr(n.elementType),n.type=e,typeof e=="function")ru(e)?(o=gr(e,o),n.tag=1,n=tm(null,n,e,o,l)):(n.tag=0,n=Yu(null,n,e,o,l));else{if(e!=null){var f=e.$$typeof;if(f===q){n.tag=11,n=Qp(null,n,e,o,l);break e}else if(f===U){n.tag=14,n=Xp(null,n,e,o,l);break e}}throw n=W(e)||e,Error(a(306,n,""))}}return n;case 0:return Yu(e,n,n.type,n.pendingProps,l);case 1:return o=n.type,f=gr(o,n.pendingProps),tm(e,n,o,f,l);case 3:e:{if(ge(n,n.stateNode.containerInfo),e===null)throw Error(a(387));o=n.pendingProps;var g=n.memoizedState;f=g.element,vu(e,n),$l(n,o,null,l);var w=n.memoizedState;if(o=w.cache,Di(n,Ft,o),o!==g.cache&&hu(n,[Ft],l,!0),Vl(),o=w.element,g.isDehydrated)if(g={element:o,isDehydrated:!1,cache:w.cache},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){n=nm(e,n,o,l);break e}else if(o!==f){f=Mn(Error(a(424)),n),Bl(f),n=nm(e,n,o,l);break e}else for(e=n.stateNode.containerInfo,e.nodeType===9?e=e.body:e=e.nodeName==="HTML"?e.ownerDocument.body:e,Mt=In(e.firstChild),rn=n,ut=!0,zi=null,Bn=!0,l=Zh(n,null,o,l),n.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(or(),o===f){n=gi(e,n,l);break e}an(e,n,o,l)}n=n.child}return n;case 26:return vs(e,n),e===null?(l=yg(n.type,null,n.pendingProps,null))?n.memoizedState=l:ut||(l=n.type,e=n.pendingProps,o=Ls(Z.current).createElement(l),o[Dt]=n,o[nn]=e,sn(o,l,e),Wt(o),n.stateNode=o):n.memoizedState=yg(n.type,e.memoizedProps,n.pendingProps,e.memoizedState),null;case 27:return ve(n),e===null&&ut&&(o=n.stateNode=pg(n.type,n.pendingProps,Z.current),rn=n,Bn=!0,f=Mt,Yi(n.type)?(_c=f,Mt=In(o.firstChild)):Mt=f),an(e,n,n.pendingProps.children,l),vs(e,n),e===null&&(n.flags|=4194304),n.child;case 5:return e===null&&ut&&((f=o=Mt)&&(o=t1(o,n.type,n.pendingProps,Bn),o!==null?(n.stateNode=o,rn=n,Mt=In(o.firstChild),Bn=!1,f=!0):f=!1),f||_i(n)),ve(n),f=n.type,g=n.pendingProps,w=e!==null?e.memoizedProps:null,o=g.children,Nc(f,g)?o=null:w!==null&&Nc(f,w)&&(n.flags|=32),n.memoizedState!==null&&(f=Eu(e,n,g0,null,null,l),ca._currentValue=f),vs(e,n),an(e,n,o,l),n.child;case 6:return e===null&&ut&&((e=l=Mt)&&(l=n1(l,n.pendingProps,Bn),l!==null?(n.stateNode=l,rn=n,Mt=null,e=!0):e=!1),e||_i(n)),null;case 13:return im(e,n,l);case 4:return ge(n,n.stateNode.containerInfo),o=n.pendingProps,e===null?n.child=pr(n,null,o,l):an(e,n,o,l),n.child;case 11:return Qp(e,n,n.type,n.pendingProps,l);case 7:return an(e,n,n.pendingProps,l),n.child;case 8:return an(e,n,n.pendingProps.children,l),n.child;case 12:return an(e,n,n.pendingProps.children,l),n.child;case 10:return o=n.pendingProps,Di(n,n.type,o.value),an(e,n,o.children,l),n.child;case 9:return f=n.type._context,o=n.pendingProps.children,cr(n),f=ln(f),o=o(f),n.flags|=1,an(e,n,o,l),n.child;case 14:return Xp(e,n,n.type,n.pendingProps,l);case 15:return Kp(e,n,n.type,n.pendingProps,l);case 19:return lm(e,n,l);case 31:return k0(e,n,l);case 22:return Zp(e,n,l,n.pendingProps);case 24:return cr(n),o=ln(Ft),e===null?(f=gu(),f===null&&(f=Rt,g=pu(),f.pooledCache=g,g.refCount++,g!==null&&(f.pooledCacheLanes|=l),f=g),n.memoizedState={parent:o,cache:f},bu(n),Di(n,Ft,f)):((e.lanes&l)!==0&&(vu(e,n),$l(n,null,null,l),Vl()),f=e.memoizedState,g=n.memoizedState,f.parent!==o?(f={parent:o,cache:o},n.memoizedState=f,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=f),Di(n,Ft,o)):(o=g.cache,Di(n,Ft,o),o!==f.cache&&hu(n,[Ft],l,!0))),an(e,n,n.pendingProps.children,l),n.child;case 29:throw n.pendingProps}throw Error(a(156,n.tag))}function yi(e){e.flags|=4}function ec(e,n,l,o,f){if((n=(e.mode&32)!==0)&&(n=!1),n){if(e.flags|=16777216,(f&335544128)===f)if(e.stateNode.complete)e.flags|=8192;else if(Dm())e.flags|=8192;else throw hr=rs,yu}else e.flags&=-16777217}function sm(e,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!Sg(n))if(Dm())e.flags|=8192;else throw hr=rs,yu}function ws(e,n){n!==null&&(e.flags|=4),e.flags&16384&&(n=e.tag!==22?ce():536870912,e.lanes|=n,il|=n)}function Kl(e,n){if(!ut)switch(e.tailMode){case"hidden":n=e.tail;for(var l=null;n!==null;)n.alternate!==null&&(l=n),n=n.sibling;l===null?e.tail=null:l.sibling=null;break;case"collapsed":l=e.tail;for(var o=null;l!==null;)l.alternate!==null&&(o=l),l=l.sibling;o===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:o.sibling=null}}function Ot(e){var n=e.alternate!==null&&e.alternate.child===e.child,l=0,o=0;if(n)for(var f=e.child;f!==null;)l|=f.lanes|f.childLanes,o|=f.subtreeFlags&65011712,o|=f.flags&65011712,f.return=e,f=f.sibling;else for(f=e.child;f!==null;)l|=f.lanes|f.childLanes,o|=f.subtreeFlags,o|=f.flags,f.return=e,f=f.sibling;return e.subtreeFlags|=o,e.childLanes=l,n}function E0(e,n,l){var o=n.pendingProps;switch(ou(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ot(n),null;case 1:return Ot(n),null;case 3:return l=n.stateNode,o=null,e!==null&&(o=e.memoizedState.cache),n.memoizedState.cache!==o&&(n.flags|=2048),hi(Ft),P(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&($r(n)?yi(n):e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,cu())),Ot(n),null;case 26:var f=n.type,g=n.memoizedState;return e===null?(yi(n),g!==null?(Ot(n),sm(n,g)):(Ot(n),ec(n,f,null,o,l))):g?g!==e.memoizedState?(yi(n),Ot(n),sm(n,g)):(Ot(n),n.flags&=-16777217):(e=e.memoizedProps,e!==o&&yi(n),Ot(n),ec(n,f,e,o,l)),null;case 27:if(De(n),l=Z.current,f=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==o&&yi(n);else{if(!o){if(n.stateNode===null)throw Error(a(166));return Ot(n),null}e=J.current,$r(n)?qh(n):(e=pg(f,o,l),n.stateNode=e,yi(n))}return Ot(n),null;case 5:if(De(n),f=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==o&&yi(n);else{if(!o){if(n.stateNode===null)throw Error(a(166));return Ot(n),null}if(g=J.current,$r(n))qh(n);else{var w=Ls(Z.current);switch(g){case 1:g=w.createElementNS("http://www.w3.org/2000/svg",f);break;case 2:g=w.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;default:switch(f){case"svg":g=w.createElementNS("http://www.w3.org/2000/svg",f);break;case"math":g=w.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;case"script":g=w.createElement("div"),g.innerHTML="<script><\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof o.is=="string"?w.createElement("select",{is:o.is}):w.createElement("select"),o.multiple?g.multiple=!0:o.size&&(g.size=o.size);break;default:g=typeof o.is=="string"?w.createElement(f,{is:o.is}):w.createElement(f)}}g[Dt]=n,g[nn]=o;e:for(w=n.child;w!==null;){if(w.tag===5||w.tag===6)g.appendChild(w.stateNode);else if(w.tag!==4&&w.tag!==27&&w.child!==null){w.child.return=w,w=w.child;continue}if(w===n)break e;for(;w.sibling===null;){if(w.return===null||w.return===n)break e;w=w.return}w.sibling.return=w.return,w=w.sibling}n.stateNode=g;e:switch(sn(g,f,o),f){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}o&&yi(n)}}return Ot(n),ec(n,n.type,e===null?null:e.memoizedProps,n.pendingProps,l),null;case 6:if(e&&n.stateNode!=null)e.memoizedProps!==o&&yi(n);else{if(typeof o!="string"&&n.stateNode===null)throw Error(a(166));if(e=Z.current,$r(n)){if(e=n.stateNode,l=n.memoizedProps,o=null,f=rn,f!==null)switch(f.tag){case 27:case 5:o=f.memoizedProps}e[Dt]=n,e=!!(e.nodeValue===l||o!==null&&o.suppressHydrationWarning===!0||ig(e.nodeValue,l)),e||_i(n,!0)}else e=Ls(e).createTextNode(o),e[Dt]=n,n.stateNode=e}return Ot(n),null;case 31:if(l=n.memoizedState,e===null||e.memoizedState!==null){if(o=$r(n),l!==null){if(e===null){if(!o)throw Error(a(318));if(e=n.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(557));e[Dt]=n}else or(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;Ot(n),e=!1}else l=cu(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return n.flags&256?(Cn(n),n):(Cn(n),null);if((n.flags&128)!==0)throw Error(a(558))}return Ot(n),null;case 13:if(o=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(f=$r(n),o!==null&&o.dehydrated!==null){if(e===null){if(!f)throw Error(a(318));if(f=n.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(a(317));f[Dt]=n}else or(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;Ot(n),f=!1}else f=cu(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=f),f=!0;if(!f)return n.flags&256?(Cn(n),n):(Cn(n),null)}return Cn(n),(n.flags&128)!==0?(n.lanes=l,n):(l=o!==null,e=e!==null&&e.memoizedState!==null,l&&(o=n.child,f=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(f=o.alternate.memoizedState.cachePool.pool),g=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(g=o.memoizedState.cachePool.pool),g!==f&&(o.flags|=2048)),l!==e&&l&&(n.child.flags|=8192),ws(n,n.updateQueue),Ot(n),null);case 4:return P(),e===null&&Sc(n.stateNode.containerInfo),Ot(n),null;case 10:return hi(n.type),Ot(n),null;case 19:if(re(Vt),o=n.memoizedState,o===null)return Ot(n),null;if(f=(n.flags&128)!==0,g=o.rendering,g===null)if(f)Kl(o,!1);else{if(Ht!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(g=os(e),g!==null){for(n.flags|=128,Kl(o,!1),e=g.updateQueue,n.updateQueue=e,ws(n,e),n.subtreeFlags=0,e=l,l=n.child;l!==null;)Oh(l,e),l=l.sibling;return E(Vt,Vt.current&1|2),ut&&di(n,o.treeForkCount),n.child}e=e.sibling}o.tail!==null&&Ie()>Es&&(n.flags|=128,f=!0,Kl(o,!1),n.lanes=4194304)}else{if(!f)if(e=os(g),e!==null){if(n.flags|=128,f=!0,e=e.updateQueue,n.updateQueue=e,ws(n,e),Kl(o,!0),o.tail===null&&o.tailMode==="hidden"&&!g.alternate&&!ut)return Ot(n),null}else 2*Ie()-o.renderingStartTime>Es&&l!==536870912&&(n.flags|=128,f=!0,Kl(o,!1),n.lanes=4194304);o.isBackwards?(g.sibling=n.child,n.child=g):(e=o.last,e!==null?e.sibling=g:n.child=g,o.last=g)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=Ie(),e.sibling=null,l=Vt.current,E(Vt,f?l&1|2:l&1),ut&&di(n,o.treeForkCount),e):(Ot(n),null);case 22:case 23:return Cn(n),ju(),o=n.memoizedState!==null,e!==null?e.memoizedState!==null!==o&&(n.flags|=8192):o&&(n.flags|=8192),o?(l&536870912)!==0&&(n.flags&128)===0&&(Ot(n),n.subtreeFlags&6&&(n.flags|=8192)):Ot(n),l=n.updateQueue,l!==null&&ws(n,l.retryQueue),l=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),o=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(o=n.memoizedState.cachePool.pool),o!==l&&(n.flags|=2048),e!==null&&re(dr),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),n.memoizedState.cache!==l&&(n.flags|=2048),hi(Ft),Ot(n),null;case 25:return null;case 30:return null}throw Error(a(156,n.tag))}function N0(e,n){switch(ou(n),n.tag){case 1:return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return hi(Ft),P(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 26:case 27:case 5:return De(n),null;case 31:if(n.memoizedState!==null){if(Cn(n),n.alternate===null)throw Error(a(340));or()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 13:if(Cn(n),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(a(340));or()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return re(Vt),null;case 4:return P(),null;case 10:return hi(n.type),null;case 22:case 23:return Cn(n),ju(),e!==null&&re(dr),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 24:return hi(Ft),null;case 25:return null;default:return null}}function om(e,n){switch(ou(n),n.tag){case 3:hi(Ft),P();break;case 26:case 27:case 5:De(n);break;case 4:P();break;case 31:n.memoizedState!==null&&Cn(n);break;case 13:Cn(n);break;case 19:re(Vt);break;case 10:hi(n.type);break;case 22:case 23:Cn(n),ju(),e!==null&&re(dr);break;case 24:hi(Ft)}}function Zl(e,n){try{var l=n.updateQueue,o=l!==null?l.lastEffect:null;if(o!==null){var f=o.next;l=f;do{if((l.tag&e)===e){o=void 0;var g=l.create,w=l.inst;o=g(),w.destroy=o}l=l.next}while(l!==f)}}catch(z){jt(n,n.return,z)}}function Ii(e,n,l){try{var o=n.updateQueue,f=o!==null?o.lastEffect:null;if(f!==null){var g=f.next;o=g;do{if((o.tag&e)===e){var w=o.inst,z=w.destroy;if(z!==void 0){w.destroy=void 0,f=n;var $=l,se=z;try{se()}catch(he){jt(f,$,he)}}}o=o.next}while(o!==g)}}catch(he){jt(n,n.return,he)}}function um(e){var n=e.updateQueue;if(n!==null){var l=e.stateNode;try{Wh(n,l)}catch(o){jt(e,e.return,o)}}}function cm(e,n,l){l.props=gr(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(o){jt(e,n,o)}}function Jl(e,n){try{var l=e.ref;if(l!==null){switch(e.tag){case 26:case 27:case 5:var o=e.stateNode;break;case 30:o=e.stateNode;break;default:o=e.stateNode}typeof l=="function"?e.refCleanup=l(o):l.current=o}}catch(f){jt(e,n,f)}}function Jn(e,n){var l=e.ref,o=e.refCleanup;if(l!==null)if(typeof o=="function")try{o()}catch(f){jt(e,n,f)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(f){jt(e,n,f)}else l.current=null}function dm(e){var n=e.type,l=e.memoizedProps,o=e.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":l.autoFocus&&o.focus();break e;case"img":l.src?o.src=l.src:l.srcSet&&(o.srcset=l.srcSet)}}catch(f){jt(e,e.return,f)}}function tc(e,n,l){try{var o=e.stateNode;X0(o,e.type,l,n),o[nn]=n}catch(f){jt(e,e.return,f)}}function fm(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Yi(e.type)||e.tag===4}function nc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||fm(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Yi(e.type)||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 ic(e,n,l){var o=e.tag;if(o===5||o===6)e=e.stateNode,n?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(e,n):(n=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,n.appendChild(e),l=l._reactRootContainer,l!=null||n.onclick!==null||(n.onclick=oi));else if(o!==4&&(o===27&&Yi(e.type)&&(l=e.stateNode,n=null),e=e.child,e!==null))for(ic(e,n,l),e=e.sibling;e!==null;)ic(e,n,l),e=e.sibling}function Ss(e,n,l){var o=e.tag;if(o===5||o===6)e=e.stateNode,n?l.insertBefore(e,n):l.appendChild(e);else if(o!==4&&(o===27&&Yi(e.type)&&(l=e.stateNode),e=e.child,e!==null))for(Ss(e,n,l),e=e.sibling;e!==null;)Ss(e,n,l),e=e.sibling}function hm(e){var n=e.stateNode,l=e.memoizedProps;try{for(var o=e.type,f=n.attributes;f.length;)n.removeAttributeNode(f[0]);sn(n,o,l),n[Dt]=e,n[nn]=l}catch(g){jt(e,e.return,g)}}var bi=!1,Kt=!1,rc=!1,pm=typeof WeakSet=="function"?WeakSet:Set,en=null;function T0(e,n){if(e=e.containerInfo,Cc=Vs,e=Eh(e),Zo(e)){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{l=(l=e.ownerDocument)&&l.defaultView||window;var o=l.getSelection&&l.getSelection();if(o&&o.rangeCount!==0){l=o.anchorNode;var f=o.anchorOffset,g=o.focusNode;o=o.focusOffset;try{l.nodeType,g.nodeType}catch{l=null;break e}var w=0,z=-1,$=-1,se=0,he=0,me=e,oe=null;t:for(;;){for(var de;me!==l||f!==0&&me.nodeType!==3||(z=w+f),me!==g||o!==0&&me.nodeType!==3||($=w+o),me.nodeType===3&&(w+=me.nodeValue.length),(de=me.firstChild)!==null;)oe=me,me=de;for(;;){if(me===e)break t;if(oe===l&&++se===f&&(z=w),oe===g&&++he===o&&($=w),(de=me.nextSibling)!==null)break;me=oe,oe=me.parentNode}me=de}l=z===-1||$===-1?null:{start:z,end:$}}else l=null}l=l||{start:0,end:0}}else l=null;for(Ec={focusedElem:e,selectionRange:l},Vs=!1,en=n;en!==null;)if(n=en,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,en=e;else for(;en!==null;){switch(n=en,g=n.alternate,e=n.flags,n.tag){case 0:if((e&4)!==0&&(e=n.updateQueue,e=e!==null?e.events:null,e!==null))for(l=0;l<e.length;l++)f=e[l],f.ref.impl=f.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&g!==null){e=void 0,l=n,f=g.memoizedProps,g=g.memoizedState,o=l.stateNode;try{var Ee=gr(l.type,f);e=o.getSnapshotBeforeUpdate(Ee,g),o.__reactInternalSnapshotBeforeUpdate=e}catch(Le){jt(l,l.return,Le)}}break;case 3:if((e&1024)!==0){if(e=n.stateNode.containerInfo,l=e.nodeType,l===9)Ac(e);else if(l===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Ac(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(a(163))}if(e=n.sibling,e!==null){e.return=n.return,en=e;break}en=n.return}}function mm(e,n,l){var o=l.flags;switch(l.tag){case 0:case 11:case 15:xi(e,l),o&4&&Zl(5,l);break;case 1:if(xi(e,l),o&4)if(e=l.stateNode,n===null)try{e.componentDidMount()}catch(w){jt(l,l.return,w)}else{var f=gr(l.type,n.memoizedProps);n=n.memoizedState;try{e.componentDidUpdate(f,n,e.__reactInternalSnapshotBeforeUpdate)}catch(w){jt(l,l.return,w)}}o&64&&um(l),o&512&&Jl(l,l.return);break;case 3:if(xi(e,l),o&64&&(e=l.updateQueue,e!==null)){if(n=null,l.child!==null)switch(l.child.tag){case 27:case 5:n=l.child.stateNode;break;case 1:n=l.child.stateNode}try{Wh(e,n)}catch(w){jt(l,l.return,w)}}break;case 27:n===null&&o&4&&hm(l);case 26:case 5:xi(e,l),n===null&&o&4&&dm(l),o&512&&Jl(l,l.return);break;case 12:xi(e,l);break;case 31:xi(e,l),o&4&&bm(e,l);break;case 13:xi(e,l),o&4&&vm(e,l),o&64&&(e=l.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(l=B0.bind(null,l),i1(e,l))));break;case 22:if(o=l.memoizedState!==null||bi,!o){n=n!==null&&n.memoizedState!==null||Kt,f=bi;var g=Kt;bi=o,(Kt=n)&&!g?wi(e,l,(l.subtreeFlags&8772)!==0):xi(e,l),bi=f,Kt=g}break;case 30:break;default:xi(e,l)}}function gm(e){var n=e.alternate;n!==null&&(e.alternate=null,gm(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&Mo(n)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Bt=null,mn=!1;function vi(e,n,l){for(l=l.child;l!==null;)ym(e,n,l),l=l.sibling}function ym(e,n,l){if(ct&&typeof ct.onCommitFiberUnmount=="function")try{ct.onCommitFiberUnmount(wt,l)}catch{}switch(l.tag){case 26:Kt||Jn(l,n),vi(e,n,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:Kt||Jn(l,n);var o=Bt,f=mn;Yi(l.type)&&(Bt=l.stateNode,mn=!1),vi(e,n,l),sa(l.stateNode),Bt=o,mn=f;break;case 5:Kt||Jn(l,n);case 6:if(o=Bt,f=mn,Bt=null,vi(e,n,l),Bt=o,mn=f,Bt!==null)if(mn)try{(Bt.nodeType===9?Bt.body:Bt.nodeName==="HTML"?Bt.ownerDocument.body:Bt).removeChild(l.stateNode)}catch(g){jt(l,n,g)}else try{Bt.removeChild(l.stateNode)}catch(g){jt(l,n,g)}break;case 18:Bt!==null&&(mn?(e=Bt,ug(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,l.stateNode),dl(e)):ug(Bt,l.stateNode));break;case 4:o=Bt,f=mn,Bt=l.stateNode.containerInfo,mn=!0,vi(e,n,l),Bt=o,mn=f;break;case 0:case 11:case 14:case 15:Ii(2,l,n),Kt||Ii(4,l,n),vi(e,n,l);break;case 1:Kt||(Jn(l,n),o=l.stateNode,typeof o.componentWillUnmount=="function"&&cm(l,n,o)),vi(e,n,l);break;case 21:vi(e,n,l);break;case 22:Kt=(o=Kt)||l.memoizedState!==null,vi(e,n,l),Kt=o;break;default:vi(e,n,l)}}function bm(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{dl(e)}catch(l){jt(n,n.return,l)}}}function vm(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{dl(e)}catch(l){jt(n,n.return,l)}}function A0(e){switch(e.tag){case 31:case 13:case 19:var n=e.stateNode;return n===null&&(n=e.stateNode=new pm),n;case 22:return e=e.stateNode,n=e._retryCache,n===null&&(n=e._retryCache=new pm),n;default:throw Error(a(435,e.tag))}}function js(e,n){var l=A0(e);n.forEach(function(o){if(!l.has(o)){l.add(o);var f=U0.bind(null,e,o);o.then(f,f)}})}function gn(e,n){var l=n.deletions;if(l!==null)for(var o=0;o<l.length;o++){var f=l[o],g=e,w=n,z=w;e:for(;z!==null;){switch(z.tag){case 27:if(Yi(z.type)){Bt=z.stateNode,mn=!1;break e}break;case 5:Bt=z.stateNode,mn=!1;break e;case 3:case 4:Bt=z.stateNode.containerInfo,mn=!0;break e}z=z.return}if(Bt===null)throw Error(a(160));ym(g,w,f),Bt=null,mn=!1,g=f.alternate,g!==null&&(g.return=null),f.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)xm(n,e),n=n.sibling}var Vn=null;function xm(e,n){var l=e.alternate,o=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:gn(n,e),yn(e),o&4&&(Ii(3,e,e.return),Zl(3,e),Ii(5,e,e.return));break;case 1:gn(n,e),yn(e),o&512&&(Kt||l===null||Jn(l,l.return)),o&64&&bi&&(e=e.updateQueue,e!==null&&(o=e.callbacks,o!==null&&(l=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=l===null?o:l.concat(o))));break;case 26:var f=Vn;if(gn(n,e),yn(e),o&512&&(Kt||l===null||Jn(l,l.return)),o&4){var g=l!==null?l.memoizedState:null;if(o=e.memoizedState,l===null)if(o===null)if(e.stateNode===null){e:{o=e.type,l=e.memoizedProps,f=f.ownerDocument||f;t:switch(o){case"title":g=f.getElementsByTagName("title")[0],(!g||g[Cl]||g[Dt]||g.namespaceURI==="http://www.w3.org/2000/svg"||g.hasAttribute("itemprop"))&&(g=f.createElement(o),f.head.insertBefore(g,f.querySelector("head > title"))),sn(g,o,l),g[Dt]=e,Wt(g),o=g;break e;case"link":var w=xg("link","href",f).get(o+(l.href||""));if(w){for(var z=0;z<w.length;z++)if(g=w[z],g.getAttribute("href")===(l.href==null||l.href===""?null:l.href)&&g.getAttribute("rel")===(l.rel==null?null:l.rel)&&g.getAttribute("title")===(l.title==null?null:l.title)&&g.getAttribute("crossorigin")===(l.crossOrigin==null?null:l.crossOrigin)){w.splice(z,1);break t}}g=f.createElement(o),sn(g,o,l),f.head.appendChild(g);break;case"meta":if(w=xg("meta","content",f).get(o+(l.content||""))){for(z=0;z<w.length;z++)if(g=w[z],g.getAttribute("content")===(l.content==null?null:""+l.content)&&g.getAttribute("name")===(l.name==null?null:l.name)&&g.getAttribute("property")===(l.property==null?null:l.property)&&g.getAttribute("http-equiv")===(l.httpEquiv==null?null:l.httpEquiv)&&g.getAttribute("charset")===(l.charSet==null?null:l.charSet)){w.splice(z,1);break t}}g=f.createElement(o),sn(g,o,l),f.head.appendChild(g);break;default:throw Error(a(468,o))}g[Dt]=e,Wt(g),o=g}e.stateNode=o}else wg(f,e.type,e.stateNode);else e.stateNode=vg(f,o,e.memoizedProps);else g!==o?(g===null?l.stateNode!==null&&(l=l.stateNode,l.parentNode.removeChild(l)):g.count--,o===null?wg(f,e.type,e.stateNode):vg(f,o,e.memoizedProps)):o===null&&e.stateNode!==null&&tc(e,e.memoizedProps,l.memoizedProps)}break;case 27:gn(n,e),yn(e),o&512&&(Kt||l===null||Jn(l,l.return)),l!==null&&o&4&&tc(e,e.memoizedProps,l.memoizedProps);break;case 5:if(gn(n,e),yn(e),o&512&&(Kt||l===null||Jn(l,l.return)),e.flags&32){f=e.stateNode;try{Mr(f,"")}catch(Ee){jt(e,e.return,Ee)}}o&4&&e.stateNode!=null&&(f=e.memoizedProps,tc(e,f,l!==null?l.memoizedProps:f)),o&1024&&(rc=!0);break;case 6:if(gn(n,e),yn(e),o&4){if(e.stateNode===null)throw Error(a(162));o=e.memoizedProps,l=e.stateNode;try{l.nodeValue=o}catch(Ee){jt(e,e.return,Ee)}}break;case 3:if(Is=null,f=Vn,Vn=Bs(n.containerInfo),gn(n,e),Vn=f,yn(e),o&4&&l!==null&&l.memoizedState.isDehydrated)try{dl(n.containerInfo)}catch(Ee){jt(e,e.return,Ee)}rc&&(rc=!1,wm(e));break;case 4:o=Vn,Vn=Bs(e.stateNode.containerInfo),gn(n,e),yn(e),Vn=o;break;case 12:gn(n,e),yn(e);break;case 31:gn(n,e),yn(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,js(e,o)));break;case 13:gn(n,e),yn(e),e.child.flags&8192&&e.memoizedState!==null!=(l!==null&&l.memoizedState!==null)&&(Cs=Ie()),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,js(e,o)));break;case 22:f=e.memoizedState!==null;var $=l!==null&&l.memoizedState!==null,se=bi,he=Kt;if(bi=se||f,Kt=he||$,gn(n,e),Kt=he,bi=se,yn(e),o&8192)e:for(n=e.stateNode,n._visibility=f?n._visibility&-2:n._visibility|1,f&&(l===null||$||bi||Kt||yr(e)),l=null,n=e;;){if(n.tag===5||n.tag===26){if(l===null){$=l=n;try{if(g=$.stateNode,f)w=g.style,typeof w.setProperty=="function"?w.setProperty("display","none","important"):w.display="none";else{z=$.stateNode;var me=$.memoizedProps.style,oe=me!=null&&me.hasOwnProperty("display")?me.display:null;z.style.display=oe==null||typeof oe=="boolean"?"":(""+oe).trim()}}catch(Ee){jt($,$.return,Ee)}}}else if(n.tag===6){if(l===null){$=n;try{$.stateNode.nodeValue=f?"":$.memoizedProps}catch(Ee){jt($,$.return,Ee)}}}else if(n.tag===18){if(l===null){$=n;try{var de=$.stateNode;f?cg(de,!0):cg($.stateNode,!1)}catch(Ee){jt($,$.return,Ee)}}}else if((n.tag!==22&&n.tag!==23||n.memoizedState===null||n===e)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break e;for(;n.sibling===null;){if(n.return===null||n.return===e)break e;l===n&&(l=null),n=n.return}l===n&&(l=null),n.sibling.return=n.return,n=n.sibling}o&4&&(o=e.updateQueue,o!==null&&(l=o.retryQueue,l!==null&&(o.retryQueue=null,js(e,l))));break;case 19:gn(n,e),yn(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,js(e,o)));break;case 30:break;case 21:break;default:gn(n,e),yn(e)}}function yn(e){var n=e.flags;if(n&2){try{for(var l,o=e.return;o!==null;){if(fm(o)){l=o;break}o=o.return}if(l==null)throw Error(a(160));switch(l.tag){case 27:var f=l.stateNode,g=nc(e);Ss(e,g,f);break;case 5:var w=l.stateNode;l.flags&32&&(Mr(w,""),l.flags&=-33);var z=nc(e);Ss(e,z,w);break;case 3:case 4:var $=l.stateNode.containerInfo,se=nc(e);ic(e,se,$);break;default:throw Error(a(161))}}catch(he){jt(e,e.return,he)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function wm(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var n=e;wm(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),e=e.sibling}}function xi(e,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)mm(e,n.alternate,n),n=n.sibling}function yr(e){for(e=e.child;e!==null;){var n=e;switch(n.tag){case 0:case 11:case 14:case 15:Ii(4,n,n.return),yr(n);break;case 1:Jn(n,n.return);var l=n.stateNode;typeof l.componentWillUnmount=="function"&&cm(n,n.return,l),yr(n);break;case 27:sa(n.stateNode);case 26:case 5:Jn(n,n.return),yr(n);break;case 22:n.memoizedState===null&&yr(n);break;case 30:yr(n);break;default:yr(n)}e=e.sibling}}function wi(e,n,l){for(l=l&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var o=n.alternate,f=e,g=n,w=g.flags;switch(g.tag){case 0:case 11:case 15:wi(f,g,l),Zl(4,g);break;case 1:if(wi(f,g,l),o=g,f=o.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(se){jt(o,o.return,se)}if(o=g,f=o.updateQueue,f!==null){var z=o.stateNode;try{var $=f.shared.hiddenCallbacks;if($!==null)for(f.shared.hiddenCallbacks=null,f=0;f<$.length;f++)Jh($[f],z)}catch(se){jt(o,o.return,se)}}l&&w&64&&um(g),Jl(g,g.return);break;case 27:hm(g);case 26:case 5:wi(f,g,l),l&&o===null&&w&4&&dm(g),Jl(g,g.return);break;case 12:wi(f,g,l);break;case 31:wi(f,g,l),l&&w&4&&bm(f,g);break;case 13:wi(f,g,l),l&&w&4&&vm(f,g);break;case 22:g.memoizedState===null&&wi(f,g,l),Jl(g,g.return);break;case 30:break;default:wi(f,g,l)}n=n.sibling}}function lc(e,n){var l=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),e=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(e=n.memoizedState.cachePool.pool),e!==l&&(e!=null&&e.refCount++,l!=null&&Ul(l))}function ac(e,n){e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&Ul(e))}function $n(e,n,l,o){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)Sm(e,n,l,o),n=n.sibling}function Sm(e,n,l,o){var f=n.flags;switch(n.tag){case 0:case 11:case 15:$n(e,n,l,o),f&2048&&Zl(9,n);break;case 1:$n(e,n,l,o);break;case 3:$n(e,n,l,o),f&2048&&(e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&Ul(e)));break;case 12:if(f&2048){$n(e,n,l,o),e=n.stateNode;try{var g=n.memoizedProps,w=g.id,z=g.onPostCommit;typeof z=="function"&&z(w,n.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch($){jt(n,n.return,$)}}else $n(e,n,l,o);break;case 31:$n(e,n,l,o);break;case 13:$n(e,n,l,o);break;case 23:break;case 22:g=n.stateNode,w=n.alternate,n.memoizedState!==null?g._visibility&2?$n(e,n,l,o):Wl(e,n):g._visibility&2?$n(e,n,l,o):(g._visibility|=2,el(e,n,l,o,(n.subtreeFlags&10256)!==0||!1)),f&2048&&lc(w,n);break;case 24:$n(e,n,l,o),f&2048&&ac(n.alternate,n);break;default:$n(e,n,l,o)}}function el(e,n,l,o,f){for(f=f&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var g=e,w=n,z=l,$=o,se=w.flags;switch(w.tag){case 0:case 11:case 15:el(g,w,z,$,f),Zl(8,w);break;case 23:break;case 22:var he=w.stateNode;w.memoizedState!==null?he._visibility&2?el(g,w,z,$,f):Wl(g,w):(he._visibility|=2,el(g,w,z,$,f)),f&&se&2048&&lc(w.alternate,w);break;case 24:el(g,w,z,$,f),f&&se&2048&&ac(w.alternate,w);break;default:el(g,w,z,$,f)}n=n.sibling}}function Wl(e,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var l=e,o=n,f=o.flags;switch(o.tag){case 22:Wl(l,o),f&2048&&lc(o.alternate,o);break;case 24:Wl(l,o),f&2048&&ac(o.alternate,o);break;default:Wl(l,o)}n=n.sibling}}var ea=8192;function tl(e,n,l){if(e.subtreeFlags&ea)for(e=e.child;e!==null;)jm(e,n,l),e=e.sibling}function jm(e,n,l){switch(e.tag){case 26:tl(e,n,l),e.flags&ea&&e.memoizedState!==null&&m1(l,Vn,e.memoizedState,e.memoizedProps);break;case 5:tl(e,n,l);break;case 3:case 4:var o=Vn;Vn=Bs(e.stateNode.containerInfo),tl(e,n,l),Vn=o;break;case 22:e.memoizedState===null&&(o=e.alternate,o!==null&&o.memoizedState!==null?(o=ea,ea=16777216,tl(e,n,l),ea=o):tl(e,n,l));break;default:tl(e,n,l)}}function km(e){var n=e.alternate;if(n!==null&&(e=n.child,e!==null)){n.child=null;do n=e.sibling,e.sibling=null,e=n;while(e!==null)}}function ta(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var l=0;l<n.length;l++){var o=n[l];en=o,Em(o,e)}km(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Cm(e),e=e.sibling}function Cm(e){switch(e.tag){case 0:case 11:case 15:ta(e),e.flags&2048&&Ii(9,e,e.return);break;case 3:ta(e);break;case 12:ta(e);break;case 22:var n=e.stateNode;e.memoizedState!==null&&n._visibility&2&&(e.return===null||e.return.tag!==13)?(n._visibility&=-3,ks(e)):ta(e);break;default:ta(e)}}function ks(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var l=0;l<n.length;l++){var o=n[l];en=o,Em(o,e)}km(e)}for(e=e.child;e!==null;){switch(n=e,n.tag){case 0:case 11:case 15:Ii(8,n,n.return),ks(n);break;case 22:l=n.stateNode,l._visibility&2&&(l._visibility&=-3,ks(n));break;default:ks(n)}e=e.sibling}}function Em(e,n){for(;en!==null;){var l=en;switch(l.tag){case 0:case 11:case 15:Ii(8,l,n);break;case 23:case 22:if(l.memoizedState!==null&&l.memoizedState.cachePool!==null){var o=l.memoizedState.cachePool.pool;o!=null&&o.refCount++}break;case 24:Ul(l.memoizedState.cache)}if(o=l.child,o!==null)o.return=l,en=o;else e:for(l=e;en!==null;){o=en;var f=o.sibling,g=o.return;if(gm(o),o===l){en=null;break e}if(f!==null){f.return=g,en=f;break e}en=g}}}var R0={getCacheForType:function(e){var n=ln(Ft),l=n.data.get(e);return l===void 0&&(l=e(),n.data.set(e,l)),l},cacheSignal:function(){return ln(Ft).controller.signal}},z0=typeof WeakMap=="function"?WeakMap:Map,vt=0,Rt=null,nt=null,at=0,St=0,En=null,qi=!1,nl=!1,sc=!1,Si=0,Ht=0,Hi=0,br=0,oc=0,Nn=0,il=0,na=null,bn=null,uc=!1,Cs=0,Nm=0,Es=1/0,Ns=null,Gi=null,Jt=0,Vi=null,rl=null,ji=0,cc=0,dc=null,Tm=null,ia=0,fc=null;function Tn(){return(vt&2)!==0&&at!==0?at&-at:V.T!==null?bc():ai()}function Am(){if(Nn===0)if((at&536870912)===0||ut){var e=je;je<<=1,(je&3932160)===0&&(je=262144),Nn=e}else Nn=536870912;return e=kn.current,e!==null&&(e.flags|=32),Nn}function vn(e,n,l){(e===Rt&&(St===2||St===9)||e.cancelPendingCommit!==null)&&(ll(e,0),$i(e,at,Nn,!1)),He(e,l),((vt&2)===0||e!==Rt)&&(e===Rt&&((vt&2)===0&&(br|=l),Ht===4&&$i(e,at,Nn,!1)),Wn(e))}function Rm(e,n,l){if((vt&6)!==0)throw Error(a(327));var o=!l&&(n&127)===0&&(n&e.expiredLanes)===0||Te(e,n),f=o?M0(e,n):pc(e,n,!0),g=o;do{if(f===0){nl&&!o&&$i(e,n,0,!1);break}else{if(l=e.current.alternate,g&&!_0(l)){f=pc(e,n,!1),g=!1;continue}if(f===2){if(g=n,e.errorRecoveryDisabledLanes&g)var w=0;else w=e.pendingLanes&-536870913,w=w!==0?w:w&536870912?536870912:0;if(w!==0){n=w;e:{var z=e;f=na;var $=z.current.memoizedState.isDehydrated;if($&&(ll(z,w).flags|=256),w=pc(z,w,!1),w!==2){if(sc&&!$){z.errorRecoveryDisabledLanes|=g,br|=g,f=4;break e}g=bn,bn=f,g!==null&&(bn===null?bn=g:bn.push.apply(bn,g))}f=w}if(g=!1,f!==2)continue}}if(f===1){ll(e,0),$i(e,n,0,!0);break}e:{switch(o=e,g=f,g){case 0:case 1:throw Error(a(345));case 4:if((n&4194048)!==n)break;case 6:$i(o,n,Nn,!qi);break e;case 2:bn=null;break;case 3:case 5:break;default:throw Error(a(329))}if((n&62914560)===n&&(f=Cs+300-Ie(),10<f)){if($i(o,n,Nn,!qi),ke(o,0,!0)!==0)break e;ji=n,o.timeoutHandle=sg(zm.bind(null,o,l,bn,Ns,uc,n,Nn,br,il,qi,g,"Throttled",-0,0),f);break e}zm(o,l,bn,Ns,uc,n,Nn,br,il,qi,g,null,-0,0)}}break}while(!0);Wn(e)}function zm(e,n,l,o,f,g,w,z,$,se,he,me,oe,de){if(e.timeoutHandle=-1,me=n.subtreeFlags,me&8192||(me&16785408)===16785408){me={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:oi},jm(n,g,me);var Ee=(g&62914560)===g?Cs-Ie():(g&4194048)===g?Nm-Ie():0;if(Ee=g1(me,Ee),Ee!==null){ji=g,e.cancelPendingCommit=Ee(Im.bind(null,e,n,g,l,o,f,w,z,$,he,me,null,oe,de)),$i(e,g,w,!se);return}}Im(e,n,g,l,o,f,w,z,$)}function _0(e){for(var n=e;;){var l=n.tag;if((l===0||l===11||l===15)&&n.flags&16384&&(l=n.updateQueue,l!==null&&(l=l.stores,l!==null)))for(var o=0;o<l.length;o++){var f=l[o],g=f.getSnapshot;f=f.value;try{if(!Sn(g(),f))return!1}catch{return!1}}if(l=n.child,n.subtreeFlags&16384&&l!==null)l.return=n,n=l;else{if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function $i(e,n,l,o){n&=~oc,n&=~br,e.suspendedLanes|=n,e.pingedLanes&=~n,o&&(e.warmLanes|=n),o=e.expirationTimes;for(var f=n;0<f;){var g=31-lt(f),w=1<<g;o[g]=-1,f&=~w}l!==0&&Qe(e,l,n)}function Ts(){return(vt&6)===0?(ra(0),!1):!0}function hc(){if(nt!==null){if(St===0)var e=nt.return;else e=nt,fi=ur=null,Au(e),Xr=null,ql=0,e=nt;for(;e!==null;)om(e.alternate,e),e=e.return;nt=null}}function ll(e,n){var l=e.timeoutHandle;l!==-1&&(e.timeoutHandle=-1,J0(l)),l=e.cancelPendingCommit,l!==null&&(e.cancelPendingCommit=null,l()),ji=0,hc(),Rt=e,nt=l=ci(e.current,null),at=n,St=0,En=null,qi=!1,nl=Te(e,n),sc=!1,il=Nn=oc=br=Hi=Ht=0,bn=na=null,uc=!1,(n&8)!==0&&(n|=n&32);var o=e.entangledLanes;if(o!==0)for(e=e.entanglements,o&=n;0<o;){var f=31-lt(o),g=1<<f;n|=e[f],o&=~g}return Si=n,Xa(),l}function _m(e,n){Ye=null,V.H=Ql,n===Qr||n===is?(n=Qh(),St=3):n===yu?(n=Qh(),St=4):St=n===Pu?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,En=n,nt===null&&(Ht=1,ys(e,Mn(n,e.current)))}function Dm(){var e=kn.current;return e===null?!0:(at&4194048)===at?Un===null:(at&62914560)===at||(at&536870912)!==0?e===Un:!1}function Mm(){var e=V.H;return V.H=Ql,e===null?Ql:e}function Om(){var e=V.A;return V.A=R0,e}function As(){Ht=4,qi||(at&4194048)!==at&&kn.current!==null||(nl=!0),(Hi&134217727)===0&&(br&134217727)===0||Rt===null||$i(Rt,at,Nn,!1)}function pc(e,n,l){var o=vt;vt|=2;var f=Mm(),g=Om();(Rt!==e||at!==n)&&(Ns=null,ll(e,n)),n=!1;var w=Ht;e:do try{if(St!==0&&nt!==null){var z=nt,$=En;switch(St){case 8:hc(),w=6;break e;case 3:case 2:case 9:case 6:kn.current===null&&(n=!0);var se=St;if(St=0,En=null,al(e,z,$,se),l&&nl){w=0;break e}break;default:se=St,St=0,En=null,al(e,z,$,se)}}D0(),w=Ht;break}catch(he){_m(e,he)}while(!0);return n&&e.shellSuspendCounter++,fi=ur=null,vt=o,V.H=f,V.A=g,nt===null&&(Rt=null,at=0,Xa()),w}function D0(){for(;nt!==null;)Lm(nt)}function M0(e,n){var l=vt;vt|=2;var o=Mm(),f=Om();Rt!==e||at!==n?(Ns=null,Es=Ie()+500,ll(e,n)):nl=Te(e,n);e:do try{if(St!==0&&nt!==null){n=nt;var g=En;t:switch(St){case 1:St=0,En=null,al(e,n,g,1);break;case 2:case 9:if(Yh(g)){St=0,En=null,Bm(n);break}n=function(){St!==2&&St!==9||Rt!==e||(St=7),Wn(e)},g.then(n,n);break e;case 3:St=7;break e;case 4:St=5;break e;case 7:Yh(g)?(St=0,En=null,Bm(n)):(St=0,En=null,al(e,n,g,7));break;case 5:var w=null;switch(nt.tag){case 26:w=nt.memoizedState;case 5:case 27:var z=nt;if(w?Sg(w):z.stateNode.complete){St=0,En=null;var $=z.sibling;if($!==null)nt=$;else{var se=z.return;se!==null?(nt=se,Rs(se)):nt=null}break t}}St=0,En=null,al(e,n,g,5);break;case 6:St=0,En=null,al(e,n,g,6);break;case 8:hc(),Ht=6;break e;default:throw Error(a(462))}}O0();break}catch(he){_m(e,he)}while(!0);return fi=ur=null,V.H=o,V.A=f,vt=l,nt!==null?0:(Rt=null,at=0,Xa(),Ht)}function O0(){for(;nt!==null&&!Fe();)Lm(nt)}function Lm(e){var n=am(e.alternate,e,Si);e.memoizedProps=e.pendingProps,n===null?Rs(e):nt=n}function Bm(e){var n=e,l=n.alternate;switch(n.tag){case 15:case 0:n=em(l,n,n.pendingProps,n.type,void 0,at);break;case 11:n=em(l,n,n.pendingProps,n.type.render,n.ref,at);break;case 5:Au(n);default:om(l,n),n=nt=Oh(n,Si),n=am(l,n,Si)}e.memoizedProps=e.pendingProps,n===null?Rs(e):nt=n}function al(e,n,l,o){fi=ur=null,Au(n),Xr=null,ql=0;var f=n.return;try{if(j0(e,f,n,l,at)){Ht=1,ys(e,Mn(l,e.current)),nt=null;return}}catch(g){if(f!==null)throw nt=f,g;Ht=1,ys(e,Mn(l,e.current)),nt=null;return}n.flags&32768?(ut||o===1?e=!0:nl||(at&536870912)!==0?e=!1:(qi=e=!0,(o===2||o===9||o===3||o===6)&&(o=kn.current,o!==null&&o.tag===13&&(o.flags|=16384))),Um(n,e)):Rs(n)}function Rs(e){var n=e;do{if((n.flags&32768)!==0){Um(n,qi);return}e=n.return;var l=E0(n.alternate,n,Si);if(l!==null){nt=l;return}if(n=n.sibling,n!==null){nt=n;return}nt=n=e}while(n!==null);Ht===0&&(Ht=5)}function Um(e,n){do{var l=N0(e.alternate,e);if(l!==null){l.flags&=32767,nt=l;return}if(l=e.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!n&&(e=e.sibling,e!==null)){nt=e;return}nt=e=l}while(e!==null);Ht=6,nt=null}function Im(e,n,l,o,f,g,w,z,$){e.cancelPendingCommit=null;do zs();while(Jt!==0);if((vt&6)!==0)throw Error(a(327));if(n!==null){if(n===e.current)throw Error(a(177));if(g=n.lanes|n.childLanes,g|=nu,Yt(e,l,g,w,z,$),e===Rt&&(nt=Rt=null,at=0),rl=n,Vi=e,ji=l,cc=g,dc=f,Tm=o,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,I0(ye,function(){return $m(),null})):(e.callbackNode=null,e.callbackPriority=0),o=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||o){o=V.T,V.T=null,f=B.p,B.p=2,w=vt,vt|=4;try{T0(e,n,l)}finally{vt=w,B.p=f,V.T=o}}Jt=1,qm(),Hm(),Gm()}}function qm(){if(Jt===1){Jt=0;var e=Vi,n=rl,l=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||l){l=V.T,V.T=null;var o=B.p;B.p=2;var f=vt;vt|=4;try{xm(n,e);var g=Ec,w=Eh(e.containerInfo),z=g.focusedElem,$=g.selectionRange;if(w!==z&&z&&z.ownerDocument&&Ch(z.ownerDocument.documentElement,z)){if($!==null&&Zo(z)){var se=$.start,he=$.end;if(he===void 0&&(he=se),"selectionStart"in z)z.selectionStart=se,z.selectionEnd=Math.min(he,z.value.length);else{var me=z.ownerDocument||document,oe=me&&me.defaultView||window;if(oe.getSelection){var de=oe.getSelection(),Ee=z.textContent.length,Le=Math.min($.start,Ee),Nt=$.end===void 0?Le:Math.min($.end,Ee);!de.extend&&Le>Nt&&(w=Nt,Nt=Le,Le=w);var te=kh(z,Le),Y=kh(z,Nt);if(te&&Y&&(de.rangeCount!==1||de.anchorNode!==te.node||de.anchorOffset!==te.offset||de.focusNode!==Y.node||de.focusOffset!==Y.offset)){var le=me.createRange();le.setStart(te.node,te.offset),de.removeAllRanges(),Le>Nt?(de.addRange(le),de.extend(Y.node,Y.offset)):(le.setEnd(Y.node,Y.offset),de.addRange(le))}}}}for(me=[],de=z;de=de.parentNode;)de.nodeType===1&&me.push({element:de,left:de.scrollLeft,top:de.scrollTop});for(typeof z.focus=="function"&&z.focus(),z=0;z<me.length;z++){var pe=me[z];pe.element.scrollLeft=pe.left,pe.element.scrollTop=pe.top}}Vs=!!Cc,Ec=Cc=null}finally{vt=f,B.p=o,V.T=l}}e.current=n,Jt=2}}function Hm(){if(Jt===2){Jt=0;var e=Vi,n=rl,l=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||l){l=V.T,V.T=null;var o=B.p;B.p=2;var f=vt;vt|=4;try{mm(e,n.alternate,n)}finally{vt=f,B.p=o,V.T=l}}Jt=3}}function Gm(){if(Jt===4||Jt===3){Jt=0,Lt();var e=Vi,n=rl,l=ji,o=Tm;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?Jt=5:(Jt=0,rl=Vi=null,Vm(e,e.pendingLanes));var f=e.pendingLanes;if(f===0&&(Gi=null),We(l),n=n.stateNode,ct&&typeof ct.onCommitFiberRoot=="function")try{ct.onCommitFiberRoot(wt,n,void 0,(n.current.flags&128)===128)}catch{}if(o!==null){n=V.T,f=B.p,B.p=2,V.T=null;try{for(var g=e.onRecoverableError,w=0;w<o.length;w++){var z=o[w];g(z.value,{componentStack:z.stack})}}finally{V.T=n,B.p=f}}(ji&3)!==0&&zs(),Wn(e),f=e.pendingLanes,(l&261930)!==0&&(f&42)!==0?e===fc?ia++:(ia=0,fc=e):ia=0,ra(0)}}function Vm(e,n){(e.pooledCacheLanes&=n)===0&&(n=e.pooledCache,n!=null&&(e.pooledCache=null,Ul(n)))}function zs(){return qm(),Hm(),Gm(),$m()}function $m(){if(Jt!==5)return!1;var e=Vi,n=cc;cc=0;var l=We(ji),o=V.T,f=B.p;try{B.p=32>l?32:l,V.T=null,l=dc,dc=null;var g=Vi,w=ji;if(Jt=0,rl=Vi=null,ji=0,(vt&6)!==0)throw Error(a(331));var z=vt;if(vt|=4,Cm(g.current),Sm(g,g.current,w,l),vt=z,ra(0,!1),ct&&typeof ct.onPostCommitFiberRoot=="function")try{ct.onPostCommitFiberRoot(wt,g)}catch{}return!0}finally{B.p=f,V.T=o,Vm(e,n)}}function Pm(e,n,l){n=Mn(l,n),n=$u(e.stateNode,n,2),e=Li(e,n,2),e!==null&&(He(e,2),Wn(e))}function jt(e,n,l){if(e.tag===3)Pm(e,e,l);else for(;n!==null;){if(n.tag===3){Pm(n,e,l);break}else if(n.tag===1){var o=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(Gi===null||!Gi.has(o))){e=Mn(l,e),l=Yp(2),o=Li(n,l,2),o!==null&&(Fp(l,o,n,e),He(o,2),Wn(o));break}}n=n.return}}function mc(e,n,l){var o=e.pingCache;if(o===null){o=e.pingCache=new z0;var f=new Set;o.set(n,f)}else f=o.get(n),f===void 0&&(f=new Set,o.set(n,f));f.has(l)||(sc=!0,f.add(l),e=L0.bind(null,e,n,l),n.then(e,e))}function L0(e,n,l){var o=e.pingCache;o!==null&&o.delete(n),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,Rt===e&&(at&l)===l&&(Ht===4||Ht===3&&(at&62914560)===at&&300>Ie()-Cs?(vt&2)===0&&ll(e,0):oc|=l,il===at&&(il=0)),Wn(e)}function Ym(e,n){n===0&&(n=ce()),e=ar(e,n),e!==null&&(He(e,n),Wn(e))}function B0(e){var n=e.memoizedState,l=0;n!==null&&(l=n.retryLane),Ym(e,l)}function U0(e,n){var l=0;switch(e.tag){case 31:case 13:var o=e.stateNode,f=e.memoizedState;f!==null&&(l=f.retryLane);break;case 19:o=e.stateNode;break;case 22:o=e.stateNode._retryCache;break;default:throw Error(a(314))}o!==null&&o.delete(n),Ym(e,l)}function I0(e,n){return At(e,n)}var _s=null,sl=null,gc=!1,Ds=!1,yc=!1,Pi=0;function Wn(e){e!==sl&&e.next===null&&(sl===null?_s=sl=e:sl=sl.next=e),Ds=!0,gc||(gc=!0,H0())}function ra(e,n){if(!yc&&Ds){yc=!0;do for(var l=!1,o=_s;o!==null;){if(e!==0){var f=o.pendingLanes;if(f===0)var g=0;else{var w=o.suspendedLanes,z=o.pingedLanes;g=(1<<31-lt(42|e)+1)-1,g&=f&~(w&~z),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(l=!0,Km(o,g))}else g=at,g=ke(o,o===Rt?g:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(g&3)===0||Te(o,g)||(l=!0,Km(o,g));o=o.next}while(l);yc=!1}}function q0(){Fm()}function Fm(){Ds=gc=!1;var e=0;Pi!==0&&Z0()&&(e=Pi);for(var n=Ie(),l=null,o=_s;o!==null;){var f=o.next,g=Qm(o,n);g===0?(o.next=null,l===null?_s=f:l.next=f,f===null&&(sl=l)):(l=o,(e!==0||(g&3)!==0)&&(Ds=!0)),o=f}Jt!==0&&Jt!==5||ra(e),Pi!==0&&(Pi=0)}function Qm(e,n){for(var l=e.suspendedLanes,o=e.pingedLanes,f=e.expirationTimes,g=e.pendingLanes&-62914561;0<g;){var w=31-lt(g),z=1<<w,$=f[w];$===-1?((z&l)===0||(z&o)!==0)&&(f[w]=G(z,n)):$<=n&&(e.expiredLanes|=z),g&=~z}if(n=Rt,l=at,l=ke(e,e===n?l:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o=e.callbackNode,l===0||e===n&&(St===2||St===9)||e.cancelPendingCommit!==null)return o!==null&&o!==null&&Je(o),e.callbackNode=null,e.callbackPriority=0;if((l&3)===0||Te(e,l)){if(n=l&-l,n===e.callbackPriority)return n;switch(o!==null&&Je(o),We(l)){case 2:case 8:l=ie;break;case 32:l=ye;break;case 268435456:l=Ce;break;default:l=ye}return o=Xm.bind(null,e),l=At(l,o),e.callbackPriority=n,e.callbackNode=l,n}return o!==null&&o!==null&&Je(o),e.callbackPriority=2,e.callbackNode=null,2}function Xm(e,n){if(Jt!==0&&Jt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var l=e.callbackNode;if(zs()&&e.callbackNode!==l)return null;var o=at;return o=ke(e,e===Rt?o:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o===0?null:(Rm(e,o,n),Qm(e,Ie()),e.callbackNode!=null&&e.callbackNode===l?Xm.bind(null,e):null)}function Km(e,n){if(zs())return null;Rm(e,n,!0)}function H0(){W0(function(){(vt&6)!==0?At(M,q0):Fm()})}function bc(){if(Pi===0){var e=Yr;e===0&&(e=Se,Se<<=1,(Se&261888)===0&&(Se=256)),Pi=e}return Pi}function Zm(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Ha(""+e)}function Jm(e,n){var l=n.ownerDocument.createElement("input");return l.name=n.name,l.value=n.value,e.id&&l.setAttribute("form",e.id),n.parentNode.insertBefore(l,n),e=new FormData(e),l.parentNode.removeChild(l),e}function G0(e,n,l,o,f){if(n==="submit"&&l&&l.stateNode===f){var g=Zm((f[nn]||null).action),w=o.submitter;w&&(n=(n=w[nn]||null)?Zm(n.formAction):w.getAttribute("formAction"),n!==null&&(g=n,w=null));var z=new Pa("action","action",null,o,f);e.push({event:z,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(Pi!==0){var $=w?Jm(f,w):new FormData(f);Uu(l,{pending:!0,data:$,method:f.method,action:g},null,$)}}else typeof g=="function"&&(z.preventDefault(),$=w?Jm(f,w):new FormData(f),Uu(l,{pending:!0,data:$,method:f.method,action:g},g,$))},currentTarget:f}]})}}for(var vc=0;vc<tu.length;vc++){var xc=tu[vc],V0=xc.toLowerCase(),$0=xc[0].toUpperCase()+xc.slice(1);Gn(V0,"on"+$0)}Gn(Ah,"onAnimationEnd"),Gn(Rh,"onAnimationIteration"),Gn(zh,"onAnimationStart"),Gn("dblclick","onDoubleClick"),Gn("focusin","onFocus"),Gn("focusout","onBlur"),Gn(a0,"onTransitionRun"),Gn(s0,"onTransitionStart"),Gn(o0,"onTransitionCancel"),Gn(_h,"onTransitionEnd"),_r("onMouseEnter",["mouseout","mouseover"]),_r("onMouseLeave",["mouseout","mouseover"]),_r("onPointerEnter",["pointerout","pointerover"]),_r("onPointerLeave",["pointerout","pointerover"]),nr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),nr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),nr("onBeforeInput",["compositionend","keypress","textInput","paste"]),nr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),nr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),nr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var la="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(" "),P0=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(la));function Wm(e,n){n=(n&4)!==0;for(var l=0;l<e.length;l++){var o=e[l],f=o.event;o=o.listeners;e:{var g=void 0;if(n)for(var w=o.length-1;0<=w;w--){var z=o[w],$=z.instance,se=z.currentTarget;if(z=z.listener,$!==g&&f.isPropagationStopped())break e;g=z,f.currentTarget=se;try{g(f)}catch(he){Qa(he)}f.currentTarget=null,g=$}else for(w=0;w<o.length;w++){if(z=o[w],$=z.instance,se=z.currentTarget,z=z.listener,$!==g&&f.isPropagationStopped())break e;g=z,f.currentTarget=se;try{g(f)}catch(he){Qa(he)}f.currentTarget=null,g=$}}}}function it(e,n){var l=n[Xn];l===void 0&&(l=n[Xn]=new Set);var o=e+"__bubble";l.has(o)||(eg(n,e,2,!1),l.add(o))}function wc(e,n,l){var o=0;n&&(o|=4),eg(l,e,o,n)}var Ms="_reactListening"+Math.random().toString(36).slice(2);function Sc(e){if(!e[Ms]){e[Ms]=!0,Ff.forEach(function(l){l!=="selectionchange"&&(P0.has(l)||wc(l,!1,e),wc(l,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[Ms]||(n[Ms]=!0,wc("selectionchange",!1,n))}}function eg(e,n,l,o){switch(Ag(n)){case 2:var f=v1;break;case 8:f=x1;break;default:f=Bc}l=f.bind(null,n,l,e),f=void 0,!Go||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(f=!0),o?f!==void 0?e.addEventListener(n,l,{capture:!0,passive:f}):e.addEventListener(n,l,!0):f!==void 0?e.addEventListener(n,l,{passive:f}):e.addEventListener(n,l,!1)}function jc(e,n,l,o,f){var g=o;if((n&1)===0&&(n&2)===0&&o!==null)e:for(;;){if(o===null)return;var w=o.tag;if(w===3||w===4){var z=o.stateNode.containerInfo;if(z===f)break;if(w===4)for(w=o.return;w!==null;){var $=w.tag;if(($===3||$===4)&&w.stateNode.containerInfo===f)return;w=w.return}for(;z!==null;){if(w=Ar(z),w===null)return;if($=w.tag,$===5||$===6||$===26||$===27){o=g=w;continue e}z=z.parentNode}}o=o.return}lh(function(){var se=g,he=qo(l),me=[];e:{var oe=Dh.get(e);if(oe!==void 0){var de=Pa,Ee=e;switch(e){case"keypress":if(Va(l)===0)break e;case"keydown":case"keyup":de=Ux;break;case"focusin":Ee="focus",de=Yo;break;case"focusout":Ee="blur",de=Yo;break;case"beforeblur":case"afterblur":de=Yo;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":de=oh;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":de=Ex;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":de=Hx;break;case Ah:case Rh:case zh:de=Ax;break;case _h:de=Vx;break;case"scroll":case"scrollend":de=kx;break;case"wheel":de=Px;break;case"copy":case"cut":case"paste":de=zx;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":de=ch;break;case"toggle":case"beforetoggle":de=Fx}var Le=(n&4)!==0,Nt=!Le&&(e==="scroll"||e==="scrollend"),te=Le?oe!==null?oe+"Capture":null:oe;Le=[];for(var Y=se,le;Y!==null;){var pe=Y;if(le=pe.stateNode,pe=pe.tag,pe!==5&&pe!==26&&pe!==27||le===null||te===null||(pe=Nl(Y,te),pe!=null&&Le.push(aa(Y,pe,le))),Nt)break;Y=Y.return}0<Le.length&&(oe=new de(oe,Ee,null,l,he),me.push({event:oe,listeners:Le}))}}if((n&7)===0){e:{if(oe=e==="mouseover"||e==="pointerover",de=e==="mouseout"||e==="pointerout",oe&&l!==Io&&(Ee=l.relatedTarget||l.fromElement)&&(Ar(Ee)||Ee[Qn]))break e;if((de||oe)&&(oe=he.window===he?he:(oe=he.ownerDocument)?oe.defaultView||oe.parentWindow:window,de?(Ee=l.relatedTarget||l.toElement,de=se,Ee=Ee?Ar(Ee):null,Ee!==null&&(Nt=d(Ee),Le=Ee.tag,Ee!==Nt||Le!==5&&Le!==27&&Le!==6)&&(Ee=null)):(de=null,Ee=se),de!==Ee)){if(Le=oh,pe="onMouseLeave",te="onMouseEnter",Y="mouse",(e==="pointerout"||e==="pointerover")&&(Le=ch,pe="onPointerLeave",te="onPointerEnter",Y="pointer"),Nt=de==null?oe:El(de),le=Ee==null?oe:El(Ee),oe=new Le(pe,Y+"leave",de,l,he),oe.target=Nt,oe.relatedTarget=le,pe=null,Ar(he)===se&&(Le=new Le(te,Y+"enter",Ee,l,he),Le.target=le,Le.relatedTarget=Nt,pe=Le),Nt=pe,de&&Ee)t:{for(Le=Y0,te=de,Y=Ee,le=0,pe=te;pe;pe=Le(pe))le++;pe=0;for(var Me=Y;Me;Me=Le(Me))pe++;for(;0<le-pe;)te=Le(te),le--;for(;0<pe-le;)Y=Le(Y),pe--;for(;le--;){if(te===Y||Y!==null&&te===Y.alternate){Le=te;break t}te=Le(te),Y=Le(Y)}Le=null}else Le=null;de!==null&&tg(me,oe,de,Le,!1),Ee!==null&&Nt!==null&&tg(me,Nt,Ee,Le,!0)}}e:{if(oe=se?El(se):window,de=oe.nodeName&&oe.nodeName.toLowerCase(),de==="select"||de==="input"&&oe.type==="file")var gt=bh;else if(gh(oe))if(vh)gt=i0;else{gt=t0;var Re=e0}else de=oe.nodeName,!de||de.toLowerCase()!=="input"||oe.type!=="checkbox"&&oe.type!=="radio"?se&&Uo(se.elementType)&&(gt=bh):gt=n0;if(gt&&(gt=gt(e,se))){yh(me,gt,l,he);break e}Re&&Re(e,oe,se),e==="focusout"&&se&&oe.type==="number"&&se.memoizedProps.value!=null&&Bo(oe,"number",oe.value)}switch(Re=se?El(se):window,e){case"focusin":(gh(Re)||Re.contentEditable==="true")&&(Ur=Re,Jo=se,Ol=null);break;case"focusout":Ol=Jo=Ur=null;break;case"mousedown":Wo=!0;break;case"contextmenu":case"mouseup":case"dragend":Wo=!1,Nh(me,l,he);break;case"selectionchange":if(l0)break;case"keydown":case"keyup":Nh(me,l,he)}var Xe;if(Qo)e:{switch(e){case"compositionstart":var st="onCompositionStart";break e;case"compositionend":st="onCompositionEnd";break e;case"compositionupdate":st="onCompositionUpdate";break e}st=void 0}else Br?ph(e,l)&&(st="onCompositionEnd"):e==="keydown"&&l.keyCode===229&&(st="onCompositionStart");st&&(dh&&l.locale!=="ko"&&(Br||st!=="onCompositionStart"?st==="onCompositionEnd"&&Br&&(Xe=ah()):(Ai=he,Vo="value"in Ai?Ai.value:Ai.textContent,Br=!0)),Re=Os(se,st),0<Re.length&&(st=new uh(st,e,null,l,he),me.push({event:st,listeners:Re}),Xe?st.data=Xe:(Xe=mh(l),Xe!==null&&(st.data=Xe)))),(Xe=Xx?Kx(e,l):Zx(e,l))&&(st=Os(se,"onBeforeInput"),0<st.length&&(Re=new uh("onBeforeInput","beforeinput",null,l,he),me.push({event:Re,listeners:st}),Re.data=Xe)),G0(me,e,se,l,he)}Wm(me,n)})}function aa(e,n,l){return{instance:e,listener:n,currentTarget:l}}function Os(e,n){for(var l=n+"Capture",o=[];e!==null;){var f=e,g=f.stateNode;if(f=f.tag,f!==5&&f!==26&&f!==27||g===null||(f=Nl(e,l),f!=null&&o.unshift(aa(e,f,g)),f=Nl(e,n),f!=null&&o.push(aa(e,f,g))),e.tag===3)return o;e=e.return}return[]}function Y0(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function tg(e,n,l,o,f){for(var g=n._reactName,w=[];l!==null&&l!==o;){var z=l,$=z.alternate,se=z.stateNode;if(z=z.tag,$!==null&&$===o)break;z!==5&&z!==26&&z!==27||se===null||($=se,f?(se=Nl(l,g),se!=null&&w.unshift(aa(l,se,$))):f||(se=Nl(l,g),se!=null&&w.push(aa(l,se,$)))),l=l.return}w.length!==0&&e.push({event:n,listeners:w})}var F0=/\r\n?/g,Q0=/\u0000|\uFFFD/g;function ng(e){return(typeof e=="string"?e:""+e).replace(F0,`
9
- `).replace(Q0,"")}function ig(e,n){return n=ng(n),ng(e)===n}function Et(e,n,l,o,f,g){switch(l){case"children":typeof o=="string"?n==="body"||n==="textarea"&&o===""||Mr(e,o):(typeof o=="number"||typeof o=="bigint")&&n!=="body"&&Mr(e,""+o);break;case"className":Ia(e,"class",o);break;case"tabIndex":Ia(e,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":Ia(e,l,o);break;case"style":ih(e,o,g);break;case"data":if(n!=="object"){Ia(e,"data",o);break}case"src":case"href":if(o===""&&(n!=="a"||l!=="href")){e.removeAttribute(l);break}if(o==null||typeof o=="function"||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(l);break}o=Ha(""+o),e.setAttribute(l,o);break;case"action":case"formAction":if(typeof o=="function"){e.setAttribute(l,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof g=="function"&&(l==="formAction"?(n!=="input"&&Et(e,n,"name",f.name,f,null),Et(e,n,"formEncType",f.formEncType,f,null),Et(e,n,"formMethod",f.formMethod,f,null),Et(e,n,"formTarget",f.formTarget,f,null)):(Et(e,n,"encType",f.encType,f,null),Et(e,n,"method",f.method,f,null),Et(e,n,"target",f.target,f,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(l);break}o=Ha(""+o),e.setAttribute(l,o);break;case"onClick":o!=null&&(e.onclick=oi);break;case"onScroll":o!=null&&it("scroll",e);break;case"onScrollEnd":o!=null&&it("scrollend",e);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(a(61));if(l=o.__html,l!=null){if(f.children!=null)throw Error(a(60));e.innerHTML=l}}break;case"multiple":e.multiple=o&&typeof o!="function"&&typeof o!="symbol";break;case"muted":e.muted=o&&typeof o!="function"&&typeof o!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(o==null||typeof o=="function"||typeof o=="boolean"||typeof o=="symbol"){e.removeAttribute("xlink:href");break}l=Ha(""+o),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(l,""+o):e.removeAttribute(l);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":o&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(l,""):e.removeAttribute(l);break;case"capture":case"download":o===!0?e.setAttribute(l,""):o!==!1&&o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(l,o):e.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":o!=null&&typeof o!="function"&&typeof o!="symbol"&&!isNaN(o)&&1<=o?e.setAttribute(l,o):e.removeAttribute(l);break;case"rowSpan":case"start":o==null||typeof o=="function"||typeof o=="symbol"||isNaN(o)?e.removeAttribute(l):e.setAttribute(l,o);break;case"popover":it("beforetoggle",e),it("toggle",e),Ua(e,"popover",o);break;case"xlinkActuate":si(e,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":si(e,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":si(e,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":si(e,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":si(e,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":si(e,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":si(e,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":si(e,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":si(e,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":Ua(e,"is",o);break;case"innerText":case"textContent":break;default:(!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(l=Sx.get(l)||l,Ua(e,l,o))}}function kc(e,n,l,o,f,g){switch(l){case"style":ih(e,o,g);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(a(61));if(l=o.__html,l!=null){if(f.children!=null)throw Error(a(60));e.innerHTML=l}}break;case"children":typeof o=="string"?Mr(e,o):(typeof o=="number"||typeof o=="bigint")&&Mr(e,""+o);break;case"onScroll":o!=null&&it("scroll",e);break;case"onScrollEnd":o!=null&&it("scrollend",e);break;case"onClick":o!=null&&(e.onclick=oi);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Qf.hasOwnProperty(l))e:{if(l[0]==="o"&&l[1]==="n"&&(f=l.endsWith("Capture"),n=l.slice(2,f?l.length-7:void 0),g=e[nn]||null,g=g!=null?g[l]:null,typeof g=="function"&&e.removeEventListener(n,g,f),typeof o=="function")){typeof g!="function"&&g!==null&&(l in e?e[l]=null:e.hasAttribute(l)&&e.removeAttribute(l)),e.addEventListener(n,o,f);break e}l in e?e[l]=o:o===!0?e.setAttribute(l,""):Ua(e,l,o)}}}function sn(e,n,l){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":it("error",e),it("load",e);var o=!1,f=!1,g;for(g in l)if(l.hasOwnProperty(g)){var w=l[g];if(w!=null)switch(g){case"src":o=!0;break;case"srcSet":f=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(a(137,n));default:Et(e,n,g,w,l,null)}}f&&Et(e,n,"srcSet",l.srcSet,l,null),o&&Et(e,n,"src",l.src,l,null);return;case"input":it("invalid",e);var z=g=w=f=null,$=null,se=null;for(o in l)if(l.hasOwnProperty(o)){var he=l[o];if(he!=null)switch(o){case"name":f=he;break;case"type":w=he;break;case"checked":$=he;break;case"defaultChecked":se=he;break;case"value":g=he;break;case"defaultValue":z=he;break;case"children":case"dangerouslySetInnerHTML":if(he!=null)throw Error(a(137,n));break;default:Et(e,n,o,he,l,null)}}Wf(e,g,z,$,se,w,f,!1);return;case"select":it("invalid",e),o=w=g=null;for(f in l)if(l.hasOwnProperty(f)&&(z=l[f],z!=null))switch(f){case"value":g=z;break;case"defaultValue":w=z;break;case"multiple":o=z;default:Et(e,n,f,z,l,null)}n=g,l=w,e.multiple=!!o,n!=null?Dr(e,!!o,n,!1):l!=null&&Dr(e,!!o,l,!0);return;case"textarea":it("invalid",e),g=f=o=null;for(w in l)if(l.hasOwnProperty(w)&&(z=l[w],z!=null))switch(w){case"value":o=z;break;case"defaultValue":f=z;break;case"children":g=z;break;case"dangerouslySetInnerHTML":if(z!=null)throw Error(a(91));break;default:Et(e,n,w,z,l,null)}th(e,o,f,g);return;case"option":for($ in l)l.hasOwnProperty($)&&(o=l[$],o!=null)&&($==="selected"?e.selected=o&&typeof o!="function"&&typeof o!="symbol":Et(e,n,$,o,l,null));return;case"dialog":it("beforetoggle",e),it("toggle",e),it("cancel",e),it("close",e);break;case"iframe":case"object":it("load",e);break;case"video":case"audio":for(o=0;o<la.length;o++)it(la[o],e);break;case"image":it("error",e),it("load",e);break;case"details":it("toggle",e);break;case"embed":case"source":case"link":it("error",e),it("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(se in l)if(l.hasOwnProperty(se)&&(o=l[se],o!=null))switch(se){case"children":case"dangerouslySetInnerHTML":throw Error(a(137,n));default:Et(e,n,se,o,l,null)}return;default:if(Uo(n)){for(he in l)l.hasOwnProperty(he)&&(o=l[he],o!==void 0&&kc(e,n,he,o,l,void 0));return}}for(z in l)l.hasOwnProperty(z)&&(o=l[z],o!=null&&Et(e,n,z,o,l,null))}function X0(e,n,l,o){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var f=null,g=null,w=null,z=null,$=null,se=null,he=null;for(de in l){var me=l[de];if(l.hasOwnProperty(de)&&me!=null)switch(de){case"checked":break;case"value":break;case"defaultValue":$=me;default:o.hasOwnProperty(de)||Et(e,n,de,null,o,me)}}for(var oe in o){var de=o[oe];if(me=l[oe],o.hasOwnProperty(oe)&&(de!=null||me!=null))switch(oe){case"type":g=de;break;case"name":f=de;break;case"checked":se=de;break;case"defaultChecked":he=de;break;case"value":w=de;break;case"defaultValue":z=de;break;case"children":case"dangerouslySetInnerHTML":if(de!=null)throw Error(a(137,n));break;default:de!==me&&Et(e,n,oe,de,o,me)}}Lo(e,w,z,$,se,he,g,f);return;case"select":de=w=z=oe=null;for(g in l)if($=l[g],l.hasOwnProperty(g)&&$!=null)switch(g){case"value":break;case"multiple":de=$;default:o.hasOwnProperty(g)||Et(e,n,g,null,o,$)}for(f in o)if(g=o[f],$=l[f],o.hasOwnProperty(f)&&(g!=null||$!=null))switch(f){case"value":oe=g;break;case"defaultValue":z=g;break;case"multiple":w=g;default:g!==$&&Et(e,n,f,g,o,$)}n=z,l=w,o=de,oe!=null?Dr(e,!!l,oe,!1):!!o!=!!l&&(n!=null?Dr(e,!!l,n,!0):Dr(e,!!l,l?[]:"",!1));return;case"textarea":de=oe=null;for(z in l)if(f=l[z],l.hasOwnProperty(z)&&f!=null&&!o.hasOwnProperty(z))switch(z){case"value":break;case"children":break;default:Et(e,n,z,null,o,f)}for(w in o)if(f=o[w],g=l[w],o.hasOwnProperty(w)&&(f!=null||g!=null))switch(w){case"value":oe=f;break;case"defaultValue":de=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(a(91));break;default:f!==g&&Et(e,n,w,f,o,g)}eh(e,oe,de);return;case"option":for(var Ee in l)oe=l[Ee],l.hasOwnProperty(Ee)&&oe!=null&&!o.hasOwnProperty(Ee)&&(Ee==="selected"?e.selected=!1:Et(e,n,Ee,null,o,oe));for($ in o)oe=o[$],de=l[$],o.hasOwnProperty($)&&oe!==de&&(oe!=null||de!=null)&&($==="selected"?e.selected=oe&&typeof oe!="function"&&typeof oe!="symbol":Et(e,n,$,oe,o,de));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Le in l)oe=l[Le],l.hasOwnProperty(Le)&&oe!=null&&!o.hasOwnProperty(Le)&&Et(e,n,Le,null,o,oe);for(se in o)if(oe=o[se],de=l[se],o.hasOwnProperty(se)&&oe!==de&&(oe!=null||de!=null))switch(se){case"children":case"dangerouslySetInnerHTML":if(oe!=null)throw Error(a(137,n));break;default:Et(e,n,se,oe,o,de)}return;default:if(Uo(n)){for(var Nt in l)oe=l[Nt],l.hasOwnProperty(Nt)&&oe!==void 0&&!o.hasOwnProperty(Nt)&&kc(e,n,Nt,void 0,o,oe);for(he in o)oe=o[he],de=l[he],!o.hasOwnProperty(he)||oe===de||oe===void 0&&de===void 0||kc(e,n,he,oe,o,de);return}}for(var te in l)oe=l[te],l.hasOwnProperty(te)&&oe!=null&&!o.hasOwnProperty(te)&&Et(e,n,te,null,o,oe);for(me in o)oe=o[me],de=l[me],!o.hasOwnProperty(me)||oe===de||oe==null&&de==null||Et(e,n,me,oe,o,de)}function rg(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function K0(){if(typeof performance.getEntriesByType=="function"){for(var e=0,n=0,l=performance.getEntriesByType("resource"),o=0;o<l.length;o++){var f=l[o],g=f.transferSize,w=f.initiatorType,z=f.duration;if(g&&z&&rg(w)){for(w=0,z=f.responseEnd,o+=1;o<l.length;o++){var $=l[o],se=$.startTime;if(se>z)break;var he=$.transferSize,me=$.initiatorType;he&&rg(me)&&($=$.responseEnd,w+=he*($<z?1:(z-se)/($-se)))}if(--o,n+=8*(g+w)/(f.duration/1e3),e++,10<e)break}}if(0<e)return n/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var Cc=null,Ec=null;function Ls(e){return e.nodeType===9?e:e.ownerDocument}function lg(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function ag(e,n){if(e===0)switch(n){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&n==="foreignObject"?0:e}function Nc(e,n){return e==="textarea"||e==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.children=="bigint"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var Tc=null;function Z0(){var e=window.event;return e&&e.type==="popstate"?e===Tc?!1:(Tc=e,!0):(Tc=null,!1)}var sg=typeof setTimeout=="function"?setTimeout:void 0,J0=typeof clearTimeout=="function"?clearTimeout:void 0,og=typeof Promise=="function"?Promise:void 0,W0=typeof queueMicrotask=="function"?queueMicrotask:typeof og<"u"?function(e){return og.resolve(null).then(e).catch(e1)}:sg;function e1(e){setTimeout(function(){throw e})}function Yi(e){return e==="head"}function ug(e,n){var l=n,o=0;do{var f=l.nextSibling;if(e.removeChild(l),f&&f.nodeType===8)if(l=f.data,l==="/$"||l==="/&"){if(o===0){e.removeChild(f),dl(n);return}o--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")o++;else if(l==="html")sa(e.ownerDocument.documentElement);else if(l==="head"){l=e.ownerDocument.head,sa(l);for(var g=l.firstChild;g;){var w=g.nextSibling,z=g.nodeName;g[Cl]||z==="SCRIPT"||z==="STYLE"||z==="LINK"&&g.rel.toLowerCase()==="stylesheet"||l.removeChild(g),g=w}}else l==="body"&&sa(e.ownerDocument.body);l=f}while(l);dl(n)}function cg(e,n){var l=e;e=0;do{var o=l.nextSibling;if(l.nodeType===1?n?(l._stashedDisplay=l.style.display,l.style.display="none"):(l.style.display=l._stashedDisplay||"",l.getAttribute("style")===""&&l.removeAttribute("style")):l.nodeType===3&&(n?(l._stashedText=l.nodeValue,l.nodeValue=""):l.nodeValue=l._stashedText||""),o&&o.nodeType===8)if(l=o.data,l==="/$"){if(e===0)break;e--}else l!=="$"&&l!=="$?"&&l!=="$~"&&l!=="$!"||e++;l=o}while(l)}function Ac(e){var n=e.firstChild;for(n&&n.nodeType===10&&(n=n.nextSibling);n;){var l=n;switch(n=n.nextSibling,l.nodeName){case"HTML":case"HEAD":case"BODY":Ac(l),Mo(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}e.removeChild(l)}}function t1(e,n,l,o){for(;e.nodeType===1;){var f=l;if(e.nodeName.toLowerCase()!==n.toLowerCase()){if(!o&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(o){if(!e[Cl])switch(n){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(g=e.getAttribute("rel"),g==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(g!==f.rel||e.getAttribute("href")!==(f.href==null||f.href===""?null:f.href)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin)||e.getAttribute("title")!==(f.title==null?null:f.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(g=e.getAttribute("src"),(g!==(f.src==null?null:f.src)||e.getAttribute("type")!==(f.type==null?null:f.type)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin))&&g&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(n==="input"&&e.type==="hidden"){var g=f.name==null?null:""+f.name;if(f.type==="hidden"&&e.getAttribute("name")===g)return e}else return e;if(e=In(e.nextSibling),e===null)break}return null}function n1(e,n,l){if(n==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!l||(e=In(e.nextSibling),e===null))return null;return e}function dg(e,n){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=In(e.nextSibling),e===null))return null;return e}function Rc(e){return e.data==="$?"||e.data==="$~"}function zc(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function i1(e,n){var l=e.ownerDocument;if(e.data==="$~")e._reactRetry=n;else if(e.data!=="$?"||l.readyState!=="loading")n();else{var o=function(){n(),l.removeEventListener("DOMContentLoaded",o)};l.addEventListener("DOMContentLoaded",o),e._reactRetry=o}}function In(e){for(;e!=null;e=e.nextSibling){var n=e.nodeType;if(n===1||n===3)break;if(n===8){if(n=e.data,n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"||n==="F!"||n==="F")break;if(n==="/$"||n==="/&")return null}}return e}var _c=null;function fg(e){e=e.nextSibling;for(var n=0;e;){if(e.nodeType===8){var l=e.data;if(l==="/$"||l==="/&"){if(n===0)return In(e.nextSibling);n--}else l!=="$"&&l!=="$!"&&l!=="$?"&&l!=="$~"&&l!=="&"||n++}e=e.nextSibling}return null}function hg(e){e=e.previousSibling;for(var n=0;e;){if(e.nodeType===8){var l=e.data;if(l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"){if(n===0)return e;n--}else l!=="/$"&&l!=="/&"||n++}e=e.previousSibling}return null}function pg(e,n,l){switch(n=Ls(l),e){case"html":if(e=n.documentElement,!e)throw Error(a(452));return e;case"head":if(e=n.head,!e)throw Error(a(453));return e;case"body":if(e=n.body,!e)throw Error(a(454));return e;default:throw Error(a(451))}}function sa(e){for(var n=e.attributes;n.length;)e.removeAttributeNode(n[0]);Mo(e)}var qn=new Map,mg=new Set;function Bs(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var ki=B.d;B.d={f:r1,r:l1,D:a1,C:s1,L:o1,m:u1,X:d1,S:c1,M:f1};function r1(){var e=ki.f(),n=Ts();return e||n}function l1(e){var n=Rr(e);n!==null&&n.tag===5&&n.type==="form"?_p(n):ki.r(e)}var ol=typeof document>"u"?null:document;function gg(e,n,l){var o=ol;if(o&&typeof n=="string"&&n){var f=_n(n);f='link[rel="'+e+'"][href="'+f+'"]',typeof l=="string"&&(f+='[crossorigin="'+l+'"]'),mg.has(f)||(mg.add(f),e={rel:e,crossOrigin:l,href:n},o.querySelector(f)===null&&(n=o.createElement("link"),sn(n,"link",e),Wt(n),o.head.appendChild(n)))}}function a1(e){ki.D(e),gg("dns-prefetch",e,null)}function s1(e,n){ki.C(e,n),gg("preconnect",e,n)}function o1(e,n,l){ki.L(e,n,l);var o=ol;if(o&&e&&n){var f='link[rel="preload"][as="'+_n(n)+'"]';n==="image"&&l&&l.imageSrcSet?(f+='[imagesrcset="'+_n(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(f+='[imagesizes="'+_n(l.imageSizes)+'"]')):f+='[href="'+_n(e)+'"]';var g=f;switch(n){case"style":g=ul(e);break;case"script":g=cl(e)}qn.has(g)||(e=b({rel:"preload",href:n==="image"&&l&&l.imageSrcSet?void 0:e,as:n},l),qn.set(g,e),o.querySelector(f)!==null||n==="style"&&o.querySelector(oa(g))||n==="script"&&o.querySelector(ua(g))||(n=o.createElement("link"),sn(n,"link",e),Wt(n),o.head.appendChild(n)))}}function u1(e,n){ki.m(e,n);var l=ol;if(l&&e){var o=n&&typeof n.as=="string"?n.as:"script",f='link[rel="modulepreload"][as="'+_n(o)+'"][href="'+_n(e)+'"]',g=f;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=cl(e)}if(!qn.has(g)&&(e=b({rel:"modulepreload",href:e},n),qn.set(g,e),l.querySelector(f)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(ua(g)))return}o=l.createElement("link"),sn(o,"link",e),Wt(o),l.head.appendChild(o)}}}function c1(e,n,l){ki.S(e,n,l);var o=ol;if(o&&e){var f=zr(o).hoistableStyles,g=ul(e);n=n||"default";var w=f.get(g);if(!w){var z={loading:0,preload:null};if(w=o.querySelector(oa(g)))z.loading=5;else{e=b({rel:"stylesheet",href:e,"data-precedence":n},l),(l=qn.get(g))&&Dc(e,l);var $=w=o.createElement("link");Wt($),sn($,"link",e),$._p=new Promise(function(se,he){$.onload=se,$.onerror=he}),$.addEventListener("load",function(){z.loading|=1}),$.addEventListener("error",function(){z.loading|=2}),z.loading|=4,Us(w,n,o)}w={type:"stylesheet",instance:w,count:1,state:z},f.set(g,w)}}}function d1(e,n){ki.X(e,n);var l=ol;if(l&&e){var o=zr(l).hoistableScripts,f=cl(e),g=o.get(f);g||(g=l.querySelector(ua(f)),g||(e=b({src:e,async:!0},n),(n=qn.get(f))&&Mc(e,n),g=l.createElement("script"),Wt(g),sn(g,"link",e),l.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},o.set(f,g))}}function f1(e,n){ki.M(e,n);var l=ol;if(l&&e){var o=zr(l).hoistableScripts,f=cl(e),g=o.get(f);g||(g=l.querySelector(ua(f)),g||(e=b({src:e,async:!0,type:"module"},n),(n=qn.get(f))&&Mc(e,n),g=l.createElement("script"),Wt(g),sn(g,"link",e),l.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},o.set(f,g))}}function yg(e,n,l,o){var f=(f=Z.current)?Bs(f):null;if(!f)throw Error(a(446));switch(e){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(n=ul(l.href),l=zr(f).hoistableStyles,o=l.get(n),o||(o={type:"style",instance:null,count:0,state:null},l.set(n,o)),o):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){e=ul(l.href);var g=zr(f).hoistableStyles,w=g.get(e);if(w||(f=f.ownerDocument||f,w={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(e,w),(g=f.querySelector(oa(e)))&&!g._p&&(w.instance=g,w.state.loading=5),qn.has(e)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},qn.set(e,l),g||h1(f,e,l,w.state))),n&&o===null)throw Error(a(528,""));return w}if(n&&o!==null)throw Error(a(529,""));return null;case"script":return n=l.async,l=l.src,typeof l=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=cl(l),l=zr(f).hoistableScripts,o=l.get(n),o||(o={type:"script",instance:null,count:0,state:null},l.set(n,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(a(444,e))}}function ul(e){return'href="'+_n(e)+'"'}function oa(e){return'link[rel="stylesheet"]['+e+"]"}function bg(e){return b({},e,{"data-precedence":e.precedence,precedence:null})}function h1(e,n,l,o){e.querySelector('link[rel="preload"][as="style"]['+n+"]")?o.loading=1:(n=e.createElement("link"),o.preload=n,n.addEventListener("load",function(){return o.loading|=1}),n.addEventListener("error",function(){return o.loading|=2}),sn(n,"link",l),Wt(n),e.head.appendChild(n))}function cl(e){return'[src="'+_n(e)+'"]'}function ua(e){return"script[async]"+e}function vg(e,n,l){if(n.count++,n.instance===null)switch(n.type){case"style":var o=e.querySelector('style[data-href~="'+_n(l.href)+'"]');if(o)return n.instance=o,Wt(o),o;var f=b({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return o=(e.ownerDocument||e).createElement("style"),Wt(o),sn(o,"style",f),Us(o,l.precedence,e),n.instance=o;case"stylesheet":f=ul(l.href);var g=e.querySelector(oa(f));if(g)return n.state.loading|=4,n.instance=g,Wt(g),g;o=bg(l),(f=qn.get(f))&&Dc(o,f),g=(e.ownerDocument||e).createElement("link"),Wt(g);var w=g;return w._p=new Promise(function(z,$){w.onload=z,w.onerror=$}),sn(g,"link",o),n.state.loading|=4,Us(g,l.precedence,e),n.instance=g;case"script":return g=cl(l.src),(f=e.querySelector(ua(g)))?(n.instance=f,Wt(f),f):(o=l,(f=qn.get(g))&&(o=b({},l),Mc(o,f)),e=e.ownerDocument||e,f=e.createElement("script"),Wt(f),sn(f,"link",o),e.head.appendChild(f),n.instance=f);case"void":return null;default:throw Error(a(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(o=n.instance,n.state.loading|=4,Us(o,l.precedence,e));return n.instance}function Us(e,n,l){for(var o=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=o.length?o[o.length-1]:null,g=f,w=0;w<o.length;w++){var z=o[w];if(z.dataset.precedence===n)g=z;else if(g!==f)break}g?g.parentNode.insertBefore(e,g.nextSibling):(n=l.nodeType===9?l.head:l,n.insertBefore(e,n.firstChild))}function Dc(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.title==null&&(e.title=n.title)}function Mc(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.integrity==null&&(e.integrity=n.integrity)}var Is=null;function xg(e,n,l){if(Is===null){var o=new Map,f=Is=new Map;f.set(l,o)}else f=Is,o=f.get(l),o||(o=new Map,f.set(l,o));if(o.has(e))return o;for(o.set(e,null),l=l.getElementsByTagName(e),f=0;f<l.length;f++){var g=l[f];if(!(g[Cl]||g[Dt]||e==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var w=g.getAttribute(n)||"";w=e+w;var z=o.get(w);z?z.push(g):o.set(w,[g])}}return o}function wg(e,n,l){e=e.ownerDocument||e,e.head.insertBefore(l,n==="title"?e.querySelector("head > title"):null)}function p1(e,n,l){if(l===1||n.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;return n.rel==="stylesheet"?(e=n.disabled,typeof n.precedence=="string"&&e==null):!0;case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function Sg(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function m1(e,n,l,o){if(l.type==="stylesheet"&&(typeof o.media!="string"||matchMedia(o.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var f=ul(o.href),g=n.querySelector(oa(f));if(g){n=g._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(e.count++,e=qs.bind(e),n.then(e,e)),l.state.loading|=4,l.instance=g,Wt(g);return}g=n.ownerDocument||n,o=bg(o),(f=qn.get(f))&&Dc(o,f),g=g.createElement("link"),Wt(g);var w=g;w._p=new Promise(function(z,$){w.onload=z,w.onerror=$}),sn(g,"link",o),l.instance=g}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(l,n),(n=l.state.preload)&&(l.state.loading&3)===0&&(e.count++,l=qs.bind(e),n.addEventListener("load",l),n.addEventListener("error",l))}}var Oc=0;function g1(e,n){return e.stylesheets&&e.count===0&&Gs(e,e.stylesheets),0<e.count||0<e.imgCount?function(l){var o=setTimeout(function(){if(e.stylesheets&&Gs(e,e.stylesheets),e.unsuspend){var g=e.unsuspend;e.unsuspend=null,g()}},6e4+n);0<e.imgBytes&&Oc===0&&(Oc=62500*K0());var f=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Gs(e,e.stylesheets),e.unsuspend)){var g=e.unsuspend;e.unsuspend=null,g()}},(e.imgBytes>Oc?50:800)+n);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(o),clearTimeout(f)}}:null}function qs(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Gs(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Hs=null;function Gs(e,n){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Hs=new Map,n.forEach(y1,e),Hs=null,qs.call(e))}function y1(e,n){if(!(n.state.loading&4)){var l=Hs.get(e);if(l)var o=l.get(null);else{l=new Map,Hs.set(e,l);for(var f=e.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g<f.length;g++){var w=f[g];(w.nodeName==="LINK"||w.getAttribute("media")!=="not all")&&(l.set(w.dataset.precedence,w),o=w)}o&&l.set(null,o)}f=n.instance,w=f.getAttribute("data-precedence"),g=l.get(w)||o,g===o&&l.set(null,f),l.set(w,f),this.count++,o=qs.bind(this),f.addEventListener("load",o),f.addEventListener("error",o),g?g.parentNode.insertBefore(f,g.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(f,e.firstChild)),n.state.loading|=4}}var ca={$$typeof:D,Provider:null,Consumer:null,_currentValue:Q,_currentValue2:Q,_threadCount:0};function b1(e,n,l,o,f,g,w,z,$){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=qe(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=qe(0),this.hiddenUpdates=qe(null),this.identifierPrefix=o,this.onUncaughtError=f,this.onCaughtError=g,this.onRecoverableError=w,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=$,this.incompleteTransitions=new Map}function jg(e,n,l,o,f,g,w,z,$,se,he,me){return e=new b1(e,n,l,w,$,se,he,me,z),n=1,g===!0&&(n|=24),g=jn(3,null,null,n),e.current=g,g.stateNode=e,n=pu(),n.refCount++,e.pooledCache=n,n.refCount++,g.memoizedState={element:o,isDehydrated:l,cache:n},bu(g),e}function kg(e){return e?(e=Hr,e):Hr}function Cg(e,n,l,o,f,g){f=kg(f),o.context===null?o.context=f:o.pendingContext=f,o=Oi(n),o.payload={element:l},g=g===void 0?null:g,g!==null&&(o.callback=g),l=Li(e,o,n),l!==null&&(vn(l,e,n),Gl(l,e,n))}function Eg(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var l=e.retryLane;e.retryLane=l!==0&&l<n?l:n}}function Lc(e,n){Eg(e,n),(e=e.alternate)&&Eg(e,n)}function Ng(e){if(e.tag===13||e.tag===31){var n=ar(e,67108864);n!==null&&vn(n,e,67108864),Lc(e,67108864)}}function Tg(e){if(e.tag===13||e.tag===31){var n=Tn();n=ht(n);var l=ar(e,n);l!==null&&vn(l,e,n),Lc(e,n)}}var Vs=!0;function v1(e,n,l,o){var f=V.T;V.T=null;var g=B.p;try{B.p=2,Bc(e,n,l,o)}finally{B.p=g,V.T=f}}function x1(e,n,l,o){var f=V.T;V.T=null;var g=B.p;try{B.p=8,Bc(e,n,l,o)}finally{B.p=g,V.T=f}}function Bc(e,n,l,o){if(Vs){var f=Uc(o);if(f===null)jc(e,n,o,$s,l),Rg(e,o);else if(S1(f,e,n,l,o))o.stopPropagation();else if(Rg(e,o),n&4&&-1<w1.indexOf(e)){for(;f!==null;){var g=Rr(f);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var w=ue(g.pendingLanes);if(w!==0){var z=g;for(z.pendingLanes|=2,z.entangledLanes|=2;w;){var $=1<<31-lt(w);z.entanglements[1]|=$,w&=~$}Wn(g),(vt&6)===0&&(Es=Ie()+500,ra(0))}}break;case 31:case 13:z=ar(g,2),z!==null&&vn(z,g,2),Ts(),Lc(g,2)}if(g=Uc(o),g===null&&jc(e,n,o,$s,l),g===f)break;f=g}f!==null&&o.stopPropagation()}else jc(e,n,o,null,l)}}function Uc(e){return e=qo(e),Ic(e)}var $s=null;function Ic(e){if($s=null,e=Ar(e),e!==null){var n=d(e);if(n===null)e=null;else{var l=n.tag;if(l===13){if(e=c(n),e!==null)return e;e=null}else if(l===31){if(e=h(n),e!==null)return e;e=null}else if(l===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;e=null}else n!==e&&(e=null)}}return $s=e,null}function Ag(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(pt()){case M:return 2;case ie:return 8;case ye:case xe:return 32;case Ce:return 268435456;default:return 32}default:return 32}}var qc=!1,Fi=null,Qi=null,Xi=null,da=new Map,fa=new Map,Ki=[],w1="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Rg(e,n){switch(e){case"focusin":case"focusout":Fi=null;break;case"dragenter":case"dragleave":Qi=null;break;case"mouseover":case"mouseout":Xi=null;break;case"pointerover":case"pointerout":da.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":fa.delete(n.pointerId)}}function ha(e,n,l,o,f,g){return e===null||e.nativeEvent!==g?(e={blockedOn:n,domEventName:l,eventSystemFlags:o,nativeEvent:g,targetContainers:[f]},n!==null&&(n=Rr(n),n!==null&&Ng(n)),e):(e.eventSystemFlags|=o,n=e.targetContainers,f!==null&&n.indexOf(f)===-1&&n.push(f),e)}function S1(e,n,l,o,f){switch(n){case"focusin":return Fi=ha(Fi,e,n,l,o,f),!0;case"dragenter":return Qi=ha(Qi,e,n,l,o,f),!0;case"mouseover":return Xi=ha(Xi,e,n,l,o,f),!0;case"pointerover":var g=f.pointerId;return da.set(g,ha(da.get(g)||null,e,n,l,o,f)),!0;case"gotpointercapture":return g=f.pointerId,fa.set(g,ha(fa.get(g)||null,e,n,l,o,f)),!0}return!1}function zg(e){var n=Ar(e.target);if(n!==null){var l=d(n);if(l!==null){if(n=l.tag,n===13){if(n=c(l),n!==null){e.blockedOn=n,Gt(e.priority,function(){Tg(l)});return}}else if(n===31){if(n=h(l),n!==null){e.blockedOn=n,Gt(e.priority,function(){Tg(l)});return}}else if(n===3&&l.stateNode.current.memoizedState.isDehydrated){e.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ps(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var l=Uc(e.nativeEvent);if(l===null){l=e.nativeEvent;var o=new l.constructor(l.type,l);Io=o,l.target.dispatchEvent(o),Io=null}else return n=Rr(l),n!==null&&Ng(n),e.blockedOn=l,!1;n.shift()}return!0}function _g(e,n,l){Ps(e)&&l.delete(n)}function j1(){qc=!1,Fi!==null&&Ps(Fi)&&(Fi=null),Qi!==null&&Ps(Qi)&&(Qi=null),Xi!==null&&Ps(Xi)&&(Xi=null),da.forEach(_g),fa.forEach(_g)}function Ys(e,n){e.blockedOn===n&&(e.blockedOn=null,qc||(qc=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,j1)))}var Fs=null;function Dg(e){Fs!==e&&(Fs=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Fs===e&&(Fs=null);for(var n=0;n<e.length;n+=3){var l=e[n],o=e[n+1],f=e[n+2];if(typeof o!="function"){if(Ic(o||l)===null)continue;break}var g=Rr(l);g!==null&&(e.splice(n,3),n-=3,Uu(g,{pending:!0,data:f,method:l.method,action:o},o,f))}}))}function dl(e){function n($){return Ys($,e)}Fi!==null&&Ys(Fi,e),Qi!==null&&Ys(Qi,e),Xi!==null&&Ys(Xi,e),da.forEach(n),fa.forEach(n);for(var l=0;l<Ki.length;l++){var o=Ki[l];o.blockedOn===e&&(o.blockedOn=null)}for(;0<Ki.length&&(l=Ki[0],l.blockedOn===null);)zg(l),l.blockedOn===null&&Ki.shift();if(l=(e.ownerDocument||e).$$reactFormReplay,l!=null)for(o=0;o<l.length;o+=3){var f=l[o],g=l[o+1],w=f[nn]||null;if(typeof g=="function")w||Dg(l);else if(w){var z=null;if(g&&g.hasAttribute("formAction")){if(f=g,w=g[nn]||null)z=w.formAction;else if(Ic(f)!==null)continue}else z=w.action;typeof z=="function"?l[o+1]=z:(l.splice(o,3),o-=3),Dg(l)}}}function Mg(){function e(g){g.canIntercept&&g.info==="react-transition"&&g.intercept({handler:function(){return new Promise(function(w){return f=w})},focusReset:"manual",scroll:"manual"})}function n(){f!==null&&(f(),f=null),o||setTimeout(l,20)}function l(){if(!o&&!navigation.transition){var g=navigation.currentEntry;g&&g.url!=null&&navigation.navigate(g.url,{state:g.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var o=!1,f=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",n),navigation.addEventListener("navigateerror",n),setTimeout(l,100),function(){o=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",n),navigation.removeEventListener("navigateerror",n),f!==null&&(f(),f=null)}}}function Hc(e){this._internalRoot=e}Qs.prototype.render=Hc.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(a(409));var l=n.current,o=Tn();Cg(l,o,e,n,null,null)},Qs.prototype.unmount=Hc.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;Cg(e.current,2,null,e,null,null),Ts(),n[Qn]=null}};function Qs(e){this._internalRoot=e}Qs.prototype.unstable_scheduleHydration=function(e){if(e){var n=ai();e={blockedOn:null,target:e,priority:n};for(var l=0;l<Ki.length&&n!==0&&n<Ki[l].priority;l++);Ki.splice(l,0,e),l===0&&zg(e)}};var Og=i.version;if(Og!=="19.2.6")throw Error(a(527,Og,"19.2.6"));B.findDOMNode=function(e){var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(a(188)):(e=Object.keys(e).join(","),Error(a(268,e)));return e=m(n),e=e!==null?y(e):null,e=e===null?null:e.stateNode,e};var k1={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:V,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Xs=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Xs.isDisabled&&Xs.supportsFiber)try{wt=Xs.inject(k1),ct=Xs}catch{}}return ma.createRoot=function(e,n){if(!u(e))throw Error(a(299));var l=!1,o="",f=Gp,g=Vp,w=$p;return n!=null&&(n.unstable_strictMode===!0&&(l=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onUncaughtError!==void 0&&(f=n.onUncaughtError),n.onCaughtError!==void 0&&(g=n.onCaughtError),n.onRecoverableError!==void 0&&(w=n.onRecoverableError)),n=jg(e,1,!1,null,null,l,o,null,f,g,w,Mg),e[Qn]=n.current,Sc(e),new Hc(n)},ma.hydrateRoot=function(e,n,l){if(!u(e))throw Error(a(299));var o=!1,f="",g=Gp,w=Vp,z=$p,$=null;return l!=null&&(l.unstable_strictMode===!0&&(o=!0),l.identifierPrefix!==void 0&&(f=l.identifierPrefix),l.onUncaughtError!==void 0&&(g=l.onUncaughtError),l.onCaughtError!==void 0&&(w=l.onCaughtError),l.onRecoverableError!==void 0&&(z=l.onRecoverableError),l.formState!==void 0&&($=l.formState)),n=jg(e,1,!0,n,l??null,o,f,$,g,w,z,Mg),n.context=kg(null),l=n.current,o=Tn(),o=ht(o),f=Oi(o),f.callback=null,Li(l,f,o),l=o,n.current.lanes=l,He(n,l),Wn(n),e[Qn]=n.current,Sc(e),new Qs(n)},ma.version="19.2.6",ma}var Yg;function Z1(){if(Yg)return Pc.exports;Yg=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(i){console.error(i)}}return t(),Pc.exports=K1(),Pc.exports}var J1=Z1();const W1=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;function Hb(t){if(!t||typeof t!="object")return!1;const i=t;return i.version===1&&typeof i.id=="string"&&W1.test(i.id)&&typeof i.name=="string"&&i.name.trim().length>0&&i.name.length<=128&&!/[\u0000-\u001f\u007f]/.test(i.name)&&["desktop","hub","project-host"].includes(i.kind)&&i.entryPath===(i.kind==="desktop"?"/mobile":"/")}const bf="codeshell.environments.v1",Gb=32;function vf(t){if(t.length>2048||/[\\\u0000-\u0020\u007f]/.test(t))throw new Error("请输入完整的工作台地址。");const i=new URL(t);if(!["https:","http:"].includes(i.protocol)||i.username||i.password||i.search||i.hash)throw new Error("请使用不含密码、配对令牌或查询参数的工作台地址。");if(!["/","/mobile","/mobile/"].includes(i.pathname))throw new Error("请填写工作台首页或桌面 /mobile 地址。");return i.origin+(i.pathname.startsWith("/mobile")?"/mobile":"/")}function Vb(t){if(!t||typeof t!="object")throw new Error("无效的连接记录。");const i=t;if(typeof i.address!="string"||typeof i.name!="string"||!i.name.trim()||i.name.length>80||/[\u0000-\u001f\u007f]/.test(i.name))throw new Error("连接名称需为 1–80 个字符。");if(i.environmentId!==void 0&&!Hb({version:1,id:i.environmentId,name:"Host",kind:"hub",entryPath:"/"}))throw new Error("无效的环境身份。");return{address:vf(i.address),name:i.name.trim(),...i.environmentId?{environmentId:i.environmentId}:{}}}function yo(t){const i=t.getItem(bf);if(i===null)return[];if(i.length>1e5)throw new Error("连接记录过大,请清理当前工作台的连接记录。");const r=JSON.parse(i);if(!Array.isArray(r)||r.length>Gb)throw new Error("连接记录格式无效。");return r.map(Vb)}function Fg(t,i){const r=Vb(i),a=yo(t),u=a.find(c=>c.address===r.address);if(u?.environmentId&&r.environmentId&&u.environmentId!==r.environmentId)throw new Error("这个地址的环境身份已变化。请确认目标后,删除旧连接再添加。");const d=[...a.filter(c=>c.address!==r.address),{...r,...u?.environmentId?{environmentId:u.environmentId}:{}}];if(d.length>Gb)throw new Error("最多保存 32 个环境,请先移除不再使用的连接。");return t.setItem(bf,JSON.stringify(d)),d}function ew(t,i){const r=yo(t).filter(a=>a.address!==vf(i));return t.setItem(bf,JSON.stringify(r)),r}function tw(t,i,r){const a=t.find(u=>u.address===i+r.entryPath);if(a?.environmentId&&a.environmentId!==r.id)throw new Error("当前地址对应的环境已变化,请核对项目后重新保存连接。")}const $b=S.createContext("/api/v1/environment");function xf({discover:t=!0,navigate:i}){const r=S.useContext($b),[a,u]=S.useState(!1),[d,c]=S.useState(),[h,p]=S.useState([]),[m,y]=S.useState(""),[b,v]=S.useState(""),[x,j]=S.useState(""),R=S.useRef(null),C=S.useRef(null);S.useEffect(()=>{try{p(yo(window.localStorage))}catch{j("无法读取连接记录。当前项目仍可使用。")}},[]),S.useEffect(()=>{if(!t)return;const D=new AbortController;return Ue(r,{signal:D.signal}).then(q=>{if(!D.signal.aborted){if(!Hb(q))throw new Error("环境信息无效,请更新工作台后重试。");c(q),tw(yo(window.localStorage),window.location.origin,q)}}).catch(q=>{D.signal.aborted||q instanceof Ze&&[401,404].includes(q.status)||j(q instanceof Error?q.message:"无法读取环境信息。")}),()=>D.abort()},[t,r]),S.useEffect(()=>{a&&(R.current?.showModal(),C.current?.focus())},[a]);const A=D=>{try{p(D()),j("")}catch(q){j(q instanceof Error?q.message:"保存连接失败。")}},_=D=>{const q=vf(D);u(!1),i?i(q):window.location.assign(q)};return s.jsxs("div",{className:"environment-switcher",children:[s.jsxs("button",{type:"button",className:"ghost environment-trigger",onClick:()=>u(!0),children:[d?.name??"连接环境",s.jsx("span",{"aria-hidden":"true",children:" ▾"})]}),a?s.jsxs("dialog",{ref:R,className:"environment-dialog","aria-labelledby":"environment-title",onCancel:()=>u(!1),onClose:()=>u(!1),children:[s.jsxs("header",{children:[s.jsx("h2",{id:"environment-title",children:"电脑与云端"}),s.jsx("button",{ref:C,type:"button",className:"ghost",onClick:()=>u(!1),children:"关闭"})]}),s.jsx("p",{children:"打开目标环境后选择项目。切换入口不会移动文件或正在运行的任务。"}),s.jsxs("p",{className:"environment-location",children:["当前地址:",window.location.origin]}),x?s.jsx("p",{role:"alert",className:"form-error",children:x}):null,d?s.jsx("button",{type:"button",className:"library-button",onClick:()=>A(()=>Fg(window.localStorage,{name:d.name,address:window.location.origin+d.entryPath,environmentId:d.id})),children:"保存当前环境"}):null,s.jsx("ul",{className:"environment-list",children:h.map(D=>s.jsxs("li",{children:[s.jsxs("div",{children:[s.jsx("strong",{children:D.name}),s.jsx("small",{children:D.address})]}),s.jsx("button",{type:"button",className:"library-button",onClick:()=>_(D.address),children:"打开"}),s.jsx("button",{type:"button",className:"ghost","aria-label":`移除 ${D.name}`,onClick:()=>A(()=>ew(window.localStorage,D.address)),children:"移除"})]},D.address))}),s.jsxs("form",{onSubmit:D=>{D.preventDefault(),A(()=>Fg(window.localStorage,{name:m,address:b.trim()}))},children:[s.jsxs("label",{children:["连接名称",s.jsx("input",{required:!0,maxLength:80,value:m,onChange:D=>y(D.target.value),placeholder:"例如:家里的电脑"})]}),s.jsxs("label",{children:["工作台地址",s.jsx("input",{required:!0,type:"url",maxLength:2048,value:b,onChange:D=>v(D.target.value),placeholder:"https://example.com/"})]}),s.jsx("button",{type:"submit",className:"library-button primary",children:"添加连接"})]}),s.jsx("p",{className:"environment-hint",children:"连接记录保存在当前工作台的浏览器存储中。目标环境需要单独登录或配对,请勿保存带配对令牌的地址。未连接的环境不会显示为在线。"})]}):null]})}function nw({session:t,onClose:i,onAuthLost:r}){const[a,u]=S.useState([]),[d,c]=S.useState(""),[h,p]=S.useState("loading"),m=S.useRef(null),y=S.useCallback(x=>{x instanceof Ze&&x.status===401?r():c(x instanceof Error?x.message:"操作失败,请重试。")},[r]);S.useEffect(()=>{let x=!0;return m.current?.showModal(),Ue("/api/v1/auth/sessions").then(j=>{x&&u(j.sessions)}).catch(j=>{x&&y(j)}).finally(()=>{x&&p(null)}),()=>{x=!1}},[y]);const b=async x=>{p(x.id),c("");try{await Ue(`/api/v1/auth/sessions/${encodeURIComponent(x.id)}`,{method:"DELETE"}),x.current?r():u(j=>j.filter(R=>R.id!==x.id))}catch(j){y(j)}finally{p(null)}},v=async()=>{p("logout"),c("");try{await Pd("/api/v1/auth/logout"),r()}catch(x){y(x)}finally{p(null)}};return s.jsxs("dialog",{className:"devices-dialog",ref:m,onCancel:i,"aria-labelledby":"devices-title",children:[s.jsxs("div",{className:"dialog-head",children:[s.jsx("h2",{id:"devices-title",children:"账号与设备"}),s.jsx("button",{className:"ghost",onClick:i,"aria-label":"关闭",children:"×"})]}),s.jsxs("p",{className:"muted",children:[t?.username," · ",t?.deviceName||"当前设备"]}),d?s.jsx("p",{className:"form-error",role:"alert",children:d}):null,h==="loading"?s.jsx("p",{role:"status",children:"正在读取设备…"}):null,s.jsx("ul",{className:"device-list",children:a.map(x=>s.jsxs("li",{children:[s.jsxs("div",{children:[s.jsxs("strong",{children:[x.deviceName||"未命名设备",x.current?"(当前)":""]}),s.jsxs("span",{children:["最近活动 ",new Date(x.lastSeenAt).toLocaleString()]})]}),s.jsx("button",{className:"ghost",disabled:h!==null,onClick:()=>{b(x)},children:h===x.id?"处理中…":"撤销登录"})]},x.id))}),s.jsx("button",{className:"stop",disabled:h!==null,onClick:()=>{v()},children:"退出当前设备"})]})}function iw(t){if(!(!t||t.length>2048))try{const i=new URL(t);return i.origin!==t||i.username||i.password||i.pathname!=="/"||i.search||i.hash||i.protocol!=="https:"&&!(i.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(i.hostname))?void 0:`${i.origin}/api/v1/account/manage`}catch{return}}function Pb({pending:t,error:i,onLogout:r,accountOrigin:a}){const u=iw(a);return s.jsxs("div",{className:"cloud-account-controls",children:[s.jsx("span",{children:"Cloud 工作台"}),u?s.jsx("a",{className:"library-button",href:u,target:"_blank",rel:"noopener noreferrer",children:"账号资料"}):s.jsx("button",{className:"library-button",disabled:!0,title:"此工作台尚未提供账号服务地址",children:"账号资料"}),s.jsx("button",{className:"library-button",disabled:t,onClick:r,children:t?"正在退出…":"退出此 Cloud 工作台"}),i?s.jsx("p",{className:"form-error",role:"alert",children:i}):null]})}function Xc(t){return{expectedRevision:t?t.revision:null,id:t?.id??"",catalogId:t?.catalogId??"",model:t?.model??"",baseUrl:t?.baseUrl??"",apiKey:""}}function rw(t){const i={id:t.id.trim(),catalogId:t.catalogId,model:t.model.trim(),baseUrl:t.baseUrl.trim()};return t.expectedRevision!==void 0&&(i.expectedRevision=t.expectedRevision),t.apiKey.trim()&&(i.apiKey=t.apiKey.trim()),i}function wf(t){if(!t||typeof t.workspace?.path!="string"||!t.defaults||!Array.isArray(t.connections)||!Array.isArray(t.catalog)||!Array.isArray(t.skills)||!Array.isArray(t.mcpServers)||!Array.isArray(t.workspace.skillDirectories))throw new Error("服务端返回了无效的设置,请刷新后重试。");return t}async function Yb(t){return wf(await Ue("/api/v1/configuration",{signal:t}))}async function Sf(t,i,r){return wf(await Ue(`/api/v1/configuration/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i),signal:r}))}function lw(t,i){return Sf("connections",rw(t),i)}function aw(t,i){return Sf("defaults",t,i)}function sw(t,i,r){return Sf("skills",{name:t,enabled:i},r)}function Fb(t){const i=t instanceof Error?t.message:"设置更新失败,请重试。",r={"provide an API key when changing the endpoint origin":"更换服务地址时,请同时填写该服务使用的 API Key。现有密钥不会自动发送到新的服务地址。","baseUrl must be an HTTP(S) URL without credentials, query or fragment":"请填写 HTTP 或 HTTPS 服务地址,不要在地址中包含账号、密码、查询参数或片段。","enable the owning plugin on the server first":"请先在服务器上启用这个 Skill 所属的插件。","select an existing text connection":"这个模型连接已不可用,请刷新后重新选择。","configuration request failed":"配置操作未完成,请刷新设置确认当前状态后重试。","too many model connections":"模型连接数量已达上限,请先删除不用的连接。","skill not found":"这个 Skill 已不在服务器上,请刷新列表。","unknown text provider":"这个模型服务商不可用,请刷新设置后重新选择。","existing connection provider cannot be changed":"已有连接的服务商不能直接更换,请创建新连接。"};return r[i]?r[i]:/^(id|catalogId|model|text|auxText|apiKey) is invalid$/.exec(i)?"配置字段无效,请检查名称、模型与密钥后重试。":i}async function ow(t,i,r,a){return wf(await Ue("/api/v1/configuration/connections",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,...i?{replacementText:i}:{},...a?{expectedRevision:a}:{}}),signal:r}))}async function uw(t,i){const r=Da(),a=kt("/api/v1/configuration/connections/probe"),u=kt("/api/v1/configuration/connections/probe/cancel");let d;try{d=await Ue(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,requestId:r}),signal:i})}catch(c){throw i?.aborted&&await Ue(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:r}),signal:AbortSignal.timeout(2e3)}).catch(()=>{}),c}if(!d||d.connectionId!==t||typeof d.ok!="boolean"||typeof d.message!="string"||typeof d.code!="string"||!Number.isFinite(d.latencyMs))throw new Error("服务端返回了无效的测试结果,请重试。");return d}const jf="/api/v1/skills";async function Qg(t){const i=await Ue(jf,{signal:t});if(!i||!Array.isArray(i.skills)||!Array.isArray(i.directories))throw new Error("Skills 列表读取失败,请刷新重试。");return i}async function cw(t,i){const r=await Ue(`${jf}/detail?name=${encodeURIComponent(t)}`,{signal:i});if(r.name!==t||typeof r.content!="string"||typeof r.revision!="string")throw new Error("Skill 内容读取失败,请重试。");return r}function Cr(t,i,r,a){return Ue(`${jf}${t}`,{method:i,headers:{"Content-Type":"application/json"},body:JSON.stringify(r),signal:a})}const dw=(t,i,r)=>Cr("/local","POST",{name:t,content:i},r),fw=(t,i,r,a)=>Cr("/local","PUT",{name:t,content:i,revision:r},a),hw=(t,i,r)=>Cr("/local","DELETE",{name:t,revision:i},r),pw=(t,i)=>Cr("/github/preview","POST",{url:t.trim()},i),mw=(t,i,r,a)=>Cr("/github/install","POST",{reviewToken:t,pathInRepo:i,name:r.trim()},a),gw=(t,i,r)=>Cr("/github/update-preview","POST",{name:t,revision:i},r),yw=(t,i)=>Cr("/github/update","POST",{reviewToken:t},i);function Ws(t){return`---
10
- name: ${t||"my-skill"}
11
- description: 描述这个 Skill 适合处理什么任务
12
- ---
13
-
14
- # 工作方式
15
-
16
- 在这里写下具体步骤、输入要求和完成标准。
17
- `}function Qd(t){return/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(t)&&!t.includes("..")}function bw(t,i,r){const a=i.trim().toLocaleLowerCase();return t.filter(u=>(r==="all"||u.source===r)&&(!a||`${u.name} ${u.description}`.toLocaleLowerCase().includes(a)))}const Xg={project:"工作区",user:"用户级",plugin:"插件","panel-app":"Panel App"};function vw({onAuthLost:t,onChanged:i,onDirtyChange:r,configurationVersion:a=0}){const[u,d]=S.useState(null),[c,h]=S.useState(null),[p,m]=S.useState(""),[y,b]=S.useState("all"),[v,x]=S.useState(""),[j,R]=S.useState(""),[C,A]=S.useState(""),[_,D]=S.useState(0),[q,ae]=S.useState(!1),[N,U]=S.useState(!1),X=S.useRef(null),H=S.useRef(null),T=S.useRef(!1),I=S.useRef({onAuthLost:t,onChanged:i});I.current={onAuthLost:t,onChanged:i};const L=S.useRef(null),F=S.useRef(null),W=S.useCallback(k=>{k instanceof Ze&&k.status===401?I.current.onAuthLost():R(k instanceof Error?k.message:"操作失败,请重试。")},[]);S.useEffect(()=>()=>{X.current?.abort(),H.current?.abort()},[]),S.useEffect(()=>{if(X.current){T.current=!0;return}const k=new AbortController;return H.current=k,Qg(k.signal).then(O=>{k.signal.aborted||d(O)}).catch(O=>{k.signal.aborted||W(O)}),()=>k.abort()},[_,a,W]),S.useEffect(()=>{c&&L.current?.focus()},[c?.kind]);const ee=k=>{F.current=document.activeElement,R(""),A(""),ae(!1),U(!1),h(k)},V=()=>{h(null),ae(!1),U(!1),R(""),F.current?.focus()},B=()=>{if(!X.current){if(q){U(!0);return}V()}},Q=async(k,O,re=!1)=>{if(X.current)return;H.current?.abort();const E=new AbortController;X.current=E,x(k),R(""),A("");try{const J=await O(E.signal);if(E.signal.aborted)return;if(re){try{const be=await Qg(E.signal);E.signal.aborted||d(be)}catch(be){if(be instanceof Ze&&be.status===401)throw be;E.signal.aborted||R("操作已完成,但列表刷新失败。请点击刷新查看最新状态。")}if(E.signal.aborted)return;A(J.message||"设置已保存,下次任务生效。"),I.current.onChanged?.()}return J}catch(J){E.signal.aborted||W(J);return}finally{X.current===E&&(X.current=null),E.signal.aborted||(x(""),T.current&&(T.current=!1,D(J=>J+1)))}};S.useEffect(()=>(r?.(q||!!v),()=>r?.(!1)),[q,v,r]);const fe=bw(u?.skills??[],p,y);return s.jsxs("section",{className:"hub-skills","aria-labelledby":"skills-title",onKeyDown:k=>{k.key==="Escape"&&c&&!v&&(k.preventDefault(),B())},children:[s.jsxs("header",{className:"skills-heading",children:[s.jsxs("div",{children:[s.jsx("span",{className:"skills-eyebrow",children:"工作区能力"}),s.jsx("h1",{id:"skills-title",children:"Skills"}),s.jsx("p",{children:"创建工作说明,导入社区技能,把常用流程留在工作区。"})]}),s.jsxs("div",{className:"skills-actions",children:[s.jsx("button",{className:"config-button",disabled:!!v||!!c,onClick:()=>ee({kind:"import"}),children:"从 GitHub 导入"}),s.jsx("button",{className:"config-button config-button-primary",disabled:!!v||!!c,onClick:()=>ee({kind:"create"}),children:"+ 创建 Skill"})]})]}),j&&s.jsx("div",{className:"config-message config-error",role:"alert",children:j}),C&&s.jsx("div",{className:"config-message config-success",role:"status",children:C}),v&&s.jsxs("p",{className:"skills-progress",role:"status",children:[v,"…"]}),c&&s.jsxs("section",{className:"skills-workspace-panel","aria-labelledby":"skills-panel-title",children:[s.jsxs("header",{children:[s.jsx("h2",{id:"skills-panel-title",ref:L,tabIndex:-1,children:c.kind==="create"?"创建 Skill":c.kind==="detail"?c.detail.editable?`编辑 ${c.detail.name}`:c.detail.name:c.kind==="import"?"从 GitHub 导入":c.kind==="update"?`更新 ${c.preview.name}`:`移除 ${c.skill.name}`}),s.jsx("button",{className:"config-button config-button-quiet",disabled:!!v,onClick:B,children:"关闭"})]}),N&&s.jsxs("div",{className:"skills-discard-confirm",role:"alert",children:[s.jsx("p",{children:"还有未保存的修改。关闭会丢弃这些修改。"}),s.jsxs("div",{className:"skills-actions",children:[s.jsx("button",{className:"config-button",onClick:()=>U(!1),children:"继续编辑"}),s.jsx("button",{className:"config-button skills-danger",onClick:V,children:"放弃修改并关闭"})]})]}),(c.kind==="create"||c.kind==="detail")&&s.jsx(xw,{detail:c.kind==="detail"?c.detail:void 0,busy:!!v,run:Q,onSaved:V,onDirtyChange:ae},c.kind==="detail"?c.detail.name+c.detail.revision:"create"),c.kind==="import"&&s.jsx(ww,{preview:c.preview,busy:!!v,run:Q,onPreview:k=>h({kind:"import",preview:k}),onInstalled:V},c.preview?.reviewToken??"url"),c.kind==="update"&&s.jsx(Sw,{preview:c.preview,busy:!!v,run:Q,onUpdated:V}),c.kind==="remove"&&s.jsxs("div",{className:"skills-remove-confirm",children:[s.jsxs("p",{children:["确认从当前工作区移除 ",s.jsx("strong",{children:c.skill.name}),"?它的 SKILL.md、脚本和资源文件都会移除。"]}),s.jsx("p",{className:"config-help",children:"已保存的对话会保留。其他设备下一次运行任务时将不再使用这个工作区 Skill。"}),s.jsxs("div",{className:"skills-actions",children:[s.jsx("button",{className:"config-button",disabled:!!v,onClick:B,children:"取消"}),s.jsx("button",{className:"config-button skills-danger",disabled:!!v,onClick:()=>{Q("正在移除 Skill",k=>hw(c.skill.name,c.skill.revision,k),!0).then(k=>{k&&V()})},children:"确认移除"})]})]})]}),s.jsxs("div",{className:"skills-filter",children:[s.jsxs("label",{children:[s.jsx("span",{className:"config-sr-only",children:"搜索 Skills"}),s.jsx("input",{type:"search","aria-label":"搜索 Skills",value:p,onChange:k=>m(k.target.value),placeholder:"搜索名称或用途…"})]}),s.jsxs("select",{"aria-label":"Skill 来源",value:y,onChange:k=>b(k.target.value),children:[s.jsx("option",{value:"all",children:"全部来源"}),Object.entries(Xg).map(([k,O])=>s.jsx("option",{value:k,children:O},k))]}),s.jsx("button",{className:"config-button config-button-quiet",disabled:!!v,onClick:()=>{R(""),D(k=>k+1)},children:"刷新"})]}),!u&&!j?s.jsx("p",{className:"config-help",children:"正在读取 Skills…"}):u?s.jsxs("p",{className:"skills-count",children:[fe.length===u.skills.length?`${fe.length} 个 Skill`:`显示 ${fe.length} / ${u.skills.length} 个 Skill`," · ",u.skills.filter(k=>k.enabled).length," 个已启用"]}):null,u&&!fe.length&&s.jsxs("div",{className:"skills-empty",children:[s.jsx("h2",{children:p||y!=="all"?"没有匹配的 Skills":"从一个常用流程开始"}),s.jsx("p",{children:p||y!=="all"?"调整搜索词或来源筛选。":"创建自己的 Skill,或粘贴 GitHub 地址导入完整的社区技能。"})]}),s.jsx("div",{className:"skills-list",children:fe.map(k=>s.jsxs("article",{className:"skills-card",children:[s.jsxs("div",{className:"skills-card-heading",children:[s.jsxs("div",{children:[s.jsx("h2",{children:k.name}),s.jsx("span",{className:"config-badge",children:Xg[k.source]}),k.origin&&s.jsx("span",{className:"config-badge",children:"GitHub"})]}),s.jsx("button",{className:"config-switch",role:"switch","aria-checked":k.enabled,"aria-label":`${k.enabled?"停用":"启用"} ${k.name}`,disabled:!!v||!!k.disabledReason,title:k.disabledReason,onClick:()=>{Q("正在更新 Skill",async O=>(await sw(k.name,!k.enabled,O),{ok:!0,name:k.name,message:k.enabled?"Skill 已停用,下次任务生效。":"Skill 已启用,下次任务生效。"}),!0)},children:s.jsx("span",{})})]}),s.jsx("p",{children:k.description||"暂未填写用途描述。"}),k.origin&&s.jsxs("p",{className:"skills-source",children:[k.origin.url.replace("https://github.com/","")," · ",k.origin.ref," ·"," ",k.origin.commit.slice(0,8)]}),k.readOnlyReason&&s.jsx("p",{className:"config-help",children:k.readOnlyReason}),k.disabledReason&&s.jsx("p",{className:"config-help",children:k.disabledReason}),s.jsxs("footer",{className:"skills-actions",children:[s.jsx("button",{className:"config-button config-button-quiet",disabled:!!v||!!c,onClick:()=>{F.current=document.activeElement,Q("正在读取 Skill",O=>cw(k.name,O)).then(O=>{O&&ee({kind:"detail",detail:O})})},children:k.editable?"查看与编辑":"查看说明"}),k.editable&&k.origin&&s.jsx("button",{className:"config-button config-button-quiet",disabled:!!v||!!c,onClick:()=>{Q("正在检查来源更新",O=>gw(k.name,k.revision,O)).then(O=>{O?.changed?ee({kind:"update",preview:O}):O&&A(`${k.name} 已是最新版本。`)})},children:"检查更新"}),k.removable&&s.jsx("button",{className:"config-button config-button-quiet skills-remove",disabled:!!v||!!c,onClick:()=>ee({kind:"remove",skill:k}),children:"移除"})]})]},k.name))}),u&&s.jsxs("details",{className:"skills-directories",children:[s.jsx("summary",{children:"Skills 存在哪里"}),s.jsx("p",{children:"这里管理当前工作区。用户级、插件和 Panel App 的 Skills 可以查看和启停,安装内容由各自来源管理。"}),s.jsx("ul",{children:u.directories.map(k=>s.jsx("li",{children:s.jsx("code",{children:k})},k))})]})]})}function xw({detail:t,busy:i,run:r,onSaved:a,onDirtyChange:u}){const[d,c]=S.useState(t?.name??"my-skill"),[h,p]=S.useState(t?.content??Ws("my-skill")),m=h!==t?.content,y=!t||t.editable;return S.useEffect(()=>{u(y&&(t?h!==t.content:d!=="my-skill"||h!==Ws("my-skill")))},[h,d,t,y,u]),s.jsx("form",{className:"skills-editor",onSubmit:b=>{b.preventDefault(),r(t?"正在保存 Skill":"正在创建 Skill",v=>t?fw(t.name,h,t.revision,v):dw(d.trim(),h,v),!0).then(v=>{v&&a()})},children:s.jsxs("fieldset",{disabled:i,children:[!t&&s.jsxs("label",{children:[s.jsx("span",{children:"名称"}),s.jsx("input",{required:!0,value:d,maxLength:128,onChange:b=>{const v=b.target.value;h===Ws(d)&&p(Ws(v)),c(v)},"aria-describedby":"skill-name-help","aria-label":"Skill 名称"}),s.jsx("small",{id:"skill-name-help",children:"字母、数字、短横线、下划线或点;创建后名称保持不变。"}),!Qd(d)&&s.jsx("span",{className:"skills-field-error",children:"请输入有效名称。"})]}),s.jsxs("label",{children:[s.jsxs("span",{children:[y?"SKILL.md":"说明",t&&y&&m&&s.jsx("small",{className:"skills-unsaved",children:"未保存"})]}),s.jsx("textarea",{value:h,readOnly:!y,onChange:b=>p(b.target.value),rows:18,spellCheck:!1,"aria-label":"SKILL.md 内容"})]}),t?.origin&&y&&s.jsx("p",{className:"config-help",children:"手动编辑会保留 GitHub 来源;以后更新来源时,会预览将替换的完整内容。"}),y&&s.jsxs("div",{className:"skills-actions",children:[s.jsx("span",{className:"config-help",children:"支持 Markdown 和 YAML Frontmatter。变更在下一次任务中生效。"}),s.jsx("button",{className:"config-button config-button-primary",type:"submit",disabled:!h.trim()||!t&&!Qd(d)||!!t&&!m,children:t?"保存修改":"创建 Skill"})]})]})})}function ww({preview:t,busy:i,run:r,onPreview:a,onInstalled:u}){const[d,c]=S.useState(""),[h,p]=S.useState(t?.skills[0]?.pathInRepo??""),[m,y]=S.useState(t?.skills[0]?.name??"");return t?s.jsxs("form",{className:"skills-import-preview",onSubmit:b=>{b.preventDefault(),r("正在导入 Skill 与资源",v=>mw(t.reviewToken,h,m,v),!0).then(v=>{v&&u()})},children:[s.jsxs("p",{children:[s.jsx("a",{href:t.repoUrl,target:"_blank",rel:"noreferrer",children:t.repoUrl.replace("https://github.com/","")})," ",s.jsx("span",{className:"config-badge",children:t.commit.slice(0,8)})]}),t.warning&&s.jsx("p",{className:"config-help",children:t.warning}),s.jsxs("fieldset",{disabled:i,children:[s.jsx("legend",{children:"选择一个 Skill"}),s.jsx("div",{className:"skills-source-choices",children:t.skills.map(b=>s.jsxs("label",{children:[s.jsx("input",{type:"radio",name:"github-skill",checked:h===b.pathInRepo,onChange:()=>{p(b.pathInRepo),y(b.name)}}),s.jsxs("span",{children:[s.jsx("strong",{children:b.name}),s.jsx("small",{children:b.description||b.pathInRepo}),b.alreadyInstalled&&s.jsx("small",{children:"已有同名 Skill,可修改安装名称。"})]})]},b.pathInRepo))}),!!t.skills.length&&s.jsxs(s.Fragment,{children:[s.jsxs("label",{children:[s.jsx("span",{children:"安装到工作区时使用的名称"}),s.jsx("input",{required:!0,maxLength:128,value:m,onChange:b=>y(b.target.value)})]}),s.jsx("p",{className:"config-help",children:"将导入预览时的确定版本。不会执行其中的脚本。"}),s.jsx("button",{className:"config-button config-button-primary",disabled:!h||!Qd(m),type:"submit",children:"确认导入到工作区"})]})]})]}):s.jsxs("form",{className:"skills-import-url",onSubmit:b=>{b.preventDefault(),r("正在检查 GitHub 来源",v=>pw(d,v)).then(v=>{v&&a(v)})},children:[s.jsxs("label",{children:[s.jsx("span",{children:"GitHub 仓库或 Skill 目录地址"}),s.jsx("input",{type:"url",required:!0,value:d,onChange:b=>c(b.target.value),placeholder:"https://github.com/owner/repository/tree/main/skills/example",disabled:i})]}),s.jsx("p",{className:"config-help",children:"先查看可导入的技能,再确认安装。脚本和资源文件会一起保留。"}),s.jsx("button",{className:"config-button config-button-primary",disabled:i||!d.trim(),children:"预览来源"})]})}function Sw({preview:t,busy:i,run:r,onUpdated:a}){return s.jsxs("div",{className:"skills-update-preview",children:[s.jsxs("p",{children:["来源版本 ",s.jsx("code",{children:t.currentCommit.slice(0,8)})," →"," ",s.jsx("code",{children:t.latestCommit.slice(0,8)})]}),s.jsx("p",{children:"确认后会用下方版本替换此 Skill 的说明、脚本和资源,包括你在其中做过的本地修改。"}),s.jsxs("details",{children:[s.jsxs("summary",{children:["查看将导入的 ",t.files?.length??0," 个文件"]}),s.jsx("ul",{children:t.files?.map(u=>s.jsxs("li",{children:[s.jsx("code",{children:u.path}),s.jsxs("span",{children:[Math.ceil(u.size/1024)," KB",u.executable?" · 可执行脚本":""]})]},u.path))})]}),s.jsxs("label",{children:[s.jsx("span",{children:"新的 SKILL.md"}),s.jsx("textarea",{value:t.content??"",readOnly:!0,rows:16,"aria-label":"更新后的 SKILL.md"})]}),s.jsx("button",{className:"config-button config-button-primary",disabled:i||!t.reviewToken,onClick:()=>{r("正在更新 Skill",u=>yw(t.reviewToken,u),!0).then(u=>{u&&a()})},children:"确认更新到预览版本"})]})}function jw(t){const i=r=>r.map((a,u)=>({id:`stored-${u}`,name:a,value:"",stored:!0,removed:!1}));return{name:t?.name??"",transport:t?.transport??"stdio",command:t?.command??"",args:"",clearArgs:!1,url:t?.url??"",env:i(t?.envKeys??[]),headers:i(t?.headerKeys??[]),envHeaders:Object.entries(t?.envHeaders??{}).map(([r,a],u)=>({id:`stored-${u}`,name:r,value:a,initialValue:a,stored:!0,removed:!1})),envVars:(t?.envVars??[]).join(`
18
- `),bearerTokenEnvVar:t?.bearerTokenEnvVar??"",credentialRef:t?.credentialRef??"",enabled:t?.enabled??!0,restrictTools:t?.allowedTools!==void 0,allowedTools:(t?.allowedTools??[]).join(`
19
- `),disabledTools:(t?.disabledTools??[]).join(`
20
- `),reuseStoredSecrets:!1}}function Kc(t){return t.split(/\r?\n/).map(i=>i.trim()).filter(Boolean)}function kw(t,i){const r={},a=new Set;for(const u of t){if(!u.stored&&u.removed)continue;const d=u.name.trim();if(["__proto__","prototype","constructor"].includes(d))throw new Error(`${i}名称无效。`);if(!d&&!u.value&&!u.stored)continue;if(!d||!u.stored&&!u.value)throw new Error(`请完整填写${i}的名称和值,或移除空行。`);const c=i==="环境变量"?d:d.toLowerCase();if(a.has(c))throw new Error(`${i}名称不能重复。`);a.add(c),u.removed?r[d]=null:u.value&&u.value!==u.initialValue&&(r[d]=u.value)}return r}function Kg(t){try{return new URL(t).origin}catch{return""}}function Cw(t,i){if(!i)return!1;const r=i.envKeys.length||i.headerKeys.length||i.envVars.length||Object.keys(i.envHeaders).length||i.credentialRef||i.bearerTokenEnvVar||i.argsCount,a=t.transport!==i.transport||(t.transport==="stdio"?t.command.trim()!==i.command||!!t.args.trim()||t.clearArgs:Kg(t.url)!==Kg(i.url??""));return!!r&&a}function Ew(t,i){const r={name:t.name.trim()};(!i||t.transport!==i.transport)&&(r.transport=t.transport),(!i||t.enabled!==i.enabled)&&(r.enabled=t.enabled),t.transport==="stdio"?((!i||t.command.trim()!==i.command)&&(r.command=t.command.trim()),t.clearArgs?r.args=[]:t.args.trim()&&(r.args=t.args.split(/\r?\n/).filter(c=>c.length>0))):(!i||t.url.trim()!==i.url)&&(r.url=t.url.trim());for(const[c,h]of[["env","环境变量"],["headers","请求头"],["envHeaders","环境变量请求头"]]){const p=kw(t[c],h);Object.keys(p).length&&(r[c]=p)}const a=Kc(t.envVars);(!i||JSON.stringify(a)!==JSON.stringify(i.envVars))&&(r.envVars=a);for(const c of["bearerTokenEnvVar","credentialRef"])(!i||t[c].trim()!==(i[c]??""))&&(r[c]=t[c].trim()||null);const u=t.restrictTools?Kc(t.allowedTools):void 0;(!i||JSON.stringify(u)!==JSON.stringify(i.allowedTools))&&(r.allowedTools=u??null);const d=Kc(t.disabledTools);return(!i||JSON.stringify(d)!==JSON.stringify(i.disabledTools))&&(r.disabledTools=d),t.reuseStoredSecrets&&(r.reuseStoredSecrets=!0),r}function Qb(t){if(!t||typeof t.workspacePath!="string"||!Array.isArray(t.servers)||!Array.isArray(t.removed))throw new Error("服务端返回了无效的 MCP 配置,请刷新重试。");return t}const Sl=(t,i="")=>`/api/v1/mcp/servers/${encodeURIComponent(t)}${i}`;async function Nw(t){return Qb(await Ue("/api/v1/mcp",{signal:t}))}async function Eo(t,i,r,a){return Qb(await Ue(t,{method:i,headers:{"Content-Type":"application/json"},...r===void 0?{}:{body:JSON.stringify(r)},signal:a}))}function Tw(t,i,r){return Eo(i?Sl(i.name):"/api/v1/mcp/servers",i?"PUT":"POST",Ew(t,i),r)}function Aw(t,i,r){return Eo(Sl(t,"/enabled"),"PUT",{enabled:i},r)}function Rw(t,i){return Eo(Sl(t),"DELETE",void 0,i)}function Zg(t,i){return Eo(Sl(t,"/inherit"),"POST",{},i)}async function zw(t,i){const r=await Ue(Sl(t,"/probe"),{method:"POST",headers:{"Content-Type":"application/json"},body:"{}",signal:i});if(r.name!==t||!["ok","error","cancelled"].includes(r.status))throw new Error("服务端返回了无效的连接测试结果。");return r}function Jg(t,i,r){return Ue(kt(Sl(t,"/cancel-probe"),i,r),{method:"POST",headers:{"Content-Type":"application/json"},body:"{}",keepalive:!0})}const _w={local:"工作区本地",project:"工作区配置",user:"用户级",managed:"启动配置",plugin:"插件提供"};function Dw({onAuthLost:t,onConfigurationChange:i,configurationVersion:r=0,onDirtyChange:a}){const[u,d]=S.useState(null),[c,h]=S.useState(!0),[p,m]=S.useState(!1),[y,b]=S.useState(!1),[v,x]=S.useState(""),[j,R]=S.useState(""),[C,A]=S.useState(null),[_,D]=S.useState(null),[q,ae]=S.useState(""),[N,U]=S.useState({}),[X,H]=S.useState(null),[T,I]=S.useState(0),L=S.useRef({onAuthLost:t,onConfigurationChange:i,onDirtyChange:a});L.current={onAuthLost:t,onConfigurationChange:i,onDirtyChange:a};const F=S.useRef(!1),W=S.useRef(null),ee=S.useRef(null),V=S.useRef(null),B=S.useRef(0),Q=S.useRef(!1),fe=S.useRef(r);S.useEffect(()=>{L.current.onDirtyChange?.(y||p)},[y,p]);const k=S.useCallback(P=>{P instanceof Ze&&P.status===401?L.current.onAuthLost():x(P instanceof Error?P.message:"MCP 操作失败,请重试。")},[]);S.useEffect(()=>(F.current=!0,()=>{F.current=!1,L.current.onDirtyChange?.(!1),ee.current?.abort();const P=V.current;P&&(P.controller.abort(),Jg(P.name,P.workspace,P.projectId).catch(()=>{}))}),[]),S.useEffect(()=>{fe.current!==r&&(fe.current=r,ee.current?Q.current=!0:I(P=>P+1))},[r]),S.useEffect(()=>{const P=new AbortController;W.current=P;const ve=Date.now(),De=++B.current;return h(!0),x(""),Nw(P.signal).then(ze=>{!P.signal.aborted&&De===B.current&&(d(ze),U(_e=>Object.fromEntries(Object.entries(_e).filter(([,Ge])=>Date.parse(Ge.checkedAt)>=ve))))}).catch(ze=>{!P.signal.aborted&&De===B.current&&k(ze)}).finally(()=>{!P.signal.aborted&&De===B.current&&h(!1)}),()=>P.abort()},[T,k]);const O=async(P,ve="MCP 设置已保存,任务进程会加载新的配置。")=>{if(ee.current||V.current)return!1;W.current?.abort();const De=++B.current,ze=new AbortController;ee.current=ze,m(!0),h(!1),x(""),R("");try{const _e=await P(ze.signal);return!F.current||ze.signal.aborted||De!==B.current?!1:(d(_e),U({}),R(ve),L.current.onConfigurationChange?.(),!0)}catch(_e){return F.current&&!ze.signal.aborted&&k(_e),!1}finally{ee.current===ze&&(ee.current=null),F.current&&!ze.signal.aborted&&(m(!1),Q.current&&(Q.current=!1,I(_e=>_e+1)))}},re=async P=>{if(V.current||ee.current)return;const ve=new AbortController;V.current={name:P,controller:ve,workspace:go()??"",projectId:Ta()},H(P),x(""),R(""),U(De=>{const ze={...De};return delete ze[P],ze});try{const De=await zw(P,ve.signal);F.current&&!ve.signal.aborted&&U(ze=>({...ze,[P]:De}))}catch(De){F.current&&!ve.signal.aborted&&k(De)}finally{V.current?.controller===ve&&(V.current=null),F.current&&H(null)}},E=async()=>{const P=V.current;if(P)try{await Jg(P.name,P.workspace,P.projectId)}catch(ve){F.current&&k(ve)}finally{P.controller.abort(),V.current===P&&(V.current=null),F.current&&(H(null),U(ve=>({...ve,[P.name]:{name:P.name,status:"cancelled",checkedAt:new Date().toISOString(),durationMs:0,error:{code:"cancelled",message:"测试已取消。"}}})))}},J=p||c||X!==null,be=q.trim().toLocaleLowerCase(),Z=[...u?.servers??[]];C?.kind==="edit"&&!Z.some(P=>P.name===C.name)&&Z.push(C.original);const ne=Z.filter(P=>!be||P.name.toLocaleLowerCase().includes(be)||C?.kind==="edit"&&C.name===P.name),ge=C?.kind==="edit"?Z.find(P=>P.name===C.name):void 0;return s.jsxs("div",{className:"hub-mcp",children:[s.jsxs("div",{className:"config-section-heading hub-mcp-toolbar",children:[s.jsxs("label",{className:"config-search",children:[s.jsx("span",{"aria-hidden":"true",children:"⌕"}),s.jsx("input",{type:"search",value:q,onChange:P=>ae(P.target.value),placeholder:"搜索 MCP 服务…","aria-label":"搜索 MCP 服务"})]}),s.jsxs("div",{className:"hub-mcp-toolbar-actions",children:[s.jsx("button",{className:"config-button config-button-quiet",disabled:J,onClick:()=>I(P=>P+1),children:"刷新 MCP"}),s.jsx("button",{className:"config-button",disabled:J||C!==null,onClick:()=>A({kind:"new"}),children:"+ 添加服务"})]})]}),v&&s.jsx("p",{className:"config-message config-error",role:"alert",children:v}),j&&s.jsx("p",{className:"config-message config-success",role:"status",children:j}),p&&s.jsx("p",{className:"config-help",role:"status",children:"正在保存 MCP 配置…"}),c&&!u&&s.jsx("p",{className:"config-help",role:"status",children:"正在读取 MCP 配置…"}),C?.kind==="new"&&s.jsxs("div",{className:"config-card hub-mcp-editor-card",children:[s.jsx("h2",{children:"添加 MCP 服务"}),s.jsx(Wg,{disabled:J,save:O,onDone:()=>A(null),onProbe:P=>{re(P)},onDirtyChange:b})]}),!ne.length&&u&&C?.kind!=="new"&&s.jsxs("div",{className:"config-empty",children:[s.jsx("span",{"aria-hidden":"true",children:"⌘"}),s.jsx("h3",{children:be?"没有匹配的服务":"连接你的工具与数据"}),s.jsx("p",{children:be?"试试其他服务名称。":"添加运行 CodeShell 的设备上的命令,或连接提供 MCP 接口的 HTTP 服务。"})]}),s.jsx("div",{className:"hub-mcp-list",children:ne.map(P=>s.jsxs("article",{className:"config-card hub-mcp-card",children:[s.jsxs("div",{className:"hub-mcp-card-head",children:[s.jsx("span",{className:"config-row-icon","aria-hidden":"true",children:"⌘"}),s.jsxs("div",{className:"config-row-copy",children:[s.jsx("strong",{children:P.name}),s.jsxs("span",{children:[P.transport==="stdio"?"本地命令":P.transport==="inprocess"?"内置工具":"HTTP 服务"," ","· ",_w[P.scope]]})]}),s.jsx("button",{className:"config-switch",type:"button",role:"switch","aria-checked":P.enabled,"aria-label":`${P.enabled?"停用":"启用"} MCP ${P.name}`,disabled:J||P.pluginDisabled,onClick:()=>{O(ve=>Aw(P.name,!P.enabled,ve))},children:s.jsx("span",{})})]}),C?.kind==="edit"&&C.name===P.name&&ge?s.jsx(Wg,{server:ge,disabled:J,save:O,onDone:()=>A(null),onProbe:ve=>{re(ve)},onDirtyChange:b},P.name):s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"hub-mcp-endpoint",children:[s.jsx("code",{children:P.transport==="stdio"?P.command:P.url||"由任务进程提供"}),P.argsCount>0&&s.jsxs("span",{children:[P.argsCount," 个已保存参数"]})]}),s.jsxs("div",{className:"hub-mcp-metadata",children:[s.jsx("span",{className:`config-badge${P.enabled?" config-badge-accent":""}`,children:P.enabled?"配置启用":"配置停用"}),P.envKeys.length>0&&s.jsxs("span",{children:[P.envKeys.length," 个环境变量"]}),(P.headerKeys.length>0||P.credentialRef||P.bearerTokenEnvVar||Object.keys(P.envHeaders).length>0)&&s.jsx("span",{children:"已配置认证"}),P.hasLocalOverride&&s.jsx("span",{children:"本地覆盖"})]}),P.source==="plugin"&&s.jsx("p",{className:"config-help",children:P.pluginDisabled?"所属插件已停用。启用插件后,才能启用或测试这个服务。":"连接命令与地址由插件提供,可在此启停或测试。"}),s.jsxs("div",{className:"hub-mcp-card-actions",children:[X===P.name?s.jsx("button",{className:"config-button",onClick:()=>{E()},children:"取消测试"}):s.jsx("button",{className:"config-button",disabled:J||P.pluginDisabled||P.transport==="inprocess",onClick:()=>{re(P.name)},children:"测试连接"}),P.editable&&s.jsx("button",{className:"config-button config-button-quiet",disabled:J||C!==null,onClick:()=>{D(null),A({kind:"edit",name:P.name,original:P})},children:"编辑"}),P.hasLocalOverride&&s.jsx("button",{className:"config-button config-button-quiet",disabled:J,onClick:()=>{O(ve=>Zg(P.name,ve),"已移除本地覆盖,恢复继承配置。")},children:"恢复继承"}),P.deletable&&s.jsx("button",{className:"config-button config-button-quiet hub-mcp-remove",disabled:J||C!==null,onClick:()=>D(P.name),children:"移除"})]}),_===P.name&&s.jsxs("div",{className:"hub-mcp-delete",role:"alert",children:[s.jsxs("span",{children:["从当前工作区移除 ",P.name,"?其他工作区的配置不受影响。"]}),s.jsxs("div",{children:[s.jsx("button",{className:"config-button config-button-quiet",disabled:J,onClick:()=>D(null),children:"取消"}),s.jsx("button",{className:"config-button hub-mcp-remove",disabled:J,onClick:async()=>{await O(ve=>Rw(P.name,ve),"已从当前工作区移除服务。")&&D(null)},children:"确认移除"})]})]}),X===P.name&&s.jsx("p",{className:"hub-mcp-probing",role:"status",children:"正在建立测试连接并读取工具列表…"}),N[P.name]&&s.jsx(Mw,{result:N[P.name]})]})]},P.name))}),!!u?.removed.length&&s.jsxs("details",{className:"hub-mcp-removed",children:[s.jsxs("summary",{children:["已在当前工作区移除(",u.removed.length,")"]}),u.removed.map(P=>s.jsxs("div",{className:"hub-mcp-removed-row",children:[s.jsx("span",{children:P.name}),s.jsx("button",{className:"config-button config-button-quiet",disabled:J,onClick:()=>{O(ve=>Zg(P.name,ve),"已恢复继承的 MCP 配置。")},children:"恢复继承"})]},P.name))]}),s.jsx("p",{className:"config-help hub-mcp-explanation",children:"连接使用运行 CodeShell 的设备上的网络、环境和凭据。测试只建立一次短连接并读取工具列表,完成后关闭;不会调用工具或改变启用状态。"})]})}function Wg({server:t,disabled:i,save:r,onDone:a,onProbe:u,onDirtyChange:d}){const c=S.useRef(t).current,[h,p]=S.useState(()=>jw(c)),m=S.useRef(JSON.stringify(h)).current,y=JSON.stringify(h)!==m;S.useEffect(()=>{d(y)},[y,d]),S.useEffect(()=>()=>d(!1),[d]);const[b,v]=S.useState(""),x=(C,A)=>p(_=>({..._,[C]:A})),j=Cw(h,c),R=h.transport==="stdio";return s.jsx("form",{className:"hub-mcp-editor",onSubmit:async C=>{C.preventDefault(),v("");const A=C.nativeEvent.submitter?.getAttribute("data-probe")==="true";try{await r(_=>Tw(h,c,_))&&(a(),A&&u(h.name.trim()))}catch(_){v(_ instanceof Error?_.message:"请检查填写内容。")}},children:s.jsxs("fieldset",{disabled:i,children:[s.jsx("legend",{className:"config-sr-only",children:c?`编辑 MCP ${c.name}`:"新 MCP 服务"}),s.jsxs("div",{className:"config-form-grid",children:[s.jsxs("label",{children:[s.jsx("span",{children:"服务名称"}),s.jsx("input",{required:!0,readOnly:!!c,maxLength:128,pattern:"[A-Za-z0-9][A-Za-z0-9._:\\-]*",value:h.name,onChange:C=>x("name",C.target.value),placeholder:"例如 workspace-tools"})]}),s.jsxs("label",{children:[s.jsx("span",{children:"连接方式"}),s.jsxs("select",{"aria-label":"连接方式",value:h.transport,onChange:C=>x("transport",C.target.value),children:[s.jsx("option",{value:"stdio",children:"本地命令(stdio)"}),s.jsx("option",{value:"streamable-http",children:"HTTP(Streamable HTTP)"}),c?.transport==="sse"&&s.jsx("option",{value:"sse",children:"HTTP(已有 SSE 配置)"})]})]}),R?s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"config-full-width",children:[s.jsx("span",{children:"启动命令"}),s.jsx("input",{required:!0,"aria-label":"启动命令",value:h.command,onChange:C=>x("command",C.target.value),placeholder:"例如 node、uvx 或可执行文件路径"}),s.jsx("small",{children:"在当前工作区执行。命令与参数分别填写。"})]}),s.jsxs("label",{className:"config-full-width",children:[s.jsx("span",{children:"命令参数"}),s.jsx("textarea",{"aria-label":"命令参数",rows:3,disabled:h.clearArgs,value:h.args,onChange:C=>x("args",C.target.value),placeholder:c?.argsCount?`已有 ${c.argsCount} 个参数,留空保留。填写后将完整替换。`:"每行一个参数,不需要额外添加引号",autoComplete:"off",spellCheck:!1}),s.jsx("small",{children:"参数可能含密钥,因此不会读回已有值。每一行会作为一个完整参数。"})]}),!!c?.argsCount&&s.jsxs("label",{className:"hub-mcp-check config-full-width",children:[s.jsx("input",{type:"checkbox",checked:h.clearArgs,onChange:C=>x("clearArgs",C.target.checked)}),s.jsx("span",{children:"清空已保存的所有参数"})]})]}):s.jsxs("label",{className:"config-full-width",children:[s.jsx("span",{children:"MCP 接口地址"}),s.jsx("input",{type:"url","aria-label":"MCP 接口地址",required:!0,value:h.url,onChange:C=>x("url",C.target.value),placeholder:"https://example.com/mcp"}),c?.urlHasHiddenParts&&s.jsx("small",{children:"已有地址的查询参数已隐藏;不修改地址时会保留。"})]})]}),R?s.jsx(Zc,{title:"环境变量",rows:h.env,onChange:C=>x("env",C)}):s.jsx(Zc,{title:"请求头",rows:h.headers,onChange:C=>x("headers",C)}),s.jsxs("details",{className:"hub-mcp-advanced",children:[s.jsx("summary",{children:"高级配置"}),s.jsx("div",{className:"config-form-grid",children:R?s.jsxs("label",{className:"config-full-width",children:[s.jsx("span",{children:"转发运行环境变量"}),s.jsx("textarea",{"aria-label":"转发运行环境变量",rows:2,value:h.envVars,onChange:C=>x("envVars",C.target.value),placeholder:"每行一个环境变量名称,例如 GITHUB_TOKEN"}),s.jsx("small",{children:"只填写名称,实际值在连接时从CodeShell 的启动环境读取。"})]}):s.jsxs(s.Fragment,{children:[s.jsxs("label",{children:[s.jsx("span",{children:"Bearer Token 环境变量"}),s.jsx("input",{"aria-label":"Bearer Token 环境变量",value:h.bearerTokenEnvVar,onChange:C=>x("bearerTokenEnvVar",C.target.value),placeholder:"例如 MCP_ACCESS_TOKEN",autoComplete:"off"}),s.jsx("small",{children:"填写运行环境中的变量名称。"})]}),s.jsxs("label",{children:[s.jsx("span",{children:"已存储的凭据 ID"}),s.jsx("input",{"aria-label":"已存储的凭据 ID",value:h.credentialRef,onChange:C=>x("credentialRef",C.target.value),placeholder:"可选",autoComplete:"off"}),s.jsx("small",{children:"引用已有凭据;优先于 Bearer 环境变量。"})]})]})}),!R&&s.jsx(Zc,{title:"环境变量请求头",rows:h.envHeaders,onChange:C=>x("envHeaders",C),visibleValues:!0}),s.jsxs("label",{className:"hub-mcp-check",children:[s.jsx("input",{type:"checkbox",checked:h.restrictTools,onChange:C=>x("restrictTools",C.target.checked)}),s.jsx("span",{children:"只允许指定工具"})]}),s.jsxs("div",{className:"config-form-grid",children:[h.restrictTools&&s.jsxs("label",{className:"config-full-width",children:[s.jsx("span",{children:"允许的工具名称"}),s.jsx("textarea",{rows:2,value:h.allowedTools,onChange:C=>x("allowedTools",C.target.value),placeholder:"每行一个精确工具名称;留空则不开放任何工具"})]}),s.jsxs("label",{className:"config-full-width",children:[s.jsx("span",{children:"停用的工具名称"}),s.jsx("textarea",{rows:2,value:h.disabledTools,onChange:C=>x("disabledTools",C.target.value),placeholder:"每行一个精确工具名称,可留空"})]})]})]}),s.jsxs("label",{className:"hub-mcp-check",children:[s.jsx("input",{type:"checkbox",checked:h.enabled,onChange:C=>x("enabled",C.target.checked)}),s.jsx("span",{children:"启用服务,让任务可以使用这些工具"})]}),j&&s.jsxs("label",{className:"hub-mcp-check hub-mcp-reuse",children:[s.jsx("input",{type:"checkbox",required:!0,checked:h.reuseStoredSecrets,onChange:C=>x("reuseStoredSecrets",C.target.checked)}),s.jsx("span",{children:"允许新的启动方式或服务地址使用已保存的参数、环境变量和认证配置。"})]}),b&&s.jsx("p",{className:"config-error config-message",role:"alert",children:b}),s.jsxs("div",{className:"config-form-actions",children:[s.jsx("button",{type:"button",className:"config-button config-button-quiet",onClick:a,children:"取消"}),s.jsx("button",{type:"submit","data-probe":"true",className:"config-button",children:"保存并测试"}),s.jsx("button",{type:"submit",className:"config-button config-button-primary",children:"保存配置"})]})]})})}function Zc({title:t,rows:i,onChange:r,visibleValues:a=!1}){const u=(d,c)=>r(i.map(h=>h.id===d?{...h,...c}:h));return s.jsxs("div",{className:"hub-mcp-keys",children:[s.jsxs("div",{className:"hub-mcp-key-heading",children:[s.jsx("h3",{children:t}),s.jsxs("button",{className:"config-text-button",type:"button",onClick:()=>r([...i,{id:Da(),name:"",value:"",stored:!1,removed:!1}]),children:["+ 添加",t]})]}),!i.length&&s.jsx("p",{className:"config-help",children:a?"可按请求头名称引用运行环境变量。":"无需此项时可以留空。"}),i.map(d=>s.jsxs("div",{className:`hub-mcp-key-row${d.removed?" hub-mcp-key-removed":""}`,children:[s.jsxs("label",{children:[s.jsxs("span",{className:"config-sr-only",children:[t,"名称"]}),s.jsx("input",{"aria-label":`${t}名称`,value:d.name,readOnly:d.stored,disabled:d.removed,onChange:c=>u(d.id,{name:c.target.value}),placeholder:t==="环境变量"?"例如 API_KEY":"例如 Authorization",autoComplete:"off"})]}),s.jsxs("label",{children:[s.jsxs("span",{className:"config-sr-only",children:[t,"值"]}),s.jsx("input",{"aria-label":`${t} ${d.name||"新条目"} 的值`,type:a?"text":"password",value:d.value,disabled:d.removed,onChange:c=>u(d.id,{value:c.target.value}),placeholder:d.removed?"保存时移除":a?"运行环境变量名称":d.stored?"已配置 · 留空保留":"输入值",autoComplete:a?"off":"new-password",spellCheck:!1})]}),s.jsx("button",{className:"config-button config-button-quiet",type:"button",onClick:()=>d.stored?u(d.id,{removed:!d.removed}):r(i.filter(c=>c.id!==d.id)),children:d.removed?"撤销移除":"移除"})]},d.id)),!!i.length&&!a&&s.jsx("p",{className:"config-help",children:"已有值保留在运行 CodeShell 的设备上;留空保留,填写新值替换,点击“移除”后保存才能删除。"})]})}function Mw({result:t}){return s.jsxs("div",{className:`hub-mcp-probe-result hub-mcp-probe-${t.status}`,role:"status",children:[s.jsxs("div",{className:"hub-mcp-probe-summary",children:[s.jsx("strong",{children:t.status==="ok"?"测试连接成功":t.status==="cancelled"?"测试已取消":"连接测试失败"}),s.jsxs("span",{children:[new Date(t.checkedAt).toLocaleTimeString()," ·"," ",t.durationMs<1e3?`${t.durationMs} ms`:`${(t.durationMs/1e3).toFixed(1)} 秒`]})]}),t.error&&s.jsx("p",{children:t.error.message}),t.status==="ok"&&s.jsxs(s.Fragment,{children:[s.jsxs("p",{children:["发现 ",t.toolCount??0," 个工具",t.truncated?"(列表已截取)":"","。测试连接现已关闭。"]}),!!t.tools?.length&&s.jsxs("details",{children:[s.jsx("summary",{children:"查看工具列表"}),s.jsx("ul",{children:t.tools.map((i,r)=>s.jsxs("li",{children:[s.jsxs("div",{children:[s.jsx("code",{children:i.name}),!i.allowed&&s.jsx("span",{className:"config-badge",children:"被工具策略停用"})]}),i.description&&s.jsx("p",{children:i.description})]},`${i.name}-${r}`))})]})]})]})}const Ow={overview:{title:"设置",description:"管理当前工作区的模型、Skills 和工具连接。"},models:{title:"模型与连接",description:"选择默认模型,管理工作区使用的服务商连接与凭据。"},skills:{title:"Skills",description:"让 CodeShell 按照你熟悉的工作方式完成任务。"},mcp:{title:"MCP 工具",description:"管理工具连接,测试连接并查看可用工具。"}};function Lw(t){return t.section==="skills"?s.jsx(vw,{onAuthLost:t.onAuthLost,onDirtyChange:t.onDirtyChange,onChanged:t.onConfigurationChange,configurationVersion:t.configurationVersion}):s.jsx(Bw,{...t})}function Bw({host:t="hub",section:i,onSectionChange:r,onAuthLost:a,onDirtyChange:u,onConfigurationChange:d,configurationVersion:c=0}){const[h,p]=S.useState(null),[m,y]=S.useState(!0),[b,v]=S.useState(""),[x,j]=S.useState(""),[R,C]=S.useState(null),[A,_]=S.useState(0),D=S.useRef({onAuthLost:a,onConfigurationChange:d});D.current={onAuthLost:a,onConfigurationChange:d};const q=S.useRef(!1),ae=S.useRef(0),N=S.useRef(null),U=S.useRef(null),X=S.useRef(!1),H=S.useRef(c),T=S.useCallback(F=>{F instanceof Ze&&F.status===401?D.current.onAuthLost():v(Fb(F))},[]);S.useEffect(()=>{c!==H.current&&(H.current=c,U.current?X.current=!0:_(F=>F+1))},[c]),S.useEffect(()=>(q.current=!0,()=>{q.current=!1,U.current?.abort()}),[]),S.useEffect(()=>{const F=new AbortController;N.current=F;const W=++ae.current;return y(!0),v(""),Yb(F.signal).then(ee=>{!F.signal.aborted&&W===ae.current&&p(ee)}).catch(ee=>{!F.signal.aborted&&W===ae.current&&T(ee)}).finally(()=>{!F.signal.aborted&&W===ae.current&&y(!1)}),()=>F.abort()},[A,T]);const I=async(F,W)=>{if(U.current)return!1;N.current?.abort();const ee=++ae.current,V=new AbortController;U.current=V,y(!1),C(F),v(""),j("");try{const B=await W(V.signal);return!q.current||V.signal.aborted||ee!==ae.current?!1:(p(B),j(B.restartRequired?"设置已保存,重启服务后生效。":"设置已保存,下次运行任务时生效。"),D.current.onConfigurationChange?.(),!0)}catch(B){return B instanceof Ze&&B.status===409&&(X.current=!0),q.current&&!V.signal.aborted&&T(B),!1}finally{U.current===V&&(U.current=null),q.current&&!V.signal.aborted&&(C(null),X.current&&(X.current=!1,_(B=>B+1)))}},L=Ow[i];return s.jsxs("section",{className:"hub-settings","aria-labelledby":"hub-settings-title",children:[s.jsxs("div",{className:"hub-settings-heading",children:[s.jsxs("div",{children:[s.jsx("span",{className:"hub-settings-eyebrow",children:t==="desktop"?"桌面工作区":"服务端工作区"}),s.jsx("h1",{id:"hub-settings-title",children:L.title}),s.jsx("p",{children:L.description})]}),s.jsx("button",{className:"config-button config-button-quiet",disabled:m||R!==null,onClick:()=>{j(""),_(F=>F+1)},children:m?"读取中…":"刷新"})]}),b&&s.jsx("div",{className:"config-message config-error",role:"alert",children:b}),x&&s.jsx("div",{className:"config-message config-success",role:"status",children:x}),R&&s.jsxs("p",{className:"config-loading",role:"status",children:["正在保存",R,"…"]}),!h&&m?s.jsx("p",{className:"config-loading",role:"status",children:"正在读取工作区设置…"}):null,h&&s.jsxs(s.Fragment,{children:[i==="overview"&&s.jsx(Uw,{host:t,configuration:h,onSectionChange:r}),i==="models"&&s.jsx(Iw,{configuration:h,disabled:R!==null||m,saving:R!==null,save:I,onDirtyChange:u,onAuthLost:a}),i==="mcp"&&s.jsx(Dw,{onAuthLost:a,onDirtyChange:u,onConfigurationChange:d,configurationVersion:c}),s.jsx("p",{className:"config-scope-note",children:"配置作用于当前工作区,所有连接到这里的设备共用。"})]})]})}function Uw({host:t,configuration:i,onSectionChange:r}){const a=i.connections.find(c=>c.id===i.defaults.text),u=i.skills.filter(c=>c.enabled).length,d=[{section:"models",title:"模型与连接",summary:a?`${a.id} · ${a.model}`:"尚未设置默认模型",icon:"◈"},{section:"skills",title:"Skills",summary:`${i.skills.length} 个可用 · ${u} 个已启用`,icon:"✧"},{section:"mcp",title:"MCP 工具",summary:`${i.mcpServers.length} 个已配置的工具服务`,icon:"⌘"}];return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"config-workspace-card",children:[s.jsx("span",{className:"config-workspace-icon","aria-hidden":"true",children:"▱"}),s.jsxs("div",{children:[s.jsx("strong",{children:"当前工作区"}),s.jsx("code",{children:i.workspace.path}),s.jsx("p",{children:t==="desktop"?"对话、文件操作和工具都由已连接的桌面端执行。":"对话、文件操作和工具都在服务端运行。"})]}),s.jsx("span",{className:"config-badge",children:t==="desktop"?"桌面工作区":"服务端工作区"})]}),s.jsx("h2",{className:"config-section-title",children:"工作区配置"}),s.jsx("div",{className:"config-card config-overview-list",children:d.map(c=>{const h=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"config-row-icon","aria-hidden":"true",children:c.icon}),s.jsxs("span",{className:"config-row-copy",children:[s.jsx("strong",{children:c.title}),s.jsx("span",{children:c.summary})]}),r&&s.jsx("span",{className:"config-chevron","aria-hidden":"true",children:"›"})]});return r?s.jsx("button",{className:"config-overview-row",onClick:()=>r(c.section),children:h},c.section):s.jsx("div",{className:"config-overview-row",children:h},c.section)})}),s.jsxs("div",{className:"config-explanation",children:[s.jsx("h2",{children:"工作区与执行位置"}),s.jsx("p",{children:t==="desktop"?"这里直接使用桌面端的任务、模型、Skills 和工具连接。修改配置后,桌面窗口和已配对的网页共同使用。":"这里使用服务端的任务、模型、Skills 和工具连接。修改配置后,连接到这个服务端的网页共同使用。"}),s.jsx("p",{children:t==="desktop"?"切换项目会切换对应的文件、历史和工作区设置;无需复制桌面配置。":"独立部署使用自己的运行环境。部署到另一台机器时,需要迁移配置和数据,或在这里重新设置。"})]})]})}function Iw({configuration:t,disabled:i,saving:r,save:a,onDirtyChange:u,onAuthLost:d}){const[c,h]=S.useState(null),[p,m]=S.useState(null),[y,b]=S.useState(""),[v,x]=S.useState(!1),[j,R]=S.useState(!1),[C,A]=S.useState(null),[_,D]=S.useState({}),q=S.useRef(null),ae=t.connections.filter(T=>T.tag==="text"),N=t.connections.length-ae.length,U=i||!!C;S.useEffect(()=>{p&&!t.connections.some(T=>T.id===p.id)&&m(null)},[t.connections,p]),S.useEffect(()=>()=>q.current?.abort(),[]);const X=S.useRef(new Map);S.useEffect(()=>{const T=new Map(t.connections.map(L=>[L.id,L.revision??JSON.stringify(L)])),I=new Set([...X.current].filter(([L,F])=>T.get(L)!==F).map(([L])=>L));X.current=T,C&&I.has(C)&&q.current?.abort(),I.size&&D(L=>Object.fromEntries(Object.entries(L).filter(([F])=>!I.has(F))))},[t,C]),S.useEffect(()=>(u?.(v||j||r||!!C),()=>u?.(!1)),[v,j,r,C,u]);const H=async T=>{if(q.current)return;const I=new AbortController;q.current=I,A(T.id),D(L=>({...L,[T.id]:"正在发送一条简短测试请求…"}));try{const L=await uw(T.id,I.signal);I.signal.aborted||D(F=>({...F,[T.id]:L}))}catch(L){I.signal.aborted||(L instanceof Ze&&L.status===401?d():D(F=>({...F,[T.id]:Fb(L)})))}finally{q.current===I&&(q.current=null,A(null))}};return s.jsxs(s.Fragment,{children:[s.jsx(qw,{configuration:t,disabled:U,save:a,onDirtyChange:R}),s.jsxs("div",{className:"config-section-heading",children:[s.jsxs("h2",{children:["文字模型连接 ",s.jsx("span",{className:"config-count",children:ae.length})]}),s.jsxs("button",{className:"config-button",disabled:U||c!==null||p!==null||!t.catalog.length,onClick:()=>h("__new__"),children:[s.jsx("span",{"aria-hidden":"true",children:"+"})," 添加连接"]})]}),c!==null&&s.jsxs("div",{className:"config-card config-editor-card",children:[s.jsx("h3",{children:c==="__new__"?"添加模型连接":`编辑 ${c.id}`}),s.jsx(Hw,{connection:c==="__new__"?void 0:c,configuration:t,disabled:U,save:a,onDone:()=>h(null),onDirtyChange:x},c==="__new__"?"new":c.id)]}),!ae.length&&c!=="__new__"&&s.jsx(Gw,{title:"还没有文字模型连接",description:"添加服务商地址、模型名称和 API Key,再选择一个默认模型。"}),s.jsx("div",{className:"config-connection-list",children:ae.map(T=>{const I=t.catalog.find(V=>V.id===T.catalogId),L=p?.id===T.id,F=L&&p?.revision!==T.revision,W=t.defaults.text===T.id&&ae.length>1,ee=_[T.id];return s.jsxs("article",{className:"config-card config-connection-card",children:[s.jsxs("div",{className:"config-connection-head",children:[s.jsx("span",{className:"config-model-icon","aria-hidden":"true",children:"◈"}),s.jsxs("div",{className:"config-row-copy",children:[s.jsx("strong",{children:T.id}),s.jsx("span",{children:I?.displayName??T.catalogId})]}),t.defaults.text===T.id&&s.jsx("span",{className:"config-badge config-badge-accent",children:"默认"}),s.jsx("button",{className:"config-button config-button-quiet",disabled:U||c!==null||p!==null,onClick:()=>h(T),children:"编辑"})]}),s.jsxs("dl",{className:"config-connection-facts",children:[s.jsxs("div",{children:[s.jsx("dt",{children:"模型"}),s.jsx("dd",{children:T.model||"未填写"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"服务地址"}),s.jsx("dd",{children:T.baseUrl||I?.defaultBaseUrl||"服务商默认地址"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"API Key"}),s.jsx("dd",{children:T.hasApiKey?"•••••••• · 已配置":T.needsKey?"未配置":"无需 API Key"})]})]}),s.jsxs("div",{className:"config-model-actions",children:[C===T.id?s.jsx("button",{className:"config-button",onClick:()=>{q.current?.abort(),D(V=>({...V,[T.id]:"已取消连接测试。"}))},children:"取消测试"}):s.jsx("button",{className:"config-button",disabled:U||c!==null||p!==null,onClick:()=>{H(T)},children:"测试连接"}),s.jsx("span",{className:"config-help",children:"发送一条简短请求,服务商可能计费。"}),s.jsx("button",{className:"config-button config-button-quiet config-remove-connection",disabled:U||c!==null||p!==null,onClick:()=>{m(T),b("")},children:"删除"})]}),ee&&s.jsxs("div",{className:`config-probe-result ${typeof ee!="string"&&ee.ok?"is-success":""}`,role:"status",children:[s.jsx("span",{children:typeof ee=="string"?ee:ee.message}),typeof ee!="string"&&s.jsxs("small",{children:[Math.max(.01,ee.latencyMs/1e3).toFixed(2)," 秒 ·"," ",new Date(ee.checkedAt).toLocaleTimeString()]})]}),L&&s.jsxs("div",{className:"config-remove-confirm",children:[s.jsxs("h3",{children:["删除连接 ",T.id,"?"]}),s.jsx("p",{children:"连接会从当前工作区移除,已有对话记录会保留。"}),F&&s.jsx("p",{role:"alert",children:"连接已被其他设备更新,请取消后重新检查再删除。"}),ae.length===1&&s.jsx("p",{children:"这是最后一个文字模型连接。删除后需重新添加连接才能继续对话。"}),W&&s.jsxs("label",{children:[s.jsx("span",{children:"替代默认模型"}),s.jsxs("select",{"aria-label":"替代默认模型",value:y,onChange:V=>b(V.target.value),disabled:U,children:[s.jsx("option",{value:"",children:"请选择其他连接"}),ae.filter(V=>V.id!==T.id).map(V=>s.jsxs("option",{value:V.id,children:[V.id," · ",V.model]},V.id))]})]}),s.jsxs("div",{className:"config-form-actions",children:[s.jsx("button",{className:"config-button",disabled:U,onClick:()=>m(null),children:"取消删除"}),s.jsx("button",{className:"config-button config-button-danger",disabled:U||F||W&&!y,onClick:()=>{a("删除连接",V=>ow(T.id,y||void 0,V,p?.revision)).then(V=>{V&&m(null)})},children:"确认删除连接"})]})]})]},T.id)})}),N>0&&s.jsxs("p",{className:"config-help",children:["另有 ",N," 个其他类型的模型连接,保留在工作区配置中。目前此处提供文字模型编辑。"]})]})}function qw({configuration:t,disabled:i,save:r,onDirtyChange:a}){const[u,d]=S.useState(t.defaults.text??""),[c,h]=S.useState(t.defaults.auxText??""),p=S.useRef(t.defaults);S.useEffect(()=>{const b=p.current;p.current=t.defaults,d(v=>v===(b.text??"")?t.defaults.text??"":v),h(v=>v===(b.auxText??"")?t.defaults.auxText??"":v)},[t.defaults]);const m=t.connections.filter(b=>b.tag==="text"),y=u!==(t.defaults.text??"")||c!==(t.defaults.auxText??"");return S.useEffect(()=>(a(y),()=>a(!1)),[y,a]),s.jsx("form",{className:"config-card config-defaults",onSubmit:b=>{b.preventDefault(),r("默认模型",v=>aw({text:u,auxText:c||null},v))},children:s.jsxs("fieldset",{disabled:i||!m.length,children:[s.jsx("legend",{children:"默认模型"}),s.jsxs("div",{className:"config-form-grid",children:[s.jsxs("label",{children:[s.jsx("span",{children:"对话模型"}),s.jsxs("select",{required:!0,value:u,onChange:b=>d(b.target.value),"aria-label":"默认对话模型",children:[s.jsx("option",{value:"",disabled:!0,children:"选择模型连接"}),u&&!m.some(b=>b.id===u)&&s.jsxs("option",{value:u,disabled:!0,children:[u,"(连接不可用)"]}),m.map(b=>s.jsxs("option",{value:b.id,children:[b.id," · ",b.model]},b.id))]})]}),s.jsxs("label",{children:[s.jsx("span",{children:"辅助模型"}),s.jsxs("select",{value:c,onChange:b=>h(b.target.value),"aria-label":"默认辅助模型",children:[s.jsx("option",{value:"",children:"跟随对话模型"}),c&&!m.some(b=>b.id===c)&&s.jsxs("option",{value:c,disabled:!0,children:[c,"(连接不可用)"]}),m.map(b=>s.jsxs("option",{value:b.id,children:[b.id," · ",b.model]},b.id))]})]})]}),s.jsxs("div",{className:"config-form-footer",children:[s.jsx("p",{className:"config-help",children:"辅助模型用于标题生成等轻量任务。"}),s.jsx("button",{className:"config-button",disabled:!y||!u,type:"submit",children:"保存默认模型"})]})]})})}function Hw({connection:t,configuration:i,disabled:r,save:a,onDone:u,onDirtyChange:d}){const[c,h]=S.useState(()=>{const _=Xc(t);return t||(_.catalogId=i.catalog[0]?.id??""),_}),p=S.useRef(c),m=JSON.stringify(c)!==JSON.stringify(p.current),[y,b]=S.useState(!1),v=t?i.connections.find(_=>_.id===t.id):void 0,x=!!t&&(!v||c.expectedRevision!==v.revision);S.useEffect(()=>{if(!m&&v&&c.expectedRevision!==v.revision){const _=Xc(v);p.current=_,h(_)}},[m,v,c.expectedRevision]);const j=()=>{if(!v)return;const _=Xc(v);p.current=_,h(_),b(!1)};S.useEffect(()=>(d(m),()=>d(!1)),[m,d]);const R=i.catalog.find(_=>_.id===c.catalogId),C=!t&&i.connections.some(_=>_.id===c.id.trim()),A=(_,D)=>h(q=>({...q,[_]:D}));return s.jsx("form",{className:"config-connection-editor",onSubmit:async _=>{_.preventDefault(),!x&&await a("模型连接",D=>lw(c,D))&&u()},children:s.jsxs("fieldset",{disabled:r,children:[s.jsx("legend",{className:"config-sr-only",children:t?`编辑 ${t.id}`:"新模型连接"}),x&&s.jsxs("div",{className:"config-remove-confirm",role:"alert",children:[s.jsx("p",{children:v?"其他设备已更新这个连接。你的草稿已保留,请检查最新设置后再保存。":"这个连接已被其他设备删除。草稿仍保留,你可以复制内容后关闭编辑。"}),v&&s.jsx("button",{className:"config-button",type:"button",onClick:j,children:"放弃草稿并载入最新设置"})]}),s.jsxs("div",{className:"config-form-grid",children:[s.jsxs("label",{children:[s.jsx("span",{children:"连接名称"}),s.jsx("input",{required:!0,maxLength:120,value:c.id,readOnly:!!t,onChange:_=>A("id",_.target.value),placeholder:"例如 work-model",autoComplete:"off"})]}),s.jsxs("label",{children:[s.jsx("span",{children:"服务商"}),s.jsxs("select",{required:!0,disabled:!!t,"aria-label":"服务商",value:c.catalogId,onChange:_=>A("catalogId",_.target.value),children:[t&&!R&&s.jsx("option",{value:c.catalogId,children:c.catalogId}),i.catalog.map(_=>s.jsx("option",{value:_.id,children:_.displayName},_.id))]})]}),s.jsxs("label",{className:"config-full-width",children:[s.jsx("span",{children:"模型名称"}),s.jsx("input",{required:!0,maxLength:240,value:c.model,onChange:_=>A("model",_.target.value),placeholder:"服务商提供的模型 ID",autoComplete:"off"})]}),s.jsxs("label",{className:"config-full-width",children:[s.jsx("span",{children:"服务地址"}),s.jsx("input",{type:"url","aria-label":"服务地址",value:c.baseUrl,onChange:_=>A("baseUrl",_.target.value),placeholder:R?.defaultBaseUrl||"使用服务商默认地址",autoComplete:"off"}),s.jsx("small",{children:"留空使用服务商默认地址,支持兼容接口。"})]}),s.jsxs("label",{className:"config-full-width",children:[s.jsxs("span",{children:["API Key ",t?.hasApiKey&&s.jsx("span",{className:"config-field-meta",children:"已配置"})]}),s.jsx("input",{type:"password","aria-label":"API Key",required:R?.needsKey&&!t?.hasApiKey,value:c.apiKey,onChange:_=>A("apiKey",_.target.value),placeholder:t?.hasApiKey?"留空保留现有 API Key":R?.needsKey?"输入 API Key":"可选",autoComplete:"new-password",spellCheck:!1}),s.jsx("small",{children:t?.hasApiKey?"现有密钥保留在运行 CodeShell 的设备上,输入新值可替换。":"密钥保存在当前工作区配置中。"})]})]}),C&&s.jsx("p",{className:"config-error config-message",role:"alert",children:"连接名称已存在,请使用其他名称或编辑现有连接。"}),s.jsx("p",{className:"config-help",children:"保存后可在连接卡片中测试实际连接。"}),y&&s.jsxs("div",{className:"config-remove-confirm",role:"alert",children:[s.jsx("p",{children:"还有未保存的修改,确定放弃?"}),s.jsxs("div",{className:"config-form-actions",children:[s.jsx("button",{type:"button",className:"config-button",onClick:()=>b(!1),children:"继续编辑"}),s.jsx("button",{type:"button",className:"config-button config-button-danger",onClick:u,children:"放弃修改"})]})]}),s.jsxs("div",{className:"config-form-actions",children:[s.jsx("button",{type:"button",className:"config-button config-button-quiet",onClick:()=>m?b(!0):u(),children:"取消"}),s.jsx("button",{type:"submit",className:"config-button config-button-primary",disabled:C||x,children:"保存连接"})]})]})})}function Gw({title:t,description:i}){return s.jsxs("div",{className:"config-empty",children:[s.jsx("span",{"aria-hidden":"true",children:"◇"}),s.jsx("h3",{children:t}),s.jsx("p",{children:i})]})}function Jc(t,i=!1){return kt(`/api/v1/files/content?path=${encodeURIComponent(t)}${i?"&inline=true":""}`)}function ey(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Vw({initialPath:t,openVersion:i=0,onAuthLost:r}){const[a,u]=S.useState(""),[d,c]=S.useState(null),[h,p]=S.useState(null),[m,y]=S.useState(!1),[b,v]=S.useState(!1),[x,j]=S.useState(""),[R,C]=S.useState(0),[A,_]=S.useState(""),D=S.useRef(null),q=S.useRef(r);q.current=r;const ae=S.useCallback(H=>{H instanceof Ze&&H.status===401?q.current():j(H instanceof Error?H.message:"文件读取失败,请重试。")},[]);S.useEffect(()=>{const H=new AbortController;return y(!0),j(""),Ue(`/api/v1/files?path=${encodeURIComponent(a)}`,{signal:H.signal}).then(T=>{H.signal.aborted||c(T)}).catch(T=>{H.signal.aborted||ae(T)}).finally(()=>{H.signal.aborted||y(!1)}),()=>H.abort()},[a,R,ae]);const N=S.useCallback((H,T=!1)=>{D.current?.abort();const I=new AbortController;D.current=I,p(null),v(!0),j(""),Ue(`${Jc(H)}&preview=true`,{signal:I.signal}).then(L=>{I.signal.aborted||(T&&u(L.path.split("/").slice(0,-1).join("/")),p(L))}).catch(L=>{I.signal.aborted||ae(L)}).finally(()=>{I.signal.aborted||v(!1)})},[ae]);S.useEffect(()=>{t&&N(t,!0)},[t,i,N]),S.useEffect(()=>()=>D.current?.abort(),[]);const U=H=>{D.current?.abort(),v(!1),p(null),u(H),_("")},X=d?.files.filter(H=>H.name.toLocaleLowerCase().includes(A.toLocaleLowerCase()))??[];return s.jsxs("section",{className:"hub-library hub-files","aria-labelledby":"hub-files-heading",children:[s.jsxs("header",{className:"library-heading",children:[s.jsxs("div",{children:[s.jsx("h1",{id:"hub-files-heading",children:"工作区文件"}),s.jsx("p",{children:"查看任务生成的内容,下载到当前设备。"})]}),s.jsx("button",{className:"library-button",onClick:()=>{C(H=>H+1),h&&N(h.path)},children:"刷新"})]}),x?s.jsx("div",{className:"library-error",role:"alert",children:x}):null,s.jsxs("nav",{className:"file-breadcrumbs","aria-label":"文件位置",children:[s.jsx("button",{onClick:()=>U(""),children:"工作区"}),(d?.path??a).split("/").filter(Boolean).map((H,T,I)=>s.jsxs(S.Fragment,{children:[s.jsx("span",{"aria-hidden":"true",children:"/"}),s.jsx("button",{onClick:()=>U(I.slice(0,T+1).join("/")),children:H})]},T))]}),s.jsxs("div",{className:`file-columns${h||b?" has-preview":""}`,children:[s.jsxs("div",{className:"file-directory",children:[s.jsxs("label",{className:"library-search",children:[s.jsx("span",{className:"sr-only",children:"筛选当前文件夹"}),s.jsx("input",{type:"search",placeholder:"筛选当前文件夹…",value:A,onChange:H=>_(H.target.value)})]}),s.jsx("div",{className:"file-entries","aria-busy":m,children:m?s.jsx("p",{className:"library-empty",role:"status",children:"正在读取文件…"}):X.length===0?s.jsx("p",{className:"library-empty",children:A?"没有匹配的文件。":"这个文件夹还没有文件。"}):X.map(H=>s.jsxs("button",{className:`file-entry${h?.path===H.path?" selected":""}`,onClick:()=>H.kind==="directory"?U(H.path):N(H.path),children:[s.jsx("span",{className:"file-glyph","aria-hidden":"true",children:H.kind==="directory"?"▱":"▤"}),s.jsx("span",{className:"file-entry-name",children:H.name}),s.jsx("span",{className:"file-entry-size",children:H.kind==="directory"?"文件夹":ey(H.size)})]},H.path))}),d?.truncated?s.jsx("p",{className:"library-hint",children:"这里只显示前 500 项。可以进入子文件夹继续查看。"}):null]}),b||h?s.jsxs("article",{className:"file-preview","aria-label":"文件预览",children:[s.jsxs("header",{children:[s.jsxs("div",{children:[s.jsx("strong",{children:h?.name??"正在打开…"}),h?s.jsx("span",{children:ey(h.size)}):null]}),s.jsxs("div",{className:"library-actions",children:[h?s.jsx("a",{className:"library-button",href:Jc(h.path),download:!0,children:"下载"}):null,s.jsx("button",{className:"library-button",onClick:()=>{D.current?.abort(),v(!1),p(null)},children:"关闭预览"})]})]}),b?s.jsx("p",{className:"library-empty",role:"status",children:"正在读取内容…"}):h?.kind==="text"?s.jsxs(s.Fragment,{children:[s.jsx("pre",{tabIndex:0,children:h.content}),h.truncated?s.jsx("p",{className:"library-hint",children:"预览显示前 512 KB,下载可获取完整内容。"}):null]}):h?.kind==="image"?s.jsx("img",{src:Jc(h.path,!0),alt:h.name,onError:()=>j("图片无法预览,可以下载后打开。")}):s.jsx("div",{className:"library-empty",children:"这个文件暂不支持直接预览,可以下载后打开。"})]}):null]})]})}async function Xd(t={}){const i=new URLSearchParams({archived:t.archived??"false",limit:"50"});return t.query&&i.set("query",t.query),t.cursor&&i.set("cursor",t.cursor),Ue(`/api/v1/sessions?${i}`,{signal:t.signal})}function ty(t,i="markdown"){return kt(`/api/v1/sessions/${encodeURIComponent(t)}/export?format=${i}`)}function $w({onAuthLost:t,onOpen:i,onChanged:r,version:a=0,onDirtyChange:u}){const[d,c]=S.useState(""),[h,p]=S.useState(""),[m,y]=S.useState("false"),[b,v]=S.useState([]),[x,j]=S.useState(null),[R,C]=S.useState(!0),[A,_]=S.useState(!1),[D,q]=S.useState(""),[ae,N]=S.useState(""),[U,X]=S.useState(0),[H,T]=S.useState(""),[I,L]=S.useState(null),F=S.useRef(null),W=S.useRef(null),ee=S.useRef(null),V=S.useRef(null);S.useEffect(()=>{I?.id&&F.current?.focus()},[I?.id]),S.useEffect(()=>{I?.error&&W.current?.focus()},[I?.error]);const B=()=>{L(null),requestAnimationFrame(()=>{ee.current?.isConnected?ee.current.focus():V.current?.focus()})};S.useEffect(()=>{u?.(!!I||!!H)},[I,H,u]),S.useEffect(()=>()=>u?.(!1),[u]);const Q=S.useRef(null),fe=S.useRef(null),k=S.useRef({onAuthLost:t,onChanged:r,onOpen:i});k.current={onAuthLost:t,onChanged:r,onOpen:i};const O=S.useCallback(Z=>{Z instanceof Ze&&Z.status===401?k.current.onAuthLost():q(Z instanceof Error?Z.message:"会话操作失败,请重试。")},[]);S.useEffect(()=>{const Z=setTimeout(()=>p(d.trim()),200);return()=>clearTimeout(Z)},[d]),S.useEffect(()=>{Q.current?.abort();const Z=new AbortController;return Q.current=Z,C(!0),_(!1),q(""),Xd({query:h,archived:m,signal:Z.signal}).then(ne=>{Z.signal.aborted||(v(ne.sessions),j(ne.nextCursor))}).catch(ne=>{Z.signal.aborted||O(ne)}).finally(()=>{Z.signal.aborted||C(!1)}),()=>Z.abort()},[h,m,a,U,O]),S.useEffect(()=>()=>{Q.current?.abort(),fe.current?.abort()},[]);const re=()=>{if(!x||A||R)return;const Z=new AbortController;Q.current?.abort(),Q.current=Z,_(!0),Xd({query:h,archived:m,cursor:x,signal:Z.signal}).then(ne=>{Z.signal.aborted||(v(ge=>{const P=new Set(ge.map(ve=>ve.sessionId));return[...ge,...ne.sessions.filter(ve=>!P.has(ve.sessionId))]}),j(ne.nextCursor))}).catch(ne=>{Z.signal.aborted||O(ne)}).finally(()=>{Z.signal.aborted||_(!1)})},E=async(Z,ne,ge=!1)=>{if(fe.current)return;const P=new AbortController;fe.current=P,T(Z),q(""),N(""),"title"in ne&&L(ve=>ve&&{...ve,error:""});try{if(await Ue(`/api/v1/sessions/${encodeURIComponent(Z)}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(ne),signal:P.signal}),P.signal.aborted)return;"title"in ne?(B(),N(ne.title?"标题已保存。":"已恢复自动标题。")):N(ne.archived?"对话已归档,可以在“已归档”中恢复。":"对话已恢复。"),X(ve=>ve+1),k.current.onChanged?.(),ge&&k.current.onOpen(Z)}catch(ve){P.signal.aborted||("title"in ne&&!(ve instanceof Ze&&ve.status===401)?L(De=>De?.id===Z?{...De,error:ve instanceof Error?ve.message:"标题保存失败,请重试。",conflict:ve instanceof Ze&&ve.status===409,unavailable:ve instanceof Ze&&ve.status===404}:De):O(ve))}finally{fe.current===P&&(fe.current=null),P.signal.aborted||T("")}},J=async()=>{if(!I||fe.current)return;const Z=I.id,ne=new AbortController;fe.current=ne,T(Z),L(ge=>ge&&{...ge,error:""});try{const ge=await Ue(`/api/v1/sessions/${encodeURIComponent(Z)}`,{signal:ne.signal});if(ne.signal.aborted)return;L(P=>P?.id===Z?{...P,expectedTitle:ge.customTitle,reviewedTitle:ge.title,conflict:!1,unavailable:!1,error:""}:P),F.current?.focus()}catch(ge){ne.signal.aborted||(ge instanceof Ze&&ge.status===401?O(ge):L(P=>P?.id===Z?{...P,error:ge instanceof Error?ge.message:"无法读取最新标题,请重试。",unavailable:ge instanceof Ze&&ge.status===404}:P))}finally{fe.current===ne&&(fe.current=null),ne.signal.aborted||T("")}},be=Z=>Z.archivedAt?void E(Z.sessionId,{archived:!1},!0):k.current.onOpen(Z.sessionId);return s.jsxs("section",{className:"hub-library hub-sessions","aria-labelledby":"hub-history-heading",children:[s.jsxs("header",{className:"library-heading",children:[s.jsxs("div",{children:[s.jsx("h1",{id:"hub-history-heading",children:"历史对话"}),s.jsx("p",{children:"查找、整理并导出当前工作区的对话。"})]}),s.jsx("button",{className:"library-button",onClick:()=>X(Z=>Z+1),children:"刷新"})]}),D?s.jsx("div",{className:"library-error",role:"alert",children:D}):null,ae?s.jsx("p",{className:"library-hint",role:"status",children:ae}):null,s.jsxs("div",{className:"session-toolbar",children:[s.jsxs("label",{className:"library-search",children:[s.jsx("span",{className:"sr-only",children:"搜索对话标题"}),s.jsx("input",{ref:V,type:"search",placeholder:"搜索对话标题…",value:d,onChange:Z=>c(Z.target.value)})]}),s.jsxs("label",{children:[s.jsx("span",{className:"sr-only",children:"对话范围"}),s.jsxs("select",{value:m,onChange:Z=>y(Z.target.value),children:[s.jsx("option",{value:"false",children:"当前对话"}),s.jsx("option",{value:"true",children:"已归档"}),s.jsx("option",{value:"all",children:"全部对话"})]})]})]}),I?s.jsxs("form",{className:"session-history-editor","aria-labelledby":"session-title-editor-heading",onSubmit:Z=>{Z.preventDefault(),!H&&!I.conflict&&!I.unavailable&&E(I.id,{title:I.title,expectedTitle:I.expectedTitle})},children:[s.jsxs("div",{children:[s.jsx("h2",{id:"session-title-editor-heading",children:"重命名对话"}),s.jsxs("p",{className:"library-hint",children:["正在编辑:",I.originalTitle]}),!R&&!b.some(Z=>Z.sessionId===I.id)?s.jsx("p",{className:"library-hint",children:"此对话已不在当前列表中,标题草稿仍保留在这里。"}):null]}),I.error?s.jsx("div",{className:"library-error",id:"session-title-error",role:"alert",tabIndex:-1,ref:W,children:I.error}):null,I.reviewedTitle?s.jsxs("p",{className:"session-title-review",role:"status",children:["最新标题:",s.jsx("strong",{children:I.reviewedTitle}),"。你的草稿仍保留,请核对后再保存。"]}):null,s.jsxs("label",{children:[s.jsx("span",{children:"对话标题"}),s.jsx("input",{ref:F,className:"library-title-input",value:I.title,maxLength:1024,"aria-describedby":I.error?"session-title-error":void 0,onChange:Z=>{const ne=Z.target.value;L(ge=>ge&&{...ge,title:ne})},readOnly:!!H})]}),s.jsxs("div",{className:"library-actions",children:[s.jsx("button",{type:"submit",className:"library-button primary",disabled:!!H||I.conflict||I.unavailable,children:H?"处理中…":I.reviewedTitle?"确认保存我的标题":"保存标题"}),I.conflict||I.unavailable?s.jsx("button",{type:"button",className:"library-button",disabled:!!H,onClick:()=>{J()},children:"读取最新标题"}):null,s.jsx("button",{type:"button",className:"library-button",disabled:!!H,onClick:B,children:"取消"}),I.expectedTitle?s.jsx("button",{type:"button",className:"library-button",disabled:!!H||I.conflict||I.unavailable,onClick:()=>{E(I.id,{title:"",expectedTitle:I.expectedTitle})},children:"使用自动标题"}):null]})]}):null,s.jsx("div",{className:"session-history-list","aria-busy":R,children:R?s.jsx("p",{className:"library-empty",role:"status",children:"正在读取对话…"}):b.length===0?s.jsx("p",{className:"library-empty",children:h?"没有找到匹配的对话。":m==="true"?"还没有归档的对话。":"还没有保存的对话,开始一条新对话后会显示在这里。"}):b.map(Z=>s.jsxs("article",{className:"session-history-row",children:[s.jsxs("div",{className:"session-history-info",children:[s.jsx("button",{className:"session-history-title",onClick:()=>be(Z),children:Z.title}),Z.preview&&Z.preview!==Z.title?s.jsx("p",{children:Z.preview.slice(0,150)}):null,s.jsxs("div",{className:"session-history-meta",children:[s.jsx("span",{children:new Date(Z.lastActiveAt||Z.startedAt).toLocaleString()}),s.jsxs("span",{children:[Z.turnCount," 轮"]}),Z.running?s.jsx("span",{children:"正在运行"}):Z.archivedAt?s.jsx("span",{children:"已归档"}):null]})]}),s.jsxs("div",{className:"library-actions",children:[s.jsx("button",{className:"library-button",disabled:!!H||!!I,onClick:ne=>{ee.current=ne.currentTarget,N(""),L({id:Z.sessionId,title:Z.title,originalTitle:Z.title,expectedTitle:Z.customTitle})},children:I?.id===Z.sessionId?"正在编辑":"重命名"}),s.jsx("button",{className:"library-button",disabled:!!H||Z.running,onClick:()=>{E(Z.sessionId,{archived:!Z.archivedAt})},children:H===Z.sessionId?"处理中…":Z.archivedAt?"恢复":"归档"}),Z.running?s.jsx("button",{className:"library-button",disabled:!0,children:"运行结束后导出"}):s.jsxs("details",{className:"session-export",children:[s.jsx("summary",{className:"library-button",children:"导出"}),s.jsxs("div",{children:[s.jsx("a",{href:ty(Z.sessionId),download:!0,children:"Markdown 文档"}),s.jsx("a",{href:ty(Z.sessionId,"json"),download:!0,children:"完整 JSON 记录"})]})]})]})]},Z.sessionId))}),x&&!R?s.jsx("div",{className:"session-load-more",children:s.jsx("button",{className:"library-button",disabled:A,onClick:re,children:A?"读取中…":"加载更多"})}):null]})}var Pw=qb();function bo(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function uo(t){return typeof t=="string"?t:""}function Xb(t){return Array.isArray(t)?t.map(bo).filter(i=>i!==void 0):[]}function Yw(t){return typeof t=="string"?t:Xb(t).filter(i=>i.type==="text").map(i=>uo(i.text)).join("")}function ga(t){return t.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")}function Wc(t){const i=t.replace(/\\/g,"/").split("/").filter(Boolean).pop()||"附件";return t.includes(".code-shell/attachments/")?i.replace(/^[a-f0-9]{16}-/,""):i}function ed(t){const i=typeof t=="number"?t:Number(t);return Number.isSafeInteger(i)&&i>=0?i:0}function Kb(t,i={}){const r=[],a=p=>/^(?:[a-zA-Z]:[\\/]|[\\/])/.test(p)||!i.cwd?p:`${i.cwd.replace(/[\\/]$/,"")}/${p}`,u=[];let d=Yw(t.content);d=d.replace(/<attached-file\s+path="([^"]*)">\s*([\s\S]*?)<\/attached-file>/g,(p,m,y)=>{if(!/^absolutePath:\s*.+$/m.test(y)||!/^origin:\s*.+$/m.test(y))return p;const b=y.match(/^mime:\s*(.+)$/m)?.[1]?.trim();return r.push({name:Wc(ga(m)),path:ga(m),...i.includeAbsolutePaths?{absPath:y.match(/^absolutePath:\s*(.+)$/m)[1].trim()}:{},size:ed(y.match(/^size:\s*(\d+)\s*$/m)?.[1]),...b?{mime:b}:{}}),""}),d=d.replace(/<attached-directory\s+path="([^"]*)"[^>]*>[\s\S]*?<\/attached-directory>/g,(p,m)=>(r.push({name:`${Wc(ga(m))}/`,path:ga(m),...i.includeAbsolutePaths?{absPath:a(ga(m))}:{},size:0}),"")),d=d.replace(/<attached-image-paths>\s*([\s\S]*?)<\/attached-image-paths>\s*(?:\(上面附带的图片在工作区的真实路径[^\n]*\))?/g,(p,m)=>(u.push(...m.split(`
21
- `).map(y=>y.trim()).filter(Boolean)),""));const c=Xb(t.content).filter(p=>p.type==="image");for(let p=0;p<Math.max(c.length,u.length);p++){const m=bo(c[p]?.source),y=uo(m?.data).replace(/\s/g,"");r.push({name:u[p]?Wc(u[p]):`图片 ${p+1}`,...u[p]?{path:u[p]}:{},...i.includeAbsolutePaths&&u[p]?{absPath:a(u[p])}:{},size:y?Math.max(0,Math.floor(y.length*3/4)-(y.match(/=+$/)?.[0].length??0)):ed(m?.byteLength),...typeof m?.media_type=="string"?{mime:m.media_type}:{}})}const h=Array.isArray(t.attachments)?t.attachments.flatMap(p=>{const m=bo(p),y=uo(m?.name)||uo(m?.originalName);return y?[{name:y,size:ed(m?.size),...typeof m?.mime=="string"?{mime:m.mime}:{},...typeof m?.path=="string"?{path:m.path}:{}}]:[]}):[];return{text:typeof t.displayText=="string"?t.displayText:d.trim(),attachments:h.length?h:r}}function Zb(t){if(t.type!=="session_user_message"&&t.type!=="steer_injected")return t;const i=bo(t.transcriptMessage);return i?{...t,...Kb(i,{includeAbsolutePaths:!0,...typeof i.cwd=="string"?{cwd:i.cwd}:{}})}:t}function ny(t){return t.replace(/<system-reminder>[\s\S]*?<\/system-reminder>\s*/g,"")}function co(){return{items:[],run:"idle",seq:0,liveByAgent:{}}}function ya(t){return t.agentId??""}function eo(t,i,r=!1){const a=i.goalId;if(t.goalId!==a&&!(r&&t.goalId===void 0&&a!==void 0))return!0;const u=i.revision;return t.goalRevision!==void 0&&(u===void 0||u<t.goalRevision)}function Fw(t){switch(t){case"aborted_streaming":case"aborted_tools":return"idle";case"prompt_too_long":case"model_error":case"image_error":case"replay_incomplete":case"batch_incomplete":case"unverified_write":return"error";default:return"completed"}}function Qw(t){if(!t||typeof t!="object")return null;const i=t;if(i.method==="agent/streamEvent"&&i.params&&typeof i.params=="object"){const r=i.params;if(r.event&&typeof r.event=="object")return{event:r.event,sessionId:typeof r.sessionId=="string"?r.sessionId:void 0}}return typeof i.type=="string"?{event:i}:null}function wr(t,i){const r=Qw(i);if(!r)return t;const{sessionId:a}=r,u=Zb(r.event),d=u.type;let c=t;a&&a!==c.sessionId&&(c={...c,sessionId:a});const h=p=>{const m=c.seq+1;return[`${p}-${m}`,{...c,seq:m}]};switch(d){case"stream_request_start":{const p=ya(u),[m,y]=h("a"),b={kind:"assistant",id:m,text:"",reasoning:"",done:!1,agentId:u.agentId,...typeof u.messageId=="string"?{messageId:u.messageId}:{}};return{...y,items:[...y.items,b],liveByAgent:{...y.liveByAgent,[p]:m},run:"running"}}case"text_delta":{const p=u.text??"",m=ya(u),y=c.liveByAgent[m];if(y&&c.items.find(R=>R.id===y&&R.kind==="assistant"))return{...c,run:"running",items:c.items.map(R=>R.id===y&&R.kind==="assistant"?{...R,text:R.text+p}:R)};const[v,x]=h("a"),j={kind:"assistant",id:v,text:p,reasoning:"",done:!1,agentId:u.agentId};return{...x,items:[...x.items,j],liveByAgent:{...x.liveByAgent,[m]:v},run:"running"}}case"thinking_delta":{const p=u.text??"",m=ya(u),y=c.liveByAgent[m];if(y&&c.items.some(j=>j.id===y&&j.kind==="assistant"))return{...c,run:"running",items:c.items.map(j=>j.id===y&&j.kind==="assistant"?{...j,reasoning:j.reasoning+p}:j)};const[b,v]=h("a"),x={kind:"assistant",id:b,text:"",reasoning:p,done:!1,agentId:u.agentId};return{...v,items:[...v.items,x],liveByAgent:{...v.liveByAgent,[m]:b},run:"running"}}case"tool_use_start":{const p=u.toolCall;if(!p||c.items.some(v=>v.kind==="tool"&&v.id===p.id))return c;const m=c.orphanResults?.[p.id],y={kind:"tool",id:p.id,name:p.toolName,args:p.args,summary:p.summary,done:!!m,result:m?.result,error:m?.error,agentId:u.agentId};let b=c.orphanResults;if(m){const{[p.id]:v,...x}=c.orphanResults;b=Object.keys(x).length>0?x:void 0}return{...c,run:"running",items:[...c.items,y],orphanResults:b}}case"tool_use_args_delta":{const p=u.toolCallId,m=u.args;return!p||!m?c:{...c,items:c.items.map(y=>y.kind==="tool"&&y.id===p?{...y,args:{...y.args??{},...m}}:y)}}case"tool_result":{const p=u.result;return p?c.items.some(y=>y.kind==="tool"&&y.id===p.id)?{...c,items:c.items.map(y=>y.kind==="tool"&&y.id===p.id?{...y,done:!0,result:ny(p.result??p.error??""),error:!!(p.isError||p.error)}:y)}:{...c,orphanResults:{...c.orphanResults??{},[p.id]:{result:p.result??p.error??"",error:!!(p.isError||p.error)}}}:c}case"room_tool_result":{const p=u.summary??"",m=ny(p),y=!!u.isError;let b=-1;for(let j=c.items.length-1;j>=0;j--)if(c.items[j].kind==="tool"&&!c.items[j].done){b=j;break}if(b===-1)return c;const v=c.items.slice(),x=v[b];return v[b]={...x,done:!0,result:m,summary:m||x.summary,error:y},{...c,items:v}}case"tool_summary":{const p=u.summary??"",m=Array.isArray(u.toolCallIds)?u.toolCallIds.filter(R=>typeof R=="string"):[],b=m.length>0?m[m.length-1]:void 0,v=u.agentId;if(b){let R=!1;const C=c.items.map(A=>A.kind!=="tool"||A.id!==b||A.agentId!==v?A:(R=!0,{...A,summary:p}));return R?{...c,items:C}:c}if(v){let R=-1;for(let A=c.items.length-1;A>=0;A--){const _=c.items[A];if(_.kind==="tool"&&_.agentId===v){R=A;break}}if(R===-1)return c;const C=c.items.slice();return C[R]={...C[R],summary:p},{...c,items:C}}let x=-1;for(let R=c.items.length-1;R>=0;R--){const C=c.items[R];if(C.kind==="tool"&&C.agentId===void 0){x=R;break}}if(x===-1)return c;const j=c.items.slice();return j[x]={...j[x],summary:p},{...c,items:j}}case"tombstone":{if(typeof u.messageId!="string")return c;const p=new Set(c.items.filter(m=>m.kind==="assistant"&&m.messageId===u.messageId||m.kind==="tool"&&m.id===u.messageId).map(m=>m.id));return p.size?{...c,items:c.items.filter(m=>!p.has(m.id)),liveByAgent:Object.fromEntries(Object.entries(c.liveByAgent).filter(([,m])=>!p.has(m)))}:c}case"assistant_message":{const p=ya(u);if(!(p in c.liveByAgent))return c;const{[p]:m,...y}=c.liveByAgent,b=c.items.map(v=>v.kind==="assistant"&&!v.done&&(v.agentId??"")===p?{...v,done:!0}:v);return{...c,liveByAgent:y,items:b}}case"turn_complete":{const p=u.reason??"completed",m=ya(u),{[m]:y,...b}=c.liveByAgent,v=c.items.map(x=>x.kind==="assistant"&&!x.done&&(x.agentId??"")===m?{...x,done:!0}:x);return u.agentId?{...c,liveByAgent:b,items:v}:{...c,liveByAgent:b,items:v,run:Fw(p)}}case"goal_set":{const p=u.objective??"",m=!!u.paused;return c.goal&&c.goalId===u.goalId&&eo(c,u)?c:{...c,goal:p?`◎ ${p}${m?" (已暂停)":""}`:"◎ 目标",goalId:u.goalId,goalPaused:m,goalRevision:u.revision}}case"goal_updated":{if(c.goal&&eo(c,u,!0))return c;const p=u.goalId,m=u.objective??"",y=!!u.paused;return{...c,goal:m?`◎ ${m}${y?" (已暂停)":""}`:c.goal,goalId:p??c.goalId,goalPaused:y,goalRevision:u.revision??c.goalRevision}}case"goal_cleared":return c.goal&&eo(c,u)?c:{...c,goal:void 0,goalId:void 0,goalPaused:void 0,goalRevision:void 0};case"goal_progress":{if(c.goal&&eo(c,u))return c;const p=u.status??"";if(p==="met"||p==="exhausted")return{...c,goal:void 0,goalId:void 0,goalPaused:void 0,goalRevision:void 0};const m=u.round,y=m?`目标 · 第 ${m} 轮 (${p})`:`目标 (${p})`;return{...c,goal:y,goalRevision:u.revision??c.goalRevision}}case"task_update":{const p=u.agentId;if(!p)return c;const m=u.tasks??[],y=m.filter(j=>j.status==="completed").length,b=`任务 ${y}/${m.length}`,v=c.items.findIndex(j=>j.kind==="subagent"&&j.agentId===p),x={kind:"subagent",id:`sub-${p}`,agentId:p,label:b,status:m.length>0&&y===m.length?"completed":"running"};if(v>=0){const j=c.items.slice();return j[v]=x,{...c,items:j}}return{...c,items:[...c.items,x]}}case"agent_start":{const p=u.agentId;if(!p)return c;const m={kind:"subagent",id:`sub-${p}`,agentId:p,label:u.name||u.description||"子代理",status:u.status==="recorded"?"recorded":"running"};return c.items.some(y=>y.kind==="subagent"&&y.agentId===p)?c:{...c,items:[...c.items,m]}}case"agent_end":{const p=u.agentId;return{...c,items:c.items.map(m=>m.kind==="subagent"&&m.agentId===p?{...m,status:u.error?"error":"completed"}:m)}}case"background_agent_completed":{const p=typeof u.agentId=="string"?u.agentId:"",m=u.status==="failed",y=m?"error":u.status==="cancelled"?"cancelled":"completed",b=typeof u.name=="string"?u.name:"后台任务",v=m?u.error??u.description:u.finalText??u.description,x=`${b} · ${y}${typeof v=="string"&&v.trim()?`: ${v.trim().slice(0,240)}`:""}`,[j,R]=h("bg-done");return{...R,items:[...c.items.map(C=>C.kind==="subagent"&&C.agentId===p?{...C,status:y}:C),{kind:"system",id:j,text:x}]}}case"error":{const[p,m]=h("err");return{...m,run:"error",liveByAgent:{},items:[...m.items,{kind:"system_error",id:p,text:u.error||"运行出错"}]}}case"session_title":return{...c,title:u.title};case"session_user_message":case"steer_injected":case"user_message":{if(u.agentId||u.injected===!0||u.authority==="agent"||u.authority==="system"||u.authority==="policy")return c;const p=typeof u.clientMessageId=="string"?u.clientMessageId:void 0,m=Array.isArray(u.attachments)?u.attachments.map(v=>v).filter(v=>!!v&&typeof v.name=="string"&&typeof v.size=="number"&&Number.isFinite(v.size)&&v.size>=0).map(v=>({name:v.name,size:v.size,...typeof v.mime=="string"?{mime:v.mime}:{},...typeof v.path=="string"?{path:v.path}:{}})):void 0;if(p&&c.items.some(v=>v.kind==="user"&&v.clientMessageId===p))return m?.length?{...c,items:c.items.map(v=>v.kind==="user"&&v.clientMessageId===p?{...v,attachments:m.map((x,j)=>{const R=v.attachments?.[j];return R?.name===x.name?{...R,...x}:x})}:v)}:c;const[y,b]=h("u");return{...b,items:[...b.items,{kind:"user",id:y,text:u.text??"",...m?.length?{attachments:m}:{},...p?{clientMessageId:p}:{}}]}}case"assistant_text":{const[p,m]=h("a");return{...m,run:"running",items:[...m.items,{kind:"assistant",id:p,text:u.text??"",reasoning:"",done:!0,agentId:u.agentId}]}}default:return c}}function Xw(t,i,r,a){const u=`u-${t.seq+1}`;return{...t,seq:t.seq+1,items:[...t.items,{kind:"user",id:u,text:i,...r?.length?{attachments:r}:{},...a?{clientMessageId:a}:{}}]}}const Kw="codeshell.uiLanguage";function Zw(){try{const t=globalThis.localStorage?.getItem(Kw);if(t==="zh"||t==="en")return t}catch{}return"zh"}const Jw={zh:{mobile:{app:{extendGoal:"延长目标",clearGoal:"清除目标",loadingCcSession:"正在加载 CC 会话…",loadingSession:"正在加载会话…",conversationFallback:"对话",desktopSession:"桌面会话",newSession:"新会话",openSessionsAria:"打开会话",leaveSessionAria:"退出会话",deviceFallback:"设备",logoutAria:"退出登录",permission:"权限",ccRoomObserving:"此会话当前为只读查看;请在桌面端明确接管后再发送消息。"},approval:{risk:{low:"低风险",medium:"中风险",high:"高风险"},readSourceSummary:"读取数据源 {source} / {scope} / {resource}",question:"问题",customPlaceholder:"或输入自定义回答…",sendCustom:"发送自定义回答",rememberScope:"记住范围",scope:{once:"仅本次",session:"本会话",project:"本项目"},pathScopeLabel:"路径范围",pathScope:{file:"此文件",dir:"此目录",tool:"此工具"},allow:"允许",reject:"拒绝"},cc:{title:"CC 会话",subtitle:"外部 {label} 会话",selectProjectFirst:"先选择一个项目。",probingCli:"正在检测 {label} CLI…",cliMissing:"未检测到 {label} CLI(需在桌面端机器的 PATH 中)。",loadingSessions:"正在加载 cc 会话…",empty:"该项目下没有 {label} 会话。",messageCount:"{count} 条"},sidePane:{localTab:"会话",ccTab:"CC 会话"},composer:{disconnected:"未连接",placeholder:"发消息…",stop:"停止",send:"发送",chooseImages:"从相册选择图片",takePhoto:"拍照",removeImage:"移除图片",uploading:"上传中…",tooManyImages:"每条消息最多发送 4 张图片",unsupportedImage:"不支持此图片格式",sendFailed:"图片发送失败,请重试"},connection:{connectingTitle:"正在连接…",connectingBody:"与 CodeShell 建立通道",authenticatingTitle:"认证中…",authenticatingBody:"正在校验设备身份",unpairedTitle:"未配对",unpairedBody:"请在 CodeShell 桌面端打开「设置 → 远程」,扫码或打开配对链接。",offlineTitle:"连接断开",offlineBody:"正在自动重连…"},format:{noProject:"无项目",justNow:"刚刚",minutesAgo:"{n} 分钟前",hoursAgo:"{n} 小时前",daysAgo:"{n} 天前",monthsAgo:"{n} 个月前",yearsAgo:"{n} 年前"},notice:{roomMissing:"会话不存在或未就绪",roomError:"会话错误",sessionRecoveryIncomplete:"当前回复的开头尚未恢复,请重新打开会话以读取已保存的内容。",sessionRecoveryHistoryOnly:"已恢复保存的聊天记录。当前回复的实时部分暂时无法接续,请稍后重新打开会话。",goalExtendFailed:"延长目标失败",ccRoomOpenFailed:"cc 会话无法打开",ccRoomObserving:"此 CC 会话当前为只读查看,消息未发送",attachmentSendFailed:"图片发送失败:{error}"},permissionMode:{default:"默认",acceptEdits:"自动改",bypassPermissions:"全放行",defaultDesc:"每个工具调用都要你确认",acceptEditsDesc:"自动放行文件编辑,其余仍确认",bypassDesc:"跳过所有权限确认(危险)",title:"选择权限模式",confirmBypass:"全放行模式会跳过所有权限确认。确定吗?"},sessionList:{title:"会话",takeoverCount:"{count} 个可接管",refreshAria:"刷新会话",new:"新建",createHint:"新会话默认使用当前目录",currentProject:"当前项目 · {name}",noProjectConversation:"无项目对话",desktopCwd:"当前桌面目录",unboundRepo:"不绑定 repo",followsDesktopCwd:"跟随桌面当前 cwd",otherProjects:"其他项目",loading:"正在加载会话…",empty:"还没有会话。点「新建」开一个,或在桌面端开始。",automation:"自动",noProjectPath:"无项目路径",unreadAria:"有新内容",primaryRoot:"主目录",secondaryRoot:"次目录"},status:{conn:{connecting:"连接中…",authenticating:"认证中…",unpaired:"未配对",online:"在线",offline:"已断开"},run:{idle:"空闲",running:"运行中",waiting:"待审批",completed:"已完成",error:"出错"}},storage:{browserDevice:"{platform} 浏览器"},stream:{showReasoning:"显示思考",hideReasoning:"隐藏思考",subagent:"子代理",loading:"正在加载…",generating:"正在生成回复",emptyHint:"发个任务试试,或在侧栏打开一个 Claude Code 会话。"},tool:{running:"运行中",failed:"失败",completed:"完成",fallbackName:"操作",truncated:"… (已截断)"}}},en:{mobile:{app:{extendGoal:"Extend goal",clearGoal:"Clear goal",loadingCcSession:"Loading CC session…",loadingSession:"Loading conversation…",conversationFallback:"Conversation",desktopSession:"Desktop session",newSession:"New session",openSessionsAria:"Open sessions",leaveSessionAria:"Leave session",deviceFallback:"Device",logoutAria:"Log out",permission:"Permission",ccRoomObserving:"This session is read-only. Take it over explicitly on desktop before sending messages."},approval:{risk:{low:"Low risk",medium:"Medium risk",high:"High risk"},readSourceSummary:"Read data source {source} / {scope} / {resource}",question:"Question",customPlaceholder:"Or enter a custom answer…",sendCustom:"Send custom answer",rememberScope:"Remember scope",scope:{once:"Once",session:"This session",project:"This project"},pathScopeLabel:"Path scope",pathScope:{file:"This file",dir:"This directory",tool:"This tool"},allow:"Allow",reject:"Deny"},cc:{title:"CC sessions",subtitle:"External {label} sessions",selectProjectFirst:"Select a project first.",probingCli:"Checking {label} CLI…",cliMissing:"{label} CLI was not found (it must be in PATH on the desktop machine).",loadingSessions:"Loading cc sessions…",empty:"No {label} sessions in this project.",messageCount:"{count} messages"},sidePane:{localTab:"Sessions",ccTab:"CC"},composer:{disconnected:"Disconnected",placeholder:"Message…",stop:"Stop",send:"Send",chooseImages:"Choose images",takePhoto:"Take photo",removeImage:"Remove image",uploading:"Uploading…",tooManyImages:"Up to 4 images can be sent per message",unsupportedImage:"This image format is not supported",sendFailed:"Could not send images; try again"},connection:{connectingTitle:"Connecting…",connectingBody:"Opening a channel to CodeShell",authenticatingTitle:"Authenticating…",authenticatingBody:"Verifying this device",unpairedTitle:"Not paired",unpairedBody:"Open Settings → Remote in CodeShell desktop, then scan the QR code or open the pairing link.",offlineTitle:"Disconnected",offlineBody:"Reconnecting automatically…"},format:{noProject:"No project",justNow:"Just now",minutesAgo:"{n} min ago",hoursAgo:"{n} hr ago",daysAgo:"{n} days ago",monthsAgo:"{n} mo ago",yearsAgo:"{n} yr ago"},notice:{roomMissing:"Session does not exist or is not ready",roomError:"Session error",sessionRecoveryIncomplete:"The beginning of this reply could not be restored. Reopen the conversation to read its saved content.",sessionRecoveryHistoryOnly:"Saved chat history has been restored. Reopen the conversation later to see the rest of this reply.",goalExtendFailed:"Failed to extend goal",ccRoomOpenFailed:"Could not open cc session",ccRoomObserving:"This CC session is read-only; the message was not sent",attachmentSendFailed:"Could not send images: {error}"},permissionMode:{default:"Default",acceptEdits:"Auto-edit",bypassPermissions:"Allow all",defaultDesc:"Confirm every tool call",acceptEditsDesc:"Allow file edits automatically; confirm everything else",bypassDesc:"Skip all permission confirmations (dangerous)",title:"Choose permission mode",confirmBypass:"Allow all mode skips every permission confirmation. Continue?"},sessionList:{title:"Sessions",takeoverCount:"{count} available",refreshAria:"Refresh sessions",new:"New",createHint:"New sessions default to the current directory",currentProject:"Current project · {name}",noProjectConversation:"No-project conversation",desktopCwd:"Current desktop directory",unboundRepo:"Do not bind a repo",followsDesktopCwd:"Follow desktop current cwd",otherProjects:"Other projects",loading:"Loading sessions…",empty:"No sessions yet. Tap “New” to start one, or start from desktop.",automation:"Automation",noProjectPath:"No project path",unreadAria:"New content",primaryRoot:"Primary",secondaryRoot:"Secondary"},status:{conn:{connecting:"Connecting…",authenticating:"Authenticating…",unpaired:"Not paired",online:"Online",offline:"Disconnected"},run:{idle:"Idle",running:"Running",waiting:"Awaiting approval",completed:"Completed",error:"Error"}},storage:{browserDevice:"{platform} browser"},stream:{showReasoning:"Show reasoning",hideReasoning:"Hide reasoning",subagent:"Subagent",loading:"Loading…",generating:"Generating response",emptyHint:"Send a task, or open a Claude Code session from the sidebar."},tool:{running:"Running",failed:"Failed",completed:"Completed",fallbackName:"Operation",truncated:"… (truncated)"}}}},iy=Jw;function ry(t,i){let r=t;for(const a of i.split(".")){if(r==null||typeof r!="object")return;r=r[a]}return typeof r=="string"?r:void 0}function Ww(t,i){return i?t.replace(/\{(\w+)\}/g,(r,a)=>a in i?String(i[a]):r):t}function eS(t,i,r){const a=ry(iy[t],i)??ry(iy.zh,i)??i;return Ww(a,r)}function tS(t,i){return eS(Zw(),t,i)}const nS=["command","file_path","path","url","pattern","query"];function iS(t,i,r){let a="";const u=t?.source,d=t?.scope,c=t?.resource;if(r==="ReadSource"&&typeof u=="string"&&u.length>0&&typeof d=="string"&&d.length>0&&typeof c=="string"&&c.length>0)a=tS("mobile.approval.readSourceSummary",{source:u,scope:d,resource:c});else for(const p of nS){const m=t?.[p];if(typeof m=="string"&&m.length>0){a=m;break}}a||(a=JSON.stringify(t??{}));let h;return i==="low"||i==="medium"||i==="high"?h=i:i===void 0||i===""?h="medium":h="high",{summary:a,risk:h}}const rS=16*1024*1024;function xr(t){if(typeof t!="string"||t.length>2048||!/^[A-Za-z0-9_-]+$/.test(t))throw new Error("Invalid output cursor");const i=JSON.parse(atob(t.replace(/-/g,"+").replace(/_/g,"/")));if(typeof i.identity!="string"||!Number.isSafeInteger(i.sequence)||i.sequence<0||!Number.isSafeInteger(i.offset)||i.offset<0)throw new Error("Invalid output cursor");return i}function lS(t){if(t.length>Math.ceil(64*1024/3)*4||!/^[A-Za-z0-9+/]*={0,2}$/.test(t))throw new Error("Invalid output fragment");const i=atob(t);return Uint8Array.from(i,r=>r.charCodeAt(0))}function ka(t,i){try{const r=xr(t),a=xr(i);return r.identity===a.identity?Math.sign(r.sequence-a.sequence):void 0}catch{return}}function aS(t,i,r){if(t.incomplete)return!1;try{if(i.version!==1||i.status!=="ok"||!i.from||!i.through||!i.next||!i.coverageStart||!Array.isArray(i.frames)||i.frames.length>512||new TextEncoder().encode(JSON.stringify(i)).length>1024*1024+16*1024)throw new Error("Output recovery is incomplete");if((t.cursor??i.coverageStart)!==i.from||t.through&&t.through!==i.through||t.coverageStart&&t.coverageStart!==i.coverageStart||t.legacyBaseThroughEventId!==void 0&&t.legacyBaseThroughEventId!==i.legacyBaseThroughEventId)throw new Error("Output recovery page changed its snapshot");let a=xr(i.from);const u=xr(i.through),d=xr(i.coverageStart);if(d.sequence!==0||d.identity!==a.identity||u.identity!==a.identity||a.sequence>u.sequence)throw new Error("Output recovery cursor domain changed");let c=t.pending?{...t.pending,chunks:t.pending.chunks.slice()}:void 0,h=t.appliedCursor??i.from;const p=[];for(const y of i.frames){const b=xr(y.cursor);if(b.identity!==a.identity||b.sequence!==a.sequence+1||y.sequence!==b.sequence||b.offset<=a.offset||b.sequence>u.sequence||!!y.event==!!y.fragment)throw new Error("Output recovery has a gap");let v=y.event;if(y.fragment){const x=y.fragment;if(!c){if(x.index!==0||!Number.isSafeInteger(x.total)||x.total<2||x.total>256)throw new Error("Output fragment has no beginning");c={id:x.id,total:x.total,next:0,bytes:0,chunks:[]}}if(x.id!==c.id||x.total!==c.total||x.index!==c.next)throw new Error("Output fragment has a gap");const j=lS(x.data);if(c.bytes+=j.length,c.bytes>rS)throw new Error("Output fragment exceeds its budget");if(c.chunks.push(j),c.next++,c.next===c.total){const R=new Uint8Array(c.bytes);let C=0;for(const A of c.chunks)R.set(A,C),C+=A.length;v=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(R)),c=void 0}}else if(c)throw new Error("Output fragment was interrupted");if(v){if(typeof v!="object"||typeof v.type!="string"||v.outputRecovery==="incomplete")throw new Error("Invalid output event");p.push({...Zb(v),outputCursor:y.cursor}),h=y.cursor}a=b}const m=xr(i.next);if(m.identity!==a.identity||m.sequence!==a.sequence||m.offset!==a.offset||(i.frames.at(-1)?.cursor??i.from)!==i.next||i.complete!==(i.next===i.through)||i.complete&&c||!i.complete&&!i.frames.length)throw new Error("Output recovery page did not establish coverage");t.cursor=i.next,t.appliedCursor=h,t.through=i.through,t.coverageStart=i.coverageStart,t.legacyBaseThroughEventId=i.legacyBaseThroughEventId,t.pending=c;for(const y of p)r(y);return i.complete}catch{return t.incomplete=!0,t.pending=void 0,!1}}const sS=new Set(["session_started","stream_request_start","text_delta","thinking_delta","tool_use_start","tool_use_args_delta","tool_result","room_tool_result","tool_summary","tombstone","assistant_message","turn_complete","goal_set","goal_updated","goal_cleared","goal_progress","task_update","agent_start","agent_end","background_agent_completed","context_compact","error","session_user_message","steer_injected","user_message","assistant_text"]);function oS(t){if(typeof t!="string"||t.length>2048||!/^[A-Za-z0-9_-]+$/.test(t))return!1;try{const i=JSON.parse(atob(t.replace(/-/g,"+").replace(/_/g,"/")));return typeof i.identity=="string"&&typeof i.hash=="string"&&/^[a-f0-9]{64}$/.test(i.identity)&&/^[a-f0-9]{64}$/.test(i.hash)&&Number.isSafeInteger(i.sequence)&&i.sequence>0&&Number.isSafeInteger(i.offset)&&i.offset>0}catch{return!1}}class kf{lastCursor;blocked=!1;overflowed=!1;inputs=new Set;copy(){const i=new kf;i.lastCursor=this.lastCursor,i.blocked=this.blocked,i.overflowed=this.overflowed;for(const r of this.inputs)i.inputs.add(r);return i}observe(i){if(this.overflowed)return;const r=i;if(r){if(r.outputCursor!==void 0){const a=oS(r.outputCursor)?this.lastCursor?ka(r.outputCursor,this.lastCursor):1:void 0;if(a===void 0||a<=0){this.discardProof();return}this.lastCursor=r.outputCursor;return}if(!(!r.type||!sS.has(r.type))&&!(["session_user_message","steer_injected","user_message"].includes(r.type)&&(r.agentId||r.injected===!0||["agent","system","policy"].includes(String(r.authority)))))if(r.type==="session_user_message"){const a=r.clientMessageId;typeof a!="string"||!a.trim()||a.length>512?this.blocked=!0:this.inputs.add(a),(this.inputIds.length>128||this.memoryBytes>32*1024)&&this.discardProof()}else this.blocked=!0}}acknowledgeInputs(i){for(const r of i)this.inputs.delete(r)}get inputIds(){return[...this.inputs]}get incomplete(){return this.blocked||this.overflowed}get memoryBytes(){return this.inputIds.reduce((i,r)=>i+new TextEncoder().encode(r).length,0)}discardProof(){this.overflowed=!0,this.inputs.clear()}}function ba(t,i,r,a={}){if(t.unpaired)throw new Error("Output recovery contains unpaired visible output");if(i.coverageIdentity!==void 0&&a.requireIdentity!==!1&&(t.incarnation===void 0||t.journalIdentity===void 0))throw new Error("Output recovery Session incarnation proof is unavailable");if(t.incarnation!==void 0&&t.incarnation!==i.coverageIdentity)throw new Error("Output recovery Session incarnation changed");if(t.journalIdentity!==void 0){let d;try{d=JSON.parse(atob((i.coverageStart??"").replace(/-/g,"+").replace(/_/g,"/"))).hash}catch{throw new Error("Output recovery journal pin is unpaired")}if(d!==t.journalIdentity)throw new Error("Output recovery journal pin changed")}const u=t.inputIds??[];if(!Array.isArray(u)||u.length>128||new Set(u).size!==u.length||u.some(d=>typeof d!="string"||!d.trim()||d.length>512)||u.reduce((d,c)=>d+new TextEncoder().encode(c).length,0)>32*1024)throw new Error("Output recovery input identities are unpaired");if(u.some(d=>!r(d)))throw new Error("Output recovery input has no recorded anchor")}const td=1e4,ly=15e3,uS=5e3;class cS{constructor(i,r,a=!1){this.sendProbe=i,this.expire=r,this.paused=a,this.arm(td,()=>this.fail())}sendProbe;expire;timer;revision=0;stopped=!1;paused;ready=!1;opened=!1;probing=!1;connected(){this.stopped||(this.ready=!0,this.arm(ly,()=>this.check()))}authenticating(){this.stopped||this.ready||this.opened||(this.opened=!0,this.arm(td,()=>this.fail()))}received(){return this.stopped||this.paused||!this.probing?!1:(this.probing=!1,this.arm(ly,()=>this.check()),!0)}check(){if(!(this.stopped||this.paused||this.probing||!this.ready)){this.probing=!0,this.arm(uS,()=>this.fail());try{this.sendProbe()}catch{this.fail()}}}pause(){this.paused=!0,this.probing=!1,this.clear()}resume(){if(this.stopped)return;const i=this.paused;this.paused=!1,this.ready?this.check():i&&this.arm(td,()=>this.fail())}stop(){this.stopped=!0,this.probing=!1,this.clear()}clear(){this.revision++,this.timer!==void 0&&clearTimeout(this.timer),this.timer=void 0}arm(i,r){if(this.clear(),this.stopped||this.paused)return;const a=this.revision;this.timer=setTimeout(()=>{this.stopped||this.paused||a!==this.revision||(this.timer=void 0,r())},i)}fail(){this.stopped||(this.stop(),this.expire())}}function to(){return typeof document<"u"&&document.visibilityState==="hidden"}function Ci(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function It(t){return typeof t=="string"?t:""}function Kd(t){return Array.isArray(t)?t.map(Ci).filter(i=>i!==void 0):[]}function ay(t){return typeof t=="string"?t:Kd(t).filter(i=>i.type==="text").map(i=>It(i.text)).join("")}function sy(t){return Ci(t.data)??Ci(t.message)??t}function dS(t){const i=[],r=new Set,a=new Set,u=new Map;for(const h of t){const p=Ci(h);if(!p)continue;const m=sy(p);p.type==="tool_use"&&It(m.toolCallId)&&u.set(It(m.toolCallId),{name:It(m.toolName)||"工具",args:Ci(m.args)??{}});for(const y of Kd(m.content))y.type==="tool_use"&&It(y.id)&&u.set(It(y.id),{name:It(y.name)||"工具",args:Ci(y.input)??{}})}const d=(h,p,m,y)=>{h&&(a.has(h)?i.push({type:"tool_use_args_delta",toolCallId:h,args:m,...y?{agentId:y}:{}}):(a.add(h),i.push({type:"tool_use_start",toolCall:{id:h,toolName:p||"工具",args:m},...y?{agentId:y}:{}})))},c=(h,p,m)=>{if(!h)return;const y=u.get(h);a.has(h)||d(h,y?.name||It(p.toolName)||"工具",y?.args??{},m);const b=typeof p.result=="string"?p.result:ay(p.content??p.contentBlocks),v=It(p.error);i.push({type:"tool_result",result:{id:h,result:b||v,...v?{error:v}:{},isError:p.isError===!0||p.is_error===!0||!!v},...m?{agentId:m}:{}})};for(const h of t){const p=Ci(h);if(!p)continue;const m=It(p.id);if(m&&r.has(m))continue;m&&r.add(m);const y=sy(p),b=It(y.agentId)||void 0;switch(typeof p.type=="string"?p.type:typeof y.role=="string"?"message":""){case"message":{const x=Kd(y.content);if(y.role==="user"){if(y.injected===!0||y.authority==="agent"||y.authority==="system"||y.authority==="policy")break;const j=Kb(y);if(j.text.startsWith("<system-reminder>"))break;(j.text||j.attachments.length)&&i.push({type:"user_message",...j,...typeof y.clientMessageId=="string"?{clientMessageId:y.clientMessageId}:{}});for(const R of x)R.type==="tool_result"&&c(It(R.tool_use_id),R,b)}else if(y.role==="assistant"){const j=ay(y.content),R=x.filter(C=>C.type==="reasoning").map(C=>It(C.reasoningContent)||It(C.text)).join("");if(j||R){const C=b?{agentId:b}:{};i.push({type:"stream_request_start",...C}),R&&i.push({type:"thinking_delta",text:R,...C}),j&&i.push({type:"text_delta",text:j,...C}),i.push({type:"assistant_message",...C})}for(const C of x)C.type==="tool_use"&&d(It(C.id),It(C.name),Ci(C.input)??{},b)}else y.role==="tool"&&c(It(y.tool_call_id),y,b);break}case"tool_use":d(It(y.toolCallId),It(y.toolName),Ci(y.args)??{},b);break;case"tool_result":c(It(y.toolCallId),y,b);break;case"subagent":b&&i.push({type:"agent_start",agentId:b,name:It(y.name),description:It(y.description),status:"recorded"});break;case"error":It(y.error)&&i.push({type:"error",error:y.error});break;case"turn_stopped":i.push({type:"turn_complete",reason:"aborted_tools"});break;case"session_meta":It(y.sessionId)&&i.push({type:"session_started",sessionId:y.sessionId});break}}return i}function Jb(t){let i=co();for(const r of dS(t))i=wr(i,r);return{...i,run:i.run==="error"?"error":"idle",liveByAgent:{}}}var fl={},nd,oy;function fS(){return oy||(oy=1,nd=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),nd}var id={},Ji={},uy;function Er(){if(uy)return Ji;uy=1;let t;const i=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Ji.getSymbolSize=function(a){if(!a)throw new Error('"version" cannot be null or undefined');if(a<1||a>40)throw new Error('"version" should be in range from 1 to 40');return a*4+17},Ji.getSymbolTotalCodewords=function(a){return i[a]},Ji.getBCHDigit=function(r){let a=0;for(;r!==0;)a++,r>>>=1;return a},Ji.setToSJISFunction=function(a){if(typeof a!="function")throw new Error('"toSJISFunc" is not a valid function.');t=a},Ji.isKanjiModeEnabled=function(){return typeof t<"u"},Ji.toSJIS=function(a){return t(a)},Ji}var rd={},cy;function Cf(){return cy||(cy=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function i(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+r)}}t.isValid=function(a){return a&&typeof a.bit<"u"&&a.bit>=0&&a.bit<4},t.from=function(a,u){if(t.isValid(a))return a;try{return i(a)}catch{return u}}})(rd)),rd}var ld,dy;function hS(){if(dy)return ld;dy=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(i){const r=Math.floor(i/8);return(this.buffer[r]>>>7-i%8&1)===1},put:function(i,r){for(let a=0;a<r;a++)this.putBit((i>>>r-a-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(i){const r=Math.floor(this.length/8);this.buffer.length<=r&&this.buffer.push(0),i&&(this.buffer[r]|=128>>>this.length%8),this.length++}},ld=t,ld}var ad,fy;function pS(){if(fy)return ad;fy=1;function t(i){if(!i||i<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=i,this.data=new Uint8Array(i*i),this.reservedBit=new Uint8Array(i*i)}return t.prototype.set=function(i,r,a,u){const d=i*this.size+r;this.data[d]=a,u&&(this.reservedBit[d]=!0)},t.prototype.get=function(i,r){return this.data[i*this.size+r]},t.prototype.xor=function(i,r,a){this.data[i*this.size+r]^=a},t.prototype.isReserved=function(i,r){return this.reservedBit[i*this.size+r]},ad=t,ad}var sd={},hy;function mS(){return hy||(hy=1,(function(t){const i=Er().getSymbolSize;t.getRowColCoords=function(a){if(a===1)return[];const u=Math.floor(a/7)+2,d=i(a),c=d===145?26:Math.ceil((d-13)/(2*u-2))*2,h=[d-7];for(let p=1;p<u-1;p++)h[p]=h[p-1]-c;return h.push(6),h.reverse()},t.getPositions=function(a){const u=[],d=t.getRowColCoords(a),c=d.length;for(let h=0;h<c;h++)for(let p=0;p<c;p++)h===0&&p===0||h===0&&p===c-1||h===c-1&&p===0||u.push([d[h],d[p]]);return u}})(sd)),sd}var od={},py;function gS(){if(py)return od;py=1;const t=Er().getSymbolSize,i=7;return od.getPositions=function(a){const u=t(a);return[[0,0],[u-i,0],[0,u-i]]},od}var ud={},my;function yS(){return my||(my=1,(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const i={N1:3,N2:3,N3:40,N4:10};t.isValid=function(u){return u!=null&&u!==""&&!isNaN(u)&&u>=0&&u<=7},t.from=function(u){return t.isValid(u)?parseInt(u,10):void 0},t.getPenaltyN1=function(u){const d=u.size;let c=0,h=0,p=0,m=null,y=null;for(let b=0;b<d;b++){h=p=0,m=y=null;for(let v=0;v<d;v++){let x=u.get(b,v);x===m?h++:(h>=5&&(c+=i.N1+(h-5)),m=x,h=1),x=u.get(v,b),x===y?p++:(p>=5&&(c+=i.N1+(p-5)),y=x,p=1)}h>=5&&(c+=i.N1+(h-5)),p>=5&&(c+=i.N1+(p-5))}return c},t.getPenaltyN2=function(u){const d=u.size;let c=0;for(let h=0;h<d-1;h++)for(let p=0;p<d-1;p++){const m=u.get(h,p)+u.get(h,p+1)+u.get(h+1,p)+u.get(h+1,p+1);(m===4||m===0)&&c++}return c*i.N2},t.getPenaltyN3=function(u){const d=u.size;let c=0,h=0,p=0;for(let m=0;m<d;m++){h=p=0;for(let y=0;y<d;y++)h=h<<1&2047|u.get(m,y),y>=10&&(h===1488||h===93)&&c++,p=p<<1&2047|u.get(y,m),y>=10&&(p===1488||p===93)&&c++}return c*i.N3},t.getPenaltyN4=function(u){let d=0;const c=u.data.length;for(let p=0;p<c;p++)d+=u.data[p];return Math.abs(Math.ceil(d*100/c/5)-10)*i.N4};function r(a,u,d){switch(a){case t.Patterns.PATTERN000:return(u+d)%2===0;case t.Patterns.PATTERN001:return u%2===0;case t.Patterns.PATTERN010:return d%3===0;case t.Patterns.PATTERN011:return(u+d)%3===0;case t.Patterns.PATTERN100:return(Math.floor(u/2)+Math.floor(d/3))%2===0;case t.Patterns.PATTERN101:return u*d%2+u*d%3===0;case t.Patterns.PATTERN110:return(u*d%2+u*d%3)%2===0;case t.Patterns.PATTERN111:return(u*d%3+(u+d)%2)%2===0;default:throw new Error("bad maskPattern:"+a)}}t.applyMask=function(u,d){const c=d.size;for(let h=0;h<c;h++)for(let p=0;p<c;p++)d.isReserved(p,h)||d.xor(p,h,r(u,p,h))},t.getBestMask=function(u,d){const c=Object.keys(t.Patterns).length;let h=0,p=1/0;for(let m=0;m<c;m++){d(m),t.applyMask(m,u);const y=t.getPenaltyN1(u)+t.getPenaltyN2(u)+t.getPenaltyN3(u)+t.getPenaltyN4(u);t.applyMask(m,u),y<p&&(p=y,h=m)}return h}})(ud)),ud}var no={},gy;function Wb(){if(gy)return no;gy=1;const t=Cf(),i=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return no.getBlocksCount=function(u,d){switch(d){case t.L:return i[(u-1)*4+0];case t.M:return i[(u-1)*4+1];case t.Q:return i[(u-1)*4+2];case t.H:return i[(u-1)*4+3];default:return}},no.getTotalCodewordsCount=function(u,d){switch(d){case t.L:return r[(u-1)*4+0];case t.M:return r[(u-1)*4+1];case t.Q:return r[(u-1)*4+2];case t.H:return r[(u-1)*4+3];default:return}},no}var cd={},va={},yy;function bS(){if(yy)return va;yy=1;const t=new Uint8Array(512),i=new Uint8Array(256);return(function(){let a=1;for(let u=0;u<255;u++)t[u]=a,i[a]=u,a<<=1,a&256&&(a^=285);for(let u=255;u<512;u++)t[u]=t[u-255]})(),va.log=function(a){if(a<1)throw new Error("log("+a+")");return i[a]},va.exp=function(a){return t[a]},va.mul=function(a,u){return a===0||u===0?0:t[i[a]+i[u]]},va}var by;function vS(){return by||(by=1,(function(t){const i=bS();t.mul=function(a,u){const d=new Uint8Array(a.length+u.length-1);for(let c=0;c<a.length;c++)for(let h=0;h<u.length;h++)d[c+h]^=i.mul(a[c],u[h]);return d},t.mod=function(a,u){let d=new Uint8Array(a);for(;d.length-u.length>=0;){const c=d[0];for(let p=0;p<u.length;p++)d[p]^=i.mul(u[p],c);let h=0;for(;h<d.length&&d[h]===0;)h++;d=d.slice(h)}return d},t.generateECPolynomial=function(a){let u=new Uint8Array([1]);for(let d=0;d<a;d++)u=t.mul(u,new Uint8Array([1,i.exp(d)]));return u}})(cd)),cd}var dd,vy;function xS(){if(vy)return dd;vy=1;const t=vS();function i(r){this.genPoly=void 0,this.degree=r,this.degree&&this.initialize(this.degree)}return i.prototype.initialize=function(a){this.degree=a,this.genPoly=t.generateECPolynomial(this.degree)},i.prototype.encode=function(a){if(!this.genPoly)throw new Error("Encoder not initialized");const u=new Uint8Array(a.length+this.degree);u.set(a);const d=t.mod(u,this.genPoly),c=this.degree-d.length;if(c>0){const h=new Uint8Array(this.degree);return h.set(d,c),h}return d},dd=i,dd}var fd={},hd={},pd={},xy;function ev(){return xy||(xy=1,pd.isValid=function(i){return!isNaN(i)&&i>=1&&i<=40}),pd}var ei={},wy;function tv(){if(wy)return ei;wy=1;const t="[0-9]+",i="[A-Z $%*+\\-./:]+";let r="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";r=r.replace(/u/g,"\\u");const a="(?:(?![A-Z0-9 $%*+\\-./:]|"+r+`)(?:.|[\r
22
- ]))+`;ei.KANJI=new RegExp(r,"g"),ei.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),ei.BYTE=new RegExp(a,"g"),ei.NUMERIC=new RegExp(t,"g"),ei.ALPHANUMERIC=new RegExp(i,"g");const u=new RegExp("^"+r+"$"),d=new RegExp("^"+t+"$"),c=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return ei.testKanji=function(p){return u.test(p)},ei.testNumeric=function(p){return d.test(p)},ei.testAlphanumeric=function(p){return c.test(p)},ei}var Sy;function Nr(){return Sy||(Sy=1,(function(t){const i=ev(),r=tv();t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(d,c){if(!d.ccBits)throw new Error("Invalid mode: "+d);if(!i.isValid(c))throw new Error("Invalid version: "+c);return c>=1&&c<10?d.ccBits[0]:c<27?d.ccBits[1]:d.ccBits[2]},t.getBestModeForData=function(d){return r.testNumeric(d)?t.NUMERIC:r.testAlphanumeric(d)?t.ALPHANUMERIC:r.testKanji(d)?t.KANJI:t.BYTE},t.toString=function(d){if(d&&d.id)return d.id;throw new Error("Invalid mode")},t.isValid=function(d){return d&&d.bit&&d.ccBits};function a(u){if(typeof u!="string")throw new Error("Param is not a string");switch(u.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+u)}}t.from=function(d,c){if(t.isValid(d))return d;try{return a(d)}catch{return c}}})(hd)),hd}var jy;function wS(){return jy||(jy=1,(function(t){const i=Er(),r=Wb(),a=Cf(),u=Nr(),d=ev(),c=7973,h=i.getBCHDigit(c);function p(v,x,j){for(let R=1;R<=40;R++)if(x<=t.getCapacity(R,j,v))return R}function m(v,x){return u.getCharCountIndicator(v,x)+4}function y(v,x){let j=0;return v.forEach(function(R){const C=m(R.mode,x);j+=C+R.getBitsLength()}),j}function b(v,x){for(let j=1;j<=40;j++)if(y(v,j)<=t.getCapacity(j,x,u.MIXED))return j}t.from=function(x,j){return d.isValid(x)?parseInt(x,10):j},t.getCapacity=function(x,j,R){if(!d.isValid(x))throw new Error("Invalid QR Code version");typeof R>"u"&&(R=u.BYTE);const C=i.getSymbolTotalCodewords(x),A=r.getTotalCodewordsCount(x,j),_=(C-A)*8;if(R===u.MIXED)return _;const D=_-m(R,x);switch(R){case u.NUMERIC:return Math.floor(D/10*3);case u.ALPHANUMERIC:return Math.floor(D/11*2);case u.KANJI:return Math.floor(D/13);case u.BYTE:default:return Math.floor(D/8)}},t.getBestVersionForData=function(x,j){let R;const C=a.from(j,a.M);if(Array.isArray(x)){if(x.length>1)return b(x,C);if(x.length===0)return 1;R=x[0]}else R=x;return p(R.mode,R.getLength(),C)},t.getEncodedBits=function(x){if(!d.isValid(x)||x<7)throw new Error("Invalid QR Code version");let j=x<<12;for(;i.getBCHDigit(j)-h>=0;)j^=c<<i.getBCHDigit(j)-h;return x<<12|j}})(fd)),fd}var md={},ky;function SS(){if(ky)return md;ky=1;const t=Er(),i=1335,r=21522,a=t.getBCHDigit(i);return md.getEncodedBits=function(d,c){const h=d.bit<<3|c;let p=h<<10;for(;t.getBCHDigit(p)-a>=0;)p^=i<<t.getBCHDigit(p)-a;return(h<<10|p)^r},md}var gd={},yd,Cy;function jS(){if(Cy)return yd;Cy=1;const t=Nr();function i(r){this.mode=t.NUMERIC,this.data=r.toString()}return i.getBitsLength=function(a){return 10*Math.floor(a/3)+(a%3?a%3*3+1:0)},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(a){let u,d,c;for(u=0;u+3<=this.data.length;u+=3)d=this.data.substr(u,3),c=parseInt(d,10),a.put(c,10);const h=this.data.length-u;h>0&&(d=this.data.substr(u),c=parseInt(d,10),a.put(c,h*3+1))},yd=i,yd}var bd,Ey;function kS(){if(Ey)return bd;Ey=1;const t=Nr(),i=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function r(a){this.mode=t.ALPHANUMERIC,this.data=a}return r.getBitsLength=function(u){return 11*Math.floor(u/2)+6*(u%2)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(u){let d;for(d=0;d+2<=this.data.length;d+=2){let c=i.indexOf(this.data[d])*45;c+=i.indexOf(this.data[d+1]),u.put(c,11)}this.data.length%2&&u.put(i.indexOf(this.data[d]),6)},bd=r,bd}var vd,Ny;function CS(){if(Ny)return vd;Ny=1;const t=Nr();function i(r){this.mode=t.BYTE,typeof r=="string"?this.data=new TextEncoder().encode(r):this.data=new Uint8Array(r)}return i.getBitsLength=function(a){return a*8},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(r){for(let a=0,u=this.data.length;a<u;a++)r.put(this.data[a],8)},vd=i,vd}var xd,Ty;function ES(){if(Ty)return xd;Ty=1;const t=Nr(),i=Er();function r(a){this.mode=t.KANJI,this.data=a}return r.getBitsLength=function(u){return u*13},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(a){let u;for(u=0;u<this.data.length;u++){let d=i.toSJIS(this.data[u]);if(d>=33088&&d<=40956)d-=33088;else if(d>=57408&&d<=60351)d-=49472;else throw new Error("Invalid SJIS character: "+this.data[u]+`
23
- Make sure your charset is UTF-8`);d=(d>>>8&255)*192+(d&255),a.put(d,13)}},xd=r,xd}var wd={exports:{}},Ay;function NS(){return Ay||(Ay=1,(function(t){var i={single_source_shortest_paths:function(r,a,u){var d={},c={};c[a]=0;var h=i.PriorityQueue.make();h.push(a,0);for(var p,m,y,b,v,x,j,R,C;!h.empty();){p=h.pop(),m=p.value,b=p.cost,v=r[m]||{};for(y in v)v.hasOwnProperty(y)&&(x=v[y],j=b+x,R=c[y],C=typeof c[y]>"u",(C||R>j)&&(c[y]=j,h.push(y,j),d[y]=m))}if(typeof u<"u"&&typeof c[u]>"u"){var A=["Could not find a path from ",a," to ",u,"."].join("");throw new Error(A)}return d},extract_shortest_path_from_predecessor_list:function(r,a){for(var u=[],d=a;d;)u.push(d),r[d],d=r[d];return u.reverse(),u},find_path:function(r,a,u){var d=i.single_source_shortest_paths(r,a,u);return i.extract_shortest_path_from_predecessor_list(d,u)},PriorityQueue:{make:function(r){var a=i.PriorityQueue,u={},d;r=r||{};for(d in a)a.hasOwnProperty(d)&&(u[d]=a[d]);return u.queue=[],u.sorter=r.sorter||a.default_sorter,u},default_sorter:function(r,a){return r.cost-a.cost},push:function(r,a){var u={value:r,cost:a};this.queue.push(u),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=i})(wd)),wd.exports}var Ry;function TS(){return Ry||(Ry=1,(function(t){const i=Nr(),r=jS(),a=kS(),u=CS(),d=ES(),c=tv(),h=Er(),p=NS();function m(A){return unescape(encodeURIComponent(A)).length}function y(A,_,D){const q=[];let ae;for(;(ae=A.exec(D))!==null;)q.push({data:ae[0],index:ae.index,mode:_,length:ae[0].length});return q}function b(A){const _=y(c.NUMERIC,i.NUMERIC,A),D=y(c.ALPHANUMERIC,i.ALPHANUMERIC,A);let q,ae;return h.isKanjiModeEnabled()?(q=y(c.BYTE,i.BYTE,A),ae=y(c.KANJI,i.KANJI,A)):(q=y(c.BYTE_KANJI,i.BYTE,A),ae=[]),_.concat(D,q,ae).sort(function(U,X){return U.index-X.index}).map(function(U){return{data:U.data,mode:U.mode,length:U.length}})}function v(A,_){switch(_){case i.NUMERIC:return r.getBitsLength(A);case i.ALPHANUMERIC:return a.getBitsLength(A);case i.KANJI:return d.getBitsLength(A);case i.BYTE:return u.getBitsLength(A)}}function x(A){return A.reduce(function(_,D){const q=_.length-1>=0?_[_.length-1]:null;return q&&q.mode===D.mode?(_[_.length-1].data+=D.data,_):(_.push(D),_)},[])}function j(A){const _=[];for(let D=0;D<A.length;D++){const q=A[D];switch(q.mode){case i.NUMERIC:_.push([q,{data:q.data,mode:i.ALPHANUMERIC,length:q.length},{data:q.data,mode:i.BYTE,length:q.length}]);break;case i.ALPHANUMERIC:_.push([q,{data:q.data,mode:i.BYTE,length:q.length}]);break;case i.KANJI:_.push([q,{data:q.data,mode:i.BYTE,length:m(q.data)}]);break;case i.BYTE:_.push([{data:q.data,mode:i.BYTE,length:m(q.data)}])}}return _}function R(A,_){const D={},q={start:{}};let ae=["start"];for(let N=0;N<A.length;N++){const U=A[N],X=[];for(let H=0;H<U.length;H++){const T=U[H],I=""+N+H;X.push(I),D[I]={node:T,lastCount:0},q[I]={};for(let L=0;L<ae.length;L++){const F=ae[L];D[F]&&D[F].node.mode===T.mode?(q[F][I]=v(D[F].lastCount+T.length,T.mode)-v(D[F].lastCount,T.mode),D[F].lastCount+=T.length):(D[F]&&(D[F].lastCount=T.length),q[F][I]=v(T.length,T.mode)+4+i.getCharCountIndicator(T.mode,_))}}ae=X}for(let N=0;N<ae.length;N++)q[ae[N]].end=0;return{map:q,table:D}}function C(A,_){let D;const q=i.getBestModeForData(A);if(D=i.from(_,q),D!==i.BYTE&&D.bit<q.bit)throw new Error('"'+A+'" cannot be encoded with mode '+i.toString(D)+`.
24
- Suggested mode is: `+i.toString(q));switch(D===i.KANJI&&!h.isKanjiModeEnabled()&&(D=i.BYTE),D){case i.NUMERIC:return new r(A);case i.ALPHANUMERIC:return new a(A);case i.KANJI:return new d(A);case i.BYTE:return new u(A)}}t.fromArray=function(_){return _.reduce(function(D,q){return typeof q=="string"?D.push(C(q,null)):q.data&&D.push(C(q.data,q.mode)),D},[])},t.fromString=function(_,D){const q=b(_,h.isKanjiModeEnabled()),ae=j(q),N=R(ae,D),U=p.find_path(N.map,"start","end"),X=[];for(let H=1;H<U.length-1;H++)X.push(N.table[U[H]].node);return t.fromArray(x(X))},t.rawSplit=function(_){return t.fromArray(b(_,h.isKanjiModeEnabled()))}})(gd)),gd}var zy;function AS(){if(zy)return id;zy=1;const t=Er(),i=Cf(),r=hS(),a=pS(),u=mS(),d=gS(),c=yS(),h=Wb(),p=xS(),m=wS(),y=SS(),b=Nr(),v=TS();function x(N,U){const X=N.size,H=d.getPositions(U);for(let T=0;T<H.length;T++){const I=H[T][0],L=H[T][1];for(let F=-1;F<=7;F++)if(!(I+F<=-1||X<=I+F))for(let W=-1;W<=7;W++)L+W<=-1||X<=L+W||(F>=0&&F<=6&&(W===0||W===6)||W>=0&&W<=6&&(F===0||F===6)||F>=2&&F<=4&&W>=2&&W<=4?N.set(I+F,L+W,!0,!0):N.set(I+F,L+W,!1,!0))}}function j(N){const U=N.size;for(let X=8;X<U-8;X++){const H=X%2===0;N.set(X,6,H,!0),N.set(6,X,H,!0)}}function R(N,U){const X=u.getPositions(U);for(let H=0;H<X.length;H++){const T=X[H][0],I=X[H][1];for(let L=-2;L<=2;L++)for(let F=-2;F<=2;F++)L===-2||L===2||F===-2||F===2||L===0&&F===0?N.set(T+L,I+F,!0,!0):N.set(T+L,I+F,!1,!0)}}function C(N,U){const X=N.size,H=m.getEncodedBits(U);let T,I,L;for(let F=0;F<18;F++)T=Math.floor(F/3),I=F%3+X-8-3,L=(H>>F&1)===1,N.set(T,I,L,!0),N.set(I,T,L,!0)}function A(N,U,X){const H=N.size,T=y.getEncodedBits(U,X);let I,L;for(I=0;I<15;I++)L=(T>>I&1)===1,I<6?N.set(I,8,L,!0):I<8?N.set(I+1,8,L,!0):N.set(H-15+I,8,L,!0),I<8?N.set(8,H-I-1,L,!0):I<9?N.set(8,15-I-1+1,L,!0):N.set(8,15-I-1,L,!0);N.set(H-8,8,1,!0)}function _(N,U){const X=N.size;let H=-1,T=X-1,I=7,L=0;for(let F=X-1;F>0;F-=2)for(F===6&&F--;;){for(let W=0;W<2;W++)if(!N.isReserved(T,F-W)){let ee=!1;L<U.length&&(ee=(U[L]>>>I&1)===1),N.set(T,F-W,ee),I--,I===-1&&(L++,I=7)}if(T+=H,T<0||X<=T){T-=H,H=-H;break}}}function D(N,U,X){const H=new r;X.forEach(function(W){H.put(W.mode.bit,4),H.put(W.getLength(),b.getCharCountIndicator(W.mode,N)),W.write(H)});const T=t.getSymbolTotalCodewords(N),I=h.getTotalCodewordsCount(N,U),L=(T-I)*8;for(H.getLengthInBits()+4<=L&&H.put(0,4);H.getLengthInBits()%8!==0;)H.putBit(0);const F=(L-H.getLengthInBits())/8;for(let W=0;W<F;W++)H.put(W%2?17:236,8);return q(H,N,U)}function q(N,U,X){const H=t.getSymbolTotalCodewords(U),T=h.getTotalCodewordsCount(U,X),I=H-T,L=h.getBlocksCount(U,X),F=H%L,W=L-F,ee=Math.floor(H/L),V=Math.floor(I/L),B=V+1,Q=ee-V,fe=new p(Q);let k=0;const O=new Array(L),re=new Array(L);let E=0;const J=new Uint8Array(N.buffer);for(let P=0;P<L;P++){const ve=P<W?V:B;O[P]=J.slice(k,k+ve),re[P]=fe.encode(O[P]),k+=ve,E=Math.max(E,ve)}const be=new Uint8Array(H);let Z=0,ne,ge;for(ne=0;ne<E;ne++)for(ge=0;ge<L;ge++)ne<O[ge].length&&(be[Z++]=O[ge][ne]);for(ne=0;ne<Q;ne++)for(ge=0;ge<L;ge++)be[Z++]=re[ge][ne];return be}function ae(N,U,X,H){let T;if(Array.isArray(N))T=v.fromArray(N);else if(typeof N=="string"){let ee=U;if(!ee){const V=v.rawSplit(N);ee=m.getBestVersionForData(V,X)}T=v.fromString(N,ee||40)}else throw new Error("Invalid data");const I=m.getBestVersionForData(T,X);if(!I)throw new Error("The amount of data is too big to be stored in a QR Code");if(!U)U=I;else if(U<I)throw new Error(`
25
- The chosen QR Code version cannot contain this amount of data.
26
- Minimum version required to store current data is: `+I+`.
27
- `);const L=D(U,X,T),F=t.getSymbolSize(U),W=new a(F);return x(W,U),j(W),R(W,U),A(W,X,0),U>=7&&C(W,U),_(W,L),isNaN(H)&&(H=c.getBestMask(W,A.bind(null,W,X))),c.applyMask(H,W),A(W,X,H),{modules:W,version:U,errorCorrectionLevel:X,maskPattern:H,segments:T}}return id.create=function(U,X){if(typeof U>"u"||U==="")throw new Error("No input text");let H=i.M,T,I;return typeof X<"u"&&(H=i.from(X.errorCorrectionLevel,i.M),T=m.from(X.version),I=c.from(X.maskPattern),X.toSJISFunc&&t.setToSJISFunction(X.toSJISFunc)),ae(U,T,H,I)},id}var Sd={},jd={},_y;function nv(){return _y||(_y=1,(function(t){function i(r){if(typeof r=="number"&&(r=r.toString()),typeof r!="string")throw new Error("Color should be defined as hex string");let a=r.slice().replace("#","").split("");if(a.length<3||a.length===5||a.length>8)throw new Error("Invalid hex color: "+r);(a.length===3||a.length===4)&&(a=Array.prototype.concat.apply([],a.map(function(d){return[d,d]}))),a.length===6&&a.push("F","F");const u=parseInt(a.join(""),16);return{r:u>>24&255,g:u>>16&255,b:u>>8&255,a:u&255,hex:"#"+a.slice(0,6).join("")}}t.getOptions=function(a){a||(a={}),a.color||(a.color={});const u=typeof a.margin>"u"||a.margin===null||a.margin<0?4:a.margin,d=a.width&&a.width>=21?a.width:void 0,c=a.scale||4;return{width:d,scale:d?4:c,margin:u,color:{dark:i(a.color.dark||"#000000ff"),light:i(a.color.light||"#ffffffff")},type:a.type,rendererOpts:a.rendererOpts||{}}},t.getScale=function(a,u){return u.width&&u.width>=a+u.margin*2?u.width/(a+u.margin*2):u.scale},t.getImageWidth=function(a,u){const d=t.getScale(a,u);return Math.floor((a+u.margin*2)*d)},t.qrToImageData=function(a,u,d){const c=u.modules.size,h=u.modules.data,p=t.getScale(c,d),m=Math.floor((c+d.margin*2)*p),y=d.margin*p,b=[d.color.light,d.color.dark];for(let v=0;v<m;v++)for(let x=0;x<m;x++){let j=(v*m+x)*4,R=d.color.light;if(v>=y&&x>=y&&v<m-y&&x<m-y){const C=Math.floor((v-y)/p),A=Math.floor((x-y)/p);R=b[h[C*c+A]?1:0]}a[j++]=R.r,a[j++]=R.g,a[j++]=R.b,a[j]=R.a}}})(jd)),jd}var Dy;function RS(){return Dy||(Dy=1,(function(t){const i=nv();function r(u,d,c){u.clearRect(0,0,d.width,d.height),d.style||(d.style={}),d.height=c,d.width=c,d.style.height=c+"px",d.style.width=c+"px"}function a(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(d,c,h){let p=h,m=c;typeof p>"u"&&(!c||!c.getContext)&&(p=c,c=void 0),c||(m=a()),p=i.getOptions(p);const y=i.getImageWidth(d.modules.size,p),b=m.getContext("2d"),v=b.createImageData(y,y);return i.qrToImageData(v.data,d,p),r(b,m,y),b.putImageData(v,0,0),m},t.renderToDataURL=function(d,c,h){let p=h;typeof p>"u"&&(!c||!c.getContext)&&(p=c,c=void 0),p||(p={});const m=t.render(d,c,p),y=p.type||"image/png",b=p.rendererOpts||{};return m.toDataURL(y,b.quality)}})(Sd)),Sd}var kd={},My;function zS(){if(My)return kd;My=1;const t=nv();function i(u,d){const c=u.a/255,h=d+'="'+u.hex+'"';return c<1?h+" "+d+'-opacity="'+c.toFixed(2).slice(1)+'"':h}function r(u,d,c){let h=u+d;return typeof c<"u"&&(h+=" "+c),h}function a(u,d,c){let h="",p=0,m=!1,y=0;for(let b=0;b<u.length;b++){const v=Math.floor(b%d),x=Math.floor(b/d);!v&&!m&&(m=!0),u[b]?(y++,b>0&&v>0&&u[b-1]||(h+=m?r("M",v+c,.5+x+c):r("m",p,0),p=0,m=!1),v+1<d&&u[b+1]||(h+=r("h",y),y=0)):p++}return h}return kd.render=function(d,c,h){const p=t.getOptions(c),m=d.modules.size,y=d.modules.data,b=m+p.margin*2,v=p.color.light.a?"<path "+i(p.color.light,"fill")+' d="M0 0h'+b+"v"+b+'H0z"/>':"",x="<path "+i(p.color.dark,"stroke")+' d="'+a(y,m,p.margin)+'"/>',j='viewBox="0 0 '+b+" "+b+'"',C='<svg xmlns="http://www.w3.org/2000/svg" '+(p.width?'width="'+p.width+'" height="'+p.width+'" ':"")+j+' shape-rendering="crispEdges">'+v+x+`</svg>
28
- `;return typeof h=="function"&&h(null,C),C},kd}var Oy;function _S(){if(Oy)return fl;Oy=1;const t=fS(),i=AS(),r=RS(),a=zS();function u(d,c,h,p,m){const y=[].slice.call(arguments,1),b=y.length,v=typeof y[b-1]=="function";if(!v&&!t())throw new Error("Callback required as last argument");if(v){if(b<2)throw new Error("Too few arguments provided");b===2?(m=h,h=c,c=p=void 0):b===3&&(c.getContext&&typeof m>"u"?(m=p,p=void 0):(m=p,p=h,h=c,c=void 0))}else{if(b<1)throw new Error("Too few arguments provided");return b===1?(h=c,c=p=void 0):b===2&&!c.getContext&&(p=h,h=c,c=void 0),new Promise(function(x,j){try{const R=i.create(h,p);x(d(R,c,p))}catch(R){j(R)}})}try{const x=i.create(h,p);m(null,d(x,c,p))}catch(x){m(x)}}return fl.create=i.create,fl.toCanvas=u.bind(null,r.render),fl.toDataURL=u.bind(null,r.renderToDataURL),fl.toString=u.bind(null,function(d,c,h){return a.render(d,h)}),fl}var DS=_S();const MS=ko(DS),OS={openPage:"打开授权页面",waitingBrowser:"在服务商页面完成授权,返回后会自动确认连接。",deviceInstruction:"在授权页面输入此验证码:",copy:"复制验证码",submit:"验证并保存",verifyCode:"输入服务商提供的验证码",secondFactor:"完成服务商要求的追加验证",detectSession:"检查登录状态",bindSession:"使用这个账号",loginSession:"登录账号",notInstalled:"此环境尚未安装对应 CLI。",notAuthenticated:"请先在当前环境登录对应 CLI,再检查状态。",authenticated:"已登录",processing:"正在确认并保存连接…",connected:"连接已保存。",cancelled:"授权已取消。",failed:"授权未完成,请重新连接。",expired:"授权已过期,请重新连接。",unsupported:"当前客户端不支持这个授权步骤,请更新客户端。",invalidUrl:"授权地址无效,请检查服务配置。",scan:"使用服务商的手机应用扫描二维码。",confirmOnPhone:"已扫码,请在手机上确认。",qrExpired:"二维码已过期。",refreshQr:"刷新二维码",qrError:"无法显示二维码,请重试。",qrAlt:"服务商授权二维码",confirm:"确认授权",resourcesTruncated:"此列表仅显示部分资源,请缩小选择范围后继续。",expiresAt:"有效期至",rejected:"服务商未接受此凭据,请检查后重试。",cliUnavailable:"此环境没有可用的 CLI 登录,请检查登录状态或选择其他方式。"};function LS(t){const i={...OS,...t.labels},r=Ni(t.authorization),[a,u]=S.useState({}),[d,c]=S.useState({}),[h,p]=S.useState(),[m,y]=S.useState(!1),[b,v]=S.useState(Date.now()),x=Math.min(t.authorization.expiresAt?Date.parse(t.authorization.expiresAt):1/0,r?Date.parse(r.expiresAt):1/0),j=r?.kind==="qr-code"&&r.qr?Date.parse(r.qr.challengeExpiresAt):1/0,R=r?.kind==="qr-code"&&r.phase!=="expired"?r.qr?.payload:void 0;if(S.useEffect(()=>{u({}),c({})},[t.authorization.id,r?.id]),S.useEffect(()=>{v(Date.now());const N=[x,j].filter(U=>Number.isFinite(U)&&U>Date.now()).map(U=>setTimeout(()=>v(Date.now()),U-Date.now()+1));return()=>{for(const U of N)clearTimeout(U)}},[x,j]),S.useEffect(()=>{let N=!0;if(p(void 0),y(!1),!R||R.length>4096||j<=Date.now()){R&&R.length>4096&&y(!0);return}return MS.toDataURL(R,{width:220,margin:2,errorCorrectionLevel:"M"}).then(U=>{N&&p(U)}).catch(()=>{N&&y(!0)}),()=>{N=!1}},[R,j]),t.authorization.state!=="pending"){const N=t.authorization.state==="connected"?t.authorization.connection?i.connected:i.processing:t.authorization.state==="cancelled"?i.cancelled:t.authorization.errorCode==="authorization_expired"?i.expired:i.failed;return s.jsx("p",{className:"link-authorization-status",role:"status",children:N})}if(!r)return s.jsx("p",{role:"alert",children:i.unsupported});if(!Number.isFinite(x)||x<=b)return s.jsx("p",{className:"link-authorization-status",role:"status",children:i.expired});const C=!!t.busy,A=(N,U)=>t.onRespond({stepId:r.id,operation:N,...U?{input:U}:{}}),_=N=>{if(t.canOpenUrl===!1)return null;const U=O1(N);return U?s.jsxs("button",{type:"button",disabled:C,onClick:()=>t.onOpenUrl(U),children:[i.openPage," ↗"]}):s.jsx("p",{role:"alert",children:i.invalidUrl})},D=s.jsxs("p",{className:"link-authorization-expires",children:[i.expiresAt," ",new Date(x).toLocaleTimeString()]}),q=t.authorization.errorCode?s.jsx("p",{className:"link-authorization-error",role:"alert",children:t.authorization.errorCode==="provider_rejected"?i.rejected:t.authorization.errorCode==="cli_unavailable"?i.cliUnavailable:i.failed}):null,ae=()=>{switch(r.kind){case"redirect":return s.jsxs("div",{className:"link-authorization-step",role:"status",children:[s.jsx("p",{children:i.waitingBrowser}),_(r.authorizationUrl),D]});case"device-code":return s.jsxs("div",{className:"link-authorization-step link-authorization-device",children:[s.jsx("p",{children:i.deviceInstruction}),s.jsx("strong",{className:"link-authorization-code",children:r.userCode}),s.jsxs("div",{className:"link-authorization-actions",children:[t.onCopy&&s.jsx("button",{type:"button",onClick:()=>t.onCopy?.(r.userCode),children:i.copy}),_(r.verificationUriComplete??r.verificationUri)]}),D]});case"qr-code":{const N=r.phase==="expired"||j<=b;return s.jsxs("div",{className:"link-authorization-step link-authorization-qr",children:[s.jsx("p",{role:"status",children:N?i.qrExpired:r.phase==="awaiting-confirmation"?i.confirmOnPhone:i.scan}),!N&&h&&s.jsx("img",{width:220,height:220,src:h,alt:i.qrAlt}),!N&&m&&s.jsx("p",{role:"alert",children:i.qrError}),!N&&r.qr?.instructions.map((U,X)=>s.jsx("p",{children:U},X)),r.canRefresh&&s.jsx("button",{type:"button",disabled:C,onClick:()=>A("refresh-qr"),children:i.refreshQr}),D]})}case"credential-input":return s.jsxs("form",{className:"link-authorization-step link-authorization-fields",onSubmit:N=>{if(N.preventDefault(),C)return;const U={};for(const X of r.fields)U[X.id]=a[X.id]??"";u({}),A("submit",U)},children:[r.purpose!=="credential"&&s.jsx("p",{children:r.purpose==="verification-code"?i.verifyCode:i.secondFactor}),r.fields.map(N=>s.jsxs("label",{children:[N.label,s.jsx("input",{name:N.id,type:N.secret?"password":"text",autoComplete:"off",spellCheck:!1,value:a[N.id]??"",placeholder:N.placeholder,maxLength:Math.min(N.maxLength??16384,16384),required:N.required,disabled:C,onChange:U=>u(X=>({...X,[N.id]:U.target.value}))})]},N.id)),s.jsx("button",{type:"submit",disabled:C||r.fields.some(N=>N.required&&!a[N.id]?.trim()),children:i.submit}),D]});case"local-session":return s.jsxs("div",{className:"link-authorization-step",children:[s.jsx("p",{role:"status",children:r.session.authenticated?`${i.authenticated}${r.session.account?`:${r.session.account}`:""}`:r.session.installed?i.notAuthenticated:i.notInstalled}),r.session.message&&s.jsx("p",{children:r.session.message}),s.jsxs("div",{className:"link-authorization-actions",children:[s.jsx("button",{type:"button",disabled:C,onClick:()=>A("detect-session"),children:i.detectSession}),!r.session.authenticated&&r.session.canLogin&&s.jsx("button",{type:"button",disabled:C,onClick:()=>A("login-session"),children:i.loginSession}),r.session.authenticated&&s.jsx("button",{type:"button",disabled:C,onClick:()=>A("bind-session"),children:i.bindSession})]}),D]});case"consent":{const N=d.permissions??r.permissions.filter(H=>H.required).map(H=>H.id),U=(H,T,I,L)=>c(F=>({...F,[H]:I?[...new Set([...L,T])]:L.filter(W=>W!==T)})),X=r.resourceGroups.some(H=>{const T=(d[H.id]??[]).length;return T<(H.minSelected??0)||T>(H.maxSelected??1/0)||H.truncated});return s.jsxs("form",{className:"link-authorization-step link-authorization-consent",onSubmit:H=>{H.preventDefault(),!C&&!X&&A("confirm",{...d,permissions:N})},children:[s.jsx("p",{children:s.jsx("strong",{children:r.account.label})}),s.jsx("div",{children:r.permissions.map(H=>s.jsxs("label",{children:[s.jsx("input",{type:"checkbox",checked:H.required||N.includes(H.id),disabled:C||H.required,onChange:T=>U("permissions",H.id,T.target.checked,N)}),H.label,H.description&&s.jsx("small",{children:H.description})]},H.id))}),r.resourceGroups.map(H=>s.jsxs("fieldset",{children:[s.jsx("legend",{children:H.label}),H.items.map(T=>s.jsxs("label",{children:[s.jsx("input",{type:"checkbox",checked:(d[H.id]??[]).includes(T.id),disabled:C,onChange:I=>U(H.id,T.id,I.target.checked,d[H.id]??[])}),T.label,T.description&&s.jsx("small",{children:T.description})]},T.id)),H.truncated&&s.jsx("p",{children:i.resourcesTruncated})]},H.id)),s.jsx("button",{type:"submit",disabled:C||X,children:i.confirm}),D]})}case"processing":return s.jsx("p",{className:"link-authorization-status",role:"status",children:i.processing});default:return s.jsx("p",{role:"alert",children:i.unsupported})}};return s.jsxs(s.Fragment,{children:[q,ae()]})}const Pn="/api/v1/links",BS={connected:"已连接",expired:"授权已过期",invalid:"需要重新连接",unavailable:"凭据不可用"};function hl(t){try{const i=new URL(t??"");return i.protocol==="https:"&&!i.username&&!i.password?i.href:void 0}catch{return}}function US({onAuthLost:t,onDirtyChange:i,hostLabel:r="服务端",configurationVersion:a=0}){const[u,d]=S.useState(),[c,h]=S.useState(),[p,m]=S.useState(""),[y,b]=S.useState(""),[v,x]=S.useState(""),[j,R]=S.useState(!0),[C,A]=S.useState(!1),[_,D]=S.useState(),[q,ae]=S.useState(),[N,U]=S.useState(),[X,H]=S.useState(),T=S.useRef(new Map),I=S.useRef(new Set),[L,F]=S.useState(),W=S.useMemo(()=>new U1({begin:async(M,ie)=>{const ye=mo(),{workspace:xe,projectId:Ce}=ye,Ae=await Ue(kt(`${Pn}/authorizations`,xe,Ce),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...M,authModeId:ie})},ye);return T.current.set(Ae.id,{target:kt(`${Pn}/authorizations/${encodeURIComponent(Ae.id)}`,xe,Ce),scope:ye}),Ae},status:M=>{const ie=T.current.get(M);return Ue(ie.target,{},ie.scope)},respond:(M,ie)=>{const ye=T.current.get(M),xe=new URL(ye.target,window.location.origin);return xe.pathname+="/responses",Ue(xe.pathname+xe.search,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ie)},ye.scope)},cancel:async M=>{if(I.current.has(M))return;const ie=T.current.get(M);ie&&(await Ue(ie.target,{method:"DELETE",keepalive:!0},ie.scope),T.current.delete(M))}}),[]),ee=S.useSyncExternalStore(W.subscribe,W.getSnapshot),V=u?.capabilities.authorizationSteps===1&&!!c?.provider.authModes,B=V&&ee.authorization?.state==="pending",[Q,fe]=S.useState(0),k=S.useRef(!1),O=S.useRef(0),re=S.useRef(null),E=S.useRef(void 0),J=S.useRef(void 0),be=S.useRef(void 0),Z=S.useRef(void 0),ne=S.useRef({onAuthLost:t,onDirtyChange:i});ne.current={onAuthLost:t,onDirtyChange:i};const ge=C||ee.busy||B||N?.state==="pending"||!!(c&&(c.token||c.label!==(c.original?.label??c.provider.displayName))),P=S.useCallback(M=>{M instanceof Ze&&M.status===401?ne.current.onAuthLost():b(M instanceof Error?M.message:"连接操作失败,请重试。")},[]);S.useEffect(()=>{if(!c)return;const M=document.activeElement;return re.current?.querySelector("input:not(:disabled), button:not(:disabled)")?.focus(),()=>M?.focus?.()},[!!c]),S.useEffect(()=>{ne.current.onDirtyChange?.(ge)},[ge]),S.useEffect(()=>{k.current=!0;const M=++O.current;return()=>{k.current=!1,ne.current.onDirtyChange?.(!1),E.current?.abort(),queueMicrotask(()=>{O.current===M&&W.dispose()}),J.current&&Ue(J.current,{method:"DELETE",keepalive:!0},be.current).catch(()=>{})}},[W]),S.useEffect(()=>{const M=new AbortController;return Z.current=M,R(!0),Ue(Pn,{signal:M.signal}).then(ie=>{M.signal.aborted||d(ie)}).catch(ie=>{M.signal.aborted||P(ie)}).finally(()=>{M.signal.aborted||R(!1)}),()=>M.abort()},[Q,a,P]),S.useEffect(()=>{V&&(ee.error&&P(ee.error),ee.authorization?.state==="connected"&&ee.authorization.connection&&(h(void 0),x("授权完成,连接已保存。"),fe(M=>M+1)))},[V,ee.authorization,ee.error,P]),S.useEffect(()=>{if(!u?.remoteCleanupPending)return;const M=setInterval(()=>fe(ie=>ie+1),3e4);return()=>clearInterval(M)},[u?.remoteCleanupPending]),S.useEffect(()=>{if(N?.state!=="pending"||!J.current)return;const M=J.current,ie=be.current,ye=new AbortController;let xe;const Ce=async()=>{try{const Ae=await Ue(M,{signal:ye.signal},ie);if(ye.signal.aborted||J.current!==M)return;U(Ae),Ae.state==="connected"?(J.current=void 0,h(void 0),x("授权完成,连接已保存。"),fe(Pe=>Pe+1)):Ae.state!=="pending"?(J.current=void 0,b(Ae.state==="cancelled"?"授权已取消。":"授权未完成或已过期,请重新开始。")):xe=setTimeout(()=>{Ce()},2e3)}catch(Ae){if(ye.signal.aborted||J.current!==M)return;P(Ae),Ae instanceof Ze&&[401,404].includes(Ae.status)?(J.current=void 0,U(Pe=>Pe?{...Pe,state:"failed"}:void 0)):xe=setTimeout(()=>{Ce()},4e3)}};return xe=setTimeout(()=>{Ce()},1e3),()=>{ye.abort(),clearTimeout(xe)}},[N?.id,N?.state,P]);async function ve(M,ie){if(E.current)return;const ye=new AbortController;E.current=ye,Z.current?.abort(),A(!0),R(!1),b(""),x("");try{const xe=await M(ye.signal);k.current&&!ye.signal.aborted&&ie(xe)}catch(xe){k.current&&!ye.signal.aborted&&(P(xe),xe instanceof Ze&&[409,503].includes(xe.status)&&fe(Ce=>Ce+1))}finally{E.current===ye&&(E.current=void 0),k.current&&A(!1)}}function De(M,ie,ye,xe,Ce){return Ue(M,{method:ie,headers:{"Content-Type":"application/json"},body:JSON.stringify(ye),signal:xe},Ce)}function ze(){return{providerId:c.provider.id,methodId:c.methodId,label:c.label.trim(),expectedRevision:c.original?.revision??null,...c.original?{connectionId:c.original.id}:{}}}function _e(){h(void 0),ae(void 0),x("连接已保存。"),fe(M=>M+1)}function Ge(M,ie){if(C||ee.busy||B||N?.state==="pending"||ge&&!window.confirm("放弃当前未保存的连接修改?"))return;W.reset();const ye=ie?$c(M,ie.methodId):$c(M),xe=ie?M.connectionMethods.find(Ae=>Ae.id===ie.methodId):M.connectionMethods.find(Ae=>Ae.id===ye?.methodId)??M.connectionMethods.find(Ae=>Ae.executionRuntime==="local"&&Ae.availability==="available");if(!xe){b("当前环境未提供此连接的授权方式,请检查服务器连接设置。");return}const Ce={provider:M,original:ie,methodId:xe.id,label:ie?.label??M.displayName,token:""};h(Ce),ae(void 0),U(void 0),H(ye?.id),b(""),x(""),!ie&&u?.capabilities.authorizationSteps===1&&ye&&ft(Ce,ye)}async function ft(M,ie){if(!ie.available||!M.label.trim()||W.getSnapshot().authorization?.state==="pending"&&(await W.cancel(),W.getSnapshot().authorization?.state==="pending"))return;b(""),H(ie.id),h({...M,methodId:ie.methodId});const ye={workspace:go()??"",projectId:Ta()},xe=await W.begin({providerId:M.provider.id,methodId:ie.methodId,label:M.label.trim(),expectedRevision:M.original?.revision??null,...M.original?{connectionId:M.original.id}:{}},ie.id);if(!(xe?.state!=="pending"||Ni(xe)?.kind!=="redirect"))try{if(u?.capabilities.browserHandoff===1){const Pe=T.current.get(xe.id),wt=new URL(Pe.target,window.location.origin);wt.pathname+="/browser";const ct=await Ue(wt.pathname+wt.search,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"},Pe.scope),mt=new URL(ct.launchUrl);if(mt.origin!==window.location.origin||mt.pathname!=="/link/authorize"||mt.username||mt.password||mt.hash||mt.searchParams.size!==1||!/^[A-Za-z0-9_-]{43}$/.test(mt.searchParams.get("ticket")??""))throw new Error("授权浏览器入口无效,请重新连接。");W.getSnapshot().authorization?.id===xe.id&&W.getSnapshot().authorization?.state==="pending"&&F({id:xe.id,url:mt.href});return}const Ce=u?.remoteServer?.issuer;if(!Ce)throw new Error("当前 Host 尚未配置授权服务。");const Ae=H1(xe,Ce,ye);I.current.add(xe.id),Pw.flushSync(()=>{h(void 0),ne.current.onDirtyChange?.(!1)}),window.location.assign(Ae)}catch(Ce){await W.cancel(),P(Ce)}}async function xt(){if(B){await W.cancel(),W.getSnapshot().authorization?.state==="cancelled"&&x("授权已取消。");return}if(!J.current)return;const M=J.current,ie=be.current;await ve(ye=>Ue(M,{method:"DELETE",signal:ye},ie),()=>{J.current=void 0,U(void 0),x("授权已取消。")})}function Ke(){V?W.cancel().then(()=>{W.getSnapshot().authorization?.state!=="pending"&&h(void 0)}):!Je&&(!ge||window.confirm("放弃未保存的连接修改?"))&&h(void 0)}function Tt(M,ie=mo()){if(V&&W.getSnapshot().authorization?.state==="pending"&&c?.original?.id===M.id){W.cancel().then(()=>{W.getSnapshot().authorization?.state!=="pending"&&Tt(M,ie)});return}const ye=c?.original?.id===M.id&&N?.state==="pending"?J.current:void 0,xe=kt(`${Pn}/connections/${encodeURIComponent(M.id)}`,ie.workspace,ie.projectId),Ce=be.current;ve(async Ae=>{if(ye){try{await Ue(ye,{method:"DELETE",signal:Ae},Ce)}catch(Pe){if(!(Pe instanceof Ze&&Pe.status===404))throw Pe}k.current&&!Ae.aborted&&J.current===ye&&(J.current=void 0,U(void 0))}return De(xe,"DELETE",{expectedRevision:M.revision},Ae,ie)},()=>{c?.original?.id===M.id&&h(void 0),D(void 0),fe(Ae=>Ae+1),x("连接已断开。")})}const Be=c?.provider.connectionMethods.find(M=>M.id===c.methodId),At=N?.state==="pending",Je=C||ee.busy||At||B,Fe=p.trim().toLowerCase(),Lt=(u?.providers??[]).filter(M=>(u?.capabilities.authorizationSteps!==1||M.authModes?.some(ie=>ie.available))&&`${M.displayName} ${M.description.zh}`.toLowerCase().includes(Fe)),Ie=c&&u?.connections.find(M=>c.original?M.id===c.original.id:M.id===`link-${c.provider.id}-${c.methodId}`&&M.providerId===c.provider.id&&M.methodId===c.methodId),pt=c&&u&&(c.original?Ie?.revision!==c.original.revision:!!Ie);return s.jsxs("section",{className:"hub-links",children:[s.jsxs("header",{className:"links-heading",children:[s.jsxs("div",{children:[s.jsx("h1",{children:"Link"}),s.jsx("p",{children:"连接你的工具与账号,让任务访问已授权的服务。"})]}),s.jsx("button",{onClick:()=>{b(""),fe(M=>M+1)},disabled:C||j,children:"刷新"})]}),!!u?.remoteCleanupPending&&s.jsxs("p",{role:"status",className:"links-muted",children:["有 ",u.remoteCleanupPending," 项遗留授权等待撤销。项目所在环境 会自动重试,重启后仍会继续;也可在 Link 服务中撤销。"]}),s.jsxs("p",{className:"links-host",children:["连接由当前项目所属的",r,"管理,授权后只访问你允许的服务与资源。"]}),y&&s.jsx("p",{className:"form-error",role:"alert",children:y}),v&&s.jsx("p",{className:"links-notice",role:"status",children:v}),j&&!u&&s.jsx("p",{role:"status",children:"正在加载连接…"}),s.jsx("h2",{children:"已连接"}),u&&u.connections.length===0&&s.jsx("p",{className:"links-muted",children:"还没有连接。选择下面的服务开始。"}),s.jsx("div",{className:"links-connections",children:u?.connections.map(M=>{const ie=u.providers.find(ye=>ye.id===M.providerId);return s.jsxs("article",{className:"links-connection",children:[s.jsxs("div",{children:[s.jsx("strong",{children:M.label}),s.jsxs("p",{children:[ie?.displayName??M.providerId," ·"," ",M.account?.label??M.account?.id??"已授权账号"]}),s.jsx("span",{className:`links-state ${M.status==="connected"?"ready":""}`,children:BS[M.status]}),s.jsxs("small",{children:[M.authSource==="remote-link"?"独立 Link 授权":M.authSource==="cli-session"?"CLI 登录":M.authSource==="browser-oauth"?"浏览器授权":"Token",M.expiresAt?` · 到期 ${new Date(M.expiresAt).toLocaleString()}`:""]}),M.account?.resources.length?s.jsx("p",{children:M.account.resources.join("、")}):null]}),s.jsx("div",{className:"links-actions",children:M.editable?s.jsxs(s.Fragment,{children:[s.jsx("button",{disabled:Je||!ie,onClick:()=>ie&&Ge(ie,M),children:"管理连接"}),s.jsx("button",{disabled:C,onClick:()=>D(M),children:"断开"})]}):s.jsx("small",{children:"项目配置管理"})})]},M.id)})}),_&&s.jsxs("div",{className:"links-confirm",role:"alertdialog","aria-label":"断开连接",children:[s.jsxs("p",{children:["断开「",_.label,"」后,后续任务将无法使用这个连接,正在执行的请求会尝试停止。"]}),s.jsx("button",{disabled:C,onClick:()=>Tt(_),children:"确认断开"}),s.jsx("button",{disabled:C,onClick:()=>D(void 0),children:"取消"})]}),c&&Be&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"links-editor-backdrop","aria-hidden":"true"}),s.jsxs("section",{className:"links-editor",ref:re,onKeyDown:M=>{if(M.key==="Escape"&&(M.preventDefault(),Ke()),M.key!=="Tab")return;const ie=re.current?.querySelectorAll("button:not(:disabled), input:not(:disabled), a[href], summary");if(!ie?.length)return;const ye=ie[0],xe=ie[ie.length-1];M.shiftKey&&document.activeElement===ye?(M.preventDefault(),xe.focus()):!M.shiftKey&&document.activeElement===xe&&(M.preventDefault(),ye.focus())},role:"dialog","aria-modal":"true","aria-label":`${c.provider.displayName} 连接设置`,children:[s.jsxs("div",{className:"links-heading",children:[s.jsxs("h2",{children:[c.provider.displayName," · ",c.original?"管理连接":"添加连接"]}),s.jsx("button",{disabled:!V&&Je,onClick:Ke,children:"关闭"})]}),s.jsxs("label",{children:["连接名称",s.jsx("input",{maxLength:100,value:c.label,disabled:Je,onChange:M=>h({...c,label:M.target.value})})]}),pt&&s.jsxs("div",{className:"links-conflict",role:"alert",children:[s.jsx("p",{children:"这个连接已在其他设备创建、修改或删除。你的输入仍然保留,请先载入最新版本。"}),s.jsx("button",{disabled:Je,onClick:()=>h({...c,original:Ie||void 0}),children:"载入最新版本,保留输入"})]}),V?s.jsxs("div",{className:"links-authorization",children:[s.jsx("p",{className:"links-muted",children:Be.executionRuntime==="server"?"由 Link 服务保存授权并访问已选择的资源。":`连接保存到当前项目所属的${r}。`}),ee.authorization?s.jsx(LS,{authorization:ee.authorization,busy:ee.busy||!!pt||u?.capabilities.browserHandoff===1&&Ni(ee.authorization)?.kind==="redirect"&&L?.id!==ee.authorization.id,onRespond:M=>{W.respond(M)},onOpenUrl:M=>{const ye=u?.capabilities.browserHandoff===1&&Ni(ee.authorization)?.kind==="redirect"?L&&L.id===ee.authorization?.id?L.url:void 0:M;ye&&window.open(ye,"_blank","noopener,noreferrer")},onCopy:M=>{navigator.clipboard?.writeText(M).catch(P)}}):s.jsx("button",{disabled:ee.busy||!!pt||!c.label.trim(),onClick:()=>{const M=c.provider.authModes?.find(ie=>ie.id===X&&ie.available)??$c(c.provider,c.methodId);M&&ft(c,M)},children:ee.busy?"正在连接…":c.original?"重新连接":"开始连接"}),s.jsxs("div",{className:"links-actions",children:[B&&s.jsx("button",{disabled:ee.busy,onClick:()=>{xt()},children:"取消授权"}),ee.authorization&&ee.authorization.state!=="pending"&&s.jsx("button",{disabled:ee.busy||!!pt||!c.label.trim(),onClick:()=>{const M=c.provider.authModes?.find(ie=>ie.id===X&&ie.available);M&&ft(c,M)},children:"重新连接"})]}),s.jsxs("details",{className:"links-other-methods",children:[s.jsx("summary",{children:"其他连接方式"}),s.jsx("div",{className:"links-methods",children:c.provider.authModes?.map(M=>s.jsxs("button",{disabled:ee.busy||!M.available||!!pt||!c.label.trim(),title:M.unavailableReason,onClick:()=>{ft(c,M)},children:[M.label,M.id===X?" · 当前":""]},M.id))})]}),c.original&&s.jsx("button",{disabled:Je||!!pt||!c.label.trim(),onClick:()=>{ve(M=>De(`${Pn}/connections/${encodeURIComponent(c.original.id)}`,"PATCH",{label:c.label.trim(),expectedRevision:c.original.revision},M),_e)},children:"保存名称"})]}):s.jsxs(s.Fragment,{children:[Be.browserAuth&&s.jsxs("div",{className:"links-auth-option",children:[s.jsx("h3",{children:"浏览器授权"}),c.provider.deviceAuth?.configured?s.jsx("button",{disabled:Je||!c.label.trim()||!!pt,onClick:()=>{const M=go()??"",ie=Ta(),ye={workspace:M,projectId:ie},xe=kt(`${Pn}/authorizations/device`,M,ie);ve(Ce=>De(xe,"POST",ze(),Ce,ye),Ce=>{J.current=kt(`${Pn}/authorizations/${encodeURIComponent(Ce.id)}`,M,ie),be.current=ye,U(Ce)})},children:"开始授权"}):s.jsxs("p",{className:"links-muted",children:["这台",r,"尚未配置此服务的浏览器授权,可使用下面的连接方式。"]}),At&&N.prompt&&s.jsxs("div",{className:"links-device-code",role:"status",children:[s.jsx("p",{children:"在服务商页面输入验证码:"}),s.jsx("strong",{children:N.prompt.userCode}),s.jsx("p",{children:hl(N.prompt.verificationUriComplete??N.prompt.verificationUri)&&s.jsx("a",{href:hl(N.prompt.verificationUriComplete??N.prompt.verificationUri),target:"_blank",rel:"noreferrer",children:"打开授权页面 ↗"})}),s.jsxs("p",{children:["完成后会自动保存。有效期至"," ",new Date(N.prompt.expiresAt).toLocaleTimeString(),"。"]}),s.jsx("button",{disabled:C,onClick:()=>{xt()},children:"取消授权"})]})]}),Be.quickAuth&&s.jsxs("div",{className:"links-auth-option",children:[s.jsx("h3",{children:"使用已登录的 CLI"}),s.jsxs("p",{children:[r,"需要已安装并登录 ",Be.quickAuth.command,"。"]}),s.jsx("button",{disabled:Je,onClick:()=>{ve(M=>Ue(`${Pn}/providers/${encodeURIComponent(c.provider.id)}/cli`,{signal:M}),ae)},children:"检查登录状态"}),q&&s.jsx("p",{role:"status",children:q.authenticated?`已登录${q.account?`:${q.account}`:""}`:q.installed?"已安装,尚未登录。请在运行服务的机器上登录。":"尚未安装。"}),q?.authenticated&&s.jsx("button",{disabled:Je||!c.label.trim()||!!pt,onClick:()=>{ve(M=>De(`${Pn}/connections/cli`,"POST",ze(),M),_e)},children:"绑定这个登录"})]}),Be.authKind==="token"&&s.jsxs("form",{className:"links-auth-option",onSubmit:M=>{M.preventDefault(),!(Je||pt)&&ve(ie=>c.original&&!c.token.trim()?De(`${Pn}/connections/${encodeURIComponent(c.original.id)}`,"PATCH",{label:c.label.trim(),expectedRevision:c.original.revision},ie):De(`${Pn}/connections/token`,"POST",{...ze(),token:c.token.trim()},ie),_e)},children:[s.jsx("h3",{children:c.original?"名称与 Token":"使用 Token"}),Be.authGuide&&s.jsxs(s.Fragment,{children:[s.jsx("p",{children:Be.authGuide.summary.zh}),s.jsxs("div",{className:"links-actions",children:[hl(Be.authGuide.createCredentialUrl)&&s.jsx("a",{href:hl(Be.authGuide.createCredentialUrl),target:"_blank",rel:"noreferrer",children:"创建凭据 ↗"}),hl(Be.authGuide.docsUrl)&&s.jsx("a",{href:hl(Be.authGuide.docsUrl),target:"_blank",rel:"noreferrer",children:"授权说明 ↗"})]}),s.jsxs("details",{children:[s.jsx("summary",{children:"所需权限与设置步骤"}),s.jsx("ul",{children:Be.authGuide.permissions.map(M=>s.jsxs("li",{children:[M.label,"(",M.level==="required"?"必需":"可选",")",M.description?`:${M.description.zh}`:""]},M.id))}),s.jsx("ol",{children:Be.authGuide.steps.map((M,ie)=>s.jsx("li",{children:M.zh},ie))})]})]}),s.jsxs("label",{children:[Be.tokenLabel??c.provider.tokenLabel,s.jsx("input",{type:"password",autoComplete:"off",value:c.token,disabled:Je,placeholder:c.original?"留空保留当前授权,仅修改名称":Be.tokenPlaceholder??c.provider.tokenPlaceholder,onChange:M=>h({...c,token:M.target.value}),required:!c.original,maxLength:16384})]}),s.jsx("button",{type:"submit",className:"send",disabled:Je||!!pt||!c.label.trim(),children:C?"正在验证并保存…":c.token.trim()||!c.original?"验证并保存":"保存名称"})]})]}),s.jsxs("details",{children:[s.jsxs("summary",{children:[V?"服务支持的操作":"可用操作","(",c.provider.actions.length,")"]}),V&&s.jsx("p",{className:"links-muted",children:"此连接实际可用的操作以授权时确认的权限为准。"}),s.jsx("ul",{children:c.provider.actions.map(M=>s.jsxs("li",{children:[s.jsx("strong",{children:M.title}),M.risk==="write"?" · 执行前需要确认":"",s.jsx("p",{children:M.description})]},M.id))})]})]})]}),s.jsxs("div",{className:"links-heading",children:[s.jsx("h2",{children:"添加服务"}),s.jsx("input",{type:"search","aria-label":"搜索 Link 服务",placeholder:"搜索服务",value:p,onChange:M=>m(M.target.value)})]}),s.jsx("div",{className:"links-providers",children:Lt.map(M=>{const ie=u?.connections.find(ye=>ye.providerId===M.id);return s.jsxs("article",{className:"links-provider",children:[s.jsx("div",{className:`links-brand accent-${M.accent}`,"aria-hidden":"true",children:M.brandText}),s.jsx("h3",{children:M.displayName}),s.jsx("p",{children:M.description.zh}),s.jsxs("small",{children:[M.actions.length," 项操作"]}),s.jsx("button",{disabled:Je||u?.capabilities.authorizationSteps!==1&&!!(ie&&!ie.editable),onClick:()=>Ge(M,u?.capabilities.authorizationSteps===1?void 0:ie),children:u?.capabilities.authorizationSteps===1?"添加连接":ie?ie.editable?"管理连接":"项目配置管理":"添加连接"})]},M.id)})}),u&&Lt.length===0&&s.jsx("p",{className:"links-muted",children:"没有匹配的服务。"})]})}const Cd="/api/v1/panels",Ly="https://github.com/cjhyy/codeshell-panel-apps.git",By={"context.session":"读取当前对话信息","context.workspace":"读取当前工作区信息",storage:"保存面板自己的数据","external.open":"打开外部网页","agent.submitPrompt":"向当前对话提交任务","agent.task":"创建和管理 Agent 任务","workspace.info":"查看工作区信息","workspace.read":"读取工作区文件","workspace.write":"修改工作区文件","notifications.send":"发送通知","audio.transcribe":"将音频转成文字","credentials.cookies":"使用宿主授权的浏览器 Cookie","automations.manage":"管理自动化任务",process:"在宿主运行命令和进程",media:"处理宿主上的音视频文件","media.capture":"使用麦克风、摄像头或屏幕录制"};function Yn(t){return t["zh-CN"]||t.default}function io({value:t}){return t.supported&&t.reasons.length===0?null:s.jsxs("div",{className:"panels-warning",children:[s.jsx("strong",{children:t.supported?"部分功能可用":"当前 Web 工作台暂不支持此面板"}),t.supported&&s.jsx("p",{children:"可以打开面板,以下功能当前不可用或需要额外配置。"}),t.reasons.length>0&&s.jsx("ul",{children:t.reasons.map(i=>s.jsx("li",{children:i},i))})]})}function IS({onAuthLost:t,onDirtyChange:i,onChanged:r,onOpen:a,hostLabel:u="服务端",configurationVersion:d=0}){const[c,h]=S.useState(),[p,m]=S.useState(""),[y,b]=S.useState(""),[v,x]=S.useState(""),[j,R]=S.useState(""),[C,A]=S.useState(),[_,D]=S.useState(),[q,ae]=S.useState(),[N,U]=S.useState(),[X,H]=S.useState(!1),[T,I]=S.useState(),[L,F]=S.useState(),[W,ee]=S.useState(!1),[V,B]=S.useState(!0),[Q,fe]=S.useState(!1),[k,O]=S.useState(),[re,E]=S.useState(!0),[J,be]=S.useState(""),[Z,ne]=S.useState(""),[ge,P]=S.useState(""),[ve,De]=S.useState(0),ze=S.useRef(!1),_e=S.useRef(void 0),Ge=S.useRef(void 0),ft=S.useRef(!1),xt=S.useRef(void 0),Ke=S.useRef(null),Tt=S.useRef({onAuthLost:t,onDirtyChange:i,onChanged:r,onOpen:a});Tt.current={onAuthLost:t,onDirtyChange:i,onChanged:r,onOpen:a};function Be(G){fetch(G.target,{method:"DELETE",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify({reviewToken:G.token}),keepalive:!0,signal:AbortSignal.timeout(5e3)}).catch(()=>{})}const At=!!(J||_||q||L||k||p.trim()||y.trim()||v.trim()),Je=S.useCallback(G=>{G instanceof Ze&&G.status===401?Tt.current.onAuthLost():ne(G instanceof Error?G.message:"面板操作失败,请重试。")},[]);S.useEffect(()=>(ze.current=!0,()=>{ze.current=!1,_e.current?.abort(),Ge.current?.abort(),xt.current&&(Be(xt.current),xt.current=void 0),Tt.current.onDirtyChange?.(!1)}),[]),S.useEffect(()=>{Tt.current.onDirtyChange?.(At)},[At]),S.useEffect(()=>{if(_e.current){ft.current=!0;return}const G=new AbortController;return Ge.current=G,E(!0),Ue(kt(Cd),{signal:G.signal}).then(ce=>{G.signal.aborted||h(ce)}).catch(ce=>{G.signal.aborted||Je(ce)}).finally(()=>{G.signal.aborted||E(!1)}),()=>G.abort()},[ve,d,Je]),S.useEffect(()=>{_&&Ke.current?.focus()},[_?.reviewToken]);async function Fe(G,ce,qe,He,Yt=!1,Qe){if(_e.current||!ze.current)return;const ot=new AbortController;_e.current=ot,Ge.current?.abort(),E(!1),be(G),ne(""),P("");const tt=kt(`${Cd}${ce}`);try{const ht=await Ue(tt,{method:qe,headers:{"Content-Type":"application/json"},body:JSON.stringify(He),signal:ot.signal});if(ot.signal.aborted||!ze.current){Qe?.(ht);return}return Yt&&(ft.current=!0,Tt.current.onChanged?.()),ht}catch(ht){if(ot.signal.aborted||!ze.current)return;ht instanceof Ze&&(ht.status===409||ht.status===410)&&(_&&ee(!0),N&&H(!0),ft.current=!0),Je(ht);return}finally{_e.current===ot&&(_e.current=void 0),ze.current&&!ot.signal.aborted&&(be(""),ft.current&&(ft.current=!1,De(ht=>ht+1)))}}const Lt=async G=>{if(!await Pe())return;ae(void 0),U(void 0),F(void 0),D(void 0),O(void 0),A(void 0);const ce=await Fe("正在读取仓库…","/github/discover","POST",{url:G.url,...G.ref?{ref:G.ref}:{},...G.subdir?{subdir:G.subdir}:{}});ce&&A(ce)},Ie=async G=>{if(!await Pe())return;ae(void 0),U(void 0);const ce=await Fe("正在准备安装审阅…","/preview","POST",{source:G});ce&&(O(void 0),I(G),D(ce),ee(!1),fe(!1),B(!!c?.hasProject&&ce.compatibility.supported))},pt=async G=>{if(!await Pe())return;ae(void 0),U(void 0);const ce=await Fe("正在检查更新…",`/${encodeURIComponent(G.id)}/update-preview`,"POST",{expectedRevision:G.revision});ce&&(O(void 0),I(void 0),D(ce),ee(!1),fe(G.bound),B(G.bound&&ce.compatibility.supported))},M=()=>{if(_)if(_.kind==="update"){const G=c?.panels.find(ce=>ce.id===_.preview.id);G?pt(G):(ne("此面板已被卸载,请重新从 GitHub 选择安装。"),D(void 0))}else T&&Ie(T)},ie=()=>{F(void 0),A(void 0),m(""),b(""),x("")},ye=async()=>{if(D(void 0),!L||L.position+1>=L.candidates.length){ie();return}const G=L.position+1;F({...L,position:G}),await Ie(L.candidates[G].source)},xe=async G=>{G.length&&(F({candidates:G,position:0}),await Ie(G[0].source))},Ce=async()=>{if(!_||W)return;if(_.expiresAt<=Date.now()){ee(!0),ne("安装审阅已过期,请重新审阅后继续。");return}await Fe(_.kind==="update"?"正在更新面板…":"正在安装面板…","/install","POST",{reviewToken:_.reviewToken,bind:V},!0)&&(P(`${Yn(_.preview.title)} 已${_.kind==="update"?"更新":"安装"}${V?"并绑定当前工作区":""}。`),D(void 0),L?await ye():ie())},Ae=async G=>{const ce=await Fe(G.bound?"正在解除绑定…":"正在绑定工作区…",`/${encodeURIComponent(G.id)}/binding`,"PATCH",{bound:!G.bound,expectedRevision:G.revision},!0);ce&&(h(ce),P(`${Yn(G.title)} 已${G.bound?"解除当前工作区绑定":"绑定当前工作区"}。`))},Pe=async()=>N?(await Fe("正在关闭版本审阅…","/restore/review","DELETE",{reviewToken:N.reviewToken}))?.cancelled?(xt.current=void 0,U(void 0),!0):!1:!0,wt=async()=>{await Pe()&&ae(void 0)},ct=async G=>{if(!await Pe())return;D(void 0),O(void 0),U(void 0),ae(void 0);const ce=await Fe("正在检查保留版本…",`/${encodeURIComponent(G.id)}/versions`,"POST",{expectedRevision:G.revision});ce&&(ae(ce),H(!1))},mt=async G=>{if(!q||!await Pe())return;const ce=kt(`${Cd}/restore/review`),qe=await Fe("正在审阅项目版本…",`/${encodeURIComponent(q.appId)}/restore-preview`,"POST",{packageDigest:G,expectedRevision:q.expectedRevision},!1,He=>Be({target:ce,token:He.reviewToken}));if(qe){if(!ze.current){Be({target:ce,token:qe.reviewToken});return}xt.current={target:ce,token:qe.reviewToken},U(qe),H(!1)}},lt=async()=>{if(!N||Te)return;if(N.expiresAt<=Date.now()){H(!0),ne("版本审阅已过期,请重新选择版本。");return}await Fe("正在恢复项目版本…","/restore","POST",{reviewToken:N.reviewToken},!0)&&(xt.current=void 0,P(`${Yn(N.title)} 的项目版本已恢复为 v${N.version}。`),ae(void 0),U(void 0))},Pt=async()=>{if(!k||c?.panels.find(ce=>ce.id===k.id)?.revision!==k.revision)return;(await Fe("正在卸载面板…",`/${encodeURIComponent(k.id)}`,"DELETE",{expectedRevision:k.revision},!0))?.removed&&(P(`${Yn(k.title)} 已卸载。`),O(void 0))},bt=!!J||!c||!!L,K=j.trim().toLowerCase(),Se=(c?.panels??[]).filter(G=>[Yn(G.title),G.id,G.description??"",G.source.label].join(" ").toLowerCase().includes(K)),je=C?.panels.filter(G=>!c?.panels.some(ce=>ce.id===G.id)&&!c?.issues?.some(ce=>ce.id===G.id)&&C.panels.filter(ce=>ce.id===G.id).length===1)??[],Ne=k&&c?.panels.find(G=>G.id===k.id),ue=!!k&&Ne?.revision!==k.revision,ke=_?.kind==="update"?c?.panels.find(G=>G.id===_.preview.id):void 0,Te=X||!!q&&(c?.panels.find(G=>G.id===q.appId)?.revision??c?.issues?.find(G=>G.id===q.appId)?.revision)!==q.expectedRevision;return s.jsxs("section",{className:"hub-panels",children:[s.jsxs("header",{className:"panels-heading",children:[s.jsxs("div",{children:[s.jsx("h1",{children:"面板"}),s.jsx("p",{children:"从 GitHub 安装工具面板,绑定工作区后直接在工作台中打开。"})]}),s.jsx("button",{disabled:!!J||re,onClick:()=>De(G=>G+1),children:re?"正在刷新…":"刷新"})]}),s.jsxs("p",{className:"panels-muted",children:["面板安装在",u,"上,文件和任务操作使用当前工作区。"]}),c&&!c.hasProject&&s.jsx("div",{className:"panels-warning",children:"请先选择一个项目,才能绑定和打开面板。"}),Z&&s.jsx("p",{role:"alert",className:"error",children:Z}),ge&&s.jsx("p",{role:"status",className:"panels-notice",children:ge}),J&&s.jsx("p",{role:"status",className:"panels-muted",children:J}),c?.issues?.filter(G=>G.id.toLowerCase().includes(K)).map(G=>s.jsxs("section",{className:"panels-warning","aria-label":"需要修复的面板",children:[s.jsx("h2",{children:G.id}),s.jsxs("p",{children:["项目记录版本:",G.version??"未记录","。安装包缺失或无法校验,面板暂不可用。"]}),s.jsx("p",{children:"项目数据和任务记录仍保留。可检查宿主保留的版本,审阅权限后恢复。"}),s.jsx("button",{disabled:!!J||!G.bound||!c.canRestorePackages,onClick:()=>{ct(G)},children:"检查可用版本"})]},G.id)),q&&s.jsxs("section",{className:"panels-review","aria-label":"项目保留版本",children:[s.jsxs("header",{className:"panels-heading",children:[s.jsxs("div",{children:[s.jsxs("h2",{children:[Yn(q.title)," · 项目版本"]}),s.jsxs("p",{children:["项目记录版本:",q.current.version]})]}),s.jsx("button",{disabled:!!J,onClick:()=>{wt()},children:"关闭版本记录"})]}),s.jsx("p",{children:"选择宿主已保留的程序版本,仅切换当前项目。其他项目继续使用各自版本。"}),s.jsx("p",{className:"panels-warning",children:"切换程序版本不会恢复旧数据。请先备份项目,确认该版本支持当前文档格式;任务与产物记录会保留。"}),q.current.unavailable&&s.jsx("p",{role:"status",children:"当前安装包不可用,无法读取原权限;恢复前需重新审阅目标版本的全部权限。"}),q.unavailablePackages>0&&s.jsxs("p",{role:"status",children:["有 ",q.unavailablePackages," 个保留包无法校验,暂不能选择。"]}),!q.versions.length&&s.jsx("p",{children:"没有可用的保留版本。"}),s.jsx("div",{className:"panels-grid",children:q.versions.map(G=>s.jsxs("article",{className:"panels-card",children:[s.jsxs("h3",{children:["v",G.version]}),s.jsxs("small",{children:["内容编号 ",G.packageDigest.slice(0,12)]}),s.jsx(io,{value:G.compatibility}),s.jsx("button",{disabled:!!J||!G.compatibility.supported||G.packageDigest===q.current.packageDigest,onClick:()=>{mt(G.packageDigest)},children:G.packageDigest===q.current.packageDigest?"当前项目版本":`审阅 v${G.version}`})]},G.packageDigest))}),N&&s.jsxs("section",{className:"panels-confirm","aria-label":"确认恢复项目版本",children:[s.jsxs("h3",{children:["v",N.current.version," → v",N.version]}),s.jsx("h4",{children:"此版本请求的权限"}),!N.permissions.length&&s.jsx("p",{children:"未申请宿主权限。"}),N.permissions.map(G=>s.jsxs("div",{className:"panels-permission",children:[s.jsx("span",{children:By[G]??G}),N.addedPermissions.includes(G)&&s.jsx("strong",{children:N.current.unavailable?"需重新确认":"新增权限"})]},G)),s.jsx(io,{value:N.compatibility}),Te&&s.jsx("p",{role:"alert",children:"项目或审阅已变化,请关闭版本记录并重新读取。"}),s.jsx("button",{disabled:!!J||Te||!N.compatibility.supported,onClick:()=>{lt()},children:"确认权限并恢复项目版本"})]})]}),L&&s.jsxs("section",{className:"panels-confirm","aria-label":"逐个审阅面板",children:[s.jsxs("p",{children:["正在审阅第 ",L.position+1," / ",L.candidates.length," 个面板:",Yn(L.candidates[L.position].title),"。每个面板都需要单独确认安装。"]}),s.jsxs("div",{className:"panels-actions",children:[!_&&s.jsx("button",{disabled:!!J,onClick:()=>{Ie(L.candidates[L.position].source)},children:"重新读取此面板"}),s.jsx("button",{disabled:!!J,onClick:()=>{ye()},children:"跳过此面板"}),s.jsx("button",{disabled:!!J,onClick:()=>{F(void 0),D(void 0),ne("")},children:"取消逐个审阅"})]})]}),_&&s.jsxs("section",{className:"panels-review","aria-labelledby":"panel-review-heading",children:[s.jsxs("header",{className:"panels-heading",children:[s.jsxs("div",{children:[s.jsx("h2",{id:"panel-review-heading",ref:Ke,tabIndex:-1,children:_.kind==="update"?"审阅面板更新":"审阅面板安装"}),s.jsxs("p",{children:[Yn(_.preview.title)," · ",_.preview.id," · v",_.preview.version]})]}),s.jsx("button",{disabled:!!J,onClick:()=>{F(void 0),D(void 0),ne("")},children:"取消审阅"})]}),_.preview.description&&s.jsx("p",{children:_.preview.description}),ke&&s.jsxs("p",{className:"panels-warning",children:["当前版本 v",ke.version," → 更新后 v",_.preview.version,ke.source.commit&&s.jsxs(s.Fragment,{children:[s.jsx("br",{}),"当前提交 ",s.jsx("code",{children:ke.source.commit.slice(0,12)})," → 更新提交"," ",s.jsx("code",{children:_.source.commit.slice(0,12)})]})]}),s.jsxs("section",{children:[s.jsx("h3",{children:"安装来源"}),s.jsxs("dl",{children:[s.jsx("dt",{children:"仓库"}),s.jsx("dd",{children:_.source.url}),s.jsx("dt",{children:"分支 / 标签"}),s.jsx("dd",{children:_.source.ref}),s.jsx("dt",{children:"已锁定提交"}),s.jsx("dd",{children:s.jsx("code",{children:_.source.commit})}),s.jsx("dt",{children:"面板目录"}),s.jsx("dd",{children:_.source.subdir||"仓库根目录"}),s.jsx("dt",{children:"界面入口"}),s.jsx("dd",{children:s.jsx("code",{children:_.preview.entry})})]})]}),s.jsxs("section",{children:[s.jsx("h3",{children:"面板请求的权限"}),_.preview.permissions.length===0?s.jsx("p",{className:"panels-muted",children:"未申请宿主权限。"}):_.preview.permissions.map(G=>s.jsxs("div",{className:"panels-permission",children:[s.jsx("span",{children:By[G]??G}),s.jsx("small",{children:G})]},G))]}),s.jsxs("section",{children:[s.jsx("h3",{children:"随面板安装的工具与 Skills"}),_.preview.agent?.tools.length||_.preview.agent?.skills.length?s.jsxs("div",{className:"panels-badges",children:[_.preview.agent?.tools.map(G=>s.jsxs("span",{className:"panels-badge",title:G.description,children:[G.name," · ",G.readOnly?"只读":"可修改数据"]},G.name)),_.preview.agent?.skills.map(G=>s.jsxs("span",{className:"panels-badge",children:["Skill · ",G.split("/").at(-2)??G]},G))]}):s.jsx("p",{className:"panels-muted",children:"此面板没有额外的 Agent 工具或 Skills。"})]}),s.jsx(io,{value:_.compatibility}),_.preview.warnings.length>0&&s.jsx("div",{className:"panels-warning",children:s.jsx("ul",{children:_.preview.warnings.map(G=>s.jsx("li",{children:G},G))})}),s.jsxs("footer",{children:[!_.compatibility.supported&&s.jsxs("p",{className:"panels-muted",children:["可以安装到",u,",但当前 Web 工作台无法绑定或打开它。"]}),Q?s.jsx("p",{className:"panels-muted",children:"已绑定当前工作区,更新将保留绑定。"}):s.jsxs("label",{className:"panels-check",children:[s.jsx("input",{type:"checkbox",checked:V,disabled:!!J||!c?.hasProject||!_.compatibility.supported,onChange:G=>B(G.target.checked)}),"绑定当前工作区"]}),W?s.jsxs("div",{className:"panels-actions",children:[s.jsx("span",{className:"panels-muted",children:"安装内容或本地版本已变化,请重新审阅。"}),s.jsx("button",{disabled:!!J,onClick:M,children:"重新审阅"})]}):s.jsx("button",{className:"panels-primary",disabled:!!J,onClick:()=>{Ce()},children:_.kind==="update"?"确认更新":"确认安装"})]})]}),s.jsxs("section",{className:"panels-section","aria-labelledby":"installed-panels-heading",children:[s.jsxs("div",{className:"panels-heading",children:[s.jsxs("h2",{id:"installed-panels-heading",children:["已安装面板",c?` · ${c.panels.length+(c.issues?.length??0)}`:""]}),s.jsx("input",{type:"search","aria-label":"搜索已安装面板",placeholder:"搜索已安装面板",value:j,onChange:G=>R(G.target.value)})]}),!c&&s.jsx("p",{className:"panels-muted",children:re?"正在读取面板…":"暂时无法读取面板,请刷新重试。"}),c&&Se.length===0&&!c.issues?.some(G=>G.id.toLowerCase().includes(K))&&s.jsxs("div",{className:"panels-empty",children:[s.jsx("strong",{children:c.panels.length||c.issues?.length?"没有匹配的面板":"还没有安装面板"}),s.jsx("p",{className:"panels-muted",children:c.panels.length||c.issues?.length?"试试其他名称或清除搜索。":"在下方粘贴 GitHub 仓库地址,或浏览官方面板仓库。"})]}),s.jsx("div",{className:"panels-grid",children:Se.map(G=>s.jsxs("article",{className:"panels-card",children:[s.jsxs("div",{className:"panels-card-heading",children:[s.jsx("h3",{children:Yn(G.title)}),s.jsxs("span",{className:"panels-badge",children:["v",G.version]})]}),s.jsx("small",{children:G.id}),G.description&&s.jsx("p",{children:G.description}),s.jsx("div",{className:"panels-badges",children:s.jsx("span",{className:`panels-badge ${G.enabled&&G.compatibility.supported?"panels-badge-ready":""}`,children:G.globalDisabled?"已全局停用":G.bound?"已绑定当前工作区":"未绑定当前工作区"})}),s.jsxs("dl",{children:[s.jsx("dt",{children:"来源"}),s.jsx("dd",{children:G.source.label}),G.source.ref&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"分支 / 标签"}),s.jsx("dd",{children:G.source.ref})]})]}),s.jsx(io,{value:G.compatibility}),G.globalDisabled&&s.jsx("p",{className:"panels-muted",children:"请在宿主配置中启用此面板后使用。"}),s.jsxs("div",{className:"panels-actions",children:[s.jsx("button",{className:"panels-primary",disabled:bt||!G.enabled||!G.compatibility.supported,onClick:()=>Tt.current.onOpen(G),children:"打开面板"}),s.jsx("button",{disabled:bt||!c?.hasProject||!G.bound&&(G.globalDisabled||!G.compatibility.supported),onClick:()=>{Ae(G)},children:G.bound?"解除绑定":"绑定工作区"}),G.updatable&&s.jsx("button",{disabled:bt,onClick:()=>{pt(G)},children:"检查更新"}),c?.canRestorePackages&&G.bound&&s.jsx("button",{disabled:bt,onClick:()=>{ct(G)},children:"项目版本"}),s.jsx("button",{className:"panels-danger",disabled:bt,onClick:async()=>{!await Pe()||!ze.current||(O(G),D(void 0),ae(void 0),U(void 0),ne(""),P(""))},children:"卸载"})]})]},G.id))}),k&&s.jsxs("section",{className:"panels-confirm","aria-label":"确认卸载面板",children:[s.jsxs("p",{children:["卸载「",Yn(k.title),"」v",k.version,"?面板将从",u,"移除,其他工作区也将无法打开它。"]}),s.jsxs("div",{className:"panels-actions",children:[s.jsx("button",{disabled:!!J,onClick:()=>O(void 0),children:"取消卸载"}),ue&&s.jsx("span",{className:"panels-muted",children:Ne?"面板已被其他设备修改,请查看最新版本后重新确认。":"此面板已被其他设备卸载。"}),ue&&Ne&&s.jsx("button",{disabled:!!J||re,onClick:()=>{O(Ne),ne("")},children:"查看最新版本"}),s.jsx("button",{className:"panels-danger",disabled:!!J||re||ue,onClick:()=>{Pt()},children:"确认卸载"})]})]})]}),s.jsxs("section",{className:"panels-import panels-section","aria-labelledby":"github-panels-heading",children:[s.jsxs("div",{className:"panels-heading",children:[s.jsxs("div",{children:[s.jsx("h2",{id:"github-panels-heading",children:"从 GitHub 安装"}),s.jsx("p",{children:"先读取仓库并选择面板,再查看安装内容和所需权限。"})]}),s.jsx("button",{disabled:bt,onClick:()=>{m(Ly),b(""),x(""),Lt({url:Ly})},children:"浏览官方仓库"})]}),s.jsxs("form",{onSubmit:G=>{G.preventDefault(),p.trim()&&Lt({url:p.trim(),...y.trim()?{ref:y.trim()}:{},...v.trim()?{subdir:v.trim()}:{}})},children:[s.jsxs("label",{children:["GitHub 仓库地址",s.jsx("input",{type:"url",placeholder:"https://github.com/owner/repository",value:p,required:!0,disabled:!!J||!!L,onChange:G=>{m(G.target.value),A(void 0)}})]}),s.jsxs("details",{children:[s.jsx("summary",{children:"指定分支或子目录"}),s.jsxs("div",{className:"panels-source-fields",children:[s.jsxs("label",{children:["分支 / 标签(可选)",s.jsx("input",{value:y,placeholder:"使用默认分支",disabled:!!J||!!L,onChange:G=>{b(G.target.value),A(void 0)}})]}),s.jsxs("label",{children:["子目录(可选)",s.jsx("input",{value:v,placeholder:"例如 apps/my-panel",disabled:!!J||!!L,onChange:G=>{x(G.target.value),A(void 0)}})]})]})]}),s.jsxs("div",{className:"panels-actions",children:[s.jsx("button",{type:"submit",disabled:bt||!p.trim(),children:"读取仓库"}),(p||y||v||C)&&s.jsx("button",{type:"button",disabled:!!J,onClick:()=>{ie(),D(void 0)},children:"清除"})]})]}),C&&s.jsxs("div",{className:"panels-candidates",children:[s.jsxs("h3",{children:["找到 ",C.panels.length," 个面板"]}),s.jsxs("p",{className:"panels-muted",children:[C.source.url," · ",C.source.ref," ·"," ",s.jsx("code",{children:C.source.commit.slice(0,12)})]}),C.panels.length===0&&s.jsx("p",{className:"panels-muted",children:"仓库中没有找到可安装的面板。请检查地址和子目录。"}),je.length>1&&s.jsxs("div",{className:"panels-actions panels-batch-start",children:[s.jsxs("button",{disabled:bt,onClick:()=>{xe(je)},children:["逐个审阅未安装面板(",je.length,")"]}),s.jsx("small",{children:"按顺序确认,可随时跳过或停止。"})]}),s.jsx("div",{className:"panels-grid",children:C.panels.map(G=>{const ce=c?.panels.find(qe=>qe.id===G.id);return s.jsxs("article",{className:"panels-card",children:[s.jsxs("div",{className:"panels-card-heading",children:[s.jsx("h3",{children:Yn(G.title)}),s.jsxs("span",{className:"panels-badge",children:["v",G.version]})]}),G.description&&s.jsx("p",{children:G.description}),s.jsx("small",{children:G.subdir==="."?"仓库根目录":G.subdir}),s.jsx("div",{className:"panels-actions",children:s.jsx("button",{disabled:bt||!!(ce&&!ce.updatable),onClick:()=>ce?void pt(ce):void Ie(G.source),children:ce?ce.updatable?"已安装 · 检查更新":"已从其他来源安装":"审阅安装"})})]},`${G.id}:${G.subdir}`)})}),C.issues.length>0&&s.jsxs("div",{className:"panels-warning",children:[s.jsx("strong",{children:"部分目录无法作为面板安装"}),s.jsx("ul",{children:C.issues.map(G=>s.jsxs("li",{children:[G.subdir,":",G.error]},G.subdir))})]})]})]})]})}function qS(t){const i=t.projectId===void 0?Ta():t.projectId,r=`/api/v1/panels/runtime/${encodeURIComponent(t.instanceId)}`,a=new Set,u=new Set;let d=!1,c=t.expiresAt,h=c-6e4,p,m=0,y=0,b=0,v,x;const j=(T,I)=>{const L=setTimeout(()=>{a.delete(L),d||T()},Math.max(0,Math.min(I,2147483647)));return a.add(L),L},R=T=>{T!==void 0&&(clearTimeout(T),a.delete(T))},C=()=>{if(!d){d=!0;for(const T of a)clearTimeout(T);a.clear();for(const T of u)T.abort();u.clear()}},A=T=>{d||(C(),t.onTerminal(T))},_=()=>A(new Error("面板连接已到期,请重新打开继续使用。")),D=T=>T instanceof Ze&&[401,403,410].includes(T.status),q=()=>{d||t.onStatus(m||y?"面板连接暂时中断,正在重试;当前内容会保留。":"")},ae=async(T,I="GET")=>{const L=new AbortController;u.add(L);const F=j(()=>L.abort(),8e3);try{return await Ue(kt(`${r}${T}`,t.workspace,i),{method:I,...I==="POST"?{headers:{"Content-Type":"application/json"},body:"{}"}:{},signal:L.signal})}finally{R(F),u.delete(L)}},N=()=>{R(v),v=j(()=>{Date.now()>=c?_():N()},c-Date.now())},U=()=>{R(x),m<5&&(x=j(X,h-Date.now()))};function X(){if(!d){if(Date.now()>=c){_();return}p||m>=5||Date.now()<h||(p=(async()=>{try{const T=await ae("/renew","POST");if(d)return;if(!T||typeof T!="object"||!("expiresAt"in T)||typeof T.expiresAt!="number"||!Number.isFinite(T.expiresAt)||T.expiresAt<=Date.now()+6e4)throw new Error("面板续期响应无效。");c=T.expiresAt,h=c-6e4,m=0,N(),q()}catch(T){if(d)return;if(D(T)){A(T);return}m++,h=Date.now()+Math.min(5e3*2**(m-1),3e4),q()}finally{p=void 0,d||U()}})())}}async function H(){try{const T=await ae(`/events?after=${b}`);if(d)return;if(!T||typeof T!="object"||!("cursor"in T)||!("events"in T))throw new Error("面板事件响应无效。");if(!Number.isSafeInteger(T.cursor)||T.cursor<b||!Array.isArray(T.events)||T.events.length>2048)throw new Error("面板事件响应无效。");const I=[];let L=b;for(const F of T.events){if(!F||typeof F!="object"||!Number.isSafeInteger(F.id)||F.id<=L||F.id>T.cursor||typeof F.event!="string"||!/^[A-Za-z][A-Za-z0-9._-]{0,100}$/.test(F.event))throw new Error("面板事件响应无效。");L=F.id,I.push(F)}t.onEvents(I),b=T.cursor,y=0,q()}catch(T){if(d)return;if(D(T)){A(T);return}y++,q()}finally{d||j(()=>{H()},Math.min(1e3*2**y,5e3))}}return N(),U(),H(),{stop:C,refresh:X}}function HS(t){if(!Number.isInteger(t.maxDurationSeconds)||t.maxDurationSeconds<1||t.maxDurationSeconds>600||!Number.isInteger(t.maxBytes)||t.maxBytes<1||t.maxBytes>25*1024*1024)throw new Error("录音限制无效。");let i={phase:"idle",elapsedSeconds:0,message:"点击开始录音后,浏览器才会请求麦克风。"},r=0,a,u,d,c=[],h=0,p="",m=t.signal.aborted;const y=j=>{i={...i,...j},m||t.onChange({...i})},b=()=>{a?.getTracks().forEach(j=>j.stop()),a=void 0,d&&clearInterval(d),d=void 0},v=()=>{try{u?.state!=="inactive"&&u?.stop()}finally{b()}},x=()=>{if(!m){m=!0,r++,u&&(u.ondataavailable=null,u.onstop=null,u.onerror=null);try{v()}finally{b()}c=[],i={phase:"closed",elapsedSeconds:0,message:"录音已关闭。"},t.signal.removeEventListener("abort",x)}};return m?i={phase:"closed",elapsedSeconds:0,message:"录音授权已结束。"}:t.signal.addEventListener("abort",x,{once:!0}),{snapshot:()=>({...i}),async start(){if(m||t.signal.aborted)throw new Error("录音授权已结束。");if(["requesting","recording"].includes(i.phase))throw new Error("已有录音正在进行。");const j=++r,R=()=>!m&&j===r&&!t.signal.aborted;c=[],h=0,p="",y({phase:"requesting",elapsedSeconds:0,blob:void 0,message:"正在等待麦克风授权…"});try{const C=await(t.getStream?t.getStream():navigator.mediaDevices.getUserMedia({audio:!0,video:!1}));if(!R()){C.getTracks().forEach(q=>q.stop());return}a=C;const A=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(q=>typeof MediaRecorder<"u"&&MediaRecorder.isTypeSupported(q));u=t.makeRecorder?t.makeRecorder(a):new MediaRecorder(a,{...A?{mimeType:A}:{},audioBitsPerSecond:128e3});const _=u;_.ondataavailable=q=>{!R()||!q.data.size||(c.push(q.data),h+=q.data.size,h>t.maxBytes&&(p="录音超过大小限制;可以下载备份,或重新录制较短的音频。",v()))},_.onerror=()=>{if(R()){p="录音设备发生错误;请检查麦克风后重新录制。";try{v()}catch{b()}y({phase:"error",message:p})}},_.onstop=()=>{if(!R())return;b();const q=new Blob(c,{type:_.mimeType.split(";")[0]||"audio/webm"});c=[],y({phase:q.size&&!p?"review":"error",blob:q.size?q:void 0,message:p||(q.size?"录音已停止。可以试听,再保存到当前项目。":"没有录到声音,请重新录制。")})};const D=Date.now();_.start(250),y({phase:"recording",message:"正在使用这台设备的麦克风录音。"}),d=setInterval(()=>{if(!R())return;const q=Math.floor((Date.now()-D)/1e3);y({elapsedSeconds:q}),q>=t.maxDurationSeconds&&v()},250)}catch(C){if(b(),!R())return;y({phase:"error",message:C instanceof Error&&["NotAllowedError","SecurityError"].includes(C.name)?"麦克风未获授权,请检查浏览器和系统的麦克风权限。":"无法启动录音,请确认安全连接、麦克风和浏览器录音支持。"})}},stop:v,close:x}}function iv(t){const i=new Blob([t.blob],{type:t.blob.type.split(";")[0].trim().toLowerCase()}),r=[],a=t.timing?.now??Date.now,u=t.timing?.sleep??((v,x)=>new Promise((j,R)=>{const C=()=>{clearTimeout(A),R(x.reason)},A=setTimeout(()=>{x.removeEventListener("abort",C),j()},v);x.addEventListener("abort",C,{once:!0}),x.aborted&&C()})),d=async()=>{const v=t.transferBudget;if(!(!v||!Number.isSafeInteger(v.rateWindowMs)||v.rateWindowMs<1||!Number.isSafeInteger(v.maxTransferCallsPerWindow)||v.maxTransferCallsPerWindow<1))for(;;){t.signal.throwIfAborted();const x=a();for(;r.length&&r[0]<=x-v.rateWindowMs;)r.shift();if(r.length<v.maxTransferCallsPerWindow){r.push(x);return}await u(Math.max(1,r[0]+v.rateWindowMs-x),t.signal)}};let c,h=!1,p;const m=()=>t.signal.throwIfAborted(),y=async(v,x)=>{m();const j=await t.call(v,x);return m(),j},b=v=>{const x=v;if(!x||typeof x.sessionId!="string"||!/^upload-[a-f0-9-]{36}$/.test(x.sessionId)||c&&c!==x.sessionId||x.mimeType!==i.type||!["uploading","finished"].includes(String(x.state))||!Number.isSafeInteger(x.receivedBytes)||Number(x.receivedBytes)<0||Number(x.receivedBytes)>i.size||!Number.isSafeInteger(x.nextSequence)||Number(x.nextSequence)<0||!Number.isSafeInteger(x.maxChunkBytes)||Number(x.maxChunkBytes)<1||Number(x.maxChunkBytes)>32768)throw new Error("文件上传状态无效,请保留本机备份后重新打开面板。");return x};return{async save(){if(m(),h)throw new Error("文件正在保存,请稍候。");if(!i.size||i.size>t.maxBytes||!t.mimeTypes.includes(i.type))throw new Error("文件格式或大小无效。");h=!0;try{if(!p){const j=await i.arrayBuffer();m(),p=Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",j)),R=>R.toString(16).padStart(2,"0")).join(""),m()}let v=b(c?await y("resources.upload.get",{sessionId:c}):await y("resources.upload.begin",{name:t.name,mimeType:i.type,expectedBytes:i.size,expectedSha256:p}));for(c=v.sessionId,t.onProgress(v.receivedBytes);v.receivedBytes<i.size;){if(v.state!=="uploading")throw new Error("文件上传已结束,文件大小不匹配。");const j=v.receivedBytes,R=new Uint8Array(await i.slice(j,j+v.maxChunkBytes).arrayBuffer());m(),await d(),m();const C=b(await y("resources.upload.write",{sessionId:c,sequence:v.nextSequence,offset:j,dataBase64:btoa(String.fromCharCode(...R))}));if(C.receivedBytes!==j+R.length||C.nextSequence!==v.nextSequence+1)throw new Error("文件上传进度不匹配,请重试保存以核对服务端状态。");v=C,t.onProgress(v.receivedBytes)}const x=await y("resources.upload.finish",{sessionId:c});if(!x?.asset||x.asset.id!==`asset-${p}`||x.asset.bytes!==i.size||x.asset.mimeType!==i.type)throw new Error("文件保存回执不匹配,请保留本机备份并重试。");return x}finally{h=!1}}}}function GS(t){return iv({...t,maxBytes:25*1024*1024,mimeTypes:["audio/webm","audio/mp4","audio/ogg","audio/wav"]})}function VS({request:t}){const[i,r]=S.useState({phase:"idle",elapsedSeconds:0,message:"点击开始录音后,浏览器才会请求麦克风。"}),[a,u]=S.useState(""),[d,c]=S.useState(!1),[h,p]=S.useState(0),[m,y]=S.useState(""),b=S.useRef(null),v=S.useRef(void 0),x=S.useRef(void 0),j=S.useRef(void 0);S.useEffect(()=>{const A=new AbortController;j.current=A;const _=AbortSignal.any([t.signal,A.signal]);return v.current=HS({...t,signal:_,onChange:r}),b.current?.focus(),b.current?.scrollIntoView?.({block:"nearest"}),()=>{A.abort(),v.current?.close(),v.current=void 0,x.current=void 0}},[t]),S.useEffect(()=>{if(!i.blob){y("");return}const A=URL.createObjectURL(i.blob);return y(A),()=>URL.revokeObjectURL(A)},[i.blob]);const R=i.blob?.type==="audio/mp4"?"m4a":i.blob?.type==="audio/ogg"?"ogg":"webm",C=async()=>{const A=i.blob,_=j.current;if(!A||!_||d||i.phase!=="review")return;const D=AbortSignal.any([t.signal,_.signal]);c(!0),u("");try{x.current?.blob!==A&&(x.current={blob:A,transfer:GS({blob:A,name:`recording.${R}`,signal:D,call:(ae,N)=>t.call(ae,N,D),onProgress:p})});const q=await x.current.transfer.save();D.throwIfAborted(),t.finish(q)}catch(q){D.aborted||u(`${q instanceof Error?q.message:"保存失败。"} 录音仍保留在本页,可重试保存或下载备份。`)}finally{D.aborted||c(!1)}};return s.jsxs("section",{className:"panel-host-audio panel-host-preview","aria-label":"录音",tabIndex:-1,ref:b,children:[s.jsxs("header",{children:[s.jsx("h2",{children:"录音并保存到当前项目"}),s.jsx("button",{onClick:()=>t.finish({cancelled:!0}),children:"取消录音"})]}),s.jsxs("p",{children:["使用当前设备的麦克风;最长 ",t.maxDurationSeconds," ","秒。停止后可试听,点击保存才会上传到当前项目。关闭面板会丢弃未保存录音。"]}),s.jsxs("p",{role:"status",children:[i.message," ",i.elapsedSeconds>0&&`${i.elapsedSeconds} 秒`]}),m&&s.jsx("audio",{controls:!0,src:m}),a&&s.jsx("p",{role:"alert",children:a}),d&&s.jsxs("p",{role:"status",children:["正在保存录音:",Math.round(h/(i.blob?.size||1)*100),"%"]}),s.jsxs("div",{className:"panel-host-actions",children:[["idle","error"].includes(i.phase)&&!i.blob&&s.jsx("button",{onClick:()=>{u(""),v.current?.start().catch(A=>u(String(A)))},children:"开始录音"}),i.phase==="recording"&&s.jsx("button",{onClick:()=>v.current?.stop(),children:"停止录音"}),i.phase==="review"&&s.jsx("button",{disabled:d,className:"panel-host-primary",onClick:()=>{C()},children:d?"正在保存…":"保存到当前项目"}),m&&s.jsx("button",{disabled:d,onClick:()=>{u(""),x.current=void 0,v.current?.start().catch(A=>u(String(A)))},children:"丢弃并重新录制"}),m&&s.jsx("a",{href:m,download:`recording.${R}`,children:"下载本机备份"})]})]})}const bl=Object.freeze({maxDurationSeconds:1200,maxBytes:200*1024*1024,defaultDurationSeconds:300,defaultBytes:64*1024*1024});function rv(t){const i=t;if(!i||typeof i!="object"||Array.isArray(i)||Object.keys(i).some(u=>!["source","microphone","systemAudio","maxDurationSeconds","maxBytes"].includes(u))||i.source!=="camera"&&i.source!=="screen"||i.microphone!==void 0&&typeof i.microphone!="boolean"||i.systemAudio!==void 0&&typeof i.systemAudio!="boolean"||i.source!=="screen"&&i.systemAudio===!0)throw new Error("视频录制请求无效。");const r=i.maxDurationSeconds??bl.defaultDurationSeconds,a=i.maxBytes??bl.defaultBytes;if(!Number.isSafeInteger(r)||Number(r)<1||Number(r)>bl.maxDurationSeconds||!Number.isSafeInteger(a)||Number(a)<1||Number(a)>bl.maxBytes)throw new Error("视频录制限制无效。");return{source:i.source,microphone:i.microphone!==!1,systemAudio:i.systemAudio===!0,maxDurationSeconds:Number(r),maxBytes:Number(a)}}const $S=["video/webm;codecs=vp8,opus","video/webm;codecs=vp9,opus","video/webm","video/mp4"];function lv(){try{return $S.find(t=>typeof MediaRecorder<"u"&&MediaRecorder.isTypeSupported(t))}catch{return}}function Ed(){const t=typeof navigator>"u"?void 0:navigator.mediaDevices,i=typeof window<"u"&&window.isSecureContext===!0&&!!lv(),r=i&&typeof t?.getUserMedia=="function",a=i&&typeof t?.getDisplayMedia=="function";return{camera:r,screen:a,microphone:r,systemAudio:a,maxDurationSeconds:bl.maxDurationSeconds,maxBytes:bl.maxBytes}}function PS(t){const i=rv({source:t.source,microphone:t.microphone,systemAudio:t.systemAudio,maxDurationSeconds:t.maxDurationSeconds,maxBytes:t.maxBytes});let r={phase:"idle",elapsedSeconds:0,message:"点击开始录制后,才会请求设备授权。",capture:{source:i.source,microphone:!1,systemAudio:!1}},a=0,u=t.signal.aborted,d,c,h,p=[],m=0,y="";const b=new Set,v=C=>{r={...r,...C},u||t.onChange({...r})},x=()=>{h&&clearInterval(h),h=void 0;for(const C of new Set([...b].flatMap(A=>A.getTracks())))C.onended=null,C.stop();b.clear(),c&&c.state!=="closed"&&c.close().catch(()=>{}),c=void 0},j=()=>{try{d?.state!=="inactive"&&d?.stop()}finally{x()}},R=()=>{if(!u){u=!0,a++,d&&(d.ondataavailable=null,d.onstop=null,d.onerror=null);try{j()}finally{x()}p=[],r={...r,phase:"closed",stream:void 0,blob:void 0},t.signal.removeEventListener("abort",R)}};return u?r.phase="closed":t.signal.addEventListener("abort",R,{once:!0}),{snapshot:()=>({...r}),async start(){if(u||t.signal.aborted)throw new Error("录制授权已结束。");if(["requesting","recording"].includes(r.phase))throw new Error("已有录制正在进行。");const C=++a,A=()=>!u&&a===C&&!t.signal.aborted,_=D=>{if(!A())throw D.getTracks().forEach(q=>q.stop()),new Error("录制授权已结束。");b.add(D);for(const q of D.getTracks()){if(q.readyState==="ended")throw new Error("所选采集来源已经停止,请重新连接。");q.onended=()=>{A()&&(r.phase==="recording"?j():(a++,x(),v({phase:"error",stream:void 0,message:"采集来源已停止,请重新连接。"})))}}return D};x(),p=[],m=0,y="",v({phase:"requesting",elapsedSeconds:0,stream:void 0,blob:void 0,message:"正在等待设备授权…"});try{const D=t.devices??navigator.mediaDevices;if(!D)throw new Error("录制需要安全连接和浏览器设备支持。");const q=_(await(i.source==="screen"?D.getDisplayMedia({video:!0,audio:i.systemAudio}):D.getUserMedia({video:!0,audio:i.microphone})));if(!q.getVideoTracks().length)throw new Error("没有获得可录制的画面。");const ae=i.source==="screen"&&i.microphone?_(await D.getUserMedia({audio:!0,video:!1})):void 0,N=i.microphone?(i.source==="camera"?q:ae)?.getAudioTracks()??[]:[];if(i.microphone&&!N.length)throw new Error("没有获得麦克风音轨。");const U=i.source==="screen"&&i.systemAudio?q.getAudioTracks():[];let X=_(new MediaStream([...q.getVideoTracks(),...N,...U]));if(N.length&&i.source==="screen")if(U.length){c=t.makeAudioContext?t.makeAudioContext():new AudioContext;const L=c,F=L.createMediaStreamDestination();_(F.stream);for(const ee of[N,U])L.createMediaStreamSource(new MediaStream(ee)).connect(F);let W;try{await Promise.race([L.resume(),new Promise((ee,V)=>{W=setTimeout(()=>V(new Error("声音混合未能启动,请重新录制。")),2e3)})])}finally{W&&clearTimeout(W)}t.signal.throwIfAborted(),X=_(new MediaStream([...q.getVideoTracks(),...F.stream.getAudioTracks()]))}else X=_(new MediaStream([...q.getVideoTracks(),...N]));if(!A()){x();return}const H=lv();if(!H)throw new Error("此浏览器不支持视频录制编码。");d=t.makeRecorder?t.makeRecorder(X,H):new MediaRecorder(X,{mimeType:H});const T=d;T.ondataavailable=L=>{!A()||!L.data.size||(p.push(L.data),m+=L.data.size,m>i.maxBytes&&(y="录制超过大小限制;可以下载备份或重新录制较短的视频。",j()))},T.onerror=()=>{if(A()){y="录制设备或编码器发生错误,请保留备份后重试。";try{j()}catch{x()}v({phase:"error",stream:void 0,message:y})}},T.onstop=()=>{if(!A())return;x();const L=new Blob(p,{type:T.mimeType.split(";")[0]||H.split(";")[0]});p=[],v({phase:L.size&&!y?"review":"error",stream:void 0,blob:L.size?L:void 0,message:y||(L.size?"录制已停止。可以预览,再保存到当前项目。":"没有录到内容,请重新录制。")})};const I=Date.now();T.start(250),v({phase:"recording",stream:X,capture:{source:i.source,microphone:N.length>0,systemAudio:U.length>0},message:"正在使用这台设备录制;停止后可以预览和保存。"}),h=setInterval(()=>{if(!A())return;const L=Math.floor((Date.now()-I)/1e3);v({elapsedSeconds:L}),L>=i.maxDurationSeconds&&j()},250)}catch(D){if(x(),!A())return;v({phase:"error",stream:void 0,message:D instanceof Error&&["NotAllowedError","SecurityError"].includes(D.name)?"设备未获授权或屏幕选择已取消,请检查浏览器和系统权限后重试。":D instanceof Error?D.message:"无法启动录制,请检查设备和浏览器支持。"})}},stop:j,close:R}}function YS({request:t}){const[i,r]=S.useState({phase:"idle",elapsedSeconds:0,message:"点击开始录制后,才会请求设备授权。",capture:{source:t.source,microphone:!1,systemAudio:!1}}),[a,u]=S.useState(""),[d,c]=S.useState(!1),[h,p]=S.useState(0),[m,y]=S.useState(""),b=S.useRef(null),v=S.useRef(null),x=S.useRef(void 0),j=S.useRef(void 0),R=S.useRef(void 0);S.useEffect(()=>{const D=new AbortController;R.current=D;const q=AbortSignal.any([t.signal,D.signal]);x.current=PS({...t,signal:q,onChange:r});const ae=()=>{D.abort(),t.finish({cancelled:!0})};return window.addEventListener("pagehide",ae,{once:!0}),b.current?.focus(),b.current?.scrollIntoView?.({block:"nearest"}),()=>{window.removeEventListener("pagehide",ae),D.abort(),x.current?.close(),x.current=void 0,j.current=void 0}},[t]),S.useEffect(()=>{const D=v.current;if(D)return D.srcObject=i.stream??null,i.stream&&D.play().catch(()=>{}),()=>{D.srcObject=null}},[i.stream]),S.useEffect(()=>{if(!i.blob){y("");return}const D=URL.createObjectURL(i.blob);return y(D),()=>URL.revokeObjectURL(D)},[i.blob]);const C=i.blob?.type==="video/mp4"?"mp4":"webm",A=()=>{u(""),j.current=void 0,x.current?.start().catch(D=>u(String(D)))},_=async()=>{const D=i.blob,q=R.current;if(!D||!q||d||i.phase!=="review")return;const ae=AbortSignal.any([t.signal,q.signal]);c(!0),u("");try{j.current?.blob!==D&&(j.current={blob:D,transfer:iv({blob:D,name:`recording.${C}`,signal:ae,maxBytes:t.maxBytes,mimeTypes:["video/webm","video/mp4"],transferBudget:t.transferBudget,call:(U,X)=>t.call(U,X,ae),onProgress:p})});const N=await j.current.transfer.save();ae.throwIfAborted(),t.finish({...N,capture:i.capture})}catch(N){ae.aborted||u(`${N instanceof Error?N.message:"保存失败。"} 视频仍保留在本页,可重试保存或下载备份。若已保存但未收到回复,重开面板后可从项目资源找回。`)}finally{ae.aborted||c(!1)}};return s.jsxs("section",{className:"panel-host-video panel-host-preview","aria-label":"视频录制",tabIndex:-1,ref:b,children:[s.jsxs("header",{children:[s.jsxs("h2",{children:[t.source==="camera"?"摄像头录制":"屏幕录制","并保存到当前项目"]}),s.jsx("button",{onClick:()=>t.finish({cancelled:!0}),children:"取消录制"})]}),s.jsxs("p",{children:["使用当前设备;最长 ",t.maxDurationSeconds," 秒,最多"," ",Math.ceil(t.maxBytes/1024/1024)," MiB。",t.microphone?"使用麦克风。":"不使用麦克风。",t.systemAudio&&"屏幕声音取决于浏览器和你选择的共享来源,可能没有声音音轨。","停止后可预览,点击保存才会上传。关闭面板会丢弃未保存录制。"]}),s.jsxs("p",{role:"status",children:[i.message," ",i.elapsedSeconds>0&&`${i.elapsedSeconds} 秒`]}),i.stream&&s.jsx("video",{ref:v,muted:!0,playsInline:!0,"aria-label":"实时录制预览"}),m&&s.jsx("video",{controls:!0,playsInline:!0,src:m,"aria-label":"录制预览"}),i.phase==="recording"&&s.jsxs("p",{children:["麦克风:",i.capture.microphone?"已采集":"未采集",";屏幕声音:",i.capture.systemAudio?"已采集":"未采集"]}),a&&s.jsx("p",{role:"alert",children:a}),d&&s.jsxs("p",{role:"status",children:["正在保存视频:",Math.round(h/(i.blob?.size||1)*100),"%"]}),s.jsxs("div",{className:"panel-host-actions",children:[["idle","error"].includes(i.phase)&&!i.blob&&s.jsx("button",{onClick:A,children:"开始录制"}),i.phase==="recording"&&s.jsx("button",{onClick:()=>x.current?.stop(),children:"停止录制"}),i.phase==="review"&&s.jsx("button",{disabled:d,className:"panel-host-primary",onClick:()=>{_()},children:d?"正在保存…":"保存到当前项目"}),m&&s.jsx("button",{disabled:d,onClick:A,children:"丢弃并重新录制"}),m&&s.jsx("a",{href:m,download:`recording.${C}`,children:"下载本机备份"})]})]})}const er="/api/v1/panels/runtime";function tn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function FS(t){try{if(typeof t!="string"||t.length>2048)return;const i=new URL(t);if(i.protocol==="https:"&&!i.username&&!i.password)return i.href}catch{}}function QS(t,i){const r=`${er}/${i}/directory/`;return typeof t=="string"&&t.startsWith(r)&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t.slice(r.length))}function XS(t,i,r){if(!tn(t)||t.effect!=="resources.open"||!tn(t.asset))return;const a=t.asset;if(typeof a.id!="string"||!/^(?:asset|external)-[a-f0-9]{64}$/.test(a.id)||a.id!==r||t.url!==`${er}/${i}/resources/${a.id}`||typeof a.name!="string"||!a.name||a.name.length>1024||typeof a.mimeType!="string"||!Number.isSafeInteger(a.bytes)||Number(a.bytes)<0)return;const u=["video/mp4","video/webm","video/ogg","video/quicktime"].includes(a.mimeType)?"video":["audio/mpeg","audio/mp4","audio/ogg","audio/wav","audio/webm","audio/flac","audio/aac"].includes(a.mimeType)?"audio":["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp"].includes(a.mimeType)?"image":"file";return{name:a.name,url:t.url,kind:u}}function KS(t){if(typeof t!="string"||!/^\/api\/v1\/panel-assets\/[A-Za-z0-9_-]{20,128}\/[A-Za-z0-9_%./-]+$/.test(t))return!1;try{return t.split("/").slice(5).every(i=>{const r=decodeURIComponent(i);return!!r&&!r.startsWith(".")&&!/[\\/:\u0000-\u001f\u007f]/.test(r)})}catch{return!1}}function ZS(t){return tn(t)?typeof t.instanceId=="string"&&/^[A-Za-z0-9_-]{20,128}$/.test(t.instanceId)&&KS(t.src)&&typeof t.expiresAt=="number"&&Number.isFinite(t.expiresAt)&&tn(t.context)&&Array.isArray(t.limitations)&&t.limitations.every(i=>typeof i=="string"):!1}function JS({panel:t,sessionId:i,busy:r,onClose:a,onAuthLost:u,onDirtyChange:d,onSubmitPrompt:c}){const h=S.useRef(null),[p,m]=S.useState(),[y,b]=S.useState(!0),[v,x]=S.useState(""),[j,R]=S.useState(""),[C,A]=S.useState(),[_,D]=S.useState(),[q,ae]=S.useState(!1),N=S.useRef(null);S.useEffect(()=>{_&&(N.current?.focus(),N.current?.scrollIntoView?.({block:"nearest"}))},[_]);const[U,X]=S.useState(""),[H,T]=S.useState(""),[I,L]=S.useState(),[F,W]=S.useState(),ee=S.useRef(void 0),[V,B]=S.useState(),[Q,fe]=S.useState(!1),[k,O]=S.useState(0),re=S.useRef({onClose:a,onAuthLost:u,onDirtyChange:d,onSubmitPrompt:c,busy:r});re.current={onClose:a,onAuthLost:u,onDirtyChange:d,onSubmitPrompt:c,busy:r};const E=S.useRef(!1),J=S.useRef(void 0),be=S.useRef(void 0),Z=S.useRef(null);return S.useEffect(()=>{re.current.onDirtyChange?.(!!I||Q||!!F||!!V),I&&(Z.current?.focus(),Z.current?.scrollIntoView?.({block:"nearest"}))},[I,Q,F,V]),S.useEffect(()=>{const ne=go()??"",ge=Ta(),P={workspace:ne,grant:void 0},ve=new AbortController,De=new Set,ze=new Set;let _e=!1,Ge;const ft=[],xt=[],Ke=new Set,Tt=new Set;let Be,At=!1,Je=!1,Fe=!1,Lt=!1;const Ie=()=>{const K=h.current?.contentWindow;if(!(_e||!P.grant||!K||!Lt))for(const Se of ft.splice(0))Se.event==="tools.invoke"&&tn(Se.payload)&&typeof Se.payload.requestId=="string"&&/^[A-Za-z0-9_-]{1,128}$/.test(Se.payload.requestId)&&Tt.add(Se.payload.requestId),K.postMessage({type:"codeshell-panel:event",instanceId:P.grant.instanceId,event:Se.event,payload:Se.payload},"*")},pt=()=>{_e||!Fe||!Lt||!P.grant||(Be&&clearTimeout(Be),b(!1),Ie())},M={loaded:()=>{Fe=!0,pt()}};be.current=M,m(void 0),b(!0),x(""),R(""),A(void 0),D(void 0),ae(!1),X(""),T(""),L(void 0),fe(!1),W(void 0),B(void 0);const ie=K=>{At||(At=!0,Ue(kt(`${er}/${encodeURIComponent(K.instanceId)}`,ne,ge),{method:"DELETE",keepalive:!0}).catch(()=>{}))},ye=K=>{_e||(K instanceof Ze&&K.status===401&&!E.current&&(E.current=!0,re.current.onAuthLost()),x(K instanceof Error?K.message:"面板连接失败,请重新打开。"))},xe=K=>{if(_e||!P.grant)return;const Se=P.grant;P.grant=void 0,Ge?.stop(),J.current?.cancel(),xt.length=0,ft.length=0,ie(Se);for(const je of De)je.abort();Be&&clearTimeout(Be),m(void 0),A(void 0),D(void 0),b(!1),fe(!1),X(""),ye(K)},Ce=K=>{const Se=Ed();return{...K,...Array.isArray(K.availableMethods)?{availableMethods:K.availableMethods.filter(je=>je!=="resources.recordVideo"||Se.camera||Se.screen)}:{},...typeof K.sessionId=="string"?{busy:re.current.busy}:{}}},Ae=(K,Se,je,Ne,ue)=>{_e||!P.grant||K!==h.current?.contentWindow||K.postMessage({type:"codeshell-panel:response",instanceId:P.grant.instanceId,requestId:Se,...Ne?{error:Ne,...ue?.code?{code:ue.code}:{},...ue?.retryAfterMs!==void 0?{retryAfterMs:ue.retryAfterMs}:{}}:{result:je}},"*")},Pe=()=>{if(_e||!P.grant||J.current||ee.current||Je)return;const K=xt.shift();if(!K)return;if(K.expiresAt<=Date.now()){Pe();return}let Se=!1;const je={effect:K,cancel:()=>{J.current===je&&(clearTimeout(Ne),J.current=void 0,_e||(L(void 0),T(""),fe(!1)))},finish:ue=>{if(_e||!P.grant||J.current!==je||Se)return;Se=!0,fe(!0),T("");const ke=new AbortController;De.add(ke);const Te=setTimeout(()=>ke.abort(),8e3);Ue(kt(`${er}/${P.grant.instanceId}/confirm`,ne,ge),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:K.requestId,allowed:ue}),signal:ke.signal}).then(G=>{if(!(_e||J.current!==je)){if(typeof G.allowed!="boolean")throw new Error("确认响应无效。");ue&&G.allowed===!1&&R("此确认已超时或被取消,操作未获准执行,请在面板中重新发起。"),!ue&&G.allowed===!0&&R("该操作此前已获准执行,请在面板中查看进度或停止。"),je.cancel(),Pe()}}).catch(G=>{if(!(_e||J.current!==je)){if(G instanceof Ze&&[401,403,410].includes(G.status)){xe(G);return}if(G instanceof Ze&&G.status===409){je.cancel(),R("面板操作确认已失效,请在面板中重新发起。"),Pe();return}T("暂未收到确认结果。可以重试本次确认,或取消尚未执行的请求。")}}).finally(()=>{clearTimeout(Te),De.delete(ke),Se=!1,!_e&&J.current===je&&fe(!1)})}},Ne=setTimeout(()=>{je.cancel(),!_e&&P.grant&&(R("面板操作确认已超时,请在面板中重新发起。"),Pe())},K.expiresAt-Date.now());J.current=je,L(je),T("")},wt=K=>{for(const Se of K){if(Se.event!=="host.confirm"){ft.push(Se);continue}const je=Se.payload;if(!tn(je)||typeof je.requestId!="string"||!/^[A-Za-z0-9_-]{1,128}$/.test(je.requestId)||typeof je.title!="string"||je.title.length>500||typeof je.body!="string"||je.body.length>3e4)throw new Error("面板操作确认格式无效。");Ke.has(je.requestId)||(Ke.add(je.requestId),xt.push({effect:"host.confirm",requestId:je.requestId,title:je.title,body:je.body,expiresAt:Date.now()+5e4}))}if(ft.length>2048||xt.length>32){xe(new Error("面板状态积压过多,请重新打开面板。"));return}Pe(),Ie()},ct=K=>new Promise(Se=>{if(J.current||ee.current||Je){Se(!1);return}const je={effect:K,finish:ue=>{J.current===je&&(clearTimeout(Ne),J.current=void 0,_e||L(void 0),Se(ue),queueMicrotask(Pe))},cancel:()=>je.finish(!1)},Ne=setTimeout(()=>je.finish(!1),55e3);J.current=je,L(je)}),mt=async K=>{const Se=h.current?.contentWindow,je=P.grant,Ne=K.data;if(_e||!Se||K.source!==Se||K.origin!=="null"||!je||!tn(Ne)||Ne.instanceId!==je.instanceId)return;if(Ne.type==="codeshell-panel:ready"){Lt=!0,pt();return}if(Ne.type==="codeshell-panel:tool-result"){if(typeof Ne.requestId!="string"||!Tt.has(Ne.requestId)||De.size>=32)return;let ce;try{if(ce=JSON.stringify({requestId:Ne.requestId,...typeof Ne.error=="string"?{error:Ne.error}:{result:Ne.result}}),new TextEncoder().encode(ce).length>512*1024)return}catch{return}Tt.delete(Ne.requestId);const qe=new AbortController;De.add(qe);const He=setTimeout(()=>qe.abort(),8e3);try{await Ue(kt(`${er}/${je.instanceId}/tool-results`,ne,ge),{method:"POST",headers:{"Content-Type":"application/json"},body:ce,signal:qe.signal})}catch(Yt){!_e&&P.grant&&(Yt instanceof Ze&&[401,410].includes(Yt.status)?xe(Yt):R("面板工具结果未能送达,请在对话中重新发起操作。"))}finally{clearTimeout(He),De.delete(qe)}return}if(Ne.type!=="codeshell-panel:call"||typeof Ne.requestId!="string"||!/^[A-Za-z0-9_-]{1,80}$/.test(Ne.requestId))return;const ue=Ne.requestId;if(ze.has(ue)){Ae(Se,ue,void 0,"此请求已经处理,请重新发起。");return}if(ze.size>=8192||De.size>=32){Ae(Se,ue,void 0,"面板请求过于频繁,请稍后重试。");return}if(ze.add(ue),typeof Ne.method!="string"||!/^[A-Za-z][A-Za-z0-9.]{0,63}$/.test(Ne.method)){Ae(Se,ue,void 0,"面板方法无效。");return}let ke;try{if(ke=JSON.stringify({method:Ne.method,params:Ne.params}),new TextEncoder().encode(ke).length>3*1024*1024)throw new Error("too large")}catch{Ae(Se,ue,void 0,"面板请求内容过大或格式无效。");return}const Te=new AbortController;let G=!1;De.add(Te);try{const ce=await Ue(kt(`${er}/${je.instanceId}/call`,ne,ge),{method:"POST",headers:{"Content-Type":"application/json"},body:ke,signal:Te.signal});if(_e||Te.signal.aborted)return;if(Ne.method==="context.get"&&(Lt=!0,pt()),Ne.method==="external.open"){const qe=tn(ce)&&ce.effect===Ne.method?FS(ce.url):void 0;if(!qe)throw new Error("面板返回的外部链接无效。");if(!await ct({effect:"external.open",url:qe}))throw new Error("你取消了打开链接,或确认已超时。");Ae(Se,ue,{opened:!0})}else if(Ne.method==="agent.submitPrompt"){if(!tn(ce)||ce.effect!==Ne.method||typeof ce.prompt!="string"||!ce.prompt.trim()||ce.prompt.length>2e4||ce.sessionId!==i)throw new Error("面板任务与当前对话不匹配,请重新打开面板。");if(!await ct({effect:"agent.submitPrompt",prompt:ce.prompt,sessionId:i}))throw new Error("你取消了发送任务,或确认已超时。");if(_e||Te.signal.aborted)return;G=!0,Je=!0,fe(!0);const qe=await re.current.onSubmitPrompt({prompt:ce.prompt,sessionId:i});if(_e||Te.signal.aborted)return;R("面板任务已提交到当前对话,可切换到对话查看进度。"),Ae(Se,ue,qe)}else if(Ne.method==="resources.recordVideo.capabilities"){if(!tn(ce)||ce.effect!==Ne.method)throw new Error("视频录制能力响应无效。");Ae(Se,ue,Ed())}else if(Ne.method==="resources.recordAudio"||Ne.method==="resources.recordVideo"){const qe=Ne.method==="resources.recordVideo";if(!tn(ce)||ce.effect!==Ne.method)throw new Error("录制请求无效。");const He=qe?rv(Object.fromEntries(Object.entries(ce).filter(([Qe])=>Qe!=="effect"))):void 0;if(He){const Qe=Ed();if(!Qe[He.source]||He.microphone&&!Qe.microphone)throw new Error("当前浏览器不支持所选视频录制方式,请检查安全连接和设备支持。")}if(!qe&&(!tn(ce)||ce.effect!==Ne.method||!Number.isInteger(ce.maxDurationSeconds)||Number(ce.maxDurationSeconds)<1||Number(ce.maxDurationSeconds)>600||!Number.isInteger(ce.maxBytes)||Number(ce.maxBytes)<1||Number(ce.maxBytes)>25*1024*1024))throw new Error("录音请求无效。");if(ee.current||J.current||Je)throw new Error("请先完成当前的录制或确认操作。");const Yt=await new Promise((Qe,ot)=>{let tt=!1;const ht=(hn,Dt)=>{tt||(tt=!0,clearTimeout(ai),Te.signal.removeEventListener("abort",We),ee.current===Gt&&(ee.current=void 0,_e||(W(void 0),B(void 0))),Dt?ot(Dt):Qe(hn),Pe())},We=()=>ht(void 0,new Error("录制已关闭或授权已结束。")),ai=setTimeout(()=>ht(void 0,new Error("录制操作已超时,请重新打开。")),25*6e4),Gt={signal:Te.signal,maxDurationSeconds:Number(ce.maxDurationSeconds),maxBytes:Number(ce.maxBytes),...He?{...He,transferBudget:tn(je.context.capabilities)&&tn(je.context.capabilities.bridge)?je.context.capabilities.bridge:void 0}:{},call:async(hn,Dt,nn)=>{const Qn=nn?AbortSignal.any([Te.signal,nn]):Te.signal;if(Qn.throwIfAborted(),_e||P.grant!==je)throw new Error("当前项目授权已结束。");try{const Xn=await Ue(kt(`${er}/${je.instanceId}/call`,ne,ge),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({method:hn,params:Dt}),signal:Qn});if(Qn.throwIfAborted(),_e||P.grant!==je)throw new Error("当前项目授权已结束。");return Xn}catch(Xn){throw Xn instanceof Ze&&[401,403,410].includes(Xn.status)&&xe(Xn),Xn}},finish:ht};ee.current=Gt,Te.signal.addEventListener("abort",We,{once:!0}),qe?B(Gt):W(Gt)});Ae(Se,ue,Yt)}else if(Ne.method==="resources.open"){D(void 0),ae(!1);const qe=XS(ce,je.instanceId,tn(Ne.params)?Ne.params.assetId:void 0);if(!qe)throw new Error("面板文件预览链接无效,请重新打开文件。");D({...qe,url:kt(qe.url,ne,ge),downloadUrl:kt(`${qe.url}?download=1`,ne,ge)}),Ae(Se,ue,{opened:!0})}else if(Ne.method==="filesystem.openDirectory"){if(A(void 0),!tn(ce)||ce.effect!==Ne.method||typeof ce.path!="string")throw new Error("面板目录信息无效。");if(ce.url!==void 0&&!QS(ce.url,je.instanceId))throw new Error("面板目录链接无效,请重新打开目录。");A({path:ce.path,...typeof ce.url=="string"?{url:kt(ce.url,ne,ge)}:{}}),Ae(Se,ue,{opened:!1,path:ce.path})}else if(Ne.method==="notifications.send"){if(!tn(ce)||ce.effect!==Ne.method||typeof ce.title!="string"||ce.title.length>160||typeof ce.body!="string"||ce.body.length>2e3)throw new Error("面板通知格式无效。");R(`${ce.title}${ce.body?`:${ce.body}`:""}`),Ae(Se,ue,{sent:!0})}else Ae(Se,ue,Ne.method==="context.get"&&tn(ce)?Ce(ce):ce)}catch(ce){!_e&&!Te.signal.aborted&&(ce instanceof Ze&&[401,410].includes(ce.status)&&xe(ce),(Ne.method==="agent.submitPrompt"||Ne.method==="external.open")&&R(ce instanceof Error?ce.message:"面板操作未完成。"),Ae(Se,ue,void 0,ce instanceof Error?ce.message:"面板请求失败。",ce instanceof Ze?{code:ce.code,retryAfterMs:ce.retryAfterMs}:void 0))}finally{De.delete(Te),G&&(Je=!1,_e||fe(!1),Pe())}},lt=K=>{mt(K)};window.addEventListener("message",lt);const Pt=()=>Ge?.refresh(),bt=()=>{document.visibilityState==="visible"&&Pt()};return window.addEventListener("focus",Pt),window.addEventListener("online",Pt),document.addEventListener("visibilitychange",bt),Ue(kt(`${er}/prepare`,ne,ge),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({appId:t.id,revision:t.revision,...i?{sessionId:i}:{},theme:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",locale:"zh-CN"}),signal:ve.signal}).then(K=>{if(!ZS(K))throw new Error("面板启动信息无效,请刷新面板列表后重试。");if(_e||ve.signal.aborted){ie(K);return}if(K.expiresAt<=Date.now())throw ie(K),new Error("面板授权已过期,请重新打开。");P.grant=K,m({...K,context:Ce(K.context),src:kt(K.src,ne,ge)}),Be=setTimeout(()=>{xe(new Error("面板未能完成加载,请重新打开。若仍无法加载,可检查面板文件或使用桌面客户端。"))},45e3),Ge=qS({instanceId:K.instanceId,expiresAt:K.expiresAt,workspace:ne,projectId:ge,onEvents:wt,onTerminal:xe,onStatus:X})}).catch(K=>{!_e&&!ve.signal.aborted&&(b(!1),ye(K))}),()=>{_e=!0,J.current?.cancel(),window.removeEventListener("message",lt),window.removeEventListener("focus",Pt),window.removeEventListener("online",Pt),document.removeEventListener("visibilitychange",bt),Ge?.stop(),ve.abort();for(const K of De)K.abort();Be&&clearTimeout(Be),P.grant&&ie(P.grant),re.current.onDirtyChange?.(!1),be.current===M&&(be.current=void 0)}},[t.id,t.revision,i,k]),S.useEffect(()=>{!p||!h.current?.contentWindow||h.current.contentWindow.postMessage({type:"codeshell-panel:event",instanceId:p.instanceId,event:"context.changed",payload:{...p.context,...typeof p.context.sessionId=="string"?{busy:r}:{}}},"*")},[r,p]),s.jsxs("section",{className:"panel-host",children:[s.jsxs("header",{className:"panel-host-heading",children:[s.jsxs("div",{children:[s.jsx("h1",{children:t.title["zh-CN"]||t.title.default}),s.jsxs("p",{children:["v",t.version," · 运行于当前工作区"]})]}),s.jsx("button",{onClick:a,children:"返回面板"})]}),(p?.limitations??t.compatibility.reasons).length>0&&s.jsxs("details",{className:"panel-host-limitations",open:!0,children:[s.jsx("summary",{children:"部分功能可用"}),s.jsx("p",{children:"面板界面可以使用;以下功能尚未接入网页,使用时会显示具体限制。"}),s.jsx("ul",{children:(p?.limitations??t.compatibility.reasons).map(ne=>s.jsx("li",{children:ne},ne))})]}),j&&s.jsx("p",{className:"panel-host-notice",role:"status",children:j}),C&&s.jsxs("div",{className:"panel-host-notice panel-host-directory",role:"status",children:[s.jsxs("p",{children:["文件保存在服务器目录:",C.path]}),C.url&&s.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",children:"查看并下载文件"})]}),_&&s.jsxs("section",{className:"panel-host-preview","aria-label":"文件预览",tabIndex:-1,ref:N,children:[s.jsxs("header",{children:[s.jsx("h2",{children:_.name}),s.jsx("button",{onClick:()=>D(void 0),children:"关闭预览"})]}),!q&&_.kind==="video"&&s.jsx("video",{src:_.url,controls:!0,playsInline:!0,preload:"metadata",onError:()=>ae(!0)},_.url),!q&&_.kind==="audio"&&s.jsx("audio",{src:_.url,controls:!0,preload:"metadata",onError:()=>ae(!0)},_.url),!q&&_.kind==="image"&&s.jsx("img",{src:_.url,alt:_.name,onError:()=>ae(!0)},_.url),(q||_.kind==="file")&&s.jsx("p",{role:"status",children:"当前浏览器无法预览此文件。可以保存后打开;若保存失败,请重新打开面板检查访问权限。"}),s.jsx("a",{href:_.downloadUrl,download:_.name,children:"保存到此设备"})]}),U&&s.jsx("p",{className:"panel-host-notice",role:"status",children:U}),v&&s.jsxs("div",{className:"panel-host-error",role:"alert",children:[s.jsx("p",{children:v}),s.jsx("button",{disabled:y,onClick:()=>O(ne=>ne+1),children:"重新打开面板"})]}),y&&s.jsx("p",{className:"panel-host-loading",role:"status",children:"正在打开面板…"}),F&&s.jsx(VS,{request:F}),V&&s.jsx(YS,{request:V}),I&&s.jsxs("section",{className:"panel-host-confirm",ref:Z,tabIndex:-1,onKeyDown:ne=>{ne.key==="Escape"&&!Q&&(ne.preventDefault(),I.finish(!1))},"aria-label":I.effect.effect==="external.open"?"确认打开外部链接":I.effect.effect==="host.confirm"?"确认面板操作":"确认发送面板任务",children:[s.jsx("h2",{children:I.effect.effect==="external.open"?"面板请求打开网页":I.effect.effect==="host.confirm"?I.effect.title:"面板请求向当前对话发送任务"}),I.effect.effect==="external.open"?s.jsx("p",{className:"panel-host-url",children:I.effect.url}):I.effect.effect==="host.confirm"?s.jsx("pre",{children:I.effect.body}):s.jsx("pre",{children:I.effect.prompt}),H&&s.jsx("p",{role:"alert",children:H}),s.jsxs("div",{className:"panel-host-actions",children:[s.jsx("button",{disabled:Q,onClick:()=>I.finish(!1),children:"取消"}),I.effect.effect==="external.open"?s.jsx("a",{href:I.effect.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>I.finish(!0),children:"确认打开网页"}):s.jsx("button",{className:"panel-host-primary",disabled:Q,onClick:()=>I.finish(!0),children:Q?"正在确认…":I.effect.effect==="host.confirm"?"确认执行":"确认发送任务"})]})]}),p&&s.jsx("iframe",{ref:h,src:p.src,title:`${t.title["zh-CN"]||t.title.default}面板`,sandbox:"allow-scripts allow-downloads",referrerPolicy:"no-referrer",inert:!!I||Q||!!F||!!V,onLoad:()=>be.current?.loaded(),allow:"camera 'none'; microphone 'none'; geolocation 'none'; display-capture 'none'; clipboard-read 'none'; clipboard-write 'none'",className:"panel-host-frame"})]})}function WS(t,i){const r={};return(t[t.length-1]===""?[...t,""]:t).join((r.padRight?" ":"")+","+(r.padLeft===!1?"":" ")).trim()}const ej=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,tj=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,nj={};function Uy(t,i){return(nj.jsx?tj:ej).test(t)}const ij=/[ \t\n\f\r]/g;function rj(t){return typeof t=="object"?t.type==="text"?Iy(t.value):!1:Iy(t)}function Iy(t){return t.replace(ij,"")===""}class Ma{constructor(i,r,a){this.normal=r,this.property=i,a&&(this.space=a)}}Ma.prototype.normal={};Ma.prototype.property={};Ma.prototype.space=void 0;function av(t,i){const r={},a={};for(const u of t)Object.assign(r,u.property),Object.assign(a,u.normal);return new Ma(r,a,i)}function Zd(t){return t.toLowerCase()}class wn{constructor(i,r){this.attribute=r,this.property=i}}wn.prototype.attribute="";wn.prototype.booleanish=!1;wn.prototype.boolean=!1;wn.prototype.commaOrSpaceSeparated=!1;wn.prototype.commaSeparated=!1;wn.prototype.defined=!1;wn.prototype.mustUseProperty=!1;wn.prototype.number=!1;wn.prototype.overloadedBoolean=!1;wn.prototype.property="";wn.prototype.spaceSeparated=!1;wn.prototype.space=void 0;let lj=0;const Ve=Tr(),Zt=Tr(),Jd=Tr(),we=Tr(),zt=Tr(),Sr=Tr(),An=Tr();function Tr(){return 2**++lj}const Wd=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ve,booleanish:Zt,commaOrSpaceSeparated:An,commaSeparated:Sr,number:we,overloadedBoolean:Jd,spaceSeparated:zt},Symbol.toStringTag,{value:"Module"})),Nd=Object.keys(Wd);class Ef extends wn{constructor(i,r,a,u){let d=-1;if(super(i,r),qy(this,"space",u),typeof a=="number")for(;++d<Nd.length;){const c=Nd[d];qy(this,Nd[d],(a&Wd[c])===Wd[c])}}}Ef.prototype.defined=!0;function qy(t,i,r){r&&(t[i]=r)}function jl(t){const i={},r={};for(const[a,u]of Object.entries(t.properties)){const d=new Ef(a,t.transform(t.attributes||{},a),u,t.space);t.mustUseProperty&&t.mustUseProperty.includes(a)&&(d.mustUseProperty=!0),i[a]=d,r[Zd(a)]=a,r[Zd(d.attribute)]=a}return new Ma(i,r,t.space)}const sv=jl({properties:{ariaActiveDescendant:null,ariaAtomic:Zt,ariaAutoComplete:null,ariaBusy:Zt,ariaChecked:Zt,ariaColCount:we,ariaColIndex:we,ariaColSpan:we,ariaControls:zt,ariaCurrent:null,ariaDescribedBy:zt,ariaDetails:null,ariaDisabled:Zt,ariaDropEffect:zt,ariaErrorMessage:null,ariaExpanded:Zt,ariaFlowTo:zt,ariaGrabbed:Zt,ariaHasPopup:null,ariaHidden:Zt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:zt,ariaLevel:we,ariaLive:null,ariaModal:Zt,ariaMultiLine:Zt,ariaMultiSelectable:Zt,ariaOrientation:null,ariaOwns:zt,ariaPlaceholder:null,ariaPosInSet:we,ariaPressed:Zt,ariaReadOnly:Zt,ariaRelevant:null,ariaRequired:Zt,ariaRoleDescription:zt,ariaRowCount:we,ariaRowIndex:we,ariaRowSpan:we,ariaSelected:Zt,ariaSetSize:we,ariaSort:null,ariaValueMax:we,ariaValueMin:we,ariaValueNow:we,ariaValueText:null,role:null},transform(t,i){return i==="role"?i:"aria-"+i.slice(4).toLowerCase()}});function ov(t,i){return i in t?t[i]:i}function uv(t,i){return ov(t,i.toLowerCase())}const aj=jl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Sr,acceptCharset:zt,accessKey:zt,action:null,allow:null,allowFullScreen:Ve,allowPaymentRequest:Ve,allowUserMedia:Ve,alpha:Ve,alt:null,as:null,async:Ve,autoCapitalize:null,autoComplete:zt,autoFocus:Ve,autoPlay:Ve,blocking:zt,capture:null,charSet:null,checked:Ve,cite:null,className:zt,closedBy:null,colorSpace:null,cols:we,colSpan:we,command:null,commandFor:null,content:null,contentEditable:Zt,controls:Ve,controlsList:zt,coords:we|Sr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ve,defer:Ve,dir:null,dirName:null,disabled:Ve,download:Jd,draggable:Zt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ve,formTarget:null,headers:zt,height:we,hidden:Jd,high:we,href:null,hrefLang:null,htmlFor:zt,httpEquiv:zt,id:null,imageSizes:null,imageSrcSet:null,inert:Ve,inputMode:null,integrity:null,is:null,isMap:Ve,itemId:null,itemProp:zt,itemRef:zt,itemScope:Ve,itemType:zt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ve,low:we,manifest:null,max:null,maxLength:we,media:null,method:null,min:null,minLength:we,multiple:Ve,muted:Ve,name:null,nonce:null,noModule:Ve,noValidate:Ve,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:Ve,optimum:we,pattern:null,ping:zt,placeholder:null,playsInline:Ve,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ve,referrerPolicy:null,rel:zt,required:Ve,reversed:Ve,rows:we,rowSpan:we,sandbox:zt,scope:null,scoped:Ve,seamless:Ve,selected:Ve,shadowRootClonable:Ve,shadowRootCustomElementRegistry:Ve,shadowRootDelegatesFocus:Ve,shadowRootMode:null,shadowRootSerializable:Ve,shape:null,size:we,sizes:null,slot:null,span:we,spellCheck:Zt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:we,step:null,style:null,tabIndex:we,target:null,title:null,translate:null,type:null,typeMustMatch:Ve,useMap:null,value:Zt,width:we,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:zt,axis:null,background:null,bgColor:null,border:we,borderColor:null,bottomMargin:we,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ve,declare:Ve,event:null,face:null,frame:null,frameBorder:null,hSpace:we,leftMargin:we,link:null,longDesc:null,lowSrc:null,marginHeight:we,marginWidth:we,noResize:Ve,noHref:Ve,noShade:Ve,noWrap:Ve,object:null,profile:null,prompt:null,rev:null,rightMargin:we,rules:null,scheme:null,scrolling:Zt,standby:null,summary:null,text:null,topMargin:we,valueType:null,version:null,vAlign:null,vLink:null,vSpace:we,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Ve,disablePictureInPicture:Ve,disableRemotePlayback:Ve,exportParts:Sr,part:zt,prefix:null,property:null,results:we,security:null,unselectable:null},space:"html",transform:uv}),sj=jl({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:An,accentHeight:we,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:we,amplitude:we,arabicForm:null,ascent:we,attributeName:null,attributeType:null,azimuth:we,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:we,by:null,calcMode:null,capHeight:we,className:zt,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:we,diffuseConstant:we,direction:null,display:null,dur:null,divisor:we,dominantBaseline:null,download:Ve,dx:null,dy:null,edgeMode:null,editable:null,elevation:we,enableBackground:null,end:null,event:null,exponent:we,externalResourcesRequired:null,fill:null,fillOpacity:we,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:Sr,g2:Sr,glyphName:Sr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:we,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:we,horizOriginX:we,horizOriginY:we,id:null,ideographic:we,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:we,k:we,k1:we,k2:we,k3:we,k4:we,kernelMatrix:An,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:we,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:we,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:we,overlineThickness:we,paintOrder:null,panose1:null,path:null,pathLength:we,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:zt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:we,pointsAtY:we,pointsAtZ:we,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:An,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:An,rev:An,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:An,requiredFeatures:An,requiredFonts:An,requiredFormats:An,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:we,specularExponent:we,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:we,strikethroughThickness:we,string:null,stroke:null,strokeDashArray:An,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:we,strokeOpacity:we,strokeWidth:null,style:null,surfaceScale:we,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:An,tabIndex:we,tableValues:null,target:null,targetX:we,targetY:we,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:An,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:we,underlineThickness:we,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:we,values:null,vAlphabetic:we,vMathematical:we,vectorEffect:null,vHanging:we,vIdeographic:we,version:null,vertAdvY:we,vertOriginX:we,vertOriginY:we,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:we,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:ov}),cv=jl({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,i){return"xlink:"+i.slice(5).toLowerCase()}}),dv=jl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:uv}),fv=jl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,i){return"xml:"+i.slice(3).toLowerCase()}}),oj={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"},uj=/[A-Z]/g,Hy=/-[a-z]/g,cj=/^data[-\w.:]+$/i;function dj(t,i){const r=Zd(i);let a=i,u=wn;if(r in t.normal)return t.property[t.normal[r]];if(r.length>4&&r.slice(0,4)==="data"&&cj.test(i)){if(i.charAt(4)==="-"){const d=i.slice(5).replace(Hy,hj);a="data"+d.charAt(0).toUpperCase()+d.slice(1)}else{const d=i.slice(4);if(!Hy.test(d)){let c=d.replace(uj,fj);c.charAt(0)!=="-"&&(c="-"+c),i="data"+c}}u=Ef}return new u(a,i)}function fj(t){return"-"+t.toLowerCase()}function hj(t){return t.charAt(1).toUpperCase()}const pj=av([sv,aj,cv,dv,fv],"html"),Nf=av([sv,sj,cv,dv,fv],"svg");function mj(t){return t.join(" ").trim()}var pl={},Td,Gy;function gj(){if(Gy)return Td;Gy=1;var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,i=/\n/g,r=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,u=/^:\s*/,d=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,h=/^\s+|\s+$/g,p=`
29
- `,m="/",y="*",b="",v="comment",x="declaration";function j(C,A){if(typeof C!="string")throw new TypeError("First argument must be a string");if(!C)return[];A=A||{};var _=1,D=1;function q(W){var ee=W.match(i);ee&&(_+=ee.length);var V=W.lastIndexOf(p);D=~V?W.length-V:D+W.length}function ae(){var W={line:_,column:D};return function(ee){return ee.position=new N(W),H(),ee}}function N(W){this.start=W,this.end={line:_,column:D},this.source=A.source}N.prototype.content=C;function U(W){var ee=new Error(A.source+":"+_+":"+D+": "+W);if(ee.reason=W,ee.filename=A.source,ee.line=_,ee.column=D,ee.source=C,!A.silent)throw ee}function X(W){var ee=W.exec(C);if(ee){var V=ee[0];return q(V),C=C.slice(V.length),ee}}function H(){X(r)}function T(W){var ee;for(W=W||[];ee=I();)ee!==!1&&W.push(ee);return W}function I(){var W=ae();if(!(m!=C.charAt(0)||y!=C.charAt(1))){for(var ee=2;b!=C.charAt(ee)&&(y!=C.charAt(ee)||m!=C.charAt(ee+1));)++ee;if(ee+=2,b===C.charAt(ee-1))return U("End of comment missing");var V=C.slice(2,ee-2);return D+=2,q(V),C=C.slice(ee),D+=2,W({type:v,comment:V})}}function L(){var W=ae(),ee=X(a);if(ee){if(I(),!X(u))return U("property missing ':'");var V=X(d),B=W({type:x,property:R(ee[0].replace(t,b)),value:V?R(V[0].replace(t,b)):b});return X(c),B}}function F(){var W=[];T(W);for(var ee;ee=L();)ee!==!1&&(W.push(ee),T(W));return W}return H(),F()}function R(C){return C?C.replace(h,b):b}return Td=j,Td}var Vy;function yj(){if(Vy)return pl;Vy=1;var t=pl&&pl.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(pl,"__esModule",{value:!0}),pl.default=r;const i=t(gj());function r(a,u){let d=null;if(!a||typeof a!="string")return d;const c=(0,i.default)(a),h=typeof u=="function";return c.forEach(p=>{if(p.type!=="declaration")return;const{property:m,value:y}=p;h?u(m,y,p):y&&(d=d||{},d[m]=y)}),d}return pl}var xa={},$y;function bj(){if($y)return xa;$y=1,Object.defineProperty(xa,"__esModule",{value:!0}),xa.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,i=/-([a-z])/g,r=/^[^-]+$/,a=/^-(webkit|moz|ms|o|khtml)-/,u=/^-(ms)-/,d=function(m){return!m||r.test(m)||t.test(m)},c=function(m,y){return y.toUpperCase()},h=function(m,y){return"".concat(y,"-")},p=function(m,y){return y===void 0&&(y={}),d(m)?m:(m=m.toLowerCase(),y.reactCompat?m=m.replace(u,h):m=m.replace(a,h),m.replace(i,c))};return xa.camelCase=p,xa}var wa,Py;function vj(){if(Py)return wa;Py=1;var t=wa&&wa.__importDefault||function(u){return u&&u.__esModule?u:{default:u}},i=t(yj()),r=bj();function a(u,d){var c={};return!u||typeof u!="string"||(0,i.default)(u,function(h,p){h&&p&&(c[(0,r.camelCase)(h,d)]=p)}),c}return a.default=a,wa=a,wa}var xj=vj();const wj=ko(xj),hv=pv("end"),Tf=pv("start");function pv(t){return i;function i(r){const a=r&&r.position&&r.position[t]||{};if(typeof a.line=="number"&&a.line>0&&typeof a.column=="number"&&a.column>0)return{line:a.line,column:a.column,offset:typeof a.offset=="number"&&a.offset>-1?a.offset:void 0}}}function Sj(t){const i=Tf(t),r=hv(t);if(i&&r)return{start:i,end:r}}function Ca(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?Yy(t.position):"start"in t||"end"in t?Yy(t):"line"in t||"column"in t?ef(t):""}function ef(t){return Fy(t&&t.line)+":"+Fy(t&&t.column)}function Yy(t){return ef(t&&t.start)+"-"+ef(t&&t.end)}function Fy(t){return t&&typeof t=="number"?t:1}class cn extends Error{constructor(i,r,a){super(),typeof r=="string"&&(a=r,r=void 0);let u="",d={},c=!1;if(r&&("line"in r&&"column"in r?d={place:r}:"start"in r&&"end"in r?d={place:r}:"type"in r?d={ancestors:[r],place:r.position}:d={...r}),typeof i=="string"?u=i:!d.cause&&i&&(c=!0,u=i.message,d.cause=i),!d.ruleId&&!d.source&&typeof a=="string"){const p=a.indexOf(":");p===-1?d.ruleId=a:(d.source=a.slice(0,p),d.ruleId=a.slice(p+1))}if(!d.place&&d.ancestors&&d.ancestors){const p=d.ancestors[d.ancestors.length-1];p&&(d.place=p.position)}const h=d.place&&"start"in d.place?d.place.start:d.place;this.ancestors=d.ancestors||void 0,this.cause=d.cause||void 0,this.column=h?h.column:void 0,this.fatal=void 0,this.file="",this.message=u,this.line=h?h.line:void 0,this.name=Ca(d.place)||"1:1",this.place=d.place||void 0,this.reason=this.message,this.ruleId=d.ruleId||void 0,this.source=d.source||void 0,this.stack=c&&d.cause&&typeof d.cause.stack=="string"?d.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}cn.prototype.file="";cn.prototype.name="";cn.prototype.reason="";cn.prototype.message="";cn.prototype.stack="";cn.prototype.column=void 0;cn.prototype.line=void 0;cn.prototype.ancestors=void 0;cn.prototype.cause=void 0;cn.prototype.fatal=void 0;cn.prototype.place=void 0;cn.prototype.ruleId=void 0;cn.prototype.source=void 0;const Af={}.hasOwnProperty,jj=new Map,kj=/[A-Z]/g,Cj=new Set(["table","tbody","thead","tfoot","tr"]),Ej=new Set(["td","th"]),mv="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Nj(t,i){if(!i||i.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const r=i.filePath||void 0;let a;if(i.development){if(typeof i.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");a=Oj(r,i.jsxDEV)}else{if(typeof i.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof i.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");a=Mj(r,i.jsx,i.jsxs)}const u={Fragment:i.Fragment,ancestors:[],components:i.components||{},create:a,elementAttributeNameCase:i.elementAttributeNameCase||"react",evaluater:i.createEvaluater?i.createEvaluater():void 0,filePath:r,ignoreInvalidStyle:i.ignoreInvalidStyle||!1,passKeys:i.passKeys!==!1,passNode:i.passNode||!1,schema:i.space==="svg"?Nf:pj,stylePropertyNameCase:i.stylePropertyNameCase||"dom",tableCellAlignToStyle:i.tableCellAlignToStyle!==!1},d=gv(u,t,void 0);return d&&typeof d!="string"?d:u.create(t,u.Fragment,{children:d||void 0},void 0)}function gv(t,i,r){if(i.type==="element")return Tj(t,i,r);if(i.type==="mdxFlowExpression"||i.type==="mdxTextExpression")return Aj(t,i);if(i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement")return zj(t,i,r);if(i.type==="mdxjsEsm")return Rj(t,i);if(i.type==="root")return _j(t,i,r);if(i.type==="text")return Dj(t,i)}function Tj(t,i,r){const a=t.schema;let u=a;i.tagName.toLowerCase()==="svg"&&a.space==="html"&&(u=Nf,t.schema=u),t.ancestors.push(i);const d=bv(t,i.tagName,!1),c=Lj(t,i);let h=zf(t,i);return Cj.has(i.tagName)&&(h=h.filter(function(p){return typeof p=="string"?!rj(p):!0})),yv(t,c,d,i),Rf(c,h),t.ancestors.pop(),t.schema=a,t.create(i,d,c,r)}function Aj(t,i){if(i.data&&i.data.estree&&t.evaluater){const a=i.data.estree.body[0];return a.type,t.evaluater.evaluateExpression(a.expression)}Aa(t,i.position)}function Rj(t,i){if(i.data&&i.data.estree&&t.evaluater)return t.evaluater.evaluateProgram(i.data.estree);Aa(t,i.position)}function zj(t,i,r){const a=t.schema;let u=a;i.name==="svg"&&a.space==="html"&&(u=Nf,t.schema=u),t.ancestors.push(i);const d=i.name===null?t.Fragment:bv(t,i.name,!0),c=Bj(t,i),h=zf(t,i);return yv(t,c,d,i),Rf(c,h),t.ancestors.pop(),t.schema=a,t.create(i,d,c,r)}function _j(t,i,r){const a={};return Rf(a,zf(t,i)),t.create(i,t.Fragment,a,r)}function Dj(t,i){return i.value}function yv(t,i,r,a){typeof r!="string"&&r!==t.Fragment&&t.passNode&&(i.node=a)}function Rf(t,i){if(i.length>0){const r=i.length>1?i:i[0];r&&(t.children=r)}}function Mj(t,i,r){return a;function a(u,d,c,h){const m=Array.isArray(c.children)?r:i;return h?m(d,c,h):m(d,c)}}function Oj(t,i){return r;function r(a,u,d,c){const h=Array.isArray(d.children),p=Tf(a);return i(u,d,c,h,{columnNumber:p?p.column-1:void 0,fileName:t,lineNumber:p?p.line:void 0},void 0)}}function Lj(t,i){const r={};let a,u;for(u in i.properties)if(u!=="children"&&Af.call(i.properties,u)){const d=Uj(t,u,i.properties[u]);if(d){const[c,h]=d;t.tableCellAlignToStyle&&c==="align"&&typeof h=="string"&&Ej.has(i.tagName)?a=h:r[c]=h}}if(a){const d=r.style||(r.style={});d[t.stylePropertyNameCase==="css"?"text-align":"textAlign"]=a}return r}function Bj(t,i){const r={};for(const a of i.attributes)if(a.type==="mdxJsxExpressionAttribute")if(a.data&&a.data.estree&&t.evaluater){const d=a.data.estree.body[0];d.type;const c=d.expression;c.type;const h=c.properties[0];h.type,Object.assign(r,t.evaluater.evaluateExpression(h.argument))}else Aa(t,i.position);else{const u=a.name;let d;if(a.value&&typeof a.value=="object")if(a.value.data&&a.value.data.estree&&t.evaluater){const h=a.value.data.estree.body[0];h.type,d=t.evaluater.evaluateExpression(h.expression)}else Aa(t,i.position);else d=a.value===null?!0:a.value;r[u]=d}return r}function zf(t,i){const r=[];let a=-1;const u=t.passKeys?new Map:jj;for(;++a<i.children.length;){const d=i.children[a];let c;if(t.passKeys){const p=d.type==="element"?d.tagName:d.type==="mdxJsxFlowElement"||d.type==="mdxJsxTextElement"?d.name:void 0;if(p){const m=u.get(p)||0;c=p+"-"+m,u.set(p,m+1)}}const h=gv(t,d,c);h!==void 0&&r.push(h)}return r}function Uj(t,i,r){const a=dj(t.schema,i);if(!(r==null||typeof r=="number"&&Number.isNaN(r))){if(Array.isArray(r)&&(r=a.commaSeparated?WS(r):mj(r)),a.property==="style"){let u=typeof r=="object"?r:Ij(t,String(r));return t.stylePropertyNameCase==="css"&&(u=qj(u)),["style",u]}return[t.elementAttributeNameCase==="react"&&a.space?oj[a.property]||a.property:a.attribute,r]}}function Ij(t,i){try{return wj(i,{reactCompat:!0})}catch(r){if(t.ignoreInvalidStyle)return{};const a=r,u=new cn("Cannot parse `style` attribute",{ancestors:t.ancestors,cause:a,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw u.file=t.filePath||void 0,u.url=mv+"#cannot-parse-style-attribute",u}}function bv(t,i,r){let a;if(!r)a={type:"Literal",value:i};else if(i.includes(".")){const u=i.split(".");let d=-1,c;for(;++d<u.length;){const h=Uy(u[d])?{type:"Identifier",name:u[d]}:{type:"Literal",value:u[d]};c=c?{type:"MemberExpression",object:c,property:h,computed:!!(d&&h.type==="Literal"),optional:!1}:h}a=c}else a=Uy(i)&&!/^[a-z]/.test(i)?{type:"Identifier",name:i}:{type:"Literal",value:i};if(a.type==="Literal"){const u=a.value;return Af.call(t.components,u)?t.components[u]:u}if(t.evaluater)return t.evaluater.evaluateExpression(a);Aa(t)}function Aa(t,i){const r=new cn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:t.ancestors,place:i,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw r.file=t.filePath||void 0,r.url=mv+"#cannot-handle-mdx-estrees-without-createevaluater",r}function qj(t){const i={};let r;for(r in t)Af.call(t,r)&&(i[Hj(r)]=t[r]);return i}function Hj(t){let i=t.replace(kj,Gj);return i.slice(0,3)==="ms-"&&(i="-"+i),i}function Gj(t){return"-"+t.toLowerCase()}const Ad={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"]},Vj={};function _f(t,i){const r=Vj,a=typeof r.includeImageAlt=="boolean"?r.includeImageAlt:!0,u=typeof r.includeHtml=="boolean"?r.includeHtml:!0;return vv(t,a,u)}function vv(t,i,r){if($j(t)){if("value"in t)return t.type==="html"&&!r?"":t.value;if(i&&"alt"in t&&t.alt)return t.alt;if("children"in t)return Qy(t.children,i,r)}return Array.isArray(t)?Qy(t,i,r):""}function Qy(t,i,r){const a=[];let u=-1;for(;++u<t.length;)a[u]=vv(t[u],i,r);return a.join("")}function $j(t){return!!(t&&typeof t=="object")}const Xy=document.createElement("i");function Df(t){const i="&"+t+";";Xy.innerHTML=i;const r=Xy.textContent;return r.charCodeAt(r.length-1)===59&&t!=="semi"||r===i?!1:r}function Rn(t,i,r,a){const u=t.length;let d=0,c;if(i<0?i=-i>u?0:u+i:i=i>u?u:i,r=r>0?r:0,a.length<1e4)c=Array.from(a),c.unshift(i,r),t.splice(...c);else for(r&&t.splice(i,r);d<a.length;)c=a.slice(d,d+1e4),c.unshift(i,0),t.splice(...c),d+=1e4,i+=1e4}function Hn(t,i){return t.length>0?(Rn(t,t.length,0,i),t):i}const Ky={}.hasOwnProperty;function xv(t){const i={};let r=-1;for(;++r<t.length;)Pj(i,t[r]);return i}function Pj(t,i){let r;for(r in i){const u=(Ky.call(t,r)?t[r]:void 0)||(t[r]={}),d=i[r];let c;if(d)for(c in d){Ky.call(u,c)||(u[c]=[]);const h=d[c];Yj(u[c],Array.isArray(h)?h:h?[h]:[])}}}function Yj(t,i){let r=-1;const a=[];for(;++r<i.length;)(i[r].add==="after"?t:a).push(i[r]);Rn(t,0,0,a)}function wv(t,i){const r=Number.parseInt(t,i);return r<9||r===11||r>13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111?"�":String.fromCodePoint(r)}function Fn(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const fn=tr(/[A-Za-z]/),un=tr(/[\dA-Za-z]/),Fj=tr(/[#-'*+\--9=?A-Z^-~]/);function vo(t){return t!==null&&(t<32||t===127)}const tf=tr(/\d/),Qj=tr(/[\dA-Fa-f]/),Xj=tr(/[!-/:-@[-`{-~]/);function Oe(t){return t!==null&&t<-2}function _t(t){return t!==null&&(t<0||t===32)}function rt(t){return t===-2||t===-1||t===32}const No=tr(new RegExp("\\p{P}|\\p{S}","u")),jr=tr(/\s/);function tr(t){return i;function i(r){return r!==null&&r>-1&&t.test(String.fromCharCode(r))}}function kl(t){const i=[];let r=-1,a=0,u=0;for(;++r<t.length;){const d=t.charCodeAt(r);let c="";if(d===37&&un(t.charCodeAt(r+1))&&un(t.charCodeAt(r+2)))u=2;else if(d<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(d))||(c=String.fromCharCode(d));else if(d>55295&&d<57344){const h=t.charCodeAt(r+1);d<56320&&h>56319&&h<57344?(c=String.fromCharCode(d,h),u=1):c="�"}else c=String.fromCharCode(d);c&&(i.push(t.slice(a,r),encodeURIComponent(c)),a=r+u+1,c=""),u&&(r+=u,u=0)}return i.join("")+t.slice(a)}function dt(t,i,r,a){const u=a?a-1:Number.POSITIVE_INFINITY;let d=0;return c;function c(p){return rt(p)?(t.enter(r),h(p)):i(p)}function h(p){return rt(p)&&d++<u?(t.consume(p),h):(t.exit(r),i(p))}}const Kj={tokenize:Zj};function Zj(t){const i=t.attempt(this.parser.constructs.contentInitial,a,u);let r;return i;function a(h){if(h===null){t.consume(h);return}return t.enter("lineEnding"),t.consume(h),t.exit("lineEnding"),dt(t,i,"linePrefix")}function u(h){return t.enter("paragraph"),d(h)}function d(h){const p=t.enter("chunkText",{contentType:"text",previous:r});return r&&(r.next=p),r=p,c(h)}function c(h){if(h===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(h);return}return Oe(h)?(t.consume(h),t.exit("chunkText"),d):(t.consume(h),c)}}const Jj={tokenize:Wj},Zy={tokenize:ek};function Wj(t){const i=this,r=[];let a=0,u,d,c;return h;function h(D){if(a<r.length){const q=r[a];return i.containerState=q[1],t.attempt(q[0].continuation,p,m)(D)}return m(D)}function p(D){if(a++,i.containerState._closeFlow){i.containerState._closeFlow=void 0,u&&_();const q=i.events.length;let ae=q,N;for(;ae--;)if(i.events[ae][0]==="exit"&&i.events[ae][1].type==="chunkFlow"){N=i.events[ae][1].end;break}A(a);let U=q;for(;U<i.events.length;)i.events[U][1].end={...N},U++;return Rn(i.events,ae+1,0,i.events.slice(q)),i.events.length=U,m(D)}return h(D)}function m(D){if(a===r.length){if(!u)return v(D);if(u.currentConstruct&&u.currentConstruct.concrete)return j(D);i.interrupt=!!(u.currentConstruct&&!u._gfmTableDynamicInterruptHack)}return i.containerState={},t.check(Zy,y,b)(D)}function y(D){return u&&_(),A(a),v(D)}function b(D){return i.parser.lazy[i.now().line]=a!==r.length,c=i.now().offset,j(D)}function v(D){return i.containerState={},t.attempt(Zy,x,j)(D)}function x(D){return a++,r.push([i.currentConstruct,i.containerState]),v(D)}function j(D){if(D===null){u&&_(),A(0),t.consume(D);return}return u=u||i.parser.flow(i.now()),t.enter("chunkFlow",{_tokenizer:u,contentType:"flow",previous:d}),R(D)}function R(D){if(D===null){C(t.exit("chunkFlow"),!0),A(0),t.consume(D);return}return Oe(D)?(t.consume(D),C(t.exit("chunkFlow")),a=0,i.interrupt=void 0,h):(t.consume(D),R)}function C(D,q){const ae=i.sliceStream(D);if(q&&ae.push(null),D.previous=d,d&&(d.next=D),d=D,u.defineSkip(D.start),u.write(ae),i.parser.lazy[D.start.line]){let N=u.events.length;for(;N--;)if(u.events[N][1].start.offset<c&&(!u.events[N][1].end||u.events[N][1].end.offset>c))return;const U=i.events.length;let X=U,H,T;for(;X--;)if(i.events[X][0]==="exit"&&i.events[X][1].type==="chunkFlow"){if(H){T=i.events[X][1].end;break}H=!0}for(A(a),N=U;N<i.events.length;)i.events[N][1].end={...T},N++;Rn(i.events,X+1,0,i.events.slice(U)),i.events.length=N}}function A(D){let q=r.length;for(;q-- >D;){const ae=r[q];i.containerState=ae[1],ae[0].exit.call(i,t)}r.length=D}function _(){u.write([null]),d=void 0,u=void 0,i.containerState._closeFlow=void 0}}function ek(t,i,r){return dt(t,t.attempt(this.parser.constructs.document,i,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function wl(t){if(t===null||_t(t)||jr(t))return 1;if(No(t))return 2}function To(t,i,r){const a=[];let u=-1;for(;++u<t.length;){const d=t[u].resolveAll;d&&!a.includes(d)&&(i=d(i,r),a.push(d))}return i}const nf={name:"attention",resolveAll:tk,tokenize:nk};function tk(t,i){let r=-1,a,u,d,c,h,p,m,y;for(;++r<t.length;)if(t[r][0]==="enter"&&t[r][1].type==="attentionSequence"&&t[r][1]._close){for(a=r;a--;)if(t[a][0]==="exit"&&t[a][1].type==="attentionSequence"&&t[a][1]._open&&i.sliceSerialize(t[a][1]).charCodeAt(0)===i.sliceSerialize(t[r][1]).charCodeAt(0)){if((t[a][1]._close||t[r][1]._open)&&(t[r][1].end.offset-t[r][1].start.offset)%3&&!((t[a][1].end.offset-t[a][1].start.offset+t[r][1].end.offset-t[r][1].start.offset)%3))continue;p=t[a][1].end.offset-t[a][1].start.offset>1&&t[r][1].end.offset-t[r][1].start.offset>1?2:1;const b={...t[a][1].end},v={...t[r][1].start};Jy(b,-p),Jy(v,p),c={type:p>1?"strongSequence":"emphasisSequence",start:b,end:{...t[a][1].end}},h={type:p>1?"strongSequence":"emphasisSequence",start:{...t[r][1].start},end:v},d={type:p>1?"strongText":"emphasisText",start:{...t[a][1].end},end:{...t[r][1].start}},u={type:p>1?"strong":"emphasis",start:{...c.start},end:{...h.end}},t[a][1].end={...c.start},t[r][1].start={...h.end},m=[],t[a][1].end.offset-t[a][1].start.offset&&(m=Hn(m,[["enter",t[a][1],i],["exit",t[a][1],i]])),m=Hn(m,[["enter",u,i],["enter",c,i],["exit",c,i],["enter",d,i]]),m=Hn(m,To(i.parser.constructs.insideSpan.null,t.slice(a+1,r),i)),m=Hn(m,[["exit",d,i],["enter",h,i],["exit",h,i],["exit",u,i]]),t[r][1].end.offset-t[r][1].start.offset?(y=2,m=Hn(m,[["enter",t[r][1],i],["exit",t[r][1],i]])):y=0,Rn(t,a-1,r-a+3,m),r=a+m.length-y-2;break}}for(r=-1;++r<t.length;)t[r][1].type==="attentionSequence"&&(t[r][1].type="data");return t}function nk(t,i){const r=this.parser.constructs.attentionMarkers.null,a=this.previous,u=wl(a);let d;return c;function c(p){return d=p,t.enter("attentionSequence"),h(p)}function h(p){if(p===d)return t.consume(p),h;const m=t.exit("attentionSequence"),y=wl(p),b=!y||y===2&&u||r.includes(p),v=!u||u===2&&y||r.includes(a);return m._open=!!(d===42?b:b&&(u||!v)),m._close=!!(d===42?v:v&&(y||!b)),i(p)}}function Jy(t,i){t.column+=i,t.offset+=i,t._bufferIndex+=i}const ik={name:"autolink",tokenize:rk};function rk(t,i,r){let a=0;return u;function u(x){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(x),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),d}function d(x){return fn(x)?(t.consume(x),c):x===64?r(x):m(x)}function c(x){return x===43||x===45||x===46||un(x)?(a=1,h(x)):m(x)}function h(x){return x===58?(t.consume(x),a=0,p):(x===43||x===45||x===46||un(x))&&a++<32?(t.consume(x),h):(a=0,m(x))}function p(x){return x===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(x),t.exit("autolinkMarker"),t.exit("autolink"),i):x===null||x===32||x===60||vo(x)?r(x):(t.consume(x),p)}function m(x){return x===64?(t.consume(x),y):Fj(x)?(t.consume(x),m):r(x)}function y(x){return un(x)?b(x):r(x)}function b(x){return x===46?(t.consume(x),a=0,y):x===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(x),t.exit("autolinkMarker"),t.exit("autolink"),i):v(x)}function v(x){if((x===45||un(x))&&a++<63){const j=x===45?v:b;return t.consume(x),j}return r(x)}}const Oa={partial:!0,tokenize:lk};function lk(t,i,r){return a;function a(d){return rt(d)?dt(t,u,"linePrefix")(d):u(d)}function u(d){return d===null||Oe(d)?i(d):r(d)}}const Sv={continuation:{tokenize:sk},exit:ok,name:"blockQuote",tokenize:ak};function ak(t,i,r){const a=this;return u;function u(c){if(c===62){const h=a.containerState;return h.open||(t.enter("blockQuote",{_container:!0}),h.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(c),t.exit("blockQuoteMarker"),d}return r(c)}function d(c){return rt(c)?(t.enter("blockQuotePrefixWhitespace"),t.consume(c),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),i):(t.exit("blockQuotePrefix"),i(c))}}function sk(t,i,r){const a=this;return u;function u(c){return rt(c)?dt(t,d,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):d(c)}function d(c){return t.attempt(Sv,i,r)(c)}}function ok(t){t.exit("blockQuote")}const jv={name:"characterEscape",tokenize:uk};function uk(t,i,r){return a;function a(d){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(d),t.exit("escapeMarker"),u}function u(d){return Xj(d)?(t.enter("characterEscapeValue"),t.consume(d),t.exit("characterEscapeValue"),t.exit("characterEscape"),i):r(d)}}const kv={name:"characterReference",tokenize:ck};function ck(t,i,r){const a=this;let u=0,d,c;return h;function h(b){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(b),t.exit("characterReferenceMarker"),p}function p(b){return b===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(b),t.exit("characterReferenceMarkerNumeric"),m):(t.enter("characterReferenceValue"),d=31,c=un,y(b))}function m(b){return b===88||b===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(b),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),d=6,c=Qj,y):(t.enter("characterReferenceValue"),d=7,c=tf,y(b))}function y(b){if(b===59&&u){const v=t.exit("characterReferenceValue");return c===un&&!Df(a.sliceSerialize(v))?r(b):(t.enter("characterReferenceMarker"),t.consume(b),t.exit("characterReferenceMarker"),t.exit("characterReference"),i)}return c(b)&&u++<d?(t.consume(b),y):r(b)}}const Wy={partial:!0,tokenize:fk},eb={concrete:!0,name:"codeFenced",tokenize:dk};function dk(t,i,r){const a=this,u={partial:!0,tokenize:ae};let d=0,c=0,h;return p;function p(N){return m(N)}function m(N){const U=a.events[a.events.length-1];return d=U&&U[1].type==="linePrefix"?U[2].sliceSerialize(U[1],!0).length:0,h=N,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),y(N)}function y(N){return N===h?(c++,t.consume(N),y):c<3?r(N):(t.exit("codeFencedFenceSequence"),rt(N)?dt(t,b,"whitespace")(N):b(N))}function b(N){return N===null||Oe(N)?(t.exit("codeFencedFence"),a.interrupt?i(N):t.check(Wy,R,q)(N)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),v(N))}function v(N){return N===null||Oe(N)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),b(N)):rt(N)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),dt(t,x,"whitespace")(N)):N===96&&N===h?r(N):(t.consume(N),v)}function x(N){return N===null||Oe(N)?b(N):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),j(N))}function j(N){return N===null||Oe(N)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),b(N)):N===96&&N===h?r(N):(t.consume(N),j)}function R(N){return t.attempt(u,q,C)(N)}function C(N){return t.enter("lineEnding"),t.consume(N),t.exit("lineEnding"),A}function A(N){return d>0&&rt(N)?dt(t,_,"linePrefix",d+1)(N):_(N)}function _(N){return N===null||Oe(N)?t.check(Wy,R,q)(N):(t.enter("codeFlowValue"),D(N))}function D(N){return N===null||Oe(N)?(t.exit("codeFlowValue"),_(N)):(t.consume(N),D)}function q(N){return t.exit("codeFenced"),i(N)}function ae(N,U,X){let H=0;return T;function T(ee){return N.enter("lineEnding"),N.consume(ee),N.exit("lineEnding"),I}function I(ee){return N.enter("codeFencedFence"),rt(ee)?dt(N,L,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(ee):L(ee)}function L(ee){return ee===h?(N.enter("codeFencedFenceSequence"),F(ee)):X(ee)}function F(ee){return ee===h?(H++,N.consume(ee),F):H>=c?(N.exit("codeFencedFenceSequence"),rt(ee)?dt(N,W,"whitespace")(ee):W(ee)):X(ee)}function W(ee){return ee===null||Oe(ee)?(N.exit("codeFencedFence"),U(ee)):X(ee)}}}function fk(t,i,r){const a=this;return u;function u(c){return c===null?r(c):(t.enter("lineEnding"),t.consume(c),t.exit("lineEnding"),d)}function d(c){return a.parser.lazy[a.now().line]?r(c):i(c)}}const Rd={name:"codeIndented",tokenize:pk},hk={partial:!0,tokenize:mk};function pk(t,i,r){const a=this;return u;function u(m){return t.enter("codeIndented"),dt(t,d,"linePrefix",5)(m)}function d(m){const y=a.events[a.events.length-1];return y&&y[1].type==="linePrefix"&&y[2].sliceSerialize(y[1],!0).length>=4?c(m):r(m)}function c(m){return m===null?p(m):Oe(m)?t.attempt(hk,c,p)(m):(t.enter("codeFlowValue"),h(m))}function h(m){return m===null||Oe(m)?(t.exit("codeFlowValue"),c(m)):(t.consume(m),h)}function p(m){return t.exit("codeIndented"),i(m)}}function mk(t,i,r){const a=this;return u;function u(c){return a.parser.lazy[a.now().line]?r(c):Oe(c)?(t.enter("lineEnding"),t.consume(c),t.exit("lineEnding"),u):dt(t,d,"linePrefix",5)(c)}function d(c){const h=a.events[a.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?i(c):Oe(c)?u(c):r(c)}}const gk={name:"codeText",previous:bk,resolve:yk,tokenize:vk};function yk(t){let i=t.length-4,r=3,a,u;if((t[r][1].type==="lineEnding"||t[r][1].type==="space")&&(t[i][1].type==="lineEnding"||t[i][1].type==="space")){for(a=r;++a<i;)if(t[a][1].type==="codeTextData"){t[r][1].type="codeTextPadding",t[i][1].type="codeTextPadding",r+=2,i-=2;break}}for(a=r-1,i++;++a<=i;)u===void 0?a!==i&&t[a][1].type!=="lineEnding"&&(u=a):(a===i||t[a][1].type==="lineEnding")&&(t[u][1].type="codeTextData",a!==u+2&&(t[u][1].end=t[a-1][1].end,t.splice(u+2,a-u-2),i-=a-u-2,a=u+2),u=void 0);return t}function bk(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function vk(t,i,r){let a=0,u,d;return c;function c(b){return t.enter("codeText"),t.enter("codeTextSequence"),h(b)}function h(b){return b===96?(t.consume(b),a++,h):(t.exit("codeTextSequence"),p(b))}function p(b){return b===null?r(b):b===32?(t.enter("space"),t.consume(b),t.exit("space"),p):b===96?(d=t.enter("codeTextSequence"),u=0,y(b)):Oe(b)?(t.enter("lineEnding"),t.consume(b),t.exit("lineEnding"),p):(t.enter("codeTextData"),m(b))}function m(b){return b===null||b===32||b===96||Oe(b)?(t.exit("codeTextData"),p(b)):(t.consume(b),m)}function y(b){return b===96?(t.consume(b),u++,y):u===a?(t.exit("codeTextSequence"),t.exit("codeText"),i(b)):(d.type="codeTextData",m(b))}}class xk{constructor(i){this.left=i?[...i]:[],this.right=[]}get(i){if(i<0||i>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+i+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return i<this.left.length?this.left[i]:this.right[this.right.length-i+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(i,r){const a=r??Number.POSITIVE_INFINITY;return a<this.left.length?this.left.slice(i,a):i>this.left.length?this.right.slice(this.right.length-a+this.left.length,this.right.length-i+this.left.length).reverse():this.left.slice(i).concat(this.right.slice(this.right.length-a+this.left.length).reverse())}splice(i,r,a){const u=r||0;this.setCursor(Math.trunc(i));const d=this.right.splice(this.right.length-u,Number.POSITIVE_INFINITY);return a&&Sa(this.left,a),d.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(i){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(i)}pushMany(i){this.setCursor(Number.POSITIVE_INFINITY),Sa(this.left,i)}unshift(i){this.setCursor(0),this.right.push(i)}unshiftMany(i){this.setCursor(0),Sa(this.right,i.reverse())}setCursor(i){if(!(i===this.left.length||i>this.left.length&&this.right.length===0||i<0&&this.left.length===0))if(i<this.left.length){const r=this.left.splice(i,Number.POSITIVE_INFINITY);Sa(this.right,r.reverse())}else{const r=this.right.splice(this.left.length+this.right.length-i,Number.POSITIVE_INFINITY);Sa(this.left,r.reverse())}}}function Sa(t,i){let r=0;if(i.length<1e4)t.push(...i);else for(;r<i.length;)t.push(...i.slice(r,r+1e4)),r+=1e4}function Cv(t){const i={};let r=-1,a,u,d,c,h,p,m;const y=new xk(t);for(;++r<y.length;){for(;r in i;)r=i[r];if(a=y.get(r),r&&a[1].type==="chunkFlow"&&y.get(r-1)[1].type==="listItemPrefix"&&(p=a[1]._tokenizer.events,d=0,d<p.length&&p[d][1].type==="lineEndingBlank"&&(d+=2),d<p.length&&p[d][1].type==="content"))for(;++d<p.length&&p[d][1].type!=="content";)p[d][1].type==="chunkText"&&(p[d][1]._isInFirstContentOfListItem=!0,d++);if(a[0]==="enter")a[1].contentType&&(Object.assign(i,wk(y,r)),r=i[r],m=!0);else if(a[1]._container){for(d=r,u=void 0;d--;)if(c=y.get(d),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(u&&(y.get(u)[1].type="lineEndingBlank"),c[1].type="lineEnding",u=d);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;u&&(a[1].end={...y.get(u)[1].start},h=y.slice(u,r),h.unshift(a),y.splice(u,r-u+1,h))}}return Rn(t,0,Number.POSITIVE_INFINITY,y.slice(0)),!m}function wk(t,i){const r=t.get(i)[1],a=t.get(i)[2];let u=i-1;const d=[];let c=r._tokenizer;c||(c=a.parser[r.contentType](r.start),r._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const h=c.events,p=[],m={};let y,b,v=-1,x=r,j=0,R=0;const C=[R];for(;x;){for(;t.get(++u)[1]!==x;);d.push(u),x._tokenizer||(y=a.sliceStream(x),x.next||y.push(null),b&&c.defineSkip(x.start),x._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(y),x._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),b=x,x=x.next}for(x=r;++v<h.length;)h[v][0]==="exit"&&h[v-1][0]==="enter"&&h[v][1].type===h[v-1][1].type&&h[v][1].start.line!==h[v][1].end.line&&(R=v+1,C.push(R),x._tokenizer=void 0,x.previous=void 0,x=x.next);for(c.events=[],x?(x._tokenizer=void 0,x.previous=void 0):C.pop(),v=C.length;v--;){const A=h.slice(C[v],C[v+1]),_=d.pop();p.push([_,_+A.length-1]),t.splice(_,2,A)}for(p.reverse(),v=-1;++v<p.length;)m[j+p[v][0]]=j+p[v][1],j+=p[v][1]-p[v][0]-1;return m}const Sk={resolve:kk,tokenize:Ck},jk={partial:!0,tokenize:Ek};function kk(t){return Cv(t),t}function Ck(t,i){let r;return a;function a(h){return t.enter("content"),r=t.enter("chunkContent",{contentType:"content"}),u(h)}function u(h){return h===null?d(h):Oe(h)?t.check(jk,c,d)(h):(t.consume(h),u)}function d(h){return t.exit("chunkContent"),t.exit("content"),i(h)}function c(h){return t.consume(h),t.exit("chunkContent"),r.next=t.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,u}}function Ek(t,i,r){const a=this;return u;function u(c){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(c),t.exit("lineEnding"),dt(t,d,"linePrefix")}function d(c){if(c===null||Oe(c))return r(c);const h=a.events[a.events.length-1];return!a.parser.constructs.disable.null.includes("codeIndented")&&h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?i(c):t.interrupt(a.parser.constructs.flow,r,i)(c)}}function Ev(t,i,r,a,u,d,c,h,p){const m=p||Number.POSITIVE_INFINITY;let y=0;return b;function b(A){return A===60?(t.enter(a),t.enter(u),t.enter(d),t.consume(A),t.exit(d),v):A===null||A===32||A===41||vo(A)?r(A):(t.enter(a),t.enter(c),t.enter(h),t.enter("chunkString",{contentType:"string"}),R(A))}function v(A){return A===62?(t.enter(d),t.consume(A),t.exit(d),t.exit(u),t.exit(a),i):(t.enter(h),t.enter("chunkString",{contentType:"string"}),x(A))}function x(A){return A===62?(t.exit("chunkString"),t.exit(h),v(A)):A===null||A===60||Oe(A)?r(A):(t.consume(A),A===92?j:x)}function j(A){return A===60||A===62||A===92?(t.consume(A),x):x(A)}function R(A){return!y&&(A===null||A===41||_t(A))?(t.exit("chunkString"),t.exit(h),t.exit(c),t.exit(a),i(A)):y<m&&A===40?(t.consume(A),y++,R):A===41?(t.consume(A),y--,R):A===null||A===32||A===40||vo(A)?r(A):(t.consume(A),A===92?C:R)}function C(A){return A===40||A===41||A===92?(t.consume(A),R):R(A)}}function Nv(t,i,r,a,u,d){const c=this;let h=0,p;return m;function m(x){return t.enter(a),t.enter(u),t.consume(x),t.exit(u),t.enter(d),y}function y(x){return h>999||x===null||x===91||x===93&&!p||x===94&&!h&&"_hiddenFootnoteSupport"in c.parser.constructs?r(x):x===93?(t.exit(d),t.enter(u),t.consume(x),t.exit(u),t.exit(a),i):Oe(x)?(t.enter("lineEnding"),t.consume(x),t.exit("lineEnding"),y):(t.enter("chunkString",{contentType:"string"}),b(x))}function b(x){return x===null||x===91||x===93||Oe(x)||h++>999?(t.exit("chunkString"),y(x)):(t.consume(x),p||(p=!rt(x)),x===92?v:b)}function v(x){return x===91||x===92||x===93?(t.consume(x),h++,b):b(x)}}function Tv(t,i,r,a,u,d){let c;return h;function h(v){return v===34||v===39||v===40?(t.enter(a),t.enter(u),t.consume(v),t.exit(u),c=v===40?41:v,p):r(v)}function p(v){return v===c?(t.enter(u),t.consume(v),t.exit(u),t.exit(a),i):(t.enter(d),m(v))}function m(v){return v===c?(t.exit(d),p(c)):v===null?r(v):Oe(v)?(t.enter("lineEnding"),t.consume(v),t.exit("lineEnding"),dt(t,m,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),y(v))}function y(v){return v===c||v===null||Oe(v)?(t.exit("chunkString"),m(v)):(t.consume(v),v===92?b:y)}function b(v){return v===c||v===92?(t.consume(v),y):y(v)}}function Ea(t,i){let r;return a;function a(u){return Oe(u)?(t.enter("lineEnding"),t.consume(u),t.exit("lineEnding"),r=!0,a):rt(u)?dt(t,a,r?"linePrefix":"lineSuffix")(u):i(u)}}const Nk={name:"definition",tokenize:Ak},Tk={partial:!0,tokenize:Rk};function Ak(t,i,r){const a=this;let u;return d;function d(x){return t.enter("definition"),c(x)}function c(x){return Nv.call(a,t,h,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(x)}function h(x){return u=Fn(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)),x===58?(t.enter("definitionMarker"),t.consume(x),t.exit("definitionMarker"),p):r(x)}function p(x){return _t(x)?Ea(t,m)(x):m(x)}function m(x){return Ev(t,y,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(x)}function y(x){return t.attempt(Tk,b,b)(x)}function b(x){return rt(x)?dt(t,v,"whitespace")(x):v(x)}function v(x){return x===null||Oe(x)?(t.exit("definition"),a.parser.defined.push(u),i(x)):r(x)}}function Rk(t,i,r){return a;function a(h){return _t(h)?Ea(t,u)(h):r(h)}function u(h){return Tv(t,d,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(h)}function d(h){return rt(h)?dt(t,c,"whitespace")(h):c(h)}function c(h){return h===null||Oe(h)?i(h):r(h)}}const zk={name:"hardBreakEscape",tokenize:_k};function _k(t,i,r){return a;function a(d){return t.enter("hardBreakEscape"),t.consume(d),u}function u(d){return Oe(d)?(t.exit("hardBreakEscape"),i(d)):r(d)}}const Dk={name:"headingAtx",resolve:Mk,tokenize:Ok};function Mk(t,i){let r=t.length-2,a=3,u,d;return t[a][1].type==="whitespace"&&(a+=2),r-2>a&&t[r][1].type==="whitespace"&&(r-=2),t[r][1].type==="atxHeadingSequence"&&(a===r-1||r-4>a&&t[r-2][1].type==="whitespace")&&(r-=a+1===r?2:4),r>a&&(u={type:"atxHeadingText",start:t[a][1].start,end:t[r][1].end},d={type:"chunkText",start:t[a][1].start,end:t[r][1].end,contentType:"text"},Rn(t,a,r-a+1,[["enter",u,i],["enter",d,i],["exit",d,i],["exit",u,i]])),t}function Ok(t,i,r){let a=0;return u;function u(y){return t.enter("atxHeading"),d(y)}function d(y){return t.enter("atxHeadingSequence"),c(y)}function c(y){return y===35&&a++<6?(t.consume(y),c):y===null||_t(y)?(t.exit("atxHeadingSequence"),h(y)):r(y)}function h(y){return y===35?(t.enter("atxHeadingSequence"),p(y)):y===null||Oe(y)?(t.exit("atxHeading"),i(y)):rt(y)?dt(t,h,"whitespace")(y):(t.enter("atxHeadingText"),m(y))}function p(y){return y===35?(t.consume(y),p):(t.exit("atxHeadingSequence"),h(y))}function m(y){return y===null||y===35||_t(y)?(t.exit("atxHeadingText"),h(y)):(t.consume(y),m)}}const Lk=["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"],tb=["pre","script","style","textarea"],Bk={concrete:!0,name:"htmlFlow",resolveTo:qk,tokenize:Hk},Uk={partial:!0,tokenize:Vk},Ik={partial:!0,tokenize:Gk};function qk(t){let i=t.length;for(;i--&&!(t[i][0]==="enter"&&t[i][1].type==="htmlFlow"););return i>1&&t[i-2][1].type==="linePrefix"&&(t[i][1].start=t[i-2][1].start,t[i+1][1].start=t[i-2][1].start,t.splice(i-2,2)),t}function Hk(t,i,r){const a=this;let u,d,c,h,p;return m;function m(E){return y(E)}function y(E){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(E),b}function b(E){return E===33?(t.consume(E),v):E===47?(t.consume(E),d=!0,R):E===63?(t.consume(E),u=3,a.interrupt?i:k):fn(E)?(t.consume(E),c=String.fromCharCode(E),C):r(E)}function v(E){return E===45?(t.consume(E),u=2,x):E===91?(t.consume(E),u=5,h=0,j):fn(E)?(t.consume(E),u=4,a.interrupt?i:k):r(E)}function x(E){return E===45?(t.consume(E),a.interrupt?i:k):r(E)}function j(E){const J="CDATA[";return E===J.charCodeAt(h++)?(t.consume(E),h===J.length?a.interrupt?i:L:j):r(E)}function R(E){return fn(E)?(t.consume(E),c=String.fromCharCode(E),C):r(E)}function C(E){if(E===null||E===47||E===62||_t(E)){const J=E===47,be=c.toLowerCase();return!J&&!d&&tb.includes(be)?(u=1,a.interrupt?i(E):L(E)):Lk.includes(c.toLowerCase())?(u=6,J?(t.consume(E),A):a.interrupt?i(E):L(E)):(u=7,a.interrupt&&!a.parser.lazy[a.now().line]?r(E):d?_(E):D(E))}return E===45||un(E)?(t.consume(E),c+=String.fromCharCode(E),C):r(E)}function A(E){return E===62?(t.consume(E),a.interrupt?i:L):r(E)}function _(E){return rt(E)?(t.consume(E),_):T(E)}function D(E){return E===47?(t.consume(E),T):E===58||E===95||fn(E)?(t.consume(E),q):rt(E)?(t.consume(E),D):T(E)}function q(E){return E===45||E===46||E===58||E===95||un(E)?(t.consume(E),q):ae(E)}function ae(E){return E===61?(t.consume(E),N):rt(E)?(t.consume(E),ae):D(E)}function N(E){return E===null||E===60||E===61||E===62||E===96?r(E):E===34||E===39?(t.consume(E),p=E,U):rt(E)?(t.consume(E),N):X(E)}function U(E){return E===p?(t.consume(E),p=null,H):E===null||Oe(E)?r(E):(t.consume(E),U)}function X(E){return E===null||E===34||E===39||E===47||E===60||E===61||E===62||E===96||_t(E)?ae(E):(t.consume(E),X)}function H(E){return E===47||E===62||rt(E)?D(E):r(E)}function T(E){return E===62?(t.consume(E),I):r(E)}function I(E){return E===null||Oe(E)?L(E):rt(E)?(t.consume(E),I):r(E)}function L(E){return E===45&&u===2?(t.consume(E),V):E===60&&u===1?(t.consume(E),B):E===62&&u===4?(t.consume(E),O):E===63&&u===3?(t.consume(E),k):E===93&&u===5?(t.consume(E),fe):Oe(E)&&(u===6||u===7)?(t.exit("htmlFlowData"),t.check(Uk,re,F)(E)):E===null||Oe(E)?(t.exit("htmlFlowData"),F(E)):(t.consume(E),L)}function F(E){return t.check(Ik,W,re)(E)}function W(E){return t.enter("lineEnding"),t.consume(E),t.exit("lineEnding"),ee}function ee(E){return E===null||Oe(E)?F(E):(t.enter("htmlFlowData"),L(E))}function V(E){return E===45?(t.consume(E),k):L(E)}function B(E){return E===47?(t.consume(E),c="",Q):L(E)}function Q(E){if(E===62){const J=c.toLowerCase();return tb.includes(J)?(t.consume(E),O):L(E)}return fn(E)&&c.length<8?(t.consume(E),c+=String.fromCharCode(E),Q):L(E)}function fe(E){return E===93?(t.consume(E),k):L(E)}function k(E){return E===62?(t.consume(E),O):E===45&&u===2?(t.consume(E),k):L(E)}function O(E){return E===null||Oe(E)?(t.exit("htmlFlowData"),re(E)):(t.consume(E),O)}function re(E){return t.exit("htmlFlow"),i(E)}}function Gk(t,i,r){const a=this;return u;function u(c){return Oe(c)?(t.enter("lineEnding"),t.consume(c),t.exit("lineEnding"),d):r(c)}function d(c){return a.parser.lazy[a.now().line]?r(c):i(c)}}function Vk(t,i,r){return a;function a(u){return t.enter("lineEnding"),t.consume(u),t.exit("lineEnding"),t.attempt(Oa,i,r)}}const $k={name:"htmlText",tokenize:Pk};function Pk(t,i,r){const a=this;let u,d,c;return h;function h(k){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(k),p}function p(k){return k===33?(t.consume(k),m):k===47?(t.consume(k),ae):k===63?(t.consume(k),D):fn(k)?(t.consume(k),X):r(k)}function m(k){return k===45?(t.consume(k),y):k===91?(t.consume(k),d=0,j):fn(k)?(t.consume(k),_):r(k)}function y(k){return k===45?(t.consume(k),x):r(k)}function b(k){return k===null?r(k):k===45?(t.consume(k),v):Oe(k)?(c=b,B(k)):(t.consume(k),b)}function v(k){return k===45?(t.consume(k),x):b(k)}function x(k){return k===62?V(k):k===45?v(k):b(k)}function j(k){const O="CDATA[";return k===O.charCodeAt(d++)?(t.consume(k),d===O.length?R:j):r(k)}function R(k){return k===null?r(k):k===93?(t.consume(k),C):Oe(k)?(c=R,B(k)):(t.consume(k),R)}function C(k){return k===93?(t.consume(k),A):R(k)}function A(k){return k===62?V(k):k===93?(t.consume(k),A):R(k)}function _(k){return k===null||k===62?V(k):Oe(k)?(c=_,B(k)):(t.consume(k),_)}function D(k){return k===null?r(k):k===63?(t.consume(k),q):Oe(k)?(c=D,B(k)):(t.consume(k),D)}function q(k){return k===62?V(k):D(k)}function ae(k){return fn(k)?(t.consume(k),N):r(k)}function N(k){return k===45||un(k)?(t.consume(k),N):U(k)}function U(k){return Oe(k)?(c=U,B(k)):rt(k)?(t.consume(k),U):V(k)}function X(k){return k===45||un(k)?(t.consume(k),X):k===47||k===62||_t(k)?H(k):r(k)}function H(k){return k===47?(t.consume(k),V):k===58||k===95||fn(k)?(t.consume(k),T):Oe(k)?(c=H,B(k)):rt(k)?(t.consume(k),H):V(k)}function T(k){return k===45||k===46||k===58||k===95||un(k)?(t.consume(k),T):I(k)}function I(k){return k===61?(t.consume(k),L):Oe(k)?(c=I,B(k)):rt(k)?(t.consume(k),I):H(k)}function L(k){return k===null||k===60||k===61||k===62||k===96?r(k):k===34||k===39?(t.consume(k),u=k,F):Oe(k)?(c=L,B(k)):rt(k)?(t.consume(k),L):(t.consume(k),W)}function F(k){return k===u?(t.consume(k),u=void 0,ee):k===null?r(k):Oe(k)?(c=F,B(k)):(t.consume(k),F)}function W(k){return k===null||k===34||k===39||k===60||k===61||k===96?r(k):k===47||k===62||_t(k)?H(k):(t.consume(k),W)}function ee(k){return k===47||k===62||_t(k)?H(k):r(k)}function V(k){return k===62?(t.consume(k),t.exit("htmlTextData"),t.exit("htmlText"),i):r(k)}function B(k){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(k),t.exit("lineEnding"),Q}function Q(k){return rt(k)?dt(t,fe,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(k):fe(k)}function fe(k){return t.enter("htmlTextData"),c(k)}}const Mf={name:"labelEnd",resolveAll:Xk,resolveTo:Kk,tokenize:Zk},Yk={tokenize:Jk},Fk={tokenize:Wk},Qk={tokenize:eC};function Xk(t){let i=-1;const r=[];for(;++i<t.length;){const a=t[i][1];if(r.push(t[i]),a.type==="labelImage"||a.type==="labelLink"||a.type==="labelEnd"){const u=a.type==="labelImage"?4:2;a.type="data",i+=u}}return t.length!==r.length&&Rn(t,0,t.length,r),t}function Kk(t,i){let r=t.length,a=0,u,d,c,h;for(;r--;)if(u=t[r][1],d){if(u.type==="link"||u.type==="labelLink"&&u._inactive)break;t[r][0]==="enter"&&u.type==="labelLink"&&(u._inactive=!0)}else if(c){if(t[r][0]==="enter"&&(u.type==="labelImage"||u.type==="labelLink")&&!u._balanced&&(d=r,u.type!=="labelLink")){a=2;break}}else u.type==="labelEnd"&&(c=r);const p={type:t[d][1].type==="labelLink"?"link":"image",start:{...t[d][1].start},end:{...t[t.length-1][1].end}},m={type:"label",start:{...t[d][1].start},end:{...t[c][1].end}},y={type:"labelText",start:{...t[d+a+2][1].end},end:{...t[c-2][1].start}};return h=[["enter",p,i],["enter",m,i]],h=Hn(h,t.slice(d+1,d+a+3)),h=Hn(h,[["enter",y,i]]),h=Hn(h,To(i.parser.constructs.insideSpan.null,t.slice(d+a+4,c-3),i)),h=Hn(h,[["exit",y,i],t[c-2],t[c-1],["exit",m,i]]),h=Hn(h,t.slice(c+1)),h=Hn(h,[["exit",p,i]]),Rn(t,d,t.length,h),t}function Zk(t,i,r){const a=this;let u=a.events.length,d,c;for(;u--;)if((a.events[u][1].type==="labelImage"||a.events[u][1].type==="labelLink")&&!a.events[u][1]._balanced){d=a.events[u][1];break}return h;function h(v){return d?d._inactive?b(v):(c=a.parser.defined.includes(Fn(a.sliceSerialize({start:d.end,end:a.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(v),t.exit("labelMarker"),t.exit("labelEnd"),p):r(v)}function p(v){return v===40?t.attempt(Yk,y,c?y:b)(v):v===91?t.attempt(Fk,y,c?m:b)(v):c?y(v):b(v)}function m(v){return t.attempt(Qk,y,b)(v)}function y(v){return i(v)}function b(v){return d._balanced=!0,r(v)}}function Jk(t,i,r){return a;function a(b){return t.enter("resource"),t.enter("resourceMarker"),t.consume(b),t.exit("resourceMarker"),u}function u(b){return _t(b)?Ea(t,d)(b):d(b)}function d(b){return b===41?y(b):Ev(t,c,h,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(b)}function c(b){return _t(b)?Ea(t,p)(b):y(b)}function h(b){return r(b)}function p(b){return b===34||b===39||b===40?Tv(t,m,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(b):y(b)}function m(b){return _t(b)?Ea(t,y)(b):y(b)}function y(b){return b===41?(t.enter("resourceMarker"),t.consume(b),t.exit("resourceMarker"),t.exit("resource"),i):r(b)}}function Wk(t,i,r){const a=this;return u;function u(h){return Nv.call(a,t,d,c,"reference","referenceMarker","referenceString")(h)}function d(h){return a.parser.defined.includes(Fn(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)))?i(h):r(h)}function c(h){return r(h)}}function eC(t,i,r){return a;function a(d){return t.enter("reference"),t.enter("referenceMarker"),t.consume(d),t.exit("referenceMarker"),u}function u(d){return d===93?(t.enter("referenceMarker"),t.consume(d),t.exit("referenceMarker"),t.exit("reference"),i):r(d)}}const tC={name:"labelStartImage",resolveAll:Mf.resolveAll,tokenize:nC};function nC(t,i,r){const a=this;return u;function u(h){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(h),t.exit("labelImageMarker"),d}function d(h){return h===91?(t.enter("labelMarker"),t.consume(h),t.exit("labelMarker"),t.exit("labelImage"),c):r(h)}function c(h){return h===94&&"_hiddenFootnoteSupport"in a.parser.constructs?r(h):i(h)}}const iC={name:"labelStartLink",resolveAll:Mf.resolveAll,tokenize:rC};function rC(t,i,r){const a=this;return u;function u(c){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(c),t.exit("labelMarker"),t.exit("labelLink"),d}function d(c){return c===94&&"_hiddenFootnoteSupport"in a.parser.constructs?r(c):i(c)}}const zd={name:"lineEnding",tokenize:lC};function lC(t,i){return r;function r(a){return t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),dt(t,i,"linePrefix")}}const fo={name:"thematicBreak",tokenize:aC};function aC(t,i,r){let a=0,u;return d;function d(m){return t.enter("thematicBreak"),c(m)}function c(m){return u=m,h(m)}function h(m){return m===u?(t.enter("thematicBreakSequence"),p(m)):a>=3&&(m===null||Oe(m))?(t.exit("thematicBreak"),i(m)):r(m)}function p(m){return m===u?(t.consume(m),a++,p):(t.exit("thematicBreakSequence"),rt(m)?dt(t,h,"whitespace")(m):h(m))}}const xn={continuation:{tokenize:cC},exit:fC,name:"list",tokenize:uC},sC={partial:!0,tokenize:hC},oC={partial:!0,tokenize:dC};function uC(t,i,r){const a=this,u=a.events[a.events.length-1];let d=u&&u[1].type==="linePrefix"?u[2].sliceSerialize(u[1],!0).length:0,c=0;return h;function h(x){const j=a.containerState.type||(x===42||x===43||x===45?"listUnordered":"listOrdered");if(j==="listUnordered"?!a.containerState.marker||x===a.containerState.marker:tf(x)){if(a.containerState.type||(a.containerState.type=j,t.enter(j,{_container:!0})),j==="listUnordered")return t.enter("listItemPrefix"),x===42||x===45?t.check(fo,r,m)(x):m(x);if(!a.interrupt||x===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),p(x)}return r(x)}function p(x){return tf(x)&&++c<10?(t.consume(x),p):(!a.interrupt||c<2)&&(a.containerState.marker?x===a.containerState.marker:x===41||x===46)?(t.exit("listItemValue"),m(x)):r(x)}function m(x){return t.enter("listItemMarker"),t.consume(x),t.exit("listItemMarker"),a.containerState.marker=a.containerState.marker||x,t.check(Oa,a.interrupt?r:y,t.attempt(sC,v,b))}function y(x){return a.containerState.initialBlankLine=!0,d++,v(x)}function b(x){return rt(x)?(t.enter("listItemPrefixWhitespace"),t.consume(x),t.exit("listItemPrefixWhitespace"),v):r(x)}function v(x){return a.containerState.size=d+a.sliceSerialize(t.exit("listItemPrefix"),!0).length,i(x)}}function cC(t,i,r){const a=this;return a.containerState._closeFlow=void 0,t.check(Oa,u,d);function u(h){return a.containerState.furtherBlankLines=a.containerState.furtherBlankLines||a.containerState.initialBlankLine,dt(t,i,"listItemIndent",a.containerState.size+1)(h)}function d(h){return a.containerState.furtherBlankLines||!rt(h)?(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,c(h)):(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,t.attempt(oC,i,c)(h))}function c(h){return a.containerState._closeFlow=!0,a.interrupt=void 0,dt(t,t.attempt(xn,i,r),"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h)}}function dC(t,i,r){const a=this;return dt(t,u,"listItemIndent",a.containerState.size+1);function u(d){const c=a.events[a.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===a.containerState.size?i(d):r(d)}}function fC(t){t.exit(this.containerState.type)}function hC(t,i,r){const a=this;return dt(t,u,"listItemPrefixWhitespace",a.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function u(d){const c=a.events[a.events.length-1];return!rt(d)&&c&&c[1].type==="listItemPrefixWhitespace"?i(d):r(d)}}const nb={name:"setextUnderline",resolveTo:pC,tokenize:mC};function pC(t,i){let r=t.length,a,u,d;for(;r--;)if(t[r][0]==="enter"){if(t[r][1].type==="content"){a=r;break}t[r][1].type==="paragraph"&&(u=r)}else t[r][1].type==="content"&&t.splice(r,1),!d&&t[r][1].type==="definition"&&(d=r);const c={type:"setextHeading",start:{...t[a][1].start},end:{...t[t.length-1][1].end}};return t[u][1].type="setextHeadingText",d?(t.splice(u,0,["enter",c,i]),t.splice(d+1,0,["exit",t[a][1],i]),t[a][1].end={...t[d][1].end}):t[a][1]=c,t.push(["exit",c,i]),t}function mC(t,i,r){const a=this;let u;return d;function d(m){let y=a.events.length,b;for(;y--;)if(a.events[y][1].type!=="lineEnding"&&a.events[y][1].type!=="linePrefix"&&a.events[y][1].type!=="content"){b=a.events[y][1].type==="paragraph";break}return!a.parser.lazy[a.now().line]&&(a.interrupt||b)?(t.enter("setextHeadingLine"),u=m,c(m)):r(m)}function c(m){return t.enter("setextHeadingLineSequence"),h(m)}function h(m){return m===u?(t.consume(m),h):(t.exit("setextHeadingLineSequence"),rt(m)?dt(t,p,"lineSuffix")(m):p(m))}function p(m){return m===null||Oe(m)?(t.exit("setextHeadingLine"),i(m)):r(m)}}const gC={tokenize:yC};function yC(t){const i=this,r=t.attempt(Oa,a,t.attempt(this.parser.constructs.flowInitial,u,dt(t,t.attempt(this.parser.constructs.flow,u,t.attempt(Sk,u)),"linePrefix")));return r;function a(d){if(d===null){t.consume(d);return}return t.enter("lineEndingBlank"),t.consume(d),t.exit("lineEndingBlank"),i.currentConstruct=void 0,r}function u(d){if(d===null){t.consume(d);return}return t.enter("lineEnding"),t.consume(d),t.exit("lineEnding"),i.currentConstruct=void 0,r}}const bC={resolveAll:Rv()},vC=Av("string"),xC=Av("text");function Av(t){return{resolveAll:Rv(t==="text"?wC:void 0),tokenize:i};function i(r){const a=this,u=this.parser.constructs[t],d=r.attempt(u,c,h);return c;function c(y){return m(y)?d(y):h(y)}function h(y){if(y===null){r.consume(y);return}return r.enter("data"),r.consume(y),p}function p(y){return m(y)?(r.exit("data"),d(y)):(r.consume(y),p)}function m(y){if(y===null)return!0;const b=u[y];let v=-1;if(b)for(;++v<b.length;){const x=b[v];if(!x.previous||x.previous.call(a,a.previous))return!0}return!1}}}function Rv(t){return i;function i(r,a){let u=-1,d;for(;++u<=r.length;)d===void 0?r[u]&&r[u][1].type==="data"&&(d=u,u++):(!r[u]||r[u][1].type!=="data")&&(u!==d+2&&(r[d][1].end=r[u-1][1].end,r.splice(d+2,u-d-2),u=d+2),d=void 0);return t?t(r,a):r}}function wC(t,i){let r=0;for(;++r<=t.length;)if((r===t.length||t[r][1].type==="lineEnding")&&t[r-1][1].type==="data"){const a=t[r-1][1],u=i.sliceStream(a);let d=u.length,c=-1,h=0,p;for(;d--;){const m=u[d];if(typeof m=="string"){for(c=m.length;m.charCodeAt(c-1)===32;)h++,c--;if(c)break;c=-1}else if(m===-2)p=!0,h++;else if(m!==-1){d++;break}}if(i._contentTypeTextTrailing&&r===t.length&&(h=0),h){const m={type:r===t.length||p||h<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:d?c:a.start._bufferIndex+c,_index:a.start._index+d,line:a.end.line,column:a.end.column-h,offset:a.end.offset-h},end:{...a.end}};a.end={...m.start},a.start.offset===a.end.offset?Object.assign(a,m):(t.splice(r,0,["enter",m,i],["exit",m,i]),r+=2)}r++}return t}const SC={42:xn,43:xn,45:xn,48:xn,49:xn,50:xn,51:xn,52:xn,53:xn,54:xn,55:xn,56:xn,57:xn,62:Sv},jC={91:Nk},kC={[-2]:Rd,[-1]:Rd,32:Rd},CC={35:Dk,42:fo,45:[nb,fo],60:Bk,61:nb,95:fo,96:eb,126:eb},EC={38:kv,92:jv},NC={[-5]:zd,[-4]:zd,[-3]:zd,33:tC,38:kv,42:nf,60:[ik,$k],91:iC,92:[zk,jv],93:Mf,95:nf,96:gk},TC={null:[nf,bC]},AC={null:[42,95]},RC={null:[]},zC=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:AC,contentInitial:jC,disable:RC,document:SC,flow:CC,flowInitial:kC,insideSpan:TC,string:EC,text:NC},Symbol.toStringTag,{value:"Module"}));function _C(t,i,r){let a={_bufferIndex:-1,_index:0,line:r&&r.line||1,column:r&&r.column||1,offset:r&&r.offset||0};const u={},d=[];let c=[],h=[];const p={attempt:U(ae),check:U(N),consume:_,enter:D,exit:q,interrupt:U(N,{interrupt:!0})},m={code:null,containerState:{},defineSkip:R,events:[],now:j,parser:t,previous:null,sliceSerialize:v,sliceStream:x,write:b};let y=i.tokenize.call(m,p);return i.resolveAll&&d.push(i),m;function b(I){return c=Hn(c,I),C(),c[c.length-1]!==null?[]:(X(i,0),m.events=To(d,m.events,m),m.events)}function v(I,L){return MC(x(I),L)}function x(I){return DC(c,I)}function j(){const{_bufferIndex:I,_index:L,line:F,column:W,offset:ee}=a;return{_bufferIndex:I,_index:L,line:F,column:W,offset:ee}}function R(I){u[I.line]=I.column,T()}function C(){let I;for(;a._index<c.length;){const L=c[a._index];if(typeof L=="string")for(I=a._index,a._bufferIndex<0&&(a._bufferIndex=0);a._index===I&&a._bufferIndex<L.length;)A(L.charCodeAt(a._bufferIndex));else A(L)}}function A(I){y=y(I)}function _(I){Oe(I)?(a.line++,a.column=1,a.offset+=I===-3?2:1,T()):I!==-1&&(a.column++,a.offset++),a._bufferIndex<0?a._index++:(a._bufferIndex++,a._bufferIndex===c[a._index].length&&(a._bufferIndex=-1,a._index++)),m.previous=I}function D(I,L){const F=L||{};return F.type=I,F.start=j(),m.events.push(["enter",F,m]),h.push(F),F}function q(I){const L=h.pop();return L.end=j(),m.events.push(["exit",L,m]),L}function ae(I,L){X(I,L.from)}function N(I,L){L.restore()}function U(I,L){return F;function F(W,ee,V){let B,Q,fe,k;return Array.isArray(W)?re(W):"tokenize"in W?re([W]):O(W);function O(Z){return ne;function ne(ge){const P=ge!==null&&Z[ge],ve=ge!==null&&Z.null,De=[...Array.isArray(P)?P:P?[P]:[],...Array.isArray(ve)?ve:ve?[ve]:[]];return re(De)(ge)}}function re(Z){return B=Z,Q=0,Z.length===0?V:E(Z[Q])}function E(Z){return ne;function ne(ge){return k=H(),fe=Z,Z.partial||(m.currentConstruct=Z),Z.name&&m.parser.constructs.disable.null.includes(Z.name)?be():Z.tokenize.call(L?Object.assign(Object.create(m),L):m,p,J,be)(ge)}}function J(Z){return I(fe,k),ee}function be(Z){return k.restore(),++Q<B.length?E(B[Q]):V}}}function X(I,L){I.resolveAll&&!d.includes(I)&&d.push(I),I.resolve&&Rn(m.events,L,m.events.length-L,I.resolve(m.events.slice(L),m)),I.resolveTo&&(m.events=I.resolveTo(m.events,m))}function H(){const I=j(),L=m.previous,F=m.currentConstruct,W=m.events.length,ee=Array.from(h);return{from:W,restore:V};function V(){a=I,m.previous=L,m.currentConstruct=F,m.events.length=W,h=ee,T()}}function T(){a.line in u&&a.column<2&&(a.column=u[a.line],a.offset+=u[a.line]-1)}}function DC(t,i){const r=i.start._index,a=i.start._bufferIndex,u=i.end._index,d=i.end._bufferIndex;let c;if(r===u)c=[t[r].slice(a,d)];else{if(c=t.slice(r,u),a>-1){const h=c[0];typeof h=="string"?c[0]=h.slice(a):c.shift()}d>0&&c.push(t[u].slice(0,d))}return c}function MC(t,i){let r=-1;const a=[];let u;for(;++r<t.length;){const d=t[r];let c;if(typeof d=="string")c=d;else switch(d){case-5:{c="\r";break}case-4:{c=`
30
- `;break}case-3:{c=`\r
31
- `;break}case-2:{c=i?" ":" ";break}case-1:{if(!i&&u)continue;c=" ";break}default:c=String.fromCharCode(d)}u=d===-2,a.push(c)}return a.join("")}function OC(t){const a={constructs:xv([zC,...(t||{}).extensions||[]]),content:u(Kj),defined:[],document:u(Jj),flow:u(gC),lazy:{},string:u(vC),text:u(xC)};return a;function u(d){return c;function c(h){return _C(a,d,h)}}}function LC(t){for(;!Cv(t););return t}const ib=/[\0\t\n\r]/g;function BC(){let t=1,i="",r=!0,a;return u;function u(d,c,h){const p=[];let m,y,b,v,x;for(d=i+(typeof d=="string"?d.toString():new TextDecoder(c||void 0).decode(d)),b=0,i="",r&&(d.charCodeAt(0)===65279&&b++,r=void 0);b<d.length;){if(ib.lastIndex=b,m=ib.exec(d),v=m&&m.index!==void 0?m.index:d.length,x=d.charCodeAt(v),!m){i=d.slice(b);break}if(x===10&&b===v&&a)p.push(-3),a=void 0;else switch(a&&(p.push(-5),a=void 0),b<v&&(p.push(d.slice(b,v)),t+=v-b),x){case 0:{p.push(65533),t++;break}case 9:{for(y=Math.ceil(t/4)*4,p.push(-2);t++<y;)p.push(-1);break}case 10:{p.push(-4),t=1;break}default:a=!0,t=1}b=v+1}return h&&(a&&p.push(-5),i&&p.push(i),p.push(null)),p}}const UC=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function IC(t){return t.replace(UC,qC)}function qC(t,i,r){if(i)return i;if(r.charCodeAt(0)===35){const u=r.charCodeAt(1),d=u===120||u===88;return wv(r.slice(d?2:1),d?16:10)}return Df(r)||t}const zv={}.hasOwnProperty;function HC(t,i,r){return i&&typeof i=="object"&&(r=i,i=void 0),GC(r)(LC(OC(r).document().write(BC()(t,i,!0))))}function GC(t){const i={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:d(Be),autolinkProtocol:H,autolinkEmail:H,atxHeading:d(ft),blockQuote:d(ve),characterEscape:H,characterReference:H,codeFenced:d(De),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:d(De,c),codeText:d(ze,c),codeTextData:H,data:H,codeFlowValue:H,definition:d(_e),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:d(Ge),hardBreakEscape:d(xt),hardBreakTrailing:d(xt),htmlFlow:d(Ke,c),htmlFlowData:H,htmlText:d(Ke,c),htmlTextData:H,image:d(Tt),label:c,link:d(Be),listItem:d(Je),listItemValue:v,listOrdered:d(At,b),listUnordered:d(At),paragraph:d(Fe),reference:E,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:d(ft),strong:d(Lt),thematicBreak:d(pt)},exit:{atxHeading:p(),atxHeadingSequence:ae,autolink:p(),autolinkEmail:P,autolinkProtocol:ge,blockQuote:p(),characterEscapeValue:T,characterReferenceMarkerHexadecimal:be,characterReferenceMarkerNumeric:be,characterReferenceValue:Z,characterReference:ne,codeFenced:p(C),codeFencedFence:R,codeFencedFenceInfo:x,codeFencedFenceMeta:j,codeFlowValue:T,codeIndented:p(A),codeText:p(ee),codeTextData:T,data:T,definition:p(),definitionDestinationString:q,definitionLabelString:_,definitionTitleString:D,emphasis:p(),hardBreakEscape:p(L),hardBreakTrailing:p(L),htmlFlow:p(F),htmlFlowData:T,htmlText:p(W),htmlTextData:T,image:p(B),label:fe,labelText:Q,lineEnding:I,link:p(V),listItem:p(),listOrdered:p(),listUnordered:p(),paragraph:p(),referenceString:J,resourceDestinationString:k,resourceTitleString:O,resource:re,setextHeading:p(X),setextHeadingLineSequence:U,setextHeadingText:N,strong:p(),thematicBreak:p()}};_v(i,(t||{}).mdastExtensions||[]);const r={};return a;function a(M){let ie={type:"root",children:[]};const ye={stack:[ie],tokenStack:[],config:i,enter:h,exit:m,buffer:c,resume:y,data:r},xe=[];let Ce=-1;for(;++Ce<M.length;)if(M[Ce][1].type==="listOrdered"||M[Ce][1].type==="listUnordered")if(M[Ce][0]==="enter")xe.push(Ce);else{const Ae=xe.pop();Ce=u(M,Ae,Ce)}for(Ce=-1;++Ce<M.length;){const Ae=i[M[Ce][0]];zv.call(Ae,M[Ce][1].type)&&Ae[M[Ce][1].type].call(Object.assign({sliceSerialize:M[Ce][2].sliceSerialize},ye),M[Ce][1])}if(ye.tokenStack.length>0){const Ae=ye.tokenStack[ye.tokenStack.length-1];(Ae[1]||rb).call(ye,void 0,Ae[0])}for(ie.position={start:Wi(M.length>0?M[0][1].start:{line:1,column:1,offset:0}),end:Wi(M.length>0?M[M.length-2][1].end:{line:1,column:1,offset:0})},Ce=-1;++Ce<i.transforms.length;)ie=i.transforms[Ce](ie)||ie;return ie}function u(M,ie,ye){let xe=ie-1,Ce=-1,Ae=!1,Pe,wt,ct,mt;for(;++xe<=ye;){const lt=M[xe];switch(lt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{lt[0]==="enter"?Ce++:Ce--,mt=void 0;break}case"lineEndingBlank":{lt[0]==="enter"&&(Pe&&!mt&&!Ce&&!ct&&(ct=xe),mt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:mt=void 0}if(!Ce&&lt[0]==="enter"&&lt[1].type==="listItemPrefix"||Ce===-1&&lt[0]==="exit"&&(lt[1].type==="listUnordered"||lt[1].type==="listOrdered")){if(Pe){let Pt=xe;for(wt=void 0;Pt--;){const bt=M[Pt];if(bt[1].type==="lineEnding"||bt[1].type==="lineEndingBlank"){if(bt[0]==="exit")continue;wt&&(M[wt][1].type="lineEndingBlank",Ae=!0),bt[1].type="lineEnding",wt=Pt}else if(!(bt[1].type==="linePrefix"||bt[1].type==="blockQuotePrefix"||bt[1].type==="blockQuotePrefixWhitespace"||bt[1].type==="blockQuoteMarker"||bt[1].type==="listItemIndent"))break}ct&&(!wt||ct<wt)&&(Pe._spread=!0),Pe.end=Object.assign({},wt?M[wt][1].start:lt[1].end),M.splice(wt||xe,0,["exit",Pe,lt[2]]),xe++,ye++}if(lt[1].type==="listItemPrefix"){const Pt={type:"listItem",_spread:!1,start:Object.assign({},lt[1].start),end:void 0};Pe=Pt,M.splice(xe,0,["enter",Pt,lt[2]]),xe++,ye++,ct=void 0,mt=!0}}}return M[ie][1]._spread=Ae,ye}function d(M,ie){return ye;function ye(xe){h.call(this,M(xe),xe),ie&&ie.call(this,xe)}}function c(){this.stack.push({type:"fragment",children:[]})}function h(M,ie,ye){this.stack[this.stack.length-1].children.push(M),this.stack.push(M),this.tokenStack.push([ie,ye||void 0]),M.position={start:Wi(ie.start),end:void 0}}function p(M){return ie;function ie(ye){M&&M.call(this,ye),m.call(this,ye)}}function m(M,ie){const ye=this.stack.pop(),xe=this.tokenStack.pop();if(xe)xe[0].type!==M.type&&(ie?ie.call(this,M,xe[0]):(xe[1]||rb).call(this,M,xe[0]));else throw new Error("Cannot close `"+M.type+"` ("+Ca({start:M.start,end:M.end})+"): it’s not open");ye.position.end=Wi(M.end)}function y(){return _f(this.stack.pop())}function b(){this.data.expectingFirstListItemValue=!0}function v(M){if(this.data.expectingFirstListItemValue){const ie=this.stack[this.stack.length-2];ie.start=Number.parseInt(this.sliceSerialize(M),10),this.data.expectingFirstListItemValue=void 0}}function x(){const M=this.resume(),ie=this.stack[this.stack.length-1];ie.lang=M}function j(){const M=this.resume(),ie=this.stack[this.stack.length-1];ie.meta=M}function R(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function C(){const M=this.resume(),ie=this.stack[this.stack.length-1];ie.value=M.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function A(){const M=this.resume(),ie=this.stack[this.stack.length-1];ie.value=M.replace(/(\r?\n|\r)$/g,"")}function _(M){const ie=this.resume(),ye=this.stack[this.stack.length-1];ye.label=ie,ye.identifier=Fn(this.sliceSerialize(M)).toLowerCase()}function D(){const M=this.resume(),ie=this.stack[this.stack.length-1];ie.title=M}function q(){const M=this.resume(),ie=this.stack[this.stack.length-1];ie.url=M}function ae(M){const ie=this.stack[this.stack.length-1];if(!ie.depth){const ye=this.sliceSerialize(M).length;ie.depth=ye}}function N(){this.data.setextHeadingSlurpLineEnding=!0}function U(M){const ie=this.stack[this.stack.length-1];ie.depth=this.sliceSerialize(M).codePointAt(0)===61?1:2}function X(){this.data.setextHeadingSlurpLineEnding=void 0}function H(M){const ye=this.stack[this.stack.length-1].children;let xe=ye[ye.length-1];(!xe||xe.type!=="text")&&(xe=Ie(),xe.position={start:Wi(M.start),end:void 0},ye.push(xe)),this.stack.push(xe)}function T(M){const ie=this.stack.pop();ie.value+=this.sliceSerialize(M),ie.position.end=Wi(M.end)}function I(M){const ie=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ye=ie.children[ie.children.length-1];ye.position.end=Wi(M.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&i.canContainEols.includes(ie.type)&&(H.call(this,M),T.call(this,M))}function L(){this.data.atHardBreak=!0}function F(){const M=this.resume(),ie=this.stack[this.stack.length-1];ie.value=M}function W(){const M=this.resume(),ie=this.stack[this.stack.length-1];ie.value=M}function ee(){const M=this.resume(),ie=this.stack[this.stack.length-1];ie.value=M}function V(){const M=this.stack[this.stack.length-1];if(this.data.inReference){const ie=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=ie,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function B(){const M=this.stack[this.stack.length-1];if(this.data.inReference){const ie=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=ie,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function Q(M){const ie=this.sliceSerialize(M),ye=this.stack[this.stack.length-2];ye.label=IC(ie),ye.identifier=Fn(ie).toLowerCase()}function fe(){const M=this.stack[this.stack.length-1],ie=this.resume(),ye=this.stack[this.stack.length-1];if(this.data.inReference=!0,ye.type==="link"){const xe=M.children;ye.children=xe}else ye.alt=ie}function k(){const M=this.resume(),ie=this.stack[this.stack.length-1];ie.url=M}function O(){const M=this.resume(),ie=this.stack[this.stack.length-1];ie.title=M}function re(){this.data.inReference=void 0}function E(){this.data.referenceType="collapsed"}function J(M){const ie=this.resume(),ye=this.stack[this.stack.length-1];ye.label=ie,ye.identifier=Fn(this.sliceSerialize(M)).toLowerCase(),this.data.referenceType="full"}function be(M){this.data.characterReferenceType=M.type}function Z(M){const ie=this.sliceSerialize(M),ye=this.data.characterReferenceType;let xe;ye?(xe=wv(ie,ye==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):xe=Df(ie);const Ce=this.stack[this.stack.length-1];Ce.value+=xe}function ne(M){const ie=this.stack.pop();ie.position.end=Wi(M.end)}function ge(M){T.call(this,M);const ie=this.stack[this.stack.length-1];ie.url=this.sliceSerialize(M)}function P(M){T.call(this,M);const ie=this.stack[this.stack.length-1];ie.url="mailto:"+this.sliceSerialize(M)}function ve(){return{type:"blockquote",children:[]}}function De(){return{type:"code",lang:null,meta:null,value:""}}function ze(){return{type:"inlineCode",value:""}}function _e(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ge(){return{type:"emphasis",children:[]}}function ft(){return{type:"heading",depth:0,children:[]}}function xt(){return{type:"break"}}function Ke(){return{type:"html",value:""}}function Tt(){return{type:"image",title:null,url:"",alt:null}}function Be(){return{type:"link",title:null,url:"",children:[]}}function At(M){return{type:"list",ordered:M.type==="listOrdered",start:null,spread:M._spread,children:[]}}function Je(M){return{type:"listItem",spread:M._spread,checked:null,children:[]}}function Fe(){return{type:"paragraph",children:[]}}function Lt(){return{type:"strong",children:[]}}function Ie(){return{type:"text",value:""}}function pt(){return{type:"thematicBreak"}}}function Wi(t){return{line:t.line,column:t.column,offset:t.offset}}function _v(t,i){let r=-1;for(;++r<i.length;){const a=i[r];Array.isArray(a)?_v(t,a):VC(t,a)}}function VC(t,i){let r;for(r in i)if(zv.call(i,r))switch(r){case"canContainEols":{const a=i[r];a&&t[r].push(...a);break}case"transforms":{const a=i[r];a&&t[r].push(...a);break}case"enter":case"exit":{const a=i[r];a&&Object.assign(t[r],a);break}}}function rb(t,i){throw t?new Error("Cannot close `"+t.type+"` ("+Ca({start:t.start,end:t.end})+"): a different token (`"+i.type+"`, "+Ca({start:i.start,end:i.end})+") is open"):new Error("Cannot close document, a token (`"+i.type+"`, "+Ca({start:i.start,end:i.end})+") is still open")}function $C(t){const i=this;i.parser=r;function r(a){return HC(a,{...i.data("settings"),...t,extensions:i.data("micromarkExtensions")||[],mdastExtensions:i.data("fromMarkdownExtensions")||[]})}}function PC(t,i){const r={type:"element",tagName:"blockquote",properties:{},children:t.wrap(t.all(i),!0)};return t.patch(i,r),t.applyData(i,r)}function YC(t,i){const r={type:"element",tagName:"br",properties:{},children:[]};return t.patch(i,r),[t.applyData(i,r),{type:"text",value:`
32
- `}]}function FC(t,i){const r=i.value?i.value+`
33
- `:"",a={},u=i.lang?i.lang.split(/\s+/):[];u.length>0&&(a.className=["language-"+u[0]]);let d={type:"element",tagName:"code",properties:a,children:[{type:"text",value:r}]};return i.meta&&(d.data={meta:i.meta}),t.patch(i,d),d=t.applyData(i,d),d={type:"element",tagName:"pre",properties:{},children:[d]},t.patch(i,d),d}function QC(t,i){const r={type:"element",tagName:"del",properties:{},children:t.all(i)};return t.patch(i,r),t.applyData(i,r)}function XC(t,i){const r={type:"element",tagName:"em",properties:{},children:t.all(i)};return t.patch(i,r),t.applyData(i,r)}function KC(t,i){const r=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",a=String(i.identifier).toUpperCase(),u=kl(a.toLowerCase()),d=t.footnoteOrder.indexOf(a);let c,h=t.footnoteCounts.get(a);h===void 0?(h=0,t.footnoteOrder.push(a),c=t.footnoteOrder.length):c=d+1,h+=1,t.footnoteCounts.set(a,h);const p={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+u,id:r+"fnref-"+u+(h>1?"-"+h:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};t.patch(i,p);const m={type:"element",tagName:"sup",properties:{},children:[p]};return t.patch(i,m),t.applyData(i,m)}function ZC(t,i){const r={type:"element",tagName:"h"+i.depth,properties:{},children:t.all(i)};return t.patch(i,r),t.applyData(i,r)}function JC(t,i){if(t.options.allowDangerousHtml){const r={type:"raw",value:i.value};return t.patch(i,r),t.applyData(i,r)}}function Dv(t,i){const r=i.referenceType;let a="]";if(r==="collapsed"?a+="[]":r==="full"&&(a+="["+(i.label||i.identifier)+"]"),i.type==="imageReference")return[{type:"text",value:"!["+i.alt+a}];const u=t.all(i),d=u[0];d&&d.type==="text"?d.value="["+d.value:u.unshift({type:"text",value:"["});const c=u[u.length-1];return c&&c.type==="text"?c.value+=a:u.push({type:"text",value:a}),u}function WC(t,i){const r=String(i.identifier).toUpperCase(),a=t.definitionById.get(r);if(!a)return Dv(t,i);const u={src:kl(a.url||""),alt:i.alt};a.title!==null&&a.title!==void 0&&(u.title=a.title);const d={type:"element",tagName:"img",properties:u,children:[]};return t.patch(i,d),t.applyData(i,d)}function eE(t,i){const r={src:kl(i.url)};i.alt!==null&&i.alt!==void 0&&(r.alt=i.alt),i.title!==null&&i.title!==void 0&&(r.title=i.title);const a={type:"element",tagName:"img",properties:r,children:[]};return t.patch(i,a),t.applyData(i,a)}function tE(t,i){const r={type:"text",value:i.value.replace(/\r?\n|\r/g," ")};t.patch(i,r);const a={type:"element",tagName:"code",properties:{},children:[r]};return t.patch(i,a),t.applyData(i,a)}function nE(t,i){const r=String(i.identifier).toUpperCase(),a=t.definitionById.get(r);if(!a)return Dv(t,i);const u={href:kl(a.url||"")};a.title!==null&&a.title!==void 0&&(u.title=a.title);const d={type:"element",tagName:"a",properties:u,children:t.all(i)};return t.patch(i,d),t.applyData(i,d)}function iE(t,i){const r={href:kl(i.url)};i.title!==null&&i.title!==void 0&&(r.title=i.title);const a={type:"element",tagName:"a",properties:r,children:t.all(i)};return t.patch(i,a),t.applyData(i,a)}function rE(t,i,r){const a=t.all(i),u=r?lE(r):Mv(i),d={},c=[];if(typeof i.checked=="boolean"){const y=a[0];let b;y&&y.type==="element"&&y.tagName==="p"?b=y:(b={type:"element",tagName:"p",properties:{},children:[]},a.unshift(b)),b.children.length>0&&b.children.unshift({type:"text",value:" "}),b.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:i.checked,disabled:!0},children:[]}),d.className=["task-list-item"]}let h=-1;for(;++h<a.length;){const y=a[h];(u||h!==0||y.type!=="element"||y.tagName!=="p")&&c.push({type:"text",value:`
34
- `}),y.type==="element"&&y.tagName==="p"&&!u?c.push(...y.children):c.push(y)}const p=a[a.length-1];p&&(u||p.type!=="element"||p.tagName!=="p")&&c.push({type:"text",value:`
35
- `});const m={type:"element",tagName:"li",properties:d,children:c};return t.patch(i,m),t.applyData(i,m)}function lE(t){let i=!1;if(t.type==="list"){i=t.spread||!1;const r=t.children;let a=-1;for(;!i&&++a<r.length;)i=Mv(r[a])}return i}function Mv(t){const i=t.spread;return i??t.children.length>1}function aE(t,i){const r={},a=t.all(i);let u=-1;for(typeof i.start=="number"&&i.start!==1&&(r.start=i.start);++u<a.length;){const c=a[u];if(c.type==="element"&&c.tagName==="li"&&c.properties&&Array.isArray(c.properties.className)&&c.properties.className.includes("task-list-item")){r.className=["contains-task-list"];break}}const d={type:"element",tagName:i.ordered?"ol":"ul",properties:r,children:t.wrap(a,!0)};return t.patch(i,d),t.applyData(i,d)}function sE(t,i){const r={type:"element",tagName:"p",properties:{},children:t.all(i)};return t.patch(i,r),t.applyData(i,r)}function oE(t,i){const r={type:"root",children:t.wrap(t.all(i))};return t.patch(i,r),t.applyData(i,r)}function uE(t,i){const r={type:"element",tagName:"strong",properties:{},children:t.all(i)};return t.patch(i,r),t.applyData(i,r)}function cE(t,i){const r=t.all(i),a=r.shift(),u=[];if(a){const c={type:"element",tagName:"thead",properties:{},children:t.wrap([a],!0)};t.patch(i.children[0],c),u.push(c)}if(r.length>0){const c={type:"element",tagName:"tbody",properties:{},children:t.wrap(r,!0)},h=Tf(i.children[1]),p=hv(i.children[i.children.length-1]);h&&p&&(c.position={start:h,end:p}),u.push(c)}const d={type:"element",tagName:"table",properties:{},children:t.wrap(u,!0)};return t.patch(i,d),t.applyData(i,d)}function dE(t,i,r){const a=r?r.children:void 0,d=(a?a.indexOf(i):1)===0?"th":"td",c=r&&r.type==="table"?r.align:void 0,h=c?c.length:i.children.length;let p=-1;const m=[];for(;++p<h;){const b=i.children[p],v={},x=c?c[p]:void 0;x&&(v.align=x);let j={type:"element",tagName:d,properties:v,children:[]};b&&(j.children=t.all(b),t.patch(b,j),j=t.applyData(b,j)),m.push(j)}const y={type:"element",tagName:"tr",properties:{},children:t.wrap(m,!0)};return t.patch(i,y),t.applyData(i,y)}function fE(t,i){const r={type:"element",tagName:"td",properties:{},children:t.all(i)};return t.patch(i,r),t.applyData(i,r)}const lb=9,ab=32;function hE(t){const i=String(t),r=/\r?\n|\r/g;let a=r.exec(i),u=0;const d=[];for(;a;)d.push(sb(i.slice(u,a.index),u>0,!0),a[0]),u=a.index+a[0].length,a=r.exec(i);return d.push(sb(i.slice(u),u>0,!1)),d.join("")}function sb(t,i,r){let a=0,u=t.length;if(i){let d=t.codePointAt(a);for(;d===lb||d===ab;)a++,d=t.codePointAt(a)}if(r){let d=t.codePointAt(u-1);for(;d===lb||d===ab;)u--,d=t.codePointAt(u-1)}return u>a?t.slice(a,u):""}function pE(t,i){const r={type:"text",value:hE(String(i.value))};return t.patch(i,r),t.applyData(i,r)}function mE(t,i){const r={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(i,r),t.applyData(i,r)}const gE={blockquote:PC,break:YC,code:FC,delete:QC,emphasis:XC,footnoteReference:KC,heading:ZC,html:JC,imageReference:WC,image:eE,inlineCode:tE,linkReference:nE,link:iE,listItem:rE,list:aE,paragraph:sE,root:oE,strong:uE,table:cE,tableCell:fE,tableRow:dE,text:pE,thematicBreak:mE,toml:ro,yaml:ro,definition:ro,footnoteDefinition:ro};function ro(){}const Ov=-1,Ao=0,Na=1,xo=2,Of=3,Lf=4,Bf=5,Uf=6,Lv=7,Bv=8,yE=typeof self=="object"?self:globalThis,ob=(t,i)=>{switch(t){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+t)}return new yE[t](i)},bE=(t,i)=>{const r=(u,d)=>(t.set(d,u),u),a=u=>{if(t.has(u))return t.get(u);const[d,c]=i[u];switch(d){case Ao:case Ov:return r(c,u);case Na:{const h=r([],u);for(const p of c)h.push(a(p));return h}case xo:{const h=r({},u);for(const[p,m]of c)h[a(p)]=a(m);return h}case Of:return r(new Date(c),u);case Lf:{const{source:h,flags:p}=c;return r(new RegExp(h,p),u)}case Bf:{const h=r(new Map,u);for(const[p,m]of c)h.set(a(p),a(m));return h}case Uf:{const h=r(new Set,u);for(const p of c)h.add(a(p));return h}case Lv:{const{name:h,message:p}=c;return r(ob(h,p),u)}case Bv:return r(BigInt(c),u);case"BigInt":return r(Object(BigInt(c)),u);case"ArrayBuffer":return r(new Uint8Array(c).buffer,c);case"DataView":{const{buffer:h}=new Uint8Array(c);return r(new DataView(h),c)}}return r(ob(d,c),u)};return a},ub=t=>bE(new Map,t)(0),ml="",{toString:vE}={},{keys:xE}=Object,ja=t=>{const i=typeof t;if(i!=="object"||!t)return[Ao,i];const r=vE.call(t).slice(8,-1);switch(r){case"Array":return[Na,ml];case"Object":return[xo,ml];case"Date":return[Of,ml];case"RegExp":return[Lf,ml];case"Map":return[Bf,ml];case"Set":return[Uf,ml];case"DataView":return[Na,r]}return r.includes("Array")?[Na,r]:r.includes("Error")?[Lv,r]:[xo,r]},lo=([t,i])=>t===Ao&&(i==="function"||i==="symbol"),wE=(t,i,r,a)=>{const u=(c,h)=>{const p=a.push(c)-1;return r.set(h,p),p},d=c=>{if(r.has(c))return r.get(c);let[h,p]=ja(c);switch(h){case Ao:{let y=c;switch(p){case"bigint":h=Bv,y=c.toString();break;case"function":case"symbol":if(t)throw new TypeError("unable to serialize "+p);y=null;break;case"undefined":return u([Ov],c)}return u([h,y],c)}case Na:{if(p){let v=c;return p==="DataView"?v=new Uint8Array(c.buffer):p==="ArrayBuffer"&&(v=new Uint8Array(c)),u([p,[...v]],c)}const y=[],b=u([h,y],c);for(const v of c)y.push(d(v));return b}case xo:{if(p)switch(p){case"BigInt":return u([p,c.toString()],c);case"Boolean":case"Number":case"String":return u([p,c.valueOf()],c)}if(i&&"toJSON"in c)return d(c.toJSON());const y=[],b=u([h,y],c);for(const v of xE(c))(t||!lo(ja(c[v])))&&y.push([d(v),d(c[v])]);return b}case Of:return u([h,c.toISOString()],c);case Lf:{const{source:y,flags:b}=c;return u([h,{source:y,flags:b}],c)}case Bf:{const y=[],b=u([h,y],c);for(const[v,x]of c)(t||!(lo(ja(v))||lo(ja(x))))&&y.push([d(v),d(x)]);return b}case Uf:{const y=[],b=u([h,y],c);for(const v of c)(t||!lo(ja(v)))&&y.push(d(v));return b}}const{message:m}=c;return u([h,{name:p,message:m}],c)};return d},cb=(t,{json:i,lossy:r}={})=>{const a=[];return wE(!(i||r),!!i,new Map,a)(t),a},wo=typeof structuredClone=="function"?(t,i)=>i&&("json"in i||"lossy"in i)?ub(cb(t,i)):structuredClone(t):(t,i)=>ub(cb(t,i));function SE(t,i){const r=[{type:"text",value:"↩"}];return i>1&&r.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(i)}]}),r}function jE(t,i){return"Back to reference "+(t+1)+(i>1?"-"+i:"")}function kE(t){const i=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",r=t.options.footnoteBackContent||SE,a=t.options.footnoteBackLabel||jE,u=t.options.footnoteLabel||"Footnotes",d=t.options.footnoteLabelTagName||"h2",c=t.options.footnoteLabelProperties||{className:["sr-only"]},h=[];let p=-1;for(;++p<t.footnoteOrder.length;){const m=t.footnoteById.get(t.footnoteOrder[p]);if(!m)continue;const y=t.all(m),b=String(m.identifier).toUpperCase(),v=kl(b.toLowerCase());let x=0;const j=[],R=t.footnoteCounts.get(b);for(;R!==void 0&&++x<=R;){j.length>0&&j.push({type:"text",value:" "});let _=typeof r=="string"?r:r(p,x);typeof _=="string"&&(_={type:"text",value:_}),j.push({type:"element",tagName:"a",properties:{href:"#"+i+"fnref-"+v+(x>1?"-"+x:""),dataFootnoteBackref:"",ariaLabel:typeof a=="string"?a:a(p,x),className:["data-footnote-backref"]},children:Array.isArray(_)?_:[_]})}const C=y[y.length-1];if(C&&C.type==="element"&&C.tagName==="p"){const _=C.children[C.children.length-1];_&&_.type==="text"?_.value+=" ":C.children.push({type:"text",value:" "}),C.children.push(...j)}else y.push(...j);const A={type:"element",tagName:"li",properties:{id:i+"fn-"+v},children:t.wrap(y,!0)};t.patch(m,A),h.push(A)}if(h.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:d,properties:{...wo(c),id:"footnote-label"},children:[{type:"text",value:u}]},{type:"text",value:`
36
- `},{type:"element",tagName:"ol",properties:{},children:t.wrap(h,!0)},{type:"text",value:`
37
- `}]}}const Ro=(function(t){if(t==null)return TE;if(typeof t=="function")return zo(t);if(typeof t=="object")return Array.isArray(t)?CE(t):EE(t);if(typeof t=="string")return NE(t);throw new Error("Expected function, string, or object as test")});function CE(t){const i=[];let r=-1;for(;++r<t.length;)i[r]=Ro(t[r]);return zo(a);function a(...u){let d=-1;for(;++d<i.length;)if(i[d].apply(this,u))return!0;return!1}}function EE(t){const i=t;return zo(r);function r(a){const u=a;let d;for(d in t)if(u[d]!==i[d])return!1;return!0}}function NE(t){return zo(i);function i(r){return r&&r.type===t}}function zo(t){return i;function i(r,a,u){return!!(AE(r)&&t.call(this,r,typeof a=="number"?a:void 0,u||void 0))}}function TE(){return!0}function AE(t){return t!==null&&typeof t=="object"&&"type"in t}const Uv=[],RE=!0,rf=!1,zE="skip";function Iv(t,i,r,a){let u;typeof i=="function"&&typeof r!="function"?(a=r,r=i):u=i;const d=Ro(u),c=a?-1:1;h(t,void 0,[])();function h(p,m,y){const b=p&&typeof p=="object"?p:{};if(typeof b.type=="string"){const x=typeof b.tagName=="string"?b.tagName:typeof b.name=="string"?b.name:void 0;Object.defineProperty(v,"name",{value:"node ("+(p.type+(x?"<"+x+">":""))+")"})}return v;function v(){let x=Uv,j,R,C;if((!i||d(p,m,y[y.length-1]||void 0))&&(x=_E(r(p,y)),x[0]===rf))return x;if("children"in p&&p.children){const A=p;if(A.children&&x[0]!==zE)for(R=(a?A.children.length:-1)+c,C=y.concat(A);R>-1&&R<A.children.length;){const _=A.children[R];if(j=h(_,R,C)(),j[0]===rf)return j;R=typeof j[1]=="number"?j[1]:R+c}}return x}}}function _E(t){return Array.isArray(t)?t:typeof t=="number"?[RE,t]:t==null?Uv:[t]}function If(t,i,r,a){let u,d,c;typeof i=="function"&&typeof r!="function"?(d=void 0,c=i,u=r):(d=i,c=r,u=a),Iv(t,d,h,u);function h(p,m){const y=m[m.length-1],b=y?y.children.indexOf(p):void 0;return c(p,b,y)}}const lf={}.hasOwnProperty,DE={};function ME(t,i){const r=i||DE,a=new Map,u=new Map,d=new Map,c={...gE,...r.handlers},h={all:m,applyData:LE,definitionById:a,footnoteById:u,footnoteCounts:d,footnoteOrder:[],handlers:c,one:p,options:r,patch:OE,wrap:UE};return If(t,function(y){if(y.type==="definition"||y.type==="footnoteDefinition"){const b=y.type==="definition"?a:u,v=String(y.identifier).toUpperCase();b.has(v)||b.set(v,y)}}),h;function p(y,b){const v=y.type,x=h.handlers[v];if(lf.call(h.handlers,v)&&x)return x(h,y,b);if(h.options.passThrough&&h.options.passThrough.includes(v)){if("children"in y){const{children:R,...C}=y,A=wo(C);return A.children=h.all(y),A}return wo(y)}return(h.options.unknownHandler||BE)(h,y,b)}function m(y){const b=[];if("children"in y){const v=y.children;let x=-1;for(;++x<v.length;){const j=h.one(v[x],y);if(j){if(x&&v[x-1].type==="break"&&(!Array.isArray(j)&&j.type==="text"&&(j.value=db(j.value)),!Array.isArray(j)&&j.type==="element")){const R=j.children[0];R&&R.type==="text"&&(R.value=db(R.value))}Array.isArray(j)?b.push(...j):b.push(j)}}}return b}}function OE(t,i){t.position&&(i.position=Sj(t))}function LE(t,i){let r=i;if(t&&t.data){const a=t.data.hName,u=t.data.hChildren,d=t.data.hProperties;if(typeof a=="string")if(r.type==="element")r.tagName=a;else{const c="children"in r?r.children:[r];r={type:"element",tagName:a,properties:{},children:c}}r.type==="element"&&d&&Object.assign(r.properties,wo(d)),"children"in r&&r.children&&u!==null&&u!==void 0&&(r.children=u)}return r}function BE(t,i){const r=i.data||{},a="value"in i&&!(lf.call(r,"hProperties")||lf.call(r,"hChildren"))?{type:"text",value:i.value}:{type:"element",tagName:"div",properties:{},children:t.all(i)};return t.patch(i,a),t.applyData(i,a)}function UE(t,i){const r=[];let a=-1;for(i&&r.push({type:"text",value:`
38
- `});++a<t.length;)a&&r.push({type:"text",value:`
39
- `}),r.push(t[a]);return i&&t.length>0&&r.push({type:"text",value:`
40
- `}),r}function db(t){let i=0,r=t.charCodeAt(i);for(;r===9||r===32;)i++,r=t.charCodeAt(i);return t.slice(i)}function fb(t,i){const r=ME(t,i),a=r.one(t,void 0),u=kE(r),d=Array.isArray(a)?{type:"root",children:a}:a||{type:"root",children:[]};return u&&d.children.push({type:"text",value:`
41
- `},u),d}function IE(t,i){return t&&"run"in t?async function(r,a){const u=fb(r,{file:a,...i});await t.run(u,a)}:function(r,a){return fb(r,{file:a,...t||i})}}function hb(t){if(t)throw t}var _d,pb;function qE(){if(pb)return _d;pb=1;var t=Object.prototype.hasOwnProperty,i=Object.prototype.toString,r=Object.defineProperty,a=Object.getOwnPropertyDescriptor,u=function(m){return typeof Array.isArray=="function"?Array.isArray(m):i.call(m)==="[object Array]"},d=function(m){if(!m||i.call(m)!=="[object Object]")return!1;var y=t.call(m,"constructor"),b=m.constructor&&m.constructor.prototype&&t.call(m.constructor.prototype,"isPrototypeOf");if(m.constructor&&!y&&!b)return!1;var v;for(v in m);return typeof v>"u"||t.call(m,v)},c=function(m,y){r&&y.name==="__proto__"?r(m,y.name,{enumerable:!0,configurable:!0,value:y.newValue,writable:!0}):m[y.name]=y.newValue},h=function(m,y){if(y==="__proto__")if(t.call(m,y)){if(a)return a(m,y).value}else return;return m[y]};return _d=function p(){var m,y,b,v,x,j,R=arguments[0],C=1,A=arguments.length,_=!1;for(typeof R=="boolean"&&(_=R,R=arguments[1]||{},C=2),(R==null||typeof R!="object"&&typeof R!="function")&&(R={});C<A;++C)if(m=arguments[C],m!=null)for(y in m)b=h(R,y),v=h(m,y),R!==v&&(_&&v&&(d(v)||(x=u(v)))?(x?(x=!1,j=b&&u(b)?b:[]):j=b&&d(b)?b:{},c(R,{name:y,newValue:p(_,j,v)})):typeof v<"u"&&c(R,{name:y,newValue:v}));return R},_d}var HE=qE();const Dd=ko(HE);function af(t){if(typeof t!="object"||t===null)return!1;const i=Object.getPrototypeOf(t);return(i===null||i===Object.prototype||Object.getPrototypeOf(i)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function GE(){const t=[],i={run:r,use:a};return i;function r(...u){let d=-1;const c=u.pop();if(typeof c!="function")throw new TypeError("Expected function as last argument, not "+c);h(null,...u);function h(p,...m){const y=t[++d];let b=-1;if(p){c(p);return}for(;++b<u.length;)(m[b]===null||m[b]===void 0)&&(m[b]=u[b]);u=m,y?VE(y,h)(...m):c(null,...m)}}function a(u){if(typeof u!="function")throw new TypeError("Expected `middelware` to be a function, not "+u);return t.push(u),i}}function VE(t,i){let r;return a;function a(...c){const h=t.length>c.length;let p;h&&c.push(u);try{p=t.apply(this,c)}catch(m){const y=m;if(h&&r)throw y;return u(y)}h||(p&&p.then&&typeof p.then=="function"?p.then(d,u):p instanceof Error?u(p):d(p))}function u(c,...h){r||(r=!0,i(c,...h))}function d(c){u(null,c)}}const ti={basename:$E,dirname:PE,extname:YE,join:FE,sep:"/"};function $E(t,i){if(i!==void 0&&typeof i!="string")throw new TypeError('"ext" argument must be a string');La(t);let r=0,a=-1,u=t.length,d;if(i===void 0||i.length===0||i.length>t.length){for(;u--;)if(t.codePointAt(u)===47){if(d){r=u+1;break}}else a<0&&(d=!0,a=u+1);return a<0?"":t.slice(r,a)}if(i===t)return"";let c=-1,h=i.length-1;for(;u--;)if(t.codePointAt(u)===47){if(d){r=u+1;break}}else c<0&&(d=!0,c=u+1),h>-1&&(t.codePointAt(u)===i.codePointAt(h--)?h<0&&(a=u):(h=-1,a=c));return r===a?a=c:a<0&&(a=t.length),t.slice(r,a)}function PE(t){if(La(t),t.length===0)return".";let i=-1,r=t.length,a;for(;--r;)if(t.codePointAt(r)===47){if(a){i=r;break}}else a||(a=!0);return i<0?t.codePointAt(0)===47?"/":".":i===1&&t.codePointAt(0)===47?"//":t.slice(0,i)}function YE(t){La(t);let i=t.length,r=-1,a=0,u=-1,d=0,c;for(;i--;){const h=t.codePointAt(i);if(h===47){if(c){a=i+1;break}continue}r<0&&(c=!0,r=i+1),h===46?u<0?u=i:d!==1&&(d=1):u>-1&&(d=-1)}return u<0||r<0||d===0||d===1&&u===r-1&&u===a+1?"":t.slice(u,r)}function FE(...t){let i=-1,r;for(;++i<t.length;)La(t[i]),t[i]&&(r=r===void 0?t[i]:r+"/"+t[i]);return r===void 0?".":QE(r)}function QE(t){La(t);const i=t.codePointAt(0)===47;let r=XE(t,!i);return r.length===0&&!i&&(r="."),r.length>0&&t.codePointAt(t.length-1)===47&&(r+="/"),i?"/"+r:r}function XE(t,i){let r="",a=0,u=-1,d=0,c=-1,h,p;for(;++c<=t.length;){if(c<t.length)h=t.codePointAt(c);else{if(h===47)break;h=47}if(h===47){if(!(u===c-1||d===1))if(u!==c-1&&d===2){if(r.length<2||a!==2||r.codePointAt(r.length-1)!==46||r.codePointAt(r.length-2)!==46){if(r.length>2){if(p=r.lastIndexOf("/"),p!==r.length-1){p<0?(r="",a=0):(r=r.slice(0,p),a=r.length-1-r.lastIndexOf("/")),u=c,d=0;continue}}else if(r.length>0){r="",a=0,u=c,d=0;continue}}i&&(r=r.length>0?r+"/..":"..",a=2)}else r.length>0?r+="/"+t.slice(u+1,c):r=t.slice(u+1,c),a=c-u-1;u=c,d=0}else h===46&&d>-1?d++:d=-1}return r}function La(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const KE={cwd:ZE};function ZE(){return"/"}function sf(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function JE(t){if(typeof t=="string")t=new URL(t);else if(!sf(t)){const i=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+t+"`");throw i.code="ERR_INVALID_ARG_TYPE",i}if(t.protocol!=="file:"){const i=new TypeError("The URL must be of scheme file");throw i.code="ERR_INVALID_URL_SCHEME",i}return WE(t)}function WE(t){if(t.hostname!==""){const a=new TypeError('File URL host must be "localhost" or empty on darwin');throw a.code="ERR_INVALID_FILE_URL_HOST",a}const i=t.pathname;let r=-1;for(;++r<i.length;)if(i.codePointAt(r)===37&&i.codePointAt(r+1)===50){const a=i.codePointAt(r+2);if(a===70||a===102){const u=new TypeError("File URL path must not include encoded / characters");throw u.code="ERR_INVALID_FILE_URL_PATH",u}}return decodeURIComponent(i)}const Md=["history","path","basename","stem","extname","dirname"];class qv{constructor(i){let r;i?sf(i)?r={path:i}:typeof i=="string"||eN(i)?r={value:i}:r=i:r={},this.cwd="cwd"in r?"":KE.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let a=-1;for(;++a<Md.length;){const d=Md[a];d in r&&r[d]!==void 0&&r[d]!==null&&(this[d]=d==="history"?[...r[d]]:r[d])}let u;for(u in r)Md.includes(u)||(this[u]=r[u])}get basename(){return typeof this.path=="string"?ti.basename(this.path):void 0}set basename(i){Ld(i,"basename"),Od(i,"basename"),this.path=ti.join(this.dirname||"",i)}get dirname(){return typeof this.path=="string"?ti.dirname(this.path):void 0}set dirname(i){mb(this.basename,"dirname"),this.path=ti.join(i||"",this.basename)}get extname(){return typeof this.path=="string"?ti.extname(this.path):void 0}set extname(i){if(Od(i,"extname"),mb(this.dirname,"extname"),i){if(i.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(i.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=ti.join(this.dirname,this.stem+(i||""))}get path(){return this.history[this.history.length-1]}set path(i){sf(i)&&(i=JE(i)),Ld(i,"path"),this.path!==i&&this.history.push(i)}get stem(){return typeof this.path=="string"?ti.basename(this.path,this.extname):void 0}set stem(i){Ld(i,"stem"),Od(i,"stem"),this.path=ti.join(this.dirname||"",i+(this.extname||""))}fail(i,r,a){const u=this.message(i,r,a);throw u.fatal=!0,u}info(i,r,a){const u=this.message(i,r,a);return u.fatal=void 0,u}message(i,r,a){const u=new cn(i,r,a);return this.path&&(u.name=this.path+":"+u.name,u.file=this.path),u.fatal=!1,this.messages.push(u),u}toString(i){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(i||void 0).decode(this.value)}}function Od(t,i){if(t&&t.includes(ti.sep))throw new Error("`"+i+"` cannot be a path: did not expect `"+ti.sep+"`")}function Ld(t,i){if(!t)throw new Error("`"+i+"` cannot be empty")}function mb(t,i){if(!t)throw new Error("Setting `"+i+"` requires `path` to be set too")}function eN(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const tN=(function(t){const a=this.constructor.prototype,u=a[t],d=function(){return u.apply(d,arguments)};return Object.setPrototypeOf(d,a),d}),nN={}.hasOwnProperty;class qf extends tN{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=GE()}copy(){const i=new qf;let r=-1;for(;++r<this.attachers.length;){const a=this.attachers[r];i.use(...a)}return i.data(Dd(!0,{},this.namespace)),i}data(i,r){return typeof i=="string"?arguments.length===2?(Id("data",this.frozen),this.namespace[i]=r,this):nN.call(this.namespace,i)&&this.namespace[i]||void 0:i?(Id("data",this.frozen),this.namespace=i,this):this.namespace}freeze(){if(this.frozen)return this;const i=this;for(;++this.freezeIndex<this.attachers.length;){const[r,...a]=this.attachers[this.freezeIndex];if(a[0]===!1)continue;a[0]===!0&&(a[0]=void 0);const u=r.call(i,...a);typeof u=="function"&&this.transformers.use(u)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(i){this.freeze();const r=ao(i),a=this.parser||this.Parser;return Bd("parse",a),a(String(r),r)}process(i,r){const a=this;return this.freeze(),Bd("process",this.parser||this.Parser),Ud("process",this.compiler||this.Compiler),r?u(void 0,r):new Promise(u);function u(d,c){const h=ao(i),p=a.parse(h);a.run(p,h,function(y,b,v){if(y||!b||!v)return m(y);const x=b,j=a.stringify(x,v);lN(j)?v.value=j:v.result=j,m(y,v)});function m(y,b){y||!b?c(y):d?d(b):r(void 0,b)}}}processSync(i){let r=!1,a;return this.freeze(),Bd("processSync",this.parser||this.Parser),Ud("processSync",this.compiler||this.Compiler),this.process(i,u),yb("processSync","process",r),a;function u(d,c){r=!0,hb(d),a=c}}run(i,r,a){gb(i),this.freeze();const u=this.transformers;return!a&&typeof r=="function"&&(a=r,r=void 0),a?d(void 0,a):new Promise(d);function d(c,h){const p=ao(r);u.run(i,p,m);function m(y,b,v){const x=b||i;y?h(y):c?c(x):a(void 0,x,v)}}}runSync(i,r){let a=!1,u;return this.run(i,r,d),yb("runSync","run",a),u;function d(c,h){hb(c),u=h,a=!0}}stringify(i,r){this.freeze();const a=ao(r),u=this.compiler||this.Compiler;return Ud("stringify",u),gb(i),u(i,a)}use(i,...r){const a=this.attachers,u=this.namespace;if(Id("use",this.frozen),i!=null)if(typeof i=="function")p(i,r);else if(typeof i=="object")Array.isArray(i)?h(i):c(i);else throw new TypeError("Expected usable value, not `"+i+"`");return this;function d(m){if(typeof m=="function")p(m,[]);else if(typeof m=="object")if(Array.isArray(m)){const[y,...b]=m;p(y,b)}else c(m);else throw new TypeError("Expected usable value, not `"+m+"`")}function c(m){if(!("plugins"in m)&&!("settings"in m))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");h(m.plugins),m.settings&&(u.settings=Dd(!0,u.settings,m.settings))}function h(m){let y=-1;if(m!=null)if(Array.isArray(m))for(;++y<m.length;){const b=m[y];d(b)}else throw new TypeError("Expected a list of plugins, not `"+m+"`")}function p(m,y){let b=-1,v=-1;for(;++b<a.length;)if(a[b][0]===m){v=b;break}if(v===-1)a.push([m,...y]);else if(y.length>0){let[x,...j]=y;const R=a[v][1];af(R)&&af(x)&&(x=Dd(!0,R,x)),a[v]=[m,x,...j]}}}}const iN=new qf().freeze();function Bd(t,i){if(typeof i!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function Ud(t,i){if(typeof i!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function Id(t,i){if(i)throw new Error("Cannot call `"+t+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function gb(t){if(!af(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function yb(t,i,r){if(!r)throw new Error("`"+t+"` finished async. Use `"+i+"` instead")}function ao(t){return rN(t)?t:new qv(t)}function rN(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function lN(t){return typeof t=="string"||aN(t)}function aN(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const sN="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",bb=[],vb={allowDangerousHtml:!0},oN=/^(https?|ircs?|mailto|xmpp)$/i,uN=[{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:"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 cN(t){const i=dN(t),r=fN(t);return hN(i.runSync(i.parse(r),r),t)}function dN(t){const i=t.rehypePlugins||bb,r=t.remarkPlugins||bb,a=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...vb}:vb;return iN().use($C).use(r).use(IE,a).use(i)}function fN(t){const i=t.children||"",r=new qv;return typeof i=="string"&&(r.value=i),r}function hN(t,i){const r=i.allowedElements,a=i.allowElement,u=i.components,d=i.disallowedElements,c=i.skipHtml,h=i.unwrapDisallowed,p=i.urlTransform||pN;for(const y of uN)Object.hasOwn(i,y.from)&&(""+y.from+(y.to?"use `"+y.to+"` instead":"remove it")+sN+y.id,void 0);return i.className&&(t={type:"element",tagName:"div",properties:{className:i.className},children:t.type==="root"?t.children:[t]}),If(t,m),Nj(t,{Fragment:s.Fragment,components:u,ignoreInvalidStyle:!0,jsx:s.jsx,jsxs:s.jsxs,passKeys:!0,passNode:!0});function m(y,b,v){if(y.type==="raw"&&v&&typeof b=="number")return c?v.children.splice(b,1):v.children[b]={type:"text",value:y.value},b;if(y.type==="element"){let x;for(x in Ad)if(Object.hasOwn(Ad,x)&&Object.hasOwn(y.properties,x)){const j=y.properties[x],R=Ad[x];(R===null||R.includes(y.tagName))&&(y.properties[x]=p(String(j||""),x,y))}}if(y.type==="element"){let x=r?!r.includes(y.tagName):d?d.includes(y.tagName):!1;if(!x&&a&&typeof b=="number"&&(x=!a(y,b,v)),x&&v&&typeof b=="number")return h&&y.children?v.children.splice(b,1,...y.children):v.children.splice(b,1),b}}}function pN(t){const i=t.indexOf(":"),r=t.indexOf("?"),a=t.indexOf("#"),u=t.indexOf("/");return i===-1||u!==-1&&i>u||r!==-1&&i>r||a!==-1&&i>a||oN.test(t.slice(0,i))?t:""}function xb(t,i){const r=String(t);if(typeof i!="string")throw new TypeError("Expected character");let a=0,u=r.indexOf(i);for(;u!==-1;)a++,u=r.indexOf(i,u+i.length);return a}function mN(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function gN(t,i,r){const u=Ro((r||{}).ignore||[]),d=yN(i);let c=-1;for(;++c<d.length;)Iv(t,"text",h);function h(m,y){let b=-1,v;for(;++b<y.length;){const x=y[b],j=v?v.children:void 0;if(u(x,j?j.indexOf(x):void 0,v))return;v=x}if(v)return p(m,y)}function p(m,y){const b=y[y.length-1],v=d[c][0],x=d[c][1];let j=0;const C=b.children.indexOf(m);let A=!1,_=[];v.lastIndex=0;let D=v.exec(m.value);for(;D;){const q=D.index,ae={index:D.index,input:D.input,stack:[...y,m]};let N=x(...D,ae);if(typeof N=="string"&&(N=N.length>0?{type:"text",value:N}:void 0),N===!1?v.lastIndex=q+1:(j!==q&&_.push({type:"text",value:m.value.slice(j,q)}),Array.isArray(N)?_.push(...N):N&&_.push(N),j=q+D[0].length,A=!0),!v.global)break;D=v.exec(m.value)}return A?(j<m.value.length&&_.push({type:"text",value:m.value.slice(j)}),b.children.splice(C,1,..._)):_=[m],C+_.length}}function yN(t){const i=[];if(!Array.isArray(t))throw new TypeError("Expected find and replace tuple or list of tuples");const r=!t[0]||Array.isArray(t[0])?t:[t];let a=-1;for(;++a<r.length;){const u=r[a];i.push([bN(u[0]),vN(u[1])])}return i}function bN(t){return typeof t=="string"?new RegExp(mN(t),"g"):t}function vN(t){return typeof t=="function"?t:function(){return t}}const qd="phrasing",Hd=["autolink","link","image","label"];function xN(){return{transforms:[NN],enter:{literalAutolink:SN,literalAutolinkEmail:Gd,literalAutolinkHttp:Gd,literalAutolinkWww:Gd},exit:{literalAutolink:EN,literalAutolinkEmail:CN,literalAutolinkHttp:jN,literalAutolinkWww:kN}}}function wN(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:qd,notInConstruct:Hd},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:qd,notInConstruct:Hd},{character:":",before:"[ps]",after:"\\/",inConstruct:qd,notInConstruct:Hd}]}}function SN(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function Gd(t){this.config.enter.autolinkProtocol.call(this,t)}function jN(t){this.config.exit.autolinkProtocol.call(this,t)}function kN(t){this.config.exit.data.call(this,t);const i=this.stack[this.stack.length-1];i.type,i.url="http://"+this.sliceSerialize(t)}function CN(t){this.config.exit.autolinkEmail.call(this,t)}function EN(t){this.exit(t)}function NN(t){gN(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,TN],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),AN]],{ignore:["link","linkReference"]})}function TN(t,i,r,a,u){let d="";if(!Hv(u)||(/^w/i.test(i)&&(r=i+r,i="",d="http://"),!RN(r)))return!1;const c=zN(r+a);if(!c[0])return!1;const h={type:"link",title:null,url:d+i+c[0],children:[{type:"text",value:i+c[0]}]};return c[1]?[h,{type:"text",value:c[1]}]:h}function AN(t,i,r,a){return!Hv(a,!0)||/[-\d_]$/.test(r)?!1:{type:"link",title:null,url:"mailto:"+i+"@"+r,children:[{type:"text",value:i+"@"+r}]}}function RN(t){const i=t.split(".");return!(i.length<2||i[i.length-1]&&(/_/.test(i[i.length-1])||!/[a-zA-Z\d]/.test(i[i.length-1]))||i[i.length-2]&&(/_/.test(i[i.length-2])||!/[a-zA-Z\d]/.test(i[i.length-2])))}function zN(t){const i=/[!"&'),.:;<>?\]}]+$/.exec(t);if(!i)return[t,void 0];t=t.slice(0,i.index);let r=i[0],a=r.indexOf(")");const u=xb(t,"(");let d=xb(t,")");for(;a!==-1&&u>d;)t+=r.slice(0,a+1),r=r.slice(a+1),a=r.indexOf(")"),d++;return[t,r]}function Hv(t,i){const r=t.input.charCodeAt(t.index-1);return(t.index===0||jr(r)||No(r))&&(!i||r!==47)}Gv.peek=qN;function _N(){this.buffer()}function DN(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function MN(){this.buffer()}function ON(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function LN(t){const i=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=Fn(this.sliceSerialize(t)).toLowerCase(),r.label=i}function BN(t){this.exit(t)}function UN(t){const i=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=Fn(this.sliceSerialize(t)).toLowerCase(),r.label=i}function IN(t){this.exit(t)}function qN(){return"["}function Gv(t,i,r,a){const u=r.createTracker(a);let d=u.move("[^");const c=r.enter("footnoteReference"),h=r.enter("reference");return d+=u.move(r.safe(r.associationId(t),{after:"]",before:d})),h(),c(),d+=u.move("]"),d}function HN(){return{enter:{gfmFootnoteCallString:_N,gfmFootnoteCall:DN,gfmFootnoteDefinitionLabelString:MN,gfmFootnoteDefinition:ON},exit:{gfmFootnoteCallString:LN,gfmFootnoteCall:BN,gfmFootnoteDefinitionLabelString:UN,gfmFootnoteDefinition:IN}}}function GN(t){let i=!1;return t&&t.firstLineBlank&&(i=!0),{handlers:{footnoteDefinition:r,footnoteReference:Gv},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function r(a,u,d,c){const h=d.createTracker(c);let p=h.move("[^");const m=d.enter("footnoteDefinition"),y=d.enter("label");return p+=h.move(d.safe(d.associationId(a),{before:p,after:"]"})),y(),p+=h.move("]:"),a.children&&a.children.length>0&&(h.shift(4),p+=h.move((i?`
42
- `:" ")+d.indentLines(d.containerFlow(a,h.current()),i?Vv:VN))),m(),p}}function VN(t,i,r){return i===0?t:Vv(t,i,r)}function Vv(t,i,r){return(r?"":" ")+t}const $N=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];$v.peek=XN;function PN(){return{canContainEols:["delete"],enter:{strikethrough:FN},exit:{strikethrough:QN}}}function YN(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:$N}],handlers:{delete:$v}}}function FN(t){this.enter({type:"delete",children:[]},t)}function QN(t){this.exit(t)}function $v(t,i,r,a){const u=r.createTracker(a),d=r.enter("strikethrough");let c=u.move("~~");return c+=r.containerPhrasing(t,{...u.current(),before:c,after:"~"}),c+=u.move("~~"),d(),c}function XN(){return"~"}function KN(t){return t.length}function ZN(t,i){const r=i||{},a=(r.align||[]).concat(),u=r.stringLength||KN,d=[],c=[],h=[],p=[];let m=0,y=-1;for(;++y<t.length;){const R=[],C=[];let A=-1;for(t[y].length>m&&(m=t[y].length);++A<t[y].length;){const _=JN(t[y][A]);if(r.alignDelimiters!==!1){const D=u(_);C[A]=D,(p[A]===void 0||D>p[A])&&(p[A]=D)}R.push(_)}c[y]=R,h[y]=C}let b=-1;if(typeof a=="object"&&"length"in a)for(;++b<m;)d[b]=wb(a[b]);else{const R=wb(a);for(;++b<m;)d[b]=R}b=-1;const v=[],x=[];for(;++b<m;){const R=d[b];let C="",A="";R===99?(C=":",A=":"):R===108?C=":":R===114&&(A=":");let _=r.alignDelimiters===!1?1:Math.max(1,p[b]-C.length-A.length);const D=C+"-".repeat(_)+A;r.alignDelimiters!==!1&&(_=C.length+_+A.length,_>p[b]&&(p[b]=_),x[b]=_),v[b]=D}c.splice(1,0,v),h.splice(1,0,x),y=-1;const j=[];for(;++y<c.length;){const R=c[y],C=h[y];b=-1;const A=[];for(;++b<m;){const _=R[b]||"";let D="",q="";if(r.alignDelimiters!==!1){const ae=p[b]-(C[b]||0),N=d[b];N===114?D=" ".repeat(ae):N===99?ae%2?(D=" ".repeat(ae/2+.5),q=" ".repeat(ae/2-.5)):(D=" ".repeat(ae/2),q=D):q=" ".repeat(ae)}r.delimiterStart!==!1&&!b&&A.push("|"),r.padding!==!1&&!(r.alignDelimiters===!1&&_==="")&&(r.delimiterStart!==!1||b)&&A.push(" "),r.alignDelimiters!==!1&&A.push(D),A.push(_),r.alignDelimiters!==!1&&A.push(q),r.padding!==!1&&A.push(" "),(r.delimiterEnd!==!1||b!==m-1)&&A.push("|")}j.push(r.delimiterEnd===!1?A.join("").replace(/ +$/,""):A.join(""))}return j.join(`
43
- `)}function JN(t){return t==null?"":String(t)}function wb(t){const i=typeof t=="string"?t.codePointAt(0):0;return i===67||i===99?99:i===76||i===108?108:i===82||i===114?114:0}function WN(t,i,r,a){const u=r.enter("blockquote"),d=r.createTracker(a);d.move("> "),d.shift(2);const c=r.indentLines(r.containerFlow(t,d.current()),e2);return u(),c}function e2(t,i,r){return">"+(r?"":" ")+t}function t2(t,i){return Sb(t,i.inConstruct,!0)&&!Sb(t,i.notInConstruct,!1)}function Sb(t,i,r){if(typeof i=="string"&&(i=[i]),!i||i.length===0)return r;let a=-1;for(;++a<i.length;)if(t.includes(i[a]))return!0;return!1}function jb(t,i,r,a){let u=-1;for(;++u<r.unsafe.length;)if(r.unsafe[u].character===`
44
- `&&t2(r.stack,r.unsafe[u]))return/[ \t]/.test(a.before)?"":" ";return`\\
45
- `}function n2(t,i){const r=String(t);let a=r.indexOf(i),u=a,d=0,c=0;if(typeof i!="string")throw new TypeError("Expected substring");for(;a!==-1;)a===u?++d>c&&(c=d):d=1,u=a+i.length,a=r.indexOf(i,u);return c}function i2(t,i){return!!(i.options.fences===!1&&t.value&&!t.lang&&/[^ \r\n]/.test(t.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(t.value))}function r2(t){const i=t.options.fence||"`";if(i!=="`"&&i!=="~")throw new Error("Cannot serialize code with `"+i+"` for `options.fence`, expected `` ` `` or `~`");return i}function l2(t,i,r,a){const u=r2(r),d=t.value||"",c=u==="`"?"GraveAccent":"Tilde";if(i2(t,r)){const b=r.enter("codeIndented"),v=r.indentLines(d,a2);return b(),v}const h=r.createTracker(a),p=u.repeat(Math.max(n2(d,u)+1,3)),m=r.enter("codeFenced");let y=h.move(p);if(t.lang){const b=r.enter(`codeFencedLang${c}`);y+=h.move(r.safe(t.lang,{before:y,after:" ",encode:["`"],...h.current()})),b()}if(t.lang&&t.meta){const b=r.enter(`codeFencedMeta${c}`);y+=h.move(" "),y+=h.move(r.safe(t.meta,{before:y,after:`
46
- `,encode:["`"],...h.current()})),b()}return y+=h.move(`
47
- `),d&&(y+=h.move(d+`
48
- `)),y+=h.move(p),m(),y}function a2(t,i,r){return(r?"":" ")+t}function Hf(t){const i=t.options.quote||'"';if(i!=='"'&&i!=="'")throw new Error("Cannot serialize title with `"+i+"` for `options.quote`, expected `\"`, or `'`");return i}function s2(t,i,r,a){const u=Hf(r),d=u==='"'?"Quote":"Apostrophe",c=r.enter("definition");let h=r.enter("label");const p=r.createTracker(a);let m=p.move("[");return m+=p.move(r.safe(r.associationId(t),{before:m,after:"]",...p.current()})),m+=p.move("]: "),h(),!t.url||/[\0- \u007F]/.test(t.url)?(h=r.enter("destinationLiteral"),m+=p.move("<"),m+=p.move(r.safe(t.url,{before:m,after:">",...p.current()})),m+=p.move(">")):(h=r.enter("destinationRaw"),m+=p.move(r.safe(t.url,{before:m,after:t.title?" ":`
49
- `,...p.current()}))),h(),t.title&&(h=r.enter(`title${d}`),m+=p.move(" "+u),m+=p.move(r.safe(t.title,{before:m,after:u,...p.current()})),m+=p.move(u),h()),c(),m}function o2(t){const i=t.options.emphasis||"*";if(i!=="*"&&i!=="_")throw new Error("Cannot serialize emphasis with `"+i+"` for `options.emphasis`, expected `*`, or `_`");return i}function Ra(t){return"&#x"+t.toString(16).toUpperCase()+";"}function So(t,i,r){const a=wl(t),u=wl(i);return a===void 0?u===void 0?r==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:u===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:a===1?u===void 0?{inside:!1,outside:!1}:u===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:u===void 0?{inside:!1,outside:!1}:u===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}Pv.peek=u2;function Pv(t,i,r,a){const u=o2(r),d=r.enter("emphasis"),c=r.createTracker(a),h=c.move(u);let p=c.move(r.containerPhrasing(t,{after:u,before:h,...c.current()}));const m=p.charCodeAt(0),y=So(a.before.charCodeAt(a.before.length-1),m,u);y.inside&&(p=Ra(m)+p.slice(1));const b=p.charCodeAt(p.length-1),v=So(a.after.charCodeAt(0),b,u);v.inside&&(p=p.slice(0,-1)+Ra(b));const x=c.move(u);return d(),r.attentionEncodeSurroundingInfo={after:v.outside,before:y.outside},h+p+x}function u2(t,i,r){return r.options.emphasis||"*"}function c2(t,i){let r=!1;return If(t,function(a){if("value"in a&&/\r?\n|\r/.test(a.value)||a.type==="break")return r=!0,rf}),!!((!t.depth||t.depth<3)&&_f(t)&&(i.options.setext||r))}function d2(t,i,r,a){const u=Math.max(Math.min(6,t.depth||1),1),d=r.createTracker(a);if(c2(t,r)){const y=r.enter("headingSetext"),b=r.enter("phrasing"),v=r.containerPhrasing(t,{...d.current(),before:`
50
- `,after:`
51
- `});return b(),y(),v+`
52
- `+(u===1?"=":"-").repeat(v.length-(Math.max(v.lastIndexOf("\r"),v.lastIndexOf(`
53
- `))+1))}const c="#".repeat(u),h=r.enter("headingAtx"),p=r.enter("phrasing");d.move(c+" ");let m=r.containerPhrasing(t,{before:"# ",after:`
54
- `,...d.current()});return/^[\t ]/.test(m)&&(m=Ra(m.charCodeAt(0))+m.slice(1)),m=m?c+" "+m:c,r.options.closeAtx&&(m+=" "+c),p(),h(),m}Yv.peek=f2;function Yv(t){return t.value||""}function f2(){return"<"}Fv.peek=h2;function Fv(t,i,r,a){const u=Hf(r),d=u==='"'?"Quote":"Apostrophe",c=r.enter("image");let h=r.enter("label");const p=r.createTracker(a);let m=p.move("![");return m+=p.move(r.safe(t.alt,{before:m,after:"]",...p.current()})),m+=p.move("]("),h(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(h=r.enter("destinationLiteral"),m+=p.move("<"),m+=p.move(r.safe(t.url,{before:m,after:">",...p.current()})),m+=p.move(">")):(h=r.enter("destinationRaw"),m+=p.move(r.safe(t.url,{before:m,after:t.title?" ":")",...p.current()}))),h(),t.title&&(h=r.enter(`title${d}`),m+=p.move(" "+u),m+=p.move(r.safe(t.title,{before:m,after:u,...p.current()})),m+=p.move(u),h()),m+=p.move(")"),c(),m}function h2(){return"!"}Qv.peek=p2;function Qv(t,i,r,a){const u=t.referenceType,d=r.enter("imageReference");let c=r.enter("label");const h=r.createTracker(a);let p=h.move("![");const m=r.safe(t.alt,{before:p,after:"]",...h.current()});p+=h.move(m+"]["),c();const y=r.stack;r.stack=[],c=r.enter("reference");const b=r.safe(r.associationId(t),{before:p,after:"]",...h.current()});return c(),r.stack=y,d(),u==="full"||!m||m!==b?p+=h.move(b+"]"):u==="shortcut"?p=p.slice(0,-1):p+=h.move("]"),p}function p2(){return"!"}Xv.peek=m2;function Xv(t,i,r){let a=t.value||"",u="`",d=-1;for(;new RegExp("(^|[^`])"+u+"([^`]|$)").test(a);)u+="`";for(/[^ \r\n]/.test(a)&&(/^[ \r\n]/.test(a)&&/[ \r\n]$/.test(a)||/^`|`$/.test(a))&&(a=" "+a+" ");++d<r.unsafe.length;){const c=r.unsafe[d],h=r.compilePattern(c);let p;if(c.atBreak)for(;p=h.exec(a);){let m=p.index;a.charCodeAt(m)===10&&a.charCodeAt(m-1)===13&&m--,a=a.slice(0,m)+" "+a.slice(p.index+1)}}return u+a+u}function m2(){return"`"}function Kv(t,i){const r=_f(t);return!!(!i.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(r===t.url||"mailto:"+r===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}Zv.peek=g2;function Zv(t,i,r,a){const u=Hf(r),d=u==='"'?"Quote":"Apostrophe",c=r.createTracker(a);let h,p;if(Kv(t,r)){const y=r.stack;r.stack=[],h=r.enter("autolink");let b=c.move("<");return b+=c.move(r.containerPhrasing(t,{before:b,after:">",...c.current()})),b+=c.move(">"),h(),r.stack=y,b}h=r.enter("link"),p=r.enter("label");let m=c.move("[");return m+=c.move(r.containerPhrasing(t,{before:m,after:"](",...c.current()})),m+=c.move("]("),p(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(p=r.enter("destinationLiteral"),m+=c.move("<"),m+=c.move(r.safe(t.url,{before:m,after:">",...c.current()})),m+=c.move(">")):(p=r.enter("destinationRaw"),m+=c.move(r.safe(t.url,{before:m,after:t.title?" ":")",...c.current()}))),p(),t.title&&(p=r.enter(`title${d}`),m+=c.move(" "+u),m+=c.move(r.safe(t.title,{before:m,after:u,...c.current()})),m+=c.move(u),p()),m+=c.move(")"),h(),m}function g2(t,i,r){return Kv(t,r)?"<":"["}Jv.peek=y2;function Jv(t,i,r,a){const u=t.referenceType,d=r.enter("linkReference");let c=r.enter("label");const h=r.createTracker(a);let p=h.move("[");const m=r.containerPhrasing(t,{before:p,after:"]",...h.current()});p+=h.move(m+"]["),c();const y=r.stack;r.stack=[],c=r.enter("reference");const b=r.safe(r.associationId(t),{before:p,after:"]",...h.current()});return c(),r.stack=y,d(),u==="full"||!m||m!==b?p+=h.move(b+"]"):u==="shortcut"?p=p.slice(0,-1):p+=h.move("]"),p}function y2(){return"["}function Gf(t){const i=t.options.bullet||"*";if(i!=="*"&&i!=="+"&&i!=="-")throw new Error("Cannot serialize items with `"+i+"` for `options.bullet`, expected `*`, `+`, or `-`");return i}function b2(t){const i=Gf(t),r=t.options.bulletOther;if(!r)return i==="*"?"-":"*";if(r!=="*"&&r!=="+"&&r!=="-")throw new Error("Cannot serialize items with `"+r+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(r===i)throw new Error("Expected `bullet` (`"+i+"`) and `bulletOther` (`"+r+"`) to be different");return r}function v2(t){const i=t.options.bulletOrdered||".";if(i!=="."&&i!==")")throw new Error("Cannot serialize items with `"+i+"` for `options.bulletOrdered`, expected `.` or `)`");return i}function Wv(t){const i=t.options.rule||"*";if(i!=="*"&&i!=="-"&&i!=="_")throw new Error("Cannot serialize rules with `"+i+"` for `options.rule`, expected `*`, `-`, or `_`");return i}function x2(t,i,r,a){const u=r.enter("list"),d=r.bulletCurrent;let c=t.ordered?v2(r):Gf(r);const h=t.ordered?c==="."?")":".":b2(r);let p=i&&r.bulletLastUsed?c===r.bulletLastUsed:!1;if(!t.ordered){const y=t.children?t.children[0]:void 0;if((c==="*"||c==="-")&&y&&(!y.children||!y.children[0])&&r.stack[r.stack.length-1]==="list"&&r.stack[r.stack.length-2]==="listItem"&&r.stack[r.stack.length-3]==="list"&&r.stack[r.stack.length-4]==="listItem"&&r.indexStack[r.indexStack.length-1]===0&&r.indexStack[r.indexStack.length-2]===0&&r.indexStack[r.indexStack.length-3]===0&&(p=!0),Wv(r)===c&&y){let b=-1;for(;++b<t.children.length;){const v=t.children[b];if(v&&v.type==="listItem"&&v.children&&v.children[0]&&v.children[0].type==="thematicBreak"){p=!0;break}}}}p&&(c=h),r.bulletCurrent=c;const m=r.containerFlow(t,a);return r.bulletLastUsed=c,r.bulletCurrent=d,u(),m}function w2(t){const i=t.options.listItemIndent||"one";if(i!=="tab"&&i!=="one"&&i!=="mixed")throw new Error("Cannot serialize items with `"+i+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return i}function S2(t,i,r,a){const u=w2(r);let d=r.bulletCurrent||Gf(r);i&&i.type==="list"&&i.ordered&&(d=(typeof i.start=="number"&&i.start>-1?i.start:1)+(r.options.incrementListMarker===!1?0:i.children.indexOf(t))+d);let c=d.length+1;(u==="tab"||u==="mixed"&&(i&&i.type==="list"&&i.spread||t.spread))&&(c=Math.ceil(c/4)*4);const h=r.createTracker(a);h.move(d+" ".repeat(c-d.length)),h.shift(c);const p=r.enter("listItem"),m=r.indentLines(r.containerFlow(t,h.current()),y);return p(),m;function y(b,v,x){return v?(x?"":" ".repeat(c))+b:(x?d:d+" ".repeat(c-d.length))+b}}function j2(t,i,r,a){const u=r.enter("paragraph"),d=r.enter("phrasing"),c=r.containerPhrasing(t,a);return d(),u(),c}const k2=Ro(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function C2(t,i,r,a){return(t.children.some(function(c){return k2(c)})?r.containerPhrasing:r.containerFlow).call(r,t,a)}function E2(t){const i=t.options.strong||"*";if(i!=="*"&&i!=="_")throw new Error("Cannot serialize strong with `"+i+"` for `options.strong`, expected `*`, or `_`");return i}ex.peek=N2;function ex(t,i,r,a){const u=E2(r),d=r.enter("strong"),c=r.createTracker(a),h=c.move(u+u);let p=c.move(r.containerPhrasing(t,{after:u,before:h,...c.current()}));const m=p.charCodeAt(0),y=So(a.before.charCodeAt(a.before.length-1),m,u);y.inside&&(p=Ra(m)+p.slice(1));const b=p.charCodeAt(p.length-1),v=So(a.after.charCodeAt(0),b,u);v.inside&&(p=p.slice(0,-1)+Ra(b));const x=c.move(u+u);return d(),r.attentionEncodeSurroundingInfo={after:v.outside,before:y.outside},h+p+x}function N2(t,i,r){return r.options.strong||"*"}function T2(t,i,r,a){return r.safe(t.value,a)}function A2(t){const i=t.options.ruleRepetition||3;if(i<3)throw new Error("Cannot serialize rules with repetition `"+i+"` for `options.ruleRepetition`, expected `3` or more");return i}function R2(t,i,r){const a=(Wv(r)+(r.options.ruleSpaces?" ":"")).repeat(A2(r));return r.options.ruleSpaces?a.slice(0,-1):a}const tx={blockquote:WN,break:jb,code:l2,definition:s2,emphasis:Pv,hardBreak:jb,heading:d2,html:Yv,image:Fv,imageReference:Qv,inlineCode:Xv,link:Zv,linkReference:Jv,list:x2,listItem:S2,paragraph:j2,root:C2,strong:ex,text:T2,thematicBreak:R2};function z2(){return{enter:{table:_2,tableData:kb,tableHeader:kb,tableRow:M2},exit:{codeText:O2,table:D2,tableData:Vd,tableHeader:Vd,tableRow:Vd}}}function _2(t){const i=t._align;this.enter({type:"table",align:i.map(function(r){return r==="none"?null:r}),children:[]},t),this.data.inTable=!0}function D2(t){this.exit(t),this.data.inTable=void 0}function M2(t){this.enter({type:"tableRow",children:[]},t)}function Vd(t){this.exit(t)}function kb(t){this.enter({type:"tableCell",children:[]},t)}function O2(t){let i=this.resume();this.data.inTable&&(i=i.replace(/\\([\\|])/g,L2));const r=this.stack[this.stack.length-1];r.type,r.value=i,this.exit(t)}function L2(t,i){return i==="|"?i:t}function B2(t){const i=t||{},r=i.tableCellPadding,a=i.tablePipeAlign,u=i.stringLength,d=r?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
55
- `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:v,table:c,tableCell:p,tableRow:h}};function c(x,j,R,C){return m(y(x,R,C),x.align)}function h(x,j,R,C){const A=b(x,R,C),_=m([A]);return _.slice(0,_.indexOf(`
56
- `))}function p(x,j,R,C){const A=R.enter("tableCell"),_=R.enter("phrasing"),D=R.containerPhrasing(x,{...C,before:d,after:d});return _(),A(),D}function m(x,j){return ZN(x,{align:j,alignDelimiters:a,padding:r,stringLength:u})}function y(x,j,R){const C=x.children;let A=-1;const _=[],D=j.enter("table");for(;++A<C.length;)_[A]=b(C[A],j,R);return D(),_}function b(x,j,R){const C=x.children;let A=-1;const _=[],D=j.enter("tableRow");for(;++A<C.length;)_[A]=p(C[A],x,j,R);return D(),_}function v(x,j,R){let C=tx.inlineCode(x,j,R);return R.stack.includes("tableCell")&&(C=C.replace(/\|/g,"\\$&")),C}}function U2(){return{exit:{taskListCheckValueChecked:Cb,taskListCheckValueUnchecked:Cb,paragraph:q2}}}function I2(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:H2}}}function Cb(t){const i=this.stack[this.stack.length-2];i.type,i.checked=t.type==="taskListCheckValueChecked"}function q2(t){const i=this.stack[this.stack.length-2];if(i&&i.type==="listItem"&&typeof i.checked=="boolean"){const r=this.stack[this.stack.length-1];r.type;const a=r.children[0];if(a&&a.type==="text"){const u=i.children;let d=-1,c;for(;++d<u.length;){const h=u[d];if(h.type==="paragraph"){c=h;break}}c===r&&(a.value=a.value.slice(1),a.value.length===0?r.children.shift():r.position&&a.position&&typeof a.position.start.offset=="number"&&(a.position.start.column++,a.position.start.offset++,r.position.start=Object.assign({},a.position.start)))}}this.exit(t)}function H2(t,i,r,a){const u=t.children[0],d=typeof t.checked=="boolean"&&u&&u.type==="paragraph",c="["+(t.checked?"x":" ")+"] ",h=r.createTracker(a);d&&h.move(c);let p=tx.listItem(t,i,r,{...a,...h.current()});return d&&(p=p.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,m)),p;function m(y){return y+c}}function G2(){return[xN(),HN(),PN(),z2(),U2()]}function V2(t){return{extensions:[wN(),GN(t),YN(),B2(t),I2()]}}const $2={tokenize:K2,partial:!0},nx={tokenize:Z2,partial:!0},ix={tokenize:J2,partial:!0},rx={tokenize:W2,partial:!0},P2={tokenize:eT,partial:!0},lx={name:"wwwAutolink",tokenize:Q2,previous:sx},ax={name:"protocolAutolink",tokenize:X2,previous:ox},Ti={name:"emailAutolink",tokenize:F2,previous:ux},ri={};function Y2(){return{text:ri}}let vr=48;for(;vr<123;)ri[vr]=Ti,vr++,vr===58?vr=65:vr===91&&(vr=97);ri[43]=Ti;ri[45]=Ti;ri[46]=Ti;ri[95]=Ti;ri[72]=[Ti,ax];ri[104]=[Ti,ax];ri[87]=[Ti,lx];ri[119]=[Ti,lx];function F2(t,i,r){const a=this;let u,d;return c;function c(b){return!of(b)||!ux.call(a,a.previous)||Vf(a.events)?r(b):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),h(b))}function h(b){return of(b)?(t.consume(b),h):b===64?(t.consume(b),p):r(b)}function p(b){return b===46?t.check(P2,y,m)(b):b===45||b===95||un(b)?(d=!0,t.consume(b),p):y(b)}function m(b){return t.consume(b),u=!0,p}function y(b){return d&&u&&fn(a.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),i(b)):r(b)}}function Q2(t,i,r){const a=this;return u;function u(c){return c!==87&&c!==119||!sx.call(a,a.previous)||Vf(a.events)?r(c):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check($2,t.attempt(nx,t.attempt(ix,d),r),r)(c))}function d(c){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),i(c)}}function X2(t,i,r){const a=this;let u="",d=!1;return c;function c(b){return(b===72||b===104)&&ox.call(a,a.previous)&&!Vf(a.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),u+=String.fromCodePoint(b),t.consume(b),h):r(b)}function h(b){if(fn(b)&&u.length<5)return u+=String.fromCodePoint(b),t.consume(b),h;if(b===58){const v=u.toLowerCase();if(v==="http"||v==="https")return t.consume(b),p}return r(b)}function p(b){return b===47?(t.consume(b),d?m:(d=!0,p)):r(b)}function m(b){return b===null||vo(b)||_t(b)||jr(b)||No(b)?r(b):t.attempt(nx,t.attempt(ix,y),r)(b)}function y(b){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),i(b)}}function K2(t,i,r){let a=0;return u;function u(c){return(c===87||c===119)&&a<3?(a++,t.consume(c),u):c===46&&a===3?(t.consume(c),d):r(c)}function d(c){return c===null?r(c):i(c)}}function Z2(t,i,r){let a,u,d;return c;function c(m){return m===46||m===95?t.check(rx,p,h)(m):m===null||_t(m)||jr(m)||m!==45&&No(m)?p(m):(d=!0,t.consume(m),c)}function h(m){return m===95?a=!0:(u=a,a=void 0),t.consume(m),c}function p(m){return u||a||!d?r(m):i(m)}}function J2(t,i){let r=0,a=0;return u;function u(c){return c===40?(r++,t.consume(c),u):c===41&&a<r?d(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?t.check(rx,i,d)(c):c===null||_t(c)||jr(c)?i(c):(t.consume(c),u)}function d(c){return c===41&&a++,t.consume(c),u}}function W2(t,i,r){return a;function a(h){return h===33||h===34||h===39||h===41||h===42||h===44||h===46||h===58||h===59||h===63||h===95||h===126?(t.consume(h),a):h===38?(t.consume(h),d):h===93?(t.consume(h),u):h===60||h===null||_t(h)||jr(h)?i(h):r(h)}function u(h){return h===null||h===40||h===91||_t(h)||jr(h)?i(h):a(h)}function d(h){return fn(h)?c(h):r(h)}function c(h){return h===59?(t.consume(h),a):fn(h)?(t.consume(h),c):r(h)}}function eT(t,i,r){return a;function a(d){return t.consume(d),u}function u(d){return un(d)?r(d):i(d)}}function sx(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||_t(t)}function ox(t){return!fn(t)}function ux(t){return!(t===47||of(t))}function of(t){return t===43||t===45||t===46||t===95||un(t)}function Vf(t){let i=t.length,r=!1;for(;i--;){const a=t[i][1];if((a.type==="labelLink"||a.type==="labelImage")&&!a._balanced){r=!0;break}if(a._gfmAutolinkLiteralWalkedInto){r=!1;break}}return t.length>0&&!r&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),r}const tT={tokenize:uT,partial:!0};function nT(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:aT,continuation:{tokenize:sT},exit:oT}},text:{91:{name:"gfmFootnoteCall",tokenize:lT},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:iT,resolveTo:rT}}}}function iT(t,i,r){const a=this;let u=a.events.length;const d=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let c;for(;u--;){const p=a.events[u][1];if(p.type==="labelImage"){c=p;break}if(p.type==="gfmFootnoteCall"||p.type==="labelLink"||p.type==="label"||p.type==="image"||p.type==="link")break}return h;function h(p){if(!c||!c._balanced)return r(p);const m=Fn(a.sliceSerialize({start:c.end,end:a.now()}));return m.codePointAt(0)!==94||!d.includes(m.slice(1))?r(p):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(p),t.exit("gfmFootnoteCallLabelMarker"),i(p))}}function rT(t,i){let r=t.length;for(;r--;)if(t[r][1].type==="labelImage"&&t[r][0]==="enter"){t[r][1];break}t[r+1][1].type="data",t[r+3][1].type="gfmFootnoteCallLabelMarker";const a={type:"gfmFootnoteCall",start:Object.assign({},t[r+3][1].start),end:Object.assign({},t[t.length-1][1].end)},u={type:"gfmFootnoteCallMarker",start:Object.assign({},t[r+3][1].end),end:Object.assign({},t[r+3][1].end)};u.end.column++,u.end.offset++,u.end._bufferIndex++;const d={type:"gfmFootnoteCallString",start:Object.assign({},u.end),end:Object.assign({},t[t.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},d.start),end:Object.assign({},d.end)},h=[t[r+1],t[r+2],["enter",a,i],t[r+3],t[r+4],["enter",u,i],["exit",u,i],["enter",d,i],["enter",c,i],["exit",c,i],["exit",d,i],t[t.length-2],t[t.length-1],["exit",a,i]];return t.splice(r,t.length-r+1,...h),t}function lT(t,i,r){const a=this,u=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let d=0,c;return h;function h(b){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(b),t.exit("gfmFootnoteCallLabelMarker"),p}function p(b){return b!==94?r(b):(t.enter("gfmFootnoteCallMarker"),t.consume(b),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",m)}function m(b){if(d>999||b===93&&!c||b===null||b===91||_t(b))return r(b);if(b===93){t.exit("chunkString");const v=t.exit("gfmFootnoteCallString");return u.includes(Fn(a.sliceSerialize(v)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(b),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),i):r(b)}return _t(b)||(c=!0),d++,t.consume(b),b===92?y:m}function y(b){return b===91||b===92||b===93?(t.consume(b),d++,m):m(b)}}function aT(t,i,r){const a=this,u=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let d,c=0,h;return p;function p(j){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(j),t.exit("gfmFootnoteDefinitionLabelMarker"),m}function m(j){return j===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(j),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",y):r(j)}function y(j){if(c>999||j===93&&!h||j===null||j===91||_t(j))return r(j);if(j===93){t.exit("chunkString");const R=t.exit("gfmFootnoteDefinitionLabelString");return d=Fn(a.sliceSerialize(R)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(j),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),v}return _t(j)||(h=!0),c++,t.consume(j),j===92?b:y}function b(j){return j===91||j===92||j===93?(t.consume(j),c++,y):y(j)}function v(j){return j===58?(t.enter("definitionMarker"),t.consume(j),t.exit("definitionMarker"),u.includes(d)||u.push(d),dt(t,x,"gfmFootnoteDefinitionWhitespace")):r(j)}function x(j){return i(j)}}function sT(t,i,r){return t.check(Oa,i,t.attempt(tT,i,r))}function oT(t){t.exit("gfmFootnoteDefinition")}function uT(t,i,r){const a=this;return dt(t,u,"gfmFootnoteDefinitionIndent",5);function u(d){const c=a.events[a.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?i(d):r(d)}}function cT(t){let r=(t||{}).singleTilde;const a={name:"strikethrough",tokenize:d,resolveAll:u};return r==null&&(r=!0),{text:{126:a},insideSpan:{null:[a]},attentionMarkers:{null:[126]}};function u(c,h){let p=-1;for(;++p<c.length;)if(c[p][0]==="enter"&&c[p][1].type==="strikethroughSequenceTemporary"&&c[p][1]._close){let m=p;for(;m--;)if(c[m][0]==="exit"&&c[m][1].type==="strikethroughSequenceTemporary"&&c[m][1]._open&&c[p][1].end.offset-c[p][1].start.offset===c[m][1].end.offset-c[m][1].start.offset){c[p][1].type="strikethroughSequence",c[m][1].type="strikethroughSequence";const y={type:"strikethrough",start:Object.assign({},c[m][1].start),end:Object.assign({},c[p][1].end)},b={type:"strikethroughText",start:Object.assign({},c[m][1].end),end:Object.assign({},c[p][1].start)},v=[["enter",y,h],["enter",c[m][1],h],["exit",c[m][1],h],["enter",b,h]],x=h.parser.constructs.insideSpan.null;x&&Rn(v,v.length,0,To(x,c.slice(m+1,p),h)),Rn(v,v.length,0,[["exit",b,h],["enter",c[p][1],h],["exit",c[p][1],h],["exit",y,h]]),Rn(c,m-1,p-m+3,v),p=m+v.length-2;break}}for(p=-1;++p<c.length;)c[p][1].type==="strikethroughSequenceTemporary"&&(c[p][1].type="data");return c}function d(c,h,p){const m=this.previous,y=this.events;let b=0;return v;function v(j){return m===126&&y[y.length-1][1].type!=="characterEscape"?p(j):(c.enter("strikethroughSequenceTemporary"),x(j))}function x(j){const R=wl(m);if(j===126)return b>1?p(j):(c.consume(j),b++,x);if(b<2&&!r)return p(j);const C=c.exit("strikethroughSequenceTemporary"),A=wl(j);return C._open=!A||A===2&&!!R,C._close=!R||R===2&&!!A,h(j)}}}class dT{constructor(){this.map=[]}add(i,r,a){fT(this,i,r,a)}consume(i){if(this.map.sort(function(d,c){return d[0]-c[0]}),this.map.length===0)return;let r=this.map.length;const a=[];for(;r>0;)r-=1,a.push(i.slice(this.map[r][0]+this.map[r][1]),this.map[r][2]),i.length=this.map[r][0];a.push(i.slice()),i.length=0;let u=a.pop();for(;u;){for(const d of u)i.push(d);u=a.pop()}this.map.length=0}}function fT(t,i,r,a){let u=0;if(!(r===0&&a.length===0)){for(;u<t.map.length;){if(t.map[u][0]===i){t.map[u][1]+=r,t.map[u][2].push(...a);return}u+=1}t.map.push([i,r,a])}}function hT(t,i){let r=!1;const a=[];for(;i<t.length;){const u=t[i];if(r){if(u[0]==="enter")u[1].type==="tableContent"&&a.push(t[i+1][1].type==="tableDelimiterMarker"?"left":"none");else if(u[1].type==="tableContent"){if(t[i-1][1].type==="tableDelimiterMarker"){const d=a.length-1;a[d]=a[d]==="left"?"center":"right"}}else if(u[1].type==="tableDelimiterRow")break}else u[0]==="enter"&&u[1].type==="tableDelimiterRow"&&(r=!0);i+=1}return a}function pT(){return{flow:{null:{name:"table",tokenize:mT,resolveAll:gT}}}}function mT(t,i,r){const a=this;let u=0,d=0,c;return h;function h(T){let I=a.events.length-1;for(;I>-1;){const W=a.events[I][1].type;if(W==="lineEnding"||W==="linePrefix")I--;else break}const L=I>-1?a.events[I][1].type:null,F=L==="tableHead"||L==="tableRow"?N:p;return F===N&&a.parser.lazy[a.now().line]?r(T):F(T)}function p(T){return t.enter("tableHead"),t.enter("tableRow"),m(T)}function m(T){return T===124||(c=!0,d+=1),y(T)}function y(T){return T===null?r(T):Oe(T)?d>1?(d=0,a.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(T),t.exit("lineEnding"),x):r(T):rt(T)?dt(t,y,"whitespace")(T):(d+=1,c&&(c=!1,u+=1),T===124?(t.enter("tableCellDivider"),t.consume(T),t.exit("tableCellDivider"),c=!0,y):(t.enter("data"),b(T)))}function b(T){return T===null||T===124||_t(T)?(t.exit("data"),y(T)):(t.consume(T),T===92?v:b)}function v(T){return T===92||T===124?(t.consume(T),b):b(T)}function x(T){return a.interrupt=!1,a.parser.lazy[a.now().line]?r(T):(t.enter("tableDelimiterRow"),c=!1,rt(T)?dt(t,j,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):j(T))}function j(T){return T===45||T===58?C(T):T===124?(c=!0,t.enter("tableCellDivider"),t.consume(T),t.exit("tableCellDivider"),R):ae(T)}function R(T){return rt(T)?dt(t,C,"whitespace")(T):C(T)}function C(T){return T===58?(d+=1,c=!0,t.enter("tableDelimiterMarker"),t.consume(T),t.exit("tableDelimiterMarker"),A):T===45?(d+=1,A(T)):T===null||Oe(T)?q(T):ae(T)}function A(T){return T===45?(t.enter("tableDelimiterFiller"),_(T)):ae(T)}function _(T){return T===45?(t.consume(T),_):T===58?(c=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(T),t.exit("tableDelimiterMarker"),D):(t.exit("tableDelimiterFiller"),D(T))}function D(T){return rt(T)?dt(t,q,"whitespace")(T):q(T)}function q(T){return T===124?j(T):T===null||Oe(T)?!c||u!==d?ae(T):(t.exit("tableDelimiterRow"),t.exit("tableHead"),i(T)):ae(T)}function ae(T){return r(T)}function N(T){return t.enter("tableRow"),U(T)}function U(T){return T===124?(t.enter("tableCellDivider"),t.consume(T),t.exit("tableCellDivider"),U):T===null||Oe(T)?(t.exit("tableRow"),i(T)):rt(T)?dt(t,U,"whitespace")(T):(t.enter("data"),X(T))}function X(T){return T===null||T===124||_t(T)?(t.exit("data"),U(T)):(t.consume(T),T===92?H:X)}function H(T){return T===92||T===124?(t.consume(T),X):X(T)}}function gT(t,i){let r=-1,a=!0,u=0,d=[0,0,0,0],c=[0,0,0,0],h=!1,p=0,m,y,b;const v=new dT;for(;++r<t.length;){const x=t[r],j=x[1];x[0]==="enter"?j.type==="tableHead"?(h=!1,p!==0&&(Eb(v,i,p,m,y),y=void 0,p=0),m={type:"table",start:Object.assign({},j.start),end:Object.assign({},j.end)},v.add(r,0,[["enter",m,i]])):j.type==="tableRow"||j.type==="tableDelimiterRow"?(a=!0,b=void 0,d=[0,0,0,0],c=[0,r+1,0,0],h&&(h=!1,y={type:"tableBody",start:Object.assign({},j.start),end:Object.assign({},j.end)},v.add(r,0,[["enter",y,i]])),u=j.type==="tableDelimiterRow"?2:y?3:1):u&&(j.type==="data"||j.type==="tableDelimiterMarker"||j.type==="tableDelimiterFiller")?(a=!1,c[2]===0&&(d[1]!==0&&(c[0]=c[1],b=so(v,i,d,u,void 0,b),d=[0,0,0,0]),c[2]=r)):j.type==="tableCellDivider"&&(a?a=!1:(d[1]!==0&&(c[0]=c[1],b=so(v,i,d,u,void 0,b)),d=c,c=[d[1],r,0,0])):j.type==="tableHead"?(h=!0,p=r):j.type==="tableRow"||j.type==="tableDelimiterRow"?(p=r,d[1]!==0?(c[0]=c[1],b=so(v,i,d,u,r,b)):c[1]!==0&&(b=so(v,i,c,u,r,b)),u=0):u&&(j.type==="data"||j.type==="tableDelimiterMarker"||j.type==="tableDelimiterFiller")&&(c[3]=r)}for(p!==0&&Eb(v,i,p,m,y),v.consume(i.events),r=-1;++r<i.events.length;){const x=i.events[r];x[0]==="enter"&&x[1].type==="table"&&(x[1]._align=hT(i.events,r))}return t}function so(t,i,r,a,u,d){const c=a===1?"tableHeader":a===2?"tableDelimiter":"tableData",h="tableContent";r[0]!==0&&(d.end=Object.assign({},yl(i.events,r[0])),t.add(r[0],0,[["exit",d,i]]));const p=yl(i.events,r[1]);if(d={type:c,start:Object.assign({},p),end:Object.assign({},p)},t.add(r[1],0,[["enter",d,i]]),r[2]!==0){const m=yl(i.events,r[2]),y=yl(i.events,r[3]),b={type:h,start:Object.assign({},m),end:Object.assign({},y)};if(t.add(r[2],0,[["enter",b,i]]),a!==2){const v=i.events[r[2]],x=i.events[r[3]];if(v[1].end=Object.assign({},x[1].end),v[1].type="chunkText",v[1].contentType="text",r[3]>r[2]+1){const j=r[2]+1,R=r[3]-r[2]-1;t.add(j,R,[])}}t.add(r[3]+1,0,[["exit",b,i]])}return u!==void 0&&(d.end=Object.assign({},yl(i.events,u)),t.add(u,0,[["exit",d,i]]),d=void 0),d}function Eb(t,i,r,a,u){const d=[],c=yl(i.events,r);u&&(u.end=Object.assign({},c),d.push(["exit",u,i])),a.end=Object.assign({},c),d.push(["exit",a,i]),t.add(r+1,0,d)}function yl(t,i){const r=t[i],a=r[0]==="enter"?"start":"end";return r[1][a]}const yT={name:"tasklistCheck",tokenize:vT};function bT(){return{text:{91:yT}}}function vT(t,i,r){const a=this;return u;function u(p){return a.previous!==null||!a._gfmTasklistFirstContentOfListItem?r(p):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(p),t.exit("taskListCheckMarker"),d)}function d(p){return _t(p)?(t.enter("taskListCheckValueUnchecked"),t.consume(p),t.exit("taskListCheckValueUnchecked"),c):p===88||p===120?(t.enter("taskListCheckValueChecked"),t.consume(p),t.exit("taskListCheckValueChecked"),c):r(p)}function c(p){return p===93?(t.enter("taskListCheckMarker"),t.consume(p),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),h):r(p)}function h(p){return Oe(p)?i(p):rt(p)?t.check({tokenize:xT},i,r)(p):r(p)}}function xT(t,i,r){return dt(t,a,"whitespace");function a(u){return u===null?r(u):i(u)}}function wT(t){return xv([Y2(),nT(),cT(t),pT(),bT()])}const ST={};function jT(t){const i=this,r=t||ST,a=i.data(),u=a.micromarkExtensions||(a.micromarkExtensions=[]),d=a.fromMarkdownExtensions||(a.fromMarkdownExtensions=[]),c=a.toMarkdownExtensions||(a.toMarkdownExtensions=[]);u.push(wT(r)),d.push(G2()),c.push(V2(r))}function uf(t){const i=t.trim();if(!(!i||/[\u0000-\u0020\u007f]/.test(i)))try{const r=new URL(i);if(r.protocol==="https:"||r.protocol==="http:"||r.protocol==="mailto:")return i}catch{}}function cf(t){return!!t&&!/[\u0000-\u001f\u007f]/.test(t)&&!/^[a-z][a-z\d+.-]*:/i.test(t)&&!t.startsWith("//")}function Nb(t){if(!cf(t))return;const i=t.split(/[?#]/,1)[0];if(i)try{const r=decodeURIComponent(i);return cf(r)?r:void 0}catch{return}}async function kT(t){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(t);return}const i=document.activeElement,r=document.createElement("textarea");r.value=t,r.setAttribute("aria-label","复制内容"),r.style.cssText="position:fixed;left:-10000px;top:0",document.body.append(r);try{if(r.select(),!document.execCommand("copy"))throw new Error("复制不可用")}finally{r.remove(),i instanceof HTMLElement&&i.focus({preventScroll:!0})}}function _o({text:t,label:i="复制"}){const[r,a]=S.useState("idle"),u=S.useRef(!0),d=S.useRef(void 0);S.useEffect(()=>(u.current=!0,()=>{u.current=!1,clearTimeout(d.current)}),[]);const c=async()=>{clearTimeout(d.current);try{await kT(t),u.current&&a("copied")}catch{u.current&&a("error")}u.current&&(d.current=setTimeout(()=>a("idle"),2500))};return s.jsx("button",{className:"message-copy",onClick:()=>{c()},"aria-label":i,title:i,children:r==="copied"?"已复制":r==="error"?"复制失败":i})}function df(t){return typeof t=="string"||typeof t=="number"?String(t):Array.isArray(t)?t.map(df).join(""):S.isValidElement(t)?df(t.props.children):""}function CT({children:t}){const i=S.Children.toArray(t).find(d=>S.isValidElement(d)),a=(S.isValidElement(i)?i.props.className??"":"").match(/(?:^|\s)language-([\w+-]+)/)?.[1]??"代码",u=df(t).replace(/\n$/,"");return s.jsxs("div",{className:"message-code-block",children:[s.jsxs("div",{className:"message-code-heading",children:[s.jsx("span",{children:a}),s.jsx(_o,{text:u,label:"复制代码"})]}),s.jsx("pre",{tabIndex:0,children:t})]})}function ET(t){return{a:({href:i,children:r,title:a})=>{const u=uf(i??"");if(u)return s.jsx("a",{href:u,title:a,target:"_blank",rel:"noopener noreferrer",referrerPolicy:"no-referrer",children:r});const d=i?Nb(i):void 0;return d?s.jsxs("span",{className:"message-file-reference",title:d,children:[t?s.jsx("button",{className:"message-file-open",onClick:()=>t(d),children:r}):r,s.jsx(_o,{text:d,label:"复制路径"})]}):s.jsx("span",{children:r})},img:({src:i,alt:r})=>{const a=uf(typeof i=="string"?i:""),u=typeof i=="string"?Nb(i):void 0;return a?s.jsxs("a",{className:"message-image-reference",href:a,target:"_blank",rel:"noopener noreferrer",referrerPolicy:"no-referrer",children:[r||"图片",s.jsx("span",{children:"打开图片 ↗"})]}):u&&t?s.jsxs("button",{className:"message-image-reference",title:u,onClick:()=>t(u),children:[r||"图片",s.jsx("span",{children:"查看图片"})]}):s.jsxs("span",{className:"message-image-reference",children:[r||"图片",s.jsx("span",{children:"图片路径不可直接访问"})]})},pre:({children:i})=>s.jsx(CT,{children:i}),table:({children:i})=>s.jsx("div",{className:"message-table-scroll",role:"region","aria-label":"表格",tabIndex:0,children:s.jsx("table",{children:i})})}}const NT=S.memo(function({text:i,reasoning:r="",streaming:a=!1,onOpenFile:u}){const d=S.useMemo(()=>ET(u),[u]);return s.jsxs("div",{className:"message-content",children:[r?s.jsxs("details",{className:"message-reasoning",children:[s.jsx("summary",{children:a&&!i?"思考中…":"思考过程"}),s.jsx("pre",{children:r})]}):null,a?s.jsxs("div",{className:"message-streaming",children:[i||(r?"":"正在思考…"),s.jsx("span",{className:"cursor","aria-hidden":"true",children:"▍"})]}):i?s.jsx(cN,{remarkPlugins:[jT],skipHtml:!0,urlTransform:c=>uf(c)??(cf(c)?c:""),components:d,children:i}):null,!a&&i?s.jsx("div",{className:"message-actions",children:s.jsx(_o,{text:i,label:"复制回复"})}):null]})});function TT(t){const i=t.args??{},r=t.summary||[i.description,i.command,i.file_path,i.path,i.query,i.url].find(a=>typeof a=="string"&&a.trim());return typeof r=="string"?r.replace(/\s+/g," ").slice(0,180):""}const AT=S.memo(function({item:i,running:r}){const a=TT(i),u=i.done?i.error?"失败":"已完成":r?"执行中":"未完成";return s.jsxs("details",{className:`message-tool-card${i.error?" message-tool-error":""}`,children:[s.jsxs("summary",{children:[s.jsx("span",{className:"message-tool-indicator","aria-hidden":"true",children:i.done?i.error?"!":"✓":"·"}),s.jsx("span",{className:"message-tool-name",children:i.name}),s.jsx("span",{className:"message-tool-summary",children:a}),s.jsx("span",{className:"message-tool-status",children:u})]}),i.args&&Object.keys(i.args).length?s.jsxs("div",{className:"message-tool-section",children:[s.jsx("strong",{children:"参数"}),s.jsx("pre",{tabIndex:0,children:JSON.stringify(i.args,null,2)})]}):null,s.jsxs("div",{className:"message-tool-section",children:[s.jsxs("div",{className:"message-tool-result-heading",children:[s.jsx("strong",{children:"结果"}),i.result?s.jsx(_o,{text:i.result,label:"复制结果"}):null]}),s.jsx("pre",{tabIndex:0,children:i.result??(i.done?"工具没有返回文本内容。":r?"等待工具返回结果…":"这次工具调用没有保存结果。")})]})]})});function RT(t){return{running:"运行中",completed:"已完成",error:"失败",recorded:"历史记录"}[t]??t}function zT(t){const i=new URLSearchParams(t).get("session");return i&&/^[a-zA-Z0-9_-]{1,128}$/.test(i)?i:null}function cx(t,i){return!i||!t.hubEpoch||t.hubSequence===void 0?!0:t.hubEpoch===i.epoch&&t.hubSequence>i.sequence}function Tb(t,i=[]){let r=Jb(t.transcript);for(const u of t.liveStream?.events??[])r=wr(r,u.event);t.running?r={...r,run:"running"}:t.running===!1&&(r.run==="running"||r.run==="waiting")&&(r={...r,run:"idle"});let a=t.streamCursor;for(const u of i)cx(u,a)&&(r=wr(r,u.event),u.hubEpoch&&u.hubSequence!==void 0&&(a={epoch:u.hubEpoch,sequence:u.hubSequence}));return{chat:r,cursor:a,truncated:t.liveStream?.truncated??!1}}async function _T(t,i,r,a,u,d=()=>!0){let c=t.outputJournal??await i({});if(!d())throw new Error("Output recovery cancelled");if(c.status==="unavailable"){const x=u?await u():t.outputCoverage;if(!d())throw new Error("Output recovery cancelled");for(const j of[t.outputCoverage,x])ba({unpaired:j?.unpaired,inputIds:j?.inputIds},{},()=>!1);if(x?.outputCursor||a?.()||r.some(j=>j.event.outputCursor)){if(c=await i({}),c.status==="unavailable")throw new Error("Output recovery journal is unavailable")}else{if(x?.journalIdentity||t.outputCoverage?.journalIdentity)throw new Error("Output recovery journal is unavailable");return null}}if(c.status!=="ok"||!c.legacyBaseThroughEventId||t.transcript[0]?.type!=="session_meta")throw new Error("Output recovery has no complete legacy base");const h=t.transcript.findIndex(x=>x.id===c.legacyBaseThroughEventId);if(h<0)throw new Error("Output recovery legacy anchor was not retained");let p=Jb(t.transcript.slice(0,h+1)),m={incomplete:!1},y=0;const b=async()=>{for(;;){if(!d()||++y>2048)throw new Error("Output recovery exceeded its page budget");const x=aS(m,c,j=>{p=wr(p,j)});if(m.incomplete)throw new Error("Output recovery is incomplete");if(x)break;c=await i({after:m.cursor,through:m.through})}};await b();for(let x=0;x<8;x++){const j=u?await u():t.outputCoverage;if(!d())throw new Error("Output recovery cancelled");ba({...j,inputIds:void 0},c,()=>!0);let R;for(const A of[j?.outputCursor,a?.(),...r.map(_=>_.event.outputCursor)]){if(typeof A!="string")continue;const _=R?ka(A,R):1;if(_===void 0)throw new Error("Output recovery journal changed");_>0&&(R=A)}if(typeof R!="string"){j&&ba(j,c,A=>p.items.some(_=>_.kind==="user"&&_.clientMessageId===A));break}const C=ka(R,m.cursor);if(C===void 0)throw new Error("Output recovery journal changed");if(C<=0){j&&ba(j,c,A=>p.items.some(_=>_.kind==="user"&&_.clientMessageId===A));break}if(x===7)throw new Error("Output recovery could not catch up within its round budget");m={incomplete:!1,cursor:m.appliedCursor},c=await i({after:m.cursor,through:R}),await b()}const v=new kf;for(const x of r)v.observe(x.event);ba({unpaired:v.incomplete,inputIds:v.inputIds},c,x=>p.items.some(j=>j.kind==="user"&&j.clientMessageId===x),{requireIdentity:!1});for(const x of r){const j=x.event.outputCursor;if(typeof j=="string"){const R=ka(j,m.cursor);if(R===void 0)throw new Error("Output recovery journal changed");if(R<=0)continue;m.cursor=j}else if(x.event.type==="session_title"){p=wr(p,x.event);continue}else{if(x.event.type==="session_user_message"&&typeof x.event.clientMessageId=="string"&&p.items.some(R=>R.kind==="user"&&R.clientMessageId===x.event.clientMessageId))continue;throw new Error("Output recovery received an unpaired legacy event")}p=wr(p,x.event)}return{chat:p,outputCursor:m.cursor}}function dx(t,i){if(t?.title)return t.title;const r=t?.items.find(a=>a.kind==="user");if(r&&r.kind==="user"&&r.text.trim()){const a=r.text.trim().split(`
57
- `)[0];return a.length>32?`${a.slice(0,32)}…`:a}return r?.kind==="user"&&r.attachments?.length?`附件:${r.attachments[0].name}`:i.slice(0,8)}const DT=["profile","security","sessions","connections"],MT=["users","summary","audit"];function Ab(t){if(t.pathname==="/api/v1/account/manage"||t.pathname==="/settings/account")return{kind:"account",section:"profile"};const i=/^\/settings\/account\/([^/]+)\/?$/.exec(t.pathname);if(i&&DT.includes(i[1]))return{kind:"account",section:i[1]};const r=/^\/admin\/([^/]+)\/?$/.exec(t.pathname);return r&&MT.includes(r[1])?{kind:"admin",section:r[1]}:{kind:"workbench"}}function OT(t,i){const r=new URLSearchParams,a=i.searchParams.get("project"),u=i.searchParams.get("session");xl(a)&&(r.set("project",a),u&&/^[A-Za-z0-9_-]{1,128}$/.test(u)&&r.set("session",u));const d=ho(i);return d.view!=="chat"&&r.set("view",d.view),d.view==="settings"&&d.section!=="overview"&&r.set("section",d.section),(t.kind==="workbench"?"/":t.kind==="account"?`/settings/account/${t.section}`:`/admin/${t.section}`)+(r.size?`?${r}`:"")}function ho(t){const i=t.searchParams.get("view"),r=t.searchParams.get("section");return{view:["history","files","links","panels","settings"].includes(i??"")?i:"chat",section:["models","skills","mcp"].includes(r??"")?r:"overview"}}function LT(t,i){if(i.workspaceKey!==t.workspaceKey||i.sessionId!==t.activeId)throw new Error("当前工作区或对话已经变化,请重新打开面板后发送。");if(t.connection!=="open"||t.loading)throw new Error("工作台尚未连接,请连接后重新发送面板任务。");if(t.readOnly)throw new Error("当前对话为只读,无法发送面板任务。");if(t.running||t.chat.run==="running"||t.chat.run==="waiting"||t.approvals.some(r=>!r.sessionId||r.sessionId===i.sessionId))throw new Error("当前对话仍在处理任务,请完成后再发送面板任务。");if(t.uncertain||t.uploading||t.uploadBusy)throw new Error("当前消息或附件仍在发送,请等待结果后重试。");if(t.draft.length>0||t.files.length>0)throw new Error("当前对话还有草稿或附件,请先处理它们,再发送面板任务。");if(!i.prompt.trim()||i.prompt.length>2e4)throw new Error("面板任务内容无效。");if(t.setDraft(i.prompt),!t.send())throw t.setDraft(""),new Error("当前对话暂时无法接收任务,请稍后重新发送。");return{accepted:!0}}function BT({controller:t,onBackToProjects:i,projectName:r,cloudAccount:a,renderAccountControl:u}){const{connection:d,sessions:c,activeId:h,chat:p,draft:m,files:y,uploading:b,workerNote:v,replayNote:x,error:j,workspaceCwd:R,workspaceName:C,configuration:A,configurationVersion:_,sessionsVersion:D,localDrafts:q,running:ae,title:N,approvalCount:U,onAuthLost:X,refreshSessions:H,refreshConfiguration:T,session:I}=t,L=t.workspaceApi,F=t.host==="desktop"?"桌面":"服务端",[W,ee]=S.useState(!1),V=S.useRef(null),B=S.useRef(null),[Q,fe]=S.useState(()=>ho(new URL(window.location.href)).view),[k,O]=S.useState(),[re,E]=S.useState(),[J,be]=S.useState(0),[Z,ne]=S.useState(!1),[ge,P]=S.useState(null),[ve,De]=S.useState(()=>ho(new URL(window.location.href)).section);S.useEffect(()=>{const K=new URL(window.location.href);Q==="chat"?K.searchParams.delete("view"):K.searchParams.set("view",Q==="panel"?"panels":Q),Q==="settings"&&ve!=="overview"?K.searchParams.set("section",ve):K.searchParams.delete("section"),window.history.replaceState(window.history.state,"",K.pathname+K.search+K.hash)},[Q,ve]),S.useEffect(()=>{const K=()=>{const Se=ho(new URL(window.location.href));fe(Se.view),De(Se.section)};return window.addEventListener("popstate",K),()=>window.removeEventListener("popstate",K)},[]);const[ze,_e]=S.useState(()=>window.matchMedia("(max-width: 760px)").matches),[Ge,ft]=S.useState(()=>!window.matchMedia("(max-width: 760px)").matches),xt=S.useRef(null),Ke=S.useRef(null),Tt=S.useRef(!1),Be=S.useRef(null),At=S.useRef(null),Je=S.useRef(!0);S.useEffect(()=>{O(void 0),fe(K=>K==="panel"?"panels":K)},[t.workspaceKey]),S.useEffect(()=>{ze&&!Ge&&Tt.current&&!W&&Ke.current?.focus(),Tt.current=Ge},[ze,Ge,W]),S.useEffect(()=>{const K=window.matchMedia("(max-width: 760px)"),Se=()=>{_e(K.matches),ft(!K.matches)};return K.addEventListener("change",Se),()=>K.removeEventListener("change",Se)},[]),S.useEffect(()=>{if(!ze||!Ge)return;const K=xt.current;K?.querySelector("button")?.focus();const Se=je=>{if(!document.querySelector("dialog[open]")){if(je.key==="Escape"&&!je.isComposing)je.preventDefault(),ft(!1),Ke.current?.focus();else if(je.key==="Tab"){const Ne=Array.from(K?.querySelectorAll('button:not(:disabled), select:not(:disabled), input:not(:disabled), textarea:not(:disabled), a[href], summary, [tabindex]:not([tabindex="-1"])')??[]).filter(Te=>Te.getClientRects().length>0),ue=Ne?.[0],ke=Ne?.[Ne.length-1];je.shiftKey&&document.activeElement===ue?(je.preventDefault(),ke?.focus()):!je.shiftKey&&document.activeElement===ke&&(je.preventDefault(),ue?.focus())}}};return document.addEventListener("keydown",Se),()=>document.removeEventListener("keydown",Se)},[ze,Ge]),S.useLayoutEffect(()=>{const K=At.current;!K||Q!=="chat"||(K.style.height="auto",K.style.height=`${Math.min(180,Math.max(64,K.scrollHeight))}px`)},[m,Q]),S.useLayoutEffect(()=>{const K=Be.current;K&&Je.current&&Q==="chat"&&(K.scrollTop=K.scrollHeight)},[p.items,t.approvals.length,Q]);const Fe=()=>{ze&&(ft(!1),Ke.current?.focus())},Lt=K=>{if(Q==="settings"&&ve===K){Fe();return}Ie(()=>{De(K),fe("settings"),Fe()})},Ie=K=>{Z?P(()=>K):K()},pt=K=>Ie(()=>{E(K),be(Se=>Se+1),fe("files"),Fe()}),M=S.useRef(pt);M.current=pt;const ie=S.useCallback(K=>M.current(K),[]);S.useEffect(()=>{if(!Z&&!t.uploadBusy&&!t.hasUnsent)return;const K=Se=>{Se.preventDefault(),Se.returnValue=""};return window.addEventListener("beforeunload",K),()=>window.removeEventListener("beforeunload",K)},[Z,t.uploadBusy,t.hasUnsent]);const ye=K=>Ie(()=>{fe("chat"),Fe(),Je.current=!0,K()}),xe=K=>ye(()=>{t.selectSession(K)}),Ce=()=>ye(t.newSession),Ae=()=>{Je.current=!0,t.send()},Pe=t.stop,wt=t.approvals.filter(K=>!K.sessionId||K.sessionId===h),ct=t.approvals.filter(K=>K.sessionId&&K.sessionId!==h),mt=p.items.length===0&&wt.length===0,lt=A?.connections.find(K=>K.id===A.defaults.text),Pt=d==="open"?"已连接":d==="connecting"?"连接中":"正在重连",bt=Q==="chat"?N:Q==="files"?"工作区文件":Q==="history"?"历史对话":Q==="links"?"Link":Q==="panels"||Q==="panel"?k&&Q==="panel"?k.panel.title["zh-CN"]||k.panel.title.default:"面板":ve==="skills"?"Skills":"设置";return s.jsxs("div",{className:`shell${Ge?" sidebar-open":""}`,children:[ze&&Ge?s.jsx("div",{className:"sidebar-backdrop",onClick:()=>{ft(!1),Ke.current?.focus()},"aria-hidden":"true"}):null,s.jsxs("aside",{id:"workbench-sidebar",ref:xt,className:"rail",hidden:!Ge,role:ze?"dialog":void 0,"aria-modal":ze&&Ge?!0:void 0,"aria-label":"工作台导航",children:[s.jsxs("div",{className:"rail-head",children:[s.jsx("span",{className:"brand-mark",children:s.jsx(Ut,{name:"brand"})}),s.jsx("strong",{children:"CodeShell"}),s.jsx("span",{className:"hub-badge",children:a?"Cloud":t.host==="desktop"?"Desktop":L?"Hub":"Web"}),s.jsx("button",{className:"icon-button sidebar-close","aria-label":"收起侧栏",onClick:()=>{ft(!1),Ke.current?.focus()},children:s.jsx(Ut,{name:"sidebar"})})]}),s.jsx(xf,{discover:t.workspaceApi,navigate:K=>{const Se=()=>window.location.assign(K);Z||t.hasUnsent||t.uploadBusy?P(()=>Se):Se()}}),s.jsxs("nav",{className:"workbench-nav","aria-label":"主要功能",children:[i?s.jsxs("button",{className:"nav-button",title:r,onClick:()=>{Z||t.hasUnsent||t.uploadBusy?P(()=>i):i()},children:[s.jsx(Ut,{name:"folder"}),s.jsx("span",{children:"返回项目列表"})]}):null,s.jsxs("button",{className:"nav-button new-chat-button",onClick:Ce,children:[s.jsx(Ut,{name:"plus"}),s.jsx("span",{children:"新对话"})]}),s.jsxs("button",{className:`nav-button${Q==="chat"?" active":""}`,onClick:()=>{Ie(()=>{fe("chat"),Fe()})},"aria-current":Q==="chat"?"page":void 0,children:[s.jsx(Ut,{name:"chat"}),s.jsx("span",{children:"对话"})]}),L?s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:`nav-button${Q==="history"?" active":""}`,onClick:()=>Ie(()=>{fe("history"),Fe()}),"aria-current":Q==="history"?"page":void 0,children:[s.jsx(Ut,{name:"history"}),s.jsx("span",{children:"历史对话"})]}),s.jsxs("button",{className:`nav-button${Q==="files"?" active":""}`,onClick:()=>pt(),"aria-current":Q==="files"?"page":void 0,children:[s.jsx(Ut,{name:"folder"}),s.jsx("span",{children:"文件"})]}),s.jsxs("button",{className:`nav-button${Q==="settings"&&ve==="skills"?" active":""}`,onClick:()=>Lt("skills"),"aria-current":Q==="settings"&&ve==="skills"?"page":void 0,children:[s.jsx(Ut,{name:"skills"}),s.jsx("span",{children:"Skills"})]}),s.jsxs("button",{className:`nav-button${Q==="panels"||Q==="panel"?" active":""}`,onClick:()=>Ie(()=>{fe("panels"),Fe()}),"aria-current":Q==="panels"||Q==="panel"?"page":void 0,children:[s.jsx(Ut,{name:"panels"}),s.jsx("span",{children:"面板"})]}),s.jsxs("button",{className:`nav-button${Q==="links"?" active":""}`,onClick:()=>Ie(()=>{fe("links"),Fe()}),"aria-current":Q==="links"?"page":void 0,children:[s.jsx(Ut,{name:"links"}),s.jsx("span",{children:"Link"})]}),s.jsxs("button",{className:`nav-button${Q==="settings"&&ve!=="skills"?" active":""}`,onClick:()=>Lt("overview"),"aria-current":Q==="settings"&&ve!=="skills"?"page":void 0,children:[s.jsx(Ut,{name:"settings"}),s.jsx("span",{children:"设置"})]})]}):null]}),s.jsx("div",{className:"rail-section-label",children:"工作区"}),L?s.jsxs("button",{className:"workspace-button",title:R??void 0,onClick:()=>pt(),children:[s.jsx(Ut,{name:"folder"}),s.jsx("span",{children:r??C}),s.jsx(Ut,{name:"chevron"})]}):s.jsxs("div",{className:"workspace-button",title:R??void 0,children:[s.jsx(Ut,{name:"folder"}),s.jsx("span",{children:r??C})]}),s.jsxs("div",{className:"rail-section-label history-label",children:[s.jsx("span",{children:"最近对话"}),s.jsx("span",{children:c.length})]}),t.renderSidebar?.({guard:Ie,conversation:ye}),s.jsxs("ul",{className:"sessions","aria-label":"最近对话",children:[q.map(({sessionId:K,draft:Se})=>s.jsx("li",{children:s.jsxs("button",{className:K===h&&Q==="chat"?"session active":"session",onClick:()=>{xe(K)},children:[s.jsx("span",{className:"session-title",children:Se.text.trim()||`附件:${Se.files[0]?.name??"新对话"}`}),s.jsx("span",{className:"session-meta",children:"草稿"})]})},`draft-${K}`)),c.map(K=>s.jsx("li",{children:s.jsxs("button",{className:K.sessionId===h&&Q==="chat"?"session active":"session",onClick:()=>{xe(K.sessionId)},"aria-current":K.sessionId===h&&Q==="chat"?"page":void 0,children:[s.jsx("span",{className:"session-title",children:K.sessionId===h?K.customTitle||p.title||K.title||dx(p,K.sessionId):K.title||K.preview?.trim()||K.sessionId.slice(0,8)}),s.jsxs("span",{className:"session-meta",children:[t.unreadSessionIds?.has(K.sessionId)&&K.sessionId!==h?s.jsxs("span",{className:"session-unread","aria-label":"有新消息",children:["●"," "]}):null,U(K.sessionId)?`${U(K.sessionId)} 项待审批`:K.running?"进行中":IT(K.status),t.showTurnCounts!==!1?s.jsxs("span",{children:[" · ",K.turnCount," 轮"]}):null]})]})},K.sessionId)),c.length===0&&q.length===0?s.jsx("li",{className:"empty",children:"开始对话后,记录会保存在这里。"}):null]}),s.jsxs("div",{className:"rail-footer",children:[s.jsxs("div",{className:"host-label",children:[s.jsx("span",{className:`dot ${d}`}),s.jsxs("span",{children:[F,Pt]})]}),u?u({guard:Ie,conversation:ye}):a?s.jsx(Pb,{...a}):null,t.host==="hub"&&!a?s.jsxs("button",{className:"account-button",onClick:()=>{Fe(),ee(!0)},children:[s.jsx("span",{className:"account-avatar",children:(I?.username||"C").slice(0,1).toUpperCase()}),s.jsxs("span",{className:"account-copy",children:[s.jsx("strong",{children:I?.username||"账号"}),s.jsx("span",{children:"设备与退出"})]}),s.jsx(Ut,{name:"chevron"})]}):null,t.logout?s.jsxs("button",{className:"account-button",onClick:t.logout,children:[s.jsx("span",{className:"account-avatar",children:(t.accountName||"D").slice(0,1)}),s.jsxs("span",{className:"account-copy",children:[s.jsx("strong",{children:t.accountName||"已配对设备"}),s.jsx("span",{children:"退出此设备"})]})]}):null]})]}),s.jsxs("main",{className:"workbench-main",inert:ze&&Ge?!0:void 0,children:[s.jsxs("header",{className:"workbench-topbar",children:[s.jsx("button",{ref:Ke,className:"icon-button","aria-label":Ge?"收起侧栏":"展开侧栏","aria-expanded":Ge,"aria-controls":"workbench-sidebar",onClick:()=>ft(K=>!K),children:s.jsx(Ut,{name:"sidebar"})}),s.jsxs("div",{className:"topbar-context",children:[s.jsx("span",{className:"topbar-project","aria-label":"当前项目",title:r??C,children:r??C}),s.jsx("span",{className:"topbar-title",title:bt,children:bt})]}),s.jsxs("span",{className:"connection-pill",title:`任务在${F}工作区执行`,children:[s.jsx("span",{className:`dot ${d}`}),s.jsx("span",{children:F})]})]}),v?s.jsx("div",{className:"banner",children:v}):null,x?s.jsx("div",{className:"banner",children:x}):null,j?s.jsxs("div",{className:"banner form-error",role:"alert",children:[j,s.jsx("button",{className:"ghost","aria-label":"关闭错误提示",onClick:t.clearError,children:"×"})]}):null,ct.length?s.jsxs("div",{className:"banner",children:["其他会话有待处理审批。",ct.map(K=>s.jsxs("button",{className:"ghost",onClick:()=>{xe(K.sessionId)},children:["打开 ",K.sessionId.slice(0,8)]},K.id))]}):null,d!=="open"?s.jsxs("div",{className:"banner",children:["连接",d==="connecting"?"中…":"已断开,重连中…"]}):null,Q!=="chat"&&wt.length>0?s.jsxs("div",{className:"banner",children:["当前对话需要你的确认。",s.jsx("button",{className:"ghost",onClick:()=>Ie(()=>fe("chat")),children:"返回对话"})]}):null,s.jsxs("section",{className:`chat${mt?" chat-empty":""}`,hidden:Q!=="chat","aria-label":"对话",children:[s.jsx("div",{className:"messages",ref:Be,onScroll:K=>{const Se=K.currentTarget;Je.current=Se.scrollHeight-Se.scrollTop-Se.clientHeight<100},children:s.jsxs("div",{className:"transcript",children:[t.chatControls,t.loading?s.jsx("div",{className:"banner",role:"status",children:"正在恢复会话记录…"}):null,p.goal?s.jsxs("div",{className:"banner goal",children:[s.jsx("span",{children:p.goal}),t.goalActions]}):null,p.items.map(K=>{switch(K.kind){case"user":return s.jsxs("div",{className:"msg user",children:[K.text,K.attachments?.map((Se,je)=>L&&Se.path?s.jsxs("button",{className:"attachment attachment-open",onClick:()=>pt(Se.path),children:["📎 ",Se.name]},je):s.jsxs("span",{className:"attachment",children:["📎 ",Se.name]},je))]},K.id);case"assistant":return K.done&&!K.text&&!K.reasoning?null:s.jsx("div",{className:"msg assistant",children:s.jsx(NT,{text:K.text,reasoning:K.reasoning,streaming:!K.done,onOpenFile:L?ie:void 0})},K.id);case"tool":return s.jsx("div",{className:`msg tool${K.error?" tool-error":""}`,children:s.jsx(AT,{item:K,running:ae})},K.id);case"subagent":return s.jsxs("div",{className:"msg info",children:["↳ ",K.label," · ",RT(K.status)]},K.id);case"system":return s.jsx("div",{className:"msg info",children:K.text},K.id);case"system_error":return s.jsx("div",{className:"msg error",children:K.text},K.id);default:return null}}),t.approvalContent,mt?s.jsxs("div",{className:"empty-chat",children:[s.jsx("span",{className:"welcome-mark",children:s.jsx(Ut,{name:"brand"})}),s.jsx("h1",{children:"今天想完成什么?"}),s.jsx("p",{children:"从一个问题或想法开始,让 CodeShell 帮你一步步完成。"}),s.jsxs("span",{className:"welcome-workspace",children:[s.jsx(Ut,{name:"folder"}),r??C]})]}):null]})}),t.readOnlyNote?s.jsx("div",{className:"banner",children:t.readOnlyNote}):null,s.jsxs("div",{className:"composer-wrap",children:[s.jsxs("footer",{className:"composer",children:[y.length||b&&t.host==="hub"?s.jsxs("div",{className:"attachments","aria-live":"polite",children:[y.map(K=>s.jsxs("span",{className:"attachment",children:[s.jsx(Ut,{name:"attachment"}),K.name,s.jsx("button",{className:"ghost","aria-label":`移除 ${K.name}`,onClick:()=>{t.removeFile(K.id)},children:"×"})]},K.id)),b&&t.host==="hub"?s.jsx("span",{children:"正在上传…"}):null]}):null,s.jsx("textarea",{ref:At,"aria-label":"任务内容",value:m,disabled:t.readOnly,rows:2,placeholder:"描述你的任务,或提出一个问题…",onChange:K=>{t.setDraft(K.target.value)},onKeyDown:K=>{K.key==="Enter"&&!K.shiftKey&&!K.nativeEvent.isComposing&&(K.preventDefault(),Ae())}}),s.jsxs("div",{className:"composer-toolbar",children:[L?s.jsxs(s.Fragment,{children:[s.jsx("input",{hidden:!0,multiple:!0,type:"file",accept:t.attachmentAccept,ref:V,onChange:K=>{const Se=K.currentTarget;Promise.resolve(t.addFiles(Se.files)).finally(()=>{Se.value=""})}}),s.jsx("button",{className:"icon-button attach-button","aria-label":"添加附件",title:"添加附件",disabled:t.uploadBusy||d!=="open"||t.readOnly,onClick:()=>V.current?.click(),children:s.jsx(Ut,{name:"plus"})}),t.cameraAttachments?s.jsxs(s.Fragment,{children:[s.jsx("input",{hidden:!0,type:"file",accept:"image/*",capture:"environment",ref:B,onChange:K=>{const Se=K.currentTarget;Promise.resolve(t.addFiles(Se.files)).finally(()=>{Se.value=""})}}),s.jsx("button",{className:"icon-button attach-button","aria-label":"拍照",title:"拍照",disabled:t.uploadBusy||d!=="open"||t.readOnly,onClick:()=>B.current?.click(),children:s.jsx(Ut,{name:"camera"})})]}):null,s.jsxs("button",{className:"model-button",title:"打开模型设置",onClick:()=>Lt("models"),children:[s.jsx("span",{children:lt?.model||"配置模型"}),s.jsx(Ut,{name:"chevron"})]})]}):null,s.jsx("span",{className:"composer-run-status",role:"status",children:t.uncertain?"正在核对消息…":b?t.host==="desktop"?"正在发送…":"正在上传附件…":wt.length?"等待你的确认":ae?"正在处理…":""}),ae?s.jsx("button",{className:"stop composer-submit","aria-label":"停止",title:"停止",onClick:Pe,disabled:d!=="open",children:s.jsx(Ut,{name:"stop"})}):s.jsx("button",{className:"send composer-submit","aria-label":"发送",title:"发送",onClick:Ae,disabled:d!=="open"||b||t.uncertain||t.readOnly||!m.trim()&&!y.length,children:s.jsx(Ut,{name:"send"})})]})]}),s.jsxs("div",{className:"composer-caption",children:[s.jsxs("span",{children:["任务在",F,"工作区执行"]}),s.jsx("span",{children:"Enter 发送 · Shift + Enter 换行"})]})]})]}),Q==="settings"&&L?s.jsx(Lw,{host:t.host==="desktop"?"desktop":"hub",section:ve,onSectionChange:Lt,onAuthLost:X,onConfigurationChange:()=>{T()},configurationVersion:_,onDirtyChange:ne},`${t.workspaceKey}:settings`):null,Q==="files"&&L?s.jsx(Vw,{initialPath:re,openVersion:J,onAuthLost:X},`${t.workspaceKey}:files`):null,Q==="history"&&L?s.jsx($w,{onAuthLost:X,onOpen:K=>{xe(K)},onChanged:()=>{H()},version:D,onDirtyChange:ne},`${t.workspaceKey}:history`):null,Q==="links"&&L?s.jsx(US,{onAuthLost:X,onDirtyChange:ne,hostLabel:F,configurationVersion:_},`${t.workspaceKey}:links`):null,Q==="panels"&&L?s.jsx(IS,{onAuthLost:X,onDirtyChange:ne,onChanged:()=>{T()},hostLabel:F,configurationVersion:_,onOpen:K=>Ie(()=>{O({panel:K,workspaceKey:t.workspaceKey}),fe("panel"),Fe()})},`${t.workspaceKey}:panels`):null,Q==="panel"&&L&&k?.workspaceKey===t.workspaceKey?s.jsx(JS,{panel:k.panel,sessionId:h,busy:ae||b||t.uncertain,onAuthLost:X,onDirtyChange:ne,onClose:()=>Ie(()=>fe("panels")),onSubmitPrompt:async K=>LT(t,{...K,workspaceKey:k.workspaceKey})},`${t.workspaceKey}:panel:${k.panel.id}:${h}`):null]}),ge?s.jsx(UT,{onStay:()=>P(null),onLeave:()=>{const K=ge;P(null),ne(!1),K()}}):null,W&&t.host==="hub"&&!a?s.jsx(nw,{session:I,onClose:()=>ee(!1),onAuthLost:X}):null]})}function UT({onStay:t,onLeave:i}){const r=S.useRef(null);return S.useEffect(()=>{const a=document.activeElement;return r.current?.showModal(),()=>{r.current?.close(),a?.focus()}},[]),s.jsxs("dialog",{className:"navigation-prompt",ref:r,"aria-labelledby":"navigation-prompt-title",onCancel:a=>{a.preventDefault(),t()},children:[s.jsx("h2",{id:"navigation-prompt-title",children:"还有未保存的修改"}),s.jsx("p",{children:"离开会丢弃未提交的修改;切换项目还会清除未发送的草稿和附件。已经提交的操作可能仍会完成,请等待结果后再离开。"}),s.jsxs("div",{className:"library-actions",children:[s.jsx("button",{className:"library-button primary",onClick:t,autoFocus:!0,children:"留在此页"}),s.jsx("button",{className:"library-button",onClick:i,children:"放弃修改并离开"})]})]})}function IT(t){switch(t){case"running":return"进行中";case"waiting":case"waiting_approval":return"等待确认";case"completed":return"已完成";case"cancelled":case"canceled":return"已停止";case"failed":case"error":return"发生错误";case"idle":return"可继续";default:return"对话"}}function Ut({name:t}){const i={panels:s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),s.jsx("path",{d:"M15 3v18M15 10h6"})]}),camera:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M3 7h4l2-3h6l2 3h4v13H3Z"}),s.jsx("circle",{cx:"12",cy:"13",r:"4"})]}),links:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7 0l3-3a5 5 0 0 0-7-7l-2 2"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7 0l-3 3a5 5 0 0 0 7 7l2-2"})]}),brand:s.jsx(s.Fragment,{children:s.jsx("path",{d:"m5 7 5 5-5 5M13 17h6"})}),sidebar:s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),s.jsx("path",{d:"M9 4v16"})]}),plus:s.jsx("path",{d:"M12 5v14M5 12h14"}),chat:s.jsx("path",{d:"M21 11.5a8.4 8.4 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.4 8.4 0 0 1-3.8-.9L3 21l1.9-5.7a8.4 8.4 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.4 8.4 0 0 1 3.8-.9h.5a8.5 8.5 0 0 1 8 8v.5Z"}),history:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),s.jsx("path",{d:"M3 3v5h5M12 7v5l3 2"})]}),skills:s.jsx(s.Fragment,{children:s.jsx("path",{d:"m12 3 2.7 5.5L21 9.4l-4.5 4.4 1.1 6.2L12 17.1 6.4 20l1.1-6.2L3 9.4l6.3-.9L12 3Z"})}),settings:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"m9 3-.7 3-2.6 1-2.6 2 1.4 3-1.4 3 2.6 2 2.6 1 .7 3h6l.7-3 2.6-1 2.6-2-1.4-3 1.4-3-2.6-2-2.6-1L15 3H9Z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),folder:s.jsx("path",{d:"M3 7V5a1 1 0 0 1 1-1h5l2 3h9a1 1 0 0 1 1 1v11a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V7Z"}),chevron:s.jsx("path",{d:"m9 5 7 7-7 7"}),attachment:s.jsx("path",{d:"m21 11-8 8a6 6 0 0 1-8.5-8.5l9-9A4 4 0 0 1 19 7l-9 9a2 2 0 0 1-2.8-2.8l8-8"}),send:s.jsx("path",{d:"M12 19V5m-6 6 6-6 6 6"}),stop:s.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2",fill:"currentColor",stroke:"none"})};return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i[t]})}class ii extends Error{constructor(i,r,a){super(i),this.kind=r,this.code=a,this.name="ProtocolRequestError"}kind;code}const qT=3e4,Rb=800,HT=15e3;class GT{constructor(i){this.url=i}url;ws=null;nextId=1;pending=new Map;notificationHandlers=new Set;stateHandlers=new Set;reconnectDelay=Rb;closedByUser=!1;reconnectTimer;authHandlers=new Set;resyncHandlers=new Set;health;healthProbeId;generation=0;resumeRequested=!1;removePageListeners;connect(){this.ws||(clearTimeout(this.reconnectTimer),this.closedByUser=!1,this.installPageListeners(),this.openSocket())}openSocket(){if(this.closedByUser)return;this.reconnectTimer=void 0,this.emitState("connecting");const i=new WebSocket(this.url);this.ws=i,this.generation++;const r=new cS(()=>{this.healthProbeId=`web-health-${this.nextId++}`,i.send(JSON.stringify({jsonrpc:"2.0",id:this.healthProbeId,method:"agent/query",params:{type:"sessions"}}))},()=>this.retire(i),to());this.health=r,this.healthProbeId=void 0,this.resumeRequested=!1,i.onopen=()=>{this.ws!==i||this.closedByUser||(r.connected(),this.resumeRequested=!1,this.reconnectDelay=Rb,this.emitState("open"))},i.onmessage=a=>{if(this.ws!==i||this.closedByUser)return;let u;try{if(u=JSON.parse(String(a.data)),!u||typeof u!="object"||Array.isArray(u))return}catch{return}if(u.id===this.healthProbeId&&u.method===void 0&&(Object.hasOwn(u,"result")||Object.hasOwn(u,"error"))&&(this.healthProbeId=void 0,r.received()&&this.resumeRequested)){this.resumeRequested=!1;for(const c of this.resyncHandlers)c()}if(u.id!==void 0&&u.method===void 0){const d=this.pending.get(String(u.id));if(!d)return;this.pending.delete(String(u.id)),clearTimeout(d.timer),u.error?d.reject(new ii(u.error.message??"request failed","response",u.error.code)):d.resolve(u.result);return}if(u.method)for(const d of this.notificationHandlers)d(u.method,u.params??{})},i.onclose=a=>{if(this.ws===i){if(a.code===4401||a.code===4403){this.closedByUser=!0;for(const u of this.authHandlers)u();this.removePageListeners?.(),this.removePageListeners=void 0}this.retire(i)}},i.onerror=()=>{}}close(){this.closedByUser=!0,this.generation++,clearTimeout(this.reconnectTimer),this.reconnectTimer=void 0,this.health?.stop(),this.health=void 0,this.healthProbeId=void 0,this.resumeRequested=!1,this.removePageListeners?.(),this.removePageListeners=void 0;const i=this.ws;this.ws=null,i&&(i.onopen=i.onmessage=i.onclose=i.onerror=null),i?.close(),this.failAllPending(new ii("connection closed","transport"))}onNotification(i){return this.notificationHandlers.add(i),()=>this.notificationHandlers.delete(i)}onStateChange(i){return this.stateHandlers.add(i),()=>this.stateHandlers.delete(i)}onAuthLost(i){return this.authHandlers.add(i),()=>this.authHandlers.delete(i)}onResync(i){return this.resyncHandlers.add(i),()=>this.resyncHandlers.delete(i)}get connectionGeneration(){return this.generation}reconnect(){!this.closedByUser&&this.ws&&this.retire(this.ws)}approvalSnapshot(){return this.request("serve/approval.snapshot",{})}retire(i){if(this.ws===i){this.generation++,this.ws=null,this.health?.stop(),this.health=void 0,this.healthProbeId=void 0,this.resumeRequested=!1,i.onopen=i.onmessage=i.onclose=i.onerror=null,this.emitState("closed"),this.failAllPending(new ii("connection closed","transport"));try{i.close()}catch{}!this.closedByUser&&!to()&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>this.openSocket(),this.reconnectDelay),this.reconnectDelay=Math.min(this.reconnectDelay*2,HT))}}installPageListeners(){if(this.removePageListeners||typeof window>"u")return;const i=()=>{this.closedByUser||to()||(this.ws?(this.resumeRequested=!0,this.health?.resume()):(clearTimeout(this.reconnectTimer),this.openSocket()))},r=()=>{to()?(this.health?.pause(),this.healthProbeId=void 0,this.resumeRequested=!1,clearTimeout(this.reconnectTimer)):i()};window.addEventListener("online",i),window.addEventListener("focus",i),window.addEventListener("pageshow",i),typeof document<"u"&&document.addEventListener("visibilitychange",r),this.removePageListeners=()=>{window.removeEventListener("online",i),window.removeEventListener("focus",i),window.removeEventListener("pageshow",i),typeof document<"u"&&document.removeEventListener("visibilitychange",r)}}request(i,r,a=qT){const u=this.ws;if(!u||u.readyState!==WebSocket.OPEN)return Promise.reject(new ii("not connected","not-sent"));const d=`web-${this.nextId++}`;return new Promise((c,h)=>{const p=a>0?setTimeout(()=>{this.pending.delete(d),h(new ii(`request timed out: ${i}`,"timeout"))},a):void 0;this.pending.set(d,{resolve:c,reject:h,timer:p});try{u.send(JSON.stringify({jsonrpc:"2.0",id:d,method:i,params:r}))}catch(m){clearTimeout(p),this.pending.delete(d),h(new ii(m instanceof Error?m.message:"send failed","not-sent"))}})}run(i){return this.request("agent/run",i,0)}listSessions(){return this.request("agent/query",{type:"sessions"})}sessionDetail(i,r=!1){return this.request("agent/query",{type:"session_detail",sessionId:i,...r?{outputRecovery:!0}:{}})}outputCoverage(i){return this.request("agent/query",{type:"output_coverage",sessionId:i})}outputJournal(i,r={}){return this.request("agent/query",{type:"output_journal",sessionId:i,...r})}approve(i,r,a){return this.request("agent/approve",{sessionId:i.sessionId??"",...i.connectionId?{connectionId:i.connectionId}:{},...i.generation!==void 0?{generation:i.generation}:{},requestId:i.requestId,decision:r?{approved:!0,...a?{answer:a}:{}}:{approved:!1}})}cancel(i){return this.request("agent/cancel",{sessionId:i})}emitState(i){for(const r of this.stateHandlers)r(i)}failAllPending(i){for(const[,r]of this.pending)clearTimeout(r.timer),r.reject(i);this.pending.clear()}}function VT(){return`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}${kt("/ws")}`}function $T(t,i){const{method:r,params:a}=i;if(r==="serve/approvalSnapshot"){if(!Array.isArray(a.approvals))return t;const d={};for(const c of a.approvals)c?.requestId&&c.request&&(d[c.requestId]={payload:c});return d}if(r==="agent/approvalRequest"){const d=a;return!d.requestId||!d.request?t:{...t,[d.requestId]:{...t[d.requestId],payload:d}}}const u=a.requestId;if(typeof u!="string"||!t[u])return t;if(r==="agent/approvalResolved"){const d={...t};return delete d[u],d}return r==="serve/approvalLease"?{...t,[u]:{...t[u],lease:a}}:t}class PT{drafts=new Map;get(i){return this.drafts.get(i)??{text:"",files:[],revision:0}}update(i,r){const a={...r,revision:this.get(i).revision+1};return this.drafts.set(i,a),a}setText(i,r){return this.update(i,{...this.get(i),text:r})}addFile(i,r){const a=this.get(i);return this.update(i,{...a,files:[...a.files,r]})}removeFile(i,r){const a=this.get(i);return this.update(i,{...a,files:a.files.filter(u=>u.id!==r)})}take(i){const r=this.get(i),a=this.update(i,{text:"",files:[]});return{sessionId:i,draft:r,clearedRevision:a.revision}}restore(i){const r=this.get(i.sessionId);return r.revision!==i.clearedRevision||r.text||r.files.length?!1:(this.update(i.sessionId,i.draft),!0)}unsent(){return[...this.drafts].flatMap(([i,r])=>r.text.trim()||r.files.length?[{sessionId:i,draft:r}]:[])}}function YT({payload:t,onDecide:i,busy:r,connected:a}){const[u,d]=S.useState(""),c=t.request.toolName==="__ask_user__",{summary:h,risk:p}=iS(t.request.args,t.request.riskLevel,t.request.toolName);return s.jsxs("div",{className:"approval",children:[s.jsxs("div",{className:"approval-title",children:[c?"Agent 提问":`工具审批:${t.request.toolName}`,c?null:s.jsxs("em",{children:[" · ",p]})]}),t.request.description?s.jsx("div",{className:"approval-desc",children:t.request.description}):null,c?null:s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"approval-summary",children:h}),s.jsxs("details",{className:"approval-raw",children:[s.jsx("summary",{children:"原始参数"}),s.jsx("pre",{className:"approval-args",children:JSON.stringify(t.request.args,null,2)})]})]}),c?s.jsx("textarea",{className:"approval-answer",value:u,placeholder:"输入回答…",onChange:m=>d(m.target.value)}):null,r?s.jsx("span",{className:"muted",role:"status",children:"设备正在处理此审批…"}):null,s.jsxs("div",{className:"approval-actions",children:[s.jsx("button",{className:"send",disabled:r||!a||c&&!u.trim(),onClick:()=>i(t,!0,c?u:void 0),children:c?"回答":"允许"}),s.jsx("button",{className:"stop",disabled:r||!a,onClick:()=>i(t,!1),children:"拒绝"})]})]})}function zb(){return Da()}const FT=()=>{},QT=async()=>{};function XT({session:t,hub:i=!1,onAuthLost:r=FT,onCheckAuth:a=QT}){const u=S.useRef(null),[d,c]=S.useState("connecting"),[h,p]=S.useState([]),m=S.useRef([]),[y,b]=S.useState(()=>zT(window.location.search)??zb()),[v,x]=S.useState(co()),[j,R]=S.useReducer($T,{}),[C,A]=S.useState({}),[_,D]=S.useState(""),[q,ae]=S.useState([]),N=S.useRef(new PT),[U,X]=S.useState(0),[H,T]=S.useState(null),I=H===y,[L,F]=S.useState(null),[W,ee]=S.useState(null),[V,B]=S.useState(""),[Q,fe]=S.useState(Date.now()),[k,O]=S.useState(0),[re,E]=S.useState(null),[J,be]=S.useState(0),Z=S.useRef(0),ne=S.useRef(y),ge=S.useRef(null),P=S.useRef(null),ve=S.useRef(!1),De=S.useRef(new Map),ze=S.useRef(new Map),_e=S.useRef(new Set),Ge=S.useRef(new Set),ft=S.useRef(new Set),xt=S.useRef(0),Ke=S.useRef(!1),Tt=S.useRef(null),Be=S.useRef(null),At=S.useCallback(ue=>{if(X(Te=>Te+1),ne.current!==ue)return;const ke=N.current.get(ue);D(ke.text),ae(ke.files)},[]);S.useEffect(()=>{const ue=new URL(window.location.href);ue.searchParams.set("session",y),window.history.replaceState(window.history.state,"",ue)},[y]);const Je=S.useCallback((ue,ke)=>{const Te=N.current.restore(ue.draft);At(ue.draft.sessionId),ne.current===ue.draft.sessionId&&(x(G=>({...G,run:"error",items:G.items.filter(ce=>ce.kind!=="user"||ce.clientMessageId!==ue.clientMessageId)})),Te&&B(`${ke?`${ke} `:"消息未送达。"}内容和附件已恢复,可以重试。`))},[At]),Fe=S.useCallback(ue=>{Ke.current&&(ue instanceof Ze&&ue.status===401?r():B(ue instanceof Error?ue.message:"操作失败,请重试。"))},[r]),Lt=S.useCallback(async()=>{if(!i||!Ke.current)return;const ue=++Z.current;try{const ke=await Yb();Ke.current&&ue===Z.current&&E(ke)}catch(ke){Ke.current&&ke instanceof Ze&&ke.status===401&&r()}},[i,r]),Ie=S.useCallback(async()=>{const ue=u.current;if(ue)try{const ke=i?(await Xd()).sessions:(await ue.listSessions()).data;if(u.current===ue&&Ke.current){const Te=[...ke].sort((G,ce)=>(ce.lastActiveAt??ce.startedAt)-(G.lastActiveAt??G.startedAt));m.current=Te,p(Te)}}catch(ke){Fe(ke)}},[Fe,i]),pt=S.useCallback(async()=>{const ue=u.current;if(ue)for(const[ke,Te]of ze.current)try{const G=await ue.sessionDetail(ke);if(!Ke.current||ue!==u.current||ze.current.get(ke)!==Te)continue;Tb(G.data).chat.items.some(He=>He.kind==="user"&&He.clientMessageId===Te.clientMessageId)?ze.current.delete(ke):G.data.running||(ze.current.delete(ke),Je(Te))}catch(G){if(!Ke.current||ue!==u.current||ze.current.get(ke)!==Te)continue;G instanceof ii&&G.kind==="response"&&G.code===-32001&&G.message===`Session not found: ${ke}`&&(ze.current.delete(ke),Je(Te))}},[Je]),M=S.useCallback(async ue=>{const ke=u.current;if(!ke)return;const Te={sessionId:ue,events:[],bytes:0};Be.current=Te;try{const G=await ke.sessionDetail(ue,!0);if(!Ke.current||Be.current!==Te||ne.current!==ue)return;let ce=Te.running??G.data.running;ce?Ge.current.add(ue):ce===!1&&Ge.current.delete(ue);const qe=Tb(G.data,Te.events);let He=qe.chat,Yt=!1,Qe=!1;try{const ot=await _T(G.data,async tt=>(await ke.outputJournal(ue,tt)).data,Te.events,()=>Te.latestOutputCursor,G.data.outputCoverage?async()=>(await ke.outputCoverage(ue)).data:void 0,()=>Ke.current&&Be.current===Te&&ne.current===ue);ot?(He=ot.chat,P.current=ot.outputCursor,Yt=!0):P.current=null}catch(ot){P.current=null,Qe=!(!G.data.outputJournal&&ot instanceof ii&&ot.kind==="response"&&ot.code===-32602&&ot.message==="Unknown query type: output_journal")}if(!Ke.current||Be.current!==Te||ne.current!==ue)return;ce=Te.running??G.data.running,ve.current=Qe,Qe||(ge.current=qe.cursor??null),ee(Qe?"部分运行记录无法验证,已保留当前可见内容。请修复会话记录后重试。":!Yt&&(qe.truncated||Te.overflow)?"这次运行的实时记录较长,已恢复已保存的内容;结束后重新打开可查看完整记录。":null),ce||_e.current.has(ue)?He.run="running":ce===!1&&(He.run==="running"||He.run==="waiting")&&(He.run="idle"),x(ot=>Qe?ot:He)}catch(G){ne.current===ue&&Fe(G)}finally{Be.current===Te&&(Be.current=null)}},[Fe]);S.useEffect(()=>{Ke.current=!0;const ue=new GT(VT());u.current=ue;const ke=ue.onAuthLost(r);let Te;const G=()=>{if(!i||Te)return;const Qe=ue.connectionGeneration,ot=xt.current,tt=()=>Ke.current&&u.current===ue&&ue.connectionGeneration===Qe,ht=ue.approvalSnapshot().then(We=>{if(!(!tt()||xt.current!==ot)){if(!We||!Array.isArray(We.approvals)||We.approvals.length>256||!Array.isArray(We.leases)||We.leases.length>256)throw new Error("审批恢复快照无效,请重试。");xt.current++,R({method:"serve/approvalSnapshot",params:{approvals:We.approvals}});for(const ai of We.leases)R({method:"serve/approvalLease",params:{...ai}})}}).catch(We=>{tt()&&(We instanceof ii&&We.kind==="response"&&We.code===-32601?ue.reconnect():Fe(We))}).finally(()=>{Te===ht&&(Te=void 0)});Te=ht},ce=()=>{F(null),B(""),Ie().then(()=>{const Qe=ne.current;Ke.current&&u.current===ue&&(m.current.some(ot=>ot.sessionId===Qe)||Ge.current.has(Qe)||_e.current.has(Qe)||ze.current.has(Qe))&&M(Qe)}),Lt(),pt()},qe=ue.onResync(()=>{ce(),G()}),He=ue.onStateChange(Qe=>{c(Qe),Qe==="open"?ce():Qe==="closed"&&(i&&a(),x(ot=>({...ot,run:"idle"})))}),Yt=ue.onNotification((Qe,ot)=>{if(Qe==="serve/sessionsChanged"){Ie(),O(tt=>tt+1);return}if(Qe==="agent/runAccepted"&&typeof ot.sessionId=="string"){const tt=De.current.get(ot.sessionId);tt&&(tt.accepted=!0);return}if(Qe==="serve/configurationChanged"){Lt(),be(tt=>tt+1);return}if(Qe==="agent/streamEvent"){const tt=ot,{sessionId:ht,event:We}=tt,ai=De.current.get(ht);if(ai&&["stream_request_start","text_delta","thinking_delta","tool_use_start"].includes(String(We.type))&&(ai.accepted=!0),ht===ne.current){if(Be.current?.sessionId===ht){const Gt=Be.current;typeof We.outputCursor=="string"&&(Gt.latestOutputCursor=We.outputCursor);const hn=new TextEncoder().encode(JSON.stringify(tt)).length;for(Gt.events.push(tt),Gt.bytes+=hn;Gt.events.length>2048||Gt.bytes>8*1024*1024;){const Dt=Gt.events.shift();Dt&&(Gt.bytes-=new TextEncoder().encode(JSON.stringify(Dt)).length),Gt.overflow=!0}}if(ve.current&&We.type!=="session_title")return;if(typeof We.outputCursor=="string"&&P.current){const Gt=ka(We.outputCursor,P.current);if(Gt===void 0){M(ht);return}if(Gt<=0)return;P.current=We.outputCursor}if(!cx(tt,ge.current))return;tt.hubEpoch&&tt.hubSequence!==void 0&&(ge.current={epoch:tt.hubEpoch,sequence:tt.hubSequence}),x(Gt=>wr(Gt,We))}We.type==="stream_request_start"&&F(null),We.type==="turn_complete"&&Ie();return}if(Qe==="serve/sessionStatus"){O(We=>We+1);const{sessionId:tt,running:ht}=ot;if(typeof tt!="string"||typeof ht!="boolean")return;Be.current?.sessionId===tt&&(Be.current.running=ht),ht?Ge.current.add(tt):Ge.current.delete(tt),!ht&&ze.current.has(tt)&&pt(),tt===ne.current&&x(We=>ht?{...We,run:"running"}:We.run==="running"||We.run==="waiting"?{...We,run:"idle"}:We),Ie();return}if(Qe==="agent/approvalRequest"||Qe==="agent/approvalResolved"||Qe==="serve/approvalSnapshot"||Qe==="serve/approvalLease"){xt.current++,R({method:Qe,params:ot});return}if(Qe==="serve/workerExit"){Ge.current.clear();const tt=ot.clean;F(tt?"服务进程已退出,发送消息会自动重启":"服务进程异常退出,发送消息会自动重启"),x(ht=>({...ht,run:"idle"}))}});return ue.connect(),()=>{Ke.current=!1,Tt.current?.abort(),He(),qe(),Yt(),ke(),ue.close(),u.current=null}},[Ie,M,Lt,pt,r,a,i,Fe]);const ie=Object.values(j).some(ue=>ue.lease?.holderId&&(ue.lease.expiresAt??0)>Q);S.useEffect(()=>{if(!ie)return;fe(Date.now());const ue=setInterval(()=>fe(Date.now()),1e3);return()=>clearInterval(ue)},[ie]);const ye=async ue=>{ne.current=ue,ge.current=null,P.current=null,ve.current=!1,b(ue),At(ue),x(co()),B(""),ee(null),!(!h.some(ke=>ke.sessionId===ue)&&!Ge.current.has(ue)&&N.current.unsent().some(ke=>ke.sessionId===ue))&&await M(ue)},xe=()=>{const ue=zb();ne.current=ue,ge.current=null,P.current=null,ve.current=!1,Be.current=null,b(ue),At(ue),x(co()),B(""),ee(null)},Ce=()=>{const ue=N.current.get(ne.current),ke=ue.text.trim(),Te=u.current;if(!ke&&!ue.files.length||!Te||d!=="open"||I)return!1;const G=ne.current;if(_e.current.has(G)||Ge.current.has(G)||v.run==="running"||v.run==="waiting"||Object.values(j).some(He=>He.payload.sessionId===G)||ze.current.has(G))return!1;ne.current=G,b(G),_e.current.add(G);const ce={clientMessageId:Da(),draft:N.current.take(G),accepted:!1};De.current.set(G,ce);const qe=ce.draft.draft.files;return At(G),B(""),x(He=>({...Xw(He,ke,qe.map(Yt=>({name:Yt.name,mime:Yt.mimeType,size:Yt.size})),ce.clientMessageId),run:"running"})),Te.run({sessionId:G,task:ke,clientMessageId:ce.clientMessageId,displayText:ke,...qe.length?{uploadIds:qe.map(He=>He.id)}:{}}).catch(He=>{Ke.current&&(Fe(He),He instanceof ii&&(He.kind==="transport"||He.kind==="timeout")?(ze.current.set(G,ce),B("连接中断,重新连接后会核对这条消息是否已经送达。")):ce.accepted||Je(ce,He instanceof Error?He.message==="upload not found or expired"?"附件已失效,请移除后重新上传。":He.message:void 0),ne.current===G&&x(Yt=>({...Yt,run:"error"})))}).finally(()=>{_e.current.delete(G),De.current.get(G)===ce&&De.current.delete(G),Ke.current&&ne.current===G&&!Ge.current.has(G)&&x(He=>He.run==="running"?{...He,run:"idle"}:He)}),!0},Ae=(ue,ke,Te)=>{const G=u.current;!G||d!=="open"||ft.current.has(ue.requestId)||(xt.current++,ft.current.add(ue.requestId),A(ce=>({...ce,[ue.requestId]:!0})),B(""),G.approve({...ue,sessionId:ue.sessionId??ne.current??""},ke,Te).then(()=>R({method:"agent/approvalResolved",params:{requestId:ue.requestId}})).catch(Fe).finally(()=>{ft.current.delete(ue.requestId),A(ce=>{const qe={...ce};return delete qe[ue.requestId],qe})}))},Pe=()=>{y&&u.current?.cancel(y).catch(Fe)},wt=async ue=>{if(!ue?.length||Tt.current)return;const ke=new AbortController,Te=mo();Tt.current=ke,T(ne.current),B("");const G=ne.current;try{for(const ce of Array.from(ue)){if(!Ke.current||ke.signal.aborted)break;const qe=await M1(ce,{signal:ke.signal,scope:Te});Ke.current&&!ke.signal.aborted&&(N.current.addFile(G,qe),At(G))}}catch(ce){Fe(ce)}finally{Tt.current===ke&&(Tt.current=null),Ke.current&&T(null)}},ct=Object.values(j).filter(ue=>!ue.payload.sessionId||ue.payload.sessionId===y),mt=ue=>Object.values(j).filter(ke=>ke.payload.sessionId===ue).length,lt=v.run==="running"||v.run==="waiting"||ct.length>0,Pt=S.useMemo(()=>N.current.unsent().filter(ue=>!h.some(ke=>ke.sessionId===ue.sessionId)),[U,h]),bt=re?.workspace.path??h.find(ue=>ue.sessionId===y)?.cwd??h[0]?.cwd??null,K=bt?.split(/[\\/]/).filter(Boolean).pop()??"服务端工作区",Se=v.items.length===0&&ct.length===0,je=h.find(ue=>ue.sessionId===y),Ne=Se?"新对话":je?.customTitle||v.title||je?.title||je?.preview?.trim()||dx(v,y??"新对话");return{host:i?"hub":"legacy",workspaceApi:i,connection:d,session:t,activeId:y,chat:v,sessions:h,workspaceCwd:bt,workspaceName:K,title:Ne,workspaceKey:bt??"hub",configuration:re,configurationVersion:J,sessionsVersion:k,draft:_,files:q,uploading:I,uploadBusy:H!==null,hasUnsent:N.current.unsent().length>0,localDrafts:Pt,uncertain:ze.current.has(y),running:lt,approvals:Object.values(j).map(ue=>({id:ue.payload.requestId,sessionId:ue.payload.sessionId})),approvalCount:mt,approvalContent:ct.map(ue=>s.jsx(YT,{payload:ue.payload,onDecide:Ae,busy:!!C[ue.payload.requestId]||!!(ue.lease?.holderId&&(ue.lease.expiresAt??0)>Q),connected:d==="open"},ue.payload.requestId)),workerNote:L,replayNote:W,error:V,clearError:()=>B(""),setDraft:ue=>{N.current.setText(ne.current,ue),At(ne.current)},removeFile:ue=>{N.current.removeFile(ne.current,ue),At(ne.current)},selectSession:ye,newSession:xe,send:Ce,stop:Pe,addFiles:wt,refreshSessions:Ie,refreshConfiguration:Lt,onAuthLost:r}}function ff({onBackToProjects:t,projectName:i,cloudAccount:r,renderAccountControl:a,...u}){return s.jsx(BT,{controller:XT(u),onBackToProjects:t,projectName:i,cloudAccount:r,renderAccountControl:a})}function hf(t){if(!t||typeof t!="object")return!1;const i=t;return xl(i.id)&&typeof i.name=="string"&&i.name.length>0&&["stopped","starting","running","stopping","error"].includes(i.status)&&Number.isSafeInteger(i.generation)&&i.generation>=0&&Number.isSafeInteger(i.createdAt)&&i.createdAt>=0&&(i.error===void 0||typeof i.error=="string")}function KT(t){const i=t;if(!i||i.runtime!=="docker"||typeof i.available!="boolean"||!Array.isArray(i.projects)||!i.projects.every(hf)||new Set(i.projects.map(r=>r.id)).size!==i.projects.length||i.error!==void 0&&typeof i.error!="string")throw new Error("服务端返回了无效的项目列表,请重试。");return i}function _b(){return new URL(window.location.href).searchParams.get("project")}function gl(t,i=!1){const r=new URL(window.location.href);t?r.searchParams.set("project",t):r.searchParams.delete("project"),i||r.searchParams.delete("session"),window.history.replaceState(window.history.state,"",r)}const ZT={stopped:"已停止",starting:"正在启动",running:"运行中",stopping:"正在停止",error:"启动失败"};function fx({children:t,onAuthLost:i,accountControl:r,allowLegacy:a=!0,autoEnterSingle:u=!1,startCreatedProject:d=!1,canRequest:c}){const[h,p]=S.useState(null),[m,y]=S.useState(!1),[b,v]=S.useState(null),[x,j]=S.useState(""),[R,C]=S.useState(!0),[A,_]=S.useState(null),[D,q]=S.useState(""),[ae,N]=S.useState(null),U=S.useRef(null),X=S.useRef(_b()),H=S.useRef(b),T=S.useRef(h),I=S.useRef(0),L=S.useRef(0),F=S.useRef(null),W=S.useRef(i),ee=S.useRef(!1),V=S.useRef(!0),B=S.useRef(c);B.current=c,W.current=i,H.current=b,T.current=h;const Q=S.useCallback(E=>{if(E.status!=="running")return;const J=_b()===E.id;Zs(),Ks(E.id),gl(E.id,J),X.current=null,V.current=!1,H.current=E,v(E),j("")},[]),fe=S.useCallback(()=>{X.current=null,H.current=null,v(null),Ks(null),Zs(),gl(null)},[]),k=S.useCallback(async E=>{if(ee.current||B.current&&!B.current())return;const J=++L.current,be=I.current;try{const Z=KT(await Ue("/api/v1/projects",{signal:E}));if(E?.aborted||J!==L.current||be!==I.current)return;p(Z),T.current=Z,C(!1),j("");const ne=H.current;if(ne){const P=Z.projects.find(ve=>ve.id===ne.id);(!P||P.status!=="running"||P.generation!==ne.generation)&&(fe(),j("项目运行状态已经变化,请重新打开项目。未发送的内容不会带入其他项目。"));return}if(!X.current){u&&V.current&&Z.available&&Z.projects.length===1&&Z.projects[0].status==="running"&&Q(Z.projects[0]);return}const ge=Z.projects.find(P=>P.id===X.current);ge?ge.status==="running"&&Z.available&&Q(ge):(V.current=!1,X.current=null,gl(null),j("链接中的项目不存在或当前账号无权访问,请选择一个项目。"))}catch(Z){if(E?.aborted||J!==L.current||be!==I.current)return;C(!1),a&&Z instanceof Ze&&Z.status===404&&!T.current?(Ks(null),Zs(),ee.current=!0,y(!0)):Z instanceof Ze&&Z.status===401?W.current():j(Z instanceof Error?Z.message:"无法读取项目,请重试。")}},[fe,Q,a,u]);S.useEffect(()=>{I.current++;const E=new AbortController;k(E.signal);const J=()=>{k(E.signal)},be=()=>{document.visibilityState==="visible"&&J()};return window.addEventListener("focus",J),document.addEventListener("visibilitychange",be),()=>{I.current++,E.abort(),F.current?.abort(),window.removeEventListener("focus",J),document.removeEventListener("visibilitychange",be),Ks(null),Zs()}},[k]);const O=h?.projects.some(E=>E.status==="starting"||E.status==="stopping");S.useEffect(()=>{if(m||!h)return;const E=new AbortController,J=setInterval(()=>{k(E.signal)},O?2e3:1e4);return()=>{clearInterval(J),E.abort()}},[m,!!h,O,k]),S.useEffect(()=>{if(!ae)return;const E=document.activeElement,J=U.current;return J?.showModal?.(),()=>{J?.close?.(),E?.focus()}},[ae]);const re=async(E,J)=>{if(B.current&&!B.current()||F.current||E==="create"&&!D.trim())return;const be=new AbortController;F.current=be,_(J?.id??"create"),j(""),L.current++;try{const Z=await Ue(E==="create"?"/api/v1/projects":`/api/v1/projects/${J.id}/${E}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(E==="create"?{name:D.trim()}:{}),signal:be.signal});if(be.signal.aborted)return;if(!hf(Z.project)||J&&J.id!==Z.project.id)throw new Error("服务端返回了无效的项目状态,请刷新列表。");let ne=Z.project;if(E==="create"&&d){const ge=await Ue(`/api/v1/projects/${ne.id}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}",signal:be.signal});if(be.signal.aborted)return;if(!hf(ge.project)||ge.project.id!==ne.id)throw new Error("服务端返回了无效的项目状态,请刷新列表。");ne=ge.project,X.current=ne.id,gl(ne.id),ne.status==="running"&&Q(ne)}p(ge=>ge&&{...ge,projects:ge.projects.some(P=>P.id===ne.id)?ge.projects.map(P=>P.id===ne.id?ne:P):[...ge.projects,ne]}),E==="create"&&q(""),E==="start"&&(X.current=ne.id,gl(ne.id),ne.status==="running"&&Q(ne)),E==="stop"&&(X.current===ne.id&&(X.current=null,gl(null)),N(null)),await k(be.signal)}catch(Z){if(be.signal.aborted)return;Z instanceof Ze&&Z.status===401?W.current():j(Z instanceof Error?Z.message:"项目操作失败,请重试。")}finally{F.current===be&&(F.current=null),be.signal.aborted||_(null)}};return m?s.jsx(S.Fragment,{children:t(null)},"single-project"):b?s.jsxs(S.Fragment,{children:[x?s.jsxs("div",{className:"project-connection-note",role:"status",children:["项目状态暂时无法刷新,当前工作台会保留。",x]}):null,t(b,fe)]},`${b.id}:${b.generation}`):s.jsxs("main",{className:"projects-page",children:[s.jsxs("header",{className:"projects-header",children:[s.jsxs("div",{className:"auth-brand",children:["CodeShell ",s.jsx("span",{children:r?"Cloud":"Hub"})]}),s.jsx(xf,{}),r,s.jsx("h1",{children:"你的项目"}),s.jsx("p",{children:"每个项目有独立的运行环境、文件、会话和配置。启动后进入同一个工作台。"})]}),R?s.jsx("p",{role:"status",children:"正在读取项目…"}):null,x?s.jsxs("div",{className:"form-error",role:"alert",children:[x,s.jsx("button",{className:"library-button",onClick:()=>{k()},children:"刷新项目"})]}):null,h?s.jsxs(s.Fragment,{children:[h.available?null:s.jsx("p",{className:"form-error",role:"alert",children:d?"云端执行环境暂时不可用,请稍后重试或联系管理员。":s.jsxs(s.Fragment,{children:["项目运行环境暂不可用。",h.error||"请检查服务端 Docker 是否已启动。"]})}),s.jsxs("form",{className:"project-create",onSubmit:E=>{E.preventDefault(),re("create")},children:[s.jsxs("label",{children:["新项目名称",s.jsx("input",{value:D,maxLength:80,required:!0,placeholder:"例如:个人网站",onChange:E=>q(E.target.value)})]}),s.jsx("button",{className:"library-button primary",disabled:!!A||!D.trim(),type:"submit",children:A==="create"?"正在创建…":d?"创建并打开":"创建项目"})]}),s.jsxs("section",{className:"projects-grid","aria-label":"项目列表",children:[h.projects.length===0?s.jsx("p",{className:"project-empty",children:"创建第一个项目,开始配置模型、添加技能和使用面板。"}):null,h.projects.map(E=>s.jsxs("article",{className:"project-card",children:[s.jsxs("div",{className:"project-card-heading",children:[s.jsx("h2",{children:E.name}),s.jsx("span",{className:`project-status ${E.status}`,children:ZT[E.status]})]}),s.jsxs("p",{className:"project-date",children:["创建于 ",new Date(E.createdAt).toLocaleDateString()]}),E.error?s.jsx("p",{className:"form-error",role:"alert",children:E.error}):null,s.jsxs("div",{className:"library-actions",children:[s.jsx("button",{className:"library-button primary",disabled:!!A||!h.available||E.status==="starting"||E.status==="stopping",onClick:()=>E.status==="running"?Q(E):void re("start",E),children:A===E.id||E.status==="starting"||E.status==="stopping"?"正在处理…":E.status==="running"?"打开项目":"启动并打开"}),E.status==="running"?s.jsx("button",{className:"library-button",disabled:!!A,onClick:()=>N(E),children:"停止项目"}):null]})]},E.id))]})]}):null,ae?s.jsxs("dialog",{className:"project-stop-confirm",ref:U,role:"alertdialog","aria-modal":"true","aria-labelledby":"project-stop-title",onCancel:E=>{E.preventDefault(),A||N(null)},children:[s.jsxs("h2",{id:"project-stop-title",children:["停止 ",ae.name,"?"]}),s.jsx("p",{children:"正在运行的任务和面板进程会中断。项目文件和配置保留,可稍后重新启动。"}),s.jsxs("div",{className:"library-actions",children:[s.jsx("button",{className:"library-button primary",disabled:!!A,onClick:()=>N(null),children:"继续运行"}),s.jsx("button",{className:"library-button",disabled:!!A,onClick:()=>{re("stop",ae)},children:"确认停止"})]})]}):null]})}function JT({setupToken:t}){const[i,r]=S.useState("checking"),[a,u]=S.useState(),[d,c]=S.useState(),[h,p]=S.useState(!1),[m,y]=S.useState(""),[b,v]=S.useState(""),[x,j]=S.useState(""),[R,C]=S.useState(t),[A,_]=S.useState(""),[D,q]=S.useState(!1),[ae,N]=S.useState(""),U=S.useRef(!1),X=S.useRef(!1),H=S.useRef(!1),T=S.useRef(0),I=S.useRef(i);I.current=i;const L=S.useCallback(B=>{H.current&&(X.current=B?.mode==="cloud-account",p(X.current),c(B?.cloudSession),u(B?.session),r(B===null?"legacy":B.mode==="cloud-account"?B.authenticated?"authenticated":"cloud-login":B.initialized?B.authenticated?"authenticated":"login":"setup"),q(!1),_(""),B?.initialized&&C(""))},[]),F=S.useCallback(()=>{H.current&&(T.current++,u(void 0),c(void 0),r(X.current?"cloud-login":"login"),v(""),_(X.current?"Cloud 管理登录已失效,请从桌面 Cloud 管理器重新打开。":"登录已过期或此设备已被撤销,请重新登录。"))},[]),W=S.useCallback(async()=>{if(U.current)return;const B=++T.current;try{const Q=await _1();if(B===T.current&&X.current&&Q?.mode!=="cloud-account"){F();return}B===T.current&&L(Q)}catch(Q){if(!H.current||B!==T.current)return;if(X.current&&(Q instanceof Ze&&Q.status===401||Q instanceof Ub)){F();return}if(I.current==="authenticated"||I.current==="legacy")return;r("error"),_(Q instanceof Error?Q.message:"无法连接服务端")}},[L,F]);S.useEffect(()=>{H.current=!0,W();const B=()=>{W()},Q=()=>{document.visibilityState==="visible"&&W()};return window.addEventListener("focus",B),document.addEventListener("visibilitychange",Q),()=>{H.current=!1,window.removeEventListener("focus",B),document.removeEventListener("visibilitychange",Q)}},[W]),S.useEffect(()=>{if(!d)return;const B=setTimeout(F,Math.max(0,d.expiresAt-Date.now()));return()=>clearTimeout(B)},[d,F]);const ee=async()=>{if(U.current||!X.current)return;U.current=!0;const B=++T.current;q(!0),N("");try{const Q=await Pd("/api/v1/auth/logout");if(!H.current||B!==T.current)return;if(Q.revoked!==!0)throw new Error("Cloud 退出尚未确认。");F(),_("此 Cloud 工作台已退出。请从桌面 Cloud 管理器重新打开。")}catch(Q){if(!H.current||B!==T.current)return;Q instanceof Ze&&Q.status===401?F():N("未能确认退出此 Cloud 工作台,请重试。也可关闭此页并在桌面撤销登录。")}finally{U.current=!1,H.current&&q(!1)}},V=async B=>{if(B.preventDefault(),D||X.current)return;const Q=++T.current;q(!0),_("");try{const fe=await Pd(`/api/v1/auth/${i==="setup"?"setup":"login"}`,{username:m.trim(),password:b,deviceName:x.trim()||void 0,...i==="setup"?{token:R.trim()}:{}});if(!H.current||Q!==T.current)return;if(!fe.authenticated)throw new Error("登录失败,请重试。");v(""),C(""),L({initialized:!0,authenticated:!0,session:fe.session})}catch(fe){if(!H.current||Q!==T.current)return;_(fe instanceof Error?fe.message:"登录失败,请重试。"),fe instanceof Ze&&fe.status===409&&W()}finally{H.current&&Q===T.current&&q(!1)}};if(i==="authenticated"){const B=h?{pending:D,error:ae,onLogout:()=>{ee()},accountOrigin:d?.accountOrigin}:void 0;return s.jsx(fx,{onAuthLost:F,allowLegacy:!h,accountControl:B?s.jsx(Pb,{...B}):void 0,children:(Q,fe)=>s.jsx(ff,{session:a,hub:!0,onAuthLost:F,onCheckAuth:W,projectName:Q?.name,onBackToProjects:fe,cloudAccount:B})},d?`${d.audience}:${d.installationId}:${d.managementEpoch}:${d.accountOrigin}:${d.accountId}:${d.id}`:a?.id)}return i==="legacy"?s.jsx(ff,{session:a,hub:!1,onAuthLost:F,onCheckAuth:W}):s.jsx("main",{className:"auth-page",children:s.jsxs("section",{className:"auth-card",children:[s.jsx(xf,{discover:!1}),s.jsxs("div",{className:"auth-brand",children:["CodeShell ",s.jsx("span",{children:h?"Cloud":"Hub"})]}),i==="checking"?s.jsx("p",{role:"status",children:"正在连接你的工作空间…"}):null,i==="error"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"form-error",role:"alert",children:A}),s.jsx("button",{className:"send",onClick:()=>{W()},children:"重试连接"})]}):null,i==="cloud-login"?s.jsxs(s.Fragment,{children:[s.jsx("h1",{children:"请从桌面 Cloud 管理器登录"}),s.jsx("p",{children:"在 CodeShell 桌面端登录云账号,再从 Cloud 管理器打开这个工作台。"}),A?s.jsx("p",{role:"status",children:A}):null,s.jsx("button",{className:"send",onClick:()=>{W()},children:"重新检查 Cloud 登录"})]}):null,i==="setup"||i==="login"?s.jsxs("form",{onSubmit:B=>{V(B)},children:[s.jsx("h1",{children:i==="setup"?"创建管理员账号":"登录工作空间"}),s.jsx("p",{children:i==="setup"?"首次启动需要服务端提供的初始化令牌。创建后,可在其他设备使用此账号登录。":"连接服务端,继续你的会话与任务。"}),i==="setup"?s.jsxs("label",{children:["初始化令牌",s.jsx("input",{type:"password",autoComplete:"off",required:!0,value:R,onChange:B=>C(B.target.value)})]}):null,s.jsxs("label",{children:["用户名",s.jsx("input",{autoComplete:"username",required:!0,maxLength:64,value:m,onChange:B=>y(B.target.value)})]}),s.jsxs("label",{children:["密码",s.jsx("input",{type:"password",autoComplete:i==="setup"?"new-password":"current-password",required:!0,maxLength:256,minLength:i==="setup"?12:void 0,value:b,onChange:B=>v(B.target.value)})]}),i==="setup"?s.jsx("small",{children:"密码至少 12 个字符。"}):null,s.jsxs("label",{children:["设备名称 ",s.jsx("span",{children:"(可选)"}),s.jsx("input",{autoComplete:"off",maxLength:100,placeholder:"例如:我的笔记本",value:x,onChange:B=>j(B.target.value)})]}),A?s.jsx("p",{className:"form-error",role:"alert",children:A}):null,s.jsx("button",{className:"send",type:"submit",disabled:D,children:D?"正在连接…":i==="setup"?"创建并进入":"登录"})]}):null]})})}async function vl(t){const i=globalThis.navigator?.locks;if(!i?.request)throw new Error("浏览器不支持安全的登录会话管理,请使用新版 Chrome、Edge、Firefox 或 Safari。");return await i.request("codeshell:account-web:cookie-v1",{mode:"exclusive"},t)}const $d="/api/v1/account/web",za=/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/,po=/^[A-Za-z0-9_-]{43}$/,Db={invalid_credentials:"用户名或密码不正确。",invalid_username:"用户名须为 3–64 位字母、数字、点、下划线或连字符。",username_unavailable:"这个用户名已被使用,请换一个。",invalid_display_name:"昵称须为 1–64 个字符,且不能包含控制字符。",invalid_password:"密码须为 12–1024 个字符。",incorrect_password:"当前密码不正确,请重新输入。",password_changed:"密码已在其他页面修改,请使用最新密码重试。",password_not_configured:"此账号尚未设置密码,请继续使用 GitHub 登录。",registration_disabled:"当前服务未开放注册,请使用已有账号登录。",authentication_required:"登录已过期,请重新登录。",invalid_session:"登录已过期,请重新登录。",invalid_web_session:"登录已过期,请重新登录。",csrf_required:"页面验证已过期,请刷新后重试。",invalid_csrf:"页面验证已过期,请刷新后重试。",github_login_failed:"GitHub 登录未完成,请重新发起登录。",github_login_denied:"GitHub 授权未完成,请重新发起。",invalid_github_receipt:"GitHub 授权请求已失效,请重新发起。",provider_already_linked:"这个 GitHub 身份已关联到其他账号,或当前账号已有不同的 GitHub 身份。",account_login_required:"登录已失效,请重新登录后关联 GitHub。",administrator_required:"当前账号没有管理员权限。",protected_administrator:"不能停用当前账号或其他管理员。",too_many_attempts:"操作过于频繁,请稍后再试。",too_many_account_sessions:"登录会话已达上限,请先退出其他设备。",account_not_found:"账号已不存在,请刷新列表。",session_not_found:"此登录会话已结束,请刷新列表。",link_management_disabled:"当前服务尚未开放数据连接管理。",link_management_unavailable:"数据连接服务暂时不可用,请稍后重试。",cloud_management_disabled:"当前服务尚未配置云端工作区。"};class et extends Error{constructor(i,r=0,a){super(i),this.status=r,this.code=a}status;code}function oo(t,i,r){const a=t,u=typeof a?.error=="string"?a.error:void 0;if(r==="/github/poll"&&u==="github_login_failed"){if(a?.reason==="provider_timeout")return new et("服务器连接 GitHub 超时,请重新发起授权。",i,u);if(a?.reason==="provider_unavailable")return new et("服务器暂时无法访问 GitHub,请稍后重新发起授权。",i,u)}return new et(u&&Object.hasOwn(Db,u)?Db[u]:"操作未完成,请稍后重试。",i,u)}function pf(t){if(typeof t!="string")return!1;try{const i=new URL(t);return i.origin===t&&!i.username&&!i.password&&(i.protocol==="https:"||i.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(i.hostname))}catch{return!1}}function $f(t){const i=t;return!!i&&za.test(i.id)&&typeof i.username=="string"&&/^[a-z0-9][a-z0-9._-]{2,63}$/i.test(i.username)&&typeof i.displayName=="string"&&[...i.displayName].length>=1&&[...i.displayName].length<=64&&!/[\p{Cc}\p{Cs}]/u.test(i.displayName)&&["member","admin"].includes(i.role)}function Pf(t){const i=t;return!!i&&pf(i.cloudOrigin)&&pf(i.accountOrigin)&&za.test(i.installationId)}function ni(t){const i=t,r=i&&{...i,cloudTarget:i.cloudTarget?.enabled===!1?null:i.cloudTarget};if(!r||i.accessToken!==void 0||i.refreshToken!==void 0||typeof r.authenticated!="boolean"||(r.authenticated||r.refreshRequired)&&!po.test(r.csrfToken??"")||!r.authenticated&&typeof r.refreshRequired!="boolean"||r.cloudTarget!==null&&!Pf(r.cloudTarget)||r.authenticated&&(!$f(r.account)||!r.session||!za.test(r.session.id)||!Number.isSafeInteger(r.session.expiresAt)||r.session.expiresAt<=Date.now())||!r.authenticated&&(r.account!==void 0||r.session!==void 0))throw new et("账号服务返回了无效的会话,请刷新后重试。");const a=r.authenticated?hx(r.overview,r.account.id):void 0;if(a&&a.account.role!==r.account.role)throw new et("账号服务返回了不一致的权限,请刷新后重试。");return{authenticated:r.authenticated,...typeof r.csrfToken=="string"?{csrfToken:r.csrfToken}:{},...typeof r.refreshRequired=="boolean"?{refreshRequired:r.refreshRequired}:{},cloudTarget:r.cloudTarget?{cloudOrigin:r.cloudTarget.cloudOrigin,accountOrigin:r.cloudTarget.accountOrigin,installationId:r.cloudTarget.installationId}:null,...a?{account:{id:r.account.id,username:r.account.username,displayName:r.account.displayName,role:r.account.role},overview:a,session:{id:r.session.id,expiresAt:r.session.expiresAt}}:{}}}function hx(t,i){const r=t;if(!r||!$f(r.account)||r.account.id!==i||typeof r.security?.hasPassword!="boolean"||typeof r.security?.githubLinked!="boolean"||![r.capabilities?.sessions,r.capabilities?.passwordChange,r.capabilities?.admin,r.capabilities?.links].every(a=>typeof a=="boolean")||r.capabilities.admin!==(r.account.role==="admin")||![r.stats?.activeSessions,r.stats?.loginMethods].every(a=>Number.isSafeInteger(a)&&a>=0))throw new et("账号服务返回了无效的资料,请刷新后重试。");return{account:{id:r.account.id,username:r.account.username,displayName:r.account.displayName,role:r.account.role},security:{hasPassword:r.security.hasPassword,githubLinked:r.security.githubLinked},capabilities:{sessions:r.capabilities.sessions,passwordChange:r.capabilities.passwordChange,admin:r.capabilities.admin,links:r.capabilities.links},stats:{activeSessions:r.stats.activeSessions,loginMethods:r.stats.loginMethods}}}class WT{constructor(i=globalThis.fetch.bind(globalThis)){this.fetcher=i}fetcher;epoch=0;csrfToken="";requests=new Set;rootId;onSessionLost;setCsrf(i){this.csrfToken=i}setSession(i){this.rootId!==i.session?.id&&this.invalidate(),this.csrfToken=i.csrfToken??"",this.rootId=i.session?.id}async nativeRequest(i,r,a){if(!/^\/(?:login|register|github\/(?:start|poll|cancel))$/.test(i))throw new et("登录请求地址无效。");const u=this.epoch,d=AbortSignal.timeout(i==="/github/poll"?2e4:1e4);try{const c=await this.fetcher("/api/v1/account"+i,{method:"POST",credentials:"omit",cache:"no-store",redirect:"error",signal:d,headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),h=await c.json();if(a?.(h),u!==this.epoch)throw h?.accessToken&&this.revokeTransient(h),new et("账号状态已改变。");if(!c.ok)throw oo(h,c.status,i);return h}catch(c){throw c instanceof et?c:new et(i==="/github/poll"&&(d.aborted||c?.name==="TimeoutError")?"等待 GitHub 登录验证超时,请重新发起授权。":"无法连接账号服务,请检查网络后重试。")}}async revokeTransient(i){po.test(i?.accessToken??"")&&await this.fetcher("/api/v1/account/logout",{method:"POST",credentials:"omit",cache:"no-store",redirect:"error",signal:AbortSignal.timeout(1e4),headers:{"Content-Type":"application/json",Authorization:"Bearer "+i.accessToken},body:"{}"}).catch(()=>{})}async exchangeGrant(i,r){const a=this.rootId;if(!po.test(i?.accessToken??"")||!po.test(i?.refreshToken??"")||!za.test(i?.account?.id??"")||!za.test(i?.sessionId??"")||!Number.isSafeInteger(i?.accessTokenExpiresAt)||i.accessTokenExpiresAt<=Date.now())throw new et("登录授权结果无效,请重新发起。");return vl(async()=>{if(!r())throw await this.revokeTransient(i),new et("账号状态已改变。");let u;try{u=ni(await this.request("/session"))}catch(p){if(!(p instanceof et&&p.status===401&&a===void 0))throw p;u={authenticated:!1,refreshRequired:!1,cloudTarget:null}}if(u.refreshRequired&&(u=ni(await this.cookieRequest("/refresh","POST",{},u.csrfToken))),(u.authenticated?u.session?.id:void 0)!==a)throw await this.revokeTransient(i),new et("其他页面已切换账号,请刷新后重新发起登录。");if(!r())throw await this.revokeTransient(i),new et("账号状态已改变。");const d=await this.fetcher($d+"/session",{method:"POST",credentials:"include",cache:"no-store",redirect:"error",signal:AbortSignal.timeout(1e4),headers:{"Content-Type":"application/json",Authorization:"Bearer "+i.accessToken},body:JSON.stringify({refreshToken:i.refreshToken})}),c=await d.json();if(!d.ok)throw oo(c,d.status,"/session");const h=ni(c);if(!h.authenticated||h.account?.id!==i.account.id||h.session?.id!==i.sessionId)throw new et("账号登录结果不一致,请重新登录。");if(!r())throw this.setSession(h),await this.cookieRequest("/logout","POST",{}),this.setSession({authenticated:!1,refreshRequired:!1,cloudTarget:h.cloudTarget}),new et("账号状态已改变。");return this.setSession(h),h})}async restoreSession(i=5e3){return vl(async()=>{let r=ni(await this.request("/session"));return(r.refreshRequired||r.authenticated&&r.session.expiresAt<=Date.now()+i)&&(r=ni(await this.cookieRequest("/refresh","POST",{},r.csrfToken))),r})}async logoutSession(){const i=this.rootId;return vl(async()=>{let r=ni(await this.request("/session"));if(r.refreshRequired){if(r.csrfToken!==this.csrfToken)throw new et("其他页面已切换账号,请刷新后确认。");r=ni(await this.cookieRequest("/refresh","POST",{},r.csrfToken))}if(r.authenticated&&r.session?.id!==i)throw new et("其他页面已切换账号,请刷新后确认。");if(this.setSession(r),r.authenticated&&(await this.cookieRequest("/logout","POST",{})).ok!==!0)throw new et("服务端尚未确认退出,请重试。");return{authenticated:!1,refreshRequired:!1,cloudTarget:r.cloudTarget}})}async cookieRequest(i,r,a,u=this.csrfToken){const d=await this.fetcher($d+i,{method:r,credentials:"include",cache:"no-store",redirect:"error",signal:AbortSignal.timeout(1e4),headers:{...a===void 0?{}:{"Content-Type":"application/json"},"X-CodeShell-CSRF":u},body:a===void 0?void 0:JSON.stringify(a)}),c=await d.json();if(!d.ok)throw oo(c,d.status,i);if(c?.accessToken!==void 0||c?.refreshToken!==void 0)throw new et("账号服务返回了不支持的授权结果。");return c}invalidate(){this.epoch++;for(const i of this.requests)i.abort();this.requests.clear()}async request(i,r="GET",a,u,d,c=0){if(!/^\/[A-Za-z0-9/?=&_-]+$/.test(i)||i.startsWith("//"))throw new et("账号请求地址无效。");if(r!=="GET"&&!this.csrfToken)throw new et("页面验证尚未完成,请刷新后重试。");if(r==="DELETE"&&/^\/sessions\/[0-9a-f-]{36}$/.test(i)){const b=this.rootId;return vl(async()=>{const v=ni(await this.request("/session"));if(!v.authenticated||v.session?.id!==b)throw new et("账号状态已改变,请刷新后重试。");return this.setSession(v),this.cookieRequest(i,r)})}const h=this.epoch,p=this.rootId,m=new AbortController;this.requests.add(m);const y=AbortSignal.timeout(i==="/github/poll"?2e4:1e4);try{const b=await this.fetcher($d+i,{method:r,credentials:"include",cache:"no-store",redirect:"error",signal:AbortSignal.any([m.signal,y,...u?[u]:[]]),headers:{...a===void 0?{}:{"Content-Type":"application/json"},...this.csrfToken?{"X-CodeShell-CSRF":this.csrfToken}:{}},body:a===void 0?void 0:JSON.stringify(a)}),v=await b.json();if(d?.(v),h!==this.epoch||u?.aborted)throw new et("账号状态已改变。");if(v?.accessToken!==void 0||v?.refreshToken!==void 0)throw new et("账号服务返回了不支持的授权结果。");if(!b.ok){if(b.status===401&&c===0&&i!=="/session"&&i!=="/refresh"&&!i.startsWith("/github/")){const x=p;try{const j=await this.restoreSession();if(j.authenticated&&j.session?.id===x&&h===this.epoch&&this.rootId===p)return this.setSession(j),await this.request(i,r,a,u,d,1)}catch{}}throw h!==this.epoch||p!==this.rootId?new et("账号状态已改变。"):(b.status===401&&i!=="/session"&&i!=="/refresh"&&!i.startsWith("/github/")&&this.onSessionLost?.(),oo(v,b.status,i))}return v}catch(b){throw b instanceof et?b:h!==this.epoch||u?.aborted||m.signal.aborted?new et("账号状态已改变。"):new et(i==="/github/poll"&&(y.aborted||b?.name==="TimeoutError")?"等待 GitHub 登录验证超时,请重新发起授权。":"无法连接账号服务,请检查网络后重试。")}finally{this.requests.delete(m)}}}const px=S.createContext(null);function li(){const t=S.useContext(px);if(!t)throw new Error("Account session provider is missing");return t}function eA({children:t}){const i=S.useRef(null);i.current??=new WT;const r=i.current,[a,u]=S.useState(null),d=S.useRef(a);d.current=a;const[c,h]=S.useState(!1),[p,m]=S.useState(!1),y=S.useRef(!1),[b,v]=S.useState(""),[x,j]=S.useState(""),[R,C]=S.useState({registrationAllowed:!1,githubEnabled:!1}),[A,_]=S.useState(!1),D=S.useRef(null),q=S.useRef(0),ae=S.useRef(!1),N=B=>ae.current&&B===q.current,U=B=>{y.current=B,m(B)},X=B=>v(B instanceof Error?B.message:"请求失败,请稍后重试。"),H=B=>{const Q=ni(B);r.setSession(Q),u(Q),d.current=Q,h(!0)},T=B=>(B.popup.close(),B.mode==="link"&&(B.accountId!==d.current?.account?.id||B.rootId!==d.current?.session?.id)?Promise.resolve():(B.receipt&&!B.cleanup&&(B.cleanup=(B.mode==="login"?r.nativeRequest("/github/cancel",{receipt:B.receipt,codeVerifier:B.verifier}):r.request("/github/cancel","POST",{receipt:B.receipt,codeVerifier:B.verifier})).then(()=>{},()=>{})),B.cleanup??Promise.resolve())),I=()=>{const B=D.current;B&&(B.cancelled=!0,D.current=null,B.mode==="login"&&q.current++,T(B),_(!1),U(!1),v(""),j(B.mode==="link"?"已取消关联流程,可刷新连接状态确认。":"已取消登录。"))},L=S.useCallback(async()=>{if(y.current)return;const B=++q.current;U(!0),v("");try{const Q=await r.restoreSession();N(B)&&H(Q)}catch(Q){N(B)&&(Q instanceof et&&Q.status===401?H({authenticated:!1,refreshRequired:!1,cloudTarget:null}):h(!1),X(Q))}finally{N(B)&&U(!1)}},[r]);S.useEffect(()=>{ae.current=!0,r.onSessionLost=()=>{q.current++,r.invalidate();const fe=d.current;if(fe){const k={authenticated:!1,refreshRequired:!1,cloudTarget:fe.cloudTarget};u(k),d.current=k,r.setSession(k)}j(""),v("登录已过期,请重新登录。"),U(!1)},L();const B=new AbortController;fetch("/api/v1/account/status",{credentials:"omit",cache:"no-store",redirect:"error",signal:B.signal}).then(async fe=>{if(!fe.ok)throw new Error("登录方式暂时无法读取。");const k=await fe.json();if(typeof k.registrationAllowed!="boolean"||typeof k.githubEnabled!="boolean")throw new Error("登录方式数据无效。");B.signal.aborted||C({registrationAllowed:k.registrationAllowed,githubEnabled:k.githubEnabled})}).catch(()=>{});const Q=()=>{D.current||L()};return window.addEventListener("focus",Q),()=>{ae.current=!1,q.current++,y.current=!1,D.current&&(D.current.cancelled=!0,T(D.current),D.current=null),r.invalidate(),B.abort(),window.removeEventListener("focus",Q)}},[r,L]),S.useEffect(()=>{if(!a?.authenticated||!a.session)return;let B;const Q=async()=>{if(y.current){B=setTimeout(Q,1e3);return}const fe=q.current;try{const k=await r.restoreSession(6e4);N(fe)&&H(k)}catch(k){N(fe)&&(k instanceof et&&k.status===401?r.onSessionLost?.():X(k))}};return B=setTimeout(Q,Math.max(1e3,a.session.expiresAt-Date.now()-6e4)),()=>clearTimeout(B)},[r,a]);const F=async(B,Q)=>{if(y.current||!c)return!1;const fe=++q.current;r.invalidate(),U(!0),v(""),j("");try{const k=await r.nativeRequest("/"+B,{...Q,deviceName:"CodeShell 网站"});if(!N(fe))return r.revokeTransient(k),!1;try{const O=await r.exchangeGrant(k,()=>N(fe));if(!N(fe))return!1;H(O)}catch(O){throw r.revokeTransient(k),O}return!0}catch(k){return N(fe)&&X(k),!1}finally{N(fe)&&U(!1)}},W=async()=>{I();const B=++q.current;r.invalidate(),U(!0),v(""),j("");const Q=d.current;if(Q){const fe={authenticated:!1,refreshRequired:!1,csrfToken:Q.csrfToken,cloudTarget:Q.cloudTarget};u(fe),d.current=fe}try{const fe=await r.logoutSession();return N(B)&&H(fe),!0}catch(fe){return N(B)&&(h(!1),X(fe)),!1}finally{N(B)&&U(!1)}},ee=async B=>{if(y.current||!c||!R.githubEnabled||B==="link"&&!d.current?.authenticated)return;const Q=window.open("about:blank","_blank");if(!Q){v("请允许此页打开 GitHub 授权窗口后重试。");return}Q.opener=null;const fe=J=>btoa(String.fromCharCode(...J)).replaceAll("+","-").replaceAll("/","_").replaceAll("=",""),k={popup:Q,mode:B,verifier:fe(crypto.getRandomValues(new Uint8Array(32))),cancelled:!1,accountId:d.current?.account?.id,rootId:d.current?.session?.id};D.current=k;const O=d.current?.account?.id,re=B==="login"?++q.current:q.current,E=()=>N(re)&&D.current===k&&!k.cancelled&&(B!=="link"||d.current?.account?.id===O);U(!0),_(!0),v(""),j(B==="link"?"请在 GitHub 页面确认要关联的身份。":"请在 GitHub 页面完成登录,最终结果会显示在这里。");try{const J=fe(new Uint8Array(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(k.verifier))));if(!E())return;const be=ge=>{/^[A-Za-z0-9_-]{43}$/.test(ge?.receipt)&&(k.receipt=ge.receipt),k.cancelled&&T(k)},Z=B==="login"?await r.nativeRequest("/github/start",{codeChallenge:J},be):await r.request("/github/start","POST",{codeChallenge:J,mode:B},void 0,be);if(!E())return;const ne=new URL(Z.authorizationUrl);if(ne.origin!=="https://github.com"||ne.pathname!=="/login/oauth/authorize"||ne.username||ne.password||ne.hash||ne.searchParams.get("code_challenge")!==J||ne.searchParams.get("code_challenge_method")!=="S256"||ne.searchParams.get("scope")!=="read:user"||!k.receipt||!Number.isSafeInteger(Z.expiresAt)||Z.expiresAt<=Date.now()||Z.expiresAt>Date.now()+9e5)throw new et("GitHub 授权请求无效,请重新发起。");for(Q.location.href=ne.href;Date.now()<Z.expiresAt&&E();){const ge={receipt:Z.receipt,codeVerifier:k.verifier,deviceName:"CodeShell 网站"},P=B==="login"?await r.nativeRequest("/github/poll",ge):await r.request("/github/poll","POST",ge);if(!E()){P?.accessToken&&r.revokeTransient(P);return}if(P.status!=="pending"){if(B==="link"){if(P.linked!==!0||P.account?.id!==O)throw new et("GitHub 关联结果无效,请刷新后重试。");j("GitHub 登录身份已关联,数据授权保持独立。")}else try{const ve=await r.exchangeGrant(P,E);E()&&(H(ve),j(""))}catch(ve){throw r.revokeTransient(P),ve}return}await new Promise(ve=>setTimeout(ve,Math.min(1e4,Math.max(1e3,Z.pollIntervalMs||1e3))))}if(E())throw new et("GitHub 授权已超时,请重新发起。")}catch(J){E()&&(j(""),X(J))}finally{T(k),D.current===k&&(D.current=null,_(!1),N(re)&&U(!1))}},V=S.useCallback((...B)=>r.request(...B),[r]);return s.jsx(px.Provider,{value:{session:a,ready:c,busy:p,error:b,status:x,...R,oauthPending:A,restore:L,signIn:F,logout:W,github:ee,cancelGithub:I,clearError:()=>v(""),workspaceActive:B=>!y.current&&d.current?.authenticated===!0&&`${d.current.account.id}:${d.current.session.id}`===B,request:V},children:t})}function Do(t){const{request:i}=li(),[r,a]=S.useState(),[u,d]=S.useState(""),[c,h]=S.useState(!!t),[p,m]=S.useState(0);return S.useEffect(()=>{const y=new AbortController;return a(void 0),d(""),h(!!t),t&&i(t,"GET",void 0,y.signal).then(b=>{y.signal.aborted||a(b)}).catch(b=>{y.signal.aborted||d(b.message)}).finally(()=>{y.signal.aborted||h(!1)}),()=>y.abort()},[t,i,p]),{value:r,error:u,loading:c,reload:()=>m(y=>y+1)}}function kr({error:t,status:i}){return s.jsxs(s.Fragment,{children:[t?s.jsx("p",{className:"form-error",role:"alert",children:t}):null,i?s.jsx("p",{className:"website-notice",role:"status",children:i}):null]})}const jo=t=>Number.isSafeInteger(t)&&t>=0?new Date(t).toLocaleString():"—",Ei=t=>typeof t=="string"&&/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(t);function tA({route:t}){const i=li(),r=Do("/overview");let a,u="";if(r.value&&i.session?.account)try{a=hx(r.value,i.session.account.id)}catch(c){u=c.message}const d=a?.capabilities.admin===!0&&i.session?.account?.role==="admin";return s.jsxs("section",{className:"website-settings-content",children:[s.jsx(kr,{error:r.error||u}),r.loading?s.jsx("p",{role:"status",children:"正在读取账号设置…"}):null,r.error||u?s.jsx("button",{className:"website-button",onClick:r.reload,children:"重试读取"}):null,a&&t.kind==="account"?s.jsxs(s.Fragment,{children:[t.section==="profile"?s.jsx(nA,{profile:a.account},a.account.id):null,t.section==="security"?s.jsx(iA,{overview:a}):null,t.section==="sessions"?s.jsx(rA,{enabled:a.capabilities.sessions}):null,t.section==="connections"?s.jsx(lA,{overview:a,reload:r.reload}):null]}):null,a&&t.kind==="admin"?d?s.jsx(aA,{section:t.section}):s.jsx("p",{role:"alert",children:"当前账号没有管理员权限。"}):null]})}function nA({profile:t}){const i=li(),[r,a]=S.useState(t.displayName),[u,d]=S.useState(t.username),[c,h]=S.useState(!1),[p,m]=S.useState(""),[y,b]=S.useState(""),v=S.useRef(!0);S.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]);const x=async j=>{j.preventDefault();const R=r.trim().normalize("NFC"),C=u.trim().toLowerCase();if(!R||[...R].length>64||/[\p{Cc}\p{Cs}\u061c\u200b\u200e\u200f\u202a-\u202e\u2066-\u2069\ufeff]/u.test(R)){m("昵称须为 1–64 个字符,且不能包含控制字符。");return}if(!/^[a-z0-9][a-z0-9._-]{2,63}$/i.test(C)){m("用户名须为 3–64 位字母、数字、点、下划线或连字符。");return}const A={...R===t.displayName?{}:{displayName:R},...C===t.username?{}:{username:C}};if(!(c||!Object.keys(A).length)){h(!0),m(""),b("");try{if((await i.request("/profile","PATCH",A)).account?.id!==t.id)throw new et("账号资料结果无效,请刷新后重试。");await i.restore(),v.current&&b("账号资料已保存。")}catch(_){v.current&&m(_.message)}finally{v.current&&h(!1)}}};return s.jsxs(s.Fragment,{children:[s.jsx(Ba,{title:"账号资料",description:"昵称用于显示,用户名用于密码登录,分别修改。"}),s.jsxs("form",{className:"website-settings-card",onSubmit:j=>{x(j)},children:[s.jsxs("label",{children:["昵称",s.jsx("input",{autoComplete:"nickname",value:r,maxLength:128,disabled:c,onChange:j=>a(j.target.value)})]}),s.jsxs("label",{children:["登录用户名",s.jsx("input",{autoComplete:"username",value:u,maxLength:64,disabled:c,onChange:j=>d(j.target.value)}),s.jsx("small",{children:"修改用户名后,请使用新的用户名登录。昵称不会自动变化。"})]}),s.jsx("button",{className:"website-button primary",type:"submit",disabled:c,children:c?"保存中…":"保存修改"}),s.jsx(kr,{error:p,status:y})]})]})}function Ba({title:t,description:i}){return s.jsxs("header",{className:"website-settings-heading",children:[s.jsx("p",{className:"website-eyebrow",children:"设置"}),s.jsx("h1",{children:t}),s.jsx("p",{className:"website-muted",children:i})]})}function iA({overview:t}){const{request:i}=li(),[r,a]=S.useState(""),[u,d]=S.useState(""),[c,h]=S.useState(""),[p,m]=S.useState(!1),[y,b]=S.useState(""),[v,x]=S.useState(""),j=S.useRef(void 0);S.useEffect(()=>()=>j.current?.abort(),[]);const R=async C=>{if(C.preventDefault(),p||!t.capabilities.passwordChange)return;if(b(""),u.length<12||u.length>1024){b("新密码须为 12–1024 个字符。");return}if(u!==c){b("两次输入的新密码不一致。");return}if(!window.confirm("修改密码后,其他登录会话及其设备授权将退出。继续修改吗?"))return;const A=new AbortController;j.current=A,m(!0),x("");try{await i("/password","POST",{currentPassword:r,newPassword:u},A.signal),A.signal.aborted||(a(""),d(""),h(""),x("密码已修改,其他登录会话已退出。"))}catch(_){A.signal.aborted||b(_.message)}finally{A.signal.aborted||m(!1)}};return s.jsxs(s.Fragment,{children:[s.jsx(Ba,{title:"安全",description:"管理密码与账号登录方式。"}),s.jsxs("div",{className:"website-settings-card",children:[s.jsx("h2",{children:"密码"}),t.capabilities.passwordChange?s.jsxs("form",{onSubmit:C=>{R(C)},children:[s.jsxs("label",{children:["当前密码",s.jsx("input",{type:"password",autoComplete:"current-password",maxLength:1024,value:r,disabled:p,onChange:C=>a(C.target.value),required:!0})]}),s.jsxs("label",{children:["新密码",s.jsx("input",{type:"password",autoComplete:"new-password",maxLength:1024,value:u,disabled:p,onChange:C=>d(C.target.value),required:!0})]}),s.jsxs("label",{children:["确认新密码",s.jsx("input",{type:"password",autoComplete:"new-password",maxLength:1024,value:c,disabled:p,onChange:C=>h(C.target.value),required:!0})]}),s.jsx("button",{className:"website-button",disabled:p,type:"submit",children:"修改密码"})]}):s.jsx("p",{className:"website-muted",children:"此账号使用 GitHub 登录,尚未设置密码。请继续使用 GitHub。"}),s.jsx(kr,{error:y,status:v})]})]})}function rA({enabled:t}){const i=li(),r=Do(t?"/sessions":null),[a,u]=S.useState(!1),[d,c]=S.useState(""),h=S.useRef(!0);S.useEffect(()=>(h.current=!0,()=>{h.current=!1}),[]);const p=async y=>{if(!(a||!window.confirm(y?.current?"退出当前登录?未发送内容会被清除。":y?"退出此登录会话?其派生设备授权也会撤销。":"退出其他所有登录会话及其设备授权?"))){u(!0),c("");try{await i.request(y?`/sessions/${y.id}`:"/sessions/revoke-others",y?"DELETE":"POST",y?void 0:{}),y?.current?await i.restore():h.current&&r.reload()}catch(b){h.current&&c(b.message)}finally{h.current&&u(!1)}}},m=r.value&&Array.isArray(r.value.sessions)&&r.value.sessions.length<=64&&r.value.sessions.every(y=>Ei(y.id)&&typeof y.deviceName=="string"&&typeof y.current=="boolean"&&Number.isSafeInteger(y.expiresAt));return s.jsxs(s.Fragment,{children:[s.jsx(Ba,{title:"登录会话",description:"查看账号的有效登录,退出不再使用的设备或浏览器。"}),t?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"website-action-row",children:[s.jsx("button",{className:"website-button",disabled:a,onClick:r.reload,children:"刷新"}),s.jsx("button",{className:"website-button",disabled:a,onClick:()=>{p()},children:"退出其他会话"})]}),s.jsx(kr,{error:d||r.error||(r.value&&!m?"会话列表数据无效,请刷新后重试。":"")}),r.loading?s.jsx("p",{role:"status",children:"正在读取登录会话…"}):null,m?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"website-hint",children:r.value.hasMore?`显示最近 ${r.value.sessions.length} 个登录会话,共 ${r.value.total} 个。`:`共 ${r.value.total??r.value.sessions.length} 个有效登录。`}),s.jsx("div",{className:"website-list",children:r.value.sessions.map(y=>s.jsxs("article",{children:[s.jsxs("div",{children:[s.jsx("strong",{children:y.deviceName}),y.current?s.jsx("span",{className:"website-tag",children:"当前登录"}):null,s.jsxs("p",{children:["创建于 ",jo(y.createdAt)," · 有效期至 ",jo(y.expiresAt)]})]}),s.jsx("button",{className:"website-button",disabled:a,onClick:()=>{p(y)},children:"退出"})]},y.id))})]}):null]}):s.jsx("p",{children:"当前服务尚未开放登录会话管理。"})]})}function lA({overview:t,reload:i}){const r=li(),a=Do(t.capabilities.links?"/links":null),[u,d]=S.useState(""),[c,h]=S.useState(!1),p=S.useRef(void 0);S.useEffect(()=>()=>p.current?.abort(),[]);const m=async(v,x)=>{if(c||!window.confirm(v==="connections"?"撤销这个数据连接及相关授权?":"撤销这个工具授权?"))return;const j=new AbortController;p.current=j,h(!0),d("");try{if((await r.request(`/links/${v}/${x}`,"DELETE",void 0,j.signal)).revoked!==!0)throw new et("数据授权撤销尚未确认,请刷新后重试。");j.signal.aborted||a.reload()}catch(R){j.signal.aborted||d(R.message)}finally{j.signal.aborted||h(!1)}},y=a.value&&Array.isArray(a.value.connections)&&a.value.connections.length<=512&&Array.isArray(a.value.grants)&&a.value.grants.length<=4096&&a.value.connections.every(v=>Ei(v.id)&&typeof v.provider=="string"&&typeof v.revoked=="boolean"&&typeof v.account?.id=="string"&&(v.account.label===void 0||typeof v.account.label=="string")&&(v.account.login===void 0||typeof v.account.login=="string"))&&a.value.grants.every(v=>Ei(v.id)&&Ei(v.connectionId)&&typeof v.client?.name=="string"&&typeof v.revoked=="boolean"&&Array.isArray(v.scopes)&&v.scopes.every(x=>typeof x=="string")&&Array.isArray(v.resources)&&v.resources.every(x=>typeof x=="string")),b=y?[...a.value.connections.filter(v=>!v.revoked).map(v=>({kind:"connections",id:v.id,title:v.account.label||v.account.login||v.provider,description:`${v.provider} · 数据连接`})),...a.value.grants.filter(v=>!v.revoked).map(v=>({kind:"grants",id:v.id,title:v.client.name,description:`权限:${v.scopes.join("、")} · 资源:${v.resources.join("、")}`}))]:[];return s.jsxs(s.Fragment,{children:[s.jsx(Ba,{title:"连接",description:"GitHub 登录身份与工具的数据访问授权分别管理。"}),s.jsxs("div",{className:"website-settings-card",children:[s.jsxs("div",{className:"website-setting-line",children:[s.jsxs("div",{children:[s.jsx("h2",{children:"GitHub 登录身份"}),s.jsx("p",{className:"website-muted",children:"用于登录 CodeShell,不代表已授权仓库访问。"})]}),s.jsx("span",{className:"website-tag",children:t.security.githubLinked?"已关联":"未关联"})]}),!t.security.githubLinked&&r.githubEnabled?s.jsx("button",{className:"website-button",disabled:r.busy,onClick:()=>{r.github("link").then(i)},children:"关联 GitHub 登录身份"}):null,r.oauthPending?s.jsx("button",{className:"website-button",onClick:r.cancelGithub,children:"取消关联"}):null,s.jsx("button",{className:"ghost",disabled:r.busy,onClick:i,children:"刷新登录方式"}),s.jsx(kr,{error:r.error,status:r.status})]}),s.jsx("h2",{children:"Link 数据连接"}),t.capabilities.links?s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"website-button",disabled:c,onClick:a.reload,children:"刷新数据连接"}),s.jsx(kr,{error:u||a.error||(a.value&&!y?"数据连接列表无效,请刷新后重试。":"")}),y?s.jsxs("div",{className:"website-list",children:[b.map(v=>s.jsxs("article",{children:[s.jsxs("div",{children:[s.jsx("strong",{children:v.title}),s.jsx("p",{children:v.description})]}),s.jsx("button",{className:"website-button",disabled:c,onClick:()=>{m(v.kind,v.id)},children:"撤销"})]},`${v.kind}:${v.id}`)),b.length?null:s.jsx("p",{className:"website-muted",children:"还没有数据连接。"})]}):null]}):s.jsx("p",{className:"website-muted",children:"当前服务尚未开放数据连接管理。"}),s.jsx("p",{className:"website-hint",children:"退出登录不会自动撤销已有 Link 数据授权。"})]})}function aA({section:t}){const i=li(),[r,a]=S.useState(null),u=Do(t==="summary"?"/admin/summary":`/admin/${t}?limit=30${r?`&cursor=${r}`:""}`),[d,c]=S.useState(!1),[h,p]=S.useState(""),m=S.useRef(void 0);S.useEffect(()=>()=>m.current?.abort(),[]);const y=async(C,A=!1)=>{if(d||!window.confirm(A?`退出 ${C.username} 的所有登录会话?`:`${C.disabled?"恢复":"停用"}账号 ${C.username}?`))return;const _=new AbortController;m.current=_,c(!0),p("");try{await i.request(`/admin/users/${C.id}${A?"/revoke-sessions":""}`,A?"POST":"PATCH",A?{}:{disabled:!C.disabled},_.signal),_.signal.aborted||u.reload()}catch(D){_.signal.aborted||(p(D.message),D instanceof et&&D.status===403&&i.restore())}finally{_.signal.aborted||c(!1)}},b=Ei(u.value?.nextCursor)?u.value.nextCursor:null,v=u.value?.nextCursor===null||Ei(u.value?.nextCursor),x=t==="users"&&Array.isArray(u.value?.users)&&u.value.users.length<=30&&v&&u.value.users.every(C=>$f(C)&&typeof C.disabled=="boolean"&&Number.isSafeInteger(C.createdAt)&&C.createdAt>=0&&Number.isSafeInteger(C.sessionCount)&&C.sessionCount>=0)?u.value.users:null,j=t==="audit"&&Array.isArray(u.value?.events)&&u.value.events.length<=30&&v&&u.value.events.every(C=>Ei(C.id)&&Ei(C.actorId)&&Ei(C.targetId)&&["admin.account.disabled","admin.account.enabled","admin.sessions.revoked"].includes(C.action))?u.value.events:null,R=t==="summary"&&u.value?.users&&[u.value.users.total,u.value.users.active,u.value.users.disabled,u.value.users.administrators,u.value.sessions?.active,u.value.auditEvents].every(C=>Number.isSafeInteger(C)&&C>=0)?u.value:null;return s.jsxs(s.Fragment,{children:[s.jsx(Ba,{title:t==="users"?"用户管理":t==="summary"?"系统统计":"操作记录",description:"管理员控制台 · 权限由服务端核验。"}),s.jsx("button",{className:"website-button",disabled:d,onClick:()=>{a(null),u.reload()},children:"刷新"}),s.jsx(kr,{error:h||u.error}),u.loading?s.jsx("p",{role:"status",children:"正在读取…"}):null,x?s.jsx("div",{className:"website-list",children:x.map(C=>s.jsxs("article",{children:[s.jsxs("div",{children:[s.jsx("strong",{children:C.displayName}),s.jsxs("p",{children:["@",C.username," · ",C.role==="admin"?"管理员":"成员"," ·"," ",C.disabled?"已停用":"正常"]}),s.jsxs("p",{children:[C.sessionCount," 个登录会话 · 创建于 ",jo(C.createdAt)]})]}),s.jsxs("div",{className:"website-action-row",children:[C.role!=="admin"&&C.id!==i.session?.account?.id?s.jsx("button",{className:"website-button",disabled:d,onClick:()=>{y(C)},children:C.disabled?"恢复":"停用"}):null,s.jsx("button",{className:"website-button",disabled:d,onClick:()=>{y(C,!0)},children:"退出会话"})]})]},C.id))}):null,j?s.jsxs("div",{className:"website-list",children:[j.map(C=>s.jsx("article",{children:s.jsxs("div",{children:[s.jsx("strong",{children:{"admin.account.disabled":"停用账号","admin.account.enabled":"恢复账号","admin.sessions.revoked":"撤销登录会话"}[C.action]}),s.jsxs("p",{children:["操作人 ",C.actorId," · 目标 ",C.targetId]}),s.jsx("p",{children:jo(C.createdAt)})]})},C.id)),j.length?null:s.jsx("p",{className:"website-muted",children:"暂无操作记录。"})]}):null,R?s.jsx("div",{className:"website-statistics",children:[["账号总数",R.users.total],["正常账号",R.users.active],["停用账号",R.users.disabled],["管理员",R.users.administrators],["有效登录",R.sessions.active],["审计事件",R.auditEvents]].map(([C,A])=>s.jsxs("article",{children:[s.jsx("span",{children:C}),s.jsx("strong",{children:A})]},C))}):null,u.value&&!x&&!j&&!R?s.jsx("p",{role:"alert",children:"管理员数据无效,请刷新后重试。"}):null,b?s.jsx("button",{className:"website-button",disabled:d||u.loading,onClick:()=>a(b),children:"下一页"}):null]})}function sA(){const t=li(),[i,r]=S.useState(!1),[a,u]=S.useState(""),[d,c]=S.useState(""),[h,p]=S.useState(""),[m,y]=S.useState(""),[b,v]=S.useState(""),x=async j=>{if(j.preventDefault(),v(""),!/^[a-z0-9][a-z0-9._-]{2,63}$/i.test(a.trim())){v("用户名须为 3–64 位字母、数字、点、下划线或连字符。");return}if(h.length<12||h.length>1024){v("密码须为 12–1024 个字符。");return}if(i&&h!==m){v("两次输入的密码不一致。");return}const R=d.trim().normalize("NFC");if(i&&(!R||[...R].length>64||/[\p{Cc}\p{Cs}]/u.test(R))){v("昵称须为 1–64 个字符,且不能包含控制字符。");return}await t.signIn(i?"register":"login",{username:a.trim().toLowerCase(),password:h,...i?{displayName:R}:{}})&&(p(""),y(""))};return s.jsxs("main",{className:"website-login",children:[s.jsxs("header",{className:"website-brand",children:["CodeShell ",s.jsx("span",{children:"工作台"})]}),s.jsxs("div",{className:"website-welcome",children:[s.jsxs("section",{className:"website-introduction",children:[s.jsx("p",{className:"website-eyebrow",children:"给想法一个开始"}),s.jsxs("h1",{children:["从一句话,",s.jsx("br",{}),"到真正完成。"]}),s.jsxs("p",{children:["与 CodeShell 对话,让 Agent 帮你处理任务。",s.jsx("br",{}),"项目、工具与历史记录,都在你的工作空间。"]}),s.jsxs("div",{className:"website-features",children:[s.jsxs("p",{children:[s.jsx("strong",{children:"继续你的工作"}),s.jsx("span",{children:"随时回到对话、任务和项目文件。"})]}),s.jsxs("p",{children:[s.jsx("strong",{children:"选择执行环境"}),s.jsx("span",{children:"任务在你选定的工作区里运行。"})]}),s.jsxs("p",{children:[s.jsx("strong",{children:"按需连接工具"}),s.jsx("span",{children:"GitHub 登录身份与数据访问授权分别管理。"})]})]})]}),s.jsxs("section",{className:"auth-card website-auth","aria-labelledby":"website-login-title",children:[s.jsx("p",{className:"website-eyebrow",children:"欢迎来到 CodeShell"}),s.jsx("h2",{id:"website-login-title",children:i?"创建你的账号":"继续你的工作"}),s.jsx("p",{className:"website-muted",children:"登录后进入你的工作台。"}),s.jsx("button",{className:"website-button website-wide",disabled:t.busy||!t.githubEnabled,onClick:()=>{t.github("login")},children:"使用 GitHub 继续"}),s.jsx("p",{className:"website-hint",children:"首次使用 GitHub 登录会按服务设置创建账号。"}),s.jsx("div",{className:"website-divider",children:"或使用用户名和密码"}),s.jsxs("form",{onSubmit:j=>{x(j)},children:[i?s.jsxs("label",{children:["昵称",s.jsx("input",{maxLength:128,autoComplete:"nickname",value:d,disabled:t.busy,onChange:j=>c(j.target.value),placeholder:"显示给你的名字",required:!0})]}):null,s.jsxs("label",{children:["用户名",s.jsx("input",{maxLength:64,autoComplete:"username",value:a,disabled:t.busy,onChange:j=>u(j.target.value),required:!0})]}),s.jsxs("label",{children:["密码",s.jsx("input",{type:"password",maxLength:1024,autoComplete:i?"new-password":"current-password",value:h,disabled:t.busy,onChange:j=>p(j.target.value),required:!0})]}),i?s.jsxs("label",{children:["确认密码",s.jsx("input",{type:"password",maxLength:1024,autoComplete:"new-password",value:m,disabled:t.busy,onChange:j=>y(j.target.value),required:!0})]}):null,s.jsx("button",{className:"send website-wide",disabled:t.busy||!t.ready,type:"submit",children:t.busy?"正在连接…":i?"创建账号":"登录"})]}),t.registrationAllowed?s.jsx("button",{className:"ghost website-wide",disabled:t.busy,onClick:()=>{r(!i),y(""),v(""),t.clearError()},children:i?"已有账号?登录":"没有账号?创建账号"}):null,t.oauthPending?s.jsx("button",{className:"ghost website-wide",onClick:t.cancelGithub,children:"取消 GitHub 授权"}):null,t.status?s.jsx("p",{role:"status",className:"website-hint",children:t.status}):null,b||t.error?s.jsx("p",{role:"alert",className:"form-error",children:b||t.error}):null,!t.ready&&!t.busy?s.jsx("button",{className:"website-button",onClick:()=>{t.restore()},children:"重试连接"}):null]})]}),s.jsx("footer",{className:"website-login-footer",children:"CodeShell · 让工作继续"})]})}async function oA(t=globalThis.fetch,i){const r=await t("/api/v1/cloud-browser/capabilities",{credentials:"omit",cache:"no-store",redirect:"error",signal:i});if(r.status===404)return null;if(!r.ok)throw new Error("暂时无法确认工作台登录方式,请重试。");const a=await r.json();if(a?.version!==1||a?.mode!=="cloud-browser"||!Pf(a))throw new Error("工作台返回了无效的登录配置,请联系管理员。");return{...a,version:1,mode:"cloud-browser"}}function uA(t,i,r){return pf(r)&&Pf(i)&&t.cloudOrigin===r&&i.cloudOrigin===r&&t.accountOrigin===r&&i.accountOrigin===r&&t.installationId===i.installationId}function cA(t,i,r){const a=t,u=a?.session,d=/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/;if(a?.authenticated!==!0||a.mode!=="cloud-account"||!u||u.kind!=="cloud-management"||u.accountId!==r||u.accountOrigin!==i.accountOrigin||u.audience!==i.cloudOrigin||u.installationId!==i.installationId||![u.id,u.accountId,u.managementEpoch].every(c=>d.test(c))||!Number.isSafeInteger(u.expiresAt)||u.expiresAt<=Date.now())throw new Error("工作区登录与当前账号不一致,请重新连接。");return u}async function dA(t,i=globalThis.fetch){await vl(async()=>{const r={credentials:"include",cache:"no-store",redirect:"error"},a=await i("/api/v1/cloud-browser/status",{...r,signal:AbortSignal.timeout(1e4)});if(!a.ok)return;const u=await a.json();u?.authenticated!==!0||u.mode!=="cloud-account"||u.session?.id!==t.id||u.session?.accountId!==t.accountId||u.session?.managementEpoch!==t.managementEpoch||u.session?.audience!==t.audience||await i("/api/v1/cloud-browser/logout",{...r,method:"POST",signal:AbortSignal.timeout(1e4),headers:{"Content-Type":"application/json"},body:"{}"})})}function fA({setupToken:t}){const[i,r]=S.useState(),[a,u]=S.useState(""),[d,c]=S.useState(0);return S.useEffect(()=>{const h=new AbortController;return u(""),oA(globalThis.fetch,h.signal).then(p=>{h.signal.aborted||r(p)}).catch(p=>{h.signal.aborted||u(p instanceof Error?p.message:"无法连接工作台,请重试。")}),()=>h.abort()},[d]),i===null?s.jsx(JT,{setupToken:t}):i?s.jsx(eA,{children:s.jsx(hA,{capability:i})}):s.jsx("main",{className:"auth-page",children:s.jsxs("section",{className:"auth-card",children:[s.jsx("h1",{children:"CodeShell"}),a?s.jsxs(s.Fragment,{children:[s.jsx("p",{role:"alert",className:"form-error",children:a}),s.jsx("button",{className:"send",onClick:()=>c(h=>h+1),children:"重试连接"})]}):s.jsx("p",{role:"status",children:"正在连接工作台…"})]})})}function Mb({go:t,logout:i}){const r=li(),a=r.session?.account;return s.jsxs("details",{className:"website-account-menu",children:[s.jsx("summary",{"aria-label":"打开账号菜单",children:s.jsx("span",{"aria-hidden":"true",children:(a?.displayName||"C").slice(0,1)})}),s.jsxs("div",{className:"website-account-popover",children:[s.jsx("strong",{children:a?.displayName}),s.jsxs("small",{children:["@",a?.username]}),s.jsx("button",{onClick:u=>{u.currentTarget.closest("details")?.removeAttribute("open"),t({kind:"account",section:"profile"})},children:"账号设置"}),s.jsx("button",{onClick:u=>{u.currentTarget.closest("details")?.removeAttribute("open"),t({kind:"account",section:"connections"})},children:"连接"}),a?.role==="admin"?s.jsx("button",{onClick:()=>t({kind:"admin",section:"users"}),children:"管理控制台"}):null,s.jsx("button",{disabled:r.busy,onClick:i,children:"退出登录"})]})]})}function hA({capability:t}){const i=li(),[r,a]=S.useState(()=>Ab(new URL(window.location.href))),[u,d]=S.useState(null),[c,h]=S.useState(""),[p,m]=S.useState(!1),[y,b]=S.useState(0),v=S.useRef(0),x=i.session?.authenticated?`${i.session.account.id}:${i.session.session.id}`:null,j=u?.identity===x?u.session:null,R=i.session?.cloudTarget,C=i.session?.account?.id,A=N=>{window.history.pushState(null,"",OT(N,new URL(window.location.href))),a(N),i.clearError(),i.oauthPending&&i.cancelGithub()};S.useEffect(()=>{const N=()=>{a(Ab(new URL(window.location.href))),i.oauthPending&&i.cancelGithub()};return window.addEventListener("popstate",N),()=>window.removeEventListener("popstate",N)},[i.oauthPending]),S.useEffect(()=>{const N=++v.current,U=new AbortController;if(d(null),h(""),m(!1),!x||!C)return()=>U.abort();if(!R)return h("当前账号尚未分配云端环境。你仍可管理账号设置。"),()=>U.abort();if(!uA(t,R,window.location.origin))return h("云端环境与账号服务配置不一致,请联系管理员。"),()=>U.abort();let X;const H=async()=>{if(!(U.signal.aborted||N!==v.current)){m(!0),h("");try{const T=await i.request("/cloud-tickets","POST",{},U.signal);if(!/^[A-Za-z0-9_-]{43}$/.test(T.ticket)||!Number.isSafeInteger(T.expiresAt)||T.expiresAt<=Date.now()||T.expiresAt>Date.now()+61e3||T.cloudOrigin!==R.cloudOrigin||T.accountOrigin!==R.accountOrigin||T.installationId!==R.installationId)throw new Error("云端授权目标无效,请联系管理员。");const I=await vl(async()=>{if(U.signal.aborted||N!==v.current)throw new Error("账号状态已改变。");const L=ni(await i.request("/session"));if(!L.authenticated||`${L.account.id}:${L.session.id}`!==x)throw i.restore(),new Error("其他页面已切换账号,请重新连接。");const F=await fetch("/api/v1/cloud-browser/session",{method:"POST",credentials:"include",cache:"no-store",redirect:"error",signal:AbortSignal.timeout(1e4),headers:{"Content-Type":"application/json"},body:JSON.stringify({ticket:T.ticket})});if(!F.ok)throw new Error("云端工作区登录未完成,请重试连接。");const W=cA(await F.json(),R,C);if(U.signal.aborted||N!==v.current)throw await fetch("/api/v1/cloud-browser/logout",{method:"POST",credentials:"include",cache:"no-store",redirect:"error",signal:AbortSignal.timeout(1e4),headers:{"Content-Type":"application/json"},body:"{}"}),new Error("账号状态已改变。");return W});!U.signal.aborted&&N===v.current&&(d({session:I,identity:x}),X=setTimeout(()=>{H()},Math.max(1e3,I.expiresAt-Date.now()-3e4)))}catch(T){!U.signal.aborted&&N===v.current&&(d(null),h(T instanceof Error?T.message:"无法连接云端工作区,请重试。"))}finally{!U.signal.aborted&&N===v.current&&m(!1)}}};return H(),()=>{U.abort(),clearTimeout(X)}},[x,R?.cloudOrigin,R?.installationId,R?.accountOrigin,t,i.request,y]);const _=()=>{const N=j;v.current++,d(null),i.logout().then(U=>{if(U&&N)return dA(N)}).catch(()=>{})};if(!i.session?.authenticated)return s.jsx(sA,{});const D=s.jsx(Mb,{go:A,logout:_}),q=r.kind!=="workbench",ae=i.session.account?.role==="admin";return s.jsxs($b.Provider,{value:"/api/v1/cloud-browser/environment",children:[j?s.jsx("div",{hidden:q,className:"website-workbench-root",children:s.jsx(fx,{allowLegacy:!1,autoEnterSingle:!0,startCreatedProject:!0,canRequest:()=>i.workspaceActive(x),onAuthLost:()=>{d(null),b(N=>N+1)},accountControl:D,children:(N,U)=>s.jsx(ff,{hub:!0,onAuthLost:()=>{d(null),b(X=>X+1)},projectName:N?.name,onBackToProjects:U,cloudAccount:{pending:i.busy,error:"",onLogout:_,accountOrigin:R?.accountOrigin},renderAccountControl:X=>s.jsx(Mb,{go:A,logout:()=>X.guard(_)})})},x)}):q?null:s.jsxs("main",{className:"website-environment-empty",children:[s.jsxs("header",{className:"website-brand",children:["CodeShell ",D]}),s.jsxs("section",{children:[s.jsx("p",{className:"website-eyebrow",children:"你的工作台"}),s.jsx("h1",{children:p?"正在打开工作空间…":"连接你的工作空间"}),s.jsx("p",{role:c?"alert":"status",className:c?"form-error":"website-muted",children:c||"正在验证账号与云端环境。"}),c?s.jsx("button",{className:"website-button",onClick:()=>b(N=>N+1),children:"重新连接"}):null,s.jsx("button",{className:"ghost",onClick:()=>A({kind:"account",section:"profile"}),children:"账号设置"})]})]}),q?s.jsxs("div",{className:"website-settings-shell",children:[s.jsxs("aside",{className:"website-settings-nav",children:[s.jsx("button",{className:"website-back",onClick:()=>A({kind:"workbench"}),children:"← 返回工作台"}),s.jsx("p",{className:"website-eyebrow",children:"账号设置"}),s.jsx("nav",{"aria-label":"账号设置",children:[["profile","账号资料"],["security","安全"],["sessions","登录会话"],["connections","连接"]].map(([N,U])=>s.jsx("button",{"aria-current":r.kind==="account"&&r.section===N?"page":void 0,onClick:()=>A({kind:"account",section:N}),children:U},N))}),ae?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"website-eyebrow",children:"管理控制台"}),s.jsx("nav",{"aria-label":"管理控制台",children:[["users","用户管理"],["summary","系统统计"],["audit","操作记录"]].map(([N,U])=>s.jsx("button",{"aria-current":r.kind==="admin"&&r.section===N?"page":void 0,onClick:()=>A({kind:"admin",section:N}),children:U},N))})]}):null,s.jsx("div",{className:"website-settings-avatar",children:D})]}),s.jsx("main",{children:s.jsx(tA,{route:r},`${x}:${r.kind}:${r.section}`)})]}):null]})}function pA(t="/"){"serviceWorker"in navigator&&window.isSecureContext&&navigator.serviceWorker.register(`${t}sw.js`).catch(()=>{})}const Ob=P1(),mA=D1(window.location,window.history);J1.createRoot(document.getElementById("root")).render(s.jsx(S.StrictMode,{children:Ob?s.jsx(Y1,{callback:Ob}):s.jsx(fA,{setupToken:mA})}));pA("/");