@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.
- package/dist/components/ModelTraceExplorer.d.ts +10 -0
- package/dist/components/ModelTraceExplorer.js +490 -0
- package/dist/components/model-trace-presentation.d.ts +11 -0
- package/dist/components/model-trace-presentation.js +73 -0
- package/dist/hooks/mobileOutputClient.d.ts +4 -0
- package/dist/hooks/mobileOutputClient.js +83 -28
- package/dist/hooks/useRemoteApp.d.ts +23 -7
- package/dist/hooks/useRemoteApp.js +124 -39
- package/dist/i18n/mobile.d.ts +4 -0
- package/dist/i18n/mobile.js +4 -0
- package/dist/i18n/translate.d.ts +4 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/lib/format.d.ts +3 -0
- package/dist/lib/format.js +24 -8
- package/dist/lib/mobileAttachments.d.ts +2 -0
- package/dist/lib/mobileAttachments.js +6 -3
- package/dist/lib/mobileOutputRecovery.d.ts +12 -0
- package/dist/lib/mobileOutputRecovery.js +155 -11
- package/dist/lib/storage.js +34 -7
- package/dist/lib/streamReducer.js +26 -7
- package/dist/model-trace-api.d.ts +16 -0
- package/dist/model-trace-api.js +36 -0
- package/dist-app/assets/index-B0Ob4zoq.css +1 -0
- package/dist-app/assets/index-DcljaCB6.js +75 -0
- package/dist-app/index.html +2 -2
- package/package.json +20 -4
- package/dist-app/assets/index-DFx6OGDf.js +0 -57
- package/dist-app/assets/index-DSlekIOe.css +0 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))l(o);new MutationObserver(o=>{for(const d of o)if(d.type==="childList")for(const c of d.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&l(c)}).observe(document,{childList:!0,subtree:!0});function i(o){const d={};return o.integrity&&(d.integrity=o.integrity),o.referrerPolicy&&(d.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?d.credentials="include":o.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function l(o){if(o.ep)return;o.ep=!0;const d=i(o);fetch(o.href,d)}})();function zo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Kc={exports:{}},vl={};var Gg;function I1(){if(Gg)return vl;Gg=1;var t=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function i(l,o,d){var c=null;if(d!==void 0&&(c=""+d),o.key!==void 0&&(c=""+o.key),"key"in o){d={};for(var h in o)h!=="key"&&(d[h]=o[h])}else d=o;return o=d.ref,{$$typeof:t,type:l,key:c,ref:o!==void 0?o:null,props:d}}return vl.Fragment=r,vl.jsx=i,vl.jsxs=i,vl}var Vg;function B1(){return Vg||(Vg=1,Kc.exports=I1()),Kc.exports}var a=B1(),Xc={exports:{}},ft={};var Yg;function q1(){if(Yg)return ft;Yg=1;var t=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(M){return M===null||typeof M!="object"?null:(M=v&&M[v]||M["@@iterator"],typeof M=="function"?M:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,C={};function E(M,te,k){this.props=M,this.context=te,this.refs=C,this.updater=k||j}E.prototype.isReactComponent={},E.prototype.setState=function(M,te){if(typeof M!="object"&&typeof M!="function"&&M!=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,M,te,"setState")},E.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function A(){}A.prototype=E.prototype;function D(M,te,k){this.props=M,this.context=te,this.refs=C,this.updater=k||j}var L=D.prototype=new A;L.constructor=D,N(L,E.prototype),L.isPureReactComponent=!0;var J=Array.isArray;function T(){}var B={H:null,A:null,T:null,S:null},U=Object.prototype.hasOwnProperty;function X(M,te,k){var W=k.ref;return{$$typeof:t,type:M,key:te,ref:W!==void 0?W:null,props:k}}function _(M,te){return X(M.type,te,M.props)}function I(M){return typeof M=="object"&&M!==null&&M.$$typeof===t}function H(M){var te={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(k){return te[k]})}var Y=/\/+/g;function $(M,te){return typeof M=="object"&&M!==null&&M.key!=null?H(""+M.key):te.toString(36)}function F(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(T,T):(M.status="pending",M.then(function(te){M.status==="pending"&&(M.status="fulfilled",M.value=te)},function(te){M.status==="pending"&&(M.status="rejected",M.reason=te)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function P(M,te,k,W,ue){var me=typeof M;(me==="undefined"||me==="boolean")&&(M=null);var Q=!1;if(M===null)Q=!0;else switch(me){case"bigint":case"string":case"number":Q=!0;break;case"object":switch(M.$$typeof){case t:case r:Q=!0;break;case y:return Q=M._init,P(Q(M._payload),te,k,W,ue)}}if(Q)return ue=ue(M),Q=W===""?"."+$(M,0):W,J(ue)?(k="",Q!=null&&(k=Q.replace(Y,"$&/")+"/"),P(ue,te,k,"",function(ke){return ke})):ue!=null&&(I(ue)&&(ue=_(ue,k+(ue.key==null||M&&M.key===ue.key?"":(""+ue.key).replace(Y,"$&/")+"/")+Q)),te.push(ue)),1;Q=0;var oe=W===""?".":W+":";if(J(M))for(var fe=0;fe<M.length;fe++)W=M[fe],me=oe+$(W,fe),Q+=P(W,te,k,me,ue);else if(fe=w(M),typeof fe=="function")for(M=fe.call(M),fe=0;!(W=M.next()).done;)W=W.value,me=oe+$(W,fe++),Q+=P(W,te,k,me,ue);else if(me==="object"){if(typeof M.then=="function")return P(F(M),te,k,W,ue);throw te=String(M),Error("Objects are not valid as a React child (found: "+(te==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":te)+"). If you meant to render a collection of children, use an array instead.")}return Q}function G(M,te,k){if(M==null)return M;var W=[],ue=0;return P(M,W,"","",function(me){return te.call(k,me,ue++)}),W}function re(M){if(M._status===-1){var te=M._result;te=te(),te.then(function(k){(M._status===0||M._status===-1)&&(M._status=1,M._result=k)},function(k){(M._status===0||M._status===-1)&&(M._status=2,M._result=k)}),M._status===-1&&(M._status=0,M._result=te)}if(M._status===1)return M._result.default;throw M._result}var be=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var te=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(te))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},R={map:G,forEach:function(M,te,k){G(M,function(){te.apply(this,arguments)},k)},count:function(M){var te=0;return G(M,function(){te++}),te},toArray:function(M){return G(M,function(te){return te})||[]},only:function(M){if(!I(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return ft.Activity=b,ft.Children=R,ft.Component=E,ft.Fragment=i,ft.Profiler=o,ft.PureComponent=D,ft.StrictMode=l,ft.Suspense=f,ft.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=B,ft.__COMPILER_RUNTIME={__proto__:null,c:function(M){return B.H.useMemoCache(M)}},ft.cache=function(M){return function(){return M.apply(null,arguments)}},ft.cacheSignal=function(){return null},ft.cloneElement=function(M,te,k){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var W=N({},M.props),ue=M.key;if(te!=null)for(me in te.key!==void 0&&(ue=""+te.key),te)!U.call(te,me)||me==="key"||me==="__self"||me==="__source"||me==="ref"&&te.ref===void 0||(W[me]=te[me]);var me=arguments.length-2;if(me===1)W.children=k;else if(1<me){for(var Q=Array(me),oe=0;oe<me;oe++)Q[oe]=arguments[oe+2];W.children=Q}return X(M.type,ue,W)},ft.createContext=function(M){return M={$$typeof:c,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:d,_context:M},M},ft.createElement=function(M,te,k){var W,ue={},me=null;if(te!=null)for(W in te.key!==void 0&&(me=""+te.key),te)U.call(te,W)&&W!=="key"&&W!=="__self"&&W!=="__source"&&(ue[W]=te[W]);var Q=arguments.length-2;if(Q===1)ue.children=k;else if(1<Q){for(var oe=Array(Q),fe=0;fe<Q;fe++)oe[fe]=arguments[fe+2];ue.children=oe}if(M&&M.defaultProps)for(W in Q=M.defaultProps,Q)ue[W]===void 0&&(ue[W]=Q[W]);return X(M,me,ue)},ft.createRef=function(){return{current:null}},ft.forwardRef=function(M){return{$$typeof:h,render:M}},ft.isValidElement=I,ft.lazy=function(M){return{$$typeof:y,_payload:{_status:-1,_result:M},_init:re}},ft.memo=function(M,te){return{$$typeof:p,type:M,compare:te===void 0?null:te}},ft.startTransition=function(M){var te=B.T,k={};B.T=k;try{var W=M(),ue=B.S;ue!==null&&ue(k,W),typeof W=="object"&&W!==null&&typeof W.then=="function"&&W.then(T,be)}catch(me){be(me)}finally{te!==null&&k.types!==null&&(te.types=k.types),B.T=te}},ft.unstable_useCacheRefresh=function(){return B.H.useCacheRefresh()},ft.use=function(M){return B.H.use(M)},ft.useActionState=function(M,te,k){return B.H.useActionState(M,te,k)},ft.useCallback=function(M,te){return B.H.useCallback(M,te)},ft.useContext=function(M){return B.H.useContext(M)},ft.useDebugValue=function(){},ft.useDeferredValue=function(M,te){return B.H.useDeferredValue(M,te)},ft.useEffect=function(M,te){return B.H.useEffect(M,te)},ft.useEffectEvent=function(M){return B.H.useEffectEvent(M)},ft.useId=function(){return B.H.useId()},ft.useImperativeHandle=function(M,te,k){return B.H.useImperativeHandle(M,te,k)},ft.useInsertionEffect=function(M,te){return B.H.useInsertionEffect(M,te)},ft.useLayoutEffect=function(M,te){return B.H.useLayoutEffect(M,te)},ft.useMemo=function(M,te){return B.H.useMemo(M,te)},ft.useOptimistic=function(M,te){return B.H.useOptimistic(M,te)},ft.useReducer=function(M,te,k){return B.H.useReducer(M,te,k)},ft.useRef=function(M){return B.H.useRef(M)},ft.useState=function(M){return B.H.useState(M)},ft.useSyncExternalStore=function(M,te,k){return B.H.useSyncExternalStore(M,te,k)},ft.useTransition=function(){return B.H.useTransition()},ft.version="19.2.6",ft}var Qg;function Ef(){return Qg||(Qg=1,Xc.exports=q1()),Xc.exports}var Ze=Ef();const x=zo(Ze);let Bl,_o=null;const U1=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,Gb=/^\/p\/([0-9a-f-]{36})(\/.*)$/;function Es(t){return typeof t=="string"&&U1.test(t)}function ro(t){if(t!==null&&!Es(t))throw new Error("项目标识无效。");_o=t}function Dl(){return _o}function Cs(){return{workspace:Bl??"",projectId:_o}}function io(t){Bl=void 0}function jo(){return Bl}function Kg(t=Bl){return t?{"X-CodeShell-Workspace":encodeURIComponent(t)}:{}}function Vb(t){return/^\/api\/v1\/(?:auth|projects|environment)(?:\/|\?|$)/.test(t)||/^\/api\/v1\/cloud-browser\/environment(?:\?|$)/.test(t)||/^\/api\/v1\/desktop\/session(?:\?|$)/.test(t)}function H1(t){const r=Gb.exec(t);return!!r&&Es(r[1])}function Dt(t,r=Bl,i=_o){const l=Gb.exec(t),o=l?l[2]:t;if(l&&!Es(l[1])||!o.startsWith("/api/v1/")&&o!=="/ws"||/[\\\r\n]/.test(t))throw new Error("Workspace URLs must use the local API");const d=new URL(o,"http://codeshell.invalid");if(d.pathname!==o.split(/[?#]/,1)[0])throw new Error("Workspace URLs must use the local API");if(Vb(o))return o;if(l)return t;if(i!==null&&!Es(i))throw new Error("项目标识无效。");return r&&o.startsWith("/api/v1/")&&d.searchParams.set("workspace",r),`${i?`/p/${i}`:""}${d.pathname}${d.search}${d.hash}`}class it extends Error{constructor(r,i,l,o){super(r),this.status=i,this.code=l,this.retryAfterMs=o}status;code;retryAfterMs}class Yb extends Error{constructor(){super("服务端返回了无效的登录状态,请稍后重试。")}}async function Je(t,r={},i){const l=i?Kg(i.workspace):Kg(),o={...r};if(Object.keys(l).length&&!Vb(t)&&!H1(t)&&!t.includes("workspace=")){const h=new Headers(r.headers);for(const[f,p]of Object.entries(l))h.has(f)||h.set(f,p);o.headers=h}const d=await fetch(i?Dt(t,i.workspace,i.projectId):Dt(t,""),{...o,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 it(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 ef(t,r={}){return Je(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}async function P1(){try{const t=await Je("/api/v1/auth/status"),r=()=>new Yb;if(!t||typeof t.initialized!="boolean"||typeof t.authenticated!="boolean"||t.mode!==void 0&&t.mode!=="cloud-account")throw r();if(t.mode==="cloud-account"){if(!t.initialized||!t.authenticated&&t.session!==void 0)throw r();let i;if(t.authenticated){const l=t.session,o=/^[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(!l||Array.isArray(l)||l.kind!=="cloud-management"||![l.id,l.installationId,l.accountId,l.managementEpoch].every(c=>typeof c=="string"&&o.test(c))||!d(l.audience)||!d(l.accountOrigin)||typeof window<"u"&&l.audience!==window.location.origin||!Number.isSafeInteger(l.expiresAt)||l.expiresAt<=Date.now())throw r();i={id:l.id,kind:"cloud-management",audience:l.audience,installationId:l.installationId,accountOrigin:l.accountOrigin,accountId:l.accountId,managementEpoch:l.managementEpoch,expiresAt:l.expiresAt}}return{initialized:!0,authenticated:t.authenticated,mode:"cloud-account",...i?{cloudSession:i}:{}}}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 it&&t.status===404)return null;throw t}}function F1(t,r){const i=new URLSearchParams(t.hash.replace(/^#/,"")),l=i.get("setup")??"";if(i.has("setup")){i.delete("setup");const o=i.toString();r.replaceState(r.state,"",`${t.pathname}${t.search}${o?`#${o}`:""}`)}return l}function ql(){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 r=Array.from(t,i=>i.toString(16).padStart(2,"0")).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}async function $1(t,r={}){const i=r.scope??Cs();return Je(Dt(`/api/v1/uploads/${ql()}`,i.workspace,i.projectId),{method:"PUT",headers:{"Content-Type":t.type||"application/octet-stream","X-File-Name":encodeURIComponent(t.name)},body:t,signal:r.signal})}async function G1(t,r=Cs()){await Je(Dt(`/api/v1/uploads/${encodeURIComponent(t)}`,r.workspace,r.projectId),{method:"DELETE"})}function V1(t){try{const r=new URL(t??"");return(r.protocol==="https:"||r.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(r.hostname))&&!r.username&&!r.password?r.href:void 0}catch{return}}function Zc(t,r){const i=t.authModes?.filter(l=>l.available&&(!r||l.methodId===r));return i?.find(l=>l.preferred)??i?.[0]}function Ar(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 Y1=new Set(["redirect","device-code","qr-code","credential-input","local-session","consent","processing"]);function Q1(t,r){if(typeof t.id!="string"||!t.id||r&&t.id!==r)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 i=Ar(t);if(t.state==="pending"&&(!i||!Y1.has(i.kind)))throw new Error("当前客户端不支持这个授权步骤,请更新客户端。");if(i&&(!i.id||!Number.isFinite(Date.parse(i.expiresAt))))throw new Error("授权步骤缺少有效期限,请重新连接。");if(t.expiresAt&&(!Number.isFinite(Date.parse(t.expiresAt))||i&&Date.parse(i.expiresAt)>Date.parse(t.expiresAt)))throw new Error("授权任务的有效期限无效,请重新连接。")}class K1{constructor(r,i={}){this.transport=r,this.options=i}transport;options;value={busy:!1};listeners=new Set;timer;generation=0;disposed=!1;binding;getSnapshot=()=>this.value;subscribe=r=>(this.listeners.add(r),()=>this.listeners.delete(r));publish(r){if(!this.disposed){this.value=r;for(const i of this.listeners)i()}}stop(){return clearTimeout(this.timer),++this.generation}current(r){return!this.disposed&&r===this.generation}deadline(r){const i=Ar(r);return Math.min(r.expiresAt?Date.parse(r.expiresAt):1/0,i?Date.parse(i.expiresAt):1/0)}accept(r,i,l){if(this.current(i)){if(Q1(r,l),this.binding&&(r.providerId!==this.binding.providerId||r.methodId&&r.methodId!==this.binding.methodId))throw new Error("授权响应与当前服务不匹配。");this.publish({authorization:r,busy:!1}),r.state==="pending"&&this.schedule(i)}}schedule(r,i=this.options.pollIntervalMs??2e3){const l=this.value.authorization;if(!this.current(r)||l?.state!=="pending")return;const o=this.deadline(l)-Date.now();if(o<=0){this.stop(),this.publish({busy:!1,authorization:{...l,state:"failed",step:void 0,prompt:void 0,redirect:void 0,errorCode:"authorization_expired"}}),this.transport.cancel(l.id).catch(()=>{});return}const d=Ar(l),c=d&&["credential-input","local-session","consent"].includes(d.kind);this.timer=setTimeout(()=>{c?this.schedule(r):this.poll(r)},Math.min(i,o))}async poll(r){const i=this.value.authorization;if(!(!this.current(r)||i?.state!=="pending")){if(this.deadline(i)<=Date.now()){this.schedule(r);return}try{const l=await this.transport.status(i.id);this.accept(l,r,i.id)}catch(l){if(!this.current(r))return;this.publish({...this.value,busy:!1,error:so(l)});const o=l?.status;o!==401&&o!==404&&this.schedule(r,this.options.retryIntervalMs??4e3)}}}async begin(r,i){if(this.disposed||this.value.busy||this.value.authorization?.state==="pending")return;const l=this.stop();this.binding=r,this.publish({busy:!0});try{const o=await this.transport.begin(r,i);if(!this.current(l)){o.state==="pending"&&this.transport.cancel(o.id).catch(()=>{});return}try{this.accept(o,l)}catch(d){throw o.state==="pending"&&this.transport.cancel(o.id).catch(()=>{}),d}return o}catch(o){this.current(l)&&this.publish({busy:!1,error:so(o)})}}async respond(r){const i=this.value.authorization,l=i&&Ar(i);if(this.disposed||this.value.busy||i?.state!=="pending"||!l||l.id!==r.stepId)return;if(this.deadline(i)<=Date.now()){this.schedule(this.generation);return}const o=this.stop();this.publish({authorization:i,busy:!0});try{const d=await this.transport.respond(i.id,r);return this.accept(d,o,i.id),this.current(o)?d:void 0}catch(d){this.current(o)&&(this.publish({authorization:i,busy:!1,error:so(d)}),this.timer=setTimeout(()=>{this.poll(o)},this.options.retryIntervalMs??4e3))}}async cancel(){const r=this.value.authorization,i=this.stop();if(r?.state!=="pending"){this.publish({busy:!1});return}this.publish({authorization:r,busy:!0});try{const l=await this.transport.cancel(r.id);if(!this.current(i))return;this.publish({busy:!1,authorization:l??{...r,state:"cancelled",step:void 0,prompt:void 0,redirect:void 0}})}catch(l){this.current(i)&&(this.publish({authorization:r,busy:!1,error:so(l)}),this.schedule(i,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 r=this.value.authorization;this.stop(),this.disposed=!0,this.listeners.clear(),r?.state==="pending"&&this.transport.cancel(r.id).catch(()=>{})}}function so(t){return t instanceof Error?t:new Error("连接操作失败,请重试。")}const tf="codeshell.remote-link.authorization.v1",Cf="/api/v1/links/authorizations/",nf="[a-f0-9-]{36}",X1=new RegExp(`^(?:/p/${nf})?${Cf}${nf}$`);function Tf(t){return t==="/link/callback"?"/":t==="/mobile/link/callback"?"/mobile/":void 0}function Z1(t,r){const i=new URL(t),l=new URL(r);if(i.origin!==l.origin||i.pathname!=="/oauth/authorize"||i.username||i.password||i.hash||i.protocol!=="https:"&&!(i.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(i.hostname)))throw new Error("授权地址无效,请检查 Link 服务配置。");return i}function J1(t,r,i,l=window.location.origin,o=window.sessionStorage){const d=Ar(t);if(d?.kind!=="redirect"||!new RegExp(`^${nf}$`).test(t.id))throw new Error("授权请求无效。");const c=Z1(d.authorizationUrl,r),h=c.searchParams.get("state"),f=c.searchParams.get("redirect_uri"),p=Date.parse(d.expiresAt),y=f?Tf(new URL(f,l).pathname):void 0;if(!h||!f||!y||f!==`${l}${y}link/callback`||y==="/mobile/"&&i.projectId!==null||c.searchParams.getAll("state").length!==1||c.searchParams.getAll("redirect_uri").length!==1||!Number.isFinite(p)||p<=Date.now())throw new Error("授权回调地址或有效期无效,请检查服务配置。");const b=Dt(Cf+t.id,i.workspace,i.projectId),v=new URLSearchParams({view:"links",...i.projectId?{project:i.projectId}:{},...y==="/mobile/"?{workspace:i.workspace}:{}});return o.setItem(tf,JSON.stringify({target:b,state:h,redirectUri:f,returnUrl:`${y}?${v}`,expiresAt:p,providerId:t.providerId})),c.href}function W1(t,r,i){const l=Tf(t.pathname);if(!l)return;const o=t.href;r.replaceState(r.state,"",t.pathname);try{const d=i.getItem(tf);i.removeItem(tf);const c=JSON.parse(d??"null");if(!c||!Number.isFinite(c.expiresAt)||c.expiresAt<=Date.now())throw new Error;const h=new URL(o),f=new URL(c.target,t.origin),p=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||f.origin!==t.origin||!X1.test(f.pathname)||f.hash||f.username||f.password||[...f.searchParams.keys()].some(y=>y!=="workspace")||f.searchParams.getAll("workspace").length>1||p.origin!==t.origin||p.pathname!==l||p.username||p.password||p.hash||[...p.searchParams.keys()].some(y=>!(l==="/mobile/"?["workspace","view"]:["project","view"]).includes(y))||p.searchParams.getAll("view").length!==1||p.searchParams.get("view")!=="links"||l==="/mobile/"&&(!f.pathname.startsWith(Cf)||p.searchParams.getAll("workspace").length!==1||p.searchParams.get("workspace")!==(f.searchParams.get("workspace")??"")))throw new Error;return{callbackUrl:o,pending:c,denied:h.searchParams.has("error")}}catch{return{error:"找不到匹配的授权,或授权已过期。请返回原项目重新连接。",home:l}}}async function ew(t){const r=new URL(t.pending.target,window.location.origin),i=Qb(r);return t.denied?(await Je(t.pending.target,{method:"DELETE"},i),{id:"",providerId:t.pending.providerId??"",state:"cancelled"}):(r.pathname+="/complete",Je(r.pathname+r.search,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callbackUrl:t.callbackUrl})},i))}function Qb(t){return{workspace:t.searchParams.get("workspace")??"",projectId:/^\/p\/([a-f0-9-]{36})\//.exec(t.pathname)?.[1]??null}}function tw(t){const r=new URL(t.pending.target,window.location.origin);return Je(t.pending.target,{},Qb(r))}function nw(){const t=Tf(window.location.pathname);if(t)try{return W1(window.location,window.history,window.sessionStorage)}catch{return window.history.replaceState(window.history.state,"",window.location.pathname),{error:"浏览器无法读取原授权记录。请允许此站点保存临时数据后重新连接。",home:t}}}function rw({callback:t}){const r=x.useRef(void 0),[i,l]=x.useState(),[o,d]=x.useState("error"in t?t.error:""),[c,h]=x.useState(!1),f=b=>d(b instanceof it&&b.status===401?"原登录已失效。请返回工作台登录,并重新发起授权。":b instanceof Error?b.message:"无法确认授权结果,请检查结果或返回项目重新连接。"),p=b=>{if(b.state==="connected"&&!b.connection){f(new Error("服务尚未确认连接已保存,请检查授权结果。"));return}l(b),d("")};x.useEffect(()=>{if("error"in t)return;let b=!0;return r.current??=ew(t),r.current.then(v=>{b&&p(v)},v=>{b&&f(v)}),()=>{b=!1}},[t]);const y=!i&&!o;return a.jsx("main",{className:"auth-page",children:a.jsxs("section",{className:"auth-card",children:[a.jsx("h1",{children:"Link 授权"}),y&&a.jsx("p",{role:"status",children:"正在确认授权并保存到原项目…"}),i?.state==="connected"&&a.jsxs("p",{role:"status",children:["已连接 ",i.connection?.account?.label??i.connection?.providerId,",授权已保存到原项目。"]}),i?.previousGrantRevocationPending&&a.jsx("p",{role:"alert",children:"新连接已保存。有遗留授权等待撤销,项目所在环境将自动重试,重启后仍会继续;也可在 Link 服务中撤销。"}),i?.state==="cancelled"&&a.jsx("p",{role:"status",children:"授权已取消,没有新增连接。"}),i?.state==="failed"&&a.jsx("p",{role:"alert",children:"授权未完成。请返回原项目重新连接。"}),i?.state==="pending"&&a.jsx("p",{role:"status",children:"服务端尚未确认完成。可以稍后检查结果,或返回项目重新发起授权。"}),o&&a.jsx("p",{className:"form-error",role:"alert",children:o}),!("error"in t)&&(o||i?.state==="pending")&&a.jsx("button",{disabled:c,onClick:()=>{c||(h(!0),tw(t).then(p,f).finally(()=>h(!1)))},children:c?"正在查询…":"检查授权结果"}),!y&&a.jsx("a",{href:"error"in t?t.home??"/":t.pending.returnUrl,children:"返回原项目"})]})})}var Jc={exports:{}},xl={},Wc={exports:{}},ed={};var Xg;function iw(){return Xg||(Xg=1,(function(t){function r(P,G){var re=P.length;P.push(G);e:for(;0<re;){var be=re-1>>>1,R=P[be];if(0<o(R,G))P[be]=G,P[re]=R,re=be;else break e}}function i(P){return P.length===0?null:P[0]}function l(P){if(P.length===0)return null;var G=P[0],re=P.pop();if(re!==G){P[0]=re;e:for(var be=0,R=P.length,M=R>>>1;be<M;){var te=2*(be+1)-1,k=P[te],W=te+1,ue=P[W];if(0>o(k,re))W<R&&0>o(ue,k)?(P[be]=ue,P[W]=re,be=W):(P[be]=k,P[te]=re,be=te);else if(W<R&&0>o(ue,re))P[be]=ue,P[W]=re,be=W;else break e}}return G}function o(P,G){var re=P.sortIndex-G.sortIndex;return re!==0?re:P.id-G.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 f=[],p=[],y=1,b=null,v=3,w=!1,j=!1,N=!1,C=!1,E=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,D=typeof setImmediate<"u"?setImmediate:null;function L(P){for(var G=i(p);G!==null;){if(G.callback===null)l(p);else if(G.startTime<=P)l(p),G.sortIndex=G.expirationTime,r(f,G);else break;G=i(p)}}function J(P){if(N=!1,L(P),!j)if(i(f)!==null)j=!0,T||(T=!0,H());else{var G=i(p);G!==null&&F(J,G.startTime-P)}}var T=!1,B=-1,U=5,X=-1;function _(){return C?!0:!(t.unstable_now()-X<U)}function I(){if(C=!1,T){var P=t.unstable_now();X=P;var G=!0;try{e:{j=!1,N&&(N=!1,A(B),B=-1),w=!0;var re=v;try{t:{for(L(P),b=i(f);b!==null&&!(b.expirationTime>P&&_());){var be=b.callback;if(typeof be=="function"){b.callback=null,v=b.priorityLevel;var R=be(b.expirationTime<=P);if(P=t.unstable_now(),typeof R=="function"){b.callback=R,L(P),G=!0;break t}b===i(f)&&l(f),L(P)}else l(f);b=i(f)}if(b!==null)G=!0;else{var M=i(p);M!==null&&F(J,M.startTime-P),G=!1}}break e}finally{b=null,v=re,w=!1}G=void 0}}finally{G?H():T=!1}}}var H;if(typeof D=="function")H=function(){D(I)};else if(typeof MessageChannel<"u"){var Y=new MessageChannel,$=Y.port2;Y.port1.onmessage=I,H=function(){$.postMessage(null)}}else H=function(){E(I,0)};function F(P,G){B=E(function(){P(t.unstable_now())},G)}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(P){P.callback=null},t.unstable_forceFrameRate=function(P){0>P||125<P?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):U=0<P?Math.floor(1e3/P):5},t.unstable_getCurrentPriorityLevel=function(){return v},t.unstable_next=function(P){switch(v){case 1:case 2:case 3:var G=3;break;default:G=v}var re=v;v=G;try{return P()}finally{v=re}},t.unstable_requestPaint=function(){C=!0},t.unstable_runWithPriority=function(P,G){switch(P){case 1:case 2:case 3:case 4:case 5:break;default:P=3}var re=v;v=P;try{return G()}finally{v=re}},t.unstable_scheduleCallback=function(P,G,re){var be=t.unstable_now();switch(typeof re=="object"&&re!==null?(re=re.delay,re=typeof re=="number"&&0<re?be+re:be):re=be,P){case 1:var R=-1;break;case 2:R=250;break;case 5:R=1073741823;break;case 4:R=1e4;break;default:R=5e3}return R=re+R,P={id:y++,callback:G,priorityLevel:P,startTime:re,expirationTime:R,sortIndex:-1},re>be?(P.sortIndex=re,r(p,P),i(f)===null&&P===i(p)&&(N?(A(B),B=-1):N=!0,F(J,re-be))):(P.sortIndex=R,r(f,P),j||w||(j=!0,T||(T=!0,H()))),P},t.unstable_shouldYield=_,t.unstable_wrapCallback=function(P){var G=v;return function(){var re=v;v=G;try{return P.apply(this,arguments)}finally{v=re}}}})(ed)),ed}var Zg;function sw(){return Zg||(Zg=1,Wc.exports=iw()),Wc.exports}var td={exports:{}},pn={};var Jg;function lw(){if(Jg)return pn;Jg=1;var t=Ef();function r(f){var p="https://react.dev/errors/"+f;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)p+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+f+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(){}var l={d:{f:i,r:function(){throw Error(r(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for("react.portal");function d(f,p,y){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:b==null?null:""+b,children:f,containerInfo:p,implementation:y}}var c=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(f,p){if(f==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return pn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=l,pn.createPortal=function(f,p){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)throw Error(r(299));return d(f,p,null,y)},pn.flushSync=function(f){var p=c.T,y=l.p;try{if(c.T=null,l.p=2,f)return f()}finally{c.T=p,l.p=y,l.d.f()}},pn.preconnect=function(f,p){typeof f=="string"&&(p?(p=p.crossOrigin,p=typeof p=="string"?p==="use-credentials"?p:"":void 0):p=null,l.d.C(f,p))},pn.prefetchDNS=function(f){typeof f=="string"&&l.d.D(f)},pn.preinit=function(f,p){if(typeof f=="string"&&p&&typeof p.as=="string"){var y=p.as,b=h(y,p.crossOrigin),v=typeof p.integrity=="string"?p.integrity:void 0,w=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;y==="style"?l.d.S(f,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:b,integrity:v,fetchPriority:w}):y==="script"&&l.d.X(f,{crossOrigin:b,integrity:v,fetchPriority:w,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},pn.preinitModule=function(f,p){if(typeof f=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var y=h(p.as,p.crossOrigin);l.d.M(f,{crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0})}}else p==null&&l.d.M(f)},pn.preload=function(f,p){if(typeof f=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var y=p.as,b=h(y,p.crossOrigin);l.d.L(f,y,{crossOrigin:b,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0,type:typeof p.type=="string"?p.type:void 0,fetchPriority:typeof p.fetchPriority=="string"?p.fetchPriority:void 0,referrerPolicy:typeof p.referrerPolicy=="string"?p.referrerPolicy:void 0,imageSrcSet:typeof p.imageSrcSet=="string"?p.imageSrcSet:void 0,imageSizes:typeof p.imageSizes=="string"?p.imageSizes:void 0,media:typeof p.media=="string"?p.media:void 0})}},pn.preloadModule=function(f,p){if(typeof f=="string")if(p){var y=h(p.as,p.crossOrigin);l.d.m(f,{as:typeof p.as=="string"&&p.as!=="script"?p.as:void 0,crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0})}else l.d.m(f)},pn.requestFormReset=function(f){l.d.r(f)},pn.unstable_batchedUpdates=function(f,p){return f(p)},pn.useFormState=function(f,p,y){return c.H.useFormState(f,p,y)},pn.useFormStatus=function(){return c.H.useHostTransitionStatus()},pn.version="19.2.6",pn}var Wg;function Kb(){if(Wg)return td.exports;Wg=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(r){console.error(r)}}return t(),td.exports=lw(),td.exports}var ey;function aw(){if(ey)return xl;ey=1;var t=sw(),r=Ef(),i=Kb();function l(e){var n="https://react.dev/errors/"+e;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var s=2;s<arguments.length;s++)n+="&args[]="+encodeURIComponent(arguments[s])}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 o(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function d(e){var n=e,s=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(s=n.return),e=n.return;while(e)}return n.tag===3?s: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 f(e){if(d(e)!==e)throw Error(l(188))}function p(e){var n=e.alternate;if(!n){if(n=d(e),n===null)throw Error(l(188));return n!==e?null:e}for(var s=e,u=n;;){var m=s.return;if(m===null)break;var g=m.alternate;if(g===null){if(u=m.return,u!==null){s=u;continue}break}if(m.child===g.child){for(g=m.child;g;){if(g===s)return f(m),e;if(g===u)return f(m),n;g=g.sibling}throw Error(l(188))}if(s.return!==u.return)s=m,u=g;else{for(var S=!1,z=m.child;z;){if(z===s){S=!0,s=m,u=g;break}if(z===u){S=!0,u=m,s=g;break}z=z.sibling}if(!S){for(z=g.child;z;){if(z===s){S=!0,s=g,u=m;break}if(z===u){S=!0,u=g,s=m;break}z=z.sibling}if(!S)throw Error(l(189))}}if(s.alternate!==u)throw Error(l(190))}if(s.tag!==3)throw Error(l(188));return s.stateNode.current===s?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"),w=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),D=Symbol.for("react.context"),L=Symbol.for("react.forward_ref"),J=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),B=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),X=Symbol.for("react.activity"),_=Symbol.for("react.memo_cache_sentinel"),I=Symbol.iterator;function H(e){return e===null||typeof e!="object"?null:(e=I&&e[I]||e["@@iterator"],typeof e=="function"?e:null)}var Y=Symbol.for("react.client.reference");function $(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Y?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case N:return"Fragment";case E:return"Profiler";case C:return"StrictMode";case J:return"Suspense";case T:return"SuspenseList";case X:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case j:return"Portal";case D:return e.displayName||"Context";case A:return(e._context.displayName||"Context")+".Consumer";case L:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case B:return n=e.displayName||null,n!==null?n:$(e.type)||"Memo";case U:n=e._payload,e=e._init;try{return $(e(n))}catch{}}return null}var F=Array.isArray,P=r.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,re={pending:!1,data:null,method:null,action:null},be=[],R=-1;function M(e){return{current:e}}function te(e){0>R||(e.current=be[R],be[R]=null,R--)}function k(e,n){R++,be[R]=e.current,e.current=n}var W=M(null),ue=M(null),me=M(null),Q=M(null);function oe(e,n){switch(k(me,n),k(ue,e),k(W,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?pg(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=pg(n),e=mg(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}te(W),k(W,e)}function fe(){te(W),te(ue),te(me)}function ke(e){e.memoizedState!==null&&k(Q,e);var n=W.current,s=mg(n,e.type);n!==s&&(k(ue,e),k(W,s))}function _e(e){ue.current===e&&(te(W),te(ue)),Q.current===e&&(te(Q),ml._currentValue=re)}var Me,Ce;function qe(e){if(Me===void 0)try{throw Error()}catch(s){var n=s.stack.trim().match(/\n( *(at )?)/);Me=n&&n[1]||"",Ce=-1<s.stack.indexOf(`
|
|
2
|
+
at`)?" (<anonymous>)":-1<s.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
|
+
`+Me+e+Ce}var Ge=!1;function lt(e,n){if(!e||Ge)return"";Ge=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var u={DetermineComponentFrameRoot:function(){try{if(n){var je=function(){throw Error()};if(Object.defineProperty(je.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(je,[])}catch(ye){var pe=ye}Reflect.construct(e,[],je)}else{try{je.call()}catch(ye){pe=ye}e.call(je.prototype)}}else{try{throw Error()}catch(ye){pe=ye}(je=e())&&typeof je.catch=="function"&&je.catch(function(){})}}catch(ye){if(ye&&pe&&typeof ye.stack=="string")return[ye.stack,pe.stack]}return[null,null]}};u.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var m=Object.getOwnPropertyDescriptor(u.DetermineComponentFrameRoot,"name");m&&m.configurable&&Object.defineProperty(u.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var g=u.DetermineComponentFrameRoot(),S=g[0],z=g[1];if(S&&z){var K=S.split(`
|
|
4
|
+
`),de=z.split(`
|
|
5
|
+
`);for(m=u=0;u<K.length&&!K[u].includes("DetermineComponentFrameRoot");)u++;for(;m<de.length&&!de[m].includes("DetermineComponentFrameRoot");)m++;if(u===K.length||m===de.length)for(u=K.length-1,m=de.length-1;1<=u&&0<=m&&K[u]!==de[m];)m--;for(;1<=u&&0<=m;u--,m--)if(K[u]!==de[m]){if(u!==1||m!==1)do if(u--,m--,0>m||K[u]!==de[m]){var ve=`
|
|
6
|
+
`+K[u].replace(" at new "," at ");return e.displayName&&ve.includes("<anonymous>")&&(ve=ve.replace("<anonymous>",e.displayName)),ve}while(1<=u&&0<=m);break}}}finally{Ge=!1,Error.prepareStackTrace=s}return(s=e?e.displayName||e.name:"")?qe(s):""}function De(e,n){switch(e.tag){case 26:case 27:case 5:return qe(e.type);case 16:return qe("Lazy");case 13:return e.child!==n&&n!==null?qe("Suspense Fallback"):qe("Suspense");case 19:return qe("SuspenseList");case 0:case 15:return lt(e.type,!1);case 11:return lt(e.type.render,!1);case 1:return lt(e.type,!0);case 31:return qe("Activity");default:return""}}function Oe(e){try{var n="",s=null;do n+=De(e,s),s=e,e=e.return;while(e);return n}catch(u){return`
|
|
7
|
+
Error generating stack: `+u.message+`
|
|
8
|
+
`+u.stack}}var ht=Object.prototype.hasOwnProperty,at=t.unstable_scheduleCallback,dt=t.unstable_cancelCallback,Ke=t.unstable_shouldYield,rt=t.unstable_requestPaint,Ve=t.unstable_now,nt=t.unstable_getCurrentPriorityLevel,q=t.unstable_ImmediatePriority,ne=t.unstable_UserBlockingPriority,Ee=t.unstable_NormalPriority,xe=t.unstable_LowPriority,ze=t.unstable_IdlePriority,Le=t.log,se=t.unstable_setDisableYieldValue,Re=null,Ne=null;function Qe(e){if(typeof Le=="function"&&se(e),Ne&&typeof Ne.setStrictMode=="function")try{Ne.setStrictMode(Re,e)}catch{}}var Ue=Math.clz32?Math.clz32:Be,bt=Math.log,pt=Math.LN2;function Be(e){return e>>>=0,e===0?32:31-(bt(e)/pt|0)|0}var ie=256,O=262144,le=4194304;function we(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 Z(e,n,s){var u=e.pendingLanes;if(u===0)return 0;var m=0,g=e.suspendedLanes,S=e.pingedLanes;e=e.warmLanes;var z=u&134217727;return z!==0?(u=z&~g,u!==0?m=we(u):(S&=z,S!==0?m=we(S):s||(s=z&~e,s!==0&&(m=we(s))))):(z=u&~g,z!==0?m=we(z):S!==0?m=we(S):s||(s=u&~e,s!==0&&(m=we(s)))),m===0?0:n!==0&&n!==m&&(n&g)===0&&(g=m&-m,s=n&-n,g>=s||g===32&&(s&4194048)!==0)?n:m}function Te(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)===0}function V(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 ge(){var e=le;return le<<=1,(le&62914560)===0&&(le=4194304),e}function Ye(e){for(var n=[],s=0;31>s;s++)n.push(e);return n}function Ct(e,n){e.pendingLanes|=n,n!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function he(e,n,s,u,m,g){var S=e.pendingLanes;e.pendingLanes=s,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=s,e.entangledLanes&=s,e.errorRecoveryDisabledLanes&=s,e.shellSuspendCounter=0;var z=e.entanglements,K=e.expirationTimes,de=e.hiddenUpdates;for(s=S&~s;0<s;){var ve=31-Ue(s),je=1<<ve;z[ve]=0,K[ve]=-1;var pe=de[ve];if(pe!==null)for(de[ve]=null,ve=0;ve<pe.length;ve++){var ye=pe[ve];ye!==null&&(ye.lane&=-536870913)}s&=~je}u!==0&&Ie(e,u,0),g!==0&&m===0&&e.tag!==0&&(e.suspendedLanes|=g&~(S&~n))}function Ie(e,n,s){e.pendingLanes|=n,e.suspendedLanes&=~n;var u=31-Ue(n);e.entangledLanes|=n,e.entanglements[u]=e.entanglements[u]|1073741824|s&261930}function Pe(e,n){var s=e.entangledLanes|=n;for(e=e.entanglements;s;){var u=31-Ue(s),m=1<<u;m&n|e[u]&n&&(e[u]|=n),s&=~m}}function ot(e,n){var s=n&-n;return s=(s&42)!==0?1:Fe(s),(s&(e.suspendedLanes|n))!==0?0:s}function Fe(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 At(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Xt(){var e=G.p;return e!==0?e:(e=window.event,e===void 0?32:Bg(e.type))}function Rt(e,n){var s=G.p;try{return G.p=e,n()}finally{G.p=s}}var st=Math.random().toString(36).slice(2),yt="__reactFiber$"+st,et="__reactProps$"+st,xt="__reactContainer$"+st,ut="__reactEvents$"+st,_i="__reactListeners$"+st,un="__reactHandles$"+st,$l="__reactResources$"+st,zr="__reactMarker$"+st;function Ho(e){delete e[yt],delete e[et],delete e[ut],delete e[_i],delete e[un]}function Mi(e){var n=e[yt];if(n)return n;for(var s=e.parentNode;s;){if(n=s[xt]||s[yt]){if(s=n.alternate,n.child!==null||s!==null&&s.child!==null)for(e=Sg(e);e!==null;){if(s=e[yt])return s;e=Sg(e)}return n}e=s,s=e.parentNode}return null}function Di(e){if(e=e[yt]||e[xt]){var n=e.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return e}return null}function zs(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e.stateNode;throw Error(l(33))}function Oi(e){var n=e[$l];return n||(n=e[$l]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function ln(e){e[zr]=!0}var nh=new Set,rh={};function si(e,n){Li(e,n),Li(e+"Capture",n)}function Li(e,n){for(rh[e]=n,e=0;e<n.length;e++)nh.add(n[e])}var Nx=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]*$"),ih={},sh={};function Ax(e){return ht.call(sh,e)?!0:ht.call(ih,e)?!1:Nx.test(e)?sh[e]=!0:(ih[e]=!0,!1)}function Gl(e,n,s){if(Ax(n))if(s===null)e.removeAttribute(n);else{switch(typeof s){case"undefined":case"function":case"symbol":e.removeAttribute(n);return;case"boolean":var u=n.toLowerCase().slice(0,5);if(u!=="data-"&&u!=="aria-"){e.removeAttribute(n);return}}e.setAttribute(n,""+s)}}function Vl(e,n,s){if(s===null)e.removeAttribute(n);else{switch(typeof s){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttribute(n,""+s)}}function ur(e,n,s,u){if(u===null)e.removeAttribute(s);else{switch(typeof u){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(s);return}e.setAttributeNS(n,s,""+u)}}function Ln(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function lh(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function Rx(e,n,s){var u=Object.getOwnPropertyDescriptor(e.constructor.prototype,n);if(!e.hasOwnProperty(n)&&typeof u<"u"&&typeof u.get=="function"&&typeof u.set=="function"){var m=u.get,g=u.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return m.call(this)},set:function(S){s=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:u.enumerable}),{getValue:function(){return s},setValue:function(S){s=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function Po(e){if(!e._valueTracker){var n=lh(e)?"checked":"value";e._valueTracker=Rx(e,n,""+e[n])}}function ah(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var s=n.getValue(),u="";return e&&(u=lh(e)?e.checked?"true":"false":e.value),e=u,e!==s?(n.setValue(e),!0):!1}function Yl(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 zx=/[\n"\\]/g;function In(e){return e.replace(zx,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function Fo(e,n,s,u,m,g,S,z){e.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?e.type=S:e.removeAttribute("type"),n!=null?S==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+Ln(n)):e.value!==""+Ln(n)&&(e.value=""+Ln(n)):S!=="submit"&&S!=="reset"||e.removeAttribute("value"),n!=null?$o(e,S,Ln(n)):s!=null?$o(e,S,Ln(s)):u!=null&&e.removeAttribute("value"),m==null&&g!=null&&(e.defaultChecked=!!g),m!=null&&(e.checked=m&&typeof m!="function"&&typeof m!="symbol"),z!=null&&typeof z!="function"&&typeof z!="symbol"&&typeof z!="boolean"?e.name=""+Ln(z):e.removeAttribute("name")}function oh(e,n,s,u,m,g,S,z){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(e.type=g),n!=null||s!=null){if(!(g!=="submit"&&g!=="reset"||n!=null)){Po(e);return}s=s!=null?""+Ln(s):"",n=n!=null?""+Ln(n):s,z||n===e.value||(e.value=n),e.defaultValue=n}u=u??m,u=typeof u!="function"&&typeof u!="symbol"&&!!u,e.checked=z?e.checked:!!u,e.defaultChecked=!!u,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(e.name=S),Po(e)}function $o(e,n,s){n==="number"&&Yl(e.ownerDocument)===e||e.defaultValue===""+s||(e.defaultValue=""+s)}function Ii(e,n,s,u){if(e=e.options,n){n={};for(var m=0;m<s.length;m++)n["$"+s[m]]=!0;for(s=0;s<e.length;s++)m=n.hasOwnProperty("$"+e[s].value),e[s].selected!==m&&(e[s].selected=m),m&&u&&(e[s].defaultSelected=!0)}else{for(s=""+Ln(s),n=null,m=0;m<e.length;m++){if(e[m].value===s){e[m].selected=!0,u&&(e[m].defaultSelected=!0);return}n!==null||e[m].disabled||(n=e[m])}n!==null&&(n.selected=!0)}}function uh(e,n,s){if(n!=null&&(n=""+Ln(n),n!==e.value&&(e.value=n),s==null)){e.defaultValue!==n&&(e.defaultValue=n);return}e.defaultValue=s!=null?""+Ln(s):""}function ch(e,n,s,u){if(n==null){if(u!=null){if(s!=null)throw Error(l(92));if(F(u)){if(1<u.length)throw Error(l(93));u=u[0]}s=u}s==null&&(s=""),n=s}s=Ln(n),e.defaultValue=s,u=e.textContent,u===s&&u!==""&&u!==null&&(e.value=u),Po(e)}function Bi(e,n){if(n){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=n;return}}e.textContent=n}var _x=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 dh(e,n,s){var u=n.indexOf("--")===0;s==null||typeof s=="boolean"||s===""?u?e.setProperty(n,""):n==="float"?e.cssFloat="":e[n]="":u?e.setProperty(n,s):typeof s!="number"||s===0||_x.has(n)?n==="float"?e.cssFloat=s:e[n]=(""+s).trim():e[n]=s+"px"}function fh(e,n,s){if(n!=null&&typeof n!="object")throw Error(l(62));if(e=e.style,s!=null){for(var u in s)!s.hasOwnProperty(u)||n!=null&&n.hasOwnProperty(u)||(u.indexOf("--")===0?e.setProperty(u,""):u==="float"?e.cssFloat="":e[u]="");for(var m in n)u=n[m],n.hasOwnProperty(m)&&s[m]!==u&&dh(e,m,u)}else for(var g in n)n.hasOwnProperty(g)&&dh(e,g,n[g])}function Go(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 Mx=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"]]),Dx=/^[\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 Ql(e){return Dx.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function cr(){}var Vo=null;function Yo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var qi=null,Ui=null;function hh(e){var n=Di(e);if(n&&(e=n.stateNode)){var s=e[et]||null;e:switch(e=n.stateNode,n.type){case"input":if(Fo(e,s.value,s.defaultValue,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name),n=s.name,s.type==="radio"&&n!=null){for(s=e;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll('input[name="'+In(""+n)+'"][type="radio"]'),n=0;n<s.length;n++){var u=s[n];if(u!==e&&u.form===e.form){var m=u[et]||null;if(!m)throw Error(l(90));Fo(u,m.value,m.defaultValue,m.defaultValue,m.checked,m.defaultChecked,m.type,m.name)}}for(n=0;n<s.length;n++)u=s[n],u.form===e.form&&ah(u)}break e;case"textarea":uh(e,s.value,s.defaultValue);break e;case"select":n=s.value,n!=null&&Ii(e,!!s.multiple,n,!1)}}}var Qo=!1;function ph(e,n,s){if(Qo)return e(n,s);Qo=!0;try{var u=e(n);return u}finally{if(Qo=!1,(qi!==null||Ui!==null)&&(Oa(),qi&&(n=qi,e=Ui,Ui=qi=null,hh(n),e)))for(n=0;n<e.length;n++)hh(e[n])}}function _s(e,n){var s=e.stateNode;if(s===null)return null;var u=s[et]||null;if(u===null)return null;s=u[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":(u=!u.disabled)||(e=e.type,u=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!u;break e;default:e=!1}if(e)return null;if(s&&typeof s!="function")throw Error(l(231,n,typeof s));return s}var dr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ko=!1;if(dr)try{var Ms={};Object.defineProperty(Ms,"passive",{get:function(){Ko=!0}}),window.addEventListener("test",Ms,Ms),window.removeEventListener("test",Ms,Ms)}catch{Ko=!1}var _r=null,Xo=null,Kl=null;function mh(){if(Kl)return Kl;var e,n=Xo,s=n.length,u,m="value"in _r?_r.value:_r.textContent,g=m.length;for(e=0;e<s&&n[e]===m[e];e++);var S=s-e;for(u=1;u<=S&&n[s-u]===m[g-u];u++);return Kl=m.slice(e,1<u?1-u:void 0)}function Xl(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 Zl(){return!0}function gh(){return!1}function vn(e){function n(s,u,m,g,S){this._reactName=s,this._targetInst=m,this.type=u,this.nativeEvent=g,this.target=S,this.currentTarget=null;for(var z in e)e.hasOwnProperty(z)&&(s=e[z],this[z]=s?s(g):g[z]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?Zl:gh,this.isPropagationStopped=gh,this}return b(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=Zl)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=Zl)},persist:function(){},isPersistent:Zl}),n}var li={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Jl=vn(li),Ds=b({},li,{view:0,detail:0}),Ox=vn(Ds),Zo,Jo,Os,Wl=b({},Ds,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:eu,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!==Os&&(Os&&e.type==="mousemove"?(Zo=e.screenX-Os.screenX,Jo=e.screenY-Os.screenY):Jo=Zo=0,Os=e),Zo)},movementY:function(e){return"movementY"in e?e.movementY:Jo}}),yh=vn(Wl),Lx=b({},Wl,{dataTransfer:0}),Ix=vn(Lx),Bx=b({},Ds,{relatedTarget:0}),Wo=vn(Bx),qx=b({},li,{animationName:0,elapsedTime:0,pseudoElement:0}),Ux=vn(qx),Hx=b({},li,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Px=vn(Hx),Fx=b({},li,{data:0}),bh=vn(Fx),$x={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Gx={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"},Vx={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Yx(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=Vx[e])?!!n[e]:!1}function eu(){return Yx}var Qx=b({},Ds,{key:function(e){if(e.key){var n=$x[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=Xl(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Gx[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:eu,charCode:function(e){return e.type==="keypress"?Xl(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Xl(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Kx=vn(Qx),Xx=b({},Wl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),vh=vn(Xx),Zx=b({},Ds,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:eu}),Jx=vn(Zx),Wx=b({},li,{propertyName:0,elapsedTime:0,pseudoElement:0}),e0=vn(Wx),t0=b({},Wl,{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}),n0=vn(t0),r0=b({},li,{newState:0,oldState:0}),i0=vn(r0),s0=[9,13,27,32],tu=dr&&"CompositionEvent"in window,Ls=null;dr&&"documentMode"in document&&(Ls=document.documentMode);var l0=dr&&"TextEvent"in window&&!Ls,xh=dr&&(!tu||Ls&&8<Ls&&11>=Ls),wh=" ",Sh=!1;function jh(e,n){switch(e){case"keyup":return s0.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function kh(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Hi=!1;function a0(e,n){switch(e){case"compositionend":return kh(n);case"keypress":return n.which!==32?null:(Sh=!0,wh);case"textInput":return e=n.data,e===wh&&Sh?null:e;default:return null}}function o0(e,n){if(Hi)return e==="compositionend"||!tu&&jh(e,n)?(e=mh(),Kl=Xo=_r=null,Hi=!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 xh&&n.locale!=="ko"?null:n.data;default:return null}}var u0={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 Eh(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!u0[e.type]:n==="textarea"}function Ch(e,n,s,u){qi?Ui?Ui.push(u):Ui=[u]:qi=u,n=Pa(n,"onChange"),0<n.length&&(s=new Jl("onChange","change",null,s,u),e.push({event:s,listeners:n}))}var Is=null,Bs=null;function c0(e){og(e,0)}function ea(e){var n=zs(e);if(ah(n))return e}function Th(e,n){if(e==="change")return n}var Nh=!1;if(dr){var nu;if(dr){var ru="oninput"in document;if(!ru){var Ah=document.createElement("div");Ah.setAttribute("oninput","return;"),ru=typeof Ah.oninput=="function"}nu=ru}else nu=!1;Nh=nu&&(!document.documentMode||9<document.documentMode)}function Rh(){Is&&(Is.detachEvent("onpropertychange",zh),Bs=Is=null)}function zh(e){if(e.propertyName==="value"&&ea(Bs)){var n=[];Ch(n,Bs,e,Yo(e)),ph(c0,n)}}function d0(e,n,s){e==="focusin"?(Rh(),Is=n,Bs=s,Is.attachEvent("onpropertychange",zh)):e==="focusout"&&Rh()}function f0(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return ea(Bs)}function h0(e,n){if(e==="click")return ea(n)}function p0(e,n){if(e==="input"||e==="change")return ea(n)}function m0(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var Tn=typeof Object.is=="function"?Object.is:m0;function qs(e,n){if(Tn(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var s=Object.keys(e),u=Object.keys(n);if(s.length!==u.length)return!1;for(u=0;u<s.length;u++){var m=s[u];if(!ht.call(n,m)||!Tn(e[m],n[m]))return!1}return!0}function _h(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Mh(e,n){var s=_h(e);e=0;for(var u;s;){if(s.nodeType===3){if(u=e+s.textContent.length,e<=n&&u>=n)return{node:s,offset:n-e};e=u}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=_h(s)}}function Dh(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Dh(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Oh(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var n=Yl(e.document);n instanceof e.HTMLIFrameElement;){try{var s=typeof n.contentWindow.location.href=="string"}catch{s=!1}if(s)e=n.contentWindow;else break;n=Yl(e.document)}return n}function iu(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 g0=dr&&"documentMode"in document&&11>=document.documentMode,Pi=null,su=null,Us=null,lu=!1;function Lh(e,n,s){var u=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;lu||Pi==null||Pi!==Yl(u)||(u=Pi,"selectionStart"in u&&iu(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),Us&&qs(Us,u)||(Us=u,u=Pa(su,"onSelect"),0<u.length&&(n=new Jl("onSelect","select",null,n,s),e.push({event:n,listeners:u}),n.target=Pi)))}function ai(e,n){var s={};return s[e.toLowerCase()]=n.toLowerCase(),s["Webkit"+e]="webkit"+n,s["Moz"+e]="moz"+n,s}var Fi={animationend:ai("Animation","AnimationEnd"),animationiteration:ai("Animation","AnimationIteration"),animationstart:ai("Animation","AnimationStart"),transitionrun:ai("Transition","TransitionRun"),transitionstart:ai("Transition","TransitionStart"),transitioncancel:ai("Transition","TransitionCancel"),transitionend:ai("Transition","TransitionEnd")},au={},Ih={};dr&&(Ih=document.createElement("div").style,"AnimationEvent"in window||(delete Fi.animationend.animation,delete Fi.animationiteration.animation,delete Fi.animationstart.animation),"TransitionEvent"in window||delete Fi.transitionend.transition);function oi(e){if(au[e])return au[e];if(!Fi[e])return e;var n=Fi[e],s;for(s in n)if(n.hasOwnProperty(s)&&s in Ih)return au[e]=n[s];return e}var Bh=oi("animationend"),qh=oi("animationiteration"),Uh=oi("animationstart"),y0=oi("transitionrun"),b0=oi("transitionstart"),v0=oi("transitioncancel"),Hh=oi("transitionend"),Ph=new Map,ou="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(" ");ou.push("scrollEnd");function Yn(e,n){Ph.set(e,n),si(n,[e])}var ta=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)},Bn=[],$i=0,uu=0;function na(){for(var e=$i,n=uu=$i=0;n<e;){var s=Bn[n];Bn[n++]=null;var u=Bn[n];Bn[n++]=null;var m=Bn[n];Bn[n++]=null;var g=Bn[n];if(Bn[n++]=null,u!==null&&m!==null){var S=u.pending;S===null?m.next=m:(m.next=S.next,S.next=m),u.pending=m}g!==0&&Fh(s,m,g)}}function ra(e,n,s,u){Bn[$i++]=e,Bn[$i++]=n,Bn[$i++]=s,Bn[$i++]=u,uu|=u,e.lanes|=u,e=e.alternate,e!==null&&(e.lanes|=u)}function cu(e,n,s,u){return ra(e,n,s,u),ia(e)}function ui(e,n){return ra(e,null,null,n),ia(e)}function Fh(e,n,s){e.lanes|=s;var u=e.alternate;u!==null&&(u.lanes|=s);for(var m=!1,g=e.return;g!==null;)g.childLanes|=s,u=g.alternate,u!==null&&(u.childLanes|=s),g.tag===22&&(e=g.stateNode,e===null||e._visibility&1||(m=!0)),e=g,g=g.return;return e.tag===3?(g=e.stateNode,m&&n!==null&&(m=31-Ue(s),e=g.hiddenUpdates,u=e[m],u===null?e[m]=[n]:u.push(n),n.lane=s|536870912),g):null}function ia(e){if(50<ol)throw ol=0,vc=null,Error(l(185));for(var n=e.return;n!==null;)e=n,n=e.return;return e.tag===3?e.stateNode:null}var Gi={};function x0(e,n,s,u){this.tag=e,this.key=s,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=u,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Nn(e,n,s,u){return new x0(e,n,s,u)}function du(e){return e=e.prototype,!(!e||!e.isReactComponent)}function fr(e,n){var s=e.alternate;return s===null?(s=Nn(e.tag,n,e.key,e.mode),s.elementType=e.elementType,s.type=e.type,s.stateNode=e.stateNode,s.alternate=e,e.alternate=s):(s.pendingProps=n,s.type=e.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=e.flags&65011712,s.childLanes=e.childLanes,s.lanes=e.lanes,s.child=e.child,s.memoizedProps=e.memoizedProps,s.memoizedState=e.memoizedState,s.updateQueue=e.updateQueue,n=e.dependencies,s.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},s.sibling=e.sibling,s.index=e.index,s.ref=e.ref,s.refCleanup=e.refCleanup,s}function $h(e,n){e.flags&=65011714;var s=e.alternate;return s===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=s.childLanes,e.lanes=s.lanes,e.child=s.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=s.memoizedProps,e.memoizedState=s.memoizedState,e.updateQueue=s.updateQueue,e.type=s.type,n=s.dependencies,e.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),e}function sa(e,n,s,u,m,g){var S=0;if(u=e,typeof e=="function")du(e)&&(S=1);else if(typeof e=="string")S=E1(e,s,W.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case X:return e=Nn(31,s,n,m),e.elementType=X,e.lanes=g,e;case N:return ci(s.children,m,g,n);case C:S=8,m|=24;break;case E:return e=Nn(12,s,n,m|2),e.elementType=E,e.lanes=g,e;case J:return e=Nn(13,s,n,m),e.elementType=J,e.lanes=g,e;case T:return e=Nn(19,s,n,m),e.elementType=T,e.lanes=g,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case D:S=10;break e;case A:S=9;break e;case L:S=11;break e;case B:S=14;break e;case U:S=16,u=null;break e}S=29,s=Error(l(130,e===null?"null":typeof e,"")),u=null}return n=Nn(S,s,n,m),n.elementType=e,n.type=u,n.lanes=g,n}function ci(e,n,s,u){return e=Nn(7,e,u,n),e.lanes=s,e}function fu(e,n,s){return e=Nn(6,e,null,n),e.lanes=s,e}function Gh(e){var n=Nn(18,null,null,0);return n.stateNode=e,n}function hu(e,n,s){return n=Nn(4,e.children!==null?e.children:[],e.key,n),n.lanes=s,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}var Vh=new WeakMap;function qn(e,n){if(typeof e=="object"&&e!==null){var s=Vh.get(e);return s!==void 0?s:(n={value:e,source:n,stack:Oe(n)},Vh.set(e,n),n)}return{value:e,source:n,stack:Oe(n)}}var Vi=[],Yi=0,la=null,Hs=0,Un=[],Hn=0,Mr=null,Wn=1,er="";function hr(e,n){Vi[Yi++]=Hs,Vi[Yi++]=la,la=e,Hs=n}function Yh(e,n,s){Un[Hn++]=Wn,Un[Hn++]=er,Un[Hn++]=Mr,Mr=e;var u=Wn;e=er;var m=32-Ue(u)-1;u&=~(1<<m),s+=1;var g=32-Ue(n)+m;if(30<g){var S=m-m%5;g=(u&(1<<S)-1).toString(32),u>>=S,m-=S,Wn=1<<32-Ue(n)+m|s<<m|u,er=g+e}else Wn=1<<g|s<<m|u,er=e}function pu(e){e.return!==null&&(hr(e,1),Yh(e,1,0))}function mu(e){for(;e===la;)la=Vi[--Yi],Vi[Yi]=null,Hs=Vi[--Yi],Vi[Yi]=null;for(;e===Mr;)Mr=Un[--Hn],Un[Hn]=null,er=Un[--Hn],Un[Hn]=null,Wn=Un[--Hn],Un[Hn]=null}function Qh(e,n){Un[Hn++]=Wn,Un[Hn++]=er,Un[Hn++]=Mr,Wn=n.id,er=n.overflow,Mr=e}var cn=null,Ft=null,Tt=!1,Dr=null,Pn=!1,gu=Error(l(519));function Or(e){var n=Error(l(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ps(qn(n,e)),gu}function Kh(e){var n=e.stateNode,s=e.type,u=e.memoizedProps;switch(n[yt]=e,n[et]=u,s){case"dialog":St("cancel",n),St("close",n);break;case"iframe":case"object":case"embed":St("load",n);break;case"video":case"audio":for(s=0;s<cl.length;s++)St(cl[s],n);break;case"source":St("error",n);break;case"img":case"image":case"link":St("error",n),St("load",n);break;case"details":St("toggle",n);break;case"input":St("invalid",n),oh(n,u.value,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name,!0);break;case"select":St("invalid",n);break;case"textarea":St("invalid",n),ch(n,u.value,u.defaultValue,u.children)}s=u.children,typeof s!="string"&&typeof s!="number"&&typeof s!="bigint"||n.textContent===""+s||u.suppressHydrationWarning===!0||fg(n.textContent,s)?(u.popover!=null&&(St("beforetoggle",n),St("toggle",n)),u.onScroll!=null&&St("scroll",n),u.onScrollEnd!=null&&St("scrollend",n),u.onClick!=null&&(n.onclick=cr),n=!0):n=!1,n||Or(e,!0)}function Xh(e){for(cn=e.return;cn;)switch(cn.tag){case 5:case 31:case 13:Pn=!1;return;case 27:case 3:Pn=!0;return;default:cn=cn.return}}function Qi(e){if(e!==cn)return!1;if(!Tt)return Xh(e),Tt=!0,!1;var n=e.tag,s;if((s=n!==3&&n!==27)&&((s=n===5)&&(s=e.type,s=!(s!=="form"&&s!=="button")||Dc(e.type,e.memoizedProps)),s=!s),s&&Ft&&Or(e),Xh(e),n===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(l(317));Ft=wg(e)}else if(n===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(l(317));Ft=wg(e)}else n===27?(n=Ft,Kr(e.type)?(e=qc,qc=null,Ft=e):Ft=n):Ft=cn?$n(e.stateNode.nextSibling):null;return!0}function di(){Ft=cn=null,Tt=!1}function yu(){var e=Dr;return e!==null&&(jn===null?jn=e:jn.push.apply(jn,e),Dr=null),e}function Ps(e){Dr===null?Dr=[e]:Dr.push(e)}var bu=M(null),fi=null,pr=null;function Lr(e,n,s){k(bu,n._currentValue),n._currentValue=s}function mr(e){e._currentValue=bu.current,te(bu)}function vu(e,n,s){for(;e!==null;){var u=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,u!==null&&(u.childLanes|=n)):u!==null&&(u.childLanes&n)!==n&&(u.childLanes|=n),e===s)break;e=e.return}}function xu(e,n,s,u){var m=e.child;for(m!==null&&(m.return=e);m!==null;){var g=m.dependencies;if(g!==null){var S=m.child;g=g.firstContext;e:for(;g!==null;){var z=g;g=m;for(var K=0;K<n.length;K++)if(z.context===n[K]){g.lanes|=s,z=g.alternate,z!==null&&(z.lanes|=s),vu(g.return,s,e),u||(S=null);break e}g=z.next}}else if(m.tag===18){if(S=m.return,S===null)throw Error(l(341));S.lanes|=s,g=S.alternate,g!==null&&(g.lanes|=s),vu(S,s,e),S=null}else S=m.child;if(S!==null)S.return=m;else for(S=m;S!==null;){if(S===e){S=null;break}if(m=S.sibling,m!==null){m.return=S.return,S=m;break}S=S.return}m=S}}function Ki(e,n,s,u){e=null;for(var m=n,g=!1;m!==null;){if(!g){if((m.flags&524288)!==0)g=!0;else if((m.flags&262144)!==0)break}if(m.tag===10){var S=m.alternate;if(S===null)throw Error(l(387));if(S=S.memoizedProps,S!==null){var z=m.type;Tn(m.pendingProps.value,S.value)||(e!==null?e.push(z):e=[z])}}else if(m===Q.current){if(S=m.alternate,S===null)throw Error(l(387));S.memoizedState.memoizedState!==m.memoizedState.memoizedState&&(e!==null?e.push(ml):e=[ml])}m=m.return}e!==null&&xu(n,e,s,u),n.flags|=262144}function aa(e){for(e=e.firstContext;e!==null;){if(!Tn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function hi(e){fi=e,pr=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function dn(e){return Zh(fi,e)}function oa(e,n){return fi===null&&hi(e),Zh(e,n)}function Zh(e,n){var s=n._currentValue;if(n={context:n,memoizedValue:s,next:null},pr===null){if(e===null)throw Error(l(308));pr=n,e.dependencies={lanes:0,firstContext:n},e.flags|=524288}else pr=pr.next=n;return s}var w0=typeof AbortController<"u"?AbortController:function(){var e=[],n=this.signal={aborted:!1,addEventListener:function(s,u){e.push(u)}};this.abort=function(){n.aborted=!0,e.forEach(function(s){return s()})}},S0=t.unstable_scheduleCallback,j0=t.unstable_NormalPriority,Wt={$$typeof:D,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function wu(){return{controller:new w0,data:new Map,refCount:0}}function Fs(e){e.refCount--,e.refCount===0&&S0(j0,function(){e.controller.abort()})}var $s=null,Su=0,Xi=0,Zi=null;function k0(e,n){if($s===null){var s=$s=[];Su=0,Xi=Ec(),Zi={status:"pending",value:void 0,then:function(u){s.push(u)}}}return Su++,n.then(Jh,Jh),n}function Jh(){if(--Su===0&&$s!==null){Zi!==null&&(Zi.status="fulfilled");var e=$s;$s=null,Xi=0,Zi=null;for(var n=0;n<e.length;n++)(0,e[n])()}}function E0(e,n){var s=[],u={status:"pending",value:null,reason:null,then:function(m){s.push(m)}};return e.then(function(){u.status="fulfilled",u.value=n;for(var m=0;m<s.length;m++)(0,s[m])(n)},function(m){for(u.status="rejected",u.reason=m,m=0;m<s.length;m++)(0,s[m])(void 0)}),u}var Wh=P.S;P.S=function(e,n){Lm=Ve(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&k0(e,n),Wh!==null&&Wh(e,n)};var pi=M(null);function ju(){var e=pi.current;return e!==null?e:Ut.pooledCache}function ua(e,n){n===null?k(pi,pi.current):k(pi,n.pool)}function ep(){var e=ju();return e===null?null:{parent:Wt._currentValue,pool:e}}var Ji=Error(l(460)),ku=Error(l(474)),ca=Error(l(542)),da={then:function(){}};function tp(e){return e=e.status,e==="fulfilled"||e==="rejected"}function np(e,n,s){switch(s=e[s],s===void 0?e.push(n):s!==n&&(n.then(cr,cr),n=s),n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,ip(e),e;default:if(typeof n.status=="string")n.then(cr,cr);else{if(e=Ut,e!==null&&100<e.shellSuspendCounter)throw Error(l(482));e=n,e.status="pending",e.then(function(u){if(n.status==="pending"){var m=n;m.status="fulfilled",m.value=u}},function(u){if(n.status==="pending"){var m=n;m.status="rejected",m.reason=u}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,ip(e),e}throw gi=n,Ji}}function mi(e){try{var n=e._init;return n(e._payload)}catch(s){throw s!==null&&typeof s=="object"&&typeof s.then=="function"?(gi=s,Ji):s}}var gi=null;function rp(){if(gi===null)throw Error(l(459));var e=gi;return gi=null,e}function ip(e){if(e===Ji||e===ca)throw Error(l(483))}var Wi=null,Gs=0;function fa(e){var n=Gs;return Gs+=1,Wi===null&&(Wi=[]),np(Wi,e,n)}function Vs(e,n){n=n.props.ref,e.ref=n!==void 0?n:null}function ha(e,n){throw n.$$typeof===v?Error(l(525)):(e=Object.prototype.toString.call(n),Error(l(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e)))}function sp(e){function n(ae,ee){if(e){var ce=ae.deletions;ce===null?(ae.deletions=[ee],ae.flags|=16):ce.push(ee)}}function s(ae,ee){if(!e)return null;for(;ee!==null;)n(ae,ee),ee=ee.sibling;return null}function u(ae){for(var ee=new Map;ae!==null;)ae.key!==null?ee.set(ae.key,ae):ee.set(ae.index,ae),ae=ae.sibling;return ee}function m(ae,ee){return ae=fr(ae,ee),ae.index=0,ae.sibling=null,ae}function g(ae,ee,ce){return ae.index=ce,e?(ce=ae.alternate,ce!==null?(ce=ce.index,ce<ee?(ae.flags|=67108866,ee):ce):(ae.flags|=67108866,ee)):(ae.flags|=1048576,ee)}function S(ae){return e&&ae.alternate===null&&(ae.flags|=67108866),ae}function z(ae,ee,ce,Se){return ee===null||ee.tag!==6?(ee=fu(ce,ae.mode,Se),ee.return=ae,ee):(ee=m(ee,ce),ee.return=ae,ee)}function K(ae,ee,ce,Se){var Xe=ce.type;return Xe===N?ve(ae,ee,ce.props.children,Se,ce.key):ee!==null&&(ee.elementType===Xe||typeof Xe=="object"&&Xe!==null&&Xe.$$typeof===U&&mi(Xe)===ee.type)?(ee=m(ee,ce.props),Vs(ee,ce),ee.return=ae,ee):(ee=sa(ce.type,ce.key,ce.props,null,ae.mode,Se),Vs(ee,ce),ee.return=ae,ee)}function de(ae,ee,ce,Se){return ee===null||ee.tag!==4||ee.stateNode.containerInfo!==ce.containerInfo||ee.stateNode.implementation!==ce.implementation?(ee=hu(ce,ae.mode,Se),ee.return=ae,ee):(ee=m(ee,ce.children||[]),ee.return=ae,ee)}function ve(ae,ee,ce,Se,Xe){return ee===null||ee.tag!==7?(ee=ci(ce,ae.mode,Se,Xe),ee.return=ae,ee):(ee=m(ee,ce),ee.return=ae,ee)}function je(ae,ee,ce){if(typeof ee=="string"&&ee!==""||typeof ee=="number"||typeof ee=="bigint")return ee=fu(""+ee,ae.mode,ce),ee.return=ae,ee;if(typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case w:return ce=sa(ee.type,ee.key,ee.props,null,ae.mode,ce),Vs(ce,ee),ce.return=ae,ce;case j:return ee=hu(ee,ae.mode,ce),ee.return=ae,ee;case U:return ee=mi(ee),je(ae,ee,ce)}if(F(ee)||H(ee))return ee=ci(ee,ae.mode,ce,null),ee.return=ae,ee;if(typeof ee.then=="function")return je(ae,fa(ee),ce);if(ee.$$typeof===D)return je(ae,oa(ae,ee),ce);ha(ae,ee)}return null}function pe(ae,ee,ce,Se){var Xe=ee!==null?ee.key:null;if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return Xe!==null?null:z(ae,ee,""+ce,Se);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case w:return ce.key===Xe?K(ae,ee,ce,Se):null;case j:return ce.key===Xe?de(ae,ee,ce,Se):null;case U:return ce=mi(ce),pe(ae,ee,ce,Se)}if(F(ce)||H(ce))return Xe!==null?null:ve(ae,ee,ce,Se,null);if(typeof ce.then=="function")return pe(ae,ee,fa(ce),Se);if(ce.$$typeof===D)return pe(ae,ee,oa(ae,ce),Se);ha(ae,ce)}return null}function ye(ae,ee,ce,Se,Xe){if(typeof Se=="string"&&Se!==""||typeof Se=="number"||typeof Se=="bigint")return ae=ae.get(ce)||null,z(ee,ae,""+Se,Xe);if(typeof Se=="object"&&Se!==null){switch(Se.$$typeof){case w:return ae=ae.get(Se.key===null?ce:Se.key)||null,K(ee,ae,Se,Xe);case j:return ae=ae.get(Se.key===null?ce:Se.key)||null,de(ee,ae,Se,Xe);case U:return Se=mi(Se),ye(ae,ee,ce,Se,Xe)}if(F(Se)||H(Se))return ae=ae.get(ce)||null,ve(ee,ae,Se,Xe,null);if(typeof Se.then=="function")return ye(ae,ee,ce,fa(Se),Xe);if(Se.$$typeof===D)return ye(ae,ee,ce,oa(ee,Se),Xe);ha(ee,Se)}return null}function He(ae,ee,ce,Se){for(var Xe=null,zt=null,$e=ee,gt=ee=0,Et=null;$e!==null&><ce.length;gt++){$e.index>gt?(Et=$e,$e=null):Et=$e.sibling;var _t=pe(ae,$e,ce[gt],Se);if(_t===null){$e===null&&($e=Et);break}e&&$e&&_t.alternate===null&&n(ae,$e),ee=g(_t,ee,gt),zt===null?Xe=_t:zt.sibling=_t,zt=_t,$e=Et}if(gt===ce.length)return s(ae,$e),Tt&&hr(ae,gt),Xe;if($e===null){for(;gt<ce.length;gt++)$e=je(ae,ce[gt],Se),$e!==null&&(ee=g($e,ee,gt),zt===null?Xe=$e:zt.sibling=$e,zt=$e);return Tt&&hr(ae,gt),Xe}for($e=u($e);gt<ce.length;gt++)Et=ye($e,ae,gt,ce[gt],Se),Et!==null&&(e&&Et.alternate!==null&&$e.delete(Et.key===null?gt:Et.key),ee=g(Et,ee,gt),zt===null?Xe=Et:zt.sibling=Et,zt=Et);return e&&$e.forEach(function(ei){return n(ae,ei)}),Tt&&hr(ae,gt),Xe}function tt(ae,ee,ce,Se){if(ce==null)throw Error(l(151));for(var Xe=null,zt=null,$e=ee,gt=ee=0,Et=null,_t=ce.next();$e!==null&&!_t.done;gt++,_t=ce.next()){$e.index>gt?(Et=$e,$e=null):Et=$e.sibling;var ei=pe(ae,$e,_t.value,Se);if(ei===null){$e===null&&($e=Et);break}e&&$e&&ei.alternate===null&&n(ae,$e),ee=g(ei,ee,gt),zt===null?Xe=ei:zt.sibling=ei,zt=ei,$e=Et}if(_t.done)return s(ae,$e),Tt&&hr(ae,gt),Xe;if($e===null){for(;!_t.done;gt++,_t=ce.next())_t=je(ae,_t.value,Se),_t!==null&&(ee=g(_t,ee,gt),zt===null?Xe=_t:zt.sibling=_t,zt=_t);return Tt&&hr(ae,gt),Xe}for($e=u($e);!_t.done;gt++,_t=ce.next())_t=ye($e,ae,gt,_t.value,Se),_t!==null&&(e&&_t.alternate!==null&&$e.delete(_t.key===null?gt:_t.key),ee=g(_t,ee,gt),zt===null?Xe=_t:zt.sibling=_t,zt=_t);return e&&$e.forEach(function(L1){return n(ae,L1)}),Tt&&hr(ae,gt),Xe}function qt(ae,ee,ce,Se){if(typeof ce=="object"&&ce!==null&&ce.type===N&&ce.key===null&&(ce=ce.props.children),typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case w:e:{for(var Xe=ce.key;ee!==null;){if(ee.key===Xe){if(Xe=ce.type,Xe===N){if(ee.tag===7){s(ae,ee.sibling),Se=m(ee,ce.props.children),Se.return=ae,ae=Se;break e}}else if(ee.elementType===Xe||typeof Xe=="object"&&Xe!==null&&Xe.$$typeof===U&&mi(Xe)===ee.type){s(ae,ee.sibling),Se=m(ee,ce.props),Vs(Se,ce),Se.return=ae,ae=Se;break e}s(ae,ee);break}else n(ae,ee);ee=ee.sibling}ce.type===N?(Se=ci(ce.props.children,ae.mode,Se,ce.key),Se.return=ae,ae=Se):(Se=sa(ce.type,ce.key,ce.props,null,ae.mode,Se),Vs(Se,ce),Se.return=ae,ae=Se)}return S(ae);case j:e:{for(Xe=ce.key;ee!==null;){if(ee.key===Xe)if(ee.tag===4&&ee.stateNode.containerInfo===ce.containerInfo&&ee.stateNode.implementation===ce.implementation){s(ae,ee.sibling),Se=m(ee,ce.children||[]),Se.return=ae,ae=Se;break e}else{s(ae,ee);break}else n(ae,ee);ee=ee.sibling}Se=hu(ce,ae.mode,Se),Se.return=ae,ae=Se}return S(ae);case U:return ce=mi(ce),qt(ae,ee,ce,Se)}if(F(ce))return He(ae,ee,ce,Se);if(H(ce)){if(Xe=H(ce),typeof Xe!="function")throw Error(l(150));return ce=Xe.call(ce),tt(ae,ee,ce,Se)}if(typeof ce.then=="function")return qt(ae,ee,fa(ce),Se);if(ce.$$typeof===D)return qt(ae,ee,oa(ae,ce),Se);ha(ae,ce)}return typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint"?(ce=""+ce,ee!==null&&ee.tag===6?(s(ae,ee.sibling),Se=m(ee,ce),Se.return=ae,ae=Se):(s(ae,ee),Se=fu(ce,ae.mode,Se),Se.return=ae,ae=Se),S(ae)):s(ae,ee)}return function(ae,ee,ce,Se){try{Gs=0;var Xe=qt(ae,ee,ce,Se);return Wi=null,Xe}catch($e){if($e===Ji||$e===ca)throw $e;var zt=Nn(29,$e,null,ae.mode);return zt.lanes=Se,zt.return=ae,zt}}}var yi=sp(!0),lp=sp(!1),Ir=!1;function Eu(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Cu(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 Br(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function qr(e,n,s){var u=e.updateQueue;if(u===null)return null;if(u=u.shared,(Mt&2)!==0){var m=u.pending;return m===null?n.next=n:(n.next=m.next,m.next=n),u.pending=n,n=ia(e),Fh(e,null,s),n}return ra(e,u,n,s),ia(e)}function Ys(e,n,s){if(n=n.updateQueue,n!==null&&(n=n.shared,(s&4194048)!==0)){var u=n.lanes;u&=e.pendingLanes,s|=u,n.lanes=s,Pe(e,s)}}function Tu(e,n){var s=e.updateQueue,u=e.alternate;if(u!==null&&(u=u.updateQueue,s===u)){var m=null,g=null;if(s=s.firstBaseUpdate,s!==null){do{var S={lane:s.lane,tag:s.tag,payload:s.payload,callback:null,next:null};g===null?m=g=S:g=g.next=S,s=s.next}while(s!==null);g===null?m=g=n:g=g.next=n}else m=g=n;s={baseState:u.baseState,firstBaseUpdate:m,lastBaseUpdate:g,shared:u.shared,callbacks:u.callbacks},e.updateQueue=s;return}e=s.lastBaseUpdate,e===null?s.firstBaseUpdate=n:e.next=n,s.lastBaseUpdate=n}var Nu=!1;function Qs(){if(Nu){var e=Zi;if(e!==null)throw e}}function Ks(e,n,s,u){Nu=!1;var m=e.updateQueue;Ir=!1;var g=m.firstBaseUpdate,S=m.lastBaseUpdate,z=m.shared.pending;if(z!==null){m.shared.pending=null;var K=z,de=K.next;K.next=null,S===null?g=de:S.next=de,S=K;var ve=e.alternate;ve!==null&&(ve=ve.updateQueue,z=ve.lastBaseUpdate,z!==S&&(z===null?ve.firstBaseUpdate=de:z.next=de,ve.lastBaseUpdate=K))}if(g!==null){var je=m.baseState;S=0,ve=de=K=null,z=g;do{var pe=z.lane&-536870913,ye=pe!==z.lane;if(ye?(kt&pe)===pe:(u&pe)===pe){pe!==0&&pe===Xi&&(Nu=!0),ve!==null&&(ve=ve.next={lane:0,tag:z.tag,payload:z.payload,callback:null,next:null});e:{var He=e,tt=z;pe=n;var qt=s;switch(tt.tag){case 1:if(He=tt.payload,typeof He=="function"){je=He.call(qt,je,pe);break e}je=He;break e;case 3:He.flags=He.flags&-65537|128;case 0:if(He=tt.payload,pe=typeof He=="function"?He.call(qt,je,pe):He,pe==null)break e;je=b({},je,pe);break e;case 2:Ir=!0}}pe=z.callback,pe!==null&&(e.flags|=64,ye&&(e.flags|=8192),ye=m.callbacks,ye===null?m.callbacks=[pe]:ye.push(pe))}else ye={lane:pe,tag:z.tag,payload:z.payload,callback:z.callback,next:null},ve===null?(de=ve=ye,K=je):ve=ve.next=ye,S|=pe;if(z=z.next,z===null){if(z=m.shared.pending,z===null)break;ye=z,z=ye.next,ye.next=null,m.lastBaseUpdate=ye,m.shared.pending=null}}while(!0);ve===null&&(K=je),m.baseState=K,m.firstBaseUpdate=de,m.lastBaseUpdate=ve,g===null&&(m.shared.lanes=0),$r|=S,e.lanes=S,e.memoizedState=je}}function ap(e,n){if(typeof e!="function")throw Error(l(191,e));e.call(n)}function op(e,n){var s=e.callbacks;if(s!==null)for(e.callbacks=null,e=0;e<s.length;e++)ap(s[e],n)}var es=M(null),pa=M(0);function up(e,n){e=kr,k(pa,e),k(es,n),kr=e|n.baseLanes}function Au(){k(pa,kr),k(es,es.current)}function Ru(){kr=pa.current,te(es),te(pa)}var An=M(null),Fn=null;function Ur(e){var n=e.alternate;k(Zt,Zt.current&1),k(An,e),Fn===null&&(n===null||es.current!==null||n.memoizedState!==null)&&(Fn=e)}function zu(e){k(Zt,Zt.current),k(An,e),Fn===null&&(Fn=e)}function cp(e){e.tag===22?(k(Zt,Zt.current),k(An,e),Fn===null&&(Fn=e)):Hr()}function Hr(){k(Zt,Zt.current),k(An,An.current)}function Rn(e){te(An),Fn===e&&(Fn=null),te(Zt)}var Zt=M(0);function ma(e){for(var n=e;n!==null;){if(n.tag===13){var s=n.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||Ic(s)||Bc(s)))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 gr=0,mt=null,It=null,en=null,ga=!1,ts=!1,bi=!1,ya=0,Xs=0,ns=null,C0=0;function Qt(){throw Error(l(321))}function _u(e,n){if(n===null)return!1;for(var s=0;s<n.length&&s<e.length;s++)if(!Tn(e[s],n[s]))return!1;return!0}function Mu(e,n,s,u,m,g){return gr=g,mt=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,P.H=e===null||e.memoizedState===null?Yp:Qu,bi=!1,g=s(u,m),bi=!1,ts&&(g=fp(n,s,u,m)),dp(e),g}function dp(e){P.H=Ws;var n=It!==null&&It.next!==null;if(gr=0,en=It=mt=null,ga=!1,Xs=0,ns=null,n)throw Error(l(300));e===null||tn||(e=e.dependencies,e!==null&&aa(e)&&(tn=!0))}function fp(e,n,s,u){mt=e;var m=0;do{if(ts&&(ns=null),Xs=0,ts=!1,25<=m)throw Error(l(301));if(m+=1,en=It=null,e.updateQueue!=null){var g=e.updateQueue;g.lastEffect=null,g.events=null,g.stores=null,g.memoCache!=null&&(g.memoCache.index=0)}P.H=Qp,g=n(s,u)}while(ts);return g}function T0(){var e=P.H,n=e.useState()[0];return n=typeof n.then=="function"?Zs(n):n,e=e.useState()[0],(It!==null?It.memoizedState:null)!==e&&(mt.flags|=1024),n}function Du(){var e=ya!==0;return ya=0,e}function Ou(e,n,s){n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~s}function Lu(e){if(ga){for(e=e.memoizedState;e!==null;){var n=e.queue;n!==null&&(n.pending=null),e=e.next}ga=!1}gr=0,en=It=mt=null,ts=!1,Xs=ya=0,ns=null}function yn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return en===null?mt.memoizedState=en=e:en=en.next=e,en}function Jt(){if(It===null){var e=mt.alternate;e=e!==null?e.memoizedState:null}else e=It.next;var n=en===null?mt.memoizedState:en.next;if(n!==null)en=n,It=e;else{if(e===null)throw mt.alternate===null?Error(l(467)):Error(l(310));It=e,e={memoizedState:It.memoizedState,baseState:It.baseState,baseQueue:It.baseQueue,queue:It.queue,next:null},en===null?mt.memoizedState=en=e:en=en.next=e}return en}function ba(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Zs(e){var n=Xs;return Xs+=1,ns===null&&(ns=[]),e=np(ns,e,n),n=mt,(en===null?n.memoizedState:en.next)===null&&(n=n.alternate,P.H=n===null||n.memoizedState===null?Yp:Qu),e}function va(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Zs(e);if(e.$$typeof===D)return dn(e)}throw Error(l(438,String(e)))}function Iu(e){var n=null,s=mt.updateQueue;if(s!==null&&(n=s.memoCache),n==null){var u=mt.alternate;u!==null&&(u=u.updateQueue,u!==null&&(u=u.memoCache,u!=null&&(n={data:u.data.map(function(m){return m.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),s===null&&(s=ba(),mt.updateQueue=s),s.memoCache=n,s=n.data[n.index],s===void 0)for(s=n.data[n.index]=Array(e),u=0;u<e;u++)s[u]=_;return n.index++,s}function yr(e,n){return typeof n=="function"?n(e):n}function xa(e){var n=Jt();return Bu(n,It,e)}function Bu(e,n,s){var u=e.queue;if(u===null)throw Error(l(311));u.lastRenderedReducer=s;var m=e.baseQueue,g=u.pending;if(g!==null){if(m!==null){var S=m.next;m.next=g.next,g.next=S}n.baseQueue=m=g,u.pending=null}if(g=e.baseState,m===null)e.memoizedState=g;else{n=m.next;var z=S=null,K=null,de=n,ve=!1;do{var je=de.lane&-536870913;if(je!==de.lane?(kt&je)===je:(gr&je)===je){var pe=de.revertLane;if(pe===0)K!==null&&(K=K.next={lane:0,revertLane:0,gesture:null,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null}),je===Xi&&(ve=!0);else if((gr&pe)===pe){de=de.next,pe===Xi&&(ve=!0);continue}else je={lane:0,revertLane:de.revertLane,gesture:null,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null},K===null?(z=K=je,S=g):K=K.next=je,mt.lanes|=pe,$r|=pe;je=de.action,bi&&s(g,je),g=de.hasEagerState?de.eagerState:s(g,je)}else pe={lane:je,revertLane:de.revertLane,gesture:de.gesture,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null},K===null?(z=K=pe,S=g):K=K.next=pe,mt.lanes|=je,$r|=je;de=de.next}while(de!==null&&de!==n);if(K===null?S=g:K.next=z,!Tn(g,e.memoizedState)&&(tn=!0,ve&&(s=Zi,s!==null)))throw s;e.memoizedState=g,e.baseState=S,e.baseQueue=K,u.lastRenderedState=g}return m===null&&(u.lanes=0),[e.memoizedState,u.dispatch]}function qu(e){var n=Jt(),s=n.queue;if(s===null)throw Error(l(311));s.lastRenderedReducer=e;var u=s.dispatch,m=s.pending,g=n.memoizedState;if(m!==null){s.pending=null;var S=m=m.next;do g=e(g,S.action),S=S.next;while(S!==m);Tn(g,n.memoizedState)||(tn=!0),n.memoizedState=g,n.baseQueue===null&&(n.baseState=g),s.lastRenderedState=g}return[g,u]}function hp(e,n,s){var u=mt,m=Jt(),g=Tt;if(g){if(s===void 0)throw Error(l(407));s=s()}else s=n();var S=!Tn((It||m).memoizedState,s);if(S&&(m.memoizedState=s,tn=!0),m=m.queue,Pu(gp.bind(null,u,m,e),[e]),m.getSnapshot!==n||S||en!==null&&en.memoizedState.tag&1){if(u.flags|=2048,rs(9,{destroy:void 0},mp.bind(null,u,m,s,n),null),Ut===null)throw Error(l(349));g||(gr&127)!==0||pp(u,n,s)}return s}function pp(e,n,s){e.flags|=16384,e={getSnapshot:n,value:s},n=mt.updateQueue,n===null?(n=ba(),mt.updateQueue=n,n.stores=[e]):(s=n.stores,s===null?n.stores=[e]:s.push(e))}function mp(e,n,s,u){n.value=s,n.getSnapshot=u,yp(n)&&bp(e)}function gp(e,n,s){return s(function(){yp(n)&&bp(e)})}function yp(e){var n=e.getSnapshot;e=e.value;try{var s=n();return!Tn(e,s)}catch{return!0}}function bp(e){var n=ui(e,2);n!==null&&kn(n,e,2)}function Uu(e){var n=yn();if(typeof e=="function"){var s=e;if(e=s(),bi){Qe(!0);try{s()}finally{Qe(!1)}}}return n.memoizedState=n.baseState=e,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:yr,lastRenderedState:e},n}function vp(e,n,s,u){return e.baseState=s,Bu(e,It,typeof u=="function"?u:yr)}function N0(e,n,s,u,m){if(ja(e))throw Error(l(485));if(e=n.action,e!==null){var g={payload:m,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(S){g.listeners.push(S)}};P.T!==null?s(!0):g.isTransition=!1,u(g),s=n.pending,s===null?(g.next=n.pending=g,xp(n,g)):(g.next=s.next,n.pending=s.next=g)}}function xp(e,n){var s=n.action,u=n.payload,m=e.state;if(n.isTransition){var g=P.T,S={};P.T=S;try{var z=s(m,u),K=P.S;K!==null&&K(S,z),wp(e,n,z)}catch(de){Hu(e,n,de)}finally{g!==null&&S.types!==null&&(g.types=S.types),P.T=g}}else try{g=s(m,u),wp(e,n,g)}catch(de){Hu(e,n,de)}}function wp(e,n,s){s!==null&&typeof s=="object"&&typeof s.then=="function"?s.then(function(u){Sp(e,n,u)},function(u){return Hu(e,n,u)}):Sp(e,n,s)}function Sp(e,n,s){n.status="fulfilled",n.value=s,jp(n),e.state=s,n=e.pending,n!==null&&(s=n.next,s===n?e.pending=null:(s=s.next,n.next=s,xp(e,s)))}function Hu(e,n,s){var u=e.pending;if(e.pending=null,u!==null){u=u.next;do n.status="rejected",n.reason=s,jp(n),n=n.next;while(n!==u)}e.action=null}function jp(e){e=e.listeners;for(var n=0;n<e.length;n++)(0,e[n])()}function kp(e,n){return n}function Ep(e,n){if(Tt){var s=Ut.formState;if(s!==null){e:{var u=mt;if(Tt){if(Ft){t:{for(var m=Ft,g=Pn;m.nodeType!==8;){if(!g){m=null;break t}if(m=$n(m.nextSibling),m===null){m=null;break t}}g=m.data,m=g==="F!"||g==="F"?m:null}if(m){Ft=$n(m.nextSibling),u=m.data==="F!";break e}}Or(u)}u=!1}u&&(n=s[0])}}return s=yn(),s.memoizedState=s.baseState=n,u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:kp,lastRenderedState:n},s.queue=u,s=$p.bind(null,mt,u),u.dispatch=s,u=Uu(!1),g=Yu.bind(null,mt,!1,u.queue),u=yn(),m={state:n,dispatch:null,action:e,pending:null},u.queue=m,s=N0.bind(null,mt,m,g,s),m.dispatch=s,u.memoizedState=e,[n,s,!1]}function Cp(e){var n=Jt();return Tp(n,It,e)}function Tp(e,n,s){if(n=Bu(e,n,kp)[0],e=xa(yr)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var u=Zs(n)}catch(S){throw S===Ji?ca:S}else u=n;n=Jt();var m=n.queue,g=m.dispatch;return s!==n.memoizedState&&(mt.flags|=2048,rs(9,{destroy:void 0},A0.bind(null,m,s),null)),[u,g,e]}function A0(e,n){e.action=n}function Np(e){var n=Jt(),s=It;if(s!==null)return Tp(n,s,e);Jt(),n=n.memoizedState,s=Jt();var u=s.queue.dispatch;return s.memoizedState=e,[n,u,!1]}function rs(e,n,s,u){return e={tag:e,create:s,deps:u,inst:n,next:null},n=mt.updateQueue,n===null&&(n=ba(),mt.updateQueue=n),s=n.lastEffect,s===null?n.lastEffect=e.next=e:(u=s.next,s.next=e,e.next=u,n.lastEffect=e),e}function Ap(){return Jt().memoizedState}function wa(e,n,s,u){var m=yn();mt.flags|=e,m.memoizedState=rs(1|n,{destroy:void 0},s,u===void 0?null:u)}function Sa(e,n,s,u){var m=Jt();u=u===void 0?null:u;var g=m.memoizedState.inst;It!==null&&u!==null&&_u(u,It.memoizedState.deps)?m.memoizedState=rs(n,g,s,u):(mt.flags|=e,m.memoizedState=rs(1|n,g,s,u))}function Rp(e,n){wa(8390656,8,e,n)}function Pu(e,n){Sa(2048,8,e,n)}function R0(e){mt.flags|=4;var n=mt.updateQueue;if(n===null)n=ba(),mt.updateQueue=n,n.events=[e];else{var s=n.events;s===null?n.events=[e]:s.push(e)}}function zp(e){var n=Jt().memoizedState;return R0({ref:n,nextImpl:e}),function(){if((Mt&2)!==0)throw Error(l(440));return n.impl.apply(void 0,arguments)}}function _p(e,n){return Sa(4,2,e,n)}function Mp(e,n){return Sa(4,4,e,n)}function Dp(e,n){if(typeof n=="function"){e=e();var s=n(e);return function(){typeof s=="function"?s():n(null)}}if(n!=null)return e=e(),n.current=e,function(){n.current=null}}function Op(e,n,s){s=s!=null?s.concat([e]):null,Sa(4,4,Dp.bind(null,n,e),s)}function Fu(){}function Lp(e,n){var s=Jt();n=n===void 0?null:n;var u=s.memoizedState;return n!==null&&_u(n,u[1])?u[0]:(s.memoizedState=[e,n],e)}function Ip(e,n){var s=Jt();n=n===void 0?null:n;var u=s.memoizedState;if(n!==null&&_u(n,u[1]))return u[0];if(u=e(),bi){Qe(!0);try{e()}finally{Qe(!1)}}return s.memoizedState=[u,n],u}function $u(e,n,s){return s===void 0||(gr&1073741824)!==0&&(kt&261930)===0?e.memoizedState=n:(e.memoizedState=s,e=Bm(),mt.lanes|=e,$r|=e,s)}function Bp(e,n,s,u){return Tn(s,n)?s:es.current!==null?(e=$u(e,s,u),Tn(e,n)||(tn=!0),e):(gr&42)===0||(gr&1073741824)!==0&&(kt&261930)===0?(tn=!0,e.memoizedState=s):(e=Bm(),mt.lanes|=e,$r|=e,n)}function qp(e,n,s,u,m){var g=G.p;G.p=g!==0&&8>g?g:8;var S=P.T,z={};P.T=z,Yu(e,!1,n,s);try{var K=m(),de=P.S;if(de!==null&&de(z,K),K!==null&&typeof K=="object"&&typeof K.then=="function"){var ve=E0(K,u);Js(e,n,ve,Mn(e))}else Js(e,n,u,Mn(e))}catch(je){Js(e,n,{then:function(){},status:"rejected",reason:je},Mn())}finally{G.p=g,S!==null&&z.types!==null&&(S.types=z.types),P.T=S}}function z0(){}function Gu(e,n,s,u){if(e.tag!==5)throw Error(l(476));var m=Up(e).queue;qp(e,m,n,re,s===null?z0:function(){return Hp(e),s(u)})}function Up(e){var n=e.memoizedState;if(n!==null)return n;n={memoizedState:re,baseState:re,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:yr,lastRenderedState:re},next:null};var s={};return n.next={memoizedState:s,baseState:s,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:yr,lastRenderedState:s},next:null},e.memoizedState=n,e=e.alternate,e!==null&&(e.memoizedState=n),n}function Hp(e){var n=Up(e);n.next===null&&(n=e.alternate.memoizedState),Js(e,n.next.queue,{},Mn())}function Vu(){return dn(ml)}function Pp(){return Jt().memoizedState}function Fp(){return Jt().memoizedState}function _0(e){for(var n=e.return;n!==null;){switch(n.tag){case 24:case 3:var s=Mn();e=Br(s);var u=qr(n,e,s);u!==null&&(kn(u,n,s),Ys(u,n,s)),n={cache:wu()},e.payload=n;return}n=n.return}}function M0(e,n,s){var u=Mn();s={lane:u,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},ja(e)?Gp(n,s):(s=cu(e,n,s,u),s!==null&&(kn(s,e,u),Vp(s,n,u)))}function $p(e,n,s){var u=Mn();Js(e,n,s,u)}function Js(e,n,s,u){var m={lane:u,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null};if(ja(e))Gp(n,m);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,z=g(S,s);if(m.hasEagerState=!0,m.eagerState=z,Tn(z,S))return ra(e,n,m,0),Ut===null&&na(),!1}catch{}if(s=cu(e,n,m,u),s!==null)return kn(s,e,u),Vp(s,n,u),!0}return!1}function Yu(e,n,s,u){if(u={lane:2,revertLane:Ec(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},ja(e)){if(n)throw Error(l(479))}else n=cu(e,s,u,2),n!==null&&kn(n,e,2)}function ja(e){var n=e.alternate;return e===mt||n!==null&&n===mt}function Gp(e,n){ts=ga=!0;var s=e.pending;s===null?n.next=n:(n.next=s.next,s.next=n),e.pending=n}function Vp(e,n,s){if((s&4194048)!==0){var u=n.lanes;u&=e.pendingLanes,s|=u,n.lanes=s,Pe(e,s)}}var Ws={readContext:dn,use:va,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};Ws.useEffectEvent=Qt;var Yp={readContext:dn,use:va,useCallback:function(e,n){return yn().memoizedState=[e,n===void 0?null:n],e},useContext:dn,useEffect:Rp,useImperativeHandle:function(e,n,s){s=s!=null?s.concat([e]):null,wa(4194308,4,Dp.bind(null,n,e),s)},useLayoutEffect:function(e,n){return wa(4194308,4,e,n)},useInsertionEffect:function(e,n){wa(4,2,e,n)},useMemo:function(e,n){var s=yn();n=n===void 0?null:n;var u=e();if(bi){Qe(!0);try{e()}finally{Qe(!1)}}return s.memoizedState=[u,n],u},useReducer:function(e,n,s){var u=yn();if(s!==void 0){var m=s(n);if(bi){Qe(!0);try{s(n)}finally{Qe(!1)}}}else m=n;return u.memoizedState=u.baseState=m,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:m},u.queue=e,e=e.dispatch=M0.bind(null,mt,e),[u.memoizedState,e]},useRef:function(e){var n=yn();return e={current:e},n.memoizedState=e},useState:function(e){e=Uu(e);var n=e.queue,s=$p.bind(null,mt,n);return n.dispatch=s,[e.memoizedState,s]},useDebugValue:Fu,useDeferredValue:function(e,n){var s=yn();return $u(s,e,n)},useTransition:function(){var e=Uu(!1);return e=qp.bind(null,mt,e.queue,!0,!1),yn().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,s){var u=mt,m=yn();if(Tt){if(s===void 0)throw Error(l(407));s=s()}else{if(s=n(),Ut===null)throw Error(l(349));(kt&127)!==0||pp(u,n,s)}m.memoizedState=s;var g={value:s,getSnapshot:n};return m.queue=g,Rp(gp.bind(null,u,g,e),[e]),u.flags|=2048,rs(9,{destroy:void 0},mp.bind(null,u,g,s,n),null),s},useId:function(){var e=yn(),n=Ut.identifierPrefix;if(Tt){var s=er,u=Wn;s=(u&~(1<<32-Ue(u)-1)).toString(32)+s,n="_"+n+"R_"+s,s=ya++,0<s&&(n+="H"+s.toString(32)),n+="_"}else s=C0++,n="_"+n+"r_"+s.toString(32)+"_";return e.memoizedState=n},useHostTransitionStatus:Vu,useFormState:Ep,useActionState:Ep,useOptimistic:function(e){var n=yn();n.memoizedState=n.baseState=e;var s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=s,n=Yu.bind(null,mt,!0,s),s.dispatch=n,[e,n]},useMemoCache:Iu,useCacheRefresh:function(){return yn().memoizedState=_0.bind(null,mt)},useEffectEvent:function(e){var n=yn(),s={impl:e};return n.memoizedState=s,function(){if((Mt&2)!==0)throw Error(l(440));return s.impl.apply(void 0,arguments)}}},Qu={readContext:dn,use:va,useCallback:Lp,useContext:dn,useEffect:Pu,useImperativeHandle:Op,useInsertionEffect:_p,useLayoutEffect:Mp,useMemo:Ip,useReducer:xa,useRef:Ap,useState:function(){return xa(yr)},useDebugValue:Fu,useDeferredValue:function(e,n){var s=Jt();return Bp(s,It.memoizedState,e,n)},useTransition:function(){var e=xa(yr)[0],n=Jt().memoizedState;return[typeof e=="boolean"?e:Zs(e),n]},useSyncExternalStore:hp,useId:Pp,useHostTransitionStatus:Vu,useFormState:Cp,useActionState:Cp,useOptimistic:function(e,n){var s=Jt();return vp(s,It,e,n)},useMemoCache:Iu,useCacheRefresh:Fp};Qu.useEffectEvent=zp;var Qp={readContext:dn,use:va,useCallback:Lp,useContext:dn,useEffect:Pu,useImperativeHandle:Op,useInsertionEffect:_p,useLayoutEffect:Mp,useMemo:Ip,useReducer:qu,useRef:Ap,useState:function(){return qu(yr)},useDebugValue:Fu,useDeferredValue:function(e,n){var s=Jt();return It===null?$u(s,e,n):Bp(s,It.memoizedState,e,n)},useTransition:function(){var e=qu(yr)[0],n=Jt().memoizedState;return[typeof e=="boolean"?e:Zs(e),n]},useSyncExternalStore:hp,useId:Pp,useHostTransitionStatus:Vu,useFormState:Np,useActionState:Np,useOptimistic:function(e,n){var s=Jt();return It!==null?vp(s,It,e,n):(s.baseState=e,[e,s.queue.dispatch])},useMemoCache:Iu,useCacheRefresh:Fp};Qp.useEffectEvent=zp;function Ku(e,n,s,u){n=e.memoizedState,s=s(u,n),s=s==null?n:b({},n,s),e.memoizedState=s,e.lanes===0&&(e.updateQueue.baseState=s)}var Xu={enqueueSetState:function(e,n,s){e=e._reactInternals;var u=Mn(),m=Br(u);m.payload=n,s!=null&&(m.callback=s),n=qr(e,m,u),n!==null&&(kn(n,e,u),Ys(n,e,u))},enqueueReplaceState:function(e,n,s){e=e._reactInternals;var u=Mn(),m=Br(u);m.tag=1,m.payload=n,s!=null&&(m.callback=s),n=qr(e,m,u),n!==null&&(kn(n,e,u),Ys(n,e,u))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var s=Mn(),u=Br(s);u.tag=2,n!=null&&(u.callback=n),n=qr(e,u,s),n!==null&&(kn(n,e,s),Ys(n,e,s))}};function Kp(e,n,s,u,m,g,S){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(u,g,S):n.prototype&&n.prototype.isPureReactComponent?!qs(s,u)||!qs(m,g):!0}function Xp(e,n,s,u){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(s,u),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(s,u),n.state!==e&&Xu.enqueueReplaceState(n,n.state,null)}function vi(e,n){var s=n;if("ref"in n){s={};for(var u in n)u!=="ref"&&(s[u]=n[u])}if(e=e.defaultProps){s===n&&(s=b({},s));for(var m in e)s[m]===void 0&&(s[m]=e[m])}return s}function Zp(e){ta(e)}function Jp(e){console.error(e)}function Wp(e){ta(e)}function ka(e,n){try{var s=e.onUncaughtError;s(n.value,{componentStack:n.stack})}catch(u){setTimeout(function(){throw u})}}function em(e,n,s){try{var u=e.onCaughtError;u(s.value,{componentStack:s.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(m){setTimeout(function(){throw m})}}function Zu(e,n,s){return s=Br(s),s.tag=3,s.payload={element:null},s.callback=function(){ka(e,n)},s}function tm(e){return e=Br(e),e.tag=3,e}function nm(e,n,s,u){var m=s.type.getDerivedStateFromError;if(typeof m=="function"){var g=u.value;e.payload=function(){return m(g)},e.callback=function(){em(n,s,u)}}var S=s.stateNode;S!==null&&typeof S.componentDidCatch=="function"&&(e.callback=function(){em(n,s,u),typeof m!="function"&&(Gr===null?Gr=new Set([this]):Gr.add(this));var z=u.stack;this.componentDidCatch(u.value,{componentStack:z!==null?z:""})})}function D0(e,n,s,u,m){if(s.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){if(n=s.alternate,n!==null&&Ki(n,s,m,!0),s=An.current,s!==null){switch(s.tag){case 31:case 13:return Fn===null?La():s.alternate===null&&Kt===0&&(Kt=3),s.flags&=-257,s.flags|=65536,s.lanes=m,u===da?s.flags|=16384:(n=s.updateQueue,n===null?s.updateQueue=new Set([u]):n.add(u),Sc(e,u,m)),!1;case 22:return s.flags|=65536,u===da?s.flags|=16384:(n=s.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([u])},s.updateQueue=n):(s=n.retryQueue,s===null?n.retryQueue=new Set([u]):s.add(u)),Sc(e,u,m)),!1}throw Error(l(435,s.tag))}return Sc(e,u,m),La(),!1}if(Tt)return n=An.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=m,u!==gu&&(e=Error(l(422),{cause:u}),Ps(qn(e,s)))):(u!==gu&&(n=Error(l(423),{cause:u}),Ps(qn(n,s))),e=e.current.alternate,e.flags|=65536,m&=-m,e.lanes|=m,u=qn(u,s),m=Zu(e.stateNode,u,m),Tu(e,m),Kt!==4&&(Kt=2)),!1;var g=Error(l(520),{cause:u});if(g=qn(g,s),al===null?al=[g]:al.push(g),Kt!==4&&(Kt=2),n===null)return!0;u=qn(u,s),s=n;do{switch(s.tag){case 3:return s.flags|=65536,e=m&-m,s.lanes|=e,e=Zu(s.stateNode,u,e),Tu(s,e),!1;case 1:if(n=s.type,g=s.stateNode,(s.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(Gr===null||!Gr.has(g))))return s.flags|=65536,m&=-m,s.lanes|=m,m=tm(m),nm(m,e,s,u),Tu(s,m),!1}s=s.return}while(s!==null);return!1}var Ju=Error(l(461)),tn=!1;function fn(e,n,s,u){n.child=e===null?lp(n,null,s,u):yi(n,e.child,s,u)}function rm(e,n,s,u,m){s=s.render;var g=n.ref;if("ref"in u){var S={};for(var z in u)z!=="ref"&&(S[z]=u[z])}else S=u;return hi(n),u=Mu(e,n,s,S,g,m),z=Du(),e!==null&&!tn?(Ou(e,n,m),br(e,n,m)):(Tt&&z&&pu(n),n.flags|=1,fn(e,n,u,m),n.child)}function im(e,n,s,u,m){if(e===null){var g=s.type;return typeof g=="function"&&!du(g)&&g.defaultProps===void 0&&s.compare===null?(n.tag=15,n.type=g,sm(e,n,g,u,m)):(e=sa(s.type,null,u,n,n.mode,m),e.ref=n.ref,e.return=n,n.child=e)}if(g=e.child,!lc(e,m)){var S=g.memoizedProps;if(s=s.compare,s=s!==null?s:qs,s(S,u)&&e.ref===n.ref)return br(e,n,m)}return n.flags|=1,e=fr(g,u),e.ref=n.ref,e.return=n,n.child=e}function sm(e,n,s,u,m){if(e!==null){var g=e.memoizedProps;if(qs(g,u)&&e.ref===n.ref)if(tn=!1,n.pendingProps=u=g,lc(e,m))(e.flags&131072)!==0&&(tn=!0);else return n.lanes=e.lanes,br(e,n,m)}return Wu(e,n,s,u,m)}function lm(e,n,s,u){var m=u.children,g=e!==null?e.memoizedState:null;if(e===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),u.mode==="hidden"){if((n.flags&128)!==0){if(g=g!==null?g.baseLanes|s:s,e!==null){for(u=n.child=e.child,m=0;u!==null;)m=m|u.lanes|u.childLanes,u=u.sibling;u=m&~g}else u=0,n.child=null;return am(e,n,g,s,u)}if((s&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},e!==null&&ua(n,g!==null?g.cachePool:null),g!==null?up(n,g):Au(),cp(n);else return u=n.lanes=536870912,am(e,n,g!==null?g.baseLanes|s:s,s,u)}else g!==null?(ua(n,g.cachePool),up(n,g),Hr(),n.memoizedState=null):(e!==null&&ua(n,null),Au(),Hr());return fn(e,n,m,s),n.child}function el(e,n){return e!==null&&e.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function am(e,n,s,u,m){var g=ju();return g=g===null?null:{parent:Wt._currentValue,pool:g},n.memoizedState={baseLanes:s,cachePool:g},e!==null&&ua(n,null),Au(),cp(n),e!==null&&Ki(e,n,u,!0),n.childLanes=m,null}function Ea(e,n){return n=Ta({mode:n.mode,children:n.children},e.mode),n.ref=e.ref,e.child=n,n.return=e,n}function om(e,n,s){return yi(n,e.child,null,s),e=Ea(n,n.pendingProps),e.flags|=2,Rn(n),n.memoizedState=null,e}function O0(e,n,s){var u=n.pendingProps,m=(n.flags&128)!==0;if(n.flags&=-129,e===null){if(Tt){if(u.mode==="hidden")return e=Ea(n,u),n.lanes=536870912,el(null,e);if(zu(n),(e=Ft)?(e=xg(e,Pn),e=e!==null&&e.data==="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:Mr!==null?{id:Wn,overflow:er}:null,retryLane:536870912,hydrationErrors:null},s=Gh(e),s.return=n,n.child=s,cn=n,Ft=null)):e=null,e===null)throw Or(n);return n.lanes=536870912,null}return Ea(n,u)}var g=e.memoizedState;if(g!==null){var S=g.dehydrated;if(zu(n),m)if(n.flags&256)n.flags&=-257,n=om(e,n,s);else if(n.memoizedState!==null)n.child=e.child,n.flags|=128,n=null;else throw Error(l(558));else if(tn||Ki(e,n,s,!1),m=(s&e.childLanes)!==0,tn||m){if(u=Ut,u!==null&&(S=ot(u,s),S!==0&&S!==g.retryLane))throw g.retryLane=S,ui(e,S),kn(u,e,S),Ju;La(),n=om(e,n,s)}else e=g.treeContext,Ft=$n(S.nextSibling),cn=n,Tt=!0,Dr=null,Pn=!1,e!==null&&Qh(n,e),n=Ea(n,u),n.flags|=4096;return n}return e=fr(e.child,{mode:u.mode,children:u.children}),e.ref=n.ref,n.child=e,e.return=n,e}function Ca(e,n){var s=n.ref;if(s===null)e!==null&&e.ref!==null&&(n.flags|=4194816);else{if(typeof s!="function"&&typeof s!="object")throw Error(l(284));(e===null||e.ref!==s)&&(n.flags|=4194816)}}function Wu(e,n,s,u,m){return hi(n),s=Mu(e,n,s,u,void 0,m),u=Du(),e!==null&&!tn?(Ou(e,n,m),br(e,n,m)):(Tt&&u&&pu(n),n.flags|=1,fn(e,n,s,m),n.child)}function um(e,n,s,u,m,g){return hi(n),n.updateQueue=null,s=fp(n,u,s,m),dp(e),u=Du(),e!==null&&!tn?(Ou(e,n,g),br(e,n,g)):(Tt&&u&&pu(n),n.flags|=1,fn(e,n,s,g),n.child)}function cm(e,n,s,u,m){if(hi(n),n.stateNode===null){var g=Gi,S=s.contextType;typeof S=="object"&&S!==null&&(g=dn(S)),g=new s(u,g),n.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=Xu,n.stateNode=g,g._reactInternals=n,g=n.stateNode,g.props=u,g.state=n.memoizedState,g.refs={},Eu(n),S=s.contextType,g.context=typeof S=="object"&&S!==null?dn(S):Gi,g.state=n.memoizedState,S=s.getDerivedStateFromProps,typeof S=="function"&&(Ku(n,s,S,u),g.state=n.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(S=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),S!==g.state&&Xu.enqueueReplaceState(g,g.state,null),Ks(n,u,g,m),Qs(),g.state=n.memoizedState),typeof g.componentDidMount=="function"&&(n.flags|=4194308),u=!0}else if(e===null){g=n.stateNode;var z=n.memoizedProps,K=vi(s,z);g.props=K;var de=g.context,ve=s.contextType;S=Gi,typeof ve=="object"&&ve!==null&&(S=dn(ve));var je=s.getDerivedStateFromProps;ve=typeof je=="function"||typeof g.getSnapshotBeforeUpdate=="function",z=n.pendingProps!==z,ve||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(z||de!==S)&&Xp(n,g,u,S),Ir=!1;var pe=n.memoizedState;g.state=pe,Ks(n,u,g,m),Qs(),de=n.memoizedState,z||pe!==de||Ir?(typeof je=="function"&&(Ku(n,s,je,u),de=n.memoizedState),(K=Ir||Kp(n,s,K,u,pe,de,S))?(ve||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=u,n.memoizedState=de),g.props=u,g.state=de,g.context=S,u=K):(typeof g.componentDidMount=="function"&&(n.flags|=4194308),u=!1)}else{g=n.stateNode,Cu(e,n),S=n.memoizedProps,ve=vi(s,S),g.props=ve,je=n.pendingProps,pe=g.context,de=s.contextType,K=Gi,typeof de=="object"&&de!==null&&(K=dn(de)),z=s.getDerivedStateFromProps,(de=typeof z=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(S!==je||pe!==K)&&Xp(n,g,u,K),Ir=!1,pe=n.memoizedState,g.state=pe,Ks(n,u,g,m),Qs();var ye=n.memoizedState;S!==je||pe!==ye||Ir||e!==null&&e.dependencies!==null&&aa(e.dependencies)?(typeof z=="function"&&(Ku(n,s,z,u),ye=n.memoizedState),(ve=Ir||Kp(n,s,ve,u,pe,ye,K)||e!==null&&e.dependencies!==null&&aa(e.dependencies))?(de||typeof g.UNSAFE_componentWillUpdate!="function"&&typeof g.componentWillUpdate!="function"||(typeof g.componentWillUpdate=="function"&&g.componentWillUpdate(u,ye,K),typeof g.UNSAFE_componentWillUpdate=="function"&&g.UNSAFE_componentWillUpdate(u,ye,K)),typeof g.componentDidUpdate=="function"&&(n.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof g.componentDidUpdate!="function"||S===e.memoizedProps&&pe===e.memoizedState||(n.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&pe===e.memoizedState||(n.flags|=1024),n.memoizedProps=u,n.memoizedState=ye),g.props=u,g.state=ye,g.context=K,u=ve):(typeof g.componentDidUpdate!="function"||S===e.memoizedProps&&pe===e.memoizedState||(n.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&pe===e.memoizedState||(n.flags|=1024),u=!1)}return g=u,Ca(e,n),u=(n.flags&128)!==0,g||u?(g=n.stateNode,s=u&&typeof s.getDerivedStateFromError!="function"?null:g.render(),n.flags|=1,e!==null&&u?(n.child=yi(n,e.child,null,m),n.child=yi(n,null,s,m)):fn(e,n,s,m),n.memoizedState=g.state,e=n.child):e=br(e,n,m),e}function dm(e,n,s,u){return di(),n.flags|=256,fn(e,n,s,u),n.child}var ec={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function tc(e){return{baseLanes:e,cachePool:ep()}}function nc(e,n,s){return e=e!==null?e.childLanes&~s:0,n&&(e|=_n),e}function fm(e,n,s){var u=n.pendingProps,m=!1,g=(n.flags&128)!==0,S;if((S=g)||(S=e!==null&&e.memoizedState===null?!1:(Zt.current&2)!==0),S&&(m=!0,n.flags&=-129),S=(n.flags&32)!==0,n.flags&=-33,e===null){if(Tt){if(m?Ur(n):Hr(),(e=Ft)?(e=xg(e,Pn),e=e!==null&&e.data!=="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:Mr!==null?{id:Wn,overflow:er}:null,retryLane:536870912,hydrationErrors:null},s=Gh(e),s.return=n,n.child=s,cn=n,Ft=null)):e=null,e===null)throw Or(n);return Bc(e)?n.lanes=32:n.lanes=536870912,null}var z=u.children;return u=u.fallback,m?(Hr(),m=n.mode,z=Ta({mode:"hidden",children:z},m),u=ci(u,m,s,null),z.return=n,u.return=n,z.sibling=u,n.child=z,u=n.child,u.memoizedState=tc(s),u.childLanes=nc(e,S,s),n.memoizedState=ec,el(null,u)):(Ur(n),rc(n,z))}var K=e.memoizedState;if(K!==null&&(z=K.dehydrated,z!==null)){if(g)n.flags&256?(Ur(n),n.flags&=-257,n=ic(e,n,s)):n.memoizedState!==null?(Hr(),n.child=e.child,n.flags|=128,n=null):(Hr(),z=u.fallback,m=n.mode,u=Ta({mode:"visible",children:u.children},m),z=ci(z,m,s,null),z.flags|=2,u.return=n,z.return=n,u.sibling=z,n.child=u,yi(n,e.child,null,s),u=n.child,u.memoizedState=tc(s),u.childLanes=nc(e,S,s),n.memoizedState=ec,n=el(null,u));else if(Ur(n),Bc(z)){if(S=z.nextSibling&&z.nextSibling.dataset,S)var de=S.dgst;S=de,u=Error(l(419)),u.stack="",u.digest=S,Ps({value:u,source:null,stack:null}),n=ic(e,n,s)}else if(tn||Ki(e,n,s,!1),S=(s&e.childLanes)!==0,tn||S){if(S=Ut,S!==null&&(u=ot(S,s),u!==0&&u!==K.retryLane))throw K.retryLane=u,ui(e,u),kn(S,e,u),Ju;Ic(z)||La(),n=ic(e,n,s)}else Ic(z)?(n.flags|=192,n.child=e.child,n=null):(e=K.treeContext,Ft=$n(z.nextSibling),cn=n,Tt=!0,Dr=null,Pn=!1,e!==null&&Qh(n,e),n=rc(n,u.children),n.flags|=4096);return n}return m?(Hr(),z=u.fallback,m=n.mode,K=e.child,de=K.sibling,u=fr(K,{mode:"hidden",children:u.children}),u.subtreeFlags=K.subtreeFlags&65011712,de!==null?z=fr(de,z):(z=ci(z,m,s,null),z.flags|=2),z.return=n,u.return=n,u.sibling=z,n.child=u,el(null,u),u=n.child,z=e.child.memoizedState,z===null?z=tc(s):(m=z.cachePool,m!==null?(K=Wt._currentValue,m=m.parent!==K?{parent:K,pool:K}:m):m=ep(),z={baseLanes:z.baseLanes|s,cachePool:m}),u.memoizedState=z,u.childLanes=nc(e,S,s),n.memoizedState=ec,el(e.child,u)):(Ur(n),s=e.child,e=s.sibling,s=fr(s,{mode:"visible",children:u.children}),s.return=n,s.sibling=null,e!==null&&(S=n.deletions,S===null?(n.deletions=[e],n.flags|=16):S.push(e)),n.child=s,n.memoizedState=null,s)}function rc(e,n){return n=Ta({mode:"visible",children:n},e.mode),n.return=e,e.child=n}function Ta(e,n){return e=Nn(22,e,null,n),e.lanes=0,e}function ic(e,n,s){return yi(n,e.child,null,s),e=rc(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function hm(e,n,s){e.lanes|=n;var u=e.alternate;u!==null&&(u.lanes|=n),vu(e.return,n,s)}function sc(e,n,s,u,m,g){var S=e.memoizedState;S===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:u,tail:s,tailMode:m,treeForkCount:g}:(S.isBackwards=n,S.rendering=null,S.renderingStartTime=0,S.last=u,S.tail=s,S.tailMode=m,S.treeForkCount=g)}function pm(e,n,s){var u=n.pendingProps,m=u.revealOrder,g=u.tail;u=u.children;var S=Zt.current,z=(S&2)!==0;if(z?(S=S&1|2,n.flags|=128):S&=1,k(Zt,S),fn(e,n,u,s),u=Tt?Hs:0,!z&&e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&hm(e,s,n);else if(e.tag===19)hm(e,s,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(m){case"forwards":for(s=n.child,m=null;s!==null;)e=s.alternate,e!==null&&ma(e)===null&&(m=s),s=s.sibling;s=m,s===null?(m=n.child,n.child=null):(m=s.sibling,s.sibling=null),sc(n,!1,m,s,g,u);break;case"backwards":case"unstable_legacy-backwards":for(s=null,m=n.child,n.child=null;m!==null;){if(e=m.alternate,e!==null&&ma(e)===null){n.child=m;break}e=m.sibling,m.sibling=s,s=m,m=e}sc(n,!0,s,null,g,u);break;case"together":sc(n,!1,null,null,void 0,u);break;default:n.memoizedState=null}return n.child}function br(e,n,s){if(e!==null&&(n.dependencies=e.dependencies),$r|=n.lanes,(s&n.childLanes)===0)if(e!==null){if(Ki(e,n,s,!1),(s&n.childLanes)===0)return null}else return null;if(e!==null&&n.child!==e.child)throw Error(l(153));if(n.child!==null){for(e=n.child,s=fr(e,e.pendingProps),n.child=s,s.return=n;e.sibling!==null;)e=e.sibling,s=s.sibling=fr(e,e.pendingProps),s.return=n;s.sibling=null}return n.child}function lc(e,n){return(e.lanes&n)!==0?!0:(e=e.dependencies,!!(e!==null&&aa(e)))}function L0(e,n,s){switch(n.tag){case 3:oe(n,n.stateNode.containerInfo),Lr(n,Wt,e.memoizedState.cache),di();break;case 27:case 5:ke(n);break;case 4:oe(n,n.stateNode.containerInfo);break;case 10:Lr(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,zu(n),null;break;case 13:var u=n.memoizedState;if(u!==null)return u.dehydrated!==null?(Ur(n),n.flags|=128,null):(s&n.child.childLanes)!==0?fm(e,n,s):(Ur(n),e=br(e,n,s),e!==null?e.sibling:null);Ur(n);break;case 19:var m=(e.flags&128)!==0;if(u=(s&n.childLanes)!==0,u||(Ki(e,n,s,!1),u=(s&n.childLanes)!==0),m){if(u)return pm(e,n,s);n.flags|=128}if(m=n.memoizedState,m!==null&&(m.rendering=null,m.tail=null,m.lastEffect=null),k(Zt,Zt.current),u)break;return null;case 22:return n.lanes=0,lm(e,n,s,n.pendingProps);case 24:Lr(n,Wt,e.memoizedState.cache)}return br(e,n,s)}function mm(e,n,s){if(e!==null)if(e.memoizedProps!==n.pendingProps)tn=!0;else{if(!lc(e,s)&&(n.flags&128)===0)return tn=!1,L0(e,n,s);tn=(e.flags&131072)!==0}else tn=!1,Tt&&(n.flags&1048576)!==0&&Yh(n,Hs,n.index);switch(n.lanes=0,n.tag){case 16:e:{var u=n.pendingProps;if(e=mi(n.elementType),n.type=e,typeof e=="function")du(e)?(u=vi(e,u),n.tag=1,n=cm(null,n,e,u,s)):(n.tag=0,n=Wu(null,n,e,u,s));else{if(e!=null){var m=e.$$typeof;if(m===L){n.tag=11,n=rm(null,n,e,u,s);break e}else if(m===B){n.tag=14,n=im(null,n,e,u,s);break e}}throw n=$(e)||e,Error(l(306,n,""))}}return n;case 0:return Wu(e,n,n.type,n.pendingProps,s);case 1:return u=n.type,m=vi(u,n.pendingProps),cm(e,n,u,m,s);case 3:e:{if(oe(n,n.stateNode.containerInfo),e===null)throw Error(l(387));u=n.pendingProps;var g=n.memoizedState;m=g.element,Cu(e,n),Ks(n,u,null,s);var S=n.memoizedState;if(u=S.cache,Lr(n,Wt,u),u!==g.cache&&xu(n,[Wt],s,!0),Qs(),u=S.element,g.isDehydrated)if(g={element:u,isDehydrated:!1,cache:S.cache},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){n=dm(e,n,u,s);break e}else if(u!==m){m=qn(Error(l(424)),n),Ps(m),n=dm(e,n,u,s);break e}else for(e=n.stateNode.containerInfo,e.nodeType===9?e=e.body:e=e.nodeName==="HTML"?e.ownerDocument.body:e,Ft=$n(e.firstChild),cn=n,Tt=!0,Dr=null,Pn=!0,s=lp(n,null,u,s),n.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(di(),u===m){n=br(e,n,s);break e}fn(e,n,u,s)}n=n.child}return n;case 26:return Ca(e,n),e===null?(s=Cg(n.type,null,n.pendingProps,null))?n.memoizedState=s:Tt||(s=n.type,e=n.pendingProps,u=Fa(me.current).createElement(s),u[yt]=n,u[et]=e,hn(u,s,e),ln(u),n.stateNode=u):n.memoizedState=Cg(n.type,e.memoizedProps,n.pendingProps,e.memoizedState),null;case 27:return ke(n),e===null&&Tt&&(u=n.stateNode=jg(n.type,n.pendingProps,me.current),cn=n,Pn=!0,m=Ft,Kr(n.type)?(qc=m,Ft=$n(u.firstChild)):Ft=m),fn(e,n,n.pendingProps.children,s),Ca(e,n),e===null&&(n.flags|=4194304),n.child;case 5:return e===null&&Tt&&((m=u=Ft)&&(u=f1(u,n.type,n.pendingProps,Pn),u!==null?(n.stateNode=u,cn=n,Ft=$n(u.firstChild),Pn=!1,m=!0):m=!1),m||Or(n)),ke(n),m=n.type,g=n.pendingProps,S=e!==null?e.memoizedProps:null,u=g.children,Dc(m,g)?u=null:S!==null&&Dc(m,S)&&(n.flags|=32),n.memoizedState!==null&&(m=Mu(e,n,T0,null,null,s),ml._currentValue=m),Ca(e,n),fn(e,n,u,s),n.child;case 6:return e===null&&Tt&&((e=s=Ft)&&(s=h1(s,n.pendingProps,Pn),s!==null?(n.stateNode=s,cn=n,Ft=null,e=!0):e=!1),e||Or(n)),null;case 13:return fm(e,n,s);case 4:return oe(n,n.stateNode.containerInfo),u=n.pendingProps,e===null?n.child=yi(n,null,u,s):fn(e,n,u,s),n.child;case 11:return rm(e,n,n.type,n.pendingProps,s);case 7:return fn(e,n,n.pendingProps,s),n.child;case 8:return fn(e,n,n.pendingProps.children,s),n.child;case 12:return fn(e,n,n.pendingProps.children,s),n.child;case 10:return u=n.pendingProps,Lr(n,n.type,u.value),fn(e,n,u.children,s),n.child;case 9:return m=n.type._context,u=n.pendingProps.children,hi(n),m=dn(m),u=u(m),n.flags|=1,fn(e,n,u,s),n.child;case 14:return im(e,n,n.type,n.pendingProps,s);case 15:return sm(e,n,n.type,n.pendingProps,s);case 19:return pm(e,n,s);case 31:return O0(e,n,s);case 22:return lm(e,n,s,n.pendingProps);case 24:return hi(n),u=dn(Wt),e===null?(m=ju(),m===null&&(m=Ut,g=wu(),m.pooledCache=g,g.refCount++,g!==null&&(m.pooledCacheLanes|=s),m=g),n.memoizedState={parent:u,cache:m},Eu(n),Lr(n,Wt,m)):((e.lanes&s)!==0&&(Cu(e,n),Ks(n,null,null,s),Qs()),m=e.memoizedState,g=n.memoizedState,m.parent!==u?(m={parent:u,cache:u},n.memoizedState=m,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=m),Lr(n,Wt,u)):(u=g.cache,Lr(n,Wt,u),u!==m.cache&&xu(n,[Wt],s,!0))),fn(e,n,n.pendingProps.children,s),n.child;case 29:throw n.pendingProps}throw Error(l(156,n.tag))}function vr(e){e.flags|=4}function ac(e,n,s,u,m){if((n=(e.mode&32)!==0)&&(n=!1),n){if(e.flags|=16777216,(m&335544128)===m)if(e.stateNode.complete)e.flags|=8192;else if(Pm())e.flags|=8192;else throw gi=da,ku}else e.flags&=-16777217}function gm(e,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!zg(n))if(Pm())e.flags|=8192;else throw gi=da,ku}function Na(e,n){n!==null&&(e.flags|=4),e.flags&16384&&(n=e.tag!==22?ge():536870912,e.lanes|=n,as|=n)}function tl(e,n){if(!Tt)switch(e.tailMode){case"hidden":n=e.tail;for(var s=null;n!==null;)n.alternate!==null&&(s=n),n=n.sibling;s===null?e.tail=null:s.sibling=null;break;case"collapsed":s=e.tail;for(var u=null;s!==null;)s.alternate!==null&&(u=s),s=s.sibling;u===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:u.sibling=null}}function $t(e){var n=e.alternate!==null&&e.alternate.child===e.child,s=0,u=0;if(n)for(var m=e.child;m!==null;)s|=m.lanes|m.childLanes,u|=m.subtreeFlags&65011712,u|=m.flags&65011712,m.return=e,m=m.sibling;else for(m=e.child;m!==null;)s|=m.lanes|m.childLanes,u|=m.subtreeFlags,u|=m.flags,m.return=e,m=m.sibling;return e.subtreeFlags|=u,e.childLanes=s,n}function I0(e,n,s){var u=n.pendingProps;switch(mu(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return $t(n),null;case 1:return $t(n),null;case 3:return s=n.stateNode,u=null,e!==null&&(u=e.memoizedState.cache),n.memoizedState.cache!==u&&(n.flags|=2048),mr(Wt),fe(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(e===null||e.child===null)&&(Qi(n)?vr(n):e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,yu())),$t(n),null;case 26:var m=n.type,g=n.memoizedState;return e===null?(vr(n),g!==null?($t(n),gm(n,g)):($t(n),ac(n,m,null,u,s))):g?g!==e.memoizedState?(vr(n),$t(n),gm(n,g)):($t(n),n.flags&=-16777217):(e=e.memoizedProps,e!==u&&vr(n),$t(n),ac(n,m,e,u,s)),null;case 27:if(_e(n),s=me.current,m=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==u&&vr(n);else{if(!u){if(n.stateNode===null)throw Error(l(166));return $t(n),null}e=W.current,Qi(n)?Kh(n):(e=jg(m,u,s),n.stateNode=e,vr(n))}return $t(n),null;case 5:if(_e(n),m=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==u&&vr(n);else{if(!u){if(n.stateNode===null)throw Error(l(166));return $t(n),null}if(g=W.current,Qi(n))Kh(n);else{var S=Fa(me.current);switch(g){case 1:g=S.createElementNS("http://www.w3.org/2000/svg",m);break;case 2:g=S.createElementNS("http://www.w3.org/1998/Math/MathML",m);break;default:switch(m){case"svg":g=S.createElementNS("http://www.w3.org/2000/svg",m);break;case"math":g=S.createElementNS("http://www.w3.org/1998/Math/MathML",m);break;case"script":g=S.createElement("div"),g.innerHTML="<script><\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof u.is=="string"?S.createElement("select",{is:u.is}):S.createElement("select"),u.multiple?g.multiple=!0:u.size&&(g.size=u.size);break;default:g=typeof u.is=="string"?S.createElement(m,{is:u.is}):S.createElement(m)}}g[yt]=n,g[et]=u;e:for(S=n.child;S!==null;){if(S.tag===5||S.tag===6)g.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===n)break e;for(;S.sibling===null;){if(S.return===null||S.return===n)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}n.stateNode=g;e:switch(hn(g,m,u),m){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&vr(n)}}return $t(n),ac(n,n.type,e===null?null:e.memoizedProps,n.pendingProps,s),null;case 6:if(e&&n.stateNode!=null)e.memoizedProps!==u&&vr(n);else{if(typeof u!="string"&&n.stateNode===null)throw Error(l(166));if(e=me.current,Qi(n)){if(e=n.stateNode,s=n.memoizedProps,u=null,m=cn,m!==null)switch(m.tag){case 27:case 5:u=m.memoizedProps}e[yt]=n,e=!!(e.nodeValue===s||u!==null&&u.suppressHydrationWarning===!0||fg(e.nodeValue,s)),e||Or(n,!0)}else e=Fa(e).createTextNode(u),e[yt]=n,n.stateNode=e}return $t(n),null;case 31:if(s=n.memoizedState,e===null||e.memoizedState!==null){if(u=Qi(n),s!==null){if(e===null){if(!u)throw Error(l(318));if(e=n.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(l(557));e[yt]=n}else di(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;$t(n),e=!1}else s=yu(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=s),e=!0;if(!e)return n.flags&256?(Rn(n),n):(Rn(n),null);if((n.flags&128)!==0)throw Error(l(558))}return $t(n),null;case 13:if(u=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(m=Qi(n),u!==null&&u.dehydrated!==null){if(e===null){if(!m)throw Error(l(318));if(m=n.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(l(317));m[yt]=n}else di(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;$t(n),m=!1}else m=yu(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=m),m=!0;if(!m)return n.flags&256?(Rn(n),n):(Rn(n),null)}return Rn(n),(n.flags&128)!==0?(n.lanes=s,n):(s=u!==null,e=e!==null&&e.memoizedState!==null,s&&(u=n.child,m=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(m=u.alternate.memoizedState.cachePool.pool),g=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(g=u.memoizedState.cachePool.pool),g!==m&&(u.flags|=2048)),s!==e&&s&&(n.child.flags|=8192),Na(n,n.updateQueue),$t(n),null);case 4:return fe(),e===null&&Ac(n.stateNode.containerInfo),$t(n),null;case 10:return mr(n.type),$t(n),null;case 19:if(te(Zt),u=n.memoizedState,u===null)return $t(n),null;if(m=(n.flags&128)!==0,g=u.rendering,g===null)if(m)tl(u,!1);else{if(Kt!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(g=ma(e),g!==null){for(n.flags|=128,tl(u,!1),e=g.updateQueue,n.updateQueue=e,Na(n,e),n.subtreeFlags=0,e=s,s=n.child;s!==null;)$h(s,e),s=s.sibling;return k(Zt,Zt.current&1|2),Tt&&hr(n,u.treeForkCount),n.child}e=e.sibling}u.tail!==null&&Ve()>Ma&&(n.flags|=128,m=!0,tl(u,!1),n.lanes=4194304)}else{if(!m)if(e=ma(g),e!==null){if(n.flags|=128,m=!0,e=e.updateQueue,n.updateQueue=e,Na(n,e),tl(u,!0),u.tail===null&&u.tailMode==="hidden"&&!g.alternate&&!Tt)return $t(n),null}else 2*Ve()-u.renderingStartTime>Ma&&s!==536870912&&(n.flags|=128,m=!0,tl(u,!1),n.lanes=4194304);u.isBackwards?(g.sibling=n.child,n.child=g):(e=u.last,e!==null?e.sibling=g:n.child=g,u.last=g)}return u.tail!==null?(e=u.tail,u.rendering=e,u.tail=e.sibling,u.renderingStartTime=Ve(),e.sibling=null,s=Zt.current,k(Zt,m?s&1|2:s&1),Tt&&hr(n,u.treeForkCount),e):($t(n),null);case 22:case 23:return Rn(n),Ru(),u=n.memoizedState!==null,e!==null?e.memoizedState!==null!==u&&(n.flags|=8192):u&&(n.flags|=8192),u?(s&536870912)!==0&&(n.flags&128)===0&&($t(n),n.subtreeFlags&6&&(n.flags|=8192)):$t(n),s=n.updateQueue,s!==null&&Na(n,s.retryQueue),s=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(s=e.memoizedState.cachePool.pool),u=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(u=n.memoizedState.cachePool.pool),u!==s&&(n.flags|=2048),e!==null&&te(pi),null;case 24:return s=null,e!==null&&(s=e.memoizedState.cache),n.memoizedState.cache!==s&&(n.flags|=2048),mr(Wt),$t(n),null;case 25:return null;case 30:return null}throw Error(l(156,n.tag))}function B0(e,n){switch(mu(n),n.tag){case 1:return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return mr(Wt),fe(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 26:case 27:case 5:return _e(n),null;case 31:if(n.memoizedState!==null){if(Rn(n),n.alternate===null)throw Error(l(340));di()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 13:if(Rn(n),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(l(340));di()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return te(Zt),null;case 4:return fe(),null;case 10:return mr(n.type),null;case 22:case 23:return Rn(n),Ru(),e!==null&&te(pi),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 24:return mr(Wt),null;case 25:return null;default:return null}}function ym(e,n){switch(mu(n),n.tag){case 3:mr(Wt),fe();break;case 26:case 27:case 5:_e(n);break;case 4:fe();break;case 31:n.memoizedState!==null&&Rn(n);break;case 13:Rn(n);break;case 19:te(Zt);break;case 10:mr(n.type);break;case 22:case 23:Rn(n),Ru(),e!==null&&te(pi);break;case 24:mr(Wt)}}function nl(e,n){try{var s=n.updateQueue,u=s!==null?s.lastEffect:null;if(u!==null){var m=u.next;s=m;do{if((s.tag&e)===e){u=void 0;var g=s.create,S=s.inst;u=g(),S.destroy=u}s=s.next}while(s!==m)}}catch(z){Lt(n,n.return,z)}}function Pr(e,n,s){try{var u=n.updateQueue,m=u!==null?u.lastEffect:null;if(m!==null){var g=m.next;u=g;do{if((u.tag&e)===e){var S=u.inst,z=S.destroy;if(z!==void 0){S.destroy=void 0,m=n;var K=s,de=z;try{de()}catch(ve){Lt(m,K,ve)}}}u=u.next}while(u!==g)}}catch(ve){Lt(n,n.return,ve)}}function bm(e){var n=e.updateQueue;if(n!==null){var s=e.stateNode;try{op(n,s)}catch(u){Lt(e,e.return,u)}}}function vm(e,n,s){s.props=vi(e.type,e.memoizedProps),s.state=e.memoizedState;try{s.componentWillUnmount()}catch(u){Lt(e,n,u)}}function rl(e,n){try{var s=e.ref;if(s!==null){switch(e.tag){case 26:case 27:case 5:var u=e.stateNode;break;case 30:u=e.stateNode;break;default:u=e.stateNode}typeof s=="function"?e.refCleanup=s(u):s.current=u}}catch(m){Lt(e,n,m)}}function tr(e,n){var s=e.ref,u=e.refCleanup;if(s!==null)if(typeof u=="function")try{u()}catch(m){Lt(e,n,m)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof s=="function")try{s(null)}catch(m){Lt(e,n,m)}else s.current=null}function xm(e){var n=e.type,s=e.memoizedProps,u=e.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":s.autoFocus&&u.focus();break e;case"img":s.src?u.src=s.src:s.srcSet&&(u.srcset=s.srcSet)}}catch(m){Lt(e,e.return,m)}}function oc(e,n,s){try{var u=e.stateNode;l1(u,e.type,s,n),u[et]=n}catch(m){Lt(e,e.return,m)}}function wm(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Kr(e.type)||e.tag===4}function uc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||wm(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&&Kr(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 cc(e,n,s){var u=e.tag;if(u===5||u===6)e=e.stateNode,n?(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s).insertBefore(e,n):(n=s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,n.appendChild(e),s=s._reactRootContainer,s!=null||n.onclick!==null||(n.onclick=cr));else if(u!==4&&(u===27&&Kr(e.type)&&(s=e.stateNode,n=null),e=e.child,e!==null))for(cc(e,n,s),e=e.sibling;e!==null;)cc(e,n,s),e=e.sibling}function Aa(e,n,s){var u=e.tag;if(u===5||u===6)e=e.stateNode,n?s.insertBefore(e,n):s.appendChild(e);else if(u!==4&&(u===27&&Kr(e.type)&&(s=e.stateNode),e=e.child,e!==null))for(Aa(e,n,s),e=e.sibling;e!==null;)Aa(e,n,s),e=e.sibling}function Sm(e){var n=e.stateNode,s=e.memoizedProps;try{for(var u=e.type,m=n.attributes;m.length;)n.removeAttributeNode(m[0]);hn(n,u,s),n[yt]=e,n[et]=s}catch(g){Lt(e,e.return,g)}}var xr=!1,nn=!1,dc=!1,jm=typeof WeakSet=="function"?WeakSet:Set,an=null;function q0(e,n){if(e=e.containerInfo,_c=Xa,e=Oh(e),iu(e)){if("selectionStart"in e)var s={start:e.selectionStart,end:e.selectionEnd};else e:{s=(s=e.ownerDocument)&&s.defaultView||window;var u=s.getSelection&&s.getSelection();if(u&&u.rangeCount!==0){s=u.anchorNode;var m=u.anchorOffset,g=u.focusNode;u=u.focusOffset;try{s.nodeType,g.nodeType}catch{s=null;break e}var S=0,z=-1,K=-1,de=0,ve=0,je=e,pe=null;t:for(;;){for(var ye;je!==s||m!==0&&je.nodeType!==3||(z=S+m),je!==g||u!==0&&je.nodeType!==3||(K=S+u),je.nodeType===3&&(S+=je.nodeValue.length),(ye=je.firstChild)!==null;)pe=je,je=ye;for(;;){if(je===e)break t;if(pe===s&&++de===m&&(z=S),pe===g&&++ve===u&&(K=S),(ye=je.nextSibling)!==null)break;je=pe,pe=je.parentNode}je=ye}s=z===-1||K===-1?null:{start:z,end:K}}else s=null}s=s||{start:0,end:0}}else s=null;for(Mc={focusedElem:e,selectionRange:s},Xa=!1,an=n;an!==null;)if(n=an,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,an=e;else for(;an!==null;){switch(n=an,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(s=0;s<e.length;s++)m=e[s],m.ref.impl=m.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&g!==null){e=void 0,s=n,m=g.memoizedProps,g=g.memoizedState,u=s.stateNode;try{var He=vi(s.type,m);e=u.getSnapshotBeforeUpdate(He,g),u.__reactInternalSnapshotBeforeUpdate=e}catch(tt){Lt(s,s.return,tt)}}break;case 3:if((e&1024)!==0){if(e=n.stateNode.containerInfo,s=e.nodeType,s===9)Lc(e);else if(s===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Lc(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(l(163))}if(e=n.sibling,e!==null){e.return=n.return,an=e;break}an=n.return}}function km(e,n,s){var u=s.flags;switch(s.tag){case 0:case 11:case 15:Sr(e,s),u&4&&nl(5,s);break;case 1:if(Sr(e,s),u&4)if(e=s.stateNode,n===null)try{e.componentDidMount()}catch(S){Lt(s,s.return,S)}else{var m=vi(s.type,n.memoizedProps);n=n.memoizedState;try{e.componentDidUpdate(m,n,e.__reactInternalSnapshotBeforeUpdate)}catch(S){Lt(s,s.return,S)}}u&64&&bm(s),u&512&&rl(s,s.return);break;case 3:if(Sr(e,s),u&64&&(e=s.updateQueue,e!==null)){if(n=null,s.child!==null)switch(s.child.tag){case 27:case 5:n=s.child.stateNode;break;case 1:n=s.child.stateNode}try{op(e,n)}catch(S){Lt(s,s.return,S)}}break;case 27:n===null&&u&4&&Sm(s);case 26:case 5:Sr(e,s),n===null&&u&4&&xm(s),u&512&&rl(s,s.return);break;case 12:Sr(e,s);break;case 31:Sr(e,s),u&4&&Tm(e,s);break;case 13:Sr(e,s),u&4&&Nm(e,s),u&64&&(e=s.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(s=Q0.bind(null,s),p1(e,s))));break;case 22:if(u=s.memoizedState!==null||xr,!u){n=n!==null&&n.memoizedState!==null||nn,m=xr;var g=nn;xr=u,(nn=n)&&!g?jr(e,s,(s.subtreeFlags&8772)!==0):Sr(e,s),xr=m,nn=g}break;case 30:break;default:Sr(e,s)}}function Em(e){var n=e.alternate;n!==null&&(e.alternate=null,Em(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&Ho(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 Vt=null,xn=!1;function wr(e,n,s){for(s=s.child;s!==null;)Cm(e,n,s),s=s.sibling}function Cm(e,n,s){if(Ne&&typeof Ne.onCommitFiberUnmount=="function")try{Ne.onCommitFiberUnmount(Re,s)}catch{}switch(s.tag){case 26:nn||tr(s,n),wr(e,n,s),s.memoizedState?s.memoizedState.count--:s.stateNode&&(s=s.stateNode,s.parentNode.removeChild(s));break;case 27:nn||tr(s,n);var u=Vt,m=xn;Kr(s.type)&&(Vt=s.stateNode,xn=!1),wr(e,n,s),fl(s.stateNode),Vt=u,xn=m;break;case 5:nn||tr(s,n);case 6:if(u=Vt,m=xn,Vt=null,wr(e,n,s),Vt=u,xn=m,Vt!==null)if(xn)try{(Vt.nodeType===9?Vt.body:Vt.nodeName==="HTML"?Vt.ownerDocument.body:Vt).removeChild(s.stateNode)}catch(g){Lt(s,n,g)}else try{Vt.removeChild(s.stateNode)}catch(g){Lt(s,n,g)}break;case 18:Vt!==null&&(xn?(e=Vt,bg(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,s.stateNode),ms(e)):bg(Vt,s.stateNode));break;case 4:u=Vt,m=xn,Vt=s.stateNode.containerInfo,xn=!0,wr(e,n,s),Vt=u,xn=m;break;case 0:case 11:case 14:case 15:Pr(2,s,n),nn||Pr(4,s,n),wr(e,n,s);break;case 1:nn||(tr(s,n),u=s.stateNode,typeof u.componentWillUnmount=="function"&&vm(s,n,u)),wr(e,n,s);break;case 21:wr(e,n,s);break;case 22:nn=(u=nn)||s.memoizedState!==null,wr(e,n,s),nn=u;break;default:wr(e,n,s)}}function Tm(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{ms(e)}catch(s){Lt(n,n.return,s)}}}function Nm(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{ms(e)}catch(s){Lt(n,n.return,s)}}function U0(e){switch(e.tag){case 31:case 13:case 19:var n=e.stateNode;return n===null&&(n=e.stateNode=new jm),n;case 22:return e=e.stateNode,n=e._retryCache,n===null&&(n=e._retryCache=new jm),n;default:throw Error(l(435,e.tag))}}function Ra(e,n){var s=U0(e);n.forEach(function(u){if(!s.has(u)){s.add(u);var m=K0.bind(null,e,u);u.then(m,m)}})}function wn(e,n){var s=n.deletions;if(s!==null)for(var u=0;u<s.length;u++){var m=s[u],g=e,S=n,z=S;e:for(;z!==null;){switch(z.tag){case 27:if(Kr(z.type)){Vt=z.stateNode,xn=!1;break e}break;case 5:Vt=z.stateNode,xn=!1;break e;case 3:case 4:Vt=z.stateNode.containerInfo,xn=!0;break e}z=z.return}if(Vt===null)throw Error(l(160));Cm(g,S,m),Vt=null,xn=!1,g=m.alternate,g!==null&&(g.return=null),m.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)Am(n,e),n=n.sibling}var Qn=null;function Am(e,n){var s=e.alternate,u=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:wn(n,e),Sn(e),u&4&&(Pr(3,e,e.return),nl(3,e),Pr(5,e,e.return));break;case 1:wn(n,e),Sn(e),u&512&&(nn||s===null||tr(s,s.return)),u&64&&xr&&(e=e.updateQueue,e!==null&&(u=e.callbacks,u!==null&&(s=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=s===null?u:s.concat(u))));break;case 26:var m=Qn;if(wn(n,e),Sn(e),u&512&&(nn||s===null||tr(s,s.return)),u&4){var g=s!==null?s.memoizedState:null;if(u=e.memoizedState,s===null)if(u===null)if(e.stateNode===null){e:{u=e.type,s=e.memoizedProps,m=m.ownerDocument||m;t:switch(u){case"title":g=m.getElementsByTagName("title")[0],(!g||g[zr]||g[yt]||g.namespaceURI==="http://www.w3.org/2000/svg"||g.hasAttribute("itemprop"))&&(g=m.createElement(u),m.head.insertBefore(g,m.querySelector("head > title"))),hn(g,u,s),g[yt]=e,ln(g),u=g;break e;case"link":var S=Ag("link","href",m).get(u+(s.href||""));if(S){for(var z=0;z<S.length;z++)if(g=S[z],g.getAttribute("href")===(s.href==null||s.href===""?null:s.href)&&g.getAttribute("rel")===(s.rel==null?null:s.rel)&&g.getAttribute("title")===(s.title==null?null:s.title)&&g.getAttribute("crossorigin")===(s.crossOrigin==null?null:s.crossOrigin)){S.splice(z,1);break t}}g=m.createElement(u),hn(g,u,s),m.head.appendChild(g);break;case"meta":if(S=Ag("meta","content",m).get(u+(s.content||""))){for(z=0;z<S.length;z++)if(g=S[z],g.getAttribute("content")===(s.content==null?null:""+s.content)&&g.getAttribute("name")===(s.name==null?null:s.name)&&g.getAttribute("property")===(s.property==null?null:s.property)&&g.getAttribute("http-equiv")===(s.httpEquiv==null?null:s.httpEquiv)&&g.getAttribute("charset")===(s.charSet==null?null:s.charSet)){S.splice(z,1);break t}}g=m.createElement(u),hn(g,u,s),m.head.appendChild(g);break;default:throw Error(l(468,u))}g[yt]=e,ln(g),u=g}e.stateNode=u}else Rg(m,e.type,e.stateNode);else e.stateNode=Ng(m,u,e.memoizedProps);else g!==u?(g===null?s.stateNode!==null&&(s=s.stateNode,s.parentNode.removeChild(s)):g.count--,u===null?Rg(m,e.type,e.stateNode):Ng(m,u,e.memoizedProps)):u===null&&e.stateNode!==null&&oc(e,e.memoizedProps,s.memoizedProps)}break;case 27:wn(n,e),Sn(e),u&512&&(nn||s===null||tr(s,s.return)),s!==null&&u&4&&oc(e,e.memoizedProps,s.memoizedProps);break;case 5:if(wn(n,e),Sn(e),u&512&&(nn||s===null||tr(s,s.return)),e.flags&32){m=e.stateNode;try{Bi(m,"")}catch(He){Lt(e,e.return,He)}}u&4&&e.stateNode!=null&&(m=e.memoizedProps,oc(e,m,s!==null?s.memoizedProps:m)),u&1024&&(dc=!0);break;case 6:if(wn(n,e),Sn(e),u&4){if(e.stateNode===null)throw Error(l(162));u=e.memoizedProps,s=e.stateNode;try{s.nodeValue=u}catch(He){Lt(e,e.return,He)}}break;case 3:if(Va=null,m=Qn,Qn=$a(n.containerInfo),wn(n,e),Qn=m,Sn(e),u&4&&s!==null&&s.memoizedState.isDehydrated)try{ms(n.containerInfo)}catch(He){Lt(e,e.return,He)}dc&&(dc=!1,Rm(e));break;case 4:u=Qn,Qn=$a(e.stateNode.containerInfo),wn(n,e),Sn(e),Qn=u;break;case 12:wn(n,e),Sn(e);break;case 31:wn(n,e),Sn(e),u&4&&(u=e.updateQueue,u!==null&&(e.updateQueue=null,Ra(e,u)));break;case 13:wn(n,e),Sn(e),e.child.flags&8192&&e.memoizedState!==null!=(s!==null&&s.memoizedState!==null)&&(_a=Ve()),u&4&&(u=e.updateQueue,u!==null&&(e.updateQueue=null,Ra(e,u)));break;case 22:m=e.memoizedState!==null;var K=s!==null&&s.memoizedState!==null,de=xr,ve=nn;if(xr=de||m,nn=ve||K,wn(n,e),nn=ve,xr=de,Sn(e),u&8192)e:for(n=e.stateNode,n._visibility=m?n._visibility&-2:n._visibility|1,m&&(s===null||K||xr||nn||xi(e)),s=null,n=e;;){if(n.tag===5||n.tag===26){if(s===null){K=s=n;try{if(g=K.stateNode,m)S=g.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none";else{z=K.stateNode;var je=K.memoizedProps.style,pe=je!=null&&je.hasOwnProperty("display")?je.display:null;z.style.display=pe==null||typeof pe=="boolean"?"":(""+pe).trim()}}catch(He){Lt(K,K.return,He)}}}else if(n.tag===6){if(s===null){K=n;try{K.stateNode.nodeValue=m?"":K.memoizedProps}catch(He){Lt(K,K.return,He)}}}else if(n.tag===18){if(s===null){K=n;try{var ye=K.stateNode;m?vg(ye,!0):vg(K.stateNode,!1)}catch(He){Lt(K,K.return,He)}}}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;s===n&&(s=null),n=n.return}s===n&&(s=null),n.sibling.return=n.return,n=n.sibling}u&4&&(u=e.updateQueue,u!==null&&(s=u.retryQueue,s!==null&&(u.retryQueue=null,Ra(e,s))));break;case 19:wn(n,e),Sn(e),u&4&&(u=e.updateQueue,u!==null&&(e.updateQueue=null,Ra(e,u)));break;case 30:break;case 21:break;default:wn(n,e),Sn(e)}}function Sn(e){var n=e.flags;if(n&2){try{for(var s,u=e.return;u!==null;){if(wm(u)){s=u;break}u=u.return}if(s==null)throw Error(l(160));switch(s.tag){case 27:var m=s.stateNode,g=uc(e);Aa(e,g,m);break;case 5:var S=s.stateNode;s.flags&32&&(Bi(S,""),s.flags&=-33);var z=uc(e);Aa(e,z,S);break;case 3:case 4:var K=s.stateNode.containerInfo,de=uc(e);cc(e,de,K);break;default:throw Error(l(161))}}catch(ve){Lt(e,e.return,ve)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function Rm(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var n=e;Rm(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),e=e.sibling}}function Sr(e,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)km(e,n.alternate,n),n=n.sibling}function xi(e){for(e=e.child;e!==null;){var n=e;switch(n.tag){case 0:case 11:case 14:case 15:Pr(4,n,n.return),xi(n);break;case 1:tr(n,n.return);var s=n.stateNode;typeof s.componentWillUnmount=="function"&&vm(n,n.return,s),xi(n);break;case 27:fl(n.stateNode);case 26:case 5:tr(n,n.return),xi(n);break;case 22:n.memoizedState===null&&xi(n);break;case 30:xi(n);break;default:xi(n)}e=e.sibling}}function jr(e,n,s){for(s=s&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var u=n.alternate,m=e,g=n,S=g.flags;switch(g.tag){case 0:case 11:case 15:jr(m,g,s),nl(4,g);break;case 1:if(jr(m,g,s),u=g,m=u.stateNode,typeof m.componentDidMount=="function")try{m.componentDidMount()}catch(de){Lt(u,u.return,de)}if(u=g,m=u.updateQueue,m!==null){var z=u.stateNode;try{var K=m.shared.hiddenCallbacks;if(K!==null)for(m.shared.hiddenCallbacks=null,m=0;m<K.length;m++)ap(K[m],z)}catch(de){Lt(u,u.return,de)}}s&&S&64&&bm(g),rl(g,g.return);break;case 27:Sm(g);case 26:case 5:jr(m,g,s),s&&u===null&&S&4&&xm(g),rl(g,g.return);break;case 12:jr(m,g,s);break;case 31:jr(m,g,s),s&&S&4&&Tm(m,g);break;case 13:jr(m,g,s),s&&S&4&&Nm(m,g);break;case 22:g.memoizedState===null&&jr(m,g,s),rl(g,g.return);break;case 30:break;default:jr(m,g,s)}n=n.sibling}}function fc(e,n){var s=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(s=e.memoizedState.cachePool.pool),e=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(e=n.memoizedState.cachePool.pool),e!==s&&(e!=null&&e.refCount++,s!=null&&Fs(s))}function hc(e,n){e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&Fs(e))}function Kn(e,n,s,u){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)zm(e,n,s,u),n=n.sibling}function zm(e,n,s,u){var m=n.flags;switch(n.tag){case 0:case 11:case 15:Kn(e,n,s,u),m&2048&&nl(9,n);break;case 1:Kn(e,n,s,u);break;case 3:Kn(e,n,s,u),m&2048&&(e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&Fs(e)));break;case 12:if(m&2048){Kn(e,n,s,u),e=n.stateNode;try{var g=n.memoizedProps,S=g.id,z=g.onPostCommit;typeof z=="function"&&z(S,n.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(K){Lt(n,n.return,K)}}else Kn(e,n,s,u);break;case 31:Kn(e,n,s,u);break;case 13:Kn(e,n,s,u);break;case 23:break;case 22:g=n.stateNode,S=n.alternate,n.memoizedState!==null?g._visibility&2?Kn(e,n,s,u):il(e,n):g._visibility&2?Kn(e,n,s,u):(g._visibility|=2,is(e,n,s,u,(n.subtreeFlags&10256)!==0||!1)),m&2048&&fc(S,n);break;case 24:Kn(e,n,s,u),m&2048&&hc(n.alternate,n);break;default:Kn(e,n,s,u)}}function is(e,n,s,u,m){for(m=m&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var g=e,S=n,z=s,K=u,de=S.flags;switch(S.tag){case 0:case 11:case 15:is(g,S,z,K,m),nl(8,S);break;case 23:break;case 22:var ve=S.stateNode;S.memoizedState!==null?ve._visibility&2?is(g,S,z,K,m):il(g,S):(ve._visibility|=2,is(g,S,z,K,m)),m&&de&2048&&fc(S.alternate,S);break;case 24:is(g,S,z,K,m),m&&de&2048&&hc(S.alternate,S);break;default:is(g,S,z,K,m)}n=n.sibling}}function il(e,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var s=e,u=n,m=u.flags;switch(u.tag){case 22:il(s,u),m&2048&&fc(u.alternate,u);break;case 24:il(s,u),m&2048&&hc(u.alternate,u);break;default:il(s,u)}n=n.sibling}}var sl=8192;function ss(e,n,s){if(e.subtreeFlags&sl)for(e=e.child;e!==null;)_m(e,n,s),e=e.sibling}function _m(e,n,s){switch(e.tag){case 26:ss(e,n,s),e.flags&sl&&e.memoizedState!==null&&C1(s,Qn,e.memoizedState,e.memoizedProps);break;case 5:ss(e,n,s);break;case 3:case 4:var u=Qn;Qn=$a(e.stateNode.containerInfo),ss(e,n,s),Qn=u;break;case 22:e.memoizedState===null&&(u=e.alternate,u!==null&&u.memoizedState!==null?(u=sl,sl=16777216,ss(e,n,s),sl=u):ss(e,n,s));break;default:ss(e,n,s)}}function Mm(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 ll(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var s=0;s<n.length;s++){var u=n[s];an=u,Om(u,e)}Mm(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Dm(e),e=e.sibling}function Dm(e){switch(e.tag){case 0:case 11:case 15:ll(e),e.flags&2048&&Pr(9,e,e.return);break;case 3:ll(e);break;case 12:ll(e);break;case 22:var n=e.stateNode;e.memoizedState!==null&&n._visibility&2&&(e.return===null||e.return.tag!==13)?(n._visibility&=-3,za(e)):ll(e);break;default:ll(e)}}function za(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var s=0;s<n.length;s++){var u=n[s];an=u,Om(u,e)}Mm(e)}for(e=e.child;e!==null;){switch(n=e,n.tag){case 0:case 11:case 15:Pr(8,n,n.return),za(n);break;case 22:s=n.stateNode,s._visibility&2&&(s._visibility&=-3,za(n));break;default:za(n)}e=e.sibling}}function Om(e,n){for(;an!==null;){var s=an;switch(s.tag){case 0:case 11:case 15:Pr(8,s,n);break;case 23:case 22:if(s.memoizedState!==null&&s.memoizedState.cachePool!==null){var u=s.memoizedState.cachePool.pool;u!=null&&u.refCount++}break;case 24:Fs(s.memoizedState.cache)}if(u=s.child,u!==null)u.return=s,an=u;else e:for(s=e;an!==null;){u=an;var m=u.sibling,g=u.return;if(Em(u),u===s){an=null;break e}if(m!==null){m.return=g,an=m;break e}an=g}}}var H0={getCacheForType:function(e){var n=dn(Wt),s=n.data.get(e);return s===void 0&&(s=e(),n.data.set(e,s)),s},cacheSignal:function(){return dn(Wt).controller.signal}},P0=typeof WeakMap=="function"?WeakMap:Map,Mt=0,Ut=null,wt=null,kt=0,Ot=0,zn=null,Fr=!1,ls=!1,pc=!1,kr=0,Kt=0,$r=0,wi=0,mc=0,_n=0,as=0,al=null,jn=null,gc=!1,_a=0,Lm=0,Ma=1/0,Da=null,Gr=null,sn=0,Vr=null,os=null,Er=0,yc=0,bc=null,Im=null,ol=0,vc=null;function Mn(){return(Mt&2)!==0&&kt!==0?kt&-kt:P.T!==null?Ec():Xt()}function Bm(){if(_n===0)if((kt&536870912)===0||Tt){var e=O;O<<=1,(O&3932160)===0&&(O=262144),_n=e}else _n=536870912;return e=An.current,e!==null&&(e.flags|=32),_n}function kn(e,n,s){(e===Ut&&(Ot===2||Ot===9)||e.cancelPendingCommit!==null)&&(us(e,0),Yr(e,kt,_n,!1)),Ct(e,s),((Mt&2)===0||e!==Ut)&&(e===Ut&&((Mt&2)===0&&(wi|=s),Kt===4&&Yr(e,kt,_n,!1)),nr(e))}function qm(e,n,s){if((Mt&6)!==0)throw Error(l(327));var u=!s&&(n&127)===0&&(n&e.expiredLanes)===0||Te(e,n),m=u?G0(e,n):wc(e,n,!0),g=u;do{if(m===0){ls&&!u&&Yr(e,n,0,!1);break}else{if(s=e.current.alternate,g&&!F0(s)){m=wc(e,n,!1),g=!1;continue}if(m===2){if(g=n,e.errorRecoveryDisabledLanes&g)var S=0;else S=e.pendingLanes&-536870913,S=S!==0?S:S&536870912?536870912:0;if(S!==0){n=S;e:{var z=e;m=al;var K=z.current.memoizedState.isDehydrated;if(K&&(us(z,S).flags|=256),S=wc(z,S,!1),S!==2){if(pc&&!K){z.errorRecoveryDisabledLanes|=g,wi|=g,m=4;break e}g=jn,jn=m,g!==null&&(jn===null?jn=g:jn.push.apply(jn,g))}m=S}if(g=!1,m!==2)continue}}if(m===1){us(e,0),Yr(e,n,0,!0);break}e:{switch(u=e,g=m,g){case 0:case 1:throw Error(l(345));case 4:if((n&4194048)!==n)break;case 6:Yr(u,n,_n,!Fr);break e;case 2:jn=null;break;case 3:case 5:break;default:throw Error(l(329))}if((n&62914560)===n&&(m=_a+300-Ve(),10<m)){if(Yr(u,n,_n,!Fr),Z(u,0,!0)!==0)break e;Er=n,u.timeoutHandle=gg(Um.bind(null,u,s,jn,Da,gc,n,_n,wi,as,Fr,g,"Throttled",-0,0),m);break e}Um(u,s,jn,Da,gc,n,_n,wi,as,Fr,g,null,-0,0)}}break}while(!0);nr(e)}function Um(e,n,s,u,m,g,S,z,K,de,ve,je,pe,ye){if(e.timeoutHandle=-1,je=n.subtreeFlags,je&8192||(je&16785408)===16785408){je={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:cr},_m(n,g,je);var He=(g&62914560)===g?_a-Ve():(g&4194048)===g?Lm-Ve():0;if(He=T1(je,He),He!==null){Er=g,e.cancelPendingCommit=He(Qm.bind(null,e,n,g,s,u,m,S,z,K,ve,je,null,pe,ye)),Yr(e,g,S,!de);return}}Qm(e,n,g,s,u,m,S,z,K)}function F0(e){for(var n=e;;){var s=n.tag;if((s===0||s===11||s===15)&&n.flags&16384&&(s=n.updateQueue,s!==null&&(s=s.stores,s!==null)))for(var u=0;u<s.length;u++){var m=s[u],g=m.getSnapshot;m=m.value;try{if(!Tn(g(),m))return!1}catch{return!1}}if(s=n.child,n.subtreeFlags&16384&&s!==null)s.return=n,n=s;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 Yr(e,n,s,u){n&=~mc,n&=~wi,e.suspendedLanes|=n,e.pingedLanes&=~n,u&&(e.warmLanes|=n),u=e.expirationTimes;for(var m=n;0<m;){var g=31-Ue(m),S=1<<g;u[g]=-1,m&=~S}s!==0&&Ie(e,s,n)}function Oa(){return(Mt&6)===0?(ul(0),!1):!0}function xc(){if(wt!==null){if(Ot===0)var e=wt.return;else e=wt,pr=fi=null,Lu(e),Wi=null,Gs=0,e=wt;for(;e!==null;)ym(e.alternate,e),e=e.return;wt=null}}function us(e,n){var s=e.timeoutHandle;s!==-1&&(e.timeoutHandle=-1,u1(s)),s=e.cancelPendingCommit,s!==null&&(e.cancelPendingCommit=null,s()),Er=0,xc(),Ut=e,wt=s=fr(e.current,null),kt=n,Ot=0,zn=null,Fr=!1,ls=Te(e,n),pc=!1,as=_n=mc=wi=$r=Kt=0,jn=al=null,gc=!1,(n&8)!==0&&(n|=n&32);var u=e.entangledLanes;if(u!==0)for(e=e.entanglements,u&=n;0<u;){var m=31-Ue(u),g=1<<m;n|=e[m],u&=~g}return kr=n,na(),s}function Hm(e,n){mt=null,P.H=Ws,n===Ji||n===ca?(n=rp(),Ot=3):n===ku?(n=rp(),Ot=4):Ot=n===Ju?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,zn=n,wt===null&&(Kt=1,ka(e,qn(n,e.current)))}function Pm(){var e=An.current;return e===null?!0:(kt&4194048)===kt?Fn===null:(kt&62914560)===kt||(kt&536870912)!==0?e===Fn:!1}function Fm(){var e=P.H;return P.H=Ws,e===null?Ws:e}function $m(){var e=P.A;return P.A=H0,e}function La(){Kt=4,Fr||(kt&4194048)!==kt&&An.current!==null||(ls=!0),($r&134217727)===0&&(wi&134217727)===0||Ut===null||Yr(Ut,kt,_n,!1)}function wc(e,n,s){var u=Mt;Mt|=2;var m=Fm(),g=$m();(Ut!==e||kt!==n)&&(Da=null,us(e,n)),n=!1;var S=Kt;e:do try{if(Ot!==0&&wt!==null){var z=wt,K=zn;switch(Ot){case 8:xc(),S=6;break e;case 3:case 2:case 9:case 6:An.current===null&&(n=!0);var de=Ot;if(Ot=0,zn=null,cs(e,z,K,de),s&&ls){S=0;break e}break;default:de=Ot,Ot=0,zn=null,cs(e,z,K,de)}}$0(),S=Kt;break}catch(ve){Hm(e,ve)}while(!0);return n&&e.shellSuspendCounter++,pr=fi=null,Mt=u,P.H=m,P.A=g,wt===null&&(Ut=null,kt=0,na()),S}function $0(){for(;wt!==null;)Gm(wt)}function G0(e,n){var s=Mt;Mt|=2;var u=Fm(),m=$m();Ut!==e||kt!==n?(Da=null,Ma=Ve()+500,us(e,n)):ls=Te(e,n);e:do try{if(Ot!==0&&wt!==null){n=wt;var g=zn;t:switch(Ot){case 1:Ot=0,zn=null,cs(e,n,g,1);break;case 2:case 9:if(tp(g)){Ot=0,zn=null,Vm(n);break}n=function(){Ot!==2&&Ot!==9||Ut!==e||(Ot=7),nr(e)},g.then(n,n);break e;case 3:Ot=7;break e;case 4:Ot=5;break e;case 7:tp(g)?(Ot=0,zn=null,Vm(n)):(Ot=0,zn=null,cs(e,n,g,7));break;case 5:var S=null;switch(wt.tag){case 26:S=wt.memoizedState;case 5:case 27:var z=wt;if(S?zg(S):z.stateNode.complete){Ot=0,zn=null;var K=z.sibling;if(K!==null)wt=K;else{var de=z.return;de!==null?(wt=de,Ia(de)):wt=null}break t}}Ot=0,zn=null,cs(e,n,g,5);break;case 6:Ot=0,zn=null,cs(e,n,g,6);break;case 8:xc(),Kt=6;break e;default:throw Error(l(462))}}V0();break}catch(ve){Hm(e,ve)}while(!0);return pr=fi=null,P.H=u,P.A=m,Mt=s,wt!==null?0:(Ut=null,kt=0,na(),Kt)}function V0(){for(;wt!==null&&!Ke();)Gm(wt)}function Gm(e){var n=mm(e.alternate,e,kr);e.memoizedProps=e.pendingProps,n===null?Ia(e):wt=n}function Vm(e){var n=e,s=n.alternate;switch(n.tag){case 15:case 0:n=um(s,n,n.pendingProps,n.type,void 0,kt);break;case 11:n=um(s,n,n.pendingProps,n.type.render,n.ref,kt);break;case 5:Lu(n);default:ym(s,n),n=wt=$h(n,kr),n=mm(s,n,kr)}e.memoizedProps=e.pendingProps,n===null?Ia(e):wt=n}function cs(e,n,s,u){pr=fi=null,Lu(n),Wi=null,Gs=0;var m=n.return;try{if(D0(e,m,n,s,kt)){Kt=1,ka(e,qn(s,e.current)),wt=null;return}}catch(g){if(m!==null)throw wt=m,g;Kt=1,ka(e,qn(s,e.current)),wt=null;return}n.flags&32768?(Tt||u===1?e=!0:ls||(kt&536870912)!==0?e=!1:(Fr=e=!0,(u===2||u===9||u===3||u===6)&&(u=An.current,u!==null&&u.tag===13&&(u.flags|=16384))),Ym(n,e)):Ia(n)}function Ia(e){var n=e;do{if((n.flags&32768)!==0){Ym(n,Fr);return}e=n.return;var s=I0(n.alternate,n,kr);if(s!==null){wt=s;return}if(n=n.sibling,n!==null){wt=n;return}wt=n=e}while(n!==null);Kt===0&&(Kt=5)}function Ym(e,n){do{var s=B0(e.alternate,e);if(s!==null){s.flags&=32767,wt=s;return}if(s=e.return,s!==null&&(s.flags|=32768,s.subtreeFlags=0,s.deletions=null),!n&&(e=e.sibling,e!==null)){wt=e;return}wt=e=s}while(e!==null);Kt=6,wt=null}function Qm(e,n,s,u,m,g,S,z,K){e.cancelPendingCommit=null;do Ba();while(sn!==0);if((Mt&6)!==0)throw Error(l(327));if(n!==null){if(n===e.current)throw Error(l(177));if(g=n.lanes|n.childLanes,g|=uu,he(e,s,g,S,z,K),e===Ut&&(wt=Ut=null,kt=0),os=n,Vr=e,Er=s,yc=g,bc=m,Im=u,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,X0(Ee,function(){return Wm(),null})):(e.callbackNode=null,e.callbackPriority=0),u=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||u){u=P.T,P.T=null,m=G.p,G.p=2,S=Mt,Mt|=4;try{q0(e,n,s)}finally{Mt=S,G.p=m,P.T=u}}sn=1,Km(),Xm(),Zm()}}function Km(){if(sn===1){sn=0;var e=Vr,n=os,s=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||s){s=P.T,P.T=null;var u=G.p;G.p=2;var m=Mt;Mt|=4;try{Am(n,e);var g=Mc,S=Oh(e.containerInfo),z=g.focusedElem,K=g.selectionRange;if(S!==z&&z&&z.ownerDocument&&Dh(z.ownerDocument.documentElement,z)){if(K!==null&&iu(z)){var de=K.start,ve=K.end;if(ve===void 0&&(ve=de),"selectionStart"in z)z.selectionStart=de,z.selectionEnd=Math.min(ve,z.value.length);else{var je=z.ownerDocument||document,pe=je&&je.defaultView||window;if(pe.getSelection){var ye=pe.getSelection(),He=z.textContent.length,tt=Math.min(K.start,He),qt=K.end===void 0?tt:Math.min(K.end,He);!ye.extend&&tt>qt&&(S=qt,qt=tt,tt=S);var ae=Mh(z,tt),ee=Mh(z,qt);if(ae&&ee&&(ye.rangeCount!==1||ye.anchorNode!==ae.node||ye.anchorOffset!==ae.offset||ye.focusNode!==ee.node||ye.focusOffset!==ee.offset)){var ce=je.createRange();ce.setStart(ae.node,ae.offset),ye.removeAllRanges(),tt>qt?(ye.addRange(ce),ye.extend(ee.node,ee.offset)):(ce.setEnd(ee.node,ee.offset),ye.addRange(ce))}}}}for(je=[],ye=z;ye=ye.parentNode;)ye.nodeType===1&&je.push({element:ye,left:ye.scrollLeft,top:ye.scrollTop});for(typeof z.focus=="function"&&z.focus(),z=0;z<je.length;z++){var Se=je[z];Se.element.scrollLeft=Se.left,Se.element.scrollTop=Se.top}}Xa=!!_c,Mc=_c=null}finally{Mt=m,G.p=u,P.T=s}}e.current=n,sn=2}}function Xm(){if(sn===2){sn=0;var e=Vr,n=os,s=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||s){s=P.T,P.T=null;var u=G.p;G.p=2;var m=Mt;Mt|=4;try{km(e,n.alternate,n)}finally{Mt=m,G.p=u,P.T=s}}sn=3}}function Zm(){if(sn===4||sn===3){sn=0,rt();var e=Vr,n=os,s=Er,u=Im;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?sn=5:(sn=0,os=Vr=null,Jm(e,e.pendingLanes));var m=e.pendingLanes;if(m===0&&(Gr=null),At(s),n=n.stateNode,Ne&&typeof Ne.onCommitFiberRoot=="function")try{Ne.onCommitFiberRoot(Re,n,void 0,(n.current.flags&128)===128)}catch{}if(u!==null){n=P.T,m=G.p,G.p=2,P.T=null;try{for(var g=e.onRecoverableError,S=0;S<u.length;S++){var z=u[S];g(z.value,{componentStack:z.stack})}}finally{P.T=n,G.p=m}}(Er&3)!==0&&Ba(),nr(e),m=e.pendingLanes,(s&261930)!==0&&(m&42)!==0?e===vc?ol++:(ol=0,vc=e):ol=0,ul(0)}}function Jm(e,n){(e.pooledCacheLanes&=n)===0&&(n=e.pooledCache,n!=null&&(e.pooledCache=null,Fs(n)))}function Ba(){return Km(),Xm(),Zm(),Wm()}function Wm(){if(sn!==5)return!1;var e=Vr,n=yc;yc=0;var s=At(Er),u=P.T,m=G.p;try{G.p=32>s?32:s,P.T=null,s=bc,bc=null;var g=Vr,S=Er;if(sn=0,os=Vr=null,Er=0,(Mt&6)!==0)throw Error(l(331));var z=Mt;if(Mt|=4,Dm(g.current),zm(g,g.current,S,s),Mt=z,ul(0,!1),Ne&&typeof Ne.onPostCommitFiberRoot=="function")try{Ne.onPostCommitFiberRoot(Re,g)}catch{}return!0}finally{G.p=m,P.T=u,Jm(e,n)}}function eg(e,n,s){n=qn(s,n),n=Zu(e.stateNode,n,2),e=qr(e,n,2),e!==null&&(Ct(e,2),nr(e))}function Lt(e,n,s){if(e.tag===3)eg(e,e,s);else for(;n!==null;){if(n.tag===3){eg(n,e,s);break}else if(n.tag===1){var u=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(Gr===null||!Gr.has(u))){e=qn(s,e),s=tm(2),u=qr(n,s,2),u!==null&&(nm(s,u,n,e),Ct(u,2),nr(u));break}}n=n.return}}function Sc(e,n,s){var u=e.pingCache;if(u===null){u=e.pingCache=new P0;var m=new Set;u.set(n,m)}else m=u.get(n),m===void 0&&(m=new Set,u.set(n,m));m.has(s)||(pc=!0,m.add(s),e=Y0.bind(null,e,n,s),n.then(e,e))}function Y0(e,n,s){var u=e.pingCache;u!==null&&u.delete(n),e.pingedLanes|=e.suspendedLanes&s,e.warmLanes&=~s,Ut===e&&(kt&s)===s&&(Kt===4||Kt===3&&(kt&62914560)===kt&&300>Ve()-_a?(Mt&2)===0&&us(e,0):mc|=s,as===kt&&(as=0)),nr(e)}function tg(e,n){n===0&&(n=ge()),e=ui(e,n),e!==null&&(Ct(e,n),nr(e))}function Q0(e){var n=e.memoizedState,s=0;n!==null&&(s=n.retryLane),tg(e,s)}function K0(e,n){var s=0;switch(e.tag){case 31:case 13:var u=e.stateNode,m=e.memoizedState;m!==null&&(s=m.retryLane);break;case 19:u=e.stateNode;break;case 22:u=e.stateNode._retryCache;break;default:throw Error(l(314))}u!==null&&u.delete(n),tg(e,s)}function X0(e,n){return at(e,n)}var qa=null,ds=null,jc=!1,Ua=!1,kc=!1,Qr=0;function nr(e){e!==ds&&e.next===null&&(ds===null?qa=ds=e:ds=ds.next=e),Ua=!0,jc||(jc=!0,J0())}function ul(e,n){if(!kc&&Ua){kc=!0;do for(var s=!1,u=qa;u!==null;){if(e!==0){var m=u.pendingLanes;if(m===0)var g=0;else{var S=u.suspendedLanes,z=u.pingedLanes;g=(1<<31-Ue(42|e)+1)-1,g&=m&~(S&~z),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(s=!0,sg(u,g))}else g=kt,g=Z(u,u===Ut?g:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(g&3)===0||Te(u,g)||(s=!0,sg(u,g));u=u.next}while(s);kc=!1}}function Z0(){ng()}function ng(){Ua=jc=!1;var e=0;Qr!==0&&o1()&&(e=Qr);for(var n=Ve(),s=null,u=qa;u!==null;){var m=u.next,g=rg(u,n);g===0?(u.next=null,s===null?qa=m:s.next=m,m===null&&(ds=s)):(s=u,(e!==0||(g&3)!==0)&&(Ua=!0)),u=m}sn!==0&&sn!==5||ul(e),Qr!==0&&(Qr=0)}function rg(e,n){for(var s=e.suspendedLanes,u=e.pingedLanes,m=e.expirationTimes,g=e.pendingLanes&-62914561;0<g;){var S=31-Ue(g),z=1<<S,K=m[S];K===-1?((z&s)===0||(z&u)!==0)&&(m[S]=V(z,n)):K<=n&&(e.expiredLanes|=z),g&=~z}if(n=Ut,s=kt,s=Z(e,e===n?s:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),u=e.callbackNode,s===0||e===n&&(Ot===2||Ot===9)||e.cancelPendingCommit!==null)return u!==null&&u!==null&&dt(u),e.callbackNode=null,e.callbackPriority=0;if((s&3)===0||Te(e,s)){if(n=s&-s,n===e.callbackPriority)return n;switch(u!==null&&dt(u),At(s)){case 2:case 8:s=ne;break;case 32:s=Ee;break;case 268435456:s=ze;break;default:s=Ee}return u=ig.bind(null,e),s=at(s,u),e.callbackPriority=n,e.callbackNode=s,n}return u!==null&&u!==null&&dt(u),e.callbackPriority=2,e.callbackNode=null,2}function ig(e,n){if(sn!==0&&sn!==5)return e.callbackNode=null,e.callbackPriority=0,null;var s=e.callbackNode;if(Ba()&&e.callbackNode!==s)return null;var u=kt;return u=Z(e,e===Ut?u:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),u===0?null:(qm(e,u,n),rg(e,Ve()),e.callbackNode!=null&&e.callbackNode===s?ig.bind(null,e):null)}function sg(e,n){if(Ba())return null;qm(e,n,!0)}function J0(){c1(function(){(Mt&6)!==0?at(q,Z0):ng()})}function Ec(){if(Qr===0){var e=Xi;e===0&&(e=ie,ie<<=1,(ie&261888)===0&&(ie=256)),Qr=e}return Qr}function lg(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Ql(""+e)}function ag(e,n){var s=n.ownerDocument.createElement("input");return s.name=n.name,s.value=n.value,e.id&&s.setAttribute("form",e.id),n.parentNode.insertBefore(s,n),e=new FormData(e),s.parentNode.removeChild(s),e}function W0(e,n,s,u,m){if(n==="submit"&&s&&s.stateNode===m){var g=lg((m[et]||null).action),S=u.submitter;S&&(n=(n=S[et]||null)?lg(n.formAction):S.getAttribute("formAction"),n!==null&&(g=n,S=null));var z=new Jl("action","action",null,u,m);e.push({event:z,listeners:[{instance:null,listener:function(){if(u.defaultPrevented){if(Qr!==0){var K=S?ag(m,S):new FormData(m);Gu(s,{pending:!0,data:K,method:m.method,action:g},null,K)}}else typeof g=="function"&&(z.preventDefault(),K=S?ag(m,S):new FormData(m),Gu(s,{pending:!0,data:K,method:m.method,action:g},g,K))},currentTarget:m}]})}}for(var Cc=0;Cc<ou.length;Cc++){var Tc=ou[Cc],e1=Tc.toLowerCase(),t1=Tc[0].toUpperCase()+Tc.slice(1);Yn(e1,"on"+t1)}Yn(Bh,"onAnimationEnd"),Yn(qh,"onAnimationIteration"),Yn(Uh,"onAnimationStart"),Yn("dblclick","onDoubleClick"),Yn("focusin","onFocus"),Yn("focusout","onBlur"),Yn(y0,"onTransitionRun"),Yn(b0,"onTransitionStart"),Yn(v0,"onTransitionCancel"),Yn(Hh,"onTransitionEnd"),Li("onMouseEnter",["mouseout","mouseover"]),Li("onMouseLeave",["mouseout","mouseover"]),Li("onPointerEnter",["pointerout","pointerover"]),Li("onPointerLeave",["pointerout","pointerover"]),si("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),si("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),si("onBeforeInput",["compositionend","keypress","textInput","paste"]),si("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),si("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),si("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var cl="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(" "),n1=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(cl));function og(e,n){n=(n&4)!==0;for(var s=0;s<e.length;s++){var u=e[s],m=u.event;u=u.listeners;e:{var g=void 0;if(n)for(var S=u.length-1;0<=S;S--){var z=u[S],K=z.instance,de=z.currentTarget;if(z=z.listener,K!==g&&m.isPropagationStopped())break e;g=z,m.currentTarget=de;try{g(m)}catch(ve){ta(ve)}m.currentTarget=null,g=K}else for(S=0;S<u.length;S++){if(z=u[S],K=z.instance,de=z.currentTarget,z=z.listener,K!==g&&m.isPropagationStopped())break e;g=z,m.currentTarget=de;try{g(m)}catch(ve){ta(ve)}m.currentTarget=null,g=K}}}}function St(e,n){var s=n[ut];s===void 0&&(s=n[ut]=new Set);var u=e+"__bubble";s.has(u)||(ug(n,e,2,!1),s.add(u))}function Nc(e,n,s){var u=0;n&&(u|=4),ug(s,e,u,n)}var Ha="_reactListening"+Math.random().toString(36).slice(2);function Ac(e){if(!e[Ha]){e[Ha]=!0,nh.forEach(function(s){s!=="selectionchange"&&(n1.has(s)||Nc(s,!1,e),Nc(s,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[Ha]||(n[Ha]=!0,Nc("selectionchange",!1,n))}}function ug(e,n,s,u){switch(Bg(n)){case 2:var m=R1;break;case 8:m=z1;break;default:m=$c}s=m.bind(null,n,s,e),m=void 0,!Ko||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(m=!0),u?m!==void 0?e.addEventListener(n,s,{capture:!0,passive:m}):e.addEventListener(n,s,!0):m!==void 0?e.addEventListener(n,s,{passive:m}):e.addEventListener(n,s,!1)}function Rc(e,n,s,u,m){var g=u;if((n&1)===0&&(n&2)===0&&u!==null)e:for(;;){if(u===null)return;var S=u.tag;if(S===3||S===4){var z=u.stateNode.containerInfo;if(z===m)break;if(S===4)for(S=u.return;S!==null;){var K=S.tag;if((K===3||K===4)&&S.stateNode.containerInfo===m)return;S=S.return}for(;z!==null;){if(S=Mi(z),S===null)return;if(K=S.tag,K===5||K===6||K===26||K===27){u=g=S;continue e}z=z.parentNode}}u=u.return}ph(function(){var de=g,ve=Yo(s),je=[];e:{var pe=Ph.get(e);if(pe!==void 0){var ye=Jl,He=e;switch(e){case"keypress":if(Xl(s)===0)break e;case"keydown":case"keyup":ye=Kx;break;case"focusin":He="focus",ye=Wo;break;case"focusout":He="blur",ye=Wo;break;case"beforeblur":case"afterblur":ye=Wo;break;case"click":if(s.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ye=yh;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ye=Ix;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ye=Jx;break;case Bh:case qh:case Uh:ye=Ux;break;case Hh:ye=e0;break;case"scroll":case"scrollend":ye=Ox;break;case"wheel":ye=n0;break;case"copy":case"cut":case"paste":ye=Px;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ye=vh;break;case"toggle":case"beforetoggle":ye=i0}var tt=(n&4)!==0,qt=!tt&&(e==="scroll"||e==="scrollend"),ae=tt?pe!==null?pe+"Capture":null:pe;tt=[];for(var ee=de,ce;ee!==null;){var Se=ee;if(ce=Se.stateNode,Se=Se.tag,Se!==5&&Se!==26&&Se!==27||ce===null||ae===null||(Se=_s(ee,ae),Se!=null&&tt.push(dl(ee,Se,ce))),qt)break;ee=ee.return}0<tt.length&&(pe=new ye(pe,He,null,s,ve),je.push({event:pe,listeners:tt}))}}if((n&7)===0){e:{if(pe=e==="mouseover"||e==="pointerover",ye=e==="mouseout"||e==="pointerout",pe&&s!==Vo&&(He=s.relatedTarget||s.fromElement)&&(Mi(He)||He[xt]))break e;if((ye||pe)&&(pe=ve.window===ve?ve:(pe=ve.ownerDocument)?pe.defaultView||pe.parentWindow:window,ye?(He=s.relatedTarget||s.toElement,ye=de,He=He?Mi(He):null,He!==null&&(qt=d(He),tt=He.tag,He!==qt||tt!==5&&tt!==27&&tt!==6)&&(He=null)):(ye=null,He=de),ye!==He)){if(tt=yh,Se="onMouseLeave",ae="onMouseEnter",ee="mouse",(e==="pointerout"||e==="pointerover")&&(tt=vh,Se="onPointerLeave",ae="onPointerEnter",ee="pointer"),qt=ye==null?pe:zs(ye),ce=He==null?pe:zs(He),pe=new tt(Se,ee+"leave",ye,s,ve),pe.target=qt,pe.relatedTarget=ce,Se=null,Mi(ve)===de&&(tt=new tt(ae,ee+"enter",He,s,ve),tt.target=ce,tt.relatedTarget=qt,Se=tt),qt=Se,ye&&He)t:{for(tt=r1,ae=ye,ee=He,ce=0,Se=ae;Se;Se=tt(Se))ce++;Se=0;for(var Xe=ee;Xe;Xe=tt(Xe))Se++;for(;0<ce-Se;)ae=tt(ae),ce--;for(;0<Se-ce;)ee=tt(ee),Se--;for(;ce--;){if(ae===ee||ee!==null&&ae===ee.alternate){tt=ae;break t}ae=tt(ae),ee=tt(ee)}tt=null}else tt=null;ye!==null&&cg(je,pe,ye,tt,!1),He!==null&&qt!==null&&cg(je,qt,He,tt,!0)}}e:{if(pe=de?zs(de):window,ye=pe.nodeName&&pe.nodeName.toLowerCase(),ye==="select"||ye==="input"&&pe.type==="file")var zt=Th;else if(Eh(pe))if(Nh)zt=p0;else{zt=f0;var $e=d0}else ye=pe.nodeName,!ye||ye.toLowerCase()!=="input"||pe.type!=="checkbox"&&pe.type!=="radio"?de&&Go(de.elementType)&&(zt=Th):zt=h0;if(zt&&(zt=zt(e,de))){Ch(je,zt,s,ve);break e}$e&&$e(e,pe,de),e==="focusout"&&de&&pe.type==="number"&&de.memoizedProps.value!=null&&$o(pe,"number",pe.value)}switch($e=de?zs(de):window,e){case"focusin":(Eh($e)||$e.contentEditable==="true")&&(Pi=$e,su=de,Us=null);break;case"focusout":Us=su=Pi=null;break;case"mousedown":lu=!0;break;case"contextmenu":case"mouseup":case"dragend":lu=!1,Lh(je,s,ve);break;case"selectionchange":if(g0)break;case"keydown":case"keyup":Lh(je,s,ve)}var gt;if(tu)e:{switch(e){case"compositionstart":var Et="onCompositionStart";break e;case"compositionend":Et="onCompositionEnd";break e;case"compositionupdate":Et="onCompositionUpdate";break e}Et=void 0}else Hi?jh(e,s)&&(Et="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(Et="onCompositionStart");Et&&(xh&&s.locale!=="ko"&&(Hi||Et!=="onCompositionStart"?Et==="onCompositionEnd"&&Hi&&(gt=mh()):(_r=ve,Xo="value"in _r?_r.value:_r.textContent,Hi=!0)),$e=Pa(de,Et),0<$e.length&&(Et=new bh(Et,e,null,s,ve),je.push({event:Et,listeners:$e}),gt?Et.data=gt:(gt=kh(s),gt!==null&&(Et.data=gt)))),(gt=l0?a0(e,s):o0(e,s))&&(Et=Pa(de,"onBeforeInput"),0<Et.length&&($e=new bh("onBeforeInput","beforeinput",null,s,ve),je.push({event:$e,listeners:Et}),$e.data=gt)),W0(je,e,de,s,ve)}og(je,n)})}function dl(e,n,s){return{instance:e,listener:n,currentTarget:s}}function Pa(e,n){for(var s=n+"Capture",u=[];e!==null;){var m=e,g=m.stateNode;if(m=m.tag,m!==5&&m!==26&&m!==27||g===null||(m=_s(e,s),m!=null&&u.unshift(dl(e,m,g)),m=_s(e,n),m!=null&&u.push(dl(e,m,g))),e.tag===3)return u;e=e.return}return[]}function r1(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function cg(e,n,s,u,m){for(var g=n._reactName,S=[];s!==null&&s!==u;){var z=s,K=z.alternate,de=z.stateNode;if(z=z.tag,K!==null&&K===u)break;z!==5&&z!==26&&z!==27||de===null||(K=de,m?(de=_s(s,g),de!=null&&S.unshift(dl(s,de,K))):m||(de=_s(s,g),de!=null&&S.push(dl(s,de,K)))),s=s.return}S.length!==0&&e.push({event:n,listeners:S})}var i1=/\r\n?/g,s1=/\u0000|\uFFFD/g;function dg(e){return(typeof e=="string"?e:""+e).replace(i1,`
|
|
9
|
+
`).replace(s1,"")}function fg(e,n){return n=dg(n),dg(e)===n}function Bt(e,n,s,u,m,g){switch(s){case"children":typeof u=="string"?n==="body"||n==="textarea"&&u===""||Bi(e,u):(typeof u=="number"||typeof u=="bigint")&&n!=="body"&&Bi(e,""+u);break;case"className":Vl(e,"class",u);break;case"tabIndex":Vl(e,"tabindex",u);break;case"dir":case"role":case"viewBox":case"width":case"height":Vl(e,s,u);break;case"style":fh(e,u,g);break;case"data":if(n!=="object"){Vl(e,"data",u);break}case"src":case"href":if(u===""&&(n!=="a"||s!=="href")){e.removeAttribute(s);break}if(u==null||typeof u=="function"||typeof u=="symbol"||typeof u=="boolean"){e.removeAttribute(s);break}u=Ql(""+u),e.setAttribute(s,u);break;case"action":case"formAction":if(typeof u=="function"){e.setAttribute(s,"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"&&(s==="formAction"?(n!=="input"&&Bt(e,n,"name",m.name,m,null),Bt(e,n,"formEncType",m.formEncType,m,null),Bt(e,n,"formMethod",m.formMethod,m,null),Bt(e,n,"formTarget",m.formTarget,m,null)):(Bt(e,n,"encType",m.encType,m,null),Bt(e,n,"method",m.method,m,null),Bt(e,n,"target",m.target,m,null)));if(u==null||typeof u=="symbol"||typeof u=="boolean"){e.removeAttribute(s);break}u=Ql(""+u),e.setAttribute(s,u);break;case"onClick":u!=null&&(e.onclick=cr);break;case"onScroll":u!=null&&St("scroll",e);break;case"onScrollEnd":u!=null&&St("scrollend",e);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(l(61));if(s=u.__html,s!=null){if(m.children!=null)throw Error(l(60));e.innerHTML=s}}break;case"multiple":e.multiple=u&&typeof u!="function"&&typeof u!="symbol";break;case"muted":e.muted=u&&typeof u!="function"&&typeof u!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(u==null||typeof u=="function"||typeof u=="boolean"||typeof u=="symbol"){e.removeAttribute("xlink:href");break}s=Ql(""+u),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",s);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":u!=null&&typeof u!="function"&&typeof u!="symbol"?e.setAttribute(s,""+u):e.removeAttribute(s);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":u&&typeof u!="function"&&typeof u!="symbol"?e.setAttribute(s,""):e.removeAttribute(s);break;case"capture":case"download":u===!0?e.setAttribute(s,""):u!==!1&&u!=null&&typeof u!="function"&&typeof u!="symbol"?e.setAttribute(s,u):e.removeAttribute(s);break;case"cols":case"rows":case"size":case"span":u!=null&&typeof u!="function"&&typeof u!="symbol"&&!isNaN(u)&&1<=u?e.setAttribute(s,u):e.removeAttribute(s);break;case"rowSpan":case"start":u==null||typeof u=="function"||typeof u=="symbol"||isNaN(u)?e.removeAttribute(s):e.setAttribute(s,u);break;case"popover":St("beforetoggle",e),St("toggle",e),Gl(e,"popover",u);break;case"xlinkActuate":ur(e,"http://www.w3.org/1999/xlink","xlink:actuate",u);break;case"xlinkArcrole":ur(e,"http://www.w3.org/1999/xlink","xlink:arcrole",u);break;case"xlinkRole":ur(e,"http://www.w3.org/1999/xlink","xlink:role",u);break;case"xlinkShow":ur(e,"http://www.w3.org/1999/xlink","xlink:show",u);break;case"xlinkTitle":ur(e,"http://www.w3.org/1999/xlink","xlink:title",u);break;case"xlinkType":ur(e,"http://www.w3.org/1999/xlink","xlink:type",u);break;case"xmlBase":ur(e,"http://www.w3.org/XML/1998/namespace","xml:base",u);break;case"xmlLang":ur(e,"http://www.w3.org/XML/1998/namespace","xml:lang",u);break;case"xmlSpace":ur(e,"http://www.w3.org/XML/1998/namespace","xml:space",u);break;case"is":Gl(e,"is",u);break;case"innerText":case"textContent":break;default:(!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(s=Mx.get(s)||s,Gl(e,s,u))}}function zc(e,n,s,u,m,g){switch(s){case"style":fh(e,u,g);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(l(61));if(s=u.__html,s!=null){if(m.children!=null)throw Error(l(60));e.innerHTML=s}}break;case"children":typeof u=="string"?Bi(e,u):(typeof u=="number"||typeof u=="bigint")&&Bi(e,""+u);break;case"onScroll":u!=null&&St("scroll",e);break;case"onScrollEnd":u!=null&&St("scrollend",e);break;case"onClick":u!=null&&(e.onclick=cr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!rh.hasOwnProperty(s))e:{if(s[0]==="o"&&s[1]==="n"&&(m=s.endsWith("Capture"),n=s.slice(2,m?s.length-7:void 0),g=e[et]||null,g=g!=null?g[s]:null,typeof g=="function"&&e.removeEventListener(n,g,m),typeof u=="function")){typeof g!="function"&&g!==null&&(s in e?e[s]=null:e.hasAttribute(s)&&e.removeAttribute(s)),e.addEventListener(n,u,m);break e}s in e?e[s]=u:u===!0?e.setAttribute(s,""):Gl(e,s,u)}}}function hn(e,n,s){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":St("error",e),St("load",e);var u=!1,m=!1,g;for(g in s)if(s.hasOwnProperty(g)){var S=s[g];if(S!=null)switch(g){case"src":u=!0;break;case"srcSet":m=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(l(137,n));default:Bt(e,n,g,S,s,null)}}m&&Bt(e,n,"srcSet",s.srcSet,s,null),u&&Bt(e,n,"src",s.src,s,null);return;case"input":St("invalid",e);var z=g=S=m=null,K=null,de=null;for(u in s)if(s.hasOwnProperty(u)){var ve=s[u];if(ve!=null)switch(u){case"name":m=ve;break;case"type":S=ve;break;case"checked":K=ve;break;case"defaultChecked":de=ve;break;case"value":g=ve;break;case"defaultValue":z=ve;break;case"children":case"dangerouslySetInnerHTML":if(ve!=null)throw Error(l(137,n));break;default:Bt(e,n,u,ve,s,null)}}oh(e,g,z,K,de,S,m,!1);return;case"select":St("invalid",e),u=S=g=null;for(m in s)if(s.hasOwnProperty(m)&&(z=s[m],z!=null))switch(m){case"value":g=z;break;case"defaultValue":S=z;break;case"multiple":u=z;default:Bt(e,n,m,z,s,null)}n=g,s=S,e.multiple=!!u,n!=null?Ii(e,!!u,n,!1):s!=null&&Ii(e,!!u,s,!0);return;case"textarea":St("invalid",e),g=m=u=null;for(S in s)if(s.hasOwnProperty(S)&&(z=s[S],z!=null))switch(S){case"value":u=z;break;case"defaultValue":m=z;break;case"children":g=z;break;case"dangerouslySetInnerHTML":if(z!=null)throw Error(l(91));break;default:Bt(e,n,S,z,s,null)}ch(e,u,m,g);return;case"option":for(K in s)s.hasOwnProperty(K)&&(u=s[K],u!=null)&&(K==="selected"?e.selected=u&&typeof u!="function"&&typeof u!="symbol":Bt(e,n,K,u,s,null));return;case"dialog":St("beforetoggle",e),St("toggle",e),St("cancel",e),St("close",e);break;case"iframe":case"object":St("load",e);break;case"video":case"audio":for(u=0;u<cl.length;u++)St(cl[u],e);break;case"image":St("error",e),St("load",e);break;case"details":St("toggle",e);break;case"embed":case"source":case"link":St("error",e),St("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(de in s)if(s.hasOwnProperty(de)&&(u=s[de],u!=null))switch(de){case"children":case"dangerouslySetInnerHTML":throw Error(l(137,n));default:Bt(e,n,de,u,s,null)}return;default:if(Go(n)){for(ve in s)s.hasOwnProperty(ve)&&(u=s[ve],u!==void 0&&zc(e,n,ve,u,s,void 0));return}}for(z in s)s.hasOwnProperty(z)&&(u=s[z],u!=null&&Bt(e,n,z,u,s,null))}function l1(e,n,s,u){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var m=null,g=null,S=null,z=null,K=null,de=null,ve=null;for(ye in s){var je=s[ye];if(s.hasOwnProperty(ye)&&je!=null)switch(ye){case"checked":break;case"value":break;case"defaultValue":K=je;default:u.hasOwnProperty(ye)||Bt(e,n,ye,null,u,je)}}for(var pe in u){var ye=u[pe];if(je=s[pe],u.hasOwnProperty(pe)&&(ye!=null||je!=null))switch(pe){case"type":g=ye;break;case"name":m=ye;break;case"checked":de=ye;break;case"defaultChecked":ve=ye;break;case"value":S=ye;break;case"defaultValue":z=ye;break;case"children":case"dangerouslySetInnerHTML":if(ye!=null)throw Error(l(137,n));break;default:ye!==je&&Bt(e,n,pe,ye,u,je)}}Fo(e,S,z,K,de,ve,g,m);return;case"select":ye=S=z=pe=null;for(g in s)if(K=s[g],s.hasOwnProperty(g)&&K!=null)switch(g){case"value":break;case"multiple":ye=K;default:u.hasOwnProperty(g)||Bt(e,n,g,null,u,K)}for(m in u)if(g=u[m],K=s[m],u.hasOwnProperty(m)&&(g!=null||K!=null))switch(m){case"value":pe=g;break;case"defaultValue":z=g;break;case"multiple":S=g;default:g!==K&&Bt(e,n,m,g,u,K)}n=z,s=S,u=ye,pe!=null?Ii(e,!!s,pe,!1):!!u!=!!s&&(n!=null?Ii(e,!!s,n,!0):Ii(e,!!s,s?[]:"",!1));return;case"textarea":ye=pe=null;for(z in s)if(m=s[z],s.hasOwnProperty(z)&&m!=null&&!u.hasOwnProperty(z))switch(z){case"value":break;case"children":break;default:Bt(e,n,z,null,u,m)}for(S in u)if(m=u[S],g=s[S],u.hasOwnProperty(S)&&(m!=null||g!=null))switch(S){case"value":pe=m;break;case"defaultValue":ye=m;break;case"children":break;case"dangerouslySetInnerHTML":if(m!=null)throw Error(l(91));break;default:m!==g&&Bt(e,n,S,m,u,g)}uh(e,pe,ye);return;case"option":for(var He in s)pe=s[He],s.hasOwnProperty(He)&&pe!=null&&!u.hasOwnProperty(He)&&(He==="selected"?e.selected=!1:Bt(e,n,He,null,u,pe));for(K in u)pe=u[K],ye=s[K],u.hasOwnProperty(K)&&pe!==ye&&(pe!=null||ye!=null)&&(K==="selected"?e.selected=pe&&typeof pe!="function"&&typeof pe!="symbol":Bt(e,n,K,pe,u,ye));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 tt in s)pe=s[tt],s.hasOwnProperty(tt)&&pe!=null&&!u.hasOwnProperty(tt)&&Bt(e,n,tt,null,u,pe);for(de in u)if(pe=u[de],ye=s[de],u.hasOwnProperty(de)&&pe!==ye&&(pe!=null||ye!=null))switch(de){case"children":case"dangerouslySetInnerHTML":if(pe!=null)throw Error(l(137,n));break;default:Bt(e,n,de,pe,u,ye)}return;default:if(Go(n)){for(var qt in s)pe=s[qt],s.hasOwnProperty(qt)&&pe!==void 0&&!u.hasOwnProperty(qt)&&zc(e,n,qt,void 0,u,pe);for(ve in u)pe=u[ve],ye=s[ve],!u.hasOwnProperty(ve)||pe===ye||pe===void 0&&ye===void 0||zc(e,n,ve,pe,u,ye);return}}for(var ae in s)pe=s[ae],s.hasOwnProperty(ae)&&pe!=null&&!u.hasOwnProperty(ae)&&Bt(e,n,ae,null,u,pe);for(je in u)pe=u[je],ye=s[je],!u.hasOwnProperty(je)||pe===ye||pe==null&&ye==null||Bt(e,n,je,pe,u,ye)}function hg(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function a1(){if(typeof performance.getEntriesByType=="function"){for(var e=0,n=0,s=performance.getEntriesByType("resource"),u=0;u<s.length;u++){var m=s[u],g=m.transferSize,S=m.initiatorType,z=m.duration;if(g&&z&&hg(S)){for(S=0,z=m.responseEnd,u+=1;u<s.length;u++){var K=s[u],de=K.startTime;if(de>z)break;var ve=K.transferSize,je=K.initiatorType;ve&&hg(je)&&(K=K.responseEnd,S+=ve*(K<z?1:(z-de)/(K-de)))}if(--u,n+=8*(g+S)/(m.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 _c=null,Mc=null;function Fa(e){return e.nodeType===9?e:e.ownerDocument}function pg(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 mg(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 Dc(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 Oc=null;function o1(){var e=window.event;return e&&e.type==="popstate"?e===Oc?!1:(Oc=e,!0):(Oc=null,!1)}var gg=typeof setTimeout=="function"?setTimeout:void 0,u1=typeof clearTimeout=="function"?clearTimeout:void 0,yg=typeof Promise=="function"?Promise:void 0,c1=typeof queueMicrotask=="function"?queueMicrotask:typeof yg<"u"?function(e){return yg.resolve(null).then(e).catch(d1)}:gg;function d1(e){setTimeout(function(){throw e})}function Kr(e){return e==="head"}function bg(e,n){var s=n,u=0;do{var m=s.nextSibling;if(e.removeChild(s),m&&m.nodeType===8)if(s=m.data,s==="/$"||s==="/&"){if(u===0){e.removeChild(m),ms(n);return}u--}else if(s==="$"||s==="$?"||s==="$~"||s==="$!"||s==="&")u++;else if(s==="html")fl(e.ownerDocument.documentElement);else if(s==="head"){s=e.ownerDocument.head,fl(s);for(var g=s.firstChild;g;){var S=g.nextSibling,z=g.nodeName;g[zr]||z==="SCRIPT"||z==="STYLE"||z==="LINK"&&g.rel.toLowerCase()==="stylesheet"||s.removeChild(g),g=S}}else s==="body"&&fl(e.ownerDocument.body);s=m}while(s);ms(n)}function vg(e,n){var s=e;e=0;do{var u=s.nextSibling;if(s.nodeType===1?n?(s._stashedDisplay=s.style.display,s.style.display="none"):(s.style.display=s._stashedDisplay||"",s.getAttribute("style")===""&&s.removeAttribute("style")):s.nodeType===3&&(n?(s._stashedText=s.nodeValue,s.nodeValue=""):s.nodeValue=s._stashedText||""),u&&u.nodeType===8)if(s=u.data,s==="/$"){if(e===0)break;e--}else s!=="$"&&s!=="$?"&&s!=="$~"&&s!=="$!"||e++;s=u}while(s)}function Lc(e){var n=e.firstChild;for(n&&n.nodeType===10&&(n=n.nextSibling);n;){var s=n;switch(n=n.nextSibling,s.nodeName){case"HTML":case"HEAD":case"BODY":Lc(s),Ho(s);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(s.rel.toLowerCase()==="stylesheet")continue}e.removeChild(s)}}function f1(e,n,s,u){for(;e.nodeType===1;){var m=s;if(e.nodeName.toLowerCase()!==n.toLowerCase()){if(!u&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(u){if(!e[zr])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!==m.rel||e.getAttribute("href")!==(m.href==null||m.href===""?null:m.href)||e.getAttribute("crossorigin")!==(m.crossOrigin==null?null:m.crossOrigin)||e.getAttribute("title")!==(m.title==null?null:m.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(g=e.getAttribute("src"),(g!==(m.src==null?null:m.src)||e.getAttribute("type")!==(m.type==null?null:m.type)||e.getAttribute("crossorigin")!==(m.crossOrigin==null?null:m.crossOrigin))&&g&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(n==="input"&&e.type==="hidden"){var g=m.name==null?null:""+m.name;if(m.type==="hidden"&&e.getAttribute("name")===g)return e}else return e;if(e=$n(e.nextSibling),e===null)break}return null}function h1(e,n,s){if(n==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!s||(e=$n(e.nextSibling),e===null))return null;return e}function xg(e,n){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=$n(e.nextSibling),e===null))return null;return e}function Ic(e){return e.data==="$?"||e.data==="$~"}function Bc(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function p1(e,n){var s=e.ownerDocument;if(e.data==="$~")e._reactRetry=n;else if(e.data!=="$?"||s.readyState!=="loading")n();else{var u=function(){n(),s.removeEventListener("DOMContentLoaded",u)};s.addEventListener("DOMContentLoaded",u),e._reactRetry=u}}function $n(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 qc=null;function wg(e){e=e.nextSibling;for(var n=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"||s==="/&"){if(n===0)return $n(e.nextSibling);n--}else s!=="$"&&s!=="$!"&&s!=="$?"&&s!=="$~"&&s!=="&"||n++}e=e.nextSibling}return null}function Sg(e){e=e.previousSibling;for(var n=0;e;){if(e.nodeType===8){var s=e.data;if(s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"){if(n===0)return e;n--}else s!=="/$"&&s!=="/&"||n++}e=e.previousSibling}return null}function jg(e,n,s){switch(n=Fa(s),e){case"html":if(e=n.documentElement,!e)throw Error(l(452));return e;case"head":if(e=n.head,!e)throw Error(l(453));return e;case"body":if(e=n.body,!e)throw Error(l(454));return e;default:throw Error(l(451))}}function fl(e){for(var n=e.attributes;n.length;)e.removeAttributeNode(n[0]);Ho(e)}var Gn=new Map,kg=new Set;function $a(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Cr=G.d;G.d={f:m1,r:g1,D:y1,C:b1,L:v1,m:x1,X:S1,S:w1,M:j1};function m1(){var e=Cr.f(),n=Oa();return e||n}function g1(e){var n=Di(e);n!==null&&n.tag===5&&n.type==="form"?Hp(n):Cr.r(e)}var fs=typeof document>"u"?null:document;function Eg(e,n,s){var u=fs;if(u&&typeof n=="string"&&n){var m=In(n);m='link[rel="'+e+'"][href="'+m+'"]',typeof s=="string"&&(m+='[crossorigin="'+s+'"]'),kg.has(m)||(kg.add(m),e={rel:e,crossOrigin:s,href:n},u.querySelector(m)===null&&(n=u.createElement("link"),hn(n,"link",e),ln(n),u.head.appendChild(n)))}}function y1(e){Cr.D(e),Eg("dns-prefetch",e,null)}function b1(e,n){Cr.C(e,n),Eg("preconnect",e,n)}function v1(e,n,s){Cr.L(e,n,s);var u=fs;if(u&&e&&n){var m='link[rel="preload"][as="'+In(n)+'"]';n==="image"&&s&&s.imageSrcSet?(m+='[imagesrcset="'+In(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(m+='[imagesizes="'+In(s.imageSizes)+'"]')):m+='[href="'+In(e)+'"]';var g=m;switch(n){case"style":g=hs(e);break;case"script":g=ps(e)}Gn.has(g)||(e=b({rel:"preload",href:n==="image"&&s&&s.imageSrcSet?void 0:e,as:n},s),Gn.set(g,e),u.querySelector(m)!==null||n==="style"&&u.querySelector(hl(g))||n==="script"&&u.querySelector(pl(g))||(n=u.createElement("link"),hn(n,"link",e),ln(n),u.head.appendChild(n)))}}function x1(e,n){Cr.m(e,n);var s=fs;if(s&&e){var u=n&&typeof n.as=="string"?n.as:"script",m='link[rel="modulepreload"][as="'+In(u)+'"][href="'+In(e)+'"]',g=m;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=ps(e)}if(!Gn.has(g)&&(e=b({rel:"modulepreload",href:e},n),Gn.set(g,e),s.querySelector(m)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector(pl(g)))return}u=s.createElement("link"),hn(u,"link",e),ln(u),s.head.appendChild(u)}}}function w1(e,n,s){Cr.S(e,n,s);var u=fs;if(u&&e){var m=Oi(u).hoistableStyles,g=hs(e);n=n||"default";var S=m.get(g);if(!S){var z={loading:0,preload:null};if(S=u.querySelector(hl(g)))z.loading=5;else{e=b({rel:"stylesheet",href:e,"data-precedence":n},s),(s=Gn.get(g))&&Uc(e,s);var K=S=u.createElement("link");ln(K),hn(K,"link",e),K._p=new Promise(function(de,ve){K.onload=de,K.onerror=ve}),K.addEventListener("load",function(){z.loading|=1}),K.addEventListener("error",function(){z.loading|=2}),z.loading|=4,Ga(S,n,u)}S={type:"stylesheet",instance:S,count:1,state:z},m.set(g,S)}}}function S1(e,n){Cr.X(e,n);var s=fs;if(s&&e){var u=Oi(s).hoistableScripts,m=ps(e),g=u.get(m);g||(g=s.querySelector(pl(m)),g||(e=b({src:e,async:!0},n),(n=Gn.get(m))&&Hc(e,n),g=s.createElement("script"),ln(g),hn(g,"link",e),s.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},u.set(m,g))}}function j1(e,n){Cr.M(e,n);var s=fs;if(s&&e){var u=Oi(s).hoistableScripts,m=ps(e),g=u.get(m);g||(g=s.querySelector(pl(m)),g||(e=b({src:e,async:!0,type:"module"},n),(n=Gn.get(m))&&Hc(e,n),g=s.createElement("script"),ln(g),hn(g,"link",e),s.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},u.set(m,g))}}function Cg(e,n,s,u){var m=(m=me.current)?$a(m):null;if(!m)throw Error(l(446));switch(e){case"meta":case"title":return null;case"style":return typeof s.precedence=="string"&&typeof s.href=="string"?(n=hs(s.href),s=Oi(m).hoistableStyles,u=s.get(n),u||(u={type:"style",instance:null,count:0,state:null},s.set(n,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(s.rel==="stylesheet"&&typeof s.href=="string"&&typeof s.precedence=="string"){e=hs(s.href);var g=Oi(m).hoistableStyles,S=g.get(e);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(e,S),(g=m.querySelector(hl(e)))&&!g._p&&(S.instance=g,S.state.loading=5),Gn.has(e)||(s={rel:"preload",as:"style",href:s.href,crossOrigin:s.crossOrigin,integrity:s.integrity,media:s.media,hrefLang:s.hrefLang,referrerPolicy:s.referrerPolicy},Gn.set(e,s),g||k1(m,e,s,S.state))),n&&u===null)throw Error(l(528,""));return S}if(n&&u!==null)throw Error(l(529,""));return null;case"script":return n=s.async,s=s.src,typeof s=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=ps(s),s=Oi(m).hoistableScripts,u=s.get(n),u||(u={type:"script",instance:null,count:0,state:null},s.set(n,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(l(444,e))}}function hs(e){return'href="'+In(e)+'"'}function hl(e){return'link[rel="stylesheet"]['+e+"]"}function Tg(e){return b({},e,{"data-precedence":e.precedence,precedence:null})}function k1(e,n,s,u){e.querySelector('link[rel="preload"][as="style"]['+n+"]")?u.loading=1:(n=e.createElement("link"),u.preload=n,n.addEventListener("load",function(){return u.loading|=1}),n.addEventListener("error",function(){return u.loading|=2}),hn(n,"link",s),ln(n),e.head.appendChild(n))}function ps(e){return'[src="'+In(e)+'"]'}function pl(e){return"script[async]"+e}function Ng(e,n,s){if(n.count++,n.instance===null)switch(n.type){case"style":var u=e.querySelector('style[data-href~="'+In(s.href)+'"]');if(u)return n.instance=u,ln(u),u;var m=b({},s,{"data-href":s.href,"data-precedence":s.precedence,href:null,precedence:null});return u=(e.ownerDocument||e).createElement("style"),ln(u),hn(u,"style",m),Ga(u,s.precedence,e),n.instance=u;case"stylesheet":m=hs(s.href);var g=e.querySelector(hl(m));if(g)return n.state.loading|=4,n.instance=g,ln(g),g;u=Tg(s),(m=Gn.get(m))&&Uc(u,m),g=(e.ownerDocument||e).createElement("link"),ln(g);var S=g;return S._p=new Promise(function(z,K){S.onload=z,S.onerror=K}),hn(g,"link",u),n.state.loading|=4,Ga(g,s.precedence,e),n.instance=g;case"script":return g=ps(s.src),(m=e.querySelector(pl(g)))?(n.instance=m,ln(m),m):(u=s,(m=Gn.get(g))&&(u=b({},s),Hc(u,m)),e=e.ownerDocument||e,m=e.createElement("script"),ln(m),hn(m,"link",u),e.head.appendChild(m),n.instance=m);case"void":return null;default:throw Error(l(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(u=n.instance,n.state.loading|=4,Ga(u,s.precedence,e));return n.instance}function Ga(e,n,s){for(var u=s.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=u.length?u[u.length-1]:null,g=m,S=0;S<u.length;S++){var z=u[S];if(z.dataset.precedence===n)g=z;else if(g!==m)break}g?g.parentNode.insertBefore(e,g.nextSibling):(n=s.nodeType===9?s.head:s,n.insertBefore(e,n.firstChild))}function Uc(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.title==null&&(e.title=n.title)}function Hc(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.integrity==null&&(e.integrity=n.integrity)}var Va=null;function Ag(e,n,s){if(Va===null){var u=new Map,m=Va=new Map;m.set(s,u)}else m=Va,u=m.get(s),u||(u=new Map,m.set(s,u));if(u.has(e))return u;for(u.set(e,null),s=s.getElementsByTagName(e),m=0;m<s.length;m++){var g=s[m];if(!(g[zr]||g[yt]||e==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var S=g.getAttribute(n)||"";S=e+S;var z=u.get(S);z?z.push(g):u.set(S,[g])}}return u}function Rg(e,n,s){e=e.ownerDocument||e,e.head.insertBefore(s,n==="title"?e.querySelector("head > title"):null)}function E1(e,n,s){if(s===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 zg(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function C1(e,n,s,u){if(s.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(s.state.loading&4)===0){if(s.instance===null){var m=hs(u.href),g=n.querySelector(hl(m));if(g){n=g._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(e.count++,e=Ya.bind(e),n.then(e,e)),s.state.loading|=4,s.instance=g,ln(g);return}g=n.ownerDocument||n,u=Tg(u),(m=Gn.get(m))&&Uc(u,m),g=g.createElement("link"),ln(g);var S=g;S._p=new Promise(function(z,K){S.onload=z,S.onerror=K}),hn(g,"link",u),s.instance=g}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(s,n),(n=s.state.preload)&&(s.state.loading&3)===0&&(e.count++,s=Ya.bind(e),n.addEventListener("load",s),n.addEventListener("error",s))}}var Pc=0;function T1(e,n){return e.stylesheets&&e.count===0&&Ka(e,e.stylesheets),0<e.count||0<e.imgCount?function(s){var u=setTimeout(function(){if(e.stylesheets&&Ka(e,e.stylesheets),e.unsuspend){var g=e.unsuspend;e.unsuspend=null,g()}},6e4+n);0<e.imgBytes&&Pc===0&&(Pc=62500*a1());var m=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Ka(e,e.stylesheets),e.unsuspend)){var g=e.unsuspend;e.unsuspend=null,g()}},(e.imgBytes>Pc?50:800)+n);return e.unsuspend=s,function(){e.unsuspend=null,clearTimeout(u),clearTimeout(m)}}:null}function Ya(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ka(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Qa=null;function Ka(e,n){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Qa=new Map,n.forEach(N1,e),Qa=null,Ya.call(e))}function N1(e,n){if(!(n.state.loading&4)){var s=Qa.get(e);if(s)var u=s.get(null);else{s=new Map,Qa.set(e,s);for(var m=e.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g<m.length;g++){var S=m[g];(S.nodeName==="LINK"||S.getAttribute("media")!=="not all")&&(s.set(S.dataset.precedence,S),u=S)}u&&s.set(null,u)}m=n.instance,S=m.getAttribute("data-precedence"),g=s.get(S)||u,g===u&&s.set(null,m),s.set(S,m),this.count++,u=Ya.bind(this),m.addEventListener("load",u),m.addEventListener("error",u),g?g.parentNode.insertBefore(m,g.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(m,e.firstChild)),n.state.loading|=4}}var ml={$$typeof:D,Provider:null,Consumer:null,_currentValue:re,_currentValue2:re,_threadCount:0};function A1(e,n,s,u,m,g,S,z,K){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=Ye(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ye(0),this.hiddenUpdates=Ye(null),this.identifierPrefix=u,this.onUncaughtError=m,this.onCaughtError=g,this.onRecoverableError=S,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=K,this.incompleteTransitions=new Map}function _g(e,n,s,u,m,g,S,z,K,de,ve,je){return e=new A1(e,n,s,S,K,de,ve,je,z),n=1,g===!0&&(n|=24),g=Nn(3,null,null,n),e.current=g,g.stateNode=e,n=wu(),n.refCount++,e.pooledCache=n,n.refCount++,g.memoizedState={element:u,isDehydrated:s,cache:n},Eu(g),e}function Mg(e){return e?(e=Gi,e):Gi}function Dg(e,n,s,u,m,g){m=Mg(m),u.context===null?u.context=m:u.pendingContext=m,u=Br(n),u.payload={element:s},g=g===void 0?null:g,g!==null&&(u.callback=g),s=qr(e,u,n),s!==null&&(kn(s,e,n),Ys(s,e,n))}function Og(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<n?s:n}}function Fc(e,n){Og(e,n),(e=e.alternate)&&Og(e,n)}function Lg(e){if(e.tag===13||e.tag===31){var n=ui(e,67108864);n!==null&&kn(n,e,67108864),Fc(e,67108864)}}function Ig(e){if(e.tag===13||e.tag===31){var n=Mn();n=Fe(n);var s=ui(e,n);s!==null&&kn(s,e,n),Fc(e,n)}}var Xa=!0;function R1(e,n,s,u){var m=P.T;P.T=null;var g=G.p;try{G.p=2,$c(e,n,s,u)}finally{G.p=g,P.T=m}}function z1(e,n,s,u){var m=P.T;P.T=null;var g=G.p;try{G.p=8,$c(e,n,s,u)}finally{G.p=g,P.T=m}}function $c(e,n,s,u){if(Xa){var m=Gc(u);if(m===null)Rc(e,n,u,Za,s),qg(e,u);else if(M1(m,e,n,s,u))u.stopPropagation();else if(qg(e,u),n&4&&-1<_1.indexOf(e)){for(;m!==null;){var g=Di(m);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var S=we(g.pendingLanes);if(S!==0){var z=g;for(z.pendingLanes|=2,z.entangledLanes|=2;S;){var K=1<<31-Ue(S);z.entanglements[1]|=K,S&=~K}nr(g),(Mt&6)===0&&(Ma=Ve()+500,ul(0))}}break;case 31:case 13:z=ui(g,2),z!==null&&kn(z,g,2),Oa(),Fc(g,2)}if(g=Gc(u),g===null&&Rc(e,n,u,Za,s),g===m)break;m=g}m!==null&&u.stopPropagation()}else Rc(e,n,u,null,s)}}function Gc(e){return e=Yo(e),Vc(e)}var Za=null;function Vc(e){if(Za=null,e=Mi(e),e!==null){var n=d(e);if(n===null)e=null;else{var s=n.tag;if(s===13){if(e=c(n),e!==null)return e;e=null}else if(s===31){if(e=h(n),e!==null)return e;e=null}else if(s===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;e=null}else n!==e&&(e=null)}}return Za=e,null}function Bg(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(nt()){case q:return 2;case ne:return 8;case Ee:case xe:return 32;case ze:return 268435456;default:return 32}default:return 32}}var Yc=!1,Xr=null,Zr=null,Jr=null,gl=new Map,yl=new Map,Wr=[],_1="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 qg(e,n){switch(e){case"focusin":case"focusout":Xr=null;break;case"dragenter":case"dragleave":Zr=null;break;case"mouseover":case"mouseout":Jr=null;break;case"pointerover":case"pointerout":gl.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":yl.delete(n.pointerId)}}function bl(e,n,s,u,m,g){return e===null||e.nativeEvent!==g?(e={blockedOn:n,domEventName:s,eventSystemFlags:u,nativeEvent:g,targetContainers:[m]},n!==null&&(n=Di(n),n!==null&&Lg(n)),e):(e.eventSystemFlags|=u,n=e.targetContainers,m!==null&&n.indexOf(m)===-1&&n.push(m),e)}function M1(e,n,s,u,m){switch(n){case"focusin":return Xr=bl(Xr,e,n,s,u,m),!0;case"dragenter":return Zr=bl(Zr,e,n,s,u,m),!0;case"mouseover":return Jr=bl(Jr,e,n,s,u,m),!0;case"pointerover":var g=m.pointerId;return gl.set(g,bl(gl.get(g)||null,e,n,s,u,m)),!0;case"gotpointercapture":return g=m.pointerId,yl.set(g,bl(yl.get(g)||null,e,n,s,u,m)),!0}return!1}function Ug(e){var n=Mi(e.target);if(n!==null){var s=d(n);if(s!==null){if(n=s.tag,n===13){if(n=c(s),n!==null){e.blockedOn=n,Rt(e.priority,function(){Ig(s)});return}}else if(n===31){if(n=h(s),n!==null){e.blockedOn=n,Rt(e.priority,function(){Ig(s)});return}}else if(n===3&&s.stateNode.current.memoizedState.isDehydrated){e.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ja(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var s=Gc(e.nativeEvent);if(s===null){s=e.nativeEvent;var u=new s.constructor(s.type,s);Vo=u,s.target.dispatchEvent(u),Vo=null}else return n=Di(s),n!==null&&Lg(n),e.blockedOn=s,!1;n.shift()}return!0}function Hg(e,n,s){Ja(e)&&s.delete(n)}function D1(){Yc=!1,Xr!==null&&Ja(Xr)&&(Xr=null),Zr!==null&&Ja(Zr)&&(Zr=null),Jr!==null&&Ja(Jr)&&(Jr=null),gl.forEach(Hg),yl.forEach(Hg)}function Wa(e,n){e.blockedOn===n&&(e.blockedOn=null,Yc||(Yc=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,D1)))}var eo=null;function Pg(e){eo!==e&&(eo=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){eo===e&&(eo=null);for(var n=0;n<e.length;n+=3){var s=e[n],u=e[n+1],m=e[n+2];if(typeof u!="function"){if(Vc(u||s)===null)continue;break}var g=Di(s);g!==null&&(e.splice(n,3),n-=3,Gu(g,{pending:!0,data:m,method:s.method,action:u},u,m))}}))}function ms(e){function n(K){return Wa(K,e)}Xr!==null&&Wa(Xr,e),Zr!==null&&Wa(Zr,e),Jr!==null&&Wa(Jr,e),gl.forEach(n),yl.forEach(n);for(var s=0;s<Wr.length;s++){var u=Wr[s];u.blockedOn===e&&(u.blockedOn=null)}for(;0<Wr.length&&(s=Wr[0],s.blockedOn===null);)Ug(s),s.blockedOn===null&&Wr.shift();if(s=(e.ownerDocument||e).$$reactFormReplay,s!=null)for(u=0;u<s.length;u+=3){var m=s[u],g=s[u+1],S=m[et]||null;if(typeof g=="function")S||Pg(s);else if(S){var z=null;if(g&&g.hasAttribute("formAction")){if(m=g,S=g[et]||null)z=S.formAction;else if(Vc(m)!==null)continue}else z=S.action;typeof z=="function"?s[u+1]=z:(s.splice(u,3),u-=3),Pg(s)}}}function Fg(){function e(g){g.canIntercept&&g.info==="react-transition"&&g.intercept({handler:function(){return new Promise(function(S){return m=S})},focusReset:"manual",scroll:"manual"})}function n(){m!==null&&(m(),m=null),u||setTimeout(s,20)}function s(){if(!u&&!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 u=!1,m=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",n),navigation.addEventListener("navigateerror",n),setTimeout(s,100),function(){u=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",n),navigation.removeEventListener("navigateerror",n),m!==null&&(m(),m=null)}}}function Qc(e){this._internalRoot=e}to.prototype.render=Qc.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(l(409));var s=n.current,u=Mn();Dg(s,u,e,n,null,null)},to.prototype.unmount=Qc.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;Dg(e.current,2,null,e,null,null),Oa(),n[xt]=null}};function to(e){this._internalRoot=e}to.prototype.unstable_scheduleHydration=function(e){if(e){var n=Xt();e={blockedOn:null,target:e,priority:n};for(var s=0;s<Wr.length&&n!==0&&n<Wr[s].priority;s++);Wr.splice(s,0,e),s===0&&Ug(e)}};var $g=r.version;if($g!=="19.2.6")throw Error(l(527,$g,"19.2.6"));G.findDOMNode=function(e){var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(l(188)):(e=Object.keys(e).join(","),Error(l(268,e)));return e=p(n),e=e!==null?y(e):null,e=e===null?null:e.stateNode,e};var O1={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:P,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var no=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!no.isDisabled&&no.supportsFiber)try{Re=no.inject(O1),Ne=no}catch{}}return xl.createRoot=function(e,n){if(!o(e))throw Error(l(299));var s=!1,u="",m=Zp,g=Jp,S=Wp;return n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(u=n.identifierPrefix),n.onUncaughtError!==void 0&&(m=n.onUncaughtError),n.onCaughtError!==void 0&&(g=n.onCaughtError),n.onRecoverableError!==void 0&&(S=n.onRecoverableError)),n=_g(e,1,!1,null,null,s,u,null,m,g,S,Fg),e[xt]=n.current,Ac(e),new Qc(n)},xl.hydrateRoot=function(e,n,s){if(!o(e))throw Error(l(299));var u=!1,m="",g=Zp,S=Jp,z=Wp,K=null;return s!=null&&(s.unstable_strictMode===!0&&(u=!0),s.identifierPrefix!==void 0&&(m=s.identifierPrefix),s.onUncaughtError!==void 0&&(g=s.onUncaughtError),s.onCaughtError!==void 0&&(S=s.onCaughtError),s.onRecoverableError!==void 0&&(z=s.onRecoverableError),s.formState!==void 0&&(K=s.formState)),n=_g(e,1,!0,n,s??null,u,m,K,g,S,z,Fg),n.context=Mg(null),s=n.current,u=Mn(),u=Fe(u),m=Br(u),m.callback=null,qr(s,m,u),s=u,n.current.lanes=s,Ct(n,s),nr(n),e[xt]=n.current,Ac(e),new to(n)},xl.version="19.2.6",xl}var ty;function ow(){if(ty)return Jc.exports;ty=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(r){console.error(r)}}return t(),Jc.exports=aw(),Jc.exports}var uw=ow();const cw=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;function Xb(t){if(!t||typeof t!="object")return!1;const r=t;return r.version===1&&typeof r.id=="string"&&cw.test(r.id)&&typeof r.name=="string"&&r.name.trim().length>0&&r.name.length<=128&&!/[\u0000-\u001f\u007f]/.test(r.name)&&["desktop","hub","project-host"].includes(r.kind)&&r.entryPath===(r.kind==="desktop"?"/mobile":"/")}const Nf="codeshell.environments.v1",Zb=32;function Af(t){if(t.length>2048||/[\\\u0000-\u0020\u007f]/.test(t))throw new Error("请输入完整的工作台地址。");const r=new URL(t);if(!["https:","http:"].includes(r.protocol)||r.username||r.password||r.search||r.hash)throw new Error("请使用不含密码、配对令牌或查询参数的工作台地址。");if(!["/","/mobile","/mobile/"].includes(r.pathname))throw new Error("请填写工作台首页或桌面 /mobile 地址。");return r.origin+(r.pathname.startsWith("/mobile")?"/mobile":"/")}function Jb(t){if(!t||typeof t!="object")throw new Error("无效的连接记录。");const r=t;if(typeof r.address!="string"||typeof r.name!="string"||!r.name.trim()||r.name.length>80||/[\u0000-\u001f\u007f]/.test(r.name))throw new Error("连接名称需为 1–80 个字符。");if(r.environmentId!==void 0&&!Xb({version:1,id:r.environmentId,name:"Host",kind:"hub",entryPath:"/"}))throw new Error("无效的环境身份。");return{address:Af(r.address),name:r.name.trim(),...r.environmentId?{environmentId:r.environmentId}:{}}}function ko(t){const r=t.getItem(Nf);if(r===null)return[];if(r.length>1e5)throw new Error("连接记录过大,请清理当前工作台的连接记录。");const i=JSON.parse(r);if(!Array.isArray(i)||i.length>Zb)throw new Error("连接记录格式无效。");return i.map(Jb)}function ny(t,r){const i=Jb(r),l=ko(t),o=l.find(c=>c.address===i.address);if(o?.environmentId&&i.environmentId&&o.environmentId!==i.environmentId)throw new Error("这个地址的环境身份已变化。请确认目标后,删除旧连接再添加。");const d=[...l.filter(c=>c.address!==i.address),{...i,...o?.environmentId?{environmentId:o.environmentId}:{}}];if(d.length>Zb)throw new Error("最多保存 32 个环境,请先移除不再使用的连接。");return t.setItem(Nf,JSON.stringify(d)),d}function dw(t,r){const i=ko(t).filter(l=>l.address!==Af(r));return t.setItem(Nf,JSON.stringify(i)),i}function fw(t,r,i){const l=t.find(o=>o.address===r+i.entryPath);if(l?.environmentId&&l.environmentId!==i.id)throw new Error("当前地址对应的环境已变化,请核对项目后重新保存连接。")}const Wb=x.createContext("/api/v1/environment");function Rf({discover:t=!0,navigate:r}){const i=x.useContext(Wb),[l,o]=x.useState(!1),[d,c]=x.useState(),[h,f]=x.useState([]),[p,y]=x.useState(""),[b,v]=x.useState(""),[w,j]=x.useState(""),N=x.useRef(null),C=x.useRef(null),E=x.useRef(null);x.useEffect(()=>{try{f(ko(window.localStorage))}catch{j("无法读取连接记录。当前项目仍可使用。")}},[]),x.useEffect(()=>{if(!t)return;const L=new AbortController;return Je(i,{signal:L.signal}).then(J=>{if(!L.signal.aborted){if(!Xb(J))throw new Error("环境信息无效,请更新工作台后重试。");c(J),fw(ko(window.localStorage),window.location.origin,J)}}).catch(J=>{L.signal.aborted||J instanceof it&&[401,404].includes(J.status)||j(J instanceof Error?J.message:"无法读取环境信息。")}),()=>L.abort()},[t,i]),x.useEffect(()=>{if(l)return C.current?.showModal(),E.current?.focus(),()=>N.current?.focus()},[l]);const A=L=>{try{f(L()),j("")}catch(J){j(J instanceof Error?J.message:"保存连接失败。")}},D=L=>{const J=Af(L);o(!1),r?r(J):window.location.assign(J)};return a.jsxs("div",{className:"environment-switcher",children:[a.jsxs("button",{ref:N,type:"button",className:"ghost environment-trigger",onClick:()=>o(!0),children:[d?.name??"连接环境",a.jsx("span",{"aria-hidden":"true",children:" ▾"})]}),l?a.jsxs("dialog",{ref:C,className:"environment-dialog","aria-labelledby":"environment-title",onCancel:()=>o(!1),onClose:()=>o(!1),children:[a.jsxs("header",{children:[a.jsx("h2",{id:"environment-title",children:"电脑与云端"}),a.jsx("button",{ref:E,type:"button",className:"ghost",onClick:()=>o(!1),children:"关闭"})]}),a.jsx("p",{children:"打开目标环境后选择项目。切换入口不会移动文件或正在运行的任务。"}),a.jsxs("p",{className:"environment-location",children:["当前地址:",window.location.origin]}),w?a.jsx("p",{role:"alert",className:"form-error",children:w}):null,d?a.jsx("button",{type:"button",className:"library-button",onClick:()=>A(()=>ny(window.localStorage,{name:d.name,address:window.location.origin+d.entryPath,environmentId:d.id})),children:"保存当前环境"}):null,a.jsx("ul",{className:"environment-list",children:h.map(L=>a.jsxs("li",{children:[a.jsxs("div",{children:[a.jsx("strong",{children:L.name}),a.jsx("small",{children:L.address})]}),a.jsx("button",{type:"button",className:"library-button",onClick:()=>D(L.address),children:"打开"}),a.jsx("button",{type:"button",className:"ghost","aria-label":`移除 ${L.name}`,onClick:()=>A(()=>dw(window.localStorage,L.address)),children:"移除"})]},L.address))}),a.jsxs("form",{onSubmit:L=>{L.preventDefault(),A(()=>ny(window.localStorage,{name:p,address:b.trim()}))},children:[a.jsxs("label",{children:["连接名称",a.jsx("input",{required:!0,maxLength:80,value:p,onChange:L=>y(L.target.value),placeholder:"例如:家里的电脑"})]}),a.jsxs("label",{children:["工作台地址",a.jsx("input",{required:!0,type:"url",maxLength:2048,value:b,onChange:L=>v(L.target.value),placeholder:"https://example.com/"})]}),a.jsx("button",{type:"submit",className:"library-button primary",children:"添加连接"})]}),a.jsx("p",{className:"environment-hint",children:"连接记录保存在当前工作台的浏览器存储中。目标环境需要单独登录或配对,请勿保存带配对令牌的地址。未连接的环境不会显示为在线。"})]}):null]})}function hw(){const t=x.useRef(null);x.useLayoutEffect(()=>{const o=c=>{const h=c.type==="focusout"?c.relatedTarget:c.target;!(h instanceof Node)||h===document.body&&c.type!=="pointerdown"||t.current&&!t.current.source.contains(h)&&(t.current.cancelled=!0)},d=()=>{t.current&&(t.current.cancelled=!0)};return document.addEventListener("pointerdown",o,!0),document.addEventListener("focusin",o,!0),document.addEventListener("focusout",o,!0),window.addEventListener("blur",d),()=>{t.current=null,document.removeEventListener("pointerdown",o,!0),document.removeEventListener("focusin",o,!0),document.removeEventListener("focusout",o,!0),window.removeEventListener("blur",d)}},[]);const r=x.useCallback((o=document.activeElement)=>{t.current&&(t.current.cancelled=!0);const d=o instanceof HTMLElement&&o!==document.body?{source:o,cancelled:!1}:null;return t.current=d,d},[]),i=x.useCallback((o,d)=>{if(!o||t.current!==o)return;t.current=null;const c=document.activeElement;o.cancelled||c&&c!==document.body&&!o.source.contains(c)&&c.isConnected||d?.isConnected&&!d.matches(":disabled")&&d.focus({preventScroll:!0})},[]),l=x.useCallback(()=>{t.current=null},[]);return{capture:r,finish:i,cancel:l}}function pw({session:t,onClose:r,onAuthLost:i,opener:l,fallbackOpener:o}){const[d,c]=x.useState([]),[h,f]=x.useState(""),[p,y]=x.useState(!1),[b,v]=x.useState(0),[w,j]=x.useState("loading"),[N,C]=x.useState(null),E=x.useRef(null),A=x.useRef(null),D=x.useRef(null),L=x.useRef(null),J=x.useRef("loading"),T=x.useRef(!1),B=x.useRef(null),U=hw(),X=x.useCallback($=>$ instanceof it&&$.status===401?(i(),!1):(T.current&&f($ instanceof Error?$.message:"操作失败,请重试。"),!0),[i]);x.useLayoutEffect(()=>(T.current=!0,E.current?.open||E.current?.showModal(),B.current=U.capture(),()=>{T.current=!1}),[U.capture]),x.useEffect(()=>{let $=!0;const F=new AbortController,P=B.current;return J.current="loading",j("loading"),f(""),y(!1),Je("/api/v1/auth/sessions",{signal:F.signal}).then(G=>{$&&(c(G.sessions),b>0&&C({request:P,kind:"list",index:0}))}).catch(G=>{$&&(y(!0),X(G)&&C({request:P,kind:"error",index:0}))}).finally(()=>{$&&(J.current=null,j(null))}),()=>{$=!1,F.abort()}},[X,b]);const _=x.useCallback(()=>{const $=E.current,F=document.activeElement;if(!T.current||!$?.open||!(F instanceof HTMLElement)||!$.contains(F))return;const P=F.closest("[data-devices-scroll]");if(!P||F===P)return;const G=P.getBoundingClientRect(),re=F.getBoundingClientRect();re.top<G.top+4?P.scrollTop-=Math.ceil(G.top+4-re.top):re.bottom>G.bottom-4&&(P.scrollTop+=Math.ceil(re.bottom-G.bottom+4))},[]);x.useLayoutEffect(()=>{if(!N||w!==null)return;C(null);const $=E.current?.querySelectorAll(".device-list button"),F=N.kind==="error"?A.current:N.kind==="list"?D.current:$?.[Math.min(N.index,$.length-1)]??L.current;U.finish(N.request,F),_()},[N,w,d,U,_]),x.useLayoutEffect(()=>{const $=E.current;if(!$)return;const F=new ResizeObserver(_);return F.observe($),$.querySelectorAll("[data-devices-scroll]").forEach(P=>F.observe(P)),$.addEventListener("focusin",_),window.addEventListener("resize",_),()=>{F.disconnect(),$.removeEventListener("focusin",_),window.removeEventListener("resize",_)}},[h,_]);const I=async($,F)=>{if(J.current!==null)return;const P=U.capture(F),G=d.findIndex(re=>re.id===$.id);J.current=$.id,j($.id),f("");try{await Je(`/api/v1/auth/sessions/${encodeURIComponent($.id)}`,{method:"DELETE"}),$.current?i():T.current&&(c(re=>re.filter(be=>be.id!==$.id)),C({request:P,kind:"neighbor",index:G}))}catch(re){X(re)&&T.current&&C({request:P,kind:"error",index:G})}finally{J.current=null,T.current&&j(null)}},H=async $=>{if(J.current!==null)return;const F=U.capture($);J.current="logout",j("logout"),f("");try{await ef("/api/v1/auth/logout"),i()}catch(P){X(P)&&T.current&&C({request:F,kind:"error",index:0})}finally{J.current=null,T.current&&j(null)}},Y=()=>{U.cancel(),E.current?.close();const $=F=>F?.isConnected&&!F.closest("[inert]")&&F.getClientRects().length&&!F.matches(":disabled");$(l)?l?.focus({preventScroll:!0}):$(o)&&o?.focus({preventScroll:!0}),r()};return a.jsxs("dialog",{className:"devices-dialog",ref:E,onCancel:$=>{$.preventDefault(),Y()},"aria-labelledby":"devices-title",children:[a.jsxs("div",{className:"dialog-head",children:[a.jsx("h2",{id:"devices-title",children:"账号与设备"}),a.jsx("button",{className:"ghost",onClick:Y,"aria-label":"关闭",children:"×"})]}),h?a.jsx("p",{className:"form-error devices-error",role:"alert",tabIndex:0,ref:A,"data-devices-scroll":!0,children:h}):null,a.jsxs("div",{className:"devices-body",ref:D,role:"region","aria-label":"登录设备",tabIndex:0,"data-devices-scroll":!0,children:[a.jsxs("p",{className:"muted devices-summary",children:[t?.username," · ",t?.deviceName||"当前设备"]}),w==="loading"?a.jsx("p",{role:"status",children:"正在读取设备…"}):null,!w&&!p&&d.length===0?a.jsx("p",{className:"muted",children:"暂无可显示的登录设备。"}):null,a.jsx("ul",{className:"device-list",children:d.map($=>a.jsxs("li",{children:[a.jsxs("div",{children:[a.jsxs("strong",{children:[$.deviceName||"未命名设备",$.current?"(当前)":""]}),a.jsxs("span",{children:["最近活动 ",new Date($.lastSeenAt).toLocaleString()]})]}),a.jsx("button",{className:"ghost","aria-disabled":w!==null,"aria-busy":w===$.id,onClick:F=>{I($,F.currentTarget)},children:w===$.id?"处理中…":"撤销登录"})]},$.id))})]}),a.jsxs("div",{className:"devices-footer",children:[p?a.jsx("button",{className:"ghost","aria-disabled":w!==null,"aria-busy":w==="loading",onClick:$=>{J.current===null&&(B.current=U.capture($.currentTarget),J.current="loading",v(F=>F+1))},children:"重新读取"}):null,a.jsx("button",{className:"stop",ref:L,"aria-disabled":w!==null,"aria-busy":w==="logout",onClick:$=>{H($.currentTarget)},children:"退出当前设备"})]})]})}function mw(t){if(!(!t||t.length>2048))try{const r=new URL(t);return r.origin!==t||r.username||r.password||r.pathname!=="/"||r.search||r.hash||r.protocol!=="https:"&&!(r.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(r.hostname))?void 0:`${r.origin}/api/v1/account/manage`}catch{return}}function ev({pending:t,error:r,onLogout:i,accountOrigin:l}){const o=mw(l);return a.jsxs("div",{className:"cloud-account-controls",children:[a.jsx("span",{children:"Cloud 工作台"}),o?a.jsx("a",{className:"library-button",href:o,target:"_blank",rel:"noopener noreferrer",children:"账号资料"}):a.jsx("button",{className:"library-button",disabled:!0,title:"此工作台尚未提供账号服务地址",children:"账号资料"}),a.jsx("button",{className:"library-button",disabled:t,onClick:i,children:t?"正在退出…":"退出此 Cloud 工作台"}),r?a.jsx("p",{className:"form-error",role:"alert",children:r}):null]})}function nd(t){return{expectedRevision:t?t.revision:null,id:t?.id??"",catalogId:t?.catalogId??"",model:t?.model??"",baseUrl:t?.baseUrl??"",apiKey:""}}function gw(t){const r={id:t.id.trim(),catalogId:t.catalogId,model:t.model.trim(),baseUrl:t.baseUrl.trim()};return t.expectedRevision!==void 0&&(r.expectedRevision=t.expectedRevision),t.apiKey.trim()&&(r.apiKey=t.apiKey.trim()),r}function zf(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 tv(t){return zf(await Je("/api/v1/configuration",{signal:t}))}async function _f(t,r,i){return zf(await Je(`/api/v1/configuration/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r),signal:i}))}function yw(t,r){return _f("connections",gw(t),r)}function bw(t,r){return _f("defaults",t,r)}function vw(t,r,i){return{...r!==(t.text??"")?{text:r}:{},...i!==(t.auxText??"")?{auxText:i||null}:{}}}function xw(t,r,i){return _f("skills",{name:t,enabled:r},i)}function rf(t){const r=t instanceof Error?t.message:"设置更新失败,请重试。",i={"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 i[r]?i[r]:/^(id|catalogId|model|text|auxText|apiKey) is invalid$/.exec(r)?"配置字段无效,请检查名称、模型与密钥后重试。":r}async function ww(t,r,i,l){return zf(await Je("/api/v1/configuration/connections",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,...r?{replacementText:r}:{},...l?{expectedRevision:l}:{}}),signal:i}))}async function Sw(t,r){const i=ql(),l=Dt("/api/v1/configuration/connections/probe"),o=Dt("/api/v1/configuration/connections/probe/cancel");let d;try{d=await Je(l,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,requestId:i}),signal:r})}catch(c){throw r?.aborted&&await Je(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:i}),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 Mf="/api/v1/skills";async function ry(t){const r=await Je(Mf,{signal:t});if(!r||!Array.isArray(r.skills)||!Array.isArray(r.directories))throw new Error("Skills 列表读取失败,请刷新重试。");return r}async function nv(t,r){const i=await Je(`${Mf}/detail?name=${encodeURIComponent(t)}`,{signal:r});if(i.name!==t||typeof i.content!="string"||typeof i.revision!="string")throw new Error("Skill 内容读取失败,请重试。");return i}function Ni(t,r,i,l){return Je(`${Mf}${t}`,{method:r,headers:{"Content-Type":"application/json"},body:JSON.stringify(i),signal:l})}const jw=(t,r,i)=>Ni("/local","POST",{name:t,content:r},i),kw=(t,r,i,l)=>Ni("/local","PUT",{name:t,content:r,revision:i},l),Ew=(t,r,i)=>Ni("/local","DELETE",{name:t,revision:r},i),Cw=(t,r)=>Ni("/github/preview","POST",{url:t.trim()},r),Tw=(t,r,i,l)=>Ni("/github/install","POST",{reviewToken:t,pathInRepo:r,name:i.trim()},l),Nw=(t,r,i)=>Ni("/github/update-preview","POST",{name:t,revision:r},i),Aw=(t,r)=>Ni("/github/update","POST",{reviewToken:t},r);function lo(t){return`---
|
|
10
|
+
name: ${t||"my-skill"}
|
|
11
|
+
description: 描述这个 Skill 适合处理什么任务
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# 工作方式
|
|
15
|
+
|
|
16
|
+
在这里写下具体步骤、输入要求和完成标准。
|
|
17
|
+
`}function sf(t){return/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(t)&&!t.includes("..")}function Rw(t,r,i){const l=r.trim().toLocaleLowerCase();return t.filter(o=>(i==="all"||o.source===i)&&(!l||`${o.name} ${o.description}`.toLocaleLowerCase().includes(l)))}const iy={project:"工作区",user:"用户级",plugin:"插件","panel-app":"Panel App"};function zw({onAuthLost:t,onChanged:r,onDirtyChange:i,configurationVersion:l=0}){const[o,d]=x.useState(null),[c,h]=x.useState(null),[f,p]=x.useState(""),[y,b]=x.useState("all"),[v,w]=x.useState(""),[j,N]=x.useState(""),[C,E]=x.useState(""),[A,D]=x.useState(0),[L,J]=x.useState(!1),[T,B]=x.useState(!1),U=x.useRef(null),X=x.useRef(null),_=x.useRef(!1),I=x.useRef({onAuthLost:t,onChanged:r});I.current={onAuthLost:t,onChanged:r};const H=x.useRef(null),Y=x.useRef(null),$=x.useRef(null),F=x.useRef(null),P=x.useRef(null),G=x.useRef(null),re=x.useRef(null),be=x.useRef(null),R=(Q=document.activeElement)=>{const oe=Q instanceof HTMLElement&&Q!==document.body?{source:Q,cancelled:!1}:null;return P.current=oe,oe};x.useEffect(()=>{const Q=Me=>{const Ce=P.current;Ce&&Me instanceof Node&&!Ce.source.contains(Me)&&(Ce.cancelled=!0)},oe=Me=>Q(Me.target),fe=Me=>{Me.target!==document.body&&Q(Me.target)},ke=Me=>{Me.relatedTarget&&Me.relatedTarget!==document.body&&Q(Me.relatedTarget)},_e=()=>{P.current&&(P.current.cancelled=!0)};return document.addEventListener("pointerdown",oe,!0),document.addEventListener("focusin",fe,!0),document.addEventListener("focusout",ke,!0),window.addEventListener("blur",_e),()=>{document.removeEventListener("pointerdown",oe,!0),document.removeEventListener("focusin",fe,!0),document.removeEventListener("focusout",ke,!0),window.removeEventListener("blur",_e),P.current=null,be.current=null}},[]),x.useLayoutEffect(()=>{const Q=be.current;if(!Q||Q.target==="opener"&&(c||v))return;be.current=null;const{request:oe}=Q,fe=document.activeElement;if(Q.target==="pane"&&fe instanceof HTMLElement&&F.current?.closest(".skills-filter")?.contains(fe)&&fe.scrollIntoView({block:"nearest",inline:"nearest"}),!oe||oe!==P.current||oe.cancelled||fe!==document.body&&!oe.source.contains(fe))return;P.current=null;const ke=Q.target==="pane"?H.current:Q.target==="editor"?re.current:Y.current;ke?.isConnected&&!ke.matches(":disabled")?ke.focus():Q.target==="opener"?F.current?.focus():$.current?.querySelector("input, textarea")?.focus()},[c,v,T]);const M=x.useCallback(Q=>{Q instanceof it&&Q.status===401?I.current.onAuthLost():N(Q instanceof Error?Q.message:"操作失败,请重试。")},[]);x.useEffect(()=>()=>{U.current?.abort(),X.current?.abort()},[]),x.useEffect(()=>{if(U.current){_.current=!0;return}const Q=new AbortController;return X.current=Q,ry(Q.signal).then(oe=>{Q.signal.aborted||d(oe)}).catch(oe=>{Q.signal.aborted||M(oe)}),()=>Q.abort()},[A,l,M]);const te=(Q,oe=!1,fe)=>{const ke=oe?G.current:R(fe);c||(Y.current=ke?.source??null),be.current={request:ke,target:"pane"},N(""),E(""),J(!1),B(!1),h(Q)},k=(Q=!1)=>{const oe=Q?G.current:$.current?.contains(document.activeElement)?R():null;be.current={request:oe,target:"opener"},h(null),J(!1),B(!1),N("")},W=()=>{if(!U.current){if(L){re.current=$.current?.contains(document.activeElement)?document.activeElement:null,B(!0);return}k()}},ue=async(Q,oe,fe=!1,ke)=>{if(U.current)return;G.current=R(ke),X.current?.abort();const _e=new AbortController;U.current=_e,w(Q),N(""),E("");try{const Me=await oe(_e.signal);if(_e.signal.aborted)return;if(fe){try{const Ce=await ry(_e.signal);_e.signal.aborted||d(Ce)}catch(Ce){if(Ce instanceof it&&Ce.status===401)throw Ce;_e.signal.aborted||N("操作已完成,但列表刷新失败。请点击刷新查看最新状态。")}if(_e.signal.aborted)return;E(Me.message||"设置已保存,下次任务生效。"),I.current.onChanged?.()}return Me}catch(Me){_e.signal.aborted||M(Me);return}finally{U.current===_e&&(U.current=null),_e.signal.aborted||(w(""),_.current&&(_.current=!1,D(Me=>Me+1)))}};x.useEffect(()=>(i?.(L||!!v),()=>i?.(!1)),[L,v,i]);const me=Rw(o?.skills??[],f,y);return a.jsxs("section",{className:"hub-skills","aria-labelledby":"skills-title",onKeyDown:Q=>{Q.key==="Escape"&&c&&!v&&(Q.preventDefault(),W())},children:[a.jsxs("header",{className:"skills-heading",children:[a.jsxs("div",{children:[a.jsx("span",{className:"skills-eyebrow",children:"工作区能力"}),a.jsx("h1",{id:"skills-title",children:"Skills"}),a.jsx("p",{children:"创建工作说明,导入社区技能,把常用流程留在工作区。"})]}),a.jsxs("div",{className:"skills-actions",children:[a.jsx("button",{className:"config-button",disabled:!!v||!!c,onClick:Q=>te({kind:"import"},!1,Q.currentTarget),children:"从 GitHub 导入"}),a.jsx("button",{className:"config-button config-button-primary",disabled:!!v||!!c,onClick:Q=>te({kind:"create"},!1,Q.currentTarget),children:"+ 创建 Skill"})]})]}),j&&a.jsx("div",{className:"config-message config-error",role:"alert",children:j}),C&&a.jsx("div",{className:"config-message config-success",role:"status",children:C}),v&&a.jsxs("p",{className:"skills-progress",role:"status",children:[v,"…"]}),c&&a.jsxs("section",{ref:$,className:"skills-workspace-panel","aria-labelledby":"skills-panel-title",children:[a.jsxs("header",{children:[a.jsx("h2",{id:"skills-panel-title",ref:H,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}`}),a.jsx("button",{className:"config-button config-button-quiet",disabled:!!v,onClick:W,children:"关闭"})]}),T&&a.jsxs("div",{className:"skills-discard-confirm",role:"alert",children:[a.jsx("p",{children:"还有未保存的修改。关闭会丢弃这些修改。"}),a.jsxs("div",{className:"skills-actions",children:[a.jsx("button",{className:"config-button",onClick:()=>{be.current={request:R(),target:"editor"},B(!1)},children:"继续编辑"}),a.jsx("button",{className:"config-button skills-danger",onClick:()=>k(),children:"放弃修改并关闭"})]})]}),(c.kind==="create"||c.kind==="detail")&&a.jsx(_w,{detail:c.kind==="detail"?c.detail:void 0,busy:!!v,run:ue,onSaved:()=>k(!0),onDirtyChange:J},c.kind==="detail"?c.detail.name+c.detail.revision:"create"),c.kind==="import"&&a.jsx(Mw,{preview:c.preview,busy:!!v,run:ue,onPreview:Q=>te({kind:"import",preview:Q},!0),onInstalled:()=>k(!0)},c.preview?.reviewToken??"url"),c.kind==="update"&&a.jsx(Dw,{preview:c.preview,busy:!!v,run:ue,onUpdated:()=>k(!0)}),c.kind==="remove"&&a.jsxs("div",{className:"skills-remove-confirm",children:[a.jsxs("p",{children:["确认从当前工作区移除 ",a.jsx("strong",{children:c.skill.name}),"?它的 SKILL.md、脚本和资源文件都会移除。"]}),a.jsx("p",{className:"config-help",children:"已保存的对话会保留。其他设备下一次运行任务时将不再使用这个工作区 Skill。"}),a.jsxs("div",{className:"skills-actions",children:[a.jsx("button",{className:"config-button",disabled:!!v,onClick:W,children:"取消"}),a.jsx("button",{className:"config-button skills-danger",disabled:!!v,onClick:()=>{ue("正在移除 Skill",Q=>Ew(c.skill.name,c.skill.revision,Q),!0).then(Q=>{Q&&k(!0)})},children:"确认移除"})]})]})]}),a.jsxs("div",{className:"skills-filter",children:[a.jsxs("label",{children:[a.jsx("span",{className:"config-sr-only",children:"搜索 Skills"}),a.jsx("input",{ref:F,type:"search","aria-label":"搜索 Skills",value:f,onChange:Q=>p(Q.target.value),placeholder:"搜索名称或用途…"})]}),a.jsxs("select",{"aria-label":"Skill 来源",value:y,onChange:Q=>b(Q.target.value),children:[a.jsx("option",{value:"all",children:"全部来源"}),Object.entries(iy).map(([Q,oe])=>a.jsx("option",{value:Q,children:oe},Q))]}),a.jsx("button",{className:"config-button config-button-quiet",disabled:!!v,onClick:()=>{N(""),D(Q=>Q+1)},children:"刷新"})]}),!o&&!j?a.jsx("p",{className:"config-help",children:"正在读取 Skills…"}):o?a.jsxs("p",{className:"skills-count",children:[me.length===o.skills.length?`${me.length} 个 Skill`:`显示 ${me.length} / ${o.skills.length} 个 Skill`," · ",o.skills.filter(Q=>Q.enabled).length," 个已启用"]}):null,o&&!me.length&&a.jsxs("div",{className:"skills-empty",children:[a.jsx("h2",{children:f||y!=="all"?"没有匹配的 Skills":"从一个常用流程开始"}),a.jsx("p",{children:f||y!=="all"?"调整搜索词或来源筛选。":"创建自己的 Skill,或粘贴 GitHub 地址导入完整的社区技能。"})]}),a.jsx("div",{className:"skills-list",children:me.map(Q=>a.jsxs("article",{className:"skills-card",children:[a.jsxs("div",{className:"skills-card-heading",children:[a.jsxs("div",{children:[a.jsx("h2",{children:Q.name}),a.jsx("span",{className:"config-badge",children:iy[Q.source]}),Q.origin&&a.jsx("span",{className:"config-badge",children:"GitHub"})]}),a.jsx("button",{className:"config-switch",role:"switch","aria-checked":Q.enabled,"aria-label":`${Q.enabled?"停用":"启用"} ${Q.name}`,disabled:!!v||!!Q.disabledReason,title:Q.disabledReason,onClick:()=>{ue("正在更新 Skill",async oe=>(await xw(Q.name,!Q.enabled,oe),{ok:!0,name:Q.name,message:Q.enabled?"Skill 已停用,下次任务生效。":"Skill 已启用,下次任务生效。"}),!0)},children:a.jsx("span",{})})]}),a.jsx("p",{children:Q.description||"暂未填写用途描述。"}),Q.origin&&a.jsxs("p",{className:"skills-source",children:[Q.origin.url.replace("https://github.com/","")," · ",Q.origin.ref," ·"," ",Q.origin.commit.slice(0,8)]}),Q.readOnlyReason&&a.jsx("p",{className:"config-help",children:Q.readOnlyReason}),Q.disabledReason&&a.jsx("p",{className:"config-help",children:Q.disabledReason}),a.jsxs("footer",{className:"skills-actions",children:[a.jsx("button",{className:"config-button config-button-quiet",disabled:!!v||!!c,onClick:oe=>{ue("正在读取 Skill",fe=>nv(Q.name,fe),!1,oe.currentTarget).then(fe=>{fe&&te({kind:"detail",detail:fe},!0)})},children:Q.editable?"查看与编辑":"查看说明"}),Q.editable&&Q.origin&&a.jsx("button",{className:"config-button config-button-quiet",disabled:!!v||!!c,onClick:oe=>{ue("正在检查来源更新",fe=>Nw(Q.name,Q.revision,fe),!1,oe.currentTarget).then(fe=>{fe?.changed?te({kind:"update",preview:fe},!0):fe&&E(`${Q.name} 已是最新版本。`)})},children:"检查更新"}),Q.removable&&a.jsx("button",{className:"config-button config-button-quiet skills-remove",disabled:!!v||!!c,onClick:oe=>te({kind:"remove",skill:Q},!1,oe.currentTarget),children:"移除"})]})]},Q.name))}),o&&a.jsxs("details",{className:"skills-directories",children:[a.jsx("summary",{children:"Skills 存在哪里"}),a.jsx("p",{children:"这里管理当前工作区。用户级、插件和 Panel App 的 Skills 可以查看和启停,安装内容由各自来源管理。"}),a.jsx("ul",{children:o.directories.map(Q=>a.jsx("li",{children:a.jsx("code",{children:Q})},Q))})]})]})}function _w({detail:t,busy:r,run:i,onSaved:l,onDirtyChange:o}){const[d,c]=x.useState(t?.name??"my-skill"),[h,f]=x.useState(t?.content??lo("my-skill")),[p,y]=x.useState(t),[b,v]=x.useState(!1),[w,j]=x.useState(null),N=h!==p?.content,C=!t||t.editable;return x.useEffect(()=>{o(C&&(p?h!==p.content:d!=="my-skill"||h!==lo("my-skill")))},[h,d,p,C,o]),a.jsx("form",{className:"skills-editor",onSubmit:E=>{E.preventDefault(),i(p?"正在保存 Skill":"正在创建 Skill",A=>p?kw(p.name,h,p.revision,A).catch(D=>{throw D instanceof it&&D.status===409&&v(!0),D}):jw(d.trim(),h,A),!0).then(A=>{A&&l()})},children:a.jsxs("fieldset",{disabled:r,children:[!t&&a.jsxs("label",{children:[a.jsx("span",{children:"名称"}),a.jsx("input",{required:!0,value:d,maxLength:128,onChange:E=>{const A=E.target.value;h===lo(d)&&f(lo(A)),c(A)},"aria-describedby":"skill-name-help","aria-label":"Skill 名称"}),a.jsx("small",{id:"skill-name-help",children:"字母、数字、短横线、下划线或点;创建后名称保持不变。"}),!sf(d)&&a.jsx("span",{className:"skills-field-error",children:"请输入有效名称。"})]}),a.jsxs("label",{children:[a.jsxs("span",{children:[C?"SKILL.md":"说明",p&&C&&N&&a.jsx("small",{className:"skills-unsaved",children:"未保存"})]}),a.jsx("textarea",{value:h,readOnly:!C,onChange:E=>f(E.target.value),rows:18,spellCheck:!1,"aria-label":"SKILL.md 内容"})]}),p&&C&&b&&a.jsxs("div",{className:"skills-conflict",role:"alert",children:[a.jsx("p",{className:"config-help",children:"这个 Skill 已在其他地方修改。你的草稿仍保留;请读取最新版本核对后再决定是否保存。"}),w?a.jsxs(a.Fragment,{children:[a.jsxs("label",{children:[a.jsx("span",{children:"最新版本"}),a.jsx("textarea",{value:w.content,readOnly:!0,rows:10,spellCheck:!1,"aria-label":"最新版本内容"})]}),a.jsx("button",{type:"button",className:"config-button",onClick:()=>{y(w),j(null),v(!1)},children:"基于最新版本保存我的草稿"})]}):a.jsx("button",{type:"button",className:"config-button",onClick:()=>{i("正在读取最新 Skill",E=>nv(p.name,E)).then(E=>{E&&j(E)})},children:"读取最新版本"})]}),t?.origin&&C&&a.jsx("p",{className:"config-help",children:"手动编辑会保留 GitHub 来源;以后更新来源时,会预览将替换的完整内容。"}),C&&a.jsxs("div",{className:"skills-actions",children:[a.jsx("span",{className:"config-help",children:"支持 Markdown 和 YAML Frontmatter。变更在下一次任务中生效。"}),a.jsx("button",{className:"config-button config-button-primary",type:"submit",disabled:!h.trim()||!p&&!sf(d)||!!p&&!N,children:p?"保存修改":"创建 Skill"})]})]})})}function Mw({preview:t,busy:r,run:i,onPreview:l,onInstalled:o}){const[d,c]=x.useState(""),[h,f]=x.useState(t?.skills[0]?.pathInRepo??""),[p,y]=x.useState(t?.skills[0]?.name??"");return t?a.jsxs("form",{className:"skills-import-preview",onSubmit:b=>{b.preventDefault(),i("正在导入 Skill 与资源",v=>Tw(t.reviewToken,h,p,v),!0).then(v=>{v&&o()})},children:[a.jsxs("p",{children:[a.jsx("a",{href:t.repoUrl,target:"_blank",rel:"noreferrer",children:t.repoUrl.replace("https://github.com/","")})," ",a.jsx("span",{className:"config-badge",children:t.commit.slice(0,8)})]}),t.warning&&a.jsx("p",{className:"config-help",children:t.warning}),a.jsxs("fieldset",{disabled:r,children:[a.jsx("legend",{children:"选择一个 Skill"}),a.jsx("div",{className:"skills-source-choices",children:t.skills.map(b=>a.jsxs("label",{children:[a.jsx("input",{type:"radio",name:"github-skill",checked:h===b.pathInRepo,onChange:()=>{f(b.pathInRepo),y(b.name)}}),a.jsxs("span",{children:[a.jsx("strong",{children:b.name}),a.jsx("small",{children:b.description||b.pathInRepo}),b.alreadyInstalled&&a.jsx("small",{children:"已有同名 Skill,可修改安装名称。"})]})]},b.pathInRepo))}),!!t.skills.length&&a.jsxs(a.Fragment,{children:[a.jsxs("label",{children:[a.jsx("span",{children:"安装到工作区时使用的名称"}),a.jsx("input",{required:!0,maxLength:128,value:p,onChange:b=>y(b.target.value)})]}),a.jsx("p",{className:"config-help",children:"将导入预览时的确定版本。不会执行其中的脚本。"}),a.jsx("button",{className:"config-button config-button-primary",disabled:!h||!sf(p),type:"submit",children:"确认导入到工作区"})]})]})]}):a.jsxs("form",{className:"skills-import-url",onSubmit:b=>{b.preventDefault(),i("正在检查 GitHub 来源",v=>Cw(d,v)).then(v=>{v&&l(v)})},children:[a.jsxs("label",{children:[a.jsx("span",{children:"GitHub 仓库或 Skill 目录地址"}),a.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:r})]}),a.jsx("p",{className:"config-help",children:"先查看可导入的技能,再确认安装。脚本和资源文件会一起保留。"}),a.jsx("button",{className:"config-button config-button-primary",disabled:r||!d.trim(),children:"预览来源"})]})}function Dw({preview:t,busy:r,run:i,onUpdated:l}){return a.jsxs("div",{className:"skills-update-preview",children:[a.jsxs("p",{children:["来源版本 ",a.jsx("code",{children:t.currentCommit.slice(0,8)})," →"," ",a.jsx("code",{children:t.latestCommit.slice(0,8)})]}),a.jsx("p",{children:"确认后会用下方版本替换此 Skill 的说明、脚本和资源,包括你在其中做过的本地修改。"}),a.jsxs("details",{children:[a.jsxs("summary",{children:["查看将导入的 ",t.files?.length??0," 个文件"]}),a.jsx("ul",{children:t.files?.map(o=>a.jsxs("li",{children:[a.jsx("code",{children:o.path}),a.jsxs("span",{children:[Math.ceil(o.size/1024)," KB",o.executable?" · 可执行脚本":""]})]},o.path))})]}),a.jsxs("label",{children:[a.jsx("span",{children:"新的 SKILL.md"}),a.jsx("textarea",{value:t.content??"",readOnly:!0,rows:16,"aria-label":"更新后的 SKILL.md"})]}),a.jsx("button",{className:"config-button config-button-primary",disabled:r||!t.reviewToken,onClick:()=>{i("正在更新 Skill",o=>Aw(t.reviewToken,o),!0).then(o=>{o&&l()})},children:"确认更新到预览版本"})]})}function Ow(t){const r=i=>i.map((l,o)=>({id:`stored-${o}`,name:l,value:"",stored:!0,removed:!1}));return{name:t?.name??"",transport:t?.transport??"stdio",command:t?.command??"",args:"",clearArgs:!1,url:t?.url??"",env:r(t?.envKeys??[]),headers:r(t?.headerKeys??[]),envHeaders:Object.entries(t?.envHeaders??{}).map(([i,l],o)=>({id:`stored-${o}`,name:i,value:l,initialValue:l,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 rd(t){return t.split(/\r?\n/).map(r=>r.trim()).filter(Boolean)}function Lw(t,r){const i={},l=new Set;for(const o of t){if(!o.stored&&o.removed)continue;const d=o.name.trim();if(["__proto__","prototype","constructor"].includes(d))throw new Error(`${r}名称无效。`);if(!d&&!o.value&&!o.stored)continue;if(!d||!o.stored&&!o.value)throw new Error(`请完整填写${r}的名称和值,或移除空行。`);const c=r==="环境变量"?d:d.toLowerCase();if(l.has(c))throw new Error(`${r}名称不能重复。`);l.add(c),o.removed?i[d]=null:o.value&&o.value!==o.initialValue&&(i[d]=o.value)}return i}function sy(t){try{return new URL(t).origin}catch{return""}}function Iw(t,r){if(!r)return!1;const i=r.envKeys.length||r.headerKeys.length||r.envVars.length||Object.keys(r.envHeaders).length||r.credentialRef||r.bearerTokenEnvVar||r.argsCount,l=t.transport!==r.transport||(t.transport==="stdio"?t.command.trim()!==r.command||!!t.args.trim()||t.clearArgs:sy(t.url)!==sy(r.url??""));return!!i&&l}function Bw(t,r){const i={name:t.name.trim()};(!r||t.transport!==r.transport)&&(i.transport=t.transport),(!r||t.enabled!==r.enabled)&&(i.enabled=t.enabled),t.transport==="stdio"?((!r||t.command.trim()!==r.command)&&(i.command=t.command.trim()),t.clearArgs?i.args=[]:t.args.trim()&&(i.args=t.args.split(/\r?\n/).filter(c=>c.length>0))):(!r||t.url.trim()!==r.url)&&(i.url=t.url.trim());for(const[c,h]of[["env","环境变量"],["headers","请求头"],["envHeaders","环境变量请求头"]]){const f=Lw(t[c],h);Object.keys(f).length&&(i[c]=f)}const l=rd(t.envVars);(!r||JSON.stringify(l)!==JSON.stringify(r.envVars))&&(i.envVars=l);for(const c of["bearerTokenEnvVar","credentialRef"])(!r||t[c].trim()!==(r[c]??""))&&(i[c]=t[c].trim()||null);const o=t.restrictTools?rd(t.allowedTools):void 0;(!r||JSON.stringify(o)!==JSON.stringify(r.allowedTools))&&(i.allowedTools=o??null);const d=rd(t.disabledTools);return(!r||JSON.stringify(d)!==JSON.stringify(r.disabledTools))&&(i.disabledTools=d),t.reuseStoredSecrets&&(i.reuseStoredSecrets=!0),i}function rv(t){if(!t||typeof t.workspacePath!="string"||!Array.isArray(t.servers)||!Array.isArray(t.removed))throw new Error("服务端返回了无效的 MCP 配置,请刷新重试。");return t}const Ns=(t,r="")=>`/api/v1/mcp/servers/${encodeURIComponent(t)}${r}`;async function qw(t){return rv(await Je("/api/v1/mcp",{signal:t}))}async function Mo(t,r,i,l){return rv(await Je(t,{method:r,headers:{"Content-Type":"application/json"},...i===void 0?{}:{body:JSON.stringify(i)},signal:l}))}function Uw(t,r,i){return Mo(r?Ns(r.name):"/api/v1/mcp/servers",r?"PUT":"POST",Bw(t,r),i)}function Hw(t,r,i){return Mo(Ns(t,"/enabled"),"PUT",{enabled:r},i)}function Pw(t,r){return Mo(Ns(t),"DELETE",void 0,r)}function ly(t,r){return Mo(Ns(t,"/inherit"),"POST",{},r)}async function Fw(t,r){const i=await Je(Ns(t,"/probe"),{method:"POST",headers:{"Content-Type":"application/json"},body:"{}",signal:r});if(i.name!==t||!["ok","error","cancelled"].includes(i.status))throw new Error("服务端返回了无效的连接测试结果。");return i}function ay(t,r,i){return Je(Dt(Ns(t,"/cancel-probe"),r,i),{method:"POST",headers:{"Content-Type":"application/json"},body:"{}",keepalive:!0})}function $w(){const t=x.useRef(!1),r=x.useRef(new Set);x.useLayoutEffect(()=>{t.current=!0;const d=h=>{const f=h instanceof FocusEvent&&h.type==="focusout"?h.relatedTarget:h.target;if(!(!(f instanceof Node)||f===document.body&&h.type!=="pointerdown"))for(const p of r.current)p.source.contains(f)||(p.cancelled=!0)},c=()=>{for(const h of r.current)h.cancelled=!0};return document.addEventListener("focusin",d,!0),document.addEventListener("focusout",d,!0),document.addEventListener("pointerdown",d,!0),window.addEventListener("blur",c),()=>{t.current=!1,c(),r.current.clear(),document.removeEventListener("focusin",d,!0),document.removeEventListener("focusout",d,!0),document.removeEventListener("pointerdown",d,!0),window.removeEventListener("blur",c)}},[]);const i=x.useCallback(d=>{const c=document.activeElement;if(!(c instanceof HTMLElement)||c===document.body||!d?.contains(c))return null;const h={source:c,cancelled:!1};return r.current.add(h),h},[]),l=x.useCallback(d=>{d&&(d.cancelled=!0,r.current.delete(d))},[]),o=x.useCallback((d,c)=>{const h=document.activeElement,f=t.current&&d&&!d.cancelled&&(h===document.body||h===d.source||!h?.isConnected);l(d),f&&c?.isConnected&&!c.matches(":disabled")&&(c.focus(),c.classList.contains("hub-mcp-operation-error")&&c.scrollIntoView({block:"center",inline:"nearest"}))},[l]);return{capture:i,discard:l,finish:o}}const Gw={local:"工作区本地",project:"工作区配置",user:"用户级",managed:"启动配置",plugin:"插件提供"};function Vw({onAuthLost:t,onConfigurationChange:r,configurationVersion:i=0,onDirtyChange:l}){const[o,d]=x.useState(null),[c,h]=x.useState(!0),[f,p]=x.useState(!1),[y,b]=x.useState(!1),[v,w]=x.useState(""),[j,N]=x.useState(""),[C,E]=x.useState(null),[A,D]=x.useState(null),[L,J]=x.useState(""),[T,B]=x.useState({}),[U,X]=x.useState(null),[_,I]=x.useState(0),H=x.useRef({onAuthLost:t,onConfigurationChange:r,onDirtyChange:l});H.current={onAuthLost:t,onConfigurationChange:r,onDirtyChange:l};const Y=x.useRef(!1),$=x.useRef(null),F=x.useRef(null),P=x.useRef(null),G=x.useRef(0),re=x.useRef(0),be=x.useRef(!1),R=x.useRef(i),M=$w(),te=x.useRef(null),k=x.useRef(null),W=x.useRef(null),ue=x.useRef(null),me=x.useRef(null),Q=x.useRef(new Map),oe=x.useRef(null),fe=x.useRef(null),ke=x.useRef(null),_e=x.useRef(null),Me=x.useRef(null),Ce=x.useRef(null),qe=x.useRef(null),Ge=x.useRef(!1),[lt,De]=x.useState(""),[Oe,ht]=x.useState(null);x.useEffect(()=>{H.current.onDirtyChange?.(y||f)},[y,f]);const at=x.useCallback(se=>{se instanceof it&&se.status===401?H.current.onAuthLost():w(se instanceof Error?se.message:"MCP 操作失败,请重试。")},[]);x.useEffect(()=>(Y.current=!0,()=>{Y.current=!1,H.current.onDirtyChange?.(!1),F.current?.abort();const se=P.current;se&&(se.controller.abort(),ay(se.name,se.workspace,se.projectId).catch(()=>{}))}),[]),x.useEffect(()=>{R.current!==i&&(R.current=i,F.current?be.current=!0:I(se=>se+1))},[i]),x.useEffect(()=>{const se=new AbortController;$.current=se;const Re=Date.now(),Ne=++G.current;return h(!0),w(""),qw(se.signal).then(Qe=>{!se.signal.aborted&&Ne===G.current&&(re.current+=1,d(Qe),B(Ue=>Object.fromEntries(Object.entries(Ue).filter(([,bt])=>Date.parse(bt.checkedAt)>=Re))))}).catch(Qe=>{!se.signal.aborted&&Ne===G.current&&at(Qe)}).finally(()=>{!se.signal.aborted&&Ne===G.current&&h(!1)}),()=>se.abort()},[_,at]);const dt=async(se,Re="MCP 设置已保存,任务进程会加载新的配置。",Ne)=>{if(F.current||P.current)return!1;$.current?.abort();const Qe=++G.current,Ue=new AbortController;F.current=Ue,p(!0),h(!1),w(""),N("");try{const bt=await se(Ue.signal);return!Y.current||Ue.signal.aborted||Qe!==G.current?!1:(re.current+=1,d(bt),B({}),N(Re),H.current.onConfigurationChange?.(),!0)}catch(bt){return Y.current&&!Ue.signal.aborted&&(Ne&&!(bt instanceof it&&bt.status===401)?Ne(bt):at(bt)),!1}finally{F.current===Ue&&(F.current=null),Y.current&&!Ue.signal.aborted&&(p(!1),be.current&&(be.current=!1,h(!0),I(bt=>bt+1)))}},Ke=async se=>{if(P.current||F.current)return;const Re=new AbortController;P.current={name:se,controller:Re,workspace:jo()??"",projectId:Dl()},X(se),w(""),N(""),B(Qe=>{const Ue={...Qe};return delete Ue[se],Ue});const Ne=re.current;try{const Qe=await Fw(se,Re.signal);Y.current&&!Re.signal.aborted&&Ne===re.current&&B(Ue=>({...Ue,[se]:Qe}))}catch(Qe){Y.current&&!Re.signal.aborted&&at(Qe)}finally{P.current?.controller===Re&&(P.current=null),Y.current&&X(null)}},rt=async()=>{const se=P.current;if(se)try{await ay(se.name,se.workspace,se.projectId)}catch(Re){Y.current&&at(Re)}finally{se.controller.abort(),P.current===se&&(P.current=null),Y.current&&(X(null),B(Re=>({...Re,[se.name]:{name:se.name,status:"cancelled",checkedAt:new Date().toISOString(),durationMs:0,error:{code:"cancelled",message:"测试已取消。"}}})))}},Ve=f||c||U!==null;x.useEffect(()=>{A&&o&&!o.servers.some(se=>se.name===A)&&D(null)},[o,A]),x.useLayoutEffect(()=>{if(!Ve){if(C===null&&fe.current){const se=ue.current?.isConnected?ue.current:me.current?Q.current.get(me.current):null;M.finish(fe.current,se?.isConnected&&!se.disabled?se:k.current??W.current),fe.current=null}if(A&&_e.current&&(M.finish(_e.current,Ce.current),_e.current=null),!A&&Me.current){const se=ke.current;M.finish(Me.current,se?.isConnected&&!se.disabled?se:W.current),Me.current=null}if(Oe){const se=!o?.servers.some(Re=>Re.name===Oe.name);if(!Oe.ok&&se&&A===Oe.name)return;ht(null),Ge.current=!1,A!==Oe.name&&!(se&&A===null)?M.discard(Oe.lease):Oe.ok?(Me.current=Oe.lease,D(null)):M.finish(Oe.lease,qe.current??Ce.current??W.current)}}},[o,A,Ve,C,M,Oe]);const nt=(se,Re)=>{ue.current=Re,me.current=se.kind==="edit"?se.name:null,M.discard(oe.current),oe.current=M.capture(te.current),E(se)},q=se=>{fe.current=se,E(null)},ne=se=>{M.finish(oe.current,se),oe.current=null},Ee=L.trim().toLocaleLowerCase(),xe=[...o?.servers??[]];C?.kind==="edit"&&!xe.some(se=>se.name===C.name)&&xe.push(C.original);const ze=xe.filter(se=>!Ee||se.name.toLocaleLowerCase().includes(Ee)||C?.kind==="edit"&&C.name===se.name),Le=C?.kind==="edit"?xe.find(se=>se.name===C.name):void 0;return a.jsxs("div",{ref:te,className:"hub-mcp",children:[a.jsxs("div",{className:"config-section-heading hub-mcp-toolbar",children:[a.jsxs("label",{className:"config-search",children:[a.jsx("span",{"aria-hidden":"true",children:"⌕"}),a.jsx("input",{ref:W,type:"search",value:L,onChange:se=>J(se.target.value),placeholder:"搜索 MCP 服务…","aria-label":"搜索 MCP 服务"})]}),a.jsxs("div",{className:"hub-mcp-toolbar-actions",children:[a.jsx("button",{className:"config-button config-button-quiet",disabled:Ve,onClick:()=>I(se=>se+1),children:"刷新 MCP"}),a.jsx("button",{ref:k,className:"config-button",disabled:Ve||C!==null,onClick:se=>nt({kind:"new"},se.currentTarget),children:"+ 添加服务"})]})]}),v&&a.jsx("p",{className:"config-message config-error",role:"alert",children:v}),!A&<&&a.jsx("p",{ref:qe,className:"config-message config-error hub-mcp-operation-error",role:"alert",tabIndex:0,"aria-label":"移除 MCP 服务失败",children:lt}),j&&a.jsx("p",{className:"config-message config-success",role:"status",children:j}),f&&a.jsx("p",{className:"config-help",role:"status",children:"正在保存 MCP 配置…"}),c&&!o&&a.jsx("p",{className:"config-help",role:"status",children:"正在读取 MCP 配置…"}),C?.kind==="new"&&a.jsxs("div",{className:"config-card hub-mcp-editor-card",children:[a.jsx("h2",{children:"添加 MCP 服务"}),a.jsx(oy,{disabled:Ve,save:dt,focus:M,onReady:ne,onDone:q,onProbe:se=>{Ke(se)},onDirtyChange:b})]}),!ze.length&&o&&C?.kind!=="new"&&a.jsxs("div",{className:"config-empty",children:[a.jsx("span",{"aria-hidden":"true",children:"⌘"}),a.jsx("h3",{children:Ee?"没有匹配的服务":"连接你的工具与数据"}),a.jsx("p",{children:Ee?"试试其他服务名称。":"添加运行 CodeShell 的设备上的命令,或连接提供 MCP 接口的 HTTP 服务。"})]}),a.jsx("div",{className:"hub-mcp-list",children:ze.map(se=>a.jsxs("article",{className:"config-card hub-mcp-card",children:[a.jsxs("div",{className:"hub-mcp-card-head",children:[a.jsx("span",{className:"config-row-icon","aria-hidden":"true",children:"⌘"}),a.jsxs("div",{className:"config-row-copy",children:[a.jsx("strong",{children:se.name}),a.jsxs("span",{children:[se.transport==="stdio"?"本地命令":se.transport==="inprocess"?"内置工具":"HTTP 服务"," ","· ",Gw[se.scope]]})]}),a.jsx("button",{className:"config-switch",type:"button",role:"switch","aria-checked":se.enabled,"aria-label":`${se.enabled?"停用":"启用"} MCP ${se.name}`,disabled:Ve||se.pluginDisabled,onClick:()=>{dt(Re=>Hw(se.name,!se.enabled,Re))},children:a.jsx("span",{})})]}),C?.kind==="edit"&&C.name===se.name&&Le?a.jsx(oy,{server:Le,disabled:Ve,save:dt,focus:M,onReady:ne,onDone:q,onProbe:Re=>{Ke(Re)},onDirtyChange:b},se.name):a.jsxs(a.Fragment,{children:[a.jsxs("p",{className:"hub-mcp-endpoint",children:[a.jsx("code",{children:se.transport==="stdio"?se.command:se.url||"由任务进程提供"}),se.argsCount>0&&a.jsxs("span",{children:[se.argsCount," 个已保存参数"]})]}),a.jsxs("div",{className:"hub-mcp-metadata",children:[a.jsx("span",{className:`config-badge${se.enabled?" config-badge-accent":""}`,children:se.enabled?"配置启用":"配置停用"}),se.envKeys.length>0&&a.jsxs("span",{children:[se.envKeys.length," 个环境变量"]}),(se.headerKeys.length>0||se.credentialRef||se.bearerTokenEnvVar||Object.keys(se.envHeaders).length>0)&&a.jsx("span",{children:"已配置认证"}),se.hasLocalOverride&&a.jsx("span",{children:"本地覆盖"})]}),se.source==="plugin"&&a.jsx("p",{className:"config-help",children:se.pluginDisabled?"所属插件已停用。启用插件后,才能启用或测试这个服务。":"连接命令与地址由插件提供,可在此启停或测试。"}),a.jsxs("div",{className:"hub-mcp-card-actions",children:[U===se.name?a.jsx("button",{className:"config-button",onClick:()=>{rt()},children:"取消测试"}):a.jsx("button",{className:"config-button",disabled:Ve||se.pluginDisabled||se.transport==="inprocess",onClick:()=>{Ke(se.name)},children:"测试连接"}),se.editable&&a.jsx("button",{ref:Re=>{Re?Q.current.set(se.name,Re):Q.current.delete(se.name)},className:"config-button config-button-quiet",disabled:Ve||C!==null,onClick:Re=>{D(null),nt({kind:"edit",name:se.name,original:se},Re.currentTarget)},children:"编辑"}),se.hasLocalOverride&&a.jsx("button",{className:"config-button config-button-quiet",disabled:Ve,onClick:()=>{dt(Re=>ly(se.name,Re),"已移除本地覆盖,恢复继承配置。")},children:"恢复继承"}),se.deletable&&a.jsx("button",{className:"config-button config-button-quiet hub-mcp-remove",disabled:Ve||C!==null,onClick:Re=>{ke.current=Re.currentTarget,_e.current=M.capture(te.current),De(""),D(se.name)},children:"移除"})]}),A===se.name&&a.jsxs("div",{className:"hub-mcp-delete",role:lt?void 0:"alert",children:[a.jsxs("span",{children:["从当前工作区移除 ",se.name,"?其他工作区的配置不受影响。"]}),lt&&a.jsx("p",{ref:qe,className:"config-message config-error hub-mcp-operation-error",role:"alert",tabIndex:0,"aria-label":"移除 MCP 服务失败",children:lt}),a.jsxs("div",{children:[a.jsx("button",{ref:Ce,className:"config-button config-button-quiet",disabled:Ve,onClick:()=>{Me.current=M.capture(te.current),D(null),De("")},children:"取消"}),a.jsx("button",{className:"config-button hub-mcp-remove",disabled:Ve,onClick:async()=>{if(Ve||Ge.current)return;Ge.current=!0;const Re=M.capture(te.current);De("");const Ne=await dt(Qe=>Pw(se.name,Qe),"已从当前工作区移除服务。",Qe=>De(Qe instanceof Error?Qe.message:"MCP 操作失败,请重试。"));Y.current&&ht({lease:Re,name:se.name,ok:Ne})},children:"确认移除"})]})]}),U===se.name&&a.jsx("p",{className:"hub-mcp-probing",role:"status",children:"正在建立测试连接并读取工具列表…"}),T[se.name]&&a.jsx(Yw,{result:T[se.name]})]})]},se.name))}),!!o?.removed.length&&a.jsxs("details",{className:"hub-mcp-removed",children:[a.jsxs("summary",{children:["已在当前工作区移除(",o.removed.length,")"]}),o.removed.map(se=>a.jsxs("div",{className:"hub-mcp-removed-row",children:[a.jsx("span",{children:se.name}),a.jsx("button",{className:"config-button config-button-quiet",disabled:Ve,onClick:()=>{dt(Re=>ly(se.name,Re),"已恢复继承的 MCP 配置。")},children:"恢复继承"})]},se.name))]}),a.jsx("p",{className:"config-help hub-mcp-explanation",children:"连接使用运行 CodeShell 的设备上的网络、环境和凭据。测试只建立一次短连接并读取工具列表,完成后关闭;不会调用工具或改变启用状态。"})]})}function oy({server:t,disabled:r,save:i,focus:l,onReady:o,onDone:d,onProbe:c,onDirtyChange:h}){const f=x.useRef(t).current,p=x.useRef(null),y=x.useRef(null),b=x.useRef(null),v=x.useRef(null),w=x.useRef(null),j=x.useRef(!1),N=x.useRef(!1),[C,E]=x.useState(null);x.useLayoutEffect(()=>(j.current=!0,o(f?b.current??v.current:y.current),()=>{j.current=!1}),[]);const[A,D]=x.useState(()=>Ow(f)),L=x.useRef(JSON.stringify(A)).current,J=JSON.stringify(A)!==L;x.useEffect(()=>{h(J)},[J,h]),x.useEffect(()=>()=>h(!1),[h]);const[T,B]=x.useState(""),U=(I,H)=>D(Y=>({...Y,[I]:H})),X=Iw(A,f),_=A.transport==="stdio";return x.useLayoutEffect(()=>{r||!C||(E(null),N.current=!1,C.ok?(d(C.lease),C.testAfter&&c(A.name.trim())):l.finish(C.lease,w.current??b.current??v.current??y.current))},[r,A.name,C,l,d,c]),a.jsx("form",{ref:p,className:"hub-mcp-editor",onSubmit:async I=>{if(I.preventDefault(),r||N.current)return;N.current=!0;const H=l.capture(p.current);B("");const Y=I.nativeEvent.submitter?.getAttribute("data-probe")==="true";try{const $=await i(F=>Uw(A,f,F),void 0,F=>{j.current&&B(F instanceof Error?F.message:"请检查填写内容。")});j.current?E({lease:H,ok:$,testAfter:Y}):l.discard(H)}catch($){j.current?(B($ instanceof Error?$.message:"请检查填写内容。"),E({lease:H,ok:!1,testAfter:Y})):l.discard(H)}},children:a.jsxs("fieldset",{disabled:r,children:[a.jsx("legend",{className:"config-sr-only",children:f?`编辑 MCP ${f.name}`:"新 MCP 服务"}),a.jsxs("div",{className:"config-form-grid",children:[a.jsxs("label",{children:[a.jsx("span",{children:"服务名称"}),a.jsx("input",{ref:y,required:!0,readOnly:!!f,maxLength:128,pattern:"[A-Za-z0-9][A-Za-z0-9._:\\-]*",value:A.name,onChange:I=>U("name",I.target.value),placeholder:"例如 workspace-tools"})]}),a.jsxs("label",{children:[a.jsx("span",{children:"连接方式"}),a.jsxs("select",{"aria-label":"连接方式",value:A.transport,onChange:I=>U("transport",I.target.value),children:[a.jsx("option",{value:"stdio",children:"本地命令(stdio)"}),a.jsx("option",{value:"streamable-http",children:"HTTP(Streamable HTTP)"}),f?.transport==="sse"&&a.jsx("option",{value:"sse",children:"HTTP(已有 SSE 配置)"})]})]}),_?a.jsxs(a.Fragment,{children:[a.jsxs("label",{className:"config-full-width",children:[a.jsx("span",{children:"启动命令"}),a.jsx("input",{ref:b,required:!0,"aria-label":"启动命令",value:A.command,onChange:I=>U("command",I.target.value),placeholder:"例如 node、uvx 或可执行文件路径"}),a.jsx("small",{children:"在当前工作区执行。命令与参数分别填写。"})]}),a.jsxs("label",{className:"config-full-width",children:[a.jsx("span",{children:"命令参数"}),a.jsx("textarea",{"aria-label":"命令参数",rows:3,disabled:A.clearArgs,value:A.args,onChange:I=>U("args",I.target.value),placeholder:f?.argsCount?`已有 ${f.argsCount} 个参数,留空保留。填写后将完整替换。`:"每行一个参数,不需要额外添加引号",autoComplete:"off",spellCheck:!1}),a.jsx("small",{children:"参数可能含密钥,因此不会读回已有值。每一行会作为一个完整参数。"})]}),!!f?.argsCount&&a.jsxs("label",{className:"hub-mcp-check config-full-width",children:[a.jsx("input",{type:"checkbox",checked:A.clearArgs,onChange:I=>U("clearArgs",I.target.checked)}),a.jsx("span",{children:"清空已保存的所有参数"})]})]}):a.jsxs("label",{className:"config-full-width",children:[a.jsx("span",{children:"MCP 接口地址"}),a.jsx("input",{ref:v,type:"url","aria-label":"MCP 接口地址",required:!0,value:A.url,onChange:I=>U("url",I.target.value),placeholder:"https://example.com/mcp"}),f?.urlHasHiddenParts&&a.jsx("small",{children:"已有地址的查询参数已隐藏;不修改地址时会保留。"})]})]}),_?a.jsx(id,{title:"环境变量",rows:A.env,onChange:I=>U("env",I)}):a.jsx(id,{title:"请求头",rows:A.headers,onChange:I=>U("headers",I)}),a.jsxs("details",{className:"hub-mcp-advanced",children:[a.jsx("summary",{children:"高级配置"}),a.jsx("div",{className:"config-form-grid",children:_?a.jsxs("label",{className:"config-full-width",children:[a.jsx("span",{children:"转发运行环境变量"}),a.jsx("textarea",{"aria-label":"转发运行环境变量",rows:2,value:A.envVars,onChange:I=>U("envVars",I.target.value),placeholder:"每行一个环境变量名称,例如 GITHUB_TOKEN"}),a.jsx("small",{children:"只填写名称,实际值在连接时从CodeShell 的启动环境读取。"})]}):a.jsxs(a.Fragment,{children:[a.jsxs("label",{children:[a.jsx("span",{children:"Bearer Token 环境变量"}),a.jsx("input",{"aria-label":"Bearer Token 环境变量",value:A.bearerTokenEnvVar,onChange:I=>U("bearerTokenEnvVar",I.target.value),placeholder:"例如 MCP_ACCESS_TOKEN",autoComplete:"off"}),a.jsx("small",{children:"填写运行环境中的变量名称。"})]}),a.jsxs("label",{children:[a.jsx("span",{children:"已存储的凭据 ID"}),a.jsx("input",{"aria-label":"已存储的凭据 ID",value:A.credentialRef,onChange:I=>U("credentialRef",I.target.value),placeholder:"可选",autoComplete:"off"}),a.jsx("small",{children:"引用已有凭据;优先于 Bearer 环境变量。"})]})]})}),!_&&a.jsx(id,{title:"环境变量请求头",rows:A.envHeaders,onChange:I=>U("envHeaders",I),visibleValues:!0}),a.jsxs("label",{className:"hub-mcp-check",children:[a.jsx("input",{type:"checkbox",checked:A.restrictTools,onChange:I=>U("restrictTools",I.target.checked)}),a.jsx("span",{children:"只允许指定工具"})]}),a.jsxs("div",{className:"config-form-grid",children:[A.restrictTools&&a.jsxs("label",{className:"config-full-width",children:[a.jsx("span",{children:"允许的工具名称"}),a.jsx("textarea",{rows:2,value:A.allowedTools,onChange:I=>U("allowedTools",I.target.value),placeholder:"每行一个精确工具名称;留空则不开放任何工具"})]}),a.jsxs("label",{className:"config-full-width",children:[a.jsx("span",{children:"停用的工具名称"}),a.jsx("textarea",{rows:2,value:A.disabledTools,onChange:I=>U("disabledTools",I.target.value),placeholder:"每行一个精确工具名称,可留空"})]})]})]}),a.jsxs("label",{className:"hub-mcp-check",children:[a.jsx("input",{type:"checkbox",checked:A.enabled,onChange:I=>U("enabled",I.target.checked)}),a.jsx("span",{children:"启用服务,让任务可以使用这些工具"})]}),X&&a.jsxs("label",{className:"hub-mcp-check hub-mcp-reuse",children:[a.jsx("input",{type:"checkbox",required:!0,checked:A.reuseStoredSecrets,onChange:I=>U("reuseStoredSecrets",I.target.checked)}),a.jsx("span",{children:"允许新的启动方式或服务地址使用已保存的参数、环境变量和认证配置。"})]}),T&&a.jsx("p",{ref:w,className:"config-error config-message hub-mcp-operation-error",role:"alert",tabIndex:0,"aria-label":"保存 MCP 配置失败",children:T}),a.jsxs("div",{className:"config-form-actions",children:[a.jsx("button",{type:"button",className:"config-button config-button-quiet",onClick:()=>d(l.capture(p.current)),children:"取消"}),a.jsx("button",{type:"submit","data-probe":"true",className:"config-button",children:"保存并测试"}),a.jsx("button",{type:"submit",className:"config-button config-button-primary",children:"保存配置"})]})]})})}function id({title:t,rows:r,onChange:i,visibleValues:l=!1}){const o=(d,c)=>i(r.map(h=>h.id===d?{...h,...c}:h));return a.jsxs("div",{className:"hub-mcp-keys",children:[a.jsxs("div",{className:"hub-mcp-key-heading",children:[a.jsx("h3",{children:t}),a.jsxs("button",{className:"config-text-button",type:"button",onClick:()=>i([...r,{id:ql(),name:"",value:"",stored:!1,removed:!1}]),children:["+ 添加",t]})]}),!r.length&&a.jsx("p",{className:"config-help",children:l?"可按请求头名称引用运行环境变量。":"无需此项时可以留空。"}),r.map(d=>a.jsxs("div",{className:`hub-mcp-key-row${d.removed?" hub-mcp-key-removed":""}`,children:[a.jsxs("label",{children:[a.jsxs("span",{className:"config-sr-only",children:[t,"名称"]}),a.jsx("input",{"aria-label":`${t}名称`,value:d.name,readOnly:d.stored,disabled:d.removed,onChange:c=>o(d.id,{name:c.target.value}),placeholder:t==="环境变量"?"例如 API_KEY":"例如 Authorization",autoComplete:"off"})]}),a.jsxs("label",{children:[a.jsxs("span",{className:"config-sr-only",children:[t,"值"]}),a.jsx("input",{"aria-label":`${t} ${d.name||"新条目"} 的值`,type:l?"text":"password",value:d.value,disabled:d.removed,onChange:c=>o(d.id,{value:c.target.value}),placeholder:d.removed?"保存时移除":l?"运行环境变量名称":d.stored?"已配置 · 留空保留":"输入值",autoComplete:l?"off":"new-password",spellCheck:!1})]}),a.jsx("button",{className:"config-button config-button-quiet",type:"button",onClick:()=>d.stored?o(d.id,{removed:!d.removed}):i(r.filter(c=>c.id!==d.id)),children:d.removed?"撤销移除":"移除"})]},d.id)),!!r.length&&!l&&a.jsx("p",{className:"config-help",children:"已有值保留在运行 CodeShell 的设备上;留空保留,填写新值替换,点击“移除”后保存才能删除。"})]})}function Yw({result:t}){return a.jsxs("div",{className:`hub-mcp-probe-result hub-mcp-probe-${t.status}`,role:"status",children:[a.jsxs("div",{className:"hub-mcp-probe-summary",children:[a.jsx("strong",{children:t.status==="ok"?"测试连接成功":t.status==="cancelled"?"测试已取消":"连接测试失败"}),a.jsxs("span",{children:[new Date(t.checkedAt).toLocaleTimeString()," ·"," ",t.durationMs<1e3?`${t.durationMs} ms`:`${(t.durationMs/1e3).toFixed(1)} 秒`]})]}),t.error&&a.jsx("p",{children:t.error.message}),t.status==="ok"&&a.jsxs(a.Fragment,{children:[a.jsxs("p",{children:["发现 ",t.toolCount??0," 个工具",t.truncated?"(列表已截取)":"","。测试连接现已关闭。"]}),!!t.tools?.length&&a.jsxs("details",{children:[a.jsx("summary",{children:"查看工具列表"}),a.jsx("ul",{children:t.tools.map((r,i)=>a.jsxs("li",{children:[a.jsxs("div",{children:[a.jsx("code",{children:r.name}),!r.allowed&&a.jsx("span",{className:"config-badge",children:"被工具策略停用"})]}),r.description&&a.jsx("p",{children:r.description})]},`${r.name}-${i}`))})]})]})]})}function iv(){const t=x.useRef(!1),r=x.useRef(null);return x.useLayoutEffect(()=>{t.current=!0;const i=h=>{r.current&&h instanceof Node&&!r.current.source.contains(h)&&(r.current.cancelled=!0)},l=h=>i(h.target),o=h=>{h.target!==document.body&&i(h.target)},d=h=>{h.relatedTarget&&h.relatedTarget!==document.body&&i(h.relatedTarget)},c=()=>{r.current&&(r.current.cancelled=!0)};return document.addEventListener("pointerdown",l,!0),document.addEventListener("focusin",o,!0),document.addEventListener("focusout",d,!0),window.addEventListener("blur",c),()=>{t.current=!1,r.current=null,document.removeEventListener("pointerdown",l,!0),document.removeEventListener("focusin",o,!0),document.removeEventListener("focusout",d,!0),window.removeEventListener("blur",c)}},[]),{isLive:()=>t.current,capture:(i=document.activeElement)=>{const l=i instanceof HTMLElement&&i!==document.body?{source:i,cancelled:!1}:null;return r.current=l,l},apply:(i,l)=>{if(!i||!t.current||r.current!==i)return;r.current=null;const o=document.activeElement;i.cancelled||o&&o!==document.body&&o!==i.source&&o.isConnected||l()}}}const Qw={overview:{title:"设置",description:"管理当前工作区的模型、Skills 和工具连接。"},models:{title:"模型与连接",description:"选择默认模型,管理工作区使用的服务商连接与凭据。"},skills:{title:"Skills",description:"让 CodeShell 按照你熟悉的工作方式完成任务。"},mcp:{title:"MCP 工具",description:"管理工具连接,测试连接并查看可用工具。"}};function Kw(t){return t.section==="skills"?a.jsx(zw,{onAuthLost:t.onAuthLost,onDirtyChange:t.onDirtyChange,onChanged:t.onConfigurationChange,configurationVersion:t.configurationVersion}):a.jsx(Xw,{...t})}function Xw({host:t="hub",section:r,onSectionChange:i,onAuthLost:l,onDirtyChange:o,onConfigurationChange:d,configurationVersion:c=0}){const[h,f]=x.useState(null),[p,y]=x.useState(!0),[b,v]=x.useState(""),[w,j]=x.useState(""),[N,C]=x.useState(null),[E,A]=x.useState(0),D=x.useRef({onAuthLost:l,onConfigurationChange:d});D.current={onAuthLost:l,onConfigurationChange:d};const L=x.useRef(!1),J=x.useRef(0),T=x.useRef(null),B=x.useRef(null),U=x.useRef(!1),X=x.useRef(c),_=x.useCallback(Y=>{Y instanceof it&&Y.status===401?D.current.onAuthLost():v(rf(Y))},[]);x.useEffect(()=>{c!==X.current&&(X.current=c,B.current?U.current=!0:A(Y=>Y+1))},[c]),x.useEffect(()=>(L.current=!0,()=>{L.current=!1,B.current?.abort()}),[]),x.useEffect(()=>{const Y=new AbortController;T.current=Y;const $=++J.current;return y(!0),v(""),tv(Y.signal).then(F=>{!Y.signal.aborted&&$===J.current&&f(F)}).catch(F=>{!Y.signal.aborted&&$===J.current&&_(F)}).finally(()=>{!Y.signal.aborted&&$===J.current&&y(!1)}),()=>Y.abort()},[E,_]);const I=async(Y,$,F)=>{if(B.current)return!1;T.current?.abort();const P=++J.current,G=new AbortController;B.current=G,y(!1),C(Y),v(""),j("");try{const re=await $(G.signal);if(!L.current||G.signal.aborted||P!==J.current)return!1;f(re);const be=re.restartRequired?"设置已保存,重启服务后生效。":"设置已保存,下次运行任务时生效。";return F?F.saved(be):j(be),D.current.onConfigurationChange?.(),!0}catch(re){return re instanceof it&&re.status===409&&(U.current=!0),L.current&&!G.signal.aborted&&(F&&!(re instanceof it&&re.status===401)?F.error(rf(re)):_(re)),!1}finally{B.current===G&&(B.current=null),L.current&&!G.signal.aborted&&(C(null),U.current&&(U.current=!1,y(!0),A(re=>re+1)))}},H=Qw[r];return a.jsxs("section",{className:"hub-settings","aria-labelledby":"hub-settings-title",children:[a.jsxs("div",{className:"hub-settings-heading",children:[a.jsxs("div",{children:[a.jsx("span",{className:"hub-settings-eyebrow",children:t==="desktop"?"桌面工作区":"服务端工作区"}),a.jsx("h1",{id:"hub-settings-title",children:H.title}),a.jsx("p",{children:H.description})]}),a.jsx("button",{className:"config-button config-button-quiet",disabled:p||N!==null,onClick:()=>{j(""),A(Y=>Y+1)},children:p?"读取中…":"刷新"})]}),b&&a.jsx("div",{className:"config-message config-error",role:"alert",children:b}),w&&a.jsx("div",{className:"config-message config-success",role:"status",children:w}),N&&a.jsxs("p",{className:"config-loading",role:"status",children:["正在保存",N,"…"]}),!h&&p?a.jsx("p",{className:"config-loading",role:"status",children:"正在读取工作区设置…"}):null,h&&a.jsxs(a.Fragment,{children:[r==="overview"&&a.jsx(Zw,{host:t,configuration:h,onSectionChange:i}),r==="models"&&a.jsx(Jw,{configuration:h,disabled:N!==null||p,saving:N!==null,save:I,onDirtyChange:o,onAuthLost:l}),r==="mcp"&&a.jsx(Vw,{onAuthLost:l,onDirtyChange:o,onConfigurationChange:d,configurationVersion:c}),a.jsx("p",{className:"config-scope-note",children:"配置作用于当前工作区,所有连接到这里的设备共用。"})]})]})}function Zw({host:t,configuration:r,onSectionChange:i}){const l=r.connections.find(c=>c.id===r.defaults.text),o=r.skills.filter(c=>c.enabled).length,d=[{section:"models",title:"模型与连接",summary:l?`${l.id} · ${l.model}`:"尚未设置默认模型",icon:"◈"},{section:"skills",title:"Skills",summary:`${r.skills.length} 个可用 · ${o} 个已启用`,icon:"✧"},{section:"mcp",title:"MCP 工具",summary:`${r.mcpServers.length} 个已配置的工具服务`,icon:"⌘"}];return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"config-workspace-card",children:[a.jsx("span",{className:"config-workspace-icon","aria-hidden":"true",children:"▱"}),a.jsxs("div",{children:[a.jsx("strong",{children:"当前工作区"}),a.jsx("code",{children:r.workspace.path}),a.jsx("p",{children:t==="desktop"?"对话、文件操作和工具都由已连接的桌面端执行。":"对话、文件操作和工具都在服务端运行。"})]}),a.jsx("span",{className:"config-badge",children:t==="desktop"?"桌面工作区":"服务端工作区"})]}),a.jsx("h2",{className:"config-section-title",children:"工作区配置"}),a.jsx("div",{className:"config-card config-overview-list",children:d.map(c=>{const h=a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"config-row-icon","aria-hidden":"true",children:c.icon}),a.jsxs("span",{className:"config-row-copy",children:[a.jsx("strong",{children:c.title}),a.jsx("span",{children:c.summary})]}),i&&a.jsx("span",{className:"config-chevron","aria-hidden":"true",children:"›"})]});return i?a.jsx("button",{className:"config-overview-row",onClick:()=>i(c.section),children:h},c.section):a.jsx("div",{className:"config-overview-row",children:h},c.section)})}),a.jsxs("div",{className:"config-explanation",children:[a.jsx("h2",{children:"工作区与执行位置"}),a.jsx("p",{children:t==="desktop"?"这里直接使用桌面端的任务、模型、Skills 和工具连接。修改配置后,桌面窗口和已配对的网页共同使用。":"这里使用服务端的任务、模型、Skills 和工具连接。修改配置后,连接到这个服务端的网页共同使用。"}),a.jsx("p",{children:t==="desktop"?"切换项目会切换对应的文件、历史和工作区设置;无需复制桌面配置。":"独立部署使用自己的运行环境。部署到另一台机器时,需要迁移配置和数据,或在这里重新设置。"})]})]})}function Jw({configuration:t,disabled:r,saving:i,save:l,onDirtyChange:o,onAuthLost:d}){const[c,h]=x.useState(null),[f,p]=x.useState(null),[y,b]=x.useState(""),[v,w]=x.useState(!1),[j,N]=x.useState(!1),[C,E]=x.useState(null),[A,D]=x.useState({}),L=x.useRef(null),J=x.useRef(null),T=x.useRef(null),B=x.useRef(null),U=x.useRef(null),X=x.useRef(null),_=x.useRef(null),I=x.useRef(null),H=x.useRef(null),Y=x.useRef(!1),$=iv(),F=x.useId(),[P,G]=x.useState(null),[re,be]=x.useState(null),R=x.useRef(null),M=t.connections.filter(oe=>oe.tag==="text"),te=t.connections.length-M.length,k=r||!!C;x.useLayoutEffect(()=>{!re||k||re.kind==="close"&&f||f&&!t.connections.some(oe=>oe.id===f.id)||(be(null),$.apply(re.request,()=>{(re.kind==="open"?I.current??X.current:re.kind==="failed"&&f?_.current&&!_.current.disabled?_.current:X.current:U.current?.isConnected&&!U.current.disabled?U.current:B.current)?.focus(),H.current?.scrollIntoView({block:"nearest",inline:"nearest"})}))},[k,t.connections,re,f]),x.useLayoutEffect(()=>{const oe=R.current;if(c!==null||!oe||(R.current=null,document.activeElement!==document.body&&document.activeElement!==oe))return;const fe=J.current;(fe?.isConnected&&!fe.disabled?fe:T.current&&!T.current.disabled?T.current:B.current)?.focus()},[c]);const W=(oe,fe)=>{J.current=fe,R.current=null,h(oe)},ue=oe=>{R.current=oe&&document.activeElement instanceof HTMLElement?document.activeElement:null,h(null)};x.useEffect(()=>{f&&!t.connections.some(oe=>oe.id===f.id)&&p(null)},[t.connections,f]),x.useEffect(()=>()=>L.current?.abort(),[]);const me=x.useRef(new Map);x.useEffect(()=>{const oe=new Map(t.connections.map(ke=>[ke.id,ke.revision??JSON.stringify(ke)])),fe=new Set([...me.current].filter(([ke,_e])=>oe.get(ke)!==_e).map(([ke])=>ke));me.current=oe,C&&fe.has(C)&&L.current?.abort(),fe.size&&D(ke=>Object.fromEntries(Object.entries(ke).filter(([_e])=>!fe.has(_e))))},[t,C]),x.useEffect(()=>(o?.(v||j||i||!!C),()=>o?.(!1)),[v,j,i,C,o]);const Q=async oe=>{if(L.current)return;const fe=new AbortController;L.current=fe,E(oe.id),D(ke=>({...ke,[oe.id]:"正在发送一条简短测试请求…"}));try{const ke=await Sw(oe.id,fe.signal);fe.signal.aborted||D(_e=>({..._e,[oe.id]:ke}))}catch(ke){fe.signal.aborted||(ke instanceof it&&ke.status===401?d():D(_e=>({..._e,[oe.id]:rf(ke)})))}finally{L.current===fe&&(L.current=null,E(null))}};return a.jsxs(a.Fragment,{children:[a.jsx(Ww,{configuration:t,disabled:k,save:l,onDirtyChange:N}),a.jsxs("div",{className:"config-section-heading",children:[a.jsxs("h2",{ref:B,tabIndex:-1,children:["文字模型连接 ",a.jsx("span",{className:"config-count",children:M.length})]}),a.jsxs("button",{ref:T,className:"config-button",disabled:k||c!==null||f!==null||!t.catalog.length,onClick:oe=>W("__new__",oe.currentTarget),children:[a.jsx("span",{"aria-hidden":"true",children:"+"})," 添加连接"]})]}),!f&&P&&a.jsx("div",{ref:H,className:`config-message config-action-feedback config-${P.kind}`,role:P.kind==="error"?"alert":"status","aria-label":P.kind==="success"?"删除模型连接结果":void 0,tabIndex:0,children:P.message}),c!==null&&a.jsxs("div",{className:"config-card config-editor-card",children:[a.jsx("h3",{children:c==="__new__"?"添加模型连接":`编辑 ${c.id}`}),a.jsx(eS,{connection:c==="__new__"?void 0:c,configuration:t,disabled:k,save:l,onDone:ue,onDirtyChange:w},c==="__new__"?"new":c.id)]}),!M.length&&c!=="__new__"&&a.jsx(tS,{title:"还没有文字模型连接",description:"添加服务商地址、模型名称和 API Key,再选择一个默认模型。"}),a.jsx("div",{className:"config-connection-list",children:M.map(oe=>{const fe=t.catalog.find(qe=>qe.id===oe.catalogId),ke=f?.id===oe.id,_e=ke&&f?.revision!==oe.revision,Me=t.defaults.text===oe.id&&M.length>1,Ce=A[oe.id];return a.jsxs("article",{className:"config-card config-connection-card",children:[a.jsxs("div",{className:"config-connection-head",children:[a.jsx("span",{className:"config-model-icon","aria-hidden":"true",children:"◈"}),a.jsxs("div",{className:"config-row-copy",children:[a.jsx("strong",{children:oe.id}),a.jsx("span",{children:fe?.displayName??oe.catalogId})]}),t.defaults.text===oe.id&&a.jsx("span",{className:"config-badge config-badge-accent",children:"默认"}),a.jsx("button",{className:"config-button config-button-quiet",disabled:k||c!==null||f!==null,onClick:qe=>W(oe,qe.currentTarget),children:"编辑"})]}),a.jsxs("dl",{className:"config-connection-facts",children:[a.jsxs("div",{children:[a.jsx("dt",{children:"模型"}),a.jsx("dd",{children:oe.model||"未填写"})]}),a.jsxs("div",{children:[a.jsx("dt",{children:"服务地址"}),a.jsx("dd",{children:oe.baseUrl||fe?.defaultBaseUrl||"服务商默认地址"})]}),a.jsxs("div",{children:[a.jsx("dt",{children:"API Key"}),a.jsx("dd",{children:oe.hasApiKey?"•••••••• · 已配置":oe.needsKey?"未配置":"无需 API Key"})]})]}),a.jsxs("div",{className:"config-model-actions",children:[C===oe.id?a.jsx("button",{className:"config-button",onClick:()=>{L.current?.abort(),D(qe=>({...qe,[oe.id]:"已取消连接测试。"}))},children:"取消测试"}):a.jsx("button",{className:"config-button",disabled:k||c!==null||f!==null,onClick:()=>{Q(oe)},children:"测试连接"}),a.jsx("span",{className:"config-help",children:"发送一条简短请求,服务商可能计费。"}),a.jsx("button",{className:"config-button config-button-quiet config-remove-connection",disabled:k||c!==null||f!==null,onClick:qe=>{U.current=qe.currentTarget;const Ge=$.capture(qe.currentTarget);p(oe),b(""),G(null),be({request:Ge,kind:"open"})},children:"删除"})]}),Ce&&a.jsxs("div",{className:`config-probe-result ${typeof Ce!="string"&&Ce.ok?"is-success":""}`,role:"status",children:[a.jsx("span",{children:typeof Ce=="string"?Ce:Ce.message}),typeof Ce!="string"&&a.jsxs("small",{children:[Math.max(.01,Ce.latencyMs/1e3).toFixed(2)," 秒 ·"," ",new Date(Ce.checkedAt).toLocaleTimeString()]})]}),ke&&a.jsxs("div",{className:"config-remove-confirm",role:"group","aria-labelledby":F,children:[a.jsxs("h3",{id:F,children:["删除连接 ",oe.id,"?"]}),a.jsx("p",{children:"连接会从当前工作区移除,已有对话记录会保留。"}),M.length===1&&a.jsx("p",{children:"这是最后一个文字模型连接。删除后需重新添加连接才能继续对话。"}),Me&&a.jsxs("label",{children:[a.jsx("span",{children:"替代默认模型"}),a.jsxs("select",{ref:I,"aria-label":"替代默认模型",value:y,onChange:qe=>b(qe.target.value),disabled:k,children:[a.jsx("option",{value:"",children:"请选择其他连接"}),M.filter(qe=>qe.id!==oe.id).map(qe=>a.jsxs("option",{value:qe.id,children:[qe.id," · ",qe.model]},qe.id))]})]}),a.jsxs("div",{className:"config-form-actions",children:[a.jsx("button",{ref:X,className:"config-button",disabled:k,onClick:qe=>{if(k||Y.current)return;const Ge=$.capture(qe.currentTarget);p(null),G(null),be({request:Ge,kind:"close"})},children:"取消删除"}),a.jsx("button",{ref:_,className:"config-button config-button-danger",disabled:k||_e||Me&&!y,onClick:async qe=>{if(k||Y.current||_e||Me&&!y)return;Y.current=!0;const Ge=$.capture(qe.currentTarget);G(null);let lt=!1;const De=await l("删除连接",Oe=>ww(oe.id,y||void 0,Oe,f?.revision),{error:Oe=>{lt=!0,$.isLive()&&G({kind:"error",message:Oe})},saved:Oe=>{$.isLive()&&G({kind:"success",message:Oe})}});Y.current=!1,$.isLive()&&(De&&p(null),(De||lt)&&be({request:Ge,kind:De?"close":"failed"}))},children:"确认删除连接"})]}),(_e||P?.kind==="error")&&a.jsxs("div",{ref:H,className:"config-message config-error config-action-feedback",role:"alert",tabIndex:0,children:[_e&&"连接已被其他设备更新,请取消后重新检查再删除。",_e&&P?.kind==="error"?`
|
|
21
|
+
`:null,P?.kind==="error"&&P.message]})]})]},oe.id)})}),te>0&&a.jsxs("p",{className:"config-help",children:["另有 ",te," 个其他类型的模型连接,保留在工作区配置中。目前此处提供文字模型编辑。"]})]})}function Ww({configuration:t,disabled:r,save:i,onDirtyChange:l}){const[o,d]=x.useState(t.defaults.text??""),[c,h]=x.useState(t.defaults.auxText??""),[f,p]=x.useState(null),[y,b]=x.useState(null),v=x.useRef(!1),w=x.useRef(null),j=x.useRef(null),N=x.useRef(null),C=iv();x.useLayoutEffect(()=>{r||!y||(b(null),C.apply(y.request,()=>{(w.current&&!w.current.disabled?w.current:N.current??j.current)?.focus(),N.current?.scrollIntoView({block:"nearest",inline:"nearest"})}))},[r,y]);const E=x.useRef(t.defaults);x.useEffect(()=>{const L=E.current;E.current=t.defaults,d(J=>J===(L.text??"")?t.defaults.text??"":J),h(J=>J===(L.auxText??"")?t.defaults.auxText??"":J)},[t.defaults]);const A=t.connections.filter(L=>L.tag==="text"),D=o!==(t.defaults.text??"")||c!==(t.defaults.auxText??"");return x.useEffect(()=>(l(D),()=>l(!1)),[D,l]),a.jsx("form",{className:"config-card config-defaults",onSubmit:async L=>{if(L.preventDefault(),v.current||r||!A.length||!D||!o)return;v.current=!0;const J=L.nativeEvent.submitter,T=C.capture(J??document.activeElement);p(null);let B=!1;const U=await i("默认模型",X=>bw(vw(t.defaults,o,c),X),{error:X=>{B=!0,C.isLive()&&p({kind:"error",message:X})},saved:X=>{C.isLive()&&p({kind:"success",message:X})}});v.current=!1,C.isLive()&&(U||B)&&b({request:T})},children:a.jsxs("fieldset",{disabled:r||!A.length,children:[a.jsx("legend",{children:"默认模型"}),a.jsxs("div",{className:"config-form-grid",children:[a.jsxs("label",{children:[a.jsx("span",{children:"对话模型"}),a.jsxs("select",{ref:j,required:!0,value:o,onChange:L=>{d(L.target.value),p(null)},"aria-label":"默认对话模型",children:[a.jsx("option",{value:"",disabled:!0,children:"选择模型连接"}),o&&!A.some(L=>L.id===o)&&a.jsxs("option",{value:o,disabled:!0,children:[o,"(连接不可用)"]}),A.map(L=>a.jsxs("option",{value:L.id,children:[L.id," · ",L.model]},L.id))]})]}),a.jsxs("label",{children:[a.jsx("span",{children:"辅助模型"}),a.jsxs("select",{value:c,onChange:L=>{h(L.target.value),p(null)},"aria-label":"默认辅助模型",children:[a.jsx("option",{value:"",children:"跟随对话模型"}),c&&!A.some(L=>L.id===c)&&a.jsxs("option",{value:c,disabled:!0,children:[c,"(连接不可用)"]}),A.map(L=>a.jsxs("option",{value:L.id,children:[L.id," · ",L.model]},L.id))]})]})]}),a.jsxs("div",{className:"config-form-footer",children:[a.jsx("p",{className:"config-help",children:"辅助模型用于标题生成等轻量任务。"}),a.jsx("button",{ref:w,className:"config-button",disabled:!D||!o,type:"submit",children:"保存默认模型"})]}),f&&a.jsx("div",{ref:N,className:`config-message config-action-feedback config-${f.kind}`,role:f.kind==="error"?"alert":"status","aria-label":f.kind==="success"?"默认模型保存结果":void 0,tabIndex:0,children:f.message})]})})}function eS({connection:t,configuration:r,disabled:i,save:l,onDone:o,onDirtyChange:d}){const c=x.useRef(null),h=x.useRef(null),f=x.useRef(null),p=x.useRef(!1),y=x.useRef(null),[b,v]=x.useState(null);x.useLayoutEffect(()=>{p.current=!0,(h.current?.readOnly?f.current:h.current)?.focus();const I=Y=>{y.current&&!c.current?.contains(Y.target)&&(y.current.cancelled=!0)},H=()=>{y.current&&(y.current.cancelled=!0)};return document.addEventListener("pointerdown",I,!0),document.addEventListener("focusin",I,!0),window.addEventListener("blur",H),()=>{p.current=!1,y.current=null,document.removeEventListener("pointerdown",I,!0),document.removeEventListener("focusin",I,!0),window.removeEventListener("blur",H)}},[]),x.useLayoutEffect(()=>{if(i||!b||(v(null),y.current!==b.owner))return;y.current=null;const I=document.activeElement,H=!b.owner.cancelled&&(I===document.body||I===b.owner.source||!!c.current?.contains(I));b.ok?o(H):H&&(t?f.current:h.current)?.focus()},[t,i,b,o]);const[w,j]=x.useState(()=>{const I=nd(t);return t||(I.catalogId=r.catalog[0]?.id??""),I}),N=x.useRef(w),C=JSON.stringify(w)!==JSON.stringify(N.current),[E,A]=x.useState(!1),D=x.useRef(null),L=x.useRef(null);x.useLayoutEffect(()=>{if(E){c.current?.contains(document.activeElement)&&D.current?.focus();return}const I=L.current;L.current=null,I&&(document.activeElement===document.body||document.activeElement===I)&&(h.current?.readOnly?f.current:h.current)?.focus()},[E]);const J=t?r.connections.find(I=>I.id===t.id):void 0,T=!!t&&(!J||w.expectedRevision!==J.revision);x.useEffect(()=>{if(!C&&J&&w.expectedRevision!==J.revision){const I=nd(J);N.current=I,j(I)}},[C,J,w.expectedRevision]);const B=()=>{if(!J)return;const I=nd(J);N.current=I,j(I),A(!1)};x.useEffect(()=>(d(C),()=>d(!1)),[C,d]);const U=r.catalog.find(I=>I.id===w.catalogId),X=!t&&r.connections.some(I=>I.id===w.id.trim()),_=(I,H)=>j(Y=>({...Y,[I]:H}));return a.jsx("form",{ref:c,className:"config-connection-editor",onSubmit:async I=>{if(I.preventDefault(),i||T||y.current)return;const H={cancelled:!1,source:document.activeElement};y.current=H;const Y=await l("模型连接",$=>yw(w,$));p.current&&v({owner:H,ok:Y})},children:a.jsxs("fieldset",{disabled:i,children:[a.jsx("legend",{className:"config-sr-only",children:t?`编辑 ${t.id}`:"新模型连接"}),T&&a.jsxs("div",{className:"config-remove-confirm",role:"alert",children:[a.jsx("p",{children:J?"其他设备已更新这个连接。你的草稿已保留,请检查最新设置后再保存。":"这个连接已被其他设备删除。草稿仍保留,你可以复制内容后关闭编辑。"}),J&&a.jsx("button",{className:"config-button",type:"button",onClick:B,children:"放弃草稿并载入最新设置"})]}),a.jsxs("div",{className:"config-form-grid",children:[a.jsxs("label",{children:[a.jsx("span",{children:"连接名称"}),a.jsx("input",{ref:h,required:!0,maxLength:120,value:w.id,readOnly:!!t,onChange:I=>_("id",I.target.value),placeholder:"例如 work-model",autoComplete:"off"})]}),a.jsxs("label",{children:[a.jsx("span",{children:"服务商"}),a.jsxs("select",{required:!0,disabled:!!t,"aria-label":"服务商",value:w.catalogId,onChange:I=>_("catalogId",I.target.value),children:[t&&!U&&a.jsx("option",{value:w.catalogId,children:w.catalogId}),r.catalog.map(I=>a.jsx("option",{value:I.id,children:I.displayName},I.id))]})]}),a.jsxs("label",{className:"config-full-width",children:[a.jsx("span",{children:"模型名称"}),a.jsx("input",{ref:f,required:!0,maxLength:240,value:w.model,onChange:I=>_("model",I.target.value),placeholder:"服务商提供的模型 ID",autoComplete:"off"})]}),a.jsxs("label",{className:"config-full-width",children:[a.jsx("span",{children:"服务地址"}),a.jsx("input",{type:"url","aria-label":"服务地址",value:w.baseUrl,onChange:I=>_("baseUrl",I.target.value),placeholder:U?.defaultBaseUrl||"使用服务商默认地址",autoComplete:"off"}),a.jsx("small",{children:"留空使用服务商默认地址,支持兼容接口。"})]}),a.jsxs("label",{className:"config-full-width",children:[a.jsxs("span",{children:["API Key ",t?.hasApiKey&&a.jsx("span",{className:"config-field-meta",children:"已配置"})]}),a.jsx("input",{type:"password","aria-label":"API Key",required:U?.needsKey&&!t?.hasApiKey,value:w.apiKey,onChange:I=>_("apiKey",I.target.value),placeholder:t?.hasApiKey?"留空保留现有 API Key":U?.needsKey?"输入 API Key":"可选",autoComplete:"new-password",spellCheck:!1}),a.jsx("small",{children:t?.hasApiKey?"现有密钥保留在运行 CodeShell 的设备上,输入新值可替换。":"密钥保存在当前工作区配置中。"})]})]}),X&&a.jsx("p",{className:"config-error config-message",role:"alert",children:"连接名称已存在,请使用其他名称或编辑现有连接。"}),a.jsx("p",{className:"config-help",children:"保存后可在连接卡片中测试实际连接。"}),E&&a.jsxs("div",{className:"config-remove-confirm",role:"alert",children:[a.jsx("p",{children:"还有未保存的修改,确定放弃?"}),a.jsxs("div",{className:"config-form-actions",children:[a.jsx("button",{ref:D,type:"button",className:"config-button",onClick:I=>{L.current=document.activeElement===I.currentTarget?I.currentTarget:null,A(!1)},children:"继续编辑"}),a.jsx("button",{type:"button",className:"config-button config-button-danger",onClick:()=>o(!!c.current?.contains(document.activeElement)),children:"放弃修改"})]})]}),a.jsxs("div",{className:"config-form-actions",children:[a.jsx("button",{type:"button",className:"config-button config-button-quiet",onClick:()=>C?A(!0):o(!!c.current?.contains(document.activeElement)),children:"取消"}),a.jsx("button",{type:"submit",className:"config-button config-button-primary",disabled:X||T,children:"保存连接"})]})]})})}function tS({title:t,description:r}){return a.jsxs("div",{className:"config-empty",children:[a.jsx("span",{"aria-hidden":"true",children:"◇"}),a.jsx("h3",{children:t}),a.jsx("p",{children:r})]})}function sd(t,r=!1){return Dt(`/api/v1/files/content?path=${encodeURIComponent(t)}${r?"&inline=true":""}`)}function uy(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function nS({initialPath:t,openVersion:r=0,onAuthLost:i}){const[l,o]=x.useState(""),[d,c]=x.useState(null),[h,f]=x.useState(null),[p,y]=x.useState(null),[b,v]=x.useState(!1),[w,j]=x.useState(!1),[N,C]=x.useState(""),[E,A]=x.useState(""),[D,L]=x.useState(0),[J,T]=x.useState(""),B=x.useRef(null),U=x.useRef(null),X=x.useRef(null),_=x.useRef(null),I=x.useRef(null),H=x.useRef(null),Y=x.useRef(0),$=x.useRef(!1),F=x.useRef(!1),P=x.useRef(!1),G=x.useRef(i);G.current=i;const re=x.useCallback(ue=>ue instanceof it&&ue.status===401?(G.current(),"登录已失效,请重新登录。"):ue instanceof Error?ue.message:"文件读取失败,请重试。",[]);x.useEffect(()=>{const ue=new AbortController;return B.current=ue,v(!0),c(null),C(""),Je(`/api/v1/files?path=${encodeURIComponent(l)}`,{signal:ue.signal}).then(me=>{ue.signal.aborted||c({target:l,value:me})}).catch(me=>{ue.signal.aborted||C(re(me))}).finally(()=>{ue.signal.aborted||v(!1)}),()=>ue.abort()},[l,D,re]);const be=x.useCallback(ue=>{B.current?.abort(),c(null),C(""),v(!0),o(ue),H.current=null,Y.current=0,L(me=>me+1),T(""),$.current=!0},[]),R=x.useCallback(ue=>{U.current?.abort(),j(!1),f(null),y(null),A(""),P.current=!1,F.current=!1,be(ue)},[be]),M=x.useCallback((ue,me=!1,Q)=>{me&&(H.current=null,Y.current=0),Q&&(H.current=Q,Y.current=X.current?.scrollTop??0),$.current=!1,F.current=!0,P.current=!1,U.current?.abort();const oe=new AbortController;U.current=oe,f(null),y(ue),j(!0),A(""),Je(`${sd(ue)}&preview=true`,{signal:oe.signal}).then(fe=>{oe.signal.aborted||(me&&(be(fe.path.split("/").slice(0,-1).join("/")),$.current=!1),y(fe.path),f(fe))}).catch(fe=>{oe.signal.aborted||A(re(fe))}).finally(()=>{oe.signal.aborted||j(!1)})},[be,re]);x.useEffect(()=>{t&&M(t,!0)},[t,r,M]),x.useEffect(()=>()=>U.current?.abort(),[]);const te=()=>{U.current?.abort(),j(!1),f(null),y(null),A(""),P.current=!0};x.useLayoutEffect(()=>{if(p!==null&&F.current)F.current=!1,I.current?.focus({preventScroll:!0}),I.current?.scrollIntoView({block:"start"});else if(p===null&&P.current){P.current=!1,X.current&&(X.current.scrollTop=Y.current);const ue=H.current;ue?.isConnected?ue.focus({preventScroll:!0}):_.current?.focus({preventScroll:!0})}},[p,w]),x.useLayoutEffect(()=>{!b&&$.current&&p===null&&($.current=!1,_.current?.focus({preventScroll:!0}))},[b,p]);const k=d?.target===l?d.value:null,W=k?.files.filter(ue=>ue.name.toLocaleLowerCase().includes(J.toLocaleLowerCase()))??[];return a.jsxs("section",{ref:X,className:"hub-library hub-files","aria-labelledby":"hub-files-heading",children:[a.jsxs("header",{className:"library-heading",children:[a.jsxs("div",{children:[a.jsx("h1",{id:"hub-files-heading",children:"工作区文件"}),a.jsx("p",{children:"查看任务生成的内容,下载到当前设备。"})]}),a.jsx("button",{className:"library-button",onClick:()=>{B.current?.abort(),L(ue=>ue+1),p!==null&&M(p)},children:"刷新"})]}),a.jsxs("nav",{className:"file-breadcrumbs","aria-label":"文件位置",children:[a.jsx("button",{"aria-current":l?void 0:"location",onClick:()=>R(""),children:"工作区"}),l.split("/").filter(Boolean).map((ue,me,Q)=>a.jsxs(x.Fragment,{children:[a.jsx("span",{"aria-hidden":"true",children:"/"}),a.jsx("button",{"aria-current":me===Q.length-1?"location":void 0,onClick:()=>R(Q.slice(0,me+1).join("/")),children:ue})]},me))]}),a.jsxs("div",{className:`file-columns${p!==null?" has-preview":""}`,children:[a.jsxs("div",{ref:_,className:"file-directory",tabIndex:-1,role:"region","aria-label":`文件夹:${l||"工作区"}`,children:[a.jsxs("label",{className:"library-search",children:[a.jsx("span",{className:"sr-only",children:"筛选当前文件夹"}),a.jsx("input",{type:"search",placeholder:"筛选当前文件夹…",value:J,disabled:!k,onChange:ue=>T(ue.target.value)})]}),a.jsx("div",{className:"file-entries","aria-busy":b,children:b?a.jsx("p",{className:"library-empty",role:"status",children:"正在读取文件…"}):N?a.jsxs("div",{className:"library-error file-read-error",role:"alert",children:[a.jsxs("strong",{children:["无法读取“",l||"工作区","”"]}),a.jsx("p",{children:N}),a.jsx("button",{className:"library-button",onClick:()=>{$.current=!0,L(ue=>ue+1)},children:"重新读取文件夹"})]}):W.length===0?a.jsx("p",{className:"library-empty",children:J?"没有匹配的文件。":"这个文件夹还没有文件。"}):W.map(ue=>a.jsxs("button",{className:`file-entry${p===ue.path?" selected":""}`,"aria-current":p===ue.path?"true":void 0,onClick:me=>ue.kind==="directory"?R(ue.path):M(ue.path,!1,me.currentTarget),children:[a.jsx("span",{className:"file-glyph","aria-hidden":"true",children:ue.kind==="directory"?"▱":"▤"}),a.jsx("span",{className:"file-entry-name",children:ue.name}),a.jsx("span",{className:"file-entry-size",children:ue.kind==="directory"?"文件夹":uy(ue.size)})]},ue.path))}),k?.truncated?a.jsx("p",{className:"library-hint",children:"这里只显示前 500 项。可以进入子文件夹继续查看。"}):null]}),p!==null?a.jsxs("article",{ref:I,className:"file-preview","aria-label":`文件预览:${p}`,"aria-busy":w,tabIndex:-1,onKeyDown:ue=>{ue.key==="Escape"&&!ue.nativeEvent.isComposing&&(ue.preventDefault(),ue.stopPropagation(),te())},children:[a.jsxs("header",{children:[a.jsxs("div",{children:[a.jsx("strong",{children:h?.name??p.split("/").at(-1)}),h?a.jsx("span",{children:uy(h.size)}):null]}),a.jsxs("div",{className:"library-actions",children:[h?a.jsx("a",{className:"library-button",href:sd(h.path),download:!0,children:"下载"}):null,a.jsxs("button",{className:"library-button",onClick:te,children:[a.jsx("span",{className:"file-back-label",children:"返回文件列表"}),a.jsx("span",{className:"file-close-label",children:"关闭预览"})]})]})]}),w?a.jsx("p",{className:"library-empty",role:"status",children:"正在读取内容…"}):E?a.jsxs("div",{className:"library-error file-read-error",role:"alert",children:[a.jsxs("strong",{children:["无法预览“",p,"”"]}),a.jsx("p",{children:E}),a.jsx("button",{className:"library-button",onClick:()=>M(p),children:"重新读取文件"})]}):h?.kind==="text"?a.jsxs(a.Fragment,{children:[a.jsx("pre",{tabIndex:0,children:h.content}),h.truncated?a.jsx("p",{className:"library-hint",children:"预览显示前 512 KB,下载可获取完整内容。"}):null]}):h?.kind==="image"?a.jsx("img",{src:sd(h.path,!0),alt:h.name,onError:()=>A("图片无法预览,可以下载后打开。")}):a.jsx("div",{className:"library-empty",children:"这个文件暂不支持直接预览,可以下载后打开。"})]}):null]})]})}function rS(t){const r=i=>{const l=new URLSearchParams;for(const[o,d]of Object.entries(i)){if(["workspacePath","workspaceScopes","storageDir"].includes(o))throw new Error("Model history scope belongs to the Host");d!==void 0&&l.set(o,String(d))}return l.size?`?${l}`:""};return{async list(i={}){return await t.request(`/api/v1/model-traces${r(i)}`)},async sessions(i={}){return await t.request(`/api/v1/model-traces/sessions${r(i)}`)},async get(i){if(!/^[A-Za-z0-9_-]{1,128}$/.test(i))throw new Error("Invalid model trace id");try{return await t.request(`/api/v1/model-traces/${encodeURIComponent(i)}`)}catch(l){if(l?.status===404)return null;throw l}},async getConfig(){return await t.request("/api/v1/model-traces/config")}}}const sv=["execution","task","panel","summary","context","title","goal","memory","suggestion","speech","transcription","audio","external","other"],iS={zh:{execution:["运行 Prompt","会话执行时组装的模型输入"],task:["子任务 Prompt","委派给子任务的模型输入"],panel:["Panel 调用","由 Panel 发起的模型调用"],summary:["摘要 / 压缩 Prompt","生成摘要或压缩会话历史"],context:["上下文整理 Prompt","整理本次执行所需的上下文"],title:["标题生成 Prompt","生成会话或任务标题"],goal:["目标检查 Prompt","检查目标的进展与完成情况"],memory:["记忆整理 Prompt","提取、整理或更新记忆"],suggestion:["后续建议 Prompt","生成会话的后续操作建议"],speech:["语音合成","将文本转换为语音"],transcription:["语音转写","将语音转换为文字"],audio:["音频处理","对音频执行模型推理"],external:["外部 CLI 入口","提交给外部 CLI 的入口输入"],other:["其他调用","调用未提供可识别的类型"]},en:{execution:["Execution Prompt","Model input assembled for a session execution"],task:["Subtask Prompt","Model input for a delegated task"],panel:["Panel call","A model call initiated by a Panel"],summary:["Summary and compaction Prompt","Summarize or compact session history"],context:["Context preparation Prompt","Prepare context for an execution"],title:["Title generation Prompt","Generate a session or task title"],goal:["Goal check Prompt","Check progress toward a goal"],memory:["Memory maintenance Prompt","Extract, organize or update memory"],suggestion:["Follow-up suggestion Prompt","Suggest next steps for a session"],speech:["Speech synthesis","Convert text to speech"],transcription:["Speech transcription","Convert speech to text"],audio:["Audio processing","Run model inference on audio"],external:["External CLI entry","Input submitted to an external CLI"],other:["Other call","The call has no recognized type"]}};function Al(t,r){const i=sv.includes(t)?t:"other",[l,o]=iS[r][i];return{type:i,label:l,description:o}}function sS(t,r,i){if(t==="event")return"event";const l=t==="attempt"?r:void 0;if(l?.coverage==="provider-wire")return"wire";if(l?.coverage==="external-cli-input"||t==="request"&&i.attempts.some(d=>d.coverage==="external-cli-input"))return"external";const o=Al(i.callType,"en").type;return o==="speech"||o==="transcription"||o==="audio"?"media":"logical"}const lS={zh:{title:"执行观测",description:"按类型筛选同一份活动记录,再按会话查看执行、Prompt、响应、重试和工具事件。",refresh:"刷新",search:"搜索模型、用途、来源或编号",session:"会话 ID",model:"模型",purpose:"技术用途标识",filters:"更多筛选",callType:"按类型查看",allTypes:"全部调用",source:"来源入口",technical:"技术信息",all:"全部状态",running:"运行中",completed:"已完成",failed:"失败",cancelled:"已取消",empty:"没有符合条件的会话或独立调用",sessions:"会话与独立调用",sessionRecord:"会话",standalone:"独立调用",standaloneExecutions:"独立调用的执行",execution:"执行",loaded:"已加载调用",select:"选择会话或独立调用,查看其中的执行和模型调用",calls:"会话内的执行",back:"返回",next:"下一页",previous:"上一页",more:"加载更多调用",loading:"读取中…",input:"运行时输入快照",inputHint:"执行时组装的逻辑快照,包含指令、消息历史、工具及参数;实际请求请查看具体尝试。",mediaInput:"模型输入与资源信息",mediaHint:"展示提交给模型的文本、参数及资源元数据;音频等二进制内容不在此展开。",toolInput:"工具输入",eventInput:"事件输入",eventHint:"这是工具或其他事件的输入,不是模型 Prompt。",fullInput:"完整输入 JSON",systemPrompt:"系统指令",messages:"消息历史与本轮输入",tools:"可用工具定义",parameters:"调用参数",message:"消息",userRole:"用户角色消息",assistantRole:"助手历史消息",systemRole:"系统消息",developerRole:"开发者消息",toolRole:"工具结果消息",roleHint:"角色表示消息在模型输入中的位置;用户角色消息也可能由辅助流程生成。",output:"输出",attempts:"重试与请求",events:"工具与生命周期",attempt:"尝试",wire:"实际发出的 Provider 请求",wireHint:"此尝试提交给 Provider 的请求正文,敏感信息已脱敏,超长内容可能截断。",logical:"逻辑输入",externalInput:"外部 CLI 入口输入",external:"外部 CLI 入口输入,未覆盖 CLI 内部的模型请求",missing:"这条调用已过期或不再可用",unrecorded:"正文未采集",truncated:"正文已截断",redacted:"正文已脱敏",contentHint:"仅记录元数据。请在 Host 的执行观测设置中开启 Prompt 正文采集;历史内容不会补回。",disabled:"Host 已关闭调用记录",copy:"复制 JSON",copied:"已复制",copyFailed:"复制失败,请重试",open:"打开原会话",cost:"费用未记录",costEstimate:"估算费用",costPartial:"部分尝试费用未知",tokens:"Token",duration:"耗时",ttft:"首 Token",request:"模型调用"},en:{title:"Execution traces",description:"Filter the same activity history by type, then browse sessions, executions, prompts, responses, retries and tools.",refresh:"Refresh",search:"Search model, purpose, source or ID",session:"Session ID",model:"Model",purpose:"Technical purpose",filters:"More filters",callType:"Browse by type",allTypes:"All calls",source:"Source entry",technical:"Technical information",all:"All statuses",running:"Running",completed:"Completed",failed:"Failed",cancelled:"Cancelled",empty:"No matching sessions or standalone calls",sessions:"Sessions and standalone calls",sessionRecord:"Session",standalone:"Standalone calls",standaloneExecutions:"Standalone executions",execution:"Execution",loaded:"Loaded calls",select:"Choose a session or standalone calls to inspect executions and model calls",calls:"Executions in session",back:"Back",next:"Next page",previous:"Previous page",more:"Load more calls",loading:"Loading…",input:"Runtime input snapshot",inputHint:"A logical snapshot of instructions, message history, tools and parameters. Select an attempt to inspect its outgoing request.",mediaInput:"Model input and resource metadata",mediaHint:"Text, parameters and resource metadata submitted to the model. Binary audio and other media are not expanded here.",toolInput:"Tool input",eventInput:"Event input",eventHint:"This is input for a tool or another event, not a model Prompt.",fullInput:"Full input JSON",systemPrompt:"System instructions",messages:"Message history and current input",tools:"Available tool definitions",parameters:"Call parameters",message:"Message",userRole:"User-role message",assistantRole:"Assistant history message",systemRole:"System message",developerRole:"Developer message",toolRole:"Tool result message",roleHint:"Roles describe a message’s position in model input. User-role messages may also be generated by helper workflows.",output:"Output",attempts:"Attempts and requests",events:"Tools and lifecycle",attempt:"Attempt",wire:"Actual outgoing Provider request",wireHint:"The request body submitted to the Provider for this attempt, with sensitive information redacted and long content possibly truncated.",logical:"Logical input",externalInput:"External CLI entry input",external:"External CLI entry input; internal model requests are not covered",missing:"This call has expired or is unavailable",unrecorded:"Content was not recorded",truncated:"Content was truncated",redacted:"Content was redacted",contentHint:"Only metadata is recorded. Enable Prompt content recording in the Host’s execution trace settings. Earlier content cannot be recovered.",disabled:"The Host disabled call recording",copy:"Copy JSON",copied:"Copied",copyFailed:"Copy failed. Please retry",open:"Open conversation",cost:"Cost not recorded",costEstimate:"Estimated cost",costPartial:"Some attempt costs are unknown",tokens:"Tokens",duration:"Duration",ttft:"First token",request:"Model call"}},aS=`
|
|
22
|
+
.cs-trace-explorer{display:flex;flex-direction:column;min-height:0;min-width:0;flex:1;height:auto;color:inherit;font:inherit;background:inherit;overflow:hidden}
|
|
23
|
+
.cs-trace-explorer *{box-sizing:border-box}.cs-trace-explorer header{padding:16px 20px 12px;border-bottom:1px solid #8884;flex-shrink:0}
|
|
24
|
+
.cs-trace-explorer h1{font-size:20px;margin:0}.cs-trace-explorer h2{font-size:14px;margin:0 0 12px}.cs-trace-explorer h3{font-size:13px;margin:12px 0 6px}
|
|
25
|
+
.cs-trace-explorer p{font-size:13px;line-height:1.6;margin:8px 0;overflow-wrap:anywhere}.cs-trace-explorer button,.cs-trace-explorer input,.cs-trace-explorer select{font:inherit;color:inherit;border:1px solid #8885;border-radius:7px;background:transparent;padding:7px 9px;min-width:0}
|
|
26
|
+
.cs-trace-explorer button{cursor:pointer}.cs-trace-explorer button:hover{background:#8882}.cs-trace-explorer button:disabled{opacity:.5;cursor:default}.cs-trace-explorer button:focus-visible{outline:2px solid #4c91ee;outline-offset:2px}
|
|
27
|
+
.cs-trace-explorer button[aria-pressed=true]{background:#4c91ee22;border-color:#4c91ee}.cs-trace-explorer .cs-t-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
|
|
28
|
+
.cs-trace-explorer .cs-t-filters{display:grid;grid-template-columns:1fr 1fr 1fr 1fr;gap:8px;margin-top:12px}.cs-trace-explorer .cs-t-filters label{font-size:12px;display:flex;flex-direction:column;gap:4px;min-width:0}
|
|
29
|
+
.cs-trace-explorer .cs-t-search{display:flex;gap:6px;flex-direction:column;margin-top:10px;font-size:12px}.cs-trace-explorer .cs-t-filter-fold{margin:8px 0 0}.cs-trace-explorer .cs-t-grid{min-height:0;flex:1;display:grid;grid-template-columns:minmax(180px,1fr) minmax(190px,1fr) minmax(300px,2fr)}
|
|
30
|
+
.cs-trace-explorer .cs-t-pane{overflow:auto;min-width:0;padding:16px;border-right:1px solid #8884}.cs-trace-explorer .cs-t-item{display:block;width:100%;text-align:left;margin-bottom:8px;overflow-wrap:anywhere;word-break:break-word;font-size:12px}
|
|
31
|
+
.cs-trace-explorer .cs-t-item strong{display:block;font-size:13px;margin-bottom:5px}.cs-trace-explorer .cs-t-muted{opacity:.7;font-size:12px}.cs-trace-explorer .cs-t-error{color:#c95252;white-space:pre-wrap}
|
|
32
|
+
.cs-trace-explorer .cs-t-type{display:inline-block;border:1px solid #8884;border-radius:5px;padding:2px 6px;font-size:12px;line-height:1.5;background:#8881}.cs-trace-explorer .cs-t-type-filter-field{display:flex;flex-direction:column;gap:4px;min-width:0;font-size:12px;margin-top:10px}.cs-trace-explorer .cs-t-type-filters{display:flex;gap:6px;overflow-x:auto;padding:3px;scroll-padding:3px;max-width:100%;overscroll-behavior-x:contain}.cs-trace-explorer .cs-t-type-filters button{flex:0 0 auto;white-space:nowrap;font-size:12px;padding:6px 9px;border-radius:16px}.cs-trace-explorer .cs-t-type-filters button[aria-pressed=true]{font-weight:600;background:#4c91ee33;border-color:#4c91ee}.cs-trace-explorer .cs-t-primary-filters{display:flex;flex-direction:column;min-width:0}.cs-trace-explorer .cs-t-message{margin:12px 0}
|
|
33
|
+
.cs-trace-explorer pre{font:12px/1.6 ui-monospace,monospace;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word;max-height:65vh;overflow:auto;padding:12px;border:1px solid #8884;border-radius:8px;background:#8881}
|
|
34
|
+
.cs-trace-explorer details{margin:12px 0}.cs-trace-explorer summary{cursor:pointer;font-size:13px}.cs-trace-explorer .cs-t-back{display:none}.cs-trace-explorer dl{display:grid;grid-template-columns:auto 1fr;gap:6px 12px;font-size:12px;margin:12px 0}.cs-trace-explorer dd{margin:0;overflow-wrap:anywhere}.cs-trace-explorer footer{display:flex;gap:8px;align-items:center;justify-content:space-between;padding-top:12px}
|
|
35
|
+
@media(max-width:1000px){.cs-trace-explorer .cs-t-filters{grid-template-columns:1fr 1fr}.cs-trace-explorer .cs-t-grid{display:flex}.cs-trace-explorer .cs-t-pane{width:100%;border:0;display:none}.cs-trace-explorer .cs-t-pane[data-active=true]{display:block}.cs-trace-explorer .cs-t-back{display:inline-block;margin-bottom:12px}.cs-trace-explorer header{padding:10px;max-height:50%;overflow:auto}.cs-trace-explorer header>p{display:none}.cs-trace-explorer pre{max-height:none}}
|
|
36
|
+
`,wl=t=>t instanceof Error?t.message:String(t),ao=(t,r)=>t!==void 0&&r!==void 0?`${Math.max(0,r-t).toLocaleString()} ms`:"—";function oS({api:t,lang:r="zh",initialSessionId:i,sessionTitles:l,onOpenSession:o}){const d=lS[r],[c,h]=Ze.useState(""),[f,p]=Ze.useState(""),[y,b]=Ze.useState(""),[v,w]=Ze.useState(""),[j,N]=Ze.useState(i??""),[C,E]=Ze.useState(""),[A,D]=Ze.useState([void 0]),[L,J]=Ze.useState(0),[T,B]=Ze.useState(),[U,X]=Ze.useState(),[_,I]=Ze.useState(),[H,Y]=Ze.useState(),[$,F]=Ze.useState(""),[P,G]=Ze.useState(),[re,be]=Ze.useState(),[R,M]=Ze.useState({kind:"request"}),[te,k]=Ze.useState("list"),[W,ue]=Ze.useState(0),[me,Q]=Ze.useState(!1),[oe,fe]=Ze.useState(!1),[ke,_e]=Ze.useState(""),[Me,Ce]=Ze.useState(""),[qe,Ge]=Ze.useState(""),[lt,De]=Ze.useState(""),Oe=Ze.useRef(0),ht=Ze.useRef(null),at=Ze.useRef(null),[dt,Ke]=Ze.useState(!1),rt=`${c}\0${f}\0${y}\0${v}\0${j}\0${C}`;Ze.useEffect(()=>{D([void 0]),J(0),B(void 0),X(void 0),I(void 0),Y(void 0),G(void 0),be(void 0),Ce(""),F(""),k("list")},[t,rt]),Ze.useEffect(()=>{let ie=!0;Q(!0),_e("");const O=setTimeout(()=>{t.sessions({limit:50,cursor:A[L],search:c||void 0,model:f||void 0,purpose:y||void 0,callType:v||void 0,sessionId:j||void 0,status:C||void 0}).then(le=>{ie&&B(le)}).catch(le=>{ie&&_e(wl(le))}).finally(()=>{ie&&Q(!1)})},180);return()=>{ie=!1,clearTimeout(O)}},[t,rt,A,L,W]),Ze.useEffect(()=>{let ie=!0;return t.getConfig().then(O=>{ie&&Ge(O.enabled?O.captureContent?"":d.contentHint:d.disabled)}).catch(O=>{ie&&Ge(wl(O))}),()=>{ie=!1}},[t,W,d]);const Ve=()=>({search:c||void 0,model:f||void 0,purpose:y||void 0,callType:v||void 0,status:C||void 0,...U?.sessionId?{sessionId:U.sessionId}:{traceId:U?.traceId,withoutSession:!0}});Ze.useEffect(()=>{const ie=++Oe.current;if(!U)return;const O=U.key;return Ke(!1),F(""),Y(void 0),t.list({...Ve(),limit:200}).then(le=>{ie===Oe.current&&Y({...le,scopeKey:O})}).catch(le=>{ie===Oe.current&&F(wl(le))}),()=>{Oe.current++}},[t,U?.key,rt,W]),Ze.useEffect(()=>{let ie=!0;if(P)return fe(!0),Ce(""),be(O=>O?.record.id===P?O:void 0),t.get(P).then(O=>{ie&&be(O)}).catch(O=>{ie&&Ce(wl(O))}).finally(()=>{ie&&fe(!1)}),()=>{ie=!1}},[t,P,W]);const nt=Ze.useMemo(()=>{const ie=new Map;for(const O of H?.items??[])ie.set(O.traceId,[...ie.get(O.traceId)??[],O]);return[...ie]},[H]),q=re&&re.record.id===P&&re.record.traceId===_&&U&&(U.sessionId?re.record.sessionId===U.sessionId:re.record.traceId===U.traceId&&!re.record.sessionId)?re:void 0,ne=q?.record,Ee=U&&!U.sessionId?d.standaloneExecutions:d.calls,xe=R.kind==="attempt"?ne?.attempts.find(ie=>ie.id===R.id):R.kind==="event"?q?.events.find(ie=>ie.id===R.id):ne,ze=async()=>{try{await navigator.clipboard.writeText(JSON.stringify(xe,null,2)),De(d.copied)}catch{De(d.copyFailed)}},Le=ie=>{G(ie.id),I(ie.traceId),M({kind:"request"}),k("detail"),De("")},se=async()=>{if(!H?.nextCursor||dt||!U)return;const ie=U.key,O=Oe.current;Ke(!0);try{const le=await t.list({...Ve(),cursor:H.nextCursor,limit:200});O===Oe.current&&Y(we=>({...le,scopeKey:ie,items:[...we?.scopeKey===ie?we.items:[],...le.items]}))}catch(le){O===Oe.current&&F(wl(le))}finally{O===Oe.current&&Ke(!1)}},Re=(ie,O)=>a.jsxs(a.Fragment,{children:[O!=="recorded"&&a.jsx("p",{className:"cs-t-muted",children:O==="not-recorded"?d.unrecorded:O==="truncated"?d.truncated:d.redacted}),ie!==void 0&&a.jsx("pre",{tabIndex:0,children:typeof ie=="string"?ie:JSON.stringify(ie,null,2)})]}),Ne=ie=>{const O=Al(ie,r);return a.jsx("span",{className:"cs-t-type","data-trace-call-type":O.type,title:O.description,children:O.label})},Qe=xe&&ne?sS(R.kind,xe,ne):void 0,Ue=Qe==="wire"?d.wire:Qe==="external"?d.externalInput:Qe==="media"?d.mediaInput:Qe==="event"?xe?.kind==="tool"?d.toolInput:d.eventInput:d.input,bt=Qe==="wire"?d.wireHint:Qe==="external"?d.external:Qe==="media"?d.mediaHint:Qe==="event"?d.eventHint:d.inputHint,pt=Qe==="logical"&&xe?.input&&typeof xe.input=="object"?xe.input:void 0,Be=ie=>{const O=ie&&typeof ie=="object"&&"role"in ie?ie.role:void 0;return O==="user"?d.userRole:O==="assistant"?d.assistantRole:O==="system"?d.systemRole:O==="developer"?d.developerRole:O==="tool"?d.toolRole:typeof O=="string"?`${d.message} · ${O}`:d.message};return a.jsxs("section",{className:"cs-trace-explorer","aria-label":d.title,children:[a.jsx("style",{children:aS}),a.jsxs("header",{children:[a.jsxs("div",{className:"cs-t-row",children:[a.jsx("h1",{children:d.title}),a.jsx("button",{type:"button",disabled:me,onClick:()=>ue(ie=>ie+1),children:d.refresh})]}),a.jsx("p",{className:"cs-t-muted",children:d.description}),a.jsxs("div",{className:"cs-t-primary-filters",children:[a.jsxs("div",{className:"cs-t-type-filter-field",children:[a.jsx("span",{className:"cs-t-muted",children:d.callType}),a.jsxs("div",{className:"cs-t-type-filters",role:"group","aria-label":d.callType,children:[a.jsx("button",{type:"button","data-trace-type-filter":"","aria-pressed":v==="",onClick:()=>w(""),children:d.allTypes}),sv.map(ie=>{const O=Al(ie,r);return a.jsx("button",{type:"button","data-trace-type-filter":ie,"aria-pressed":v===ie,title:O.description,onClick:()=>w(ie),children:O.label},ie)})]})]}),a.jsxs("label",{className:"cs-t-search",children:[a.jsx("span",{className:"cs-t-muted",children:d.search}),a.jsx("input",{"aria-label":d.search,type:"search",value:c,onChange:ie=>h(ie.target.value)})]})]}),a.jsxs("details",{className:"cs-t-filter-fold",children:[a.jsx("summary",{children:d.filters}),a.jsxs("div",{className:"cs-t-filters",children:[a.jsxs("label",{children:[d.session,a.jsx("input",{value:j,onChange:ie=>N(ie.target.value)})]}),a.jsxs("label",{children:[d.model,a.jsx("input",{value:f,onChange:ie=>p(ie.target.value)})]}),a.jsxs("label",{children:[d.purpose,a.jsx("input",{value:y,onChange:ie=>b(ie.target.value)})]}),a.jsxs("label",{children:[d.all,a.jsxs("select",{value:C,onChange:ie=>E(ie.target.value),children:[a.jsx("option",{value:"",children:d.all}),["running","completed","failed","cancelled"].map(ie=>a.jsx("option",{value:ie,children:d[ie]},ie))]})]})]})]}),qe&&a.jsx("p",{role:"status",className:"cs-t-muted",children:qe}),ke&&a.jsx("p",{role:"alert",className:"cs-t-error",children:ke})]}),a.jsxs("div",{className:"cs-t-grid",children:[a.jsxs("div",{className:"cs-t-pane","data-active":te==="list","aria-label":d.sessions,children:[a.jsxs("h2",{ref:ht,tabIndex:-1,children:[d.sessions," · ",T?.total??"—"]}),me&&a.jsx("p",{role:"status",children:d.loading}),!me&&!T?.items.length&&a.jsx("p",{children:d.empty}),T?.items.map(ie=>a.jsxs("button",{type:"button",className:"cs-t-item","data-trace-session":ie.key,"aria-pressed":U?.key===ie.key,onClick:()=>{if(U?.key===ie.key){k("tree");return}Oe.current++,Ke(!1),Y(void 0),F(""),be(void 0),Ce(""),De(""),X(ie),I(ie.latestTraceId),G(ie.latestRequestId),M({kind:"request"}),k("tree")},children:[a.jsxs("strong",{children:[ie.sessionId?l?.[ie.sessionId]||d.sessionRecord:d.standalone," · ",ie.callCount," ",d.request]}),a.jsx("span",{className:"cs-t-muted",children:ie.sessionId??ie.traceId}),a.jsx("div",{className:"cs-t-row","data-trace-session-call-types":ie.key,children:(ie.callTypes?.length?ie.callTypes:["other"]).map(O=>a.jsx(x.Fragment,{children:Ne(O)},O))}),a.jsxs("p",{className:"cs-t-muted",children:[new Date(ie.updatedAt).toLocaleString(r)," · ",ie.traceCount," ",d.execution]}),a.jsxs("span",{children:[ie.sources.join(" · ")," · ",ie.models.join(" · ")]})]},ie.key)),a.jsxs("footer",{children:[a.jsx("button",{type:"button",disabled:L===0||me,onClick:()=>J(ie=>ie-1),children:d.previous}),a.jsx("span",{children:L+1}),a.jsx("button",{type:"button",disabled:!T?.nextCursor||me,onClick:()=>{D(ie=>[...ie.slice(0,L+1),T?.nextCursor]),J(ie=>ie+1)},children:d.next})]})]}),a.jsxs("div",{className:"cs-t-pane","data-active":te==="tree","aria-label":Ee,children:[a.jsx("button",{type:"button",className:"cs-t-back",onClick:()=>{k("list"),requestAnimationFrame(()=>ht.current?.focus())},children:d.back}),a.jsx("h2",{ref:at,tabIndex:-1,children:Ee}),U?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"cs-t-muted",children:U.sessionId??U.traceId}),$&&a.jsxs("div",{role:"alert",children:[a.jsx("p",{className:"cs-t-error",children:$}),a.jsx("button",{type:"button",onClick:()=>ue(ie=>ie+1),children:d.refresh})]}),!H&&!$&&a.jsx("p",{role:"status",children:d.loading}),H&&a.jsxs("p",{className:"cs-t-muted",children:[d.loaded,": ",H.items.length," / ",H.total]}),nt.map(([ie,O])=>a.jsxs("details",{open:!0,"data-trace-group":ie,children:[a.jsxs("summary",{children:[d.execution," · ",new Date(O[0].startedAt).toLocaleString(r)]}),a.jsx("p",{className:"cs-t-muted",children:ie}),O.map(le=>a.jsxs("div",{children:[a.jsxs("button",{type:"button",className:"cs-t-item","data-trace-request":le.id,"aria-pressed":P===le.id&&R.kind==="request",onClick:()=>Le(le),children:[a.jsx("strong",{children:le.model}),Ne(le.callType),a.jsx("p",{className:"cs-t-muted",children:Al(le.callType,r).description}),d.source,": ",le.source," · ",d[le.status]," ·"," ",ao(le.startedAt,le.endedAt)]}),ne?.id===le.id&&ne.attempts.map(we=>a.jsxs("button",{type:"button",className:"cs-t-item","aria-pressed":R.kind==="attempt"&&R.id===we.id,onClick:()=>{M({kind:"attempt",id:we.id}),k("detail")},children:[d.attempt," ",we.number," · ",we.httpStatus??"—"," ·"," ",d[we.status]]},we.id))]},le.id))]},ie)),H?.nextCursor&&a.jsx("button",{type:"button",disabled:dt,onClick:()=>{se()},children:d.more}),a.jsx("h3",{children:d.events}),q?.events.filter(ie=>ie.traceId===_).map(ie=>a.jsxs("button",{type:"button",className:"cs-t-item","aria-pressed":R.kind==="event"&&R.id===ie.id,onClick:()=>{M({kind:"event",id:ie.id}),k("detail")},children:[ie.kind," · ",ie.name," · ",ie.status]},ie.id))]}):a.jsx("p",{children:d.select})]}),a.jsxs("div",{className:"cs-t-pane","data-active":te==="detail","aria-label":d.request,children:[a.jsx("button",{type:"button",className:"cs-t-back",onClick:()=>{k("tree"),requestAnimationFrame(()=>at.current?.focus())},children:d.back}),Me&&a.jsx("p",{role:"alert",className:"cs-t-error",children:Me}),oe&&a.jsx("p",{role:"status",children:d.loading}),re===null&&a.jsx("p",{children:d.missing}),xe?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"cs-t-row",children:[a.jsx("h2",{children:R.kind==="event"?xe.name:ne?.model}),a.jsx("button",{type:"button",onClick:()=>{ze()},children:d.copy}),ne?.sessionId&&o&&a.jsx("button",{type:"button",onClick:()=>o(ne.sessionId),children:d.open})]}),lt&&a.jsx("p",{role:"status",children:lt}),ne&&R.kind!=="event"&&a.jsxs(a.Fragment,{children:[Ne(ne.callType),a.jsx("p",{className:"cs-t-muted",children:Al(ne.callType,r).description}),a.jsxs("p",{className:"cs-t-muted",children:[d.source,": ",ne.source]}),a.jsxs("details",{children:[a.jsx("summary",{children:d.technical}),a.jsxs("dl",{children:[a.jsx("dt",{children:d.purpose}),a.jsx("dd",{children:ne.purpose}),a.jsx("dt",{children:d.session}),a.jsx("dd",{children:ne.sessionId??"—"}),a.jsx("dt",{children:d.execution}),a.jsx("dd",{children:ne.runId??ne.traceId})]})]})]}),a.jsxs("dl",{children:[a.jsx("dt",{children:"ID"}),a.jsx("dd",{children:xe.id}),a.jsx("dt",{children:d.duration}),a.jsx("dd",{children:ao(xe.startedAt,xe.endedAt)}),a.jsx("dt",{children:d.ttft}),a.jsx("dd",{children:"firstTokenAt"in xe?ao(xe.startedAt,xe.firstTokenAt):"—"}),a.jsx("dt",{children:d.tokens}),a.jsx("dd",{children:"usage"in xe&&xe.usage?`${xe.usage.promptTokens} / ${xe.usage.completionTokens}`:"—"})]}),a.jsx("p",{className:"cs-t-muted",children:"estimatedCostUsd"in xe&&typeof xe.estimatedCostUsd=="number"?`${d.costEstimate}: $${xe.estimatedCostUsd.toFixed(6)}${"unknownCostAttempts"in xe&&xe.unknownCostAttempts?` · ${d.costPartial}`:""}`:d.cost}),xe.error&&a.jsx("p",{className:"cs-t-error",children:xe.error}),a.jsxs("details",{open:!0,children:[a.jsx("summary",{children:Ue}),a.jsx("p",{className:"cs-t-muted",children:bt}),pt?a.jsxs(a.Fragment,{children:[Re(void 0,xe.inputState),pt.systemPrompt!==void 0&&a.jsxs(a.Fragment,{children:[a.jsx("h3",{children:d.systemPrompt}),Re(pt.systemPrompt,"recorded")]}),Array.isArray(pt.messages)&&a.jsxs(a.Fragment,{children:[a.jsx("h3",{children:d.messages}),a.jsx("p",{className:"cs-t-muted",children:d.roleHint}),pt.messages.map((ie,O)=>a.jsxs("div",{className:"cs-t-message",children:[a.jsxs("h3",{children:[O+1,". ",Be(ie)]}),Re(ie,"recorded")]},O))]}),pt.tools!==void 0&&a.jsxs("details",{children:[a.jsx("summary",{children:d.tools}),Re(pt.tools,"recorded")]}),pt.parameters!==void 0&&a.jsxs("details",{children:[a.jsx("summary",{children:d.parameters}),Re(pt.parameters,"recorded")]}),a.jsxs("details",{children:[a.jsx("summary",{children:d.fullInput}),Re(xe.input,"recorded")]})]}):Re(xe.input,xe.inputState)]},`${xe.id}:input`),a.jsxs("details",{open:!0,children:[a.jsx("summary",{children:d.output}),Re(xe.output,xe.outputState)]},`${xe.id}:output`),R.kind==="request"&&ne&&a.jsxs("details",{children:[a.jsxs("summary",{children:[d.attempts," (",ne.attempts.length,")"]}),ne.attempts.map(ie=>a.jsxs("button",{type:"button",className:"cs-t-item",onClick:()=>M({kind:"attempt",id:ie.id}),children:[d.attempt," ",ie.number," · ",ie.status," ·"," ",ao(ie.startedAt,ie.endedAt)]},ie.id))]})]}):!oe&&a.jsx("p",{children:d.select})]})]})]})}function uS({onAuthLost:t,onOpenSession:r,sessionTitles:i}){const l=Ze.useMemo(()=>{const o=Cs();return rS({request:async(d,c)=>{try{return await Je(d,c,o)}catch(h){throw h instanceof it&&h.status===401&&t(),h}}})},[t]);return a.jsx(oS,{api:l,sessionTitles:i,onOpenSession:r})}function lv(){const t=x.useRef(!1),r=x.useRef(null);x.useLayoutEffect(()=>{t.current=!0;const h=p=>{const y=p instanceof FocusEvent&&p.type==="focusout"?p.relatedTarget:p.target;!(y instanceof Node)||y===document.body&&p.type!=="pointerdown"||r.current&&!r.current.source.contains(y)&&(r.current.cancelled=!0)},f=()=>{r.current&&(r.current.cancelled=!0)};return document.addEventListener("pointerdown",h,!0),document.addEventListener("focusin",h,!0),document.addEventListener("focusout",h,!0),window.addEventListener("blur",f),()=>{t.current=!1,r.current=null,document.removeEventListener("pointerdown",h,!0),document.removeEventListener("focusin",h,!0),document.removeEventListener("focusout",h,!0),window.removeEventListener("blur",f)}},[]);const i=x.useCallback((h=document.activeElement)=>{r.current&&(r.current.cancelled=!0);const f=h instanceof HTMLElement&&h!==document.body?{source:h,cancelled:!1}:null;return r.current=f,f},[]),l=x.useCallback(h=>!!h&&t.current&&r.current===h,[]),o=x.useCallback(h=>{if(!h||!t.current||r.current!==h)return null;r.current=null;const f=document.activeElement;return h.cancelled||f&&f!==document.body&&f!==h.source&&f.isConnected?null:h},[]),d=x.useCallback(h=>(r.current&&(r.current.cancelled=!0),r.current=h&&t.current&&!h.cancelled?h:null,r.current),[]),c=x.useCallback((h,f)=>{o(h)&&f?.isConnected&&!f.matches(":disabled")&&f.focus()},[o]);return{capture:i,finish:c,isCurrent:l,take:o,adopt:d}}async function lf(t={}){const r=new URLSearchParams({archived:t.archived??"false",limit:"50"});return t.query&&r.set("query",t.query),t.cursor&&r.set("cursor",t.cursor),Je(`/api/v1/sessions?${r}`,{signal:t.signal})}function cy(t,r="markdown"){return Dt(`/api/v1/sessions/${encodeURIComponent(t)}/export?format=${r}`)}function cS({onAuthLost:t,onOpen:r,onChanged:i,version:l=0,onDirtyChange:o}){const[d,c]=x.useState(""),[h,f]=x.useState(""),[p,y]=x.useState("false"),[b,v]=x.useState([]),[w,j]=x.useState(null),[N,C]=x.useState(!0),[E,A]=x.useState(!1),[D,L]=x.useState(""),[J,T]=x.useState(!1),[B,U]=x.useState(null),[X,_]=x.useState(""),[I,H]=x.useState(0),[Y,$]=x.useState(""),[F,P]=x.useState(null),G=x.useRef(0),[re,be]=x.useState(null),R=x.useRef(null),M=x.useRef(null),te=x.useRef(null),k=x.useRef(null),W=x.useRef(new Map),ue=x.useRef(null),me=x.useRef(null),Q=x.useRef(null),oe=x.useRef(null),fe=x.useRef(new Map),ke=x.useRef(""),_e=x.useRef("");ke.current=JSON.stringify([d,p,l]),_e.current=JSON.stringify([d,p]);const Me=lv();x.useLayoutEffect(()=>{const q=M.current;if(!q)return;let ne=!0;const Ee=()=>{const ze=document.activeElement;if(!ne||!(ze instanceof HTMLElement)||!q.contains(ze))return;const Le=q.getBoundingClientRect(),se=Le.top+q.clientTop+4,Re=Le.top+q.clientTop+q.clientHeight-4,Ne=ze.getBoundingClientRect();Ne.height<=Re-se?Ne.top<se?q.scrollTop-=Math.ceil(se-Ne.top):Ne.bottom>Re&&(q.scrollTop+=Math.ceil(Ne.bottom-Re)):(Ne.bottom<se||Ne.top>Re)&&(q.scrollTop+=Math.floor(Ne.top-se))},xe=new ResizeObserver(Ee);xe.observe(q);for(const ze of q.children)xe.observe(ze);return q.addEventListener("focusin",Ee),window.addEventListener("resize",Ee),Ee(),()=>{ne=!1,xe.disconnect(),q.removeEventListener("focusin",Ee),window.removeEventListener("resize",Ee)}},[B,F?.id,D,b,N,E]);const[Ce,qe]=x.useState(null),Ge=(q,ne,Ee)=>{Me.isCurrent(q)&&qe({request:q,kind:ne,id:Ee})};x.useLayoutEffect(()=>{if(!Ce||Y||N||E||Ce.kind==="return"&&F)return;qe(null);const q=F?.id===Ce.id,ne=Ce.kind==="edit"||Ce.kind==="input"?q?R.current:null:Ce.kind==="error"?q?te.current:null:Ce.kind==="read"?Q.current:Ce.kind==="more"?fe.current.get(Ce.id)??oe.current??ue.current:Ce.kind==="action"?B?.id===Ce.id?me.current:null:W.current.get(Ce.id)??(k.current?.isConnected&&!k.current.disabled?k.current:ue.current);Me.finish(Ce.request,ne)},[B,Y,F,Me,Ce,N,E]);const lt=q=>{P(null),Ge(q,"return",F?.id??"")};x.useEffect(()=>{o?.(!!F||!!Y)},[F,Y,o]),x.useEffect(()=>()=>o?.(!1),[o]);const De=x.useRef(null),Oe=x.useRef(null),ht=x.useRef({onAuthLost:t,onChanged:i,onOpen:r});ht.current={onAuthLost:t,onChanged:i,onOpen:r},x.useEffect(()=>{if(!re||Y||N||E)return;const q=requestAnimationFrame(()=>{if(be(null),G.current!==re.generation||_e.current!==re.identity)return;const ne=Me.take(re.request);ne&&ht.current.onOpen(re.id,ne)});return()=>cancelAnimationFrame(q)},[Y,N,E,re,Me.take]);const at=x.useCallback(q=>{q instanceof it&&q.status===401?ht.current.onAuthLost():L(q instanceof Error?q.message:"会话操作失败,请重试。")},[]);x.useEffect(()=>{const q=setTimeout(()=>f(d.trim()),200);return()=>clearTimeout(q)},[d]),x.useEffect(()=>{De.current?.abort();const q=new AbortController;return De.current=q,C(!0),A(!1),T(!1),L(""),lf({query:h,archived:p,signal:q.signal}).then(ne=>{q.signal.aborted||(v(ne.sessions),j(ne.nextCursor))}).catch(ne=>{q.signal.aborted||(T(!0),at(ne))}).finally(()=>{q.signal.aborted||C(!1)}),()=>q.abort()},[h,p,l,I,at]),x.useEffect(()=>()=>{De.current?.abort(),Oe.current?.abort()},[]);const dt=q=>{if(!w||E||N)return;const ne=Me.capture(q),Ee=ke.current,xe=new Set(b.map(Le=>Le.sessionId));L("");const ze=new AbortController;De.current?.abort(),De.current=ze,A(!0),lf({query:h,archived:p,cursor:w,signal:ze.signal}).then(Le=>{ze.signal.aborted||(v(se=>{const Re=new Set(se.map(Ne=>Ne.sessionId));return[...se,...Le.sessions.filter(Ne=>!Re.has(Ne.sessionId))]}),j(Le.nextCursor),Me.isCurrent(ne)&&ke.current===Ee&&qe({request:ne,kind:"more",id:Le.sessions.find(se=>!xe.has(se.sessionId))?.sessionId??""}))}).catch(Le=>{ze.signal.aborted||(at(Le),!(Le instanceof it&&Le.status===401)&&Me.isCurrent(ne)&&ke.current===Ee&&qe({request:ne,kind:"read",id:""}))}).finally(()=>{ze.signal.aborted||A(!1)})},Ke=async(q,ne,Ee=!1,xe=document.activeElement)=>{if(Oe.current)return;const ze=Me.capture(xe),Le=_e.current,se=G.current,Re=new AbortController;Oe.current=Re,$(q),L(""),_(""),U(null),"title"in ne&&P(Ne=>Ne&&{...Ne,error:""});try{if(await Je(`/api/v1/sessions/${encodeURIComponent(q)}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(ne),signal:Re.signal}),Re.signal.aborted)return;"title"in ne?(lt(ze),_(ne.title?"标题已保存。":"已恢复自动标题。")):(U({id:q,kind:"success",message:ne.archived?"对话已归档,可以在“已归档”中恢复。":"对话已恢复。"}),Ee||Ge(ze,"action",q)),C(!0),H(Ne=>Ne+1),ht.current.onChanged?.(),Ee&&be({id:q,request:ze,generation:se,identity:Le})}catch(Ne){Re.signal.aborted||("title"in ne&&!(Ne instanceof it&&Ne.status===401)?(P(Qe=>Qe?.id===q?{...Qe,error:Ne instanceof Error?Ne.message:"标题保存失败,请重试。",conflict:Ne instanceof it&&Ne.status===409,unavailable:Ne instanceof it&&Ne.status===404}:Qe),Ge(ze,"error",q)):Ne instanceof it&&Ne.status===401?at(Ne):(U({id:q,kind:"error",message:Ne instanceof Error?Ne.message:"会话操作失败,请重试。"}),Ge(ze,"action",q)))}finally{Oe.current===Re&&(Oe.current=null),Re.signal.aborted||$("")}},rt=async q=>{if(!F||Oe.current)return;const ne=F.id,Ee=Me.capture(q),xe=new AbortController;Oe.current=xe,$(ne),P(ze=>ze&&{...ze,error:""});try{const ze=await Je(`/api/v1/sessions/${encodeURIComponent(ne)}`,{signal:xe.signal});if(xe.signal.aborted)return;P(Le=>Le?.id===ne?{...Le,expectedTitle:ze.customTitle,reviewedTitle:ze.title,conflict:!1,unavailable:!1,error:""}:Le),Ge(Ee,"input",ne)}catch(ze){xe.signal.aborted||(ze instanceof it&&ze.status===401?at(ze):P(Le=>Le?.id===ne?{...Le,error:ze instanceof Error?ze.message:"无法读取最新标题,请重试。",unavailable:ze instanceof it&&ze.status===404}:Le),ze instanceof it&&ze.status===401||Ge(Ee,"error",ne))}finally{Oe.current===xe&&(Oe.current=null),xe.signal.aborted||$("")}},Ve=(q,ne)=>{if(G.current+=1,be(null),q.archivedAt)Ke(q.sessionId,{archived:!1},!0,ne);else{const Ee=document.activeElement===ne?Me.capture(ne):null;ht.current.onOpen(q.sessionId,Me.take(Ee))}},nt=B?a.jsx("div",{ref:me,className:`library-${B.kind==="error"?"error":"hint"} session-operation-receipt`,role:B.kind==="error"?"alert":"status",tabIndex:0,"aria-label":"会话操作结果",children:B.message}):null;return a.jsxs("section",{ref:M,className:"hub-library hub-sessions","aria-labelledby":"hub-history-heading",children:[a.jsxs("header",{className:"library-heading",children:[a.jsxs("div",{children:[a.jsx("h1",{id:"hub-history-heading",children:"历史对话"}),a.jsx("p",{children:"查找、整理并导出当前工作区的对话。"})]}),a.jsx("button",{className:"library-button",onClick:()=>H(q=>q+1),children:"刷新"})]}),D?a.jsx("div",{ref:Q,className:"library-error session-read-error",role:"alert",tabIndex:0,"aria-label":"对话读取失败",children:D}):null,!N&&B&&!b.some(q=>q.sessionId===B.id)?nt:null,X?a.jsx("p",{className:"library-hint",role:"status",children:X}):null,a.jsxs("div",{className:"session-toolbar",children:[a.jsxs("label",{className:"library-search",children:[a.jsx("span",{className:"sr-only",children:"搜索对话标题"}),a.jsx("input",{ref:ue,type:"search",placeholder:"搜索对话标题…",value:d,onChange:q=>c(q.target.value)})]}),a.jsxs("label",{children:[a.jsx("span",{className:"sr-only",children:"对话范围"}),a.jsxs("select",{value:p,onChange:q=>y(q.target.value),children:[a.jsx("option",{value:"false",children:"当前对话"}),a.jsx("option",{value:"true",children:"已归档"}),a.jsx("option",{value:"all",children:"全部对话"})]})]})]}),F?a.jsxs("form",{className:"session-history-editor","aria-labelledby":"session-title-editor-heading",onSubmit:q=>{q.preventDefault(),!Y&&!F.conflict&&!F.unavailable&&Ke(F.id,{title:F.title,expectedTitle:F.expectedTitle},!1,q.nativeEvent.submitter??document.activeElement)},children:[a.jsxs("div",{children:[a.jsx("h2",{id:"session-title-editor-heading",children:"重命名对话"}),a.jsxs("p",{className:"library-hint",children:["正在编辑:",F.originalTitle]}),!N&&!b.some(q=>q.sessionId===F.id)?a.jsx("p",{className:"library-hint",children:"此对话已不在当前列表中,标题草稿仍保留在这里。"}):null]}),F.error?a.jsx("div",{className:"library-error",id:"session-title-error",role:"alert",tabIndex:0,"aria-label":"标题保存失败",ref:te,children:F.error}):null,F.reviewedTitle?a.jsxs("p",{className:"session-title-review",role:"status",children:["最新标题:",a.jsx("strong",{children:F.reviewedTitle}),"。你的草稿仍保留,请核对后再保存。"]}):null,a.jsxs("label",{children:[a.jsx("span",{children:"对话标题"}),a.jsx("input",{ref:R,className:"library-title-input",value:F.title,maxLength:1024,"aria-describedby":F.error?"session-title-error":void 0,onChange:q=>{const ne=q.target.value;P(Ee=>Ee&&{...Ee,title:ne})},readOnly:!!Y})]}),a.jsxs("div",{className:"library-actions",children:[a.jsx("button",{type:"submit",className:"library-button primary",disabled:!!Y||F.conflict||F.unavailable,children:Y?"处理中…":F.reviewedTitle?"确认保存我的标题":"保存标题"}),F.conflict||F.unavailable?a.jsx("button",{type:"button",className:"library-button",disabled:!!Y,onClick:q=>{rt(q.currentTarget)},children:"读取最新标题"}):null,a.jsx("button",{type:"button",className:"library-button",disabled:!!Y,onClick:q=>lt(Me.capture(q.currentTarget)),children:"取消"}),F.expectedTitle?a.jsx("button",{type:"button",className:"library-button",disabled:!!Y||F.conflict||F.unavailable,onClick:q=>{Ke(F.id,{title:"",expectedTitle:F.expectedTitle},!1,q.currentTarget)},children:"使用自动标题"}):null]})]}):null,a.jsx("div",{className:"session-history-list","aria-busy":N,children:N?a.jsx("p",{className:"library-empty",role:"status",children:"正在读取对话…"}):b.length===0?a.jsx("p",{className:"library-empty",children:J?"未能读取对话,请使用刷新重试。":h?"没有找到匹配的对话。":p==="true"?"还没有归档的对话。":"还没有保存的对话,开始一条新对话后会显示在这里。"}):b.map(q=>a.jsxs("article",{className:`session-history-row${B?.id===q.sessionId?" has-feedback":""}`,children:[a.jsxs("div",{className:"session-history-info",children:[a.jsx("button",{ref:ne=>{ne?fe.current.set(q.sessionId,ne):fe.current.delete(q.sessionId)},className:"session-history-title",onClick:ne=>Ve(q,ne.currentTarget),children:q.title}),q.preview&&q.preview!==q.title?a.jsx("p",{children:q.preview.slice(0,150)}):null,a.jsxs("div",{className:"session-history-meta",children:[a.jsx("span",{children:new Date(q.lastActiveAt||q.startedAt).toLocaleString()}),a.jsxs("span",{children:[q.turnCount," 轮"]}),q.running?a.jsx("span",{children:"正在运行"}):q.archivedAt?a.jsx("span",{children:"已归档"}):null]})]}),a.jsxs("div",{className:"library-actions",children:[a.jsx("button",{ref:ne=>{ne?W.current.set(q.sessionId,ne):W.current.delete(q.sessionId)},className:"library-button",disabled:!!Y||!!F,onClick:ne=>{k.current=ne.currentTarget;const Ee=Me.capture(ne.currentTarget);_(""),U(null),Ge(Ee,"edit",q.sessionId),P({id:q.sessionId,title:q.title,originalTitle:q.title,expectedTitle:q.customTitle})},children:F?.id===q.sessionId?"正在编辑":"重命名"}),a.jsx("button",{className:"library-button",disabled:!!Y||q.running,onClick:ne=>{Ke(q.sessionId,{archived:!q.archivedAt},!1,ne.currentTarget)},children:Y===q.sessionId?"处理中…":q.archivedAt?"恢复":"归档"}),q.running?a.jsx("button",{className:"library-button",disabled:!0,children:"运行结束后导出"}):a.jsxs("details",{className:"session-export",children:[a.jsx("summary",{className:"library-button",children:"导出"}),a.jsxs("div",{children:[a.jsx("a",{href:cy(q.sessionId),download:!0,children:"Markdown 文档"}),a.jsx("a",{href:cy(q.sessionId,"json"),download:!0,children:"完整 JSON 记录"})]})]})]}),B?.id===q.sessionId?nt:null]},q.sessionId))}),w&&!N?a.jsx("div",{className:"session-load-more",children:a.jsx("button",{ref:oe,className:"library-button",disabled:E,onClick:q=>dt(q.currentTarget),children:E?"读取中…":"加载更多"})}):null]})}var dS=Kb();function Eo(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function bo(t){return typeof t=="string"?t:""}function av(t){return Array.isArray(t)?t.map(Eo).filter(r=>r!==void 0):[]}function fS(t){return typeof t=="string"?t:av(t).filter(r=>r.type==="text").map(r=>bo(r.text)).join("")}function Sl(t){return t.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function ld(t){const r=t.replace(/\\/g,"/").split("/").filter(Boolean).pop()||"附件";return t.includes(".code-shell/attachments/")?r.replace(/^[a-f0-9]{16}-/,""):r}function ad(t){const r=typeof t=="number"?t:Number(t);return Number.isSafeInteger(r)&&r>=0?r:0}function ov(t,r={}){const i=[],l=f=>/^(?:[a-zA-Z]:[\\/]|[\\/])/.test(f)||!r.cwd?f:`${r.cwd.replace(/[\\/]$/,"")}/${f}`,o=[];let d=fS(t.content);d=d.replace(/<attached-file\s+path="([^"]*)">\s*([\s\S]*?)<\/attached-file>/g,(f,p,y)=>{if(!/^absolutePath:\s*.+$/m.test(y)||!/^origin:\s*.+$/m.test(y))return f;const b=y.match(/^mime:\s*(.+)$/m)?.[1]?.trim();return i.push({name:ld(Sl(p)),path:Sl(p),...r.includeAbsolutePaths?{absPath:y.match(/^absolutePath:\s*(.+)$/m)[1].trim()}:{},size:ad(y.match(/^size:\s*(\d+)\s*$/m)?.[1]),...b?{mime:b}:{}}),""}),d=d.replace(/<attached-directory\s+path="([^"]*)"[^>]*>[\s\S]*?<\/attached-directory>/g,(f,p)=>(i.push({name:`${ld(Sl(p))}/`,path:Sl(p),...r.includeAbsolutePaths?{absPath:l(Sl(p))}:{},size:0}),"")),d=d.replace(/<attached-image-paths>\s*([\s\S]*?)<\/attached-image-paths>\s*(?:\(上面附带的图片在工作区的真实路径[^\n]*\))?/g,(f,p)=>(o.push(...p.split(`
|
|
37
|
+
`).map(y=>y.trim()).filter(Boolean)),""));const c=av(t.content).filter(f=>f.type==="image");for(let f=0;f<Math.max(c.length,o.length);f++){const p=Eo(c[f]?.source),y=bo(p?.data).replace(/\s/g,"");i.push({name:o[f]?ld(o[f]):`图片 ${f+1}`,...o[f]?{path:o[f]}:{},...r.includeAbsolutePaths&&o[f]?{absPath:l(o[f])}:{},size:y?Math.max(0,Math.floor(y.length*3/4)-(y.match(/=+$/)?.[0].length??0)):ad(p?.byteLength),...typeof p?.media_type=="string"?{mime:p.media_type}:{}})}const h=Array.isArray(t.attachments)?t.attachments.flatMap(f=>{const p=Eo(f),y=bo(p?.name)||bo(p?.originalName);return y?[{name:y,size:ad(p?.size),...typeof p?.mime=="string"?{mime:p.mime}:{},...typeof p?.path=="string"?{path:p.path}:{}}]:[]}):[];return{text:typeof t.displayText=="string"?t.displayText:d.trim(),attachments:h.length?h:i}}function uv(t){if(t.type!=="session_user_message"&&t.type!=="steer_injected")return t;const r=Eo(t.transcriptMessage);return r?{...t,...ov(r,{includeAbsolutePaths:!0,...typeof r.cwd=="string"?{cwd:r.cwd}:{}})}:t}function od(t){return t.replace(/<system-reminder>[\s\S]*?<\/system-reminder>\s*/g,"")}function vo(){return{items:[],run:"idle",seq:0,liveByAgent:{}}}function gs(t){return t.agentId??""}function oo(t,r,i=!1){const l=r.goalId;if(t.goalId!==l&&!(i&&t.goalId===void 0&&l!==void 0))return!0;const o=r.revision;return t.goalRevision!==void 0&&(o===void 0||o<t.goalRevision)}function hS(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 pS(t){if(!t||typeof t!="object")return null;const r=t;if(r.method==="agent/streamEvent"&&r.params&&typeof r.params=="object"){const i=r.params;if(i.event&&typeof i.event=="object")return{event:i.event,sessionId:typeof i.sessionId=="string"?i.sessionId:void 0}}return typeof r.type=="string"?{event:r}:null}function ki(t,r){const i=pS(r);if(!i)return t;const{sessionId:l}=i,o=uv(i.event),d=o.type;let c=t;l&&l!==c.sessionId&&(c={...c,sessionId:l});const h=f=>{const p=c.seq+1;return[`${f}-${p}`,{...c,seq:p}]};switch(d){case"stream_request_start":{const f=gs(o),[p,y]=h("a"),b={kind:"assistant",id:p,text:"",reasoning:"",done:!1,agentId:o.agentId,...typeof o.messageId=="string"?{messageId:o.messageId}:{}};return{...y,items:[...y.items,b],liveByAgent:{...y.liveByAgent,[f]:p},run:o.agentId?c.run:"running"}}case"text_delta":{const f=o.text??"",p=gs(o),y=c.liveByAgent[p];if(y&&c.items.find(N=>N.id===y&&N.kind==="assistant"))return{...c,run:o.agentId?c.run:"running",items:c.items.map(N=>N.id===y&&N.kind==="assistant"?{...N,text:N.text+f}:N)};const[v,w]=h("a"),j={kind:"assistant",id:v,text:f,reasoning:"",done:!1,agentId:o.agentId};return{...w,items:[...w.items,j],liveByAgent:{...w.liveByAgent,[p]:v},run:o.agentId?c.run:"running"}}case"thinking_delta":{const f=o.text??"",p=gs(o),y=c.liveByAgent[p];if(y&&c.items.some(j=>j.id===y&&j.kind==="assistant"))return{...c,run:o.agentId?c.run:"running",items:c.items.map(j=>j.id===y&&j.kind==="assistant"?{...j,reasoning:j.reasoning+f}:j)};const[b,v]=h("a"),w={kind:"assistant",id:b,text:"",reasoning:f,done:!1,agentId:o.agentId};return{...v,items:[...v.items,w],liveByAgent:{...v.liveByAgent,[p]:b},run:o.agentId?c.run:"running"}}case"tool_use_start":{const f=o.toolCall;if(!f||c.items.some(v=>v.kind==="tool"&&v.id===f.id))return c;const p=c.orphanResults?.[f.id],y={kind:"tool",id:f.id,name:f.toolName,args:f.args,summary:f.summary,done:!!p,result:p?.result,error:p?.error,agentId:o.agentId};let b=c.orphanResults;if(p){const{[f.id]:v,...w}=c.orphanResults;b=Object.keys(w).length>0?w:void 0}return{...c,run:o.agentId?c.run:"running",items:[...c.items,y],orphanResults:b}}case"tool_use_args_delta":{const f=o.toolCallId,p=o.args;return!f||!p?c:{...c,items:c.items.map(y=>y.kind==="tool"&&y.id===f?{...y,args:{...y.args??{},...p}}:y)}}case"tool_result":{const f=o.result;return f?c.items.some(y=>y.kind==="tool"&&y.id===f.id)?{...c,items:c.items.map(y=>y.kind==="tool"&&y.id===f.id?{...y,done:!0,result:od(f.result??f.error??""),error:!!(f.isError||f.error)}:y)}:{...c,orphanResults:{...c.orphanResults??{},[f.id]:{result:od(f.result??f.error??""),error:!!(f.isError||f.error)}}}:c}case"room_tool_result":{const f=o.summary??"",p=od(f),y=!!o.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(),w=v[b];return v[b]={...w,done:!0,result:p,summary:p||w.summary,error:y},{...c,items:v}}case"tool_summary":{const f=o.summary??"",p=Array.isArray(o.toolCallIds)?o.toolCallIds.filter(N=>typeof N=="string"):[],b=p.length>0?p[p.length-1]:void 0,v=o.agentId;if(b){let N=!1;const C=c.items.map(E=>E.kind!=="tool"||E.id!==b||E.agentId!==v?E:(N=!0,{...E,summary:f}));return N?{...c,items:C}:c}if(v){let N=-1;for(let E=c.items.length-1;E>=0;E--){const A=c.items[E];if(A.kind==="tool"&&A.agentId===v){N=E;break}}if(N===-1)return c;const C=c.items.slice();return C[N]={...C[N],summary:f},{...c,items:C}}let w=-1;for(let N=c.items.length-1;N>=0;N--){const C=c.items[N];if(C.kind==="tool"&&C.agentId===void 0){w=N;break}}if(w===-1)return c;const j=c.items.slice();return j[w]={...j[w],summary:f},{...c,items:j}}case"tombstone":{if(typeof o.messageId!="string")return c;const f=new Set(c.items.filter(p=>p.kind==="assistant"&&p.messageId===o.messageId||p.kind==="tool"&&p.id===o.messageId).map(p=>p.id));return f.size?{...c,items:c.items.filter(p=>!f.has(p.id)),liveByAgent:Object.fromEntries(Object.entries(c.liveByAgent).filter(([,p])=>!f.has(p)))}:c}case"assistant_message":{const f=gs(o);if(!(f in c.liveByAgent))return c;const{[f]:p,...y}=c.liveByAgent,b=c.items.map(v=>v.kind==="assistant"&&!v.done&&(v.agentId??"")===f?{...v,done:!0}:v);return{...c,liveByAgent:y,items:b}}case"turn_complete":{const f=o.reason??"completed",p=gs(o),{[p]:y,...b}=c.liveByAgent,v=c.items.map(w=>w.kind==="assistant"&&!w.done&&(w.agentId??"")===p?{...w,done:!0}:w);return o.agentId?{...c,liveByAgent:b,items:v}:{...c,liveByAgent:b,items:v,run:hS(f)}}case"goal_set":{const f=o.objective??"",p=!!o.paused;return c.goal&&c.goalId===o.goalId&&oo(c,o)?c:{...c,goal:f?`◎ ${f}${p?" (已暂停)":""}`:"◎ 目标",goalId:o.goalId,goalPaused:p,goalRevision:o.revision}}case"goal_updated":{if(c.goal&&oo(c,o,!0))return c;const f=o.goalId,p=o.objective??"",y=!!o.paused;return{...c,goal:p?`◎ ${p}${y?" (已暂停)":""}`:c.goal,goalId:f??c.goalId,goalPaused:y,goalRevision:o.revision??c.goalRevision}}case"goal_cleared":return c.goal&&oo(c,o)?c:{...c,goal:void 0,goalId:void 0,goalPaused:void 0,goalRevision:void 0};case"goal_progress":{if(c.goal&&oo(c,o))return c;const f=o.status??"";if(f==="met"||f==="exhausted")return{...c,goal:void 0,goalId:void 0,goalPaused:void 0,goalRevision:void 0};const p=o.round,y=p?`目标 · 第 ${p} 轮 (${f})`:`目标 (${f})`;return{...c,goal:y,goalRevision:o.revision??c.goalRevision}}case"task_update":{const f=o.agentId;if(!f)return c;const p=o.tasks??[],y=p.filter(j=>j.status==="completed").length,b=`任务 ${y}/${p.length}`,v=c.items.findIndex(j=>j.kind==="subagent"&&j.agentId===f),w={kind:"subagent",id:`sub-${f}`,agentId:f,label:b,status:p.length>0&&y===p.length?"completed":"running"};if(v>=0){const j=c.items.slice();return j[v]=w,{...c,items:j}}return{...c,items:[...c.items,w]}}case"agent_start":{const f=o.agentId;if(!f)return c;const p={kind:"subagent",id:`sub-${f}`,agentId:f,label:o.name||o.description||"子代理",status:o.status==="recorded"?"recorded":"running"};return c.items.some(y=>y.kind==="subagent"&&y.agentId===f)?c:{...c,items:[...c.items,p]}}case"agent_end":{const f=o.agentId;return{...c,items:c.items.map(p=>p.kind==="subagent"&&p.agentId===f?{...p,status:o.error?"error":"completed"}:p)}}case"background_agent_completed":{const f=typeof o.agentId=="string"?o.agentId:"",p=o.status==="failed",y=p?"error":o.status==="cancelled"?"cancelled":"completed",b=typeof o.name=="string"?o.name:"后台任务",v=p?o.error??o.description:o.finalText??o.description,w=`${b} · ${y}${typeof v=="string"&&v.trim()?`: ${v.trim().slice(0,240)}`:""}`,[j,N]=h("bg-done");return{...N,items:[...c.items.map(C=>C.kind==="subagent"&&C.agentId===f?{...C,status:y}:C),{kind:"system",id:j,text:w}]}}case"error":{const[f,p]=h("err");if(o.agentId){const y=gs(o),{[y]:b,...v}=p.liveByAgent;return{...p,liveByAgent:v,items:[...p.items.map(w=>w.kind==="assistant"&&!w.done&&w.agentId===y?{...w,done:!0}:w),{kind:"system_error",id:f,text:o.error||"运行出错"}]}}return{...p,run:"error",liveByAgent:{},items:[...p.items,{kind:"system_error",id:f,text:o.error||"运行出错"}]}}case"session_title":return{...c,title:o.title};case"session_user_message":case"steer_injected":case"user_message":{if(o.agentId||o.injected===!0||o.authority==="agent"||o.authority==="system"||o.authority==="policy")return c;const f=typeof o.clientMessageId=="string"?o.clientMessageId:void 0,p=Array.isArray(o.attachments)?o.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(f&&c.items.some(v=>v.kind==="user"&&v.clientMessageId===f))return p?.length?{...c,items:c.items.map(v=>v.kind==="user"&&v.clientMessageId===f?{...v,attachments:p.map((w,j)=>{const N=v.attachments?.[j];return N?.name===w.name?{...N,...w}:w})}:v)}:c;const[y,b]=h("u");return{...b,items:[...b.items,{kind:"user",id:y,text:o.text??"",...p?.length?{attachments:p}:{},...f?{clientMessageId:f}:{}}]}}case"assistant_text":{const[f,p]=h("a");return{...p,run:"running",items:[...p.items,{kind:"assistant",id:f,text:o.text??"",reasoning:"",done:!0,agentId:o.agentId}]}}default:return c}}function mS(t,r,i,l){const o=`u-${t.seq+1}`;return{...t,seq:t.seq+1,items:[...t.items,{kind:"user",id:o,text:r,...i?.length?{attachments:i}:{},...l?{clientMessageId:l}:{}}]}}const gS="codeshell.uiLanguage";function yS(){try{const t=globalThis.localStorage?.getItem(gS);if(t==="zh"||t==="en")return t}catch{}return"zh"}const bS={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}",createOffline:"连接已断开,重新连接后才能新建任务。",approvalSendFailed:"审批未送达,请检查连接后重试"},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}",createOffline:"Disconnected. Reconnect before starting a new task.",approvalSendFailed:"The approval was not delivered. Check the connection and try again."},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)"}}}},dy=bS;function fy(t,r){let i=t;for(const l of r.split(".")){if(i==null||typeof i!="object")return;i=i[l]}return typeof i=="string"?i:void 0}function vS(t,r){return r?t.replace(/\{(\w+)\}/g,(i,l)=>l in r?String(r[l]):i):t}function xS(t,r,i){const l=fy(dy[t],r)??fy(dy.zh,r)??r;return vS(l,i)}function wS(t,r){return xS(yS(),t,r)}const SS=["command","file_path","path","url","pattern","query"];function jS(t,r,i){let l="";const o=t?.source,d=t?.scope,c=t?.resource;if(i==="ReadSource"&&typeof o=="string"&&o.length>0&&typeof d=="string"&&d.length>0&&typeof c=="string"&&c.length>0)l=wS("mobile.approval.readSourceSummary",{source:o,scope:d,resource:c});else for(const f of SS){const p=t?.[f];if(typeof p=="string"&&p.length>0){l=p;break}}l||(l=JSON.stringify(t??{}));let h;return r==="low"||r==="medium"||r==="high"?h=r:r===void 0||r===""?h="medium":h="high",{summary:l,risk:h}}const kS=16*1024*1024;function ji(t){if(typeof t!="string"||t.length>2048||!/^[A-Za-z0-9_-]+$/.test(t))throw new Error("Invalid output cursor");const r=JSON.parse(atob(t.replace(/-/g,"+").replace(/_/g,"/")));if(typeof r.identity!="string"||!Number.isSafeInteger(r.sequence)||r.sequence<0||!Number.isSafeInteger(r.offset)||r.offset<0)throw new Error("Invalid output cursor");return r}function ES(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 r=atob(t);return Uint8Array.from(r,i=>i.charCodeAt(0))}function Rl(t,r){try{const i=ji(t),l=ji(r);return i.identity===l.identity?Math.sign(i.sequence-l.sequence):void 0}catch{return}}function CS(t,r,i){if(t.incomplete)return!1;try{if(r.version!==1||r.status!=="ok"||!r.from||!r.through||!r.next||!r.coverageStart||!Array.isArray(r.frames)||r.frames.length>512||new TextEncoder().encode(JSON.stringify(r)).length>1024*1024+16*1024)throw new Error("Output recovery is incomplete");if((t.cursor??r.coverageStart)!==r.from||t.through&&t.through!==r.through||t.coverageStart&&t.coverageStart!==r.coverageStart||t.legacyBaseThroughEventId!==void 0&&t.legacyBaseThroughEventId!==r.legacyBaseThroughEventId)throw new Error("Output recovery page changed its snapshot");let l=ji(r.from);const o=ji(r.through),d=ji(r.coverageStart);if(d.sequence!==0||d.identity!==l.identity||o.identity!==l.identity||l.sequence>o.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??r.from;const f=[];for(const y of r.frames){const b=ji(y.cursor);if(b.identity!==l.identity||b.sequence!==l.sequence+1||y.sequence!==b.sequence||b.offset<=l.offset||b.sequence>o.sequence||!!y.event==!!y.fragment)throw new Error("Output recovery has a gap");let v=y.event;if(y.fragment){const w=y.fragment;if(!c){if(w.index!==0||!Number.isSafeInteger(w.total)||w.total<2||w.total>256)throw new Error("Output fragment has no beginning");c={id:w.id,total:w.total,next:0,bytes:0,chunks:[]}}if(w.id!==c.id||w.total!==c.total||w.index!==c.next)throw new Error("Output fragment has a gap");const j=ES(w.data);if(c.bytes+=j.length,c.bytes>kS)throw new Error("Output fragment exceeds its budget");if(c.chunks.push(j),c.next++,c.next===c.total){const N=new Uint8Array(c.bytes);let C=0;for(const E of c.chunks)N.set(E,C),C+=E.length;v=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(N)),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");f.push({...uv(v),outputCursor:y.cursor}),h=y.cursor}l=b}const p=ji(r.next);if(p.identity!==l.identity||p.sequence!==l.sequence||p.offset!==l.offset||(r.frames.at(-1)?.cursor??r.from)!==r.next||r.complete!==(r.next===r.through)||r.complete&&c||!r.complete&&!r.frames.length)throw new Error("Output recovery page did not establish coverage");t.cursor=r.next,t.appliedCursor=h,t.through=r.through,t.coverageStart=r.coverageStart,t.legacyBaseThroughEventId=r.legacyBaseThroughEventId,t.pending=c;for(const y of f)i(y);return r.complete}catch{return t.incomplete=!0,t.pending=void 0,!1}}const TS=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 NS(t){if(typeof t!="string"||t.length>2048||!/^[A-Za-z0-9_-]+$/.test(t))return!1;try{const r=JSON.parse(atob(t.replace(/-/g,"+").replace(/_/g,"/")));return typeof r.identity=="string"&&typeof r.hash=="string"&&/^[a-f0-9]{64}$/.test(r.identity)&&/^[a-f0-9]{64}$/.test(r.hash)&&Number.isSafeInteger(r.sequence)&&r.sequence>0&&Number.isSafeInteger(r.offset)&&r.offset>0}catch{return!1}}class Df{lastCursor;blocked=!1;overflowed=!1;inputs=new Set;copy(){const r=new Df;r.lastCursor=this.lastCursor,r.blocked=this.blocked,r.overflowed=this.overflowed;for(const i of this.inputs)r.inputs.add(i);return r}observe(r){if(this.overflowed)return;const i=r;if(i){if(i.outputCursor!==void 0){const l=NS(i.outputCursor)?this.lastCursor?Rl(i.outputCursor,this.lastCursor):1:void 0;if(l===void 0||l<=0){this.discardProof();return}this.lastCursor=i.outputCursor;return}if(!(!i.type||!TS.has(i.type))&&!(["session_user_message","steer_injected","user_message"].includes(i.type)&&(i.agentId||i.injected===!0||["agent","system","policy"].includes(String(i.authority)))))if(i.type==="session_user_message"){const l=i.clientMessageId;typeof l!="string"||!l.trim()||l.length>512?this.blocked=!0:this.inputs.add(l),(this.inputIds.length>128||this.memoryBytes>32*1024)&&this.discardProof()}else this.blocked=!0}}acknowledgeInputs(r){for(const i of r)this.inputs.delete(i)}get inputIds(){return[...this.inputs]}get incomplete(){return this.blocked||this.overflowed}get memoryBytes(){return this.inputIds.reduce((r,i)=>r+new TextEncoder().encode(i).length,0)}discardProof(){this.overflowed=!0,this.inputs.clear()}}function jl(t,r,i,l={}){if(t.unpaired)throw new Error("Output recovery contains unpaired visible output");if(r.coverageIdentity!==void 0&&l.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!==r.coverageIdentity)throw new Error("Output recovery Session incarnation changed");if(t.journalIdentity!==void 0){let d;try{d=JSON.parse(atob((r.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 o=t.inputIds??[];if(!Array.isArray(o)||o.length>128||new Set(o).size!==o.length||o.some(d=>typeof d!="string"||!d.trim()||d.length>512)||o.reduce((d,c)=>d+new TextEncoder().encode(c).length,0)>32*1024)throw new Error("Output recovery input identities are unpaired");if(o.some(d=>!i(d)))throw new Error("Output recovery input has no recorded anchor")}const ud=1e4,hy=15e3,AS=5e3;class RS{constructor(r,i,l=!1){this.sendProbe=r,this.expire=i,this.paused=l,this.arm(ud,()=>this.fail())}sendProbe;expire;timer;revision=0;stopped=!1;paused;ready=!1;opened=!1;probing=!1;connected(){this.stopped||(this.ready=!0,this.arm(hy,()=>this.check()))}authenticating(){this.stopped||this.ready||this.opened||(this.opened=!0,this.arm(ud,()=>this.fail()))}received(){return this.stopped||this.paused||!this.probing?!1:(this.probing=!1,this.arm(hy,()=>this.check()),!0)}check(){if(!(this.stopped||this.paused||this.probing||!this.ready)){this.probing=!0,this.arm(AS,()=>this.fail());try{this.sendProbe()}catch{this.fail()}}}pause(){this.paused=!0,this.probing=!1,this.clear()}resume(){if(this.stopped)return;const r=this.paused;this.paused=!1,this.ready?this.check():r&&this.arm(ud,()=>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(r,i){if(this.clear(),this.stopped||this.paused)return;const l=this.revision;this.timer=setTimeout(()=>{this.stopped||this.paused||l!==this.revision||(this.timer=void 0,i())},r)}fail(){this.stopped||(this.stop(),this.expire())}}function uo(){return typeof document<"u"&&document.visibilityState==="hidden"}function Tr(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function Yt(t){return typeof t=="string"?t:""}function af(t){return Array.isArray(t)?t.map(Tr).filter(r=>r!==void 0):[]}function py(t){return typeof t=="string"?t:af(t).filter(r=>r.type==="text").map(r=>Yt(r.text)).join("")}function my(t){return Tr(t.data)??Tr(t.message)??t}function zS(t){const r=[],i=new Set,l=new Set,o=new Map;for(const h of t){const f=Tr(h);if(!f)continue;const p=my(f);f.type==="tool_use"&&Yt(p.toolCallId)&&o.set(Yt(p.toolCallId),{name:Yt(p.toolName)||"工具",args:Tr(p.args)??{}});for(const y of af(p.content))y.type==="tool_use"&&Yt(y.id)&&o.set(Yt(y.id),{name:Yt(y.name)||"工具",args:Tr(y.input)??{}})}const d=(h,f,p,y)=>{h&&(l.has(h)?r.push({type:"tool_use_args_delta",toolCallId:h,args:p,...y?{agentId:y}:{}}):(l.add(h),r.push({type:"tool_use_start",toolCall:{id:h,toolName:f||"工具",args:p},...y?{agentId:y}:{}})))},c=(h,f,p)=>{if(!h)return;const y=o.get(h);l.has(h)||d(h,y?.name||Yt(f.toolName)||"工具",y?.args??{},p);const b=typeof f.result=="string"?f.result:py(f.content??f.contentBlocks),v=Yt(f.error);r.push({type:"tool_result",result:{id:h,result:b||v,...v?{error:v}:{},isError:f.isError===!0||f.is_error===!0||!!v},...p?{agentId:p}:{}})};for(const h of t){const f=Tr(h);if(!f)continue;const p=Yt(f.id);if(p&&i.has(p))continue;p&&i.add(p);const y=my(f),b=Yt(y.agentId)||void 0;switch(typeof f.type=="string"?f.type:typeof y.role=="string"?"message":""){case"message":{const w=af(y.content);if(y.role==="user"){if(y.injected===!0||y.authority==="agent"||y.authority==="system"||y.authority==="policy")break;const j=ov(y);if(j.text.startsWith("<system-reminder>"))break;(j.text||j.attachments.length)&&r.push({type:"user_message",...j,...typeof y.clientMessageId=="string"?{clientMessageId:y.clientMessageId}:{}});for(const N of w)N.type==="tool_result"&&c(Yt(N.tool_use_id),N,b)}else if(y.role==="assistant"){const j=py(y.content),N=w.filter(C=>C.type==="reasoning").map(C=>Yt(C.reasoningContent)||Yt(C.text)).join("");if(j||N){const C=b?{agentId:b}:{};r.push({type:"stream_request_start",...C}),N&&r.push({type:"thinking_delta",text:N,...C}),j&&r.push({type:"text_delta",text:j,...C}),r.push({type:"assistant_message",...C})}for(const C of w)C.type==="tool_use"&&d(Yt(C.id),Yt(C.name),Tr(C.input)??{},b)}else y.role==="tool"&&c(Yt(y.tool_call_id),y,b);break}case"tool_use":d(Yt(y.toolCallId),Yt(y.toolName),Tr(y.args)??{},b);break;case"tool_result":c(Yt(y.toolCallId),y,b);break;case"subagent":b&&r.push({type:"agent_start",agentId:b,name:Yt(y.name),description:Yt(y.description),status:"recorded"});break;case"error":Yt(y.error)&&r.push({type:"error",error:y.error});break;case"turn_stopped":r.push({type:"turn_complete",reason:"aborted_tools"});break;case"session_meta":Yt(y.sessionId)&&r.push({type:"session_started",sessionId:y.sessionId});break}}return r}function cv(t){let r=vo();for(const i of zS(t))r=ki(r,i);return{...r,run:r.run==="error"?"error":"idle",liveByAgent:{}}}var ys={},cd,gy;function _S(){return gy||(gy=1,cd=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),cd}var dd={},ti={},yy;function Ai(){if(yy)return ti;yy=1;let t;const r=[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 ti.getSymbolSize=function(l){if(!l)throw new Error('"version" cannot be null or undefined');if(l<1||l>40)throw new Error('"version" should be in range from 1 to 40');return l*4+17},ti.getSymbolTotalCodewords=function(l){return r[l]},ti.getBCHDigit=function(i){let l=0;for(;i!==0;)l++,i>>>=1;return l},ti.setToSJISFunction=function(l){if(typeof l!="function")throw new Error('"toSJISFunc" is not a valid function.');t=l},ti.isKanjiModeEnabled=function(){return typeof t<"u"},ti.toSJIS=function(l){return t(l)},ti}var fd={},by;function Of(){return by||(by=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function r(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.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: "+i)}}t.isValid=function(l){return l&&typeof l.bit<"u"&&l.bit>=0&&l.bit<4},t.from=function(l,o){if(t.isValid(l))return l;try{return r(l)}catch{return o}}})(fd)),fd}var hd,vy;function MS(){if(vy)return hd;vy=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(r){const i=Math.floor(r/8);return(this.buffer[i]>>>7-r%8&1)===1},put:function(r,i){for(let l=0;l<i;l++)this.putBit((r>>>i-l-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(r){const i=Math.floor(this.length/8);this.buffer.length<=i&&this.buffer.push(0),r&&(this.buffer[i]|=128>>>this.length%8),this.length++}},hd=t,hd}var pd,xy;function DS(){if(xy)return pd;xy=1;function t(r){if(!r||r<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=r,this.data=new Uint8Array(r*r),this.reservedBit=new Uint8Array(r*r)}return t.prototype.set=function(r,i,l,o){const d=r*this.size+i;this.data[d]=l,o&&(this.reservedBit[d]=!0)},t.prototype.get=function(r,i){return this.data[r*this.size+i]},t.prototype.xor=function(r,i,l){this.data[r*this.size+i]^=l},t.prototype.isReserved=function(r,i){return this.reservedBit[r*this.size+i]},pd=t,pd}var md={},wy;function OS(){return wy||(wy=1,(function(t){const r=Ai().getSymbolSize;t.getRowColCoords=function(l){if(l===1)return[];const o=Math.floor(l/7)+2,d=r(l),c=d===145?26:Math.ceil((d-13)/(2*o-2))*2,h=[d-7];for(let f=1;f<o-1;f++)h[f]=h[f-1]-c;return h.push(6),h.reverse()},t.getPositions=function(l){const o=[],d=t.getRowColCoords(l),c=d.length;for(let h=0;h<c;h++)for(let f=0;f<c;f++)h===0&&f===0||h===0&&f===c-1||h===c-1&&f===0||o.push([d[h],d[f]]);return o}})(md)),md}var gd={},Sy;function LS(){if(Sy)return gd;Sy=1;const t=Ai().getSymbolSize,r=7;return gd.getPositions=function(l){const o=t(l);return[[0,0],[o-r,0],[0,o-r]]},gd}var yd={},jy;function IS(){return jy||(jy=1,(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const r={N1:3,N2:3,N3:40,N4:10};t.isValid=function(o){return o!=null&&o!==""&&!isNaN(o)&&o>=0&&o<=7},t.from=function(o){return t.isValid(o)?parseInt(o,10):void 0},t.getPenaltyN1=function(o){const d=o.size;let c=0,h=0,f=0,p=null,y=null;for(let b=0;b<d;b++){h=f=0,p=y=null;for(let v=0;v<d;v++){let w=o.get(b,v);w===p?h++:(h>=5&&(c+=r.N1+(h-5)),p=w,h=1),w=o.get(v,b),w===y?f++:(f>=5&&(c+=r.N1+(f-5)),y=w,f=1)}h>=5&&(c+=r.N1+(h-5)),f>=5&&(c+=r.N1+(f-5))}return c},t.getPenaltyN2=function(o){const d=o.size;let c=0;for(let h=0;h<d-1;h++)for(let f=0;f<d-1;f++){const p=o.get(h,f)+o.get(h,f+1)+o.get(h+1,f)+o.get(h+1,f+1);(p===4||p===0)&&c++}return c*r.N2},t.getPenaltyN3=function(o){const d=o.size;let c=0,h=0,f=0;for(let p=0;p<d;p++){h=f=0;for(let y=0;y<d;y++)h=h<<1&2047|o.get(p,y),y>=10&&(h===1488||h===93)&&c++,f=f<<1&2047|o.get(y,p),y>=10&&(f===1488||f===93)&&c++}return c*r.N3},t.getPenaltyN4=function(o){let d=0;const c=o.data.length;for(let f=0;f<c;f++)d+=o.data[f];return Math.abs(Math.ceil(d*100/c/5)-10)*r.N4};function i(l,o,d){switch(l){case t.Patterns.PATTERN000:return(o+d)%2===0;case t.Patterns.PATTERN001:return o%2===0;case t.Patterns.PATTERN010:return d%3===0;case t.Patterns.PATTERN011:return(o+d)%3===0;case t.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(d/3))%2===0;case t.Patterns.PATTERN101:return o*d%2+o*d%3===0;case t.Patterns.PATTERN110:return(o*d%2+o*d%3)%2===0;case t.Patterns.PATTERN111:return(o*d%3+(o+d)%2)%2===0;default:throw new Error("bad maskPattern:"+l)}}t.applyMask=function(o,d){const c=d.size;for(let h=0;h<c;h++)for(let f=0;f<c;f++)d.isReserved(f,h)||d.xor(f,h,i(o,f,h))},t.getBestMask=function(o,d){const c=Object.keys(t.Patterns).length;let h=0,f=1/0;for(let p=0;p<c;p++){d(p),t.applyMask(p,o);const y=t.getPenaltyN1(o)+t.getPenaltyN2(o)+t.getPenaltyN3(o)+t.getPenaltyN4(o);t.applyMask(p,o),y<f&&(f=y,h=p)}return h}})(yd)),yd}var co={},ky;function dv(){if(ky)return co;ky=1;const t=Of(),r=[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],i=[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 co.getBlocksCount=function(o,d){switch(d){case t.L:return r[(o-1)*4+0];case t.M:return r[(o-1)*4+1];case t.Q:return r[(o-1)*4+2];case t.H:return r[(o-1)*4+3];default:return}},co.getTotalCodewordsCount=function(o,d){switch(d){case t.L:return i[(o-1)*4+0];case t.M:return i[(o-1)*4+1];case t.Q:return i[(o-1)*4+2];case t.H:return i[(o-1)*4+3];default:return}},co}var bd={},kl={},Ey;function BS(){if(Ey)return kl;Ey=1;const t=new Uint8Array(512),r=new Uint8Array(256);return(function(){let l=1;for(let o=0;o<255;o++)t[o]=l,r[l]=o,l<<=1,l&256&&(l^=285);for(let o=255;o<512;o++)t[o]=t[o-255]})(),kl.log=function(l){if(l<1)throw new Error("log("+l+")");return r[l]},kl.exp=function(l){return t[l]},kl.mul=function(l,o){return l===0||o===0?0:t[r[l]+r[o]]},kl}var Cy;function qS(){return Cy||(Cy=1,(function(t){const r=BS();t.mul=function(l,o){const d=new Uint8Array(l.length+o.length-1);for(let c=0;c<l.length;c++)for(let h=0;h<o.length;h++)d[c+h]^=r.mul(l[c],o[h]);return d},t.mod=function(l,o){let d=new Uint8Array(l);for(;d.length-o.length>=0;){const c=d[0];for(let f=0;f<o.length;f++)d[f]^=r.mul(o[f],c);let h=0;for(;h<d.length&&d[h]===0;)h++;d=d.slice(h)}return d},t.generateECPolynomial=function(l){let o=new Uint8Array([1]);for(let d=0;d<l;d++)o=t.mul(o,new Uint8Array([1,r.exp(d)]));return o}})(bd)),bd}var vd,Ty;function US(){if(Ty)return vd;Ty=1;const t=qS();function r(i){this.genPoly=void 0,this.degree=i,this.degree&&this.initialize(this.degree)}return r.prototype.initialize=function(l){this.degree=l,this.genPoly=t.generateECPolynomial(this.degree)},r.prototype.encode=function(l){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(l.length+this.degree);o.set(l);const d=t.mod(o,this.genPoly),c=this.degree-d.length;if(c>0){const h=new Uint8Array(this.degree);return h.set(d,c),h}return d},vd=r,vd}var xd={},wd={},Sd={},Ny;function fv(){return Ny||(Ny=1,Sd.isValid=function(r){return!isNaN(r)&&r>=1&&r<=40}),Sd}var rr={},Ay;function hv(){if(Ay)return rr;Ay=1;const t="[0-9]+",r="[A-Z $%*+\\-./:]+";let i="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";i=i.replace(/u/g,"\\u");const l="(?:(?![A-Z0-9 $%*+\\-./:]|"+i+`)(?:.|[\r
|
|
38
|
+
]))+`;rr.KANJI=new RegExp(i,"g"),rr.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),rr.BYTE=new RegExp(l,"g"),rr.NUMERIC=new RegExp(t,"g"),rr.ALPHANUMERIC=new RegExp(r,"g");const o=new RegExp("^"+i+"$"),d=new RegExp("^"+t+"$"),c=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return rr.testKanji=function(f){return o.test(f)},rr.testNumeric=function(f){return d.test(f)},rr.testAlphanumeric=function(f){return c.test(f)},rr}var Ry;function Ri(){return Ry||(Ry=1,(function(t){const r=fv(),i=hv();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(!r.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 i.testNumeric(d)?t.NUMERIC:i.testAlphanumeric(d)?t.ALPHANUMERIC:i.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 l(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.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: "+o)}}t.from=function(d,c){if(t.isValid(d))return d;try{return l(d)}catch{return c}}})(wd)),wd}var zy;function HS(){return zy||(zy=1,(function(t){const r=Ai(),i=dv(),l=Of(),o=Ri(),d=fv(),c=7973,h=r.getBCHDigit(c);function f(v,w,j){for(let N=1;N<=40;N++)if(w<=t.getCapacity(N,j,v))return N}function p(v,w){return o.getCharCountIndicator(v,w)+4}function y(v,w){let j=0;return v.forEach(function(N){const C=p(N.mode,w);j+=C+N.getBitsLength()}),j}function b(v,w){for(let j=1;j<=40;j++)if(y(v,j)<=t.getCapacity(j,w,o.MIXED))return j}t.from=function(w,j){return d.isValid(w)?parseInt(w,10):j},t.getCapacity=function(w,j,N){if(!d.isValid(w))throw new Error("Invalid QR Code version");typeof N>"u"&&(N=o.BYTE);const C=r.getSymbolTotalCodewords(w),E=i.getTotalCodewordsCount(w,j),A=(C-E)*8;if(N===o.MIXED)return A;const D=A-p(N,w);switch(N){case o.NUMERIC:return Math.floor(D/10*3);case o.ALPHANUMERIC:return Math.floor(D/11*2);case o.KANJI:return Math.floor(D/13);case o.BYTE:default:return Math.floor(D/8)}},t.getBestVersionForData=function(w,j){let N;const C=l.from(j,l.M);if(Array.isArray(w)){if(w.length>1)return b(w,C);if(w.length===0)return 1;N=w[0]}else N=w;return f(N.mode,N.getLength(),C)},t.getEncodedBits=function(w){if(!d.isValid(w)||w<7)throw new Error("Invalid QR Code version");let j=w<<12;for(;r.getBCHDigit(j)-h>=0;)j^=c<<r.getBCHDigit(j)-h;return w<<12|j}})(xd)),xd}var jd={},_y;function PS(){if(_y)return jd;_y=1;const t=Ai(),r=1335,i=21522,l=t.getBCHDigit(r);return jd.getEncodedBits=function(d,c){const h=d.bit<<3|c;let f=h<<10;for(;t.getBCHDigit(f)-l>=0;)f^=r<<t.getBCHDigit(f)-l;return(h<<10|f)^i},jd}var kd={},Ed,My;function FS(){if(My)return Ed;My=1;const t=Ri();function r(i){this.mode=t.NUMERIC,this.data=i.toString()}return r.getBitsLength=function(l){return 10*Math.floor(l/3)+(l%3?l%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(l){let o,d,c;for(o=0;o+3<=this.data.length;o+=3)d=this.data.substr(o,3),c=parseInt(d,10),l.put(c,10);const h=this.data.length-o;h>0&&(d=this.data.substr(o),c=parseInt(d,10),l.put(c,h*3+1))},Ed=r,Ed}var Cd,Dy;function $S(){if(Dy)return Cd;Dy=1;const t=Ri(),r=["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 i(l){this.mode=t.ALPHANUMERIC,this.data=l}return i.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(o){let d;for(d=0;d+2<=this.data.length;d+=2){let c=r.indexOf(this.data[d])*45;c+=r.indexOf(this.data[d+1]),o.put(c,11)}this.data.length%2&&o.put(r.indexOf(this.data[d]),6)},Cd=i,Cd}var Td,Oy;function GS(){if(Oy)return Td;Oy=1;const t=Ri();function r(i){this.mode=t.BYTE,typeof i=="string"?this.data=new TextEncoder().encode(i):this.data=new Uint8Array(i)}return r.getBitsLength=function(l){return l*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(i){for(let l=0,o=this.data.length;l<o;l++)i.put(this.data[l],8)},Td=r,Td}var Nd,Ly;function VS(){if(Ly)return Nd;Ly=1;const t=Ri(),r=Ai();function i(l){this.mode=t.KANJI,this.data=l}return i.getBitsLength=function(o){return o*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(l){let o;for(o=0;o<this.data.length;o++){let d=r.toSJIS(this.data[o]);if(d>=33088&&d<=40956)d-=33088;else if(d>=57408&&d<=60351)d-=49472;else throw new Error("Invalid SJIS character: "+this.data[o]+`
|
|
39
|
+
Make sure your charset is UTF-8`);d=(d>>>8&255)*192+(d&255),l.put(d,13)}},Nd=i,Nd}var Ad={exports:{}},Iy;function YS(){return Iy||(Iy=1,(function(t){var r={single_source_shortest_paths:function(i,l,o){var d={},c={};c[l]=0;var h=r.PriorityQueue.make();h.push(l,0);for(var f,p,y,b,v,w,j,N,C;!h.empty();){f=h.pop(),p=f.value,b=f.cost,v=i[p]||{};for(y in v)v.hasOwnProperty(y)&&(w=v[y],j=b+w,N=c[y],C=typeof c[y]>"u",(C||N>j)&&(c[y]=j,h.push(y,j),d[y]=p))}if(typeof o<"u"&&typeof c[o]>"u"){var E=["Could not find a path from ",l," to ",o,"."].join("");throw new Error(E)}return d},extract_shortest_path_from_predecessor_list:function(i,l){for(var o=[],d=l;d;)o.push(d),i[d],d=i[d];return o.reverse(),o},find_path:function(i,l,o){var d=r.single_source_shortest_paths(i,l,o);return r.extract_shortest_path_from_predecessor_list(d,o)},PriorityQueue:{make:function(i){var l=r.PriorityQueue,o={},d;i=i||{};for(d in l)l.hasOwnProperty(d)&&(o[d]=l[d]);return o.queue=[],o.sorter=i.sorter||l.default_sorter,o},default_sorter:function(i,l){return i.cost-l.cost},push:function(i,l){var o={value:i,cost:l};this.queue.push(o),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=r})(Ad)),Ad.exports}var By;function QS(){return By||(By=1,(function(t){const r=Ri(),i=FS(),l=$S(),o=GS(),d=VS(),c=hv(),h=Ai(),f=YS();function p(E){return unescape(encodeURIComponent(E)).length}function y(E,A,D){const L=[];let J;for(;(J=E.exec(D))!==null;)L.push({data:J[0],index:J.index,mode:A,length:J[0].length});return L}function b(E){const A=y(c.NUMERIC,r.NUMERIC,E),D=y(c.ALPHANUMERIC,r.ALPHANUMERIC,E);let L,J;return h.isKanjiModeEnabled()?(L=y(c.BYTE,r.BYTE,E),J=y(c.KANJI,r.KANJI,E)):(L=y(c.BYTE_KANJI,r.BYTE,E),J=[]),A.concat(D,L,J).sort(function(B,U){return B.index-U.index}).map(function(B){return{data:B.data,mode:B.mode,length:B.length}})}function v(E,A){switch(A){case r.NUMERIC:return i.getBitsLength(E);case r.ALPHANUMERIC:return l.getBitsLength(E);case r.KANJI:return d.getBitsLength(E);case r.BYTE:return o.getBitsLength(E)}}function w(E){return E.reduce(function(A,D){const L=A.length-1>=0?A[A.length-1]:null;return L&&L.mode===D.mode?(A[A.length-1].data+=D.data,A):(A.push(D),A)},[])}function j(E){const A=[];for(let D=0;D<E.length;D++){const L=E[D];switch(L.mode){case r.NUMERIC:A.push([L,{data:L.data,mode:r.ALPHANUMERIC,length:L.length},{data:L.data,mode:r.BYTE,length:L.length}]);break;case r.ALPHANUMERIC:A.push([L,{data:L.data,mode:r.BYTE,length:L.length}]);break;case r.KANJI:A.push([L,{data:L.data,mode:r.BYTE,length:p(L.data)}]);break;case r.BYTE:A.push([{data:L.data,mode:r.BYTE,length:p(L.data)}])}}return A}function N(E,A){const D={},L={start:{}};let J=["start"];for(let T=0;T<E.length;T++){const B=E[T],U=[];for(let X=0;X<B.length;X++){const _=B[X],I=""+T+X;U.push(I),D[I]={node:_,lastCount:0},L[I]={};for(let H=0;H<J.length;H++){const Y=J[H];D[Y]&&D[Y].node.mode===_.mode?(L[Y][I]=v(D[Y].lastCount+_.length,_.mode)-v(D[Y].lastCount,_.mode),D[Y].lastCount+=_.length):(D[Y]&&(D[Y].lastCount=_.length),L[Y][I]=v(_.length,_.mode)+4+r.getCharCountIndicator(_.mode,A))}}J=U}for(let T=0;T<J.length;T++)L[J[T]].end=0;return{map:L,table:D}}function C(E,A){let D;const L=r.getBestModeForData(E);if(D=r.from(A,L),D!==r.BYTE&&D.bit<L.bit)throw new Error('"'+E+'" cannot be encoded with mode '+r.toString(D)+`.
|
|
40
|
+
Suggested mode is: `+r.toString(L));switch(D===r.KANJI&&!h.isKanjiModeEnabled()&&(D=r.BYTE),D){case r.NUMERIC:return new i(E);case r.ALPHANUMERIC:return new l(E);case r.KANJI:return new d(E);case r.BYTE:return new o(E)}}t.fromArray=function(A){return A.reduce(function(D,L){return typeof L=="string"?D.push(C(L,null)):L.data&&D.push(C(L.data,L.mode)),D},[])},t.fromString=function(A,D){const L=b(A,h.isKanjiModeEnabled()),J=j(L),T=N(J,D),B=f.find_path(T.map,"start","end"),U=[];for(let X=1;X<B.length-1;X++)U.push(T.table[B[X]].node);return t.fromArray(w(U))},t.rawSplit=function(A){return t.fromArray(b(A,h.isKanjiModeEnabled()))}})(kd)),kd}var qy;function KS(){if(qy)return dd;qy=1;const t=Ai(),r=Of(),i=MS(),l=DS(),o=OS(),d=LS(),c=IS(),h=dv(),f=US(),p=HS(),y=PS(),b=Ri(),v=QS();function w(T,B){const U=T.size,X=d.getPositions(B);for(let _=0;_<X.length;_++){const I=X[_][0],H=X[_][1];for(let Y=-1;Y<=7;Y++)if(!(I+Y<=-1||U<=I+Y))for(let $=-1;$<=7;$++)H+$<=-1||U<=H+$||(Y>=0&&Y<=6&&($===0||$===6)||$>=0&&$<=6&&(Y===0||Y===6)||Y>=2&&Y<=4&&$>=2&&$<=4?T.set(I+Y,H+$,!0,!0):T.set(I+Y,H+$,!1,!0))}}function j(T){const B=T.size;for(let U=8;U<B-8;U++){const X=U%2===0;T.set(U,6,X,!0),T.set(6,U,X,!0)}}function N(T,B){const U=o.getPositions(B);for(let X=0;X<U.length;X++){const _=U[X][0],I=U[X][1];for(let H=-2;H<=2;H++)for(let Y=-2;Y<=2;Y++)H===-2||H===2||Y===-2||Y===2||H===0&&Y===0?T.set(_+H,I+Y,!0,!0):T.set(_+H,I+Y,!1,!0)}}function C(T,B){const U=T.size,X=p.getEncodedBits(B);let _,I,H;for(let Y=0;Y<18;Y++)_=Math.floor(Y/3),I=Y%3+U-8-3,H=(X>>Y&1)===1,T.set(_,I,H,!0),T.set(I,_,H,!0)}function E(T,B,U){const X=T.size,_=y.getEncodedBits(B,U);let I,H;for(I=0;I<15;I++)H=(_>>I&1)===1,I<6?T.set(I,8,H,!0):I<8?T.set(I+1,8,H,!0):T.set(X-15+I,8,H,!0),I<8?T.set(8,X-I-1,H,!0):I<9?T.set(8,15-I-1+1,H,!0):T.set(8,15-I-1,H,!0);T.set(X-8,8,1,!0)}function A(T,B){const U=T.size;let X=-1,_=U-1,I=7,H=0;for(let Y=U-1;Y>0;Y-=2)for(Y===6&&Y--;;){for(let $=0;$<2;$++)if(!T.isReserved(_,Y-$)){let F=!1;H<B.length&&(F=(B[H]>>>I&1)===1),T.set(_,Y-$,F),I--,I===-1&&(H++,I=7)}if(_+=X,_<0||U<=_){_-=X,X=-X;break}}}function D(T,B,U){const X=new i;U.forEach(function($){X.put($.mode.bit,4),X.put($.getLength(),b.getCharCountIndicator($.mode,T)),$.write(X)});const _=t.getSymbolTotalCodewords(T),I=h.getTotalCodewordsCount(T,B),H=(_-I)*8;for(X.getLengthInBits()+4<=H&&X.put(0,4);X.getLengthInBits()%8!==0;)X.putBit(0);const Y=(H-X.getLengthInBits())/8;for(let $=0;$<Y;$++)X.put($%2?17:236,8);return L(X,T,B)}function L(T,B,U){const X=t.getSymbolTotalCodewords(B),_=h.getTotalCodewordsCount(B,U),I=X-_,H=h.getBlocksCount(B,U),Y=X%H,$=H-Y,F=Math.floor(X/H),P=Math.floor(I/H),G=P+1,re=F-P,be=new f(re);let R=0;const M=new Array(H),te=new Array(H);let k=0;const W=new Uint8Array(T.buffer);for(let fe=0;fe<H;fe++){const ke=fe<$?P:G;M[fe]=W.slice(R,R+ke),te[fe]=be.encode(M[fe]),R+=ke,k=Math.max(k,ke)}const ue=new Uint8Array(X);let me=0,Q,oe;for(Q=0;Q<k;Q++)for(oe=0;oe<H;oe++)Q<M[oe].length&&(ue[me++]=M[oe][Q]);for(Q=0;Q<re;Q++)for(oe=0;oe<H;oe++)ue[me++]=te[oe][Q];return ue}function J(T,B,U,X){let _;if(Array.isArray(T))_=v.fromArray(T);else if(typeof T=="string"){let F=B;if(!F){const P=v.rawSplit(T);F=p.getBestVersionForData(P,U)}_=v.fromString(T,F||40)}else throw new Error("Invalid data");const I=p.getBestVersionForData(_,U);if(!I)throw new Error("The amount of data is too big to be stored in a QR Code");if(!B)B=I;else if(B<I)throw new Error(`
|
|
41
|
+
The chosen QR Code version cannot contain this amount of data.
|
|
42
|
+
Minimum version required to store current data is: `+I+`.
|
|
43
|
+
`);const H=D(B,U,_),Y=t.getSymbolSize(B),$=new l(Y);return w($,B),j($),N($,B),E($,U,0),B>=7&&C($,B),A($,H),isNaN(X)&&(X=c.getBestMask($,E.bind(null,$,U))),c.applyMask(X,$),E($,U,X),{modules:$,version:B,errorCorrectionLevel:U,maskPattern:X,segments:_}}return dd.create=function(B,U){if(typeof B>"u"||B==="")throw new Error("No input text");let X=r.M,_,I;return typeof U<"u"&&(X=r.from(U.errorCorrectionLevel,r.M),_=p.from(U.version),I=c.from(U.maskPattern),U.toSJISFunc&&t.setToSJISFunction(U.toSJISFunc)),J(B,_,X,I)},dd}var Rd={},zd={},Uy;function pv(){return Uy||(Uy=1,(function(t){function r(i){if(typeof i=="number"&&(i=i.toString()),typeof i!="string")throw new Error("Color should be defined as hex string");let l=i.slice().replace("#","").split("");if(l.length<3||l.length===5||l.length>8)throw new Error("Invalid hex color: "+i);(l.length===3||l.length===4)&&(l=Array.prototype.concat.apply([],l.map(function(d){return[d,d]}))),l.length===6&&l.push("F","F");const o=parseInt(l.join(""),16);return{r:o>>24&255,g:o>>16&255,b:o>>8&255,a:o&255,hex:"#"+l.slice(0,6).join("")}}t.getOptions=function(l){l||(l={}),l.color||(l.color={});const o=typeof l.margin>"u"||l.margin===null||l.margin<0?4:l.margin,d=l.width&&l.width>=21?l.width:void 0,c=l.scale||4;return{width:d,scale:d?4:c,margin:o,color:{dark:r(l.color.dark||"#000000ff"),light:r(l.color.light||"#ffffffff")},type:l.type,rendererOpts:l.rendererOpts||{}}},t.getScale=function(l,o){return o.width&&o.width>=l+o.margin*2?o.width/(l+o.margin*2):o.scale},t.getImageWidth=function(l,o){const d=t.getScale(l,o);return Math.floor((l+o.margin*2)*d)},t.qrToImageData=function(l,o,d){const c=o.modules.size,h=o.modules.data,f=t.getScale(c,d),p=Math.floor((c+d.margin*2)*f),y=d.margin*f,b=[d.color.light,d.color.dark];for(let v=0;v<p;v++)for(let w=0;w<p;w++){let j=(v*p+w)*4,N=d.color.light;if(v>=y&&w>=y&&v<p-y&&w<p-y){const C=Math.floor((v-y)/f),E=Math.floor((w-y)/f);N=b[h[C*c+E]?1:0]}l[j++]=N.r,l[j++]=N.g,l[j++]=N.b,l[j]=N.a}}})(zd)),zd}var Hy;function XS(){return Hy||(Hy=1,(function(t){const r=pv();function i(o,d,c){o.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 l(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(d,c,h){let f=h,p=c;typeof f>"u"&&(!c||!c.getContext)&&(f=c,c=void 0),c||(p=l()),f=r.getOptions(f);const y=r.getImageWidth(d.modules.size,f),b=p.getContext("2d"),v=b.createImageData(y,y);return r.qrToImageData(v.data,d,f),i(b,p,y),b.putImageData(v,0,0),p},t.renderToDataURL=function(d,c,h){let f=h;typeof f>"u"&&(!c||!c.getContext)&&(f=c,c=void 0),f||(f={});const p=t.render(d,c,f),y=f.type||"image/png",b=f.rendererOpts||{};return p.toDataURL(y,b.quality)}})(Rd)),Rd}var _d={},Py;function ZS(){if(Py)return _d;Py=1;const t=pv();function r(o,d){const c=o.a/255,h=d+'="'+o.hex+'"';return c<1?h+" "+d+'-opacity="'+c.toFixed(2).slice(1)+'"':h}function i(o,d,c){let h=o+d;return typeof c<"u"&&(h+=" "+c),h}function l(o,d,c){let h="",f=0,p=!1,y=0;for(let b=0;b<o.length;b++){const v=Math.floor(b%d),w=Math.floor(b/d);!v&&!p&&(p=!0),o[b]?(y++,b>0&&v>0&&o[b-1]||(h+=p?i("M",v+c,.5+w+c):i("m",f,0),f=0,p=!1),v+1<d&&o[b+1]||(h+=i("h",y),y=0)):f++}return h}return _d.render=function(d,c,h){const f=t.getOptions(c),p=d.modules.size,y=d.modules.data,b=p+f.margin*2,v=f.color.light.a?"<path "+r(f.color.light,"fill")+' d="M0 0h'+b+"v"+b+'H0z"/>':"",w="<path "+r(f.color.dark,"stroke")+' d="'+l(y,p,f.margin)+'"/>',j='viewBox="0 0 '+b+" "+b+'"',C='<svg xmlns="http://www.w3.org/2000/svg" '+(f.width?'width="'+f.width+'" height="'+f.width+'" ':"")+j+' shape-rendering="crispEdges">'+v+w+`</svg>
|
|
44
|
+
`;return typeof h=="function"&&h(null,C),C},_d}var Fy;function JS(){if(Fy)return ys;Fy=1;const t=_S(),r=KS(),i=XS(),l=ZS();function o(d,c,h,f,p){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?(p=h,h=c,c=f=void 0):b===3&&(c.getContext&&typeof p>"u"?(p=f,f=void 0):(p=f,f=h,h=c,c=void 0))}else{if(b<1)throw new Error("Too few arguments provided");return b===1?(h=c,c=f=void 0):b===2&&!c.getContext&&(f=h,h=c,c=void 0),new Promise(function(w,j){try{const N=r.create(h,f);w(d(N,c,f))}catch(N){j(N)}})}try{const w=r.create(h,f);p(null,d(w,c,f))}catch(w){p(w)}}return ys.create=r.create,ys.toCanvas=o.bind(null,i.render),ys.toDataURL=o.bind(null,i.renderToDataURL),ys.toString=o.bind(null,function(d,c,h){return l.render(d,h)}),ys}var WS=JS();const ej=zo(WS),tj={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 nj(t){const r={...tj,...t.labels},i=Ar(t.authorization),[l,o]=x.useState({}),[d,c]=x.useState({}),[h,f]=x.useState(),[p,y]=x.useState(!1),[b,v]=x.useState(Date.now()),w=Math.min(t.authorization.expiresAt?Date.parse(t.authorization.expiresAt):1/0,i?Date.parse(i.expiresAt):1/0),j=i?.kind==="qr-code"&&i.qr?Date.parse(i.qr.challengeExpiresAt):1/0,N=i?.kind==="qr-code"&&i.phase!=="expired"?i.qr?.payload:void 0;if(x.useEffect(()=>{o({}),c({})},[t.authorization.id,i?.id]),x.useEffect(()=>{v(Date.now());const T=[w,j].filter(B=>Number.isFinite(B)&&B>Date.now()).map(B=>setTimeout(()=>v(Date.now()),B-Date.now()+1));return()=>{for(const B of T)clearTimeout(B)}},[w,j]),x.useEffect(()=>{let T=!0;if(f(void 0),y(!1),!N||N.length>4096||j<=Date.now()){N&&N.length>4096&&y(!0);return}return ej.toDataURL(N,{width:220,margin:2,errorCorrectionLevel:"M"}).then(B=>{T&&f(B)}).catch(()=>{T&&y(!0)}),()=>{T=!1}},[N,j]),t.authorization.state!=="pending"){const T=t.authorization.state==="connected"?t.authorization.connection?r.connected:r.processing:t.authorization.state==="cancelled"?r.cancelled:t.authorization.errorCode==="authorization_expired"?r.expired:r.failed;return a.jsx("p",{className:"link-authorization-status",role:"status",children:T})}if(!i)return a.jsx("p",{role:"alert",children:r.unsupported});if(!Number.isFinite(w)||w<=b)return a.jsx("p",{className:"link-authorization-status",role:"status",children:r.expired});const C=!!t.busy,E=(T,B)=>t.onRespond({stepId:i.id,operation:T,...B?{input:B}:{}}),A=T=>{if(t.canOpenUrl===!1)return null;const B=V1(T);return B?a.jsxs("button",{type:"button",disabled:C,onClick:()=>t.onOpenUrl(B),children:[r.openPage," ↗"]}):a.jsx("p",{role:"alert",children:r.invalidUrl})},D=a.jsxs("p",{className:"link-authorization-expires",children:[r.expiresAt," ",new Date(w).toLocaleTimeString()]}),L=t.authorization.errorCode?a.jsx("p",{className:"link-authorization-error",role:"alert",children:t.authorization.errorCode==="provider_rejected"?r.rejected:t.authorization.errorCode==="cli_unavailable"?r.cliUnavailable:r.failed}):null,J=()=>{switch(i.kind){case"redirect":return a.jsxs("div",{className:"link-authorization-step",role:"status",children:[a.jsx("p",{children:r.waitingBrowser}),A(i.authorizationUrl),D]});case"device-code":return a.jsxs("div",{className:"link-authorization-step link-authorization-device",children:[a.jsx("p",{children:r.deviceInstruction}),a.jsx("strong",{className:"link-authorization-code",children:i.userCode}),a.jsxs("div",{className:"link-authorization-actions",children:[t.onCopy&&a.jsx("button",{type:"button",onClick:()=>t.onCopy?.(i.userCode),children:r.copy}),A(i.verificationUriComplete??i.verificationUri)]}),D]});case"qr-code":{const T=i.phase==="expired"||j<=b;return a.jsxs("div",{className:"link-authorization-step link-authorization-qr",children:[a.jsx("p",{role:"status",children:T?r.qrExpired:i.phase==="awaiting-confirmation"?r.confirmOnPhone:r.scan}),!T&&h&&a.jsx("img",{width:220,height:220,src:h,alt:r.qrAlt}),!T&&p&&a.jsx("p",{role:"alert",children:r.qrError}),!T&&i.qr?.instructions.map((B,U)=>a.jsx("p",{children:B},U)),i.canRefresh&&a.jsx("button",{type:"button",disabled:C,onClick:()=>E("refresh-qr"),children:r.refreshQr}),D]})}case"credential-input":return a.jsxs("form",{className:"link-authorization-step link-authorization-fields",onSubmit:T=>{if(T.preventDefault(),C)return;const B={};for(const U of i.fields)B[U.id]=l[U.id]??"";o({}),E("submit",B)},children:[i.purpose!=="credential"&&a.jsx("p",{children:i.purpose==="verification-code"?r.verifyCode:r.secondFactor}),i.fields.map(T=>a.jsxs("label",{children:[T.label,a.jsx("input",{name:T.id,type:T.secret?"password":"text",autoComplete:"off",spellCheck:!1,value:l[T.id]??"",placeholder:T.placeholder,maxLength:Math.min(T.maxLength??16384,16384),required:T.required,disabled:C,onChange:B=>o(U=>({...U,[T.id]:B.target.value}))})]},T.id)),a.jsx("button",{type:"submit",disabled:C||i.fields.some(T=>T.required&&!l[T.id]?.trim()),children:r.submit}),D]});case"local-session":return a.jsxs("div",{className:"link-authorization-step",children:[a.jsx("p",{role:"status",children:i.session.authenticated?`${r.authenticated}${i.session.account?`:${i.session.account}`:""}`:i.session.installed?r.notAuthenticated:r.notInstalled}),i.session.message&&a.jsx("p",{children:i.session.message}),a.jsxs("div",{className:"link-authorization-actions",children:[a.jsx("button",{type:"button",disabled:C,onClick:()=>E("detect-session"),children:r.detectSession}),!i.session.authenticated&&i.session.canLogin&&a.jsx("button",{type:"button",disabled:C,onClick:()=>E("login-session"),children:r.loginSession}),i.session.authenticated&&a.jsx("button",{type:"button",disabled:C,onClick:()=>E("bind-session"),children:r.bindSession})]}),D]});case"consent":{const T=d.permissions??i.permissions.filter(X=>X.required).map(X=>X.id),B=(X,_,I,H)=>c(Y=>({...Y,[X]:I?[...new Set([...H,_])]:H.filter($=>$!==_)})),U=i.resourceGroups.some(X=>{const _=(d[X.id]??[]).length;return _<(X.minSelected??0)||_>(X.maxSelected??1/0)||X.truncated});return a.jsxs("form",{className:"link-authorization-step link-authorization-consent",onSubmit:X=>{X.preventDefault(),!C&&!U&&E("confirm",{...d,permissions:T})},children:[a.jsx("p",{children:a.jsx("strong",{children:i.account.label})}),a.jsx("div",{children:i.permissions.map(X=>a.jsxs("label",{children:[a.jsx("input",{type:"checkbox",checked:X.required||T.includes(X.id),disabled:C||X.required,onChange:_=>B("permissions",X.id,_.target.checked,T)}),X.label,X.description&&a.jsx("small",{children:X.description})]},X.id))}),i.resourceGroups.map(X=>a.jsxs("fieldset",{children:[a.jsx("legend",{children:X.label}),X.items.map(_=>a.jsxs("label",{children:[a.jsx("input",{type:"checkbox",checked:(d[X.id]??[]).includes(_.id),disabled:C,onChange:I=>B(X.id,_.id,I.target.checked,d[X.id]??[])}),_.label,_.description&&a.jsx("small",{children:_.description})]},_.id)),X.truncated&&a.jsx("p",{children:r.resourcesTruncated})]},X.id)),a.jsx("button",{type:"submit",disabled:C||U,children:r.confirm}),D]})}case"processing":return a.jsx("p",{className:"link-authorization-status",role:"status",children:r.processing});default:return a.jsx("p",{role:"alert",children:r.unsupported})}};return a.jsxs(a.Fragment,{children:[L,J()]})}const Xn="/api/v1/links",rj={connected:"已连接",expired:"授权已过期",invalid:"需要重新连接",unavailable:"凭据不可用"};function bs(t){try{const r=new URL(t??"");return r.protocol==="https:"&&!r.username&&!r.password?r.href:void 0}catch{return}}function ij(t){const r=x.useRef(!1),i=x.useRef(new Set);x.useLayoutEffect(()=>{r.current=!0;const c=f=>{const p=f instanceof FocusEvent&&f.type==="focusout"?f.relatedTarget:f.target;if(!(!(p instanceof Node)||p===document.body&&f.type!=="pointerdown"))for(const y of i.current)!y.source.contains(p)&&!(y.dialog&&t.current?.contains(p))&&(y.cancelled=!0)},h=()=>{for(const f of i.current)f.cancelled=!0};return document.addEventListener("pointerdown",c,!0),document.addEventListener("focusin",c,!0),document.addEventListener("focusout",c,!0),window.addEventListener("blur",h),()=>{r.current=!1,h(),i.current.clear(),document.removeEventListener("pointerdown",c,!0),document.removeEventListener("focusin",c,!0),document.removeEventListener("focusout",c,!0),window.removeEventListener("blur",h)}},[t]);const l=x.useCallback((c=document.activeElement,h=!1)=>{if(!(c instanceof HTMLElement)||c===document.body)return null;const f={source:c,cancelled:!1,dialog:h};return i.current.add(f),f},[]),o=x.useCallback(c=>{c&&(c.cancelled=!0,i.current.delete(c))},[]),d=x.useCallback((c,h,f=!1)=>{const p=document.activeElement,y=r.current&&c&&!c.cancelled&&(f||p===document.body||p===c.source||!p?.isConnected||c.dialog&&t.current?.contains(p));o(c),y&&h?.isConnected&&!h.matches(":disabled")&&h.focus()},[o,t]);return{capture:l,discard:o,finish:d}}function sj({onAuthLost:t,onDirtyChange:r,hostLabel:i="服务端",configurationVersion:l=0}){const[o,d]=x.useState(),[c,h]=x.useState(),[f,p]=x.useState(""),[y,b]=x.useState(""),[v,w]=x.useState(""),[j,N]=x.useState(!0),[C,E]=x.useState(!1),[A,D]=x.useState(),[L,J]=x.useState(),[T,B]=x.useState(),[U,X]=x.useState(),_=x.useRef(new Map),I=x.useRef(new Set),[H,Y]=x.useState(),$=x.useMemo(()=>new K1({begin:async(O,le)=>{const we=Cs(),{workspace:Z,projectId:Te}=we,V=await Je(Dt(`${Xn}/authorizations`,Z,Te),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...O,authModeId:le})},we);return _.current.set(V.id,{target:Dt(`${Xn}/authorizations/${encodeURIComponent(V.id)}`,Z,Te),scope:we}),V},status:O=>{const le=_.current.get(O);return Je(le.target,{},le.scope)},respond:(O,le)=>{const we=_.current.get(O),Z=new URL(we.target,window.location.origin);return Z.pathname+="/responses",Je(Z.pathname+Z.search,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(le)},we.scope)},cancel:async O=>{if(I.current.has(O))return;const le=_.current.get(O);le&&(await Je(le.target,{method:"DELETE",keepalive:!0},le.scope),_.current.delete(O))}}),[]),F=x.useSyncExternalStore($.subscribe,$.getSnapshot),P=o?.capabilities.authorizationSteps===1&&!!c?.provider.authModes,G=P&&F.authorization?.state==="pending",[re,be]=x.useState(0),R=x.useRef(!1),M=x.useRef(0),te=x.useRef(null),k=ij(te),W=x.useRef(null),ue=x.useRef(null),me=x.useRef(null),Q=x.useRef(null),oe=x.useRef(new Map),fe=x.useRef(new Map),ke=x.useRef(null),_e=x.useRef(null),[Me,Ce]=x.useState(""),[qe,Ge]=x.useState(null),lt=x.useRef(void 0),De=x.useRef(void 0),Oe=x.useRef(void 0),ht=x.useRef(void 0),at=x.useRef({onAuthLost:t,onDirtyChange:r});at.current={onAuthLost:t,onDirtyChange:r};const dt=C||F.busy||G||T?.state==="pending"||!!(c&&(c.token||c.label!==(c.original?.label??c.provider.displayName))),Ke=x.useCallback(O=>{O instanceof it&&O.status===401?at.current.onAuthLost():b(O instanceof Error?O.message:"连接操作失败,请重试。")},[]),rt=()=>{k.discard(me.current);const O=document.activeElement;return me.current=te.current?.contains(O)?k.capture(O):Q.current?.source===O?k.capture(O,!0):null,Ce(""),me.current},Ve=(O,le=null,we=te.current)=>{!(O instanceof it&&O.status===401)&&we&&we===te.current?(Ce(O instanceof Error?O.message:"连接操作失败,请重试。"),Ge(le)):(k.discard(le),Ke(O))};x.useLayoutEffect(()=>{if(c){if(W.current){const O=W.current;W.current=null,k.finish(O,te.current?.querySelector("input:not(:disabled), button:not(:disabled)")??null,!0)}qe&&!C&&!F.busy&&(Ge(null),k.finish(qe,_e.current))}else if(!C&&!F.busy&&T?.state!=="pending"){const O=ue.current;ue.current=null;const le=Q.current;Q.current=null;const we=le?.source.isConnected?le.source:le?.connection?oe.current.get(le.connection):le?fe.current.get(le.provider):null;k.finish(O,we?.isConnected&&!we.matches(":disabled")?we:ke.current)}},[T?.state,C,c,k,qe,F.busy]),x.useLayoutEffect(()=>{const O=te.current;if(!c||!O)return;let le=!0;const we=()=>{const Te=document.activeElement;if(!le||!(Te instanceof HTMLElement)||!O.contains(Te))return;const V=O.getBoundingClientRect(),ge=Te.getBoundingClientRect(),Ye=V.top+O.clientTop,Ct=Ye+O.clientHeight;ge.top<Ye?O.scrollTop+=ge.top-Ye:ge.bottom>Ct&&(O.scrollTop+=ge.bottom-Ct)},Z=new ResizeObserver(we);return Z.observe(O),O.addEventListener("focusin",we),window.addEventListener("resize",we),()=>{le=!1,Z.disconnect(),O.removeEventListener("focusin",we),window.removeEventListener("resize",we)}},[!!c]),x.useEffect(()=>{at.current.onDirtyChange?.(dt)},[dt]),x.useEffect(()=>{R.current=!0;const O=++M.current;return()=>{R.current=!1,at.current.onDirtyChange?.(!1),lt.current?.abort(),queueMicrotask(()=>{M.current===O&&$.dispose()}),De.current&&Je(De.current,{method:"DELETE",keepalive:!0},Oe.current).catch(()=>{})}},[$]),x.useEffect(()=>{const O=new AbortController;return ht.current=O,N(!0),Je(Xn,{signal:O.signal}).then(le=>{O.signal.aborted||d(le)}).catch(le=>{O.signal.aborted||Ke(le)}).finally(()=>{O.signal.aborted||N(!1)}),()=>O.abort()},[re,l,Ke]),x.useEffect(()=>{if(P){if(F.error){const O=me.current;me.current=null,Ve(F.error,O)}else F.busy||(k.discard(me.current),me.current=null);F.authorization?.state==="connected"&&F.authorization.connection&&(h(void 0),w("授权完成,连接已保存。"),be(O=>O+1))}},[P,F.authorization,F.error,Ke]),x.useEffect(()=>{if(!o?.remoteCleanupPending)return;const O=setInterval(()=>be(le=>le+1),3e4);return()=>clearInterval(O)},[o?.remoteCleanupPending]),x.useEffect(()=>{if(T?.state!=="pending"||!De.current)return;const O=De.current,le=Oe.current,we=new AbortController;let Z;const Te=async()=>{try{const V=await Je(O,{signal:we.signal},le);if(we.signal.aborted||De.current!==O)return;B(V),V.state==="connected"?(De.current=void 0,h(void 0),w("授权完成,连接已保存。"),be(ge=>ge+1)):V.state!=="pending"?(De.current=void 0,b(V.state==="cancelled"?"授权已取消。":"授权未完成或已过期,请重新开始。")):Z=setTimeout(()=>{Te()},2e3)}catch(V){if(we.signal.aborted||De.current!==O)return;Ke(V),V instanceof it&&[401,404].includes(V.status)?(De.current=void 0,B(ge=>ge?{...ge,state:"failed"}:void 0)):Z=setTimeout(()=>{Te()},4e3)}};return Z=setTimeout(()=>{Te()},1e3),()=>{we.abort(),clearTimeout(Z)}},[T?.id,T?.state,Ke]);async function nt(O,le){if(lt.current)return;const we=new AbortController,Z=te.current,Te=Z?.contains(document.activeElement)?k.capture():null;Ce(""),lt.current=we,ht.current?.abort(),E(!0),N(!1),b(""),w("");try{const V=await O(we.signal);R.current&&!we.signal.aborted&&le(V),k.discard(Te)}catch(V){R.current&&!we.signal.aborted&&(Ve(V,Te,Z),V instanceof it&&[409,503].includes(V.status)&&be(ge=>ge+1))}finally{lt.current===we&&(lt.current=void 0),R.current&&E(!1)}}function q(O,le,we,Z,Te){return Je(O,{method:le,headers:{"Content-Type":"application/json"},body:JSON.stringify(we),signal:Z},Te)}function ne(){return{providerId:c.provider.id,methodId:c.methodId,label:c.label.trim(),expectedRevision:c.original?.revision??null,...c.original?{connectionId:c.original.id}:{}}}function Ee(){h(void 0),J(void 0),w("连接已保存。"),be(O=>O+1)}function xe(O,le,we=document.activeElement){if(C||F.busy||G||T?.state==="pending"||dt&&!window.confirm("放弃当前未保存的连接修改?"))return;$.reset();const Z=le?Zc(O,le.methodId):Zc(O),Te=le?O.connectionMethods.find(ge=>ge.id===le.methodId):O.connectionMethods.find(ge=>ge.id===Z?.methodId)??O.connectionMethods.find(ge=>ge.executionRuntime==="local"&&ge.availability==="available");if(!Te){b("当前环境未提供此连接的授权方式,请检查服务器连接设置。");return}k.discard(W.current),k.discard(ue.current),k.discard(me.current),W.current=k.capture(we),ue.current=k.capture(we,!0),me.current=null,Q.current=we instanceof HTMLElement?{source:we,connection:le?.id,provider:O.id}:null,Ce("");const V={provider:O,original:le,methodId:Te.id,label:le?.label??O.displayName,token:""};h(V),J(void 0),B(void 0),X(Z?.id),b(""),w(""),!le&&o?.capabilities.authorizationSteps===1&&Z&&ze(V,Z)}async function ze(O,le){if(!le.available||!O.label.trim()||(rt(),$.getSnapshot().authorization?.state==="pending"&&(await $.cancel(),$.getSnapshot().authorization?.state==="pending")))return;b(""),X(le.id),h({...O,methodId:le.methodId});const we={workspace:jo()??"",projectId:Dl()},Z=await $.begin({providerId:O.provider.id,methodId:le.methodId,label:O.label.trim(),expectedRevision:O.original?.revision??null,...O.original?{connectionId:O.original.id}:{}},le.id);if(!(Z?.state!=="pending"||Ar(Z)?.kind!=="redirect"))try{if(o?.capabilities.browserHandoff===1){const ge=_.current.get(Z.id),Ye=new URL(ge.target,window.location.origin);Ye.pathname+="/browser";const Ct=await Je(Ye.pathname+Ye.search,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"},ge.scope),he=new URL(Ct.launchUrl);if(he.origin!==window.location.origin||he.pathname!=="/link/authorize"||he.username||he.password||he.hash||he.searchParams.size!==1||!/^[A-Za-z0-9_-]{43}$/.test(he.searchParams.get("ticket")??""))throw new Error("授权浏览器入口无效,请重新连接。");$.getSnapshot().authorization?.id===Z.id&&$.getSnapshot().authorization?.state==="pending"&&Y({id:Z.id,url:he.href});return}const Te=o?.remoteServer?.issuer;if(!Te)throw new Error("当前 Host 尚未配置授权服务。");const V=J1(Z,Te,we);I.current.add(Z.id),dS.flushSync(()=>{h(void 0),at.current.onDirtyChange?.(!1)}),window.location.assign(V)}catch(Te){await $.cancel(),Ve(Te)}}async function Le(){if(G){rt(),await $.cancel(),$.getSnapshot().authorization?.state==="cancelled"&&w("授权已取消。");return}if(!De.current)return;const O=De.current,le=Oe.current;await nt(we=>Je(O,{method:"DELETE",signal:we},le),()=>{De.current=void 0,B(void 0),w("授权已取消。")})}function se(){P?(rt(),$.cancel().then(()=>{$.getSnapshot().authorization?.state!=="pending"&&h(void 0)})):!Ue&&(!dt||window.confirm("放弃未保存的连接修改?"))&&h(void 0)}function Re(O,le=Cs()){if(P&&$.getSnapshot().authorization?.state==="pending"&&c?.original?.id===O.id){$.cancel().then(()=>{$.getSnapshot().authorization?.state!=="pending"&&Re(O,le)});return}const we=c?.original?.id===O.id&&T?.state==="pending"?De.current:void 0,Z=Dt(`${Xn}/connections/${encodeURIComponent(O.id)}`,le.workspace,le.projectId),Te=Oe.current;nt(async V=>{if(we){try{await Je(we,{method:"DELETE",signal:V},Te)}catch(ge){if(!(ge instanceof it&&ge.status===404))throw ge}R.current&&!V.aborted&&De.current===we&&(De.current=void 0,B(void 0))}return q(Z,"DELETE",{expectedRevision:O.revision},V,le)},()=>{c?.original?.id===O.id&&h(void 0),D(void 0),be(V=>V+1),w("连接已断开。")})}const Ne=c?.provider.connectionMethods.find(O=>O.id===c.methodId),Qe=T?.state==="pending",Ue=C||F.busy||Qe||G,bt=f.trim().toLowerCase(),pt=(o?.providers??[]).filter(O=>(o?.capabilities.authorizationSteps!==1||O.authModes?.some(le=>le.available))&&`${O.displayName} ${O.description.zh}`.toLowerCase().includes(bt)),Be=c&&o?.connections.find(O=>c.original?O.id===c.original.id:O.id===`link-${c.provider.id}-${c.methodId}`&&O.providerId===c.provider.id&&O.methodId===c.methodId),ie=c&&o&&(c.original?Be?.revision!==c.original.revision:!!Be);return a.jsxs("section",{className:"hub-links",children:[a.jsxs("header",{className:"links-heading",children:[a.jsxs("div",{children:[a.jsx("h1",{children:"Link"}),a.jsx("p",{children:"连接你的工具与账号,让任务访问已授权的服务。"})]}),a.jsx("button",{onClick:()=>{b(""),be(O=>O+1)},disabled:C||j,children:"刷新"})]}),!!o?.remoteCleanupPending&&a.jsxs("p",{role:"status",className:"links-muted",children:["有 ",o.remoteCleanupPending," 项遗留授权等待撤销。项目所在环境 会自动重试,重启后仍会继续;也可在 Link 服务中撤销。"]}),a.jsxs("p",{className:"links-host",children:["连接由当前项目所属的",i,"管理,授权后只访问你允许的服务与资源。"]}),y&&a.jsx("p",{className:"form-error",role:"alert",children:y}),v&&a.jsx("p",{className:"links-notice",role:"status",children:v}),j&&!o&&a.jsx("p",{role:"status",children:"正在加载连接…"}),a.jsx("h2",{children:"已连接"}),o&&o.connections.length===0&&a.jsx("p",{className:"links-muted",children:"还没有连接。选择下面的服务开始。"}),a.jsx("div",{className:"links-connections",children:o?.connections.map(O=>{const le=o.providers.find(we=>we.id===O.providerId);return a.jsxs("article",{className:"links-connection",children:[a.jsxs("div",{children:[a.jsx("strong",{children:O.label}),a.jsxs("p",{children:[le?.displayName??O.providerId," ·"," ",O.account?.label??O.account?.id??"已授权账号"]}),a.jsx("span",{className:`links-state ${O.status==="connected"?"ready":""}`,children:rj[O.status]}),a.jsxs("small",{children:[O.authSource==="remote-link"?"独立 Link 授权":O.authSource==="cli-session"?"CLI 登录":O.authSource==="browser-oauth"?"浏览器授权":"Token",O.expiresAt?` · 到期 ${new Date(O.expiresAt).toLocaleString()}`:""]}),O.account?.resources.length?a.jsx("p",{children:O.account.resources.join("、")}):null]}),a.jsx("div",{className:"links-actions",children:O.editable?a.jsxs(a.Fragment,{children:[a.jsx("button",{disabled:Ue||!le,ref:we=>{we?oe.current.set(O.id,we):oe.current.delete(O.id)},onClick:we=>le&&xe(le,O,we.currentTarget),children:"管理连接"}),a.jsx("button",{disabled:C,onClick:()=>D(O),children:"断开"})]}):a.jsx("small",{children:"项目配置管理"})})]},O.id)})}),A&&a.jsxs("div",{className:"links-confirm",role:"alertdialog","aria-label":"断开连接",children:[a.jsxs("p",{children:["断开「",A.label,"」后,后续任务将无法使用这个连接,正在执行的请求会尝试停止。"]}),a.jsx("button",{disabled:C,onClick:()=>Re(A),children:"确认断开"}),a.jsx("button",{disabled:C,onClick:()=>D(void 0),children:"取消"})]}),c&&Ne&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"links-editor-backdrop","aria-hidden":"true"}),a.jsxs("section",{className:"links-editor",ref:te,onKeyDown:O=>{if(O.nativeEvent.isComposing||O.keyCode===229||(O.key==="Escape"&&(O.preventDefault(),se()),O.key!=="Tab"))return;const le=Array.from(te.current?.querySelectorAll('button:not(:disabled), input:not(:disabled), a[href], summary, [tabindex]:not([tabindex="-1"])')??[]).filter(Te=>Te.getClientRects().length>0&&getComputedStyle(Te).visibility!=="hidden");if(!le?.length)return;const we=le[0],Z=le[le.length-1];O.shiftKey&&document.activeElement===we?(O.preventDefault(),Z.focus()):!O.shiftKey&&document.activeElement===Z&&(O.preventDefault(),we.focus())},role:"dialog","aria-modal":"true","aria-label":`${c.provider.displayName} 连接设置`,children:[a.jsxs("div",{className:"links-heading",children:[a.jsxs("h2",{children:[c.provider.displayName," · ",c.original?"管理连接":"添加连接"]}),a.jsx("button",{disabled:!P&&Ue,onClick:se,children:"关闭"})]}),Me&&a.jsx("p",{ref:_e,className:"form-error links-editor-error",role:"alert",tabIndex:0,"aria-label":"连接操作失败",children:Me}),a.jsxs("label",{children:["连接名称",a.jsx("input",{maxLength:100,value:c.label,disabled:Ue,onChange:O=>h({...c,label:O.target.value})})]}),ie&&a.jsxs("div",{className:"links-conflict",role:"alert",children:[a.jsx("p",{children:"这个连接已在其他设备创建、修改或删除。你的输入仍然保留,请先载入最新版本。"}),a.jsx("button",{disabled:Ue,onClick:()=>h({...c,original:Be||void 0}),children:"载入最新版本,保留输入"})]}),P?a.jsxs("div",{className:"links-authorization",children:[a.jsx("p",{className:"links-muted",children:Ne.executionRuntime==="server"?"由 Link 服务保存授权并访问已选择的资源。":`连接保存到当前项目所属的${i}。`}),F.authorization?a.jsx(nj,{authorization:F.authorization,busy:F.busy||!!ie||o?.capabilities.browserHandoff===1&&Ar(F.authorization)?.kind==="redirect"&&H?.id!==F.authorization.id,onRespond:O=>{rt(),$.respond(O)},onOpenUrl:O=>{const we=o?.capabilities.browserHandoff===1&&Ar(F.authorization)?.kind==="redirect"?H&&H.id===F.authorization?.id?H.url:void 0:O;we&&window.open(we,"_blank","noopener,noreferrer")},onCopy:O=>{navigator.clipboard?.writeText(O).catch(Ke)}}):a.jsx("button",{disabled:F.busy||!!ie||!c.label.trim(),onClick:()=>{const O=c.provider.authModes?.find(le=>le.id===U&&le.available)??Zc(c.provider,c.methodId);O&&ze(c,O)},children:F.busy?"正在连接…":c.original?"重新连接":"开始连接"}),a.jsxs("div",{className:"links-actions",children:[G&&a.jsx("button",{disabled:F.busy,onClick:()=>{Le()},children:"取消授权"}),F.authorization&&F.authorization.state!=="pending"&&a.jsx("button",{disabled:F.busy||!!ie||!c.label.trim(),onClick:()=>{const O=c.provider.authModes?.find(le=>le.id===U&&le.available);O&&ze(c,O)},children:"重新连接"})]}),a.jsxs("details",{className:"links-other-methods",children:[a.jsx("summary",{children:"其他连接方式"}),a.jsx("div",{className:"links-methods",children:c.provider.authModes?.map(O=>a.jsxs("button",{disabled:F.busy||!O.available||!!ie||!c.label.trim(),title:O.unavailableReason,onClick:()=>{ze(c,O)},children:[O.label,O.id===U?" · 当前":""]},O.id))})]}),c.original&&a.jsx("button",{disabled:Ue||!!ie||!c.label.trim(),onClick:()=>{nt(O=>q(`${Xn}/connections/${encodeURIComponent(c.original.id)}`,"PATCH",{label:c.label.trim(),expectedRevision:c.original.revision},O),Ee)},children:"保存名称"})]}):a.jsxs(a.Fragment,{children:[Ne.browserAuth&&a.jsxs("div",{className:"links-auth-option",children:[a.jsx("h3",{children:"浏览器授权"}),c.provider.deviceAuth?.configured?a.jsx("button",{disabled:Ue||!c.label.trim()||!!ie,onClick:()=>{const O=jo()??"",le=Dl(),we={workspace:O,projectId:le},Z=Dt(`${Xn}/authorizations/device`,O,le);nt(Te=>q(Z,"POST",ne(),Te,we),Te=>{De.current=Dt(`${Xn}/authorizations/${encodeURIComponent(Te.id)}`,O,le),Oe.current=we,B(Te)})},children:"开始授权"}):a.jsxs("p",{className:"links-muted",children:["这台",i,"尚未配置此服务的浏览器授权,可使用下面的连接方式。"]}),Qe&&T.prompt&&a.jsxs("div",{className:"links-device-code",role:"status",children:[a.jsx("p",{children:"在服务商页面输入验证码:"}),a.jsx("strong",{children:T.prompt.userCode}),a.jsx("p",{children:bs(T.prompt.verificationUriComplete??T.prompt.verificationUri)&&a.jsx("a",{href:bs(T.prompt.verificationUriComplete??T.prompt.verificationUri),target:"_blank",rel:"noreferrer",children:"打开授权页面 ↗"})}),a.jsxs("p",{children:["完成后会自动保存。有效期至"," ",new Date(T.prompt.expiresAt).toLocaleTimeString(),"。"]}),a.jsx("button",{disabled:C,onClick:()=>{Le()},children:"取消授权"})]})]}),Ne.quickAuth&&a.jsxs("div",{className:"links-auth-option",children:[a.jsx("h3",{children:"使用已登录的 CLI"}),a.jsxs("p",{children:[i,"需要已安装并登录 ",Ne.quickAuth.command,"。"]}),a.jsx("button",{disabled:Ue,onClick:()=>{nt(O=>Je(`${Xn}/providers/${encodeURIComponent(c.provider.id)}/cli`,{signal:O}),J)},children:"检查登录状态"}),L&&a.jsx("p",{role:"status",children:L.authenticated?`已登录${L.account?`:${L.account}`:""}`:L.installed?"已安装,尚未登录。请在运行服务的机器上登录。":"尚未安装。"}),L?.authenticated&&a.jsx("button",{disabled:Ue||!c.label.trim()||!!ie,onClick:()=>{nt(O=>q(`${Xn}/connections/cli`,"POST",ne(),O),Ee)},children:"绑定这个登录"})]}),Ne.authKind==="token"&&a.jsxs("form",{className:"links-auth-option",onSubmit:O=>{O.preventDefault(),!(Ue||ie)&&nt(le=>c.original&&!c.token.trim()?q(`${Xn}/connections/${encodeURIComponent(c.original.id)}`,"PATCH",{label:c.label.trim(),expectedRevision:c.original.revision},le):q(`${Xn}/connections/token`,"POST",{...ne(),token:c.token.trim()},le),Ee)},children:[a.jsx("h3",{children:c.original?"名称与 Token":"使用 Token"}),Ne.authGuide&&a.jsxs(a.Fragment,{children:[a.jsx("p",{children:Ne.authGuide.summary.zh}),a.jsxs("div",{className:"links-actions",children:[bs(Ne.authGuide.createCredentialUrl)&&a.jsx("a",{href:bs(Ne.authGuide.createCredentialUrl),target:"_blank",rel:"noreferrer",children:"创建凭据 ↗"}),bs(Ne.authGuide.docsUrl)&&a.jsx("a",{href:bs(Ne.authGuide.docsUrl),target:"_blank",rel:"noreferrer",children:"授权说明 ↗"})]}),a.jsxs("details",{children:[a.jsx("summary",{children:"所需权限与设置步骤"}),a.jsx("ul",{children:Ne.authGuide.permissions.map(O=>a.jsxs("li",{children:[O.label,"(",O.level==="required"?"必需":"可选",")",O.description?`:${O.description.zh}`:""]},O.id))}),a.jsx("ol",{children:Ne.authGuide.steps.map((O,le)=>a.jsx("li",{children:O.zh},le))})]})]}),a.jsxs("label",{children:[Ne.tokenLabel??c.provider.tokenLabel,a.jsx("input",{type:"password",autoComplete:"off",value:c.token,disabled:Ue,placeholder:c.original?"留空保留当前授权,仅修改名称":Ne.tokenPlaceholder??c.provider.tokenPlaceholder,onChange:O=>h({...c,token:O.target.value}),required:!c.original,maxLength:16384})]}),a.jsx("button",{type:"submit",className:"send",disabled:Ue||!!ie||!c.label.trim(),children:C?"正在验证并保存…":c.token.trim()||!c.original?"验证并保存":"保存名称"})]})]}),a.jsxs("details",{children:[a.jsxs("summary",{children:[P?"服务支持的操作":"可用操作","(",c.provider.actions.length,")"]}),P&&a.jsx("p",{className:"links-muted",children:"此连接实际可用的操作以授权时确认的权限为准。"}),a.jsx("ul",{children:c.provider.actions.map(O=>a.jsxs("li",{children:[a.jsx("strong",{children:O.title}),O.risk==="write"?" · 执行前需要确认":"",a.jsx("p",{children:O.description})]},O.id))})]})]})]}),a.jsxs("div",{className:"links-heading",children:[a.jsx("h2",{children:"添加服务"}),a.jsx("input",{type:"search","aria-label":"搜索 Link 服务",ref:ke,placeholder:"搜索服务",value:f,onChange:O=>p(O.target.value)})]}),a.jsx("div",{className:"links-providers",children:pt.map(O=>{const le=o?.connections.find(we=>we.providerId===O.id);return a.jsxs("article",{className:"links-provider",children:[a.jsx("div",{className:`links-brand accent-${O.accent}`,"aria-hidden":"true",children:O.brandText}),a.jsx("h3",{children:O.displayName}),a.jsx("p",{children:O.description.zh}),a.jsxs("small",{children:[O.actions.length," 项操作"]}),a.jsx("button",{disabled:Ue||o?.capabilities.authorizationSteps!==1&&!!(le&&!le.editable),ref:we=>{we?fe.current.set(O.id,we):fe.current.delete(O.id)},onClick:we=>xe(O,o?.capabilities.authorizationSteps===1?void 0:le,we.currentTarget),children:o?.capabilities.authorizationSteps===1?"添加连接":le?le.editable?"管理连接":"项目配置管理":"添加连接"})]},O.id)})}),o&&pt.length===0&&a.jsx("p",{className:"links-muted",children:"没有匹配的服务。"})]})}const Md="/api/v1/panels",$y="https://github.com/cjhyy/codeshell-panel-apps.git",Gy={"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 Zn(t){return t["zh-CN"]||t.default}function fo({value:t}){return t.supported&&t.reasons.length===0?null:a.jsxs("div",{className:"panels-warning",children:[a.jsx("strong",{children:t.supported?"部分功能可用":"当前 Web 工作台暂不支持此面板"}),t.supported&&a.jsx("p",{children:"可以打开面板,以下功能当前不可用或需要额外配置。"}),t.reasons.length>0&&a.jsx("ul",{children:t.reasons.map(r=>a.jsx("li",{children:r},r))})]})}function lj({onAuthLost:t,onDirtyChange:r,onChanged:i,onOpen:l,hostLabel:o="服务端",configurationVersion:d=0}){const[c,h]=x.useState(),[f,p]=x.useState(""),[y,b]=x.useState(""),[v,w]=x.useState(""),[j,N]=x.useState(""),[C,E]=x.useState(),[A,D]=x.useState(),[L,J]=x.useState(),[T,B]=x.useState(),[U,X]=x.useState(!1),[_,I]=x.useState(),[H,Y]=x.useState(),[$,F]=x.useState(!1),[P,G]=x.useState(!0),[re,be]=x.useState(!1),[R,M]=x.useState(),[te,k]=x.useState(!0),[W,ue]=x.useState(""),[me,Q]=x.useState(""),[oe,fe]=x.useState(""),[ke,_e]=x.useState(0),Me=x.useRef(!1),Ce=x.useRef(void 0),qe=x.useRef(void 0),Ge=x.useRef(!1),lt=x.useRef(void 0),De=x.useRef(null),Oe=x.useRef({onAuthLost:t,onDirtyChange:r,onChanged:i,onOpen:l});Oe.current={onAuthLost:t,onDirtyChange:r,onChanged:i,onOpen:l};function ht(V){fetch(V.target,{method:"DELETE",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify({reviewToken:V.token}),keepalive:!0,signal:AbortSignal.timeout(5e3)}).catch(()=>{})}const at=!!(W||A||L||H||R||f.trim()||y.trim()||v.trim()),dt=x.useCallback(V=>{V instanceof it&&V.status===401?Oe.current.onAuthLost():Q(V instanceof Error?V.message:"面板操作失败,请重试。")},[]);x.useEffect(()=>(Me.current=!0,()=>{Me.current=!1,Ce.current?.abort(),qe.current?.abort(),lt.current&&(ht(lt.current),lt.current=void 0),Oe.current.onDirtyChange?.(!1)}),[]),x.useEffect(()=>{Oe.current.onDirtyChange?.(at)},[at]),x.useEffect(()=>{if(Ce.current){Ge.current=!0;return}const V=new AbortController;return qe.current=V,k(!0),Je(Dt(Md),{signal:V.signal}).then(ge=>{V.signal.aborted||h(ge)}).catch(ge=>{V.signal.aborted||dt(ge)}).finally(()=>{V.signal.aborted||k(!1)}),()=>V.abort()},[ke,d,dt]),x.useEffect(()=>{A&&De.current?.focus()},[A?.reviewToken]);async function Ke(V,ge,Ye,Ct,he=!1,Ie){if(Ce.current||!Me.current)return;const Pe=new AbortController;Ce.current=Pe,qe.current?.abort(),k(!1),ue(V),Q(""),fe("");const ot=Dt(`${Md}${ge}`);try{const Fe=await Je(ot,{method:Ye,headers:{"Content-Type":"application/json"},body:JSON.stringify(Ct),signal:Pe.signal});if(Pe.signal.aborted||!Me.current){Ie?.(Fe);return}return he&&(Ge.current=!0,Oe.current.onChanged?.()),Fe}catch(Fe){if(Pe.signal.aborted||!Me.current)return;Fe instanceof it&&(Fe.status===409||Fe.status===410)&&(A&&F(!0),T&&X(!0),Ge.current=!0),dt(Fe);return}finally{Ce.current===Pe&&(Ce.current=void 0),Me.current&&!Pe.signal.aborted&&(ue(""),Ge.current&&(Ge.current=!1,_e(Fe=>Fe+1)))}}const rt=async V=>{if(!await se())return;J(void 0),B(void 0),Y(void 0),D(void 0),M(void 0),E(void 0);const ge=await Ke("正在读取仓库…","/github/discover","POST",{url:V.url,...V.ref?{ref:V.ref}:{},...V.subdir?{subdir:V.subdir}:{}});ge&&E(ge)},Ve=async V=>{if(!await se())return;J(void 0),B(void 0);const ge=await Ke("正在准备安装审阅…","/preview","POST",{source:V});ge&&(M(void 0),I(V),D(ge),F(!1),be(!1),G(!!c?.hasProject&&ge.compatibility.supported))},nt=async V=>{if(!await se())return;J(void 0),B(void 0);const ge=await Ke("正在检查更新…",`/${encodeURIComponent(V.id)}/update-preview`,"POST",{expectedRevision:V.revision});ge&&(M(void 0),I(void 0),D(ge),F(!1),be(V.bound),G(V.bound&&ge.compatibility.supported))},q=()=>{if(A)if(A.kind==="update"){const V=c?.panels.find(ge=>ge.id===A.preview.id);V?nt(V):(Q("此面板已被卸载,请重新从 GitHub 选择安装。"),D(void 0))}else _&&Ve(_)},ne=()=>{Y(void 0),E(void 0),p(""),b(""),w("")},Ee=async()=>{if(D(void 0),!H||H.position+1>=H.candidates.length){ne();return}const V=H.position+1;Y({...H,position:V}),await Ve(H.candidates[V].source)},xe=async V=>{V.length&&(Y({candidates:V,position:0}),await Ve(V[0].source))},ze=async()=>{if(!A||$)return;if(A.expiresAt<=Date.now()){F(!0),Q("安装审阅已过期,请重新审阅后继续。");return}await Ke(A.kind==="update"?"正在更新面板…":"正在安装面板…","/install","POST",{reviewToken:A.reviewToken,bind:P},!0)&&(fe(`${Zn(A.preview.title)} 已${A.kind==="update"?"更新":"安装"}${P?"并绑定当前工作区":""}。`),D(void 0),H?await Ee():ne())},Le=async V=>{const ge=await Ke(V.bound?"正在解除绑定…":"正在绑定工作区…",`/${encodeURIComponent(V.id)}/binding`,"PATCH",{bound:!V.bound,expectedRevision:V.revision},!0);ge&&(h(ge),fe(`${Zn(V.title)} 已${V.bound?"解除当前工作区绑定":"绑定当前工作区"}。`))},se=async()=>T?(await Ke("正在关闭版本审阅…","/restore/review","DELETE",{reviewToken:T.reviewToken}))?.cancelled?(lt.current=void 0,B(void 0),!0):!1:!0,Re=async()=>{await se()&&J(void 0)},Ne=async V=>{if(!await se())return;D(void 0),M(void 0),B(void 0),J(void 0);const ge=await Ke("正在检查保留版本…",`/${encodeURIComponent(V.id)}/versions`,"POST",{expectedRevision:V.revision});ge&&(J(ge),X(!1))},Qe=async V=>{if(!L||!await se())return;const ge=Dt(`${Md}/restore/review`),Ye=await Ke("正在审阅项目版本…",`/${encodeURIComponent(L.appId)}/restore-preview`,"POST",{packageDigest:V,expectedRevision:L.expectedRevision},!1,Ct=>ht({target:ge,token:Ct.reviewToken}));if(Ye){if(!Me.current){ht({target:ge,token:Ye.reviewToken});return}lt.current={target:ge,token:Ye.reviewToken},B(Ye),X(!1)}},Ue=async()=>{if(!T||Te)return;if(T.expiresAt<=Date.now()){X(!0),Q("版本审阅已过期,请重新选择版本。");return}await Ke("正在恢复项目版本…","/restore","POST",{reviewToken:T.reviewToken},!0)&&(lt.current=void 0,fe(`${Zn(T.title)} 的项目版本已恢复为 v${T.version}。`),J(void 0),B(void 0))},bt=async()=>{if(!R||c?.panels.find(ge=>ge.id===R.id)?.revision!==R.revision)return;(await Ke("正在卸载面板…",`/${encodeURIComponent(R.id)}`,"DELETE",{expectedRevision:R.revision},!0))?.removed&&(fe(`${Zn(R.title)} 已卸载。`),M(void 0))},pt=!!W||!c||!!H,Be=j.trim().toLowerCase(),ie=(c?.panels??[]).filter(V=>[Zn(V.title),V.id,V.description??"",V.source.label].join(" ").toLowerCase().includes(Be)),O=C?.panels.filter(V=>!c?.panels.some(ge=>ge.id===V.id)&&!c?.issues?.some(ge=>ge.id===V.id)&&C.panels.filter(ge=>ge.id===V.id).length===1)??[],le=R&&c?.panels.find(V=>V.id===R.id),we=!!R&&le?.revision!==R.revision,Z=A?.kind==="update"?c?.panels.find(V=>V.id===A.preview.id):void 0,Te=U||!!L&&(c?.panels.find(V=>V.id===L.appId)?.revision??c?.issues?.find(V=>V.id===L.appId)?.revision)!==L.expectedRevision;return a.jsxs("section",{className:"hub-panels",children:[a.jsxs("header",{className:"panels-heading",children:[a.jsxs("div",{children:[a.jsx("h1",{children:"面板"}),a.jsx("p",{children:"从 GitHub 安装工具面板,绑定工作区后直接在工作台中打开。"})]}),a.jsx("button",{disabled:!!W||te,onClick:()=>_e(V=>V+1),children:te?"正在刷新…":"刷新"})]}),a.jsxs("p",{className:"panels-muted",children:["面板安装在",o,"上,文件和任务操作使用当前工作区。"]}),c&&!c.hasProject&&a.jsx("div",{className:"panels-warning",children:"请先选择一个项目,才能绑定和打开面板。"}),me&&a.jsx("p",{role:"alert",className:"error",children:me}),oe&&a.jsx("p",{role:"status",className:"panels-notice",children:oe}),W&&a.jsx("p",{role:"status",className:"panels-muted",children:W}),c?.issues?.filter(V=>V.id.toLowerCase().includes(Be)).map(V=>a.jsxs("section",{className:"panels-warning","aria-label":"需要修复的面板",children:[a.jsx("h2",{children:V.id}),a.jsxs("p",{children:["项目记录版本:",V.version??"未记录","。安装包缺失或无法校验,面板暂不可用。"]}),a.jsx("p",{children:"项目数据和任务记录仍保留。可检查宿主保留的版本,审阅权限后恢复。"}),a.jsx("button",{disabled:!!W||!V.bound||!c.canRestorePackages,onClick:()=>{Ne(V)},children:"检查可用版本"})]},V.id)),L&&a.jsxs("section",{className:"panels-review","aria-label":"项目保留版本",children:[a.jsxs("header",{className:"panels-heading",children:[a.jsxs("div",{children:[a.jsxs("h2",{children:[Zn(L.title)," · 项目版本"]}),a.jsxs("p",{children:["项目记录版本:",L.current.version]})]}),a.jsx("button",{disabled:!!W,onClick:()=>{Re()},children:"关闭版本记录"})]}),a.jsx("p",{children:"选择宿主已保留的程序版本,仅切换当前项目。其他项目继续使用各自版本。"}),a.jsx("p",{className:"panels-warning",children:"切换程序版本不会恢复旧数据。请先备份项目,确认该版本支持当前文档格式;任务与产物记录会保留。"}),L.current.unavailable&&a.jsx("p",{role:"status",children:"当前安装包不可用,无法读取原权限;恢复前需重新审阅目标版本的全部权限。"}),L.unavailablePackages>0&&a.jsxs("p",{role:"status",children:["有 ",L.unavailablePackages," 个保留包无法校验,暂不能选择。"]}),!L.versions.length&&a.jsx("p",{children:"没有可用的保留版本。"}),a.jsx("div",{className:"panels-grid",children:L.versions.map(V=>a.jsxs("article",{className:"panels-card",children:[a.jsxs("h3",{children:["v",V.version]}),a.jsxs("small",{children:["内容编号 ",V.packageDigest.slice(0,12)]}),a.jsx(fo,{value:V.compatibility}),a.jsx("button",{disabled:!!W||!V.compatibility.supported||V.packageDigest===L.current.packageDigest,onClick:()=>{Qe(V.packageDigest)},children:V.packageDigest===L.current.packageDigest?"当前项目版本":`审阅 v${V.version}`})]},V.packageDigest))}),T&&a.jsxs("section",{className:"panels-confirm","aria-label":"确认恢复项目版本",children:[a.jsxs("h3",{children:["v",T.current.version," → v",T.version]}),a.jsx("h4",{children:"此版本请求的权限"}),!T.permissions.length&&a.jsx("p",{children:"未申请宿主权限。"}),T.permissions.map(V=>a.jsxs("div",{className:"panels-permission",children:[a.jsx("span",{children:Gy[V]??V}),T.addedPermissions.includes(V)&&a.jsx("strong",{children:T.current.unavailable?"需重新确认":"新增权限"})]},V)),a.jsx(fo,{value:T.compatibility}),Te&&a.jsx("p",{role:"alert",children:"项目或审阅已变化,请关闭版本记录并重新读取。"}),a.jsx("button",{disabled:!!W||Te||!T.compatibility.supported,onClick:()=>{Ue()},children:"确认权限并恢复项目版本"})]})]}),H&&a.jsxs("section",{className:"panels-confirm","aria-label":"逐个审阅面板",children:[a.jsxs("p",{children:["正在审阅第 ",H.position+1," / ",H.candidates.length," 个面板:",Zn(H.candidates[H.position].title),"。每个面板都需要单独确认安装。"]}),a.jsxs("div",{className:"panels-actions",children:[!A&&a.jsx("button",{disabled:!!W,onClick:()=>{Ve(H.candidates[H.position].source)},children:"重新读取此面板"}),a.jsx("button",{disabled:!!W,onClick:()=>{Ee()},children:"跳过此面板"}),a.jsx("button",{disabled:!!W,onClick:()=>{Y(void 0),D(void 0),Q("")},children:"取消逐个审阅"})]})]}),A&&a.jsxs("section",{className:"panels-review","aria-labelledby":"panel-review-heading",children:[a.jsxs("header",{className:"panels-heading",children:[a.jsxs("div",{children:[a.jsx("h2",{id:"panel-review-heading",ref:De,tabIndex:-1,children:A.kind==="update"?"审阅面板更新":"审阅面板安装"}),a.jsxs("p",{children:[Zn(A.preview.title)," · ",A.preview.id," · v",A.preview.version]})]}),a.jsx("button",{disabled:!!W,onClick:()=>{Y(void 0),D(void 0),Q("")},children:"取消审阅"})]}),A.preview.description&&a.jsx("p",{children:A.preview.description}),Z&&a.jsxs("p",{className:"panels-warning",children:["当前版本 v",Z.version," → 更新后 v",A.preview.version,Z.source.commit&&a.jsxs(a.Fragment,{children:[a.jsx("br",{}),"当前提交 ",a.jsx("code",{children:Z.source.commit.slice(0,12)})," → 更新提交"," ",a.jsx("code",{children:A.source.commit.slice(0,12)})]})]}),a.jsxs("section",{children:[a.jsx("h3",{children:"安装来源"}),a.jsxs("dl",{children:[a.jsx("dt",{children:"仓库"}),a.jsx("dd",{children:A.source.url}),a.jsx("dt",{children:"分支 / 标签"}),a.jsx("dd",{children:A.source.ref}),a.jsx("dt",{children:"已锁定提交"}),a.jsx("dd",{children:a.jsx("code",{children:A.source.commit})}),a.jsx("dt",{children:"面板目录"}),a.jsx("dd",{children:A.source.subdir||"仓库根目录"}),a.jsx("dt",{children:"界面入口"}),a.jsx("dd",{children:a.jsx("code",{children:A.preview.entry})})]})]}),a.jsxs("section",{children:[a.jsx("h3",{children:"面板请求的权限"}),A.preview.permissions.length===0?a.jsx("p",{className:"panels-muted",children:"未申请宿主权限。"}):A.preview.permissions.map(V=>a.jsxs("div",{className:"panels-permission",children:[a.jsx("span",{children:Gy[V]??V}),a.jsx("small",{children:V})]},V))]}),a.jsxs("section",{children:[a.jsx("h3",{children:"随面板安装的工具与 Skills"}),A.preview.agent?.tools.length||A.preview.agent?.skills.length?a.jsxs("div",{className:"panels-badges",children:[A.preview.agent?.tools.map(V=>a.jsxs("span",{className:"panels-badge",title:V.description,children:[V.name," · ",V.readOnly?"只读":"可修改数据"]},V.name)),A.preview.agent?.skills.map(V=>a.jsxs("span",{className:"panels-badge",children:["Skill · ",V.split("/").at(-2)??V]},V))]}):a.jsx("p",{className:"panels-muted",children:"此面板没有额外的 Agent 工具或 Skills。"})]}),a.jsx(fo,{value:A.compatibility}),A.preview.warnings.length>0&&a.jsx("div",{className:"panels-warning",children:a.jsx("ul",{children:A.preview.warnings.map(V=>a.jsx("li",{children:V},V))})}),a.jsxs("footer",{children:[!A.compatibility.supported&&a.jsxs("p",{className:"panels-muted",children:["可以安装到",o,",但当前 Web 工作台无法绑定或打开它。"]}),re?a.jsx("p",{className:"panels-muted",children:"已绑定当前工作区,更新将保留绑定。"}):a.jsxs("label",{className:"panels-check",children:[a.jsx("input",{type:"checkbox",checked:P,disabled:!!W||!c?.hasProject||!A.compatibility.supported,onChange:V=>G(V.target.checked)}),"绑定当前工作区"]}),$?a.jsxs("div",{className:"panels-actions",children:[a.jsx("span",{className:"panels-muted",children:"安装内容或本地版本已变化,请重新审阅。"}),a.jsx("button",{disabled:!!W,onClick:q,children:"重新审阅"})]}):a.jsx("button",{className:"panels-primary",disabled:!!W,onClick:()=>{ze()},children:A.kind==="update"?"确认更新":"确认安装"})]})]}),a.jsxs("section",{className:"panels-section","aria-labelledby":"installed-panels-heading",children:[a.jsxs("div",{className:"panels-heading",children:[a.jsxs("h2",{id:"installed-panels-heading",children:["已安装面板",c?` · ${c.panels.length+(c.issues?.length??0)}`:""]}),a.jsx("input",{type:"search","aria-label":"搜索已安装面板",placeholder:"搜索已安装面板",value:j,onChange:V=>N(V.target.value)})]}),!c&&a.jsx("p",{className:"panels-muted",children:te?"正在读取面板…":"暂时无法读取面板,请刷新重试。"}),c&&ie.length===0&&!c.issues?.some(V=>V.id.toLowerCase().includes(Be))&&a.jsxs("div",{className:"panels-empty",children:[a.jsx("strong",{children:c.panels.length||c.issues?.length?"没有匹配的面板":"还没有安装面板"}),a.jsx("p",{className:"panels-muted",children:c.panels.length||c.issues?.length?"试试其他名称或清除搜索。":"在下方粘贴 GitHub 仓库地址,或浏览官方面板仓库。"})]}),a.jsx("div",{className:"panels-grid",children:ie.map(V=>a.jsxs("article",{className:"panels-card",children:[a.jsxs("div",{className:"panels-card-heading",children:[a.jsx("h3",{children:Zn(V.title)}),a.jsxs("span",{className:"panels-badge",children:["v",V.version]})]}),a.jsx("small",{children:V.id}),V.description&&a.jsx("p",{children:V.description}),a.jsx("div",{className:"panels-badges",children:a.jsx("span",{className:`panels-badge ${V.enabled&&V.compatibility.supported?"panels-badge-ready":""}`,children:V.globalDisabled?"已全局停用":V.bound?"已绑定当前工作区":"未绑定当前工作区"})}),a.jsxs("dl",{children:[a.jsx("dt",{children:"来源"}),a.jsx("dd",{children:V.source.label}),V.source.ref&&a.jsxs(a.Fragment,{children:[a.jsx("dt",{children:"分支 / 标签"}),a.jsx("dd",{children:V.source.ref})]})]}),a.jsx(fo,{value:V.compatibility}),V.globalDisabled&&a.jsx("p",{className:"panels-muted",children:"请在宿主配置中启用此面板后使用。"}),a.jsxs("div",{className:"panels-actions",children:[a.jsx("button",{className:"panels-primary",disabled:pt||!V.enabled||!V.compatibility.supported,onClick:()=>Oe.current.onOpen(V),children:"打开面板"}),a.jsx("button",{disabled:pt||!c?.hasProject||!V.bound&&(V.globalDisabled||!V.compatibility.supported),onClick:()=>{Le(V)},children:V.bound?"解除绑定":"绑定工作区"}),V.updatable&&a.jsx("button",{disabled:pt,onClick:()=>{nt(V)},children:"检查更新"}),c?.canRestorePackages&&V.bound&&a.jsx("button",{disabled:pt,onClick:()=>{Ne(V)},children:"项目版本"}),a.jsx("button",{className:"panels-danger",disabled:pt,onClick:async()=>{!await se()||!Me.current||(M(V),D(void 0),J(void 0),B(void 0),Q(""),fe(""))},children:"卸载"})]})]},V.id))}),R&&a.jsxs("section",{className:"panels-confirm","aria-label":"确认卸载面板",children:[a.jsxs("p",{children:["卸载「",Zn(R.title),"」v",R.version,"?面板将从",o,"移除,其他工作区也将无法打开它。"]}),a.jsxs("div",{className:"panels-actions",children:[a.jsx("button",{disabled:!!W,onClick:()=>M(void 0),children:"取消卸载"}),we&&a.jsx("span",{className:"panels-muted",children:le?"面板已被其他设备修改,请查看最新版本后重新确认。":"此面板已被其他设备卸载。"}),we&&le&&a.jsx("button",{disabled:!!W||te,onClick:()=>{M(le),Q("")},children:"查看最新版本"}),a.jsx("button",{className:"panels-danger",disabled:!!W||te||we,onClick:()=>{bt()},children:"确认卸载"})]})]})]}),a.jsxs("section",{className:"panels-import panels-section","aria-labelledby":"github-panels-heading",children:[a.jsxs("div",{className:"panels-heading",children:[a.jsxs("div",{children:[a.jsx("h2",{id:"github-panels-heading",children:"从 GitHub 安装"}),a.jsx("p",{children:"先读取仓库并选择面板,再查看安装内容和所需权限。"})]}),a.jsx("button",{disabled:pt,onClick:()=>{p($y),b(""),w(""),rt({url:$y})},children:"浏览官方仓库"})]}),a.jsxs("form",{onSubmit:V=>{V.preventDefault(),f.trim()&&rt({url:f.trim(),...y.trim()?{ref:y.trim()}:{},...v.trim()?{subdir:v.trim()}:{}})},children:[a.jsxs("label",{children:["GitHub 仓库地址",a.jsx("input",{type:"url",placeholder:"https://github.com/owner/repository",value:f,required:!0,disabled:!!W||!!H,onChange:V=>{p(V.target.value),E(void 0)}})]}),a.jsxs("details",{children:[a.jsx("summary",{children:"指定分支或子目录"}),a.jsxs("div",{className:"panels-source-fields",children:[a.jsxs("label",{children:["分支 / 标签(可选)",a.jsx("input",{value:y,placeholder:"使用默认分支",disabled:!!W||!!H,onChange:V=>{b(V.target.value),E(void 0)}})]}),a.jsxs("label",{children:["子目录(可选)",a.jsx("input",{value:v,placeholder:"例如 apps/my-panel",disabled:!!W||!!H,onChange:V=>{w(V.target.value),E(void 0)}})]})]})]}),a.jsxs("div",{className:"panels-actions",children:[a.jsx("button",{type:"submit",disabled:pt||!f.trim(),children:"读取仓库"}),(f||y||v||C)&&a.jsx("button",{type:"button",disabled:!!W,onClick:()=>{ne(),D(void 0)},children:"清除"})]})]}),C&&a.jsxs("div",{className:"panels-candidates",children:[a.jsxs("h3",{children:["找到 ",C.panels.length," 个面板"]}),a.jsxs("p",{className:"panels-muted",children:[C.source.url," · ",C.source.ref," ·"," ",a.jsx("code",{children:C.source.commit.slice(0,12)})]}),C.panels.length===0&&a.jsx("p",{className:"panels-muted",children:"仓库中没有找到可安装的面板。请检查地址和子目录。"}),O.length>1&&a.jsxs("div",{className:"panels-actions panels-batch-start",children:[a.jsxs("button",{disabled:pt,onClick:()=>{xe(O)},children:["逐个审阅未安装面板(",O.length,")"]}),a.jsx("small",{children:"按顺序确认,可随时跳过或停止。"})]}),a.jsx("div",{className:"panels-grid",children:C.panels.map(V=>{const ge=c?.panels.find(Ye=>Ye.id===V.id);return a.jsxs("article",{className:"panels-card",children:[a.jsxs("div",{className:"panels-card-heading",children:[a.jsx("h3",{children:Zn(V.title)}),a.jsxs("span",{className:"panels-badge",children:["v",V.version]})]}),V.description&&a.jsx("p",{children:V.description}),a.jsx("small",{children:V.subdir==="."?"仓库根目录":V.subdir}),a.jsx("div",{className:"panels-actions",children:a.jsx("button",{disabled:pt||!!(ge&&!ge.updatable),onClick:()=>ge?void nt(ge):void Ve(V.source),children:ge?ge.updatable?"已安装 · 检查更新":"已从其他来源安装":"审阅安装"})})]},`${V.id}:${V.subdir}`)})}),C.issues.length>0&&a.jsxs("div",{className:"panels-warning",children:[a.jsx("strong",{children:"部分目录无法作为面板安装"}),a.jsx("ul",{children:C.issues.map(V=>a.jsxs("li",{children:[V.subdir,":",V.error]},V.subdir))})]})]})]})]})}function aj(t){const r=t.projectId===void 0?Dl():t.projectId,i=`/api/v1/panels/runtime/${encodeURIComponent(t.instanceId)}`,l=new Set,o=new Set;let d=!1,c=t.expiresAt,h=c-6e4,f,p=0,y=0,b=0,v,w;const j=(_,I)=>{const H=setTimeout(()=>{l.delete(H),d||_()},Math.max(0,Math.min(I,2147483647)));return l.add(H),H},N=_=>{_!==void 0&&(clearTimeout(_),l.delete(_))},C=()=>{if(!d){d=!0;for(const _ of l)clearTimeout(_);l.clear();for(const _ of o)_.abort();o.clear()}},E=_=>{d||(C(),t.onTerminal(_))},A=()=>E(new Error("面板连接已到期,请重新打开继续使用。")),D=_=>_ instanceof it&&[401,403,410].includes(_.status),L=()=>{d||t.onStatus(p||y?"面板连接暂时中断,正在重试;当前内容会保留。":"")},J=async(_,I="GET")=>{const H=new AbortController;o.add(H);const Y=j(()=>H.abort(),8e3);try{return await Je(Dt(`${i}${_}`,t.workspace,r),{method:I,...I==="POST"?{headers:{"Content-Type":"application/json"},body:"{}"}:{},signal:H.signal})}finally{N(Y),o.delete(H)}},T=()=>{N(v),v=j(()=>{Date.now()>=c?A():T()},c-Date.now())},B=()=>{N(w),p<5&&(w=j(U,h-Date.now()))};function U(){if(!d){if(Date.now()>=c){A();return}f||p>=5||Date.now()<h||(f=(async()=>{try{const _=await J("/renew","POST");if(d)return;if(!_||typeof _!="object"||!("expiresAt"in _)||typeof _.expiresAt!="number"||!Number.isFinite(_.expiresAt)||_.expiresAt<=Date.now()+6e4)throw new Error("面板续期响应无效。");c=_.expiresAt,h=c-6e4,p=0,T(),L()}catch(_){if(d)return;if(D(_)){E(_);return}p++,h=Date.now()+Math.min(5e3*2**(p-1),3e4),L()}finally{f=void 0,d||B()}})())}}async function X(){try{const _=await J(`/events?after=${b}`);if(d)return;if(!_||typeof _!="object"||!("cursor"in _)||!("events"in _))throw new Error("面板事件响应无效。");if(!Number.isSafeInteger(_.cursor)||_.cursor<b||!Array.isArray(_.events)||_.events.length>2048)throw new Error("面板事件响应无效。");const I=[];let H=b;for(const Y of _.events){if(!Y||typeof Y!="object"||!Number.isSafeInteger(Y.id)||Y.id<=H||Y.id>_.cursor||typeof Y.event!="string"||!/^[A-Za-z][A-Za-z0-9._-]{0,100}$/.test(Y.event))throw new Error("面板事件响应无效。");H=Y.id,I.push(Y)}t.onEvents(I),b=_.cursor,y=0,L()}catch(_){if(d)return;if(D(_)){E(_);return}y++,L()}finally{d||j(()=>{X()},Math.min(1e3*2**y,5e3))}}return T(),B(),X(),{stop:C,refresh:U}}function oj(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 r={phase:"idle",elapsedSeconds:0,message:"点击开始录音后,浏览器才会请求麦克风。"},i=0,l,o,d,c=[],h=0,f="",p=t.signal.aborted;const y=j=>{r={...r,...j},p||t.onChange({...r})},b=()=>{l?.getTracks().forEach(j=>j.stop()),l=void 0,d&&clearInterval(d),d=void 0},v=()=>{try{o?.state!=="inactive"&&o?.stop()}finally{b()}},w=()=>{if(!p){p=!0,i++,o&&(o.ondataavailable=null,o.onstop=null,o.onerror=null);try{v()}finally{b()}c=[],r={phase:"closed",elapsedSeconds:0,message:"录音已关闭。"},t.signal.removeEventListener("abort",w)}};return p?r={phase:"closed",elapsedSeconds:0,message:"录音授权已结束。"}:t.signal.addEventListener("abort",w,{once:!0}),{snapshot:()=>({...r}),async start(){if(p||t.signal.aborted)throw new Error("录音授权已结束。");if(["requesting","recording"].includes(r.phase))throw new Error("已有录音正在进行。");const j=++i,N=()=>!p&&j===i&&!t.signal.aborted;c=[],h=0,f="",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(!N()){C.getTracks().forEach(L=>L.stop());return}l=C;const E=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(L=>typeof MediaRecorder<"u"&&MediaRecorder.isTypeSupported(L));o=t.makeRecorder?t.makeRecorder(l):new MediaRecorder(l,{...E?{mimeType:E}:{},audioBitsPerSecond:128e3});const A=o;A.ondataavailable=L=>{!N()||!L.data.size||(c.push(L.data),h+=L.data.size,h>t.maxBytes&&(f="录音超过大小限制;可以下载备份,或重新录制较短的音频。",v()))},A.onerror=()=>{if(N()){f="录音设备发生错误;请检查麦克风后重新录制。";try{v()}catch{b()}y({phase:"error",message:f})}},A.onstop=()=>{if(!N())return;b();const L=new Blob(c,{type:A.mimeType.split(";")[0]||"audio/webm"});c=[],y({phase:L.size&&!f?"review":"error",blob:L.size?L:void 0,message:f||(L.size?"录音已停止。可以试听,再保存到当前项目。":"没有录到声音,请重新录制。")})};const D=Date.now();A.start(250),y({phase:"recording",message:"正在使用这台设备的麦克风录音。"}),d=setInterval(()=>{if(!N())return;const L=Math.floor((Date.now()-D)/1e3);y({elapsedSeconds:L}),L>=t.maxDurationSeconds&&v()},250)}catch(C){if(b(),!N())return;y({phase:"error",message:C instanceof Error&&["NotAllowedError","SecurityError"].includes(C.name)?"麦克风未获授权,请检查浏览器和系统的麦克风权限。":"无法启动录音,请确认安全连接、麦克风和浏览器录音支持。"})}},stop:v,close:w}}function mv(t){const r=new Blob([t.blob],{type:t.blob.type.split(";")[0].trim().toLowerCase()}),i=[],l=t.timing?.now??Date.now,o=t.timing?.sleep??((v,w)=>new Promise((j,N)=>{const C=()=>{clearTimeout(E),N(w.reason)},E=setTimeout(()=>{w.removeEventListener("abort",C),j()},v);w.addEventListener("abort",C,{once:!0}),w.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 w=l();for(;i.length&&i[0]<=w-v.rateWindowMs;)i.shift();if(i.length<v.maxTransferCallsPerWindow){i.push(w);return}await o(Math.max(1,i[0]+v.rateWindowMs-w),t.signal)}};let c,h=!1,f;const p=()=>t.signal.throwIfAborted(),y=async(v,w)=>{p();const j=await t.call(v,w);return p(),j},b=v=>{const w=v;if(!w||typeof w.sessionId!="string"||!/^upload-[a-f0-9-]{36}$/.test(w.sessionId)||c&&c!==w.sessionId||w.mimeType!==r.type||!["uploading","finished"].includes(String(w.state))||!Number.isSafeInteger(w.receivedBytes)||Number(w.receivedBytes)<0||Number(w.receivedBytes)>r.size||!Number.isSafeInteger(w.nextSequence)||Number(w.nextSequence)<0||!Number.isSafeInteger(w.maxChunkBytes)||Number(w.maxChunkBytes)<1||Number(w.maxChunkBytes)>32768)throw new Error("文件上传状态无效,请保留本机备份后重新打开面板。");return w};return{async save(){if(p(),h)throw new Error("文件正在保存,请稍候。");if(!r.size||r.size>t.maxBytes||!t.mimeTypes.includes(r.type))throw new Error("文件格式或大小无效。");h=!0;try{if(!f){const j=await r.arrayBuffer();p(),f=Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",j)),N=>N.toString(16).padStart(2,"0")).join(""),p()}let v=b(c?await y("resources.upload.get",{sessionId:c}):await y("resources.upload.begin",{name:t.name,mimeType:r.type,expectedBytes:r.size,expectedSha256:f}));for(c=v.sessionId,t.onProgress(v.receivedBytes);v.receivedBytes<r.size;){if(v.state!=="uploading")throw new Error("文件上传已结束,文件大小不匹配。");const j=v.receivedBytes,N=new Uint8Array(await r.slice(j,j+v.maxChunkBytes).arrayBuffer());p(),await d(),p();const C=b(await y("resources.upload.write",{sessionId:c,sequence:v.nextSequence,offset:j,dataBase64:btoa(String.fromCharCode(...N))}));if(C.receivedBytes!==j+N.length||C.nextSequence!==v.nextSequence+1)throw new Error("文件上传进度不匹配,请重试保存以核对服务端状态。");v=C,t.onProgress(v.receivedBytes)}const w=await y("resources.upload.finish",{sessionId:c});if(!w?.asset||w.asset.id!==`asset-${f}`||w.asset.bytes!==r.size||w.asset.mimeType!==r.type)throw new Error("文件保存回执不匹配,请保留本机备份并重试。");return w}finally{h=!1}}}}function uj(t){return mv({...t,maxBytes:25*1024*1024,mimeTypes:["audio/webm","audio/mp4","audio/ogg","audio/wav"]})}function cj({request:t}){const[r,i]=x.useState({phase:"idle",elapsedSeconds:0,message:"点击开始录音后,浏览器才会请求麦克风。"}),[l,o]=x.useState(""),[d,c]=x.useState(!1),[h,f]=x.useState(0),[p,y]=x.useState(""),b=x.useRef(null),v=x.useRef(void 0),w=x.useRef(void 0),j=x.useRef(void 0);x.useEffect(()=>{const E=new AbortController;j.current=E;const A=AbortSignal.any([t.signal,E.signal]);return v.current=oj({...t,signal:A,onChange:i}),b.current?.focus(),b.current?.scrollIntoView?.({block:"nearest"}),()=>{E.abort(),v.current?.close(),v.current=void 0,w.current=void 0}},[t]),x.useEffect(()=>{if(!r.blob){y("");return}const E=URL.createObjectURL(r.blob);return y(E),()=>URL.revokeObjectURL(E)},[r.blob]);const N=r.blob?.type==="audio/mp4"?"m4a":r.blob?.type==="audio/ogg"?"ogg":"webm",C=async()=>{const E=r.blob,A=j.current;if(!E||!A||d||r.phase!=="review")return;const D=AbortSignal.any([t.signal,A.signal]);c(!0),o("");try{w.current?.blob!==E&&(w.current={blob:E,transfer:uj({blob:E,name:`recording.${N}`,signal:D,call:(J,T)=>t.call(J,T,D),onProgress:f})});const L=await w.current.transfer.save();D.throwIfAborted(),t.finish(L)}catch(L){D.aborted||o(`${L instanceof Error?L.message:"保存失败。"} 录音仍保留在本页,可重试保存或下载备份。`)}finally{D.aborted||c(!1)}};return a.jsxs("section",{className:"panel-host-audio panel-host-preview","aria-label":"录音",tabIndex:-1,ref:b,children:[a.jsxs("header",{children:[a.jsx("h2",{children:"录音并保存到当前项目"}),a.jsx("button",{onClick:()=>t.finish({cancelled:!0}),children:"取消录音"})]}),a.jsxs("p",{children:["使用当前设备的麦克风;最长 ",t.maxDurationSeconds," ","秒。停止后可试听,点击保存才会上传到当前项目。关闭面板会丢弃未保存录音。"]}),a.jsxs("p",{role:"status",children:[r.message," ",r.elapsedSeconds>0&&`${r.elapsedSeconds} 秒`]}),p&&a.jsx("audio",{controls:!0,src:p}),l&&a.jsx("p",{role:"alert",children:l}),d&&a.jsxs("p",{role:"status",children:["正在保存录音:",Math.round(h/(r.blob?.size||1)*100),"%"]}),a.jsxs("div",{className:"panel-host-actions",children:[["idle","error"].includes(r.phase)&&!r.blob&&a.jsx("button",{onClick:()=>{o(""),v.current?.start().catch(E=>o(String(E)))},children:"开始录音"}),r.phase==="recording"&&a.jsx("button",{onClick:()=>v.current?.stop(),children:"停止录音"}),r.phase==="review"&&a.jsx("button",{disabled:d,className:"panel-host-primary",onClick:()=>{C()},children:d?"正在保存…":"保存到当前项目"}),p&&a.jsx("button",{disabled:d,onClick:()=>{o(""),w.current=void 0,v.current?.start().catch(E=>o(String(E)))},children:"丢弃并重新录制"}),p&&a.jsx("a",{href:p,download:`recording.${N}`,children:"下载本机备份"})]})]})}const js=Object.freeze({maxDurationSeconds:1200,maxBytes:200*1024*1024,defaultDurationSeconds:300,defaultBytes:64*1024*1024});function gv(t){const r=t;if(!r||typeof r!="object"||Array.isArray(r)||Object.keys(r).some(o=>!["source","microphone","systemAudio","maxDurationSeconds","maxBytes"].includes(o))||r.source!=="camera"&&r.source!=="screen"||r.microphone!==void 0&&typeof r.microphone!="boolean"||r.systemAudio!==void 0&&typeof r.systemAudio!="boolean"||r.source!=="screen"&&r.systemAudio===!0)throw new Error("视频录制请求无效。");const i=r.maxDurationSeconds??js.defaultDurationSeconds,l=r.maxBytes??js.defaultBytes;if(!Number.isSafeInteger(i)||Number(i)<1||Number(i)>js.maxDurationSeconds||!Number.isSafeInteger(l)||Number(l)<1||Number(l)>js.maxBytes)throw new Error("视频录制限制无效。");return{source:r.source,microphone:r.microphone!==!1,systemAudio:r.systemAudio===!0,maxDurationSeconds:Number(i),maxBytes:Number(l)}}const dj=["video/webm;codecs=vp8,opus","video/webm;codecs=vp9,opus","video/webm","video/mp4"];function yv(){try{return dj.find(t=>typeof MediaRecorder<"u"&&MediaRecorder.isTypeSupported(t))}catch{return}}function Dd(){const t=typeof navigator>"u"?void 0:navigator.mediaDevices,r=typeof window<"u"&&window.isSecureContext===!0&&!!yv(),i=r&&typeof t?.getUserMedia=="function",l=r&&typeof t?.getDisplayMedia=="function";return{camera:i,screen:l,microphone:i,systemAudio:l,maxDurationSeconds:js.maxDurationSeconds,maxBytes:js.maxBytes}}function fj(t){const r=gv({source:t.source,microphone:t.microphone,systemAudio:t.systemAudio,maxDurationSeconds:t.maxDurationSeconds,maxBytes:t.maxBytes});let i={phase:"idle",elapsedSeconds:0,message:"点击开始录制后,才会请求设备授权。",capture:{source:r.source,microphone:!1,systemAudio:!1}},l=0,o=t.signal.aborted,d,c,h,f=[],p=0,y="";const b=new Set,v=C=>{i={...i,...C},o||t.onChange({...i})},w=()=>{h&&clearInterval(h),h=void 0;for(const C of new Set([...b].flatMap(E=>E.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{w()}},N=()=>{if(!o){o=!0,l++,d&&(d.ondataavailable=null,d.onstop=null,d.onerror=null);try{j()}finally{w()}f=[],i={...i,phase:"closed",stream:void 0,blob:void 0},t.signal.removeEventListener("abort",N)}};return o?i.phase="closed":t.signal.addEventListener("abort",N,{once:!0}),{snapshot:()=>({...i}),async start(){if(o||t.signal.aborted)throw new Error("录制授权已结束。");if(["requesting","recording"].includes(i.phase))throw new Error("已有录制正在进行。");const C=++l,E=()=>!o&&l===C&&!t.signal.aborted,A=D=>{if(!E())throw D.getTracks().forEach(L=>L.stop()),new Error("录制授权已结束。");b.add(D);for(const L of D.getTracks()){if(L.readyState==="ended")throw new Error("所选采集来源已经停止,请重新连接。");L.onended=()=>{E()&&(i.phase==="recording"?j():(l++,w(),v({phase:"error",stream:void 0,message:"采集来源已停止,请重新连接。"})))}}return D};w(),f=[],p=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 L=A(await(r.source==="screen"?D.getDisplayMedia({video:!0,audio:r.systemAudio}):D.getUserMedia({video:!0,audio:r.microphone})));if(!L.getVideoTracks().length)throw new Error("没有获得可录制的画面。");const J=r.source==="screen"&&r.microphone?A(await D.getUserMedia({audio:!0,video:!1})):void 0,T=r.microphone?(r.source==="camera"?L:J)?.getAudioTracks()??[]:[];if(r.microphone&&!T.length)throw new Error("没有获得麦克风音轨。");const B=r.source==="screen"&&r.systemAudio?L.getAudioTracks():[];let U=A(new MediaStream([...L.getVideoTracks(),...T,...B]));if(T.length&&r.source==="screen")if(B.length){c=t.makeAudioContext?t.makeAudioContext():new AudioContext;const H=c,Y=H.createMediaStreamDestination();A(Y.stream);for(const F of[T,B])H.createMediaStreamSource(new MediaStream(F)).connect(Y);let $;try{await Promise.race([H.resume(),new Promise((F,P)=>{$=setTimeout(()=>P(new Error("声音混合未能启动,请重新录制。")),2e3)})])}finally{$&&clearTimeout($)}t.signal.throwIfAborted(),U=A(new MediaStream([...L.getVideoTracks(),...Y.stream.getAudioTracks()]))}else U=A(new MediaStream([...L.getVideoTracks(),...T]));if(!E()){w();return}const X=yv();if(!X)throw new Error("此浏览器不支持视频录制编码。");d=t.makeRecorder?t.makeRecorder(U,X):new MediaRecorder(U,{mimeType:X});const _=d;_.ondataavailable=H=>{!E()||!H.data.size||(f.push(H.data),p+=H.data.size,p>r.maxBytes&&(y="录制超过大小限制;可以下载备份或重新录制较短的视频。",j()))},_.onerror=()=>{if(E()){y="录制设备或编码器发生错误,请保留备份后重试。";try{j()}catch{w()}v({phase:"error",stream:void 0,message:y})}},_.onstop=()=>{if(!E())return;w();const H=new Blob(f,{type:_.mimeType.split(";")[0]||X.split(";")[0]});f=[],v({phase:H.size&&!y?"review":"error",stream:void 0,blob:H.size?H:void 0,message:y||(H.size?"录制已停止。可以预览,再保存到当前项目。":"没有录到内容,请重新录制。")})};const I=Date.now();_.start(250),v({phase:"recording",stream:U,capture:{source:r.source,microphone:T.length>0,systemAudio:B.length>0},message:"正在使用这台设备录制;停止后可以预览和保存。"}),h=setInterval(()=>{if(!E())return;const H=Math.floor((Date.now()-I)/1e3);v({elapsedSeconds:H}),H>=r.maxDurationSeconds&&j()},250)}catch(D){if(w(),!E())return;v({phase:"error",stream:void 0,message:D instanceof Error&&["NotAllowedError","SecurityError"].includes(D.name)?"设备未获授权或屏幕选择已取消,请检查浏览器和系统权限后重试。":D instanceof Error?D.message:"无法启动录制,请检查设备和浏览器支持。"})}},stop:j,close:N}}function hj({request:t}){const[r,i]=x.useState({phase:"idle",elapsedSeconds:0,message:"点击开始录制后,才会请求设备授权。",capture:{source:t.source,microphone:!1,systemAudio:!1}}),[l,o]=x.useState(""),[d,c]=x.useState(!1),[h,f]=x.useState(0),[p,y]=x.useState(""),b=x.useRef(null),v=x.useRef(null),w=x.useRef(void 0),j=x.useRef(void 0),N=x.useRef(void 0);x.useEffect(()=>{const D=new AbortController;N.current=D;const L=AbortSignal.any([t.signal,D.signal]);w.current=fj({...t,signal:L,onChange:i});const J=()=>{D.abort(),t.finish({cancelled:!0})};return window.addEventListener("pagehide",J,{once:!0}),b.current?.focus(),b.current?.scrollIntoView?.({block:"nearest"}),()=>{window.removeEventListener("pagehide",J),D.abort(),w.current?.close(),w.current=void 0,j.current=void 0}},[t]),x.useEffect(()=>{const D=v.current;if(D)return D.srcObject=r.stream??null,r.stream&&D.play().catch(()=>{}),()=>{D.srcObject=null}},[r.stream]),x.useEffect(()=>{if(!r.blob){y("");return}const D=URL.createObjectURL(r.blob);return y(D),()=>URL.revokeObjectURL(D)},[r.blob]);const C=r.blob?.type==="video/mp4"?"mp4":"webm",E=()=>{o(""),j.current=void 0,w.current?.start().catch(D=>o(String(D)))},A=async()=>{const D=r.blob,L=N.current;if(!D||!L||d||r.phase!=="review")return;const J=AbortSignal.any([t.signal,L.signal]);c(!0),o("");try{j.current?.blob!==D&&(j.current={blob:D,transfer:mv({blob:D,name:`recording.${C}`,signal:J,maxBytes:t.maxBytes,mimeTypes:["video/webm","video/mp4"],transferBudget:t.transferBudget,call:(B,U)=>t.call(B,U,J),onProgress:f})});const T=await j.current.transfer.save();J.throwIfAborted(),t.finish({...T,capture:r.capture})}catch(T){J.aborted||o(`${T instanceof Error?T.message:"保存失败。"} 视频仍保留在本页,可重试保存或下载备份。若已保存但未收到回复,重开面板后可从项目资源找回。`)}finally{J.aborted||c(!1)}};return a.jsxs("section",{className:"panel-host-video panel-host-preview","aria-label":"视频录制",tabIndex:-1,ref:b,children:[a.jsxs("header",{children:[a.jsxs("h2",{children:[t.source==="camera"?"摄像头录制":"屏幕录制","并保存到当前项目"]}),a.jsx("button",{onClick:()=>t.finish({cancelled:!0}),children:"取消录制"})]}),a.jsxs("p",{children:["使用当前设备;最长 ",t.maxDurationSeconds," 秒,最多"," ",Math.ceil(t.maxBytes/1024/1024)," MiB。",t.microphone?"使用麦克风。":"不使用麦克风。",t.systemAudio&&"屏幕声音取决于浏览器和你选择的共享来源,可能没有声音音轨。","停止后可预览,点击保存才会上传。关闭面板会丢弃未保存录制。"]}),a.jsxs("p",{role:"status",children:[r.message," ",r.elapsedSeconds>0&&`${r.elapsedSeconds} 秒`]}),r.stream&&a.jsx("video",{ref:v,muted:!0,playsInline:!0,"aria-label":"实时录制预览"}),p&&a.jsx("video",{controls:!0,playsInline:!0,src:p,"aria-label":"录制预览"}),r.phase==="recording"&&a.jsxs("p",{children:["麦克风:",r.capture.microphone?"已采集":"未采集",";屏幕声音:",r.capture.systemAudio?"已采集":"未采集"]}),l&&a.jsx("p",{role:"alert",children:l}),d&&a.jsxs("p",{role:"status",children:["正在保存视频:",Math.round(h/(r.blob?.size||1)*100),"%"]}),a.jsxs("div",{className:"panel-host-actions",children:[["idle","error"].includes(r.phase)&&!r.blob&&a.jsx("button",{onClick:E,children:"开始录制"}),r.phase==="recording"&&a.jsx("button",{onClick:()=>w.current?.stop(),children:"停止录制"}),r.phase==="review"&&a.jsx("button",{disabled:d,className:"panel-host-primary",onClick:()=>{A()},children:d?"正在保存…":"保存到当前项目"}),p&&a.jsx("button",{disabled:d,onClick:E,children:"丢弃并重新录制"}),p&&a.jsx("a",{href:p,download:`recording.${C}`,children:"下载本机备份"})]})]})}const ri="/api/v1/panels/runtime";function on(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function pj(t){try{if(typeof t!="string"||t.length>2048)return;const r=new URL(t);if(r.protocol==="https:"&&!r.username&&!r.password)return r.href}catch{}}function mj(t,r){const i=`${ri}/${r}/directory/`;return typeof t=="string"&&t.startsWith(i)&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t.slice(i.length))}function gj(t,r,i){if(!on(t)||t.effect!=="resources.open"||!on(t.asset))return;const l=t.asset;if(typeof l.id!="string"||!/^(?:asset|external)-[a-f0-9]{64}$/.test(l.id)||l.id!==i||t.url!==`${ri}/${r}/resources/${l.id}`||typeof l.name!="string"||!l.name||l.name.length>1024||typeof l.mimeType!="string"||!Number.isSafeInteger(l.bytes)||Number(l.bytes)<0)return;const o=["video/mp4","video/webm","video/ogg","video/quicktime"].includes(l.mimeType)?"video":["audio/mpeg","audio/mp4","audio/ogg","audio/wav","audio/webm","audio/flac","audio/aac"].includes(l.mimeType)?"audio":["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp"].includes(l.mimeType)?"image":"file";return{name:l.name,url:t.url,kind:o}}function yj(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(r=>{const i=decodeURIComponent(r);return!!i&&!i.startsWith(".")&&!/[\\/:\u0000-\u001f\u007f]/.test(i)})}catch{return!1}}function bj(t){return on(t)?typeof t.instanceId=="string"&&/^[A-Za-z0-9_-]{20,128}$/.test(t.instanceId)&&yj(t.src)&&typeof t.expiresAt=="number"&&Number.isFinite(t.expiresAt)&&on(t.context)&&Array.isArray(t.limitations)&&t.limitations.every(r=>typeof r=="string"):!1}function vj({panel:t,sessionId:r,busy:i,onClose:l,onAuthLost:o,onDirtyChange:d,onSubmitPrompt:c}){const h=x.useRef(null),[f,p]=x.useState(),[y,b]=x.useState(!0),[v,w]=x.useState(""),[j,N]=x.useState(""),[C,E]=x.useState(),[A,D]=x.useState(),[L,J]=x.useState(!1),T=x.useRef(null);x.useEffect(()=>{A&&(T.current?.focus(),T.current?.scrollIntoView?.({block:"nearest"}))},[A]);const[B,U]=x.useState(""),[X,_]=x.useState(""),[I,H]=x.useState(),[Y,$]=x.useState(),F=x.useRef(void 0),[P,G]=x.useState(),[re,be]=x.useState(!1),[R,M]=x.useState(0),te=x.useRef({onClose:l,onAuthLost:o,onDirtyChange:d,onSubmitPrompt:c,busy:i});te.current={onClose:l,onAuthLost:o,onDirtyChange:d,onSubmitPrompt:c,busy:i};const k=x.useRef(!1),W=x.useRef(void 0),ue=x.useRef(void 0),me=x.useRef(null);return x.useEffect(()=>{te.current.onDirtyChange?.(!!I||re||!!Y||!!P),I&&(me.current?.focus(),me.current?.scrollIntoView?.({block:"nearest"}))},[I,re,Y,P]),x.useEffect(()=>{const Q=jo()??"",oe=Dl(),fe={workspace:Q,grant:void 0},ke=new AbortController,_e=new Set,Me=new Set;let Ce=!1,qe;const Ge=[],lt=[],De=new Set,Oe=new Set;let ht,at=!1,dt=!1,Ke=!1,rt=!1;const Ve=()=>{const Be=h.current?.contentWindow;if(!(Ce||!fe.grant||!Be||!rt))for(const ie of Ge.splice(0))ie.event==="tools.invoke"&&on(ie.payload)&&typeof ie.payload.requestId=="string"&&/^[A-Za-z0-9_-]{1,128}$/.test(ie.payload.requestId)&&Oe.add(ie.payload.requestId),Be.postMessage({type:"codeshell-panel:event",instanceId:fe.grant.instanceId,event:ie.event,payload:ie.payload},"*")},nt=()=>{Ce||!Ke||!rt||!fe.grant||(ht&&clearTimeout(ht),b(!1),Ve())},q={loaded:()=>{Ke=!0,nt()}};ue.current=q,p(void 0),b(!0),w(""),N(""),E(void 0),D(void 0),J(!1),U(""),_(""),H(void 0),be(!1),$(void 0),G(void 0);const ne=Be=>{at||(at=!0,Je(Dt(`${ri}/${encodeURIComponent(Be.instanceId)}`,Q,oe),{method:"DELETE",keepalive:!0}).catch(()=>{}))},Ee=Be=>{Ce||(Be instanceof it&&Be.status===401&&!k.current&&(k.current=!0,te.current.onAuthLost()),w(Be instanceof Error?Be.message:"面板连接失败,请重新打开。"))},xe=Be=>{if(Ce||!fe.grant)return;const ie=fe.grant;fe.grant=void 0,qe?.stop(),W.current?.cancel(),lt.length=0,Ge.length=0,ne(ie);for(const O of _e)O.abort();ht&&clearTimeout(ht),p(void 0),E(void 0),D(void 0),b(!1),be(!1),U(""),Ee(Be)},ze=Be=>{const ie=Dd();return{...Be,...Array.isArray(Be.availableMethods)?{availableMethods:Be.availableMethods.filter(O=>O!=="resources.recordVideo"||ie.camera||ie.screen)}:{},...typeof Be.sessionId=="string"?{busy:te.current.busy}:{}}},Le=(Be,ie,O,le,we)=>{Ce||!fe.grant||Be!==h.current?.contentWindow||Be.postMessage({type:"codeshell-panel:response",instanceId:fe.grant.instanceId,requestId:ie,...le?{error:le,...we?.code?{code:we.code}:{},...we?.retryAfterMs!==void 0?{retryAfterMs:we.retryAfterMs}:{}}:{result:O}},"*")},se=()=>{if(Ce||!fe.grant||W.current||F.current||dt)return;const Be=lt.shift();if(!Be)return;if(Be.expiresAt<=Date.now()){se();return}let ie=!1;const O={effect:Be,cancel:()=>{W.current===O&&(clearTimeout(le),W.current=void 0,Ce||(H(void 0),_(""),be(!1)))},finish:we=>{if(Ce||!fe.grant||W.current!==O||ie)return;ie=!0,be(!0),_("");const Z=new AbortController;_e.add(Z);const Te=setTimeout(()=>Z.abort(),8e3);Je(Dt(`${ri}/${fe.grant.instanceId}/confirm`,Q,oe),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:Be.requestId,allowed:we}),signal:Z.signal}).then(V=>{if(!(Ce||W.current!==O)){if(typeof V.allowed!="boolean")throw new Error("确认响应无效。");we&&V.allowed===!1&&N("此确认已超时或被取消,操作未获准执行,请在面板中重新发起。"),!we&&V.allowed===!0&&N("该操作此前已获准执行,请在面板中查看进度或停止。"),O.cancel(),se()}}).catch(V=>{if(!(Ce||W.current!==O)){if(V instanceof it&&[401,403,410].includes(V.status)){xe(V);return}if(V instanceof it&&V.status===409){O.cancel(),N("面板操作确认已失效,请在面板中重新发起。"),se();return}_("暂未收到确认结果。可以重试本次确认,或取消尚未执行的请求。")}}).finally(()=>{clearTimeout(Te),_e.delete(Z),ie=!1,!Ce&&W.current===O&&be(!1)})}},le=setTimeout(()=>{O.cancel(),!Ce&&fe.grant&&(N("面板操作确认已超时,请在面板中重新发起。"),se())},Be.expiresAt-Date.now());W.current=O,H(O),_("")},Re=Be=>{for(const ie of Be){if(ie.event!=="host.confirm"){Ge.push(ie);continue}const O=ie.payload;if(!on(O)||typeof O.requestId!="string"||!/^[A-Za-z0-9_-]{1,128}$/.test(O.requestId)||typeof O.title!="string"||O.title.length>500||typeof O.body!="string"||O.body.length>3e4)throw new Error("面板操作确认格式无效。");De.has(O.requestId)||(De.add(O.requestId),lt.push({effect:"host.confirm",requestId:O.requestId,title:O.title,body:O.body,expiresAt:Date.now()+5e4}))}if(Ge.length>2048||lt.length>32){xe(new Error("面板状态积压过多,请重新打开面板。"));return}se(),Ve()},Ne=Be=>new Promise(ie=>{if(W.current||F.current||dt){ie(!1);return}const O={effect:Be,finish:we=>{W.current===O&&(clearTimeout(le),W.current=void 0,Ce||H(void 0),ie(we),queueMicrotask(se))},cancel:()=>O.finish(!1)},le=setTimeout(()=>O.finish(!1),55e3);W.current=O,H(O)}),Qe=async Be=>{const ie=h.current?.contentWindow,O=fe.grant,le=Be.data;if(Ce||!ie||Be.source!==ie||Be.origin!=="null"||!O||!on(le)||le.instanceId!==O.instanceId)return;if(le.type==="codeshell-panel:ready"){rt=!0,nt();return}if(le.type==="codeshell-panel:tool-result"){if(typeof le.requestId!="string"||!Oe.has(le.requestId)||_e.size>=32)return;let ge;try{if(ge=JSON.stringify({requestId:le.requestId,...typeof le.error=="string"?{error:le.error}:{result:le.result}}),new TextEncoder().encode(ge).length>512*1024)return}catch{return}Oe.delete(le.requestId);const Ye=new AbortController;_e.add(Ye);const Ct=setTimeout(()=>Ye.abort(),8e3);try{await Je(Dt(`${ri}/${O.instanceId}/tool-results`,Q,oe),{method:"POST",headers:{"Content-Type":"application/json"},body:ge,signal:Ye.signal})}catch(he){!Ce&&fe.grant&&(he instanceof it&&[401,410].includes(he.status)?xe(he):N("面板工具结果未能送达,请在对话中重新发起操作。"))}finally{clearTimeout(Ct),_e.delete(Ye)}return}if(le.type!=="codeshell-panel:call"||typeof le.requestId!="string"||!/^[A-Za-z0-9_-]{1,80}$/.test(le.requestId))return;const we=le.requestId;if(Me.has(we)){Le(ie,we,void 0,"此请求已经处理,请重新发起。");return}if(Me.size>=8192||_e.size>=32){Le(ie,we,void 0,"面板请求过于频繁,请稍后重试。");return}if(Me.add(we),typeof le.method!="string"||!/^[A-Za-z][A-Za-z0-9.]{0,63}$/.test(le.method)){Le(ie,we,void 0,"面板方法无效。");return}let Z;try{if(Z=JSON.stringify({method:le.method,params:le.params}),new TextEncoder().encode(Z).length>3*1024*1024)throw new Error("too large")}catch{Le(ie,we,void 0,"面板请求内容过大或格式无效。");return}const Te=new AbortController;let V=!1;_e.add(Te);try{const ge=await Je(Dt(`${ri}/${O.instanceId}/call`,Q,oe),{method:"POST",headers:{"Content-Type":"application/json"},body:Z,signal:Te.signal});if(Ce||Te.signal.aborted)return;if(le.method==="context.get"&&(rt=!0,nt()),le.method==="external.open"){const Ye=on(ge)&&ge.effect===le.method?pj(ge.url):void 0;if(!Ye)throw new Error("面板返回的外部链接无效。");if(!await Ne({effect:"external.open",url:Ye}))throw new Error("你取消了打开链接,或确认已超时。");Le(ie,we,{opened:!0})}else if(le.method==="agent.submitPrompt"){if(!on(ge)||ge.effect!==le.method||typeof ge.prompt!="string"||!ge.prompt.trim()||ge.prompt.length>2e4||ge.sessionId!==r)throw new Error("面板任务与当前对话不匹配,请重新打开面板。");if(!await Ne({effect:"agent.submitPrompt",prompt:ge.prompt,sessionId:r}))throw new Error("你取消了发送任务,或确认已超时。");if(Ce||Te.signal.aborted)return;V=!0,dt=!0,be(!0);const Ye=await te.current.onSubmitPrompt({prompt:ge.prompt,sessionId:r,modelTraceSource:`panel:${t.id}`});if(Ce||Te.signal.aborted)return;N("面板任务已提交到当前对话,可切换到对话查看进度。"),Le(ie,we,Ye)}else if(le.method==="resources.recordVideo.capabilities"){if(!on(ge)||ge.effect!==le.method)throw new Error("视频录制能力响应无效。");Le(ie,we,Dd())}else if(le.method==="resources.recordAudio"||le.method==="resources.recordVideo"){const Ye=le.method==="resources.recordVideo";if(!on(ge)||ge.effect!==le.method)throw new Error("录制请求无效。");const Ct=Ye?gv(Object.fromEntries(Object.entries(ge).filter(([Ie])=>Ie!=="effect"))):void 0;if(Ct){const Ie=Dd();if(!Ie[Ct.source]||Ct.microphone&&!Ie.microphone)throw new Error("当前浏览器不支持所选视频录制方式,请检查安全连接和设备支持。")}if(!Ye&&(!on(ge)||ge.effect!==le.method||!Number.isInteger(ge.maxDurationSeconds)||Number(ge.maxDurationSeconds)<1||Number(ge.maxDurationSeconds)>600||!Number.isInteger(ge.maxBytes)||Number(ge.maxBytes)<1||Number(ge.maxBytes)>25*1024*1024))throw new Error("录音请求无效。");if(F.current||W.current||dt)throw new Error("请先完成当前的录制或确认操作。");const he=await new Promise((Ie,Pe)=>{let ot=!1;const Fe=(st,yt)=>{ot||(ot=!0,clearTimeout(Xt),Te.signal.removeEventListener("abort",At),F.current===Rt&&(F.current=void 0,Ce||($(void 0),G(void 0))),yt?Pe(yt):Ie(st),se())},At=()=>Fe(void 0,new Error("录制已关闭或授权已结束。")),Xt=setTimeout(()=>Fe(void 0,new Error("录制操作已超时,请重新打开。")),25*6e4),Rt={signal:Te.signal,maxDurationSeconds:Number(ge.maxDurationSeconds),maxBytes:Number(ge.maxBytes),...Ct?{...Ct,transferBudget:on(O.context.capabilities)&&on(O.context.capabilities.bridge)?O.context.capabilities.bridge:void 0}:{},call:async(st,yt,et)=>{const xt=et?AbortSignal.any([Te.signal,et]):Te.signal;if(xt.throwIfAborted(),Ce||fe.grant!==O)throw new Error("当前项目授权已结束。");try{const ut=await Je(Dt(`${ri}/${O.instanceId}/call`,Q,oe),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({method:st,params:yt}),signal:xt});if(xt.throwIfAborted(),Ce||fe.grant!==O)throw new Error("当前项目授权已结束。");return ut}catch(ut){throw ut instanceof it&&[401,403,410].includes(ut.status)&&xe(ut),ut}},finish:Fe};F.current=Rt,Te.signal.addEventListener("abort",At,{once:!0}),Ye?G(Rt):$(Rt)});Le(ie,we,he)}else if(le.method==="resources.open"){D(void 0),J(!1);const Ye=gj(ge,O.instanceId,on(le.params)?le.params.assetId:void 0);if(!Ye)throw new Error("面板文件预览链接无效,请重新打开文件。");D({...Ye,url:Dt(Ye.url,Q,oe),downloadUrl:Dt(`${Ye.url}?download=1`,Q,oe)}),Le(ie,we,{opened:!0})}else if(le.method==="filesystem.openDirectory"){if(E(void 0),!on(ge)||ge.effect!==le.method||typeof ge.path!="string")throw new Error("面板目录信息无效。");if(ge.url!==void 0&&!mj(ge.url,O.instanceId))throw new Error("面板目录链接无效,请重新打开目录。");E({path:ge.path,...typeof ge.url=="string"?{url:Dt(ge.url,Q,oe)}:{}}),Le(ie,we,{opened:!1,path:ge.path})}else if(le.method==="notifications.send"){if(!on(ge)||ge.effect!==le.method||typeof ge.title!="string"||ge.title.length>160||typeof ge.body!="string"||ge.body.length>2e3)throw new Error("面板通知格式无效。");N(`${ge.title}${ge.body?`:${ge.body}`:""}`),Le(ie,we,{sent:!0})}else Le(ie,we,le.method==="context.get"&&on(ge)?ze(ge):ge)}catch(ge){!Ce&&!Te.signal.aborted&&(ge instanceof it&&[401,410].includes(ge.status)&&xe(ge),(le.method==="agent.submitPrompt"||le.method==="external.open")&&N(ge instanceof Error?ge.message:"面板操作未完成。"),Le(ie,we,void 0,ge instanceof Error?ge.message:"面板请求失败。",ge instanceof it?{code:ge.code,retryAfterMs:ge.retryAfterMs}:void 0))}finally{_e.delete(Te),V&&(dt=!1,Ce||be(!1),se())}},Ue=Be=>{Qe(Be)};window.addEventListener("message",Ue);const bt=()=>qe?.refresh(),pt=()=>{document.visibilityState==="visible"&&bt()};return window.addEventListener("focus",bt),window.addEventListener("online",bt),document.addEventListener("visibilitychange",pt),Je(Dt(`${ri}/prepare`,Q,oe),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({appId:t.id,revision:t.revision,...r?{sessionId:r}:{},theme:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",locale:"zh-CN"}),signal:ke.signal}).then(Be=>{if(!bj(Be))throw new Error("面板启动信息无效,请刷新面板列表后重试。");if(Ce||ke.signal.aborted){ne(Be);return}if(Be.expiresAt<=Date.now())throw ne(Be),new Error("面板授权已过期,请重新打开。");fe.grant=Be,p({...Be,context:ze(Be.context),src:Dt(Be.src,Q,oe)}),ht=setTimeout(()=>{xe(new Error("面板未能完成加载,请重新打开。若仍无法加载,可检查面板文件或使用桌面客户端。"))},45e3),qe=aj({instanceId:Be.instanceId,expiresAt:Be.expiresAt,workspace:Q,projectId:oe,onEvents:Re,onTerminal:xe,onStatus:U})}).catch(Be=>{!Ce&&!ke.signal.aborted&&(b(!1),Ee(Be))}),()=>{Ce=!0,W.current?.cancel(),window.removeEventListener("message",Ue),window.removeEventListener("focus",bt),window.removeEventListener("online",bt),document.removeEventListener("visibilitychange",pt),qe?.stop(),ke.abort();for(const Be of _e)Be.abort();ht&&clearTimeout(ht),fe.grant&&ne(fe.grant),te.current.onDirtyChange?.(!1),ue.current===q&&(ue.current=void 0)}},[t.id,t.revision,r,R]),x.useEffect(()=>{!f||!h.current?.contentWindow||h.current.contentWindow.postMessage({type:"codeshell-panel:event",instanceId:f.instanceId,event:"context.changed",payload:{...f.context,...typeof f.context.sessionId=="string"?{busy:i}:{}}},"*")},[i,f]),a.jsxs("section",{className:"panel-host",children:[a.jsxs("header",{className:"panel-host-heading",children:[a.jsxs("div",{children:[a.jsx("h1",{children:t.title["zh-CN"]||t.title.default}),a.jsxs("p",{children:["v",t.version," · 运行于当前工作区"]})]}),a.jsx("button",{onClick:l,children:"返回面板"})]}),(f?.limitations??t.compatibility.reasons).length>0&&a.jsxs("details",{className:"panel-host-limitations",open:!0,children:[a.jsx("summary",{children:"部分功能可用"}),a.jsx("p",{children:"面板界面可以使用;以下功能尚未接入网页,使用时会显示具体限制。"}),a.jsx("ul",{children:(f?.limitations??t.compatibility.reasons).map(Q=>a.jsx("li",{children:Q},Q))})]}),j&&a.jsx("p",{className:"panel-host-notice",role:"status",children:j}),C&&a.jsxs("div",{className:"panel-host-notice panel-host-directory",role:"status",children:[a.jsxs("p",{children:["文件保存在服务器目录:",C.path]}),C.url&&a.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",children:"查看并下载文件"})]}),A&&a.jsxs("section",{className:"panel-host-preview","aria-label":"文件预览",tabIndex:-1,ref:T,children:[a.jsxs("header",{children:[a.jsx("h2",{children:A.name}),a.jsx("button",{onClick:()=>D(void 0),children:"关闭预览"})]}),!L&&A.kind==="video"&&a.jsx("video",{src:A.url,controls:!0,playsInline:!0,preload:"metadata",onError:()=>J(!0)},A.url),!L&&A.kind==="audio"&&a.jsx("audio",{src:A.url,controls:!0,preload:"metadata",onError:()=>J(!0)},A.url),!L&&A.kind==="image"&&a.jsx("img",{src:A.url,alt:A.name,onError:()=>J(!0)},A.url),(L||A.kind==="file")&&a.jsx("p",{role:"status",children:"当前浏览器无法预览此文件。可以保存后打开;若保存失败,请重新打开面板检查访问权限。"}),a.jsx("a",{href:A.downloadUrl,download:A.name,children:"保存到此设备"})]}),B&&a.jsx("p",{className:"panel-host-notice",role:"status",children:B}),v&&a.jsxs("div",{className:"panel-host-error",role:"alert",children:[a.jsx("p",{children:v}),a.jsx("button",{disabled:y,onClick:()=>M(Q=>Q+1),children:"重新打开面板"})]}),y&&a.jsx("p",{className:"panel-host-loading",role:"status",children:"正在打开面板…"}),Y&&a.jsx(cj,{request:Y}),P&&a.jsx(hj,{request:P}),I&&a.jsxs("section",{className:"panel-host-confirm",ref:me,tabIndex:-1,onKeyDown:Q=>{Q.key==="Escape"&&!re&&(Q.preventDefault(),I.finish(!1))},"aria-label":I.effect.effect==="external.open"?"确认打开外部链接":I.effect.effect==="host.confirm"?"确认面板操作":"确认发送面板任务",children:[a.jsx("h2",{children:I.effect.effect==="external.open"?"面板请求打开网页":I.effect.effect==="host.confirm"?I.effect.title:"面板请求向当前对话发送任务"}),I.effect.effect==="external.open"?a.jsx("p",{className:"panel-host-url",children:I.effect.url}):I.effect.effect==="host.confirm"?a.jsx("pre",{children:I.effect.body}):a.jsx("pre",{children:I.effect.prompt}),X&&a.jsx("p",{role:"alert",children:X}),a.jsxs("div",{className:"panel-host-actions",children:[a.jsx("button",{disabled:re,onClick:()=>I.finish(!1),children:"取消"}),I.effect.effect==="external.open"?a.jsx("a",{href:I.effect.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>I.finish(!0),children:"确认打开网页"}):a.jsx("button",{className:"panel-host-primary",disabled:re,onClick:()=>I.finish(!0),children:re?"正在确认…":I.effect.effect==="host.confirm"?"确认执行":"确认发送任务"})]})]}),f&&a.jsx("iframe",{ref:h,src:f.src,title:`${t.title["zh-CN"]||t.title.default}面板`,sandbox:"allow-scripts allow-downloads",referrerPolicy:"no-referrer",inert:!!I||re||!!Y||!!P,onLoad:()=>ue.current?.loaded(),allow:"camera 'none'; microphone 'none'; geolocation 'none'; display-capture 'none'; clipboard-read 'none'; clipboard-write 'none'",className:"panel-host-frame"})]})}function xj(t,r){const i={};return(t[t.length-1]===""?[...t,""]:t).join((i.padRight?" ":"")+","+(i.padLeft===!1?"":" ")).trim()}const wj=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Sj=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,jj={};function Vy(t,r){return(jj.jsx?Sj:wj).test(t)}const kj=/[ \t\n\f\r]/g;function Ej(t){return typeof t=="object"?t.type==="text"?Yy(t.value):!1:Yy(t)}function Yy(t){return t.replace(kj,"")===""}class Ul{constructor(r,i,l){this.normal=i,this.property=r,l&&(this.space=l)}}Ul.prototype.normal={};Ul.prototype.property={};Ul.prototype.space=void 0;function bv(t,r){const i={},l={};for(const o of t)Object.assign(i,o.property),Object.assign(l,o.normal);return new Ul(i,l,r)}function of(t){return t.toLowerCase()}class Cn{constructor(r,i){this.attribute=i,this.property=r}}Cn.prototype.attribute="";Cn.prototype.booleanish=!1;Cn.prototype.boolean=!1;Cn.prototype.commaOrSpaceSeparated=!1;Cn.prototype.commaSeparated=!1;Cn.prototype.defined=!1;Cn.prototype.mustUseProperty=!1;Cn.prototype.number=!1;Cn.prototype.overloadedBoolean=!1;Cn.prototype.property="";Cn.prototype.spaceSeparated=!1;Cn.prototype.space=void 0;let Cj=0;const ct=zi(),rn=zi(),uf=zi(),Ae=zi(),Ht=zi(),Ei=zi(),Dn=zi();function zi(){return 2**++Cj}const cf=Object.freeze(Object.defineProperty({__proto__:null,boolean:ct,booleanish:rn,commaOrSpaceSeparated:Dn,commaSeparated:Ei,number:Ae,overloadedBoolean:uf,spaceSeparated:Ht},Symbol.toStringTag,{value:"Module"})),Od=Object.keys(cf);class Lf extends Cn{constructor(r,i,l,o){let d=-1;if(super(r,i),Qy(this,"space",o),typeof l=="number")for(;++d<Od.length;){const c=Od[d];Qy(this,Od[d],(l&cf[c])===cf[c])}}}Lf.prototype.defined=!0;function Qy(t,r,i){i&&(t[r]=i)}function As(t){const r={},i={};for(const[l,o]of Object.entries(t.properties)){const d=new Lf(l,t.transform(t.attributes||{},l),o,t.space);t.mustUseProperty&&t.mustUseProperty.includes(l)&&(d.mustUseProperty=!0),r[l]=d,i[of(l)]=l,i[of(d.attribute)]=l}return new Ul(r,i,t.space)}const vv=As({properties:{ariaActiveDescendant:null,ariaAtomic:rn,ariaAutoComplete:null,ariaBusy:rn,ariaChecked:rn,ariaColCount:Ae,ariaColIndex:Ae,ariaColSpan:Ae,ariaControls:Ht,ariaCurrent:null,ariaDescribedBy:Ht,ariaDetails:null,ariaDisabled:rn,ariaDropEffect:Ht,ariaErrorMessage:null,ariaExpanded:rn,ariaFlowTo:Ht,ariaGrabbed:rn,ariaHasPopup:null,ariaHidden:rn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ht,ariaLevel:Ae,ariaLive:null,ariaModal:rn,ariaMultiLine:rn,ariaMultiSelectable:rn,ariaOrientation:null,ariaOwns:Ht,ariaPlaceholder:null,ariaPosInSet:Ae,ariaPressed:rn,ariaReadOnly:rn,ariaRelevant:null,ariaRequired:rn,ariaRoleDescription:Ht,ariaRowCount:Ae,ariaRowIndex:Ae,ariaRowSpan:Ae,ariaSelected:rn,ariaSetSize:Ae,ariaSort:null,ariaValueMax:Ae,ariaValueMin:Ae,ariaValueNow:Ae,ariaValueText:null,role:null},transform(t,r){return r==="role"?r:"aria-"+r.slice(4).toLowerCase()}});function xv(t,r){return r in t?t[r]:r}function wv(t,r){return xv(t,r.toLowerCase())}const Tj=As({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ei,acceptCharset:Ht,accessKey:Ht,action:null,allow:null,allowFullScreen:ct,allowPaymentRequest:ct,allowUserMedia:ct,alpha:ct,alt:null,as:null,async:ct,autoCapitalize:null,autoComplete:Ht,autoFocus:ct,autoPlay:ct,blocking:Ht,capture:null,charSet:null,checked:ct,cite:null,className:Ht,closedBy:null,colorSpace:null,cols:Ae,colSpan:Ae,command:null,commandFor:null,content:null,contentEditable:rn,controls:ct,controlsList:Ht,coords:Ae|Ei,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ct,defer:ct,dir:null,dirName:null,disabled:ct,download:uf,draggable:rn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ct,formTarget:null,headers:Ht,height:Ae,hidden:uf,high:Ae,href:null,hrefLang:null,htmlFor:Ht,httpEquiv:Ht,id:null,imageSizes:null,imageSrcSet:null,inert:ct,inputMode:null,integrity:null,is:null,isMap:ct,itemId:null,itemProp:Ht,itemRef:Ht,itemScope:ct,itemType:Ht,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ct,low:Ae,manifest:null,max:null,maxLength:Ae,media:null,method:null,min:null,minLength:Ae,multiple:ct,muted:ct,name:null,nonce:null,noModule:ct,noValidate:ct,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:ct,optimum:Ae,pattern:null,ping:Ht,placeholder:null,playsInline:ct,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ct,referrerPolicy:null,rel:Ht,required:ct,reversed:ct,rows:Ae,rowSpan:Ae,sandbox:Ht,scope:null,scoped:ct,seamless:ct,selected:ct,shadowRootClonable:ct,shadowRootCustomElementRegistry:ct,shadowRootDelegatesFocus:ct,shadowRootMode:null,shadowRootSerializable:ct,shape:null,size:Ae,sizes:null,slot:null,span:Ae,spellCheck:rn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ae,step:null,style:null,tabIndex:Ae,target:null,title:null,translate:null,type:null,typeMustMatch:ct,useMap:null,value:rn,width:Ae,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ht,axis:null,background:null,bgColor:null,border:Ae,borderColor:null,bottomMargin:Ae,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ct,declare:ct,event:null,face:null,frame:null,frameBorder:null,hSpace:Ae,leftMargin:Ae,link:null,longDesc:null,lowSrc:null,marginHeight:Ae,marginWidth:Ae,noResize:ct,noHref:ct,noShade:ct,noWrap:ct,object:null,profile:null,prompt:null,rev:null,rightMargin:Ae,rules:null,scheme:null,scrolling:rn,standby:null,summary:null,text:null,topMargin:Ae,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ae,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:ct,disablePictureInPicture:ct,disableRemotePlayback:ct,exportParts:Ei,part:Ht,prefix:null,property:null,results:Ae,security:null,unselectable:null},space:"html",transform:wv}),Nj=As({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:Dn,accentHeight:Ae,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ae,amplitude:Ae,arabicForm:null,ascent:Ae,attributeName:null,attributeType:null,azimuth:Ae,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ae,by:null,calcMode:null,capHeight:Ae,className:Ht,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:Ae,diffuseConstant:Ae,direction:null,display:null,dur:null,divisor:Ae,dominantBaseline:null,download:ct,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ae,enableBackground:null,end:null,event:null,exponent:Ae,externalResourcesRequired:null,fill:null,fillOpacity:Ae,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:Ei,g2:Ei,glyphName:Ei,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ae,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ae,horizOriginX:Ae,horizOriginY:Ae,id:null,ideographic:Ae,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ae,k:Ae,k1:Ae,k2:Ae,k3:Ae,k4:Ae,kernelMatrix:Dn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ae,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:Ae,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:Ae,overlineThickness:Ae,paintOrder:null,panose1:null,path:null,pathLength:Ae,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ht,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ae,pointsAtY:Ae,pointsAtZ:Ae,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Dn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Dn,rev:Dn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Dn,requiredFeatures:Dn,requiredFonts:Dn,requiredFormats:Dn,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:Ae,specularExponent:Ae,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ae,strikethroughThickness:Ae,string:null,stroke:null,strokeDashArray:Dn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ae,strokeOpacity:Ae,strokeWidth:null,style:null,surfaceScale:Ae,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Dn,tabIndex:Ae,tableValues:null,target:null,targetX:Ae,targetY:Ae,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Dn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ae,underlineThickness:Ae,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ae,values:null,vAlphabetic:Ae,vMathematical:Ae,vectorEffect:null,vHanging:Ae,vIdeographic:Ae,version:null,vertAdvY:Ae,vertOriginX:Ae,vertOriginY:Ae,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ae,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:xv}),Sv=As({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,r){return"xlink:"+r.slice(5).toLowerCase()}}),jv=As({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:wv}),kv=As({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,r){return"xml:"+r.slice(3).toLowerCase()}}),Aj={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"},Rj=/[A-Z]/g,Ky=/-[a-z]/g,zj=/^data[-\w.:]+$/i;function _j(t,r){const i=of(r);let l=r,o=Cn;if(i in t.normal)return t.property[t.normal[i]];if(i.length>4&&i.slice(0,4)==="data"&&zj.test(r)){if(r.charAt(4)==="-"){const d=r.slice(5).replace(Ky,Dj);l="data"+d.charAt(0).toUpperCase()+d.slice(1)}else{const d=r.slice(4);if(!Ky.test(d)){let c=d.replace(Rj,Mj);c.charAt(0)!=="-"&&(c="-"+c),r="data"+c}}o=Lf}return new o(l,r)}function Mj(t){return"-"+t.toLowerCase()}function Dj(t){return t.charAt(1).toUpperCase()}const Oj=bv([vv,Tj,Sv,jv,kv],"html"),If=bv([vv,Nj,Sv,jv,kv],"svg");function Lj(t){return t.join(" ").trim()}var vs={},Ld,Xy;function Ij(){if(Xy)return Ld;Xy=1;var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,l=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,d=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,h=/^\s+|\s+$/g,f=`
|
|
45
|
+
`,p="/",y="*",b="",v="comment",w="declaration";function j(C,E){if(typeof C!="string")throw new TypeError("First argument must be a string");if(!C)return[];E=E||{};var A=1,D=1;function L($){var F=$.match(r);F&&(A+=F.length);var P=$.lastIndexOf(f);D=~P?$.length-P:D+$.length}function J(){var $={line:A,column:D};return function(F){return F.position=new T($),X(),F}}function T($){this.start=$,this.end={line:A,column:D},this.source=E.source}T.prototype.content=C;function B($){var F=new Error(E.source+":"+A+":"+D+": "+$);if(F.reason=$,F.filename=E.source,F.line=A,F.column=D,F.source=C,!E.silent)throw F}function U($){var F=$.exec(C);if(F){var P=F[0];return L(P),C=C.slice(P.length),F}}function X(){U(i)}function _($){var F;for($=$||[];F=I();)F!==!1&&$.push(F);return $}function I(){var $=J();if(!(p!=C.charAt(0)||y!=C.charAt(1))){for(var F=2;b!=C.charAt(F)&&(y!=C.charAt(F)||p!=C.charAt(F+1));)++F;if(F+=2,b===C.charAt(F-1))return B("End of comment missing");var P=C.slice(2,F-2);return D+=2,L(P),C=C.slice(F),D+=2,$({type:v,comment:P})}}function H(){var $=J(),F=U(l);if(F){if(I(),!U(o))return B("property missing ':'");var P=U(d),G=$({type:w,property:N(F[0].replace(t,b)),value:P?N(P[0].replace(t,b)):b});return U(c),G}}function Y(){var $=[];_($);for(var F;F=H();)F!==!1&&($.push(F),_($));return $}return X(),Y()}function N(C){return C?C.replace(h,b):b}return Ld=j,Ld}var Zy;function Bj(){if(Zy)return vs;Zy=1;var t=vs&&vs.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(vs,"__esModule",{value:!0}),vs.default=i;const r=t(Ij());function i(l,o){let d=null;if(!l||typeof l!="string")return d;const c=(0,r.default)(l),h=typeof o=="function";return c.forEach(f=>{if(f.type!=="declaration")return;const{property:p,value:y}=f;h?o(p,y,f):y&&(d=d||{},d[p]=y)}),d}return vs}var El={},Jy;function qj(){if(Jy)return El;Jy=1,Object.defineProperty(El,"__esModule",{value:!0}),El.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,r=/-([a-z])/g,i=/^[^-]+$/,l=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,d=function(p){return!p||i.test(p)||t.test(p)},c=function(p,y){return y.toUpperCase()},h=function(p,y){return"".concat(y,"-")},f=function(p,y){return y===void 0&&(y={}),d(p)?p:(p=p.toLowerCase(),y.reactCompat?p=p.replace(o,h):p=p.replace(l,h),p.replace(r,c))};return El.camelCase=f,El}var Cl,Wy;function Uj(){if(Wy)return Cl;Wy=1;var t=Cl&&Cl.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},r=t(Bj()),i=qj();function l(o,d){var c={};return!o||typeof o!="string"||(0,r.default)(o,function(h,f){h&&f&&(c[(0,i.camelCase)(h,d)]=f)}),c}return l.default=l,Cl=l,Cl}var Hj=Uj();const Pj=zo(Hj),Ev=Cv("end"),Bf=Cv("start");function Cv(t){return r;function r(i){const l=i&&i.position&&i.position[t]||{};if(typeof l.line=="number"&&l.line>0&&typeof l.column=="number"&&l.column>0)return{line:l.line,column:l.column,offset:typeof l.offset=="number"&&l.offset>-1?l.offset:void 0}}}function Fj(t){const r=Bf(t),i=Ev(t);if(r&&i)return{start:r,end:i}}function zl(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?eb(t.position):"start"in t||"end"in t?eb(t):"line"in t||"column"in t?df(t):""}function df(t){return tb(t&&t.line)+":"+tb(t&&t.column)}function eb(t){return df(t&&t.start)+"-"+df(t&&t.end)}function tb(t){return t&&typeof t=="number"?t:1}class gn extends Error{constructor(r,i,l){super(),typeof i=="string"&&(l=i,i=void 0);let o="",d={},c=!1;if(i&&("line"in i&&"column"in i?d={place:i}:"start"in i&&"end"in i?d={place:i}:"type"in i?d={ancestors:[i],place:i.position}:d={...i}),typeof r=="string"?o=r:!d.cause&&r&&(c=!0,o=r.message,d.cause=r),!d.ruleId&&!d.source&&typeof l=="string"){const f=l.indexOf(":");f===-1?d.ruleId=l:(d.source=l.slice(0,f),d.ruleId=l.slice(f+1))}if(!d.place&&d.ancestors&&d.ancestors){const f=d.ancestors[d.ancestors.length-1];f&&(d.place=f.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=o,this.line=h?h.line:void 0,this.name=zl(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}}gn.prototype.file="";gn.prototype.name="";gn.prototype.reason="";gn.prototype.message="";gn.prototype.stack="";gn.prototype.column=void 0;gn.prototype.line=void 0;gn.prototype.ancestors=void 0;gn.prototype.cause=void 0;gn.prototype.fatal=void 0;gn.prototype.place=void 0;gn.prototype.ruleId=void 0;gn.prototype.source=void 0;const qf={}.hasOwnProperty,$j=new Map,Gj=/[A-Z]/g,Vj=new Set(["table","tbody","thead","tfoot","tr"]),Yj=new Set(["td","th"]),Tv="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Qj(t,r){if(!r||r.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const i=r.filePath||void 0;let l;if(r.development){if(typeof r.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");l=nk(i,r.jsxDEV)}else{if(typeof r.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof r.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");l=tk(i,r.jsx,r.jsxs)}const o={Fragment:r.Fragment,ancestors:[],components:r.components||{},create:l,elementAttributeNameCase:r.elementAttributeNameCase||"react",evaluater:r.createEvaluater?r.createEvaluater():void 0,filePath:i,ignoreInvalidStyle:r.ignoreInvalidStyle||!1,passKeys:r.passKeys!==!1,passNode:r.passNode||!1,schema:r.space==="svg"?If:Oj,stylePropertyNameCase:r.stylePropertyNameCase||"dom",tableCellAlignToStyle:r.tableCellAlignToStyle!==!1},d=Nv(o,t,void 0);return d&&typeof d!="string"?d:o.create(t,o.Fragment,{children:d||void 0},void 0)}function Nv(t,r,i){if(r.type==="element")return Kj(t,r,i);if(r.type==="mdxFlowExpression"||r.type==="mdxTextExpression")return Xj(t,r);if(r.type==="mdxJsxFlowElement"||r.type==="mdxJsxTextElement")return Jj(t,r,i);if(r.type==="mdxjsEsm")return Zj(t,r);if(r.type==="root")return Wj(t,r,i);if(r.type==="text")return ek(t,r)}function Kj(t,r,i){const l=t.schema;let o=l;r.tagName.toLowerCase()==="svg"&&l.space==="html"&&(o=If,t.schema=o),t.ancestors.push(r);const d=Rv(t,r.tagName,!1),c=rk(t,r);let h=Hf(t,r);return Vj.has(r.tagName)&&(h=h.filter(function(f){return typeof f=="string"?!Ej(f):!0})),Av(t,c,d,r),Uf(c,h),t.ancestors.pop(),t.schema=l,t.create(r,d,c,i)}function Xj(t,r){if(r.data&&r.data.estree&&t.evaluater){const l=r.data.estree.body[0];return l.type,t.evaluater.evaluateExpression(l.expression)}Ol(t,r.position)}function Zj(t,r){if(r.data&&r.data.estree&&t.evaluater)return t.evaluater.evaluateProgram(r.data.estree);Ol(t,r.position)}function Jj(t,r,i){const l=t.schema;let o=l;r.name==="svg"&&l.space==="html"&&(o=If,t.schema=o),t.ancestors.push(r);const d=r.name===null?t.Fragment:Rv(t,r.name,!0),c=ik(t,r),h=Hf(t,r);return Av(t,c,d,r),Uf(c,h),t.ancestors.pop(),t.schema=l,t.create(r,d,c,i)}function Wj(t,r,i){const l={};return Uf(l,Hf(t,r)),t.create(r,t.Fragment,l,i)}function ek(t,r){return r.value}function Av(t,r,i,l){typeof i!="string"&&i!==t.Fragment&&t.passNode&&(r.node=l)}function Uf(t,r){if(r.length>0){const i=r.length>1?r:r[0];i&&(t.children=i)}}function tk(t,r,i){return l;function l(o,d,c,h){const p=Array.isArray(c.children)?i:r;return h?p(d,c,h):p(d,c)}}function nk(t,r){return i;function i(l,o,d,c){const h=Array.isArray(d.children),f=Bf(l);return r(o,d,c,h,{columnNumber:f?f.column-1:void 0,fileName:t,lineNumber:f?f.line:void 0},void 0)}}function rk(t,r){const i={};let l,o;for(o in r.properties)if(o!=="children"&&qf.call(r.properties,o)){const d=sk(t,o,r.properties[o]);if(d){const[c,h]=d;t.tableCellAlignToStyle&&c==="align"&&typeof h=="string"&&Yj.has(r.tagName)?l=h:i[c]=h}}if(l){const d=i.style||(i.style={});d[t.stylePropertyNameCase==="css"?"text-align":"textAlign"]=l}return i}function ik(t,r){const i={};for(const l of r.attributes)if(l.type==="mdxJsxExpressionAttribute")if(l.data&&l.data.estree&&t.evaluater){const d=l.data.estree.body[0];d.type;const c=d.expression;c.type;const h=c.properties[0];h.type,Object.assign(i,t.evaluater.evaluateExpression(h.argument))}else Ol(t,r.position);else{const o=l.name;let d;if(l.value&&typeof l.value=="object")if(l.value.data&&l.value.data.estree&&t.evaluater){const h=l.value.data.estree.body[0];h.type,d=t.evaluater.evaluateExpression(h.expression)}else Ol(t,r.position);else d=l.value===null?!0:l.value;i[o]=d}return i}function Hf(t,r){const i=[];let l=-1;const o=t.passKeys?new Map:$j;for(;++l<r.children.length;){const d=r.children[l];let c;if(t.passKeys){const f=d.type==="element"?d.tagName:d.type==="mdxJsxFlowElement"||d.type==="mdxJsxTextElement"?d.name:void 0;if(f){const p=o.get(f)||0;c=f+"-"+p,o.set(f,p+1)}}const h=Nv(t,d,c);h!==void 0&&i.push(h)}return i}function sk(t,r,i){const l=_j(t.schema,r);if(!(i==null||typeof i=="number"&&Number.isNaN(i))){if(Array.isArray(i)&&(i=l.commaSeparated?xj(i):Lj(i)),l.property==="style"){let o=typeof i=="object"?i:lk(t,String(i));return t.stylePropertyNameCase==="css"&&(o=ak(o)),["style",o]}return[t.elementAttributeNameCase==="react"&&l.space?Aj[l.property]||l.property:l.attribute,i]}}function lk(t,r){try{return Pj(r,{reactCompat:!0})}catch(i){if(t.ignoreInvalidStyle)return{};const l=i,o=new gn("Cannot parse `style` attribute",{ancestors:t.ancestors,cause:l,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=t.filePath||void 0,o.url=Tv+"#cannot-parse-style-attribute",o}}function Rv(t,r,i){let l;if(!i)l={type:"Literal",value:r};else if(r.includes(".")){const o=r.split(".");let d=-1,c;for(;++d<o.length;){const h=Vy(o[d])?{type:"Identifier",name:o[d]}:{type:"Literal",value:o[d]};c=c?{type:"MemberExpression",object:c,property:h,computed:!!(d&&h.type==="Literal"),optional:!1}:h}l=c}else l=Vy(r)&&!/^[a-z]/.test(r)?{type:"Identifier",name:r}:{type:"Literal",value:r};if(l.type==="Literal"){const o=l.value;return qf.call(t.components,o)?t.components[o]:o}if(t.evaluater)return t.evaluater.evaluateExpression(l);Ol(t)}function Ol(t,r){const i=new gn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:t.ancestors,place:r,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw i.file=t.filePath||void 0,i.url=Tv+"#cannot-handle-mdx-estrees-without-createevaluater",i}function ak(t){const r={};let i;for(i in t)qf.call(t,i)&&(r[ok(i)]=t[i]);return r}function ok(t){let r=t.replace(Gj,uk);return r.slice(0,3)==="ms-"&&(r="-"+r),r}function uk(t){return"-"+t.toLowerCase()}const Id={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"]},ck={};function Pf(t,r){const i=ck,l=typeof i.includeImageAlt=="boolean"?i.includeImageAlt:!0,o=typeof i.includeHtml=="boolean"?i.includeHtml:!0;return zv(t,l,o)}function zv(t,r,i){if(dk(t)){if("value"in t)return t.type==="html"&&!i?"":t.value;if(r&&"alt"in t&&t.alt)return t.alt;if("children"in t)return nb(t.children,r,i)}return Array.isArray(t)?nb(t,r,i):""}function nb(t,r,i){const l=[];let o=-1;for(;++o<t.length;)l[o]=zv(t[o],r,i);return l.join("")}function dk(t){return!!(t&&typeof t=="object")}const rb=document.createElement("i");function Ff(t){const r="&"+t+";";rb.innerHTML=r;const i=rb.textContent;return i.charCodeAt(i.length-1)===59&&t!=="semi"||i===r?!1:i}function On(t,r,i,l){const o=t.length;let d=0,c;if(r<0?r=-r>o?0:o+r:r=r>o?o:r,i=i>0?i:0,l.length<1e4)c=Array.from(l),c.unshift(r,i),t.splice(...c);else for(i&&t.splice(r,i);d<l.length;)c=l.slice(d,d+1e4),c.unshift(r,0),t.splice(...c),d+=1e4,r+=1e4}function Vn(t,r){return t.length>0?(On(t,t.length,0,r),t):r}const ib={}.hasOwnProperty;function _v(t){const r={};let i=-1;for(;++i<t.length;)fk(r,t[i]);return r}function fk(t,r){let i;for(i in r){const o=(ib.call(t,i)?t[i]:void 0)||(t[i]={}),d=r[i];let c;if(d)for(c in d){ib.call(o,c)||(o[c]=[]);const h=d[c];hk(o[c],Array.isArray(h)?h:h?[h]:[])}}}function hk(t,r){let i=-1;const l=[];for(;++i<r.length;)(r[i].add==="after"?t:l).push(r[i]);On(t,0,0,l)}function Mv(t,r){const i=Number.parseInt(t,r);return i<9||i===11||i>13&&i<32||i>126&&i<160||i>55295&&i<57344||i>64975&&i<65008||(i&65535)===65535||(i&65535)===65534||i>1114111?"�":String.fromCodePoint(i)}function Jn(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const bn=ii(/[A-Za-z]/),mn=ii(/[\dA-Za-z]/),pk=ii(/[#-'*+\--9=?A-Z^-~]/);function Co(t){return t!==null&&(t<32||t===127)}const ff=ii(/\d/),mk=ii(/[\dA-Fa-f]/),gk=ii(/[!-/:-@[-`{-~]/);function We(t){return t!==null&&t<-2}function Pt(t){return t!==null&&(t<0||t===32)}function jt(t){return t===-2||t===-1||t===32}const Do=ii(new RegExp("\\p{P}|\\p{S}","u")),Ci=ii(/\s/);function ii(t){return r;function r(i){return i!==null&&i>-1&&t.test(String.fromCharCode(i))}}function Rs(t){const r=[];let i=-1,l=0,o=0;for(;++i<t.length;){const d=t.charCodeAt(i);let c="";if(d===37&&mn(t.charCodeAt(i+1))&&mn(t.charCodeAt(i+2)))o=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(i+1);d<56320&&h>56319&&h<57344?(c=String.fromCharCode(d,h),o=1):c="�"}else c=String.fromCharCode(d);c&&(r.push(t.slice(l,i),encodeURIComponent(c)),l=i+o+1,c=""),o&&(i+=o,o=0)}return r.join("")+t.slice(l)}function Nt(t,r,i,l){const o=l?l-1:Number.POSITIVE_INFINITY;let d=0;return c;function c(f){return jt(f)?(t.enter(i),h(f)):r(f)}function h(f){return jt(f)&&d++<o?(t.consume(f),h):(t.exit(i),r(f))}}const yk={tokenize:bk};function bk(t){const r=t.attempt(this.parser.constructs.contentInitial,l,o);let i;return r;function l(h){if(h===null){t.consume(h);return}return t.enter("lineEnding"),t.consume(h),t.exit("lineEnding"),Nt(t,r,"linePrefix")}function o(h){return t.enter("paragraph"),d(h)}function d(h){const f=t.enter("chunkText",{contentType:"text",previous:i});return i&&(i.next=f),i=f,c(h)}function c(h){if(h===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(h);return}return We(h)?(t.consume(h),t.exit("chunkText"),d):(t.consume(h),c)}}const vk={tokenize:xk},sb={tokenize:wk};function xk(t){const r=this,i=[];let l=0,o,d,c;return h;function h(D){if(l<i.length){const L=i[l];return r.containerState=L[1],t.attempt(L[0].continuation,f,p)(D)}return p(D)}function f(D){if(l++,r.containerState._closeFlow){r.containerState._closeFlow=void 0,o&&A();const L=r.events.length;let J=L,T;for(;J--;)if(r.events[J][0]==="exit"&&r.events[J][1].type==="chunkFlow"){T=r.events[J][1].end;break}E(l);let B=L;for(;B<r.events.length;)r.events[B][1].end={...T},B++;return On(r.events,J+1,0,r.events.slice(L)),r.events.length=B,p(D)}return h(D)}function p(D){if(l===i.length){if(!o)return v(D);if(o.currentConstruct&&o.currentConstruct.concrete)return j(D);r.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return r.containerState={},t.check(sb,y,b)(D)}function y(D){return o&&A(),E(l),v(D)}function b(D){return r.parser.lazy[r.now().line]=l!==i.length,c=r.now().offset,j(D)}function v(D){return r.containerState={},t.attempt(sb,w,j)(D)}function w(D){return l++,i.push([r.currentConstruct,r.containerState]),v(D)}function j(D){if(D===null){o&&A(),E(0),t.consume(D);return}return o=o||r.parser.flow(r.now()),t.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:d}),N(D)}function N(D){if(D===null){C(t.exit("chunkFlow"),!0),E(0),t.consume(D);return}return We(D)?(t.consume(D),C(t.exit("chunkFlow")),l=0,r.interrupt=void 0,h):(t.consume(D),N)}function C(D,L){const J=r.sliceStream(D);if(L&&J.push(null),D.previous=d,d&&(d.next=D),d=D,o.defineSkip(D.start),o.write(J),r.parser.lazy[D.start.line]){let T=o.events.length;for(;T--;)if(o.events[T][1].start.offset<c&&(!o.events[T][1].end||o.events[T][1].end.offset>c))return;const B=r.events.length;let U=B,X,_;for(;U--;)if(r.events[U][0]==="exit"&&r.events[U][1].type==="chunkFlow"){if(X){_=r.events[U][1].end;break}X=!0}for(E(l),T=B;T<r.events.length;)r.events[T][1].end={..._},T++;On(r.events,U+1,0,r.events.slice(B)),r.events.length=T}}function E(D){let L=i.length;for(;L-- >D;){const J=i[L];r.containerState=J[1],J[0].exit.call(r,t)}i.length=D}function A(){o.write([null]),d=void 0,o=void 0,r.containerState._closeFlow=void 0}}function wk(t,r,i){return Nt(t,t.attempt(this.parser.constructs.document,r,i),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ts(t){if(t===null||Pt(t)||Ci(t))return 1;if(Do(t))return 2}function Oo(t,r,i){const l=[];let o=-1;for(;++o<t.length;){const d=t[o].resolveAll;d&&!l.includes(d)&&(r=d(r,i),l.push(d))}return r}const hf={name:"attention",resolveAll:Sk,tokenize:jk};function Sk(t,r){let i=-1,l,o,d,c,h,f,p,y;for(;++i<t.length;)if(t[i][0]==="enter"&&t[i][1].type==="attentionSequence"&&t[i][1]._close){for(l=i;l--;)if(t[l][0]==="exit"&&t[l][1].type==="attentionSequence"&&t[l][1]._open&&r.sliceSerialize(t[l][1]).charCodeAt(0)===r.sliceSerialize(t[i][1]).charCodeAt(0)){if((t[l][1]._close||t[i][1]._open)&&(t[i][1].end.offset-t[i][1].start.offset)%3&&!((t[l][1].end.offset-t[l][1].start.offset+t[i][1].end.offset-t[i][1].start.offset)%3))continue;f=t[l][1].end.offset-t[l][1].start.offset>1&&t[i][1].end.offset-t[i][1].start.offset>1?2:1;const b={...t[l][1].end},v={...t[i][1].start};lb(b,-f),lb(v,f),c={type:f>1?"strongSequence":"emphasisSequence",start:b,end:{...t[l][1].end}},h={type:f>1?"strongSequence":"emphasisSequence",start:{...t[i][1].start},end:v},d={type:f>1?"strongText":"emphasisText",start:{...t[l][1].end},end:{...t[i][1].start}},o={type:f>1?"strong":"emphasis",start:{...c.start},end:{...h.end}},t[l][1].end={...c.start},t[i][1].start={...h.end},p=[],t[l][1].end.offset-t[l][1].start.offset&&(p=Vn(p,[["enter",t[l][1],r],["exit",t[l][1],r]])),p=Vn(p,[["enter",o,r],["enter",c,r],["exit",c,r],["enter",d,r]]),p=Vn(p,Oo(r.parser.constructs.insideSpan.null,t.slice(l+1,i),r)),p=Vn(p,[["exit",d,r],["enter",h,r],["exit",h,r],["exit",o,r]]),t[i][1].end.offset-t[i][1].start.offset?(y=2,p=Vn(p,[["enter",t[i][1],r],["exit",t[i][1],r]])):y=0,On(t,l-1,i-l+3,p),i=l+p.length-y-2;break}}for(i=-1;++i<t.length;)t[i][1].type==="attentionSequence"&&(t[i][1].type="data");return t}function jk(t,r){const i=this.parser.constructs.attentionMarkers.null,l=this.previous,o=Ts(l);let d;return c;function c(f){return d=f,t.enter("attentionSequence"),h(f)}function h(f){if(f===d)return t.consume(f),h;const p=t.exit("attentionSequence"),y=Ts(f),b=!y||y===2&&o||i.includes(f),v=!o||o===2&&y||i.includes(l);return p._open=!!(d===42?b:b&&(o||!v)),p._close=!!(d===42?v:v&&(y||!b)),r(f)}}function lb(t,r){t.column+=r,t.offset+=r,t._bufferIndex+=r}const kk={name:"autolink",tokenize:Ek};function Ek(t,r,i){let l=0;return o;function o(w){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(w),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),d}function d(w){return bn(w)?(t.consume(w),c):w===64?i(w):p(w)}function c(w){return w===43||w===45||w===46||mn(w)?(l=1,h(w)):p(w)}function h(w){return w===58?(t.consume(w),l=0,f):(w===43||w===45||w===46||mn(w))&&l++<32?(t.consume(w),h):(l=0,p(w))}function f(w){return w===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(w),t.exit("autolinkMarker"),t.exit("autolink"),r):w===null||w===32||w===60||Co(w)?i(w):(t.consume(w),f)}function p(w){return w===64?(t.consume(w),y):pk(w)?(t.consume(w),p):i(w)}function y(w){return mn(w)?b(w):i(w)}function b(w){return w===46?(t.consume(w),l=0,y):w===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(w),t.exit("autolinkMarker"),t.exit("autolink"),r):v(w)}function v(w){if((w===45||mn(w))&&l++<63){const j=w===45?v:b;return t.consume(w),j}return i(w)}}const Hl={partial:!0,tokenize:Ck};function Ck(t,r,i){return l;function l(d){return jt(d)?Nt(t,o,"linePrefix")(d):o(d)}function o(d){return d===null||We(d)?r(d):i(d)}}const Dv={continuation:{tokenize:Nk},exit:Ak,name:"blockQuote",tokenize:Tk};function Tk(t,r,i){const l=this;return o;function o(c){if(c===62){const h=l.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 i(c)}function d(c){return jt(c)?(t.enter("blockQuotePrefixWhitespace"),t.consume(c),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),r):(t.exit("blockQuotePrefix"),r(c))}}function Nk(t,r,i){const l=this;return o;function o(c){return jt(c)?Nt(t,d,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):d(c)}function d(c){return t.attempt(Dv,r,i)(c)}}function Ak(t){t.exit("blockQuote")}const Ov={name:"characterEscape",tokenize:Rk};function Rk(t,r,i){return l;function l(d){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(d),t.exit("escapeMarker"),o}function o(d){return gk(d)?(t.enter("characterEscapeValue"),t.consume(d),t.exit("characterEscapeValue"),t.exit("characterEscape"),r):i(d)}}const Lv={name:"characterReference",tokenize:zk};function zk(t,r,i){const l=this;let o=0,d,c;return h;function h(b){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(b),t.exit("characterReferenceMarker"),f}function f(b){return b===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(b),t.exit("characterReferenceMarkerNumeric"),p):(t.enter("characterReferenceValue"),d=31,c=mn,y(b))}function p(b){return b===88||b===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(b),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),d=6,c=mk,y):(t.enter("characterReferenceValue"),d=7,c=ff,y(b))}function y(b){if(b===59&&o){const v=t.exit("characterReferenceValue");return c===mn&&!Ff(l.sliceSerialize(v))?i(b):(t.enter("characterReferenceMarker"),t.consume(b),t.exit("characterReferenceMarker"),t.exit("characterReference"),r)}return c(b)&&o++<d?(t.consume(b),y):i(b)}}const ab={partial:!0,tokenize:Mk},ob={concrete:!0,name:"codeFenced",tokenize:_k};function _k(t,r,i){const l=this,o={partial:!0,tokenize:J};let d=0,c=0,h;return f;function f(T){return p(T)}function p(T){const B=l.events[l.events.length-1];return d=B&&B[1].type==="linePrefix"?B[2].sliceSerialize(B[1],!0).length:0,h=T,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),y(T)}function y(T){return T===h?(c++,t.consume(T),y):c<3?i(T):(t.exit("codeFencedFenceSequence"),jt(T)?Nt(t,b,"whitespace")(T):b(T))}function b(T){return T===null||We(T)?(t.exit("codeFencedFence"),l.interrupt?r(T):t.check(ab,N,L)(T)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),v(T))}function v(T){return T===null||We(T)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),b(T)):jt(T)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),Nt(t,w,"whitespace")(T)):T===96&&T===h?i(T):(t.consume(T),v)}function w(T){return T===null||We(T)?b(T):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),j(T))}function j(T){return T===null||We(T)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),b(T)):T===96&&T===h?i(T):(t.consume(T),j)}function N(T){return t.attempt(o,L,C)(T)}function C(T){return t.enter("lineEnding"),t.consume(T),t.exit("lineEnding"),E}function E(T){return d>0&&jt(T)?Nt(t,A,"linePrefix",d+1)(T):A(T)}function A(T){return T===null||We(T)?t.check(ab,N,L)(T):(t.enter("codeFlowValue"),D(T))}function D(T){return T===null||We(T)?(t.exit("codeFlowValue"),A(T)):(t.consume(T),D)}function L(T){return t.exit("codeFenced"),r(T)}function J(T,B,U){let X=0;return _;function _(F){return T.enter("lineEnding"),T.consume(F),T.exit("lineEnding"),I}function I(F){return T.enter("codeFencedFence"),jt(F)?Nt(T,H,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):H(F)}function H(F){return F===h?(T.enter("codeFencedFenceSequence"),Y(F)):U(F)}function Y(F){return F===h?(X++,T.consume(F),Y):X>=c?(T.exit("codeFencedFenceSequence"),jt(F)?Nt(T,$,"whitespace")(F):$(F)):U(F)}function $(F){return F===null||We(F)?(T.exit("codeFencedFence"),B(F)):U(F)}}}function Mk(t,r,i){const l=this;return o;function o(c){return c===null?i(c):(t.enter("lineEnding"),t.consume(c),t.exit("lineEnding"),d)}function d(c){return l.parser.lazy[l.now().line]?i(c):r(c)}}const Bd={name:"codeIndented",tokenize:Ok},Dk={partial:!0,tokenize:Lk};function Ok(t,r,i){const l=this;return o;function o(p){return t.enter("codeIndented"),Nt(t,d,"linePrefix",5)(p)}function d(p){const y=l.events[l.events.length-1];return y&&y[1].type==="linePrefix"&&y[2].sliceSerialize(y[1],!0).length>=4?c(p):i(p)}function c(p){return p===null?f(p):We(p)?t.attempt(Dk,c,f)(p):(t.enter("codeFlowValue"),h(p))}function h(p){return p===null||We(p)?(t.exit("codeFlowValue"),c(p)):(t.consume(p),h)}function f(p){return t.exit("codeIndented"),r(p)}}function Lk(t,r,i){const l=this;return o;function o(c){return l.parser.lazy[l.now().line]?i(c):We(c)?(t.enter("lineEnding"),t.consume(c),t.exit("lineEnding"),o):Nt(t,d,"linePrefix",5)(c)}function d(c){const h=l.events[l.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?r(c):We(c)?o(c):i(c)}}const Ik={name:"codeText",previous:qk,resolve:Bk,tokenize:Uk};function Bk(t){let r=t.length-4,i=3,l,o;if((t[i][1].type==="lineEnding"||t[i][1].type==="space")&&(t[r][1].type==="lineEnding"||t[r][1].type==="space")){for(l=i;++l<r;)if(t[l][1].type==="codeTextData"){t[i][1].type="codeTextPadding",t[r][1].type="codeTextPadding",i+=2,r-=2;break}}for(l=i-1,r++;++l<=r;)o===void 0?l!==r&&t[l][1].type!=="lineEnding"&&(o=l):(l===r||t[l][1].type==="lineEnding")&&(t[o][1].type="codeTextData",l!==o+2&&(t[o][1].end=t[l-1][1].end,t.splice(o+2,l-o-2),r-=l-o-2,l=o+2),o=void 0);return t}function qk(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Uk(t,r,i){let l=0,o,d;return c;function c(b){return t.enter("codeText"),t.enter("codeTextSequence"),h(b)}function h(b){return b===96?(t.consume(b),l++,h):(t.exit("codeTextSequence"),f(b))}function f(b){return b===null?i(b):b===32?(t.enter("space"),t.consume(b),t.exit("space"),f):b===96?(d=t.enter("codeTextSequence"),o=0,y(b)):We(b)?(t.enter("lineEnding"),t.consume(b),t.exit("lineEnding"),f):(t.enter("codeTextData"),p(b))}function p(b){return b===null||b===32||b===96||We(b)?(t.exit("codeTextData"),f(b)):(t.consume(b),p)}function y(b){return b===96?(t.consume(b),o++,y):o===l?(t.exit("codeTextSequence"),t.exit("codeText"),r(b)):(d.type="codeTextData",p(b))}}class Hk{constructor(r){this.left=r?[...r]:[],this.right=[]}get(r){if(r<0||r>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+r+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return r<this.left.length?this.left[r]:this.right[this.right.length-r+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(r,i){const l=i??Number.POSITIVE_INFINITY;return l<this.left.length?this.left.slice(r,l):r>this.left.length?this.right.slice(this.right.length-l+this.left.length,this.right.length-r+this.left.length).reverse():this.left.slice(r).concat(this.right.slice(this.right.length-l+this.left.length).reverse())}splice(r,i,l){const o=i||0;this.setCursor(Math.trunc(r));const d=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return l&&Tl(this.left,l),d.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(r){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(r)}pushMany(r){this.setCursor(Number.POSITIVE_INFINITY),Tl(this.left,r)}unshift(r){this.setCursor(0),this.right.push(r)}unshiftMany(r){this.setCursor(0),Tl(this.right,r.reverse())}setCursor(r){if(!(r===this.left.length||r>this.left.length&&this.right.length===0||r<0&&this.left.length===0))if(r<this.left.length){const i=this.left.splice(r,Number.POSITIVE_INFINITY);Tl(this.right,i.reverse())}else{const i=this.right.splice(this.left.length+this.right.length-r,Number.POSITIVE_INFINITY);Tl(this.left,i.reverse())}}}function Tl(t,r){let i=0;if(r.length<1e4)t.push(...r);else for(;i<r.length;)t.push(...r.slice(i,i+1e4)),i+=1e4}function Iv(t){const r={};let i=-1,l,o,d,c,h,f,p;const y=new Hk(t);for(;++i<y.length;){for(;i in r;)i=r[i];if(l=y.get(i),i&&l[1].type==="chunkFlow"&&y.get(i-1)[1].type==="listItemPrefix"&&(f=l[1]._tokenizer.events,d=0,d<f.length&&f[d][1].type==="lineEndingBlank"&&(d+=2),d<f.length&&f[d][1].type==="content"))for(;++d<f.length&&f[d][1].type!=="content";)f[d][1].type==="chunkText"&&(f[d][1]._isInFirstContentOfListItem=!0,d++);if(l[0]==="enter")l[1].contentType&&(Object.assign(r,Pk(y,i)),i=r[i],p=!0);else if(l[1]._container){for(d=i,o=void 0;d--;)if(c=y.get(d),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(o&&(y.get(o)[1].type="lineEndingBlank"),c[1].type="lineEnding",o=d);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;o&&(l[1].end={...y.get(o)[1].start},h=y.slice(o,i),h.unshift(l),y.splice(o,i-o+1,h))}}return On(t,0,Number.POSITIVE_INFINITY,y.slice(0)),!p}function Pk(t,r){const i=t.get(r)[1],l=t.get(r)[2];let o=r-1;const d=[];let c=i._tokenizer;c||(c=l.parser[i.contentType](i.start),i._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const h=c.events,f=[],p={};let y,b,v=-1,w=i,j=0,N=0;const C=[N];for(;w;){for(;t.get(++o)[1]!==w;);d.push(o),w._tokenizer||(y=l.sliceStream(w),w.next||y.push(null),b&&c.defineSkip(w.start),w._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(y),w._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),b=w,w=w.next}for(w=i;++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&&(N=v+1,C.push(N),w._tokenizer=void 0,w.previous=void 0,w=w.next);for(c.events=[],w?(w._tokenizer=void 0,w.previous=void 0):C.pop(),v=C.length;v--;){const E=h.slice(C[v],C[v+1]),A=d.pop();f.push([A,A+E.length-1]),t.splice(A,2,E)}for(f.reverse(),v=-1;++v<f.length;)p[j+f[v][0]]=j+f[v][1],j+=f[v][1]-f[v][0]-1;return p}const Fk={resolve:Gk,tokenize:Vk},$k={partial:!0,tokenize:Yk};function Gk(t){return Iv(t),t}function Vk(t,r){let i;return l;function l(h){return t.enter("content"),i=t.enter("chunkContent",{contentType:"content"}),o(h)}function o(h){return h===null?d(h):We(h)?t.check($k,c,d)(h):(t.consume(h),o)}function d(h){return t.exit("chunkContent"),t.exit("content"),r(h)}function c(h){return t.consume(h),t.exit("chunkContent"),i.next=t.enter("chunkContent",{contentType:"content",previous:i}),i=i.next,o}}function Yk(t,r,i){const l=this;return o;function o(c){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(c),t.exit("lineEnding"),Nt(t,d,"linePrefix")}function d(c){if(c===null||We(c))return i(c);const h=l.events[l.events.length-1];return!l.parser.constructs.disable.null.includes("codeIndented")&&h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?r(c):t.interrupt(l.parser.constructs.flow,i,r)(c)}}function Bv(t,r,i,l,o,d,c,h,f){const p=f||Number.POSITIVE_INFINITY;let y=0;return b;function b(E){return E===60?(t.enter(l),t.enter(o),t.enter(d),t.consume(E),t.exit(d),v):E===null||E===32||E===41||Co(E)?i(E):(t.enter(l),t.enter(c),t.enter(h),t.enter("chunkString",{contentType:"string"}),N(E))}function v(E){return E===62?(t.enter(d),t.consume(E),t.exit(d),t.exit(o),t.exit(l),r):(t.enter(h),t.enter("chunkString",{contentType:"string"}),w(E))}function w(E){return E===62?(t.exit("chunkString"),t.exit(h),v(E)):E===null||E===60||We(E)?i(E):(t.consume(E),E===92?j:w)}function j(E){return E===60||E===62||E===92?(t.consume(E),w):w(E)}function N(E){return!y&&(E===null||E===41||Pt(E))?(t.exit("chunkString"),t.exit(h),t.exit(c),t.exit(l),r(E)):y<p&&E===40?(t.consume(E),y++,N):E===41?(t.consume(E),y--,N):E===null||E===32||E===40||Co(E)?i(E):(t.consume(E),E===92?C:N)}function C(E){return E===40||E===41||E===92?(t.consume(E),N):N(E)}}function qv(t,r,i,l,o,d){const c=this;let h=0,f;return p;function p(w){return t.enter(l),t.enter(o),t.consume(w),t.exit(o),t.enter(d),y}function y(w){return h>999||w===null||w===91||w===93&&!f||w===94&&!h&&"_hiddenFootnoteSupport"in c.parser.constructs?i(w):w===93?(t.exit(d),t.enter(o),t.consume(w),t.exit(o),t.exit(l),r):We(w)?(t.enter("lineEnding"),t.consume(w),t.exit("lineEnding"),y):(t.enter("chunkString",{contentType:"string"}),b(w))}function b(w){return w===null||w===91||w===93||We(w)||h++>999?(t.exit("chunkString"),y(w)):(t.consume(w),f||(f=!jt(w)),w===92?v:b)}function v(w){return w===91||w===92||w===93?(t.consume(w),h++,b):b(w)}}function Uv(t,r,i,l,o,d){let c;return h;function h(v){return v===34||v===39||v===40?(t.enter(l),t.enter(o),t.consume(v),t.exit(o),c=v===40?41:v,f):i(v)}function f(v){return v===c?(t.enter(o),t.consume(v),t.exit(o),t.exit(l),r):(t.enter(d),p(v))}function p(v){return v===c?(t.exit(d),f(c)):v===null?i(v):We(v)?(t.enter("lineEnding"),t.consume(v),t.exit("lineEnding"),Nt(t,p,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),y(v))}function y(v){return v===c||v===null||We(v)?(t.exit("chunkString"),p(v)):(t.consume(v),v===92?b:y)}function b(v){return v===c||v===92?(t.consume(v),y):y(v)}}function _l(t,r){let i;return l;function l(o){return We(o)?(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),i=!0,l):jt(o)?Nt(t,l,i?"linePrefix":"lineSuffix")(o):r(o)}}const Qk={name:"definition",tokenize:Xk},Kk={partial:!0,tokenize:Zk};function Xk(t,r,i){const l=this;let o;return d;function d(w){return t.enter("definition"),c(w)}function c(w){return qv.call(l,t,h,i,"definitionLabel","definitionLabelMarker","definitionLabelString")(w)}function h(w){return o=Jn(l.sliceSerialize(l.events[l.events.length-1][1]).slice(1,-1)),w===58?(t.enter("definitionMarker"),t.consume(w),t.exit("definitionMarker"),f):i(w)}function f(w){return Pt(w)?_l(t,p)(w):p(w)}function p(w){return Bv(t,y,i,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(w)}function y(w){return t.attempt(Kk,b,b)(w)}function b(w){return jt(w)?Nt(t,v,"whitespace")(w):v(w)}function v(w){return w===null||We(w)?(t.exit("definition"),l.parser.defined.push(o),r(w)):i(w)}}function Zk(t,r,i){return l;function l(h){return Pt(h)?_l(t,o)(h):i(h)}function o(h){return Uv(t,d,i,"definitionTitle","definitionTitleMarker","definitionTitleString")(h)}function d(h){return jt(h)?Nt(t,c,"whitespace")(h):c(h)}function c(h){return h===null||We(h)?r(h):i(h)}}const Jk={name:"hardBreakEscape",tokenize:Wk};function Wk(t,r,i){return l;function l(d){return t.enter("hardBreakEscape"),t.consume(d),o}function o(d){return We(d)?(t.exit("hardBreakEscape"),r(d)):i(d)}}const eE={name:"headingAtx",resolve:tE,tokenize:nE};function tE(t,r){let i=t.length-2,l=3,o,d;return t[l][1].type==="whitespace"&&(l+=2),i-2>l&&t[i][1].type==="whitespace"&&(i-=2),t[i][1].type==="atxHeadingSequence"&&(l===i-1||i-4>l&&t[i-2][1].type==="whitespace")&&(i-=l+1===i?2:4),i>l&&(o={type:"atxHeadingText",start:t[l][1].start,end:t[i][1].end},d={type:"chunkText",start:t[l][1].start,end:t[i][1].end,contentType:"text"},On(t,l,i-l+1,[["enter",o,r],["enter",d,r],["exit",d,r],["exit",o,r]])),t}function nE(t,r,i){let l=0;return o;function o(y){return t.enter("atxHeading"),d(y)}function d(y){return t.enter("atxHeadingSequence"),c(y)}function c(y){return y===35&&l++<6?(t.consume(y),c):y===null||Pt(y)?(t.exit("atxHeadingSequence"),h(y)):i(y)}function h(y){return y===35?(t.enter("atxHeadingSequence"),f(y)):y===null||We(y)?(t.exit("atxHeading"),r(y)):jt(y)?Nt(t,h,"whitespace")(y):(t.enter("atxHeadingText"),p(y))}function f(y){return y===35?(t.consume(y),f):(t.exit("atxHeadingSequence"),h(y))}function p(y){return y===null||y===35||Pt(y)?(t.exit("atxHeadingText"),h(y)):(t.consume(y),p)}}const rE=["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"],ub=["pre","script","style","textarea"],iE={concrete:!0,name:"htmlFlow",resolveTo:aE,tokenize:oE},sE={partial:!0,tokenize:cE},lE={partial:!0,tokenize:uE};function aE(t){let r=t.length;for(;r--&&!(t[r][0]==="enter"&&t[r][1].type==="htmlFlow"););return r>1&&t[r-2][1].type==="linePrefix"&&(t[r][1].start=t[r-2][1].start,t[r+1][1].start=t[r-2][1].start,t.splice(r-2,2)),t}function oE(t,r,i){const l=this;let o,d,c,h,f;return p;function p(k){return y(k)}function y(k){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(k),b}function b(k){return k===33?(t.consume(k),v):k===47?(t.consume(k),d=!0,N):k===63?(t.consume(k),o=3,l.interrupt?r:R):bn(k)?(t.consume(k),c=String.fromCharCode(k),C):i(k)}function v(k){return k===45?(t.consume(k),o=2,w):k===91?(t.consume(k),o=5,h=0,j):bn(k)?(t.consume(k),o=4,l.interrupt?r:R):i(k)}function w(k){return k===45?(t.consume(k),l.interrupt?r:R):i(k)}function j(k){const W="CDATA[";return k===W.charCodeAt(h++)?(t.consume(k),h===W.length?l.interrupt?r:H:j):i(k)}function N(k){return bn(k)?(t.consume(k),c=String.fromCharCode(k),C):i(k)}function C(k){if(k===null||k===47||k===62||Pt(k)){const W=k===47,ue=c.toLowerCase();return!W&&!d&&ub.includes(ue)?(o=1,l.interrupt?r(k):H(k)):rE.includes(c.toLowerCase())?(o=6,W?(t.consume(k),E):l.interrupt?r(k):H(k)):(o=7,l.interrupt&&!l.parser.lazy[l.now().line]?i(k):d?A(k):D(k))}return k===45||mn(k)?(t.consume(k),c+=String.fromCharCode(k),C):i(k)}function E(k){return k===62?(t.consume(k),l.interrupt?r:H):i(k)}function A(k){return jt(k)?(t.consume(k),A):_(k)}function D(k){return k===47?(t.consume(k),_):k===58||k===95||bn(k)?(t.consume(k),L):jt(k)?(t.consume(k),D):_(k)}function L(k){return k===45||k===46||k===58||k===95||mn(k)?(t.consume(k),L):J(k)}function J(k){return k===61?(t.consume(k),T):jt(k)?(t.consume(k),J):D(k)}function T(k){return k===null||k===60||k===61||k===62||k===96?i(k):k===34||k===39?(t.consume(k),f=k,B):jt(k)?(t.consume(k),T):U(k)}function B(k){return k===f?(t.consume(k),f=null,X):k===null||We(k)?i(k):(t.consume(k),B)}function U(k){return k===null||k===34||k===39||k===47||k===60||k===61||k===62||k===96||Pt(k)?J(k):(t.consume(k),U)}function X(k){return k===47||k===62||jt(k)?D(k):i(k)}function _(k){return k===62?(t.consume(k),I):i(k)}function I(k){return k===null||We(k)?H(k):jt(k)?(t.consume(k),I):i(k)}function H(k){return k===45&&o===2?(t.consume(k),P):k===60&&o===1?(t.consume(k),G):k===62&&o===4?(t.consume(k),M):k===63&&o===3?(t.consume(k),R):k===93&&o===5?(t.consume(k),be):We(k)&&(o===6||o===7)?(t.exit("htmlFlowData"),t.check(sE,te,Y)(k)):k===null||We(k)?(t.exit("htmlFlowData"),Y(k)):(t.consume(k),H)}function Y(k){return t.check(lE,$,te)(k)}function $(k){return t.enter("lineEnding"),t.consume(k),t.exit("lineEnding"),F}function F(k){return k===null||We(k)?Y(k):(t.enter("htmlFlowData"),H(k))}function P(k){return k===45?(t.consume(k),R):H(k)}function G(k){return k===47?(t.consume(k),c="",re):H(k)}function re(k){if(k===62){const W=c.toLowerCase();return ub.includes(W)?(t.consume(k),M):H(k)}return bn(k)&&c.length<8?(t.consume(k),c+=String.fromCharCode(k),re):H(k)}function be(k){return k===93?(t.consume(k),R):H(k)}function R(k){return k===62?(t.consume(k),M):k===45&&o===2?(t.consume(k),R):H(k)}function M(k){return k===null||We(k)?(t.exit("htmlFlowData"),te(k)):(t.consume(k),M)}function te(k){return t.exit("htmlFlow"),r(k)}}function uE(t,r,i){const l=this;return o;function o(c){return We(c)?(t.enter("lineEnding"),t.consume(c),t.exit("lineEnding"),d):i(c)}function d(c){return l.parser.lazy[l.now().line]?i(c):r(c)}}function cE(t,r,i){return l;function l(o){return t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),t.attempt(Hl,r,i)}}const dE={name:"htmlText",tokenize:fE};function fE(t,r,i){const l=this;let o,d,c;return h;function h(R){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(R),f}function f(R){return R===33?(t.consume(R),p):R===47?(t.consume(R),J):R===63?(t.consume(R),D):bn(R)?(t.consume(R),U):i(R)}function p(R){return R===45?(t.consume(R),y):R===91?(t.consume(R),d=0,j):bn(R)?(t.consume(R),A):i(R)}function y(R){return R===45?(t.consume(R),w):i(R)}function b(R){return R===null?i(R):R===45?(t.consume(R),v):We(R)?(c=b,G(R)):(t.consume(R),b)}function v(R){return R===45?(t.consume(R),w):b(R)}function w(R){return R===62?P(R):R===45?v(R):b(R)}function j(R){const M="CDATA[";return R===M.charCodeAt(d++)?(t.consume(R),d===M.length?N:j):i(R)}function N(R){return R===null?i(R):R===93?(t.consume(R),C):We(R)?(c=N,G(R)):(t.consume(R),N)}function C(R){return R===93?(t.consume(R),E):N(R)}function E(R){return R===62?P(R):R===93?(t.consume(R),E):N(R)}function A(R){return R===null||R===62?P(R):We(R)?(c=A,G(R)):(t.consume(R),A)}function D(R){return R===null?i(R):R===63?(t.consume(R),L):We(R)?(c=D,G(R)):(t.consume(R),D)}function L(R){return R===62?P(R):D(R)}function J(R){return bn(R)?(t.consume(R),T):i(R)}function T(R){return R===45||mn(R)?(t.consume(R),T):B(R)}function B(R){return We(R)?(c=B,G(R)):jt(R)?(t.consume(R),B):P(R)}function U(R){return R===45||mn(R)?(t.consume(R),U):R===47||R===62||Pt(R)?X(R):i(R)}function X(R){return R===47?(t.consume(R),P):R===58||R===95||bn(R)?(t.consume(R),_):We(R)?(c=X,G(R)):jt(R)?(t.consume(R),X):P(R)}function _(R){return R===45||R===46||R===58||R===95||mn(R)?(t.consume(R),_):I(R)}function I(R){return R===61?(t.consume(R),H):We(R)?(c=I,G(R)):jt(R)?(t.consume(R),I):X(R)}function H(R){return R===null||R===60||R===61||R===62||R===96?i(R):R===34||R===39?(t.consume(R),o=R,Y):We(R)?(c=H,G(R)):jt(R)?(t.consume(R),H):(t.consume(R),$)}function Y(R){return R===o?(t.consume(R),o=void 0,F):R===null?i(R):We(R)?(c=Y,G(R)):(t.consume(R),Y)}function $(R){return R===null||R===34||R===39||R===60||R===61||R===96?i(R):R===47||R===62||Pt(R)?X(R):(t.consume(R),$)}function F(R){return R===47||R===62||Pt(R)?X(R):i(R)}function P(R){return R===62?(t.consume(R),t.exit("htmlTextData"),t.exit("htmlText"),r):i(R)}function G(R){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(R),t.exit("lineEnding"),re}function re(R){return jt(R)?Nt(t,be,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):be(R)}function be(R){return t.enter("htmlTextData"),c(R)}}const $f={name:"labelEnd",resolveAll:gE,resolveTo:yE,tokenize:bE},hE={tokenize:vE},pE={tokenize:xE},mE={tokenize:wE};function gE(t){let r=-1;const i=[];for(;++r<t.length;){const l=t[r][1];if(i.push(t[r]),l.type==="labelImage"||l.type==="labelLink"||l.type==="labelEnd"){const o=l.type==="labelImage"?4:2;l.type="data",r+=o}}return t.length!==i.length&&On(t,0,t.length,i),t}function yE(t,r){let i=t.length,l=0,o,d,c,h;for(;i--;)if(o=t[i][1],d){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;t[i][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(c){if(t[i][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(d=i,o.type!=="labelLink")){l=2;break}}else o.type==="labelEnd"&&(c=i);const f={type:t[d][1].type==="labelLink"?"link":"image",start:{...t[d][1].start},end:{...t[t.length-1][1].end}},p={type:"label",start:{...t[d][1].start},end:{...t[c][1].end}},y={type:"labelText",start:{...t[d+l+2][1].end},end:{...t[c-2][1].start}};return h=[["enter",f,r],["enter",p,r]],h=Vn(h,t.slice(d+1,d+l+3)),h=Vn(h,[["enter",y,r]]),h=Vn(h,Oo(r.parser.constructs.insideSpan.null,t.slice(d+l+4,c-3),r)),h=Vn(h,[["exit",y,r],t[c-2],t[c-1],["exit",p,r]]),h=Vn(h,t.slice(c+1)),h=Vn(h,[["exit",f,r]]),On(t,d,t.length,h),t}function bE(t,r,i){const l=this;let o=l.events.length,d,c;for(;o--;)if((l.events[o][1].type==="labelImage"||l.events[o][1].type==="labelLink")&&!l.events[o][1]._balanced){d=l.events[o][1];break}return h;function h(v){return d?d._inactive?b(v):(c=l.parser.defined.includes(Jn(l.sliceSerialize({start:d.end,end:l.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(v),t.exit("labelMarker"),t.exit("labelEnd"),f):i(v)}function f(v){return v===40?t.attempt(hE,y,c?y:b)(v):v===91?t.attempt(pE,y,c?p:b)(v):c?y(v):b(v)}function p(v){return t.attempt(mE,y,b)(v)}function y(v){return r(v)}function b(v){return d._balanced=!0,i(v)}}function vE(t,r,i){return l;function l(b){return t.enter("resource"),t.enter("resourceMarker"),t.consume(b),t.exit("resourceMarker"),o}function o(b){return Pt(b)?_l(t,d)(b):d(b)}function d(b){return b===41?y(b):Bv(t,c,h,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(b)}function c(b){return Pt(b)?_l(t,f)(b):y(b)}function h(b){return i(b)}function f(b){return b===34||b===39||b===40?Uv(t,p,i,"resourceTitle","resourceTitleMarker","resourceTitleString")(b):y(b)}function p(b){return Pt(b)?_l(t,y)(b):y(b)}function y(b){return b===41?(t.enter("resourceMarker"),t.consume(b),t.exit("resourceMarker"),t.exit("resource"),r):i(b)}}function xE(t,r,i){const l=this;return o;function o(h){return qv.call(l,t,d,c,"reference","referenceMarker","referenceString")(h)}function d(h){return l.parser.defined.includes(Jn(l.sliceSerialize(l.events[l.events.length-1][1]).slice(1,-1)))?r(h):i(h)}function c(h){return i(h)}}function wE(t,r,i){return l;function l(d){return t.enter("reference"),t.enter("referenceMarker"),t.consume(d),t.exit("referenceMarker"),o}function o(d){return d===93?(t.enter("referenceMarker"),t.consume(d),t.exit("referenceMarker"),t.exit("reference"),r):i(d)}}const SE={name:"labelStartImage",resolveAll:$f.resolveAll,tokenize:jE};function jE(t,r,i){const l=this;return o;function o(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):i(h)}function c(h){return h===94&&"_hiddenFootnoteSupport"in l.parser.constructs?i(h):r(h)}}const kE={name:"labelStartLink",resolveAll:$f.resolveAll,tokenize:EE};function EE(t,r,i){const l=this;return o;function o(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 l.parser.constructs?i(c):r(c)}}const qd={name:"lineEnding",tokenize:CE};function CE(t,r){return i;function i(l){return t.enter("lineEnding"),t.consume(l),t.exit("lineEnding"),Nt(t,r,"linePrefix")}}const xo={name:"thematicBreak",tokenize:TE};function TE(t,r,i){let l=0,o;return d;function d(p){return t.enter("thematicBreak"),c(p)}function c(p){return o=p,h(p)}function h(p){return p===o?(t.enter("thematicBreakSequence"),f(p)):l>=3&&(p===null||We(p))?(t.exit("thematicBreak"),r(p)):i(p)}function f(p){return p===o?(t.consume(p),l++,f):(t.exit("thematicBreakSequence"),jt(p)?Nt(t,h,"whitespace")(p):h(p))}}const En={continuation:{tokenize:zE},exit:ME,name:"list",tokenize:RE},NE={partial:!0,tokenize:DE},AE={partial:!0,tokenize:_E};function RE(t,r,i){const l=this,o=l.events[l.events.length-1];let d=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,c=0;return h;function h(w){const j=l.containerState.type||(w===42||w===43||w===45?"listUnordered":"listOrdered");if(j==="listUnordered"?!l.containerState.marker||w===l.containerState.marker:ff(w)){if(l.containerState.type||(l.containerState.type=j,t.enter(j,{_container:!0})),j==="listUnordered")return t.enter("listItemPrefix"),w===42||w===45?t.check(xo,i,p)(w):p(w);if(!l.interrupt||w===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),f(w)}return i(w)}function f(w){return ff(w)&&++c<10?(t.consume(w),f):(!l.interrupt||c<2)&&(l.containerState.marker?w===l.containerState.marker:w===41||w===46)?(t.exit("listItemValue"),p(w)):i(w)}function p(w){return t.enter("listItemMarker"),t.consume(w),t.exit("listItemMarker"),l.containerState.marker=l.containerState.marker||w,t.check(Hl,l.interrupt?i:y,t.attempt(NE,v,b))}function y(w){return l.containerState.initialBlankLine=!0,d++,v(w)}function b(w){return jt(w)?(t.enter("listItemPrefixWhitespace"),t.consume(w),t.exit("listItemPrefixWhitespace"),v):i(w)}function v(w){return l.containerState.size=d+l.sliceSerialize(t.exit("listItemPrefix"),!0).length,r(w)}}function zE(t,r,i){const l=this;return l.containerState._closeFlow=void 0,t.check(Hl,o,d);function o(h){return l.containerState.furtherBlankLines=l.containerState.furtherBlankLines||l.containerState.initialBlankLine,Nt(t,r,"listItemIndent",l.containerState.size+1)(h)}function d(h){return l.containerState.furtherBlankLines||!jt(h)?(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,c(h)):(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,t.attempt(AE,r,c)(h))}function c(h){return l.containerState._closeFlow=!0,l.interrupt=void 0,Nt(t,t.attempt(En,r,i),"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h)}}function _E(t,r,i){const l=this;return Nt(t,o,"listItemIndent",l.containerState.size+1);function o(d){const c=l.events[l.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===l.containerState.size?r(d):i(d)}}function ME(t){t.exit(this.containerState.type)}function DE(t,r,i){const l=this;return Nt(t,o,"listItemPrefixWhitespace",l.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(d){const c=l.events[l.events.length-1];return!jt(d)&&c&&c[1].type==="listItemPrefixWhitespace"?r(d):i(d)}}const cb={name:"setextUnderline",resolveTo:OE,tokenize:LE};function OE(t,r){let i=t.length,l,o,d;for(;i--;)if(t[i][0]==="enter"){if(t[i][1].type==="content"){l=i;break}t[i][1].type==="paragraph"&&(o=i)}else t[i][1].type==="content"&&t.splice(i,1),!d&&t[i][1].type==="definition"&&(d=i);const c={type:"setextHeading",start:{...t[l][1].start},end:{...t[t.length-1][1].end}};return t[o][1].type="setextHeadingText",d?(t.splice(o,0,["enter",c,r]),t.splice(d+1,0,["exit",t[l][1],r]),t[l][1].end={...t[d][1].end}):t[l][1]=c,t.push(["exit",c,r]),t}function LE(t,r,i){const l=this;let o;return d;function d(p){let y=l.events.length,b;for(;y--;)if(l.events[y][1].type!=="lineEnding"&&l.events[y][1].type!=="linePrefix"&&l.events[y][1].type!=="content"){b=l.events[y][1].type==="paragraph";break}return!l.parser.lazy[l.now().line]&&(l.interrupt||b)?(t.enter("setextHeadingLine"),o=p,c(p)):i(p)}function c(p){return t.enter("setextHeadingLineSequence"),h(p)}function h(p){return p===o?(t.consume(p),h):(t.exit("setextHeadingLineSequence"),jt(p)?Nt(t,f,"lineSuffix")(p):f(p))}function f(p){return p===null||We(p)?(t.exit("setextHeadingLine"),r(p)):i(p)}}const IE={tokenize:BE};function BE(t){const r=this,i=t.attempt(Hl,l,t.attempt(this.parser.constructs.flowInitial,o,Nt(t,t.attempt(this.parser.constructs.flow,o,t.attempt(Fk,o)),"linePrefix")));return i;function l(d){if(d===null){t.consume(d);return}return t.enter("lineEndingBlank"),t.consume(d),t.exit("lineEndingBlank"),r.currentConstruct=void 0,i}function o(d){if(d===null){t.consume(d);return}return t.enter("lineEnding"),t.consume(d),t.exit("lineEnding"),r.currentConstruct=void 0,i}}const qE={resolveAll:Pv()},UE=Hv("string"),HE=Hv("text");function Hv(t){return{resolveAll:Pv(t==="text"?PE:void 0),tokenize:r};function r(i){const l=this,o=this.parser.constructs[t],d=i.attempt(o,c,h);return c;function c(y){return p(y)?d(y):h(y)}function h(y){if(y===null){i.consume(y);return}return i.enter("data"),i.consume(y),f}function f(y){return p(y)?(i.exit("data"),d(y)):(i.consume(y),f)}function p(y){if(y===null)return!0;const b=o[y];let v=-1;if(b)for(;++v<b.length;){const w=b[v];if(!w.previous||w.previous.call(l,l.previous))return!0}return!1}}}function Pv(t){return r;function r(i,l){let o=-1,d;for(;++o<=i.length;)d===void 0?i[o]&&i[o][1].type==="data"&&(d=o,o++):(!i[o]||i[o][1].type!=="data")&&(o!==d+2&&(i[d][1].end=i[o-1][1].end,i.splice(d+2,o-d-2),o=d+2),d=void 0);return t?t(i,l):i}}function PE(t,r){let i=0;for(;++i<=t.length;)if((i===t.length||t[i][1].type==="lineEnding")&&t[i-1][1].type==="data"){const l=t[i-1][1],o=r.sliceStream(l);let d=o.length,c=-1,h=0,f;for(;d--;){const p=o[d];if(typeof p=="string"){for(c=p.length;p.charCodeAt(c-1)===32;)h++,c--;if(c)break;c=-1}else if(p===-2)f=!0,h++;else if(p!==-1){d++;break}}if(r._contentTypeTextTrailing&&i===t.length&&(h=0),h){const p={type:i===t.length||f||h<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:d?c:l.start._bufferIndex+c,_index:l.start._index+d,line:l.end.line,column:l.end.column-h,offset:l.end.offset-h},end:{...l.end}};l.end={...p.start},l.start.offset===l.end.offset?Object.assign(l,p):(t.splice(i,0,["enter",p,r],["exit",p,r]),i+=2)}i++}return t}const FE={42:En,43:En,45:En,48:En,49:En,50:En,51:En,52:En,53:En,54:En,55:En,56:En,57:En,62:Dv},$E={91:Qk},GE={[-2]:Bd,[-1]:Bd,32:Bd},VE={35:eE,42:xo,45:[cb,xo],60:iE,61:cb,95:xo,96:ob,126:ob},YE={38:Lv,92:Ov},QE={[-5]:qd,[-4]:qd,[-3]:qd,33:SE,38:Lv,42:hf,60:[kk,dE],91:kE,92:[Jk,Ov],93:$f,95:hf,96:Ik},KE={null:[hf,qE]},XE={null:[42,95]},ZE={null:[]},JE=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:XE,contentInitial:$E,disable:ZE,document:FE,flow:VE,flowInitial:GE,insideSpan:KE,string:YE,text:QE},Symbol.toStringTag,{value:"Module"}));function WE(t,r,i){let l={_bufferIndex:-1,_index:0,line:i&&i.line||1,column:i&&i.column||1,offset:i&&i.offset||0};const o={},d=[];let c=[],h=[];const f={attempt:B(J),check:B(T),consume:A,enter:D,exit:L,interrupt:B(T,{interrupt:!0})},p={code:null,containerState:{},defineSkip:N,events:[],now:j,parser:t,previous:null,sliceSerialize:v,sliceStream:w,write:b};let y=r.tokenize.call(p,f);return r.resolveAll&&d.push(r),p;function b(I){return c=Vn(c,I),C(),c[c.length-1]!==null?[]:(U(r,0),p.events=Oo(d,p.events,p),p.events)}function v(I,H){return tC(w(I),H)}function w(I){return eC(c,I)}function j(){const{_bufferIndex:I,_index:H,line:Y,column:$,offset:F}=l;return{_bufferIndex:I,_index:H,line:Y,column:$,offset:F}}function N(I){o[I.line]=I.column,_()}function C(){let I;for(;l._index<c.length;){const H=c[l._index];if(typeof H=="string")for(I=l._index,l._bufferIndex<0&&(l._bufferIndex=0);l._index===I&&l._bufferIndex<H.length;)E(H.charCodeAt(l._bufferIndex));else E(H)}}function E(I){y=y(I)}function A(I){We(I)?(l.line++,l.column=1,l.offset+=I===-3?2:1,_()):I!==-1&&(l.column++,l.offset++),l._bufferIndex<0?l._index++:(l._bufferIndex++,l._bufferIndex===c[l._index].length&&(l._bufferIndex=-1,l._index++)),p.previous=I}function D(I,H){const Y=H||{};return Y.type=I,Y.start=j(),p.events.push(["enter",Y,p]),h.push(Y),Y}function L(I){const H=h.pop();return H.end=j(),p.events.push(["exit",H,p]),H}function J(I,H){U(I,H.from)}function T(I,H){H.restore()}function B(I,H){return Y;function Y($,F,P){let G,re,be,R;return Array.isArray($)?te($):"tokenize"in $?te([$]):M($);function M(me){return Q;function Q(oe){const fe=oe!==null&&me[oe],ke=oe!==null&&me.null,_e=[...Array.isArray(fe)?fe:fe?[fe]:[],...Array.isArray(ke)?ke:ke?[ke]:[]];return te(_e)(oe)}}function te(me){return G=me,re=0,me.length===0?P:k(me[re])}function k(me){return Q;function Q(oe){return R=X(),be=me,me.partial||(p.currentConstruct=me),me.name&&p.parser.constructs.disable.null.includes(me.name)?ue():me.tokenize.call(H?Object.assign(Object.create(p),H):p,f,W,ue)(oe)}}function W(me){return I(be,R),F}function ue(me){return R.restore(),++re<G.length?k(G[re]):P}}}function U(I,H){I.resolveAll&&!d.includes(I)&&d.push(I),I.resolve&&On(p.events,H,p.events.length-H,I.resolve(p.events.slice(H),p)),I.resolveTo&&(p.events=I.resolveTo(p.events,p))}function X(){const I=j(),H=p.previous,Y=p.currentConstruct,$=p.events.length,F=Array.from(h);return{from:$,restore:P};function P(){l=I,p.previous=H,p.currentConstruct=Y,p.events.length=$,h=F,_()}}function _(){l.line in o&&l.column<2&&(l.column=o[l.line],l.offset+=o[l.line]-1)}}function eC(t,r){const i=r.start._index,l=r.start._bufferIndex,o=r.end._index,d=r.end._bufferIndex;let c;if(i===o)c=[t[i].slice(l,d)];else{if(c=t.slice(i,o),l>-1){const h=c[0];typeof h=="string"?c[0]=h.slice(l):c.shift()}d>0&&c.push(t[o].slice(0,d))}return c}function tC(t,r){let i=-1;const l=[];let o;for(;++i<t.length;){const d=t[i];let c;if(typeof d=="string")c=d;else switch(d){case-5:{c="\r";break}case-4:{c=`
|
|
46
|
+
`;break}case-3:{c=`\r
|
|
47
|
+
`;break}case-2:{c=r?" ":" ";break}case-1:{if(!r&&o)continue;c=" ";break}default:c=String.fromCharCode(d)}o=d===-2,l.push(c)}return l.join("")}function nC(t){const l={constructs:_v([JE,...(t||{}).extensions||[]]),content:o(yk),defined:[],document:o(vk),flow:o(IE),lazy:{},string:o(UE),text:o(HE)};return l;function o(d){return c;function c(h){return WE(l,d,h)}}}function rC(t){for(;!Iv(t););return t}const db=/[\0\t\n\r]/g;function iC(){let t=1,r="",i=!0,l;return o;function o(d,c,h){const f=[];let p,y,b,v,w;for(d=r+(typeof d=="string"?d.toString():new TextDecoder(c||void 0).decode(d)),b=0,r="",i&&(d.charCodeAt(0)===65279&&b++,i=void 0);b<d.length;){if(db.lastIndex=b,p=db.exec(d),v=p&&p.index!==void 0?p.index:d.length,w=d.charCodeAt(v),!p){r=d.slice(b);break}if(w===10&&b===v&&l)f.push(-3),l=void 0;else switch(l&&(f.push(-5),l=void 0),b<v&&(f.push(d.slice(b,v)),t+=v-b),w){case 0:{f.push(65533),t++;break}case 9:{for(y=Math.ceil(t/4)*4,f.push(-2);t++<y;)f.push(-1);break}case 10:{f.push(-4),t=1;break}default:l=!0,t=1}b=v+1}return h&&(l&&f.push(-5),r&&f.push(r),f.push(null)),f}}const sC=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function lC(t){return t.replace(sC,aC)}function aC(t,r,i){if(r)return r;if(i.charCodeAt(0)===35){const o=i.charCodeAt(1),d=o===120||o===88;return Mv(i.slice(d?2:1),d?16:10)}return Ff(i)||t}const Fv={}.hasOwnProperty;function oC(t,r,i){return r&&typeof r=="object"&&(i=r,r=void 0),uC(i)(rC(nC(i).document().write(iC()(t,r,!0))))}function uC(t){const r={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:d(ht),autolinkProtocol:X,autolinkEmail:X,atxHeading:d(Ge),blockQuote:d(ke),characterEscape:X,characterReference:X,codeFenced:d(_e),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:d(_e,c),codeText:d(Me,c),codeTextData:X,data:X,codeFlowValue:X,definition:d(Ce),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:d(qe),hardBreakEscape:d(lt),hardBreakTrailing:d(lt),htmlFlow:d(De,c),htmlFlowData:X,htmlText:d(De,c),htmlTextData:X,image:d(Oe),label:c,link:d(ht),listItem:d(dt),listItemValue:v,listOrdered:d(at,b),listUnordered:d(at),paragraph:d(Ke),reference:k,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:d(Ge),strong:d(rt),thematicBreak:d(nt)},exit:{atxHeading:f(),atxHeadingSequence:J,autolink:f(),autolinkEmail:fe,autolinkProtocol:oe,blockQuote:f(),characterEscapeValue:_,characterReferenceMarkerHexadecimal:ue,characterReferenceMarkerNumeric:ue,characterReferenceValue:me,characterReference:Q,codeFenced:f(C),codeFencedFence:N,codeFencedFenceInfo:w,codeFencedFenceMeta:j,codeFlowValue:_,codeIndented:f(E),codeText:f(F),codeTextData:_,data:_,definition:f(),definitionDestinationString:L,definitionLabelString:A,definitionTitleString:D,emphasis:f(),hardBreakEscape:f(H),hardBreakTrailing:f(H),htmlFlow:f(Y),htmlFlowData:_,htmlText:f($),htmlTextData:_,image:f(G),label:be,labelText:re,lineEnding:I,link:f(P),listItem:f(),listOrdered:f(),listUnordered:f(),paragraph:f(),referenceString:W,resourceDestinationString:R,resourceTitleString:M,resource:te,setextHeading:f(U),setextHeadingLineSequence:B,setextHeadingText:T,strong:f(),thematicBreak:f()}};$v(r,(t||{}).mdastExtensions||[]);const i={};return l;function l(q){let ne={type:"root",children:[]};const Ee={stack:[ne],tokenStack:[],config:r,enter:h,exit:p,buffer:c,resume:y,data:i},xe=[];let ze=-1;for(;++ze<q.length;)if(q[ze][1].type==="listOrdered"||q[ze][1].type==="listUnordered")if(q[ze][0]==="enter")xe.push(ze);else{const Le=xe.pop();ze=o(q,Le,ze)}for(ze=-1;++ze<q.length;){const Le=r[q[ze][0]];Fv.call(Le,q[ze][1].type)&&Le[q[ze][1].type].call(Object.assign({sliceSerialize:q[ze][2].sliceSerialize},Ee),q[ze][1])}if(Ee.tokenStack.length>0){const Le=Ee.tokenStack[Ee.tokenStack.length-1];(Le[1]||fb).call(Ee,void 0,Le[0])}for(ne.position={start:ni(q.length>0?q[0][1].start:{line:1,column:1,offset:0}),end:ni(q.length>0?q[q.length-2][1].end:{line:1,column:1,offset:0})},ze=-1;++ze<r.transforms.length;)ne=r.transforms[ze](ne)||ne;return ne}function o(q,ne,Ee){let xe=ne-1,ze=-1,Le=!1,se,Re,Ne,Qe;for(;++xe<=Ee;){const Ue=q[xe];switch(Ue[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ue[0]==="enter"?ze++:ze--,Qe=void 0;break}case"lineEndingBlank":{Ue[0]==="enter"&&(se&&!Qe&&!ze&&!Ne&&(Ne=xe),Qe=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Qe=void 0}if(!ze&&Ue[0]==="enter"&&Ue[1].type==="listItemPrefix"||ze===-1&&Ue[0]==="exit"&&(Ue[1].type==="listUnordered"||Ue[1].type==="listOrdered")){if(se){let bt=xe;for(Re=void 0;bt--;){const pt=q[bt];if(pt[1].type==="lineEnding"||pt[1].type==="lineEndingBlank"){if(pt[0]==="exit")continue;Re&&(q[Re][1].type="lineEndingBlank",Le=!0),pt[1].type="lineEnding",Re=bt}else if(!(pt[1].type==="linePrefix"||pt[1].type==="blockQuotePrefix"||pt[1].type==="blockQuotePrefixWhitespace"||pt[1].type==="blockQuoteMarker"||pt[1].type==="listItemIndent"))break}Ne&&(!Re||Ne<Re)&&(se._spread=!0),se.end=Object.assign({},Re?q[Re][1].start:Ue[1].end),q.splice(Re||xe,0,["exit",se,Ue[2]]),xe++,Ee++}if(Ue[1].type==="listItemPrefix"){const bt={type:"listItem",_spread:!1,start:Object.assign({},Ue[1].start),end:void 0};se=bt,q.splice(xe,0,["enter",bt,Ue[2]]),xe++,Ee++,Ne=void 0,Qe=!0}}}return q[ne][1]._spread=Le,Ee}function d(q,ne){return Ee;function Ee(xe){h.call(this,q(xe),xe),ne&&ne.call(this,xe)}}function c(){this.stack.push({type:"fragment",children:[]})}function h(q,ne,Ee){this.stack[this.stack.length-1].children.push(q),this.stack.push(q),this.tokenStack.push([ne,Ee||void 0]),q.position={start:ni(ne.start),end:void 0}}function f(q){return ne;function ne(Ee){q&&q.call(this,Ee),p.call(this,Ee)}}function p(q,ne){const Ee=this.stack.pop(),xe=this.tokenStack.pop();if(xe)xe[0].type!==q.type&&(ne?ne.call(this,q,xe[0]):(xe[1]||fb).call(this,q,xe[0]));else throw new Error("Cannot close `"+q.type+"` ("+zl({start:q.start,end:q.end})+"): it’s not open");Ee.position.end=ni(q.end)}function y(){return Pf(this.stack.pop())}function b(){this.data.expectingFirstListItemValue=!0}function v(q){if(this.data.expectingFirstListItemValue){const ne=this.stack[this.stack.length-2];ne.start=Number.parseInt(this.sliceSerialize(q),10),this.data.expectingFirstListItemValue=void 0}}function w(){const q=this.resume(),ne=this.stack[this.stack.length-1];ne.lang=q}function j(){const q=this.resume(),ne=this.stack[this.stack.length-1];ne.meta=q}function N(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function C(){const q=this.resume(),ne=this.stack[this.stack.length-1];ne.value=q.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function E(){const q=this.resume(),ne=this.stack[this.stack.length-1];ne.value=q.replace(/(\r?\n|\r)$/g,"")}function A(q){const ne=this.resume(),Ee=this.stack[this.stack.length-1];Ee.label=ne,Ee.identifier=Jn(this.sliceSerialize(q)).toLowerCase()}function D(){const q=this.resume(),ne=this.stack[this.stack.length-1];ne.title=q}function L(){const q=this.resume(),ne=this.stack[this.stack.length-1];ne.url=q}function J(q){const ne=this.stack[this.stack.length-1];if(!ne.depth){const Ee=this.sliceSerialize(q).length;ne.depth=Ee}}function T(){this.data.setextHeadingSlurpLineEnding=!0}function B(q){const ne=this.stack[this.stack.length-1];ne.depth=this.sliceSerialize(q).codePointAt(0)===61?1:2}function U(){this.data.setextHeadingSlurpLineEnding=void 0}function X(q){const Ee=this.stack[this.stack.length-1].children;let xe=Ee[Ee.length-1];(!xe||xe.type!=="text")&&(xe=Ve(),xe.position={start:ni(q.start),end:void 0},Ee.push(xe)),this.stack.push(xe)}function _(q){const ne=this.stack.pop();ne.value+=this.sliceSerialize(q),ne.position.end=ni(q.end)}function I(q){const ne=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Ee=ne.children[ne.children.length-1];Ee.position.end=ni(q.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&r.canContainEols.includes(ne.type)&&(X.call(this,q),_.call(this,q))}function H(){this.data.atHardBreak=!0}function Y(){const q=this.resume(),ne=this.stack[this.stack.length-1];ne.value=q}function $(){const q=this.resume(),ne=this.stack[this.stack.length-1];ne.value=q}function F(){const q=this.resume(),ne=this.stack[this.stack.length-1];ne.value=q}function P(){const q=this.stack[this.stack.length-1];if(this.data.inReference){const ne=this.data.referenceType||"shortcut";q.type+="Reference",q.referenceType=ne,delete q.url,delete q.title}else delete q.identifier,delete q.label;this.data.referenceType=void 0}function G(){const q=this.stack[this.stack.length-1];if(this.data.inReference){const ne=this.data.referenceType||"shortcut";q.type+="Reference",q.referenceType=ne,delete q.url,delete q.title}else delete q.identifier,delete q.label;this.data.referenceType=void 0}function re(q){const ne=this.sliceSerialize(q),Ee=this.stack[this.stack.length-2];Ee.label=lC(ne),Ee.identifier=Jn(ne).toLowerCase()}function be(){const q=this.stack[this.stack.length-1],ne=this.resume(),Ee=this.stack[this.stack.length-1];if(this.data.inReference=!0,Ee.type==="link"){const xe=q.children;Ee.children=xe}else Ee.alt=ne}function R(){const q=this.resume(),ne=this.stack[this.stack.length-1];ne.url=q}function M(){const q=this.resume(),ne=this.stack[this.stack.length-1];ne.title=q}function te(){this.data.inReference=void 0}function k(){this.data.referenceType="collapsed"}function W(q){const ne=this.resume(),Ee=this.stack[this.stack.length-1];Ee.label=ne,Ee.identifier=Jn(this.sliceSerialize(q)).toLowerCase(),this.data.referenceType="full"}function ue(q){this.data.characterReferenceType=q.type}function me(q){const ne=this.sliceSerialize(q),Ee=this.data.characterReferenceType;let xe;Ee?(xe=Mv(ne,Ee==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):xe=Ff(ne);const ze=this.stack[this.stack.length-1];ze.value+=xe}function Q(q){const ne=this.stack.pop();ne.position.end=ni(q.end)}function oe(q){_.call(this,q);const ne=this.stack[this.stack.length-1];ne.url=this.sliceSerialize(q)}function fe(q){_.call(this,q);const ne=this.stack[this.stack.length-1];ne.url="mailto:"+this.sliceSerialize(q)}function ke(){return{type:"blockquote",children:[]}}function _e(){return{type:"code",lang:null,meta:null,value:""}}function Me(){return{type:"inlineCode",value:""}}function Ce(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function qe(){return{type:"emphasis",children:[]}}function Ge(){return{type:"heading",depth:0,children:[]}}function lt(){return{type:"break"}}function De(){return{type:"html",value:""}}function Oe(){return{type:"image",title:null,url:"",alt:null}}function ht(){return{type:"link",title:null,url:"",children:[]}}function at(q){return{type:"list",ordered:q.type==="listOrdered",start:null,spread:q._spread,children:[]}}function dt(q){return{type:"listItem",spread:q._spread,checked:null,children:[]}}function Ke(){return{type:"paragraph",children:[]}}function rt(){return{type:"strong",children:[]}}function Ve(){return{type:"text",value:""}}function nt(){return{type:"thematicBreak"}}}function ni(t){return{line:t.line,column:t.column,offset:t.offset}}function $v(t,r){let i=-1;for(;++i<r.length;){const l=r[i];Array.isArray(l)?$v(t,l):cC(t,l)}}function cC(t,r){let i;for(i in r)if(Fv.call(r,i))switch(i){case"canContainEols":{const l=r[i];l&&t[i].push(...l);break}case"transforms":{const l=r[i];l&&t[i].push(...l);break}case"enter":case"exit":{const l=r[i];l&&Object.assign(t[i],l);break}}}function fb(t,r){throw t?new Error("Cannot close `"+t.type+"` ("+zl({start:t.start,end:t.end})+"): a different token (`"+r.type+"`, "+zl({start:r.start,end:r.end})+") is open"):new Error("Cannot close document, a token (`"+r.type+"`, "+zl({start:r.start,end:r.end})+") is still open")}function dC(t){const r=this;r.parser=i;function i(l){return oC(l,{...r.data("settings"),...t,extensions:r.data("micromarkExtensions")||[],mdastExtensions:r.data("fromMarkdownExtensions")||[]})}}function fC(t,r){const i={type:"element",tagName:"blockquote",properties:{},children:t.wrap(t.all(r),!0)};return t.patch(r,i),t.applyData(r,i)}function hC(t,r){const i={type:"element",tagName:"br",properties:{},children:[]};return t.patch(r,i),[t.applyData(r,i),{type:"text",value:`
|
|
48
|
+
`}]}function pC(t,r){const i=r.value?r.value+`
|
|
49
|
+
`:"",l={},o=r.lang?r.lang.split(/\s+/):[];o.length>0&&(l.className=["language-"+o[0]]);let d={type:"element",tagName:"code",properties:l,children:[{type:"text",value:i}]};return r.meta&&(d.data={meta:r.meta}),t.patch(r,d),d=t.applyData(r,d),d={type:"element",tagName:"pre",properties:{},children:[d]},t.patch(r,d),d}function mC(t,r){const i={type:"element",tagName:"del",properties:{},children:t.all(r)};return t.patch(r,i),t.applyData(r,i)}function gC(t,r){const i={type:"element",tagName:"em",properties:{},children:t.all(r)};return t.patch(r,i),t.applyData(r,i)}function yC(t,r){const i=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",l=String(r.identifier).toUpperCase(),o=Rs(l.toLowerCase()),d=t.footnoteOrder.indexOf(l);let c,h=t.footnoteCounts.get(l);h===void 0?(h=0,t.footnoteOrder.push(l),c=t.footnoteOrder.length):c=d+1,h+=1,t.footnoteCounts.set(l,h);const f={type:"element",tagName:"a",properties:{href:"#"+i+"fn-"+o,id:i+"fnref-"+o+(h>1?"-"+h:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};t.patch(r,f);const p={type:"element",tagName:"sup",properties:{},children:[f]};return t.patch(r,p),t.applyData(r,p)}function bC(t,r){const i={type:"element",tagName:"h"+r.depth,properties:{},children:t.all(r)};return t.patch(r,i),t.applyData(r,i)}function vC(t,r){if(t.options.allowDangerousHtml){const i={type:"raw",value:r.value};return t.patch(r,i),t.applyData(r,i)}}function Gv(t,r){const i=r.referenceType;let l="]";if(i==="collapsed"?l+="[]":i==="full"&&(l+="["+(r.label||r.identifier)+"]"),r.type==="imageReference")return[{type:"text",value:"!["+r.alt+l}];const o=t.all(r),d=o[0];d&&d.type==="text"?d.value="["+d.value:o.unshift({type:"text",value:"["});const c=o[o.length-1];return c&&c.type==="text"?c.value+=l:o.push({type:"text",value:l}),o}function xC(t,r){const i=String(r.identifier).toUpperCase(),l=t.definitionById.get(i);if(!l)return Gv(t,r);const o={src:Rs(l.url||""),alt:r.alt};l.title!==null&&l.title!==void 0&&(o.title=l.title);const d={type:"element",tagName:"img",properties:o,children:[]};return t.patch(r,d),t.applyData(r,d)}function wC(t,r){const i={src:Rs(r.url)};r.alt!==null&&r.alt!==void 0&&(i.alt=r.alt),r.title!==null&&r.title!==void 0&&(i.title=r.title);const l={type:"element",tagName:"img",properties:i,children:[]};return t.patch(r,l),t.applyData(r,l)}function SC(t,r){const i={type:"text",value:r.value.replace(/\r?\n|\r/g," ")};t.patch(r,i);const l={type:"element",tagName:"code",properties:{},children:[i]};return t.patch(r,l),t.applyData(r,l)}function jC(t,r){const i=String(r.identifier).toUpperCase(),l=t.definitionById.get(i);if(!l)return Gv(t,r);const o={href:Rs(l.url||"")};l.title!==null&&l.title!==void 0&&(o.title=l.title);const d={type:"element",tagName:"a",properties:o,children:t.all(r)};return t.patch(r,d),t.applyData(r,d)}function kC(t,r){const i={href:Rs(r.url)};r.title!==null&&r.title!==void 0&&(i.title=r.title);const l={type:"element",tagName:"a",properties:i,children:t.all(r)};return t.patch(r,l),t.applyData(r,l)}function EC(t,r,i){const l=t.all(r),o=i?CC(i):Vv(r),d={},c=[];if(typeof r.checked=="boolean"){const y=l[0];let b;y&&y.type==="element"&&y.tagName==="p"?b=y:(b={type:"element",tagName:"p",properties:{},children:[]},l.unshift(b)),b.children.length>0&&b.children.unshift({type:"text",value:" "}),b.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:r.checked,disabled:!0},children:[]}),d.className=["task-list-item"]}let h=-1;for(;++h<l.length;){const y=l[h];(o||h!==0||y.type!=="element"||y.tagName!=="p")&&c.push({type:"text",value:`
|
|
50
|
+
`}),y.type==="element"&&y.tagName==="p"&&!o?c.push(...y.children):c.push(y)}const f=l[l.length-1];f&&(o||f.type!=="element"||f.tagName!=="p")&&c.push({type:"text",value:`
|
|
51
|
+
`});const p={type:"element",tagName:"li",properties:d,children:c};return t.patch(r,p),t.applyData(r,p)}function CC(t){let r=!1;if(t.type==="list"){r=t.spread||!1;const i=t.children;let l=-1;for(;!r&&++l<i.length;)r=Vv(i[l])}return r}function Vv(t){const r=t.spread;return r??t.children.length>1}function TC(t,r){const i={},l=t.all(r);let o=-1;for(typeof r.start=="number"&&r.start!==1&&(i.start=r.start);++o<l.length;){const c=l[o];if(c.type==="element"&&c.tagName==="li"&&c.properties&&Array.isArray(c.properties.className)&&c.properties.className.includes("task-list-item")){i.className=["contains-task-list"];break}}const d={type:"element",tagName:r.ordered?"ol":"ul",properties:i,children:t.wrap(l,!0)};return t.patch(r,d),t.applyData(r,d)}function NC(t,r){const i={type:"element",tagName:"p",properties:{},children:t.all(r)};return t.patch(r,i),t.applyData(r,i)}function AC(t,r){const i={type:"root",children:t.wrap(t.all(r))};return t.patch(r,i),t.applyData(r,i)}function RC(t,r){const i={type:"element",tagName:"strong",properties:{},children:t.all(r)};return t.patch(r,i),t.applyData(r,i)}function zC(t,r){const i=t.all(r),l=i.shift(),o=[];if(l){const c={type:"element",tagName:"thead",properties:{},children:t.wrap([l],!0)};t.patch(r.children[0],c),o.push(c)}if(i.length>0){const c={type:"element",tagName:"tbody",properties:{},children:t.wrap(i,!0)},h=Bf(r.children[1]),f=Ev(r.children[r.children.length-1]);h&&f&&(c.position={start:h,end:f}),o.push(c)}const d={type:"element",tagName:"table",properties:{},children:t.wrap(o,!0)};return t.patch(r,d),t.applyData(r,d)}function _C(t,r,i){const l=i?i.children:void 0,d=(l?l.indexOf(r):1)===0?"th":"td",c=i&&i.type==="table"?i.align:void 0,h=c?c.length:r.children.length;let f=-1;const p=[];for(;++f<h;){const b=r.children[f],v={},w=c?c[f]:void 0;w&&(v.align=w);let j={type:"element",tagName:d,properties:v,children:[]};b&&(j.children=t.all(b),t.patch(b,j),j=t.applyData(b,j)),p.push(j)}const y={type:"element",tagName:"tr",properties:{},children:t.wrap(p,!0)};return t.patch(r,y),t.applyData(r,y)}function MC(t,r){const i={type:"element",tagName:"td",properties:{},children:t.all(r)};return t.patch(r,i),t.applyData(r,i)}const hb=9,pb=32;function DC(t){const r=String(t),i=/\r?\n|\r/g;let l=i.exec(r),o=0;const d=[];for(;l;)d.push(mb(r.slice(o,l.index),o>0,!0),l[0]),o=l.index+l[0].length,l=i.exec(r);return d.push(mb(r.slice(o),o>0,!1)),d.join("")}function mb(t,r,i){let l=0,o=t.length;if(r){let d=t.codePointAt(l);for(;d===hb||d===pb;)l++,d=t.codePointAt(l)}if(i){let d=t.codePointAt(o-1);for(;d===hb||d===pb;)o--,d=t.codePointAt(o-1)}return o>l?t.slice(l,o):""}function OC(t,r){const i={type:"text",value:DC(String(r.value))};return t.patch(r,i),t.applyData(r,i)}function LC(t,r){const i={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(r,i),t.applyData(r,i)}const IC={blockquote:fC,break:hC,code:pC,delete:mC,emphasis:gC,footnoteReference:yC,heading:bC,html:vC,imageReference:xC,image:wC,inlineCode:SC,linkReference:jC,link:kC,listItem:EC,list:TC,paragraph:NC,root:AC,strong:RC,table:zC,tableCell:MC,tableRow:_C,text:OC,thematicBreak:LC,toml:ho,yaml:ho,definition:ho,footnoteDefinition:ho};function ho(){}const Yv=-1,Lo=0,Ml=1,To=2,Gf=3,Vf=4,Yf=5,Qf=6,Qv=7,Kv=8,BC=typeof self=="object"?self:globalThis,gb=(t,r)=>{switch(t){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+t)}return new BC[t](r)},qC=(t,r)=>{const i=(o,d)=>(t.set(d,o),o),l=o=>{if(t.has(o))return t.get(o);const[d,c]=r[o];switch(d){case Lo:case Yv:return i(c,o);case Ml:{const h=i([],o);for(const f of c)h.push(l(f));return h}case To:{const h=i({},o);for(const[f,p]of c)h[l(f)]=l(p);return h}case Gf:return i(new Date(c),o);case Vf:{const{source:h,flags:f}=c;return i(new RegExp(h,f),o)}case Yf:{const h=i(new Map,o);for(const[f,p]of c)h.set(l(f),l(p));return h}case Qf:{const h=i(new Set,o);for(const f of c)h.add(l(f));return h}case Qv:{const{name:h,message:f}=c;return i(gb(h,f),o)}case Kv:return i(BigInt(c),o);case"BigInt":return i(Object(BigInt(c)),o);case"ArrayBuffer":return i(new Uint8Array(c).buffer,c);case"DataView":{const{buffer:h}=new Uint8Array(c);return i(new DataView(h),c)}}return i(gb(d,c),o)};return l},yb=t=>qC(new Map,t)(0),xs="",{toString:UC}={},{keys:HC}=Object,Nl=t=>{const r=typeof t;if(r!=="object"||!t)return[Lo,r];const i=UC.call(t).slice(8,-1);switch(i){case"Array":return[Ml,xs];case"Object":return[To,xs];case"Date":return[Gf,xs];case"RegExp":return[Vf,xs];case"Map":return[Yf,xs];case"Set":return[Qf,xs];case"DataView":return[Ml,i]}return i.includes("Array")?[Ml,i]:i.includes("Error")?[Qv,i]:[To,i]},po=([t,r])=>t===Lo&&(r==="function"||r==="symbol"),PC=(t,r,i,l)=>{const o=(c,h)=>{const f=l.push(c)-1;return i.set(h,f),f},d=c=>{if(i.has(c))return i.get(c);let[h,f]=Nl(c);switch(h){case Lo:{let y=c;switch(f){case"bigint":h=Kv,y=c.toString();break;case"function":case"symbol":if(t)throw new TypeError("unable to serialize "+f);y=null;break;case"undefined":return o([Yv],c)}return o([h,y],c)}case Ml:{if(f){let v=c;return f==="DataView"?v=new Uint8Array(c.buffer):f==="ArrayBuffer"&&(v=new Uint8Array(c)),o([f,[...v]],c)}const y=[],b=o([h,y],c);for(const v of c)y.push(d(v));return b}case To:{if(f)switch(f){case"BigInt":return o([f,c.toString()],c);case"Boolean":case"Number":case"String":return o([f,c.valueOf()],c)}if(r&&"toJSON"in c)return d(c.toJSON());const y=[],b=o([h,y],c);for(const v of HC(c))(t||!po(Nl(c[v])))&&y.push([d(v),d(c[v])]);return b}case Gf:return o([h,c.toISOString()],c);case Vf:{const{source:y,flags:b}=c;return o([h,{source:y,flags:b}],c)}case Yf:{const y=[],b=o([h,y],c);for(const[v,w]of c)(t||!(po(Nl(v))||po(Nl(w))))&&y.push([d(v),d(w)]);return b}case Qf:{const y=[],b=o([h,y],c);for(const v of c)(t||!po(Nl(v)))&&y.push(d(v));return b}}const{message:p}=c;return o([h,{name:f,message:p}],c)};return d},bb=(t,{json:r,lossy:i}={})=>{const l=[];return PC(!(r||i),!!r,new Map,l)(t),l},No=typeof structuredClone=="function"?(t,r)=>r&&("json"in r||"lossy"in r)?yb(bb(t,r)):structuredClone(t):(t,r)=>yb(bb(t,r));function FC(t,r){const i=[{type:"text",value:"↩"}];return r>1&&i.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(r)}]}),i}function $C(t,r){return"Back to reference "+(t+1)+(r>1?"-"+r:"")}function GC(t){const r=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",i=t.options.footnoteBackContent||FC,l=t.options.footnoteBackLabel||$C,o=t.options.footnoteLabel||"Footnotes",d=t.options.footnoteLabelTagName||"h2",c=t.options.footnoteLabelProperties||{className:["sr-only"]},h=[];let f=-1;for(;++f<t.footnoteOrder.length;){const p=t.footnoteById.get(t.footnoteOrder[f]);if(!p)continue;const y=t.all(p),b=String(p.identifier).toUpperCase(),v=Rs(b.toLowerCase());let w=0;const j=[],N=t.footnoteCounts.get(b);for(;N!==void 0&&++w<=N;){j.length>0&&j.push({type:"text",value:" "});let A=typeof i=="string"?i:i(f,w);typeof A=="string"&&(A={type:"text",value:A}),j.push({type:"element",tagName:"a",properties:{href:"#"+r+"fnref-"+v+(w>1?"-"+w:""),dataFootnoteBackref:"",ariaLabel:typeof l=="string"?l:l(f,w),className:["data-footnote-backref"]},children:Array.isArray(A)?A:[A]})}const C=y[y.length-1];if(C&&C.type==="element"&&C.tagName==="p"){const A=C.children[C.children.length-1];A&&A.type==="text"?A.value+=" ":C.children.push({type:"text",value:" "}),C.children.push(...j)}else y.push(...j);const E={type:"element",tagName:"li",properties:{id:r+"fn-"+v},children:t.wrap(y,!0)};t.patch(p,E),h.push(E)}if(h.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:d,properties:{...No(c),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
|
|
52
|
+
`},{type:"element",tagName:"ol",properties:{},children:t.wrap(h,!0)},{type:"text",value:`
|
|
53
|
+
`}]}}const Io=(function(t){if(t==null)return KC;if(typeof t=="function")return Bo(t);if(typeof t=="object")return Array.isArray(t)?VC(t):YC(t);if(typeof t=="string")return QC(t);throw new Error("Expected function, string, or object as test")});function VC(t){const r=[];let i=-1;for(;++i<t.length;)r[i]=Io(t[i]);return Bo(l);function l(...o){let d=-1;for(;++d<r.length;)if(r[d].apply(this,o))return!0;return!1}}function YC(t){const r=t;return Bo(i);function i(l){const o=l;let d;for(d in t)if(o[d]!==r[d])return!1;return!0}}function QC(t){return Bo(r);function r(i){return i&&i.type===t}}function Bo(t){return r;function r(i,l,o){return!!(XC(i)&&t.call(this,i,typeof l=="number"?l:void 0,o||void 0))}}function KC(){return!0}function XC(t){return t!==null&&typeof t=="object"&&"type"in t}const Xv=[],ZC=!0,pf=!1,JC="skip";function Zv(t,r,i,l){let o;typeof r=="function"&&typeof i!="function"?(l=i,i=r):o=r;const d=Io(o),c=l?-1:1;h(t,void 0,[])();function h(f,p,y){const b=f&&typeof f=="object"?f:{};if(typeof b.type=="string"){const w=typeof b.tagName=="string"?b.tagName:typeof b.name=="string"?b.name:void 0;Object.defineProperty(v,"name",{value:"node ("+(f.type+(w?"<"+w+">":""))+")"})}return v;function v(){let w=Xv,j,N,C;if((!r||d(f,p,y[y.length-1]||void 0))&&(w=WC(i(f,y)),w[0]===pf))return w;if("children"in f&&f.children){const E=f;if(E.children&&w[0]!==JC)for(N=(l?E.children.length:-1)+c,C=y.concat(E);N>-1&&N<E.children.length;){const A=E.children[N];if(j=h(A,N,C)(),j[0]===pf)return j;N=typeof j[1]=="number"?j[1]:N+c}}return w}}}function WC(t){return Array.isArray(t)?t:typeof t=="number"?[ZC,t]:t==null?Xv:[t]}function Kf(t,r,i,l){let o,d,c;typeof r=="function"&&typeof i!="function"?(d=void 0,c=r,o=i):(d=r,c=i,o=l),Zv(t,d,h,o);function h(f,p){const y=p[p.length-1],b=y?y.children.indexOf(f):void 0;return c(f,b,y)}}const mf={}.hasOwnProperty,eT={};function tT(t,r){const i=r||eT,l=new Map,o=new Map,d=new Map,c={...IC,...i.handlers},h={all:p,applyData:rT,definitionById:l,footnoteById:o,footnoteCounts:d,footnoteOrder:[],handlers:c,one:f,options:i,patch:nT,wrap:sT};return Kf(t,function(y){if(y.type==="definition"||y.type==="footnoteDefinition"){const b=y.type==="definition"?l:o,v=String(y.identifier).toUpperCase();b.has(v)||b.set(v,y)}}),h;function f(y,b){const v=y.type,w=h.handlers[v];if(mf.call(h.handlers,v)&&w)return w(h,y,b);if(h.options.passThrough&&h.options.passThrough.includes(v)){if("children"in y){const{children:N,...C}=y,E=No(C);return E.children=h.all(y),E}return No(y)}return(h.options.unknownHandler||iT)(h,y,b)}function p(y){const b=[];if("children"in y){const v=y.children;let w=-1;for(;++w<v.length;){const j=h.one(v[w],y);if(j){if(w&&v[w-1].type==="break"&&(!Array.isArray(j)&&j.type==="text"&&(j.value=vb(j.value)),!Array.isArray(j)&&j.type==="element")){const N=j.children[0];N&&N.type==="text"&&(N.value=vb(N.value))}Array.isArray(j)?b.push(...j):b.push(j)}}}return b}}function nT(t,r){t.position&&(r.position=Fj(t))}function rT(t,r){let i=r;if(t&&t.data){const l=t.data.hName,o=t.data.hChildren,d=t.data.hProperties;if(typeof l=="string")if(i.type==="element")i.tagName=l;else{const c="children"in i?i.children:[i];i={type:"element",tagName:l,properties:{},children:c}}i.type==="element"&&d&&Object.assign(i.properties,No(d)),"children"in i&&i.children&&o!==null&&o!==void 0&&(i.children=o)}return i}function iT(t,r){const i=r.data||{},l="value"in r&&!(mf.call(i,"hProperties")||mf.call(i,"hChildren"))?{type:"text",value:r.value}:{type:"element",tagName:"div",properties:{},children:t.all(r)};return t.patch(r,l),t.applyData(r,l)}function sT(t,r){const i=[];let l=-1;for(r&&i.push({type:"text",value:`
|
|
54
|
+
`});++l<t.length;)l&&i.push({type:"text",value:`
|
|
55
|
+
`}),i.push(t[l]);return r&&t.length>0&&i.push({type:"text",value:`
|
|
56
|
+
`}),i}function vb(t){let r=0,i=t.charCodeAt(r);for(;i===9||i===32;)r++,i=t.charCodeAt(r);return t.slice(r)}function xb(t,r){const i=tT(t,r),l=i.one(t,void 0),o=GC(i),d=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return o&&d.children.push({type:"text",value:`
|
|
57
|
+
`},o),d}function lT(t,r){return t&&"run"in t?async function(i,l){const o=xb(i,{file:l,...r});await t.run(o,l)}:function(i,l){return xb(i,{file:l,...t||r})}}function wb(t){if(t)throw t}var Ud,Sb;function aT(){if(Sb)return Ud;Sb=1;var t=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,l=Object.getOwnPropertyDescriptor,o=function(p){return typeof Array.isArray=="function"?Array.isArray(p):r.call(p)==="[object Array]"},d=function(p){if(!p||r.call(p)!=="[object Object]")return!1;var y=t.call(p,"constructor"),b=p.constructor&&p.constructor.prototype&&t.call(p.constructor.prototype,"isPrototypeOf");if(p.constructor&&!y&&!b)return!1;var v;for(v in p);return typeof v>"u"||t.call(p,v)},c=function(p,y){i&&y.name==="__proto__"?i(p,y.name,{enumerable:!0,configurable:!0,value:y.newValue,writable:!0}):p[y.name]=y.newValue},h=function(p,y){if(y==="__proto__")if(t.call(p,y)){if(l)return l(p,y).value}else return;return p[y]};return Ud=function f(){var p,y,b,v,w,j,N=arguments[0],C=1,E=arguments.length,A=!1;for(typeof N=="boolean"&&(A=N,N=arguments[1]||{},C=2),(N==null||typeof N!="object"&&typeof N!="function")&&(N={});C<E;++C)if(p=arguments[C],p!=null)for(y in p)b=h(N,y),v=h(p,y),N!==v&&(A&&v&&(d(v)||(w=o(v)))?(w?(w=!1,j=b&&o(b)?b:[]):j=b&&d(b)?b:{},c(N,{name:y,newValue:f(A,j,v)})):typeof v<"u"&&c(N,{name:y,newValue:v}));return N},Ud}var oT=aT();const Hd=zo(oT);function gf(t){if(typeof t!="object"||t===null)return!1;const r=Object.getPrototypeOf(t);return(r===null||r===Object.prototype||Object.getPrototypeOf(r)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function uT(){const t=[],r={run:i,use:l};return r;function i(...o){let d=-1;const c=o.pop();if(typeof c!="function")throw new TypeError("Expected function as last argument, not "+c);h(null,...o);function h(f,...p){const y=t[++d];let b=-1;if(f){c(f);return}for(;++b<o.length;)(p[b]===null||p[b]===void 0)&&(p[b]=o[b]);o=p,y?cT(y,h)(...p):c(null,...p)}}function l(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return t.push(o),r}}function cT(t,r){let i;return l;function l(...c){const h=t.length>c.length;let f;h&&c.push(o);try{f=t.apply(this,c)}catch(p){const y=p;if(h&&i)throw y;return o(y)}h||(f&&f.then&&typeof f.then=="function"?f.then(d,o):f instanceof Error?o(f):d(f))}function o(c,...h){i||(i=!0,r(c,...h))}function d(c){o(null,c)}}const ir={basename:dT,dirname:fT,extname:hT,join:pT,sep:"/"};function dT(t,r){if(r!==void 0&&typeof r!="string")throw new TypeError('"ext" argument must be a string');Pl(t);let i=0,l=-1,o=t.length,d;if(r===void 0||r.length===0||r.length>t.length){for(;o--;)if(t.codePointAt(o)===47){if(d){i=o+1;break}}else l<0&&(d=!0,l=o+1);return l<0?"":t.slice(i,l)}if(r===t)return"";let c=-1,h=r.length-1;for(;o--;)if(t.codePointAt(o)===47){if(d){i=o+1;break}}else c<0&&(d=!0,c=o+1),h>-1&&(t.codePointAt(o)===r.codePointAt(h--)?h<0&&(l=o):(h=-1,l=c));return i===l?l=c:l<0&&(l=t.length),t.slice(i,l)}function fT(t){if(Pl(t),t.length===0)return".";let r=-1,i=t.length,l;for(;--i;)if(t.codePointAt(i)===47){if(l){r=i;break}}else l||(l=!0);return r<0?t.codePointAt(0)===47?"/":".":r===1&&t.codePointAt(0)===47?"//":t.slice(0,r)}function hT(t){Pl(t);let r=t.length,i=-1,l=0,o=-1,d=0,c;for(;r--;){const h=t.codePointAt(r);if(h===47){if(c){l=r+1;break}continue}i<0&&(c=!0,i=r+1),h===46?o<0?o=r:d!==1&&(d=1):o>-1&&(d=-1)}return o<0||i<0||d===0||d===1&&o===i-1&&o===l+1?"":t.slice(o,i)}function pT(...t){let r=-1,i;for(;++r<t.length;)Pl(t[r]),t[r]&&(i=i===void 0?t[r]:i+"/"+t[r]);return i===void 0?".":mT(i)}function mT(t){Pl(t);const r=t.codePointAt(0)===47;let i=gT(t,!r);return i.length===0&&!r&&(i="."),i.length>0&&t.codePointAt(t.length-1)===47&&(i+="/"),r?"/"+i:i}function gT(t,r){let i="",l=0,o=-1,d=0,c=-1,h,f;for(;++c<=t.length;){if(c<t.length)h=t.codePointAt(c);else{if(h===47)break;h=47}if(h===47){if(!(o===c-1||d===1))if(o!==c-1&&d===2){if(i.length<2||l!==2||i.codePointAt(i.length-1)!==46||i.codePointAt(i.length-2)!==46){if(i.length>2){if(f=i.lastIndexOf("/"),f!==i.length-1){f<0?(i="",l=0):(i=i.slice(0,f),l=i.length-1-i.lastIndexOf("/")),o=c,d=0;continue}}else if(i.length>0){i="",l=0,o=c,d=0;continue}}r&&(i=i.length>0?i+"/..":"..",l=2)}else i.length>0?i+="/"+t.slice(o+1,c):i=t.slice(o+1,c),l=c-o-1;o=c,d=0}else h===46&&d>-1?d++:d=-1}return i}function Pl(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const yT={cwd:bT};function bT(){return"/"}function yf(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function vT(t){if(typeof t=="string")t=new URL(t);else if(!yf(t)){const r=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+t+"`");throw r.code="ERR_INVALID_ARG_TYPE",r}if(t.protocol!=="file:"){const r=new TypeError("The URL must be of scheme file");throw r.code="ERR_INVALID_URL_SCHEME",r}return xT(t)}function xT(t){if(t.hostname!==""){const l=new TypeError('File URL host must be "localhost" or empty on darwin');throw l.code="ERR_INVALID_FILE_URL_HOST",l}const r=t.pathname;let i=-1;for(;++i<r.length;)if(r.codePointAt(i)===37&&r.codePointAt(i+1)===50){const l=r.codePointAt(i+2);if(l===70||l===102){const o=new TypeError("File URL path must not include encoded / characters");throw o.code="ERR_INVALID_FILE_URL_PATH",o}}return decodeURIComponent(r)}const Pd=["history","path","basename","stem","extname","dirname"];class Jv{constructor(r){let i;r?yf(r)?i={path:r}:typeof r=="string"||wT(r)?i={value:r}:i=r:i={},this.cwd="cwd"in i?"":yT.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let l=-1;for(;++l<Pd.length;){const d=Pd[l];d in i&&i[d]!==void 0&&i[d]!==null&&(this[d]=d==="history"?[...i[d]]:i[d])}let o;for(o in i)Pd.includes(o)||(this[o]=i[o])}get basename(){return typeof this.path=="string"?ir.basename(this.path):void 0}set basename(r){$d(r,"basename"),Fd(r,"basename"),this.path=ir.join(this.dirname||"",r)}get dirname(){return typeof this.path=="string"?ir.dirname(this.path):void 0}set dirname(r){jb(this.basename,"dirname"),this.path=ir.join(r||"",this.basename)}get extname(){return typeof this.path=="string"?ir.extname(this.path):void 0}set extname(r){if(Fd(r,"extname"),jb(this.dirname,"extname"),r){if(r.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(r.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=ir.join(this.dirname,this.stem+(r||""))}get path(){return this.history[this.history.length-1]}set path(r){yf(r)&&(r=vT(r)),$d(r,"path"),this.path!==r&&this.history.push(r)}get stem(){return typeof this.path=="string"?ir.basename(this.path,this.extname):void 0}set stem(r){$d(r,"stem"),Fd(r,"stem"),this.path=ir.join(this.dirname||"",r+(this.extname||""))}fail(r,i,l){const o=this.message(r,i,l);throw o.fatal=!0,o}info(r,i,l){const o=this.message(r,i,l);return o.fatal=void 0,o}message(r,i,l){const o=new gn(r,i,l);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(r){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(r||void 0).decode(this.value)}}function Fd(t,r){if(t&&t.includes(ir.sep))throw new Error("`"+r+"` cannot be a path: did not expect `"+ir.sep+"`")}function $d(t,r){if(!t)throw new Error("`"+r+"` cannot be empty")}function jb(t,r){if(!t)throw new Error("Setting `"+r+"` requires `path` to be set too")}function wT(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const ST=(function(t){const l=this.constructor.prototype,o=l[t],d=function(){return o.apply(d,arguments)};return Object.setPrototypeOf(d,l),d}),jT={}.hasOwnProperty;class Xf extends ST{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=uT()}copy(){const r=new Xf;let i=-1;for(;++i<this.attachers.length;){const l=this.attachers[i];r.use(...l)}return r.data(Hd(!0,{},this.namespace)),r}data(r,i){return typeof r=="string"?arguments.length===2?(Yd("data",this.frozen),this.namespace[r]=i,this):jT.call(this.namespace,r)&&this.namespace[r]||void 0:r?(Yd("data",this.frozen),this.namespace=r,this):this.namespace}freeze(){if(this.frozen)return this;const r=this;for(;++this.freezeIndex<this.attachers.length;){const[i,...l]=this.attachers[this.freezeIndex];if(l[0]===!1)continue;l[0]===!0&&(l[0]=void 0);const o=i.call(r,...l);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(r){this.freeze();const i=mo(r),l=this.parser||this.Parser;return Gd("parse",l),l(String(i),i)}process(r,i){const l=this;return this.freeze(),Gd("process",this.parser||this.Parser),Vd("process",this.compiler||this.Compiler),i?o(void 0,i):new Promise(o);function o(d,c){const h=mo(r),f=l.parse(h);l.run(f,h,function(y,b,v){if(y||!b||!v)return p(y);const w=b,j=l.stringify(w,v);CT(j)?v.value=j:v.result=j,p(y,v)});function p(y,b){y||!b?c(y):d?d(b):i(void 0,b)}}}processSync(r){let i=!1,l;return this.freeze(),Gd("processSync",this.parser||this.Parser),Vd("processSync",this.compiler||this.Compiler),this.process(r,o),Eb("processSync","process",i),l;function o(d,c){i=!0,wb(d),l=c}}run(r,i,l){kb(r),this.freeze();const o=this.transformers;return!l&&typeof i=="function"&&(l=i,i=void 0),l?d(void 0,l):new Promise(d);function d(c,h){const f=mo(i);o.run(r,f,p);function p(y,b,v){const w=b||r;y?h(y):c?c(w):l(void 0,w,v)}}}runSync(r,i){let l=!1,o;return this.run(r,i,d),Eb("runSync","run",l),o;function d(c,h){wb(c),o=h,l=!0}}stringify(r,i){this.freeze();const l=mo(i),o=this.compiler||this.Compiler;return Vd("stringify",o),kb(r),o(r,l)}use(r,...i){const l=this.attachers,o=this.namespace;if(Yd("use",this.frozen),r!=null)if(typeof r=="function")f(r,i);else if(typeof r=="object")Array.isArray(r)?h(r):c(r);else throw new TypeError("Expected usable value, not `"+r+"`");return this;function d(p){if(typeof p=="function")f(p,[]);else if(typeof p=="object")if(Array.isArray(p)){const[y,...b]=p;f(y,b)}else c(p);else throw new TypeError("Expected usable value, not `"+p+"`")}function c(p){if(!("plugins"in p)&&!("settings"in p))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(p.plugins),p.settings&&(o.settings=Hd(!0,o.settings,p.settings))}function h(p){let y=-1;if(p!=null)if(Array.isArray(p))for(;++y<p.length;){const b=p[y];d(b)}else throw new TypeError("Expected a list of plugins, not `"+p+"`")}function f(p,y){let b=-1,v=-1;for(;++b<l.length;)if(l[b][0]===p){v=b;break}if(v===-1)l.push([p,...y]);else if(y.length>0){let[w,...j]=y;const N=l[v][1];gf(N)&&gf(w)&&(w=Hd(!0,N,w)),l[v]=[p,w,...j]}}}}const kT=new Xf().freeze();function Gd(t,r){if(typeof r!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function Vd(t,r){if(typeof r!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function Yd(t,r){if(r)throw new Error("Cannot call `"+t+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function kb(t){if(!gf(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function Eb(t,r,i){if(!i)throw new Error("`"+t+"` finished async. Use `"+r+"` instead")}function mo(t){return ET(t)?t:new Jv(t)}function ET(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function CT(t){return typeof t=="string"||TT(t)}function TT(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const NT="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Cb=[],Tb={allowDangerousHtml:!0},AT=/^(https?|ircs?|mailto|xmpp)$/i,RT=[{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 zT(t){const r=_T(t),i=MT(t);return DT(r.runSync(r.parse(i),i),t)}function _T(t){const r=t.rehypePlugins||Cb,i=t.remarkPlugins||Cb,l=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...Tb}:Tb;return kT().use(dC).use(i).use(lT,l).use(r)}function MT(t){const r=t.children||"",i=new Jv;return typeof r=="string"&&(i.value=r),i}function DT(t,r){const i=r.allowedElements,l=r.allowElement,o=r.components,d=r.disallowedElements,c=r.skipHtml,h=r.unwrapDisallowed,f=r.urlTransform||OT;for(const y of RT)Object.hasOwn(r,y.from)&&(""+y.from+(y.to?"use `"+y.to+"` instead":"remove it")+NT+y.id,void 0);return r.className&&(t={type:"element",tagName:"div",properties:{className:r.className},children:t.type==="root"?t.children:[t]}),Kf(t,p),Qj(t,{Fragment:a.Fragment,components:o,ignoreInvalidStyle:!0,jsx:a.jsx,jsxs:a.jsxs,passKeys:!0,passNode:!0});function p(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 w;for(w in Id)if(Object.hasOwn(Id,w)&&Object.hasOwn(y.properties,w)){const j=y.properties[w],N=Id[w];(N===null||N.includes(y.tagName))&&(y.properties[w]=f(String(j||""),w,y))}}if(y.type==="element"){let w=i?!i.includes(y.tagName):d?d.includes(y.tagName):!1;if(!w&&l&&typeof b=="number"&&(w=!l(y,b,v)),w&&v&&typeof b=="number")return h&&y.children?v.children.splice(b,1,...y.children):v.children.splice(b,1),b}}}function OT(t){const r=t.indexOf(":"),i=t.indexOf("?"),l=t.indexOf("#"),o=t.indexOf("/");return r===-1||o!==-1&&r>o||i!==-1&&r>i||l!==-1&&r>l||AT.test(t.slice(0,r))?t:""}function Nb(t,r){const i=String(t);if(typeof r!="string")throw new TypeError("Expected character");let l=0,o=i.indexOf(r);for(;o!==-1;)l++,o=i.indexOf(r,o+r.length);return l}function LT(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function IT(t,r,i){const o=Io((i||{}).ignore||[]),d=BT(r);let c=-1;for(;++c<d.length;)Zv(t,"text",h);function h(p,y){let b=-1,v;for(;++b<y.length;){const w=y[b],j=v?v.children:void 0;if(o(w,j?j.indexOf(w):void 0,v))return;v=w}if(v)return f(p,y)}function f(p,y){const b=y[y.length-1],v=d[c][0],w=d[c][1];let j=0;const C=b.children.indexOf(p);let E=!1,A=[];v.lastIndex=0;let D=v.exec(p.value);for(;D;){const L=D.index,J={index:D.index,input:D.input,stack:[...y,p]};let T=w(...D,J);if(typeof T=="string"&&(T=T.length>0?{type:"text",value:T}:void 0),T===!1?v.lastIndex=L+1:(j!==L&&A.push({type:"text",value:p.value.slice(j,L)}),Array.isArray(T)?A.push(...T):T&&A.push(T),j=L+D[0].length,E=!0),!v.global)break;D=v.exec(p.value)}return E?(j<p.value.length&&A.push({type:"text",value:p.value.slice(j)}),b.children.splice(C,1,...A)):A=[p],C+A.length}}function BT(t){const r=[];if(!Array.isArray(t))throw new TypeError("Expected find and replace tuple or list of tuples");const i=!t[0]||Array.isArray(t[0])?t:[t];let l=-1;for(;++l<i.length;){const o=i[l];r.push([qT(o[0]),UT(o[1])])}return r}function qT(t){return typeof t=="string"?new RegExp(LT(t),"g"):t}function UT(t){return typeof t=="function"?t:function(){return t}}const Qd="phrasing",Kd=["autolink","link","image","label"];function HT(){return{transforms:[QT],enter:{literalAutolink:FT,literalAutolinkEmail:Xd,literalAutolinkHttp:Xd,literalAutolinkWww:Xd},exit:{literalAutolink:YT,literalAutolinkEmail:VT,literalAutolinkHttp:$T,literalAutolinkWww:GT}}}function PT(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Qd,notInConstruct:Kd},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Qd,notInConstruct:Kd},{character:":",before:"[ps]",after:"\\/",inConstruct:Qd,notInConstruct:Kd}]}}function FT(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function Xd(t){this.config.enter.autolinkProtocol.call(this,t)}function $T(t){this.config.exit.autolinkProtocol.call(this,t)}function GT(t){this.config.exit.data.call(this,t);const r=this.stack[this.stack.length-1];r.type,r.url="http://"+this.sliceSerialize(t)}function VT(t){this.config.exit.autolinkEmail.call(this,t)}function YT(t){this.exit(t)}function QT(t){IT(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,KT],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),XT]],{ignore:["link","linkReference"]})}function KT(t,r,i,l,o){let d="";if(!Wv(o)||(/^w/i.test(r)&&(i=r+i,r="",d="http://"),!ZT(i)))return!1;const c=JT(i+l);if(!c[0])return!1;const h={type:"link",title:null,url:d+r+c[0],children:[{type:"text",value:r+c[0]}]};return c[1]?[h,{type:"text",value:c[1]}]:h}function XT(t,r,i,l){return!Wv(l,!0)||/[-\d_]$/.test(i)?!1:{type:"link",title:null,url:"mailto:"+r+"@"+i,children:[{type:"text",value:r+"@"+i}]}}function ZT(t){const r=t.split(".");return!(r.length<2||r[r.length-1]&&(/_/.test(r[r.length-1])||!/[a-zA-Z\d]/.test(r[r.length-1]))||r[r.length-2]&&(/_/.test(r[r.length-2])||!/[a-zA-Z\d]/.test(r[r.length-2])))}function JT(t){const r=/[!"&'),.:;<>?\]}]+$/.exec(t);if(!r)return[t,void 0];t=t.slice(0,r.index);let i=r[0],l=i.indexOf(")");const o=Nb(t,"(");let d=Nb(t,")");for(;l!==-1&&o>d;)t+=i.slice(0,l+1),i=i.slice(l+1),l=i.indexOf(")"),d++;return[t,i]}function Wv(t,r){const i=t.input.charCodeAt(t.index-1);return(t.index===0||Ci(i)||Do(i))&&(!r||i!==47)}ex.peek=aN;function WT(){this.buffer()}function eN(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function tN(){this.buffer()}function nN(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function rN(t){const r=this.resume(),i=this.stack[this.stack.length-1];i.type,i.identifier=Jn(this.sliceSerialize(t)).toLowerCase(),i.label=r}function iN(t){this.exit(t)}function sN(t){const r=this.resume(),i=this.stack[this.stack.length-1];i.type,i.identifier=Jn(this.sliceSerialize(t)).toLowerCase(),i.label=r}function lN(t){this.exit(t)}function aN(){return"["}function ex(t,r,i,l){const o=i.createTracker(l);let d=o.move("[^");const c=i.enter("footnoteReference"),h=i.enter("reference");return d+=o.move(i.safe(i.associationId(t),{after:"]",before:d})),h(),c(),d+=o.move("]"),d}function oN(){return{enter:{gfmFootnoteCallString:WT,gfmFootnoteCall:eN,gfmFootnoteDefinitionLabelString:tN,gfmFootnoteDefinition:nN},exit:{gfmFootnoteCallString:rN,gfmFootnoteCall:iN,gfmFootnoteDefinitionLabelString:sN,gfmFootnoteDefinition:lN}}}function uN(t){let r=!1;return t&&t.firstLineBlank&&(r=!0),{handlers:{footnoteDefinition:i,footnoteReference:ex},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function i(l,o,d,c){const h=d.createTracker(c);let f=h.move("[^");const p=d.enter("footnoteDefinition"),y=d.enter("label");return f+=h.move(d.safe(d.associationId(l),{before:f,after:"]"})),y(),f+=h.move("]:"),l.children&&l.children.length>0&&(h.shift(4),f+=h.move((r?`
|
|
58
|
+
`:" ")+d.indentLines(d.containerFlow(l,h.current()),r?tx:cN))),p(),f}}function cN(t,r,i){return r===0?t:tx(t,r,i)}function tx(t,r,i){return(i?"":" ")+t}const dN=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];nx.peek=gN;function fN(){return{canContainEols:["delete"],enter:{strikethrough:pN},exit:{strikethrough:mN}}}function hN(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:dN}],handlers:{delete:nx}}}function pN(t){this.enter({type:"delete",children:[]},t)}function mN(t){this.exit(t)}function nx(t,r,i,l){const o=i.createTracker(l),d=i.enter("strikethrough");let c=o.move("~~");return c+=i.containerPhrasing(t,{...o.current(),before:c,after:"~"}),c+=o.move("~~"),d(),c}function gN(){return"~"}function yN(t){return t.length}function bN(t,r){const i=r||{},l=(i.align||[]).concat(),o=i.stringLength||yN,d=[],c=[],h=[],f=[];let p=0,y=-1;for(;++y<t.length;){const N=[],C=[];let E=-1;for(t[y].length>p&&(p=t[y].length);++E<t[y].length;){const A=vN(t[y][E]);if(i.alignDelimiters!==!1){const D=o(A);C[E]=D,(f[E]===void 0||D>f[E])&&(f[E]=D)}N.push(A)}c[y]=N,h[y]=C}let b=-1;if(typeof l=="object"&&"length"in l)for(;++b<p;)d[b]=Ab(l[b]);else{const N=Ab(l);for(;++b<p;)d[b]=N}b=-1;const v=[],w=[];for(;++b<p;){const N=d[b];let C="",E="";N===99?(C=":",E=":"):N===108?C=":":N===114&&(E=":");let A=i.alignDelimiters===!1?1:Math.max(1,f[b]-C.length-E.length);const D=C+"-".repeat(A)+E;i.alignDelimiters!==!1&&(A=C.length+A+E.length,A>f[b]&&(f[b]=A),w[b]=A),v[b]=D}c.splice(1,0,v),h.splice(1,0,w),y=-1;const j=[];for(;++y<c.length;){const N=c[y],C=h[y];b=-1;const E=[];for(;++b<p;){const A=N[b]||"";let D="",L="";if(i.alignDelimiters!==!1){const J=f[b]-(C[b]||0),T=d[b];T===114?D=" ".repeat(J):T===99?J%2?(D=" ".repeat(J/2+.5),L=" ".repeat(J/2-.5)):(D=" ".repeat(J/2),L=D):L=" ".repeat(J)}i.delimiterStart!==!1&&!b&&E.push("|"),i.padding!==!1&&!(i.alignDelimiters===!1&&A==="")&&(i.delimiterStart!==!1||b)&&E.push(" "),i.alignDelimiters!==!1&&E.push(D),E.push(A),i.alignDelimiters!==!1&&E.push(L),i.padding!==!1&&E.push(" "),(i.delimiterEnd!==!1||b!==p-1)&&E.push("|")}j.push(i.delimiterEnd===!1?E.join("").replace(/ +$/,""):E.join(""))}return j.join(`
|
|
59
|
+
`)}function vN(t){return t==null?"":String(t)}function Ab(t){const r=typeof t=="string"?t.codePointAt(0):0;return r===67||r===99?99:r===76||r===108?108:r===82||r===114?114:0}function xN(t,r,i,l){const o=i.enter("blockquote"),d=i.createTracker(l);d.move("> "),d.shift(2);const c=i.indentLines(i.containerFlow(t,d.current()),wN);return o(),c}function wN(t,r,i){return">"+(i?"":" ")+t}function SN(t,r){return Rb(t,r.inConstruct,!0)&&!Rb(t,r.notInConstruct,!1)}function Rb(t,r,i){if(typeof r=="string"&&(r=[r]),!r||r.length===0)return i;let l=-1;for(;++l<r.length;)if(t.includes(r[l]))return!0;return!1}function zb(t,r,i,l){let o=-1;for(;++o<i.unsafe.length;)if(i.unsafe[o].character===`
|
|
60
|
+
`&&SN(i.stack,i.unsafe[o]))return/[ \t]/.test(l.before)?"":" ";return`\\
|
|
61
|
+
`}function jN(t,r){const i=String(t);let l=i.indexOf(r),o=l,d=0,c=0;if(typeof r!="string")throw new TypeError("Expected substring");for(;l!==-1;)l===o?++d>c&&(c=d):d=1,o=l+r.length,l=i.indexOf(r,o);return c}function kN(t,r){return!!(r.options.fences===!1&&t.value&&!t.lang&&/[^ \r\n]/.test(t.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(t.value))}function EN(t){const r=t.options.fence||"`";if(r!=="`"&&r!=="~")throw new Error("Cannot serialize code with `"+r+"` for `options.fence`, expected `` ` `` or `~`");return r}function CN(t,r,i,l){const o=EN(i),d=t.value||"",c=o==="`"?"GraveAccent":"Tilde";if(kN(t,i)){const b=i.enter("codeIndented"),v=i.indentLines(d,TN);return b(),v}const h=i.createTracker(l),f=o.repeat(Math.max(jN(d,o)+1,3)),p=i.enter("codeFenced");let y=h.move(f);if(t.lang){const b=i.enter(`codeFencedLang${c}`);y+=h.move(i.safe(t.lang,{before:y,after:" ",encode:["`"],...h.current()})),b()}if(t.lang&&t.meta){const b=i.enter(`codeFencedMeta${c}`);y+=h.move(" "),y+=h.move(i.safe(t.meta,{before:y,after:`
|
|
62
|
+
`,encode:["`"],...h.current()})),b()}return y+=h.move(`
|
|
63
|
+
`),d&&(y+=h.move(d+`
|
|
64
|
+
`)),y+=h.move(f),p(),y}function TN(t,r,i){return(i?"":" ")+t}function Zf(t){const r=t.options.quote||'"';if(r!=='"'&&r!=="'")throw new Error("Cannot serialize title with `"+r+"` for `options.quote`, expected `\"`, or `'`");return r}function NN(t,r,i,l){const o=Zf(i),d=o==='"'?"Quote":"Apostrophe",c=i.enter("definition");let h=i.enter("label");const f=i.createTracker(l);let p=f.move("[");return p+=f.move(i.safe(i.associationId(t),{before:p,after:"]",...f.current()})),p+=f.move("]: "),h(),!t.url||/[\0- \u007F]/.test(t.url)?(h=i.enter("destinationLiteral"),p+=f.move("<"),p+=f.move(i.safe(t.url,{before:p,after:">",...f.current()})),p+=f.move(">")):(h=i.enter("destinationRaw"),p+=f.move(i.safe(t.url,{before:p,after:t.title?" ":`
|
|
65
|
+
`,...f.current()}))),h(),t.title&&(h=i.enter(`title${d}`),p+=f.move(" "+o),p+=f.move(i.safe(t.title,{before:p,after:o,...f.current()})),p+=f.move(o),h()),c(),p}function AN(t){const r=t.options.emphasis||"*";if(r!=="*"&&r!=="_")throw new Error("Cannot serialize emphasis with `"+r+"` for `options.emphasis`, expected `*`, or `_`");return r}function Ll(t){return"&#x"+t.toString(16).toUpperCase()+";"}function Ao(t,r,i){const l=Ts(t),o=Ts(r);return l===void 0?o===void 0?i==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:l===1?o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}rx.peek=RN;function rx(t,r,i,l){const o=AN(i),d=i.enter("emphasis"),c=i.createTracker(l),h=c.move(o);let f=c.move(i.containerPhrasing(t,{after:o,before:h,...c.current()}));const p=f.charCodeAt(0),y=Ao(l.before.charCodeAt(l.before.length-1),p,o);y.inside&&(f=Ll(p)+f.slice(1));const b=f.charCodeAt(f.length-1),v=Ao(l.after.charCodeAt(0),b,o);v.inside&&(f=f.slice(0,-1)+Ll(b));const w=c.move(o);return d(),i.attentionEncodeSurroundingInfo={after:v.outside,before:y.outside},h+f+w}function RN(t,r,i){return i.options.emphasis||"*"}function zN(t,r){let i=!1;return Kf(t,function(l){if("value"in l&&/\r?\n|\r/.test(l.value)||l.type==="break")return i=!0,pf}),!!((!t.depth||t.depth<3)&&Pf(t)&&(r.options.setext||i))}function _N(t,r,i,l){const o=Math.max(Math.min(6,t.depth||1),1),d=i.createTracker(l);if(zN(t,i)){const y=i.enter("headingSetext"),b=i.enter("phrasing"),v=i.containerPhrasing(t,{...d.current(),before:`
|
|
66
|
+
`,after:`
|
|
67
|
+
`});return b(),y(),v+`
|
|
68
|
+
`+(o===1?"=":"-").repeat(v.length-(Math.max(v.lastIndexOf("\r"),v.lastIndexOf(`
|
|
69
|
+
`))+1))}const c="#".repeat(o),h=i.enter("headingAtx"),f=i.enter("phrasing");d.move(c+" ");let p=i.containerPhrasing(t,{before:"# ",after:`
|
|
70
|
+
`,...d.current()});return/^[\t ]/.test(p)&&(p=Ll(p.charCodeAt(0))+p.slice(1)),p=p?c+" "+p:c,i.options.closeAtx&&(p+=" "+c),f(),h(),p}ix.peek=MN;function ix(t){return t.value||""}function MN(){return"<"}sx.peek=DN;function sx(t,r,i,l){const o=Zf(i),d=o==='"'?"Quote":"Apostrophe",c=i.enter("image");let h=i.enter("label");const f=i.createTracker(l);let p=f.move("![");return p+=f.move(i.safe(t.alt,{before:p,after:"]",...f.current()})),p+=f.move("]("),h(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(h=i.enter("destinationLiteral"),p+=f.move("<"),p+=f.move(i.safe(t.url,{before:p,after:">",...f.current()})),p+=f.move(">")):(h=i.enter("destinationRaw"),p+=f.move(i.safe(t.url,{before:p,after:t.title?" ":")",...f.current()}))),h(),t.title&&(h=i.enter(`title${d}`),p+=f.move(" "+o),p+=f.move(i.safe(t.title,{before:p,after:o,...f.current()})),p+=f.move(o),h()),p+=f.move(")"),c(),p}function DN(){return"!"}lx.peek=ON;function lx(t,r,i,l){const o=t.referenceType,d=i.enter("imageReference");let c=i.enter("label");const h=i.createTracker(l);let f=h.move("![");const p=i.safe(t.alt,{before:f,after:"]",...h.current()});f+=h.move(p+"]["),c();const y=i.stack;i.stack=[],c=i.enter("reference");const b=i.safe(i.associationId(t),{before:f,after:"]",...h.current()});return c(),i.stack=y,d(),o==="full"||!p||p!==b?f+=h.move(b+"]"):o==="shortcut"?f=f.slice(0,-1):f+=h.move("]"),f}function ON(){return"!"}ax.peek=LN;function ax(t,r,i){let l=t.value||"",o="`",d=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(l);)o+="`";for(/[^ \r\n]/.test(l)&&(/^[ \r\n]/.test(l)&&/[ \r\n]$/.test(l)||/^`|`$/.test(l))&&(l=" "+l+" ");++d<i.unsafe.length;){const c=i.unsafe[d],h=i.compilePattern(c);let f;if(c.atBreak)for(;f=h.exec(l);){let p=f.index;l.charCodeAt(p)===10&&l.charCodeAt(p-1)===13&&p--,l=l.slice(0,p)+" "+l.slice(f.index+1)}}return o+l+o}function LN(){return"`"}function ox(t,r){const i=Pf(t);return!!(!r.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(i===t.url||"mailto:"+i===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}ux.peek=IN;function ux(t,r,i,l){const o=Zf(i),d=o==='"'?"Quote":"Apostrophe",c=i.createTracker(l);let h,f;if(ox(t,i)){const y=i.stack;i.stack=[],h=i.enter("autolink");let b=c.move("<");return b+=c.move(i.containerPhrasing(t,{before:b,after:">",...c.current()})),b+=c.move(">"),h(),i.stack=y,b}h=i.enter("link"),f=i.enter("label");let p=c.move("[");return p+=c.move(i.containerPhrasing(t,{before:p,after:"](",...c.current()})),p+=c.move("]("),f(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(f=i.enter("destinationLiteral"),p+=c.move("<"),p+=c.move(i.safe(t.url,{before:p,after:">",...c.current()})),p+=c.move(">")):(f=i.enter("destinationRaw"),p+=c.move(i.safe(t.url,{before:p,after:t.title?" ":")",...c.current()}))),f(),t.title&&(f=i.enter(`title${d}`),p+=c.move(" "+o),p+=c.move(i.safe(t.title,{before:p,after:o,...c.current()})),p+=c.move(o),f()),p+=c.move(")"),h(),p}function IN(t,r,i){return ox(t,i)?"<":"["}cx.peek=BN;function cx(t,r,i,l){const o=t.referenceType,d=i.enter("linkReference");let c=i.enter("label");const h=i.createTracker(l);let f=h.move("[");const p=i.containerPhrasing(t,{before:f,after:"]",...h.current()});f+=h.move(p+"]["),c();const y=i.stack;i.stack=[],c=i.enter("reference");const b=i.safe(i.associationId(t),{before:f,after:"]",...h.current()});return c(),i.stack=y,d(),o==="full"||!p||p!==b?f+=h.move(b+"]"):o==="shortcut"?f=f.slice(0,-1):f+=h.move("]"),f}function BN(){return"["}function Jf(t){const r=t.options.bullet||"*";if(r!=="*"&&r!=="+"&&r!=="-")throw new Error("Cannot serialize items with `"+r+"` for `options.bullet`, expected `*`, `+`, or `-`");return r}function qN(t){const r=Jf(t),i=t.options.bulletOther;if(!i)return r==="*"?"-":"*";if(i!=="*"&&i!=="+"&&i!=="-")throw new Error("Cannot serialize items with `"+i+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(i===r)throw new Error("Expected `bullet` (`"+r+"`) and `bulletOther` (`"+i+"`) to be different");return i}function UN(t){const r=t.options.bulletOrdered||".";if(r!=="."&&r!==")")throw new Error("Cannot serialize items with `"+r+"` for `options.bulletOrdered`, expected `.` or `)`");return r}function dx(t){const r=t.options.rule||"*";if(r!=="*"&&r!=="-"&&r!=="_")throw new Error("Cannot serialize rules with `"+r+"` for `options.rule`, expected `*`, `-`, or `_`");return r}function HN(t,r,i,l){const o=i.enter("list"),d=i.bulletCurrent;let c=t.ordered?UN(i):Jf(i);const h=t.ordered?c==="."?")":".":qN(i);let f=r&&i.bulletLastUsed?c===i.bulletLastUsed:!1;if(!t.ordered){const y=t.children?t.children[0]:void 0;if((c==="*"||c==="-")&&y&&(!y.children||!y.children[0])&&i.stack[i.stack.length-1]==="list"&&i.stack[i.stack.length-2]==="listItem"&&i.stack[i.stack.length-3]==="list"&&i.stack[i.stack.length-4]==="listItem"&&i.indexStack[i.indexStack.length-1]===0&&i.indexStack[i.indexStack.length-2]===0&&i.indexStack[i.indexStack.length-3]===0&&(f=!0),dx(i)===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"){f=!0;break}}}}f&&(c=h),i.bulletCurrent=c;const p=i.containerFlow(t,l);return i.bulletLastUsed=c,i.bulletCurrent=d,o(),p}function PN(t){const r=t.options.listItemIndent||"one";if(r!=="tab"&&r!=="one"&&r!=="mixed")throw new Error("Cannot serialize items with `"+r+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return r}function FN(t,r,i,l){const o=PN(i);let d=i.bulletCurrent||Jf(i);r&&r.type==="list"&&r.ordered&&(d=(typeof r.start=="number"&&r.start>-1?r.start:1)+(i.options.incrementListMarker===!1?0:r.children.indexOf(t))+d);let c=d.length+1;(o==="tab"||o==="mixed"&&(r&&r.type==="list"&&r.spread||t.spread))&&(c=Math.ceil(c/4)*4);const h=i.createTracker(l);h.move(d+" ".repeat(c-d.length)),h.shift(c);const f=i.enter("listItem"),p=i.indentLines(i.containerFlow(t,h.current()),y);return f(),p;function y(b,v,w){return v?(w?"":" ".repeat(c))+b:(w?d:d+" ".repeat(c-d.length))+b}}function $N(t,r,i,l){const o=i.enter("paragraph"),d=i.enter("phrasing"),c=i.containerPhrasing(t,l);return d(),o(),c}const GN=Io(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function VN(t,r,i,l){return(t.children.some(function(c){return GN(c)})?i.containerPhrasing:i.containerFlow).call(i,t,l)}function YN(t){const r=t.options.strong||"*";if(r!=="*"&&r!=="_")throw new Error("Cannot serialize strong with `"+r+"` for `options.strong`, expected `*`, or `_`");return r}fx.peek=QN;function fx(t,r,i,l){const o=YN(i),d=i.enter("strong"),c=i.createTracker(l),h=c.move(o+o);let f=c.move(i.containerPhrasing(t,{after:o,before:h,...c.current()}));const p=f.charCodeAt(0),y=Ao(l.before.charCodeAt(l.before.length-1),p,o);y.inside&&(f=Ll(p)+f.slice(1));const b=f.charCodeAt(f.length-1),v=Ao(l.after.charCodeAt(0),b,o);v.inside&&(f=f.slice(0,-1)+Ll(b));const w=c.move(o+o);return d(),i.attentionEncodeSurroundingInfo={after:v.outside,before:y.outside},h+f+w}function QN(t,r,i){return i.options.strong||"*"}function KN(t,r,i,l){return i.safe(t.value,l)}function XN(t){const r=t.options.ruleRepetition||3;if(r<3)throw new Error("Cannot serialize rules with repetition `"+r+"` for `options.ruleRepetition`, expected `3` or more");return r}function ZN(t,r,i){const l=(dx(i)+(i.options.ruleSpaces?" ":"")).repeat(XN(i));return i.options.ruleSpaces?l.slice(0,-1):l}const hx={blockquote:xN,break:zb,code:CN,definition:NN,emphasis:rx,hardBreak:zb,heading:_N,html:ix,image:sx,imageReference:lx,inlineCode:ax,link:ux,linkReference:cx,list:HN,listItem:FN,paragraph:$N,root:VN,strong:fx,text:KN,thematicBreak:ZN};function JN(){return{enter:{table:WN,tableData:_b,tableHeader:_b,tableRow:t2},exit:{codeText:n2,table:e2,tableData:Zd,tableHeader:Zd,tableRow:Zd}}}function WN(t){const r=t._align;this.enter({type:"table",align:r.map(function(i){return i==="none"?null:i}),children:[]},t),this.data.inTable=!0}function e2(t){this.exit(t),this.data.inTable=void 0}function t2(t){this.enter({type:"tableRow",children:[]},t)}function Zd(t){this.exit(t)}function _b(t){this.enter({type:"tableCell",children:[]},t)}function n2(t){let r=this.resume();this.data.inTable&&(r=r.replace(/\\([\\|])/g,r2));const i=this.stack[this.stack.length-1];i.type,i.value=r,this.exit(t)}function r2(t,r){return r==="|"?r:t}function i2(t){const r=t||{},i=r.tableCellPadding,l=r.tablePipeAlign,o=r.stringLength,d=i?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
71
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:v,table:c,tableCell:f,tableRow:h}};function c(w,j,N,C){return p(y(w,N,C),w.align)}function h(w,j,N,C){const E=b(w,N,C),A=p([E]);return A.slice(0,A.indexOf(`
|
|
72
|
+
`))}function f(w,j,N,C){const E=N.enter("tableCell"),A=N.enter("phrasing"),D=N.containerPhrasing(w,{...C,before:d,after:d});return A(),E(),D}function p(w,j){return bN(w,{align:j,alignDelimiters:l,padding:i,stringLength:o})}function y(w,j,N){const C=w.children;let E=-1;const A=[],D=j.enter("table");for(;++E<C.length;)A[E]=b(C[E],j,N);return D(),A}function b(w,j,N){const C=w.children;let E=-1;const A=[],D=j.enter("tableRow");for(;++E<C.length;)A[E]=f(C[E],w,j,N);return D(),A}function v(w,j,N){let C=hx.inlineCode(w,j,N);return N.stack.includes("tableCell")&&(C=C.replace(/\|/g,"\\$&")),C}}function s2(){return{exit:{taskListCheckValueChecked:Mb,taskListCheckValueUnchecked:Mb,paragraph:a2}}}function l2(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:o2}}}function Mb(t){const r=this.stack[this.stack.length-2];r.type,r.checked=t.type==="taskListCheckValueChecked"}function a2(t){const r=this.stack[this.stack.length-2];if(r&&r.type==="listItem"&&typeof r.checked=="boolean"){const i=this.stack[this.stack.length-1];i.type;const l=i.children[0];if(l&&l.type==="text"){const o=r.children;let d=-1,c;for(;++d<o.length;){const h=o[d];if(h.type==="paragraph"){c=h;break}}c===i&&(l.value=l.value.slice(1),l.value.length===0?i.children.shift():i.position&&l.position&&typeof l.position.start.offset=="number"&&(l.position.start.column++,l.position.start.offset++,i.position.start=Object.assign({},l.position.start)))}}this.exit(t)}function o2(t,r,i,l){const o=t.children[0],d=typeof t.checked=="boolean"&&o&&o.type==="paragraph",c="["+(t.checked?"x":" ")+"] ",h=i.createTracker(l);d&&h.move(c);let f=hx.listItem(t,r,i,{...l,...h.current()});return d&&(f=f.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,p)),f;function p(y){return y+c}}function u2(){return[HT(),oN(),fN(),JN(),s2()]}function c2(t){return{extensions:[PT(),uN(t),hN(),i2(t),l2()]}}const d2={tokenize:y2,partial:!0},px={tokenize:b2,partial:!0},mx={tokenize:v2,partial:!0},gx={tokenize:x2,partial:!0},f2={tokenize:w2,partial:!0},yx={name:"wwwAutolink",tokenize:m2,previous:vx},bx={name:"protocolAutolink",tokenize:g2,previous:xx},Rr={name:"emailAutolink",tokenize:p2,previous:wx},ar={};function h2(){return{text:ar}}let Si=48;for(;Si<123;)ar[Si]=Rr,Si++,Si===58?Si=65:Si===91&&(Si=97);ar[43]=Rr;ar[45]=Rr;ar[46]=Rr;ar[95]=Rr;ar[72]=[Rr,bx];ar[104]=[Rr,bx];ar[87]=[Rr,yx];ar[119]=[Rr,yx];function p2(t,r,i){const l=this;let o,d;return c;function c(b){return!bf(b)||!wx.call(l,l.previous)||Wf(l.events)?i(b):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),h(b))}function h(b){return bf(b)?(t.consume(b),h):b===64?(t.consume(b),f):i(b)}function f(b){return b===46?t.check(f2,y,p)(b):b===45||b===95||mn(b)?(d=!0,t.consume(b),f):y(b)}function p(b){return t.consume(b),o=!0,f}function y(b){return d&&o&&bn(l.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),r(b)):i(b)}}function m2(t,r,i){const l=this;return o;function o(c){return c!==87&&c!==119||!vx.call(l,l.previous)||Wf(l.events)?i(c):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(d2,t.attempt(px,t.attempt(mx,d),i),i)(c))}function d(c){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),r(c)}}function g2(t,r,i){const l=this;let o="",d=!1;return c;function c(b){return(b===72||b===104)&&xx.call(l,l.previous)&&!Wf(l.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),o+=String.fromCodePoint(b),t.consume(b),h):i(b)}function h(b){if(bn(b)&&o.length<5)return o+=String.fromCodePoint(b),t.consume(b),h;if(b===58){const v=o.toLowerCase();if(v==="http"||v==="https")return t.consume(b),f}return i(b)}function f(b){return b===47?(t.consume(b),d?p:(d=!0,f)):i(b)}function p(b){return b===null||Co(b)||Pt(b)||Ci(b)||Do(b)?i(b):t.attempt(px,t.attempt(mx,y),i)(b)}function y(b){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),r(b)}}function y2(t,r,i){let l=0;return o;function o(c){return(c===87||c===119)&&l<3?(l++,t.consume(c),o):c===46&&l===3?(t.consume(c),d):i(c)}function d(c){return c===null?i(c):r(c)}}function b2(t,r,i){let l,o,d;return c;function c(p){return p===46||p===95?t.check(gx,f,h)(p):p===null||Pt(p)||Ci(p)||p!==45&&Do(p)?f(p):(d=!0,t.consume(p),c)}function h(p){return p===95?l=!0:(o=l,l=void 0),t.consume(p),c}function f(p){return o||l||!d?i(p):r(p)}}function v2(t,r){let i=0,l=0;return o;function o(c){return c===40?(i++,t.consume(c),o):c===41&&l<i?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(gx,r,d)(c):c===null||Pt(c)||Ci(c)?r(c):(t.consume(c),o)}function d(c){return c===41&&l++,t.consume(c),o}}function x2(t,r,i){return l;function l(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),l):h===38?(t.consume(h),d):h===93?(t.consume(h),o):h===60||h===null||Pt(h)||Ci(h)?r(h):i(h)}function o(h){return h===null||h===40||h===91||Pt(h)||Ci(h)?r(h):l(h)}function d(h){return bn(h)?c(h):i(h)}function c(h){return h===59?(t.consume(h),l):bn(h)?(t.consume(h),c):i(h)}}function w2(t,r,i){return l;function l(d){return t.consume(d),o}function o(d){return mn(d)?i(d):r(d)}}function vx(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Pt(t)}function xx(t){return!bn(t)}function wx(t){return!(t===47||bf(t))}function bf(t){return t===43||t===45||t===46||t===95||mn(t)}function Wf(t){let r=t.length,i=!1;for(;r--;){const l=t[r][1];if((l.type==="labelLink"||l.type==="labelImage")&&!l._balanced){i=!0;break}if(l._gfmAutolinkLiteralWalkedInto){i=!1;break}}return t.length>0&&!i&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),i}const S2={tokenize:R2,partial:!0};function j2(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:T2,continuation:{tokenize:N2},exit:A2}},text:{91:{name:"gfmFootnoteCall",tokenize:C2},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:k2,resolveTo:E2}}}}function k2(t,r,i){const l=this;let o=l.events.length;const d=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let c;for(;o--;){const f=l.events[o][1];if(f.type==="labelImage"){c=f;break}if(f.type==="gfmFootnoteCall"||f.type==="labelLink"||f.type==="label"||f.type==="image"||f.type==="link")break}return h;function h(f){if(!c||!c._balanced)return i(f);const p=Jn(l.sliceSerialize({start:c.end,end:l.now()}));return p.codePointAt(0)!==94||!d.includes(p.slice(1))?i(f):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(f),t.exit("gfmFootnoteCallLabelMarker"),r(f))}}function E2(t,r){let i=t.length;for(;i--;)if(t[i][1].type==="labelImage"&&t[i][0]==="enter"){t[i][1];break}t[i+1][1].type="data",t[i+3][1].type="gfmFootnoteCallLabelMarker";const l={type:"gfmFootnoteCall",start:Object.assign({},t[i+3][1].start),end:Object.assign({},t[t.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},t[i+3][1].end),end:Object.assign({},t[i+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const d={type:"gfmFootnoteCallString",start:Object.assign({},o.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[i+1],t[i+2],["enter",l,r],t[i+3],t[i+4],["enter",o,r],["exit",o,r],["enter",d,r],["enter",c,r],["exit",c,r],["exit",d,r],t[t.length-2],t[t.length-1],["exit",l,r]];return t.splice(i,t.length-i+1,...h),t}function C2(t,r,i){const l=this,o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let d=0,c;return h;function h(b){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(b),t.exit("gfmFootnoteCallLabelMarker"),f}function f(b){return b!==94?i(b):(t.enter("gfmFootnoteCallMarker"),t.consume(b),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",p)}function p(b){if(d>999||b===93&&!c||b===null||b===91||Pt(b))return i(b);if(b===93){t.exit("chunkString");const v=t.exit("gfmFootnoteCallString");return o.includes(Jn(l.sliceSerialize(v)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(b),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),r):i(b)}return Pt(b)||(c=!0),d++,t.consume(b),b===92?y:p}function y(b){return b===91||b===92||b===93?(t.consume(b),d++,p):p(b)}}function T2(t,r,i){const l=this,o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let d,c=0,h;return f;function f(j){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(j),t.exit("gfmFootnoteDefinitionLabelMarker"),p}function p(j){return j===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(j),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",y):i(j)}function y(j){if(c>999||j===93&&!h||j===null||j===91||Pt(j))return i(j);if(j===93){t.exit("chunkString");const N=t.exit("gfmFootnoteDefinitionLabelString");return d=Jn(l.sliceSerialize(N)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(j),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),v}return Pt(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"),o.includes(d)||o.push(d),Nt(t,w,"gfmFootnoteDefinitionWhitespace")):i(j)}function w(j){return r(j)}}function N2(t,r,i){return t.check(Hl,r,t.attempt(S2,r,i))}function A2(t){t.exit("gfmFootnoteDefinition")}function R2(t,r,i){const l=this;return Nt(t,o,"gfmFootnoteDefinitionIndent",5);function o(d){const c=l.events[l.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?r(d):i(d)}}function z2(t){let i=(t||{}).singleTilde;const l={name:"strikethrough",tokenize:d,resolveAll:o};return i==null&&(i=!0),{text:{126:l},insideSpan:{null:[l]},attentionMarkers:{null:[126]}};function o(c,h){let f=-1;for(;++f<c.length;)if(c[f][0]==="enter"&&c[f][1].type==="strikethroughSequenceTemporary"&&c[f][1]._close){let p=f;for(;p--;)if(c[p][0]==="exit"&&c[p][1].type==="strikethroughSequenceTemporary"&&c[p][1]._open&&c[f][1].end.offset-c[f][1].start.offset===c[p][1].end.offset-c[p][1].start.offset){c[f][1].type="strikethroughSequence",c[p][1].type="strikethroughSequence";const y={type:"strikethrough",start:Object.assign({},c[p][1].start),end:Object.assign({},c[f][1].end)},b={type:"strikethroughText",start:Object.assign({},c[p][1].end),end:Object.assign({},c[f][1].start)},v=[["enter",y,h],["enter",c[p][1],h],["exit",c[p][1],h],["enter",b,h]],w=h.parser.constructs.insideSpan.null;w&&On(v,v.length,0,Oo(w,c.slice(p+1,f),h)),On(v,v.length,0,[["exit",b,h],["enter",c[f][1],h],["exit",c[f][1],h],["exit",y,h]]),On(c,p-1,f-p+3,v),f=p+v.length-2;break}}for(f=-1;++f<c.length;)c[f][1].type==="strikethroughSequenceTemporary"&&(c[f][1].type="data");return c}function d(c,h,f){const p=this.previous,y=this.events;let b=0;return v;function v(j){return p===126&&y[y.length-1][1].type!=="characterEscape"?f(j):(c.enter("strikethroughSequenceTemporary"),w(j))}function w(j){const N=Ts(p);if(j===126)return b>1?f(j):(c.consume(j),b++,w);if(b<2&&!i)return f(j);const C=c.exit("strikethroughSequenceTemporary"),E=Ts(j);return C._open=!E||E===2&&!!N,C._close=!N||N===2&&!!E,h(j)}}}class _2{constructor(){this.map=[]}add(r,i,l){M2(this,r,i,l)}consume(r){if(this.map.sort(function(d,c){return d[0]-c[0]}),this.map.length===0)return;let i=this.map.length;const l=[];for(;i>0;)i-=1,l.push(r.slice(this.map[i][0]+this.map[i][1]),this.map[i][2]),r.length=this.map[i][0];l.push(r.slice()),r.length=0;let o=l.pop();for(;o;){for(const d of o)r.push(d);o=l.pop()}this.map.length=0}}function M2(t,r,i,l){let o=0;if(!(i===0&&l.length===0)){for(;o<t.map.length;){if(t.map[o][0]===r){t.map[o][1]+=i,t.map[o][2].push(...l);return}o+=1}t.map.push([r,i,l])}}function D2(t,r){let i=!1;const l=[];for(;r<t.length;){const o=t[r];if(i){if(o[0]==="enter")o[1].type==="tableContent"&&l.push(t[r+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(t[r-1][1].type==="tableDelimiterMarker"){const d=l.length-1;l[d]=l[d]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(i=!0);r+=1}return l}function O2(){return{flow:{null:{name:"table",tokenize:L2,resolveAll:I2}}}}function L2(t,r,i){const l=this;let o=0,d=0,c;return h;function h(_){let I=l.events.length-1;for(;I>-1;){const $=l.events[I][1].type;if($==="lineEnding"||$==="linePrefix")I--;else break}const H=I>-1?l.events[I][1].type:null,Y=H==="tableHead"||H==="tableRow"?T:f;return Y===T&&l.parser.lazy[l.now().line]?i(_):Y(_)}function f(_){return t.enter("tableHead"),t.enter("tableRow"),p(_)}function p(_){return _===124||(c=!0,d+=1),y(_)}function y(_){return _===null?i(_):We(_)?d>1?(d=0,l.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(_),t.exit("lineEnding"),w):i(_):jt(_)?Nt(t,y,"whitespace")(_):(d+=1,c&&(c=!1,o+=1),_===124?(t.enter("tableCellDivider"),t.consume(_),t.exit("tableCellDivider"),c=!0,y):(t.enter("data"),b(_)))}function b(_){return _===null||_===124||Pt(_)?(t.exit("data"),y(_)):(t.consume(_),_===92?v:b)}function v(_){return _===92||_===124?(t.consume(_),b):b(_)}function w(_){return l.interrupt=!1,l.parser.lazy[l.now().line]?i(_):(t.enter("tableDelimiterRow"),c=!1,jt(_)?Nt(t,j,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(_):j(_))}function j(_){return _===45||_===58?C(_):_===124?(c=!0,t.enter("tableCellDivider"),t.consume(_),t.exit("tableCellDivider"),N):J(_)}function N(_){return jt(_)?Nt(t,C,"whitespace")(_):C(_)}function C(_){return _===58?(d+=1,c=!0,t.enter("tableDelimiterMarker"),t.consume(_),t.exit("tableDelimiterMarker"),E):_===45?(d+=1,E(_)):_===null||We(_)?L(_):J(_)}function E(_){return _===45?(t.enter("tableDelimiterFiller"),A(_)):J(_)}function A(_){return _===45?(t.consume(_),A):_===58?(c=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(_),t.exit("tableDelimiterMarker"),D):(t.exit("tableDelimiterFiller"),D(_))}function D(_){return jt(_)?Nt(t,L,"whitespace")(_):L(_)}function L(_){return _===124?j(_):_===null||We(_)?!c||o!==d?J(_):(t.exit("tableDelimiterRow"),t.exit("tableHead"),r(_)):J(_)}function J(_){return i(_)}function T(_){return t.enter("tableRow"),B(_)}function B(_){return _===124?(t.enter("tableCellDivider"),t.consume(_),t.exit("tableCellDivider"),B):_===null||We(_)?(t.exit("tableRow"),r(_)):jt(_)?Nt(t,B,"whitespace")(_):(t.enter("data"),U(_))}function U(_){return _===null||_===124||Pt(_)?(t.exit("data"),B(_)):(t.consume(_),_===92?X:U)}function X(_){return _===92||_===124?(t.consume(_),U):U(_)}}function I2(t,r){let i=-1,l=!0,o=0,d=[0,0,0,0],c=[0,0,0,0],h=!1,f=0,p,y,b;const v=new _2;for(;++i<t.length;){const w=t[i],j=w[1];w[0]==="enter"?j.type==="tableHead"?(h=!1,f!==0&&(Db(v,r,f,p,y),y=void 0,f=0),p={type:"table",start:Object.assign({},j.start),end:Object.assign({},j.end)},v.add(i,0,[["enter",p,r]])):j.type==="tableRow"||j.type==="tableDelimiterRow"?(l=!0,b=void 0,d=[0,0,0,0],c=[0,i+1,0,0],h&&(h=!1,y={type:"tableBody",start:Object.assign({},j.start),end:Object.assign({},j.end)},v.add(i,0,[["enter",y,r]])),o=j.type==="tableDelimiterRow"?2:y?3:1):o&&(j.type==="data"||j.type==="tableDelimiterMarker"||j.type==="tableDelimiterFiller")?(l=!1,c[2]===0&&(d[1]!==0&&(c[0]=c[1],b=go(v,r,d,o,void 0,b),d=[0,0,0,0]),c[2]=i)):j.type==="tableCellDivider"&&(l?l=!1:(d[1]!==0&&(c[0]=c[1],b=go(v,r,d,o,void 0,b)),d=c,c=[d[1],i,0,0])):j.type==="tableHead"?(h=!0,f=i):j.type==="tableRow"||j.type==="tableDelimiterRow"?(f=i,d[1]!==0?(c[0]=c[1],b=go(v,r,d,o,i,b)):c[1]!==0&&(b=go(v,r,c,o,i,b)),o=0):o&&(j.type==="data"||j.type==="tableDelimiterMarker"||j.type==="tableDelimiterFiller")&&(c[3]=i)}for(f!==0&&Db(v,r,f,p,y),v.consume(r.events),i=-1;++i<r.events.length;){const w=r.events[i];w[0]==="enter"&&w[1].type==="table"&&(w[1]._align=D2(r.events,i))}return t}function go(t,r,i,l,o,d){const c=l===1?"tableHeader":l===2?"tableDelimiter":"tableData",h="tableContent";i[0]!==0&&(d.end=Object.assign({},Ss(r.events,i[0])),t.add(i[0],0,[["exit",d,r]]));const f=Ss(r.events,i[1]);if(d={type:c,start:Object.assign({},f),end:Object.assign({},f)},t.add(i[1],0,[["enter",d,r]]),i[2]!==0){const p=Ss(r.events,i[2]),y=Ss(r.events,i[3]),b={type:h,start:Object.assign({},p),end:Object.assign({},y)};if(t.add(i[2],0,[["enter",b,r]]),l!==2){const v=r.events[i[2]],w=r.events[i[3]];if(v[1].end=Object.assign({},w[1].end),v[1].type="chunkText",v[1].contentType="text",i[3]>i[2]+1){const j=i[2]+1,N=i[3]-i[2]-1;t.add(j,N,[])}}t.add(i[3]+1,0,[["exit",b,r]])}return o!==void 0&&(d.end=Object.assign({},Ss(r.events,o)),t.add(o,0,[["exit",d,r]]),d=void 0),d}function Db(t,r,i,l,o){const d=[],c=Ss(r.events,i);o&&(o.end=Object.assign({},c),d.push(["exit",o,r])),l.end=Object.assign({},c),d.push(["exit",l,r]),t.add(i+1,0,d)}function Ss(t,r){const i=t[r],l=i[0]==="enter"?"start":"end";return i[1][l]}const B2={name:"tasklistCheck",tokenize:U2};function q2(){return{text:{91:B2}}}function U2(t,r,i){const l=this;return o;function o(f){return l.previous!==null||!l._gfmTasklistFirstContentOfListItem?i(f):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(f),t.exit("taskListCheckMarker"),d)}function d(f){return Pt(f)?(t.enter("taskListCheckValueUnchecked"),t.consume(f),t.exit("taskListCheckValueUnchecked"),c):f===88||f===120?(t.enter("taskListCheckValueChecked"),t.consume(f),t.exit("taskListCheckValueChecked"),c):i(f)}function c(f){return f===93?(t.enter("taskListCheckMarker"),t.consume(f),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),h):i(f)}function h(f){return We(f)?r(f):jt(f)?t.check({tokenize:H2},r,i)(f):i(f)}}function H2(t,r,i){return Nt(t,l,"whitespace");function l(o){return o===null?i(o):r(o)}}function P2(t){return _v([h2(),j2(),z2(t),O2(),q2()])}const F2={};function $2(t){const r=this,i=t||F2,l=r.data(),o=l.micromarkExtensions||(l.micromarkExtensions=[]),d=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),c=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);o.push(P2(i)),d.push(u2()),c.push(c2(i))}function vf(t){const r=t.trim();if(!(!r||/[\u0000-\u0020\u007f]/.test(r)))try{const i=new URL(r);if(i.protocol==="https:"||i.protocol==="http:"||i.protocol==="mailto:")return r}catch{}}function xf(t){return!!t&&!/[\u0000-\u001f\u007f]/.test(t)&&!/^[a-z][a-z\d+.-]*:/i.test(t)&&!t.startsWith("//")}function Ob(t){if(!xf(t))return;const r=t.split(/[?#]/,1)[0];if(r)try{const i=decodeURIComponent(r);return xf(i)?i:void 0}catch{return}}async function G2(t){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(t);return}const r=document.activeElement,i=document.createElement("textarea");i.value=t,i.setAttribute("aria-label","复制内容"),i.style.cssText="position:fixed;left:-10000px;top:0",document.body.append(i);try{if(i.select(),!document.execCommand("copy"))throw new Error("复制不可用")}finally{i.remove(),r instanceof HTMLElement&&r.focus({preventScroll:!0})}}function qo({text:t,label:r="复制"}){const[i,l]=x.useState("idle"),o=x.useRef(!0),d=x.useRef(void 0);x.useEffect(()=>(o.current=!0,()=>{o.current=!1,clearTimeout(d.current)}),[]);const c=async()=>{clearTimeout(d.current);try{await G2(t),o.current&&l("copied")}catch{o.current&&l("error")}o.current&&(d.current=setTimeout(()=>l("idle"),2500))};return a.jsx("button",{className:"message-copy",onClick:()=>{c()},"aria-label":r,title:r,children:i==="copied"?"已复制":i==="error"?"复制失败":r})}function wf(t){return typeof t=="string"||typeof t=="number"?String(t):Array.isArray(t)?t.map(wf).join(""):x.isValidElement(t)?wf(t.props.children):""}function V2({children:t}){const r=x.Children.toArray(t).find(d=>x.isValidElement(d)),l=(x.isValidElement(r)?r.props.className??"":"").match(/(?:^|\s)language-([\w+-]+)/)?.[1]??"代码",o=wf(t).replace(/\n$/,"");return a.jsxs("div",{className:"message-code-block",children:[a.jsxs("div",{className:"message-code-heading",children:[a.jsx("span",{children:l}),a.jsx(qo,{text:o,label:"复制代码"})]}),a.jsx("pre",{tabIndex:0,children:t})]})}function Y2(t){return{a:({href:r,children:i,title:l})=>{const o=vf(r??"");if(o)return a.jsx("a",{href:o,title:l,target:"_blank",rel:"noopener noreferrer",referrerPolicy:"no-referrer",children:i});const d=r?Ob(r):void 0;return d?a.jsxs("span",{className:"message-file-reference",title:d,children:[t?a.jsx("button",{className:"message-file-open",onClick:()=>t(d),children:i}):i,a.jsx(qo,{text:d,label:"复制路径"})]}):a.jsx("span",{children:i})},img:({src:r,alt:i})=>{const l=vf(typeof r=="string"?r:""),o=typeof r=="string"?Ob(r):void 0;return l?a.jsxs("a",{className:"message-image-reference",href:l,target:"_blank",rel:"noopener noreferrer",referrerPolicy:"no-referrer",children:[i||"图片",a.jsx("span",{children:"打开图片 ↗"})]}):o&&t?a.jsxs("button",{className:"message-image-reference",title:o,onClick:()=>t(o),children:[i||"图片",a.jsx("span",{children:"查看图片"})]}):a.jsxs("span",{className:"message-image-reference",children:[i||"图片",a.jsx("span",{children:"图片路径不可直接访问"})]})},pre:({children:r})=>a.jsx(V2,{children:r}),table:({children:r})=>a.jsx("div",{className:"message-table-scroll",role:"region","aria-label":"表格",tabIndex:0,children:a.jsx("table",{children:r})})}}const Q2=x.memo(function({text:r,reasoning:i="",streaming:l=!1,onOpenFile:o}){const d=x.useMemo(()=>Y2(o),[o]);return a.jsxs("div",{className:"message-content",children:[i?a.jsxs("details",{className:"message-reasoning",children:[a.jsx("summary",{children:l&&!r?"思考中…":"思考过程"}),a.jsx("pre",{children:i})]}):null,l?a.jsxs("div",{className:"message-streaming",children:[r||(i?"":"正在思考…"),a.jsx("span",{className:"cursor","aria-hidden":"true",children:"▍"})]}):r?a.jsx(zT,{remarkPlugins:[$2],skipHtml:!0,urlTransform:c=>vf(c)??(xf(c)?c:""),components:d,children:r}):null,!l&&r?a.jsx("div",{className:"message-actions",children:a.jsx(qo,{text:r,label:"复制回复"})}):null]})});function K2(t){const r=t.args??{},i=t.summary||[r.description,r.command,r.file_path,r.path,r.query,r.url].find(l=>typeof l=="string"&&l.trim());return typeof i=="string"?i.replace(/\s+/g," ").slice(0,180):""}const X2=x.memo(function({item:r,running:i}){const l=K2(r),o=r.done?r.error?"失败":"已完成":i?"执行中":"未完成";return a.jsxs("details",{className:`message-tool-card${r.error?" message-tool-error":""}`,children:[a.jsxs("summary",{children:[a.jsx("span",{className:"message-tool-indicator","aria-hidden":"true",children:r.done?r.error?"!":"✓":"·"}),a.jsx("span",{className:"message-tool-name",children:r.name}),a.jsx("span",{className:"message-tool-summary",children:l}),a.jsx("span",{className:"message-tool-status",children:o})]}),r.args&&Object.keys(r.args).length?a.jsxs("div",{className:"message-tool-section",children:[a.jsx("strong",{children:"参数"}),a.jsx("pre",{tabIndex:0,children:JSON.stringify(r.args,null,2)})]}):null,a.jsxs("div",{className:"message-tool-section",children:[a.jsxs("div",{className:"message-tool-result-heading",children:[a.jsx("strong",{children:"结果"}),r.result?a.jsx(qo,{text:r.result,label:"复制结果"}):null]}),a.jsx("pre",{tabIndex:0,children:r.result??(r.done?"工具没有返回文本内容。":i?"等待工具返回结果…":"这次工具调用没有保存结果。")})]})]})});function Z2(t){return{running:"运行中",completed:"已完成",error:"失败",recorded:"历史记录"}[t]??t}function J2(t){const r=new URLSearchParams(t).get("session");return r&&/^[a-zA-Z0-9_-]{1,128}$/.test(r)?r:null}function Sx(t,r){return!r||!t.hubEpoch||t.hubSequence===void 0?!0:t.hubEpoch===r.epoch&&t.hubSequence>r.sequence}function Lb(t,r=[]){let i=cv(t.transcript);for(const o of t.liveStream?.events??[])i=ki(i,o.event);t.running?i={...i,run:"running"}:t.running===!1&&(i.run==="running"||i.run==="waiting")&&(i={...i,run:"idle"});let l=t.streamCursor;for(const o of r)Sx(o,l)&&(i=ki(i,o.event),o.hubEpoch&&o.hubSequence!==void 0&&(l={epoch:o.hubEpoch,sequence:o.hubSequence}));return{chat:i,cursor:l,truncated:t.liveStream?.truncated??!1}}async function W2(t,r,i,l,o,d=()=>!0){let c=t.outputJournal??await r({});if(!d())throw new Error("Output recovery cancelled");if(c.status==="unavailable"){const w=o?await o():t.outputCoverage;if(!d())throw new Error("Output recovery cancelled");for(const j of[t.outputCoverage,w])jl({unpaired:j?.unpaired,inputIds:j?.inputIds},{},()=>!1);if(w?.outputCursor||l?.()||i.some(j=>j.event.outputCursor)){if(c=await r({}),c.status==="unavailable")throw new Error("Output recovery journal is unavailable")}else{if(w?.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(w=>w.id===c.legacyBaseThroughEventId);if(h<0)throw new Error("Output recovery legacy anchor was not retained");let f=cv(t.transcript.slice(0,h+1)),p={incomplete:!1},y=0;const b=async()=>{for(;;){if(!d()||++y>2048)throw new Error("Output recovery exceeded its page budget");const w=CS(p,c,j=>{f=ki(f,j)});if(p.incomplete)throw new Error("Output recovery is incomplete");if(w)break;c=await r({after:p.cursor,through:p.through})}};await b();for(let w=0;w<8;w++){const j=o?await o():t.outputCoverage;if(!d())throw new Error("Output recovery cancelled");jl({...j,inputIds:void 0},c,()=>!0);let N;for(const E of[j?.outputCursor,l?.(),...i.map(A=>A.event.outputCursor)]){if(typeof E!="string")continue;const A=N?Rl(E,N):1;if(A===void 0)throw new Error("Output recovery journal changed");A>0&&(N=E)}if(typeof N!="string"){j&&jl(j,c,E=>f.items.some(A=>A.kind==="user"&&A.clientMessageId===E));break}const C=Rl(N,p.cursor);if(C===void 0)throw new Error("Output recovery journal changed");if(C<=0){j&&jl(j,c,E=>f.items.some(A=>A.kind==="user"&&A.clientMessageId===E));break}if(w===7)throw new Error("Output recovery could not catch up within its round budget");p={incomplete:!1,cursor:p.appliedCursor},c=await r({after:p.cursor,through:N}),await b()}const v=new Df;for(const w of i)v.observe(w.event);jl({unpaired:v.incomplete,inputIds:v.inputIds},c,w=>f.items.some(j=>j.kind==="user"&&j.clientMessageId===w),{requireIdentity:!1});for(const w of i){const j=w.event.outputCursor;if(typeof j=="string"){const N=Rl(j,p.cursor);if(N===void 0)throw new Error("Output recovery journal changed");if(N<=0)continue;p.cursor=j}else if(w.event.type==="session_title"){f=ki(f,w.event);continue}else{if(w.event.type==="session_user_message"&&typeof w.event.clientMessageId=="string"&&f.items.some(N=>N.kind==="user"&&N.clientMessageId===w.event.clientMessageId))continue;throw new Error("Output recovery received an unpaired legacy event")}f=ki(f,w.event)}return{chat:f,outputCursor:p.cursor}}function jx(t,r){if(t?.title)return t.title;const i=t?.items.find(l=>l.kind==="user");if(i&&i.kind==="user"&&i.text.trim()){const l=i.text.trim().split(`
|
|
73
|
+
`)[0];return l.length>32?`${l.slice(0,32)}…`:l}return i?.kind==="user"&&i.attachments?.length?`附件:${i.attachments[0].name}`:r.slice(0,8)}const eA=["profile","security","sessions","connections"],tA=["users","summary","audit"];function Ib(t){if(t.pathname==="/api/v1/account/manage"||t.pathname==="/settings/account")return{kind:"account",section:"profile"};const r=/^\/settings\/account\/([^/]+)\/?$/.exec(t.pathname);if(r&&eA.includes(r[1]))return{kind:"account",section:r[1]};const i=/^\/admin\/([^/]+)\/?$/.exec(t.pathname);return i&&tA.includes(i[1])?{kind:"admin",section:i[1]}:{kind:"workbench"}}function nA(t,r){const i=new URLSearchParams,l=r.searchParams.get("project"),o=r.searchParams.get("session");Es(l)&&(i.set("project",l),o&&/^[A-Za-z0-9_-]{1,128}$/.test(o)&&i.set("session",o));const d=wo(r);return d.view!=="chat"&&i.set("view",d.view),d.view==="settings"&&d.section!=="overview"&&i.set("section",d.section),(t.kind==="workbench"?"/":t.kind==="account"?`/settings/account/${t.section}`:`/admin/${t.section}`)+(i.size?`?${i}`:"")}function wo(t){const r=t.searchParams.get("view"),i=t.searchParams.get("section");return{view:["activity","history","files","links","panels","settings"].includes(r??"")?r:"chat",section:["models","skills","mcp"].includes(i??"")?i:"overview"}}function kx(t){return t.kind!=="user"&&!(t.kind==="assistant"&&t.done&&!t.text&&!t.reasoning)}function rA(t,r){if(!kx(r)||t===r)return!1;if(!t||t.kind!==r.kind)return!0;switch(r.kind){case"user":return!1;case"assistant":return t.kind==="assistant"&&(t.text!==r.text||t.reasoning!==r.reasoning||t.done!==r.done);case"tool":return t.kind==="tool"&&(t.result!==r.result||t.summary!==r.summary||t.done!==r.done||t.error!==r.error||JSON.stringify(t.args)!==JSON.stringify(r.args));case"subagent":return t.kind==="subagent"&&(t.label!==r.label||t.status!==r.status);case"system":case"system_error":return(t.kind==="system"||t.kind==="system_error")&&t.text!==r.text}}function iA({items:t,scope:r,connection:i,loading:l,active:o,approvalCount:d}){const c=Ze.useRef(null),h=Ze.useRef(null),f=Ze.useRef(!0),p=Ze.useRef(null),y=Ze.useRef(null),b=Ze.useRef(new Map),v=Ze.useRef(new Set),w=Ze.useRef({scope:r,connection:i,loading:l,active:o}),[j,N]=Ze.useState(!1),[C,E]=Ze.useState(0),A=Ze.useCallback(()=>{v.current.clear(),E(0)},[]),D=Ze.useCallback(()=>{const B=c.current;B&&(B.scrollTop=B.scrollHeight,p.current=B.scrollTop,y.current={width:B.clientWidth,height:B.clientHeight})},[]),L=Ze.useCallback(()=>{f.current=!0,A(),N(!1),D()},[A,D]),J=Ze.useCallback(()=>{const B=c.current;if(!B||!o)return;const U=y.current;if(f.current&&U&&(U.width!==B.clientWidth||U.height!==B.clientHeight)){D(),N(!1);return}const X=B.scrollHeight-B.scrollTop-B.clientHeight<=100;if(p.current!==null&&Math.abs(B.scrollTop-p.current)<=2){p.current=null,N(!X&&!f.current);return}p.current=null,f.current=X,N(!X),X&&A()},[o,A,D]);Ze.useLayoutEffect(()=>{const B=w.current,U=B.scope!==r,X=U||B.connection!==i||B.loading!==l||B.active!==o;w.current={scope:r,connection:i,loading:l,active:o};const _=new Map(t.filter(kx).map(I=>[I.id,I]));if(X)A(),U&&(f.current=!0,p.current=null,N(!1));else if(o&&i==="open"&&!l&&!f.current){for(const I of t)rA(b.current.get(I.id),I)&&v.current.add(I.id);for(const I of v.current)_.has(I)||v.current.delete(I);E(v.current.size)}b.current=_,o&&f.current&&D()},[t,r,i,l,o,d,A,D]),Ze.useEffect(()=>{const B=c.current,U=h.current;if(!o||!B||!U||typeof ResizeObserver>"u")return;const X=new ResizeObserver(()=>{f.current?D():B.scrollHeight-B.scrollTop-B.clientHeight<=100?L():N(!0)});return X.observe(B),X.observe(U),()=>X.disconnect()},[o,L,D]);const T=Ze.useCallback(()=>{L(),c.current?.focus({preventScroll:!0})},[L]);return{listRef:c,contentRef:h,onScroll:J,showJump:j,newOutputCount:C,jumpToLatest:T,resume:L}}function sA(t,r){if(r.workspaceKey!==t.workspaceKey||r.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(i=>!i.asynchronous&&(!i.sessionId||i.sessionId===r.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(!r.prompt.trim()||r.prompt.length>2e4)throw new Error("面板任务内容无效。");if(t.setDraft(r.prompt),!t.send(r.modelTraceSource?{modelTraceSource:r.modelTraceSource}:void 0))throw t.setDraft(""),new Error("当前对话暂时无法接收任务,请稍后重新发送。");return{accepted:!0}}function lA({controller:t,onBackToProjects:r,projectName:i,cloudAccount:l,renderAccountControl:o}){const{connection:d,sessions:c,activeId:h,chat:f,draft:p,files:y,uploading:b,workerNote:v,replayNote:w,error:j,workspaceCwd:N,workspaceName:C,configuration:E,configurationVersion:A,sessionsVersion:D,localDrafts:L,running:J,title:T,approvalCount:B,onAuthLost:U,refreshSessions:X,refreshConfiguration:_,session:I}=t,H=t.workspaceApi,Y=t.host==="desktop"?"桌面":"服务端",[$,F]=x.useState(!1),P=lv(),G=x.useRef(null),re=x.useRef(null),be=x.useRef(null),R=x.useRef(null),[M,te]=x.useState(()=>wo(new URL(window.location.href)).view),[k,W]=x.useState(),[ue,me]=x.useState(),[Q,oe]=x.useState(0),[fe,ke]=x.useState(!1),[_e,Me]=x.useState(null),[Ce,qe]=x.useState(()=>wo(new URL(window.location.href)).section);x.useEffect(()=>{const Z=new URL(window.location.href);M==="chat"?Z.searchParams.delete("view"):Z.searchParams.set("view",M==="panel"?"panels":M),M==="settings"&&Ce!=="overview"?Z.searchParams.set("section",Ce):Z.searchParams.delete("section"),window.history.replaceState(window.history.state,"",Z.pathname+Z.search+Z.hash)},[M,Ce]),x.useEffect(()=>{const Z=()=>{const Te=wo(new URL(window.location.href));te(Te.view),qe(Te.section)};return window.addEventListener("popstate",Z),()=>window.removeEventListener("popstate",Z)},[]);const[Ge,lt]=x.useState(()=>window.matchMedia("(max-width: 760px)").matches),[De,Oe]=x.useState(()=>!window.matchMedia("(max-width: 760px)").matches),ht=x.useRef(null),at=x.useRef(null),dt=x.useRef(null),Ke=x.useRef(null),rt=x.useId(),Ve=x.useRef(null),nt=iA({items:f.items,scope:JSON.stringify([t.workspaceKey,h]),connection:d,loading:!!t.loading,active:M==="chat",approvalCount:t.approvals.length});x.useLayoutEffect(()=>{const Z=G.current;Z&&(M!=="chat"||Ge||Z.workspace!==t.workspaceKey?(G.current=null,P.finish(Z.request,null)):h===Z.id&&(G.current=null,P.finish(Z.request,nt.listRef.current)))},[h,t.workspaceKey,P,nt.listRef,Ge,M]),x.useEffect(()=>{W(void 0),te(Z=>Z==="panel"?"panels":Z)},[t.workspaceKey]),x.useLayoutEffect(()=>{if(De)return;const Z=Ke.current;Ke.current=null;const Te=document.activeElement;Z&&!Z.cancelled&&Z.workspace===t.workspaceKey&&Ge&&!De&&!$&&(Te===Z.source||Te===document.body||!Te?.isConnected)&&dt.current?.focus()},[Ge,De,$,t.workspaceKey]),x.useEffect(()=>{const Z=window.matchMedia("(max-width: 760px)"),Te=()=>{const Ye=document.activeElement;Ke.current=Z.matches&&Ye instanceof HTMLElement&&ht.current?.contains(Ye)?{source:Ye,workspace:t.workspaceKey,cancelled:!1}:null,lt(Z.matches),Oe(!Z.matches)},V=Ye=>{const Ct=Ye instanceof FocusEvent&&Ye.type==="focusout"?Ye.relatedTarget:Ye.target;if(!(Ct instanceof Node)||Ct===document.body&&Ye.type!=="pointerdown"||Ye.type==="pointerdown"&&Ct===at.current)return;if(Ye.type==="focusin"&&Ct instanceof HTMLElement&&ht.current?.contains(Ct)){Ke.current={source:Ct,workspace:t.workspaceKey,cancelled:!1};return}const he=Ke.current;he&&!he.source.contains(Ct)&&(he.cancelled=!0)},ge=()=>{Ke.current&&(Ke.current.cancelled=!0)};return Z.addEventListener("change",Te),document.addEventListener("pointerdown",V,!0),document.addEventListener("focusin",V,!0),document.addEventListener("focusout",V,!0),window.addEventListener("blur",ge),()=>{Ke.current=null,Z.removeEventListener("change",Te),document.removeEventListener("pointerdown",V,!0),document.removeEventListener("focusin",V,!0),document.removeEventListener("focusout",V,!0),window.removeEventListener("blur",ge)}},[t.workspaceKey]),x.useEffect(()=>{if(!Ge||!De)return;const Z=ht.current;Z?.querySelector("button")?.focus();const Te=V=>{if(!document.querySelector("dialog[open]")){if(V.key==="Escape"&&!V.isComposing)V.preventDefault(),Oe(!1),dt.current?.focus();else if(V.key==="Tab"){const ge=Array.from(Z?.querySelectorAll('button:not(:disabled), select:not(:disabled), input:not(:disabled), textarea:not(:disabled), a[href], summary, [tabindex]:not([tabindex="-1"])')??[]).filter(he=>he.getClientRects().length>0),Ye=ge?.[0],Ct=ge?.[ge.length-1];V.shiftKey&&document.activeElement===Ye?(V.preventDefault(),Ct?.focus()):!V.shiftKey&&document.activeElement===Ct&&(V.preventDefault(),Ye?.focus())}}};return document.addEventListener("keydown",Te),()=>document.removeEventListener("keydown",Te)},[Ge,De]),x.useLayoutEffect(()=>{const Z=Ve.current;!Z||M!=="chat"||(Z.style.height="auto",Z.style.height=`${Math.min(180,Math.max(64,Z.scrollHeight))}px`)},[p,M]);const q=()=>{if(Ge){const Z=document.activeElement;De&&Z instanceof HTMLElement&&Z!==document.body&&(Ke.current={source:Z,workspace:t.workspaceKey,cancelled:!1}),Oe(!1),dt.current?.focus()}},ne=Z=>{if(M==="settings"&&Ce===Z){q();return}Ee(()=>{qe(Z),te("settings"),q()})},Ee=Z=>{fe?Me(()=>Z):Z()},xe=Z=>Ee(()=>{me(Z),oe(Te=>Te+1),te("files"),q()}),ze=x.useRef(xe);ze.current=xe;const Le=x.useCallback(Z=>ze.current(Z),[]);x.useEffect(()=>{if(!fe&&!t.uploadBusy&&!t.hasUnsent)return;const Z=Te=>{Te.preventDefault(),Te.returnValue=""};return window.addEventListener("beforeunload",Z),()=>window.removeEventListener("beforeunload",Z)},[fe,t.uploadBusy,t.hasUnsent]);const se=Z=>Ee(()=>{te("chat"),q(),nt.resume(),Z()}),Re=(Z,Te)=>{G.current&&P.finish(G.current.request,null),G.current=null,Te&&!Ge&&(G.current={request:P.adopt(Te),id:Z,workspace:t.workspaceKey}),se(()=>{t.selectSession(Z)})},Ne=()=>se(t.newSession),Qe=()=>{t.send()&&nt.resume()},Ue=t.stop,bt=t.approvals.filter(Z=>!Z.sessionId||Z.sessionId===h),pt=bt.filter(Z=>!Z.asynchronous),Be=t.approvals.filter(Z=>Z.sessionId&&Z.sessionId!==h),ie=f.items.length===0&&bt.length===0,O=E?.connections.find(Z=>Z.id===E.defaults.text),le=d==="open"?"已连接":d==="connecting"?"连接中":"正在重连",we=M==="chat"?T:M==="files"?"工作区文件":M==="activity"?"执行观测":M==="history"?"历史对话":M==="links"?"Link":M==="panels"||M==="panel"?k&&M==="panel"?k.panel.title["zh-CN"]||k.panel.title.default:"面板":Ce==="skills"?"Skills":"设置";return a.jsxs("div",{className:`shell${De?" sidebar-open":""}`,children:[Ge&&De?a.jsx("div",{ref:at,className:"sidebar-backdrop",onClick:()=>{Oe(!1),dt.current?.focus()},"aria-hidden":"true"}):null,a.jsxs("aside",{id:"workbench-sidebar",ref:ht,className:"rail",hidden:!De,role:Ge?"dialog":void 0,"aria-modal":Ge&&De?!0:void 0,"aria-label":"工作台导航",children:[a.jsxs("div",{className:"rail-head",children:[a.jsx("span",{className:"brand-mark",children:a.jsx(Gt,{name:"brand"})}),a.jsx("strong",{children:"CodeShell"}),a.jsx("span",{className:"hub-badge",children:l?"Cloud":t.host==="desktop"?"Desktop":H?"Hub":"Web"}),a.jsx("button",{className:"icon-button sidebar-close","aria-label":"收起侧栏",onClick:()=>{Oe(!1),dt.current?.focus()},children:a.jsx(Gt,{name:"sidebar"})})]}),a.jsxs("div",{className:"rail-content",role:"region","aria-label":"功能与最近对话",tabIndex:0,children:[a.jsx(Rf,{discover:t.workspaceApi,navigate:Z=>{const Te=()=>window.location.assign(Z);fe||t.hasUnsent||t.uploadBusy?Me(()=>Te):Te()}}),a.jsxs("nav",{className:"workbench-nav","aria-label":"主要功能",children:[r?a.jsxs("button",{className:"nav-button",title:i,onClick:()=>{fe||t.hasUnsent||t.uploadBusy?Me(()=>r):r()},children:[a.jsx(Gt,{name:"folder"}),a.jsx("span",{children:"返回项目列表"})]}):null,a.jsxs("button",{className:"nav-button new-chat-button",onClick:Ne,children:[a.jsx(Gt,{name:"plus"}),a.jsx("span",{children:"新对话"})]}),a.jsxs("button",{className:`nav-button${M==="chat"?" active":""}`,onClick:()=>{Ee(()=>{te("chat"),q()})},"aria-current":M==="chat"?"page":void 0,children:[a.jsx(Gt,{name:"chat"}),a.jsx("span",{children:"对话"})]}),H?a.jsxs(a.Fragment,{children:[a.jsxs("button",{className:`nav-button${M==="activity"?" active":""}`,onClick:()=>Ee(()=>{te("activity"),q()}),"aria-current":M==="activity"?"page":void 0,children:[a.jsx(Gt,{name:"history"}),a.jsx("span",{children:"执行观测"})]}),a.jsxs("button",{className:`nav-button${M==="history"?" active":""}`,onClick:()=>Ee(()=>{te("history"),q()}),"aria-current":M==="history"?"page":void 0,children:[a.jsx(Gt,{name:"history"}),a.jsx("span",{children:"历史对话"})]}),a.jsxs("button",{className:`nav-button${M==="files"?" active":""}`,onClick:()=>xe(),"aria-current":M==="files"?"page":void 0,children:[a.jsx(Gt,{name:"folder"}),a.jsx("span",{children:"文件"})]}),a.jsxs("button",{className:`nav-button${M==="settings"&&Ce==="skills"?" active":""}`,onClick:()=>ne("skills"),"aria-current":M==="settings"&&Ce==="skills"?"page":void 0,children:[a.jsx(Gt,{name:"skills"}),a.jsx("span",{children:"Skills"})]}),a.jsxs("button",{className:`nav-button${M==="panels"||M==="panel"?" active":""}`,onClick:()=>Ee(()=>{te("panels"),q()}),"aria-current":M==="panels"||M==="panel"?"page":void 0,children:[a.jsx(Gt,{name:"panels"}),a.jsx("span",{children:"面板"})]}),a.jsxs("button",{className:`nav-button${M==="links"?" active":""}`,onClick:()=>Ee(()=>{te("links"),q()}),"aria-current":M==="links"?"page":void 0,children:[a.jsx(Gt,{name:"links"}),a.jsx("span",{children:"Link"})]}),a.jsxs("button",{className:`nav-button${M==="settings"&&Ce!=="skills"?" active":""}`,onClick:()=>ne("overview"),"aria-current":M==="settings"&&Ce!=="skills"?"page":void 0,children:[a.jsx(Gt,{name:"settings"}),a.jsx("span",{children:"设置"})]})]}):null]}),a.jsx("div",{className:"rail-section-label",children:"工作区"}),H?a.jsxs("button",{className:"workspace-button",title:N??void 0,onClick:()=>xe(),children:[a.jsx(Gt,{name:"folder"}),a.jsx("span",{children:i??C}),a.jsx(Gt,{name:"chevron"})]}):a.jsxs("div",{className:"workspace-button",title:N??void 0,children:[a.jsx(Gt,{name:"folder"}),a.jsx("span",{children:i??C})]}),a.jsxs("div",{className:"rail-section-label history-label",children:[a.jsx("span",{children:"最近对话"}),a.jsx("span",{children:c.length})]}),t.renderSidebar?.({guard:Ee,conversation:se}),a.jsxs("ul",{className:"sessions","aria-label":"最近对话",children:[L.map(({sessionId:Z,draft:Te})=>a.jsx("li",{children:a.jsxs("button",{className:Z===h&&M==="chat"?"session active":"session",onClick:()=>{Re(Z)},children:[a.jsx("span",{className:"session-title",children:Te.text.trim()||`附件:${Te.files[0]?.name??"新对话"}`}),a.jsx("span",{className:"session-meta",children:"草稿"})]})},`draft-${Z}`)),c.map(Z=>a.jsx("li",{children:a.jsxs("button",{className:Z.sessionId===h&&M==="chat"?"session active":"session",onClick:()=>{Re(Z.sessionId)},"aria-current":Z.sessionId===h&&M==="chat"?"page":void 0,children:[a.jsx("span",{className:"session-title",children:Z.sessionId===h?Z.customTitle||f.title||Z.title||jx(f,Z.sessionId):Z.title||Z.preview?.trim()||Z.sessionId.slice(0,8)}),a.jsxs("span",{className:"session-meta",children:[t.unreadSessionIds?.has(Z.sessionId)&&Z.sessionId!==h?a.jsxs("span",{className:"session-unread","aria-label":"有新消息",children:["●"," "]}):null,B(Z.sessionId)?`${B(Z.sessionId)} 项待审批`:Z.running?"进行中":oA(Z.status),t.showTurnCounts!==!1?a.jsxs("span",{children:[" · ",Z.turnCount," 轮"]}):null]})]})},Z.sessionId)),c.length===0&&L.length===0?a.jsx("li",{className:"empty",children:"开始对话后,记录会保存在这里。"}):null]})]}),a.jsxs("div",{className:"rail-footer",children:[a.jsxs("div",{className:"host-label",children:[a.jsx("span",{className:`dot ${d}`}),a.jsxs("span",{children:[Y,le]})]}),o?o({guard:Ee,conversation:se}):l?a.jsx(ev,{...l}):null,t.host==="hub"&&!l?a.jsxs("button",{className:"account-button",onClick:Z=>{R.current=Z.currentTarget,q(),F(!0)},children:[a.jsx("span",{className:"account-avatar",children:(I?.username||"C").slice(0,1).toUpperCase()}),a.jsxs("span",{className:"account-copy",children:[a.jsx("strong",{children:I?.username||"账号"}),a.jsx("span",{children:"设备与退出"})]}),a.jsx(Gt,{name:"chevron"})]}):null,t.logout?a.jsxs("button",{className:"account-button",onClick:t.logout,children:[a.jsx("span",{className:"account-avatar",children:(t.accountName||"D").slice(0,1)}),a.jsxs("span",{className:"account-copy",children:[a.jsx("strong",{children:t.accountName||"已配对设备"}),a.jsx("span",{children:"退出此设备"})]})]}):null]})]}),a.jsxs("main",{className:"workbench-main",inert:Ge&&De?!0:void 0,children:[a.jsxs("header",{className:"workbench-topbar",children:[a.jsx("button",{ref:dt,className:"icon-button","aria-label":De?"收起侧栏":"展开侧栏","aria-expanded":De,"aria-controls":"workbench-sidebar",onClick:()=>Oe(Z=>!Z),children:a.jsx(Gt,{name:"sidebar"})}),a.jsxs("div",{className:"topbar-context",children:[a.jsx("span",{className:"topbar-project","aria-label":"当前项目",title:i??C,children:i??C}),a.jsx("span",{className:"topbar-title",title:we,children:we})]}),a.jsxs("span",{className:"connection-pill",title:`任务在${Y}工作区执行`,children:[a.jsx("span",{className:`dot ${d}`}),a.jsx("span",{children:Y})]})]}),v?a.jsx("div",{className:"banner",children:v}):null,w?a.jsx("div",{className:"banner",children:w}):null,j?a.jsxs("div",{className:"banner form-error",role:"alert",children:[j,a.jsx("button",{className:"ghost","aria-label":"关闭错误提示",onClick:t.clearError,children:"×"})]}):null,Be.length?a.jsxs("div",{className:"banner",children:["其他会话有待处理审批。",Be.map(Z=>a.jsxs("button",{className:"ghost",onClick:()=>{Re(Z.sessionId)},children:["打开 ",Z.sessionId.slice(0,8)]},Z.id))]}):null,d!=="open"?a.jsxs("div",{className:"banner",children:["连接",d==="connecting"?"中…":"已断开,重连中…"]}):null,M!=="chat"&&bt.length>0?a.jsxs("div",{className:"banner",children:[pt.length?"当前对话需要你的确认。":"当前对话有可稍后回答的问题。",a.jsx("button",{className:"ghost",onClick:()=>Ee(()=>te("chat")),children:"返回对话"})]}):null,a.jsxs("section",{className:`chat${ie?" chat-empty":""}`,hidden:M!=="chat","aria-label":"对话",children:[a.jsxs("div",{className:"message-viewport",children:[a.jsx("div",{className:"messages",id:rt,role:"region","aria-label":"消息列表",tabIndex:0,ref:nt.listRef,onScroll:nt.onScroll,children:a.jsxs("div",{className:"transcript",ref:nt.contentRef,children:[t.chatControls,t.loading?a.jsx("div",{className:"banner",role:"status",children:"正在恢复会话记录…"}):null,f.goal?a.jsxs("div",{className:"banner goal",children:[a.jsx("span",{children:f.goal}),t.goalActions]}):null,f.items.map(Z=>{switch(Z.kind){case"user":return a.jsxs("div",{className:"msg user",children:[Z.text,Z.attachments?.map((Te,V)=>H&&Te.path?a.jsxs("button",{className:"attachment attachment-open",onClick:()=>xe(Te.path),children:["📎 ",Te.name]},V):a.jsxs("span",{className:"attachment",children:["📎 ",Te.name]},V))]},Z.id);case"assistant":return Z.done&&!Z.text&&!Z.reasoning?null:a.jsx("div",{className:"msg assistant",children:a.jsx(Q2,{text:Z.text,reasoning:Z.reasoning,streaming:!Z.done,onOpenFile:H?Le:void 0})},Z.id);case"tool":return a.jsx("div",{className:`msg tool${Z.error?" tool-error":""}`,children:a.jsx(X2,{item:Z,running:J})},Z.id);case"subagent":return a.jsxs("div",{className:"msg info",children:["↳ ",Z.label," · ",Z2(Z.status)]},Z.id);case"system":return a.jsx("div",{className:"msg info",children:Z.text},Z.id);case"system_error":return a.jsx("div",{className:"msg error",children:Z.text},Z.id);default:return null}}),t.approvalContent,ie?a.jsxs("div",{className:"empty-chat",children:[a.jsx("span",{className:"welcome-mark",children:a.jsx(Gt,{name:"brand"})}),a.jsx("h1",{children:"今天想完成什么?"}),a.jsx("p",{children:"从一个问题或想法开始,让 CodeShell 帮你一步步完成。"}),a.jsxs("span",{className:"welcome-workspace",children:[a.jsx(Gt,{name:"folder"}),i??C]})]}):null]})}),nt.showJump&&a.jsxs("button",{type:"button",className:"latest-messages","aria-controls":rt,"aria-label":nt.newOutputCount?`回到最新消息,${nt.newOutputCount>99?"99+":nt.newOutputCount} 条新输出`:"回到最新消息",onClick:nt.jumpToLatest,children:[a.jsx("span",{"aria-hidden":"true",children:"↓"}),"回到最新消息",nt.newOutputCount>0&&a.jsxs("span",{className:"latest-count","aria-hidden":"true",children:[nt.newOutputCount>99?"99+":nt.newOutputCount," 条新输出"]})]}),a.jsx("span",{className:"latest-announcement",role:"status","aria-live":"polite","aria-atomic":"true",children:nt.newOutputCount>0?`${nt.newOutputCount>99?"99+":nt.newOutputCount} 条新输出,可回到最新消息。`:""})]}),t.readOnlyNote?a.jsx("div",{className:"banner",children:t.readOnlyNote}):null,a.jsxs("div",{className:"composer-wrap",children:[a.jsxs("footer",{className:"composer",children:[y.length||b&&t.host==="hub"?a.jsxs("div",{className:"attachments","aria-live":"polite",children:[y.map(Z=>a.jsxs("span",{className:"attachment",children:[a.jsx(Gt,{name:"attachment"}),Z.name,a.jsx("button",{className:"ghost","aria-label":`移除 ${Z.name}`,onClick:()=>{t.removeFile(Z.id)},children:"×"})]},Z.id)),b&&t.host==="hub"?a.jsx("span",{children:"正在上传…"}):null]}):null,a.jsx("textarea",{ref:Ve,"aria-label":"任务内容",value:p,disabled:t.readOnly,rows:2,placeholder:"描述你的任务,或提出一个问题…",onChange:Z=>{t.setDraft(Z.target.value)},onKeyDown:Z=>{!window.matchMedia("(max-width: 760px)").matches&&Z.key==="Enter"&&!Z.shiftKey&&!Z.nativeEvent.isComposing&&(Z.preventDefault(),Qe())}}),a.jsxs("div",{className:"composer-toolbar",children:[H?a.jsxs(a.Fragment,{children:[a.jsx("input",{hidden:!0,multiple:!0,type:"file",accept:t.attachmentAccept,ref:re,onChange:Z=>{const Te=Z.currentTarget;Promise.resolve(t.addFiles(Te.files)).finally(()=>{Te.value=""})}}),a.jsx("button",{className:"icon-button attach-button","aria-label":"添加附件",title:"添加附件",disabled:t.uploadBusy||d!=="open"||t.readOnly,onClick:()=>re.current?.click(),children:a.jsx(Gt,{name:"plus"})}),t.cameraAttachments?a.jsxs(a.Fragment,{children:[a.jsx("input",{hidden:!0,type:"file",accept:"image/*",capture:"environment",ref:be,onChange:Z=>{const Te=Z.currentTarget;Promise.resolve(t.addFiles(Te.files)).finally(()=>{Te.value=""})}}),a.jsx("button",{className:"icon-button attach-button","aria-label":"拍照",title:"拍照",disabled:t.uploadBusy||d!=="open"||t.readOnly,onClick:()=>be.current?.click(),children:a.jsx(Gt,{name:"camera"})})]}):null,a.jsxs("button",{className:"model-button",title:"打开模型设置",onClick:()=>ne("models"),children:[a.jsx("span",{children:O?.model||"配置模型"}),a.jsx(Gt,{name:"chevron"})]})]}):null,a.jsx("span",{className:"composer-run-status",role:"status",children:t.uncertain?"正在核对消息…":b?t.host==="desktop"?"正在发送…":"正在上传附件…":pt.length?"等待你的确认":J?"正在处理…":bt.length?"有可稍后回答的问题":""}),J?a.jsx("button",{className:"stop composer-submit","aria-label":"停止",title:"停止",onClick:Ue,disabled:d!=="open",children:a.jsx(Gt,{name:"stop"})}):a.jsx("button",{className:"send composer-submit","aria-label":"发送",title:"发送",onClick:Qe,disabled:d!=="open"||t.loading||b||t.uncertain||t.readOnly||!p.trim()&&!y.length,children:a.jsx(Gt,{name:"send"})})]})]}),a.jsxs("div",{className:"composer-caption",children:[a.jsxs("span",{children:["任务在",Y,"工作区执行"]}),a.jsx("span",{children:"Enter 发送 · Shift + Enter 换行"})]})]})]}),M==="settings"&&H?a.jsx(Kw,{host:t.host==="desktop"?"desktop":"hub",section:Ce,onSectionChange:ne,onAuthLost:U,onConfigurationChange:()=>{_()},configurationVersion:A,onDirtyChange:ke},`${t.workspaceKey}:settings`):null,M==="files"&&H?a.jsx(nS,{initialPath:ue,openVersion:Q,onAuthLost:U},`${t.workspaceKey}:files`):null,M==="activity"&&H?a.jsx(uS,{sessionTitles:Object.fromEntries(c.map(Z=>[Z.sessionId,Z.customTitle||Z.title||Z.preview?.trim()||Z.sessionId.slice(0,8)])),onAuthLost:U,onOpenSession:Z=>{Re(Z)}},`${t.workspaceKey}:activity`):null,M==="history"&&H?a.jsx(cS,{onAuthLost:U,onOpen:(Z,Te)=>{Re(Z,Te)},onChanged:()=>{X()},version:D,onDirtyChange:ke},`${t.workspaceKey}:history`):null,M==="links"&&H?a.jsx(sj,{onAuthLost:U,onDirtyChange:ke,hostLabel:Y,configurationVersion:A},`${t.workspaceKey}:links`):null,M==="panels"&&H?a.jsx(lj,{onAuthLost:U,onDirtyChange:ke,onChanged:()=>{_()},hostLabel:Y,configurationVersion:A,onOpen:Z=>Ee(()=>{W({panel:Z,workspaceKey:t.workspaceKey}),te("panel"),q()})},`${t.workspaceKey}:panels`):null,M==="panel"&&H&&k?.workspaceKey===t.workspaceKey?a.jsx(vj,{panel:k.panel,sessionId:h,busy:J||b||t.uncertain,onAuthLost:U,onDirtyChange:ke,onClose:()=>Ee(()=>te("panels")),onSubmitPrompt:async Z=>sA(t,{...Z,workspaceKey:k.workspaceKey})},`${t.workspaceKey}:panel:${k.panel.id}:${h}`):null]}),_e?a.jsx(aA,{identity:_e,workspaceKey:t.workspaceKey,onStay:()=>Me(null),onLeave:()=>{const Z=_e;Me(null),ke(!1),Z()}}):null,$&&t.host==="hub"&&!l?a.jsx(pw,{session:I,onClose:()=>F(!1),onAuthLost:U,opener:R.current,fallbackOpener:dt.current}):null]})}function aA({onStay:t,onLeave:r,identity:i,workspaceKey:l}){const o=x.useRef(null),d=x.useRef(null);if(!d.current||d.current.identity!==i){const p=document.activeElement;d.current={identity:i,workspace:l,source:p instanceof HTMLElement&&p!==document.body?p:null,cancelled:!1,returning:!1}}const c=d.current,h=x.useRef(l);h.current=l,x.useLayoutEffect(()=>{c.workspace!==l&&(c.cancelled=!0)},[c,l]),x.useEffect(()=>{const p=o.current;if(!p)return;const y=v=>{const w=v instanceof FocusEvent&&v.type==="focusout"?v.relatedTarget:v.target;if(!(!(w instanceof Node)||w===document.body&&v.type!=="pointerdown")&&(p.contains(w)||(c.cancelled=!0),v instanceof PointerEvent&&w===p)){const j=p.getBoundingClientRect();(v.clientX<j.left||v.clientX>j.right||v.clientY<j.top||v.clientY>j.bottom)&&(c.cancelled=!0)}},b=()=>{c.cancelled=!0};return document.addEventListener("pointerdown",y,!0),document.addEventListener("focusin",y,!0),document.addEventListener("focusout",y,!0),window.addEventListener("blur",b),p.showModal(),()=>{document.removeEventListener("pointerdown",y,!0),document.removeEventListener("focusin",y,!0),document.removeEventListener("focusout",y,!0),window.removeEventListener("blur",b),p.isConnected&&d.current===c&&p.close();const v=document.activeElement;c.returning&&!c.cancelled&&d.current===c&&h.current===c.workspace&&c.source?.isConnected&&!c.source.matches(":disabled")&&(v===document.body||v===c.source||!v?.isConnected)&&c.source.focus()}},[c]);const f=()=>{c.returning=!0,t()};return a.jsxs("dialog",{className:"navigation-prompt",ref:o,"aria-labelledby":"navigation-prompt-title",onCancel:p=>{p.preventDefault(),f()},children:[a.jsx("h2",{id:"navigation-prompt-title",children:"还有未保存的修改"}),a.jsx("p",{children:"离开会丢弃未提交的修改;切换项目还会清除未发送的草稿和附件。已经提交的操作可能仍会完成,请等待结果后再离开。"}),a.jsxs("div",{className:"library-actions",children:[a.jsx("button",{className:"library-button primary",onClick:f,autoFocus:!0,children:"留在此页"}),a.jsx("button",{className:"library-button",onClick:r,children:"放弃修改并离开"})]})]})}function oA(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 Gt({name:t}){const r={panels:a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),a.jsx("path",{d:"M15 3v18M15 10h6"})]}),camera:a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M3 7h4l2-3h6l2 3h4v13H3Z"}),a.jsx("circle",{cx:"12",cy:"13",r:"4"})]}),links:a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M10 13a5 5 0 0 0 7 0l3-3a5 5 0 0 0-7-7l-2 2"}),a.jsx("path",{d:"M14 11a5 5 0 0 0-7 0l-3 3a5 5 0 0 0 7 7l2-2"})]}),brand:a.jsx(a.Fragment,{children:a.jsx("path",{d:"m5 7 5 5-5 5M13 17h6"})}),sidebar:a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),a.jsx("path",{d:"M9 4v16"})]}),plus:a.jsx("path",{d:"M12 5v14M5 12h14"}),chat:a.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:a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),a.jsx("path",{d:"M3 3v5h5M12 7v5l3 2"})]}),skills:a.jsx(a.Fragment,{children:a.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:a.jsxs(a.Fragment,{children:[a.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"}),a.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),folder:a.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:a.jsx("path",{d:"m9 5 7 7-7 7"}),attachment:a.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:a.jsx("path",{d:"M12 19V5m-6 6 6-6 6 6"}),stop:a.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2",fill:"currentColor",stroke:"none"})};return a.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:r[t]})}class lr extends Error{constructor(r,i,l){super(r),this.kind=i,this.code=l,this.name="ProtocolRequestError"}kind;code}const uA=3e4,Bb=800,cA=15e3;class dA{constructor(r){this.url=r}url;ws=null;nextId=1;pending=new Map;notificationHandlers=new Set;stateHandlers=new Set;reconnectDelay=Bb;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 r=new WebSocket(this.url);this.ws=r,this.generation++;const i=new RS(()=>{this.healthProbeId=`web-health-${this.nextId++}`,r.send(JSON.stringify({jsonrpc:"2.0",id:this.healthProbeId,method:"agent/query",params:{type:"sessions"}}))},()=>this.retire(r),uo());this.health=i,this.healthProbeId=void 0,this.resumeRequested=!1,r.onopen=()=>{this.ws!==r||this.closedByUser||(i.connected(),this.resumeRequested=!1,this.reconnectDelay=Bb,this.emitState("open"))},r.onmessage=l=>{if(this.ws!==r||this.closedByUser)return;let o;try{if(o=JSON.parse(String(l.data)),!o||typeof o!="object"||Array.isArray(o))return}catch{return}if(o.id===this.healthProbeId&&o.method===void 0&&(Object.hasOwn(o,"result")||Object.hasOwn(o,"error"))&&(this.healthProbeId=void 0,i.received()&&this.resumeRequested)){this.resumeRequested=!1;for(const c of this.resyncHandlers)c()}if(o.id!==void 0&&o.method===void 0){const d=this.pending.get(String(o.id));if(!d)return;this.pending.delete(String(o.id)),clearTimeout(d.timer),o.error?d.reject(new lr(o.error.message??"request failed","response",o.error.code)):d.resolve(o.result);return}if(o.method)for(const d of this.notificationHandlers)d(o.method,o.params??{})},r.onclose=l=>{if(this.ws===r){if(l.code===4401||l.code===4403){this.closedByUser=!0;for(const o of this.authHandlers)o();this.removePageListeners?.(),this.removePageListeners=void 0}this.retire(r)}},r.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 r=this.ws;this.ws=null,r&&(r.onopen=r.onmessage=r.onclose=r.onerror=null),r?.close(),this.failAllPending(new lr("connection closed","transport"))}onNotification(r){return this.notificationHandlers.add(r),()=>this.notificationHandlers.delete(r)}onStateChange(r){return this.stateHandlers.add(r),()=>this.stateHandlers.delete(r)}onAuthLost(r){return this.authHandlers.add(r),()=>this.authHandlers.delete(r)}onResync(r){return this.resyncHandlers.add(r),()=>this.resyncHandlers.delete(r)}get connectionGeneration(){return this.generation}reconnect(){!this.closedByUser&&this.ws&&this.retire(this.ws)}approvalSnapshot(){return this.request("serve/approval.snapshot",{})}retire(r){if(this.ws===r){this.generation++,this.ws=null,this.health?.stop(),this.health=void 0,this.healthProbeId=void 0,this.resumeRequested=!1,r.onopen=r.onmessage=r.onclose=r.onerror=null,this.emitState("closed"),this.failAllPending(new lr("connection closed","transport"));try{r.close()}catch{}!this.closedByUser&&!uo()&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>this.openSocket(),this.reconnectDelay),this.reconnectDelay=Math.min(this.reconnectDelay*2,cA))}}installPageListeners(){if(this.removePageListeners||typeof window>"u")return;const r=()=>{this.closedByUser||uo()||(this.ws?(this.resumeRequested=!0,this.health?.resume()):(clearTimeout(this.reconnectTimer),this.openSocket()))},i=()=>{uo()?(this.health?.pause(),this.healthProbeId=void 0,this.resumeRequested=!1,clearTimeout(this.reconnectTimer)):r()};window.addEventListener("online",r),window.addEventListener("focus",r),window.addEventListener("pageshow",r),typeof document<"u"&&document.addEventListener("visibilitychange",i),this.removePageListeners=()=>{window.removeEventListener("online",r),window.removeEventListener("focus",r),window.removeEventListener("pageshow",r),typeof document<"u"&&document.removeEventListener("visibilitychange",i)}}request(r,i,l=uA){const o=this.ws;if(!o||o.readyState!==WebSocket.OPEN)return Promise.reject(new lr("not connected","not-sent"));const d=`web-${this.nextId++}`;return new Promise((c,h)=>{const f=l>0?setTimeout(()=>{this.pending.delete(d),h(new lr(`request timed out: ${r}`,"timeout"))},l):void 0;this.pending.set(d,{resolve:c,reject:h,timer:f});try{o.send(JSON.stringify({jsonrpc:"2.0",id:d,method:r,params:i}))}catch(p){clearTimeout(f),this.pending.delete(d),h(new lr(p instanceof Error?p.message:"send failed","not-sent"))}})}run(r){return this.request("agent/run",r,0)}listSessions(){return this.request("agent/query",{type:"sessions"})}sessionDetail(r,i=!1){return this.request("agent/query",{type:"session_detail",sessionId:r,...i?{outputRecovery:!0}:{}})}outputCoverage(r){return this.request("agent/query",{type:"output_coverage",sessionId:r})}outputJournal(r,i={}){return this.request("agent/query",{type:"output_journal",sessionId:r,...i})}approve(r,i,l){return this.request("agent/approve",{sessionId:r.sessionId??"",...r.connectionId?{connectionId:r.connectionId}:{},...r.generation!==void 0?{generation:r.generation}:{},requestId:r.requestId,decision:i?{approved:!0,...l?{answer:l}:{}}:{approved:!1}})}cancel(r){return this.request("agent/cancel",{sessionId:r})}emitState(r){for(const i of this.stateHandlers)i(r)}failAllPending(r){for(const[,i]of this.pending)clearTimeout(i.timer),i.reject(r);this.pending.clear()}}function fA(){return`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}${Dt("/ws")}`}function hA(t,r){const{method:i,params:l}=r;if(i==="serve/approvalSnapshot"){if(!Array.isArray(l.approvals))return t;const d={};for(const c of l.approvals)c?.requestId&&c.request&&(d[c.requestId]={payload:c});return d}if(i==="agent/approvalRequest"){const d=l;return!d.requestId||!d.request?t:{...t,[d.requestId]:{...t[d.requestId],payload:d}}}const o=l.requestId;if(typeof o!="string"||!t[o])return t;if(i==="agent/approvalResolved"){const d={...t};return delete d[o],d}return i==="serve/approvalLease"?{...t,[o]:{...t[o],lease:l}}:t}class pA{drafts=new Map;settled=new WeakSet;get(r){return this.drafts.get(r)??{text:"",files:[],revision:0}}update(r,i){const l={...i,revision:this.get(r).revision+1};return this.drafts.set(r,l),l}setText(r,i){return this.update(r,{...this.get(r),text:i})}addFile(r,i){const l=this.get(r);return this.update(r,{...l,files:[...l.files,i]})}removeFile(r,i){const l=this.get(r);return this.update(r,{...l,files:l.files.filter(o=>o.id!==i)})}take(r){const i=this.get(r),l=this.update(r,{text:"",files:[]});return{sessionId:r,draft:i,clearedRevision:l.revision}}restore(r){if(this.settled.has(r))return!1;this.settled.add(r);const i=this.get(r.sessionId),{draft:l}=r;if(!i.text&&!i.files.length)return this.update(r.sessionId,{text:l.text,files:l.files}),"restored";const o=new Set(l.files.map(d=>d.id));return this.update(r.sessionId,{text:l.text?i.text?`${l.text}
|
|
74
|
+
|
|
75
|
+
${i.text}`:l.text:i.text,files:[...l.files,...i.files.filter(d=>!o.has(d.id))]}),"merged"}unsent(){return[...this.drafts].flatMap(([r,i])=>i.text.trim()||i.files.length?[{sessionId:r,draft:i}]:[])}}function mA({payload:t,onDecide:r,busy:i,connected:l,hidden:o}){const[d,c]=x.useState(""),[h,f]=x.useState([]),p=t.request.toolName==="__ask_user__",y=(Array.isArray(t.request.args.options)?t.request.args.options:[]).flatMap(E=>typeof E=="string"&&E.trim()?[{label:E}]:E&&typeof E=="object"&&typeof E.label=="string"&&E.label.trim()?[{label:E.label,description:typeof E.description=="string"?E.description:void 0}]:[]),b=y.length>0&&t.request.args.optionsOnly===!0,v=y.length>0&&t.request.args.multiSelect===!0,w=d.trim()?`${y.length?"Other: ":""}${d.trim()}`:"",j=v?[...y.filter((E,A)=>h.includes(A)).map(E=>E.label),...!b&&w?[w]:[]].join(", "):w,{summary:N,risk:C}=jS(t.request.args,t.request.riskLevel,t.request.toolName);return a.jsxs("div",{className:"approval",hidden:o,children:[a.jsxs("div",{className:"approval-title",children:[p?"Agent 提问":`工具审批:${t.request.toolName}`,p?null:a.jsxs("em",{children:[" · ",C]})]}),t.request.description?a.jsx("div",{className:"approval-desc",children:t.request.description}):null,p?null:a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"approval-summary",children:N}),a.jsxs("details",{className:"approval-raw",children:[a.jsx("summary",{children:"原始参数"}),a.jsx("pre",{className:"approval-args",children:JSON.stringify(t.request.args,null,2)})]})]}),p?a.jsxs(a.Fragment,{children:[t.request.args.asynchronous===!0?a.jsx("span",{className:"muted",children:"可以稍后回答,任务会继续处理。"}):null,y.length?a.jsx("div",{className:"approval-options",role:"group","aria-label":"回答选项",children:y.map((E,A)=>v?a.jsxs("label",{className:"approval-option",children:[a.jsx("input",{type:"checkbox",checked:h.includes(A),disabled:i||!l,onChange:D=>{const L=D.currentTarget.checked;f(J=>L?[...J,A]:J.filter(T=>T!==A))}}),a.jsxs("span",{children:[a.jsx("span",{children:E.label}),E.description?a.jsx("span",{className:"approval-option-description",children:E.description}):null]})]},`${E.label}:${A}`):a.jsxs("button",{className:"approval-option",disabled:i||!l,onClick:()=>r(t,!0,E.label),children:[a.jsx("span",{children:E.label}),E.description?a.jsx("span",{className:"approval-option-description",children:E.description}):null]},`${E.label}:${A}`))}):null,b?null:a.jsx("textarea",{className:"approval-answer","aria-label":"自定义回答",value:d,placeholder:"输入回答…",onChange:E=>c(E.target.value)})]}):null,i?a.jsx("span",{className:"muted",role:"status",children:"设备正在处理此审批…"}):null,a.jsxs("div",{className:"approval-actions",children:[!p||!b||v?a.jsx("button",{className:"send",disabled:i||!l||p&&!j,onClick:()=>r(t,!0,p?j:void 0),children:p?"回答":"允许"}):null,a.jsx("button",{className:"stop",disabled:i||!l,onClick:()=>r(t,!1),children:"拒绝"})]})]})}function qb(){return ql()}const gA=()=>{},yA=async()=>{};function Jd(t){return t.request.toolName==="__ask_user__"&&t.request.args.asynchronous===!0}function bA({session:t,hub:r=!1,onAuthLost:i=gA,onCheckAuth:l=yA}){const o=x.useRef(null),[d,c]=x.useState("connecting"),[h,f]=x.useState([]),p=x.useRef([]),[y,b]=x.useState(()=>J2(window.location.search)??qb()),[v,w]=x.useState(vo()),[j,N]=x.useState(null),[C,E]=x.useReducer(hA,{}),[A,D]=x.useState({}),[L,J]=x.useState(""),[T,B]=x.useState([]),U=x.useRef(new pA),[X,_]=x.useState(0),[I,H]=x.useState(null),Y=I===y,[$,F]=x.useState(null),[P,G]=x.useState(null),[re,be]=x.useState(()=>new Map),[R,M]=x.useState(Date.now()),[te,k]=x.useState(0),[W,ue]=x.useState(null),[me,Q]=x.useState(0),oe=x.useRef(0),fe=x.useRef(0),ke=x.useRef(y),_e=x.useCallback((he,Ie=ke.current)=>{be(Pe=>{if((Pe.get(Ie)??"")===he)return Pe;const ot=new Map(Pe);return he?ot.set(Ie,he):ot.delete(Ie),ot})},[]),Me=re.get(y)??"",Ce=x.useRef(null),qe=x.useRef(null),Ge=x.useRef(!1),lt=x.useRef(new Map),De=x.useRef(new Map),Oe=x.useRef(new Set),ht=x.useRef(new Set),at=x.useRef(new Set),dt=x.useRef(new Set),Ke=x.useRef(0),rt=x.useRef(!1),Ve=x.useRef(null),nt=x.useRef(new Map),q=x.useRef(null),ne=x.useCallback(he=>{if(_(Pe=>Pe+1),ke.current!==he)return;const Ie=U.current.get(he);J(Ie.text),B(Ie.files)},[]);x.useEffect(()=>{const he=new URL(window.location.href);he.searchParams.set("session",y),window.history.replaceState(window.history.state,"",he)},[y]);const Ee=x.useCallback((he,Ie)=>{const Pe=U.current.restore(he.draft);ne(he.draft.sessionId),Pe&&_e(`${Ie?`${Ie} `:"消息未送达。"}${Pe==="merged"?"原内容和附件已放回输入框,之后输入的内容也已保留。":"内容和附件已恢复,可以重试。"}`,he.draft.sessionId),ke.current===he.draft.sessionId&&w(ot=>({...ot,run:"error",items:ot.items.filter(Fe=>Fe.kind!=="user"||Fe.clientMessageId!==he.clientMessageId)}))},[ne,_e]),xe=x.useCallback((he,Ie=ke.current)=>{rt.current&&(he instanceof it&&he.status===401?i():_e(he instanceof Error?he.message:"操作失败,请重试。",Ie))},[i,_e]),ze=x.useCallback(async()=>{if(!r||!rt.current)return;const he=++oe.current;try{const Ie=await tv();rt.current&&he===oe.current&&ue(Ie)}catch(Ie){rt.current&&Ie instanceof it&&Ie.status===401&&i()}},[r,i]),Le=x.useCallback(async()=>{const he=o.current;if(!he)return;const Ie=++fe.current;try{const Pe=r?(await lf()).sessions:(await he.listSessions()).data;if(o.current===he&&rt.current&&Ie===fe.current){const ot=[...Pe].sort((Fe,At)=>(At.lastActiveAt??At.startedAt)-(Fe.lastActiveAt??Fe.startedAt));p.current=ot,f(ot)}}catch(Pe){o.current===he&&rt.current&&(Ie===fe.current||Pe instanceof it&&Pe.status===401)&&xe(Pe)}},[xe,r]),se=x.useCallback(async()=>{const he=o.current;if(he)for(const[Ie,Pe]of De.current)try{const ot=await he.sessionDetail(Ie);if(!rt.current||he!==o.current||De.current.get(Ie)!==Pe)continue;Lb(ot.data).chat.items.some(Xt=>Xt.kind==="user"&&Xt.clientMessageId===Pe.clientMessageId)?(De.current.delete(Ie),_(Xt=>Xt+1)):ot.data.running||(De.current.delete(Ie),Ee(Pe))}catch(ot){if(!rt.current||he!==o.current||De.current.get(Ie)!==Pe)continue;ot instanceof lr&&ot.kind==="response"&&ot.code===-32001&&ot.message===`Session not found: ${Ie}`&&(De.current.delete(Ie),Ee(Pe))}},[Ee]),Re=x.useCallback(async he=>{const Ie=o.current;if(!Ie)return;const Pe={sessionId:he,events:[],bytes:0};q.current=Pe,N(he);try{const ot=await Ie.sessionDetail(he,!0);if(!rt.current||q.current!==Pe||ke.current!==he)return;let Fe=Pe.running??ot.data.running;Fe?at.current.add(he):Fe===!1&&at.current.delete(he);let At,Xt=null,Rt=!1,st=!1;try{const xt=await W2(ot.data,async ut=>(await Ie.outputJournal(he,ut)).data,Pe.events,()=>Pe.latestOutputCursor,ot.data.outputCoverage?async()=>(await Ie.outputCoverage(he)).data:void 0,()=>rt.current&&q.current===Pe&&ke.current===he);xt&&(At=xt.chat,Xt=xt.outputCursor,Rt=!0)}catch(xt){st=!(!ot.data.outputJournal&&xt instanceof lr&&xt.kind==="response"&&xt.code===-32602&&xt.message==="Unknown query type: output_journal")}if(!rt.current||q.current!==Pe||ke.current!==he)return;const yt=Lb(ot.data,Pe.events),et=At??yt.chat;qe.current=Xt,Fe=Pe.running??ot.data.running,Ge.current=st,st||(Ce.current=yt.cursor??null),G(st?"部分运行记录无法验证,已保留当前可见内容。请修复会话记录后重试。":!Rt&&(yt.truncated||Pe.overflow)?"这次运行的实时记录较长,已恢复已保存的内容;结束后重新打开可查看完整记录。":null),Fe||Oe.current.has(he)?et.run="running":Fe===!1&&(et.run==="running"||et.run==="waiting")&&(et.run="idle"),w(xt=>st?xt:et)}catch(ot){q.current===Pe&&ke.current===he&&xe(ot)}finally{q.current===Pe&&(q.current=null,rt.current&&N(null))}},[xe]);x.useEffect(()=>{rt.current=!0;const he=new dA(fA());o.current=he;const Ie=he.onAuthLost(i);let Pe;const ot=()=>{if(!r||Pe)return;const st=he.connectionGeneration,yt=Ke.current,et=()=>rt.current&&o.current===he&&he.connectionGeneration===st,xt=he.approvalSnapshot().then(ut=>{if(!(!et()||Ke.current!==yt)){if(!ut||!Array.isArray(ut.approvals)||ut.approvals.length>256||!Array.isArray(ut.leases)||ut.leases.length>256)throw new Error("审批恢复快照无效,请重试。");Ke.current++,E({method:"serve/approvalSnapshot",params:{approvals:ut.approvals}});for(const _i of ut.leases)E({method:"serve/approvalLease",params:{..._i}})}}).catch(ut=>{et()&&(ut instanceof lr&&ut.kind==="response"&&ut.code===-32601?he.reconnect():xe(ut))}).finally(()=>{Pe===xt&&(Pe=void 0)});Pe=xt},Fe=()=>{F(null),_e(""),Le().then(()=>{const st=ke.current;rt.current&&o.current===he&&(p.current.some(yt=>yt.sessionId===st)||at.current.has(st)||Oe.current.has(st)||De.current.has(st))&&Re(st)}),ze(),se()},At=he.onResync(()=>{Fe(),ot()}),Xt=he.onStateChange(st=>{c(st),st==="open"?Fe():st==="closed"&&(r&&l(),w(yt=>({...yt,run:"idle"})))}),Rt=he.onNotification((st,yt)=>{if(st==="serve/sessionsChanged"){Le(),k(et=>et+1);return}if(st==="agent/runAccepted"&&typeof yt.sessionId=="string"){const et=lt.current.get(yt.sessionId);et&&(et.accepted=!0);return}if(st==="serve/configurationChanged"){ze(),Q(et=>et+1);return}if(st==="agent/streamEvent"){const et=yt,{sessionId:xt,event:ut}=et;ut.type==="session_title"&&(Le(),k(un=>un+1));const _i=lt.current.get(xt);if(_i&&["stream_request_start","text_delta","thinking_delta","tool_use_start"].includes(String(ut.type))&&(_i.accepted=!0),xt===ke.current){if(q.current?.sessionId===xt){const un=q.current;typeof ut.outputCursor=="string"&&(un.latestOutputCursor=ut.outputCursor);const $l=new TextEncoder().encode(JSON.stringify(et)).length;for(un.events.push(et),un.bytes+=$l;un.events.length>2048||un.bytes>8*1024*1024;){const zr=un.events.shift();zr&&(un.bytes-=new TextEncoder().encode(JSON.stringify(zr)).length),un.overflow=!0}}if(Ge.current&&ut.type!=="session_title")return;if(typeof ut.outputCursor=="string"&&qe.current){const un=Rl(ut.outputCursor,qe.current);if(un===void 0){Re(xt);return}if(un<=0)return;qe.current=ut.outputCursor}if(!Sx(et,Ce.current))return;et.hubEpoch&&et.hubSequence!==void 0&&(Ce.current={epoch:et.hubEpoch,sequence:et.hubSequence}),w(un=>ki(un,ut))}ut.type==="stream_request_start"&&F(null),ut.type==="turn_complete"&&Le();return}if(st==="serve/sessionStatus"){k(ut=>ut+1);const{sessionId:et,running:xt}=yt;if(typeof et!="string"||typeof xt!="boolean")return;q.current?.sessionId===et&&(q.current.running=xt),xt?at.current.add(et):at.current.delete(et),!xt&&De.current.has(et)&&se(),et===ke.current&&w(ut=>xt?{...ut,run:"running"}:ut.run==="running"||ut.run==="waiting"?{...ut,run:"idle"}:ut),Le();return}if(st==="agent/approvalRequest"||st==="agent/approvalResolved"||st==="serve/approvalSnapshot"||st==="serve/approvalLease"){Ke.current++,E({method:st,params:yt});return}if(st==="serve/workerExit"){at.current.clear();const et=yt.clean;F(et?"服务进程已退出,发送消息会自动重启":"服务进程异常退出,发送消息会自动重启"),w(xt=>({...xt,run:"idle"}))}});return he.connect(),()=>{rt.current=!1,Ve.current?.abort(),Xt(),At(),Rt(),Ie(),he.close(),o.current=null}},[Le,Re,ze,se,i,l,r,xe]);const Ne=Object.values(C).some(he=>he.lease?.holderId&&(he.lease.expiresAt??0)>R);x.useEffect(()=>{if(!Ne)return;M(Date.now());const he=setInterval(()=>M(Date.now()),1e3);return()=>clearInterval(he)},[Ne]);const Qe=async he=>{ke.current=he,Ce.current=null,qe.current=null,Ge.current=!1,b(he),ne(he),w(vo()),G(null),!(!h.some(Ie=>Ie.sessionId===he)&&!at.current.has(he)&&U.current.unsent().some(Ie=>Ie.sessionId===he))&&await Re(he)},Ue=()=>{const he=qb();ke.current=he,Ce.current=null,qe.current=null,Ge.current=!1,q.current=null,N(null),b(he),ne(he),w(vo()),_e(""),G(null)},bt=he=>{const Ie=U.current.get(ke.current),Pe=Ie.text.trim(),ot=o.current;if(!Pe&&!Ie.files.length||!ot||d!=="open"||Y)return!1;const Fe=ke.current;if(q.current?.sessionId===Fe||Oe.current.has(Fe)||at.current.has(Fe)||v.run==="running"||v.run==="waiting"||Object.values(C).some(Rt=>(!Rt.payload.sessionId||Rt.payload.sessionId===Fe)&&!Jd(Rt.payload))||De.current.has(Fe))return!1;ke.current=Fe,b(Fe),Oe.current.add(Fe);const At={clientMessageId:ql(),draft:U.current.take(Fe),accepted:!1};lt.current.set(Fe,At);const Xt=At.draft.draft.files;return ne(Fe),_e(""),w(Rt=>({...mS(Rt,Pe,Xt.map(st=>({name:st.name,mime:st.mimeType,size:st.size})),At.clientMessageId),run:"running"})),ot.run({sessionId:Fe,task:Pe,...he?.modelTraceSource?{modelTraceSource:he.modelTraceSource}:{},clientMessageId:At.clientMessageId,displayText:Pe,...Xt.length?{uploadIds:Xt.map(Rt=>Rt.id)}:{}}).catch(Rt=>{rt.current&&(xe(Rt,Fe),Rt instanceof lr&&(Rt.kind==="transport"||Rt.kind==="timeout")?(De.current.set(Fe,At),_e("连接中断,重新连接后会核对这条消息是否已经送达。",Fe)):At.accepted||Ee(At,Rt instanceof Error?Rt.message==="upload not found or expired"?"附件已失效,请移除后重新上传。":Rt.message:void 0),ke.current===Fe&&w(st=>({...st,run:"error"})))}).finally(()=>{Oe.current.delete(Fe),lt.current.get(Fe)===At&<.current.delete(Fe),rt.current&&ke.current===Fe&&!at.current.has(Fe)&&w(Rt=>Rt.run==="running"?{...Rt,run:"idle"}:Rt)}),!0},pt=(he,Ie,Pe)=>{const ot=o.current;if(!ot||d!=="open"||dt.current.has(he.requestId))return;const Fe=he.sessionId??ke.current;Ke.current++,dt.current.add(he.requestId),D(At=>({...At,[he.requestId]:!0})),_e(""),ot.approve({...he,sessionId:he.sessionId??ke.current??""},Ie,Pe).then(()=>E({method:"agent/approvalResolved",params:{requestId:he.requestId}})).catch(At=>xe(At,Fe)).finally(()=>{dt.current.delete(he.requestId),D(At=>{const Xt={...At};return delete Xt[he.requestId],Xt})})},Be=()=>{const he=ke.current,Ie=o.current;!Ie||d!=="open"||ht.current.has(he)||(ht.current.add(he),_e("",he),Ie.cancel(he).catch(Pe=>xe(Pe,he)).finally(()=>ht.current.delete(he)))},ie=async he=>{if(!he?.length||Ve.current)return;const Ie=new AbortController,Pe=Cs();Ve.current=Ie,H(ke.current),_e("");const ot=ke.current;try{for(const Fe of Array.from(he)){if(!rt.current||Ie.signal.aborted)break;const At=await $1(Fe,{signal:Ie.signal,scope:Pe});rt.current&&!Ie.signal.aborted&&(nt.current.set(At.id,Pe),U.current.addFile(ot,At),ne(ot))}}catch(Fe){xe(Fe,ot)}finally{Ve.current===Ie&&(Ve.current=null),rt.current&&H(null)}},O=Object.values(C).filter(he=>!he.payload.sessionId||he.payload.sessionId===y),le=he=>Object.values(C).filter(Ie=>Ie.payload.sessionId===he).length,we=v.run==="running"||v.run==="waiting"||O.some(he=>!Jd(he.payload)),Z=x.useMemo(()=>U.current.unsent().filter(he=>!h.some(Ie=>Ie.sessionId===he.sessionId)),[X,h]),Te=W?.workspace.path??h.find(he=>he.sessionId===y)?.cwd??h[0]?.cwd??null,V=Te?.split(/[\\/]/).filter(Boolean).pop()??"服务端工作区",ge=v.items.length===0&&O.length===0,Ye=h.find(he=>he.sessionId===y),Ct=ge?"新对话":Ye?.customTitle||v.title||Ye?.title||Ye?.preview?.trim()||jx(v,y??"新对话");return{host:r?"hub":"legacy",workspaceApi:r,connection:d,session:t,activeId:y,loading:j===y,chat:v,sessions:h,workspaceCwd:Te,workspaceName:V,title:Ct,workspaceKey:Te??"hub",configuration:W,configurationVersion:me,sessionsVersion:te,draft:L,files:T,uploading:Y,uploadBusy:I!==null,hasUnsent:U.current.unsent().length>0||De.current.size>0,localDrafts:Z,uncertain:De.current.has(y),running:we,approvals:Object.values(C).map(he=>({id:he.payload.requestId,sessionId:he.payload.sessionId,...Jd(he.payload)?{asynchronous:!0}:{}})),approvalCount:le,approvalContent:Object.values(C).map(he=>a.jsx(mA,{payload:he.payload,hidden:!!he.payload.sessionId&&he.payload.sessionId!==y,onDecide:pt,busy:!!A[he.payload.requestId]||!!(he.lease?.holderId&&(he.lease.expiresAt??0)>R),connected:d==="open"},he.payload.requestId)),workerNote:$,replayNote:P,error:Me,clearError:()=>_e(""),setDraft:he=>{U.current.setText(ke.current,he),ne(ke.current)},removeFile:he=>{U.current.removeFile(ke.current,he),ne(ke.current);const Ie=nt.current.get(he);nt.current.delete(he),G1(he,Ie).catch(()=>{})},selectSession:Qe,newSession:Ue,send:bt,stop:Be,addFiles:ie,refreshSessions:Le,refreshConfiguration:ze,onAuthLost:i}}function Sf({onBackToProjects:t,projectName:r,cloudAccount:i,renderAccountControl:l,...o}){return a.jsx(lA,{controller:bA(o),onBackToProjects:t,projectName:r,cloudAccount:i,renderAccountControl:l})}function jf(t){if(!t||typeof t!="object")return!1;const r=t;return Es(r.id)&&typeof r.name=="string"&&r.name.length>0&&["stopped","starting","running","stopping","error"].includes(r.status)&&Number.isSafeInteger(r.generation)&&r.generation>=0&&Number.isSafeInteger(r.createdAt)&&r.createdAt>=0&&(r.error===void 0||typeof r.error=="string")}function vA(t){const r=t;if(!r||r.runtime!=="docker"||typeof r.available!="boolean"||!Array.isArray(r.projects)||!r.projects.every(jf)||new Set(r.projects.map(i=>i.id)).size!==r.projects.length||r.error!==void 0&&typeof r.error!="string")throw new Error("服务端返回了无效的项目列表,请重试。");return r}function Ub(){return new URL(window.location.href).searchParams.get("project")}function ws(t,r=!1){const i=new URL(window.location.href);t?i.searchParams.set("project",t):i.searchParams.delete("project"),r||i.searchParams.delete("session"),window.history.replaceState(window.history.state,"",i)}const xA={stopped:"已停止",starting:"正在启动",running:"运行中",stopping:"正在停止",error:"启动失败"};function Ex({children:t,onAuthLost:r,accountControl:i,allowLegacy:l=!0,autoEnterSingle:o=!1,startCreatedProject:d=!1,canRequest:c}){const[h,f]=x.useState(null),[p,y]=x.useState(!1),[b,v]=x.useState(null),[w,j]=x.useState(""),[N,C]=x.useState(!0),[E,A]=x.useState(null),[D,L]=x.useState(""),[J,T]=x.useState(null),B=x.useRef(null),U=x.useRef(Ub()),X=x.useRef(b),_=x.useRef(h),I=x.useRef(0),H=x.useRef(0),Y=x.useRef(null),$=x.useRef(r),F=x.useRef(!1),P=x.useRef(!0),G=x.useRef(c);G.current=c,$.current=r,X.current=b,_.current=h;const re=x.useCallback(k=>{if(k.status!=="running")return;const W=Ub()===k.id;io(),ro(k.id),ws(k.id,W),U.current=null,P.current=!1,X.current=k,v(k),j("")},[]),be=x.useCallback(()=>{U.current=null,X.current=null,v(null),ro(null),io(),ws(null)},[]),R=x.useCallback(async k=>{if(F.current||G.current&&!G.current())return;const W=++H.current,ue=I.current;try{const me=vA(await Je("/api/v1/projects",{signal:k}));if(k?.aborted||W!==H.current||ue!==I.current)return;f(me),_.current=me,C(!1),j("");const Q=X.current;if(Q){const fe=me.projects.find(ke=>ke.id===Q.id);(!fe||fe.status!=="running"||fe.generation!==Q.generation)&&(be(),j("项目运行状态已经变化,请重新打开项目。未发送的内容不会带入其他项目。"));return}if(!U.current){o&&P.current&&me.available&&me.projects.length===1&&me.projects[0].status==="running"&&re(me.projects[0]);return}const oe=me.projects.find(fe=>fe.id===U.current);oe?oe.status==="running"&&me.available&&re(oe):(P.current=!1,U.current=null,ws(null),j("链接中的项目不存在或当前账号无权访问,请选择一个项目。"))}catch(me){if(k?.aborted||W!==H.current||ue!==I.current)return;C(!1),l&&me instanceof it&&me.status===404&&!_.current?(ro(null),io(),F.current=!0,y(!0)):me instanceof it&&me.status===401?$.current():j(me instanceof Error?me.message:"无法读取项目,请重试。")}},[be,re,l,o]);x.useEffect(()=>{I.current++;const k=new AbortController;R(k.signal);const W=()=>{R(k.signal)},ue=()=>{document.visibilityState==="visible"&&W()};return window.addEventListener("focus",W),document.addEventListener("visibilitychange",ue),()=>{I.current++,k.abort(),Y.current?.abort(),window.removeEventListener("focus",W),document.removeEventListener("visibilitychange",ue),ro(null),io()}},[R]);const M=h?.projects.some(k=>k.status==="starting"||k.status==="stopping");x.useEffect(()=>{if(p||!h)return;const k=new AbortController,W=setInterval(()=>{R(k.signal)},M?2e3:1e4);return()=>{clearInterval(W),k.abort()}},[p,!!h,M,R]),x.useEffect(()=>{if(!J)return;const k=document.activeElement,W=B.current;return W?.showModal?.(),()=>{W?.close?.(),k?.focus()}},[J]);const te=async(k,W)=>{if(G.current&&!G.current()||Y.current||k==="create"&&!D.trim())return;const ue=new AbortController;Y.current=ue,A(W?.id??"create"),j(""),H.current++;try{const me=await Je(k==="create"?"/api/v1/projects":`/api/v1/projects/${W.id}/${k}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k==="create"?{name:D.trim()}:{}),signal:ue.signal});if(ue.signal.aborted)return;if(!jf(me.project)||W&&W.id!==me.project.id)throw new Error("服务端返回了无效的项目状态,请刷新列表。");let Q=me.project;if(k==="create"&&d){const oe=await Je(`/api/v1/projects/${Q.id}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}",signal:ue.signal});if(ue.signal.aborted)return;if(!jf(oe.project)||oe.project.id!==Q.id)throw new Error("服务端返回了无效的项目状态,请刷新列表。");Q=oe.project,U.current=Q.id,ws(Q.id),Q.status==="running"&&re(Q)}f(oe=>oe&&{...oe,projects:oe.projects.some(fe=>fe.id===Q.id)?oe.projects.map(fe=>fe.id===Q.id?Q:fe):[...oe.projects,Q]}),k==="create"&&L(""),k==="start"&&(U.current=Q.id,ws(Q.id),Q.status==="running"&&re(Q)),k==="stop"&&(U.current===Q.id&&(U.current=null,ws(null)),T(null)),await R(ue.signal)}catch(me){if(ue.signal.aborted)return;me instanceof it&&me.status===401?$.current():j(me instanceof Error?me.message:"项目操作失败,请重试。")}finally{Y.current===ue&&(Y.current=null),ue.signal.aborted||A(null)}};return p?a.jsx(x.Fragment,{children:t(null)},"single-project"):b?a.jsxs(x.Fragment,{children:[w?a.jsxs("div",{className:"project-connection-note",role:"status",children:["项目状态暂时无法刷新,当前工作台会保留。",w]}):null,t(b,be)]},`${b.id}:${b.generation}`):a.jsxs("main",{className:"projects-page",children:[a.jsxs("header",{className:"projects-header",children:[a.jsxs("div",{className:"auth-brand",children:["CodeShell ",a.jsx("span",{children:i?"Cloud":"Hub"})]}),a.jsx(Rf,{}),i,a.jsx("h1",{children:"你的项目"}),a.jsx("p",{children:"每个项目有独立的运行环境、文件、会话和配置。启动后进入同一个工作台。"})]}),N?a.jsx("p",{role:"status",children:"正在读取项目…"}):null,w?a.jsxs("div",{className:"form-error",role:"alert",children:[w,a.jsx("button",{className:"library-button",onClick:()=>{R()},children:"刷新项目"})]}):null,h?a.jsxs(a.Fragment,{children:[h.available?null:a.jsx("p",{className:"form-error",role:"alert",children:d?"云端执行环境暂时不可用,请稍后重试或联系管理员。":a.jsxs(a.Fragment,{children:["项目运行环境暂不可用。",h.error||"请检查服务端 Docker 是否已启动。"]})}),a.jsxs("form",{className:"project-create",onSubmit:k=>{k.preventDefault(),te("create")},children:[a.jsxs("label",{children:["新项目名称",a.jsx("input",{value:D,maxLength:80,required:!0,placeholder:"例如:个人网站",onChange:k=>L(k.target.value)})]}),a.jsx("button",{className:"library-button primary",disabled:!!E||!D.trim(),type:"submit",children:E==="create"?"正在创建…":d?"创建并打开":"创建项目"})]}),a.jsxs("section",{className:"projects-grid","aria-label":"项目列表",children:[h.projects.length===0?a.jsx("p",{className:"project-empty",children:"创建第一个项目,开始配置模型、添加技能和使用面板。"}):null,h.projects.map(k=>a.jsxs("article",{className:"project-card",children:[a.jsxs("div",{className:"project-card-heading",children:[a.jsx("h2",{children:k.name}),a.jsx("span",{className:`project-status ${k.status}`,children:xA[k.status]})]}),a.jsxs("p",{className:"project-date",children:["创建于 ",new Date(k.createdAt).toLocaleDateString()]}),k.error?a.jsx("p",{className:"form-error",role:"alert",children:k.error}):null,a.jsxs("div",{className:"library-actions",children:[a.jsx("button",{className:"library-button primary",disabled:!!E||!h.available||k.status==="starting"||k.status==="stopping",onClick:()=>k.status==="running"?re(k):void te("start",k),children:E===k.id||k.status==="starting"||k.status==="stopping"?"正在处理…":k.status==="running"?"打开项目":"启动并打开"}),k.status==="running"?a.jsx("button",{className:"library-button",disabled:!!E,onClick:()=>T(k),children:"停止项目"}):null]})]},k.id))]})]}):null,J?a.jsxs("dialog",{className:"project-stop-confirm",ref:B,role:"alertdialog","aria-modal":"true","aria-labelledby":"project-stop-title",onCancel:k=>{k.preventDefault(),E||T(null)},children:[a.jsxs("h2",{id:"project-stop-title",children:["停止 ",J.name,"?"]}),a.jsx("p",{children:"正在运行的任务和面板进程会中断。项目文件和配置保留,可稍后重新启动。"}),a.jsxs("div",{className:"library-actions",children:[a.jsx("button",{className:"library-button primary",disabled:!!E,onClick:()=>T(null),children:"继续运行"}),a.jsx("button",{className:"library-button",disabled:!!E,onClick:()=>{te("stop",J)},children:"确认停止"})]})]}):null]})}function Hb(t,r){return r?`${r.audience}:${r.installationId}:${r.managementEpoch}:${r.accountOrigin}:${r.accountId}:${r.id}`:t?.id}function wA({setupToken:t}){const[r,i]=x.useState("checking"),[l,o]=x.useState(),[d,c]=x.useState(),[h,f]=x.useState(!1),[p,y]=x.useState(""),[b,v]=x.useState(""),[w,j]=x.useState(""),[N,C]=x.useState(t),[E,A]=x.useState(""),[D,L]=x.useState(!1),[J,T]=x.useState(""),B=x.useRef(!1),U=x.useRef(!1),X=x.useRef(0),_=x.useRef(void 0),[I,H]=x.useState(0),Y=x.useRef(!1),$=x.useRef(!1),F=x.useRef(0),P=x.useRef(r);P.current=r;const G=x.useCallback(k=>{if(!$.current)return;const W=k===null?"legacy":k.authenticated?Hb(k.session,k.cloudSession):void 0;W!==_.current&&(_.current=W,H(++X.current)),Y.current=k?.mode==="cloud-account",f(Y.current),c(k?.cloudSession),o(k?.session),i(k===null?"legacy":k.mode==="cloud-account"?k.authenticated?"authenticated":"cloud-login":k.initialized?k.authenticated?"authenticated":"login":"setup"),L(!1),A(""),k?.initialized&&C("")},[]),re=x.useCallback(()=>{$.current&&(F.current++,_.current=void 0,H(++X.current),o(void 0),c(void 0),i(Y.current?"cloud-login":"login"),v(""),A(Y.current?"Cloud 管理登录已失效,请从桌面 Cloud 管理器重新打开。":"登录已过期或此设备已被撤销,请重新登录。"))},[]),be=x.useMemo(()=>()=>{I===X.current&&re()},[re,I]),R=x.useCallback(async()=>{if(B.current||U.current)return;const k=++F.current;try{const W=await P1();if(k===F.current&&Y.current&&W?.mode!=="cloud-account"){re();return}k===F.current&&G(W)}catch(W){if(!$.current||k!==F.current)return;if(Y.current&&(W instanceof it&&W.status===401||W instanceof Yb)){re();return}if(P.current==="authenticated"||P.current==="legacy")return;i("error"),A(W instanceof Error?W.message:"无法连接服务端")}},[G,re]);x.useEffect(()=>{$.current=!0,R();const k=()=>{R()},W=()=>{document.visibilityState==="visible"&&R()};return window.addEventListener("focus",k),document.addEventListener("visibilitychange",W),()=>{$.current=!1,window.removeEventListener("focus",k),document.removeEventListener("visibilitychange",W)}},[R]),x.useEffect(()=>{if(!d)return;const k=setTimeout(be,Math.max(0,d.expiresAt-Date.now()));return()=>clearTimeout(k)},[d,be]);const M=async()=>{if(B.current||!Y.current)return;B.current=!0;const k=++F.current;L(!0),T("");try{const W=await ef("/api/v1/auth/logout");if(!$.current||k!==F.current)return;if(W.revoked!==!0)throw new Error("Cloud 退出尚未确认。");re(),A("此 Cloud 工作台已退出。请从桌面 Cloud 管理器重新打开。")}catch(W){if(!$.current||k!==F.current)return;W instanceof it&&W.status===401?re():T("未能确认退出此 Cloud 工作台,请重试。也可关闭此页并在桌面撤销登录。")}finally{B.current=!1,$.current&&L(!1)}},te=async k=>{if(k.preventDefault(),D||U.current||Y.current)return;U.current=!0;const W=++F.current;L(!0),A("");try{const ue=await ef(`/api/v1/auth/${r==="setup"?"setup":"login"}`,{username:p.trim(),password:b,deviceName:w.trim()||void 0,...r==="setup"?{token:N.trim()}:{}});if(!$.current||W!==F.current)return;if(!ue.authenticated)throw new Error("登录失败,请重试。");v(""),C(""),G({initialized:!0,authenticated:!0,session:ue.session})}catch(ue){if(!$.current||W!==F.current)return;A(ue instanceof Error?ue.message:"登录失败,请重试。"),ue instanceof it&&ue.status===409&&(U.current=!1,R())}finally{U.current=!1,$.current&&W===F.current&&L(!1)}};if(r==="authenticated"){const k=h?{pending:D,error:J,onLogout:()=>{M()},accountOrigin:d?.accountOrigin}:void 0;return a.jsx(Ex,{onAuthLost:be,allowLegacy:!h,accountControl:k?a.jsx(ev,{...k}):void 0,children:(W,ue)=>a.jsx(Sf,{session:l,hub:!0,onAuthLost:be,onCheckAuth:R,projectName:W?.name,onBackToProjects:ue,cloudAccount:k})},Hb(l,d))}return r==="legacy"?a.jsx(Sf,{session:l,hub:!1,onAuthLost:be,onCheckAuth:R}):a.jsx("main",{className:"auth-page",children:a.jsxs("section",{className:"auth-card",children:[a.jsx(Rf,{discover:!1}),a.jsxs("div",{className:"auth-brand",children:["CodeShell ",a.jsx("span",{children:h?"Cloud":"Hub"})]}),r==="checking"?a.jsx("p",{role:"status",children:"正在连接你的工作空间…"}):null,r==="error"?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"form-error",role:"alert",children:E}),a.jsx("button",{className:"send",onClick:()=>{R()},children:"重试连接"})]}):null,r==="cloud-login"?a.jsxs(a.Fragment,{children:[a.jsx("h1",{children:"请从桌面 Cloud 管理器登录"}),a.jsx("p",{children:"在 CodeShell 桌面端登录云账号,再从 Cloud 管理器打开这个工作台。"}),E?a.jsx("p",{role:"status",children:E}):null,a.jsx("button",{className:"send",onClick:()=>{R()},children:"重新检查 Cloud 登录"})]}):null,r==="setup"||r==="login"?a.jsxs("form",{onSubmit:k=>{te(k)},children:[a.jsx("h1",{children:r==="setup"?"创建管理员账号":"登录工作空间"}),a.jsx("p",{children:r==="setup"?"首次启动需要服务端提供的初始化令牌。创建后,可在其他设备使用此账号登录。":"连接服务端,继续你的会话与任务。"}),r==="setup"?a.jsxs("label",{children:["初始化令牌",a.jsx("input",{type:"password",autoComplete:"off",required:!0,value:N,onChange:k=>C(k.target.value)})]}):null,a.jsxs("label",{children:["用户名",a.jsx("input",{autoComplete:"username",required:!0,maxLength:64,value:p,onChange:k=>y(k.target.value)})]}),a.jsxs("label",{children:["密码",a.jsx("input",{type:"password",autoComplete:r==="setup"?"new-password":"current-password",required:!0,maxLength:256,minLength:r==="setup"?12:void 0,value:b,onChange:k=>v(k.target.value)})]}),r==="setup"?a.jsx("small",{children:"密码至少 12 个字符。"}):null,a.jsxs("label",{children:["设备名称 ",a.jsx("span",{children:"(可选)"}),a.jsx("input",{autoComplete:"off",maxLength:100,placeholder:"例如:我的笔记本",value:w,onChange:k=>j(k.target.value)})]}),E?a.jsx("p",{className:"form-error",role:"alert",children:E}):null,a.jsx("button",{className:"send",type:"submit",disabled:D,children:D?"正在连接…":r==="setup"?"创建并进入":"登录"})]}):null]})})}async function ks(t){const r=globalThis.navigator?.locks;if(!r?.request)throw new Error("浏览器不支持安全的登录会话管理,请使用新版 Chrome、Edge、Firefox 或 Safari。");return await r.request("codeshell:account-web:cookie-v1",{mode:"exclusive"},t)}const Wd="/api/v1/account/web",Il=/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/,So=/^[A-Za-z0-9_-]{43}$/,Pb={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 vt extends Error{constructor(r,i=0,l){super(r),this.status=i,this.code=l}status;code}function yo(t,r,i){const l=t,o=typeof l?.error=="string"?l.error:void 0;if(i==="/github/poll"&&o==="github_login_failed"){if(l?.reason==="provider_timeout")return new vt("服务器连接 GitHub 超时,请重新发起授权。",r,o);if(l?.reason==="provider_unavailable")return new vt("服务器暂时无法访问 GitHub,请稍后重新发起授权。",r,o)}return new vt(o&&Object.hasOwn(Pb,o)?Pb[o]:"操作未完成,请稍后重试。",r,o)}function kf(t){if(typeof t!="string")return!1;try{const r=new URL(t);return r.origin===t&&!r.username&&!r.password&&(r.protocol==="https:"||r.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(r.hostname))}catch{return!1}}function eh(t){const r=t;return!!r&&Il.test(r.id)&&typeof r.username=="string"&&/^[a-z0-9][a-z0-9._-]{2,63}$/i.test(r.username)&&typeof r.displayName=="string"&&[...r.displayName].length>=1&&[...r.displayName].length<=64&&!/[\p{Cc}\p{Cs}]/u.test(r.displayName)&&["member","admin"].includes(r.role)}function th(t){const r=t;return!!r&&kf(r.cloudOrigin)&&kf(r.accountOrigin)&&Il.test(r.installationId)}function sr(t){const r=t,i=r&&{...r,cloudTarget:r.cloudTarget?.enabled===!1?null:r.cloudTarget};if(!i||r.accessToken!==void 0||r.refreshToken!==void 0||typeof i.authenticated!="boolean"||(i.authenticated||i.refreshRequired)&&!So.test(i.csrfToken??"")||!i.authenticated&&typeof i.refreshRequired!="boolean"||i.cloudTarget!==null&&!th(i.cloudTarget)||i.authenticated&&(!eh(i.account)||!i.session||!Il.test(i.session.id)||!Number.isSafeInteger(i.session.expiresAt)||i.session.expiresAt<=Date.now())||!i.authenticated&&(i.account!==void 0||i.session!==void 0))throw new vt("账号服务返回了无效的会话,请刷新后重试。");const l=i.authenticated?Cx(i.overview,i.account.id):void 0;if(l&&l.account.role!==i.account.role)throw new vt("账号服务返回了不一致的权限,请刷新后重试。");return{authenticated:i.authenticated,...typeof i.csrfToken=="string"?{csrfToken:i.csrfToken}:{},...typeof i.refreshRequired=="boolean"?{refreshRequired:i.refreshRequired}:{},cloudTarget:i.cloudTarget?{cloudOrigin:i.cloudTarget.cloudOrigin,accountOrigin:i.cloudTarget.accountOrigin,installationId:i.cloudTarget.installationId}:null,...l?{account:{id:i.account.id,username:i.account.username,displayName:i.account.displayName,role:i.account.role},overview:l,session:{id:i.session.id,expiresAt:i.session.expiresAt}}:{}}}function Cx(t,r){const i=t;if(!i||!eh(i.account)||i.account.id!==r||typeof i.security?.hasPassword!="boolean"||typeof i.security?.githubLinked!="boolean"||![i.capabilities?.sessions,i.capabilities?.passwordChange,i.capabilities?.admin,i.capabilities?.links].every(l=>typeof l=="boolean")||i.capabilities.admin!==(i.account.role==="admin")||![i.stats?.activeSessions,i.stats?.loginMethods].every(l=>Number.isSafeInteger(l)&&l>=0))throw new vt("账号服务返回了无效的资料,请刷新后重试。");return{account:{id:i.account.id,username:i.account.username,displayName:i.account.displayName,role:i.account.role},security:{hasPassword:i.security.hasPassword,githubLinked:i.security.githubLinked},capabilities:{sessions:i.capabilities.sessions,passwordChange:i.capabilities.passwordChange,admin:i.capabilities.admin,links:i.capabilities.links},stats:{activeSessions:i.stats.activeSessions,loginMethods:i.stats.loginMethods}}}class SA{constructor(r=globalThis.fetch.bind(globalThis)){this.fetcher=r}fetcher;epoch=0;csrfToken="";requests=new Set;rootId;onSessionLost;setCsrf(r){this.csrfToken=r}setSession(r){this.rootId!==r.session?.id&&this.invalidate(),this.csrfToken=r.csrfToken??"",this.rootId=r.session?.id}async nativeRequest(r,i,l){if(!/^\/(?:login|register|github\/(?:start|poll|cancel))$/.test(r))throw new vt("登录请求地址无效。");const o=this.epoch,d=AbortSignal.timeout(r==="/github/poll"?2e4:1e4);try{const c=await this.fetcher("/api/v1/account"+r,{method:"POST",credentials:"omit",cache:"no-store",redirect:"error",signal:d,headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}),h=await c.json();if(l?.(h),o!==this.epoch)throw h?.accessToken&&this.revokeTransient(h),new vt("账号状态已改变。");if(!c.ok)throw yo(h,c.status,r);return h}catch(c){throw c instanceof vt?c:new vt(r==="/github/poll"&&(d.aborted||c?.name==="TimeoutError")?"等待 GitHub 登录验证超时,请重新发起授权。":"无法连接账号服务,请检查网络后重试。")}}async revokeTransient(r){So.test(r?.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 "+r.accessToken},body:"{}"}).catch(()=>{})}async exchangeGrant(r,i){const l=this.rootId;if(!So.test(r?.accessToken??"")||!So.test(r?.refreshToken??"")||!Il.test(r?.account?.id??"")||!Il.test(r?.sessionId??"")||!Number.isSafeInteger(r?.accessTokenExpiresAt)||r.accessTokenExpiresAt<=Date.now())throw new vt("登录授权结果无效,请重新发起。");return ks(async()=>{if(!i())throw await this.revokeTransient(r),new vt("账号状态已改变。");let o;try{o=sr(await this.request("/session"))}catch(f){if(!(f instanceof vt&&f.status===401&&l===void 0))throw f;o={authenticated:!1,refreshRequired:!1,cloudTarget:null}}if(o.refreshRequired&&(o=sr(await this.cookieRequest("/refresh","POST",{},o.csrfToken))),(o.authenticated?o.session?.id:void 0)!==l)throw await this.revokeTransient(r),new vt("其他页面已切换账号,请刷新后重新发起登录。");if(!i())throw await this.revokeTransient(r),new vt("账号状态已改变。");const d=await this.fetcher(Wd+"/session",{method:"POST",credentials:"include",cache:"no-store",redirect:"error",signal:AbortSignal.timeout(1e4),headers:{"Content-Type":"application/json",Authorization:"Bearer "+r.accessToken},body:JSON.stringify({refreshToken:r.refreshToken})}),c=await d.json();if(!d.ok)throw yo(c,d.status,"/session");const h=sr(c);if(!h.authenticated||h.account?.id!==r.account.id||h.session?.id!==r.sessionId)throw new vt("账号登录结果不一致,请重新登录。");if(!i())throw this.setSession(h),await this.cookieRequest("/logout","POST",{}),this.setSession({authenticated:!1,refreshRequired:!1,cloudTarget:h.cloudTarget}),new vt("账号状态已改变。");return this.setSession(h),h})}async restoreSession(r=5e3){return ks(async()=>{let i=sr(await this.request("/session"));return(i.refreshRequired||i.authenticated&&i.session.expiresAt<=Date.now()+r)&&(i=sr(await this.cookieRequest("/refresh","POST",{},i.csrfToken))),i})}async logoutSession(){const r=this.rootId;return ks(async()=>{let i=sr(await this.request("/session"));if(i.refreshRequired){if(i.csrfToken!==this.csrfToken)throw new vt("其他页面已切换账号,请刷新后确认。");i=sr(await this.cookieRequest("/refresh","POST",{},i.csrfToken))}if(i.authenticated&&i.session?.id!==r)throw new vt("其他页面已切换账号,请刷新后确认。");if(this.setSession(i),i.authenticated&&(await this.cookieRequest("/logout","POST",{})).ok!==!0)throw new vt("服务端尚未确认退出,请重试。");return{authenticated:!1,refreshRequired:!1,cloudTarget:i.cloudTarget}})}async cookieRequest(r,i,l,o=this.csrfToken){const d=await this.fetcher(Wd+r,{method:i,credentials:"include",cache:"no-store",redirect:"error",signal:AbortSignal.timeout(1e4),headers:{...l===void 0?{}:{"Content-Type":"application/json"},"X-CodeShell-CSRF":o},body:l===void 0?void 0:JSON.stringify(l)}),c=await d.json();if(!d.ok)throw yo(c,d.status,r);if(c?.accessToken!==void 0||c?.refreshToken!==void 0)throw new vt("账号服务返回了不支持的授权结果。");return c}invalidate(){this.epoch++;for(const r of this.requests)r.abort();this.requests.clear()}async request(r,i="GET",l,o,d,c=0){if(!/^\/[A-Za-z0-9/?=&_-]+$/.test(r)||r.startsWith("//"))throw new vt("账号请求地址无效。");if(i!=="GET"&&!this.csrfToken)throw new vt("页面验证尚未完成,请刷新后重试。");if(i==="DELETE"&&/^\/sessions\/[0-9a-f-]{36}$/.test(r)){const b=this.rootId;return ks(async()=>{const v=sr(await this.request("/session"));if(!v.authenticated||v.session?.id!==b)throw new vt("账号状态已改变,请刷新后重试。");return this.setSession(v),this.cookieRequest(r,i)})}const h=this.epoch,f=this.rootId,p=new AbortController;this.requests.add(p);const y=AbortSignal.timeout(r==="/github/poll"?2e4:1e4);try{const b=await this.fetcher(Wd+r,{method:i,credentials:"include",cache:"no-store",redirect:"error",signal:AbortSignal.any([p.signal,y,...o?[o]:[]]),headers:{...l===void 0?{}:{"Content-Type":"application/json"},...this.csrfToken?{"X-CodeShell-CSRF":this.csrfToken}:{}},body:l===void 0?void 0:JSON.stringify(l)}),v=await b.json();if(d?.(v),h!==this.epoch||o?.aborted)throw new vt("账号状态已改变。");if(v?.accessToken!==void 0||v?.refreshToken!==void 0)throw new vt("账号服务返回了不支持的授权结果。");if(!b.ok){if(b.status===401&&c===0&&r!=="/session"&&r!=="/refresh"&&!r.startsWith("/github/")){const w=f;try{const j=await this.restoreSession();if(j.authenticated&&j.session?.id===w&&h===this.epoch&&this.rootId===f)return this.setSession(j),await this.request(r,i,l,o,d,1)}catch{}}throw h!==this.epoch||f!==this.rootId?new vt("账号状态已改变。"):(b.status===401&&r!=="/session"&&r!=="/refresh"&&!r.startsWith("/github/")&&this.onSessionLost?.(),yo(v,b.status,r))}return v}catch(b){throw b instanceof vt?b:h!==this.epoch||o?.aborted||p.signal.aborted?new vt("账号状态已改变。"):new vt(r==="/github/poll"&&(y.aborted||b?.name==="TimeoutError")?"等待 GitHub 登录验证超时,请重新发起授权。":"无法连接账号服务,请检查网络后重试。")}finally{this.requests.delete(p)}}}const Tx=x.createContext(null);function or(){const t=x.useContext(Tx);if(!t)throw new Error("Account session provider is missing");return t}function jA({children:t}){const r=x.useRef(null);r.current??=new SA;const i=r.current,[l,o]=x.useState(null),d=x.useRef(l);d.current=l;const[c,h]=x.useState(!1),[f,p]=x.useState(!1),y=x.useRef(!1),[b,v]=x.useState(""),[w,j]=x.useState(""),[N,C]=x.useState({registrationAllowed:!1,githubEnabled:!1}),[E,A]=x.useState(!1),D=x.useRef(null),L=x.useRef(0),J=x.useRef(!1),T=G=>J.current&&G===L.current,B=G=>{y.current=G,p(G)},U=G=>v(G instanceof Error?G.message:"请求失败,请稍后重试。"),X=G=>{const re=sr(G);i.setSession(re),o(re),d.current=re,h(!0)},_=G=>(G.popup.close(),G.mode==="link"&&(G.accountId!==d.current?.account?.id||G.rootId!==d.current?.session?.id)?Promise.resolve():(G.receipt&&!G.cleanup&&(G.cleanup=(G.mode==="login"?i.nativeRequest("/github/cancel",{receipt:G.receipt,codeVerifier:G.verifier}):i.request("/github/cancel","POST",{receipt:G.receipt,codeVerifier:G.verifier})).then(()=>{},()=>{})),G.cleanup??Promise.resolve())),I=()=>{const G=D.current;G&&(G.cancelled=!0,D.current=null,G.mode==="login"&&L.current++,_(G),A(!1),B(!1),v(""),j(G.mode==="link"?"已取消关联流程,可刷新连接状态确认。":"已取消登录。"))},H=x.useCallback(async()=>{if(y.current)return;const G=++L.current;B(!0),v("");try{const re=await i.restoreSession();T(G)&&X(re)}catch(re){T(G)&&(re instanceof vt&&re.status===401?X({authenticated:!1,refreshRequired:!1,cloudTarget:null}):h(!1),U(re))}finally{T(G)&&B(!1)}},[i]);x.useEffect(()=>{J.current=!0,i.onSessionLost=()=>{L.current++,i.invalidate();const be=d.current;if(be){const R={authenticated:!1,refreshRequired:!1,cloudTarget:be.cloudTarget};o(R),d.current=R,i.setSession(R)}j(""),v("登录已过期,请重新登录。"),B(!1)},H();const G=new AbortController;fetch("/api/v1/account/status",{credentials:"omit",cache:"no-store",redirect:"error",signal:G.signal}).then(async be=>{if(!be.ok)throw new Error("登录方式暂时无法读取。");const R=await be.json();if(typeof R.registrationAllowed!="boolean"||typeof R.githubEnabled!="boolean")throw new Error("登录方式数据无效。");G.signal.aborted||C({registrationAllowed:R.registrationAllowed,githubEnabled:R.githubEnabled})}).catch(()=>{});const re=()=>{D.current||H()};return window.addEventListener("focus",re),()=>{J.current=!1,L.current++,y.current=!1,D.current&&(D.current.cancelled=!0,_(D.current),D.current=null),i.invalidate(),G.abort(),window.removeEventListener("focus",re)}},[i,H]),x.useEffect(()=>{if(!l?.authenticated||!l.session)return;let G;const re=async()=>{if(y.current){G=setTimeout(re,1e3);return}const be=L.current;try{const R=await i.restoreSession(6e4);T(be)&&X(R)}catch(R){T(be)&&(R instanceof vt&&R.status===401?i.onSessionLost?.():U(R))}};return G=setTimeout(re,Math.max(1e3,l.session.expiresAt-Date.now()-6e4)),()=>clearTimeout(G)},[i,l]);const Y=async(G,re)=>{if(y.current||!c)return!1;const be=++L.current;i.invalidate(),B(!0),v(""),j("");try{const R=await i.nativeRequest("/"+G,{...re,deviceName:"CodeShell 网站"});if(!T(be))return i.revokeTransient(R),!1;try{const M=await i.exchangeGrant(R,()=>T(be));if(!T(be))return!1;X(M)}catch(M){throw i.revokeTransient(R),M}return!0}catch(R){return T(be)&&U(R),!1}finally{T(be)&&B(!1)}},$=async()=>{I();const G=++L.current;i.invalidate(),B(!0),v(""),j("");const re=d.current;if(re){const be={authenticated:!1,refreshRequired:!1,csrfToken:re.csrfToken,cloudTarget:re.cloudTarget};o(be),d.current=be}try{const be=await i.logoutSession();return T(G)&&X(be),!0}catch(be){return T(G)&&(h(!1),U(be)),!1}finally{T(G)&&B(!1)}},F=async G=>{if(y.current||!c||!N.githubEnabled||G==="link"&&!d.current?.authenticated)return;const re=window.open("about:blank","_blank");if(!re){v("请允许此页打开 GitHub 授权窗口后重试。");return}re.opener=null;const be=W=>btoa(String.fromCharCode(...W)).replaceAll("+","-").replaceAll("/","_").replaceAll("=",""),R={popup:re,mode:G,verifier:be(crypto.getRandomValues(new Uint8Array(32))),cancelled:!1,accountId:d.current?.account?.id,rootId:d.current?.session?.id};D.current=R;const M=d.current?.account?.id,te=G==="login"?++L.current:L.current,k=()=>T(te)&&D.current===R&&!R.cancelled&&(G!=="link"||d.current?.account?.id===M);B(!0),A(!0),v(""),j(G==="link"?"请在 GitHub 页面确认要关联的身份。":"请在 GitHub 页面完成登录,最终结果会显示在这里。");try{const W=be(new Uint8Array(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(R.verifier))));if(!k())return;const ue=oe=>{/^[A-Za-z0-9_-]{43}$/.test(oe?.receipt)&&(R.receipt=oe.receipt),R.cancelled&&_(R)},me=G==="login"?await i.nativeRequest("/github/start",{codeChallenge:W},ue):await i.request("/github/start","POST",{codeChallenge:W,mode:G},void 0,ue);if(!k())return;const Q=new URL(me.authorizationUrl);if(Q.origin!=="https://github.com"||Q.pathname!=="/login/oauth/authorize"||Q.username||Q.password||Q.hash||Q.searchParams.get("code_challenge")!==W||Q.searchParams.get("code_challenge_method")!=="S256"||Q.searchParams.get("scope")!=="read:user"||!R.receipt||!Number.isSafeInteger(me.expiresAt)||me.expiresAt<=Date.now()||me.expiresAt>Date.now()+9e5)throw new vt("GitHub 授权请求无效,请重新发起。");for(re.location.href=Q.href;Date.now()<me.expiresAt&&k();){const oe={receipt:me.receipt,codeVerifier:R.verifier,deviceName:"CodeShell 网站"},fe=G==="login"?await i.nativeRequest("/github/poll",oe):await i.request("/github/poll","POST",oe);if(!k()){fe?.accessToken&&i.revokeTransient(fe);return}if(fe.status!=="pending"){if(G==="link"){if(fe.linked!==!0||fe.account?.id!==M)throw new vt("GitHub 关联结果无效,请刷新后重试。");j("GitHub 登录身份已关联,数据授权保持独立。")}else try{const ke=await i.exchangeGrant(fe,k);k()&&(X(ke),j(""))}catch(ke){throw i.revokeTransient(fe),ke}return}await new Promise(ke=>setTimeout(ke,Math.min(1e4,Math.max(1e3,me.pollIntervalMs||1e3))))}if(k())throw new vt("GitHub 授权已超时,请重新发起。")}catch(W){k()&&(j(""),U(W))}finally{_(R),D.current===R&&(D.current=null,A(!1),T(te)&&B(!1))}},P=x.useCallback((...G)=>i.request(...G),[i]);return a.jsx(Tx.Provider,{value:{session:l,ready:c,busy:f,error:b,status:w,...N,oauthPending:E,restore:H,signIn:Y,logout:$,github:F,cancelGithub:I,clearError:()=>v(""),workspaceActive:G=>!y.current&&d.current?.authenticated===!0&&`${d.current.account.id}:${d.current.session.id}`===G,request:P},children:t})}function Uo(t){const{request:r}=or(),[i,l]=x.useState(),[o,d]=x.useState(""),[c,h]=x.useState(!!t),[f,p]=x.useState(0);return x.useEffect(()=>{const y=new AbortController;return l(void 0),d(""),h(!!t),t&&r(t,"GET",void 0,y.signal).then(b=>{y.signal.aborted||l(b)}).catch(b=>{y.signal.aborted||d(b.message)}).finally(()=>{y.signal.aborted||h(!1)}),()=>y.abort()},[t,r,f]),{value:i,error:o,loading:c,reload:()=>p(y=>y+1)}}function Ti({error:t,status:r}){return a.jsxs(a.Fragment,{children:[t?a.jsx("p",{className:"form-error",role:"alert",children:t}):null,r?a.jsx("p",{className:"website-notice",role:"status",children:r}):null]})}const Ro=t=>Number.isSafeInteger(t)&&t>=0?new Date(t).toLocaleString():"—",Nr=t=>typeof t=="string"&&/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(t);function kA({route:t}){const r=or(),i=Uo("/overview");let l,o="";if(i.value&&r.session?.account)try{l=Cx(i.value,r.session.account.id)}catch(c){o=c.message}const d=l?.capabilities.admin===!0&&r.session?.account?.role==="admin";return a.jsxs("section",{className:"website-settings-content",children:[a.jsx(Ti,{error:i.error||o}),i.loading?a.jsx("p",{role:"status",children:"正在读取账号设置…"}):null,i.error||o?a.jsx("button",{className:"website-button",onClick:i.reload,children:"重试读取"}):null,l&&t.kind==="account"?a.jsxs(a.Fragment,{children:[t.section==="profile"?a.jsx(EA,{profile:l.account},l.account.id):null,t.section==="security"?a.jsx(CA,{overview:l}):null,t.section==="sessions"?a.jsx(TA,{enabled:l.capabilities.sessions}):null,t.section==="connections"?a.jsx(NA,{overview:l,reload:i.reload}):null]}):null,l&&t.kind==="admin"?d?a.jsx(AA,{section:t.section}):a.jsx("p",{role:"alert",children:"当前账号没有管理员权限。"}):null]})}function EA({profile:t}){const r=or(),[i,l]=x.useState(t.displayName),[o,d]=x.useState(t.username),[c,h]=x.useState(!1),[f,p]=x.useState(""),[y,b]=x.useState(""),v=x.useRef(!0);x.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]);const w=async j=>{j.preventDefault();const N=i.trim().normalize("NFC"),C=o.trim().toLowerCase();if(!N||[...N].length>64||/[\p{Cc}\p{Cs}\u061c\u200b\u200e\u200f\u202a-\u202e\u2066-\u2069\ufeff]/u.test(N)){p("昵称须为 1–64 个字符,且不能包含控制字符。");return}if(!/^[a-z0-9][a-z0-9._-]{2,63}$/i.test(C)){p("用户名须为 3–64 位字母、数字、点、下划线或连字符。");return}const E={...N===t.displayName?{}:{displayName:N},...C===t.username?{}:{username:C}};if(!(c||!Object.keys(E).length)){h(!0),p(""),b("");try{if((await r.request("/profile","PATCH",E)).account?.id!==t.id)throw new vt("账号资料结果无效,请刷新后重试。");await r.restore(),v.current&&b("账号资料已保存。")}catch(A){v.current&&p(A.message)}finally{v.current&&h(!1)}}};return a.jsxs(a.Fragment,{children:[a.jsx(Fl,{title:"账号资料",description:"昵称用于显示,用户名用于密码登录,分别修改。"}),a.jsxs("form",{className:"website-settings-card",onSubmit:j=>{w(j)},children:[a.jsxs("label",{children:["昵称",a.jsx("input",{autoComplete:"nickname",value:i,maxLength:128,disabled:c,onChange:j=>l(j.target.value)})]}),a.jsxs("label",{children:["登录用户名",a.jsx("input",{autoComplete:"username",value:o,maxLength:64,disabled:c,onChange:j=>d(j.target.value)}),a.jsx("small",{children:"修改用户名后,请使用新的用户名登录。昵称不会自动变化。"})]}),a.jsx("button",{className:"website-button primary",type:"submit",disabled:c,children:c?"保存中…":"保存修改"}),a.jsx(Ti,{error:f,status:y})]})]})}function Fl({title:t,description:r}){return a.jsxs("header",{className:"website-settings-heading",children:[a.jsx("p",{className:"website-eyebrow",children:"设置"}),a.jsx("h1",{children:t}),a.jsx("p",{className:"website-muted",children:r})]})}function CA({overview:t}){const{request:r}=or(),[i,l]=x.useState(""),[o,d]=x.useState(""),[c,h]=x.useState(""),[f,p]=x.useState(!1),[y,b]=x.useState(""),[v,w]=x.useState(""),j=x.useRef(void 0);x.useEffect(()=>()=>j.current?.abort(),[]);const N=async C=>{if(C.preventDefault(),f||!t.capabilities.passwordChange)return;if(b(""),o.length<12||o.length>1024){b("新密码须为 12–1024 个字符。");return}if(o!==c){b("两次输入的新密码不一致。");return}if(!window.confirm("修改密码后,其他登录会话及其设备授权将退出。继续修改吗?"))return;const E=new AbortController;j.current=E,p(!0),w("");try{await r("/password","POST",{currentPassword:i,newPassword:o},E.signal),E.signal.aborted||(l(""),d(""),h(""),w("密码已修改,其他登录会话已退出。"))}catch(A){E.signal.aborted||b(A.message)}finally{E.signal.aborted||p(!1)}};return a.jsxs(a.Fragment,{children:[a.jsx(Fl,{title:"安全",description:"管理密码与账号登录方式。"}),a.jsxs("div",{className:"website-settings-card",children:[a.jsx("h2",{children:"密码"}),t.capabilities.passwordChange?a.jsxs("form",{onSubmit:C=>{N(C)},children:[a.jsxs("label",{children:["当前密码",a.jsx("input",{type:"password",autoComplete:"current-password",maxLength:1024,value:i,disabled:f,onChange:C=>l(C.target.value),required:!0})]}),a.jsxs("label",{children:["新密码",a.jsx("input",{type:"password",autoComplete:"new-password",maxLength:1024,value:o,disabled:f,onChange:C=>d(C.target.value),required:!0})]}),a.jsxs("label",{children:["确认新密码",a.jsx("input",{type:"password",autoComplete:"new-password",maxLength:1024,value:c,disabled:f,onChange:C=>h(C.target.value),required:!0})]}),a.jsx("button",{className:"website-button",disabled:f,type:"submit",children:"修改密码"})]}):a.jsx("p",{className:"website-muted",children:"此账号使用 GitHub 登录,尚未设置密码。请继续使用 GitHub。"}),a.jsx(Ti,{error:y,status:v})]})]})}function TA({enabled:t}){const r=or(),i=Uo(t?"/sessions":null),[l,o]=x.useState(!1),[d,c]=x.useState(""),h=x.useRef(!0);x.useEffect(()=>(h.current=!0,()=>{h.current=!1}),[]);const f=async y=>{if(!(l||!window.confirm(y?.current?"退出当前登录?未发送内容会被清除。":y?"退出此登录会话?其派生设备授权也会撤销。":"退出其他所有登录会话及其设备授权?"))){o(!0),c("");try{await r.request(y?`/sessions/${y.id}`:"/sessions/revoke-others",y?"DELETE":"POST",y?void 0:{}),y?.current?await r.restore():h.current&&i.reload()}catch(b){h.current&&c(b.message)}finally{h.current&&o(!1)}}},p=i.value&&Array.isArray(i.value.sessions)&&i.value.sessions.length<=64&&i.value.sessions.every(y=>Nr(y.id)&&typeof y.deviceName=="string"&&typeof y.current=="boolean"&&Number.isSafeInteger(y.expiresAt));return a.jsxs(a.Fragment,{children:[a.jsx(Fl,{title:"登录会话",description:"查看账号的有效登录,退出不再使用的设备或浏览器。"}),t?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"website-action-row",children:[a.jsx("button",{className:"website-button",disabled:l,onClick:i.reload,children:"刷新"}),a.jsx("button",{className:"website-button",disabled:l,onClick:()=>{f()},children:"退出其他会话"})]}),a.jsx(Ti,{error:d||i.error||(i.value&&!p?"会话列表数据无效,请刷新后重试。":"")}),i.loading?a.jsx("p",{role:"status",children:"正在读取登录会话…"}):null,p?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"website-hint",children:i.value.hasMore?`显示最近 ${i.value.sessions.length} 个登录会话,共 ${i.value.total} 个。`:`共 ${i.value.total??i.value.sessions.length} 个有效登录。`}),a.jsx("div",{className:"website-list",children:i.value.sessions.map(y=>a.jsxs("article",{children:[a.jsxs("div",{children:[a.jsx("strong",{children:y.deviceName}),y.current?a.jsx("span",{className:"website-tag",children:"当前登录"}):null,a.jsxs("p",{children:["创建于 ",Ro(y.createdAt)," · 有效期至 ",Ro(y.expiresAt)]})]}),a.jsx("button",{className:"website-button",disabled:l,onClick:()=>{f(y)},children:"退出"})]},y.id))})]}):null]}):a.jsx("p",{children:"当前服务尚未开放登录会话管理。"})]})}function NA({overview:t,reload:r}){const i=or(),l=Uo(t.capabilities.links?"/links":null),[o,d]=x.useState(""),[c,h]=x.useState(!1),f=x.useRef(void 0);x.useEffect(()=>()=>f.current?.abort(),[]);const p=async(v,w)=>{if(c||!window.confirm(v==="connections"?"撤销这个数据连接及相关授权?":"撤销这个工具授权?"))return;const j=new AbortController;f.current=j,h(!0),d("");try{if((await i.request(`/links/${v}/${w}`,"DELETE",void 0,j.signal)).revoked!==!0)throw new vt("数据授权撤销尚未确认,请刷新后重试。");j.signal.aborted||l.reload()}catch(N){j.signal.aborted||d(N.message)}finally{j.signal.aborted||h(!1)}},y=l.value&&Array.isArray(l.value.connections)&&l.value.connections.length<=512&&Array.isArray(l.value.grants)&&l.value.grants.length<=4096&&l.value.connections.every(v=>Nr(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"))&&l.value.grants.every(v=>Nr(v.id)&&Nr(v.connectionId)&&typeof v.client?.name=="string"&&typeof v.revoked=="boolean"&&Array.isArray(v.scopes)&&v.scopes.every(w=>typeof w=="string")&&Array.isArray(v.resources)&&v.resources.every(w=>typeof w=="string")),b=y?[...l.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} · 数据连接`})),...l.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 a.jsxs(a.Fragment,{children:[a.jsx(Fl,{title:"连接",description:"GitHub 登录身份与工具的数据访问授权分别管理。"}),a.jsxs("div",{className:"website-settings-card",children:[a.jsxs("div",{className:"website-setting-line",children:[a.jsxs("div",{children:[a.jsx("h2",{children:"GitHub 登录身份"}),a.jsx("p",{className:"website-muted",children:"用于登录 CodeShell,不代表已授权仓库访问。"})]}),a.jsx("span",{className:"website-tag",children:t.security.githubLinked?"已关联":"未关联"})]}),!t.security.githubLinked&&i.githubEnabled?a.jsx("button",{className:"website-button",disabled:i.busy,onClick:()=>{i.github("link").then(r)},children:"关联 GitHub 登录身份"}):null,i.oauthPending?a.jsx("button",{className:"website-button",onClick:i.cancelGithub,children:"取消关联"}):null,a.jsx("button",{className:"ghost",disabled:i.busy,onClick:r,children:"刷新登录方式"}),a.jsx(Ti,{error:i.error,status:i.status})]}),a.jsx("h2",{children:"Link 数据连接"}),t.capabilities.links?a.jsxs(a.Fragment,{children:[a.jsx("button",{className:"website-button",disabled:c,onClick:l.reload,children:"刷新数据连接"}),a.jsx(Ti,{error:o||l.error||(l.value&&!y?"数据连接列表无效,请刷新后重试。":"")}),y?a.jsxs("div",{className:"website-list",children:[b.map(v=>a.jsxs("article",{children:[a.jsxs("div",{children:[a.jsx("strong",{children:v.title}),a.jsx("p",{children:v.description})]}),a.jsx("button",{className:"website-button",disabled:c,onClick:()=>{p(v.kind,v.id)},children:"撤销"})]},`${v.kind}:${v.id}`)),b.length?null:a.jsx("p",{className:"website-muted",children:"还没有数据连接。"})]}):null]}):a.jsx("p",{className:"website-muted",children:"当前服务尚未开放数据连接管理。"}),a.jsx("p",{className:"website-hint",children:"退出登录不会自动撤销已有 Link 数据授权。"})]})}function AA({section:t}){const r=or(),[i,l]=x.useState(null),o=Uo(t==="summary"?"/admin/summary":`/admin/${t}?limit=30${i?`&cursor=${i}`:""}`),[d,c]=x.useState(!1),[h,f]=x.useState(""),p=x.useRef(void 0);x.useEffect(()=>()=>p.current?.abort(),[]);const y=async(C,E=!1)=>{if(d||!window.confirm(E?`退出 ${C.username} 的所有登录会话?`:`${C.disabled?"恢复":"停用"}账号 ${C.username}?`))return;const A=new AbortController;p.current=A,c(!0),f("");try{await r.request(`/admin/users/${C.id}${E?"/revoke-sessions":""}`,E?"POST":"PATCH",E?{}:{disabled:!C.disabled},A.signal),A.signal.aborted||o.reload()}catch(D){A.signal.aborted||(f(D.message),D instanceof vt&&D.status===403&&r.restore())}finally{A.signal.aborted||c(!1)}},b=Nr(o.value?.nextCursor)?o.value.nextCursor:null,v=o.value?.nextCursor===null||Nr(o.value?.nextCursor),w=t==="users"&&Array.isArray(o.value?.users)&&o.value.users.length<=30&&v&&o.value.users.every(C=>eh(C)&&typeof C.disabled=="boolean"&&Number.isSafeInteger(C.createdAt)&&C.createdAt>=0&&Number.isSafeInteger(C.sessionCount)&&C.sessionCount>=0)?o.value.users:null,j=t==="audit"&&Array.isArray(o.value?.events)&&o.value.events.length<=30&&v&&o.value.events.every(C=>Nr(C.id)&&Nr(C.actorId)&&Nr(C.targetId)&&["admin.account.disabled","admin.account.enabled","admin.sessions.revoked"].includes(C.action))?o.value.events:null,N=t==="summary"&&o.value?.users&&[o.value.users.total,o.value.users.active,o.value.users.disabled,o.value.users.administrators,o.value.sessions?.active,o.value.auditEvents].every(C=>Number.isSafeInteger(C)&&C>=0)?o.value:null;return a.jsxs(a.Fragment,{children:[a.jsx(Fl,{title:t==="users"?"用户管理":t==="summary"?"系统统计":"操作记录",description:"管理员控制台 · 权限由服务端核验。"}),a.jsx("button",{className:"website-button",disabled:d,onClick:()=>{l(null),o.reload()},children:"刷新"}),a.jsx(Ti,{error:h||o.error}),o.loading?a.jsx("p",{role:"status",children:"正在读取…"}):null,w?a.jsx("div",{className:"website-list",children:w.map(C=>a.jsxs("article",{children:[a.jsxs("div",{children:[a.jsx("strong",{children:C.displayName}),a.jsxs("p",{children:["@",C.username," · ",C.role==="admin"?"管理员":"成员"," ·"," ",C.disabled?"已停用":"正常"]}),a.jsxs("p",{children:[C.sessionCount," 个登录会话 · 创建于 ",Ro(C.createdAt)]})]}),a.jsxs("div",{className:"website-action-row",children:[C.role!=="admin"&&C.id!==r.session?.account?.id?a.jsx("button",{className:"website-button",disabled:d,onClick:()=>{y(C)},children:C.disabled?"恢复":"停用"}):null,a.jsx("button",{className:"website-button",disabled:d,onClick:()=>{y(C,!0)},children:"退出会话"})]})]},C.id))}):null,j?a.jsxs("div",{className:"website-list",children:[j.map(C=>a.jsx("article",{children:a.jsxs("div",{children:[a.jsx("strong",{children:{"admin.account.disabled":"停用账号","admin.account.enabled":"恢复账号","admin.sessions.revoked":"撤销登录会话"}[C.action]}),a.jsxs("p",{children:["操作人 ",C.actorId," · 目标 ",C.targetId]}),a.jsx("p",{children:Ro(C.createdAt)})]})},C.id)),j.length?null:a.jsx("p",{className:"website-muted",children:"暂无操作记录。"})]}):null,N?a.jsx("div",{className:"website-statistics",children:[["账号总数",N.users.total],["正常账号",N.users.active],["停用账号",N.users.disabled],["管理员",N.users.administrators],["有效登录",N.sessions.active],["审计事件",N.auditEvents]].map(([C,E])=>a.jsxs("article",{children:[a.jsx("span",{children:C}),a.jsx("strong",{children:E})]},C))}):null,o.value&&!w&&!j&&!N?a.jsx("p",{role:"alert",children:"管理员数据无效,请刷新后重试。"}):null,b?a.jsx("button",{className:"website-button",disabled:d||o.loading,onClick:()=>l(b),children:"下一页"}):null]})}function RA(){const t=or(),[r,i]=x.useState(!1),[l,o]=x.useState(""),[d,c]=x.useState(""),[h,f]=x.useState(""),[p,y]=x.useState(""),[b,v]=x.useState(""),w=async j=>{if(j.preventDefault(),v(""),!/^[a-z0-9][a-z0-9._-]{2,63}$/i.test(l.trim())){v("用户名须为 3–64 位字母、数字、点、下划线或连字符。");return}if(h.length<12||h.length>1024){v("密码须为 12–1024 个字符。");return}if(r&&h!==p){v("两次输入的密码不一致。");return}const N=d.trim().normalize("NFC");if(r&&(!N||[...N].length>64||/[\p{Cc}\p{Cs}]/u.test(N))){v("昵称须为 1–64 个字符,且不能包含控制字符。");return}await t.signIn(r?"register":"login",{username:l.trim().toLowerCase(),password:h,...r?{displayName:N}:{}})&&(f(""),y(""))};return a.jsxs("main",{className:"website-login",children:[a.jsxs("header",{className:"website-brand",children:["CodeShell ",a.jsx("span",{children:"工作台"})]}),a.jsxs("div",{className:"website-welcome",children:[a.jsxs("section",{className:"website-introduction",children:[a.jsx("p",{className:"website-eyebrow",children:"给想法一个开始"}),a.jsxs("h1",{children:["从一句话,",a.jsx("br",{}),"到真正完成。"]}),a.jsxs("p",{children:["与 CodeShell 对话,让 Agent 帮你处理任务。",a.jsx("br",{}),"项目、工具与历史记录,都在你的工作空间。"]}),a.jsxs("div",{className:"website-features",children:[a.jsxs("p",{children:[a.jsx("strong",{children:"继续你的工作"}),a.jsx("span",{children:"随时回到对话、任务和项目文件。"})]}),a.jsxs("p",{children:[a.jsx("strong",{children:"选择执行环境"}),a.jsx("span",{children:"任务在你选定的工作区里运行。"})]}),a.jsxs("p",{children:[a.jsx("strong",{children:"按需连接工具"}),a.jsx("span",{children:"GitHub 登录身份与数据访问授权分别管理。"})]})]})]}),a.jsxs("section",{className:"auth-card website-auth","aria-labelledby":"website-login-title",children:[a.jsx("p",{className:"website-eyebrow",children:"欢迎来到 CodeShell"}),a.jsx("h2",{id:"website-login-title",children:r?"创建你的账号":"继续你的工作"}),a.jsx("p",{className:"website-muted",children:"登录后进入你的工作台。"}),a.jsx("button",{className:"website-button website-wide",disabled:t.busy||!t.githubEnabled,onClick:()=>{t.github("login")},children:"使用 GitHub 继续"}),a.jsx("p",{className:"website-hint",children:"首次使用 GitHub 登录会按服务设置创建账号。"}),a.jsx("div",{className:"website-divider",children:"或使用用户名和密码"}),a.jsxs("form",{onSubmit:j=>{w(j)},children:[r?a.jsxs("label",{children:["昵称",a.jsx("input",{maxLength:128,autoComplete:"nickname",value:d,disabled:t.busy,onChange:j=>c(j.target.value),placeholder:"显示给你的名字",required:!0})]}):null,a.jsxs("label",{children:["用户名",a.jsx("input",{maxLength:64,autoComplete:"username",value:l,disabled:t.busy,onChange:j=>o(j.target.value),required:!0})]}),a.jsxs("label",{children:["密码",a.jsx("input",{type:"password",maxLength:1024,autoComplete:r?"new-password":"current-password",value:h,disabled:t.busy,onChange:j=>f(j.target.value),required:!0})]}),r?a.jsxs("label",{children:["确认密码",a.jsx("input",{type:"password",maxLength:1024,autoComplete:"new-password",value:p,disabled:t.busy,onChange:j=>y(j.target.value),required:!0})]}):null,a.jsx("button",{className:"send website-wide",disabled:t.busy||!t.ready,type:"submit",children:t.busy?"正在连接…":r?"创建账号":"登录"})]}),t.registrationAllowed?a.jsx("button",{className:"ghost website-wide",disabled:t.busy,onClick:()=>{i(!r),y(""),v(""),t.clearError()},children:r?"已有账号?登录":"没有账号?创建账号"}):null,t.oauthPending?a.jsx("button",{className:"ghost website-wide",onClick:t.cancelGithub,children:"取消 GitHub 授权"}):null,t.status?a.jsx("p",{role:"status",className:"website-hint",children:t.status}):null,b||t.error?a.jsx("p",{role:"alert",className:"form-error",children:b||t.error}):null,!t.ready&&!t.busy?a.jsx("button",{className:"website-button",onClick:()=>{t.restore()},children:"重试连接"}):null]})]}),a.jsx("footer",{className:"website-login-footer",children:"CodeShell · 让工作继续"})]})}async function zA(t=globalThis.fetch,r){const i=await t("/api/v1/cloud-browser/capabilities",{credentials:"omit",cache:"no-store",redirect:"error",signal:r});if(i.status===404)return null;if(!i.ok)throw new Error("暂时无法确认工作台登录方式,请重试。");const l=await i.json();if(l?.version!==1||l?.mode!=="cloud-browser"||!th(l))throw new Error("工作台返回了无效的登录配置,请联系管理员。");return{...l,version:1,mode:"cloud-browser"}}function _A(t,r,i){return kf(i)&&th(r)&&t.cloudOrigin===i&&r.cloudOrigin===i&&t.accountOrigin===i&&r.accountOrigin===i&&t.installationId===r.installationId}function MA(t,r,i){const l=t,o=l?.session,d=/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/;if(l?.authenticated!==!0||l.mode!=="cloud-account"||!o||o.kind!=="cloud-management"||o.accountId!==i||o.accountOrigin!==r.accountOrigin||o.audience!==r.cloudOrigin||o.installationId!==r.installationId||![o.id,o.accountId,o.managementEpoch].every(c=>d.test(c))||!Number.isSafeInteger(o.expiresAt)||o.expiresAt<=Date.now())throw new Error("工作区登录与当前账号不一致,请重新连接。");return o}async function DA(t,r=globalThis.fetch){await ks(async()=>{const i={credentials:"include",cache:"no-store",redirect:"error"},l=await r("/api/v1/cloud-browser/status",{...i,signal:AbortSignal.timeout(1e4)});if(!l.ok)return;const o=await l.json();o?.authenticated!==!0||o.mode!=="cloud-account"||o.session?.id!==t.id||o.session?.accountId!==t.accountId||o.session?.managementEpoch!==t.managementEpoch||o.session?.audience!==t.audience||await r("/api/v1/cloud-browser/logout",{...i,method:"POST",signal:AbortSignal.timeout(1e4),headers:{"Content-Type":"application/json"},body:"{}"})})}function OA({setupToken:t}){const[r,i]=x.useState(),[l,o]=x.useState(""),[d,c]=x.useState(0);return x.useEffect(()=>{const h=new AbortController;return o(""),zA(globalThis.fetch,h.signal).then(f=>{h.signal.aborted||i(f)}).catch(f=>{h.signal.aborted||o(f instanceof Error?f.message:"无法连接工作台,请重试。")}),()=>h.abort()},[d]),r===null?a.jsx(wA,{setupToken:t}):r?a.jsx(jA,{children:a.jsx(LA,{capability:r})}):a.jsx("main",{className:"auth-page",children:a.jsxs("section",{className:"auth-card",children:[a.jsx("h1",{children:"CodeShell"}),l?a.jsxs(a.Fragment,{children:[a.jsx("p",{role:"alert",className:"form-error",children:l}),a.jsx("button",{className:"send",onClick:()=>c(h=>h+1),children:"重试连接"})]}):a.jsx("p",{role:"status",children:"正在连接工作台…"})]})})}function Fb({go:t,logout:r}){const i=or(),l=i.session?.account;return a.jsxs("details",{className:"website-account-menu",children:[a.jsx("summary",{"aria-label":"打开账号菜单",children:a.jsx("span",{"aria-hidden":"true",children:(l?.displayName||"C").slice(0,1)})}),a.jsxs("div",{className:"website-account-popover",children:[a.jsx("strong",{children:l?.displayName}),a.jsxs("small",{children:["@",l?.username]}),a.jsx("button",{onClick:o=>{o.currentTarget.closest("details")?.removeAttribute("open"),t({kind:"account",section:"profile"})},children:"账号设置"}),a.jsx("button",{onClick:o=>{o.currentTarget.closest("details")?.removeAttribute("open"),t({kind:"account",section:"connections"})},children:"连接"}),l?.role==="admin"?a.jsx("button",{onClick:()=>t({kind:"admin",section:"users"}),children:"管理控制台"}):null,a.jsx("button",{disabled:i.busy,onClick:r,children:"退出登录"})]})]})}function LA({capability:t}){const r=or(),[i,l]=x.useState(()=>Ib(new URL(window.location.href))),[o,d]=x.useState(null),[c,h]=x.useState(""),[f,p]=x.useState(!1),[y,b]=x.useState(0),v=x.useRef(0),w=r.session?.authenticated?`${r.session.account.id}:${r.session.session.id}`:null,j=o?.identity===w?o.session:null,N=r.session?.cloudTarget,C=r.session?.account?.id,E=T=>{window.history.pushState(null,"",nA(T,new URL(window.location.href))),l(T),r.clearError(),r.oauthPending&&r.cancelGithub()};x.useEffect(()=>{const T=()=>{l(Ib(new URL(window.location.href))),r.oauthPending&&r.cancelGithub()};return window.addEventListener("popstate",T),()=>window.removeEventListener("popstate",T)},[r.oauthPending]),x.useEffect(()=>{const T=++v.current,B=new AbortController;if(d(null),h(""),p(!1),!w||!C)return()=>B.abort();if(!N)return h("当前账号尚未分配云端环境。你仍可管理账号设置。"),()=>B.abort();if(!_A(t,N,window.location.origin))return h("云端环境与账号服务配置不一致,请联系管理员。"),()=>B.abort();let U;const X=async()=>{if(!(B.signal.aborted||T!==v.current)){p(!0),h("");try{const _=await r.request("/cloud-tickets","POST",{},B.signal);if(!/^[A-Za-z0-9_-]{43}$/.test(_.ticket)||!Number.isSafeInteger(_.expiresAt)||_.expiresAt<=Date.now()||_.expiresAt>Date.now()+61e3||_.cloudOrigin!==N.cloudOrigin||_.accountOrigin!==N.accountOrigin||_.installationId!==N.installationId)throw new Error("云端授权目标无效,请联系管理员。");const I=await ks(async()=>{if(B.signal.aborted||T!==v.current)throw new Error("账号状态已改变。");const H=sr(await r.request("/session"));if(!H.authenticated||`${H.account.id}:${H.session.id}`!==w)throw r.restore(),new Error("其他页面已切换账号,请重新连接。");const Y=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:_.ticket})});if(!Y.ok)throw new Error("云端工作区登录未完成,请重试连接。");const $=MA(await Y.json(),N,C);if(B.signal.aborted||T!==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 $});!B.signal.aborted&&T===v.current&&(d({session:I,identity:w}),U=setTimeout(()=>{X()},Math.max(1e3,I.expiresAt-Date.now()-3e4)))}catch(_){!B.signal.aborted&&T===v.current&&(d(null),h(_ instanceof Error?_.message:"无法连接云端工作区,请重试。"))}finally{!B.signal.aborted&&T===v.current&&p(!1)}}};return X(),()=>{B.abort(),clearTimeout(U)}},[w,N?.cloudOrigin,N?.installationId,N?.accountOrigin,t,r.request,y]);const A=()=>{const T=j;v.current++,d(null),r.logout().then(B=>{if(B&&T)return DA(T)}).catch(()=>{})};if(!r.session?.authenticated)return a.jsx(RA,{});const D=a.jsx(Fb,{go:E,logout:A}),L=i.kind!=="workbench",J=r.session.account?.role==="admin";return a.jsxs(Wb.Provider,{value:"/api/v1/cloud-browser/environment",children:[j?a.jsx("div",{hidden:L,className:"website-workbench-root",children:a.jsx(Ex,{allowLegacy:!1,autoEnterSingle:!0,startCreatedProject:!0,canRequest:()=>r.workspaceActive(w),onAuthLost:()=>{d(null),b(T=>T+1)},accountControl:D,children:(T,B)=>a.jsx(Sf,{hub:!0,onAuthLost:()=>{d(null),b(U=>U+1)},projectName:T?.name,onBackToProjects:B,cloudAccount:{pending:r.busy,error:"",onLogout:A,accountOrigin:N?.accountOrigin},renderAccountControl:U=>a.jsx(Fb,{go:E,logout:()=>U.guard(A)})})},w)}):L?null:a.jsxs("main",{className:"website-environment-empty",children:[a.jsxs("header",{className:"website-brand",children:["CodeShell ",D]}),a.jsxs("section",{children:[a.jsx("p",{className:"website-eyebrow",children:"你的工作台"}),a.jsx("h1",{children:f?"正在打开工作空间…":"连接你的工作空间"}),a.jsx("p",{role:c?"alert":"status",className:c?"form-error":"website-muted",children:c||"正在验证账号与云端环境。"}),c?a.jsx("button",{className:"website-button",onClick:()=>b(T=>T+1),children:"重新连接"}):null,a.jsx("button",{className:"ghost",onClick:()=>E({kind:"account",section:"profile"}),children:"账号设置"})]})]}),L?a.jsxs("div",{className:"website-settings-shell",children:[a.jsxs("aside",{className:"website-settings-nav",children:[a.jsx("button",{className:"website-back",onClick:()=>E({kind:"workbench"}),children:"← 返回工作台"}),a.jsx("p",{className:"website-eyebrow",children:"账号设置"}),a.jsx("nav",{"aria-label":"账号设置",children:[["profile","账号资料"],["security","安全"],["sessions","登录会话"],["connections","连接"]].map(([T,B])=>a.jsx("button",{"aria-current":i.kind==="account"&&i.section===T?"page":void 0,onClick:()=>E({kind:"account",section:T}),children:B},T))}),J?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"website-eyebrow",children:"管理控制台"}),a.jsx("nav",{"aria-label":"管理控制台",children:[["users","用户管理"],["summary","系统统计"],["audit","操作记录"]].map(([T,B])=>a.jsx("button",{"aria-current":i.kind==="admin"&&i.section===T?"page":void 0,onClick:()=>E({kind:"admin",section:T}),children:B},T))})]}):null,a.jsx("div",{className:"website-settings-avatar",children:D})]}),a.jsx("main",{children:a.jsx(kA,{route:i},`${w}:${i.kind}:${i.section}`)})]}):null]})}function IA(t="/"){"serviceWorker"in navigator&&window.isSecureContext&&navigator.serviceWorker.register(`${t}sw.js`).catch(()=>{})}const $b=nw(),BA=F1(window.location,window.history);uw.createRoot(document.getElementById("root")).render(a.jsx(x.StrictMode,{children:$b?a.jsx(rw,{callback:$b}):a.jsx(OA,{setupToken:BA})}));IA("/");
|